"use strict";(()=>{var e={};e.id=8968,e.ids=[8968,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")},85206:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>g,patchFetch:()=>x,requestAsyncStorage:()=>o,routeModule:()=>d,serverHooks:()=>l,staticGenerationAsyncStorage:()=>c});var i={};t.r(i),t.d(i,{POST:()=>m});var a=t(49303),s=t(88716),u=t(60670),n=t(87070),p=t(72331);async function m(e,{params:r}){try{let{plan_type:t}=await e.json(),i={monthly:30,quarterly:90,yearly:365};if(!i[t])return n.NextResponse.json({success:!1,message:"Tipe plan tidak valid"},{status:400});let a=await p.prisma.user.findUnique({where:{id:r.id},select:{userId:!0,premiumTier:!0,premiumExpiresAt:!0}});if(!a)return n.NextResponse.json({success:!1,message:"Pengguna tidak ditemukan"},{status:404});let s=i[t],u=new Date,m=a.premiumExpiresAt&&a.premiumExpiresAt>u?a.premiumExpiresAt:u,d=new Date(m.getTime()+864e5*s);return await p.prisma.user.update({where:{id:r.id},data:{premiumTier:t,premiumExpiresAt:d,updatedAt:new Date}}),await p.prisma.premiumSubscription.create({data:{userId:r.id,planType:t,amount:0,currency:"IDR",paymentProvider:"admin_grant",startsAt:u,expiresAt:d,isActive:!0,autoRenew:!1}}),await p.prisma.auditLog.create({data:{userId:r.id,action:"premium_aktif",entityType:"user",entityId:r.id,metadata:{plan_type:t,expires_at:d,granted_by:"admin"}}}),n.NextResponse.json({success:!0,message:`Premium ${t} berhasil diberikan ke @${a.userId}. Berlaku hingga ${d.toLocaleDateString("id-ID")}.`})}catch(e){return console.error("User premium POST error:",e),n.NextResponse.json({success:!1,message:"Gagal memberikan premium"},{status:500})}}let d=new a.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/admin/users/[id]/premium/route",pathname:"/api/admin/users/[id]/premium",filename:"route",bundlePath:"app/api/admin/users/[id]/premium/route"},resolvedPagePath:"C:\\xampp\\htdocs\\Bolafest\\app\\api\\admin\\users\\[id]\\premium\\route.ts",nextConfigOutput:"standalone",userland:i}),{requestAsyncStorage:o,staticGenerationAsyncStorage:c,serverHooks:l}=d,g="/api/admin/users/[id]/premium/route";function x(){return(0,u.patchFetch)({serverHooks:l,staticGenerationAsyncStorage:c})}},72331:(e,r,t)=>{t.d(r,{prisma:()=>a});var i=t(53524);let a=globalThis.prisma??new i.PrismaClient({log:["error"]})}};var r=require("../../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),i=r.X(0,[9276,5972],()=>t(85206));module.exports=i})();