(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6878],{36052:(e,s,t)=>{Promise.resolve().then(t.bind(t,54733))},50627:(e,s,t)=>{"use strict";var r=t(47192);t.o(r,"notFound")&&t.d(s,{notFound:function(){return r.notFound}}),t.o(r,"useParams")&&t.d(s,{useParams:function(){return r.useParams}}),t.o(r,"usePathname")&&t.d(s,{usePathname:function(){return r.usePathname}}),t.o(r,"useRouter")&&t.d(s,{useRouter:function(){return r.useRouter}}),t.o(r,"useSearchParams")&&t.d(s,{useSearchParams:function(){return r.useSearchParams}})},54733:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>o});var r=t(73365),a=t(1521),n=t(50627);function o(){let[e,s]=(0,a.useState)(""),[t,o]=(0,a.useState)(""),[l,d]=(0,a.useState)(!1),[i,u]=(0,a.useState)(null),[c,m]=(0,a.useState)(null),[h,x]=(0,a.useState)(null),p=(0,n.useRouter)(),{token:f}=(0,n.useParams)();(0,a.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/auth/validate-reset-token/".concat(f)),s=await e.json();if(!e.ok){u(!1),x(s.message||"Invalid or expired token");return}u(!0)}catch(e){u(!1),x("Failed to validate token")}})()},[f]);let w=async s=>{if(s.preventDefault(),i){if(d(!0),x(null),m(null),e!==t){x("Passwords do not match"),d(!1);return}try{let s=await fetch("/api/auth/reset-password/".concat(f),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e,passwordConfirm:t})}),r=await s.json();if(!s.ok)throw Error(r.message||"Password reset failed");m("Password successfully reset! Redirecting to login..."),setTimeout(()=>p.push("/login"),2e3)}catch(e){x(e.message)}finally{d(!1)}}};return null===i?(0,r.jsx)("div",{className:"min-h-screen flex items-center justify-center",children:(0,r.jsx)("div",{className:"text-center",children:(0,r.jsx)("p",{children:"Validating reset token..."})})}):i?(0,r.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8",children:(0,r.jsxs)("div",{className:"max-w-md w-full space-y-8 bg-white p-8 rounded-lg shadow",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"mt-6 text-center text-3xl font-extrabold text-gray-900",children:"Reset your password"}),(0,r.jsx)("p",{className:"mt-2 text-center text-sm text-gray-600",children:"Enter your new password below"})]}),h&&(0,r.jsx)("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative",children:h}),c&&(0,r.jsx)("div",{className:"bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative",children:c}),(0,r.jsxs)("form",{className:"mt-8 space-y-6",onSubmit:w,children:[(0,r.jsxs)("div",{className:"rounded-md shadow-sm space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700",children:"New Password"}),(0,r.jsx)("input",{id:"password",name:"password",type:"password",autoComplete:"new-password",required:!0,value:e,onChange:e=>s(e.target.value),className:"mt-1 appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm text-gray-700",placeholder:"••••••••",minLength:"8"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"passwordConfirm",className:"block text-sm font-medium text-gray-700",children:"Confirm New Password"}),(0,r.jsx)("input",{id:"passwordConfirm",name:"passwordConfirm",type:"password",autoComplete:"new-password",required:!0,value:t,onChange:e=>o(e.target.value),className:"mt-1 appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm text-gray-700",placeholder:"••••••••",minLength:"8"})]})]}),(0,r.jsx)("div",{children:(0,r.jsx)("button",{type:"submit",disabled:l,className:"w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",children:l?"Resetting...":"Reset Password"})})]})]})}):(0,r.jsx)("div",{className:"min-h-screen flex items-center justify-center",children:(0,r.jsxs)("div",{className:"max-w-md w-full space-y-8 bg-white p-8 rounded-lg shadow text-center",children:[(0,r.jsx)("h2",{className:"text-3xl font-extrabold text-gray-900",children:"Invalid Reset Link"}),(0,r.jsx)("p",{className:"mt-2 text-red-600",children:h}),(0,r.jsx)("button",{onClick:()=>p.push("/forgot-password"),className:"mt-4 text-blue-600 hover:text-blue-500",children:"Request new reset link"})]})})}}},e=>{var s=s=>e(e.s=s);e.O(0,[2347,4870,7358],()=>s(36052)),_N_E=e.O()}]);