import { useState } from 'react'
import { ExternalLink, Globe } from '../../lib/icons'
import Select, { type SelectOption } from '../ui/Select'
import { motion } from 'framer-motion'
import type { TmdbWatchProviders } from '../../api/tmdb'
import { getTmdbImageUrl } from '../../api/tmdb'
import { countryLabel } from '../../lib/format'
import { SectionLabel } from '../ui/SectionLabel'
interface Props {
providers?: TmdbWatchProviders | null
defaultRegion: string
onRegionChange?: (region: string) => void
}
const COMMON_REGIONS = ['US', 'GB', 'CA', 'AU', 'DE', 'FR', 'ES', 'IT', 'NL', 'JP', 'BR', 'IN', 'MX']
export default function WhereToWatch({ providers, defaultRegion, onRegionChange }: Props) {
const [region, setRegion] = useState(defaultRegion)
const all = providers?.results || {}
const regionData = all[region]
const availableRegions = Object.keys(all).sort()
if (!regionData && !availableRegions.length) return null
function changeRegion(next: string) {
setRegion(next)
onRegionChange?.(next)
}
return (
Not available for streaming in {countryLabel(region) || region}.