"use strict";(()=>{var e={};e.id=6717,e.ids=[6717],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")},93071:(e,t,i)=>{i.r(t),i.d(t,{originalPathname:()=>h,patchFetch:()=>y,requestAsyncStorage:()=>d,routeModule:()=>c,serverHooks:()=>w,staticGenerationAsyncStorage:()=>v});var n={};i.r(n),i.d(n,{POST:()=>u});var r=i(49303),s=i(88716),a=i(60670),o=i(87070),p=i(72331);let l=[{id:1,label:"VIP 1 Bulan",type:"vip",value:30,weight:.5},{id:2,label:"25 Coins",type:"coin",value:25,weight:13},{id:3,label:"200 Coins",type:"coin",value:200,weight:5},{id:4,label:"ZONK",type:"none",value:0,weight:25},{id:5,label:"IPHONE 17 PRO",type:"jackpot",value:0,weight:1e-4},{id:6,label:"25 Coins",type:"coin",value:25,weight:13},{id:7,label:"200 Coins",type:"coin",value:200,weight:5},{id:8,label:"ZONK",type:"none",value:0,weight:25},{id:9,label:"LAPTOP",type:"jackpot",value:0,weight:.001},{id:10,label:"25 Coins",type:"coin",value:25,weight:13.4989}];async function u(e){try{let{userId:t}=await e.json();if(!t)return o.NextResponse.json({error:"User ID required"},{status:400});let i=await p._.user.findUnique({where:{id:t}});if(!i)return o.NextResponse.json({error:"User not found"},{status:404});if(i.spinTickets<1)return o.NextResponse.json({error:"No tickets"},{status:400});let n=function(){let e=Math.random()*l.reduce((e,t)=>e+t.weight,0);for(let t of l){if(e<t.weight)return t;e-=t.weight}return l[3]}(),r={spinTickets:{decrement:1}};if("coin"===n.type)r.coins={increment:n.value};else if("vip"===n.type){let e=i.vipExpiresAt&&new Date(i.vipExpiresAt)>new Date?new Date(i.vipExpiresAt):new Date,t=new Date(e);t.setDate(t.getDate()+n.value),r.vipExpiresAt=t,i.vipLevel<4&&(r.vipLevel=4)}let s=await p._.user.update({where:{id:t},data:r});return"none"!==n.type&&await p._.transaction.create({data:{userId:i.id,type:"SPIN_WIN",amount:0,coins:"coin"===n.type?n.value:0,status:"SUCCESS",description:`Won ${n.label} from Lucky Spin`}}),o.NextResponse.json({success:!0,result:n,user:{coins:s.coins,spinTickets:s.spinTickets}})}catch(e){return console.error("Spin Error:",e),o.NextResponse.json({error:"Internal server error"},{status:500})}}let c=new r.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/luckyspin/spin/route",pathname:"/api/luckyspin/spin",filename:"route",bundlePath:"app/api/luckyspin/spin/route"},resolvedPagePath:"C:\\Users\\MSI\\Downloads\\film\\app\\api\\luckyspin\\spin\\route.ts",nextConfigOutput:"standalone",userland:n}),{requestAsyncStorage:d,staticGenerationAsyncStorage:v,serverHooks:w}=c,h="/api/luckyspin/spin/route";function y(){return(0,a.patchFetch)({serverHooks:w,staticGenerationAsyncStorage:v})}},72331:(e,t,i)=>{i.d(t,{_:()=>r});var n=i(53524);let r=global.prisma||new n.PrismaClient}};var t=require("../../../../webpack-runtime.js");t.C(e);var i=e=>t(t.s=e),n=t.X(0,[8948,5972],()=>i(93071));module.exports=n})();