tweb/public/106.4189d0e1c7117b023dc9.chunk.js
Eduard Kuzmenko 3cc5df683e Build
2022-08-22 13:05:40 +02:00

2 lines
8.6 KiB
JavaScript

"use strict";(this.webpackChunktweb=this.webpackChunktweb||[]).push([[106,810,392,53],{4489:(e,t,n)=>{n.d(t,{Z:()=>i});var a=n(503);class i extends a.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 a=this.value.replace(/\D/g,"").slice(0,e.length);this.setValueSilently(a);const i=this.value.length;if(i===e.length)e.onFill(this.value);else if(i===n)return;n=i}))}}},3083:(e,t,n)=>{n.d(t,{Z:()=>i});var a=n(2384);class i{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([a.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(),a.Z.waitForFirstFrame(e)))),a.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")})),a.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:()=>y});var a=n(4755),i=n(4874),s=n(810),o=n(3083),r=n(4489),l=n(2325),d=n(144),h=n(5565),c=n(3512);let u,p=null,m=null,g=null;const v=new i.Z("page-authCode",!0,(()=>{const e=p.type.length,t=new r.Z({label:"Code",name:(0,d.a)(),length:e,onFill:e=>{m(e)}});u=t.input,v.pageEl.querySelector(".input-wrapper").append(t.container),v.pageEl.querySelector(".phone-edit").addEventListener("click",(function(){return s.default.mount()}));const i=()=>{setTimeout((()=>{b.remove()}),300)},m=e=>{u.setAttribute("disabled","true");const a={phone_number:p.phone_number,phone_code_hash:p.phone_code_hash,phone_code:e};c.Z.managers.apiManager.invokeApi("auth.signIn",a,{ignoreErrors:!0}).then((e=>{switch(e._){case"auth.authorization":c.Z.managers.apiManager.setUser(e.user),n.e(781).then(n.bind(n,5436)).then((e=>{e.default.mount()})),i();break;case"auth.authorizationSignUpRequired":Promise.all([n.e(765),n.e(339)]).then(n.bind(n,8339)).then((e=>{e.default.mount({phone_number:p.phone_number,phone_code_hash:p.phone_code_hash})})),i()}})).catch((e=>{return a=void 0,i=void 0,o=function*(){let a=!1;switch(e.type){case"SESSION_PASSWORD_NEEDED":a=!0,e.handled=!0,yield(yield n.e(836).then(n.bind(n,9437))).default.mount(),setTimeout((()=>{u.value=""}),300);break;case"PHONE_CODE_EXPIRED":u.classList.add("error"),(0,h.Z)(t.label,(0,l.ag)("PHONE_CODE_EXPIRED"));break;case"PHONE_CODE_EMPTY":case"PHONE_CODE_INVALID":u.classList.add("error"),(0,h.Z)(t.label,(0,l.ag)("PHONE_CODE_INVALID"));break;default:t.label.innerText=e.type}a||t.select(),u.removeAttribute("disabled")},new((s=void 0)||(s=Promise))((function(e,t){function n(e){try{l(o.next(e))}catch(e){t(e)}}function r(e){try{l(o.throw(e))}catch(e){t(e)}}function l(t){var a;t.done?e(t.value):(a=t.value,a instanceof s?a:new s((function(e){e(a)}))).then(n,r)}l((o=o.apply(a,i||[])).next())}));var a,i,s,o}))},g=v.pageEl.querySelector(".auth-image"),y=a.Z.isMobile?100:166,b=new o.Z(t,y);return g.append(b.container),b.load()}),(e=>{if(p=e,m){u.value="";const e=document.createEvent("HTMLEvents");e.initEvent("input",!1,!0),u.dispatchEvent(e)}else m=v.pageEl.getElementsByClassName("phone")[0],g=v.pageEl.getElementsByClassName("sent-type")[0];let t,n;switch(m.innerText=p.phone_number,p.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=[p.type._]}(0,h.Z)(g,(0,l.ag)(t,n)),c.Z.managers.appStateManager.pushToState("authState",{_:"authStateAuthCode",sentCode:e})}),(()=>{u.focus()})),y=v},810:(e,t,n)=>{n.r(t),n.d(t,{default:()=>P});var a=n(279),i=n(4874),s=n(9807),o=n(4494),r=n(5432),l=n(4159),d=n(2325),h=n(2384),c=n(1405),u=n(9709),p=n(9638),m=n(3910),g=n(2738),v=n(5565),y=n(1656),b=n(7487),_=n(2398),E=n(6669),Z=n(7922),f=n(3512),S=n(709),L=n(3789),k=n(5431);let w,A=null;const C=new i.Z("page-sign",!0,(()=>{const e=document.createElement("div");let t,i;e.classList.add("input-wrapper");const c=new k.Z({onCountryChange:(e,n)=>{t=e,i=n,n&&(P.value=P.lastValue="+"+n.country_code,setTimeout((()=>{x.focus(),(0,_.Z)(x,!0)}),0))}}),P=new S.Z({onInput:e=>{h.Z.loadLottieWorkers();const{country:n,code:a}=e||{},s=n?n.name||n.default_name:"";s===c.value||t&&n&&a&&(t===n||i.country_code===a.country_code)||c.override(n,a,s),n||P.value.length-1>1?A.style.visibility="":A.style.visibility="hidden"}}),x=P.input;x.addEventListener("keypress",(e=>{if(!A.style.visibility&&"Enter"===e.key)return T()}));const F=new s.Z({text:"Login.KeepSigned",name:"keepSession",withRipple:!0,checked:!0});F.input.addEventListener("change",(()=>{const e=F.checked;f.Z.managers.appStateManager.pushToState("keepSigned",e),L.Z.toggleStorages(e,!0)})),L.Z.getState().then((e=>{Z.Z.isAvailable()?F.checked=e.keepSigned:(F.checked=!1,F.label.classList.add("checkbox-disabled"))})),A=(0,o.Z)("btn-primary btn-color-primary",{text:"Login.Next"}),A.style.visibility="hidden";const T=e=>{e&&(0,m.Z)(e);const t=(0,y.Z)([A,w],!0);(0,v.Z)(A,(0,d.ag)("PleaseWait")),(0,a.y)(A);const i=P.value;f.Z.managers.apiManager.invokeApi("auth.sendCode",{phone_number:i,api_id:l.Z.id,api_hash:l.Z.hash,settings:{_:"codeSettings"}}).then((e=>{n.e(392).then(n.bind(n,6392)).then((t=>t.default.mount(Object.assign(e,{phone_number:i}))))})).catch((e=>{t(),"PHONE_NUMBER_INVALID"===e.type?(P.setError(),(0,v.Z)(P.label,(0,d.ag)("Login.PhoneLabelInvalid")),x.classList.add("error"),(0,v.Z)(A,(0,d.ag)("Login.Next"))):(console.error("auth.sendCode error:",e),A.innerText=e.type)}))};(0,g.fc)(A,T),w=(0,o.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"Login.QR.Login"}),w.addEventListener("click",(()=>{u.default.mount()})),e.append(c.container,P.container,F.label,A,w);const N=document.createElement("h4");N.classList.add("text-center"),(0,d.$d)(N,"Login.Title");const M=document.createElement("div");M.classList.add("subtitle","text-center"),(0,d.$d)(M,"Login.StartText"),C.pageEl.querySelector(".container").append(N,M,e),r.Z||setTimeout((()=>{x.focus()}),0),(0,p.Z)(e),f.Z.managers.apiManager.invokeApi("help.getNearestDc").then((e=>{var t;const n=Z.Z.getFromCache("langPack");n&&!(null===(t=n.countries)||void 0===t?void 0:t.hash)&&d.ZP.getLangPack(n.lang_code).then((()=>{(0,E.Z)(x,"input")}));const a=new Set([1,2,3,4,5]),i=[e.this_dc];let s;return e.nearest_dc!==e.this_dc&&(s=f.Z.managers.apiManager.getNetworkerVoid(e.nearest_dc).then((()=>{i.push(e.nearest_dc)}))),(s||Promise.resolve()).then((()=>{i.forEach((e=>{a.delete(e)}));const e=[...a],t=()=>{return n=void 0,a=void 0,s=function*(){const n=e.shift();if(!n)return;const a=`dc${n}_auth_key`;if(yield b.Z.get(a))return t();setTimeout((()=>{f.Z.managers.apiManager.getNetworkerVoid(n).finally(t)}),3e3)},new((i=void 0)||(i=Promise))((function(e,t){function o(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(o,r)}l((s=s.apply(n,a||[])).next())}));var n,a,i,s};t()})),e})).then((e=>{c.value.length||P.value.length||c.selectCountryByIso2(e.country)}))}),(()=>{A&&((0,v.Z)(A,(0,d.ag)("Login.Next")),(0,c.Z)(A,void 0,void 0,!0),A.removeAttribute("disabled")),w&&w.removeAttribute("disabled"),f.Z.managers.appStateManager.pushToState("authState",{_:"authStateSignIn"})})),P=C}}]);
//# sourceMappingURL=106.4189d0e1c7117b023dc9.chunk.js.map