import{o as e,r as t,t as n}from"./jsx-runtime-BbTa8W_M-1776590214964.js";import{a as r,i,n as a,r as o,t as s}from"./app-CXDQ5oEH-1776590214964.js";import{t as c}from"./useTranslation-D1etqd9u-1776590214964.js";import{t as l}from"./arrow-left-BFhIh_le-1776590214964.js";import{t as u}from"./key-round-DyqVLoC9-1776590214964.js";import{t as d}from"./loader-circle-BF-wgoyu-1776590214964.js";import{t as f}from"./refresh-cw-rCzZXyoy-1776590214964.js";import{t as p}from"./button-WiAFyHfP-1776590214964.js";import{t as m}from"./label-DwYxovYB-1776590214964.js";import{t as h}from"./AuthLayout-BNB2211y-1776590214964.js";import{a as g,i as _,n as v,o as y,r as b,t as x}from"./card-Cby8flFO-1776590214964.js";import{t as S}from"./input-BlYvaS0F-1776590214964.js";var C=e(t(),1),w=n();function T({email:e,channel:t,status:n}){let{t:T}=c(),[E,D]=(0,C.useState)(60),[O,k]=(0,C.useState)(!1),{data:A,setData:j,post:M,processing:N,errors:P,reset:F}=r({email:e||``,otp:``,password:``,password_confirmation:``});return(0,C.useEffect)(()=>{if(E>0){let e=setTimeout(()=>D(E-1),1e3);return()=>clearTimeout(e)}},[E]),(0,w.jsxs)(h,{children:[(0,w.jsx)(a,{title:T(`Reset Password`)}),(0,w.jsxs)(x,{className:`w-full border-border/50 shadow-lg bg-card`,children:[(0,w.jsxs)(g,{className:`space-y-1 text-center`,children:[(0,w.jsx)(`div`,{className:`mx-auto h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center text-primary mb-2`,children:(0,w.jsx)(u,{className:`h-6 w-6`})}),(0,w.jsx)(y,{className:`text-2xl font-bold`,children:T(`Create New Password`)}),(0,w.jsxs)(b,{children:[T(`Enter the 6-digit OTP code sent to your`),` `,T(t===`email`?`email`:`phone`),` `,T(`and create a new password.`)]})]}),(0,w.jsxs)(v,{children:[n&&(0,w.jsx)(`div`,{className:`mb-4 p-3 rounded-lg bg-green-500/10 text-green-600 text-sm font-bold border border-green-500/20 text-center`,children:n}),(0,w.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),M(route(`password.store`),{onFinish:()=>F(`password`,`password_confirmation`)})},className:`space-y-4`,children:[(0,w.jsx)(`input`,{type:`hidden`,name:`email`,value:A.email}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,w.jsx)(m,{htmlFor:`otp`,children:T(`6-Digit OTP Code`)}),(0,w.jsxs)(`button`,{type:`button`,onClick:()=>{E>0||O||(k(!0),i.post(route(`password.resend`),{email:e,channel:t},{preserveScroll:!0,onSuccess:()=>{D(60),s.success(T(`A new OTP has been sent!`))},onError:e=>{s.error(e.otp||T(`Failed to resend OTP.`))},onFinish:()=>k(!1)}))},disabled:E>0||O,className:`text-xs font-bold flex items-center gap-1 ${E>0?`text-muted-foreground cursor-not-allowed`:`text-primary hover:underline`}`,children:[O?(0,w.jsx)(d,{className:`w-3 h-3 animate-spin`}):(0,w.jsx)(f,{className:`w-3 h-3`}),E>0?`${T(`Resend in`)} ${E}s`:T(`Resend OTP`)]})]}),(0,w.jsx)(S,{id:`otp`,type:`text`,maxLength:`6`,placeholder:`123456`,value:A.otp,onChange:e=>j(`otp`,e.target.value.replace(/[^0-9]/g,``)),className:`text-center tracking-[0.5em] font-mono text-xl h-12 ${P.otp?`border-destructive focus-visible:ring-destructive`:``}`,autoFocus:!0,required:!0}),P.otp&&(0,w.jsx)(`p`,{className:`text-xs text-destructive font-bold p-2 bg-red-500/10 rounded`,children:P.otp})]}),(0,w.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,w.jsx)(m,{htmlFor:`password`,children:T(`New Password`)}),(0,w.jsx)(S,{id:`password`,type:`password`,placeholder:`••••••••`,value:A.password,onChange:e=>j(`password`,e.target.value),className:P.password?`border-destructive focus-visible:ring-destructive`:``,required:!0}),P.password&&(0,w.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:P.password})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(m,{htmlFor:`password_confirmation`,children:T(`Confirm Password`)}),(0,w.jsx)(S,{id:`password_confirmation`,type:`password`,placeholder:`••••••••`,value:A.password_confirmation,onChange:e=>j(`password_confirmation`,e.target.value),required:!0})]}),(0,w.jsxs)(p,{className:`w-full gap-2 text-base font-bold shadow-md mt-4`,type:`submit`,disabled:N,children:[N?(0,w.jsx)(d,{className:`w-5 h-5 animate-spin`}):null,T(N?`Resetting Password...`:`Reset Password`)]})]})]}),(0,w.jsx)(_,{className:`flex justify-center border-t py-4 bg-muted/20 rounded-b-xl`,children:(0,w.jsxs)(o,{href:route(`login`),className:`flex items-center gap-2 text-sm text-muted-foreground hover:text-primary transition-colors font-bold`,children:[(0,w.jsx)(l,{className:`h-4 w-4`}),T(`Back to login`)]})})]})]})}export{T as default};