/* Metro module 12080; source: modules/routing/RouteManager.tsx; dependencies: [6, 7, 4257, 12081, 661, 1230, 12082, 7364, 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 GatewayConnectionStore from '../gateway/GatewayConnectionStore.tsx'; /* Metro dependency 4257 */ import KeybindRouterStore from './KeybindRouterStore.tsx'; /* Metro dependency 12081 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */ import * as Router_utilsModule from './router_utils.tsx'; /* Metro dependency 1230 */ function _fun92819(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#92819, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:6, offset: 0x0209a336, size: 230 bytes, params: 8, frame: 19 const env0_0 = require; const _arrayLikeToArray_92822 = 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}); let value = _fun92823(); value = new value(); (FileImportTrackerModule).fileFinishedImporting('modules/routing/RouteManager.tsx'); exports.default = value; function _createForOfIteratorHelperLoose_92820(a0, a1) { // fn#92820, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:158, offset: 0x0209a41c, 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 _fun92821; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_92822(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_92822(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_92822(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun92821; } 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 _fun92821() { // fn#92821, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:729, 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 _fun92823() { // fn#92823, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:1078, offset: 0x0209a590, size: 236 bytes, params: 1, frame: 15 return CreateClass(RouteManager, [{key: 'initialize', value: value_92829}, {key: 'executeRouteRewrites', value: value_92830}, {key: 'cleanup', value: function() { var property = this.unlistenHistory; if (property != null) { property.call(this); } this.unlistenHistory = undefined; property = this.unlistenKeyboardChange; if (property != null) { property.call(this); } this.unlistenKeyboardChange = undefined; GatewayConnectionStore.removeChangeListener(this.handleConnectionChange); }}, {key: 'addRouteChangeListener', value: value_92832}, {key: 'addRouteRewriter', value: value_92834}, {key: 'removeRouteChangeListener', value: function(a0) { this.listeners.delete(a0); }}, {key: 'removeRouteRewriter', value: function(a0) { this.rewrites.delete(a0); }}, {key: 'getHistory', value: value_92838}]); function RouteManager() { // fn#92824, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:1099, offset: 0x0209a67c, size: 179 bytes, params: 1, frame: 15 var environment; const value = environment.__proto__; env1_2(this, RouteManager); let Set = global.Set; this.rewrites = new Set(); Set = global.Set; this.listeners = new Set(); this.routeChangeCount = 0; this.timer = -1; this.connected = false; this.handleConnectionChange = handleConnectionChange; this.handleRouteChange = handleRouteChange; this.handleKeybindRouteChange = handleKeybindRouteChange; this.flushRoute = flushRoute; function handleConnectionChange() { // fn#92825, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:1273, owner: RouteManager.handleConnectionChange, offset: 0x0209a72f, size: 126 bytes, params: 1, frame: 14 var binding; var executeRouteRewrites; let value = environment.__proto__.__proto__; const isConnected2 = GatewayConnectionStore.isConnected(); const r2 = isConnected2 && !env0_0.connected; env0_0.connected = isConnected2; if (r2) { binding = env0_0; binding.routeChangeCount = 0; executeRouteRewrites = binding.executeRouteRewrites; value = require(1230) /* metro dependency 1230: router_utils */; Reflect.apply(executeRouteRewrites, binding, [value.getHistory().location, 'REPLACE']); } } function handleRouteChange(a0, a1) { // fn#92826, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:1459, owner: RouteManager.handleRouteChange, offset: 0x0209a7ad, size: 298 bytes, params: 3, frame: 19 var r5; var value; var binding; var executeRouteRewrites; var moduleValue; var convertRouteToNavigation; var moduleValue2; var keybindRouterStoreBinding; var getState; var value2; var basePath; var pathname; var resetPath; var _createForOfIteratorHelperLoose_92820Binding; var listeners; var value3; var value4; var done; var value5; var error; var value6; reducibleJoin8: while (true) { reducibleJoin6: while (true) { if (a1 === 'POP') { value = environment.__proto__.__proto__; keybindRouterStoreBinding = KeybindRouterStore; value2 = keybindRouterStoreBinding.getState(); basePath = value2.basePath; pathname = a0.pathname; if (basePath === pathname) { break reducibleJoin6; } resetPath = value2.resetPath; pathname = a0.pathname; Reflect.apply(resetPath, value2, [pathname]); break reducibleJoin6; } value = environment; binding = env0_0; executeRouteRewrites = binding.executeRouteRewrites; if (Reflect.apply(executeRouteRewrites, binding, [a0, a1])) { return undefined; } value = environment.__proto__.__proto__; moduleValue = require(12082) /* metro dependency 12082: convertRouteToNavigationNative */; convertRouteToNavigation = moduleValue.convertRouteToNavigation; if (!Reflect.apply(convertRouteToNavigation, moduleValue, [a0])) { moduleValue2 = require(1230) /* metro dependency 1230: router_utils */; moduleValue2.replaceWith(Routes.ME); return undefined; } value = environment.__proto__.__proto__; keybindRouterStoreBinding = KeybindRouterStore; getState = keybindRouterStoreBinding.getState; value2 = Reflect.apply(getState, keybindRouterStoreBinding, []); basePath = value2.basePath; pathname = a0.pathname; if (basePath === pathname) { break reducibleJoin6; } resetPath = value2.resetPath; pathname = a0.pathname; Reflect.apply(resetPath, value2, [pathname]); break reducibleJoin6; } _createForOfIteratorHelperLoose_92820Binding = _createForOfIteratorHelperLoose_92820; value = environment; listeners = env0_0.listeners; value3 = _createForOfIteratorHelperLoose_92820Binding(listeners); value4 = value3(); done = value4.done; if (done) { env0_0.routeChangeCount = 0; return undefined; } r5 = value4; value5 = r5.value; break reducibleJoin8; } exceptionMain8: while (true) { reducibleLoop8: while (true) { try { value5(a0, a1); } catch (error) { while (true) { value6 = value3(); done = value6.done; if (done) { continue; } r5 = value6; value5 = r5.value; break; env0_0.routeChangeCount = 0; return undefined; continue exceptionMain8; } } value6 = value3(); done = value6.done; if (done) { break reducibleLoop8; } r5 = value6; value5 = r5.value; continue reducibleLoop8; } env0_0.routeChangeCount = 0; return undefined; } } function handleKeybindRouteChange({path}) { // fn#92827, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:1837, owner: RouteManager.handleKeybindRouteChange, offset: 0x0209a8d7, size: 102 bytes, params: 2, frame: 14 var binding; if (env0_0.timer !== -1) { global.clearTimeout(env0_0.timer); } if (path != null) { binding = env0_0; binding.timer = global.setTimeout(binding.flushRoute, 200); } } function flushRoute() { // fn#92828, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:1963, owner: RouteManager.flushRoute, offset: 0x0209a93d, size: 96 bytes, params: 1, frame: 13 const clearTimeout = global.clearTimeout; clearTimeout(env0_0.timer); let value = environment.__proto__.__proto__; const state = KeybindRouterStore.getState(); if (state.path != null) { value = require(1230) /* metro dependency 1230: router_utils */; value.transitionTo(state.path); } } } function value_92829() { // fn#92829, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:2084, offset: 0x0209a99d, size: 172 bytes, params: 1, frame: 17 this.cleanup(); let getHistory = Router_utilsModule.getHistory; const value2 = Reflect.apply(getHistory, Router_utilsModule, []); this.unlistenHistory = value2.listen(this.handleRouteChange); getHistory = Router_utilsModule.getHistory; const pathname = Reflect.apply(getHistory, Router_utilsModule, []).location.pathname; const keybindRouterStoreBinding = KeybindRouterStore; keybindRouterStoreBinding.getState().resetPath(pathname); this.unlistenKeyboardChange = keybindRouterStoreBinding.subscribe(this.handleKeybindRouteChange); const gatewayConnectionStoreBinding = GatewayConnectionStore; gatewayConnectionStoreBinding.addChangeListener(this.handleConnectionChange); } function value_92830(a0, a1) { // fn#92830, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:2412, offset: 0x0209aa49, size: 299 bytes, params: 3, frame: 21 var r5; var value; var value2; var value3; var done; var value4; var moduleValue; var getHistory; var location; var pathname; var value5; var value6; var addBreadcrumb; var path; var replaceWith; this.routeChangeCount = this.routeChangeCount + 1; if (this.routeChangeCount < 10) { value = environment.__proto__; value2 = _createForOfIteratorHelperLoose_92820(this.rewrites); value3 = value2(); done = value3.done; if (done) { return false; } r5 = value3; loopExit3: while (true) { value4 = r5.value; moduleValue = require(1230) /* metro dependency 1230: router_utils */; getHistory = moduleValue.getHistory; location = Reflect.apply(getHistory, moduleValue, []).location; pathname = location.pathname; value5 = value4(a0, a1); if (value5 != null) { break loopExit3; } value6 = value2(); done = value6.done; if (done) { return false; } r5 = value6; continue; } value = require(7364) /* metro dependency 7364 */; addBreadcrumb = value.addBreadcrumb; path = value5.path; Reflect.apply(addBreadcrumb, value, [{message: 'RouteManager.handleRouteChange: A route rewrite is replacing the current route', data: {replacePath: path, previousPath: pathname}}]); value = require(1230) /* metro dependency 1230: router_utils */; replaceWith = value.replaceWith; path = value5.path; Reflect.apply(replaceWith, value, [path, value5.state]); return true; } const Error = global.Error; throw new Error('RouteManager: Something has gone horribly wrong with rewrites'); } function value_92832(a0) { // fn#92832, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:3218, offset: 0x0209abc9, size: 105 bytes, params: 2, frame: 15 var environment; var value; const env0_1 = a0; if (this.unlistenHistory != null) { value = environment.__proto__; value = require(1230) /* metro dependency 1230: router_utils */; a0(value.getHistory().location, 'REPLACE'); } this.listeners.add(a0); return _fun92833; function _fun92833() { // fn#92833, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:3331, offset: 0x0209ac32, size: 24 bytes, params: 1, frame: 11 return env0_0.removeRouteChangeListener(env0_1); } } function value_92834(a0) { // fn#92834, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:3401, offset: 0x0209ac4a, size: 167 bytes, params: 2, frame: 20 var environment; var value; var moduleValue; var getHistory; var location; var moduleValue2; var value2; const env0_1 = a0; if (this.unlistenHistory != null) { value = environment.__proto__; moduleValue = require(1230) /* metro dependency 1230: router_utils */; getHistory = moduleValue.getHistory; location = Reflect.apply(getHistory, moduleValue, []).location; moduleValue2 = require(1230) /* metro dependency 1230: router_utils */; getHistory = moduleValue2.getHistory; value2 = a0(location, Reflect.apply(getHistory, moduleValue2, []).action); if (value2 != null) { value = require(1230) /* metro dependency 1230: router_utils */; value.replaceWith(value2.path, value2.state); } } this.rewrites.add(a0); return _fun92835; function _fun92835() { // fn#92835, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:3587, offset: 0x0209acf1, size: 24 bytes, params: 1, frame: 11 return env0_0.removeRouteRewriter(env0_1); } } function value_92838() { // fn#92838, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12266:3794, offset: 0x0209ad3d, size: 37 bytes, params: 1, frame: 11 const value = environment.__proto__; return (Router_utilsModule).getHistory(); } } } global.__d(_fun92819, 12080, [6, 7, 4257, 12081, 661, 1230, 12082, 7364, 2]) /* metro module 12080, dependencies: [6, 7, 4257, 12081, 661, 1230, 12082, 7364, 2] */;