// Metro module 8023 (f8024). import EmojiStore from "../emojis/EmojiStore"; import ActiveJoinedThreadsStore from "../threads/ActiveJoinedThreadsStore"; import ChannelStore from "../../stores/ChannelStore"; import GuildChannelStore, { GUILD_SELECTABLE_CHANNELS_KEY } from "../../stores/GuildChannelStore"; import GuildMemberStore from "../../stores/GuildMemberStore"; import GuildRoleStore from "../../stores/GuildRoleStore"; import GuildStore from "../../stores/GuildStore"; import PermissionStore from "../../stores/PermissionStore"; import RelationshipStore from "../../stores/RelationshipStore"; import UserStore from "../../stores/UserStore"; import { Permissions } from "../../Constants"; import { EmojiIntention } from "../emojis/EmojiConstants"; import { voidToOptionValue } from "./slate/SlateUtils"; import { unescapeChannelName, computeChannelName } from "../channel/useChannelName"; import SnowflakeUtils from "../../utils/SnowflakeUtils"; import { COMMAND_SUPPORTED_CHANNEL_TYPE_KEYS } from "../../utils/AutocompleteUtils"; import UnicodeEmojis from "../emojis/UnicodeEmojis"; import EmojiUtils from "../../utils/EmojiUtils"; let matchesUser; const resolvePlaintextInlineVoid = function resolvePlaintextInlineVoid(a0, a1, a2, a3) { const r4 = a3 == null ? {} : a3; const { allowUsers = true, allowRoles = true } = r4; const r11 = a0[0]; if (r11 === "@") { return (function resolveUserOrRole(a0, a1, a2, a3, a4) { const [r32, r33] = a0.slice(1).split("#", 2); let c26081_0 = r32; let c26081_1 = r33; const r35 = a1 != null ? GuildStore.getGuild(a1) : null; if (a4 && r33 == null && r35 != null) { for (const item of GuildRoleStore.getSortedRoles(r35.id)) { if (r32 !== item.name) { continue; } return { type: "roleMention", roleId: item.id, children: [{ text: "" }] }; } } if (a3) { const r58 = a2 != null ? ChannelStore.getChannel(a2) : null; if (r58 == null) { return null; } const r74 = (r58.isPrivate() ? r58.recipients : GuildMemberStore.getMembers(a1).map((item) => item.userId)).map((item) => UserStore.getUser(item)).filter((item) => { let r2 = item !== void 0; if (r2) { let r6 = c26081_1; let requireExact = ({}).requireExact; if (requireExact === void 0) { requireExact = false; } let r11 = item != null; if (r11) { const username = item.username; let r13 = requireExact ? username === c26081_0 : username.startsWith(c26081_0); if (r13) { const discriminator = item.discriminator; if (r6 == null) { r6 = "0"; } r13 = discriminator === r6; } r11 = r13; } r2 = r11; } return r2; }); if (r74.length === 1) { const r76 = r74[0]; if (matchesUser(r32, r33, r76, { requireExact: true })) { return { type: "userMention", userId: r76.id, children: [{ text: "" }] }; } } } return null; })(a0, a1, a2, allowUsers, allowRoles); } if (r11 === ":") { const r34 = UnicodeEmojis.EMOJI_NAME_RE.exec(a0); const r3 = r34 == null; let r35 = null; if (!r3) { const r15 = r34[1]; const emoji = EmojiStore.getDisambiguatedEmojiContext(a1).getCustomEmoji().get(r15); const channel = a2 != null ? ChannelStore.getChannel(a2) : null; r35 = emoji != null ? EmojiUtils.isEmojiFiltered({ emoji, channel, intention: EmojiIntention.CHAT }) ? null : { type: "customEmoji", emoji: { emojiId: emoji.id, name: "require_colons" in emoji && emoji.require_colons ? `:${emoji.name}:` : emoji.name, animated: emoji.animated === true, jumboable: false }, children: [{ text: "" }] } : null; } return r35; } if (r11 === "#") { return (function resolveChannel(a0, a1) { let r116, r167; if (a1 == null) { return null; } const r4 = a0.length > 3 && (a0[1] === "\"" && a0[a0.length - 1] === "\"") ? unescapeChannelName(a0.slice(2, a0.length - 1)) : a0.slice(1); const textChannelNameDisambiguations = GuildChannelStore.getTextChannelNameDisambiguations(a1); for (const item of SnowflakeUtils.keys(textChannelNameDisambiguations)) { const channelId = item; if (textChannelNameDisambiguations[item].name !== r4) { continue; } return { type: "channelMention", channelId, children: [{ text: "" }] }; } for (const item2 of COMMAND_SUPPORTED_CHANNEL_TYPE_KEYS) { L25: { if (item2 === GUILD_SELECTABLE_CHANNELS_KEY) { continue; } for (const item3 of GuildChannelStore.getChannels(a1)[item2]) { const channel = item3.channel; if (computeChannelName(channel, UserStore, RelationshipStore) !== r4) { continue; } if (channel.isCategory() && !PermissionStore.can(Permissions.VIEW_CHANNEL, channel)) { continue; } r116 = { type: "channelMention", channelId: channel.id, children: [{ text: "" }] }; break L25; } continue; } return r116; } const activeJoinedThreadsForGuild = ActiveJoinedThreadsStore.getActiveJoinedThreadsForGuild(a1); for (const item4 of SnowflakeUtils.keys(activeJoinedThreadsForGuild)) { done150: { for (const item5 of SnowflakeUtils.keys(activeJoinedThreadsForGuild[item4])) { const channel2 = activeJoinedThreadsForGuild[item4][item5].channel; if (computeChannelName(channel2, UserStore, RelationshipStore) !== r4) { continue; } r167 = { type: "channelMention", channelId: channel2.id, children: [{ text: "" }] }; break done150; } continue; } return r167; } return null; })(a0, a1); } return null; }; matchesUser = function matchesUser(a0, a1, a2) { let requireExact = arguments[3].requireExact; if (requireExact === void 0) { requireExact = false; } let r8 = a2 != null; if (r8) { const username = a2.username; let r10 = requireExact ? username === a0 : username.startsWith(a0); if (r10) { let r11 = a1; const discriminator = a2.discriminator; if (a1 == null) { r11 = "0"; } r10 = discriminator === r11; } r8 = r10; } return r8; }; export { resolvePlaintextInlineVoid }; export function resolveApplicationCommandOption(a0, a1, a2, a3) { const r5 = resolvePlaintextInlineVoid(a0, a1, a2, a3); return r5 != null ? voidToOptionValue(r5) : null; }