/* Metro module 13011; source: modules/user_settings/FrecencySettingsMigrations.tsx; dependencies: [670, 661, 566, 1349, 22, 1350, 587, 21, 2] */ import Module00022 from '../../by-id/module-00022.js'; /* Metro dependency 22 */ import Flux from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as StorageModule from '../../external/discord_common/js/packages/storage/Storage.tsx'; /* Metro dependency 587 */ import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */ import * as UserSettingsConstantsModule from './UserSettingsConstants.tsx'; /* Metro dependency 670 */ import * as Frecency_user_settingsModule from '../../external/discord_common/js/packages/protos/discord_protos/discord_users/v1/frecency_user_settings.tsx'; /* Metro dependency 1349 */ function _fun99269(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#99269, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:6, offset: 0x021c232b, size: 525 bytes, params: 8, frame: 19 const env0_0 = require; const _arrayLikeToArray_99272 = function(a0, a1) { var r0; var r1; var r2; var value3; var length; var value5; var value = undefined; var value2 = value == null; reducibleJoin2: while (true) { if (value2) { r0 = value2; break reducibleJoin2; } value3 = value > a0.length; r0 = value3; break reducibleJoin2; } reducibleJoin4: while (true) { if (r0) { length = a0.length; r1 = length; break reducibleJoin4; } r1 = value; break reducibleJoin4; } value = (0, global.Array)(r1); var value4 = 0; if (value4 < r1) { r2 = value4; reducibleLoop5: while (true) { value[r2] = a0[r2]; value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1; if (value5 < r1) { r2 = value5; continue reducibleLoop5; } break reducibleLoop5; } } return value; }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const items2 = [{version: 2, run: run_99277, cleanup: function() { }}]; items2[1] = {version: 3, run: run_99279, cleanup: function() { var Storage = require(dependencyMap[6]).Storage; Storage.remove('StickersPersistedStore'); }}; items2[2] = {version: 4, run: run_99283, cleanup: function() { var Storage = require(dependencyMap[6]).Storage; Storage.remove('EmojiStore'); Storage.remove('EmojiUsageHistory'); Storage.remove('EmojiDiversitySurrogate'); }}; items2[3] = {version: 6, run: run_99286, cleanup: function() { }}; items2[4] = {version: 7, run: run_99289, cleanup: function() { var Storage = require(dependencyMap[6]).Storage; Storage.remove('ApplicationCommandFrecency'); }}; items2[5] = {version: 8, run: run_99291, cleanup: function() { var Storage = require(dependencyMap[6]).Storage; Storage.remove('SoundboardFavoriteStore'); }}; items2[6] = {version: 9, run: run_99295, cleanup: function() { var Storage = require(dependencyMap[6]).Storage; Storage.remove('selectedChannelGuildFrecency'); }}; items2[7] = {version: 10, run: run_99297, cleanup: function() { }}; items2[8] = {version: 11, run: run_99299, cleanup: function() { }}; (FileImportTrackerModule).fileFinishedImporting('modules/user_settings/FrecencySettingsMigrations.tsx'); exports.default = items2; function _createForOfIteratorHelperLoose_99270(a0, a1) { // fn#99270, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:177, offset: 0x021c2538, size: 372 bytes, params: 3, frame: 20 var r6; var r9; var r5; var value3; var regexp; const env0_0 = a0; const Symbol = global.Symbol; let value = typeof Symbol !== 'undefined'; let r1 = value && a0[global.Symbol.iterator]; r1 = !r1 ? a0['@@iterator'] : r1; if (r1) { value = r1.call(a0); return value.next.bind(value); } const Array = global.Array; if (Array.isArray(a0)) { if (r1) { } return _fun99271; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_99272(a0, value); r5 = value; } else { value3 = ({}).toString.call(a0).slice(8, -1); r6 = value3 === 'Object' && a0.constructor; r9 = r6 ? a0.constructor.name : value3; if (r9 === 'Map') { r6 = global.Array.from(a0); } else if (r9 === 'Set') { r6 = global.Array.from(a0); } else if (r9 === 'Arguments') { value = _arrayLikeToArray_99272(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_99272(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun99271; } const TypeError = global.TypeError; throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); function _fun99271() { // fn#99271, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:748, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5 return env0_1 >= env0_0.length ? {done: true} : {done: false, value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]}; } } function readFavoriteGIFs(a0) { // fn#99273, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:1124, offset: 0x021c26ac, size: 173 bytes, params: 2, frame: 14 const object = {IMAGE: 'IMAGE', VIDEO: 'VIDEO'}; const PersistedStore = (Flux).PersistedStore; const state = PersistedStore.migrateAndReadStoreState('GIFFavoritesStore', [function(a0) { var value = a0; return value == null ? {favorites: [], timesFavorited: 0} : global.Array.isArray(value) ? {favorites: value, timesFavorited: 0} : value; }, function(a0) { var value = a0; var Array = global.Array; return Array.isArray(value.favorites) ? value : {favorites: [], timesFavorited: 0}; }]).state; return state == null || state.favorites.length === 0 ? [] : state.favorites.map(_fun99276); function _fun99276(a0, a1) { // fn#99276, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:1513, offset: 0x021c27d9, size: 269 bytes, params: 3, frame: 17 var r3; const GIFType = (Frecency_user_settingsModule).GIFType; const value = environment.__proto__; const FavoriteGIF = (Frecency_user_settingsModule).FavoriteGIF; const value2 = FavoriteGIF.create(); const format = a0.format; const IMAGE = env0_1.IMAGE; if (IMAGE === format) { r3 = GIFType.IMAGE; } else if (env0_1.VIDEO === format) { r3 = GIFType.VIDEO; } else { a0.format; r3 = GIFType.NONE; } value2.format = r3; value2.src = a0.src; value2.width = a0.width; value2.height = a0.height; value2.order = state.favorites.length - a1 + env0_0; return {url: a0.url, favorite: value2}; } } function run_99277(a0) { // fn#99277, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:1854, offset: 0x021c28e6, size: 201 bytes, params: 2, frame: 16 var r3; var FavoriteGIFs; var create; var value4; var url; var favorite; var gifs; var value5; const value2 = readFavoriteGIFs(1); if (value2.length === 0) { return false; } let favoriteGifs = a0.favoriteGifs; reducibleJoin3: while (true) { if (favoriteGifs != null) { break reducibleJoin3; } FavoriteGIFs = (require(1349) /* metro dependency 1349: frecency_user_settings */).FavoriteGIFs; create = FavoriteGIFs.create; a0.favoriteGifs = Reflect.apply(create, FavoriteGIFs, []); break reducibleJoin3; } a0.favoriteGifs.gifs = {}; const value = _createForOfIteratorHelperLoose_99270(value2); const value3 = value(); let done = value3.done; if (!done) { r3 = value3; reducibleLoop4: while (true) { value4 = r3.value; url = value4.url; favorite = value4.favorite; favoriteGifs = a0.favoriteGifs; gifs = favoriteGifs.gifs; gifs[url] = favorite; value5 = value(); done = value5.done; if (done) { break reducibleLoop4; } r3 = value5; continue reducibleLoop4; } } a0.favoriteGifs.hideTooltip = value2.length > 2; return true; } function run_99279(a0) { // fn#99279, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:2201, offset: 0x021c29af, size: 353 bytes, params: 2, frame: 19 var r0; var FavoriteStickers; var favoriteStickers; var defaultImport; var StickerFrecency; var stickerFrecency; var value; const PersistedStore = (Flux).PersistedStore; const state = PersistedStore.migrateAndReadStoreState('StickersPersistedStore', [function(a0) { var r0; var property; var value = a0; if (value == null) { r0 = {usageHistory: {}, favorites: []}; } else { property = global.Object; property = property.keys(value).length; r0 = property !== 0 ? value : {usageHistory: {}, favorites: []}; } return r0; }, function(a0) { var r0; var property; var value = a0; if (value == null) { r0 = {usageHistory: {}, favorites: []}; } else { property = global.Object; property = property.keys(value).length; if (property === 0) { r0 = {usageHistory: {}, favorites: []}; } else if (value.favorites != null) { r0 = value; } else { value.favorites = []; r0 = value; } } return r0; }]).state; if (state == null) { return false; } if (state.favorites.length > 0) { FavoriteStickers = (require(1349) /* metro dependency 1349: frecency_user_settings */).FavoriteStickers; a0.favoriteStickers = FavoriteStickers.create(); favoriteStickers = a0.favoriteStickers; defaultImport = importDefault(22) /* metro dependency 22 */; favoriteStickers.stickerIds = defaultImport.uniq(state.favorites).slice(0, MAX_FAVORITES); r0 = true; } else { r0 = false; } const defaultImport2 = importDefault(22) /* metro dependency 22 */; if (defaultImport2.size(state.usageHistory) > 0) { StickerFrecency = (require(1349) /* metro dependency 1349: frecency_user_settings */).StickerFrecency; a0.stickerFrecency = StickerFrecency.create(); stickerFrecency = a0.stickerFrecency; value = require(1350) /* metro dependency 1350: UserSettingsUtils */; stickerFrecency.stickers = value.serializeUsageHistory(state.usageHistory, 100); value = true; r0 = value; } return r0; } function run_99283(a0) { // fn#99283, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:2910, offset: 0x021c2bd8, size: 359 bytes, params: 2, frame: 19 var r0; var FavoriteEmojis; var favoriteEmojis; var defaultImport; var EmojiFrecency; var emojiFrecency; var value; const PersistedStore = (Flux).PersistedStore; const state = PersistedStore.migrateAndReadStoreState('EmojiStore', [_fun99284]).state; if (state == null) { return false; } if (state.favorites != null && state.favorites.length > 0) { FavoriteEmojis = (require(1349) /* metro dependency 1349: frecency_user_settings */).FavoriteEmojis; a0.favoriteEmojis = FavoriteEmojis.create(); favoriteEmojis = a0.favoriteEmojis; defaultImport = importDefault(22) /* metro dependency 22 */; favoriteEmojis.emojis = defaultImport.uniq(state.favorites).slice(0, MAX_FAVORITES); r0 = true; } else { r0 = false; } const defaultImport2 = importDefault(22) /* metro dependency 22 */; if (defaultImport2.size(state.usageHistory) > 0) { EmojiFrecency = (require(1349) /* metro dependency 1349: frecency_user_settings */).EmojiFrecency; a0.emojiFrecency = EmojiFrecency.create(); emojiFrecency = a0.emojiFrecency; value = require(1350) /* metro dependency 1350: UserSettingsUtils */; emojiFrecency.emojis = value.serializeUsageHistory(state.usageHistory, 100); value = true; r0 = value; } return r0; function _fun99284() { // fn#99284, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:2986, offset: 0x021c2d3f, size: 61 bytes, params: 1, frame: 12 const value = environment.__proto__; const Storage = (StorageModule).Storage; return {usageHistory: Storage.get('EmojiUsageHistory') || ({})}; } } function run_99286(a0) { // fn#99286, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:3579, offset: 0x021c2dee, size: 664 bytes, params: 2, frame: 27 var r2; var r8; var r11; var r14; var r0; var r9; const FavoriteGIFs = (require(1349) /* metro dependency 1349: frecency_user_settings */).FavoriteGIFs; var value9; var url; var favorite; var value10; var FavoriteGIF; var length2; var value11; var value12; var value13; var property; var order; var value14; var propertyName; var propertyName2; var gifs2; var value15; let favoriteGifs = a0.favoriteGifs; if (favoriteGifs == null) { a0.favoriteGifs = FavoriteGIFs.create(); } let gifs = a0.favoriteGifs.gifs; if (gifs == null) { a0.favoriteGifs.gifs = {}; } const value2 = readFavoriteGIFs(1); let length = value2.length; const value3 = 0; if (value3 === length) { return false; } (Module00022)(a0.favoriteGifs.gifs).values().sortBy('order').forEach(_fun99287); let toBinary = FavoriteGIFs.toBinary; length = Reflect.apply(toBinary, FavoriteGIFs, [a0.favoriteGifs]).length; const value7 = _createForOfIteratorHelperLoose_99270(value2); const value8 = value7(); let done = value8.done; if (!done) { r2 = value3; r8 = value8; r11 = length; while (true) { value9 = r8.value; url = value9.url; favorite = value9.favorite; length = value2.length; favorite.order = length - r2; value10 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1; favoriteGifs = a0.favoriteGifs; gifs = favoriteGifs.gifs; if (!(url in gifs)) { FavoriteGIF = (require(1349) /* metro dependency 1349: frecency_user_settings */).FavoriteGIF; toBinary = FavoriteGIF.toBinary; length = Reflect.apply(toBinary, FavoriteGIF, [favorite]).length; length2 = url.length; value11 = length + length2 + 7; value12 = r11 + value11; if (value12 > MAX_FAVORITE_GIFS_SIZE) { r14 = r11; break; } value13 = r11 + value11; a0.favoriteGifs.gifs[url] = favorite; r14 = value13; break; } favoriteGifs = a0.favoriteGifs; gifs = favoriteGifs.gifs; property = gifs[url]; order = favorite.order; property.order = order; r14 = r11; value14 = value7(); done = value14.done; if (done) { break; } r2 = value10; r8 = value14; r11 = r14; continue; } } length = FavoriteGIFs.toBinary(a0.favoriteGifs).length; if (length > MAX_FAVORITE_GIFS_SIZE) { while (true) { favoriteGifs = a0.favoriteGifs; gifs = favoriteGifs.gifs; r0 = value3; for (propertyName in gifs) { favoriteGifs = a0.favoriteGifs; gifs2 = favoriteGifs.gifs; delete gifs2[propertyName]; value15 = typeof r0 === 'bigint' ? r0 + 1n : +r0 + 1; if (value15 >= 10) { break; } r0 = value15; r9 = propertyName2; continue; } toBinary = FavoriteGIFs.toBinary; favoriteGifs = a0.favoriteGifs; length = Reflect.apply(toBinary, FavoriteGIFs, [favoriteGifs]).length; if (length > MAX_FAVORITE_GIFS_SIZE) { continue; } break; } } return true; function _fun99287(a0, a1) { // fn#99287, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:3823, offset: 0x021c3086, size: 37 bytes, params: 3, frame: 2 const value = env0_0.length + 1 + a1; a0.order = value; return value; } } function run_99289(a0) { // fn#99289, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:4445, offset: 0x021c30ab, size: 212 bytes, params: 2, frame: 17 var r0; var ApplicationCommandFrecency; var applicationCommandFrecency; var value; const PersistedStore = (Flux).PersistedStore; const state = PersistedStore.migrateAndReadStoreState('ApplicationCommandFrecency', []).state; if (state == null) { return false; } const defaultImport = Module00022; if (defaultImport.size(state.usageHistory) > 0) { ApplicationCommandFrecency = (require(1349) /* metro dependency 1349: frecency_user_settings */).ApplicationCommandFrecency; a0.applicationCommandFrecency = ApplicationCommandFrecency.create(); applicationCommandFrecency = a0.applicationCommandFrecency; value = require(1350) /* metro dependency 1350: UserSettingsUtils */; applicationCommandFrecency.applicationCommands = value.serializeUsageHistory(state.usageHistory, 500); value = true; r0 = value; } else { r0 = false; } return r0; } function run_99291(a0) { // fn#99291, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:4876, offset: 0x021c31af, size: 225 bytes, params: 2, frame: 18 var r0; var FavoriteSoundboardSounds; const env0_0 = a0; var value; const PersistedStore = (Flux).PersistedStore; const state = PersistedStore.migrateAndReadStoreState('SoundboardFavoriteStore', []).state; if (state == null) { return false; } const defaultImport = Module00022; if (defaultImport.size(state.favoriteSounds) > 0) { FavoriteSoundboardSounds = (require(1349) /* metro dependency 1349: frecency_user_settings */).FavoriteSoundboardSounds; a0.favoriteSoundboardSounds = FavoriteSoundboardSounds.create(); value = importDefault(21) /* metro dependency 21: SnowflakeUtils */; value = value.keys(state.favoriteSounds); value.forEach(_fun99292); value = true; r0 = value; } else { r0 = false; } return r0; function _fun99292(a0) { // fn#99292, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:5157, offset: 0x021c3290, size: 71 bytes, params: 2, frame: 11 const Set = global.Set; new Set(state.favoriteSounds[a0]).forEach(_fun99293); function _fun99293(a0) { // fn#99293, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:5199, offset: 0x021c32d7, size: 42 bytes, params: 2, frame: 11 const favoriteSoundboardSounds = env1_0.favoriteSoundboardSounds; if (favoriteSoundboardSounds != null) { favoriteSoundboardSounds.soundIds.push(a0); } } } } function run_99295(a0) { // fn#99295, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:5355, offset: 0x021c3333, size: 193 bytes, params: 2, frame: 21 var r6; var propertyName; var propertyName2; var test; const Storage = (StorageModule).Storage; const value2 = Storage.get('selectedChannelGuildFrecency'); if (value2 == null) { return false; } for (propertyName in value2) { test = ID_REGEX.test; if (Reflect.apply(test, ID_REGEX, [propertyName])) { r6 = propertyName2; continue; } delete value2[propertyName]; r6 = propertyName2; } const GuildAndChannelFrecency = (Frecency_user_settingsModule).GuildAndChannelFrecency; a0.guildAndChannelFrecency = GuildAndChannelFrecency.create(); a0.guildAndChannelFrecency.guildAndChannels = (require(1350) /* metro dependency 1350: UserSettingsUtils */).serializeUsageHistory(value2, 100); return true; } function run_99297(a0) { // fn#99297, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:5661, offset: 0x021c3426, size: 218 bytes, params: 2, frame: 19 var r0; const EmojiFrecency = (Frecency_user_settingsModule).EmojiFrecency; var value4; if (a0.emojiFrecency == null) { return false; } if ((importDefault(22) /* metro dependency 22 */).size(a0.emojiFrecency.emojis ?? ({})) > 0) { value4 = EmojiFrecency.create(); EmojiFrecency.mergePartial(value4, a0.emojiFrecency); if (a0.emojiReactionFrecency != null) { EmojiFrecency.mergePartial(value4, a0.emojiReactionFrecency); } a0.emojiReactionFrecency = value4; r0 = true; } else { r0 = false; } return r0; } function run_99299(a0) { // fn#99299, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13201:6033, offset: 0x021c3500, size: 303 bytes, params: 2, frame: 30 var r1; var r11; var r16; var r17; var r0; var propertyName; var propertyName2; var gifs2; var property; var src; var startsWith; var format; const GIFType = (Frecency_user_settingsModule).GIFType; var IMAGE; var regexp; var test; let favoriteGifs = a0.favoriteGifs; if (favoriteGifs == null) { return false; } let gifs = a0.favoriteGifs.gifs; if (gifs == null) { return false; } gifs = a0.favoriteGifs.gifs; let value = false; const properties = Object.keys(gifs); const properties2 = 0; const properties3 = properties.length; if (properties === undefined) { r0 = value; } else { r1 = value; r11 = properties2; while (true) { propertyName = properties[r11]; propertyName2 = r11 + 1; if (propertyName === undefined) { r0 = r1; break; } favoriteGifs = a0.favoriteGifs; gifs2 = favoriteGifs.gifs; property = gifs2[propertyName]; if (property == null) { r11 = propertyName2; continue; } src = property.src; startsWith = src.startsWith; if (!Reflect.apply(startsWith, src, ['//'])) { r16 = r1; continue; } src = property.src; property.src = 'https:' + src; r16 = true; format = property.format; IMAGE = GIFType.IMAGE; value = format !== IMAGE; if (!value) { r17 = value; continue; } regexp = RegExp('\\.(webp|avif|gif)(\\?|$)', 'i'); test = regexp.test; src = property.src; value = Reflect.apply(test, regexp, [src]); r17 = value; if (!r17) { continue; } IMAGE = GIFType.IMAGE; property.format = IMAGE; value = true; r16 = value; r1 = r16; r11 = propertyName2; } } return r0; } } global.__d(_fun99269, 13011, [670, 661, 566, 1349, 22, 1350, 587, 21, 2]) /* metro module 13011, dependencies: [670, 661, 566, 1349, 22, 1350, 587, 21, 2] */;