import{e as C,L as j,v as L,f as w,k as $,j as M,r as d,o as c,c as E,a as r,w as i,l as e,m as y,b as D,p as B,t as b,J as N,q as T,g,h as I,i as G}from"./main-B9dpPbRR.js";import{u as O}from"./auth-6FPSPboo.js";const P={class:"flex items-center justify-between"},A={__name:"Login",setup(R){const _=C(),k=j(),s=O(),{t:m}=L.useI18n();let u=w(!1);const l=w(!1),h=$(()=>l.value?"text":"password"),V=$(()=>({loginData:{email:{required:g.withMessage(m("validation.required"),I),email:g.withMessage(m("validation.email_incorrect"),G)},password:{required:g.withMessage(m("validation.required"),I)}}})),o=M(V,s);async function q(){if(o.value.loginData.$touch(),o.value.loginData.$invalid)return!0;u.value=!0;let n={...s.loginData,company:k.params.company};try{return await s.login(n),u.value=!1,_.push({name:"customer.dashboard"});s.$reset()}catch{u.value=!1}}return(n,a)=>{const v=d("BaseInput"),f=d("BaseInputGroup"),p=d("BaseIcon"),x=d("router-link"),S=d("BaseButton");return c(),E("form",{id:"loginForm",class:"space-y-6",action:"#",method:"POST",onSubmit:T(q,["prevent"])},[r(f,{error:e(o).loginData.email.$error&&e(o).loginData.email.$errors[0].$message,label:n.$t("login.email"),class:"mb-4",required:""},{default:i(()=>[r(v,{modelValue:e(s).loginData.email,"onUpdate:modelValue":a[0]||(a[0]=t=>e(s).loginData.email=t),type:"email",invalid:e(o).loginData.email.$error,onInput:a[1]||(a[1]=t=>e(o).loginData.email.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["error","label"]),r(f,{error:e(o).loginData.password.$error&&e(o).loginData.password.$errors[0].$message,label:n.$t("login.password"),class:"mb-4",required:""},{default:i(()=>[r(v,{modelValue:e(s).loginData.password,"onUpdate:modelValue":a[4]||(a[4]=t=>e(s).loginData.password=t),type:h.value,invalid:e(o).loginData.password.$error,onInput:a[5]||(a[5]=t=>e(o).loginData.password.$touch())},{right:i(()=>[l.value?(c(),y(p,{key:0,name:"EyeOffIcon",class:"w-5 h-5 mr-1 text-gray-500 cursor-pointer",onClick:a[2]||(a[2]=t=>l.value=!l.value)})):(c(),y(p,{key:1,name:"EyeIcon",class:"w-5 h-5 mr-1 text-gray-500 cursor-pointer",onClick:a[3]||(a[3]=t=>l.value=!l.value)}))]),_:1},8,["modelValue","type","invalid"])]),_:1},8,["error","label"]),D("div",P,[r(x,{to:{name:"customer.forgot-password"},class:"text-sm text-primary-600 hover:text-gray-500"},{default:i(()=>[B(b(n.$t("login.forgot_password")),1)]),_:1},8,["to"])]),D("div",null,[r(S,{loading:e(u),disabled:e(u),type:"submit",class:"w-full justify-center"},{left:i(t=>[r(p,{name:"LockClosedIcon",class:N(t.class)},null,8,["class"])]),default:i(()=>[B(" "+b(n.$t("login.login")),1)]),_:1},8,["loading","disabled"])])],32)}}};export{A as default};
