Files
discord-decomp/modules/media_uploads/native/ImageConversionDecision.tsx
T
2026-11-01 12:12:55 +02:00

65 lines
2.1 KiB
TypeScript

// Metro module 4752 (f4753).
import { isIOS } from "../../../utils/PlatformUtils";
import IosImageTypesManager from "../../media/native/IosImageTypesManager";
export function isPhotoKitAsset(a0, a1) {
return a0.match(/^ph:\/\//i) != null && a1 != null;
}
export function isHeicUTI(a0) {
if (a0 == null) {
return false;
}
const r4 = a0.toLowerCase();
return r4.includes("heic") || r4.includes("heif");
}
export function shouldForceConvertToJPG(a0, a1, a2) {
let r16 = !!isIOS();
if (r16) {
const r1 = a2 == null;
let r17 = false;
if (!r1) {
const r10 = a2.toLowerCase();
r17 = r10.includes("heic") || r10.includes("heif");
}
r16 = !!r17 || (a0.match(/^ph:\/\//i) != null && a1 != null ? (a1 == null ? void 0 : a1.match(/\.HEI[CF]$/i)) != null : a0.match(/^(assets-library|file):\/\/.+(&ext=|\.)(HEI[CF])$/i) != null);
}
return r16;
}
export function shouldConvertToJPG(a0, a1, a2, a3, r8 = true) {
if (isIOS()) {
let r12 = a1 == null ? void 0 : a1.lastIndexOf(".");
if (r12 == null) {
r12 = -1;
}
const r21 = r12 !== -1 ? a1.substring(r12 + 1).toLowerCase() : void 0;
const match = a0.match;
if (r8) {
if (match.call(a0, /^ph:\/\//i) != null && a1 != null) {
if (r21 == null) {
return false;
}
if (r21 === "png") {
if (a3) {
return true;
}
if (a2) {
return true;
}
} else {
if (IosImageTypesManager.isExtensionAnimated(r21)) {
return false;
}
const supportedExtensions = IosImageTypesManager.getSupportedExtensions();
if (supportedExtensions !== null && supportedExtensions.has(r21)) {
return true;
}
}
return false;
}
return a0.match(/^(assets-library|file):\/\/.+(&ext=|\.)(hei[cf]|jpe?g|dng)$/i) != null || !(a0.match(/^(assets-library|file):\/\/.+(&ext=|\.)png$/i) == null || (a2 ? !a2 : !a3));
}
const r3 = match.call(a0, /(&ext=|\.)(hei[cf])$/i) != null;
return r21 === "heic" || r21 === "heif" || r3;
}
return false;
}