import W from"./p230hGW8.js";import X from"./Bvs3L9q-.js";import{u as Y,s as F,b as Z,d as x,e as ss,r as p,I as es,f as h,m as l,A as m,p as s,v as as,k as o,t as a,F as L,B as os,D as N,E as T,G as j,C as y,l as _,w as k,q as v,_ as ts,j as r}from"./BCLrUOBx.js";import{u as ls}from"./CCot8u0_.js";import{u as rs}from"./XuZCjD2R.js";import"./CWalxxGV.js";const ns={key:0,class:"error-list mb-15"},is={class:"mb-10"},us={class:"icon-input"},ds=["placeholder"],ps={key:0,class:"error"},cs={key:1,class:"error"},ms={class:"icon-input"},vs=["placeholder"],fs={key:0,class:"error"},gs={key:0,class:"error"},ws={key:1,class:"error"},$s={key:0,class:"error"},_s={key:1,class:"error"},hs={class:"flex right no-space"},ys={class:"mt-20 mt-sm-15 mb-10"},Ps={key:1},bs={class:"mb-15 bold"},ks={class:"mb-15"},Vs={class:"mb-15"},Ds={__name:"forgot-password",setup(Cs){var B;const I=Y(),{langCode:V}=F(I),C=Z(),{unAuthPost:S,setToastMessage:O}=C,{customScripts:Ss,site_setting:R}=F(C),{t:E}=x(),{pageMeta:U}=ls();ss(U({...R.value,meta_title:`${E("login.forgotPassword")} | ${(B=R.value)==null?void 0:B.meta_title}`}));const n=p(""),u=p(""),c=p(""),f=p(""),g=p([]),t=p(!1),w=p(!1),$=p(!1),P=p(!1);es(n,()=>{b.value||(t.value=!1)});const{isValidEmail:H,isValidLength:z}=rs(),b=h(()=>!H(n.value)),G=h(()=>n.value&&!b.value),q=h(()=>!z(u.value)),M=h(()=>u.value&&!q.value),J=async()=>{if(!$.value&&n.value)if(n.value){w.value=!0;const e=await S({params:{email:n.value},lang:V.value,api:"forgotPassword"});e.status===200?(O(E("forgotPassword.sentEmail")),$.value=!0,t.value=!1,g.value=[]):g.value=e.data.form,w.value=!1}else t.value=!0;else if(c.value&&n.value&&u.value&&u.value===f.value){w.value=!0;const e=await S({params:{email:n.value,code:c.value,password:u.value},lang:V.value,api:"updatePassword"});e.status===200?(P.value=!0,t.value=!1,g.value=[]):g.value=e.data.form,w.value=!1}else t.value=!0};return(e,i)=>{const A=W,K=X,D=ts;return r(),l("div",null,[!s($)||!s(P)?(r(),l("form",{key:0,onSubmit:as(J,["prevent"])},[s(g).length?(r(),l("ul",ns,[o("li",is,a(e.$t("forgotPassword.errorOccurred")),1),(r(!0),l(L,null,os(s(g),(d,Q)=>(r(),l("li",{key:Q},a(d),1))),128))])):m("",!0),o("div",{class:y(["input-wrap",{invalid:!s(G)&&s(t)}])},[o("label",null,a(e.$t("addressPopup.email")),1),o("div",us,[i[4]||(i[4]=o("i",{class:"icon email-icon"},null,-1)),N(o("input",{type:"text","onUpdate:modelValue":i[0]||(i[0]=d=>j(n)?n.value=d:null),placeholder:e.$t("contact.your",{type:e.$t("contact.email")})},null,8,ds),[[T,s(n)]])]),!s(n)&&s(t)?(r(),l("span",ps,a(e.$t("addressPopup.isRequired",{type:e.$t("addressPopup.email")})),1)):s(b)&&s(t)?(r(),l("span",cs,a(e.$t("contact.invalidEmail")),1)):m("",!0)],2),s($)?(r(),l(L,{key:1},[o("div",{class:y(["input-wrap",{invalid:!s(c)&&s(t)}])},[o("label",null,a(e.$t("forgotPassword.code")),1),o("div",ms,[i[5]||(i[5]=o("i",{class:"icon code-icon"},null,-1)),N(o("input",{type:"text","onUpdate:modelValue":i[1]||(i[1]=d=>j(c)?c.value=d:null),placeholder:e.$t("forgotPassword.codeFrom")},null,8,vs),[[T,s(c)]])]),!s(c)&&s(t)?(r(),l("span",fs,a(e.$t("addressPopup.isRequired",{type:e.$t("forgotPassword.code")}))+" Code is Required ",1)):m("",!0)],2),o("div",{class:y(["input-wrap",{invalid:!s(M)&&s(t)}])},[o("label",null,a(e.$t("profile.password")),1),_(A,{value:s(u),onOnChange:i[2]||(i[2]=d=>u.value=d)},null,8,["value"]),!s(u)&&s(t)?(r(),l("span",gs,a(e.$t("addressPopup.isRequired",{type:e.$t("profile.password")})),1)):s(q)&&s(t)?(r(),l("span",ws,a(e.$t("profile.invalidLength")),1)):m("",!0)],2),o("div",{class:y(["input-wrap",{invalid:(!s(M)||s(f)!==s(u))&&s(t)}])},[o("label",null,a(e.$t("profile.confirmPassword")),1),_(A,{value:s(f),onOnChange:i[3]||(i[3]=d=>f.value=d)},null,8,["value"]),!s(f)&&s(t)?(r(),l("span",$s,a(e.$t("addressPopup.isRequired",{type:e.$t("profile.password")})),1)):s(f)!==s(u)&&s(t)?(r(),l("span",_s,a(e.$t("profile.noMatch")),1)):m("",!0)],2)],64)):m("",!0),o("div",hs,[_(K,{class:"primary-btn plr-20 w-50","fetching-data":s(w),"loading-text":e.$t("checkoutRight.submitting")},{default:k(()=>[v(a(e.$t("ajaxButton.submit")),1)]),_:1},8,["fetching-data","loading-text"])]),o("div",ys,[v(a(e.$t("forgotPassword.noAccount"))+" ",1),_(D,{to:"/register",class:"mlr-10 link bold color-primary"},{default:k(()=>[v(a(e.$t("forgotPassword.createAccount")),1)]),_:1})])],32)):s($)&&s(P)?(r(),l("div",Ps,[o("h4",bs,a(e.$t("contact.success"))+"!!!",1),o("p",ks,[o("b",null,a(e.$t("forgotPassword.congratulations")),1),v(". "+a(e.$t("forgotPassword.verified")),1)]),o("p",Vs,[v(a(e.$t("forgotPassword.youCan"))+" ",1),_(D,{to:"/login",class:"mlr-10 link bold color-primary"},{default:k(()=>[v(a(e.$t("forgotPassword.signIn")),1)]),_:1}),v(" "+a(e.$t("contact.now"))+". ",1)])])):m("",!0)])}}};export{Ds as default};
