decord/source/modules/voice_channel_effects/VoiceChannelEffectsUtils.tsx

204 lines
7.6 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 7347
// Function ID: 7348
2026-07-29 08:29:29 +00:00
// Name: VoiceChannelEffectAnimationType
2026-08-24 06:08:38 +00:00
// Dependencies: [1922, 7346, 7348, 7349, 7350, 7351, 7352, 7353, 7354, 7355, 7356, 7357, 7358, 7359, 7360, 7361, 7362, 7363, 7364, 7365, 7366, 7367, 7368, 7369, 12, 1469, 1435, 4037, 4041, 1236, 2]
2026-07-20 16:05:17 +00:00
// Exports: getEffectAnnouncement, getEffectUrl, sampleAnimationId
2026-08-24 06:08:38 +00:00
// Module 7347 (VoiceChannelEffectAnimationType)
import getAvatarURLDefault from "getAvatarURL" /* 1435 */;
import parseRawEmojiObjectDefault from "parseRawEmojiObject" /* 4037 */;
import getEmojiUnavailableReasonDefault from "getEmojiUnavailableReason" /* 4041 */;
import _modDef7348 from "module_7348" /* 7348 */;
import _modDef7349 from "module_7349" /* 7349 */;
import _modDef7350 from "module_7350" /* 7350 */;
import _modDef7351 from "module_7351" /* 7351 */;
import _modDef7352 from "module_7352" /* 7352 */;
import _modDef7353 from "module_7353" /* 7353 */;
import _modDef7354 from "module_7354" /* 7354 */;
import _modDef7355 from "module_7355" /* 7355 */;
import _modDef7356 from "module_7356" /* 7356 */;
import _modDef7357 from "module_7357" /* 7357 */;
import _modDef7358 from "module_7358" /* 7358 */;
import _modDef7359 from "module_7359" /* 7359 */;
import _modDef7360 from "module_7360" /* 7360 */;
import _modDef7361 from "module_7361" /* 7361 */;
import _modDef7362 from "module_7362" /* 7362 */;
import _modDef7363 from "module_7363" /* 7363 */;
import _modDef7364 from "module_7364" /* 7364 */;
import _modDef7365 from "module_7365" /* 7365 */;
import _modDef7366 from "module_7366" /* 7366 */;
import _modDef7367 from "module_7367" /* 7367 */;
import _modDef7368 from "module_7368" /* 7368 */;
import _modDef7369 from "module_7369" /* 7369 */;
import closure_3 from "mergeGuildAvatar" /* 1922 */;
import VoiceChannelEffectAnimationType from "VoiceChannelEffectAnimationType" /* 7346 */;
import importDefaultResult from "apply" /* 12 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-29 08:29:29 +00:00
({ EMOJI_SIZE: c4, VoiceChannelEffectAnimationType } = VoiceChannelEffectAnimationType);
2026-08-24 06:08:38 +00:00
const items = [_modDef7348];
const items1 = [_modDef7349, _modDef7350, _modDef7351, _modDef7352, _modDef7353, _modDef7354, _modDef7355, _modDef7356, _modDef7357, _modDef7358, _modDef7359, _modDef7360, _modDef7361, _modDef7362, _modDef7363, _modDef7364, _modDef7365, _modDef7366, _modDef7367, _modDef7368, _modDef7369];
2026-07-29 08:29:29 +00:00
let obj = { [VoiceChannelEffectAnimationType.BASIC]: items, [VoiceChannelEffectAnimationType.PREMIUM]: items1 };
2026-08-24 06:08:38 +00:00
const memoizeResult = importDefaultResult.memoize((arg0) => {
closure_0 = arg0;
2026-07-20 16:05:17 +00:00
return new Promise((arg0) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
2026-07-20 16:05:17 +00:00
const image = new globalThis.Image();
2026-07-23 10:11:24 +00:00
image.src = closure_0;
2026-07-20 16:05:17 +00:00
image.crossOrigin = "Anonymous";
image.onload = () => {
2026-08-24 06:08:38 +00:00
const result = closure_2_4 * callback(closure_2_2[25]).getDevicePixelRatio();
2026-07-20 16:05:17 +00:00
if (image.width === result) {
2026-07-29 08:29:29 +00:00
if (tmp2.height === result) {
2026-07-23 10:11:24 +00:00
callback(callback);
2026-07-20 16:05:17 +00:00
}
}
const element = <canvas />;
element.width = result;
element.height = result;
const context = element.getContext("2d");
2026-07-29 08:29:29 +00:00
if (context != null) {
context.drawImage(tmp2, 0, 0);
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
callback(element.toDataURL("image/png"));
2026-07-20 16:05:17 +00:00
};
});
});
2026-08-24 06:08:38 +00:00
let result = require("set").fileFinishedImporting("modules/voice_channel_effects/VoiceChannelEffectsUtils.tsx");
2026-07-20 16:05:17 +00:00
2026-07-23 10:11:24 +00:00
export const CUSTOM_CALL_SOUND_ANIMATION_RANGE = { start: 10, end: 15 };
2026-07-20 16:05:17 +00:00
export const AnimationTypeToAnimations = obj;
export const getResizedEmojiData = memoizeResult;
export const sampleAnimationId = function sampleAnimationId(BASIC, CUSTOM_CALL_SOUND_ANIMATION_RANGE) {
if (null != CUSTOM_CALL_SOUND_ANIMATION_RANGE) {
if (BASIC === VoiceChannelEffectAnimationType.PREMIUM) {
const sum = CUSTOM_CALL_SOUND_ANIMATION_RANGE.end + 1;
const _Math = Math;
const _Math2 = Math;
return Math.floor(Math.random() * (CUSTOM_CALL_SOUND_ANIMATION_RANGE.start - sum) + sum);
}
}
return Math.floor(Math.random() * obj[BASIC].length);
};
export const getEffectUrl = function getEffectUrl(emoji) {
let tmp = arg1;
if (arg1 === undefined) {
tmp = closure_4;
}
if (null != emoji.id) {
2026-08-24 06:08:38 +00:00
obj = { id: null, animated: null, size: null };
2026-07-29 08:29:29 +00:00
({ id: obj5[0], animated } = emoji);
if (animated == null) {
animated = false;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[1] = animated;
obj[2] = tmp;
2026-08-24 06:08:38 +00:00
return getAvatarURLDefault.getEmojiURL(obj);
2026-07-20 16:05:17 +00:00
} else {
2026-08-24 06:08:38 +00:00
obj = parseRawEmojiObjectDefault;
2026-07-20 16:05:17 +00:00
const result = obj.convertSurrogateToName(emoji.name, false);
2026-08-24 06:08:38 +00:00
const byName = parseRawEmojiObjectDefault.getByName(result);
2026-07-20 16:05:17 +00:00
let str = "";
if (null != byName) {
2026-08-24 06:08:38 +00:00
str = getEmojiUnavailableReasonDefault.getURL(byName.surrogates);
const tmp2Result = getEmojiUnavailableReasonDefault;
2026-07-20 16:05:17 +00:00
}
return str;
}
};
2026-07-29 08:29:29 +00:00
export const getEffectAnnouncement = function getEffectAnnouncement(closure_7) {
if (closure_7.length < 1) {
2026-07-20 16:05:17 +00:00
return "";
} else {
2026-07-29 08:29:29 +00:00
let emojiName = "userId";
let yZYxzF = dependencyMap;
2026-08-24 06:08:38 +00:00
const mapped = importDefaultResult(closure_7).map((arg0) => {
2026-07-29 08:29:29 +00:00
let tmp = arg0[emojiName];
if (tmp == null) {
tmp = null;
}
return tmp;
});
const found = mapped.filter((arg0) => null != arg0);
2026-08-24 06:08:38 +00:00
const arr = importDefaultResult(closure_7);
obj = found.uniq().value();
2026-07-29 08:29:29 +00:00
emojiName = "emojiName";
const iter = found.uniq();
2026-08-24 06:08:38 +00:00
const mapped1 = importDefaultResult(closure_7).map((arg0) => {
2026-07-29 08:29:29 +00:00
let tmp = arg0[emojiName];
if (tmp == null) {
tmp = null;
}
return tmp;
});
const found1 = mapped1.filter((arg0) => null != arg0);
2026-08-24 06:08:38 +00:00
const arr3 = importDefaultResult(closure_7);
2026-07-29 08:29:29 +00:00
const valueResult = found1.uniq().value();
if (valueResult.length < 2) {
let str2;
if (valueResult != null) {
str2 = valueResult[0];
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (str2 == null) {
str2 = "";
2026-07-20 16:05:17 +00:00
}
let joined = str2;
} else {
2026-07-29 08:29:29 +00:00
joined = valueResult.join(", ");
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (obj.length < 1) {
2026-07-20 16:05:17 +00:00
return "";
2026-07-29 08:29:29 +00:00
} else if (1 === obj.length) {
const intl2 = emojiName(1236).intl;
yZYxzF = emojiName(1236).t.yZYxzF;
const user = authStore.getUser(obj[0]);
2026-07-20 16:05:17 +00:00
let username;
2026-07-29 08:29:29 +00:00
if (user != null) {
2026-07-20 16:05:17 +00:00
username = user.username;
}
2026-07-29 08:29:29 +00:00
obj = { firstUsername: null, emojiNames: null };
obj[0] = username;
obj[1] = joined;
let formatToPlainStringResult = intl2.formatToPlainString(yZYxzF, obj);
} else if (2 === obj.length) {
const intl = emojiName(1236).intl;
const user1 = authStore.getUser(obj[0]);
2026-07-20 16:05:17 +00:00
let username1;
2026-07-29 08:29:29 +00:00
if (user1 != null) {
2026-07-20 16:05:17 +00:00
username1 = user1.username;
}
2026-07-29 08:29:29 +00:00
obj = { firstUsername: null, secondUsername: null, emojiNames: null };
obj[0] = username1;
const user2 = authStore.getUser(obj[1]);
2026-07-20 16:05:17 +00:00
let username2;
2026-07-29 08:29:29 +00:00
if (user2 != null) {
2026-07-20 16:05:17 +00:00
username2 = user2.username;
}
2026-07-29 08:29:29 +00:00
obj[1] = username2;
obj[2] = joined;
formatToPlainStringResult = intl.formatToPlainString(emojiName(1236).t["8rmtbd"], obj);
const obj2 = authStore;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
const intl3 = emojiName(1236).intl;
const user3 = authStore.getUser(obj[0]);
2026-07-20 16:05:17 +00:00
let username3;
2026-07-29 08:29:29 +00:00
if (user3 != null) {
2026-07-20 16:05:17 +00:00
username3 = user3.username;
}
2026-07-29 08:29:29 +00:00
obj = { firstUsername: null, secondUsername: null, count: null, emojiNames: null };
obj[0] = username3;
const user4 = authStore.getUser(obj[1]);
2026-07-20 16:05:17 +00:00
let username4;
2026-07-29 08:29:29 +00:00
if (user4 != null) {
2026-07-20 16:05:17 +00:00
username4 = user4.username;
}
2026-07-29 08:29:29 +00:00
obj[1] = username4;
obj[2] = obj.length - 2;
obj[3] = joined;
formatToPlainStringResult = intl3.formatToPlainString(emojiName(1236).t["/okjv0"], obj);
const obj7 = authStore;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const iter2 = found1.uniq();
2026-07-20 16:05:17 +00:00
}
};