@githumbi/grabby 0.3.0 → 0.5.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.
@@ -679,6 +679,7 @@ function createCrosshair() {
679
679
  let hLine = null;
680
680
  let vLine = null;
681
681
  let listening = false;
682
+ let held = false;
682
683
  function injectStyles2() {
683
684
  if (hasStyles(CROSSHAIR_STYLE_ID)) return;
684
685
  addStyles(CROSSHAIR_STYLE_ID, `
@@ -701,7 +702,7 @@ function createCrosshair() {
701
702
  width: 1px;
702
703
  }
703
704
  `);
704
- addStyles(CURSOR_STYLE_ID, "body.grabby-crosshair-active { cursor: crosshair !important; }", "document");
705
+ addStyles(CURSOR_STYLE_ID, "body.grabby-crosshair-active:not(.grabby-crosshair-held) { cursor: crosshair !important; }", "document");
705
706
  }
706
707
  function ensureElements() {
707
708
  if (!hLine) {
@@ -718,7 +719,12 @@ function createCrosshair() {
718
719
  getUiRoot().appendChild(vLine);
719
720
  }
720
721
  }
722
+ function hideLines() {
723
+ if (hLine) hLine.style.top = "-10px";
724
+ if (vLine) vLine.style.left = "-10px";
725
+ }
721
726
  function handleMouseMove(e) {
727
+ if (held) return;
722
728
  if (hLine) {
723
729
  hLine.style.top = `${e.clientY}px`;
724
730
  }
@@ -739,13 +745,19 @@ function createCrosshair() {
739
745
  listening = false;
740
746
  document.body.classList.remove("grabby-crosshair-active");
741
747
  document.removeEventListener("mousemove", handleMouseMove, true);
742
- if (hLine) hLine.style.top = "-10px";
743
- if (vLine) vLine.style.left = "-10px";
748
+ hideLines();
749
+ },
750
+ hold(on) {
751
+ if (held === on) return;
752
+ held = on;
753
+ document.body.classList.toggle("grabby-crosshair-held", on);
754
+ if (on) hideLines();
744
755
  },
745
756
  isCrosshairElement(el) {
746
757
  return el === hLine || el === vLine || el.id === H_LINE_ID || el.id === V_LINE_ID;
747
758
  },
748
759
  dispose() {
760
+ this.hold(false);
749
761
  this.deactivate();
750
762
  _optionalChain([hLine, 'optionalAccess', _17 => _17.remove, 'call', _18 => _18()]);
751
763
  _optionalChain([vLine, 'optionalAccess', _19 => _19.remove, 'call', _20 => _20()]);
@@ -1148,6 +1160,7 @@ function buildUniqueSelector(el) {
1148
1160
  // src/core/picker/element-picker.ts
1149
1161
  function createElementPicker(deps) {
1150
1162
  let hoveredElement = null;
1163
+ let heldElement = null;
1151
1164
  let listening = false;
1152
1165
  function resolveComponentName(el) {
1153
1166
  const resolver = deps.getComponentResolver();
@@ -1178,17 +1191,21 @@ function createElementPicker(deps) {
1178
1191
  if (!raw || raw.closest(`[${IGNORE_ATTR}]`)) return raw && _optionalChain([deps, 'access', _33 => _33.isToolbarElement, 'optionalCall', _34 => _34(raw)]) ? raw : null;
1179
1192
  return exact ? raw : promoteTarget(raw);
1180
1193
  }
1194
+ function showOverlay(target) {
1195
+ const componentName = resolveComponentName(target);
1196
+ const sourcePath = resolveSourcePath(target);
1197
+ const cssClasses = filterAngularClasses(target.classList);
1198
+ deps.overlay.show(target, componentName, sourcePath, cssClasses);
1199
+ }
1181
1200
  function handleMouseMove(e) {
1201
+ if (heldElement) return;
1182
1202
  const target = elementAtPoint(e.clientX, e.clientY, e.shiftKey);
1183
1203
  if (!target || deps.overlay.isOverlayElement(target)) return;
1184
1204
  if (deps.crosshair.isCrosshairElement(target)) return;
1185
1205
  if (_optionalChain([deps, 'access', _35 => _35.isToolbarElement, 'optionalCall', _36 => _36(target)])) return;
1186
1206
  if (target === hoveredElement) return;
1187
1207
  hoveredElement = target;
1188
- const componentName = resolveComponentName(target);
1189
- const sourcePath = resolveSourcePath(target);
1190
- const cssClasses = filterAngularClasses(target.classList);
1191
- deps.overlay.show(target, componentName, sourcePath, cssClasses);
1208
+ showOverlay(target);
1192
1209
  deps.onHover(target);
1193
1210
  }
1194
1211
  function handleClick(e) {
@@ -1198,8 +1215,9 @@ function createElementPicker(deps) {
1198
1215
  if (target && (_optionalChain([deps, 'access', _39 => _39.isToolbarElement, 'optionalCall', _40 => _40(target)]) || deps.crosshair.isCrosshairElement(target))) return;
1199
1216
  e.preventDefault();
1200
1217
  e.stopPropagation();
1218
+ if (heldElement) return;
1201
1219
  if (hoveredElement) {
1202
- deps.onSelect(hoveredElement);
1220
+ deps.onSelect(hoveredElement, { x: e.clientX, y: e.clientY });
1203
1221
  }
1204
1222
  }
1205
1223
  return {
@@ -1214,12 +1232,29 @@ function createElementPicker(deps) {
1214
1232
  if (!listening) return;
1215
1233
  listening = false;
1216
1234
  hoveredElement = null;
1235
+ heldElement = null;
1236
+ deps.crosshair.hold(false);
1217
1237
  deps.crosshair.deactivate();
1218
1238
  document.removeEventListener("mousemove", handleMouseMove, true);
1219
1239
  document.removeEventListener("click", handleClick, true);
1220
1240
  deps.overlay.hide();
1221
1241
  deps.onHover(null);
1222
1242
  },
1243
+ hold(element) {
1244
+ if (!listening) return;
1245
+ heldElement = element;
1246
+ hoveredElement = element;
1247
+ deps.crosshair.hold(true);
1248
+ showOverlay(element);
1249
+ },
1250
+ release() {
1251
+ if (!heldElement) return;
1252
+ heldElement = null;
1253
+ deps.crosshair.hold(false);
1254
+ },
1255
+ isHolding() {
1256
+ return heldElement !== null;
1257
+ },
1223
1258
  getHoveredElement() {
1224
1259
  return hoveredElement;
1225
1260
  },
@@ -1440,7 +1475,8 @@ function createWebhookPlugin(url) {
1440
1475
  type: "grabby.comment",
1441
1476
  version: 1,
1442
1477
  origin: typeof location !== "undefined" ? location.origin : null,
1443
- comment
1478
+ // The marker position is browser-only.
1479
+ comment: { ...comment, pin: void 0 }
1444
1480
  })
1445
1481
  }).catch(() => {
1446
1482
  });
@@ -1532,6 +1568,9 @@ ${vars.join("\n")}
1532
1568
 
1533
1569
  // src/core/toolbar/toolbar-renderer.ts
1534
1570
  var TOOLBAR_ID = "__grabby-toolbar__";
1571
+ var COLLAPSED_SIZE = 42;
1572
+ var EASE_OUT_EXPO = "cubic-bezier(0.19, 1, 0.22, 1)";
1573
+ var MORPH_MS = 360;
1535
1574
  var STYLE_ID3 = "__grabby-toolbar-styles__";
1536
1575
  function syncSummary(comments) {
1537
1576
  if (comments.length === 0) return null;
@@ -1552,6 +1591,14 @@ function createToolbarRenderer(callbacks, options = {}) {
1552
1591
  let allElements = /* @__PURE__ */ new Set();
1553
1592
  let badge = null;
1554
1593
  let status = null;
1594
+ let expandBadge = null;
1595
+ let content = null;
1596
+ let collapsed = false;
1597
+ let morphTimer = null;
1598
+ function clearMorph() {
1599
+ if (morphTimer) clearTimeout(morphTimer);
1600
+ morphTimer = null;
1601
+ }
1555
1602
  function injectStyles2() {
1556
1603
  if (hasStyles(STYLE_ID3)) return;
1557
1604
  addStyles(STYLE_ID3, `
@@ -1571,7 +1618,21 @@ function createToolbarRenderer(callbacks, options = {}) {
1571
1618
  box-shadow: 0 4px 16px var(--grabby-toolbar-shadow, rgba(0, 0, 0, 0.12));
1572
1619
  pointer-events: auto;
1573
1620
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
1574
- transition: opacity 0.2s ease, transform 0.2s ease;
1621
+ box-sizing: border-box;
1622
+ height: ${COLLAPSED_SIZE}px;
1623
+ overflow: hidden;
1624
+ justify-content: flex-end;
1625
+ transition: opacity 0.2s ease, transform 0.2s ease,
1626
+ left ${MORPH_MS}ms ${EASE_OUT_EXPO}, width ${MORPH_MS}ms ${EASE_OUT_EXPO};
1627
+ }
1628
+ #${TOOLBAR_ID} .grabby-toolbar-content {
1629
+ display: flex;
1630
+ align-items: center;
1631
+ gap: 2px;
1632
+ flex-shrink: 0;
1633
+ transform-origin: right center;
1634
+ transition: opacity 0.24s ease-out, filter 0.3s cubic-bezier(0.22, 1, 0.36, 1),
1635
+ transform 0.42s ${EASE_OUT_EXPO}, visibility 0s;
1575
1636
  }
1576
1637
  #${TOOLBAR_ID}.grabby-toolbar-hidden {
1577
1638
  opacity: 0;
@@ -1667,6 +1728,45 @@ function createToolbarRenderer(callbacks, options = {}) {
1667
1728
  background: var(--grabby-accent-hover, #1d4ed8);
1668
1729
  color: #fff;
1669
1730
  }
1731
+ #${TOOLBAR_ID} button.grabby-btn-expand {
1732
+ position: absolute;
1733
+ left: 50%;
1734
+ top: 50%;
1735
+ translate: -50% -50%;
1736
+ color: var(--grabby-accent, #2563eb);
1737
+ opacity: 0;
1738
+ scale: 0.6;
1739
+ visibility: hidden;
1740
+ pointer-events: none;
1741
+ transition: opacity 0.2s ease-out, scale 0.3s ${EASE_OUT_EXPO}, visibility 0s 0.2s;
1742
+ }
1743
+ #${TOOLBAR_ID} button.grabby-btn-expand .grabby-badge { top: -3px; right: -5px; }
1744
+ #${TOOLBAR_ID}.grabby-toolbar-collapsed {
1745
+ left: calc(100% - 20px - ${COLLAPSED_SIZE / 2}px);
1746
+ padding: 4px;
1747
+ }
1748
+ #${TOOLBAR_ID}.grabby-toolbar-collapsed .grabby-toolbar-content {
1749
+ opacity: 0;
1750
+ filter: blur(6px);
1751
+ transform: scale(0.4);
1752
+ pointer-events: none;
1753
+ visibility: hidden;
1754
+ transition: opacity 0.24s ease-out, filter 0.3s cubic-bezier(0.22, 1, 0.36, 1),
1755
+ transform 0.42s ${EASE_OUT_EXPO}, visibility 0s 0.3s;
1756
+ }
1757
+ #${TOOLBAR_ID}.grabby-toolbar-collapsed button.grabby-btn-expand {
1758
+ opacity: 1;
1759
+ scale: 1;
1760
+ visibility: visible;
1761
+ pointer-events: auto;
1762
+ transition: opacity 0.24s ease-out 0.08s, scale 0.36s ${EASE_OUT_EXPO} 0.08s, visibility 0s;
1763
+ }
1764
+ @media (prefers-reduced-motion: reduce) {
1765
+ #${TOOLBAR_ID}, #${TOOLBAR_ID} .grabby-toolbar-content, #${TOOLBAR_ID} button.grabby-btn-expand {
1766
+ transition-duration: 0s !important;
1767
+ transition-delay: 0s !important;
1768
+ }
1769
+ }
1670
1770
  #${TOOLBAR_ID} .grabby-toolbar-left.grabby-toolbar-left-hidden {
1671
1771
  max-width: 0;
1672
1772
  opacity: 0;
@@ -1707,6 +1807,12 @@ function createToolbarRenderer(callbacks, options = {}) {
1707
1807
  buttons.history.appendChild(badge);
1708
1808
  buttons.enable = createButton("enable", ICON_POWER, "Enable/Disable", callbacks.onEnableToggle);
1709
1809
  buttons.dismiss = createButton("dismiss", ICON_DISMISS, _nullishCoalesce(options.dismissLabel, () => ( "Dismiss toolbar")), callbacks.onDismiss);
1810
+ buttons.expand = createButton("expand", ICON_GRAB, _nullishCoalesce(options.expandLabel, () => ( "Open Grabby toolbar")), () => _optionalChain([callbacks, 'access', _45 => _45.onExpand, 'optionalCall', _46 => _46()]));
1811
+ buttons.expand.classList.add("grabby-btn-expand");
1812
+ expandBadge = document.createElement("span");
1813
+ expandBadge.className = "grabby-badge";
1814
+ expandBadge.hidden = true;
1815
+ buttons.expand.appendChild(expandBadge);
1710
1816
  const divider = document.createElement("span");
1711
1817
  divider.className = "grabby-toolbar-divider";
1712
1818
  leftGroup = document.createElement("div");
@@ -1714,7 +1820,9 @@ function createToolbarRenderer(callbacks, options = {}) {
1714
1820
  leftGroup.appendChild(buttons.selection);
1715
1821
  leftGroup.appendChild(buttons.history);
1716
1822
  leftGroup.appendChild(divider);
1717
- container.appendChild(leftGroup);
1823
+ content = document.createElement("div");
1824
+ content.className = "grabby-toolbar-content";
1825
+ content.appendChild(leftGroup);
1718
1826
  if (options.review) {
1719
1827
  status = document.createElement("span");
1720
1828
  status.className = "grabby-toolbar-status";
@@ -1729,18 +1837,24 @@ function createToolbarRenderer(callbacks, options = {}) {
1729
1837
  buttons.finish.addEventListener("click", (e) => {
1730
1838
  e.preventDefault();
1731
1839
  e.stopPropagation();
1732
- _optionalChain([callbacks, 'access', _45 => _45.onFinish, 'optionalCall', _46 => _46()]);
1840
+ _optionalChain([callbacks, 'access', _47 => _47.onFinish, 'optionalCall', _48 => _48()]);
1733
1841
  });
1734
- container.appendChild(status);
1735
- container.appendChild(buttons.finish);
1842
+ content.appendChild(status);
1843
+ content.appendChild(buttons.finish);
1736
1844
  allElements.add(status);
1737
1845
  }
1738
- if (!options.hideEnable) container.appendChild(buttons.enable);
1739
- container.appendChild(buttons.dismiss);
1846
+ if (!options.hideEnable) content.appendChild(buttons.enable);
1847
+ content.appendChild(buttons.dismiss);
1848
+ container.append(content, buttons.expand);
1849
+ if (collapsed) {
1850
+ container.classList.add("grabby-toolbar-collapsed");
1851
+ container.style.width = `${COLLAPSED_SIZE}px`;
1852
+ }
1740
1853
  getUiRoot().appendChild(container);
1741
1854
  allElements.clear();
1742
1855
  allElements.add(container);
1743
1856
  allElements.add(leftGroup);
1857
+ allElements.add(content);
1744
1858
  allElements.add(divider);
1745
1859
  for (const btn of Object.values(buttons)) {
1746
1860
  allElements.add(btn);
@@ -1764,26 +1878,54 @@ function createToolbarRenderer(callbacks, options = {}) {
1764
1878
  buttons.selection.classList.remove("grabby-btn-active");
1765
1879
  }
1766
1880
  const count = state.toolbar.comments.length;
1767
- if (badge) {
1768
- badge.hidden = count === 0;
1769
- badge.textContent = count > 99 ? "99+" : String(count);
1881
+ for (const b of [badge, expandBadge]) {
1882
+ if (!b) continue;
1883
+ b.hidden = count === 0;
1884
+ b.textContent = count > 99 ? "99+" : String(count);
1770
1885
  }
1771
1886
  buttons.history.setAttribute("aria-label", count ? `Comments (${count})` : "Comments");
1772
1887
  if (status && buttons.finish) {
1773
1888
  const summary = syncSummary(state.toolbar.comments);
1774
1889
  status.hidden = !summary;
1775
- status.textContent = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _47 => _47.text]), () => ( ""));
1776
- status.dataset.tone = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _48 => _48.tone]), () => ( ""));
1890
+ status.textContent = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _49 => _49.text]), () => ( ""));
1891
+ status.dataset.tone = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _50 => _50.tone]), () => ( ""));
1777
1892
  buttons.finish.hidden = count === 0;
1778
1893
  }
1779
1894
  if (state.options.enabled) {
1780
1895
  buttons.enable.classList.add("grabby-btn-active");
1781
- _optionalChain([leftGroup, 'optionalAccess', _49 => _49.classList, 'access', _50 => _50.remove, 'call', _51 => _51("grabby-toolbar-left-hidden")]);
1896
+ _optionalChain([leftGroup, 'optionalAccess', _51 => _51.classList, 'access', _52 => _52.remove, 'call', _53 => _53("grabby-toolbar-left-hidden")]);
1782
1897
  } else {
1783
1898
  buttons.enable.classList.remove("grabby-btn-active");
1784
- _optionalChain([leftGroup, 'optionalAccess', _52 => _52.classList, 'access', _53 => _53.add, 'call', _54 => _54("grabby-toolbar-left-hidden")]);
1899
+ _optionalChain([leftGroup, 'optionalAccess', _54 => _54.classList, 'access', _55 => _55.add, 'call', _56 => _56("grabby-toolbar-left-hidden")]);
1785
1900
  }
1786
1901
  },
1902
+ collapse() {
1903
+ if (collapsed) return;
1904
+ collapsed = true;
1905
+ if (!container) return;
1906
+ clearMorph();
1907
+ container.style.width = `${container.offsetWidth}px`;
1908
+ void container.offsetWidth;
1909
+ container.classList.add("grabby-toolbar-collapsed");
1910
+ container.style.width = `${COLLAPSED_SIZE}px`;
1911
+ },
1912
+ expand() {
1913
+ if (!collapsed) return;
1914
+ collapsed = false;
1915
+ if (!container) return;
1916
+ clearMorph();
1917
+ container.classList.remove("grabby-toolbar-collapsed");
1918
+ const cs = getComputedStyle(container);
1919
+ const chrome = ["paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"].reduce((sum, k) => sum + (parseFloat(cs[k]) || 0), 0);
1920
+ container.style.width = `${(_nullishCoalesce(_optionalChain([content, 'optionalAccess', _57 => _57.offsetWidth]), () => ( 0))) + chrome}px`;
1921
+ morphTimer = setTimeout(() => {
1922
+ morphTimer = null;
1923
+ if (!collapsed && container) container.style.width = "";
1924
+ }, MORPH_MS + 40);
1925
+ },
1926
+ isCollapsed() {
1927
+ return collapsed;
1928
+ },
1787
1929
  isToolbarElement(el) {
1788
1930
  if (allElements.has(el)) return true;
1789
1931
  let current = el;
@@ -1795,12 +1937,15 @@ function createToolbarRenderer(callbacks, options = {}) {
1795
1937
  return false;
1796
1938
  },
1797
1939
  dispose() {
1798
- _optionalChain([container, 'optionalAccess', _55 => _55.remove, 'call', _56 => _56()]);
1940
+ clearMorph();
1941
+ _optionalChain([container, 'optionalAccess', _58 => _58.remove, 'call', _59 => _59()]);
1799
1942
  removeStyles(STYLE_ID3);
1800
1943
  container = null;
1801
1944
  leftGroup = null;
1945
+ content = null;
1802
1946
  buttons = {};
1803
1947
  badge = null;
1948
+ expandBadge = null;
1804
1949
  status = null;
1805
1950
  allElements.clear();
1806
1951
  }
@@ -1845,7 +1990,7 @@ function header(comments, env, ctx) {
1845
1990
  if (frameworks.length) meta.push(frameworks.join(", "));
1846
1991
  const routes = uniq(comments.map((c) => c.page.route));
1847
1992
  if (!ctx.showRoutes && routes.length === 1) meta.push(`page ${routes[0]}`);
1848
- const vp = _optionalChain([comments, 'access', _57 => _57[0], 'optionalAccess', _58 => _58.page, 'access', _59 => _59.viewport]);
1993
+ const vp = _optionalChain([comments, 'access', _60 => _60[0], 'optionalAccess', _61 => _61.page, 'access', _62 => _62.viewport]);
1849
1994
  if (vp) meta.push(`${vp[0]}\xD7${vp[1]}`);
1850
1995
  meta.push((_nullishCoalesce(env.now, () => ( /* @__PURE__ */ new Date()))).toISOString().slice(0, 10));
1851
1996
  lines.push(meta.join(" \xB7 "));
@@ -1871,8 +2016,8 @@ function detailBlock(c, i, ctx, groupHasSource, headedComponent) {
1871
2016
  const b = (text) => lines.push(` - ${text}`);
1872
2017
  const where = [`\`${t.preview}\``, `(${t.kind})`];
1873
2018
  if (t.component && t.component !== headedComponent) {
1874
- where.push(_optionalChain([t, 'access', _60 => _60.source, 'optionalAccess', _61 => _61.line]) != null && groupHasSource ? `${t.component} line ${t.source.line}` : t.component);
1875
- } else if (_optionalChain([t, 'access', _62 => _62.source, 'optionalAccess', _63 => _63.line]) != null && groupHasSource) {
2019
+ where.push(_optionalChain([t, 'access', _63 => _63.source, 'optionalAccess', _64 => _64.line]) != null && groupHasSource ? `${t.component} line ${t.source.line}` : t.component);
2020
+ } else if (_optionalChain([t, 'access', _65 => _65.source, 'optionalAccess', _66 => _66.line]) != null && groupHasSource) {
1876
2021
  where.push(`line ${t.source.line}`);
1877
2022
  }
1878
2023
  b(where.join(" "));
@@ -1888,7 +2033,7 @@ function detailBlock(c, i, ctx, groupHasSource, headedComponent) {
1888
2033
  for (const [k, v] of Object.entries(t.extra)) b(`${k}: ${v}`);
1889
2034
  b(`viewport: ${c.page.viewport[0]}\xD7${c.page.viewport[1]}`);
1890
2035
  }
1891
- if (_optionalChain([c, 'access', _64 => _64.screenshot, 'optionalAccess', _65 => _65.url])) b(`screenshot: ${c.screenshot.url}`);
2036
+ if (_optionalChain([c, 'access', _67 => _67.screenshot, 'optionalAccess', _68 => _68.url])) b(`screenshot: ${c.screenshot.url}`);
1892
2037
  const meta = [];
1893
2038
  if (ctx.showAuthors) meta.push(`by ${authorLabel(c.author)}`);
1894
2039
  if (ctx.showRoutes) meta.push(`on ${c.page.route}`);
@@ -1914,7 +2059,7 @@ function formatExport(comments, level = "standard", env = {}) {
1914
2059
  }
1915
2060
  const groups = /* @__PURE__ */ new Map();
1916
2061
  for (const c of ordered) {
1917
- const key = _nullishCoalesce(_optionalChain([c, 'access', _66 => _66.target, 'access', _67 => _67.source, 'optionalAccess', _68 => _68.file]), () => ( ""));
2062
+ const key = _nullishCoalesce(_optionalChain([c, 'access', _69 => _69.target, 'access', _70 => _70.source, 'optionalAccess', _71 => _71.file]), () => ( ""));
1918
2063
  const list = groups.get(key);
1919
2064
  if (list) list.push(c);
1920
2065
  else groups.set(key, [c]);
@@ -1924,7 +2069,7 @@ function formatExport(comments, level = "standard", env = {}) {
1924
2069
  out.push("");
1925
2070
  const components = uniq(list.map((c) => c.target.component));
1926
2071
  const headed = file && components.length === 1 ? components[0] : null;
1927
- const lines = uniq(list.map((c) => _nullishCoalesce(_optionalChain([c, 'access', _69 => _69.target, 'access', _70 => _70.source, 'optionalAccess', _71 => _71.line]), () => ( null))));
2072
+ const lines = uniq(list.map((c) => _nullishCoalesce(_optionalChain([c, 'access', _72 => _72.target, 'access', _73 => _73.source, 'optionalAccess', _74 => _74.line]), () => ( null))));
1928
2073
  if (file) {
1929
2074
  const loc = lines.length === 1 ? location2(file, lines[0], true) : file;
1930
2075
  out.push(`## ${loc}${headed ? ` \xB7 ${headed}` : ""}`);
@@ -2109,7 +2254,7 @@ function createCommentsPanel(callbacks, options = {}) {
2109
2254
  let visible = false;
2110
2255
  let objectUrls = [];
2111
2256
  function ensurePanel() {
2112
- if (_optionalChain([panel, 'optionalAccess', _72 => _72.isConnected])) return panel;
2257
+ if (_optionalChain([panel, 'optionalAccess', _75 => _75.isConnected])) return panel;
2113
2258
  addStyles(STYLE_ID4, CSS2);
2114
2259
  panel = h("div", { id: PANEL_ID, role: "dialog", "aria-label": "Comments" });
2115
2260
  getUiRoot().appendChild(panel);
@@ -2120,7 +2265,7 @@ function createCommentsPanel(callbacks, options = {}) {
2120
2265
  objectUrls = [];
2121
2266
  }
2122
2267
  function thumbnail(comment) {
2123
- const localId = _optionalChain([comment, 'access', _73 => _73.screenshot, 'optionalAccess', _74 => _74.localId]);
2268
+ const localId = _optionalChain([comment, 'access', _76 => _76.screenshot, 'optionalAccess', _77 => _77.localId]);
2124
2269
  if (!localId) return null;
2125
2270
  const img = h("img", { class: "grabby-thumb", alt: "", loading: "lazy" });
2126
2271
  img.addEventListener("error", () => img.remove(), { once: true });
@@ -2229,7 +2374,7 @@ function createCommentsPanel(callbacks, options = {}) {
2229
2374
  h("strong", null, live ? "Nothing sent yet" : "No comments yet"),
2230
2375
  live ? "Click Comment, then click the part of the page you want to talk about." : "Click the hand icon (or press Alt+G), then click anything on the page to comment on it."
2231
2376
  ) : h("div", { class: "grabby-panel-list" }, ...comments.map((c) => row2(c, showAuthors)));
2232
- const who = _nullishCoalesce(_optionalChain([options, 'access', _75 => _75.identityLabel, 'optionalCall', _76 => _76()]), () => ( null));
2377
+ const who = _nullishCoalesce(_optionalChain([options, 'access', _78 => _78.identityLabel, 'optionalCall', _79 => _79()]), () => ( null));
2233
2378
  let footer = null;
2234
2379
  if (live && who) {
2235
2380
  footer = h(
@@ -2242,7 +2387,7 @@ function createCommentsPanel(callbacks, options = {}) {
2242
2387
  "data-grabby-change-identity": "",
2243
2388
  onclick: (e) => {
2244
2389
  e.stopPropagation();
2245
- _optionalChain([callbacks, 'access', _77 => _77.onChangeIdentity, 'optionalCall', _78 => _78()]);
2390
+ _optionalChain([callbacks, 'access', _80 => _80.onChangeIdentity, 'optionalCall', _81 => _81()]);
2246
2391
  }
2247
2392
  }, "Change")
2248
2393
  );
@@ -2276,7 +2421,7 @@ function createCommentsPanel(callbacks, options = {}) {
2276
2421
  },
2277
2422
  hide() {
2278
2423
  visible = false;
2279
- _optionalChain([panel, 'optionalAccess', _79 => _79.classList, 'access', _80 => _80.remove, 'call', _81 => _81("grabby-popover-visible")]);
2424
+ _optionalChain([panel, 'optionalAccess', _82 => _82.classList, 'access', _83 => _83.remove, 'call', _84 => _84("grabby-popover-visible")]);
2280
2425
  },
2281
2426
  isVisible() {
2282
2427
  return visible;
@@ -2286,7 +2431,7 @@ function createCommentsPanel(callbacks, options = {}) {
2286
2431
  },
2287
2432
  dispose() {
2288
2433
  revokeThumbs();
2289
- _optionalChain([panel, 'optionalAccess', _82 => _82.remove, 'call', _83 => _83()]);
2434
+ _optionalChain([panel, 'optionalAccess', _85 => _85.remove, 'call', _86 => _86()]);
2290
2435
  removeStyles(STYLE_ID4);
2291
2436
  panel = null;
2292
2437
  visible = false;
@@ -2367,6 +2512,18 @@ function createCommentPopover(callbacks) {
2367
2512
  font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 4px; border: none;
2368
2513
  background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer; text-decoration: underline;
2369
2514
  }
2515
+ #${POPOVER_ID} .grabby-cp-edit-actions { display: flex; align-items: center; gap: 6px; }
2516
+ #${POPOVER_ID} .grabby-cp-edit-actions .grabby-cp-spacer { flex: 1; }
2517
+ #${POPOVER_ID} .grabby-cp-delete {
2518
+ font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 6px; border: none;
2519
+ border-radius: 8px; background: transparent; color: #b91c1c; cursor: pointer;
2520
+ }
2521
+ #${POPOVER_ID} .grabby-cp-delete:hover { background: rgba(185, 28, 28, 0.08); }
2522
+ #${POPOVER_ID} .grabby-cp-cancel {
2523
+ font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 10px; border: none;
2524
+ border-radius: 8px; background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer;
2525
+ }
2526
+ #${POPOVER_ID} .grabby-cp-cancel:hover { background: var(--grabby-surface, #f1f5f9); }
2370
2527
  #${POPOVER_ID} .grabby-cp-hint {
2371
2528
  font-size: 11px;
2372
2529
  color: var(--grabby-text-muted, #94a3b8);
@@ -2428,6 +2585,37 @@ function createCommentPopover(callbacks) {
2428
2585
  function isEditable(el) {
2429
2586
  return !!el && el !== textarea && el !== nameInput && isEditableElement(el);
2430
2587
  }
2588
+ function save() {
2589
+ const v = _optionalChain([textarea, 'optionalAccess', _87 => _87.value, 'access', _88 => _88.trim, 'call', _89 => _89()]);
2590
+ if (!v) return;
2591
+ pendingValue = v;
2592
+ if (askIdentity) showIdentityStep();
2593
+ else finish();
2594
+ }
2595
+ function editActions() {
2596
+ const act = (fn) => (e) => {
2597
+ e.stopPropagation();
2598
+ fn();
2599
+ };
2600
+ const cancel = () => {
2601
+ const ctx = currentCtx;
2602
+ doHide();
2603
+ callbacks.onCancel(ctx);
2604
+ };
2605
+ const del = () => {
2606
+ const ctx = currentCtx;
2607
+ doHide();
2608
+ _optionalChain([callbacks, 'access', _90 => _90.onDelete, 'optionalCall', _91 => _91(ctx)]);
2609
+ };
2610
+ return h(
2611
+ "div",
2612
+ { class: "grabby-cp-edit-actions" },
2613
+ callbacks.onDelete ? h("button", { type: "button", class: "grabby-cp-delete", "data-grabby-delete": "", onclick: act(del) }, "Delete") : null,
2614
+ h("span", { class: "grabby-cp-spacer" }),
2615
+ h("button", { type: "button", class: "grabby-cp-cancel", "data-grabby-cancel": "", onclick: act(cancel) }, "Cancel"),
2616
+ h("button", { type: "button", class: "grabby-cp-post", "data-grabby-save": "", onclick: act(save) }, "Save")
2617
+ );
2618
+ }
2431
2619
  function finish(identity) {
2432
2620
  const ctx = currentCtx;
2433
2621
  const value = pendingValue;
@@ -2446,7 +2634,7 @@ function createCommentPopover(callbacks) {
2446
2634
  autocomplete: "name",
2447
2635
  "aria-label": "Your name"
2448
2636
  });
2449
- const post = () => finish({ name: _optionalChain([nameInput, 'optionalAccess', _84 => _84.value, 'access', _85 => _85.trim, 'call', _86 => _86()]) || null });
2637
+ const post = () => finish({ name: _optionalChain([nameInput, 'optionalAccess', _92 => _92.value, 'access', _93 => _93.trim, 'call', _94 => _94()]) || null });
2450
2638
  popover.replaceChildren(
2451
2639
  h("div", { class: "grabby-cp-title" }, "Thanks! Who is this from?"),
2452
2640
  h("div", { class: "grabby-cp-sub" }, "Your name helps the team follow up. It's remembered in this browser."),
@@ -2480,7 +2668,7 @@ function createCommentPopover(callbacks) {
2480
2668
  } else if (e.key === "Enter" && deepActiveElement() === nameInput) {
2481
2669
  e.preventDefault();
2482
2670
  e.stopImmediatePropagation();
2483
- finish({ name: _optionalChain([nameInput, 'optionalAccess', _87 => _87.value, 'access', _88 => _88.trim, 'call', _89 => _89()]) || null });
2671
+ finish({ name: _optionalChain([nameInput, 'optionalAccess', _95 => _95.value, 'access', _96 => _96.trim, 'call', _97 => _97()]) || null });
2484
2672
  }
2485
2673
  return;
2486
2674
  }
@@ -2493,11 +2681,7 @@ function createCommentPopover(callbacks) {
2493
2681
  e.stopImmediatePropagation();
2494
2682
  if (e.key === "Enter" && !e.shiftKey) {
2495
2683
  e.preventDefault();
2496
- const v = textarea.value.trim();
2497
- if (!v) return;
2498
- pendingValue = v;
2499
- if (askIdentity) showIdentityStep();
2500
- else finish();
2684
+ save();
2501
2685
  } else if (e.key === "Escape") {
2502
2686
  e.preventDefault();
2503
2687
  const ctx = currentCtx;
@@ -2515,7 +2699,7 @@ function createCommentPopover(callbacks) {
2515
2699
  }
2516
2700
  function doHide() {
2517
2701
  visible = false;
2518
- _optionalChain([popover, 'optionalAccess', _90 => _90.remove, 'call', _91 => _91()]);
2702
+ _optionalChain([popover, 'optionalAccess', _98 => _98.remove, 'call', _99 => _99()]);
2519
2703
  popover = null;
2520
2704
  textarea = null;
2521
2705
  nameInput = null;
@@ -2531,10 +2715,11 @@ function createCommentPopover(callbacks) {
2531
2715
  currentCtx = { mode: opts.mode, entryId: opts.entryId };
2532
2716
  askIdentity = opts.askIdentity === true && opts.mode === "new";
2533
2717
  visible = true;
2718
+ if (opts.mode === "edit") el.appendChild(editActions());
2534
2719
  position(el, opts.anchor);
2535
2720
  attachKey();
2536
- _optionalChain([textarea, 'optionalAccess', _92 => _92.focus, 'call', _93 => _93()]);
2537
- requestAnimationFrame(() => _optionalChain([textarea, 'optionalAccess', _94 => _94.focus, 'call', _95 => _95()]));
2721
+ _optionalChain([textarea, 'optionalAccess', _100 => _100.focus, 'call', _101 => _101()]);
2722
+ requestAnimationFrame(() => _optionalChain([textarea, 'optionalAccess', _102 => _102.focus, 'call', _103 => _103()]));
2538
2723
  },
2539
2724
  hide() {
2540
2725
  if (!visible) return;
@@ -2546,7 +2731,7 @@ function createCommentPopover(callbacks) {
2546
2731
  hasDraft() {
2547
2732
  if (!visible) return false;
2548
2733
  if (stage === "identity") return true;
2549
- const v = _nullishCoalesce(_optionalChain([textarea, 'optionalAccess', _96 => _96.value, 'access', _97 => _97.trim, 'call', _98 => _98()]), () => ( ""));
2734
+ const v = _nullishCoalesce(_optionalChain([textarea, 'optionalAccess', _104 => _104.value, 'access', _105 => _105.trim, 'call', _106 => _106()]), () => ( ""));
2550
2735
  return v !== "" && v !== initialValue.trim();
2551
2736
  },
2552
2737
  isPopoverElement(el) {
@@ -2635,7 +2820,7 @@ function createCopySheet(callbacks) {
2635
2820
  document.removeEventListener("keydown", keyHandler, true);
2636
2821
  keyHandler = null;
2637
2822
  }
2638
- _optionalChain([callbacks, 'access', _99 => _99.onClose, 'optionalCall', _100 => _100()]);
2823
+ _optionalChain([callbacks, 'access', _107 => _107.onClose, 'optionalCall', _108 => _108()]);
2639
2824
  }
2640
2825
  function open(options) {
2641
2826
  close();
@@ -2657,12 +2842,12 @@ function createCopySheet(callbacks) {
2657
2842
  level = next;
2658
2843
  edited = false;
2659
2844
  textarea.value = options.render(level);
2660
- hint.textContent = _nullishCoalesce(_optionalChain([LEVELS, 'access', _101 => _101.find, 'call', _102 => _102((l) => l.id === level), 'optionalAccess', _103 => _103.hint]), () => ( ""));
2845
+ hint.textContent = _nullishCoalesce(_optionalChain([LEVELS, 'access', _109 => _109.find, 'call', _110 => _110((l) => l.id === level), 'optionalAccess', _111 => _111.hint]), () => ( ""));
2661
2846
  for (const [id, btn] of segButtons) btn.setAttribute("aria-checked", String(id === level));
2662
2847
  status.classList.remove("grabby-error");
2663
2848
  status.textContent = discarded ? "Your edits were replaced by the new detail level." : "";
2664
2849
  updateTokens();
2665
- _optionalChain([callbacks, 'access', _104 => _104.onLevelChange, 'optionalCall', _105 => _105(level)]);
2850
+ _optionalChain([callbacks, 'access', _112 => _112.onLevelChange, 'optionalCall', _113 => _113(level)]);
2666
2851
  }
2667
2852
  const seg = h(
2668
2853
  "div",
@@ -2740,7 +2925,7 @@ function createCopySheet(callbacks) {
2740
2925
  document.addEventListener("keydown", keyHandler, true);
2741
2926
  getUiRoot().appendChild(sheet);
2742
2927
  setLevel(level, true);
2743
- _optionalChain([sheet, 'access', _106 => _106.querySelector, 'call', _107 => _107("[data-grabby-copy-clear]"), 'optionalAccess', _108 => _108.focus, 'call', _109 => _109()]);
2928
+ _optionalChain([sheet, 'access', _114 => _114.querySelector, 'call', _115 => _115("[data-grabby-copy-clear]"), 'optionalAccess', _116 => _116.focus, 'call', _117 => _117()]);
2744
2929
  }
2745
2930
  return {
2746
2931
  open,
@@ -2888,7 +3073,7 @@ function createFinishSheet(callbacks) {
2888
3073
  ...note ? [h("div", { class: "grabby-finish-note" }, note)] : [],
2889
3074
  h("div", { class: "grabby-finish-actions" }, ...actions)
2890
3075
  );
2891
- _optionalChain([sheet, 'access', _110 => _110.querySelector, 'call', _111 => _111(".grabby-btn-primary:not([disabled])"), 'optionalAccess', _112 => _112.focus, 'call', _113 => _113()]);
3076
+ _optionalChain([sheet, 'access', _118 => _118.querySelector, 'call', _119 => _119(".grabby-btn-primary:not([disabled])"), 'optionalAccess', _120 => _120.focus, 'call', _121 => _121()]);
2892
3077
  }
2893
3078
  return {
2894
3079
  open(next) {
@@ -2972,7 +3157,7 @@ function createCoachMark() {
2972
3157
  let el = null;
2973
3158
  function dismiss() {
2974
3159
  markSeen();
2975
- _optionalChain([el, 'optionalAccess', _114 => _114.remove, 'call', _115 => _115()]);
3160
+ _optionalChain([el, 'optionalAccess', _122 => _122.remove, 'call', _123 => _123()]);
2976
3161
  el = null;
2977
3162
  }
2978
3163
  return {
@@ -3004,7 +3189,7 @@ function createCoachMark() {
3004
3189
  },
3005
3190
  dismiss,
3006
3191
  dispose() {
3007
- _optionalChain([el, 'optionalAccess', _116 => _116.remove, 'call', _117 => _117()]);
3192
+ _optionalChain([el, 'optionalAccess', _124 => _124.remove, 'call', _125 => _125()]);
3008
3193
  el = null;
3009
3194
  removeStyles(STYLE_ID8);
3010
3195
  }
@@ -3062,9 +3247,10 @@ function createOutbox(deps) {
3062
3247
  }, delay);
3063
3248
  }
3064
3249
  function wireShape(c) {
3065
- const { screenshot: _shot, sync: _sync, ...rest } = c;
3250
+ const { screenshot: _shot, sync: _sync, pin: _pin, ...rest } = c;
3066
3251
  void _shot;
3067
3252
  void _sync;
3253
+ void _pin;
3068
3254
  return rest;
3069
3255
  }
3070
3256
  function postComment(comment) {
@@ -3098,14 +3284,14 @@ function createOutbox(deps) {
3098
3284
  if (job.kind === "comment") {
3099
3285
  const res2 = await postComment(comment);
3100
3286
  if (res2.ok) {
3101
- if (_optionalChain([deps, 'access', _118 => _118.getComment, 'call', _119 => _119(job.id), 'optionalAccess', _120 => _120.screenshot, 'optionalAccess', _121 => _121.localId])) add(job.id, "shot");
3287
+ if (_optionalChain([deps, 'access', _126 => _126.getComment, 'call', _127 => _127(job.id), 'optionalAccess', _128 => _128.screenshot, 'optionalAccess', _129 => _129.localId])) add(job.id, "shot");
3102
3288
  return "done";
3103
3289
  }
3104
3290
  if (res2.status === 429 || res2.status >= 500) return "retry";
3105
3291
  deps.onState(job.id, "failed", await res2.text().catch(() => String(res2.status)));
3106
3292
  return "drop";
3107
3293
  }
3108
- const localId = _optionalChain([comment, 'access', _122 => _122.screenshot, 'optionalAccess', _123 => _123.localId]);
3294
+ const localId = _optionalChain([comment, 'access', _130 => _130.screenshot, 'optionalAccess', _131 => _131.localId]);
3109
3295
  const blob = localId ? await deps.getScreenshot(localId) : null;
3110
3296
  if (!blob) return "drop";
3111
3297
  const { width, height } = comment.screenshot;
@@ -3366,7 +3552,7 @@ function createFreezeOverlay() {
3366
3552
  removeHoverRules();
3367
3553
  unfreezeAnimations();
3368
3554
  unblockEvents();
3369
- _optionalChain([overlay, 'optionalAccess', _124 => _124.remove, 'call', _125 => _125()]);
3555
+ _optionalChain([overlay, 'optionalAccess', _132 => _132.remove, 'call', _133 => _133()]);
3370
3556
  removeStyles(FREEZE_STYLE_ID);
3371
3557
  overlay = null;
3372
3558
  visible = false;
@@ -3374,11 +3560,314 @@ function createFreezeOverlay() {
3374
3560
  };
3375
3561
  }
3376
3562
 
3563
+ // src/core/overlay/markers.ts
3564
+ var LAYER_ID = "__grabby-markers__";
3565
+ var TIP_ID = "__grabby-marker-tip__";
3566
+ var STYLE_ID9 = "__grabby-marker-styles__";
3567
+ var SIZE = 22;
3568
+ var ROUTE_CHECK_MS = 250;
3569
+ var LOOKUP_RETRY_MS = 500;
3570
+ var STAGGER_MS = 30;
3571
+ var TIP_MAX = 140;
3572
+ var ICON_EDIT = {
3573
+ size: 12,
3574
+ shapes: paths("M10.5 2.5l3 3L6 13H3v-3z", "M9 4l3 3")
3575
+ };
3576
+ function createMarkers(deps) {
3577
+ let layer = null;
3578
+ let tip = null;
3579
+ let visible = false;
3580
+ let route = "";
3581
+ let rafId = null;
3582
+ let lastRouteCheck = 0;
3583
+ let hovered = null;
3584
+ const entries = /* @__PURE__ */ new Map();
3585
+ function injectStyles2() {
3586
+ if (hasStyles(STYLE_ID9)) return;
3587
+ addStyles(STYLE_ID9, `
3588
+ #${LAYER_ID} {
3589
+ position: fixed;
3590
+ inset: 0;
3591
+ pointer-events: none;
3592
+ z-index: ${Z_INDEX_CROSSHAIR};
3593
+ }
3594
+ #${LAYER_ID} .grabby-marker {
3595
+ position: absolute;
3596
+ left: 0;
3597
+ top: 0;
3598
+ width: ${SIZE}px;
3599
+ height: ${SIZE}px;
3600
+ margin: 0;
3601
+ padding: 0;
3602
+ border: none;
3603
+ border-radius: 50%;
3604
+ background: var(--grabby-accent, #2563eb);
3605
+ color: #fff;
3606
+ box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, 0.25);
3607
+ font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
3608
+ display: flex;
3609
+ align-items: center;
3610
+ justify-content: center;
3611
+ cursor: pointer;
3612
+ pointer-events: auto;
3613
+ transition: transform 0.12s ease, box-shadow 0.15s ease;
3614
+ }
3615
+ #${LAYER_ID} .grabby-marker[hidden] { display: none; }
3616
+ #${LAYER_ID} .grabby-marker:hover,
3617
+ #${LAYER_ID} .grabby-marker:focus-visible {
3618
+ z-index: 1;
3619
+ outline: none;
3620
+ box-shadow: 0 0 0 2px #fff, 0 0 0 5px color-mix(in srgb, var(--grabby-accent, #2563eb) 35%, transparent), 0 2px 6px rgba(0, 0, 0, 0.25);
3621
+ }
3622
+ #${LAYER_ID} .grabby-marker-edit { display: none; }
3623
+ #${LAYER_ID} .grabby-marker:hover .grabby-marker-num,
3624
+ #${LAYER_ID} .grabby-marker:focus-visible .grabby-marker-num { display: none; }
3625
+ #${LAYER_ID} .grabby-marker:hover .grabby-marker-edit,
3626
+ #${LAYER_ID} .grabby-marker:focus-visible .grabby-marker-edit { display: block; }
3627
+ #${LAYER_ID} .grabby-marker-in {
3628
+ animation: grabby-marker-in 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
3629
+ }
3630
+ #${LAYER_ID} .grabby-marker-out {
3631
+ animation: grabby-marker-out 0.2s ease-out both;
3632
+ pointer-events: none;
3633
+ }
3634
+ @keyframes grabby-marker-in {
3635
+ from { opacity: 0; scale: 0.3; }
3636
+ to { opacity: 1; scale: 1; }
3637
+ }
3638
+ @keyframes grabby-marker-out {
3639
+ from { opacity: 1; scale: 1; }
3640
+ to { opacity: 0; scale: 0.3; }
3641
+ }
3642
+ #${TIP_ID} {
3643
+ position: fixed;
3644
+ z-index: ${Z_INDEX_CROSSHAIR};
3645
+ max-width: 260px;
3646
+ padding: 8px 10px;
3647
+ border-radius: 10px;
3648
+ background: var(--grabby-label-bg, #1e293b);
3649
+ color: #fff;
3650
+ font: 12px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
3651
+ box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
3652
+ pointer-events: none;
3653
+ white-space: pre-wrap;
3654
+ overflow-wrap: anywhere;
3655
+ animation: grabby-marker-tip-in 0.12s ease both;
3656
+ }
3657
+ #${TIP_ID}[hidden] { display: none; }
3658
+ #${TIP_ID} .grabby-marker-tip-hint { display: block; margin-top: 4px; opacity: 0.6; font-size: 11px; }
3659
+ @keyframes grabby-marker-tip-in {
3660
+ from { opacity: 0; transform: translateY(-2px); }
3661
+ to { opacity: 1; transform: none; }
3662
+ }
3663
+ @media (prefers-reduced-motion: reduce) {
3664
+ #${LAYER_ID} .grabby-marker-in, #${LAYER_ID} .grabby-marker-out, #${TIP_ID} { animation: none; }
3665
+ }
3666
+ `);
3667
+ }
3668
+ function ensureLayer() {
3669
+ if (layer) return layer;
3670
+ injectStyles2();
3671
+ layer = document.createElement("div");
3672
+ layer.id = LAYER_ID;
3673
+ tip = document.createElement("div");
3674
+ tip.id = TIP_ID;
3675
+ tip.hidden = true;
3676
+ tip.setAttribute("role", "tooltip");
3677
+ getUiRoot().append(layer, tip);
3678
+ return layer;
3679
+ }
3680
+ function pageComments() {
3681
+ return deps.getComments().filter((c) => c.page.route === route).reverse();
3682
+ }
3683
+ function preview(text) {
3684
+ const flat = text.trim();
3685
+ return flat.length > TIP_MAX ? `${flat.slice(0, TIP_MAX - 1)}\u2026` : flat;
3686
+ }
3687
+ function createEntry(comment) {
3688
+ const number = document.createElement("span");
3689
+ number.className = "grabby-marker-num";
3690
+ const button = document.createElement("button");
3691
+ button.type = "button";
3692
+ button.className = "grabby-marker";
3693
+ button.dataset.grabbyMarker = comment.id;
3694
+ button.append(number, svgIcon(ICON_EDIT, "grabby-marker-edit"));
3695
+ const entry = { comment, button, number, element: null, lastLookup: 0 };
3696
+ button.addEventListener("click", (e) => {
3697
+ e.preventDefault();
3698
+ e.stopPropagation();
3699
+ hideTip();
3700
+ deps.onOpen(entry.comment, entry.element, button);
3701
+ });
3702
+ button.addEventListener("mouseenter", () => startHover(entry));
3703
+ button.addEventListener("focus", () => startHover(entry));
3704
+ button.addEventListener("mouseleave", () => endHover(entry));
3705
+ button.addEventListener("blur", () => endHover(entry));
3706
+ return entry;
3707
+ }
3708
+ function startHover(entry) {
3709
+ hovered = entry;
3710
+ showTip(entry);
3711
+ deps.onHover(entry.comment, entry.element);
3712
+ }
3713
+ function endHover(entry) {
3714
+ if (hovered !== entry) return;
3715
+ hovered = null;
3716
+ hideTip();
3717
+ deps.onHover(null, null);
3718
+ }
3719
+ function showTip(entry) {
3720
+ if (!tip) return;
3721
+ const hint = document.createElement("span");
3722
+ hint.className = "grabby-marker-tip-hint";
3723
+ hint.textContent = "Click to edit";
3724
+ tip.replaceChildren(document.createTextNode(preview(entry.comment.comment)), hint);
3725
+ tip.hidden = false;
3726
+ placeTip(entry);
3727
+ }
3728
+ function placeTip(entry) {
3729
+ if (!tip || tip.hidden) return;
3730
+ const m = entry.button.getBoundingClientRect();
3731
+ const t = tip.getBoundingClientRect();
3732
+ const left = Math.max(8, Math.min(m.left + m.width / 2 - t.width / 2, window.innerWidth - t.width - 8));
3733
+ const below = m.bottom + 8;
3734
+ const top = below + t.height > window.innerHeight - 8 ? m.top - 8 - t.height : below;
3735
+ tip.style.left = `${left}px`;
3736
+ tip.style.top = `${Math.max(8, top)}px`;
3737
+ }
3738
+ function hideTip() {
3739
+ if (tip) tip.hidden = true;
3740
+ }
3741
+ function animateIn(button, delay) {
3742
+ button.classList.remove("grabby-marker-out", "grabby-marker-in");
3743
+ button.style.animationDelay = `${delay}ms`;
3744
+ void button.offsetWidth;
3745
+ button.classList.add("grabby-marker-in");
3746
+ }
3747
+ function removeEntry(id, animate) {
3748
+ const entry = entries.get(id);
3749
+ if (!entry) return;
3750
+ entries.delete(id);
3751
+ if (hovered === entry) endHover(entry);
3752
+ if (!animate) {
3753
+ entry.button.remove();
3754
+ return;
3755
+ }
3756
+ entry.button.style.animationDelay = "0ms";
3757
+ entry.button.classList.remove("grabby-marker-in");
3758
+ entry.button.classList.add("grabby-marker-out");
3759
+ setTimeout(() => entry.button.remove(), 220);
3760
+ }
3761
+ function sync(fresh) {
3762
+ if (!visible) return;
3763
+ const host2 = ensureLayer();
3764
+ const list = pageComments();
3765
+ const ids = new Set(list.map((c) => c.id));
3766
+ for (const id of [...entries.keys()]) if (!ids.has(id)) removeEntry(id, !fresh);
3767
+ list.forEach((comment, i) => {
3768
+ let entry = entries.get(comment.id);
3769
+ const isNew = !entry;
3770
+ if (!entry) {
3771
+ entry = createEntry(comment);
3772
+ entries.set(comment.id, entry);
3773
+ host2.appendChild(entry.button);
3774
+ }
3775
+ entry.comment = comment;
3776
+ const n = String(i + 1);
3777
+ entry.number.textContent = n;
3778
+ entry.button.setAttribute("aria-label", `Comment ${n}: ${preview(comment.comment)}. Click to edit.`);
3779
+ if (fresh || isNew) animateIn(entry.button, fresh ? i * STAGGER_MS : 0);
3780
+ });
3781
+ if (hovered && entries.get(hovered.comment.id) === hovered) showTip(hovered);
3782
+ position(performance.now());
3783
+ schedule();
3784
+ }
3785
+ function position(now) {
3786
+ for (const entry of entries.values()) {
3787
+ if (!_optionalChain([entry, 'access', _134 => _134.element, 'optionalAccess', _135 => _135.isConnected])) {
3788
+ entry.element = null;
3789
+ if (now - entry.lastLookup >= LOOKUP_RETRY_MS) {
3790
+ entry.lastLookup = now;
3791
+ entry.element = deps.findElement(entry.comment);
3792
+ }
3793
+ }
3794
+ const rect = _optionalChain([entry, 'access', _136 => _136.element, 'optionalAccess', _137 => _137.getBoundingClientRect, 'call', _138 => _138()]);
3795
+ if (!rect || rect.width === 0 && rect.height === 0) {
3796
+ entry.button.hidden = true;
3797
+ continue;
3798
+ }
3799
+ const pin = _nullishCoalesce(entry.comment.pin, () => ( { x: 1, y: 0 }));
3800
+ const x = rect.left + pin.x * rect.width - SIZE / 2;
3801
+ const y = rect.top + pin.y * rect.height - SIZE / 2;
3802
+ entry.button.hidden = false;
3803
+ entry.button.style.transform = `translate(${Math.round(x)}px, ${Math.round(y)}px)`;
3804
+ }
3805
+ if (hovered) placeTip(hovered);
3806
+ }
3807
+ function frame() {
3808
+ rafId = null;
3809
+ const now = performance.now();
3810
+ if (!visible) return;
3811
+ if (now - lastRouteCheck >= ROUTE_CHECK_MS) {
3812
+ lastRouteCheck = now;
3813
+ const next = deps.currentRoute();
3814
+ if (next !== route) {
3815
+ route = next;
3816
+ for (const id of [...entries.keys()]) removeEntry(id, false);
3817
+ sync(true);
3818
+ return;
3819
+ }
3820
+ }
3821
+ position(now);
3822
+ schedule();
3823
+ }
3824
+ function schedule() {
3825
+ if (rafId === null && visible) rafId = requestAnimationFrame(frame);
3826
+ }
3827
+ function stop() {
3828
+ if (rafId !== null) cancelAnimationFrame(rafId);
3829
+ rafId = null;
3830
+ }
3831
+ return {
3832
+ setVisible(next) {
3833
+ if (next === visible) return;
3834
+ visible = next;
3835
+ if (next) {
3836
+ route = deps.currentRoute();
3837
+ lastRouteCheck = performance.now();
3838
+ sync(true);
3839
+ } else {
3840
+ stop();
3841
+ hideTip();
3842
+ if (hovered) endHover(hovered);
3843
+ for (const id of [...entries.keys()]) removeEntry(id, true);
3844
+ }
3845
+ },
3846
+ refresh() {
3847
+ sync(false);
3848
+ },
3849
+ isMarkerElement(el) {
3850
+ return !!layer && (layer === el || layer.contains(el));
3851
+ },
3852
+ dispose() {
3853
+ stop();
3854
+ entries.clear();
3855
+ _optionalChain([layer, 'optionalAccess', _139 => _139.remove, 'call', _140 => _140()]);
3856
+ _optionalChain([tip, 'optionalAccess', _141 => _141.remove, 'call', _142 => _142()]);
3857
+ layer = null;
3858
+ tip = null;
3859
+ hovered = null;
3860
+ visible = false;
3861
+ removeStyles(STYLE_ID9);
3862
+ }
3863
+ };
3864
+ }
3865
+
3377
3866
  // src/core/overlay/select-feedback.ts
3378
- var STYLE_ID9 = "__grabby-feedback-styles__";
3867
+ var STYLE_ID10 = "__grabby-feedback-styles__";
3379
3868
  function injectStyles() {
3380
- if (hasStyles(STYLE_ID9)) return;
3381
- addStyles(STYLE_ID9, `
3869
+ if (hasStyles(STYLE_ID10)) return;
3870
+ addStyles(STYLE_ID10, `
3382
3871
  @keyframes grabby-flash {
3383
3872
  0% { opacity: 1; }
3384
3873
  100% { opacity: 0; transform: scale(1.02); }
@@ -3457,7 +3946,7 @@ function showSelectFeedback(element, label = "Selected") {
3457
3946
  setTimeout(cleanup, 1200);
3458
3947
  }
3459
3948
  function disposeFeedbackStyles() {
3460
- removeStyles(STYLE_ID9);
3949
+ removeStyles(STYLE_ID10);
3461
3950
  }
3462
3951
 
3463
3952
  // src/core/storage/history-persistence.ts
@@ -3548,7 +4037,7 @@ function clearPersistedHistory() {
3548
4037
  var baselineFrame = null;
3549
4038
  var baselineCache = /* @__PURE__ */ new Map();
3550
4039
  function baselineDoc() {
3551
- if (_optionalChain([baselineFrame, 'optionalAccess', _126 => _126.isConnected]) && baselineFrame.contentDocument) return baselineFrame.contentDocument;
4040
+ if (_optionalChain([baselineFrame, 'optionalAccess', _143 => _143.isConnected]) && baselineFrame.contentDocument) return baselineFrame.contentDocument;
3552
4041
  try {
3553
4042
  baselineFrame = document.createElement("iframe");
3554
4043
  baselineFrame.setAttribute("aria-hidden", "true");
@@ -3578,8 +4067,8 @@ function baselineFor(tag, type, props) {
3578
4067
  const missing = props.filter((p) => !cached.has(p));
3579
4068
  if (missing.length > 0) {
3580
4069
  const doc = baselineDoc();
3581
- const view = _optionalChain([doc, 'optionalAccess', _127 => _127.defaultView]);
3582
- if (_optionalChain([doc, 'optionalAccess', _128 => _128.body]) && view) {
4070
+ const view = _optionalChain([doc, 'optionalAccess', _144 => _144.defaultView]);
4071
+ if (_optionalChain([doc, 'optionalAccess', _145 => _145.body]) && view) {
3583
4072
  const probe = doc.createElement(tag);
3584
4073
  if (type) probe.setAttribute("type", type);
3585
4074
  doc.body.appendChild(probe);
@@ -3593,7 +4082,7 @@ function baselineFor(tag, type, props) {
3593
4082
  return cached;
3594
4083
  }
3595
4084
  function disposeStyleBaseline() {
3596
- _optionalChain([baselineFrame, 'optionalAccess', _129 => _129.remove, 'call', _130 => _130()]);
4085
+ _optionalChain([baselineFrame, 'optionalAccess', _146 => _146.remove, 'call', _147 => _147()]);
3597
4086
  baselineFrame = null;
3598
4087
  baselineCache.clear();
3599
4088
  }
@@ -3695,7 +4184,7 @@ function states(el) {
3695
4184
  }
3696
4185
  function actionFacts(el) {
3697
4186
  const f = {};
3698
- const imgAlt = _nullishCoalesce(_optionalChain([el, 'access', _131 => _131.querySelector, 'call', _132 => _132("img[alt]"), 'optionalAccess', _133 => _133.getAttribute, 'call', _134 => _134("alt")]), () => ( ""));
4187
+ const imgAlt = _nullishCoalesce(_optionalChain([el, 'access', _148 => _148.querySelector, 'call', _149 => _149("img[alt]"), 'optionalAccess', _150 => _150.getAttribute, 'call', _151 => _151("alt")]), () => ( ""));
3699
4188
  put(f, "label", accessibleLabel(el) || textOf(el, 80) || redact(_nullishCoalesce(el.getAttribute("title"), () => ( ""))) || redact(imgAlt));
3700
4189
  if (el.tagName === "A") put(f, "href", sanitizeUrl(_nullishCoalesce(el.getAttribute("href"), () => ( ""))));
3701
4190
  else if (el.tagName === "BUTTON" || el.tagName === "INPUT") put(f, "type", _nullishCoalesce(el.getAttribute("type"), () => ( (el.tagName === "BUTTON" ? "submit" : ""))));
@@ -3744,7 +4233,7 @@ function mediaFacts(el) {
3744
4233
  put(f, "label", accessibleLabel(el) || textOf(_nullishCoalesce(el.querySelector("title"), () => ( el)), 40));
3745
4234
  put(f, "viewBox", _nullishCoalesce(el.getAttribute("viewBox"), () => ( "")));
3746
4235
  } else if (el.tagName === "VIDEO" || el.tagName === "AUDIO" || el.tagName === "IFRAME") {
3747
- put(f, "src", basename3(_nullishCoalesce(_nullishCoalesce(el.getAttribute("src"), () => ( _optionalChain([el, 'access', _135 => _135.querySelector, 'call', _136 => _136("source"), 'optionalAccess', _137 => _137.getAttribute, 'call', _138 => _138("src")]))), () => ( ""))));
4236
+ put(f, "src", basename3(_nullishCoalesce(_nullishCoalesce(el.getAttribute("src"), () => ( _optionalChain([el, 'access', _152 => _152.querySelector, 'call', _153 => _153("source"), 'optionalAccess', _154 => _154.getAttribute, 'call', _155 => _155("src")]))), () => ( ""))));
3748
4237
  put(f, "title", redact(_nullishCoalesce(el.getAttribute("title"), () => ( ""))));
3749
4238
  }
3750
4239
  put(f, "size", size(el));
@@ -3752,8 +4241,8 @@ function mediaFacts(el) {
3752
4241
  return f;
3753
4242
  }
3754
4243
  function childLabel(child, resolver) {
3755
- const resolved = _optionalChain([resolver, 'optionalCall', _139 => _139(child)]);
3756
- if (_optionalChain([resolved, 'optionalAccess', _140 => _140.name]) && resolved.hostElement === child) return resolved.name;
4244
+ const resolved = _optionalChain([resolver, 'optionalCall', _156 => _156(child)]);
4245
+ if (_optionalChain([resolved, 'optionalAccess', _157 => _157.name]) && resolved.hostElement === child) return resolved.name;
3757
4246
  const tag = child.tagName.toLowerCase();
3758
4247
  if (/^h[1-6]$/.test(tag)) return "heading";
3759
4248
  if (tag === "a") return "link";
@@ -3788,7 +4277,7 @@ function sectionFacts(el, resolver) {
3788
4277
  const f = {};
3789
4278
  put(f, "title", redact(el.ownerDocument.title));
3790
4279
  put(f, "viewport", `${window.innerWidth}\xD7${window.innerHeight}`);
3791
- const regions = Array.from(el.querySelectorAll('header, nav, main, aside, footer, section, [role="region"]')).filter((r) => !_optionalChain([r, 'access', _141 => _141.parentElement, 'optionalAccess', _142 => _142.closest, 'call', _143 => _143('header, nav, main, aside, footer, section, [role="region"]')]) || r.parentElement === el).slice(0, 8).map((r) => {
4280
+ const regions = Array.from(el.querySelectorAll('header, nav, main, aside, footer, section, [role="region"]')).filter((r) => !_optionalChain([r, 'access', _158 => _158.parentElement, 'optionalAccess', _159 => _159.closest, 'call', _160 => _160('header, nav, main, aside, footer, section, [role="region"]')]) || r.parentElement === el).slice(0, 8).map((r) => {
3792
4281
  const heading = firstHeading2(r);
3793
4282
  return heading ? `${r.tagName.toLowerCase()} "${truncate(heading, 30)}"` : r.tagName.toLowerCase();
3794
4283
  });
@@ -3845,22 +4334,22 @@ function isAppFile(file) {
3845
4334
  return !!file && !/(^|[\\/])node_modules[\\/]/.test(file);
3846
4335
  }
3847
4336
  function resolveStack(el, deps) {
3848
- const comp = _nullishCoalesce(_optionalChain([deps, 'access', _144 => _144.componentResolver, 'optionalCall', _145 => _145(el)]), () => ( null));
4337
+ const comp = _nullishCoalesce(_optionalChain([deps, 'access', _161 => _161.componentResolver, 'optionalCall', _162 => _162(el)]), () => ( null));
3849
4338
  const frames = [];
3850
4339
  const named = [];
3851
- for (const entry of _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _146 => _146.stack]), () => ( []))) {
4340
+ for (const entry of _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _163 => _163.stack]), () => ( []))) {
3852
4341
  const src = entry.filePath !== void 0 ? { filePath: entry.filePath, line: _nullishCoalesce(entry.line, () => ( null)) } : entry.hostElement && deps.sourceResolver ? deps.sourceResolver(entry.hostElement) : null;
3853
- const frame = { name: entry.name, file: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _147 => _147.filePath]), () => ( null)), line: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _148 => _148.line]), () => ( null)) };
4342
+ const frame = { name: entry.name, file: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _164 => _164.filePath]), () => ( null)), line: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _165 => _165.line]), () => ( null)) };
3854
4343
  named.push(frame);
3855
4344
  if (isAppFile(frame.file) && frames.length < MAX_STACK) frames.push(frame);
3856
4345
  }
3857
- return { component: _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _149 => _149.name]), () => ( null)), frames: frames.length > 0 ? frames : named.slice(0, 2) };
4346
+ return { component: _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _166 => _166.name]), () => ( null)), frames: frames.length > 0 ? frames : named.slice(0, 2) };
3858
4347
  }
3859
4348
  function resolveSource(el, deps, frames) {
3860
- const own = _optionalChain([deps, 'access', _150 => _150.sourceResolver, 'optionalCall', _151 => _151(el)]);
4349
+ const own = _optionalChain([deps, 'access', _167 => _167.sourceResolver, 'optionalCall', _168 => _168(el)]);
3861
4350
  if (own && isAppFile(own.filePath)) return { file: own.filePath, line: own.line, column: own.column };
3862
4351
  const first = frames.find((f) => isAppFile(f.file));
3863
- return _optionalChain([first, 'optionalAccess', _152 => _152.file]) ? { file: first.file, line: first.line, column: null } : null;
4352
+ return _optionalChain([first, 'optionalAccess', _169 => _169.file]) ? { file: first.file, line: first.line, column: null } : null;
3864
4353
  }
3865
4354
  function captureTarget(el, deps) {
3866
4355
  const cleanClasses = _nullishCoalesce(deps.cleanClasses, () => ( ((list) => list.filter((c) => !isNoiseClass(c)))));
@@ -3911,7 +4400,7 @@ function sandboxHtml() {
3911
4400
  return policy ? policy.createHTML(SANDBOX_HTML) : null;
3912
4401
  }
3913
4402
  async function getSandbox() {
3914
- if (_optionalChain([sandbox, 'optionalAccess', _153 => _153.isConnected])) return sandbox;
4403
+ if (_optionalChain([sandbox, 'optionalAccess', _170 => _170.isConnected])) return sandbox;
3915
4404
  const frame = document.createElement("iframe");
3916
4405
  frame.setAttribute("aria-hidden", "true");
3917
4406
  frame.setAttribute("tabindex", "-1");
@@ -3935,7 +4424,7 @@ async function getSandbox() {
3935
4424
  return frame;
3936
4425
  }
3937
4426
  function disposeScreenshotSandbox() {
3938
- _optionalChain([sandbox, 'optionalAccess', _154 => _154.remove, 'call', _155 => _155()]);
4427
+ _optionalChain([sandbox, 'optionalAccess', _171 => _171.remove, 'call', _172 => _172()]);
3939
4428
  sandbox = null;
3940
4429
  }
3941
4430
  function withTimeout(promise, ms) {
@@ -4095,7 +4584,7 @@ function resolveComponent(element) {
4095
4584
  name: cleanComponentName(owning.constructor.name),
4096
4585
  hostElement: _nullishCoalesce(host2, () => ( walk.parentElement))
4097
4586
  });
4098
- current = _nullishCoalesce(_nullishCoalesce(_optionalChain([host2, 'optionalAccess', _156 => _156.parentElement]), () => ( _optionalChain([walk, 'access', _157 => _157.parentElement, 'optionalAccess', _158 => _158.parentElement]))), () => ( null));
4587
+ current = _nullishCoalesce(_nullishCoalesce(_optionalChain([host2, 'optionalAccess', _173 => _173.parentElement]), () => ( _optionalChain([walk, 'access', _174 => _174.parentElement, 'optionalAccess', _175 => _175.parentElement]))), () => ( null));
4099
4588
  while (current) {
4100
4589
  const comp = ng.getComponent(current);
4101
4590
  if (comp && !seen2.has(comp)) {
@@ -4229,14 +4718,14 @@ function resolveComponent2(element) {
4229
4718
  let current = fiber;
4230
4719
  while (current && stack.length < MAX_STACK2) {
4231
4720
  const name = getComponentName(current.type);
4232
- if (name && !isNoise(name) && _optionalChain([stack, 'access', _159 => _159[stack.length - 1], 'optionalAccess', _160 => _160.name]) !== name) {
4721
+ if (name && !isNoise(name) && _optionalChain([stack, 'access', _176 => _176[stack.length - 1], 'optionalAccess', _177 => _177.name]) !== name) {
4233
4722
  stack.push({ name, hostElement: findHostElement(current) });
4234
4723
  }
4235
4724
  current = current.return;
4236
4725
  }
4237
4726
  return {
4238
- name: _nullishCoalesce(_optionalChain([stack, 'access', _161 => _161[0], 'optionalAccess', _162 => _162.name]), () => ( null)),
4239
- hostElement: _nullishCoalesce(_optionalChain([stack, 'access', _163 => _163[0], 'optionalAccess', _164 => _164.hostElement]), () => ( null)),
4727
+ name: _nullishCoalesce(_optionalChain([stack, 'access', _178 => _178[0], 'optionalAccess', _179 => _179.name]), () => ( null)),
4728
+ hostElement: _nullishCoalesce(_optionalChain([stack, 'access', _180 => _180[0], 'optionalAccess', _181 => _181.hostElement]), () => ( null)),
4240
4729
  stack
4241
4730
  };
4242
4731
  }
@@ -4247,7 +4736,7 @@ var LOCATION = /^(.*?):(\d+):(\d+)(?::([A-Za-z_$][\w$.]*))?$/;
4247
4736
  function resolveSource3(element) {
4248
4737
  let current = element;
4249
4738
  while (current) {
4250
- const raw = _optionalChain([current, 'access', _165 => _165.getAttribute, 'optionalCall', _166 => _166(SOURCE_ATTRIBUTE)]);
4739
+ const raw = _optionalChain([current, 'access', _182 => _182.getAttribute, 'optionalCall', _183 => _183(SOURCE_ATTRIBUTE)]);
4251
4740
  if (raw) return parseLocation(raw);
4252
4741
  current = current.parentElement;
4253
4742
  }
@@ -4259,7 +4748,7 @@ function parseLocation(raw) {
4259
4748
  return { filePath: match[1], line: Number(match[2]), column: Number(match[3]) };
4260
4749
  }
4261
4750
  function ownStamp(element) {
4262
- const raw = _optionalChain([element, 'optionalAccess', _167 => _167.getAttribute, 'optionalCall', _168 => _168(SOURCE_ATTRIBUTE)]);
4751
+ const raw = _optionalChain([element, 'optionalAccess', _184 => _184.getAttribute, 'optionalCall', _185 => _185(SOURCE_ATTRIBUTE)]);
4263
4752
  if (!raw) return null;
4264
4753
  const match = LOCATION.exec(raw);
4265
4754
  if (!match) return { file: raw, line: null, column: null, name: null };
@@ -4274,8 +4763,8 @@ function nameFromStamps(result) {
4274
4763
  const stack = [];
4275
4764
  for (const entry of result.stack) {
4276
4765
  const stamp = ownStamp(entry.hostElement);
4277
- const name = _nullishCoalesce(_optionalChain([stamp, 'optionalAccess', _169 => _169.name]), () => ( (stamp ? baseName(stamp.file) : null)));
4278
- if (name && _optionalChain([stack, 'access', _170 => _170[stack.length - 1], 'optionalAccess', _171 => _171.name]) !== name) stack.push({ name, hostElement: entry.hostElement });
4766
+ const name = _nullishCoalesce(_optionalChain([stamp, 'optionalAccess', _186 => _186.name]), () => ( (stamp ? baseName(stamp.file) : null)));
4767
+ if (name && _optionalChain([stack, 'access', _187 => _187[stack.length - 1], 'optionalAccess', _188 => _188.name]) !== name) stack.push({ name, hostElement: entry.hostElement });
4279
4768
  }
4280
4769
  return stack[0] ? { name: stack[0].name, hostElement: stack[0].hostElement, stack } : null;
4281
4770
  }
@@ -4311,7 +4800,7 @@ function vue3Name(inst) {
4311
4800
  return t.__name || t.name || t.displayName || (t.__file ? baseName(t.__file) : null);
4312
4801
  }
4313
4802
  function vue3Host(inst) {
4314
- return firstElement(_nullishCoalesce(_optionalChain([inst, 'access', _172 => _172.subTree, 'optionalAccess', _173 => _173.el]), () => ( _optionalChain([inst, 'access', _174 => _174.vnode, 'optionalAccess', _175 => _175.el]))));
4803
+ return firstElement(_nullishCoalesce(_optionalChain([inst, 'access', _189 => _189.subTree, 'optionalAccess', _190 => _190.el]), () => ( _optionalChain([inst, 'access', _191 => _191.vnode, 'optionalAccess', _192 => _192.el]))));
4315
4804
  }
4316
4805
  function vue2Owner(el) {
4317
4806
  let current = el;
@@ -4351,7 +4840,7 @@ function resolveVueComponent(el) {
4351
4840
  }
4352
4841
  function resolveVueSource(el) {
4353
4842
  const inst3 = vue3Owner(el);
4354
- const file = _nullishCoalesce(_optionalChain([inst3, 'optionalAccess', _176 => _176.type, 'optionalAccess', _177 => _177.__file]), () => ( _optionalChain([vue2Owner, 'call', _178 => _178(el), 'optionalAccess', _179 => _179.$options, 'optionalAccess', _180 => _180.__file])));
4843
+ const file = _nullishCoalesce(_optionalChain([inst3, 'optionalAccess', _193 => _193.type, 'optionalAccess', _194 => _194.__file]), () => ( _optionalChain([vue2Owner, 'call', _195 => _195(el), 'optionalAccess', _196 => _196.$options, 'optionalAccess', _197 => _197.__file])));
4355
4844
  return file ? { filePath: relativizePath(file), line: null, column: null } : NO_SOURCE;
4356
4845
  }
4357
4846
  var vueAdapter = {
@@ -4367,19 +4856,19 @@ function metaOf(el) {
4367
4856
  let current = el;
4368
4857
  while (current) {
4369
4858
  const meta = current.__svelte_meta;
4370
- if (_optionalChain([meta, 'optionalAccess', _181 => _181.loc])) return { meta, el: current };
4859
+ if (_optionalChain([meta, 'optionalAccess', _198 => _198.loc])) return { meta, el: current };
4371
4860
  current = current.parentElement;
4372
4861
  }
4373
4862
  return null;
4374
4863
  }
4375
4864
  function lineOf(meta) {
4376
- const line = _optionalChain([meta, 'access', _182 => _182.loc, 'optionalAccess', _183 => _183.line]);
4865
+ const line = _optionalChain([meta, 'access', _199 => _199.loc, 'optionalAccess', _200 => _200.line]);
4377
4866
  if (typeof line !== "number") return null;
4378
4867
  return "parent" in meta ? line : line + 1;
4379
4868
  }
4380
4869
  function resolveSvelteComponent(el) {
4381
4870
  const found = metaOf(el);
4382
- if (!_optionalChain([found, 'optionalAccess', _184 => _184.meta, 'access', _185 => _185.loc, 'optionalAccess', _186 => _186.file])) return null;
4871
+ if (!_optionalChain([found, 'optionalAccess', _201 => _201.meta, 'access', _202 => _202.loc, 'optionalAccess', _203 => _203.file])) return null;
4383
4872
  const { meta } = found;
4384
4873
  const own = baseName(meta.loc.file);
4385
4874
  const stack = [{ name: own, hostElement: found.el }];
@@ -4393,9 +4882,9 @@ function resolveSvelteComponent(el) {
4393
4882
  }
4394
4883
  function resolveSvelteSource(el) {
4395
4884
  const found = metaOf(el);
4396
- const file = _optionalChain([found, 'optionalAccess', _187 => _187.meta, 'access', _188 => _188.loc, 'optionalAccess', _189 => _189.file]);
4885
+ const file = _optionalChain([found, 'optionalAccess', _204 => _204.meta, 'access', _205 => _205.loc, 'optionalAccess', _206 => _206.file]);
4397
4886
  if (!found || !file) return NO_SOURCE;
4398
- const column = _optionalChain([found, 'access', _190 => _190.meta, 'access', _191 => _191.loc, 'optionalAccess', _192 => _192.column]);
4887
+ const column = _optionalChain([found, 'access', _207 => _207.meta, 'access', _208 => _208.loc, 'optionalAccess', _209 => _209.column]);
4399
4888
  return {
4400
4889
  filePath: relativizePath(file),
4401
4890
  line: lineOf(found.meta),
@@ -4415,10 +4904,10 @@ var domAdapter = {
4415
4904
  name: "HTML",
4416
4905
  resolveComponent: (el) => {
4417
4906
  const host2 = el.closest("[data-component]");
4418
- const name = _optionalChain([host2, 'optionalAccess', _193 => _193.getAttribute, 'call', _194 => _194("data-component")]);
4907
+ const name = _optionalChain([host2, 'optionalAccess', _210 => _210.getAttribute, 'call', _211 => _211("data-component")]);
4419
4908
  if (!host2 || !name) return null;
4420
4909
  const stack = [];
4421
- for (let h2 = host2; h2; h2 = _nullishCoalesce(_optionalChain([h2, 'access', _195 => _195.parentElement, 'optionalAccess', _196 => _196.closest, 'call', _197 => _197("[data-component]")]), () => ( null))) {
4910
+ for (let h2 = host2; h2; h2 = _nullishCoalesce(_optionalChain([h2, 'access', _212 => _212.parentElement, 'optionalAccess', _213 => _213.closest, 'call', _214 => _214("[data-component]")]), () => ( null))) {
4422
4911
  const n = h2.getAttribute("data-component");
4423
4912
  if (n) stack.push({ name: n, hostElement: h2 });
4424
4913
  if (stack.length >= 12) break;
@@ -4440,7 +4929,7 @@ function composeAdapters(adapters = DEFAULT_ADAPTERS) {
4440
4929
  for (const adapter of adapters) {
4441
4930
  try {
4442
4931
  const result = adapter.resolveComponent(el);
4443
- if (_optionalChain([result, 'optionalAccess', _198 => _198.name])) return { adapter, result };
4932
+ if (_optionalChain([result, 'optionalAccess', _215 => _215.name])) return { adapter, result };
4444
4933
  } catch (e30) {
4445
4934
  }
4446
4935
  }
@@ -4448,7 +4937,7 @@ function composeAdapters(adapters = DEFAULT_ADAPTERS) {
4448
4937
  }
4449
4938
  return {
4450
4939
  resolveComponent(el) {
4451
- return _nullishCoalesce(_optionalChain([owner, 'call', _199 => _199(el), 'optionalAccess', _200 => _200.result]), () => ( null));
4940
+ return _nullishCoalesce(_optionalChain([owner, 'call', _216 => _216(el), 'optionalAccess', _217 => _217.result]), () => ( null));
4452
4941
  },
4453
4942
  resolveSource(el) {
4454
4943
  const stamped = resolveSource3(el);
@@ -4457,15 +4946,15 @@ function composeAdapters(adapters = DEFAULT_ADAPTERS) {
4457
4946
  const ordered = found ? [found.adapter, ...adapters.filter((a) => a !== found.adapter)] : adapters;
4458
4947
  for (const adapter of ordered) {
4459
4948
  try {
4460
- const src = _optionalChain([adapter, 'access', _201 => _201.resolveSource, 'optionalCall', _202 => _202(el)]);
4461
- if (_optionalChain([src, 'optionalAccess', _203 => _203.filePath])) return src;
4949
+ const src = _optionalChain([adapter, 'access', _218 => _218.resolveSource, 'optionalCall', _219 => _219(el)]);
4950
+ if (_optionalChain([src, 'optionalAccess', _220 => _220.filePath])) return src;
4462
4951
  } catch (e31) {
4463
4952
  }
4464
4953
  }
4465
4954
  return null;
4466
4955
  },
4467
4956
  frameworkFor(el) {
4468
- return _nullishCoalesce(_optionalChain([owner, 'call', _204 => _204(el), 'optionalAccess', _205 => _205.adapter, 'access', _206 => _206.name]), () => ( "HTML"));
4957
+ return _nullishCoalesce(_optionalChain([owner, 'call', _221 => _221(el), 'optionalAccess', _222 => _222.adapter, 'access', _223 => _223.name]), () => ( "HTML"));
4469
4958
  },
4470
4959
  cleanClasses(classes) {
4471
4960
  return adapters.reduce((list, a) => a.cleanClasses ? a.cleanClasses(list) : list, classes);
@@ -4497,7 +4986,7 @@ function getDefaultOptions() {
4497
4986
  };
4498
4987
  }
4499
4988
  function init(options) {
4500
- if (_optionalChain([options, 'optionalAccess', _207 => _207.mode]) === "live" && !_chunk6CBIOKZVcjs.consumeFeedbackLink.call(void 0, options.projectKey)) {
4989
+ if (_optionalChain([options, 'optionalAccess', _224 => _224.mode]) === "live" && !_chunk6CBIOKZVcjs.consumeFeedbackLink.call(void 0, options.projectKey)) {
4501
4990
  return createDormantApi(options);
4502
4991
  }
4503
4992
  return createGrabInstance(options);
@@ -4523,7 +5012,7 @@ function createDormantApi(options) {
4523
5012
  real.show();
4524
5013
  return;
4525
5014
  }
4526
- _optionalChain([flusher, 'optionalAccess', _208 => _208.dispose, 'call', _209 => _209()]);
5015
+ _optionalChain([flusher, 'optionalAccess', _225 => _225.dispose, 'call', _226 => _226()]);
4527
5016
  _chunk6CBIOKZVcjs.startFeedbackSession.call(void 0, );
4528
5017
  real = createGrabInstance(options);
4529
5018
  for (const fn of queued.splice(0)) fn(real);
@@ -4550,14 +5039,29 @@ function flushLeftovers(options) {
4550
5039
  }
4551
5040
  });
4552
5041
  }
5042
+ var COLLAPSED_KEY = "grabby:v1:collapsed";
5043
+ function loadCollapsed() {
5044
+ try {
5045
+ return sessionStorage.getItem(COLLAPSED_KEY) === "1";
5046
+ } catch (e33) {
5047
+ return false;
5048
+ }
5049
+ }
5050
+ function saveCollapsed(on) {
5051
+ try {
5052
+ if (on) sessionStorage.setItem(COLLAPSED_KEY, "1");
5053
+ else sessionStorage.removeItem(COLLAPSED_KEY);
5054
+ } catch (e34) {
5055
+ }
5056
+ }
4553
5057
  function isDevMode() {
4554
5058
  try {
4555
5059
  if (typeof ngDevMode !== "undefined" && ngDevMode === false) return false;
4556
- } catch (e33) {
5060
+ } catch (e35) {
4557
5061
  }
4558
5062
  try {
4559
5063
  if (process.env.NODE_ENV === "production") return false;
4560
- } catch (e34) {
5064
+ } catch (e36) {
4561
5065
  }
4562
5066
  return true;
4563
5067
  }
@@ -4565,14 +5069,14 @@ function loadLevel(fallback) {
4565
5069
  try {
4566
5070
  const v = localStorage.getItem(LEVEL_KEY);
4567
5071
  if (v === "compact" || v === "standard" || v === "detailed") return v;
4568
- } catch (e35) {
5072
+ } catch (e37) {
4569
5073
  }
4570
5074
  return fallback;
4571
5075
  }
4572
5076
  function saveLevel(level) {
4573
5077
  try {
4574
5078
  localStorage.setItem(LEVEL_KEY, level);
4575
- } catch (e36) {
5079
+ } catch (e38) {
4576
5080
  }
4577
5081
  }
4578
5082
  function createNoopApi() {
@@ -4630,8 +5134,12 @@ function createGrabInstance(options) {
4630
5134
  let sourceResolver = adapters.resolveSource;
4631
5135
  const cleanClasses = (list) => adapters.cleanClasses(list.filter((c) => !isNoiseClass(c)));
4632
5136
  let selectedElement = null;
5137
+ let selectedPin;
4633
5138
  let pendingShot = null;
5139
+ const commentedElements = /* @__PURE__ */ new Map();
5140
+ let editingFromMarker = false;
4634
5141
  let level = loadLevel(merged.detailLevel);
5142
+ let collapsed = loadCollapsed();
4635
5143
  const pendingShotDeletes = /* @__PURE__ */ new Map();
4636
5144
  themeManager.apply(store.state.toolbar.themeMode);
4637
5145
  updateToastOffset();
@@ -4683,12 +5191,12 @@ function createGrabInstance(options) {
4683
5191
  function toastDetail(c) {
4684
5192
  return {
4685
5193
  componentName: c.target.component,
4686
- filePath: _nullishCoalesce(_optionalChain([c, 'access', _210 => _210.target, 'access', _211 => _211.source, 'optionalAccess', _212 => _212.file]), () => ( null)),
4687
- line: _nullishCoalesce(_optionalChain([c, 'access', _213 => _213.target, 'access', _214 => _214.source, 'optionalAccess', _215 => _215.line]), () => ( null)),
4688
- column: _nullishCoalesce(_optionalChain([c, 'access', _216 => _216.target, 'access', _217 => _217.source, 'optionalAccess', _218 => _218.column]), () => ( null))
5194
+ filePath: _nullishCoalesce(_optionalChain([c, 'access', _227 => _227.target, 'access', _228 => _228.source, 'optionalAccess', _229 => _229.file]), () => ( null)),
5195
+ line: _nullishCoalesce(_optionalChain([c, 'access', _230 => _230.target, 'access', _231 => _231.source, 'optionalAccess', _232 => _232.line]), () => ( null)),
5196
+ column: _nullishCoalesce(_optionalChain([c, 'access', _233 => _233.target, 'access', _234 => _234.source, 'optionalAccess', _235 => _235.column]), () => ( null))
4689
5197
  };
4690
5198
  }
4691
- function saveComment(element, text, shot) {
5199
+ function saveComment(element, text, shot, pin) {
4692
5200
  const now = Date.now();
4693
5201
  const comment = {
4694
5202
  id: randomId(),
@@ -4705,11 +5213,13 @@ function createGrabInstance(options) {
4705
5213
  target: captureTarget(element, { componentResolver, sourceResolver, cleanClasses }),
4706
5214
  screenshot: null,
4707
5215
  framework: adapters.frameworkFor(element),
4708
- ...outbox ? { sync: "pending" } : {}
5216
+ ...outbox ? { sync: "pending" } : {},
5217
+ ...pin ? { pin } : {}
4709
5218
  };
5219
+ commentedElements.set(comment.id, element);
4710
5220
  setComments([comment, ...comments()].slice(0, MAX_COMMENTS));
4711
5221
  pluginRegistry.callHook("onComment", comment, element);
4712
- _optionalChain([outbox, 'optionalAccess', _219 => _219.send, 'call', _220 => _220(comment.id)]);
5222
+ _optionalChain([outbox, 'optionalAccess', _236 => _236.send, 'call', _237 => _237(comment.id)]);
4713
5223
  if (shot) void attachScreenshot(comment.id, shot);
4714
5224
  const count = comments().length;
4715
5225
  if (live) {
@@ -4744,18 +5254,19 @@ function createGrabInstance(options) {
4744
5254
  const updated = { ...current, screenshot: { localId: id, width: result.width, height: result.height } };
4745
5255
  setComments(comments().map((c) => c.id === id ? updated : c));
4746
5256
  pluginRegistry.callHook("onScreenshot", updated, result.blob);
4747
- _optionalChain([outbox, 'optionalAccess', _221 => _221.sendScreenshot, 'call', _222 => _222(id)]);
5257
+ _optionalChain([outbox, 'optionalAccess', _238 => _238.sendScreenshot, 'call', _239 => _239(id)]);
4748
5258
  }
4749
5259
  function removeComments(ids, message, withdraw = false) {
4750
5260
  if (ids.length === 0) return;
4751
5261
  const idSet = new Set(ids);
4752
5262
  const before = comments();
4753
5263
  const removed = before.filter((c) => idSet.has(c.id));
5264
+ for (const id of ids) commentedElements.delete(id);
4754
5265
  setComments(before.filter((c) => !idSet.has(c.id)));
4755
5266
  const withdrawn = withdraw && outbox ? removed.filter((c) => c.sync !== void 0) : [];
4756
5267
  const hadQueued = new Set(withdrawn.filter((c) => outbox.isQueued(c.id)).map((c) => c.id));
4757
5268
  for (const c of withdrawn) outbox.remove(c.id, c.author.sessionId, message ? UNDO_MS + 500 : 0);
4758
- const shotIds = removed.flatMap((c) => _optionalChain([c, 'access', _223 => _223.screenshot, 'optionalAccess', _224 => _224.localId]) ? [c.screenshot.localId] : []);
5269
+ const shotIds = removed.flatMap((c) => _optionalChain([c, 'access', _240 => _240.screenshot, 'optionalAccess', _241 => _241.localId]) ? [c.screenshot.localId] : []);
4759
5270
  const key = randomId();
4760
5271
  pendingShotDeletes.set(key, setTimeout(() => {
4761
5272
  pendingShotDeletes.delete(key);
@@ -4774,7 +5285,7 @@ function createGrabInstance(options) {
4774
5285
  const back = removed.filter((c) => !present.has(c.id)).map((c) => resend.has(c.id) ? { ...c, sync: "pending" } : c);
4775
5286
  const restored = [...back, ...comments()].sort((a, b) => b.createdAt - a.createdAt);
4776
5287
  setComments(restored);
4777
- for (const id of resend) _optionalChain([outbox, 'optionalAccess', _225 => _225.send, 'call', _226 => _226(id)]);
5288
+ for (const id of resend) _optionalChain([outbox, 'optionalAccess', _242 => _242.send, 'call', _243 => _243(id)]);
4778
5289
  showToast(`Restored ${removed.length} comment${removed.length === 1 ? "" : "s"}`);
4779
5290
  }
4780
5291
  }]
@@ -4805,9 +5316,24 @@ function createGrabInstance(options) {
4805
5316
  function isAnyToolbarElement(el) {
4806
5317
  return isUiNode(el) || freezeOverlay.isFreezeElement(el);
4807
5318
  }
5319
+ function hideCommentPopover() {
5320
+ commentPopover.hide();
5321
+ endMarkerEdit();
5322
+ if (picker.isHolding()) {
5323
+ selectedElement = null;
5324
+ selectedPin = void 0;
5325
+ pendingShot = null;
5326
+ picker.release();
5327
+ }
5328
+ }
5329
+ function endMarkerEdit() {
5330
+ if (!editingFromMarker) return;
5331
+ editingFromMarker = false;
5332
+ overlay.hide();
5333
+ }
4808
5334
  function closeAllPopovers() {
4809
5335
  commentsPanel.hide();
4810
- commentPopover.hide();
5336
+ hideCommentPopover();
4811
5337
  copySheet.close();
4812
5338
  finishSheet.close();
4813
5339
  }
@@ -4841,15 +5367,52 @@ function createGrabInstance(options) {
4841
5367
  pluginRegistry.callHook("onElementHover", element);
4842
5368
  }
4843
5369
  },
4844
- onSelect(element) {
5370
+ onSelect(element, point) {
4845
5371
  selectedElement = element;
5372
+ const rect = element.getBoundingClientRect();
5373
+ const frac = (v, start, size2) => size2 > 0 ? Math.min(1, Math.max(0, (v - start) / size2)) : 0.5;
5374
+ selectedPin = {
5375
+ x: Math.round(frac(point.x, rect.left, rect.width) * 1e3) / 1e3,
5376
+ y: Math.round(frac(point.y, rect.top, rect.height) * 1e3) / 1e3
5377
+ };
4846
5378
  pendingShot = store.state.options.screenshots ? captureScreenshot(element) : null;
4847
5379
  pluginRegistry.callHook("onElementSelect", element);
4848
5380
  coachMark.dismiss();
4849
5381
  showSelectFeedback(element);
5382
+ picker.hold(element);
4850
5383
  commentPopover.show({ anchor: element, mode: "new", askIdentity: shouldAskIdentity() });
4851
5384
  }
4852
5385
  });
5386
+ const markers = createMarkers({
5387
+ getComments: comments,
5388
+ currentRoute: () => sanitizeRoute(location, store.state.options.captureQueryParams),
5389
+ findElement(comment) {
5390
+ const known = commentedElements.get(comment.id);
5391
+ if (_optionalChain([known, 'optionalAccess', _244 => _244.isConnected])) return known;
5392
+ return safeQuery(comment.target.selector);
5393
+ },
5394
+ onHover(comment, element) {
5395
+ if (picker.isHolding() || editingFromMarker || commentPopover.isVisible()) return;
5396
+ if (comment && element) overlay.show(element, comment.target.component, null, []);
5397
+ else overlay.hide();
5398
+ },
5399
+ onOpen(comment, element, marker) {
5400
+ if (picker.isHolding()) return;
5401
+ closeAllPopovers();
5402
+ doDeactivate(true);
5403
+ editingFromMarker = true;
5404
+ if (element) overlay.show(element, comment.target.component, null, []);
5405
+ commentPopover.show({
5406
+ anchor: _nullishCoalesce(element, () => ( marker)),
5407
+ initialValue: comment.comment,
5408
+ mode: "edit",
5409
+ entryId: comment.id
5410
+ });
5411
+ }
5412
+ });
5413
+ function updateMarkers() {
5414
+ markers.setVisible(store.state.toolbar.visible && !collapsed && store.state.options.enabled);
5415
+ }
4853
5416
  function doActivate() {
4854
5417
  if (!store.state.options.enabled) return;
4855
5418
  if (store.state.active) return;
@@ -4857,6 +5420,7 @@ function createGrabInstance(options) {
4857
5420
  store.state.toolbar = { ...store.state.toolbar, visible: true };
4858
5421
  toolbar.show();
4859
5422
  }
5423
+ if (collapsed) expandToolbar();
4860
5424
  closeAllPopovers();
4861
5425
  store.state.active = true;
4862
5426
  picker.activate();
@@ -4891,7 +5455,7 @@ function createGrabInstance(options) {
4891
5455
  }
4892
5456
  },
4893
5457
  onHistory() {
4894
- commentPopover.hide();
5458
+ hideCommentPopover();
4895
5459
  copySheet.close();
4896
5460
  if (commentsPanel.isVisible()) {
4897
5461
  commentsPanel.hide();
@@ -4908,16 +5472,30 @@ function createGrabInstance(options) {
4908
5472
  }
4909
5473
  toolbar.update(store.state);
4910
5474
  },
4911
- onDismiss() {
4912
- const { pending, failed } = reviewCounts();
4913
- if (live && outbox && (pending || failed)) {
4914
- openFinishSheet();
4915
- return;
4916
- }
4917
- exitFeedbackMode();
4918
- },
5475
+ // Close collapses the toolbar into a round button in the bottom-right
5476
+ // corner instead of removing it, so nothing is lost and it's one click
5477
+ // back. Comments keep sending while it's collapsed.
5478
+ onDismiss: collapseToolbar,
5479
+ onExpand: expandToolbar,
4919
5480
  onFinish: openFinishSheet
4920
- }, live ? { label: "Comment", dismissLabel: "Exit feedback mode", hideEnable: true, review: !!merged.server } : {});
5481
+ }, live ? { label: "Comment", dismissLabel: "Hide toolbar", expandLabel: "Leave feedback", hideEnable: true, review: !!merged.server } : { dismissLabel: "Hide toolbar", expandLabel: "Open Grabby toolbar" });
5482
+ function collapseToolbar() {
5483
+ closeAllPopovers();
5484
+ coachMark.dismiss();
5485
+ doDeactivate(true);
5486
+ collapsed = true;
5487
+ toolbar.collapse();
5488
+ saveCollapsed(true);
5489
+ updateToastOffset();
5490
+ updateMarkers();
5491
+ }
5492
+ function expandToolbar() {
5493
+ collapsed = false;
5494
+ toolbar.expand();
5495
+ saveCollapsed(false);
5496
+ updateToastOffset();
5497
+ updateMarkers();
5498
+ }
4921
5499
  const commentsPanel = createCommentsPanel({
4922
5500
  onHover(comment) {
4923
5501
  const el = comment ? safeQuery(comment.target.selector) : null;
@@ -4979,7 +5557,7 @@ function createGrabInstance(options) {
4979
5557
  });
4980
5558
  const finishSheet = createFinishSheet({
4981
5559
  onDone() {
4982
- const done = comments().filter((c) => c.sync === "sent" && !_optionalChain([outbox, 'optionalAccess', _227 => _227.isQueued, 'call', _228 => _228(c.id)])).map((c) => c.id);
5560
+ const done = comments().filter((c) => c.sync === "sent" && !_optionalChain([outbox, 'optionalAccess', _245 => _245.isQueued, 'call', _246 => _246(c.id)])).map((c) => c.id);
4983
5561
  if (!comments().length) {
4984
5562
  exitFeedbackMode();
4985
5563
  return;
@@ -4993,9 +5571,9 @@ function createGrabInstance(options) {
4993
5571
  if (failed.length) {
4994
5572
  const ids = new Set(failed.map((c) => c.id));
4995
5573
  setComments(comments().map((c) => ids.has(c.id) ? { ...c, sync: "pending" } : c));
4996
- for (const id of ids) _optionalChain([outbox, 'optionalAccess', _229 => _229.send, 'call', _230 => _230(id)]);
5574
+ for (const id of ids) _optionalChain([outbox, 'optionalAccess', _247 => _247.send, 'call', _248 => _248(id)]);
4997
5575
  }
4998
- _optionalChain([outbox, 'optionalAccess', _231 => _231.flush, 'call', _232 => _232()]);
5576
+ _optionalChain([outbox, 'optionalAccess', _249 => _249.flush, 'call', _250 => _250()]);
4999
5577
  }
5000
5578
  });
5001
5579
  const commentPopover = createCommentPopover({
@@ -5004,9 +5582,11 @@ function createGrabInstance(options) {
5004
5582
  if (ctx.mode === "new") {
5005
5583
  const element = selectedElement;
5006
5584
  const shot = pendingShot;
5585
+ const pin = selectedPin;
5007
5586
  selectedElement = null;
5587
+ selectedPin = void 0;
5008
5588
  pendingShot = null;
5009
- if (element) saveComment(element, value, shot);
5589
+ if (element) saveComment(element, value, shot, pin);
5010
5590
  doDeactivate(true);
5011
5591
  return;
5012
5592
  }
@@ -5015,18 +5595,25 @@ function createGrabInstance(options) {
5015
5595
  (c) => c.id === ctx.entryId ? { ...c, comment: value, updatedAt: Date.now(), ...outbox ? { sync: "pending" } : {} } : c
5016
5596
  );
5017
5597
  setComments(updated);
5018
- _optionalChain([outbox, 'optionalAccess', _233 => _233.send, 'call', _234 => _234(ctx.entryId)]);
5598
+ _optionalChain([outbox, 'optionalAccess', _251 => _251.send, 'call', _252 => _252(ctx.entryId)]);
5019
5599
  showToast("Comment updated");
5020
- commentsPanel.show([...updated]);
5600
+ if (editingFromMarker) endMarkerEdit();
5601
+ else commentsPanel.show([...updated]);
5021
5602
  },
5022
5603
  onCancel(ctx) {
5023
5604
  if (ctx.mode === "new") {
5024
5605
  selectedElement = null;
5606
+ selectedPin = void 0;
5025
5607
  pendingShot = null;
5026
5608
  doDeactivate(true);
5027
5609
  return;
5028
5610
  }
5029
- commentsPanel.show([...comments()]);
5611
+ if (editingFromMarker) endMarkerEdit();
5612
+ else commentsPanel.show([...comments()]);
5613
+ },
5614
+ onDelete(ctx) {
5615
+ endMarkerEdit();
5616
+ if (ctx.entryId) removeComments([ctx.entryId], "Comment deleted", true);
5030
5617
  }
5031
5618
  });
5032
5619
  function handleDocumentClick(e) {
@@ -5040,7 +5627,7 @@ function createGrabInstance(options) {
5040
5627
  document.addEventListener("click", handleDocumentClick);
5041
5628
  function handlePageHide() {
5042
5629
  flushPendingWrite();
5043
- _optionalChain([outbox, 'optionalAccess', _235 => _235.flushOnExit, 'call', _236 => _236()]);
5630
+ _optionalChain([outbox, 'optionalAccess', _253 => _253.flushOnExit, 'call', _254 => _254()]);
5044
5631
  }
5045
5632
  function handleVisibilityChange() {
5046
5633
  if (document.visibilityState === "hidden") flushPendingWrite();
@@ -5054,7 +5641,7 @@ function createGrabInstance(options) {
5054
5641
  }
5055
5642
  window.addEventListener("beforeunload", handleBeforeUnload);
5056
5643
  function updateToastOffset() {
5057
- if (store.state.toolbar.visible) {
5644
+ if (store.state.toolbar.visible && !collapsed) {
5058
5645
  document.documentElement.style.setProperty("--grabby-toast-bottom", TOOLBAR_TOAST_OFFSET);
5059
5646
  } else {
5060
5647
  document.documentElement.style.removeProperty("--grabby-toast-bottom");
@@ -5182,6 +5769,7 @@ function createGrabInstance(options) {
5182
5769
  overlay.dispose();
5183
5770
  crosshair.dispose();
5184
5771
  freezeOverlay.dispose();
5772
+ markers.dispose();
5185
5773
  disposeToast();
5186
5774
  disposeFeedbackStyles();
5187
5775
  pluginRegistry.dispose();
@@ -5192,7 +5780,7 @@ function createGrabInstance(options) {
5192
5780
  copySheet.dispose();
5193
5781
  finishSheet.dispose();
5194
5782
  coachMark.dispose();
5195
- _optionalChain([outbox, 'optionalAccess', _237 => _237.dispose, 'call', _238 => _238()]);
5783
+ _optionalChain([outbox, 'optionalAccess', _255 => _255.dispose, 'call', _256 => _256()]);
5196
5784
  themeManager.dispose();
5197
5785
  disposeStyleBaseline();
5198
5786
  disposeScreenshotSandbox();
@@ -5204,9 +5792,10 @@ function createGrabInstance(options) {
5204
5792
  keyboard.start();
5205
5793
  }
5206
5794
  store.state.toolbar = { ...store.state.toolbar, visible: false };
5795
+ if (collapsed) toolbar.collapse();
5207
5796
  if (live && merged.showToolbar) {
5208
5797
  api.showToolbar();
5209
- coachMark.maybeShow();
5798
+ if (!collapsed) coachMark.maybeShow();
5210
5799
  }
5211
5800
  store.subscribe((state, key) => {
5212
5801
  if (key === "options") {
@@ -5217,8 +5806,11 @@ function createGrabInstance(options) {
5217
5806
  doDeactivate(true);
5218
5807
  }
5219
5808
  }
5809
+ if (key === "options") updateMarkers();
5220
5810
  if (key === "toolbar") {
5221
5811
  updateToastOffset();
5812
+ updateMarkers();
5813
+ markers.refresh();
5222
5814
  if (state.options.persistHistory) {
5223
5815
  if (state.toolbar.comments.length > 0) {
5224
5816
  saveHistory(state.toolbar.comments);
@@ -5240,6 +5832,7 @@ function createGrabInstance(options) {
5240
5832
  if (merged.webhookUrl) {
5241
5833
  api.registerPlugin(createWebhookPlugin(merged.webhookUrl));
5242
5834
  }
5835
+ updateMarkers();
5243
5836
  return api;
5244
5837
  }
5245
5838