import type { TemplateId } from "./types";

export type TemplateMeta = {
  id: TemplateId;
  nom: string;
  description: string;
  accent: string;
};

export const TEMPLATES: TemplateMeta[] = [
  {
    id: "classique",
    nom: "Classique",
    description: "En-tête marine, proche du gabarit Excel d’origine.",
    accent: "#1f3864",
  },
  {
    id: "moderne",
    nom: "Moderne",
    description: "Mise en page aérée, bandeau latéral anthracite.",
    accent: "#334155",
  },
  {
    id: "vert",
    nom: "Vert pro",
    description: "Ton forêt, adapté aux TPE / artisanat.",
    accent: "#1b5e3b",
  },
  {
    id: "compact",
    nom: "Compact",
    description: "Dense et lisible, idéal pour de nombreuses lignes.",
    accent: "#3f3f46",
  },
  {
    id: "luxe",
    nom: "Luxe",
    description: "Graphite et or doux, typographie soignée.",
    accent: "#b0892e",
  },
  {
    id: "azur",
    nom: "Azur",
    description: "Bleu clair élégant, grands espaces et fines filets.",
    accent: "#0e7490",
  },
  {
    id: "signature",
    nom: "Signature",
    description: "Noir encre, hiérarchie typographique éditoriale.",
    accent: "#111111",
  },
  {
    id: "bordeaux",
    nom: "Bordeaux",
    description: "Bordeaux profond, allure cabinet / profession libérale.",
    accent: "#7f1d1d",
  },
];

export const DEFAULT_TEMPLATE: TemplateId = "classique";

const IDS = new Set(TEMPLATES.map((t) => t.id));

export function isTemplateId(v: unknown): v is TemplateId {
  return typeof v === "string" && IDS.has(v as TemplateId);
}

export function resolveTemplate(id?: TemplateId | null): TemplateId {
  return isTemplateId(id) ? id : DEFAULT_TEMPLATE;
}
