"use strict";(()=>{var e={};e.id=289,e.ids=[289],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")},46317:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>h,patchFetch:()=>v,requestAsyncStorage:()=>m,routeModule:()=>d,serverHooks:()=>g,staticGenerationAsyncStorage:()=>x});var a={};r.r(a),r.d(a,{POST:()=>c});var i=r(49303),n=r(88716),s=r(60670),o=r(87070),l=r(8194),u=r(42023),p=r.n(u),f=r(39655);async function c(e){try{let{email:t,password:r}=await e.json();if(!t||!r)return o.NextResponse.json({error:"Email dan password wajib diisi"},{status:400});let a=await l._.affiliate.findUnique({where:{email:t}});if(!a||!await p().compare(r,a.password))return o.NextResponse.json({error:"Email atau password salah"},{status:401});let i=(0,f.PX)({affiliateId:a.id,email:a.email}),n=o.NextResponse.json({affiliate:{id:a.id,name:a.name,email:a.email,referralCode:a.referralCode,isActive:a.isActive}});return n.cookies.set("aff_token",i,{httpOnly:!0,secure:!0,sameSite:"lax",maxAge:604800,path:"/"}),n}catch(e){return console.error("Affiliate login error:",e),o.NextResponse.json({error:"Server error"},{status:500})}}let d=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/affiliate/auth/login/route",pathname:"/api/affiliate/auth/login",filename:"route",bundlePath:"app/api/affiliate/auth/login/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\affiliate\\auth\\login\\route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:m,staticGenerationAsyncStorage:x,serverHooks:g}=d,h="/api/affiliate/auth/login/route";function v(){return(0,s.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:x})}},39655:(e,t,r)=>{r.d(t,{No:()=>u,Of:()=>p,PX:()=>l});var a=r(41482),i=r.n(a),n=r(71615),s=r(8194);let o=process.env.JWT_SECRET||"fallback-secret-change-me";function l(e){return i().sign({...e,isAffiliate:!0},o,{expiresIn:"7d"})}async function u(){let e=await (0,n.cookies)(),t=e.get("aff_token")?.value;if(!t)return null;let r=function(e){try{let t=i().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 p(){return await u()||null}},8194:(e,t,r)=>{r.d(t,{_:()=>i});let a=require("@prisma/client"),i=globalThis.prisma??new a.PrismaClient}};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(46317));module.exports=a})();