/* Metro module 7863; source: modules/application_commands/ApplicationCommandFrecencyStore.tsx; dependencies: [6, 7, 15, 17, 18, 1348, 5066, 4238, 670, 4393, 22, 566, 694, 2] */ import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */ import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */ import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */ import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */ import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */ import Flux from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */ import UserSettingsProtoStore from '../user_settings/UserSettingsProtoStore.tsx'; /* Metro dependency 1348 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as UserSettingsConstantsModule from '../user_settings/UserSettingsConstants.tsx'; /* Metro dependency 670 */ import * as ApplicationConstantsModule from '../applications/ApplicationConstants.tsx'; /* Metro dependency 4238 */ import * as ApplicationCommandConstantsModule from './ApplicationCommandConstants.tsx'; /* Metro dependency 5066 */ 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}); let value = ApplicationCommandConstantsModule; const env0_8 = value.DISCOVERY_COMMAND_FRECENCY_GATEWAY_LIMIT; const env0_9 = value.SUB_COMMAND_KEY_SEPARATOR; const FREQUENCY_ITEM_LIMIT = (ApplicationConstantsModule).FREQUENCY_ITEM_LIMIT; 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 = (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}); (FileImportTrackerModule).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 _fun62916() { // fn#62916, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:1071, 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 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 _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 object = {}; copyDataProperties(object, 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; }); object['recentUses'] = value; return object; } } 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 ApplicationCommandFrecencyStore2 = ApplicationCommandFrecencyStore; Inherits(ApplicationCommandFrecencyStore2, a0); return CreateClass(ApplicationCommandFrecencyStore2, [{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 ApplicationCommandFrecencyStore() { // fn#62926, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:1965, offset: 0x00ea76ec, size: 113 bytes, params: 1, frame: 20 const value = environment.__proto__; env1_2(this, ApplicationCommandFrecencyStore); const value3 = env1_5(ApplicationCommandFrecencyStore); return env1_4(this, _isNativeReflectConstruct_62912() ? global.Reflect.construct(value3, arguments, env1_5(this).constructor) : value3.apply(this, arguments)); } 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_62928() { // fn#62928, offset: 0x00ef8482, size: 9 bytes, params: 1, frame: 1 return env1_11; } function value_62929() { // fn#62929, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:2494, offset: 0x01b6c08d, size: 26 bytes, params: 1, frame: 2 return env1_11.pendingUsages.length > 0; } function value_62930() { // fn#62930, offset: 0x00e2f9de, size: 9 bytes, params: 1, frame: 1 return env1_12; } 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 value_62932() { // fn#62932, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:2770, offset: 0x01b6c0cc, size: 15 bytes, params: 1, frame: 1 return env1_12.frequently; } } 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 object = {key: key_62918}; const Date = global.Date; object.timestamp = Date.now(); Reflect.apply(push, pendingUsages, [object]); 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 _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; } } } function _fun62921(a0) { // fn#62921, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:1917, offset: 0x011bbce4, size: 11 bytes, params: 2, frame: 2 return a0 > 0; } function _fun62938(a0) { // fn#62938, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8041:3787, offset: 0x01b6c991, size: 25 bytes, params: 2, frame: 11 return a0.split(':')[0]; } global.__d(_fun62911, 7863, [6, 7, 15, 17, 18, 1348, 5066, 4238, 670, 4393, 22, 566, 694, 2]) /* metro module 7863, dependencies: [6, 7, 15, 17, 18, 1348, 5066, 4238, 670, 4393, 22, 566, 694, 2] */;