import {
  Award,
  BadgeCheck,
  Crown,
  Gem,
  Heart,
  Moon,
  ShieldCheck,
  Sparkles,
  Star,
  Sun,
  type LucideIcon
} from 'lucide-react';

export const DEFAULT_VERIFICATION_ICON = 'badge-check';

export const VERIFICATION_ICON_OPTIONS = [
  { slug: 'badge-check', name: 'Галочка', Icon: BadgeCheck },
  { slug: 'star', name: 'Звезда', Icon: Star },
  { slug: 'sparkles', name: 'Искры', Icon: Sparkles },
  { slug: 'moon', name: 'Луна', Icon: Moon },
  { slug: 'sun', name: 'Солнце', Icon: Sun },
  { slug: 'crown', name: 'Корона', Icon: Crown },
  { slug: 'gem', name: 'Драгоценность', Icon: Gem },
  { slug: 'heart', name: 'Сердце', Icon: Heart },
  { slug: 'award', name: 'Награда', Icon: Award },
  { slug: 'shield-check', name: 'Щит', Icon: ShieldCheck }
] as const;

export type VerificationIconSlug = (typeof VERIFICATION_ICON_OPTIONS)[number]['slug'];

const iconBySlug = Object.fromEntries(VERIFICATION_ICON_OPTIONS.map((option) => [option.slug, option.Icon])) as Record<
  VerificationIconSlug,
  LucideIcon
>;

export function resolveVerificationIcon(slug?: string | null): VerificationIconSlug {
  if (slug && slug in iconBySlug) {
    return slug as VerificationIconSlug;
  }
  return DEFAULT_VERIFICATION_ICON;
}

export function VerificationIconGlyph({ slug, className }: { slug?: string | null; className?: string }) {
  const Icon = iconBySlug[resolveVerificationIcon(slug)];
  return <Icon className={className} aria-hidden />;
}
