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

@@ -0,0 +1,26 @@
// Metro module 8848 (f8849).
import { useMemo } from "react";
import UserSettingsProtoStore from "../user_settings/UserSettingsProtoStore";
import UserStore from "../../stores/UserStore";
import { getVideoBackgroundOptionFromProto, isCustomBackgroundOption, isDefaultBackgroundOption } from "./VideoBackgroundUtils";
import PremiumUtils from "../../utils/PremiumUtils";
import { useStateFromStores } from "../../_bundle/Module589";
export function getLastUsedVideoBackgroundOption(a0) {
const videoBackgroundOptionFromProto = getVideoBackgroundOptionFromProto(UserSettingsProtoStore.settings.voiceAndVideo?.videoBackgroundFilterDesktop, a0.id);
return isCustomBackgroundOption(videoBackgroundOptionFromProto) ? PremiumUtils.canUseCustomBackgrounds(a0) ? typeof videoBackgroundOptionFromProto === "number" ? isDefaultBackgroundOption(videoBackgroundOptionFromProto) ? videoBackgroundOptionFromProto : null : videoBackgroundOptionFromProto : null : typeof videoBackgroundOptionFromProto === "number" ? isDefaultBackgroundOption(videoBackgroundOptionFromProto) ? videoBackgroundOptionFromProto : null : videoBackgroundOptionFromProto;
}
export function useLastUsedVideoBackgroundOption() {
let stateFromStores, videoBackgroundFilterDesktop;
const stateFromStores2 = useStateFromStores([UserSettingsProtoStore], () => UserSettingsProtoStore.settings);
stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
videoBackgroundFilterDesktop = stateFromStores2.voiceAndVideo?.videoBackgroundFilterDesktop;
return useMemo(() => {
const r0 = stateFromStores == null;
let r1 = null;
if (!r0) {
const videoBackgroundOptionFromProto = getVideoBackgroundOptionFromProto(videoBackgroundFilterDesktop, stateFromStores.id);
r1 = isCustomBackgroundOption(videoBackgroundOptionFromProto) ? PremiumUtils.canUseCustomBackgrounds(stateFromStores) ? typeof videoBackgroundOptionFromProto === "number" ? isDefaultBackgroundOption(videoBackgroundOptionFromProto) ? videoBackgroundOptionFromProto : null : videoBackgroundOptionFromProto : null : typeof videoBackgroundOptionFromProto === "number" ? isDefaultBackgroundOption(videoBackgroundOptionFromProto) ? videoBackgroundOptionFromProto : null : videoBackgroundOptionFromProto;
}
return r1;
}, [videoBackgroundFilterDesktop, stateFromStores]);
}
@@ -0,0 +1,168 @@
// Metro module 8846 (f8847).
import MediaEngineStore from "../../stores/MediaEngineStore";
import UserStore from "../../stores/UserStore";
import { Endpoints } from "../../Constants";
import { HTTP } from "../../_bundle/sendRequest";
import Dispatcher from "../../Dispatcher";
import VideoFilterImageError from "./VideoFilterImageError";
import { getLastUsedVideoBackgroundOption } from "./LastUsedVideoBackgroundOption";
import { getVideoBackgroundProtoFromOption, isCustomBackgroundOption } from "./VideoBackgroundUtils";
import { PreloadedUserSettingsActionCreators, UserSettingsDelay } from "../user_settings/UserSettingsProtoActionCreators";
let env5769 = {};
export async function saveLastUsedBackgroundOption(c26299_0) {
let env29990;
const r10 = env5769;
let c26299_2 = r10;
const r29 = env29990 = {
$parent: r10
};
let c26299_1 = r29;
env29990[0] = c26299_0;
env29990[1] = void 0;
await PreloadedUserSettingsActionCreators.updateAsync("voiceAndVideo", (a0) => {
a0.videoBackgroundFilterDesktop = getVideoBackgroundProtoFromOption(env29990[0]);
}, UserSettingsDelay.FREQUENT_USER_ACTION);
if (isCustomBackgroundOption(env29990[0])) {
env29990[1] = await HTTP.post({
url: Endpoints.VIDEO_FILTER_ASSET_LAST_USED(env29990[0].id),
rejectWithError: false
});
Dispatcher.dispatch({
type: "VIDEO_SAVE_LAST_USED_BACKGROUND_OPTION",
backgroundOption: env29990[1].body
});
} else {
Dispatcher.dispatch({
type: "VIDEO_SAVE_LAST_USED_BACKGROUND_OPTION",
backgroundOption: env29990[0]
});
}
}
export async function fetchVideoFilterAssets() {
let r59;
let c26296_2;
let c26296_3 = 0;
let c29987_0, c29987_1;
try {
c29987_0 = void 0;
c26296_3 = 1;
c29987_0 = await HTTP.get({
url: Endpoints.VIDEO_FILTER_ASSETS,
rejectWithError: false
});
Dispatcher.dispatch({
type: "VIDEO_FILTER_ASSETS_FETCH_SUCCESS",
assets: c29987_0.body
});
r59 = c29987_0;
c26296_3 = 0;
} catch ($e) {
const r24 = $e;
let r8 = r24;
c26296_2 = r24;
if (c26296_3 !== 0) {
while (true) {
try {
const r68 = c26296_2;
c26296_3 = 0;
c29987_1 = r68;
Dispatcher.dispatch({
type: "VIDEO_FILTER_ASSETS_FETCH_FAILURE",
error: c29987_1
});
throw c29987_1;
} catch (r64) {
r8 = r64;
c26296_2 = r64;
if (c26296_3 === 0) {
break;
}
}
}
}
throw r8;
}
return r59;
}
export async function uploadVideoFilterAsset(asset, type, c26297_2) {
let body;
let c26297_5;
let c26297_6 = 0;
let c29988_0, c29988_1;
try {
c29988_0 = void 0;
c26297_6 = 1;
c29988_0 = await HTTP.post({
url: Endpoints.VIDEO_FILTER_ASSETS,
body: {
type,
asset,
last_used: c26297_2 == null ? void 0 : c26297_2.toISOString()
},
rejectWithError: false
});
Dispatcher.dispatch({
type: "VIDEO_FILTER_ASSET_UPLOAD_SUCCESS",
videoFilterAsset: c29988_0.body
});
body = c29988_0.body;
c26297_6 = 0;
} catch ($e) {
const r28 = $e;
let r8 = r28;
c26297_5 = r28;
if (c26297_6 !== 0) {
while (true) {
try {
const r79 = c26297_5;
c26297_6 = 0;
c29988_1 = r79;
throw new VideoFilterImageError(c29988_1);
} catch (r75) {
r8 = r75;
c26297_5 = r75;
if (c26297_6 === 0) {
break;
}
}
}
}
throw r8;
}
return body;
}
export async function deleteVideoFilterAsset(c26298_0) {
let c29989_0 = c26298_0;
await HTTP.del({
url: Endpoints.VIDEO_FILTER_ASSET(c26298_0.id),
rejectWithError: false
});
let c29989_1 = getLastUsedVideoBackgroundOption(UserStore.getCurrentUser());
if (isCustomBackgroundOption(c29989_1) && c29989_1.id === c29989_0.id) {
(0, saveLastUsedBackgroundOption)(null);
}
Dispatcher.dispatch({
type: "VIDEO_FILTER_ASSET_DELETE_SUCCESS",
videoFilterAsset: c29989_0
});
}
export function applyMediaFilterSettings(a0) {
if (MediaEngineStore.isSupported()) {
Dispatcher.dispatch({
type: "MEDIA_ENGINE_APPLY_MEDIA_FILTER_SETTINGS",
settings: a0
});
}
}
export function startApplyMediaFilterSettings() {
if (MediaEngineStore.isSupported()) {
Dispatcher.dispatch({
type: "MEDIA_ENGINE_APPLY_MEDIA_FILTER_SETTINGS_START"
});
}
}
export function errorApplyingMediaFilterSettings() {
Dispatcher.dispatch({
type: "MEDIA_ENGINE_APPLY_MEDIA_FILTER_SETTINGS_ERROR"
});
}
@@ -0,0 +1,41 @@
// Metro module 7948 (f7949).
const r12 = {
BACKGROUND: 0,
0: "BACKGROUND"
};
const r14 = {
OPTION_1: 0,
0: "OPTION_1",
OPTION_2: 1,
1: "OPTION_2",
OPTION_3: 2,
2: "OPTION_3",
OPTION_4: 3,
3: "OPTION_4",
OPTION_7: 7,
7: "OPTION_7",
OPTION_8: 8,
8: "OPTION_8",
OPTION_9: 9,
9: "OPTION_9",
OPTION_10: 10,
10: "OPTION_10"
};
const r31 = [r14.OPTION_7, r14.OPTION_8, r14.OPTION_9, r14.OPTION_10];
const r44 = [r14.OPTION_7, r14.OPTION_8, r14.OPTION_9, r14.OPTION_10, r14.OPTION_1, r14.OPTION_2, r14.OPTION_3, r14.OPTION_4].reduce((acc, item, index) => {
const r0 = {
...acc
};
r0[item] = index;
return r0;
}, {});
export { r12 as VideoFilterType };
export { r14 as DefaultVideoBackground };
export { r31 as ANIMATED_DEFAULT_VIDEO_BACKGROUNDS };
export { r44 as DEFAULT_VIDEO_BACKGROUND_SORT };
export const BLUR_BACKGROUND_OPTION = "blur";
export const BACKGROUND_REPLACEMENT_SIZE = {
width: 1280,
height: 720
};
export const MAX_BACKGROUND_IMAGE_UPLOAD_FILESIZE_BYTES = 10485760;
@@ -0,0 +1,120 @@
// Metro module 8844 (f8845).
import UserSettingsProtoStore from "../user_settings/UserSettingsProtoStore";
import MediaEngineStore from "../../stores/MediaEngineStore";
import SelectedChannelStore from "../../stores/SelectedChannelStore";
import UserStore from "../../stores/UserStore";
import { getVideoBackgroundOptionFromProto } from "./VideoBackgroundUtils";
import { FilterSettingsKey } from "../../_bundle/Module4286";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c5767_6, voiceChannelId, c5767_8, c5767_9, c5767_10, c5767_11;
const handleSyncedStoresUpdate = function handleSyncedStoresUpdate() {
if (voiceChannelId !== SelectedChannelStore.getVoiceChannelId()) {
c5767_8 = false;
c5767_10 = false;
c5767_11 = false;
}
const currentUser = UserStore.getCurrentUser();
const r2 = currentUser == null;
let r16 = false;
if (!r2) {
const videoBackgroundOptionFromProto = getVideoBackgroundOptionFromProto(UserSettingsProtoStore.settings.voiceAndVideo?.videoBackgroundFilterDesktop, currentUser.id);
r16 = SelectedChannelStore.getVoiceChannelId() != null && MediaEngineStore.isVideoEnabled() && videoBackgroundOptionFromProto != null;
}
if (r16) {
c5767_8 = true;
}
voiceChannelId = SelectedChannelStore.getVoiceChannelId();
};
c5767_6 = false;
voiceChannelId = null;
c5767_8 = false;
c5767_9 = {};
c5767_10 = false;
c5767_11 = false;
class VideoBackgroundStore extends Module589.Store {
static displayName = "VideoBackgroundStore";
initialize() {
this.waitFor(MediaEngineStore, SelectedChannelStore, UserSettingsProtoStore, UserStore);
this.syncWith([SelectedChannelStore, MediaEngineStore], handleSyncedStoresUpdate);
}
get videoFilterAssets() {
return c5767_9;
}
get hasBeenApplied() {
return c5767_6;
}
get hasUsedBackgroundInCall() {
return c5767_8;
}
get videoBackgroundUnavailable() {
return c5767_10;
}
get videoBackgroundPreviewUnavailable() {
return c5767_11;
}
}
const videoBackgroundStore = new VideoBackgroundStore(Dispatcher, {
VIDEO_FILTER_ASSETS_FETCH_SUCCESS: function handleVideoFilterAssetFetchSuccess({ assets }) {
const r5 = {};
let c16824_0 = r5;
assets.forEach((asset) => {
c16824_0[asset.id] = asset;
return asset;
});
c5767_9 = r5;
},
VIDEO_FILTER_ASSET_UPLOAD_SUCCESS: function handleAddBackground({ videoFilterAsset }) {
const r7 = {
...c5767_9
};
r7[videoFilterAsset.id] = videoFilterAsset;
c5767_9 = r7;
},
VIDEO_FILTER_ASSET_DELETE_SUCCESS: function handleRemoveBackground({ videoFilterAsset }) {
const r2 = {
...c5767_9
};
c5767_9 = r2;
delete r2[videoFilterAsset.id];
},
VIDEO_SAVE_LAST_USED_BACKGROUND_OPTION: function handleSaveLastUsedBackgroundOption({ backgroundOption }) {
const currentUser = UserStore.getCurrentUser();
const r2 = currentUser == null;
let r13 = false;
if (!r2) {
if (backgroundOption == null) {
backgroundOption = getVideoBackgroundOptionFromProto(UserSettingsProtoStore.settings.voiceAndVideo?.videoBackgroundFilterDesktop, currentUser.id);
}
r13 = SelectedChannelStore.getVoiceChannelId() != null && MediaEngineStore.isVideoEnabled() && backgroundOption != null;
}
if (r13) {
c5767_8 = true;
}
},
MEDIA_ENGINE_APPLY_MEDIA_FILTER_SETTINGS: function handleApplyMediaFilterSettings({ settings }) {
if (FilterSettingsKey.CAMERA_BACKGROUND_LIVE in settings) {
c5767_6 = true;
c5767_10 = false;
}
if (FilterSettingsKey.CAMERA_BACKGROUND_PREVIEW in settings) {
c5767_11 = false;
}
},
MEDIA_ENGINE_VIDEO_FILTER_ERROR: function handleVideoFilterError(a0) {
if (a0.target === "live") {
c5767_10 = true;
} else {
c5767_11 = true;
}
},
LOGOUT: function handleLogout() {
c5767_6 = false;
c5767_8 = false;
voiceChannelId = null;
c5767_9 = {};
c5767_10 = false;
c5767_11 = false;
}
});
export default videoBackgroundStore;
@@ -0,0 +1,161 @@
// Metro module 8845 (f8846).
import ChannelStore from "../../stores/ChannelStore";
import RTCConnectionStore from "../../stores/RTCConnectionStore";
import { ANIMATED_DEFAULT_VIDEO_BACKGROUNDS, DefaultVideoBackground, VideoFilterType } from "./VideoBackgroundConstants";
import { AnalyticEvents } from "../../Constants";
import { isAnimatedIconHash, isVideoAssetHash } from "../../utils/AvatarUtils";
import { getVoiceStateMetadata } from "../app_analytics/AppAnalyticsUtils";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
let getEffectDetailAnalyticsName;
const isAnimatedBackgroundOption = function isAnimatedBackgroundOption(a0) {
let r18;
if (typeof a0 === "number" ? a0 in DefaultVideoBackground : typeof a0 === "number") {
r18 = ANIMATED_DEFAULT_VIDEO_BACKGROUNDS.includes(a0);
} else {
let r12 = a0 != null && typeof a0 === "object" && "id" in a0;
if (r12) {
let r1 = a0.type === VideoFilterType.BACKGROUND;
if (!r1) {
a0.type;
r1 = false;
}
r12 = r1;
}
r18 = !!r12 && (isAnimatedIconHash(a0.asset) || isVideoAssetHash(a0.asset));
}
return r18;
};
getEffectDetailAnalyticsName = function getEffectDetailAnalyticsName(lastUsedVideoBackgroundOption) {
const r1 = lastUsedVideoBackgroundOption == null;
let r3 = "None";
if (!r1) {
let r10 = lastUsedVideoBackgroundOption != null && typeof lastUsedVideoBackgroundOption === "object" && "id" in lastUsedVideoBackgroundOption;
if (r10) {
let r13 = lastUsedVideoBackgroundOption.type === VideoFilterType.BACKGROUND;
if (!r13) {
lastUsedVideoBackgroundOption.type;
r13 = false;
}
r10 = r13;
}
let r15 = "Custom";
if (!r10) {
let r16 = "Blur";
if (lastUsedVideoBackgroundOption !== "blur") {
const OPTION_1 = DefaultVideoBackground.OPTION_1;
const r18 = OPTION_1 !== lastUsedVideoBackgroundOption ? DefaultVideoBackground.OPTION_2 !== lastUsedVideoBackgroundOption ? DefaultVideoBackground.OPTION_3 !== lastUsedVideoBackgroundOption ? DefaultVideoBackground.OPTION_4 !== lastUsedVideoBackgroundOption ? DefaultVideoBackground.OPTION_7 !== lastUsedVideoBackgroundOption ? DefaultVideoBackground.OPTION_8 !== lastUsedVideoBackgroundOption ? DefaultVideoBackground.OPTION_9 !== lastUsedVideoBackgroundOption ? DefaultVideoBackground.OPTION_10 === lastUsedVideoBackgroundOption ? "Wumpice" : void 0 : "Hacker Den" : "Capernite Night" : "Capernite Day" : "Vaporwave" : "Wumpus Vacation" : "Discord the Movie" : "Cybercity";
r16 = `Preset - ${r18}`;
}
r15 = r16;
}
r3 = r15;
}
return r3;
};
export function isCustomBackgroundOption(a0) {
let r6 = a0 != null && typeof a0 === "object" && "id" in a0;
if (r6) {
let r1 = a0.type === VideoFilterType.BACKGROUND;
if (!r1) {
a0.type;
r1 = false;
}
r6 = r1;
}
return r6;
}
export function isDefaultBackgroundOption(a0) {
return typeof a0 === "number" ? a0 in DefaultVideoBackground : typeof a0 === "number";
}
export { isAnimatedBackgroundOption };
export function getEffectAnalyticsType(a0) {
return a0 != null ? "Video Background" : "None";
}
export { getEffectDetailAnalyticsName };
export function trackBackgroundOptionUpdated(a0, a1, a2) {
const guildId = RTCConnectionStore.getGuildId();
const channelId = RTCConnectionStore.getChannelId();
const channel = ChannelStore.getChannel(channelId);
const voiceStateMetadata = getVoiceStateMetadata(guildId, channelId, true);
AnalyticsUtils.track(AnalyticEvents.VIDEO_EFFECT_UPDATED, {
location: a1,
effect_type: a0 != null ? "Video Background" : "None",
effect_detail: getEffectDetailAnalyticsName(a0),
effect_state: a2,
channel_id: channelId,
channel_type: channel?.type,
guild_id: guildId,
voice_state_count: voiceStateMetadata.voice_state_count,
video_stream_count: voiceStateMetadata.video_stream_count,
media_session_id: RTCConnectionStore.getMediaSessionId(),
rtc_connection_id: RTCConnectionStore.getRTCConnectionId(),
is_animated: isAnimatedBackgroundOption(a0)
});
}
export function trackBackgroundOptionAdded(a0, a1, a2) {
AnalyticsUtils.track(AnalyticEvents.VIDEO_BACKGROUND_ADDED, {
is_animated: isAnimatedBackgroundOption(a0),
is_video: a1,
is_from_tenor: a2
});
}
export function trackBackgroundOptionDeleted(a0) {
AnalyticsUtils.track(AnalyticEvents.VIDEO_BACKGROUND_DELETED, {
is_animated: isAnimatedBackgroundOption(a0)
});
}
export function getVideoBackgroundProtoFromOption(a0) {
let r14;
if (a0 == null) {
r14 = {
oneofKind: void 0
};
} else {
let r8 = a0 != null && typeof a0 === "object" && "id" in a0;
if (r8) {
let r1 = a0.type === VideoFilterType.BACKGROUND;
if (!r1) {
a0.type;
r1 = false;
}
r8 = r1;
}
r14 = r8 ? {
oneofKind: "customAsset",
customAsset: {
id: a0.id,
assetHash: a0.asset
}
} : a0 === "blur" ? {
oneofKind: "blur",
blur: {
useBlur: true
}
} : {
oneofKind: "presetOption",
presetOption: a0
};
}
return r14;
}
export function getVideoBackgroundOptionFromProto(a0, a1) {
if (a0 != null && a0.oneofKind !== void 0) {
const oneofKind = a0.oneofKind;
if (oneofKind === "customAsset") {
return {
type: VideoFilterType.BACKGROUND,
id: a0.customAsset.id,
user_id: a1,
asset: a0.customAsset.assetHash
};
}
if (oneofKind === "blur") {
return a0.blur.useBlur ? "blur" : null;
}
if (oneofKind === "presetOption") {
return a0.presetOption;
}
return void 0;
}
return null;
}
@@ -0,0 +1,20 @@
// Metro module 8847 (f8848).
import { V8APIError } from "../../_bundle/sendRequest";
import { intl, t } from "../../intl/index.native";
let c5770_2 = {
ASSET_SIZE: "BINARY_TYPE_MAX_SIZE"
};
let c5770_3 = {
ASSET: "asset"
};
class VideoFilterImageError extends V8APIError {
constructor(a0, a1) {
const r12 = intl.string(t.Mt8yDB);
super(a0, a1, r12);
const fieldErrors = this.getFieldErrors(c5770_3.ASSET);
if (fieldErrors != null && fieldErrors[0]?.code === c5770_2.ASSET_SIZE) {
this.message = intl.string(t.mrlScX);
}
}
}
export default VideoFilterImageError;
@@ -0,0 +1,238 @@
// Metro module 8843 (f8844).
import UserStore from "../../stores/UserStore";
import VideoBackgroundStore from "./VideoBackgroundStore";
import { BLUR_BACKGROUND_OPTION, BACKGROUND_REPLACEMENT_SIZE } from "./VideoBackgroundConstants";
import { NOOP } from "../../Constants";
import Module38 from "../../_bundle/Module38";
import { applyMediaFilterSettings, errorApplyingMediaFilterSettings, startApplyMediaFilterSettings } from "./VideoBackgroundActionCreators";
import { FilterSettingsGraph, FilterSettingsKey, FilterTargetType } from "../../_bundle/Module4286";
import getDefaultBackgroundData_native from "./getDefaultBackgroundData.native";
import { isAnimatedIconHash, isVideoAssetHash, getVideoFilterAssetURL } from "../../utils/AvatarUtils";
import { trackBackgroundOptionUpdated } from "./VideoBackgroundUtils";
import { getLastUsedVideoBackgroundOption } from "./LastUsedVideoBackgroundOption";
import isVideoBackgroundSupported from "./isVideoBackgroundSupported";
function $mk115352($env) {
return function getFilterBlob() {
return $env[9].apply(this, arguments);
};
}
let applyBackgroundMediaFilterSettings, applyBackgroundOption, applyBackgroundOptionLive;
let env5766 = {};
env5766[9] = function _getFilterBlob() {
const r8 = async (c26292_0) => {
let c29983_0 = await fetch(c26292_0);
let c29983_1 = await c29983_0.blob();
const Uint8ClampedArray2 = Uint8ClampedArray;
const r70 = await c29983_1.arrayBuffer();
const r79 = Object.create(Uint8ClampedArray2.prototype);
return new Uint8ClampedArray2(r70);
};
env5766[9] = r8;
return r8.apply(this, arguments);
};
applyBackgroundMediaFilterSettings = function applyBackgroundMediaFilterSettings(a0, a1, a2, a3, a4) {
const r9 = {};
r9[a0] = {
graph: a2,
target: a1,
image: a3,
blob: a4
};
applyMediaFilterSettings(r9);
};
applyBackgroundOption = async function applyBackgroundOption(c26293_0, c26293_1, c26293_2) {
let r71, r81;
let isVideo, c26293_4, c26293_5, c26293_6;
let c26293_7 = 0;
const r10 = env5766;
L39: {
L26: {
L38: {
try {
let env29984;
c26293_5 = r10;
const r23 = env29984 = {
$parent: r10
};
c26293_4 = r23;
env29984[0] = c26293_0;
env29984[1] = c26293_1;
env29984[2] = void 0;
env29984[4] = void 0;
env29984[5] = void 0;
env29984[3] = false;
if (c26293_2 == null) {
applyBackgroundMediaFilterSettings(c26293_0, c26293_1, FilterSettingsGraph.NONE);
break L39;
}
if (c26293_2 === BLUR_BACKGROUND_OPTION) {
applyBackgroundMediaFilterSettings(c26293_0, c26293_1, FilterSettingsGraph.BACKGROUND_BLUR);
break L38;
}
if (typeof c26293_2 !== "string" && typeof c26293_2 !== "number") {
const asset = c26293_2.asset;
r71 = isAnimatedIconHash(asset) || isVideoAssetHash(asset);
env29984[3] = r71;
r81 = getVideoFilterAssetURL({
userId: c26293_2.user_id,
assetId: c26293_2.id,
assetHash: asset,
size: BACKGROUND_REPLACEMENT_SIZE.width
});
env29984[2] = r81;
} else {
const r64 = getDefaultBackgroundData_native()[c26293_2];
isVideo = r64.isVideo;
if (isVideo == null) {
isVideo = false;
}
env29984[3] = isVideo;
const source = r64.source;
env29984[2] = source;
r71 = isVideo;
r81 = source;
}
if (r81 != null) {
c26293_7 = 1;
const r88 = void 0;
if (!r71) {
env29984[4] = await (function getFilterImage(src) {
return new Promise((c31981_0, c31981_1) => {
const image = new Image();
let c31981_2 = image;
image.crossOrigin = "anonymous";
image.onload = () => {
const element = document.createElement("canvas");
element.width = BACKGROUND_REPLACEMENT_SIZE.width;
element.height = BACKGROUND_REPLACEMENT_SIZE.height;
const context = element.getContext("2d");
Module38(context != null, "Canvas context is missing");
const r33 = c31981_2.height / c31981_2.width;
const height = BACKGROUND_REPLACEMENT_SIZE.height;
const r36 = BACKGROUND_REPLACEMENT_SIZE.height / r33;
context.drawImage(c31981_2, (element.width - r36) / 2, (element.height - height) / 2, r36, height);
const imageData = context.getImageData(0, 0, element.width, element.height);
c31981_0({
data: imageData.data,
width: imageData.width,
height: imageData.height,
pixelFormat: "rgba"
});
};
image.onerror = (a0) => c31981_1(a0);
image.src = src;
});
})(r81);
const r112 = env29984[3];
const r113 = void 0;
if (r112) {
const r114 = env29984[2];
env29984[5] = await $mk115352(env5766)(r114);
(0, applyBackgroundMediaFilterSettings)(env29984[0], env29984[1], FilterSettingsGraph.BACKGROUND_REPLACEMENT, env29984[4], env29984[5]);
c26293_7 = 0;
break L26;
}
env29984[5] = r113;
(0, applyBackgroundMediaFilterSettings)(env29984[0], env29984[1], FilterSettingsGraph.BACKGROUND_REPLACEMENT, env29984[4], env29984[5]);
c26293_7 = 0;
break L26;
}
env29984[4] = r88;
const r90 = env29984[3];
const r20 = void 0;
if (r90) {
const r164 = env29984[2];
env29984[5] = await $mk115352(env5766)(r164);
(0, applyBackgroundMediaFilterSettings)(env29984[0], env29984[1], FilterSettingsGraph.BACKGROUND_REPLACEMENT, env29984[4], env29984[5]);
c26293_7 = 0;
break L26;
}
env29984[5] = r20;
(0, applyBackgroundMediaFilterSettings)(env29984[0], env29984[1], FilterSettingsGraph.BACKGROUND_REPLACEMENT, env29984[4], env29984[5]);
c26293_7 = 0;
}
} catch ($e) {
const r42 = $e;
let r8 = r42;
c26293_6 = r42;
if (c26293_7 !== 0) {
while (true) {
try {
c26293_7 = 0;
errorApplyingMediaFilterSettings();
break L26;
} catch (r224) {
r8 = r224;
c26293_6 = r224;
if (c26293_7 === 0) {
break;
}
}
}
}
throw r8;
}
return void 0;
}
return void 0;
}
return void 0;
}
};
applyBackgroundOptionLive = async function applyBackgroundOptionLive(c26294_0, c26294_1) {
let c29985_1, c29985_2;
c29985_1 = void 0;
c29985_2 = void 0;
let c29985_0 = c26294_0;
const track = c26294_1.track;
if (track !== void 0) {
c29985_1 = track;
c29985_2 = c26294_1.location;
} else {
c29985_1 = true;
c29985_2 = c26294_1.location;
}
await void 0;
await (0, applyBackgroundOption)(FilterSettingsKey.CAMERA_BACKGROUND_LIVE, {
type: FilterTargetType.INPUT_DEVICE
}, c29985_0);
if (c29985_1) {
trackBackgroundOptionUpdated(c29985_0, c29985_2, "Enabled");
}
};
export { applyBackgroundOptionLive };
export async function applyBackgroundOptionPreview(c26295_0, c26295_1, c26295_2) {
let c29986_2, c29986_3;
c29986_2 = void 0;
c29986_3 = void 0;
let c29986_0 = c26295_0;
let c29986_1 = c26295_1;
const track = c26295_2.track;
if (track !== void 0) {
c29986_2 = track;
c29986_3 = c26295_2.location;
} else {
c29986_2 = true;
c29986_3 = c26295_2.location;
}
await void 0;
startApplyMediaFilterSettings();
await (0, applyBackgroundOption)(FilterSettingsKey.CAMERA_BACKGROUND_PREVIEW, {
type: FilterTargetType.STREAM,
streamId: c29986_1
}, c29986_0);
if (c29986_2) {
trackBackgroundOptionUpdated(c29986_0, c29986_3, "Preview");
}
}
export function applyInitialVideoBackgroundOption() {
const currentUser = UserStore.getCurrentUser();
if (currentUser != null) {
const lastUsedVideoBackgroundOption = getLastUsedVideoBackgroundOption(currentUser);
if (isVideoBackgroundSupported() && !VideoBackgroundStore.hasBeenApplied && lastUsedVideoBackgroundOption != null) {
applyBackgroundOptionLive(lastUsedVideoBackgroundOption, {
track: false
}).catch(NOOP);
}
}
}
@@ -0,0 +1,19 @@
// Metro module 8849 (f8850).
import { DefaultVideoBackground } from "./VideoBackgroundConstants";
let c5772_1 = {
id: DefaultVideoBackground.OPTION_1,
source: "",
name: ""
};
export default function getDefaultBackgroundData() {
const r0 = {};
r0[DefaultVideoBackground.OPTION_1] = c5772_1;
r0[DefaultVideoBackground.OPTION_2] = c5772_1;
r0[DefaultVideoBackground.OPTION_3] = c5772_1;
r0[DefaultVideoBackground.OPTION_4] = c5772_1;
r0[DefaultVideoBackground.OPTION_7] = c5772_1;
r0[DefaultVideoBackground.OPTION_8] = c5772_1;
r0[DefaultVideoBackground.OPTION_9] = c5772_1;
r0[DefaultVideoBackground.OPTION_10] = c5772_1;
return r0;
};
@@ -0,0 +1,11 @@
// Metro module 8850 (f8851).
import MediaEngineStore from "../../stores/MediaEngineStore";
import { Features } from "../../_bundle/Module4250";
export default function isVideoBackgroundSupported(r3 = MediaEngineStore) {
let r9 = r3.supports(Features.MEDIAPIPE);
const r6 = r3;
if (r9) {
r9 = Object.values(r6.getVideoDevices()).length > 0;
}
return r9;
};