decord/source/modules/voice_channel_effects/VoiceChannelEffectsUtils.tsx
github-actions f0f877e8ce chore: update source for alpha 347.1
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4824.js (118.4 MB)
2026-09-15 14:23:42 +00:00

195 lines
7.1 KiB
TypeScript

// Module ID: 7456
// Function ID: 7457
// Name: VoiceChannelEffectsUtils
// Dependencies: [1372, 7455, 7457, 7458, 7459, 7460, 7461, 7462, 7463, 7464, 7465, 7466, 7467, 7468, 7469, 7470, 7471, 7472, 7473, 7474, 7475, 7476, 7477, 7478, 12, 1431, 1397, 4292, 4296, 1115, 2]
// Exports: getEffectAnnouncement, getEffectUrl, sampleAnimationId
// Module 7456 (VoiceChannelEffectsUtils)
import util from "util" /* 1115 */;
import AvatarUtilsDefault from "AvatarUtils" /* 1397 */;
import ImageLoaderUtils from "ImageLoaderUtils" /* 1431 */;
import UnicodeEmojisDefault from "UnicodeEmojis" /* 4292 */;
import _modDef7457 from "module_7457" /* 7457 */;
import _modDef7458 from "module_7458" /* 7458 */;
import _modDef7459 from "module_7459" /* 7459 */;
import _modDef7460 from "module_7460" /* 7460 */;
import _modDef7461 from "module_7461" /* 7461 */;
import _modDef7462 from "module_7462" /* 7462 */;
import _modDef7463 from "module_7463" /* 7463 */;
import _modDef7464 from "module_7464" /* 7464 */;
import _modDef7465 from "module_7465" /* 7465 */;
import _modDef7466 from "module_7466" /* 7466 */;
import _modDef7467 from "module_7467" /* 7467 */;
import _modDef7468 from "module_7468" /* 7468 */;
import _modDef7469 from "module_7469" /* 7469 */;
import _modDef7470 from "module_7470" /* 7470 */;
import _modDef7471 from "module_7471" /* 7471 */;
import _modDef7472 from "module_7472" /* 7472 */;
import _modDef7473 from "module_7473" /* 7473 */;
import _modDef7474 from "module_7474" /* 7474 */;
import _modDef7475 from "module_7475" /* 7475 */;
import _modDef7476 from "module_7476" /* 7476 */;
import _modDef7477 from "module_7477" /* 7477 */;
import _modDef7478 from "module_7478" /* 7478 */;
import UserStore from "UserStore" /* 1372 */;
import apply from "module_12" /* 12 */;
require = fn;
const VoiceChannelEffectsConstants = fn(7455);
({ EMOJI_SIZE: closure_4, VoiceChannelEffectAnimationType } = VoiceChannelEffectsConstants);
const items = [_modDef7457];
const items1 = [_modDef7458, _modDef7459, _modDef7460, _modDef7461, _modDef7462, _modDef7463, _modDef7464, _modDef7465, _modDef7466, _modDef7467, _modDef7468, _modDef7469, _modDef7470, _modDef7471, _modDef7472, _modDef7473, _modDef7474, _modDef7475, _modDef7476, _modDef7477, _modDef7478];
const AnimationTypeToAnimations = { [VoiceChannelEffectAnimationType.BASIC]: items, [VoiceChannelEffectAnimationType.PREMIUM]: items1 };
const size = fn(2);
let result = size.fileFinishedImporting("modules/voice_channel_effects/VoiceChannelEffectsUtils.tsx");
export const CUSTOM_CALL_SOUND_ANIMATION_RANGE = { start: 10, end: 15 };
export { AnimationTypeToAnimations };
export const getResizedEmojiData = apply.memoize((src) => new Promise((arg0) => {
src = arg0;
const image = new globalThis.Image();
image.src = src;
image.crossOrigin = "Anonymous";
image.onload = () => {
const result = React4 * ImageLoaderUtils.getDevicePixelRatio();
if (image.width === result) {
if (tmp2.height === result) {
closure_0(closure_0);
}
}
const element = <canvas />;
element.width = result;
element.height = result;
const context = element.getContext("2d");
if (context != null) {
context.drawImage(tmp2, 0, 0);
}
closure_0(element.toDataURL("image/png"));
};
}));
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 = React4;
}
if (null != emoji.id) {
const obj3 = { id: null, animated: null, size: null };
({ id: obj5.id, animated } = emoji);
if (animated == null) {
animated = false;
}
obj3.animated = animated;
obj3.size = tmp;
return AvatarUtilsDefault.getEmojiURL(obj3);
} else {
const result = UnicodeEmojisDefault.convertSurrogateToName(emoji.name, false);
const tmp2 = importDefault;
const byName = UnicodeEmojisDefault.getByName(result);
let str = "";
if (null != byName) {
str = tmp2(4296).getURL(byName.surrogates);
const tmp2Result = tmp2(4296);
}
return str;
}
};
export const getEffectAnnouncement = function getEffectAnnouncement(items) {
if (items.length < 1) {
return "";
} else {
let emojiName = "userId";
let yZYxzF = dependencyMap;
const mapped = apply(items).map((item) => {
let tmp = item[emojiName];
if (tmp == null) {
tmp = null;
}
return tmp;
});
const found = mapped.filter((item) => null != item);
const arr = apply(items);
let obj3 = found.uniq().value();
emojiName = "emojiName";
const iter = found.uniq();
const mapped1 = apply(items).map((item) => {
let tmp = item[emojiName];
if (tmp == null) {
tmp = null;
}
return tmp;
});
const found1 = mapped1.filter((item) => null != item);
const arr3 = apply(items);
const valueResult2 = found1.uniq().value();
if (valueResult2.length < 2) {
let str2;
if (valueResult2 != null) {
str2 = valueResult2[0];
}
if (str2 == null) {
str2 = "";
}
let joined = str2;
} else {
joined = valueResult2.join(", ");
}
if (obj3.length < 1) {
return "";
} else if (1 === obj3.length) {
const intl2 = util.intl;
yZYxzF = util.t.yZYxzF;
const user = UserStore.getUser(obj3[0]);
let username;
if (user != null) {
username = user.username;
}
obj3 = { firstUsername: username, emojiNames: joined };
let formatToPlainStringResult = intl2.formatToPlainString(yZYxzF, obj3);
} else if (2 === obj3.length) {
const intl = util.intl;
const user1 = UserStore.getUser(obj3[0]);
let username1;
if (user1 != null) {
username1 = user1.username;
}
const obj4 = { firstUsername: username1, secondUsername: null, emojiNames: null };
const user2 = UserStore.getUser(obj3[1]);
let username2;
if (user2 != null) {
username2 = user2.username;
}
obj4.secondUsername = username2;
obj4.emojiNames = joined;
formatToPlainStringResult = intl.formatToPlainString(util.t["8rmtbd"], obj4);
} else {
const intl3 = util.intl;
const user3 = UserStore.getUser(obj3[0]);
let username3;
if (user3 != null) {
username3 = user3.username;
}
const obj = { firstUsername: username3, secondUsername: null, count: null, emojiNames: null };
const user4 = UserStore.getUser(obj3[1]);
let username4;
if (user4 != null) {
username4 = user4.username;
}
obj.secondUsername = username4;
obj.count = obj3.length - 2;
obj.emojiNames = joined;
formatToPlainStringResult = intl3.formatToPlainString(util.t["/okjv0"], obj);
}
const iter2 = found1.uniq();
}
};