import{_ as x,r as u,I as O,E as $,c as l,o as i,a as e,t as n,f as h,w as S,F as T,h as P,i as v,S as d,e as I,d as V,v as j}from"./app-L4cdeQDO.js";/* empty css            */const C={class:"bg-light vh-100 d-flex align-items-center justify-content-center"},B={class:"login-wizard bg-white col-12 col-lg-8 theme-shadow p-4"},R={class:"row"},A={class:"col-12 col-lg-6 px-5 py-4"},D={class:"d-flex h-100"},E={class:"my-auto w-100"},L={class:"fw-bold mb-3"},N={class:"text-muted"},F={class:"otp-fields d-flex mb-4"},M=["onUpdate:modelValue","onInput"],U={key:0,class:"d-block mb-3"},q={class:"text-primary"},z={type:"submit",class:"btn btn-primary w-100 rounded-pill mt-3"},W={__name:"VerifyOtp",setup(Y){const g=O(),_=I(),r=u(["","","",""]),f=u([]),p=u(g.query.email),y=$(),a=u(59);setInterval(()=>{a.value>0&&(a.value--,a.value<10?a.value="0"+a.value:a.value)},1e3);const w=async()=>{var s,t;try{const o=await v.post("/reset-password/validate",{otp:r.value.join(""),email:p.value});y.setAuthData(o.data.data.token,o.data.data.user),d.fire({icon:"success",title:$t("OTP Verified"),text:$t("You can now change your password"),showConfirmButton:!1,timer:1500}),_.push("/new_password")}catch(o){d.fire({icon:"error",title:"Oops...",text:((t=(s=o.response)==null?void 0:s.data)==null?void 0:t.message)||$t("Something went wrong. Please try again")})}},b=async()=>{var s,t;try{v.post("/reset-password",{email:p.value},{headers:{"Content-Type":"application/json",Accept:"application/json"}}),d.fire({icon:"success",title:"Success",text:$t("Password reset link sent to your email address"),showConfirmButton:!1,timer:1500}),a.value=59}catch(o){d.fire({icon:"error",title:"Oops...",text:((t=(s=o.response)==null?void 0:s.data)==null?void 0:t.message)||$t("Something went wrong. Please try again")})}},k=(s,t)=>{const o=s.target;o.value.length===1&&(r.value.splice(t,1,o.value),t<r.value.length-1&&f.value[t+1].focus())};return(s,t)=>(i(),l("section",C,[e("section",B,[e("div",R,[e("div",A,[t[0]||(t[0]=e("img",{src:"/assets/images/logo-new.png",class:"object-fit-cover",alt:"Login",height:"50px"},null,-1)),e("div",D,[e("div",E,[e("h3",L,n(s.$t("Enter Code")),1),e("span",N,[h(n(s.$t("We sent an OTP code to your email address"))+" - ",1),e("strong",null,n(p.value),1)]),e("form",{onSubmit:S(w,["prevent"]),class:"my-4"},[e("div",F,[(i(!0),l(T,null,P(r.value,(o,c)=>V((i(),l("input",{type:"number",class:"form-control text-center py-3 me-3",maxlength:"1",key:c,ref_for:!0,ref_key:"otpInput",ref:f,"onUpdate:modelValue":m=>r.value[c]=m,onInput:m=>k(m,c),placeholder:"_"},null,40,M)),[[j,r.value[c]]])),128))]),a.value!=="00"?(i(),l("span",U,[h(n(s.$t("Resend OTP in"))+" ",1),e("span",q,"00:"+n(a.value),1)])):(i(),l("a",{key:1,onClick:b,class:"text-primary d-block"},n(s.$t("Resend OTP")),1)),e("button",z,n(s.$t("Confirm OTP")),1)],32)])])]),t[1]||(t[1]=e("div",{class:"d-none d-lg-block col-6"},[e("img",{src:"/assets/images/login-bg.png",class:"side-image object-fit-cover w-100"})],-1))])])]))}},J=x(W,[["__scopeId","data-v-a73abd39"]]);export{J as default};
