/* Metro module 14703; source: modules/voice_calls/RTCConnectionDesyncHooks.tsx; dependencies: [57, 31, 4606, 4298, 1226, 1379, 1945, 12603, 4294, 1878, 4297, 22, 566, 1360, 4610, 2] */ import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */ import AuthenticationStore from '../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */ import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */ import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */ import GuildMemberStore from '../../stores/GuildMemberStore.tsx'; /* Metro dependency 1945 */ import RTCConnectionStore from '../../stores/RTCConnectionStore.tsx'; /* Metro dependency 4294 */ import VoiceStateStore from '../../stores/VoiceStateStore.tsx'; /* Metro dependency 4297 */ import VoiceStateRecord from '../../records/VoiceStateRecord.tsx'; /* Metro dependency 4298 */ import ChannelRTCStore from '../calls/ChannelRTCStore.tsx'; /* Metro dependency 4606 */ import RTCConnectionDesyncStore from '../../stores/RTCConnectionDesyncStore.tsx'; /* Metro dependency 12603 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as Module00022Module from '../../by-id/module-00022.js'; /* Metro dependency 22 */ import * as ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */ import * as FluxModule from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */ import * as GlobalUtilsModule from '../../utils/GlobalUtils.tsx'; /* Metro dependency 1360 */ import * as ChannelRTCParticipantsModule from '../calls/ChannelRTCParticipants.tsx'; /* Metro dependency 4610 */ function _fun110903(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#110903, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:6, offset: 0x0238bedf, size: 344 bytes, params: 8, frame: 20 let env0_0 = require; const _arrayLikeToArray_110906 = 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 closure = function(a0) { var env0_0 = a0; return require(dependencyMap[12]).useStateFromStores([RTCConnectionDesyncStore, RTCConnectionStore], _fun110908); }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); (FileImportTrackerModule).fileFinishedImporting('modules/voice_calls/RTCConnectionDesyncHooks.tsx'); exports.useEnsureSyncedChannelVoiceStates = useEnsureSyncedChannelVoiceStates; exports.useDesyncedChannelParticipants = closure; exports.useEnsureSyncedChannelParticipants = useEnsureSyncedChannelParticipants; exports.useIsRTCDisconnectedUIVisible = useIsRTCDisconnectedUIVisible; function _createForOfIteratorHelperLoose_110904(a0, a1) { // fn#110904, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:212, offset: 0x0238c037, 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 _fun110905; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_110906(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_110906(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_110906(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun110905; } 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 _fun110905() { // fn#110905, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:783, 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 useDesyncedChannelParticipants(a0) { // fn#110907, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:1122, offset: 0x0238c1ab, size: 74 bytes, params: 2, frame: 15 const env0_0 = a0; return (FluxModule).useStateFromStores([RTCConnectionDesyncStore, RTCConnectionStore], _fun110908); function _fun110908() { // fn#110908, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:1208, offset: 0x0238c1f5, size: 48 bytes, params: 1, frame: 11 const binding = env0_0; const value = environment.__proto__; return binding !== RTCConnectionStore.getChannelId() ? null : RTCConnectionDesyncStore.getDesyncedParticipants(); } } function useEnsureSyncedChannelVoiceStates(a0, a1) { // fn#110909, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:1389, offset: 0x0238c225, size: 306 bytes, params: 3, frame: 21 const env0_0 = a0; const env0_1 = a1; const value2 = undefined; const value3 = (FluxModule).useStateFromStores([RTCConnectionDesyncStore, RTCConnectionStore], _fun110910); const env0_3 = (FluxModule).useStateFromStoresArray([ChannelRTCStore], _fun110911); const value4 = (FluxModule).useStateFromStoresArray([UserStore], _fun110912); const basicChannel = (FluxModule).useStateFromStores([ChannelStore], _fun110914); return env0_3.useMemo(_fun110917, [value3, a1, env0_3.useMemo(_fun110915, [value4, basicChannel == null ? value2 : basicChannel.guild_id])]); function _fun110910() { // fn#110910, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:1479, offset: 0x0238c357, size: 48 bytes, params: 1, frame: 11 const binding = env0_0; const value = environment.__proto__; return binding !== RTCConnectionStore.getChannelId() ? null : RTCConnectionDesyncStore.getDesyncedVoiceStates(); } function _fun110911() { // fn#110911, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:1579, offset: 0x0238c387, size: 56 bytes, params: 1, frame: 13 var r0; var value2; var channelRTCStoreBinding; var items2; var guildRingingUsers; if (env0_0 == null) { r0 = []; } else { value2 = environment.__proto__; channelRTCStoreBinding = ChannelRTCStore; guildRingingUsers = channelRTCStoreBinding.getGuildRingingUsers(env0_0); items2 = []; arraySpread(items2, guildRingingUsers, 0, channelRTCStoreBinding); r0 = items2; } return r0; } function _fun110912() { // fn#110912, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:1668, offset: 0x0238c3bf, size: 69 bytes, params: 1, frame: 13 const value = env0_3.map(function(a0) { return UserStore.getUser(a0); }); return value.filter((GlobalUtilsModule).isNotNullish); } function _fun110914() { // fn#110914, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:1766, offset: 0x0238c41b, size: 27 bytes, params: 1, frame: 11 return ChannelStore.getBasicChannel(env0_0); } function _fun110915() { // fn#110915, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:1806, offset: 0x0238c436, size: 28 bytes, params: 1, frame: 11 return env0_4.map(_fun110916); function _fun110916(a0) { // fn#110916, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:1817, offset: 0x0238c452, size: 161 bytes, params: 2, frame: 18 const value = environment.__proto__.__proto__; const voiceStateRecordBinding = VoiceStateRecord; const id = a0.id; const value2 = Object.create(voiceStateRecordBinding.prototype, {constructor: {value: voiceStateRecordBinding}}); const voiceStateRecord2 = new voiceStateRecordBinding(id); const basicChannelBinding = basicChannel; const value5 = null; const value6 = undefined; return {voiceState: voiceStateRecord2 instanceof Object ? voiceStateRecord2 : value2, user: a0, member: value5 != (value5 == basicChannelBinding ? value6 : basicChannel.guild_id) ? GuildMemberStore.getMember(value5 == basicChannel ? value6 : basicChannel.guild_id, a0.id) : value5, nick: a0.globalName, comparator: a0.globalName, _isPlaceholder: false}; } } function _fun110917() { // fn#110917, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:2056, offset: 0x0238c4f3, size: 35 bytes, params: 1, frame: 15 return syncChannelVoiceStates(Module00057, require, env0_6); function syncChannelVoiceStates(a0, a1, a2) { // fn#110918, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:2060, offset: 0x0238c516, size: 211 bytes, params: 4, frame: 20 var environment; var r7; var length; var items2; var Set; var prototype; var value; var set; var value2; var value3; var value4; var done; var value5; var push; var add; var user; var id; var value6; var forEach; if (a0 != null) { length = a0.length; reducibleJoin2: while (true) { if (length !== 0) { items2 = []; var env0_0 = items2; Set = global.Set; prototype = Set.prototype; value = Object.create(prototype, {constructor: {value: Set}}); set = new Set(); value = set instanceof Object ? set : value; var env0_1 = value; value2 = environment.__proto__.__proto__; value3 = _createForOfIteratorHelperLoose_110904(a1); value4 = value3(); done = value4.done; if (!done) { r7 = value4; reducibleLoop4: while (true) { value5 = r7.value; push = items2.push; Reflect.apply(push, items2, [value5]); add = value.add; user = value5.user; id = user.id; Reflect.apply(add, value, [id]); value6 = value3(); done = value6.done; if (done) { break reducibleLoop4; } r7 = value6; continue reducibleLoop4; } } reducibleJoin7: while (true) { if (a0 == null) { break reducibleJoin7; } forEach = a0.forEach; Reflect.apply(forEach, a0, [_fun110919]); break reducibleJoin7; } length = a2.length; reducibleJoin9: while (true) { if (length > 0) { forEach = a2.forEach; Reflect.apply(forEach, a2, [_fun110921]); break reducibleJoin9; } break reducibleJoin9; } return items2; } break reducibleJoin2; } } if (a2.length === 0) { return a1; } items2 = []; Set = global.Set; set = new Set(); value3 = _createForOfIteratorHelperLoose_110904(a1); value4 = value3(); done = value4.done; if (!done) { r7 = value4; reducibleLoop4: while (true) { value5 = r7.value; push = items2.push; Reflect.apply(push, items2, [value5]); add = set.add; user = value5.user; id = user.id; Reflect.apply(add, set, [id]); value6 = value3(); done = value6.done; if (done) { break reducibleLoop4; } r7 = value6; continue reducibleLoop4; } } reducibleJoin7: while (true) { if (a0 == null) { break reducibleJoin7; } forEach = a0.forEach; Reflect.apply(forEach, a0, [_fun110919]); break reducibleJoin7; } reducibleJoin9: while (true) { if (a2.length > 0) { forEach = a2.forEach; Reflect.apply(forEach, a2, [_fun110921]); break reducibleJoin9; } break reducibleJoin9; } return items2; function _fun110919(a0) { // fn#110919, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:2295, offset: 0x0238c5e9, size: 78 bytes, params: 2, frame: 18 const binding = env0_0; const splice = binding.splice; Reflect.apply(splice, binding, [Module00022Module.sortedIndexBy(env0_0, a0, function(a0) { return a0.comparator; }), 0, a0]); } function _fun110921(a0) { // fn#110921, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:2390, offset: 0x0238c637, size: 107 bytes, params: 2, frame: 17 var environment; var splice; var value2; var moduleValue; let binding = env0_1; const has = binding.has; const user = a0.user; if (!Reflect.apply(has, binding, [user.id])) { binding = env0_0; splice = binding.splice; value2 = environment.__proto__.__proto__.__proto__; moduleValue = require(22) /* metro dependency 22 */; Reflect.apply(splice, binding, [moduleValue.sortedIndexBy(env0_0, a0, function(a0) { return a0.comparator; }), 0, a0]); } } } } } function useEnsureSyncedChannelParticipants(a0, a1) { // fn#110923, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:2604, offset: 0x0238c6a2, size: 66 bytes, params: 3, frame: 15 const env0_0 = a1; return ReactModule.useMemo(_fun110924, [useDesyncedChannelParticipants(a0), a1]); function _fun110924() { // fn#110924, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:2711, offset: 0x0238c6e4, size: 30 bytes, params: 1, frame: 13 return ((a0, a1) => { if (a0 == null) { return a1; } if (a0.length === 0) { return a1; } var items = []; arraySpread(items, a1, 0, a0); var env0_0 = items; a0.forEach(_fun110926); return items; })(env0_1, require); function syncChannelParticipants(a0, a1) { // fn#110925, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:2715, offset: 0x0238c702, size: 66 bytes, params: 3, frame: 15 if (a0 == null) { return a1; } if (a0.length === 0) { return a1; } const items2 = []; arraySpread(items2, a1, 0, a0); a0.forEach(_fun110926); return items2; function _fun110926(a0) { // fn#110926, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:2818, offset: 0x0238c744, size: 78 bytes, params: 2, frame: 18 const binding = env0_0; const splice = binding.splice; Reflect.apply(splice, binding, [Module00022Module.sortedIndexBy(env0_0, a0, _fun110927), 0, a0]); function _fun110927(a0) { // fn#110927, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:2860, offset: 0x0238c792, size: 41 bytes, params: 2, frame: 11 const value = environment.__proto__.__proto__.__proto__.__proto__; return (ChannelRTCParticipantsModule).sortKey(a0); } } } } } function useIsRTCDisconnectedUIVisible(a0, a1) { // fn#110928, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:2944, offset: 0x0238c7bb, size: 401 bytes, params: 3, frame: 26 const env0_0 = a0; const env0_1 = a1; let useStateFromStores = FluxModule.useStateFromStores; const value2 = Reflect.apply(useStateFromStores, FluxModule, [[AuthenticationStore], _fun110929]); const channelId = FluxModule.useStateFromStores([RTCConnectionStore], function() { return RTCConnectionStore.getChannelId(); }); const channelId2 = channelId; const binding = env0_3; var env0_3 = binding.useRef(null); let useState = binding.useState; const value3 = Reflect.apply(useState, binding, [false]); const binding2 = channelId2; const value4 = binding2(value3, 2); const property = value4[0]; const env0_4 = value4[1]; useState = binding.useState; const value5 = binding2(Reflect.apply(useState, binding, [false]), 2); const property2 = value5[0]; const env0_5 = value5[1]; useStateFromStores = FluxModule.useStateFromStores; const voiceStateStoreBinding = VoiceStateStore; const value6 = Reflect.apply(useStateFromStores, FluxModule, [[RTCConnectionStore, voiceStateStoreBinding], _fun110931]); const value = FluxModule.useStateFromStores([RTCConnectionStore, voiceStateStoreBinding], _fun110932); binding.useEffect(_fun110933, [value6]); binding.useEffect(_fun110934, [a0, channelId]); binding.useEffect(_fun110935, [value]); return !value2 && property2 && property; function _fun110929() { // fn#110929, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:3028, offset: 0x0238c94c, size: 30 bytes, params: 1, frame: 9 const value = environment.__proto__; return AuthenticationStore.getId() === require; } function _fun110931() { // fn#110931, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:3242, offset: 0x0238c96a, size: 113 bytes, params: 1, frame: 16 let r0 = require != null && env0_0 != null && RTCConnectionStore.getChannelId() === env0_0; r0 = r0 && VoiceStateStore.isInChannel(env0_0, require) != null && RTCConnectionStore.isUserConnected(require); return r0; } function _fun110932() { // fn#110932, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:3373, offset: 0x0238c9db, size: 116 bytes, params: 1, frame: 16 let r0 = require != null && env0_0 != null && RTCConnectionStore.getChannelId() === env0_0; r0 = r0 && VoiceStateStore.isInChannel(env0_0, require) != null && !RTCConnectionStore.isUserConnected(require); return r0; } function _fun110933() { // fn#110933, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:3487, offset: 0x0238ca4f, size: 27 bytes, params: 1, frame: 11 if (env0_6) { env0_5(true); } } function _fun110934() { // fn#110934, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:3521, offset: 0x0238ca6a, size: 32 bytes, params: 1, frame: 11 if (channelId !== env0_0) { env0_5(false); } } function _fun110935() { // fn#110935, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:3561, offset: 0x0238ca8a, size: 117 bytes, params: 1, frame: 15 var clearTimeout; var binding; if (env0_7) { if (env0_3.current == null) { env0_3.current = global.setTimeout(_fun110936, 250); } else { clearTimeout = global.clearTimeout; binding = env0_3; clearTimeout(binding.current); binding.current = null; env0_4(false); } } else { clearTimeout = global.clearTimeout; binding = env0_3; clearTimeout(binding.current); binding.current = null; env0_4(false); } return _fun110937; function _fun110936() { // fn#110936, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:3607, offset: 0x0238caff, size: 30 bytes, params: 1, frame: 11 env1_3.current = null; env1_4(true); } function _fun110937() { // fn#110937, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14900:3687, offset: 0x0238cb1d, size: 37 bytes, params: 1, frame: 12 const clearTimeout = global.clearTimeout; const binding = env1_3; clearTimeout(binding.current); binding.current = null; } } } } global.__d(_fun110903, 14703, [57, 31, 4606, 4298, 1226, 1379, 1945, 12603, 4294, 1878, 4297, 22, 566, 1360, 4610, 2]) /* metro module 14703, dependencies: [57, 31, 4606, 4298, 1226, 1379, 1945, 12603, 4294, 1878, 4297, 22, 566, 1360, 4610, 2] */;