61 lines
2.3 KiB
TypeScript
61 lines
2.3 KiB
TypeScript
// Metro module 8077 (f8078).
|
|
import AccessibilityStore from "../../a11y/AccessibilityStore";
|
|
import { useEffectiveThemeOverride } from "./useProfileThemeOverrideStore";
|
|
import { ThemeTypes } from "../../../Constants";
|
|
import useTheme from "../../../hooks/useTheme";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import { unsafe_getResolvedRawColor } from "../../../_bundle/Module711";
|
|
import { useAvatarColors } from "../../avatar/useAvatarColor";
|
|
import { hex2int } from "../../../_bundle/int2hslRaw";
|
|
import { getProfileTheme } from "../UserProfileGradientUtils";
|
|
import { isThemeDark, isThemeLight } from "../../../design/shared";
|
|
export default function useProfileTheme(a0) {
|
|
const { user, displayProfile, pendingThemeColors } = a0;
|
|
let pendingAvatarSrc = a0.pendingAvatarSrc;
|
|
const { isPreview, forceUserTheme } = a0;
|
|
const theme = useTheme();
|
|
const effectiveThemeOverride = useEffectiveThemeOverride();
|
|
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.syncProfileThemeWithUserTheme);
|
|
if (pendingAvatarSrc == null) {
|
|
pendingAvatarSrc = user == null ? void 0 : user.getAvatarURL(displayProfile?.guildId, 80);
|
|
}
|
|
const [r45, r46] = useAvatarColors(pendingAvatarSrc, unsafe_getResolvedRawColor("PRIMARY_530", {
|
|
saturation: 1
|
|
}), false);
|
|
if (effectiveThemeOverride != null) {
|
|
return effectiveThemeOverride;
|
|
}
|
|
if (!displayProfile?.canEditThemes && !isPreview) {
|
|
return {
|
|
theme,
|
|
primaryColor: null,
|
|
secondaryColor: null
|
|
};
|
|
}
|
|
const r51 = displayProfile == null ? void 0 : displayProfile.getPreviewThemeColors(pendingThemeColors);
|
|
let primaryColor = r51 == null ? void 0 : r51[0];
|
|
if (primaryColor == null) {
|
|
primaryColor = hex2int(r45);
|
|
}
|
|
let secondaryColor = r51 == null ? void 0 : r51[1];
|
|
if (secondaryColor == null) {
|
|
secondaryColor = hex2int(r46);
|
|
}
|
|
let r63 = theme;
|
|
if (!stateFromStores) {
|
|
r63 = theme;
|
|
if (!forceUserTheme) {
|
|
let r67 = getProfileTheme(primaryColor);
|
|
if (r67 == null) {
|
|
r67 = theme;
|
|
}
|
|
r63 = r67;
|
|
}
|
|
}
|
|
return {
|
|
theme: r63 === ThemeTypes.DARK ? isThemeDark(theme) ? theme : r63 === ThemeTypes.DARK && isThemeLight(theme) ? ThemeTypes.DARKER : r63 : r63 === ThemeTypes.DARK && isThemeLight(theme) ? ThemeTypes.DARKER : r63,
|
|
primaryColor,
|
|
secondaryColor
|
|
};
|
|
};
|