import{d as F,a3 as j,l as d,aC as L,k as M,a4 as D,r as E,o as i,b as u,w as o,s as e,n as m,q as t,a6 as O,a7 as R,aM as v,B as P,L as $,ay as I,V as T,h as H,x as J,I as V,c as U,y as Q,av as W,S as G,H as C,aI as A,b4 as K,W as X,bN as Y,bR as Z,aQ as ee,aB as ae}from"./index-2e57ee69.js";import{_ as se}from"./AppTextField.vue_vue_type_script_setup_true_lang-e8a09900.js";import{a as h,V as k}from"./VRow-22fc34ca.js";import{V as te}from"./VCheckbox-f4762d5d.js";import{b as B}from"./route-block-83d24a4e.js";import"./VCheckboxBtn-0a0e30be.js";const oe={class:"position-relative w-100 ma-8 me-0"},ne={class:"d-flex align-center justify-center w-100 h-100"},le={class:"text-h4 mb-1"},ie={key:0,class:"text-capitalize"},re=m("p",{class:"mb-0"},"Inicie sesión en su cuenta para continuar...",-1),de={class:"d-flex align-center flex-wrap justify-space-between mt-2 mb-4"},ue={key:0},me=F({__name:"login",setup(ce){const s=j(),c=d(!1),p=L(),N=M(),w=D(),x=d({email:void 0,password:void 0}),S=d(),r=d(!1),f=d(p.query.email?String(p.query.email):""),g=d(""),_=d(!1),q=async()=>{r.value=!0,Y.login({email:f.value,password:g.value,remember:_.value}).then(async a=>{const{accessToken:n,userData:y}={accessToken:a.data.token,userData:{id:a.data.roles[0].pivot.user_id,names:a.data.user.names,photo:a.data.user.photo,email:a.data.user.email,phone:a.data.user.phone,role:a.data.roles.find(l=>l.id===a.data.current_role),maximumFileSizeToUpload:a.data.maximum_file_size_to_upload,extensionsAllowedToUpload:a.data.extensions_allowed_to_upload,document_type:a.data.user.document_type,document_number:a.data.user.document_number}},b=Z(a.data.menu);localStorage.setItem("userAbilities",JSON.stringify(b)),w.update(b),s.set({...s.get(),token:n,user:y,roles:a.data.roles}),N.replace(p.query.to?String(p.query.to):"/").then(()=>{s.toggleChangingRole(),setTimeout(()=>{ee(w).finally(()=>{s.toggleChangingRole()})},500)})}).catch(a=>{ae.error(a)}).finally(()=>{r.value=!1})},z=()=>{var a;(a=S.value)==null||a.validate().then(({valid:n})=>{n&&q()})};return(a,n)=>{const y=se,b=E("RouterLink");return i(),u(k,{"no-gutters":"",class:"auth-wrapper bg-surface"},{default:o(()=>[e(s).systemConfiguration&&e(s).systemConfiguration.banner&&e(s).systemConfiguration.banner!==""?(i(),u(h,{key:0,lg:"8",class:"d-none d-lg-flex",style:{height:"100vh"}},{default:o(()=>[m("div",oe,[m("div",ne,[t(O,{height:"100%",src:e(R).getUrlImage(e(s).systemConfiguration.banner),class:"rounded-lg",cover:"",position:"center"},{placeholder:o(()=>[t(k,{align:"center",class:"fill-height ma-0",justify:"center"},{default:o(()=>[t(e(v),{color:"grey-lighten-5",indeterminate:""})]),_:1})]),_:1},8,["src"])])])]),_:1})):P("",!0),t(h,{cols:"12",lg:e(s).systemConfiguration&&e(s).systemConfiguration.banner&&e(s).systemConfiguration.banner!==""?"4":"12",class:"auth-card-v2 d-flex align-center justify-center px-4"},{default:o(()=>[t($,{flat:"",width:500,class:"mt-12 mt-sm-0 pa-4"},{default:o(()=>[t(I,null,{default:o(()=>[e(s).systemConfiguration&&e(s).systemConfiguration.logo?(i(),u(e(T),{key:0,nodes:("h"in a?a.h:e(H))("img",{attrs:{src:e(R).getUrlImage(e(s).systemConfiguration.logo)}})},null,8,["nodes"])):(i(),u(e(T),{key:1,nodes:e(J).app.logo,class:"mb-6"},null,8,["nodes"])),m("h5",le,[V(" Bienvenido(a) a "),e(s).systemConfiguration!==null?(i(),U("span",ie,Q(e(s).systemConfiguration.institution_name),1)):(i(),u(e(v),{key:1,indeterminate:"",color:"primary",size:"20",width:"2"})),V("!👋🏻 ")]),re]),_:1}),t(I,null,{default:o(()=>[t(e(W),{ref_key:"refVForm",ref:S,onSubmit:G(z,["prevent"])},{default:o(()=>[t(k,null,{default:o(()=>[t(h,{cols:"12"},{default:o(()=>[t(y,{modelValue:e(f),"onUpdate:modelValue":n[0]||(n[0]=l=>C(f)?f.value=l:null),label:"Email",type:"email",autofocus:"",rules:[e(A),e(K)],"error-messages":e(x).email,disabled:e(r)},null,8,["modelValue","rules","error-messages","disabled"])]),_:1}),t(h,{cols:"12"},{default:o(()=>[t(y,{modelValue:e(g),"onUpdate:modelValue":n[1]||(n[1]=l=>C(g)?g.value=l:null),label:"Contraseña",rules:[e(A)],type:e(c)?"text":"password","error-messages":e(x).password,"append-inner-icon":e(c)?"tabler-eye-off":"tabler-eye",disabled:e(r),"onClick:appendInner":n[2]||(n[2]=l=>c.value=!e(c))},null,8,["modelValue","rules","type","error-messages","append-inner-icon","disabled"]),m("div",de,[t(te,{modelValue:e(_),"onUpdate:modelValue":n[3]||(n[3]=l=>C(_)?_.value=l:null),label:"Recordarme",disabled:e(r)},null,8,["modelValue","disabled"]),t(b,{class:"text-primary ms-2 mb-1",to:{name:"forgot-password"}},{default:o(()=>[V(" ¿Olvidaste tu contraseña? ")]),_:1})]),t(X,{block:"",type:"submit",disabled:e(r)},{default:o(()=>[e(r)?(i(),u(e(v),{key:1,indeterminate:"",color:"white",size:"24"})):(i(),U("span",ue,"Acceder"))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["onSubmit"])]),_:1})]),_:1})]),_:1},8,["lg"])]),_:1})}}});typeof B=="function"&&B(me);export{me as default};
