import{_ as w,u as k,a as h,c as m,b as s,d,t as x,w as S,e as v,v as b,f as _,g as N,h as V,i as C,r as u,j as L,k as A,o,l as B}from"./index-3TWHIczS.js";import{E}from"./ErrorMessage-BHF5LlOC.js";import{L as I}from"./LoadingSpinner-COK2j8hC.js";const M={class:"login-page"},U={class:"login-content"},T={class:"login-brand"},j=["src","alt"],q={class:"header-title login-title"},D={class:"input-group"},R={class:"input-group"},F=["disabled"],O={key:1},P={__name:"LoginView",setup(z){const f=A(),c=k(),a=h(),p=u(""),g=u(""),r=u(""),n=u(!1),y=async()=>{r.value="",n.value=!0;try{await c.login(p.value,g.value);const l={admin:"/admin",barber:"/barber/agenda",client:"/client/book"},e=c.user.role==="client"?"/client/inicio":l[c.user.role]||"/login";f.push(e)}catch(l){const e=l.response?.data,i=e?.errors&&Object.values(e.errors)[0],t=Array.isArray(i)?i[0]:null;r.value=t||e?.message||"Error al iniciar sesión"}finally{n.value=!1}};return(l,e)=>{const i=L("router-link");return o(),m("div",M,[s("div",U,[s("div",T,[(o(),m("img",{key:d(a).logoUrl,src:d(a).logoUrl,alt:d(a).businessName,class:"login-logo"},null,8,j)),s("h1",q,x(d(a).businessName),1),e[2]||(e[2]=s("p",{class:"login-subtitle"},"Iniciá sesión para reservar",-1))]),s("form",{onSubmit:S(y,["prevent"])},[s("div",D,[e[3]||(e[3]=s("label",{for:"credential"},"Teléfono o correo",-1)),v(s("input",{"onUpdate:modelValue":e[0]||(e[0]=t=>p.value=t),type:"text",id:"credential",name:"credential",autocomplete:"username",class:"input-control",placeholder:"88881234 o tu@email.com",required:""},null,512),[[b,p.value]])]),s("div",R,[e[4]||(e[4]=s("label",{for:"password"},"Contraseña o PIN",-1)),v(s("input",{"onUpdate:modelValue":e[1]||(e[1]=t=>g.value=t),type:"password",id:"password",name:"password",autocomplete:"current-password",class:"input-control",placeholder:"••••••••",required:""},null,512),[[b,g.value]])]),r.value?(o(),_(E,{key:0,message:r.value},null,8,["message"])):N("",!0),s("button",{type:"submit",disabled:n.value,class:"btn btn-gold",style:{"margin-top":"20px"}},[n.value?(o(),_(I,{key:0})):(o(),m("span",O,"Ingresar"))],8,F),V(i,{to:"/register",class:"btn btn-outline",style:{"margin-top":"15px",display:"block","text-align":"center","text-decoration":"none"}},{default:C(()=>[...e[5]||(e[5]=[B(" Crear Cuenta Nueva ",-1)])]),_:1})],32)])])}}},K=w(P,[["__scopeId","data-v-b20d2339"]]);export{K as default};
