import { Badge } from "@/components/ui/badge";
import { Brain, User, Zap } from "lucide-react";

import type { DecisionLevel, DecisionSource, ExecutionMode } from "./types";

interface DecisionLevelBadgeProps {
  level: DecisionLevel;
}

export function DecisionLevelBadge({ level }: DecisionLevelBadgeProps) {
  const config: Record<DecisionLevel, { label: string; className: string }> = {
    critical: {
      label: "紧急",
      className: "bg-error-muted text-error-muted-foreground border-error",
    },
    important: {
      label: "重要",
      className: "bg-warning-muted text-warning-muted-foreground border-warning",
    },
    normal: {
      label: "一般",
      className: "bg-info-muted text-info-muted-foreground border-info",
    },
    suggestion: {
      label: "建议",
      className: "bg-success-muted text-success-muted-foreground border-success",
    },
  };

  const { label, className } = config[level];

  return (
    <Badge variant="outline" className={className}>
      {label}
    </Badge>
  );
}

interface DecisionSourceBadgeProps {
  source: DecisionSource;
}

export function DecisionSourceBadge({ source }: DecisionSourceBadgeProps) {
  const config: Record<DecisionSource, { label: string; className: string; icon: typeof Brain | typeof User }> = {
    auto: {
      label: "自动生成",
      className: "bg-accent text-accent-foreground border-accent",
      icon: Brain,
    },
    manual: {
      label: "手动添加",
      className: "bg-info-muted text-info-muted-foreground border-info",
      icon: User,
    },
  };

  const { label, className, icon: Icon } = config[source];

  return (
    <Badge variant="outline" className={className}>
      <Icon className="w-3 h-3 mr-1" />
      {label}
    </Badge>
  );
}

interface ExecutionModeBadgeProps {
  mode: ExecutionMode;
}

export function ExecutionModeBadge({ mode }: ExecutionModeBadgeProps) {
  const config: Record<ExecutionMode, { label: string; className: string; icon: typeof Zap | typeof User }> = {
    manual: {
      label: "手动执行",
      className: "bg-info-muted text-info-muted-foreground border-info",
      icon: User,
    },
    auto: {
      label: "自动执行",
      className: "bg-success-muted text-success-muted-foreground border-success",
      icon: Zap,
    },
  };

  const { label, className, icon: Icon } = config[mode];

  return (
    <Badge variant="outline" className={className}>
      <Icon className="w-3 h-3 mr-1" />
      {label}
    </Badge>
  );
}
