/**
 * Badge preset factory functions
 * @countermeasure/web-components/display/badge
 */

import { Badge } from './index'
import { type BadgeConfig, type BadgeSeverity, type BadgeStatus } from './types'

/** Labels for severity levels */
const SEVERITY_LABELS: Record<BadgeSeverity, string> = {
  critical: 'Critical',
  high: 'High',
  medium: 'Medium',
  low: 'Low',
  info: 'Info',
}

/** Labels for status values */
const STATUS_LABELS: Record<BadgeStatus, string> = {
  active: 'Active',
  inactive: 'Inactive',
  pending: 'Pending',
  error: 'Error',
}

/** Create a severity badge with appropriate styling */
export function severityBadge(severity: BadgeSeverity, config?: Partial<BadgeConfig>): Badge {
  const mergedConfig: BadgeConfig = {
    label: SEVERITY_LABELS[severity],
    severity,
    dot: true,
    ...config,
  }
  return new Badge(mergedConfig)
}

/** Create a status badge with appropriate styling */
export function statusBadge(status: BadgeStatus, config?: Partial<BadgeConfig>): Badge {
  const mergedConfig: BadgeConfig = {
    label: STATUS_LABELS[status],
    status,
    dot: true,
    ...config,
  }
  return new Badge(mergedConfig)
}
