import{c5 as T,c as P,e7 as C,v as d,y as I,o as E,b as o,n as p,W as M,t as x,cZ as N,cn as W,fq as O}from"./index-6Jqoo2rk.js";import{u as D,s as _,B as z}from"./bootstrapIm-BS8HLnlI.js";import{S as g}from"./simpleConfirmation-5BGWRx60.js";import{M as m}from"./mediaHeader-B5k-4_FU.js";import{t as k}from"./toast-B3QB1-N7.js";import{b as V,a as B,f as H}from"./anchorCallback-DsA1XczG.js";import{f as q}from"./focusWhenConnected-14rkj1jb.js";import{h as j}from"./htmlToSpan-DhAls8qz.js";import{A as Y}from"./AuthCard-Cghujz7c.js";import"./iconTsx-Cr8T7ZIv.js";import"./transition-DuxZkCEv.js";const Z=x('<svg xmlns=http://www.w3.org/2000/svg class=preloader-circular viewBox="25 25 50 50"><circle class=preloader-path cx=50 cy=50 r=20 fill=none stroke-miterlimit=10>');function oe($){const{managers:i,navigate:y,toIm:K}=D();let l;const L=document.createElement("div"),A=T.isMobile?100:130;let a,c,f=!1;const[b,w]=P(!1),[F,u]=P("Login.Next"),n=new C({label:"LoginPassword",name:"password"}),t=n.input,S=d("ForgotPassword",[V(()=>{f||(f=!0,i.passwordManager.requestRecovery().then(e=>{y({name:"emailRecover",payload:{email_pattern:e.email_pattern}})}).catch(async e=>{if(e.type==="PASSWORD_RECOVERY_NA"){await g.show({titleLangKey:"Login.ResetPassword.Title",descriptionLangKey:"Login.ResetPassword.NoEmailText",button:{langKey:"Login.ResetPassword.ResetAccount",isDanger:!0}}),await g.show({titleLangKey:"Login.ResetAccount.Title",descriptionLangKey:"Login.ResetAccount.Text",button:{langKey:"Login.ResetPassword.ResetAccount",isDanger:!0}}),await i.appAccountManager.deleteAccount("Forgot password").then(()=>{y({name:"signIn"})}).catch(r=>{if(r.type==="2FA_RECENT_CONFIRM")g.show({titleLangKey:"Login.ResetAccountFail.Title",descriptionLangKey:"Login.ResetAccountFail.TextCancelled",button:{langKey:"OK"}});else if(r.type.startsWith("2FA_CONFIRM_WAIT_")){const s=+r.type.replace("2FA_CONFIRM_WAIT_","");g.show({titleLangKey:"Login.ResetAccountFail.Title",descriptionLangKey:"Login.ResetAccountFail.TextWait",descriptionArgs:[B(H(s))],button:{langKey:"OK"}})}else console.error(r),k({langPackKey:"Error.AnError"})});return}k({langPackKey:"Error.AnError"})}).finally(()=>{f=!1}))})]);S.classList.add(_.forgotLink);function h(){return a||(a=window.setInterval(h,1e4)),i.passwordManager.getState().then(e=>{c=e,c.hint?N(n.label,j(W(c.hint))):n.setLabel()})}function v(e){if(e&&M(e),!t.value.length){t.classList.add("error");return}w(!0),t.disabled=!0,u("PleaseWait");const r=t.value;n.setValueSilently(""+Math.random()),n.setValueSilently(r),i.passwordManager.check(r,c).then(s=>{s._==="auth.authorization"?(a&&(clearInterval(a),a=void 0),K(),l?.remove()):(w(!1),t.disabled=!1,u(s._))}).catch(s=>{switch(w(!1),t.disabled=!1,n.input.classList.add("error"),s.type){default:u("PASSWORD_HASH_INVALID"),t.select();break}h()})}t.addEventListener("keypress",function(e){if(this.classList.remove("error"),u("Login.Next"),e.key==="Enter")return v()});let R;return I(()=>{i.appStateManager.pushToState("authState",{_:"authStatePassword"}),l=new O(n,A),L.append(l.container),l.load(),h(),R=q(t)}),E(()=>{R?.(),l?.remove(),a&&(clearInterval(a),a=void 0)}),o(Y,{get class(){return _.pagePassword},get header(){return o(m,{get children(){return[o(m.Sticker,{element:L,size:A}),o(m.Title,{get children(){return d("Login.Password.Title")}}),o(m.Subtitle,{get children(){return d("Login.Password.Subtitle")}})]}})},get children(){return[p(()=>n.container),S,o(z,{class:"btn-primary btn-color-primary",get disabled(){return b()},onClick:v,get children(){return[p(()=>d(F())),p(()=>p(()=>!!b())()&&Z())]}})]}})}export{oe as default};
//# sourceMappingURL=PasswordCard-pnz8-dX6.js.map
