/* Icon component backed by the Lucide icon set (loaded via CDN UMD as window.lucide) */
const Icon = ({ name, size = 20, stroke = 1.75, className = "", style = {} }) => {
  const lib = (window.lucide && window.lucide.icons) || {};
  const node = lib[name];
  const renderChild = (child, i) => {
    if (!Array.isArray(child)) return null;
    const [tag, attrs = {}, kids] = child;
    const props = { key: i };
    for (const k in attrs) {
      // convert kebab to camel for React
      const ck = k.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
      props[ck] = attrs[k];
    }
    return React.createElement(
      tag, props,
      Array.isArray(kids) ? kids.map(renderChild) : null
    );
  };
  return (
    <svg
      width={size} height={size} viewBox="0 0 24 24" fill="none"
      stroke="currentColor" strokeWidth={stroke} strokeLinecap="round" strokeLinejoin="round"
      className={className} style={{ display: "block", flex: "none", ...style }}
      aria-hidden="true"
    >
      {node ? node.map(renderChild) : null}
    </svg>
  );
};

Object.assign(window, { Icon });
