Files
discord-decomp/sources/modules/media_uploads/ImageEncodingLadder.tsx
T
2026-07-27 16:20:00 +03:00

109 lines
5.3 KiB
TypeScript

/* Metro module 4685; source: modules/media_uploads/ImageEncodingLadder.tsx; dependencies: [6, 7, 661, 2] */
function _fun40550(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#40550, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4863:6, offset: 0x01104934, size: 211 bytes, params: 8, frame: 20
const closure = getAdaptiveImageCompressionQuality;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_0 = importDefault(6) /* metro dependency 6 */;
const env0_1 = importDefault(7) /* metro dependency 7 */;
const env0_2 = (require(661) /* metro dependency 661: Constants */).CompressionQuality;
const value = _fun40552();
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/media_uploads/ImageEncodingLadder.tsx');
exports.IMAGE_COMPRESSION_THRESHOLDS = {'SMALL': 921600, 'MEDIUM': 2073600, 'LARGE': 3686400, 'VERY_LARGE': 8294400};
exports.ADAPTIVE_COMPRESSION_CONFIG = {'useAdaptiveCompression': true, 'veryHighQuality': 0.8, 'highQuality': 0.7,
'mediumQuality': 0.6, 'lowQuality': 0.5, 'veryLowQuality': 0.4, 'useOriginalIfSmaller': true};
exports.getAdaptiveImageCompressionQuality = closure;
exports.ImageEncodingLadder = value;
}
function getAdaptiveImageCompressionQuality(a0, a1) { // fn#40551, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4863:347, offset: 0x01104a07, size: 269 bytes, params: 3, frame: 6
var value;
var width;
var height;
if (a1.useAdaptiveCompression) {
width = a0.width;
if (width == null) {
return CompressionQuality.HIGH;
}
height = a0.height;
if (height == null) {
return CompressionQuality.HIGH;
}
width = a0.width;
height = a0.height;
value = width * height;
return value <= env0_3.SMALL ? a1.veryHighQuality ?? CompressionQuality.HIGH : value <= env0_3.MEDIUM ? a1.highQuality ?? CompressionQuality.HIGH : value <= env0_3.LARGE ? a1.mediumQuality ?? CompressionQuality.HIGH : value <= env0_3.VERY_LARGE ? a1.lowQuality ?? CompressionQuality.HIGH : a1.veryLowQuality ?? CompressionQuality.HIGH;
}
return CompressionQuality.HIGH;
}
function _fun40552() { // fn#40552, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4863:755, offset: 0x01104b14, size: 85 bytes, params: 1, frame: 16
return env0_1(ImageEncodingLadder, null, [{key: 'selectEncodingConfig', value: value_40554},
{key: 'clampDimensions', value: value_40555}]);
}
function value_40554(a0) { // fn#40554, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4863:894, offset: 0x01104b69, size: 196 bytes, params: 2, frame: 19
var object;
var lowQuality;
let value = ImageEncodingLadder.clampDimensions(a0.width, a0.height, 3840, 2160);
const targetWidth = value.targetWidth;
const targetHeight = value.targetHeight;
if (a0.width !== targetWidth) {
value = environment.__proto__;
lowQuality = env1_4.lowQuality;
value = 0.5;
object = {compressionQuality: 100 * (lowQuality ?? value), targetWidth: targetWidth,
targetHeight: targetHeight};
} else if (a0.height === targetHeight) {
value = environment.__proto__;
value = getAdaptiveImageCompressionQuality({width: targetWidth, height: targetHeight}, env1_4);
object = {compressionQuality: 100 * value, targetWidth: targetWidth, targetHeight: targetHeight};
} else {
value = environment.__proto__;
lowQuality = env1_4.lowQuality;
value = 0.5;
object = {compressionQuality: 100 * (lowQuality ?? value), targetWidth: targetWidth,
targetHeight: targetHeight};
}
return object;
}
function value_40555(a0, a1, a2, a3) { // fn#40555, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4863:1278, offset: 0x01104c2d, size: 220 bytes, params: 5, frame: 19
var object2;
let Math = global.Math;
let max = Math.max;
let value = Reflect.apply(max, Math, [a0, a1]);
Math = global.Math;
let min = Math.min;
const value2 = Reflect.apply(min, Math, [a0, a1]);
Math = global.Math;
const value3 = Math.max(a2, a3);
Math = global.Math;
const value4 = Math.min(a2, a3);
if (value <= value3) {
if (value2 <= value4) {
return {targetWidth: a0, targetHeight: a1};
}
Math = global.Math;
min = Math.min;
value = value3 / value;
value = Reflect.apply(min, Math, [value, value4 / value2]);
object2 = {};
Math = global.Math;
object2.targetWidth = Math.max(1, global.Math.round(a0 * value));
} else {
Math = global.Math;
min = Math.min;
value = value3 / value;
value = Reflect.apply(min, Math, [value, value4 / value2]);
object2 = {};
Math = global.Math;
object2.targetWidth = Math.max(1, global.Math.round(a0 * value));
}
Math = global.Math;
max = Math.max;
const Math3 = global.Math;
object2.targetHeight = Reflect.apply(max, Math, [1, Math3.round(a1 * value)]);
return object2;
}