import photosData from "@/data/photos.json";

export type Photo = {
  category: string;
  filename: string;
  path: string;
  alt: string;
  credit: string;
  source: string;
  license: string;
};

export const photos = photosData as Photo[];

export function firstPhoto(category: string): Photo | undefined {
  return photos.find((p) => p.category === category);
}

// Per-product audience-card avatar categories — the 3 photo categories used
// for the three "Who it's for" audience tiles.
const productAudienceCategories: Record<string, [string, string, string]> = {
  atlas: ["global-health", "training", "anatomy"],
  consentiq: ["consent", "surgery", "training"],
  orthoprep: ["exam-prep", "training", "classroom"],
  academy: ["classroom", "surgery", "rehab"],
};

/**
 * Return 3 avatar photos for a given product's audience cards, picking a
 * different photo from each target category when possible.
 */
export function audienceAvatarsForProduct(slug: string): (Photo | undefined)[] {
  const cats = productAudienceCategories[slug];
  if (!cats) return [undefined, undefined, undefined];
  return cats.map((c) => firstPhoto(c));
}

// Showcase-band photo + human-written caption per product.
const productShowcase: Record<
  string,
  { category: string; eyebrow: string; caption: string }
> = {
  atlas: {
    category: "global-health",
    eyebrow: "Capacity, country by country",
    caption: "From Nairobi to Mogadishu to Kabul — the data behind where orthopaedic care exists, and where it doesn't.",
  },
  consentiq: {
    category: "consent",
    eyebrow: "Plain-language, clinician-reviewed",
    caption: "Consent that starts a conversation — not a form patients sign in a hurry.",
  },
  orthoprep: {
    category: "exam-prep",
    eyebrow: "Board-calibrated questions",
    caption: "Surgeon-written SBA items, tuned to how FRCS and EBOT examiners actually ask.",
  },
  academy: {
    category: "classroom",
    eyebrow: "Structured, surgeon-taught",
    caption: "Short-form, case-based courses built for the way orthopaedic trainees actually learn.",
  },
};

export function showcaseForProduct(slug: string) {
  const cfg = productShowcase[slug];
  if (!cfg) return undefined;
  const photo = firstPhoto(cfg.category);
  if (!photo) return undefined;
  return { photo, eyebrow: cfg.eyebrow, caption: cfg.caption };
}
