export type ColorEnumBGOY =
  | 'primary'
  | 'red'
  | 'green'
  | 'blue'
  | 'pink'
  | 'yellow'
  | 'orange'
  | 'purple'
  | 'deeppurple'
  | 'lightblue'
  | 'teal'
  | 'lime'
  | 'deeporange';

const colorMap: Record<ColorEnumBGOY, string> = {
  primary: '#3390ec',
  red: '#e53935',
  green: '#43a047',
  blue: '#1e88e5',
  pink: '#ec407a',
  yellow: '#fbc02d',
  orange: '#fb8c00',
  purple: '#8e24aa',
  deeppurple: '#5e35b1',
  lightblue: '#039be5',
  teal: '#00897b',
  lime: '#7cb342',
  deeporange: '#f4511e',
};

/**
 * Applies a color theme to the whole UI for every presentation (`?style=telegram|whatsapp|instagram`).
 * Sets `--tg-theme-color` on `document.documentElement`; palettes derive accents via `var(--tg-theme-color)` / `var(--tg-accent)` in `src/index.css`.
 *
 * Pass any color name from {@link ColorEnumBGOY}, e.g. 'red', 'green', 'teal'.
 * Use 'primary' (default) to restore the Telegram blue.
 */
export const setColorTheme = (color: ColorEnumBGOY) => {
  const hex = colorMap[color] ?? colorMap.primary;
  document.documentElement.style.setProperty('--tg-theme-color', hex);
};

export const getThemeColorHex = (color: ColorEnumBGOY): string =>
  colorMap[color] ?? colorMap.primary;
