import{C as e,E as t,Ht as n,Lt as r,Q as i,R as a,W as o,_ as s,b as c,d as l,g as u,gt as d,lt as f,ut as p,w as m}from"./vue.runtime.esm-bundler-56z_v_HH.js";import{a as h,i as g}from"./vue-router-_izWfDzq.js";import{t as _}from"./notification.store-EczSZ_VB.js";import{n as v,r as y}from"./error-handling-S7N4FACK.js";import{t as b}from"./store-DIrP_oUf.js";import{r as x}from"./routes-B4sdSdat.js";import{n as S}from"./vue-i18n-DhldrKy8.js";import{D as C,M as w,O as T,T as E}from"./main-CkEZzrzw.js";var D={class:`flex items-center justify-between`},O=t({__name:`CustomerPortalLoginView`,setup(t){let O=b(),k=_(),A=g(),j=h(),{t:M}=S(),N=f({email:``,password:``}),P=p(!1),F=p(!1),I=u(()=>x(A.params.company)),L=u(()=>F.value?`text`:`password`),R=E(u(()=>({email:{required:C.withMessage(M(`validation.required`),w),email:C.withMessage(M(`validation.email_incorrect`),T)},password:{required:C.withMessage(M(`validation.required`),w)}})),N);async function z(){if(R.value.$touch(),!(R.value.$invalid||!I.value)){P.value=!0;try{await O.login({...N,company:I.value,device_name:`customer-portal-web`}),await O.bootstrap(I.value),k.showNotification({type:`success`,message:M(`general.login_successfully`)}),await j.push({name:`customer-portal.dashboard`,params:{company:I.value}})}catch(e){B(e)}finally{P.value=!1}}}function B(e){let t=y(e),n=v(t.message);k.showNotification({type:`error`,message:n?M(n):t.message})}return(t,u)=>{let f=o(`BaseInput`),p=o(`BaseInputGroup`),h=o(`BaseIcon`),g=o(`router-link`),_=o(`BaseButton`);return a(),c(`form`,{class:`space-y-6`,onSubmit:l(z,[`prevent`])},[m(p,{error:d(R).email.$error?String(d(R).email.$errors[0]?.$message):void 0,label:t.$t(`login.email`),required:``},{default:i(()=>[m(f,{modelValue:N.email,"onUpdate:modelValue":u[0]||=e=>N.email=e,invalid:d(R).email.$error,focus:``,name:`email`,type:`email`,onInput:u[1]||=e=>d(R).email.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`error`,`label`]),m(p,{error:d(R).password.$error?String(d(R).password.$errors[0]?.$message):void 0,label:t.$t(`login.password`),required:``},{default:i(()=>[m(f,{modelValue:N.password,"onUpdate:modelValue":u[3]||=e=>N.password=e,invalid:d(R).password.$error,type:L.value,name:`password`,onInput:u[4]||=e=>d(R).password.$touch()},{right:i(()=>[m(h,{name:F.value?`EyeIcon`:`EyeSlashIcon`,class:`mr-1 cursor-pointer text-muted`,onClick:u[2]||=e=>F.value=!F.value},null,8,[`name`])]),_:1},8,[`modelValue`,`invalid`,`type`])]),_:1},8,[`error`,`label`]),s(`div`,D,[m(g,{to:{name:`customer-portal.forgot-password`,params:{company:I.value}},class:`text-sm text-primary-500 hover:text-heading`},{default:i(()=>[e(n(t.$t(`login.forgot_password`)),1)]),_:1},8,[`to`])]),m(_,{disabled:P.value,loading:P.value,class:`w-full justify-center`,type:`submit`},{left:i(e=>[m(h,{name:`LockClosedIcon`,class:r(e.class)},null,8,[`class`])]),default:i(()=>[e(` `+n(t.$t(`login.login`)),1)]),_:1},8,[`disabled`,`loading`])],32)}}});export{O as default};