/* global React */
// Lucide (lucide.dev) via the Iconify API — pre-tinted SVG rendered as <img>.
function Icon({ name, size = 24, color = "#14143a", style = {} }) {
  const MAP = {
    "var(--color-primary)": "#e8a02c",
    "var(--color-navy-deep)": "#14143a",
    "var(--color-ink)": "#14143a",
    "var(--color-mute)": "#86868f",
    "var(--color-body)": "#454552",
    "var(--color-positive-deep)": "#054d28",
    "#fff": "#ffffff",
  };
  const hex = MAP[color] || (/^#/.test(color) ? color : "#14143a");
  const url = `https://api.iconify.design/lucide/${name}.svg?color=${encodeURIComponent(hex)}`;
  return (
    <img
      src={url}
      alt=""
      aria-hidden="true"
      width={size}
      height={size}
      style={{ display: "inline-block", flexShrink: 0, verticalAlign: "middle", ...style }}
    />
  );
}
window.DBIcon = Icon;
