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