/**
 * ═══════════════════════════════════════════════════════════════════
 *  SITE IMAGE CATALOG
 * ═══════════════════════════════════════════════════════════════════
 *
 *  ALL image files live in ONE folder on disk:
 *
 *    public/images/site/
 *
 *  To change an image: replace the file in that folder (same filename).
 *  You do NOT need to edit this file unless you add a NEW product or page.
 *
 *  Filename guide — see public/images/site/README.txt
 */

import type { Category } from '@/domain/entities';

/** Single folder — every website image file is here */
export const IMAGE_FOLDER = '/images/site';

/** Bump when site images are re-processed (cache bust) */
export const SITE_IMAGE_VERSION = '11';

/** Build path to a file in the site image folder */
export function siteImage(filename: string): string {
  return `${IMAGE_FOLDER}/${filename}?v=${SITE_IMAGE_VERSION}`;
}

export type ProductImageId =
  | 'chicken-whole'
  | 'chicken-breast'
  | 'chicken-thighs'
  | 'chicken-wings'
  | 'beef-nihari'
  | 'beef-steak'
  | 'beef-mince'
  | 'beef-boneless'
  | 'lamb-shoulder'
  | 'lamb-leg'
  | 'lamb-chops'
  | 'lamb-mince'
  | 'fish-salmon'
  | 'fish-rohu'
  | 'fish-prawns'
  | 'fish-basa';

export type OfferImageId =
  | 'chicken-wings-pl'
  | 'lamb-steak-ireland'
  | 'beef-mince-irl';

type ImageRef =
  | { type: 'product'; id: ProductImageId }
  | { type: 'category'; id: Category };

interface ProductImageEntry {
  main: string;
  gallery?: string[];
}

function product(id: ProductImageId, second?: string): ProductImageEntry {
  const main = siteImage(`${id}.jpg`);
  if (second) {
    return { main, gallery: [main, siteImage(second)] };
  }
  return { main };
}

/** ─── Brand ─── */
export const BRAND_IMAGES = {
  logo: siteImage('logo.jpeg'),
} as const;

/** ─── Page backgrounds ─── */
export const PAGE_IMAGES = {
  hero: siteImage('hero.jpg'),
  aboutMeat: siteImage('about.jpg'),
  weeklyOffersBanner: siteImage('weekly-offers.jpg'),
} as const;

/** ─── Category tiles ─── */
export const CATEGORY_IMAGES: Record<Category, string> = {
  chicken: siteImage('category-chicken.jpg'),
  beef: siteImage('category-beef.jpg'),
  lamb: siteImage('category-lamb.jpg'),
  fish: siteImage('category-fish.jpg'),
};

/** ─── Product photos (filename = product id) ─── */
export const PRODUCT_IMAGES: Record<ProductImageId, ProductImageEntry> = {
  'chicken-whole': product('chicken-whole', 'chicken-whole-2.jpg'),
  'chicken-breast': product('chicken-breast', 'chicken-breast-2.jpg'),
  'chicken-thighs': product('chicken-thighs'),
  'chicken-wings': product('chicken-wings'),
  'beef-nihari': product('beef-nihari', 'beef-nihari-2.jpg'),
  'beef-steak': product('beef-steak', 'beef-steak-2.jpg'),
  'beef-mince': product('beef-mince'),
  'beef-boneless': product('beef-boneless'),
  'lamb-shoulder': product('lamb-shoulder', 'lamb-shoulder-2.jpg'),
  'lamb-leg': product('lamb-leg'),
  'lamb-chops': product('lamb-chops'),
  'lamb-mince': product('lamb-mince'),
  'fish-salmon': product('fish-salmon', 'fish-salmon-2.jpg'),
  'fish-rohu': product('fish-rohu'),
  'fish-prawns': product('fish-prawns'),
  'fish-basa': product('fish-basa'),
};

/** ─── Weekly offers (reuse product/category images) ─── */
export const OFFER_IMAGE_REFS: Record<OfferImageId, ImageRef> = {
  'chicken-wings-pl': { type: 'product', id: 'chicken-wings' },
  'lamb-steak-ireland': { type: 'category', id: 'lamb' },
  'beef-mince-irl': { type: 'product', id: 'beef-mince' },
};

export const IMAGE_QUALITY = 90;