"use strict";(()=>{var e={};e.id=6039,e.ids=[6039],e.modules={72934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},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")},78893:e=>{e.exports=require("buffer")},84770:e=>{e.exports=require("crypto")},76162:e=>{e.exports=require("stream")},21764:e=>{e.exports=require("util")},52927:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>v,patchFetch:()=>w,requestAsyncStorage:()=>h,routeModule:()=>g,serverHooks:()=>x,staticGenerationAsyncStorage:()=>m});var a={};r.r(a),r.d(a,{POST:()=>d});var n=r(49303),i=r(88716),s=r(60670),o=r(87070),l=r(8194),u=r(42023),f=r.n(u),c=r(40644),p=r(39655);async function d(e){try{let{name:t,email:r,password:a,phone:n,bankName:i,bankAccount:s,bankHolder:u}=await e.json();if(!t||!r||!a)return o.NextResponse.json({error:"Nama, email, dan password wajib diisi"},{status:400});if(await l._.affiliate.findUnique({where:{email:r}}))return o.NextResponse.json({error:"Email sudah terdaftar"},{status:400});let d=(0,c.lJ)(),g=0;for(;await l._.affiliate.findUnique({where:{referralCode:d}})&&(d=(0,c.lJ)(),!(++g>10)););let h=await f().hash(a,10),m=await l._.affiliate.create({data:{name:t,email:r,password:h,phone:n||null,referralCode:d,bankName:i||null,bankAccount:s||null,bankHolder:u||null,isActive:!1}}),x=(0,p.PX)({affiliateId:m.id,email:m.email}),v=o.NextResponse.json({affiliate:{id:m.id,name:m.name,email:m.email,referralCode:m.referralCode,isActive:m.isActive}});return v.cookies.set("aff_token",x,{httpOnly:!0,secure:!0,sameSite:"lax",maxAge:604800,path:"/"}),v}catch(e){return console.error("Affiliate register error:",e),o.NextResponse.json({error:"Server error"},{status:500})}}let g=new n.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/affiliate/auth/register/route",pathname:"/api/affiliate/auth/register",filename:"route",bundlePath:"app/api/affiliate/auth/register/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\affiliate\\auth\\register\\route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:h,staticGenerationAsyncStorage:m,serverHooks:x}=g,v="/api/affiliate/auth/register/route";function w(){return(0,s.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:m})}},39655:(e,t,r)=>{r.d(t,{No:()=>u,Of:()=>f,PX:()=>l});var a=r(41482),n=r.n(a),i=r(71615),s=r(8194);let o=process.env.JWT_SECRET||"fallback-secret-change-me";function l(e){return n().sign({...e,isAffiliate:!0},o,{expiresIn:"7d"})}async function u(){let e=await (0,i.cookies)(),t=e.get("aff_token")?.value;if(!t)return null;let r=function(e){try{let t=n().verify(e,o);if(!t.isAffiliate)return null;return t}catch{return null}}(t);return r&&await s._.affiliate.findUnique({where:{id:r.affiliateId}})||null}async function f(){return await u()||null}},8194:(e,t,r)=>{r.d(t,{_:()=>n});let a=require("@prisma/client"),n=globalThis.prisma??new a.PrismaClient},40644:(e,t,r)=>{function a(){let e=new Date().toISOString().slice(0,10).replace(/-/g,""),t=Math.random().toString(36).substring(2,6).toUpperCase();return`ORD-${e}-${t}`}function n(){let e=new Date().toISOString().slice(0,10).replace(/-/g,""),t=Math.random().toString(36).substring(2,8).toUpperCase();return`PAY-${e}-${t}`}function i(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function s(){let e="ABCDEFGHJKLMNPQRSTUVWXYZ23456789",t="";for(let r=0;r<8;r++)t+=e.charAt(Math.floor(Math.random()*e.length));return t}function o(){let e="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789",t="";for(let r=0;r<8;r++)t+=e.charAt(Math.floor(Math.random()*e.length));return t}function l(){let e="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789",t="";for(let r=0;r<12;r++)t+=e.charAt(Math.floor(Math.random()*e.length));return t}function u(e){if(0===e.length)return"pending";let t=e.filter(e=>"cancelled"!==e.status&&"unavailable"!==e.status);if(0===t.length)return"cancelled";let r=t.map(e=>e.status);return r.every(e=>"served"===e)?"served":r.every(e=>"ready"===e||"served"===e)?"ready":r.some(e=>"preparing"===e)?"preparing":r.every(e=>"pending"===e)?"confirmed":"preparing"}r.d(t,{TL:()=>n,lJ:()=>s,lV:()=>i,m1:()=>a,pc:()=>o,s7:()=>l,yZ:()=>u})}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972,4261,2023],()=>r(52927));module.exports=a})();