/* Metro module 4395; source: stores/StreamRTCConnectionStore.tsx; dependencies: [6, 7, 15, 17, 18, 4266, 1226, 4259, 4396, 4294, 661, 4286, 44, 4398, 22, 4285, 7128, 694, 4406, 477, 12381, 566, 2] */ function _fun37208(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#37208, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:6, offset: 0x0109e9a8, size: 636 bytes, params: 8, frame: 21 const env0_0 = require; const closure = function() { return true; }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); 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 runningGameStoreNative = importDefault(4266) /* metro dependency 4266: RunningGameStoreNative */; const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */; const mediaEngineStore = importDefault(4259) /* metro dependency 4259: MediaEngineStore */; const presenceStore = importDefault(4396) /* metro dependency 4396: PresenceStore */; const rtcConnectionStore = importDefault(4294) /* metro dependency 4294: RTCConnectionStore */; const constantsModule = require(661) /* metro dependency 661: Constants */; const env0_14 = constantsModule.RTCConnectionQuality; const StreamLayouts = constantsModule.StreamLayouts; const env0_15 = (require(4286) /* metro dependency 4286: Constants */).StreamTypes; const env0_16 = {}; const env0_17 = {}; const env0_18 = {}; const env0_19 = {}; const env0_20 = {}; const env0_21 = {}; const env0_22 = StreamLayouts.PORTRAIT; const env0_23 = {}; const Store = (importDefault(566) /* metro dependency 566: flux */).Store; const value3 = _fun37216(Store); value3.displayName = 'StreamRTCConnectionStore'; const value5 = new value3(importDefault(694) /* metro dependency 694: Dispatcher */, mediaEngineStore.isSupported() ? {CONNECTION_OPEN: function(a0) { env0_3 = a0.sessionId; destroyStreamRTCConnections(); }, CONNECTION_CLOSED: function() { env0_3 = null; destroyStreamRTCConnections(); }, RTC_CONNECTION_STATE: closure, RTC_CONNECTION_PING: closure, RTC_CONNECTION_LOSS_RATE: closure, RTC_CONNECTION_UPDATE_ID: RTC_CONNECTION_UPDATE_ID_37237, RTC_CONNECTION_SECURE_FRAMES_UPDATE: closure, RTC_CONNECTION_REMOTE_VIDEO_SINK_WANTS: RTC_CONNECTION_REMOTE_VIDEO_SINK_WANTS_37239, STREAM_START: STREAM_START_37241, STREAM_STOP: STREAM_STOP_37243, STREAM_CREATE: STREAM_CREATE, STREAM_SERVER_UPDATE: STREAM_SERVER_UPDATE, STREAM_UPDATE: STREAM_UPDATE_37247, STREAM_DELETE: STREAM_DELETE, STREAM_LAYOUT_UPDATE: STREAM_LAYOUT_UPDATE, VIDEO_SIZE_UPDATE: VIDEO_SIZE_UPDATE_37251} : {}); (require(2) /* metro dependency 2 */).fileFinishedImporting('stores/StreamRTCConnectionStore.tsx'); exports.default = value5; } function _isNativeReflectConstruct_37209() { // fn#37209, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:277, offset: 0x0109ec24, 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_37209_isNativeReflectConstruct = function() { return !!result; })(); } function destroyStreamRTCConnections() { // fn#37212, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:522, offset: 0x0109ec82, size: 49 bytes, params: 1, frame: 14 const defaultImport = importDefault(22) /* metro dependency 22 */; defaultImport.forEach(env0_23, _fun37213); } function parseSourceType(a0) { // fn#37215, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:715, offset: 0x0109ecf0, size: 252 bytes, params: 2, frame: 15 var startsWith; if (a0 == null) { return 'unknown'; } const value = undefined; if ((require(477) /* metro dependency 477: PlatformUtils */).isPlatformEmbedded) { startsWith = a0.startsWith; if (Reflect.apply(startsWith, a0, ['web-contents-media-stream:'])) { return 'tab'; } startsWith = a0.startsWith; if (Reflect.apply(startsWith, a0, ['window:'])) { return 'window'; } startsWith = a0.startsWith; if (Reflect.apply(startsWith, a0, ['screen:'])) { return 'screen'; } return 'unknown'; } let platform = global.platform; if ((platform == null ? value : platform.name) === 'Chrome') { startsWith = a0.startsWith; if (Reflect.apply(startsWith, a0, ['web-contents-media-stream:'])) { return 'tab'; } startsWith = a0.startsWith; if (Reflect.apply(startsWith, a0, ['window:'])) { return 'window'; } startsWith = a0.startsWith; if (Reflect.apply(startsWith, a0, ['screen:'])) { return 'screen'; } return 'unknown'; } platform = global.platform; if ((platform == null ? value : platform.name) === 'Firefox') { return a0 === '' ? 'screen' : 'window'; } platform = global.platform; if ((platform == null ? value : platform.name) !== 'Safari') { return 'unknown'; } return 'window'; } function _fun37216(a0) { // fn#37216, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:1173, offset: 0x0109edec, size: 440 bytes, params: 2, frame: 16 const closure = StreamRTCConnectionStore; env0_8(closure, a0); return env0_5(closure, [{key: 'initialize', value: function() { this.waitFor(AuthenticationStore, MediaEngineStore, RTCConnectionStore, RunningGameStoreNative); }}, {key: 'getRTCConnections', value: value_37219}, {key: 'getAllActiveStreamKeys', value: value_37220}, {key: 'getRTCConnection', value: value_37221}, {key: 'getQuality', value: value_37222}, {key: 'getMediaSessionId', value: value_37223}, {key: 'getRtcConnectionId', value: value_37224}, {key: 'getVideoStats', value: value_37225}, {key: 'getHostname', value: value_37226}, {key: 'getRegion', value: value_37227}, {key: 'getMaxViewers', value: value_37228}, {key: 'getStreamSourceId', value: value_37229}, {key: 'getLastNonZeroRemoteVideoSinkWantsTime', value: value_37230}, {key: 'getUserIds', value: value_37231}, {key: 'isUserConnected', value: value_37232}, {key: 'getSecureFramesState', value: value_37233}, {key: 'getSecureFramesRosterMapEntry', value: value_37234}]); } function RTC_CONNECTION_UPDATE_ID_37237(a0) { // fn#37237, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:3586, offset: 0x0109f2da, size: 57 bytes, params: 2, frame: 14 const env0_0 = a0; const defaultImport = importDefault(22) /* metro dependency 22 */; return defaultImport.some(env0_23, _fun37238); } function RTC_CONNECTION_REMOTE_VIDEO_SINK_WANTS_37239({context, wants, userId, guildId, channelId}) { // fn#37239, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:3764, offset: 0x0109f329, size: 243 bytes, params: 2, frame: 21 var r1; var value7; var binding; var performance; let value3 = (require(4285) /* metro dependency 4285: StreamKeyUtils */).encodeStreamKey({streamType: guildId == null ? StreamTypes.CALL : StreamTypes.GUILD, guildId: guildId, channelId: channelId, ownerId: userId}); const MediaEngineContextTypes = (require(4406) /* metro dependency 4406: mediaEngine */).MediaEngineContextTypes; const STREAM = MediaEngineContextTypes.STREAM; let r0 = context === STREAM && env0_23[value3] != null; if (r0) { value7 = global.Object.entries(wants).some(function(a0) { var r0; var r2; var r3; var item3; var value3; var iterator = a0[Symbol.iterator](); var iterator2 = iterator.next; var item2 = Reflect.apply(iterator2, iterator, []); var item = item2.value; item2 = item2.done ? undefined : iterator; var value = undefined; var value2 = item2 === value; var r1 = value2 ? value : item; if (value2) { r0 = item2; r2 = value; r3 = value2; } else { item3 = Reflect.apply(iterator2, item2, []); item = item3.value; item3 = item3.done ? undefined : item2; value3 = item3 === value; if (value3) { r0 = item3; r2 = value; r3 = value3; } else { r0 = item3; r2 = item; r3 = value3; } } if (!r3) { r0.return(); } return r1 !== 'any' && r2 !== 0; }); if (value7) { binding = env0_21; performance = global.performance; binding[value3] = performance.now(); r1 = undefined; } else { r1 = !!value7; } r0 = r1; } return r0; } function STREAM_START_37241({streamType, guildId, channelId, appContext, pid, sourceId, sourcePid, nativePickerStyleUsed, goLiveModalDurationMs, analyticsLocations}) { // fn#37241, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:4129, offset: 0x0109f41c, size: 415 bytes, params: 2, frame: 25 var property; var gameForPID; const streamKeyUtilsModule = require(4285) /* metro dependency 4285: StreamKeyUtils */; const encodeStreamKey = streamKeyUtilsModule.encodeStreamKey; const object2 = {streamType: streamType, guildId: guildId, channelId: channelId}; object2.ownerId = AuthenticationStore.getId(); const value2 = Reflect.apply(encodeStreamKey, streamKeyUtilsModule, [object2]); env0_16[value2] = {appContext: appContext, analyticsLocations: analyticsLocations}; const defaultImport = importDefault(22) /* metro dependency 22 */; defaultImport.forEach(env0_23, function({analyticsContext, isOwner}) { analyticsContext.setActionContext(appContext); analyticsContext.setNativePickerStyleUsed(nativePickerStyleUsed); if (isOwner) { analyticsContext.trackStart(); } }); const r7 = pid ?? sourcePid; env0_19[value2] = sourceId; env0_18[value2] = r7; if (r7 != null) { gameForPID = RunningGameStoreNative.getGameForPID(r7); if (gameForPID != null) { env0_17[value2] = {name: gameForPID.name, id: gameForPID.id, exe: gameForPID.exeName, distributor: gameForPID.distributor, sku: gameForPID.sku, gameMetadata: gameForPID.gameMetadata}; } property = env0_23[value2]; if (property != null) { property.analyticsContext.updateStreamApplication(env0_17[value2]); } } else { property = env0_23[value2]; if (property != null) { property.analyticsContext.updateStreamApplication(null); } } if (goLiveModalDurationMs != null) { env0_20[value2] = goLiveModalDurationMs; } else { delete env0_20[value2]; } } function STREAM_STOP_37243({appContext, streamKey}) { // fn#37243, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:4926, offset: 0x0109f600, size: 114 bytes, params: 2, frame: 16 env0_16[streamKey] = {appContext: appContext, analyticsLocations: undefined}; const defaultImport = importDefault(22) /* metro dependency 22 */; defaultImport.forEach(env0_23, function({analyticsContext, isOwner}) { analyticsContext.setActionContext(appContext); if (isOwner) { analyticsContext.trackEnd(); } }); env0_19[streamKey] = null; env0_18[streamKey] = null; delete env0_20[streamKey]; } function STREAM_CREATE({streamKey, rtcServerId, rtcChannelId, region, viewerIds}) { // fn#37245, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:5169, offset: 0x0109f6a6, size: 577 bytes, params: 2, frame: 23 var r5; var binding; var moduleValue2; var StreamRTCAnalyticsContext; var object2; var prototype; var value9; var streamRTCAnalyticsContext; var value10; var defaultImport2; var value11; var defaultImport22; var value13; let property = env0_23[streamKey]; if (property == null && rtcServerId != null) { if (env0_18[streamKey] == null) { env0_17[streamKey] = null; } if (env0_17[streamKey] == null && env0_19[streamKey] == null) { binding = env0_17; moduleValue2 = require(7128) /* metro dependency 7128: StreamerApplicationSelectors */; binding[streamKey] = moduleValue2.getStreamerApplication((require(4285) /* metro dependency 4285: StreamKeyUtils */).decodeStreamKey(streamKey), PresenceStore); } StreamRTCAnalyticsContext = (require(4398) /* metro dependency 4398: StreamRTCConnection */).StreamRTCAnalyticsContext; object2 = {streamRegion: region, streamApplication: env0_17[streamKey]}; object2.streamSourceType = parseSourceType(env0_19[streamKey]); property = env0_16[streamKey]; object2.actionContext = property?.appContext; object2.numViewers = viewerIds != null ? viewerIds.length : 0; object2.goLiveModalDurationMs = env0_20[streamKey]; property = env0_16[streamKey]; object2.analyticsLocations = property?.analyticsLocations; prototype = StreamRTCAnalyticsContext.prototype; value9 = Object.create(prototype, {constructor: {value: StreamRTCAnalyticsContext}}); streamRTCAnalyticsContext = new StreamRTCAnalyticsContext(); value10 = streamRTCAnalyticsContext instanceof Object ? streamRTCAnalyticsContext : value9; (importDefault(44) /* metro dependency 44 */)(env0_3 != null, 'Creating RTCConnection without session.'); defaultImport2 = importDefault(4398) /* metro dependency 4398: StreamRTCConnection */; object2 = {sessionId: env0_3, streamKey: streamKey, serverId: rtcServerId, channelId: rtcChannelId}; object2.initialLayout = PORTRAIT; object2.analyticsContext = value10; object2.parentMediaSessionId = RTCConnectionStore.getMediaSessionId(); prototype = defaultImport2.prototype; value11 = Object.create(prototype, {constructor: {value: defaultImport2}}); defaultImport22 = new defaultImport2(); value13 = defaultImport22 instanceof Object ? defaultImport22 : value11; env0_23[streamKey] = value13; r5 = value13; } else { r5 = property; } delete env0_21[streamKey]; const dispatcher = importDefault(694) /* metro dependency 694: Dispatcher */; const dispatch = dispatcher.dispatch; object2 = {type: 'MEDIA_ENGINE_CONNECTION_STATS_HISTORY_RESET'}; object2.mediaEngineConnectionId = r5.getMediaEngineConnectionId(); Reflect.apply(dispatch, dispatcher, [object2]); } function STREAM_SERVER_UPDATE({streamKey, endpoint, token}) { // fn#37246, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:6132, offset: 0x0109f8e7, size: 58 bytes, params: 2, frame: 13 const property = env0_23[streamKey]; if (property == null) { return false; } property.connect(endpoint, token); } function STREAM_UPDATE_37247({streamKey, viewerIds, paused}) { // fn#37247, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:6255, offset: 0x0109f921, size: 87 bytes, params: 2, frame: 13 var analyticsContext; const property = env0_23[streamKey]; if (property == null) { return false; } if (viewerIds != null) { analyticsContext = property.analyticsContext; analyticsContext.trackViewerCount(viewerIds.length); } property.streamUpdate(paused); } function STREAM_DELETE({streamKey}) { // fn#37248, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:6438, offset: 0x0109f978, size: 116 bytes, params: 2, frame: 16 const property = env0_23[streamKey]; if (property == null) { return false; } const defaultImport = importDefault(694) /* metro dependency 694: Dispatcher */; const dispatch = defaultImport.dispatch; const object2 = {type: 'MEDIA_ENGINE_CONNECTION_STATS_HISTORY_RESET'}; object2.mediaEngineConnectionId = property.getMediaEngineConnectionId(); Reflect.apply(dispatch, defaultImport, [object2]); property.destroy('stream-end'); delete env0_23[streamKey]; } function STREAM_LAYOUT_UPDATE({layout}) { // fn#37249, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:6697, offset: 0x0109f9ec, size: 63 bytes, params: 2, frame: 12 const Object = global.Object; Object.values(env0_23).forEach(function(a0) { return a0.layoutChange(layout); }); } function VIDEO_SIZE_UPDATE_37251({streamId, dimensions, zoom}) { // fn#37251, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:6809, offset: 0x0109fa42, size: 82 bytes, params: 2, frame: 14 const defaultImport = importDefault(22) /* metro dependency 22 */; defaultImport.forEach(env0_23, _fun37252); } function _fun37213(a0, a1) { // fn#37213, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:581, offset: 0x0109ecb3, size: 61 bytes, params: 3, frame: 13 a0.destroy(a0.isOwner ? 'sender-disconnect' : 'receiver-disconnect'); value = environment.__proto__; delete env1_23[a1]; delete env1_21[a1]; } function value_37220() { // fn#37220, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:1647, offset: 0x0109f03c, size: 27 bytes, params: 1, frame: 11 const Object = global.Object; return Object.keys(env1_23); } function value_37222(a0) { // fn#37222, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:1762, offset: 0x0109f067, size: 85 bytes, params: 2, frame: 13 return (importDefault(12381) /* metro dependency 12381: canSpectate */)(MediaEngineStore) ? a0 == null ? RTCConnectionQuality.UNKNOWN : env1_23[a0]?.quality ?? RTCConnectionQuality.UNKNOWN : RTCConnectionQuality.UNKNOWN; } function value_37223(a0) { // fn#37223, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:1898, offset: 0x0109f0bc, size: 55 bytes, params: 2, frame: 12 const value = null; if (value == a0) { return value; } const property = env1_23[a0]; return value != property ? value != property ? property.getMediaSessionId() : value : undefined; } function value_37224(a0) { // fn#37224, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:2035, offset: 0x0109f0f3, size: 55 bytes, params: 2, frame: 12 const value = null; if (value == a0) { return value; } const property = env1_23[a0]; return value != property ? value != property ? property.getRTCConnectionId() : value : undefined; } function value_37225(a0) { // fn#37225, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:2168, offset: 0x0109f12a, size: 43 bytes, params: 2, frame: 11 const value = null; if (value == a0) { return value; } const property = env1_23[a0]; return value != property ? property.getVideoStats() : value; } function value_37226(a0) { // fn#37226, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:2279, offset: 0x0109f155, size: 64 bytes, params: 2, frame: 5 if (a0 == null) { return ''; } const value = environment.__proto__; const property = env1_23[a0]; return property != null && property.hostname != null ? property.hostname : ''; } function value_37227(a0) { // fn#37227, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:2394, offset: 0x0109f195, size: 43 bytes, params: 2, frame: 11 const value = null; if (value == a0) { return value; } const property = env1_23[a0]; return value != property ? property.getRegion() : value; } function value_37228(a0) { // fn#37228, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:2503, offset: 0x0109f1c0, size: 43 bytes, params: 2, frame: 11 const value = null; if (value == a0) { return value; } const property = env1_23[a0]; return value != property ? property.getMaxViewers() : value; } function value_37229(a0) { // fn#37229, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:2620, offset: 0x0109f1eb, size: 16 bytes, params: 2, frame: 2 return env1_19[a0]; } function value_37231(a0) { // fn#37231, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:2748, offset: 0x0109f1fb, size: 37 bytes, params: 2, frame: 10 const value = environment.__proto__; return env1_23[a0]?.getUserIds(); } function value_37232(a0, a1) { // fn#37232, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:2839, offset: 0x0109f220, size: 41 bytes, params: 3, frame: 12 const value = environment.__proto__; return env1_23[a0]?.getIsUserConnected(a1); } function value_37233(a0) { // fn#37233, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:2946, offset: 0x0109f249, size: 37 bytes, params: 2, frame: 10 const value = environment.__proto__; return env1_23[a0]?.getSecureFramesState(); } function value_37234(a0, a1) { // fn#37234, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:3061, offset: 0x0109f26e, size: 59 bytes, params: 3, frame: 13 let value = environment.__proto__; const property = env1_23[a0]; value = undefined; const r3 = property == null ? value : property.getSecureFramesRosterMap(); return r3 == null ? value : r3.get(a1); } function _fun37238(a0) { // fn#37238, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:3650, offset: 0x0109f313, size: 22 bytes, params: 2, frame: 2 return a0 === env0_0.connection; } function _fun37252(a0) { // fn#37252, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4567:6894, offset: 0x0109fa94, size: 41 bytes, params: 2, frame: 15 if (a0 != null) { a0.setVideoSize(streamId, dimensions, zoom); } }