"use strict";(()=>{var e={};e.id=9436,e.ids=[9436],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")},74300:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>m,patchFetch:()=>w,requestAsyncStorage:()=>c,routeModule:()=>l,serverHooks:()=>h,staticGenerationAsyncStorage:()=>x});var s={};t.r(s),t.d(s,{POST:()=>d});var n=t(49303),a=t(88716),o=t(60670),i=t(87070),u=t(8194),p=t(95456);async function d(e){try{let{token:r,password:t}=await e.json();if(!r)return i.NextResponse.json({error:"Token tidak ditemukan"},{status:400});if(!t||t.length<6)return i.NextResponse.json({error:"Password minimal 6 karakter"},{status:400});let s=await u._.user.findUnique({where:{resetToken:r}});if(!s)return i.NextResponse.json({error:"Token tidak valid atau sudah digunakan"},{status:400});if(s.resetExpiry&&new Date>s.resetExpiry)return i.NextResponse.json({error:"Token sudah kedaluwarsa. Silakan minta link reset baru."},{status:400});let n=await (0,p.c_)(t);return await u._.user.update({where:{id:s.id},data:{password:n,resetToken:null,resetExpiry:null}}),i.NextResponse.json({message:"Password berhasil diubah. Silakan login dengan password baru Anda."})}catch(e){return console.error("Reset password error:",e),i.NextResponse.json({error:"Terjadi kesalahan server"},{status:500})}}let l=new n.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/auth/reset-password/route",pathname:"/api/auth/reset-password",filename:"route",bundlePath:"app/api/auth/reset-password/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\auth\\reset-password\\route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:c,staticGenerationAsyncStorage:x,serverHooks:h}=l,m="/api/auth/reset-password/route";function w(){return(0,o.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:x})}},95456:(e,r,t)=>{t.d(r,{Gv:()=>l,MH:()=>m,PT:()=>w,RA:()=>c,WX:()=>x,c_:()=>d,ts:()=>h});var s=t(41482),n=t.n(s),a=t(42023),o=t.n(a),i=t(71615),u=t(8194);let p=process.env.JWT_SECRET||"fallback-secret-change-me";async function d(e){return o().hash(e,12)}async function l(e,r){return o().compare(e,r)}function c(e){return n().sign(e,p,{expiresIn:"7d"})}function x(e){try{return n().verify(e,p)}catch{return null}}async function h(){let e=await (0,i.cookies)(),r=e.get("token")?.value;if(!r)return null;let t=x(r);return t?await u._.user.findUnique({where:{id:t.userId},include:{tenant:!0,store:!0}}):null}function m(e,r){return r.includes(e)}function w(e){return!["owner","admin"].includes(e.role)&&!!e.storeId&&!!e.store&&!e.store.isActive}},8194:(e,r,t)=>{t.d(r,{_:()=>n});let s=require("@prisma/client"),n=globalThis.prisma??new s.PrismaClient}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8948,5972,4261,2023],()=>t(74300));module.exports=s})();