/* ═══════════════════════════════════════════════════════════════ THEME The admin's palette (Panel → Site settings → Colours, table site_setting_colors) over the site's own colour tokens. THEME_DEFAULTS must match @theme and the dark block in src/index.css: the same tokens, the same light and dark values. A blank override keeps the default. themeCss() is written into every page's (pageMeta.js). It goes into the same cascade layers as index.css (theme for light, base for dark), after it, so an override replaces exactly the value it names: a light-only change leaves dark mode alone. checkTheme() runs when Site settings is saved (the descriptor's `check`, inside the save's transaction), and refuses a palette in which any text would fall under WCAG AA (4.5:1) in either mode, so an admin can't make the site unreadable. ═══════════════════════════════════════════════════════════════ */ import { HttpError } from "./admin-crud.js"; // light dark export const THEME_DEFAULTS = { ink: ["#073d4a", "#eaf6f8"], body: ["#26454c", "#cde0e4"], muted: ["#4a6b72", "#9fb9bf"], link: ["#0f7183", "#5ccbdc"], brand: ["#138ba0", "#2aa7bc"], action: ["#0f7183", "#0f7183"], "action-hover": ["#0b5c6a", "#0b5c6a"], surface: ["#ffffff", "#0c1d21"], tint: ["#eef9fb", "#11292e"], "tint-soft": ["#f6fbfc", "#0f2428"], danger: ["#b3261e", "#ff8a80"], "danger-tint": ["#fdf3f2", "#3b1714"], }; export const THEME_TOKENS = Object.keys(THEME_DEFAULTS); const HEX = /^#[0-9a-f]{6}$/i; const MODES = ["light", "dark"]; function overrides(db) { const rows = db .prepare(`SELECT token, light, dark FROM site_setting_colors WHERE settings_id = 'site'`) .all(); // Checked again here, not only by the table's CHECK: this goes // straight into a