import{u as P,a as R,s as n,l as b}from"./index.ab3d776b.js";/* empty css               *//* empty css              */import{C as y}from"./Cover.fc91526c.js";import{s as o}from"./ForgotPassword.module.51f61226.js";import{P as g}from"./regular.2d81b23f.js";import{f as v}from"./antd.5e666edb.js";import{u as I}from"./RSA.f54b2b0a.js";import{u as N,i as C,j as e,d as t}from"./react.6693569e.js";import{F as i,I as l,B as m,m as p}from"./antd.e57bc55d.js";const{layout:j}=v,_=()=>{const u=N(),w=C(),{T:s}=P(),{encrypt:f}=I(),h=async({password:d})=>{try{await R.authApi.forceResetPassword({password:f(d)}),p.success(s("forceResetPassword.submit.success")),n.authStore.clearSession(),setTimeout(()=>{const{redirect_uri:r}=b.parse(u.search.slice(1));window.location.href=decodeURIComponent(decodeURIComponent(r))||n.configStore.baseUrl},1e3)}catch(r){console.error(r);const a={"password should not same as old":s("forceResetPassword.submit.error.passwordShouldNotSameAsOld")};p.error(a[r==null?void 0:r.message]||s("forceResetPassword.submit.error.basic"))}};return e(y,{children:t("div",{className:o.forgotPassword,children:[t("div",{className:o.title,children:[e("div",{className:o.header,children:s("forceResetPassword.header")}),e("div",{className:o.tip,children:s("forceResetPassword.tip")})]}),t(i,{className:o.form,...j,onFinish:h,children:[e(i.Item,{label:s("forceResetPassword.label.password"),name:"password",rules:[{required:!0,message:s("forceResetPassword.rules.password.required")},{pattern:g,message:s("forceResetPassword.rules.password.pattern")}],children:e(l.Password,{})}),e(i.Item,{label:s("forceResetPassword.label.repassword"),name:"repassword",required:!0,rules:[({getFieldValue:d})=>({validator:(r,a)=>{if(!a)return Promise.reject(s("forceResetPassword.rules.repassword.required"));const c=d("password");return c&&c!==a?Promise.reject(s("forceResetPassword.rules.repassword.validator")):Promise.resolve()}})],children:e(l.Password,{})}),e(i.Item,{wrapperCol:{span:24},children:t("div",{className:o.btnGroup,children:[e(m,{type:"primary",htmlType:"submit",children:s("forceResetPassword.submit.button")}),e(m,{onClick:()=>w.go(-1),children:s("forceResetPassword.goBackButton")})]})})]})]})})};export{_ as default};
