import { ClipboardList, Receipt, FileSpreadsheet, Wallet, FileText, type LucideIcon } from "lucide-react";

export const REPORT_TYPE_COLORS = [
  "#3B82F6",
  "#10B981",
  "#F59E0B",
  "#8B5CF6",
  "#EC4899",
  "#EF4444",
  "#6366F1",
  "#14B8A6",
  "#F97316",
  "#0EA5E9",
];

export const REPORT_TYPE_BG_CLASSES = [
  "bg-blue-100 text-blue-700",
  "bg-green-100 text-green-700",
  "bg-amber-100 text-amber-700",
  "bg-purple-100 text-purple-700",
  "bg-pink-100 text-pink-700",
  "bg-red-100 text-red-700",
  "bg-indigo-100 text-indigo-700",
  "bg-teal-100 text-teal-700",
  "bg-orange-100 text-orange-700",
  "bg-sky-100 text-sky-700",
];

export function getTypeColorIndex(type: string): number {
  if (!type) return 0;
  let hash = 0;
  for (let i = 0; i < type.length; i++) {
    hash = type.charCodeAt(i) + ((hash << 5) - hash);
  }
  return Math.abs(hash) % REPORT_TYPE_COLORS.length;
}

export function getTypeColor(type: string): string {
  return REPORT_TYPE_COLORS[getTypeColorIndex(type)];
}

export function getTypeBgClass(type: string): string {
  return REPORT_TYPE_BG_CLASSES[getTypeColorIndex(type)];
}

const REPORT_TYPE_LABELS: Record<string, string> = {
  ORDER: "발주서",
  INVOICE: "청구서",
  STATEMENT: "거래명세서",
  RECEIPT: "영수증",
  BASIC: "기본",
};

export function getTypeLabel(type: string): string {
  return REPORT_TYPE_LABELS[type] || type;
}

const REPORT_TYPE_ICONS: Record<string, LucideIcon> = {
  ORDER: ClipboardList,
  INVOICE: Receipt,
  STATEMENT: FileSpreadsheet,
  RECEIPT: Wallet,
  BASIC: FileText,
};

export function getTypeIcon(type: string): LucideIcon {
  return REPORT_TYPE_ICONS[type] || FileText;
}

export const REPORT_TYPE_OPTIONS = [
  { value: "STATEMENT", label: "거래명세서" },
  { value: "BASIC", label: "기본" },
  { value: "ORDER", label: "발주서" },
  { value: "RECEIPT", label: "영수증" },
  { value: "INVOICE", label: "청구서" },
] as const;
