import { join, resolve } from "node:path";

// The dashboard's files the plugin's brand assets are made from, and nothing
// else: export-source.ts imports this module under Node alone, so it may not
// reach for Vite, PostCSS or an extensionless import.

const PUBLIC = resolve(import.meta.dirname, "../../apps/dashboard/public");
export const FONTS_DIR = join(PUBLIC, "fonts");
export const LOGO_FILE = join(PUBLIC, "img/logo.svg");
export const FALLBACK_STYLESHEET = resolve(
  import.meta.dirname,
  "src/wp/fallback.css",
);

/**
 * The family names the bundle declares. Its own, not the typefaces' bare
 * names: `@font-face` is global, and another plugin's "IBM Plex Sans" with
 * other weights or another subset must not answer for ours, nor ours for its.
 * `src/wp/fonts.css` points the theme's two font variables at them.
 */
export const FONT_FAMILIES = {
  heading: "AccessiBit Plus Jakarta Sans",
  sans: "AccessiBit IBM Plex Sans",
} as const;

/**
 * The files and weights the dashboard loads (`app/fonts.ts`): the latin
 * subset, which covers the three languages the plugin speaks.
 */
export const FONT_FACES: {
  family: string;
  weight: number;
  file: string;
}[] = [
  ...[600, 700, 800].map((weight) => ({
    family: FONT_FAMILIES.heading,
    weight,
    file: `plus-jakarta-sans-latin-${weight}-normal.woff2`,
  })),
  ...[400, 500, 600, 700].map((weight) => ({
    family: FONT_FAMILIES.sans,
    weight,
    file: `ibm-plex-sans-latin-${weight}-normal.woff2`,
  })),
];

/** The licences that travel with the fonts, for THIRD-PARTY-NOTICES.txt. */
export const FONT_LICENCES = [
  { name: "Plus Jakarta Sans", file: "plus-jakarta-sans-OFL.txt" },
  { name: "IBM Plex Sans", file: "ibm-plex-sans-OFL.txt" },
];

/** Every file of the dashboard's this module reads, for the source export. */
export const BRAND_SOURCES = [
  ...FONT_FACES.map((face) => join(FONTS_DIR, face.file)),
  ...FONT_LICENCES.map((licence) => join(FONTS_DIR, licence.file)),
  LOGO_FILE,
];
