"use strict";(()=>{var e={};e.id=4355,e.ids=[4355],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")},84770:e=>{e.exports=require("crypto")},37883:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>h,patchFetch:()=>g,requestAsyncStorage:()=>c,routeModule:()=>m,serverHooks:()=>f,staticGenerationAsyncStorage:()=>w});var a={};t.r(a),t.d(a,{POST:()=>d});var i=t(49303),s=t(88716),n=t(60670),o=t(87070),u=t(72331),p=t(98691),l=t(89833);async function d(e){try{let{username:r,password:t,email:a,phoneNumber:i,otp:s,referralCode:n}=await e.json()||{},d=String(a||"").trim().toLowerCase();if(!r||!t||!d||!s)return o.NextResponse.json({error:"Username, password, email, and otp are required"},{status:400});if(await u._.user.findUnique({where:{username:r}}))return o.NextResponse.json({error:"Username already taken"},{status:400});if(await u._.user.findUnique({where:{email:d}}))return o.NextResponse.json({error:"Email already taken"},{status:400});let m=await u._.emailOtp.findUnique({where:{email:d}});if(!m||m.expiresAt<new Date)return o.NextResponse.json({error:"OTP expired or invalid"},{status:400});if(!await p.ZP.compare(String(s),m.otpHash))return await u._.emailOtp.update({where:{email:d},data:{attempts:m.attempts+1}}),o.NextResponse.json({error:"OTP invalid"},{status:400});await u._.emailOtp.delete({where:{email:d}});let c=await p.ZP.hash(t,10),w=String(r).replace(/[^a-zA-Z0-9]/g,"").slice(0,6).toUpperCase()||"USER",f="";for(let e=0;e<5;e+=1){let e=`${w}${Math.floor(1e3+9e3*Math.random())}`;if(!await u._.user.findUnique({where:{referralCode:e}})){f=e;break}}f||(f=`U${Date.now()}`);let h=n?await u._.user.findUnique({where:{referralCode:String(n).trim()}}):null,g=Math.max(0,Number(process.env.REFERRAL_REWARD_COINS||0)),R=!!(h&&g>0),_=await u._.user.create({data:{username:r,password:c,email:d,phoneNumber:i||null,referralCode:f,referredById:h?.id||null,referralRewarded:R,emailVerified:!0}});R&&h&&(await u._.user.update({where:{id:h.id},data:{coins:{increment:g}}}),await u._.transaction.create({data:{userId:h.id,type:"REFERRAL",amount:0,coins:g,status:"SUCCESS",description:`Referral from ${_.username}`}}));let x=h?`Referrer: ${h.username}`:"Referrer: -";return await (0,l.T)(`User baru: ${_.username}
Email: ${_.email}
${x}`),o.NextResponse.json(_)}catch(e){return console.error("Registration error:",e),o.NextResponse.json({error:"Something went wrong",details:e.message||String(e)},{status:500})}}let m=new i.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/user/register/route",pathname:"/api/user/register",filename:"route",bundlePath:"app/api/user/register/route"},resolvedPagePath:"C:\\Users\\MSI\\Downloads\\film\\app\\api\\user\\register\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:c,staticGenerationAsyncStorage:w,serverHooks:f}=m,h="/api/user/register/route";function g(){return(0,n.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:w})}},72331:(e,r,t)=>{t.d(r,{_:()=>i});var a=t(53524);let i=global.prisma||new a.PrismaClient},89833:(e,r,t)=>{t.d(r,{T:()=>a});async function a(e){let r=process.env.TELEGRAM_BOT_TOKEN,t=(process.env.TELEGRAM_CHAT_IDS||"").split(/[,\s]+/).map(e=>e.trim()).filter(Boolean);if(!r||0===t.length)return!1;let a=`https://api.telegram.org/bot${r}/sendMessage`;return await Promise.all(t.map(r=>fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chat_id:r,text:e,disable_web_page_preview:!0})}))),!0}}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[8948,5972,8691],()=>t(37883));module.exports=a})();