import { Chip } from '@mui/material'
import { Zap, Clock, AlertCircle } from 'lucide-react'
import type { FreshnessStatus } from '../../domain/enums'
import { DS_COLORS } from '../../lib/ds'
import { FRESHNESS_LABELS } from '../../lib/constants'

interface FreshnessBadgeProps {
  status: FreshnessStatus
  size?: 'small' | 'medium'
}

const ICONS: Record<FreshnessStatus, React.ElementType> = {
  FRESH:    Zap,
  STALE:    Clock,
  OUTDATED: AlertCircle,
}

export function FreshnessBadge({ status, size = 'small' }: FreshnessBadgeProps) {
  const { bg, fg } = DS_COLORS.freshness[status]
  const Icon = ICONS[status]
  return (
    <Chip
      size={size}
      label={FRESHNESS_LABELS[status] ?? status}
      icon={<Icon size={11} color={fg} />}
      aria-label={`Datenaktualität: ${FRESHNESS_LABELS[status] ?? status}`}
      sx={{
        bgcolor: bg,
        color: fg,
        border: 'none',
        fontWeight: 600,
        fontSize: '0.7rem',
        '& .MuiChip-icon': { ml: 0.5 },
      }}
    />
  )
}
