import{r as s,j as e,H as f,F as h}from"./app-Ajql0Lt4.js";import{I as u}from"./input-error-Drp3HhtP.js";import{B as y}from"./createLucideIcon-B_iAwCmA.js";import{I as g}from"./input-B0_NTiRR.js";import{I as j,K as v,O as l,a as I,b as T}from"./use-two-factor-auth-PVYcuVkA.js";import{A as C}from"./auth-layout-BA0f4QcD.js";import{s as b}from"./index-D6lErTwd.js";import"./app-B4XVefei.js";import"./app-logo-icon-B9D8MR-Y.js";function S(){const[t,d]=s.useState(!1),[m,n]=s.useState(""),r=s.useMemo(()=>t?{title:"Recovery Code",description:"Please confirm access to your account by entering one of your emergency recovery codes.",toggleText:"login using an authentication code"}:{title:"Authentication Code",description:"Enter the authentication code provided by your authenticator application.",toggleText:"login using a recovery code"},[t]),p=o=>{d(!t),o(),n("")};return e.jsxs(C,{title:r.title,description:r.description,children:[e.jsx(f,{title:"Two-Factor Authentication"}),e.jsx("div",{className:"space-y-6",children:e.jsx(h,{...b.form(),className:"space-y-4",resetOnError:!0,resetOnSuccess:!t,children:({errors:o,processing:a,clearErrors:x})=>e.jsxs(e.Fragment,{children:[t?e.jsxs(e.Fragment,{children:[e.jsx(g,{name:"recovery_code",type:"text",placeholder:"Enter recovery code",autoFocus:t,required:!0}),e.jsx(u,{message:o.recovery_code})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-center",children:[e.jsx("div",{className:"flex w-full items-center justify-center",children:e.jsx(j,{name:"code",maxLength:l,value:m,onChange:c=>n(c),disabled:a,pattern:v,children:e.jsx(I,{children:Array.from({length:l},(c,i)=>e.jsx(T,{index:i},i))})})}),e.jsx(u,{message:o.code})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:"Continue"}),e.jsxs("div",{className:"text-center text-sm text-muted-foreground",children:[e.jsx("span",{children:"or you can "}),e.jsx("button",{type:"button",className:"cursor-pointer text-foreground underline decoration-neutral-300 underline-offset-4 transition-colors duration-300 ease-out hover:decoration-current! dark:decoration-neutral-500",onClick:()=>p(x),children:r.toggleText})]})]})})})]})}export{S as default};