import { cn } from '@/lib/utils';

/**
 * Color-coded pill for a review's source channel. Values come straight from
 * config/creators.php so the canonical names (Airbnb, Booking.com, etc.) map directly.
 */
const SOURCE_STYLES: Record<string, string> = {
    'Airbnb': 'bg-rose-100 text-rose-700 ring-rose-200',
    'Booking.com': 'bg-blue-100 text-blue-700 ring-blue-200',
    'Expedia': 'bg-yellow-100 text-yellow-800 ring-yellow-200',
    'Vrbo': 'bg-orange-100 text-orange-700 ring-orange-200',
    'Trip.com': 'bg-cyan-100 text-cyan-700 ring-cyan-200',
    'Hometogo': 'bg-emerald-100 text-emerald-700 ring-emerald-200',
    'Plum Guide': 'bg-purple-100 text-purple-700 ring-purple-200',
    'Google Travel': 'bg-sky-100 text-sky-700 ring-sky-200',
    'TUI Villas': 'bg-amber-100 text-amber-700 ring-amber-200',
    'Onefinestay': 'bg-stone-100 text-stone-700 ring-stone-200',
    'Top Villas': 'bg-fuchsia-100 text-fuchsia-700 ring-fuchsia-200',
    'Agoda': 'bg-red-100 text-red-700 ring-red-200',
    'Travelstaytion': 'bg-teal-100 text-teal-700 ring-teal-200',
    'All Luxury Apartments': 'bg-pink-100 text-pink-700 ring-pink-200',
    'Thelandlord.tn': 'bg-slate-100 text-slate-700 ring-slate-200',
    'Questionnaire': 'bg-violet-100 text-violet-700 ring-violet-200',
};

const FALLBACK = 'bg-gray-100 text-gray-600 ring-gray-200';

export function SourceBadge({ source }: { source: string | null }) {
    if (!source) {
        return <span className="text-xs text-gray-400">—</span>;
    }

    const styles = SOURCE_STYLES[source] ?? FALLBACK;

    return (
        <span
            className={cn(
                'inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ring-1 ring-inset',
                styles,
            )}
        >
            {source}
        </span>
    );
}
