glitchgrab 1.61.1 → 1.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1470,24 +1470,102 @@ async function encodeImageFile(file, maxLength = MAX_SCREENSHOT_DATA_URL_LENGTH)
1470
1470
  }
1471
1471
  return readAsDataUrl(file);
1472
1472
  }
1473
- var PALETTE = ["#ef4444", "#f59e0b", "#22c55e", "#3b82f6", "#a855f7", "#ffffff"];
1473
+ var PALETTE = ["#ef4444", "#facc15", "#22c55e", "#3b82f6", "#a855f7", "#ffffff"];
1474
+ var TOOL_DEFAULTS = {
1475
+ pen: { color: PALETTE[0], width: 4 },
1476
+ highlighter: { color: "#facc15", width: 22 },
1477
+ rect: { color: PALETTE[0], width: 4 },
1478
+ circle: { color: PALETTE[0], width: 4 },
1479
+ arrow: { color: PALETTE[0], width: 4 }
1480
+ };
1481
+ var WIDTH_RANGE = {
1482
+ pen: { min: 2, max: 12 },
1483
+ highlighter: { min: 10, max: 40 },
1484
+ rect: { min: 2, max: 12 },
1485
+ circle: { min: 2, max: 12 },
1486
+ arrow: { min: 2, max: 12 }
1487
+ };
1488
+ var HIGHLIGHT_ALPHA = 0.45;
1489
+ var HIGHLIGHT_WASH_ALPHA = 0.22;
1490
+ var MIN_RECT_SIZE = 3;
1491
+ function normalizeRect(r) {
1492
+ return {
1493
+ ...r,
1494
+ x: r.w < 0 ? r.x + r.w : r.x,
1495
+ y: r.h < 0 ? r.y + r.h : r.y,
1496
+ w: Math.abs(r.w),
1497
+ h: Math.abs(r.h)
1498
+ };
1499
+ }
1500
+ function hitTestRect(strokes, p, tolerance, selected) {
1501
+ if (selected !== null) {
1502
+ const s = strokes[selected];
1503
+ if ((s == null ? void 0 : s.type) === "rect") {
1504
+ const corners = [
1505
+ ["nw", s.x, s.y],
1506
+ ["ne", s.x + s.w, s.y],
1507
+ ["sw", s.x, s.y + s.h],
1508
+ ["se", s.x + s.w, s.y + s.h]
1509
+ ];
1510
+ for (const [handle, cx, cy] of corners) {
1511
+ if (Math.abs(p.x - cx) <= tolerance && Math.abs(p.y - cy) <= tolerance) {
1512
+ return { index: selected, handle };
1513
+ }
1514
+ }
1515
+ if (insideRect(s, p, tolerance)) return { index: selected, handle: "move" };
1516
+ }
1517
+ }
1518
+ for (let i = strokes.length - 1; i >= 0; i--) {
1519
+ const s = strokes[i];
1520
+ if (s.type !== "rect" || i === selected) continue;
1521
+ const band = tolerance + s.width / 2;
1522
+ if (insideRect(s, p, band) && !insideRect(s, p, -band)) return { index: i, handle: "move" };
1523
+ }
1524
+ return null;
1525
+ }
1526
+ function insideRect(r, p, pad) {
1527
+ return p.x >= r.x - pad && p.x <= r.x + r.w + pad && p.y >= r.y - pad && p.y <= r.y + r.h + pad;
1528
+ }
1529
+ function dragRect(orig, handle, dx, dy) {
1530
+ if (handle === "move") return { ...orig, x: orig.x + dx, y: orig.y + dy };
1531
+ const left = handle === "nw" || handle === "sw" ? orig.x + dx : orig.x;
1532
+ const right = handle === "ne" || handle === "se" ? orig.x + orig.w + dx : orig.x + orig.w;
1533
+ const top = handle === "nw" || handle === "ne" ? orig.y + dy : orig.y;
1534
+ const bottom = handle === "sw" || handle === "se" ? orig.y + orig.h + dy : orig.y + orig.h;
1535
+ return normalizeRect({ ...orig, x: left, y: top, w: right - left, h: bottom - top });
1536
+ }
1537
+ function strokePath(ctx, points) {
1538
+ ctx.beginPath();
1539
+ ctx.moveTo(points[0].x, points[0].y);
1540
+ for (let i = 1; i < points.length; i++) ctx.lineTo(points[i].x, points[i].y);
1541
+ ctx.stroke();
1542
+ }
1474
1543
  function drawStroke(ctx, s) {
1544
+ ctx.save();
1475
1545
  ctx.strokeStyle = s.color;
1476
1546
  ctx.lineWidth = s.width;
1477
1547
  ctx.lineCap = "round";
1478
1548
  ctx.lineJoin = "round";
1479
1549
  if (s.type === "freehand") {
1480
- if (s.points.length < 2) return;
1481
- ctx.beginPath();
1482
- ctx.moveTo(s.points[0].x, s.points[0].y);
1483
- for (let i = 1; i < s.points.length; i++) ctx.lineTo(s.points[i].x, s.points[i].y);
1484
- ctx.stroke();
1550
+ if (s.points.length >= 2) strokePath(ctx, s.points);
1551
+ } else if (s.type === "highlight") {
1552
+ if (s.points.length >= 2) {
1553
+ ctx.lineCap = "butt";
1554
+ ctx.globalCompositeOperation = "multiply";
1555
+ ctx.globalAlpha = HIGHLIGHT_ALPHA;
1556
+ strokePath(ctx, s.points);
1557
+ ctx.globalCompositeOperation = "source-over";
1558
+ ctx.globalAlpha = HIGHLIGHT_WASH_ALPHA;
1559
+ strokePath(ctx, s.points);
1560
+ }
1561
+ } else if (s.type === "rect") {
1562
+ ctx.lineJoin = "miter";
1563
+ ctx.strokeRect(s.x, s.y, s.w, s.h);
1485
1564
  } else if (s.type === "circle") {
1486
1565
  ctx.beginPath();
1487
1566
  ctx.arc(s.cx, s.cy, s.r, 0, Math.PI * 2);
1488
1567
  ctx.stroke();
1489
- } else {
1490
- if (Math.hypot(s.x2 - s.x1, s.y2 - s.y1) < 3) return;
1568
+ } else if (Math.hypot(s.x2 - s.x1, s.y2 - s.y1) >= 3) {
1491
1569
  const angle = Math.atan2(s.y2 - s.y1, s.x2 - s.x1);
1492
1570
  const head = Math.max(14, s.width * 4);
1493
1571
  ctx.beginPath();
@@ -1498,16 +1576,57 @@ function drawStroke(ctx, s) {
1498
1576
  ctx.lineTo(s.x2 - head * Math.cos(angle + Math.PI / 6), s.y2 - head * Math.sin(angle + Math.PI / 6));
1499
1577
  ctx.stroke();
1500
1578
  }
1579
+ ctx.restore();
1580
+ }
1581
+ function paintOrder(strokes) {
1582
+ return [...strokes.filter((s) => s.type === "highlight"), ...strokes.filter((s) => s.type !== "highlight")];
1583
+ }
1584
+ function drawSelection(ctx, r, scale) {
1585
+ const pad = r.width / 2 + 3 * scale;
1586
+ const size = 9 * scale;
1587
+ ctx.save();
1588
+ ctx.strokeStyle = "#22d3ee";
1589
+ ctx.lineWidth = 1.5 * scale;
1590
+ ctx.setLineDash([5 * scale, 4 * scale]);
1591
+ ctx.strokeRect(r.x - pad, r.y - pad, r.w + pad * 2, r.h + pad * 2);
1592
+ ctx.setLineDash([]);
1593
+ ctx.fillStyle = "#ffffff";
1594
+ for (const [cx, cy] of [
1595
+ [r.x, r.y],
1596
+ [r.x + r.w, r.y],
1597
+ [r.x, r.y + r.h],
1598
+ [r.x + r.w, r.y + r.h]
1599
+ ]) {
1600
+ ctx.fillRect(cx - size / 2, cy - size / 2, size, size);
1601
+ ctx.strokeRect(cx - size / 2, cy - size / 2, size, size);
1602
+ }
1603
+ ctx.restore();
1604
+ }
1605
+ function paintAnnotations(ctx, img, strokes, current, selected, scale) {
1606
+ const { width, height } = ctx.canvas;
1607
+ ctx.clearRect(0, 0, width, height);
1608
+ ctx.drawImage(img, 0, 0, width, height);
1609
+ for (const s of paintOrder(current ? [...strokes, current] : strokes)) drawStroke(ctx, s);
1610
+ const sel = selected !== null ? strokes[selected] : void 0;
1611
+ if ((sel == null ? void 0 : sel.type) === "rect") drawSelection(ctx, sel, scale);
1612
+ }
1613
+ function cursorFor(handle) {
1614
+ if (handle === "move") return "move";
1615
+ if (handle === "nw" || handle === "se") return "nwse-resize";
1616
+ if (handle === "ne" || handle === "sw") return "nesw-resize";
1617
+ return "crosshair";
1501
1618
  }
1502
1619
  function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
1503
1620
  const canvasRef = useRef(null);
1504
1621
  const imgRef = useRef(null);
1622
+ const dragRef = useRef(null);
1505
1623
  const [ready, setReady] = useState(false);
1506
1624
  const [tool, setTool] = useState("pen");
1507
- const [color, setColor] = useState(PALETTE[0]);
1508
- const [strokeWidth, setStrokeWidth] = useState(4);
1625
+ const [settings, setSettings] = useState(TOOL_DEFAULTS);
1509
1626
  const [strokes, setStrokes] = useState([]);
1510
1627
  const [currentStroke, setCurrentStroke] = useState(null);
1628
+ const [selected, setSelected] = useState(null);
1629
+ const { color, width: strokeWidth } = settings[tool];
1511
1630
  useEffect(() => {
1512
1631
  const img = new Image();
1513
1632
  img.onload = () => {
@@ -1521,18 +1640,21 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
1521
1640
  };
1522
1641
  img.src = imageSrc;
1523
1642
  }, [imageSrc]);
1524
- useEffect(() => {
1525
- if (!ready) return;
1643
+ const displayScale = (canvas) => {
1644
+ const w = canvas.getBoundingClientRect().width;
1645
+ return w > 0 ? canvas.width / w : 1;
1646
+ };
1647
+ const paint = (showSelection) => {
1526
1648
  const canvas = canvasRef.current;
1527
1649
  const img = imgRef.current;
1528
1650
  if (!canvas || !img) return;
1529
1651
  const ctx = canvas.getContext("2d");
1530
1652
  if (!ctx) return;
1531
- ctx.clearRect(0, 0, canvas.width, canvas.height);
1532
- ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
1533
- for (const s of strokes) drawStroke(ctx, s);
1534
- if (currentStroke) drawStroke(ctx, currentStroke);
1535
- }, [ready, strokes, currentStroke]);
1653
+ paintAnnotations(ctx, img, strokes, currentStroke, showSelection ? selected : null, displayScale(canvas));
1654
+ };
1655
+ useEffect(() => {
1656
+ if (ready) paint(true);
1657
+ });
1536
1658
  const getPos = (e) => {
1537
1659
  const canvas = e.currentTarget;
1538
1660
  const rect = canvas.getBoundingClientRect();
@@ -1541,32 +1663,76 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
1541
1663
  y: (e.clientY - rect.top) * canvas.height / rect.height
1542
1664
  };
1543
1665
  };
1666
+ const hitAt = (canvas, p, pointerType) => tool === "rect" ? hitTestRect(strokes, p, (pointerType === "mouse" ? 8 : 16) * displayScale(canvas), selected) : null;
1544
1667
  const handlePointerDown = (e) => {
1545
1668
  e.currentTarget.setPointerCapture(e.pointerId);
1546
- const { x, y } = getPos(e);
1669
+ const p = getPos(e);
1670
+ const hit = hitAt(e.currentTarget, p, e.pointerType);
1671
+ if (hit) {
1672
+ setSelected(hit.index);
1673
+ dragRef.current = { index: hit.index, handle: hit.handle, start: p, orig: strokes[hit.index] };
1674
+ return;
1675
+ }
1676
+ setSelected(null);
1677
+ const { x, y } = p;
1678
+ const base = { color, width: strokeWidth };
1547
1679
  setCurrentStroke(
1548
- tool === "pen" ? { type: "freehand", color, width: strokeWidth, points: [{ x, y }] } : tool === "circle" ? { type: "circle", color, width: strokeWidth, cx: x, cy: y, r: 0 } : { type: "arrow", color, width: strokeWidth, x1: x, y1: y, x2: x, y2: y }
1680
+ tool === "pen" ? { type: "freehand", ...base, points: [p] } : tool === "highlighter" ? { type: "highlight", ...base, points: [p] } : tool === "rect" ? { type: "rect", ...base, x, y, w: 0, h: 0 } : tool === "circle" ? { type: "circle", ...base, cx: x, cy: y, r: 0 } : { type: "arrow", ...base, x1: x, y1: y, x2: x, y2: y }
1549
1681
  );
1550
1682
  };
1551
1683
  const handlePointerMove = (e) => {
1552
- if (!currentStroke) return;
1553
- const { x, y } = getPos(e);
1684
+ var _a;
1685
+ const p = getPos(e);
1686
+ const drag = dragRef.current;
1687
+ if (drag) {
1688
+ const next = dragRect(drag.orig, drag.handle, p.x - drag.start.x, p.y - drag.start.y);
1689
+ setStrokes((s) => s.map((st, i) => i === drag.index ? next : st));
1690
+ return;
1691
+ }
1692
+ if (!currentStroke) {
1693
+ e.currentTarget.style.cursor = cursorFor((_a = hitAt(e.currentTarget, p, e.pointerType)) == null ? void 0 : _a.handle);
1694
+ return;
1695
+ }
1696
+ const { x, y } = p;
1554
1697
  setCurrentStroke((prev) => {
1555
1698
  if (!prev) return prev;
1556
- if (prev.type === "freehand") return { ...prev, points: [...prev.points, { x, y }] };
1699
+ if (prev.type === "freehand" || prev.type === "highlight") return { ...prev, points: [...prev.points, p] };
1700
+ if (prev.type === "rect") return { ...prev, w: x - prev.x, h: y - prev.y };
1557
1701
  if (prev.type === "arrow") return { ...prev, x2: x, y2: y };
1558
1702
  return { ...prev, r: Math.hypot(x - prev.cx, y - prev.cy) };
1559
1703
  });
1560
1704
  };
1561
1705
  const handlePointerUp = () => {
1562
- setCurrentStroke((prev) => {
1563
- if (prev) setStrokes((s) => [...s, prev]);
1564
- return null;
1565
- });
1706
+ if (dragRef.current) {
1707
+ dragRef.current = null;
1708
+ return;
1709
+ }
1710
+ const done = currentStroke;
1711
+ setCurrentStroke(null);
1712
+ if (!done) return;
1713
+ if (done.type === "rect") {
1714
+ const r = normalizeRect(done);
1715
+ if (r.w < MIN_RECT_SIZE || r.h < MIN_RECT_SIZE) return;
1716
+ setStrokes((s) => [...s, r]);
1717
+ setSelected(strokes.length);
1718
+ return;
1719
+ }
1720
+ setStrokes((s) => [...s, done]);
1721
+ };
1722
+ const applySetting = (patch) => {
1723
+ setSettings((s) => ({ ...s, [tool]: { ...s[tool], ...patch } }));
1724
+ if (selected !== null) {
1725
+ setStrokes((s) => s.map((st, i) => i === selected && st.type === "rect" ? { ...st, ...patch } : st));
1726
+ }
1727
+ };
1728
+ const chooseTool = (t) => {
1729
+ setTool(t);
1730
+ setSelected(null);
1566
1731
  };
1567
1732
  const handleSave = () => {
1568
1733
  const canvas = canvasRef.current;
1569
1734
  if (!canvas) return;
1735
+ paint(false);
1570
1736
  onSave(encodeScreenshot(canvas));
1571
1737
  };
1572
1738
  const iconBtn = (active = false) => ({
@@ -1610,6 +1776,7 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
1610
1776
  onPointerDown: handlePointerDown,
1611
1777
  onPointerMove: handlePointerMove,
1612
1778
  onPointerUp: handlePointerUp,
1779
+ onPointerCancel: handlePointerUp,
1613
1780
  style: {
1614
1781
  maxWidth: "100%",
1615
1782
  maxHeight: "calc(100vh - 140px)",
@@ -1633,15 +1800,17 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
1633
1800
  maxWidth: "100%"
1634
1801
  },
1635
1802
  children: [
1636
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setTool("pen"), style: iconBtn(tool === "pen"), title: "Freehand", "aria-label": "Freehand tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M12 20h9M16.5 3.5a2.12 2.12 0 013 3L7 19l-4 1 1-4L16.5 3.5z", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
1637
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setTool("circle"), style: iconBtn(tool === "circle"), title: "Circle", "aria-label": "Circle tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "8", stroke: "currentColor", strokeWidth: "1.8" }) }) }),
1638
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setTool("arrow"), style: iconBtn(tool === "arrow"), title: "Arrow", "aria-label": "Arrow tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M5 19L19 5M19 5h-8M19 5v8", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
1803
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => chooseTool("pen"), style: iconBtn(tool === "pen"), title: "Freehand", "aria-label": "Freehand tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M12 20h9M16.5 3.5a2.12 2.12 0 013 3L7 19l-4 1 1-4L16.5 3.5z", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
1804
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => chooseTool("highlighter"), style: iconBtn(tool === "highlighter"), title: "Highlighter", "aria-label": "Highlighter tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M9 11l-6 6v3h9l3-3M22 12l-4.6 4.6a2 2 0 01-2.8 0l-5.2-5.2a2 2 0 010-2.8L14 4", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
1805
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => chooseTool("rect"), style: iconBtn(tool === "rect"), title: "Rectangle \u2014 drag to draw, then drag it or its corners to adjust", "aria-label": "Rectangle tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("rect", { x: "4", y: "5", width: "16", height: "14", rx: "1.5", stroke: "currentColor", strokeWidth: "1.8" }) }) }),
1806
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => chooseTool("circle"), style: iconBtn(tool === "circle"), title: "Circle", "aria-label": "Circle tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "8", stroke: "currentColor", strokeWidth: "1.8" }) }) }),
1807
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => chooseTool("arrow"), style: iconBtn(tool === "arrow"), title: "Arrow", "aria-label": "Arrow tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M5 19L19 5M19 5h-8M19 5v8", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
1639
1808
  /* @__PURE__ */ jsx("div", { style: { width: "1px", height: "20px", background: "rgba(255,255,255,0.15)" } }),
1640
1809
  PALETTE.map((c) => /* @__PURE__ */ jsx(
1641
1810
  "button",
1642
1811
  {
1643
1812
  type: "button",
1644
- onClick: () => setColor(c),
1813
+ onClick: () => applySetting({ color: c }),
1645
1814
  "aria-label": `Color ${c}`,
1646
1815
  style: {
1647
1816
  width: "22px",
@@ -1660,7 +1829,7 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
1660
1829
  {
1661
1830
  type: "color",
1662
1831
  value: color,
1663
- onChange: (e) => setColor(e.target.value),
1832
+ onChange: (e) => applySetting({ color: e.target.value }),
1664
1833
  title: "Custom color",
1665
1834
  "aria-label": "Custom color",
1666
1835
  style: {
@@ -1678,11 +1847,11 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
1678
1847
  "input",
1679
1848
  {
1680
1849
  type: "range",
1681
- min: 2,
1682
- max: 12,
1850
+ min: WIDTH_RANGE[tool].min,
1851
+ max: WIDTH_RANGE[tool].max,
1683
1852
  value: strokeWidth,
1684
- onChange: (e) => setStrokeWidth(Number(e.target.value)),
1685
- title: "Stroke width",
1853
+ onChange: (e) => applySetting({ width: Number(e.target.value) }),
1854
+ title: tool === "rect" ? "Border thickness" : "Stroke width",
1686
1855
  "aria-label": "Stroke width",
1687
1856
  style: { width: "70px" }
1688
1857
  }
@@ -1692,7 +1861,10 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
1692
1861
  "button",
1693
1862
  {
1694
1863
  type: "button",
1695
- onClick: () => setStrokes((s) => s.slice(0, -1)),
1864
+ onClick: () => {
1865
+ setStrokes((s) => s.slice(0, -1));
1866
+ setSelected(null);
1867
+ },
1696
1868
  disabled: strokes.length === 0,
1697
1869
  style: { ...iconBtn(), opacity: strokes.length === 0 ? 0.35 : 1 },
1698
1870
  title: "Undo",
@@ -1704,7 +1876,10 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
1704
1876
  "button",
1705
1877
  {
1706
1878
  type: "button",
1707
- onClick: () => setStrokes([]),
1879
+ onClick: () => {
1880
+ setStrokes([]);
1881
+ setSelected(null);
1882
+ },
1708
1883
  disabled: strokes.length === 0,
1709
1884
  style: { ...iconBtn(), opacity: strokes.length === 0 ? 0.35 : 1 },
1710
1885
  title: "Clear all",
@@ -3793,33 +3968,37 @@ function AssistSheet({
3793
3968
  gap: "6px",
3794
3969
  paddingLeft: "32px"
3795
3970
  },
3796
- children: options.map((option) => /* @__PURE__ */ jsx3(
3797
- "button",
3798
- {
3799
- type: "button",
3800
- "data-gg-chip": "",
3801
- "data-gg-option": "",
3802
- onClick: () => {
3803
- logEvent("option_tap", option);
3804
- send(option, option === CONFIRM_OPTION);
3805
- },
3806
- style: {
3807
- border: `1px solid ${t.inputBorder}`,
3808
- background: "transparent",
3809
- color: t.textMuted,
3810
- borderRadius: "999px",
3811
- // Same 8px as the picker chips — one tap target size in
3812
- // this sheet, not two.
3813
- padding: "8px 12px",
3814
- fontSize: "12px",
3815
- fontFamily: "inherit",
3816
- cursor: "pointer",
3817
- textAlign: "left"
3971
+ children: options.map((option) => {
3972
+ const primary = option === CONFIRM_OPTION;
3973
+ return /* @__PURE__ */ jsx3(
3974
+ "button",
3975
+ {
3976
+ type: "button",
3977
+ "data-gg-chip": "",
3978
+ "data-gg-option": "",
3979
+ onClick: () => {
3980
+ logEvent("option_tap", option);
3981
+ send(option, option === CONFIRM_OPTION);
3982
+ },
3983
+ style: {
3984
+ border: primary ? "1px solid transparent" : `1px solid ${t.inputBorder}`,
3985
+ background: primary ? t.accent : "transparent",
3986
+ color: primary ? t.accentText : t.textMuted,
3987
+ fontWeight: primary ? 600 : void 0,
3988
+ borderRadius: "999px",
3989
+ // Same 8px as the picker chips — one tap target size in
3990
+ // this sheet, not two.
3991
+ padding: "8px 12px",
3992
+ fontSize: "12px",
3993
+ fontFamily: "inherit",
3994
+ cursor: "pointer",
3995
+ textAlign: "left"
3996
+ },
3997
+ children: option
3818
3998
  },
3819
- children: option
3820
- },
3821
- option
3822
- ))
3999
+ option
4000
+ );
4001
+ })
3823
4002
  }
3824
4003
  ),
3825
4004
  busy && /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "8px", minWidth: 0 }, role: "status", "aria-label": "Thinking", children: [