// Metro module 1934 (f1935). import GuildRoleStore from "../../stores/GuildRoleStore"; import GuildStore from "../../stores/GuildStore"; import { GuildSettingsSections } from "../../Constants"; import { ChannelNotificationSettingsFlags } from "../user_settings/UserSettingsConstants"; import SnowflakeUtils from "../../utils/SnowflakeUtils"; import { ImpersonateType } from "./ImpersonateTypes"; import * as _Module1384 from "../../_bundle/Module1384"; import Module589 from "../../_bundle/Module589"; import { isPlainObjectEmpty } from "../../utils/FunctionUtils"; import Dispatcher from "../../Dispatcher"; let c1620_8 = {}; class ImpersonateStore extends Module589.Store { static displayName = "ImpersonateStore"; initialize() { this.waitFor(GuildStore, GuildRoleStore); } hasViewingRoles() { return !isPlainObjectEmpty(c1620_8); } isViewingRoles(a0) { return a0 != null && c1620_8[a0] != null; } getViewingRoles(a0) { return c1620_8[a0]?.roles; } getViewingRolesTimestamp(a0) { return a0 != null ? c1620_8[a0]?.timestamp : null; } getData(a0) { return c1620_8[a0]; } isFullServerPreview(a0) { return c1620_8[a0]?.type === ImpersonateType.NEW_MEMBER; } isOptInEnabled(a0) { const r6 = c1620_8[a0]; return r6 != null && r6.type === ImpersonateType.NEW_MEMBER && r6.optInEnabled; } isOnboardingEnabled(a0) { const r6 = c1620_8[a0]; return r6 != null && r6.type === ImpersonateType.NEW_MEMBER && r6.onboardingEnabled; } getViewingChannels(a0) { const r7 = c1620_8[a0]; return r7 == null ? null : r7.type === ImpersonateType.NEW_MEMBER ? r7.optInChannels : null; } getOnboardingResponses(a0) { const r7 = c1620_8[a0]; return r7 == null ? null : r7.type === ImpersonateType.NEW_MEMBER ? r7.onboardingResponses : null; } getMemberOptions(a0) { const r7 = c1620_8[a0]; return r7 == null ? null : r7.type === ImpersonateType.NEW_MEMBER ? r7.memberOptions : null; } isChannelOptedIn(a0, a1) { const viewingChannels = this.getViewingChannels(a0); return viewingChannels != null && viewingChannels.has(a1); } isViewingServerShop(a0) { return a0 != null && c1620_8[a0]?.type === ImpersonateType.SERVER_SHOP; } getImpersonateType(a0) { if (a0 == null) { return null; } const r5 = c1620_8[a0]; return r5 == null ? null : r5.type; } getBackNavigationSection(a0) { if (a0 == null) { return GuildSettingsSections.ROLES; } const r7 = c1620_8[a0]; if (r7 == null) { return GuildSettingsSections.ROLES; } const type = r7.type; if (ImpersonateType.ROLES !== type && ImpersonateType.SERVER_SHOP !== type) { if (ImpersonateType.NEW_MEMBER === type) { return GuildSettingsSections.ONBOARDING; } return GuildSettingsSections.ROLES; } return r7.returnToSection; } } const impersonateStore = new ImpersonateStore(Dispatcher, { IMPERSONATE_UPDATE: function handleImpersonateUpdate({ guildId: guildId2, data }) { delete data.roles[SnowflakeUtils.castGuildIdAsEveryoneGuildRoleId(guildId2)]; c1620_8[guildId2] = { ...data, timestamp: Date.now() }; }, IMPERSONATE_STOP: function handleImpersonateStop({ guildId: guildId2 }) { if (c1620_8[guildId2] == null) { return false; } delete c1620_8[guildId2]; }, GUILD_ROLE_DELETE: function handleGuildRoleDelete({ guildId: guildId2, roleId }) { if (c1620_8[guildId2] == null) { return false; } delete c1620_8[guildId2].roles[roleId]; }, USER_GUILD_SETTINGS_CHANNEL_UPDATE_BULK: function handleUserGuildSettingsChannelUpdateBulk({ guildId: guildId2, overrides }) { let c13354_1; c13354_1 = void 0; if (guildId2 != null && c1620_8[guildId2] != null) { const r13 = c1620_8[guildId2]; if (r13 != null && r13.type === ImpersonateType.NEW_MEMBER) { let optInChannels = r13.optInChannels; if (optInChannels == null) { optInChannels = new Set(); } c13354_1 = optInChannels; SnowflakeUtils.keys(overrides).forEach((item) => { let flags = overrides[item].flags; if (flags == null) { flags = 0; } const hasFlag = _Module1384.hasFlag(flags, ChannelNotificationSettingsFlags.OPT_IN_ENABLED); if (hasFlag) { c13354_1.add(item); } else { c13354_1.delete(item); } }); r13.optInChannels = optInChannels; return true; } return false; } return false; }, GUILD_ONBOARDING_SELECT_OPTION: function handleOptionSelect({ guildId: guildId2, optionId, selected, removedOptionIds }) { let c13355_0; c13355_0 = void 0; if (guildId2 != null && c1620_8[guildId2] != null) { const r14 = c1620_8[guildId2]; if (r14 != null && r14.type === ImpersonateType.NEW_MEMBER) { let onboardingResponses = r14.onboardingResponses; if (onboardingResponses == null) { onboardingResponses = new Set(); } c13355_0 = onboardingResponses; if (removedOptionIds != null && removedOptionIds.length > 0) { removedOptionIds.forEach((removedOptionId) => c13355_0.delete(removedOptionId)); } if (selected) { onboardingResponses.add(optionId); } else { onboardingResponses.delete(optionId); } r14.onboardingResponses = onboardingResponses; return true; } return false; } return false; }, GUILD_MEMBER_UPDATE_LOCAL: function handleGuildMemberUpdateLocal({ guildId, roles, flags }) { if (guildId == null) { return false; } const r11 = c1620_8[guildId]; let r0 = r11 != null; if (r0) { if (roles != null) { r11.roles = roles.reduce((acc, a1) => { const role = GuildRoleStore.getRole(guildId, a1); if (role != null) { acc[a1] = role; } return acc; }, {}); } const r1 = flags != null && r11.type === ImpersonateType.NEW_MEMBER; r0 = true; if (r1) { r11.memberOptions.flags = flags; r0 = true; } } return r0; } }); export default impersonateStore;