@commentkit/comment-kit 0.6.9 → 0.7.1

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 (73) hide show
  1. package/CHANGELOG.md +63 -4
  2. package/LICENSE +18 -2
  3. package/README.md +133 -88
  4. package/SECURITY.md +48 -0
  5. package/dist/THIRD_PARTY_NOTICES.txt +284 -0
  6. package/dist/angular.es.js +25 -12
  7. package/dist/comment-kit.es.js +25 -13
  8. package/dist/demo.es.js +148 -70
  9. package/dist/headless.es.js +3 -3
  10. package/dist/preact.es.js +3 -3
  11. package/dist/qwik.es.js +1 -110
  12. package/dist/qwik.qwik.mjs +114 -0
  13. package/dist/react.es.js +3 -3
  14. package/dist/shared/annotation-icons-Dh-bmNYK.js +172 -0
  15. package/dist/shared/annotation-toolbar-cGC1p-SP.js +1093 -0
  16. package/dist/shared/attachment-refresh-CzQFXHkL.js +94 -0
  17. package/dist/shared/{bridge-DRE03N9X.js → bridge-CJoGYngu.js} +6 -3
  18. package/dist/shared/{button-group-CHfMRXyA.js → button-group-CWdKaOlC.js} +14 -16
  19. package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
  20. package/dist/shared/comment-drawing-canvas-DdXlMgbF.js +124 -0
  21. package/dist/shared/comment-icon-Dg9ZWpz-.js +608 -0
  22. package/dist/shared/comment-image-lightbox-B7iHjnAz.js +190 -0
  23. package/dist/shared/comment-images-content-D7YNUgo5.js +214 -0
  24. package/dist/shared/{comment-kit-core-D0kY00St.js → comment-kit-core-C862uNAm.js} +1371 -853
  25. package/dist/shared/comment-kit-ui-0vd-DY4S.js +19977 -0
  26. package/dist/shared/comment-screenshot-annotator-DcaSSuWB.js +151 -0
  27. package/dist/shared/comment-screenshot-overlay-D_nFoJmM.js +207 -0
  28. package/dist/shared/{dev-export-panel-BLngcr5q.js → dev-export-panel-pWBlhlse.js} +8 -8
  29. package/dist/shared/dev-grab-eQ9EgEGY.js +210 -0
  30. package/dist/shared/dist-De294MVF.js +623 -0
  31. package/dist/shared/{element-selector-CtFzgHvq.js → element-selector-DC-_XJ0k.js} +350 -305
  32. package/dist/shared/{icons-BSHCWYO1.js → icons-nzMOLzrm.js} +2 -3
  33. package/dist/shared/{mount-ui-CVivB_eQ.js → mount-ui-B68j8r6I.js} +4 -4
  34. package/dist/shared/{pusher-BEl7Qn-8.js → pusher-C1FHQGXV.js} +1 -1
  35. package/dist/shared/realtime-Diqz7G_y.js +317 -0
  36. package/dist/shared/realtime-recovery-DJ_adc-H.js +135 -0
  37. package/dist/shared/{separator-DusFNTs-.js → separator-XDBsaWyw.js} +891 -785
  38. package/dist/shared/{shadow-root-CmYXiSRR.js → shadow-root-CrO75sED.js} +1 -1
  39. package/dist/shared/styles-C9Jwvm0Q.js +2 -0
  40. package/dist/shared/useRender-D1z_X_BY.js +5 -0
  41. package/dist/shared/{useValueChanged-DQXLia-2.js → useValueChanged-CrzfD8l-.js} +15 -15
  42. package/dist/shared/{validation-C7QG8j7Z.js → validation-D-8u4M7I.js} +14 -1
  43. package/dist/shared/{websocket-manager-BTRqNTB7.js → websocket-manager-CFak_YHy.js} +148 -89
  44. package/dist/solid.es.js +3 -3
  45. package/dist/svelte.es.js +3 -3
  46. package/dist/types/adapters/bridge.d.ts +9 -12
  47. package/dist/types/angular/index.d.ts +15 -5
  48. package/dist/types/core/api-client.d.ts +24 -18
  49. package/dist/types/core/comment-kit-core.d.ts +28 -11
  50. package/dist/types/core/local-demo.d.ts +1 -0
  51. package/dist/types/core/types.d.ts +103 -0
  52. package/dist/types/core/websocket-manager.d.ts +12 -0
  53. package/dist/types/core/write-access.d.ts +9 -0
  54. package/dist/types/headless.d.ts +1 -1
  55. package/dist/types/index.d.ts +8 -4
  56. package/dist/types/qwik/index.d.ts +4 -1
  57. package/dist/vue.es.js +3 -3
  58. package/docs/api-reference.md +378 -0
  59. package/docs/local-demo.md +60 -0
  60. package/package.json +17 -6
  61. package/dist/shared/annotation-toolbar-pX17NLmJ.js +0 -1104
  62. package/dist/shared/clamp-CcFVX0vC.js +0 -55
  63. package/dist/shared/comment-drawing-canvas-CYu5SwRf.js +0 -126
  64. package/dist/shared/comment-image-lightbox-0VdAs2iT.js +0 -178
  65. package/dist/shared/comment-kit-ui-D2j2gvnm.js +0 -16685
  66. package/dist/shared/comment-screenshot-annotator-BuojwviY.js +0 -137
  67. package/dist/shared/comment-screenshot-overlay-BZX0Vcb8.js +0 -144
  68. package/dist/shared/dev-grab-pDAfH2lr.js +0 -203
  69. package/dist/shared/local-demo-context-BohlYbHt.js +0 -6
  70. package/dist/shared/realtime-BG_t_ze7.js +0 -281
  71. package/dist/shared/resolveAriaLabelledBy-CIKpnjNJ.js +0 -669
  72. package/dist/shared/styles-D_FEJZ9G.js +0 -2
  73. package/dist/shared/useLabelableId-DGbfdMi_.js +0 -155
@@ -0,0 +1,151 @@
1
+ import { n as e, r as t, t as n } from "./annotation-toolbar-cGC1p-SP.js";
2
+ import { N as r, _ as i, a, g as o, i as s } from "./comment-kit-ui-0vd-DY4S.js";
3
+ import * as c from "react";
4
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
5
+ function d(e) {
6
+ return new Promise((t, n) => {
7
+ let r = new Image(), i = setTimeout(() => n(/* @__PURE__ */ Error("Screenshot loading timed out. Try capturing it again.")), 15e3);
8
+ r.onload = () => {
9
+ clearTimeout(i), t(r);
10
+ }, r.onerror = () => {
11
+ clearTimeout(i), n(/* @__PURE__ */ Error("Could not load screenshot. Try capturing it again."));
12
+ }, r.src = e;
13
+ });
14
+ }
15
+ function f({ imageUrl: f, availableUsers: p = [], onSave: m, onCancel: h }) {
16
+ let g = t(), _ = c.useRef(null), v = c.useRef(null), y = c.useRef(0), [b, x] = c.useState(null), [S, C] = c.useState(() => ({
17
+ w: window.innerWidth,
18
+ h: window.innerHeight
19
+ }));
20
+ c.useEffect(() => {
21
+ let e = () => C({
22
+ w: window.innerWidth,
23
+ h: window.innerHeight
24
+ });
25
+ return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
26
+ }, []), c.useEffect(() => () => {
27
+ y.current += 1;
28
+ }, []);
29
+ let w = c.useCallback(() => {
30
+ y.current += 1, h();
31
+ }, [h]), T = S.w < 1024, E = Math.max(160, Math.min(S.w - (T ? 32 : 428), 800)), D = Math.max(160, T ? Math.min(S.h * .42, 520) : S.h - 160), O = b?.w ?? E, k = b?.h ?? D;
32
+ if (T) O = E, b && b.w > 0 && (k = E * b.h / b.w);
33
+ else {
34
+ let e = Math.min(E / O, D / k, 1);
35
+ O *= e, k *= e;
36
+ }
37
+ let A = b?.w ?? O, j = b?.h ?? k, M = g.paths.flatMap((e) => {
38
+ let t = a(e);
39
+ return t ? [t] : [];
40
+ }), N = g.activePath ? a(g.activePath) : null, P = (e) => {
41
+ let t = e.currentTarget.getBoundingClientRect();
42
+ return !t.width || !t.height ? null : {
43
+ x: (e.clientX - t.left) * A / t.width,
44
+ y: (e.clientY - t.top) * j / t.height
45
+ };
46
+ };
47
+ return e(g.undo, g.redo, w), /* @__PURE__ */ u("div", {
48
+ "data-commentkit-ui": "",
49
+ "data-slot": "comment-screenshot-annotator",
50
+ className: "ck-screenshot-annotator",
51
+ children: [/* @__PURE__ */ l("div", {
52
+ className: "ck-screenshot-annotator-layout",
53
+ children: /* @__PURE__ */ u("div", {
54
+ className: "ck-screenshot-annotator-stage",
55
+ children: [/* @__PURE__ */ u("div", {
56
+ className: "ck-screenshot-annotator-media",
57
+ children: [/* @__PURE__ */ l("div", {
58
+ className: "ck-screenshot-annotator-toolbar",
59
+ children: /* @__PURE__ */ l(n, {
60
+ colors: r,
61
+ drawing: g,
62
+ onCancel: w
63
+ })
64
+ }), /* @__PURE__ */ u("div", {
65
+ className: "ck-screenshot-annotator-canvas",
66
+ style: {
67
+ "--ck-w": `${O}px`,
68
+ "--ck-h": `${k}px`,
69
+ "--ck-frame": `${D}px`
70
+ },
71
+ children: [/* @__PURE__ */ l("img", {
72
+ src: f,
73
+ alt: "Screenshot",
74
+ className: "ck-screenshot-annotator-image",
75
+ draggable: !1,
76
+ onLoad: (e) => {
77
+ let t = e.currentTarget;
78
+ t.naturalWidth && t.naturalHeight && x({
79
+ w: t.naturalWidth,
80
+ h: t.naturalHeight
81
+ });
82
+ }
83
+ }), /* @__PURE__ */ u("svg", {
84
+ ref: _,
85
+ role: "application",
86
+ "aria-label": "Annotation canvas",
87
+ className: "ck-screenshot-annotator-strokes",
88
+ width: O,
89
+ height: k,
90
+ viewBox: `0 0 ${A} ${j}`,
91
+ onPointerDown: (e) => {
92
+ if (e.button !== 0 || v.current !== null) return;
93
+ let t = P(e);
94
+ if (t) {
95
+ v.current = e.pointerId;
96
+ try {
97
+ e.currentTarget.setPointerCapture(e.pointerId);
98
+ } catch {}
99
+ g.startPath(t.x, t.y, A / O);
100
+ }
101
+ },
102
+ onPointerMove: (e) => {
103
+ if (v.current !== e.pointerId) return;
104
+ let t = P(e);
105
+ t && g.addPoint(t.x, t.y);
106
+ },
107
+ onPointerUp: (e) => {
108
+ v.current === e.pointerId && (v.current = null, e.currentTarget.hasPointerCapture?.(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), g.endPath());
109
+ },
110
+ onPointerCancel: (e) => {
111
+ v.current === e.pointerId && (v.current = null, g.cancelPath());
112
+ },
113
+ children: [M.map((e, t) => /* @__PURE__ */ l(s, { path: e }, `${e.type}-${t}`)), N ? /* @__PURE__ */ l(s, { path: N }) : null]
114
+ })]
115
+ })]
116
+ }), /* @__PURE__ */ l("div", {
117
+ className: "ck-screenshot-annotator-composer",
118
+ children: /* @__PURE__ */ l(i, {
119
+ mode: "new-thread",
120
+ placeholder: "Describe what you see...",
121
+ availableUsers: p,
122
+ onSubmit: async (e, t) => {
123
+ let n = y.current, r = _.current;
124
+ if (!r || g.paths.length === 0) {
125
+ await m(f, e, t);
126
+ return;
127
+ }
128
+ let i = await d(f), a = document.createElement("canvas");
129
+ a.width = i.naturalWidth, a.height = i.naturalHeight;
130
+ let o = a.getContext("2d");
131
+ if (!o) throw Error("Screenshot annotation is unavailable in this browser.");
132
+ o.drawImage(i, 0, 0);
133
+ let s = r.cloneNode(!0);
134
+ s.setAttribute("xmlns", "http://www.w3.org/2000/svg"), s.setAttribute("width", String(a.width)), s.setAttribute("height", String(a.height));
135
+ let c = new XMLSerializer().serializeToString(s), l = URL.createObjectURL(new Blob([c], { type: "image/svg+xml;charset=utf-8" }));
136
+ try {
137
+ let r = await d(l);
138
+ if (n !== y.current) return;
139
+ o.drawImage(r, 0, 0, a.width, a.height), await m(a.toDataURL("image/png"), e, t);
140
+ } finally {
141
+ URL.revokeObjectURL(l);
142
+ }
143
+ },
144
+ onCancel: w
145
+ })
146
+ })]
147
+ })
148
+ }), /* @__PURE__ */ l(o, { mode: "draw" })]
149
+ });
150
+ }
151
+ export { f as CommentScreenshotAnnotator };
@@ -0,0 +1,207 @@
1
+ import { t as e } from "./button-By0hGrJK.js";
2
+ import { g as t, j as n, v as r } from "./comment-kit-ui-0vd-DY4S.js";
3
+ import { d as i, i as a } from "./annotation-icons-Dh-bmNYK.js";
4
+ import * as o from "react";
5
+ import { useCallback as s, useEffect as c, useRef as l, useState as u } from "react";
6
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
7
+ var m = ".ck-annotation-toolbar{background-color:var(--background);width:100%;max-width:100%;box-shadow:0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a, 0 0 0 1px color-mix(in oklch, var(--foreground) 5%, transparent);border-radius:2rem;flex-wrap:wrap;justify-content:center;align-items:center;gap:.375rem .5rem;margin-inline:auto;padding:.375rem;display:flex}@media (width>=1024px){.ck-annotation-toolbar{width:fit-content}}.ck-annotation-separator.ck-separator[data-orientation=vertical]{height:1rem;display:none}@media (width>=1024px){.ck-annotation-separator.ck-separator[data-orientation=vertical]{display:block}}.ck-annotation-stroke{align-items:center;gap:.5rem;width:7rem;padding-inline:.25rem;display:flex}@media (width>=1024px){.ck-annotation-stroke{width:12rem}}.ck-annotation-slider{flex:auto;min-width:0}.ck-annotation-stroke-label{color:var(--muted-foreground);font-variant-numeric:tabular-nums;flex-shrink:0;font-size:.75rem;line-height:1rem}.ck-annotation-swatch{background-color:var(--ck-bg);width:.875rem;height:.875rem;box-shadow:0 0 0 1px color-mix(in oklch, var(--foreground) 5%, transparent);border-radius:999px}.ck-annotation-tooltip{align-items:center;gap:.375rem;display:inline-flex}.ck-annotation-save--disabled{opacity:.5}.ck-screenshot-overlay{z-index:var(--z-ck-overlay);cursor:none;pointer-events:auto;touch-action:none;outline:none;position:fixed;inset:0}.ck-screenshot-selection{pointer-events:none;inset-inline-start:var(--ck-x);top:var(--ck-y);width:var(--ck-w);height:var(--ck-h);box-shadow:0 0 0 2px var(--primary);background:color-mix(in oklch, var(--primary) 10%, transparent);position:fixed}.ck-screenshot-overlay-bar{inset-inline-start:50%;z-index:10;background:var(--background);max-width:calc(100vw - 1.5rem);color:var(--foreground);box-shadow:var(--shadow-lg), 0 0 0 1px color-mix(in oklch, var(--foreground) 5%, transparent);cursor:auto;border-radius:2rem;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.875rem;line-height:1.25rem;display:flex;position:fixed;top:1rem;transform:translate(-50%)}.ck-screenshot-overlay-bar>svg{flex-shrink:0;width:1rem;height:1rem}.ck-screenshot-overlay-bar>button{margin-inline-start:.25rem}.ck-screenshot-overlay-error{border-radius:var(--radius-md);background:var(--background);width:max-content;max-width:calc(100vw - 1.5rem);color:var(--destructive);margin:.75rem auto;padding:.75rem;font-size:.875rem;position:absolute;top:5rem;left:50%;transform:translate(-50%)}.ck-screenshot-overlay-bar>span,.ck-screenshot-overlay-bar>svg{color:var(--muted-foreground)}@media (width<=767px){.ck-screenshot-overlay-bar{width:max-content}}.ck-screenshot-annotator{z-index:var(--z-ck-overlay);pointer-events:auto;background:#0000004d;position:fixed;inset:0;overflow-y:auto}@supports ((-webkit-backdrop-filter:blur(4px)) or (backdrop-filter:blur(4px))){.ck-screenshot-annotator{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}}.ck-screenshot-annotator-layout{justify-content:center;align-items:flex-start;width:100%;min-height:100%;padding:.75rem;display:flex}.ck-screenshot-annotator-stage{flex-direction:column;align-items:stretch;gap:.75rem;width:100%;max-width:100%;display:flex}.ck-screenshot-annotator-media{flex-direction:column;align-items:center;gap:.75rem;width:100%;min-width:0;display:flex}.ck-screenshot-annotator-toolbar{width:100%;min-width:0}.ck-screenshot-annotator-canvas{width:100%;max-width:100%;max-height:var(--ck-frame);box-shadow:var(--shadow-xl), 0 0 0 1px color-mix(in oklch, var(--foreground) 5%, transparent);position:relative;overflow:auto}.ck-screenshot-annotator-image{width:var(--ck-w);height:var(--ck-h);-webkit-user-select:none;user-select:none;max-width:none;display:block}.ck-screenshot-annotator-strokes{cursor:none;touch-action:none;position:absolute;inset:0}.ck-screenshot-annotator-composer{flex-direction:column;width:100%;min-width:0;display:flex}@media (width>=1024px){.ck-screenshot-annotator-layout{align-items:center;padding:1rem}.ck-screenshot-annotator-stage{flex-direction:row;align-items:flex-start;gap:1.5rem;width:auto}.ck-screenshot-annotator-media{width:auto}.ck-screenshot-annotator-canvas{width:var(--ck-w);height:var(--ck-h);max-height:none;overflow:hidden}.ck-screenshot-annotator-composer{flex-shrink:0;width:380px}}", h = 15e3, g = 32e6;
8
+ async function _(e, t, n) {
9
+ let r = e.dimensions.width / n.width, i = e.dimensions.height / n.height, a = new Image(), o = new Promise((e, t) => {
10
+ a.onload = () => e(), a.onerror = () => t(/* @__PURE__ */ Error("Could not load captured screenshot"));
11
+ });
12
+ a.src = e.dataUrl, await o;
13
+ let s = document.createElement("canvas");
14
+ if (s.width = Math.max(1, Math.round(t.width * r)), s.height = Math.max(1, Math.round(t.height * i)), s.width > 16384 || s.height > 16384 || s.width * s.height > g) throw Error("Selected area is too large to capture");
15
+ let c = s.getContext("2d");
16
+ if (!c) throw Error("Screenshot cropping is unavailable in this browser");
17
+ return c.drawImage(a, (t.x + n.scrollX) * r, (t.y + n.scrollY) * i, s.width, s.height, 0, 0, s.width, s.height), s.toDataURL("image/png");
18
+ }
19
+ function v(e) {
20
+ try {
21
+ return e.matches?.("[data-commentkit],[data-commentkit-host],[data-commentkit-ui],[data-commentkit-panel],input[type=\"password\"],[data-commentkit-redact],[data-html2canvas-ignore]") ?? !1;
22
+ } catch {
23
+ return !1;
24
+ }
25
+ }
26
+ function y(e) {
27
+ let [t, n] = u(null), [r, i] = u(!1), [a, o] = u(null), d = l(0), f = l(!1), p = l(void 0);
28
+ return c(() => () => {
29
+ d.current += 1, clearTimeout(p.current);
30
+ }, []), {
31
+ imageUrl: t,
32
+ capturing: r,
33
+ error: a,
34
+ capture: s(async (t) => {
35
+ if (f.current) return;
36
+ f.current = !0;
37
+ let r = ++d.current;
38
+ i(!0), o(null);
39
+ try {
40
+ let i = await Promise.race([(async () => {
41
+ let n = {
42
+ width: Math.max(document.documentElement.scrollWidth, document.body?.scrollWidth ?? 0, window.innerWidth),
43
+ height: Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight ?? 0, window.innerHeight),
44
+ scrollX: window.scrollX,
45
+ scrollY: window.scrollY
46
+ };
47
+ if (e) {
48
+ let r = await e();
49
+ if (!r) throw Error("Screenshot provider could not capture this page");
50
+ return t ? _(r, t, n) : r.dataUrl;
51
+ }
52
+ let i;
53
+ try {
54
+ i = (await import("html2canvas")).default;
55
+ } catch {
56
+ throw Error("Screenshot requires either a custom screenshotProvider in config or html2canvas installed. Install html2canvas: npm install html2canvas — or provide config.screenshotProvider.");
57
+ }
58
+ if (r !== d.current) return null;
59
+ let a = n.width, o = n.height, s = t?.width ?? a, c = t?.height ?? o;
60
+ if (s > 16384 || c > 16384 || s * c > g) throw Error("Selected area is too large to capture");
61
+ return (await i(document.body, {
62
+ useCORS: !0,
63
+ allowTaint: !1,
64
+ scale: 1,
65
+ logging: !1,
66
+ ignoreElements: v,
67
+ onclone: (e) => import("./capture-colors-CxSLsU5-.js").then(({ normalizeCaptureColors: t }) => t(e)),
68
+ x: t ? t.x + n.scrollX : 0,
69
+ y: t ? t.y + n.scrollY : 0,
70
+ width: t?.width ?? a,
71
+ height: t?.height ?? o,
72
+ windowWidth: a,
73
+ windowHeight: o,
74
+ scrollX: 0,
75
+ scrollY: 0
76
+ })).toDataURL("image/png");
77
+ })(), new Promise((e, t) => {
78
+ p.current = setTimeout(() => t(/* @__PURE__ */ Error("Screenshot timed out")), h);
79
+ })]);
80
+ r === d.current && i && n(i);
81
+ } catch (e) {
82
+ if (r !== d.current) return;
83
+ console.error("[CommentKit] Screenshot failed:", e), n(null), o("Could not capture the page. Try again, or cancel to return to the page.");
84
+ } finally {
85
+ r === d.current && (clearTimeout(p.current), p.current = void 0, f.current = !1, i(!1));
86
+ }
87
+ }, [e]),
88
+ reset: s(() => {
89
+ d.current += 1, clearTimeout(p.current), p.current = void 0, f.current = !1, i(!1), n(null), o(null);
90
+ }, [])
91
+ };
92
+ }
93
+ var b = () => import("./comment-screenshot-annotator-DcaSSuWB.js");
94
+ function x({ capturePage: s, availableUsers: c = [], onSave: l, onCancel: u }) {
95
+ let { imageUrl: d, capturing: m, error: h, capture: g, reset: _ } = y(s), v = o.useRef(null), [x, S] = o.useState(null), [C, w] = o.useState(null), T = x !== null, E = o.useMemo(() => !x || !C ? null : {
96
+ x: Math.min(x.x, C.x),
97
+ y: Math.min(x.y, C.y),
98
+ width: Math.abs(C.x - x.x),
99
+ height: Math.abs(C.y - x.y)
100
+ }, [C, x]), D = o.useCallback(() => {
101
+ g();
102
+ }, [g]), O = (e) => {
103
+ if (!(e.button !== 0 || d || m) && v.current === null) {
104
+ v.current = e.pointerId;
105
+ try {
106
+ e.currentTarget.setPointerCapture(e.pointerId);
107
+ } catch {}
108
+ S({
109
+ x: e.clientX,
110
+ y: e.clientY
111
+ }), w({
112
+ x: e.clientX,
113
+ y: e.clientY
114
+ });
115
+ }
116
+ }, k = (e) => {
117
+ T && !d && v.current === e.pointerId && w({
118
+ x: e.clientX,
119
+ y: e.clientY
120
+ });
121
+ }, A = (e) => {
122
+ if (v.current !== e.pointerId) return;
123
+ if (v.current = null, e.currentTarget.hasPointerCapture?.(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), !T || !E || d) {
124
+ S(null), w(null);
125
+ return;
126
+ }
127
+ let t = E.width >= 20 && E.height >= 20 ? E : void 0;
128
+ S(null), w(null), g(t);
129
+ }, j = (e) => {
130
+ d || m || e.target !== e.currentTarget || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), D());
131
+ }, M = o.useCallback(() => {
132
+ _(), u();
133
+ }, [_, u]);
134
+ return o.useEffect(() => {
135
+ if (d) return;
136
+ let e = (e) => {
137
+ e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(), M());
138
+ };
139
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
140
+ }, [d, M]), d ? /* @__PURE__ */ f(n, {
141
+ load: b,
142
+ label: "screenshot editor",
143
+ onCancel: M,
144
+ children: ({ CommentScreenshotAnnotator: e }) => /* @__PURE__ */ f(e, {
145
+ imageUrl: d,
146
+ availableUsers: c,
147
+ onSave: l,
148
+ onCancel: M
149
+ })
150
+ }) : /* @__PURE__ */ p("div", {
151
+ role: "button",
152
+ tabIndex: 0,
153
+ "data-commentkit-ui": "",
154
+ "data-slot": "comment-screenshot-overlay",
155
+ className: "ck-screenshot-overlay",
156
+ "aria-label": "Drag to select a region, or press Enter for the full page",
157
+ onPointerDown: O,
158
+ onPointerMove: k,
159
+ onPointerUp: A,
160
+ onPointerCancel: () => {
161
+ v.current = null, S(null), w(null);
162
+ },
163
+ onKeyDown: j,
164
+ children: [
165
+ E && E.width > 5 && E.height > 5 ? /* @__PURE__ */ f("div", {
166
+ className: "ck-screenshot-selection",
167
+ style: {
168
+ "--ck-x": `${E.x}px`,
169
+ "--ck-y": `${E.y}px`,
170
+ "--ck-w": `${E.width}px`,
171
+ "--ck-h": `${E.height}px`
172
+ }
173
+ }) : null,
174
+ /* @__PURE__ */ p("div", {
175
+ className: "ck-screenshot-overlay-bar",
176
+ onPointerDown: (e) => e.stopPropagation(),
177
+ children: [
178
+ f(m ? r : a, {}),
179
+ /* @__PURE__ */ f("span", { children: m ? "Capturing…" : "Drag to select region, or click for full page" }),
180
+ /* @__PURE__ */ f(e, {
181
+ type: "button",
182
+ variant: "ghost",
183
+ size: "icon-sm",
184
+ "aria-label": "Cancel screenshot",
185
+ onClick: (e) => {
186
+ e.stopPropagation(), M();
187
+ },
188
+ children: /* @__PURE__ */ f(i, {})
189
+ })
190
+ ]
191
+ }),
192
+ h ? /* @__PURE__ */ f("p", {
193
+ role: "alert",
194
+ className: "ck-screenshot-overlay-error",
195
+ children: h
196
+ }) : null,
197
+ /* @__PURE__ */ f(t, { mode: "screenshot" })
198
+ ]
199
+ });
200
+ }
201
+ function S(e) {
202
+ return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("style", {
203
+ "data-ck-tool-styles": "screenshot",
204
+ children: m
205
+ }), /* @__PURE__ */ f(x, { ...e })] });
206
+ }
207
+ export { S as CommentScreenshotOverlay };
@@ -1,7 +1,7 @@
1
1
  import { t as e } from "./button-By0hGrJK.js";
2
- import { i as t, o as n, r, t as i } from "./separator-DusFNTs-.js";
2
+ import { i as t, o as n, r, t as i } from "./separator-XDBsaWyw.js";
3
3
  import { t as a } from "./createReactComponent-BZHeRbD0.js";
4
- import { a as o, d as s, m as c, v as l, y as u } from "./comment-kit-ui-D2j2gvnm.js";
4
+ import { C as o, H as s, U as c, W as l, u } from "./comment-kit-ui-0vd-DY4S.js";
5
5
  import * as d from "react";
6
6
  import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
7
7
  var h = a("outline", "refresh", "Refresh", [["path", {
@@ -48,7 +48,7 @@ var y = 2500, b = ({ core: a, state: f }) => {
48
48
  className: "ck-dev-export-header",
49
49
  children: [/* @__PURE__ */ m("div", {
50
50
  className: "ck-dev-export-title",
51
- children: [/* @__PURE__ */ p(l, {
51
+ children: [/* @__PURE__ */ p(s, {
52
52
  size: 16,
53
53
  "aria-hidden": !0
54
54
  }), /* @__PURE__ */ p("strong", { children: "Dev export" })]
@@ -61,7 +61,7 @@ var y = 2500, b = ({ core: a, state: f }) => {
61
61
  /* @__PURE__ */ m("div", {
62
62
  className: "ck-dev-export-toolbar",
63
63
  children: [
64
- /* @__PURE__ */ p(s, {
64
+ /* @__PURE__ */ p(o, {
65
65
  checked: A,
66
66
  indeterminate: j,
67
67
  onCheckedChange: () => {
@@ -124,7 +124,7 @@ var y = 2500, b = ({ core: a, state: f }) => {
124
124
  }
125
125
  },
126
126
  disabled: M || x,
127
- children: [/* @__PURE__ */ p(u, {
127
+ children: [/* @__PURE__ */ p(c, {
128
128
  size: 14,
129
129
  "aria-hidden": !0
130
130
  }), x ? "Copying…" : `Copy ${g.size || ""} for agent`.trim()]
@@ -143,9 +143,9 @@ var y = 2500, b = ({ core: a, state: f }) => {
143
143
  " open comments."
144
144
  ]
145
145
  }),
146
- /* @__PURE__ */ p(o, {
146
+ /* @__PURE__ */ p(u, {
147
147
  className: "ck-dev-export-scroll",
148
- children: O.length === 0 ? /* @__PURE__ */ p(c, {
148
+ children: O.length === 0 ? /* @__PURE__ */ p(l, {
149
149
  className: "ck-dev-export-empty",
150
150
  children: "No open stakeholder comments on this project. Comments left in production or staging will show up here for bulk export."
151
151
  }) : /* @__PURE__ */ p("ul", {
@@ -155,7 +155,7 @@ var y = 2500, b = ({ core: a, state: f }) => {
155
155
  return /* @__PURE__ */ m("li", {
156
156
  className: "ck-dev-export-row",
157
157
  "data-checked": t,
158
- children: [/* @__PURE__ */ p(s, {
158
+ children: [/* @__PURE__ */ p(o, {
159
159
  checked: t,
160
160
  onCheckedChange: () => N(e.id),
161
161
  "aria-label": `Select ${e.title}`
@@ -0,0 +1,210 @@
1
+ import { c as e, f as t, l as n, m as r, p as i, r as a } from "./comment-kit-core-C862uNAm.js";
2
+ import { a as o, i as s, o as c } from "./dom-Bhf4WFtY.js";
3
+ var l = 4e3, u = 500, d = 2e3, f = 1e3, p = 5, m = 25, h = 3145728;
4
+ function g(e) {
5
+ let t = r(e?.comment, d);
6
+ return t.length > 0 ? t : null;
7
+ }
8
+ function _(e) {
9
+ return (e?.attachments ?? []).slice(0, p).flatMap((e) => {
10
+ let t = r(e.name, f), n = r(e.path, f);
11
+ return !t || !n ? [] : [{
12
+ name: t,
13
+ path: n,
14
+ ...e.pathSource ? { pathSource: e.pathSource } : {},
15
+ ...e.type ? { type: r(e.type, f) } : {},
16
+ ...typeof e.size == "number" ? { size: e.size } : {},
17
+ ...typeof e.lastModified == "number" ? { lastModified: e.lastModified } : {}
18
+ }];
19
+ });
20
+ }
21
+ function v(e) {
22
+ return typeof HTMLElement < "u" && e instanceof HTMLElement;
23
+ }
24
+ function y(e, t, n, i) {
25
+ let a = e.getBoundingClientRect(), c = s(e), d = o(e), f = e.getAttribute("class"), p = e.getAttribute("role"), m = e.getAttribute("aria-label"), h = r(e.textContent, u), g = r(e.outerHTML, l);
26
+ return {
27
+ found: !0,
28
+ tagName: e.tagName.toLowerCase(),
29
+ ...e.id ? { id: e.id } : {},
30
+ ...f ? { className: f } : {},
31
+ ...p ? { role: p } : {},
32
+ ...m ? { ariaLabel: m } : {},
33
+ ...h ? { text: h } : {},
34
+ rect: {
35
+ top: a.top,
36
+ left: a.left,
37
+ width: a.width,
38
+ height: a.height
39
+ },
40
+ ...g ? { htmlPreview: g } : {},
41
+ ...c ? { selector: c } : {},
42
+ ...d ? { xpath: d } : {},
43
+ ...t ? {
44
+ source: b(t),
45
+ stack: n.map(b)
46
+ } : {},
47
+ ...i ? { componentName: i } : {}
48
+ };
49
+ }
50
+ function b(e) {
51
+ return {
52
+ filePath: e.filePath,
53
+ lineNumber: e.lineNumber,
54
+ columnNumber: e.columnNumber,
55
+ componentName: e.componentName
56
+ };
57
+ }
58
+ function x(e) {
59
+ let t = `${r(e.filePath, 2e3)}${e.lineNumber === null ? "" : `:${e.lineNumber}`}${e.columnNumber === null ? "" : `:${e.columnNumber}`}`;
60
+ return e.componentName ? `${r(e.componentName, 300)} (${t})` : t;
61
+ }
62
+ function S(e, t, n, a, o, s) {
63
+ let c = [
64
+ "# CommentKit Element Grab",
65
+ "",
66
+ i,
67
+ ""
68
+ ], l = r(t.tagName ?? "element", 100), u = t.id ? `#${r(t.id, 300)}` : "";
69
+ if (c.push(`**Tag:** \`${l}${u}\``), o && c.push(`**Comment:** ${o}`), s.length > 0) {
70
+ c.push("", "**Attachments:**");
71
+ for (let e of s) {
72
+ let t = [
73
+ e.type ? `type: \`${e.type}\`` : null,
74
+ typeof e.size == "number" ? `size: ${e.size} bytes` : null,
75
+ e.pathSource ? `path source: ${e.pathSource}` : null
76
+ ].filter(Boolean).join(", ");
77
+ c.push(`- \`${e.name}\` - path: \`${e.path}\`${t ? ` (${t})` : ""}`);
78
+ }
79
+ }
80
+ if (t.componentName && c.push(`**Component:** \`${r(t.componentName, 300)}\``), t.source && c.push(`**Source:** ${x(t.source)}`), t.stack && t.stack.length > 1) {
81
+ c.push("", "**Stack:**");
82
+ for (let e of t.stack) c.push(`- ${x(e)}`);
83
+ }
84
+ return t.source || (t.selector && c.push(`**Selector:** \`${r(t.selector, 2e3)}\``), t.xpath && c.push(`**XPath:** \`${r(t.xpath, 2e3)}\``)), c.push(`**Page:** ${r(e.title || "Untitled", 300)} — ${r(e.url || e.path, 4e3)}`), c.push(""), c.push("**HTML:**", "```html", n, "```", ""), a && c.push("**Screenshot:** captured. If no image accompanies this paste, attach it from the export preview.", ""), c.join("\n");
85
+ }
86
+ function C(e) {
87
+ let t = e.element;
88
+ return {
89
+ tagName: t.tagName,
90
+ id: t.id,
91
+ className: t.className,
92
+ textContent: t.text,
93
+ componentName: t.componentName,
94
+ filePath: t.source?.filePath,
95
+ lineNumber: t.source?.lineNumber ?? void 0,
96
+ columnNumber: t.source?.columnNumber ?? void 0,
97
+ comment: e.comment ?? void 0,
98
+ attachments: e.attachments,
99
+ selector: t.selector,
100
+ xpath: t.xpath
101
+ };
102
+ }
103
+ function w(e) {
104
+ if (typeof window > "u" || typeof window.dispatchEvent != "function") return;
105
+ let t = e[0];
106
+ t && window.dispatchEvent(new CustomEvent("commentkit:element-selected", { detail: {
107
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
108
+ page: t.page,
109
+ elements: e.map(C)
110
+ } }));
111
+ }
112
+ async function T(i, o, s, u) {
113
+ if (!i || typeof Element > "u" || !(i instanceof Element) || typeof i.getBoundingClientRect != "function") return null;
114
+ let d = (v(i), i), f = await t(i), p = f?.source ?? null, m = f?.stack ?? [], h = f?.componentName ?? null, b = await a(o, s, d, { reportErrors: !1 }), x = b?.dataUrl ?? null, C = b?.blob ?? null, T = y(i, p, m, h), E = T.htmlPreview ?? r(i.outerHTML, l), D = c(), O = g(u), k = _(u), A = S({
115
+ url: D.url,
116
+ path: D.path,
117
+ title: D.title
118
+ }, T, E, x, O, k);
119
+ try {
120
+ C ? await e(A, C) : await n(A);
121
+ } catch {}
122
+ let j = {
123
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
124
+ page: {
125
+ url: D.url,
126
+ path: D.path,
127
+ title: D.title
128
+ },
129
+ element: T,
130
+ comment: O,
131
+ attachments: k,
132
+ html: E,
133
+ screenshotDataUrl: x,
134
+ markdown: A
135
+ };
136
+ return w([j]), j;
137
+ }
138
+ function E(e, t, n, a) {
139
+ let o = [
140
+ "# CommentKit Element Grab",
141
+ "",
142
+ i,
143
+ "",
144
+ `**Elements:** ${t.length}`,
145
+ `**Page:** ${r(e.title || "Untitled", 300)} — ${r(e.url || e.path, 4e3)}`
146
+ ];
147
+ if (n && o.push(`**Comment:** ${n}`), a.length > 0) {
148
+ o.push("", "**Attachments:**");
149
+ for (let e of a) o.push(`- \`${e.name}\` - path: \`${e.path}\`${e.pathSource ? ` (path source: ${e.pathSource})` : ""}`);
150
+ }
151
+ return o.push(""), t.forEach((e, t) => {
152
+ let { element: n } = e, i = r(n.tagName ?? "element", 100), a = n.id ? `#${r(n.id, 300)}` : "";
153
+ o.push(`## [${t + 1}] \`${i}${a}\``), n.componentName && o.push(`- Component: \`${r(n.componentName, 300)}\``), n.source && o.push(`- Source: ${x(n.source)}`), n.stack && n.stack.length > 1 && o.push(`- Stack: ${n.stack.map((e) => r(e.componentName ?? e.filePath, 2e3)).join(" → ")}`), n.source || (n.selector && o.push(`- Selector: \`${r(n.selector, 2e3)}\``), n.xpath && o.push(`- XPath: \`${r(n.xpath, 2e3)}\``)), o.push("", "```html", e.html, "```", ""), e.screenshotDataUrl && o.push(`![screenshot](${e.screenshotDataUrl})`, "");
154
+ }), o.join("\n");
155
+ }
156
+ async function D(e, i, o, s) {
157
+ let u = e.filter((e) => !!e && typeof Element < "u" && e instanceof Element && typeof e.getBoundingClientRect == "function");
158
+ if (u.length === 0) return null;
159
+ let d = u.slice(0, m);
160
+ u.length > m && typeof console < "u" && console.warn(`[CommentKit] grabElements was called with ${u.length} elements — capped to ${m} for clipboard size. Pass fewer elements to avoid truncation.`);
161
+ let f = [], p = 0, b = 0, x = g(s), C = _(s);
162
+ for (let e of d) {
163
+ let n = (v(e), e), s = await t(e), u = s?.source ?? null, d = s?.stack ?? [], m = s?.componentName ?? null, g = null;
164
+ if (p < h) {
165
+ let e = (await a(i, o, n, { reportErrors: !1 }))?.dataUrl ?? null;
166
+ e && p + e.length <= h ? (g = e, p += e.length) : e && b++;
167
+ } else b++;
168
+ let _ = y(e, u, d, m), w = _.htmlPreview ?? r(e.outerHTML, l), T = c(), E = S({
169
+ url: T.url,
170
+ path: T.path,
171
+ title: T.title
172
+ }, _, w, g, x, C);
173
+ f.push({
174
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
175
+ page: {
176
+ url: T.url,
177
+ path: T.path,
178
+ title: T.title
179
+ },
180
+ element: _,
181
+ comment: x,
182
+ attachments: C,
183
+ html: w,
184
+ screenshotDataUrl: g,
185
+ markdown: E
186
+ });
187
+ }
188
+ b > 0 && typeof console < "u" && console.warn(`[CommentKit] grabElements dropped ${b} screenshot${b === 1 ? "" : "s"} to stay under the ${Math.round(h / 1024 / 1024)}MB clipboard budget.`);
189
+ let T = c(), D = E({
190
+ url: T.url,
191
+ path: T.path,
192
+ title: T.title
193
+ }, f, x, C);
194
+ try {
195
+ await n(D);
196
+ } catch {}
197
+ let O = {
198
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
199
+ page: {
200
+ url: T.url,
201
+ path: T.path,
202
+ title: T.title
203
+ },
204
+ results: f,
205
+ attachments: C,
206
+ markdown: D
207
+ };
208
+ return w(f), O;
209
+ }
210
+ export { T as grabElement, D as grabElements };