/* Metro module 7704; source: modules/client_themes/native/ThemedGradient.tsx; dependencies: [31, 27, 3964, 33, 4501, 4002, 4001, 4000, 1478, 4589, 4048, 697, 4004, 3963, 674, 1216, 632, 4006, 4047, 3966, 2] */ import UseWindowDimensionsNative from '../../screen/useWindowDimensions.native.tsx'; /* Metro dependency 1478 */ import ClientThemesBackgroundStore from '../ClientThemesBackgroundStore.tsx'; /* Metro dependency 3964 */ import Color from '../../../utils/Color.tsx'; /* Metro dependency 4001 */ import UseRoutedActiveGuildTheme from '../../guild_themes/native/useRoutedActiveGuildTheme.tsx'; /* Metro dependency 4006 */ import UseTheme from '../../../hooks/useTheme.tsx'; /* Metro dependency 4048 */ import LinearGradient from '../../../by-id/module-04589-LinearGradient.js'; /* Metro dependency 4589 */ import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ReactNativeModule from '../../../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */ import * as ReactModule from '../../../by-id/module-00031-React.js'; /* Metro dependency 31 */ import * as JsxRuntimeModule from '../../../by-id/module-00033-JsxRuntime.js'; /* Metro dependency 33 */ import * as UseStateFromStoresModule from '../../../external/discord_common/js/packages/flux/useStateFromStores.tsx'; /* Metro dependency 632 */ import * as ClientThemesUtilsModule from './ClientThemesUtils.tsx'; /* Metro dependency 3963 */ import * as ClientThemesTypesModule from '../ClientThemesTypes.tsx'; /* Metro dependency 3966 */ import * as ColorUtilsModule from '../../../utils/ColorUtils.tsx'; /* Metro dependency 4000 */ import * as SharedModule from '../../../design/shared.tsx'; /* Metro dependency 4002 */ import * as GuildThemePresetsModule from '../../guild_themes/GuildThemePresets.tsx'; /* Metro dependency 4004 */ import * as UseCustomThemeDisplaySettingsModule from './useCustomThemeDisplaySettings.tsx'; /* Metro dependency 4047 */ import * as CreateStylesModule from '../../../design/components/Styles/native/createStyles.tsx'; /* Metro dependency 4501 */ function _fun61503(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#61503, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:6, offset: 0x01b42256, size: 425 bytes, params: 8, frame: 21 const env0_0 = require; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_8 = (CreateStylesModule).createStyles({softenGradient: {flex: 1}, linearGradient: {flex: 1}, absolute: {'position': 'absolute', 'top': 0, 'bottom': 0, 'left': 0, 'right': 0}}); const env0_9 = {'x': 0.5, 'y': 0.5}; const Gradient2 = Gradient; const env0_14 = RegExp('^#(?:[0-9a-fA-F]{3}){1,2}$', ''); const closure2 = function(a0) { return a0.reduce(_fun61522, []); }; const useThemedGradientCommon = function() { var value2 = useStyles(); var value3 = importDefault(dependencyMap[10])(); var object = {styles: value2}; var isThemeDark = require(dependencyMap[5]).isThemeDark(value3); var property = importDefault(dependencyMap[11]).unsafe_rawColors; object.overlayColor = isThemeDark ? property.BLACK : property.WHITE; return object; }; (FileImportTrackerModule).fileFinishedImporting('modules/client_themes/native/ThemedGradient.tsx'); exports.default = _default_61526; exports.Gradient = Gradient2; exports.validateColors = closure2; exports.CustomThemedGradient = CustomThemedGradient; function getThemeMixColor({mixAmount = {}, mixColorOverride, theme, darkFallbackOpacity, lightFallbackOpacity}) { // fn#61504, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:319, offset: 0x01b423ff, size: 206 bytes, params: 2, frame: 22 darkFallbackOpacity = darkFallbackOpacity === undefined ? 0.7 : darkFallbackOpacity; lightFallbackOpacity = lightFallbackOpacity === undefined ? 0.8 : lightFallbackOpacity; if (mixColorOverride != null) { return mixColorOverride; } const isThemeDark2 = (SharedModule).isThemeDark(theme); let r4 = isThemeDark2 ? darkFallbackOpacity : lightFallbackOpacity; let r3 = isThemeDark2 ? mixAmount.dark : mixAmount.light; r4 = r3 ?? r4; r3 = isThemeDark2 ? 0 : 255; let value = Color; const value4 = Object.create(value.prototype, {constructor: {value: value}}); value = new value(r3, r3, r3, r4); return value instanceof Object ? value : value4; } function getThemedMixAmount({mixAmount = {}, theme, darkFallbackAmount, lightFallbackAmount}) { // fn#61505, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:578, offset: 0x01b424cd, size: 157 bytes, params: 2, frame: 16 darkFallbackAmount = darkFallbackAmount === undefined ? 0.3 : darkFallbackAmount; lightFallbackAmount = lightFallbackAmount === undefined ? 0.2 : lightFallbackAmount; return SharedModule.isThemeDark(theme) ? mixAmount.dark == null ? darkFallbackAmount : 1 - mixAmount.dark : mixAmount.light == null ? lightFallbackAmount : 1 - mixAmount.light; } function getMixedGradientColor({color, mixAmount, mixColorOverride, theme}) { // fn#61506, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:762, offset: 0x01b4256a, size: 197 bytes, params: 2, frame: 22 const themeMixColor = getThemeMixColor({mixAmount: mixAmount, mixColorOverride: mixColorOverride, theme: theme}); const themedMixAmount = getThemedMixAmount({mixAmount: mixAmount, theme: theme}); const {r, g, b} = (ColorUtilsModule).hexToRgb(color); const mixColors = ColorUtilsModule.mixColors; let value = Color; value = new value(r, g, b, themedMixAmount); value = Reflect.apply(mixColors, ColorUtilsModule, [themeMixColor, value]); return value.toHexString(); } function CustomThemesGradient({colors, baseMix, gradientAngle, gradientColorStops, absolute, wide, tall, mix, mixAmount = {}, mixColorOverride, componentStyles, theme}) { // fn#61507, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:2500, offset: 0x01b4262f, size: 541 bytes, params: 2, frame: 29 var r0; var value; const styles = useStyles(); const {width, height} = (UseWindowDimensionsNative)(); const value3 = ((a0) => { var r3; var property = a0.colors; var env0_0 = a0.baseMix; var mix = a0.mix; var mixAmount = a0.mixAmount; var env0_1 = mixAmount !== undefined ? mixAmount : {}; var env0_2 = a0.mixColorOverride; var env0_3 = a0.theme; r3 = mix ? property.map(_fun61509) : property; return r3.length !== 1 ? r3 : [r3[0], r3[0]]; })({colors: colors, mix: mix, mixAmount: mixAmount, mixColorOverride: mixColorOverride, theme: theme, baseMix: baseMix}); const value4 = gradientAngle - 90; let Math = global.Math; const PI = Math.PI; const value5 = value4 * PI / 180; Math = global.Math; const value6 = Math.cos(value5); Math = global.Math; const value7 = Math.sin(value5); const {start, end} = {start: {x: 0.6 - 0.7142857142857143 * value6, y: 0.5 - 0.7142857142857143 * value7}, end: {x: 0.6 + 0.7142857142857143 * value6, y: 0.5 + 0.7142857142857143 * value7}}; const value8 = validateColors(value3); const value9 = ((a0) => { var r3; var value = a1; var env0_0 = a0; r3 = value !== undefined ? value : []; return r3.length === a0.length ? r3.map(_fun61511) : a0.length === 1 ? [0, 1] : a0.map(_fun61512); })(value8, gradientColorStops); ReactModule.useEffect(_fun61513, [value8, value3]); if (value8.length < 2) { r0 = null; } else { value = importDefault(4589) /* metro dependency 4589 */; absolute = absolute && styles.absolute; value = ((Component) => )(value); r0 = value; } return r0; function getGradientColorsForCustomThemesGradient({colors, baseMix, mix, mixAmount = {}, mixColorOverride, theme}) { // fn#61508, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:2726, owner: CustomThemesGradient.getGradientColorsForCustomThemesGradient, offset: 0x01b4284c, size: 127 bytes, params: 2, frame: 14 const r3 = mix ? colors.map(_fun61509) : colors; return r3.length !== 1 ? r3 : [r3[0], r3[0]]; function _fun61509(a0) { // fn#61509, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:2874, offset: 0x01b428cb, size: 292 bytes, params: 2, frame: 23 const value2 = 1 - baseMix / 100; const getThemeMixColorBinding = getThemeMixColor; const binding = env0_1; const themeBinding = theme; let value = getThemeMixColorBinding({mixAmount: binding, mixColorOverride: mixColorOverride, theme: themeBinding, darkFallbackOpacity: env2_10 + 0.25 * value2, lightFallbackOpacity: env2_10 + 0.2 * value2}); const themedMixAmount = getThemedMixAmount({mixAmount: binding, theme: themeBinding, darkFallbackAmount: env2_10, lightFallbackAmount: env2_10}); const {r, g, b} = (ColorUtilsModule).hexToRgb(a0); const mixColors = ColorUtilsModule.mixColors; const defaultImport = Color; const value6 = Object.create(defaultImport.prototype, {constructor: {value: defaultImport}}); const defaultImport2 = new defaultImport(r, g, b, themedMixAmount); value = Reflect.apply(mixColors, ColorUtilsModule, [value, defaultImport2 instanceof Object ? defaultImport2 : value6]); return (ClientThemesUtilsModule).colorToHex(value); } } function getGradientLocationsForCustomThemesGradient(a0) { // fn#61510, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:3547, owner: CustomThemesGradient.getGradientLocationsForCustomThemesGradient, offset: 0x01b429ef, size: 94 bytes, params: 2, frame: 13 const value = a1; const env0_0 = a0; const r3 = value !== undefined ? value : []; return r3.length === a0.length ? r3.map(function(a0) { return a0 / 100; }) : a0.length === 1 ? [0, 1] : a0.map(_fun61512); function _fun61512(a0, a1) { // fn#61512, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:3679, offset: 0x00d3a36f, size: 28 bytes, params: 3, frame: 2 return a1 / (env0_0.length - 1); } } function _fun61513() { // fn#61513, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:3729, offset: 0x01b42a59, size: 129 bytes, params: 1, frame: 17 var value2; var defaultImport; var captureException; var error; var object2; if (env0_1.length < 2) { value2 = environment.__proto__; defaultImport = importDefault(1216) /* metro dependency 1216: SentryUtilsNative */; captureException = defaultImport.captureException; error = new global.Error('Invalid custom theme gradient colors'); object2 = {}; object2.gradientColors = global.JSON.stringify(env0_0); Reflect.apply(captureException, defaultImport, [error, {extra: object2}]); } } } function GradientBase({colors, locations, angle, angleCenter = env0_9, absolute, wide, tall, componentStyles}) { // fn#61514, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:1076, offset: 0x01b42ada, size: 227 bytes, params: 2, frame: 25 const styles = useStyles(); const {width, height} = (UseWindowDimensionsNative)(); absolute = absolute && styles.absolute; return ((Component) => )(LinearGradient); } function Gradient({gradient, absolute, wide, tall, angleOverride, componentStyles, mix, mixAmount = {}, mixColorOverride}) { // fn#61515, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:1368, offset: 0x01b42bbd, size: 237 bytes, params: 2, frame: 23 const env0_3 = (UseTheme)(); return ( ); function _fun61516(a0) { // fn#61516, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:1520, offset: 0x01b42caa, size: 136 bytes, params: 2, frame: 16 var r0; var getMixedGradientColorBinding; var object; if (mix) { getMixedGradientColorBinding = getMixedGradientColor; object = {}; object.color = (importDefault(697) /* metro dependency 697: native */).unsafe_rawColors[a0.token]; object.mixAmount = env0_1; object.mixColorOverride = mixColorOverride; object.theme = env0_3; r0 = getMixedGradientColorBinding(object); } else { r0 = (importDefault(697) /* metro dependency 697: native */).unsafe_rawColors[a0.token]; } return r0; } } function GuildThemePresetGradient({preset, absolute, wide, tall, angleOverride, componentStyles, mix, mixAmount = {}, mixColorOverride}) { // fn#61518, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:1876, offset: 0x01b42d44, size: 255 bytes, params: 2, frame: 23 const guildThemePresetAppearance = (GuildThemePresetsModule).getGuildThemePresetAppearance(preset, (UseTheme)()); return ( ); function _fun61519(a0) { // fn#61519, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:2071, offset: 0x01b42e43, size: 76 bytes, params: 2, frame: 13 return mix ? getMixedGradientColor({color: a0.hex, mixAmount: env0_1, mixColorOverride: mixColorOverride, theme: ReactModule}) : a0.hex; } } function validateColors(a0) { // fn#61521, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:2366, offset: 0x01b42e8f, size: 28 bytes, params: 2, frame: 13 return a0.reduce(_fun61522, []); function _fun61522(a0, a1) { // fn#61522, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:2379, offset: 0x01b42eab, size: 125 bytes, params: 3, frame: 15 var value; var push; var property; var hex; var error; if (typeof a1 !== 'string') { try { push = a0.push; value = environment.__proto__; property = dependencyMap[14]; value = importDefault(property); value = value(a1); value = value.hex('rgb'); Reflect.apply(push, a0, [value]); } catch (error) { } } else { value = environment.__proto__; var binding = env1_14; if (binding.test(a1)) { a0.push(a1); return a0; } try { push = a0.push; } catch (error) { return a0; } value = environment.__proto__; try { } catch (error) { return a0; } try { } catch (error) { return a0; } try { property = dependencyMap[14]; } catch (error) { return a0; } try { value = importDefault(property); } catch (error) { return a0; } try { value = value(a1); } catch (error) { return a0; } try { hex = value.hex; } catch (error) { return a0; } try { value = Reflect.apply(hex, value, ['rgb']); } catch (error) { return a0; } try { Reflect.apply(push, a0, [value]); } catch (error) { } } return a0; } } function wrapWithOverlayIfNeeded(a0, a1, a2, a3, a4) { // fn#61523, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:4037, offset: 0x01b42f28, size: 145 bytes, params: 6, frame: 23 var r0; var items3; var items2; var object2; let value = a0; if (a1) { var viewBindingProps = {style: a2.absolute}; items3 = [value]; items2 = [a2.softenGradient]; object2 = {}; value = require(4000) /* metro dependency 4000: ColorUtils */; object2.backgroundColor = value.hexWithOpacity(a3, a4); items2[1] = object2; items3[1] = ; value = ( {items3} ); r0 = value; } else { r0 = value; } return r0; } function ActiveGuildThemeGradient(a0) { // fn#61525, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:4369, offset: 0x01b43031, size: 298 bytes, params: 2, frame: 23 var customUserThemeSettings; var property; var items2; const activeGuildTheme = a0.activeGuildTheme; const theme = a0.theme; let value = Object.create(null); const value2 = 0; value.activeGuildTheme = value2; value.theme = value2; const value3 = copyDataProperties({}, a0, value, undefined); if (activeGuildTheme.type === 'custom') { customUserThemeSettings = activeGuildTheme.customUserThemeSettings; property = customUserThemeSettings.colors[value2]; var customThemesGradientBindingProps = {...value3}; value = require(4004) /* metro dependency 4004: GuildThemePresets */; value = value.getSingleColorGuildThemeGradientColors(property, theme); items2 = []; arraySpread(items2, value, value2, property); customThemesGradientBindingProps['colors'] = items2; customThemesGradientBindingProps['gradientColorStops'] = []; customThemesGradientBindingProps['gradientAngle'] = customUserThemeSettings.gradientAngle ?? value2; customThemesGradientBindingProps['baseMix'] = customUserThemeSettings.baseMix ?? (require(4004) /* metro dependency 4004: GuildThemePresets */).GUILD_THEME_DEFAULT_BASE_MIX; customThemesGradientBindingProps['theme'] = theme; return ; } return ; } function _default_61526(a0) { // fn#61526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:4794, offset: 0x01b4315b, size: 667 bytes, params: 2, frame: 30 var type; const ClientThemeType = (ClientThemesTypesModule).ClientThemeType; let overlayOpacity = a0.overlayOpacity; overlayOpacity = overlayOpacity === undefined ? 0.7 : overlayOpacity; const gradientOverride = a0.gradientOverride; const value = null; const value2 = Object.create(value); value2.overlayOpacity = 0; value2.gradientOverride = 0; const value3 = copyDataProperties({}, a0, value2, undefined); const {styles, overlayColor} = useThemedGradientCommon(); const withOverlay = value3.withOverlay; const value6 = (UseTheme)(); const useStateFromStoresObject = UseStateFromStoresModule.useStateFromStoresObject; const preset = Reflect.apply(useStateFromStoresObject, UseStateFromStoresModule, [[ClientThemesBackgroundStore], function() { return {preset: ClientThemesBackgroundStore.gradientPreset}; }]).preset; const value7 = (UseRoutedActiveGuildTheme)(); const value8 = (UseCustomThemeDisplaySettingsModule).useCustomThemeDisplaySettings(); const value9 = value8 !== undefined; if (value != gradientOverride) { if (value9) { type = gradientOverride.type; if (type === ClientThemeType.CUSTOM_BACKGROUND_GRADIENT) { return wrapWithOverlayIfNeeded(, withOverlay, styles, overlayColor, overlayOpacity); } type = gradientOverride.type; if (type === ClientThemeType.BACKGROUND_GRADIENT_PRESET) { return wrapWithOverlayIfNeeded(, withOverlay, styles, overlayColor, overlayOpacity); } return ( value != value7 ? wrapWithOverlayIfNeeded(, withOverlay, styles, overlayColor, overlayOpacity) : ( value9 && value9 ? wrapWithOverlayIfNeeded(, withOverlay, styles, overlayColor, overlayOpacity) : ( value != preset ? wrapWithOverlayIfNeeded(, withOverlay, styles, overlayColor, overlayOpacity) : value ) ) ); } type = gradientOverride.type; if (type === ClientThemeType.BACKGROUND_GRADIENT_PRESET) { return wrapWithOverlayIfNeeded(, withOverlay, styles, overlayColor, overlayOpacity); } } return ( value != value7 ? wrapWithOverlayIfNeeded(, withOverlay, styles, overlayColor, overlayOpacity) : ( value9 && value9 ? wrapWithOverlayIfNeeded(, withOverlay, styles, overlayColor, overlayOpacity) : ( value != preset ? wrapWithOverlayIfNeeded(, withOverlay, styles, overlayColor, overlayOpacity) : value ) ) ); } function CustomThemedGradient(a0) { // fn#61528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:5890, offset: 0x01b4340c, size: 158 bytes, params: 2, frame: 23 let overlayOpacity = a0.overlayOpacity; overlayOpacity = overlayOpacity === undefined ? 0.7 : overlayOpacity; const customTheme = a0.customTheme; let value = Object.create(null); value.overlayOpacity = 0; value.customTheme = 0; value = copyDataProperties({}, a0, value, undefined); const {styles, overlayColor} = useThemedGradientCommon(); return wrapWithOverlayIfNeeded(, value.withOverlay, styles, overlayColor, overlayOpacity); } } function _fun61511(a0) { // fn#61511, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7882:3642, offset: 0x01b42a4d, size: 12 bytes, params: 2, frame: 2 return a0 / 100; } global.__d(_fun61503, 7704, [31, 27, 3964, 33, 4501, 4002, 4001, 4000, 1478, 4589, 4048, 697, 4004, 3963, 674, 1216, 632, 4006, 4047, 3966, 2]) /* metro module 7704, dependencies: [31, 27, 3964, 33, 4501, 4002, 4001, 4000, 1478, 4589, 4048, 697, 4004, 3963, 674, 1216, 632, 4006, 4047, 3966, 2] */;