@githumbi/grabby 0.2.1 → 0.4.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.
@@ -142,12 +142,378 @@ function disposeUiRoot() {
142
142
  root = null;
143
143
  }
144
144
 
145
+ // src/core/capture/kind.ts
146
+ var ACTION_TAGS = /* @__PURE__ */ new Set(["BUTTON", "A", "SUMMARY"]);
147
+ var ACTION_ROLES = /* @__PURE__ */ new Set(["button", "link", "tab", "menuitem", "menuitemcheckbox", "menuitemradio", "switch", "option", "checkbox", "radio"]);
148
+ var BUTTON_INPUT_TYPES = /* @__PURE__ */ new Set(["button", "submit", "reset", "image"]);
149
+ var FIELD_TAGS = /* @__PURE__ */ new Set(["INPUT", "SELECT", "TEXTAREA"]);
150
+ var FIELD_ROLES = /* @__PURE__ */ new Set(["textbox", "combobox", "searchbox", "spinbutton", "slider"]);
151
+ var MEDIA_TAGS = /* @__PURE__ */ new Set(["IMG", "SVG", "VIDEO", "PICTURE", "CANVAS", "IFRAME", "AUDIO"]);
152
+ var TEXT_TAGS = /* @__PURE__ */ new Set([
153
+ "H1",
154
+ "H2",
155
+ "H3",
156
+ "H4",
157
+ "H5",
158
+ "H6",
159
+ "P",
160
+ "SPAN",
161
+ "LABEL",
162
+ "LI",
163
+ "STRONG",
164
+ "EM",
165
+ "B",
166
+ "I",
167
+ "SMALL",
168
+ "BLOCKQUOTE",
169
+ "CODE",
170
+ "PRE",
171
+ "TD",
172
+ "TH",
173
+ "DT",
174
+ "DD",
175
+ "FIGCAPTION",
176
+ "LEGEND",
177
+ "CAPTION",
178
+ "Q",
179
+ "CITE",
180
+ "MARK",
181
+ "TIME"
182
+ ]);
183
+ var PAGE_TAGS = /* @__PURE__ */ new Set(["HTML", "BODY", "MAIN"]);
184
+ var LANDMARK_TAGS = /* @__PURE__ */ new Set(["HEADER", "FOOTER", "NAV", "ASIDE"]);
185
+ var SECTION_AREA_RATIO = 0.6;
186
+ function role(el) {
187
+ return (_nullishCoalesce(el.getAttribute("role"), () => ( ""))).toLowerCase();
188
+ }
189
+ function isAction(el) {
190
+ if (ACTION_TAGS.has(el.tagName)) return el.tagName !== "A" || el.hasAttribute("href") || el.hasAttribute("role");
191
+ if (el.tagName === "INPUT" && BUTTON_INPUT_TYPES.has(el.type)) return true;
192
+ return ACTION_ROLES.has(role(el));
193
+ }
194
+ function isField(el) {
195
+ if (el.tagName === "INPUT") return !BUTTON_INPUT_TYPES.has(el.type);
196
+ if (FIELD_TAGS.has(el.tagName)) return true;
197
+ if (el.isContentEditable && el.getAttribute("contenteditable") !== null) return true;
198
+ return FIELD_ROLES.has(role(el));
199
+ }
200
+ function coversViewport(el) {
201
+ const rect = el.getBoundingClientRect();
202
+ const vw = window.innerWidth || document.documentElement.clientWidth;
203
+ const vh = window.innerHeight || document.documentElement.clientHeight;
204
+ if (!vw || !vh) return false;
205
+ const w = Math.max(0, Math.min(rect.right, vw) - Math.max(rect.left, 0));
206
+ const hgt = Math.max(0, Math.min(rect.bottom, vh) - Math.max(rect.top, 0));
207
+ return w * hgt / (vw * vh) >= SECTION_AREA_RATIO;
208
+ }
209
+ function hasElementChildren(el) {
210
+ return el.children.length > 0;
211
+ }
212
+ function detectKind(el) {
213
+ if (PAGE_TAGS.has(el.tagName)) return "section";
214
+ if (MEDIA_TAGS.has(el.tagName)) return "media";
215
+ if (isField(el)) return "field";
216
+ if (isAction(el)) return "action";
217
+ if (LANDMARK_TAGS.has(el.tagName) || role(el) === "main" || role(el) === "region") {
218
+ return coversViewport(el) ? "section" : "container";
219
+ }
220
+ if (TEXT_TAGS.has(el.tagName)) return "text";
221
+ if (!hasElementChildren(el) && (_nullishCoalesce(el.textContent, () => ( ""))).trim()) return "text";
222
+ if (coversViewport(el)) return "section";
223
+ return "container";
224
+ }
225
+ var PROMOTE_DEPTH = 3;
226
+ function promoteTarget(el) {
227
+ if (isAction(el) || isField(el)) return el;
228
+ let current = el.parentElement;
229
+ for (let depth = 0; current && depth < PROMOTE_DEPTH; depth++) {
230
+ if (isAction(current) || isField(current)) return current;
231
+ if (PAGE_TAGS.has(current.tagName)) break;
232
+ current = current.parentElement;
233
+ }
234
+ return el;
235
+ }
236
+
237
+ // src/core/capture/redact.ts
238
+ var EMAIL = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g;
239
+ var JWT = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g;
240
+ var BEARER = /\b(Bearer|Basic|Token)\s+[A-Za-z0-9._~+/=-]{8,}/gi;
241
+ var LONG_NUMBER = /\b\d(?:[ -]?\d){8,}\b/g;
242
+ var OPAQUE_TOKEN = /\b[A-Za-z0-9_-]{32,}\b/g;
243
+ var SENSITIVE_PARAM = /([?&#](?:access_token|id_token|token|key|api_key|apikey|secret|password|pass|auth|code|session|sig|signature)=)[^&#\s]*/gi;
244
+ function redact(text, options = {}) {
245
+ if (!text) return text;
246
+ const scrubbed = text.replace(SENSITIVE_PARAM, "$1[redacted]").replace(JWT, "[token]").replace(BEARER, "$1 [token]");
247
+ return (options.keepEmails ? scrubbed : scrubbed.replace(EMAIL, "[email]")).replace(LONG_NUMBER, "[number]").replace(OPAQUE_TOKEN, (m) => /\d/.test(m) && /[A-Za-z]/.test(m) ? "[token]" : m);
248
+ }
249
+ function sanitizeRoute(loc, keepParams = []) {
250
+ let route = loc.pathname || "/";
251
+ if (keepParams.length > 0 && loc.search) {
252
+ const params = new URLSearchParams(loc.search);
253
+ const kept = new URLSearchParams();
254
+ for (const name of keepParams) {
255
+ const value = params.get(name);
256
+ if (value !== null) kept.set(name, value);
257
+ }
258
+ const qs = kept.toString();
259
+ if (qs) route += `?${qs}`;
260
+ }
261
+ if (loc.hash.startsWith("#/")) route += loc.hash.split("?")[0];
262
+ return redact(route);
263
+ }
264
+ function sanitizeUrl(raw, base = typeof location !== "undefined" ? location.href : "http://localhost/") {
265
+ try {
266
+ const url = new URL(raw, base);
267
+ if (url.protocol === "javascript:" || url.protocol === "data:" || url.protocol === "vbscript:") return `${url.protocol}\u2026`;
268
+ const baseUrl = new URL(base);
269
+ const path = url.pathname + (url.hash.startsWith("#/") ? url.hash : "");
270
+ return redact(url.origin === baseUrl.origin ? path : `${url.host}${path}`);
271
+ } catch (e3) {
272
+ return redact(raw.split(/[?#]/)[0]);
273
+ }
274
+ }
275
+
276
+ // src/core/capture/preview.ts
277
+ var MASK_ATTR = "data-grabby-mask";
278
+ var IGNORE_ATTR = "data-grabby-ignore";
279
+ var PRIORITY_ATTRS = [
280
+ "id",
281
+ "class",
282
+ "role",
283
+ "aria-label",
284
+ "data-testid",
285
+ "data-test",
286
+ "data-cy",
287
+ "name",
288
+ "type",
289
+ "href",
290
+ "src",
291
+ "alt",
292
+ "placeholder",
293
+ "title",
294
+ "for",
295
+ "aria-expanded",
296
+ "aria-selected",
297
+ "disabled"
298
+ ];
299
+ var URL_ATTRS = /* @__PURE__ */ new Set(["href", "src"]);
300
+ var MAX_ATTRS = 8;
301
+ var MAX_CLASS_CHARS = 60;
302
+ var MAX_ATTR_CHARS = 80;
303
+ var MAX_TEXT_CHARS = 80;
304
+ var MAX_PREVIEW_CHARS = 300;
305
+ function isNoiseAttr(name) {
306
+ return name.startsWith("_ng") || name.startsWith("ng-reflect-") || name.startsWith("data-v-") || name.startsWith("data-grabby-") || name.startsWith("data-svelte") || name === "style" || name === "value" || name.startsWith("on");
307
+ }
308
+ function isNoiseClass(name) {
309
+ return name.startsWith("ng-") || name.startsWith("_ng") || /^svelte-[a-z0-9]+$/i.test(name) || /^s-[A-Za-z0-9_-]{8,}$/.test(name);
310
+ }
311
+ function truncate(text, max) {
312
+ return text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}\u2026`;
313
+ }
314
+ function isMasked(el) {
315
+ return el.closest(`[${MASK_ATTR}]`) !== null;
316
+ }
317
+ function textOf(el, max) {
318
+ if (isMasked(el)) return "[masked]";
319
+ let raw = "";
320
+ const walker = el.ownerDocument.createTreeWalker(el, NodeFilter.SHOW_TEXT);
321
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
322
+ const parent = node.parentElement;
323
+ if (parent && /^(SCRIPT|STYLE|NOSCRIPT|TEMPLATE)$/.test(parent.tagName)) continue;
324
+ if (_optionalChain([parent, 'optionalAccess', _7 => _7.closest, 'call', _8 => _8(`[${IGNORE_ATTR}], [${MASK_ATTR}]`)])) continue;
325
+ raw += ` ${_nullishCoalesce(node.nodeValue, () => ( ""))}`;
326
+ if (raw.length > max * 3) break;
327
+ }
328
+ return truncate(redact(raw.replace(/\s+/g, " ").trim()), max);
329
+ }
330
+ function ownText(el) {
331
+ let raw = "";
332
+ for (const node of Array.from(el.childNodes)) {
333
+ if (node.nodeType === Node.TEXT_NODE) raw += ` ${_nullishCoalesce(node.nodeValue, () => ( ""))}`;
334
+ }
335
+ return raw.replace(/\s+/g, " ").trim();
336
+ }
337
+ function attrValue(el, name, value, cleanClasses) {
338
+ if (name === "class") {
339
+ const classes = cleanClasses(value.split(/\s+/).filter(Boolean));
340
+ if (classes.length === 0) return null;
341
+ return truncate(classes.join(" "), MAX_CLASS_CHARS);
342
+ }
343
+ if (URL_ATTRS.has(name)) return truncate(sanitizeUrl(value), 120);
344
+ return truncate(redact(value, { keepEmails: name === "placeholder" }), MAX_ATTR_CHARS);
345
+ }
346
+ function openingTag(el, cleanClasses = (l) => l.filter((c) => !isNoiseClass(c))) {
347
+ const tag = el.tagName.toLowerCase();
348
+ const attrs = [];
349
+ const seen2 = /* @__PURE__ */ new Set();
350
+ const add = (name) => {
351
+ if (attrs.length >= MAX_ATTRS || seen2.has(name) || isNoiseAttr(name)) return;
352
+ const raw = el.getAttribute(name);
353
+ if (raw === null) return;
354
+ seen2.add(name);
355
+ if (raw === "") {
356
+ attrs.push(name);
357
+ return;
358
+ }
359
+ const value = attrValue(el, name, raw, cleanClasses);
360
+ if (value !== null) attrs.push(`${name}="${value.replace(/"/g, "&quot;")}"`);
361
+ };
362
+ for (const name of PRIORITY_ATTRS) add(name);
363
+ for (const { name } of Array.from(el.attributes)) {
364
+ if (name.startsWith("aria-")) add(name);
365
+ }
366
+ return `<${tag}${attrs.length ? ` ${attrs.join(" ")}` : ""}>`;
367
+ }
368
+ function buildPreview(el, cleanClasses) {
369
+ const tag = el.tagName.toLowerCase();
370
+ const open = openingTag(el, cleanClasses);
371
+ if (/^(img|input|br|hr|meta|link|source|area|col|embed|wbr)$/.test(tag)) {
372
+ return truncate(open, MAX_PREVIEW_CHARS);
373
+ }
374
+ const children = Array.from(el.children).filter((c) => !c.hasAttribute(IGNORE_ATTR));
375
+ let inner;
376
+ if (isMasked(el)) {
377
+ inner = "[masked]";
378
+ } else if (children.length === 0) {
379
+ inner = truncate(redact(ownText(el)), MAX_TEXT_CHARS);
380
+ } else if (children.length <= 2) {
381
+ const text = truncate(redact(ownText(el)), 40);
382
+ const kids = children.map((c) => {
383
+ const t = textOf(c, 30);
384
+ return `<${c.tagName.toLowerCase()}${t ? `>${t}</${c.tagName.toLowerCase()}>` : " \u2026>"}`;
385
+ });
386
+ inner = [text, ...kids].filter(Boolean).join(" ");
387
+ } else {
388
+ inner = `(${children.length} elements)`;
389
+ }
390
+ return truncate(`${open}${inner}</${tag}>`, MAX_PREVIEW_CHARS);
391
+ }
392
+
393
+ // src/core/capture/describe.ts
394
+ var MAX_NAME = 40;
395
+ var HEADING = /^h[1-6]$/;
396
+ function role2(el) {
397
+ return (_nullishCoalesce(el.getAttribute("role"), () => ( ""))).toLowerCase();
398
+ }
399
+ function hasBox(el) {
400
+ try {
401
+ const s = getComputedStyle(el);
402
+ const bordered = s.borderStyle !== "none" && parseFloat(s.borderWidth) > 0;
403
+ const shadow = !!s.boxShadow && s.boxShadow !== "none";
404
+ return shadow || bordered && parseFloat(s.borderRadius) > 0;
405
+ } catch (e4) {
406
+ return false;
407
+ }
408
+ }
409
+ function nounFor(tag, kind, r = "", inputType = "", boxed = false, titled = false) {
410
+ switch (kind) {
411
+ case "action":
412
+ if (r === "tab") return "Tab";
413
+ if (r.startsWith("menuitem")) return "Menu item";
414
+ if (r === "checkbox" || inputType === "checkbox") return "Checkbox";
415
+ if (r === "radio" || r === "option" || inputType === "radio") return "Option";
416
+ if (r === "switch") return "Switch";
417
+ if (tag === "a" || r === "link") return "Link";
418
+ return "Button";
419
+ case "field":
420
+ if (tag === "select" || r === "combobox") return "Dropdown";
421
+ if (tag === "textarea") return "Text area";
422
+ if (inputType === "checkbox") return "Checkbox";
423
+ if (inputType === "radio") return "Option";
424
+ if (inputType === "range" || r === "slider") return "Slider";
425
+ if (inputType === "file") return "File upload";
426
+ if (inputType === "search" || r === "searchbox") return "Search box";
427
+ if (/^(date|datetime-local|month|week|time)$/.test(inputType)) return "Date picker";
428
+ return "Text box";
429
+ case "media":
430
+ if (tag === "svg") return "Icon";
431
+ if (tag === "video") return "Video";
432
+ if (tag === "audio") return "Audio player";
433
+ if (tag === "iframe") return "Embedded content";
434
+ if (tag === "canvas") return "Chart or drawing";
435
+ return "Image";
436
+ case "text":
437
+ if (HEADING.test(tag) || r === "heading") return "Heading";
438
+ if (tag === "li") return "List item";
439
+ if (tag === "label") return "Label";
440
+ if (tag === "td" || tag === "th") return "Table cell";
441
+ if (tag === "blockquote" || tag === "q") return "Quote";
442
+ if (tag === "code" || tag === "pre") return "Code";
443
+ return "Text";
444
+ case "section":
445
+ if (tag === "html" || tag === "body") return "Whole page";
446
+ if (tag === "main" || r === "main") return "Main content";
447
+ if (tag === "header") return "Page header";
448
+ if (tag === "footer") return "Page footer";
449
+ if (tag === "nav") return "Navigation menu";
450
+ return "Page section";
451
+ default:
452
+ if (tag === "nav" || r === "navigation" || r === "menu" || r === "menubar") return "Menu";
453
+ if (tag === "header") return "Header";
454
+ if (tag === "footer") return "Footer";
455
+ if (tag === "aside") return "Sidebar";
456
+ if (tag === "form" || r === "form") return "Form";
457
+ if (tag === "table" || r === "table" || r === "grid") return "Table";
458
+ if (tag === "ul" || tag === "ol" || r === "list") return "List";
459
+ if (tag === "dialog" || r === "dialog" || r === "alertdialog") return "Pop-up";
460
+ if (boxed) return "Card";
461
+ if (titled) return "Section";
462
+ return "Area";
463
+ }
464
+ }
465
+ function fieldName(el) {
466
+ const labels = el.labels;
467
+ if (labels && labels.length) return textOf(labels[0], MAX_NAME);
468
+ return redact(_nullishCoalesce(el.getAttribute("aria-label"), () => ( ""))) || redact(_nullishCoalesce(el.getAttribute("placeholder"), () => ( "")));
469
+ }
470
+ function firstHeading(el) {
471
+ return el.querySelector('h1, h2, h3, h4, h5, h6, [role="heading"]');
472
+ }
473
+ function nameOf(el, kind) {
474
+ if (isMasked(el) || el.tagName === "BODY" || el.tagName === "HTML") return "";
475
+ const aria = redact(_nullishCoalesce(el.getAttribute("aria-label"), () => ( "")));
476
+ switch (kind) {
477
+ case "action":
478
+ return aria || textOf(el, MAX_NAME) || redact(_nullishCoalesce(el.getAttribute("title"), () => ( ""))) || redact(_nullishCoalesce(_optionalChain([el, 'access', _9 => _9.querySelector, 'call', _10 => _10("img[alt]"), 'optionalAccess', _11 => _11.getAttribute, 'call', _12 => _12("alt")]), () => ( "")));
479
+ case "field":
480
+ return fieldName(el);
481
+ case "media":
482
+ return redact(_nullishCoalesce(el.getAttribute("alt"), () => ( ""))) || aria || redact(_nullishCoalesce(el.getAttribute("title"), () => ( "")));
483
+ case "text":
484
+ return textOf(el, MAX_NAME);
485
+ default: {
486
+ const heading = firstHeading(el);
487
+ return aria || (heading ? textOf(heading, MAX_NAME) : "");
488
+ }
489
+ }
490
+ }
491
+ function quoted(noun, name) {
492
+ const clean = truncate(name.replace(/\s+/g, " ").trim(), MAX_NAME);
493
+ return clean ? `${noun} \u201C${clean}\u201D` : noun;
494
+ }
495
+ function describeElement(el) {
496
+ const tag = el.tagName.toLowerCase();
497
+ const kind = tag === "svg" ? "media" : detectKind(el);
498
+ const r = role2(el);
499
+ const inputType = tag === "input" ? (el.type || "").toLowerCase() : "";
500
+ const container = kind === "container";
501
+ const noun = nounFor(tag, kind, r, inputType, container && hasBox(el), container && !!firstHeading(el));
502
+ return quoted(noun, nameOf(el, kind));
503
+ }
504
+ function describeTarget(target) {
505
+ const facts = _nullishCoalesce(target.facts, () => ( {}));
506
+ const noun = nounFor(target.tag, target.kind, "", (_nullishCoalesce(facts.type, () => ( ""))).toLowerCase(), false, !!facts.heading);
507
+ const name = facts.label || facts.heading || facts.text || facts.alt || "";
508
+ return quoted(noun, name);
509
+ }
510
+
145
511
  // src/core/overlay/overlay-renderer.ts
146
512
  var OVERLAY_ID = "__grabby-overlay__";
147
513
  var LABEL_ID = "__grabby-label__";
148
514
  var STYLE_ID = "__grabby-styles__";
149
515
  var MAX_LABEL_CLASSES = 3;
150
- function createOverlayRenderer() {
516
+ function createOverlayRenderer(options = {}) {
151
517
  let overlay = null;
152
518
  let label = null;
153
519
  let rafId = null;
@@ -155,6 +521,7 @@ function createOverlayRenderer() {
155
521
  let currentComponentName = null;
156
522
  let currentSourcePath = null;
157
523
  let currentCssClasses = [];
524
+ let currentPlainLabel = "";
158
525
  function injectStyles2() {
159
526
  if (hasStyles(STYLE_ID)) return;
160
527
  addStyles(STYLE_ID, `
@@ -182,6 +549,11 @@ function createOverlayRenderer() {
182
549
  overflow: hidden;
183
550
  text-overflow: ellipsis;
184
551
  }
552
+ #${LABEL_ID}.grabby-plain {
553
+ font: 600 12px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
554
+ padding: 3px 8px;
555
+ border-radius: 6px;
556
+ }
185
557
  `);
186
558
  }
187
559
  function ensureElements() {
@@ -194,6 +566,7 @@ function createOverlayRenderer() {
194
566
  if (!label) {
195
567
  label = document.createElement("div");
196
568
  label.id = LABEL_ID;
569
+ if (options.plainLabels) label.className = "grabby-plain";
197
570
  getUiRoot().appendChild(label);
198
571
  }
199
572
  }
@@ -212,6 +585,11 @@ function createOverlayRenderer() {
212
585
  overlay.style.display = "block";
213
586
  const tag = currentElement.tagName.toLowerCase();
214
587
  let labelText = `<${tag}>`;
588
+ if (options.plainLabels) {
589
+ label.textContent = `${currentPlainLabel} \xB7 Click to select`;
590
+ placeLabel(rect);
591
+ return;
592
+ }
215
593
  if (currentCssClasses.length > 0) {
216
594
  const shown = currentCssClasses.slice(0, MAX_LABEL_CLASSES);
217
595
  labelText += ` .${shown.join(".")}${currentCssClasses.length > shown.length ? "\u2026" : ""}`;
@@ -223,6 +601,10 @@ function createOverlayRenderer() {
223
601
  labelText += ` \u2014 ${currentSourcePath}`;
224
602
  }
225
603
  label.textContent = labelText;
604
+ placeLabel(rect);
605
+ }
606
+ function placeLabel(rect) {
607
+ if (!label) return;
226
608
  const labelHeight = 20;
227
609
  const gap = 4;
228
610
  let labelTop = rect.top - labelHeight - gap;
@@ -255,6 +637,7 @@ function createOverlayRenderer() {
255
637
  ensureElements();
256
638
  currentElement = element;
257
639
  currentComponentName = componentName;
640
+ if (options.plainLabels) currentPlainLabel = describeElement(element);
258
641
  currentSourcePath = _nullishCoalesce(sourcePath, () => ( null));
259
642
  currentCssClasses = _nullishCoalesce(cssClasses, () => ( []));
260
643
  stopTracking();
@@ -278,8 +661,8 @@ function createOverlayRenderer() {
278
661
  currentComponentName = null;
279
662
  currentSourcePath = null;
280
663
  currentCssClasses = [];
281
- _optionalChain([overlay, 'optionalAccess', _7 => _7.remove, 'call', _8 => _8()]);
282
- _optionalChain([label, 'optionalAccess', _9 => _9.remove, 'call', _10 => _10()]);
664
+ _optionalChain([overlay, 'optionalAccess', _13 => _13.remove, 'call', _14 => _14()]);
665
+ _optionalChain([label, 'optionalAccess', _15 => _15.remove, 'call', _16 => _16()]);
283
666
  removeStyles(STYLE_ID);
284
667
  overlay = null;
285
668
  label = null;
@@ -296,6 +679,7 @@ function createCrosshair() {
296
679
  let hLine = null;
297
680
  let vLine = null;
298
681
  let listening = false;
682
+ let held = false;
299
683
  function injectStyles2() {
300
684
  if (hasStyles(CROSSHAIR_STYLE_ID)) return;
301
685
  addStyles(CROSSHAIR_STYLE_ID, `
@@ -318,7 +702,7 @@ function createCrosshair() {
318
702
  width: 1px;
319
703
  }
320
704
  `);
321
- 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");
322
706
  }
323
707
  function ensureElements() {
324
708
  if (!hLine) {
@@ -335,7 +719,12 @@ function createCrosshair() {
335
719
  getUiRoot().appendChild(vLine);
336
720
  }
337
721
  }
722
+ function hideLines() {
723
+ if (hLine) hLine.style.top = "-10px";
724
+ if (vLine) vLine.style.left = "-10px";
725
+ }
338
726
  function handleMouseMove(e) {
727
+ if (held) return;
339
728
  if (hLine) {
340
729
  hLine.style.top = `${e.clientY}px`;
341
730
  }
@@ -356,16 +745,22 @@ function createCrosshair() {
356
745
  listening = false;
357
746
  document.body.classList.remove("grabby-crosshair-active");
358
747
  document.removeEventListener("mousemove", handleMouseMove, true);
359
- if (hLine) hLine.style.top = "-10px";
360
- 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();
361
755
  },
362
756
  isCrosshairElement(el) {
363
757
  return el === hLine || el === vLine || el.id === H_LINE_ID || el.id === V_LINE_ID;
364
758
  },
365
759
  dispose() {
760
+ this.hold(false);
366
761
  this.deactivate();
367
- _optionalChain([hLine, 'optionalAccess', _11 => _11.remove, 'call', _12 => _12()]);
368
- _optionalChain([vLine, 'optionalAccess', _13 => _13.remove, 'call', _14 => _14()]);
762
+ _optionalChain([hLine, 'optionalAccess', _17 => _17.remove, 'call', _18 => _18()]);
763
+ _optionalChain([vLine, 'optionalAccess', _19 => _19.remove, 'call', _20 => _20()]);
369
764
  removeStyles(CROSSHAIR_STYLE_ID);
370
765
  removeStyles(CURSOR_STYLE_ID);
371
766
  hLine = null;
@@ -543,488 +938,241 @@ function injectToastStyles() {
543
938
  }
544
939
  #${TOAST_ID} .grabby-toast-details {
545
940
  margin-top: 8px;
546
- display: flex;
547
- flex-direction: column;
548
- gap: 4px;
549
- font-size: 12px;
550
- font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
551
- }
552
- #${TOAST_ID} .grabby-toast-row {
553
- display: flex;
554
- gap: 8px;
555
- align-items: baseline;
556
- }
557
- #${TOAST_ID} .grabby-toast-label {
558
- color: var(--grabby-toast-label, #64748b);
559
- flex-shrink: 0;
560
- min-width: 72px;
561
- }
562
- #${TOAST_ID} .grabby-toast-value {
563
- color: var(--grabby-toast-text, #334155);
564
- overflow: hidden;
565
- text-overflow: ellipsis;
566
- white-space: nowrap;
567
- }
568
- #${TOAST_ID} .grabby-toast-file-link {
569
- color: var(--grabby-toast-text, #334155);
570
- text-decoration: none;
571
- overflow: hidden;
572
- text-overflow: ellipsis;
573
- white-space: nowrap;
574
- pointer-events: auto;
575
- cursor: pointer;
576
- }
577
- #${TOAST_ID} .grabby-toast-file-link:hover {
578
- text-decoration: underline;
579
- color: var(--grabby-accent, #2563eb);
580
- }
581
- `);
582
- }
583
- var toastEl = null;
584
- function getOrCreateToast() {
585
- if (_optionalChain([toastEl, 'optionalAccess', _15 => _15.isConnected])) return toastEl;
586
- injectToastStyles();
587
- toastEl = h("div", { id: TOAST_ID, role: "status", "aria-live": "polite" });
588
- getUiRoot().appendChild(toastEl);
589
- return toastEl;
590
- }
591
- function vsCodeUri(filePath, line, column) {
592
- let uri = `vscode://file/${encodeURI(filePath)}`;
593
- if (line != null) uri += `:${line}`;
594
- if (line != null && column != null) uri += `:${column}`;
595
- return uri;
596
- }
597
- function row(label, value) {
598
- return h(
599
- "div",
600
- { class: "grabby-toast-row" },
601
- h("span", { class: "grabby-toast-label" }, label),
602
- typeof value === "string" ? h("span", { class: "grabby-toast-value" }, value) : value
603
- );
604
- }
605
- function showToast(message, opts = {}) {
606
- const toast = getOrCreateToast();
607
- const { detail, actions } = opts;
608
- const durationMs = _nullishCoalesce(opts.duration, () => ( (_optionalChain([actions, 'optionalAccess', _16 => _16.length]) ? 8e3 : 3500)));
609
- const children = [
610
- h(
611
- "div",
612
- { class: "grabby-toast-header" },
613
- svgIcon(ICON_CHECK_CIRCLE, "grabby-toast-icon"),
614
- h("span", { class: "grabby-toast-title" }, message)
615
- )
616
- ];
617
- if (detail) {
618
- const details = h("div", { class: "grabby-toast-details" });
619
- if (detail.componentName) details.appendChild(row("Component", detail.componentName));
620
- if (detail.filePath) {
621
- const loc = detail.line != null ? `${detail.filePath}:${detail.line}` : detail.filePath;
622
- details.appendChild(row("File", h("a", {
623
- class: "grabby-toast-file-link",
624
- href: vsCodeUri(detail.filePath, detail.line, detail.column),
625
- title: "Open in VS Code"
626
- }, loc)));
627
- }
628
- if (detail.cssClasses && detail.cssClasses.length > 0) {
629
- details.appendChild(row("Classes", detail.cssClasses.map((c) => `.${c}`).join(" ")));
630
- }
631
- children.push(details);
632
- }
633
- if (_optionalChain([actions, 'optionalAccess', _17 => _17.length])) {
634
- children[0].appendChild(h(
635
- "span",
636
- { class: "grabby-toast-actions" },
637
- ...actions.map((a) => h("button", {
638
- type: "button",
639
- class: a.primary ? "grabby-toast-action grabby-toast-action-primary" : "grabby-toast-action",
640
- onclick: (e) => {
641
- e.stopPropagation();
642
- hideToast();
643
- a.onClick();
644
- }
645
- }, a.label))
646
- ));
647
- }
648
- toast.replaceChildren(...children);
649
- if (activeTimer) {
650
- clearTimeout(activeTimer);
651
- activeTimer = null;
652
- }
653
- toast.classList.remove("grabby-toast-visible");
654
- void toast.offsetHeight;
655
- toast.classList.add("grabby-toast-visible");
656
- activeTimer = setTimeout(() => {
657
- toast.classList.remove("grabby-toast-visible");
658
- activeTimer = null;
659
- }, durationMs);
660
- }
661
- function hideToast() {
662
- if (activeTimer) {
663
- clearTimeout(activeTimer);
664
- activeTimer = null;
665
- }
666
- _optionalChain([toastEl, 'optionalAccess', _18 => _18.classList, 'access', _19 => _19.remove, 'call', _20 => _20("grabby-toast-visible")]);
667
- }
668
- function disposeToast() {
669
- if (activeTimer) {
670
- clearTimeout(activeTimer);
671
- activeTimer = null;
672
- }
673
- _optionalChain([toastEl, 'optionalAccess', _21 => _21.remove, 'call', _22 => _22()]);
674
- toastEl = null;
675
- removeStyles(TOAST_STYLE_ID);
676
- }
677
-
678
- // src/core/utils.ts
679
- function filterAngularClasses(classList) {
680
- return Array.from(classList).filter((c) => !c.startsWith("ng-") && !c.startsWith("_ng"));
681
- }
682
- function cssEscape(value) {
683
- if (typeof CSS !== "undefined" && typeof CSS.escape === "function") return CSS.escape(value);
684
- let out = "";
685
- for (let i = 0; i < value.length; i++) {
686
- const ch = value.charAt(i);
687
- const code = value.charCodeAt(i);
688
- if (code === 0) {
689
- out += "\uFFFD";
690
- continue;
691
- }
692
- if (code >= 1 && code <= 31 || code === 127 || i === 0 && code >= 48 && code <= 57 || i === 1 && code >= 48 && code <= 57 && value.charCodeAt(0) === 45) {
693
- out += `\\${code.toString(16)} `;
694
- continue;
695
- }
696
- if (i === 0 && value.length === 1 && code === 45) {
697
- out += `\\${ch}`;
698
- continue;
699
- }
700
- if (code >= 128 || code === 45 || code === 95 || code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122) {
701
- out += ch;
702
- continue;
703
- }
704
- out += `\\${ch}`;
705
- }
706
- return out;
707
- }
708
- function safeQuery(selector, root2 = document) {
709
- if (!selector) return null;
710
- try {
711
- return root2.querySelector(selector);
712
- } catch (e3) {
713
- return null;
714
- }
715
- }
716
- var TEST_ID_ATTRS = ["data-testid", "data-test", "data-cy", "data-qa"];
717
- var MAX_SELECTOR_DEPTH = 8;
718
- function isUnique(selector, el) {
719
- try {
720
- const matches = el.ownerDocument.querySelectorAll(selector);
721
- return matches.length === 1 && matches[0] === el;
722
- } catch (e4) {
723
- return false;
724
- }
725
- }
726
- function stepFor(el) {
727
- const tag = el.tagName.toLowerCase();
728
- const parent = el.parentElement;
729
- if (!parent) return tag;
730
- const sameTag = Array.from(parent.children).filter((c) => c.tagName === el.tagName);
731
- if (sameTag.length === 1) return tag;
732
- return `${tag}:nth-of-type(${sameTag.indexOf(el) + 1})`;
733
- }
734
- function buildUniqueSelector(el) {
735
- for (const attr of TEST_ID_ATTRS) {
736
- const value = el.getAttribute(attr);
737
- if (value) {
738
- const sel = `[${attr}="${value.replace(/["\\]/g, "\\$&")}"]`;
739
- if (isUnique(sel, el)) return sel;
941
+ display: flex;
942
+ flex-direction: column;
943
+ gap: 4px;
944
+ font-size: 12px;
945
+ font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
740
946
  }
741
- }
742
- if (el.id) {
743
- const sel = `#${cssEscape(el.id)}`;
744
- if (isUnique(sel, el)) return sel;
745
- }
746
- const steps = [];
747
- let current = el;
748
- while (current && steps.length < MAX_SELECTOR_DEPTH) {
749
- if (current !== el && current.id) {
750
- const anchor = `#${cssEscape(current.id)}`;
751
- if (isUnique(anchor, current)) {
752
- steps.unshift(anchor);
753
- break;
754
- }
947
+ #${TOAST_ID} .grabby-toast-row {
948
+ display: flex;
949
+ gap: 8px;
950
+ align-items: baseline;
755
951
  }
756
- steps.unshift(stepFor(current));
757
- const sel = steps.join(" > ");
758
- if (isUnique(sel, el)) return sel;
759
- if (current.tagName === "BODY" || current.tagName === "HTML") break;
760
- current = current.parentElement;
761
- }
762
- return steps.join(" > ");
763
- }
764
-
765
- // src/core/capture/kind.ts
766
- var ACTION_TAGS = /* @__PURE__ */ new Set(["BUTTON", "A", "SUMMARY"]);
767
- var ACTION_ROLES = /* @__PURE__ */ new Set(["button", "link", "tab", "menuitem", "menuitemcheckbox", "menuitemradio", "switch", "option", "checkbox", "radio"]);
768
- var BUTTON_INPUT_TYPES = /* @__PURE__ */ new Set(["button", "submit", "reset", "image"]);
769
- var FIELD_TAGS = /* @__PURE__ */ new Set(["INPUT", "SELECT", "TEXTAREA"]);
770
- var FIELD_ROLES = /* @__PURE__ */ new Set(["textbox", "combobox", "searchbox", "spinbutton", "slider"]);
771
- var MEDIA_TAGS = /* @__PURE__ */ new Set(["IMG", "SVG", "VIDEO", "PICTURE", "CANVAS", "IFRAME", "AUDIO"]);
772
- var TEXT_TAGS = /* @__PURE__ */ new Set([
773
- "H1",
774
- "H2",
775
- "H3",
776
- "H4",
777
- "H5",
778
- "H6",
779
- "P",
780
- "SPAN",
781
- "LABEL",
782
- "LI",
783
- "STRONG",
784
- "EM",
785
- "B",
786
- "I",
787
- "SMALL",
788
- "BLOCKQUOTE",
789
- "CODE",
790
- "PRE",
791
- "TD",
792
- "TH",
793
- "DT",
794
- "DD",
795
- "FIGCAPTION",
796
- "LEGEND",
797
- "CAPTION",
798
- "Q",
799
- "CITE",
800
- "MARK",
801
- "TIME"
802
- ]);
803
- var PAGE_TAGS = /* @__PURE__ */ new Set(["HTML", "BODY", "MAIN"]);
804
- var LANDMARK_TAGS = /* @__PURE__ */ new Set(["HEADER", "FOOTER", "NAV", "ASIDE"]);
805
- var SECTION_AREA_RATIO = 0.6;
806
- function role(el) {
807
- return (_nullishCoalesce(el.getAttribute("role"), () => ( ""))).toLowerCase();
808
- }
809
- function isAction(el) {
810
- if (ACTION_TAGS.has(el.tagName)) return el.tagName !== "A" || el.hasAttribute("href") || el.hasAttribute("role");
811
- if (el.tagName === "INPUT" && BUTTON_INPUT_TYPES.has(el.type)) return true;
812
- return ACTION_ROLES.has(role(el));
813
- }
814
- function isField(el) {
815
- if (el.tagName === "INPUT") return !BUTTON_INPUT_TYPES.has(el.type);
816
- if (FIELD_TAGS.has(el.tagName)) return true;
817
- if (el.isContentEditable && el.getAttribute("contenteditable") !== null) return true;
818
- return FIELD_ROLES.has(role(el));
819
- }
820
- function coversViewport(el) {
821
- const rect = el.getBoundingClientRect();
822
- const vw = window.innerWidth || document.documentElement.clientWidth;
823
- const vh = window.innerHeight || document.documentElement.clientHeight;
824
- if (!vw || !vh) return false;
825
- const w = Math.max(0, Math.min(rect.right, vw) - Math.max(rect.left, 0));
826
- const hgt = Math.max(0, Math.min(rect.bottom, vh) - Math.max(rect.top, 0));
827
- return w * hgt / (vw * vh) >= SECTION_AREA_RATIO;
828
- }
829
- function hasElementChildren(el) {
830
- return el.children.length > 0;
952
+ #${TOAST_ID} .grabby-toast-label {
953
+ color: var(--grabby-toast-label, #64748b);
954
+ flex-shrink: 0;
955
+ min-width: 72px;
956
+ }
957
+ #${TOAST_ID} .grabby-toast-value {
958
+ color: var(--grabby-toast-text, #334155);
959
+ overflow: hidden;
960
+ text-overflow: ellipsis;
961
+ white-space: nowrap;
962
+ }
963
+ #${TOAST_ID} .grabby-toast-file-link {
964
+ color: var(--grabby-toast-text, #334155);
965
+ text-decoration: none;
966
+ overflow: hidden;
967
+ text-overflow: ellipsis;
968
+ white-space: nowrap;
969
+ pointer-events: auto;
970
+ cursor: pointer;
971
+ }
972
+ #${TOAST_ID} .grabby-toast-file-link:hover {
973
+ text-decoration: underline;
974
+ color: var(--grabby-accent, #2563eb);
975
+ }
976
+ `);
831
977
  }
832
- function detectKind(el) {
833
- if (PAGE_TAGS.has(el.tagName)) return "section";
834
- if (MEDIA_TAGS.has(el.tagName)) return "media";
835
- if (isField(el)) return "field";
836
- if (isAction(el)) return "action";
837
- if (LANDMARK_TAGS.has(el.tagName) || role(el) === "main" || role(el) === "region") {
838
- return coversViewport(el) ? "section" : "container";
839
- }
840
- if (TEXT_TAGS.has(el.tagName)) return "text";
841
- if (!hasElementChildren(el) && (_nullishCoalesce(el.textContent, () => ( ""))).trim()) return "text";
842
- if (coversViewport(el)) return "section";
843
- return "container";
978
+ var toastEl = null;
979
+ function getOrCreateToast() {
980
+ if (_optionalChain([toastEl, 'optionalAccess', _21 => _21.isConnected])) return toastEl;
981
+ injectToastStyles();
982
+ toastEl = h("div", { id: TOAST_ID, role: "status", "aria-live": "polite" });
983
+ getUiRoot().appendChild(toastEl);
984
+ return toastEl;
844
985
  }
845
- var PROMOTE_DEPTH = 3;
846
- function promoteTarget(el) {
847
- if (isAction(el) || isField(el)) return el;
848
- let current = el.parentElement;
849
- for (let depth = 0; current && depth < PROMOTE_DEPTH; depth++) {
850
- if (isAction(current) || isField(current)) return current;
851
- if (PAGE_TAGS.has(current.tagName)) break;
852
- current = current.parentElement;
853
- }
854
- return el;
986
+ function vsCodeUri(filePath, line, column) {
987
+ let uri = `vscode://file/${encodeURI(filePath)}`;
988
+ if (line != null) uri += `:${line}`;
989
+ if (line != null && column != null) uri += `:${column}`;
990
+ return uri;
855
991
  }
856
-
857
- // src/core/capture/redact.ts
858
- var EMAIL = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g;
859
- var JWT = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g;
860
- var BEARER = /\b(Bearer|Basic|Token)\s+[A-Za-z0-9._~+/=-]{8,}/gi;
861
- var LONG_NUMBER = /\b\d(?:[ -]?\d){8,}\b/g;
862
- var OPAQUE_TOKEN = /\b[A-Za-z0-9_-]{32,}\b/g;
863
- var SENSITIVE_PARAM = /([?&#](?:access_token|id_token|token|key|api_key|apikey|secret|password|pass|auth|code|session|sig|signature)=)[^&#\s]*/gi;
864
- function redact(text, options = {}) {
865
- if (!text) return text;
866
- const scrubbed = text.replace(SENSITIVE_PARAM, "$1[redacted]").replace(JWT, "[token]").replace(BEARER, "$1 [token]");
867
- return (options.keepEmails ? scrubbed : scrubbed.replace(EMAIL, "[email]")).replace(LONG_NUMBER, "[number]").replace(OPAQUE_TOKEN, (m) => /\d/.test(m) && /[A-Za-z]/.test(m) ? "[token]" : m);
992
+ function row(label, value) {
993
+ return h(
994
+ "div",
995
+ { class: "grabby-toast-row" },
996
+ h("span", { class: "grabby-toast-label" }, label),
997
+ typeof value === "string" ? h("span", { class: "grabby-toast-value" }, value) : value
998
+ );
868
999
  }
869
- function sanitizeRoute(loc, keepParams = []) {
870
- let route = loc.pathname || "/";
871
- if (keepParams.length > 0 && loc.search) {
872
- const params = new URLSearchParams(loc.search);
873
- const kept = new URLSearchParams();
874
- for (const name of keepParams) {
875
- const value = params.get(name);
876
- if (value !== null) kept.set(name, value);
1000
+ function showToast(message, opts = {}) {
1001
+ const toast = getOrCreateToast();
1002
+ const { detail, actions } = opts;
1003
+ const durationMs = _nullishCoalesce(opts.duration, () => ( (_optionalChain([actions, 'optionalAccess', _22 => _22.length]) ? 8e3 : 3500)));
1004
+ const children = [
1005
+ h(
1006
+ "div",
1007
+ { class: "grabby-toast-header" },
1008
+ svgIcon(ICON_CHECK_CIRCLE, "grabby-toast-icon"),
1009
+ h("span", { class: "grabby-toast-title" }, message)
1010
+ )
1011
+ ];
1012
+ if (detail) {
1013
+ const details = h("div", { class: "grabby-toast-details" });
1014
+ if (detail.componentName) details.appendChild(row("Component", detail.componentName));
1015
+ if (detail.filePath) {
1016
+ const loc = detail.line != null ? `${detail.filePath}:${detail.line}` : detail.filePath;
1017
+ details.appendChild(row("File", h("a", {
1018
+ class: "grabby-toast-file-link",
1019
+ href: vsCodeUri(detail.filePath, detail.line, detail.column),
1020
+ title: "Open in VS Code"
1021
+ }, loc)));
877
1022
  }
878
- const qs = kept.toString();
879
- if (qs) route += `?${qs}`;
880
- }
881
- if (loc.hash.startsWith("#/")) route += loc.hash.split("?")[0];
882
- return redact(route);
883
- }
884
- function sanitizeUrl(raw, base = typeof location !== "undefined" ? location.href : "http://localhost/") {
885
- try {
886
- const url = new URL(raw, base);
887
- if (url.protocol === "javascript:" || url.protocol === "data:" || url.protocol === "vbscript:") return `${url.protocol}\u2026`;
888
- const baseUrl = new URL(base);
889
- const path = url.pathname + (url.hash.startsWith("#/") ? url.hash : "");
890
- return redact(url.origin === baseUrl.origin ? path : `${url.host}${path}`);
891
- } catch (e5) {
892
- return redact(raw.split(/[?#]/)[0]);
893
- }
894
- }
895
-
896
- // src/core/capture/preview.ts
897
- var MASK_ATTR = "data-grabby-mask";
898
- var IGNORE_ATTR = "data-grabby-ignore";
899
- var PRIORITY_ATTRS = [
900
- "id",
901
- "class",
902
- "role",
903
- "aria-label",
904
- "data-testid",
905
- "data-test",
906
- "data-cy",
907
- "name",
908
- "type",
909
- "href",
910
- "src",
911
- "alt",
912
- "placeholder",
913
- "title",
914
- "for",
915
- "aria-expanded",
916
- "aria-selected",
917
- "disabled"
918
- ];
919
- var URL_ATTRS = /* @__PURE__ */ new Set(["href", "src"]);
920
- var MAX_ATTRS = 8;
921
- var MAX_CLASS_CHARS = 60;
922
- var MAX_ATTR_CHARS = 80;
923
- var MAX_TEXT_CHARS = 80;
924
- var MAX_PREVIEW_CHARS = 300;
925
- function isNoiseAttr(name) {
926
- return name.startsWith("_ng") || name.startsWith("ng-reflect-") || name.startsWith("data-v-") || name.startsWith("data-grabby-") || name.startsWith("data-svelte") || name === "style" || name === "value" || name.startsWith("on");
1023
+ if (detail.cssClasses && detail.cssClasses.length > 0) {
1024
+ details.appendChild(row("Classes", detail.cssClasses.map((c) => `.${c}`).join(" ")));
1025
+ }
1026
+ children.push(details);
1027
+ }
1028
+ if (_optionalChain([actions, 'optionalAccess', _23 => _23.length])) {
1029
+ children[0].appendChild(h(
1030
+ "span",
1031
+ { class: "grabby-toast-actions" },
1032
+ ...actions.map((a) => h("button", {
1033
+ type: "button",
1034
+ class: a.primary ? "grabby-toast-action grabby-toast-action-primary" : "grabby-toast-action",
1035
+ onclick: (e) => {
1036
+ e.stopPropagation();
1037
+ hideToast();
1038
+ a.onClick();
1039
+ }
1040
+ }, a.label))
1041
+ ));
1042
+ }
1043
+ toast.replaceChildren(...children);
1044
+ if (activeTimer) {
1045
+ clearTimeout(activeTimer);
1046
+ activeTimer = null;
1047
+ }
1048
+ toast.classList.remove("grabby-toast-visible");
1049
+ void toast.offsetHeight;
1050
+ toast.classList.add("grabby-toast-visible");
1051
+ activeTimer = setTimeout(() => {
1052
+ toast.classList.remove("grabby-toast-visible");
1053
+ activeTimer = null;
1054
+ }, durationMs);
927
1055
  }
928
- function isNoiseClass(name) {
929
- return name.startsWith("ng-") || name.startsWith("_ng") || /^svelte-[a-z0-9]+$/i.test(name) || /^s-[A-Za-z0-9_-]{8,}$/.test(name);
1056
+ function hideToast() {
1057
+ if (activeTimer) {
1058
+ clearTimeout(activeTimer);
1059
+ activeTimer = null;
1060
+ }
1061
+ _optionalChain([toastEl, 'optionalAccess', _24 => _24.classList, 'access', _25 => _25.remove, 'call', _26 => _26("grabby-toast-visible")]);
930
1062
  }
931
- function truncate(text, max) {
932
- return text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}\u2026`;
1063
+ function disposeToast() {
1064
+ if (activeTimer) {
1065
+ clearTimeout(activeTimer);
1066
+ activeTimer = null;
1067
+ }
1068
+ _optionalChain([toastEl, 'optionalAccess', _27 => _27.remove, 'call', _28 => _28()]);
1069
+ toastEl = null;
1070
+ removeStyles(TOAST_STYLE_ID);
933
1071
  }
934
- function isMasked(el) {
935
- return el.closest(`[${MASK_ATTR}]`) !== null;
1072
+
1073
+ // src/core/utils.ts
1074
+ function filterAngularClasses(classList) {
1075
+ return Array.from(classList).filter((c) => !c.startsWith("ng-") && !c.startsWith("_ng"));
936
1076
  }
937
- function textOf(el, max) {
938
- if (isMasked(el)) return "[masked]";
939
- let raw = "";
940
- const walker = el.ownerDocument.createTreeWalker(el, NodeFilter.SHOW_TEXT);
941
- for (let node = walker.nextNode(); node; node = walker.nextNode()) {
942
- const parent = node.parentElement;
943
- if (parent && /^(SCRIPT|STYLE|NOSCRIPT|TEMPLATE)$/.test(parent.tagName)) continue;
944
- if (_optionalChain([parent, 'optionalAccess', _23 => _23.closest, 'call', _24 => _24(`[${IGNORE_ATTR}], [${MASK_ATTR}]`)])) continue;
945
- raw += ` ${_nullishCoalesce(node.nodeValue, () => ( ""))}`;
946
- if (raw.length > max * 3) break;
1077
+ function cssEscape(value) {
1078
+ if (typeof CSS !== "undefined" && typeof CSS.escape === "function") return CSS.escape(value);
1079
+ let out = "";
1080
+ for (let i = 0; i < value.length; i++) {
1081
+ const ch = value.charAt(i);
1082
+ const code = value.charCodeAt(i);
1083
+ if (code === 0) {
1084
+ out += "\uFFFD";
1085
+ continue;
1086
+ }
1087
+ if (code >= 1 && code <= 31 || code === 127 || i === 0 && code >= 48 && code <= 57 || i === 1 && code >= 48 && code <= 57 && value.charCodeAt(0) === 45) {
1088
+ out += `\\${code.toString(16)} `;
1089
+ continue;
1090
+ }
1091
+ if (i === 0 && value.length === 1 && code === 45) {
1092
+ out += `\\${ch}`;
1093
+ continue;
1094
+ }
1095
+ if (code >= 128 || code === 45 || code === 95 || code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122) {
1096
+ out += ch;
1097
+ continue;
1098
+ }
1099
+ out += `\\${ch}`;
947
1100
  }
948
- return truncate(redact(raw.replace(/\s+/g, " ").trim()), max);
1101
+ return out;
949
1102
  }
950
- function ownText(el) {
951
- let raw = "";
952
- for (const node of Array.from(el.childNodes)) {
953
- if (node.nodeType === Node.TEXT_NODE) raw += ` ${_nullishCoalesce(node.nodeValue, () => ( ""))}`;
1103
+ function safeQuery(selector, root2 = document) {
1104
+ if (!selector) return null;
1105
+ try {
1106
+ return root2.querySelector(selector);
1107
+ } catch (e5) {
1108
+ return null;
954
1109
  }
955
- return raw.replace(/\s+/g, " ").trim();
956
1110
  }
957
- function attrValue(el, name, value, cleanClasses) {
958
- if (name === "class") {
959
- const classes = cleanClasses(value.split(/\s+/).filter(Boolean));
960
- if (classes.length === 0) return null;
961
- return truncate(classes.join(" "), MAX_CLASS_CHARS);
1111
+ var TEST_ID_ATTRS = ["data-testid", "data-test", "data-cy", "data-qa"];
1112
+ var MAX_SELECTOR_DEPTH = 8;
1113
+ function isUnique(selector, el) {
1114
+ try {
1115
+ const matches = el.ownerDocument.querySelectorAll(selector);
1116
+ return matches.length === 1 && matches[0] === el;
1117
+ } catch (e6) {
1118
+ return false;
962
1119
  }
963
- if (URL_ATTRS.has(name)) return truncate(sanitizeUrl(value), 120);
964
- return truncate(redact(value, { keepEmails: name === "placeholder" }), MAX_ATTR_CHARS);
965
1120
  }
966
- function openingTag(el, cleanClasses = (l) => l.filter((c) => !isNoiseClass(c))) {
1121
+ function stepFor(el) {
967
1122
  const tag = el.tagName.toLowerCase();
968
- const attrs = [];
969
- const seen2 = /* @__PURE__ */ new Set();
970
- const add = (name) => {
971
- if (attrs.length >= MAX_ATTRS || seen2.has(name) || isNoiseAttr(name)) return;
972
- const raw = el.getAttribute(name);
973
- if (raw === null) return;
974
- seen2.add(name);
975
- if (raw === "") {
976
- attrs.push(name);
977
- return;
1123
+ const parent = el.parentElement;
1124
+ if (!parent) return tag;
1125
+ const sameTag = Array.from(parent.children).filter((c) => c.tagName === el.tagName);
1126
+ if (sameTag.length === 1) return tag;
1127
+ return `${tag}:nth-of-type(${sameTag.indexOf(el) + 1})`;
1128
+ }
1129
+ function buildUniqueSelector(el) {
1130
+ for (const attr of TEST_ID_ATTRS) {
1131
+ const value = el.getAttribute(attr);
1132
+ if (value) {
1133
+ const sel = `[${attr}="${value.replace(/["\\]/g, "\\$&")}"]`;
1134
+ if (isUnique(sel, el)) return sel;
978
1135
  }
979
- const value = attrValue(el, name, raw, cleanClasses);
980
- if (value !== null) attrs.push(`${name}="${value.replace(/"/g, "&quot;")}"`);
981
- };
982
- for (const name of PRIORITY_ATTRS) add(name);
983
- for (const { name } of Array.from(el.attributes)) {
984
- if (name.startsWith("aria-")) add(name);
985
1136
  }
986
- return `<${tag}${attrs.length ? ` ${attrs.join(" ")}` : ""}>`;
987
- }
988
- function buildPreview(el, cleanClasses) {
989
- const tag = el.tagName.toLowerCase();
990
- const open = openingTag(el, cleanClasses);
991
- if (/^(img|input|br|hr|meta|link|source|area|col|embed|wbr)$/.test(tag)) {
992
- return truncate(open, MAX_PREVIEW_CHARS);
1137
+ if (el.id) {
1138
+ const sel = `#${cssEscape(el.id)}`;
1139
+ if (isUnique(sel, el)) return sel;
993
1140
  }
994
- const children = Array.from(el.children).filter((c) => !c.hasAttribute(IGNORE_ATTR));
995
- let inner;
996
- if (isMasked(el)) {
997
- inner = "[masked]";
998
- } else if (children.length === 0) {
999
- inner = truncate(redact(ownText(el)), MAX_TEXT_CHARS);
1000
- } else if (children.length <= 2) {
1001
- const text = truncate(redact(ownText(el)), 40);
1002
- const kids = children.map((c) => {
1003
- const t = textOf(c, 30);
1004
- return `<${c.tagName.toLowerCase()}${t ? `>${t}</${c.tagName.toLowerCase()}>` : " \u2026>"}`;
1005
- });
1006
- inner = [text, ...kids].filter(Boolean).join(" ");
1007
- } else {
1008
- inner = `(${children.length} elements)`;
1141
+ const steps = [];
1142
+ let current = el;
1143
+ while (current && steps.length < MAX_SELECTOR_DEPTH) {
1144
+ if (current !== el && current.id) {
1145
+ const anchor = `#${cssEscape(current.id)}`;
1146
+ if (isUnique(anchor, current)) {
1147
+ steps.unshift(anchor);
1148
+ break;
1149
+ }
1150
+ }
1151
+ steps.unshift(stepFor(current));
1152
+ const sel = steps.join(" > ");
1153
+ if (isUnique(sel, el)) return sel;
1154
+ if (current.tagName === "BODY" || current.tagName === "HTML") break;
1155
+ current = current.parentElement;
1009
1156
  }
1010
- return truncate(`${open}${inner}</${tag}>`, MAX_PREVIEW_CHARS);
1157
+ return steps.join(" > ");
1011
1158
  }
1012
1159
 
1013
1160
  // src/core/picker/element-picker.ts
1014
1161
  function createElementPicker(deps) {
1015
1162
  let hoveredElement = null;
1163
+ let heldElement = null;
1016
1164
  let listening = false;
1017
1165
  function resolveComponentName(el) {
1018
1166
  const resolver = deps.getComponentResolver();
1019
1167
  if (!resolver) return null;
1020
1168
  const result = resolver(el);
1021
- return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _25 => _25.name]), () => ( null));
1169
+ return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _29 => _29.name]), () => ( null));
1022
1170
  }
1023
1171
  function resolveSourcePath(el) {
1024
1172
  const resolver = deps.getSourceResolver();
1025
1173
  if (!resolver) return null;
1026
1174
  const result = resolver(el);
1027
- if (!_optionalChain([result, 'optionalAccess', _26 => _26.filePath])) return null;
1175
+ if (!_optionalChain([result, 'optionalAccess', _30 => _30.filePath])) return null;
1028
1176
  let path = result.filePath;
1029
1177
  if (result.line != null) {
1030
1178
  path += `:${result.line}`;
@@ -1032,7 +1180,7 @@ function createElementPicker(deps) {
1032
1180
  return path;
1033
1181
  }
1034
1182
  function rawElementAtPoint(x, y) {
1035
- const freezeEl = _optionalChain([deps, 'access', _27 => _27.getFreezeElement, 'optionalCall', _28 => _28()]);
1183
+ const freezeEl = _optionalChain([deps, 'access', _31 => _31.getFreezeElement, 'optionalCall', _32 => _32()]);
1036
1184
  if (freezeEl) freezeEl.style.pointerEvents = "none";
1037
1185
  const target = document.elementFromPoint(x, y);
1038
1186
  if (freezeEl) freezeEl.style.pointerEvents = "auto";
@@ -1040,29 +1188,34 @@ function createElementPicker(deps) {
1040
1188
  }
1041
1189
  function elementAtPoint(x, y, exact) {
1042
1190
  const raw = rawElementAtPoint(x, y);
1043
- if (!raw || raw.closest(`[${IGNORE_ATTR}]`)) return raw && _optionalChain([deps, 'access', _29 => _29.isToolbarElement, 'optionalCall', _30 => _30(raw)]) ? raw : null;
1191
+ if (!raw || raw.closest(`[${IGNORE_ATTR}]`)) return raw && _optionalChain([deps, 'access', _33 => _33.isToolbarElement, 'optionalCall', _34 => _34(raw)]) ? raw : null;
1044
1192
  return exact ? raw : promoteTarget(raw);
1045
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
+ }
1046
1200
  function handleMouseMove(e) {
1201
+ if (heldElement) return;
1047
1202
  const target = elementAtPoint(e.clientX, e.clientY, e.shiftKey);
1048
1203
  if (!target || deps.overlay.isOverlayElement(target)) return;
1049
1204
  if (deps.crosshair.isCrosshairElement(target)) return;
1050
- if (_optionalChain([deps, 'access', _31 => _31.isToolbarElement, 'optionalCall', _32 => _32(target)])) return;
1205
+ if (_optionalChain([deps, 'access', _35 => _35.isToolbarElement, 'optionalCall', _36 => _36(target)])) return;
1051
1206
  if (target === hoveredElement) return;
1052
1207
  hoveredElement = target;
1053
- const componentName = resolveComponentName(target);
1054
- const sourcePath = resolveSourcePath(target);
1055
- const cssClasses = filterAngularClasses(target.classList);
1056
- deps.overlay.show(target, componentName, sourcePath, cssClasses);
1208
+ showOverlay(target);
1057
1209
  deps.onHover(target);
1058
1210
  }
1059
1211
  function handleClick(e) {
1060
1212
  const origin = eventTarget(e);
1061
- if (origin && _optionalChain([deps, 'access', _33 => _33.isToolbarElement, 'optionalCall', _34 => _34(origin)])) return;
1213
+ if (origin && _optionalChain([deps, 'access', _37 => _37.isToolbarElement, 'optionalCall', _38 => _38(origin)])) return;
1062
1214
  const target = rawElementAtPoint(e.clientX, e.clientY);
1063
- if (target && (_optionalChain([deps, 'access', _35 => _35.isToolbarElement, 'optionalCall', _36 => _36(target)]) || deps.crosshair.isCrosshairElement(target))) return;
1215
+ if (target && (_optionalChain([deps, 'access', _39 => _39.isToolbarElement, 'optionalCall', _40 => _40(target)]) || deps.crosshair.isCrosshairElement(target))) return;
1064
1216
  e.preventDefault();
1065
1217
  e.stopPropagation();
1218
+ if (heldElement) return;
1066
1219
  if (hoveredElement) {
1067
1220
  deps.onSelect(hoveredElement);
1068
1221
  }
@@ -1079,12 +1232,29 @@ function createElementPicker(deps) {
1079
1232
  if (!listening) return;
1080
1233
  listening = false;
1081
1234
  hoveredElement = null;
1235
+ heldElement = null;
1236
+ deps.crosshair.hold(false);
1082
1237
  deps.crosshair.deactivate();
1083
1238
  document.removeEventListener("mousemove", handleMouseMove, true);
1084
1239
  document.removeEventListener("click", handleClick, true);
1085
1240
  deps.overlay.hide();
1086
1241
  deps.onHover(null);
1087
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
+ },
1088
1258
  getHoveredElement() {
1089
1259
  return hoveredElement;
1090
1260
  },
@@ -1137,6 +1307,7 @@ function matchesCombo(e, parsed) {
1137
1307
  function createKeyboardHandler(deps) {
1138
1308
  let holdTimer = null;
1139
1309
  let holdActivated = false;
1310
+ let togglePending = false;
1140
1311
  let listening = false;
1141
1312
  function handleKeyDown(e) {
1142
1313
  if (!deps.getEnableInInputs() && isEditableElement(eventTarget(e))) return;
@@ -1159,6 +1330,7 @@ function createKeyboardHandler(deps) {
1159
1330
  }
1160
1331
  } else {
1161
1332
  e.preventDefault();
1333
+ togglePending = true;
1162
1334
  }
1163
1335
  }
1164
1336
  function handleKeyUp(e) {
@@ -1175,6 +1347,8 @@ function createKeyboardHandler(deps) {
1175
1347
  deps.onDeactivate();
1176
1348
  }
1177
1349
  } else {
1350
+ if (!togglePending) return;
1351
+ togglePending = false;
1178
1352
  if (deps.isActive()) {
1179
1353
  deps.onDeactivate();
1180
1354
  } else {
@@ -1197,6 +1371,7 @@ function createKeyboardHandler(deps) {
1197
1371
  holdTimer = null;
1198
1372
  }
1199
1373
  holdActivated = false;
1374
+ togglePending = false;
1200
1375
  document.removeEventListener("keydown", handleKeyDown, true);
1201
1376
  document.removeEventListener("keyup", handleKeyUp, true);
1202
1377
  },
@@ -1233,7 +1408,7 @@ function createPluginRegistry() {
1233
1408
  },
1234
1409
  callHook(hookName, ...args) {
1235
1410
  for (const plugin of plugins.values()) {
1236
- const hook = _optionalChain([plugin, 'access', _37 => _37.hooks, 'optionalAccess', _38 => _38[hookName]]);
1411
+ const hook = _optionalChain([plugin, 'access', _41 => _41.hooks, 'optionalAccess', _42 => _42[hookName]]);
1237
1412
  if (hook) {
1238
1413
  try {
1239
1414
  hook(...args);
@@ -1246,7 +1421,7 @@ function createPluginRegistry() {
1246
1421
  callTransformHook(text, comments) {
1247
1422
  let result = text;
1248
1423
  for (const plugin of plugins.values()) {
1249
- const transform = _optionalChain([plugin, 'access', _39 => _39.hooks, 'optionalAccess', _40 => _40.transformCopyContent]);
1424
+ const transform = _optionalChain([plugin, 'access', _43 => _43.hooks, 'optionalAccess', _44 => _44.transformCopyContent]);
1250
1425
  if (transform) {
1251
1426
  try {
1252
1427
  result = transform(result, comments);
@@ -1264,7 +1439,7 @@ function createPluginRegistry() {
1264
1439
  for (const cleanup of cleanups.values()) {
1265
1440
  try {
1266
1441
  cleanup();
1267
- } catch (e6) {
1442
+ } catch (e7) {
1268
1443
  }
1269
1444
  }
1270
1445
  cleanups.clear();
@@ -1279,7 +1454,7 @@ function isAllowedWebhookUrl(raw) {
1279
1454
  const url = new URL(raw, typeof location !== "undefined" ? location.href : void 0);
1280
1455
  if (url.protocol === "https:") return true;
1281
1456
  return url.protocol === "http:" && /^(localhost|127\.0\.0\.1|\[::1\])$/.test(url.hostname);
1282
- } catch (e7) {
1457
+ } catch (e8) {
1283
1458
  return false;
1284
1459
  }
1285
1460
  }
@@ -1412,6 +1587,8 @@ function createToolbarRenderer(callbacks, options = {}) {
1412
1587
  let allElements = /* @__PURE__ */ new Set();
1413
1588
  let badge = null;
1414
1589
  let status = null;
1590
+ let expandBadge = null;
1591
+ let collapsed = false;
1415
1592
  function injectStyles2() {
1416
1593
  if (hasStyles(STYLE_ID3)) return;
1417
1594
  addStyles(STYLE_ID3, `
@@ -1527,6 +1704,24 @@ function createToolbarRenderer(callbacks, options = {}) {
1527
1704
  background: var(--grabby-accent-hover, #1d4ed8);
1528
1705
  color: #fff;
1529
1706
  }
1707
+ #${TOOLBAR_ID} button.grabby-btn-expand { display: none; }
1708
+ #${TOOLBAR_ID}.grabby-toolbar-collapsed {
1709
+ left: auto;
1710
+ right: 20px;
1711
+ transform: none;
1712
+ padding: 4px;
1713
+ }
1714
+ #${TOOLBAR_ID}.grabby-toolbar-collapsed.grabby-toolbar-hidden {
1715
+ transform: translateY(20px);
1716
+ }
1717
+ #${TOOLBAR_ID}.grabby-toolbar-collapsed > * { display: none !important; }
1718
+ #${TOOLBAR_ID}.grabby-toolbar-collapsed > button.grabby-btn-expand {
1719
+ display: flex !important;
1720
+ width: 40px;
1721
+ height: 40px;
1722
+ border-radius: 50%;
1723
+ color: var(--grabby-accent, #2563eb);
1724
+ }
1530
1725
  #${TOOLBAR_ID} .grabby-toolbar-left.grabby-toolbar-left-hidden {
1531
1726
  max-width: 0;
1532
1727
  opacity: 0;
@@ -1567,6 +1762,12 @@ function createToolbarRenderer(callbacks, options = {}) {
1567
1762
  buttons.history.appendChild(badge);
1568
1763
  buttons.enable = createButton("enable", ICON_POWER, "Enable/Disable", callbacks.onEnableToggle);
1569
1764
  buttons.dismiss = createButton("dismiss", ICON_DISMISS, _nullishCoalesce(options.dismissLabel, () => ( "Dismiss toolbar")), callbacks.onDismiss);
1765
+ buttons.expand = createButton("expand", ICON_GRAB, _nullishCoalesce(options.expandLabel, () => ( "Open Grabby toolbar")), () => _optionalChain([callbacks, 'access', _45 => _45.onExpand, 'optionalCall', _46 => _46()]));
1766
+ buttons.expand.classList.add("grabby-btn-expand");
1767
+ expandBadge = document.createElement("span");
1768
+ expandBadge.className = "grabby-badge";
1769
+ expandBadge.hidden = true;
1770
+ buttons.expand.appendChild(expandBadge);
1570
1771
  const divider = document.createElement("span");
1571
1772
  divider.className = "grabby-toolbar-divider";
1572
1773
  leftGroup = document.createElement("div");
@@ -1589,7 +1790,7 @@ function createToolbarRenderer(callbacks, options = {}) {
1589
1790
  buttons.finish.addEventListener("click", (e) => {
1590
1791
  e.preventDefault();
1591
1792
  e.stopPropagation();
1592
- _optionalChain([callbacks, 'access', _41 => _41.onFinish, 'optionalCall', _42 => _42()]);
1793
+ _optionalChain([callbacks, 'access', _47 => _47.onFinish, 'optionalCall', _48 => _48()]);
1593
1794
  });
1594
1795
  container.appendChild(status);
1595
1796
  container.appendChild(buttons.finish);
@@ -1597,6 +1798,8 @@ function createToolbarRenderer(callbacks, options = {}) {
1597
1798
  }
1598
1799
  if (!options.hideEnable) container.appendChild(buttons.enable);
1599
1800
  container.appendChild(buttons.dismiss);
1801
+ container.appendChild(buttons.expand);
1802
+ container.classList.toggle("grabby-toolbar-collapsed", collapsed);
1600
1803
  getUiRoot().appendChild(container);
1601
1804
  allElements.clear();
1602
1805
  allElements.add(container);
@@ -1624,26 +1827,38 @@ function createToolbarRenderer(callbacks, options = {}) {
1624
1827
  buttons.selection.classList.remove("grabby-btn-active");
1625
1828
  }
1626
1829
  const count = state.toolbar.comments.length;
1627
- if (badge) {
1628
- badge.hidden = count === 0;
1629
- badge.textContent = count > 99 ? "99+" : String(count);
1830
+ for (const b of [badge, expandBadge]) {
1831
+ if (!b) continue;
1832
+ b.hidden = count === 0;
1833
+ b.textContent = count > 99 ? "99+" : String(count);
1630
1834
  }
1631
1835
  buttons.history.setAttribute("aria-label", count ? `Comments (${count})` : "Comments");
1632
1836
  if (status && buttons.finish) {
1633
1837
  const summary = syncSummary(state.toolbar.comments);
1634
1838
  status.hidden = !summary;
1635
- status.textContent = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _43 => _43.text]), () => ( ""));
1636
- status.dataset.tone = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _44 => _44.tone]), () => ( ""));
1839
+ status.textContent = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _49 => _49.text]), () => ( ""));
1840
+ status.dataset.tone = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _50 => _50.tone]), () => ( ""));
1637
1841
  buttons.finish.hidden = count === 0;
1638
1842
  }
1639
1843
  if (state.options.enabled) {
1640
1844
  buttons.enable.classList.add("grabby-btn-active");
1641
- _optionalChain([leftGroup, 'optionalAccess', _45 => _45.classList, 'access', _46 => _46.remove, 'call', _47 => _47("grabby-toolbar-left-hidden")]);
1845
+ _optionalChain([leftGroup, 'optionalAccess', _51 => _51.classList, 'access', _52 => _52.remove, 'call', _53 => _53("grabby-toolbar-left-hidden")]);
1642
1846
  } else {
1643
1847
  buttons.enable.classList.remove("grabby-btn-active");
1644
- _optionalChain([leftGroup, 'optionalAccess', _48 => _48.classList, 'access', _49 => _49.add, 'call', _50 => _50("grabby-toolbar-left-hidden")]);
1848
+ _optionalChain([leftGroup, 'optionalAccess', _54 => _54.classList, 'access', _55 => _55.add, 'call', _56 => _56("grabby-toolbar-left-hidden")]);
1645
1849
  }
1646
1850
  },
1851
+ collapse() {
1852
+ collapsed = true;
1853
+ _optionalChain([container, 'optionalAccess', _57 => _57.classList, 'access', _58 => _58.add, 'call', _59 => _59("grabby-toolbar-collapsed")]);
1854
+ },
1855
+ expand() {
1856
+ collapsed = false;
1857
+ _optionalChain([container, 'optionalAccess', _60 => _60.classList, 'access', _61 => _61.remove, 'call', _62 => _62("grabby-toolbar-collapsed")]);
1858
+ },
1859
+ isCollapsed() {
1860
+ return collapsed;
1861
+ },
1647
1862
  isToolbarElement(el) {
1648
1863
  if (allElements.has(el)) return true;
1649
1864
  let current = el;
@@ -1655,12 +1870,13 @@ function createToolbarRenderer(callbacks, options = {}) {
1655
1870
  return false;
1656
1871
  },
1657
1872
  dispose() {
1658
- _optionalChain([container, 'optionalAccess', _51 => _51.remove, 'call', _52 => _52()]);
1873
+ _optionalChain([container, 'optionalAccess', _63 => _63.remove, 'call', _64 => _64()]);
1659
1874
  removeStyles(STYLE_ID3);
1660
1875
  container = null;
1661
1876
  leftGroup = null;
1662
1877
  buttons = {};
1663
1878
  badge = null;
1879
+ expandBadge = null;
1664
1880
  status = null;
1665
1881
  allElements.clear();
1666
1882
  }
@@ -1705,7 +1921,7 @@ function header(comments, env, ctx) {
1705
1921
  if (frameworks.length) meta.push(frameworks.join(", "));
1706
1922
  const routes = uniq(comments.map((c) => c.page.route));
1707
1923
  if (!ctx.showRoutes && routes.length === 1) meta.push(`page ${routes[0]}`);
1708
- const vp = _optionalChain([comments, 'access', _53 => _53[0], 'optionalAccess', _54 => _54.page, 'access', _55 => _55.viewport]);
1924
+ const vp = _optionalChain([comments, 'access', _65 => _65[0], 'optionalAccess', _66 => _66.page, 'access', _67 => _67.viewport]);
1709
1925
  if (vp) meta.push(`${vp[0]}\xD7${vp[1]}`);
1710
1926
  meta.push((_nullishCoalesce(env.now, () => ( /* @__PURE__ */ new Date()))).toISOString().slice(0, 10));
1711
1927
  lines.push(meta.join(" \xB7 "));
@@ -1731,8 +1947,8 @@ function detailBlock(c, i, ctx, groupHasSource, headedComponent) {
1731
1947
  const b = (text) => lines.push(` - ${text}`);
1732
1948
  const where = [`\`${t.preview}\``, `(${t.kind})`];
1733
1949
  if (t.component && t.component !== headedComponent) {
1734
- where.push(_optionalChain([t, 'access', _56 => _56.source, 'optionalAccess', _57 => _57.line]) != null && groupHasSource ? `${t.component} line ${t.source.line}` : t.component);
1735
- } else if (_optionalChain([t, 'access', _58 => _58.source, 'optionalAccess', _59 => _59.line]) != null && groupHasSource) {
1950
+ where.push(_optionalChain([t, 'access', _68 => _68.source, 'optionalAccess', _69 => _69.line]) != null && groupHasSource ? `${t.component} line ${t.source.line}` : t.component);
1951
+ } else if (_optionalChain([t, 'access', _70 => _70.source, 'optionalAccess', _71 => _71.line]) != null && groupHasSource) {
1736
1952
  where.push(`line ${t.source.line}`);
1737
1953
  }
1738
1954
  b(where.join(" "));
@@ -1748,7 +1964,7 @@ function detailBlock(c, i, ctx, groupHasSource, headedComponent) {
1748
1964
  for (const [k, v] of Object.entries(t.extra)) b(`${k}: ${v}`);
1749
1965
  b(`viewport: ${c.page.viewport[0]}\xD7${c.page.viewport[1]}`);
1750
1966
  }
1751
- if (_optionalChain([c, 'access', _60 => _60.screenshot, 'optionalAccess', _61 => _61.url])) b(`screenshot: ${c.screenshot.url}`);
1967
+ if (_optionalChain([c, 'access', _72 => _72.screenshot, 'optionalAccess', _73 => _73.url])) b(`screenshot: ${c.screenshot.url}`);
1752
1968
  const meta = [];
1753
1969
  if (ctx.showAuthors) meta.push(`by ${authorLabel(c.author)}`);
1754
1970
  if (ctx.showRoutes) meta.push(`on ${c.page.route}`);
@@ -1774,7 +1990,7 @@ function formatExport(comments, level = "standard", env = {}) {
1774
1990
  }
1775
1991
  const groups = /* @__PURE__ */ new Map();
1776
1992
  for (const c of ordered) {
1777
- const key = _nullishCoalesce(_optionalChain([c, 'access', _62 => _62.target, 'access', _63 => _63.source, 'optionalAccess', _64 => _64.file]), () => ( ""));
1993
+ const key = _nullishCoalesce(_optionalChain([c, 'access', _74 => _74.target, 'access', _75 => _75.source, 'optionalAccess', _76 => _76.file]), () => ( ""));
1778
1994
  const list = groups.get(key);
1779
1995
  if (list) list.push(c);
1780
1996
  else groups.set(key, [c]);
@@ -1784,7 +2000,7 @@ function formatExport(comments, level = "standard", env = {}) {
1784
2000
  out.push("");
1785
2001
  const components = uniq(list.map((c) => c.target.component));
1786
2002
  const headed = file && components.length === 1 ? components[0] : null;
1787
- const lines = uniq(list.map((c) => _nullishCoalesce(_optionalChain([c, 'access', _65 => _65.target, 'access', _66 => _66.source, 'optionalAccess', _67 => _67.line]), () => ( null))));
2003
+ const lines = uniq(list.map((c) => _nullishCoalesce(_optionalChain([c, 'access', _77 => _77.target, 'access', _78 => _78.source, 'optionalAccess', _79 => _79.line]), () => ( null))));
1788
2004
  if (file) {
1789
2005
  const loc = lines.length === 1 ? location2(file, lines[0], true) : file;
1790
2006
  out.push(`## ${loc}${headed ? ` \xB7 ${headed}` : ""}`);
@@ -1819,7 +2035,7 @@ function openDb() {
1819
2035
  req.onsuccess = () => resolve(req.result);
1820
2036
  req.onerror = () => resolve(null);
1821
2037
  req.onblocked = () => resolve(null);
1822
- } catch (e8) {
2038
+ } catch (e9) {
1823
2039
  resolve(null);
1824
2040
  }
1825
2041
  });
@@ -1835,7 +2051,7 @@ async function run(mode, fn) {
1835
2051
  tx.oncomplete = () => resolve(req ? req.result : null);
1836
2052
  tx.onerror = () => resolve(null);
1837
2053
  tx.onabort = () => resolve(null);
1838
- } catch (e9) {
2054
+ } catch (e10) {
1839
2055
  resolve(null);
1840
2056
  }
1841
2057
  });
@@ -1969,7 +2185,7 @@ function createCommentsPanel(callbacks, options = {}) {
1969
2185
  let visible = false;
1970
2186
  let objectUrls = [];
1971
2187
  function ensurePanel() {
1972
- if (_optionalChain([panel, 'optionalAccess', _68 => _68.isConnected])) return panel;
2188
+ if (_optionalChain([panel, 'optionalAccess', _80 => _80.isConnected])) return panel;
1973
2189
  addStyles(STYLE_ID4, CSS2);
1974
2190
  panel = h("div", { id: PANEL_ID, role: "dialog", "aria-label": "Comments" });
1975
2191
  getUiRoot().appendChild(panel);
@@ -1980,7 +2196,7 @@ function createCommentsPanel(callbacks, options = {}) {
1980
2196
  objectUrls = [];
1981
2197
  }
1982
2198
  function thumbnail(comment) {
1983
- const localId = _optionalChain([comment, 'access', _69 => _69.screenshot, 'optionalAccess', _70 => _70.localId]);
2199
+ const localId = _optionalChain([comment, 'access', _81 => _81.screenshot, 'optionalAccess', _82 => _82.localId]);
1984
2200
  if (!localId) return null;
1985
2201
  const img = h("img", { class: "grabby-thumb", alt: "", loading: "lazy" });
1986
2202
  img.addEventListener("error", () => img.remove(), { once: true });
@@ -1997,16 +2213,18 @@ function createCommentsPanel(callbacks, options = {}) {
1997
2213
  }
1998
2214
  function row2(comment, showAuthors) {
1999
2215
  const t = comment.target;
2000
- const meta = [h("span", { class: "grabby-kind" }, t.kind)];
2001
- if (t.component) meta.push(document.createTextNode(`${t.component} `));
2002
- if (t.source) {
2003
- meta.push(h("a", {
2004
- href: vsCodeUri2(t.source.file, t.source.line, t.source.column),
2005
- title: `Open ${t.source.file} in VS Code`,
2006
- onclick: (e) => e.stopPropagation()
2007
- }, `${basename2(t.source.file)}${t.source.line != null ? `:${t.source.line}` : ""}`));
2008
- } else if (!t.component) {
2009
- meta.push(document.createTextNode(`<${t.tag}>`));
2216
+ const meta = live ? [document.createTextNode(`${describeTarget(t)} `)] : [h("span", { class: "grabby-kind" }, t.kind)];
2217
+ if (!live) {
2218
+ if (t.component) meta.push(document.createTextNode(`${t.component} `));
2219
+ if (t.source) {
2220
+ meta.push(h("a", {
2221
+ href: vsCodeUri2(t.source.file, t.source.line, t.source.column),
2222
+ title: `Open ${t.source.file} in VS Code`,
2223
+ onclick: (e) => e.stopPropagation()
2224
+ }, `${basename2(t.source.file)}${t.source.line != null ? `:${t.source.line}` : ""}`));
2225
+ } else if (!t.component) {
2226
+ meta.push(document.createTextNode(`<${t.tag}>`));
2227
+ }
2010
2228
  }
2011
2229
  const tail = [showAuthors && !live ? authorLabel(comment.author) : "", formatRelativeTime(comment.createdAt)].filter(Boolean);
2012
2230
  meta.push(document.createTextNode(` \xB7 ${tail.join(" \xB7 ")}`));
@@ -2087,7 +2305,7 @@ function createCommentsPanel(callbacks, options = {}) {
2087
2305
  h("strong", null, live ? "Nothing sent yet" : "No comments yet"),
2088
2306
  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."
2089
2307
  ) : h("div", { class: "grabby-panel-list" }, ...comments.map((c) => row2(c, showAuthors)));
2090
- const who = _nullishCoalesce(_optionalChain([options, 'access', _71 => _71.identityLabel, 'optionalCall', _72 => _72()]), () => ( null));
2308
+ const who = _nullishCoalesce(_optionalChain([options, 'access', _83 => _83.identityLabel, 'optionalCall', _84 => _84()]), () => ( null));
2091
2309
  let footer = null;
2092
2310
  if (live && who) {
2093
2311
  footer = h(
@@ -2100,7 +2318,7 @@ function createCommentsPanel(callbacks, options = {}) {
2100
2318
  "data-grabby-change-identity": "",
2101
2319
  onclick: (e) => {
2102
2320
  e.stopPropagation();
2103
- _optionalChain([callbacks, 'access', _73 => _73.onChangeIdentity, 'optionalCall', _74 => _74()]);
2321
+ _optionalChain([callbacks, 'access', _85 => _85.onChangeIdentity, 'optionalCall', _86 => _86()]);
2104
2322
  }
2105
2323
  }, "Change")
2106
2324
  );
@@ -2134,7 +2352,7 @@ function createCommentsPanel(callbacks, options = {}) {
2134
2352
  },
2135
2353
  hide() {
2136
2354
  visible = false;
2137
- _optionalChain([panel, 'optionalAccess', _75 => _75.classList, 'access', _76 => _76.remove, 'call', _77 => _77("grabby-popover-visible")]);
2355
+ _optionalChain([panel, 'optionalAccess', _87 => _87.classList, 'access', _88 => _88.remove, 'call', _89 => _89("grabby-popover-visible")]);
2138
2356
  },
2139
2357
  isVisible() {
2140
2358
  return visible;
@@ -2144,7 +2362,7 @@ function createCommentsPanel(callbacks, options = {}) {
2144
2362
  },
2145
2363
  dispose() {
2146
2364
  revokeThumbs();
2147
- _optionalChain([panel, 'optionalAccess', _78 => _78.remove, 'call', _79 => _79()]);
2365
+ _optionalChain([panel, 'optionalAccess', _90 => _90.remove, 'call', _91 => _91()]);
2148
2366
  removeStyles(STYLE_ID4);
2149
2367
  panel = null;
2150
2368
  visible = false;
@@ -2304,7 +2522,7 @@ function createCommentPopover(callbacks) {
2304
2522
  autocomplete: "name",
2305
2523
  "aria-label": "Your name"
2306
2524
  });
2307
- const post = () => finish({ name: _optionalChain([nameInput, 'optionalAccess', _80 => _80.value, 'access', _81 => _81.trim, 'call', _82 => _82()]) || null });
2525
+ const post = () => finish({ name: _optionalChain([nameInput, 'optionalAccess', _92 => _92.value, 'access', _93 => _93.trim, 'call', _94 => _94()]) || null });
2308
2526
  popover.replaceChildren(
2309
2527
  h("div", { class: "grabby-cp-title" }, "Thanks! Who is this from?"),
2310
2528
  h("div", { class: "grabby-cp-sub" }, "Your name helps the team follow up. It's remembered in this browser."),
@@ -2338,7 +2556,7 @@ function createCommentPopover(callbacks) {
2338
2556
  } else if (e.key === "Enter" && deepActiveElement() === nameInput) {
2339
2557
  e.preventDefault();
2340
2558
  e.stopImmediatePropagation();
2341
- finish({ name: _optionalChain([nameInput, 'optionalAccess', _83 => _83.value, 'access', _84 => _84.trim, 'call', _85 => _85()]) || null });
2559
+ finish({ name: _optionalChain([nameInput, 'optionalAccess', _95 => _95.value, 'access', _96 => _96.trim, 'call', _97 => _97()]) || null });
2342
2560
  }
2343
2561
  return;
2344
2562
  }
@@ -2373,7 +2591,7 @@ function createCommentPopover(callbacks) {
2373
2591
  }
2374
2592
  function doHide() {
2375
2593
  visible = false;
2376
- _optionalChain([popover, 'optionalAccess', _86 => _86.remove, 'call', _87 => _87()]);
2594
+ _optionalChain([popover, 'optionalAccess', _98 => _98.remove, 'call', _99 => _99()]);
2377
2595
  popover = null;
2378
2596
  textarea = null;
2379
2597
  nameInput = null;
@@ -2391,8 +2609,8 @@ function createCommentPopover(callbacks) {
2391
2609
  visible = true;
2392
2610
  position(el, opts.anchor);
2393
2611
  attachKey();
2394
- _optionalChain([textarea, 'optionalAccess', _88 => _88.focus, 'call', _89 => _89()]);
2395
- requestAnimationFrame(() => _optionalChain([textarea, 'optionalAccess', _90 => _90.focus, 'call', _91 => _91()]));
2612
+ _optionalChain([textarea, 'optionalAccess', _100 => _100.focus, 'call', _101 => _101()]);
2613
+ requestAnimationFrame(() => _optionalChain([textarea, 'optionalAccess', _102 => _102.focus, 'call', _103 => _103()]));
2396
2614
  },
2397
2615
  hide() {
2398
2616
  if (!visible) return;
@@ -2404,7 +2622,7 @@ function createCommentPopover(callbacks) {
2404
2622
  hasDraft() {
2405
2623
  if (!visible) return false;
2406
2624
  if (stage === "identity") return true;
2407
- const v = _nullishCoalesce(_optionalChain([textarea, 'optionalAccess', _92 => _92.value, 'access', _93 => _93.trim, 'call', _94 => _94()]), () => ( ""));
2625
+ const v = _nullishCoalesce(_optionalChain([textarea, 'optionalAccess', _104 => _104.value, 'access', _105 => _105.trim, 'call', _106 => _106()]), () => ( ""));
2408
2626
  return v !== "" && v !== initialValue.trim();
2409
2627
  },
2410
2628
  isPopoverElement(el) {
@@ -2493,7 +2711,7 @@ function createCopySheet(callbacks) {
2493
2711
  document.removeEventListener("keydown", keyHandler, true);
2494
2712
  keyHandler = null;
2495
2713
  }
2496
- _optionalChain([callbacks, 'access', _95 => _95.onClose, 'optionalCall', _96 => _96()]);
2714
+ _optionalChain([callbacks, 'access', _107 => _107.onClose, 'optionalCall', _108 => _108()]);
2497
2715
  }
2498
2716
  function open(options) {
2499
2717
  close();
@@ -2515,12 +2733,12 @@ function createCopySheet(callbacks) {
2515
2733
  level = next;
2516
2734
  edited = false;
2517
2735
  textarea.value = options.render(level);
2518
- hint.textContent = _nullishCoalesce(_optionalChain([LEVELS, 'access', _97 => _97.find, 'call', _98 => _98((l) => l.id === level), 'optionalAccess', _99 => _99.hint]), () => ( ""));
2736
+ hint.textContent = _nullishCoalesce(_optionalChain([LEVELS, 'access', _109 => _109.find, 'call', _110 => _110((l) => l.id === level), 'optionalAccess', _111 => _111.hint]), () => ( ""));
2519
2737
  for (const [id, btn] of segButtons) btn.setAttribute("aria-checked", String(id === level));
2520
2738
  status.classList.remove("grabby-error");
2521
2739
  status.textContent = discarded ? "Your edits were replaced by the new detail level." : "";
2522
2740
  updateTokens();
2523
- _optionalChain([callbacks, 'access', _100 => _100.onLevelChange, 'optionalCall', _101 => _101(level)]);
2741
+ _optionalChain([callbacks, 'access', _112 => _112.onLevelChange, 'optionalCall', _113 => _113(level)]);
2524
2742
  }
2525
2743
  const seg = h(
2526
2744
  "div",
@@ -2598,7 +2816,7 @@ function createCopySheet(callbacks) {
2598
2816
  document.addEventListener("keydown", keyHandler, true);
2599
2817
  getUiRoot().appendChild(sheet);
2600
2818
  setLevel(level, true);
2601
- _optionalChain([sheet, 'access', _102 => _102.querySelector, 'call', _103 => _103("[data-grabby-copy-clear]"), 'optionalAccess', _104 => _104.focus, 'call', _105 => _105()]);
2819
+ _optionalChain([sheet, 'access', _114 => _114.querySelector, 'call', _115 => _115("[data-grabby-copy-clear]"), 'optionalAccess', _116 => _116.focus, 'call', _117 => _117()]);
2602
2820
  }
2603
2821
  return {
2604
2822
  open,
@@ -2746,7 +2964,7 @@ function createFinishSheet(callbacks) {
2746
2964
  ...note ? [h("div", { class: "grabby-finish-note" }, note)] : [],
2747
2965
  h("div", { class: "grabby-finish-actions" }, ...actions)
2748
2966
  );
2749
- _optionalChain([sheet, 'access', _106 => _106.querySelector, 'call', _107 => _107(".grabby-btn-primary:not([disabled])"), 'optionalAccess', _108 => _108.focus, 'call', _109 => _109()]);
2967
+ _optionalChain([sheet, 'access', _118 => _118.querySelector, 'call', _119 => _119(".grabby-btn-primary:not([disabled])"), 'optionalAccess', _120 => _120.focus, 'call', _121 => _121()]);
2750
2968
  }
2751
2969
  return {
2752
2970
  open(next) {
@@ -2816,21 +3034,21 @@ var CSS5 = `
2816
3034
  function seen() {
2817
3035
  try {
2818
3036
  return localStorage.getItem(SEEN_KEY) === "1";
2819
- } catch (e10) {
3037
+ } catch (e11) {
2820
3038
  return false;
2821
3039
  }
2822
3040
  }
2823
3041
  function markSeen() {
2824
3042
  try {
2825
3043
  localStorage.setItem(SEEN_KEY, "1");
2826
- } catch (e11) {
3044
+ } catch (e12) {
2827
3045
  }
2828
3046
  }
2829
3047
  function createCoachMark() {
2830
3048
  let el = null;
2831
3049
  function dismiss() {
2832
3050
  markSeen();
2833
- _optionalChain([el, 'optionalAccess', _110 => _110.remove, 'call', _111 => _111()]);
3051
+ _optionalChain([el, 'optionalAccess', _122 => _122.remove, 'call', _123 => _123()]);
2834
3052
  el = null;
2835
3053
  }
2836
3054
  return {
@@ -2862,7 +3080,7 @@ function createCoachMark() {
2862
3080
  },
2863
3081
  dismiss,
2864
3082
  dispose() {
2865
- _optionalChain([el, 'optionalAccess', _112 => _112.remove, 'call', _113 => _113()]);
3083
+ _optionalChain([el, 'optionalAccess', _124 => _124.remove, 'call', _125 => _125()]);
2866
3084
  el = null;
2867
3085
  removeStyles(STYLE_ID8);
2868
3086
  }
@@ -2879,8 +3097,8 @@ function loadJobs() {
2879
3097
  const raw = localStorage.getItem(STORE_KEY);
2880
3098
  const jobs = raw ? JSON.parse(raw) : [];
2881
3099
  if (!Array.isArray(jobs)) return [];
2882
- return jobs.filter((j) => typeof j.id === "string" && (j.kind === "comment" || j.kind === "shot")).map((j) => typeof j.created === "number" ? j : { ...j, created: Date.now() });
2883
- } catch (e12) {
3100
+ return jobs.filter((j) => typeof j.id === "string" && (j.kind === "comment" || j.kind === "shot" || j.kind === "delete" && typeof j.session === "string")).map((j) => typeof j.created === "number" ? j : { ...j, created: Date.now() });
3101
+ } catch (e13) {
2884
3102
  return [];
2885
3103
  }
2886
3104
  }
@@ -2899,7 +3117,7 @@ function createOutbox(deps) {
2899
3117
  try {
2900
3118
  if (jobs.length) localStorage.setItem(STORE_KEY, JSON.stringify(jobs));
2901
3119
  else localStorage.removeItem(STORE_KEY);
2902
- } catch (e13) {
3120
+ } catch (e14) {
2903
3121
  }
2904
3122
  }
2905
3123
  function headers(extra = {}) {
@@ -2936,20 +3154,34 @@ function createOutbox(deps) {
2936
3154
  body
2937
3155
  });
2938
3156
  }
3157
+ function deleteComment(id, session) {
3158
+ return fetch(`${base}/v1/comments/${encodeURIComponent(id)}`, {
3159
+ method: "DELETE",
3160
+ credentials: "omit",
3161
+ keepalive: true,
3162
+ headers: headers({ "X-Grabby-Session": session })
3163
+ });
3164
+ }
2939
3165
  async function deliver(job) {
3166
+ if (job.kind === "delete") {
3167
+ const res2 = await deleteComment(job.id, job.session);
3168
+ if (res2.ok || res2.status === 404) return "done";
3169
+ if (res2.status === 429 || res2.status >= 500) return "retry";
3170
+ return "drop";
3171
+ }
2940
3172
  const comment = deps.getComment(job.id);
2941
3173
  if (!comment) return "drop";
2942
3174
  if (job.kind === "comment") {
2943
3175
  const res2 = await postComment(comment);
2944
3176
  if (res2.ok) {
2945
- if (_optionalChain([deps, 'access', _114 => _114.getComment, 'call', _115 => _115(job.id), 'optionalAccess', _116 => _116.screenshot, 'optionalAccess', _117 => _117.localId])) add(job.id, "shot");
3177
+ if (_optionalChain([deps, 'access', _126 => _126.getComment, 'call', _127 => _127(job.id), 'optionalAccess', _128 => _128.screenshot, 'optionalAccess', _129 => _129.localId])) add(job.id, "shot");
2946
3178
  return "done";
2947
3179
  }
2948
3180
  if (res2.status === 429 || res2.status >= 500) return "retry";
2949
3181
  deps.onState(job.id, "failed", await res2.text().catch(() => String(res2.status)));
2950
3182
  return "drop";
2951
3183
  }
2952
- const localId = _optionalChain([comment, 'access', _118 => _118.screenshot, 'optionalAccess', _119 => _119.localId]);
3184
+ const localId = _optionalChain([comment, 'access', _130 => _130.screenshot, 'optionalAccess', _131 => _131.localId]);
2953
3185
  const blob = localId ? await deps.getScreenshot(localId) : null;
2954
3186
  if (!blob) return "drop";
2955
3187
  const { width, height } = comment.screenshot;
@@ -2973,7 +3205,7 @@ function createOutbox(deps) {
2973
3205
  let outcome;
2974
3206
  try {
2975
3207
  outcome = await deliver(job);
2976
- } catch (e14) {
3208
+ } catch (e15) {
2977
3209
  outcome = "retry";
2978
3210
  }
2979
3211
  if (outcome === "retry" && Date.now() - job.created < GIVE_UP_AFTER_MS) {
@@ -3001,6 +3233,19 @@ function createOutbox(deps) {
3001
3233
  if (jobs.length) schedule(500);
3002
3234
  return {
3003
3235
  send: (id) => add(id, "comment"),
3236
+ remove(id, sessionId, delayMs = 0) {
3237
+ jobs = jobs.filter((j) => j.id !== id);
3238
+ jobs.push({ id, kind: "delete", session: sessionId, attempts: 0, next: Date.now() + delayMs, created: Date.now() });
3239
+ save();
3240
+ schedule(0);
3241
+ },
3242
+ cancelRemove(id) {
3243
+ const job = jobs.find((j) => j.id === id && j.kind === "delete");
3244
+ if (!job) return false;
3245
+ jobs = jobs.filter((j) => j !== job);
3246
+ save();
3247
+ return job.attempts === 0;
3248
+ },
3004
3249
  sendScreenshot: (id) => {
3005
3250
  if (!jobs.some((j) => j.id === id && j.kind === "comment")) add(id, "shot");
3006
3251
  },
@@ -3008,11 +3253,18 @@ function createOutbox(deps) {
3008
3253
  flush: onOnline,
3009
3254
  flushOnExit() {
3010
3255
  for (const job of jobs) {
3256
+ if (job.kind === "delete") {
3257
+ job.attempts += 1;
3258
+ deleteComment(job.id, job.session).catch(() => {
3259
+ });
3260
+ continue;
3261
+ }
3011
3262
  if (job.kind !== "comment") continue;
3012
3263
  const comment = deps.getComment(job.id);
3013
3264
  if (comment) postComment(comment).catch(() => {
3014
3265
  });
3015
3266
  }
3267
+ save();
3016
3268
  },
3017
3269
  dispose() {
3018
3270
  disposed = true;
@@ -3113,7 +3365,7 @@ function createFreezeOverlay() {
3113
3365
  let rules;
3114
3366
  try {
3115
3367
  rules = sheet.cssRules;
3116
- } catch (e15) {
3368
+ } catch (e16) {
3117
3369
  continue;
3118
3370
  }
3119
3371
  collectHoverRules(rules, cloned);
@@ -3190,7 +3442,7 @@ function createFreezeOverlay() {
3190
3442
  removeHoverRules();
3191
3443
  unfreezeAnimations();
3192
3444
  unblockEvents();
3193
- _optionalChain([overlay, 'optionalAccess', _120 => _120.remove, 'call', _121 => _121()]);
3445
+ _optionalChain([overlay, 'optionalAccess', _132 => _132.remove, 'call', _133 => _133()]);
3194
3446
  removeStyles(FREEZE_STYLE_ID);
3195
3447
  overlay = null;
3196
3448
  visible = false;
@@ -3301,10 +3553,10 @@ function loadHistory() {
3301
3553
  return [];
3302
3554
  }
3303
3555
  return parsed.entries;
3304
- } catch (e16) {
3556
+ } catch (e17) {
3305
3557
  try {
3306
3558
  localStorage.removeItem(STORAGE_KEY);
3307
- } catch (e17) {
3559
+ } catch (e18) {
3308
3560
  }
3309
3561
  return [];
3310
3562
  }
@@ -3338,7 +3590,7 @@ function writeWithQuotaFallback(entries) {
3338
3590
  const half = entries.slice(0, Math.floor(entries.length / 2));
3339
3591
  try {
3340
3592
  localStorage.setItem(STORAGE_KEY, JSON.stringify({ v: SCHEMA_VERSION, entries: half }));
3341
- } catch (e18) {
3593
+ } catch (e19) {
3342
3594
  warnQuotaOnce();
3343
3595
  }
3344
3596
  } else {
@@ -3364,7 +3616,7 @@ function clearPersistedHistory() {
3364
3616
  pendingEntries = null;
3365
3617
  try {
3366
3618
  localStorage.removeItem(STORAGE_KEY);
3367
- } catch (e19) {
3619
+ } catch (e20) {
3368
3620
  }
3369
3621
  }
3370
3622
 
@@ -3372,7 +3624,7 @@ function clearPersistedHistory() {
3372
3624
  var baselineFrame = null;
3373
3625
  var baselineCache = /* @__PURE__ */ new Map();
3374
3626
  function baselineDoc() {
3375
- if (_optionalChain([baselineFrame, 'optionalAccess', _122 => _122.isConnected]) && baselineFrame.contentDocument) return baselineFrame.contentDocument;
3627
+ if (_optionalChain([baselineFrame, 'optionalAccess', _134 => _134.isConnected]) && baselineFrame.contentDocument) return baselineFrame.contentDocument;
3376
3628
  try {
3377
3629
  baselineFrame = document.createElement("iframe");
3378
3630
  baselineFrame.setAttribute("aria-hidden", "true");
@@ -3388,7 +3640,7 @@ function baselineDoc() {
3388
3640
  });
3389
3641
  document.documentElement.appendChild(baselineFrame);
3390
3642
  return baselineFrame.contentDocument;
3391
- } catch (e20) {
3643
+ } catch (e21) {
3392
3644
  return null;
3393
3645
  }
3394
3646
  }
@@ -3402,8 +3654,8 @@ function baselineFor(tag, type, props) {
3402
3654
  const missing = props.filter((p) => !cached.has(p));
3403
3655
  if (missing.length > 0) {
3404
3656
  const doc = baselineDoc();
3405
- const view = _optionalChain([doc, 'optionalAccess', _123 => _123.defaultView]);
3406
- if (_optionalChain([doc, 'optionalAccess', _124 => _124.body]) && view) {
3657
+ const view = _optionalChain([doc, 'optionalAccess', _135 => _135.defaultView]);
3658
+ if (_optionalChain([doc, 'optionalAccess', _136 => _136.body]) && view) {
3407
3659
  const probe = doc.createElement(tag);
3408
3660
  if (type) probe.setAttribute("type", type);
3409
3661
  doc.body.appendChild(probe);
@@ -3417,7 +3669,7 @@ function baselineFor(tag, type, props) {
3417
3669
  return cached;
3418
3670
  }
3419
3671
  function disposeStyleBaseline() {
3420
- _optionalChain([baselineFrame, 'optionalAccess', _125 => _125.remove, 'call', _126 => _126()]);
3672
+ _optionalChain([baselineFrame, 'optionalAccess', _137 => _137.remove, 'call', _138 => _138()]);
3421
3673
  baselineFrame = null;
3422
3674
  baselineCache.clear();
3423
3675
  }
@@ -3451,7 +3703,7 @@ function customStyles(el, props) {
3451
3703
  let cs;
3452
3704
  try {
3453
3705
  cs = getComputedStyle(el);
3454
- } catch (e21) {
3706
+ } catch (e22) {
3455
3707
  return out;
3456
3708
  }
3457
3709
  const tag = el.tagName.toLowerCase();
@@ -3519,7 +3771,7 @@ function states(el) {
3519
3771
  }
3520
3772
  function actionFacts(el) {
3521
3773
  const f = {};
3522
- const imgAlt = _nullishCoalesce(_optionalChain([el, 'access', _127 => _127.querySelector, 'call', _128 => _128("img[alt]"), 'optionalAccess', _129 => _129.getAttribute, 'call', _130 => _130("alt")]), () => ( ""));
3774
+ const imgAlt = _nullishCoalesce(_optionalChain([el, 'access', _139 => _139.querySelector, 'call', _140 => _140("img[alt]"), 'optionalAccess', _141 => _141.getAttribute, 'call', _142 => _142("alt")]), () => ( ""));
3523
3775
  put(f, "label", accessibleLabel(el) || textOf(el, 80) || redact(_nullishCoalesce(el.getAttribute("title"), () => ( ""))) || redact(imgAlt));
3524
3776
  if (el.tagName === "A") put(f, "href", sanitizeUrl(_nullishCoalesce(el.getAttribute("href"), () => ( ""))));
3525
3777
  else if (el.tagName === "BUTTON" || el.tagName === "INPUT") put(f, "type", _nullishCoalesce(el.getAttribute("type"), () => ( (el.tagName === "BUTTON" ? "submit" : ""))));
@@ -3568,7 +3820,7 @@ function mediaFacts(el) {
3568
3820
  put(f, "label", accessibleLabel(el) || textOf(_nullishCoalesce(el.querySelector("title"), () => ( el)), 40));
3569
3821
  put(f, "viewBox", _nullishCoalesce(el.getAttribute("viewBox"), () => ( "")));
3570
3822
  } else if (el.tagName === "VIDEO" || el.tagName === "AUDIO" || el.tagName === "IFRAME") {
3571
- put(f, "src", basename3(_nullishCoalesce(_nullishCoalesce(el.getAttribute("src"), () => ( _optionalChain([el, 'access', _131 => _131.querySelector, 'call', _132 => _132("source"), 'optionalAccess', _133 => _133.getAttribute, 'call', _134 => _134("src")]))), () => ( ""))));
3823
+ put(f, "src", basename3(_nullishCoalesce(_nullishCoalesce(el.getAttribute("src"), () => ( _optionalChain([el, 'access', _143 => _143.querySelector, 'call', _144 => _144("source"), 'optionalAccess', _145 => _145.getAttribute, 'call', _146 => _146("src")]))), () => ( ""))));
3572
3824
  put(f, "title", redact(_nullishCoalesce(el.getAttribute("title"), () => ( ""))));
3573
3825
  }
3574
3826
  put(f, "size", size(el));
@@ -3576,8 +3828,8 @@ function mediaFacts(el) {
3576
3828
  return f;
3577
3829
  }
3578
3830
  function childLabel(child, resolver) {
3579
- const resolved = _optionalChain([resolver, 'optionalCall', _135 => _135(child)]);
3580
- if (_optionalChain([resolved, 'optionalAccess', _136 => _136.name]) && resolved.hostElement === child) return resolved.name;
3831
+ const resolved = _optionalChain([resolver, 'optionalCall', _147 => _147(child)]);
3832
+ if (_optionalChain([resolved, 'optionalAccess', _148 => _148.name]) && resolved.hostElement === child) return resolved.name;
3581
3833
  const tag = child.tagName.toLowerCase();
3582
3834
  if (/^h[1-6]$/.test(tag)) return "heading";
3583
3835
  if (tag === "a") return "link";
@@ -3596,13 +3848,13 @@ function childSummary(el, resolver) {
3596
3848
  if (counts.size > 6) parts.push("\u2026");
3597
3849
  return parts.join(", ");
3598
3850
  }
3599
- function firstHeading(el) {
3851
+ function firstHeading2(el) {
3600
3852
  const heading = el.querySelector('h1, h2, h3, h4, h5, h6, [role="heading"]');
3601
3853
  return heading ? textOf(heading, 60) : "";
3602
3854
  }
3603
3855
  function containerFacts(el, resolver) {
3604
3856
  const f = {};
3605
- put(f, "heading", firstHeading(el));
3857
+ put(f, "heading", firstHeading2(el));
3606
3858
  put(f, "contains", childSummary(el, resolver));
3607
3859
  put(f, "size", size(el));
3608
3860
  put(f, "layout", formatStyles(customStyles(el, CONTAINER_STYLES)));
@@ -3612,8 +3864,8 @@ function sectionFacts(el, resolver) {
3612
3864
  const f = {};
3613
3865
  put(f, "title", redact(el.ownerDocument.title));
3614
3866
  put(f, "viewport", `${window.innerWidth}\xD7${window.innerHeight}`);
3615
- const regions = Array.from(el.querySelectorAll('header, nav, main, aside, footer, section, [role="region"]')).filter((r) => !_optionalChain([r, 'access', _137 => _137.parentElement, 'optionalAccess', _138 => _138.closest, 'call', _139 => _139('header, nav, main, aside, footer, section, [role="region"]')]) || r.parentElement === el).slice(0, 8).map((r) => {
3616
- const heading = firstHeading(r);
3867
+ const regions = Array.from(el.querySelectorAll('header, nav, main, aside, footer, section, [role="region"]')).filter((r) => !_optionalChain([r, 'access', _149 => _149.parentElement, 'optionalAccess', _150 => _150.closest, 'call', _151 => _151('header, nav, main, aside, footer, section, [role="region"]')]) || r.parentElement === el).slice(0, 8).map((r) => {
3868
+ const heading = firstHeading2(r);
3617
3869
  return heading ? `${r.tagName.toLowerCase()} "${truncate(heading, 30)}"` : r.tagName.toLowerCase();
3618
3870
  });
3619
3871
  put(f, "regions", regions.join(", "));
@@ -3669,22 +3921,22 @@ function isAppFile(file) {
3669
3921
  return !!file && !/(^|[\\/])node_modules[\\/]/.test(file);
3670
3922
  }
3671
3923
  function resolveStack(el, deps) {
3672
- const comp = _nullishCoalesce(_optionalChain([deps, 'access', _140 => _140.componentResolver, 'optionalCall', _141 => _141(el)]), () => ( null));
3924
+ const comp = _nullishCoalesce(_optionalChain([deps, 'access', _152 => _152.componentResolver, 'optionalCall', _153 => _153(el)]), () => ( null));
3673
3925
  const frames = [];
3674
3926
  const named = [];
3675
- for (const entry of _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _142 => _142.stack]), () => ( []))) {
3927
+ for (const entry of _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _154 => _154.stack]), () => ( []))) {
3676
3928
  const src = entry.filePath !== void 0 ? { filePath: entry.filePath, line: _nullishCoalesce(entry.line, () => ( null)) } : entry.hostElement && deps.sourceResolver ? deps.sourceResolver(entry.hostElement) : null;
3677
- const frame = { name: entry.name, file: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _143 => _143.filePath]), () => ( null)), line: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _144 => _144.line]), () => ( null)) };
3929
+ const frame = { name: entry.name, file: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _155 => _155.filePath]), () => ( null)), line: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _156 => _156.line]), () => ( null)) };
3678
3930
  named.push(frame);
3679
3931
  if (isAppFile(frame.file) && frames.length < MAX_STACK) frames.push(frame);
3680
3932
  }
3681
- return { component: _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _145 => _145.name]), () => ( null)), frames: frames.length > 0 ? frames : named.slice(0, 2) };
3933
+ return { component: _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _157 => _157.name]), () => ( null)), frames: frames.length > 0 ? frames : named.slice(0, 2) };
3682
3934
  }
3683
3935
  function resolveSource(el, deps, frames) {
3684
- const own = _optionalChain([deps, 'access', _146 => _146.sourceResolver, 'optionalCall', _147 => _147(el)]);
3936
+ const own = _optionalChain([deps, 'access', _158 => _158.sourceResolver, 'optionalCall', _159 => _159(el)]);
3685
3937
  if (own && isAppFile(own.filePath)) return { file: own.filePath, line: own.line, column: own.column };
3686
3938
  const first = frames.find((f) => isAppFile(f.file));
3687
- return _optionalChain([first, 'optionalAccess', _148 => _148.file]) ? { file: first.file, line: first.line, column: null } : null;
3939
+ return _optionalChain([first, 'optionalAccess', _160 => _160.file]) ? { file: first.file, line: first.line, column: null } : null;
3688
3940
  }
3689
3941
  function captureTarget(el, deps) {
3690
3942
  const cleanClasses = _nullishCoalesce(deps.cleanClasses, () => ( ((list) => list.filter((c) => !isNoiseClass(c)))));
@@ -3728,14 +3980,14 @@ function sandboxHtml() {
3728
3980
  if (policy === void 0) {
3729
3981
  try {
3730
3982
  policy = tt.createPolicy("grabby", { createHTML: (html) => html === SANDBOX_HTML ? html : "" });
3731
- } catch (e22) {
3983
+ } catch (e23) {
3732
3984
  policy = null;
3733
3985
  }
3734
3986
  }
3735
3987
  return policy ? policy.createHTML(SANDBOX_HTML) : null;
3736
3988
  }
3737
3989
  async function getSandbox() {
3738
- if (_optionalChain([sandbox, 'optionalAccess', _149 => _149.isConnected])) return sandbox;
3990
+ if (_optionalChain([sandbox, 'optionalAccess', _161 => _161.isConnected])) return sandbox;
3739
3991
  const frame = document.createElement("iframe");
3740
3992
  frame.setAttribute("aria-hidden", "true");
3741
3993
  frame.setAttribute("tabindex", "-1");
@@ -3750,7 +4002,7 @@ async function getSandbox() {
3750
4002
  setTimeout(done, 1e3);
3751
4003
  try {
3752
4004
  frame.srcdoc = html;
3753
- } catch (e23) {
4005
+ } catch (e24) {
3754
4006
  done();
3755
4007
  }
3756
4008
  });
@@ -3759,7 +4011,7 @@ async function getSandbox() {
3759
4011
  return frame;
3760
4012
  }
3761
4013
  function disposeScreenshotSandbox() {
3762
- _optionalChain([sandbox, 'optionalAccess', _150 => _150.remove, 'call', _151 => _151()]);
4014
+ _optionalChain([sandbox, 'optionalAccess', _162 => _162.remove, 'call', _163 => _163()]);
3763
4015
  sandbox = null;
3764
4016
  }
3765
4017
  function withTimeout(promise, ms) {
@@ -3822,7 +4074,7 @@ function randomId() {
3822
4074
  if (c && typeof c.randomUUID === "function") {
3823
4075
  try {
3824
4076
  return c.randomUUID();
3825
- } catch (e24) {
4077
+ } catch (e25) {
3826
4078
  }
3827
4079
  }
3828
4080
  const bytes = new Uint8Array(16);
@@ -3841,7 +4093,7 @@ function getSessionId() {
3841
4093
  const id = randomId();
3842
4094
  localStorage.setItem(SESSION_KEY, id);
3843
4095
  return id;
3844
- } catch (e25) {
4096
+ } catch (e26) {
3845
4097
  memorySession ??= randomId();
3846
4098
  return memorySession;
3847
4099
  }
@@ -3853,20 +4105,20 @@ function loadIdentity() {
3853
4105
  const parsed = JSON.parse(raw);
3854
4106
  if (typeof parsed !== "object" || parsed === null || typeof parsed.anonymous !== "boolean") return null;
3855
4107
  return { name: typeof parsed.name === "string" ? parsed.name.slice(0, 80) : null, anonymous: parsed.anonymous };
3856
- } catch (e26) {
4108
+ } catch (e27) {
3857
4109
  return null;
3858
4110
  }
3859
4111
  }
3860
4112
  function saveIdentity(identity) {
3861
4113
  try {
3862
4114
  localStorage.setItem(AUTHOR_KEY, JSON.stringify(identity));
3863
- } catch (e27) {
4115
+ } catch (e28) {
3864
4116
  }
3865
4117
  }
3866
4118
  function clearIdentity() {
3867
4119
  try {
3868
4120
  localStorage.removeItem(AUTHOR_KEY);
3869
- } catch (e28) {
4121
+ } catch (e29) {
3870
4122
  }
3871
4123
  }
3872
4124
  function currentAuthor(identity) {
@@ -3919,7 +4171,7 @@ function resolveComponent(element) {
3919
4171
  name: cleanComponentName(owning.constructor.name),
3920
4172
  hostElement: _nullishCoalesce(host2, () => ( walk.parentElement))
3921
4173
  });
3922
- current = _nullishCoalesce(_nullishCoalesce(_optionalChain([host2, 'optionalAccess', _152 => _152.parentElement]), () => ( _optionalChain([walk, 'access', _153 => _153.parentElement, 'optionalAccess', _154 => _154.parentElement]))), () => ( null));
4174
+ current = _nullishCoalesce(_nullishCoalesce(_optionalChain([host2, 'optionalAccess', _164 => _164.parentElement]), () => ( _optionalChain([walk, 'access', _165 => _165.parentElement, 'optionalAccess', _166 => _166.parentElement]))), () => ( null));
3923
4175
  while (current) {
3924
4176
  const comp = ng.getComponent(current);
3925
4177
  if (comp && !seen2.has(comp)) {
@@ -4053,14 +4305,14 @@ function resolveComponent2(element) {
4053
4305
  let current = fiber;
4054
4306
  while (current && stack.length < MAX_STACK2) {
4055
4307
  const name = getComponentName(current.type);
4056
- if (name && !isNoise(name) && _optionalChain([stack, 'access', _155 => _155[stack.length - 1], 'optionalAccess', _156 => _156.name]) !== name) {
4308
+ if (name && !isNoise(name) && _optionalChain([stack, 'access', _167 => _167[stack.length - 1], 'optionalAccess', _168 => _168.name]) !== name) {
4057
4309
  stack.push({ name, hostElement: findHostElement(current) });
4058
4310
  }
4059
4311
  current = current.return;
4060
4312
  }
4061
4313
  return {
4062
- name: _nullishCoalesce(_optionalChain([stack, 'access', _157 => _157[0], 'optionalAccess', _158 => _158.name]), () => ( null)),
4063
- hostElement: _nullishCoalesce(_optionalChain([stack, 'access', _159 => _159[0], 'optionalAccess', _160 => _160.hostElement]), () => ( null)),
4314
+ name: _nullishCoalesce(_optionalChain([stack, 'access', _169 => _169[0], 'optionalAccess', _170 => _170.name]), () => ( null)),
4315
+ hostElement: _nullishCoalesce(_optionalChain([stack, 'access', _171 => _171[0], 'optionalAccess', _172 => _172.hostElement]), () => ( null)),
4064
4316
  stack
4065
4317
  };
4066
4318
  }
@@ -4071,7 +4323,7 @@ var LOCATION = /^(.*?):(\d+):(\d+)(?::([A-Za-z_$][\w$.]*))?$/;
4071
4323
  function resolveSource3(element) {
4072
4324
  let current = element;
4073
4325
  while (current) {
4074
- const raw = _optionalChain([current, 'access', _161 => _161.getAttribute, 'optionalCall', _162 => _162(SOURCE_ATTRIBUTE)]);
4326
+ const raw = _optionalChain([current, 'access', _173 => _173.getAttribute, 'optionalCall', _174 => _174(SOURCE_ATTRIBUTE)]);
4075
4327
  if (raw) return parseLocation(raw);
4076
4328
  current = current.parentElement;
4077
4329
  }
@@ -4083,7 +4335,7 @@ function parseLocation(raw) {
4083
4335
  return { filePath: match[1], line: Number(match[2]), column: Number(match[3]) };
4084
4336
  }
4085
4337
  function ownStamp(element) {
4086
- const raw = _optionalChain([element, 'optionalAccess', _163 => _163.getAttribute, 'optionalCall', _164 => _164(SOURCE_ATTRIBUTE)]);
4338
+ const raw = _optionalChain([element, 'optionalAccess', _175 => _175.getAttribute, 'optionalCall', _176 => _176(SOURCE_ATTRIBUTE)]);
4087
4339
  if (!raw) return null;
4088
4340
  const match = LOCATION.exec(raw);
4089
4341
  if (!match) return { file: raw, line: null, column: null, name: null };
@@ -4098,8 +4350,8 @@ function nameFromStamps(result) {
4098
4350
  const stack = [];
4099
4351
  for (const entry of result.stack) {
4100
4352
  const stamp = ownStamp(entry.hostElement);
4101
- const name = _nullishCoalesce(_optionalChain([stamp, 'optionalAccess', _165 => _165.name]), () => ( (stamp ? baseName(stamp.file) : null)));
4102
- if (name && _optionalChain([stack, 'access', _166 => _166[stack.length - 1], 'optionalAccess', _167 => _167.name]) !== name) stack.push({ name, hostElement: entry.hostElement });
4353
+ const name = _nullishCoalesce(_optionalChain([stamp, 'optionalAccess', _177 => _177.name]), () => ( (stamp ? baseName(stamp.file) : null)));
4354
+ if (name && _optionalChain([stack, 'access', _178 => _178[stack.length - 1], 'optionalAccess', _179 => _179.name]) !== name) stack.push({ name, hostElement: entry.hostElement });
4103
4355
  }
4104
4356
  return stack[0] ? { name: stack[0].name, hostElement: stack[0].hostElement, stack } : null;
4105
4357
  }
@@ -4135,7 +4387,7 @@ function vue3Name(inst) {
4135
4387
  return t.__name || t.name || t.displayName || (t.__file ? baseName(t.__file) : null);
4136
4388
  }
4137
4389
  function vue3Host(inst) {
4138
- return firstElement(_nullishCoalesce(_optionalChain([inst, 'access', _168 => _168.subTree, 'optionalAccess', _169 => _169.el]), () => ( _optionalChain([inst, 'access', _170 => _170.vnode, 'optionalAccess', _171 => _171.el]))));
4390
+ return firstElement(_nullishCoalesce(_optionalChain([inst, 'access', _180 => _180.subTree, 'optionalAccess', _181 => _181.el]), () => ( _optionalChain([inst, 'access', _182 => _182.vnode, 'optionalAccess', _183 => _183.el]))));
4139
4391
  }
4140
4392
  function vue2Owner(el) {
4141
4393
  let current = el;
@@ -4175,7 +4427,7 @@ function resolveVueComponent(el) {
4175
4427
  }
4176
4428
  function resolveVueSource(el) {
4177
4429
  const inst3 = vue3Owner(el);
4178
- const file = _nullishCoalesce(_optionalChain([inst3, 'optionalAccess', _172 => _172.type, 'optionalAccess', _173 => _173.__file]), () => ( _optionalChain([vue2Owner, 'call', _174 => _174(el), 'optionalAccess', _175 => _175.$options, 'optionalAccess', _176 => _176.__file])));
4430
+ const file = _nullishCoalesce(_optionalChain([inst3, 'optionalAccess', _184 => _184.type, 'optionalAccess', _185 => _185.__file]), () => ( _optionalChain([vue2Owner, 'call', _186 => _186(el), 'optionalAccess', _187 => _187.$options, 'optionalAccess', _188 => _188.__file])));
4179
4431
  return file ? { filePath: relativizePath(file), line: null, column: null } : NO_SOURCE;
4180
4432
  }
4181
4433
  var vueAdapter = {
@@ -4191,19 +4443,19 @@ function metaOf(el) {
4191
4443
  let current = el;
4192
4444
  while (current) {
4193
4445
  const meta = current.__svelte_meta;
4194
- if (_optionalChain([meta, 'optionalAccess', _177 => _177.loc])) return { meta, el: current };
4446
+ if (_optionalChain([meta, 'optionalAccess', _189 => _189.loc])) return { meta, el: current };
4195
4447
  current = current.parentElement;
4196
4448
  }
4197
4449
  return null;
4198
4450
  }
4199
4451
  function lineOf(meta) {
4200
- const line = _optionalChain([meta, 'access', _178 => _178.loc, 'optionalAccess', _179 => _179.line]);
4452
+ const line = _optionalChain([meta, 'access', _190 => _190.loc, 'optionalAccess', _191 => _191.line]);
4201
4453
  if (typeof line !== "number") return null;
4202
4454
  return "parent" in meta ? line : line + 1;
4203
4455
  }
4204
4456
  function resolveSvelteComponent(el) {
4205
4457
  const found = metaOf(el);
4206
- if (!_optionalChain([found, 'optionalAccess', _180 => _180.meta, 'access', _181 => _181.loc, 'optionalAccess', _182 => _182.file])) return null;
4458
+ if (!_optionalChain([found, 'optionalAccess', _192 => _192.meta, 'access', _193 => _193.loc, 'optionalAccess', _194 => _194.file])) return null;
4207
4459
  const { meta } = found;
4208
4460
  const own = baseName(meta.loc.file);
4209
4461
  const stack = [{ name: own, hostElement: found.el }];
@@ -4217,9 +4469,9 @@ function resolveSvelteComponent(el) {
4217
4469
  }
4218
4470
  function resolveSvelteSource(el) {
4219
4471
  const found = metaOf(el);
4220
- const file = _optionalChain([found, 'optionalAccess', _183 => _183.meta, 'access', _184 => _184.loc, 'optionalAccess', _185 => _185.file]);
4472
+ const file = _optionalChain([found, 'optionalAccess', _195 => _195.meta, 'access', _196 => _196.loc, 'optionalAccess', _197 => _197.file]);
4221
4473
  if (!found || !file) return NO_SOURCE;
4222
- const column = _optionalChain([found, 'access', _186 => _186.meta, 'access', _187 => _187.loc, 'optionalAccess', _188 => _188.column]);
4474
+ const column = _optionalChain([found, 'access', _198 => _198.meta, 'access', _199 => _199.loc, 'optionalAccess', _200 => _200.column]);
4223
4475
  return {
4224
4476
  filePath: relativizePath(file),
4225
4477
  line: lineOf(found.meta),
@@ -4239,10 +4491,10 @@ var domAdapter = {
4239
4491
  name: "HTML",
4240
4492
  resolveComponent: (el) => {
4241
4493
  const host2 = el.closest("[data-component]");
4242
- const name = _optionalChain([host2, 'optionalAccess', _189 => _189.getAttribute, 'call', _190 => _190("data-component")]);
4494
+ const name = _optionalChain([host2, 'optionalAccess', _201 => _201.getAttribute, 'call', _202 => _202("data-component")]);
4243
4495
  if (!host2 || !name) return null;
4244
4496
  const stack = [];
4245
- for (let h2 = host2; h2; h2 = _nullishCoalesce(_optionalChain([h2, 'access', _191 => _191.parentElement, 'optionalAccess', _192 => _192.closest, 'call', _193 => _193("[data-component]")]), () => ( null))) {
4497
+ for (let h2 = host2; h2; h2 = _nullishCoalesce(_optionalChain([h2, 'access', _203 => _203.parentElement, 'optionalAccess', _204 => _204.closest, 'call', _205 => _205("[data-component]")]), () => ( null))) {
4246
4498
  const n = h2.getAttribute("data-component");
4247
4499
  if (n) stack.push({ name: n, hostElement: h2 });
4248
4500
  if (stack.length >= 12) break;
@@ -4264,15 +4516,15 @@ function composeAdapters(adapters = DEFAULT_ADAPTERS) {
4264
4516
  for (const adapter of adapters) {
4265
4517
  try {
4266
4518
  const result = adapter.resolveComponent(el);
4267
- if (_optionalChain([result, 'optionalAccess', _194 => _194.name])) return { adapter, result };
4268
- } catch (e29) {
4519
+ if (_optionalChain([result, 'optionalAccess', _206 => _206.name])) return { adapter, result };
4520
+ } catch (e30) {
4269
4521
  }
4270
4522
  }
4271
4523
  return null;
4272
4524
  }
4273
4525
  return {
4274
4526
  resolveComponent(el) {
4275
- return _nullishCoalesce(_optionalChain([owner, 'call', _195 => _195(el), 'optionalAccess', _196 => _196.result]), () => ( null));
4527
+ return _nullishCoalesce(_optionalChain([owner, 'call', _207 => _207(el), 'optionalAccess', _208 => _208.result]), () => ( null));
4276
4528
  },
4277
4529
  resolveSource(el) {
4278
4530
  const stamped = resolveSource3(el);
@@ -4281,15 +4533,15 @@ function composeAdapters(adapters = DEFAULT_ADAPTERS) {
4281
4533
  const ordered = found ? [found.adapter, ...adapters.filter((a) => a !== found.adapter)] : adapters;
4282
4534
  for (const adapter of ordered) {
4283
4535
  try {
4284
- const src = _optionalChain([adapter, 'access', _197 => _197.resolveSource, 'optionalCall', _198 => _198(el)]);
4285
- if (_optionalChain([src, 'optionalAccess', _199 => _199.filePath])) return src;
4286
- } catch (e30) {
4536
+ const src = _optionalChain([adapter, 'access', _209 => _209.resolveSource, 'optionalCall', _210 => _210(el)]);
4537
+ if (_optionalChain([src, 'optionalAccess', _211 => _211.filePath])) return src;
4538
+ } catch (e31) {
4287
4539
  }
4288
4540
  }
4289
4541
  return null;
4290
4542
  },
4291
4543
  frameworkFor(el) {
4292
- return _nullishCoalesce(_optionalChain([owner, 'call', _200 => _200(el), 'optionalAccess', _201 => _201.adapter, 'access', _202 => _202.name]), () => ( "HTML"));
4544
+ return _nullishCoalesce(_optionalChain([owner, 'call', _212 => _212(el), 'optionalAccess', _213 => _213.adapter, 'access', _214 => _214.name]), () => ( "HTML"));
4293
4545
  },
4294
4546
  cleanClasses(classes) {
4295
4547
  return adapters.reduce((list, a) => a.cleanClasses ? a.cleanClasses(list) : list, classes);
@@ -4321,7 +4573,7 @@ function getDefaultOptions() {
4321
4573
  };
4322
4574
  }
4323
4575
  function init(options) {
4324
- if (_optionalChain([options, 'optionalAccess', _203 => _203.mode]) === "live" && !_chunk6CBIOKZVcjs.consumeFeedbackLink.call(void 0, options.projectKey)) {
4576
+ if (_optionalChain([options, 'optionalAccess', _215 => _215.mode]) === "live" && !_chunk6CBIOKZVcjs.consumeFeedbackLink.call(void 0, options.projectKey)) {
4325
4577
  return createDormantApi(options);
4326
4578
  }
4327
4579
  return createGrabInstance(options);
@@ -4347,7 +4599,7 @@ function createDormantApi(options) {
4347
4599
  real.show();
4348
4600
  return;
4349
4601
  }
4350
- _optionalChain([flusher, 'optionalAccess', _204 => _204.dispose, 'call', _205 => _205()]);
4602
+ _optionalChain([flusher, 'optionalAccess', _216 => _216.dispose, 'call', _217 => _217()]);
4351
4603
  _chunk6CBIOKZVcjs.startFeedbackSession.call(void 0, );
4352
4604
  real = createGrabInstance(options);
4353
4605
  for (const fn of queued.splice(0)) fn(real);
@@ -4359,7 +4611,7 @@ function createDormantApi(options) {
4359
4611
  function flushLeftovers(options) {
4360
4612
  try {
4361
4613
  if (!localStorage.getItem("grabby:v1:outbox")) return null;
4362
- } catch (e31) {
4614
+ } catch (e32) {
4363
4615
  return null;
4364
4616
  }
4365
4617
  let comments = loadHistory();
@@ -4374,14 +4626,29 @@ function flushLeftovers(options) {
4374
4626
  }
4375
4627
  });
4376
4628
  }
4629
+ var COLLAPSED_KEY = "grabby:v1:collapsed";
4630
+ function loadCollapsed() {
4631
+ try {
4632
+ return sessionStorage.getItem(COLLAPSED_KEY) === "1";
4633
+ } catch (e33) {
4634
+ return false;
4635
+ }
4636
+ }
4637
+ function saveCollapsed(on) {
4638
+ try {
4639
+ if (on) sessionStorage.setItem(COLLAPSED_KEY, "1");
4640
+ else sessionStorage.removeItem(COLLAPSED_KEY);
4641
+ } catch (e34) {
4642
+ }
4643
+ }
4377
4644
  function isDevMode() {
4378
4645
  try {
4379
4646
  if (typeof ngDevMode !== "undefined" && ngDevMode === false) return false;
4380
- } catch (e32) {
4647
+ } catch (e35) {
4381
4648
  }
4382
4649
  try {
4383
4650
  if (process.env.NODE_ENV === "production") return false;
4384
- } catch (e33) {
4651
+ } catch (e36) {
4385
4652
  }
4386
4653
  return true;
4387
4654
  }
@@ -4389,14 +4656,14 @@ function loadLevel(fallback) {
4389
4656
  try {
4390
4657
  const v = localStorage.getItem(LEVEL_KEY);
4391
4658
  if (v === "compact" || v === "standard" || v === "detailed") return v;
4392
- } catch (e34) {
4659
+ } catch (e37) {
4393
4660
  }
4394
4661
  return fallback;
4395
4662
  }
4396
4663
  function saveLevel(level) {
4397
4664
  try {
4398
4665
  localStorage.setItem(LEVEL_KEY, level);
4399
- } catch (e35) {
4666
+ } catch (e38) {
4400
4667
  }
4401
4668
  }
4402
4669
  function createNoopApi() {
@@ -4442,7 +4709,7 @@ function createGrabInstance(options) {
4442
4709
  store.state.toolbar = { ...store.state.toolbar, comments: persisted };
4443
4710
  }
4444
4711
  }
4445
- const overlay = createOverlayRenderer();
4712
+ const overlay = createOverlayRenderer({ plainLabels: live });
4446
4713
  const crosshair = createCrosshair();
4447
4714
  const freezeOverlay = createFreezeOverlay();
4448
4715
  const pluginRegistry = createPluginRegistry();
@@ -4456,6 +4723,7 @@ function createGrabInstance(options) {
4456
4723
  let selectedElement = null;
4457
4724
  let pendingShot = null;
4458
4725
  let level = loadLevel(merged.detailLevel);
4726
+ let collapsed = loadCollapsed();
4459
4727
  const pendingShotDeletes = /* @__PURE__ */ new Map();
4460
4728
  themeManager.apply(store.state.toolbar.themeMode);
4461
4729
  updateToastOffset();
@@ -4507,9 +4775,9 @@ function createGrabInstance(options) {
4507
4775
  function toastDetail(c) {
4508
4776
  return {
4509
4777
  componentName: c.target.component,
4510
- filePath: _nullishCoalesce(_optionalChain([c, 'access', _206 => _206.target, 'access', _207 => _207.source, 'optionalAccess', _208 => _208.file]), () => ( null)),
4511
- line: _nullishCoalesce(_optionalChain([c, 'access', _209 => _209.target, 'access', _210 => _210.source, 'optionalAccess', _211 => _211.line]), () => ( null)),
4512
- column: _nullishCoalesce(_optionalChain([c, 'access', _212 => _212.target, 'access', _213 => _213.source, 'optionalAccess', _214 => _214.column]), () => ( null))
4778
+ filePath: _nullishCoalesce(_optionalChain([c, 'access', _218 => _218.target, 'access', _219 => _219.source, 'optionalAccess', _220 => _220.file]), () => ( null)),
4779
+ line: _nullishCoalesce(_optionalChain([c, 'access', _221 => _221.target, 'access', _222 => _222.source, 'optionalAccess', _223 => _223.line]), () => ( null)),
4780
+ column: _nullishCoalesce(_optionalChain([c, 'access', _224 => _224.target, 'access', _225 => _225.source, 'optionalAccess', _226 => _226.column]), () => ( null))
4513
4781
  };
4514
4782
  }
4515
4783
  function saveComment(element, text, shot) {
@@ -4533,7 +4801,7 @@ function createGrabInstance(options) {
4533
4801
  };
4534
4802
  setComments([comment, ...comments()].slice(0, MAX_COMMENTS));
4535
4803
  pluginRegistry.callHook("onComment", comment, element);
4536
- _optionalChain([outbox, 'optionalAccess', _215 => _215.send, 'call', _216 => _216(comment.id)]);
4804
+ _optionalChain([outbox, 'optionalAccess', _227 => _227.send, 'call', _228 => _228(comment.id)]);
4537
4805
  if (shot) void attachScreenshot(comment.id, shot);
4538
4806
  const count = comments().length;
4539
4807
  if (live) {
@@ -4568,15 +4836,18 @@ function createGrabInstance(options) {
4568
4836
  const updated = { ...current, screenshot: { localId: id, width: result.width, height: result.height } };
4569
4837
  setComments(comments().map((c) => c.id === id ? updated : c));
4570
4838
  pluginRegistry.callHook("onScreenshot", updated, result.blob);
4571
- _optionalChain([outbox, 'optionalAccess', _217 => _217.sendScreenshot, 'call', _218 => _218(id)]);
4839
+ _optionalChain([outbox, 'optionalAccess', _229 => _229.sendScreenshot, 'call', _230 => _230(id)]);
4572
4840
  }
4573
- function removeComments(ids, message) {
4841
+ function removeComments(ids, message, withdraw = false) {
4574
4842
  if (ids.length === 0) return;
4575
4843
  const idSet = new Set(ids);
4576
4844
  const before = comments();
4577
4845
  const removed = before.filter((c) => idSet.has(c.id));
4578
4846
  setComments(before.filter((c) => !idSet.has(c.id)));
4579
- const shotIds = removed.flatMap((c) => _optionalChain([c, 'access', _219 => _219.screenshot, 'optionalAccess', _220 => _220.localId]) ? [c.screenshot.localId] : []);
4847
+ const withdrawn = withdraw && outbox ? removed.filter((c) => c.sync !== void 0) : [];
4848
+ const hadQueued = new Set(withdrawn.filter((c) => outbox.isQueued(c.id)).map((c) => c.id));
4849
+ for (const c of withdrawn) outbox.remove(c.id, c.author.sessionId, message ? UNDO_MS + 500 : 0);
4850
+ const shotIds = removed.flatMap((c) => _optionalChain([c, 'access', _231 => _231.screenshot, 'optionalAccess', _232 => _232.localId]) ? [c.screenshot.localId] : []);
4580
4851
  const key = randomId();
4581
4852
  pendingShotDeletes.set(key, setTimeout(() => {
4582
4853
  pendingShotDeletes.delete(key);
@@ -4591,8 +4862,11 @@ function createGrabInstance(options) {
4591
4862
  clearTimeout(pendingShotDeletes.get(key));
4592
4863
  pendingShotDeletes.delete(key);
4593
4864
  const present = new Set(comments().map((c) => c.id));
4594
- const restored = [...removed.filter((c) => !present.has(c.id)), ...comments()].sort((a, b) => b.createdAt - a.createdAt);
4865
+ const resend = new Set(withdrawn.filter((c) => !present.has(c.id) && (!outbox.cancelRemove(c.id) || c.sync !== "sent" || hadQueued.has(c.id))).map((c) => c.id));
4866
+ const back = removed.filter((c) => !present.has(c.id)).map((c) => resend.has(c.id) ? { ...c, sync: "pending" } : c);
4867
+ const restored = [...back, ...comments()].sort((a, b) => b.createdAt - a.createdAt);
4595
4868
  setComments(restored);
4869
+ for (const id of resend) _optionalChain([outbox, 'optionalAccess', _233 => _233.send, 'call', _234 => _234(id)]);
4596
4870
  showToast(`Restored ${removed.length} comment${removed.length === 1 ? "" : "s"}`);
4597
4871
  }
4598
4872
  }]
@@ -4623,9 +4897,17 @@ function createGrabInstance(options) {
4623
4897
  function isAnyToolbarElement(el) {
4624
4898
  return isUiNode(el) || freezeOverlay.isFreezeElement(el);
4625
4899
  }
4900
+ function hideCommentPopover() {
4901
+ commentPopover.hide();
4902
+ if (picker.isHolding()) {
4903
+ selectedElement = null;
4904
+ pendingShot = null;
4905
+ picker.release();
4906
+ }
4907
+ }
4626
4908
  function closeAllPopovers() {
4627
4909
  commentsPanel.hide();
4628
- commentPopover.hide();
4910
+ hideCommentPopover();
4629
4911
  copySheet.close();
4630
4912
  finishSheet.close();
4631
4913
  }
@@ -4665,6 +4947,7 @@ function createGrabInstance(options) {
4665
4947
  pluginRegistry.callHook("onElementSelect", element);
4666
4948
  coachMark.dismiss();
4667
4949
  showSelectFeedback(element);
4950
+ picker.hold(element);
4668
4951
  commentPopover.show({ anchor: element, mode: "new", askIdentity: shouldAskIdentity() });
4669
4952
  }
4670
4953
  });
@@ -4675,6 +4958,7 @@ function createGrabInstance(options) {
4675
4958
  store.state.toolbar = { ...store.state.toolbar, visible: true };
4676
4959
  toolbar.show();
4677
4960
  }
4961
+ if (collapsed) expandToolbar();
4678
4962
  closeAllPopovers();
4679
4963
  store.state.active = true;
4680
4964
  picker.activate();
@@ -4709,7 +4993,7 @@ function createGrabInstance(options) {
4709
4993
  }
4710
4994
  },
4711
4995
  onHistory() {
4712
- commentPopover.hide();
4996
+ hideCommentPopover();
4713
4997
  copySheet.close();
4714
4998
  if (commentsPanel.isVisible()) {
4715
4999
  commentsPanel.hide();
@@ -4726,16 +5010,28 @@ function createGrabInstance(options) {
4726
5010
  }
4727
5011
  toolbar.update(store.state);
4728
5012
  },
4729
- onDismiss() {
4730
- const { pending, failed } = reviewCounts();
4731
- if (live && outbox && (pending || failed)) {
4732
- openFinishSheet();
4733
- return;
4734
- }
4735
- exitFeedbackMode();
4736
- },
5013
+ // Close collapses the toolbar into a round button in the bottom-right
5014
+ // corner instead of removing it, so nothing is lost and it's one click
5015
+ // back. Comments keep sending while it's collapsed.
5016
+ onDismiss: collapseToolbar,
5017
+ onExpand: expandToolbar,
4737
5018
  onFinish: openFinishSheet
4738
- }, live ? { label: "Comment", dismissLabel: "Exit feedback mode", hideEnable: true, review: !!merged.server } : {});
5019
+ }, live ? { label: "Comment", dismissLabel: "Hide toolbar", expandLabel: "Leave feedback", hideEnable: true, review: !!merged.server } : { dismissLabel: "Hide toolbar", expandLabel: "Open Grabby toolbar" });
5020
+ function collapseToolbar() {
5021
+ closeAllPopovers();
5022
+ coachMark.dismiss();
5023
+ doDeactivate(true);
5024
+ collapsed = true;
5025
+ toolbar.collapse();
5026
+ saveCollapsed(true);
5027
+ updateToastOffset();
5028
+ }
5029
+ function expandToolbar() {
5030
+ collapsed = false;
5031
+ toolbar.expand();
5032
+ saveCollapsed(false);
5033
+ updateToastOffset();
5034
+ }
4739
5035
  const commentsPanel = createCommentsPanel({
4740
5036
  onHover(comment) {
4741
5037
  const el = comment ? safeQuery(comment.target.selector) : null;
@@ -4758,7 +5054,7 @@ function createGrabInstance(options) {
4758
5054
  },
4759
5055
  onDelete(comment) {
4760
5056
  overlay.hide();
4761
- removeComments([comment.id], "Comment deleted");
5057
+ removeComments([comment.id], "Comment deleted", true);
4762
5058
  },
4763
5059
  onCopyAll() {
4764
5060
  overlay.hide();
@@ -4767,7 +5063,7 @@ function createGrabInstance(options) {
4767
5063
  onClearAll() {
4768
5064
  overlay.hide();
4769
5065
  const n = comments().length;
4770
- removeComments(comments().map((c) => c.id), `Cleared ${n} comment${n === 1 ? "" : "s"}`);
5066
+ removeComments(comments().map((c) => c.id), `Cleared ${n} comment${n === 1 ? "" : "s"}`, true);
4771
5067
  commentsPanel.hide();
4772
5068
  },
4773
5069
  onChangeIdentity() {
@@ -4797,7 +5093,7 @@ function createGrabInstance(options) {
4797
5093
  });
4798
5094
  const finishSheet = createFinishSheet({
4799
5095
  onDone() {
4800
- const done = comments().filter((c) => c.sync === "sent" && !_optionalChain([outbox, 'optionalAccess', _221 => _221.isQueued, 'call', _222 => _222(c.id)])).map((c) => c.id);
5096
+ const done = comments().filter((c) => c.sync === "sent" && !_optionalChain([outbox, 'optionalAccess', _235 => _235.isQueued, 'call', _236 => _236(c.id)])).map((c) => c.id);
4801
5097
  if (!comments().length) {
4802
5098
  exitFeedbackMode();
4803
5099
  return;
@@ -4811,9 +5107,9 @@ function createGrabInstance(options) {
4811
5107
  if (failed.length) {
4812
5108
  const ids = new Set(failed.map((c) => c.id));
4813
5109
  setComments(comments().map((c) => ids.has(c.id) ? { ...c, sync: "pending" } : c));
4814
- for (const id of ids) _optionalChain([outbox, 'optionalAccess', _223 => _223.send, 'call', _224 => _224(id)]);
5110
+ for (const id of ids) _optionalChain([outbox, 'optionalAccess', _237 => _237.send, 'call', _238 => _238(id)]);
4815
5111
  }
4816
- _optionalChain([outbox, 'optionalAccess', _225 => _225.flush, 'call', _226 => _226()]);
5112
+ _optionalChain([outbox, 'optionalAccess', _239 => _239.flush, 'call', _240 => _240()]);
4817
5113
  }
4818
5114
  });
4819
5115
  const commentPopover = createCommentPopover({
@@ -4833,7 +5129,7 @@ function createGrabInstance(options) {
4833
5129
  (c) => c.id === ctx.entryId ? { ...c, comment: value, updatedAt: Date.now(), ...outbox ? { sync: "pending" } : {} } : c
4834
5130
  );
4835
5131
  setComments(updated);
4836
- _optionalChain([outbox, 'optionalAccess', _227 => _227.send, 'call', _228 => _228(ctx.entryId)]);
5132
+ _optionalChain([outbox, 'optionalAccess', _241 => _241.send, 'call', _242 => _242(ctx.entryId)]);
4837
5133
  showToast("Comment updated");
4838
5134
  commentsPanel.show([...updated]);
4839
5135
  },
@@ -4858,7 +5154,7 @@ function createGrabInstance(options) {
4858
5154
  document.addEventListener("click", handleDocumentClick);
4859
5155
  function handlePageHide() {
4860
5156
  flushPendingWrite();
4861
- _optionalChain([outbox, 'optionalAccess', _229 => _229.flushOnExit, 'call', _230 => _230()]);
5157
+ _optionalChain([outbox, 'optionalAccess', _243 => _243.flushOnExit, 'call', _244 => _244()]);
4862
5158
  }
4863
5159
  function handleVisibilityChange() {
4864
5160
  if (document.visibilityState === "hidden") flushPendingWrite();
@@ -4872,7 +5168,7 @@ function createGrabInstance(options) {
4872
5168
  }
4873
5169
  window.addEventListener("beforeunload", handleBeforeUnload);
4874
5170
  function updateToastOffset() {
4875
- if (store.state.toolbar.visible) {
5171
+ if (store.state.toolbar.visible && !collapsed) {
4876
5172
  document.documentElement.style.setProperty("--grabby-toast-bottom", TOOLBAR_TOAST_OFFSET);
4877
5173
  } else {
4878
5174
  document.documentElement.style.removeProperty("--grabby-toast-bottom");
@@ -4969,7 +5265,7 @@ function createGrabInstance(options) {
4969
5265
  return exportText(list, _nullishCoalesce(opts.level, () => ( level)));
4970
5266
  },
4971
5267
  deleteComment(id) {
4972
- removeComments([id], null);
5268
+ removeComments([id], null, true);
4973
5269
  },
4974
5270
  clearComments() {
4975
5271
  removeComments(comments().map((c) => c.id), null);
@@ -5010,7 +5306,7 @@ function createGrabInstance(options) {
5010
5306
  copySheet.dispose();
5011
5307
  finishSheet.dispose();
5012
5308
  coachMark.dispose();
5013
- _optionalChain([outbox, 'optionalAccess', _231 => _231.dispose, 'call', _232 => _232()]);
5309
+ _optionalChain([outbox, 'optionalAccess', _245 => _245.dispose, 'call', _246 => _246()]);
5014
5310
  themeManager.dispose();
5015
5311
  disposeStyleBaseline();
5016
5312
  disposeScreenshotSandbox();
@@ -5022,9 +5318,10 @@ function createGrabInstance(options) {
5022
5318
  keyboard.start();
5023
5319
  }
5024
5320
  store.state.toolbar = { ...store.state.toolbar, visible: false };
5321
+ if (collapsed) toolbar.collapse();
5025
5322
  if (live && merged.showToolbar) {
5026
5323
  api.showToolbar();
5027
- coachMark.maybeShow();
5324
+ if (!collapsed) coachMark.maybeShow();
5028
5325
  }
5029
5326
  store.subscribe((state, key) => {
5030
5327
  if (key === "options") {