/* Metro module 8357; source: modules/interaction_components/ComponentStateContext.tsx; dependencies: [57, 31, 8057, 3785, 1379, 1945, 4798, 1878, 8358, 33, 1909, 4633, 4629, 566, 8229, 6860, 8360, 8056, 694, 4594, 4627, 2] */ import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */ import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */ import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */ import GuildMemberStore from '../../stores/GuildMemberStore.tsx'; /* Metro dependency 1945 */ import LurkingStore from '../lurker_mode/LurkingStore.tsx'; /* Metro dependency 3785 */ import UseMountEffect from '../../hooks/useMountEffect.tsx'; /* Metro dependency 4594 */ import GuildVerificationStore from '../../stores/GuildVerificationStore.tsx'; /* Metro dependency 4798 */ import InteractionStore from '../interactions/InteractionStore.tsx'; /* Metro dependency 8057 */ import LocalInteractionComponentStateStore from './LocalInteractionComponentStateStore.tsx'; /* Metro dependency 8358 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */ import * as JsxRuntimeModule from '../../by-id/module-00033-JsxRuntime.js'; /* Metro dependency 33 */ import * as FluxModule from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */ import * as InteractionComponentUtilsModule from './InteractionComponentUtils.tsx'; /* Metro dependency 4627 */ import * as InteractionComponentTypesModule from './InteractionComponentTypes.tsx'; /* Metro dependency 4633 */ import * as ThreadHooksModule from '../threads/ThreadHooks.tsx'; /* Metro dependency 6860 */ import * as UseUserCommunicationDisabledModule from '../guild_communication_disabled/useUserCommunicationDisabled.tsx'; /* Metro dependency 8229 */ function _fun66523(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#66523, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:6, offset: 0x01bffa12, size: 439 bytes, params: 8, frame: 20 let env0_0 = require; const getApplicationWidgetContainerId = function({applicationId}) { return 'app-widget-' + applicationId; }; const getParentsNotSupported = function(a0) { var env0_0 = 'ApplicationWidget'; return _fun66540; }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const getActionComponentState2 = getActionComponentState; const useShouldDisableInteractiveComponents2 = useShouldDisableInteractiveComponents; const env0_16 = ReactModule.createContext(null); (FileImportTrackerModule).fileFinishedImporting('modules/interaction_components/ComponentStateContext.tsx'); exports.getActionComponentState = getActionComponentState2; exports.useShouldDisableInteractiveComponents = useShouldDisableInteractiveComponents2; exports.ComponentStateContextProvider = ComponentStateContextProvider; exports.useComponentState = useComponentState; exports.useComponentStateContext = useComponentStateContext; exports.useComponentContainerId = useComponentContainerId; exports.useComponentError = useComponentError; function useComponentValidatorState(a0, a1) { // fn#66525, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1888, offset: 0x01bffbeb, size: 184 bytes, params: 3, frame: 18 const env0_0 = a0; const env0_1 = a1; const value2 = env0_4.useContext(env0_16); const value3 = env0_4.useCallback(_fun66526, [a0, value2]); env0_4.useEffect(_fun66528, [value2.validators, value3, a1, a0.id]); const validationErrors = value2.validationErrors; const value = null; const r3 = value == validationErrors ? undefined : validationErrors[a0.id]; return {error: value != r3 ? r3 : value, validate: value3}; function _fun66526(a0) { // fn#66526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1972, offset: 0x01bffca3, size: 117 bytes, params: 2, frame: 18 var environment; let value = environment.__proto__; value = importDefault(8360) /* metro dependency 8360: validateComponent */; value = value(env0_0, a0, env0_2.modal != null ? 'modal' : 'message'); if (env0_2.setValidationErrors != null) { env0_2.setValidationErrors(_fun66527); } return value == null; function _fun66527(a0) { // fn#66527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2087, offset: 0x01bffd18, size: 38 bytes, params: 2, frame: 12 const object = {}; copyDataProperties(object, a0, undefined); object[env1_0.id] = env0_0; return object; } } function _fun66528() { // fn#66528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2147, offset: 0x01bffd3e, size: 51 bytes, params: 1, frame: 12 const currentValidate2 = currentValidate; const validators = env0_2.validators; if (validators != null) { validators.add(currentValidate2); } return _fun66530; function currentValidate() { // fn#66529, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2174, offset: 0x01bffd71, size: 20 bytes, params: 1, frame: 11 return env1_3(require); } function _fun66530() { // fn#66530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2237, offset: 0x01bffd85, size: 40 bytes, params: 1, frame: 11 const validators = env1_2.validators; if (validators != null) { validators.delete(currentValidate); } } } } function useComponentStateForMessage(a0, a1, a2) { // fn#66531, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2406, offset: 0x01bffdad, size: 335 bytes, params: 4, frame: 25 let value = a1; const env0_0 = a0; const env0_1 = a2; const interactionComponentState = (FluxModule).useStateFromStores([LocalInteractionComponentStateStore], _fun66532); const value3 = (FluxModule).useStateFromStores([InteractionStore], _fun66533, [a0]); const r3 = useShouldDisableInteractiveComponents(a0.channel_id) || value; value = useComponentValidatorState(a2, interactionComponentState); const error = value.error; const validate = value.validate; const r12 = a0.applicationId ?? a0.author.id; object = {state: interactionComponentState}; object.executeStateUpdate = env0_4.useCallback(_fun66534, [a0.channel_id, a0.flags, a0.id, a2.customId, a2.type, a2.id, r12, validate]); object.isDisabled = r3 && isInteractionComponent(a2); object.visualState = getActionComponentState(value3, a2, r3); object.error = error; return object; function _fun66532() { // fn#66532, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2491, offset: 0x01bffefc, size: 42 bytes, params: 1, frame: 13 return LocalInteractionComponentStateStore.getInteractionComponentState(env0_0.id, importDefault.id); } function _fun66533() { // fn#66533, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2574, offset: 0x01bfff26, size: 27 bytes, params: 1, frame: 11 return InteractionStore.getInteraction(env0_0); } function _fun66534(a0) { // fn#66534, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2809, offset: 0x01bfff41, size: 205 bytes, params: 2, frame: 17 var value2; var channelStoreBinding; var value3; var moduleValue; var executeMessageComponentInteraction; var object; var binding; var id; if (validate(a0)) { value2 = environment.__proto__; channelStoreBinding = ChannelStore; value3 = channelStoreBinding.getChannel(env0_0.channel_id); if (value3 != null && importDefault.customId != null) { moduleValue = require(8056) /* metro dependency 8056: InteractionUtils */; executeMessageComponentInteraction = moduleValue.executeMessageComponentInteraction; object = {}; object.componentType = importDefault.type; binding = env0_0; id = binding.id; object.messageId = id; object.messageFlags = binding.flags; object.customId = importDefault.customId; id = importDefault.id; object.componentId = id; object.applicationId = Module00057; id = value3.id; object.channelId = id; object.guildId = value3.guild_id; object.localState = a0; Reflect.apply(executeMessageComponentInteraction, moduleValue, [object]); } return true; } return false; } } function useComponentStateForModal(a0, a1, a2) { // fn#66535, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:3255, offset: 0x01c0000e, size: 303 bytes, params: 4, frame: 22 const env0_0 = a0; const env0_1 = a1; const env0_2 = a2; const interactionComponentState = (FluxModule).useStateFromStores([LocalInteractionComponentStateStore], _fun66536); const property = interactionComponentState(validate2.useState(a2), 1)[0]; const {error, validate} = useComponentValidatorState(a1, interactionComponentState); var validate2 = validate; const value5 = validate2.useCallback(_fun66537, [a0.customId, a1.id, validate]); (UseMountEffect)(_fun66538); object = {}; const value6 = null; const r6 = value6 == interactionComponentState ? property : interactionComponentState; object.state = value6 != r6 ? r6 : value6; object.executeStateUpdate = value5; object.isDisabled = false; const ActionComponentState = (InteractionComponentTypesModule).ActionComponentState; const NORMAL = ActionComponentState.NORMAL; object.visualState = NORMAL; object.error = error; return object; function _fun66536() { // fn#66536, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:3338, offset: 0x01c0013d, size: 43 bytes, params: 1, frame: 13 return LocalInteractionComponentStateStore.getInteractionComponentState(env0_0.customId, require.id); } function _fun66537(a0) { // fn#66537, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:3494, offset: 0x01c00168, size: 112 bytes, params: 2, frame: 16 var r0; let value = a0 == null; if (value) { r0 = value; } else { value = environment.__proto__; value = importDefault(694) /* metro dependency 694: Dispatcher */; value.dispatch({type: 'SET_INTERACTION_COMPONENT_STATE', rootContainerId: env0_0.customId, componentId: require.id, state: a0}); value = !!validate(a0); r0 = value; } return r0; } function _fun66538() { // fn#66538, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:3666, offset: 0x01c001d8, size: 32 bytes, params: 1, frame: 11 if (interactionComponentState == null) { env0_5(importDefault); } } } function getParentsNotSupported(a0) { // fn#66539, offset: 0x01c001f8, size: 19 bytes, params: 2, frame: 2 return _fun66540; function _fun66540() { // fn#66540, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:3858, offset: 0x01c0020b, size: 64 bytes, params: 1, frame: 14 const Error = global.Error; const value = '' + env0_0 + ' does not support parents'; const value2 = Object.create(Error.prototype, {constructor: {value: Error}}); const error = new Error(); throw error instanceof Object ? error : value2; } } function isInteractionComponent(a0) { // fn#66541, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:223, offset: 0x01c0024b, size: 336 bytes, params: 2, frame: 15 const type = a0.type; const ComponentType = (require(1909) /* metro dependency 1909: Server */).ComponentType; const BUTTON = ComponentType.BUTTON; if (BUTTON === type) { return a0.style !== (require(1909) /* metro dependency 1909: Server */).ButtonStyle.LINK; } const STRING_SELECT = ComponentType.STRING_SELECT; if (STRING_SELECT === type) { return true; } const USER_SELECT = ComponentType.USER_SELECT; if (USER_SELECT === type) { return true; } const ROLE_SELECT = ComponentType.ROLE_SELECT; if (ROLE_SELECT === type) { return true; } const MENTIONABLE_SELECT = ComponentType.MENTIONABLE_SELECT; if (MENTIONABLE_SELECT === type) { return true; } const CHANNEL_SELECT = ComponentType.CHANNEL_SELECT; if (CHANNEL_SELECT === type) { return true; } const ACTION_ROW = ComponentType.ACTION_ROW; if (ACTION_ROW !== type) { ComponentType.TEXT_INPUT; } return false; } function getActionComponentState(a0, a1) { // fn#66542, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:662, offset: 0x01c0039b, size: 299 bytes, params: 3, frame: 20 const value = a2; let r2 = value !== undefined ? value : false; const ActionComponentState = (InteractionComponentTypesModule).ActionComponentState; const NORMAL = ActionComponentState.NORMAL; let r0 = a0 != null && a0.state !== (require(4629) /* metro dependency 4629: InteractionTypes */).InteractionState.FAILED ? a0.data.interactionType !== (require(1909) /* metro dependency 1909: Server */).InteractionTypes.MESSAGE_COMPONENT ? isInteractionComponent(a1) ? ActionComponentState.DISABLED : NORMAL : a0.data.componentId === a1.id ? ActionComponentState.LOADING : isInteractionComponent(a1) ? ActionComponentState.DISABLED : NORMAL : NORMAL; r2 = r2 && isInteractionComponent(a1); r0 = r2 ? ActionComponentState.DISABLED : r0; return r0; } function useShouldDisableInteractiveComponents(a0) { // fn#66543, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1186, offset: 0x01c004c6, size: 379 bytes, params: 2, frame: 23 var r4; var r2; const channel = ChannelStore.getChannel(a0); const value3 = undefined; const value4 = (FluxModule).useStateFromStores([GuildVerificationStore], _fun66544, [channel]); const value5 = (FluxModule).useStateFromStores([LurkingStore], _fun66545, [channel]); const value6 = (FluxModule).useStateFromStores([GuildMemberStore, UserStore], _fun66546); const useCurrentUserCommunicationDisabled = UseUserCommunicationDisabledModule.useCurrentUserCommunicationDisabled; const property = Module00057(Reflect.apply(useCurrentUserCommunicationDisabled, UseUserCommunicationDisabledModule, [channel == null ? value3 : channel.guild_id]), 2)[1]; let value = ThreadHooksModule; value = value.useIsThreadModerator(channel); const value9 = (ThreadHooksModule).useCanUnarchiveThread(channel); let r0 = value4 ? value5 : !value4; r0 = !r0 ? value6 : r0; if (!r0) { r4 = channel != null && channel.isLockedThread(); r4 = r4 && !value; r0 = r4; } if (!r0) { r2 = channel != null && channel.isArchivedThread(); r2 = r2 && !value9; r0 = r2; } r0 = !r0 ? property : r0; return !!r0; function _fun66544() { // fn#66544, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1247, offset: 0x01c00641, size: 63 bytes, params: 1, frame: 12 return env0_0?.guild_id == null || GuildVerificationStore.canChatInGuild(env0_0.guild_id); } function _fun66545() { // fn#66545, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1356, offset: 0x01c00680, size: 63 bytes, params: 1, frame: 12 return env0_0?.guild_id != null && LurkingStore.isLurking(env0_0.guild_id); } function _fun66546() { // fn#66546, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1462, offset: 0x01c006bf, size: 134 bytes, params: 1, frame: 18 const value = environment.__proto__; const currentUser = UserStore.getCurrentUser(); const value4 = null; const value5 = undefined; const r1 = value4 != (value4 == env0_0 ? value5 : env0_0.guild_id) && value4 != currentUser ? value4 == GuildMemberStore.getMember(value4 == env0_0 ? value5 : env0_0.guild_id, currentUser.id) ? value5 : GuildMemberStore.getMember(value4 == env0_0 ? value5 : env0_0.guild_id, currentUser.id).isPending : value4; return value4 != r1 && r1; } } function ComponentStateContextProvider({children, message, modal, applicationWidget, validators, validationErrors, setValidationErrors, shouldDisableInteractiveComponents}) { // fn#66547, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:4192, offset: 0x01c00745, size: 176 bytes, params: 2, frame: 23 const validationErrors2 = validationErrors; shouldDisableInteractiveComponents = !(shouldDisableInteractiveComponents === undefined) && shouldDisableInteractiveComponents; const value2 = validationErrors2.useMemo(_fun66548, [message, modal, applicationWidget, shouldDisableInteractiveComponents, validators, validationErrors, setValidationErrors]); const Provider = env0_16.Provider; return ( {children} ); function _fun66548() { // fn#66548, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:4394, offset: 0x01c007f5, size: 341 bytes, params: 1, frame: 19 var environment; var object; var value2; var getApplicationWidgetContainerIdBinding; var value3; var bind; var value4; let messageBinding = message; if (messageBinding != null) { value4 = environment.__proto__; bind = useComponentStateForMessage.bind; messageBinding = message; return {useComponentState: Reflect.apply(bind, useComponentStateForMessage, [null, messageBinding, shouldDisableInteractiveComponents]), channelId: messageBinding.channel_id, containerId: messageBinding.id, message: messageBinding, validators: validators, getParents: getParents_66549}; } let modalBinding = modal; if (modalBinding != null) { value3 = environment.__proto__; bind = useComponentStateForModal.bind; modalBinding = modal; return {useComponentState: Reflect.apply(bind, useComponentStateForModal, [null, modalBinding]), channelId: modalBinding.channelId, containerId: modalBinding.customId, modal: modalBinding, validators: validators, validationErrors: validationErrors, setValidationErrors: setValidationErrors, getParents: getParents_66550}; } let applicationWidgetBinding = applicationWidget; if (applicationWidgetBinding != null) { object = {}; object.useComponentState = useComponentState_66551; value2 = environment.__proto__; getApplicationWidgetContainerIdBinding = getApplicationWidgetContainerId; applicationWidgetBinding = applicationWidget; object.containerId = getApplicationWidgetContainerIdBinding(applicationWidgetBinding); object.applicationWidget = applicationWidgetBinding; object.validators = validators; object.validationErrors = validationErrors; object.setValidationErrors = setValidationErrors; object.getParents = getParentsNotSupported('ApplicationWidget'); return object; } const Error = global.Error; throw new Error('ComponentStateContextProvider requires at least one of message, modal, or applicationWidget'); function getParents_66549(a0) { // fn#66549, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:4552, offset: 0x01c0094a, size: 55 bytes, params: 2, frame: 13 const value = environment.__proto__.__proto__; return (InteractionComponentUtilsModule).getParents(message.components, a0); } function getParents_66550(a0) { // fn#66550, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:4785, offset: 0x01c00981, size: 55 bytes, params: 2, frame: 13 const value = environment.__proto__.__proto__; return (InteractionComponentUtilsModule).getParents(modal.components, a0); } function useComponentState_66551() { // fn#66551, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:4884, offset: 0x01c009b8, size: 64 bytes, params: 1, frame: 14 const Error = global.Error; const value = '' + env0_0 + ' does not support state'; const value2 = Object.create(Error.prototype, {constructor: {value: Error}}); const error = new Error(); throw error instanceof Object ? error : value2; } } } function useComponentState(a0, a1) { // fn#66552, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:5314, offset: 0x01c009f8, size: 42 bytes, params: 3, frame: 13 return env0_4.useContext(env0_16).useComponentState(a0, a1); } function useComponentStateContext() { // fn#66553, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:5420, offset: 0x01c00a22, size: 24 bytes, params: 1, frame: 11 return env0_4.useContext(env0_16); } function useComponentContainerId() { // fn#66554, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:5506, offset: 0x01c00a3a, size: 30 bytes, params: 1, frame: 11 const binding = env0_4; const useContext = binding.useContext; return Reflect.apply(useContext, binding, [env0_16]).containerId; } function useComponentError(a0) { // fn#66555, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:5597, offset: 0x01c00a58, size: 65 bytes, params: 2, frame: 12 const binding = env0_4; const useContext = binding.useContext; const validationErrors = Reflect.apply(useContext, binding, [env0_16]).validationErrors; const value = null; const r1 = value == validationErrors ? undefined : validationErrors[a0.id]; return value != r1 ? r1 : value; } } global.__d(_fun66523, 8357, [57, 31, 8057, 3785, 1379, 1945, 4798, 1878, 8358, 33, 1909, 4633, 4629, 566, 8229, 6860, 8360, 8056, 694, 4594, 4627, 2]) /* metro module 8357, dependencies: [57, 31, 8057, 3785, 1379, 1945, 4798, 1878, 8358, 33, 1909, 4633, 4629, 566, 8229, 6860, 8360, 8056, 694, 4594, 4627, 2] */;