Files
discord-decomp/sources/modules/guild_boosting/RoleIconUtils.tsx
T
2026-07-28 01:06:53 +03:00

115 lines
5.9 KiB
TypeScript

/* Metro module 6794; source: modules/guild_boosting/RoleIconUtils.tsx; dependencies: [661, 477, 3797, 1457, 1423, 2] */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as PlatformUtilsModule from '../../utils/PlatformUtils.tsx'; /* Metro dependency 477 */
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
function _fun53491(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#53491, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6972:6, offset: 0x0134d670, size: 323 bytes, params: 8, frame: 23
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let protocol = global.location.protocol;
let GLOBAL_ENV = global.window.GLOBAL_ENV;
const CDN_HOST = GLOBAL_ENV.CDN_HOST;
const env0_5 = '' + protocol + '//' + CDN_HOST + '/role-icons';
protocol = global.location.protocol;
GLOBAL_ENV = global.window.GLOBAL_ENV;
const API_ENDPOINT = GLOBAL_ENV.API_ENDPOINT;
const env0_6 = '' + protocol + API_ENDPOINT;
const env0_7 = (PlatformUtilsModule).isAndroid();
(FileImportTrackerModule).fileFinishedImporting('modules/guild_boosting/RoleIconUtils.tsx');
exports.getRoleIconData = getRoleIconData;
exports.replaceRoleIconSourceSize = replaceRoleIconSourceSize;
exports.isRoleIconAssetUrl = isRoleIconAssetUrl;
exports.canGuildUseRoleIcons = canGuildUseRoleIcons;
function getRoleIconSource({id, icon}, a1) { // fn#53492, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6972:303, offset: 0x0134d7b3, size: 336 bytes, params: 3, frame: 32
var r10;
var r1;
var r7;
var r8;
var value;
var value4;
var moduleValue;
var getBestMediaProxySize;
var moduleValue2;
var value7;
var binding;
if (icon != null) {
if (icon.startsWith('data:')) {
return icon;
}
r10 = (require(1423) /* metro dependency 1423: AvatarUtils */).SUPPORTS_WEBP ? 'webp' : 'png';
value4 = '';
if (a1 != null) {
moduleValue = require(1457) /* metro dependency 1457: ImageLoaderUtils */;
getBestMediaProxySize = moduleValue.getBestMediaProxySize;
moduleValue2 = require(1457) /* metro dependency 1457: ImageLoaderUtils */;
value7 = 'size=' + Reflect.apply(getBestMediaProxySize, moduleValue,
[a1 * moduleValue2.getDevicePixelRatio()]);
r1 = env0_7 ? value4 : '&quality=lossless';
r7 = value7;
r8 = r1;
} else {
r7 = value4;
r8 = 'quality=lossless';
}
if (global.window.GLOBAL_ENV.CDN_HOST != null) {
r1 = value4 + env0_5 + '/' + id + '/' + icon + '.' + r10 + '?' + r7 + r8;
} else {
binding = env0_6;
value = Endpoints.ROLE_ICON(id, icon);
value = value4 + binding + value + '?' + r7;
r1 = value;
}
return r1;
}
}
function getRoleIconData(a0, a1) { // fn#53493, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6972:729, offset: 0x0134d903, size: 136 bytes, params: 3, frame: 19
var r3;
var defaultImport;
var getByName;
var defaultImport2;
if (a0 == null) {
return null;
}
const unicodeEmoji = a0.unicodeEmoji;
const value = undefined;
if (unicodeEmoji != null) {
defaultImport = importDefault(3797) /* metro dependency 3797: UnicodeEmojis */;
getByName = defaultImport.getByName;
defaultImport2 = importDefault(3797) /* metro dependency 3797: UnicodeEmojis */;
r3 = Reflect.apply(getByName, defaultImport, [defaultImport2.convertSurrogateToName(a0.unicodeEmoji, false)]);
} else {
r3 = value;
}
const object = {};
object.customIconSrc = getRoleIconSource(a0, a1);
object.unicodeEmoji = r3 ?? value;
return object;
}
function replaceRoleIconSourceSize(a0, a1) { // fn#53494, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6972:967, offset: 0x0134d98b, size: 116 bytes, params: 3, frame: 17
const replace = a0.replace;
var value;
const getBestMediaProxySize = (require(1457) /* metro dependency 1457: ImageLoaderUtils */).getBestMediaProxySize;
value = Reflect.apply(getBestMediaProxySize, value,
[a1 * (require(1457) /* metro dependency 1457: ImageLoaderUtils */).getDevicePixelRatio()]);
value = 'size=' + value;
return Reflect.apply(replace, a0, [RegExp('size=[0-9]+', 'g'), value]);
}
function isRoleIconAssetUrl(a0) { // fn#53495, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6972:1094, offset: 0x0134d9ff, size: 92 bytes, params: 2, frame: 16
return a0.startsWith(env0_5) || a0.startsWith('' + env0_6 + '/roles') && a0.includes('/icons/');
}
function canGuildUseRoleIcons(a0, a1) { // fn#53496, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6972:1187, offset: 0x0134da5b, size: 76 bytes, params: 3, frame: 13
let value = undefined;
value = (a1 == null || a1.tags == null ? value : a1.tags.subscription_listing_id) != null;
return value || a0.features.has(GuildFeatures.ROLE_ICONS);
}
}
global.__d(_fun53491, 6794, [661, 477, 3797, 1457, 1423,
2]) /* metro module 6794, dependencies: [661, 477, 3797, 1457, 1423, 2] */;