/* LucideIcon — renders a Lucide icon from the UMD global.
   Defensive about the global's shape across versions. */
(function () {
  function resolve(name) {
    const L = window.lucide || {};
    const icons = L.icons || L;
    // try as given, PascalCase, and a few aliases
    const tryNames = [name];
    // kebab/space -> Pascal
    const pascal = String(name)
      .replace(/(^|[-_\s])(\w)/g, (_, __, c) => c.toUpperCase());
    tryNames.push(pascal);
    for (const n of tryNames) {
      if (icons[n]) return icons[n];
    }
    return null;
  }

  function LucideIcon({ name, size = 24, color = 'currentColor', strokeWidth = 2, fill = 'none', className, style }) {
    const node = resolve(name);
    if (!node) {
      // fallback: tiny neutral square so layout never breaks
      return React.createElement('svg', { width: size, height: size, viewBox: '0 0 24 24', className, style });
    }
    // lucide icon node = ["svg", attrs, [ [tag, attrs], ... ] ]
    const kids = Array.isArray(node[2]) ? node[2] : node;
    const children = kids.map((child, i) => {
      const tag = child[0];
      const attrs = child[1] || {};
      return React.createElement(tag, Object.assign({ key: i }, attrs));
    });
    return React.createElement('svg', {
      xmlns: 'http://www.w3.org/2000/svg',
      width: size, height: size,
      viewBox: '0 0 24 24',
      fill,
      stroke: color,
      strokeWidth,
      strokeLinecap: 'round',
      strokeLinejoin: 'round',
      className, style,
    }, children);
  }

  window.LucideIcon = LucideIcon;

  // Gender glyphs (Lucide has no Mars/Venus in this build) — clean hand-drawn ♀/♂
  function GenderSymbol({ gender, size = 16, strokeWidth = 2.4, className, style, color }) {
    if (gender !== 'm' && gender !== 'f') return null;
    const stroke = color || (gender === 'm' ? '#5C86C2' : '#C26FA0');
    const kids = gender === 'f'
      ? [['circle', { cx: 12, cy: 8, r: 5.4 }], ['line', { x1: 12, y1: 13.4, x2: 12, y2: 21 }], ['line', { x1: 8.4, y1: 17.6, x2: 15.6, y2: 17.6 }]]
      : [['circle', { cx: 10, cy: 14, r: 5.4 }], ['line', { x1: 14.1, y1: 9.9, x2: 20, y2: 4 }], ['polyline', { points: '15,4 20,4 20,9' }]];
    return React.createElement('svg', {
      xmlns: 'http://www.w3.org/2000/svg', width: size, height: size, viewBox: '0 0 24 24',
      fill: 'none', stroke, strokeWidth, strokeLinecap: 'round', strokeLinejoin: 'round', className, style,
    }, kids.map((c, i) => React.createElement(c[0], Object.assign({ key: i }, c[1]))));
  }

  window.GenderSymbol = GenderSymbol;
})();
