import type { ComponentType } from 'react'
import {
  Confetti,
  Award,
  Globe,
  Spy,
  MoonStars,
  Heart,
  Ghost,
  HomeHeart,
  Clock,
  Trophy,
} from './icons'

/**
 * Mood-first discovery entry points. Each mood maps to a TMDB filter
 * recipe - the user picks a vibe, not a row from a wall of rows. The
 * `extra` filter narrows the result client-side when a TMDB param
 * alone can't express the mood (e.g. "non-English original").
 */

export interface DiscoverMood {
  id: string
  label: string
  blurb: string
  icon: ComponentType<{ size?: number; stroke?: number; className?: string }>
  /** TMDB /discover/movie params */
  movieParams: Record<string, string>
  /** TMDB /discover/tv params - omit for movie-only moods. */
  tvParams?: Record<string, string>
  /** Optional client-side filter applied on top of the TMDB results. */
  extra?: (m: { original_language?: string; vote_average?: number; runtime?: number }) => boolean
}

export const DISCOVER_MOODS: DiscoverMood[] = [
  {
    id: 'quick-laugh',
    label: 'Quick laugh',
    blurb: 'Comedy that doesn\'t overstay',
    icon: Confetti,
    movieParams: {
      with_genres: '35',
      'with_runtime.lte': '100',
      'vote_count.gte': '500',
      sort_by: 'popularity.desc',
    },
    tvParams: {
      with_genres: '35',
      'vote_count.gte': '200',
      sort_by: 'vote_average.desc',
    },
  },
  {
    id: 'cinematic',
    label: 'Cinematic epic',
    blurb: 'Prestige, ambition, scale',
    icon: Award,
    movieParams: {
      'with_runtime.gte': '140',
      'vote_average.gte': '7.5',
      'vote_count.gte': '1000',
      sort_by: 'vote_average.desc',
    },
    tvParams: {
      with_genres: '18',
      'vote_average.gte': '8',
      'vote_count.gte': '500',
      sort_by: 'vote_average.desc',
    },
  },
  {
    id: 'foreign',
    label: 'Foreign cinema',
    blurb: 'Outside the English-speaking world',
    icon: Globe,
    movieParams: {
      'vote_count.gte': '500',
      'vote_average.gte': '7',
      sort_by: 'vote_average.desc',
    },
    tvParams: {
      'vote_count.gte': '200',
      'vote_average.gte': '7.5',
      sort_by: 'vote_average.desc',
    },
    extra: m => !!m.original_language && m.original_language !== 'en',
  },
  {
    id: 'edge-of-seat',
    label: 'Edge of seat',
    blurb: 'Thrillers and tense rides',
    icon: Spy,
    movieParams: {
      with_genres: '53',
      'vote_count.gte': '500',
      sort_by: 'vote_average.desc',
    },
    tvParams: {
      with_genres: '9648,80',
      'vote_count.gte': '200',
      sort_by: 'vote_average.desc',
    },
  },
  {
    id: 'mind-bending',
    label: 'Mind-bending',
    blurb: 'Sci-fi that makes you think',
    icon: MoonStars,
    movieParams: {
      with_genres: '878',
      'vote_count.gte': '500',
      'vote_average.gte': '7',
      sort_by: 'vote_average.desc',
    },
    tvParams: {
      with_genres: '10765',
      'vote_count.gte': '200',
      'vote_average.gte': '7.5',
      sort_by: 'vote_average.desc',
    },
  },
  {
    id: 'feel-good',
    label: 'Feel good',
    blurb: 'Light, warm, easy watching',
    icon: Heart,
    movieParams: {
      with_genres: '10749,35',
      'vote_count.gte': '500',
      sort_by: 'popularity.desc',
    },
    tvParams: {
      with_genres: '35,10751',
      'vote_count.gte': '200',
      sort_by: 'popularity.desc',
    },
  },
  {
    id: 'lights-off',
    label: 'Lights off',
    blurb: 'Horror with a high bar',
    icon: Ghost,
    movieParams: {
      with_genres: '27',
      'vote_count.gte': '500',
      'vote_average.gte': '6.5',
      sort_by: 'vote_average.desc',
    },
    tvParams: {
      with_genres: '9648',
      'vote_count.gte': '200',
      'vote_average.gte': '7',
      sort_by: 'vote_average.desc',
    },
  },
  {
    id: 'family',
    label: 'Family night',
    blurb: 'Everyone in the room',
    icon: HomeHeart,
    movieParams: {
      with_genres: '10751',
      'vote_count.gte': '500',
      sort_by: 'vote_average.desc',
    },
    tvParams: {
      with_genres: '10751,16',
      'vote_count.gte': '200',
      sort_by: 'vote_average.desc',
    },
  },
  {
    id: 'short',
    label: 'One sitting',
    blurb: 'Under 95 minutes, well-rated',
    icon: Clock,
    movieParams: {
      'with_runtime.lte': '95',
      'with_runtime.gte': '70',
      'vote_count.gte': '500',
      'vote_average.gte': '7',
      sort_by: 'vote_average.desc',
    },
    // Intentionally no tvParams - the "one sitting" mood is movie-only.
  },
  {
    id: 'all-time',
    label: 'All-time greats',
    blurb: 'The canon, things you missed',
    icon: Trophy,
    movieParams: {
      'vote_count.gte': '5000',
      'vote_average.gte': '8',
      sort_by: 'vote_average.desc',
    },
    tvParams: {
      'vote_count.gte': '2000',
      'vote_average.gte': '8.3',
      sort_by: 'vote_average.desc',
    },
  },
]
