// Colour theme preference. "system" (the default) follows the OS setting via
// `prefers-color-scheme`; "light"/"dark" force one. Stored in a cookie so the
// server renders the right `data-theme` on <html> and there is no flash.

export const THEME_COOKIE = "bts_theme";
export const THEME_PREFERENCES = ["system", "light", "dark"] as const;
export type ThemePreference = (typeof THEME_PREFERENCES)[number];

export const THEME_LABELS: Record<ThemePreference, string> = {
  system: "System",
  light: "Light",
  dark: "Dark",
};

export function parseThemePreference(value: string | undefined | null): ThemePreference {
  return value === "light" || value === "dark" ? value : "system";
}
