/* Metro module 4863; source: modules/app_analytics/AppAnalyticsUtils.tsx; dependencies: [1383, 1226, 1379, 1935, 4111, 1945, 1938, 1867, 4259, 3784, 4396, 4294, 4605, 3793, 1934, 3969, 4864, 1878, 4297, 661, 1386, 3789, 483, 4866, 683, 672, 4867, 4868, 22, 2] */ import Module00022 from '../../by-id/module-00022.js'; /* Metro dependency 22 */ import AnalyticsUtils from '../../utils/AnalyticsUtils.tsx'; /* Metro dependency 683 */ import AuthenticationStore from '../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */ import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */ import GuildStore from '../../stores/GuildStore.tsx'; /* Metro dependency 1867 */ import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */ import SelectedChannelStore from '../../stores/SelectedChannelStore.tsx'; /* Metro dependency 1934 */ import GuildChannelStore from '../../stores/GuildChannelStore.tsx'; /* Metro dependency 1935 */ import GuildRoleStore from '../../stores/GuildRoleStore.tsx'; /* Metro dependency 1938 */ import GuildMemberStore from '../../stores/GuildMemberStore.tsx'; /* Metro dependency 1945 */ import PermissionStore from '../../stores/PermissionStore.tsx'; /* Metro dependency 3784 */ import RelationshipStore from '../../stores/RelationshipStore.tsx'; /* Metro dependency 3793 */ import SelectedGuildStore from '../../stores/SelectedGuildStore.tsx'; /* Metro dependency 3969 */ import GuildMemberCountStore from '../../stores/GuildMemberCountStore.tsx'; /* Metro dependency 4111 */ import MediaEngineStore from '../../stores/MediaEngineStore.tsx'; /* Metro dependency 4259 */ import RTCConnectionStore from '../../stores/RTCConnectionStore.tsx'; /* Metro dependency 4294 */ import VoiceStateStore from '../../stores/VoiceStateStore.tsx'; /* Metro dependency 4297 */ import PresenceStore from '../../stores/PresenceStore.tsx'; /* Metro dependency 4396 */ import ReadStateStore from '../../stores/ReadStateStore.tsx'; /* Metro dependency 4605 */ import UserGuildSettingsStore from '../../stores/UserGuildSettingsStore.tsx'; /* Metro dependency 4864 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ChannelRecordModule from '../../records/ChannelRecord.tsx'; /* Metro dependency 1383 */ import * as ChannelConstantsModule from '../channel/ChannelConstants.tsx'; /* Metro dependency 1386 */ import * as GuildChannelStoreModule from '../../stores/GuildChannelStore.tsx'; /* Metro dependency 1935 */ import * as AppAnalyticsUtilsAdditionalNativeModule from './AppAnalyticsUtilsAdditional.native.tsx'; /* Metro dependency 4866 */ function _fun42492(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#42492, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:6, offset: 0x0113b00b, size: 690 bytes, params: 8, frame: 25 const env0_0 = require; const _arrayLikeToArray_42495 = 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 countKeys = function(a0) { var r1; var r5; var r0; var propertyName; var propertyName2; var value = 0; var properties = Object.keys(a0); var properties2 = 0; var properties3 = properties.length; if (properties === undefined) { r0 = value; } else { r1 = value; for (r5 = properties2; true; r5 = propertyName2) { propertyName = properties[r5]; propertyName2 = r5 + 1; if (propertyName === undefined) { r0 = r1; break; } value = r1 + 1; r1 = value; } } return r0; }; const collectGuildAnalyticsMetadata2 = collectGuildAnalyticsMetadata; const closure2 = function(a0, a1) { return {channel_static_route: a1, channel_hidden: false}; }; const collectChannelAnalyticsMetadata2 = collectChannelAnalyticsMetadata; const trackWithMetadata2 = trackWithMetadata; const closure5 = function(a0) { var r3; var r4; var r8; var r2; var value5; var value6; var value7; var value2 = _createForOfIteratorHelperLoose_42493(a0); var value3 = value2(); var value4 = 0; if (value3.done) { r2 = value4; } else { r3 = value4; r4 = value3; while (true) { value5 = r4.value; if (RelationshipStore.isFriend(value5)) { value6 = typeof r3 === 'bigint' ? r3 + 1n : +r3 + 1; r8 = value6; } else { r8 = r3; } value7 = value2(); if (value7.done) { r2 = r8; break; } r3 = r8; r4 = value7; continue; } } return {friendCount: r2, nonFriendCount: a0.length - r2}; }; const getVoiceStateMetadata2 = getVoiceStateMetadata; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); let value = GuildChannelStoreModule; const env0_7 = value.GUILD_SELECTABLE_CHANNELS_KEY; const env0_8 = value.GUILD_VOCAL_CHANNELS_KEY; value = require(661) /* metro dependency 661: Constants */; const env0_25 = value.GuildFeatures; const env0_26 = value.AnalyticsLocations; const env0_27 = value.Permissions; const env0_28 = value.ActivityTypes; object = {trackWithMetadata: trackWithMetadata2, getVoiceStateMetadata: getVoiceStateMetadata2}; (FileImportTrackerModule).fileFinishedImporting('modules/app_analytics/AppAnalyticsUtils.tsx'); exports.default = object; exports.collectGuildAnalyticsMetadata = collectGuildAnalyticsMetadata2; exports.collectStaticChannelRouteAnalyticsMetadata = closure2; exports.collectChannelAnalyticsMetadataFromId = function(a0) { var value = null; if (value == a0) { return value; } var value3 = ChannelStore.getChannel(a0); return value == value3 ? value : collectChannelAnalyticsMetadata(value3); }; exports.collectChannelAnalyticsMetadata = collectChannelAnalyticsMetadata2; exports.collectVoiceAnalyticsMetadata = collectVoiceAnalyticsMetadata; exports.trackWithMetadata = trackWithMetadata2; exports.getChannelOpenedMetadata = getChannelOpenedMetadata; exports.getRecipientFriendCounts = closure5; exports.getVoiceStateMetadata = getVoiceStateMetadata2; exports.getCustomStatusMetadata = getCustomStatusMetadata; function _createForOfIteratorHelperLoose_42493(a0, a1) { // fn#42493, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:515, offset: 0x0113b2bd, 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 _fun42494; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_42495(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_42495(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_42495(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun42494; } 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 _fun42494() { // fn#42494, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:1086, 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 collectGuildAnalyticsMetadata(a0) { // fn#42497, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:1484, offset: 0x0113b455, size: 370 bytes, params: 2, frame: 21 if (a0 == null) { return null; } const guild = GuildStore.getGuild(a0); if (guild == null) { return null; } const numRoles = GuildRoleStore.getNumRoles(guild.id); const member = GuildMemberStore.getMember(a0, AuthenticationStore.getId()); const channels = GuildChannelStore.getChannels(a0); const length = channels[GUILD_SELECTABLE_CHANNELS_KEY].length; const length2 = channels[GUILD_VOCAL_CHANNELS_KEY].length; const voiceStates = VoiceStateStore.getVoiceStates(a0); const object = {}; object.guild_id = guild.id; object.guild_size_total = GuildMemberCountStore.getMemberCount(a0); object.guild_num_channels = length + length2; object.guild_num_text_channels = length; object.guild_num_voice_channels = length2; object.guild_num_roles = numRoles; object.guild_member_num_roles = member != null ? member.roles.length : 0; const String = global.String; object.guild_member_perms = String(PermissionStore.getGuildPermissions(guild) ?? (importAll(3789) /* metro dependency 3789: PermissionUtils */).NONE); const features = guild.features; const has = features.has; const VIP_REGIONS = GuildFeatures.VIP_REGIONS; object.guild_is_vip = Reflect.apply(has, features, [VIP_REGIONS]); object.is_member = member != null; object.num_voice_channels_active = countKeys(voiceStates); return object; } function collectChannelAnalyticsMetadata(a0) { // fn#42499, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:2210, offset: 0x0113b5da, size: 260 bytes, params: 2, frame: 17 if (a0 == null) { return null; } const guildId = a0.getGuildId(); const r2 = guildId != null && (THREAD_CHANNEL_TYPES.has(a0.type) && a0.parent_id != null ? isHidden(ChannelStore.getChannel(a0.parent_id)) : isHidden(a0)); const object = {}; object.channel_id = a0.id; object.channel_type = a0.type; object.channel_size_total = a0.isPrivate() ? a0.recipients.length : 0; const String = global.String; object.channel_member_perms = String(guildId == null ? (importAll(3789) /* metro dependency 3789: PermissionUtils */).NONE : PermissionStore.getChannelPermissions(a0) ?? (importAll(3789) /* metro dependency 3789: PermissionUtils */).NONE); object.channel_hidden = r2; return object; function isHidden(a0) { // fn#42500, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:2334, owner: collectChannelAnalyticsMetadata.isHidden, offset: 0x0113b6de, size: 91 bytes, params: 2, frame: 15 var r0; var moduleValue; if (a0 == null) { return false; } const permissionOverwrites = a0.permissionOverwrites; const property = permissionOverwrites[env0_0]; let value = property != null; if (value) { value = environment.__proto__; moduleValue = importAll(483) /* metro dependency 483: BigFlagUtils */; value = moduleValue.has(property.deny, Permissions.VIEW_CHANNEL); r0 = value; } else { r0 = value; } return r0; } } function trackWithMetadata(a0) { // fn#42501, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:2735, offset: 0x0113b739, size: 380 bytes, params: 2, frame: 24 var r2; var r8; var r4; var r12; var r11; var object; var value3; var channel; var value11; var guildId; let value = a1; const value2 = a2; const r10 = value !== undefined ? value : {}; const r6 = value2 !== undefined ? value2 : false; const defaultImport = AnalyticsUtils; if (!defaultImport.isThrottled(a0)) { value3 = 'location' in r10; r2 = value3 ? r10.location !== AnalyticsLocations.GUILD_CREATE_INVITE_SUGGESTION : !value3; r8 = 'guild_id' in r10 ? r10.guild_id : r2 ? SelectedGuildStore.getGuildId() : null; r4 = 'channel_id' in r10 ? r10.channel_id : r2 ? SelectedChannelStore.getChannelId(r8) : null; channel = ChannelStore.getChannel(r4); value11 = null; if (value11 == channel) { r11 = value11 != r8 ? r8 : value11; } else if (channel.isPrivate()) { r11 = value11; } else { guildId = channel.getGuildId(); r12 = value11 == guildId ? r8 : guildId; r11 = value11 != r12 ? r12 : value11; } object = {}; copyDataProperties(object, r10, undefined); copyDataProperties(object, collectGuildAnalyticsMetadata(r11), undefined); r2 = value11 == r8 || value11 == r4 ? collectChannelAnalyticsMetadata(channel) : isStaticChannelRoute(r4) ? collectStaticChannelRouteAnalyticsMetadata(0, r4) : collectChannelAnalyticsMetadata(channel); copyDataProperties(object, r2, undefined); value = defaultImport; value.track(a0, object, {flush: r6}); } } function getVoiceStateMetadata(a0, a1, a2) { // fn#42503, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:3517, offset: 0x0113b922, size: 132 bytes, params: 4, frame: 15 const env0_0 = a1; const defaultImport = Module00022; const voiceStateStoreBinding = VoiceStateStore; const getVoiceStates = voiceStateStoreBinding.getVoiceStates; let value = defaultImport(Reflect.apply(getVoiceStates, voiceStateStoreBinding, [a0])); value = value.filter(function({channelId}) { return channelId === require; }); value = value.filter(function({userId}) { return userId !== AuthenticationStore.getId(); }); value.forEach(_fun42506); return {'voice_state_count': 0, 'video_stream_count': 0, video_enabled: a2}; function _fun42506(a0) { // fn#42506, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:3729, offset: 0x0113b9c5, size: 66 bytes, params: 2, frame: 4 var video_stream_count; let binding = env0_1; const voice_state_count = binding.voice_state_count; binding.voice_state_count = typeof voice_state_count === 'bigint' ? voice_state_count + 1n : +voice_state_count + 1; if (a0.selfVideo || a0.selfStream) { binding = env0_1; video_stream_count = binding.video_stream_count; binding.video_stream_count = typeof video_stream_count === 'bigint' ? video_stream_count + 1n : +video_stream_count + 1; } } } function collectVoiceAnalyticsMetadata(a0) { // fn#42508, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:4436, offset: 0x0113ba39, size: 182 bytes, params: 2, frame: 18 if (a0 == null) { return null; } const channel = ChannelStore.getChannel(a0); if (channel == null) { return null; } const isVideoEnabled2 = MediaEngineStore.isVideoEnabled(); const mediaSessionId = RTCConnectionStore.getMediaSessionId(); const object = {}; object.channel_id = channel.id; object.channel_type = channel.type; object.guild_id = channel.getGuildId(); object.media_session_id = mediaSessionId; copyDataProperties(object, getVoiceStateMetadata(channel.getGuildId(), channel.id, isVideoEnabled2), undefined); const getVoiceAnalyticsMetadataAdditional = AppAnalyticsUtilsAdditionalNativeModule.getVoiceAnalyticsMetadataAdditional; copyDataProperties(object, Reflect.apply(getVoiceAnalyticsMetadataAdditional, AppAnalyticsUtilsAdditionalNativeModule, []), undefined); return object; } function getChannelOpenedMetadata(a0) { // fn#42509, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:4849, offset: 0x0113baef, size: 705 bytes, params: 2, frame: 25 var bot; var r4; var object; if (isStaticChannelRoute(a0)) { return {channel_static_route: a0}; } const channel = ChannelStore.getChannel(a0); const value3 = null; if (value3 == channel) { return {channel_id: a0}; } const guild = GuildStore.getGuild(channel.guild_id); if (value3 == guild) { bot = channel.isDM() && value3 != UserStore.getUser(channel.recipients[0]) && UserStore.getUser(channel.recipients[0]).bot; r4 = channel.isDM() || channel.isGroupDM() ? getRecipientFriendCounts(channel.recipients) : value3; copyDataProperties({channel_id: a0, is_app_dm: bot}, value3 != r4 ? {friend_recipient_count: r4.friendCount, non_friend_recipient_count: r4.nonFriendCount} : value3, undefined); } else { var readStateStoreBinding = ReadStateStore; var getSnapshot = readStateStoreBinding.getSnapshot; var Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis; var SECOND = Millis.SECOND; var value5 = Reflect.apply(getSnapshot, readStateStoreBinding, [a0, 10 * SECOND]); object = {channel_id: a0}; object.channel_was_unread = value5.unread; object.channel_mention_count = value5.mentionCount; var userGuildSettingsStoreBinding = UserGuildSettingsStore; object.channel_is_muted = userGuildSettingsStoreBinding.isChannelMuted(channel.guild_id, channel.id); object.channel_is_nsfw = channel.isNSFW(); object.channel_is_spoiler = channel.isSpoilerChannel(); object.channel_resolved_unread_setting = userGuildSettingsStoreBinding.resolveUnreadSetting(channel); var moduleValue = require(4867) /* metro dependency 4867: notificationSettingsPresetUtils */; var presetFromSettings = moduleValue.presetFromSettings; object.channel_preset = Reflect.apply(presetFromSettings, moduleValue, [userGuildSettingsStoreBinding.resolveUnreadSetting(channel), userGuildSettingsStoreBinding.resolvedMessageNotifications(channel)]); object.guild_id = channel.guild_id; object.guild_was_unread = value5.guildUnread; object.guild_mention_count = value5.guildMentionCount; object.guild_is_muted = userGuildSettingsStoreBinding.isMuted(channel.guild_id); object.guild_resolved_unread_setting = userGuildSettingsStoreBinding.resolveGuildUnreadSetting(guild); var moduleValue2 = require(4867) /* metro dependency 4867: notificationSettingsPresetUtils */; presetFromSettings = moduleValue2.presetFromSettings; var guildUnreadSetting = userGuildSettingsStoreBinding.resolveGuildUnreadSetting(guild); var getMessageNotifications = userGuildSettingsStoreBinding.getMessageNotifications; object.guild_preset = Reflect.apply(presetFromSettings, moduleValue2, [guildUnreadSetting, Reflect.apply(getMessageNotifications, userGuildSettingsStoreBinding, [channel.guild_id])]); object.parent_id = channel.parent_id; object.parent_channel_type = channel.parentChannelThreadType; var moduleValue3 = require(4868) /* metro dependency 4868: hasPendingMemberAction */; object.has_pending_member_action = moduleValue3.hasPendingMemberAction(channel.guild_id, a0); var permissionStoreBinding = PermissionStore; var can = permissionStoreBinding.can; var SEND_MESSAGES = Permissions.SEND_MESSAGES; object.can_send_message = Reflect.apply(can, permissionStoreBinding, [SEND_MESSAGES, channel]); object.is_app_dm = false; } return object; } function getCustomStatusMetadata(a0, a1) { // fn#42510, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:6341, offset: 0x0113bdb0, size: 87 bytes, params: 3, frame: 15 const env0_0 = a1; const defaultImport = Module00022; const voiceStateStoreBinding = VoiceStateStore; const getVoiceStates = voiceStateStoreBinding.getVoiceStates; defaultImport(Reflect.apply(getVoiceStates, voiceStateStoreBinding, [a0])).forEach(_fun42511); return {custom_status_count: 0}; function _fun42511(a0) { // fn#42511, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:6455, offset: 0x0113be07, size: 85 bytes, params: 2, frame: 15 var binding; var custom_status_count; if (a0.channelId === require && PresenceStore.findActivity(a0.userId, function({type}) { return type === ActivityTypes.CUSTOM_STATUS; }) != null) { binding = env0_1; custom_status_count = binding.custom_status_count; binding.custom_status_count = typeof custom_status_count === 'bigint' ? custom_status_count + 1n : +custom_status_count + 1; } } } } global.__d(_fun42492, 4863, [1383, 1226, 1379, 1935, 4111, 1945, 1938, 1867, 4259, 3784, 4396, 4294, 4605, 3793, 1934, 3969, 4864, 1878, 4297, 661, 1386, 3789, 483, 4866, 683, 672, 4867, 4868, 22, 2]) /* metro module 4863, dependencies: [1383, 1226, 1379, 1935, 4111, 1945, 1938, 1867, 4259, 3784, 4396, 4294, 4605, 3793, 1934, 3969, 4864, 1878, 4297, 661, 1386, 3789, 483, 4866, 683, 672, 4867, 4868, 22, 2] */;