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

397 lines
16 KiB
TypeScript
Raw Normal View History

2026-07-27 11:26:19 +00:00
// Module ID: 11454
// Function ID: 89097
2026-07-24 07:16:23 +00:00
// Name: _createForOfIteratorHelperLoose
2026-07-27 11:26:19 +00:00
// Dependencies: [57, 31, 6038, 6039, 4152, 6108, 5913, 1850, 4568, 4131, 689, 22, 5639, 566, 8419, 11109, 11107, 7962, 1882, 11455, 11108, 2]
2026-07-20 16:05:17 +00:00
2026-07-27 11:26:19 +00:00
// Module 11454 (_createForOfIteratorHelperLoose)
2026-07-23 10:11:24 +00:00
import _slicedToArray from "_slicedToArray";
import importAllResult from "result";
import _isNativeReflectConstruct from "_isNativeReflectConstruct";
import closure_7 from "_isNativeReflectConstruct";
2026-07-24 07:16:23 +00:00
import closure_8 from "_isNativeReflectConstruct";
import closure_9 from "_isNativeReflectConstruct";
import closure_10 from "_isNativeReflectConstruct";
import closure_11 from "_isNativeReflectConstruct";
import regExp from "regExp";
2026-07-23 10:11:24 +00:00
import _createForOfIteratorHelperLoose from "_createForOfIteratorHelperLoose";
2026-07-24 07:16:23 +00:00
let closure_12;
let closure_13;
let closure_14;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-24 07:16:23 +00:00
function _createForOfIteratorHelperLoose(iterable) {
let closure_0 = iterable;
iterable = "undefined" !== typeof Symbol;
if (iterable) {
const _Symbol = Symbol;
iterable = iterable[Symbol.iterator];
}
if (!iterable) {
iterable = iterable[Symbol.iterator];
}
if (iterable) {
const iter = iterable.call(iterable);
const next = iter.next;
return next.bind(iter);
} else {
const _Array = Array;
let tmp = iterable;
if (!Array.isArray(iterable)) {
let tmp2;
if (iterable) {
if ("string" === typeof iterable) {
tmp2 = _arrayLikeToArray(iterable, undefined);
} else {
const toString = {}.toString;
const substr = toString.call(iterable).slice(8, -1);
let name = substr;
if (tmp3) {
name = iterable.constructor.name;
}
if ("Map" !== name) {
if ("Set" !== name) {
if ("Arguments" === name) {
let arr = _arrayLikeToArray(iterable, undefined);
} else {
let obj = /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/;
}
}
tmp2 = arr;
}
const _Array2 = Array;
arr = Array.from(iterable);
const callResult = toString.call(iterable);
tmp3 = "Object" === substr && iterable.constructor;
}
}
tmp = tmp2;
if (!tmp2) {
const _TypeError = TypeError;
const typeError = new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
throw typeError;
}
}
if (tmp) {
closure_0 = tmp;
}
let c1 = 0;
return () => {
if (closure_1 >= length.length) {
let obj = { done: true };
} else {
obj = { done: false };
closure_1 = tmp3 + 1;
obj.value = length[+closure_1];
}
return obj;
};
}
}
function _arrayLikeToArray(arg0, arg1) {
let length;
if (tmp) {
length = arg0.length;
}
const ArrayResult = Array(length);
for (let num = 0; num < length; num = num + 1) {
ArrayResult[num] = arg0[num];
}
return ArrayResult;
}
function areResolvedGamesEqual(size, size2) {
if (size === size2) {
return true;
} else {
if (null != size) {
if (null != size2) {
if (size.size === size2.size) {
const tmp3 = _createForOfIteratorHelperLoose(size.keys());
let iter = tmp3();
if (!iter.done) {
while (size2.has(iter.value)) {
let iter2 = tmp3();
iter = iter2;
}
return false;
}
return true;
}
}
}
return false;
}
}
({ extractGameMentionIds: closure_12, GAME_MENTION_RAW_RE_GLOBAL: closure_13, GAME_MENTION_SENTINEL: closure_14 } = regExp);
2026-07-20 16:05:17 +00:00
let obj = {};
2026-07-23 10:11:24 +00:00
obj = { backgroundColor: require("_createForOfIteratorHelperLoose").colors.KEYWORD_HIGHLIGHT_BACKGROUND, color: require("_createForOfIteratorHelperLoose").colors.TEXT_DEFAULT, borderRadius: require("_createForOfIteratorHelperLoose").radii.xs, fontSize: 14 };
2026-07-20 16:05:17 +00:00
obj.commandOption = obj;
2026-07-23 10:11:24 +00:00
_createForOfIteratorHelperLoose = { backgroundColor: require("_createForOfIteratorHelperLoose").colors.KEYWORD_HIGHLIGHT_BACKGROUND, color: require("_createForOfIteratorHelperLoose").colors.TEXT_FEEDBACK_CRITICAL, borderRadius: require("_createForOfIteratorHelperLoose").radii.xs, fontSize: 14 };
obj.commandErrorOption = _createForOfIteratorHelperLoose;
2026-07-24 07:16:23 +00:00
obj.gameMention = { backgroundColor: require("_createForOfIteratorHelperLoose").colors.MENTION_BACKGROUND, color: require("_createForOfIteratorHelperLoose").colors.MENTION_FOREGROUND, borderRadius: require("_createForOfIteratorHelperLoose").radii.xs, fontSize: 14, fontWeight: "bold" };
let obj2 = { backgroundColor: require("_createForOfIteratorHelperLoose").colors.MENTION_BACKGROUND, color: require("_createForOfIteratorHelperLoose").colors.MENTION_FOREGROUND, borderRadius: require("_createForOfIteratorHelperLoose").radii.xs, fontSize: 14, fontWeight: "bold" };
2026-07-23 10:11:24 +00:00
obj.autocomplete = { color: require("_createForOfIteratorHelperLoose").colors.TEXT_BRAND, fontWeight: "bold" };
2026-07-24 07:16:23 +00:00
let closure_15 = _createForOfIteratorHelperLoose.createStyles(obj);
2026-07-20 16:05:17 +00:00
const forwardRefResult = importAllResult.forwardRef((chatInputRef) => {
chatInputRef = chatInputRef.chatInputRef;
const chatInputStateRef = chatInputRef.chatInputStateRef;
const channel = chatInputRef.channel;
const commandsDisabled = chatInputRef.commandsDisabled;
2026-07-24 07:16:23 +00:00
let tmp = callback();
callback = tmp;
const applicationCommandOptionValueParser = chatInputRef(commandsDisabled[15]).useApplicationCommandOptionValueParser({ channel });
let obj = chatInputRef(commandsDisabled[15]);
let items = [stateFromStores1];
const stateFromStores = chatInputRef(commandsDisabled[13]).useStateFromStores(items, () => stateFromStores1.getActiveCommand(channel.id));
const obj2 = chatInputRef(commandsDisabled[13]);
let items1 = [stateFromStores];
stateFromStores1 = chatInputRef(commandsDisabled[13]).useStateFromStores(items1, () => stateFromStores.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-24 07:16:23 +00:00
const ref = applicationCommandOptionValueParser.useRef(substr.trimEnd());
const tmp6 = callback(applicationCommandOptionValueParser.useState(ref.current), 2);
2026-07-20 16:05:17 +00:00
let closure_9 = tmp6[1];
2026-07-24 07:16:23 +00:00
let obj4 = chatInputRef(commandsDisabled[16]);
const commands = channel(commandsDisabled[17]).useCachedResults({ type: "channel", channel }, chatInputRef(commandsDisabled[18]).ApplicationCommandType.CHAT, tmp6[0]).commands;
2026-07-23 10:11:24 +00:00
let closure_11 = applicationCommandOptionValueParser.useRef(undefined);
2026-07-24 07:16:23 +00:00
let tmp7 = (function useResolveComposerGameMentions(id) {
let closure_0 = id;
tmp = tmp(applicationCommandOptionValueParser.useState([]), 2);
const first = tmp[0];
let closure_2 = tmp[1];
const items = [first];
const callback = applicationCommandOptionValueParser.useCallback((arg0) => {
let closure_0 = syncRawGameMentionIdsFromText(arg0);
callback((arg0) => {
let tmp = arg0;
if (!obj.isEqual(arg0, closure_0)) {
tmp = closure_0;
}
return tmp;
});
}, []);
const memo = applicationCommandOptionValueParser.useMemo(() => first.filter((arg0) => null == gameById.getGameById(arg0)), items);
let obj = chatInputRef(commandsDisabled[12]);
const games = obj.useGames(memo);
const items1 = [ref, closure_11, commands, closure_9];
const items2 = [first, id];
obj = {
syncRawGameMentionIdsFromText: callback,
rawGameMentionIds: first,
resolvedGameMentions: chatInputRef(commandsDisabled[13]).useStateFromStores(items1, () => {
let iter3;
let media;
if (0 === first.length) {
return null;
} else {
currentUser = currentUser.getCurrentUser();
if (null != currentUser) {
const nsfwAllowed = currentUser.nsfwAllowed;
}
const editingMessage = commands.getEditingMessage(closure_0);
if (null != editingMessage) {
const mentionGames = editingMessage.mentionGames;
}
const _Map = Map;
const map = new Map();
const tmp10 = outer2_16(first);
const iter = tmp10();
let iter2 = iter;
if (!iter.done) {
do {
let value = iter2.value;
value = undefined;
if (null != mentionGames) {
value = mentionGames.get(value);
}
if (null == value) {
let tmp19 = ref;
let game = ref.getGame(value);
if (null == game) {
let tmp25 = gameById;
gameById = gameById.getGameById(value);
let tmp27 = game;
let tmp16 = gameById;
let tmp17 = tmp12;
let tmp18 = tmp13;
if (null != gameById) {
let result = map.set(value, gameById);
let tmp29 = game;
tmp16 = gameById;
tmp17 = tmp12;
tmp18 = tmp13;
}
} else {
let tmp35 = chatInputRef;
let tmp36 = commandsDisabled;
let obj4 = chatInputRef(commandsDisabled[14]);
let tmp37 = game;
tmp16 = tmp11;
tmp17 = tmp12;
tmp18 = tmp13;
if (!obj4.isGameProfileObscured(game, nsfwAllowed)) {
let obj = { id: value };
({ name: obj3.name, media } = game);
let icon;
if (null != media) {
icon = media.icon;
}
let tmp22 = null;
if (null != icon) {
tmp22 = icon;
}
obj.icon = tmp22;
let result1 = map.set(value, obj);
let tmp24 = game;
tmp16 = tmp11;
tmp17 = icon;
tmp18 = media;
}
}
} else {
obj = { id: value };
({ name: obj2.name, icon: obj2.icon } = value);
let result2 = map.set(value, obj);
tmp16 = tmp11;
tmp17 = tmp12;
tmp18 = tmp13;
}
iter3 = tmp10();
tmp11 = tmp16;
tmp12 = tmp17;
tmp13 = tmp18;
iter2 = iter3;
} while (!iter3.done);
}
let tmp30 = null;
if (map.size > 0) {
tmp30 = map;
}
return tmp30;
}
}, items2, outer1_18)
};
return obj;
})(channel.id);
const syncRawGameMentionIdsFromText = tmp7.syncRawGameMentionIdsFromText;
const rawGameMentionIds = tmp7.rawGameMentionIds;
const resolvedGameMentions = tmp7.resolvedGameMentions;
let items2 = [stateFromStores, channel, chatInputRef, chatInputStateRef, commandsDisabled, stateFromStores1, applicationCommandOptionValueParser, commands, tmp, syncRawGameMentionIdsFromText];
2026-07-23 10:11:24 +00:00
callback = applicationCommandOptionValueParser.useCallback(() => {
2026-07-24 07:16:23 +00:00
let editId;
let focused;
let selectionEnd;
let selectionStart;
2026-07-20 16:05:17 +00:00
const current = chatInputStateRef.current;
let text = current.text;
2026-07-24 07:16:23 +00:00
({ editId, focused, selectionStart, selectionEnd } = current);
syncRawGameMentionIdsFromText(text);
let obj = { activeCommand: stateFromStores, channel, commandsDisabled, editId, focused, lastCommandAutocompleteResponseNonce: stateFromStores1, queryCommands: commands, selectionStart, selectionEnd, text };
2026-07-20 16:05:17 +00:00
if (null == ref.current) {
2026-07-24 07:16:23 +00:00
let tmp7 = chatInputStateRef(commandsDisabled[19]);
2026-07-20 16:05:17 +00:00
obj = {};
obj.props = obj;
obj.ref = chatInputRef;
obj.optionValueParser = applicationCommandOptionValueParser;
obj = {
commandOption() {
2026-07-24 07:16:23 +00:00
return chatInputRef(commandsDisabled[20]).convertToNativeStyle(outer1_4.commandOption);
2026-07-20 16:05:17 +00:00
},
commandErrorOption() {
2026-07-24 07:16:23 +00:00
return chatInputRef(commandsDisabled[20]).convertToNativeStyle(outer1_4.commandErrorOption);
},
gameMention() {
return chatInputRef(commandsDisabled[20]).convertToNativeStyle(outer1_4.gameMention);
2026-07-20 16:05:17 +00:00
},
autocomplete(arg0) {
if (null == arg0) {
2026-07-24 07:16:23 +00:00
let convertToNativeStyleResult = chatInputRef(commandsDisabled[20]).convertToNativeStyle(outer1_4.autocomplete);
const obj3 = chatInputRef(commandsDisabled[20]);
2026-07-20 16:05:17 +00:00
} else {
2026-07-24 07:16:23 +00:00
let obj = chatInputRef(commandsDisabled[20]);
2026-07-20 16:05:17 +00:00
obj = {};
2026-07-23 10:11:24 +00:00
const merged = Object.assign(outer1_4.autocomplete);
2026-07-20 16:05:17 +00:00
obj["color"] = arg0;
convertToNativeStyleResult = obj.convertToNativeStyle(obj);
}
return convertToNativeStyleResult;
}
};
obj.styles = obj;
2026-07-24 07:16:23 +00:00
const prototype = tmp7.prototype;
tmp7 = new tmp7(obj);
ref.current = tmp7;
2026-07-20 16:05:17 +00:00
} else {
const current2 = ref.current;
const obj1 = { newState: obj };
const result = current2.updateApplicationCommandManagerState(obj1);
}
2026-07-24 07:16:23 +00:00
text = chatInputRef(commandsDisabled[16]).getTextBeforeFirstOption(text).text;
2026-07-20 16:05:17 +00:00
const substr = text.slice(1);
const trimEndResult = substr.trimEnd();
if (ref.current !== trimEndResult) {
callback(trimEndResult);
ref.current = trimEndResult;
}
}, items2);
const items3 = [callback];
2026-07-23 10:11:24 +00:00
const effect = applicationCommandOptionValueParser.useEffect(() => {
2026-07-20 16:05:17 +00:00
callback();
}, items3);
2026-07-24 07:16:23 +00:00
const items4 = [resolvedGameMentions, rawGameMentionIds, chatInputRef, chatInputStateRef, callback];
const effect1 = applicationCommandOptionValueParser.useEffect(() => {
let done;
const current = ref.current;
if (null != resolvedGameMentions) {
if (0 !== rawGameMentionIds.length) {
if (null != current) {
const mapped = syncRawGameMentionIdsFromText(chatInputStateRef.current.text).map((arg0) => outer1_14.get(arg0));
const found = mapped.filter((arg0) => null != arg0);
if (0 !== found.length) {
const replaced = str.replace(rawGameMentionIds, (arg0, arg1) => {
let combined = arg0;
const value = outer1_14.get(arg1);
if (null != value) {
const _HermesInternal = HermesInternal;
combined = "" + resolvedGameMentions + value.name;
}
return combined;
});
const tmp13 = outer1_16(found);
let iter2 = tmp13();
if (!iter2.done) {
do {
let addGameMentionResult = current.addGameMention(iter2.value);
let iter = tmp13();
iter2 = iter;
done = iter.done;
} while (!done);
}
const current2 = chatInputRef.current;
current2.setText(replaced);
chatInputStateRef.current.textPrev = str;
chatInputStateRef.current.text = replaced;
callback();
}
const arr = syncRawGameMentionIdsFromText(chatInputStateRef.current.text);
}
}
}
}, items4);
2026-07-23 10:11:24 +00:00
const imperativeHandle = applicationCommandOptionValueParser.useImperativeHandle(arg1, () => ({
2026-07-20 16:05:17 +00:00
getApplicationCommandManager() {
2026-07-23 10:11:24 +00:00
return outer1_11.current;
2026-07-20 16:05:17 +00:00
},
updateState() {
2026-07-24 07:16:23 +00:00
return outer1_15();
2026-07-20 16:05:17 +00:00
}
}));
return null;
});
forwardRefResult.displayName = "ChatInputAppCommandManager";
2026-07-24 07:16:23 +00:00
let obj3 = { color: require("_createForOfIteratorHelperLoose").colors.TEXT_BRAND, fontWeight: "bold" };
2026-07-20 16:05:17 +00:00
const memoResult = importAllResult.memo(forwardRefResult);
2026-07-23 10:11:24 +00:00
let result = require("_isNativeReflectConstruct").fileFinishedImporting("modules/chat_input/native/ChatInputAppCommandManager.tsx");
2026-07-20 16:05:17 +00:00
export default memoResult;