451 lines
19 KiB
TypeScript
451 lines
19 KiB
TypeScript
/* Metro module 1475; source: utils/ImageUtils.tsx; dependencies: [5, 1476, 1477, 22, 44, 2] */
|
|
import Module00005 from '../by-id/module-00005.js'; /* Metro dependency 5 */
|
|
import Module01476 from '../by-id/module-01476.js'; /* Metro dependency 1476 */
|
|
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
|
|
function _fun16856(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#16856, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:6, offset: 0x00e5d237, size: 384 bytes, params: 8, frame: 22
|
|
let env0_0 = require;
|
|
const fit2 = fit;
|
|
const getPalette2 = getPalette;
|
|
const dataUrlToBlob2 = dataUrlToBlob;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
object = [[0, 0, 0]];
|
|
(importDefault(22) /* metro dependency 22 */).memoize(function(a0) {
|
|
var env0_0 = a0;
|
|
var Promise = global.Promise;
|
|
var value = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
var value2 = new Promise(_fun16867);
|
|
return value2 instanceof Object ? value2 : value;
|
|
});
|
|
(FileImportTrackerModule).fileFinishedImporting('utils/ImageUtils.tsx');
|
|
exports.fit = fit2;
|
|
exports.IMAGE_MAX_ZOOM = 2000;
|
|
exports.zoomFit = zoomFit;
|
|
exports.zoomScale = zoomScale;
|
|
exports.getRatio = function({width, height, maxWidth, maxHeight}) {
|
|
var r4;
|
|
var value = 1;
|
|
r4 = width > maxWidth ? maxWidth / width : value;
|
|
var Math = global.Math;
|
|
Math.round(width * r4);
|
|
var value3 = global.Math.round(height * r4);
|
|
return global.Math.min(r4 * (value3 > maxHeight ? maxHeight / value3 : value), value);
|
|
};
|
|
exports.getCoverRatio = function({width, height, maxWidth, maxHeight}) {
|
|
if (width === height) {
|
|
return 1;
|
|
}
|
|
var Math = global.Math;
|
|
var value = maxWidth / width;
|
|
value = Math.max(value, maxHeight / height);
|
|
return global.Math.min(value, 1);
|
|
};
|
|
exports.hasDimensions = function({width, height}) {
|
|
return width != null && width !== 0 && height != null && height !== 0;
|
|
};
|
|
exports.makeCssUrlString = function(a0) {
|
|
return a0 == null || a0 === '' ? 'none' : 'url(' + a0 + ')';
|
|
};
|
|
exports.getPalette = getPalette2;
|
|
exports.getPaletteForAvatar = function(a0) {
|
|
return require(dependencyMap[2]).default.getPaletteForAvatarMobile(a0);
|
|
};
|
|
exports.readFileAsBase64 = function(a0) {
|
|
var env0_0 = a0;
|
|
var Promise = global.Promise;
|
|
var value = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
var value2 = new Promise(_fun16878);
|
|
return value2 instanceof Object ? value2 : value;
|
|
};
|
|
exports.dataUriFileSize = function(a0) {
|
|
var value = a0.split(';base64,');
|
|
importDefault(dependencyMap[4])(value.length === 2, 'Input data is not a valid image.');
|
|
return global.atob(value[1]).length;
|
|
};
|
|
exports.dataUrlToFile = function() {
|
|
return _dataUrlToFile.apply(this, arguments);
|
|
};
|
|
exports.dataUrlToBlob = dataUrlToBlob2;
|
|
exports.isPNGAnimated = function() {
|
|
return _isPNGAnimated.apply(this, arguments);
|
|
};
|
|
exports.preloadImage = function(a0) {
|
|
var env0_0 = a0;
|
|
var Promise = global.Promise;
|
|
var value = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
var value2 = new Promise(_fun16885);
|
|
return value2 instanceof Object ? value2 : value;
|
|
};
|
|
function getPalette(a0, a1, a2) { // fn#16858, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:426, offset: 0x00e5d4b9, size: 361 bytes, params: 4, frame: 31
|
|
var r13;
|
|
var value5;
|
|
var property;
|
|
var property2;
|
|
var property3;
|
|
var property4;
|
|
var value6;
|
|
var value7;
|
|
var value8;
|
|
var value9;
|
|
var value10;
|
|
var value11;
|
|
let value = global.document.createElement('canvas');
|
|
const context = value.getContext('2d');
|
|
if (context == null) {
|
|
value = environment;
|
|
return env0_4;
|
|
}
|
|
const width = a0.width;
|
|
const value3 = 128;
|
|
const value4 = 0;
|
|
let r0 = value4 === width ? value3 : a0.width;
|
|
value.width = r0;
|
|
let height = a0.height;
|
|
height = value4 === height ? value3 : a0.height;
|
|
value.height = height;
|
|
context.drawImage(a0, value4, value4, r0, height);
|
|
const getImageData = context.getImageData;
|
|
const data = Reflect.apply(getImageData, context, [value4, value4, r0, height]).data;
|
|
value = r0 * height;
|
|
const items2 = [];
|
|
if (value4 < value) {
|
|
r0 = value4;
|
|
while (true) {
|
|
value5 = 4 * r0;
|
|
property = data[value4 + value5];
|
|
property2 = data[value5 + 1];
|
|
property3 = data[value5 + 2];
|
|
property4 = data[value5 + 3];
|
|
value6 = property4 === undefined;
|
|
if (value6) {
|
|
r13 = value6;
|
|
} else {
|
|
value7 = property4 >= 125;
|
|
r13 = value7;
|
|
}
|
|
if (!r13) {
|
|
continue;
|
|
}
|
|
value8 = property > 250;
|
|
if (!value8) {
|
|
r13 = value8;
|
|
continue;
|
|
}
|
|
value9 = property2 > 250;
|
|
r13 = value9;
|
|
if (!r13) {
|
|
continue;
|
|
}
|
|
value10 = property3 > 250;
|
|
r13 = value10;
|
|
if (r13) {
|
|
continue;
|
|
}
|
|
items2.push([property, property2, property3]);
|
|
value11 = r0 + a2;
|
|
if (value11 < value) {
|
|
r0 = value11;
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
const value12 = (Module01476)(items2, a1);
|
|
return typeof value12 === 'boolean' ? env0_4 : value12.palette();
|
|
}
|
|
|
|
function _dataUrlToFile() { // fn#16859, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:1127, offset: 0x00e5d622, size: 48 bytes, params: 1, frame: 14
|
|
return Module00005(_fun16861).apply(this, arguments);
|
|
function* _fun16861(a0, a1, a2) { // fn#16861, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:1178, offset: 0x00e5d65b, size: 107 bytes, params: 4, frame: 17
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
value = environment.__proto__.__proto__;
|
|
value = env2_8(a0);
|
|
yield value.arrayBuffer();
|
|
value = undefined;
|
|
if (false) {
|
|
return value;
|
|
}
|
|
const File = global.File;
|
|
const items2 = [value];
|
|
value = Object.create(File.prototype, {constructor: {value: File}});
|
|
const file = new File(items2, a1, {type: a2});
|
|
return file instanceof Object ? file : value;
|
|
}
|
|
|
|
}
|
|
|
|
function _isPNGAnimated() { // fn#16863, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:1566, offset: 0x00e5d7e1, size: 48 bytes, params: 1, frame: 14
|
|
return Module00005(_fun16865).apply(this, arguments);
|
|
}
|
|
|
|
function _fun16866(a0) { // fn#16866, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:929, offset: 0x00e5d8d4, size: 44 bytes, params: 2, frame: 11
|
|
const env0_0 = a0;
|
|
const Promise = global.Promise;
|
|
const value = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
const promise = new Promise(_fun16867);
|
|
return promise instanceof Object ? promise : value;
|
|
function _fun16867(a0, a1) { // fn#16867, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:945, offset: 0x00e5d900, size: 107 bytes, params: 3, frame: 10
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
const Image = global.Image;
|
|
const image = new Image();
|
|
image.crossOrigin = 'Anonymous';
|
|
image.onerror = onerror_16868;
|
|
image.onload = onload_16869;
|
|
image.src = env0_0;
|
|
function onerror_16868(a0) { // fn#16868, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:1005, offset: 0x00e5d96b, size: 41 bytes, params: 2, frame: 13
|
|
require(a0);
|
|
const binding = env0_2;
|
|
binding.onload = null;
|
|
binding.onerror = null;
|
|
}
|
|
|
|
function onload_16869() { // fn#16869, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:1055, offset: 0x00e5d994, size: 62 bytes, params: 1, frame: 17
|
|
let binding = env0_0;
|
|
binding(getPalette(env0_2, 5, 10));
|
|
binding = env0_2;
|
|
binding.onload = null;
|
|
binding.onerror = null;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function zoomFit(a0, a1) { // fn#16870, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:1946, offset: 0x00e5d9d2, size: 258 bytes, params: 3, frame: 17
|
|
let Math = global.Math;
|
|
let min = Math.min;
|
|
const Math2 = global.Math;
|
|
let value = Math2.round(0.65 * global.window.innerHeight);
|
|
const Math3 = global.Math;
|
|
value = Reflect.apply(min, Math, [value, Math3.round(global.window.innerHeight)]);
|
|
Math = global.Math;
|
|
min = Math.min;
|
|
const Math4 = global.Math;
|
|
const value2 = Math4.round(0.75 * global.window.innerWidth);
|
|
const Math5 = global.Math;
|
|
const value3 = Reflect.apply(min, Math, [value2, Math5.round(global.window.innerWidth)]);
|
|
Math = global.Math;
|
|
value = Math.min(value, 2000);
|
|
const fitBinding = fit;
|
|
const object = {width: a0, height: a1};
|
|
Math = global.Math;
|
|
object.maxWidth = Math.min(value3, 2000);
|
|
object.maxHeight = value;
|
|
return fitBinding(object);
|
|
}
|
|
|
|
function readFileAsBase64(a0) { // fn#16877, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:3166, offset: 0x00e5dd49, size: 44 bytes, params: 2, frame: 11
|
|
const env0_0 = a0;
|
|
const Promise = global.Promise;
|
|
const value = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
const promise = new Promise(_fun16878);
|
|
return promise instanceof Object ? promise : value;
|
|
function _fun16878(a0, a1) { // fn#16878, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:3215, offset: 0x00e5dd75, size: 92 bytes, params: 3, frame: 12
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
const FileReader = global.FileReader;
|
|
const fileReader = new FileReader();
|
|
fileReader.readAsDataURL(env0_0);
|
|
fileReader.onload = onload_16879;
|
|
fileReader.onerror = function(a0) {
|
|
return require(a0);
|
|
};
|
|
function onload_16879() { // fn#16879, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:3272, offset: 0x00e5ddd1, size: 78 bytes, params: 1, frame: 15
|
|
let value = environment.__proto__.__proto__;
|
|
value = importDefault(44) /* metro dependency 44 */;
|
|
const binding = env0_2;
|
|
value(typeof binding.result === 'string', 'Result must be a string');
|
|
env0_0(binding.result);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function preloadImage(a0) { // fn#16884, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:3752, offset: 0x00e5deba, size: 44 bytes, params: 2, frame: 11
|
|
const env0_0 = a0;
|
|
const Promise = global.Promise;
|
|
const value = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
const promise = new Promise(_fun16885);
|
|
return promise instanceof Object ? promise : value;
|
|
function _fun16885(a0, a1) { // fn#16885, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:3797, offset: 0x00e5dee6, size: 83 bytes, params: 3, frame: 13
|
|
const Image = global.Image;
|
|
const image = new Image();
|
|
image.addEventListener('load', a0);
|
|
image.addEventListener('error', a1);
|
|
image.src = env0_0;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function fit({width, height, maxWidth, maxHeight, minWidth, minHeight}) { // fn#16857, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:113, offset: 0x00e5d3b7, size: 258 bytes, params: 2, frame: 23
|
|
var r0;
|
|
var r9;
|
|
var r1;
|
|
var r2;
|
|
var value;
|
|
var Math;
|
|
var max;
|
|
var Math2;
|
|
var round;
|
|
var value3;
|
|
var Math3;
|
|
var value4;
|
|
var Math4;
|
|
var Math5;
|
|
minWidth = minWidth === undefined ? 0 : minWidth;
|
|
minHeight = minHeight === undefined ? 0 : minHeight;
|
|
if (width !== maxWidth) {
|
|
value = 1;
|
|
r0 = width > maxWidth ? maxWidth / width : value;
|
|
Math = global.Math;
|
|
max = Math.max;
|
|
Math2 = global.Math;
|
|
round = Math2.round;
|
|
value3 = Reflect.apply(max, Math, [Reflect.apply(round, Math2, [width * r0]), minWidth]);
|
|
Math = global.Math;
|
|
max = Math.max;
|
|
Math3 = global.Math;
|
|
round = Math3.round;
|
|
value4 = Reflect.apply(max, Math, [Reflect.apply(round, Math3, [height * r0]), minHeight]);
|
|
r9 = value4 > maxHeight ? maxHeight / value4 : value;
|
|
Math = global.Math;
|
|
max = Math.max;
|
|
Math4 = global.Math;
|
|
round = Math4.round;
|
|
value = Reflect.apply(max, Math, [Reflect.apply(round, Math4, [value3 * r9]), minWidth]);
|
|
Math = global.Math;
|
|
max = Math.max;
|
|
Math5 = global.Math;
|
|
round = Math5.round;
|
|
r1 = Reflect.apply(max, Math, [Reflect.apply(round, Math5, [value4 * r9]), minHeight]);
|
|
r2 = value;
|
|
} else if (height === maxHeight) {
|
|
r1 = height;
|
|
r2 = width;
|
|
} else {
|
|
value = 1;
|
|
r0 = width > maxWidth ? maxWidth / width : value;
|
|
Math = global.Math;
|
|
max = Math.max;
|
|
Math2 = global.Math;
|
|
round = Math2.round;
|
|
value3 = Reflect.apply(max, Math, [Reflect.apply(round, Math2, [width * r0]), minWidth]);
|
|
Math = global.Math;
|
|
max = Math.max;
|
|
Math3 = global.Math;
|
|
round = Math3.round;
|
|
value4 = Reflect.apply(max, Math, [Reflect.apply(round, Math3, [height * r0]), minHeight]);
|
|
r9 = value4 > maxHeight ? maxHeight / value4 : value;
|
|
Math = global.Math;
|
|
max = Math.max;
|
|
Math4 = global.Math;
|
|
round = Math4.round;
|
|
value = Reflect.apply(max, Math, [Reflect.apply(round, Math4, [value3 * r9]), minWidth]);
|
|
Math = global.Math;
|
|
max = Math.max;
|
|
Math5 = global.Math;
|
|
round = Math5.round;
|
|
r1 = Reflect.apply(max, Math, [Reflect.apply(round, Math5, [value4 * r9]), minHeight]);
|
|
r2 = value;
|
|
}
|
|
return {width: r2, height: r1};
|
|
}
|
|
|
|
function dataUrlToBlob(a0) { // fn#16862, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:1300, offset: 0x00e5d6c6, size: 283 bytes, params: 2, frame: 16
|
|
var r4;
|
|
var r5;
|
|
var btoa;
|
|
var atob;
|
|
var charCodeAt;
|
|
var value3;
|
|
let value = a0.split(',');
|
|
const value2 = 0;
|
|
let property = value[value2];
|
|
if (property.indexOf('base64') >= value2) {
|
|
atob = global.atob;
|
|
value = a0.split(',');
|
|
value = atob(value[1]);
|
|
r4 = value;
|
|
} else {
|
|
btoa = global.btoa;
|
|
value = a0.split(',');
|
|
value = btoa(value[1]);
|
|
r4 = value;
|
|
}
|
|
property = Reflect.apply(a0.split(',')[value2].split(':')[1].split, property, [';'])[value2];
|
|
const Uint8Array = global.Uint8Array;
|
|
let length = r4.length;
|
|
let uint8Array = new Uint8Array(length);
|
|
length = r4.length;
|
|
if (value2 < length) {
|
|
for (r5 = value2; true; r5 = value3) {
|
|
charCodeAt = r4.charCodeAt;
|
|
uint8Array[r5] = Reflect.apply(charCodeAt, r4, [r5]);
|
|
value3 = typeof r5 === 'bigint' ? r5 + 1n : +r5 + 1;
|
|
length = r4.length;
|
|
if (!(value3 < length)) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
const Blob = global.Blob;
|
|
const items2 = [uint8Array];
|
|
const object = {type: property};
|
|
uint8Array = Object.create(Blob.prototype, {constructor: {value: Blob}});
|
|
const blob = new Blob(items2, object);
|
|
return blob instanceof Object ? blob : uint8Array;
|
|
}
|
|
|
|
function* _fun16865(a0) { // fn#16865, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:1617, offset: 0x00e5d81a, size: 186 bytes, params: 2, frame: 15
|
|
var r2;
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
const type = a0.type;
|
|
if ((type == null ? undefined : type.split(';')[0]) !== 'image/png') {
|
|
throw new global.Error('File is not a PNG');
|
|
}
|
|
yield a0.text();
|
|
value = undefined;
|
|
if (false) {
|
|
return value;
|
|
}
|
|
const value4 = value.indexOf('IDAT');
|
|
const value5 = value4 > 0;
|
|
if (value5) {
|
|
value = value.substring(0, value4);
|
|
value = value.indexOf('acTL');
|
|
value = value !== -1;
|
|
r2 = value;
|
|
} else {
|
|
r2 = value5;
|
|
}
|
|
return r2;
|
|
}
|
|
|
|
function zoomScale(a0, a1, a2, a3) { // fn#16871, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1602:2222, offset: 0x00e5dad4, size: 270 bytes, params: 5, frame: 21
|
|
let Math = global.Math;
|
|
const max = Math.max;
|
|
let value = 0;
|
|
let r4 = a0 != null ? value === a0 ? value : a1 != null ? value === a1 ? value : a0 / a2 : value : value;
|
|
value = 2;
|
|
const value2 = Reflect.apply(max, Math, [value, r4]);
|
|
const r5 = a2 != null && a2 * value2 > global.window.innerWidth * 1.6 ? global.window.innerWidth * 1.6 / a2 : value;
|
|
r4 = a3 != null && a3 * value2 > global.window.innerHeight * 1.6 ? global.window.innerHeight * 1.6 / a3 : value;
|
|
Math = global.Math;
|
|
const value11 = Math.min(value2, r5, r4);
|
|
const parseFloat = global.parseFloat;
|
|
value = value11.toFixed(value);
|
|
return parseFloat(value);
|
|
}
|
|
|
|
global.__d(_fun16856, 1475, [5, 1476, 1477, 22, 44,
|
|
2]) /* metro module 1475, dependencies: [5, 1476, 1477, 22, 44, 2] */;
|