"use client";

import {
  // Alimentation
  ShoppingCart,
  Utensils,
  Croissant,
  Coffee,
  Wine,
  Beer,
  Pizza,
  Apple,
  Cherry,
  Salad,
  Sandwich,
  IceCream,
  Cake,
  CupSoda,
  Milk,
  Egg,
  Fish,
  Beef,
  // Transport
  Fuel,
  Train,
  Car,
  SquareParking,
  Bike,
  Plane,
  Bus,
  Ship,
  Sailboat,
  Truck,
  CarFront,
  CircleParking,
  TrainFront,
  // Logement
  Home,
  Zap,
  Droplet,
  Hammer,
  Sofa,
  Refrigerator,
  WashingMachine,
  Lamp,
  LampDesk,
  Armchair,
  Bath,
  ShowerHead,
  DoorOpen,
  Fence,
  Trees,
  Flower,
  Leaf,
  Sun,
  Snowflake,
  Wind,
  Thermometer,
  // Santé
  Pill,
  Stethoscope,
  Hospital,
  Glasses,
  Dumbbell,
  Sparkles,
  Heart,
  HeartPulse,
  Activity,
  Syringe,
  Bandage,
  Brain,
  Eye,
  Ear,
  Hand,
  Footprints,
  PersonStanding,
  // Loisirs
  Tv,
  Music,
  Film,
  Gamepad,
  Book,
  Ticket,
  Clapperboard,
  Headphones,
  Speaker,
  Radio,
  Camera,
  Image,
  Palette,
  Brush,
  PenTool,
  Scissors,
  Drama,
  PartyPopper,
  // Sport
  Trophy,
  Medal,
  Target,
  Volleyball,
  // Shopping
  Shirt,
  Smartphone,
  Package,
  ShoppingBag,
  Store,
  Gem,
  Watch,
  Glasses as SunGlasses,
  Crown,
  Laptop,
  Monitor,
  Keyboard,
  Mouse,
  Printer,
  TabletSmartphone,
  Headset,
  // Services
  Wifi,
  Repeat,
  Landmark,
  Shield,
  Receipt,
  FileText,
  Mail,
  Phone,
  MessageSquare,
  Send,
  Globe,
  Cloud,
  Server,
  Lock,
  Unlock,
  Settings,
  // Finance
  PiggyBank,
  Banknote,
  Wallet,
  HandCoins,
  Undo,
  Coins,
  CreditCard,
  Building,
  Building2,
  TrendingUp,
  TrendingDown,
  BarChart,
  PieChart,
  LineChart,
  Calculator,
  Percent,
  DollarSign,
  Euro,
  // Voyage
  Bed,
  Luggage,
  Map,
  MapPin,
  Compass,
  Mountain,
  Tent,
  Palmtree,
  Umbrella,
  Globe2,
  Flag,
  // Famille
  GraduationCap,
  Baby,
  PawPrint,
  Users,
  User,
  UserPlus,
  Dog,
  Cat,
  Bird,
  Rabbit,
  // Autre
  Wrench,
  HeartHandshake,
  Gift,
  Cigarette,
  ArrowRightLeft,
  HelpCircle,
  Tag,
  Folder,
  Key,
  Star,
  Bookmark,
  Clock,
  Calendar,
  Bell,
  AlertTriangle,
  Info,
  CheckCircle,
  XCircle,
  Plus,
  Minus,
  Search,
  Trash,
  Edit,
  Download,
  Upload,
  Share,
  Link,
  Paperclip,
  Archive,
  Box,
  Boxes,
  Container,
  Briefcase,
  GraduationCap as Education,
  Award,
  Lightbulb,
  Flame,
  Rocket,
  Atom,
  type LucideIcon,
} from "lucide-react";

// Map icon names to Lucide components
const iconMap: Record<string, LucideIcon> = {
  // Alimentation
  "shopping-cart": ShoppingCart,
  utensils: Utensils,
  croissant: Croissant,
  coffee: Coffee,
  wine: Wine,
  beer: Beer,
  pizza: Pizza,
  apple: Apple,
  cherry: Cherry,
  salad: Salad,
  sandwich: Sandwich,
  "ice-cream": IceCream,
  cake: Cake,
  "cup-soda": CupSoda,
  milk: Milk,
  egg: Egg,
  fish: Fish,
  beef: Beef,
  // Transport
  fuel: Fuel,
  train: Train,
  car: Car,
  parking: SquareParking,
  bike: Bike,
  plane: Plane,
  bus: Bus,
  ship: Ship,
  sailboat: Sailboat,
  truck: Truck,
  "car-front": CarFront,
  "circle-parking": CircleParking,
  "train-front": TrainFront,
  // Logement
  home: Home,
  zap: Zap,
  droplet: Droplet,
  hammer: Hammer,
  sofa: Sofa,
  refrigerator: Refrigerator,
  "washing-machine": WashingMachine,
  lamp: Lamp,
  "lamp-desk": LampDesk,
  armchair: Armchair,
  bath: Bath,
  "shower-head": ShowerHead,
  "door-open": DoorOpen,
  fence: Fence,
  trees: Trees,
  flower: Flower,
  leaf: Leaf,
  sun: Sun,
  snowflake: Snowflake,
  wind: Wind,
  thermometer: Thermometer,
  // Santé
  pill: Pill,
  stethoscope: Stethoscope,
  hospital: Hospital,
  glasses: Glasses,
  dumbbell: Dumbbell,
  sparkles: Sparkles,
  heart: Heart,
  "heart-pulse": HeartPulse,
  activity: Activity,
  syringe: Syringe,
  bandage: Bandage,
  brain: Brain,
  eye: Eye,
  ear: Ear,
  hand: Hand,
  footprints: Footprints,
  "person-standing": PersonStanding,
  // Loisirs
  tv: Tv,
  music: Music,
  film: Film,
  gamepad: Gamepad,
  book: Book,
  ticket: Ticket,
  clapperboard: Clapperboard,
  headphones: Headphones,
  speaker: Speaker,
  radio: Radio,
  camera: Camera,
  image: Image,
  palette: Palette,
  brush: Brush,
  "pen-tool": PenTool,
  scissors: Scissors,
  drama: Drama,
  "party-popper": PartyPopper,
  // Sport
  trophy: Trophy,
  medal: Medal,
  target: Target,
  volleyball: Volleyball,
  // Shopping
  shirt: Shirt,
  smartphone: Smartphone,
  package: Package,
  "shopping-bag": ShoppingBag,
  store: Store,
  gem: Gem,
  watch: Watch,
  sunglasses: SunGlasses,
  crown: Crown,
  laptop: Laptop,
  monitor: Monitor,
  keyboard: Keyboard,
  mouse: Mouse,
  printer: Printer,
  "tablet-smartphone": TabletSmartphone,
  headset: Headset,
  // Services
  wifi: Wifi,
  repeat: Repeat,
  landmark: Landmark,
  shield: Shield,
  receipt: Receipt,
  "file-text": FileText,
  mail: Mail,
  phone: Phone,
  "message-square": MessageSquare,
  send: Send,
  globe: Globe,
  cloud: Cloud,
  server: Server,
  lock: Lock,
  unlock: Unlock,
  settings: Settings,
  // Finance
  "piggy-bank": PiggyBank,
  banknote: Banknote,
  wallet: Wallet,
  "hand-coins": HandCoins,
  undo: Undo,
  coins: Coins,
  "credit-card": CreditCard,
  building: Building,
  building2: Building2,
  "trending-up": TrendingUp,
  "trending-down": TrendingDown,
  "bar-chart": BarChart,
  "pie-chart": PieChart,
  "line-chart": LineChart,
  calculator: Calculator,
  percent: Percent,
  "dollar-sign": DollarSign,
  euro: Euro,
  // Voyage
  bed: Bed,
  luggage: Luggage,
  map: Map,
  "map-pin": MapPin,
  compass: Compass,
  mountain: Mountain,
  tent: Tent,
  palmtree: Palmtree,
  umbrella: Umbrella,
  globe2: Globe2,
  flag: Flag,
  // Famille
  "graduation-cap": GraduationCap,
  baby: Baby,
  "paw-print": PawPrint,
  users: Users,
  user: User,
  "user-plus": UserPlus,
  dog: Dog,
  cat: Cat,
  bird: Bird,
  rabbit: Rabbit,
  // Autre
  wrench: Wrench,
  "heart-handshake": HeartHandshake,
  gift: Gift,
  cigarette: Cigarette,
  "arrow-right-left": ArrowRightLeft,
  "help-circle": HelpCircle,
  tag: Tag,
  folder: Folder,
  key: Key,
  star: Star,
  bookmark: Bookmark,
  clock: Clock,
  calendar: Calendar,
  bell: Bell,
  "alert-triangle": AlertTriangle,
  info: Info,
  "check-circle": CheckCircle,
  "x-circle": XCircle,
  plus: Plus,
  minus: Minus,
  search: Search,
  trash: Trash,
  edit: Edit,
  download: Download,
  upload: Upload,
  share: Share,
  link: Link,
  paperclip: Paperclip,
  archive: Archive,
  box: Box,
  boxes: Boxes,
  container: Container,
  briefcase: Briefcase,
  education: Education,
  award: Award,
  lightbulb: Lightbulb,
  flame: Flame,
  rocket: Rocket,
  atom: Atom,
};

// Get all available icon names
export const availableIcons = Object.keys(iconMap);

// Get the icon component by name
export function getIconComponent(iconName: string): LucideIcon {
  return iconMap[iconName] || Tag;
}

interface CategoryIconProps {
  icon: string;
  color?: string;
  className?: string;
  size?: number;
}

export function CategoryIcon({
  icon,
  color,
  className,
  size = 20,
}: CategoryIconProps) {
  const IconComponent = getIconComponent(icon);
  return <IconComponent className={className} style={{ color }} size={size} />;
}
