import{$ as e,C as t,G as n,S as r,Wt as i,dt as a,h as o,u as s,ut as c,vt as l,y as u,z as d}from"./vue.runtime.esm-bundler-DAWRyTnP.js";import{t as f}from"./http-BdoVLsWz.js";import{a as p,i as m}from"./vue-router-Bna4o8ws.js";import{t as h}from"./notification-BM55Quw3.js";import{t as g}from"./error-handling-CuGxlkPL.js";import{n as _}from"./vue-i18n-C4HYJWrq.js";import{$ as v,J as y,K as b,Z as x,jn as S}from"./main-Gn9UsJwa.js";var C={__name:`ResetPassword`,setup(C){let w=h(),{t:T}=_(),E=m(),D=p(),O=c({email:``,password:``,password_confirmation:``}),k=a(!1),A=S(o(()=>({email:{required:x,email:b},password:{required:x,minLength:y(8)},password_confirmation:{sameAsPassword:v(O.password)}})),O),j=o(()=>A.value.email.$error?A.value.email.required.$invalid?T(`validation.required`):A.value.email.email?T(`validation.email_incorrect`):!1:``),M=o(()=>A.value.password.$error?A.value.password.required.$invalid?T(`validation.required`):A.value.password.minLength?T(`validation.password_min_length`,{count:A.value.password.minLength.$params.min}):!1:``),N=o(()=>A.value.password_confirmation.$error?A.value.password_confirmation.sameAsPassword.$invalid?T(`validation.password_incorrect`):!1:``);async function P(e){if(A.value.$touch(),!A.value.$invalid)try{let e={email:O.email,password:O.password,password_confirmation:O.password_confirmation,token:E.params.token};k.value=!0;let t=await f.post(`/api/v1/auth/reset/password`,e);k.value=!1,t.data&&(w.showNotification({type:`success`,message:T(`login.password_reset_successfully`)}),D.push(`/login`))}catch(e){g(e),k.value=!1,e.response&&e.response.status}}return(a,o)=>{let c=n(`BaseInput`),f=n(`BaseInputGroup`),p=n(`BaseButton`);return d(),u(`form`,{id:`loginForm`,onSubmit:s(P,[`prevent`])},[t(f,{error:j.value,label:a.$t(`login.email`),class:`mb-4`,required:``},{default:e(()=>[t(c,{modelValue:O.email,"onUpdate:modelValue":o[0]||=e=>O.email=e,invalid:l(A).email.$error,focus:``,type:`email`,name:`email`,onInput:o[1]||=e=>l(A).email.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`error`,`label`]),t(f,{error:M.value,label:a.$t(`login.password`),class:`mb-4`,required:``},{default:e(()=>[t(c,{modelValue:O.password,"onUpdate:modelValue":o[2]||=e=>O.password=e,invalid:l(A).password.$error,type:`password`,name:`password`,onInput:o[3]||=e=>l(A).password.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`error`,`label`]),t(f,{error:N.value,label:a.$t(`login.retype_password`),class:`mb-4`,required:``},{default:e(()=>[t(c,{modelValue:O.password_confirmation,"onUpdate:modelValue":o[4]||=e=>O.password_confirmation=e,invalid:l(A).password_confirmation.$error,type:`password`,name:`password`,onInput:o[5]||=e=>l(A).password_confirmation.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`error`,`label`]),t(p,{loading:k.value,type:`submit`,variant:`primary`},{default:e(()=>[r(i(a.$t(`login.reset_password`)),1)]),_:1},8,[`loading`])],32)}}};export{C as default};