// ForestLynk shared icons + small primitives.
// Lucide-derived strokes; never increase weight past 1.5px in product chrome.

const FLIcons = {
  Map: ({ size = 22, color = 'currentColor' }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      <path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/>
      <path d="M15 5.764v15"/><path d="M9 3.236v15"/>
    </svg>
  ),
  Sun: ({ size = 22, color = 'currentColor' }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      <circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>
    </svg>
  ),
  Pencil: ({ size = 22, color = 'currentColor' }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <path d="M12 20h9"/><path d="M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z"/>
    </svg>
  ),
  User: ({ size = 22, color = 'currentColor' }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      <circle cx="12" cy="12" r="10"/><circle cx="12" cy="10" r="3"/><path d="M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662"/>
    </svg>
  ),
  Pin: ({ size = 16, color = 'currentColor' }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      <path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"/><circle cx="12" cy="10" r="3"/>
    </svg>
  ),
  Branch: ({ size = 16, color = 'currentColor' }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      <polyline points="15 10 20 15 15 20"/><path d="M4 4v7a4 4 0 0 0 4 4h12"/>
    </svg>
  ),
  Search: ({ size = 18, color = 'currentColor' }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      <circle cx="11" cy="11" r="7"/><path d="m21 21-4.35-4.35"/>
    </svg>
  ),
  ArrowUp: ({ size = 18, color = 'currentColor' }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
      <path d="M12 19V5"/><path d="m5 12 7-7 7 7"/>
    </svg>
  ),
  ChevronLeft: ({ size = 22, color = 'currentColor' }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      <path d="m15 18-6-6 6-6"/>
    </svg>
  ),
  More: ({ size = 22, color = 'currentColor' }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      <circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>
    </svg>
  ),
  TreeMark: ({ size = 22, active = false }) => {
    const ring = active ? "#4F8E51" : "#586552";
    return (
      <svg width={size} height={size} viewBox="0 0 52 52" fill="none">
        <circle cx="26" cy="26" r="23" stroke={ring} strokeOpacity={active ? 0.45 : 0.32} strokeWidth="1.4"/>
        <circle cx="26" cy="26" r="16" stroke={ring} strokeOpacity={active ? 0.7 : 0.5} strokeWidth="1.5"/>
        <circle cx="26" cy="26" r="9" stroke={ring} strokeOpacity={active ? 1 : 0.75} strokeWidth="1.6"/>
        <circle cx="26" cy="26" r="3.2" fill="#D4960C"/>
      </svg>
    );
  },
};

// Identity stage badge
function StageBadge({ stage = 'stranger', size = 'sm' }) {
  const cfg = {
    stranger: { bg: '#1A2812', border: '#2D3A22', fg: '#8A9678', label: 'Stranger' },
    acquaintance: { bg: '#1B3A1D', border: '#2C5F2E', fg: '#A9C2A4', label: 'Acquaintance' },
    friend: { bg: '#4F8E51', border: '#4F8E51', fg: '#F2EDE4', label: 'Friend' },
  }[stage];
  return (
    <span style={{
      display: 'inline-flex', alignItems: 'center', gap: 5,
      padding: size === 'sm' ? '3px 9px' : '5px 12px',
      borderRadius: 999,
      background: cfg.bg, border: `0.5px solid ${cfg.border}`,
      color: cfg.fg, font: `500 ${size === 'sm' ? 11 : 12}px var(--font-sans)`,
      whiteSpace: 'nowrap',
    }}>{cfg.label}</span>
  );
}

// Node dot — color encodes depth
function NodeDot({ depth = 0, active = false, size = 10 }) {
  const colors = ['#2C5F2E', '#5E8048', '#A8C5A0', '#A8C5A0'];
  const c = active ? '#D4960C' : (colors[Math.min(depth, 3)]);
  return (
    <span style={{
      display: 'inline-block', width: size, height: size, borderRadius: '50%',
      background: c, flexShrink: 0,
      boxShadow: active ? `0 0 0 ${Math.max(3, size * 0.4)}px rgba(212,150,12,0.22)` : 'none',
    }}/>
  );
}

Object.assign(window, { FLIcons, StageBadge, NodeDot });
