Files
2026-07-28 01:06:53 +03:00

170 lines
9.7 KiB
TypeScript

/* Metro module 8403; source: modules/recent_avatars/RecentAvatarUtils.tsx; dependencies: [661, 1423, 1457, 1468, 1244, 7611, 1360, 2] */
import Module01468 from '../../by-id/module-01468.js'; /* Metro dependency 1468 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
import * as IndexNativeModule from '../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as GlobalUtilsModule from '../../utils/GlobalUtils.tsx'; /* Metro dependency 1360 */
import * as AvatarUtilsModule from '../../utils/AvatarUtils.tsx'; /* Metro dependency 1423 */
import * as ImageLoaderUtilsModule from '../image_upload/ImageLoaderUtils.tsx'; /* Metro dependency 1457 */
import * as RecentAvatarsTypesModule from './RecentAvatarsTypes.tsx'; /* Metro dependency 7611 */
function _fun66786(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#66786, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8588:6, offset: 0x01c09669, size: 214 bytes, params: 8, frame: 20
const env0_0 = require;
const getImageFormat_667872 = getImageFormat_66787;
const getArchivedAvatarURL2 = getArchivedAvatarURL;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('modules/recent_avatars/RecentAvatarUtils.tsx');
exports.getImageFormat = getImageFormat_667872;
exports.getArchivedAvatarURL = getArchivedAvatarURL2;
exports.generateAvatarDescription = generateAvatarDescription;
exports.generateRecentAvatarFileDetails = generateRecentAvatarFileDetails;
exports.createPendingImage = createPendingImage;
exports.getPendingAvatarSrc = getPendingAvatarSrc;
function getImageFormat_66787({storageHash, canAnimate, allowWebp}) { // fn#66787, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8588:116, offset: 0x01c0973f, size: 216 bytes, params: 2, frame: 18
var r0;
var moduleValue;
const SUPPORTS_WEBP = (require(1423) /* metro dependency 1423: AvatarUtils */).SUPPORTS_WEBP;
canAnimate = !(canAnimate === undefined) && canAnimate;
allowWebp = allowWebp === undefined || allowWebp;
if (canAnimate) {
moduleValue = require(1423) /* metro dependency 1423: AvatarUtils */;
r0 = moduleValue.isAnimatedIconHash(storageHash) ? allowWebp && SUPPORTS_WEBP ? 'webp' : 'gif' : global.window.GLOBAL_ENV.CDN_HOST == null ? 'jpg' : allowWebp && SUPPORTS_WEBP ? 'webp' : 'png';
} else {
r0 = global.window.GLOBAL_ENV.CDN_HOST == null ? 'jpg' : allowWebp && SUPPORTS_WEBP ? 'webp' : 'png';
}
return r0;
}
function getArchivedAvatarURL({userId, avatarId, storageHash, canAnimate, allowWebp, size}) { // fn#66788, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8588:343, offset: 0x01c09817, size: 375 bytes, params: 2, frame: 27
canAnimate = !(canAnimate === undefined) && canAnimate;
allowWebp = allowWebp === undefined || allowWebp;
const GLOBAL_ENV = global.window.GLOBAL_ENV;
const CDN_HOST = GLOBAL_ENV.CDN_HOST;
const r5 = CDN_HOST != null ? 'https://' + CDN_HOST : global.location.protocol + global.window.GLOBAL_ENV.API_ENDPOINT;
const imageFormat_66787 = getImageFormat_66787({storageHash: storageHash, canAnimate: canAnimate,
allowWebp: allowWebp});
object = {};
const getBestMediaProxySize = ImageLoaderUtilsModule.getBestMediaProxySize;
const getDevicePixelRatio = ImageLoaderUtilsModule.getDevicePixelRatio;
object.size = Reflect.apply(getBestMediaProxySize, ImageLoaderUtilsModule,
[size * Reflect.apply(getDevicePixelRatio, ImageLoaderUtilsModule, [])]);
if (imageFormat_66787 === 'webp' && canAnimate && (require(1423) /* metro dependency 1423: AvatarUtils */).isAnimatedIconHash(storageHash)) {
object.animated = true;
}
const value4 = Endpoints.ARCHIVED_AVATAR(userId, avatarId, storageHash, imageFormat_66787);
let value = Module01468;
value = value.stringify(object);
return '' + r5 + value4 + '?' + value;
}
function getFileTypeFromExtension(a0) { // fn#66789, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8588:814, offset: 0x01c0998e, size: 109 bytes, params: 2, frame: 12
if (a0 === 'gif') {
return 'image/gif';
}
if (a0 === 'png') {
return 'image/png';
}
if (a0 === 'jpg') {
return 'image/jpeg';
}
if (a0 === 'webp') {
return 'image/webp';
}
(GlobalUtilsModule).assertNever(a0);
}
function generateAvatarDescription(a0) { // fn#66790, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8588:1190, offset: 0x01c099fb, size: 374 bytes, params: 2, frame: 21
var r5;
const AssetOriginTypes = (RecentAvatarsTypesModule).AssetOriginTypes;
const intl = (IndexNativeModule).intl;
const t = (IndexNativeModule).t;
var date;
const r0 = a0 ?? ({});
const filename = r0.filename;
const assetOrigin = r0.assetOrigin;
const r6 = assetOrigin !== undefined ? assetOrigin : AssetOriginTypes.NEW_ASSET;
const ARCHIVED_ASSET = AssetOriginTypes.ARCHIVED_ASSET;
if (r6 !== ARCHIVED_ASSET) {
r5 = filename ?? intl.string(t.lqaIxI);
date = new global.Date();
return intl.formatToPlainString(r6 === AssetOriginTypes.EDITED_ARCHIVED_ASSET ? t.eC2sZi : t.DYil93, {name: r5,
dateTime: date.toLocaleString(intl.currentLocale, {'year': 'numeric', 'day': 'numeric', 'month': 'long',
'hour': 'numeric', 'minute': 'numeric'})});
}
}
function generateRecentAvatarFileDetails(a0, a1) { // fn#66791, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8588:1742, offset: 0x01c09b71, size: 198 bytes, params: 3, frame: 20
var r7;
var intl;
const getImageFormat_66787Binding = getImageFormat_66787;
const SUPPORTS_WEBP = (AvatarUtilsModule).SUPPORTS_WEBP;
const imageFormat_66787Binding = getImageFormat_66787Binding({storageHash: a0, canAnimate: true,
allowWebp: SUPPORTS_WEBP});
object = {};
if (a1 == null) {
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
r7 = intl.string((require(1244) /* metro dependency 1244: indexNative */).t.lqaIxI);
} else {
r7 = a1.split(',')[0];
}
object.filename = '' + r7 + '.' + imageFormat_66787Binding;
object.type = getFileTypeFromExtension(imageFormat_66787Binding);
return object;
}
function createPendingImage({assetOrigin, imageUri, description, originalAsset, originalMd5}) { // fn#66792, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8588:2068, offset: 0x01c09c37, size: 284 bytes, params: 2, frame: 18
const AssetOriginTypes = (RecentAvatarsTypesModule).AssetOriginTypes;
const r4 = assetOrigin !== undefined ? assetOrigin : AssetOriginTypes.NEW_ASSET;
const NEW_ASSET = AssetOriginTypes.NEW_ASSET;
if (NEW_ASSET === r4) {
return {assetOrigin: r4, imageUri: imageUri, description: description, originalMd5: originalMd5};
}
const EDITED_ARCHIVED_ASSET = AssetOriginTypes.EDITED_ARCHIVED_ASSET;
if (EDITED_ARCHIVED_ASSET === r4) {
return {assetOrigin: r4, imageUri: imageUri, description: description, originalAsset: originalAsset,
originalMd5: originalMd5};
}
const ARCHIVED_ASSET = AssetOriginTypes.ARCHIVED_ASSET;
if (ARCHIVED_ASSET === r4) {
return {assetOrigin: r4, imageUri: imageUri, originalAsset: originalAsset};
}
(GlobalUtilsModule).assertNever(r4);
}
function getPendingAvatarSrc({userId, image, size, canAnimate}) { // fn#66793, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8588:2592, offset: 0x01c09d53, size: 181 bytes, params: 2, frame: 19
var r1;
var r0;
var getArchivedAvatarURLBinding;
var object;
var originalAsset;
size = size === undefined ? 80 : size;
canAnimate = canAnimate === undefined || canAnimate;
if (image == null) {
r0 = image;
} else if (typeof image === 'string') {
r0 = image;
} else {
if (image.assetOrigin === (require(7611) /* metro dependency 7611: RecentAvatarsTypes */).AssetOriginTypes.ARCHIVED_ASSET) {
getArchivedAvatarURLBinding = getArchivedAvatarURL;
object = {userId: userId};
originalAsset = image.originalAsset;
object.avatarId = originalAsset.id;
originalAsset = image.originalAsset;
object.storageHash = originalAsset.storageHash;
object.size = size;
object.canAnimate = canAnimate;
r1 = getArchivedAvatarURLBinding(object);
} else {
r1 = image.imageUri;
}
r0 = r1;
}
return r0;
}
}
global.__d(_fun66786, 8403, [661, 1423, 1457, 1468, 1244, 7611, 1360,
2]) /* metro module 8403, dependencies: [661, 1423, 1457, 1468, 1244, 7611, 1360, 2] */;