import {
  FileText,
  Briefcase,
  Newspaper,
  BookOpen,
  Folder,
  Layers,
  Image as ImageIcon,
  Calendar,
  Users,
  HelpCircle,
  type LucideIcon,
} from 'lucide-react'

/**
 * Icon registry for Post Types. Keyed by the string value stored in a
 * collection's `admin.icon`. Rendering surfaces (Post Types cards, the
 * New Post picker, the Quick Post Type gallery) all resolve through
 * `resolvePostTypeIcon` so a single map keeps them in sync — adding an
 * icon here makes it available everywhere at once.
 */
export const POST_TYPE_ICONS: Record<string, LucideIcon> = {
  'file-text': FileText,
  briefcase: Briefcase,
  newspaper: Newspaper,
  book: BookOpen,
  folder: Folder,
  layers: Layers,
  image: ImageIcon,
  calendar: Calendar,
  users: Users,
  help: HelpCircle,
}

export type PostTypeIconName = keyof typeof POST_TYPE_ICONS

export function resolvePostTypeIcon(name: string | null | undefined): LucideIcon {
  if (!name) return FileText
  return POST_TYPE_ICONS[name.toLowerCase()] ?? FileText
}
