import{c as S,j as e,r as L,L as h,e as A,t as u}from"./index-DiwDH9aE.js";import{N as E,u as k,a as C}from"./usePublicPageRedirect-BmN2olSc.js";import{B as T}from"./Button-Cu8l7rID.js";import{L as F,A as U,a as _}from"./authSchemas-DDkGZrcM.js";import{I as x,E as g}from"./schemas-BwNPnT22.js";import"./studentRegistrationSchemas-CVTP24QO.js";import"./multiUserApiClient-CKPzIhIr.js";import{u as $,a as B,h as H}from"./handleFormErrors-CaWHVJ6Q.js";import{G as M}from"./graduation-cap-B3zNhUOw.js";import{U as D}from"./users-BLfoITz0.js";import{S as P}from"./shield-Beyfz6Tk.js";import{u as R}from"./useAuth-DEWkUfUW.js";import{I as z,L as G}from"./registerService-CxQfNS19.js";import"./cycleStore-Brm22ojq.js";import"./x-D4vgwdOf.js";import"./menu-Da05vmTL.js";import"./award-Cb8JG_li.js";import"./phone-DYXWN0h8.js";import"./map-pin-C8p0ntE-.js";import"./book-open-d9PZeRFr.js";import"./authService-7ekyJsWC.js";import"./endpoints-BUXROgJ9.js";/**
 * @license lucide-react v0.544.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const V=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],q=S("log-in",V),W=({selectedType:n,onTypeChange:o,disabled:a=!1})=>{const t=[{id:"student",label:"Estudiante",icon:M,color:{active:"bg-blue-600 text-white",hover:"hover:bg-blue-50 hover:text-blue-600",border:"border-blue-600"}},{id:"teacher",label:"Docente",icon:D,color:{active:"bg-green-600 text-white",hover:"hover:bg-green-50 hover:text-green-600",border:"border-green-600"}},{id:"admin",label:"Admin",icon:P,color:{active:"bg-orange-600 text-white",hover:"hover:bg-orange-50 hover:text-orange-600",border:"border-orange-600"}}];return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700",children:"Tipo de Usuario"}),e.jsx("div",{className:"flex gap-2",children:t.map(r=>{const s=r.icon,d=n===r.id;return e.jsxs("button",{type:"button",onClick:()=>o(r.id),disabled:a,className:`
              flex-1 flex items-center justify-center gap-2
              py-2.5 px-3 rounded-lg border-2 
              text-sm font-medium transition-all
              ${d?`${r.color.active} ${r.color.border}`:`bg-white text-gray-600 border-gray-300 ${r.color.hover}`}
              ${a?"opacity-50 cursor-not-allowed":"cursor-pointer"}
            `,children:[e.jsx(s,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs",children:r.label})]},r.id)})})]})},J=({cycle:n,hasCycle:o,refresh:a})=>{const[t,r]=L.useState("admin"),{loading:s,loginAdmin:d,loginTeacher:p,loginStudent:b}=R(),{register:m,handleSubmit:j,setError:v,formState:{errors:i}}=$({resolver:B(F),mode:"onBlur",defaultValues:{document_number:"",password:""}}),f={admin:d,teacher:p,student:b},y=async w=>{try{const l=f[t],c=await l(w);if(!c.success){H(c,v,"Error al iniciar sesión");return}const I=c.data?.user?.names||c.data?.user?.name||"Usuario";u.success(`¡Bienvenido, ${I}!`)}catch(l){console.error("Error inesperado en login:",l),u.error("Error de conexión. Intente nuevamente.")}},N=t==="admin"||o;return e.jsxs("div",{className:"bg-white rounded-xl p-6 md:my-12 shadow-sm border border-gray-200 max-w-4xl mx-auto",children:[e.jsx(h,{show:s,message:"Iniciando sesión...",variant:"glass"}),e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Iniciar Sesión"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Ingrese sus credenciales para continuar"})]}),e.jsx(W,{selectedType:t,onTypeChange:r,disabled:s}),N?e.jsxs(e.Fragment,{children:[e.jsxs("form",{onSubmit:j(y),className:"space-y-5 mt-6",children:[e.jsxs("div",{children:[e.jsx(x,{...m("document_number"),label:"Número de Documento",placeholder:"Ingrese su documento",icon:z,type:"text",inputMode:"numeric",maxLength:12,disabled:s,error:i.document_number?.message}),e.jsx(g,{message:i.document_number?.message})]}),e.jsxs("div",{children:[e.jsx(x,{...m("password"),label:"Contraseña",placeholder:"Ingrese su contraseña",type:"password",icon:G,disabled:s,error:i.password?.message}),e.jsx(g,{message:i.password?.message})]}),e.jsx(T,{type:"submit",variant:"primary",size:"lg",text:s?"Iniciando sesión...":"Iniciar Sesión",leftIcon:!s&&e.jsx(q,{className:"w-5 h-5"}),loading:s,disabled:s,fullWidth:!0,className:"mt-6"})]}),e.jsx("div",{className:"mt-6 p-4 bg-blue-50 border border-blue-200 rounded-lg",children:e.jsxs("p",{className:"text-xs text-blue-800 text-center leading-relaxed",children:["💡 ",e.jsx("strong",{children:"Importante:"})," Ingrese su número de documento (DNI, CE, etc.) de ",e.jsx("strong",{children:"8 a 12 dígitos"})," y su contraseña registrada."]})}),o&&e.jsx("div",{className:"mt-4 text-center",children:e.jsxs("p",{className:"text-sm text-gray-600",children:["¿No tienes una cuenta?"," ",e.jsx(A,{to:"/register",className:"text-[#00306e] font-medium hover:text-[#00439e] transition-colors duration-200",children:"Regístrate aquí"})]})})]}):e.jsx(E,{cycle:n,refresh:a,compact:!0})]})},be=()=>{k(!1);const{cycle:n,loading:o,hasCycle:a,refresh:t}=C(!0,!1);return e.jsxs(e.Fragment,{children:[e.jsx(h,{show:o,message:"Verificando disponibilidad de inscripciones...",variant:"light"}),e.jsxs("div",{className:"relative z-0",children:[e.jsx(U,{}),e.jsx("div",{children:e.jsx(J,{cycle:n,hasCycle:a,refresh:t})}),e.jsx(_,{})]})]})};export{be as default};
