decord/source/modules/application_commands/native/ApplicationCommandBar.tsx

391 lines
16 KiB
TypeScript
Raw Normal View History

// Module ID: 12496
// Function ID: 12497
// Name: ApplicationCommandBar
// Dependencies: [32, 19, 17, 2021, 21, 4606, 576, 5492, 5174, 1114, 1178, 504, 12324, 5638, 4602, 8684, 8358, 12497, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
// Module 12496 (ApplicationCommandBar)
import nativeDefault from "native" /* 576 */;
import util from "util" /* 1114 */;
import native from "native" /* 1178 */;
import Text_Text from "Text/Text" /* 4602 */;
import Pressables from "Pressables" /* 5174 */;
import usePreviousDefault from "usePrevious" /* 8358 */;
import application_commands_ApplicationCommandUtils from "application_commands/ApplicationCommandUtils" /* 12324 */;
import DescriptionEllipsisDefault from "DescriptionEllipsis" /* 12497 */;
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
import GuildMemberStore from "GuildMemberStore" /* 2021 */;
2026-07-23 10:11:24 +00:00
require = fn;
2026-07-20 16:05:17 +00:00
function ApplicationCommandOptionItem(arg0) {
({ option, optionState } = arg0);
const merged = Object.assign(arg0, Object.assign({ option: 0, optionState: 0 }));
const tmp2 = closure_11();
2026-07-29 08:29:29 +00:00
let flag;
if (optionState != null) {
flag = optionState.isActive;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (flag == null) {
flag = false;
}
const obj = { accessibilityLabel: null, accessibilityRole: "button", disabled: null, style: null };
const intl = util.intl;
obj.accessibilityLabel = intl.formatToPlainString(util.t.evoEHc, { optionName: option.displayName });
obj.disabled = flag;
2026-07-29 08:29:29 +00:00
const items = [tmp2.applicationCommandOption, , ];
let activeCommandOption = flag;
if (flag) {
activeCommandOption = tmp2.activeCommandOption;
2026-07-20 16:05:17 +00:00
}
items[1] = activeCommandOption;
2026-07-29 08:29:29 +00:00
let completeCommandOption = !flag;
if (!flag) {
2026-07-20 16:05:17 +00:00
let success;
2026-07-29 08:29:29 +00:00
if (optionState != null) {
if (optionState.lastValidationResult != null) {
2026-07-20 16:05:17 +00:00
success = lastValidationResult.success;
}
}
completeCommandOption = success;
}
if (completeCommandOption) {
2026-07-29 08:29:29 +00:00
completeCommandOption = tmp2.completeCommandOption;
2026-07-20 16:05:17 +00:00
}
items[2] = completeCommandOption;
obj.style = items;
2026-07-20 16:05:17 +00:00
const merged1 = Object.assign(merged);
2026-07-29 08:29:29 +00:00
const items1 = [tmp2.applicationCommandOptionText, , , ];
let activeCommandOptionText = flag;
if (flag) {
activeCommandOptionText = tmp2.activeCommandOptionText;
2026-07-20 16:05:17 +00:00
}
items1[1] = activeCommandOptionText;
2026-07-29 08:29:29 +00:00
let completeCommandOptionText = !flag;
if (!flag) {
2026-07-20 16:05:17 +00:00
let success1;
2026-07-29 08:29:29 +00:00
if (optionState != null) {
if (optionState.lastValidationResult != null) {
2026-07-20 16:05:17 +00:00
success1 = lastValidationResult2.success;
}
}
completeCommandOptionText = success1;
}
if (completeCommandOptionText) {
2026-07-29 08:29:29 +00:00
completeCommandOptionText = tmp2.completeCommandOptionText;
2026-07-20 16:05:17 +00:00
}
items1[2] = completeCommandOptionText;
2026-07-29 08:29:29 +00:00
let errorCommandOptionText = !flag;
if (!flag) {
2026-07-20 16:05:17 +00:00
let success2;
2026-07-29 08:29:29 +00:00
if (optionState != null) {
if (optionState.lastValidationResult != null) {
2026-07-20 16:05:17 +00:00
success2 = lastValidationResult3.success;
}
}
errorCommandOptionText = false === success2;
}
if (errorCommandOptionText) {
2026-07-29 08:29:29 +00:00
errorCommandOptionText = tmp2.errorCommandOptionText;
2026-07-20 16:05:17 +00:00
}
items1[3] = errorCommandOptionText;
obj.children = React6(native.LegacyText, { style: items1, numberOfLines: 1, children: option.displayName });
return React6(Pressables.PressableOpacity, obj);
2026-07-20 16:05:17 +00:00
}
get_ActivityIndicator = fn(17);
({ View: hasOwnProperty, ScrollView: metroRequire, StyleSheet } = get_ActivityIndicator);
const jsxProd = fn(21);
({ jsx: closure_8, Fragment: closure_9, jsxs: c10 } = jsxProd);
const createStyles = fn(4606);
let obj2 = { applicationCommandBar: { flexDirection: "column", backgroundColor: nativeDefault.colors.MOBILE_FLOATING_ACCESSORY_BACKGROUND, borderRadius: nativeDefault.modules.mobile.CHAT_INPUT_FLOATING_BORDER_RADIUS, borderWidth: nativeDefault.modules.mobile.CHAT_INPUT_FLOATING_ACCESSORY_BORDER_WIDTH, borderColor: nativeDefault.colors.MOBILE_FLOATING_ACCESSORY_BORDER, overflow: "hidden" }, applicationIcon: null, applicationTopWrapperScrollView: null, applicationName: null, applicationOptionalOptionsDivider: null, applicationOptionalOptionsDividerWithNoRequired: null, applicationOptionalOptionsIndicator: null, applicationDescriptionContainer: null, applicationDescriptionDivider: null, applicationCommandOption: null, applicationCommandOptionText: null, activeCommandOption: null, activeCommandOptionText: null, completeCommandOptionText: null, errorCommandOptionText: null, optionDescriptionContainer: null, descriptionEllipsis: null, descriptionEllipsisDots: null, completeCommandOption: null };
let size = { width: 24, height: 24, borderRadius: nativeDefault.radii.md, marginRight: 16 };
obj2.applicationIcon = size;
obj2.applicationTopWrapperScrollView = { flexDirection: "row", alignItems: "center", paddingHorizontal: 16, paddingVertical: 8 };
obj2.applicationName = { textAlignVertical: "center", marginRight: 12 };
const size1 = { width: StyleSheet.hairlineWidth, marginVertical: 8, marginHorizontal: 12, backgroundColor: nativeDefault.colors.BACKGROUND_MOD_NORMAL, height: "100%" };
obj2.applicationOptionalOptionsDivider = size1;
obj2.applicationOptionalOptionsDividerWithNoRequired = { marginLeft: 4 };
obj2.applicationOptionalOptionsIndicator = { marginHorizontal: 4, paddingVertical: 8 };
obj2.applicationDescriptionContainer = { flexShrink: 1 };
let obj3 = { flexDirection: "column", backgroundColor: nativeDefault.colors.MOBILE_FLOATING_ACCESSORY_BACKGROUND, borderRadius: nativeDefault.modules.mobile.CHAT_INPUT_FLOATING_BORDER_RADIUS, borderWidth: nativeDefault.modules.mobile.CHAT_INPUT_FLOATING_ACCESSORY_BORDER_WIDTH, borderColor: nativeDefault.colors.MOBILE_FLOATING_ACCESSORY_BORDER, overflow: "hidden" };
obj2.applicationDescriptionDivider = { marginLeft: 0, backgroundColor: nativeDefault.colors.MOBILE_COMMAND_BAR_DIVIDER };
let obj4 = { marginLeft: 0, backgroundColor: nativeDefault.colors.MOBILE_COMMAND_BAR_DIVIDER };
obj2.applicationCommandOption = { marginHorizontal: 4, padding: 8, fontSize: 12, alignItems: "center", borderRadius: nativeDefault.radii.xs, backgroundColor: fn(5492).DARK_PRIMARY_800_LIGHT_PRIMARY_300 };
let obj5 = { marginHorizontal: 4, padding: 8, fontSize: 12, alignItems: "center", borderRadius: nativeDefault.radii.xs, backgroundColor: fn(5492).DARK_PRIMARY_800_LIGHT_PRIMARY_300 };
obj2.applicationCommandOptionText = { color: nativeDefault.colors.TEXT_DEFAULT };
let obj6 = { color: nativeDefault.colors.TEXT_DEFAULT };
obj2.activeCommandOption = { backgroundColor: nativeDefault.colors.BACKGROUND_BRAND };
let obj7 = { backgroundColor: nativeDefault.colors.BACKGROUND_BRAND };
obj2.activeCommandOptionText = { color: nativeDefault.colors.WHITE };
obj2.completeCommandOptionText = { opacity: 0.5 };
let obj8 = { color: nativeDefault.colors.WHITE };
obj2.errorCommandOptionText = { color: nativeDefault.colors.TEXT_FEEDBACK_CRITICAL };
obj2.optionDescriptionContainer = { overflow: "hidden", paddingHorizontal: 16, paddingVertical: 8, flexDirection: "row" };
const obj9 = { color: nativeDefault.colors.TEXT_FEEDBACK_CRITICAL };
obj2.descriptionEllipsis = { marginLeft: 10, backgroundColor: nativeDefault.colors.MOBILE_FLOATING_ACCESSORY_BACKGROUND };
const obj10 = { marginLeft: 10, backgroundColor: nativeDefault.colors.MOBILE_FLOATING_ACCESSORY_BACKGROUND };
obj2.descriptionEllipsisDots = { backgroundColor: nativeDefault.colors.INTERACTIVE_TEXT_DEFAULT };
let obj11 = { backgroundColor: nativeDefault.colors.INTERACTIVE_TEXT_DEFAULT };
obj2.completeCommandOption = { backgroundColor: fn(5492).DARK_PRIMARY_660_LIGHT_PRIMARY_300 };
let closure_11 = createStyles.createStyles(obj2);
2026-07-20 16:05:17 +00:00
function ApplicationCommandOptionDescription(option) {
option = option.option;
const optionState = option.optionState;
lineClamp = undefined;
closure_3 = undefined;
first1 = undefined;
2026-08-24 06:08:38 +00:00
closure_5 = undefined;
2026-07-23 10:11:24 +00:00
c6 = undefined;
const tmp = closure_11();
const tmp4 = usePreviousDefault(option);
closure_1 = tmp4;
[lineClamp, closure_3] = noop.useState(undefined);
[first1, closure_5] = noop.useState(0);
[tmp10, c6] = noop.useState(0);
const tmp11 = usePreviousDefault(first1);
2026-08-24 06:08:38 +00:00
closure_7 = tmp11;
2026-07-29 08:29:29 +00:00
const items = [tmp4, option, first1, tmp11];
const effect = noop.useEffect(() => {
2026-08-24 06:08:38 +00:00
if (closure_1 !== option) {
closure_5(0);
2026-07-23 10:11:24 +00:00
_undefined(0);
closure_3(undefined);
2026-07-20 16:05:17 +00:00
} else {
let tmp2 = first1 > 0;
if (tmp2) {
2026-08-24 06:08:38 +00:00
tmp2 = 0 === closure_7;
2026-07-20 16:05:17 +00:00
}
if (tmp2) {
closure_3(1);
2026-07-20 16:05:17 +00:00
}
}
}, items);
const items1 = [lineClamp];
let tmp14 = 1 === lineClamp;
const callback = noop.useCallback(() => {
2026-08-24 06:08:38 +00:00
closure_3(1);
2026-07-20 16:05:17 +00:00
}, items1);
2026-07-29 08:29:29 +00:00
if (tmp14) {
tmp14 = tmp10 === first1;
2026-07-20 16:05:17 +00:00
}
let str = "button";
2026-07-29 08:29:29 +00:00
if (tmp14) {
2026-07-20 16:05:17 +00:00
str = "text";
}
const obj = { accessibilityRole: str, disabled: tmp14, onPress: callback, children: null };
const obj2 = { style: tmp.optionDescriptionContainer, children: null };
const obj3 = { style: tmp.applicationDescriptionContainer, children: null };
let error;
2026-07-29 08:29:29 +00:00
if (optionState != null) {
if (optionState.lastValidationResult != null) {
2026-07-20 16:05:17 +00:00
error = lastValidationResult.error;
}
}
2026-07-29 08:29:29 +00:00
function onDescriptionLayout(nativeEvent) {
const truncResult = Math.trunc(nativeEvent.nativeEvent.layout.height);
let tmp2 = undefined === first;
if (!tmp2) {
tmp2 = truncResult > first1;
}
if (tmp2) {
closure_5(truncResult);
2026-07-29 08:29:29 +00:00
}
_undefined(truncResult);
}
2026-07-20 16:05:17 +00:00
if (null != error) {
const obj4 = { lineClamp, onLayout: onDescriptionLayout, variant: "text-sm/medium", color: "text-feedback-critical", children: optionState.lastValidationResult.error };
let obj5 = obj4;
2026-07-20 16:05:17 +00:00
} else {
obj5 = { lineClamp, onLayout: onDescriptionLayout, variant: "text-sm/medium", color: "mobile-text-heading-primary", children: null != option ? option.displayDescription : option.command.displayDescription };
2026-07-20 16:05:17 +00:00
}
obj3.children = React6(Text_Text.Text, obj5);
const items2 = [React6(hasOwnProperty, obj3), ];
2026-07-29 08:29:29 +00:00
let tmp15Result = null;
if (tmp10 !== first1) {
({ descriptionEllipsis: obj6.style, descriptionEllipsisDots: obj6.dotStyle } = tmp);
tmp15Result = tmp15(DescriptionEllipsisDefault, { style: null, dotStyle: null });
const obj11 = { style: null, dotStyle: null };
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
items2[1] = tmp15Result;
obj2.children = items2;
obj.children = closure_1_10(hasOwnProperty, obj2);
return React6(Pressables.PressableOpacity, obj);
2026-07-20 16:05:17 +00:00
}
size = fn(2);
const result = size.fileFinishedImporting("modules/application_commands/native/ApplicationCommandBar.tsx");
2026-07-20 16:05:17 +00:00
export default function _default(command) {
command = command.command;
const section = command.section;
2026-07-23 10:11:24 +00:00
({ guildId: dependencyMap, currentOption } = command);
2026-07-20 16:05:17 +00:00
const optionStates = command.optionStates;
const onPressOption = command.onPressOption;
2026-07-29 08:29:29 +00:00
c9 = undefined;
c10 = undefined;
let first;
2026-07-23 10:11:24 +00:00
let tmp = first();
2026-08-24 06:08:38 +00:00
closure_6 = tmp;
optionStates.useRef(null);
const ref = optionStates.useRef({});
2026-07-29 08:29:29 +00:00
[tmp4, c9] = currentOption(optionStates.useState(false), 2);
2026-07-23 10:11:24 +00:00
const tmp3 = currentOption(optionStates.useState(false), 2);
2026-07-29 08:29:29 +00:00
[tmp6, c10] = currentOption(optionStates.useState(false), 2);
2026-07-23 10:11:24 +00:00
const tmp7 = currentOption(optionStates.useState(), 2);
first = tmp7[0];
2026-07-29 08:29:29 +00:00
closure_12 = tmp7[1];
2026-07-20 16:05:17 +00:00
const items = [command];
2026-07-23 10:11:24 +00:00
const effect = optionStates.useEffect(() => {
c0 = false;
2026-08-24 06:08:38 +00:00
c1 = false;
const options = command.options;
2026-07-29 08:29:29 +00:00
if (options != null) {
2026-07-20 16:05:17 +00:00
const item = options.forEach((required) => {
if (true !== required.required) {
2026-08-24 06:08:38 +00:00
c0 = true;
2026-07-20 16:05:17 +00:00
} else {
2026-08-24 06:08:38 +00:00
c1 = true;
2026-07-20 16:05:17 +00:00
}
});
}
_undefined(c0);
2026-08-24 06:08:38 +00:00
_undefined2(c1);
2026-07-20 16:05:17 +00:00
}, items);
const items1 = [currentOption];
2026-07-23 10:11:24 +00:00
const effect1 = optionStates.useEffect(() => {
2026-07-20 16:05:17 +00:00
let name;
2026-07-29 08:29:29 +00:00
if (currentOption != null) {
2026-07-20 16:05:17 +00:00
name = currentOption.name;
}
closure_12(name);
}, items1);
const items2 = [first, tmp];
2026-07-23 10:11:24 +00:00
const effect2 = optionStates.useEffect(() => {
2026-07-29 08:29:29 +00:00
let tmp2 = null;
2026-07-20 16:05:17 +00:00
if (null != first) {
2026-07-29 08:29:29 +00:00
tmp2 = ref.current[tmp];
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (null != tmp2) {
2026-07-20 16:05:17 +00:00
const current = ref.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
const obj = { x: tmp2.x - closure_6.applicationTopWrapperScrollView.paddingHorizontal, animated: true };
2026-07-20 16:05:17 +00:00
current.scrollTo(obj);
}
}
}, items2);
const tmp5 = currentOption(optionStates.useState(false), 2);
2026-07-23 10:11:24 +00:00
const items3 = [ref];
const stateFromStores = command(504).useStateFromStores(items3, () => {
if (null != dependencyMap) {
2026-07-20 16:05:17 +00:00
let botId;
2026-07-29 08:29:29 +00:00
if (section != null) {
botId = tmp2.botId;
2026-07-20 16:05:17 +00:00
}
if (null != botId) {
return GuildMemberStore.getMember(tmp, tmp2.botId);
2026-07-20 16:05:17 +00:00
}
}
});
const items4 = [section, stateFromStores];
const memo = optionStates.useMemo(() => application_commands_ApplicationCommandUtils.getApplicationCommandsIconSource(section, stateFromStores), items4);
2026-07-29 08:29:29 +00:00
closure_14 = optionStates.useCallback((nativeEvent, name) => {
2026-07-20 16:05:17 +00:00
nativeEvent = nativeEvent.nativeEvent;
const current = ref.current;
current[name.name] = { x: nativeEvent.layout.x, width: nativeEvent.layout.width };
ref.current = current;
}, []);
let name;
2026-07-29 08:29:29 +00:00
if (currentOption != null) {
2026-07-20 16:05:17 +00:00
name = currentOption.name;
}
2026-07-29 08:29:29 +00:00
let tmp17;
2026-07-20 16:05:17 +00:00
if (null != name) {
let name1;
2026-07-29 08:29:29 +00:00
if (currentOption != null) {
2026-07-20 16:05:17 +00:00
name1 = currentOption.name;
}
2026-07-29 08:29:29 +00:00
tmp17 = optionStates[name1];
2026-07-20 16:05:17 +00:00
}
const obj2 = { style: tmp.applicationCommandBar, children: null };
const obj3 = { ref, contentContainerStyle: tmp.applicationTopWrapperScrollView, keyboardShouldPersistTaps: "always", showsHorizontalScrollIndicator: false, horizontal: true, children: null };
2026-07-29 08:29:29 +00:00
let tmp22 = null != memo;
if (tmp22) {
const obj4 = { style: tmp.applicationIcon, source: memo };
tmp22 = ref(section(5638), obj4);
2026-07-20 16:05:17 +00:00
}
const items5 = [tmp22, ref(command(4602).Text, { style: tmp.applicationName, lineClamp: 1, variant: "text-sm/semibold", color: "mobile-text-heading-primary", children: `/ ${command.displayName}` }), , ];
2026-07-23 10:11:24 +00:00
let options = command.options;
2026-07-20 16:05:17 +00:00
let mapped;
2026-07-29 08:29:29 +00:00
if (options != null) {
2026-07-20 16:05:17 +00:00
mapped = options.map((required) => {
2026-08-24 06:08:38 +00:00
closure_0 = required;
2026-07-20 16:05:17 +00:00
let tmp = null;
if (required.required) {
const obj = {
option: required,
onPress() {
let tmpResult;
if (onPressOption != null) {
tmpResult = tmp(closure_0);
}
return tmpResult;
},
optionState: optionStates[required.name],
onLayout(arg0) {
return closure_14(arg0, closure_0);
}
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
tmp = ref(closure_12, obj, required.name);
2026-07-20 16:05:17 +00:00
}
return tmp;
});
}
items5[2] = mapped;
2026-07-29 08:29:29 +00:00
let tmp19Result = null;
2026-07-20 16:05:17 +00:00
if (tmp4) {
const items6 = [tmp.applicationOptionalOptionsDivider, ];
let applicationOptionalOptionsDividerWithNoRequired = !tmp6;
2026-07-29 08:29:29 +00:00
if (!tmp6) {
2026-07-20 16:05:17 +00:00
applicationOptionalOptionsDividerWithNoRequired = tmp.applicationOptionalOptionsDividerWithNoRequired;
}
const obj6 = { style: null };
2026-07-20 16:05:17 +00:00
items6[1] = applicationOptionalOptionsDividerWithNoRequired;
obj6.style = items6;
const items7 = [tmp25(tmp20, obj6), , ];
const obj7 = { style: tmp.applicationOptionalOptionsIndicator, lineClamp: 1, variant: "eyebrow", color: "text-muted", children: null };
const intl = tmp12(1114).intl;
obj7.children = intl.string(tmp12(1114).t.U19GM3);
items7[1] = tmp25(tmp12(4602).Text, obj7);
2026-07-20 16:05:17 +00:00
const options1 = command.options;
let mapped1;
2026-07-29 08:29:29 +00:00
if (options1 != null) {
2026-07-20 16:05:17 +00:00
mapped1 = options1.map((required) => {
2026-08-24 06:08:38 +00:00
closure_0 = required;
2026-07-20 16:05:17 +00:00
let tmp = null;
if (!required.required) {
const obj = {
option: required,
onPress() {
return onPressOption(closure_0);
},
optionState: optionStates[required.name],
onLayout(arg0) {
return closure_14(arg0, closure_0);
}
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
tmp = ref(closure_12, obj, required.name);
2026-07-20 16:05:17 +00:00
}
return tmp;
});
}
const obj8 = { children: null };
2026-07-20 16:05:17 +00:00
items7[2] = mapped1;
obj8.children = items7;
tmp19Result = tmp19(c9, obj8);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
items5[3] = tmp19Result;
obj3.children = items5;
const items8 = [c10(closure_6, obj3), ref(command(8684).FormDivider, { style: tmp.applicationDescriptionDivider }), ref(stateFromStores, { command, option: currentOption, optionState: tmp17 }), ref(command(8684).FormDivider, { style: tmp.applicationDescriptionDivider })];
obj2.children = items8;
return c10(onPressOption, obj2);
2026-07-20 16:05:17 +00:00
};