/* Metro module 8057; source: modules/interactions/InteractionStore.tsx; dependencies: [6, 7, 15, 17, 18, 57, 1226, 1379, 672, 4629, 1909, 7067, 566, 694, 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 PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */ import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */ import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */ import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */ import Flux from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */ import AuthenticationStore from '../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */ import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ServerModule from '../../flow/Server.tsx'; /* Metro dependency 1909 */ import * as InteractionTypesModule from './InteractionTypes.tsx'; /* Metro dependency 4629 */ function _fun63924(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#63924, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:6, offset: 0x01b96662, size: 563 bytes, params: 8, frame: 21 const env0_0 = require; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); let Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis; const MINUTE = Millis.MINUTE; const value = 5 * MINUTE; Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis; const SECOND = Millis.SECOND; const value2 = 10 * SECOND; const env0_13 = {}; const env0_14 = {}; const env0_15 = {}; const env0_18 = {}; const Store = (Flux).Store; const value3 = _fun63930(Store); value3.displayName = 'InteractionStore'; const value6 = new value3(importDefault(694) /* metro dependency 694: Dispatcher */, {LOGOUT: LOGOUT_63939, INTERACTION_QUEUE: INTERACTION_QUEUE, INTERACTION_CREATE: INTERACTION_CREATE, INTERACTION_SUCCESS: function({nonce}) { markInteractionByNonceCompleted(nonce); }, INTERACTION_FAILURE: INTERACTION_FAILURE_63944, MESSAGE_CREATE: MESSAGE_CREATE_63945, CHANNEL_SELECT: CHANNEL_SELECT_63946, INTERACTION_IFRAME_MODAL_CREATE: function({application, nonce}) { env0_17 = application.id; markInteractionByNonceCompleted(nonce); }, INTERACTION_IFRAME_MODAL_CLOSE: function() { env0_16 = undefined; env0_17 = undefined; }, INTERACTION_IFRAME_MODAL_KEY_CREATE: function(a0) { env0_16 = a0.modalKey; }, INTERACTION_MODAL_CREATE: function({nonce}) { markInteractionByNonceCompleted(nonce); }, EMBEDDED_ACTIVITY_UPDATE_V2: EMBEDDED_ACTIVITY_UPDATE_V2_63951}); (FileImportTrackerModule).fileFinishedImporting('modules/interactions/InteractionStore.tsx'); exports.default = value6; exports.STALE_INTERACTION_INTERVAL = value; exports.STALE_INTERACTION_DURATION = value2; function _isNativeReflectConstruct_63925() { // fn#63925, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:178, offset: 0x01b96895, 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_63925_isNativeReflectConstruct = function() { return !!result; })(); } function markInteractionByNonceCompleted(a0) { // fn#63928, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:466, offset: 0x01b968f3, size: 65 bytes, params: 2, frame: 13 if (a0 == null) { return false; } const property = env0_13[a0]; if (property == null) { return false; } if (property.onSuccess != null) { property.onSuccess(); } deleteNonce(a0); } function deleteNonce(a0) { // fn#63929, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:609, offset: 0x01b96934, size: 124 bytes, params: 2, frame: 14 var property; var property2; var binding; var object; if (env0_18[a0] == null) { property = env0_13[a0]; delete env0_13[a0]; property2 = env0_15[a0]; if (property2 != null) { delete env0_14[property2]; } delete env0_15[a0]; binding = env0_18; object = {}; object.insertedAt = global.Date.now(); object.nonce = a0; object.messageId = property2; object.interaction = property; binding[a0] = object; } else { delete env0_18[a0]; } } function _fun63930(a0) { // fn#63930, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:801, offset: 0x01b969b0, size: 216 bytes, params: 2, frame: 16 const InteractionStore2 = InteractionStore; Inherits(InteractionStore2, a0); return CreateClass(InteractionStore2, [{key: 'initialize', value: function() { this.waitFor(AuthenticationStore, ChannelStore); }}, {key: 'getInteraction', value: value_63933}, {key: 'getMessageInteractionStates', value: value_63934}, {key: 'canQueueInteraction', value: value_63935}, {key: 'getIFrameModalApplicationId', value: value_63936}, {key: 'getIFrameModalKey', value: value_63937}, {key: 'getInteractionDebugContext', value: value_63938}]); function InteractionStore() { // fn#63931, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:813, offset: 0x00e07435, size: 113 bytes, params: 1, frame: 20 const value = environment.__proto__; env1_3(this, InteractionStore); const value3 = env1_6(InteractionStore); return env1_5(this, _isNativeReflectConstruct_63925() ? global.Reflect.construct(value3, arguments, env1_6(this).constructor) : value3.apply(this, arguments)); } function value_63933({id}) { // fn#63933, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:1170, offset: 0x01b96aa6, size: 38 bytes, params: 2, frame: 4 const property = env1_14[id]; return property != null ? env1_13[property] : null; } function value_63934() { // fn#63934, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:1264, offset: 0x01b96acc, size: 111 bytes, params: 1, frame: 21 var r2; var property; var value4; var property2; var state; var value5; const object = {}; const Object = global.Object; const value2 = Object.entries(env1_13); let length = value2.length; const value3 = 0; if (value3 < length) { r2 = value3; while (true) { property = value2[r2]; value4 = env1_8(property, 2); property = value4[value3]; property2 = value4[1]; property = env1_15[property]; if (property != null) { state = property2.state; object[property] = state; } value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1; length = value2.length; if (value5 < length) { r2 = value5; continue; } break; } } return object; } function value_63935(a0, a1) { // fn#63935, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:1437, offset: 0x01b96b3b, size: 169 bytes, params: 3, frame: 16 const InteractionState = (InteractionTypesModule).InteractionState; const value = environment.__proto__; const property = env1_14[a0]; let r0 = property != null && env1_13[property] != null && env1_13[property].state !== InteractionState.FAILED; r0 = !r0 ? env1_13[a1] != null && env1_13[a1].state !== InteractionState.FAILED : r0; return !r0; } function value_63936() { // fn#63936, offset: 0x00e07553, size: 9 bytes, params: 1, frame: 1 return env1_17; } function value_63937() { // fn#63937, offset: 0x00df0e94, size: 9 bytes, params: 1, frame: 1 return env1_16; } function value_63938(a0) { // fn#63938, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:1753, offset: 0x01b96be4, size: 93 bytes, params: 2, frame: 7 var value; var property; if (a0 != null) { value = environment.__proto__; property = env1_13[a0]; if (property != null) { return {interaction: property, messageId: env1_15[a0]}; } property = env1_18[a0]; value = undefined; return property != null ? {interaction: property.interaction, messageId: property.messageId} : value; } } } function LOGOUT_63939() { // fn#63939, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:2003, offset: 0x01b96c41, size: 56 bytes, params: 1, frame: 13 env0_13 = {}; env0_14 = {}; env0_15 = {}; env0_18 = {}; global.setInterval(_fun63940, env0_11); function _fun63940() { // fn#63940, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:2058, offset: 0x01b96c79, size: 127 bytes, params: 1, frame: 20 var r2; var property; var value5; var insertedAt; var value6; var value7; const Date = global.Date; const value = Date.now(); const Object = global.Object; const value3 = Object.entries(env1_18); let length = value3.length; const value4 = 0; if (value4 < length) { r2 = value4; while (true) { property = value3[r2]; value5 = env1_8(property, 2); property = value5[value4]; insertedAt = value5[1].insertedAt; value6 = value - insertedAt; if (value6 > env1_12) { delete env1_18[property]; } value7 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1; length = value3.length; if (value7 < length) { r2 = value7; continue; } break; } } } } function INTERACTION_QUEUE({nonce, messageId, data, onCreate, onCancel, onSuccess, onFailure}) { // fn#63941, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:2209, offset: 0x01b96cf8, size: 145 bytes, params: 2, frame: 19 if (messageId != null) { env0_14[messageId] = nonce; env0_15[nonce] = messageId; } const binding = env0_13; const InteractionState = (InteractionTypesModule).InteractionState; const QUEUED = InteractionState.QUEUED; binding[nonce] = {state: QUEUED, data: data, onCreate: onCreate, onCancel: onCancel, onSuccess: onSuccess, onFailure: onFailure}; } function INTERACTION_CREATE({nonce, interactionId}) { // fn#63942, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:2460, offset: 0x01b96d89, size: 145 bytes, params: 2, frame: 17 if (nonce == null) { return false; } const property = env0_13[nonce]; if (property == null) { return false; } const state = property.state; const InteractionState = (InteractionTypesModule).InteractionState; const QUEUED = InteractionState.QUEUED; if (state !== QUEUED) { return false; } const CREATED = InteractionState.CREATED; property.state = CREATED; if (property.onCreate != null) { property.onCreate(interactionId); } } function INTERACTION_FAILURE_63944({nonce, errorCode, errorMessage, status, reasonCode}) { // fn#63944, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:2809, offset: 0x01b96e33, size: 243 bytes, params: 2, frame: 21 var r11; var binding; var object; if (nonce == null) { return false; } const property = env0_13[nonce]; if (property == null) { return false; } if (property.onFailure != null) { property.onFailure(errorCode, errorMessage, status, reasonCode); r11 = status; } const interactionType = property.data.interactionType; const InteractionTypes = (ServerModule).InteractionTypes; const APPLICATION_COMMAND = InteractionTypes.APPLICATION_COMMAND; if (interactionType === APPLICATION_COMMAND) { deleteNonce(nonce); } else { binding = env0_13; object = {}; copyDataProperties(object, property, r11); object['state'] = (require(4629) /* metro dependency 4629: InteractionTypes */).InteractionState.FAILED; object['errorCode'] = errorCode; object['errorMessage'] = errorMessage; binding[nonce] = object; } } function MESSAGE_CREATE_63945({message}) { // fn#63945, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:3173, offset: 0x01b96f26, size: 88 bytes, params: 2, frame: 13 if (message.nonce == null) { return false; } const property = env0_13[message.nonce]; if (property == null) { return false; } if (property.onSuccess != null) { property.onSuccess(); } deleteNonce(message.nonce); } function CHANNEL_SELECT_63946({channelId}) { // fn#63946, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:3348, offset: 0x01b96f7e, size: 171 bytes, params: 2, frame: 21 var r2; var property; var value5; var state; var InteractionState; var FAILED; var value6; if (ChannelStore.getChannel(channelId) == null) { return false; } const Object = global.Object; const value3 = Object.entries(env0_13); let length = value3.length; if (0 < length) { r2 = 0; while (true) { property = value3[r2]; value5 = Module00057(property, 2); property = value5[0]; state = value5[1].state; InteractionState = (require(4629) /* metro dependency 4629: InteractionTypes */).InteractionState; FAILED = InteractionState.FAILED; if (state === FAILED) { deleteNonce(property); } value6 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1; length = value3.length; if (value6 < length) { r2 = value6; continue; } break; } } } function EMBEDDED_ACTIVITY_UPDATE_V2_63951({participants}) { // fn#63951, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:4010, offset: 0x01b97073, size: 246 bytes, params: 2, frame: 18 var r0; var r4; var nonce; var binding; var property; var messageId; var value; const authenticationStoreBinding = AuthenticationStore; const env0_0 = authenticationStoreBinding.getSessionId(); const env0_1 = authenticationStoreBinding.getId(); const value2 = participants.find(_fun63952); if (value2 != null) { nonce = value2.nonce; if (nonce != null) { binding = env0_18; nonce = value2.nonce; property = binding[nonce]; if (property == null) { binding = env0_15; nonce = value2.nonce; property = binding[nonce]; binding = env0_13; nonce = value2.nonce; r0 = binding[nonce]; r4 = property; } else { messageId = property.messageId; r0 = property.interaction; r4 = messageId; } if (r0 != null && r4 != null) { deleteNonce(value2.nonce); if (r4 != null && 'channelId' in r0.data) { value = importDefault(7067) /* metro dependency 7067: MessageActionCreators */; value.deleteMessage(r0.data.channelId, r4, true); } } } } function _fun63952(a0) { // fn#63952, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:4113, offset: 0x01b97169, size: 39 bytes, params: 2, frame: 4 const user_id = a0.user_id; return user_id === env0_1 && a0.session_id === env0_0; } } } global.__d(_fun63924, 8057, [6, 7, 15, 17, 18, 57, 1226, 1379, 672, 4629, 1909, 7067, 566, 694, 2]) /* metro module 8057, dependencies: [6, 7, 15, 17, 18, 57, 1226, 1379, 672, 4629, 1909, 7067, 566, 694, 2] */;