/* icons.jsx — tiny inline SVG icon set, shared via window.Icons */
const I = (path, vb = "0 0 24 24") => (p) =>
  React.createElement("svg", {
    width: p.s || 16, height: p.s || 16, viewBox: vb, fill: "none",
    stroke: "currentColor", strokeWidth: p.w || 2, strokeLinecap: "round",
    strokeLinejoin: "round", style: p.style, "aria-hidden": true,
  }, ...(Array.isArray(path) ? path : [path]).map((d, i) =>
    React.createElement("path", { key: i, d })));

const Icons = {
  Chevron: I("M6 9l6 6 6-6"),
  Plus: I("M12 5v14M5 12h14"),
  Search: I(["M11 19a8 8 0 100-16 8 8 0 000 16z", "M21 21l-4.3-4.3"]),
  X: I("M18 6L6 18M6 6l12 12"),
  Dots: (p) => React.createElement("svg", { width: p.s || 16, height: p.s || 16, viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true },
    React.createElement("circle", { cx: 5, cy: 12, r: 1.7 }),
    React.createElement("circle", { cx: 12, cy: 12, r: 1.7 }),
    React.createElement("circle", { cx: 19, cy: 12, r: 1.7 })),
  Copy: I(["M9 9h10v10a2 2 0 01-2 2H9a2 2 0 01-2-2V9z", "M5 15V5a2 2 0 012-2h10"]),
  Trash: I(["M4 7h16", "M9 7V5a1 1 0 011-1h4a1 1 0 011 1v2", "M6 7l1 13a1 1 0 001 1h8a1 1 0 001-1l1-13"]),
  Edit: I(["M4 20h4L19 9l-4-4L4 16v4z", "M14 5l4 4"]),
  Cal: I(["M7 3v3M17 3v3", "M4 8h16", "M5 6h14a1 1 0 011 1v12a1 1 0 01-1 1H5a1 1 0 01-1-1V7a1 1 0 011-1z"]),
  Check: I("M5 12l5 5L20 6"),
  Flag: I(["M5 21V4", "M5 4h11l-2 4 2 4H5"]),
  User: I(["M12 12a4 4 0 100-8 4 4 0 000 8z", "M5 20a7 7 0 0114 0"]),
  Money: I(["M12 3v18", "M16 7H10a2.5 2.5 0 000 5h4a2.5 2.5 0 010 5H8"]),
  Users: I(["M16 19a5 5 0 00-8 0", "M12 12a3.5 3.5 0 100-7 3.5 3.5 0 000 7", "M20 18a4 4 0 00-3-3.8", "M4 18a4 4 0 013-3.8"]),
  ListChk: I(["M9 6h11M9 12h11M9 18h11", "M4 6l1 1 1.5-2", "M4 12l1 1 1.5-2", "M4 18l1 1 1.5-2"]),
  Folder: I("M3 7a2 2 0 012-2h4l2 2h8a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V7z"),
  Sliders: I(["M4 6h10M18 6h2", "M4 12h2M10 12h10", "M4 18h7M15 18h5", "M14 6v0M6 12v0M11 18v0"]),
  Text: I(["M5 7V5h14v2", "M12 5v14", "M9 19h6"]),
  Info: I(["M12 21a9 9 0 110-18 9 9 0 010 18z", "M12 11v5", "M12 8h.01"]),
};
window.Icons = Icons;

/* ---- Accurate Rotary wheel: 24 cogs, 6 spokes, hub + keyway ---- */
const ROTARY_GEAR_PATH = (function () {
  const cx = 50, cy = 50, Rt = 49, Rr = 43, teeth = 24, tipHalf = 3.3, rootHalf = 7.5;
  const rad = (a) => (a - 90) * Math.PI / 180;
  const pts = [];
  for (let i = 0; i < teeth; i++) {
    const c = i * (360 / teeth);
    [[Rr, c - rootHalf], [Rt, c - tipHalf], [Rt, c + tipHalf], [Rr, c + rootHalf]].forEach(([r, a]) => {
      pts.push([cx + r * Math.cos(rad(a)), cy + r * Math.sin(rad(a))]);
    });
  }
  return "M" + pts.map((p) => p[0].toFixed(2) + "," + p[1].toFixed(2)).join(" L") + " Z";
})();

let _rwSeq = 0;
function RotaryWheel({ size = 28, color = "#F7A81B", spin = false, className, style }) {
  const id = React.useMemo(() => "rw" + (++_rwSeq), []);
  return (
    <svg width={size} height={size} viewBox="0 0 100 100" className={className}
      style={spin ? { animation: "spin 1.1s linear infinite", ...style } : style} aria-hidden="true">
      <mask id={id}>
        <rect width="100" height="100" fill="#000" />
        <path d={ROTARY_GEAR_PATH} fill="#fff" />
        <circle cx="50" cy="50" r="33.5" fill="#000" />
        <g fill="#fff">
          <rect x="45.6" y="14" width="8.8" height="72" rx="1.2" />
          <rect x="45.6" y="14" width="8.8" height="72" rx="1.2" transform="rotate(60 50 50)" />
          <rect x="45.6" y="14" width="8.8" height="72" rx="1.2" transform="rotate(120 50 50)" />
        </g>
        <circle cx="50" cy="50" r="15" fill="#fff" />
        <circle cx="50" cy="50" r="7.4" fill="#000" />
        <rect x="47.7" y="34.5" width="4.6" height="9.5" rx="0.6" fill="#000" />
      </mask>
      <rect width="100" height="100" fill={color} mask={`url(#${id})`} />
    </svg>
  );
}
window.RotaryWheel = RotaryWheel;
