import{_ as w,u as h,a as k,c as m,b as s,d as g,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 l,j as L,k as A,o as i,l as B}from"./index-Dd5IVJne.js";import{E}from"./ErrorMessage-a6bz43cw.js";import{L as I}from"./LoadingSpinner-jnwft0T9.js";const M={class:"login-page"},T={class:"login-content"},U={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(),d=h(),u=k(),c=l(""),p=l(""),o=l(""),a=l(!1),y=async()=>{o.value="",a.value=!0;try{await d.login(c.value,p.value);const r={admin:"/admin",barber:"/barber/agenda",client:"/client/book"},e=d.user.role==="client"?"/client/inicio":r[d.user.role]||"/login";f.push(e)}catch(r){const e=r.response?.data,n=e?.errors&&Object.values(e.errors)[0],t=Array.isArray(n)?n[0]:null;o.value=t||e?.message||"Error al iniciar sesión"}finally{a.value=!1}};return(r,e)=>{const n=L("router-link");return i(),m("div",M,[s("div",T,[s("div",U,[s("img",{src:g(u).logoUrl,alt:g(u).businessName,class:"login-logo"},null,8,j),s("h1",q,x(g(u).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=>c.value=t),type:"text",id:"credential",name:"credential",autocomplete:"username",class:"input-control",placeholder:"88881234 o tu@email.com",required:""},null,512),[[b,c.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=>p.value=t),type:"password",id:"password",name:"password",autocomplete:"current-password",class:"input-control",placeholder:"••••••••",required:""},null,512),[[b,p.value]])]),o.value?(i(),_(E,{key:0,message:o.value},null,8,["message"])):N("",!0),s("button",{type:"submit",disabled:a.value,class:"btn btn-gold",style:{"margin-top":"20px"}},[a.value?(i(),_(I,{key:0})):(i(),m("span",O,"Ingresar"))],8,F),V(n,{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-cd90ab42"]]);export{K as default};
