"use client";

import {
  ArrowRight,
  Certificate,
  Envelope,
  Gauge,
  Heart,
  Phone,
  ShieldCheck,
} from "@phosphor-icons/react";

// @phosphor-icons/react 2.1.10 cannot be evaluated inside Server Components:
// its ESM build imports React APIs (createContext) that the react-server build
// does not export. Client components compile against the full React build, so
// ALL phosphor icons reach the DOM through this wrapper.

const ICONS = {
  "arrow-right": ArrowRight,
  certificate: Certificate,
  envelope: Envelope,
  gauge: Gauge,
  heart: Heart,
  phone: Phone,
  "shield-check": ShieldCheck,
} as const;

type IconName = keyof typeof ICONS;

type IconProps = {
  name: IconName;
  size?: number;
  weight?: "light" | "regular" | "bold";
  className?: string;
};

export default function Icon({ name, size = 20, weight = "light", className }: IconProps) {
  const C = ICONS[name];
  if (!C) return null;
  return <C size={size} weight={weight} className={className} />;
}
