/* Metro module 12505; source: modules/gateway/GatewayCompressionHandler.tsx; dependencies: [15, 17, 18, 6, 7, 27, 12506, 12508, 3, 477, 12507, 4664, 2] */ function _fun95279(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#95279, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:6, offset: 0x02137e2d, size: 381 bytes, params: 8, frame: 19 const env0_0 = require; const _arrayLikeToArray_95282 = 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(15) /* metro dependency 15 */; const env0_4 = importDefault(17) /* metro dependency 17 */; const env0_5 = importDefault(18) /* metro dependency 18 */; const env0_6 = importDefault(6) /* metro dependency 6 */; const env0_7 = importDefault(7) /* metro dependency 7 */; const env0_8 = (require(27) /* metro dependency 27 */).NativeModules; items = []; let value = _fun95287(); items.push(_fun95293(value)); items.push(_fun95300(value)); items.push(_fun95308(value)); items.push(_fun95315(value)); value = _fun95323(value); items.push(value); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/gateway/GatewayCompressionHandler.tsx'); exports.getCompressionHandler = getCompressionHandler; } function _createForOfIteratorHelperLoose_95280(a0, a1) { // fn#95280, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:162, offset: 0x02137faa, 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 _fun95281; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_95282(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_95282(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_95282(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun95281; } 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_95284() { // fn#95284, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:1203, offset: 0x0213811e, size: 98 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_95284_isNativeReflectConstruct = function() { return !!result; })(); } function _fun95287() { // fn#95287, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:1432, offset: 0x02138180, size: 145 bytes, params: 1, frame: 16 return env0_7(BaseGatewayCompressionHandler, [{key: 'bindWebSocket', value: function() { }}, {key: 'feed', value: function() { }}, {key: 'dataReady', value: function(a0) { this._onDataReady = a0; }}], [{key: 'canUse', value: function() { return false; }}]); } function _fun95293(a0) { // fn#95293, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:1769, offset: 0x0213824d, size: 181 bytes, params: 2, frame: 17 const closure = DesktopZstdGatewayCompressionHandler; env0_5(closure, a0); return env0_7(closure, [{key: 'getAlgorithm', value: function() { return 'zstd-stream'; }}, {key: 'usesLegacyCompression', value: function() { return false; }}, {key: 'feed', value: value_95297}, {key: 'close', value: function() { }}], [{key: 'canUse', value: function() { return false; }}]); } function _fun95300(a0) { // fn#95300, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:2745, offset: 0x02138463, size: 208 bytes, params: 2, frame: 17 const closure = PakoStreamGatewayCompressionHandler; env0_5(closure, a0); return env0_7(closure, [{key: 'getAlgorithm', value: function() { return 'zlib-stream'; }}, {key: 'usesLegacyCompression', value: function() { return false; }}, {key: 'feed', value: value_95304}, {key: 'close', value: function() { if (this._inflate != null) { this._inflate.onEnd = null; this._inflate.chunks = []; } this._inflate = null; }}, {key: 'handleFlushEnd', value: value_95306}], [{key: 'canUse', value: function() { return false; }}]); } function _fun95308(a0) { // fn#95308, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:4514, offset: 0x02138902, size: 181 bytes, params: 2, frame: 17 const closure = PakoGatewayCompressionHandler; env0_5(closure, a0); return env0_7(closure, [{key: 'getAlgorithm', value: function() { return null; }}, {key: 'usesLegacyCompression', value: function() { return true; }}, {key: 'feed', value: value_95312}, {key: 'close', value: function() { }}], [{key: 'canUse', value: function() { return false; }}]); } function _fun95315(a0) { // fn#95315, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:5237, offset: 0x02138a91, size: 208 bytes, params: 2, frame: 17 const closure = MobileGatewayCompressionHandler; env0_5(closure, a0); return env0_7(closure, [{key: 'bindWebSocket', value: value_95317}, {key: 'getAlgorithm', value: value_95318}, {key: 'usesLegacyCompression', value: function() { return false; }}, {key: 'feed', value: function(a0) { if (this._onDataReady == null) { throw new global.Error('Cannot feed unless a data ready callback is registered.'); } if (a0 !== null) { this._onDataReady(a0); } }}, {key: 'close', value: value_95321}], [{key: 'canUse', value: value_95322}]); } function _fun95323(a0) { // fn#95323, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:6621, offset: 0x02138e40, size: 181 bytes, params: 2, frame: 17 const closure = NullGatewayCompressionHandler; env0_5(closure, a0); return env0_7(closure, [{key: 'getAlgorithm', value: function() { return null; }}, {key: 'usesLegacyCompression', value: function() { return false; }}, {key: 'feed', value: function(a0) { if (this._onDataReady == null) { throw new global.Error('Cannot feed unless a data ready callback is registered.'); } this._onDataReady(a0); }}, {key: 'close', value: function() { }}], [{key: 'canUse', value: function() { return true; }}]); } function getCompressionHandler(a0) { // fn#95330, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:7313, offset: 0x02138f64, size: 195 bytes, params: 2, frame: 16 var value4; var canUse; var value5; var binding; var binding2; var binding3; let value = environment; const ProcessArgs = (require(4664) /* metro dependency 4664: ProcessArgs */).ProcessArgs; if (ProcessArgs.isDiscordGatewayPlaintextSet()) { binding = env0_10; value = Object.create(binding.prototype, {constructor: {value: binding}}); binding3 = new binding(a0); return binding3 instanceof Object ? binding3 : value; } const value2 = _createForOfIteratorHelperLoose_95280(env0_9); const value3 = value2(); let done = value3.done; if (done) { binding = env0_10; value = Object.create(binding.prototype, {constructor: {value: binding}}); binding2 = new binding(a0); return binding2 instanceof Object ? binding2 : value; } let r4 = value3; loopExit2: while (true) { value4 = r4.value; canUse = value4.canUse; if (Reflect.apply(canUse, value4, [])) { break loopExit2; } value5 = value2(); done = value5.done; if (done) { binding = env0_10; value = Object.create(binding.prototype, {constructor: {value: binding}}); binding2 = new binding(a0); return binding2 instanceof Object ? binding2 : value; } r4 = value5; continue; } value = Object.create(value4.prototype, {constructor: {value: value4}}); const value6 = new value4(a0); return value6 instanceof Object ? value6 : value; } function BaseGatewayCompressionHandler(a0) { // fn#95288, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:1453, offset: 0x02138211, size: 44 bytes, params: 2, frame: 13 env1_6(this, BaseGatewayCompressionHandler); this._onDataReady = null; this._gatewayEncoding = a0; } function DesktopZstdGatewayCompressionHandler(a0) { // fn#95294, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:1781, offset: 0x02138302, size: 160 bytes, params: 2, frame: 17 var TextDecoder; var value4; var textDecoder; const value = environment.__proto__; env1_6(this, DesktopZstdGatewayCompressionHandler); const value3 = _callSuper_95283(this, DesktopZstdGatewayCompressionHandler, [a0]); value3._decoder = null; const _gatewayEncoding = value3._gatewayEncoding; if (_gatewayEncoding.wantsString()) { TextDecoder = global.TextDecoder; value4 = Object.create(TextDecoder.prototype, {constructor: {value: TextDecoder}}); textDecoder = new TextDecoder('utf-8'); value3._decoder = textDecoder instanceof Object ? textDecoder : value4; } else { value3._decoder = null; } value3._stream = (require(12506) /* metro dependency 12506: GatewayZstdUtilsNative */).createZstdContextWeb(); return value3; } function value_95297(a0) { // fn#95297, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:2316, offset: 0x021383aa, size: 185 bytes, params: 2, frame: 15 var r1; var value; if (this._stream == null) { throw new global.Error('Trying to decompress with zstd but did not initialize with it'); } const ArrayBuffer = global.ArrayBuffer; if (a0 instanceof ArrayBuffer) { value = this._stream.decompress(a0); if (this._decoder == null) { r1 = value; } else { value = this._decoder.decode(value); r1 = value; } if (this._onDataReady != null) { this._onDataReady(r1); } return undefined; } const Error = global.Error; throw new Error('Expected array buffer, but got ' + typeof a0); } function PakoStreamGatewayCompressionHandler(a0) { // fn#95301, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:2757, offset: 0x02138533, size: 218 bytes, params: 2, frame: 17 var object2; const value = environment.__proto__; env1_6(this, PakoStreamGatewayCompressionHandler); const value3 = _callSuper_95283(this, PakoStreamGatewayCompressionHandler, [a0]); value3._pako = require(12508) /* metro dependency 12508 */; value3._usesZstd = false; value3._zstdDecoder = null; value3._zstdStream = null; const Inflate = value3._pako.Inflate; object2 = {chunkSize: 65536}; object2.to = value3._gatewayEncoding.wantsString() ? 'string' : ''; value3._inflate = new Inflate(object2); value3._inflate.onEnd = value3.handleFlushEnd.bind(value3); return value3; } function value_95304(a0) { // fn#95304, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:3355, offset: 0x02138615, size: 283 bytes, params: 2, frame: 16 var r5; var dataView; var value3; var push; let _inflate = this._inflate; if (_inflate == null) { throw new global.Error('Trying to feed to closed compression adapter'); } if (this._onDataReady === null) { throw new global.Error('Cannot feed unless a data ready callback is registered.'); } const ArrayBuffer = global.ArrayBuffer; if (a0 instanceof ArrayBuffer) { dataView = new global.DataView(a0); value3 = dataView.byteLength >= 4; if (value3) { dataView = dataView.getUint32(dataView.byteLength - 4, false); dataView = dataView === 65535; r5 = dataView; } else { r5 = value3; } _inflate = this._inflate; push = _inflate.push; dataView = !!r5; Reflect.apply(push, _inflate, [a0, r5 ? this._pako.Z_SYNC_FLUSH : dataView]); return undefined; } const Error = global.Error; throw new Error('Expected array buffer, but got ' + typeof a0); } function value_95306(a0) { // fn#95306, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:3932, offset: 0x02138765, size: 413 bytes, params: 2, frame: 23 var r9; var r10; var r11; var r8; var r2; var value; var chunks; var length; var property; var length2; var value3; var value4; var uint8Array; var set; var length3; var value7; var _onDataReady; var Error; const _pako = this._pako; const _inflate = this._inflate; if (_inflate != null) { if (a0 !== _pako.Z_OK) { Error = global.Error; value = 'zlib error, ' + a0 + ', ' + _inflate.strm.msg; throw new Error(); } chunks = _inflate.chunks; length = chunks.length; value = this._gatewayEncoding.wantsString(); if (value) { r2 = length > 1 ? chunks.join('') : chunks[0]; } else if (length > 1) { value = 0; if (value < length) { r9 = value; r10 = value; reducibleLoop7: while (true) { length2 = chunks[r9].length; value3 = r10 + length2; value4 = typeof r9 === 'bigint' ? r9 + 1n : +r9 + 1; if (value4 < length) { r9 = value4; r10 = value3; continue reducibleLoop7; } r11 = value3; break reducibleLoop7; } } else { r11 = value; } uint8Array = new global.Uint8Array(); if (value < length) { r8 = value; r9 = value; reducibleLoop9: while (true) { property = chunks[r8]; set = uint8Array.set; Reflect.apply(set, uint8Array, [property, r9]); length3 = property.length; value = r9 + length3; value7 = typeof r8 === 'bigint' ? r8 + 1n : +r8 + 1; if (value7 < length) { r8 = value7; r9 = value; continue reducibleLoop9; } r2 = uint8Array; break reducibleLoop9; } } else { r2 = uint8Array; } } else { r2 = chunks[0]; } chunks.length = 0; _onDataReady = this._onDataReady; reducibleJoin16: while (true) { if (_onDataReady == null) { break reducibleJoin16; } _onDataReady = this._onDataReady; Reflect.apply(_onDataReady, this, [r2]); break reducibleJoin16; } } else { value = environment.__proto__; value = importDefault(3) /* metro dependency 3: Logger */; value = new value('GatewayCompressionHandler'); value.error('flush end happened on closed compression adapter'); } } function PakoGatewayCompressionHandler(a0) { // fn#95309, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:4526, offset: 0x021389b7, size: 86 bytes, params: 2, frame: 18 let value = copyRestArgs(0, undefined); env1_6(this, PakoGatewayCompressionHandler); const _callSuper_95283Binding = _callSuper_95283; const items2 = []; arraySpread(items2, value, 0, undefined); value = _callSuper_95283Binding(this, PakoGatewayCompressionHandler, items2); value._pako = require(12508) /* metro dependency 12508 */; return value; } function value_95312(a0) { // fn#95312, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:4898, offset: 0x02138a0d, size: 132 bytes, params: 2, frame: 17 var r2; let value = a0; const _pako = this._pako; const ArrayBuffer = global.ArrayBuffer; if (value instanceof ArrayBuffer && this._gatewayEncoding.wantsString()) { value = _pako.inflate(value, {to: 'string'}); r2 = value; } else { r2 = value; } if (this._onDataReady == null) { throw new global.Error('Cannot feed unless a data ready callback is registered.'); } this._onDataReady(r2); } function MobileGatewayCompressionHandler(a0) { // fn#95316, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:5249, offset: 0x02138b61, size: 57 bytes, params: 2, frame: 16 let value = environment.__proto__; env1_6(this, MobileGatewayCompressionHandler); value = _callSuper_95283(this, MobileGatewayCompressionHandler, [a0]); value._socketId = null; return value; } function value_95317({_socketId}) { // fn#95317, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:5526, offset: 0x02138b9a, size: 313 bytes, params: 2, frame: 16 var DCDCompressionManager; const property = (require(12507) /* metro dependency 12507: NativeCompressionModule */).default; this.close(); this._socketId = _socketId; const value2 = (require(12506) /* metro dependency 12506: GatewayZstdUtilsNative */).supportsZstd(); const isAndroid2 = (require(477) /* metro dependency 477: PlatformUtils */).isAndroid(); if (value2) { if (isAndroid2) { if (property != null) { property.enableZstdStreamSupport(this._socketId); } } else { DCDCompressionManager = NativeModules.DCDCompressionManager; DCDCompressionManager.enableZstdStreamSupport(this._socketId, 0); } } else if (isAndroid2) { if (property != null) { property.enableZlibStreamSupport(this._socketId); } } else { DCDCompressionManager = NativeModules.DCDCompressionManager; DCDCompressionManager.enableZlibStreamSupport(this._socketId); } } function value_95318() { // fn#95318, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:5968, offset: 0x02138cd3, size: 52 bytes, params: 1, frame: 11 let value = environment.__proto__; value = require(12506) /* metro dependency 12506: GatewayZstdUtilsNative */; value = value.supportsZstd(); return value ? 'zstd-stream' : 'zlib-stream'; } function value_95321() { // fn#95321, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:6281, offset: 0x02138d50, size: 151 bytes, params: 1, frame: 15 var value; var moduleValue; const _socketId = this._socketId; this._socketId = null; if (_socketId !== null) { value = environment.__proto__; moduleValue = require(477) /* metro dependency 477: PlatformUtils */; if (moduleValue.isAndroid()) { if ((require(12507) /* metro dependency 12507: NativeCompressionModule */).default != null) { (require(12507) /* metro dependency 12507: NativeCompressionModule */).default.disableZlibStreamSupport(_socketId); } } else { NativeModules.DCDCompressionManager.disableZlibStreamSupport(_socketId); } } } function value_95322() { // fn#95322, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:6513, offset: 0x02138de7, size: 89 bytes, params: 1, frame: 13 const value = environment.__proto__; const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */; return platformUtilsModule.isAndroid() ? (require(12507) /* metro dependency 12507: NativeCompressionModule */).default != null : NativeModules.DCDCompressionManager != null; } function NullGatewayCompressionHandler() { // fn#95324, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12695:6633, offset: 0x02138ef5, size: 42 bytes, params: 1, frame: 16 env1_6(this, NullGatewayCompressionHandler); return _callSuper_95283(this, NullGatewayCompressionHandler, arguments); }