1import{c as C,a as p,e as L,j as e,y as A,z as E,Q as z,aJ as I,B as v,aK as q,t as S,q as d,f as $,s as B,aI as K,L as M}from"./index-DmuA0bGG.js";import{o as T}from"./yup-DcABgwZ0.js";import{u as V}from"./resolvers-KC_-DC7L.js";import{P as Q}from"./Page-ZZpGWyYo.js";import{c as W,a as _}from"./index.esm-B1MbeT5i.js";import{F as J}from"./IdentificationIcon-D_XJ6_g_.js";import{F as Y}from"./ArrowLeftIcon-vhkbUAWS.js";function G({isOpen:a,onClose:u,identifier:m}){const{t:o}=C(),[n,c]=p.useState(Array(5).fill("")),l=p.useRef([]),y=L(),[x,i]=p.useState(!1),b=(r,t)=>{if(!/^\d*$/.test(r))return;const s=[...n];s[t]=r.slice(-1),c(s),r&&l.current[t+1]&&l.current[t+1]?.focus()},w=(r,t)=>{r.key==="Backspace"&&n[t]===""&&t>0&&l.current[t-1]?.focus()},g=(r,t)=>{r.preventDefault();const s=r.clipboardData.getData("text").replace(/\D/g,"");if(!s)return;const f=s.split("");c(R=>{const j=[...R];return f.forEach((F,D)=>{const k=t+D;k<j.length&&(j[k]=F)}),j});const P=Math.min(t+f.length,n.length-1),N=l.current[P];N&&N.focus()},h=async()=>{const r=n.join("");if(r.length!==5){q.error(o("auth.otp.error-length"));return}i(!0);try{const t={identifier:m,type:"PASSWORD_RECOVERY",code:r},s=await S.postVerificationCode(t);i(!1);const f=s?.data?.recovery_token;if(s?.satisfactory&&f){d.custom(s?.title,s?.message??null,"success"),y("/updatePassword",{state:{recoveryToken:f}});return}d.custom(s?.title,s?.message??null,"error")}catch(t){d.custom(o("auth.recovery.error"),t?.message??null,"error")}finally{c(Array(5).fill("")),i(!1)}},O=async()=>{i(!0);try{const r=await S.postForgotPassword({identifier:m});if(i(!1),d.custom(r?.title,r?.message??null,"success"),!r?.satisfactory)return}catch(r){i(!1),d.custom(o("auth.recovery.error"),r?.message??null,"error")}finally{c(Array(5).fill(""))}};return e.jsxs(A,{open:a,onClose:u,className:"relative z-50",children:[e.jsx("div",{className:"fixed inset-0 bg-black/40","aria-hidden":"true"}),e.jsx("div",{className:"fixed inset-0 flex items-center justify-center p-4",children:e.jsxs(E,{className:"w-full max-w-md rounded-lg bg-white p-6 shadow-xl dark:bg-gray-900",children:[e.jsx(z,{className:"mb-2 text-lg font-semibold",children:o("auth.otp.title")}),e.jsx(I,{className:"mb-4 text-gray-600 dark:text-gray-300",children:o("auth.otp.description")}),e.jsx("div",{className:"mb-6 flex justify-center gap-2",children:n.map((r,t)=>e.jsx("input",{ref:s=>{l.current[t]=s},type:"text",maxLength:1,value:r,onChange:s=>b(s.target.value,t),onKeyDown:s=>w(s,t),onPaste:s=>g(s,t),className:"h-12 w-12 rounded-md border border-gray-500 text-center text-xl font-semibold focus:border-blue-500 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-800"},t))}),e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx(v,{color:"success",onClick:O,disabled:x,children:o("auth.otp.resend")}),e.jsx(v,{color:"warning",onClick:h,disabled:x,children:o("auth.otp.confirm")})]})]})})]})}function re(){const{t:a}=C(),[u,m]=p.useState({open:!1,identifier:""}),{forgotPassword:o}=$(),[n,c]=p.useState(!1),l=W().shape({identifier:_().trim().min(5,a("auth.recovery.dni-required")).required(a("auth.recovery.dni-required"))}),{register:y,handleSubmit:x,formState:{errors:i}}=V({resolver:T(l),defaultValues:{identifier:""}}),b=async w=>{c(!0);const g=w.identifier.trim().toLowerCase(),h=await o(g);if(c(!1),h?.satisfactory){m({identifier:g,open:!0});return}d.custom(h?.title,h?.message??null,"error")};return e.jsxs(Q,{title:a("auth.recovery.page-title"),children:[e.jsx("main",{className:"grid min-h-screen w-full place-items-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"mb-6 flex flex-col items-center text-center",children:[e.jsx("img",{src:B,alt:"El Nacional",className:"h-20 w-auto object-contain drop-shadow"}),e.jsx("p",{className:"mt-3 text-[11px] font-bold tracking-widest text-white/55 uppercase",children:a("auth.recovery.club")})]}),e.jsxs("div",{className:"bg-navy-800 rounded-3xl border border-white/10 p-7 shadow-2xl sm:p-9",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("h1",{className:"text-2xl font-black text-white uppercase",children:[a("auth.recovery.title-prefix")," ",e.jsx("span",{className:"text-red-500",children:a("auth.recovery.title-highlight")})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/60",children:a("auth.recovery.subtitle")})]}),e.jsxs("form",{onSubmit:x(b),autoComplete:"off",className:"mt-7",children:[e.jsx(K,{unstyled:!0,type:"text",autoComplete:"username",placeholder:"Correo o cédula",className:"w-full rounded-xl border border-white/10 bg-white/[0.04] px-3 py-2.5 text-white transition placeholder:text-white/40 focus:border-red-500 focus:ring-2 focus:ring-red-500/30",prefix:e.jsx(J,{className:"size-5 text-white/45",strokeWidth:"1.5"}),...y("identifier"),error:i?.identifier?.message}),e.jsx(v,{type:"submit",disabled:n,className:"mt-5 h-11 w-full !rou
1nded-xl !bg-red-600 font-black tracking-widest !text-white uppercase shadow-lg transition-all duration-200 hover:!bg-red-700 hover:shadow-red-900/30 active:scale-[0.99] disabled:cursor-not-allowed disabled:opacity-60",children:a(n?"auth.searching":"auth.search")})]}),e.jsxs(M,{to:"/login",className:"mt-6 flex items-center justify-center gap-2 text-sm font-semibold text-white/70 transition-colors hover:text-red-400",children:[e.jsx(Y,{className:"size-4"}),a("auth.recovery.back-to-login")]})]})]})}),u.open&&e.jsx(G,{isOpen:u.open,onClose:()=>{m({open:!1,identifier:""})},identifier:u.identifier})]})}export{re 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.