import{a as e,c as t,d as n,i as r,n as i,t as a}from"./app-DqWc0bf2.js";import{t as o}from"./swal-OIXtGkLz.js";var s=n(t(),1),c=a();function l({type:t=`totp`}){let[n,a]=(0,s.useState)(!1),{data:l,setData:u,post:d,processing:f,errors:p}=e({code:``}),[m,h]=(0,s.useState)(!1),g=e=>{e.preventDefault(),d(route(`two-factor.verify`),{preserveScroll:!0})},_=()=>{m||(h(!0),r.post(route(`two-factor.resend`),{},{preserveScroll:!0,onSuccess:()=>{h(!1),o.success(`Sent!`,`A new verification code has been sent to your email.`)},onError:e=>{h(!1),o.error(`Error`,e.code||`Failed to resend verification code.`)}}))},v=t===`email`;return(0,c.jsxs)(`div`,{className:`min-h-screen bg-[#E3EBE8] flex items-center justify-center p-4`,children:[(0,c.jsx)(i,{title:`Two-Factor Authentication`}),(0,c.jsxs)(`div`,{className:`w-full max-w-sm`,children:[(0,c.jsxs)(`div`,{className:`text-center mb-8`,children:[(0,c.jsx)(`div`,{className:`inline-flex items-center justify-center w-14 h-14 rounded-2xl bg-[#3D4E4B] mb-4 shadow-lg shadow-[#3D4E4B]/10`,children:v&&!n?(0,c.jsx)(`svg`,{className:`w-7 h-7 text-[#D4A017]`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,c.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z`})}):(0,c.jsx)(`svg`,{className:`w-7 h-7 text-[#D4A017]`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,c.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z`})})}),(0,c.jsx)(`h1`,{className:`text-xl font-black text-[#3D4E4B] tracking-tight`,children:`Two-Factor Authentication`}),(0,c.jsx)(`p`,{className:`text-sm text-gray-500 font-medium mt-2 leading-relaxed px-2`,children:n?`Enter a recovery code to continue.`:v?`Please enter the 6-digit verification code sent to your registered email address.`:`Please enter the 6-digit authentication code from your authenticator app.`})]}),(0,c.jsxs)(`div`,{className:`bg-white rounded-2xl shadow-sm border border-gray-100 p-8`,children:[(0,c.jsxs)(`form`,{onSubmit:g,className:`space-y-5`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`label`,{className:`block text-xs font-bold text-gray-400 uppercase tracking-widest mb-2.5`,children:n?`Recovery Code`:v?`Email Verification Code`:`Authenticator Code`}),(0,c.jsx)(`input`,{type:`text`,inputMode:n?`text`:`numeric`,maxLength:n?21:6,value:l.code,onChange:e=>u(`code`,e.target.value),autoFocus:!0,className:`w-full h-12 border rounded-xl px-4 text-center font-mono font-bold text-lg tracking-[0.4em] outline-none transition-all ${p.code?`border-red-300 bg-red-50 focus:ring-red-100`:`border-gray-200 focus:border-[#3D4E4B] focus:ring-2 focus:ring-[#3D4E4B]/10`}`,placeholder:n?`xxxxxxxxxx-xxxxxxxxxx`:`000000`}),p.code&&(0,c.jsx)(`p`,{className:`text-xs text-red-500 font-semibold mt-1.5 text-center`,children:p.code})]}),(0,c.jsx)(`button`,{type:`submit`,disabled:f||l.code.length<(n?5:6),className:`w-full h-11 bg-[#3D4E4B] text-white text-sm font-bold rounded-xl hover:bg-[#2D3A38] transition-all disabled:opacity-60 shadow-md shadow-[#3D4E4B]/15`,children:f?`Verifying...`:`Continue`})]}),v&&!n&&(0,c.jsx)(`div`,{className:`mt-5 text-center`,children:(0,c.jsx)(`button`,{onClick:_,disabled:m,className:`text-xs font-bold text-[#D4A017] hover:underline disabled:opacity-50`,children:m?`Resending code...`:`Didn't receive a code? Resend`})}),!v&&(0,c.jsx)(`div`,{className:`mt-6 text-center border-t border-gray-50 pt-4`,children:(0,c.jsx)(`button`,{onClick:()=>{a(!n),u(`code`,``)},className:`text-xs font-bold text-[#3D4E4B] hover:underline`,children:n?`Use authenticator code instead`:`Use a recovery code`})})]}),(0,c.jsx)(`div`,{className:`mt-6 text-center`,children:(0,c.jsx)(`a`,{href:`/login`,className:`text-xs font-semibold text-gray-400 hover:text-[#3D4E4B] transition-colors`,children:`← Back to login`})})]})]})}export{l as default};