"use strict";(()=>{var e={};e.id=4757,e.ids=[4757,2331],e.modules={53524:e=>{e.exports=require("@prisma/client")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},4742:(e,i,s)=>{s.r(i),s.d(i,{originalPathname:()=>w,patchFetch:()=>x,requestAsyncStorage:()=>g,routeModule:()=>c,serverHooks:()=>y,staticGenerationAsyncStorage:()=>_});var t={};s.r(t),s.d(t,{GET:()=>p});var a=s(49303),r=s(88716),n=s(60670),o=s(87070),m=s(72331);function l(e){return e?new Date(e).toLocaleString("id-ID",{timeZone:"Asia/Jakarta"}):"-"}function d(e){let i=null==e?"":String(e);return i.includes(",")||i.includes('"')||i.includes("\n")?`"${i.replace(/"/g,'""')}"`:i}let u={daily:"Harian",weekly:"Mingguan",special:"Spesial"};async function p(e){try{let i;let{searchParams:s}=new URL(e.url),t=parseInt(s.get("page")??"1"),a=parseInt(s.get("limit")??"20"),r="csv"===s.get("export"),n=s.get("user_id_search"),p=s.get("mission_id"),c=s.get("mission_type"),g="false"!==s.get("claimed"),_=s.get("date_from"),y=s.get("date_to"),w=r?0:(t-1)*a,x=r?1e4:a;if(n){let e=await m.prisma.user.findFirst({where:{userId:{contains:n}},select:{id:!0}});i=e?.id}let f={};i?f.userId=i:n&&(f.userId="not-found"),p&&(f.missionId=parseInt(p)),g&&(f.isClaimed=!0),c&&(f.mission={type:c}),(_||y)&&(f.claimedAt={},_&&(f.claimedAt.gte=new Date(_+"T00:00:00+07:00")),y&&(f.claimedAt.lte=new Date(y+"T23:59:59+07:00")));let[h,C]=await Promise.all([m.prisma.userMission.findMany({where:f,include:{user:{select:{id:!0,userId:!0,premiumTier:!0,totalCoins:!0}},mission:{select:{id:!0,title:!0,type:!0,rewardCoins:!0,requirementType:!0,requirementValue:!0}}},orderBy:{claimedAt:"desc"},skip:w,take:x}),m.prisma.userMission.count({where:f})]),I=h.map(e=>({id:e.id,user:{id:e.user.id,user_id:e.user.userId,premium_tier:e.user.premiumTier,total_coins:e.user.totalCoins},mission:{id:e.mission.id,title:e.mission.title,type:e.mission.type,type_label:u[e.mission.type]??e.mission.type,reward_coins:e.mission.rewardCoins,requirement_type:e.mission.requirementType,requirement_value:e.mission.requirementValue},progress:e.progress,is_completed:e.isCompleted,is_claimed:e.isClaimed,completed_at:e.completedAt,claimed_at:e.claimedAt,expires_at:e.expiresAt})),v=(await m.prisma.userMission.findMany({where:f,include:{mission:{select:{rewardCoins:!0}}}})).reduce((e,i)=>e+(i.isClaimed?i.mission.rewardCoins:0),0);if(r){let e=I.map(e=>[e.id,e.user.user_id,e.user.premium_tier,e.mission.title,e.mission.type_label,e.mission.reward_coins,e.progress,e.is_completed?"Ya":"Tidak",e.is_claimed?"Ya":"Tidak",l(e.claimed_at),l(e.expires_at)]),i=[["ID","User ID","Premium","Judul Misi","Tipe Misi","Reward Koin","Progress","Selesai","Diklaim","Waktu Klaim (WIB)","Kadaluarsa (WIB)"],...e].map(e=>e.map(d).join(",")).join("\r\n");return new o.NextResponse(i,{headers:{"Content-Type":"text/csv; charset=utf-8","Content-Disposition":`attachment; filename="klaim-misi-${new Date().toISOString().slice(0,10)}.csv"`}})}return o.NextResponse.json({success:!0,data:I,summary:{total_claims:C,total_coins_awarded:v},pagination:{page:t,limit:a,total:C,total_pages:Math.ceil(C/a)}})}catch(e){return console.error("Admin mission claims GET error:",e),o.NextResponse.json({success:!1,message:"Gagal memuat data klaim misi"},{status:500})}}let c=new a.AppRouteRouteModule({definition:{kind:r.x.APP_ROUTE,page:"/api/admin/missions/claims/route",pathname:"/api/admin/missions/claims",filename:"route",bundlePath:"app/api/admin/missions/claims/route"},resolvedPagePath:"C:\\xampp\\htdocs\\Bolafest\\app\\api\\admin\\missions\\claims\\route.ts",nextConfigOutput:"standalone",userland:t}),{requestAsyncStorage:g,staticGenerationAsyncStorage:_,serverHooks:y}=c,w="/api/admin/missions/claims/route";function x(){return(0,n.patchFetch)({serverHooks:y,staticGenerationAsyncStorage:_})}},72331:(e,i,s)=>{s.d(i,{prisma:()=>a});var t=s(53524);let a=globalThis.prisma??new t.PrismaClient({log:["error"]})}};var i=require("../../../../../webpack-runtime.js");i.C(e);var s=e=>i(i.s=e),t=i.X(0,[9276,5972],()=>s(4742));module.exports=t})();