"use client";

import * as Icons from "lucide-react";
import type { LucideProps } from "lucide-react";

type IconName = keyof typeof Icons;

/** Resolve a lucide icon by name (so server config can stay serialisable). */
export function Icon({ name, ...props }: { name: string } & LucideProps) {
  const Cmp = (Icons as unknown as Record<string, React.ComponentType<LucideProps>>)[name as IconName] ?? Icons.Circle;
  return <Cmp {...props} />;
}
