@commentkit/comment-kit 0.7.0 → 0.7.2

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +10 -6
  3. package/SECURITY.md +14 -6
  4. package/dist/angular.es.js +2 -2
  5. package/dist/comment-kit.es.js +5 -5
  6. package/dist/demo.es.js +36 -34
  7. package/dist/headless.es.js +3 -3
  8. package/dist/preact.es.js +2 -2
  9. package/dist/qwik.qwik.mjs +2 -2
  10. package/dist/react.es.js +2 -2
  11. package/dist/shared/{ShadowRootContext-Bv-4aElu.js → ShadowRootContext-CjciYxVN.js} +4 -4
  12. package/dist/shared/annotation-toolbar-CZI1KVdW.js +1094 -0
  13. package/dist/shared/attachment-refresh-mQw-L7hB.js +94 -0
  14. package/dist/shared/{button-group-Cl9CrvvU.js → button-group-C285iSkZ.js} +14 -16
  15. package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
  16. package/dist/shared/capture-privacy-DUROnio5.js +77 -0
  17. package/dist/shared/{comment-drawing-canvas-Dzb5YoFw.js → comment-drawing-canvas-CYFFKgCm.js} +2 -2
  18. package/dist/shared/{comment-utils-BycYTSxA.js → comment-icon-4SQd3nlz.js} +30 -24
  19. package/dist/shared/comment-image-lightbox-DmTNxuqX.js +190 -0
  20. package/dist/shared/comment-images-content-BX4DQ9Ol.js +214 -0
  21. package/dist/shared/{comment-kit-core-BaSuMzp9.js → comment-kit-core-VuIidMeu.js} +1096 -793
  22. package/dist/shared/{comment-kit-ui-CzfdAZs2.js → comment-kit-ui-BjJ1ZLiv.js} +6091 -6486
  23. package/dist/shared/{comment-screenshot-annotator-C7X-_bm6.js → comment-screenshot-annotator-CMOG1md7.js} +5 -5
  24. package/dist/shared/{comment-screenshot-overlay-wIrZrcRy.js → comment-screenshot-overlay-iWW-V-Iw.js} +114 -118
  25. package/dist/shared/comment-shortcut-groups-CfEmkitU.js +153 -0
  26. package/dist/shared/{dev-export-panel-FwFVdady.js → dev-export-panel-CrRENbMn.js} +9 -10
  27. package/dist/shared/dev-grab-Ca4MlS2Y.js +196 -0
  28. package/dist/shared/{element-selector-BhJm-NSs.js → element-selector-g1bTvdEA.js} +450 -408
  29. package/dist/shared/{mount-ui--ijs8pWT.js → mount-ui-Dz5QLq4W.js} +121 -106
  30. package/dist/shared/{pusher-ipHMJnO_.js → pusher-ue0D83de.js} +1 -1
  31. package/dist/shared/realtime-CieWAnsW.js +321 -0
  32. package/dist/shared/realtime-recovery-BSVMwsXJ.js +135 -0
  33. package/dist/shared/request-activity-DQrAUwfA.js +11 -0
  34. package/dist/shared/{separator-XDBsaWyw.js → separator-aphZiRoJ.js} +1 -1
  35. package/dist/shared/{shadow-root-C5v-T8lQ.js → shadow-root-Cv1aLuFf.js} +31 -31
  36. package/dist/shared/{styles-D3yMtaec.js → styles-CnYsLS2f.js} +1 -1
  37. package/dist/shared/text-B4HHZNaa.js +23 -0
  38. package/dist/shared/token-session-CPQpt3-u.js +25 -0
  39. package/dist/shared/useRender-D1z_X_BY.js +5 -0
  40. package/dist/shared/{validation-C7QG8j7Z.js → validation-3wbbbuX0.js} +26 -1
  41. package/dist/shared/websocket-manager-BnK55c3U.js +381 -0
  42. package/dist/solid.es.js +2 -2
  43. package/dist/svelte.es.js +2 -2
  44. package/dist/types/core/api-client.d.ts +11 -2
  45. package/dist/types/core/comment-kit-core.d.ts +11 -5
  46. package/dist/types/core/types.d.ts +54 -2
  47. package/dist/types/core/websocket-manager.d.ts +13 -0
  48. package/dist/types/core/write-access.d.ts +9 -0
  49. package/dist/vue.es.js +2 -2
  50. package/docs/api-reference.md +25 -4
  51. package/package.json +3 -2
  52. package/dist/shared/annotation-toolbar-B9SxYqoF.js +0 -1093
  53. package/dist/shared/comment-image-lightbox-BPYJT1sB.js +0 -183
  54. package/dist/shared/dev-grab-DDqg0LQf.js +0 -203
  55. package/dist/shared/realtime-Dk41VwKg.js +0 -302
  56. package/dist/shared/websocket-manager-DhLWh3Jr.js +0 -302
@@ -1,30 +1,31 @@
1
- import { a as e, i as t, m as n, n as r, o as i } from "./dom-Bhf4WFtY.js";
2
- import { n as a } from "./dist-De294MVF.js";
3
- import { t as o } from "./button-By0hGrJK.js";
4
- import { t as s } from "./createReactComponent-BZHeRbD0.js";
5
- import { R as c, n as ee, y as te } from "./comment-kit-ui-CzfdAZs2.js";
6
- import * as l from "react";
7
- import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
8
- var ne = s("outline", "paperclip", "Paperclip", [["path", {
1
+ import { u as e } from "./comment-kit-core-VuIidMeu.js";
2
+ import { a as t, i as n, m as r, n as i, o as a } from "./dom-Bhf4WFtY.js";
3
+ import { n as o } from "./dist-De294MVF.js";
4
+ import { t as s } from "./button-By0hGrJK.js";
5
+ import { t as c } from "./createReactComponent-BZHeRbD0.js";
6
+ import { G as l, K as ee, S as te, V as u, n as ne } from "./comment-kit-ui-BjJ1ZLiv.js";
7
+ import * as d from "react";
8
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
9
+ var re = c("outline", "paperclip", "Paperclip", [["path", {
9
10
  d: "M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5",
10
11
  key: "svg-0"
11
- }]]), re = s("outline", "x", "X", [["path", {
12
+ }]]), ie = c("outline", "x", "X", [["path", {
12
13
  d: "M18 6l-12 12",
13
14
  key: "svg-0"
14
15
  }], ["path", {
15
16
  d: "M6 6l12 12",
16
17
  key: "svg-1"
17
- }]]), p = ".ck-element-selector{z-index:calc(var(--z-ck-fab) - 1);pointer-events:none;position:fixed;inset:0}.ck-element-selector-outline,.ck-element-selector-mark{pointer-events:none;border-radius:4px;position:fixed}.ck-element-selector-outline{z-index:calc(var(--z-ck-fab) - 1);border:2px solid var(--primary);background-color:color-mix(in oklch, var(--primary) 8%, transparent);box-shadow:0 0 0 1px color-mix(in oklch, var(--background) 95%, transparent), 0 0 0 4px color-mix(in oklch, var(--primary) 18%, transparent)}.ck-element-selector-outline[data-state=selected]{background-color:color-mix(in oklch, var(--primary) 12%, transparent);border-style:solid}.ck-element-selector-outline[data-state=multi]{border-style:dashed;border-color:color-mix(in oklch, var(--primary) 70%, var(--foreground));background-color:color-mix(in oklch, var(--primary) 6%, transparent)}.ck-element-selector-outline[data-state=multi]:before{content:attr(data-multi-index);top:-10px;background:var(--primary);min-width:20px;height:20px;color:var(--primary-foreground,white);text-align:center;border-radius:999px;padding:0 6px;font:600 11px/20px ui-monospace,SF Mono,Menlo,monospace;position:absolute;inset-inline-start:-10px;box-shadow:0 1px 3px #00000040}.ck-element-selector-multibar{bottom:24px;z-index:calc(var(--z-ck-fab) + 1);border:1px solid var(--border);background-color:var(--popover);color:var(--popover-foreground);box-shadow:0 18px 30px -12px #00000047, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:999px;align-items:center;gap:8px;padding:6px 10px;font:13px/1 system-ui,sans-serif;display:inline-flex;position:fixed;inset-inline-start:50%;transform:translate(-50%)}.ck-element-selector-multibar-count{color:var(--popover-foreground);padding:0 4px}.ck-element-selector-marquee{z-index:calc(var(--z-ck-fab) - 1);border:1px dashed var(--primary);background-color:color-mix(in oklch, var(--primary) 12%, transparent);pointer-events:none;border-radius:4px;position:fixed}.ck-element-selector-context-menu{z-index:calc(var(--z-ck-fab) + 2);border:1px solid var(--border);background-color:var(--popover);min-width:200px;color:var(--popover-foreground);box-shadow:0 18px 30px -12px #0000004d, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:8px;margin:0;padding:4px;font:13px/1 system-ui,sans-serif;list-style:none;position:fixed}.ck-element-selector-context-menu li{list-style:none}.ck-element-selector-context-menu button{width:100%;color:inherit;text-align:left;cursor:pointer;font:inherit;background:0 0;border:0;border-radius:4px;padding:8px 10px}.ck-element-selector-context-menu button:hover,.ck-element-selector-context-menu button:focus-visible{background-color:color-mix(in oklch, var(--primary) 14%, transparent);outline:none}.ck-element-selector-mark{z-index:calc(var(--z-ck-fab) - 2);border:2px solid color-mix(in oklch, var(--primary) 78%, var(--foreground));box-shadow:inset 0 0 0 1px color-mix(in oklch, var(--background) 80%, transparent), 0 0 0 3px color-mix(in oklch, var(--primary) 14%, transparent)}.ck-element-selector-composer{z-index:var(--z-ck-fab);border:1px solid var(--border);background-color:var(--popover);width:min(28rem,100vw - 1rem);color:var(--popover-foreground);box-shadow:0 22px 42px -16px #00000052, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:8px;align-items:stretch;gap:.625rem;padding:.75rem;display:grid;position:fixed}.ck-element-selector-input-row{min-width:0}.ck-element-selector-composer .ck-input{border-radius:7px;width:100%;min-width:0;min-height:3rem;padding-inline:.875rem;font-size:.875rem;line-height:1.25rem}.ck-element-selector-actions{align-items:center;gap:.5rem;width:100%;display:flex}.ck-element-selector-actions .ck-button{min-height:2.375rem}.ck-element-selector-attach-action{gap:.375rem;margin-inline-end:auto}.ck-element-selector-grab-action{min-width:8.75rem}.ck-element-selector-action-icon{flex:none;width:.95rem;height:.95rem}.ck-element-selector-file-input{clip:rect(0 0 0 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.ck-element-selector-attachment{border:1px solid color-mix(in oklch, var(--border) 80%, transparent);background-color:color-mix(in oklch, var(--muted) 55%, transparent);border-radius:7px;align-items:center;gap:.625rem;width:100%;min-width:0;padding:.5rem;display:flex}.ck-element-selector-attachment-image{object-fit:cover;border-radius:6px;flex:none;width:2.5rem;height:2.5rem}.ck-element-selector-attachment-meta{flex:1;gap:.125rem;min-width:0;display:grid}.ck-element-selector-attachment-name,.ck-element-selector-attachment-path,.ck-element-selector-attachment-size{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ck-element-selector-attachment-name{color:var(--foreground);font-size:.75rem;font-weight:600;line-height:1rem}.ck-element-selector-attachment-path,.ck-element-selector-attachment-size{color:var(--muted-foreground);font-size:.6875rem;line-height:.875rem}.ck-element-selector-error{width:100%;color:var(--destructive);font-size:.75rem;line-height:1rem}@media (width<=420px){.ck-element-selector-actions{flex-wrap:wrap}.ck-element-selector-attach-action{margin-inline-end:0}.ck-element-selector-save-action,.ck-element-selector-grab-action{flex:auto}}", m = "data-commentkit-freeze", h = "\n*, *::before, *::after {\n animation-play-state: paused !important;\n transition: none !important;\n}\n", g = 0, _ = null, v = [];
18
- function y() {
19
- if (_ || typeof document > "u") return;
20
- let e = document.createElement("style");
21
- e.setAttribute(m, ""), e.textContent = h, document.head.appendChild(e), _ = e;
22
- }
18
+ }]]), h = ".ck-element-selector{z-index:calc(var(--z-ck-fab) - 1);pointer-events:none;position:fixed;inset:0}.ck-element-selector-outline,.ck-element-selector-mark{pointer-events:none;border-radius:4px;position:fixed}.ck-element-selector-outline{z-index:calc(var(--z-ck-fab) - 1);border:2px solid var(--primary);background-color:color-mix(in oklch, var(--primary) 8%, transparent);box-shadow:0 0 0 1px color-mix(in oklch, var(--background) 95%, transparent), 0 0 0 4px color-mix(in oklch, var(--primary) 18%, transparent)}.ck-element-selector-outline[data-state=selected]{background-color:color-mix(in oklch, var(--primary) 12%, transparent);border-style:solid}.ck-element-selector-outline[data-state=multi]{border-style:dashed;border-color:color-mix(in oklch, var(--primary) 70%, var(--foreground));background-color:color-mix(in oklch, var(--primary) 6%, transparent)}.ck-element-selector-outline[data-state=multi]:before{content:attr(data-multi-index);top:-10px;background:var(--primary);min-width:20px;height:20px;color:var(--primary-foreground,white);text-align:center;border-radius:999px;padding:0 6px;font:600 11px/20px ui-monospace,SF Mono,Menlo,monospace;position:absolute;inset-inline-start:-10px;box-shadow:0 1px 3px #00000040}.ck-element-selector-multibar{bottom:24px;z-index:calc(var(--z-ck-fab) + 1);border:1px solid var(--border);background-color:var(--popover);color:var(--popover-foreground);box-shadow:0 18px 30px -12px #00000047, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:999px;align-items:center;gap:8px;padding:6px 10px;font:13px/1 system-ui,sans-serif;display:inline-flex;position:fixed;inset-inline-start:50%;transform:translate(-50%)}.ck-element-selector-multibar-count{color:var(--popover-foreground);padding:0 4px}.ck-element-selector-marquee{z-index:calc(var(--z-ck-fab) - 1);border:1px dashed var(--primary);background-color:color-mix(in oklch, var(--primary) 12%, transparent);pointer-events:none;border-radius:4px;position:fixed}.ck-element-selector-context-menu{z-index:calc(var(--z-ck-fab) + 2);border:1px solid var(--border);background-color:var(--popover);min-width:200px;color:var(--popover-foreground);box-shadow:0 18px 30px -12px #0000004d, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:8px;margin:0;padding:4px;font:13px/1 system-ui,sans-serif;list-style:none;position:fixed}.ck-element-selector-context-menu li{list-style:none}.ck-element-selector-context-menu button{width:100%;color:inherit;text-align:left;cursor:pointer;font:inherit;background:0 0;border:0;border-radius:4px;padding:8px 10px}.ck-element-selector-context-menu button:hover,.ck-element-selector-context-menu button:focus-visible{background-color:color-mix(in oklch, var(--primary) 14%, transparent);outline:none}.ck-element-selector-mark{z-index:calc(var(--z-ck-fab) - 2);border:2px solid color-mix(in oklch, var(--primary) 78%, var(--foreground));box-shadow:inset 0 0 0 1px color-mix(in oklch, var(--background) 80%, transparent), 0 0 0 3px color-mix(in oklch, var(--primary) 14%, transparent)}.ck-element-selector-composer{z-index:var(--z-ck-fab);border:1px solid var(--border);background-color:var(--popover);width:min(28rem,100vw - 1rem);color:var(--popover-foreground);box-shadow:0 22px 42px -16px #00000052, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:8px;align-items:stretch;gap:.625rem;padding:.75rem;display:grid;position:fixed}.ck-element-selector-input-row{min-width:0}.ck-element-selector-composer .ck-input{border-radius:7px;width:100%;min-width:0;min-height:3rem;padding-inline:.875rem;font-size:.875rem;line-height:1.25rem}.ck-element-selector-actions{align-items:center;gap:.5rem;width:100%;display:flex}.ck-element-selector-actions .ck-button{min-height:2.375rem}.ck-element-selector-attach-action{gap:.375rem;margin-inline-end:auto}.ck-element-selector-grab-action{min-width:8.75rem}.ck-element-selector-action-icon{flex:none;width:.95rem;height:.95rem}.ck-element-selector-file-input{clip:rect(0 0 0 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.ck-element-selector-attachment{border:1px solid color-mix(in oklch, var(--border) 80%, transparent);background-color:color-mix(in oklch, var(--muted) 55%, transparent);border-radius:7px;align-items:center;gap:.625rem;width:100%;min-width:0;padding:.5rem;display:flex}.ck-element-selector-attachment-image{object-fit:cover;border-radius:6px;flex:none;width:2.5rem;height:2.5rem}.ck-element-selector-attachment-meta{flex:1;gap:.125rem;min-width:0;display:grid}.ck-element-selector-attachment-name,.ck-element-selector-attachment-path,.ck-element-selector-attachment-size{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ck-element-selector-attachment-name{color:var(--foreground);font-size:.75rem;font-weight:600;line-height:1rem}.ck-element-selector-attachment-path,.ck-element-selector-attachment-size{color:var(--muted-foreground);font-size:.6875rem;line-height:.875rem}.ck-element-selector-error{width:100%;color:var(--destructive);font-size:.75rem;line-height:1rem}@media (width<=420px){.ck-element-selector-actions{flex-wrap:wrap}.ck-element-selector-attach-action{margin-inline-end:0}.ck-element-selector-save-action,.ck-element-selector-grab-action{flex:auto}}", ae = "data-commentkit-freeze", g = "\n*, *::before, *::after {\n animation-play-state: paused !important;\n transition: none !important;\n}\n", _ = 0, v = null, y = [];
23
19
  function b() {
24
- _ &&= (_.remove(), null);
20
+ if (v || typeof document > "u") return;
21
+ let e = document.createElement("style");
22
+ e.setAttribute(ae, ""), e.textContent = g, document.head.appendChild(e), v = e;
25
23
  }
26
24
  function x() {
27
- typeof document < "u" && typeof document.getAnimations == "function" && (v = document.getAnimations().filter((e) => {
25
+ v &&= (v.remove(), null);
26
+ }
27
+ function S() {
28
+ typeof document < "u" && typeof document.getAnimations == "function" && (y = document.getAnimations().filter((e) => {
28
29
  if (e.playState !== "running") return !1;
29
30
  try {
30
31
  return e.pause(), !0;
@@ -33,63 +34,63 @@ function x() {
33
34
  }
34
35
  }));
35
36
  }
36
- function S() {
37
- for (let e of v) try {
37
+ function C() {
38
+ for (let e of y) try {
38
39
  e.play();
39
40
  } catch {}
40
- v = [];
41
+ y = [];
41
42
  }
42
- function ie() {
43
- g++, g === 1 && (y(), x());
43
+ function oe() {
44
+ _++, _ === 1 && (b(), S());
44
45
  let e = !1;
45
46
  return () => {
46
- e || (e = !0, g = Math.max(0, g - 1), g === 0 && (b(), S()));
47
+ e || (e = !0, _ = Math.max(0, _ - 1), _ === 0 && (x(), C()));
47
48
  };
48
49
  }
49
- var C = 448, ae = 236, w = 8, T = .9, E = 1e3, D = 2147483600;
50
- function O(e) {
50
+ var w = 448, se = 236, T = 8, E = .9, D = 1e3, O = 2147483600;
51
+ function k(e) {
51
52
  return typeof Element < "u" && e instanceof Element;
52
53
  }
53
- function k() {
54
+ function A() {
54
55
  let e = document.activeElement;
55
56
  for (; e?.shadowRoot?.activeElement;) e = e.shadowRoot.activeElement;
56
57
  return e;
57
58
  }
58
- function oe(e) {
59
+ function ce(e) {
59
60
  let t = typeof e.composedPath == "function" ? e.composedPath()[0] ?? e.target : e.target;
60
- if (!O(t)) return !1;
61
+ if (!k(t)) return !1;
61
62
  let n = t.tagName.toLowerCase();
62
63
  return n === "input" || n === "textarea" || n === "select" || t instanceof HTMLElement && t.isContentEditable;
63
64
  }
64
- function A(e) {
65
+ function j(e) {
65
66
  let t = e.getRootNode();
66
67
  return !!(e.closest("[data-commentkit], [data-commentkit-host], [data-commentkit-ui], .ck-root") || typeof ShadowRoot < "u" && t instanceof ShadowRoot && t.host.matches("[data-commentkit], [data-commentkit-host], [data-commentkit-ui]"));
67
68
  }
68
- function j(e, t = B(e)) {
69
+ function M(e, t = V(e)) {
69
70
  let n = e.tagName.toLowerCase();
70
- if (n === "html" || n === "body" || A(e) || e.closest("[data-commentkit-ignore], [data-react-grab-ignore]") || !le(t)) return !1;
71
+ if (n === "html" || n === "body" || j(e) || e.closest("[data-commentkit-ignore], [data-react-grab-ignore]") || !H(t)) return !1;
71
72
  let r = window.getComputedStyle(e);
72
73
  if (r.display === "none" || r.visibility === "hidden") return !1;
73
74
  let i = Number.parseFloat(r.opacity || "1");
74
75
  if (Number.isFinite(i) && i <= .01) return !1;
75
- let a = Number.parseInt(r.zIndex || "", 10), o = r.position === "fixed" || r.position === "absolute", s = t.width / Math.max(window.innerWidth, 1) >= T && t.height / Math.max(window.innerHeight, 1) >= T;
76
- return !(r.pointerEvents === "none" && r.position === "fixed" && Number.isFinite(a) && a >= D || s && o && (r.backgroundColor === "transparent" || r.backgroundColor === "rgba(0, 0, 0, 0)" || Number.isFinite(i) && i < .1 || Number.isFinite(a) && a > E));
76
+ let a = Number.parseInt(r.zIndex || "", 10), o = r.position === "fixed" || r.position === "absolute", s = t.width / Math.max(window.innerWidth, 1) >= E && t.height / Math.max(window.innerHeight, 1) >= E;
77
+ return !(r.pointerEvents === "none" && r.position === "fixed" && Number.isFinite(a) && a >= O || s && o && (r.backgroundColor === "transparent" || r.backgroundColor === "rgba(0, 0, 0, 0)" || Number.isFinite(i) && i < .1 || Number.isFinite(a) && a > D));
77
78
  }
78
- function M(e) {
79
+ function N(e) {
79
80
  return typeof e.composedPath == "function" ? e.composedPath() : e.target ? [e.target] : [];
80
81
  }
81
- function N(e) {
82
- return M(e).some((e) => O(e) && A(e));
82
+ function P(e) {
83
+ return N(e).some((e) => k(e) && j(e));
83
84
  }
84
- function P(e, t) {
85
+ function F(e, t) {
85
86
  if (typeof document.elementsFromPoint == "function") return document.elementsFromPoint(e, t);
86
87
  let n = document.elementFromPoint?.(e, t);
87
88
  return n ? [n] : [];
88
89
  }
89
- function F(e, t) {
90
- return P(e, t).find((e) => j(e)) ?? null;
90
+ function I(e, t) {
91
+ return F(e, t).find((e) => M(e)) ?? null;
91
92
  }
92
- function se(e) {
93
+ function le(e) {
93
94
  let t = Math.min(e.startX, e.x), n = Math.min(e.startY, e.y), r = Math.abs(e.x - e.startX), i = Math.abs(e.y - e.startY);
94
95
  return {
95
96
  left: t,
@@ -100,27 +101,27 @@ function se(e) {
100
101
  bottom: n + i
101
102
  };
102
103
  }
103
- function I(e, t) {
104
+ function L(e, t) {
104
105
  return !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom);
105
106
  }
106
- var L = 200, R = 5e3;
107
- function z(e) {
107
+ var R = 200, z = 5e3;
108
+ function B(e) {
108
109
  let t = window.getComputedStyle(e), n = (e) => e === "hidden" || e === "clip";
109
110
  return n(t.overflowX) || n(t.overflowY) || n(t.overflow);
110
111
  }
111
- function ce(e) {
112
+ function ue(e) {
112
113
  let t = [];
113
114
  if (typeof document > "u") return t;
114
115
  let n = 0, r = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, { acceptNode(r) {
115
- if (n >= R || t.length >= L) return NodeFilter.FILTER_REJECT;
116
+ if (n >= z || t.length >= R) return NodeFilter.FILTER_REJECT;
116
117
  n += 1;
117
- let i = r, a = B(i), o = le(a) && I(a, e);
118
- return !o && z(i) ? NodeFilter.FILTER_REJECT : o && j(i, a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
118
+ let i = r, a = V(i), o = H(a) && L(a, e);
119
+ return !o && B(i) ? NodeFilter.FILTER_REJECT : o && M(i, a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
119
120
  } }), i = r.nextNode();
120
- for (; i && (t.push(i), !(t.length >= L || n >= R));) i = r.nextNode();
121
+ for (; i && (t.push(i), !(t.length >= R || n >= z));) i = r.nextNode();
121
122
  return t;
122
123
  }
123
- function B(e) {
124
+ function V(e) {
124
125
  let t = e.getBoundingClientRect();
125
126
  return {
126
127
  top: t.top,
@@ -131,38 +132,38 @@ function B(e) {
131
132
  right: t.right
132
133
  };
133
134
  }
134
- function le(e) {
135
+ function H(e) {
135
136
  return e.width > 0 && e.height > 0;
136
137
  }
137
- function V(n) {
138
+ function U(e) {
138
139
  return {
139
- element: n,
140
- selector: t(n),
141
- xpath: e(n),
142
- rect: B(n)
140
+ element: e,
141
+ selector: n(e),
142
+ xpath: t(e),
143
+ rect: V(e)
143
144
  };
144
145
  }
145
- function H(e, t, n) {
146
+ function W(e, t, n) {
146
147
  return Math.min(n, Math.max(t, e));
147
148
  }
148
- function U() {
149
+ function G() {
149
150
  return {
150
151
  width: Math.max(window.innerWidth || 0, 16),
151
152
  height: Math.max(window.innerHeight || 0, 16)
152
153
  };
153
154
  }
154
- function ue(e) {
155
- let t = U(), r = H(e.rect.left + e.rect.width / 2, 0, t.width), i = H(e.rect.top + e.rect.height / 2, 0, t.height);
155
+ function de(e) {
156
+ let t = G(), n = W(e.rect.left + e.rect.width / 2, 0, t.width), i = W(e.rect.top + e.rect.height / 2, 0, t.height);
156
157
  return {
157
- ...n(r, i, t),
158
+ ...r(n, i, t),
158
159
  element: e.selector,
159
160
  xpath: e.xpath
160
161
  };
161
162
  }
162
- function de(e) {
163
+ function fe(e) {
163
164
  return typeof e != "number" || !Number.isFinite(e) ? "" : e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
164
165
  }
165
- function W(e, t) {
166
+ function pe(e, t) {
166
167
  let n = e.path;
167
168
  if (typeof n == "string" && n.trim()) return {
168
169
  path: n.trim(),
@@ -181,9 +182,10 @@ function W(e, t) {
181
182
  pathSource: "browser-fallback"
182
183
  };
183
184
  }
184
- function fe(e, t) {
185
- let { path: n, pathSource: r } = W(e, t);
185
+ function me(e, t) {
186
+ let { path: n, pathSource: r } = pe(e, t);
186
187
  return {
188
+ file: e,
187
189
  name: e.name,
188
190
  path: n,
189
191
  pathSource: r,
@@ -193,23 +195,23 @@ function fe(e, t) {
193
195
  previewUrl: e.type.startsWith("image/") && typeof URL.createObjectURL == "function" ? URL.createObjectURL(e) : null
194
196
  };
195
197
  }
196
- function G(e) {
198
+ function K(e) {
197
199
  e && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
198
200
  }
199
- async function pe(e, t) {
201
+ async function he(e, t) {
200
202
  try {
201
203
  if (!navigator.clipboard?.writeText) throw Error("clipboard unavailable");
202
204
  await navigator.clipboard.writeText(e);
203
205
  try {
204
- a.success(`${t} copied`);
206
+ o.success(`${t} copied`);
205
207
  } catch {}
206
208
  } catch {
207
209
  try {
208
- a.error(`Could not copy ${t.toLowerCase()}`);
210
+ o.error(`Could not copy ${t.toLowerCase()}`);
209
211
  } catch {}
210
212
  }
211
213
  }
212
- function K(e) {
214
+ function q(e) {
213
215
  return {
214
216
  top: e.top,
215
217
  left: e.left,
@@ -217,39 +219,39 @@ function K(e) {
217
219
  height: e.height
218
220
  };
219
221
  }
220
- function me(e, t = ae) {
221
- let n = U(), r = Math.max(w, n.width - C - w), i = H(e.left, w, r), a = e.bottom + w, o = e.top - t - w;
222
+ function ge(e, t = se) {
223
+ let n = G(), r = Math.max(T, n.width - w - T), i = W(e.left, T, r), a = e.bottom + T, o = e.top - t - T;
222
224
  return {
223
225
  left: i,
224
- top: a + t <= n.height - w ? a : H(o, w, n.height - t - w)
226
+ top: a + t <= n.height - T ? a : W(o, T, n.height - t - T)
225
227
  };
226
228
  }
227
- var he = 220, ge = 200;
228
- function _e(e) {
229
- let t = U();
229
+ var _e = 220, J = 200;
230
+ function ve(e) {
231
+ let t = G();
230
232
  return {
231
- left: H(e.x, w, Math.max(w, t.width - he - w)),
232
- top: H(e.y, w, Math.max(w, t.height - ge - w))
233
+ left: W(e.x, T, Math.max(T, t.width - _e - T)),
234
+ top: W(e.y, T, Math.max(T, t.height - J - T))
233
235
  };
234
236
  }
235
- function ve(e) {
237
+ function ye(e) {
236
238
  return e.status === "open" && !!(e.position.element || e.position.xpath);
237
239
  }
238
- function ye(e) {
240
+ function be(e) {
239
241
  return e.flatMap((e) => {
240
- if (!ve(e)) return [];
241
- let t = r(e.position.element ?? "", e.position.xpath);
242
+ if (!ye(e)) return [];
243
+ let t = i(e.position.element ?? "", e.position.xpath);
242
244
  if (!t) return [];
243
- let n = B(t);
244
- return j(t, n) ? [{
245
+ let n = V(t);
246
+ return M(t, n) ? [{
245
247
  id: e.id,
246
248
  rect: n
247
249
  }] : [];
248
250
  });
249
251
  }
250
- function be(e) {
251
- let [t, n] = l.useState(0);
252
- return l.useEffect(() => {
252
+ function xe(e) {
253
+ let [t, n] = d.useState(0);
254
+ return d.useEffect(() => {
253
255
  if (!e) return;
254
256
  let t = 0, r = () => {
255
257
  t ||= window.requestAnimationFrame(() => {
@@ -273,59 +275,67 @@ function be(e) {
273
275
  };
274
276
  }, [e]), t;
275
277
  }
276
- var xe = l.memo(function({ core: n, state: r, active: a }) {
277
- let s = c(), [p, m] = l.useState(null), [h, g] = l.useState(null), [_, v] = l.useState([]), [y, b] = l.useState(null), [x, S] = l.useState(null), [C, w] = l.useState(""), [T, E] = l.useState(null), [D, O] = l.useState(!1), [A, j] = l.useState(!1), [M, P] = l.useState(null), I = l.useRef(null), L = l.useRef(null), R = l.useRef(null), z = l.useRef(null), [le, H] = l.useState(ae), U = i().path, W = l.useMemo(() => r.comments.filter((e) => e.page?.path === U), [r.comments, U]), he = W.some(ve), ge = be(a || he || !!h || _.length > 0), xe = l.useRef(null), q = l.useRef([]), Se = l.useRef(""), Ce = l.useRef(null);
278
- l.useEffect(() => {
279
- xe.current = h?.element ?? p?.element ?? null;
280
- }, [p, h]), l.useEffect(() => {
281
- q.current = _;
282
- }, [_]), l.useEffect(() => {
283
- Se.current = C;
284
- }, [C]), l.useEffect(() => {
285
- Ce.current = T;
286
- }, [T]);
287
- let we = l.useMemo(() => ye(W), [W, ge]);
288
- l.useEffect(() => {
289
- a || (m(null), g(null), v([]), S(null), w(""), E((e) => (G(e?.previewUrl), null)), O(!1), P(null), b(null), Z.current = null, Q.current = !1);
290
- }, [a]), l.useEffect(() => () => {
291
- G(Ce.current?.previewUrl);
292
- }, []), l.useEffect(() => {
293
- if (!a) return;
278
+ var Y = d.memo(function({ core: r, state: i, active: o }) {
279
+ let c = u(), { canWrite: h, message: ae } = ee(), [g, _] = d.useState(null), [v, y] = d.useState(null), [b, x] = d.useState([]), [S, C] = d.useState(null), [w, T] = d.useState(null), [E, D] = d.useState(""), [O, k] = d.useState(null), [j, M] = d.useState(!1), N = d.useRef(null), [F, L] = d.useState(!1), [R, z] = d.useState(null), B = d.useRef(null), H = d.useRef(null), W = d.useRef(null), G = d.useRef(null), [pe, _e] = d.useState(se), J = a().path, Y = d.useMemo(() => i.comments.filter((e) => e.page?.path === J), [i.comments, J]), Se = Y.some(ye), Ce = xe(o || Se || !!v || b.length > 0), we = d.useRef(null), Te = d.useRef([]), Ee = d.useRef(""), De = d.useRef(null);
280
+ d.useEffect(() => {
281
+ we.current = v?.element ?? g?.element ?? null;
282
+ }, [g, v]), d.useEffect(() => {
283
+ Te.current = b;
284
+ }, [b]), d.useEffect(() => {
285
+ Ee.current = E;
286
+ }, [E]), d.useEffect(() => {
287
+ De.current = O;
288
+ }, [O]);
289
+ let Oe = d.useMemo(() => be(Y), [Y, Ce]);
290
+ d.useEffect(() => {
291
+ let e = N.current;
292
+ (e && (i.currentUser?.id !== e.userId || (i.activeBranch ?? null) !== e.branch || J !== e.page || !e.submitting && i.activeTool === null || i.activeTool !== null && i.activeTool !== "select") || !o && !j) && (N.current = null, _(null), y(null), x([]), T(null), D(""), k((e) => (K(e?.previewUrl), null)), M(!1), z(null), C(null), Q.current = null, $.current = !1);
293
+ }, [
294
+ o,
295
+ j,
296
+ i.activeTool,
297
+ i.activeBranch,
298
+ i.currentUser?.id,
299
+ J
300
+ ]), d.useEffect(() => () => {
301
+ N.current = null, K(De.current?.previewUrl);
302
+ }, []), d.useEffect(() => {
303
+ if (!o) return;
294
304
  let e = document.body.style.cursor;
295
305
  document.body.style.cursor = "crosshair";
296
- let t = ie();
306
+ let t = oe();
297
307
  return () => {
298
308
  document.body.style.cursor = e, t();
299
309
  };
300
- }, [a]);
301
- let J = a && !!h;
302
- l.useEffect(() => {
303
- if (!J) return;
304
- let e = k();
305
- return e instanceof HTMLElement && !I.current?.contains(e) && (z.current = e), I.current?.querySelector("[data-ck-composer-input]")?.focus({ preventScroll: !0 }), () => {
306
- let e = z.current;
307
- z.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
310
+ }, [o]);
311
+ let X = o && !!v;
312
+ d.useEffect(() => {
313
+ if (!X) return;
314
+ let e = A();
315
+ return e instanceof HTMLElement && !B.current?.contains(e) && (G.current = e), B.current?.querySelector("[data-ck-composer-input]")?.focus({ preventScroll: !0 }), () => {
316
+ let e = G.current;
317
+ G.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
308
318
  };
309
- }, [J]);
310
- let Te = l.useRef(r.isAuthenticated);
311
- l.useEffect(() => {
312
- let e = !Te.current && r.isAuthenticated;
313
- if (Te.current = r.isAuthenticated, !e || !J || !C.trim()) return;
314
- let t = I.current?.querySelector("[data-ck-composer-input]");
319
+ }, [X]);
320
+ let ke = d.useRef(i.isAuthenticated);
321
+ d.useEffect(() => {
322
+ let e = !ke.current && i.isAuthenticated;
323
+ if (ke.current = i.isAuthenticated, !e || !X || !E.trim()) return;
324
+ let t = B.current?.querySelector("[data-ck-composer-input]");
315
325
  t?.focus({ preventScroll: !0 });
316
326
  let n = t?.value.length ?? 0;
317
- t?.setSelectionRange?.(n, n), P((e) => e && e.startsWith("Sign in to save comments") ? null : e);
327
+ t?.setSelectionRange?.(n, n), z((e) => e && e.startsWith("Sign in to save comments") ? null : e);
318
328
  }, [
319
- r.isAuthenticated,
320
- J,
321
- C
322
- ]), l.useLayoutEffect(() => {
323
- if (!J) return;
324
- let e = I.current;
329
+ i.isAuthenticated,
330
+ X,
331
+ E
332
+ ]), d.useLayoutEffect(() => {
333
+ if (!X) return;
334
+ let e = B.current;
325
335
  if (!e) return;
326
336
  let t = () => {
327
337
  let t = e.getBoundingClientRect().height;
328
- t > 0 && H((e) => Math.abs(e - t) > 1 ? t : e);
338
+ t > 0 && _e((e) => Math.abs(e - t) > 1 ? t : e);
329
339
  };
330
340
  t();
331
341
  let n = null;
@@ -336,81 +346,81 @@ var xe = l.memo(function({ core: n, state: r, active: a }) {
336
346
  }
337
347
  return () => n?.disconnect();
338
348
  }, [
339
- J,
340
- T,
341
- M
342
- ]), l.useEffect(() => {
343
- if (!a) return;
349
+ X,
350
+ O,
351
+ R
352
+ ]), d.useEffect(() => {
353
+ if (!o) return;
344
354
  let e = () => {
345
- g((e) => e && {
355
+ y((e) => e && {
346
356
  ...e,
347
- rect: B(e.element)
348
- }), m((e) => e && {
357
+ rect: V(e.element)
358
+ }), _((e) => e && {
349
359
  ...e,
350
- rect: B(e.element)
351
- }), v((e) => e.map((e) => ({
360
+ rect: V(e.element)
361
+ }), x((e) => e.map((e) => ({
352
362
  ...e,
353
- rect: B(e.element)
363
+ rect: V(e.element)
354
364
  })));
355
365
  };
356
366
  return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
357
367
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
358
368
  };
359
- }, [a]);
360
- let Y = l.useCallback(async (e, t, r) => {
361
- if (!e || A) return !1;
362
- j(!0), P(null);
369
+ }, [o]);
370
+ let Z = d.useCallback(async (e, t, n) => {
371
+ if (!e || F) return !1;
372
+ L(!0), z(null);
363
373
  try {
364
- let i = t?.trim(), a = r ? [{
365
- name: r.name,
366
- path: r.path,
367
- pathSource: r.pathSource,
368
- type: r.type,
369
- size: r.size,
370
- lastModified: r.lastModified
374
+ let i = t?.trim(), a = n ? [{
375
+ name: n.name,
376
+ path: n.path,
377
+ pathSource: n.pathSource,
378
+ type: n.type,
379
+ size: n.size,
380
+ lastModified: n.lastModified
371
381
  }] : [], o = i || a.length > 0 ? {
372
382
  ...i ? { comment: i } : {},
373
383
  ...a.length > 0 ? { attachments: a } : {}
374
- } : void 0, s = o ? await n.grabElement(e, o) : await n.grabElement(e);
375
- return j(!1), s ? (g(null), m(null), w(""), E((e) => (G(e?.previewUrl), null)), n.setTool(null), !0) : (P("Could not grab this element."), !1);
384
+ } : void 0, s = o ? await r.grabElement(e, o) : await r.grabElement(e);
385
+ return L(!1), s ? (y(null), _(null), D(""), k((e) => (K(e?.previewUrl), null)), r.setTool(null), !0) : (z("Could not grab this element."), !1);
376
386
  } catch {
377
- return j(!1), P("Could not copy this element for the agent."), !1;
387
+ return L(!1), z("Could not copy this element for the agent."), !1;
378
388
  }
379
- }, [n, A]), X = l.useCallback(async (e) => {
380
- if (e.length === 0 || A) return !1;
381
- j(!0), P(null);
389
+ }, [r, F]), Ae = d.useCallback(async (e) => {
390
+ if (e.length === 0 || F) return !1;
391
+ L(!0), z(null);
382
392
  try {
383
- let t = await n.grabElements(e);
384
- return j(!1), t ? (v([]), g(null), m(null), w(""), E((e) => (G(e?.previewUrl), null)), n.setTool(null), !0) : (P("Could not grab these elements."), !1);
393
+ let t = await r.grabElements(e);
394
+ return L(!1), t ? (x([]), y(null), _(null), D(""), k((e) => (K(e?.previewUrl), null)), r.setTool(null), !0) : (z("Could not grab these elements."), !1);
385
395
  } catch {
386
- return j(!1), P("Could not copy these elements for the agent."), !1;
396
+ return L(!1), z("Could not copy these elements for the agent."), !1;
387
397
  }
388
- }, [n, A]), Ee = l.useCallback(() => {
389
- let e = q.current.map((e) => e.element);
390
- X(e);
391
- }, [X]), De = l.useCallback(() => {
392
- v([]);
393
- }, []), Z = l.useRef(null), Q = l.useRef(!1), $ = l.useRef(null);
394
- $.current = y;
395
- let Oe = l.useRef(null);
396
- Oe.current = x, l.useEffect(() => {
397
- if (!x) return;
398
- let e = n.blockEscape();
398
+ }, [r, F]), je = d.useCallback(() => {
399
+ let e = Te.current.map((e) => e.element);
400
+ Ae(e);
401
+ }, [Ae]), Me = d.useCallback(() => {
402
+ x([]);
403
+ }, []), Q = d.useRef(null), $ = d.useRef(!1), Ne = d.useRef(null);
404
+ Ne.current = S;
405
+ let Pe = d.useRef(null);
406
+ Pe.current = w, d.useEffect(() => {
407
+ if (!w) return;
408
+ let e = r.blockEscape();
399
409
  return () => e();
400
- }, [x, n]), l.useEffect(() => {
401
- if (!x) return;
402
- let e = k();
403
- return e instanceof HTMLElement && !R.current?.contains(e) && (z.current = e), R.current?.querySelector("[role=\"menuitem\"]")?.focus({ preventScroll: !0 }), () => {
404
- let e = z.current;
405
- z.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
410
+ }, [w, r]), d.useEffect(() => {
411
+ if (!w) return;
412
+ let e = A();
413
+ return e instanceof HTMLElement && !W.current?.contains(e) && (G.current = e), W.current?.querySelector("[role=\"menuitem\"]")?.focus({ preventScroll: !0 }), () => {
414
+ let e = G.current;
415
+ G.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
406
416
  };
407
- }, [x]);
408
- let ke = l.useCallback((e) => {
409
- let t = R.current;
417
+ }, [w]);
418
+ let Fe = d.useCallback((e) => {
419
+ let t = W.current;
410
420
  if (!t) return;
411
421
  let n = Array.from(t.querySelectorAll("[role=\"menuitem\"]"));
412
422
  if (n.length === 0) return;
413
- let r = k(), i = n.findIndex((e) => e === r), a = (e) => {
423
+ let r = A(), i = n.findIndex((e) => e === r), a = (e) => {
414
424
  n[(e + n.length) % n.length]?.focus({ preventScroll: !0 });
415
425
  };
416
426
  switch (e.key) {
@@ -427,432 +437,464 @@ var xe = l.memo(function({ core: n, state: r, active: a }) {
427
437
  e.preventDefault(), e.stopPropagation(), a(n.length - 1);
428
438
  break;
429
439
  case "Enter":
430
- case " ": e.preventDefault(), e.stopPropagation(), k()?.click();
440
+ case " ": e.preventDefault(), e.stopPropagation(), A()?.click();
431
441
  }
432
442
  }, []);
433
- l.useEffect(() => {
434
- if (!a) return;
435
- let r = (e) => {
436
- e.button !== 0 || N(e) || h || (S(null), Z.current = {
437
- x: e.clientX,
438
- y: e.clientY
439
- }, Q.current = !1);
440
- }, i = (n) => {
441
- if (N(n)) return;
442
- let r = F(n.clientX, n.clientY);
443
- r && (n.preventDefault(), n.stopPropagation(), S({
444
- element: r,
445
- selector: t(r),
446
- xpath: e(r),
447
- x: n.clientX,
448
- y: n.clientY
449
- }));
450
- }, o = null, s = null, c = () => {
451
- o &&= (clearTimeout(o), null), s = null;
452
- }, ee = (n) => {
453
- if (N(n) || n.touches.length !== 1) return;
454
- let r = n.touches[0];
455
- if (!r) return;
456
- let i = F(r.clientX, r.clientY);
457
- i && (s = {
443
+ d.useEffect(() => {
444
+ if (!o && !j) return;
445
+ let i = (t) => {
446
+ e() || t.button !== 0 || P(t) || v || (T(null), Q.current = {
447
+ x: t.clientX,
448
+ y: t.clientY
449
+ }, $.current = !1);
450
+ }, a = (r) => {
451
+ if (e() || P(r)) return;
452
+ let i = I(r.clientX, r.clientY);
453
+ i && (r.preventDefault(), r.stopPropagation(), T({
454
+ element: i,
455
+ selector: n(i),
456
+ xpath: t(i),
458
457
  x: r.clientX,
459
- y: r.clientY,
460
- element: i
461
- }, o = setTimeout(() => {
462
- s && (S({
463
- element: s.element,
464
- selector: t(s.element),
465
- xpath: e(s.element),
466
- x: s.x,
467
- y: s.y
468
- }), s = null, o = null);
458
+ y: r.clientY
459
+ }));
460
+ }, s = null, c = null, l = () => {
461
+ s &&= (clearTimeout(s), null), c = null;
462
+ }, ee = (r) => {
463
+ if (e() || P(r) || r.touches.length !== 1) return;
464
+ let i = r.touches[0];
465
+ if (!i) return;
466
+ let a = I(i.clientX, i.clientY);
467
+ a && (c = {
468
+ x: i.clientX,
469
+ y: i.clientY,
470
+ element: a
471
+ }, s = setTimeout(() => {
472
+ c && (T({
473
+ element: c.element,
474
+ selector: n(c.element),
475
+ xpath: t(c.element),
476
+ x: c.x,
477
+ y: c.y
478
+ }), c = null, s = null);
469
479
  }, 550));
470
480
  }, te = (e) => {
471
- if (!s || e.touches.length !== 1) return;
481
+ if (!c || e.touches.length !== 1) return;
472
482
  let t = e.touches[0];
473
483
  if (!t) return;
474
- let n = t.clientX - s.x, r = t.clientY - s.y;
475
- (Math.abs(n) > 10 || Math.abs(r) > 10) && c();
476
- }, l = () => {
477
- c();
478
- }, u = (e) => {
479
- if (N(e)) return;
480
- let t = Z.current;
481
- if (t) {
482
- if (e.pointerType === "mouse" && !(e.buttons & 1)) Z.current = null, Q.current = !1, b(null);
484
+ let n = t.clientX - c.x, r = t.clientY - c.y;
485
+ (Math.abs(n) > 10 || Math.abs(r) > 10) && l();
486
+ }, u = () => {
487
+ l();
488
+ }, ne = (t) => {
489
+ if (e() || P(t)) return;
490
+ let n = Q.current;
491
+ if (n) {
492
+ if (t.pointerType === "mouse" && !(t.buttons & 1)) Q.current = null, $.current = !1, C(null);
483
493
  else {
484
- let n = e.clientX - t.x, r = e.clientY - t.y;
485
- if ($.current || Math.abs(n) > 6 || Math.abs(r) > 6) {
486
- Q.current = !0, b({
487
- startX: t.x,
488
- startY: t.y,
489
- x: e.clientX,
490
- y: e.clientY
491
- }), m(null);
494
+ let e = t.clientX - n.x, r = t.clientY - n.y;
495
+ if (Ne.current || Math.abs(e) > 6 || Math.abs(r) > 6) {
496
+ $.current = !0, C({
497
+ startX: n.x,
498
+ startY: n.y,
499
+ x: t.clientX,
500
+ y: t.clientY
501
+ }), _(null);
492
502
  return;
493
503
  }
494
504
  }
495
505
  }
496
- if (h) return;
497
- let n = F(e.clientX, e.clientY);
498
- m(n ? V(n) : null);
506
+ if (v) return;
507
+ let r = I(t.clientX, t.clientY);
508
+ _(r ? U(r) : null);
499
509
  }, d = () => {
500
- Z.current = null, Q.current = !1, b(null);
501
- }, f = (e) => {
502
- let t = Z.current;
503
- Z.current = null;
504
- let n = $.current;
505
- if (!t || !n) return;
506
- let r = se({
507
- ...n,
508
- x: e.clientX,
509
- y: e.clientY
510
+ Q.current = null, $.current = !1, C(null);
511
+ }, f = (t) => {
512
+ if (e()) return;
513
+ let n = Q.current;
514
+ Q.current = null;
515
+ let r = Ne.current;
516
+ if (!n || !r) return;
517
+ let i = le({
518
+ ...r,
519
+ x: t.clientX,
520
+ y: t.clientY
510
521
  });
511
- if (r.width < 6 || r.height < 6) {
512
- b(null);
522
+ if (i.width < 6 || i.height < 6) {
523
+ C(null);
513
524
  return;
514
525
  }
515
- let i = ce(r);
516
- if (i.length > 0) {
517
- let e = i.map(V);
518
- v((t) => {
526
+ let a = ue(i);
527
+ if (a.length > 0) {
528
+ let e = a.map(U);
529
+ x((t) => {
519
530
  let n = new Set(t.map((e) => e.element)), r = [...t];
520
531
  for (let t of e) n.has(t.element) || r.push(t);
521
532
  return r;
522
533
  });
523
534
  }
524
- b(null);
525
- }, ne = (e) => {
526
- if (N(e)) return;
527
- if (Q.current) {
528
- Q.current = !1, e.preventDefault(), e.stopPropagation();
535
+ C(null);
536
+ }, p = (t) => {
537
+ if (e() || P(t) || j) return;
538
+ if ($.current) {
539
+ $.current = !1, t.preventDefault(), t.stopPropagation();
529
540
  return;
530
541
  }
531
- e.preventDefault(), e.stopPropagation();
532
- let t = F(e.clientX, e.clientY);
533
- h && !e.shiftKey ? (g(null), m(null), w(""), E((e) => (G(e?.previewUrl), null)), P(null)) : t && (e.shiftKey ? (v((e) => e.some((e) => e.element === t) ? e.filter((e) => e.element !== t) : [...h && !e.some((e) => e.element === h.element) ? [...e, h] : e, V(t)]), m(null), g(null), w(""), E((e) => (G(e?.previewUrl), null)), P(null)) : (g(V(t)), m(null), w(""), E((e) => (G(e?.previewUrl), null)), P(null)));
534
- }, re = (e) => {
535
- if (e.key === "Escape") {
536
- if (e.isComposing) return;
537
- if (Oe.current) {
538
- e.preventDefault(), e.stopPropagation(), S(null);
542
+ t.preventDefault(), t.stopPropagation();
543
+ let n = I(t.clientX, t.clientY);
544
+ v && !t.shiftKey ? (y(null), _(null), D(""), k((e) => (K(e?.previewUrl), null)), z(null)) : n && (t.shiftKey ? (x((e) => e.some((e) => e.element === n) ? e.filter((e) => e.element !== n) : [...v && !e.some((e) => e.element === v.element) ? [...e, v] : e, U(n)]), _(null), y(null), D(""), k((e) => (K(e?.previewUrl), null)), z(null)) : (y(U(n)), _(null), D(""), k((e) => (K(e?.previewUrl), null)), z(null)));
545
+ }, m = (t) => {
546
+ if (e()) return;
547
+ if (t.key === "Escape") {
548
+ if (t.isComposing) return;
549
+ if (Pe.current) {
550
+ t.preventDefault(), t.stopPropagation(), T(null);
539
551
  return;
540
552
  }
541
- e.preventDefault(), e.stopPropagation(), g(null), m(null), w(""), E((e) => (G(e?.previewUrl), null)), P(null), n.setTool(null);
553
+ t.preventDefault(), t.stopPropagation(), N.current = null, M(!1), y(null), _(null), D(""), k((e) => (K(e?.previewUrl), null)), z(null), r.setTool(null);
542
554
  return;
543
555
  }
544
- if (!e.metaKey && !e.ctrlKey || e.shiftKey || e.altKey || e.key !== "c" && e.key !== "C" && e.code !== "KeyC" || oe(e)) return;
545
- let t = typeof window < "u" ? window.getSelection() : null;
546
- if (t && !t.isCollapsed && t.toString().length > 0) return;
547
- let r = q.current;
548
- if (r.length > 0) {
549
- e.preventDefault(), e.stopPropagation(), X(r.map((e) => e.element));
556
+ if (j || !t.metaKey && !t.ctrlKey || t.shiftKey || t.altKey || t.key !== "c" && t.key !== "C" && t.code !== "KeyC" || ce(t)) return;
557
+ let n = typeof window < "u" ? window.getSelection() : null;
558
+ if (n && !n.isCollapsed && n.toString().length > 0) return;
559
+ let i = Te.current;
560
+ if (i.length > 0) {
561
+ t.preventDefault(), t.stopPropagation(), Ae(i.map((e) => e.element));
550
562
  return;
551
563
  }
552
- let i = xe.current;
553
- if (!i) return;
554
- e.preventDefault(), e.stopPropagation();
555
- let a = h?.element === i;
556
- Y(i, a ? Se.current : void 0, a ? Ce.current : null);
564
+ let a = we.current;
565
+ if (!a) return;
566
+ t.preventDefault(), t.stopPropagation();
567
+ let o = v?.element === a;
568
+ Z(a, o ? Ee.current : void 0, o ? De.current : null);
557
569
  };
558
- return document.addEventListener("pointerdown", r, !0), document.addEventListener("pointermove", u, !0), document.addEventListener("pointerup", f, !0), document.addEventListener("pointercancel", d, !0), document.addEventListener("click", ne, !0), document.addEventListener("contextmenu", i, !0), document.addEventListener("touchstart", ee, {
570
+ return document.addEventListener("pointerdown", i, !0), document.addEventListener("pointermove", ne, !0), document.addEventListener("pointerup", f, !0), document.addEventListener("pointercancel", d, !0), document.addEventListener("click", p, !0), document.addEventListener("contextmenu", a, !0), document.addEventListener("touchstart", ee, {
559
571
  capture: !0,
560
572
  passive: !0
561
573
  }), document.addEventListener("touchmove", te, {
562
574
  capture: !0,
563
575
  passive: !0
564
- }), document.addEventListener("touchend", l, {
576
+ }), document.addEventListener("touchend", u, {
565
577
  capture: !0,
566
578
  passive: !0
567
- }), document.addEventListener("touchcancel", l, {
579
+ }), document.addEventListener("touchcancel", u, {
568
580
  capture: !0,
569
581
  passive: !0
570
- }), window.addEventListener("keydown", re, !0), () => {
571
- document.removeEventListener("pointerdown", r, !0), document.removeEventListener("pointermove", u, !0), document.removeEventListener("pointerup", f, !0), document.removeEventListener("pointercancel", d, !0), document.removeEventListener("click", ne, !0), document.removeEventListener("contextmenu", i, !0), document.removeEventListener("touchstart", ee, !0), document.removeEventListener("touchmove", te, !0), document.removeEventListener("touchend", l, !0), document.removeEventListener("touchcancel", l, !0), window.removeEventListener("keydown", re, !0), c();
582
+ }), window.addEventListener("keydown", m, !0), () => {
583
+ document.removeEventListener("pointerdown", i, !0), document.removeEventListener("pointermove", ne, !0), document.removeEventListener("pointerup", f, !0), document.removeEventListener("pointercancel", d, !0), document.removeEventListener("click", p, !0), document.removeEventListener("contextmenu", a, !0), document.removeEventListener("touchstart", ee, !0), document.removeEventListener("touchmove", te, !0), document.removeEventListener("touchend", u, !0), document.removeEventListener("touchcancel", u, !0), window.removeEventListener("keydown", m, !0), l();
572
584
  };
573
585
  }, [
574
- a,
575
- n,
576
- Y,
577
- X,
578
- h
586
+ o,
587
+ j,
588
+ r,
589
+ Z,
590
+ Ae,
591
+ v
579
592
  ]);
580
- let Ae = l.useCallback(async (e) => {
593
+ let Ie = d.useCallback(async (e) => {
581
594
  e.preventDefault();
582
- let t = C.trim();
583
- if (h && t && !D) {
584
- if (!r.currentUser) P("Sign in to save comments. You can still use Grab for agent without signing in."), n.toggleLoginModal();
585
- else {
586
- O(!0), P(null);
587
- try {
588
- await n.createComment("pin", t, ue(h)), O(!1), g(null), w(""), E((e) => (G(e?.previewUrl), null)), n.setTool(null);
589
- } catch {
590
- O(!1), P("Could not save this comment. Try again.");
591
- }
592
- }
595
+ let t = E.trim();
596
+ if (!v || !t || j) return;
597
+ if (!i.currentUser) {
598
+ z("Sign in to save comments. You can still use Grab for agent without signing in."), r.toggleLoginModal();
599
+ return;
600
+ }
601
+ let n = {
602
+ userId: i.currentUser.id,
603
+ branch: i.activeBranch ?? null,
604
+ page: J,
605
+ submitting: !1
606
+ };
607
+ N.current = n;
608
+ let o = () => {
609
+ let e = r.getState();
610
+ return N.current === n && e.isAuthenticated && e.currentUser?.id === n.userId && (e.activeBranch ?? null) === n.branch && (e.activeTool === null || e.activeTool === "select") && a().path === n.page;
611
+ }, s = r.on("auth:logout", () => {
612
+ N.current === n && (N.current = null, M(!1));
613
+ });
614
+ M(!0), z(null);
615
+ try {
616
+ let e = await l(r, t, de(v), { files: O ? [O.file] : [] }, () => !o() || r.getState().activeTool !== "select" ? !1 : (n.submitting = !0, !0));
617
+ if (!o()) return;
618
+ if (e.status === "failed") throw Error(e.message);
619
+ y(null), D(""), k((e) => (K(e?.previewUrl), null)), r.setTool(null);
620
+ } catch {
621
+ if (!o()) return;
622
+ r.getState().activeTool === null && r.setTool("select"), z("Could not save this comment. Try again.");
623
+ } finally {
624
+ s(), N.current === n && (N.current = null, M(!1));
593
625
  }
594
626
  }, [
595
- C,
596
- n,
597
- D,
598
- h,
599
- r.currentUser
600
- ]), je = l.useCallback(() => {
601
- Y(h?.element ?? null, C, T);
627
+ O,
628
+ E,
629
+ r,
630
+ J,
631
+ j,
632
+ v,
633
+ i.activeBranch,
634
+ i.currentUser
635
+ ]), Le = d.useCallback(() => {
636
+ Z(v?.element ?? null, E, O);
602
637
  }, [
603
- T,
604
- C,
605
- Y,
606
- h
607
- ]), Me = l.useCallback(() => {
608
- L.current?.click();
609
- }, []), Ne = l.useCallback((e) => {
638
+ O,
639
+ E,
640
+ Z,
641
+ v
642
+ ]), Re = d.useCallback(() => {
643
+ H.current?.click();
644
+ }, []), ze = d.useCallback((e) => {
610
645
  let t = e.currentTarget, n = t.files?.[0] ?? null;
611
- E((e) => (G(e?.previewUrl), n ? fe(n, t) : null)), t.value = "";
612
- }, []), Pe = l.useCallback(() => {
613
- E((e) => (G(e?.previewUrl), null));
614
- }, []), Fe = l.useMemo(() => ee(), []);
615
- return !a && we.length === 0 ? null : /* @__PURE__ */ f("div", {
646
+ k((e) => (K(e?.previewUrl), n ? me(n, t) : null)), t.value = "";
647
+ }, []), Be = d.useCallback(() => {
648
+ k((e) => (K(e?.previewUrl), null));
649
+ }, []), Ve = d.useMemo(() => ne(), []);
650
+ return !o && !j && Oe.length === 0 ? null : /* @__PURE__ */ m("div", {
616
651
  className: "ck-element-selector",
617
652
  "data-testid": "ck-element-selector",
618
653
  children: [
619
- we.map((e) => /* @__PURE__ */ d("div", {
654
+ Oe.map((e) => /* @__PURE__ */ p("div", {
620
655
  "aria-hidden": "true",
621
656
  className: "ck-element-selector-mark",
622
657
  "data-comment-id": e.id,
623
- style: K(e.rect)
658
+ style: q(e.rect)
624
659
  }, e.id)),
625
- a && p && !y && /* @__PURE__ */ d("div", {
660
+ o && g && !S && /* @__PURE__ */ p("div", {
626
661
  "aria-hidden": "true",
627
662
  className: "ck-element-selector-outline",
628
663
  "data-state": "hover",
629
- style: K(p.rect)
664
+ style: q(g.rect)
630
665
  }),
631
- a && y && /* @__PURE__ */ d("div", {
666
+ o && S && /* @__PURE__ */ p("div", {
632
667
  "aria-hidden": "true",
633
668
  className: "ck-element-selector-marquee",
634
669
  "data-testid": "ck-element-selector-marquee",
635
670
  style: {
636
- left: Math.min(y.startX, y.x),
637
- top: Math.min(y.startY, y.y),
638
- width: Math.abs(y.x - y.startX),
639
- height: Math.abs(y.y - y.startY)
671
+ left: Math.min(S.startX, S.x),
672
+ top: Math.min(S.startY, S.y),
673
+ width: Math.abs(S.x - S.startX),
674
+ height: Math.abs(S.y - S.startY)
640
675
  }
641
676
  }),
642
- a && _.map((e, t) => /* @__PURE__ */ d("div", {
677
+ o && b.map((e, t) => /* @__PURE__ */ p("div", {
643
678
  "aria-hidden": "true",
644
679
  className: "ck-element-selector-outline",
645
680
  "data-state": "multi",
646
681
  "data-multi-index": t + 1,
647
- style: K(e.rect)
682
+ style: q(e.rect)
648
683
  }, `multi-${t}-${e.selector}-${e.xpath}`)),
649
- a && x && /* @__PURE__ */ f("ul", {
650
- ref: R,
684
+ o && w && /* @__PURE__ */ m("ul", {
685
+ ref: W,
651
686
  className: "ck-element-selector-context-menu",
652
687
  "data-testid": "ck-element-selector-context-menu",
653
688
  role: "menu",
654
689
  "aria-label": "Element actions",
655
- onKeyDown: ke,
656
- style: _e(x),
690
+ onKeyDown: Fe,
691
+ style: ve(w),
657
692
  children: [
658
- /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d("button", {
693
+ /* @__PURE__ */ p("li", { children: /* @__PURE__ */ p("button", {
659
694
  type: "button",
660
695
  role: "menuitem",
661
696
  "data-testid": "ck-context-menu-grab",
662
697
  onClick: () => {
663
- let e = x.element;
664
- S(null), Y(e);
698
+ let e = w.element;
699
+ T(null), Z(e);
665
700
  },
666
701
  children: "Grab for agent"
667
702
  }) }),
668
- /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d("button", {
703
+ /* @__PURE__ */ p("li", { children: /* @__PURE__ */ p("button", {
669
704
  type: "button",
670
705
  role: "menuitem",
671
706
  "data-testid": "ck-context-menu-comment",
707
+ disabled: !h,
672
708
  onClick: () => {
673
- let e = V(x.element);
674
- S(null), g(e);
709
+ let e = U(w.element);
710
+ T(null), y(e);
675
711
  },
676
712
  children: "Add comment"
677
713
  }) }),
678
- /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d("button", {
714
+ /* @__PURE__ */ p("li", { children: /* @__PURE__ */ p("button", {
679
715
  type: "button",
680
716
  role: "menuitem",
681
717
  "data-testid": "ck-context-menu-copy-selector",
682
718
  onClick: () => {
683
- let e = x.selector;
684
- S(null), pe(e, "CSS selector");
719
+ let e = w.selector;
720
+ T(null), he(e, "CSS selector");
685
721
  },
686
722
  children: "Copy CSS selector"
687
723
  }) }),
688
- /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d("button", {
724
+ /* @__PURE__ */ p("li", { children: /* @__PURE__ */ p("button", {
689
725
  type: "button",
690
726
  role: "menuitem",
691
727
  "data-testid": "ck-context-menu-copy-xpath",
692
728
  onClick: () => {
693
- let e = x.xpath;
694
- S(null), pe(e, "XPath");
729
+ let e = w.xpath;
730
+ T(null), he(e, "XPath");
695
731
  },
696
732
  children: "Copy XPath"
697
733
  }) }),
698
- /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d("button", {
734
+ /* @__PURE__ */ p("li", { children: /* @__PURE__ */ p("button", {
699
735
  type: "button",
700
736
  role: "menuitem",
701
737
  "data-testid": "ck-context-menu-inspect",
702
738
  onClick: () => {
703
- console.log("[CommentKit] inspect", x.element), S(null);
739
+ console.log("[CommentKit] inspect", w.element), T(null);
704
740
  },
705
741
  children: "Inspect (log to console)"
706
742
  }) })
707
743
  ]
708
744
  }),
709
- a && _.length > 0 && /* @__PURE__ */ f("div", {
745
+ o && b.length > 0 && /* @__PURE__ */ m("div", {
710
746
  className: "ck-element-selector-multibar",
711
747
  "data-testid": "ck-element-selector-multibar",
712
748
  children: [
713
- /* @__PURE__ */ f("span", {
749
+ /* @__PURE__ */ m("span", {
714
750
  className: "ck-element-selector-multibar-count",
715
- children: [_.length, " selected"]
751
+ children: [b.length, " selected"]
716
752
  }),
717
- /* @__PURE__ */ d(o, {
753
+ /* @__PURE__ */ p(s, {
718
754
  type: "button",
719
755
  size: "sm",
720
- onClick: Ee,
721
- disabled: A,
756
+ onClick: je,
757
+ disabled: F,
722
758
  "data-testid": "ck-element-grab-many-button",
723
- children: A ? "Grabbing…" : `Grab ${_.length} for agent`
759
+ children: F ? "Grabbing…" : `Grab ${b.length} for agent`
724
760
  }),
725
- /* @__PURE__ */ d(o, {
761
+ /* @__PURE__ */ p(s, {
726
762
  type: "button",
727
763
  size: "sm",
728
764
  variant: "ghost",
729
- onClick: De,
730
- disabled: A,
765
+ onClick: Me,
766
+ disabled: F,
731
767
  "data-testid": "ck-element-grab-clear-button",
732
768
  children: "Clear"
733
769
  })
734
770
  ]
735
771
  }),
736
- a && h && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("div", {
772
+ (o || j) && v && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("div", {
737
773
  "aria-hidden": "true",
738
774
  className: "ck-element-selector-outline",
739
775
  "data-state": "selected",
740
- style: K(h.rect)
741
- }), /* @__PURE__ */ f("form", {
742
- ref: I,
776
+ style: q(v.rect)
777
+ }), /* @__PURE__ */ m("form", {
778
+ ref: B,
743
779
  className: "ck-element-selector-composer",
744
- style: me(h.rect, le),
745
- onSubmit: Ae,
780
+ style: ge(v.rect, pe),
781
+ onSubmit: Ie,
746
782
  children: [
747
- /* @__PURE__ */ d("div", {
783
+ /* @__PURE__ */ p("div", {
748
784
  className: "ck-element-selector-input-row",
749
- children: /* @__PURE__ */ d(te, {
785
+ children: /* @__PURE__ */ p(te, {
750
786
  "data-ck-composer-input": "",
751
787
  "aria-label": "Element comment",
752
- value: C,
788
+ value: E,
753
789
  placeholder: "Add comment",
754
- disabled: D || A,
790
+ disabled: j || F,
755
791
  onChange: (e) => {
756
- w(e.currentTarget.value), M && P(null);
792
+ D(e.currentTarget.value), R && z(null);
757
793
  }
758
794
  })
759
795
  }),
760
- !s && /* @__PURE__ */ d("input", {
761
- ref: L,
796
+ !c && /* @__PURE__ */ p("input", {
797
+ ref: H,
762
798
  "aria-label": "Attach file",
763
799
  className: "ck-element-selector-file-input",
764
800
  type: "file",
765
- onChange: Ne
801
+ disabled: j || F,
802
+ onChange: ze
766
803
  }),
767
- T && /* @__PURE__ */ f("div", {
804
+ O && /* @__PURE__ */ m("div", {
768
805
  className: "ck-element-selector-attachment",
769
806
  "data-testid": "ck-element-attachment-preview",
770
807
  children: [
771
- T.previewUrl && /* @__PURE__ */ d("img", {
808
+ O.previewUrl && /* @__PURE__ */ p("img", {
772
809
  alt: "",
773
810
  "aria-hidden": "true",
774
811
  className: "ck-element-selector-attachment-image",
775
- src: T.previewUrl
812
+ src: O.previewUrl
776
813
  }),
777
- /* @__PURE__ */ f("div", {
814
+ /* @__PURE__ */ m("div", {
778
815
  className: "ck-element-selector-attachment-meta",
779
816
  children: [
780
- /* @__PURE__ */ d("span", {
817
+ /* @__PURE__ */ p("span", {
781
818
  className: "ck-element-selector-attachment-name",
782
- children: T.name
819
+ children: O.name
783
820
  }),
784
- /* @__PURE__ */ d("span", {
821
+ /* @__PURE__ */ p("span", {
785
822
  className: "ck-element-selector-attachment-path",
786
- title: T.path,
787
- children: T.path
823
+ title: O.path,
824
+ children: O.path
788
825
  }),
789
- /* @__PURE__ */ d("span", {
826
+ /* @__PURE__ */ p("span", {
790
827
  className: "ck-element-selector-attachment-size",
791
- children: de(T.size)
828
+ children: fe(O.size)
792
829
  })
793
830
  ]
794
831
  }),
795
- /* @__PURE__ */ d(o, {
832
+ /* @__PURE__ */ p(s, {
796
833
  type: "button",
797
834
  size: "icon-xs",
798
835
  variant: "ghost",
799
836
  "aria-label": "Remove attachment",
800
- disabled: D || A,
801
- onClick: Pe,
802
- children: /* @__PURE__ */ d(re, {
837
+ disabled: j || F,
838
+ onClick: Be,
839
+ children: /* @__PURE__ */ p(ie, {
803
840
  className: "ck-element-selector-action-icon",
804
841
  "aria-hidden": "true"
805
842
  })
806
843
  })
807
844
  ]
808
845
  }),
809
- /* @__PURE__ */ f("div", {
846
+ /* @__PURE__ */ m("div", {
810
847
  className: "ck-element-selector-actions",
811
848
  children: [
812
- !s && /* @__PURE__ */ f(o, {
849
+ !c && /* @__PURE__ */ m(s, {
813
850
  type: "button",
814
851
  variant: "outline",
815
852
  className: "ck-element-selector-attach-action",
816
- disabled: D || A,
817
- onClick: Me,
853
+ disabled: j || F,
854
+ onClick: Re,
818
855
  "data-testid": "ck-element-attach-button",
819
- children: [/* @__PURE__ */ d(ne, {
856
+ children: [/* @__PURE__ */ p(re, {
820
857
  className: "ck-element-selector-action-icon",
821
858
  "aria-hidden": "true"
822
- }), /* @__PURE__ */ d("span", { children: "Attach" })]
859
+ }), /* @__PURE__ */ p("span", { children: "Attach" })]
823
860
  }),
824
- /* @__PURE__ */ d(o, {
861
+ /* @__PURE__ */ p(s, {
825
862
  type: "submit",
826
863
  className: "ck-element-selector-save-action",
827
- disabled: !C.trim() || D || A,
828
- children: D ? "Saving" : "Save"
864
+ disabled: !h || !E.trim() || j || F,
865
+ children: j ? "Saving" : "Save"
829
866
  }),
830
- /* @__PURE__ */ d(o, {
867
+ /* @__PURE__ */ p(s, {
831
868
  type: "button",
832
869
  className: "ck-element-selector-grab-action",
833
- variant: Fe ? "default" : "outline",
834
- disabled: D || A,
835
- onClick: je,
836
- title: s ? "Copy element context to clipboard for your agent" : "Copy element source + screenshot to clipboard for your agent",
870
+ variant: Ve ? "default" : "outline",
871
+ disabled: j || F,
872
+ onClick: Le,
873
+ title: c ? "Copy element context to clipboard for your agent" : "Copy element source + screenshot to clipboard for your agent",
837
874
  "data-testid": "ck-element-grab-button",
838
- children: A ? "Grabbing…" : "Grab for agent"
875
+ children: F ? "Grabbing…" : "Grab for agent"
839
876
  })
840
877
  ]
841
878
  }),
842
- M && /* @__PURE__ */ d("p", {
879
+ !h && /* @__PURE__ */ p("p", {
880
+ role: "status",
881
+ className: "ck-element-selector-error",
882
+ children: ae
883
+ }),
884
+ R && /* @__PURE__ */ p("p", {
843
885
  className: "ck-element-selector-error",
844
886
  role: "alert",
845
- children: M
887
+ children: R
846
888
  })
847
889
  ]
848
890
  })] })
849
891
  ]
850
892
  });
851
893
  });
852
- function q(e) {
853
- return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("style", {
894
+ function Se(e) {
895
+ return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("style", {
854
896
  "data-ck-tool-styles": "element-selector",
855
- children: p
856
- }), /* @__PURE__ */ d(xe, { ...e })] });
897
+ children: h
898
+ }), /* @__PURE__ */ p(Y, { ...e })] });
857
899
  }
858
- export { q as ElementSelector };
900
+ export { Se as ElementSelector };