// icons.jsx — 细线图标 + 篆刻方印
// 所有线性图标 stroke 1.5，currentColor，无填充；篆刻方印为朱印式方章。
const { createElement: h } = React;

function svg(paths, vb) {
  return (props) => {
    const { size = 16, style, ...rest } = props || {};
    return h('svg', {
      width: size, height: size, viewBox: vb || '0 0 24 24',
      fill: 'none', stroke: 'currentColor', strokeWidth: 1.5,
      strokeLinecap: 'round', strokeLinejoin: 'round', style, ...rest
    }, paths.map((d, i) => h('path', { key: i, d })));
  };
}
function raw(children, vb) {
  return (props) => {
    const { size = 16, style, ...rest } = props || {};
    return h('svg', {
      width: size, height: size, viewBox: vb || '0 0 24 24',
      fill: 'none', stroke: 'currentColor', strokeWidth: 1.5,
      strokeLinecap: 'round', strokeLinejoin: 'round', style, ...rest
    }, children);
  };
}

const L = {
  clock:    raw([h('circle',{key:0,cx:12,cy:12,r:9}), h('path',{key:1,d:'M12 7v5l3 2'})]),
  mapPin:   svg(['M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z','M12 10.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z']),
  layers:   svg(['M12 3 3 8l9 5 9-5-9-5Z','M3 13l9 5 9-5','M3 16.5l9 5 9-5']),
  download: svg(['M12 3v12','M7 11l5 5 5-5','M5 21h14']),
  bell:     svg(['M18 8a6 6 0 1 0-12 0c0 7-3 9-3 9h18s-3-2-3-9','M13.7 21a2 2 0 0 1-3.4 0']),
  share:    raw([h('circle',{key:0,cx:18,cy:5,r:2.4}),h('circle',{key:1,cx:6,cy:12,r:2.4}),h('circle',{key:2,cx:18,cy:19,r:2.4}),h('path',{key:3,d:'M8.1 10.8 15.9 6.2M8.1 13.2l7.8 4.6'})]),
  users:    raw([h('circle',{key:0,cx:9,cy:8,r:3}),h('path',{key:1,d:'M3 20c0-3.3 2.7-6 6-6s6 2.7 6 6'}),h('path',{key:2,d:'M16 5.3A3 3 0 0 1 16 13'}),h('path',{key:3,d:'M21 20c0-2.6-1.7-4.8-4-5.6'})]),
  spark:    svg(['M12 3l1.6 5.4L19 10l-5.4 1.6L12 17l-1.6-5.4L5 10l5.4-1.6L12 3Z','M19 15l.7 2.3L22 18l-2.3.7L19 21l-.7-2.3L16 18l2.3-.7L19 15Z']),
  plus:     svg(['M12 5v14','M5 12h14']),
  chevDown: svg(['M6 9l6 6 6-6']),
  chevRight:svg(['M9 6l6 6-6 6']),
  x:        svg(['M6 6l12 12','M18 6 6 18']),
  check:    svg(['M5 12l5 5 9-11']),
  camera:   raw([h('path',{key:0,d:'M4 8h3l1.5-2h7L17 8h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1Z'}),h('circle',{key:1,cx:12,cy:13,r:3.2})]),
  pencil:   svg(['M4 20h4L19 9a2.1 2.1 0 0 0-3-3L5 17v3Z','M14 7l3 3']),
  send:     svg(['M21 3 3 11l7 3 3 7 8-18Z','M10 14l4-4']),
  arrowL:   svg(['M15 6l-6 6 6 6']),
  calendar: raw([h('rect',{key:0,x:3.5,y:5,width:17,height:16,rx:2}),h('path',{key:1,d:'M3.5 9.5h17M8 3v4M16 3v4'})]),
  home:     svg(['M4 11l8-7 8 7','M6 10v9h12v-9']),
  coffee:   svg(['M4 9h13v5a4 4 0 0 1-4 4H8a4 4 0 0 1-4-4V9Z','M17 10h2.2a2 2 0 0 1 0 4H17','M8 3v2M12 3v2']),
  book:     svg(['M5 4h11a2 2 0 0 1 2 2v14H7a2 2 0 0 1-2-2V4Z','M5 17h13']),
  image:    raw([h('rect',{key:0,x:3.5,y:4.5,width:17,height:15,rx:2}),h('circle',{key:1,cx:9,cy:10,r:1.8}),h('path',{key:2,d:'M20 16l-5-5L4 20'})]),
  globe:    raw([h('circle',{key:0,cx:12,cy:12,r:9}),h('path',{key:1,d:'M3 12h18M12 3c2.5 2.6 2.5 15.4 0 18M12 3c-2.5 2.6-2.5 15.4 0 18'})]),
  grid:     raw([h('rect',{key:0,x:4,y:4,width:16,height:16,rx:1}),h('path',{key:1,d:'M4 10h16M4 14h16M10 4v16M14 4v16'})]),
  lines:    svg(['M4 8h16','M4 12h16','M4 16h16']),
  dots:     raw([1,2,3].flatMap((r)=>[1,2,3].map((c)=>h('circle',{key:`${r}-${c}`,cx:6+(c-1)*6,cy:6+(r-1)*6,r:.9,fill:'currentColor',stroke:'none'}))) ),
  blank:    raw([h('rect',{key:0,x:4,y:4,width:16,height:16,rx:1})]),
  eye:      raw([h('path',{key:0,d:'M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12Z'}),h('circle',{key:1,cx:12,cy:12,r:3})]),
  search:   raw([h('circle',{key:0,cx:11,cy:11,r:7}),h('path',{key:1,d:'M21 21l-4.3-4.3'})]),
  sun:      raw([h('circle',{key:0,cx:12,cy:12,r:4}),h('path',{key:1,d:'M12 2v3M12 19v3M2 12h3M19 12h3M5 5l2 2M17 17l2 2M19 5l-2 2M7 17l-2 2'})]),
  music:    raw([h('circle',{key:0,cx:7,cy:18,r:2.4}),h('circle',{key:1,cx:18,cy:16,r:2.4}),h('path',{key:2,d:'M9.4 18V6l11-2v12'})]),
  wallet:   svg(['M4 7a2 2 0 0 1 2-2h12v3','M4 7v11a2 2 0 0 0 2 2h13a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1H6a2 2 0 0 1-2-1Z','M17 13.5h.01']),
  heart:    svg(['M12 20s-7-4.3-9.3-8.1C1.2 9.4 2.3 6 5.4 6c1.9 0 2.9 1.1 3.6 2.1.7-1 1.7-2.1 3.6-2.1 3.1 0 4.2 3.4 2.7 5.9C19 15.7 12 20 12 20Z']),
  upload:   svg(['M12 16V4','M7 9l5-5 5 5','M5 20h14']),
  settings: raw([h('circle',{key:0,cx:12,cy:12,r:3}),h('path',{key:1,d:'M12 2v3M12 19v3M22 12h-3M5 12H2M19 5l-2 2M7 17l-2 2M19 19l-2-2M7 7 5 5'})]),
  filter:   svg(['M4 5h16l-6 8v6l-4-2v-4L4 5Z']),
  type:     svg(['M5 6h14','M12 6v13','M8 19h8']),
  route:    raw([h('circle',{key:0,cx:6,cy:18,r:2.6}),h('circle',{key:1,cx:18,cy:6,r:2.6}),h('path',{key:2,d:'M8.5 18H14a3.5 3.5 0 0 0 0-7H9a3.5 3.5 0 0 1 0-7h6.5'})]),
  video:    svg(['M3.5 7a1.5 1.5 0 0 1 1.5-1.5h8A1.5 1.5 0 0 1 14.5 7v10A1.5 1.5 0 0 1 13 18.5H5A1.5 1.5 0 0 1 3.5 17V7Z','M14.5 10l6-3v10l-6-3']),
  film:     raw([h('rect',{key:0,x:3.5,y:4.5,width:17,height:15,rx:2}),h('path',{key:1,d:'M3.5 9h17M3.5 15h17M8 4.5v15M16 4.5v15'})]),
  deck:     raw([h('rect',{key:0,x:3.5,y:4.5,width:17,height:12,rx:1.5}),h('path',{key:1,d:'M12 16.5V20M8.5 20h7'})]),
  code:     svg(['M9 8l-4 4 4 4','M15 8l4 4-4 4']),
  hash:     svg(['M9 4 7 20','M17 4l-2 16','M5 9h15','M4 15h15']),
  shield:   svg(['M12 3l7 3v5c0 4.5-3 7.5-7 9-4-1.5-7-4.5-7-9V6l7-3Z','M9 12l2 2 4-4']),
  fingerprint: svg(['M12 4a8 8 0 0 1 8 8','M4 12a8 8 0 0 1 4-6.9','M7 12a5 5 0 0 1 10 0v2','M10 12a2 2 0 0 1 4 0v3a4 4 0 0 0 .8 2.4','M7 14v1a6 6 0 0 0 1.2 3.6','M12 16v3']),
  play:     svg(['M7 5l11 7-11 7V5Z']),
  refresh:  svg(['M20 11a8 8 0 1 0-1.5 5','M20 5v6h-6']),
  copy:     raw([h('rect',{key:0,x:8,y:8,width:11,height:11,rx:2}),h('path',{key:1,d:'M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2'})]),
  zap:      svg(['M13 3 4 14h6l-1 7 9-11h-6l1-7Z']),
  link:     svg(['M10 13a5 5 0 0 0 7.07 0l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71','M14 11a5 5 0 0 0-7.07 0l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71']),
  maximize: svg(['M8 3H5a2 2 0 0 0-2 2v3','M16 3h3a2 2 0 0 1 2 2v3','M16 21h3a2 2 0 0 0 2-2v-3','M8 21H5a2 2 0 0 1-2-2v-3']),
  minimize: svg(['M8 3v3a2 2 0 0 1-2 2H3','M21 8h-3a2 2 0 0 1-2-2V3','M3 16h3a2 2 0 0 1 2 2v3','M16 21v-3a2 2 0 0 1 2-2h3']),
  bookmark: svg(['M6 4h12v16l-6-4-6 4V4Z']),
  quote:    svg(['M7 7H4v6h6V7H7l1.5-3M17 7h-3v6h6V7h-3l1.5-3']),
  minus:    svg(['M5 12h14']),
  save:     svg(['M5 4h11l3 3v13H5V4Z','M8 4v5h7V4M8 20v-6h8v6']),
  mic:      svg(['M12 4a3 3 0 0 0-3 3v5a3 3 0 0 0 6 0V7a3 3 0 0 0-3-3Z','M5 11a7 7 0 0 0 14 0','M12 18v3M9 21h6']),
  keyboard: raw([h('rect',{key:0,x:3,y:6,width:18,height:12,rx:2}),h('path',{key:1,d:'M7 10h.01M11 10h.01M15 10h.01M17 10h.01M7 13h.01M17 13h.01M9 16h6'})]),
  penTablet:raw([h('rect',{key:0,x:3,y:4,width:14,height:16,rx:2}),h('path',{key:1,d:'M20.5 5.5a1.6 1.6 0 0 0-2.3 0L11 12.7V15h2.3l7.2-7.2a1.6 1.6 0 0 0 0-2.3Z'})]),
  // —— 本子分类（成套·1.5 线）—— //
  catBook:  svg(['M5 4.5h11a1.5 1.5 0 0 1 1.5 1.5v13H6.5A1.5 1.5 0 0 1 5 17V4.5Z','M5 17.5A1.5 1.5 0 0 1 6.5 16h11','M9 8h5']),
  catMusic: raw([h('circle',{key:0,cx:7,cy:17.5,r:2.3}),h('circle',{key:1,cx:17,cy:15.5,r:2.3}),h('path',{key:2,d:'M9.3 17.5V7l9.7-2v10.5'}),h('path',{key:3,d:'M9.3 8.6 19 6.6'})]),
  catMoney: raw([h('circle',{key:0,cx:12,cy:12,r:8.2}),h('path',{key:1,d:'M14.4 9.2c-.5-1-1.5-1.5-2.6-1.5-1.5 0-2.6.9-2.6 2.1 0 2.8 5.4 1.5 5.4 4.4 0 1.3-1.2 2.2-2.8 2.2-1.3 0-2.4-.6-2.9-1.6'}),h('path',{key:2,d:'M12 6.2v1.6M12 16.2v1.6'})]),
  catHealth:svg(['M3.5 12.5h3.5l1.6-3.4 2.6 7 2.2-5 1.3 2.4h3.8','M5.2 8.4a4 4 0 0 1 6.8-2.1 4 4 0 0 1 6.8 2.9c0 .5-.07 1-.2 1.4']),
  catFilm:  raw([h('rect',{key:0,x:3.5,y:5.5,width:17,height:13,rx:1.5}),h('path',{key:1,d:'M3.5 9.5h17M3.5 14.5h17M8 5.5v13M16 5.5v13'})]),
  catRun:   svg(['M14.5 5.4a1.7 1.7 0 1 0 0-.1','M9 21l2.2-4.3 2.3-2.2-1.2-4.5L8 12l-2 3','M11.5 9.8l3-2.4 2.5 1.6 2.3-.6','M12.3 14.7l2.4 1.8.6 4']),
  catTravel:raw([h('circle',{key:0,cx:12,cy:12,r:8.4}),h('path',{key:1,d:'M3.6 12h16.8M12 3.6c2.3 2.4 2.3 14.4 0 16.8M12 3.6c-2.3 2.4-2.3 14.4 0 16.8'})]),
  catLife:  svg(['M5 10.5 12 5l7 5.5V19a1 1 0 0 1-1 1h-3.5v-5h-5v5H6a1 1 0 0 1-1-1v-8.5Z']),
};

function Icon({ name, size = 16, style, ...rest }) {
  const C = L[name];
  if (!C) return null;
  return h(C, { size, style, ...rest });
}

// 篆刻方印：朱印式方章，白文/朱文随 variant
// variant: 'seal'（实底白字）| 'stamp'（描边朱字，手作感）| 'line'（细线图标兜底）
function SealGlyph({ glyph, color = '#8B2020', fg = '#FAF6EE', size = 22, variant = 'seal', lineIcon, style }) {
  if (variant === 'line' && lineIcon) {
    return h('span', { className: 'seal-ico', style: { width: size, height: size, color, ...style } },
      h(Icon, { name: lineIcon, size: Math.round(size * 0.78) }));
  }
  const fontSize = Math.round(size * 0.62);
  if (variant === 'stamp') {
    return h('span', {
      className: 'seal-ico',
      style: {
        width: size, height: size, color,
        border: `1.5px solid ${color}`, background: 'transparent',
        fontSize, ...style
      }
    }, glyph);
  }
  // seal — 实底朱文
  return h('span', {
    className: 'seal-ico',
    style: {
      width: size, height: size, color: fg, background: color,
      fontSize, ...style
    }
  }, glyph);
}

Object.assign(window, { Icon, SealGlyph });
