tweb/public/392.a16c421c1f68b829c496.ch...

2 lines
4.9 KiB
JavaScript

"use strict";(this.webpackChunktweb=this.webpackChunktweb||[]).push([[392],{4489:(e,t,n)=>{n.d(t,{Z:()=>a});var i=n(503);class a extends i.Z{constructor(e){super(Object.assign({plainText:!0},e));const t=this.input;t.type="tel",t.setAttribute("required",""),t.autocomplete="off";let n=0;this.input.addEventListener("input",(t=>{this.input.classList.remove("error"),this.setLabel();const i=this.value.replace(/\D/g,"").slice(0,e.length);this.setValueSilently(i);const a=this.value.length;if(a===e.length)e.onFill(this.value);else if(a===n)return;n=a}))}}},3083:(e,t,n)=>{n.d(t,{Z:()=>a});var i=n(2897);class a{constructor(e,t){this.inputField=e,this.size=t,this.max=45,this.needFrame=0,this.container=document.createElement("div"),this.container.classList.add("media-sticker-wrapper");const n=e.input;n.addEventListener("blur",(()=>{this.playAnimation(0)})),n.addEventListener("input",(t=>{this.playAnimation(e.value.length)}))}playAnimation(e){if(!this.animation)return;let t;(e=Math.min(e,30))?(t=Math.round(Math.min(this.max,e)*(165/this.max)+11.33),this.idleAnimation&&(this.idleAnimation.stop(!0),this.idleAnimation.canvas.style.display="none"),this.animation.canvas.style.display=""):t=0;const n=this.needFrame>t?-1:1;this.animation.setDirection(n),0!==this.needFrame&&0===t&&this.animation.setSpeed(7),this.needFrame=t,this.animation.play()}load(){return this.loadPromise?this.loadPromise:this.loadPromise=Promise.all([i.Z.loadAnimationAsAsset({container:this.container,loop:!0,autoplay:!0,width:this.size,height:this.size},"TwoFactorSetupMonkeyIdle").then((e=>(this.idleAnimation=e,this.inputField.value.length||e.play(),i.Z.waitForFirstFrame(e)))),i.Z.loadAnimationAsAsset({container:this.container,loop:!1,autoplay:!1,width:this.size,height:this.size},"TwoFactorSetupMonkeyTracking").then((e=>(this.animation=e,this.inputField.value.length||(this.animation.canvas.style.display="none"),this.animation.addEventListener("enterFrame",(e=>{(1===this.animation.direction&&e>=this.needFrame||-1===this.animation.direction&&e<=this.needFrame)&&(this.animation.setSpeed(1),this.animation.pause()),0===e&&0===this.needFrame&&this.idleAnimation&&(this.idleAnimation.canvas.style.display="",this.idleAnimation.play(),this.animation.canvas.style.display="none")})),i.Z.waitForFirstFrame(e))))])}remove(){this.animation&&this.animation.remove(),this.idleAnimation&&this.idleAnimation.remove()}}},6392:(e,t,n)=>{n.r(t),n.d(t,{default:()=>b});var i=n(4755),a=n(4687),s=n(9518),o=n(4874),l=n(810),h=n(3083),r=n(4489),d=n(4727),u=n(144),c=n(5565);let p,m=null,y=null,v=null;const E=new o.Z("page-authCode",!0,(()=>{const e=m.type.length,t=new r.Z({label:"Code",name:(0,u.a)(),length:e,onFill:e=>{o(e)}});p=t.input,E.pageEl.querySelector(".input-wrapper").append(t.container),E.pageEl.querySelector(".phone-edit").addEventListener("click",(function(){return l.default.mount()}));const a=()=>{setTimeout((()=>{b.remove()}),300)},o=e=>{p.setAttribute("disabled","true");const i={phone_number:m.phone_number,phone_code_hash:m.phone_code_hash,phone_code:e};s.Z.invokeApi("auth.signIn",i,{ignoreErrors:!0}).then((e=>{switch(e._){case"auth.authorization":s.Z.setUser(e.user),n.e(781).then(n.bind(n,5436)).then((e=>{e.default.mount()})),a();break;case"auth.authorizationSignUpRequired":Promise.all([n.e(765),n.e(339)]).then(n.bind(n,8339)).then((e=>{e.default.mount({phone_number:m.phone_number,phone_code_hash:m.phone_code_hash})})),a()}})).catch((e=>{return i=void 0,a=void 0,o=function*(){let i=!1;switch(e.type){case"SESSION_PASSWORD_NEEDED":i=!0,e.handled=!0,yield(yield n.e(774).then(n.bind(n,9437))).default.mount(),setTimeout((()=>{p.value=""}),300);break;case"PHONE_CODE_EXPIRED":p.classList.add("error"),(0,c.Z)(t.label,(0,d.i18n)("PHONE_CODE_EXPIRED"));break;case"PHONE_CODE_EMPTY":case"PHONE_CODE_INVALID":p.classList.add("error"),(0,c.Z)(t.label,(0,d.i18n)("PHONE_CODE_INVALID"));break;default:t.label.innerText=e.type}i||t.select(),p.removeAttribute("disabled")},new((s=void 0)||(s=Promise))((function(e,t){function n(e){try{h(o.next(e))}catch(e){t(e)}}function l(e){try{h(o.throw(e))}catch(e){t(e)}}function h(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(n,l)}h((o=o.apply(i,a||[])).next())}));var i,a,s,o}))},y=E.pageEl.querySelector(".auth-image"),v=i.ZP.isMobile?100:166,b=new h.Z(t,v);return y.append(b.container),b.load()}),(e=>{if(m=e,y){p.value="";const e=document.createEvent("HTMLEvents");e.initEvent("input",!1,!0),p.dispatchEvent(e)}else y=E.pageEl.getElementsByClassName("phone")[0],v=E.pageEl.getElementsByClassName("sent-type")[0];let t,n;switch(y.innerText=m.phone_number,m.type._){case"auth.sentCodeTypeSms":t="Login.Code.SentSms";break;case"auth.sentCodeTypeApp":t="Login.Code.SentInApp";break;case"auth.sentCodeTypeCall":t="Login.Code.SentCall";break;default:t="Login.Code.SentUnknown",n=[m.type._]}(0,c.Z)(v,(0,d.i18n)(t,n)),a.default.pushToState("authState",{_:"authStateAuthCode",sentCode:e})}),(()=>{p.focus()})),b=E}}]);
//# sourceMappingURL=392.a16c421c1f68b829c496.chunk.js.map