This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

+447
View File
@@ -0,0 +1,447 @@
// Metro module 6164 (f6165).
import ThreadMemberListStore from "../threads/ThreadMemberListStore";
import LinkRecord from "../../records/LinkRecord";
import { GUILD_VOCAL_CHANNELS_KEY } from "../../stores/GuildChannelStore";
import RelationshipStore from "../../stores/RelationshipStore";
import UserStore from "../../stores/UserStore";
import { AutocompleterResultTypes } from "./AutocompleterConstants";
import AutocompleteUtils, { getBoosterMap, calculateScore, getGameProfileMatchTier } from "../../utils/AutocompleteUtils";
import UserSearchManager from "./UserSearchManager";
import { FrecencyUserSettingsActionCreators } from "../user_settings/UserSettingsProtoActionCreators";
import GuildUtils from "../../utils/GuildUtils";
import { queryGamesAutocomplete } from "../games/autocomplete/queryGamesAutocomplete";
import * as _StringUtils from "../../utils/StringUtils";
import { findCodedLink } from "../coded_links/findCodedLinks";
import { CodedLinkType } from "../coded_links/CodedLink";
import Module3888 from "../../_bundle/Module3888";
import URLUtils from "../../utils/URLUtils";
import Module12 from "../../_bundle/Module12";
import sortByMatchScore from "./sortByMatchScore";
let options;
const getAutocompleterBoosterMap = function getAutocompleterBoosterMap(a0, options) {
return options.frecencyBoosters ? getBoosterMap(a0) : {};
};
options = Object.freeze({});
class Autocompleter {
constructor(a0, a1, _limit = 100, r7 = options, _refetchForSingleCategoryLimit = 0) {
this.query = "";
this.options = options;
this.results = [];
this._userResults = [];
this._groupDMResults = [];
this._textChannelResults = [];
this._voiceChannelResults = [];
this._guildResults = [];
this._applicationResults = [];
this._gameProfileResults = [];
this._linkResults = [];
this._inAppNavigations = [];
this._userBlacklist = null;
this._refetched = false;
this.parseUserResults = ({ results }) => {
if (this._include(AutocompleterResultTypes.USER)) {
this._userResults = [];
for (const item of results) {
const { id, score, comparator } = item;
const user = UserStore.getUser(id);
const record = user;
if (user != null) {
const _userResults = this._userResults;
const r49 = {
type: AutocompleterResultTypes.USER,
record,
score: calculateScore(score),
comparator: null
};
let comparator2 = comparator;
if (comparator2 == null) {
comparator2 = void 0;
}
r49.comparator = comparator2;
_userResults.push(r49);
}
}
const r62 = this._willRefetchIfSingleCategoryResults();
let r63 = !r62;
if (!r62) {
r63 = this._userResults.length > this._limit;
}
if (r63) {
this._userResults.length = this._limit;
}
if (r62) {
this.refetchIfSingleCategoryResults();
}
this.updateAllResults();
}
};
this.updateAllResults = () => {
const r3 = clearTimeout;
r3(this._asyncTimeout);
this.results = Module12([...this._userResults, ...this._groupDMResults, ...this._textChannelResults, ...this._voiceChannelResults, ...this._guildResults, ...this._gameProfileResults, ...this._linkResults, ...this._inAppNavigations]).uniqBy((item) => `${item.type}-${item.record.id}`).sort(sortByMatchScore).value();
this.onResultsChange(this.results, this.query);
};
this.onResultsChange = a0;
this.setOptions(r7, true);
this._limit = _limit;
this._refetchForSingleCategoryLimit = _refetchForSingleCategoryLimit;
this.createSearchContext();
this.setResultTypes(a1);
}
createSearchContext() {
if (this.userSearchContext == null) {
this.userSearchContext = UserSearchManager.getUserSearchContext(this.parseUserResults, this._limit);
}
}
setLimit(a0) {
const userSearchContext = this.userSearchContext;
this._limit = a0;
if (userSearchContext != null) {
userSearchContext.setLimit(a0);
}
if (this._userResults.length > this._limit) {
this._userResults.length = this._limit;
}
if (this._groupDMResults.length > this._limit) {
this._groupDMResults.length = this._limit;
}
if (this._textChannelResults.length > this._limit) {
this._textChannelResults.length = this._limit;
}
if (this._voiceChannelResults.length > this._limit) {
this._voiceChannelResults.length = this._limit;
}
if (this._guildResults.length > this._limit) {
this._guildResults.length = this._limit;
}
if (this._applicationResults.length > this._limit) {
this._applicationResults.length = this._limit;
}
if (this._gameProfileResults.length > this._limit) {
this._gameProfileResults.length = this._limit;
}
if (this._linkResults.length > this._limit) {
this._linkResults.length = this._limit;
}
if (this._inAppNavigations.length > this._limit) {
this._inAppNavigations.length = this._limit;
}
}
setRefetchForSingleCategoryLimit(a0) {
this._refetchForSingleCategoryLimit = a0;
}
setResultTypes(a0) {
this.resultTypes = a0 != null ? new Set(a0) : null;
this._userResults = this._include(AutocompleterResultTypes.USER) ? this._userResults : [];
this._groupDMResults = this._include(AutocompleterResultTypes.GROUP_DM) ? this._groupDMResults : [];
this._textChannelResults = this._include(AutocompleterResultTypes.TEXT_CHANNEL) ? this._textChannelResults : [];
this._voiceChannelResults = this._include(AutocompleterResultTypes.VOICE_CHANNEL) ? this._voiceChannelResults : [];
this._guildResults = this._include(AutocompleterResultTypes.GUILD) ? this._guildResults : [];
this._applicationResults = this._include(AutocompleterResultTypes.APPLICATION) ? this._applicationResults : [];
this._gameProfileResults = this._include(AutocompleterResultTypes.GAME_PROFILE) ? this._gameProfileResults : [];
this._linkResults = this._include(AutocompleterResultTypes.LINK) ? this._linkResults : [];
this._inAppNavigations = this._include(AutocompleterResultTypes.IN_APP_NAVIGATION) ? this._inAppNavigations : [];
}
_include(a0) {
return this.resultTypes == null || this.resultTypes.has(a0);
}
_isAsyncSearch() {
let r8 = this._include(AutocompleterResultTypes.USER);
if (r8) {
const options2 = this.options;
r8 = (options2 == null ? void 0 : options2.userFilters?.thread) != null;
}
return r8;
}
setOptions(a0, r4 = false) {
this.options = r4 ? {
...this.options,
...a0
} : a0;
if (this.options.blacklist != null) {
this._userBlacklist = Array.from(this.options.blacklist).map((item) => item.startsWith("user:") ? item.replace("user:", "") : "").filter((item) => item !== "");
} else {
this._userBlacklist = null;
}
}
_willRefetchIfSingleCategoryResults() {
const r5 = this._refetched || this._refetchForSingleCategoryLimit <= 5;
return r5 ? !r5 : this.options.voiceChannelGuildFilter == null && this.options.userFilters == null && [this._userResults, this._groupDMResults, this._textChannelResults, this._voiceChannelResults, this._guildResults, this._applicationResults, this._gameProfileResults, this._linkResults, this._inAppNavigations].filter((item) => item.length > 0).length === 1;
}
refetchIfSingleCategoryResults() {
if (this._willRefetchIfSingleCategoryResults()) {
this._refetched = true;
const query = this.query;
if (this._userResults.length > 0) {
this.queryUsers(query, null, this._refetchForSingleCategoryLimit);
} else if (this._groupDMResults.length > 0) {
this._groupDMResults = this.queryGroupDMs(query, this._refetchForSingleCategoryLimit);
} else if (this._textChannelResults.length > 0) {
this._textChannelResults = this.queryTextChannels(query, this._refetchForSingleCategoryLimit);
} else if (this._voiceChannelResults.length > 0) {
this._voiceChannelResults = this.queryVoiceChannels(query, this._refetchForSingleCategoryLimit);
} else if (this._guildResults.length > 0) {
this._guildResults = this.queryGuilds(query, this._refetchForSingleCategoryLimit);
} else if (this._applicationResults.length > 0) {
this._applicationResults = this.queryApplications(query, this._refetchForSingleCategoryLimit);
} else if (this._gameProfileResults.length > 0) {
this._gameProfileResults = this.queryGameProfiles(query, this._refetchForSingleCategoryLimit);
} else if (this._linkResults.length > 0) {
this._linkResults = this.queryLink(query, this._refetchForSingleCategoryLimit);
} else if (this._inAppNavigations.length > 0) {
this._inAppNavigations = this.queryInAppNavigations(query, this._refetchForSingleCategoryLimit);
}
}
}
search(a0, c15541_0) {
this.query = a0;
this._refetched = false;
if (a0.trim() === "") {
this.clear();
this.updateAllResults();
return void 0;
}
(this.options.frecencyBoosters ? FrecencyUserSettingsActionCreators.loadIfNecessary() : Promise.resolve()).finally(() => {
this.queryUsers(a0, c15541_0, this._limit);
this._groupDMResults = this.queryGroupDMs(a0, this._limit);
this._textChannelResults = this.queryTextChannels(a0, this._limit);
this._voiceChannelResults = this.queryVoiceChannels(a0, this._limit);
this._guildResults = this.queryGuilds(a0, this._limit);
this._applicationResults = this.queryApplications(a0, this._limit);
this._gameProfileResults = this.queryGameProfiles(a0, this._limit);
this._inAppNavigations = this.queryInAppNavigations(a0, this._limit);
if (this._isAsyncSearch()) {
clearTimeout(this._asyncTimeout);
this._asyncTimeout = setTimeout(this.updateAllResults, 300);
} else if (!this._include(AutocompleterResultTypes.USER)) {
this.updateAllResults();
}
});
}
clear() {
const userSearchContext = this.userSearchContext;
if (userSearchContext != null) {
userSearchContext.clearQuery();
}
this.results = [];
this._userResults = [];
this._groupDMResults = [];
this._textChannelResults = [];
this._voiceChannelResults = [];
this._guildResults = [];
this._applicationResults = [];
this._gameProfileResults = [];
this._linkResults = [];
this._inAppNavigations = [];
}
clean() {
this.clear();
this.destroy();
this.query = "";
this.updateAllResults();
}
pause() {
const userSearchContext = this.userSearchContext;
if (userSearchContext != null) {
const unsubscribe = userSearchContext.unsubscribe;
if (unsubscribe != null) {
unsubscribe.call(userSearchContext);
}
}
}
resume() {
const userSearchContext = this.userSearchContext;
if (userSearchContext != null) {
const subscribe = userSearchContext.subscribe;
if (subscribe != null) {
subscribe.call(userSearchContext);
}
}
}
destroy() {
const userSearchContext = this.userSearchContext;
if (userSearchContext != null) {
userSearchContext.destroy();
this.userSearchContext = null;
}
}
queryTextChannels(a0, a1) {
if (this._include(AutocompleterResultTypes.TEXT_CHANNEL)) {
const TEXT_CHANNEL = AutocompleterResultTypes.TEXT_CHANNEL;
const boosters = this.options.frecencyBoosters ? getBoosterMap(TEXT_CHANNEL) : {};
const options2 = this.options;
const { allowSnowflake, blacklist } = options2;
return AutocompleteUtils.queryChannels({
query: a0,
guildId: null,
limit: a1,
fuzzy: true,
allowSnowflake,
filter: blacklist != null ? (a0) => !blacklist.has(`channel:${a0.id}`) : void 0,
boosters
});
}
return [];
}
queryVoiceChannels(a0, a1) {
if (this._include(AutocompleterResultTypes.VOICE_CHANNEL)) {
const options2 = this.options;
const { allowSnowflake, voiceChannelGuildFilter } = options2;
const VOICE_CHANNEL = AutocompleterResultTypes.VOICE_CHANNEL;
return AutocompleteUtils.queryChannels({
query: a0,
guildId: voiceChannelGuildFilter,
limit: a1,
fuzzy: true,
type: GUILD_VOCAL_CHANNELS_KEY,
allowSnowflake,
boosters: this.options.frecencyBoosters ? getBoosterMap(VOICE_CHANNEL) : {}
});
}
return [];
}
queryGuilds(a0, a1) {
if (this._include(AutocompleterResultTypes.GUILD)) {
const GUILD = AutocompleterResultTypes.GUILD;
const boosters = this.options.frecencyBoosters ? getBoosterMap(GUILD) : {};
const options2 = this.options;
const { allowSnowflake, blacklist: blacklist2 } = options2;
return AutocompleteUtils.queryGuilds({
query: a0,
limit: a1,
fuzzy: true,
filter: blacklist2 != null ? (a0) => !blacklist2.has(`guild:${a0.id}`) : void 0,
boosters,
allowSnowflake
});
}
return [];
}
queryUsers(a0, a1, a2) {
const userSearchContext = this.userSearchContext;
if (userSearchContext != null && this._include(AutocompleterResultTypes.USER)) {
const options2 = this.options;
const { allowSnowflake, userFilters } = options2;
const autocompleterBoosterMap = getAutocompleterBoosterMap(AutocompleterResultTypes.USER, this.options);
if (userFilters?.thread == null) {
if (a1 !== void 0) {
GuildUtils.requestMembers(a1, a0, 100);
}
userSearchContext.setLimit(a2);
userSearchContext.setQuery({
query: a0,
filters: userFilters,
blacklist: this._userBlacklist,
boosters: autocompleterBoosterMap
});
} else {
const memberListSections = ThreadMemberListStore.getMemberListSections(userFilters.thread);
const users = [];
for (const key in memberListSections) {
const r51 = memberListSections[key];
for (const userId of r51.userIds) {
let r59 = userFilters?.friends && !RelationshipStore.isFriend(userId);
if (!r59) {
const _userBlacklist = this._userBlacklist;
r59 = _userBlacklist == null ? void 0 : _userBlacklist.includes(userId);
}
if (!r59) {
const userId2 = userId;
users.push({
userId: userId2,
nick: r51.usersById[userId2]?.displayName
});
}
}
}
this._userResults = AutocompleteUtils.queryUsers({
query: a0,
users,
limit: a2,
boosters: autocompleterBoosterMap,
allowSnowflake
});
}
}
}
queryGroupDMs(a0, a1) {
if (this._include(AutocompleterResultTypes.GROUP_DM)) {
const blacklist3 = this.options.blacklist;
const GROUP_DM = AutocompleterResultTypes.GROUP_DM;
return AutocompleteUtils.queryGroupDMs({
query: a0,
limit: a1,
fuzzy: true,
filter: blacklist3 != null ? (a0) => !blacklist3.has(`channel:${a0.id}`) : void 0,
boosters: this.options.frecencyBoosters ? getBoosterMap(GROUP_DM) : {}
});
}
return [];
}
queryApplications(a0, a1) {
return this._include(AutocompleterResultTypes.APPLICATION) ? AutocompleteUtils.queryApplications({
query: a0,
limit: a1,
fuzzy: true
}) : [];
}
queryGameProfiles(a0, a1) {
if (this._include(AutocompleterResultTypes.GAME_PROFILE)) {
let r15 = queryGamesAutocomplete(a0);
if (r15 == null) {
r15 = [];
}
let c15545_0 = a0.toLocaleLowerCase();
return r15.slice(0, a1).map((item, index) => ({
type: AutocompleterResultTypes.GAME_PROFILE,
record: item,
score: calculateScore(getGameProfileMatchTier(item.name, c15545_0, index)),
comparator: item.name,
sortable: item.name.toLocaleLowerCase()
}));
}
return [];
}
refreshGameProfiles() {
const isNullOrEmpty = _StringUtils.isNullOrEmpty(this.query.trim());
if (isNullOrEmpty ? !isNullOrEmpty : this._include(AutocompleterResultTypes.GAME_PROFILE)) {
this._gameProfileResults = this.queryGameProfiles(this.query, this._limit);
this.updateAllResults();
}
}
queryLink(a0) {
let uRL;
if (this._include(AutocompleterResultTypes.LINK)) {
const r22 = findCodedLink(a0);
if (r22?.type === CodedLinkType.INVITE) {
return [{
type: AutocompleterResultTypes.LINK,
record: LinkRecord.fromInviteCode(r22.code),
score: calculateScore(11)
}];
}
const r12 = Module3888.sanitizeUrl(a0);
try {
uRL = new URL(r12);
} catch ($e) {
return [];
}
const { pathname, hostname = "", host } = uRL;
const r42 = URLUtils.isDiscordHostname(hostname) || window.location.host === host;
return pathname !== null && (r42 && URLUtils.isAppRoute(pathname)) ? [{
type: AutocompleterResultTypes.LINK,
record: LinkRecord.fromPath(pathname),
score: calculateScore(11)
}] : [];
}
return [];
}
queryInAppNavigations(a0, a1) {
return this._include(AutocompleterResultTypes.IN_APP_NAVIGATION) ? AutocompleteUtils.queryInAppNavigations({
query: a0,
limit: a1,
fuzzy: true
}) : [];
}
}
export default Autocompleter;
@@ -0,0 +1,35 @@
// Metro module 5100 (f5101).
const r10 = {
UP: "UP",
DOWN: "DOWN"
};
const r13 = {
GUILD: "GUILD",
TEXT_CHANNEL: "TEXT_CHANNEL",
GROUP_DM: "GROUP_DM",
VOICE_CHANNEL: "VOICE_CHANNEL",
USER: "USER",
HEADER: "HEADER",
APPLICATION: "APPLICATION",
GAME_PROFILE: "GAME_PROFILE",
SKU: "SKU",
LINK: "LINK",
IN_APP_NAVIGATION: "IN_APP_NAVIGATION",
DM: "DM"
};
const r26 = {
USER: "@",
TEXT_CHANNEL: "#",
VOICE_CHANNEL: "!",
GUILD: "*",
GAME_PROFILE: "$"
};
export class HeaderRecord {
constructor(a0) {
this.id = a0;
this.text = a0;
}
}
export { r10 as FindResultDirections };
export { r13 as AutocompleterResultTypes };
export { r26 as AutocompleterQuerySymbols };
+716
View File
@@ -0,0 +1,716 @@
// Metro module 6167 (f6168).
import { isPrivate } from "../../records/ChannelRecord";
import UserRecord from "../../records/UserRecord";
import ChannelStore from "../../stores/ChannelStore";
import GuildMemberStore from "../../stores/GuildMemberStore";
import RelationshipStore from "../../stores/RelationshipStore";
import UserStore from "../../stores/UserStore";
import { UserFlags } from "../../Constants";
import UserUtils from "../../utils/UserUtils";
import { hasFlag } from "../../_bundle/Module1384";
import { v4 } from "../../_bundle/Module514";
import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager";
import * as _UserSearch_worker from "./native/UserSearch.worker";
import { isNotNullish } from "../../utils/GlobalUtils";
import SentryUtils_native from "../../utils/SentryUtils.native";
import Module12 from "../../_bundle/Module12";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
function $mk77900($env) {
return (a0) => {
const r2 = $env;
const r3 = $env.$parent;
const r9 = (0, r3[12])(r3[9].getUser(a0));
const r10 = r2[0];
if (r10 != null) {
const id2 = r10.id;
if (r9 != null) {
r9.nicknames[id2] = null;
}
}
r2[1].push(r9);
};
}
function $mk77901($env) {
return (a0) => {
const r11 = (0, $env.$parent[12])(a0.user);
if (r11 != null) {
const r12 = $env;
const r7 = r12[0];
const nick = a0.nick;
if (r11 != null) {
r11.nicknames[r7] = nick != null ? nick !== "" ? nick : null : null;
}
r12[1].push(r11);
}
};
}
function $mk77903($env) {
return ({ data }) => {
let r0 = data != null && data.type === $env.$parent[11].USER_RESULTS;
const r10 = $env;
if (r0) {
r0 = data.uuid === r10[0]._uuid;
}
if (r0) {
const r13 = r10[0];
if (r13._currentQuery !== false) {
r13._callback(data.payload);
}
if (r13._currentQuery != null) {
r13._currentQuery = null;
}
r13._setNextQuery();
}
};
}
let setNick, getDMUpdates, updateMembersList, getUsersFromMessage, c3907_11, c3907_18;
let env3907 = {};
const getTransformedUser = function getTransformedUser(a0) {
let isProvisional, isStaff;
if (a0 != null) {
if (!RelationshipStore.isBlockedOrIgnored(a0.id)) {
const r17 = {
id: a0.id,
username: a0.discriminator !== "0" ? `${a0.username}#${a0.discriminator}` : a0.username,
nicknames: {}
};
if (UserUtils.getGlobalName(a0) != null) {
r17.globalName = a0.globalName;
}
if (a0.bot) {
r17.isBot = true;
}
if (a0 instanceof UserRecord) {
isProvisional = a0.isProvisional;
} else {
isProvisional = "flags" in a0;
if (isProvisional) {
let flags = a0.flags;
if (flags == null) {
flags = 0;
}
isProvisional = hasFlag(flags, UserFlags.PROVISIONAL_ACCOUNT);
}
}
r17.isProvisional = isProvisional;
if (RelationshipStore.isFriend(a0.id)) {
r17.isFriend = true;
r17.friendNickname = RelationshipStore.getNickname(a0.id);
}
if (a0 instanceof UserRecord) {
isStaff = a0.isStaff();
} else {
isStaff = "flags" in a0;
if (isStaff) {
let flags2 = a0.flags;
if (flags2 == null) {
flags2 = 0;
}
isStaff = hasFlag(flags2, UserFlags.STAFF);
}
}
r17.isStaff = isStaff;
return r17;
}
}
return null;
};
setNick = function setNick(a0, a1, a2) {
if (a0 != null) {
a0.nicknames[a1] = a2 != null ? a2 !== "" ? a2 : null : null;
}
};
getDMUpdates = function getDMUpdates(a0) {
let env15550;
const r2 = env15550 = {
$parent: env3907
};
env15550[0] = a0;
const r1 = [];
env15550[1] = r1;
if (a0 != null && (0, isPrivate)(a0.type)) {
let recipients = a0.recipients;
if (recipients === void 0) {
recipients = [];
}
recipients.forEach($mk77900(r2));
return r1;
}
return r1;
};
updateMembersList = function updateMembersList(a0, a1) {
let env15551;
const r1 = env15551 = {
$parent: env3907
};
env15551[0] = a1;
const r4 = [];
env15551[1] = r4;
a0.forEach($mk77901(r1));
return r4;
};
getUsersFromMessage = function getUsersFromMessage(a0) {
const message = a0.message;
let nicknameContextId = a0.nicknameContextId;
const channel = ChannelStore.getChannel(message.channel_id);
if (nicknameContextId == null) {
nicknameContextId = (channel == null ? void 0 : channel.isPrivate()) === true ? channel?.id : channel == null ? void 0 : channel.getGuildId();
}
const id = nicknameContextId;
const r21 = [];
let c15552_1 = r21;
if (message.author != null) {
const transformedUser = getTransformedUser(message.author);
if (transformedUser != null) {
r21.push(transformedUser);
if (id != null && transformedUser != null) {
transformedUser.nicknames[id] = null;
}
}
}
const mentions = message.mentions;
if (mentions != null) {
mentions.forEach((mention) => {
const transformedUser = getTransformedUser(mention);
if (transformedUser != null) {
c15552_1.push(transformedUser);
if (id != null && transformedUser != null) {
transformedUser.nicknames[id] = null;
}
}
});
}
return r21;
};
c3907_11 = {
UPDATE_USERS: "UPDATE_USERS",
USER_RESULTS: "USER_RESULTS",
QUERY_SET: "QUERY_SET",
QUERY_CLEAR: "QUERY_CLEAR",
REQUEST_DEBUG_STATE: "REQUEST_DEBUG_STATE",
DEBUG_STATE: "DEBUG_STATE"
};
export class UserSearchContext {
constructor(a0, a1, _limit = 10) {
let env15553;
const r7 = env15553 = {
$parent: env3907
};
env15553[0] = this;
this.handleMessages = $mk77903(r7);
this._worker = a0;
this._uuid = v4();
this._callback = a1;
this._limit = _limit;
this._currentQuery = null;
this._nextQuery = null;
this._subscribed = false;
this.subscribe();
}
setLimit(a0) {
this._limit = a0;
if (this._nextQuery != null) {
this._nextQuery.limit = a0;
}
}
subscribe() {
if (!(this._worker == null || this._subscribed)) {
this._worker.addEventListener("message", this.handleMessages, false);
this._subscribed = true;
this._setNextQuery();
}
}
unsubscribe() {
if (this._worker != null && this._subscribed) {
this._worker.removeEventListener("message", this.handleMessages, false);
this._subscribed = false;
}
}
destroy() {
this.clearQuery();
this.unsubscribe();
}
clearQuery() {
this._currentQuery = false;
this._nextQuery = null;
if (this._worker != null && this._subscribed) {
this._worker.postMessage({
uuid: this._uuid,
type: c3907_11.QUERY_CLEAR
});
}
}
setQuery(a0) {
const { query, filters, blacklist } = a0;
let boosters = a0.boosters;
let boosterFallback = a0.boosterFallback;
if (boosters == null) {
boosters = {};
}
if (boosterFallback == null) {
boosterFallback = 1;
}
this._nextQuery = {
query,
filters,
blacklist,
boosters,
boosterFallback,
limit: this._limit
};
this._setNextQuery();
}
_setNextQuery() {
const r0 = this._currentQuery != null && this._currentQuery !== false || this._nextQuery == null;
L10: {
if (!r0) {
if (this._worker != null && this._subscribed) {
this._currentQuery = this._nextQuery;
this._nextQuery = null;
this._worker.postMessage({
uuid: this._uuid,
type: c3907_11.QUERY_SET,
payload: this._currentQuery
});
break L10;
}
if (!this._subscribed) {
this.subscribe();
}
}
}
}
}
class UserSearchManager extends AutomaticLifecycleManager {
actions = {
LOGOUT: () => this._handleLogout(),
POST_CONNECTION_OPEN: () => this._handleConnectionOpen(),
CONNECTION_OPEN_SUPPLEMENTAL: (a0) => this._handleConnectionOpenSupplemental(a0),
OVERLAY_INITIALIZE: (a0) => this._handleOverlayInitialize(a0),
CURRENT_USER_UPDATE: (a0) => this._handleCurrentUserUpdate(a0),
GUILD_CREATE: (a0) => this._handleGuildCreate(a0),
GUILD_MEMBERS_CHUNK_BATCH: (a0) => this._handleGuildMembersChunkBatch(a0),
GUILD_MEMBER_ADD: (a0) => this._handleGuildMemberUpdate(a0),
GUILD_MEMBER_UPDATE: (a0) => this._handleGuildMemberUpdate(a0),
RELATIONSHIP_ADD: (a0) => this._handleRelationshipAdd(a0),
RELATIONSHIP_UPDATE: (a0) => this._handleRelationshipUpdate(a0),
RELATIONSHIP_REMOVE: (a0) => this._handleRelationshipRemove(a0),
CHANNEL_CREATE: (a0) => this._handleDMCreate(a0),
CHANNEL_UPDATES: (a0) => this._handleDMUpdates(a0),
CHANNEL_RECIPIENT_ADD: (a0) => this._handleRecipientChanges(a0),
PASSIVE_UPDATE_V2: (a0) => this._handlePassiveUpdateV2(a0),
THREAD_LIST_SYNC: (a0) => this._handleThreadListSync(a0),
LOAD_FORUM_POSTS: (a0) => this._handleLoadForumPosts(a0),
LOAD_MESSAGES_SUCCESS: (a0) => this._handleLoadMessagesSuccess(a0),
SEARCH_MESSAGES_SUCCESS: (a0) => this._handleSearchMessagesSuccess(a0),
LOAD_THREADS_SUCCESS: (a0) => this._handleLoadThreadsSuccess(a0),
LOAD_ARCHIVED_THREADS_SUCCESS: (a0) => this._handleLoadThreadsSuccess(a0),
LOAD_PINNED_MESSAGES_SUCCESS: (a0) => this._handleLoadPinnedMessagesSuccess(a0),
GUILD_SCHEDULED_EVENT_USERS_FETCH_SUCCESS: (a0) => this._handleGuildScheduledEventUsersFetchSuccess(a0),
MESSAGE_CREATE: (a0) => this._handleMessageCreateOrUpdate(a0),
MESSAGE_UPDATE: (a0) => this._handleMessageCreateOrUpdate(a0)
};
_handleLogout = () => {
this.rebootWebworker();
};
_handleConnectionOpen = () => {
setTimeout(() => {
const currentUser = UserStore.getCurrentUser();
if (currentUser != null) {
const transformedUser = getTransformedUser(currentUser);
const r11 = {};
r11[transformedUser.id] = transformedUser;
let c29679_0 = r11;
Object.values(UserStore.getUsers()).forEach((item) => {
c29679_0[item.id] = getTransformedUser(item);
});
const mutableAllGuildsAndMembers = GuildMemberStore.getMutableAllGuildsAndMembers();
for (const key in mutableAllGuildsAndMembers) {
const r37 = mutableAllGuildsAndMembers[key];
for (const key2 in r37) {
const r19 = r11[key2];
let r42 = mutableAllGuildsAndMembers[key][key2]?.nick;
if (r42 == null) {
r42 = UserUtils.getGlobalName(r19);
}
if (r19 != null && r19 != null) {
r19.nicknames[key] = r42 != null ? r42 !== "" ? r42 : null : null;
}
}
}
this.updateUsers(Object.values(r11), "connection_open");
}
}, 3000);
};
_handleConnectionOpenSupplemental = ({ guilds }) => {
setTimeout(() => {
this.updateUsers([...Module12.flatMap(guilds, ({ members, id: id2 }) => {
let env31397;
const r1 = env31397 = {
$parent: env3907
};
env31397[0] = id2;
const r5 = [];
env31397[1] = r5;
members.forEach($mk77901(r1));
return r5;
}), ...Module12.flatMap(guilds, (a0) => {
const r1 = [];
let c31398_1 = r1;
const activity_instances = a0.activity_instances;
if (activity_instances != null) {
activity_instances.forEach((activity_instance) => {
activity_instance.participants.forEach(({ member }) => {
if (member != null) {
const transformedUser = getTransformedUser(member.user);
if (transformedUser != null) {
const id2 = a0.id;
const nick = member.nick;
if (transformedUser != null) {
transformedUser.nicknames[id2] = nick != null ? nick !== "" ? nick : null : null;
}
c31398_1.push(transformedUser);
}
}
});
});
}
return r1;
})], "connection_open_supplemental");
}, 3000);
};
_handleOverlayInitialize = ({ users, guildMembers }) => {
const map = new Map();
for (const item of users) {
map.set(item.id, getTransformedUser(item));
}
for (const item3 of SnowflakeUtils.keys(guildMembers)) {
const r60 = guildMembers[item3];
if (r60 != null) {
for (const item2 of SnowflakeUtils.keys(r60)) {
const r76 = map.get(item2);
const r78 = r60[item2];
if (r76 != null && r78 != null && r78.nick != null) {
setNick(r76, item3, r78.nick);
map.set(item2, r76);
}
}
}
}
this.updateUsers(Array.from(map.values()), "overlay_initialize");
map.clear();
};
_handleCurrentUserUpdate = (a0) => {
const transformedUser = getTransformedUser(a0.user);
if (transformedUser != null) {
this.updateUsers([transformedUser], "current_user_update");
}
};
_handleGuildCreate = ({ guild }) => {
let env25730;
const { members, id: id2 } = guild;
const r10 = env25730 = {
$parent: env3907
};
env25730[0] = id2;
const r11 = [];
env25730[1] = r11;
members.forEach($mk77901(r10));
this.updateUsers(r11, "guild_create");
};
_handleGuildMembersChunkBatch = ({ chunks }) => {
const r4 = [];
for (const item of chunks) {
r4.push.apply(r4, [...updateMembersList(item.members, item.guildId)]);
}
this.updateUsers(r4, "guild_members_chunk_batch");
};
_handleGuildMemberUpdate = ({ guildId: guildId5, user, nick }) => {
const transformedUser = getTransformedUser(user);
if (transformedUser != null) {
if (transformedUser != null) {
transformedUser.nicknames[guildId5] = nick != null ? nick !== "" ? nick : null : null;
}
this.updateUsers([transformedUser], "guild_member_update");
}
};
_handlePassiveUpdateV2 = ({ members, guildId: guildId5 }) => {
let env25731;
const r9 = env25731 = {
$parent: env3907
};
env25731[0] = guildId5;
const r10 = [];
env25731[1] = r10;
members.forEach($mk77901(r9));
this.updateUsers(r10, "passive_update_v2");
};
_handleRelationshipAdd = (a0) => {
this.updateUsers([getTransformedUser(a0.relationship.user)], "relationship_add");
};
_handleRelationshipUpdate = (a0) => {
this.updateUsers([getTransformedUser(UserStore.getUser(a0.relationship.id))], "relationship_update");
};
_handleRelationshipRemove = (a0) => {
this.updateUsers([getTransformedUser(UserStore.getUser(a0.relationship.id))], "relationship_remove");
};
_handleDMCreate = (a0) => {
let env25732;
const id2 = a0.channel.id;
const r11 = env3907;
const channel = ChannelStore.getChannel(id2);
const r12 = env25732 = {
$parent: r11
};
env25732[0] = channel;
const r13 = [];
env25732[1] = r13;
if (channel != null && (0, isPrivate)(channel.type)) {
let recipients = channel.recipients;
if (recipients === void 0) {
recipients = [];
}
recipients.forEach($mk77900(r12));
}
if (r13.length !== 0) {
const transformedUser = getTransformedUser(UserStore.getCurrentUser());
if (transformedUser != null) {
transformedUser.nicknames[id2] = null;
}
r13.push(transformedUser);
this.updateUsers(r13, "dm_create");
}
};
_handleDMUpdates = (a0) => {
for (const channel of a0.channels) {
const dMUpdates = getDMUpdates(ChannelStore.getChannel(channel.id));
if (dMUpdates.length !== 0) {
const transformedUser = getTransformedUser(UserStore.getCurrentUser());
setNick(transformedUser, channel.id);
dMUpdates.push(transformedUser);
this.updateUsers(dMUpdates, "dm_updates");
}
}
};
_handleRecipientChanges = (a0) => {
const { channelId, user } = a0;
if (a0.isMember) {
const transformedUser = getTransformedUser(user);
if (transformedUser != null) {
transformedUser.nicknames[channelId] = null;
}
this.updateUsers([transformedUser], "recipient_changes");
}
};
_handleThreadListSync = ({ guildId, mostRecentMessages }) => {
let c25733_1;
c25733_1 = void 0;
if (mostRecentMessages != null) {
const r5 = [];
c25733_1 = r5;
mostRecentMessages.forEach((mostRecentMessage) => {
getUsersFromMessage({
message: mostRecentMessage,
nicknameContextId: guildId
}).forEach((item) => c25733_1.push(item));
});
this.updateUsers(r5, "thread_list_sync");
}
};
_handleLoadForumPosts = ({ guildId: guildId2, threads }) => {
const r4 = [];
let c25734_1 = r4;
Object.values(threads).forEach(({ first_message, most_recent_message, owner }) => {
if (first_message != null) {
getUsersFromMessage({
message: first_message,
nicknameContextId: guildId2
}).forEach((item) => c25734_1.push(item));
}
if (most_recent_message != null) {
getUsersFromMessage({
message: most_recent_message,
nicknameContextId: guildId2
}).forEach((item) => c25734_1.push(item));
}
if (owner != null) {
let env29680;
const r24 = [owner];
const r27 = env29680 = {
$parent: env3907
};
env29680[0] = guildId2;
const r28 = [];
env29680[1] = r28;
r24.forEach($mk77901(r27));
r28.forEach((item) => c25734_1.push(item));
}
});
this.updateUsers(r4, "load_forum_posts");
};
_handleLoadMessagesSuccess = (a0) => {
this.updateUsers(a0.messages.flatMap((a0) => getUsersFromMessage({
message: a0
})), "load_messages_success");
};
_handleLoadPinnedMessagesSuccess = ({ pins }) => {
const r4 = [];
let c25735_0 = r4;
pins.forEach((pin) => {
getUsersFromMessage({
message: pin.message
}).forEach((item) => c25735_0.push(item));
});
this.updateUsers(r4, "load_pinned_messages_success");
};
_handleSearchMessagesSuccess = ({ data }) => {
const r4 = [];
let c25736_0 = r4;
data.forEach((a0) => {
a0.messages.forEach((a0) => {
a0.forEach((a0) => {
getUsersFromMessage({
message: a0
}).forEach((item) => c25736_0.push(item));
});
});
});
this.updateUsers(r4, "search_messages_success");
};
_handleLoadThreadsSuccess = (a0) => {
const r2 = env3907;
const { guildId: guildId3, firstMessages, mostRecentMessages, owners } = a0;
const r10 = [];
let c25737_1 = r10;
if (firstMessages != null) {
firstMessages.forEach((firstMessage) => {
getUsersFromMessage({
message: firstMessage,
nicknameContextId: guildId3
}).forEach((item) => c25737_1.push(item));
});
}
if (mostRecentMessages != null) {
mostRecentMessages.forEach((mostRecentMessage) => {
getUsersFromMessage({
message: mostRecentMessage,
nicknameContextId: guildId3
}).forEach((item) => c25737_1.push(item));
});
}
if (owners != null) {
let env25738;
const r15 = env25738 = {
$parent: r2
};
env25738[0] = guildId3;
const r16 = [];
env25738[1] = r16;
owners.forEach($mk77901(r15));
r16.forEach((item) => c25737_1.push(item));
}
this.updateUsers(r10, "load_threads_success");
};
_handleMessageCreateOrUpdate = (a0) => {
this.updateUsers(getUsersFromMessage({
message: a0.message
}), "message_create_or_update");
};
_handleGuildScheduledEventUsersFetchSuccess = ({ guildId: guildId4, guildScheduledEventUsers }) => {
const r4 = [];
let c25739_1 = r4;
guildScheduledEventUsers.forEach(({ user, member }) => {
const transformedUser = getTransformedUser(user);
if (transformedUser != null) {
const nick = member?.nick;
if (transformedUser != null) {
transformedUser.nicknames[guildId4] = nick != null ? nick !== "" ? nick : null : null;
}
c25739_1.push(transformedUser);
}
});
this.updateUsers(r4, "guild_scheduled_event_users_fetch_success");
};
_initialize() {
this.rebootWebworker();
}
_terminate() {
if (this._worker != null) {
this._worker.terminate();
this._worker = null;
}
}
rebootWebworker() {
if (this._worker != null) {
this._worker.terminate();
this._worker = null;
}
this._worker = _UserSearch_worker;
}
updateUsers(a0, a1) {
const _worker = this._worker;
if (_worker != null) {
const payload = a0.filter(isNotNullish);
for (const item of payload) {
if (item?.id == null) {
const username = item?.username;
SentryUtils_native.addBreadcrumb({
category: "debug",
message: "User missing id",
data: {
action: a1,
userFields: {
userIsNull: item == null,
idIsNull: true,
usernameIsNull: username == null,
isBot: item?.isBot,
isFriend: item?.isFriend,
isProvisional: item?.isProvisional,
globalNameIsNull: item?.globalName == null,
usersArrayLength: payload.length
}
}
});
}
}
_worker.postMessage({
type: c3907_11.UPDATE_USERS,
payload
});
}
}
getUserSearchContext(a0, _limit = 10) {
this.initialize();
const _worker = this._worker;
if (_worker == null) {
throw new Error("SearchContextManager: No webworker initialized");
}
if (_limit === void 0) {
_limit = 10;
}
let env15555;
const r17 = {
__proto__: UserSearchContext.prototype
};
const r8 = env15555 = {
$parent: env3907
};
env15555[0] = r17;
r17.handleMessages = $mk77903(r8);
r17._worker = _worker;
r17._uuid = v4();
r17._callback = a0;
r17._limit = _limit;
r17._currentQuery = null;
r17._nextQuery = null;
r17._subscribed = false;
r17.subscribe();
return r17;
}
requestDebugState() {
return Promise.resolve(null);
}
}
c3907_18 = UserSearchManager;
const r79 = new UserSearchManager();
export default r79;
@@ -0,0 +1,9 @@
// Metro module 6172 (f6173).
import { AutocompleterResultTypes, HeaderRecord } from "./AutocompleterConstants";
export function createHeaderResult(a0) {
return {
type: AutocompleterResultTypes.HEADER,
record: new HeaderRecord(a0),
score: 0
};
}
@@ -0,0 +1,46 @@
// Metro module 6174 (f6175).
import ChannelStore from "../../stores/ChannelStore";
import RelationshipStore from "../../stores/RelationshipStore";
import UserStore from "../../stores/UserStore";
import { AutocompleterResultTypes } from "./AutocompleterConstants";
import { ChannelTypes } from "../../Constants";
import { computeChannelName } from "../channel/useChannelName";
export default function createAutocompleterResultForChannelId(a0, r7 = ChannelStore, r5 = UserStore, r4 = RelationshipStore) {
const channel = r7.getChannel(a0);
if (channel == null) {
return null;
}
const comparator = computeChannelName(channel, r5, r4);
const type = channel.type;
if (ChannelTypes.DM === type) {
const user = r5.getUser(channel.getRecipientId());
return user == null ? null : {
type: AutocompleterResultTypes.USER,
record: user,
score: 0,
comparator
};
}
if (ChannelTypes.GROUP_DM === type) {
return {
type: AutocompleterResultTypes.GROUP_DM,
record: channel,
score: 0,
comparator
};
}
if (ChannelTypes.GUILD_VOICE !== type && ChannelTypes.GUILD_STAGE_VOICE !== type) {
return {
type: AutocompleterResultTypes.TEXT_CHANNEL,
record: channel,
score: 0,
comparator
};
}
return {
type: AutocompleterResultTypes.VOICE_CHANNEL,
record: channel,
score: 0,
comparator
};
};
@@ -0,0 +1,34 @@
// Metro module 6173 (f6174).
import { AutocompleterResultTypes, FindResultDirections } from "./AutocompleterConstants";
const findNextSelectedResult = function findNextSelectedResult(a0, a1, a2, a3) {
let r25;
const length = a2.length;
if (length === 0) {
return 0;
}
let r9 = a1;
if (a3 != null) {
r9 = a3;
if (a3 === a1) {
return a1;
}
}
const r0 = a0 === FindResultDirections.UP ? -1 : 1;
L14: {
const r12 = a1 + r0;
const r21 = r12 < 0;
if (!r21 && !(r12 >= length)) {
const type = a2[r12].type;
const HEADER = AutocompleterResultTypes.HEADER;
r25 = r12;
if (type !== HEADER) {
break L14;
}
r25 = findNextSelectedResult(a0, r12, a2, r9);
} else {
r25 = findNextSelectedResult(a0, r21 ? length : -1, a2, r9);
}
}
return r25;
};
export default findNextSelectedResult;
+13
View File
@@ -0,0 +1,13 @@
// Metro module 6163 (f6164).
import Autocompleter from "./Autocompleter";
import * as _AutocompleterConstants from "./AutocompleterConstants";
import * as _createAutocompleterResult from "./createAutocompleterResult";
import findNextSelectedResult from "./findNextSelectedResult";
import sortByMatchScore from "./sortByMatchScore";
export default Autocompleter;
for (const key in _AutocompleterConstants) {
exports[key] = _AutocompleterConstants[key];
}
export const createHeaderResult = _createAutocompleterResult.createHeaderResult;
exports.findNextSelectedResult = findNextSelectedResult;
exports.sortByMatchScore = sortByMatchScore;
@@ -0,0 +1,180 @@
// Metro module 11485 (f11486).
import { useMemo } from "react";
import { View } from "react-native";
import GuildStore from "../../../stores/GuildStore";
import RelationshipStore from "../../../stores/RelationshipStore";
import UserStore from "../../../stores/UserStore";
import { ChannelTypes, Fonts } from "../../../Constants";
import { AUTOCOMPLETE_ROW_HEIGHT } from "../../application_commands/native/ApplicationCommandsConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { FormRow } from "../../../design/void/Form/native/index";
import { useStateFromStores } from "../../../_bundle/Module589";
import UserUtils from "../../../utils/UserUtils";
import { Avatar, AvatarSizes, Icon, LegacyText } from "../../../design/void/native";
import DiscordTag from "../../user_profile/native/DiscordTag";
import { TableRow } from "../../../design/components/TableRow/native/TableRow.native";
import { TableRowTrailingText } from "../../../design/components/TableRow/native/TableRowTrailingText.native";
import { intl, t } from "../../../intl/index.native";
import Module7903 from "../../../_bundle/Module7903";
import { getChannelIconWithGuild } from "../../../utils/native/ChannelUtils";
import { computeChannelName } from "../../channel/useChannelName";
import { Text } from "../../../design/components/Text/native/Text";
import FastImage from "../../../components_native/common/FastImage";
import ChannelAutocompleteEmojiUpsell from "../../channel_text_area/native/ChannelAutocompleteEmojiUpsell";
import { useShouldAnimateSticker } from "../../stickers/StickersHooks";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
import Sticker2 from "../../stickers/native/Sticker";
import Module12 from "../../../_bundle/Module12";
import getGameMediaRefURL from "../../games/getGameMediaRefURL";
import { isNullOrEmpty } from "../../../utils/StringUtils";
import { UnknownGameIcon } from "../../../design/components/Icon/native/redesign/generated/UnknownGameIcon";
let useStyles;
const AutocompleteLabel = function AutocompleteLabel(props) {
return <FormRow.Label style={useStyles().leading} text={props.text} />;
};
useStyles = createStyles({
row: {
height: AUTOCOMPLETE_ROW_HEIGHT,
paddingVertical: 0,
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH
},
leading: {
fontSize: 16,
color: Module712.colors.INTERACTIVE_TEXT_ACTIVE,
fontFamily: Fonts.PRIMARY_SEMIBOLD
},
trailing: {
fontSize: 14,
color: Module712.colors.TEXT_MUTED
},
username: {
color: Module712.unsafe_rawColors.PRIMARY_400
},
emoji: {
width: 32,
height: 32
},
emojiImage: {
resizeMode: "contain"
},
emojiText: {
lineHeight: 32,
fontSize: 27,
textAlign: "center",
color: Module712.colors.TEXT_DEFAULT
},
stickerContainer: {
width: 56,
height: 56,
marginHorizontal: 4,
justifyContent: "center",
alignItems: "center",
backgroundColor: Module712.colors.BACKGROUND_MOD_NORMAL,
borderRadius: Module712.radii.sm
},
commandChoiceLoadingContainer: {
flex: 1,
justifyContent: "center"
},
commandChoiceLoadingItem: {
backgroundColor: Module712.colors.BACKGROUND_MOD_MUTED,
height: 16,
borderRadius: Module712.radii.lg,
alignSelf: "flex-start"
},
autocompleteIcon: {
opacity: 0.6
},
gameIcon: {
width: 32,
height: 32,
borderRadius: Module712.radii.sm
},
labelRow: {
flexDirection: "row",
alignItems: "center",
gap: Module712.space.PX_8
}
});
const r101 = {
User: function User(props) {
const user = props.user;
let nick = props.nick;
const { status, guildId, onPress } = props;
const styles = useStyles();
const stateFromStores = useStateFromStores([RelationshipStore], () => guildId == null ? RelationshipStore.getNickname(user.id) : null);
if (nick == null) {
nick = stateFromStores;
}
if (nick == null) {
nick = UserUtils.getName(user);
}
return <FormRow DEPRECATED_style={styles.row} onPress={onPress} accessibilityRole="menuitem" label={<AutocompleteLabel text={nick} />} leading={<Avatar status={status} user={user} size={AvatarSizes.SMALL} guildId={guildId} autoStatusCutout />} trailing={<DiscordTag user={user} usernameStyle={[styles.trailing, styles.username]} discriminatorStyle={styles.trailing} />} />;
},
Global: function Global(props) {
const { text, description, badge, onPress } = props;
const styles = useStyles();
return <TableRow onPress={onPress} accessibilityRole="menuitem" label={badge != null ? <View style={styles.labelRow}>
<AutocompleteLabel text={text} />
{badge}
</View> : <AutocompleteLabel text={text} />} trailing={<TableRowTrailingText text={description} />} />;
},
Role: function Role(props) {
const { onPress, showDescription, name, colorString } = props;
return <TableRow onPress={onPress} accessibilityRole="menuitem" label={<FormRow.Label style={[useStyles().leading, colorString != null ? {
color: colorString
} : void 0]} text={`@${name}`} />} trailing={<TableRowTrailingText text={showDescription ? intl.string(t.HrUmDH) : ""} />} />;
},
Channel: function Channel(props) {
const { channel, category, onPress } = props;
const styles = useStyles();
const guild = GuildStore.getGuild(channel.getGuildId());
return <FormRow onPress={onPress} accessibilityRole="menuitem" leading={<Icon source={channel.type === ChannelTypes.GUILD_CATEGORY ? Module7903 : getChannelIconWithGuild(channel, guild)} style={styles.autocompleteIcon} />} label={<AutocompleteLabel text={computeChannelName(channel, UserStore, RelationshipStore)} />} trailing={<Text style={styles.trailing} variant="text-sm/medium" color="text-muted">
{category != null && category.name}
</Text>} />;
},
Emoji: function Emoji(props) {
const { name, url, surrogates, onPress } = props;
const styles = useStyles();
return <FormRow onPress={onPress} accessibilityRole="menuitem" leading={url !== "" ? <FastImage style={[styles.emoji, styles.emojiImage]} source={{
uri: url
}} /> : <LegacyText style={[styles.emoji, styles.emojiText]} allowFontScaling={false}>{surrogates}</LegacyText>} label={<AutocompleteLabel text={`:${name}:`} />} />;
},
EmojiPremiumUpsell: function EmojiPremiumUpsell(props) {
return <FormRow onPress={props.onPress} accessibilityRole="menuitem" label={<ChannelAutocompleteEmojiUpsell results={props.results} />} />;
},
Choice: function Choice(props) {
return <FormRow onPress={props.onPress} accessibilityRole="menuitem" label={<AutocompleteLabel text={props.choice.displayName} />} />;
},
ChoiceLoading: function ChoiceLoading() {
const styles = useStyles();
return <FormRow DEPRECATED_style={styles.row} leading={<View style={styles.commandChoiceLoadingContainer}>
<View style={[styles.commandChoiceLoadingItem, {
width: useMemo(() => Module12.random(100, 300), [])
}]} />
</View>} />;
},
Sticker: function Sticker(props) {
const { sticker, onPress, onLongPress, isInteracting } = props;
return <PressableOpacity accessibilityRole="menuitem" style={useStyles().stickerContainer} onPress={onPress} onLongPress={onLongPress} pointerEvents="box-only">
<Sticker2 sticker={sticker} size={40} animated={useShouldAnimateSticker(isInteracting)} />
</PressableOpacity>;
},
Label: function Label(props) {
return <FormRow label={<AutocompleteLabel text={props.label} />} />;
},
Game: function Game(props) {
const { game, onPress } = props;
const styles = useStyles();
const gameMediaRefURL = getGameMediaRefURL(game.id, game.icon, {
size: 32
});
return <FormRow onPress={onPress} accessibilityRole="menuitem" leading={isNullOrEmpty(gameMediaRefURL) ? <UnknownGameIcon size="sm" style={styles.gameIcon} /> : <FastImage style={styles.gameIcon} source={{
uri: gameMediaRefURL
}} />} label={<AutocompleteLabel text={game.name} />} />;
}
};
export default r101;
export const AUTOCOMPLETE_STICKER_NODE_SIZE = 56;
export const AUTOCOMPLETE_STICKER_NODE_MARGIN = 4;
@@ -0,0 +1,225 @@
// Metro module 9659 (f9660).
import ApplicationCommandAutocompleteStore from "../../application_commands/ApplicationCommandAutocompleteStore";
import ApplicationCommandStore from "../../application_commands/ApplicationCommandStore";
import GameAutocompleteStore from "../../games/autocomplete/GameAutocompleteStore";
import StickersStore from "../../stickers/StickersStore";
import ChannelStore from "../../../stores/ChannelStore";
import GuildMemberStore from "../../../stores/GuildMemberStore";
import GuildStore from "../../../stores/GuildStore";
import { AutoCompleteResultTypes, MAX_AUTOCOMPLETE_RESULTS } from "../../../Constants";
import { AUTOCOMPLETE_OPTION_DEBOUNCE_TIME } from "../../application_commands/ApplicationCommandConstants";
import { CHANNEL_SENTINEL, COMMAND_SENTINEL, EMOJI_SENTINEL, MENTION_SENTINEL } from "../../channel_autocomplete/ChannelAutocompleteConstants";
import { AutocompleteTypes } from "../../channel_text_area/native/ChannelAutocompleteConstants";
import { EMOJI_MAX_LENGTH, EMOJI_URL_BASE_SIZE, EmojiIntention } from "../../emojis/EmojiConstants";
import Module12 from "../../../_bundle/Module12";
import executeCommand from "../../application_commands/executeCommand";
import AutocompleteUtils from "../../../utils/AutocompleteUtils";
import { getGameMentionsAutocompleteConfig } from "../../game_mentions/getGameMentionsAutocompleteConfig";
import { queryGamesAutocomplete } from "../../games/autocomplete/queryGamesAutocomplete";
import { fetchStickerPacks } from "../../stickers/StickersActionCreators";
import { StickerSendability } from "../../stickers/StickerSendability";
import AvatarUtils from "../../../utils/AvatarUtils";
import { intl, t } from "../../../intl/index.native";
import { HermesBuiltin } from "../../../_hermes/prelude";
let $mk83005 = function() {
return (a0) => ({
type: AutoCompleteResultTypes.GAME_MENTION,
game: a0
});
};
let c6387_20 = false;
let c6387_21 = Module12.debounce(executeCommand, AUTOCOMPLETE_OPTION_DEBOUNCE_TIME, {
leading: true,
trailing: true
});
export function getAutocompleteOptions(channel, r10 = false) {
let c17380_1 = r10;
let r11 = arguments[2];
if (r11 === void 0) {
r11 = true;
}
let c17380_2 = r11;
const r12 = {};
r12[AutocompleteTypes.MENTIONS] = {
stores: [GuildMemberStore, GameAutocompleteStore],
queryResults: (a0, a1, a2) => {
let r57;
const r33 = AutocompleteUtils.queryMentionResults({
query: a0,
channel,
canMentionEveryone: a1?.canMentionEveryone,
canMentionHere: a1?.canMentionHere,
canMentionUsers: a1?.canMentionUsers,
canMentionRoles: a1?.canMentionRoles,
includeAllGuildUsers: a1?.canMentionAnyGuildUser,
includeNonMentionableRoles: a1?.canMentionNonMentionableRoles,
request: a2
});
const { users, globals, roles } = r33;
const gameMentionsAutocompleteConfig = getGameMentionsAutocompleteConfig("mentions autocomplete");
if (a1?.canMentionGames === true && gameMentionsAutocompleteConfig.enabled && gameMentionsAutocompleteConfig.combineMentionAutocomplete && a0.length > 0) {
if (!a1?.isActiveApplicationCommand) {
let r52 = queryGamesAutocomplete(a0);
if (r52 == null) {
r52 = [];
}
r57 = r52.slice(0, 1).map($mk83005());
} else {
r57 = [];
}
} else {
r57 = [];
}
const r18 = users.map((user) => ({
type: AutoCompleteResultTypes.USER,
...user
}));
const r62 = [];
const r63 = HermesBuiltin.arraySpread(r62, r18, 0);
const r68 = HermesBuiltin.arraySpread(r62, globals.map((global) => ({
type: AutoCompleteResultTypes.GLOBAL,
...global
})), r63);
HermesBuiltin.arraySpread(r62, r57, HermesBuiltin.arraySpread(r62, roles.map((role) => ({
type: AutoCompleteResultTypes.ROLE,
...role
})), r68));
return Module12(r62).value();
},
matches: (a0, a1) => AutocompleteUtils.matchSentinel(a0, a1, MENTION_SENTINEL)
};
r12[AutocompleteTypes.GAME_MENTIONS] = {
stores: [GameAutocompleteStore],
queryResults: (a0) => {
let r24;
const gameMentionsAutocompleteConfig = getGameMentionsAutocompleteConfig("game_mentions autocomplete");
if (gameMentionsAutocompleteConfig.enabled && (!gameMentionsAutocompleteConfig.combineMentionAutocomplete && a0.length !== 0)) {
let r17 = queryGamesAutocomplete(a0);
if (r17 == null) {
r17 = [];
}
r24 = r17.slice(0, MAX_AUTOCOMPLETE_RESULTS).map($mk83005());
} else {
r24 = [];
}
return r24;
},
matches: () => false
};
r12[AutocompleteTypes.CHANNELS] = {
queryResults: (a0, a1) => {
const channelTypes = a1?.channelTypes;
return (a1?.isActiveApplicationCommand ? AutocompleteUtils.queryApplicationCommandChannelResults({
query: a0,
channel,
channelTypes
}) : AutocompleteUtils.queryChannelResults({
query: a0,
channel
})).channels.map((a0) => ({
type: AutoCompleteResultTypes.CHANNEL,
channel: a0,
category: ChannelStore.getChannel(a0.parent_id)
}));
},
matches: (a0, a1) => {
const isPrivate = channel.isPrivate();
return isPrivate ? !isPrivate : AutocompleteUtils.matchSentinel(a0, a1, CHANNEL_SENTINEL);
}
};
r12[AutocompleteTypes.EMOJIS_AND_STICKERS] = {
queryResults: (a0, a1) => {
const r23 = AutocompleteUtils.queryEmojiResults({
query: a0,
channel,
intention: EmojiIntention.CHAT,
maxCount: MAX_AUTOCOMPLETE_RESULTS + (c17380_2 ? 0 : 40)
});
const r34 = a1?.includeEmojiPremiumUpsell && (r23.emojis.locked.length > 0 && r23.emojis.unlocked.length < 4) ? [{
type: AutoCompleteResultTypes.EMOJI_PREMIUM_UPSELL,
results: r23.emojis.locked
}] : [];
let r41 = [];
if (c17380_2) {
if (!(c6387_20 || StickersStore.hasLoadedStickerPacks)) {
c6387_20 = true;
fetchStickerPacks();
}
r41 = AutocompleteUtils.queryStickers([a0], true, [channel, (a0, a1) => a1 === StickerSendability.SENDABLE]);
}
const r16 = r41.map(({ sticker }) => ({
type: AutoCompleteResultTypes.STICKER,
name: sticker.name,
sticker
}));
const r59 = [];
const r60 = HermesBuiltin.arraySpread(r59, r16, 0);
HermesBuiltin.arraySpread(r59, r34, HermesBuiltin.arraySpread(r59, r23.emojis.unlocked.map((item) => ({
type: AutoCompleteResultTypes.EMOJI,
name: item.name,
url: item.id != null ? AvatarUtils.getEmojiURL({
id: item.id,
animated: item.animated,
size: EMOJI_URL_BASE_SIZE
}) : item.url,
surrogates: item.id == null ? item.surrogates : void 0
})), r60));
return r59;
},
matches: (a0, a1) => {
let r2 = a0 === EMOJI_SENTINEL;
if (r2) {
const r1 = a1.length < 2 || a1.length > EMOJI_MAX_LENGTH;
r2 = r1 ? !r1 : !a1.includes(EMOJI_SENTINEL);
}
return r2;
}
};
r12[AutocompleteTypes.SLASHES] = {
queryResults: () => [],
matches: (a0, a1, a2) => a2 === 0 && a0 === COMMAND_SENTINEL && !(c17380_1 && a1.length === 0)
};
r12[AutocompleteTypes.SLASHES_DISCOVERY] = {
queryResults: () => [],
matches: (a0, a1, a2) => c17380_1 && a2 === 0 && a0 === COMMAND_SENTINEL && a1.length === 0
};
r12[AutocompleteTypes.CHOICES] = {
stores: [ApplicationCommandStore, ApplicationCommandAutocompleteStore],
queryResults: (a0, a1) => {
if ((a1 == null ? void 0 : a1.option?.autocomplete) && a1?.activeCommand != null && a1?.optionValues != null) {
c6387_21({
command: a1.activeCommand,
optionValues: a1.optionValues,
context: {
channel,
guild: GuildStore.getGuild(channel.guild_id),
autocomplete: {
name: a1.option.name,
query: a0
}
}
});
const autocompleteChoices = ApplicationCommandAutocompleteStore.getAutocompleteChoices(channel.id, a1.option.name, a0);
return autocompleteChoices == null ? new Array(4).fill({
type: AutoCompleteResultTypes.CHOICE_LOADING
}) : autocompleteChoices.length === 0 ? [{
type: AutoCompleteResultTypes.LABEL,
label: intl.string(t["41014u"])
}] : autocompleteChoices.map((autocompleteChoice) => ({
type: AutoCompleteResultTypes.CHOICE,
choice: autocompleteChoice
}));
}
const choices = a1?.choices;
return choices == null ? [] : AutocompleteUtils.queryChoiceResults({
query: a0,
choices
}).choices.map((a0) => ({
type: AutoCompleteResultTypes.CHOICE,
choice: a0
}));
},
matches: () => false
};
return r12;
}
@@ -0,0 +1,98 @@
// Metro module 9578 (f9579).
import { StyleSheet } from "react-native";
import { isGuildSelectableChannelType } from "../../../records/ChannelRecord";
import GuildChannelStore from "../../../stores/GuildChannelStore";
import RelationshipStore from "../../../stores/RelationshipStore";
import UserStore from "../../../stores/UserStore";
import { AutoCompleteResultTypes, WHITESPACE_RE } from "../../../Constants";
import { AUTOCOMPLETE_EMOJI_ROW_HEIGHT, AUTOCOMPLETE_ROW_HEIGHT } from "../../application_commands/native/ApplicationCommandsConstants";
import { CHANNEL_SENTINEL, EMOJI_SENTINEL, GAME_MENTION_SENTINEL, MENTION_SENTINEL } from "../../channel_autocomplete/ChannelAutocompleteConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { escapeChannelName, computeChannelName } from "../../channel/useChannelName";
import AutocompleteUtils from "../../../utils/AutocompleteUtils";
import UserUtils from "../../../utils/UserUtils";
import FormDivider from "../../../design/void/Form/native/FormDivider";
let hairlineWidth, useStyles;
const AutocompleteFormDivider = function AutocompleteFormDivider() {
return <FormDivider style={useStyles().itemDivider} />;
};
hairlineWidth = StyleSheet.hairlineWidth;
useStyles = createStyles({
itemDivider: {
marginLeft: 16,
backgroundColor: Module712.colors.BORDER_SUBTLE
}
});
export function getItemLayout(a0, a1) {
const length = (a0 == null ? void 0 : a0[a1]?.type) === AutoCompleteResultTypes.EMOJI ? AUTOCOMPLETE_EMOJI_ROW_HEIGHT : AUTOCOMPLETE_ROW_HEIGHT;
return {
length,
offset: a1 * length + Math.max(0, (a1 - 1) * hairlineWidth),
index: a1
};
}
export function getAutocompleteResultText(a0, a1, a2) {
if (a2 != null && !a2.has(a0.type)) {
return "";
}
const type = a0.type;
if (AutoCompleteResultTypes.USER === type) {
const user = a0.user;
return AutocompleteUtils.hasSameRoleAsUsername(a1, user) ? `${MENTION_SENTINEL}${user.tag}` : `${MENTION_SENTINEL}${UserUtils.getUserTag(user)}`;
}
if (AutoCompleteResultTypes.GLOBAL === type) {
return a0.text;
}
if (AutoCompleteResultTypes.ROLE === type) {
return `${MENTION_SENTINEL}${a0.name}`;
}
if (AutoCompleteResultTypes.CHANNEL === type) {
if (a0.channel.isThread()) {
return `#"${escapeChannelName(computeChannelName(a0.channel, UserStore, RelationshipStore))}"`;
}
const guildId = a0.channel.getGuildId();
if (guildId != null && isGuildSelectableChannelType(a0.channel.type)) {
let r82 = GuildChannelStore.getTextChannelNameDisambiguations(guildId)[a0.channel.id]?.name;
if (r82 == null) {
r82 = computeChannelName(a0.channel, UserStore, RelationshipStore);
}
return `${CHANNEL_SENTINEL}${r82}`;
}
return `${CHANNEL_SENTINEL}${computeChannelName(a0.channel, UserStore, RelationshipStore)}`;
}
if (AutoCompleteResultTypes.GAME_MENTION === type) {
return `${GAME_MENTION_SENTINEL}${a0.game.name}`;
}
if (AutoCompleteResultTypes.EMOJI === type) {
return `${EMOJI_SENTINEL}${a0.name}:`;
}
if (AutoCompleteResultTypes.EMOJI_PREMIUM_UPSELL !== type && AutoCompleteResultTypes.SLASH !== type) {
if (AutoCompleteResultTypes.CHOICE === type) {
return `${a0.choice.displayName}`;
}
if (AutoCompleteResultTypes.STICKER !== type && AutoCompleteResultTypes.CHOICE_LOADING !== type && AutoCompleteResultTypes.LABEL !== type) {
return void 0;
}
return "";
}
return "";
}
export function getMentionTextWithUser(a0, a1) {
return AutocompleteUtils.hasSameRoleAsUsername(a0, a1) ? `${MENTION_SENTINEL}${a1.tag}` : `${MENTION_SENTINEL}${UserUtils.getUserTag(a1)}`;
}
export function getItemSeparator() {
return <AutocompleteFormDivider />;
}
export function getPrefix(a0) {
return a0[0];
}
export function getQuery(a0) {
return a0.slice(1).toLowerCase();
}
export function isWhitespaceSeparatingBoundary(a0, a1) {
return a1 === 0 || WHITESPACE_RE.test(a0[a1 - 1]);
}
export function isUnbrokenRun(a0, a1, a2) {
return !WHITESPACE_RE.test(a0.slice(a1, a2));
}
@@ -0,0 +1,891 @@
// Metro module 11484 (f11485).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import * as Module19 from "react";
import { forwardRef, useState, useContext, useMemo, useEffect, useImperativeHandle, useCallback, useRef } from "react";
import { FlatList, View, StyleSheet } from "react-native";
import ApplicationCommandStore from "../../application_commands/ApplicationCommandStore";
import EmojiStore from "../../emojis/EmojiStore";
import GatewayConnectionStore from "../../gateway/GatewayConnectionStore";
import StickersStore from "../../stickers/StickersStore";
import { AnalyticEvents, AutoCompleteResultTypes, UpsellTypes, WHITESPACE_RE } from "../../../Constants";
import { BOOLEAN_CHOICES } from "../../application_commands/ApplicationCommandConstants";
import { AUTOCOMPLETE_EMOJI_ROW_HEIGHT, AUTOCOMPLETE_ROW_HEIGHT } from "../../application_commands/native/ApplicationCommandsConstants";
import { CHANNEL_SENTINEL, EMOJI_SENTINEL, GAME_MENTION_INPUT_PREFIX, MENTION_SENTINEL } from "../../channel_autocomplete/ChannelAutocompleteConstants";
import { AutocompleteTypes } from "../../channel_text_area/native/ChannelAutocompleteConstants";
import { EmojiInteractionPoint } from "../../emojis/EmojiConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import * as _PlatformUtils from "../../../utils/PlatformUtils";
import { isAndroid } from "../../../utils/PlatformUtils";
import Module712 from "../../../_bundle/Module712";
import Autocomplete, { AUTOCOMPLETE_STICKER_NODE_SIZE, AUTOCOMPLETE_STICKER_NODE_MARGIN } from "./Autocomplete";
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
import useSafeAreaInsetsKeyboardAware_native from "../../safe_area/useSafeAreaInsetsKeyboardAware.native";
import { NAV_BAR_HEIGHT } from "../../../design/components/Navigator/native/NavigatorConstants.native";
import { useStateFromStoresObject, useStateFromStores, BatchedStoreListener } from "../../../_bundle/Module589";
import { useToken } from "../../../design/tokens/native/useToken";
import { useScaledTextLineHeight } from "../../screen/native/useScaledTextLineHeight.android";
import useGameMentionSearchBarHeight from "../../game_mentions/hooks/native/useGameMentionSearchBarHeight";
import { IncludeStickersInAutocomplete } from "../../user_settings/UserSettings";
import { RedesignCompatContext } from "../../../design/components/RedesignCompat/native/RedesignCompat.native";
import { getAutocompleteOptions } from "./AutocompleteOptions";
import { getGameMentionsAutocompleteConfig } from "../../game_mentions/getGameMentionsAutocompleteConfig";
import useMentionAnchor from "./useMentionAnchor";
import { initiateEmojiInteraction } from "../../emojis/EmojiActionCreators";
import { getApplicationCommandOptionQueryOptions } from "../../application_commands/ApplicationCommandUtils";
import { ApplicationCommandOptionType } from "../../../flow/Server";
import * as _AutocompleteUtils from "./AutocompleteUtils";
import { getPrefix, getQuery, getAutocompleteResultText, getItemSeparator } from "./AutocompleteUtils";
import { getTextBeforeFirstOption } from "../../chat_input/native/ChatInputCommandOptionParser";
import { KeyboardTypes } from "../../keyboard/native/KeyboardTypes";
import { trackWithMetadata } from "../../app_analytics/AppAnalyticsUtils";
import { iOSTrackAutocompleteOpen, iOSTrackAutocompleteSelect } from "../../channel_text_area/native/ChannelAutocompleteAnalytics";
import { useMobileVisualRefreshConfig } from "../../themes/experiments/MobileVisualRefreshExperiment";
import { useIsScreenReaderEnabled } from "../../a11y/native/useIsScreenReaderEnabled.native";
import useAutocompleteAnimatedHeightStyles from "./useAutocompleteAnimatedHeightStyles";
import PremiumUpsellUtils from "../../../utils/native/PremiumUpsellUtils";
import { openCommandAttachmentPreview } from "../../application_commands/native/ApplicationCommandUtils";
import { NewTag } from "../../../design/void/native";
import ReanimatedRexport from "../../reanimated/ReanimatedRexport";
import ApplicationCommandDiscovery from "../../application_commands/native/ApplicationCommandDiscovery";
import { ApplicationCommandTriggerLocations } from "../../application_commands/ApplicationCommandTypes";
import ApplicationCommandList from "../../application_commands/native/ApplicationCommandList";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
import FormDivider from "../../../design/void/Form/native/FormDivider";
import GameMentionSearchBar from "../../game_mentions/native/GameMentionSearchBar";
import ApplicationCommandBar from "../../application_commands/native/ApplicationCommandBar";
let variant, hairlineWidth, useStyles, c7821_31;
const getStickersItemLayout = function getStickersItemLayout(a0, a1) {
return {
length: AUTOCOMPLETE_STICKER_NODE_SIZE,
offset: a1 * (AUTOCOMPLETE_STICKER_NODE_SIZE + AUTOCOMPLETE_STICKER_NODE_MARGIN) + (a1 - 1) * AUTOCOMPLETE_STICKER_NODE_MARGIN,
index: a1
};
};
variant = "text-sm/semibold";
hairlineWidth = StyleSheet.hairlineWidth;
useStyles = createStyles((a0, a1, a2, a3, a4) => ({
autocompletePositionRelative: {
position: "relative"
},
autocompleteWrapper: {
position: isAndroid() ? "relative" : "absolute",
marginHorizontal: a3,
marginBottom: a4
},
autocompleteWrapperAbsolute: {
left: 0,
right: 0,
bottom: 0
},
autocompleteContainer: {
backgroundColor: Module712.colors.MOBILE_FLOATING_ACCESSORY_BACKGROUND,
borderRadius: a0,
borderWidth: a1,
borderTopWidth: a2,
borderColor: Module712.colors.MOBILE_FLOATING_ACCESSORY_BORDER,
overflow: "hidden"
},
autocomplete: {
flexGrow: 0,
flexShrink: 1,
backgroundColor: Module712.colors.MOBILE_FLOATING_ACCESSORY_BACKGROUND
},
sectionDivider: {
backgroundColor: Module712.colors.MOBILE_FLOATING_ACCESSORY_BORDER,
marginLeft: -16
},
sectionTitle: {
backgroundColor: Module712.colors.MOBILE_FLOATING_ACCESSORY_BACKGROUND,
paddingLeft: 12,
marginVertical: 12,
justifyContent: "center"
},
stickersAutocompleteList: {
paddingLeft: 12 - AUTOCOMPLETE_STICKER_NODE_MARGIN,
marginBottom: 12,
height: AUTOCOMPLETE_STICKER_NODE_SIZE,
flexShrink: 0
},
newTag: {
backgroundColor: Module712.colors.BADGE_BACKGROUND_BRAND
}
}));
c7821_31 = {
resultCount: 0,
stickerResults: [],
nonStickerResults: [],
hasStickerResults: false,
hasNonStickerResults: false
};
const r73 = forwardRef(function({ analyticsLocations, channel, canMentionEveryone, keyboardType, onChangeAutoCompleteVisibility, commandsDisabled, chatInputRef, canOnlyUseTextCommands, screenIndex }, a1) {
let r265;
let optionStates, activeOption, activeCommand, token, scaledTextLineHeight, c18886_12, setting, resultCount, stickerResults, nonStickerResults, hasStickerResults, hasNonStickerResults, setState, context, memo, focused, text, selectionStart, selectionEnd, setState2, setState3, gameMentionsAutocompleteConfig, c18886_29, anchor, beginSearch, autocompleteType, query, queryOptions, autocompleteSelectionStart, showOptionValuesPicker, callback, callback2, memo2, ref, ref2, c18886_42, memo3, state, setState4, chatInputFloating, c18886_47, token2, styles, isScreenReaderEnabled, callback3, callback4, state2, setState5;
optionStates = void 0;
activeOption = void 0;
activeCommand = void 0;
token = void 0;
scaledTextLineHeight = void 0;
c18886_12 = void 0;
setting = void 0;
resultCount = void 0;
stickerResults = void 0;
nonStickerResults = void 0;
hasStickerResults = void 0;
hasNonStickerResults = void 0;
setState = void 0;
context = void 0;
memo = void 0;
focused = void 0;
text = void 0;
selectionStart = void 0;
selectionEnd = void 0;
setState2 = void 0;
setState3 = void 0;
gameMentionsAutocompleteConfig = void 0;
c18886_29 = void 0;
anchor = void 0;
beginSearch = void 0;
autocompleteType = void 0;
query = void 0;
queryOptions = void 0;
autocompleteSelectionStart = void 0;
showOptionValuesPicker = void 0;
callback = void 0;
callback2 = void 0;
memo2 = void 0;
ref = void 0;
ref2 = void 0;
c18886_42 = void 0;
memo3 = void 0;
state = void 0;
setState4 = void 0;
chatInputFloating = void 0;
c18886_47 = void 0;
token2 = void 0;
styles = void 0;
isScreenReaderEnabled = void 0;
callback3 = void 0;
callback4 = void 0;
state2 = void 0;
setState5 = void 0;
const stateFromStoresObject = useStateFromStoresObject([ApplicationCommandStore], () => ({
optionStates: ApplicationCommandStore.getOptionStates(channel.id),
activeOption: ApplicationCommandStore.getActiveOption(channel.id),
activeCommand: ApplicationCommandStore.getActiveCommand(channel.id),
activeSection: ApplicationCommandStore.getActiveCommandSection(channel.id)
}));
optionStates = stateFromStoresObject.optionStates;
activeOption = stateFromStoresObject.activeOption;
activeCommand = stateFromStoresObject.activeCommand;
const activeSection = stateFromStoresObject.activeSection;
token = useToken(Module712.modules.mobile.TABLE_ROW_HEIGHT);
scaledTextLineHeight = useScaledTextLineHeight(variant);
const gameMentionSearchBarHeight = useGameMentionSearchBarHeight();
c18886_12 = gameMentionSearchBarHeight;
setting = IncludeStickersInAutocomplete.getSetting();
const r84 = _slicedToArray(useState(c7821_31), 2);
const r85 = r84[0];
resultCount = r85.resultCount;
stickerResults = r85.stickerResults;
nonStickerResults = r85.nonStickerResults;
let hasStickerResults2 = r85.hasStickerResults;
hasStickerResults = hasStickerResults2;
let hasNonStickerResults2 = r85.hasNonStickerResults;
hasNonStickerResults = hasNonStickerResults2;
setState = r84[1];
const stateFromStores2 = useStateFromStores([EmojiStore], () => EmojiStore.loadState);
const stateFromStores = useStateFromStores([StickersStore], () => StickersStore.loadState);
context = useContext(RedesignCompatContext);
memo = useMemo(() => getAutocompleteOptions(channel, true, setting), [channel, setting]);
const r108 = _slicedToArray(useState({
focused: false,
text: "",
selectionStart: 0,
selectionEnd: 0
}), 2);
const r109 = r108[0];
focused = r109.focused;
text = r109.text;
selectionStart = r109.selectionStart;
selectionEnd = r109.selectionEnd;
setState2 = r108[1];
let state3;
[state3, setState3] = useState(0);
gameMentionsAutocompleteConfig = getGameMentionsAutocompleteConfig("AutocompleteWrapper game search");
const r33 = gameMentionsAutocompleteConfig.enabled && !gameMentionsAutocompleteConfig.combineMentionAutocomplete;
c18886_29 = r33;
const mentionAnchor = useMentionAnchor(text, selectionEnd, chatInputRef, r33, GAME_MENTION_INPUT_PREFIX);
anchor = mentionAnchor.anchor;
beginSearch = mentionAnchor.beginSearch;
useEffect(() => {
let c27073_0 = false;
GatewayConnectionStore.addConditionalChangeListener(() => {
let r0 = !c27073_0;
if (!c27073_0) {
const isConnected = GatewayConnectionStore.isConnected();
let r8 = void 0;
if (isConnected) {
initiateEmojiInteraction(EmojiInteractionPoint.AutocompleteWrapperShown);
r8 = false;
}
r0 = r8;
}
return r0;
});
return () => {
c27073_0 = true;
};
}, []);
useImperativeHandle(a1, useMemo(() => {
let c27074_0 = -1;
return () => ({
setChatInputHeight: setState3,
setData: ({ focused: focused2, text: text2, selectionStart: selectionStart3, selectionEnd: selectionEnd2 }) => {
if (c27074_0 !== -1) {
clearTimeout(c27074_0);
}
c27074_0 = setTimeout(() => {
setState2((prevState2) => prevState2.focused === focused2 && (prevState2.text === text2 && (prevState2.selectionStart === selectionStart3 && prevState2.selectionEnd === selectionEnd2)) ? prevState2 : {
focused: focused2,
text: text2,
selectionStart: selectionStart3,
selectionEnd: selectionEnd2
});
}, 16);
}
});
}, []));
const memo4 = useMemo(() => {
let r17, r30, r130, CHOICES, autocompleteSelectionStart2, channelTypes, choices, showOptionValuesPicker2;
let prefix, query2, c27075_3;
let selectionStart2 = selectionStart;
if (text != null && text.trim().length !== 0) {
const r7 = activeOption != null ? getApplicationCommandOptionQueryOptions(activeOption) : {
canMentionEveryone,
canMentionHere: canMentionEveryone,
canMentionChannels: true,
canMentionUsers: true,
canMentionRoles: true,
canMentionAnyGuildUser: false,
canMentionNonMentionableRoles: false,
canMentionOtherGlobals: true,
canMentionGames: true
};
const r11 = activeOption != null ? optionStates[activeOption.name] : void 0;
const r48 = activeCommand != null;
let r28 = void 0;
let r27 = void 0;
if (r48) {
const r49 = activeOption != null;
r28 = void 0;
r27 = void 0;
if (r49) {
const r50 = r11 != null;
r28 = void 0;
r27 = void 0;
if (r50) {
let location2 = r11.location;
if (location2 == null) {
location2 = 0;
}
let length = r11.length;
if (length == null) {
length = 0;
}
const r19 = selectionStart >= location2 + length ? text.substring(location2 + length, selectionStart) : void 0;
L27: {
query2 = r19;
if (activeOption.choices == null && !activeOption.autocomplete) {
const type = activeOption.type;
if (ApplicationCommandOptionType.BOOLEAN === type) {
prefix = "";
CHOICES = AutocompleteTypes.CHOICES;
choices = BOOLEAN_CHOICES;
showOptionValuesPicker2 = true;
channelTypes = void 0;
r17 = "";
break L27;
}
if (ApplicationCommandOptionType.CHANNEL === type) {
prefix = CHANNEL_SENTINEL;
CHOICES = AutocompleteTypes.CHANNELS;
channelTypes = activeOption.channelTypes;
showOptionValuesPicker2 = true;
choices = void 0;
r17 = CHANNEL_SENTINEL;
break L27;
}
if (ApplicationCommandOptionType.ROLE !== type && ApplicationCommandOptionType.USER !== type) {
const MENTIONABLE = ApplicationCommandOptionType.MENTIONABLE;
showOptionValuesPicker2 = false;
channelTypes = void 0;
choices = void 0;
r17 = void 0;
CHOICES = void 0;
if (MENTIONABLE !== type) {
break L27;
}
}
prefix = MENTION_SENTINEL;
CHOICES = AutocompleteTypes.MENTIONS;
showOptionValuesPicker2 = true;
channelTypes = void 0;
choices = void 0;
r17 = MENTION_SENTINEL;
} else {
prefix = "";
CHOICES = AutocompleteTypes.CHOICES;
choices = activeOption.choices;
showOptionValuesPicker2 = true;
channelTypes = void 0;
r17 = "";
}
}
r28 = r19;
r27 = CHOICES;
if (showOptionValuesPicker2) {
const r167 = r17 != null && r17 !== "" && r19 != null && r19.startsWith(r17);
let query5 = r19;
if (r167) {
query2 = r19.length > r17.length ? r19.substring(r17.length) : "";
query5 = query2;
}
const optionValues = {};
c27075_3 = optionValues;
Object.entries(optionStates).forEach((item) => {
const [r13, r14] = item;
if (r14.optionValue != null) {
c27075_3[r13] = r14.optionValue;
}
});
return {
query: query5,
autocompleteType: CHOICES,
autocompleteSelectionStart: location2 + length,
queryOptions: {
activeCommand,
optionValues,
isActiveApplicationCommand: showOptionValuesPicker2,
option: activeOption,
choices,
channelTypes,
...r7
},
showOptionValuesPicker: showOptionValuesPicker2
};
}
}
}
}
if (c18886_29 && anchor != null) {
return {
query: text.slice(anchor + GAME_MENTION_INPUT_PREFIX.length, selectionEnd).toLowerCase(),
autocompleteType: AutocompleteTypes.GAME_MENTIONS,
autocompleteSelectionStart: anchor,
queryOptions: {
...r7
}
};
}
const r4 = r11 != null;
let r26 = null;
if (r4) {
let location3 = r11.location;
if (location3 == null) {
location3 = 0;
}
let length2 = r11.length;
if (length2 == null) {
length2 = 0;
}
r26 = location3 + length2;
}
const r103 = r26 == null;
let r22 = selectionStart;
while (true) {
const isWhitespaceSeparatingBoundary = _AutocompleteUtils.isWhitespaceSeparatingBoundary(text, r22);
const r110 = r22;
let r31 = r28;
let autocompleteType2 = r27;
const r25 = r103 ? 0 : r26;
L47: {
L44: {
if (r110 !== r25) {
r30 = autocompleteType2;
if (!isWhitespaceSeparatingBoundary) {
break L44;
}
}
const r114 = text.slice(r110, selectionEnd);
prefix = getPrefix(r114);
query2 = getQuery(r114);
if (query2 != null) {
const r128 = WHITESPACE_RE.test(query2);
autocompleteSelectionStart2 = r110;
r130 = query2;
if (r128) {
break L47;
}
}
r30 = Object.keys(memo).find((item) => {
const r8 = memo[item];
let r11 = item !== AutocompleteTypes.SLASHES && item !== AutocompleteTypes.SLASHES_DISCOVERY || activeCommand == null && !commandsDisabled;
if (r11) {
r11 = prefix !== void 0 && query2 !== void 0 && r8.matches(prefix, query2, selectionStart2);
}
return r11;
});
r31 = query2;
autocompleteSelectionStart2 = r110;
r130 = r31;
autocompleteType2 = r30;
if (autocompleteType2 != null) {
break L47;
}
}
const r135 = r110 - 1;
selectionStart2 = r135;
const r136 = r103 ? 0 : r26;
r22 = r135;
r28 = r31;
r27 = r30;
r130 = r28;
autocompleteType2 = r27;
autocompleteSelectionStart2 = r22;
if (autocompleteSelectionStart2 >= r136) {
continue;
}
}
const SLASHES = AutocompleteTypes.SLASHES;
let query4 = r130;
if (autocompleteType2 === SLASHES) {
query2 = getTextBeforeFirstOption(r130 == null ? "" : r130).text;
query4 = query2;
}
return {
query: query4,
autocompleteType: autocompleteType2,
autocompleteSelectionStart: autocompleteSelectionStart2,
queryOptions: {
...r7
}
};
}
}
return {
query: null,
autocompleteType: null,
autocompleteSelectionStart: null
};
}, [selectionStart, selectionEnd, text, activeCommand, optionStates, activeOption, canMentionEveryone, commandsDisabled, memo, stateFromStores2, stateFromStores, r33, anchor]);
autocompleteType = memo4.autocompleteType;
query = memo4.query;
queryOptions = memo4.queryOptions;
autocompleteSelectionStart = memo4.autocompleteSelectionStart;
showOptionValuesPicker = memo4.showOptionValuesPicker;
callback = useCallback((a0) => {
if (autocompleteType != null && query != null) {
const r16 = memo[autocompleteType].queryResults(query, queryOptions, a0);
const stickerResults2 = [];
let c27076_0 = stickerResults2;
const nonStickerResults2 = [];
let c27076_1 = nonStickerResults2;
r16.forEach((item) => {
if (item.type === AutoCompleteResultTypes.STICKER) {
c27076_0.push(item);
} else {
c27076_1.push(item);
}
});
setState({
resultCount: r16.length,
stickerResults: stickerResults2,
nonStickerResults: nonStickerResults2,
hasStickerResults: stickerResults2.length > 0,
hasNonStickerResults: nonStickerResults2.length > 0
});
} else {
setState(c7821_31);
}
}, [autocompleteType, query, queryOptions, memo]);
useEffect(() => {
const r6 = autocompleteType != null ? memo == null ? void 0 : memo[autocompleteType].stores : null;
if (r6 != null) {
let c27077_0;
const batchedStoreListener = new BatchedStoreListener(r6, () => callback(false));
c27077_0 = batchedStoreListener;
batchedStoreListener.attach("AutocompleteWrapper");
return () => c27077_0.detach();
}
}, [autocompleteType, callback, memo]);
useEffect(() => {
callback(true);
}, [callback]);
callback2 = useCallback(() => ({
numStickerResults: stickerResults.length,
numEmojiResults: nonStickerResults.filter((nonStickerResult) => nonStickerResult.type === AutoCompleteResultTypes.EMOJI).length
}), [stickerResults, nonStickerResults]);
memo2 = useMemo(() => {
const r1 = resultCount > 0 || (autocompleteType === AutocompleteTypes.SLASHES || autocompleteType === AutocompleteTypes.SLASHES_DISCOVERY) || autocompleteType === AutocompleteTypes.GAME_MENTIONS;
const SYSTEM = KeyboardTypes.SYSTEM;
let r24 = focused;
if (focused) {
r24 = r1;
}
if (r24) {
r24 = keyboardType === SYSTEM;
}
return r24;
}, [autocompleteType, focused, keyboardType, resultCount]);
ref = useRef(false);
useEffect(() => {
const current = ref.current;
let current2 = autocompleteType === AutocompleteTypes.SLASHES;
if (current) {
if (!current2) {
current2 = autocompleteType === AutocompleteTypes.SLASHES_DISCOVERY;
}
if (!current2) {
current2 = activeCommand != null;
}
ref.current = current2;
} else {
ref.current = (current2 ? current2 : autocompleteType === AutocompleteTypes.SLASHES_DISCOVERY) || activeCommand != null;
if (ref.current) {
trackWithMetadata(AnalyticEvents.APPLICATION_COMMAND_TOP_OF_FUNNEL, {
location: "slash_ui"
});
}
}
}, [autocompleteType, activeCommand]);
ref2 = useRef(null);
useEffect(() => {
let r2 = memo2;
if (!memo2) {
r2 = activeCommand != null;
}
if (onChangeAutoCompleteVisibility != null) {
onChangeAutoCompleteVisibility(r2);
}
if (r2) {
const current = `${channel.id}:${autocompleteType == null ? "" : autocompleteType}`;
if (ref2.current !== current) {
ref2.current = current;
iOSTrackAutocompleteOpen(autocompleteType, channel, {
...callback2(),
gameMentionsAvailable: autocompleteType === AutocompleteTypes.MENTIONS ? gameMentionsAutocompleteConfig.enabled : void 0
});
}
} else {
ref2.current = null;
}
}, [onChangeAutoCompleteVisibility, activeCommand, memo2, autocompleteType, channel, callback2, gameMentionsAutocompleteConfig.enabled]);
const windowDimensions_native = useWindowDimensions_native({
ignoreKeyboard: true
});
const insets = useSafeAreaInsetsKeyboardAware_native({
includeKeyboardHeight: true
}).insets;
const r195 = windowDimensions_native.height - insets.top - insets.bottom - NAV_BAR_HEIGHT - state3;
c18886_42 = r195;
memo3 = useMemo(() => {
const r8 = scaledTextLineHeight + 24;
const r11 = 200 + r8;
return Math.min(c18886_42, stickerResults.length > 0 ? r11 + r8 + AUTOCOMPLETE_STICKER_NODE_SIZE + 12 + hairlineWidth : autocompleteType !== AutocompleteTypes.EMOJIS_AND_STICKERS ? autocompleteType === AutocompleteTypes.GAME_MENTIONS ? 200 + c18886_12 : 200 : r11);
}, [autocompleteType, stickerResults.length, r195, scaledTextLineHeight, gameMentionSearchBarHeight]);
[state, setState4] = useState(null);
const memo5 = useMemo(() => {
let r8;
if (autocompleteType === AutocompleteTypes.EMOJIS_AND_STICKERS) {
const length = nonStickerResults.length;
let r31 = token;
let r32 = 0;
if (length !== 0) {
if (!context) {
r31 = autocompleteType === AutocompleteTypes.EMOJIS_AND_STICKERS ? AUTOCOMPLETE_EMOJI_ROW_HEIGHT : AUTOCOMPLETE_ROW_HEIGHT;
}
r32 = length * r31 + (length - 1) * hairlineWidth;
}
const r41 = hasNonStickerResults ? r32 + (scaledTextLineHeight + 24) : r32;
let r45 = hasStickerResults;
const r46 = hasStickerResults ? r41 + (scaledTextLineHeight + 24 + AUTOCOMPLETE_STICKER_NODE_SIZE + 12) : r41;
if (hasStickerResults) {
r45 = hasNonStickerResults;
}
r8 = r45 ? r46 + hairlineWidth : r46;
} else if (autocompleteType === AutocompleteTypes.SLASHES || autocompleteType === AutocompleteTypes.SLASHES_DISCOVERY) {
let r27 = state;
if (state == null) {
r27 = 0;
}
r8 = r27;
} else {
const r16 = autocompleteType != null;
r8 = 0;
if (r16) {
let r17 = token;
let r0 = 0;
if (resultCount !== 0) {
if (!context) {
r17 = autocompleteType === AutocompleteTypes.EMOJIS_AND_STICKERS ? AUTOCOMPLETE_EMOJI_ROW_HEIGHT : AUTOCOMPLETE_ROW_HEIGHT;
}
r0 = resultCount * r17 + (resultCount - 1) * hairlineWidth;
}
r8 = autocompleteType === AutocompleteTypes.GAME_MENTIONS ? r0 + c18886_12 : r0;
}
}
return Math.min(memo2 ? r8 : 0, memo3);
}, [resultCount, autocompleteType, memo2, hasStickerResults, hasNonStickerResults, nonStickerResults.length, memo3, state, context, token, scaledTextLineHeight, gameMentionSearchBarHeight]);
chatInputFloating = useMobileVisualRefreshConfig({
location: "AutocompleteWrapper"
}).chatInputFloating;
const r5 = memo5 > 0;
c18886_47 = r5;
const token3 = useToken(Module712.modules.mobile.CHAT_INPUT_FLOATING_BORDER_RADIUS);
const token4 = useToken(Module712.modules.mobile.CHAT_INPUT_FLOATING_ACCESSORY_BORDER_WIDTH);
const token5 = useToken(Module712.modules.mobile.CHAT_INPUT_FLOATING_ACCESSORY_TOP_BORDER_WIDTH);
const token6 = useToken(Module712.modules.mobile.CHAT_INPUT_FLOATING_ACCESSORY_MARGIN_HORIZONTAL);
token2 = useToken(Module712.modules.mobile.CHAT_INPUT_FLOATING_ACCESSORY_MARGIN_BOTTOM);
const r263 = r5 ? token4 : 0;
const r264 = r5 ? token5 : 0;
L10: {
if (!r5) {
const r4 = activeCommand != null;
r265 = 0;
if (!r4) {
break L10;
}
r265 = commandsDisabled ? 0 : token2;
} else {
r265 = token2;
}
}
styles = useStyles(token3, r263, r264, token6, r265);
isScreenReaderEnabled = useIsScreenReaderEnabled();
const r280 = isAndroid() || _PlatformUtils.isIOS() && (isScreenReaderEnabled ? isScreenReaderEnabled : chatInputFloating);
const memo6 = useMemo(() => {
let r9;
L4: {
const isIOS = _PlatformUtils.isIOS();
r9 = null;
if (isIOS) {
if (!isScreenReaderEnabled) {
r9 = null;
if (!chatInputFloating) {
break L4;
}
}
r9 = styles.autocompletePositionRelative;
}
}
return r9;
}, [isScreenReaderEnabled, chatInputFloating, styles.autocompletePositionRelative]);
const memo7 = useMemo(() => c18886_47 ? {
marginTop: token2
} : void 0, [r5, token2]);
const styles2 = useAutocompleteAnimatedHeightStyles(memo5, screenIndex);
callback3 = useCallback((a0, a1, a2) => {
if (a0.type !== AutoCompleteResultTypes.EMOJI_PREMIUM_UPSELL) {
if (a0.type === AutoCompleteResultTypes.GLOBAL && a0.inlineAutocompleteType === "gameMentionInput") {
chatInputRef.current.insertText(GAME_MENTION_INPUT_PREFIX, a1, false);
beginSearch(a1);
return void 0;
}
const autocompleteResultText = getAutocompleteResultText(a0, channel);
const applicationCommandManager = chatInputRef.current.getApplicationCommandManager();
const type = a0.type;
const GAME_MENTION = AutoCompleteResultTypes.GAME_MENTION;
let r43 = void 0;
if (type === GAME_MENTION) {
if (applicationCommandManager != null) {
applicationCommandManager.addGameMention(a0.game);
}
const r14 = applicationCommandManager == null ? void 0 : applicationCommandManager.buildGameMentionNode(a0.game);
r43 = r14 != null ? [r14] : void 0;
}
if (!(applicationCommandManager == null ? void 0 : applicationCommandManager.setAutoCompleteResult(channel.id, autocompleteResultText, a2, a0))) {
chatInputRef.current.insertText(autocompleteResultText, a1, a0.type !== AutoCompleteResultTypes.STICKER, r43);
if (a0.type === AutoCompleteResultTypes.STICKER) {
chatInputRef.current.handleSelectSticker(a0.sticker, a1);
}
}
} else {
PremiumUpsellUtils.handleShowUpsellAlert({
initialUpsellKey: UpsellTypes.EMOJI_AUTOCOMPLETE,
analyticsLocations
});
}
}, [analyticsLocations, beginSearch, channel, chatInputRef]);
const callback5 = useCallback((a0) => {
const applicationCommandManager = chatInputRef.current.getApplicationCommandManager();
if (a0.type === ApplicationCommandOptionType.ATTACHMENT) {
const r24 = optionStates[a0.name];
const id = channel.id;
if (r24.lastValidationResult?.success) {
openCommandAttachmentPreview(applicationCommandManager, id, a0.name);
} else if (applicationCommandManager != null) {
applicationCommandManager.insertOrJumpCommandOption(a0);
}
} else {
const r17 = applicationCommandManager == null ? void 0 : applicationCommandManager.props.text.length;
if (applicationCommandManager != null) {
applicationCommandManager.insertOrJumpCommandOption(a0, r17);
}
}
}, [chatInputRef, optionStates, channel]);
callback4 = useCallback((a0) => {
iOSTrackAutocompleteSelect(autocompleteType, channel, {
selectionType: a0.type === AutoCompleteResultTypes.GLOBAL && a0.inlineAutocompleteType === "gameMentionInput" ? AutoCompleteResultTypes.GAME_MENTION : a0.type,
stickerId: a0.type === AutoCompleteResultTypes.STICKER ? a0.sticker.id : null,
gameId: a0.type === AutoCompleteResultTypes.GAME_MENTION ? a0.game.id : null,
...callback2()
});
let r35 = autocompleteSelectionStart;
if (autocompleteSelectionStart == null) {
r35 = 0;
}
callback3(a0, r35, showOptionValuesPicker);
}, [autocompleteSelectionStart, autocompleteType, callback2, channel, callback3, showOptionValuesPicker]);
[state2, setState5] = useState(null);
const callback6 = useCallback(({ item }) => {
const type = item.type;
if (AutoCompleteResultTypes.USER === type) {
return <Autocomplete.User {...item} guildId={channel.guild_id} onPress={() => callback4(item)} />;
}
if (AutoCompleteResultTypes.GLOBAL === type) {
return <Autocomplete.Global {...item} onPress={() => callback4(item)} badge={item.inlineAutocompleteType === "gameMentionInput" ? gameMentionsAutocompleteConfig.showNewTag ? <NewTag containerStyle={styles.newTag} variant="text-xs/bold" color="badge-text-brand" /> : void 0 : void 0} />;
}
if (AutoCompleteResultTypes.ROLE === type) {
return <Autocomplete.Role {...item} onPress={() => callback4(item)} showDescription={autocompleteType === AutocompleteTypes.MENTIONS && activeCommand == null} />;
}
if (AutoCompleteResultTypes.CHANNEL === type) {
return <Autocomplete.Channel {...item} onPress={() => callback4(item)} />;
}
if (AutoCompleteResultTypes.EMOJI === type) {
return <Autocomplete.Emoji {...item} onPress={() => callback4(item)} />;
}
if (AutoCompleteResultTypes.EMOJI_PREMIUM_UPSELL === type) {
return <Autocomplete.EmojiPremiumUpsell {...item} onPress={() => callback4(item)} />;
}
if (AutoCompleteResultTypes.CHOICE === type) {
return <Autocomplete.Choice {...item} onPress={() => callback4(item)} />;
}
if (AutoCompleteResultTypes.CHOICE_LOADING === type) {
return <Autocomplete.ChoiceLoading />;
}
if (AutoCompleteResultTypes.STICKER === type) {
const isInteracting = state2 === item.sticker.id;
return <Autocomplete.Sticker key={`${item.sticker.id}-${isInteracting}`} {...item} onPress={() => callback4(item)} onLongPress={() => setState5(item.sticker.id)} isInteracting={isInteracting} />;
}
if (AutoCompleteResultTypes.GAME_MENTION === type) {
return <Autocomplete.Game {...item} onPress={() => callback4(item)} />;
}
if (AutoCompleteResultTypes.LABEL === type) {
return <Autocomplete.Label {...item} />;
}
return null;
}, [autocompleteType, callback4, state2, channel, activeCommand, gameMentionsAutocompleteConfig.showNewTag, styles]);
const style = [styles.autocomplete, {
maxHeight: memo3
}];
const style2 = [styles.autocompleteWrapper, r280 ? !r280 : styles.autocompleteWrapperAbsolute, memo6];
let r336 = autocompleteType != null;
if (r336) {
const r345 = [autocompleteType === AutocompleteTypes.SLASHES_DISCOVERY && <ApplicationCommandDiscovery channel={channel} onPressSlashItem={(event, a1, a2) => {
const r4 = {
command: event,
section: a1,
type: AutoCompleteResultTypes.SLASH,
visualSection: a2,
location: ApplicationCommandTriggerLocations.DISCOVERY
};
let r18 = autocompleteSelectionStart;
if (autocompleteSelectionStart == null) {
r18 = 0;
}
callback3(r4, r18);
}} onHeightChange={setState4} canOnlyUseTextCommands={canOnlyUseTextCommands} />, autocompleteType === AutocompleteTypes.SLASHES && <ApplicationCommandList channel={channel} query={query == null ? "" : query} onPressCommandItem={(event, a1) => {
const r4 = {
command: event,
section: a1,
type: AutoCompleteResultTypes.SLASH,
location: ApplicationCommandTriggerLocations.DISCOVERY,
query
};
let r18 = autocompleteSelectionStart;
if (autocompleteSelectionStart == null) {
r18 = 0;
}
callback3(r4, r18);
}} style={style} ItemSeparatorComponent={getItemSeparator} getItemLayout={_AutocompleteUtils.getItemLayout} onCommandsChange={(event) => {
let r9 = token;
let r0 = 0;
if (event !== 0) {
if (!context) {
r9 = autocompleteType === AutocompleteTypes.EMOJIS_AND_STICKERS ? AUTOCOMPLETE_EMOJI_ROW_HEIGHT : AUTOCOMPLETE_ROW_HEIGHT;
}
r0 = event * r9 + (event - 1) * hairlineWidth;
}
setState4(r0);
}} />, , , ,];
let r361 = autocompleteType === AutocompleteTypes.EMOJIS_AND_STICKERS;
if (r361) {
let r362 = hasStickerResults;
if (hasStickerResults) {
r362 = <>
{[<View style={[styles.sectionTitle, {
height: scaledTextLineHeight
}]}>
<Text variant={variant}>
{intl.format(t.uferGG, {
prefix: query
})}
</Text>
</View>, <FlatList horizontal style={{
...style,
...styles.stickersAutocompleteList
}} keyExtractor={(item) => item.sticker.id} data={stickerResults} renderItem={callback6} showsHorizontalScrollIndicator={false} getItemLayout={getStickersItemLayout} contentInset={{
right: 12
}} />]}
</>;
}
const r398 = [r362, , ,];
if (hasStickerResults) {
hasStickerResults2 = hasNonStickerResults;
}
if (hasStickerResults2) {
hasStickerResults2 = <FormDivider style={styles.sectionDivider} />;
}
r398[1] = hasStickerResults2;
if (hasNonStickerResults) {
hasNonStickerResults2 = <View style={[styles.sectionTitle, {
height: scaledTextLineHeight
}]}>
<Text variant={variant}>
{intl.format(t.ksAVYt, {
prefix: `${EMOJI_SENTINEL}${query}`
})}
</Text>
</View>;
}
r398[2] = hasNonStickerResults2;
r361 = <>{r398}</>;
}
r345[2] = r361;
r345[3] = autocompleteType === AutocompleteTypes.GAME_MENTIONS && <GameMentionSearchBar />;
r345[4] = <FlatList style={style} keyExtractor={(item, index) => String(index)} data={nonStickerResults} renderItem={callback6} ItemSeparatorComponent={getItemSeparator} getItemLayout={_AutocompleteUtils.getItemLayout} />;
r336 = <>{r345}</>;
}
return <View style={styles.autocompletePositionRelative}>
<View style={style2}>
<ReanimatedRexport.View style={[styles.autocompleteContainer, styles2]}>{r336}</ReanimatedRexport.View>
{activeCommand != null && !commandsDisabled && <View style={memo7}>
<ApplicationCommandBar command={activeCommand} section={activeSection} guildId={channel.guild_id} onPressOption={callback5} currentOption={activeOption} optionStates={optionStates} />
</View>}
</View>
</View>;
});
r73.displayName = "AutocompleteWrapper";
const r76 = Module19.memo(r73);
export default r76;
@@ -0,0 +1,65 @@
// Metro module 6168 (f6169).
import * as _Module17 from "react-native";
import { $callWithNewTarget } from "../../../_hermes/prelude";
function $mk77953($env) {
return (data) => {
$env[0].handlers.forEach((handler) => handler({
data
}));
};
}
let c3909_0;
let env3909;
const { NativeModules, NativeEventEmitter } = _Module17;
const UserSearchWorkerManager = NativeModules.UserSearchWorkerManager;
class UserSearchWorker extends NativeEventEmitter {
constructor() {
let env15556;
super(UserSearchWorkerManager);
const r11 = env15556 = {};
env15556[0] = this;
this.handlers = new Set();
this.subscription = null;
this.handleCallback = $mk77953(r11);
}
postMessage(a0) {
if (a0) {
UserSearchWorkerManager.onmessage(JSON.stringify(a0));
return void 0;
}
throw new Error("Invalid data");
}
addEventListener(a0, a1) {
if (a0 === "message") {
if (this.subscription == null) {
this.subscription = this.addListener("ReturnResults", this.handleCallback);
}
this.handlers.add(a1);
}
}
removeEventListener(a0, a1) {
if (a0 === "message") {
this.handlers.delete(a1);
if (this.handlers.size === 0) {
const subscription = this.subscription;
if (subscription != null) {
subscription.remove();
}
this.subscription = null;
}
}
}
terminate() {
UserSearchWorkerManager.terminate();
}
}
const prototypeOf = Object.getPrototypeOf(UserSearchWorker);
const r24 = Object.create(UserSearchWorker.prototype);
const r25 = $callWithNewTarget(prototypeOf, r24, UserSearchWorker, UserSearchWorkerManager);
const exports2 = r25 instanceof Object ? r25 : r24;
const r28 = env3909 = {};
c3909_0 = exports2;
exports2.handlers = new Set();
exports2.subscription = null;
exports2.handleCallback = $mk77953(r28);
module.exports = exports2;
@@ -0,0 +1,24 @@
// Metro module 11491 (f11492).
import { useIsScreenIndexFrozenSharedValue } from "../../channel/native/ScreenIndexFrozen";
import { useAnimatedStyle } from "../../reanimated/ReanimatedRexport";
import * as _timing from "../../../design/animation/reanimated/timing/timing";
import * as _timingPresets from "../../../design/animation/reanimated/timing/timingPresets";
const __initData = {
code: "function useAutocompleteAnimatedHeightStylesTsx1(){const{withTiming,height,timingStandard,isFrozenSharedValue}=this.__closure;return{height:withTiming(height,timingStandard),display:!isFrozenSharedValue.get()?'flex':'none'};}"
};
export default function useAutocompleteAnimatedHeightStyles(a0, a1) {
const isScreenIndexFrozenSharedValue = useIsScreenIndexFrozenSharedValue(a1);
const r16 = () => ({
height: _timing.withTiming(a0, _timingPresets.timingStandard),
display: isScreenIndexFrozenSharedValue.get() ? "none" : "flex"
});
r16.__closure = {
withTiming: _timing.withTiming,
height: a0,
timingStandard: _timingPresets.timingStandard,
isFrozenSharedValue: isScreenIndexFrozenSharedValue
};
r16.__workletHash = 3862216441966;
r16.__initData = __initData;
return useAnimatedStyle(r16);
};
@@ -0,0 +1,137 @@
// Metro module 11489 (f11490).
import { useState, useEffect, useCallback } from "react";
import { WHITESPACE_RE } from "../../../Constants";
import { isUnbrokenRun, isWhitespaceSeparatingBoundary } from "./AutocompleteUtils";
const search = {
kind: "idle"
};
let c7826_6 = {
search,
cleanupAnchor: null
};
export default function useMentionAnchor(a0, a1, a2, a3, a4) {
let r48, r72;
let c18889_0 = a0;
const [state, setState] = useState(c7826_6);
const { cleanupAnchor, search: search2 } = state;
const r35 = search2.kind !== "idle" ? search2.anchor : null;
const r36 = a3 ? r35 != null && r35 >= 0 && a0.startsWith(a4, r35) && a1 >= r35 + a4.length && isUnbrokenRun(a0, r35 + a4.length, a1) : a3;
const anchor2 = r36 ? r35 : null;
if (a3) {
const { search: search3, cleanupAnchor: cleanupAnchor2 } = state;
const kind = search3.kind;
if (kind === "idle") {
const r74 = a0.lastIndexOf(a4, a1);
const anchor3 = r74 !== -1 ? isWhitespaceSeparatingBoundary(a0, r74) ? r74 != null && r74 >= 0 && a0.startsWith(a4, r74) && a1 >= r74 + a4.length && isUnbrokenRun(a0, r74 + a4.length, a1) ? r74 : null : null : null;
r48 = anchor3 != null ? {
search: {
kind: "pending",
anchor: anchor3,
seenText: null
},
cleanupAnchor: null
} : {
search,
cleanupAnchor: a0.includes(a4) ? cleanupAnchor2 : null
};
} else if (kind === "active") {
const r67 = {
search: null,
cleanupAnchor: null
};
if (r36) {
r67.search = search3;
r72 = r67;
} else {
r67.search = search;
r67.cleanupAnchor = a0.includes(a4) ? search3.anchor : null;
r72 = r67;
}
r48 = r72;
} else {
r48 = void 0;
if (kind === "pending") {
const { anchor, seenText } = search3;
r48 = r36 ? {
search: {
kind: "active",
anchor
},
cleanupAnchor: cleanupAnchor2
} : a0.startsWith(a4, anchor) ? {
search: {
kind: "pending",
anchor,
seenText: null
},
cleanupAnchor: cleanupAnchor2
} : anchor > a0.length ? {
search,
cleanupAnchor: cleanupAnchor2
} : seenText == null ? {
search: {
kind: "pending",
anchor,
seenText: a0
},
cleanupAnchor: cleanupAnchor2
} : seenText !== a0 ? {
search,
cleanupAnchor: cleanupAnchor2
} : state;
}
}
} else {
r48 = {
search,
cleanupAnchor: null
};
}
let r2 = state.cleanupAnchor === r48.cleanupAnchor;
if (r2) {
const search4 = state.search;
const search5 = r48.search;
r2 = search4.kind === search5.kind && (search4.kind === "idle" || (search4.kind === "active" ? search5.kind === "active" && search4.anchor === search5.anchor : search5.kind === "pending" && search4.anchor === search5.anchor && search4.seenText === search5.seenText));
}
if (!r2) {
setState(r48);
}
useEffect(() => {
if (cleanupAnchor != null) {
const location2 = c18889_0.startsWith(a4, cleanupAnchor) ? cleanupAnchor : c18889_0.indexOf(a4);
if (!(location2 < 0)) {
let length = c18889_0.slice(location2).search(WHITESPACE_RE);
if (length === -1) {
length = c18889_0.length - location2;
}
const current = a2.current;
const applicationCommandManager = a2.current.getApplicationCommandManager();
let editId = applicationCommandManager == null ? void 0 : applicationCommandManager.props.editId;
if (editId == null) {
editId = void 0;
}
current.replaceRange({
location: location2,
length,
text: "",
editId
});
}
}
}, [cleanupAnchor, a0, a4, a2]);
return {
anchor: anchor2,
beginSearch: useCallback((a0) => {
if (a3) {
setState({
search: {
kind: "pending",
anchor: a0,
seenText: null
},
cleanupAnchor: null
});
}
}, [a3])
};
};
@@ -0,0 +1,182 @@
// Metro module 5032 (f5033).
import Record from "../../../lib/Record";
import { Routes } from "../../../Constants";
import { RewardFilterTypes } from "../../quests/QuestConstants";
import { UserSettingsPath } from "../../user_settings/UserSettingsConstants";
import { settingsPathToRoute } from "../../user_settings/UserSettingsURLUtils";
import { $callWithNewTarget } from "../../../_hermes/prelude";
let c3038_5 = {
SHOP: "SHOP",
SHOP_ORBS_TAB: "SHOP_ORBS_TAB",
NITRO_HOME: "NITRO_HOME",
QUEST_HOME: "QUEST_HOME",
QUEST_ORBS: "QUEST_ORBS",
APPS_HOME: "APPS_HOME",
SETTINGS: "SETTINGS",
PLAYGROUND: "PLAYGROUND"
};
class InAppNavigationRecord extends Record {
constructor(a0) {
super();
const id = a0.collectionId != null ? `${a0.type}_${a0.collectionId}` : a0.type;
this.id = id;
this.path = a0.path;
this.type = a0.type;
this.label = a0.label;
this.collectionId = a0.collectionId;
this.IconComponent = a0.IconComponent;
}
static fromType(a0, a1, a2, a3, a4) {
if (c3038_5.SHOP === a0) {
const r241 = {
path: Routes.COLLECTIBLES_SHOP,
type: c3038_5.SHOP
};
const prototypeOf8 = Object.getPrototypeOf(InAppNavigationRecord);
const r247 = Object.create(InAppNavigationRecord.prototype);
const r249 = $callWithNewTarget(prototypeOf8, r247, InAppNavigationRecord);
const id8 = r241.collectionId != null ? `${r241.type}_${r241.collectionId}` : r241.type;
const r261 = r249 instanceof Object ? r249 : r247;
r261.id = id8;
r261.path = r241.path;
r261.type = r241.type;
r261.label = r241.label;
r261.collectionId = r241.collectionId;
r261.IconComponent = r241.IconComponent;
return r261;
}
if (c3038_5.NITRO_HOME === a0) {
const r210 = {
path: Routes.NITRO_HOME,
type: c3038_5.NITRO_HOME
};
const prototypeOf7 = Object.getPrototypeOf(InAppNavigationRecord);
const r217 = Object.create(InAppNavigationRecord.prototype);
const r219 = $callWithNewTarget(prototypeOf7, r217, InAppNavigationRecord);
const id7 = r210.collectionId != null ? `${r210.type}_${r210.collectionId}` : r210.type;
const r231 = r219 instanceof Object ? r219 : r217;
r231.id = id7;
r231.path = r210.path;
r231.type = r210.type;
r231.label = r210.label;
r231.collectionId = r210.collectionId;
r231.IconComponent = r210.IconComponent;
return r231;
}
if (c3038_5.QUEST_HOME === a0) {
const r180 = {
path: Routes.QUEST_HOME,
type: c3038_5.QUEST_HOME
};
const prototypeOf6 = Object.getPrototypeOf(InAppNavigationRecord);
const r187 = Object.create(InAppNavigationRecord.prototype);
const r189 = $callWithNewTarget(prototypeOf6, r187, InAppNavigationRecord);
const id6 = r180.collectionId != null ? `${r180.type}_${r180.collectionId}` : r180.type;
const r201 = r189 instanceof Object ? r189 : r187;
r201.id = id6;
r201.path = r180.path;
r201.type = r180.type;
r201.label = r180.label;
r201.collectionId = r180.collectionId;
r201.IconComponent = r180.IconComponent;
return r201;
}
if (c3038_5.APPS_HOME === a0) {
const r150 = {
path: Routes.GLOBAL_DISCOVERY_APPS,
type: c3038_5.APPS_HOME
};
const prototypeOf5 = Object.getPrototypeOf(InAppNavigationRecord);
const r157 = Object.create(InAppNavigationRecord.prototype);
const r159 = $callWithNewTarget(prototypeOf5, r157, InAppNavigationRecord);
const id5 = r150.collectionId != null ? `${r150.type}_${r150.collectionId}` : r150.type;
const r171 = r159 instanceof Object ? r159 : r157;
r171.id = id5;
r171.path = r150.path;
r171.type = r150.type;
r171.label = r150.label;
r171.collectionId = r150.collectionId;
r171.IconComponent = r150.IconComponent;
return r171;
}
let path = a1;
if (c3038_5.SETTINGS === a0) {
if (a1 == null) {
path = settingsPathToRoute(UserSettingsPath.ACCOUNT);
}
const r122 = {
path,
label: a2,
type: c3038_5.SETTINGS
};
const prototypeOf4 = Object.getPrototypeOf(InAppNavigationRecord);
const r128 = Object.create(InAppNavigationRecord.prototype);
const r130 = $callWithNewTarget(prototypeOf4, r128, InAppNavigationRecord);
const id4 = r122.collectionId != null ? `${r122.type}_${r122.collectionId}` : r122.type;
const r141 = r130 instanceof Object ? r130 : r128;
r141.id = id4;
r141.path = r122.path;
r141.type = r122.type;
r141.label = r122.label;
r141.collectionId = r122.collectionId;
r141.IconComponent = r122.IconComponent;
return r141;
}
if (c3038_5.PLAYGROUND === a0) {
const path2 = a1 == null ? Routes.APP : a1;
const PLAYGROUND = c3038_5.PLAYGROUND;
const prototypeOf3 = Object.getPrototypeOf(InAppNavigationRecord);
const r100 = Object.create(InAppNavigationRecord.prototype);
const r102 = $callWithNewTarget(prototypeOf3, r100, InAppNavigationRecord);
const id3 = a3 != null ? `${PLAYGROUND}_${a3}` : PLAYGROUND;
const r111 = r102 instanceof Object ? r102 : r100;
r111.id = id3;
r111.path = path2;
r111.type = PLAYGROUND;
r111.label = a2;
r111.collectionId = a3;
r111.IconComponent = a4;
return r111;
}
if (c3038_5.SHOP_ORBS_TAB === a0) {
const r62 = {
path: Routes.COLLECTIBLES_SHOP,
type: c3038_5.SHOP_ORBS_TAB
};
const prototypeOf2 = Object.getPrototypeOf(InAppNavigationRecord);
const r69 = Object.create(InAppNavigationRecord.prototype);
const r71 = $callWithNewTarget(prototypeOf2, r69, InAppNavigationRecord);
const id2 = r62.collectionId != null ? `${r62.type}_${r62.collectionId}` : r62.type;
const r83 = r71 instanceof Object ? r71 : r69;
r83.id = id2;
r83.path = r62.path;
r83.type = r62.type;
r83.label = r62.label;
r83.collectionId = r62.collectionId;
r83.IconComponent = r62.IconComponent;
return r83;
}
if (c3038_5.QUEST_ORBS === a0) {
const r36 = {
path: `${Routes.QUEST_HOME}?filter=${RewardFilterTypes.VIRTUAL_CURRENCY}`,
type: c3038_5.QUEST_ORBS
};
const prototypeOf = Object.getPrototypeOf(InAppNavigationRecord);
const r43 = Object.create(InAppNavigationRecord.prototype);
const r45 = $callWithNewTarget(prototypeOf, r43, InAppNavigationRecord);
const id = r36.collectionId != null ? `${r36.type}_${r36.collectionId}` : r36.type;
const r53 = r45 instanceof Object ? r45 : r43;
r53.id = id;
r53.path = r36.path;
r53.type = r36.type;
r53.label = r36.label;
r53.collectionId = r36.collectionId;
r53.IconComponent = r36.IconComponent;
return r53;
}
throw new Error("Unhandled InAppNavigationType");
}
}
export default InAppNavigationRecord;
export { InAppNavigationRecord };
export { c3038_5 as InAppNavigationType };
@@ -0,0 +1,28 @@
// Metro module 5103 (f5104).
export default function sortByMatchScore(a0, a1) {
if (a0.score === a1.score) {
let sortable = a0.sortable;
if (sortable == null) {
const comparator = a0.comparator;
sortable = comparator == null ? void 0 : comparator.toLocaleLowerCase();
}
if (sortable == null) {
sortable = "";
}
let sortable2 = a0.sortable;
if (sortable2 == null) {
const comparator2 = a1.comparator;
sortable2 = comparator2 == null ? void 0 : comparator2.toLocaleLowerCase();
}
if (sortable2 == null) {
sortable2 = "";
}
if (sortable < sortable2) {
return -1;
}
if (sortable > sortable2) {
return 1;
}
}
return a1.score - a0.score;
};