1import{c as e,e as s,r as a,j as r}from"./vendor-react-DbsVTsKS.js";import{ab as t,ac as o}from"./index-Dirtnqiz.js";/* empty css */import"./vendor-i18n-DiTKF2NC.js";import"./vendor-ui-B_XW8Pya.js";import"./vendor-charts-CG7l663-.js";import"./vendor-otel-B3hnpEUX.js";import"./app-constants-D3ojol5R.js";import"./vendor-virtuoso-CT6D0QVj.js";import"./vendor-markdown-CiT-VfZw.js";const i=()=>{var i;const n=e(),l=(null==(i=s().state)?void 0:i.email)||"",[d,c]=a.useState({email:l,password:"",confirmPassword:""}),[m,p]=a.useState(""),[u,h]=a.useState(null),[g,w]=a.useState(!1),[f,j]=a.useState(!1),[x,y]=a.useState(0),[v,P]=a.useState(null),[b,N]=a.useState({}),[S,C]=a.useState(!1),[O,T]=a.useState(!1),[k,F]=a.useState(!1),[E,I]=a.useState(!1),[R,q]=a.useState(""),B=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;a.useEffect(()=>()=>{v&&clearInterval(v)},[v]);const V=e=>{const{name:s,value:a}=e.target;c(e=>({...e,[s]:a})),b[s]&&N(e=>({...e,[s]:""}))},$=async()=>{if(d.email?B.test(d.email)||(N(e=>({...e,email:"Please enter a valid email address"})),0):(N(e=>({...e,email:"Email is required"})),0)){T(!0),N(e=>({...e,otp:""}));try{const e=await o.generateOTP(d.email);e.success&&e.responseBody&&h(e.responseBody),w(!0),y(300),v&&clearInterval(v);const s=setInterval(()=>{y(e=>e<=1?(clearInterval(s),P(null),0):e-1)},1e3);P(s),N(e=>({...e,otp:""}))}catch(e){N(s=>({...s,otp:e.userFriendlyMessage||e.message||"Failed to send OTP. Please try again."}))}finally{T(!1)}}},A=e=>`${Math.floor(e/60)}:${(e%60).toString().padStart(2,"0")}`;return r.jsx("div",{className:"signup-form-container",children:r.jsxs("div",{className:"signup-form-card",children:[r.jsx("h1",{className:"signup-form-title",children:"Reset Password"}),r.jsx("p",{className:"signup-form-subtitle",children:"Enter your email to reset your password"}),r.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),(()=>{const e={};return d.password?d.password.length<8&&(e.password="Password must be at least 8 characters long"):e.password="Password is required",d.confirmPassword?d.password!==d.confirmPassword&&(e.confirmPassword="Passwords do not match"):e.confirmPassword="Please confirm your password",N(e),0===Object.keys(e).length})()){C(!0),N({}),q("");try{(await t.resetPassword(d.email,d.password)).success?(q("Password reset successfully! Redirecting to login..."),setTimeout(()=>{n("/login",{state:{email:d.email,message:"Password reset successfully. Please log in with your new password."}})},2e3)):N({submit:"Failed to reset password. Please try again."})}catch(s){N({submit:s.userFriendlyMessage||s.message||"Failed to reset password. Please try again."})}finally{C(!1)}}},className:"signup-form",children:[r.jsxs("div",{className:"form-group",children:[r.jsx("label",{htmlFor:"email",children:"Email Address *"}),r.jsxs("div",{className:"email-verify-container",children:[r.jsx("input",{type:"email",id:"email",name:"email",value:d.email,onChange:V,className:`form-input ${b.email?"error":""} ${f?"verified":""}`,placeholder:"Enter your email",disabled:f,required:!0}),!f&&r.jsx("button",{type:"button",onClick:$,disabled:O||!d.email||x>0,className:"verify-btn",children:O?"Sending...":x>0?A(x):"Verify"}),f&&r.jsx("span",{className:"verified-badge",children:"â Verified"})]}),b.email&&r.jsx("span",{className:"error-message",children:b.email})]}),g&&!f&&r.jsxs("div",{className:"form-group",children:[r.jsx("label",{htmlFor:"otp",children:"Enter OTP *"}),r.jsxs("div",{className:"otp-verify-container",children:[r.jsx("input",{type:"text",id:"otp",value:m,onChange:e=>p(e.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,6)),className:"form-input "+(b.otp?"error":""),placeholder:"Enter 6-character OTP",maxLength:6,required:!0}),r.jsx("button",{type:"button",onClick:async()=>{var e;if(m&&6===m.length)if(u&&m!==u)N(e=>({...e,otp:"Invalid OTP. Please check and try again."}));else{T(!0),N(e=>({...e,otp:""}));try{const s=await o.validateOTP(d.email,m);s.success&&"Valid"===(null==(e=s.responseBody)?void 0:e.Status)?(j(!0),N(e=>({...e,otp:""})),v&&(clearInterval(v),P(null))):N(e=>({...e,otp:"Invalid OTP. Please try again."}))}catch(s){N(e=>({...e,otp:s.userFriendlyMessage||s.message||"Invalid OTP. Please try again."}))}finally{T(!1)}}else N(e=>({...e,otp:"Please enter the 6-character OTP"}))},disabled:O||6!==m.length,className:"verify-otp-btn",children:O?"Verifying...":"
1Verify OTP"})]}),b.otp&&r.jsx("span",{className:"error-message",children:b.otp}),r.jsxs("div",{className:"otp-info-container",children:[r.jsxs("p",{className:"otp-info",children:["OTP sent to ",d.email,x>0&&r.jsxs("span",{className:"otp-timer",children:[" ⢠Expires in ",A(x)]})]}),0===x&&r.jsx("button",{type:"button",onClick:async()=>{p(""),await $()},disabled:O,className:"resend-otp-btn",children:"Resend OTP"})]})]}),f&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"form-group",children:[r.jsx("label",{htmlFor:"password",children:"New Password *"}),r.jsxs("div",{className:"password-input-container",children:[r.jsx("input",{type:k?"text":"password",id:"password",name:"password",value:d.password,onChange:V,className:"form-input "+(b.password?"error":""),placeholder:"Enter new password (min 8 characters)",required:!0}),r.jsx("button",{type:"button",className:"password-toggle",onClick:()=>F(!k),children:k?"ðï¸":"ðï¸âð¨ï¸"})]}),b.password&&r.jsx("span",{className:"error-message",children:b.password}),r.jsx("p",{className:"password-hint",children:"Password must be at least 8 characters long"})]}),r.jsxs("div",{className:"form-group",children:[r.jsx("label",{htmlFor:"confirmPassword",children:"Confirm Password *"}),r.jsxs("div",{className:"password-input-container",children:[r.jsx("input",{type:E?"text":"password",id:"confirmPassword",name:"confirmPassword",value:d.confirmPassword,onChange:V,className:"form-input "+(b.confirmPassword?"error":""),placeholder:"Re-enter your new password",required:!0}),r.jsx("button",{type:"button",className:"password-toggle",onClick:()=>I(!E),children:E?"ðï¸":"ðï¸âð¨ï¸"})]}),b.confirmPassword&&r.jsx("span",{className:"error-message",children:b.confirmPassword})]})]}),R&&r.jsx("div",{className:"success-message",style:{padding:"12px",backgroundColor:"#d4edda",color:"#155724",borderRadius:"4px",marginBottom:"16px",textAlign:"center"},children:R}),b.submit&&r.jsx("div",{className:"submit-error",children:b.submit}),r.jsx("button",{type:"submit",className:"submit-btn",disabled:S||!f,children:S?"Resetting Password...":"Reset Password"}),r.jsxs("p",{className:"login-link",children:["Remember your password?"," ",r.jsx("a",{href:"/login",onClick:e=>{e.preventDefault(),n("/login")},children:"Back to Login"})]})]})]})})};export{i as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.