Files
discord-decomp/utils/EmojiUtilsPlatformed.native.tsx
T
2026-11-01 12:12:55 +02:00

147 lines
5.4 KiB
TypeScript

// Metro module 6094 (f6095).
import _slicedToArray from "../_bundle/_slicedToArray";
import { processColor, NativeModules } from "react-native";
import defaultImageSrcGenerator from "../_bundle/defaultImageSrcGenerator";
import { getSystemVersionMajor, getSystemVersionMinor } from "./native/DeviceUtils";
import * as _PlatformUtils from "./PlatformUtils";
import Module12 from "../_bundle/Module12";
import AvatarUtils from "./AvatarUtils";
import { EMOJI_IN_ANIMATION_SIZE } from "../modules/messages/native/burst_reactions/BurstReactionEffectUtils";
import { getPaletteForAvatar } from "./ImageUtils";
import { rgbToHex } from "./ColorUtils";
import { openBurstReactionFirstSendActionSheet } from "../components_native/reactions/BurstReactionFirstSendActionSheet";
import MemoizerUtils from "./MemoizerUtils";
function $mk114867($env) {
return (a0) => {
const r7 = (0, _slicedToArray)(a0, 3);
return rgbToHex(r7[0], r7[1], r7[2]);
};
}
let env3873 = {};
const getURL = function getURL(a0) {
let r5, r11;
if (a0 != null) {
const isAndroid = _PlatformUtils.isAndroid();
r11 = "";
if (isAndroid) {
r5 = defaultImageSrcGenerator.convert.toCodePoint(a0);
r11 = `asset:/emoji-${r5}.png`;
}
} else {
r5 = defaultImageSrcGenerator.convert.toCodePoint(a0);
r11 = `asset:/emoji-${r5}.png`;
}
return r11;
};
const r28 = {
getURL: MemoizerUtils.makeMemoizer(getURL),
filterUnsupportedEmojis: function filterUnsupportedEmojis(a0) {
return _PlatformUtils.isAndroid() ? a0 : Module12.filter(a0, (a0) => {
let r18;
L62: {
const unicodeVersion = a0.unicodeVersion;
const systemVersionMajor = getSystemVersionMajor();
const systemVersionMinor = getSystemVersionMinor();
const r1 = unicodeVersion > 8;
r18 = true;
if (r1) {
if (unicodeVersion === 9) {
r18 = systemVersionMajor > 10 || systemVersionMajor === 10 && systemVersionMinor >= 2;
} else if (unicodeVersion === 10) {
r18 = systemVersionMajor > 11 || systemVersionMajor === 11 && systemVersionMinor >= 1;
} else if (unicodeVersion === 11) {
r18 = systemVersionMajor > 12 || systemVersionMajor === 12 && systemVersionMinor >= 1;
} else {
if (unicodeVersion !== 12 && unicodeVersion !== 12.1) {
if (unicodeVersion === 13) {
r18 = systemVersionMajor > 14 || systemVersionMajor === 14 && systemVersionMinor >= 2;
break L62;
}
if (unicodeVersion === 13.1) {
r18 = systemVersionMajor > 14 || systemVersionMajor === 14 && systemVersionMinor >= 5;
break L62;
}
if (unicodeVersion === 14) {
r18 = systemVersionMajor > 15 || systemVersionMajor === 15 && systemVersionMinor >= 4;
break L62;
}
if (unicodeVersion === 15) {
r18 = systemVersionMajor > 16 || systemVersionMajor === 16 && systemVersionMinor >= 4;
break L62;
}
if (unicodeVersion === 15.1) {
r18 = systemVersionMajor > 17 || systemVersionMajor === 17 && systemVersionMinor >= 4;
break L62;
}
r18 = false;
if (unicodeVersion !== 16) {
break L62;
}
r18 = systemVersionMajor > 18 || systemVersionMajor === 18 && systemVersionMinor >= 4;
break L62;
}
r18 = systemVersionMajor > 13 || systemVersionMajor === 13 && systemVersionMinor >= 2;
}
}
}
return r18;
});
},
applyPlatformToThemedEmojiColorPalette: function applyPlatformToThemedEmojiColorPalette({ palette, shouldProcessMobileColors = false }) {
if (shouldProcessMobileColors && palette != null) {
const { LIGHT, DARK } = palette;
return {
LIGHT: {
accentColor: processColor(LIGHT?.accentColor),
backgroundColor: processColor(LIGHT?.backgroundColor),
highlightColor: processColor(LIGHT?.highlightColor),
opacity: LIGHT?.opacity
},
DARK: {
accentColor: processColor(DARK?.accentColor),
backgroundColor: processColor(DARK?.backgroundColor),
highlightColor: processColor(DARK?.highlightColor),
opacity: DARK?.opacity
}
};
}
return palette;
},
getEmojiColors: async function getEmojiColors(c25710_0) {
let r67;
let env29667;
const r32 = env3873;
let c25710_2 = r32;
const r11 = env29667 = {
$parent: r32
};
let c25710_1 = r11;
env29667[0] = void 0;
env29667[1] = void 0;
const { id, name } = c25710_0;
const r37 = id != null ? AvatarUtils.getEmojiURL({
id,
size: 32,
animated: false
}) : getURL(name);
env29667[0] = r37;
if (r37 === "") {
env29667[0] = `data:image/png;base64,${await NativeModules.ImageManager.getEmojiBase64(c25710_0.name, EMOJI_IN_ANIMATION_SIZE)}`;
r67 = await getPaletteForAvatar(env29667[0]);
} else {
r67 = await getPaletteForAvatar(env29667[0]);
}
env29667[1] = r67;
const r76 = env29667[1];
return r76 == null ? void 0 : r76.map($mk114867(env3873));
},
triggerFullscreenAnimation: function triggerFullscreenAnimation(a0) {
openBurstReactionFirstSendActionSheet({
channelId: a0.channelId,
messageId: a0.messageId,
emoji: a0.emoji
});
}
};
export default r28;