/**
 * Icon Resolver
 *
 * Maps icon name strings from PHP package schemas to Lucide React components.
 * Curated allowlist of icons relevant to common option contexts (roles, statuses,
 * permissions, content types). Not dynamic import — safe for bundling.
 */

import type { LucideIcon } from 'lucide-react';
import {
  Shield,
  ShieldCheck,
  User,
  UserCog,
  Users,
  Eye,
  Pencil,
  Lock,
  Unlock,
  Crown,
  Star,
  Check,
  X,
  AlertTriangle,
  Info,
  Mail,
  Globe,
  FileText,
  Image,
  Tag,
  Folder,
  Settings,
  Zap,
  Clock,
  Archive,
  Trash2,
} from 'lucide-react';

const iconMap: Record<string, LucideIcon> = {
  Shield,
  ShieldCheck,
  User,
  UserCog,
  Users,
  Eye,
  Pencil,
  Lock,
  Unlock,
  Crown,
  Star,
  Check,
  X,
  AlertTriangle,
  Info,
  Mail,
  Globe,
  FileText,
  Image,
  Tag,
  Folder,
  Settings,
  Zap,
  Clock,
  Archive,
  Trash2,
};

/**
 * Resolve an icon name string to a Lucide React component.
 * Returns null if the name is not in the allowlist.
 */
export function resolveIcon(name?: string): LucideIcon | null {
  if (!name) return null;
  return iconMap[name] ?? null;
}
