/* Metro module 3963; source: modules/client_themes/native/ClientThemesUtils.tsx; dependencies: [57, 31, 1310, 3964, 1354, 697, 674, 4000, 4001, 3966, 4002, 4003, 4048, 4045, 2] */ import Module00057 from '../../../by-id/module-00057.js'; /* Metro dependency 57 */ import Module00674 from '../../../by-id/module-00674.js'; /* Metro dependency 674 */ import Native from '../../../external/discord_common/js/packages/tokens/native.tsx'; /* Metro dependency 697 */ import ThemeStore from '../../user_settings/ThemeStore.tsx'; /* Metro dependency 1310 */ import CustomThemeMobileStore from './CustomThemeMobileStore.tsx'; /* Metro dependency 1354 */ import ClientThemesBackgroundStore from '../ClientThemesBackgroundStore.tsx'; /* Metro dependency 3964 */ import Color from '../../../utils/Color.tsx'; /* Metro dependency 4001 */ import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ReactModule from '../../../by-id/module-00031-React.js'; /* Metro dependency 31 */ import * as ClientThemesTypesModule from '../ClientThemesTypes.tsx'; /* Metro dependency 3966 */ import * as ColorUtilsModule from '../../../utils/ColorUtils.tsx'; /* Metro dependency 4000 */ import * as MobileThemesUtilsModule from './MobileThemesUtils.tsx'; /* Metro dependency 4045 */ function _fun32428(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#32428, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:6, offset: 0x0101522b, size: 844 bytes, params: 8, frame: 25 const env0_0 = require; const getClientThemesGradientColorByPercentage2 = getClientThemesGradientColorByPercentage; const closure2 = function({colors}) { return colors.map(_fun32433); }; const getGradientAngle = function(a0) { return a0.type === require(dependencyMap[9]).ClientThemeType.BACKGROUND_GRADIENT_PRESET ? a0.angle : a0.customThemeSettings.gradientAngle; }; const closure3 = function(a0, a1) { return calculateGradientValueWithOpacity(a0, a1, a0.theme); }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); object = {LEVEL_9: 0.9}; object[0.9] = 'LEVEL_9'; object.LEVEL_85 = 0.85; object[0.85] = 'LEVEL_85'; object.LEVEL_8 = 0.8; object[0.8] = 'LEVEL_8'; object.LEVEL_75 = 0.75; object[0.75] = 'LEVEL_75'; object.LEVEL_7 = 0.7; object[0.7] = 'LEVEL_7'; object.LEVEL_6 = 0.6; object[0.6] = 'LEVEL_6'; object.LEVEL_5 = 0.5; object[0.5] = 'LEVEL_5'; object.LEVEL_4 = 0.4; object[0.4] = 'LEVEL_4'; object.LEVEL_35 = 0.35; object[0.35] = 'LEVEL_35'; object.LEVEL_3 = 0.3; object[0.3] = 'LEVEL_3'; object.LEVEL_25 = 0.25; object[0.25] = 'LEVEL_25'; object.LEVEL_2 = 0.2; object[0.2] = 'LEVEL_2'; object.LEVEL_15 = 0.15; object[0.15] = 'LEVEL_15'; object.LEVEL_1 = 0.1; object[0.1] = 'LEVEL_1'; const object2 = {}; const BLACK = (Native).unsafe_rawColors.BLACK; object2.DARK = BLACK; const WHITE = (Native).unsafe_rawColors.WHITE; object2.LIGHT = WHITE; const object3 = {START: 0}; object3[0] = 'START'; object3.MID = 50; object3[50] = 'MID'; object3.END = 100; object3[100] = 'END'; const colorToHex2 = colorToHex; (FileImportTrackerModule).fileFinishedImporting('modules/client_themes/native/ClientThemesUtils.tsx'); exports.GRADIENT_ANGLE_BREAKPOINT = 128; exports.OverlayOpacity = object; exports.OverlayColors = object2; exports.GradientPercentage = object3; exports.colorToHex = colorToHex2; exports.getClientThemesGradientColorByPercentage = getClientThemesGradientColorByPercentage2; exports.getClientThemesGradientHexColors = closure2; exports.getGradientThemeMetadata = getGradientThemeMetadata; exports.getGradientValue = closure3; exports.useGradientValue = useGradientValue; exports.getEmbedScrollGradientBackground = getEmbedScrollGradientBackground; exports.getEmbedBackground = getEmbedBackground; function getMixWithOpacity({r, g, b}, {r, g, b}, a2) { // fn#32429, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:791, offset: 0x01015577, size: 164 bytes, params: 4, frame: 25 const colorToHexBinding = colorToHex; const mixColors = ColorUtilsModule.mixColors; let value = Color; value = new value(r, g, b, a2); const defaultImport = Color; const value3 = 1 - a2; const value4 = Object.create(defaultImport.prototype, {constructor: {value: defaultImport}}); const defaultImport2 = new defaultImport(r, g, b, value3); return colorToHexBinding(Reflect.apply(mixColors, ColorUtilsModule, [value, defaultImport2 instanceof Object ? defaultImport2 : value4])); } function getClientThemesGradientColorByPercentage(a0, a1) { // fn#32430, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:924, offset: 0x0101561b, size: 149 bytes, params: 3, frame: 16 const value = Module00057((importDefault(674) /* metro dependency 674 */).scale(getClientThemesGradientHexColors(a0)).domain(a0.colors.map(function(a0) { return a0.stop; }))(a1).rgb(), 3); return {r: value[0], g: value[1], b: value[2]}; } function getClientThemesGradientHexColors({colors}) { // fn#32432, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:1126, offset: 0x010156bb, size: 27 bytes, params: 2, frame: 11 return colors.map(function(a0) { return importDefault(dependencyMap[5]).unsafe_rawColors[a0.token]; }); function _fun32433({token}) { // fn#32433, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:1192, offset: 0x010156d6, size: 45 bytes, params: 2, frame: 11 return (Native).unsafe_rawColors[token]; } } function getGradientColorByPercentage(a0, a1) { // fn#32435, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:1373, offset: 0x0101574a, size: 254 bytes, params: 3, frame: 19 const type = a0.type; const ClientThemeType = (ClientThemesTypesModule).ClientThemeType; const BACKGROUND_GRADIENT_PRESET = ClientThemeType.BACKGROUND_GRADIENT_PRESET; if (type === BACKGROUND_GRADIENT_PRESET) { return getClientThemesGradientColorByPercentage(a0, a1); } const colors = a0.customThemeSettings.colors; if (colors.length === 1) { return (require(4000) /* metro dependency 4000: ColorUtils */).hexToRgb(colors[0]); } const value2 = colors.map(function(a0, a1) { return a1 / (colors.length - 1) * 100; }); const value3 = (Module00674).scale(colors); const value = Module00057(value3.domain(value2)(a1).rgb(), 3); return {r: value[0], g: value[1], b: value[2]}; } function getBottomColorWithOpacity(a0, a1, a2) { // fn#32437, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:1733, offset: 0x0101586b, size: 76 bytes, params: 4, frame: 17 return getMixWithOpacity(getGradientColorByPercentage(a0, getGradientAngle(a0) > env0_8 ? env0_11.END : env0_11.START), a1, a2); } function getTopColorWithOpacity(a0, a1, a2) { // fn#32438, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:1873, offset: 0x010158b7, size: 76 bytes, params: 4, frame: 17 return getMixWithOpacity(getGradientColorByPercentage(a0, getGradientAngle(a0) > env0_8 ? env0_11.START : env0_11.END), a1, a2); } function calculateGradientValueWithOpacity(a0, a1, a2, a3) { // fn#32439, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:2010, offset: 0x01015903, size: 512 bytes, params: 5, frame: 23 var r3; var r0; var isThemeDark3; let value = a1; const value2 = a3; const isThemeDark2 = (require(4002) /* metro dependency 4002: shared */).isThemeDark(a2); const hexToRgb = ColorUtilsModule.hexToRgb; let binding = env0_10; const r4 = isThemeDark2 ? Reflect.apply(hexToRgb, ColorUtilsModule, [binding.DARK]) : Reflect.apply(hexToRgb, ColorUtilsModule, [binding.LIGHT]); let type = a0.type; const ClientThemeType = (ClientThemesTypesModule).ClientThemeType; const BACKGROUND_GRADIENT_PRESET = ClientThemeType.BACKGROUND_GRADIENT_PRESET; let r8 = type !== BACKGROUND_GRADIENT_PRESET ? env0_11.MID : a0.midpointPercentage ?? env0_11.MID; r8 = value ?? r8; type = a0.type; const CUSTOM_BACKGROUND_GRADIENT = ClientThemeType.CUSTOM_BACKGROUND_GRADIENT; if (type === CUSTOM_BACKGROUND_GRADIENT) { value = a0.customThemeSettings.baseMix / 100; if (value2 != null) { r0 = value2; } else { isThemeDark3 = (require(4002) /* metro dependency 4002: shared */).isThemeDark(a2); value = 0.2 * value; r0 = isThemeDark3 ? 0.12 + value : 0.3 + value; } r3 = r0; } else if (value2 != null) { r3 = value2; } else { value = require(4002) /* metro dependency 4002: shared */; value = value.isThemeDark(a2); binding = env0_9; r3 = value ? binding.LEVEL_2 : binding.LEVEL_4; } value = getGradientAngle(a0); const START = env0_11.START; return r8 === START ? value < env0_8 ? getBottomColorWithOpacity(a0, r4, r3) : getTopColorWithOpacity(a0, r4, r3) : r8 === env0_11.END ? value > env0_8 ? getBottomColorWithOpacity(a0, r4, r3) : getTopColorWithOpacity(a0, r4, r3) : getMixWithOpacity(getGradientColorByPercentage(a0, r8), r4, r3); } function colorToHex({red, green, blue}) { // fn#32441, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:742, offset: 0x01015b21, size: 76 bytes, params: 2, frame: 15 let value = Module00674; value = value.rgb(red, green, blue); return value.hex('rgb'); } function getGradientThemeMetadata(a0, a1) { // fn#32442, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:3241, offset: 0x01015b6d, size: 608 bytes, params: 3, frame: 33 var r10; var r3; var r4; var colors; var value7; var indexOf; var Math; var min; var items2; var value9; var defaultImport; var max; var value10; if (a0 == null) { return null; } if (a1 == null) { return null; } var value; const getGradientValueBinding = getGradientValue; const START = env0_11.START; const gradientValueBinding = getGradientValueBinding(a1, START); const MID = env0_11.MID; const gradientValueBinding2 = getGradientValueBinding(a1, MID); const END = env0_11.END; const gradientValueBinding3 = getGradientValueBinding(a1, END); const gradientAngle = getGradientAngle(a1); const r6 = gradientAngle > env0_8 ? gradientValueBinding : gradientValueBinding3; const r5 = gradientAngle > env0_8 ? gradientValueBinding3 : gradientValueBinding; let type = a1.type; const ClientThemeType = (ClientThemesTypesModule).ClientThemeType; const BACKGROUND_GRADIENT_PRESET = ClientThemeType.BACKGROUND_GRADIENT_PRESET; const r11 = type === BACKGROUND_GRADIENT_PRESET ? getClientThemesGradientHexColors(a1) : a1.customThemeSettings.colors; const property = r11[0]; const property2 = r11[r11.length - 1]; type = a1.type; const CUSTOM_BACKGROUND_GRADIENT = ClientThemeType.CUSTOM_BACKGROUND_GRADIENT; if (type !== CUSTOM_BACKGROUND_GRADIENT) { r3 = property2; r4 = property; } else { colors = a1.customThemeSettings.colors; value7 = colors.map(_fun32443); value = importDefault(674) /* metro dependency 674 */; indexOf = value7.indexOf; Math = global.Math; min = Math.min; items2 = []; value = value(colors[Reflect.apply(indexOf, value7, [apply(min, items2, Math, arraySpread(items2, value7, 0, undefined))])]); value = value.set('hsl.s', 0.2); value9 = value.set('hsl.l', 0.7).hex(); defaultImport = importDefault(674) /* metro dependency 674 */; indexOf = value7.indexOf; Math = global.Math; max = Math.max; items2 = []; arraySpread(items2, value7, 0, value); value = defaultImport(colors[Reflect.apply(indexOf, value7, [apply(max, items2, Math, value)])]); value = value.set('hsl.s', 0.2); value = value.set('hsl.l', 0.9); value = value.hex(); value10 = a0 === 'dark'; r10 = value10 ? value9 : value; r3 = value10 ? value : value9; r4 = r10; } return {theme: a0, colors: {['gradient.start']: gradientValueBinding, ['gradient.mid']: gradientValueBinding2, ['gradient.end']: gradientValueBinding3, ['gradient.top']: r6, ['gradient.bottom']: r5, ['gradient.primary']: r4, ['gradient.secondary']: r3}}; function _fun32443(a0) { // fn#32443, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:3748, offset: 0x01015dcd, size: 45 bytes, params: 2, frame: 11 let value = environment.__proto__; value = importDefault(674) /* metro dependency 674 */; value = value(a0); return value.luminance(); } } function useGradientValue(a0, a1) { // fn#32444, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:4184, offset: 0x01015dfa, size: 147 bytes, params: 3, frame: 20 const env0_0 = a0; const env0_1 = a1; const value2 = undefined; return ReactModule.useMemo(_fun32445, [(importDefault(4003) /* metro dependency 4003: useColorThemeBackground */)(), a1 == null ? value2 : a1.dark, a1 == null ? value2 : a1.light, a0, (importDefault(4048) /* metro dependency 4048: useTheme */)()]); function _fun32445() { // fn#32445, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:4265, offset: 0x01015e8d, size: 282 bytes, params: 1, frame: 20 var r5; var r7; var calculateGradientValueWithOpacityBinding; var binding; var value4; var isThemeDark2; var isThemeDark3; var value5; var binding3; var binding4; if (env0_2 == null) { return null; } const value2 = undefined; if ((require == null ? value2 : require.dark) != null) { value4 = environment.__proto__; isThemeDark2 = (require(4002) /* metro dependency 4002: shared */).isThemeDark(Module00057); binding = env1_9; r5 = isThemeDark2 ? binding.LEVEL_2 : binding.LEVEL_4; isThemeDark3 = (require(4002) /* metro dependency 4002: shared */).isThemeDark(Module00057); value5 = require == null; r7 = isThemeDark3 ? value5 ? value2 : require.dark : value5 ? value2 : require.light; calculateGradientValueWithOpacityBinding = calculateGradientValueWithOpacity; binding = env0_2; binding3 = env0_0; binding4 = Module00057; r5 = r7 ?? r5; return calculateGradientValueWithOpacityBinding(binding, binding3, binding4, r5); } if ((require == null ? value2 : require.light) != null) { value4 = environment.__proto__; isThemeDark2 = (require(4002) /* metro dependency 4002: shared */).isThemeDark(Module00057); binding = env1_9; r5 = isThemeDark2 ? binding.LEVEL_2 : binding.LEVEL_4; isThemeDark3 = (require(4002) /* metro dependency 4002: shared */).isThemeDark(Module00057); value5 = require == null; r7 = isThemeDark3 ? value5 ? value2 : require.dark : value5 ? value2 : require.light; calculateGradientValueWithOpacityBinding = calculateGradientValueWithOpacity; binding = env0_2; binding3 = env0_0; binding4 = Module00057; r5 = r7 ?? r5; return calculateGradientValueWithOpacityBinding(binding, binding3, binding4, r5); } return calculateGradientValueWithOpacity(env0_2, env0_0, Module00057); } } function getEmbedScrollGradientBackground() { // fn#32446, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:4682, offset: 0x01015fa7, size: 83 bytes, params: 1, frame: 14 const customBackgroundGradient = (MobileThemesUtilsModule).getCustomBackgroundGradient(); const value3 = null; const r4 = value3 != customBackgroundGradient ? customBackgroundGradient : ClientThemesBackgroundStore.gradientPreset; const r2 = value3 != r4 ? r4 : value3; return value3 == r2 ? value3 : getGradientValue(r2); } function getEmbedBackground() { // fn#32447, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4112:4884, offset: 0x01015ffa, size: 144 bytes, params: 1, frame: 15 var r3; var moduleValue; var isThemeDark2; var binding; var moduleValue2; const hasCustomTheme2 = CustomThemeMobileStore.hasCustomTheme(); if (ClientThemesBackgroundStore.gradientPreset != null) { moduleValue = require(4002) /* metro dependency 4002: shared */; isThemeDark2 = moduleValue.isThemeDark(ThemeStore.theme); binding = env0_10; r3 = isThemeDark2 ? binding.DARK : binding.LIGHT; moduleValue2 = require(4000) /* metro dependency 4000: ColorUtils */; return moduleValue2.hexWithOpacity(r3, env0_9.LEVEL_1); } if (hasCustomTheme2) { moduleValue = require(4002) /* metro dependency 4002: shared */; isThemeDark2 = moduleValue.isThemeDark(ThemeStore.theme); binding = env0_10; r3 = isThemeDark2 ? binding.DARK : binding.LIGHT; moduleValue2 = require(4000) /* metro dependency 4000: ColorUtils */; return moduleValue2.hexWithOpacity(r3, env0_9.LEVEL_1); } return null; } } global.__d(_fun32428, 3963, [57, 31, 1310, 3964, 1354, 697, 674, 4000, 4001, 3966, 4002, 4003, 4048, 4045, 2]) /* metro module 3963, dependencies: [57, 31, 1310, 3964, 1354, 697, 674, 4000, 4001, 3966, 4002, 4003, 4048, 4045, 2] */;