import Q from"./p230hGW8.js";import{b as W,s as C,r as p,a as X,c as Y,d as Z,e as x,u as ee,h as se,f as v,m as l,A as w,k as o,p as s,t,F as te,B as ae,D as oe,E as re,G as ne,C as E,l as f,w as T,q as $,v as le,_ as ie,j as i,n as ue}from"./BCLrUOBx.js";import ce from"./Bvs3L9q-.js";import{u as de}from"./CCot8u0_.js";import{u as pe}from"./XuZCjD2R.js";import"./CWalxxGV.js";const me={key:0,class:"error-list mb-15"},ve={class:"mb-10"},fe={class:"icon-input"},ge=["placeholder"],_e={key:0,class:"error"},he={key:1,class:"error"},we={key:0,class:"error"},$e={key:1,class:"error"},ke={class:"no-space flex sided"},ye={class:"mt-20 mt-sm-15 mb-10"},Me={__name:"login",setup(Se){var V;const k=W(),{customScripts:be,site_setting:y}=C(k),{unAuthPost:A,getRequest:M}=k,r=p(""),u=p(""),R=X(),{setProfile:q,getUserToken:B}=R,L=Y(),{setToken:N}=L,U=e=>{u.value=e},{t:D}=Z(),{pageMeta:F}=de();x(F({...y.value,meta_title:`${D("header.login")} | ${(V=y.value)==null?void 0:V.meta_title}`}));const I=ee(),{langCode:S}=C(I),b=p("");se(()=>{b.value=localStorage.getItem("redirection_url","")});const n=p(!1),m=p([]),g=p(!1),{isValidEmail:j,isValidLength:H}=pe(),P=v(()=>!j(r.value)),O=v(()=>r.value&&!P.value),_=v(()=>!H(u.value)),z=v(()=>u.value&&!_.value),G=async()=>{var e,c;if(m.value=[],r.value&&u.value&&!_.value){g.value=!0;const d=await A({params:{user_token:await B(),password:u.value,email:r.value},lang:S.value,api:"login"});if(d.status===200){N(d.data.token);const a=await M({params:"",lang:S.value,api:"profile"});if((a==null?void 0:a.status)===200)return n.value=!1,q(a.data),ue(b.value||"/");m.value=(e=a==null?void 0:a.data)==null?void 0:e.form}else m.value=(c=d==null?void 0:d.data)==null?void 0:c.form;g.value=!1}else n.value=!0};return(e,c)=>{const d=Q,a=ie,J=ce;return i(),l("form",{onSubmit:le(G,["prevent"])},[s(m).length?(i(),l("ul",me,[o("li",ve,t(e.$t("forgotPassword.errorOccurred")),1),(i(!0),l(te,null,ae(s(m),(h,K)=>(i(),l("li",{key:K},t(h),1))),128))])):w("",!0),o("div",{class:E(["input-wrap",{invalid:!s(O)&&s(n)}])},[o("label",null,t(e.$t("addressPopup.email")),1),o("div",fe,[c[1]||(c[1]=o("i",{class:"icon email-icon"},null,-1)),oe(o("input",{type:"text",placeholder:e.$t("contact.your",{type:e.$t("contact.email")}),"onUpdate:modelValue":c[0]||(c[0]=h=>ne(r)?r.value=h:null)},null,8,ge),[[re,s(r),void 0,{trim:!0}]])]),!s(r)&&s(n)?(i(),l("span",_e,t(e.$t("addressPopup.isRequired",{type:e.$t("addressPopup.email")})),1)):s(P)&&s(n)?(i(),l("span",he,t(e.$t("contact.invalidEmail")),1)):w("",!0)],2),o("div",{class:E(["input-wrap",{invalid:!s(z)&&s(n)}])},[o("label",null,t(e.$t("profile.password")),1),f(d,{value:s(u),onOnChange:U},null,8,["value"]),!s(u)&&s(n)?(i(),l("span",we,t(e.$t("addressPopup.isRequired",{type:e.$t("profile.password")})),1)):s(_)&&s(n)?(i(),l("span",$e,t(e.$t("profile.invalidLength")),1)):w("",!0)],2),o("div",ke,[f(a,{to:"/forgot-password",class:"link color-lite"},{default:T(()=>[$(t(e.$t("login.forgotPassword")),1)]),_:1}),f(J,{class:"primary-btn plr-30 plr-sm-15","fetching-data":s(g),"loading-text":e.$t("login.loggingIn")},null,8,["fetching-data","loading-text"])]),o("div",ye,[$(t(e.$t("forgotPassword.noAccount"))+" ",1),f(a,{to:"/register",class:"mlr-10 link bold color-primary"},{default:T(()=>[$(t(e.$t("forgotPassword.createAccount")),1)]),_:1})])],32)}}};export{Me as default};
