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AC,MAC9D,CACLjB,EAAU,MAAQ,GAEZ,MAAAgC,EAAM,SAAS,YAAY,YAAY,EACzCA,EAAA,UAAU,QAAS,GAAO,EAAI,EAClChC,EAAU,cAAcgC,CAAG,CAC7B,CAEM,MAAAC,EAAepC,EAAa,KAA8C,OAC5EI,IACFA,EAAiB,IAAIiC,EAAe,CAClC,MAAO,OACP,KAAMC,EAAW,EACjB,OAAQF,EACR,OAAS3B,GAAS,CAChBD,EAAWC,CAAI,CACjB,EACD,EAEDN,EAAYC,EAAe,OAG7BA,EAAe,QAAQ,OAASgC,EAEhCnC,EAAc,UAAYD,EAAa,aACvC,IAAIuC,EAAkBC,EACtB,MAAMC,EAAmBzC,EAAa,KACtC,OAAOyC,EAAiB,EAAG,CACzB,IAAK,uBACGF,EAAA,qBACN,MACF,IAAK,uBACGA,EAAA,uBACN,MACF,IAAK,wBACGA,EAAA,sBACN,MACF,IAAK,+BACGA,EAAA,iCACA,MAAAG,EAAI,SAAS,cAAc,GAAG,EACpCC,EAAiBD,CAAC,EAClBA,EAAE,KAAOD,EAAiB,IAC1BD,EAAO,CAACE,CAAC,EACT,MACF,QACQH,EAAA,yBACCC,EAAA,CAACC,EAAiB,CAAC,EAC1B,KACJ,CAEA,OAAAxB,EAAef,EAAiBgB,EAAKqB,EAAKC,CAAI,CAAC,EAErC7B,EAAA,SAAS,gBAAgB,YAAY,YAAa,CAAC,EAAG,oBAAqB,SAAUuB,CAAA,CAAU,EAElGT,EAAA,EAAe,MAAM,IAAM,EAAE,CACtC,EAAG,IAAM,CACPtB,EAAU,MAAM,CAClB,CAAC","names":["authSentCode","headerElement","sentTypeElement","codeInput","codeInputField","monkey","player","cleanup","submitCode","code","params","rootScope","response","__vitePreload","m","err","good","replaceContent","i18n","onFirstMount","page","editButton","Icon","attachClickEvent","pageSignIn","getAnimation","imageDiv","size","mediaSizes","container","lottieLoader","animation","TrackingMonkey","Page","_authCode","evt","CODE_LENGTH","CodeInputField","randomLong","key","args","authSentCodeType","a","setBlankToAnchor"],"ignoreList":[],"sources":["../src/pages/pageAuthCode.ts"],"sourcesContent":["/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\nimport mediaSizes from '../helpers/mediaSizes';\nimport {AuthSentCode, AuthSentCodeType, AuthSignIn} from '../layer';\nimport Page from './page';\nimport pageSignIn from './pageSignIn';\nimport TrackingMonkey from '../components/monkeys/tracking';\nimport CodeInputField from '../components/codeInputField';\nimport {i18n, LangPackKey} from '../lib/langPack';\nimport {randomLong} from '../helpers/random';\nimport replaceContent from '../helpers/dom/replaceContent';\nimport rootScope from '../lib/rootScope';\nimport lottieLoader from '../lib/rlottie/lottieLoader';\nimport RLottiePlayer from '../lib/rlottie/rlottiePlayer';\nimport setBlankToAnchor from '../lib/richTextProcessor/setBlankToAnchor';\nimport {attachClickEvent} from '../helpers/dom/clickEvent';\nimport Icon from '../components/icon';\n\nlet authSentCode: AuthSentCode.authSentCode = null;\n\nlet headerElement: HTMLHeadElement = null;\nlet sentTypeElement: HTMLParagraphElement = null;\nlet codeInput: HTMLInputElement, codeInputField: CodeInputField;\nlet monkey: TrackingMonkey, player: RLottiePlayer;\n\nconst cleanup = () => {\n setTimeout(() => {\n monkey?.remove();\n player?.remove();\n }, 300);\n};\n\nconst submitCode = (code: string) => {\n codeInput.setAttribute('disabled', 'true');\n\n const params: AuthSignIn = {\n phone_number: authSentCode.phone_number,\n phone_code_hash: authSentCode.phone_code_hash,\n phone_code: code\n };\n\n // console.log('invoking auth.signIn with params:', params);\n\n rootScope.managers.apiManager.invokeApi('auth.signIn', params, {ignoreErrors: true})\n .then(async(response) => {\n // console.log('auth.signIn response:', response);\n\n switch(response._) {\n case 'auth.authorization':\n await rootScope.managers.apiManager.setUser(response.user);\n\n import('./pageIm').then((m) => {\n m.default.mount();\n });\n cleanup();\n break;\n case 'auth.authorizationSignUpRequired':\n // console.log('Registration needed!');\n\n import('./pageSignUp').then((m) => {\n m.default.mount({\n 'phone_number': authSentCode.phone_number,\n 'phone_code_hash': authSentCode.phone_code_hash\n });\n });\n\n cleanup();\n break;\n /* default:\n codeInput.innerText = response._;\n break; */\n }\n }).catch(async(err) => {\n let good = false;\n switch(err.type) {\n case 'SESSION_PASSWORD_NEEDED':\n // console.warn('pageAuthCode: SESSION_PASSWORD_NEEDED');\n good = true;\n err.handled = true;\n await (await import('./pagePassword')).default.mount(); // lol\n setTimeout(() => {\n codeInput.value = '';\n }, 300);\n break;\n case 'PHONE_CODE_EXPIRED':\n codeInput.classList.add('error');\n replaceContent(codeInputField.label, i18n('PHONE_CODE_EXPIRED'));\n break;\n case 'PHONE_CODE_EMPTY':\n case 'PHONE_CODE_INVALID':\n codeInput.classList.add('error');\n replaceContent(codeInputField.label, i18n('PHONE_CODE_INVALID'));\n break;\n default:\n codeInputField.label.innerText = err.type;\n break;\n }\n\n if(!good) {\n codeInputField.select();\n }\n\n codeInput.removeAttribute('disabled');\n });\n};\n\nconst onFirstMount = () => {\n page.pageEl.querySelector('.input-wrapper').append(codeInputField.container);\n\n const editButton = page.pageEl.querySelector('.phone-edit') as HTMLElement;\n editButton.append(Icon('edit'));\n attachClickEvent(editButton, () => {\n return pageSignIn.mount();\n });\n};\n\nconst getAnimation = () => {\n const imageDiv = page.pageEl.querySelector('.auth-image') as HTMLDivElement;\n const size = mediaSizes.isMobile ? 100 : 166;\n if(authSentCode.type._ === 'auth.sentCodeTypeFragmentSms') {\n if(imageDiv.firstElementChild) {\n monkey?.remove();\n monkey = undefined;\n imageDiv.replaceChildren();\n }\n\n const container = document.createElement('div');\n container.classList.add('media-sticker-wrapper');\n imageDiv.append(container);\n return lottieLoader.loadAnimationAsAsset({\n container: container,\n loop: true,\n autoplay: true,\n width: size,\n height: size\n }, 'jolly_roger').then((animation) => {\n player = animation;\n return lottieLoader.waitForFirstFrame(animation);\n }).then(() => {});\n } else {\n if(imageDiv.firstElementChild) {\n player?.remove();\n player = undefined;\n imageDiv.replaceChildren();\n }\n\n monkey = new TrackingMonkey(codeInputField, size);\n imageDiv.append(monkey.container);\n return monkey.load();\n }\n};\n\nconst page = new Page('page-authCode', true, onFirstMount, (_authCode: typeof authSentCode) => {\n authSentCode = _authCode;\n\n if(!headerElement) {\n headerElement = page.pageEl.getElementsByClassName('phone')[0] as HTMLHeadElement;\n sentTypeElement = page.pageEl.getElementsByClassName('sent-type')[0] as HTMLParagraphElement;\n } else {\n codeInput.value = '';\n\n const evt = document.createEvent('HTMLEvents');\n evt.initEvent('input', false, true);\n codeInput.dispatchEvent(evt);\n }\n\n const CODE_LENGTH = (authSentCode.type as AuthSentCodeType.authSentCodeTypeApp).length;\n if(!codeInputField) {\n codeInputField = new CodeInputField({\n label: 'Code',\n name: randomLong(),\n length: CODE_LENGTH,\n onFill: (code) => {\n submitCode(code);\n }\n });\n\n codeInput = codeInputField.input as HTMLInputElement;\n }\n\n codeInputField.options.length = CODE_LENGTH;\n\n headerElement.innerText = authSentCode.phone_number;\n let key: LangPackKey, args: any[];\n const authSentCodeType = authSentCode.type;\n switch(authSentCodeType._) {\n case 'auth.sentCodeTypeSms':\n key = 'Login.Code.SentSms';\n break;\n case 'auth.sentCodeTypeApp':\n key = 'Login.Code.SentInApp';\n break;\n case 'auth.sentCodeTypeCall':\n key = 'Login.Code.SentCall';\n break;\n case 'auth.sentCodeTypeFragmentSms':\n key = 'PhoneNumber.Code.Fragment.Info';\n const a = document.createElement('a');\n setBlankToAnchor(a);\n a.href = authSentCodeType.url;\n args = [a];\n break;\n default:\n key = 'Login.Code.SentUnknown';\n args = [authSentCodeType._];\n break;\n }\n\n replaceContent(sentTypeElement, i18n(key, args));\n\n rootScope.managers.appStateManager.pushToState('authState', {_: 'authStateAuthCode', sentCode: _authCode});\n\n return getAnimation().catch(() => {});\n}, () => {\n codeInput.focus();\n});\n\nexport default page;\n"],"file":"pageAuthCode-D0FL5KCv.js"}