import type { InstalledTheme } from './plugin-types'; /** * Resolve which logo to show. * * Precedence: * 1. An admin-configured global logo (Branding tab / APP_LOGO_*_URL / * LOGIN_LOGO_*_URL) - set `hasGlobalOverride` when the caller's config * source for that field is 'admin' or 'env', not 'default'. This is * what makes the Branding tab's existing logo fields actually take * effect for customers who want their own mark regardless of theme. * 2. The active theme's own brand logo (logoLightUrl/logoDarkUrl) - so * switching theme still switches the whole brand (VNClagoon wordmark * vs SRC mark) for anyone who HASN'T set an explicit override. * 3. The fallback value itself (theme has no logo and nothing was * configured). * * Returns a raw path; the caller applies withBasePath(). */ export function resolveThemeLogo( themes: InstalledTheme[], activeThemeId: string | null, isDark: boolean, fallbackLight: string, fallbackDark: string, hasGlobalOverride = false, ): string { const fallback = isDark ? (fallbackDark || fallbackLight) : (fallbackLight || fallbackDark); if (hasGlobalOverride && fallback) return fallback; const theme = activeThemeId ? themes.find((t) => t.id === activeThemeId) : undefined; if (theme) { const themed = isDark ? (theme.logoDarkUrl ?? theme.logoLightUrl) : (theme.logoLightUrl ?? theme.logoDarkUrl); if (themed) return themed; } return fallback; }