import{R as b,j as e}from"./app-DZfefqwY.js";import{A as j}from"./arrow-left-EsrmbjxM.js";const g=b.forwardRef(({value:r,onChange:o,onKeyDown:a,onPaste:l,type:n="text",error:c=!1,autoFocus:i=!1},u)=>e.jsx("input",{ref:u,type:n,inputMode:"numeric",pattern:"[0-9]*",maxLength:1,required:!0,autoComplete:"off",className:`h-12 w-12 rounded-md border text-center text-2xl focus:ring-1 focus:outline-none ${c?"border-red-500 focus:ring-red-500":"border-gray-300 focus:border-blue-500 focus:ring-blue-500"}`,value:r,onChange:o,onKeyDown:a,onPaste:l,autoFocus:i,onFocus:m=>m.target.select()}));g.displayName="DigitInput";const v=({otp:r,phone:o,errors:a,processing:l,countdown:n,onOtpChange:c,onKeyDown:i,onBack:u,onResendOtp:m,onSubmit:h,inputRefs:d})=>{const p=(x,t)=>{var f;const s=x.target.value.replace(/\D/g,"");c(s,t),s&&t<5&&d.current[t+1]&&((f=d.current[t+1])==null||f.focus())};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:u,className:"flex items-center text-sm text-gray-600 hover:text-gray-800",type:"button",children:[e.jsx(j,{className:"mr-1 h-4 w-4"}),"Kembali"]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-center text-2xl font-bold text-gray-900",children:"Verifikasi OTP"}),e.jsxs("p",{className:"mt-2 text-center text-sm text-gray-600",children:["Masukkan 6 digit kode OTP yang dikirim ke ",o??"Whatsapp Anda"]})]}),a.otp&&e.jsx("div",{className:"text-center text-sm text-red-500",children:a.otp}),e.jsxs("form",{onSubmit:h,className:"space-y-6",children:[e.jsx("div",{className:"flex justify-center space-x-2",children:Array.from({length:6}).map((x,t)=>e.jsx(g,{ref:s=>{d.current[t]=s},value:r[t]||"",onChange:s=>p(s,t),onKeyDown:s=>i(s,t),error:!!a.otp,autoFocus:t===0},t))}),e.jsx("div",{className:"text-center",children:n>0?e.jsxs("p",{className:"text-sm text-gray-500",children:["Kirim ulang OTP dalam ",n," detik"]}):e.jsx("button",{type:"button",onClick:m,className:"text-sm text-blue-600 hover:text-blue-800",children:"Kirim Ulang OTP"})}),e.jsx("div",{children:e.jsx("button",{type:"submit",disabled:l||r.length!==6,className:`flex w-full justify-center rounded-md border border-transparent px-4 py-2 text-sm font-medium text-white shadow-sm ${r.length===6?"bg-blue-600 hover:bg-blue-700 focus:ring-blue-500":"cursor-not-allowed bg-gray-400"} focus:ring-2 focus:ring-offset-2 focus:outline-none`,children:l?"Memverifikasi...":"Verifikasi"})})]})]})};export{g as D,v as O};
