decord/alpha/source/utils/EmojiUtils.tsx

410 lines
14 KiB
TypeScript
Raw Normal View History

2026-10-03 08:58:59 +00:00
// Module ID: 4527
// Function ID: 4528
// Name: EmojiUtils
2026-10-03 08:58:59 +00:00
// Dependencies: [5, 2055, 4509, 1377, 1085, 1380, 4526, 4528, 5643, 4501, 7411, 1481, 1402, 2]
2026-07-20 16:05:17 +00:00
// Exports: countEmoji, getAllEmojiNamesString, getEmojiColors, getEmojiUrl
2026-10-03 08:58:59 +00:00
// Module 4527 (EmojiUtils)
import Constants from "Constants" /* 1085 */;
import AvatarUtilsDefault from "AvatarUtils" /* 1402 */;
import ImageUtils from "ImageUtils" /* 1481 */;
import CreatorMonetizationRestrictionsUtils from "CreatorMonetizationRestrictionsUtils" /* 4501 */;
import EmojiTypes from "EmojiTypes" /* 4526 */;
import PremiumUtilsDefault from "PremiumUtils" /* 4528 */;
import RoleSubscriptionEmojiUtils from "RoleSubscriptionEmojiUtils" /* 5643 */;
import EmojiUtilsPlatformedDefault from "EmojiUtilsPlatformed" /* 7411 */;
import _asyncToGenerator from "_asyncToGenerator" /* 5 */;
import ChannelRecord from "ChannelRecord" /* 2055 */;
import PermissionStore from "PermissionStore" /* 4509 */;
import UserStore from "UserStore" /* 1377 */;
import EmojiConstants from "EmojiConstants" /* 1380 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let animated, c1, c2, closure_1, closure_2, closure_3, closure_5, closure_6, customExternal, dependencyMap, importDefault, managed, managedExternal;
let EmojiDisabledReasons;
let c10;
let c9;
let closure_14;
let closure_4;
let hasOwnProperty;
let map1;
let unpackModuleId;
2026-08-25 06:04:03 +00:00
function getEmojiUnavailableReason(forceIncludeExternalGuilds) {
2026-10-03 08:58:59 +00:00
let bypassPremiumEmojiEntitlement;
let channel;
let emoji;
let guildId;
let intention;
2026-08-25 06:04:03 +00:00
({ emoji, channel, guildId } = forceIncludeExternalGuilds);
2026-07-20 16:05:17 +00:00
if (guildId === undefined) {
let guildId1;
2026-07-29 08:29:29 +00:00
if (channel != null) {
guildId1 = channel.getGuildId();
2026-07-20 16:05:17 +00:00
}
guildId = guildId1;
2026-07-20 16:05:17 +00:00
}
2026-08-25 06:04:03 +00:00
({ intention, bypassPremiumEmojiEntitlement } = forceIncludeExternalGuilds);
2026-10-03 08:58:59 +00:00
forceIncludeExternalGuilds = forceIncludeExternalGuilds.forceIncludeExternalGuilds;
const tmp5 = emoji.type === EmojiTypes.EmojiTypes.GUILD || null != emoji.guildId;
2026-07-29 08:29:29 +00:00
if (tmp5) {
2026-10-03 08:58:59 +00:00
if (intention !== map1.GUILD_PROFILE) {
if (intention !== map1.NO_CUSTOM_EMOJI) {
const tmp10 = null != channel && managed(channel.type);
null != channel && hasOwnProperty(channel.type);
2026-07-29 08:29:29 +00:00
let tmp13 = null != emoji && null != guildId;
if (tmp13) {
2026-10-03 08:58:59 +00:00
const tmp14 = emoji.type === EmojiTypes.EmojiTypes.GUILD || null != emoji.guildId;
2026-07-29 08:29:29 +00:00
let tmp15 = !tmp14;
if (tmp14) {
tmp15 = guildId === emoji.guildId;
}
tmp13 = tmp15;
}
2026-10-03 08:58:59 +00:00
if (intention === map1.COMMUNITY_CONTENT) {
2026-07-29 08:29:29 +00:00
if (tmp13) {
2026-10-03 08:58:59 +00:00
let DISALLOW_EXTERNAL;
2026-07-20 16:05:17 +00:00
if (null != emoji.guildId) {
2026-10-03 08:58:59 +00:00
DISALLOW_EXTERNAL = null;
2026-07-20 16:05:17 +00:00
}
return DISALLOW_EXTERNAL;
}
DISALLOW_EXTERNAL = EmojiDisabledReasons.DISALLOW_EXTERNAL;
} else {
2026-10-03 08:58:59 +00:00
let PREMIUM_LOCKED;
if (!authStore2(intention)) {
2026-07-29 08:29:29 +00:00
let tmp19 = null != emoji && null != guildId;
if (tmp19) {
2026-10-03 08:58:59 +00:00
const tmp20 = emoji.type === EmojiTypes.EmojiTypes.GUILD || null != emoji.guildId;
2026-07-29 08:29:29 +00:00
let tmp21 = !tmp20;
if (tmp20) {
tmp21 = guildId === emoji.guildId;
}
tmp19 = tmp21;
}
if (!tmp19) {
2026-10-03 08:58:59 +00:00
if (!forceIncludeExternalGuilds) {
2026-07-20 16:05:17 +00:00
return EmojiDisabledReasons.DISALLOW_EXTERNAL;
}
}
}
2026-07-29 08:29:29 +00:00
if (tmp10) {
if (!tmp13) {
if (!tmp18) {
2026-07-20 16:05:17 +00:00
return EmojiDisabledReasons.DISALLOW_EXTERNAL;
}
}
}
if (null != emoji.id) {
if (!emoji.available) {
return EmojiDisabledReasons.GUILD_SUBSCRIPTION_UNAVAILABLE;
}
}
const currentUser = UserStore.getCurrentUser();
2026-08-25 06:04:03 +00:00
if (!bypassPremiumEmojiEntitlement) {
2026-10-03 08:58:59 +00:00
obj = PremiumUtilsDefault;
2026-08-25 06:04:03 +00:00
if (!obj.canUseEmojisEverywhere(currentUser)) {
if (!tmp13) {
2026-10-03 08:58:59 +00:00
if (intention === map1.STATUS) {
2026-08-25 06:04:03 +00:00
return EmojiDisabledReasons.PREMIUM_LOCKED;
} else if (!emoji.managed) {
return EmojiDisabledReasons.PREMIUM_LOCKED;
}
2026-07-20 16:05:17 +00:00
}
}
}
2026-10-03 08:58:59 +00:00
const isUnusableRoleSubscriptionEmoji = RoleSubscriptionEmojiUtils.isUnusableRoleSubscriptionEmoji;
RoleSubscriptionEmojiUtils;
if (isUnusableRoleSubscriptionEmoji(emoji, guildId)) {
const tmp3Result3 = CreatorMonetizationRestrictionsUtils;
PREMIUM_LOCKED = tmp3Result3.shouldHideGuildPurchaseEntryPoints(emoji.guildId) ? tmp34.ROLE_SUBSCRIPTION_UNAVAILABLE : tmp34.ROLE_SUBSCRIPTION_LOCKED;
2026-07-20 16:05:17 +00:00
} else {
2026-10-03 08:58:59 +00:00
PREMIUM_LOCKED = null;
2026-07-20 16:05:17 +00:00
if (emoji.animated) {
PREMIUM_LOCKED = null;
2026-08-25 06:04:03 +00:00
if (!bypassPremiumEmojiEntitlement) {
2026-07-20 16:05:17 +00:00
PREMIUM_LOCKED = null;
2026-10-03 08:58:59 +00:00
const obj2 = PremiumUtilsDefault;
if (!obj2.canUseAnimatedEmojis(currentUser)) {
2026-08-25 06:04:03 +00:00
PREMIUM_LOCKED = null;
2026-10-03 08:58:59 +00:00
const tmp3Result4 = RoleSubscriptionEmojiUtils;
if (!tmp3Result4.isPurchasableRoleSubscriptionEmoji(emoji)) {
2026-08-25 06:04:03 +00:00
PREMIUM_LOCKED = EmojiDisabledReasons.PREMIUM_LOCKED;
}
2026-07-20 16:05:17 +00:00
}
}
}
}
2026-10-03 08:58:59 +00:00
return PREMIUM_LOCKED;
2026-07-20 16:05:17 +00:00
}
}
}
return EmojiDisabledReasons.DISALLOW_CUSTOM;
} else {
return null;
}
}
2026-10-03 08:58:59 +00:00
let obj = function _getEmojiColors() {
obj = _asyncToGenerator(async (arg0, value) => {
let obj3;
let closure_0 = arg0;
if (c1 === 2) {
c1 = 3;
throw new TypeError("Generator functions may not be called on executing generators");
} else if (tmp2 === 3) {
if (arg0 === 1) {
throw value;
} else if (arg0 === 2) {
const obj2 = { value, done: true };
return obj2;
} else {
2026-10-05 08:00:40 +00:00
return { value: "IconComponent", done: null };
2026-10-03 08:58:59 +00:00
}
} else {
try {
c1 = 2;
if (0 === c2) {
if (arg0 === 1) {
c1 = 3;
throw value;
} else if (arg0 === 2) {
c1 = 3;
const obj4 = { value, done: true };
return obj4;
} else {
c2 = 1;
c1 = 1;
const obj5 = { value: obj3.getEmojiColors(closure_0), done: false };
obj3 = EmojiUtilsPlatformedDefault;
return obj5;
}
} else if (arg0 === 1) {
c1 = 3;
throw value;
} else if (arg0 === 2) {
c1 = 3;
const obj6 = { value, done: true };
return obj6;
} else {
c1 = 3;
obj = { value, done: true };
return obj;
}
} catch (tmp7) {
c1 = 3;
throw tmp7;
}
}
});
return obj(...arguments);
};
({ isGuildTextChannelType: closure_4, isGuildVocalChannelType: hasOwnProperty } = ChannelRecord);
2026-10-03 08:58:59 +00:00
const Permissions = Constants.Permissions;
({ EMOJI_MAX_FILESIZE: c9, EMOJI_MAX_LENGTH: c10, EMOJI_RE: unpackModuleId, EmojiDisabledReasons } = EmojiConstants);
({ EmojiIntention: map1, isExternalEmojiAllowedForIntention: closure_14 } = EmojiConstants);
2026-07-29 08:29:29 +00:00
const items = [, ];
2026-07-20 16:05:17 +00:00
({ PREMIUM_LOCKED: arr[0], ROLE_SUBSCRIPTION_LOCKED: arr[1] } = EmojiDisabledReasons);
const set = new Set(items);
2026-07-20 16:05:17 +00:00
const items1 = [...set, EmojiDisabledReasons.GUILD_SUBSCRIPTION_UNAVAILABLE, EmojiDisabledReasons.ROLE_SUBSCRIPTION_UNAVAILABLE];
const set1 = new Set(items1);
const items2 = [, , , ];
({ DISALLOW_CUSTOM: arr3[0], DISALLOW_EXTERNAL: arr3[1], GUILD_SUBSCRIPTION_UNAVAILABLE: arr3[2], ONLY_GUILD_EMOJIS_ALLOWED: arr3[3] } = EmojiDisabledReasons);
const set2 = new Set(items2);
2026-10-03 08:58:59 +00:00
obj = {
2026-07-29 08:29:29 +00:00
sanitizeEmojiName(str) {
2026-07-20 16:05:17 +00:00
let length;
2026-10-03 08:58:59 +00:00
const replaced = str.replace(unpackModuleId, "");
const substr = replaced.slice(0, authStore);
2026-07-20 16:05:17 +00:00
let tmp = substr;
let tmp2 = substr;
if (substr.length < 2) {
do {
let text = `${tmp}_`;
tmp = text;
tmp2 = text;
length = `${tmp}_`.length;
} while (length < 2);
}
return tmp2;
},
filterUnsupportedEmojis: EmojiUtilsPlatformedDefault.filterUnsupportedEmojis,
getURL: EmojiUtilsPlatformedDefault.getURL,
isInternalEmojiForGuildId(type, arg1) {
2026-07-29 08:29:29 +00:00
let tmp = null != type && null != arg1;
if (tmp) {
2026-08-24 06:08:38 +00:00
const tmp4 = type.type === EmojiTypes.EmojiTypes.GUILD || null != type.guildId;
2026-07-29 08:29:29 +00:00
let tmp5 = !tmp4;
if (tmp4) {
tmp5 = arg1 === type.guildId;
}
tmp = tmp5;
}
return tmp;
},
2026-07-20 16:05:17 +00:00
getEmojiUnavailableReason,
2026-07-29 08:29:29 +00:00
isCustomEmoji(emoji) {
2026-10-03 08:58:59 +00:00
const tmp = emoji.type === EmojiTypes.EmojiTypes.GUILD || null != emoji.guildId;
2026-07-29 08:29:29 +00:00
return tmp;
},
2026-10-03 08:58:59 +00:00
getEmojiUnavailableReasons(categoryEmojis) {
let bypassPremiumEmojiEntitlement;
let channel;
let guildId;
let intention;
categoryEmojis = categoryEmojis.categoryEmojis;
({ channel, guildId, intention, bypassPremiumEmojiEntitlement } = categoryEmojis);
2026-07-29 08:29:29 +00:00
const emojisDisabled = new Set();
const emojisUnfiltered = [];
let emojisPremiumLockedCount = 0;
let emojiNitroLocked = false;
2026-10-03 08:58:59 +00:00
const iter = categoryEmojis[Symbol.iterator]();
2026-07-29 08:29:29 +00:00
const nextResult = iter.next();
while (iter !== undefined) {
let tmp2 = nextResult;
2026-10-03 08:58:59 +00:00
obj = { emoji: nextResult, channel, guildId, intention, bypassPremiumEmojiEntitlement };
2026-07-29 08:29:29 +00:00
let tmp4 = getEmojiUnavailableReason(obj);
let tmp5 = tmp4;
if (null != tmp4) {
if (!set2.has(tmp5)) {
let arr = emojisUnfiltered.push(tmp2);
}
if (set1.has(tmp5)) {
if (null != tmp2.id) {
let addResult = emojisDisabled.add(tmp2.id);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (set.has(tmp5)) {
let tmp19 = emojiNitroLocked;
2026-10-03 08:58:59 +00:00
if (!tmp19) {
2026-07-29 08:29:29 +00:00
tmp19 = tmp5 !== EmojiDisabledReasons.PREMIUM_LOCKED;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!tmp19) {
emojiNitroLocked = true;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
emojisPremiumLockedCount = emojisPremiumLockedCount + 1;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
} else {
let arr3 = emojisUnfiltered.push(tmp2);
2026-07-29 08:29:29 +00:00
}
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return { emojisDisabled, emojisUnfiltered, emojisPremiumLockedCount, emojiNitroLocked };
2026-07-20 16:05:17 +00:00
},
2026-08-25 06:04:03 +00:00
isEmojiFiltered(forceIncludeExternalGuilds) {
return set2.has(getEmojiUnavailableReason(forceIncludeExternalGuilds));
2026-07-20 16:05:17 +00:00
},
2026-08-25 06:04:03 +00:00
isEmojiPremiumLocked(forceIncludeExternalGuilds) {
return set.has(getEmojiUnavailableReason(forceIncludeExternalGuilds));
2026-07-20 16:05:17 +00:00
},
isEmojiCategoryNitroLocked(categoryEmojis) {
2026-10-03 08:58:59 +00:00
let channel;
let guildId;
let intention;
2026-07-20 16:05:17 +00:00
categoryEmojis = categoryEmojis.categoryEmojis;
let flag = false;
let num = 0;
2026-07-29 08:29:29 +00:00
({ channel, guildId, intention } = categoryEmojis);
2026-10-03 08:58:59 +00:00
const tmp = categoryEmojis[Symbol.iterator]();
2026-07-29 08:29:29 +00:00
while (tmp !== undefined) {
2026-10-03 08:58:59 +00:00
obj = { emoji: tmp2, channel, intention, guildId };
2026-07-29 08:29:29 +00:00
let tmp4 = getEmojiUnavailableReason(obj);
if (tmp4 === EmojiDisabledReasons.PREMIUM_LOCKED) {
flag = true;
num = num + 1;
} else if (tmp5 === tmp6.GUILD_SUBSCRIPTION_UNAVAILABLE) {
num = num + 1;
2026-07-29 08:29:29 +00:00
}
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (flag) {
flag = num === categoryEmojis.length;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return flag;
2026-07-20 16:05:17 +00:00
},
2026-08-25 06:04:03 +00:00
isEmojiFilteredOrLocked(forceIncludeExternalGuilds) {
2026-07-20 16:05:17 +00:00
const self = this;
2026-10-03 08:58:59 +00:00
const tmp = this.isEmojiFiltered(forceIncludeExternalGuilds) || self.isEmojiPremiumLocked(forceIncludeExternalGuilds);
return tmp;
2026-07-20 16:05:17 +00:00
},
2026-08-25 06:04:03 +00:00
isEmojiDisabled(forceIncludeExternalGuilds) {
return set1.has(getEmojiUnavailableReason(forceIncludeExternalGuilds));
2026-07-20 16:05:17 +00:00
},
isFileTooBig(size) {
return size.size > 2097152;
},
2026-10-03 08:58:59 +00:00
isDataTooBig(base64) {
obj = ImageUtils;
return obj.dataUriFileSize(base64) > React4;
2026-07-20 16:05:17 +00:00
}
};
2026-10-03 08:58:59 +00:00
const result = size.fileFinishedImporting("utils/EmojiUtils.tsx");
export default obj;
export const countEmoji = function countEmoji(arr, arg1) {
2026-10-03 08:58:59 +00:00
let closure_0 = arg1;
importDefault = 0;
dependencyMap = 0;
customExternal = 0;
managed = 0;
managedExternal = 0;
animated = 0;
2026-07-20 16:05:17 +00:00
const item = arr.forEach((id) => {
if (null != id.id) {
if (id.type === EmojiTypes.EmojiTypes.GUILD) {
if (id.guildId === closure_0) {
2026-07-20 16:05:17 +00:00
if (id.managed) {
closure_4 = closure_4 + 1;
} else {
closure_2 = closure_2 + 1;
}
} else if (id.managed) {
closure_5 = closure_5 + 1;
} else {
closure_3 = closure_3 + 1;
}
}
if (id.animated) {
2026-08-24 06:08:38 +00:00
closure_6 = closure_6 + 1;
2026-07-20 16:05:17 +00:00
}
} else {
closure_1 = closure_1 + 1;
}
});
return { unicode: importDefault, custom: dependencyMap, customExternal, managed, managedExternal, animated };
2026-07-20 16:05:17 +00:00
};
export const getEmojiColors = function getEmojiColors() {
2026-10-03 08:58:59 +00:00
return obj(...arguments);
2026-07-20 16:05:17 +00:00
};
export const getEmojiUrl = function getEmojiUrl(arg0, arg1) {
2026-10-03 08:58:59 +00:00
let emojiURL;
let id;
2026-07-20 16:05:17 +00:00
let num = arg1;
if (arg1 === undefined) {
num = 32;
}
({ id, animated } = arg0);
if (null != id) {
2026-10-03 08:58:59 +00:00
const obj2 = { id, size: num, animated };
const getEmojiURL = AvatarUtilsDefault.getEmojiURL;
AvatarUtilsDefault;
2026-07-29 08:29:29 +00:00
if (animated == null) {
animated = false;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
emojiURL = getEmojiURL(obj2);
2026-07-20 16:05:17 +00:00
} else {
2026-10-03 08:58:59 +00:00
obj = EmojiUtilsPlatformedDefault;
emojiURL = obj.getURL(tmp);
2026-07-20 16:05:17 +00:00
}
return emojiURL;
};
export const getAllEmojiNamesString = function getAllEmojiNamesString(emojiByIdOrName) {
2026-10-03 08:58:59 +00:00
let allNamesString;
2026-07-20 16:05:17 +00:00
if ("allNamesString" in emojiByIdOrName) {
2026-10-03 08:58:59 +00:00
allNamesString = emojiByIdOrName.allNamesString;
2026-07-20 16:05:17 +00:00
} else {
const _HermesInternal = HermesInternal;
allNamesString = ":" + emojiByIdOrName.name + ":";
}
return allNamesString;
};