{"version":3,"sources":["webpack:///./src/components/passwordInputField.ts","webpack:///./src/components/monkeys/password.ts","webpack:///./src/pages/pagePassword.ts","webpack:///./src/helpers/dom/replaceContent.ts","webpack:///./src/components/inputField.ts","webpack:///./src/helpers/dom/selectElementContents.ts","webpack:///./src/components/singleTransition.ts","webpack:///./src/helpers/dom/toggleDisability.ts","webpack:///./src/helpers/dom/getRichValue.ts","webpack:///./src/helpers/dom/findUpAttribute.ts","webpack:///./src/helpers/dom/getRichElementValue.ts","webpack:///./src/helpers/dom/isInputEmpty.ts","webpack:///./src/lib/mtproto/passwordManager.ts","webpack:///./src/pages/loginPage.ts","webpack:///./src/helpers/dom/htmlToSpan.ts"],"names":["PasswordInputField","options","super","plainText","passwordVisible","onVisibilityClick","e","this","toggleVisible","classList","toggle","input","type","onVisibilityClickAdditional","setAttribute","name","autocomplete","stealthy","document","createElement","add","tabIndex","parentElement","prepend","insertBefore","cloneNode","nextSibling","container","append","addEventListener","PasswordMonkey","passwordInputField","size","needFrame","loadPromise","loadAnimationAsAsset","loop","autoplay","width","height","noCache","then","_animation","animation","currentFrame","direction","setSpeed","pause","setDirection","curFrame","play","waitForFirstFrame","remove","passwordInput","page","className","withInputWrapper","titleLangKey","subtitleLangKey","btnNext","btnNextI18n","IntlElement","key","element","label","getStateInterval","inputWrapper","state","getState","window","setInterval","_state","hint","wrapEmojiText","setLabel","onSubmit","value","length","update","preloader","setValueSilently","Math","random","check","response","_","clearInterval","m","default","mount","monkey","removeAttribute","catch","err","select","isMobile","imageDiv","Promise","all","load","focus","pushToState","replaceContent","elem","node","innerHTML","firstChild","lastChild","replaceWith","textContent","init","findUpAttribute","target","text","entities","preventDefault","originalEvent","clipboardData","getData","usePlainText","html","trim","replace","match","span","curChild","nodeType","nodeValue","richValue","getRichValue","entities2","parseEntities","filter","mergeEntities","wrapDraftText","execCommand","InputState","required","validate","undefined","maxLength","showLengthOn","min","round","placeholder","canBeEdited","processInput","labelText","firstElementChild","String","observer","MutationObserver","isInputEmpty","inputFake","onFakeInput","observe","characterData","childList","subtree","animate","border","labelEl","lastElementChild","showingLength","wasError","contains","inputLength","diff","isError","el","range","createRange","selectNodeContents","sel","getSelection","removeAllRanges","addRange","selectElementContents","labelOptions","setHeight","scrollHeight","newHeight","currentHeight","style","transitionDuration","log","abs","fireFakeInput","originalValue","isValid","isChanged","silent","setDraftValue","Error","Valid","setState","SetTransition","forwards","duration","onTransitionEnd","useRafs","timeout","raf","dataset","clearTimeout","cancelAnimationFrame","settings","animationsEnabled","requestAnimationFrame","afterTimeout","setTimeout","toggleDisability","elements","disable","forEach","field","withEntities","lines","line","push","join","combineSameEntities","sortEntities","attribute","closest","markdownTags","bold","entityName","underline","italic","monospace","strikethrough","link","mentionName","spoiler","BLOCK_TAG_NAMES","Set","getRichElementValue","selNode","selOffset","offset","substr","parentNode","tag","getAttribute","url","href","user_id","follow","toUserId","isSelected","isBlock","has","tagName","splice","HTMLImageElement","alt","isTableCell","matches","wasEntitiesLength","i","wasLength","hasAttribute","passwordManager","invokeApi","result","currentHashPromise","newHashPromise","params","password","new_settings","email","currentPassword","invokeCrypto","resolve","newAlgo","new_algo","salt1","Uint8Array","randomize","set","newPassword","hashes","new_password_hash","inputCheckPassword","auth","setUser","user","code","LoginPage","body","querySelector","title","subtitle","htmlToSpan"],"mappings":"6FAAA,qDAUe,MAAMA,UAA2B,IAK9C,YAAYC,EAA6B,IACvCC,MAAM,OAAD,QACHC,WAAW,GACRF,IAPA,KAAAG,iBAAkB,EAyClB,KAAAC,kBAAqBC,IAC1B,YAAYA,GACZC,KAAKH,iBAAmBG,KAAKH,gBAE7BG,KAAKC,cAAcC,UAAUC,OAAO,aAAcH,KAAKH,iBACtDG,KAAKI,MAA2BC,KAAOL,KAAKH,gBAAkB,OAAS,WACxEG,KAAKM,6BAA+BN,KAAKM,+BArCzC,MAAMF,EAAQJ,KAAKI,MACnBA,EAAMC,KAAO,WACbD,EAAMG,aAAa,WAAY,IAC/BH,EAAMI,KAAO,qBACbJ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AO,eAAK3B,EAAQyD,kBAGpCnD,KAAKoB,UAAUC,OAAOrB,KAAKyF,SAAUzF,KAAK6R,MAAO7R,KAAK8R,UAEnDpS,EAAQuD,mBACTjD,KAAK2D,aAAehD,SAASC,cAAc,OAC3CZ,KAAK2D,aAAaX,UAAY,gBAC9BhD,KAAKoB,UAAUC,OAAOrB,KAAK2D,eAG7B3D,KAAKwD,QAAQnC,OAAOrB,KAAKoB,c,gCC7Cd,SAAS2Q,EAAW9K,GACjC,MAAMI,EAAO1G,SAASC,cAAc,QAEpC,OADAyG,EAAKnB,UAAYe,EACVI,EATT","file":"16.dd165468586f22f31041.chunk.js","sourcesContent":["/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n */\r\n\r\n// import { IS_MOBILE_SAFARI, IS_SAFARI } from \"../environment/userAgent\";\r\nimport { cancelEvent } from \"../helpers/dom/cancelEvent\";\r\nimport InputField, { InputFieldOptions } from \"./inputField\";\r\n\r\nexport default class PasswordInputField extends InputField {\r\n public passwordVisible = false;\r\n public toggleVisible: HTMLElement;\r\n public onVisibilityClickAdditional: () => void;\r\n\r\n constructor(options: InputFieldOptions = {}) {\r\n super({\r\n plainText: true,\r\n ...options\r\n });\r\n\r\n const input = this.input as HTMLInputElement;\r\n input.type = 'password';\r\n input.setAttribute('required', '');\r\n input.name = 'notsearch_password';\r\n input.autocomplete = 'off';\r\n\r\n /* if(IS_SAFARI && !IS_MOBILE_SAFARI) {\r\n input.setAttribute('readonly', '');\r\n input.addEventListener('focus', () => {\r\n input.removeAttribute('readonly');\r\n }, {once: true});\r\n } */\r\n\r\n // * https://stackoverflow.com/a/35949954/6758968\r\n const stealthy = document.createElement('input');\r\n stealthy.classList.add('stealthy');\r\n stealthy.tabIndex = -1;\r\n stealthy.type = 'password';\r\n input.parentElement.prepend(stealthy);\r\n input.parentElement.insertBefore(stealthy.cloneNode(), input.nextSibling);\r\n\r\n const toggleVisible = this.toggleVisible = document.createElement('span');\r\n toggleVisible.classList.add('toggle-visible', 'tgico');\r\n\r\n this.container.classList.add('input-field-password');\r\n this.container.append(toggleVisible);\r\n\r\n toggleVisible.addEventListener('click', this.onVisibilityClick);\r\n toggleVisible.addEventListener('touchend', this.onVisibilityClick);\r\n }\r\n\r\n public onVisibilityClick = (e: Event) => {\r\n cancelEvent(e);\r\n this.passwordVisible = !this.passwordVisible;\r\n\r\n this.toggleVisible.classList.toggle('eye-hidden', this.passwordVisible);\r\n (this.input as HTMLInputElement).type = this.passwordVisible ? 'text' : 'password';\r\n this.onVisibilityClickAdditional && this.onVisibilityClickAdditional();\r\n };\r\n}\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n */\r\n\r\nimport lottieLoader, { LottieLoader } from \"../../lib/rlottie/lottieLoader\";\r\nimport RLottiePlayer from \"../../lib/rlottie/rlottiePlayer\";\r\nimport PasswordInputField from \"../passwordInputField\";\r\n\r\nexport default class PasswordMonkey {\r\n public container: HTMLElement;\r\n public animation: RLottiePlayer;\r\n public needFrame = 0;\r\n protected loadPromise: ReturnType;\r\n\r\n constructor(protected passwordInputField: PasswordInputField, protected size: number) {\r\n this.container = document.createElement('div');\r\n this.container.classList.add('media-sticker-wrapper');\r\n }\r\n\r\n public load() {\r\n if(this.loadPromise) return this.loadPromise;\r\n return this.loadPromise = lottieLoader.loadAnimationAsAsset({\r\n container: this.container,\r\n loop: false,\r\n autoplay: false,\r\n width: this.size,\r\n height: this.size,\r\n noCache: true\r\n //}, 'assets/img/TwoFactorSetupMonkeyClose.tgs').then(_animation => {\r\n }, 'TwoFactorSetupMonkeyPeek').then(_animation => {\r\n //return;\r\n this.animation = _animation;\r\n this.animation.addEventListener('enterFrame', currentFrame => {\r\n //console.log('enterFrame', currentFrame, this.needFrame);\r\n\r\n if((this.animation.direction === 1 && currentFrame >= this.needFrame) ||\r\n (this.animation.direction === -1 && currentFrame <= this.needFrame)) {\r\n this.animation.setSpeed(1);\r\n this.animation.pause();\r\n } \r\n });\r\n\r\n this.passwordInputField.onVisibilityClickAdditional = () => {\r\n if(this.passwordInputField.passwordVisible) {\r\n this.animation.setDirection(1);\r\n this.animation.curFrame = 0;\r\n this.needFrame = 16;\r\n this.animation.play();\r\n } else {\r\n this.animation.setDirection(-1);\r\n this.animation.curFrame = 16;\r\n this.needFrame = 0;\r\n this.animation.play();\r\n }\r\n };\r\n\r\n return lottieLoader.waitForFirstFrame(_animation);\r\n });\r\n }\r\n\r\n public remove() {\r\n if(this.animation) {\r\n this.animation.remove();\r\n }\r\n }\r\n}\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n */\r\n\r\nimport { putPreloader } from '../components/misc';\r\nimport mediaSizes from '../helpers/mediaSizes';\r\nimport { AccountPassword } from '../layer';\r\nimport appStateManager from '../lib/appManagers/appStateManager';\r\nimport passwordManager from '../lib/mtproto/passwordManager';\r\nimport Page from './page';\r\nimport Button from '../components/button';\r\nimport PasswordInputField from '../components/passwordInputField';\r\nimport PasswordMonkey from '../components/monkeys/password';\r\nimport RichTextProcessor from '../lib/richtextprocessor';\r\nimport I18n from '../lib/langPack';\r\nimport LoginPage from './loginPage';\r\nimport { cancelEvent } from '../helpers/dom/cancelEvent';\r\nimport { attachClickEvent } from '../helpers/dom/clickEvent';\r\nimport htmlToSpan from '../helpers/dom/htmlToSpan';\r\nimport replaceContent from '../helpers/dom/replaceContent';\r\nimport toggleDisability from '../helpers/dom/toggleDisability';\r\n\r\nconst TEST = false;\r\nlet passwordInput: HTMLInputElement;\r\n\r\nlet onFirstMount = (): Promise => {\r\n const page = new LoginPage({\r\n className: 'page-password',\r\n withInputWrapper: true,\r\n titleLangKey: 'Login.Password.Title',\r\n subtitleLangKey: 'Login.Password.Subtitle'\r\n });\r\n\r\n const btnNext = Button('btn-primary btn-color-primary');\r\n const btnNextI18n = new I18n.IntlElement({key: 'Login.Next'});\r\n\r\n btnNext.append(btnNextI18n.element);\r\n\r\n const passwordInputField = new PasswordInputField({\r\n label: 'LoginPassword',\r\n name: 'password'\r\n });\r\n\r\n passwordInput = passwordInputField.input as HTMLInputElement;\r\n\r\n page.inputWrapper.append(passwordInputField.container, btnNext);\r\n\r\n let getStateInterval: number;\r\n\r\n let getState = () => {\r\n // * just to check session relevance\r\n if(!getStateInterval) {\r\n getStateInterval = window.setInterval(getState, 10e3);\r\n }\r\n\r\n return !TEST && passwordManager.getState().then(_state => {\r\n state = _state;\r\n\r\n if(state.hint) {\r\n replaceContent(passwordInputField.label, htmlToSpan(RichTextProcessor.wrapEmojiText(state.hint)));\r\n } else {\r\n passwordInputField.setLabel();\r\n }\r\n });\r\n };\r\n\r\n let state: AccountPassword;\r\n \r\n const onSubmit = (e?: Event) => {\r\n if(e) {\r\n cancelEvent(e);\r\n }\r\n\r\n if(!passwordInput.value.length) {\r\n passwordInput.classList.add('error');\r\n return;\r\n }\r\n\r\n const toggle = toggleDisability([passwordInput, btnNext], true);\r\n let value = passwordInput.value;\r\n\r\n btnNextI18n.update({key: 'PleaseWait'});\r\n const preloader = putPreloader(btnNext);\r\n\r\n passwordInputField.setValueSilently('' + Math.random()); // prevent saving suggestion\r\n passwordInputField.setValueSilently(value); // prevent saving suggestion\r\n\r\n passwordManager.check(value, state).then((response) => {\r\n //console.log('passwordManager response:', response);\r\n \r\n switch(response._) {\r\n case 'auth.authorization':\r\n clearInterval(getStateInterval);\r\n import('./pageIm').then(m => {\r\n m.default.mount();\r\n });\r\n if(monkey) monkey.remove();\r\n break;\r\n default:\r\n btnNext.removeAttribute('disabled');\r\n btnNextI18n.update({key: response._ as any});\r\n preloader.remove();\r\n break;\r\n }\r\n }).catch((err: any) => {\r\n toggle();\r\n passwordInputField.input.classList.add('error');\r\n \r\n switch(err.type) {\r\n default:\r\n //btnNext.innerText = err.type;\r\n btnNextI18n.update({key: 'PASSWORD_HASH_INVALID'});\r\n passwordInput.select();\r\n break;\r\n }\r\n\r\n preloader.remove();\r\n \r\n getState();\r\n });\r\n };\r\n \r\n attachClickEvent(btnNext, onSubmit);\r\n\r\n passwordInput.addEventListener('keypress', function(this, e) {\r\n this.classList.remove('error');\r\n btnNextI18n.update({key: 'Login.Next'});\r\n\r\n if(e.key === 'Enter') {\r\n return onSubmit();\r\n }\r\n });\r\n\r\n const size = mediaSizes.isMobile ? 100 : 166;\r\n const monkey = new PasswordMonkey(passwordInputField, size);\r\n page.imageDiv.append(monkey.container);\r\n return Promise.all([\r\n monkey.load(),\r\n getState()\r\n ]);\r\n};\r\n\r\nconst page = new Page('page-password', true, onFirstMount, null, () => {\r\n //if(!isAppleMobile) {\r\n passwordInput.focus();\r\n //}\r\n\r\n appStateManager.pushToState('authState', {_: 'authStatePassword'});\r\n});\r\n\r\nexport default page;\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n */\r\n\r\nexport default function replaceContent(elem: HTMLElement, node: string | Node) {\r\n if(typeof(node) === 'string') {\r\n elem.innerHTML = node;\r\n return;\r\n }\r\n\r\n // * children.length doesn't count text nodes\r\n const firstChild = elem.firstChild;\r\n if(firstChild) {\r\n if(elem.lastChild === firstChild) {\r\n firstChild.replaceWith(node);\r\n } else {\r\n elem.textContent = '';\r\n elem.append(node);\r\n }\r\n } else {\r\n elem.append(node);\r\n }\r\n}\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n */\r\n\r\nimport simulateEvent from \"../helpers/dom/dispatchEvent\";\r\nimport findUpAttribute from \"../helpers/dom/findUpAttribute\";\r\nimport getRichValue from \"../helpers/dom/getRichValue\";\r\nimport isInputEmpty from \"../helpers/dom/isInputEmpty\";\r\nimport selectElementContents from \"../helpers/dom/selectElementContents\";\r\nimport { MessageEntity } from \"../layer\";\r\nimport { i18n, LangPackKey, _i18n } from \"../lib/langPack\";\r\nimport RichTextProcessor from \"../lib/richtextprocessor\";\r\nimport SetTransition from \"./singleTransition\";\r\n\r\nlet init = () => {\r\n document.addEventListener('paste', (e) => {\r\n if(!findUpAttribute(e.target, 'contenteditable=\"true\"')) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n let text: string, entities: MessageEntity[];\r\n\r\n // @ts-ignore\r\n let plainText: string = (e.originalEvent || e).clipboardData.getData('text/plain');\r\n let usePlainText = true;\r\n\r\n // @ts-ignore\r\n let html: string = (e.originalEvent || e).clipboardData.getData('text/html');\r\n if(html.trim()) {\r\n html = html.replace(//, '');\r\n html = html.replace(//, '');\r\n\r\n const match = html.match(/([\\s\\S]*)<\\/body>/);\r\n if(match) {\r\n html = match[1].trim();\r\n }\r\n\r\n let span: HTMLElement = document.createElement('span');\r\n span.innerHTML = html;\r\n\r\n let curChild = span.firstChild;\r\n while(curChild) { // * fix whitespace between elements like

asd

\\n

zxc

\r\n let nextSibling = curChild.nextSibling;\r\n if(curChild.nodeType === 3) {\r\n if(!curChild.nodeValue.trim()) {\r\n curChild.remove();\r\n }\r\n }\r\n\r\n curChild = nextSibling;\r\n }\r\n\r\n const richValue = getRichValue(span, true);\r\n if(richValue.value.replace(/\\s/g, '').length === plainText.replace(/\\s/g, '').length) {\r\n text = richValue.value;\r\n entities = richValue.entities;\r\n usePlainText = false;\r\n \r\n let entities2 = RichTextProcessor.parseEntities(text);\r\n entities2 = entities2.filter(e => e._ === 'messageEntityEmoji' || e._ === 'messageEntityLinebreak');\r\n RichTextProcessor.mergeEntities(entities, entities2);\r\n }\r\n }\r\n \r\n if(usePlainText) {\r\n text = plainText;\r\n entities = RichTextProcessor.parseEntities(text);\r\n entities = entities.filter(e => e._ === 'messageEntityEmoji' || e._ === 'messageEntityLinebreak');\r\n }\r\n\r\n text = RichTextProcessor.wrapDraftText(text, {entities});\r\n \r\n window.document.execCommand('insertHTML', false, text);\r\n });\r\n\r\n init = null;\r\n};\r\n\r\n// ! it doesn't respect symbols other than strongs\r\n/* const checkAndSetRTL = (input: HTMLElement) => {\r\n //const isEmpty = isInputEmpty(input);\r\n //console.log('input', isEmpty);\r\n\r\n //const char = [...getRichValue(input)][0];\r\n const char = (input instanceof HTMLInputElement ? input.value : input.innerText)[0];\r\n let direction = 'ltr';\r\n if(char && checkRTL(char)) {\r\n direction = 'rtl';\r\n }\r\n\r\n //console.log('RTL', direction, char);\r\n\r\n input.style.direction = direction;\r\n}; */\r\n\r\nexport enum InputState {\r\n Neutral = 0,\r\n Valid = 1,\r\n Error = 2\r\n};\r\n\r\nexport type InputFieldOptions = {\r\n placeholder?: LangPackKey, \r\n label?: LangPackKey, \r\n labelOptions?: any[],\r\n labelText?: string,\r\n name?: string, \r\n maxLength?: number, \r\n showLengthOn?: number,\r\n plainText?: true,\r\n animate?: boolean,\r\n required?: boolean,\r\n canBeEdited?: boolean,\r\n validate?: () => boolean\r\n};\r\n\r\nclass InputField {\r\n public container: HTMLElement;\r\n public input: HTMLElement;\r\n public inputFake: HTMLElement;\r\n public label: HTMLLabelElement;\r\n\r\n public originalValue: string;\r\n\r\n public required: boolean;\r\n public validate: () => boolean;\r\n\r\n //public onLengthChange: (length: number, isOverflow: boolean) => void;\r\n // protected wasInputFakeClientHeight: number;\r\n // protected showScrollDebounced: () => void;\r\n\r\n constructor(public options: InputFieldOptions = {}) {\r\n this.container = document.createElement('div');\r\n this.container.classList.add('input-field');\r\n\r\n this.required = options.required;\r\n this.validate = options.validate;\r\n\r\n if(options.maxLength !== undefined && options.showLengthOn === undefined) {\r\n options.showLengthOn = Math.min(40, Math.round(options.maxLength / 3));\r\n }\r\n\r\n const {placeholder, maxLength, showLengthOn, name, plainText, canBeEdited = true} = options;\r\n\r\n let label = options.label || options.labelText;\r\n\r\n let input: HTMLElement;\r\n if(!plainText) {\r\n if(init) {\r\n init();\r\n }\r\n\r\n this.container.innerHTML = `\r\n
\r\n `;\r\n\r\n input = this.container.firstElementChild as HTMLElement;\r\n const observer = new MutationObserver(() => {\r\n //checkAndSetRTL(input);\r\n\r\n if(processInput) {\r\n processInput();\r\n }\r\n });\r\n\r\n // * because if delete all characters there will br left\r\n input.addEventListener('input', () => {\r\n if(isInputEmpty(input)) {\r\n input.innerHTML = '';\r\n }\r\n\r\n if(this.inputFake) {\r\n this.inputFake.innerHTML = input.innerHTML;\r\n this.onFakeInput();\r\n }\r\n });\r\n \r\n // ! childList for paste first symbol\r\n observer.observe(input, {characterData: true, childList: true, subtree: true});\r\n\r\n if(options.animate) {\r\n input.classList.add('scrollable', 'scrollable-y');\r\n // this.wasInputFakeClientHeight = 0;\r\n // this.showScrollDebounced = debounce(() => this.input.classList.remove('no-scrollbar'), 150, false, true);\r\n this.inputFake = document.createElement('div');\r\n this.inputFake.setAttribute('contenteditable', 'true');\r\n this.inputFake.className = input.className + ' input-field-input-fake';\r\n }\r\n } else {\r\n this.container.innerHTML = `\r\n \r\n `;\r\n\r\n input = this.container.firstElementChild as HTMLElement;\r\n //input.addEventListener('input', () => checkAndSetRTL(input));\r\n }\r\n\r\n input.setAttribute('dir', 'auto');\r\n\r\n if(placeholder) {\r\n _i18n(input, placeholder, undefined, 'placeholder');\r\n\r\n if(this.inputFake) {\r\n _i18n(this.inputFake, placeholder, undefined, 'placeholder');\r\n }\r\n }\r\n\r\n if(label || placeholder) {\r\n const border = document.createElement('div');\r\n border.classList.add('input-field-border');\r\n this.container.append(border);\r\n }\r\n\r\n if(label) {\r\n this.label = document.createElement('label');\r\n this.setLabel();\r\n this.container.append(this.label);\r\n }\r\n\r\n let processInput: () => void;\r\n if(maxLength) {\r\n const labelEl = this.container.lastElementChild as HTMLLabelElement;\r\n let showingLength = false;\r\n\r\n processInput = () => {\r\n const wasError = input.classList.contains('error');\r\n // * https://stackoverflow.com/a/54369605 #2 to count emoji as 1 symbol\r\n const inputLength = plainText ? (input as HTMLInputElement).value.length : [...getRichValue(input, false).value].length;\r\n const diff = maxLength - inputLength;\r\n const isError = diff < 0;\r\n input.classList.toggle('error', isError);\r\n\r\n //this.onLengthChange && this.onLengthChange(inputLength, isError);\r\n\r\n if(isError || diff <= showLengthOn) {\r\n this.setLabel();\r\n labelEl.append(` (${maxLength - inputLength})`);\r\n if(!showingLength) showingLength = true;\r\n } else if((wasError && !isError) || showingLength) {\r\n this.setLabel();\r\n showingLength = false;\r\n }\r\n };\r\n\r\n input.addEventListener('input', processInput);\r\n }\r\n\r\n this.input = input;\r\n }\r\n\r\n public select() {\r\n if(!this.value) { // * avoid selecting whole empty field on iOS devices\r\n return;\r\n }\r\n\r\n if(this.options.plainText) {\r\n (this.input as HTMLInputElement).select(); // * select text\r\n } else {\r\n selectElementContents(this.input);\r\n }\r\n }\r\n\r\n public setLabel() {\r\n this.label.textContent = '';\r\n if(this.options.labelText) {\r\n this.label.innerHTML = this.options.labelText;\r\n } else {\r\n this.label.append(i18n(this.options.label, this.options.labelOptions));\r\n }\r\n }\r\n\r\n public onFakeInput(setHeight = true) {\r\n const {scrollHeight: newHeight/* , clientHeight */} = this.inputFake;\r\n /* if(this.wasInputFakeClientHeight && this.wasInputFakeClientHeight !== clientHeight) {\r\n this.input.classList.add('no-scrollbar'); // ! в сафари может вообще не появиться скролл после анимации, так как ему нужен полный reflow блока с overflow.\r\n this.showScrollDebounced();\r\n } */\r\n\r\n const currentHeight = +this.input.style.height.replace('px', '');\r\n if(currentHeight === newHeight) {\r\n return;\r\n }\r\n\r\n const TRANSITION_DURATION_FACTOR = 50;\r\n const transitionDuration = Math.round(\r\n TRANSITION_DURATION_FACTOR * Math.log(Math.abs(newHeight - currentHeight)),\r\n );\r\n\r\n // this.wasInputFakeClientHeight = clientHeight;\r\n this.input.style.transitionDuration = `${transitionDuration}ms`;\r\n\r\n if(setHeight) {\r\n this.input.style.height = newHeight ? newHeight + 'px' : '';\r\n }\r\n\r\n const className = 'is-changing-height';\r\n SetTransition(this.input, className, true, transitionDuration, () => {\r\n this.input.classList.remove(className);\r\n });\r\n }\r\n\r\n get value() {\r\n return this.options.plainText ? (this.input as HTMLInputElement).value : getRichValue(this.input, false).value;\r\n //return getRichValue(this.input);\r\n }\r\n\r\n set value(value: string) {\r\n this.setValueSilently(value, false);\r\n\r\n simulateEvent(this.input, 'input');\r\n }\r\n\r\n public setValueSilently(value: string, fireFakeInput = true) {\r\n if(this.options.plainText) {\r\n (this.input as HTMLInputElement).value = value;\r\n } else {\r\n this.input.innerHTML = value;\r\n \r\n if(this.inputFake) {\r\n this.inputFake.innerHTML = value;\r\n\r\n if(fireFakeInput) {\r\n this.onFakeInput();\r\n }\r\n }\r\n }\r\n }\r\n\r\n public isChanged() {\r\n return this.value !== this.originalValue;\r\n }\r\n\r\n public isValid() {\r\n return !this.input.classList.contains('error') && \r\n (!this.validate || this.validate()) && \r\n (!this.required || !isInputEmpty(this.input));\r\n }\r\n\r\n public isValidToChange() {\r\n return this.isValid() && this.isChanged();\r\n }\r\n\r\n public setDraftValue(value = '', silent = false) {\r\n if(!this.options.plainText) {\r\n value = RichTextProcessor.wrapDraftText(value);\r\n }\r\n\r\n if(silent) {\r\n this.setValueSilently(value, false); \r\n } else {\r\n this.value = value;\r\n }\r\n }\r\n\r\n public setOriginalValue(value: InputField['originalValue'] = '', silent = false) {\r\n this.originalValue = value;\r\n this.setDraftValue(value, silent);\r\n }\r\n\r\n public setState(state: InputState, label?: LangPackKey) {\r\n if(label) {\r\n this.label.textContent = '';\r\n this.label.append(i18n(label, this.options.labelOptions));\r\n }\r\n\r\n this.input.classList.toggle('error', !!(state & InputState.Error));\r\n this.input.classList.toggle('valid', !!(state & InputState.Valid));\r\n }\r\n\r\n public setError(label?: LangPackKey) {\r\n this.setState(InputState.Error, label);\r\n }\r\n}\r\n\r\nexport default InputField;\r\n","// https://stackoverflow.com/a/6150060\nexport default function selectElementContents(el: HTMLElement) {\n const range = document.createRange();\n range.selectNodeContents(el);\n const sel = window.getSelection();\n sel.removeAllRanges();\n sel.addRange(range);\n}\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n */\r\n\r\nimport rootScope from \"../lib/rootScope\";\r\n\r\nconst SetTransition = (\r\n element: HTMLElement, \r\n className: string, \r\n forwards: boolean, \r\n duration: number, \r\n onTransitionEnd?: () => void, \r\n useRafs?: number\r\n) => {\r\n const {timeout, raf} = element.dataset;\r\n if(timeout !== undefined) {\r\n clearTimeout(+timeout);\r\n }\r\n\r\n if(raf !== undefined) {\r\n window.cancelAnimationFrame(+raf);\r\n if(!useRafs) {\r\n delete element.dataset.raf;\r\n }\r\n }\r\n\r\n // if(forwards && className && element.classList.contains(className) && !element.classList.contains('animating')) {\r\n // return;\r\n // }\r\n\r\n if(useRafs && rootScope.settings.animationsEnabled && duration) {\r\n element.dataset.raf = '' + window.requestAnimationFrame(() => {\r\n delete element.dataset.raf;\r\n SetTransition(element, className, forwards, duration, onTransitionEnd, useRafs - 1);\r\n });\r\n\r\n return;\r\n }\r\n\r\n if(forwards && className) {\r\n element.classList.add(className);\r\n }\r\n\r\n const afterTimeout = () => {\r\n delete element.dataset.timeout;\r\n if(!forwards && className) {\r\n element.classList.remove('backwards', className);\r\n }\r\n\r\n element.classList.remove('animating');\r\n \r\n onTransitionEnd && onTransitionEnd();\r\n };\r\n\r\n if(!rootScope.settings.animationsEnabled || !duration) {\r\n element.classList.remove('animating', 'backwards');\r\n afterTimeout();\r\n return;\r\n }\r\n\r\n element.classList.add('animating');\r\n\r\n element.classList.toggle('backwards', !forwards);\r\n element.dataset.timeout = '' + setTimeout(afterTimeout, duration);\r\n};\r\n\r\nexport default SetTransition;\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n */\r\n\r\nexport default function toggleDisability(elements: HTMLElement[], disable: boolean): () => void {\r\n if(disable) {\r\n elements.forEach(el => el.setAttribute('disabled', 'true'));\r\n } else {\r\n elements.forEach(el => el.removeAttribute('disabled'));\r\n }\r\n\r\n return () => toggleDisability(elements, !disable);\r\n}\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n * \r\n * Originally from:\r\n * https://github.com/zhukov/webogram\r\n * Copyright (C) 2014 Igor Zhukov \r\n * https://github.com/zhukov/webogram/blob/master/LICENSE\r\n */\r\n\r\nimport { MOUNT_CLASS_TO } from \"../../config/debug\";\r\nimport { MessageEntity } from \"../../layer\";\r\nimport RichTextProcessor from \"../../lib/richtextprocessor\";\r\nimport getRichElementValue from \"./getRichElementValue\";\r\n\r\nexport default function getRichValue(field: HTMLElement, withEntities = true) {\r\n const lines: string[] = [];\r\n const line: string[] = [];\r\n\r\n const entities: MessageEntity[] = withEntities ? [] : undefined;\r\n getRichElementValue(field, lines, line, undefined, undefined, entities);\r\n if(line.length) {\r\n lines.push(line.join(''));\r\n }\r\n\r\n let value = lines.join('\\n');\r\n value = value.replace(/\\u00A0/g, ' ');\r\n\r\n if(entities?.length) {\r\n // ! cannot do that here because have the same check before the sending in RichTextProcessor.parseMarkdown\r\n /* const entity = entities[entities.length - 1];\r\n const length = value.length;\r\n const trimmedLength = value.trimRight().length;\r\n if(length !== trimmedLength) {\r\n entity.length -= length - trimmedLength;\r\n } */\r\n\r\n RichTextProcessor.combineSameEntities(entities);\r\n RichTextProcessor.sortEntities(entities);\r\n }\r\n\r\n //console.log('getRichValue:', value, entities);\r\n\r\n return {value, entities};\r\n}\r\n\r\nMOUNT_CLASS_TO.getRichValue = getRichValue;\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n */\r\n\r\nexport default function findUpAttribute(el: any, attribute: string): HTMLElement {\r\n return el.closest(`[${attribute}]`);\r\n /* if(el.getAttribute(attribute) !== null) return el; // 03.02.2020\r\n\r\n while(el.parentElement) {\r\n el = el.parentElement;\r\n if(el.getAttribute(attribute) !== null) \r\n return el;\r\n }\r\n return null; */\r\n}\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n * \r\n * Originally from:\r\n * https://github.com/zhukov/webogram\r\n * Copyright (C) 2014 Igor Zhukov \r\n * https://github.com/zhukov/webogram/blob/master/LICENSE\r\n */\r\n\r\nimport { MessageEntity } from \"../../layer\";\r\n\r\nexport type MarkdownType = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'monospace' | 'link' | 'mentionName' | 'spoiler';\r\nexport type MarkdownTag = {\r\n match: string,\r\n entityName: Extract;\r\n};\r\n\r\n// https://core.telegram.org/bots/api#html-style\r\nexport const markdownTags: {[type in MarkdownType]: MarkdownTag} = {\r\n bold: {\r\n match: '[style*=\"bold\"], [style*=\"font-weight: 700\"], [style*=\"font-weight: 600\"], [style*=\"font-weight:700\"], [style*=\"font-weight:600\"], b, strong',\r\n entityName: 'messageEntityBold'\r\n },\r\n underline: {\r\n match: '[style*=\"underline\"], u, ins',\r\n entityName: 'messageEntityUnderline'\r\n },\r\n italic: {\r\n match: '[style*=\"italic\"], i, em',\r\n entityName: 'messageEntityItalic'\r\n },\r\n monospace: {\r\n match: '[style*=\"monospace\"], [face=\"monospace\"], pre',\r\n entityName: 'messageEntityPre'\r\n },\r\n strikethrough: {\r\n match: '[style*=\"line-through\"], strike, del, s',\r\n entityName: 'messageEntityStrike'\r\n },\r\n link: {\r\n match: 'A:not(.follow)',\r\n entityName: 'messageEntityTextUrl'\r\n },\r\n mentionName: {\r\n match: 'A.follow',\r\n entityName: 'messageEntityMentionName'\r\n },\r\n spoiler: {\r\n match: '[style*=\"spoiler\"]',\r\n entityName: 'messageEntitySpoiler'\r\n }\r\n};\r\n\r\nconst tabulationMatch = '[style*=\"table-cell\"], th, td';\r\n\r\n/* export function getDepth(child: Node, container?: Node) {\r\n let depth = 0;\r\n\r\n do {\r\n if(child === container) {\r\n return depth;\r\n }\r\n\r\n ++depth;\r\n } while((child = child.parentNode) !== null);\r\n\r\n return depth;\r\n} */\r\n\r\nconst BLOCK_TAG_NAMES = new Set([\r\n 'DIV',\r\n 'P',\r\n 'BR',\r\n 'LI',\r\n 'SECTION',\r\n 'H6',\r\n 'H5',\r\n 'H4',\r\n 'H3',\r\n 'H2',\r\n 'H1',\r\n 'TR'\r\n]);\r\n\r\nexport default function getRichElementValue(node: HTMLElement, lines: string[], line: string[], selNode?: Node, selOffset?: number, entities?: MessageEntity[], offset = {offset: 0}) {\r\n if(node.nodeType === 3) { // TEXT\r\n let nodeValue = node.nodeValue;\r\n\r\n /* const tabulation = node.parentElement?.closest(tabulationMatch + ', [contenteditable]');\r\n if(tabulation?.getAttribute('contenteditable') === null) {\r\n nodeValue += ' ';\r\n // line.push('\\t');\r\n // ++offset.offset;\r\n } */\r\n\r\n if(selNode === node) {\r\n line.push(nodeValue.substr(0, selOffset) + '\\x01' + nodeValue.substr(selOffset));\r\n } else {\r\n line.push(nodeValue);\r\n }\r\n\r\n if(entities && nodeValue.length) {\r\n if(node.parentNode) {\r\n const parentElement = node.parentElement;\r\n \r\n // let closestTag: MarkdownTag, closestElementByTag: Element, closestDepth = Infinity;\r\n for(const type in markdownTags) {\r\n const tag = markdownTags[type as MarkdownType];\r\n const closest = parentElement.closest(tag.match + ', [contenteditable]');\r\n if(closest?.getAttribute('contenteditable') !== null) {\r\n /* const depth = getDepth(closest, parentElement.closest('[contenteditable]'));\r\n if(closestDepth > depth) {\r\n closestDepth = depth;\r\n closestTag = tag;\r\n closestElementByTag = closest;\r\n } */\r\n continue;\r\n }\r\n\r\n if(tag.entityName === 'messageEntityTextUrl') {\r\n entities.push({\r\n _: tag.entityName,\r\n url: (closest as HTMLAnchorElement).href,\r\n offset: offset.offset,\r\n length: nodeValue.length\r\n });\r\n } else if(tag.entityName === 'messageEntityMentionName') {\r\n entities.push({\r\n _: tag.entityName,\r\n offset: offset.offset,\r\n length: nodeValue.length,\r\n user_id: (closest as HTMLElement).dataset.follow.toUserId()\r\n });\r\n } else {\r\n entities.push({\r\n _: tag.entityName as any,\r\n offset: offset.offset,\r\n length: nodeValue.length\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n offset.offset += nodeValue.length;\r\n return;\r\n }\r\n\r\n if(node.nodeType !== 1) { // NON-ELEMENT\r\n return;\r\n }\r\n\r\n const isSelected = selNode === node;\r\n const isBlock = BLOCK_TAG_NAMES.has(node.tagName);\r\n if(isBlock && line.length) {\r\n lines.push(line.join(''));\r\n line.splice(0, line.length);\r\n ++offset.offset;\r\n } else if(node instanceof HTMLImageElement) {\r\n const alt = node.alt;\r\n if(alt) {\r\n line.push(alt);\r\n offset.offset += alt.length;\r\n }\r\n }\r\n\r\n if(isSelected && !selOffset) {\r\n line.push('\\x01');\r\n }\r\n\r\n const isTableCell = node.matches(tabulationMatch);\r\n const wasEntitiesLength = entities?.length;\r\n\r\n let curChild = node.firstChild as HTMLElement;\r\n while(curChild) {\r\n getRichElementValue(curChild, lines, line, selNode, selOffset, entities, offset);\r\n curChild = curChild.nextSibling as any;\r\n }\r\n\r\n if(isSelected && selOffset) {\r\n line.push('\\x01');\r\n }\r\n\r\n if(isTableCell && node.nextSibling) {\r\n line.push(' ');\r\n ++offset.offset;\r\n\r\n // * combine entities such as url after adding space\r\n if(wasEntitiesLength !== undefined) {\r\n for(let i = wasEntitiesLength, length = entities.length; i < length; ++i) {\r\n ++entities[i].length;\r\n }\r\n }\r\n }\r\n\r\n const wasLength = line.length;\r\n if(isBlock && wasLength) {\r\n lines.push(line.join(''));\r\n line.splice(0, wasLength);\r\n ++offset.offset;\r\n }\r\n\r\n if(wasLength && node.tagName === 'P' && node.nextSibling) {\r\n lines.push('');\r\n ++offset.offset;\r\n }\r\n}\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n */\r\n\r\nimport getRichValue from \"./getRichValue\";\r\n\r\nexport default function isInputEmpty(element: HTMLElement) {\r\n if(element.hasAttribute('contenteditable') || element.tagName !== 'INPUT') {\r\n /* const value = element.innerText;\r\n\r\n return !value.trim() && !serializeNodes(Array.from(element.childNodes)).trim(); */\r\n return !getRichValue(element, false).value.trim();\r\n } else {\r\n return !(element as HTMLInputElement).value.trim();\r\n }\r\n}\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n * \r\n * Originally from:\r\n * https://github.com/zhukov/webogram\r\n * Copyright (C) 2014 Igor Zhukov \r\n * https://github.com/zhukov/webogram/blob/master/LICENSE\r\n */\r\n\r\nimport type { AccountPassword, AccountUpdatePasswordSettings, InputCheckPasswordSRP, PasswordKdfAlgo } from '../../layer';\r\nimport { MOUNT_CLASS_TO } from '../../config/debug';\r\nimport apiManager from './mtprotoworker';\r\n\r\nexport class PasswordManager {\r\n public getState(): Promise {\r\n return apiManager.invokeApi('account.getPassword').then((result) => {\r\n return result;\r\n });\r\n }\r\n\r\n public updateSettings(settings: {\r\n hint?: string,\r\n email?: string,\r\n newPassword?: string,\r\n currentPassword?: string\r\n } = {}) {\r\n //state = Object.assign({}, state);\r\n //state.new_algo = Object.assign({}, state.new_algo);\r\n\r\n return this.getState().then(state => {\r\n let currentHashPromise: Promise;\r\n let newHashPromise: Promise;\r\n const params: AccountUpdatePasswordSettings = {\r\n password: null,\r\n new_settings: {\r\n _: 'account.passwordInputSettings',\r\n hint: settings.hint,\r\n email: settings.email\r\n }\r\n };\r\n \r\n if(settings.currentPassword) {\r\n currentHashPromise = apiManager.invokeCrypto('computeSRP', settings.currentPassword, state, false) as any;\r\n } else {\r\n currentHashPromise = Promise.resolve({\r\n _: 'inputCheckPasswordEmpty'\r\n });\r\n }\r\n \r\n // * https://core.telegram.org/api/srp#setting-a-new-2fa-password, but still there is a mistake, TDesktop passes 'new_algo' everytime\r\n const newAlgo = state.new_algo as PasswordKdfAlgo.passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow;\r\n const salt1 = new Uint8Array(newAlgo.salt1.length + 32);\r\n salt1.randomize();\r\n salt1.set(newAlgo.salt1, 0);\r\n newAlgo.salt1 = salt1;\r\n \r\n if(settings.newPassword) {\r\n newHashPromise = apiManager.invokeCrypto('computeSRP', settings.newPassword, state, true) as any;\r\n } else {\r\n newHashPromise = Promise.resolve(new Uint8Array());\r\n }\r\n \r\n return Promise.all([currentHashPromise, newHashPromise]).then((hashes) => {\r\n params.password = hashes[0];\r\n params.new_settings.new_algo = newAlgo;\r\n params.new_settings.new_password_hash = hashes[1];\r\n \r\n return apiManager.invokeApi('account.updatePasswordSettings', params);\r\n });\r\n });\r\n }\r\n\r\n public check(password: string, state: AccountPassword, options: any = {}) {\r\n return apiManager.invokeCrypto('computeSRP', password, state, false).then((inputCheckPassword) => {\r\n //console.log('SRP', inputCheckPassword);\r\n return apiManager.invokeApi('auth.checkPassword', {\r\n password: inputCheckPassword as InputCheckPasswordSRP.inputCheckPasswordSRP\r\n }, options).then(auth => {\r\n if(auth._ === 'auth.authorization') {\r\n apiManager.setUser(auth.user);\r\n }\r\n\r\n return auth;\r\n });\r\n });\r\n }\r\n\r\n public confirmPasswordEmail(code: string) {\r\n return apiManager.invokeApi('account.confirmPasswordEmail', {code});\r\n }\r\n\r\n public resendPasswordEmail() {\r\n return apiManager.invokeApi('account.resendPasswordEmail');\r\n }\r\n\r\n public cancelPasswordEmail() {\r\n return apiManager.invokeApi('account.cancelPasswordEmail');\r\n }\r\n\r\n /* public requestRecovery(options: any = {}) {\r\n return apiManager.invokeApi('auth.requestPasswordRecovery', {}, options);\r\n }\r\n\r\n public recover(code: any, options: any = {}) {\r\n return apiManager.invokeApi('auth.recoverPassword', {\r\n code\r\n }, options);\r\n } */\r\n}\r\n\r\nconst passwordManager = new PasswordManager();\r\nMOUNT_CLASS_TO.passwordManager = passwordManager;\r\nexport default passwordManager;\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n */\r\n\r\nimport { LangPackKey, i18n } from \"../lib/langPack\";\r\n\r\nexport default class LoginPage {\r\n public element: HTMLElement;\r\n public container: HTMLElement;\r\n public imageDiv: HTMLElement;\r\n public inputWrapper: HTMLElement;\r\n public title: HTMLElement;\r\n public subtitle: HTMLParagraphElement;\r\n\r\n constructor(options: {\r\n className: string,\r\n withInputWrapper?: boolean,\r\n titleLangKey?: LangPackKey,\r\n subtitleLangKey?: LangPackKey,\r\n }) {\r\n this.element = document.body.querySelector('.' + options.className) as HTMLDivElement;\r\n //this.element = document.createElement('div');\r\n //this.element.className = 'page-' + options.className;\r\n\r\n this.container = document.createElement('div');\r\n this.container.className = 'container center-align';\r\n\r\n this.imageDiv = document.createElement('div');\r\n this.imageDiv.className = 'auth-image';\r\n\r\n this.title = document.createElement('h4');\r\n if(options.titleLangKey) {\r\n this.title.append(i18n(options.titleLangKey));\r\n }\r\n\r\n this.subtitle = document.createElement('p');\r\n this.subtitle.className = 'subtitle';\r\n if(options.subtitleLangKey) {\r\n this.subtitle.append(i18n(options.subtitleLangKey));\r\n }\r\n \r\n this.container.append(this.imageDiv, this.title, this.subtitle);\r\n\r\n if(options.withInputWrapper) {\r\n this.inputWrapper = document.createElement('div');\r\n this.inputWrapper.className = 'input-wrapper';\r\n this.container.append(this.inputWrapper);\r\n }\r\n\r\n this.element.append(this.container);\r\n }\r\n}\r\n","/*\r\n * https://github.com/morethanwords/tweb\r\n * Copyright (C) 2019-2021 Eduard Kuzmenko\r\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\r\n */\r\n\r\nexport default function htmlToSpan(html: string) {\r\n const span = document.createElement('span');\r\n span.innerHTML = html;\r\n return span;\r\n}\r\n"],"sourceRoot":""}