' to avoid XSS. See https://bit.ly/2ZqJzkp\";\n if (level === 'warn') {\n warn(msg);\n } else if (level === 'error') {\n error(msg);\n }\n }\n }\n };\n\n fn(level, locale, message, paths);\n};\n\nVueI18n.prototype._initVM = function _initVM (data) {\n var silent = Vue.config.silent;\n Vue.config.silent = true;\n this._vm = new Vue({ data: data, __VUE18N__INSTANCE__: true });\n Vue.config.silent = silent;\n};\n\nVueI18n.prototype.destroyVM = function destroyVM () {\n this._vm.$destroy();\n};\n\nVueI18n.prototype.subscribeDataChanging = function subscribeDataChanging (vm) {\n this._dataListeners.add(vm);\n};\n\nVueI18n.prototype.unsubscribeDataChanging = function unsubscribeDataChanging (vm) {\n remove(this._dataListeners, vm);\n};\n\nVueI18n.prototype.watchI18nData = function watchI18nData () {\n var this$1 = this;\n return this._vm.$watch('$data', function () {\n var listeners = arrayFrom(this$1._dataListeners);\n var i = listeners.length;\n while(i--) {\n Vue.nextTick(function () {\n listeners[i] && listeners[i].$forceUpdate();\n });\n }\n }, { deep: true })\n};\n\nVueI18n.prototype.watchLocale = function watchLocale (composer) {\n if (!composer) {\n /* istanbul ignore if */\n if (!this._sync || !this._root) { return null }\n var target = this._vm;\n return this._root.$i18n.vm.$watch('locale', function (val) {\n target.$set(target, 'locale', val);\n target.$forceUpdate();\n }, { immediate: true })\n } else {\n // deal with vue-i18n-bridge\n if (!this.__VUE_I18N_BRIDGE__) { return null }\n var self = this;\n var target$1 = this._vm;\n return this.vm.$watch('locale', function (val) {\n target$1.$set(target$1, 'locale', val);\n if (self.__VUE_I18N_BRIDGE__ && composer) {\n composer.locale.value = val;\n }\n target$1.$forceUpdate();\n }, { immediate: true })\n }\n};\n\nVueI18n.prototype.onComponentInstanceCreated = function onComponentInstanceCreated (newI18n) {\n if (this._componentInstanceCreatedListener) {\n this._componentInstanceCreatedListener(newI18n, this);\n }\n};\n\nprototypeAccessors.vm.get = function () { return this._vm };\n\nprototypeAccessors.messages.get = function () { return looseClone(this._getMessages()) };\nprototypeAccessors.dateTimeFormats.get = function () { return looseClone(this._getDateTimeFormats()) };\nprototypeAccessors.numberFormats.get = function () { return looseClone(this._getNumberFormats()) };\nprototypeAccessors.availableLocales.get = function () { return Object.keys(this.messages).sort() };\n\nprototypeAccessors.locale.get = function () { return this._vm.locale };\nprototypeAccessors.locale.set = function (locale) {\n this._vm.$set(this._vm, 'locale', locale);\n};\n\nprototypeAccessors.fallbackLocale.get = function () { return this._vm.fallbackLocale };\nprototypeAccessors.fallbackLocale.set = function (locale) {\n this._localeChainCache = {};\n this._vm.$set(this._vm, 'fallbackLocale', locale);\n};\n\nprototypeAccessors.formatFallbackMessages.get = function () { return this._formatFallbackMessages };\nprototypeAccessors.formatFallbackMessages.set = function (fallback) { this._formatFallbackMessages = fallback; };\n\nprototypeAccessors.missing.get = function () { return this._missing };\nprototypeAccessors.missing.set = function (handler) { this._missing = handler; };\n\nprototypeAccessors.formatter.get = function () { return this._formatter };\nprototypeAccessors.formatter.set = function (formatter) { this._formatter = formatter; };\n\nprototypeAccessors.silentTranslationWarn.get = function () { return this._silentTranslationWarn };\nprototypeAccessors.silentTranslationWarn.set = function (silent) { this._silentTranslationWarn = silent; };\n\nprototypeAccessors.silentFallbackWarn.get = function () { return this._silentFallbackWarn };\nprototypeAccessors.silentFallbackWarn.set = function (silent) { this._silentFallbackWarn = silent; };\n\nprototypeAccessors.preserveDirectiveContent.get = function () { return this._preserveDirectiveContent };\nprototypeAccessors.preserveDirectiveContent.set = function (preserve) { this._preserveDirectiveContent = preserve; };\n\nprototypeAccessors.warnHtmlInMessage.get = function () { return this._warnHtmlInMessage };\nprototypeAccessors.warnHtmlInMessage.set = function (level) {\n var this$1 = this;\n\n var orgLevel = this._warnHtmlInMessage;\n this._warnHtmlInMessage = level;\n if (orgLevel !== level && (level === 'warn' || level === 'error')) {\n var messages = this._getMessages();\n Object.keys(messages).forEach(function (locale) {\n this$1._checkLocaleMessage(locale, this$1._warnHtmlInMessage, messages[locale]);\n });\n }\n};\n\nprototypeAccessors.postTranslation.get = function () { return this._postTranslation };\nprototypeAccessors.postTranslation.set = function (handler) { this._postTranslation = handler; };\n\nprototypeAccessors.sync.get = function () { return this._sync };\nprototypeAccessors.sync.set = function (val) { this._sync = val; };\n\nVueI18n.prototype._getMessages = function _getMessages () { return this._vm.messages };\nVueI18n.prototype._getDateTimeFormats = function _getDateTimeFormats () { return this._vm.dateTimeFormats };\nVueI18n.prototype._getNumberFormats = function _getNumberFormats () { return this._vm.numberFormats };\n\nVueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm, values, interpolateMode) {\n if (!isNull(result)) { return result }\n if (this._missing) {\n var missingRet = this._missing.apply(null, [locale, key, vm, values]);\n if (isString(missingRet)) {\n return missingRet\n }\n } else {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key)) {\n warn(\n \"Cannot translate the value of keypath '\" + key + \"'. \" +\n 'Use the value of keypath as default.'\n );\n }\n }\n\n if (this._formatFallbackMessages) {\n var parsedArgs = parseArgs.apply(void 0, values);\n return this._render(key, interpolateMode, parsedArgs.params, key)\n } else {\n return key\n }\n};\n\nVueI18n.prototype._isFallbackRoot = function _isFallbackRoot (val) {\n return (this._fallbackRootWithEmptyString? !val : isNull(val)) && !isNull(this._root) && this._fallbackRoot\n};\n\nVueI18n.prototype._isSilentFallbackWarn = function _isSilentFallbackWarn (key) {\n return this._silentFallbackWarn instanceof RegExp\n ? this._silentFallbackWarn.test(key)\n : this._silentFallbackWarn\n};\n\nVueI18n.prototype._isSilentFallback = function _isSilentFallback (locale, key) {\n return this._isSilentFallbackWarn(key) && (this._isFallbackRoot() || locale !== this.fallbackLocale)\n};\n\nVueI18n.prototype._isSilentTranslationWarn = function _isSilentTranslationWarn (key) {\n return this._silentTranslationWarn instanceof RegExp\n ? this._silentTranslationWarn.test(key)\n : this._silentTranslationWarn\n};\n\nVueI18n.prototype._interpolate = function _interpolate (\n locale,\n message,\n key,\n host,\n interpolateMode,\n values,\n visitedLinkStack\n) {\n if (!message) { return null }\n\n var pathRet = this._path.getPathValue(message, key);\n if (isArray(pathRet) || isPlainObject(pathRet)) { return pathRet }\n\n var ret;\n if (isNull(pathRet)) {\n /* istanbul ignore else */\n if (isPlainObject(message)) {\n ret = message[key];\n if (!(isString(ret) || isFunction(ret))) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallback(locale, key)) {\n warn((\"Value of key '\" + key + \"' is not a string or function !\"));\n }\n return null\n }\n } else {\n return null\n }\n } else {\n /* istanbul ignore else */\n if (isString(pathRet) || isFunction(pathRet)) {\n ret = pathRet;\n } else {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallback(locale, key)) {\n warn((\"Value of key '\" + key + \"' is not a string or function!\"));\n }\n return null\n }\n }\n\n // Check for the existence of links within the translated string\n if (isString(ret) && (ret.indexOf('@:') >= 0 || ret.indexOf('@.') >= 0)) {\n ret = this._link(locale, message, ret, host, 'raw', values, visitedLinkStack);\n }\n\n return this._render(ret, interpolateMode, values, key)\n};\n\nVueI18n.prototype._link = function _link (\n locale,\n message,\n str,\n host,\n interpolateMode,\n values,\n visitedLinkStack\n) {\n var ret = str;\n\n // Match all the links within the local\n // We are going to replace each of\n // them with its translation\n var matches = ret.match(linkKeyMatcher);\n\n // eslint-disable-next-line no-autofix/prefer-const\n for (var idx in matches) {\n // ie compatible: filter custom array\n // prototype method\n if (!matches.hasOwnProperty(idx)) {\n continue\n }\n var link = matches[idx];\n var linkKeyPrefixMatches = link.match(linkKeyPrefixMatcher);\n var linkPrefix = linkKeyPrefixMatches[0];\n var formatterName = linkKeyPrefixMatches[1];\n\n // Remove the leading @:, @.case: and the brackets\n var linkPlaceholder = link.replace(linkPrefix, '').replace(bracketsMatcher, '');\n\n if (includes(visitedLinkStack, linkPlaceholder)) {\n if (process.env.NODE_ENV !== 'production') {\n warn((\"Circular reference found. \\\"\" + link + \"\\\" is already visited in the chain of \" + (visitedLinkStack.reverse().join(' <- '))));\n }\n return ret\n }\n visitedLinkStack.push(linkPlaceholder);\n\n // Translate the link\n var translated = this._interpolate(\n locale, message, linkPlaceholder, host,\n interpolateMode === 'raw' ? 'string' : interpolateMode,\n interpolateMode === 'raw' ? undefined : values,\n visitedLinkStack\n );\n\n if (this._isFallbackRoot(translated)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(linkPlaceholder)) {\n warn((\"Fall back to translate the link placeholder '\" + linkPlaceholder + \"' with root locale.\"));\n }\n /* istanbul ignore if */\n if (!this._root) { throw Error('unexpected error') }\n var root = this._root.$i18n;\n translated = root._translate(\n root._getMessages(), root.locale, root.fallbackLocale,\n linkPlaceholder, host, interpolateMode, values\n );\n }\n translated = this._warnDefault(\n locale, linkPlaceholder, translated, host,\n isArray(values) ? values : [values],\n interpolateMode\n );\n\n if (this._modifiers.hasOwnProperty(formatterName)) {\n translated = this._modifiers[formatterName](translated);\n } else if (defaultModifiers.hasOwnProperty(formatterName)) {\n translated = defaultModifiers[formatterName](translated);\n }\n\n visitedLinkStack.pop();\n\n // Replace the link with the translated\n ret = !translated ? ret : ret.replace(link, translated);\n }\n\n return ret\n};\n\nVueI18n.prototype._createMessageContext = function _createMessageContext (values, formatter, path, interpolateMode) {\n var this$1 = this;\n\n var _list = isArray(values) ? values : [];\n var _named = isObject(values) ? values : {};\n var list = function (index) { return _list[index]; };\n var named = function (key) { return _named[key]; };\n var messages = this._getMessages();\n var locale = this.locale;\n\n return {\n list: list,\n named: named,\n values: values,\n formatter: formatter,\n path: path,\n messages: messages,\n locale: locale,\n linked: function (linkedKey) { return this$1._interpolate(locale, messages[locale] || {}, linkedKey, null, interpolateMode, undefined, [linkedKey]); }\n }\n};\n\nVueI18n.prototype._render = function _render (message, interpolateMode, values, path) {\n if (isFunction(message)) {\n return message(\n this._createMessageContext(values, this._formatter || defaultFormatter, path, interpolateMode)\n )\n }\n\n var ret = this._formatter.interpolate(message, values, path);\n\n // If the custom formatter refuses to work - apply the default one\n if (!ret) {\n ret = defaultFormatter.interpolate(message, values, path);\n }\n\n // if interpolateMode is **not** 'string' ('row'),\n // return the compiled data (e.g. ['foo', VNode, 'bar']) with formatter\n return interpolateMode === 'string' && !isString(ret) ? ret.join('') : ret\n};\n\nVueI18n.prototype._appendItemToChain = function _appendItemToChain (chain, item, blocks) {\n var follow = false;\n if (!includes(chain, item)) {\n follow = true;\n if (item) {\n follow = item[item.length - 1] !== '!';\n item = item.replace(/!/g, '');\n chain.push(item);\n if (blocks && blocks[item]) {\n follow = blocks[item];\n }\n }\n }\n return follow\n};\n\nVueI18n.prototype._appendLocaleToChain = function _appendLocaleToChain (chain, locale, blocks) {\n var follow;\n var tokens = locale.split('-');\n do {\n var item = tokens.join('-');\n follow = this._appendItemToChain(chain, item, blocks);\n tokens.splice(-1, 1);\n } while (tokens.length && (follow === true))\n return follow\n};\n\nVueI18n.prototype._appendBlockToChain = function _appendBlockToChain (chain, block, blocks) {\n var follow = true;\n for (var i = 0; (i < block.length) && (isBoolean(follow)); i++) {\n var locale = block[i];\n if (isString(locale)) {\n follow = this._appendLocaleToChain(chain, locale, blocks);\n }\n }\n return follow\n};\n\nVueI18n.prototype._getLocaleChain = function _getLocaleChain (start, fallbackLocale) {\n if (start === '') { return [] }\n\n if (!this._localeChainCache) {\n this._localeChainCache = {};\n }\n\n var chain = this._localeChainCache[start];\n if (!chain) {\n if (!fallbackLocale) {\n fallbackLocale = this.fallbackLocale;\n }\n chain = [];\n\n // first block defined by start\n var block = [start];\n\n // while any intervening block found\n while (isArray(block)) {\n block = this._appendBlockToChain(\n chain,\n block,\n fallbackLocale\n );\n }\n\n // last block defined by default\n var defaults;\n if (isArray(fallbackLocale)) {\n defaults = fallbackLocale;\n } else if (isObject(fallbackLocale)) {\n /* $FlowFixMe */\n if (fallbackLocale['default']) {\n defaults = fallbackLocale['default'];\n } else {\n defaults = null;\n }\n } else {\n defaults = fallbackLocale;\n }\n\n // convert defaults to array\n if (isString(defaults)) {\n block = [defaults];\n } else {\n block = defaults;\n }\n if (block) {\n this._appendBlockToChain(\n chain,\n block,\n null\n );\n }\n this._localeChainCache[start] = chain;\n }\n return chain\n};\n\nVueI18n.prototype._translate = function _translate (\n messages,\n locale,\n fallback,\n key,\n host,\n interpolateMode,\n args\n) {\n var chain = this._getLocaleChain(locale, fallback);\n var res;\n for (var i = 0; i < chain.length; i++) {\n var step = chain[i];\n res =\n this._interpolate(step, messages[step], key, host, interpolateMode, args, [key]);\n if (!isNull(res)) {\n if (step !== locale && process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn((\"Fall back to translate the keypath '\" + key + \"' with '\" + step + \"' locale.\"));\n }\n return res\n }\n }\n return null\n};\n\nVueI18n.prototype._t = function _t (key, _locale, messages, host) {\n var ref;\n\n var values = [], len = arguments.length - 4;\n while ( len-- > 0 ) values[ len ] = arguments[ len + 4 ];\n if (!key) { return '' }\n\n var parsedArgs = parseArgs.apply(void 0, values);\n if(this._escapeParameterHtml) {\n parsedArgs.params = escapeParams(parsedArgs.params);\n }\n\n var locale = parsedArgs.locale || _locale;\n\n var ret = this._translate(\n messages, locale, this.fallbackLocale, key,\n host, 'string', parsedArgs.params\n );\n if (this._isFallbackRoot(ret)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn((\"Fall back to translate the keypath '\" + key + \"' with root locale.\"));\n }\n /* istanbul ignore if */\n if (!this._root) { throw Error('unexpected error') }\n return (ref = this._root).$t.apply(ref, [ key ].concat( values ))\n } else {\n ret = this._warnDefault(locale, key, ret, host, values, 'string');\n if (this._postTranslation && ret !== null && ret !== undefined) {\n ret = this._postTranslation(ret, key);\n }\n return ret\n }\n};\n\nVueI18n.prototype.t = function t (key) {\n var ref;\n\n var values = [], len = arguments.length - 1;\n while ( len-- > 0 ) values[ len ] = arguments[ len + 1 ];\n return (ref = this)._t.apply(ref, [ key, this.locale, this._getMessages(), null ].concat( values ))\n};\n\nVueI18n.prototype._i = function _i (key, locale, messages, host, values) {\n var ret =\n this._translate(messages, locale, this.fallbackLocale, key, host, 'raw', values);\n if (this._isFallbackRoot(ret)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key)) {\n warn((\"Fall back to interpolate the keypath '\" + key + \"' with root locale.\"));\n }\n if (!this._root) { throw Error('unexpected error') }\n return this._root.$i18n.i(key, locale, values)\n } else {\n return this._warnDefault(locale, key, ret, host, [values], 'raw')\n }\n};\n\nVueI18n.prototype.i = function i (key, locale, values) {\n /* istanbul ignore if */\n if (!key) { return '' }\n\n if (!isString(locale)) {\n locale = this.locale;\n }\n\n return this._i(key, locale, this._getMessages(), null, values)\n};\n\nVueI18n.prototype._tc = function _tc (\n key,\n _locale,\n messages,\n host,\n choice\n) {\n var ref;\n\n var values = [], len = arguments.length - 5;\n while ( len-- > 0 ) values[ len ] = arguments[ len + 5 ];\n if (!key) { return '' }\n if (choice === undefined) {\n choice = 1;\n }\n\n var predefined = { 'count': choice, 'n': choice };\n var parsedArgs = parseArgs.apply(void 0, values);\n parsedArgs.params = Object.assign(predefined, parsedArgs.params);\n values = parsedArgs.locale === null ? [parsedArgs.params] : [parsedArgs.locale, parsedArgs.params];\n return this.fetchChoice((ref = this)._t.apply(ref, [ key, _locale, messages, host ].concat( values )), choice)\n};\n\nVueI18n.prototype.fetchChoice = function fetchChoice (message, choice) {\n /* istanbul ignore if */\n if (!message || !isString(message)) { return null }\n var choices = message.split('|');\n\n choice = this.getChoiceIndex(choice, choices.length);\n if (!choices[choice]) { return message }\n return choices[choice].trim()\n};\n\nVueI18n.prototype.tc = function tc (key, choice) {\n var ref;\n\n var values = [], len = arguments.length - 2;\n while ( len-- > 0 ) values[ len ] = arguments[ len + 2 ];\n return (ref = this)._tc.apply(ref, [ key, this.locale, this._getMessages(), null, choice ].concat( values ))\n};\n\nVueI18n.prototype._te = function _te (key, locale, messages) {\n var args = [], len = arguments.length - 3;\n while ( len-- > 0 ) args[ len ] = arguments[ len + 3 ];\n\n var _locale = parseArgs.apply(void 0, args).locale || locale;\n return this._exist(messages[_locale], key)\n};\n\nVueI18n.prototype.te = function te (key, locale) {\n return this._te(key, this.locale, this._getMessages(), locale)\n};\n\nVueI18n.prototype.getLocaleMessage = function getLocaleMessage (locale) {\n return looseClone(this._vm.messages[locale] || {})\n};\n\nVueI18n.prototype.setLocaleMessage = function setLocaleMessage (locale, message) {\n if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {\n this._checkLocaleMessage(locale, this._warnHtmlInMessage, message);\n }\n this._vm.$set(this._vm.messages, locale, message);\n};\n\nVueI18n.prototype.mergeLocaleMessage = function mergeLocaleMessage (locale, message) {\n if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {\n this._checkLocaleMessage(locale, this._warnHtmlInMessage, message);\n }\n this._vm.$set(this._vm.messages, locale, merge(\n typeof this._vm.messages[locale] !== 'undefined' && Object.keys(this._vm.messages[locale]).length\n ? Object.assign({}, this._vm.messages[locale])\n : {},\n message\n ));\n};\n\nVueI18n.prototype.getDateTimeFormat = function getDateTimeFormat (locale) {\n return looseClone(this._vm.dateTimeFormats[locale] || {})\n};\n\nVueI18n.prototype.setDateTimeFormat = function setDateTimeFormat (locale, format) {\n this._vm.$set(this._vm.dateTimeFormats, locale, format);\n this._clearDateTimeFormat(locale, format);\n};\n\nVueI18n.prototype.mergeDateTimeFormat = function mergeDateTimeFormat (locale, format) {\n this._vm.$set(this._vm.dateTimeFormats, locale, merge(this._vm.dateTimeFormats[locale] || {}, format));\n this._clearDateTimeFormat(locale, format);\n};\n\nVueI18n.prototype._clearDateTimeFormat = function _clearDateTimeFormat (locale, format) {\n // eslint-disable-next-line no-autofix/prefer-const\n for (var key in format) {\n var id = locale + \"__\" + key;\n\n if (!this._dateTimeFormatters.hasOwnProperty(id)) {\n continue\n }\n\n delete this._dateTimeFormatters[id];\n }\n};\n\nVueI18n.prototype._localizeDateTime = function _localizeDateTime (\n value,\n locale,\n fallback,\n dateTimeFormats,\n key\n) {\n var _locale = locale;\n var formats = dateTimeFormats[_locale];\n\n var chain = this._getLocaleChain(locale, fallback);\n for (var i = 0; i < chain.length; i++) {\n var current = _locale;\n var step = chain[i];\n formats = dateTimeFormats[step];\n _locale = step;\n // fallback locale\n if (isNull(formats) || isNull(formats[key])) {\n if (step !== locale && process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn((\"Fall back to '\" + step + \"' datetime formats from '\" + current + \"' datetime formats.\"));\n }\n } else {\n break\n }\n }\n\n if (isNull(formats) || isNull(formats[key])) {\n return null\n } else {\n var format = formats[key];\n var id = _locale + \"__\" + key;\n var formatter = this._dateTimeFormatters[id];\n if (!formatter) {\n formatter = this._dateTimeFormatters[id] = new Intl.DateTimeFormat(_locale, format);\n }\n return formatter.format(value)\n }\n};\n\nVueI18n.prototype._d = function _d (value, locale, key) {\n /* istanbul ignore if */\n if (process.env.NODE_ENV !== 'production' && !VueI18n.availabilities.dateTimeFormat) {\n warn('Cannot format a Date value due to not supported Intl.DateTimeFormat.');\n return ''\n }\n\n if (!key) {\n return new Intl.DateTimeFormat(locale).format(value)\n }\n\n var ret =\n this._localizeDateTime(value, locale, this.fallbackLocale, this._getDateTimeFormats(), key);\n if (this._isFallbackRoot(ret)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn((\"Fall back to datetime localization of root: key '\" + key + \"'.\"));\n }\n /* istanbul ignore if */\n if (!this._root) { throw Error('unexpected error') }\n return this._root.$i18n.d(value, key, locale)\n } else {\n return ret || ''\n }\n};\n\nVueI18n.prototype.d = function d (value) {\n var args = [], len = arguments.length - 1;\n while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];\n\n var locale = this.locale;\n var key = null;\n\n if (args.length === 1) {\n if (isString(args[0])) {\n key = args[0];\n } else if (isObject(args[0])) {\n if (args[0].locale) {\n locale = args[0].locale;\n }\n if (args[0].key) {\n key = args[0].key;\n }\n }\n } else if (args.length === 2) {\n if (isString(args[0])) {\n key = args[0];\n }\n if (isString(args[1])) {\n locale = args[1];\n }\n }\n\n return this._d(value, locale, key)\n};\n\nVueI18n.prototype.getNumberFormat = function getNumberFormat (locale) {\n return looseClone(this._vm.numberFormats[locale] || {})\n};\n\nVueI18n.prototype.setNumberFormat = function setNumberFormat (locale, format) {\n this._vm.$set(this._vm.numberFormats, locale, format);\n this._clearNumberFormat(locale, format);\n};\n\nVueI18n.prototype.mergeNumberFormat = function mergeNumberFormat (locale, format) {\n this._vm.$set(this._vm.numberFormats, locale, merge(this._vm.numberFormats[locale] || {}, format));\n this._clearNumberFormat(locale, format);\n};\n\nVueI18n.prototype._clearNumberFormat = function _clearNumberFormat (locale, format) {\n // eslint-disable-next-line no-autofix/prefer-const\n for (var key in format) {\n var id = locale + \"__\" + key;\n\n if (!this._numberFormatters.hasOwnProperty(id)) {\n continue\n }\n\n delete this._numberFormatters[id];\n }\n};\n\nVueI18n.prototype._getNumberFormatter = function _getNumberFormatter (\n value,\n locale,\n fallback,\n numberFormats,\n key,\n options\n) {\n var _locale = locale;\n var formats = numberFormats[_locale];\n\n var chain = this._getLocaleChain(locale, fallback);\n for (var i = 0; i < chain.length; i++) {\n var current = _locale;\n var step = chain[i];\n formats = numberFormats[step];\n _locale = step;\n // fallback locale\n if (isNull(formats) || isNull(formats[key])) {\n if (step !== locale && process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn((\"Fall back to '\" + step + \"' number formats from '\" + current + \"' number formats.\"));\n }\n } else {\n break\n }\n }\n\n if (isNull(formats) || isNull(formats[key])) {\n return null\n } else {\n var format = formats[key];\n\n var formatter;\n if (options) {\n // If options specified - create one time number formatter\n formatter = new Intl.NumberFormat(_locale, Object.assign({}, format, options));\n } else {\n var id = _locale + \"__\" + key;\n formatter = this._numberFormatters[id];\n if (!formatter) {\n formatter = this._numberFormatters[id] = new Intl.NumberFormat(_locale, format);\n }\n }\n return formatter\n }\n};\n\nVueI18n.prototype._n = function _n (value, locale, key, options) {\n /* istanbul ignore if */\n if (!VueI18n.availabilities.numberFormat) {\n if (process.env.NODE_ENV !== 'production') {\n warn('Cannot format a Number value due to not supported Intl.NumberFormat.');\n }\n return ''\n }\n\n if (!key) {\n var nf = !options ? new Intl.NumberFormat(locale) : new Intl.NumberFormat(locale, options);\n return nf.format(value)\n }\n\n var formatter = this._getNumberFormatter(value, locale, this.fallbackLocale, this._getNumberFormats(), key, options);\n var ret = formatter && formatter.format(value);\n if (this._isFallbackRoot(ret)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {\n warn((\"Fall back to number localization of root: key '\" + key + \"'.\"));\n }\n /* istanbul ignore if */\n if (!this._root) { throw Error('unexpected error') }\n return this._root.$i18n.n(value, Object.assign({}, { key: key, locale: locale }, options))\n } else {\n return ret || ''\n }\n};\n\nVueI18n.prototype.n = function n (value) {\n var args = [], len = arguments.length - 1;\n while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];\n\n var locale = this.locale;\n var key = null;\n var options = null;\n\n if (args.length === 1) {\n if (isString(args[0])) {\n key = args[0];\n } else if (isObject(args[0])) {\n if (args[0].locale) {\n locale = args[0].locale;\n }\n if (args[0].key) {\n key = args[0].key;\n }\n\n // Filter out number format options only\n options = Object.keys(args[0]).reduce(function (acc, key) {\n var obj;\n\n if (includes(numberFormatKeys, key)) {\n return Object.assign({}, acc, ( obj = {}, obj[key] = args[0][key], obj ))\n }\n return acc\n }, null);\n }\n } else if (args.length === 2) {\n if (isString(args[0])) {\n key = args[0];\n }\n if (isString(args[1])) {\n locale = args[1];\n }\n }\n\n return this._n(value, locale, key, options)\n};\n\nVueI18n.prototype._ntp = function _ntp (value, locale, key, options) {\n /* istanbul ignore if */\n if (!VueI18n.availabilities.numberFormat) {\n if (process.env.NODE_ENV !== 'production') {\n warn('Cannot format to parts a Number value due to not supported Intl.NumberFormat.');\n }\n return []\n }\n\n if (!key) {\n var nf = !options ? new Intl.NumberFormat(locale) : new Intl.NumberFormat(locale, options);\n return nf.formatToParts(value)\n }\n\n var formatter = this._getNumberFormatter(value, locale, this.fallbackLocale, this._getNumberFormats(), key, options);\n var ret = formatter && formatter.formatToParts(value);\n if (this._isFallbackRoot(ret)) {\n if (process.env.NODE_ENV !== 'production' && !this._isSilentTranslationWarn(key)) {\n warn((\"Fall back to format number to parts of root: key '\" + key + \"' .\"));\n }\n /* istanbul ignore if */\n if (!this._root) { throw Error('unexpected error') }\n return this._root.$i18n._ntp(value, locale, key, options)\n } else {\n return ret || []\n }\n};\n\nObject.defineProperties( VueI18n.prototype, prototypeAccessors );\n\nvar availabilities;\n// $FlowFixMe\nObject.defineProperty(VueI18n, 'availabilities', {\n get: function get () {\n if (!availabilities) {\n var intlDefined = typeof Intl !== 'undefined';\n availabilities = {\n dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined',\n numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined'\n };\n }\n\n return availabilities\n }\n});\n\nVueI18n.install = install;\nVueI18n.version = '8.27.0';\n\nexport default VueI18n;\n","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{\"name\":\"m-message-fade\",\"mode\":\"in-out\"}},[_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.show),expression:\"show\"}],staticClass:\"m-message-wrapper\",class:_vm.wrapperClassName,style:({\r\n width: _vm.width\r\n })},[_c('mmessage',{class:[_vm.type && 'm-message--' + _vm.type, _vm.className],attrs:{\"event\":_vm.event,\"chat\":_vm.chat,\"closable\":_vm.showClose,\"is-collapsed\":_vm.isCollapsed,\"close-handler\":_vm.close,\"click-handler\":_vm.click,\"title\":_vm.title,\"supportHTML\":_vm.supportHTML},nativeOn:{\"mouseenter\":function($event){return _vm.clearTimer.apply(null, arguments)},\"mouseleave\":function($event){return _vm.startTimer.apply(null, arguments)}}},[_c('template',{slot:\"icon\"},[(_vm.iconImg)?_c('img',{staticClass:\"m-message--icon\",attrs:{\"src\":_vm.iconImg}}):(_vm.type)?_c('icon',{staticClass:\"m-message--icon\",attrs:{\"name\":_vm.type}}):_vm._e()],1)],2)],1)])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.visible),expression:\"visible\"}],staticClass:\"m-message\"},[(_vm.iconImg || _vm.$slots.icon)?_c('div',{staticClass:\"m-message-icons\",on:{\"click\":_vm.handleClick}},[(_vm.iconImg)?_c('img',{staticClass:\"m-message--icon\",attrs:{\"src\":_vm.iconImg,\"alt\":\"Img\"}}):_vm._t(\"icon\")],2):_vm._e(),_c('div',{staticClass:\"m-message-content\",on:{\"click\":_vm.handleClick}},[(_vm.title || _vm.$slots.title)?_c('div',{staticClass:\"m-message--title\"},[_vm._t(\"title\",function(){return [_vm._v(\" \"+_vm._s(_vm.title)+\" \")]})],2):_vm._e(),(_vm.event && _vm.chat)?_c('event',{attrs:{\"event\":_vm.event,\"chat\":_vm.chat,\"preview\":true}}):_c('div',{staticClass:\"m-message--body\"},[_vm._t(\"message\")],2)],1)])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\r\n \r\n
\r\n
![\"Img\"/]()
\r\n
\r\n
\r\n
\r\n
\r\n \r\n {{ title }}\r\n \r\n
\r\n\r\n
\r\n
\r\n \r\n\r\n \r\n
\r\n \r\n
\r\n
\r\n\r\n\r\n\r\n","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./mmessage.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./mmessage.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./mmessage.vue?vue&type=template&id=03371e2c&\"\nimport script from \"./mmessage.vue?vue&type=script&lang=js&\"\nexport * from \"./mmessage.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n ,true\n)\n\nexport default component.exports","'use strict'\r\nconst icons = {}\r\n\r\nexport const addIcon = function (name, options) {\r\n icons[name] = options\r\n}\r\n\r\nconst Icon = {\r\n name: 'Icon',\r\n props: {\r\n name: String,\r\n color: String\r\n },\r\n computed: {\r\n svg () {\r\n return icons[this.name]\r\n }\r\n },\r\n // eslint-disable-next-line\r\n render (h) {\r\n const svg = this.svg\r\n\r\n if (!svg) {\r\n // eslint-disable-next-line\r\n console.warn(`The name of '${this.name}' could not be found.`)\r\n return ``\r\n }\r\n\r\n const style = {\r\n color: this.color ? this.color : (svg.fill ? svg.fill : null)\r\n }\r\n\r\n return (\r\n `\r\n \r\n `\r\n )\r\n }\r\n}\r\n\r\nIcon.add = addIcon\r\n\r\nexport default Icon\r\n","export default {\r\n name: 'info',\r\n fill: '#1CADF2',\r\n viewBox: '0 0 1024 1024',\r\n path: 'M512,72C269,72,72,269,72,512s197,440,440,440s440-197,440-440S755,72,512,72z M581,673.9 c-33.2,49.9-67,88.3-123.8,88.3c-38.8-6.3-54.7-34.1-46.3-62.4L484,457.6c1.8-5.9-1.2-12.3-6.6-14.2c-5.4-1.9-15.9,5.1-25.1,15.1 l-44.2,53.2c-1.2-8.9-0.1-23.7-0.1-29.6c33.2-49.9,87.8-89.2,124.8-89.2c35.2,3.6,51.8,31.7,45.7,62.6l-73.6,243.3 c-1,5.5,1.9,11.1,6.9,12.8c5.4,1.9,16.8-5.1,26-15.1l44.2-53.1C583,652.3,581,667.9,581,673.9z M571.2,357.6 c-28,0-50.6-20.4-50.6-50.4c0-30,22.7-50.3,50.6-50.3c28,0,50.6,20.4,50.6,50.3C621.8,337.3,599.1,357.6,571.2,357.6z'\r\n}\r\n","export default {\r\n name: 'success',\r\n fill: '#17B77E',\r\n viewBox: '0 0 1024 1024',\r\n path: 'M512,72C269,72,72,269,72,512s197,440,440,440s440-197,440-440S755,72,512,72L512,72z M758.9,374 c-48.5,48.6-81.2,76.9-172.3,186.8c-52.6,63.4-102.3,131.5-102.7,132L462.1,720c-4.6,6.1-13.5,6.8-19.1,1.6L267.9,558.9 c-17.8-16.5-18.8-44.4-2.3-62.2s44.4-18.8,62.2-2.3l104.9,97.5c5.5,5.1,14.1,4.5,18.9-1.3c16.2-20.1,38.4-44.5,62.4-68.6 c90.2-90.9,145.6-139.7,175.2-161.3c36-26.2,77.3-48.6,87.3-36.2C792,343.9,782.5,350.3,758.9,374L758.9,374z'\r\n}\r\n","export default {\r\n name: 'error',\r\n fill: '#F56C6C',\r\n viewBox: '0 0 1024 1024',\r\n path: 'M512,952C269,952,72,755,72,512S269,72,512,72s440,197,440,440S755,952,512,952z M579.7,512l101.6-101.6 c18.7-18.7,18.7-49,0-67.7c-18.7-18.7-49-18.7-67.7,0l0,0L512,444.3L410.4,342.7c-18.7-18.7-49-18.7-67.7,0s-18.7,49,0,67.7 L444.3,512L342.7,613.6c-18.7,18.7-18.7,49,0,67.7c18.7,18.7,49,18.7,67.7,0L512,579.7l101.6,101.6c18.7,18.7,49,18.7,67.7,0 c18.7-18.7,18.7-49,0-67.7L579.7,512z'\r\n}\r\n","export default {\r\n name: 'warning',\r\n fill: '#FFC603',\r\n viewBox: '0 0 1024 1024',\r\n path: 'M512,952C269,952,72,755,72,512S269,72,512,72s440,197,440,440S755,952,512,952z M510,770.8 c30.4,0,55-24.6,55-55s-24.6-55-55-55s-55,24.6-55,55S479.6,770.8,510,770.8z M509.8,255.3c-39.3,0-71.2,31.9-71.2,71.2 c0,3.1,0.2,6.2,0.6,9.3L472.4,588c2.5,19.3,18.9,33.7,38.4,33.7c19.4,0,35.8-14.4,38.2-33.7l31.8-252.2c5-39.2-22.8-75-62-79.9 C515.9,255.5,512.8,255.3,509.8,255.3z'\r\n}\r\n","export default {\r\n name: 'loading',\r\n viewBox: '0 0 50 50',\r\n class: 'm-loading-icon m-loading-wipe',\r\n defs: ``,\r\n html: ''\r\n}\r\n","import Icon from './icon'\r\nimport InfoIcon from './svgs/info'\r\nimport SuccessIcon from './svgs/success'\r\nimport ErrorIcon from './svgs/error'\r\nimport WarningIcon from './svgs/warning'\r\nimport LoadingIcon from './svgs/loading'\r\n\r\nIcon.add(InfoIcon.name, InfoIcon)\r\nIcon.add(SuccessIcon.name, SuccessIcon)\r\nIcon.add(ErrorIcon.name, ErrorIcon)\r\nIcon.add(WarningIcon.name, WarningIcon)\r\nIcon.add(LoadingIcon.name, LoadingIcon)\r\n\r\nexport default Icon\r\n","\r\n\r\n \r\n
\r\n \r\n
\r\n \r\n \r\n \r\n
\r\n\r\n\r\n\r\n","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./message-template.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./message-template.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./message-template.vue?vue&type=template&id=7da7e992&\"\nimport script from \"./message-template.vue?vue&type=script&lang=js&\"\nexport * from \"./message-template.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n ,true\n)\n\nexport default component.exports","import MessageTemplate from './message-template'\r\nimport Vue from 'vue'\r\nconst MessageConstructor = Vue.extend(MessageTemplate)\r\n\r\nconst instances = []\r\nlet count = 1\r\nconst containers = {}\r\n\r\nconst Message = function (options) {\r\n let userOnClose = options.onClose\r\n let userOnClick = options.onClick\r\n const position = options.position || 'top-center'\r\n const hasMask = options.hasMask || false\r\n const containerKey = position + (hasMask ? '-mask' : '')\r\n let containerEl = containers[containerKey]\r\n\r\n if (!containerEl) {\r\n containerEl = containers[containerKey] = document.createElement('div')\r\n containerEl.className = [\r\n 'm-message-container',\r\n 'is-' + position,\r\n hasMask ? 'has-mask' : ''\r\n ].filter(function (e) { return !!e }).join(' ')\r\n document.body.appendChild(containerEl)\r\n }\r\n\r\n if (options.zIndex) {\r\n containerEl.style.zIndex = options.zIndex\r\n }\r\n\r\n const id = count++\r\n options.onClose = function () {\r\n Message.close(id, userOnClose)\r\n }\r\n\r\n options.onClick = function () {\r\n Message.click(id, userOnClick, userOnClose)\r\n }\r\n\r\n const instance = new MessageConstructor({\r\n el: document.createElement('div'),\r\n data: options\r\n })\r\n\r\n instance.id = id\r\n instance.containerKey = containerKey\r\n\r\n // for position of bottom-*\r\n if (position.indexOf('bottom') === 0 && containerEl.firstChild) {\r\n containerEl.insertBefore(instance.$el, containerEl.firstChild)\r\n } else {\r\n containerEl.appendChild(instance.$el)\r\n }\r\n // 挂载后再设置显示才有过渡效果\r\n instance.show = true\r\n\r\n instances.push(instance)\r\n\r\n return instance\r\n}\r\n\r\nMessage.click = function (id, userOnClick, userOnClose) {\r\n for (let i = 0, len = instances.length; i < len; i++) {\r\n if (id === instances[i].id) {\r\n const { containerKey, hasMask } = instances[i]\r\n // 响应options.onClose\r\n if (typeof userOnClick === 'function') {\r\n userOnClick(instances[i])\r\n }\r\n \r\n }\r\n }\r\n\r\n Message.close(id, userOnClose)\r\n}\r\n\r\nMessage.close = function (id, userOnClose) {\r\n for (let i = 0, len = instances.length; i < len; i++) {\r\n if (id === instances[i].id) {\r\n const { containerKey, hasMask } = instances[i]\r\n // 响应options.onClose\r\n if (typeof userOnClose === 'function') {\r\n userOnClose(instances[i])\r\n }\r\n instances[i] = null\r\n instances.splice(i, 1)\r\n\r\n const index = instances.findIndex(function (e) {\r\n return e.containerKey === containerKey\r\n })\r\n // 如果开启遮罩,300ms 后移除容器(不移除白屏时间太长)\r\n if (hasMask && index === -1) {\r\n setTimeout(function () {\r\n containers[containerKey].remove()\r\n containers[containerKey] = null\r\n }, 300)\r\n }\r\n break\r\n }\r\n }\r\n\r\n setTimeout(function () {\r\n // 当前没有消息后,移除容器\r\n if (instances.length === 0) {\r\n for (let type in containers) {\r\n if (containers[type]) {\r\n containers[type].remove()\r\n containers[type] = null\r\n }\r\n }\r\n }\r\n }, 300)\r\n}\r\n\r\nMessage.closeAll = function () {\r\n for (let i = instances.length - 1; i >= 0; i--) {\r\n instances[i].close()\r\n }\r\n}\r\n\r\nconst types = [ 'info', 'success', 'error', 'warning', 'loading' ]\r\n\r\ntypes.forEach(type => {\r\n Message[type] = function (options) {\r\n options = typeof options === 'string' ? { message: options } : options\r\n return Message({ ...options, type })\r\n }\r\n})\r\n\r\nexport default Message\r\n","import Message from './message.js'\r\nimport MessageComponent from './mmessage.vue'\r\nimport './asd.css'\r\n\r\nMessage.install = function (Vue, options) {\r\n if (options && options.name) {\r\n Vue.prototype[`$${options.name}`] = Message\r\n } else {\r\n Vue.prototype.$message = Message\r\n }\r\n}\r\n\r\nexport const MMessage = MessageComponent\r\nexport default Message\r\n","import f from \"@/application/functions\";\r\n\r\nvar cachestorage = {}\r\n\r\nclass MTRXKIT {\r\n\r\n constructor(core, p) {\r\n if (!p) p = {}\r\n\r\n this.core = core\r\n }\r\n\r\n tetatetchat(m_chat){\r\n if(!m_chat) return false\r\n \r\n if(typeof m_chat.tetatet != 'undefined') return m_chat.tetatet\r\n\r\n var users = this.core.mtrx.chatUsersInfo(m_chat.roomId)\r\n var tt = false\r\n\r\n if(users.length == 2){\r\n tt = m_chat.name == '#' + this.tetatetid(users[0], users[1])\r\n }\r\n if(users.length > 1) m_chat.tetatet = tt\r\n\r\n return tt\r\n }\r\n\r\n tetatetid(user1, user2) {\r\n\r\n var seed = 2;\r\n\r\n if(user1.id == user2.id) return null\r\n\r\n var id = parseInt(user1.id, 16) * parseInt(user2.id, 16) * seed\r\n\r\n if(cachestorage[id]) return cachestorage[id]\r\n\r\n var hash = f.sha224(id.toString()).toString('hex')\r\n\r\n cachestorage[id] = hash\r\n\r\n return hash\r\n }\r\n\r\n unknowngroupusers(m_chat){\r\n return m_chat && m_chat._selfMembership === 'invite' && !m_chat.summary.members && !this.tetatetchat(this.m_chat)\r\n }\r\n\r\n usersFromChats(m_chats){\r\n var users = {}\r\n \r\n _.each(m_chats, (chat) => {\r\n\r\n users[chat.roomId] = _.map(_.uniq([].concat(_.toArray(chat.currentState.members), chat.summary.members || []), (r) => {\r\n return r.userId\r\n\r\n }), function(r){\r\n\r\n return {\r\n userId : f.getmatrixid(r.userId),\r\n membership : r.membership,\r\n powerLevel : r.powerLevel\r\n }\r\n\r\n }) \r\n })\r\n\r\n\r\n\r\n return users\r\n }\r\n\r\n prepareChat(m_chat){\r\n\t\treturn this.usersInfoForChatsStore([m_chat]).then(() => {\r\n return this.core.pcrypto.addroom(m_chat)\r\n })\r\n\t}\r\n\r\n fillContacts(m_chats){\r\n\r\n m_chats = _.filter(m_chats, (ch) => {\r\n return ch._selfMembership == 'join' && ch.name.length == 57\r\n })\r\n\r\n return this.usersInfoForChatsStore(m_chats).then(i => {\r\n\r\n this.core.store.commit('SET_CONTACTS_FROM_MATRIX', _.filter(i, (m) => {\r\n return !this.core.user.userinfo || m.id !== this.core.user.userinfo.id\r\n }))\r\n\r\n })\r\n }\r\n\r\n usersInfoForChatsStore(m_chats, reload){\r\n\r\n return this.usersInfoForChats(m_chats, reload).then(i => {\r\n\r\n this.core.store.commit('SET_CHATS_USERS', this.usersFromChats(m_chats))\r\n\r\n return Promise.resolve(i)\r\n }).catch(e => {\r\n return Promise.resolve()\r\n })\r\n }\r\n\r\n allchatmembers(m_chats, reload, withinvite){\r\n var members = []\r\n var promises = []\r\n\r\n\r\n if(withinvite){\r\n var promises = _.map(m_chats, (chat) => {\r\n\r\n\r\n if(chat._selfMembership === 'invite' && (!chat.summary.members || reload) && !chat.summary.membersloading){\r\n \r\n chat.summary.membersloading = true\r\n \r\n return chat._loadMembersFromServer().then(r => {\r\n \r\n chat.summary.membersloading = false\r\n \r\n chat.summary.members = _.map(r, (user) => {\r\n \r\n return {\r\n name: f.getmatrixid(user.state_key),\r\n membership: user.content.membership,\r\n user: user,\r\n userId : user.state_key,\r\n powerLevel : user.content.powerLevel || 0\r\n }\r\n \r\n })\r\n \r\n if(chat._selfMembership === 'invite' && this.core.user.userinfo){\r\n \r\n if(!_.find(chat.summary.members, (m) => {\r\n return m.userId == this.core.user.matrixId(this.core.user.userinfo.id)\r\n } )){\r\n \r\n chat.summary.members.push({\r\n name: this.core.user.userinfo.id,\r\n membership: 'invite',\r\n user: this.core.user.userinfo,\r\n userId : this.core.user.matrixId(this.core.user.userinfo.id),\r\n powerLevel : 0\r\n })\r\n \r\n }\r\n \r\n }\r\n \r\n return Promise.resolve()\r\n \r\n }).catch(e => {\r\n \r\n chat.summary.membersloading = false\r\n \r\n return Promise.resolve()\r\n })\r\n }\r\n \r\n return Promise.resolve()\r\n \r\n })\r\n }\r\n\r\n return Promise.all(promises).then(r => {\r\n\r\n _.each(m_chats, (chat) => {\r\n members = members.concat(_.toArray(chat.currentState.members), chat.summary.members || [])\r\n })\r\n\r\n members = _.uniq(members, function(m){\r\n return m.userId\r\n })\r\n\r\n return Promise.resolve(members)\r\n })\r\n }\r\n\r\n usersInfoForChats(m_chats, reload) {\r\n\r\n /// TODO FILTER CONTACTS\r\n\r\n return this.allchatmembers(m_chats, reload).then(members => {\r\n\r\n return this.usersInfo(members, reload)\r\n })\r\n \r\n }\r\n\r\n usersInfoById(id) {\r\n\r\n var ids = [f.getmatrixid(id)]\r\n\r\n return this.core.user.usersInfo(ids, false).then( r => {\r\n return Promise.resolve(r[0])\r\n })\r\n }\r\n\r\n usersInfo(members, reload) {\r\n\r\n var ids = _.map(members, function (m) {\r\n return f.getmatrixid(m.userId)\r\n })\r\n\r\n ids = _.uniq(ids)\r\n\r\n return this.core.user.usersInfo(ids, false, reload)\r\n }\r\n\r\n groupId(users) {\r\n let id = [];\r\n let idForInviting = []\r\n let self = this\r\n\r\n users.forEach( (user) => {\r\n idForInviting.push( this.core.user.matrixId(user.id) )\r\n })\r\n\r\n users.forEach(function (user) {\r\n let idsForHash = parseInt(user.id, 16)\r\n\r\n id.push(idsForHash)\r\n })\r\n\r\n const groupNameId = id.reduce((product, n) => product * n, 1);\r\n const mGroupNamId = f.makeid(groupNameId)\r\n let hash = f.sha224(mGroupNamId.toString()).toString('hex')\r\n\r\n return {hash: hash, idForInviting: idForInviting}\r\n\r\n }\r\n\r\n groupIdLight(ids) {\r\n\r\n let id = [];\r\n let idForInviting = []\r\n let self = this\r\n\r\n var domains = [null]\r\n\r\n if (window.chatinvitedomains) domains = [].concat(domains, window.chatinvitedomains)\r\n\r\n _.each(domains, (domain) => {\r\n\r\n _.each(ids, (id) => {\r\n idForInviting.push( this.core.user.matrixId(id, domain) )\r\n })\r\n\r\n })\r\n\r\n \r\n _.each(ids, (_id) => {\r\n let idsForHash = parseInt(_id, 16)\r\n\r\n id.push(idsForHash)\r\n })\r\n\r\n const groupNameId = id.reduce((product, n) => product * n, 1);\r\n const mGroupNamId = f.makeid(groupNameId)\r\n\r\n let hash = f.sha224(mGroupNamId.toString()).toString('hex')\r\n return {hash: hash, idForInviting: idForInviting}\r\n }\r\n\r\n chatIsPublic(chat){\r\n var join_rules = chat.currentState.getStateEvents(\"m.room.join_rules\")\r\n\r\n return _.find(join_rules, (v) => {\r\n return f.deep(v, 'event.content.join_rule') == 'public'\r\n }) ? true : false\r\n }\r\n\r\n \r\n}\r\n\r\nexport default MTRXKIT","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * FingerprintJS v3.3.2 - Copyright (c) FingerprintJS, Inc, 2021 (https://fingerprintjs.com)\n * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.\n *\n * This software contains code from open-source projects:\n * MurmurHash3 by Karan Lyons (https://github.com/karanlyons/murmurHash3.js)\n */\n\nimport { __awaiter, __generator, __assign, __spreadArrays } from 'tslib';\n\nvar version = \"3.3.2\";\n\nfunction wait(durationMs, resolveWith) {\n return new Promise(function (resolve) { return setTimeout(resolve, durationMs, resolveWith); });\n}\nfunction requestIdleCallbackIfAvailable(fallbackTimeout, deadlineTimeout) {\n if (deadlineTimeout === void 0) { deadlineTimeout = Infinity; }\n var requestIdleCallback = window.requestIdleCallback;\n if (requestIdleCallback) {\n // The function `requestIdleCallback` loses the binding to `window` here.\n // `globalThis` isn't always equal `window` (see https://github.com/fingerprintjs/fingerprintjs/issues/683).\n // Therefore, an error can occur. `call(window,` prevents the error.\n return new Promise(function (resolve) { return requestIdleCallback.call(window, function () { return resolve(); }, { timeout: deadlineTimeout }); });\n }\n else {\n return wait(Math.min(fallbackTimeout, deadlineTimeout));\n }\n}\nfunction isPromise(value) {\n return value && typeof value.then === 'function';\n}\n/**\n * Calls a maybe asynchronous function without creating microtasks when the function is synchronous.\n * Catches errors in both cases.\n *\n * If just you run a code like this:\n * ```\n * console.time('Action duration')\n * await action()\n * console.timeEnd('Action duration')\n * ```\n * The synchronous function time can be measured incorrectly because another microtask may run before the `await`\n * returns the control back to the code.\n */\nfunction awaitIfAsync(action, callback) {\n try {\n var returnedValue = action();\n if (isPromise(returnedValue)) {\n returnedValue.then(function (result) { return callback(true, result); }, function (error) { return callback(false, error); });\n }\n else {\n callback(true, returnedValue);\n }\n }\n catch (error) {\n callback(false, error);\n }\n}\n/**\n * If you run many synchronous tasks without using this function, the JS main loop will be busy and asynchronous tasks\n * (e.g. completing a network request, rendering the page) won't be able to happen.\n * This function allows running many synchronous tasks such way that asynchronous tasks can run too in background.\n */\nfunction forEachWithBreaks(items, callback, loopReleaseInterval) {\n if (loopReleaseInterval === void 0) { loopReleaseInterval = 16; }\n return __awaiter(this, void 0, void 0, function () {\n var lastLoopReleaseTime, i, now;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n lastLoopReleaseTime = Date.now();\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < items.length)) return [3 /*break*/, 4];\n callback(items[i], i);\n now = Date.now();\n if (!(now >= lastLoopReleaseTime + loopReleaseInterval)) return [3 /*break*/, 3];\n lastLoopReleaseTime = now;\n // Allows asynchronous actions and microtasks to happen\n return [4 /*yield*/, wait(0)];\n case 2:\n // Allows asynchronous actions and microtasks to happen\n _a.sent();\n _a.label = 3;\n case 3:\n ++i;\n return [3 /*break*/, 1];\n case 4: return [2 /*return*/];\n }\n });\n });\n}\n\n/*\n * Taken from https://github.com/karanlyons/murmurHash3.js/blob/a33d0723127e2e5415056c455f8aed2451ace208/murmurHash3.js\n */\n//\n// Given two 64bit ints (as an array of two 32bit ints) returns the two\n// added together as a 64bit int (as an array of two 32bit ints).\n//\nfunction x64Add(m, n) {\n m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff];\n n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff];\n var o = [0, 0, 0, 0];\n o[3] += m[3] + n[3];\n o[2] += o[3] >>> 16;\n o[3] &= 0xffff;\n o[2] += m[2] + n[2];\n o[1] += o[2] >>> 16;\n o[2] &= 0xffff;\n o[1] += m[1] + n[1];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n o[0] += m[0] + n[0];\n o[0] &= 0xffff;\n return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];\n}\n//\n// Given two 64bit ints (as an array of two 32bit ints) returns the two\n// multiplied together as a 64bit int (as an array of two 32bit ints).\n//\nfunction x64Multiply(m, n) {\n m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff];\n n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff];\n var o = [0, 0, 0, 0];\n o[3] += m[3] * n[3];\n o[2] += o[3] >>> 16;\n o[3] &= 0xffff;\n o[2] += m[2] * n[3];\n o[1] += o[2] >>> 16;\n o[2] &= 0xffff;\n o[2] += m[3] * n[2];\n o[1] += o[2] >>> 16;\n o[2] &= 0xffff;\n o[1] += m[1] * n[3];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n o[1] += m[2] * n[2];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n o[1] += m[3] * n[1];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n o[0] += m[0] * n[3] + m[1] * n[2] + m[2] * n[1] + m[3] * n[0];\n o[0] &= 0xffff;\n return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];\n}\n//\n// Given a 64bit int (as an array of two 32bit ints) and an int\n// representing a number of bit positions, returns the 64bit int (as an\n// array of two 32bit ints) rotated left by that number of positions.\n//\nfunction x64Rotl(m, n) {\n n %= 64;\n if (n === 32) {\n return [m[1], m[0]];\n }\n else if (n < 32) {\n return [(m[0] << n) | (m[1] >>> (32 - n)), (m[1] << n) | (m[0] >>> (32 - n))];\n }\n else {\n n -= 32;\n return [(m[1] << n) | (m[0] >>> (32 - n)), (m[0] << n) | (m[1] >>> (32 - n))];\n }\n}\n//\n// Given a 64bit int (as an array of two 32bit ints) and an int\n// representing a number of bit positions, returns the 64bit int (as an\n// array of two 32bit ints) shifted left by that number of positions.\n//\nfunction x64LeftShift(m, n) {\n n %= 64;\n if (n === 0) {\n return m;\n }\n else if (n < 32) {\n return [(m[0] << n) | (m[1] >>> (32 - n)), m[1] << n];\n }\n else {\n return [m[1] << (n - 32), 0];\n }\n}\n//\n// Given two 64bit ints (as an array of two 32bit ints) returns the two\n// xored together as a 64bit int (as an array of two 32bit ints).\n//\nfunction x64Xor(m, n) {\n return [m[0] ^ n[0], m[1] ^ n[1]];\n}\n//\n// Given a block, returns murmurHash3's final x64 mix of that block.\n// (`[0, h[0] >>> 1]` is a 33 bit unsigned right shift. This is the\n// only place where we need to right shift 64bit ints.)\n//\nfunction x64Fmix(h) {\n h = x64Xor(h, [0, h[0] >>> 1]);\n h = x64Multiply(h, [0xff51afd7, 0xed558ccd]);\n h = x64Xor(h, [0, h[0] >>> 1]);\n h = x64Multiply(h, [0xc4ceb9fe, 0x1a85ec53]);\n h = x64Xor(h, [0, h[0] >>> 1]);\n return h;\n}\n//\n// Given a string and an optional seed as an int, returns a 128 bit\n// hash using the x64 flavor of MurmurHash3, as an unsigned hex.\n//\nfunction x64hash128(key, seed) {\n key = key || '';\n seed = seed || 0;\n var remainder = key.length % 16;\n var bytes = key.length - remainder;\n var h1 = [0, seed];\n var h2 = [0, seed];\n var k1 = [0, 0];\n var k2 = [0, 0];\n var c1 = [0x87c37b91, 0x114253d5];\n var c2 = [0x4cf5ad43, 0x2745937f];\n var i;\n for (i = 0; i < bytes; i = i + 16) {\n k1 = [\n (key.charCodeAt(i + 4) & 0xff) |\n ((key.charCodeAt(i + 5) & 0xff) << 8) |\n ((key.charCodeAt(i + 6) & 0xff) << 16) |\n ((key.charCodeAt(i + 7) & 0xff) << 24),\n (key.charCodeAt(i) & 0xff) |\n ((key.charCodeAt(i + 1) & 0xff) << 8) |\n ((key.charCodeAt(i + 2) & 0xff) << 16) |\n ((key.charCodeAt(i + 3) & 0xff) << 24),\n ];\n k2 = [\n (key.charCodeAt(i + 12) & 0xff) |\n ((key.charCodeAt(i + 13) & 0xff) << 8) |\n ((key.charCodeAt(i + 14) & 0xff) << 16) |\n ((key.charCodeAt(i + 15) & 0xff) << 24),\n (key.charCodeAt(i + 8) & 0xff) |\n ((key.charCodeAt(i + 9) & 0xff) << 8) |\n ((key.charCodeAt(i + 10) & 0xff) << 16) |\n ((key.charCodeAt(i + 11) & 0xff) << 24),\n ];\n k1 = x64Multiply(k1, c1);\n k1 = x64Rotl(k1, 31);\n k1 = x64Multiply(k1, c2);\n h1 = x64Xor(h1, k1);\n h1 = x64Rotl(h1, 27);\n h1 = x64Add(h1, h2);\n h1 = x64Add(x64Multiply(h1, [0, 5]), [0, 0x52dce729]);\n k2 = x64Multiply(k2, c2);\n k2 = x64Rotl(k2, 33);\n k2 = x64Multiply(k2, c1);\n h2 = x64Xor(h2, k2);\n h2 = x64Rotl(h2, 31);\n h2 = x64Add(h2, h1);\n h2 = x64Add(x64Multiply(h2, [0, 5]), [0, 0x38495ab5]);\n }\n k1 = [0, 0];\n k2 = [0, 0];\n switch (remainder) {\n case 15:\n k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 14)], 48));\n // fallthrough\n case 14:\n k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 13)], 40));\n // fallthrough\n case 13:\n k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 12)], 32));\n // fallthrough\n case 12:\n k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 11)], 24));\n // fallthrough\n case 11:\n k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 10)], 16));\n // fallthrough\n case 10:\n k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 9)], 8));\n // fallthrough\n case 9:\n k2 = x64Xor(k2, [0, key.charCodeAt(i + 8)]);\n k2 = x64Multiply(k2, c2);\n k2 = x64Rotl(k2, 33);\n k2 = x64Multiply(k2, c1);\n h2 = x64Xor(h2, k2);\n // fallthrough\n case 8:\n k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 7)], 56));\n // fallthrough\n case 7:\n k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 6)], 48));\n // fallthrough\n case 6:\n k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 5)], 40));\n // fallthrough\n case 5:\n k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 4)], 32));\n // fallthrough\n case 4:\n k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 3)], 24));\n // fallthrough\n case 3:\n k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 2)], 16));\n // fallthrough\n case 2:\n k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 1)], 8));\n // fallthrough\n case 1:\n k1 = x64Xor(k1, [0, key.charCodeAt(i)]);\n k1 = x64Multiply(k1, c1);\n k1 = x64Rotl(k1, 31);\n k1 = x64Multiply(k1, c2);\n h1 = x64Xor(h1, k1);\n // fallthrough\n }\n h1 = x64Xor(h1, [0, key.length]);\n h2 = x64Xor(h2, [0, key.length]);\n h1 = x64Add(h1, h2);\n h2 = x64Add(h2, h1);\n h1 = x64Fmix(h1);\n h2 = x64Fmix(h2);\n h1 = x64Add(h1, h2);\n h2 = x64Add(h2, h1);\n return (('00000000' + (h1[0] >>> 0).toString(16)).slice(-8) +\n ('00000000' + (h1[1] >>> 0).toString(16)).slice(-8) +\n ('00000000' + (h2[0] >>> 0).toString(16)).slice(-8) +\n ('00000000' + (h2[1] >>> 0).toString(16)).slice(-8));\n}\n\n/**\n * Converts an error object to a plain object that can be used with `JSON.stringify`.\n * If you just run `JSON.stringify(error)`, you'll get `'{}'`.\n */\nfunction errorToObject(error) {\n var _a;\n return __assign({ name: error.name, message: error.message, stack: (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split('\\n') }, error);\n}\n\n/*\n * This file contains functions to work with pure data only (no browser features, DOM, side effects, etc).\n */\n/**\n * Does the same as Array.prototype.includes but has better typing\n */\nfunction includes(haystack, needle) {\n for (var i = 0, l = haystack.length; i < l; ++i) {\n if (haystack[i] === needle) {\n return true;\n }\n }\n return false;\n}\n/**\n * Like `!includes()` but with proper typing\n */\nfunction excludes(haystack, needle) {\n return !includes(haystack, needle);\n}\n/**\n * Be careful, NaN can return\n */\nfunction toInt(value) {\n return parseInt(value);\n}\n/**\n * Be careful, NaN can return\n */\nfunction toFloat(value) {\n return parseFloat(value);\n}\nfunction replaceNaN(value, replacement) {\n return typeof value === 'number' && isNaN(value) ? replacement : value;\n}\nfunction countTruthy(values) {\n return values.reduce(function (sum, value) { return sum + (value ? 1 : 0); }, 0);\n}\nfunction round(value, base) {\n if (base === void 0) { base = 1; }\n if (Math.abs(base) >= 1) {\n return Math.round(value / base) * base;\n }\n else {\n // Sometimes when a number is multiplied by a small number, precision is lost,\n // for example 1234 * 0.0001 === 0.12340000000000001, and it's more precise divide: 1234 / (1 / 0.0001) === 0.1234.\n var counterBase = 1 / base;\n return Math.round(value * counterBase) / counterBase;\n }\n}\n/**\n * Parses a CSS selector into tag name with HTML attributes.\n * Only single element selector are supported (without operators like space, +, >, etc).\n *\n * Multiple values can be returned for each attribute. You decide how to handle them.\n */\nfunction parseSimpleCssSelector(selector) {\n var _a, _b;\n var errorMessage = \"Unexpected syntax '\" + selector + \"'\";\n var tagMatch = /^\\s*([a-z-]*)(.*)$/i.exec(selector);\n var tag = tagMatch[1] || undefined;\n var attributes = {};\n var partsRegex = /([.:#][\\w-]+|\\[.+?\\])/gi;\n var addAttribute = function (name, value) {\n attributes[name] = attributes[name] || [];\n attributes[name].push(value);\n };\n for (;;) {\n var match = partsRegex.exec(tagMatch[2]);\n if (!match) {\n break;\n }\n var part = match[0];\n switch (part[0]) {\n case '.':\n addAttribute('class', part.slice(1));\n break;\n case '#':\n addAttribute('id', part.slice(1));\n break;\n case '[': {\n var attributeMatch = /^\\[([\\w-]+)([~|^$*]?=(\"(.*?)\"|([\\w-]+)))?(\\s+[is])?\\]$/.exec(part);\n if (attributeMatch) {\n addAttribute(attributeMatch[1], (_b = (_a = attributeMatch[4]) !== null && _a !== void 0 ? _a : attributeMatch[5]) !== null && _b !== void 0 ? _b : '');\n }\n else {\n throw new Error(errorMessage);\n }\n break;\n }\n default:\n throw new Error(errorMessage);\n }\n }\n return [tag, attributes];\n}\n\nfunction ensureErrorWithMessage(error) {\n return error && typeof error === 'object' && 'message' in error ? error : { message: error };\n}\n/**\n * Loads the given entropy source. Returns a function that gets an entropy component from the source.\n *\n * The result is returned synchronously to prevent `loadSources` from\n * waiting for one source to load before getting the components from the other sources.\n */\nfunction loadSource(source, sourceOptions) {\n var isFinalResultLoaded = function (loadResult) {\n return typeof loadResult !== 'function';\n };\n var sourceLoadPromise = new Promise(function (resolveLoad) {\n var loadStartTime = Date.now();\n // `awaitIfAsync` is used instead of just `await` in order to measure the duration of synchronous sources\n // correctly (other microtasks won't affect the duration).\n awaitIfAsync(source.bind(null, sourceOptions), function () {\n var loadArgs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n loadArgs[_i] = arguments[_i];\n }\n var loadDuration = Date.now() - loadStartTime;\n // Source loading failed\n if (!loadArgs[0]) {\n return resolveLoad(function () { return ({ error: ensureErrorWithMessage(loadArgs[1]), duration: loadDuration }); });\n }\n var loadResult = loadArgs[1];\n // Source loaded with the final result\n if (isFinalResultLoaded(loadResult)) {\n return resolveLoad(function () { return ({ value: loadResult, duration: loadDuration }); });\n }\n // Source loaded with \"get\" stage\n resolveLoad(function () {\n return new Promise(function (resolveGet) {\n var getStartTime = Date.now();\n awaitIfAsync(loadResult, function () {\n var getArgs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n getArgs[_i] = arguments[_i];\n }\n var duration = loadDuration + Date.now() - getStartTime;\n // Source getting failed\n if (!getArgs[0]) {\n return resolveGet({ error: ensureErrorWithMessage(getArgs[1]), duration: duration });\n }\n // Source getting succeeded\n resolveGet({ value: getArgs[1], duration: duration });\n });\n });\n });\n });\n });\n return function getComponent() {\n return sourceLoadPromise.then(function (finalizeSource) { return finalizeSource(); });\n };\n}\n/**\n * Loads the given entropy sources. Returns a function that collects the entropy components.\n *\n * The result is returned synchronously in order to allow start getting the components\n * before the sources are loaded completely.\n *\n * Warning for package users:\n * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.\n */\nfunction loadSources(sources, sourceOptions, excludeSources) {\n var includedSources = Object.keys(sources).filter(function (sourceKey) { return excludes(excludeSources, sourceKey); });\n var sourceGetters = Array(includedSources.length);\n // Using `forEachWithBreaks` allows asynchronous sources to complete between synchronous sources\n // and measure the duration correctly\n forEachWithBreaks(includedSources, function (sourceKey, index) {\n sourceGetters[index] = loadSource(sources[sourceKey], sourceOptions);\n });\n return function getComponents() {\n return __awaiter(this, void 0, void 0, function () {\n var components, _i, includedSources_1, sourceKey, componentPromises, _loop_1, state_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n components = {};\n for (_i = 0, includedSources_1 = includedSources; _i < includedSources_1.length; _i++) {\n sourceKey = includedSources_1[_i];\n components[sourceKey] = undefined;\n }\n componentPromises = Array(includedSources.length);\n _loop_1 = function () {\n var hasAllComponentPromises;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n hasAllComponentPromises = true;\n return [4 /*yield*/, forEachWithBreaks(includedSources, function (sourceKey, index) {\n if (!componentPromises[index]) {\n // `sourceGetters` may be incomplete at this point of execution because `forEachWithBreaks` is asynchronous\n if (sourceGetters[index]) {\n componentPromises[index] = sourceGetters[index]().then(function (component) { return (components[sourceKey] = component); });\n }\n else {\n hasAllComponentPromises = false;\n }\n }\n })];\n case 1:\n _a.sent();\n if (hasAllComponentPromises) {\n return [2 /*return*/, \"break\"];\n }\n return [4 /*yield*/, wait(1)]; // Lets the source load loop continue\n case 2:\n _a.sent(); // Lets the source load loop continue\n return [2 /*return*/];\n }\n });\n };\n _a.label = 1;\n case 1: return [5 /*yield**/, _loop_1()];\n case 2:\n state_1 = _a.sent();\n if (state_1 === \"break\")\n return [3 /*break*/, 4];\n _a.label = 3;\n case 3: return [3 /*break*/, 1];\n case 4: return [4 /*yield*/, Promise.all(componentPromises)];\n case 5:\n _a.sent();\n return [2 /*return*/, components];\n }\n });\n });\n };\n}\n\n/*\n * Functions to help with features that vary through browsers\n */\n/**\n * Checks whether the browser is based on Trident (the Internet Explorer engine) without using user-agent.\n *\n * Warning for package users:\n * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.\n */\nfunction isTrident() {\n var w = window;\n var n = navigator;\n // The properties are checked to be in IE 10, IE 11 and not to be in other browsers in October 2020\n return (countTruthy([\n 'MSCSSMatrix' in w,\n 'msSetImmediate' in w,\n 'msIndexedDB' in w,\n 'msMaxTouchPoints' in n,\n 'msPointerEnabled' in n,\n ]) >= 4);\n}\n/**\n * Checks whether the browser is based on EdgeHTML (the pre-Chromium Edge engine) without using user-agent.\n *\n * Warning for package users:\n * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.\n */\nfunction isEdgeHTML() {\n // Based on research in October 2020\n var w = window;\n var n = navigator;\n return (countTruthy(['msWriteProfilerMark' in w, 'MSStream' in w, 'msLaunchUri' in n, 'msSaveBlob' in n]) >= 3 &&\n !isTrident());\n}\n/**\n * Checks whether the browser is based on Chromium without using user-agent.\n *\n * Warning for package users:\n * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.\n */\nfunction isChromium() {\n // Based on research in October 2020. Tested to detect Chromium 42-86.\n var w = window;\n var n = navigator;\n return (countTruthy([\n 'webkitPersistentStorage' in n,\n 'webkitTemporaryStorage' in n,\n n.vendor.indexOf('Google') === 0,\n 'webkitResolveLocalFileSystemURL' in w,\n 'BatteryManager' in w,\n 'webkitMediaStream' in w,\n 'webkitSpeechGrammar' in w,\n ]) >= 5);\n}\n/**\n * Checks whether the browser is based on mobile or desktop Safari without using user-agent.\n * All iOS browsers use WebKit (the Safari engine).\n *\n * Warning for package users:\n * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.\n */\nfunction isWebKit() {\n // Based on research in September 2020\n var w = window;\n var n = navigator;\n return (countTruthy([\n 'ApplePayError' in w,\n 'CSSPrimitiveValue' in w,\n 'Counter' in w,\n n.vendor.indexOf('Apple') === 0,\n 'getStorageUpdates' in n,\n 'WebKitMediaKeys' in w,\n ]) >= 4);\n}\n/**\n * Checks whether the WebKit browser is a desktop Safari.\n *\n * Warning for package users:\n * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.\n */\nfunction isDesktopSafari() {\n var w = window;\n return (countTruthy([\n 'safari' in w,\n !('DeviceMotionEvent' in w),\n !('ongestureend' in w),\n !('standalone' in navigator),\n ]) >= 3);\n}\n/**\n * Checks whether the browser is based on Gecko (Firefox engine) without using user-agent.\n *\n * Warning for package users:\n * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.\n */\nfunction isGecko() {\n var _a, _b;\n var w = window;\n // Based on research in September 2020\n return (countTruthy([\n 'buildID' in navigator,\n 'MozAppearance' in ((_b = (_a = document.documentElement) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : {}),\n 'onmozfullscreenchange' in w,\n 'mozInnerScreenX' in w,\n 'CSSMozDocumentRule' in w,\n 'CanvasCaptureMediaStream' in w,\n ]) >= 4);\n}\n/**\n * Checks whether the browser is based on Chromium version ≥86 without using user-agent.\n * It doesn't check that the browser is based on Chromium, there is a separate function for this.\n */\nfunction isChromium86OrNewer() {\n // Checked in Chrome 85 vs Chrome 86 both on desktop and Android\n var w = window;\n return (countTruthy([\n !('MediaSettingsRange' in w),\n 'RTCEncodedAudioFrame' in w,\n '' + w.Intl === '[object Intl]',\n '' + w.Reflect === '[object Reflect]',\n ]) >= 3);\n}\n/**\n * Checks whether the browser is based on WebKit version ≥606 (Safari ≥12) without using user-agent.\n * It doesn't check that the browser is based on WebKit, there is a separate function for this.\n *\n * @link https://en.wikipedia.org/wiki/Safari_version_history#Release_history Safari-WebKit versions map\n */\nfunction isWebKit606OrNewer() {\n // Checked in Safari 9–14\n var w = window;\n return (countTruthy([\n 'DOMRectList' in w,\n 'RTCPeerConnectionIceEvent' in w,\n 'SVGGeometryElement' in w,\n 'ontransitioncancel' in w,\n ]) >= 3);\n}\n/**\n * Checks whether the device is an iPad.\n * It doesn't check that the engine is WebKit and that the WebKit isn't desktop.\n */\nfunction isIPad() {\n // Checked on:\n // Safari on iPadOS (both mobile and desktop modes): 8, 11, 12, 13, 14\n // Chrome on iPadOS (both mobile and desktop modes): 11, 12, 13, 14\n // Safari on iOS (both mobile and desktop modes): 9, 10, 11, 12, 13, 14\n // Chrome on iOS (both mobile and desktop modes): 9, 10, 11, 12, 13, 14\n // Before iOS 13. Safari tampers the value in \"request desktop site\" mode since iOS 13.\n if (navigator.platform === 'iPad') {\n return true;\n }\n var s = screen;\n var screenRatio = s.width / s.height;\n return (countTruthy([\n 'MediaSource' in window,\n !!Element.prototype.webkitRequestFullscreen,\n // iPhone 4S that runs iOS 9 matches this. But it won't match the criteria above, so it won't be detected as iPad.\n screenRatio > 0.65 && screenRatio < 1.53,\n ]) >= 2);\n}\n/**\n * Warning for package users:\n * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.\n */\nfunction getFullscreenElement() {\n var d = document;\n return d.fullscreenElement || d.msFullscreenElement || d.mozFullScreenElement || d.webkitFullscreenElement || null;\n}\nfunction exitFullscreen() {\n var d = document;\n // `call` is required because the function throws an error without a proper \"this\" context\n return (d.exitFullscreen || d.msExitFullscreen || d.mozCancelFullScreen || d.webkitExitFullscreen).call(d);\n}\n/**\n * Checks whether the device runs on Android without using user-agent.\n *\n * Warning for package users:\n * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.\n */\nfunction isAndroid() {\n var isItChromium = isChromium();\n var isItGecko = isGecko();\n // Only 2 browser engines are presented on Android.\n // Actually, there is also Android 4.1 browser, but it's not worth detecting it at the moment.\n if (!isItChromium && !isItGecko) {\n return false;\n }\n var w = window;\n // Chrome removes all words \"Android\" from `navigator` when desktop version is requested\n // Firefox keeps \"Android\" in `navigator.appVersion` when desktop version is requested\n return (countTruthy([\n 'onorientationchange' in w,\n 'orientation' in w,\n isItChromium && !('SharedWorker' in w),\n isItGecko && /android/i.test(navigator.appVersion),\n ]) >= 2);\n}\n\n/**\n * A deep description: https://fingerprintjs.com/blog/audio-fingerprinting/\n * Inspired by and based on https://github.com/cozylife/audio-fingerprint\n */\nfunction getAudioFingerprint() {\n var w = window;\n var AudioContext = w.OfflineAudioContext || w.webkitOfflineAudioContext;\n if (!AudioContext) {\n return -2 /* NotSupported */;\n }\n // In some browsers, audio context always stays suspended unless the context is started in response to a user action\n // (e.g. a click or a tap). It prevents audio fingerprint from being taken at an arbitrary moment of time.\n // Such browsers are old and unpopular, so the audio fingerprinting is just skipped in them.\n // See a similar case explanation at https://stackoverflow.com/questions/46363048/onaudioprocess-not-called-on-ios11#46534088\n if (doesCurrentBrowserSuspendAudioContext()) {\n return -1 /* KnownToSuspend */;\n }\n var hashFromIndex = 4500;\n var hashToIndex = 5000;\n var context = new AudioContext(1, hashToIndex, 44100);\n var oscillator = context.createOscillator();\n oscillator.type = 'triangle';\n oscillator.frequency.value = 10000;\n var compressor = context.createDynamicsCompressor();\n compressor.threshold.value = -50;\n compressor.knee.value = 40;\n compressor.ratio.value = 12;\n compressor.attack.value = 0;\n compressor.release.value = 0.25;\n oscillator.connect(compressor);\n compressor.connect(context.destination);\n oscillator.start(0);\n var _a = startRenderingAudio(context), renderPromise = _a[0], finishRendering = _a[1];\n var fingerprintPromise = renderPromise.then(function (buffer) { return getHash(buffer.getChannelData(0).subarray(hashFromIndex)); }, function (error) {\n if (error.name === \"timeout\" /* Timeout */ || error.name === \"suspended\" /* Suspended */) {\n return -3 /* Timeout */;\n }\n throw error;\n });\n // Suppresses the console error message in case when the fingerprint fails before requested\n fingerprintPromise.catch(function () { return undefined; });\n return function () {\n finishRendering();\n return fingerprintPromise;\n };\n}\n/**\n * Checks if the current browser is known to always suspend audio context\n */\nfunction doesCurrentBrowserSuspendAudioContext() {\n return isWebKit() && !isDesktopSafari() && !isWebKit606OrNewer();\n}\n/**\n * Starts rendering the audio context.\n * When the returned function is called, the render process starts finishing.\n */\nfunction startRenderingAudio(context) {\n var renderTryMaxCount = 3;\n var renderRetryDelay = 500;\n var runningMaxAwaitTime = 500;\n var runningSufficientTime = 5000;\n var finalize = function () { return undefined; };\n var resultPromise = new Promise(function (resolve, reject) {\n var isFinalized = false;\n var renderTryCount = 0;\n var startedRunningAt = 0;\n context.oncomplete = function (event) { return resolve(event.renderedBuffer); };\n var startRunningTimeout = function () {\n setTimeout(function () { return reject(makeInnerError(\"timeout\" /* Timeout */)); }, Math.min(runningMaxAwaitTime, startedRunningAt + runningSufficientTime - Date.now()));\n };\n var tryRender = function () {\n try {\n context.startRendering();\n switch (context.state) {\n case 'running':\n startedRunningAt = Date.now();\n if (isFinalized) {\n startRunningTimeout();\n }\n break;\n // Sometimes the audio context doesn't start after calling `startRendering` (in addition to the cases where\n // audio context doesn't start at all). A known case is starting an audio context when the browser tab is in\n // background on iPhone. Retries usually help in this case.\n case 'suspended':\n // The audio context can reject starting until the tab is in foreground. Long fingerprint duration\n // in background isn't a problem, therefore the retry attempts don't count in background. It can lead to\n // a situation when a fingerprint takes very long time and finishes successfully. FYI, the audio context\n // can be suspended when `document.hidden === false` and start running after a retry.\n if (!document.hidden) {\n renderTryCount++;\n }\n if (isFinalized && renderTryCount >= renderTryMaxCount) {\n reject(makeInnerError(\"suspended\" /* Suspended */));\n }\n else {\n setTimeout(tryRender, renderRetryDelay);\n }\n break;\n }\n }\n catch (error) {\n reject(error);\n }\n };\n tryRender();\n finalize = function () {\n if (!isFinalized) {\n isFinalized = true;\n if (startedRunningAt > 0) {\n startRunningTimeout();\n }\n }\n };\n });\n return [resultPromise, finalize];\n}\nfunction getHash(signal) {\n var hash = 0;\n for (var i = 0; i < signal.length; ++i) {\n hash += Math.abs(signal[i]);\n }\n return hash;\n}\nfunction makeInnerError(name) {\n var error = new Error(name);\n error.name = name;\n return error;\n}\n\n/**\n * Creates and keeps an invisible iframe while the given function runs.\n * The given function is called when the iframe is loaded and has a body.\n * The iframe allows to measure DOM sizes inside itself.\n *\n * Notice: passing an initial HTML code doesn't work in IE.\n *\n * Warning for package users:\n * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.\n */\nfunction withIframe(action, initialHtml, domPollInterval) {\n var _a, _b, _c;\n if (domPollInterval === void 0) { domPollInterval = 50; }\n return __awaiter(this, void 0, void 0, function () {\n var d, iframe;\n return __generator(this, function (_d) {\n switch (_d.label) {\n case 0:\n d = document;\n _d.label = 1;\n case 1:\n if (!!d.body) return [3 /*break*/, 3];\n return [4 /*yield*/, wait(domPollInterval)];\n case 2:\n _d.sent();\n return [3 /*break*/, 1];\n case 3:\n iframe = d.createElement('iframe');\n _d.label = 4;\n case 4:\n _d.trys.push([4, , 10, 11]);\n return [4 /*yield*/, new Promise(function (_resolve, _reject) {\n var isComplete = false;\n var resolve = function () {\n isComplete = true;\n _resolve();\n };\n var reject = function (error) {\n isComplete = true;\n _reject(error);\n };\n iframe.onload = resolve;\n iframe.onerror = reject;\n var style = iframe.style;\n style.setProperty('display', 'block', 'important'); // Required for browsers to calculate the layout\n style.position = 'absolute';\n style.top = '0';\n style.left = '0';\n style.visibility = 'hidden';\n if (initialHtml && 'srcdoc' in iframe) {\n iframe.srcdoc = initialHtml;\n }\n else {\n iframe.src = 'about:blank';\n }\n d.body.appendChild(iframe);\n // WebKit in WeChat doesn't fire the iframe's `onload` for some reason.\n // This code checks for the loading state manually.\n // See https://github.com/fingerprintjs/fingerprintjs/issues/645\n var checkReadyState = function () {\n var _a, _b;\n // The ready state may never become 'complete' in Firefox despite the 'load' event being fired.\n // So an infinite setTimeout loop can happen without this check.\n // See https://github.com/fingerprintjs/fingerprintjs/pull/716#issuecomment-986898796\n if (isComplete) {\n return;\n }\n // Make sure iframe.contentWindow and iframe.contentWindow.document are both loaded\n // The contentWindow.document can miss in JSDOM (https://github.com/jsdom/jsdom).\n if (((_b = (_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document) === null || _b === void 0 ? void 0 : _b.readyState) === 'complete') {\n resolve();\n }\n else {\n setTimeout(checkReadyState, 10);\n }\n };\n checkReadyState();\n })];\n case 5:\n _d.sent();\n _d.label = 6;\n case 6:\n if (!!((_b = (_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document) === null || _b === void 0 ? void 0 : _b.body)) return [3 /*break*/, 8];\n return [4 /*yield*/, wait(domPollInterval)];\n case 7:\n _d.sent();\n return [3 /*break*/, 6];\n case 8: return [4 /*yield*/, action(iframe, iframe.contentWindow)];\n case 9: return [2 /*return*/, _d.sent()];\n case 10:\n (_c = iframe.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(iframe);\n return [7 /*endfinally*/];\n case 11: return [2 /*return*/];\n }\n });\n });\n}\n/**\n * Creates a DOM element that matches the given selector.\n * Only single element selector are supported (without operators like space, +, >, etc).\n */\nfunction selectorToElement(selector) {\n var _a = parseSimpleCssSelector(selector), tag = _a[0], attributes = _a[1];\n var element = document.createElement(tag !== null && tag !== void 0 ? tag : 'div');\n for (var _i = 0, _b = Object.keys(attributes); _i < _b.length; _i++) {\n var name_1 = _b[_i];\n element.setAttribute(name_1, attributes[name_1].join(' '));\n }\n return element;\n}\n\n// We use m or w because these two characters take up the maximum width.\n// And we use a LLi so that the same matching fonts can get separated.\nvar testString = 'mmMwWLliI0O&1';\n// We test using 48px font size, we may use any size. I guess larger the better.\nvar textSize = '48px';\n// A font will be compared against all the three default fonts.\n// And if for any default fonts it doesn't match, then that font is available.\nvar baseFonts = ['monospace', 'sans-serif', 'serif'];\nvar fontList = [\n // This is android-specific font from \"Roboto\" family\n 'sans-serif-thin',\n 'ARNO PRO',\n 'Agency FB',\n 'Arabic Typesetting',\n 'Arial Unicode MS',\n 'AvantGarde Bk BT',\n 'BankGothic Md BT',\n 'Batang',\n 'Bitstream Vera Sans Mono',\n 'Calibri',\n 'Century',\n 'Century Gothic',\n 'Clarendon',\n 'EUROSTILE',\n 'Franklin Gothic',\n 'Futura Bk BT',\n 'Futura Md BT',\n 'GOTHAM',\n 'Gill Sans',\n 'HELV',\n 'Haettenschweiler',\n 'Helvetica Neue',\n 'Humanst521 BT',\n 'Leelawadee',\n 'Letter Gothic',\n 'Levenim MT',\n 'Lucida Bright',\n 'Lucida Sans',\n 'Menlo',\n 'MS Mincho',\n 'MS Outlook',\n 'MS Reference Specialty',\n 'MS UI Gothic',\n 'MT Extra',\n 'MYRIAD PRO',\n 'Marlett',\n 'Meiryo UI',\n 'Microsoft Uighur',\n 'Minion Pro',\n 'Monotype Corsiva',\n 'PMingLiU',\n 'Pristina',\n 'SCRIPTINA',\n 'Segoe UI Light',\n 'Serifa',\n 'SimHei',\n 'Small Fonts',\n 'Staccato222 BT',\n 'TRAJAN PRO',\n 'Univers CE 55 Medium',\n 'Vrinda',\n 'ZWAdobeF',\n];\n// kudos to http://www.lalit.org/lab/javascript-css-font-detect/\nfunction getFonts() {\n // Running the script in an iframe makes it not affect the page look and not be affected by the page CSS. See:\n // https://github.com/fingerprintjs/fingerprintjs/issues/592\n // https://github.com/fingerprintjs/fingerprintjs/issues/628\n return withIframe(function (_, _a) {\n var document = _a.document;\n var holder = document.body;\n holder.style.fontSize = textSize;\n // div to load spans for the default fonts and the fonts to detect\n var spansContainer = document.createElement('div');\n var defaultWidth = {};\n var defaultHeight = {};\n // creates a span where the fonts will be loaded\n var createSpan = function (fontFamily) {\n var span = document.createElement('span');\n var style = span.style;\n style.position = 'absolute';\n style.top = '0';\n style.left = '0';\n style.fontFamily = fontFamily;\n span.textContent = testString;\n spansContainer.appendChild(span);\n return span;\n };\n // creates a span and load the font to detect and a base font for fallback\n var createSpanWithFonts = function (fontToDetect, baseFont) {\n return createSpan(\"'\" + fontToDetect + \"',\" + baseFont);\n };\n // creates spans for the base fonts and adds them to baseFontsDiv\n var initializeBaseFontsSpans = function () {\n return baseFonts.map(createSpan);\n };\n // creates spans for the fonts to detect and adds them to fontsDiv\n var initializeFontsSpans = function () {\n // Stores {fontName : [spans for that font]}\n var spans = {};\n var _loop_1 = function (font) {\n spans[font] = baseFonts.map(function (baseFont) { return createSpanWithFonts(font, baseFont); });\n };\n for (var _i = 0, fontList_1 = fontList; _i < fontList_1.length; _i++) {\n var font = fontList_1[_i];\n _loop_1(font);\n }\n return spans;\n };\n // checks if a font is available\n var isFontAvailable = function (fontSpans) {\n return baseFonts.some(function (baseFont, baseFontIndex) {\n return fontSpans[baseFontIndex].offsetWidth !== defaultWidth[baseFont] ||\n fontSpans[baseFontIndex].offsetHeight !== defaultHeight[baseFont];\n });\n };\n // create spans for base fonts\n var baseFontsSpans = initializeBaseFontsSpans();\n // create spans for fonts to detect\n var fontsSpans = initializeFontsSpans();\n // add all the spans to the DOM\n holder.appendChild(spansContainer);\n // get the default width for the three base fonts\n for (var index = 0; index < baseFonts.length; index++) {\n defaultWidth[baseFonts[index]] = baseFontsSpans[index].offsetWidth; // width for the default font\n defaultHeight[baseFonts[index]] = baseFontsSpans[index].offsetHeight; // height for the default font\n }\n // check available fonts\n return fontList.filter(function (font) { return isFontAvailable(fontsSpans[font]); });\n });\n}\n\nfunction getPlugins() {\n var rawPlugins = navigator.plugins;\n if (!rawPlugins) {\n return undefined;\n }\n var plugins = [];\n // Safari 10 doesn't support iterating navigator.plugins with for...of\n for (var i = 0; i < rawPlugins.length; ++i) {\n var plugin = rawPlugins[i];\n if (!plugin) {\n continue;\n }\n var mimeTypes = [];\n for (var j = 0; j < plugin.length; ++j) {\n var mimeType = plugin[j];\n mimeTypes.push({\n type: mimeType.type,\n suffixes: mimeType.suffixes,\n });\n }\n plugins.push({\n name: plugin.name,\n description: plugin.description,\n mimeTypes: mimeTypes,\n });\n }\n return plugins;\n}\n\n// https://www.browserleaks.com/canvas#how-does-it-work\nfunction getCanvasFingerprint() {\n var _a = makeCanvasContext(), canvas = _a[0], context = _a[1];\n if (!isSupported(canvas, context)) {\n return { winding: false, geometry: '', text: '' };\n }\n return {\n winding: doesSupportWinding(context),\n geometry: makeGeometryImage(canvas, context),\n // Text is unstable:\n // https://github.com/fingerprintjs/fingerprintjs/issues/583\n // https://github.com/fingerprintjs/fingerprintjs/issues/103\n // Therefore it's extracted into a separate image.\n text: makeTextImage(canvas, context),\n };\n}\nfunction makeCanvasContext() {\n var canvas = document.createElement('canvas');\n canvas.width = 1;\n canvas.height = 1;\n return [canvas, canvas.getContext('2d')];\n}\nfunction isSupported(canvas, context) {\n // TODO: look into: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob\n return !!(context && canvas.toDataURL);\n}\nfunction doesSupportWinding(context) {\n // https://web.archive.org/web/20170825024655/http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/\n // https://github.com/Modernizr/Modernizr/blob/master/feature-detects/canvas/winding.js\n context.rect(0, 0, 10, 10);\n context.rect(2, 2, 6, 6);\n return !context.isPointInPath(5, 5, 'evenodd');\n}\nfunction makeTextImage(canvas, context) {\n // Resizing the canvas cleans it\n canvas.width = 240;\n canvas.height = 60;\n context.textBaseline = 'alphabetic';\n context.fillStyle = '#f60';\n context.fillRect(100, 1, 62, 20);\n context.fillStyle = '#069';\n // It's important to use explicit built-in fonts in order to exclude the affect of font preferences\n // (there is a separate entropy source for them).\n context.font = '11pt \"Times New Roman\"';\n // The choice of emojis has a gigantic impact on rendering performance (especially in FF).\n // Some newer emojis cause it to slow down 50-200 times.\n // There must be no text to the right of the emoji, see https://github.com/fingerprintjs/fingerprintjs/issues/574\n // A bare emoji shouldn't be used because the canvas will change depending on the script encoding:\n // https://github.com/fingerprintjs/fingerprintjs/issues/66\n // Escape sequence shouldn't be used too because Terser will turn it into a bare unicode.\n var printedText = \"Cwm fjordbank gly \" + String.fromCharCode(55357, 56835) /* 😃 */;\n context.fillText(printedText, 2, 15);\n context.fillStyle = 'rgba(102, 204, 0, 0.2)';\n context.font = '18pt Arial';\n context.fillText(printedText, 4, 45);\n return save(canvas);\n}\nfunction makeGeometryImage(canvas, context) {\n // Resizing the canvas cleans it\n canvas.width = 122;\n canvas.height = 110;\n // Canvas blending\n // https://web.archive.org/web/20170826194121/http://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/\n // http://jsfiddle.net/NDYV8/16/\n context.globalCompositeOperation = 'multiply';\n for (var _i = 0, _a = [\n ['#f2f', 40, 40],\n ['#2ff', 80, 40],\n ['#ff2', 60, 80],\n ]; _i < _a.length; _i++) {\n var _b = _a[_i], color = _b[0], x = _b[1], y = _b[2];\n context.fillStyle = color;\n context.beginPath();\n context.arc(x, y, 40, 0, Math.PI * 2, true);\n context.closePath();\n context.fill();\n }\n // Canvas winding\n // https://web.archive.org/web/20130913061632/http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/\n // http://jsfiddle.net/NDYV8/19/\n context.fillStyle = '#f9c';\n context.arc(60, 60, 60, 0, Math.PI * 2, true);\n context.arc(60, 60, 20, 0, Math.PI * 2, true);\n context.fill('evenodd');\n return save(canvas);\n}\nfunction save(canvas) {\n // TODO: look into: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob\n return canvas.toDataURL();\n}\n\n/**\n * This is a crude and primitive touch screen detection. It's not possible to currently reliably detect the availability\n * of a touch screen with a JS, without actually subscribing to a touch event.\n *\n * @see http://www.stucox.com/blog/you-cant-detect-a-touchscreen/\n * @see https://github.com/Modernizr/Modernizr/issues/548\n */\nfunction getTouchSupport() {\n var n = navigator;\n var maxTouchPoints = 0;\n var touchEvent;\n if (n.maxTouchPoints !== undefined) {\n maxTouchPoints = toInt(n.maxTouchPoints);\n }\n else if (n.msMaxTouchPoints !== undefined) {\n maxTouchPoints = n.msMaxTouchPoints;\n }\n try {\n document.createEvent('TouchEvent');\n touchEvent = true;\n }\n catch (_a) {\n touchEvent = false;\n }\n var touchStart = 'ontouchstart' in window;\n return {\n maxTouchPoints: maxTouchPoints,\n touchEvent: touchEvent,\n touchStart: touchStart,\n };\n}\n\nfunction getOsCpu() {\n return navigator.oscpu;\n}\n\nfunction getLanguages() {\n var n = navigator;\n var result = [];\n var language = n.language || n.userLanguage || n.browserLanguage || n.systemLanguage;\n if (language !== undefined) {\n result.push([language]);\n }\n if (Array.isArray(n.languages)) {\n // Starting from Chromium 86, there is only a single value in `navigator.language` in Incognito mode:\n // the value of `navigator.language`. Therefore the value is ignored in this browser.\n if (!(isChromium() && isChromium86OrNewer())) {\n result.push(n.languages);\n }\n }\n else if (typeof n.languages === 'string') {\n var languages = n.languages;\n if (languages) {\n result.push(languages.split(','));\n }\n }\n return result;\n}\n\nfunction getColorDepth() {\n return window.screen.colorDepth;\n}\n\nfunction getDeviceMemory() {\n // `navigator.deviceMemory` is a string containing a number in some unidentified cases\n return replaceNaN(toFloat(navigator.deviceMemory), undefined);\n}\n\nfunction getScreenResolution() {\n var s = screen;\n // Some browsers return screen resolution as strings, e.g. \"1200\", instead of a number, e.g. 1200.\n // I suspect it's done by certain plugins that randomize browser properties to prevent fingerprinting.\n // Some browsers even return screen resolution as not numbers.\n var parseDimension = function (value) { return replaceNaN(toInt(value), null); };\n var dimensions = [parseDimension(s.width), parseDimension(s.height)];\n dimensions.sort().reverse();\n return dimensions;\n}\n\nvar screenFrameCheckInterval = 2500;\nvar roundingPrecision = 10;\n// The type is readonly to protect from unwanted mutations\nvar screenFrameBackup;\nvar screenFrameSizeTimeoutId;\n/**\n * Starts watching the screen frame size. When a non-zero size appears, the size is saved and the watch is stopped.\n * Later, when `getScreenFrame` runs, it will return the saved non-zero size if the current size is null.\n *\n * This trick is required to mitigate the fact that the screen frame turns null in some cases.\n * See more on this at https://github.com/fingerprintjs/fingerprintjs/issues/568\n */\nfunction watchScreenFrame() {\n if (screenFrameSizeTimeoutId !== undefined) {\n return;\n }\n var checkScreenFrame = function () {\n var frameSize = getCurrentScreenFrame();\n if (isFrameSizeNull(frameSize)) {\n screenFrameSizeTimeoutId = setTimeout(checkScreenFrame, screenFrameCheckInterval);\n }\n else {\n screenFrameBackup = frameSize;\n screenFrameSizeTimeoutId = undefined;\n }\n };\n checkScreenFrame();\n}\nfunction getScreenFrame() {\n var _this = this;\n watchScreenFrame();\n return function () { return __awaiter(_this, void 0, void 0, function () {\n var frameSize;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n frameSize = getCurrentScreenFrame();\n if (!isFrameSizeNull(frameSize)) return [3 /*break*/, 2];\n if (screenFrameBackup) {\n return [2 /*return*/, __spreadArrays(screenFrameBackup)];\n }\n if (!getFullscreenElement()) return [3 /*break*/, 2];\n // Some browsers set the screen frame to zero when programmatic fullscreen is on.\n // There is a chance of getting a non-zero frame after exiting the fullscreen.\n // See more on this at https://github.com/fingerprintjs/fingerprintjs/issues/568\n return [4 /*yield*/, exitFullscreen()];\n case 1:\n // Some browsers set the screen frame to zero when programmatic fullscreen is on.\n // There is a chance of getting a non-zero frame after exiting the fullscreen.\n // See more on this at https://github.com/fingerprintjs/fingerprintjs/issues/568\n _a.sent();\n frameSize = getCurrentScreenFrame();\n _a.label = 2;\n case 2:\n if (!isFrameSizeNull(frameSize)) {\n screenFrameBackup = frameSize;\n }\n return [2 /*return*/, frameSize];\n }\n });\n }); };\n}\n/**\n * Sometimes the available screen resolution changes a bit, e.g. 1900x1440 → 1900x1439. A possible reason: macOS Dock\n * shrinks to fit more icons when there is too little space. The rounding is used to mitigate the difference.\n */\nfunction getRoundedScreenFrame() {\n var _this = this;\n var screenFrameGetter = getScreenFrame();\n return function () { return __awaiter(_this, void 0, void 0, function () {\n var frameSize, processSize;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, screenFrameGetter()];\n case 1:\n frameSize = _a.sent();\n processSize = function (sideSize) { return (sideSize === null ? null : round(sideSize, roundingPrecision)); };\n // It might look like I don't know about `for` and `map`.\n // In fact, such code is used to avoid TypeScript issues without using `as`.\n return [2 /*return*/, [processSize(frameSize[0]), processSize(frameSize[1]), processSize(frameSize[2]), processSize(frameSize[3])]];\n }\n });\n }); };\n}\nfunction getCurrentScreenFrame() {\n var s = screen;\n // Some browsers return screen resolution as strings, e.g. \"1200\", instead of a number, e.g. 1200.\n // I suspect it's done by certain plugins that randomize browser properties to prevent fingerprinting.\n //\n // Some browsers (IE, Edge ≤18) don't provide `screen.availLeft` and `screen.availTop`. The property values are\n // replaced with 0 in such cases to not lose the entropy from `screen.availWidth` and `screen.availHeight`.\n return [\n replaceNaN(toFloat(s.availTop), null),\n replaceNaN(toFloat(s.width) - toFloat(s.availWidth) - replaceNaN(toFloat(s.availLeft), 0), null),\n replaceNaN(toFloat(s.height) - toFloat(s.availHeight) - replaceNaN(toFloat(s.availTop), 0), null),\n replaceNaN(toFloat(s.availLeft), null),\n ];\n}\nfunction isFrameSizeNull(frameSize) {\n for (var i = 0; i < 4; ++i) {\n if (frameSize[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction getHardwareConcurrency() {\n // sometimes hardware concurrency is a string\n return replaceNaN(toInt(navigator.hardwareConcurrency), undefined);\n}\n\nfunction getTimezone() {\n var _a;\n var DateTimeFormat = (_a = window.Intl) === null || _a === void 0 ? void 0 : _a.DateTimeFormat;\n if (DateTimeFormat) {\n var timezone = new DateTimeFormat().resolvedOptions().timeZone;\n if (timezone) {\n return timezone;\n }\n }\n // For browsers that don't support timezone names\n // The minus is intentional because the JS offset is opposite to the real offset\n var offset = -getTimezoneOffset();\n return \"UTC\" + (offset >= 0 ? '+' : '') + Math.abs(offset);\n}\nfunction getTimezoneOffset() {\n var currentYear = new Date().getFullYear();\n // The timezone offset may change over time due to daylight saving time (DST) shifts.\n // The non-DST timezone offset is used as the result timezone offset.\n // Since the DST season differs in the northern and the southern hemispheres,\n // both January and July timezones offsets are considered.\n return Math.max(\n // `getTimezoneOffset` returns a number as a string in some unidentified cases\n toFloat(new Date(currentYear, 0, 1).getTimezoneOffset()), toFloat(new Date(currentYear, 6, 1).getTimezoneOffset()));\n}\n\nfunction getSessionStorage() {\n try {\n return !!window.sessionStorage;\n }\n catch (error) {\n /* SecurityError when referencing it means it exists */\n return true;\n }\n}\n\n// https://bugzilla.mozilla.org/show_bug.cgi?id=781447\nfunction getLocalStorage() {\n try {\n return !!window.localStorage;\n }\n catch (e) {\n /* SecurityError when referencing it means it exists */\n return true;\n }\n}\n\nfunction getIndexedDB() {\n // IE and Edge don't allow accessing indexedDB in private mode, therefore IE and Edge will have different\n // visitor identifier in normal and private modes.\n if (isTrident() || isEdgeHTML()) {\n return undefined;\n }\n try {\n return !!window.indexedDB;\n }\n catch (e) {\n /* SecurityError when referencing it means it exists */\n return true;\n }\n}\n\nfunction getOpenDatabase() {\n return !!window.openDatabase;\n}\n\nfunction getCpuClass() {\n return navigator.cpuClass;\n}\n\nfunction getPlatform() {\n // Android Chrome 86 and 87 and Android Firefox 80 and 84 don't mock the platform value when desktop mode is requested\n var platform = navigator.platform;\n // iOS mocks the platform value when desktop version is requested: https://github.com/fingerprintjs/fingerprintjs/issues/514\n // iPad uses desktop mode by default since iOS 13\n // The value is 'MacIntel' on M1 Macs\n // The value is 'iPhone' on iPod Touch\n if (platform === 'MacIntel') {\n if (isWebKit() && !isDesktopSafari()) {\n return isIPad() ? 'iPad' : 'iPhone';\n }\n }\n return platform;\n}\n\nfunction getVendor() {\n return navigator.vendor || '';\n}\n\n/**\n * Checks for browser-specific (not engine specific) global variables to tell browsers with the same engine apart.\n * Only somewhat popular browsers are considered.\n */\nfunction getVendorFlavors() {\n var flavors = [];\n for (var _i = 0, _a = [\n // Blink and some browsers on iOS\n 'chrome',\n // Safari on macOS\n 'safari',\n // Chrome on iOS (checked in 85 on 13 and 87 on 14)\n '__crWeb',\n '__gCrWeb',\n // Yandex Browser on iOS, macOS and Android (checked in 21.2 on iOS 14, macOS and Android)\n 'yandex',\n // Yandex Browser on iOS (checked in 21.2 on 14)\n '__yb',\n '__ybro',\n // Firefox on iOS (checked in 32 on 14)\n '__firefox__',\n // Edge on iOS (checked in 46 on 14)\n '__edgeTrackingPreventionStatistics',\n 'webkit',\n // Opera Touch on iOS (checked in 2.6 on 14)\n 'oprt',\n // Samsung Internet on Android (checked in 11.1)\n 'samsungAr',\n // UC Browser on Android (checked in 12.10 and 13.0)\n 'ucweb',\n 'UCShellJava',\n // Puffin on Android (checked in 9.0)\n 'puffinDevice',\n ]; _i < _a.length; _i++) {\n var key = _a[_i];\n var value = window[key];\n if (value && typeof value === 'object') {\n flavors.push(key);\n }\n }\n return flavors.sort();\n}\n\n/**\n * navigator.cookieEnabled cannot detect custom or nuanced cookie blocking configurations. For example, when blocking\n * cookies via the Advanced Privacy Settings in IE9, it always returns true. And there have been issues in the past with\n * site-specific exceptions. Don't rely on it.\n *\n * @see https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cookies.js Taken from here\n */\nfunction areCookiesEnabled() {\n var d = document;\n // Taken from here: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cookies.js\n // navigator.cookieEnabled cannot detect custom or nuanced cookie blocking configurations. For example, when blocking\n // cookies via the Advanced Privacy Settings in IE9, it always returns true. And there have been issues in the past\n // with site-specific exceptions. Don't rely on it.\n // try..catch because some in situations `document.cookie` is exposed but throws a\n // SecurityError if you try to access it; e.g. documents created from data URIs\n // or in sandboxed iframes (depending on flags/context)\n try {\n // Create cookie\n d.cookie = 'cookietest=1; SameSite=Strict;';\n var result = d.cookie.indexOf('cookietest=') !== -1;\n // Delete cookie\n d.cookie = 'cookietest=1; SameSite=Strict; expires=Thu, 01-Jan-1970 00:00:01 GMT';\n return result;\n }\n catch (e) {\n return false;\n }\n}\n\n/**\n * Only single element selector are supported (no operators like space, +, >, etc).\n * `embed` and `position: fixed;` will be considered as blocked anyway because it always has no offsetParent.\n * Avoid `iframe` and anything with `[src=]` because they produce excess HTTP requests.\n *\n * See docs/content_blockers.md to learn how to make the list\n */\nvar filters = {\n abpIndo: [\n '#Iklan-Melayang',\n '#Kolom-Iklan-728',\n '#SidebarIklan-wrapper',\n 'a[title=\"7naga poker\" i]',\n '[title=\"ALIENBOLA\" i]',\n ],\n abpvn: [\n '#quangcaomb',\n '.iosAdsiosAds-layout',\n '.quangcao',\n '[href^=\"https://r88.vn/\"]',\n '[href^=\"https://zbet.vn/\"]',\n ],\n adBlockFinland: [\n '.mainostila',\n '.sponsorit',\n '.ylamainos',\n 'a[href*=\"/clickthrgh.asp?\"]',\n 'a[href^=\"https://app.readpeak.com/ads\"]',\n ],\n adBlockPersian: [\n '#navbar_notice_50',\n 'a[href^=\"http://g1.v.fwmrm.net/ad/\"]',\n '.kadr',\n 'TABLE[width=\"140px\"]',\n '#divAgahi',\n ],\n adBlockWarningRemoval: ['#adblock-honeypot', '.adblocker-root', '.wp_adblock_detect'],\n adGuardAnnoyances: ['amp-embed[type=\"zen\"]', '.hs-sosyal', '#cookieconsentdiv', 'div[class^=\"app_gdpr\"]', '.as-oil'],\n adGuardBase: ['#ad-after', '#ad-p3', '.BetterJsPopOverlay', '#ad_300X250', '#bannerfloat22'],\n adGuardChinese: [\n '#piao_div_0[style*=\"width:140px;\"]',\n 'a[href*=\".ttz5.cn\"]',\n 'a[href*=\".yabovip2027.com/\"]',\n '.tm3all2h4b',\n '.cc5278_banner_ad',\n ],\n adGuardFrench: [\n '.zonepub',\n '[class*=\"_adLeaderboard\"]',\n '[id^=\"block-xiti_oas-\"]',\n 'a[href^=\"http://ptapjmp.com/\"]',\n 'a[href^=\"https://go.alvexo.com/\"]',\n ],\n adGuardGerman: [\n '.banneritemwerbung_head_1',\n '.boxstartwerbung',\n '.werbung3',\n 'a[href^=\"http://www.eis.de/index.phtml?refid=\"]',\n 'a[href^=\"https://www.tipico.com/?affiliateId=\"]',\n ],\n adGuardJapanese: [\n '#kauli_yad_1',\n '#ad-giftext',\n '#adsSPRBlock',\n 'a[href^=\"http://ad2.trafficgate.net/\"]',\n 'a[href^=\"http://www.rssad.jp/\"]',\n ],\n adGuardMobile: ['amp-auto-ads', '#mgid_iframe', '.amp_ad', 'amp-embed[type=\"24smi\"]', '#mgid_iframe1'],\n adGuardRussian: [\n 'a[href^=\"https://ya-distrib.ru/r/\"]',\n 'a[href^=\"https://ad.letmeads.com/\"]',\n '.reclama',\n 'div[id^=\"smi2adblock\"]',\n 'div[id^=\"AdFox_banner_\"]',\n ],\n adGuardSocial: [\n 'a[href^=\"//www.stumbleupon.com/submit?url=\"]',\n 'a[href^=\"//telegram.me/share/url?\"]',\n '.etsy-tweet',\n '#inlineShare',\n '.popup-social',\n ],\n adGuardSpanishPortuguese: [\n '#barraPublicidade',\n '#Publicidade',\n '#publiEspecial',\n '#queTooltip',\n '[href^=\"http://ads.glispa.com/\"]',\n ],\n adGuardTrackingProtection: [\n 'amp-embed[type=\"taboola\"]',\n '#qoo-counter',\n 'a[href^=\"http://click.hotlog.ru/\"]',\n 'a[href^=\"http://hitcounter.ru/top/stat.php\"]',\n 'a[href^=\"http://top.mail.ru/jump\"]',\n ],\n adGuardTurkish: [\n '#backkapat',\n '#reklami',\n 'a[href^=\"http://adserv.ontek.com.tr/\"]',\n 'a[href^=\"http://izlenzi.com/campaign/\"]',\n 'a[href^=\"http://www.installads.net/\"]',\n ],\n bulgarian: ['td#freenet_table_ads', '#adbody', '#ea_intext_div', '.lapni-pop-over', '#xenium_hot_offers'],\n easyList: ['#AD_banner_bottom', '#Ads_google_02', '#N-ad-article-rightRail-1', '#ad-fullbanner2', '#ad-zone-2'],\n easyListChina: [\n 'a[href*=\".wensixuetang.com/\"]',\n 'A[href*=\"/hth107.com/\"]',\n '.appguide-wrap[onclick*=\"bcebos.com\"]',\n '.frontpageAdvM',\n '#taotaole',\n ],\n easyListCookie: ['#adtoniq-msg-bar', '#CoockiesPage', '#CookieModal_cookiemodal', '#DO_CC_PANEL', '#ShowCookie'],\n easyListCzechSlovak: ['#onlajny-stickers', '#reklamni-box', '.reklama-megaboard', '.sklik', '[id^=\"sklikReklama\"]'],\n easyListDutch: [\n '#advertentie',\n '#vipAdmarktBannerBlock',\n '.adstekst',\n 'a[href^=\"https://xltube.nl/click/\"]',\n '#semilo-lrectangle',\n ],\n easyListGermany: [\n 'a[href^=\"http://www.hw-area.com/?dp=\"]',\n 'a[href^=\"https://ads.sunmaker.com/tracking.php?\"]',\n '.werbung-skyscraper2',\n '.bannergroup_werbung',\n '.ads_rechts',\n ],\n easyListItaly: [\n '.box_adv_annunci',\n '.sb-box-pubbliredazionale',\n 'a[href^=\"http://affiliazioniads.snai.it/\"]',\n 'a[href^=\"https://adserver.html.it/\"]',\n 'a[href^=\"https://affiliazioniads.snai.it/\"]',\n ],\n easyListLithuania: [\n '.reklamos_tarpas',\n '.reklamos_nuorodos',\n 'img[alt=\"Reklaminis skydelis\"]',\n 'img[alt=\"Dedikuoti.lt serveriai\"]',\n 'img[alt=\"Hostingas Serveriai.lt\"]',\n ],\n estonian: ['A[href*=\"http://pay4results24.eu\"]'],\n fanboyAnnoyances: [\n '#feedback-tab',\n '#taboola-below-article',\n '.feedburnerFeedBlock',\n '.widget-feedburner-counter',\n '[title=\"Subscribe to our blog\"]',\n ],\n fanboyAntiFacebook: ['.util-bar-module-firefly-visible'],\n fanboyEnhancedTrackers: [\n '.open.pushModal',\n '#issuem-leaky-paywall-articles-zero-remaining-nag',\n '#sovrn_container',\n 'div[class$=\"-hide\"][zoompage-fontsize][style=\"display: block;\"]',\n '.BlockNag__Card',\n ],\n fanboySocial: [\n '.td-tags-and-social-wrapper-box',\n '.twitterContainer',\n '.youtube-social',\n 'a[title^=\"Like us on Facebook\"]',\n 'img[alt^=\"Share on Digg\"]',\n ],\n frellwitSwedish: [\n 'a[href*=\"casinopro.se\"][target=\"_blank\"]',\n 'a[href*=\"doktor-se.onelink.me\"]',\n 'article.category-samarbete',\n 'div.holidAds',\n 'ul.adsmodern',\n ],\n greekAdBlock: [\n 'A[href*=\"adman.otenet.gr/click?\"]',\n 'A[href*=\"http://axiabanners.exodus.gr/\"]',\n 'A[href*=\"http://interactive.forthnet.gr/click?\"]',\n 'DIV.agores300',\n 'TABLE.advright',\n ],\n hungarian: [\n 'A[href*=\"ad.eval.hu\"]',\n 'A[href*=\"ad.netmedia.hu\"]',\n 'A[href*=\"daserver.ultraweb.hu\"]',\n '#cemp_doboz',\n '.optimonk-iframe-container',\n ],\n iDontCareAboutCookies: [\n '.alert-info[data-block-track*=\"CookieNotice\"]',\n '.ModuleTemplateCookieIndicator',\n '.o--cookies--container',\n '.cookie-msg-info-container',\n '#cookies-policy-sticky',\n ],\n icelandicAbp: ['A[href^=\"/framework/resources/forms/ads.aspx\"]'],\n latvian: [\n 'a[href=\"http://www.salidzini.lv/\"][style=\"display: block; width: 120px; height: 40px; overflow: hidden; position: relative;\"]',\n 'a[href=\"http://www.salidzini.lv/\"][style=\"display: block; width: 88px; height: 31px; overflow: hidden; position: relative;\"]',\n ],\n listKr: [\n 'a[href*=\"//kingtoon.slnk.kr\"]',\n 'a[href*=\"//playdsb.com/kr\"]',\n 'div.logly-lift-adz',\n 'div[data-widget_id=\"ml6EJ074\"]',\n 'ins.daum_ddn_area',\n ],\n listeAr: [\n '.geminiLB1Ad',\n '.right-and-left-sponsers',\n 'a[href*=\".aflam.info\"]',\n 'a[href*=\"booraq.org\"]',\n 'a[href*=\"dubizzle.com/ar/?utm_source=\"]',\n ],\n listeFr: [\n 'a[href^=\"http://promo.vador.com/\"]',\n '#adcontainer_recherche',\n 'a[href*=\"weborama.fr/fcgi-bin/\"]',\n '.site-pub-interstitiel',\n 'div[id^=\"crt-\"][data-criteo-id]',\n ],\n officialPolish: [\n '#ceneo-placeholder-ceneo-12',\n '[href^=\"https://aff.sendhub.pl/\"]',\n 'a[href^=\"http://advmanager.techfun.pl/redirect/\"]',\n 'a[href^=\"http://www.trizer.pl/?utm_source\"]',\n 'div#skapiec_ad',\n ],\n ro: [\n 'a[href^=\"//afftrk.altex.ro/Counter/Click\"]',\n 'a[href^=\"/magazin/\"]',\n 'a[href^=\"https://blackfridaysales.ro/trk/shop/\"]',\n 'a[href^=\"https://event.2performant.com/events/click\"]',\n 'a[href^=\"https://l.profitshare.ro/\"]',\n ],\n ruAd: [\n 'a[href*=\"//febrare.ru/\"]',\n 'a[href*=\"//utimg.ru/\"]',\n 'a[href*=\"://chikidiki.ru\"]',\n '#pgeldiz',\n '.yandex-rtb-block',\n ],\n thaiAds: ['a[href*=macau-uta-popup]', '#ads-google-middle_rectangle-group', '.ads300s', '.bumq', '.img-kosana'],\n webAnnoyancesUltralist: [\n '#mod-social-share-2',\n '#social-tools',\n '.ctpl-fullbanner',\n '.zergnet-recommend',\n '.yt.btn-link.btn-md.btn',\n ],\n};\n/**\n * The order of the returned array means nothing (it's always sorted alphabetically).\n *\n * Notice that the source is slightly unstable.\n * Safari provides a 2-taps way to disable all content blockers on a page temporarily.\n * Also content blockers can be disabled permanently for a domain, but it requires 4 taps.\n * So empty array shouldn't be treated as \"no blockers\", it should be treated as \"no signal\".\n * If you are a website owner, don't make your visitors want to disable content blockers.\n */\nfunction getDomBlockers(_a) {\n var debug = (_a === void 0 ? {} : _a).debug;\n return __awaiter(this, void 0, void 0, function () {\n var filterNames, allSelectors, blockedSelectors, activeBlockers;\n var _b;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n if (!isApplicable()) {\n return [2 /*return*/, undefined];\n }\n filterNames = Object.keys(filters);\n allSelectors = (_b = []).concat.apply(_b, filterNames.map(function (filterName) { return filters[filterName]; }));\n return [4 /*yield*/, getBlockedSelectors(allSelectors)];\n case 1:\n blockedSelectors = _c.sent();\n if (debug) {\n printDebug(blockedSelectors);\n }\n activeBlockers = filterNames.filter(function (filterName) {\n var selectors = filters[filterName];\n var blockedCount = countTruthy(selectors.map(function (selector) { return blockedSelectors[selector]; }));\n return blockedCount > selectors.length * 0.6;\n });\n activeBlockers.sort();\n return [2 /*return*/, activeBlockers];\n }\n });\n });\n}\nfunction isApplicable() {\n // Safari (desktop and mobile) and all Android browsers keep content blockers in both regular and private mode\n return isWebKit() || isAndroid();\n}\nfunction getBlockedSelectors(selectors) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var d, root, elements, blockedSelectors, i, element, holder, i;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n d = document;\n root = d.createElement('div');\n elements = new Array(selectors.length);\n blockedSelectors = {} // Set() isn't used just in case somebody need older browser support\n ;\n forceShow(root);\n // First create all elements that can be blocked. If the DOM steps below are done in a single cycle,\n // browser will alternate tree modification and layout reading, that is very slow.\n for (i = 0; i < selectors.length; ++i) {\n element = selectorToElement(selectors[i]);\n holder = d.createElement('div') // Protects from unwanted effects of `+` and `~` selectors of filters\n ;\n forceShow(holder);\n holder.appendChild(element);\n root.appendChild(holder);\n elements[i] = element;\n }\n _b.label = 1;\n case 1:\n if (!!d.body) return [3 /*break*/, 3];\n return [4 /*yield*/, wait(50)];\n case 2:\n _b.sent();\n return [3 /*break*/, 1];\n case 3:\n d.body.appendChild(root);\n try {\n // Then check which of the elements are blocked\n for (i = 0; i < selectors.length; ++i) {\n if (!elements[i].offsetParent) {\n blockedSelectors[selectors[i]] = true;\n }\n }\n }\n finally {\n // Then remove the elements\n (_a = root.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(root);\n }\n return [2 /*return*/, blockedSelectors];\n }\n });\n });\n}\nfunction forceShow(element) {\n element.style.setProperty('display', 'block', 'important');\n}\nfunction printDebug(blockedSelectors) {\n var message = 'DOM blockers debug:\\n```';\n for (var _i = 0, _a = Object.keys(filters); _i < _a.length; _i++) {\n var filterName = _a[_i];\n message += \"\\n\" + filterName + \":\";\n for (var _b = 0, _c = filters[filterName]; _b < _c.length; _b++) {\n var selector = _c[_b];\n message += \"\\n \" + selector + \" \" + (blockedSelectors[selector] ? '🚫' : '➡️');\n }\n }\n // console.log is ok here because it's under a debug clause\n // eslint-disable-next-line no-console\n console.log(message + \"\\n```\");\n}\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/color-gamut\n */\nfunction getColorGamut() {\n // rec2020 includes p3 and p3 includes srgb\n for (var _i = 0, _a = ['rec2020', 'p3', 'srgb']; _i < _a.length; _i++) {\n var gamut = _a[_i];\n if (matchMedia(\"(color-gamut: \" + gamut + \")\").matches) {\n return gamut;\n }\n }\n return undefined;\n}\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/inverted-colors\n */\nfunction areColorsInverted() {\n if (doesMatch('inverted')) {\n return true;\n }\n if (doesMatch('none')) {\n return false;\n }\n return undefined;\n}\nfunction doesMatch(value) {\n return matchMedia(\"(inverted-colors: \" + value + \")\").matches;\n}\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors\n */\nfunction areColorsForced() {\n if (doesMatch$1('active')) {\n return true;\n }\n if (doesMatch$1('none')) {\n return false;\n }\n return undefined;\n}\nfunction doesMatch$1(value) {\n return matchMedia(\"(forced-colors: \" + value + \")\").matches;\n}\n\nvar maxValueToCheck = 100;\n/**\n * If the display is monochrome (e.g. black&white), the value will be ≥0 and will mean the number of bits per pixel.\n * If the display is not monochrome, the returned value will be 0.\n * If the browser doesn't support this feature, the returned value will be undefined.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/monochrome\n */\nfunction getMonochromeDepth() {\n if (!matchMedia('(min-monochrome: 0)').matches) {\n // The media feature isn't supported by the browser\n return undefined;\n }\n // A variation of binary search algorithm can be used here.\n // But since expected values are very small (≤10), there is no sense in adding the complexity.\n for (var i = 0; i <= maxValueToCheck; ++i) {\n if (matchMedia(\"(max-monochrome: \" + i + \")\").matches) {\n return i;\n }\n }\n throw new Error('Too high value');\n}\n\n/**\n * @see https://www.w3.org/TR/mediaqueries-5/#prefers-contrast\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-contrast\n */\nfunction getContrastPreference() {\n if (doesMatch$2('no-preference')) {\n return 0 /* None */;\n }\n // The sources contradict on the keywords. Probably 'high' and 'low' will never be implemented.\n // Need to check it when all browsers implement the feature.\n if (doesMatch$2('high') || doesMatch$2('more')) {\n return 1 /* More */;\n }\n if (doesMatch$2('low') || doesMatch$2('less')) {\n return -1 /* Less */;\n }\n if (doesMatch$2('forced')) {\n return 10 /* ForcedColors */;\n }\n return undefined;\n}\nfunction doesMatch$2(value) {\n return matchMedia(\"(prefers-contrast: \" + value + \")\").matches;\n}\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion\n */\nfunction isMotionReduced() {\n if (doesMatch$3('reduce')) {\n return true;\n }\n if (doesMatch$3('no-preference')) {\n return false;\n }\n return undefined;\n}\nfunction doesMatch$3(value) {\n return matchMedia(\"(prefers-reduced-motion: \" + value + \")\").matches;\n}\n\n/**\n * @see https://www.w3.org/TR/mediaqueries-5/#dynamic-range\n */\nfunction isHDR() {\n if (doesMatch$4('high')) {\n return true;\n }\n if (doesMatch$4('standard')) {\n return false;\n }\n return undefined;\n}\nfunction doesMatch$4(value) {\n return matchMedia(\"(dynamic-range: \" + value + \")\").matches;\n}\n\nvar M = Math; // To reduce the minified code size\nvar fallbackFn = function () { return 0; };\n/**\n * @see https://gitlab.torproject.org/legacy/trac/-/issues/13018\n * @see https://bugzilla.mozilla.org/show_bug.cgi?id=531915\n */\nfunction getMathFingerprint() {\n // Native operations\n var acos = M.acos || fallbackFn;\n var acosh = M.acosh || fallbackFn;\n var asin = M.asin || fallbackFn;\n var asinh = M.asinh || fallbackFn;\n var atanh = M.atanh || fallbackFn;\n var atan = M.atan || fallbackFn;\n var sin = M.sin || fallbackFn;\n var sinh = M.sinh || fallbackFn;\n var cos = M.cos || fallbackFn;\n var cosh = M.cosh || fallbackFn;\n var tan = M.tan || fallbackFn;\n var tanh = M.tanh || fallbackFn;\n var exp = M.exp || fallbackFn;\n var expm1 = M.expm1 || fallbackFn;\n var log1p = M.log1p || fallbackFn;\n // Operation polyfills\n var powPI = function (value) { return M.pow(M.PI, value); };\n var acoshPf = function (value) { return M.log(value + M.sqrt(value * value - 1)); };\n var asinhPf = function (value) { return M.log(value + M.sqrt(value * value + 1)); };\n var atanhPf = function (value) { return M.log((1 + value) / (1 - value)) / 2; };\n var sinhPf = function (value) { return M.exp(value) - 1 / M.exp(value) / 2; };\n var coshPf = function (value) { return (M.exp(value) + 1 / M.exp(value)) / 2; };\n var expm1Pf = function (value) { return M.exp(value) - 1; };\n var tanhPf = function (value) { return (M.exp(2 * value) - 1) / (M.exp(2 * value) + 1); };\n var log1pPf = function (value) { return M.log(1 + value); };\n // Note: constant values are empirical\n return {\n acos: acos(0.123124234234234242),\n acosh: acosh(1e308),\n acoshPf: acoshPf(1e154),\n asin: asin(0.123124234234234242),\n asinh: asinh(1),\n asinhPf: asinhPf(1),\n atanh: atanh(0.5),\n atanhPf: atanhPf(0.5),\n atan: atan(0.5),\n sin: sin(-1e300),\n sinh: sinh(1),\n sinhPf: sinhPf(1),\n cos: cos(10.000000000123),\n cosh: cosh(1),\n coshPf: coshPf(1),\n tan: tan(-1e300),\n tanh: tanh(1),\n tanhPf: tanhPf(1),\n exp: exp(1),\n expm1: expm1(1),\n expm1Pf: expm1Pf(1),\n log1p: log1p(10),\n log1pPf: log1pPf(10),\n powPI: powPI(-100),\n };\n}\n\n/**\n * We use m or w because these two characters take up the maximum width.\n * Also there are a couple of ligatures.\n */\nvar defaultText = 'mmMwWLliI0fiflO&1';\n/**\n * Settings of text blocks to measure. The keys are random but persistent words.\n */\nvar presets = {\n /**\n * The default font. User can change it in desktop Chrome, desktop Firefox, IE 11,\n * Android Chrome (but only when the size is ≥ than the default) and Android Firefox.\n */\n default: [],\n /** OS font on macOS. User can change its size and weight. Applies after Safari restart. */\n apple: [{ font: '-apple-system-body' }],\n /** User can change it in desktop Chrome and desktop Firefox. */\n serif: [{ fontFamily: 'serif' }],\n /** User can change it in desktop Chrome and desktop Firefox. */\n sans: [{ fontFamily: 'sans-serif' }],\n /** User can change it in desktop Chrome and desktop Firefox. */\n mono: [{ fontFamily: 'monospace' }],\n /**\n * Check the smallest allowed font size. User can change it in desktop Chrome, desktop Firefox and desktop Safari.\n * The height can be 0 in Chrome on a retina display.\n */\n min: [{ fontSize: '1px' }],\n /** Tells one OS from another in desktop Chrome. */\n system: [{ fontFamily: 'system-ui' }],\n};\n/**\n * The result is a dictionary of the width of the text samples.\n * Heights aren't included because they give no extra entropy and are unstable.\n *\n * The result is very stable in IE 11, Edge 18 and Safari 14.\n * The result changes when the OS pixel density changes in Chromium 87. The real pixel density is required to solve,\n * but seems like it's impossible: https://stackoverflow.com/q/1713771/1118709.\n * The \"min\" and the \"mono\" (only on Windows) value may change when the page is zoomed in Firefox 87.\n */\nfunction getFontPreferences() {\n return withNaturalFonts(function (document, container) {\n var elements = {};\n var sizes = {};\n // First create all elements to measure. If the DOM steps below are done in a single cycle,\n // browser will alternate tree modification and layout reading, that is very slow.\n for (var _i = 0, _a = Object.keys(presets); _i < _a.length; _i++) {\n var key = _a[_i];\n var _b = presets[key], _c = _b[0], style = _c === void 0 ? {} : _c, _d = _b[1], text = _d === void 0 ? defaultText : _d;\n var element = document.createElement('span');\n element.textContent = text;\n element.style.whiteSpace = 'nowrap';\n for (var _e = 0, _f = Object.keys(style); _e < _f.length; _e++) {\n var name_1 = _f[_e];\n var value = style[name_1];\n if (value !== undefined) {\n element.style[name_1] = value;\n }\n }\n elements[key] = element;\n container.appendChild(document.createElement('br'));\n container.appendChild(element);\n }\n // Then measure the created elements\n for (var _g = 0, _h = Object.keys(presets); _g < _h.length; _g++) {\n var key = _h[_g];\n sizes[key] = elements[key].getBoundingClientRect().width;\n }\n return sizes;\n });\n}\n/**\n * Creates a DOM environment that provides the most natural font available, including Android OS font.\n * Measurements of the elements are zoom-independent.\n * Don't put a content to measure inside an absolutely positioned element.\n */\nfunction withNaturalFonts(action, containerWidthPx) {\n if (containerWidthPx === void 0) { containerWidthPx = 4000; }\n /*\n * Requirements for Android Chrome to apply the system font size to a text inside an iframe:\n * - The iframe mustn't have a `display: none;` style;\n * - The text mustn't be positioned absolutely;\n * - The text block must be wide enough.\n * 2560px on some devices in portrait orientation for the biggest font size option (32px);\n * - There must be much enough text to form a few lines (I don't know the exact numbers);\n * - The text must have the `text-size-adjust: none` style. Otherwise the text will scale in \"Desktop site\" mode;\n *\n * Requirements for Android Firefox to apply the system font size to a text inside an iframe:\n * - The iframe document must have a header: ``.\n * The only way to set it is to use the `srcdoc` attribute of the iframe;\n * - The iframe content must get loaded before adding extra content with JavaScript;\n *\n * https://example.com as the iframe target always inherits Android font settings so it can be used as a reference.\n *\n * Observations on how page zoom affects the measurements:\n * - macOS Safari 11.1, 12.1, 13.1, 14.0: zoom reset + offsetWidth = 100% reliable;\n * - macOS Safari 11.1, 12.1, 13.1, 14.0: zoom reset + getBoundingClientRect = 100% reliable;\n * - macOS Safari 14.0: offsetWidth = 5% fluctuation;\n * - macOS Safari 14.0: getBoundingClientRect = 5% fluctuation;\n * - iOS Safari 9, 10, 11.0, 12.0: haven't found a way to zoom a page (pinch doesn't change layout);\n * - iOS Safari 13.1, 14.0: zoom reset + offsetWidth = 100% reliable;\n * - iOS Safari 13.1, 14.0: zoom reset + getBoundingClientRect = 100% reliable;\n * - iOS Safari 14.0: offsetWidth = 100% reliable;\n * - iOS Safari 14.0: getBoundingClientRect = 100% reliable;\n * - Chrome 42, 65, 80, 87: zoom 1/devicePixelRatio + offsetWidth = 1px fluctuation;\n * - Chrome 42, 65, 80, 87: zoom 1/devicePixelRatio + getBoundingClientRect = 100% reliable;\n * - Chrome 87: offsetWidth = 1px fluctuation;\n * - Chrome 87: getBoundingClientRect = 0.7px fluctuation;\n * - Firefox 48, 51: offsetWidth = 10% fluctuation;\n * - Firefox 48, 51: getBoundingClientRect = 10% fluctuation;\n * - Firefox 52, 53, 57, 62, 66, 67, 68, 71, 75, 80, 84: offsetWidth = width 100% reliable, height 10% fluctuation;\n * - Firefox 52, 53, 57, 62, 66, 67, 68, 71, 75, 80, 84: getBoundingClientRect = width 100% reliable, height 10%\n * fluctuation;\n * - Android Chrome 86: haven't found a way to zoom a page (pinch doesn't change layout);\n * - Android Firefox 84: font size in accessibility settings changes all the CSS sizes, but offsetWidth and\n * getBoundingClientRect keep measuring with regular units, so the size reflects the font size setting and doesn't\n * fluctuate;\n * - IE 11, Edge 18: zoom 1/devicePixelRatio + offsetWidth = 100% reliable;\n * - IE 11, Edge 18: zoom 1/devicePixelRatio + getBoundingClientRect = reflects the zoom level;\n * - IE 11, Edge 18: offsetWidth = 100% reliable;\n * - IE 11, Edge 18: getBoundingClientRect = 100% reliable;\n */\n return withIframe(function (_, iframeWindow) {\n var iframeDocument = iframeWindow.document;\n var iframeBody = iframeDocument.body;\n var bodyStyle = iframeBody.style;\n bodyStyle.width = containerWidthPx + \"px\";\n bodyStyle.webkitTextSizeAdjust = bodyStyle.textSizeAdjust = 'none';\n // See the big comment above\n if (isChromium()) {\n iframeBody.style.zoom = \"\" + 1 / iframeWindow.devicePixelRatio;\n }\n else if (isWebKit()) {\n iframeBody.style.zoom = 'reset';\n }\n // See the big comment above\n var linesOfText = iframeDocument.createElement('div');\n linesOfText.textContent = __spreadArrays(Array((containerWidthPx / 20) << 0)).map(function () { return 'word'; }).join(' ');\n iframeBody.appendChild(linesOfText);\n return action(iframeDocument, iframeBody);\n }, '');\n}\n\n/**\n * The list of entropy sources used to make visitor identifiers.\n *\n * This value isn't restricted by Semantic Versioning, i.e. it may be changed without bumping minor or major version of\n * this package.\n */\nvar sources = {\n // READ FIRST:\n // See https://github.com/fingerprintjs/fingerprintjs/blob/master/contributing.md#how-to-make-an-entropy-source\n // to learn how entropy source works and how to make your own.\n // The sources run in this exact order.\n // The asynchronous sources are at the start to run in parallel with other sources.\n fonts: getFonts,\n domBlockers: getDomBlockers,\n fontPreferences: getFontPreferences,\n audio: getAudioFingerprint,\n screenFrame: getRoundedScreenFrame,\n osCpu: getOsCpu,\n languages: getLanguages,\n colorDepth: getColorDepth,\n deviceMemory: getDeviceMemory,\n screenResolution: getScreenResolution,\n hardwareConcurrency: getHardwareConcurrency,\n timezone: getTimezone,\n sessionStorage: getSessionStorage,\n localStorage: getLocalStorage,\n indexedDB: getIndexedDB,\n openDatabase: getOpenDatabase,\n cpuClass: getCpuClass,\n platform: getPlatform,\n plugins: getPlugins,\n canvas: getCanvasFingerprint,\n touchSupport: getTouchSupport,\n vendor: getVendor,\n vendorFlavors: getVendorFlavors,\n cookiesEnabled: areCookiesEnabled,\n colorGamut: getColorGamut,\n invertedColors: areColorsInverted,\n forcedColors: areColorsForced,\n monochrome: getMonochromeDepth,\n contrast: getContrastPreference,\n reducedMotion: isMotionReduced,\n hdr: isHDR,\n math: getMathFingerprint,\n};\n/**\n * Loads the built-in entropy sources.\n * Returns a function that collects the entropy components to make the visitor identifier.\n */\nfunction loadBuiltinSources(options) {\n return loadSources(sources, options, []);\n}\n\nvar commentTemplate = '$ if upgrade to Pro: https://fpjs.dev/pro';\nfunction getConfidence(components) {\n var openConfidenceScore = getOpenConfidenceScore(components);\n var proConfidenceScore = deriveProConfidenceScore(openConfidenceScore);\n return { score: openConfidenceScore, comment: commentTemplate.replace(/\\$/g, \"\" + proConfidenceScore) };\n}\nfunction getOpenConfidenceScore(components) {\n // In order to calculate the true probability of the visitor identifier being correct, we need to know the number of\n // website visitors (the higher the number, the less the probability because the fingerprint entropy is limited).\n // JS agent doesn't know the number of visitors, so we can only do an approximate assessment.\n if (isAndroid()) {\n return 0.4;\n }\n // Safari (mobile and desktop)\n if (isWebKit()) {\n return isDesktopSafari() ? 0.5 : 0.3;\n }\n var platform = components.platform.value || '';\n // Windows\n if (/^Win/.test(platform)) {\n // The score is greater than on macOS because of the higher variety of devices running Windows.\n // Chrome provides more entropy than Firefox according too\n // https://netmarketshare.com/browser-market-share.aspx?options=%7B%22filter%22%3A%7B%22%24and%22%3A%5B%7B%22platform%22%3A%7B%22%24in%22%3A%5B%22Windows%22%5D%7D%7D%5D%7D%2C%22dateLabel%22%3A%22Trend%22%2C%22attributes%22%3A%22share%22%2C%22group%22%3A%22browser%22%2C%22sort%22%3A%7B%22share%22%3A-1%7D%2C%22id%22%3A%22browsersDesktop%22%2C%22dateInterval%22%3A%22Monthly%22%2C%22dateStart%22%3A%222019-11%22%2C%22dateEnd%22%3A%222020-10%22%2C%22segments%22%3A%22-1000%22%7D\n // So we assign the same score to them.\n return 0.6;\n }\n // macOS\n if (/^Mac/.test(platform)) {\n // Chrome provides more entropy than Safari and Safari provides more entropy than Firefox.\n // Chrome is more popular than Safari and Safari is more popular than Firefox according to\n // https://netmarketshare.com/browser-market-share.aspx?options=%7B%22filter%22%3A%7B%22%24and%22%3A%5B%7B%22platform%22%3A%7B%22%24in%22%3A%5B%22Mac%20OS%22%5D%7D%7D%5D%7D%2C%22dateLabel%22%3A%22Trend%22%2C%22attributes%22%3A%22share%22%2C%22group%22%3A%22browser%22%2C%22sort%22%3A%7B%22share%22%3A-1%7D%2C%22id%22%3A%22browsersDesktop%22%2C%22dateInterval%22%3A%22Monthly%22%2C%22dateStart%22%3A%222019-11%22%2C%22dateEnd%22%3A%222020-10%22%2C%22segments%22%3A%22-1000%22%7D\n // So we assign the same score to them.\n return 0.5;\n }\n // Another platform, e.g. a desktop Linux. It's rare, so it should be pretty unique.\n return 0.7;\n}\nfunction deriveProConfidenceScore(openConfidenceScore) {\n return round(0.99 + 0.01 * openConfidenceScore, 0.0001);\n}\n\nfunction componentsToCanonicalString(components) {\n var result = '';\n for (var _i = 0, _a = Object.keys(components).sort(); _i < _a.length; _i++) {\n var componentKey = _a[_i];\n var component = components[componentKey];\n var value = component.error ? 'error' : JSON.stringify(component.value);\n result += \"\" + (result ? '|' : '') + componentKey.replace(/([:|\\\\])/g, '\\\\$1') + \":\" + value;\n }\n return result;\n}\nfunction componentsToDebugString(components) {\n return JSON.stringify(components, function (_key, value) {\n if (value instanceof Error) {\n return errorToObject(value);\n }\n return value;\n }, 2);\n}\nfunction hashComponents(components) {\n return x64hash128(componentsToCanonicalString(components));\n}\n/**\n * Makes a GetResult implementation that calculates the visitor id hash on demand.\n * Designed for optimisation.\n */\nfunction makeLazyGetResult(components) {\n var visitorIdCache;\n // This function runs very fast, so there is no need to make it lazy\n var confidence = getConfidence(components);\n // A plain class isn't used because its getters and setters aren't enumerable.\n return {\n get visitorId() {\n if (visitorIdCache === undefined) {\n visitorIdCache = hashComponents(this.components);\n }\n return visitorIdCache;\n },\n set visitorId(visitorId) {\n visitorIdCache = visitorId;\n },\n confidence: confidence,\n components: components,\n version: version,\n };\n}\n/**\n * A delay is required to ensure consistent entropy components.\n * See https://github.com/fingerprintjs/fingerprintjs/issues/254\n * and https://github.com/fingerprintjs/fingerprintjs/issues/307\n * and https://github.com/fingerprintjs/fingerprintjs/commit/945633e7c5f67ae38eb0fea37349712f0e669b18\n */\nfunction prepareForSources(delayFallback) {\n if (delayFallback === void 0) { delayFallback = 50; }\n // A proper deadline is unknown. Let it be twice the fallback timeout so that both cases have the same average time.\n return requestIdleCallbackIfAvailable(delayFallback, delayFallback * 2);\n}\n/**\n * The function isn't exported from the index file to not allow to call it without `load()`.\n * The hiding gives more freedom for future non-breaking updates.\n *\n * A factory function is used instead of a class to shorten the attribute names in the minified code.\n * Native private class fields could've been used, but TypeScript doesn't allow them with `\"target\": \"es5\"`.\n */\nfunction makeAgent(getComponents, debug) {\n var creationTime = Date.now();\n return {\n get: function (options) {\n return __awaiter(this, void 0, void 0, function () {\n var startTime, components, result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n startTime = Date.now();\n return [4 /*yield*/, getComponents()];\n case 1:\n components = _a.sent();\n result = makeLazyGetResult(components);\n if (debug || (options === null || options === void 0 ? void 0 : options.debug)) {\n // console.log is ok here because it's under a debug clause\n // eslint-disable-next-line no-console\n console.log(\"Copy the text below to get the debug data:\\n\\n```\\nversion: \" + result.version + \"\\nuserAgent: \" + navigator.userAgent + \"\\ntimeBetweenLoadAndGet: \" + (startTime - creationTime) + \"\\nvisitorId: \" + result.visitorId + \"\\ncomponents: \" + componentsToDebugString(components) + \"\\n```\");\n }\n return [2 /*return*/, result];\n }\n });\n });\n },\n };\n}\n/**\n * Sends an unpersonalized AJAX request to collect installation statistics\n */\nfunction monitor() {\n // The FingerprintJS CDN (https://github.com/fingerprintjs/cdn) replaces `window.__fpjs_d_m` with `true`\n if (window.__fpjs_d_m || Math.random() >= 0.01) {\n return;\n }\n try {\n var request = new XMLHttpRequest();\n request.open('get', \"https://openfpcdn.io/fingerprintjs/v\" + version + \"/npm-monitoring\", true);\n request.send();\n }\n catch (error) {\n // console.error is ok here because it's an unexpected error handler\n // eslint-disable-next-line no-console\n console.error(error);\n }\n}\n/**\n * Builds an instance of Agent and waits a delay required for a proper operation.\n */\nfunction load(_a) {\n var _b = _a === void 0 ? {} : _a, delayFallback = _b.delayFallback, debug = _b.debug, _c = _b.monitoring, monitoring = _c === void 0 ? true : _c;\n return __awaiter(this, void 0, void 0, function () {\n var getComponents;\n return __generator(this, function (_d) {\n switch (_d.label) {\n case 0:\n if (monitoring) {\n monitor();\n }\n return [4 /*yield*/, prepareForSources(delayFallback)];\n case 1:\n _d.sent();\n getComponents = loadBuiltinSources({ debug: debug });\n return [2 /*return*/, makeAgent(getComponents, debug)];\n }\n });\n });\n}\n\n// The default export is a syntax sugar (`import * as FP from '...' → import FP from '...'`).\n// It should contain all the public exported values.\nvar index = { load: load, hashComponents: hashComponents, componentsToDebugString: componentsToDebugString };\n// The exports below are for private usage. They may change unexpectedly. Use them at your own risk.\n/** Not documented, out of Semantic Versioning, usage is at your own risk */\nvar murmurX64Hash128 = x64hash128;\n\nexport default index;\nexport { componentsToDebugString, getFullscreenElement, getScreenFrame, hashComponents, isAndroid, isChromium, isDesktopSafari, isEdgeHTML, isGecko, isTrident, isWebKit, load, loadSources, murmurX64Hash128, prepareForSources, sources };\n","const sdk = require('@/matrix-js-sdk');\r\n\r\nimport MTRXKIT from \"./mtrxkit\";\r\nimport f from \"./functions\";\r\nimport images from \"./utils/images\";\r\nimport FingerprintJS from '@fingerprintjs/fingerprintjs';\r\n\r\nimport qs from 'qs';\r\nimport fileSaver from 'file-saver';\r\nimport ChatStorage from \"./chatstorage\";\r\n\r\nvar axios = require('axios');\r\n\r\n\r\nclass MTRX {\r\n\r\n constructor(core, p) {\r\n if (!p) p = {}\r\n\r\n this.core = core\r\n this.baseUrl = p.baseUrl\r\n this.ready = false\r\n this.error = false\r\n this.kit = new MTRXKIT(this.core, p)\r\n this.sdk = sdk\r\n this.sync = ''\r\n this.nd = false\r\n this.version = 4\r\n this.dversion = '2'\r\n this.backup = {}\r\n this.db = null\r\n\r\n this.customrequest = true\r\n\r\n this.devicekey = 'm8_device'\r\n }\r\n\r\n\r\n async setCredentials() {\r\n return this.core.user.matrixCredentials().then(credentials => {\r\n this.credentials = credentials\r\n return Promise.resolve(credentials)\r\n })\r\n\r\n }\r\n\r\n getDevices() {\r\n var devices = localStorage[this.devicekey] || ''\r\n\r\n if (devices) {\r\n try {\r\n var d = JSON.parse(devices)\r\n\r\n return d\r\n } catch (e) {\r\n }\r\n }\r\n\r\n return {}\r\n }\r\n\r\n setDevice(device, userkey) {\r\n\r\n var devices = this.getDevices()\r\n\r\n devices[userkey] = device\r\n\r\n localStorage[this.devicekey] = JSON.stringify(devices)\r\n localStorage.device_ = JSON.stringify(device)\r\n\r\n }\r\n\r\n getDevice(userkey) {\r\n // return localStorage.m8_device;\r\n // var devices = this.getDevices()\r\n // return devices[userkey] || null\r\n }\r\n\r\n request(opts, clbk) {\r\n\r\n var response = null;\r\n\r\n var error = null\r\n\r\n const cancelTokenSource = axios.CancelToken.source();\r\n\r\n var aopts = {\r\n url: opts.uri,\r\n params: opts.qs,\r\n data: JSON.parse(opts.body || \"{}\"),\r\n timeout: opts.timeout,\r\n headers: opts.headers,\r\n json: opts.json,\r\n method: opts.method,\r\n withCredentials: opts.withCredentials,\r\n _matrix_opts: opts,\r\n cancelToken: cancelTokenSource.token,\r\n\r\n paramsSerializer: function (params) {\r\n return qs.stringify(params, opts.qsStringifyOptions)\r\n },\r\n }\r\n\r\n var req = axios(aopts).then(response => {\r\n\r\n\r\n return Promise.resolve(response)\r\n }).catch(e => {\r\n\r\n error = e\r\n response = e.response\r\n\r\n return Promise.resolve(response)\r\n\r\n }).then(response => {\r\n\r\n var parsederror = error\r\n\r\n if (error) {\r\n\r\n try {\r\n parsederror = JSON.parse(f.deep(response, 'request.responseText'))\r\n\r\n error = new sdk.MatrixError(parsederror)\r\n\r\n } catch (e) {\r\n }\r\n\r\n //error.error = parsederror\r\n\r\n }\r\n\r\n clbk(error, response, f.deep(response, 'request.responseText') || '')\r\n\r\n /*if (error)\r\n return Promise.reject(parsederror)*/\r\n })\r\n\r\n req.abort = function () {\r\n cancelTokenSource.cancel();\r\n }\r\n\r\n return req\r\n\r\n /*\r\n uri\tstring\tThe complete URI.\r\n method\tstring\tThe HTTP method.\r\n qs\tObject\tThe query parameters to append to the URI.\r\n body\tObject\tThe JSON-serializable object.\r\n json\tboolean\tTrue if this is a JSON request.\r\n _matrix_opts\r\n */\r\n\r\n\r\n }\r\n\r\n async getFingerprint() {\r\n var fp = await FingerprintJS.load()\r\n var result = await fp.get()\r\n return result.visitorId + this.dversion\r\n }\r\n\r\n createMtrxClient(opts) {\r\n\r\n var client = sdk.createClient(opts);\r\n\r\n client.getProfileInfo = function () {\r\n return Promise.resolve({\r\n avatar_url: '',\r\n displayname: 'test'\r\n })\r\n }\r\n\r\n return client\r\n }\r\n\r\n async getClient() {\r\n\r\n await this.setCredentials();\r\n\r\n var userClientData = {\r\n baseUrl: this.baseUrl\r\n }\r\n\r\n var opts = {\r\n baseUrl: this.baseUrl\r\n }\r\n\r\n if (this.customrequest)\r\n opts.request = this.request\r\n\r\n var client = this.createMtrxClient(opts);\r\n\r\n\r\n try {\r\n var userData = await client.login('m.login.password', {\r\n user: this.credentials.username,\r\n password: this.credentials.password,\r\n })\r\n\r\n } catch (e) {\r\n\r\n if(e && e.indexOf && e.indexOf('M_USER_DEACTIVATED') > -1){\r\n this.error = 'M_USER_DEACTIVATED'\r\n return null\r\n }\r\n\r\n if (await client.isUsernameAvailable(this.credentials.username)) {\r\n\r\n userData = await client.register(\r\n this.credentials.username,\r\n this.credentials.password,\r\n null,\r\n {\r\n type: 'm.login.dummy',\r\n //signature : this.core.user.signature('matrix')\r\n }\r\n )\r\n\r\n } else {\r\n throw 'Signup error, username is not available: ' + e\r\n }\r\n }\r\n\r\n localStorage.accessToken = userData.access_token\r\n var store = new sdk.IndexedDBStore({\r\n indexedDB: window.indexedDB,\r\n dbName: 'matrix-js-sdk:' + this.credentials.username\r\n })\r\n await store.startup()\r\n\r\n Object.assign(userClientData, {\r\n userId: userData.user_id,\r\n accessToken: userData.access_token,\r\n unstableClientRelationAggregation: true,\r\n timelineSupport: true,\r\n store: store,\r\n\r\n // deviceId: userData.device_id,\r\n })\r\n\r\n if (this.customrequest)\r\n userClientData.request = this.request\r\n\r\n\r\n var userClient = this.createMtrxClient(userClientData)\r\n window.client = userClient\r\n window.core = this.core\r\n\r\n await userClient.startClient({\r\n pollTimeout: 60000,\r\n resolveInvitesToProfiles: true\r\n });\r\n\r\n\r\n this.access = userClientData\r\n\r\n this.client = userClient\r\n\r\n return userClient;\r\n }\r\n\r\n clearstorage(key) {\r\n var keys = Object.keys(localStorage), i = keys.length;\r\n\r\n while (i--) {\r\n if (keys[i] && keys[i].indexOf(key) == 0) {\r\n localStorage.removeItem(keys[i]);\r\n }\r\n }\r\n }\r\n\r\n clearstore() {\r\n\r\n var version = Number(localStorage.matrixversion || '0')\r\n\r\n if (version < this.version) {\r\n\r\n this.clearstorage('crypto.')\r\n this.clearstorage('session.')\r\n\r\n var keys = ['', '2', '3', '4', '5', '6', '8']\r\n\r\n _.each(keys, function (key) {\r\n delete localStorage['m' + key + '_device']\r\n })\r\n\r\n }\r\n\r\n localStorage.matrixversion = this.version\r\n }\r\n\r\n async createClient() {\r\n try {\r\n this.client = await this.getClient()\r\n this.store = this.client.store\r\n this.ready = true\r\n\r\n } catch (e) {\r\n this.error = e\r\n }\r\n\r\n\r\n return true\r\n }\r\n\r\n wait() {\r\n return f.pretry(() => {\r\n return this.ready\r\n }).then(() => {\r\n\r\n\r\n if (this.error) {\r\n return Promise.reject(this.error)\r\n }\r\n\r\n return Promise.resolve()\r\n\r\n })\r\n }\r\n\r\n waitchats() {\r\n\r\n return f.pretry(() => {\r\n\r\n return this.chatsready\r\n\r\n }).then(() => {\r\n\r\n if (this.error) {\r\n return Promise.reject(this.error)\r\n }\r\n\r\n return Promise.resolve()\r\n\r\n })\r\n }\r\n\r\n me(id) {\r\n return f.getmatrixid(id) == this.core.user.userinfo?.id\r\n }\r\n\r\n reciepts(event) {\r\n var room = null;\r\n\r\n return f.pretry(() => {\r\n\r\n var rooms = this.core.mtrx.store.rooms\r\n\r\n room = rooms[event.getRoomId()]\r\n\r\n return room\r\n\r\n }).then(() => {\r\n\r\n return room.getReceiptsForEvent(event)\r\n\r\n })\r\n }\r\n\r\n storeFileLocal(url, file){\r\n\r\n return file.arrayBuffer().then((arrayBuffer) => {\r\n const blob = new Blob([new Uint8Array(arrayBuffer)], {type: file.type });\r\n\r\n if (window.POCKETNETINSTANCE && window.POCKETNETINSTANCE.storage && window.cordova){\r\n return window.POCKETNETINSTANCE.storage.saveFile(url, blob);\r\n }\r\n \r\n else{\r\n if(this.db){\r\n return this.db.set(url, blob)\r\n }\r\n }\r\n \r\n });\r\n \r\n \r\n }\r\n\r\n download(url) {\r\n\r\n // Function to download the file\r\n var dlFile = () => {\r\n return f.fetchLocal(url).then(response => {\r\n // Update the storage before returning\r\n if (window.POCKETNETINSTANCE && window.POCKETNETINSTANCE.storage && window.cordova){\r\n window.POCKETNETINSTANCE.storage.saveFile(url, response.data);\r\n }\r\n \r\n else{\r\n if(this.db){\r\n this.db.set(url, response.data)\r\n }\r\n }\r\n\r\n return Promise.resolve(response.data);\r\n })\r\n }\r\n\r\n\r\n // Check if file is saved in the storage\r\n if (window.POCKETNETINSTANCE && window.POCKETNETINSTANCE.storage && window.cordova) {\r\n return window.POCKETNETINSTANCE.storage.loadFile(url).then((file) => {\r\n return Promise.resolve(file);\r\n }, (e) => {\r\n\r\n // Nothing in storage, download file\r\n return dlFile();\r\n });\r\n } else {\r\n\r\n if(this.db){\r\n\r\n return this.db.get(url).then((file) => {\r\n\r\n return Promise.resolve(file);\r\n\r\n }).catch(() => {\r\n return dlFile();\r\n })\r\n \r\n }\r\n\r\n return dlFile();\r\n\r\n }\r\n \r\n \r\n }\r\n\r\n customRoomType(roomId) {\r\n var room = this.core.mtrx.client.getRoom(roomId)\r\n\r\n if (!room) return null\r\n\r\n var ev = room.currentState.getStateEvents(\"m.room.custom\", \"\") || {};\r\n\r\n return ev.event?.content.type\r\n\r\n }\r\n\r\n isReaded(event, me) {\r\n\r\n return this.reciepts(event).then(reciepts => {\r\n return Promise.resolve(\r\n _.find(reciepts, reciept => {\r\n var m = this.me(reciept.userId)\r\n\r\n\r\n return reciept.type == 'm.read' && ((me && m) || (!m && !me))\r\n })\r\n )\r\n })\r\n\r\n\r\n }\r\n\r\n initEvents() {\r\n\r\n let self = this\r\n\r\n let userId = this.core.mtrx.client.credentials.userId\r\n\r\n this.client.on(\"RoomMember.membership\", (event, member) => {\r\n\r\n\r\n if (!this.chatsready) return\r\n\r\n\r\n if ((member.membership === \"invite\" || member.membership === \"join\") && event.getSender() !== userId) {\r\n this.core.notifier.event(event)\r\n }\r\n\r\n });\r\n\r\n this.client.on(\"Room.timeline\", (message, member) => {\r\n\r\n if (!this.chatsready) return\r\n\r\n if (!message.event.content) return\r\n\r\n if (message.event.content.msgtype === 'm.file') {\r\n message.event.content.pbody = JSON.parse(message.event.content.body)\r\n }\r\n\r\n\r\n if (message.getSender() !== userId) {\r\n\r\n var m_chat = this.core.mtrx.client.getRoom(message.event.room_id)\r\n\r\n if (message.event.content['m.relates_to'] && message.event.content['m.relates_to'][\"rel_type\"] == 'm.replace') return false\r\n\r\n if (m_chat && this.core.pcrypto.rooms[message.event.room_id]) this.core.notifier.event(message, m_chat)\r\n\r\n }\r\n\r\n\r\n });\r\n\r\n this.client.on(\"RoomMember.typing\", (event, member) => {\r\n this.core.store.dispatch('TYPING_EVENT', member)\r\n });\r\n\r\n\r\n this.client.on('sync', (state, prevState, res) => {\r\n\r\n if (state === 'PREPARED') {\r\n this.setready()\r\n }\r\n\r\n this.core.store.dispatch('FETCH_CHATS').then(r => {\r\n this.core.store.dispatch('FETCH_EVENTS')\r\n this.core.store.commit('ALL_NOTIFICATIONS_COUNT', this.client.getRooms())\r\n })\r\n\r\n\r\n });\r\n\r\n }\r\n\r\n setready() {\r\n\r\n if (!this.chatsready) {\r\n this.chatsready = true\r\n this.core.store.commit('SET_CHATS_READY', true)\r\n }\r\n\r\n }\r\n\r\n initdb(){\r\n return ChatStorage('files', 1).then((db) => {\r\n this.db = db\r\n return Promise.resolve()\r\n }).catch(() => {\r\n return Promise.resolve()\r\n })\r\n }\r\n\r\n init() {\r\n return this.createClient().then(() => {\r\n\r\n if(this.error){\r\n return Promise.reject(this.error)\r\n }\r\n\r\n return this.initdb()\r\n \r\n }).then(() => {\r\n\r\n this.initEvents()\r\n\r\n return Promise.resolve()\r\n })\r\n }\r\n\r\n deactivateAccount(){\r\n\r\n if (this.client) {\r\n return this.client.deactivateAccount(this.credentials, true)\r\n }\r\n\r\n return Promise.reject('noclient')\r\n }\r\n\r\n destroy() {\r\n if (this.client) {\r\n // Before client is stopped, delete the pusher if needed\r\n if (window.cordova) {\r\n this.deletePusher();\r\n }\r\n\r\n this.client.stopClient()\r\n }\r\n\r\n this.chatsready = false\r\n this.ready = false\r\n this.error = false\r\n }\r\n\r\n // Try to delete the current pusher if needed\r\n deletePusher() {\r\n // Try to get a saved token\r\n\r\n if (!window.cordova) return\r\n\r\n var savedToken;\r\n if (localStorage)\r\n savedToken = localStorage.getItem('fcmtoken5');\r\n if (savedToken && this.client.setPusher) {\r\n var appName = 'pocketnet';\r\n var pusherData = {\r\n app_display_name: appName,\r\n app_id: appName + window.cordova.platformId,\r\n\r\n data: {\r\n url: this.core.mtrx.baseUrl + '/_matrix/push/v1/notify',\r\n default_payload: {\r\n aps: {\r\n \"sound\": \"default\",\r\n \"content-available\": 1\r\n }\r\n }\r\n },\r\n\r\n device_display_name: window.device.manufacturer + \" \" + window.device.model,\r\n kind: null,\t// Set to null to delete the pusher\r\n lang: localStorage.getItem('loc') || 'en',\r\n pushkey: savedToken\r\n\r\n };\r\n\r\n this.core.mtrx.client.setPusher(pusherData).then(() => {\r\n localStorage.removeItem('fcmtoken5');\r\n }, (err) => {\r\n console.log(err);\r\n });\r\n }\r\n }\r\n\r\n uploadContent(file, save) {\r\n return this.client.uploadContent(file).then(src => {\r\n return Promise.resolve(this.core.mtrx.client.mxcUrlToHttp(src))\r\n }).then(url => {\r\n\r\n if(save){\r\n return this.storeFileLocal(url, file).then(() => {\r\n return Promise.resolve(url)\r\n }).catch(e => {\r\n return Promise.resolve(url)\r\n })\r\n }\r\n\r\n return Promise.resolve()\r\n })\r\n }\r\n\r\n /*transaction(roomId, txId){\r\n this.client.sendEvent(roomId, \"m.room.message\", {\r\n\r\n txId: roomId,\r\n msgtype: \"m.notice\"\r\n\r\n }, \"\");\r\n }*/\r\n\r\n\r\n originalEvent(id, timeline) {\r\n var rtr = timeline._timelineSet.getRelationsForEvent(e.event.event_id, 'm.reference', 'm.room.message')\r\n\r\n if (rtr) {\r\n var events = rtr.getRelations()\r\n return events[0]\r\n }\r\n }\r\n\r\n clearEventId(event) {\r\n var previd = null\r\n\r\n if (\r\n event.event.content['m.relates_to'] &&\r\n event.event.content['m.relates_to']['rel_type'] == 'm.replace') previd = event.event.content['m.relates_to']['event_id']\r\n\r\n\r\n return previd || event.getId()\r\n\r\n }\r\n\r\n textEvent(chat, text) {\r\n if (chat.pcrypto.canBeEncrypt()) {\r\n return chat.pcrypto.encryptEvent(text)\r\n }\r\n\r\n return Promise.resolve(this.sdk.ContentHelpers.makeTextMessage(text))\r\n }\r\n\r\n sendtext(chat, text, {relation, from}) {\r\n\r\n return this.textEvent(chat, text).then(r => {\r\n\r\n if (relation) {\r\n\r\n r['m.relates_to'] = {\r\n \"rel_type\": relation.type,\r\n \"event_id\": this.clearEventId(relation.event),\r\n }\r\n\r\n }\r\n\r\n if (from) {\r\n r['from'] = from\r\n }\r\n\r\n if (chat.pcrypto.canBeEncrypt()) {\r\n return this.client.sendEvent(chat.roomId, 'm.room.message', r)\r\n } else\r\n return this.client.sendMessage(chat.roomId, r)\r\n })\r\n\r\n\r\n }\r\n\r\n sendFile(chat, file, meta, {relation, from}, notenc) {\r\n\r\n if (!meta) meta = {}\r\n\r\n var fileInfo = {}\r\n fileInfo.name = file.name\r\n fileInfo.size = file.size\r\n\r\n var encpromise = (() => Promise.resolve(file))()\r\n var promise = null\r\n\r\n if (chat.pcrypto.canBeEncrypt() && !notenc) {\r\n\r\n encpromise = chat.pcrypto.encryptFile(file).then(r => {\r\n\r\n fileInfo.secrets = r.secrets\r\n\r\n return Promise.resolve(r.file)\r\n\r\n })\r\n\r\n }\r\n\r\n return encpromise.then(file => {\r\n\r\n promise = this.client.uploadContent(file)\r\n\r\n if (promise.abort) meta.abort = promise.abort\r\n\r\n return promise\r\n\r\n }).then(src => {\r\n\r\n if (meta.aborted)\r\n return Promise.reject('aborted')\r\n\r\n return Promise.resolve(this.client.mxcUrlToHttp(src))\r\n\r\n }).then((url) => {\r\n\r\n fileInfo.url = url\r\n\r\n let body = JSON.stringify(fileInfo)\r\n\r\n var r = {\r\n body: body,\r\n msgtype: 'm.file'\r\n }\r\n\r\n if (relation) {\r\n\r\n r['m.relates_to'] = {\r\n \"rel_type\": relation.type,\r\n \"event_id\": this.clearEventId(relation.event),\r\n }\r\n\r\n }\r\n\r\n if (from) {\r\n r['from'] = from\r\n }\r\n\r\n return this.client.sendMessage(chat.roomId, r)\r\n\r\n })\r\n\r\n }\r\n\r\n sendImageBase64(chat, base64, meta, p) {\r\n\r\n var method = 'toFileFetch'\r\n\r\n if (base64.indexOf('data:') > -1) method = 'toFile'\r\n\r\n return f.Base64[method](base64).then(file => {\r\n return this.sendImage(chat, base64, file, meta, p)\r\n })\r\n }\r\n\r\n sendAudioBase64(chat, base64, meta, p) {\r\n\r\n var method = 'toFileFetch'\r\n\r\n if (base64.indexOf('data:') > -1) method = 'toFile'\r\n\r\n return f.Base64[method](base64).then(file => {\r\n return this.sendAudio(chat, base64, file, meta, p)\r\n })\r\n }\r\n\r\n sendImage(chat, base64, file, meta, {relation, from} = {}) {\r\n if (!file) return this.sendImageBase64(chat, base64, meta)\r\n\r\n var i = new images()\r\n var info = {}\r\n\r\n if (!meta) meta = {}\r\n\r\n return i.wh(base64).then(_info => {\r\n info = _info\r\n\r\n if (from)\r\n info.from = from\r\n\r\n if (chat.pcrypto.canBeEncrypt()) {\r\n\r\n return chat.pcrypto.encryptFile(file).then(r => {\r\n info.secrets = r.secrets\r\n return Promise.resolve(r.file)\r\n })\r\n\r\n }\r\n\r\n return Promise.resolve(file)\r\n\r\n\r\n }).then(file => {\r\n var promise = this.core.mtrx.uploadContent(file, true)\r\n if (promise.abort) meta.abort = promise.abort\r\n\r\n return promise\r\n }).then((image) => {\r\n if (meta.aborted) return Promise.reject('aborted')\r\n\r\n return this.client.sendImageMessage(chat.roomId, image, info, 'Image')\r\n })\r\n }\r\n\r\n sendAudio(chat, base64, file, meta, {relation, from} = {}) {\r\n\r\n\r\n if (!file) return this.sendAudioBase64(chat, base64, meta)\r\n\r\n \r\n let info = {}\r\n\r\n info.from = from\r\n\r\n return new Promise(resolve => {\r\n if (chat.pcrypto.canBeEncrypt()) {\r\n\r\n return chat.pcrypto.encryptFile(file).then(r => {\r\n info.secrets = r.secrets\r\n return resolve(r.file)\r\n })\r\n }\r\n\r\n resolve(file) \r\n\r\n }).then(file => {\r\n\r\n let promise = this.core.mtrx.uploadContent(file, true)\r\n\r\n if (promise.abort) meta.abort = promise.abort\r\n\r\n return promise\r\n }).then((audio) => {\r\n\r\n if (meta.aborted) return Promise.reject('aborted')\r\n\r\n return this.client.sendAudioMessage(chat.roomId, audio, info, 'Audio')\r\n })\r\n\r\n }\r\n\r\n async getFile(chat, event) {\r\n\r\n try {\r\n\r\n var decryptKey = await chat.pcrypto.decryptKey(event.event)\r\n\r\n event.event.decryptKey = decryptKey\r\n\r\n } catch (e) {\r\n return Promise.reject(e)\r\n\r\n }\r\n\r\n return this.download(event.event.content.pbody.url).then(blob => {\r\n\r\n return chat.pcrypto.decryptFile(blob, decryptKey)\r\n\r\n }).then(r => {\r\n\r\n return Promise.resolve({\r\n file: r,\r\n name: event.event.content.pbody.name\r\n });\r\n\r\n }).catch(e => {\r\n return Promise.reject(e)\r\n })\r\n\r\n }\r\n\r\n async downloadFile(chat, event) {\r\n\r\n return this.getFile(chat, event).then(r => {\r\n\r\n if (window.cordova && f.saveFileCordova) {\r\n return new Promise((resolve, reject) => {\r\n\r\n f.saveFileCordova(r.file, r.name, function (i, e) {\r\n\r\n if (e) {\r\n console.error(e)\r\n }\r\n\r\n if (!e) resolve()\r\n\r\n else reject('unable')\r\n })\r\n })\r\n }\r\n\r\n return fileSaver.saveAs(r.file, r.name);\r\n\r\n }).catch(e => {\r\n console.error(e)\r\n return Promise.reject(e)\r\n })\r\n\r\n\r\n }\r\n\r\n async getAudioUnencrypt(chat, event){\r\n\r\n if(event.event.content.audioData){\r\n return Promise.resolve(event.event.content.audioData)\r\n }\r\n\r\n return this.download(event.event.content.url, true).then(r => {\r\n\r\n return f.readFile(r)\r\n }).then(arraybuffer => {\r\n\r\n event.event.content.audioData = arraybuffer\r\n\r\n return Promise.resolve(arraybuffer)\r\n })\r\n\r\n }\r\n\r\n async getAudio(chat, event) {\r\n\r\n if (event.event.decryptedAudio) {\r\n return Promise.resolve(event.event.decryptedAudio)\r\n }\r\n\r\n try {\r\n\r\n var decryptKey = await chat.pcrypto.decryptKey(event.event)\r\n\r\n event.event.decryptKey = decryptKey\r\n\r\n return this.download(event.event.content.url, true).then(blob => {\r\n\r\n return chat.pcrypto.decryptFile(blob, decryptKey)\r\n\r\n }).then(r => {\r\n\r\n return f.readFile(r)\r\n }).then(arraybuffer => {\r\n\r\n event.event.decryptedAudio = arraybuffer\r\n\r\n return Promise.resolve(event.event.decryptedAudio)\r\n\r\n }).catch(e => {\r\n return Promise.reject(e)\r\n })\r\n\r\n } catch (e) {\r\n return Promise.reject(e)\r\n }\r\n }\r\n\r\n async getImage(chat, event) {\r\n\r\n if (event.event.decryptedImage) {\r\n return Promise.resolve(event.event.decryptedImage)\r\n }\r\n\r\n try {\r\n\r\n var decryptKey = await chat.pcrypto.decryptKey(event.event)\r\n\r\n event.event.decryptKey = decryptKey\r\n\r\n return this.download(event.event.content.url, true).then(blob => {\r\n\r\n return chat.pcrypto.decryptFile(blob, decryptKey)\r\n\r\n }).then(r => {\r\n return f.Base64.fromFile(r)\r\n }).then(url => {\r\n\r\n event.event.decryptedImage = url.replace('data:file;', 'data:image/jpeg;')\r\n return Promise.resolve(event.event.decryptedImage)\r\n\r\n\r\n }).catch(e => {\r\n return Promise.reject(e)\r\n })\r\n\r\n } catch (e) {\r\n return Promise.reject(e)\r\n\r\n }\r\n }\r\n\r\n\r\n shareInChat(id, share) {\r\n var m_chat = this.client.getRoom(id)\r\n\r\n\r\n //// share.openwithItems []\r\n\r\n //// https://github.com/j3k0/cordova-plugin-openwith (item.type ---> resize)\r\n\r\n return this.core.mtrx.kit.prepareChat(m_chat).then(r => {\r\n\r\n var promises = []\r\n\r\n //// todo resize images.resize.fit\r\n _.each(share.images, (base64) => {\r\n\r\n var promise = this.sendImageBase64(m_chat, base64, {}, {from: share.from})\r\n\r\n promises.push(promise)\r\n\r\n })\r\n\r\n _.each(share.files, (file) => {\r\n\r\n promises.push(this.sendFile(m_chat, file, {}, {from: share.from}))\r\n\r\n })\r\n\r\n _.each(share.urls, (url) => {\r\n\r\n promises.push(this.sendtext(m_chat, url, {from: share.from}))\r\n\r\n })\r\n\r\n _.each(share.messages, (text) => {\r\n\r\n promises.push(this.sendtext(m_chat, text, {from: share.from}))\r\n\r\n })\r\n\r\n _.each(share.audio, (arraybuffer) => {\r\n\r\n var base64 = 'data:audio/mpeg;base64,' + f._arrayBufferToBase64(arraybuffer)\r\n\r\n promises.push(this.sendAudioBase64(m_chat, base64,{}, {from: share.from}))\r\n\r\n })\r\n\r\n return Promise.all(promises)\r\n\r\n })\r\n }\r\n\r\n opencontact(contact) {\r\n\r\n this.core.store.commit('setmodal', {\r\n caption: contact.name,\r\n type: 'contact',\r\n data: {\r\n contact: contact\r\n }\r\n })\r\n }\r\n\r\n complain(caption, p) {\r\n\r\n this.core.store.commit('setmodal', {\r\n caption: caption,\r\n type: 'complain',\r\n data: p\r\n })\r\n }\r\n\r\n blockeduser(id) {\r\n\r\n if (!this.core.mtrx.client) return\r\n\r\n return this.core.mtrx.client.isUserIgnored(this.core.user.matrixId(id))\r\n }\r\n\r\n blockUser(userId) {\r\n\r\n userId = this.core.user.matrixId(userId)\r\n\r\n if (this.client.isUserIgnored(userId)) {\r\n return Promise.resolve()\r\n }\r\n\r\n var blackList = this.client.getIgnoredUsers()\r\n\r\n blackList.push(userId)\r\n\r\n return this.client.setIgnoredUsers(blackList).then(r => {\r\n return Promise.resolve(r)\r\n })\r\n }\r\n\r\n fastsync = function () {\r\n\r\n var state = this.client.getSyncState()\r\n\r\n if (state === \"PREPARED\" || state === \"SYNCING\") {\r\n\r\n } else {\r\n return this.client.retryImmediately().catch(e => {\r\n console.log('fastsyncerror', e)\r\n })\r\n }\r\n\r\n\r\n }\r\n\r\n unblockUser(userId) {\r\n\r\n userId = this.core.user.matrixId(userId)\r\n\r\n if (!this.client.isUserIgnored(userId)) {\r\n return Promise.resolve()\r\n }\r\n\r\n var blackList = this.client.getIgnoredUsers()\r\n\r\n blackList = _.filter(blackList, function (_id) {\r\n return userId != _id\r\n })\r\n\r\n return this.client.setIgnoredUsers(blackList).then(r => {\r\n return Promise.resolve(r)\r\n })\r\n }\r\n\r\n chatUsersInfo(roomId, m) {\r\n\r\n if (!m) m = 'chatUsers'\r\n\r\n var _users = this.core.store.state.users\r\n\r\n return _.filter(_.map(this[m](roomId), (user) => {\r\n return _users[user.userId]\r\n }), function (u) {\r\n return u\r\n })\r\n\r\n }\r\n\r\n chatUsers(roomId) {\r\n return this.core.store.state.chatusers[roomId] || []\r\n }\r\n\r\n\r\n anotherChatUsers(roomId) {\r\n return _.filter(this.chatUsers(roomId), (user) => {\r\n return user.userId != this.core.user.userinfo.id\r\n })\r\n }\r\n}\r\n\r\nexport default MTRX\r\n","//require('ion-sound')\r\nimport f from \"./functions\";\r\n//const { Howl, Howler } = require('howler');\r\n\r\nclass Notifier {\r\n\r\n\tconstructor(core, p) {\r\n\t\tif (!p) p = {}\r\n\r\n\t\tthis.core = core\r\n\t\tthis.showed = JSON.parse(localStorage[this.key] || \"{}\")\r\n\r\n\t\tthis.ion = null\r\n\r\n\t\tif (typeof ion != 'undefined') this.ion = ion\r\n\r\n\t\t/*ion.sound({\r\n\t\t sounds: [\r\n\t\t\t{\r\n\t\t\t name: \"glass\"\r\n\t\t\t}\r\n\t\t ],\r\n\t\t path: \"sounds/\",\r\n\t\t preload: true\r\n\t\t});*/\r\n\t}\r\n\r\n\tkey = 'showednotifications'\r\n\tshowed = {}\r\n\r\n\taddshowed(id) {\r\n\r\n\t\tthis.showed = JSON.parse(localStorage[this.key] || \"{}\")\r\n\t\tthis.showed[id] = true\r\n\t\tlocalStorage[this.key] = JSON.stringify(this.showed)\r\n\r\n\t}\r\n\r\n\tclearshowed() {\r\n\t\tthis.showed = {}\r\n\t\tlocalStorage[this.key] = JSON.stringify(this.showed)\r\n\t}\r\n\r\n\tplaysound() {\r\n\t\t// If cordova is available, use the media plugin to play a sound\r\n\t\tif (window.Media && window.cordova && window.cordova.file && window.cordova.file.applicationDirectory) {\r\n\r\n\t\t\tvar soundSrc = window.cordova.file.applicationDirectory + 'www/sounds/glass.mp3';\r\n\t\t\tif (soundSrc.startsWith('file://'))\r\n\t\t\t\tsoundSrc = soundSrc.substring(7);\r\n\t\t\tvar notificationSound = new Media(soundSrc);\r\n\t\t\t// Play audio\r\n\t\t\tnotificationSound.play();\r\n\t\t}\r\n\r\n\t\t// Else, try to use the Howler sound plugin\r\n\t\telse if (window.ion) {\r\n\r\n\t\t\tion.sound.play('glass')\r\n\r\n\t\t\t/*var notificationSound = new Howl({\r\n\t\t\t\tsrc: ['sounds/glass.mp3'],\r\n\t\t\t\thtml5: true\r\n\t\t\t});\r\n\t\t\tnotificationSound.play();*/\r\n\t\t}\r\n\t}\r\n\r\n\tnotifySoundOrAction() {\r\n\r\n\t\tvar lastsounddate = localStorage['lastsounddate'] || null\r\n\r\n\t\tif (lastsounddate) {\r\n\t\t\tlastsounddate = new Date(lastsounddate)\r\n\r\n\t\t\tif (f.date.addseconds(lastsounddate, 10) > (new Date())) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlocalStorage['lastsounddate'] = (new Date())\r\n\r\n\t\tif (window.cordova && window.POCKETNETINSTANCE) {\r\n\t\t\twindow.POCKETNETINSTANCE.mobile.vibration.small()\r\n\t\t}\r\n\t\telse {\r\n\t\t\tthis.playsound()\r\n\t\t}\r\n\t}\r\n\r\n\tdecrypt(event, chat) {\r\n\r\n\t\treturn this.core.mtrx.kit.prepareChat(chat).then(r => {\r\n\r\n\t\t\t\r\n\t\t\tif (event.event.decrypted) {\r\n\r\n\t\t\t\treturn Promise.resolve()\r\n\t\t\t}\r\n\r\n\t\t\treturn chat.pcrypto.decryptEvent(event.event)\r\n\t\t\t \r\n\t\t}).catch(e => {\r\n\t\t\treturn Promise.resolve()\r\n\t\t})\r\n\r\n\t}\r\n\r\n\tmessage(event, user, chat) {\r\n\r\n\t\tvar state = this.core.vm.$store.state\r\n\r\n\r\n\t\tif (this.showed[event.event.event_id]) return\r\n\r\n\t\tthis.addshowed(event.event.event_id)\r\n\r\n\t\tvar external = f.deep(this, 'core.external.clbks.NOTIFICATION') || {}\r\n\t\tvar ctype = ''\r\n\r\n\t\tvar t = f.deep(event, 'event.type')\r\n\r\n\t\tif (['m.room.member'].indexOf(t) > -1) ctype = 'invite'\r\n\t\tif (['m.room.message'].indexOf(t) > -1) ctype = 'message'\r\n\t\tif (['m.room.name'].indexOf(t) > -1) ctype = ''\r\n\t\tif (['m.room.power_levels'].indexOf(t) > -1) ctype = 'moder'\r\n\t\tif (['m.room.redaction'].indexOf(t) > -1) ctype = 'redaction'\r\n\t\tif (f.deep(event, 'event.content.msgtype') == 'm.encrypted') ctype = 'encrypted'\r\n\r\n\t\tvar c = () => {\r\n\r\n\t\t\t\r\n\t\t\tvar msg = {\r\n\t\t\t\ttitle: user.name,\r\n\t\t\t\tevent: event,\r\n\t\t\t\tmessage: event.event.content.type == 'm.encrypted' ? \"***\" : event.event.content.body, // event.content.body,\r\n\t\t\t\troomId: event.event.room_id,\r\n\t\t\t\ticon: user.image,\r\n\t\t\t\tchat: chat,\r\n\t\t\t\tctype: ctype\r\n\t\t\t}\r\n\r\n\t\t\t_.each(external, function (e) {\r\n\t\t\t\te(msg)\r\n\t\t\t})\r\n\r\n\t\t\tif (state.currentRoom === event.event.room_id && !this.core.hiddenInParent) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tthis.notifySoundOrAction()\r\n\t\t\tthis.show(msg, '/chat?id=' + event.event.room_id)\r\n\t\t}\r\n\r\n\t\tif (ctype == 'encrypted') {\r\n\t\t\tthis.decrypt(event, chat).then(c)\r\n\t\t}\r\n\t\telse {\r\n\t\t\tc()\r\n\t\t}\r\n\r\n\r\n\t}\r\n\r\n\tevent(event, chat) {\r\n\t\tlet pushAction = this.core.mtrx.client.getPushActionsForEvent(event)\r\n\r\n\r\n\t\tif (!pushAction.notify) return\r\n\r\n\t\t//let timeFromNow = moment(moment.utc(event.event.origin_server_ts).toDate()).local().fromNow()\r\n\r\n\t\tvar date = moment(moment.utc(event.event.origin_server_ts).toDate()).local().toDate()\r\n\t\tvar iftime = f.date.addseconds(date, 10) > moment().toDate()\r\n\r\n\r\n\t\tif (!iftime) return\r\n\r\n\t\tthis.core.mtrx.isReaded(event, true).then(r => {\r\n\r\n\t\t\tif (r) return\r\n\r\n\t\t\tif (!this.core.mtrx.me(event.getSender()) && event.getSender() && event.getSender() !== this.core.mtrx.client.credentials.userId) {\r\n\r\n\r\n\t\t\t\tthis.core.user.usersInfo([f.getmatrixid(event.getSender())]).then(info => {\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\tinfo && info[0]\r\n\t\t\t\t\t) {\r\n\r\n\r\n\t\t\t\t\t\tthis.message(event, info[0], chat)\r\n\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t})\r\n\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t}\r\n\r\n\tshow = function (info, click) {\r\n\t\tif (typeof click != 'function') {\r\n\t\t\tvar route = click\r\n\t\t\tclick = () => {\r\n\t\t\t\tthis.core.vm.$router.push(route).catch(e => {})\r\n\r\n\t\t\t\tif (this.core.apptochat) this.core.apptochat()\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tvar position = \"bottom-right\";\r\n\r\n\t\tif (this.core.vm.$store.state.mobile) {\r\n\t\t\tposition = 'top-left'\r\n\t\t}\r\n\r\n\t\tthis.core.vm.$message({\r\n\t\t\tevent: info.event,\r\n\t\t\ttitle: info.title,\r\n\t\t\tmessage: info.message,\r\n\t\t\troomId: info.roomId,\r\n\t\t\ticonImg: info.icon || null,\r\n\t\t\tonClick: click,\r\n\t\t\tzIndex: 999,\r\n\t\t\tsupportHTML: true,\r\n\t\t\twrapperClassName: \"notificationWrapper\",\r\n\t\t\tposition: position,\r\n\t\t\ttype: 'info',\r\n\t\t\tchat: info.chat,\r\n\t\t\tduration: 5000\r\n\t\t})\r\n\t}\r\n}\r\n\r\nexport default Notifier","var Axios = require('axios');\r\nimport axiosRequest from '@nelsonomuto/axios-request-timeout';\r\nvar { error, byError } = require('./error')\r\n\r\nimport f from '@/application/functions'\r\nimport qs from 'qs';\r\n\r\nvar Axios = function(){\r\n\r\n var datakeys = [\r\n 'data.result'\r\n ]\r\n\r\n var errorkeys = [\r\n 'data.error'\r\n ]\r\n\r\n async function axios ({\r\n to : to,\r\n data : data\r\n }){\r\n\r\n data || (data = {})\r\n\r\n _.each(data, (v, i) => {\r\n if(_.isArray(v) || _.isObject(v)){\r\n data[i] = JSON.stringify(v)\r\n }\r\n }) \r\n\r\n var response = null;\r\n\r\n try{\r\n response = await axiosRequest({\r\n method: 'post',\r\n headers: { 'content-type': 'application/x-www-form-urlencoded' },\r\n url: to,\r\n data: qs.stringify(data),\r\n timeout: 35000\r\n })\r\n\r\n }\r\n catch(e){\r\n response = e.response\r\n }\r\n \r\n\r\n if(!response){\r\n return Promise.reject('noresponse')\r\n }\r\n\r\n ////errors\r\n \r\n var ke = _.find(errorkeys, function(k){\r\n return f.deep(response.data, k)\r\n })\r\n\r\n\r\n if (ke){\r\n return Promise.reject(byError(f.deep(response.data, ke)))\r\n }\r\n\r\n ////result\r\n\r\n var k = _.find(datakeys, function(k){\r\n return f.deep(response.data, k)\r\n })\r\n\r\n\r\n if (k){\r\n return Promise.resolve(f.deep(response.data, k))\r\n }\r\n\r\n ////result\r\n \r\n return Promise.reject('error')\r\n \r\n\r\n }\r\n\r\n return {\r\n axios\r\n }\r\n\r\n}\r\n\r\nexport default Axios","import f from './functions'\r\nimport Axios from './axios'\r\nvar { error } = require('./error')\r\n\r\nimport ChatStorage from \"./chatstorage\";\r\n\r\nvar ApiWrapper = function (core) {\r\n\r\n\tvar self = this;\r\n\tvar a = new Axios();\r\n\r\n\tvar cache = {}\r\n\tvar loading = {}\r\n\tvar storages = {}\r\n\r\n\tvar apis = {\r\n\t\tpocketnet : null\r\n\t}\r\n\r\n\tvar ep = function(){\r\n\t\treturn Promise.resolve()\r\n\t}\r\n\r\n\tvar getstorage = function(p){\r\n\r\n\t\tif(!storages[p.storage]){\r\n\t\t\treturn ChatStorage(p.storage, p.version || 1, p.time).then(storage => {\r\n\r\n\t\t\t\tstorages[p.storage] = storage\r\n\r\n\t\t\t\treturn Promise.resolve(storage)\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\treturn Promise.resolve(storages[p.storage])\r\n\t}\r\n\r\n\t\r\n\tvar scasheAct = function (ids, key, resultsKey, reload, storageparameters) {\r\n\r\n\t\tif (!_.isArray(ids)) ids = [ids]\r\n\r\n\t\tvar waitLoading = {}\r\n\r\n\t\tif(!resultsKey) \r\n\t\t\tresultsKey = key\r\n\r\n\t\tif(!cache[key]) {\r\n\t\t\tcache[key] = {}\r\n\t\t}\r\n\r\n\t\tif(!loading[key]) {\r\n\t\t\tloading[key] = {}\r\n\t\t}\r\n\r\n\t\treturn (storageparameters ? getstorage(storageparameters) : ep()).then(storage => {\r\n\r\n\t\t\tif (storage){\r\n\r\n\t\t\t\treturn Promise.all(_.map(ids, (id) => {\r\n\r\n\t\t\t\t\tif (cache[key][id]){\r\n\t\t\t\t\t\treturn Promise.resolve()\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn storage.get(id).then((stored) => {\r\n\t\t\t\t\t\tcache[key][stored[resultsKey]] = stored\r\n\r\n\t\t\t\t\t\treturn Promise.resolve()\r\n\t\t\t\t\t}).catch(e => {\r\n\t\t\t\t\t\treturn Promise.resolve()\r\n\t\t\t\t\t})\r\n\r\n\t\t\t\t}))\r\n\r\n\t\t\t}\r\n\r\n\t\t\treturn Promise.resolve()\r\n\r\n\t\t\t\r\n\t\t}).then(r => {\r\n\r\n\t\t\tvar idtoloadPrev = _.uniq(_.filter(ids, function (id) {\r\n\t\t\t\treturn reload || !cache[key][id] || cache[key][id].nocache\r\n\t\t\t}))\r\n\t\r\n\t\t\tvar idtoload = _.filter(idtoloadPrev, function (id) {\r\n\t\r\n\t\t\t\tif(!loading[key][id]) {\r\n\t\t\t\t\tloading[key][id] = true\r\n\t\t\t\t\treturn true\r\n\t\t\t\t}\r\n\t\r\n\t\t\t\twaitLoading[id] = true\r\n\t\t\t})\r\n\t\r\n\t\t\tvar handleResults = function (result, _ids) {\r\n\r\n\t\t\t\treturn (storageparameters ? getstorage(storageparameters) : ep()).then(storage => {\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(storage){\r\n\t\t\t\t\t\treturn Promise.all(_.map(result, (row) => {\r\n\r\n\t\t\t\t\t\t\tif(!row[resultsKey]){\r\n\t\t\t\t\t\t\t\treturn Promise.resolve()\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\treturn storage.set(row[resultsKey], row)\r\n\r\n\t\t\t\t\t\t}))\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn Promise.resolve()\r\n\t\t\t\t\t\r\n\t\t\t\t}).then(() => {\r\n\r\n\t\t\t\t\t_.each(result, function (row) {\r\n\r\n\t\t\t\t\t\tif (row[resultsKey]) {\r\n\t\t\t\t\t\t\tcache[key][row[resultsKey]] = row\r\n\t\t\t\t\t\t}\r\n\t\r\n\t\t\t\t\t})\r\n\t\t\r\n\t\t\t\t\t_.each(_ids, function(id){\r\n\t\t\t\t\t\tdelete loading[key][id]\r\n\t\t\t\t\t\tdelete waitLoading[id]\r\n\t\t\r\n\t\t\t\t\t\tif(!cache[key][id])\r\n\t\t\t\t\t\t\tcache[key][id] = 'error'\r\n\t\t\t\t\t})\r\n\t\t\r\n\t\t\t\t\tvar nresult = {};\r\n\t\t\r\n\t\t\t\t\treturn f.pretry(() => {\r\n\t\t\r\n\t\t\t\t\t\t_.each(ids, function (id) {\r\n\t\t\r\n\t\t\t\t\t\t\tif (cache[key][id]) {\r\n\t\t\r\n\t\t\t\t\t\t\t\tif (cache[key][id] != 'error')\r\n\t\t\r\n\t\t\t\t\t\t\t\t\tnresult[id] = (cache[key][id])\r\n\t\t\r\n\t\t\t\t\t\t\t\tdelete loading[key][id]\r\n\t\t\t\t\t\t\t\tdelete waitLoading[id]\r\n\t\t\t\t\t\t\t}\r\n\t\t\r\n\t\t\t\t\t\t})\r\n\t\t\r\n\t\t\t\t\t\treturn _.toArray(waitLoading).length == 0\r\n\t\t\r\n\t\t\t\t\t}).then(() => {\r\n\t\t\t\t\t\treturn Promise.resolve(nresult)\r\n\t\t\t\t\t})\r\n\r\n\t\t\t\t})\r\n\t\r\n\t\t\t\t\r\n\t\r\n\t\t\t}\r\n\t\r\n\t\t\treturn Promise.resolve({\r\n\t\t\t\tid: idtoload,\r\n\t\t\t\thandle: handleResults\r\n\t\t\t})\r\n\t\t})\r\n\r\n\r\n\t\t\r\n\t\t\r\n\t}\r\n\r\n\tvar waitonline = function () {\r\n\r\n\t\tif (!core || !core.waitonline) {\r\n\t\t\treturn Promise.resolve()\r\n\t\t}\r\n\r\n\t\treturn core.waitonline()\r\n\r\n\t}\r\n\r\n\tvar crequest = function (ids, key, rkey, reload, storageparameters) {\r\n\r\n\t\treturn scasheAct(ids, key, rkey, reload, storageparameters).then(sh => {\r\n\r\n\t\t\tif (!sh.id.length) {\r\n\t\t\t\treturn sh.handle([])\r\n\t\t\t}\r\n\t\r\n\t\t\treturn Promise.reject(sh)\r\n\r\n\t\t})\r\n\r\n\t\t\r\n\t}\r\n\r\n\tvar request = function (data, to) {\r\n\r\n\t\treturn waitonline().then(() => {\r\n\r\n\t\t\tdata || (data = {})\r\n\r\n\t\t\treturn a.axios({\r\n\t\t\t\tto,\r\n\t\t\t\tdata,\r\n\t\t\t}).then(r => {\r\n\r\n\t\t\t\treturn Promise.resolve(r)\r\n\r\n\t\t\t})\r\n\t\t\t\t.catch(e => {\r\n\r\n\t\t\t\t\tif (e == 'noresponse') {\r\n\r\n\t\t\t\t\t\treturn new Promise((resolve, reject) => {\r\n\r\n\t\t\t\t\t\t\tsetTimeout(function () {\r\n\t\t\t\t\t\t\t\trequest(data, to).then(r => {\r\n\r\n\r\n\t\t\t\t\t\t\t\t\treturn resolve(r)\r\n\r\n\t\t\t\t\t\t\t\t}).catch(e => {\r\n\r\n\t\t\t\t\t\t\t\t\treturn reject(e)\r\n\r\n\t\t\t\t\t\t\t\t})\r\n\r\n\t\t\t\t\t\t\t}, 3000)\r\n\t\t\t\t\t\t})\r\n\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn Promise.reject(e)\r\n\r\n\t\t\t\t})\r\n\r\n\r\n\t\t})\r\n\r\n\r\n\t}\r\n\r\n\tself.clearCache = function (key) {\r\n\r\n\t\tif (!key) {\r\n\t\t\tcache = {}\r\n\t\t} else {\r\n\t\t\tdelete cache[key]\r\n\t\t}\r\n\t}\r\n\r\n\tself.pocketnet = {\r\n\r\n\t\tcommon: (data, method) => {\r\n\r\n\t\t\tif(!data) data = {}\r\n\r\n\t\t\tif(!apis.pocketnet)\r\n\t\t\t\tapis.pocketnet = f.deep(window, 'POCKETNETINSTANCE.api')\r\n\t\t\t\t\r\n\t\t\tif(!apis.pocketnet && typeof Api != 'undefined'){\r\n\t\t\t\tapis.pocketnet = new Api(core)\r\n\t\t\t}\t\r\n\t\t\t\t\r\n\t\t\tif (apis.pocketnet) {\r\n\r\n\t\t\t\treturn apis.pocketnet.initIf().then(() => {\r\n\t\t\t\t\treturn apis.pocketnet.wait.ready('use', 3000)\r\n\t\t\t\t\t\r\n\t\t\t\t}).then(r => {\r\n\t\t\t\t\treturn apis.pocketnet.rpc(method, data.parameters)\r\n\t\t\t\t}).catch(e => {\r\n\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\terror : e\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\r\n\t\t\t\t})\r\n\t\t\t\t\r\n\t\t\t}\r\n\r\n\t\t\tdata.method = method\r\n\t\t\tdata.node = '185.148.147.15'\r\n\t\t\tdata.parameters = f.hexEncode(JSON.stringify(data.parameters || \"\"))\r\n\r\n\t\t\treturn request(data, servers.pocketnet + '/rpc-' + (method || \"common\"))\r\n\r\n\t\t},\r\n\t\t\r\n\t\tuserState: (addresses) => {\r\n\r\n\t\t\tif (!_.isArray(addresses)) addresses = [addresses]\r\n\r\n\t\t\tvar parameters = [addresses.join(',')];\r\n\r\n\t\t\treturn self.pocketnet.common({ parameters }, 'getuserstate')\r\n\t\t},\r\n\r\n\t\tuserStateMe: (address) => {\r\n\r\n\t\t\tvar cacheresult = f.deep(window, 'POCKETNETINSTANCE.platform.sdk.ustate.storage.' + address)\r\n\r\n\t\t\tif(cacheresult){\r\n\t\t\t\treturn Promise.resolve(cacheresult)\r\n\t\t\t}\r\n\r\n\t\t\treturn self.pocketnet.userState(address)\r\n\t\t},\r\n\r\n\t\tuserInfoCached: (addresses, reload) => {\r\n\r\n\t\t\tvar rescached = []\r\n\r\n\t\t\tif(!reload){\r\n\r\n\t\t\t\trescached = _.filter(_.map(addresses, (address) => {\r\n\t\t\t\t\treturn f.deep(window, 'POCKETNETINSTANCE.platform.sdk.userscl.storage.' + address) || null\r\n\t\t\t\t}), (u) => {return u})\r\n\r\n\t\t\t\taddresses = _.filter(addresses, (a) => {\r\n\t\t\t\t\treturn !_.find(rescached, (r) => {\r\n\t\t\t\t\t\treturn r.address == a\r\n\t\t\t\t\t})\r\n\t\t\t\t})\r\n\t\t\t}\r\n\r\n\t\t\treturn self.pocketnet.userInfo(addresses, reload).then(rs => {\r\n\r\n\t\t\t\t\r\n\t\t\t\trs = _.toArray(rs)\r\n\r\n\t\t\t\t_.each(rescached, (c) => {\r\n\t\t\t\t\trs.push(c)\r\n\t\t\t\t})\r\n\r\n\r\n\t\t\t\treturn Promise.resolve(rs)\r\n\t\t\t})\r\n\r\n\t\t},\r\n\r\n\t\tsearch: (text) => {\r\n\r\n\t\t\tvar parameters = [text, 'users'];\r\n\r\n\t\t\treturn self.pocketnet.common({ parameters }, 'searchusers').then(data => {\r\n\t\t\t\treturn Promise.resolve(data || [])\r\n\t\t\t})\r\n\t\t},\r\n\r\n\t\tuserInfo: (addresses, reload) => {\r\n\r\n\t\t\tif(!addresses.length){\r\n\t\t\t\treturn Promise.resolve([])\r\n\t\t\t}\r\n\r\n\t\t\treturn crequest(addresses, 'pocketnet_userInfo', 'address', reload, {\r\n\t\t\t\tstorage : 'userInfo',\r\n\t\t\t\ttime : 60 * 60 * 24 \r\n\t\t\t}).catch(sh => {\r\n\r\n\t\t\t\tif(!sh || !sh.id) {\r\n\t\t\t\t\treturn Promise.reject(sh)\r\n\t\t\t\t}\r\n\r\n\t\t\t\tvar parameters = [sh.id, '1'];\r\n\r\n\t\t\t\treturn self.pocketnet.common({ parameters }, 'getuserprofile').then(results => {\r\n\r\n\t\t\t\t\treturn sh.handle(results, sh.id)\r\n\r\n\t\t\t\t})\r\n\t\t\t})\r\n\t\t},\r\n\r\n\t\tpostInfo: (params) => {\r\n\r\n\t\t\tvar parameters = [[params.parameters]]\r\n\r\n\t\t\treturn self.pocketnet.common({ parameters }, 'getrawtransactionwithmessagebyid').then(results => {\r\n\r\n\t\t\t\treturn Promise.resolve(results)\r\n\r\n\t\t\t})\r\n\t\t},\r\n\r\n\t\tpocketNetProfileAddress: (profile_name) => {\r\n\r\n\t\t\tvar parameters = [[profile_name.parameters]]\r\n\r\n\t\t\treturn self.pocketnet.common({ parameters }, 'getuseraddress').then(results => {\r\n\r\n\t\t\t\treturn Promise.resolve(results)\r\n\r\n\t\t\t})\r\n\t\t},\r\n\r\n\t\tpocketNetProfileInfo: (profile_address) => {\r\n\r\n\t\t\tvar parameters = [[profile_address.parameters]]\r\n\r\n\t\t\treturn self.pocketnet.common({ parameters }, 'getuserprofile').then(results => {\r\n\r\n\t\t\t\treturn Promise.resolve(results)\r\n\r\n\t\t\t})\r\n\t\t},\r\n\r\n\r\n\t}\r\n\r\n\treturn self;\r\n}\r\n\r\nexport default ApiWrapper\r\n\r\n","import f from './functions';\r\n\r\nvar Media = function () {\r\n var self = this\r\n\r\n self.gettingmedia = false\r\n\r\n var permissions = {\r\n\r\n ios : {\r\n audio : function(){\r\n\r\n return new Promise((resolve, reject) => {\r\n\r\n window.audioinput.checkMicrophonePermission(function(hasPermission) {\r\n if (hasPermission) {\r\n \r\n resolve();\r\n } \r\n else {\t \r\n // Ask the user for permission to access the microphone\r\n window.audioinput.getMicrophonePermission(function(hasPermission, message) {\r\n if (hasPermission) {\r\n resolve()\r\n } else {\r\n reject('permissions')\r\n }\r\n });\r\n }\r\n });\r\n\r\n })\r\n \r\n },\r\n\r\n video : function(){\r\n\r\n return new Promise((resolve, reject) => {\r\n \r\n var needMic = true;\r\n var needCamera = true;\r\n\r\n cordova.plugins.iosrtc.requestPermission(needMic, needCamera, function (permissionApproved) {\r\n // permissionApproved will be true if user accepted permission otherwise will be false.\r\n if(permissionApproved) resolve()\r\n else reject('permissions')\r\n\r\n })\r\n\r\n })\r\n \r\n } \r\n },\r\n\r\n audio : function(){\r\n\r\n var permissions = window.cordova.plugins.permissions;\r\n\r\n return new Promise((resolve, reject) => {\r\n\r\n if (permissions){\r\n\r\n var request = function(){\r\n permissions.requestPermission(permissions.RECORD_AUDIO, (status) => {\r\n\r\n if (status.hasPermission) {\r\n resolve()\r\n }\r\n else{\r\n reject('permissions')\r\n }\r\n\r\n }, (err) => {\r\n\r\n console.error(err)\r\n\r\n reject('permissions')\r\n\r\n });\r\n }\r\n\r\n permissions.checkPermission(permissions.RECORD_AUDIO, (status) => {\r\n\r\n\r\n if (status.hasPermission) {\r\n resolve()\r\n }\r\n else {\r\n request()\r\n }\r\n\r\n }, (err) => {\r\n\r\n console.error(err)\r\n\r\n request()\r\n });\r\n\r\n }\r\n else{\r\n reject('permissions')\r\n }\r\n\r\n })\r\n\r\n \r\n\r\n },\r\n\r\n video : function(){\r\n\r\n var permissions = window.cordova.plugins.permissions;\r\n\r\n return new Promise((resolve, reject) => {\r\n\r\n if (permissions){\r\n\r\n permissions.hasPermission(permissions.CAMERA, (status) => {\r\n\r\n if (status.hasPermission) {\r\n\r\n resolve()\r\n\r\n }\r\n else {\r\n\r\n permissions.requestPermission(permissions.CAMERA, () => {\r\n\r\n resolve()\r\n\r\n }, () => {\r\n\r\n reject('permissions')\r\n\r\n });\r\n\r\n }\r\n\r\n });\r\n\r\n }\r\n else{\r\n reject('permissions')\r\n }\r\n\r\n })\r\n\r\n \r\n\r\n }\r\n \r\n }\r\n\r\n var initPermissions = function(mediasettings){\r\n\r\n var callperm = function(f, setting){\r\n if (setting){\r\n return f()\r\n }\r\n else{\r\n return Promise.resolve()\r\n }\r\n }\r\n\r\n if(window.cordova && window.device){\r\n\r\n var ios = f.isios()\r\n\r\n return callperm(ios ? permissions.ios.audio : permissions.audio, mediasettings.audio).then(() => {\r\n return callperm(ios ? permissions.ios.video : permissions.video, mediasettings.video)\r\n }).catch(e => {\r\n console.error(\"E\", e)\r\n return Promise.reject(e)\r\n })\r\n\r\n }\r\n\r\n return Promise.resolve()\r\n\r\n }\r\n\r\n var initMedia = function(mediasettings){\r\n\r\n return new Promise((resolve, reject)=> {\r\n\r\n\r\n initPermissions(mediasettings).then(() => {\r\n\r\n if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\r\n navigator.mediaDevices.getUserMedia(mediasettings).then(resolve).catch(reject);\r\n } else {\r\n (\r\n navigator.getUserMedia ||\r\n navigator.webkitGetUserMedia ||\r\n navigator.mozGetUserMedia ||\r\n navigator.msGetUserMedia\r\n )\r\n (mediasettings, resolve, reject);\r\n }\r\n\r\n }).catch(reject)\r\n\r\n })\r\n \r\n }\r\n \r\n self.get = function(mediasettings){\r\n\r\n return initMedia(mediasettings)\r\n\r\n }\r\n\r\n self.permissions = initPermissions\r\n\r\n}\r\n\r\n\r\nexport default Media","// Copied from https://github.com/chris-rudmin/Recorderjs\n\nexport default () => {\n let BYTES_PER_SAMPLE = 2\n\n let recorded = []\n\n function encode (buffer) {\n let length = buffer.length\n let data = new Uint8Array(length * BYTES_PER_SAMPLE)\n for (let i = 0; i < length; i++) {\n let index = i * BYTES_PER_SAMPLE\n let sample = buffer[i]\n if (sample > 1) {\n sample = 1\n } else if (sample < -1) {\n sample = -1\n }\n sample = sample * 32768\n data[index] = sample\n data[index + 1] = sample >> 8\n }\n recorded.push(data)\n }\n\n function dump (sampleRate) {\n let bufferLength = recorded.length ? recorded[0].length : 0\n let length = recorded.length * bufferLength\n let wav = new Uint8Array(44 + length)\n let view = new DataView(wav.buffer)\n\n // RIFF identifier 'RIFF'\n view.setUint32(0, 1380533830, false)\n // file length minus RIFF identifier length and file description length\n view.setUint32(4, 36 + length, true)\n // RIFF type 'WAVE'\n view.setUint32(8, 1463899717, false)\n // format chunk identifier 'fmt '\n view.setUint32(12, 1718449184, false)\n // format chunk length\n view.setUint32(16, 16, true)\n // sample format (raw)\n view.setUint16(20, 1, true)\n // channel count\n view.setUint16(22, 1, true)\n // sample rate\n view.setUint32(24, sampleRate, true)\n // byte rate (sample rate * block align)\n view.setUint32(28, sampleRate * BYTES_PER_SAMPLE, true)\n // block align (channel count * bytes per sample)\n view.setUint16(32, BYTES_PER_SAMPLE, true)\n // bits per sample\n view.setUint16(34, 8 * BYTES_PER_SAMPLE, true)\n // data chunk identifier 'data'\n view.setUint32(36, 1684108385, false)\n // data chunk length\n view.setUint32(40, length, true)\n\n // eslint-disable-next-line unicorn/no-for-loop\n for (let i = 0; i < recorded.length; i++) {\n wav.set(recorded[i], i * bufferLength + 44)\n }\n\n recorded = []\n postMessage(wav.buffer, [wav.buffer])\n }\n\n onmessage = e => {\n if (e.data[0] === 'encode') {\n encode(e.data[1])\n } else if (e.data[0] === 'dump') {\n dump(e.data[1])\n }\n }\n}\n","import waveEncoder from './wave-encoder/index.js'\n\nlet AudioContext = window.AudioContext || window.webkitAudioContext\n\nlet createWorker = fn => {\n let js = fn\n .toString()\n .replace(/^(\\(\\)\\s*=>|function\\s*\\(\\))\\s*{/, '')\n .replace(/}$/, '')\n let blob = new Blob([js])\n return new Worker(URL.createObjectURL(blob))\n}\n\nlet error = method => {\n let event = new Event('error')\n event.data = new Error('Wrong state for ' + method)\n return event\n}\n\nlet context\n\n/**\n * Audio Recorder with MediaRecorder API.\n *\n * @example\n * navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {\n * let recorder = new MediaRecorder(stream)\n * })\n */\nclass MediaRecorder {\n /**\n * @param {MediaStream} stream The audio stream to record.\n */\n constructor (stream, config = null) {\n /**\n * The `MediaStream` passed into the constructor.\n * @type {MediaStream}\n */\n this.stream = stream\n this.config = config\n /**\n * The current state of recording process.\n * @type {\"inactive\"|\"recording\"|\"paused\"}\n */\n this.state = 'inactive'\n\n this.em = document.createDocumentFragment()\n this.encoder = createWorker(MediaRecorder.encoder)\n\n let recorder = this\n this.encoder.addEventListener('message', e => {\n let event = new Event('dataavailable')\n event.data = new Blob([e.data], { type: recorder.mimeType })\n recorder.em.dispatchEvent(event)\n if (recorder.state === 'inactive') {\n recorder.em.dispatchEvent(new Event('stop'))\n }\n })\n }\n\n /**\n * Begins recording media.\n *\n * @param {number} [timeslice] The milliseconds to record into each `Blob`.\n * If this parameter isn’t included, single `Blob`\n * will be recorded.\n *\n * @return {undefined}\n *\n * @example\n * recordButton.addEventListener('click', () => {\n * recorder.start()\n * })\n */\n start (timeslice) {\n if (this.state !== 'inactive') {\n return this.em.dispatchEvent(error('start'))\n }\n\n this.state = 'recording'\n\n if (!context) {\n context = new AudioContext(this.config)\n }\n this.clone = this.stream.clone()\n this.input = context.createMediaStreamSource(this.clone)\n this.processor = context.createScriptProcessor(2048, 1, 1)\n\n this.encoder.postMessage(['init', context.sampleRate])\n\n this.processor.onaudioprocess = e => {\n if (this.state === 'recording') {\n this.encoder.postMessage(['encode', e.inputBuffer.getChannelData(0)])\n }\n }\n\n this.input.connect(this.processor)\n this.processor.connect(context.destination)\n\n this.em.dispatchEvent(new Event('start'))\n\n if (timeslice) {\n this.slicing = setInterval(() => {\n if (this.state === 'recording') this.requestData()\n }, timeslice)\n }\n\n return undefined\n }\n\n /**\n * Stop media capture and raise `dataavailable` event with recorded data.\n *\n * @return {undefined}\n *\n * @example\n * finishButton.addEventListener('click', () => {\n * recorder.stop()\n * })\n */\n stop () {\n if (this.state === 'inactive') {\n return this.em.dispatchEvent(error('stop'))\n }\n\n this.requestData()\n this.state = 'inactive'\n this.clone.getTracks().forEach(track => {\n track.stop()\n })\n this.processor.disconnect()\n this.input.disconnect()\n return clearInterval(this.slicing)\n }\n\n /**\n * Pauses recording of media streams.\n *\n * @return {undefined}\n *\n * @example\n * pauseButton.addEventListener('click', () => {\n * recorder.pause()\n * })\n */\n pause () {\n if (this.state !== 'recording') {\n return this.em.dispatchEvent(error('pause'))\n }\n\n this.state = 'paused'\n return this.em.dispatchEvent(new Event('pause'))\n }\n\n /**\n * Resumes media recording when it has been previously paused.\n *\n * @return {undefined}\n *\n * @example\n * resumeButton.addEventListener('click', () => {\n * recorder.resume()\n * })\n */\n resume () {\n if (this.state !== 'paused') {\n return this.em.dispatchEvent(error('resume'))\n }\n\n this.state = 'recording'\n return this.em.dispatchEvent(new Event('resume'))\n }\n\n /**\n * Raise a `dataavailable` event containing the captured media.\n *\n * @return {undefined}\n *\n * @example\n * this.on('nextData', () => {\n * recorder.requestData()\n * })\n */\n requestData () {\n if (this.state === 'inactive') {\n return this.em.dispatchEvent(error('requestData'))\n }\n\n return this.encoder.postMessage(['dump', context.sampleRate])\n }\n\n /**\n * Add listener for specified event type.\n *\n * @param {\"start\"|\"stop\"|\"pause\"|\"resume\"|\"dataavailable\"|\"error\"}\n * type Event type.\n * @param {function} listener The listener function.\n *\n * @return {undefined}\n *\n * @example\n * recorder.addEventListener('dataavailable', e => {\n * audio.src = URL.createObjectURL(e.data)\n * })\n */\n addEventListener (...args) {\n this.em.addEventListener(...args)\n }\n\n /**\n * Remove event listener.\n *\n * @param {\"start\"|\"stop\"|\"pause\"|\"resume\"|\"dataavailable\"|\"error\"}\n * type Event type.\n * @param {function} listener The same function used in `addEventListener`.\n *\n * @return {undefined}\n */\n removeEventListener (...args) {\n this.em.removeEventListener(...args)\n }\n\n /**\n * Calls each of the listeners registered for a given event.\n *\n * @param {Event} event The event object.\n *\n * @return {boolean} Is event was no canceled by any listener.\n */\n dispatchEvent (...args) {\n this.em.dispatchEvent(...args)\n }\n}\n\n/**\n * The MIME type that is being used for recording.\n * @type {string}\n */\nMediaRecorder.prototype.mimeType = 'audio/wav'\n\n/**\n * Returns `true` if the MIME type specified is one the polyfill can record.\n *\n * This polyfill supports `audio/wav` and `audio/mpeg`.\n *\n * @param {string} mimeType The mimeType to check.\n *\n * @return {boolean} `true` on `audio/wav` and `audio/mpeg` MIME type.\n */\nMediaRecorder.isTypeSupported = mimeType => {\n return MediaRecorder.prototype.mimeType === mimeType\n}\n\n/**\n * `true` if MediaRecorder can not be polyfilled in the current browser.\n * @type {boolean}\n *\n * @example\n * if (MediaRecorder.notSupported) {\n * showWarning('Audio recording is not supported in this browser')\n * }\n */\nMediaRecorder.notSupported = !navigator.mediaDevices || !AudioContext\n\n/**\n * Converts RAW audio buffer to compressed audio files.\n * It will be loaded to Web Worker.\n * By default, WAVE encoder will be used.\n * @type {function}\n *\n * @example\n * MediaRecorder.prototype.mimeType = 'audio/ogg'\n * MediaRecorder.encoder = oggEncoder\n */\nMediaRecorder.encoder = waveEncoder\n\nexport default MediaRecorder\n","\n\n\nexport default () => {\n importScripts(\n 'https://cdnjs.cloudflare.com/ajax/libs/lamejs/1.2.0/lame.min.js'\n )\n\n let CHANNELS = 1\n let KBPS = 128\n let DEFAULT_SAMPLE_RATE = 44100\n\n let encoder\n let recorded = new Int8Array()\n\n function concat (a, b) {\n if (b.length === 0) {\n return a\n }\n let c = new Int8Array(a.length + b.length)\n c.set(a)\n c.set(b, a.length)\n return c\n }\n\n function init (sampleRate) {\n encoder = new lamejs.Mp3Encoder(\n CHANNELS,\n sampleRate || DEFAULT_SAMPLE_RATE,\n KBPS\n )\n }\n\n function encode (buffer) {\n for (let i = 0; i < buffer.length; i++) {\n buffer[i] = buffer[i] * 32767.5\n }\n\n let buf = encoder.encodeBuffer(buffer)\n recorded = concat(recorded, buf)\n }\n\n function dump () {\n let buf = encoder.flush()\n recorded = concat(recorded, buf)\n let buffer = recorded.buffer\n recorded = new Int8Array()\n postMessage(buffer, [buffer])\n }\n\n onmessage = e => {\n if (e.data[0] === 'init') {\n init(e.data[1])\n } else if (e.data[0] === 'encode') {\n encode(e.data[1])\n } else {\n dump(e.data[1])\n }\n }\n}\n","\r\n\r\nimport MTRX from \"./mtrx.js\";\r\nimport Notifier from \"./notifier.js\";\r\nimport PNUser from \"./user/pnuser.js\";\r\nimport ApiWrapper from \"./api.js\";\r\nimport Pcrypto from \"./pcrypto.js\";\r\nimport listeners from './listeners'\r\nimport f from './functions'\r\nimport Media from './media'\r\n/*\r\nimport pcm from '@/application/utils/pcm.js'\r\nlet Mp3 = require('js-mp3');\r\n*/\r\n/*\r\nvar {register} = require('extendable-media-recorder')\r\nvar {connect} = require('extendable-media-recorder-wav-encoder')*/\r\n\r\n\r\nimport AudioRecorder from 'audio-recorder-polyfill'\r\nimport mpegEncoder from 'audio-recorder-polyfill/mpeg-encoder'\r\n\r\nAudioRecorder.encoder = mpegEncoder\r\nAudioRecorder.prototype.mimeType = 'audio/mpeg'\r\n\r\n\r\n\r\n\r\nclass Core {\r\n constructor(vm, p){\r\n if(!p) p = {}\r\n\r\n this.options = {\r\n listofproxies : p.listofproxies\r\n }\r\n\r\n if(!p.mtrx) p.mtrx = {}\r\n p.mtrx.baseUrl = 'https://' + p.domain\r\n\r\n if (p.mtrx.baseUrl == 'https://test.matrix.pocketnet.app'){\r\n \r\n this.options.burn = {\r\n v : 'minutes',\r\n w : 120,\r\n m : 30,\r\n b : 15\r\n }\r\n }\r\n else{\r\n this.options.burn = {\r\n v : 'days',\r\n w : 7,\r\n m : 2,\r\n b : 1\r\n }\r\n }\r\n\r\n \r\n\r\n this.apiHandlers = {\r\n error : function(){},\r\n success : function(){}\r\n }\r\n\r\n this.domain = p.domain\r\n\r\n this.vm = vm\r\n this.mtrx = new MTRX(this, p.mtrx)\r\n this.user = new PNUser(this, p.user || {})\r\n this.notifier = new Notifier(this, p.notifier || {})\r\n this.pcrypto = new Pcrypto(this, p.pcrypto || {})\r\n this.api = new ApiWrapper(this, p.servers)\r\n\r\n this.onlineListener = new listeners.online(this)\r\n this.focusListener = new listeners.focus(this)\r\n this.online = true\r\n this.focus = true\r\n this.store = vm.$store\r\n this.loading = true\r\n\r\n this.external = {}\r\n this.hiddenInParent = false\r\n\r\n this.customRecorderConnected = false\r\n\r\n this.pcrypto.init(this.user)\r\n\r\n this.media = new Media()\r\n this.audioContext = null\r\n\r\n }\r\n\r\n hideOptimization = function(v){\r\n\r\n //this.hideOptimization = v\r\n this.store.commit('hideOptimization', v)\r\n\r\n }\r\n\r\n hideInParent = function(v){\r\n this.hiddenInParent = v\r\n this.store.commit('hiddenInParent', v)\r\n\r\n\r\n /*if(!v)\r\n this.store.commit('wasunhidden', true)*/\r\n }\r\n\r\n canback = function(){\r\n return this.store.state.gallery ? false : true\r\n }\r\n\r\n update = function({block}){\r\n\r\n this.pcrypto.set.block(block)\r\n }\r\n\r\n logerror = function(type, data){\r\n\r\n\r\n if (window.POCKETNETINSTANCE){\r\n\r\n window.POCKETNETINSTANCE.Logger.error({\r\n err: type,\r\n payload: data,\r\n code: 402,\r\n });\r\n\r\n }\r\n }\r\n\r\n destroy = function(){\r\n this.store.commit('clearall')\r\n this.removeEvents()\r\n\r\n if(!this.vm.$route.name != 'chats')\r\n this.vm.$router.push('/chats').catch(e => {})\r\n\r\n this.user.destroy()\r\n this.mtrx.destroy()\r\n this.pcrypto.destroy()\r\n\r\n if (window.POCKETNETINSTANCE){\r\n window.POCKETNETINSTANCE.platform.matrixchat.unlink(this)\r\n }\r\n\r\n this.vm.$destroy();\r\n\r\n }\r\n\r\n init = function(){\r\n \r\n this.focusListener.init()\r\n this.onlineListener.init()\r\n\r\n this.initEvents()\r\n\r\n if (window.POCKETNETINSTANCE){\r\n window.POCKETNETINSTANCE.platform.matrixchat.link(this)\r\n }\r\n }\r\n \r\n\r\n setUnauthorized = function(v){\r\n this.unauthorized = v\r\n this.store.commit('SET_UNAUTHORIZED', v)\r\n }\r\n\r\n initWithUserBase = function(){\r\n\r\n this.loading = true\r\n\r\n return this.user.checkCredentials().then(state => {\r\n\r\n return this.user.userInfo()\r\n\r\n }).then(r => {\r\n\r\n if(!r){\r\n return Promise.reject('unknown')\r\n }\r\n\r\n if(r.deleted){\r\n return Promise.reject('deleted')\r\n }\r\n\r\n return this.pcrypto.prepare()\r\n\r\n }).then(r => {\r\n\r\n return this.mtrx.init()\r\n\r\n }).then(r => {\r\n\r\n this.loading = false\r\n this.setUnauthorized(null)\r\n\r\n this.pcrypto.helpers.checkuser()\r\n\r\n if (f.deep(this.user,'userinfo.name'))\r\n this.mtrx.client.setDisplayName(f.deep(this.user,'userinfo.name'))\r\n\r\n return Promise.resolve()\r\n\r\n }).catch(e => {\r\n\r\n console.log(\"E\", e)\r\n \r\n this.loading = false\r\n\r\n if(e == 'unauthorized' || e == 'unknown' || e == 'deleted'){\r\n this.setUnauthorized(e)\r\n }\r\n\r\n return Promise.resolve()\r\n\r\n })\r\n }\r\n\r\n initWithUser = function(credentials){\r\n\r\n\r\n this.user.setCredentials(credentials)\r\n\r\n return this.initWithUserBase().then(() => {\r\n return this.user.initKeysProcess()\r\n }).catch(e => {\r\n return Promise.resolve()\r\n })\r\n\r\n }\r\n\r\n waitonline = function(){\r\n\r\n if(this.online) return Promise.resolve()\r\n\r\n return new Promise((resolve, reject) => {\r\n\r\n f.retry(() => {\r\n return this.online;\r\n }, function () {\r\n\r\n resolve()\r\n\r\n }, 5)\r\n\r\n })\r\n\r\n\r\n }\r\n\r\n removeEvents = function(){\r\n delete this.focusListener.clbks.resume.core\r\n delete this.focusListener.clbks.pause.core\r\n delete this.onlineListener.clbks.online.core\r\n delete this.onlineListener.clbks.offline.core\r\n }\r\n\r\n initEvents = function(){\r\n this.focusListener.clbks.resume.core = (time) => {\r\n\r\n this.focus = this.focusListener.focus\r\n\r\n if(time > 60){\r\n }\r\n }\r\n\r\n this.focusListener.clbks.pause.core = () => {\r\n this.focus = this.focusListener.focus\r\n }\r\n\r\n this.onlineListener.clbks.online.core = (time) => {\r\n this.online = this.onlineListener.online\r\n }\r\n\r\n this.onlineListener.clbks.offline.core = () => {\r\n this.online = this.onlineListener.online\r\n }\r\n }\r\n\r\n externalLink = function(pobj){\r\n this.external = pobj\r\n\r\n }\r\n\r\n destroyExternalLink = function(){\r\n this.external = {}\r\n }\r\n\r\n currentTime = function () {\r\n var created = Math.floor((new Date().getTime()) / 1000)\r\n\r\n if (this.timeDifference) {\r\n created += this.timeDifference\r\n }\r\n\r\n return created;\r\n }\r\n\r\n wait = function(){\r\n return f.pretry(() => {\r\n\t\t\treturn !this.loading\r\n\t\t}).then(() => {\r\n\r\n\t\t\treturn Promise.resolve()\r\n\r\n\t\t})\r\n }\r\n\r\n joinRoom(roomid){\r\n return this.wait().then(() => {\r\n\r\n return this.mtrx.wait()\r\n\r\n }).then(() => {\r\n\r\n if (this.unauthorized){\r\n\r\n this.store.commit('JOINROOM', roomid)\r\n \r\n return Promise.reject(this.unauthorized)\r\n }\r\n\r\n return Promise.resolve()\r\n\r\n }).then(info => {\r\n\r\n if (this.store.state.chatsMap[roomid]){\r\n /// old chat\r\n this.vm.$router.push('/chat?id=' + roomid).catch(e => {})\r\n }\r\n else\r\n {\r\n this.store.commit('JOINROOM', roomid)\r\n this.vm.$router.push('/publicPreview?id=' + roomid).catch(e => {})\r\n }\r\n\r\n return Promise.resolve()\r\n })\r\n }\r\n\r\n connect(address){\r\n\r\n return this.wait().then(() => {\r\n\r\n return this.mtrx.wait()\r\n\r\n }).then(() => {\r\n\r\n if (this.unauthorized){\r\n\r\n this.store.commit('CONNECT', f.hexEncode(address))\r\n \r\n return Promise.reject(this.unauthorized)\r\n }\r\n\r\n else{\r\n return this.user.usersInfo([address], true)\r\n }\r\n\r\n }).then(info => {\r\n\r\n var roomId = this.mtrx.kit.tetatetid(info[0], this.user.userinfo)\r\n\r\n\r\n if(!roomId) return Promise.reject('roomId')\r\n\r\n if (this.store.state.chatsMap[roomId]){\r\n /// old chat\r\n\r\n this.gotoRoute('/chat?id=' + roomId)\r\n /*this.vm.$router.push('/chat?id=' + roomId).catch(e => {\r\n console.error('e', e)\r\n })*/\r\n }\r\n else\r\n {\r\n\r\n this.gotoRoute('/contact?id=' + f.hexEncode(address))\r\n //this.store.commit('CONTACT', roomId)\r\n //this.gotoRoute('/chat?id=' + roomId + '&u=' + f.hexEncode(address))\r\n\r\n }\r\n\r\n return Promise.resolve()\r\n })\r\n }\r\n\r\n cancelshare(){\r\n this.store.commit('SHARE', null)\r\n\r\n return Promise.resolve()\r\n }\r\n\r\n share(share){\r\n\t\tthis.store.commit('SHARE', share)\r\n\r\n this.vm.$router.push('/chats').catch(e => {})\r\n\r\n return Promise.resolve()\r\n\t}\r\n\r\n goto(roomId){\r\n\r\n this.cancelDefaultRoute = true;\r\n\r\n this.mtrx.wait().then(() => {\r\n this.vm.$router.push('/chat?id=' + roomId).catch(e => {});\r\n });\r\n }\r\n\r\n gotoRoute(route){\r\n\r\n this.cancelDefaultRoute = true;\r\n\r\n this.mtrx.wait().then(() => {\r\n this.vm.$router.push(route).catch(e => {});\r\n });\r\n }\r\n\r\n updateUser(){\r\n \r\n return this.user.userInfo(true).then(r => {\r\n\r\n /*if (this.unauthorized){\r\n return this.initWithUserBase()\r\n }*/\r\n \r\n })\r\n }\r\n\r\n isactive(){\r\n return this.vm.$store.state.minimized && this.vm.$store.state.active && this.vm.$store.state.pocketnet\r\n } \r\n\r\n sitemessage(title){\r\n\r\n var position = \"bottom-right\";\r\n\r\n if (this.vm.$store.state.mobile){\r\n position = 'top-left'\r\n }\r\n \r\n this.vm.$message({\r\n title: title,\r\n zIndex: 999,\r\n supportHTML: true,\r\n wrapperClassName: \"notificationWrapper\",\r\n position: position,\r\n type: 'info',\r\n duration : 2000\r\n })\r\n }\r\n\r\n menu(v){\r\n\r\n this.store.commit('SET_MENU', v ? {\r\n\t\t\titems : v.items,\r\n\t\t\titem : v.item,\r\n handler : v.handler\r\n\t\t} : null)\r\n }\r\n\r\n invitepnt(){\r\n\r\n var ui = f.deep(this, 'user.userinfo.source')\r\n\r\n if(ui){\r\n\r\n if (window.POCKETNETINSTANCE && window.POCKETNETINSTANCE.platform){\r\n \r\n if(this.backtoapp) this.backtoapp()\r\n\r\n window.POCKETNETINSTANCE.platform.ui.socialshare('welcome?connect=' + ui.address, {\r\n sharing : {\r\n image : '',\r\n images : [ui.i],\r\n title : this.vm.$i18n.t(\"caption.joinApp\"),\r\n html : {\r\n body : this.vm.$i18n.t(\"caption.joinApp\") + ' ' + this.vm.$i18n.t(\"caption.hasInvitedToJoin\"),\r\n preview : this.vm.$i18n.t(\"caption.joinApp\") + ' ' + this.vm.$i18n.t(\"caption.hasInvitedToJoin\")\r\n },\r\n \r\n text : {\r\n body : this.vm.$i18n.t(\"caption.joinApp\") + ' ' + this.vm.$i18n.t(\"caption.hasInvitedToJoin\"),\r\n preview : this.vm.$i18n.t(\"caption.joinApp\") + ' ' + this.vm.$i18n.t(\"caption.hasInvitedToJoin\")\r\n }\r\n \r\n },\r\n embedding : {\r\n type : 'connect',\r\n id : ui.address\r\n }\r\n })\r\n\r\n }\r\n else{\r\n var l = 'https://bastyon.com/welcome?connect=' + ui.address\r\n\r\n f.copytext(l)\r\n\r\n this.sitemessage('The link was copied successfully')\r\n }\r\n\r\n }\r\n\r\n else{\r\n this.sitemessage('The error was occuried')\r\n }\r\n\r\n \r\n }\r\n\r\n async convertAudioToBase64(blob) {\r\n const reader = new FileReader()\r\n reader.readAsDataURL(blob)\r\n return new Promise(resolve => {\r\n reader.onloadend = () => {\r\n resolve(reader.result)\r\n }\r\n })\r\n }\r\n\r\n /*async connectCustomRecorder() {\r\n\r\n if (this.customRecorderConnected) return\r\n this.customRecorderConnected = true\r\n \r\n await register(await connect());\r\n \r\n }*/\r\n\r\n /*mp3ToWav(base64Audio){\r\n\r\n var mp3ArrayBuffer = f._base64ToArrayBuffer(base64Audio.split(',')[1])\r\n\r\n var decoder = Mp3.newDecoder(mp3ArrayBuffer);\r\n var pcmArrayBuffer = decoder.decode();\r\n\r\n var dataURI = new pcm({channels: 1, rate: 8000, depth: 8}).toWav(pcmArrayBuffer).encode();\r\n\r\n return dataURI\r\n\r\n }*/\r\n\r\n initMediaRecorder() {\r\n\r\n if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\r\n\r\n\r\n return this.media.get({ audio: true }).then(stream => {\r\n\r\n let mediaRecorder = new AudioRecorder(stream, { audioBitsPerSecond : 32000 })\r\n \r\n return mediaRecorder\r\n \r\n }).catch(function (err) {\r\n return Promise.reject(err)\r\n });\r\n\r\n } else {\r\n return Promise.reject()\r\n }\r\n }\r\n\r\n getAudioContext(){\r\n\r\n if(this.audioContext && this.audioContext.state != 'closed') {\r\n\r\n\r\n if(this.audioContext.state === \"suspended\") this.audioContext.resume()\r\n\r\n\r\n\r\n return this.audioContext\r\n }\r\n else{\r\n }\r\n\r\n this.audioContext = new (window.AudioContext || window.webkitAudioContext)() || null;\r\n\r\n if(f.isios() && window.unmute){\r\n unmute(this.audioContext, false, false);\r\n }\r\n\r\n return this.audioContext\r\n }\r\n}\r\n\r\nexport default Core\r\n","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:{'bin' : _vm.pocketnet, 'bout' : !_vm.pocketnet, minimized: _vm.minimized, fix : _vm.pocketnet, active: _vm.active},attrs:{\"id\":\"preloader\",\"platform\":_vm.platform}},[_vm._m(0)])}\nvar staticRenderFns = [function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"variant \"},[_c('div',{staticClass:\"iospreloadercenter\"},[_c('div',{staticClass:\"spinner-eff spinner-eff-3\"},[_c('div',{staticClass:\"circle circle-1\"}),_c('div',{staticClass:\"circle circle-2\"}),_c('div',{staticClass:\"circle circle-3\"})])])])}]\n\nexport { render, staticRenderFns }","import { mapState } from 'vuex';\r\nimport f from '@/application/functions'\r\nexport default {\r\n name: 'preloader',\r\n props: {\r\n },\r\n\r\n computed : mapState({\r\n pocketnet: state => state.pocketnet,\r\n minimized : state => state.minimized,\r\n active : state => state.active,\r\n platform : function(){\r\n return f.deep(window, 'device.platform') || 'browser'\r\n },\r\n })\r\n}","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=3e6353d6&scoped=true&\"\nimport script from \"./index.js?vue&type=script&lang=js&\"\nexport * from \"./index.js?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index_ex.sass?vue&type=style&index=0&id=3e6353d6&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\nvar style1 = require(\"./index.sass?vue&type=style&index=1&id=3e6353d6&scoped=true&lang=sass&\")\nif (style1.__inject__) style1.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"3e6353d6\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:{'bin' : _vm.pocketnet, 'bout' : !_vm.pocketnet, minimized: _vm.minimized, fix : _vm.pocketnet, active: _vm.active},attrs:{\"id\":\"wai-fixedmessageicon\"}},[_c('div',{staticClass:\"wrapper\"},[_c('div',{staticClass:\"table\"},[_c('div',{staticClass:\"cell\"},[(_vm.icon)?_c('div',{staticClass:\"iconWrapper\"},[_c('sweetalert',{attrs:{\"icon\":_vm.icon}})],1):_vm._e(),(_vm.message)?_c('div',{staticClass:\"message\"},[_c('div',[_vm._v(_vm._s(_vm.message))])]):_vm._e()])])])])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"sa\",style:(_vm.cssVars)},[(_vm.isIcon('error'))?_c('div',{staticClass:\"sa-error\"},[_vm._m(0),_c('div',{staticClass:\"sa-error-placeholder\"}),_c('div',{staticClass:\"sa-error-fix\"})]):(_vm.isIcon('warning'))?_c('div',{staticClass:\"sa-warning\"},[_c('div',{staticClass:\"sa-warning-body\"}),_c('div',{staticClass:\"sa-warning-dot\"})]):(_vm.isIcon('info'))?_c('div',{staticClass:\"sa-info\"},[_c('div',{staticClass:\"sa-info-body\"}),_c('div',{staticClass:\"sa-info-dot\"})]):(_vm.isIcon('loading'))?_c('div',{staticClass:\"sa-loading\"},[_c('div',{staticClass:\"sa-loading-body\"})]):_c('div',{staticClass:\"sa-success\"},[_c('div',{staticClass:\"sa-success-tip\"}),_c('div',{staticClass:\"sa-success-long\"}),_c('div',{staticClass:\"sa-success-placeholder\"}),_c('div',{staticClass:\"sa-success-fix\"})])])}\nvar staticRenderFns = [function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"sa-error-x\"},[_c('div',{staticClass:\"sa-error-left\"}),_c('div',{staticClass:\"sa-error-right\"})])}]\n\nexport { render, staticRenderFns }","\r\n \r\n
\r\n\r\n
\r\n\r\n
\r\n\r\n
\r\n\r\n
\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n","import mod from \"-!../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../node_modules/babel-loader/lib/index.js!../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./icon.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../node_modules/babel-loader/lib/index.js!../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./icon.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./icon.vue?vue&type=template&id=0635047f&scoped=true&\"\nimport script from \"./icon.vue?vue&type=script&lang=js&\"\nexport * from \"./icon.vue?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./icon.vue?vue&type=style&index=0&id=0635047f&scoped=true&lang=scss&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"0635047f\",\n null\n ,true\n)\n\nexport default component.exports","import { mapState } from 'vuex';\r\nimport sweetalert from '@/editedplugins/vue-sweetalert-icons/src/components/icon.vue'\r\nexport default {\r\n name: 'fixedmessageicon',\r\n props: {\r\n \r\n },\r\n\r\n components : {\r\n sweetalert\r\n },\r\n\r\n data : function(){\r\n\r\n return {\r\n loading : false\r\n }\r\n\r\n },\r\n\r\n created : () => {\r\n\r\n },\r\n\r\n watch: {\r\n icon : {\r\n immediate: true,\r\n handler(){\r\n this.init()\r\n }\r\n }\r\n },\r\n\r\n\r\n computed: mapState({\r\n auth : state => state.auth,\r\n icon : function(){\r\n return this.$store.state.icon ? this.$store.state.icon.icon : null\r\n },\r\n\r\n message : function(){\r\n return this.$store.state.icon ? this.$store.state.icon.message : null\r\n },\r\n\r\n \r\n pocketnet: state => state.pocketnet,\r\n minimized: state => state.minimized,\r\n active : state => state.active,\r\n }),\r\n\r\n methods : {\r\n init : function(){\r\n var t = this\r\n\r\n const timeout = this.$store.state.icon?.timeout;\r\n\r\n if(this.$store.state.icon.manual) return\r\n\r\n setTimeout(function(){\r\n\r\n t.$store.commit('icon', null)\r\n\r\n }, timeout || 2000)\r\n }\r\n },\r\n}","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=1cf419f0&scoped=true&\"\nimport script from \"./index.js?vue&type=script&lang=js&\"\nexport * from \"./index.js?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.sass?vue&type=style&index=0&id=1cf419f0&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"1cf419f0\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('span',{attrs:{\"id\":\"wai-date\"}},[_vm._v(_vm._s(_vm.label))])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","import { mapState } from 'vuex';\r\n\r\nexport default {\r\n name: 'date',\r\n props: ['date'],\r\n\r\n computed: mapState({\r\n auth : state => state.auth,\r\n\r\n label : function(){\r\n\r\n moment.locale(this.$i18n.locale)\r\n\r\n return moment(moment.utc(this.date).toDate()).local().fromNow();\r\n\r\n }\r\n }),\r\n}","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=eb4df516&scoped=true&\"\nimport script from \"./index.js?vue&type=script&lang=js&\"\nexport * from \"./index.js?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.sass?vue&type=style&index=0&id=eb4df516&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"eb4df516\",\n null\n ,true\n)\n\nexport default component.exports","var render = function (_h,_vm) {var _c=_vm._c;return _c('div',{staticClass:\"userpic\"},[_c('div',{staticClass:\"userpicSquareWrapper\"},[_c('div',{staticClass:\"userpicSquareInnerWrapper\"},[_c('div',{staticClass:\"userpicSquareInnerWrapper\",class:_vm.props.status},[(_vm.props.userinfo.image)?_c('bgimage',{attrs:{\"src\":_vm.props.userinfo.image}}):_vm._e(),(!_vm.props.userinfo.image && _vm.props.userinfo.name && (_vm.props.status != 'blocked' && _vm.props.status != 'invite' && _vm.props.status != 'ban'))?_c('div',{staticClass:\"charAvatar\"},[_c('span',[_vm._v(_vm._s(_vm.props.userinfo.name.charAt(0)))])]):_vm._e(),_c('div',{staticClass:\"statusIcon\"},[(_vm.props.status == 'blocked' || _vm.props.status == 'ban')?_c('i',{staticClass:\"fas fa-ban\"}):_vm._e(),(_vm.props.status == 'invite')?_c('i',{staticClass:\"fas fa-user-plus\"}):_vm._e()])],1)])])])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\r\nexport default {\r\n name: 'userpic',\r\n props: {\r\n userinfo: {\r\n type : Object,\r\n default : {}\r\n },\r\n status : ''\r\n }\r\n}\r\n","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=5034d1e2&scoped=true&functional=true&\"\nimport script from \"./index.js?vue&type=script&lang=js&\"\nexport * from \"./index.js?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.sass?vue&type=style&index=0&id=5034d1e2&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n true,\n injectStyles,\n \"5034d1e2\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.users)?_c('div',{staticClass:\"userspic\",class:{oneuser : _vm.users && _vm.users.length === 1}},[(_vm.users.length === 0)?_c('userpic',{attrs:{\"userinfo\":_vm.single,\"status\":_vm.single.status}}):_vm._e(),(_vm.users.length === 1)?_c('userpic',{attrs:{\"status\":_vm.status[_vm.users[0].id],\"userinfo\":_vm.users[0],\"unseen\":_vm.unseen}}):_vm._e(),(_vm.users.length > 1)?_c('many',{attrs:{\"slidesPerView\":_vm.slidesPerView,\"status\":_vm.status,\"userinfo\":_vm.users,\"unseen\":_vm.unseen}}):_vm._e(),(_vm.unseen)?_c('div',{staticClass:\"unseen\"},[_vm._v(\" \"+_vm._s(_vm.unseen > 99 ? '99' : _vm.unseen)+\" \")]):_vm._e()],1):_vm._e()}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","import many from '@/components/assets/userspic/many.vue'\r\n\r\nexport default {\r\n name: 'userspic',\r\n props: {\r\n users: Array,\r\n single: {},\r\n unseen: Number,\r\n slidesPerView: Number,\r\n status : {\r\n type : Object,\r\n default : {}\r\n }\r\n \r\n },\r\n\r\n data : function(){\r\n return {}\r\n },\r\n components: {\r\n many\r\n },\r\n\r\n}\r\n","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=792279b0&scoped=true&\"\nimport script from \"./index.js?vue&type=script&lang=js&\"\nexport * from \"./index.js?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.vue?vue&type=style&index=0&id=792279b0&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"792279b0\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"bgimage\",class:{loaded: _vm.loaded, hasimage : _vm.src},style:('background-image:url('+_vm.imageSrc+'); background-size: cover; background-position: center center; background-repeat: no-repeat')},[_vm._t(\"cnt\")],2)}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\r\n \r\n \r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n","import mod from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./bgimage.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./bgimage.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./bgimage.vue?vue&type=template&id=5d20f73c&scoped=true&\"\nimport script from \"./bgimage.vue?vue&type=script&lang=js&\"\nexport * from \"./bgimage.vue?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./bgimage.vue?vue&type=style&index=0&id=5d20f73c&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"5d20f73c\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{attrs:{\"id\":\"wai-logotype\"}},[_c('div',{staticClass:\"items\"},[_c('div',{staticClass:\"item\"},[_c('div',{staticClass:\"logo\"},[_c('img',{attrs:{\"src\":'img/ldpiwide-' + _vm.themeL + '.png'}})])])])])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","import { mapState } from 'vuex';\r\n\r\nvar bwl = {\r\n black : 'black',\r\n white : 'white',\r\n classic : 'white'\r\n\r\n}\r\n\r\nexport default {\r\n name: 'wai-logotype',\r\n props: {\r\n },\r\n\r\n data : function(){\r\n\r\n return {\r\n loading : false\r\n }\r\n\r\n },\r\n\r\n created : () => {\r\n\r\n },\r\n\r\n watch: {\r\n //$route: 'getdata'\r\n },\r\n\r\n \r\n\r\n computed: mapState({\r\n auth : state => state.auth,\r\n\r\n themeL : function(state){\r\n return bwl[state.theme] || 'white'\r\n }\r\n }),\r\n\r\n methods : {\r\n \r\n },\r\n}","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=e33cd7cc&scoped=true&\"\nimport script from \"./index.js?vue&type=script&lang=js&\"\nexport * from \"./index.js?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.sass?vue&type=style&index=0&id=e33cd7cc&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"e33cd7cc\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"outer-div\",class:{'bin' : _vm.pocketnet, 'bout' : !_vm.pocketnet, minimized: _vm.minimized, active: _vm.active, mobile: _vm.mobile},on:{\"click\":function($event){$event.stopPropagation();}}},[(_vm.menuIsVisible && !_vm.hiddenInParent)?_c('div',{staticClass:\"dropdown\",class:{visible: _vm.menuIsVisible}},[_c('div',{staticClass:\"backgr\",on:{\"click\":function($event){return _vm.hidePopup()}}}),_c('div',{directives:[{name:\"click-outside\",rawName:\"v-click-outside\",value:(_vm.hidePopup),expression:\"hidePopup\"}],staticClass:\"menuwrapper\"},[_c('simpleMenu',{attrs:{\"items\":_vm.menuItems},scopedSlots:_vm._u([{key:\"default\",fn:function(slotProps){return [_vm._t(\"default\",function(){return [_c('div',{staticClass:\"menu-item\",on:{\"click\":function($event){return _vm.menuItemClick(slotProps.item)}}},[_c('div',{staticClass:\"iconWrapper\"},[(slotProps.item.icon)?_c('i',{class:slotProps.item.icon}):_vm._e()]),_c('div',{staticClass:\"title\"},[_vm._v(\" \"+_vm._s(slotProps.item.title)+\" \")])])]},{\"item\":slotProps.item})]}}],null,true)}),_c('div',{staticClass:\"cancelWrapper\"},[_c('div',{staticClass:\"menu-item\",on:{\"click\":function($event){return _vm.hidePopup()}}},[_c('div',{staticClass:\"iconWrapper\"}),_c('div',{staticClass:\"title\"},[_vm._v(_vm._s(_vm.$t(\"cancel\")))])])])],1)]):_vm._e(),_c('div',{staticClass:\"dropDownIcon\",on:{\"click\":_vm.onClickHandler}},[_c('i',{class:'icon ' + (_vm.icon || 'fas fa-ellipsis-h')})])])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","import simpleMenu from '@/components/assets/simpleMenu/simpleMenu.vue';\r\nimport { mapState } from 'vuex';\r\nexport default {\r\n name: 'dropdownMenu',\r\n props: {\r\n menuItems: {\r\n type: Array,\r\n required: true\r\n },\r\n\r\n rowObject: {\r\n type: Object,\r\n },\r\n\r\n icon : String\r\n },\r\n\r\n components: {\r\n simpleMenu,\r\n },\r\n\r\n data : function(){\r\n\r\n return {\r\n loading : false,\r\n menuIsVisible: false,\r\n }\r\n\r\n },\r\n\r\n watch: {\r\n menuIsVisible: function(newValue) {\r\n this.$emit('menuIsVisible', newValue);\r\n }\r\n },\r\n\r\n computed: {\r\n\r\n dropdownWidthInner(){\r\n return this.dropdownWidth;\r\n },\r\n \r\n ...mapState({\r\n pocketnet: state => state.pocketnet,\r\n minimized : state => state.minimized,\r\n mobile : state => state.mobile,\r\n active: state => state.active,\r\n hiddenInParent : state => state.hiddenInParent\r\n })\r\n },\r\n\r\n methods : {\r\n menuItemClick(item) {\r\n this.$emit('itemClicked', item, this.rowObject, {\r\n hidePopup : this.hidePopup,\r\n showPopup : this.showPopup\r\n });\r\n },\r\n onClickHandler() {\r\n this.menuIsVisible = !this.menuIsVisible;\r\n\r\n\r\n },\r\n hidePopup() {\r\n this.menuIsVisible = false;\r\n\r\n },\r\n showPopup() {\r\n \r\n this.menuIsVisible = true;\r\n\r\n\r\n }\r\n },\r\n}","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=e4f39dca&scoped=true&\"\nimport script from \"./index.js?vue&type=script&lang=js&\"\nexport * from \"./index.js?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.sass?vue&type=style&index=0&id=e4f39dca&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"e4f39dca\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"back\",on:{\"click\":_vm.click}},[_c('div',{staticClass:\"iconbutton\"},[_c('i',{class:(_vm.icon || 'fas fa-angle-left')})])])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\r\n \r\n\r\n\r\n\r\n\r\n","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=7e97eec1&scoped=true&\"\nimport script from \"./index.vue?vue&type=script&lang=js&\"\nexport * from \"./index.vue?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.vue?vue&type=style&index=0&id=7e97eec1&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"7e97eec1\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"fixedOnPageTop\",class:{'bin' : _vm.pocketnet, 'bout' : !_vm.pocketnet, minimized: _vm.minimized, fix : _vm.pocketnet, active: _vm.active, unauthorized: _vm.unauthorized, modalShowed : _vm.modalShowed ? true : false, mobile: _vm.mobile},attrs:{\"id\":\"maincontent\"},on:{\"mouseenter\":_vm.mouseenter,\"mouseleave\":_vm.mouseleave}},[_c('div',{staticClass:\"headerSpacerWrapper\"},[_c('div',{staticClass:\"headerSpacerWrapperOvf\"},[_c('div',{ref:\"scrollable\",staticClass:\"headerSpacer\"},[_vm._t(\"content\",function(){return [_vm._v(\" \")]})],2)]),_c('pmenu'),(_vm.modalShowed && _vm.modalShowed.data && !_vm.hiddenInParent)?_c('modal',{on:{\"close\":_vm.closeModal},scopedSlots:_vm._u([{key:\"header\",fn:function(){return [_vm._v(_vm._s(_vm.modalShowed.caption))]},proxy:true},{key:\"body\",fn:function(){return [_c('div',{staticClass:\"modalcommoncontent\"},[(_vm.modalShowed.type == 'complain')?_c('complain',{attrs:{\"p\":_vm.modalShowed.data}}):_vm._e(),(_vm.modalShowed.type == 'contact')?_c('contact',{attrs:{\"contact\":_vm.modalShowed.data.contact}}):_vm._e(),(_vm.modalShowed.type == 'showuserselect')?_c('contacts',{attrs:{\"users\":_vm.modalShowed.data.users,\"mode\":\"Select\"},on:{\"close\":_vm.closeModal,\"select\":function (contact) {_vm.modalShowed.data.userselected(contact); _vm.closeModal()}}}):_vm._e()],1)]},proxy:true},{key:\"footer\",fn:function(){return undefined},proxy:true}],null,false,3972288297)}):_vm._e(),(!_vm.unauthorized && _vm.rbackexp)?_c('div',{staticClass:\"expandp\",on:{\"click\":_vm.setactive,\"mousemove\":_vm.effect}},[_vm._m(0)]):_vm._e()],1),(_vm.iconshow)?_c('transition',{attrs:{\"name\":\"fade\"}},[_c('fixedmessageicon')],1):_vm._e()],1)}\nvar staticRenderFns = [function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"etablew\"},[_c('div',{staticClass:\"etable table\"},[_c('div',[_c('i',{staticClass:\"fas fa-expand-arrows-alt\"})])])])}]\n\nexport { render, staticRenderFns }","import { mapState } from 'vuex';\r\n\r\nexport default {\r\n name: 'maincontent',\r\n props: {\r\n rbackexp : Boolean\r\n },\r\n\r\n components : {\r\n\r\n 'contact': () => import('@/components/contact/index.vue'),\r\n 'contacts': () => import('@/components/contacts/list/index.vue'),\r\n 'complain': () => import('@/components/complain/index.vue')\r\n },\r\n\r\n data : function(){\r\n\r\n return {\r\n loading : false\r\n }\r\n\r\n },\r\n\r\n created : () => {\r\n\r\n },\r\n\r\n watch: {\r\n //$route: 'getdata'\r\n },\r\n\r\n \r\n\r\n computed: mapState({\r\n auth : state => state.auth,\r\n iconshow: function() {\r\n\t\t\treturn this.$store.state.icon ? true : false\r\n\t\t},\r\n pocketnet: state => state.pocketnet,\r\n minimized: state => state.minimized,\r\n active : state => state.active,\r\n modalShowed : state => state.modalShowed,\r\n hiddenInParent : state => state.hiddenInParent,\r\n mobile : state => state.mobile,\r\n unauthorized : state => state.unauthorized\r\n }),\r\n\r\n methods : {\r\n setactive : function(){\r\n this.$store.commit('active', true)\r\n this.$store.commit('blockactive', {value : true, item : 'main'})\r\n this.$store.commit('setiteraction', true)\r\n },\r\n mouseenter : function(){\r\n /*this.$store.commit('active', true)\r\n this.$store.commit('blockactive', {value : true, item : 'main'})*/\r\n },\r\n\r\n mouseleave : function(){\r\n\r\n if (this.$store.state.autohide){\r\n this.$store.commit('active', false)\r\n }\r\n this.$store.commit('blockactive', {value : false, item : 'main'})\r\n },\r\n\r\n effect : function(e){\r\n /*const x = e.pageX - e.target.offsetLeft\r\n const y = e.pageY - e.target.offsetTop\r\n\r\n e.target.style.setProperty('--x', `${ x }px`)\r\n e.target.style.setProperty('--y', `${ y }px`)*/\r\n },\r\n\r\n closeModal : function(){\r\n this.$store.commit('setmodal', null)\r\n },\r\n\r\n scroll : function(v){\r\n this.$refs['scrollable'].scrollTop = v || 0\r\n },\r\n \r\n \r\n },\r\n}","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=a8a70f9c&scoped=true&\"\nimport script from \"./index.js?vue&type=script&lang=js&\"\nexport * from \"./index.js?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.sass?vue&type=style&index=0&id=a8a70f9c&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"a8a70f9c\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:{'bin' : _vm.pocketnet, 'bout' : !_vm.pocketnet, minimized: _vm.minimized, fix : _vm.pocketnet, active: _vm.active},attrs:{\"id\":\"search\"}},[_c('div',{staticClass:\"searchWrapper\"},[_c('div',{staticClass:\"inputWrapper\"},[_c('input',{ref:\"input\",attrs:{\"placeholder\":_vm.placeholder || this.$i18n.t('caption.search'),\"type\":\"text\"},domProps:{\"value\":_vm.searchTxt},on:{\"keyup\":_vm.change,\"input\":_vm.change,\"focus\":_vm.focused,\"blur\":_vm.blured}})]),(!_vm.searchTxt)?_c('div',{staticClass:\"iconWrapper\"},[_c('i',{staticClass:\"fas fa-search\"})]):_vm._e(),(_vm.searchTxt)?_c('div',{staticClass:\"iconWrapper\",on:{\"click\":_vm.clear}},[_c('i',{staticClass:\"fas fa-times\"})]):_vm._e()])])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","import {mapState} from 'vuex';\r\n// TODO IGOR' SEARCH ALL COMPONENTS\r\nexport default {\r\n name: 'search',\r\n props: {\r\n placeholder: String,\r\n minimize: {\r\n type: Boolean,\r\n default: false\r\n }\r\n },\r\n\r\n data: function () {\r\n\r\n return {\r\n loading: false,\r\n isTyping: false,\r\n searchTxt: ''\r\n }\r\n\r\n },\r\n\r\n created: () => {\r\n\r\n },\r\n\r\n watch: {\r\n searchTxt : {\r\n handler : _.debounce(function() {\r\n\r\n var text = this.searchTxt.toLowerCase()\r\n this.$emit('search', text)\r\n \r\n }, 500)\r\n }\r\n },\r\n computed: mapState({\r\n auth: state => state.auth,\r\n pocketnet: state => state.pocketnet,\r\n minimized: state => state.minimized,\r\n active: function (state) {\r\n return state.active || !this.minimize\r\n },\r\n }),\r\n\r\n methods: {\r\n change : function(event){\r\n this.searchTxt = event.target.value\r\n },\r\n\r\n clear : function(event){\r\n this.searchTxt = ''\r\n }, \r\n \r\n clickicon: function () {\r\n this.$refs['input'].focus()\r\n },\r\n\r\n blured: function () {\r\n this.$store.commit('blockactive', {value: false, item: 'input'})\r\n },\r\n\r\n focused: function () {\r\n this.$store.commit('blockactive', {value: true, item: 'input'})\r\n }\r\n },\r\n}","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=1774f2a8&scoped=true&\"\nimport script from \"./index.js?vue&type=script&lang=js&\"\nexport * from \"./index.js?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.sass?vue&type=style&index=0&id=1774f2a8&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"1774f2a8\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _vm._m(0)}\nvar staticRenderFns = [function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{attrs:{\"id\":\"linepreloader\"}},[_c('span'),_c('span'),_c('span')])}]\n\nexport { render, staticRenderFns }","import { mapState } from 'vuex';\r\n\r\nexport default {\r\n name: 'linepreloader',\r\n props: {\r\n },\r\n}","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=bcf20e38&scoped=true&\"\nimport script from \"./index.js?vue&type=script&lang=js&\"\nexport * from \"./index.js?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.sass?vue&type=style&index=0&id=bcf20e38&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"bcf20e38\",\n null\n ,true\n)\n\nexport default component.exports","\r\n \r\n
\r\n
\r\n
\r\n
\r\n\r\n
\r\n\r\n
\r\n\r\n \r\n \r\n \r\n
\r\n \r\n\r\n\r\n \r\n\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\n\r\n\r\n","import mod from \"-!../node_modules/cache-loader/dist/cjs.js??ref--13-0!../node_modules/thread-loader/dist/cjs.js!../node_modules/babel-loader/lib/index.js!../node_modules/cache-loader/dist/cjs.js??ref--1-0!../node_modules/vue-loader/lib/index.js??vue-loader-options!./App.vue?vue&type=script&lang=js&shadow\"; export default mod; export * from \"-!../node_modules/cache-loader/dist/cjs.js??ref--13-0!../node_modules/thread-loader/dist/cjs.js!../node_modules/babel-loader/lib/index.js!../node_modules/cache-loader/dist/cjs.js??ref--1-0!../node_modules/vue-loader/lib/index.js??vue-loader-options!./App.vue?vue&type=script&lang=js&shadow\"","import { render, staticRenderFns } from \"./App.vue?vue&type=template&id=01d24e5e&shadow\"\nimport script from \"./App.vue?vue&type=script&lang=js&shadow\"\nexport * from \"./App.vue?vue&type=script&lang=js&shadow\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./editedplugins/vue-m-message/dist/index.css?vue&type=style&index=0&lang=css&shadow\")\nif (style0.__inject__) style0.__inject__(context)\nvar style1 = require(\"./index.sass?vue&type=style&index=1&lang=sass&shadow\")\nif (style1.__inject__) style1.__inject__(context)\nvar style2 = require(\"./App.vue?vue&type=style&index=2&lang=css&shadow\")\nif (style2.__inject__) style2.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n null,\n null\n ,true\n)\n\nexport default component.exports","import './setPublicPath'\nimport Vue from 'vue'\nimport wrap from '@vue/web-component-wrapper'\n\n// runtime shared by every component chunk\nimport 'css-loader/dist/runtime/api.js'\nimport 'vue-style-loader/lib/addStylesShadow'\nimport 'vue-loader/lib/runtime/componentNormalizer'\n\nimport matrixElement from '~root/src/App.vue?shadow'\nwindow.customElements.define('matrix-element', wrap(Vue, matrixElement))","var MD5 = require('md5.js')\n\nmodule.exports = function (buffer) {\n return new MD5().update(buffer).digest()\n}\n","module.exports=function(e){var r={};function n(t){if(r[t])return r[t].exports;var a=r[t]={i:t,l:!1,exports:{}};return e[t].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&\"object\"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,\"default\",{enumerable:!0,value:e}),2&r&&\"string\"!=typeof e)for(var a in e)n.d(t,a,function(r){return e[r]}.bind(null,a));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,\"a\",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p=\"\",n(n.s=0)}([function(e,r,n){\"use strict\";n.r(r),n.d(r,\"validateHTMLColorName\",(function(){return l})),n.d(r,\"validateHTMLColorSpecialName\",(function(){return i})),n.d(r,\"validateHTMLColorHex\",(function(){return u})),n.d(r,\"validateHTMLColorRgb\",(function(){return d})),n.d(r,\"validateHTMLColorHsl\",(function(){return f})),n.d(r,\"validateHTMLColorHwb\",(function(){return h})),n.d(r,\"validateHTMLColorLab\",(function(){return g})),n.d(r,\"validateHTMLColor\",(function(){return m}));const t=e=>e&&\"string\"==typeof e,a=[\"AliceBlue\",\"AntiqueWhite\",\"Aqua\",\"Aquamarine\",\"Azure\",\"Beige\",\"Bisque\",\"Black\",\"BlanchedAlmond\",\"Blue\",\"BlueViolet\",\"Brown\",\"BurlyWood\",\"CadetBlue\",\"Chartreuse\",\"Chocolate\",\"Coral\",\"CornflowerBlue\",\"Cornsilk\",\"Crimson\",\"Cyan\",\"DarkBlue\",\"DarkCyan\",\"DarkGoldenrod\",\"DarkGray\",\"DarkGreen\",\"DarkKhaki\",\"DarkMagenta\",\"DarkOliveGreen\",\"DarkOrange\",\"DarkOrchid\",\"DarkRed\",\"DarkSalmon\",\"DarkSeaGreen\",\"DarkSlateBlue\",\"DarkSlateGray\",\"DarkTurquoise\",\"DarkViolet\",\"DeepPink\",\"DeepSkyBlue\",\"DimGray\",\"DodgerBlue\",\"FireBrick\",\"FloralWhite\",\"ForestGreen\",\"Fuchsia\",\"Gainsboro\",\"GhostWhite\",\"Gold\",\"Goldenrod\",\"Gray\",\"Green\",\"GreenYellow\",\"HoneyDew\",\"HotPink\",\"IndianRed\",\"Indigo\",\"Ivory\",\"Khaki\",\"Lavender\",\"LavenderBlush\",\"LawnGreen\",\"LemonChiffon\",\"LightBlue\",\"LightCoral\",\"LightCyan\",\"LightGoldenrodYellow\",\"LightGray\",\"LightGreen\",\"LightPink\",\"LightSalmon\",\"LightSalmon\",\"LightSeaGreen\",\"LightSkyBlue\",\"LightSlateGray\",\"LightSteelBlue\",\"LightYellow\",\"Lime\",\"LimeGreen\",\"Linen\",\"Magenta\",\"Maroon\",\"MediumAquamarine\",\"MediumBlue\",\"MediumOrchid\",\"MediumPurple\",\"MediumSeaGreen\",\"MediumSlateBlue\",\"MediumSlateBlue\",\"MediumSpringGreen\",\"MediumTurquoise\",\"MediumVioletRed\",\"MidnightBlue\",\"MintCream\",\"MistyRose\",\"Moccasin\",\"NavajoWhite\",\"Navy\",\"OldLace\",\"Olive\",\"OliveDrab\",\"Orange\",\"OrangeRed\",\"Orchid\",\"PaleGoldenrod\",\"PaleGreen\",\"PaleTurquoise\",\"PaleVioletRed\",\"PapayaWhip\",\"PeachPuff\",\"Peru\",\"Pink\",\"Plum\",\"PowderBlue\",\"Purple\",\"RebeccaPurple\",\"Red\",\"RosyBrown\",\"RoyalBlue\",\"SaddleBrown\",\"Salmon\",\"SandyBrown\",\"SeaGreen\",\"SeaShell\",\"Sienna\",\"Silver\",\"SkyBlue\",\"SlateBlue\",\"SlateGray\",\"Snow\",\"SpringGreen\",\"SteelBlue\",\"Tan\",\"Teal\",\"Thistle\",\"Tomato\",\"Turquoise\",\"Violet\",\"Wheat\",\"White\",\"WhiteSmoke\",\"Yellow\",\"YellowGreen\"],o=[\"currentColor\",\"inherit\",\"transparent\"],l=e=>{let r=!1;return t(e)&&a.map(n=>(e.toLowerCase()===n.toLowerCase()&&(r=!0),null)),r},i=e=>{let r=!1;return t(e)&&o.map(n=>(e.toLowerCase()===n.toLowerCase()&&(r=!0),null)),r},u=e=>{if(t(e)){const r=/^#([\\da-f]{3}){1,2}$|^#([\\da-f]{4}){1,2}$/i;return e&&r.test(e)}},d=e=>{if(t(e)){const r=/(rgb)a?\\((\\s*\\d+%?\\s*?,?\\s*){2}(\\s*\\d+%?\\s*?,?\\s*\\)?)(\\s*,?\\s*\\/?\\s*(0?\\.?\\d+%?\\s*)?|1|0)?\\)$/i;return e&&r.test(e)}},s=\"(([0-9]|[1-9][0-9]|100)%)\",c=`\\\\s*?\\\\)?)(\\\\s*?(\\\\/?)\\\\s+${`(((${s}))|(0?(\\\\.\\\\d+)?)|1))?`}\\\\s*?\\\\)$`,f=e=>{if(t(e)){const r=new RegExp(`(hsl)a?\\\\((\\\\s*?(${\"(-?([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-5][0-9]|360)(deg)?)\"}|${\"(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-9][0-9]|400)gra)\"}|${\"((([0-5])?\\\\.\\\\d+|6\\\\.([0-9]|1[0-9]|2[0-8])|[0-6])rad)\"}|${\"((0?(\\\\.\\\\d+)?|1)turn)\"})((\\\\s*,\\\\s*)|(\\\\s+)))(\\\\s*?(0|${s})((\\\\s*,\\\\s*)|(\\\\s+)))(\\\\s*?(0|${s})\\\\s*?\\\\)?)(\\\\s*?(\\\\/?|,?)\\\\s*?(((${s}))|(0?(\\\\.\\\\d+)?)|1))?\\\\)$`);return e&&r.test(e)}},h=e=>{if(t(e)){const r=new RegExp(`(hwb\\\\(\\\\s*?${\"(-?([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-5][0-9]|360)(deg)?)\"}\\\\s+)((0|${s})\\\\s+)((0|${s})${c}`);return e&&r.test(e)}},g=e=>{if(t(e)){const r=\"(-?(([0-9]|[1-9][0-9]|1[0-5][0-9])(\\\\.\\\\d+)??|160))\",n=new RegExp(`(lab\\\\(\\\\s*?((\\\\d*(\\\\.\\\\d+)?)%)\\\\s+${r}\\\\s+${r}${c}`);return e&&n.test(e)}},m=e=>!!(e&&u(e)||d(e)||f(e)||h(e)||g(e));r.default=e=>!!(e&&u(e)||l(e)||i(e)||d(e)||f(e)||h(e)||g(e))}]);","// Imports\nvar ___CSS_LOADER_API_IMPORT___ = require(\"../../../node_modules/css-loader/dist/runtime/api.js\");\nexports = ___CSS_LOADER_API_IMPORT___(false);\n// Module\nexports.push([module.id, \"#teamroom.mobile[data-v-9b340a7a]{margin-bottom:10px}#teamroom[data-v-9b340a7a]:hover{cursor:pointer}#teamroom .teamChatWrapper[data-v-9b340a7a]{padding:.5em .25em;display:flex;align-items:center;transition:.3s}#teamroom .teamChatWrapper .iconWrapper[data-v-9b340a7a]{width:44px;display:flex;align-items:center;min-width:44px;height:44px;position:relative}#teamroom .teamChatWrapper .iconWrapper .logo[data-v-9b340a7a]{background-size:cover;background-position:50%;background-repeat:no-repeat;height:44px;width:44px;margin-left:0;margin-top:0;position:absolute;background:rgb(var(--text-on-bg-ac-color));border-radius:50%;padding-top:8px;text-align:center}#teamroom .teamChatWrapper .iconWrapper .logo img[data-v-9b340a7a]{width:28px;height:28px;margin:0 auto}#teamroom .teamChatWrapper .iconWrapper .unseen[data-v-9b340a7a]{background:rgba(var(--color-bg-ac),.9);color:rgb(var(--text-on-bg-ac-color));position:absolute;width:22px;height:22px;right:-10%;top:-10%;line-height:22px;text-align:center;font-weight:500;border-radius:50%;z-index:2;font-size:.6em}#teamroom .teamChatWrapper .infoWrapper[data-v-9b340a7a]{padding-left:.5em}#teamroom .teamChatWrapper .infoWrapper>div[data-v-9b340a7a]{display:flex;align-content:center}#teamroom .teamChatWrapper .infoWrapper .infoName span[data-v-9b340a7a]{font-size:.9em;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-weight:700;display:inline-block;max-width:190px;color:rgb(var(--text-color))}#teamroom .teamChatWrapper .infoWrapper .previewMessage[data-v-9b340a7a]{display:flex;justify-content:flex-start;align-items:center;width:100%}#teamroom .teamChatWrapper .infoWrapper .previewMessage span[data-v-9b340a7a]{display:block;color:rgb(var(--color-txt-gray));font-size:.9em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;text-align:left;max-width:210px}#teamroom.minimized:not(.active) .teamChatWrapper[data-v-9b340a7a]{padding:.5em 0}\", \"\"]);\n// Exports\nmodule.exports = exports;\n","module.exports = function (bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n","/*\n* loglevel - https://github.com/pimterry/loglevel\n*\n* Copyright (c) 2013 Tim Perry\n* Licensed under the MIT license.\n*/\n(function (root, definition) {\n \"use strict\";\n if (typeof define === 'function' && define.amd) {\n define(definition);\n } else if (typeof module === 'object' && module.exports) {\n module.exports = definition();\n } else {\n root.log = definition();\n }\n}(this, function () {\n \"use strict\";\n\n // Slightly dubious tricks to cut down minimized file size\n var noop = function() {};\n var undefinedType = \"undefined\";\n var isIE = (typeof window !== undefinedType) && (typeof window.navigator !== undefinedType) && (\n /Trident\\/|MSIE /.test(window.navigator.userAgent)\n );\n\n var logMethods = [\n \"trace\",\n \"debug\",\n \"info\",\n \"warn\",\n \"error\"\n ];\n\n // Cross-browser bind equivalent that works at least back to IE6\n function bindMethod(obj, methodName) {\n var method = obj[methodName];\n if (typeof method.bind === 'function') {\n return method.bind(obj);\n } else {\n try {\n return Function.prototype.bind.call(method, obj);\n } catch (e) {\n // Missing bind shim or IE8 + Modernizr, fallback to wrapping\n return function() {\n return Function.prototype.apply.apply(method, [obj, arguments]);\n };\n }\n }\n }\n\n // Trace() doesn't print the message in IE, so for that case we need to wrap it\n function traceForIE() {\n if (console.log) {\n if (console.log.apply) {\n console.log.apply(console, arguments);\n } else {\n // In old IE, native console methods themselves don't have apply().\n Function.prototype.apply.apply(console.log, [console, arguments]);\n }\n }\n if (console.trace) console.trace();\n }\n\n // Build the best logging method possible for this env\n // Wherever possible we want to bind, not wrap, to preserve stack traces\n function realMethod(methodName) {\n if (methodName === 'debug') {\n methodName = 'log';\n }\n\n if (typeof console === undefinedType) {\n return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives\n } else if (methodName === 'trace' && isIE) {\n return traceForIE;\n } else if (console[methodName] !== undefined) {\n return bindMethod(console, methodName);\n } else if (console.log !== undefined) {\n return bindMethod(console, 'log');\n } else {\n return noop;\n }\n }\n\n // These private functions always need `this` to be set properly\n\n function replaceLoggingMethods(level, loggerName) {\n /*jshint validthis:true */\n for (var i = 0; i < logMethods.length; i++) {\n var methodName = logMethods[i];\n this[methodName] = (i < level) ?\n noop :\n this.methodFactory(methodName, level, loggerName);\n }\n\n // Define log.log as an alias for log.debug\n this.log = this.debug;\n }\n\n // In old IE versions, the console isn't present until you first open it.\n // We build realMethod() replacements here that regenerate logging methods\n function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {\n return function () {\n if (typeof console !== undefinedType) {\n replaceLoggingMethods.call(this, level, loggerName);\n this[methodName].apply(this, arguments);\n }\n };\n }\n\n // By default, we use closely bound real methods wherever possible, and\n // otherwise we wait for a console to appear, and then try again.\n function defaultMethodFactory(methodName, level, loggerName) {\n /*jshint validthis:true */\n return realMethod(methodName) ||\n enableLoggingWhenConsoleArrives.apply(this, arguments);\n }\n\n function Logger(name, defaultLevel, factory) {\n var self = this;\n var currentLevel;\n defaultLevel = defaultLevel == null ? \"WARN\" : defaultLevel;\n\n var storageKey = \"loglevel\";\n if (typeof name === \"string\") {\n storageKey += \":\" + name;\n } else if (typeof name === \"symbol\") {\n storageKey = undefined;\n }\n\n function persistLevelIfPossible(levelNum) {\n var levelName = (logMethods[levelNum] || 'silent').toUpperCase();\n\n if (typeof window === undefinedType || !storageKey) return;\n\n // Use localStorage if available\n try {\n window.localStorage[storageKey] = levelName;\n return;\n } catch (ignore) {}\n\n // Use session cookie as fallback\n try {\n window.document.cookie =\n encodeURIComponent(storageKey) + \"=\" + levelName + \";\";\n } catch (ignore) {}\n }\n\n function getPersistedLevel() {\n var storedLevel;\n\n if (typeof window === undefinedType || !storageKey) return;\n\n try {\n storedLevel = window.localStorage[storageKey];\n } catch (ignore) {}\n\n // Fallback to cookies if local storage gives us nothing\n if (typeof storedLevel === undefinedType) {\n try {\n var cookie = window.document.cookie;\n var location = cookie.indexOf(\n encodeURIComponent(storageKey) + \"=\");\n if (location !== -1) {\n storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];\n }\n } catch (ignore) {}\n }\n\n // If the stored level is not valid, treat it as if nothing was stored.\n if (self.levels[storedLevel] === undefined) {\n storedLevel = undefined;\n }\n\n return storedLevel;\n }\n\n function clearPersistedLevel() {\n if (typeof window === undefinedType || !storageKey) return;\n\n // Use localStorage if available\n try {\n window.localStorage.removeItem(storageKey);\n return;\n } catch (ignore) {}\n\n // Use session cookie as fallback\n try {\n window.document.cookie =\n encodeURIComponent(storageKey) + \"=; expires=Thu, 01 Jan 1970 00:00:00 UTC\";\n } catch (ignore) {}\n }\n\n /*\n *\n * Public logger API - see https://github.com/pimterry/loglevel for details\n *\n */\n\n self.name = name;\n\n self.levels = { \"TRACE\": 0, \"DEBUG\": 1, \"INFO\": 2, \"WARN\": 3,\n \"ERROR\": 4, \"SILENT\": 5};\n\n self.methodFactory = factory || defaultMethodFactory;\n\n self.getLevel = function () {\n return currentLevel;\n };\n\n self.setLevel = function (level, persist) {\n if (typeof level === \"string\" && self.levels[level.toUpperCase()] !== undefined) {\n level = self.levels[level.toUpperCase()];\n }\n if (typeof level === \"number\" && level >= 0 && level <= self.levels.SILENT) {\n currentLevel = level;\n if (persist !== false) { // defaults to true\n persistLevelIfPossible(level);\n }\n replaceLoggingMethods.call(self, level, name);\n if (typeof console === undefinedType && level < self.levels.SILENT) {\n return \"No console available for logging\";\n }\n } else {\n throw \"log.setLevel() called with invalid level: \" + level;\n }\n };\n\n self.setDefaultLevel = function (level) {\n defaultLevel = level;\n if (!getPersistedLevel()) {\n self.setLevel(level, false);\n }\n };\n\n self.resetLevel = function () {\n self.setLevel(defaultLevel, false);\n clearPersistedLevel();\n };\n\n self.enableAll = function(persist) {\n self.setLevel(self.levels.TRACE, persist);\n };\n\n self.disableAll = function(persist) {\n self.setLevel(self.levels.SILENT, persist);\n };\n\n // Initialize with the right level\n var initialLevel = getPersistedLevel();\n if (initialLevel == null) {\n initialLevel = defaultLevel;\n }\n self.setLevel(initialLevel, false);\n }\n\n /*\n *\n * Top-level API\n *\n */\n\n var defaultLogger = new Logger();\n\n var _loggersByName = {};\n defaultLogger.getLogger = function getLogger(name) {\n if ((typeof name !== \"symbol\" && typeof name !== \"string\") || name === \"\") {\n throw new TypeError(\"You must supply a name when creating a logger.\");\n }\n\n var logger = _loggersByName[name];\n if (!logger) {\n logger = _loggersByName[name] = new Logger(\n name, defaultLogger.getLevel(), defaultLogger.methodFactory);\n }\n return logger;\n };\n\n // Grab the current global log variable in case of overwrite\n var _log = (typeof window !== undefinedType) ? window.log : undefined;\n defaultLogger.noConflict = function() {\n if (typeof window !== undefinedType &&\n window.log === defaultLogger) {\n window.log = _log;\n }\n\n return defaultLogger;\n };\n\n defaultLogger.getLoggers = function getLoggers() {\n return _loggersByName;\n };\n\n // ES6 default export, for compatibility\n defaultLogger['default'] = defaultLogger;\n\n return defaultLogger;\n}));\n","// Ported from https://github.com/mafintosh/pump with\n// permission from the author, Mathias Buus (@mafintosh).\n'use strict';\n\nvar eos;\n\nfunction once(callback) {\n var called = false;\n return function () {\n if (called) return;\n called = true;\n callback.apply(void 0, arguments);\n };\n}\n\nvar _require$codes = require('../../../errors').codes,\n ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,\n ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;\n\nfunction noop(err) {\n // Rethrow the error if it exists to avoid swallowing it\n if (err) throw err;\n}\n\nfunction isRequest(stream) {\n return stream.setHeader && typeof stream.abort === 'function';\n}\n\nfunction destroyer(stream, reading, writing, callback) {\n callback = once(callback);\n var closed = false;\n stream.on('close', function () {\n closed = true;\n });\n if (eos === undefined) eos = require('./end-of-stream');\n eos(stream, {\n readable: reading,\n writable: writing\n }, function (err) {\n if (err) return callback(err);\n closed = true;\n callback();\n });\n var destroyed = false;\n return function (err) {\n if (closed) return;\n if (destroyed) return;\n destroyed = true; // request.destroy just do .end - .abort is what we want\n\n if (isRequest(stream)) return stream.abort();\n if (typeof stream.destroy === 'function') return stream.destroy();\n callback(err || new ERR_STREAM_DESTROYED('pipe'));\n };\n}\n\nfunction call(fn) {\n fn();\n}\n\nfunction pipe(from, to) {\n return from.pipe(to);\n}\n\nfunction popCallback(streams) {\n if (!streams.length) return noop;\n if (typeof streams[streams.length - 1] !== 'function') return noop;\n return streams.pop();\n}\n\nfunction pipeline() {\n for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {\n streams[_key] = arguments[_key];\n }\n\n var callback = popCallback(streams);\n if (Array.isArray(streams[0])) streams = streams[0];\n\n if (streams.length < 2) {\n throw new ERR_MISSING_ARGS('streams');\n }\n\n var error;\n var destroys = streams.map(function (stream, i) {\n var reading = i < streams.length - 1;\n var writing = i > 0;\n return destroyer(stream, reading, writing, function (err) {\n if (!error) error = err;\n if (err) destroys.forEach(call);\n if (reading) return;\n destroys.forEach(call);\n callback(error);\n });\n });\n return streams.reduce(pipe);\n}\n\nmodule.exports = pipeline;","// style-loader: Adds some css to the DOM by adding a \n","import mod from \"-!../../cache-loader/dist/cjs.js??ref--13-0!../../thread-loader/dist/cjs.js!../../babel-loader/lib/index.js!../../cache-loader/dist/cjs.js??ref--1-0!../../vue-loader/lib/index.js??vue-loader-options!./ClipLoader.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../cache-loader/dist/cjs.js??ref--13-0!../../thread-loader/dist/cjs.js!../../babel-loader/lib/index.js!../../cache-loader/dist/cjs.js??ref--1-0!../../vue-loader/lib/index.js??vue-loader-options!./ClipLoader.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./ClipLoader.vue?vue&type=template&id=7edc50d8&\"\nimport script from \"./ClipLoader.vue?vue&type=script&lang=js&\"\nexport * from \"./ClipLoader.vue?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./ClipLoader.vue?vue&type=style&index=0&lang=css&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n null,\n null\n ,true\n)\n\nexport default component.exports","\r\n \r\n \r\n {{preview.name}}
\r\n {{preview.size}}
\r\n \r\n\r\n","import mod from \"-!../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../node_modules/babel-loader/lib/index.js!../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../node_modules/babel-loader/lib/index.js!../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=3d50eb11&\"\nimport script from \"./index.vue?vue&type=script&lang=js&\"\nexport * from \"./index.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"listPreview\"},[(_vm.urlpreview && _vm.metaPreviewLink)?_c('div',{staticClass:\"previewMessage\"},[(_vm.senderName)?_c('span',{staticClass:\"sname txt\"},[_vm._v(_vm._s(_vm.senderName)+\" \")]):_vm._e(),_c('span',{staticClass:\"linkTitle txt\"},[_vm._v(\"sent link: \"+_vm._s(_vm.meta['og:title'])+\" \")]),(_vm.meta['og:site_name'] === 'Pocketnet')?_c('span',{staticClass:\"pocketnetLink\"},[_vm._v(\" \"+_vm._s(_vm.meta['og:site_name'])+\" \")]):_c('span',[_vm._v(\" \"+_vm._s(_vm.meta['og:site_name'])+\" \")])]):_vm._e(),(_vm.content.msgtype === 'm.file')?_c('div',{staticClass:\"previewMessage\"},[(_vm.senderName)?_c('span',{staticClass:\"sname txt\"},[_vm._v(_vm._s(_vm.senderName)+\" \")]):_vm._e(),_c('span',{staticClass:\"txt\"},[_vm._v(\" sent file: \"+_vm._s(JSON.parse(_vm.content.body).name)+\" \")])]):_vm._e(),(_vm.content.msgtype === 'm.bad.encrypted')?_c('div',{staticClass:\"previewMessage\"},[_c('span',[_vm._v(\" \"+_vm._s(_vm.$t(\"caption.unabletoDecrypt\"))+\" \")])]):_vm._e(),(_vm.event.event.type === 'm.room.redaction')?_c('div',{staticClass:\"previewMessage\"},[_c('span',{staticClass:\"txt\"},[_c('i',{staticClass:\"fas fa-eraser\"}),_vm._v(\" \"+_vm._s(_vm.$t(\"caption.messageDeleted\"))+\" \")])]):_vm._e(),(_vm.event.event.type === 'm.room.power_levels')?_c('div',{staticClass:\"previewMessage\"},[(_vm.senderName)?_c('span',{staticClass:\"txt sname\"},[_vm._v(_vm._s(_vm.senderName)+\" \")]):_vm._e(),_c('span',{staticClass:\"txt\"},[_vm._v(\" \"+_vm._s(_vm.powerLevels)+\" \")])]):_vm._e(),(_vm.content.msgtype === 'm.image')?_c('div',{staticClass:\"previewMessage\"},[(_vm.senderName)?_c('span',{staticClass:\"txt sname\"},[_vm._v(_vm._s(_vm.senderName)+\" \")]):_vm._e(),_c('span',{staticClass:\"txt\"},[_vm._v(_vm._s(_vm.$t(\"caption.sentImage\")))])]):_vm._e(),(_vm.content.msgtype === 'm.audio')?_c('div',{staticClass:\"previewMessage\"},[(_vm.senderName)?_c('span',{staticClass:\"txt sname\"},[_vm._v(_vm._s(_vm.senderName)+\" \")]):_vm._e(),_c('span',{staticClass:\"txt\"},[_vm._v(_vm._s(_vm.$t(\"caption.sentVoiceMessage\")))])]):_vm._e(),((_vm.content.msgtype === 'm.text') && !_vm.urlpreview)?_c('div',{staticClass:\"previewMessage\"},[(_vm.senderName && _vm.senderName!= 'You')?_c('span',{staticClass:\"txt sname\"},[_vm._v(_vm._s(_vm.senderName)+\": \")]):_vm._e(),_c('span',{staticClass:\"txt\"},[_c('IncomingMessage',{attrs:{\"message\":_vm.content.body}})],1)]):_vm._e(),(_vm.content.msgtype === 'm.encrypted' && !_vm.urlpreview)?_c('div',{staticClass:\"previewMessage\"},[(_vm.senderName && _vm.senderName!= 'You')?_c('span',{staticClass:\"txt sname\"},[_vm._v(_vm._s(_vm.senderName)+\": \")]):_vm._e(),_c('span',{staticClass:\"txt\"},[_c('IncomingMessage',{attrs:{\"message\":_vm.decryptEvent.body}})],1)]):_vm._e(),(_vm.content.membership === 'invite')?_c('div',{staticClass:\"invitedEvent\"},[(_vm.tetatetchat)?_c('span',{staticClass:\"txt\"},[_vm._v(_vm._s(_vm.$t(\"caption.invitationToChat\")))]):_vm._e(),(!_vm.tetatetchat)?_c('span',{staticClass:\"txt\"},[_vm._v(_vm._s(_vm.$t(\"caption.invitationToRoom\")))]):_vm._e()]):_vm._e(),(_vm.content.membership === 'leave')?_c('div',{staticClass:\"previewMessage\"},[(_vm.senderName)?_c('span',{staticClass:\"txt sname\"},[_vm._v(_vm._s(_vm.senderName)+\": \")]):_vm._e(),_c('span',{staticClass:\"txt sname\"},[_vm._v(\" \"+_vm._s(_vm.name)+\" \")]),_c('span',{staticClass:\"txt\"},[_vm._v(_vm._s(_vm.$t(\"caption.leftChat\")))])]):_vm._e(),(_vm.content.membership === 'ban')?_c('div',[(_vm.senderName)?_c('span',{staticClass:\"txt sname\"},[_vm._v(_vm._s(_vm.senderName)+\" \")]):_vm._e(),_vm._v(\" \"),_c('span',{staticClass:\"txt\"},[_vm._v(\"banned \"+_vm._s(_vm.content.displayname))])]):_vm._e(),(_vm.content.membership === 'join' && _vm.event.getSender() !== _vm.userId)?_c('div',{staticClass:\"invitedEvent\"},[(_vm.senderName)?_c('span',{staticClass:\"txt sname\"},[_vm._v(_vm._s(_vm.senderName)+\" \")]):_vm._e(),_c('span',{staticClass:\"txt\"},[_vm._v(_vm._s(_vm.$t(\"caption.joined\")))])]):_vm._e(),(_vm.content.name)?_c('div',[_c('span',{staticClass:\"txt\"},[_vm._v(_vm._s(_vm.$t(\"caption.chatRenamed\"))+\" \"),_c('b',[_vm._v(_vm._s(_vm.content.name))])])]):_vm._e(),(_vm.content.topic)?_c('div',[_c('span',{staticClass:\"txt\"},[_vm._v(_vm._s(_vm.$t(\"caption.chatTopic\"))+\" \"),_c('b',[_vm._v(_vm._s(_vm.content.topic.replace(/_/g, ' ')))])])]):_vm._e(),(_vm.readed)?_c('div',{staticClass:\"statusWrapper\"},[(_vm.my)?_c('div',{staticClass:\"my\"},[_c('i',{staticClass:\"fas fa-check-double\"})]):_vm._e()]):_vm._e()])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('label',_vm._l((_vm.chunks),function(chunk,index){return _c('label',{key:index,attrs:{\"chunks\":_vm.chunks}},[(chunk.id)?_c('label',{staticClass:\"likelink\",on:{\"click\":function($event){return _vm.show(chunk)}}},[_vm._v(\"@\"+_vm._s(chunk.name))]):_c('label',[_vm._v(_vm._s(chunk))])])}),0)}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\r\n \r\n\r\n\r\n\r\n\r\n","import mod from \"-!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../../node_modules/babel-loader/lib/index.js!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./incomingMessage.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../../node_modules/babel-loader/lib/index.js!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./incomingMessage.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./incomingMessage.vue?vue&type=template&id=6b3704ba&scoped=true&\"\nimport script from \"./incomingMessage.vue?vue&type=script&lang=js&\"\nexport * from \"./incomingMessage.vue?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./incomingMessage.vue?vue&type=style&index=0&id=6b3704ba&lang=sass&scoped=true&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"6b3704ba\",\n null\n ,true\n)\n\nexport default component.exports","\r\n \r\n\r\n\r\n
\r\n\r\n {{ senderName }} \r\n sent link: {{ meta['og:title'] }} \r\n\r\n \r\n {{ meta['og:site_name'] }}\r\n \r\n \r\n {{ meta['og:site_name'] }}\r\n \r\n
\r\n\r\n
\r\n {{ senderName }} \r\n \r\n sent file: {{ JSON.parse(content.body).name }}\r\n \r\n
\r\n\r\n
\r\n \r\n {{ $t(\"caption.unabletoDecrypt\") }}\r\n \r\n
\r\n\r\n
\r\n \r\n {{ $t(\"caption.messageDeleted\") }}\r\n \r\n
\r\n
\r\n {{ senderName }} \r\n \r\n {{ powerLevels }}\r\n \r\n
\r\n\r\n
\r\n {{ senderName }} {{ $t(\"caption.sentImage\") }}\r\n
\r\n\r\n
\r\n {{ senderName }} {{ $t(\"caption.sentVoiceMessage\") }}\r\n
\r\n\r\n\r\n
\r\n\r\n {{ senderName }}: \r\n
\r\n\r\n
\r\n {{senderName}}: \r\n\r\n
\r\n\r\n
\r\n {{ $t(\"caption.invitationToChat\") }}\r\n {{ $t(\"caption.invitationToRoom\") }}\r\n
\r\n\r\n
\r\n {{ senderName }}: \r\n {{name}} \r\n {{ $t(\"caption.leftChat\") }}\r\n
\r\n
\r\n {{senderName}} banned {{content.displayname}}\r\n
\r\n
\r\n {{ senderName }} {{ $t(\"caption.joined\") }}\r\n
\r\n\r\n
\r\n {{ $t(\"caption.chatRenamed\") }} {{content.name}}\r\n
\r\n
\r\n {{ $t(\"caption.chatTopic\") }} {{content.topic.replace(/_/g, ' ') }}\r\n
\r\n\r\n
\r\n\r\n
\r\n\r\n\r\n\r\n","import mod from \"-!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../../node_modules/babel-loader/lib/index.js!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../../node_modules/babel-loader/lib/index.js!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=ba5ac396&scoped=true&\"\nimport script from \"./index.vue?vue&type=script&lang=js&\"\nexport * from \"./index.vue?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.sass?vue&type=style&index=0&id=ba5ac396&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"ba5ac396\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"urlMessage\",attrs:{\"id\":\"url\"}},[(_vm.urltype!= 'impty' && !_vm.error)?_c('div',{staticClass:\"urlwrapper\"},[(!_vm.loading)?_c('metaMessage',{ref:\"metamessage\",attrs:{\"type\":_vm.urltype,\"name\":_vm.meta['og:site_name'],\"title\":_vm.meta['og:title'],\"description\":_vm.meta['og:description'],\"image\":_vm.previewImageUrl,\"url\":_vm.url,\"h\":_vm.meta['og:image:height'],\"w\":_vm.meta['og:image:width']},on:{\"updatedSize\":_vm.updatedSize}}):_c('div',[_c('div',{staticClass:\"preloaderWrapperLocal\"},[_c('linepreloader')],1)])],1):_vm._e()])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\r\n \r\n\r\n\r\n\r\n\r\n","import mod from \"-!../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../node_modules/babel-loader/lib/index.js!../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../node_modules/babel-loader/lib/index.js!../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=791cf1f7&scoped=true&\"\nimport script from \"./index.vue?vue&type=script&lang=js&\"\nexport * from \"./index.vue?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.vue?vue&type=style&index=0&id=791cf1f7&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"791cf1f7\",\n null\n ,true\n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"voiceMessage\",class:{playing:_vm.isPlaying}},[_c('div',{staticClass:\"voiceMessage_wrapper\"},[_c('button',{staticClass:\"voiceMessage_toggle\",class:{encrypted: _vm.encrypted},on:{\"touchend\":_vm.audioToggle,\"click\":_vm.audioToggleClick}},[_c('i',{class:_vm.isPlaying ? 'fas fa-pause': 'fas fa-play'})]),_c('div',{staticClass:\"voiceMessage_graph\"},[_c('canvas',{ref:\"canvas\",attrs:{\"width\":\"100\",\"height\":\"50\"},on:{\"mousedown\":_vm.goTo}})]),_c('div',{staticClass:\"voiceMessage_options\"},[(!_vm.error)?_c('span',[_vm._v(_vm._s(_vm.getDurationString))]):_vm._e(),(_vm.error)?_c('i',{staticClass:\"fas fa-exclamation-circle\"}):_vm._e()]),(_vm.encrypted && !_vm.error)?_c('div',{staticClass:\"encsign\"},[_c('i',{staticClass:\"fas fa-lock\"})]):_vm._e()])])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\r\n \r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n {{ getDurationString }}\r\n \r\n \r\n
\r\n\r\n
\r\n\r\n
\r\n
\r\n\r\n\r\n\r\n\r\n","import mod from \"-!../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../node_modules/babel-loader/lib/index.js!../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../node_modules/babel-loader/lib/index.js!../../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=0438bc11&scoped=true&\"\nimport script from \"./index.vue?vue&type=script&lang=js&\"\nexport * from \"./index.vue?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.vue?vue&type=style&index=0&id=0438bc11&scoped=true&lang=scss&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"0438bc11\",\n null\n ,true\n)\n\nexport default component.exports","import actions from \"@/components/events/event/actions/index.vue\";\r\nimport filePreview from \"@/components/events/previews/filePreview/index.vue\";\r\nimport fileMessage from \"@/components/events/event/fileMessage/index.vue\";\r\nimport listPreview from \"@/components/events/event/message/listPreview/index.vue\";\r\nimport f from '@/application/functions'\r\nimport url from '@/components/events/event/url/index.vue'\r\nimport imagesLoaded from 'vue-images-loaded'\r\nimport dummypreviews from \"@/components/chats/dummypreviews\";\r\nimport IncomingMessage from \"./incomingMessage/incomingMessage.vue\"\r\nimport VoiceMessage from '@/components/events/event/VoiceMessage';\r\n\r\nexport default {\r\n name: 'eventsMessage',\r\n props: {\r\n decryptEvent: {},\r\n origin: Object,\r\n prevevent : Object,\r\n event: Object,\r\n preview: Boolean,\r\n userinfo: Object,\r\n readed: Object,\r\n downloaded: Boolean,\r\n baseImg: {\r\n type: String,\r\n default: 'empty'\r\n },\r\n filePreview: Object,\r\n imgEvent: {},\r\n add_image: Function,\r\n goToGallery: Function,\r\n chat: Object,\r\n encrypted: false,\r\n encryptedData: Boolean,\r\n decryptedInfo: null,\r\n error: String,\r\n withImage: Boolean,\r\n reference: Object,\r\n last : Boolean,\r\n showmyicontrue : false,\r\n fromreference : Boolean,\r\n multiSelect: {\r\n default: false,\r\n type: Boolean,\r\n },\r\n selectedMessages: {\r\n default: [],\r\n type: Array,\r\n },\r\n isRemoveSelectedMessages: false,\r\n audioBuffer : null\r\n },\r\n directives: {\r\n imagesLoaded\r\n },\r\n\r\n data: function () {\r\n\r\n return {\r\n referenceshowed : false,\r\n }\r\n\r\n },\r\n components: {\r\n actions,\r\n filePreview,\r\n fileMessage,\r\n listPreview,\r\n url,\r\n dummypreviews,\r\n IncomingMessage,\r\n VoiceMessage,\r\n },\r\n watch : {\r\n isRemoveSelectedMessages: {\r\n immediate: true,\r\n handler: function () {\r\n if (this.isRemoveSelectedMessages) {\r\n for (let i = 0; i < this.selectedMessages.length; i++) {\r\n if (\r\n this.selectedMessages[i].message_id === this.origin.event.event_id\r\n ) {\r\n this.$emit('remove');\r\n\r\n return this.core.mtrx.client.redactEvent(\r\n this.chat.roomId,\r\n this.origin.event.event_id,\r\n null,\r\n {\r\n reason: 'messagedeleting',\r\n }\r\n );\r\n }\r\n }\r\n this.$emit('messagesIsDeleted', true);\r\n }\r\n },\r\n },\r\n readyToRender : {\r\n immediate : true,\r\n handler : function(){\r\n if(this.readyToRender) this.$emit('readyToRender')\r\n }\r\n }\r\n },\r\n computed: {\r\n showburn : function(){ \r\n\r\n if(new Date() < new Date(2021,11,28)) {\r\n return ''\r\n }\r\n\r\n if( - moment().diff(this.willburn, this.core.options.burn.v) < this.core.options.burn.b) return 'big'\r\n\r\n if( - moment().diff(this.willburn, this.core.options.burn.v) < this.core.options.burn.m) return 'medium'\r\n\r\n return ''\r\n },\r\n willburn : function(){\r\n\r\n var d = moment(this.origin._localTimestamp).add(this.core.options.burn.w, this.core.options.burn.v)\r\n\r\n return d\r\n\r\n },\r\n\r\n readyToRender : function(){\r\n\r\n var r = ( this.content.msgtype === 'm.encrypted' && !this.textWithoutLinks && this.badenctypted ) || \r\n\r\n (this.content.membership) ||\r\n\r\n ((this.content.msgtype === 'm.text' || this.content.msgtype === 'm.encrypted') && this.textWithoutLinks) ||\r\n (this.file) || (this.error) || \r\n (this.content.msgtype === 'm.image' && this.imageUrl) ||\r\n (this.content.msgtype === 'm.audio' && this.audioUrl) ||\r\n (this.urlpreview) || \r\n (this.preview)\r\n\r\n return r \r\n\r\n },\r\n my: function () {\r\n return this.userinfo.id === this.core.user.userinfo?.id\r\n },\r\n stateChat: function () {\r\n var id = this.$route.query.id\r\n\r\n return this.$store.state.chatsMap[id]\r\n },\r\n\r\n\r\n sending: function () {\r\n return this.origin.status == 'sending'\r\n },\r\n\r\n showmeta : function(){\r\n if(!this.prevevent) return true\r\n\r\n var prevuser = this.$f.getmatrixid(this.prevevent.getSender())\r\n\r\n var t = 10 * 60000\r\n\r\n if((moment().diff(this.origin._localTimestamp, 'days')) != 0){\r\n t = 60 * 1000 * 60 * 24\r\n }\r\n\r\n if (prevuser != this.userinfo.id || this.prevevent._localTimestamp + t < this.origin._localTimestamp){\r\n return true\r\n }\r\n \r\n },\r\n\r\n imageFrom: function () {\r\n if (this.content && this.content.info) return this.content.info.from\r\n },\r\n\r\n showmyicon: function () {\r\n \r\n return this.showmyicontrue || \r\n this.content.msgtype === 'm.image' ||\r\n /*this.content.msgtype === 'm.audio' ||*/\r\n this.content.msgtype === 'm.file' || \r\n this.urlpreview || (!this.$store.state.active && this.$store.state.minimized)\r\n\r\n\r\n },\r\n\r\n file: function () {\r\n if (this.content.msgtype === 'm.file') {\r\n return this.body\r\n }\r\n },\r\n\r\n replacedmintionsbody:function(){\r\n return this.body.replace(/@\\w{68}:(\\w{1,50})/g, function(str, l){\r\n return '@' + l\r\n })\r\n\r\n },\r\n\r\n body: function () {\r\n\r\n var bc = this.origin.event.content\r\n\r\n if (this.origin.event.content.msgtype == 'm.encrypted') {\r\n bc = this.decryptEvent\r\n }\r\n\r\n return bc.pbody || bc.body || ''\r\n },\r\n\r\n content: function () {\r\n return this.origin.event.content\r\n },\r\n\r\n badenctypted: function () {\r\n return this.decryptEvent.msgtype == 'm.bad.encrypted'\r\n },\r\n\r\n \r\n\r\n textWithoutLinks: function () {\r\n\r\n var trimmed = this.$f.trim(this.body)\r\n \r\n if (!this.urlpreview || this.urlpreview.length < 10 ||\r\n (trimmed.indexOf(this.urlpreview) > 0 && trimmed.indexOf(this.urlpreview) + this.urlpreview.length < trimmed.length)\r\n ) {\r\n return trimmed\r\n }\r\n\r\n return this.$f.trim(trimmed.replace(this.urlpreview, ''))\r\n\r\n },\r\n\r\n imageUrl: function () {\r\n if (this.content.msgtype === 'm.image') {\r\n\r\n if (this.encryptedData) {\r\n return this.decryptedInfo\r\n } else {\r\n\r\n \r\n\r\n return this.content && this.content.url;\r\n }\r\n\r\n }\r\n },\r\n\r\n audioUrl: function () {\r\n if (this.content.msgtype === 'm.audio') {\r\n\r\n if(this.encryptedData && this.decryptedInfo) return this.decryptedInfo\r\n\r\n return this.audioBuffer\r\n\r\n //return this.content && this.content.audioData\r\n }\r\n },\r\n\r\n\r\n canediting: function () {\r\n var type = f.deep(this.origin, 'event.type')\r\n\r\n if (type == 'm.room.message') {\r\n if (this.origin.event.content.msgtype == 'm.encrypted' || this.origin.event.content.msgtype == 'm.text') {\r\n return true\r\n }\r\n }\r\n },\r\n\r\n cancopy: function () {\r\n var type = f.deep(this.origin, 'event.type')\r\n\r\n if (type == 'm.room.message') {\r\n if (this.origin.event.content.msgtype == 'm.encrypted' || this.origin.event.content.msgtype == 'm.text') {\r\n return true\r\n }\r\n }\r\n },\r\n\r\n menuItems: function () {\r\n var menu = [\r\n {\r\n click: \"reply\",\r\n title: this.$i18n.t(\"button.reply\"),\r\n icon: \"fas fa-reply\"\r\n },\r\n {\r\n click: \"showMultiSelect\",\r\n title: this.$i18n.t(\"button.select\"),\r\n icon: \"fas fa-check-circle\",\r\n },\r\n ]\r\n\r\n if(!this.file){\r\n menu.push({\r\n click: \"share\",\r\n title: this.$i18n.t(\"button.share\"),\r\n icon: \"fas fa-share-alt\"\r\n })\r\n }\r\n\r\n\r\n if (this.my) {\r\n menu.push({\r\n click: \"delete\",\r\n title: this.$i18n.t(\"button.delete\"),\r\n icon: \"far fa-trash-alt\"\r\n })\r\n }\r\n\r\n var type = f.deep(this.origin, 'event.type')\r\n\r\n if (type == 'm.room.message') {\r\n menu.unshift({\r\n click: \"copy\",\r\n title: this.$i18n.t(\"button.copy\"),\r\n icon: \"far fa-copy\"\r\n })\r\n\r\n if (this.my && this.canediting)\r\n menu.unshift({\r\n click: \"edit\",\r\n title: this.$i18n.t(\"button.edit\"),\r\n icon: \"far fa-edit\"\r\n })\r\n }\r\n\r\n return menu\r\n },\r\n\r\n\r\n urlpreview: function () {\r\n if (!this.preview && this.content.msgtype !== 'm.file') {\r\n\r\n\r\n var url = f.getUrl(this.body)\r\n\r\n if (url){\r\n var _u = new URL(url)\r\n\r\n if(_u.pathname == '/'){\r\n if(f.knsite(url)) return ''\r\n }\r\n\r\n return url\r\n }\r\n\r\n return url || ''\r\n }\r\n },\r\n\r\n edited: function () {\r\n if (this.content.edited) return true\r\n\r\n if (\r\n this.origin.event.content['m.relates_to'] &&\r\n this.origin.event.content['m.relates_to']['rel_type'] == 'm.replace') return true\r\n },\r\n\r\n selectedMessage: function () {\r\n const elem = this.selectedMessages.filter(\r\n (item) => item.message_id === this.origin.event.event_id\r\n );\r\n return elem[0]?.message_id === this.origin.event.event_id ? true : false;\r\n },\r\n },\r\n\r\n mounted() {\r\n\r\n },\r\n\r\n methods: {\r\n gotoreference: function () {\r\n var id = this.reference.getId()\r\n\r\n this.$emit('gotoreference', id)\r\n },\r\n\r\n showwhenburn : function(){\r\n\r\n var text = ''\r\n\r\n //console.log(this.willburn.toDate(), new Date(), this.willburn.toDate() > new Date())\r\n\r\n if(this.willburn.toDate() < new Date()){\r\n text = this.$i18n.t(\"messagewasburn\")\r\n }\r\n else{\r\n text = this.$i18n.t(\"messagewillburn\")\r\n\r\n //this.willburn.locale(this.$i18n.locale).format('DD MMMM YYYY')\r\n }\r\n\r\n this.$store.commit('icon', {\r\n\t\t\t\ticon: 'info',\r\n\t\t\t\tmessage: text\r\n \r\n \r\n\t\t\t})\r\n\r\n },\r\n\r\n imagesLoaded: function () {\r\n this.updatedSize()\r\n },\r\n updatedSize: function (before) {\r\n this.$emit('updatedSize', before)\r\n },\r\n\r\n dropDownMenuShow: function () {\r\n\r\n if(this.urlpreview) return\r\n\r\n setTimeout(() => {\r\n this.setmenu()\r\n }, 200)\r\n\r\n },\r\n\r\n setmenu : function(){\r\n this.core.menu({\r\n items : this.menuItems,\r\n handler : this.menuItemClickHandler,\r\n item : {}\r\n })\r\n },\r\n\r\n menushare: function () {\r\n\r\n var sharing = {}\r\n\r\n var trimmed = this.$f.trim(this.body)\r\n \r\n if (this.content.msgtype === 'm.image' && this.imageUrl) sharing.images = [this.imageUrl]\r\n\r\n if (this.content.msgtype === 'm.audio' && this.audioUrl) sharing.audio = [this.audioUrl]\r\n\r\n if ((this.content.msgtype === 'm.text' || this.content.msgtype === 'm.encrypted') && trimmed) sharing.messages = [trimmed]\r\n\r\n //if(this.urlpreview) sharing.urls = [urlpreview]\r\n\r\n if (this.file) {\r\n sharing.download = true\r\n }\r\n\r\n //sharing.route = 'chat?id=' + this.chat.roomId\r\n sharing.from = this.userinfo.id\r\n\r\n this.$emit('share', sharing)\r\n\r\n return Promise.resolve()\r\n },\r\n\r\n menuedit: function () {\r\n this.$emit('editing', this.body)\r\n\r\n return Promise.resolve()\r\n },\r\n\r\n menushowMultiSelect: function () {\r\n this.$emit('showMultiSelect');\r\n this.selectMessage();\r\n\r\n return Promise.resolve()\r\n },\r\n\r\n menureply: function () {\r\n\r\n this.$emit('reply')\r\n\r\n return Promise.resolve()\r\n },\r\n menucopy: function () {\r\n\r\n \r\n\r\n this.$f.copytext(this.replacedmintionsbody)\r\n\r\n return Promise.resolve()\r\n },\r\n menudelete: function () {\r\n\r\n return this.$dialog.confirm(\r\n 'Do you really want to delete message?', {\r\n okText: this.$i18n.t(\"yes\"),\r\n cancelText: this.$i18n.t(\"cancel\")\r\n })\r\n\r\n .then((dialog) => {\r\n\r\n this.$emit('remove')\r\n\r\n\r\n return this.core.mtrx.client.redactEvent(this.chat.roomId, this.origin.event.event_id, null, {\r\n reason: \"messagedeleting\",\r\n })\r\n\r\n }).catch(e => {\r\n return Promise.resolve()\r\n })\r\n\r\n\r\n },\r\n menuItemClickHandler: function (item, d, p) {\r\n\r\n p.hidePopup()\r\n\r\n this['menu' + item.click]().then(r => {\r\n\r\n }).catch(e => {\r\n p.showPopup()\r\n })\r\n\r\n },\r\n\r\n imagePaddingStyle : function(c){\r\n\r\n if(c.info && c.info.h && c.info.w){\r\n\r\n var cc = c.info.h / c.info.w\r\n\r\n if (cc > 1.7) cc = 1.7\r\n\r\n var h = 'padding-bottom:' + ((cc) * 100) + '%'\r\n\r\n return h\r\n }\r\n\r\n return ''\r\n },\r\n parser(event) {\r\n return JSON.parse(event)['og:title']\r\n },\r\n openImage(img) {\r\n this.$emit('openImg', img)\r\n },\r\n\r\n format_date(value) {\r\n if (value) {\r\n if ((moment().diff(value, 'days')) === 0) {\r\n return new Date(value).toLocaleTimeString([], {hour: '2-digit', minute: \"2-digit\", hour12: false})\r\n } else {\r\n if (moment().year() === moment(value).year()) {\r\n return moment(value).locale(this.$i18n.locale).format('D MMMM')\r\n } else {\r\n return moment(value).locale(this.$i18n.locale).format('D MMMM YYYY')\r\n }\r\n }\r\n }\r\n },\r\n\r\n download: function () {\r\n this.$emit('download')\r\n },\r\n\r\n decryptagain : function(){\r\n this.$emit('decryptagain')\r\n },\r\n \r\n openImageGallery(msgEvent) {\r\n this.$emit('openGalleryImg', msgEvent)\r\n },\r\n reshareKeys() {\r\n let roomId = this.chat.roomId\r\n },\r\n textDonation: function (withTx = false) {\r\n var from = this.$i18n.t(\"caption.somebody\"), msg = '';\r\n try {\r\n from = this.$f.deep(this, '$store.state.users.' + this.content.from).name;\r\n } catch (err) {\r\n }\r\n var to = this.$i18n.t(\"caption.somebody\");\r\n try {\r\n to = this.$f.deep(this, '$store.state.users.' + this.content.to).name;\r\n } catch (err) {\r\n }\r\n msg += from + this.$i18n.t(\"caption.sent\") + this.content.amount + this.$i18n.t(\"caption.sent\") + to;\r\n return msg;\r\n },\r\n\r\n menuIsVisibleHandler(isVisible) {\r\n this.$emit('menuIsVisible', isVisible);\r\n },\r\n\r\n showreference : function(){\r\n this.referenceshowed = !this.referenceshowed\r\n },\r\n\r\n selectMessage: function () {\r\n var sharing = {};\r\n\r\n var trimmed = this.$f.trim(this.body);\r\n\r\n if (this.content.msgtype === 'm.image' && this.imageUrl)\r\n sharing.images = [this.imageUrl];\r\n\r\n if (this.content.msgtype === 'm.audio' && this.decryptedInfo)\r\n sharing.audio = [this.decryptedInfo];\r\n\r\n if (\r\n (this.content.msgtype === 'm.text' ||\r\n this.content.msgtype === 'm.encrypted') &&\r\n trimmed\r\n )\r\n sharing.messages = [trimmed];\r\n\r\n //if(this.urlpreview) sharing.urls = [urlpreview]\r\n\r\n if (this.file) {\r\n sharing.download = true;\r\n }\r\n\r\n //sharing.route = 'chat?id=' + this.chat.roomId\r\n sharing.from = this.userinfo.id;\r\n this.$emit('selectMessage', {\r\n message_id: this.origin.event.event_id,\r\n ...sharing,\r\n });\r\n },\r\n removeMessage: function () {\r\n this.$emit('removeMessage', {\r\n message_id: this.origin.event.event_id,\r\n });\r\n },\r\n\r\n eventMessage: function (state) {\r\n state ? this.removeMessage() : this.selectMessage()\r\n }\r\n }\r\n}","import mod from \"-!../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../node_modules/babel-loader/lib/index.js!./index.js?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=c8f458dc&scoped=true&\"\nimport script from \"./index.js?vue&type=script&lang=js&\"\nexport * from \"./index.js?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.sass?vue&type=style&index=0&id=c8f458dc&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"c8f458dc\",\n null\n ,true\n)\n\nexport default component.exports","\r\n \r\n \r\n
\r\n\r\n
\r\n\r\n
\r\n\r\n
\r\n \r\n
\r\n\r\n
\r\n\r\n \r\n {{ $t(\"caption.messageDeleted\") }}\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n","import mod from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../../node_modules/thread-loader/dist/cjs.js!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./index.vue?vue&type=template&id=72e46191&scoped=true&\"\nimport script from \"./index.vue?vue&type=script&lang=js&\"\nexport * from \"./index.vue?vue&type=script&lang=js&\"\nfunction injectStyles (context) {\n \n var style0 = require(\"./index.vue?vue&type=style&index=0&id=72e46191&scoped=true&lang=sass&\")\nif (style0.__inject__) style0.__inject__(context)\n\n}\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n injectStyles,\n \"72e46191\",\n null\n ,true\n)\n\nexport default component.exports","/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","export * from \"-!../../../../node_modules/vue-style-loader/index.js??ref--10-oneOf-1-0!../../../../node_modules/css-loader/dist/cjs.js??ref--10-oneOf-1-1!../../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../../node_modules/postcss-loader/src/index.js??ref--10-oneOf-1-2!../../../../node_modules/postcss-loader/src/index.js??ref--10-oneOf-1-3!../../../../node_modules/sass-loader/dist/cjs.js??ref--10-oneOf-1-4!./index.sass?vue&type=style&index=0&id=79bb4e47&scoped=true&lang=sass&\"","module.exports = function(module) {\n\tif (!module.webpackPolyfill) {\n\t\tmodule.deprecate = function() {};\n\t\tmodule.paths = [];\n\t\t// module.parent = undefined by default\n\t\tif (!module.children) module.children = [];\n\t\tObject.defineProperty(module, \"loaded\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.l;\n\t\t\t}\n\t\t});\n\t\tObject.defineProperty(module, \"id\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.i;\n\t\t\t}\n\t\t});\n\t\tmodule.webpackPolyfill = 1;\n\t}\n\treturn module;\n};\n","var global = require('../internals/global');\n\n// eslint-disable-next-line es-x/no-object-defineproperty -- safe\nvar defineProperty = Object.defineProperty;\n\nmodule.exports = function (key, value) {\n try {\n defineProperty(global, key, { value: value, configurable: true, writable: true });\n } catch (error) {\n global[key] = value;\n } return value;\n};\n","\"use strict\";\r\n\r\nvar _interopRequireWildcard = require(\"@babel/runtime/helpers/interopRequireWildcard\");\r\n\r\nObject.defineProperty(exports, \"__esModule\", {\r\n value: true\r\n});\r\nexports.EventTimelineSet = EventTimelineSet;\r\n\r\nvar _events = require(\"events\");\r\n\r\nvar _eventTimeline = require(\"./event-timeline\");\r\n\r\nvar _event = require(\"./event\");\r\n\r\nvar utils = _interopRequireWildcard(require(\"../utils\"));\r\n\r\nvar _logger = require(\"../logger\");\r\n\r\nvar _relations = require(\"./relations\");\r\n\r\n/*\r\nCopyright 2016 OpenMarket Ltd\r\nCopyright 2019 The Matrix.org Foundation C.I.C.\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\");\r\nyou may not use this file except in compliance with the License.\r\nYou may obtain a copy of the License at\r\n\r\n http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless required by applicable law or agreed to in writing, software\r\ndistributed under the License is distributed on an \"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\nSee the License for the specific language governing permissions and\r\nlimitations under the License.\r\n*/\r\n\r\n/**\r\n * @module models/event-timeline-set\r\n */\r\n// var DEBUG = false;\r\nconst DEBUG = true;\r\nlet debuglog;\r\n\r\nif (DEBUG) {\r\n // using bind means that we get to keep useful line numbers in the console\r\n debuglog = _logger.logger.log.bind(_logger.logger);\r\n} else {\r\n debuglog = function () {};\r\n}\r\n/**\r\n * Construct a set of EventTimeline objects, typically on behalf of a given\r\n * room. A room may have multiple EventTimelineSets for different levels\r\n * of filtering. The global notification list is also an EventTimelineSet, but\r\n * lacks a room.\r\n *\r\n * This is an ordered sequence of timelines, which may or may not\r\n * be continuous. Each timeline lists a series of events, as well as tracking\r\n * the room state at the start and the end of the timeline (if appropriate).\r\n * It also tracks forward and backward pagination tokens, as well as containing\r\n * links to the next timeline in the sequence.\r\n *\r\n *
There is one special timeline - the 'live' timeline, which represents the\r\n * timeline to which events are being added in real-time as they are received\r\n * from the /sync API. Note that you should not retain references to this\r\n * timeline - even if it is the current timeline right now, it may not remain\r\n * so if the server gives us a timeline gap in /sync.\r\n *\r\n *
In order that we can find events from their ids later, we also maintain a\r\n * map from event_id to timeline and index.\r\n *\r\n * @constructor\r\n * @param {?Room} room\r\n * Room for this timelineSet. May be null for non-room cases, such as the\r\n * notification timeline.\r\n * @param {Object} opts Options inherited from Room.\r\n *\r\n * @param {boolean} [opts.timelineSupport = false]\r\n * Set to true to enable improved timeline support.\r\n * @param {Object} [opts.filter = null]\r\n * The filter object, if any, for this timelineSet.\r\n * @param {boolean} [opts.unstableClientRelationAggregation = false]\r\n * Optional. Set to true to enable client-side aggregation of event relations\r\n * via `getRelationsForEvent`.\r\n * This feature is currently unstable and the API may change without notice.\r\n */\r\n\r\n\r\nfunction EventTimelineSet(room, opts) {\r\n this.room = room;\r\n this._timelineSupport = Boolean(opts.timelineSupport);\r\n this._liveTimeline = new _eventTimeline.EventTimeline(this);\r\n this._unstableClientRelationAggregation = !!opts.unstableClientRelationAggregation; // just a list - *not* ordered.\r\n\r\n this._timelines = [this._liveTimeline];\r\n this._eventIdToTimeline = {};\r\n this._filter = opts.filter || null;\r\n\r\n if (this._unstableClientRelationAggregation) {\r\n // A tree of objects to access a set of relations for an event, as in:\r\n // this._relations[relatesToEventId][relationType][relationEventType]\r\n this._relations = {};\r\n }\r\n}\r\n\r\nutils.inherits(EventTimelineSet, _events.EventEmitter);\r\n/**\r\n * Get all the timelines in this set\r\n * @return {module:models/event-timeline~EventTimeline[]} the timelines in this set\r\n */\r\n\r\nEventTimelineSet.prototype.getTimelines = function () {\r\n return this._timelines;\r\n};\r\n/**\r\n * Get the filter object this timeline set is filtered on, if any\r\n * @return {?Filter} the optional filter for this timelineSet\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.getFilter = function () {\r\n return this._filter;\r\n};\r\n/**\r\n * Set the filter object this timeline set is filtered on\r\n * (passed to the server when paginating via /messages).\r\n * @param {Filter} filter the filter for this timelineSet\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.setFilter = function (filter) {\r\n this._filter = filter;\r\n};\r\n/**\r\n * Get the list of pending sent events for this timelineSet's room, filtered\r\n * by the timelineSet's filter if appropriate.\r\n *\r\n * @return {module:models/event.MatrixEvent[]} A list of the sent events\r\n * waiting for remote echo.\r\n *\r\n * @throws If opts.pendingEventOrdering
was not 'detached'\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.getPendingEvents = function () {\r\n if (!this.room) {\r\n return [];\r\n }\r\n\r\n if (this._filter) {\r\n return this._filter.filterRoomTimeline(this.room.getPendingEvents());\r\n } else {\r\n return this.room.getPendingEvents();\r\n }\r\n};\r\n/**\r\n * Get the live timeline for this room.\r\n *\r\n * @return {module:models/event-timeline~EventTimeline} live timeline\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.getLiveTimeline = function () {\r\n return this._liveTimeline;\r\n};\r\n/**\r\n * Return the timeline (if any) this event is in.\r\n * @param {String} eventId the eventId being sought\r\n * @return {module:models/event-timeline~EventTimeline} timeline\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.eventIdToTimeline = function (eventId) {\r\n return this._eventIdToTimeline[eventId];\r\n};\r\n/**\r\n * Track a new event as if it were in the same timeline as an old event,\r\n * replacing it.\r\n * @param {String} oldEventId event ID of the original event\r\n * @param {String} newEventId event ID of the replacement event\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.replaceEventId = function (oldEventId, newEventId) {\r\n const existingTimeline = this._eventIdToTimeline[oldEventId];\r\n\r\n if (existingTimeline) {\r\n delete this._eventIdToTimeline[oldEventId];\r\n this._eventIdToTimeline[newEventId] = existingTimeline;\r\n }\r\n};\r\n/**\r\n * Reset the live timeline, and start a new one.\r\n *\r\n *
This is used when /sync returns a 'limited' timeline.\r\n *\r\n * @param {string=} backPaginationToken token for back-paginating the new timeline\r\n * @param {string=} forwardPaginationToken token for forward-paginating the old live timeline,\r\n * if absent or null, all timelines are reset.\r\n *\r\n * @fires module:client~MatrixClient#event:\"Room.timelineReset\"\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.resetLiveTimeline = function (backPaginationToken, forwardPaginationToken) {\r\n // Each EventTimeline has RoomState objects tracking the state at the start\r\n // and end of that timeline. The copies at the end of the live timeline are\r\n // special because they will have listeners attached to monitor changes to\r\n // the current room state, so we move this RoomState from the end of the\r\n // current live timeline to the end of the new one and, if necessary,\r\n // replace it with a newly created one. We also make a copy for the start\r\n // of the new timeline.\r\n // if timeline support is disabled, forget about the old timelines\r\n const resetAllTimelines = !this._timelineSupport || !forwardPaginationToken;\r\n const oldTimeline = this._liveTimeline;\r\n const newTimeline = resetAllTimelines ? oldTimeline.forkLive(_eventTimeline.EventTimeline.FORWARDS) : oldTimeline.fork(_eventTimeline.EventTimeline.FORWARDS);\r\n\r\n if (resetAllTimelines) {\r\n this._timelines = [newTimeline];\r\n this._eventIdToTimeline = {};\r\n } else {\r\n this._timelines.push(newTimeline);\r\n }\r\n\r\n if (forwardPaginationToken) {\r\n // Now set the forward pagination token on the old live timeline\r\n // so it can be forward-paginated.\r\n oldTimeline.setPaginationToken(forwardPaginationToken, _eventTimeline.EventTimeline.FORWARDS);\r\n } // make sure we set the pagination token before firing timelineReset,\r\n // otherwise clients which start back-paginating will fail, and then get\r\n // stuck without realising that they *can* back-paginate.\r\n\r\n\r\n newTimeline.setPaginationToken(backPaginationToken, _eventTimeline.EventTimeline.BACKWARDS); // Now we can swap the live timeline to the new one.\r\n\r\n this._liveTimeline = newTimeline;\r\n this.emit(\"Room.timelineReset\", this.room, this, resetAllTimelines);\r\n};\r\n/**\r\n * Get the timeline which contains the given event, if any\r\n *\r\n * @param {string} eventId event ID to look for\r\n * @return {?module:models/event-timeline~EventTimeline} timeline containing\r\n * the given event, or null if unknown\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.getTimelineForEvent = function (eventId) {\r\n const res = this._eventIdToTimeline[eventId];\r\n return res === undefined ? null : res;\r\n};\r\n/**\r\n * Get an event which is stored in our timelines\r\n *\r\n * @param {string} eventId event ID to look for\r\n * @return {?module:models/event~MatrixEvent} the given event, or undefined if unknown\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.findEventById = function (eventId) {\r\n const tl = this.getTimelineForEvent(eventId);\r\n\r\n if (!tl) {\r\n return undefined;\r\n }\r\n\r\n return utils.findElement(tl.getEvents(), function (ev) {\r\n return ev.getId() == eventId;\r\n });\r\n};\r\n/**\r\n * Add a new timeline to this timeline list\r\n *\r\n * @return {module:models/event-timeline~EventTimeline} newly-created timeline\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.addTimeline = function () {\r\n if (!this._timelineSupport) {\r\n throw new Error(\"timeline support is disabled. Set the 'timelineSupport'\" + \" parameter to true when creating MatrixClient to enable\" + \" it.\");\r\n }\r\n\r\n const timeline = new _eventTimeline.EventTimeline(this);\r\n\r\n this._timelines.push(timeline);\r\n\r\n return timeline;\r\n};\r\n/**\r\n * Add events to a timeline\r\n *\r\n *
Will fire \"Room.timeline\" for each event added.\r\n *\r\n * @param {MatrixEvent[]} events A list of events to add.\r\n *\r\n * @param {boolean} toStartOfTimeline True to add these events to the start\r\n * (oldest) instead of the end (newest) of the timeline. If true, the oldest\r\n * event will be the last element of 'events'.\r\n *\r\n * @param {module:models/event-timeline~EventTimeline} timeline timeline to\r\n * add events to.\r\n *\r\n * @param {string=} paginationToken token for the next batch of events\r\n *\r\n * @fires module:client~MatrixClient#event:\"Room.timeline\"\r\n *\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.addEventsToTimeline = function (events, toStartOfTimeline, timeline, paginationToken) {\r\n if (!timeline) {\r\n throw new Error(\"'timeline' not specified for EventTimelineSet.addEventsToTimeline\");\r\n }\r\n\r\n if (!toStartOfTimeline && timeline == this._liveTimeline) {\r\n throw new Error(\"EventTimelineSet.addEventsToTimeline cannot be used for adding events to \" + \"the live timeline - use Room.addLiveEvents instead\");\r\n }\r\n\r\n if (this._filter) {\r\n events = this._filter.filterRoomTimeline(events);\r\n\r\n if (!events.length) {\r\n return;\r\n }\r\n }\r\n\r\n const direction = toStartOfTimeline ? _eventTimeline.EventTimeline.BACKWARDS : _eventTimeline.EventTimeline.FORWARDS;\r\n const inverseDirection = toStartOfTimeline ? _eventTimeline.EventTimeline.FORWARDS : _eventTimeline.EventTimeline.BACKWARDS; // Adding events to timelines can be quite complicated. The following\r\n // illustrates some of the corner-cases.\r\n //\r\n // Let's say we start by knowing about four timelines. timeline3 and\r\n // timeline4 are neighbours:\r\n //\r\n // timeline1 timeline2 timeline3 timeline4\r\n // [M] [P] [S] <------> [T]\r\n //\r\n // Now we paginate timeline1, and get the following events from the server:\r\n // [M, N, P, R, S, T, U].\r\n //\r\n // 1. First, we ignore event M, since we already know about it.\r\n //\r\n // 2. Next, we append N to timeline 1.\r\n //\r\n // 3. Next, we don't add event P, since we already know about it,\r\n // but we do link together the timelines. We now have:\r\n //\r\n // timeline1 timeline2 timeline3 timeline4\r\n // [M, N] <---> [P] [S] <------> [T]\r\n //\r\n // 4. Now we add event R to timeline2:\r\n //\r\n // timeline1 timeline2 timeline3 timeline4\r\n // [M, N] <---> [P, R] [S] <------> [T]\r\n //\r\n // Note that we have switched the timeline we are working on from\r\n // timeline1 to timeline2.\r\n //\r\n // 5. We ignore event S, but again join the timelines:\r\n //\r\n // timeline1 timeline2 timeline3 timeline4\r\n // [M, N] <---> [P, R] <---> [S] <------> [T]\r\n //\r\n // 6. We ignore event T, and the timelines are already joined, so there\r\n // is nothing to do.\r\n //\r\n // 7. Finally, we add event U to timeline4:\r\n //\r\n // timeline1 timeline2 timeline3 timeline4\r\n // [M, N] <---> [P, R] <---> [S] <------> [T, U]\r\n //\r\n // The important thing to note in the above is what happened when we\r\n // already knew about a given event:\r\n //\r\n // - if it was appropriate, we joined up the timelines (steps 3, 5).\r\n // - in any case, we started adding further events to the timeline which\r\n // contained the event we knew about (steps 3, 5, 6).\r\n //\r\n //\r\n // So much for adding events to the timeline. But what do we want to do\r\n // with the pagination token?\r\n //\r\n // In the case above, we will be given a pagination token which tells us how to\r\n // get events beyond 'U' - in this case, it makes sense to store this\r\n // against timeline4. But what if timeline4 already had 'U' and beyond? in\r\n // that case, our best bet is to throw away the pagination token we were\r\n // given and stick with whatever token timeline4 had previously. In short,\r\n // we want to only store the pagination token if the last event we receive\r\n // is one we didn't previously know about.\r\n //\r\n // We make an exception for this if it turns out that we already knew about\r\n // *all* of the events, and we weren't able to join up any timelines. When\r\n // that happens, it means our existing pagination token is faulty, since it\r\n // is only telling us what we already know. Rather than repeatedly\r\n // paginating with the same token, we might as well use the new pagination\r\n // token in the hope that we eventually work our way out of the mess.\r\n\r\n let didUpdate = false;\r\n let lastEventWasNew = false;\r\n\r\n for (let i = 0; i < events.length; i++) {\r\n const event = events[i];\r\n const eventId = event.getId();\r\n const existingTimeline = this._eventIdToTimeline[eventId];\r\n\r\n if (!existingTimeline) {\r\n // we don't know about this event yet. Just add it to the timeline.\r\n this.addEventToTimeline(event, timeline, toStartOfTimeline);\r\n lastEventWasNew = true;\r\n didUpdate = true;\r\n continue;\r\n }\r\n\r\n lastEventWasNew = false;\r\n\r\n if (existingTimeline == timeline) {\r\n debuglog(\"Event \" + eventId + \" already in timeline \" + timeline);\r\n continue;\r\n }\r\n\r\n const neighbour = timeline.getNeighbouringTimeline(direction);\r\n\r\n if (neighbour) {\r\n // this timeline already has a neighbour in the relevant direction;\r\n // let's assume the timelines are already correctly linked up, and\r\n // skip over to it.\r\n //\r\n // there's probably some edge-case here where we end up with an\r\n // event which is in a timeline a way down the chain, and there is\r\n // a break in the chain somewhere. But I can't really imagine how\r\n // that would happen, so I'm going to ignore it for now.\r\n //\r\n if (existingTimeline == neighbour) {\r\n debuglog(\"Event \" + eventId + \" in neighbouring timeline - \" + \"switching to \" + existingTimeline);\r\n } else {\r\n debuglog(\"Event \" + eventId + \" already in a different \" + \"timeline \" + existingTimeline);\r\n }\r\n\r\n timeline = existingTimeline;\r\n continue;\r\n } // time to join the timelines.\r\n\r\n\r\n _logger.logger.info(\"Already have timeline for \" + eventId + \" - joining timeline \" + timeline + \" to \" + existingTimeline); // Variables to keep the line length limited below.\r\n\r\n\r\n const existingIsLive = existingTimeline === this._liveTimeline;\r\n const timelineIsLive = timeline === this._liveTimeline;\r\n const backwardsIsLive = direction === _eventTimeline.EventTimeline.BACKWARDS && existingIsLive;\r\n const forwardsIsLive = direction === _eventTimeline.EventTimeline.FORWARDS && timelineIsLive;\r\n\r\n if (backwardsIsLive || forwardsIsLive) {\r\n // The live timeline should never be spliced into a non-live position.\r\n // We use independent logging to better discover the problem at a glance.\r\n if (backwardsIsLive) {\r\n _logger.logger.warn(\"Refusing to set a preceding existingTimeLine on our \" + \"timeline as the existingTimeLine is live (\" + existingTimeline + \")\");\r\n }\r\n\r\n if (forwardsIsLive) {\r\n _logger.logger.warn(\"Refusing to set our preceding timeline on a existingTimeLine \" + \"as our timeline is live (\" + timeline + \")\");\r\n }\r\n\r\n continue; // abort splicing - try next event\r\n }\r\n\r\n timeline.setNeighbouringTimeline(existingTimeline, direction);\r\n existingTimeline.setNeighbouringTimeline(timeline, inverseDirection);\r\n timeline = existingTimeline;\r\n didUpdate = true;\r\n } // see above - if the last event was new to us, or if we didn't find any\r\n // new information, we update the pagination token for whatever\r\n // timeline we ended up on.\r\n\r\n\r\n if (lastEventWasNew || !didUpdate) {\r\n if (direction === _eventTimeline.EventTimeline.FORWARDS && timeline === this._liveTimeline) {\r\n _logger.logger.warn({\r\n lastEventWasNew,\r\n didUpdate\r\n }); // for debugging\r\n\r\n\r\n _logger.logger.warn(`Refusing to set forwards pagination token of live timeline ` + `${timeline} to ${paginationToken}`);\r\n\r\n return;\r\n }\r\n\r\n timeline.setPaginationToken(paginationToken, direction);\r\n }\r\n};\r\n/**\r\n * Add an event to the end of this live timeline.\r\n *\r\n * @param {MatrixEvent} event Event to be added\r\n * @param {string?} duplicateStrategy 'ignore' or 'replace'\r\n * @param {boolean} fromCache whether the sync response came from cache\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.addLiveEvent = function (event, duplicateStrategy, fromCache) {\r\n if (this._filter) {\r\n const events = this._filter.filterRoomTimeline([event]);\r\n\r\n if (!events.length) {\r\n return;\r\n }\r\n }\r\n\r\n const timeline = this._eventIdToTimeline[event.getId()];\r\n\r\n if (timeline) {\r\n if (duplicateStrategy === \"replace\") {\r\n debuglog(\"EventTimelineSet.addLiveEvent: replacing duplicate event \" + event.getId());\r\n const tlEvents = timeline.getEvents();\r\n\r\n for (let j = 0; j < tlEvents.length; j++) {\r\n if (tlEvents[j].getId() === event.getId()) {\r\n // still need to set the right metadata on this event\r\n _eventTimeline.EventTimeline.setEventMetadata(event, timeline.getState(_eventTimeline.EventTimeline.FORWARDS), false);\r\n\r\n if (!tlEvents[j].encryptedType) {\r\n tlEvents[j] = event;\r\n } // XXX: we need to fire an event when this happens.\r\n\r\n\r\n break;\r\n }\r\n }\r\n } else {\r\n debuglog(\"EventTimelineSet.addLiveEvent: ignoring duplicate event \" + event.getId());\r\n }\r\n\r\n return;\r\n }\r\n\r\n this.addEventToTimeline(event, this._liveTimeline, false, fromCache);\r\n};\r\n/**\r\n * Add event to the given timeline, and emit Room.timeline. Assumes\r\n * we have already checked we don't know about this event.\r\n *\r\n * Will fire \"Room.timeline\" for each event added.\r\n *\r\n * @param {MatrixEvent} event\r\n * @param {EventTimeline} timeline\r\n * @param {boolean} toStartOfTimeline\r\n * @param {boolean} fromCache whether the sync response came from cache\r\n *\r\n * @fires module:client~MatrixClient#event:\"Room.timeline\"\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.addEventToTimeline = function (event, timeline, toStartOfTimeline, fromCache) {\r\n const eventId = event.getId();\r\n timeline.addEvent(event, toStartOfTimeline);\r\n this._eventIdToTimeline[eventId] = timeline;\r\n this.setRelationsTarget(event);\r\n this.aggregateRelations(event);\r\n const data = {\r\n timeline: timeline,\r\n liveEvent: !toStartOfTimeline && timeline == this._liveTimeline && !fromCache\r\n };\r\n this.emit(\"Room.timeline\", event, this.room, Boolean(toStartOfTimeline), false, data);\r\n};\r\n/**\r\n * Replaces event with ID oldEventId with one with newEventId, if oldEventId is\r\n * recognised. Otherwise, add to the live timeline. Used to handle remote echos.\r\n *\r\n * @param {MatrixEvent} localEvent the new event to be added to the timeline\r\n * @param {String} oldEventId the ID of the original event\r\n * @param {boolean} newEventId the ID of the replacement event\r\n *\r\n * @fires module:client~MatrixClient#event:\"Room.timeline\"\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.handleRemoteEcho = function (localEvent, oldEventId, newEventId) {\r\n // XXX: why don't we infer newEventId from localEvent?\r\n const existingTimeline = this._eventIdToTimeline[oldEventId];\r\n\r\n if (existingTimeline) {\r\n delete this._eventIdToTimeline[oldEventId];\r\n this._eventIdToTimeline[newEventId] = existingTimeline;\r\n } else {\r\n if (this._filter) {\r\n if (this._filter.filterRoomTimeline([localEvent]).length) {\r\n this.addEventToTimeline(localEvent, this._liveTimeline, false);\r\n }\r\n } else {\r\n this.addEventToTimeline(localEvent, this._liveTimeline, false);\r\n }\r\n }\r\n};\r\n/**\r\n * Removes a single event from this room.\r\n *\r\n * @param {String} eventId The id of the event to remove\r\n *\r\n * @return {?MatrixEvent} the removed event, or null if the event was not found\r\n * in this room.\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.removeEvent = function (eventId) {\r\n const timeline = this._eventIdToTimeline[eventId];\r\n\r\n if (!timeline) {\r\n return null;\r\n }\r\n\r\n const removed = timeline.removeEvent(eventId);\r\n\r\n if (removed) {\r\n delete this._eventIdToTimeline[eventId];\r\n const data = {\r\n timeline: timeline\r\n };\r\n this.emit(\"Room.timeline\", removed, this.room, undefined, true, data);\r\n }\r\n\r\n return removed;\r\n};\r\n/**\r\n * Determine where two events appear in the timeline relative to one another\r\n *\r\n * @param {string} eventId1 The id of the first event\r\n * @param {string} eventId2 The id of the second event\r\n\r\n * @return {?number} a number less than zero if eventId1 precedes eventId2, and\r\n * greater than zero if eventId1 succeeds eventId2. zero if they are the\r\n * same event; null if we can't tell (either because we don't know about one\r\n * of the events, or because they are in separate timelines which don't join\r\n * up).\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.compareEventOrdering = function (eventId1, eventId2) {\r\n if (eventId1 == eventId2) {\r\n // optimise this case\r\n return 0;\r\n }\r\n\r\n const timeline1 = this._eventIdToTimeline[eventId1];\r\n const timeline2 = this._eventIdToTimeline[eventId2];\r\n\r\n if (timeline1 === undefined) {\r\n return null;\r\n }\r\n\r\n if (timeline2 === undefined) {\r\n return null;\r\n }\r\n\r\n if (timeline1 === timeline2) {\r\n // both events are in the same timeline - figure out their\r\n // relative indices\r\n let idx1;\r\n let idx2;\r\n const events = timeline1.getEvents();\r\n\r\n for (let idx = 0; idx < events.length && (idx1 === undefined || idx2 === undefined); idx++) {\r\n const evId = events[idx].getId();\r\n\r\n if (evId == eventId1) {\r\n idx1 = idx;\r\n }\r\n\r\n if (evId == eventId2) {\r\n idx2 = idx;\r\n }\r\n }\r\n\r\n return idx1 - idx2;\r\n } // the events are in different timelines. Iterate through the\r\n // linkedlist to see which comes first.\r\n // first work forwards from timeline1\r\n\r\n\r\n let tl = timeline1;\r\n\r\n while (tl) {\r\n if (tl === timeline2) {\r\n // timeline1 is before timeline2\r\n return -1;\r\n }\r\n\r\n tl = tl.getNeighbouringTimeline(_eventTimeline.EventTimeline.FORWARDS);\r\n } // now try backwards from timeline1\r\n\r\n\r\n tl = timeline1;\r\n\r\n while (tl) {\r\n if (tl === timeline2) {\r\n // timeline2 is before timeline1\r\n return 1;\r\n }\r\n\r\n tl = tl.getNeighbouringTimeline(_eventTimeline.EventTimeline.BACKWARDS);\r\n } // the timelines are not contiguous.\r\n\r\n\r\n return null;\r\n};\r\n/**\r\n * Get a collection of relations to a given event in this timeline set.\r\n *\r\n * @param {String} eventId\r\n * The ID of the event that you'd like to access relation events for.\r\n * For example, with annotations, this would be the ID of the event being annotated.\r\n * @param {String} relationType\r\n * The type of relation involved, such as \"m.annotation\", \"m.reference\", \"m.replace\", etc.\r\n * @param {String} eventType\r\n * The relation event's type, such as \"m.reaction\", etc.\r\n * @throws If eventId
, relationType
or eventType
\r\n * are not valid.\r\n *\r\n * @returns {?Relations}\r\n * A container for relation events or undefined if there are no relation events for\r\n * the relationType.\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.getRelationsForEvent = function (eventId, relationType, eventType) {\r\n if (!this._unstableClientRelationAggregation) {\r\n throw new Error(\"Client-side relation aggregation is disabled\");\r\n }\r\n\r\n if (!eventId || !relationType || !eventType) {\r\n throw new Error(\"Invalid arguments for `getRelationsForEvent`\");\r\n } // debuglog(\"Getting relations for: \", eventId, relationType, eventType);\r\n\r\n\r\n const relationsForEvent = this._relations[eventId] || {};\r\n const relationsWithRelType = relationsForEvent[relationType] || {};\r\n return relationsWithRelType[eventType];\r\n};\r\n/**\r\n * Set an event as the target event if any Relations exist for it already\r\n *\r\n * @param {MatrixEvent} event\r\n * The event to check as relation target.\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.setRelationsTarget = function (event) {\r\n if (!this._unstableClientRelationAggregation) {\r\n return;\r\n }\r\n\r\n const relationsForEvent = this._relations[event.getId()];\r\n\r\n if (!relationsForEvent) {\r\n return;\r\n } // don't need it for non m.replace relations for now\r\n\r\n\r\n const relationsWithRelType = relationsForEvent[\"m.replace\"];\r\n\r\n if (!relationsWithRelType) {\r\n return;\r\n } // only doing replacements for messages for now (e.g. edits)\r\n\r\n\r\n const relationsWithEventType = relationsWithRelType[\"m.room.message\"];\r\n\r\n if (relationsWithEventType) {\r\n relationsWithEventType.setTargetEvent(event);\r\n }\r\n};\r\n/**\r\n * Add relation events to the relevant relation collection.\r\n *\r\n * @param {MatrixEvent} event\r\n * The new relation event to be aggregated.\r\n */\r\n\r\n\r\nEventTimelineSet.prototype.aggregateRelations = function (event) {\r\n if (!this._unstableClientRelationAggregation) {\r\n return;\r\n }\r\n\r\n if (event.isRedacted() || event.status === _event.EventStatus.CANCELLED) {\r\n return;\r\n } // If the event is currently encrypted, wait until it has been decrypted.\r\n\r\n\r\n if (event.isBeingDecrypted()) {\r\n event.once(\"Event.decrypted\", () => {\r\n this.aggregateRelations(event);\r\n });\r\n return;\r\n }\r\n\r\n const relation = event.getRelation();\r\n\r\n if (!relation) {\r\n return;\r\n }\r\n\r\n const relatesToEventId = relation.event_id;\r\n const relationType = relation.rel_type;\r\n const eventType = event.getType(); // debuglog(\"Aggregating relation: \", event.getId(), eventType, relation);\r\n\r\n let relationsForEvent = this._relations[relatesToEventId];\r\n\r\n if (!relationsForEvent) {\r\n relationsForEvent = this._relations[relatesToEventId] = {};\r\n }\r\n\r\n let relationsWithRelType = relationsForEvent[relationType];\r\n\r\n if (!relationsWithRelType) {\r\n relationsWithRelType = relationsForEvent[relationType] = {};\r\n }\r\n\r\n let relationsWithEventType = relationsWithRelType[eventType];\r\n let isNewRelations = false;\r\n let relatesToEvent;\r\n\r\n if (!relationsWithEventType) {\r\n relationsWithEventType = relationsWithRelType[eventType] = new _relations.Relations(relationType, eventType, this.room);\r\n isNewRelations = true;\r\n relatesToEvent = this.findEventById(relatesToEventId) || this.room.getPendingEvent(relatesToEventId);\r\n\r\n if (relatesToEvent) {\r\n relationsWithEventType.setTargetEvent(relatesToEvent);\r\n }\r\n }\r\n\r\n relationsWithEventType.addEvent(event); // only emit once event has been added to relations\r\n\r\n if (isNewRelations && relatesToEvent) {\r\n relatesToEvent.emit(\"Event.relationsCreated\", relationType, eventType);\r\n }\r\n};\r\n/**\r\n * Fires whenever the timeline in a room is updated.\r\n * @event module:client~MatrixClient#\"Room.timeline\"\r\n * @param {MatrixEvent} event The matrix event which caused this event to fire.\r\n * @param {?Room} room The room, if any, whose timeline was updated.\r\n * @param {boolean} toStartOfTimeline True if this event was added to the start\r\n * @param {boolean} removed True if this event has just been removed from the timeline\r\n * (beginning; oldest) of the timeline e.g. due to pagination.\r\n *\r\n * @param {object} data more data about the event\r\n *\r\n * @param {module:models/event-timeline.EventTimeline} data.timeline the timeline the\r\n * event was added to/removed from\r\n *\r\n * @param {boolean} data.liveEvent true if the event was a real-time event\r\n * added to the end of the live timeline\r\n *\r\n * @example\r\n * matrixClient.on(\"Room.timeline\",\r\n * function(event, room, toStartOfTimeline, removed, data) {\r\n * if (!toStartOfTimeline && data.liveEvent) {\r\n * var messageToAppend = room.timeline.[room.timeline.length - 1];\r\n * }\r\n * });\r\n */\r\n\r\n/**\r\n * Fires whenever the live timeline in a room is reset.\r\n *\r\n * When we get a 'limited' sync (for example, after a network outage), we reset\r\n * the live timeline to be empty before adding the recent events to the new\r\n * timeline. This event is fired after the timeline is reset, and before the\r\n * new events are added.\r\n *\r\n * @event module:client~MatrixClient#\"Room.timelineReset\"\r\n * @param {Room} room The room whose live timeline was reset, if any\r\n * @param {EventTimelineSet} timelineSet timelineSet room whose live timeline was reset\r\n * @param {boolean} resetAllTimelines True if all timelines were reset.\r\n */","\"use strict\";\r\n\r\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\");\r\n\r\nObject.defineProperty(exports, \"__esModule\", {\r\n value: true\r\n});\r\nexports.logger = void 0;\r\n\r\nvar _loglevel = _interopRequireDefault(require(\"loglevel\"));\r\n\r\n/*\r\nCopyright 2018 André Jaenisch\r\nCopyright 2019, 2021 The Matrix.org Foundation C.I.C.\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\");\r\nyou may not use this file except in compliance with the License.\r\nYou may obtain a copy of the License at\r\n\r\n http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless required by applicable law or agreed to in writing, software\r\ndistributed under the License is distributed on an \"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\nSee the License for the specific language governing permissions and\r\nlimitations under the License.\r\n*/\r\n\r\n/**\r\n * @module logger\r\n */\r\n// This is to demonstrate, that you can use any namespace you want.\r\n// Namespaces allow you to turn on/off the logging for specific parts of the\r\n// application.\r\n// An idea would be to control this via an environment variable (on Node.js).\r\n// See https://www.npmjs.com/package/debug to see how this could be implemented\r\n// Part of #332 is introducing a logging library in the first place.\r\nconst DEFAULT_NAMESPACE = \"matrix\"; // because rageshakes in react-sdk hijack the console log, also at module load time,\r\n// initializing the logger here races with the initialization of rageshakes.\r\n// to avoid the issue, we override the methodFactory of loglevel that binds to the\r\n// console methods at initialization time by a factory that looks up the console methods\r\n// when logging so we always get the current value of console methods.\r\n\r\n_loglevel.default.methodFactory = function (methodName, logLevel, loggerName) {\r\n return function (...args) {\r\n /* eslint-disable @babel/no-invalid-this */\r\n if (this.prefix) {\r\n args.unshift(this.prefix);\r\n }\r\n /* eslint-enable @babel/no-invalid-this */\r\n\r\n\r\n const supportedByConsole = methodName === \"error\" || methodName === \"warn\" || methodName === \"trace\" || methodName === \"info\";\r\n /* eslint-disable no-console */\r\n\r\n return\r\n\r\n if (supportedByConsole) {\r\n return console[methodName](...args);\r\n } else {\r\n return console.log(...args);\r\n }\r\n /* eslint-enable no-console */\r\n\r\n };\r\n};\r\n/**\r\n * Drop-in replacement for console
using {@link https://www.npmjs.com/package/loglevel|loglevel}.\r\n * Can be tailored down to specific use cases if needed.\r\n */\r\n\r\n\r\nconst logger = _loglevel.default.getLogger(DEFAULT_NAMESPACE);\r\n\r\nexports.logger = logger;\r\nlogger.setLevel(_loglevel.default.levels.DEBUG);\r\n\r\nfunction extendLogger(logger) {\r\n logger.withPrefix = function (prefix) {\r\n const existingPrefix = this.prefix || \"\";\r\n return getPrefixedLogger(existingPrefix + prefix);\r\n };\r\n}\r\n\r\nextendLogger(logger);\r\n\r\nfunction getPrefixedLogger(prefix) {\r\n const prefixLogger = _loglevel.default.getLogger(`${DEFAULT_NAMESPACE}-${prefix}`);\r\n\r\n if (prefixLogger.prefix !== prefix) {\r\n // Only do this setup work the first time through, as loggers are saved by name.\r\n extendLogger(prefixLogger);\r\n prefixLogger.prefix = prefix;\r\n prefixLogger.setLevel(_loglevel.default.levels.DEBUG);\r\n }\r\n\r\n return prefixLogger;\r\n}","var Buffer = require('safe-buffer').Buffer\nvar Transform = require('stream').Transform\nvar StringDecoder = require('string_decoder').StringDecoder\nvar inherits = require('inherits')\n\nfunction CipherBase (hashMode) {\n Transform.call(this)\n this.hashMode = typeof hashMode === 'string'\n if (this.hashMode) {\n this[hashMode] = this._finalOrDigest\n } else {\n this.final = this._finalOrDigest\n }\n if (this._final) {\n this.__final = this._final\n this._final = null\n }\n this._decoder = null\n this._encoding = null\n}\ninherits(CipherBase, Transform)\n\nCipherBase.prototype.update = function (data, inputEnc, outputEnc) {\n if (typeof data === 'string') {\n data = Buffer.from(data, inputEnc)\n }\n\n var outData = this._update(data)\n if (this.hashMode) return this\n\n if (outputEnc) {\n outData = this._toString(outData, outputEnc)\n }\n\n return outData\n}\n\nCipherBase.prototype.setAutoPadding = function () {}\nCipherBase.prototype.getAuthTag = function () {\n throw new Error('trying to get auth tag in unsupported state')\n}\n\nCipherBase.prototype.setAuthTag = function () {\n throw new Error('trying to set auth tag in unsupported state')\n}\n\nCipherBase.prototype.setAAD = function () {\n throw new Error('trying to set aad in unsupported state')\n}\n\nCipherBase.prototype._transform = function (data, _, next) {\n var err\n try {\n if (this.hashMode) {\n this._update(data)\n } else {\n this.push(this._update(data))\n }\n } catch (e) {\n err = e\n } finally {\n next(err)\n }\n}\nCipherBase.prototype._flush = function (done) {\n var err\n try {\n this.push(this.__final())\n } catch (e) {\n err = e\n }\n\n done(err)\n}\nCipherBase.prototype._finalOrDigest = function (outputEnc) {\n var outData = this.__final() || Buffer.alloc(0)\n if (outputEnc) {\n outData = this._toString(outData, outputEnc, true)\n }\n return outData\n}\n\nCipherBase.prototype._toString = function (value, enc, fin) {\n if (!this._decoder) {\n this._decoder = new StringDecoder(enc)\n this._encoding = enc\n }\n\n if (this._encoding !== enc) throw new Error('can\\'t switch encodings')\n\n var out = this._decoder.write(value)\n if (fin) {\n out += this._decoder.end()\n }\n\n return out\n}\n\nmodule.exports = CipherBase\n","\"use strict\";\r\n\r\nvar _interopRequireWildcard = require(\"@babel/runtime/helpers/interopRequireWildcard\");\r\n\r\nObject.defineProperty(exports, \"__esModule\", {\r\n value: true\r\n});\r\nexports.SyncApi = SyncApi;\r\n\r\nvar _user = require(\"./models/user\");\r\n\r\nvar _room = require(\"./models/room\");\r\n\r\nvar _group = require(\"./models/group\");\r\n\r\nvar utils = _interopRequireWildcard(require(\"./utils\"));\r\n\r\nvar _filter = require(\"./filter\");\r\n\r\nvar _eventTimeline = require(\"./models/event-timeline\");\r\n\r\nvar _pushprocessor = require(\"./pushprocessor\");\r\n\r\nvar _logger = require(\"./logger\");\r\n\r\nvar _errors = require(\"./errors\");\r\n\r\n/*\r\nCopyright 2015, 2016 OpenMarket Ltd\r\nCopyright 2017 Vector Creations Ltd\r\nCopyright 2018 New Vector Ltd\r\nCopyright 2019 The Matrix.org Foundation C.I.C.\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\");\r\nyou may not use this file except in compliance with the License.\r\nYou may obtain a copy of the License at\r\n\r\n http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless required by applicable law or agreed to in writing, software\r\ndistributed under the License is distributed on an \"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\nSee the License for the specific language governing permissions and\r\nlimitations under the License.\r\n*/\r\n\r\n/*\r\n * TODO:\r\n * This class mainly serves to take all the syncing logic out of client.js and\r\n * into a separate file. It's all very fluid, and this class gut wrenches a lot\r\n * of MatrixClient props (e.g. _http). Given we want to support WebSockets as\r\n * an alternative syncing API, we may want to have a proper syncing interface\r\n * for HTTP and WS at some point.\r\n */\r\nconst DEBUG = true; // /sync requests allow you to set a timeout= but the request may continue\r\n// beyond that and wedge forever, so we need to track how long we are willing\r\n// to keep open the connection. This constant is *ADDED* to the timeout= value\r\n// to determine the max time we're willing to wait.\r\n\r\nconst BUFFER_PERIOD_MS = 80 * 1000; // Number of consecutive failed syncs that will lead to a syncState of ERROR as opposed\r\n// to RECONNECTING. This is needed to inform the client of server issues when the\r\n// keepAlive is successful but the server /sync fails.\r\n\r\nconst FAILED_SYNC_ERROR_THRESHOLD = 3;\r\n\r\nfunction getFilterName(userId, suffix) {\r\n // scope this on the user ID because people may login on many accounts\r\n // and they all need to be stored!\r\n return \"FILTER_SYNC_\" + userId + (suffix ? \"_\" + suffix : \"\");\r\n}\r\n\r\nfunction debuglog(...params) {\r\n if (!DEBUG) {\r\n return;\r\n }\r\n\r\n _logger.logger.log(...params);\r\n}\r\n/**\r\n * Internal class - unstable.\r\n * Construct an entity which is able to sync with a homeserver.\r\n * @constructor\r\n * @param {MatrixClient} client The matrix client instance to use.\r\n * @param {Object} opts Config options\r\n * @param {module:crypto=} opts.crypto Crypto manager\r\n * @param {Function=} opts.canResetEntireTimeline A function which is called\r\n * with a room ID and returns a boolean. It should return 'true' if the SDK can\r\n * SAFELY remove events from this room. It may not be safe to remove events if\r\n * there are other references to the timelines for this room.\r\n * Default: returns false.\r\n * @param {Boolean=} opts.disablePresence True to perform syncing without automatically\r\n * updating presence.\r\n */\r\n\r\n\r\nfunction SyncApi(client, opts) {\r\n this.client = client;\r\n opts = opts || {};\r\n opts.initialSyncLimit = opts.initialSyncLimit === undefined ? 8 : opts.initialSyncLimit;\r\n opts.resolveInvitesToProfiles = opts.resolveInvitesToProfiles || false;\r\n opts.pollTimeout = opts.pollTimeout || 30 * 1000;\r\n opts.pendingEventOrdering = opts.pendingEventOrdering || \"chronological\";\r\n\r\n if (!opts.canResetEntireTimeline) {\r\n opts.canResetEntireTimeline = function (roomId) {\r\n return false;\r\n };\r\n }\r\n\r\n this.opts = opts;\r\n this._peekRoom = null;\r\n this._currentSyncRequest = null;\r\n this._syncState = null;\r\n this._syncStateData = null; // additional data (eg. error object for failed sync)\r\n\r\n this._catchingUp = false;\r\n this._running = false;\r\n this._keepAliveTimer = null;\r\n this._connectionReturnedDefer = null;\r\n this._notifEvents = []; // accumulator of sync events in the current sync response\r\n\r\n this._failedSyncCount = 0; // Number of consecutive failed /sync requests\r\n\r\n this._storeIsInvalid = false; // flag set if the store needs to be cleared before we can start\r\n\r\n if (client.getNotifTimelineSet()) {\r\n client.reEmitter.reEmit(client.getNotifTimelineSet(), [\"Room.timeline\", \"Room.timelineReset\"]);\r\n }\r\n}\r\n/**\r\n * @param {string} roomId\r\n * @return {Room}\r\n */\r\n\r\n\r\nSyncApi.prototype.createRoom = function (roomId) {\r\n const client = this.client;\r\n const {\r\n timelineSupport,\r\n unstableClientRelationAggregation\r\n } = client;\r\n const room = new _room.Room(roomId, client, client.getUserId(), {\r\n lazyLoadMembers: this.opts.lazyLoadMembers,\r\n pendingEventOrdering: this.opts.pendingEventOrdering,\r\n timelineSupport,\r\n unstableClientRelationAggregation\r\n });\r\n client.reEmitter.reEmit(room, [\"Room.name\", \"Room.avatar\", \"Room.timeline\", \"Room.redaction\", \"Room.redactionCancelled\", \"Room.receipt\", \"Room.tags\", \"Room.timelineReset\", \"Room.localEchoUpdated\", \"Room.accountData\", \"Room.myMembership\", \"Room.replaceEvent\"]);\r\n\r\n this._registerStateListeners(room);\r\n\r\n return room;\r\n};\r\n/**\r\n * @param {string} groupId\r\n * @return {Group}\r\n */\r\n\r\n\r\nSyncApi.prototype.createGroup = function (groupId) {\r\n const client = this.client;\r\n const group = new _group.Group(groupId);\r\n client.reEmitter.reEmit(group, [\"Group.profile\", \"Group.myMembership\"]);\r\n client.store.storeGroup(group);\r\n return group;\r\n};\r\n/**\r\n * @param {Room} room\r\n * @private\r\n */\r\n\r\n\r\nSyncApi.prototype._registerStateListeners = function (room) {\r\n const client = this.client; // we need to also re-emit room state and room member events, so hook it up\r\n // to the client now. We need to add a listener for RoomState.members in\r\n // order to hook them correctly. (TODO: find a better way?)\r\n\r\n client.reEmitter.reEmit(room.currentState, [\"RoomState.events\", \"RoomState.members\", \"RoomState.newMember\"]);\r\n room.currentState.on(\"RoomState.newMember\", function (event, state, member) {\r\n member.user = client.getUser(member.userId);\r\n client.reEmitter.reEmit(member, [\"RoomMember.name\", \"RoomMember.typing\", \"RoomMember.powerLevel\", \"RoomMember.membership\"]);\r\n });\r\n};\r\n/**\r\n * @param {Room} room\r\n * @private\r\n */\r\n\r\n\r\nSyncApi.prototype._deregisterStateListeners = function (room) {\r\n // could do with a better way of achieving this.\r\n room.currentState.removeAllListeners(\"RoomState.events\");\r\n room.currentState.removeAllListeners(\"RoomState.members\");\r\n room.currentState.removeAllListeners(\"RoomState.newMember\");\r\n};\r\n/**\r\n * Sync rooms the user has left.\r\n * @return {Promise} Resolved when they've been added to the store.\r\n */\r\n\r\n\r\nSyncApi.prototype.syncLeftRooms = function () {\r\n const client = this.client;\r\n const self = this; // grab a filter with limit=1 and include_leave=true\r\n\r\n const filter = new _filter.Filter(this.client.credentials.userId);\r\n filter.setTimelineLimit(1);\r\n filter.setIncludeLeaveRooms(true);\r\n const localTimeoutMs = this.opts.pollTimeout + BUFFER_PERIOD_MS;\r\n const qps = {\r\n timeout: 0 // don't want to block since this is a single isolated req\r\n\r\n };\r\n return client.getOrCreateFilter(getFilterName(client.credentials.userId, \"LEFT_ROOMS\"), filter).then(function (filterId) {\r\n qps.filter = filterId;\r\n return client._http.authedRequest(undefined, \"GET\", \"/sync\", qps, undefined, localTimeoutMs);\r\n }).then(function (data) {\r\n let leaveRooms = [];\r\n\r\n if (data.rooms && data.rooms.leave) {\r\n leaveRooms = self._mapSyncResponseToRoomArray(data.rooms.leave);\r\n }\r\n\r\n const rooms = [];\r\n leaveRooms.forEach(function (leaveObj) {\r\n const room = leaveObj.room;\r\n rooms.push(room);\r\n\r\n if (!leaveObj.isBrandNewRoom) {\r\n // the intention behind syncLeftRooms is to add in rooms which were\r\n // *omitted* from the initial /sync. Rooms the user were joined to\r\n // but then left whilst the app is running will appear in this list\r\n // and we do not want to bother with them since they will have the\r\n // current state already (and may get dupe messages if we add\r\n // yet more timeline events!), so skip them.\r\n // NB: When we persist rooms to localStorage this will be more\r\n // complicated...\r\n return;\r\n }\r\n\r\n leaveObj.timeline = leaveObj.timeline || {};\r\n\r\n const timelineEvents = self._mapSyncEventsFormat(leaveObj.timeline, room);\r\n\r\n const stateEvents = self._mapSyncEventsFormat(leaveObj.state, room); // set the back-pagination token. Do this *before* adding any\r\n // events so that clients can start back-paginating.\r\n\r\n\r\n room.getLiveTimeline().setPaginationToken(leaveObj.timeline.prev_batch, _eventTimeline.EventTimeline.BACKWARDS);\r\n\r\n self._processRoomEvents(room, stateEvents, timelineEvents);\r\n\r\n room.recalculate();\r\n client.store.storeRoom(room);\r\n client.emit(\"Room\", room);\r\n\r\n self._processEventsForNotifs(room, timelineEvents);\r\n });\r\n return rooms;\r\n });\r\n};\r\n/**\r\n * Peek into a room. This will result in the room in question being synced so it\r\n * is accessible via getRooms(). Live updates for the room will be provided.\r\n * @param {string} roomId The room ID to peek into.\r\n * @return {Promise} A promise which resolves once the room has been added to the\r\n * store.\r\n */\r\n\r\n\r\nSyncApi.prototype.peek = function (roomId) {\r\n if (this._peekRoom && this._peekRoom.roomId === roomId) {\r\n return Promise.resolve(this._peekRoom);\r\n }\r\n\r\n const client = this.client;\r\n this._peekRoom = this.createRoom(roomId);\r\n return this.client.roomInitialSync(roomId, 20).then(response => {\r\n // make sure things are init'd\r\n response.messages = response.messages || {};\r\n response.messages.chunk = response.messages.chunk || [];\r\n response.state = response.state || []; // FIXME: Mostly duplicated from _processRoomEvents but not entirely\r\n // because \"state\" in this API is at the BEGINNING of the chunk\r\n\r\n const oldStateEvents = utils.map(utils.deepCopy(response.state), client.getEventMapper());\r\n const stateEvents = utils.map(response.state, client.getEventMapper());\r\n const messages = utils.map(response.messages.chunk, client.getEventMapper()); // XXX: copypasted from /sync until we kill off this\r\n // minging v1 API stuff)\r\n // handle presence events (User objects)\r\n\r\n if (response.presence && utils.isArray(response.presence)) {\r\n response.presence.map(client.getEventMapper()).forEach(function (presenceEvent) {\r\n let user = client.store.getUser(presenceEvent.getContent().user_id);\r\n\r\n if (user) {\r\n user.setPresenceEvent(presenceEvent);\r\n } else {\r\n user = createNewUser(client, presenceEvent.getContent().user_id);\r\n user.setPresenceEvent(presenceEvent);\r\n client.store.storeUser(user);\r\n }\r\n\r\n client.emit(\"event\", presenceEvent);\r\n });\r\n } // set the pagination token before adding the events in case people\r\n // fire off pagination requests in response to the Room.timeline\r\n // events.\r\n\r\n\r\n if (response.messages.start) {\r\n this._peekRoom.oldState.paginationToken = response.messages.start;\r\n } // set the state of the room to as it was after the timeline executes\r\n\r\n\r\n this._peekRoom.oldState.setStateEvents(oldStateEvents);\r\n\r\n this._peekRoom.currentState.setStateEvents(stateEvents);\r\n\r\n this._resolveInvites(this._peekRoom);\r\n\r\n this._peekRoom.recalculate(); // roll backwards to diverge old state. addEventsToTimeline\r\n // will overwrite the pagination token, so make sure it overwrites\r\n // it with the right thing.\r\n\r\n\r\n this._peekRoom.addEventsToTimeline(messages.reverse(), true, this._peekRoom.getLiveTimeline(), response.messages.start);\r\n\r\n client.store.storeRoom(this._peekRoom);\r\n client.emit(\"Room\", this._peekRoom);\r\n\r\n this._peekPoll(this._peekRoom);\r\n\r\n return this._peekRoom;\r\n });\r\n};\r\n/**\r\n * Stop polling for updates in the peeked room. NOPs if there is no room being\r\n * peeked.\r\n */\r\n\r\n\r\nSyncApi.prototype.stopPeeking = function () {\r\n this._peekRoom = null;\r\n};\r\n/**\r\n * Do a peek room poll.\r\n * @param {Room} peekRoom\r\n * @param {string?} token from= token\r\n */\r\n\r\n\r\nSyncApi.prototype._peekPoll = function (peekRoom, token) {\r\n if (this._peekRoom !== peekRoom) {\r\n debuglog(\"Stopped peeking in room %s\", peekRoom.roomId);\r\n return;\r\n }\r\n\r\n const self = this; // FIXME: gut wrenching; hard-coded timeout values\r\n\r\n this.client._http.authedRequest(undefined, \"GET\", \"/events\", {\r\n room_id: peekRoom.roomId,\r\n timeout: 30 * 1000,\r\n from: token\r\n }, undefined, 50 * 1000).then(function (res) {\r\n if (self._peekRoom !== peekRoom) {\r\n debuglog(\"Stopped peeking in room %s\", peekRoom.roomId);\r\n return;\r\n } // We have a problem that we get presence both from /events and /sync\r\n // however, /sync only returns presence for users in rooms\r\n // you're actually joined to.\r\n // in order to be sure to get presence for all of the users in the\r\n // peeked room, we handle presence explicitly here. This may result\r\n // in duplicate presence events firing for some users, which is a\r\n // performance drain, but such is life.\r\n // XXX: copypasted from /sync until we can kill this minging v1 stuff.\r\n\r\n\r\n res.chunk.filter(function (e) {\r\n return e.type === \"m.presence\";\r\n }).map(self.client.getEventMapper()).forEach(function (presenceEvent) {\r\n let user = self.client.store.getUser(presenceEvent.getContent().user_id);\r\n\r\n if (user) {\r\n user.setPresenceEvent(presenceEvent);\r\n } else {\r\n user = createNewUser(self.client, presenceEvent.getContent().user_id);\r\n user.setPresenceEvent(presenceEvent);\r\n self.client.store.storeUser(user);\r\n }\r\n\r\n self.client.emit(\"event\", presenceEvent);\r\n }); // strip out events which aren't for the given room_id (e.g presence)\r\n // and also ephemeral events (which we're assuming is anything without\r\n // and event ID because the /events API doesn't separate them).\r\n\r\n const events = res.chunk.filter(function (e) {\r\n return e.room_id === peekRoom.roomId && e.event_id;\r\n }).map(self.client.getEventMapper());\r\n peekRoom.addLiveEvents(events);\r\n\r\n self._peekPoll(peekRoom, res.end);\r\n }, function (err) {\r\n _logger.logger.error(\"[%s] Peek poll failed: %s\", peekRoom.roomId, err);\r\n\r\n setTimeout(function () {\r\n self._peekPoll(peekRoom, token);\r\n }, 30 * 1000);\r\n });\r\n};\r\n/**\r\n * Returns the current state of this sync object\r\n * @see module:client~MatrixClient#event:\"sync\"\r\n * @return {?String}\r\n */\r\n\r\n\r\nSyncApi.prototype.getSyncState = function () {\r\n return this._syncState;\r\n};\r\n/**\r\n * Returns the additional data object associated with\r\n * the current sync state, or null if there is no\r\n * such data.\r\n * Sync errors, if available, are put in the 'error' key of\r\n * this object.\r\n * @return {?Object}\r\n */\r\n\r\n\r\nSyncApi.prototype.getSyncStateData = function () {\r\n return this._syncStateData;\r\n};\r\n\r\nSyncApi.prototype.recoverFromSyncStartupError = async function (savedSyncPromise, err) {\r\n // Wait for the saved sync to complete - we send the pushrules and filter requests\r\n // before the saved sync has finished so they can run in parallel, but only process\r\n // the results after the saved sync is done. Equivalently, we wait for it to finish\r\n // before reporting failures from these functions.\r\n await savedSyncPromise;\r\n\r\n const keepaliveProm = this._startKeepAlives();\r\n\r\n this._updateSyncState(\"ERROR\", {\r\n error: err\r\n });\r\n\r\n await keepaliveProm;\r\n};\r\n/**\r\n * Is the lazy loading option different than in previous session?\r\n * @param {bool} lazyLoadMembers current options for lazy loading\r\n * @return {bool} whether or not the option has changed compared to the previous session */\r\n\r\n\r\nSyncApi.prototype._wasLazyLoadingToggled = async function (lazyLoadMembers) {\r\n lazyLoadMembers = !!lazyLoadMembers; // assume it was turned off before\r\n // if we don't know any better\r\n\r\n let lazyLoadMembersBefore = false;\r\n const isStoreNewlyCreated = await this.client.store.isNewlyCreated();\r\n\r\n if (!isStoreNewlyCreated) {\r\n const prevClientOptions = await this.client.store.getClientOptions();\r\n\r\n if (prevClientOptions) {\r\n lazyLoadMembersBefore = !!prevClientOptions.lazyLoadMembers;\r\n }\r\n\r\n return lazyLoadMembersBefore !== lazyLoadMembers;\r\n }\r\n\r\n return false;\r\n};\r\n\r\nSyncApi.prototype._shouldAbortSync = function (error) {\r\n if (error.errcode === \"M_UNKNOWN_TOKEN\") {\r\n // The logout already happened, we just need to stop.\r\n _logger.logger.warn(\"Token no longer valid - assuming logout\");\r\n\r\n this.stop();\r\n return true;\r\n }\r\n\r\n return false;\r\n};\r\n/**\r\n * Main entry point\r\n */\r\n\r\n\r\nSyncApi.prototype.sync = function () {\r\n const client = this.client;\r\n const self = this;\r\n this._running = true;\r\n\r\n if (global.window && global.window.addEventListener) {\r\n this._onOnlineBound = this._onOnline.bind(this);\r\n global.window.addEventListener(\"online\", this._onOnlineBound, false);\r\n }\r\n\r\n let savedSyncPromise = Promise.resolve();\r\n let savedSyncToken = null; // We need to do one-off checks before we can begin the /sync loop.\r\n // These are:\r\n // 1) We need to get push rules so we can check if events should bing as we get\r\n // them from /sync.\r\n // 2) We need to get/create a filter which we can use for /sync.\r\n // 3) We need to check the lazy loading option matches what was used in the\r\n // stored sync. If it doesn't, we can't use the stored sync.\r\n\r\n async function getPushRules() {\r\n try {\r\n debuglog(\"Getting push rules...\");\r\n const result = await client.getPushRules();\r\n debuglog(\"Got push rules\");\r\n client.pushRules = result;\r\n } catch (err) {\r\n _logger.logger.error(\"Getting push rules failed\", err);\r\n\r\n if (self._shouldAbortSync(err)) return; // wait for saved sync to complete before doing anything else,\r\n // otherwise the sync state will end up being incorrect\r\n\r\n debuglog(\"Waiting for saved sync before retrying push rules...\");\r\n await self.recoverFromSyncStartupError(savedSyncPromise, err);\r\n getPushRules();\r\n return;\r\n }\r\n\r\n checkLazyLoadStatus(); // advance to the next stage\r\n }\r\n\r\n function buildDefaultFilter() {\r\n const filter = new _filter.Filter(client.credentials.userId);\r\n filter.setTimelineLimit(self.opts.initialSyncLimit);\r\n return filter;\r\n }\r\n\r\n const checkLazyLoadStatus = async () => {\r\n debuglog(\"Checking lazy load status...\");\r\n\r\n if (this.opts.lazyLoadMembers && client.isGuest()) {\r\n this.opts.lazyLoadMembers = false;\r\n }\r\n\r\n if (this.opts.lazyLoadMembers) {\r\n debuglog(\"Checking server lazy load support...\");\r\n const supported = await client.doesServerSupportLazyLoading();\r\n\r\n if (supported) {\r\n debuglog(\"Enabling lazy load on sync filter...\");\r\n\r\n if (!this.opts.filter) {\r\n this.opts.filter = buildDefaultFilter();\r\n }\r\n\r\n this.opts.filter.setLazyLoadMembers(true);\r\n } else {\r\n debuglog(\"LL: lazy loading requested but not supported \" + \"by server, so disabling\");\r\n this.opts.lazyLoadMembers = false;\r\n }\r\n } // need to vape the store when enabling LL and wasn't enabled before\r\n\r\n\r\n debuglog(\"Checking whether lazy loading has changed in store...\");\r\n const shouldClear = await this._wasLazyLoadingToggled(this.opts.lazyLoadMembers);\r\n\r\n if (shouldClear) {\r\n this._storeIsInvalid = true;\r\n const reason = _errors.InvalidStoreError.TOGGLED_LAZY_LOADING;\r\n const error = new _errors.InvalidStoreError(reason, !!this.opts.lazyLoadMembers);\r\n\r\n this._updateSyncState(\"ERROR\", {\r\n error\r\n }); // bail out of the sync loop now: the app needs to respond to this error.\r\n // we leave the state as 'ERROR' which isn't great since this normally means\r\n // we're retrying. The client must be stopped before clearing the stores anyway\r\n // so the app should stop the client, clear the store and start it again.\r\n\r\n\r\n _logger.logger.warn(\"InvalidStoreError: store is not usable: stopping sync.\");\r\n\r\n return;\r\n }\r\n\r\n if (this.opts.lazyLoadMembers && this.opts.crypto) {\r\n this.opts.crypto.enableLazyLoading();\r\n }\r\n\r\n try {\r\n debuglog(\"Storing client options...\");\r\n await this.client._storeClientOptions();\r\n debuglog(\"Stored client options\");\r\n } catch (err) {\r\n _logger.logger.error(\"Storing client options failed\", err);\r\n\r\n throw err;\r\n }\r\n\r\n getFilter(); // Now get the filter and start syncing\r\n };\r\n\r\n async function getFilter() {\r\n debuglog(\"Getting filter...\");\r\n let filter;\r\n\r\n if (self.opts.filter) {\r\n filter = self.opts.filter;\r\n } else {\r\n filter = buildDefaultFilter();\r\n }\r\n\r\n let filterId;\r\n\r\n try {\r\n filterId = await client.getOrCreateFilter(getFilterName(client.credentials.userId), filter);\r\n } catch (err) {\r\n _logger.logger.error(\"Getting filter failed\", err);\r\n\r\n if (self._shouldAbortSync(err)) return; // wait for saved sync to complete before doing anything else,\r\n // otherwise the sync state will end up being incorrect\r\n\r\n debuglog(\"Waiting for saved sync before retrying filter...\");\r\n await self.recoverFromSyncStartupError(savedSyncPromise, err);\r\n getFilter();\r\n return;\r\n } // reset the notifications timeline to prepare it to paginate from\r\n // the current point in time.\r\n // The right solution would be to tie /sync pagination tokens into\r\n // /notifications API somehow.\r\n\r\n\r\n client.resetNotifTimelineSet();\r\n\r\n if (self._currentSyncRequest === null) {\r\n // Send this first sync request here so we can then wait for the saved\r\n // sync data to finish processing before we process the results of this one.\r\n debuglog(\"Sending first sync request...\");\r\n self._currentSyncRequest = self._doSyncRequest({\r\n filterId\r\n }, savedSyncToken);\r\n } // Now wait for the saved sync to finish...\r\n\r\n\r\n debuglog(\"Waiting for saved sync before starting sync processing...\");\r\n await savedSyncPromise;\r\n\r\n self._sync({\r\n filterId\r\n });\r\n }\r\n\r\n if (client.isGuest()) {\r\n // no push rules for guests, no access to POST filter for guests.\r\n self._sync({});\r\n } else {\r\n // Pull the saved sync token out first, before the worker starts sending\r\n // all the sync data which could take a while. This will let us send our\r\n // first incremental sync request before we've processed our saved data.\r\n debuglog(\"Getting saved sync token...\");\r\n savedSyncPromise = client.store.getSavedSyncToken().then(tok => {\r\n debuglog(\"Got saved sync token\");\r\n savedSyncToken = tok;\r\n debuglog(\"Getting saved sync...\");\r\n return client.store.getSavedSync();\r\n }).then(savedSync => {\r\n debuglog(`Got reply from saved sync, exists? ${!!savedSync}`);\r\n\r\n if (savedSync) {\r\n return self._syncFromCache(savedSync);\r\n }\r\n }).catch(err => {\r\n _logger.logger.error(\"Getting saved sync failed\", err);\r\n }); // Now start the first incremental sync request: this can also\r\n // take a while so if we set it going now, we can wait for it\r\n // to finish while we process our saved sync data.\r\n\r\n getPushRules();\r\n }\r\n};\r\n/**\r\n * Stops the sync object from syncing.\r\n */\r\n\r\n\r\nSyncApi.prototype.stop = function () {\r\n debuglog(\"SyncApi.stop\");\r\n\r\n if (global.window) {\r\n global.window.removeEventListener(\"online\", this._onOnlineBound, false);\r\n this._onOnlineBound = undefined;\r\n }\r\n\r\n this._running = false;\r\n\r\n if (this._currentSyncRequest) {\r\n this._currentSyncRequest.abort();\r\n }\r\n\r\n if (this._keepAliveTimer) {\r\n clearTimeout(this._keepAliveTimer);\r\n this._keepAliveTimer = null;\r\n }\r\n};\r\n/**\r\n * Retry a backed off syncing request immediately. This should only be used when\r\n * the user explicitly attempts to retry their lost connection.\r\n * @return {boolean} True if this resulted in a request being retried.\r\n */\r\n\r\n\r\nSyncApi.prototype.retryImmediately = function () {\r\n if (!this._connectionReturnedDefer) {\r\n return false;\r\n }\r\n\r\n this._startKeepAlives(0);\r\n\r\n return true;\r\n};\r\n/**\r\n * Process a single set of cached sync data.\r\n * @param {Object} savedSync a saved sync that was persisted by a store. This\r\n * should have been acquired via client.store.getSavedSync().\r\n */\r\n\r\n\r\nSyncApi.prototype._syncFromCache = async function (savedSync) {\r\n debuglog(\"sync(): not doing HTTP hit, instead returning stored /sync data\");\r\n const nextSyncToken = savedSync.nextBatch; // Set sync token for future incremental syncing\r\n\r\n this.client.store.setSyncToken(nextSyncToken); // No previous sync, set old token to null\r\n\r\n const syncEventData = {\r\n oldSyncToken: null,\r\n nextSyncToken,\r\n catchingUp: false,\r\n fromCache: true\r\n };\r\n const data = {\r\n next_batch: nextSyncToken,\r\n rooms: savedSync.roomsData,\r\n groups: savedSync.groupsData,\r\n account_data: {\r\n events: savedSync.accountData\r\n }\r\n };\r\n\r\n try {\r\n await this._processSyncResponse(syncEventData, data);\r\n } catch (e) {\r\n _logger.logger.error(\"Error processing cached sync\", e.stack || e);\r\n } // Don't emit a prepared if we've bailed because the store is invalid:\r\n // in this case the client will not be usable until stopped & restarted\r\n // so this would be useless and misleading.\r\n\r\n\r\n if (!this._storeIsInvalid) {\r\n this._updateSyncState(\"PREPARED\", syncEventData);\r\n }\r\n};\r\n/**\r\n * Invoke me to do /sync calls\r\n * @param {Object} syncOptions\r\n * @param {string} syncOptions.filterId\r\n * @param {boolean} syncOptions.hasSyncedBefore\r\n */\r\n\r\n\r\nSyncApi.prototype._sync = async function (syncOptions) {\r\n const client = this.client;\r\n\r\n if (!this._running) {\r\n debuglog(\"Sync no longer running: exiting.\");\r\n\r\n if (this._connectionReturnedDefer) {\r\n this._connectionReturnedDefer.reject();\r\n\r\n this._connectionReturnedDefer = null;\r\n }\r\n\r\n this._updateSyncState(\"STOPPED\");\r\n\r\n return;\r\n }\r\n\r\n const syncToken = client.store.getSyncToken();\r\n let data;\r\n\r\n try {\r\n //debuglog('Starting sync since=' + syncToken);\r\n if (this._currentSyncRequest === null) {\r\n this._currentSyncRequest = this._doSyncRequest(syncOptions, syncToken);\r\n }\r\n\r\n data = await this._currentSyncRequest;\r\n } catch (e) {\r\n this._onSyncError(e, syncOptions);\r\n\r\n return;\r\n } finally {\r\n this._currentSyncRequest = null;\r\n } //debuglog('Completed sync, next_batch=' + data.next_batch);\r\n // set the sync token NOW *before* processing the events. We do this so\r\n // if something barfs on an event we can skip it rather than constantly\r\n // polling with the same token.\r\n\r\n\r\n client.store.setSyncToken(data.next_batch); // Reset after a successful sync\r\n\r\n this._failedSyncCount = 0;\r\n await client.store.setSyncData(data);\r\n const syncEventData = {\r\n oldSyncToken: syncToken,\r\n nextSyncToken: data.next_batch,\r\n catchingUp: this._catchingUp\r\n };\r\n\r\n if (this.opts.crypto) {\r\n // tell the crypto module we're about to process a sync\r\n // response\r\n await this.opts.crypto.onSyncWillProcess(syncEventData);\r\n }\r\n\r\n try {\r\n await this._processSyncResponse(syncEventData, data);\r\n } catch (e) {\r\n // log the exception with stack if we have it, else fall back\r\n // to the plain description\r\n _logger.logger.error(\"Caught /sync error\", e.stack || e); // Emit the exception for client handling\r\n\r\n\r\n this.client.emit(\"sync.unexpectedError\", e);\r\n } // update this as it may have changed\r\n\r\n\r\n syncEventData.catchingUp = this._catchingUp; // emit synced events\r\n\r\n if (!syncOptions.hasSyncedBefore) {\r\n this._updateSyncState(\"PREPARED\", syncEventData);\r\n\r\n syncOptions.hasSyncedBefore = true;\r\n } // tell the crypto module to do its processing. It may block (to do a\r\n // /keys/changes request).\r\n\r\n\r\n if (this.opts.crypto) {\r\n await this.opts.crypto.onSyncCompleted(syncEventData);\r\n } // keep emitting SYNCING -> SYNCING for clients who want to do bulk updates\r\n\r\n\r\n this._updateSyncState(\"SYNCING\", syncEventData);\r\n\r\n if (client.store.wantsSave()) {\r\n // We always save the device list (if it's dirty) before saving the sync data:\r\n // this means we know the saved device list data is at least as fresh as the\r\n // stored sync data which means we don't have to worry that we may have missed\r\n // device changes. We can also skip the delay since we're not calling this very\r\n // frequently (and we don't really want to delay the sync for it).\r\n if (this.opts.crypto) {\r\n await this.opts.crypto.saveDeviceList(0);\r\n } // tell databases that everything is now in a consistent state and can be saved.\r\n\r\n\r\n client.store.save();\r\n } // Begin next sync\r\n\r\n\r\n this._sync(syncOptions);\r\n};\r\n\r\nSyncApi.prototype._doSyncRequest = function (syncOptions, syncToken) {\r\n const qps = this._getSyncParams(syncOptions, syncToken);\r\n\r\n return this.client._http.authedRequest(undefined, \"GET\", \"/sync\", qps, undefined, qps.timeout + BUFFER_PERIOD_MS);\r\n};\r\n\r\nSyncApi.prototype._getSyncParams = function (syncOptions, syncToken) {\r\n let pollTimeout = this.opts.pollTimeout;\r\n\r\n if (this.getSyncState() !== 'SYNCING' || this._catchingUp) {\r\n // unless we are happily syncing already, we want the server to return\r\n // as quickly as possible, even if there are no events queued. This\r\n // serves two purposes:\r\n //\r\n // * When the connection dies, we want to know asap when it comes back,\r\n // so that we can hide the error from the user. (We don't want to\r\n // have to wait for an event or a timeout).\r\n //\r\n // * We want to know if the server has any to_device messages queued up\r\n // for us. We do that by calling it with a zero timeout until it\r\n // doesn't give us any more to_device messages.\r\n this._catchingUp = true;\r\n pollTimeout = 0;\r\n }\r\n\r\n let filterId = syncOptions.filterId;\r\n\r\n if (this.client.isGuest() && !filterId) {\r\n filterId = this._getGuestFilter();\r\n }\r\n\r\n const qps = {\r\n filter: filterId,\r\n timeout: pollTimeout\r\n };\r\n\r\n if (this.opts.disablePresence) {\r\n qps.set_presence = \"offline\";\r\n }\r\n\r\n if (syncToken) {\r\n qps.since = syncToken;\r\n } else {\r\n // use a cachebuster for initialsyncs, to make sure that\r\n // we don't get a stale sync\r\n // (https://github.com/vector-im/vector-web/issues/1354)\r\n qps._cacheBuster = Date.now();\r\n }\r\n\r\n if (this.getSyncState() == 'ERROR' || this.getSyncState() == 'RECONNECTING') {\r\n // we think the connection is dead. If it comes back up, we won't know\r\n // about it till /sync returns. If the timeout= is high, this could\r\n // be a long time. Set it to 0 when doing retries so we don't have to wait\r\n // for an event or a timeout before emiting the SYNCING event.\r\n qps.timeout = 0;\r\n }\r\n\r\n return qps;\r\n};\r\n\r\nSyncApi.prototype._onSyncError = function (err, syncOptions) {\r\n if (!this._running) {\r\n debuglog(\"Sync no longer running: exiting\");\r\n\r\n if (this._connectionReturnedDefer) {\r\n this._connectionReturnedDefer.reject();\r\n\r\n this._connectionReturnedDefer = null;\r\n }\r\n\r\n this._updateSyncState(\"STOPPED\");\r\n\r\n return;\r\n }\r\n\r\n _logger.logger.error(\"/sync error %s\", err);\r\n\r\n _logger.logger.error(err);\r\n\r\n if (this._shouldAbortSync(err)) {\r\n return;\r\n }\r\n\r\n this._failedSyncCount++;\r\n\r\n _logger.logger.log('Number of consecutive failed sync requests:', this._failedSyncCount);\r\n\r\n debuglog(\"Starting keep-alive\"); // Note that we do *not* mark the sync connection as\r\n // lost yet: we only do this if a keepalive poke\r\n // fails, since long lived HTTP connections will\r\n // go away sometimes and we shouldn't treat this as\r\n // erroneous. We set the state to 'reconnecting'\r\n // instead, so that clients can observe this state\r\n // if they wish.\r\n\r\n this._startKeepAlives().then(connDidFail => {\r\n // Only emit CATCHUP if we detected a connectivity error: if we didn't,\r\n // it's quite likely the sync will fail again for the same reason and we\r\n // want to stay in ERROR rather than keep flip-flopping between ERROR\r\n // and CATCHUP.\r\n if (connDidFail && this.getSyncState() === 'ERROR') {\r\n this._updateSyncState(\"CATCHUP\", {\r\n oldSyncToken: null,\r\n nextSyncToken: null,\r\n catchingUp: true\r\n });\r\n }\r\n\r\n this._sync(syncOptions);\r\n });\r\n\r\n this._currentSyncRequest = null; // Transition from RECONNECTING to ERROR after a given number of failed syncs\r\n\r\n this._updateSyncState(this._failedSyncCount >= FAILED_SYNC_ERROR_THRESHOLD ? \"ERROR\" : \"RECONNECTING\", {\r\n error: err\r\n });\r\n};\r\n/**\r\n * Process data returned from a sync response and propagate it\r\n * into the model objects\r\n *\r\n * @param {Object} syncEventData Object containing sync tokens associated with this sync\r\n * @param {Object} data The response from /sync\r\n */\r\n\r\n\r\nSyncApi.prototype._processSyncResponse = async function (syncEventData, data) {\r\n const client = this.client;\r\n const self = this; // data looks like:\r\n // {\r\n // next_batch: $token,\r\n // presence: { events: [] },\r\n // account_data: { events: [] },\r\n // device_lists: { changed: [\"@user:server\", ... ]},\r\n // to_device: { events: [] },\r\n // device_one_time_keys_count: { signed_curve25519: 42 },\r\n // rooms: {\r\n // invite: {\r\n // $roomid: {\r\n // invite_state: { events: [] }\r\n // }\r\n // },\r\n // join: {\r\n // $roomid: {\r\n // state: { events: [] },\r\n // timeline: { events: [], prev_batch: $token, limited: true },\r\n // ephemeral: { events: [] },\r\n // summary: {\r\n // m.heroes: [ $user_id ],\r\n // m.joined_member_count: $count,\r\n // m.invited_member_count: $count\r\n // },\r\n // account_data: { events: [] },\r\n // unread_notifications: {\r\n // highlight_count: 0,\r\n // notification_count: 0,\r\n // }\r\n // }\r\n // },\r\n // leave: {\r\n // $roomid: {\r\n // state: { events: [] },\r\n // timeline: { events: [], prev_batch: $token }\r\n // }\r\n // }\r\n // },\r\n // groups: {\r\n // invite: {\r\n // $groupId: {\r\n // inviter: $inviter,\r\n // profile: {\r\n // avatar_url: $avatarUrl,\r\n // name: $groupName,\r\n // },\r\n // },\r\n // },\r\n // join: {},\r\n // leave: {},\r\n // },\r\n // }\r\n // TODO-arch:\r\n // - Each event we pass through needs to be emitted via 'event', can we\r\n // do this in one place?\r\n // - The isBrandNewRoom boilerplate is boilerplatey.\r\n // handle presence events (User objects)\r\n\r\n if (data.presence && utils.isArray(data.presence.events)) {\r\n data.presence.events.map(client.getEventMapper()).forEach(function (presenceEvent) {\r\n let user = client.store.getUser(presenceEvent.getSender());\r\n\r\n if (user) {\r\n user.setPresenceEvent(presenceEvent);\r\n } else {\r\n user = createNewUser(client, presenceEvent.getSender());\r\n user.setPresenceEvent(presenceEvent);\r\n client.store.storeUser(user);\r\n }\r\n\r\n client.emit(\"event\", presenceEvent);\r\n });\r\n } // handle non-room account_data\r\n\r\n\r\n if (data.account_data && utils.isArray(data.account_data.events)) {\r\n const events = data.account_data.events.map(client.getEventMapper());\r\n const prevEventsMap = events.reduce((m, c) => {\r\n m[c.getId()] = client.store.getAccountData(c.getType());\r\n return m;\r\n }, {});\r\n client.store.storeAccountDataEvents(events);\r\n events.forEach(function (accountDataEvent) {\r\n // Honour push rules that come down the sync stream but also\r\n // honour push rules that were previously cached. Base rules\r\n // will be updated when we receive push rules via getPushRules\r\n // (see SyncApi.prototype.sync) before syncing over the network.\r\n if (accountDataEvent.getType() === 'm.push_rules') {\r\n const rules = accountDataEvent.getContent();\r\n client.pushRules = _pushprocessor.PushProcessor.rewriteDefaultRules(rules);\r\n }\r\n\r\n const prevEvent = prevEventsMap[accountDataEvent.getId()];\r\n client.emit(\"accountData\", accountDataEvent, prevEvent);\r\n return accountDataEvent;\r\n });\r\n } // handle to-device events\r\n\r\n\r\n if (data.to_device && utils.isArray(data.to_device.events) && data.to_device.events.length > 0) {\r\n const cancelledKeyVerificationTxns = [];\r\n data.to_device.events.map(client.getEventMapper()).map(toDeviceEvent => {\r\n // map is a cheap inline forEach\r\n // We want to flag m.key.verification.start events as cancelled\r\n // if there's an accompanying m.key.verification.cancel event, so\r\n // we pull out the transaction IDs from the cancellation events\r\n // so we can flag the verification events as cancelled in the loop\r\n // below.\r\n if (toDeviceEvent.getType() === \"m.key.verification.cancel\") {\r\n const txnId = toDeviceEvent.getContent()['transaction_id'];\r\n\r\n if (txnId) {\r\n cancelledKeyVerificationTxns.push(txnId);\r\n }\r\n } // as mentioned above, .map is a cheap inline forEach, so return\r\n // the unmodified event.\r\n\r\n\r\n return toDeviceEvent;\r\n }).forEach(function (toDeviceEvent) {\r\n const content = toDeviceEvent.getContent();\r\n\r\n if (toDeviceEvent.getType() == \"m.room.message\" && content.msgtype == \"m.bad.encrypted\") {\r\n // the mapper already logged a warning.\r\n _logger.logger.log('Ignoring undecryptable to-device event from ' + toDeviceEvent.getSender());\r\n\r\n return;\r\n }\r\n\r\n if (toDeviceEvent.getType() === \"m.key.verification.start\" || toDeviceEvent.getType() === \"m.key.verification.request\") {\r\n const txnId = content['transaction_id'];\r\n\r\n if (cancelledKeyVerificationTxns.includes(txnId)) {\r\n toDeviceEvent.flagCancelled();\r\n }\r\n }\r\n\r\n client.emit(\"toDeviceEvent\", toDeviceEvent);\r\n });\r\n } else {\r\n // no more to-device events: we can stop polling with a short timeout.\r\n this._catchingUp = false;\r\n }\r\n\r\n if (data.groups) {\r\n if (data.groups.invite) {\r\n this._processGroupSyncEntry(data.groups.invite, 'invite');\r\n }\r\n\r\n if (data.groups.join) {\r\n this._processGroupSyncEntry(data.groups.join, 'join');\r\n }\r\n\r\n if (data.groups.leave) {\r\n this._processGroupSyncEntry(data.groups.leave, 'leave');\r\n }\r\n } // the returned json structure is a bit crap, so make it into a\r\n // nicer form (array) after applying sanity to make sure we don't fail\r\n // on missing keys (on the off chance)\r\n\r\n\r\n let inviteRooms = [];\r\n let joinRooms = [];\r\n let leaveRooms = [];\r\n\r\n if (data.rooms) {\r\n if (data.rooms.invite) {\r\n inviteRooms = this._mapSyncResponseToRoomArray(data.rooms.invite);\r\n }\r\n\r\n if (data.rooms.join) {\r\n joinRooms = this._mapSyncResponseToRoomArray(data.rooms.join);\r\n }\r\n\r\n if (data.rooms.leave) {\r\n leaveRooms = this._mapSyncResponseToRoomArray(data.rooms.leave);\r\n }\r\n }\r\n\r\n this._notifEvents = []; // Handle invites\r\n\r\n inviteRooms.forEach(function (inviteObj) {\r\n const room = inviteObj.room;\r\n\r\n const stateEvents = self._mapSyncEventsFormat(inviteObj.invite_state, room);\r\n\r\n self._processRoomEvents(room, stateEvents);\r\n\r\n if (inviteObj.isBrandNewRoom) {\r\n room.recalculate();\r\n client.store.storeRoom(room);\r\n client.emit(\"Room\", room);\r\n }\r\n\r\n stateEvents.forEach(function (e) {\r\n client.emit(\"event\", e);\r\n });\r\n room.updateMyMembership(\"invite\");\r\n }); // Handle joins\r\n\r\n await utils.promiseMapSeries(joinRooms, async function (joinObj) {\r\n const room = joinObj.room;\r\n\r\n const stateEvents = self._mapSyncEventsFormat(joinObj.state, room);\r\n\r\n const timelineEvents = self._mapSyncEventsFormat(joinObj.timeline, room);\r\n\r\n const ephemeralEvents = self._mapSyncEventsFormat(joinObj.ephemeral);\r\n\r\n const accountDataEvents = self._mapSyncEventsFormat(joinObj.account_data); // we do this first so it's correct when any of the events fire\r\n\r\n\r\n if (joinObj.unread_notifications) {\r\n room.setUnreadNotificationCount('total', joinObj.unread_notifications.notification_count); // We track unread notifications ourselves in encrypted rooms, so don't\r\n // bother setting it here. We trust our calculations better than the\r\n // server's for this case, and therefore will assume that our non-zero\r\n // count is accurate.\r\n\r\n const encrypted = client.isRoomEncrypted(room.roomId);\r\n\r\n if (!encrypted || encrypted && room.getUnreadNotificationCount('highlight') <= 0) {\r\n room.setUnreadNotificationCount('highlight', joinObj.unread_notifications.highlight_count);\r\n }\r\n }\r\n\r\n joinObj.timeline = joinObj.timeline || {};\r\n\r\n if (joinObj.isBrandNewRoom) {\r\n // set the back-pagination token. Do this *before* adding any\r\n // events so that clients can start back-paginating.\r\n room.getLiveTimeline().setPaginationToken(joinObj.timeline.prev_batch, _eventTimeline.EventTimeline.BACKWARDS);\r\n } else if (joinObj.timeline.limited) {\r\n let limited = true; // we've got a limited sync, so we *probably* have a gap in the\r\n // timeline, so should reset. But we might have been peeking or\r\n // paginating and already have some of the events, in which\r\n // case we just want to append any subsequent events to the end\r\n // of the existing timeline.\r\n //\r\n // This is particularly important in the case that we already have\r\n // *all* of the events in the timeline - in that case, if we reset\r\n // the timeline, we'll end up with an entirely empty timeline,\r\n // which we'll try to paginate but not get any new events (which\r\n // will stop us linking the empty timeline into the chain).\r\n //\r\n\r\n for (let i = timelineEvents.length - 1; i >= 0; i--) {\r\n const eventId = timelineEvents[i].getId();\r\n\r\n if (room.getTimelineForEvent(eventId)) {\r\n debuglog(\"Already have event \" + eventId + \" in limited \" + \"sync - not resetting\");\r\n limited = false; // we might still be missing some of the events before i;\r\n // we don't want to be adding them to the end of the\r\n // timeline because that would put them out of order.\r\n\r\n timelineEvents.splice(0, i); // XXX: there's a problem here if the skipped part of the\r\n // timeline modifies the state set in stateEvents, because\r\n // we'll end up using the state from stateEvents rather\r\n // than the later state from timelineEvents. We probably\r\n // need to wind stateEvents forward over the events we're\r\n // skipping.\r\n\r\n break;\r\n }\r\n }\r\n\r\n if (limited) {\r\n self._deregisterStateListeners(room);\r\n\r\n room.resetLiveTimeline(joinObj.timeline.prev_batch, self.opts.canResetEntireTimeline(room.roomId) ? null : syncEventData.oldSyncToken); // We have to assume any gap in any timeline is\r\n // reason to stop incrementally tracking notifications and\r\n // reset the timeline.\r\n\r\n client.resetNotifTimelineSet();\r\n\r\n self._registerStateListeners(room);\r\n }\r\n }\r\n\r\n self._processRoomEvents(room, stateEvents, timelineEvents, syncEventData.fromCache); // set summary after processing events,\r\n // because it will trigger a name calculation\r\n // which needs the room state to be up to date\r\n\r\n\r\n if (joinObj.summary) {\r\n room.setSummary(joinObj.summary);\r\n } // we deliberately don't add ephemeral events to the timeline\r\n\r\n\r\n room.addEphemeralEvents(ephemeralEvents); // we deliberately don't add accountData to the timeline\r\n\r\n room.addAccountData(accountDataEvents);\r\n room.recalculate();\r\n\r\n if (joinObj.isBrandNewRoom) {\r\n client.store.storeRoom(room);\r\n client.emit(\"Room\", room);\r\n }\r\n\r\n self._processEventsForNotifs(room, timelineEvents);\r\n\r\n async function processRoomEvent(e) {\r\n client.emit(\"event\", e);\r\n\r\n if (e.isState() && e.getType() == \"m.room.encryption\" && self.opts.crypto) {\r\n await self.opts.crypto.onCryptoEvent(e);\r\n }\r\n\r\n if (e.isState() && e.getType() === \"im.vector.user_status\") {\r\n let user = client.store.getUser(e.getStateKey());\r\n\r\n if (user) {\r\n user._unstable_updateStatusMessage(e);\r\n } else {\r\n user = createNewUser(client, e.getStateKey());\r\n\r\n user._unstable_updateStatusMessage(e);\r\n\r\n client.store.storeUser(user);\r\n }\r\n }\r\n }\r\n\r\n await utils.promiseMapSeries(stateEvents, processRoomEvent);\r\n await utils.promiseMapSeries(timelineEvents, processRoomEvent);\r\n ephemeralEvents.forEach(function (e) {\r\n client.emit(\"event\", e);\r\n });\r\n accountDataEvents.forEach(function (e) {\r\n client.emit(\"event\", e);\r\n });\r\n room.updateMyMembership(\"join\");\r\n }); // Handle leaves (e.g. kicked rooms)\r\n\r\n leaveRooms.forEach(function (leaveObj) {\r\n const room = leaveObj.room;\r\n\r\n const stateEvents = self._mapSyncEventsFormat(leaveObj.state, room);\r\n\r\n const timelineEvents = self._mapSyncEventsFormat(leaveObj.timeline, room);\r\n\r\n const accountDataEvents = self._mapSyncEventsFormat(leaveObj.account_data);\r\n\r\n self._processRoomEvents(room, stateEvents, timelineEvents);\r\n\r\n room.addAccountData(accountDataEvents);\r\n room.recalculate();\r\n\r\n if (leaveObj.isBrandNewRoom) {\r\n client.store.storeRoom(room);\r\n client.emit(\"Room\", room);\r\n }\r\n\r\n self._processEventsForNotifs(room, timelineEvents);\r\n\r\n stateEvents.forEach(function (e) {\r\n client.emit(\"event\", e);\r\n });\r\n timelineEvents.forEach(function (e) {\r\n client.emit(\"event\", e);\r\n });\r\n accountDataEvents.forEach(function (e) {\r\n client.emit(\"event\", e);\r\n });\r\n room.updateMyMembership(\"leave\");\r\n }); // update the notification timeline, if appropriate.\r\n // we only do this for live events, as otherwise we can't order them sanely\r\n // in the timeline relative to ones paginated in by /notifications.\r\n // XXX: we could fix this by making EventTimeline support chronological\r\n // ordering... but it doesn't, right now.\r\n\r\n if (syncEventData.oldSyncToken && this._notifEvents.length) {\r\n this._notifEvents.sort(function (a, b) {\r\n return a.getTs() - b.getTs();\r\n });\r\n\r\n this._notifEvents.forEach(function (event) {\r\n client.getNotifTimelineSet().addLiveEvent(event);\r\n });\r\n } // Handle device list updates\r\n\r\n\r\n if (data.device_lists) {\r\n if (this.opts.crypto) {\r\n await this.opts.crypto.handleDeviceListChanges(syncEventData, data.device_lists);\r\n } else {// FIXME if we *don't* have a crypto module, we still need to\r\n // invalidate the device lists. But that would require a\r\n // substantial bit of rework :/.\r\n }\r\n } // Handle one_time_keys_count\r\n\r\n\r\n if (this.opts.crypto && data.device_one_time_keys_count) {\r\n const currentCount = data.device_one_time_keys_count.signed_curve25519 || 0;\r\n this.opts.crypto.updateOneTimeKeyCount(currentCount);\r\n }\r\n\r\n if (this.opts.crypto && data[\"org.matrix.msc2732.device_unused_fallback_key_types\"]) {\r\n // The presence of device_unused_fallback_key_types indicates that the\r\n // server supports fallback keys. If there's no unused\r\n // signed_curve25519 fallback key we need a new one.\r\n const unusedFallbackKeys = data[\"org.matrix.msc2732.device_unused_fallback_key_types\"];\r\n this.opts.crypto.setNeedsNewFallback(unusedFallbackKeys instanceof Array && !unusedFallbackKeys.includes(\"signed_curve25519\"));\r\n }\r\n};\r\n/**\r\n * Starts polling the connectivity check endpoint\r\n * @param {number} delay How long to delay until the first poll.\r\n * defaults to a short, randomised interval (to prevent\r\n * tightlooping if /versions succeeds but /sync etc. fail).\r\n * @return {promise} which resolves once the connection returns\r\n */\r\n\r\n\r\nSyncApi.prototype._startKeepAlives = function (delay) {\r\n if (delay === undefined) {\r\n delay = 2000 + Math.floor(Math.random() * 5000);\r\n }\r\n\r\n if (this._keepAliveTimer !== null) {\r\n clearTimeout(this._keepAliveTimer);\r\n }\r\n\r\n const self = this;\r\n\r\n if (delay > 0) {\r\n self._keepAliveTimer = setTimeout(self._pokeKeepAlive.bind(self), delay);\r\n } else {\r\n self._pokeKeepAlive();\r\n }\r\n\r\n if (!this._connectionReturnedDefer) {\r\n this._connectionReturnedDefer = utils.defer();\r\n }\r\n\r\n return this._connectionReturnedDefer.promise;\r\n};\r\n/**\r\n * Make a dummy call to /_matrix/client/versions, to see if the HS is\r\n * reachable.\r\n *\r\n * On failure, schedules a call back to itself. On success, resolves\r\n * this._connectionReturnedDefer.\r\n *\r\n * @param {bool} connDidFail True if a connectivity failure has been detected. Optional.\r\n */\r\n\r\n\r\nSyncApi.prototype._pokeKeepAlive = function (connDidFail) {\r\n if (connDidFail === undefined) connDidFail = false;\r\n const self = this;\r\n\r\n function success() {\r\n clearTimeout(self._keepAliveTimer);\r\n\r\n if (self._connectionReturnedDefer) {\r\n self._connectionReturnedDefer.resolve(connDidFail);\r\n\r\n self._connectionReturnedDefer = null;\r\n }\r\n }\r\n\r\n this.client._http.request(undefined, // callback\r\n \"GET\", \"/_matrix/client/versions\", undefined, // queryParams\r\n undefined, // data\r\n {\r\n prefix: '',\r\n localTimeoutMs: 15 * 1000\r\n }).then(function () {\r\n success();\r\n }, function (err) {\r\n if (err.httpStatus == 400 || err.httpStatus == 404) {\r\n // treat this as a success because the server probably just doesn't\r\n // support /versions: point is, we're getting a response.\r\n // We wait a short time though, just in case somehow the server\r\n // is in a mode where it 400s /versions responses and sync etc.\r\n // responses fail, this will mean we don't hammer in a loop.\r\n self._keepAliveTimer = setTimeout(success, 2000);\r\n } else {\r\n connDidFail = true;\r\n self._keepAliveTimer = setTimeout(self._pokeKeepAlive.bind(self, connDidFail), 5000 + Math.floor(Math.random() * 5000)); // A keepalive has failed, so we emit the\r\n // error state (whether or not this is the\r\n // first failure).\r\n // Note we do this after setting the timer:\r\n // this lets the unit tests advance the mock\r\n // clock when they get the error.\r\n\r\n self._updateSyncState(\"ERROR\", {\r\n error: err\r\n });\r\n }\r\n });\r\n};\r\n/**\r\n * @param {Object} groupsSection Groups section object, eg. response.groups.invite\r\n * @param {string} sectionName Which section this is ('invite', 'join' or 'leave')\r\n */\r\n\r\n\r\nSyncApi.prototype._processGroupSyncEntry = function (groupsSection, sectionName) {\r\n // Processes entries from 'groups' section of the sync stream\r\n for (const groupId of Object.keys(groupsSection)) {\r\n const groupInfo = groupsSection[groupId];\r\n let group = this.client.store.getGroup(groupId);\r\n const isBrandNew = group === null;\r\n\r\n if (group === null) {\r\n group = this.createGroup(groupId);\r\n }\r\n\r\n if (groupInfo.profile) {\r\n group.setProfile(groupInfo.profile.name, groupInfo.profile.avatar_url);\r\n }\r\n\r\n if (groupInfo.inviter) {\r\n group.setInviter({\r\n userId: groupInfo.inviter\r\n });\r\n }\r\n\r\n group.setMyMembership(sectionName);\r\n\r\n if (isBrandNew) {\r\n // Now we've filled in all the fields, emit the Group event\r\n this.client.emit(\"Group\", group);\r\n }\r\n }\r\n};\r\n/**\r\n * @param {Object} obj\r\n * @return {Object[]}\r\n */\r\n\r\n\r\nSyncApi.prototype._mapSyncResponseToRoomArray = function (obj) {\r\n // Maps { roomid: {stuff}, roomid: {stuff} }\r\n // to\r\n // [{stuff+Room+isBrandNewRoom}, {stuff+Room+isBrandNewRoom}]\r\n const client = this.client;\r\n const self = this;\r\n return utils.keys(obj).map(function (roomId) {\r\n const arrObj = obj[roomId];\r\n let room = client.store.getRoom(roomId);\r\n let isBrandNewRoom = false;\r\n\r\n if (!room) {\r\n room = self.createRoom(roomId);\r\n isBrandNewRoom = true;\r\n }\r\n\r\n arrObj.room = room;\r\n arrObj.isBrandNewRoom = isBrandNewRoom;\r\n return arrObj;\r\n });\r\n};\r\n/**\r\n * @param {Object} obj\r\n * @param {Room} room\r\n * @return {MatrixEvent[]}\r\n */\r\n\r\n\r\nSyncApi.prototype._mapSyncEventsFormat = function (obj, room) {\r\n if (!obj || !utils.isArray(obj.events)) {\r\n return [];\r\n }\r\n\r\n const mapper = this.client.getEventMapper();\r\n return obj.events.map(function (e) {\r\n if (room) {\r\n e.room_id = room.roomId;\r\n }\r\n\r\n return mapper(e);\r\n });\r\n};\r\n/**\r\n * @param {Room} room\r\n */\r\n\r\n\r\nSyncApi.prototype._resolveInvites = function (room) {\r\n if (!room || !this.opts.resolveInvitesToProfiles) {\r\n return;\r\n }\r\n\r\n const client = this.client; // For each invited room member we want to give them a displayname/avatar url\r\n // if they have one (the m.room.member invites don't contain this).\r\n\r\n room.getMembersWithMembership(\"invite\").forEach(function (member) {\r\n if (member._requestedProfileInfo) {\r\n return;\r\n }\r\n\r\n member._requestedProfileInfo = true; // try to get a cached copy first.\r\n\r\n const user = client.getUser(member.userId);\r\n let promise;\r\n\r\n if (user) {\r\n promise = Promise.resolve({\r\n avatar_url: user.avatarUrl,\r\n displayname: user.displayName\r\n });\r\n } else {\r\n promise = client.getProfileInfo(member.userId);\r\n }\r\n\r\n promise.then(function (info) {\r\n // slightly naughty by doctoring the invite event but this means all\r\n // the code paths remain the same between invite/join display name stuff\r\n // which is a worthy trade-off for some minor pollution.\r\n const inviteEvent = member.events.member;\r\n\r\n if (inviteEvent.getContent().membership !== \"invite\") {\r\n // between resolving and now they have since joined, so don't clobber\r\n return;\r\n }\r\n\r\n inviteEvent.getContent().avatar_url = info.avatar_url;\r\n inviteEvent.getContent().displayname = info.displayname; // fire listeners\r\n\r\n member.setMembershipEvent(inviteEvent, room.currentState);\r\n }, function (err) {// OH WELL.\r\n });\r\n });\r\n};\r\n/**\r\n * @param {Room} room\r\n * @param {MatrixEvent[]} stateEventList A list of state events. This is the state\r\n * at the *START* of the timeline list if it is supplied.\r\n * @param {MatrixEvent[]} [timelineEventList] A list of timeline events. Lower index\r\n * @param {boolean} fromCache whether the sync response came from cache\r\n * is earlier in time. Higher index is later.\r\n */\r\n\r\n\r\nSyncApi.prototype._processRoomEvents = function (room, stateEventList, timelineEventList, fromCache) {\r\n // If there are no events in the timeline yet, initialise it with\r\n // the given state events\r\n const liveTimeline = room.getLiveTimeline();\r\n const timelineWasEmpty = liveTimeline.getEvents().length == 0;\r\n\r\n if (timelineWasEmpty) {\r\n // Passing these events into initialiseState will freeze them, so we need\r\n // to compute and cache the push actions for them now, otherwise sync dies\r\n // with an attempt to assign to read only property.\r\n // XXX: This is pretty horrible and is assuming all sorts of behaviour from\r\n // these functions that it shouldn't be. We should probably either store the\r\n // push actions cache elsewhere so we can freeze MatrixEvents, or otherwise\r\n // find some solution where MatrixEvents are immutable but allow for a cache\r\n // field.\r\n for (const ev of stateEventList) {\r\n this.client.getPushActionsForEvent(ev);\r\n }\r\n\r\n liveTimeline.initialiseState(stateEventList);\r\n }\r\n\r\n this._resolveInvites(room); // recalculate the room name at this point as adding events to the timeline\r\n // may make notifications appear which should have the right name.\r\n // XXX: This looks suspect: we'll end up recalculating the room once here\r\n // and then again after adding events (_processSyncResponse calls it after\r\n // calling us) even if no state events were added. It also means that if\r\n // one of the room events in timelineEventList is something that needs\r\n // a recalculation (like m.room.name) we won't recalculate until we've\r\n // finished adding all the events, which will cause the notification to have\r\n // the old room name rather than the new one.\r\n\r\n\r\n room.recalculate(); // If the timeline wasn't empty, we process the state events here: they're\r\n // defined as updates to the state before the start of the timeline, so this\r\n // starts to roll the state forward.\r\n // XXX: That's what we *should* do, but this can happen if we were previously\r\n // peeking in a room, in which case we obviously do *not* want to add the\r\n // state events here onto the end of the timeline. Historically, the js-sdk\r\n // has just set these new state events on the old and new state. This seems\r\n // very wrong because there could be events in the timeline that diverge the\r\n // state, in which case this is going to leave things out of sync. However,\r\n // for now I think it;s best to behave the same as the code has done previously.\r\n\r\n if (!timelineWasEmpty) {\r\n // XXX: As above, don't do this...\r\n //room.addLiveEvents(stateEventList || []);\r\n // Do this instead...\r\n room.oldState.setStateEvents(stateEventList || []);\r\n room.currentState.setStateEvents(stateEventList || []);\r\n } // execute the timeline events. This will continue to diverge the current state\r\n // if the timeline has any state events in it.\r\n // This also needs to be done before running push rules on the events as they need\r\n // to be decorated with sender etc.\r\n\r\n\r\n room.addLiveEvents(timelineEventList || [], null, fromCache);\r\n};\r\n/**\r\n * Takes a list of timelineEvents and adds and adds to _notifEvents\r\n * as appropriate.\r\n * This must be called after the room the events belong to has been stored.\r\n *\r\n * @param {Room} room\r\n * @param {MatrixEvent[]} [timelineEventList] A list of timeline events. Lower index\r\n * is earlier in time. Higher index is later.\r\n */\r\n\r\n\r\nSyncApi.prototype._processEventsForNotifs = function (room, timelineEventList) {\r\n // gather our notifications into this._notifEvents\r\n if (this.client.getNotifTimelineSet()) {\r\n for (let i = 0; i < timelineEventList.length; i++) {\r\n const pushActions = this.client.getPushActionsForEvent(timelineEventList[i]);\r\n\r\n if (pushActions && pushActions.notify && pushActions.tweaks && pushActions.tweaks.highlight) {\r\n this._notifEvents.push(timelineEventList[i]);\r\n }\r\n }\r\n }\r\n};\r\n/**\r\n * @return {string}\r\n */\r\n\r\n\r\nSyncApi.prototype._getGuestFilter = function () {\r\n const guestRooms = this.client._guestRooms; // FIXME: horrible gut-wrenching\r\n\r\n if (!guestRooms) {\r\n return \"{}\";\r\n } // we just need to specify the filter inline if we're a guest because guests\r\n // can't create filters.\r\n\r\n\r\n return JSON.stringify({\r\n room: {\r\n timeline: {\r\n limit: 20\r\n }\r\n }\r\n });\r\n};\r\n/**\r\n * Sets the sync state and emits an event to say so\r\n * @param {String} newState The new state string\r\n * @param {Object} data Object of additional data to emit in the event\r\n */\r\n\r\n\r\nSyncApi.prototype._updateSyncState = function (newState, data) {\r\n const old = this._syncState;\r\n this._syncState = newState;\r\n this._syncStateData = data;\r\n this.client.emit(\"sync\", this._syncState, old, data);\r\n};\r\n/**\r\n * Event handler for the 'online' event\r\n * This event is generally unreliable and precise behaviour\r\n * varies between browsers, so we poll for connectivity too,\r\n * but this might help us reconnect a little faster.\r\n */\r\n\r\n\r\nSyncApi.prototype._onOnline = function () {\r\n debuglog(\"Browser thinks we are back online\");\r\n\r\n this._startKeepAlives(0);\r\n};\r\n\r\nfunction createNewUser(client, userId) {\r\n const user = new _user.User(userId);\r\n client.reEmitter.reEmit(user, [\"User.avatarUrl\", \"User.displayName\", \"User.presence\", \"User.currentlyActive\", \"User.lastPresenceTs\"]);\r\n return user;\r\n}","export * from \"-!../../../../node_modules/vue-style-loader/index.js??ref--10-oneOf-1-0!../../../../node_modules/css-loader/dist/cjs.js??ref--10-oneOf-1-1!../../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../../node_modules/postcss-loader/src/index.js??ref--10-oneOf-1-2!../../../../node_modules/postcss-loader/src/index.js??ref--10-oneOf-1-3!../../../../node_modules/sass-loader/dist/cjs.js??ref--10-oneOf-1-4!../../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./name.vue?vue&type=style&index=0&id=72a9c575&scoped=true&lang=sass&\"","'use strict';\n\nmodule.exports = function bind(fn, thisArg) {\n return function wrap() {\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n return fn.apply(thisArg, args);\n };\n};\n","// Imports\nvar ___CSS_LOADER_API_IMPORT___ = require(\"../../node_modules/css-loader/dist/runtime/api.js\");\nexports = ___CSS_LOADER_API_IMPORT___(false);\n// Module\nexports.push([module.id, \".topheader[data-v-62a1ab6a]{top:0;z-index:999}.newChat[data-v-62a1ab6a] #maincontent .headerSpacer,.newChat[data-v-62a1ab6a] #maincontent .headerSpacerWrapper,.newChat[data-v-62a1ab6a] #maincontent .headerSpacerWrapperOvf{overflow:visible!important}.newChat.minimized.active[data-v-62a1ab6a] #maincontent .desktopList{display:none}\", \"\"]);\n// Exports\nmodule.exports = exports;\n","// Imports\nvar ___CSS_LOADER_API_IMPORT___ = require(\"../../../../../../node_modules/css-loader/dist/runtime/api.js\");\nexports = ___CSS_LOADER_API_IMPORT___(false);\n// Module\nexports.push([module.id, \"br[data-v-ba5ac396]{content:\\\"\\\"}.sname[data-v-ba5ac396]{font-weight:700}.listPreview[data-v-ba5ac396]{display:flex;align-items:center}.statusWrapper[data-v-ba5ac396]{padding-left:.5em}.statusWrapper .my[data-v-ba5ac396]{font-size:.6em;opacity:.5}.previewMessage[data-v-ba5ac396]{min-height:25px}\", \"\"]);\n// Exports\nmodule.exports = exports;\n","'use strict';\n\n/* eslint no-invalid-this: 1 */\n\nvar ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';\nvar slice = Array.prototype.slice;\nvar toStr = Object.prototype.toString;\nvar funcType = '[object Function]';\n\nmodule.exports = function bind(that) {\n var target = this;\n if (typeof target !== 'function' || toStr.call(target) !== funcType) {\n throw new TypeError(ERROR_MESSAGE + target);\n }\n var args = slice.call(arguments, 1);\n\n var bound;\n var binder = function () {\n if (this instanceof bound) {\n var result = target.apply(\n this,\n args.concat(slice.call(arguments))\n );\n if (Object(result) === result) {\n return result;\n }\n return this;\n } else {\n return target.apply(\n that,\n args.concat(slice.call(arguments))\n );\n }\n };\n\n var boundLength = Math.max(0, target.length - args.length);\n var boundArgs = [];\n for (var i = 0; i < boundLength; i++) {\n boundArgs.push('$' + i);\n }\n\n bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);\n\n if (target.prototype) {\n var Empty = function Empty() {};\n Empty.prototype = target.prototype;\n bound.prototype = new Empty();\n Empty.prototype = null;\n }\n\n return bound;\n};\n","'use strict';\n\nvar colorString = require('color-string');\nvar convert = require('color-convert');\n\nvar _slice = [].slice;\n\nvar skippedModels = [\n\t// to be honest, I don't really feel like keyword belongs in color convert, but eh.\n\t'keyword',\n\n\t// gray conflicts with some method names, and has its own method defined.\n\t'gray',\n\n\t// shouldn't really be in color-convert either...\n\t'hex'\n];\n\nvar hashedModelKeys = {};\nObject.keys(convert).forEach(function (model) {\n\thashedModelKeys[_slice.call(convert[model].labels).sort().join('')] = model;\n});\n\nvar limiters = {};\n\nfunction Color(obj, model) {\n\tif (!(this instanceof Color)) {\n\t\treturn new Color(obj, model);\n\t}\n\n\tif (model && model in skippedModels) {\n\t\tmodel = null;\n\t}\n\n\tif (model && !(model in convert)) {\n\t\tthrow new Error('Unknown model: ' + model);\n\t}\n\n\tvar i;\n\tvar channels;\n\n\tif (obj == null) { // eslint-disable-line no-eq-null,eqeqeq\n\t\tthis.model = 'rgb';\n\t\tthis.color = [0, 0, 0];\n\t\tthis.valpha = 1;\n\t} else if (obj instanceof Color) {\n\t\tthis.model = obj.model;\n\t\tthis.color = obj.color.slice();\n\t\tthis.valpha = obj.valpha;\n\t} else if (typeof obj === 'string') {\n\t\tvar result = colorString.get(obj);\n\t\tif (result === null) {\n\t\t\tthrow new Error('Unable to parse color from string: ' + obj);\n\t\t}\n\n\t\tthis.model = result.model;\n\t\tchannels = convert[this.model].channels;\n\t\tthis.color = result.value.slice(0, channels);\n\t\tthis.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;\n\t} else if (obj.length) {\n\t\tthis.model = model || 'rgb';\n\t\tchannels = convert[this.model].channels;\n\t\tvar newArr = _slice.call(obj, 0, channels);\n\t\tthis.color = zeroArray(newArr, channels);\n\t\tthis.valpha = typeof obj[channels] === 'number' ? obj[channels] : 1;\n\t} else if (typeof obj === 'number') {\n\t\t// this is always RGB - can be converted later on.\n\t\tobj &= 0xFFFFFF;\n\t\tthis.model = 'rgb';\n\t\tthis.color = [\n\t\t\t(obj >> 16) & 0xFF,\n\t\t\t(obj >> 8) & 0xFF,\n\t\t\tobj & 0xFF\n\t\t];\n\t\tthis.valpha = 1;\n\t} else {\n\t\tthis.valpha = 1;\n\n\t\tvar keys = Object.keys(obj);\n\t\tif ('alpha' in obj) {\n\t\t\tkeys.splice(keys.indexOf('alpha'), 1);\n\t\t\tthis.valpha = typeof obj.alpha === 'number' ? obj.alpha : 0;\n\t\t}\n\n\t\tvar hashedKeys = keys.sort().join('');\n\t\tif (!(hashedKeys in hashedModelKeys)) {\n\t\t\tthrow new Error('Unable to parse color from object: ' + JSON.stringify(obj));\n\t\t}\n\n\t\tthis.model = hashedModelKeys[hashedKeys];\n\n\t\tvar labels = convert[this.model].labels;\n\t\tvar color = [];\n\t\tfor (i = 0; i < labels.length; i++) {\n\t\t\tcolor.push(obj[labels[i]]);\n\t\t}\n\n\t\tthis.color = zeroArray(color);\n\t}\n\n\t// perform limitations (clamping, etc.)\n\tif (limiters[this.model]) {\n\t\tchannels = convert[this.model].channels;\n\t\tfor (i = 0; i < channels; i++) {\n\t\t\tvar limit = limiters[this.model][i];\n\t\t\tif (limit) {\n\t\t\t\tthis.color[i] = limit(this.color[i]);\n\t\t\t}\n\t\t}\n\t}\n\n\tthis.valpha = Math.max(0, Math.min(1, this.valpha));\n\n\tif (Object.freeze) {\n\t\tObject.freeze(this);\n\t}\n}\n\nColor.prototype = {\n\ttoString: function () {\n\t\treturn this.string();\n\t},\n\n\ttoJSON: function () {\n\t\treturn this[this.model]();\n\t},\n\n\tstring: function (places) {\n\t\tvar self = this.model in colorString.to ? this : this.rgb();\n\t\tself = self.round(typeof places === 'number' ? places : 1);\n\t\tvar args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);\n\t\treturn colorString.to[self.model](args);\n\t},\n\n\tpercentString: function (places) {\n\t\tvar self = this.rgb().round(typeof places === 'number' ? places : 1);\n\t\tvar args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);\n\t\treturn colorString.to.rgb.percent(args);\n\t},\n\n\tarray: function () {\n\t\treturn this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);\n\t},\n\n\tobject: function () {\n\t\tvar result = {};\n\t\tvar channels = convert[this.model].channels;\n\t\tvar labels = convert[this.model].labels;\n\n\t\tfor (var i = 0; i < channels; i++) {\n\t\t\tresult[labels[i]] = this.color[i];\n\t\t}\n\n\t\tif (this.valpha !== 1) {\n\t\t\tresult.alpha = this.valpha;\n\t\t}\n\n\t\treturn result;\n\t},\n\n\tunitArray: function () {\n\t\tvar rgb = this.rgb().color;\n\t\trgb[0] /= 255;\n\t\trgb[1] /= 255;\n\t\trgb[2] /= 255;\n\n\t\tif (this.valpha !== 1) {\n\t\t\trgb.push(this.valpha);\n\t\t}\n\n\t\treturn rgb;\n\t},\n\n\tunitObject: function () {\n\t\tvar rgb = this.rgb().object();\n\t\trgb.r /= 255;\n\t\trgb.g /= 255;\n\t\trgb.b /= 255;\n\n\t\tif (this.valpha !== 1) {\n\t\t\trgb.alpha = this.valpha;\n\t\t}\n\n\t\treturn rgb;\n\t},\n\n\tround: function (places) {\n\t\tplaces = Math.max(places || 0, 0);\n\t\treturn new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model);\n\t},\n\n\talpha: function (val) {\n\t\tif (arguments.length) {\n\t\t\treturn new Color(this.color.concat(Math.max(0, Math.min(1, val))), this.model);\n\t\t}\n\n\t\treturn this.valpha;\n\t},\n\n\t// rgb\n\tred: getset('rgb', 0, maxfn(255)),\n\tgreen: getset('rgb', 1, maxfn(255)),\n\tblue: getset('rgb', 2, maxfn(255)),\n\n\thue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, function (val) { return ((val % 360) + 360) % 360; }), // eslint-disable-line brace-style\n\n\tsaturationl: getset('hsl', 1, maxfn(100)),\n\tlightness: getset('hsl', 2, maxfn(100)),\n\n\tsaturationv: getset('hsv', 1, maxfn(100)),\n\tvalue: getset('hsv', 2, maxfn(100)),\n\n\tchroma: getset('hcg', 1, maxfn(100)),\n\tgray: getset('hcg', 2, maxfn(100)),\n\n\twhite: getset('hwb', 1, maxfn(100)),\n\twblack: getset('hwb', 2, maxfn(100)),\n\n\tcyan: getset('cmyk', 0, maxfn(100)),\n\tmagenta: getset('cmyk', 1, maxfn(100)),\n\tyellow: getset('cmyk', 2, maxfn(100)),\n\tblack: getset('cmyk', 3, maxfn(100)),\n\n\tx: getset('xyz', 0, maxfn(100)),\n\ty: getset('xyz', 1, maxfn(100)),\n\tz: getset('xyz', 2, maxfn(100)),\n\n\tl: getset('lab', 0, maxfn(100)),\n\ta: getset('lab', 1),\n\tb: getset('lab', 2),\n\n\tkeyword: function (val) {\n\t\tif (arguments.length) {\n\t\t\treturn new Color(val);\n\t\t}\n\n\t\treturn convert[this.model].keyword(this.color);\n\t},\n\n\thex: function (val) {\n\t\tif (arguments.length) {\n\t\t\treturn new Color(val);\n\t\t}\n\n\t\treturn colorString.to.hex(this.rgb().round().color);\n\t},\n\n\trgbNumber: function () {\n\t\tvar rgb = this.rgb().color;\n\t\treturn ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);\n\t},\n\n\tluminosity: function () {\n\t\t// http://www.w3.org/TR/WCAG20/#relativeluminancedef\n\t\tvar rgb = this.rgb().color;\n\n\t\tvar lum = [];\n\t\tfor (var i = 0; i < rgb.length; i++) {\n\t\t\tvar chan = rgb[i] / 255;\n\t\t\tlum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);\n\t\t}\n\n\t\treturn 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];\n\t},\n\n\tcontrast: function (color2) {\n\t\t// http://www.w3.org/TR/WCAG20/#contrast-ratiodef\n\t\tvar lum1 = this.luminosity();\n\t\tvar lum2 = color2.luminosity();\n\n\t\tif (lum1 > lum2) {\n\t\t\treturn (lum1 + 0.05) / (lum2 + 0.05);\n\t\t}\n\n\t\treturn (lum2 + 0.05) / (lum1 + 0.05);\n\t},\n\n\tlevel: function (color2) {\n\t\tvar contrastRatio = this.contrast(color2);\n\t\tif (contrastRatio >= 7.1) {\n\t\t\treturn 'AAA';\n\t\t}\n\n\t\treturn (contrastRatio >= 4.5) ? 'AA' : '';\n\t},\n\n\tisDark: function () {\n\t\t// YIQ equation from http://24ways.org/2010/calculating-color-contrast\n\t\tvar rgb = this.rgb().color;\n\t\tvar yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;\n\t\treturn yiq < 128;\n\t},\n\n\tisLight: function () {\n\t\treturn !this.isDark();\n\t},\n\n\tnegate: function () {\n\t\tvar rgb = this.rgb();\n\t\tfor (var i = 0; i < 3; i++) {\n\t\t\trgb.color[i] = 255 - rgb.color[i];\n\t\t}\n\t\treturn rgb;\n\t},\n\n\tlighten: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[2] += hsl.color[2] * ratio;\n\t\treturn hsl;\n\t},\n\n\tdarken: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[2] -= hsl.color[2] * ratio;\n\t\treturn hsl;\n\t},\n\n\tsaturate: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[1] += hsl.color[1] * ratio;\n\t\treturn hsl;\n\t},\n\n\tdesaturate: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[1] -= hsl.color[1] * ratio;\n\t\treturn hsl;\n\t},\n\n\twhiten: function (ratio) {\n\t\tvar hwb = this.hwb();\n\t\thwb.color[1] += hwb.color[1] * ratio;\n\t\treturn hwb;\n\t},\n\n\tblacken: function (ratio) {\n\t\tvar hwb = this.hwb();\n\t\thwb.color[2] += hwb.color[2] * ratio;\n\t\treturn hwb;\n\t},\n\n\tgrayscale: function () {\n\t\t// http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale\n\t\tvar rgb = this.rgb().color;\n\t\tvar val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;\n\t\treturn Color.rgb(val, val, val);\n\t},\n\n\tfade: function (ratio) {\n\t\treturn this.alpha(this.valpha - (this.valpha * ratio));\n\t},\n\n\topaquer: function (ratio) {\n\t\treturn this.alpha(this.valpha + (this.valpha * ratio));\n\t},\n\n\trotate: function (degrees) {\n\t\tvar hsl = this.hsl();\n\t\tvar hue = hsl.color[0];\n\t\thue = (hue + degrees) % 360;\n\t\thue = hue < 0 ? 360 + hue : hue;\n\t\thsl.color[0] = hue;\n\t\treturn hsl;\n\t},\n\n\tmix: function (mixinColor, weight) {\n\t\t// ported from sass implementation in C\n\t\t// https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209\n\t\tif (!mixinColor || !mixinColor.rgb) {\n\t\t\tthrow new Error('Argument to \"mix\" was not a Color instance, but rather an instance of ' + typeof mixinColor);\n\t\t}\n\t\tvar color1 = mixinColor.rgb();\n\t\tvar color2 = this.rgb();\n\t\tvar p = weight === undefined ? 0.5 : weight;\n\n\t\tvar w = 2 * p - 1;\n\t\tvar a = color1.alpha() - color2.alpha();\n\n\t\tvar w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;\n\t\tvar w2 = 1 - w1;\n\n\t\treturn Color.rgb(\n\t\t\t\tw1 * color1.red() + w2 * color2.red(),\n\t\t\t\tw1 * color1.green() + w2 * color2.green(),\n\t\t\t\tw1 * color1.blue() + w2 * color2.blue(),\n\t\t\t\tcolor1.alpha() * p + color2.alpha() * (1 - p));\n\t}\n};\n\n// model conversion methods and static constructors\nObject.keys(convert).forEach(function (model) {\n\tif (skippedModels.indexOf(model) !== -1) {\n\t\treturn;\n\t}\n\n\tvar channels = convert[model].channels;\n\n\t// conversion methods\n\tColor.prototype[model] = function () {\n\t\tif (this.model === model) {\n\t\t\treturn new Color(this);\n\t\t}\n\n\t\tif (arguments.length) {\n\t\t\treturn new Color(arguments, model);\n\t\t}\n\n\t\tvar newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha;\n\t\treturn new Color(assertArray(convert[this.model][model].raw(this.color)).concat(newAlpha), model);\n\t};\n\n\t// 'static' construction methods\n\tColor[model] = function (color) {\n\t\tif (typeof color === 'number') {\n\t\t\tcolor = zeroArray(_slice.call(arguments), channels);\n\t\t}\n\t\treturn new Color(color, model);\n\t};\n});\n\nfunction roundTo(num, places) {\n\treturn Number(num.toFixed(places));\n}\n\nfunction roundToPlace(places) {\n\treturn function (num) {\n\t\treturn roundTo(num, places);\n\t};\n}\n\nfunction getset(model, channel, modifier) {\n\tmodel = Array.isArray(model) ? model : [model];\n\n\tmodel.forEach(function (m) {\n\t\t(limiters[m] || (limiters[m] = []))[channel] = modifier;\n\t});\n\n\tmodel = model[0];\n\n\treturn function (val) {\n\t\tvar result;\n\n\t\tif (arguments.length) {\n\t\t\tif (modifier) {\n\t\t\t\tval = modifier(val);\n\t\t\t}\n\n\t\t\tresult = this[model]();\n\t\t\tresult.color[channel] = val;\n\t\t\treturn result;\n\t\t}\n\n\t\tresult = this[model]().color[channel];\n\t\tif (modifier) {\n\t\t\tresult = modifier(result);\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\nfunction maxfn(max) {\n\treturn function (v) {\n\t\treturn Math.max(0, Math.min(max, v));\n\t};\n}\n\nfunction assertArray(val) {\n\treturn Array.isArray(val) ? val : [val];\n}\n\nfunction zeroArray(arr, length) {\n\tfor (var i = 0; i < length; i++) {\n\t\tif (typeof arr[i] !== 'number') {\n\t\t\tarr[i] = 0;\n\t\t}\n\t}\n\n\treturn arr;\n}\n\nmodule.exports = Color;\n","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar axios_1 = __importDefault(require(\"axios\"));\nvar CancelToken = axios_1.default.CancelToken;\n/**\n * Axios request with timeout throw\n */\nfunction axiosRequest(config) {\n return __awaiter(this, void 0, void 0, function () {\n var timeout, cancel;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n timeout = config.timeout;\n if (timeout) {\n config.cancelToken = new CancelToken(function (c) { return cancel = c; });\n setTimeout(function () {\n cancel('timeout cancel', { timeout: timeout });\n }, timeout);\n }\n return [4 /*yield*/, axios_1.default(config)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n}\nexports.default = axiosRequest;\n","\"use strict\";\r\n\r\nvar _interopRequireWildcard = require(\"@babel/runtime/helpers/interopRequireWildcard\");\r\n\r\nObject.defineProperty(exports, \"__esModule\", {\r\n value: true\r\n});\r\nexports.MemoryStore = MemoryStore;\r\n\r\nvar _user = require(\"../models/user\");\r\n\r\nvar utils = _interopRequireWildcard(require(\"../utils\"));\r\n\r\n/*\r\nCopyright 2015, 2016 OpenMarket Ltd\r\nCopyright 2017 Vector Creations Ltd\r\nCopyright 2018 New Vector Ltd\r\nCopyright 2019 The Matrix.org Foundation C.I.C.\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\");\r\nyou may not use this file except in compliance with the License.\r\nYou may obtain a copy of the License at\r\n\r\n http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless required by applicable law or agreed to in writing, software\r\ndistributed under the License is distributed on an \"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\nSee the License for the specific language governing permissions and\r\nlimitations under the License.\r\n*/\r\n\r\n/**\r\n * This is an internal module. See {@link MemoryStore} for the public class.\r\n * @module store/memory\r\n */\r\nfunction isValidFilterId(filterId) {\r\n const isValidStr = typeof filterId === \"string\" && !!filterId && filterId !== \"undefined\" && // exclude these as we've serialized undefined in localStorage before\r\n filterId !== \"null\";\r\n return isValidStr || typeof filterId === \"number\";\r\n}\r\n/**\r\n * Construct a new in-memory data store for the Matrix Client.\r\n * @constructor\r\n * @param {Object=} opts Config options\r\n * @param {LocalStorage} opts.localStorage The local storage instance to persist\r\n * some forms of data such as tokens. Rooms will NOT be stored.\r\n */\r\n\r\n\r\nfunction MemoryStore(opts) {\r\n opts = opts || {};\r\n this.rooms = {// roomId: Room\r\n };\r\n this.groups = {// groupId: Group\r\n };\r\n this.users = {// userId: User\r\n };\r\n this.syncToken = null;\r\n this.filters = {// userId: {\r\n // filterId: Filter\r\n // }\r\n };\r\n this.accountData = {// type : content\r\n };\r\n this.localStorage = opts.localStorage;\r\n this._oobMembers = {// roomId: [member events]\r\n };\r\n this._clientOptions = {};\r\n}\r\n\r\nMemoryStore.prototype = {\r\n /**\r\n * Retrieve the token to stream from.\r\n * @return {string} The token or null.\r\n */\r\n getSyncToken: function () {\r\n return this.syncToken;\r\n },\r\n\r\n /** @return {Promise} whether or not the database was newly created in this session. */\r\n isNewlyCreated: function () {\r\n return Promise.resolve(true);\r\n },\r\n\r\n /**\r\n * Set the token to stream from.\r\n * @param {string} token The token to stream from.\r\n */\r\n setSyncToken: function (token) {\r\n this.syncToken = token;\r\n },\r\n\r\n /**\r\n * Store the given room.\r\n * @param {Group} group The group to be stored\r\n */\r\n storeGroup: function (group) {\r\n this.groups[group.groupId] = group;\r\n },\r\n\r\n /**\r\n * Retrieve a group by its group ID.\r\n * @param {string} groupId The group ID.\r\n * @return {Group} The group or null.\r\n */\r\n getGroup: function (groupId) {\r\n return this.groups[groupId] || null;\r\n },\r\n\r\n /**\r\n * Retrieve all known groups.\r\n * @return {Group[]} A list of groups, which may be empty.\r\n */\r\n getGroups: function () {\r\n return utils.values(this.groups);\r\n },\r\n\r\n /**\r\n * Store the given room.\r\n * @param {Room} room The room to be stored. All properties must be stored.\r\n */\r\n storeRoom: function (room) {\r\n this.rooms[room.roomId] = room; // add listeners for room member changes so we can keep the room member\r\n // map up-to-date.\r\n\r\n room.currentState.on(\"RoomState.members\", this._onRoomMember.bind(this)); // add existing members\r\n\r\n const self = this;\r\n room.currentState.getMembers().forEach(function (m) {\r\n self._onRoomMember(null, room.currentState, m);\r\n });\r\n },\r\n\r\n /**\r\n * Called when a room member in a room being tracked by this store has been\r\n * updated.\r\n * @param {MatrixEvent} event\r\n * @param {RoomState} state\r\n * @param {RoomMember} member\r\n */\r\n _onRoomMember: function (event, state, member) {\r\n if (member.membership === \"invite\") {\r\n // We do NOT add invited members because people love to typo user IDs\r\n // which would then show up in these lists (!)\r\n return;\r\n }\r\n\r\n const user = this.users[member.userId] || new _user.User(member.userId);\r\n\r\n if (member.name) {\r\n user.setDisplayName(member.name);\r\n\r\n if (member.events.member) {\r\n user.setRawDisplayName(member.events.member.getDirectionalContent().displayname);\r\n }\r\n }\r\n\r\n if (member.events.member && member.events.member.getContent().avatar_url) {\r\n user.setAvatarUrl(member.events.member.getContent().avatar_url);\r\n }\r\n\r\n this.users[user.userId] = user;\r\n },\r\n\r\n /**\r\n * Retrieve a room by its' room ID.\r\n * @param {string} roomId The room ID.\r\n * @return {Room} The room or null.\r\n */\r\n getRoom: function (roomId) {\r\n return this.rooms[roomId] || null;\r\n },\r\n\r\n /**\r\n * Retrieve all known rooms.\r\n * @return {Room[]} A list of rooms, which may be empty.\r\n */\r\n getRooms: function () {\r\n return utils.values(this.rooms);\r\n },\r\n\r\n /**\r\n * Permanently delete a room.\r\n * @param {string} roomId\r\n */\r\n removeRoom: function (roomId) {\r\n if (this.rooms[roomId]) {\r\n this.rooms[roomId].removeListener(\"RoomState.members\", this._onRoomMember);\r\n }\r\n\r\n delete this.rooms[roomId];\r\n },\r\n\r\n /**\r\n * Retrieve a summary of all the rooms.\r\n * @return {RoomSummary[]} A summary of each room.\r\n */\r\n getRoomSummaries: function () {\r\n return utils.map(utils.values(this.rooms), function (room) {\r\n return room.summary;\r\n });\r\n },\r\n\r\n /**\r\n * Store a User.\r\n * @param {User} user The user to store.\r\n */\r\n storeUser: function (user) {\r\n this.users[user.userId] = user;\r\n },\r\n\r\n /**\r\n * Retrieve a User by its' user ID.\r\n * @param {string} userId The user ID.\r\n * @return {User} The user or null.\r\n */\r\n getUser: function (userId) {\r\n return this.users[userId] || null;\r\n },\r\n\r\n /**\r\n * Retrieve all known users.\r\n * @return {User[]} A list of users, which may be empty.\r\n */\r\n getUsers: function () {\r\n return utils.values(this.users);\r\n },\r\n\r\n /**\r\n * Retrieve scrollback for this room.\r\n * @param {Room} room The matrix room\r\n * @param {integer} limit The max number of old events to retrieve.\r\n * @return {Array