decord/source/modules/autocompleter/native/AutocompleteUtils.tsx

231 lines
7.8 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 10066
// Function ID: 10067
2026-07-29 08:29:29 +00:00
// Name: AutocompleteFormDivider
2026-08-25 06:04:03 +00:00
// Dependencies: [19, 17, 1395, 1982, 4034, 1922, 676, 10067, 4839, 21, 4380, 712, 4574, 5266, 4224, 7552, 2]
2026-08-04 08:36:32 +00:00
// Exports: findAutoInsertOnSpaceToken, findWordStart, getAutocompleteResultText, getItemLayout, getItemSeparator, getMentionTextWithUser, getPrefix, getQuery, isSpaceJustTypedAtCaret, isUnbrokenRun, isWhitespaceSeparatingBoundary
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 10066 (AutocompleteFormDivider)
2026-08-24 06:08:38 +00:00
import noopAll from "noop" /* 19 */;
import ThemesDefault from "Themes" /* 712 */;
2026-08-25 06:04:03 +00:00
import nameFromUserDefault from "nameFromUser" /* 4224 */;
import computeChannelName from "computeChannelName" /* 4574 */;
import DividerDefault from "Divider" /* 7552 */;
2026-08-24 06:08:38 +00:00
import { isGuildSelectableChannelType as closure_3 } from "createChannelRecord" /* 1395 */;
2026-08-25 06:04:03 +00:00
import closure_4 from "comparator" /* 1982 */;
import closure_5 from "markAllUserIdListsStale" /* 4034 */;
2026-08-24 06:08:38 +00:00
import closure_6 from "mergeGuildAvatar" /* 1922 */;
import ME from "ME" /* 676 */;
2026-08-25 06:04:03 +00:00
import AUTOCOMPLETE_ROW_HEIGHT from "AUTOCOMPLETE_ROW_HEIGHT" /* 10067 */;
import regExp from "regExp" /* 4839 */;
2026-08-24 06:08:38 +00:00
import { jsx } from "jsxProd" /* 21 */;
2026-08-25 06:04:03 +00:00
import createCacheKey from "createCacheKey" /* 4380 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-20 16:05:17 +00:00
function AutocompleteFormDivider() {
2026-08-24 06:08:38 +00:00
const tmp = callback2();
return jsx(DividerDefault, { style: callback2().itemDivider });
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
noopAll;
({ AutoCompleteResultTypes: error, WHITESPACE_RE: closure_8 } = ME);
2026-07-29 08:29:29 +00:00
({ AUTOCOMPLETE_EMOJI_ROW_HEIGHT: c9, AUTOCOMPLETE_ROW_HEIGHT: c10 } = AUTOCOMPLETE_ROW_HEIGHT);
({ CHANNEL_SENTINEL: unpackModuleId, EMOJI_SENTINEL: closure_12, GAME_MENTION_SENTINEL: map1, MENTION_SENTINEL: closure_14 } = regExp);
2026-07-23 10:11:24 +00:00
const hairlineWidth = require("get ActivityIndicator").StyleSheet.hairlineWidth;
2026-07-29 08:29:29 +00:00
createCacheKey = { itemDivider: null };
2026-08-24 06:08:38 +00:00
createCacheKey = { marginLeft: 16, backgroundColor: ThemesDefault.colors.BORDER_SUBTLE };
2026-07-29 08:29:29 +00:00
createCacheKey[0] = createCacheKey;
2026-08-24 06:08:38 +00:00
let closure_17 = createCacheKey.createStyles(createCacheKey);
let result = require("set").fileFinishedImporting("modules/autocompleter/native/AutocompleteUtils.tsx");
2026-07-20 16:05:17 +00:00
export const getItemLayout = function getItemLayout(arg0, index) {
let type;
2026-07-29 08:29:29 +00:00
if (arg0 != null) {
if (arg0[index] != null) {
2026-07-20 16:05:17 +00:00
type = tmp2.type;
}
}
2026-07-24 07:16:23 +00:00
const tmp3 = type === constants.EMOJI ? closure_9 : closure_10;
2026-07-20 16:05:17 +00:00
const result = index * tmp3;
return { length: tmp3, offset: result + Math.max(0, (index - 1) * hairlineWidth), index };
};
export const getAutocompleteResultText = function getAutocompleteResultText(type, channel, channel2) {
if (null != channel2) {
if (!channel2.has(type.type)) {
return "";
}
}
type = type.type;
2026-07-24 07:16:23 +00:00
if (constants.USER === type) {
2026-07-29 08:29:29 +00:00
const user = type.user;
if (obj5.hasSameRoleAsUsername(channel, user)) {
const _HermesInternal9 = HermesInternal;
let combined = "" + tmp34 + user.tag;
} else {
const _HermesInternal8 = HermesInternal;
2026-08-24 06:08:38 +00:00
combined = "" + tmp34 + nameFromUserDefault.getUserTag(user);
const tmp32Result = nameFromUserDefault;
2026-07-29 08:29:29 +00:00
}
return combined;
} else if (tmp.GLOBAL === type) {
2026-07-20 16:05:17 +00:00
return type.text;
2026-07-29 08:29:29 +00:00
} else if (tmp.ROLE === type) {
2026-07-24 07:16:23 +00:00
const _HermesInternal7 = HermesInternal;
return "" + closure_14 + type.name;
2026-07-29 08:29:29 +00:00
} else if (tmp.CHANNEL === type) {
2026-07-20 16:05:17 +00:00
channel = type.channel;
if (channel.isThread()) {
2026-08-24 06:08:38 +00:00
const obj3 = computeChannelName;
2026-07-24 07:16:23 +00:00
const _HermesInternal6 = HermesInternal;
2026-08-24 06:08:38 +00:00
return "#\"" + obj3.escapeChannelName(computeChannelName.computeChannelName(type.channel, closure_6, closure_5)) + "\"";
2026-07-20 16:05:17 +00:00
} else {
channel2 = type.channel;
const guildId = channel2.getGuildId();
if (null != guildId) {
if (callback(type.channel.type)) {
2026-07-29 08:29:29 +00:00
const tmp16 = textChannelNameDisambiguations.getTextChannelNameDisambiguations(guildId)[type.channel.id];
2026-07-20 16:05:17 +00:00
let name;
2026-07-29 08:29:29 +00:00
if (tmp16 != null) {
name = tmp16.name;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (name == null) {
2026-08-24 06:08:38 +00:00
name = computeChannelName.computeChannelName(type.channel, closure_6, closure_5);
const obj2 = computeChannelName;
2026-07-20 16:05:17 +00:00
}
2026-07-24 07:16:23 +00:00
const _HermesInternal5 = HermesInternal;
return "" + closure_11 + name;
2026-07-20 16:05:17 +00:00
}
}
2026-07-24 07:16:23 +00:00
const _HermesInternal4 = HermesInternal;
2026-08-24 06:08:38 +00:00
return "" + closure_11 + computeChannelName.computeChannelName(type.channel, closure_6, closure_5);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
} else if (tmp.GAME_MENTION === type) {
2026-07-24 07:16:23 +00:00
const _HermesInternal3 = HermesInternal;
return "" + closure_13 + type.game.name;
2026-07-29 08:29:29 +00:00
} else if (tmp.EMOJI === type) {
2026-07-20 16:05:17 +00:00
const _HermesInternal2 = HermesInternal;
2026-07-24 07:16:23 +00:00
return "" + closure_12 + type.name + ":";
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
if (tmp.EMOJI_PREMIUM_UPSELL !== type) {
if (tmp.SLASH !== type) {
if (tmp.CHOICE === type) {
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
return "" + type.choice.displayName;
} else {
return "";
}
}
}
return "";
}
};
2026-07-29 08:29:29 +00:00
export const getMentionTextWithUser = function getMentionTextWithUser(messageChannel, user) {
if (obj.hasSameRoleAsUsername(messageChannel, user)) {
const _HermesInternal2 = HermesInternal;
let combined = "" + tmp3 + user.tag;
} else {
const _HermesInternal = HermesInternal;
2026-08-24 06:08:38 +00:00
combined = "" + tmp3 + nameFromUserDefault.getUserTag(user);
const tmpResult = nameFromUserDefault;
2026-07-29 08:29:29 +00:00
}
return combined;
};
2026-07-20 16:05:17 +00:00
export const getItemSeparator = function getItemSeparator() {
return <AutocompleteFormDivider />;
};
export const getPrefix = function getPrefix(substr1) {
return substr1[0];
};
export const getQuery = function getQuery(arr) {
return arr.slice(1).toLowerCase();
};
2026-07-30 10:14:41 +00:00
export const isWhitespaceSeparatingBoundary = function isWhitespaceSeparatingBoundary(c22, index) {
2026-07-29 08:29:29 +00:00
let isMatch = 0 === index;
2026-07-24 07:16:23 +00:00
if (!isMatch) {
2026-07-30 10:14:41 +00:00
isMatch = regex.test(c22[index - 1]);
2026-07-24 07:16:23 +00:00
}
return isMatch;
};
2026-07-29 08:29:29 +00:00
export const isUnbrokenRun = function isUnbrokenRun(arr, arg1, arg2) {
return !regex.test(arr.slice(arg1, arg2));
2026-07-24 07:16:23 +00:00
};
2026-08-04 08:36:32 +00:00
export const findWordStart = function findWordStart(arg0, arg1) {
let tmp = arg1;
if (arg1 > 0) {
let tmp4 = arg1;
tmp = arg1;
if (!regex.test(arg0[arg1 - 1])) {
const diff = tmp4 - 1;
tmp = diff;
while (diff > 0) {
let tmp6 = regex;
tmp4 = diff;
tmp = diff;
if (regex.test(arg0[diff - 1])) {
break;
}
}
}
}
return tmp;
};
export const isSpaceJustTypedAtCaret = function isSpaceJustTypedAtCaret(text, selectionEnd, arr, arg3) {
let sum = arg3;
if (arg3 === selectionEnd + 1) {
if (arr.length === text.length + 1) {
if (" " === arr[sum - 1]) {
let num = 0;
if (0 < selectionEnd) {
while (arr[num] === text[num]) {
num = num + 1;
}
return false;
}
if (sum < arr.length) {
while (arr[sum] === text[sum - 1]) {
sum = sum + 1;
}
return false;
}
return true;
}
}
}
return false;
};
export const findAutoInsertOnSpaceToken = function findAutoInsertOnSpaceToken(arr, arg1, closure_18) {
if (arg1 >= closure_18.length + 2) {
if (" " === arr[arg1 - 1]) {
const diff = arg1 - 1;
let tmp3 = diff;
if (0 < diff) {
let tmp2 = diff;
tmp3 = diff;
if (!regex.test(arr[diff - 1])) {
const diff1 = tmp2 - 1;
tmp3 = diff1;
while (0 < diff1) {
let tmp5 = regex;
tmp2 = diff1;
tmp3 = diff1;
if (regex.test(arr[diff1 - 1])) {
break;
}
}
}
}
if (arr.startsWith(closure_18, tmp3)) {
if (arr.lastIndexOf(closure_18, diff - closure_18.length) !== tmp3) {
return null;
} else {
const obj = { tokenStart: null, trigger: null };
obj[0] = tmp3;
obj[1] = arr.slice(tmp3 + closure_18.length, diff);
return obj;
}
} else {
return null;
}
}
}
return null;
};