import {
	Library,
	BookOpen,
	BookMarked,
	Book,
	Bookmark,
	FolderOpen,
	Code,
	Terminal,
	Cpu,
	Server,
	Database,
	Binary,
	Braces,
	GraduationCap,
	FlaskConical,
	Microscope,
	Atom,
	Dna,
	Brain,
	FileText,
	ScrollText,
	Calculator,
	Compass,
	Ruler,
	PencilRuler,
	Sigma,
	Image,
	Palette,
	Sparkles,
	Zap,
	Feather,
	PenLine,
	Quote,
	Wand2,
	Sword,
	Crown,
	Flame,
	Shield,
	Rocket,
	Satellite,
	Globe,
	Search,
	Eye,
	Fingerprint,
	Heart,
	HeartHandshake,
	Landmark,
	Scroll,
	Archive,
	Clock,
	Star,
	Rainbow,
	Baby,
	Headphones,
	Music
} from '@lucide/svelte';
import type { Component } from 'svelte';

export type IconName = keyof typeof LIBRARY_ICONS;

export const LIBRARY_ICONS: Record<
	string,
	{ component: Component; label: string; category: string }
> = {
	// Generic
	library: { component: Library, label: 'Library', category: 'Generic' },
	'book-open': { component: BookOpen, label: 'Book Open', category: 'Generic' },
	'book-marked': { component: BookMarked, label: 'Book Marked', category: 'Generic' },
	book: { component: Book, label: 'Book', category: 'Generic' },
	bookmark: { component: Bookmark, label: 'Bookmark', category: 'Generic' },
	'folder-open': { component: FolderOpen, label: 'Folder Open', category: 'Generic' },

	// Technical
	code: { component: Code, label: 'Code', category: 'Technical' },
	terminal: { component: Terminal, label: 'Terminal', category: 'Technical' },
	cpu: { component: Cpu, label: 'CPU', category: 'Technical' },
	server: { component: Server, label: 'Server', category: 'Technical' },
	database: { component: Database, label: 'Database', category: 'Technical' },
	binary: { component: Binary, label: 'Binary', category: 'Technical' },
	braces: { component: Braces, label: 'Braces', category: 'Technical' },

	// Academic
	'graduation-cap': { component: GraduationCap, label: 'Graduation Cap', category: 'Academic' },
	'flask-conical': { component: FlaskConical, label: 'Flask', category: 'Academic' },
	microscope: { component: Microscope, label: 'Microscope', category: 'Academic' },
	atom: { component: Atom, label: 'Atom', category: 'Academic' },
	dna: { component: Dna, label: 'DNA', category: 'Academic' },
	brain: { component: Brain, label: 'Brain', category: 'Academic' },
	'file-text': { component: FileText, label: 'File Text', category: 'Academic' },
	'scroll-text': { component: ScrollText, label: 'Scroll Text', category: 'Academic' },

	// Math/Engineering
	calculator: { component: Calculator, label: 'Calculator', category: 'Math' },
	compass: { component: Compass, label: 'Compass', category: 'Math' },
	ruler: { component: Ruler, label: 'Ruler', category: 'Math' },
	'pencil-ruler': { component: PencilRuler, label: 'Pencil Ruler', category: 'Math' },
	sigma: { component: Sigma, label: 'Sigma', category: 'Math' },

	// Comics/Manga
	image: { component: Image, label: 'Image', category: 'Comics' },
	palette: { component: Palette, label: 'Palette', category: 'Comics' },
	sparkles: { component: Sparkles, label: 'Sparkles', category: 'Comics' },
	zap: { component: Zap, label: 'Zap', category: 'Comics' },

	// Fiction
	feather: { component: Feather, label: 'Feather', category: 'Fiction' },
	'pen-line': { component: PenLine, label: 'Pen', category: 'Fiction' },
	quote: { component: Quote, label: 'Quote', category: 'Fiction' },

	// Fantasy
	wand: { component: Wand2, label: 'Wand', category: 'Fantasy' },
	sword: { component: Sword, label: 'Sword', category: 'Fantasy' },
	crown: { component: Crown, label: 'Crown', category: 'Fantasy' },
	flame: { component: Flame, label: 'Flame', category: 'Fantasy' },
	shield: { component: Shield, label: 'Shield', category: 'Fantasy' },

	// Sci-Fi
	rocket: { component: Rocket, label: 'Rocket', category: 'Sci-Fi' },
	satellite: { component: Satellite, label: 'Satellite', category: 'Sci-Fi' },
	globe: { component: Globe, label: 'Globe', category: 'Sci-Fi' },

	// Mystery
	search: { component: Search, label: 'Search', category: 'Mystery' },
	eye: { component: Eye, label: 'Eye', category: 'Mystery' },
	fingerprint: { component: Fingerprint, label: 'Fingerprint', category: 'Mystery' },

	// Romance
	heart: { component: Heart, label: 'Heart', category: 'Romance' },
	'heart-handshake': { component: HeartHandshake, label: 'Heart Handshake', category: 'Romance' },

	// History
	landmark: { component: Landmark, label: 'Landmark', category: 'History' },
	scroll: { component: Scroll, label: 'Scroll', category: 'History' },
	archive: { component: Archive, label: 'Archive', category: 'History' },
	clock: { component: Clock, label: 'Clock', category: 'History' },

	// Children's
	star: { component: Star, label: 'Star', category: "Children's" },
	rainbow: { component: Rainbow, label: 'Rainbow', category: "Children's" },
	baby: { component: Baby, label: 'Baby', category: "Children's" },

	// Audio
	headphones: { component: Headphones, label: 'Headphones', category: 'Audio' },
	music: { component: Music, label: 'Music', category: 'Audio' }
};

export function getIconComponent(name: string): Component {
	return LIBRARY_ICONS[name]?.component ?? LIBRARY_ICONS['library'].component;
}
