/**
 * Default category taxonomy definition.
 * Used for seeding and reference. Actual data lives in the categories table.
 */

export interface TaxonomyNode {
  slug: string;
  name_en: string;
  name_nl: string;
  children?: TaxonomyNode[];
}

export interface TaxonomyDimension {
  dimension: string;
  categories: TaxonomyNode[];
}

export const TAXONOMY: TaxonomyDimension[] = [
  {
    dimension: 'activity',
    categories: [
      {
        slug: 'lifestyle', name_en: 'Lifestyle', name_nl: 'Lifestyle',
        children: [
          { slug: 'lifestyle/casual', name_en: 'Casual', name_nl: 'Casual' },
          { slug: 'lifestyle/streetwear', name_en: 'Fashion / Streetwear', name_nl: 'Fashion / Streetwear' },
        ],
      },
      {
        slug: 'running', name_en: 'Running', name_nl: 'Hardlopen',
        children: [
          { slug: 'running/road', name_en: 'Road Running', name_nl: 'Wegrennen' },
          { slug: 'running/trail', name_en: 'Trail Running', name_nl: 'Trail Running' },
          { slug: 'running/racing', name_en: 'Racing / Competition', name_nl: 'Wedstrijd' },
        ],
      },
      {
        slug: 'basketball', name_en: 'Basketball', name_nl: 'Basketbal',
        children: [
          { slug: 'basketball/performance', name_en: 'Performance', name_nl: 'Performance' },
          { slug: 'basketball/lifestyle', name_en: 'Lifestyle / Off-court', name_nl: 'Lifestyle / Off-court' },
        ],
      },
      {
        slug: 'skateboarding', name_en: 'Skateboarding', name_nl: 'Skateboarden',
        children: [
          { slug: 'skateboarding/low', name_en: 'Low-top', name_nl: 'Low-top' },
          { slug: 'skateboarding/high', name_en: 'High-top', name_nl: 'High-top' },
        ],
      },
      {
        slug: 'training', name_en: 'Training & Gym', name_nl: 'Training & Gym',
        children: [
          { slug: 'training/cross', name_en: 'Cross-training', name_nl: 'Cross-training' },
          { slug: 'training/weightlifting', name_en: 'Weightlifting', name_nl: 'Gewichtheffen' },
        ],
      },
      {
        slug: 'football', name_en: 'Football / Soccer', name_nl: 'Voetbal',
        children: [
          { slug: 'football/indoor', name_en: 'Indoor', name_nl: 'Indoor' },
          { slug: 'football/turf', name_en: 'Turf / Street', name_nl: 'Turf / Straat' },
        ],
      },
      { slug: 'tennis', name_en: 'Tennis / Padel', name_nl: 'Tennis / Padel' },
      {
        slug: 'walking', name_en: 'Walking / Outdoor', name_nl: 'Wandelen / Outdoor',
        children: [
          { slug: 'walking/hiking', name_en: 'Hiking', name_nl: 'Wandelen' },
          { slug: 'walking/sandals', name_en: 'Sandals', name_nl: 'Sandalen' },
        ],
      },
    ],
  },
  {
    dimension: 'style',
    categories: [
      {
        slug: 'retro', name_en: 'Retro / Heritage', name_nl: 'Retro / Heritage',
        children: [
          { slug: 'retro/70s-80s', name_en: '70s & 80s Classics', name_nl: '70s & 80s Classics' },
          { slug: 'retro/90s', name_en: '90s Retro', name_nl: '90s Retro' },
          { slug: 'retro/2000s', name_en: '2000s Retro', name_nl: '2000s Retro' },
        ],
      },
      {
        slug: 'limited', name_en: 'Limited / Collab', name_nl: 'Limited / Collab',
        children: [
          { slug: 'limited/designer', name_en: 'Designer Collabs', name_nl: 'Designer Collabs' },
          { slug: 'limited/artist', name_en: 'Artist Collabs', name_nl: 'Artist Collabs' },
          { slug: 'limited/editions', name_en: 'Limited Editions', name_nl: 'Limited Editions' },
        ],
      },
      { slug: 'high-top', name_en: 'High-top', name_nl: 'High-top' },
      { slug: 'low-top', name_en: 'Low-top', name_nl: 'Low-top' },
      { slug: 'mid-top', name_en: 'Mid-top', name_nl: 'Mid-top' },
      { slug: 'platform', name_en: 'Platform / Chunky', name_nl: 'Platform / Chunky' },
    ],
  },
  {
    dimension: 'gender',
    categories: [
      { slug: 'men', name_en: 'Men', name_nl: 'Heren' },
      { slug: 'women', name_en: 'Women', name_nl: 'Dames' },
      { slug: 'unisex', name_en: 'Unisex', name_nl: 'Unisex' },
      {
        slug: 'kids', name_en: 'Kids', name_nl: 'Kinderen',
        children: [
          { slug: 'kids/boys', name_en: 'Boys', name_nl: 'Jongens' },
          { slug: 'kids/girls', name_en: 'Girls', name_nl: 'Meisjes' },
          { slug: 'kids/toddler', name_en: 'Toddler', name_nl: 'Peuter' },
          { slug: 'kids/infant', name_en: 'Infant', name_nl: 'Baby' },
        ],
      },
    ],
  },
];

/** Model family patterns: brand → [{ pattern, categorySlug, activity? }] */
export const MODEL_FAMILY_PATTERNS: Record<string, Array<{
  patterns: RegExp[];
  slug: string;
  activity?: string;
  tags?: string[];
}>> = {
  nike: [
    { patterns: [/air\s*max/i], slug: 'nike/air-max', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/air\s*force\s*1/i, /\baf1\b/i], slug: 'nike/air-force-1', activity: 'lifestyle' },
    { patterns: [/\bdunk\b/i], slug: 'nike/dunk', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/air\s*jordan/i, /\baj\d/i, /\bjordan\s*\d/i], slug: 'nike/air-jordan', activity: 'basketball/lifestyle' },
    { patterns: [/\bblazer\b/i], slug: 'nike/blazer', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/\bcortez\b/i], slug: 'nike/cortez', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/\bpegasus\b/i, /\bvomero\b/i], slug: 'nike/pegasus', activity: 'running' },
  ],
  adidas: [
    { patterns: [/\bsuperstar\b/i], slug: 'adidas/superstar', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/\bstan\s*smith\b/i], slug: 'adidas/stan-smith', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/\bforum\b/i], slug: 'adidas/forum', activity: 'lifestyle' },
    { patterns: [/\b(gazelle|samba|spezial)\b/i], slug: 'adidas/samba', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/ultra\s*boost/i], slug: 'adidas/ultraboost', activity: 'running' },
    { patterns: [/\bnmd\b/i], slug: 'adidas/nmd', activity: 'lifestyle' },
    { patterns: [/\byeezy\b/i], slug: 'adidas/yeezy', activity: 'lifestyle' },
    { patterns: [/\bcampus\b/i], slug: 'adidas/campus', activity: 'lifestyle', tags: ['retro'] },
  ],
  'new balance': [
    { patterns: [/\b550\b/], slug: 'new-balance/550', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/\b574\b/], slug: 'new-balance/574', activity: 'lifestyle' },
    { patterns: [/\b99[0-3]\b/], slug: 'new-balance/990', activity: 'lifestyle' },
    { patterns: [/\b2002r?\b/i], slug: 'new-balance/2002r', activity: 'lifestyle' },
    { patterns: [/\b1906r?\b/i], slug: 'new-balance/1906r', activity: 'lifestyle' },
  ],
  puma: [
    { patterns: [/\bsuede\b/i], slug: 'puma/suede', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/\brs-?x\b/i], slug: 'puma/rs-x', activity: 'lifestyle' },
  ],
  converse: [
    { patterns: [/chuck\s*(taylor|70|all\s*star)/i, /\ball\s*star\b/i], slug: 'converse/chuck-taylor', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/\bone\s*star\b/i], slug: 'converse/one-star', activity: 'lifestyle' },
  ],
  vans: [
    { patterns: [/old\s*skool/i], slug: 'vans/old-skool', activity: 'skateboarding' },
    { patterns: [/sk8[\s-]*hi/i], slug: 'vans/sk8-hi', activity: 'skateboarding' },
    { patterns: [/\b(authentic|era)\b/i], slug: 'vans/authentic', activity: 'skateboarding' },
  ],
  asics: [
    { patterns: [/gel[\s-]*lyte/i], slug: 'asics/gel-lyte', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/gel[\s-]*kayano/i], slug: 'asics/gel-kayano', activity: 'running' },
    { patterns: [/gel[\s-]*(1130|nyc)/i], slug: 'asics/gel-1130', activity: 'lifestyle' },
  ],
  reebok: [
    { patterns: [/classic\s*leather/i], slug: 'reebok/classic-leather', activity: 'lifestyle', tags: ['retro'] },
    { patterns: [/club\s*c/i], slug: 'reebok/club-c', activity: 'lifestyle', tags: ['retro'] },
  ],
  'on running': [
    { patterns: [/cloud\s*5/i], slug: 'on-running/cloud-5', activity: 'running' },
    { patterns: [/cloudmonster/i], slug: 'on-running/cloudmonster', activity: 'running' },
    { patterns: [/cloudnova/i], slug: 'on-running/cloudnova', activity: 'lifestyle' },
  ],
  salomon: [
    { patterns: [/\bxt[\s-]*6\b/i], slug: 'salomon/xt-6', activity: 'walking' },
    { patterns: [/speedcross/i], slug: 'salomon/speedcross', activity: 'running/trail' },
    { patterns: [/acs\s*pro/i], slug: 'salomon/acs-pro', activity: 'walking' },
  ],
};

/** Gender detection keywords */
export const GENDER_PATTERNS: Array<{ patterns: RegExp[]; gender: string }> = [
  { patterns: [/\bwmns\b/i, /\bwomen'?s?\b/i, /\bdames\b/i, /\bw's\b/i], gender: 'women' },
  { patterns: [/\bmen'?s?\b/i, /\bheren\b/i], gender: 'men' },
  { patterns: [/\b(gs|grade\s*school)\b/i, /\bkids?\b/i, /\bjunior\b/i, /\bkinderen\b/i], gender: 'kids' },
  { patterns: [/\btoddler\b/i, /\btd\b/i, /\bpeuter\b/i], gender: 'kids/toddler' },
  { patterns: [/\b(ps|preschool)\b/i], gender: 'kids' },
  { patterns: [/\binfant\b/i, /\bbaby\b/i], gender: 'kids/infant' },
];

/** Activity detection keywords (fallback when model family doesn't set it) */
export const ACTIVITY_PATTERNS: Array<{ patterns: RegExp[]; slug: string }> = [
  { patterns: [/\brunning\b/i, /\bhardloop/i, /\brunner\b/i, /\brun\b/i], slug: 'running' },
  { patterns: [/\bbasketbal/i, /\bhoops?\b/i], slug: 'basketball' },
  { patterns: [/\bskate\b/i, /\bsb\b/i], slug: 'skateboarding' },
  { patterns: [/\btraining\b/i, /\bgym\b/i, /\bcross[\s-]?fit/i], slug: 'training' },
  { patterns: [/\bfootball\b/i, /\bvoetbal/i, /\bsoccer\b/i], slug: 'football' },
  { patterns: [/\btennis\b/i, /\bpadel\b/i], slug: 'tennis' },
  { patterns: [/\bhiking?\b/i, /\btrail\b/i, /\boutdoor\b/i, /\bwandel/i], slug: 'walking' },
];
