decord/source/modules/image_upload/AttachmentImageLadder.tsx

105 lines
3 KiB
TypeScript
Raw Normal View History

2026-08-15 05:55:55 +00:00
// Module ID: 1471
// Function ID: 1472
2026-07-29 08:29:29 +00:00
// Name: items
2026-07-23 10:11:24 +00:00
// Dependencies: [2]
2026-08-15 05:55:55 +00:00
// Exports: getSnapDownMaxUpscale, snapAttachmentDimensions
2026-07-20 16:05:17 +00:00
2026-08-15 05:55:55 +00:00
// Module 1471 (items)
2026-08-24 06:08:38 +00:00
import set from "set" /* 2 */;
2026-07-23 10:11:24 +00:00
const items = [128, 192, 256, 320, 384, 512, 640, 768, 1024, 1280, 1536, 2048, 3072, 4096];
2026-08-24 06:08:38 +00:00
let result = set.fileFinishedImporting("modules/image_upload/AttachmentImageLadder.tsx");
2026-07-20 16:05:17 +00:00
export const ATTACHMENT_LADDER = items;
2026-07-31 08:44:05 +00:00
export const ATTACHMENT_LADDER_MAX_UPSCALE = 1.1;
2026-08-15 05:55:55 +00:00
export const getSnapDownMaxUpscale = function getSnapDownMaxUpscale(minSnapDownDpr, arg1) {
let maxUpscale = null;
if (arg1 >= minSnapDownDpr.minSnapDownDpr) {
maxUpscale = minSnapDownDpr.maxUpscale;
}
return maxUpscale;
};
2026-07-20 16:05:17 +00:00
export const snapAttachmentDimensions = function snapAttachmentDimensions(arg0) {
({ targetWidth, targetHeight, sourceWidth, sourceHeight, maxUpscale } = arg0);
2026-07-29 08:29:29 +00:00
let bound;
bound = Math.max(targetWidth, targetHeight);
2026-07-20 16:05:17 +00:00
if (bound <= 0) {
2026-07-29 08:29:29 +00:00
let obj = { width: null, height: null };
obj[0] = targetWidth;
obj[1] = targetHeight;
2026-07-20 16:05:17 +00:00
return obj;
} else {
2026-07-23 10:11:24 +00:00
let found = bound.find((arg0) => bound <= arg0);
2026-07-29 08:29:29 +00:00
if (found == null) {
found = arr[arr.length - 1];
2026-07-20 16:05:17 +00:00
}
2026-07-31 08:44:05 +00:00
let tmp4 = null != sourceWidth && null != sourceHeight;
if (tmp4) {
const _Math = Math;
tmp4 = Math.max(sourceWidth, sourceHeight) <= found;
}
let tmp5 = found;
2026-07-20 16:05:17 +00:00
if (null != maxUpscale) {
2026-07-31 08:44:05 +00:00
tmp5 = found;
2026-07-20 16:05:17 +00:00
if (maxUpscale > 1) {
2026-07-31 08:44:05 +00:00
tmp5 = found;
if (!tmp4) {
for (const item10027 of arr) {
let tmp8 = item10027;
if (item10027 <= bound) {
let tmp = item10027;
continue;
} else {
let tmp9 = obj;
obj.return();
break;
}
let tmp10 = tmp;
let tmp11 = null != tmp;
if (tmp11) {
let tmp12 = tmp;
tmp11 = bound <= tmp * maxUpscale;
}
tmp5 = found;
if (tmp11) {
tmp5 = tmp;
}
2026-07-20 16:05:17 +00:00
}
}
}
}
if (null != sourceWidth) {
if (null != sourceHeight) {
2026-07-31 08:44:05 +00:00
const _Math2 = Math;
if (Math.max(sourceWidth, sourceHeight) <= tmp5) {
2026-07-29 08:29:29 +00:00
obj = { width: null, height: null };
obj[0] = sourceWidth;
obj[1] = sourceHeight;
2026-07-20 16:05:17 +00:00
return obj;
}
}
}
2026-07-31 08:44:05 +00:00
const result = tmp5 / bound;
2026-07-20 16:05:17 +00:00
const _Math3 = Math;
const _Math4 = Math;
2026-07-31 08:44:05 +00:00
const bound1 = Math.max(1, Math.round(targetWidth * result));
2026-07-20 16:05:17 +00:00
const _Math5 = Math;
2026-07-31 08:44:05 +00:00
const _Math6 = Math;
2026-07-20 16:05:17 +00:00
const bound2 = Math.max(1, Math.round(targetHeight * result));
let bound3 = bound1;
if (null != sourceWidth) {
2026-07-31 08:44:05 +00:00
const _Math7 = Math;
2026-07-20 16:05:17 +00:00
bound3 = Math.min(bound1, sourceWidth);
}
2026-08-24 06:08:38 +00:00
obj1 = { width: null, height: null };
2026-07-29 08:29:29 +00:00
obj1[0] = bound3;
2026-07-20 16:05:17 +00:00
let bound4 = bound2;
if (null != sourceHeight) {
2026-07-31 08:44:05 +00:00
const _Math8 = Math;
2026-07-20 16:05:17 +00:00
bound4 = Math.min(bound2, sourceHeight);
}
2026-07-29 08:29:29 +00:00
obj1[1] = bound4;
return obj1;
2026-07-20 16:05:17 +00:00
}
};