"use strict";(()=>{var e={};e.id=6622,e.ids=[6622,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")},61653:(e,s,t)=>{t.r(s),t.d(s,{originalPathname:()=>y,patchFetch:()=>h,requestAsyncStorage:()=>c,routeModule:()=>l,serverHooks:()=>g,staticGenerationAsyncStorage:()=>d});var i={};t.r(i),t.d(i,{GET:()=>m,POST:()=>p});var a=t(49303),r=t(88716),n=t(60670),o=t(87070),u=t(72331);async function m(e){try{let{searchParams:s}=new URL(e.url),t=Math.max(1,parseInt(s.get("page")||"1")),i=Math.min(50,parseInt(s.get("limit")||"20")),a=s.get("type")||"",r=s.get("search")||"",n=(t-1)*i,m={};a&&(m.type=a),r&&(m.OR=[{title:{contains:r}},{description:{contains:r}}]);let[p,l]=await Promise.all([u.prisma.mission.findMany({where:m,orderBy:[{type:"asc"},{createdAt:"desc"}],skip:n,take:i}),u.prisma.mission.count({where:m})]);return o.NextResponse.json({success:!0,data:p.map(e=>({id:e.id,title:e.title,description:e.description,type:e.type,category:e.category,reward_coins:e.rewardCoins,requirement_type:e.requirementType,requirement_value:e.requirementValue,is_premium_only:e.isPremiumOnly,is_active:e.isActive,starts_at:e.startsAt,ends_at:e.endsAt,created_at:e.createdAt})),pagination:{page:t,limit:i,total:l,total_pages:Math.ceil(l/i)}})}catch(e){return console.error("Admin missions GET error:",e),o.NextResponse.json({success:!1,message:"Gagal memuat misi"},{status:500})}}async function p(e){try{let{title:s,description:t,type:i,category:a,reward_coins:r,requirement_type:n,requirement_value:m,is_premium_only:p,is_active:l,starts_at:c,ends_at:d}=await e.json();if(!s?.trim())return o.NextResponse.json({success:!1,message:"Judul misi wajib diisi"},{status:400});if(!i||!["daily","weekly","special"].includes(i))return o.NextResponse.json({success:!1,message:"Tipe misi tidak valid (daily/weekly/special)"},{status:400});if(!r||r<1)return o.NextResponse.json({success:!1,message:"Hadiah koin harus lebih dari 0"},{status:400});let g=await u.prisma.mission.create({data:{title:s.trim(),description:t?.trim()||null,type:i,category:a||null,rewardCoins:parseInt(r),requirementType:n||null,requirementValue:m?parseInt(m):null,isPremiumOnly:!!p,isActive:!1!==l,startsAt:c?new Date(c):null,endsAt:d?new Date(d):null}});return o.NextResponse.json({success:!0,data:{id:g.id},message:"Misi berhasil ditambahkan"},{status:201})}catch(e){return console.error("Admin missions POST error:",e),o.NextResponse.json({success:!1,message:"Gagal menambahkan misi"},{status:500})}}let l=new a.AppRouteRouteModule({definition:{kind:r.x.APP_ROUTE,page:"/api/admin/missions/route",pathname:"/api/admin/missions",filename:"route",bundlePath:"app/api/admin/missions/route"},resolvedPagePath:"C:\\xampp\\htdocs\\Bolafest\\app\\api\\admin\\missions\\route.ts",nextConfigOutput:"standalone",userland:i}),{requestAsyncStorage:c,staticGenerationAsyncStorage:d,serverHooks:g}=l,y="/api/admin/missions/route";function h(){return(0,n.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:d})}},72331:(e,s,t)=>{t.d(s,{prisma:()=>a});var i=t(53524);let a=globalThis.prisma??new i.PrismaClient({log:["error"]})}};var s=require("../../../../webpack-runtime.js");s.C(e);var t=e=>s(s.s=e),i=s.X(0,[9276,5972],()=>t(61653));module.exports=i})();