decord/source/modules/chat_input/native/ChatInputAppCommandManager.tsx

283 lines
13 KiB
TypeScript
Raw Normal View History

// Module ID: 12435
// Function ID: 12436
// Name: ChatInputAppCommandManager
// Dependencies: [32, 19, 7793, 7794, 1916, 5122, 1371, 5014, 4574, 576, 12022, 12, 7323, 504, 5125, 12023, 12021, 9448, 1894, 12436, 2]
2026-07-20 16:05:17 +00:00
// Module 12435 (ChatInputAppCommandManager)
import nativeDefault from "native" /* 576 */;
import useGameProfileObscured from "useGameProfileObscured" /* 5125 */;
import ChatInputCommandOptionParser from "ChatInputCommandOptionParser" /* 12021 */;
import ApplicationCommandManagerDefault from "ApplicationCommandManager" /* 12436 */;
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
import ApplicationCommandAutocompleteStore from "ApplicationCommandAutocompleteStore" /* 7793 */;
import ApplicationCommandStore from "ApplicationCommandStore" /* 7794 */;
import GameStore from "GameStore" /* 1916 */;
import GameAutocompleteStore from "GameAutocompleteStore" /* 5122 */;
import UserStore from "UserStore" /* 1371 */;
2026-07-23 10:11:24 +00:00
require = fn;
2026-07-24 07:16:23 +00:00
function areResolvedGamesEqual(size, size2) {
if (size === size2) {
return true;
} else {
if (null != size) {
if (null != size2) {
if (size.size === size2.size) {
2026-07-29 08:29:29 +00:00
const keys = size.keys();
for (const item10011 of keys) {
if (arg1.has(item10011)) {
continue;
} else {
obj.return();
let flag = false;
return false;
2026-07-24 07:16:23 +00:00
}
}
return true;
}
}
}
return false;
}
}
const ChannelAutocompleteConstants = fn(5014);
({ extractGameMentionIds: closure_11, GAME_MENTION_RAW_RE_GLOBAL: closure_12, GAME_MENTION_SENTINEL: map1 } = ChannelAutocompleteConstants);
const createStyles = fn(4574);
let obj = { commandOption: { backgroundColor: nativeDefault.colors.KEYWORD_HIGHLIGHT_BACKGROUND, color: nativeDefault.colors.TEXT_DEFAULT, borderRadius: nativeDefault.radii.xs, fontSize: 14 }, commandErrorOption: null, gameMention: null, timestampMention: null, autocomplete: null };
let obj3 = { backgroundColor: nativeDefault.colors.KEYWORD_HIGHLIGHT_BACKGROUND, color: nativeDefault.colors.TEXT_DEFAULT, borderRadius: nativeDefault.radii.xs, fontSize: 14 };
obj.commandErrorOption = { backgroundColor: nativeDefault.colors.KEYWORD_HIGHLIGHT_BACKGROUND, color: nativeDefault.colors.TEXT_FEEDBACK_CRITICAL, borderRadius: nativeDefault.radii.xs, fontSize: 14 };
let obj4 = { backgroundColor: nativeDefault.colors.KEYWORD_HIGHLIGHT_BACKGROUND, color: nativeDefault.colors.TEXT_FEEDBACK_CRITICAL, borderRadius: nativeDefault.radii.xs, fontSize: 14 };
obj.gameMention = { backgroundColor: nativeDefault.colors.MENTION_BACKGROUND, color: nativeDefault.colors.MENTION_FOREGROUND, borderRadius: nativeDefault.radii.xs, fontSize: 14, fontWeight: "bold" };
const obj5 = { backgroundColor: nativeDefault.colors.MENTION_BACKGROUND, color: nativeDefault.colors.MENTION_FOREGROUND, borderRadius: nativeDefault.radii.xs, fontSize: 14, fontWeight: "bold" };
obj.timestampMention = { backgroundColor: nativeDefault.colors.MENTION_BACKGROUND, color: nativeDefault.colors.MENTION_FOREGROUND, borderRadius: nativeDefault.radii.xs, fontSize: 14, fontWeight: "bold" };
let obj6 = { backgroundColor: nativeDefault.colors.MENTION_BACKGROUND, color: nativeDefault.colors.MENTION_FOREGROUND, borderRadius: nativeDefault.radii.xs, fontSize: 14, fontWeight: "bold" };
obj.autocomplete = { color: nativeDefault.colors.TEXT_BRAND, fontWeight: "bold" };
let closure_14 = createStyles.createStyles(obj);
const forwardRefResult = noop.forwardRef((chatInputRef, ref) => {
2026-07-20 16:05:17 +00:00
chatInputRef = chatInputRef.chatInputRef;
const chatInputStateRef = chatInputRef.chatInputStateRef;
const channel = chatInputRef.channel;
const commandsDisabled = chatInputRef.commandsDisabled;
2026-07-29 08:29:29 +00:00
let stateFromStores1;
first = undefined;
let stateFromStores2;
let callback1;
2026-08-06 08:05:19 +00:00
let tmp = stateFromStores2();
_slicedToArray = tmp;
const applicationCommandOptionValueParser = chatInputRef(commandsDisabled[15]).useApplicationCommandOptionValueParser({ channel });
let obj = chatInputRef(commandsDisabled[15]);
2026-07-29 08:29:29 +00:00
const items = [stateFromStores1];
const stateFromStores = chatInputRef(commandsDisabled[13]).useStateFromStores(items, () => ApplicationCommandStore.getActiveCommand(channel.id));
let obj2 = chatInputRef(commandsDisabled[13]);
2026-07-29 08:29:29 +00:00
const items1 = [stateFromStores];
stateFromStores1 = chatInputRef(commandsDisabled[13]).useStateFromStores(items1, () => ApplicationCommandAutocompleteStore.getLastResponseNonce(channel.id));
let obj3 = chatInputRef(commandsDisabled[13]);
let text = chatInputRef(commandsDisabled[16]).getTextBeforeFirstOption(chatInputStateRef.current.text).text;
2026-07-23 10:11:24 +00:00
let substr = text.slice(1);
2026-07-29 08:29:29 +00:00
ref = applicationCommandOptionValueParser.useRef(substr.trimEnd());
const tmp6 = _slicedToArray(applicationCommandOptionValueParser.useState(ref.current), 2);
2026-08-24 06:08:38 +00:00
closure_9 = tmp6[1];
let obj4 = chatInputRef(commandsDisabled[16]);
const commands = channel(commandsDisabled[17]).useCachedResults({ type: "channel", channel }, chatInputRef(commandsDisabled[18]).ApplicationCommandType.CHAT, tmp6[0]).commands;
ref = applicationCommandOptionValueParser.useRef(undefined);
closure_129_1 = undefined;
[first, closure_129_1] = applicationCommandOptionValueParser.useState([]);
closure_129_0 = first;
const callback = applicationCommandOptionValueParser.useCallback((arg0) => {
closure_0 = closure_2_11(arg0);
chatInputStateRef((arg0) => {
2026-07-29 08:29:29 +00:00
let tmp = closure_0;
if (obj.isEqual(arg0, closure_0)) {
tmp = arg0;
}
return tmp;
});
}, []);
const items2 = [first];
const memo = applicationCommandOptionValueParser.useMemo(() => chatInputRef.filter((item) => null == gameById.getGameById(item)), items2);
2026-08-06 08:05:19 +00:00
const obj6 = channel(commandsDisabled[17]);
const games = chatInputRef(commandsDisabled[12]).useGames(memo);
const obj7 = chatInputRef(commandsDisabled[12]);
2026-08-24 06:08:38 +00:00
const items3 = [ref, commands, closure_9];
2026-08-06 08:05:19 +00:00
const items4 = [first];
stateFromStores2 = chatInputRef(commandsDisabled[13]).useStateFromStores(items3, () => {
if (0 === chatInputRef.length) {
2026-07-29 08:29:29 +00:00
return null;
} else {
const currentUser = UserStore.getCurrentUser();
2026-07-29 08:29:29 +00:00
if (currentUser != null) {
const nsfwAllowed = currentUser.nsfwAllowed;
}
const _Map = Map;
const map = new Map();
2026-08-06 08:05:19 +00:00
for (const item10017 of tmp) {
let tmp8 = item10017;
let game = GameStore.getGame(item10017);
2026-08-06 08:05:19 +00:00
let tmp11 = game;
if (null == game) {
let gameById = GameAutocompleteStore.getGameById(tmp8);
2026-08-06 08:05:19 +00:00
if (null != gameById) {
let result = map.set(tmp8, tmp22);
}
} else {
let obj2 = useGameProfileObscured;
2026-08-06 08:05:19 +00:00
if (!obj2.isGameProfileObscured(tmp11, nsfwAllowed)) {
let obj = { id: tmp8, name: null, icon: null };
({ name: obj3.name, media } = tmp11);
2026-08-06 08:05:19 +00:00
let icon;
if (media != null) {
icon = media.icon;
2026-07-29 08:29:29 +00:00
}
2026-08-06 08:05:19 +00:00
if (icon == null) {
icon = null;
2026-07-29 08:29:29 +00:00
}
obj.icon = icon;
2026-08-06 08:05:19 +00:00
let result1 = map.set(tmp8, obj);
2026-07-24 07:16:23 +00:00
}
}
2026-07-29 08:29:29 +00:00
continue;
}
2026-08-06 08:05:19 +00:00
let tmp26 = null;
2026-07-29 08:29:29 +00:00
if (map.size > 0) {
2026-08-06 08:05:19 +00:00
tmp26 = map;
2026-07-29 08:29:29 +00:00
}
2026-08-06 08:05:19 +00:00
return tmp26;
2026-07-29 08:29:29 +00:00
}
2026-08-06 08:05:19 +00:00
}, items4, callback1);
2026-07-29 08:29:29 +00:00
const items5 = [stateFromStores, channel, chatInputRef, chatInputStateRef, commandsDisabled, stateFromStores1, applicationCommandOptionValueParser, commands, tmp, callback];
callback1 = applicationCommandOptionValueParser.useCallback(() => {
const current = chatInputStateRef.current;
const text = current.text;
2026-07-24 07:16:23 +00:00
({ editId, focused, selectionStart, selectionEnd } = current);
2026-07-29 08:29:29 +00:00
callback(text);
const obj = { activeCommand: stateFromStores, channel, commandsDisabled, editId, focused, lastCommandAutocompleteResponseNonce: stateFromStores1, queryCommands: commands, selectionStart, selectionEnd, text };
2026-08-06 08:05:19 +00:00
if (null == ref.current) {
const obj2 = { props: obj, ref: chatInputRef, optionValueParser: applicationCommandOptionValueParser, styles: null };
2026-08-24 06:08:38 +00:00
closure_0 = closure_4;
const obj3 = {
commandOption() {
return chatInputRef(commandsDisabled[10]).convertToNativeStyle(closure_0.commandOption);
},
commandErrorOption() {
return chatInputRef(commandsDisabled[10]).convertToNativeStyle(closure_0.commandErrorOption);
},
gameMention() {
return chatInputRef(commandsDisabled[10]).convertToNativeStyle(closure_0.gameMention);
},
timestampMention() {
return chatInputRef(commandsDisabled[10]).convertToNativeStyle(closure_0.timestampMention);
},
autocomplete(color) {
if (null == color) {
let autocomplete = closure_0.autocomplete;
} else {
autocomplete = {};
const merged = Object.assign(closure_0.autocomplete);
autocomplete.color = color;
}
return chatInputRef(commandsDisabled[10]).convertToNativeStyle(autocomplete);
}
2026-07-29 08:29:29 +00:00
};
obj2.styles = obj3;
const tmp12 = new ApplicationCommandManagerDefault(obj2);
2026-07-29 08:29:29 +00:00
tmp2.current = tmp12;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
const current2 = tmp2.current;
const obj4 = { newState: obj };
const result = current2.updateApplicationCommandManagerState(obj4);
2026-07-20 16:05:17 +00:00
}
const text1 = ChatInputCommandOptionParser.getTextBeforeFirstOption(text).text;
const substr = text1.slice(1);
2026-07-20 16:05:17 +00:00
const trimEndResult = substr.trimEnd();
if (ref.current !== trimEndResult) {
closure_9(trimEndResult);
2026-07-29 08:29:29 +00:00
tmp15.current = trimEndResult;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}, items5);
const items6 = [callback1];
2026-07-23 10:11:24 +00:00
const effect = applicationCommandOptionValueParser.useEffect(() => {
2026-07-29 08:29:29 +00:00
callback1();
}, items6);
const items7 = [tmp];
2026-07-24 07:16:23 +00:00
const effect1 = applicationCommandOptionValueParser.useEffect(() => {
2026-08-06 08:05:19 +00:00
const current = ref.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-08-24 06:08:38 +00:00
closure_0 = closure_4;
const obj = {
commandOption() {
return chatInputRef(commandsDisabled[10]).convertToNativeStyle(closure_0.commandOption);
},
commandErrorOption() {
return chatInputRef(commandsDisabled[10]).convertToNativeStyle(closure_0.commandErrorOption);
},
gameMention() {
return chatInputRef(commandsDisabled[10]).convertToNativeStyle(closure_0.gameMention);
},
timestampMention() {
return chatInputRef(commandsDisabled[10]).convertToNativeStyle(closure_0.timestampMention);
},
autocomplete(color) {
if (null == color) {
let autocomplete = closure_0.autocomplete;
} else {
autocomplete = {};
const merged = Object.assign(closure_0.autocomplete);
autocomplete.color = color;
}
return chatInputRef(commandsDisabled[10]).convertToNativeStyle(autocomplete);
}
2026-07-29 08:29:29 +00:00
};
current.updateStyles(obj);
2026-07-28 08:39:19 +00:00
}
2026-07-29 08:29:29 +00:00
}, items7);
const items8 = [stateFromStores2, first, chatInputRef, chatInputStateRef, callback1];
2026-07-28 08:39:19 +00:00
const effect2 = applicationCommandOptionValueParser.useEffect(() => {
2026-08-06 08:05:19 +00:00
const current = ref.current;
2026-07-29 08:29:29 +00:00
if (null != stateFromStores2) {
if (0 !== first.length) {
2026-07-24 07:16:23 +00:00
if (null != current) {
const mapped = closure_2_11(chatInputStateRef.current.text).map((item) => stateFromStores2.get(item));
const found = mapped.filter((item) => null != item);
2026-07-24 07:16:23 +00:00
if (0 !== found.length) {
const replaced = str.replace(closure_2_12, (arg0, arg1) => {
2026-07-24 07:16:23 +00:00
let combined = arg0;
value = stateFromStores2.get(arg1);
2026-07-24 07:16:23 +00:00
if (null != value) {
const _HermesInternal = HermesInternal;
combined = "" + first + value.name;
2026-07-24 07:16:23 +00:00
}
return combined;
});
2026-07-29 08:29:29 +00:00
for (const item10011 of found) {
let addGameMentionResult = current.addGameMention(item10011);
continue;
2026-07-24 07:16:23 +00:00
}
const current2 = chatInputRef.current;
2026-07-24 07:16:23 +00:00
current2.setText(replaced);
chatInputStateRef.current.textPrev = str;
chatInputStateRef.current.text = replaced;
2026-07-29 08:29:29 +00:00
callback1();
2026-07-24 07:16:23 +00:00
}
const arr = closure_2_11(chatInputStateRef.current.text);
2026-07-24 07:16:23 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
}, items8);
const imperativeHandle = applicationCommandOptionValueParser.useImperativeHandle(ref, () => ({
2026-07-20 16:05:17 +00:00
getApplicationCommandManager() {
2026-07-29 08:29:29 +00:00
return ref.current;
2026-07-20 16:05:17 +00:00
},
updateState() {
return callback1();
2026-07-20 16:05:17 +00:00
}
}));
return null;
});
forwardRefResult.displayName = "ChatInputAppCommandManager";
let obj7 = { color: nativeDefault.colors.TEXT_BRAND, fontWeight: "bold" };
const size = fn(2);
let result = size.fileFinishedImporting("modules/chat_input/native/ChatInputAppCommandManager.tsx");
2026-07-20 16:05:17 +00:00
export default noop.memo(forwardRefResult);