/* Metro module 6929; source: modules/lurker_mode/LurkerPreviewManager.tsx; dependencies: [5, 6, 7, 15, 17, 18, 4294, 3969, 3785, 6912, 694, 6911, 4561, 2] */ function _fun55077(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#55077, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:6, offset: 0x013753fd, size: 328 bytes, params: 8, frame: 19 const env0_0 = require; const _arrayLikeToArray_55080 = 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 env0_3 = importDefault(5) /* metro dependency 5 */; const env0_4 = importDefault(6) /* metro dependency 6 */; const env0_5 = importDefault(7) /* metro dependency 7 */; const env0_6 = importDefault(15) /* metro dependency 15 */; const env0_7 = importDefault(17) /* metro dependency 17 */; const env0_8 = importDefault(18) /* metro dependency 18 */; const rtcConnectionStore = importDefault(4294) /* metro dependency 4294: RTCConnectionStore */; const selectedGuildStore = importDefault(3969) /* metro dependency 3969: SelectedGuildStore */; const lurkingStore = importDefault(3785) /* metro dependency 3785: LurkingStore */; let value = importDefault(4561) /* metro dependency 4561: LifecycleManager */; value = _fun55084(value); value = new value(); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/lurker_mode/LurkerPreviewManager.tsx'); exports.default = value; exports.LURKER_PREVIEW_PERSIST_MS = 60000; exports.LURKER_PREVIEW_MAX_CONCURRENT = 3; } function _createForOfIteratorHelperLoose_55078(a0, a1) { // fn#55078, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:190, offset: 0x01375545, 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 _fun55079; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_55080(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_55080(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_55080(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun55079; } 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 _isNativeReflectConstruct_55081() { // fn#55081, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:1100, offset: 0x013756b7, 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_55081_isNativeReflectConstruct = function() { return !!result; })(); } function _fun55084(a0) { // fn#55084, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:1299, offset: 0x01375715, size: 114 bytes, params: 2, frame: 16 const closure = LurkerPreviewManager; env0_8(closure, a0); return env0_5(closure, [{key: 'hasNavigatedAway', value: function(a0) { return this.navigatedAwayFromLurkingGuildIds.has(a0); }}, {key: '_initialize', value: function() { LurkingStore.addChangeListener(this.handleStoreChange); SelectedGuildStore.addChangeListener(this.handleStoreChange); RTCConnectionStore.addChangeListener(this.handleStoreChange); this.handleStoreChange(); }}, {key: '_terminate', value: value_55102}]); } function LurkerPreviewManager(a0) { // fn#55085, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:1311, offset: 0x01375787, size: 311 bytes, params: 2, frame: 20 var r0; var Reflect; let value = copyRestArgs(0, undefined); let binding = env1_4; binding(this, LurkerPreviewManager); const items2 = []; arraySpread(items2, value, 0, items2); value = env1_7(LurkerPreviewManager); binding = env1_6; if (_isNativeReflectConstruct_55081()) { Reflect = global.Reflect; value = Reflect.construct(value, items2, env1_7(this).constructor); r0 = value; } else { value = value.apply(this, items2); r0 = value; } value = binding(this, r0); const Map = global.Map; const value4 = Object.create(Map.prototype, {constructor: {value: Map}}); const map = new Map(); value.timers = map instanceof Object ? map : value4; let Set = global.Set; const value6 = Object.create(Set.prototype, {constructor: {value: Set}}); let set = new Set(); value.viewedLurkingGuildIds = set instanceof Object ? set : value6; Set = global.Set; const value8 = Object.create(Set.prototype, {constructor: {value: Set}}); set = new Set(); value.navigatedAwayFromLurkingGuildIds = set instanceof Object ? set : value8; value.handleStoreChange = handleStoreChange_55086; value.trackViewedLurkingGuilds = trackViewedLurkingGuilds; value.evictOverflowingLurkers = evictOverflowingLurkers; value.ensureMissingExpiries = ensureMissingExpiries; value.expireElapsed = expireElapsed; value.syncTimers = syncTimers; value.expireLurkerPreviews = _fun55095(); return value; } function value_55102() { // fn#55102, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:4232, offset: 0x01375f45, size: 190 bytes, params: 1, frame: 15 var r3; var value3; var clearTimeout; var value4; let value = environment.__proto__; LurkingStore.removeChangeListener(this.handleStoreChange); SelectedGuildStore.removeChangeListener(this.handleStoreChange); RTCConnectionStore.removeChangeListener(this.handleStoreChange); const _createForOfIteratorHelperLoose_55078Binding = _createForOfIteratorHelperLoose_55078; value = this.timers.values(); value = _createForOfIteratorHelperLoose_55078Binding(value); const value2 = value(); let done = value2.done; if (!done) { for (r3 = value2; true; r3 = value4) { value3 = r3.value; clearTimeout = global.clearTimeout; clearTimeout(value3); value4 = value(); done = value4.done; if (done) { break; } } } this.timers.clear(); this.viewedLurkingGuildIds.clear(); this.navigatedAwayFromLurkingGuildIds.clear(); } function LurkerPreviewManagerHandleStoreChange() { // fn#55086, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:1669, owner: LurkerPreviewManager.handleStoreChange, offset: 0x013758be, size: 61 bytes, params: 1, frame: 9 const binding = env0_0; binding.trackViewedLurkingGuilds(); binding.evictOverflowingLurkers(); binding.ensureMissingExpiries(); binding.expireElapsed(); binding.syncTimers(); } function trackViewedLurkingGuilds() { // fn#55087, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:1818, owner: LurkerPreviewManager.trackViewedLurkingGuilds, offset: 0x013758fb, size: 363 bytes, params: 1, frame: 18 var r6; var r4; var property; var has; var value8; var value10; var value13; var value14; const Set = global.Set; let value = environment.__proto__.__proto__; const set = new Set(LurkingStore.lurkingGuildIds()); let Array = global.Array; let from = Array.from; let viewedLurkingGuildIds = env0_0.viewedLurkingGuildIds; const value6 = Reflect.apply(from, Array, [viewedLurkingGuildIds]); let length = value6.length; const value7 = 0; if (value7 < length) { r6 = value7; while (true) { property = value6[r6]; has = set.has; if (!Reflect.apply(has, set, [property])) { viewedLurkingGuildIds = env0_0.viewedLurkingGuildIds; viewedLurkingGuildIds.delete(property); } value8 = typeof r6 === 'bigint' ? r6 + 1n : +r6 + 1; length = value6.length; if (value8 < length) { r6 = value8; continue; } break; } } Array = global.Array; from = Array.from; let navigatedAwayFromLurkingGuildIds = env0_0.navigatedAwayFromLurkingGuildIds; const value9 = Reflect.apply(from, Array, [navigatedAwayFromLurkingGuildIds]); length = value9.length; if (value7 < length) { r4 = value7; while (true) { property = value9[r4]; has = set.has; if (!Reflect.apply(has, set, [property])) { navigatedAwayFromLurkingGuildIds = env0_0.navigatedAwayFromLurkingGuildIds; navigatedAwayFromLurkingGuildIds.delete(property); } value10 = typeof r4 === 'bigint' ? r4 + 1n : +r4 + 1; length = value9.length; if (value10 < length) { r4 = value10; continue; } break; } } const guildId = SelectedGuildStore.getGuildId(); value = _createForOfIteratorHelperLoose_55078(env0_0.viewedLurkingGuildIds); const value12 = value(); let done = value12.done; if (!done) { r4 = value12; while (true) { value13 = r4.value; if (value13 !== guildId) { navigatedAwayFromLurkingGuildIds = env0_0.navigatedAwayFromLurkingGuildIds; navigatedAwayFromLurkingGuildIds.add(value13); } value14 = value(); done = value14.done; if (done) { break; } r4 = value14; continue; } } if (guildId != null && set.has(guildId)) { env0_0.viewedLurkingGuildIds.add(guildId); } } function evictOverflowingLurkers() { // fn#55088, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:2360, owner: LurkerPreviewManager.evictOverflowingLurkers, offset: 0x01375a66, size: 121 bytes, params: 1, frame: 14 let value = environment.__proto__.__proto__; const value2 = LurkingStore.lurkingGuildIds(); if (!(value2.length <= 3)) { value = require(6912) /* metro dependency 6912: MobileLurkerServerPreviewExperiment */; if (value.getMobileLurkerServerPreview('LurkerPreviewManager.evictOverflowingLurkers').stickyLurk) { value = value2.length - 3; value = value2.slice(0, value); env0_0.expireLurkerPreviews(value); } } } function ensureMissingExpiries() { // fn#55089, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:2592, owner: LurkerPreviewManager.ensureMissingExpiries, offset: 0x01375adf, size: 229 bytes, params: 1, frame: 14 var environment; var r1; var value3; var value4; var moduleValue; var dispatch; var object2; let value = environment.__proto__.__proto__; const value2 = LurkingStore.lurkingGuildIds(); if (value2.length !== 0) { var env0_0 = LurkingStore.getLurkingPreviewExpirations(); var env0_1 = SelectedGuildStore.getGuildId(); value3 = value2.filter(_fun55090); value4 = value3.length !== 0; if (value4) { moduleValue = require(6912) /* metro dependency 6912: MobileLurkerServerPreviewExperiment */; r1 = moduleValue.getMobileLurkerServerPreview('LurkerPreviewManager.ensureMissingExpiries').stickyLurk; } else { r1 = value4; } if (r1) { value = importDefault(694) /* metro dependency 694: Dispatcher */; dispatch = value.dispatch; object2 = {type: 'LURKER_PREVIEW_SET_EXPIRY', guildIds: value3}; object2.expiresAt = global.Date.now() + 60000; Reflect.apply(dispatch, value, [object2]); } } } function expireElapsed() { // fn#55091, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:2981, owner: LurkerPreviewManager.expireElapsed, offset: 0x01375bff, size: 177 bytes, params: 1, frame: 19 var r3; var r0; var property; var value7; var value8; var value9; let value = environment.__proto__.__proto__; const lurkingPreviewExpirations = LurkingStore.getLurkingPreviewExpirations(); const guildId = SelectedGuildStore.getGuildId(); value = RTCConnectionStore.getGuildId(); const Date = global.Date; const value4 = Date.now(); const items2 = []; const Object = global.Object; const value5 = Object.keys(lurkingPreviewExpirations); let length = value5.length; const value6 = 0; if (value6 < length) { r3 = value6; while (true) { property = value5[r3]; if (property !== guildId) { value7 = property !== value; if (!value7) { r0 = value7; continue; } value8 = lurkingPreviewExpirations[property] <= value4; r0 = value8; if (r0) { items2.push(property); break; } break; } value9 = typeof r3 === 'bigint' ? r3 + 1n : +r3 + 1; length = value5.length; if (value9 < length) { r3 = value9; continue; } break; } } if (items2.length > value6) { env0_0.expireLurkerPreviews(items2); } } function syncTimers() { // fn#55092, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:3216, owner: LurkerPreviewManager.syncTimers, offset: 0x01375cb0, size: 225 bytes, params: 1, frame: 22 var environment; var r7; var r4; var property; var value5; var clearTimeout; var value6; var value7; let value = environment.__proto__.__proto__; value = LurkingStore.getLurkingPreviewExpirations(); const env0_0 = value; const Array = global.Array; const from = Array.from; let timers = env0_0.timers; const value3 = Reflect.apply(from, Array, [timers.keys()]); let length = value3.length; const value4 = 0; if (value4 < length) { r7 = value4; while (true) { property = value3[r7]; if (value[property] == null) { timers = env0_0.timers; value5 = timers.get(property); if (value5 == null) { continue; } clearTimeout = global.clearTimeout; clearTimeout(value5); timers = env0_0.timers; timers.delete(property); } value6 = typeof r7 === 'bigint' ? r7 + 1n : +r7 + 1; length = value3.length; if (value6 < length) { r7 = value6; continue; } break; } } const closure = syncTimers_loop; const Object = global.Object; value = Object.keys(value); length = value.length; if (value4 < length) { for (r4 = value4; true; r4 = value7) { closure(value[r4]); value7 = typeof r4 === 'bigint' ? r4 + 1n : +r4 + 1; length = value.length; if (!(value7 < length)) { break; } } } } function _fun55095() { // fn#55095, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:3675, offset: 0x01375e45, size: 32 bytes, params: 1, frame: 12 const env0_0 = env2_3(_fun55097); return _fun55099; } function _fun55090(a0) { // fn#55090, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:2708, offset: 0x01375bc4, size: 59 bytes, params: 2, frame: 12 var value; let r0 = env0_0[a0] == null && a0 !== env0_1; if (r0) { value = environment.__proto__; value = env1_0.viewedLurkingGuildIds.has(a0); r0 = value; } return r0; } function syncTimers_loop(a0) { // fn#55093, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:3421, owner: LurkerPreviewManager.syncTimers._loop, offset: 0x01375d91, size: 136 bytes, params: 2, frame: 16 const env0_0 = a0; const timers = env1_0.timers; if (timers.has(a0)) { return 0; } const property = env0_0[a0]; let Date = global.Date; if (property <= Date.now()) { return 0; } Date = global.Date; env1_0.timers.set(a0, global.setTimeout(_fun55094, property - Date.now())); } function* _fun55097(a0) { // fn#55097, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:3695, offset: 0x01375e6e, size: 67 bytes, params: 2, frame: 14 if (true) { var Promise = global.Promise; yield Promise.all(a0.map(_fun55098)); if (false) { return undefined; } } } function _fun55094() { // fn#55094, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:3531, offset: 0x01375e19, size: 44 bytes, params: 1, frame: 12 const binding = env2_0; binding.timers.delete(env0_0); binding.handleStoreChange(); } function _fun55098(a0) { // fn#55098, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7107:3733, offset: 0x01375eb1, size: 41 bytes, params: 2, frame: 11 const value = environment.__proto__.__proto__.__proto__.__proto__.__proto__; return env5_0(env5_2[11]).stopLurkingForGuild(a0); }