/* Metro module 7863; source: modules/application_commands/ApplicationCommandFrecencyStore.tsx; dependencies: [6, 7, 15, 17, 18, 1348, 5066, 4238, 670, 4393, 22, 566, 694, 2] */ function _fun62911(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#62911, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:6, offset: 0x01b6c199, size: 526 bytes, params: 8, frame: 20 const _arrayLikeToArray_62917 = 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 getKey_62918 = function(a0, a1) { var r0; if (global.Number(a1.id) < 0) { r0 = a1.id; } else { r0 = a0?.guild; r0 = r0 == null ? a1.id : a1.guildId != null ? '' + a1.id + ':' + a0.guild.id : a1.id; } return r0; }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_2 = importDefault(6) /* metro dependency 6 */; const env0_3 = importDefault(7) /* metro dependency 7 */; const env0_4 = importDefault(15) /* metro dependency 15 */; const env0_5 = importDefault(17) /* metro dependency 17 */; const env0_6 = importDefault(18) /* metro dependency 18 */; const userSettingsProtoStore = importDefault(1348) /* metro dependency 1348: UserSettingsProtoStore */; let value = require(5066) /* metro dependency 5066: ApplicationCommandConstants */; const env0_8 = value.DISCOVERY_COMMAND_FRECENCY_GATEWAY_LIMIT; const env0_9 = value.SUB_COMMAND_KEY_SEPARATOR; const FREQUENCY_ITEM_LIMIT = (require(4238) /* metro dependency 4238: ApplicationConstants */).FREQUENCY_ITEM_LIMIT; const env0_10 = (require(670) /* metro dependency 670: UserSettingsConstants */).UserSettingsTypes; object = {pendingUsages: []}; value = importDefault(4393) /* metro dependency 4393: Frecency */; value = new value({computeBonus: function() { return 1; }, lookupKey: function(a0) { return a0; }, afterCompute: function() { }, numFrequentlyItems: FREQUENCY_ITEM_LIMIT}); const PersistedStore = (importDefault(566) /* metro dependency 566: flux */).PersistedStore; value = _fun62925(PersistedStore); value.displayName = 'ApplicationCommandFrecencyStore'; value.persistKey = 'ApplicationCommandFrecencyV2'; value = new value(importDefault(694) /* metro dependency 694: Dispatcher */, {APPLICATION_COMMAND_USED: APPLICATION_COMMAND_USED_62933, USER_SETTINGS_PROTO_UPDATE: USER_SETTINGS_PROTO_UPDATE_62934}); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/application_commands/ApplicationCommandFrecencyStore.tsx'); exports.default = value; exports.getTopRealCommands = getTopRealCommands; exports.getFilteredTopCommands = function(a0, a1) { var env0_0 = a1; return a0.filter(_fun62937).map(_fun62938); }; } function _isNativeReflectConstruct_62912() { // fn#62912, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:307, offset: 0x01b6c3a7, size: 94 bytes, params: 1, frame: 18 var Boolean; var prototype; var valueOf; var call; var Reflect; var construct; var closure; var value; var error; try { Boolean = global.Boolean; prototype = Boolean.prototype; valueOf = prototype.valueOf; call = valueOf.call; Reflect = global.Reflect; construct = Reflect.construct; Boolean = global.Boolean; closure = function() { }; value = Reflect.apply(construct, Reflect, [Boolean, [], closure]); value = Reflect.apply(call, valueOf, [value]); var result = !value; } catch (error) { } return (_isNativeReflectConstruct_62912_isNativeReflectConstruct = function() { return !!result; })(); } function _createForOfIteratorHelperLoose_62915(a0, a1) { // fn#62915, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:500, offset: 0x01b6c405, size: 370 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 _fun62916; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_62917(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_62917(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_62917(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun62916; } 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 handleUserSettingsProtoStoreChange_62919() { // fn#62919, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:1653, offset: 0x01b6c5ed, size: 111 bytes, params: 1, frame: 17 const applicationCommandFrecency = UserSettingsProtoStore.frecencyWithoutFetchingLatest.applicationCommandFrecency; const value2 = undefined; const r7 = (applicationCommandFrecency == null ? value2 : applicationCommandFrecency.applicationCommands) ?? ({}); const binding = env0_12; binding.overwriteHistory((importDefault(22) /* metro dependency 22 */).mapValues(r7, function(a0) { var r3; var object = {}; copyDataProperties(object, a0, r3); var value = a0.recentUses.map(global.Number); value = value.filter(_fun62921); object['recentUses'] = value; return object; }), env0_11.pendingUsages); return value2; } function _fun62925(a0) { // fn#62925, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:1953, offset: 0x01b6c69f, size: 185 bytes, params: 2, frame: 16 const closure = ApplicationCommandFrecencyStore; env0_6(closure, a0); return env0_3(closure, [{key: 'initialize', value: value_62927}, {key: 'getState', value: value_62928}, {key: 'hasPendingUsage', value: value_62929}, {key: 'getCommandFrecencyWithoutLoadingLatest', value: value_62930}, {key: 'getScoreWithoutLoadingLatest', value: value_62931}, {key: 'getTopCommandsWithoutLoadingLatest', value: value_62932}]); } function APPLICATION_COMMAND_USED_62933({command, context}) { // fn#62933, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:2970, offset: 0x01b6c7c2, size: 107 bytes, params: 2, frame: 17 const key_62918 = getKey_62918(context, command); const pendingUsages = env0_11.pendingUsages; const push = pendingUsages.push; const object2 = {key: key_62918}; const Date = global.Date; object2.timestamp = Date.now(); Reflect.apply(push, pendingUsages, [object2]); env0_12.track(key_62918); env0_12.compute(); } function USER_SETTINGS_PROTO_UPDATE_62934({settings, wasSaved}) { // fn#62934, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:3151, offset: 0x01b6c82d, size: 62 bytes, params: 2, frame: 4 const type = settings.type; const FRECENCY_AND_FAVORITES_SETTINGS = UserSettingsTypes.FRECENCY_AND_FAVORITES_SETTINGS; if (type === FRECENCY_AND_FAVORITES_SETTINGS) { if (wasSaved) { env0_11.pendingUsages = []; return undefined; } } return false; } function getTopRealCommands(a0) { // fn#62935, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:3433, offset: 0x01b6c86b, size: 153 bytes, params: 2, frame: 20 var r9; var r3; var value5; var split; var property; var Number; var size; var value6; const Set = global.Set; const set = new Set(); const value3 = _createForOfIteratorHelperLoose_62915(a0); const value4 = value3(); let done = value4.done; if (!done) { r3 = value4; while (true) { value5 = r3.value; split = value5.split; property = Reflect.apply(split, value5, [SUB_COMMAND_KEY_SEPARATOR])[0]; Number = global.Number; if (Number(property) > 0) { set.add(property); } size = set.size; if (size >= DISCOVERY_COMMAND_FRECENCY_GATEWAY_LIMIT) { r9 = value5; break; } value6 = value3(); done = value6.done; if (done) { r9 = value5; break; } r3 = value6; continue; } } const items2 = []; arraySpread(items2, set, 0, r9); return items2; } function getFilteredTopCommands(a0, a1) { // fn#62936, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:3644, offset: 0x01b6c904, size: 44 bytes, params: 3, frame: 12 const env0_0 = a1; return a0.filter(_fun62937).map(function(a0) { return a0.split(':')[0]; }); } function _fun62920(a0) { // fn#62920, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:1863, offset: 0x01b6c65c, size: 67 bytes, params: 2, frame: 13 const object2 = {}; copyDataProperties(object2, a0, undefined); const recentUses = a0.recentUses; const map = recentUses.map; const Number = global.Number; let value = Reflect.apply(map, recentUses, [Number]); value = value.filter(function(a0) { return a0 > 0; }); object2['recentUses'] = value; return object2; } function value_62927(a0) { // fn#62927, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:2338, offset: 0x01b6c758, size: 54 bytes, params: 2, frame: 14 var value; if (a0 != null) { value = environment.__proto__; env1_11 = a0; } this.syncWith([UserSettingsProtoStore], handleUserSettingsProtoStoreChange_62919); } function value_62931(a0, a1) { // fn#62931, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:2655, offset: 0x01b6c78e, size: 52 bytes, params: 3, frame: 15 const value = environment.__proto__; return env1_12.getScore(getKey_62918(a0, a1)) ?? 0; } function _fun62937(a0) { // fn#62937, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:3698, offset: 0x01b6c930, size: 97 bytes, params: 2, frame: 15 var r1; var r0; var value4; var id; let value = a0.includes(':'); if (value) { value4 = require?.guild != null; if (value4) { id = require.guild.id; value = a0.split(':'); value = id === value[1]; r1 = value; } else { r1 = value4; } r0 = r1; } else { r0 = !value; } return r0; }