tweb/public/106.074bf17aad93c3a097a5.chunk.js
Eduard Kuzmenko 019a7aa1e3 Build
2022-06-24 21:23:25 +04:00

2 lines
12 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),c=n(5565),u=n(3512);let h,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)}});h=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((()=>{f.remove()}),300)},m=e=>{h.setAttribute("disabled","true");const a={phone_number:p.phone_number,phone_code_hash:p.phone_code_hash,phone_code:e};u.Z.managers.apiManager.invokeApi("auth.signIn",a,{ignoreErrors:!0}).then((e=>{switch(e._){case"auth.authorization":u.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(813)]).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(774).then(n.bind(n,9437))).default.mount(),setTimeout((()=>{h.value=""}),300);break;case"PHONE_CODE_EXPIRED":h.classList.add("error"),(0,c.Z)(t.label,(0,l.ag)("PHONE_CODE_EXPIRED"));break;case"PHONE_CODE_EMPTY":case"PHONE_CODE_INVALID":h.classList.add("error"),(0,c.Z)(t.label,(0,l.ag)("PHONE_CODE_INVALID"));break;default:t.label.innerText=e.type}a||t.select(),h.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,f=new o.Z(t,y);return g.append(f.container),f.load()}),(e=>{if(p=e,m){h.value="";const e=document.createEvent("HTMLEvents");e.initEvent("input",!1,!0),h.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,c.Z)(g,(0,l.ag)(t,n)),u.Z.managers.appStateManager.pushToState("authState",{_:"authStateAuthCode",sentCode:e})}),(()=>{h.focus()})),y=v},810:(e,t,n)=>{n.r(t),n.d(t,{default:()=>z});var a=n(279),i=n(8805),s=n(4874),o=n(503),r=n(9807),l=n(4494),d=n(4789),c=n(5432),u=n(4159),h=n(2325),p=n(2384),m=n(1405),g=n(4668),v=n(8497),y=n(144),f=n(9709),E=n(9638),b=n(3910),Z=n(2738),_=n(5565),L=n(1656),w=n(7487),S=n(2398),k=n(671),A=n(6669),C=n(7922),T=n(3512),x=n(709),P=n(9976),F=n(130),N=n(8115),M=n(3789);let D,I=null;const O=new s.Z("page-sign",!0,(()=>{const e=()=>{t=h.ZP.countriesList.filter((e=>{var t;return!(null===(t=e.pFlags)||void 0===t?void 0:t.hidden)})).sort(((e,t)=>(e.name||e.default_name).localeCompare(t.name||t.default_name)))};let t;e(),T.Z.addEventListener("language_change",(()=>{e()}));const s=new Map;let m,z;const q=document.createElement("div");q.classList.add("input-wrapper");const H=new o.Z({label:"Login.CountrySelectorLabel",name:(0,y.a)()});H.container.classList.add("input-select");const R=H.input,V=document.createElement("div");V.classList.add("select-wrapper","z-depth-3","hide");const B=document.createElement("span");B.classList.add("arrow","arrow-down"),H.container.append(B);const U=document.createElement("ul");V.appendChild(U),new i.ZP(V);let W=()=>{W=null,t.forEach((e=>{const t=(0,k.Ml)(e.iso2),n=[];e.country_codes.forEach((a=>{const i=document.createElement("li");let s=(0,N.Z)(t);if(P.Z){const e=document.createElement("span");(0,F.Z)(e,s),i.append(e)}else(0,F.Z)(i,s);const o=(0,h.ag)(e.default_name);o.dataset.defaultName=e.default_name,i.append(o);const r=document.createElement("span");r.classList.add("phone-code"),r.innerText="+"+a.country_code,i.appendChild(r),n.push(i),U.append(i)})),s.set(e.iso2,n)})),U.addEventListener("mousedown",(e=>{if(0!==e.button)return;const t=(0,g.Z)(e.target,"LI");j(t)})),H.container.appendChild(V)};const j=e=>{const n=e.childNodes[1].dataset.defaultName,a=e.querySelector(".phone-code").innerText,i=a.replace(/\D/g,"");(0,_.Z)(R,(0,h.ag)(n)),(0,A.Z)(R,"input"),m=t.find((e=>e.default_name===n)),z=m.country_codes.find((e=>e.country_code===i)),Y.value=Y.lastValue=a,Q(),setTimeout((()=>{G.focus(),(0,S.Z)(G,!0)}),0)};let $;W(),R.addEventListener("focus",(function(e){W?W():t.forEach((e=>{s.get(e.iso2).forEach((e=>e.style.display=""))})),clearTimeout($),$=void 0,V.classList.remove("hide"),V.offsetWidth,V.classList.add("active"),H.select(),(0,d.Z)({container:O.pageEl.parentElement.parentElement,element:R,position:"start",margin:4}),setTimeout((()=>{K||(document.addEventListener("mousedown",X,{capture:!0}),K=!0)}),0)}));let K=!1;const X=e=>{(0,v.Z)(e.target,"input-select")||e.target!==R&&(Q(),document.removeEventListener("mousedown",X,{capture:!0}),K=!1)},Q=()=>{void 0===$&&(V.classList.remove("active"),$=window.setTimeout((()=>{V.classList.add("hide"),$=void 0}),200))};R.addEventListener("keyup",(e=>{const n=e.key;if(e.ctrlKey||"Control"===n)return!1;let a=H.value.toLowerCase(),i=[];t.forEach((e=>{const t=[e.name,e.default_name,e.iso2];t.filter(Boolean).forEach((e=>{const n=e.split(" ").filter((e=>/\w/.test(e))).map((e=>e[0])).join("");n.length>1&&t.push(n)}));let n=!!t.filter(Boolean).find((e=>-1!==e.toLowerCase().indexOf(a)));s.get(e.iso2).forEach((e=>e.style.display=n?"":"none")),n&&i.push(e)})),0===i.length?t.forEach((e=>{s.get(e.iso2).forEach((e=>e.style.display=""))})):1===i.length&&"Enter"===n&&j(s.get(i[0].iso2)[0])})),B.addEventListener("mousedown",(function(e){e.cancelBubble=!0,e.preventDefault(),R.matches(":focus")?R.blur():R.focus()}));const Y=new x.Z({onInput:e=>{p.Z.loadLottieWorkers();const{country:t,code:n}=e||{};let a=t?t.name||t.default_name:"";a===H.value||m&&t&&n&&(m===t||z.country_code===n.country_code)||((0,_.Z)(R,t?(0,h.ag)(t.default_name):a),m=t,z=n),t||Y.value.length-1>1?I.style.visibility="":I.style.visibility="hidden"}}),G=Y.input;G.addEventListener("keypress",(e=>{if(!I.style.visibility&&"Enter"===e.key)return ee()}));const J=new r.Z({text:"Login.KeepSigned",name:"keepSession",withRipple:!0,checked:!0});J.input.addEventListener("change",(()=>{const e=J.checked;T.Z.managers.appStateManager.pushToState("keepSigned",e),M.Z.toggleStorages(e,!0)})),M.Z.getState().then((e=>{C.Z.isAvailable()?J.checked=e.keepSigned:(J.checked=!1,J.label.classList.add("checkbox-disabled"))})),I=(0,l.Z)("btn-primary btn-color-primary",{text:"Login.Next"}),I.style.visibility="hidden";const ee=e=>{e&&(0,b.Z)(e);const t=(0,L.Z)([I,D],!0);(0,_.Z)(I,(0,h.ag)("PleaseWait")),(0,a.y)(I);let i=Y.value;T.Z.managers.apiManager.invokeApi("auth.sendCode",{phone_number:i,api_id:u.Z.id,api_hash:u.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?(Y.setError(),(0,_.Z)(Y.label,(0,h.ag)("Login.PhoneLabelInvalid")),G.classList.add("error"),(0,_.Z)(I,(0,h.ag)("Login.Next"))):(console.error("auth.sendCode error:",e),I.innerText=e.type)}))};(0,Z.fc)(I,ee),D=(0,l.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"Login.QR.Login"}),D.addEventListener("click",(()=>{f.default.mount()})),q.append(H.container,Y.container,J.label,I,D);const te=document.createElement("h4");te.classList.add("text-center"),(0,h.$d)(te,"Login.Title");const ne=document.createElement("div");ne.classList.add("subtitle","text-center"),(0,h.$d)(ne,"Login.StartText"),O.pageEl.querySelector(".container").append(te,ne,q),c.Z||setTimeout((()=>{G.focus()}),0),(0,E.Z)(q),T.Z.managers.apiManager.invokeApi("help.getNearestDc").then((e=>{var t;const n=C.Z.getFromCache("langPack");n&&!(null===(t=n.countries)||void 0===t?void 0:t.hash)&&h.ZP.getLangPack(n.lang_code).then((()=>{(0,A.Z)(G,"input")}));const a=new Set([1,2,3,4,5]),i=[e.this_dc];let s;return e.nearest_dc!==e.this_dc&&(s=T.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 w.Z.get(a))return t();setTimeout((()=>{T.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=>{H.value.length||Y.value.length||j(s.get(e.country)[0])}))}),(()=>{I&&((0,_.Z)(I,(0,h.ag)("Login.Next")),(0,m.Z)(I,void 0,void 0,!0),I.removeAttribute("disabled")),D&&D.removeAttribute("disabled"),T.Z.managers.appStateManager.pushToState("authState",{_:"authStateSignIn"})})),z=O}}]);
//# sourceMappingURL=106.074bf17aad93c3a097a5.chunk.js.map