decord/source/modules/channel_text_area/PlaintextResolvers.tsx
github-actions 777dc50a28 chore: update source for alpha 346.3
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4790.js (118.4 MB)
2026-09-10 19:12:31 +00:00

208 lines
7.1 KiB
TypeScript

// Module ID: 9485
// Function ID: 9486
// Name: PlaintextResolvers
// Dependencies: [32, 5509, 5556, 1957, 2012, 2021, 2015, 1979, 4243, 4253, 1371, 1074, 1374, 7737, 4758, 11, 5492, 4257, 4261, 2]
// Exports: resolveApplicationCommandOption
// Module 9485 (PlaintextResolvers)
import SnowflakeUtilsDefault from "SnowflakeUtils" /* 11 */;
import UnicodeEmojisDefault from "UnicodeEmojis" /* 4257 */;
import EmojiUtilsDefault from "EmojiUtils" /* 4261 */;
import useChannelName from "useChannelName" /* 4758 */;
import SlateUtils from "SlateUtils" /* 7737 */;
import _slicedToArray from "module_32" /* 32 */;
import EmojiStore from "EmojiStore" /* 5509 */;
import ActiveJoinedThreadsStore from "ActiveJoinedThreadsStore" /* 5556 */;
import ChannelStore from "ChannelStore" /* 1957 */;
import GuildChannelStore from "GuildChannelStore" /* 2012 */;
import GuildMemberStore from "GuildMemberStore" /* 2021 */;
import GuildRoleStore from "GuildRoleStore" /* 2015 */;
import GuildStore from "GuildStore" /* 1979 */;
import PermissionStore from "PermissionStore" /* 4243 */;
import RelationshipStore from "RelationshipStore" /* 4253 */;
import UserStore from "UserStore" /* 1371 */;
require = fn;
function resolvePlaintextInlineVoid(text, id, id2, arg3) {
let obj = arg3;
if (arg3 == null) {
obj = {};
}
const allowUsers = obj.allowUsers;
const allowRoles = obj.allowRoles;
let first = text[0];
if ("@" === first) {
return (function resolveUserOrRole(arr, id, id2, arg3, arg4) {
let tmp = closure_3(arr.slice(1).split("#", 2), 2);
const first = tmp[0];
closure_1 = tmp3;
guild = null;
if (null != id) {
guild = guild.getGuild(id);
}
if (arg4) {
if (null == tmp3) {
if (null != guild) {
sortedRoles = sortedRoles.getSortedRoles(guild.id);
for (const item10028 of sortedRoles) {
if (first === item10028.name) {
let element = { type: "roleMention", roleId: item10028.id, children: null };
let items = [{ text: "" }];
element.children = items;
obj.return();
return element;
}
}
}
}
}
if (arg3) {
channel = null;
if (null != id2) {
channel = channel.getChannel(id2);
}
if (null == channel) {
return null;
} else {
if (channel.isPrivate()) {
let recipients = channel.recipients;
} else {
members = members.getMembers(id);
recipients = members.map((userId) => userId.userId);
}
const mapped = recipients.map((item) => user.getUser(item));
const found = mapped.filter((username) => {
let tmp = undefined !== username;
if (tmp) {
let str = closure_1;
let flag = {}.requireExact;
if (flag === undefined) {
flag = false;
}
let tmp4 = null != username;
if (tmp4) {
username = username.username;
if (flag) {
let startsWithResult = username === tmp2;
} else {
startsWithResult = username.startsWith(tmp2);
}
if (startsWithResult) {
if (str == null) {
str = "0";
}
startsWithResult = username.discriminator === str;
}
tmp4 = startsWithResult;
}
tmp = tmp4;
}
return tmp;
});
if (1 === found.length) {
const first1 = found[0];
if (closure_18(first, tmp3, first1, { requireExact: true })) {
const element1 = { type: "userMention", userId: first1.id, children: null };
const items1 = [{ text: "" }];
element1.children = items1;
return element1;
}
}
}
}
return null;
})(text, id, id2, tmp, tmp2);
} else if (":" === first) {
const EMOJI_NAME_RE = UnicodeEmojisDefault.EMOJI_NAME_RE;
const match = EMOJI_NAME_RE.exec(text);
let tmp7 = null;
if (null != match) {
const disambiguatedEmojiContext = EmojiStore.getDisambiguatedEmojiContext(id);
const customEmoji = disambiguatedEmojiContext.getCustomEmoji();
let obj4 = customEmoji.get(match[1]);
let channel = null;
if (null != id2) {
channel = ChannelStore.getChannel(id2);
}
tmp7 = null;
if (null != obj4) {
let obj2 = { emoji: obj4, channel, intention: EmojiIntention.CHAT };
tmp7 = null;
if (!tmp4Result.isEmojiFiltered(obj2)) {
let obj3 = { emojiId: obj4.id, name: null, animated: null, jumboable: false };
if (!("require_colons" in obj4)) {
let element = { type: "customEmoji", emoji: null, children: null };
obj3.name = obj4.name;
obj3.animated = true === obj4.animated;
element.emoji = obj3;
obj3 = [];
obj4 = { text: "" };
obj3[0] = obj4;
element.children = obj3;
}
const _HermesInternal = HermesInternal;
const combined = ":" + obj4.name + ":";
}
tmp4Result = EmojiUtilsDefault;
}
}
return tmp7;
} else if ("#" === first) {
return (function resolveChannel(arr, id) {
if (null == id) {
return null;
} else {
if (arr.length > 3) {
if ("\"" === arr[1]) {
textChannelNameDisambiguations = textChannelNameDisambiguations.getTextChannelNameDisambiguations(id);
const num = SnowflakeUtilsDefault.keys(textChannelNameDisambiguations);
num[Symbol.iterator]();
}
useChannelName.unescapeChannelName(arr.slice(2, arr.length - num));
}
const substr = arr.slice(1);
}
})(text, id);
} else {
return null;
}
}
function matchesUser(arg0, arg1, username, requireExact) {
let flag = requireExact.requireExact;
if (flag === undefined) {
flag = false;
}
let tmp = null != username;
if (tmp) {
username = username.username;
if (flag) {
let startsWithResult = username === arg0;
} else {
startsWithResult = username.startsWith(arg0);
}
if (startsWithResult) {
let str = arg1;
if (arg1 == null) {
str = "0";
}
startsWithResult = username.discriminator === str;
}
tmp = startsWithResult;
}
return tmp;
}
let closure_8 = fn(2012).GUILD_SELECTABLE_CHANNELS_KEY;
const Permissions = fn(1074).Permissions;
const EmojiIntention = fn(1374).EmojiIntention;
const size = fn(2);
const result = size.fileFinishedImporting("modules/channel_text_area/PlaintextResolvers.tsx");
export { resolvePlaintextInlineVoid };
export const resolveApplicationCommandOption = function resolveApplicationCommandOption(text, id, id2, arg3) {
const tmp = resolvePlaintextInlineVoid(text, id, id2, arg3);
let voidToOptionValueResult = null;
if (null != tmp) {
voidToOptionValueResult = SlateUtils.voidToOptionValue(tmp);
}
return voidToOptionValueResult;
};