/* The Pulse — line-style SVG icon set + EKG pulse line.
   All icons inherit color via stroke="currentColor". */
(function () {
  const S = ({ children, size = 24, sw = 1.7 }) => {
    const kids = React.Children.map(children, (ch, i) =>
      ch ? React.cloneElement(ch, { key: i }) : ch);
    return React.createElement(
      "svg",
      {
        width: size, height: size, viewBox: "0 0 24 24", fill: "none",
        stroke: "currentColor", strokeWidth: sw,
        strokeLinecap: "round", strokeLinejoin: "round"
      },
      kids
    );
  };
  const P = (d, extra) => React.createElement("path", Object.assign({ d }, extra));
  const C = (cx, cy, r) => React.createElement("circle", { cx, cy, r });
  const L = (x1, y1, x2, y2) => React.createElement("line", { x1, y1, x2, y2 });

  const Icons = {
    Calendar: (p) => S({ ...p, children: [
      React.createElement("rect", { key: "r", x: 3, y: 4.5, width: 18, height: 16, rx: 2.5 }),
      L(3, 9, 21, 9), L(8, 2.5, 8, 6), L(16, 2.5, 16, 6)
    ]}),
    Mic: (p) => S({ ...p, children: [
      React.createElement("rect", { key: "r", x: 9, y: 2.5, width: 6, height: 11, rx: 3 }),
      P("M5 11a7 7 0 0 0 14 0"), L(12, 18, 12, 21.5), L(8.5, 21.5, 15.5, 21.5)
    ]}),
    Star: (p) => S({ ...p, children: [
      P("M12 3.2l2.6 5.3 5.8.8-4.2 4.1 1 5.8-5.2-2.7-5.2 2.7 1-5.8L3.6 9.3l5.8-.8z")
    ]}),
    People: (p) => S({ ...p, children: [
      C(8.5, 8, 3), P("M2.5 20a6 6 0 0 1 12 0"),
      P("M16 5.2a3 3 0 0 1 0 5.6"), P("M17 13.6a6 6 0 0 1 4.5 6.4")
    ]}),
    List: (p) => S({ ...p, children: [
      L(8.5, 6.5, 21, 6.5), L(8.5, 12, 21, 12), L(8.5, 17.5, 21, 17.5),
      C(4, 6.5, 1.2), C(4, 12, 1.2), C(4, 17.5, 1.2)
    ]}),
    Hand: (p) => S({ ...p, children: [
      P("M12 11V4.5a1.5 1.5 0 0 1 3 0V12"),
      P("M15 12V6a1.5 1.5 0 0 1 3 0v8.5a6.5 6.5 0 0 1-6.5 6.5h-1a6 6 0 0 1-5.2-3l-2-3.4a1.5 1.5 0 0 1 2.5-1.6L9 13"),
      P("M9 13V6.5a1.5 1.5 0 0 1 3 0V12")
    ]}),
    Pin: (p) => S({ ...p, children: [ P("M12 21s7-5.5 7-11a7 7 0 1 0-14 0c0 5.5 7 11 7 11z"), C(12, 10, 2.6) ]}),
    Clock: (p) => S({ ...p, children: [ C(12, 12, 9), P("M12 7.5V12l3 2") ]}),
    Arrow: (p) => S({ ...p, children: [ L(4, 12, 19, 12), P("M13 6l6 6-6 6") ]}),
    Run: (p) => S({ ...p, children: [
      C(15.5, 4.5, 2), P("M5 13l3.5-2 3-1.5 2.5 2 2.5 1.5"),
      P("M11 9.5L9 21"), P("M13.5 13l1.5 8"), P("M5 21l3-5")
    ]}),
    Book: (p) => S({ ...p, children: [
      P("M4 5.5A2 2 0 0 1 6 4h5v15H6a2 2 0 0 0-2 1.5z"),
      P("M20 5.5A2 2 0 0 0 18 4h-5v15h5a2 2 0 0 1 2 1.5z")
    ]}),
    Hands: (p) => S({ ...p, children: [
      P("M12 6v4"), P("M12 10c-1.5-1-3-1.2-4 0l-4 4a2 2 0 0 0 2.6 3l2.4-1.8"),
      P("M12 10c1.5-1 3-1.2 4 0l4 4a2 2 0 0 1-2.6 3l-2.4-1.8"),
      P("M8 8.5L6.5 7"), P("M16 8.5L17.5 7")
    ]}),
    Tree: (p) => S({ ...p, children: [
      P("M12 3l5 7h-3l3 4.5h-3.5L16 18H8l1.5-3.5H6L9 10H6z"), L(12, 18, 12, 21.5)
    ]}),
    Sparkle: (p) => S({ ...p, children: [
      P("M12 3l1.6 5.4L19 10l-5.4 1.6L12 17l-1.6-5.4L5 10l5.4-1.6z")
    ]}),
    Heart: (p) => S({ ...p, children: [
      P("M12 20s-7-4.6-7-9.5A4 4 0 0 1 12 7a4 4 0 0 1 7 3.5C19 15.4 12 20 12 20z")
    ]}),
    Mail: (p) => S({ ...p, children: [
      React.createElement("rect", { key: "r", x: 3, y: 5, width: 18, height: 14, rx: 2.5 }),
      P("M4 7l8 6 8-6")
    ]}),
    Image: (p) => S({ ...p, children: [
      React.createElement("rect", { key: "r", x: 3, y: 4.5, width: 18, height: 15, rx: 2.5 }),
      C(8.5, 9.5, 1.7), P("M4 17l4.5-4 3.5 2.8 3.5-3 4.5 4.2")
    ]}),
    Upload: (p) => S({ ...p, children: [
      P("M12 15.5V4"), P("M7.5 8.5L12 4l4.5 4.5"), P("M4.5 20h15")
    ]}),
    Plus: (p) => S({ ...p, children: [ L(12, 5, 12, 19), L(5, 12, 19, 12) ]}),
    Trash: (p) => S({ ...p, children: [
      L(4, 7, 20, 7), P("M9 7V4.5h6V7"), P("M6.5 7l1 13h9l1-13"), L(10, 11, 10, 16), L(14, 11, 14, 16)
    ]}),
    Layers: (p) => S({ ...p, children: [
      P("M12 3l9 4.8-9 4.8-9-4.8z"), P("M3 13l9 4.8 9-4.8")
    ]}),
    Copy: (p) => S({ ...p, children: [
      React.createElement("rect", { key: "r", x: 8, y: 8, width: 12, height: 12, rx: 2.5 }),
      P("M16 8V5.5A1.5 1.5 0 0 0 14.5 4H5.5A1.5 1.5 0 0 0 4 5.5v9A1.5 1.5 0 0 0 5.5 16H8")
    ]}),
    Qr: (p) => S({ ...p, sw: 1.5, children: [
      React.createElement("rect", { key: "a", x: 3.5, y: 3.5, width: 6, height: 6, rx: 1 }),
      React.createElement("rect", { key: "b", x: 14.5, y: 3.5, width: 6, height: 6, rx: 1 }),
      React.createElement("rect", { key: "c", x: 3.5, y: 14.5, width: 6, height: 6, rx: 1 }),
      L(14.5, 14, 14.5, 17.5), L(18, 14.5, 18, 14.5), L(14.5, 20.5, 17.5, 20.5), L(20.5, 14.5, 20.5, 20.5)
    ]}),
    ChevDown: (p) => S({ ...p, children: [ P("M6 9.5l6 6 6-6") ]}),
    Check: (p) => S({ ...p, children: [ P("M5 12.5l4.5 4.5L19 6.5") ]})
  };

  // EKG / heartbeat line. Stretches to container width.
  function PulseLine({ color = "#00B7BD", height = 26, stroke = 2.4, opacity = 1, className = "" }) {
    const d =
      "M0 30 H180 l16 0 l9 -16 l13 32 l11 -40 l9 24 l8 0 H470 " +
      "l16 0 l9 -16 l13 32 l11 -40 l9 24 l8 0 H760 " +
      "l16 0 l9 -16 l13 32 l11 -40 l9 24 l8 0 H1050 " +
      "l16 0 l9 -16 l13 32 l11 -40 l9 24 l8 0 H1200";
    return React.createElement(
      "svg",
      {
        className, width: "100%", height, viewBox: "0 0 1200 60",
        preserveAspectRatio: "none", fill: "none", style: { display: "block", opacity }
      },
      React.createElement("path", {
        d, stroke: color, strokeWidth: stroke,
        strokeLinecap: "round", strokeLinejoin: "round", vectorEffect: "non-scaling-stroke"
      })
    );
  }

  // Decorative stylized QR (placeholder — user swaps for a real code).
  function FauxQR({ fg = "#004860", size = 116 }) {
    const cells = 13;
    const seed = [
      0b1111111, 0b1000001, 0b1011101, 0b1011101, 0b1011101, 0b1000001, 0b1111111
    ];
    // deterministic pattern
    const grid = [];
    for (let y = 0; y < cells; y++) {
      for (let x = 0; x < cells; x++) {
        const corner =
          (x < 4 && y < 4) || (x > cells - 5 && y < 4) || (x < 4 && y > cells - 5);
        if (corner) continue;
        const on = ((x * 7 + y * 13 + x * y) % 5 < 2);
        if (on) grid.push(React.createElement("rect", {
          key: x + "-" + y, x: x * 8 + 2, y: y * 8 + 2, width: 6, height: 6, rx: 1, fill: fg
        }));
      }
    }
    const finder = (gx, gy) => [
      React.createElement("rect", { key: "a" + gx + gy, x: gx, y: gy, width: 30, height: 30, rx: 5, fill: fg }),
      React.createElement("rect", { key: "b" + gx + gy, x: gx + 5, y: gy + 5, width: 20, height: 20, rx: 3, fill: "#fff" }),
      React.createElement("rect", { key: "c" + gx + gy, x: gx + 9, y: gy + 9, width: 12, height: 12, rx: 2, fill: fg })
    ];
    return React.createElement(
      "svg",
      { width: size, height: size, viewBox: "0 0 108 108", fill: "none" },
      grid, finder(2, 2), finder(76, 2), finder(2, 76)
    );
  }

  window.PulseIcons = Icons;
  window.PulseLine = PulseLine;
  window.FauxQR = FauxQR;
})();
