@commentkit/comment-kit 0.7.7 → 1.0.0-beta.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 (129) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +172 -732
  3. package/SECURITY.md +24 -14
  4. package/dist/npm/THIRD_PARTY_NOTICES.txt +73 -0
  5. package/dist/npm/chunks/Guest-CKoV6pEK.js +157 -0
  6. package/dist/npm/chunks/MarkupEditor-DAo4qppg.js +199 -0
  7. package/dist/npm/chunks/Panel-BRBDHlGg.js +399 -0
  8. package/dist/npm/chunks/Shortcuts-CHMcrjAM.js +56 -0
  9. package/dist/npm/chunks/ThreadCard-D8FzIxbs.js +570 -0
  10. package/dist/npm/chunks/anchor-DT-Ynhh1.js +270 -0
  11. package/dist/npm/chunks/ar-D3SPpN1T.js +195 -0
  12. package/dist/npm/chunks/client-D1NizpDK.js +627 -0
  13. package/dist/{shared/capture-colors-D0uLr-vZ.js → npm/chunks/colors-CX-IPjvb.js} +2 -0
  14. package/dist/npm/chunks/de-C8eC6c6f.js +187 -0
  15. package/dist/npm/chunks/es-Bczf42tm.js +187 -0
  16. package/dist/npm/chunks/extension--it1LAj-.js +54 -0
  17. package/dist/npm/chunks/extension-XfuRGu2o.js +26 -0
  18. package/dist/npm/chunks/format-Bw_tNOh9.js +524 -0
  19. package/dist/npm/chunks/fr-BaQw-v2e.js +187 -0
  20. package/dist/npm/chunks/hi-BamV-yXv.js +187 -0
  21. package/dist/npm/chunks/html2canvas-DfGb8yka.js +4024 -0
  22. package/dist/npm/chunks/it-DC14_EjN.js +187 -0
  23. package/dist/npm/chunks/ja-B1mmTN7Y.js +187 -0
  24. package/dist/npm/chunks/mount-5fFig0k6.js +1447 -0
  25. package/dist/npm/chunks/nl-BfhqUsmX.js +187 -0
  26. package/dist/npm/chunks/privacy-DLhezjyi.js +30 -0
  27. package/dist/npm/chunks/pt-BR-CEPu4W5U.js +187 -0
  28. package/dist/{shared/pusher-CnhQgAvF.js → npm/chunks/pusher-BSsQoE1K.js} +224 -222
  29. package/dist/npm/chunks/realtime-CBRW9BB3.js +34 -0
  30. package/dist/npm/chunks/report-Dh4fxd4J.js +27 -0
  31. package/dist/npm/chunks/rolldown-runtime-Y_bBpyJl.js +20 -0
  32. package/dist/npm/chunks/src-DujplxfI.js +517 -0
  33. package/dist/npm/chunks/zh-CN-kgqjYwHQ.js +187 -0
  34. package/dist/npm/element.js +41 -0
  35. package/dist/npm/headless.js +3 -0
  36. package/dist/npm/index.js +3 -0
  37. package/dist/npm/react.js +26 -0
  38. package/dist/npm/svelte.js +17 -0
  39. package/dist/npm/types/adapters/react.d.ts +11 -0
  40. package/dist/npm/types/adapters/svelte.d.ts +9 -0
  41. package/dist/npm/types/adapters/vue.d.ts +118 -0
  42. package/dist/npm/types/anchor/index.d.ts +49 -0
  43. package/dist/npm/types/core/api.d.ts +31 -0
  44. package/dist/npm/types/core/auth.d.ts +87 -0
  45. package/dist/npm/types/core/client.d.ts +114 -0
  46. package/dist/npm/types/core/store.d.ts +7 -0
  47. package/dist/npm/types/core/types.d.ts +303 -0
  48. package/dist/npm/types/element.d.ts +13 -0
  49. package/dist/npm/types/headless.d.ts +7 -0
  50. package/dist/npm/types/index.d.ts +32 -0
  51. package/dist/npm/vue.js +71 -0
  52. package/package.json +71 -173
  53. package/dist/THIRD_PARTY_NOTICES.txt +0 -284
  54. package/dist/angular.es.js +0 -321
  55. package/dist/comment-kit.es.js +0 -218
  56. package/dist/demo.es.js +0 -483
  57. package/dist/headless.es.js +0 -4
  58. package/dist/preact.es.js +0 -117
  59. package/dist/qwik.es.js +0 -1
  60. package/dist/qwik.qwik.mjs +0 -114
  61. package/dist/react.es.js +0 -98
  62. package/dist/shared/ShadowRootContext-DD6a0QaI.js +0 -11
  63. package/dist/shared/annotation-icons-Dh-bmNYK.js +0 -172
  64. package/dist/shared/annotation-toolbar-zeiCmKIr.js +0 -1086
  65. package/dist/shared/attachment-refresh-DAacLaRu.js +0 -94
  66. package/dist/shared/bridge-CJoGYngu.js +0 -177
  67. package/dist/shared/button-D4GHW6oZ.js +0 -474
  68. package/dist/shared/button-group-BVR7iT-S.js +0 -91
  69. package/dist/shared/capture-privacy-CiOrcAlt.js +0 -101
  70. package/dist/shared/comment-drawing-canvas-Btc12IsS.js +0 -124
  71. package/dist/shared/comment-icon-D8JTCEJ7.js +0 -607
  72. package/dist/shared/comment-image-lightbox--QpbcAtH.js +0 -190
  73. package/dist/shared/comment-images-content-C_r4SHM-.js +0 -214
  74. package/dist/shared/comment-kit-core-CmLUFujd.js +0 -3682
  75. package/dist/shared/comment-kit-ui-BHwYuSIi.js +0 -19391
  76. package/dist/shared/comment-screenshot-annotator-zJZyO-XM.js +0 -151
  77. package/dist/shared/comment-screenshot-overlay-CoKTYB0J.js +0 -205
  78. package/dist/shared/comment-shortcut-groups-CfEmkitU.js +0 -153
  79. package/dist/shared/createReactComponent-BZHeRbD0.js +0 -45
  80. package/dist/shared/dev-export-panel-Cnt6oCZU.js +0 -207
  81. package/dist/shared/dev-grab-B85jo9AS.js +0 -197
  82. package/dist/shared/dist-D9A5k-N4.js +0 -617
  83. package/dist/shared/dom-Bhf4WFtY.js +0 -223
  84. package/dist/shared/element-selector-Cng84xC7.js +0 -902
  85. package/dist/shared/error-boundary-D3PD74vI.js +0 -21
  86. package/dist/shared/errors-Bu5ajEmB.js +0 -22
  87. package/dist/shared/icons-nzMOLzrm.js +0 -266
  88. package/dist/shared/input-UPtAj0M6.js +0 -111
  89. package/dist/shared/mount-ui-Dz7FB_Ak.js +0 -208
  90. package/dist/shared/realtime-recovery-BjlV-ewc.js +0 -162
  91. package/dist/shared/realtime-yGLX4wMK.js +0 -334
  92. package/dist/shared/request-activity-DQrAUwfA.js +0 -11
  93. package/dist/shared/screenshot-B5-hwpmt.js +0 -199
  94. package/dist/shared/separator-UhJb0Row.js +0 -3955
  95. package/dist/shared/shadow-root-B58ZI2yz.js +0 -133
  96. package/dist/shared/styles-CnYsLS2f.js +0 -2
  97. package/dist/shared/text-B4HHZNaa.js +0 -23
  98. package/dist/shared/token-session-D92MYbNu.js +0 -25
  99. package/dist/shared/useLabelableId-8n0QmH8N.js +0 -154
  100. package/dist/shared/useRender-Uxk1OPK-.js +0 -5
  101. package/dist/shared/useValueChanged-DKq5cMot.js +0 -92
  102. package/dist/shared/validation-3wbbbuX0.js +0 -70
  103. package/dist/shared/websocket-manager-KhH4hL0Q.js +0 -381
  104. package/dist/solid.es.js +0 -98
  105. package/dist/svelte.es.js +0 -130
  106. package/dist/types/adapters/bridge.d.ts +0 -122
  107. package/dist/types/angular/index.d.ts +0 -145
  108. package/dist/types/core/agent-context.d.ts +0 -17
  109. package/dist/types/core/api-client.d.ts +0 -155
  110. package/dist/types/core/comment-kit-core.d.ts +0 -254
  111. package/dist/types/core/local-demo.d.ts +0 -60
  112. package/dist/types/core/types.d.ts +0 -770
  113. package/dist/types/core/websocket-manager.d.ts +0 -125
  114. package/dist/types/core/write-access.d.ts +0 -11
  115. package/dist/types/demo.d.ts +0 -17
  116. package/dist/types/headless.d.ts +0 -8
  117. package/dist/types/index.d.ts +0 -87
  118. package/dist/types/preact/index.d.ts +0 -25
  119. package/dist/types/qwik/index.d.ts +0 -73
  120. package/dist/types/react/client.d.ts +0 -31
  121. package/dist/types/react/index.d.ts +0 -4
  122. package/dist/types/solid/index.d.ts +0 -37
  123. package/dist/types/svelte/index.d.ts +0 -55
  124. package/dist/types/utils/dom.d.ts +0 -59
  125. package/dist/types/utils/event-emitter.d.ts +0 -11
  126. package/dist/types/vue/index.d.ts +0 -87
  127. package/dist/vue.es.js +0 -148
  128. package/docs/api-reference.md +0 -405
  129. package/docs/local-demo.md +0 -60
@@ -1,190 +0,0 @@
1
- import { n as e } from "./dist-D9A5k-N4.js";
2
- import { o as t, t as n } from "./button-D4GHW6oZ.js";
3
- import { i as r, o as i, r as a } from "./separator-UhJb0Row.js";
4
- import { t as o } from "./comment-icon-D8JTCEJ7.js";
5
- import { t as s } from "./button-group-BVR7iT-S.js";
6
- import { c, h as l, m as u, p as d } from "./comment-kit-ui-BHwYuSIi.js";
7
- import { r as f, t as p } from "./attachment-refresh-DAacLaRu.js";
8
- import * as m from "react";
9
- import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
10
- var v = ".ck-dialog-content.ck-image-lightbox{width:100vw;max-width:none;height:100dvh;max-height:none;box-shadow:none;background-color:#0000;border:0;border-radius:0;justify-content:center;align-items:center;gap:0;padding:0;display:flex;inset:0;translate:none}@media (width>=640px){.ck-dialog-content.ck-image-lightbox{max-width:none}}.ck-root[data-theme=dark] .ck-dialog-content.ck-image-lightbox{box-shadow:none}.ck-image-lightbox-prev,.ck-image-lightbox-next{position:absolute}.ck-image-lightbox-prev{inset-inline-start:1rem}.ck-image-lightbox-next{inset-inline-end:1rem}.ck-image-lightbox-photo{object-fit:contain;width:auto;max-width:90vw;height:auto;max-height:90vh}.ck-image-lightbox-meta{border-radius:var(--radius-xl);background-color:var(--muted);text-align:center;max-width:90vw;color:var(--muted-foreground);padding:.25rem .625rem;font-size:.75rem;line-height:1rem;position:absolute;bottom:3.5rem;left:50%;transform:translate(-50%)}.ck-image-lightbox-actions{top:1rem;position:absolute;inset-inline-end:1rem}.ck-image-lightbox-dots{gap:.5rem;display:flex;position:absolute;bottom:1.5rem}.ck-image-lightbox-dot{cursor:pointer;background-color:color-mix(in oklch, var(--foreground) 40%, transparent);border:0;border-radius:999px;width:.625rem;height:.625rem;padding:0;transition:background-color .15s cubic-bezier(.4,0,.2,1)}.ck-image-lightbox-dot:hover{background-color:color-mix(in oklch, var(--foreground) 60%, transparent)}.ck-image-lightbox-dot--active,.ck-image-lightbox-dot--active:hover{background-color:var(--foreground)}";
11
- function y() {
12
- return /* @__PURE__ */ g(o, {
13
- strokeWidth: 1.5,
14
- children: /* @__PURE__ */ g("path", { d: "M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18" })
15
- });
16
- }
17
- function b() {
18
- return /* @__PURE__ */ g(o, {
19
- strokeWidth: 1.5,
20
- children: /* @__PURE__ */ g("path", { d: "M9.00005 6C9.00005 6 15 10.4189 15 12C15 13.5812 9 18 9 18" })
21
- });
22
- }
23
- function x() {
24
- return /* @__PURE__ */ _(o, {
25
- strokeWidth: 1.5,
26
- children: [/* @__PURE__ */ g("path", { d: "M7.5 14.5C7.5 11.2002 7.5 9.55025 8.52513 8.52513C9.55025 7.5 11.2002 7.5 14.5 7.5C17.7998 7.5 19.4497 7.5 20.4749 8.52513C21.5 9.55025 21.5 11.2002 21.5 14.5C21.5 17.7998 21.5 19.4497 20.4749 20.4749C19.4497 21.5 17.7998 21.5 14.5 21.5C11.2002 21.5 9.55025 21.5 8.52513 20.4749C7.5 19.4497 7.5 17.7998 7.5 14.5Z" }), /* @__PURE__ */ g("path", { d: "M7.5 16.5C6.10355 16.5 5.40533 16.5 4.84402 16.3036C3.83866 15.9518 3.0482 15.1613 2.69641 14.156C2.5 13.5947 2.5 12.8964 2.5 11.5V9.5C2.5 6.20017 2.5 4.55025 3.52513 3.52513C4.55025 2.5 6.20017 2.5 9.5 2.5H11.5C12.8964 2.5 13.5947 2.5 14.156 2.69641C15.1613 3.0482 15.9518 3.83866 16.3036 4.84402C16.5 5.40533 16.5 6.10355 16.5 7.5" })]
27
- });
28
- }
29
- function S() {
30
- return /* @__PURE__ */ _(o, {
31
- strokeWidth: 1.5,
32
- children: [/* @__PURE__ */ g("path", { d: "M2.99969 17.0002C2.99969 17.9302 2.99969 18.3952 3.10192 18.7767C3.37932 19.8119 4.18796 20.6206 5.22324 20.898C5.60474 21.0002 6.06972 21.0002 6.99969 21.0002L16.9997 21.0002C17.9297 21.0002 18.3947 21.0002 18.7762 20.898C19.8114 20.6206 20.6201 19.8119 20.8975 18.7767C20.9997 18.3952 20.9997 17.9302 20.9997 17.0002" }), /* @__PURE__ */ g("path", { d: "M16.4998 11.5002C16.4998 11.5002 13.1856 16.0002 11.9997 16.0002C10.8139 16.0002 7.49976 11.5002 7.49976 11.5002M11.9997 15.0002V3.00016" })]
33
- });
34
- }
35
- function C() {
36
- return /* @__PURE__ */ g(o, {
37
- strokeWidth: 1.5,
38
- children: /* @__PURE__ */ g("path", { d: "M18 6L6.00081 17.9992M17.9992 18L6 6.00085" })
39
- });
40
- }
41
- var w = m.memo(function({ images: o, initialIndex: v, open: w, onClose: T, returnFocusRef: E }) {
42
- let [D, O] = m.useState(v);
43
- m.useEffect(() => {
44
- w && O(Math.max(0, Math.min(v, o.length - 1)));
45
- }, [
46
- v,
47
- w,
48
- o.length
49
- ]);
50
- let k = o[D], A = f(k), j = !!(k && (k.type ?? k.filename ?? k.size != null)), M = async (t) => {
51
- if (t.stopPropagation(), k) try {
52
- let t = await A.resolve();
53
- if (!t) throw Error("Attachment unavailable");
54
- let n = new URL(t, window.location.href);
55
- if (n.protocol !== "http:" && n.protocol !== "https:" && n.protocol !== "data:" && n.protocol !== "blob:") throw Error("Invalid image URL protocol");
56
- let r = await fetch(n.href).catch((e) => {
57
- throw A.onError(), e;
58
- });
59
- if (!r.ok) throw A.onError(), Error(`Failed to fetch image (${String(r.status)})`);
60
- let i = await r.blob();
61
- await navigator.clipboard.write([new ClipboardItem({ [i.type]: i })]), e.success("Image copied");
62
- } catch {
63
- e.error("Failed to copy image");
64
- }
65
- };
66
- return /* @__PURE__ */ g(d, {
67
- open: w && o.length > 0,
68
- onOpenChange: (e) => {
69
- e || T();
70
- },
71
- children: /* @__PURE__ */ _(u, {
72
- showCloseButton: !1,
73
- finalFocus: E,
74
- "aria-describedby": void 0,
75
- className: "ck-image-lightbox",
76
- onClick: T,
77
- onKeyDownCapture: (e) => {
78
- if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
79
- e.preventDefault(), e.stopPropagation();
80
- let t = e.key === "ArrowLeft" ? -1 : 1;
81
- O((e) => Math.max(0, Math.min(o.length - 1, e + t)));
82
- },
83
- children: [/* @__PURE__ */ g(l, {
84
- className: "ck-sr-only",
85
- children: "Image lightbox"
86
- }), k ? /* @__PURE__ */ _(h, { children: [
87
- o.length > 1 && D > 0 ? /* @__PURE__ */ g(n, {
88
- variant: "outline",
89
- size: "icon",
90
- "aria-label": "Previous image",
91
- className: "ck-image-lightbox-prev",
92
- onClick: (e) => {
93
- e.stopPropagation(), O((e) => e - 1);
94
- },
95
- children: /* @__PURE__ */ g(y, {})
96
- }) : null,
97
- o.length > 1 && D < o.length - 1 ? /* @__PURE__ */ g(n, {
98
- variant: "outline",
99
- size: "icon",
100
- "aria-label": "Next image",
101
- className: "ck-image-lightbox-next",
102
- onClick: (e) => {
103
- e.stopPropagation(), O((e) => e + 1);
104
- },
105
- children: /* @__PURE__ */ g(b, {})
106
- }) : null,
107
- A.failed ? /* @__PURE__ */ g(p, { link: A }) : /* @__PURE__ */ g("img", {
108
- src: k.url,
109
- onError: A.onError,
110
- alt: k.alt ?? k.filename ?? `Image ${String(D + 1)}`,
111
- className: "ck-image-lightbox-photo",
112
- onClick: (e) => {
113
- e.stopPropagation();
114
- }
115
- }, `${k.url}:${A.attempt}`),
116
- j ? /* @__PURE__ */ g("div", {
117
- className: "ck-image-lightbox-meta",
118
- onClick: (e) => {
119
- e.stopPropagation();
120
- },
121
- children: [
122
- k.type,
123
- k.filename,
124
- c(k.size)
125
- ].filter(Boolean).join(" • ")
126
- }) : null,
127
- /* @__PURE__ */ _(s, {
128
- className: "ck-image-lightbox-actions",
129
- onClick: (e) => {
130
- e.stopPropagation();
131
- },
132
- children: [
133
- /* @__PURE__ */ _(a, { children: [/* @__PURE__ */ g(i, {
134
- render: /* @__PURE__ */ g(n, {
135
- variant: "outline",
136
- size: "icon",
137
- "aria-label": "Copy image",
138
- disabled: A.loading,
139
- onClick: (e) => {
140
- M(e);
141
- }
142
- }),
143
- children: /* @__PURE__ */ g(x, {})
144
- }), /* @__PURE__ */ g(r, { children: "Copy image" })] }),
145
- /* @__PURE__ */ _(a, { children: [/* @__PURE__ */ g(i, {
146
- render: /* @__PURE__ */ g(n, {
147
- variant: "outline",
148
- size: "icon",
149
- "aria-label": "Download",
150
- disabled: A.loading,
151
- onClick: (e) => {
152
- e.stopPropagation(), k && A.download(k.filename ?? k.alt ?? `image-${String(D + 1)}`);
153
- }
154
- }),
155
- children: /* @__PURE__ */ g(S, {})
156
- }), /* @__PURE__ */ g(r, { children: "Download" })] }),
157
- /* @__PURE__ */ _(a, { children: [/* @__PURE__ */ g(i, {
158
- render: /* @__PURE__ */ g(n, {
159
- variant: "outline",
160
- size: "icon",
161
- "aria-label": "Close",
162
- onClick: T
163
- }),
164
- children: /* @__PURE__ */ g(C, {})
165
- }), /* @__PURE__ */ g(r, { children: "Close" })] })
166
- ]
167
- }),
168
- o.length > 1 ? /* @__PURE__ */ g("div", {
169
- className: "ck-image-lightbox-dots",
170
- children: o.map((e, n) => /* @__PURE__ */ g("button", {
171
- type: "button",
172
- "aria-label": `Go to image ${String(n + 1)}`,
173
- "aria-current": n === D ? "true" : void 0,
174
- className: t("ck-image-lightbox-dot", n === D && "ck-image-lightbox-dot--active"),
175
- onClick: (e) => {
176
- e.stopPropagation(), O(n);
177
- }
178
- }, e.id))
179
- }) : null
180
- ] }) : null]
181
- })
182
- });
183
- });
184
- function T(e) {
185
- return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", {
186
- "data-ck-tool-styles": "lightbox",
187
- children: v
188
- }), /* @__PURE__ */ g(w, { ...e })] });
189
- }
190
- export { T as CommentImageLightbox };
@@ -1,214 +0,0 @@
1
- import { o as e, t, u as n } from "./button-D4GHW6oZ.js";
2
- import { t as r } from "./useRender-Uxk1OPK-.js";
3
- import { C as i, c as a, l as o, r as s } from "./comment-kit-ui-BHwYuSIi.js";
4
- import { n as c, r as l, t as u } from "./attachment-refresh-DAacLaRu.js";
5
- import * as d from "react";
6
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
7
- var h = d.forwardRef(function({ ratio: t, className: n, style: r, ...i }, a) {
8
- return /* @__PURE__ */ p("div", {
9
- ref: a,
10
- "data-slot": "aspect-ratio",
11
- className: e("ck-aspect-ratio", n),
12
- style: {
13
- "--ratio": t,
14
- ...r
15
- },
16
- ...i
17
- });
18
- }), g = d.forwardRef(function({ className: t, state: n = "done", size: r = "default", orientation: i = "horizontal", ...a }, o) {
19
- return /* @__PURE__ */ p("div", {
20
- ref: o,
21
- "data-slot": "attachment",
22
- "data-state": n,
23
- "data-size": r,
24
- "data-orientation": i,
25
- className: e("ck-attachment", t),
26
- ...a
27
- });
28
- }), _ = d.forwardRef(function({ className: t, variant: n = "icon", ...r }, i) {
29
- return /* @__PURE__ */ p("div", {
30
- ref: i,
31
- "data-slot": "attachment-media",
32
- "data-variant": n,
33
- className: e("ck-attachment-media", t),
34
- ...r
35
- });
36
- });
37
- d.forwardRef(function({ className: t, ...n }, r) {
38
- return s("attachment"), /* @__PURE__ */ p("div", {
39
- ref: r,
40
- "data-slot": "attachment-group",
41
- className: e("ck-attachment-group", t),
42
- ...n
43
- });
44
- });
45
- var v = d.forwardRef(function({ className: t, ...n }, r) {
46
- return /* @__PURE__ */ p("div", {
47
- ref: r,
48
- "data-slot": "attachment-content",
49
- className: e("ck-attachment-content", t),
50
- ...n
51
- });
52
- }), y = d.forwardRef(function({ className: t, ...n }, r) {
53
- return /* @__PURE__ */ p("span", {
54
- ref: r,
55
- "data-slot": "attachment-title",
56
- className: e("ck-attachment-title", t),
57
- ...n
58
- });
59
- }), b = d.forwardRef(function({ className: t, ...n }, r) {
60
- return /* @__PURE__ */ p("span", {
61
- ref: r,
62
- "data-slot": "attachment-description",
63
- className: e("ck-attachment-description", t),
64
- ...n
65
- });
66
- });
67
- d.forwardRef(function({ className: t, ...n }, r) {
68
- return /* @__PURE__ */ p("div", {
69
- ref: r,
70
- "data-slot": "attachment-actions",
71
- className: e("ck-attachment-actions", t),
72
- ...n
73
- });
74
- }), d.forwardRef(function({ className: e, variant: n = "ghost", size: r = "icon-xs", ...i }, a) {
75
- return /* @__PURE__ */ p(t, {
76
- ref: a,
77
- "data-slot": "attachment-action",
78
- variant: n,
79
- size: r,
80
- className: e,
81
- ...i
82
- });
83
- });
84
- var x = d.forwardRef(function({ className: t, render: i, type: a, ...o }, s) {
85
- return r({
86
- defaultTagName: "button",
87
- props: n({
88
- ref: s,
89
- type: i ? a : a ?? "button",
90
- className: e("ck-attachment-trigger", t)
91
- }, o),
92
- render: i,
93
- state: { slot: "attachment-trigger" }
94
- });
95
- }), S = () => import("./comment-image-lightbox--QpbcAtH.js"), C = 3;
96
- function w(e) {
97
- return e.mimeType ? e.mimeType.startsWith("image/") : e.type === "screenshot" || e.type === "drawing" || e.thumbnail ? !0 : /^data:image\//i.test(e.url) || /\.(png|jpe?g|webp|gif|avif|svg)(?:[?#]|$)/i.test(e.filename ?? e.url);
98
- }
99
- function T(e) {
100
- try {
101
- let t = new URL(e, typeof window > "u" ? "https://commentkit.dev" : window.location.href);
102
- return [
103
- "http:",
104
- "https:",
105
- "blob:"
106
- ].includes(t.protocol) ? t.href : void 0;
107
- } catch {
108
- return;
109
- }
110
- }
111
- var E = d.memo(function({ images: e }) {
112
- let [t, n] = d.useState(!1), [r, a] = d.useState(0), o = d.useRef(null), s = e.filter(w), c = e.filter((e) => !w(e)), l = s.length > C ? s.length - C : 0, u = s.slice(0, C), h = d.useCallback((e) => {
113
- a(e), n(!0);
114
- }, []);
115
- return e.length === 0 ? null : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ m("div", {
116
- className: "ck-comment-images",
117
- onClick: (e) => {
118
- e.stopPropagation();
119
- },
120
- children: [u.map((e, t) => /* @__PURE__ */ p(D, {
121
- image: e,
122
- index: t,
123
- more: t === u.length - 1 ? l : 0,
124
- onOpen: (e) => {
125
- o.current = e, h(t);
126
- }
127
- }, e.id)), c.map((e) => /* @__PURE__ */ p(O, { file: e }, e.id))]
128
- }), /* @__PURE__ */ p(i, {
129
- load: S,
130
- label: "image viewer",
131
- needed: t,
132
- onCancel: () => n(!1),
133
- children: ({ CommentImageLightbox: e }) => /* @__PURE__ */ p(e, {
134
- images: s,
135
- initialIndex: r,
136
- open: t,
137
- returnFocusRef: o,
138
- onClose: () => {
139
- n(!1);
140
- }
141
- })
142
- })] });
143
- });
144
- function D({ image: e, index: t, more: n, onOpen: r }) {
145
- let i = l(e), s = e.filename ?? e.alt ?? `Image ${String(t + 1)}`;
146
- return /* @__PURE__ */ m(g, {
147
- orientation: "vertical",
148
- children: [
149
- /* @__PURE__ */ p(_, {
150
- variant: "image",
151
- children: /* @__PURE__ */ p(h, {
152
- ratio: 1,
153
- className: "ck-comment-image-ratio",
154
- children: i.failed ? /* @__PURE__ */ p(u, {
155
- link: i,
156
- compact: !0
157
- }) : /* @__PURE__ */ p("img", {
158
- src: e.url,
159
- alt: s,
160
- className: "ck-comment-image",
161
- onError: i.onError
162
- }, `${e.url}:${i.attempt}`)
163
- })
164
- }),
165
- n > 0 ? /* @__PURE__ */ m(o, {
166
- variant: "secondary",
167
- className: "ck-comment-image-more",
168
- children: ["+", n]
169
- }) : null,
170
- /* @__PURE__ */ p(x, {
171
- "aria-label": `Open ${s}`,
172
- title: [
173
- e.type,
174
- e.filename,
175
- a(e.size)
176
- ].filter(Boolean).join(" • ") || void 0,
177
- onClick: (e) => {
178
- e.stopPropagation(), r(e.currentTarget);
179
- }
180
- })
181
- ]
182
- });
183
- }
184
- function O({ file: e }) {
185
- let t = l(e), n = e.filename ?? e.alt ?? "Attachment", r = T(e.url);
186
- return /* @__PURE__ */ m(g, {
187
- className: "ck-comment-file",
188
- children: [
189
- /* @__PURE__ */ p(_, { children: /* @__PURE__ */ m("svg", {
190
- viewBox: "0 0 24 24",
191
- fill: "none",
192
- stroke: "currentColor",
193
- strokeWidth: "1.5",
194
- "aria-hidden": "true",
195
- children: [/* @__PURE__ */ p("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6Z" }), /* @__PURE__ */ p("path", { d: "M14 2v6h6M8 13h8M8 17h5" })]
196
- }) }),
197
- /* @__PURE__ */ m(v, { children: [/* @__PURE__ */ p(y, { children: n }), /* @__PURE__ */ p(b, { children: t.refreshFailed ? "Could not refresh. Try again." : t.loading ? "Refreshing link…" : a(e.size) ?? "File" })] }),
198
- r ? /* @__PURE__ */ p(x, {
199
- render: /* @__PURE__ */ p("a", {
200
- href: r,
201
- download: n,
202
- target: "_blank",
203
- rel: "noopener noreferrer"
204
- }),
205
- "aria-label": `Download ${n}`,
206
- "aria-disabled": t.loading || void 0,
207
- onClick: (r) => {
208
- t.loading ? r.preventDefault() : c(e.url) && (r.preventDefault(), t.download(n));
209
- }
210
- }) : null
211
- ]
212
- });
213
- }
214
- export { E as CommentImagesContent };