@commentkit/comment-kit 0.7.1 → 0.7.3
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.
- package/CHANGELOG.md +22 -0
- package/README.md +10 -6
- package/SECURITY.md +14 -6
- package/dist/angular.es.js +2 -2
- package/dist/comment-kit.es.js +5 -5
- package/dist/demo.es.js +35 -34
- package/dist/headless.es.js +3 -3
- package/dist/preact.es.js +2 -2
- package/dist/qwik.qwik.mjs +2 -2
- package/dist/react.es.js +2 -2
- package/dist/shared/{ShadowRootContext-Bv-4aElu.js → ShadowRootContext-CjciYxVN.js} +4 -4
- package/dist/shared/annotation-toolbar-XpqojzM2.js +1094 -0
- package/dist/shared/{attachment-refresh-CzQFXHkL.js → attachment-refresh-agUheZPF.js} +2 -2
- package/dist/shared/{button-group-CWdKaOlC.js → button-group-C285iSkZ.js} +1 -1
- package/dist/shared/capture-privacy-DUROnio5.js +77 -0
- package/dist/shared/{comment-drawing-canvas-DdXlMgbF.js → comment-drawing-canvas-B3zqdIZH.js} +2 -2
- package/dist/shared/{comment-icon-Dg9ZWpz-.js → comment-icon-4SQd3nlz.js} +1 -1
- package/dist/shared/{comment-image-lightbox-B7iHjnAz.js → comment-image-lightbox-j9y3Klh6.js} +5 -5
- package/dist/shared/{comment-images-content-D7YNUgo5.js → comment-images-content-aJrMaOi9.js} +3 -3
- package/dist/shared/{comment-kit-core-C862uNAm.js → comment-kit-core-Bsyydwpk.js} +786 -703
- package/dist/shared/{comment-kit-ui-0vd-DY4S.js → comment-kit-ui-qKjCHHOy.js} +4642 -4820
- package/dist/shared/{comment-screenshot-annotator-DcaSSuWB.js → comment-screenshot-annotator-aDtgMbBF.js} +2 -2
- package/dist/shared/{comment-screenshot-overlay-D_nFoJmM.js → comment-screenshot-overlay-B-rAubia.js} +113 -118
- package/dist/shared/comment-shortcut-groups-CfEmkitU.js +153 -0
- package/dist/shared/{dev-export-panel-pWBlhlse.js → dev-export-panel-mrxmtzei.js} +3 -4
- package/dist/shared/dev-grab-Cc-lJYBv.js +196 -0
- package/dist/shared/{element-selector-DC-_XJ0k.js → element-selector-4TxTAXHK.js} +408 -405
- package/dist/shared/{mount-ui-B68j8r6I.js → mount-ui-Dbqe5VsO.js} +121 -106
- package/dist/shared/{pusher-C1FHQGXV.js → pusher-zAMukOay.js} +1 -1
- package/dist/shared/{realtime-recovery-DJ_adc-H.js → realtime-recovery-BSVMwsXJ.js} +1 -1
- package/dist/shared/realtime-t5o6fk6w.js +321 -0
- package/dist/shared/request-activity-DQrAUwfA.js +11 -0
- package/dist/shared/{separator-XDBsaWyw.js → separator-aphZiRoJ.js} +1 -1
- package/dist/shared/{shadow-root-CrO75sED.js → shadow-root-DlfbvZF9.js} +31 -31
- package/dist/shared/{styles-C9Jwvm0Q.js → styles-CnYsLS2f.js} +1 -1
- package/dist/shared/text-B4HHZNaa.js +23 -0
- package/dist/shared/token-session-ZzSO1tEl.js +25 -0
- package/dist/shared/{validation-D-8u4M7I.js → validation-3wbbbuX0.js} +14 -2
- package/dist/shared/{websocket-manager-CFak_YHy.js → websocket-manager-DGN8T9mq.js} +136 -116
- package/dist/solid.es.js +2 -2
- package/dist/svelte.es.js +2 -2
- package/dist/types/core/api-client.d.ts +3 -1
- package/dist/types/core/comment-kit-core.d.ts +2 -5
- package/dist/types/core/types.d.ts +22 -5
- package/dist/types/core/websocket-manager.d.ts +1 -0
- package/dist/vue.es.js +2 -2
- package/docs/api-reference.md +19 -4
- package/package.json +1 -1
- package/dist/shared/annotation-toolbar-cGC1p-SP.js +0 -1093
- package/dist/shared/dev-grab-eQ9EgEGY.js +0 -210
- package/dist/shared/realtime-Diqz7G_y.js +0 -317
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
import { a as e, c as t, d as n,
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function m(e) {
|
|
8
|
-
return f.set(e, (f.get(e) ?? 0) + 1), () => {
|
|
9
|
-
let t = (f.get(e) ?? 1) - 1;
|
|
10
|
-
t ? f.set(e, t) : f.delete(e);
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
var h = "https://api.commentkit.dev/api", g = 3e4, _ = 10485760, v = 10, y = 1e4, ee = 5e3, b = 254, te = 6, ne = 4096, re = [
|
|
1
|
+
import { a as e, c as t, d as n, f as r, l as i, n as a, o, p as s, r as c, s as l, t as u, u as d } from "./validation-3wbbbuX0.js";
|
|
2
|
+
import { t as f } from "./request-activity-DQrAUwfA.js";
|
|
3
|
+
import { n as p, o as m } from "./dom-Bhf4WFtY.js";
|
|
4
|
+
import { n as h, t as g } from "./capture-privacy-DUROnio5.js";
|
|
5
|
+
import { a as _, n as v, r as y, t as ee } from "./text-B4HHZNaa.js";
|
|
6
|
+
var b = "https://api.commentkit.dev/api", te = 3e4, ne = 10485760, re = 10, ie = 1e4, ae = 5e3, oe = 254, se = 6, ce = 4096, le = [
|
|
14
7
|
".png",
|
|
15
8
|
".jpg",
|
|
16
9
|
".jpeg",
|
|
17
10
|
".gif",
|
|
18
11
|
".webp"
|
|
19
|
-
],
|
|
12
|
+
], ue = [
|
|
20
13
|
"image/png",
|
|
21
14
|
"image/jpeg",
|
|
22
15
|
"image/gif",
|
|
23
16
|
"image/webp"
|
|
24
|
-
],
|
|
17
|
+
], de = /@\[([^\]]+)\]\(([^)]+)\)/g, x = {
|
|
25
18
|
invalid_api_key: "Authentication failed. Please check your API key.",
|
|
26
19
|
missing_api_key: "Authentication failed. Please check your API key.",
|
|
27
20
|
origin_not_allowed: "This domain is not allowed to use this project's API key.",
|
|
@@ -45,22 +38,23 @@ var h = "https://api.commentkit.dev/api", g = 3e4, _ = 10485760, v = 10, y = 1e4
|
|
|
45
38
|
email_mismatch: "This invite was issued for a different email address.",
|
|
46
39
|
quota_exceeded: "This project has reached its plan limit."
|
|
47
40
|
};
|
|
48
|
-
function
|
|
41
|
+
function fe(e, t) {
|
|
49
42
|
let n = {};
|
|
50
43
|
return e.content !== void 0 && (n.content = e.content), e.status !== void 0 && (n.status = e.status), e.priority !== void 0 && (n.priority = e.priority), e.description !== void 0 && (n.description = e.description), e.assignees !== void 0 && (n.assignees = e.assignees.map((e) => e.id)), e.checklist !== void 0 && (n.checklist = e.checklist.map((e) => ({
|
|
51
44
|
...e,
|
|
52
45
|
id: /^\d+$/.test(e.id) ? Number(e.id) : null
|
|
53
46
|
}))), e.textSelection !== void 0 && (n.text_selection = e.textSelection), e.drawingData !== void 0 && (n.drawing_data = e.drawingData), e.attachmentIds !== void 0 && (n.attachment_ids = e.attachmentIds.map((e) => typeof e == "number" ? e : Number(e)).filter((e) => Number.isInteger(e) && e > 0).slice(0, 20)), t && t.length > 0 && (n.mentions = t), n;
|
|
54
47
|
}
|
|
55
|
-
function
|
|
48
|
+
function pe(e) {
|
|
56
49
|
return e === "localhost" || e === "127.0.0.1" || e === "[::1]" || e.endsWith(".localhost");
|
|
57
50
|
}
|
|
58
|
-
function
|
|
59
|
-
let t = (e ||
|
|
51
|
+
function me(e) {
|
|
52
|
+
let t = (e || b).trim().replace(/\/+$/, "");
|
|
60
53
|
try {
|
|
61
54
|
let e = new URL(t);
|
|
55
|
+
if (e.username || e.password || e.search || e.hash || a(t)) throw Error("ambiguous endpoint");
|
|
62
56
|
if (e.protocol !== "https:" && e.protocol !== "http:") throw Error("unsupported protocol");
|
|
63
|
-
if (e.protocol === "http:" && !
|
|
57
|
+
if (e.protocol === "http:" && !pe(e.hostname)) throw Error("insecure protocol");
|
|
64
58
|
} catch {
|
|
65
59
|
throw new T("invalid_base_url", "Invalid API base URL", 400);
|
|
66
60
|
}
|
|
@@ -68,37 +62,37 @@ function ce(e) {
|
|
|
68
62
|
}
|
|
69
63
|
function S(e) {
|
|
70
64
|
let t = String(e).trim();
|
|
71
|
-
if (!t ||
|
|
65
|
+
if (!t || a(t)) throw new T("invalid_id", "Invalid identifier", 400);
|
|
72
66
|
return encodeURIComponent(t);
|
|
73
67
|
}
|
|
74
|
-
function
|
|
75
|
-
if (typeof e != "string" ||
|
|
68
|
+
function he(e) {
|
|
69
|
+
if (typeof e != "string" || a(e)) throw new T("invalid_email", "A valid email address is required", 400);
|
|
76
70
|
let t = e.trim();
|
|
77
|
-
if (!
|
|
71
|
+
if (!s(t, oe)) throw new T("invalid_email", "A valid email address is required", 400);
|
|
78
72
|
return t;
|
|
79
73
|
}
|
|
80
|
-
function
|
|
81
|
-
if (
|
|
74
|
+
function ge(e) {
|
|
75
|
+
if (a(e)) throw new T("invalid_otp", "A valid OTP code is required", 400);
|
|
82
76
|
let t = e.trim();
|
|
83
|
-
if (t.length !==
|
|
77
|
+
if (t.length !== se || /\s/.test(t)) throw new T("invalid_otp", "A valid OTP code is required", 400);
|
|
84
78
|
return t;
|
|
85
79
|
}
|
|
86
|
-
function
|
|
87
|
-
if (
|
|
80
|
+
function _e(e) {
|
|
81
|
+
if (a(e)) throw new T("invalid_token", "A valid invite token is required", 400);
|
|
88
82
|
let t = e.trim();
|
|
89
83
|
if (t.length !== 64 || !/^[\w-]+$/.test(t)) throw new T("invalid_token", "A valid invite token is required", 400);
|
|
90
84
|
return t;
|
|
91
85
|
}
|
|
92
|
-
function C(e, t, n =
|
|
86
|
+
function C(e, t, n = ie) {
|
|
93
87
|
let r = e.trim();
|
|
94
88
|
if (!r) throw new T("invalid_content", `${t} cannot be empty`, 400);
|
|
95
89
|
if (r.length > n) throw new T("content_too_long", `${t} exceeds maximum length of ${n} characters`, 400);
|
|
96
90
|
return r;
|
|
97
91
|
}
|
|
98
|
-
function
|
|
92
|
+
function ve(e, t) {
|
|
99
93
|
let n = {};
|
|
100
|
-
for (let [t, r] of Object.entries(
|
|
101
|
-
if (
|
|
94
|
+
for (let [t, r] of Object.entries(o(e) ? e : {}).slice(0, 20)) /^[\w.-]{1,64}$/.test(t) && t !== "__proto__" && t !== "constructor" && t !== "prototype" && (typeof r == "string" ? n[t] = r.slice(0, 200) : typeof r == "number" || typeof r == "boolean" || r === null ? n[t] = r : Array.isArray(r) && (n[t] = r.filter((e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null).slice(0, 10).map((e) => typeof e == "string" ? e.slice(0, 200) : e)));
|
|
95
|
+
if (o(t)) {
|
|
102
96
|
let e = {};
|
|
103
97
|
for (let n of [
|
|
104
98
|
"type",
|
|
@@ -111,18 +105,18 @@ function fe(e, t) {
|
|
|
111
105
|
}
|
|
112
106
|
return Object.keys(n).length > 0 ? n : void 0;
|
|
113
107
|
}
|
|
114
|
-
var
|
|
108
|
+
var ye = class {
|
|
115
109
|
constructor(e) {
|
|
116
|
-
this.projectId = null, this.channelProjectId = null, this.userEmail = null, this.authToken = null, this.authRevision = 0, this.environment = null, this.onAuthExpired = null, this.baseUrl =
|
|
110
|
+
this.projectId = null, this.channelProjectId = null, this.userEmail = null, this.authToken = null, this.authRevision = 0, this.environment = null, this.onAuthExpired = null, this.baseUrl = me(e.baseUrl), this.apiKey = e.apiKey, this.projectId = e.projectId || null, this.channelProjectId = this.projectId, this.environment = e.environment || null;
|
|
117
111
|
}
|
|
118
112
|
setProject(e, t = e) {
|
|
119
113
|
this.projectId = String(e).trim(), this.channelProjectId = String(t).trim();
|
|
120
114
|
}
|
|
121
115
|
setUserEmail(e) {
|
|
122
|
-
this.userEmail = e ?
|
|
116
|
+
this.userEmail = e ? he(e) : null;
|
|
123
117
|
}
|
|
124
118
|
setAuthToken(e) {
|
|
125
|
-
if (e && (
|
|
119
|
+
if (e && (a(e) || e.length > ce)) throw new T("invalid_token", "A valid auth token is required", 400);
|
|
126
120
|
let t = e?.trim() || null;
|
|
127
121
|
this.authToken = t, this.authRevision++;
|
|
128
122
|
}
|
|
@@ -133,7 +127,7 @@ var pe = class {
|
|
|
133
127
|
this.onAuthExpired = e;
|
|
134
128
|
}
|
|
135
129
|
buildHeaders(e) {
|
|
136
|
-
if (typeof this.apiKey != "string" ||
|
|
130
|
+
if (typeof this.apiKey != "string" || a(this.apiKey)) throw new T("invalid_api_key", "Authentication failed. Please check your API key.", 401);
|
|
137
131
|
return {
|
|
138
132
|
"X-API-Key": this.apiKey,
|
|
139
133
|
...this.userEmail ? { "X-User-Email": this.userEmail } : {},
|
|
@@ -142,16 +136,21 @@ var pe = class {
|
|
|
142
136
|
};
|
|
143
137
|
}
|
|
144
138
|
async executeRequest(e, t, n, r) {
|
|
145
|
-
let i = this.authRevision,
|
|
139
|
+
let i = this.authRevision, a = this.authToken, s = t.method && t.method !== "GET" ? f(this) : null, c = new AbortController(), l = setTimeout(() => c.abort(), te);
|
|
146
140
|
try {
|
|
147
141
|
let s = await fetch(e, {
|
|
148
142
|
...t,
|
|
143
|
+
credentials: "omit",
|
|
144
|
+
redirect: "manual",
|
|
145
|
+
referrerPolicy: "no-referrer",
|
|
149
146
|
signal: c.signal
|
|
150
|
-
})
|
|
147
|
+
});
|
|
148
|
+
if (s.type === "opaqueredirect" || s.status >= 300 && s.status < 400) throw new T("unexpected_redirect", "The API endpoint redirected. Check the configured API URL before retrying.", 400);
|
|
149
|
+
let l = await this.parseResponseBody(s);
|
|
151
150
|
if (!s.ok) {
|
|
152
|
-
s.status === 401 &&
|
|
153
|
-
let e =
|
|
154
|
-
throw new T(t, x[t] ?? r, s.status,
|
|
151
|
+
s.status === 401 && a && i === this.authRevision && (this.setAuthToken(null), this.onAuthExpired?.());
|
|
152
|
+
let e = o(l) ? l : {}, t = typeof e.error == "string" ? e.error : s.status === 403 ? "unauthorized" : n;
|
|
153
|
+
throw new T(t, x[t] ?? r, s.status, ve(e.details, e.quota));
|
|
155
154
|
}
|
|
156
155
|
return l;
|
|
157
156
|
} catch (e) {
|
|
@@ -216,9 +215,12 @@ var pe = class {
|
|
|
216
215
|
body: JSON.stringify({})
|
|
217
216
|
});
|
|
218
217
|
}
|
|
218
|
+
async verifySession() {
|
|
219
|
+
return this.request("/auth/me");
|
|
220
|
+
}
|
|
219
221
|
async authorizeChannel(e, t) {
|
|
220
222
|
if (!this.authToken) throw new T("unauthorized", x.unauthorized, 401);
|
|
221
|
-
if (!/^\d+\.\d+$/.test(e) ||
|
|
223
|
+
if (!/^\d+\.\d+$/.test(e) || a(e) || e.length > 128 || !this.channelProjectId || t !== `presence-project.${this.channelProjectId}`) throw new T("invalid_channel", "Invalid realtime channel request.", 400);
|
|
222
224
|
let n = this.authRevision, r = await this.request("/broadcasting/auth", {
|
|
223
225
|
method: "POST",
|
|
224
226
|
body: JSON.stringify({
|
|
@@ -227,28 +229,28 @@ var pe = class {
|
|
|
227
229
|
})
|
|
228
230
|
});
|
|
229
231
|
if (n !== this.authRevision) throw new T("unauthorized", x.unauthorized, 401);
|
|
230
|
-
if (!
|
|
231
|
-
let
|
|
232
|
+
if (!o(r) || typeof r.auth != "string" || !r.auth || typeof r.channel_data != "string") throw new T("invalid_response", x.invalid_response, 502);
|
|
233
|
+
let i;
|
|
232
234
|
try {
|
|
233
|
-
|
|
235
|
+
i = JSON.parse(r.channel_data);
|
|
234
236
|
} catch {
|
|
235
237
|
throw new T("invalid_response", x.invalid_response, 502);
|
|
236
238
|
}
|
|
237
|
-
if (!
|
|
239
|
+
if (!o(i) || !i.user_id) throw new T("invalid_response", x.invalid_response, 502);
|
|
238
240
|
return {
|
|
239
241
|
auth: r.auth,
|
|
240
242
|
channel_data: r.channel_data
|
|
241
243
|
};
|
|
242
244
|
}
|
|
243
245
|
async requestOtp(e) {
|
|
244
|
-
let t =
|
|
246
|
+
let t = he(e);
|
|
245
247
|
return this.request("/auth/otp/request", {
|
|
246
248
|
method: "POST",
|
|
247
249
|
body: JSON.stringify({ email: t })
|
|
248
250
|
});
|
|
249
251
|
}
|
|
250
252
|
async verifyOtp(e, t) {
|
|
251
|
-
let n =
|
|
253
|
+
let n = he(e), r = ge(t);
|
|
252
254
|
return this.request("/auth/otp/verify", {
|
|
253
255
|
method: "POST",
|
|
254
256
|
body: JSON.stringify({
|
|
@@ -258,7 +260,7 @@ var pe = class {
|
|
|
258
260
|
});
|
|
259
261
|
}
|
|
260
262
|
async validateInvite(e, t) {
|
|
261
|
-
let n =
|
|
263
|
+
let n = _e(e), r = he(t);
|
|
262
264
|
return this.request("/auth/validate-invite", {
|
|
263
265
|
method: "POST",
|
|
264
266
|
body: JSON.stringify({
|
|
@@ -288,7 +290,7 @@ var pe = class {
|
|
|
288
290
|
return (await this.request(`/projects/${S(t)}/comments/${S(e)}`)).comment;
|
|
289
291
|
}
|
|
290
292
|
idempotencyHeaders(e) {
|
|
291
|
-
return typeof e == "string" && e.length > 0 && e.length <= 256 && !
|
|
293
|
+
return typeof e == "string" && e.length > 0 && e.length <= 256 && !a(e) ? { "Idempotency-Key": e } : {};
|
|
292
294
|
}
|
|
293
295
|
async createComment(e, t, n, r, i = "medium", a, o, s, c) {
|
|
294
296
|
let l = C(t, "Comment content"), u = this.requireProjectId(), d = s?.mentions ?? w(l);
|
|
@@ -304,7 +306,7 @@ var pe = class {
|
|
|
304
306
|
environment: this.environment || void 0,
|
|
305
307
|
branch: s?.branch,
|
|
306
308
|
device_info: s?.deviceInfo,
|
|
307
|
-
...
|
|
309
|
+
...fe({
|
|
308
310
|
content: l,
|
|
309
311
|
priority: i,
|
|
310
312
|
description: s?.description,
|
|
@@ -318,7 +320,7 @@ var pe = class {
|
|
|
318
320
|
})).comment;
|
|
319
321
|
}
|
|
320
322
|
async updateComment(e, t) {
|
|
321
|
-
let n = this.requireProjectId(), r = t.content === void 0 ? void 0 : C(t.content, "Comment content"), i = t.mentions ?? (r ? w(r) : void 0), a =
|
|
323
|
+
let n = this.requireProjectId(), r = t.content === void 0 ? void 0 : C(t.content, "Comment content"), i = t.mentions ?? (r ? w(r) : void 0), a = fe({
|
|
322
324
|
...t,
|
|
323
325
|
...r === void 0 ? {} : { content: r }
|
|
324
326
|
}, i);
|
|
@@ -332,7 +334,7 @@ var pe = class {
|
|
|
332
334
|
await this.request(`/projects/${S(t)}/comments/${S(e)}`, { method: "DELETE" });
|
|
333
335
|
}
|
|
334
336
|
async addReply(e, t, n, r) {
|
|
335
|
-
let i = this.requireProjectId(), a = C(t, "Reply content",
|
|
337
|
+
let i = this.requireProjectId(), a = C(t, "Reply content", ae), o = r?.mentions ?? w(a);
|
|
336
338
|
return (await this.request(`/projects/${S(i)}/comments/${S(e)}/replies`, {
|
|
337
339
|
method: "POST",
|
|
338
340
|
headers: this.idempotencyHeaders(n),
|
|
@@ -345,7 +347,7 @@ var pe = class {
|
|
|
345
347
|
})).reply;
|
|
346
348
|
}
|
|
347
349
|
async updateReply(e, t, n, r) {
|
|
348
|
-
let i = this.requireProjectId(), a = C(n, "Reply content",
|
|
350
|
+
let i = this.requireProjectId(), a = C(n, "Reply content", ae);
|
|
349
351
|
return (await this.request(`/projects/${S(i)}/comments/${S(e)}/replies/${S(t)}`, {
|
|
350
352
|
method: "PUT",
|
|
351
353
|
body: JSON.stringify({
|
|
@@ -409,15 +411,15 @@ var pe = class {
|
|
|
409
411
|
return this.createComment("drawing", e, n, r, "medium", void 0, t, a, i);
|
|
410
412
|
}
|
|
411
413
|
validateFile(e, t = !1) {
|
|
412
|
-
if (e.size >
|
|
413
|
-
if (
|
|
414
|
+
if (e.size > ne) throw new T("file_too_large", `File size (${Math.round(e.size / 1024 / 1024)}MB) exceeds maximum of ${ne / 1024 / 1024}MB`, 400);
|
|
415
|
+
if (a(e.name) || e.name.includes("/") || e.name.includes("\\")) throw new T("invalid_filename", "Filename contains invalid characters", 400);
|
|
414
416
|
if (t) {
|
|
415
417
|
/* v8 ignore next -- pop() always returns a value since file has a name */
|
|
416
418
|
let t = "." + (e.name.split(".").pop()?.toLowerCase() ?? "");
|
|
417
419
|
if ((e.name.match(/\./g) || []).length > 1) throw new T("invalid_filename", "Filenames with multiple extensions are not allowed", 400);
|
|
418
|
-
if (!
|
|
420
|
+
if (!ue.includes(e.type) || !le.includes(t)) throw new T("invalid_file_type", `Only image files are allowed (${le.join(", ")})`, 400);
|
|
419
421
|
}
|
|
420
|
-
if (
|
|
422
|
+
if (u(e.name)) throw new T("invalid_file_type", "This file type is not allowed", 400);
|
|
421
423
|
}
|
|
422
424
|
async uploadFile(e, t, n) {
|
|
423
425
|
this.validateFile(e, t === "screenshot" || t === "drawing");
|
|
@@ -441,10 +443,10 @@ var pe = class {
|
|
|
441
443
|
return (await this.requestFormData(`/projects/${S(r)}/screenshots`, i)).comment;
|
|
442
444
|
}
|
|
443
445
|
async uploadFiles(e, t) {
|
|
444
|
-
if (e.length >
|
|
446
|
+
if (e.length > re) throw new T("too_many_files", `Cannot upload more than ${re} files at once`, 400);
|
|
445
447
|
let n = await Promise.allSettled(e.map((e) => {
|
|
446
448
|
/* v8 ignore next -- pop() always returns a value since file has a name */
|
|
447
|
-
let n = "." + (e.name.split(".").pop()?.toLowerCase() ?? ""), r =
|
|
449
|
+
let n = "." + (e.name.split(".").pop()?.toLowerCase() ?? ""), r = ue.includes(e.type) && le.includes(n);
|
|
448
450
|
return this.uploadFile(e, r ? "screenshot" : "attachment", t);
|
|
449
451
|
})), r = n.filter((e) => e.status === "fulfilled").map((e) => e.value.id), i = n.find((e) => e.status === "rejected");
|
|
450
452
|
if (i) {
|
|
@@ -467,7 +469,7 @@ var pe = class {
|
|
|
467
469
|
};
|
|
468
470
|
function w(e) {
|
|
469
471
|
let t = [], n;
|
|
470
|
-
for (
|
|
472
|
+
for (de.lastIndex = 0; (n = de.exec(e)) !== null;) {
|
|
471
473
|
let e = n[1]?.trim(), r = n[2]?.trim();
|
|
472
474
|
e && r && /^[\w-]+$/.test(r) && t.push({
|
|
473
475
|
name: e,
|
|
@@ -477,11 +479,11 @@ function w(e) {
|
|
|
477
479
|
}
|
|
478
480
|
return t;
|
|
479
481
|
}
|
|
480
|
-
function
|
|
482
|
+
function be(e) {
|
|
481
483
|
return `@[${e.name.replace(/\]/g, "")}](${e.id.replace(/\)/g, "")})`;
|
|
482
484
|
}
|
|
483
|
-
function
|
|
484
|
-
return e.replace(
|
|
485
|
+
function xe(e) {
|
|
486
|
+
return e.replace(de, "@$1");
|
|
485
487
|
}
|
|
486
488
|
var T = class extends Error {
|
|
487
489
|
constructor(e, t, n, r) {
|
|
@@ -499,26 +501,19 @@ var T = class extends Error {
|
|
|
499
501
|
isPremiumFeatureError() {
|
|
500
502
|
return this.code === 402;
|
|
501
503
|
}
|
|
502
|
-
},
|
|
503
|
-
function
|
|
504
|
-
return
|
|
505
|
-
}
|
|
506
|
-
function E(e, t) {
|
|
507
|
-
return (e ?? "").replace(/\s+/g, " ").replace(/`/g, "'").trim().slice(0, t);
|
|
508
|
-
}
|
|
509
|
-
var D = null, ve = 0, ye = 3;
|
|
510
|
-
function be() {
|
|
511
|
-
return D || (D = (async () => {
|
|
504
|
+
}, E = null, Se = 0, Ce = 3;
|
|
505
|
+
function we() {
|
|
506
|
+
return E || (E = (async () => {
|
|
512
507
|
try {
|
|
513
508
|
let e = await import("element-source");
|
|
514
509
|
return typeof e?.resolveElementInfo == "function" ? e : null;
|
|
515
510
|
} catch {
|
|
516
|
-
return
|
|
511
|
+
return Se += 1, Se < Ce && (E = null), null;
|
|
517
512
|
}
|
|
518
|
-
})(),
|
|
513
|
+
})(), E);
|
|
519
514
|
}
|
|
520
|
-
async function
|
|
521
|
-
let t = await
|
|
515
|
+
async function Te(e) {
|
|
516
|
+
let t = await we();
|
|
522
517
|
if (!t) return null;
|
|
523
518
|
try {
|
|
524
519
|
return await t.resolveElementInfo(e);
|
|
@@ -526,27 +521,27 @@ async function xe(e) {
|
|
|
526
521
|
return null;
|
|
527
522
|
}
|
|
528
523
|
}
|
|
529
|
-
var
|
|
530
|
-
function
|
|
524
|
+
var Ee = 200, De = 500, Oe = 500, ke = 2e3, Ae = "application/x-commentkit-agent-context", je = "Address the UI feedback in this context.";
|
|
525
|
+
function Me(e) {
|
|
531
526
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
532
527
|
}
|
|
533
|
-
function
|
|
534
|
-
return e === void 0 ?
|
|
528
|
+
function Ne(e) {
|
|
529
|
+
return e === void 0 ? Ee : !Number.isFinite(e) || e <= 0 ? 0 : Math.min(De, Math.floor(e));
|
|
535
530
|
}
|
|
536
|
-
function
|
|
531
|
+
function Pe(e) {
|
|
537
532
|
return {
|
|
538
533
|
id: e.id,
|
|
539
534
|
name: e.name,
|
|
540
535
|
email: e.email
|
|
541
536
|
};
|
|
542
537
|
}
|
|
543
|
-
function
|
|
538
|
+
function Fe(e, t) {
|
|
544
539
|
return e.page.path === t.path || e.page.url === t.url;
|
|
545
540
|
}
|
|
546
|
-
function
|
|
547
|
-
return !(!n.includeResolved && e.status !== "open" || n.currentPageOnly && !
|
|
541
|
+
function Ie(e, t, n, r) {
|
|
542
|
+
return !(!n.includeResolved && e.status !== "open" || n.currentPageOnly && !Fe(e, t) || r && !r.has(e.id));
|
|
548
543
|
}
|
|
549
|
-
function
|
|
544
|
+
function Le(e) {
|
|
550
545
|
let t = e.getBoundingClientRect();
|
|
551
546
|
return {
|
|
552
547
|
top: t.top,
|
|
@@ -555,78 +550,93 @@ function Ne(e) {
|
|
|
555
550
|
height: t.height
|
|
556
551
|
};
|
|
557
552
|
}
|
|
558
|
-
function
|
|
559
|
-
let r = n ?
|
|
553
|
+
function Re(e, t, n) {
|
|
554
|
+
let r = n ? p(e.element ?? "", e.xpath) : null, i = {
|
|
560
555
|
...e.element ? { selector: e.element } : {},
|
|
561
556
|
...e.xpath ? { xpath: e.xpath } : {}
|
|
562
557
|
};
|
|
563
|
-
if (!r) return {
|
|
558
|
+
if (!r || g(r)) return {
|
|
564
559
|
...i,
|
|
565
560
|
found: !1
|
|
566
561
|
};
|
|
567
|
-
let a =
|
|
562
|
+
let a = h(r), o = y(a.text, Oe), s = t ? y(a.html, ke) : "", c = r.getAttribute("class"), l = r.getAttribute("role"), u = r.getAttribute("aria-label");
|
|
568
563
|
return {
|
|
569
564
|
...i,
|
|
570
565
|
found: !0,
|
|
571
566
|
tagName: r.tagName.toLowerCase(),
|
|
572
567
|
...r.id ? { id: r.id } : {},
|
|
573
|
-
...
|
|
574
|
-
...
|
|
575
|
-
...
|
|
576
|
-
...
|
|
577
|
-
rect:
|
|
578
|
-
...
|
|
568
|
+
...c ? { className: c } : {},
|
|
569
|
+
...l ? { role: l } : {},
|
|
570
|
+
...u ? { ariaLabel: u } : {},
|
|
571
|
+
...o ? { text: o } : {},
|
|
572
|
+
rect: Le(r),
|
|
573
|
+
...s ? { htmlPreview: s } : {}
|
|
579
574
|
};
|
|
580
575
|
}
|
|
581
|
-
function
|
|
576
|
+
function ze(e) {
|
|
582
577
|
return {
|
|
583
578
|
id: e.id,
|
|
584
579
|
content: e.content,
|
|
585
|
-
author:
|
|
580
|
+
author: Pe(e.author),
|
|
586
581
|
createdAt: e.createdAt,
|
|
587
582
|
isEdited: e.isEdited,
|
|
588
583
|
replyTo: e.replyTo,
|
|
589
584
|
mentions: e.mentions,
|
|
590
585
|
reactions: e.reactions,
|
|
591
|
-
attachments: e.attachments
|
|
586
|
+
attachments: e.attachments?.map(D)
|
|
592
587
|
};
|
|
593
588
|
}
|
|
594
|
-
function
|
|
595
|
-
return e.
|
|
589
|
+
function Be(e) {
|
|
590
|
+
return e && e.length <= 4096 && !/[?#]/.test(e) && /^https?:\/\//i.test(e) && d(e) ? e : void 0;
|
|
591
|
+
}
|
|
592
|
+
function D(e) {
|
|
593
|
+
let { id: t, type: n, filename: r, mimeType: i, size: a } = e, o = Be(e.url);
|
|
594
|
+
return {
|
|
595
|
+
id: t,
|
|
596
|
+
type: n,
|
|
597
|
+
filename: r,
|
|
598
|
+
mimeType: i,
|
|
599
|
+
size: a,
|
|
600
|
+
...o ? { url: o } : { inlineContentOmitted: !0 }
|
|
601
|
+
};
|
|
596
602
|
}
|
|
597
|
-
function
|
|
598
|
-
let r =
|
|
603
|
+
function Ve(e, t, n) {
|
|
604
|
+
let r = e.attachments.map(D), i = r.find((e) => e.type === "screenshot" && e.url)?.url;
|
|
599
605
|
return {
|
|
600
606
|
id: e.id,
|
|
601
607
|
type: e.type,
|
|
602
608
|
status: e.status,
|
|
603
609
|
priority: e.priority,
|
|
604
610
|
content: e.content,
|
|
605
|
-
author:
|
|
611
|
+
author: Pe(e.author),
|
|
606
612
|
createdAt: e.createdAt,
|
|
607
613
|
updatedAt: e.updatedAt,
|
|
608
614
|
environment: e.environment,
|
|
609
615
|
branch: e.branch,
|
|
610
616
|
deviceInfo: e.deviceInfo,
|
|
611
617
|
description: e.description,
|
|
612
|
-
assignees: e.assignees?.map(
|
|
618
|
+
assignees: e.assignees?.map(Pe),
|
|
613
619
|
mentions: e.mentions,
|
|
614
620
|
checklist: e.checklist,
|
|
615
621
|
reactions: e.reactions,
|
|
616
622
|
isEdited: e.isEdited,
|
|
617
623
|
resolvedAt: e.resolvedAt,
|
|
618
624
|
completedAt: e.completedAt,
|
|
619
|
-
page:
|
|
625
|
+
page: {
|
|
626
|
+
...e.page,
|
|
627
|
+
url: _(e.page.url),
|
|
628
|
+
path: _(e.page.path)
|
|
629
|
+
},
|
|
620
630
|
position: e.position,
|
|
621
631
|
textSelection: e.textSelection,
|
|
622
632
|
drawingData: e.drawingData,
|
|
623
|
-
attachments:
|
|
624
|
-
element:
|
|
625
|
-
...
|
|
626
|
-
replies: e.replies.map(
|
|
633
|
+
attachments: r,
|
|
634
|
+
element: Re(e.position, t.includeHtml === !0, Fe(e, n)),
|
|
635
|
+
...i ? { screenshotUrl: i } : {},
|
|
636
|
+
replies: e.replies.map(ze)
|
|
627
637
|
};
|
|
628
638
|
}
|
|
629
|
-
function
|
|
639
|
+
function He(e) {
|
|
630
640
|
return {
|
|
631
641
|
filePath: e.filePath,
|
|
632
642
|
lineNumber: e.lineNumber,
|
|
@@ -635,16 +645,20 @@ function Re(e) {
|
|
|
635
645
|
};
|
|
636
646
|
}
|
|
637
647
|
function O(e, t = {}) {
|
|
638
|
-
let n =
|
|
648
|
+
let n = m(), r = {
|
|
639
649
|
url: n.url,
|
|
640
650
|
path: n.path,
|
|
641
651
|
title: n.title
|
|
642
|
-
}, i = t.commentIds?.length ? new Set(t.commentIds) : null, a =
|
|
652
|
+
}, i = t.commentIds?.length ? new Set(t.commentIds) : null, a = Ne(t.maxComments), o = e.comments.filter((e) => Ie(e, r, t, i)), s = o.slice(0, a).map((e) => Ve(e, t, r));
|
|
643
653
|
return {
|
|
644
654
|
version: 1,
|
|
645
655
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
646
|
-
instructions:
|
|
647
|
-
page:
|
|
656
|
+
instructions: v(t.instructions, 2e3) || je,
|
|
657
|
+
page: {
|
|
658
|
+
...r,
|
|
659
|
+
url: _(r.url),
|
|
660
|
+
path: _(r.path)
|
|
661
|
+
},
|
|
648
662
|
comments: s,
|
|
649
663
|
...e.project ? { project: {
|
|
650
664
|
id: e.project.id,
|
|
@@ -664,15 +678,15 @@ function O(e, t = {}) {
|
|
|
664
678
|
sourceResolved: !1
|
|
665
679
|
};
|
|
666
680
|
}
|
|
667
|
-
async function
|
|
681
|
+
async function Ue(e) {
|
|
668
682
|
let t = !1, n = await Promise.all(e.comments.map(async (e) => {
|
|
669
683
|
if (!e.element.found) return e;
|
|
670
|
-
let n =
|
|
671
|
-
if (!n) return e;
|
|
672
|
-
let r = await
|
|
684
|
+
let n = p(e.element.selector ?? "", e.element.xpath);
|
|
685
|
+
if (!n || g(n)) return e;
|
|
686
|
+
let r = await Te(n);
|
|
673
687
|
if (!r || !r.source) return e;
|
|
674
688
|
t = !0;
|
|
675
|
-
let i =
|
|
689
|
+
let i = He(r.source), a = r.stack.map(He), o = r.componentName ?? void 0;
|
|
676
690
|
return {
|
|
677
691
|
...e,
|
|
678
692
|
element: {
|
|
@@ -689,50 +703,121 @@ async function ze(e) {
|
|
|
689
703
|
sourceResolved: t
|
|
690
704
|
};
|
|
691
705
|
}
|
|
692
|
-
function Be(e) {
|
|
693
|
-
let t = `${E(e.filePath, 2e3)}${e.lineNumber === null ? "" : `:${e.lineNumber}`}${e.columnNumber === null ? "" : `:${e.columnNumber}`}`;
|
|
694
|
-
return e.componentName ? `${E(e.componentName, 300)} (${t})` : t;
|
|
695
|
-
}
|
|
696
706
|
function k(e) {
|
|
707
|
+
let t = We(e);
|
|
697
708
|
return [
|
|
698
709
|
"# CommentKit Agent Context",
|
|
699
710
|
"",
|
|
700
|
-
|
|
711
|
+
v(e.instructions, 2e3),
|
|
701
712
|
"",
|
|
702
|
-
|
|
713
|
+
ee,
|
|
703
714
|
"",
|
|
704
|
-
`
|
|
705
|
-
|
|
706
|
-
...e.scope ? [`Scope: loaded comments; branch ${E(e.scope.activeBranch ?? "all branches", 300)}; ${e.scope.currentPageOnly ? "current page" : "all loaded pages"}; ${e.scope.includeResolved ? "all statuses" : "open only"}.`, ...e.scope.truncated || e.scope.hasMoreOnServer ? ["Incomplete snapshot: additional matching or unloaded comments are not included."] : []] : [],
|
|
715
|
+
`Comments: ${e.comments.length}`,
|
|
716
|
+
...e.scope?.truncated || e.scope?.hasMoreOnServer ? ["Incomplete snapshot: additional comments may be unloaded."] : [],
|
|
707
717
|
"",
|
|
708
|
-
...e.comments.map((e, t) => {
|
|
709
|
-
let n = e.element.found ? E(`${e.element.tagName}${e.element.id ? `#${e.element.id}` : ""}`, 500) : "not found", r = [
|
|
710
|
-
`## ${t + 1}. ${E(e.content, 300)}`,
|
|
711
|
-
`- Status: ${E(e.status, 40)}`,
|
|
712
|
-
`- Priority: ${E(e.priority, 40)}`,
|
|
713
|
-
`- Author: ${E(e.author.name, 300)} <${E(e.author.email, 320)}>`,
|
|
714
|
-
`- Page: ${E(e.page.url, 4e3)}`,
|
|
715
|
-
`- Element: ${n}`
|
|
716
|
-
];
|
|
717
|
-
return e.branch && r.push(`- Branch: ${E(e.branch, 300)}`), e.environment && r.push(`- Environment: ${E(e.environment, 40)}`), e.description && r.push(`- Description: ${E(e.description, 500)}`), e.textSelection && r.push(`- Highlighted text: ${E(e.textSelection.text, 500)}`), e.attachments?.length && r.push(`- Attachments: ${e.attachments.length} (full references in JSON)`), e.element.source && r.push(`- Source: ${Be(e.element.source)}`), e.element.stack && e.element.stack.length > 0 && r.push("- Stack:", ...e.element.stack.map((e) => ` - ${Be(e)}`)), e.element.source || r.push(`- Selector: ${E(e.element.selector ?? "none", 2e3)}`, `- XPath: ${E(e.element.xpath ?? "none", 2e3)}`), e.screenshotUrl && r.push(`- Screenshot: ${E(e.screenshotUrl, 4e3)}`), r.push(e.replies.length > 0 ? `- Replies: ${e.replies.length}` : "- Replies: 0", ""), r.join("\n");
|
|
718
|
-
}),
|
|
719
718
|
"```json",
|
|
720
|
-
JSON.stringify(
|
|
719
|
+
JSON.stringify(t, null, 2).replace(/[<>&`]/g, (e) => `\\u${e.charCodeAt(0).toString(16).padStart(4, "0")}`),
|
|
721
720
|
"```"
|
|
722
721
|
].join("\n");
|
|
723
722
|
}
|
|
724
|
-
function
|
|
723
|
+
function We(e) {
|
|
724
|
+
let t = 2e3, n = (e) => e.length > t ? `${e.slice(0, t)}… [clipped]` : e;
|
|
725
|
+
return {
|
|
726
|
+
version: e.version,
|
|
727
|
+
generatedAt: e.generatedAt,
|
|
728
|
+
page: {
|
|
729
|
+
title: e.page.title,
|
|
730
|
+
path: _(e.page.path),
|
|
731
|
+
url: _(e.page.url)
|
|
732
|
+
},
|
|
733
|
+
...e.project ? { project: e.project } : {},
|
|
734
|
+
scope: e.scope,
|
|
735
|
+
comments: e.comments.map((e) => ({
|
|
736
|
+
id: e.id,
|
|
737
|
+
type: e.type,
|
|
738
|
+
status: e.status,
|
|
739
|
+
priority: e.priority,
|
|
740
|
+
content: n(e.content),
|
|
741
|
+
...e.description ? { description: n(e.description) } : {},
|
|
742
|
+
author: e.author.name,
|
|
743
|
+
createdAt: e.createdAt,
|
|
744
|
+
...e.branch ? { branch: e.branch } : {},
|
|
745
|
+
...e.environment ? { environment: e.environment } : {},
|
|
746
|
+
page: {
|
|
747
|
+
title: e.page.title,
|
|
748
|
+
path: _(e.page.path),
|
|
749
|
+
url: _(e.page.url)
|
|
750
|
+
},
|
|
751
|
+
target: {
|
|
752
|
+
selector: e.element.selector,
|
|
753
|
+
xpath: e.element.xpath,
|
|
754
|
+
...e.element.text ? { text: y(e.element.text, 500) } : {},
|
|
755
|
+
source: e.element.source,
|
|
756
|
+
...e.textSelection?.text ? { highlightedText: e.textSelection.text } : {},
|
|
757
|
+
position: {
|
|
758
|
+
x: e.position.x,
|
|
759
|
+
y: e.position.y
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
...e.drawingData?.paths.length ? { drawing: {
|
|
763
|
+
viewport: e.drawingData.viewport,
|
|
764
|
+
pathCount: e.drawingData.paths.length,
|
|
765
|
+
paths: e.drawingData.paths.slice(0, 12).map((e) => ({
|
|
766
|
+
type: e.type,
|
|
767
|
+
x: e.x,
|
|
768
|
+
y: e.y,
|
|
769
|
+
width: e.width,
|
|
770
|
+
height: e.height,
|
|
771
|
+
...e.text ? { text: y(e.text, 200) } : {},
|
|
772
|
+
...e.d ? { bounds: Ge(e.d) } : {}
|
|
773
|
+
})),
|
|
774
|
+
...e.drawingData.paths.length > 12 ? { omittedPaths: e.drawingData.paths.length - 12 } : {}
|
|
775
|
+
} } : {},
|
|
776
|
+
...e.assignees?.length ? { assignees: e.assignees.map((e) => e.name) } : {},
|
|
777
|
+
...e.checklist?.length ? { checklist: e.checklist.map(({ label: e, done: t }) => ({
|
|
778
|
+
label: e,
|
|
779
|
+
done: t
|
|
780
|
+
})) } : {},
|
|
781
|
+
...e.attachments?.length ? { attachments: e.attachments.map(D) } : {},
|
|
782
|
+
replyCount: e.replies.length,
|
|
783
|
+
...e.replies.length > 12 ? { omittedReplies: e.replies.length - 12 } : {},
|
|
784
|
+
replies: e.replies.slice(-12).map((e) => ({
|
|
785
|
+
id: e.id,
|
|
786
|
+
content: n(e.content),
|
|
787
|
+
author: e.author.name,
|
|
788
|
+
createdAt: e.createdAt,
|
|
789
|
+
...e.replyTo ? { replyTo: {
|
|
790
|
+
type: e.replyTo.type,
|
|
791
|
+
body: e.replyTo.body
|
|
792
|
+
} } : {},
|
|
793
|
+
...e.attachments?.length ? { attachments: e.attachments.map(D) } : {}
|
|
794
|
+
}))
|
|
795
|
+
}))
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function Ge(e) {
|
|
799
|
+
let t = [...e.matchAll(/[ML]\s*(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)/gi)];
|
|
800
|
+
if (!t.length) return null;
|
|
801
|
+
let n = t.map((e) => Number(e[1])), r = t.map((e) => Number(e[2]));
|
|
802
|
+
return {
|
|
803
|
+
x: Math.min(...n),
|
|
804
|
+
y: Math.min(...r),
|
|
805
|
+
width: Math.max(...n) - Math.min(...n),
|
|
806
|
+
height: Math.max(...r) - Math.min(...r)
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
function Ke(e) {
|
|
725
810
|
return {
|
|
726
811
|
version: e?.version ?? 1,
|
|
727
812
|
generatedAt: e?.generatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
728
813
|
commentCount: e?.comments.length ?? 0,
|
|
729
|
-
context: e
|
|
814
|
+
context: e ? We(e) : null
|
|
730
815
|
};
|
|
731
816
|
}
|
|
732
|
-
function
|
|
817
|
+
function qe(e, t) {
|
|
733
818
|
if (typeof document > "u" || !document.body || typeof document.execCommand != "function") return !1;
|
|
734
819
|
let n = JSON.stringify(t), r = (t) => {
|
|
735
|
-
t.preventDefault(), t.clipboardData?.setData("text/plain", e), t.clipboardData?.setData("text/html", `<meta charset="utf-8"><pre><code>${
|
|
820
|
+
t.preventDefault(), t.clipboardData?.setData("text/plain", e), t.clipboardData?.setData("text/html", `<meta charset="utf-8"><pre><code>${Me(e)}</code></pre>`), t.clipboardData?.setData(Ae, n);
|
|
736
821
|
}, i = document.createElement("textarea");
|
|
737
822
|
i.value = e, i.setAttribute("readonly", ""), i.setAttribute("aria-hidden", "true"), i.style.position = "fixed", i.style.left = "-9999px", document.addEventListener("copy", r), document.body.appendChild(i), i.select();
|
|
738
823
|
try {
|
|
@@ -741,10 +826,10 @@ function He(e, t) {
|
|
|
741
826
|
document.removeEventListener("copy", r), i.remove();
|
|
742
827
|
}
|
|
743
828
|
}
|
|
744
|
-
async function
|
|
829
|
+
async function Je(e, t) {
|
|
745
830
|
if (typeof navigator > "u" || typeof navigator.clipboard?.write != "function" || typeof ClipboardItem > "u") return !1;
|
|
746
831
|
try {
|
|
747
|
-
let n = new Blob([`<meta charset="utf-8"><pre><code>${
|
|
832
|
+
let n = new Blob([`<meta charset="utf-8"><pre><code>${Me(e)}</code></pre>`], { type: "text/html" }), r = new Blob([e], { type: "text/plain" }), i = t.type && t.type.startsWith("image/") ? t.type : "image/png";
|
|
748
833
|
return await navigator.clipboard.write([new ClipboardItem({
|
|
749
834
|
"text/plain": r,
|
|
750
835
|
"text/html": n,
|
|
@@ -754,16 +839,16 @@ async function Ue(e, t) {
|
|
|
754
839
|
return !1;
|
|
755
840
|
}
|
|
756
841
|
}
|
|
757
|
-
async function
|
|
758
|
-
return t && await
|
|
842
|
+
async function Ye(e, t) {
|
|
843
|
+
return t && await Je(e, t) ? !0 : (await Xe(e), !1);
|
|
759
844
|
}
|
|
760
|
-
async function
|
|
761
|
-
if (!
|
|
845
|
+
async function Xe(e, t = null) {
|
|
846
|
+
if (!qe(e, Ke(t))) {
|
|
762
847
|
if (typeof navigator < "u" && typeof navigator.clipboard?.writeText == "function") await navigator.clipboard.writeText(e);
|
|
763
848
|
else throw Error("Clipboard is unavailable");
|
|
764
849
|
}
|
|
765
850
|
}
|
|
766
|
-
function
|
|
851
|
+
function Ze(e, t, n = null) {
|
|
767
852
|
let r = t.projectContext, i = n ?? (r?.permissions.canWriteComments === !1 ? r.permissions.writeRestriction ?? (r.organization?.plan === "none" ? "plan_required" : "feature_disabled") : null), a = i === "plan_required", o = !i && e.features?.comments !== !1;
|
|
768
853
|
return {
|
|
769
854
|
canWrite: o,
|
|
@@ -772,21 +857,25 @@ function Ke(e, t, n = null) {
|
|
|
772
857
|
message: o ? "" : a ? "This workspace is read-only. An active plan is required to add or change feedback. You can still read and export comments." : "Comment changes are disabled for this project. You can still read and export comments."
|
|
773
858
|
};
|
|
774
859
|
}
|
|
775
|
-
|
|
776
|
-
|
|
860
|
+
function A() {
|
|
861
|
+
for (let e of document.querySelectorAll("dialog:modal,[aria-modal=true]:is(dialog,[role$=dialog])")) if (e.getClientRects().length && getComputedStyle(e).visibility === "visible") return !0;
|
|
862
|
+
return !1;
|
|
863
|
+
}
|
|
864
|
+
var Qe = 100, $e = () => {};
|
|
865
|
+
function et(e) {
|
|
777
866
|
return typeof e == "function";
|
|
778
867
|
}
|
|
779
|
-
var
|
|
868
|
+
var tt = class {
|
|
780
869
|
constructor() {
|
|
781
870
|
this.listeners = /* @__PURE__ */ new Map(), this.onceWrappers = /* @__PURE__ */ new Map();
|
|
782
871
|
}
|
|
783
872
|
on(e, t) {
|
|
784
|
-
if (!
|
|
873
|
+
if (!et(t)) return console.warn(`[CommentKit] Ignoring non-function listener for '${String(e)}'`), $e;
|
|
785
874
|
let n = this.listeners.get(e);
|
|
786
|
-
return n || (n = /* @__PURE__ */ new Set(), this.listeners.set(e, n)), !n.has(t) && n.size >=
|
|
875
|
+
return n || (n = /* @__PURE__ */ new Set(), this.listeners.set(e, n)), !n.has(t) && n.size >= Qe && console.warn(`[CommentKit] Max listeners (${Qe}) reached for '${String(e)}' - possible memory leak`), n.add(t), () => this.off(e, t);
|
|
787
876
|
}
|
|
788
877
|
off(e, t) {
|
|
789
|
-
if (!
|
|
878
|
+
if (!et(t)) return;
|
|
790
879
|
let n = this.listeners.get(e);
|
|
791
880
|
if (n) {
|
|
792
881
|
n.delete(t);
|
|
@@ -803,7 +892,7 @@ var Xe = class {
|
|
|
803
892
|
}
|
|
804
893
|
}
|
|
805
894
|
once(e, t) {
|
|
806
|
-
if (!
|
|
895
|
+
if (!et(t)) return console.warn(`[CommentKit] Ignoring non-function listener for '${String(e)}'`), $e;
|
|
807
896
|
let n = (n) => {
|
|
808
897
|
this.off(e, t), t(n);
|
|
809
898
|
}, r = this.onceWrappers.get(e);
|
|
@@ -815,7 +904,7 @@ var Xe = class {
|
|
|
815
904
|
listenerCount(e) {
|
|
816
905
|
return this.listeners.get(e)?.size ?? 0;
|
|
817
906
|
}
|
|
818
|
-
},
|
|
907
|
+
}, nt = Symbol(), j = Object.freeze({
|
|
819
908
|
ID: 256,
|
|
820
909
|
CONTENT: 1e4,
|
|
821
910
|
REPLY_CONTENT: 5e3,
|
|
@@ -840,39 +929,39 @@ var Xe = class {
|
|
|
840
929
|
REACTION_COUNT: 1e6,
|
|
841
930
|
PENDING_MUTATIONS: 1e3,
|
|
842
931
|
RETRY_DELAY: 3e4
|
|
843
|
-
}),
|
|
844
|
-
function
|
|
932
|
+
}), rt = "commentkit:session:", it = 4096;
|
|
933
|
+
function at() {
|
|
845
934
|
try {
|
|
846
935
|
return typeof sessionStorage > "u" ? null : sessionStorage;
|
|
847
936
|
} catch {
|
|
848
937
|
return null;
|
|
849
938
|
}
|
|
850
939
|
}
|
|
851
|
-
function
|
|
852
|
-
return `${
|
|
940
|
+
function M(e) {
|
|
941
|
+
return `${rt}${e}`;
|
|
853
942
|
}
|
|
854
|
-
function
|
|
855
|
-
return
|
|
943
|
+
function ot(e) {
|
|
944
|
+
return o(e) && r(e.id, j.ID) && r(e.name, j.NAME) && typeof e.email == "string" && s(e.email, j.EMAIL);
|
|
856
945
|
}
|
|
857
|
-
function
|
|
858
|
-
return
|
|
946
|
+
function st(e) {
|
|
947
|
+
return o(e) && r(e.token, it) && typeof e.email == "string" && s(e.email, j.EMAIL) && ot(e.user);
|
|
859
948
|
}
|
|
860
|
-
function
|
|
949
|
+
function ct(e, t) {
|
|
861
950
|
if (!e) return;
|
|
862
|
-
let n =
|
|
951
|
+
let n = at();
|
|
863
952
|
if (n) try {
|
|
864
|
-
n.setItem(
|
|
953
|
+
n.setItem(M(e), JSON.stringify(t));
|
|
865
954
|
} catch {}
|
|
866
955
|
}
|
|
867
|
-
function
|
|
956
|
+
function lt(e) {
|
|
868
957
|
if (!e) return null;
|
|
869
|
-
let t =
|
|
958
|
+
let t = at();
|
|
870
959
|
if (!t) return null;
|
|
871
960
|
try {
|
|
872
|
-
let n = t.getItem(
|
|
961
|
+
let n = t.getItem(M(e));
|
|
873
962
|
if (!n) return null;
|
|
874
963
|
let r = JSON.parse(n);
|
|
875
|
-
return
|
|
964
|
+
return st(r) ? {
|
|
876
965
|
token: r.token.trim(),
|
|
877
966
|
email: r.email.trim(),
|
|
878
967
|
user: {
|
|
@@ -881,19 +970,19 @@ function it(e) {
|
|
|
881
970
|
email: r.user.email.trim(),
|
|
882
971
|
...r.user.avatar ? { avatar: r.user.avatar } : {}
|
|
883
972
|
}
|
|
884
|
-
} : (t.removeItem(
|
|
973
|
+
} : (t.removeItem(M(e)), null);
|
|
885
974
|
} catch {
|
|
886
975
|
return null;
|
|
887
976
|
}
|
|
888
977
|
}
|
|
889
|
-
function
|
|
978
|
+
function ut(e) {
|
|
890
979
|
if (!e) return;
|
|
891
|
-
let t =
|
|
980
|
+
let t = at();
|
|
892
981
|
if (t) try {
|
|
893
|
-
t.removeItem(
|
|
982
|
+
t.removeItem(M(e));
|
|
894
983
|
} catch {}
|
|
895
984
|
}
|
|
896
|
-
function
|
|
985
|
+
function dt(e, t) {
|
|
897
986
|
for (let n of e.getState().pendingMutations) e.emit("offline:failed", {
|
|
898
987
|
id: n.id,
|
|
899
988
|
error: {
|
|
@@ -903,35 +992,35 @@ function ot(e, t) {
|
|
|
903
992
|
}
|
|
904
993
|
});
|
|
905
994
|
}
|
|
906
|
-
var
|
|
907
|
-
function
|
|
995
|
+
var ft = j.EMAIL, pt = j.NAME, mt = j.ID, ht = 4096, gt = 6;
|
|
996
|
+
function _t(e) {
|
|
908
997
|
if (typeof e != "string") return null;
|
|
909
998
|
let t = e.trim();
|
|
910
|
-
return
|
|
999
|
+
return s(t, ft) ? t : null;
|
|
911
1000
|
}
|
|
912
|
-
function
|
|
913
|
-
return !
|
|
1001
|
+
function vt(e) {
|
|
1002
|
+
return !a(e) && e.trim().length === gt;
|
|
914
1003
|
}
|
|
915
|
-
function
|
|
916
|
-
return
|
|
1004
|
+
function yt(e) {
|
|
1005
|
+
return o(e) && r(e.id, mt) && r(e.name, pt) && typeof e.email == "string" && _t(e.email) !== null;
|
|
917
1006
|
}
|
|
918
|
-
function
|
|
919
|
-
return
|
|
1007
|
+
function bt(e) {
|
|
1008
|
+
return o(e) && r(e.id, mt);
|
|
920
1009
|
}
|
|
921
|
-
function
|
|
1010
|
+
function N(e, t, n) {
|
|
922
1011
|
return {
|
|
923
1012
|
error: e,
|
|
924
1013
|
message: t,
|
|
925
1014
|
code: n
|
|
926
1015
|
};
|
|
927
1016
|
}
|
|
928
|
-
async function
|
|
929
|
-
let r =
|
|
1017
|
+
async function xt(e, t, n = () => !0) {
|
|
1018
|
+
let r = _t(t);
|
|
930
1019
|
if (!r) e.setState({
|
|
931
1020
|
isLoading: !1,
|
|
932
1021
|
otpStep: "idle",
|
|
933
1022
|
otpEmail: null
|
|
934
|
-
}), e.handleError(
|
|
1023
|
+
}), e.handleError(N("invalid_email", "A valid email address is required", 400));
|
|
935
1024
|
else try {
|
|
936
1025
|
e.setState({
|
|
937
1026
|
isLoading: !0,
|
|
@@ -951,7 +1040,7 @@ async function gt(e, t, n = () => !0) {
|
|
|
951
1040
|
isLoading: !1,
|
|
952
1041
|
otpStep: "idle",
|
|
953
1042
|
otpEmail: null
|
|
954
|
-
}), e.handleError(
|
|
1043
|
+
}), e.handleError(N("otp_failed", "Failed to send OTP. Please try again.", 500)));
|
|
955
1044
|
} catch (t) {
|
|
956
1045
|
if (!n()) return;
|
|
957
1046
|
e.setState({
|
|
@@ -961,19 +1050,19 @@ async function gt(e, t, n = () => !0) {
|
|
|
961
1050
|
}), e.handleError(t);
|
|
962
1051
|
}
|
|
963
1052
|
}
|
|
964
|
-
async function
|
|
965
|
-
let { onAuthenticated:
|
|
966
|
-
if (!
|
|
967
|
-
else if (!
|
|
1053
|
+
async function St(e, t, n) {
|
|
1054
|
+
let { onAuthenticated: i, onWrongOtp: a, onSuccess: o, isCurrent: s = () => !0 } = typeof n == "function" ? { onAuthenticated: n } : n, c = e.getState().otpEmail;
|
|
1055
|
+
if (!c) e.handleError(N("no_email", "No OTP request in progress", 400));
|
|
1056
|
+
else if (!vt(t)) e.setState({ isLoading: !1 }), e.handleError(N("invalid_otp", "Invalid or expired OTP code", 401));
|
|
968
1057
|
else try {
|
|
969
1058
|
e.setState({
|
|
970
1059
|
isLoading: !0,
|
|
971
1060
|
error: null
|
|
972
1061
|
});
|
|
973
|
-
let n = await e.apiClient.verifyOtp(
|
|
974
|
-
if (!
|
|
975
|
-
if (n.verified &&
|
|
976
|
-
if (e.apiClient.setAuthToken(n.token), e.apiClient.setUserEmail(n.user.email),
|
|
1062
|
+
let n = await e.apiClient.verifyOtp(c, t);
|
|
1063
|
+
if (!s()) return;
|
|
1064
|
+
if (n.verified && r(n.token, ht) && yt(n.user) && bt(n.project)) {
|
|
1065
|
+
if (e.apiClient.setAuthToken(n.token), e.apiClient.setUserEmail(n.user.email), e.config.persistence !== "memory" && ct(e.config.projectId, {
|
|
977
1066
|
token: n.token,
|
|
978
1067
|
email: n.user.email,
|
|
979
1068
|
user: n.user
|
|
@@ -986,15 +1075,15 @@ async function _t(e, t, n) {
|
|
|
986
1075
|
isLoading: !1,
|
|
987
1076
|
otpStep: "idle",
|
|
988
1077
|
otpEmail: null
|
|
989
|
-
}),
|
|
990
|
-
await
|
|
991
|
-
} else e.setState({ isLoading: !1 }),
|
|
1078
|
+
}), o?.(), e.emit("auth:otp-verified", n.user), !s() || (e.emit("auth:login", n.user), !s())) return;
|
|
1079
|
+
await i();
|
|
1080
|
+
} else e.setState({ isLoading: !1 }), a?.(), e.handleError(N("invalid_otp", "Invalid or expired OTP code", 401));
|
|
992
1081
|
} catch (t) {
|
|
993
|
-
if (!
|
|
1082
|
+
if (!s()) return;
|
|
994
1083
|
e.setState({ isLoading: !1 }), e.handleError(t);
|
|
995
1084
|
}
|
|
996
1085
|
}
|
|
997
|
-
function
|
|
1086
|
+
function Ct(e) {
|
|
998
1087
|
e.setState({
|
|
999
1088
|
otpStep: "idle",
|
|
1000
1089
|
otpEmail: null,
|
|
@@ -1002,12 +1091,12 @@ function vt(e) {
|
|
|
1002
1091
|
isLoading: !1
|
|
1003
1092
|
});
|
|
1004
1093
|
}
|
|
1005
|
-
async function
|
|
1094
|
+
async function wt(e, t = () => !0) {
|
|
1006
1095
|
let n = e.getState().otpEmail;
|
|
1007
|
-
n && await
|
|
1096
|
+
n && await xt(e, n, t);
|
|
1008
1097
|
}
|
|
1009
|
-
function
|
|
1010
|
-
|
|
1098
|
+
function Tt(e, t) {
|
|
1099
|
+
dt(e, "Pending offline changes were discarded on logout"), ut(e.config.projectId), e.apiClient.setUserEmail(null), e.apiClient.setAuthToken(null), t(), e.setState({
|
|
1011
1100
|
isAuthenticated: !1,
|
|
1012
1101
|
currentUser: null,
|
|
1013
1102
|
comments: [],
|
|
@@ -1035,8 +1124,8 @@ function bt(e, t) {
|
|
|
1035
1124
|
isLoading: !1
|
|
1036
1125
|
}), e.emit("auth:logout", void 0);
|
|
1037
1126
|
}
|
|
1038
|
-
function
|
|
1039
|
-
|
|
1127
|
+
function Et(e) {
|
|
1128
|
+
dt(e, "Pending offline changes were discarded because the session expired"), ut(e.config.projectId), e.apiClient.setUserEmail(null), e.apiClient.setAuthToken(null), e.setState({
|
|
1040
1129
|
isAuthenticated: !1,
|
|
1041
1130
|
currentUser: null,
|
|
1042
1131
|
comments: [],
|
|
@@ -1059,17 +1148,17 @@ function xt(e) {
|
|
|
1059
1148
|
code: 401
|
|
1060
1149
|
});
|
|
1061
1150
|
}
|
|
1062
|
-
function
|
|
1151
|
+
function Dt(e) {
|
|
1063
1152
|
e.setState({ isLoginModalVisible: !e.getState().isLoginModalVisible });
|
|
1064
1153
|
}
|
|
1065
|
-
async function
|
|
1154
|
+
async function Ot(e, t, n, r = () => !0) {
|
|
1066
1155
|
let i = e.config.inviteToken;
|
|
1067
1156
|
if (!i) {
|
|
1068
|
-
e.handleError(
|
|
1157
|
+
e.handleError(N("no_invite", "No invite token found", 400));
|
|
1069
1158
|
return;
|
|
1070
1159
|
}
|
|
1071
|
-
let a =
|
|
1072
|
-
if (!a) e.setState({ isLoading: !1 }), e.handleError(
|
|
1160
|
+
let a = _t(t);
|
|
1161
|
+
if (!a) e.setState({ isLoading: !1 }), e.handleError(N("invalid_email", "A valid email address is required", 400));
|
|
1073
1162
|
else try {
|
|
1074
1163
|
e.setState({
|
|
1075
1164
|
isLoading: !0,
|
|
@@ -1077,17 +1166,17 @@ async function Ct(e, t, n, r = () => !0) {
|
|
|
1077
1166
|
});
|
|
1078
1167
|
let t = await e.apiClient.validateInvite(i, a);
|
|
1079
1168
|
if (!r()) return;
|
|
1080
|
-
t.success ? await n(a) : (e.setState({ isLoading: !1 }), e.handleError(
|
|
1169
|
+
t.success ? await n(a) : (e.setState({ isLoading: !1 }), e.handleError(N("invite_invalid", "Invite validation failed", 400)));
|
|
1081
1170
|
} catch (t) {
|
|
1082
1171
|
if (!r()) return;
|
|
1083
1172
|
e.setState({ isLoading: !1 }), e.handleError(t);
|
|
1084
1173
|
}
|
|
1085
1174
|
}
|
|
1086
|
-
function
|
|
1175
|
+
function P(e) {
|
|
1087
1176
|
return Object.freeze(e);
|
|
1088
1177
|
}
|
|
1089
|
-
var
|
|
1090
|
-
auth:
|
|
1178
|
+
var kt = Object.freeze({
|
|
1179
|
+
auth: P([
|
|
1091
1180
|
"isAuthenticated",
|
|
1092
1181
|
"currentUser",
|
|
1093
1182
|
"project",
|
|
@@ -1096,7 +1185,7 @@ var wt = Object.freeze({
|
|
|
1096
1185
|
"otpStep",
|
|
1097
1186
|
"otpEmail"
|
|
1098
1187
|
]),
|
|
1099
|
-
ui:
|
|
1188
|
+
ui: P([
|
|
1100
1189
|
"isOverlayVisible",
|
|
1101
1190
|
"isSidebarVisible",
|
|
1102
1191
|
"isShortcutsOverlayVisible",
|
|
@@ -1114,24 +1203,24 @@ var wt = Object.freeze({
|
|
|
1114
1203
|
"isLoading",
|
|
1115
1204
|
"error"
|
|
1116
1205
|
]),
|
|
1117
|
-
comments:
|
|
1206
|
+
comments: P([
|
|
1118
1207
|
"comments",
|
|
1119
1208
|
"pagination",
|
|
1120
1209
|
"seenThreadIds",
|
|
1121
1210
|
"activeBranch"
|
|
1122
1211
|
]),
|
|
1123
|
-
realtime:
|
|
1212
|
+
realtime: P([
|
|
1124
1213
|
"onlineUsers",
|
|
1125
1214
|
"connectionStatus",
|
|
1126
1215
|
"pendingMutations",
|
|
1127
1216
|
"isOnline"
|
|
1128
1217
|
])
|
|
1129
1218
|
});
|
|
1130
|
-
function
|
|
1219
|
+
function At() {
|
|
1131
1220
|
return typeof navigator < "u" && typeof navigator.onLine == "boolean" ? navigator.onLine : !0;
|
|
1132
1221
|
}
|
|
1133
|
-
var
|
|
1134
|
-
function
|
|
1222
|
+
var jt = 2e3;
|
|
1223
|
+
function Mt() {
|
|
1135
1224
|
return {
|
|
1136
1225
|
isAuthenticated: !1,
|
|
1137
1226
|
isOverlayVisible: !0,
|
|
@@ -1163,59 +1252,59 @@ function Dt() {
|
|
|
1163
1252
|
otpEmail: null,
|
|
1164
1253
|
pagination: null,
|
|
1165
1254
|
pendingMutations: [],
|
|
1166
|
-
isOnline:
|
|
1255
|
+
isOnline: At()
|
|
1167
1256
|
};
|
|
1168
1257
|
}
|
|
1169
|
-
function
|
|
1258
|
+
function F(e) {
|
|
1170
1259
|
let t = e.config.branch ?? e.getState().activeBranch;
|
|
1171
|
-
if (!(typeof t != "string" || t.length > 255 ||
|
|
1260
|
+
if (!(typeof t != "string" || t.length > 255 || a(t))) return t.trim() || void 0;
|
|
1172
1261
|
}
|
|
1173
|
-
var
|
|
1262
|
+
var I = j.ID, Nt = j.CONTENT, Pt = j.REPLY_CONTENT, Ft = j.SELECTOR, It = j.TEXT_SELECTION, Lt = j.DESCRIPTION, Rt = j.ASSIGNEES, zt = j.CHECKLIST_ITEMS, Bt = j.CHECKLIST_LABEL, Vt = j.DRAWING_PATHS, Ht = j.DRAWING_PATH_DATA, Ut = j.DRAWING_TEXT, Wt = j.REACTION_COUNT, Gt = j.EMOJI, Kt = /* @__PURE__ */ new Set([
|
|
1174
1263
|
"pin",
|
|
1175
1264
|
"highlight",
|
|
1176
1265
|
"drawing"
|
|
1177
|
-
]),
|
|
1266
|
+
]), qt = /* @__PURE__ */ new Set([
|
|
1178
1267
|
"low",
|
|
1179
1268
|
"medium",
|
|
1180
1269
|
"high",
|
|
1181
1270
|
"urgent"
|
|
1182
|
-
]),
|
|
1271
|
+
]), Jt = /* @__PURE__ */ new Set([
|
|
1183
1272
|
"open",
|
|
1184
1273
|
"resolved",
|
|
1185
1274
|
"complete"
|
|
1186
|
-
]),
|
|
1275
|
+
]), Yt = /* @__PURE__ */ new Set([
|
|
1187
1276
|
"path",
|
|
1188
1277
|
"line",
|
|
1189
1278
|
"rectangle",
|
|
1190
1279
|
"circle",
|
|
1191
1280
|
"text"
|
|
1192
1281
|
]);
|
|
1193
|
-
function
|
|
1282
|
+
function L(e, t, n) {
|
|
1194
1283
|
e.handleError(new T(t, n, 400));
|
|
1195
1284
|
}
|
|
1196
|
-
function
|
|
1197
|
-
return
|
|
1285
|
+
function R(e) {
|
|
1286
|
+
return r(e, I);
|
|
1198
1287
|
}
|
|
1199
|
-
function
|
|
1288
|
+
function z(e, t = Nt) {
|
|
1200
1289
|
if (typeof e != "string") return null;
|
|
1201
1290
|
let n = e.trim();
|
|
1202
|
-
return !n || n.length > t ||
|
|
1291
|
+
return !n || n.length > t || c(n) ? null : n;
|
|
1203
1292
|
}
|
|
1204
|
-
function
|
|
1293
|
+
function B(e, t) {
|
|
1205
1294
|
if (e === void 0) return;
|
|
1206
1295
|
if (typeof e != "string") return null;
|
|
1207
1296
|
let n = e.trim();
|
|
1208
|
-
return n.length > t ||
|
|
1297
|
+
return n.length > t || c(n) ? null : n;
|
|
1209
1298
|
}
|
|
1210
|
-
function
|
|
1299
|
+
function V(e) {
|
|
1211
1300
|
if (e === void 0) return;
|
|
1212
1301
|
if (typeof e != "string") return null;
|
|
1213
1302
|
let t = e.trim();
|
|
1214
|
-
return !t || t.length >
|
|
1303
|
+
return !t || t.length > Ft || c(t) ? null : t;
|
|
1215
1304
|
}
|
|
1216
|
-
function
|
|
1217
|
-
if (!
|
|
1218
|
-
let n =
|
|
1305
|
+
function Xt(t) {
|
|
1306
|
+
if (!o(t) || !e(t.x) || !e(t.y)) return null;
|
|
1307
|
+
let n = V(t.element), r = V(t.xpath);
|
|
1219
1308
|
return n === null || r === null ? null : {
|
|
1220
1309
|
x: t.x,
|
|
1221
1310
|
y: t.y,
|
|
@@ -1223,10 +1312,10 @@ function Gt(t) {
|
|
|
1223
1312
|
...r === void 0 ? {} : { xpath: r }
|
|
1224
1313
|
};
|
|
1225
1314
|
}
|
|
1226
|
-
function
|
|
1227
|
-
if (!
|
|
1228
|
-
let t =
|
|
1229
|
-
return !
|
|
1315
|
+
function Zt(e) {
|
|
1316
|
+
if (!o(e)) return null;
|
|
1317
|
+
let t = B(e.avatar, Ft), n = B(e.organizationId, I);
|
|
1318
|
+
return !R(e.id) || typeof e.name != "string" || !e.name.trim() || e.name.length > j.NAME || c(e.name) || typeof e.email != "string" || !e.email.trim() || e.email.length > j.EMAIL || /\s/.test(e.email.trim()) || c(e.email) || t === null || n === null ? null : {
|
|
1230
1319
|
id: e.id.trim(),
|
|
1231
1320
|
name: e.name.trim(),
|
|
1232
1321
|
email: e.email.trim(),
|
|
@@ -1234,25 +1323,25 @@ function Kt(e) {
|
|
|
1234
1323
|
...n === void 0 ? {} : { organizationId: n }
|
|
1235
1324
|
};
|
|
1236
1325
|
}
|
|
1237
|
-
function
|
|
1326
|
+
function Qt(e) {
|
|
1238
1327
|
if (e === void 0) return;
|
|
1239
|
-
if (!Array.isArray(e) || e.length >
|
|
1328
|
+
if (!Array.isArray(e) || e.length > Rt) return null;
|
|
1240
1329
|
let t = [];
|
|
1241
1330
|
for (let n of e) {
|
|
1242
|
-
let e =
|
|
1331
|
+
let e = Zt(n);
|
|
1243
1332
|
if (!e) return null;
|
|
1244
1333
|
t.push(e);
|
|
1245
1334
|
}
|
|
1246
1335
|
return t;
|
|
1247
1336
|
}
|
|
1248
|
-
function
|
|
1337
|
+
function $t(e) {
|
|
1249
1338
|
if (e === void 0) return;
|
|
1250
|
-
if (!Array.isArray(e) || e.length >
|
|
1339
|
+
if (!Array.isArray(e) || e.length > zt) return null;
|
|
1251
1340
|
let t = [];
|
|
1252
1341
|
for (let n of e) {
|
|
1253
|
-
if (!
|
|
1254
|
-
let e =
|
|
1255
|
-
if (!
|
|
1342
|
+
if (!o(n)) return null;
|
|
1343
|
+
let e = z(n.label);
|
|
1344
|
+
if (!R(n.id) || !e || typeof n.done != "boolean" || n.sortOrder !== void 0 && (typeof n.sortOrder != "number" || !Number.isFinite(n.sortOrder)) || e.length > Bt) return null;
|
|
1256
1345
|
t.push({
|
|
1257
1346
|
id: n.id.trim(),
|
|
1258
1347
|
label: e,
|
|
@@ -1262,11 +1351,11 @@ function Jt(e) {
|
|
|
1262
1351
|
}
|
|
1263
1352
|
return t;
|
|
1264
1353
|
}
|
|
1265
|
-
function
|
|
1354
|
+
function en(e) {
|
|
1266
1355
|
if (e === void 0) return;
|
|
1267
|
-
if (!
|
|
1268
|
-
let t = e.text.trim(), n =
|
|
1269
|
-
return !t || t.length >
|
|
1356
|
+
if (!o(e) || typeof e.text != "string") return null;
|
|
1357
|
+
let t = e.text.trim(), n = V(e.element), r = V(e.xpath);
|
|
1358
|
+
return !t || t.length > It || c(t) || typeof e.startOffset != "number" || typeof e.endOffset != "number" || !Number.isInteger(e.startOffset) || !Number.isInteger(e.endOffset) || e.startOffset < 0 || e.endOffset < e.startOffset || n === null || r === null || n === void 0 || r === void 0 ? null : {
|
|
1270
1359
|
text: t,
|
|
1271
1360
|
startOffset: e.startOffset,
|
|
1272
1361
|
endOffset: e.endOffset,
|
|
@@ -1274,20 +1363,20 @@ function Yt(e) {
|
|
|
1274
1363
|
xpath: r
|
|
1275
1364
|
};
|
|
1276
1365
|
}
|
|
1277
|
-
function
|
|
1278
|
-
return typeof e == "string" && e.length > 0 && e.length <=
|
|
1366
|
+
function tn(e) {
|
|
1367
|
+
return typeof e == "string" && e.length > 0 && e.length <= j.COLOR && t(e);
|
|
1279
1368
|
}
|
|
1280
|
-
function
|
|
1369
|
+
function H(e) {
|
|
1281
1370
|
return e === void 0 || typeof e == "number" && Number.isFinite(e);
|
|
1282
1371
|
}
|
|
1283
|
-
function
|
|
1372
|
+
function nn(e) {
|
|
1284
1373
|
if (e === void 0) return;
|
|
1285
|
-
if (!
|
|
1374
|
+
if (!o(e) || e.type !== "svg" || !Array.isArray(e.paths) || e.paths.length > Vt || !o(e.viewport) || typeof e.viewport.width != "number" || typeof e.viewport.height != "number" || !Number.isFinite(e.viewport.width) || !Number.isFinite(e.viewport.height) || e.viewport.width <= 0 || e.viewport.height <= 0) return null;
|
|
1286
1375
|
let t = [];
|
|
1287
1376
|
for (let n of e.paths) {
|
|
1288
|
-
if (!
|
|
1289
|
-
let e =
|
|
1290
|
-
if (!
|
|
1377
|
+
if (!o(n) || !Yt.has(String(n.type))) return null;
|
|
1378
|
+
let e = B(n.text, Ut);
|
|
1379
|
+
if (!tn(n.stroke) || !tn(n.fill) || typeof n.strokeWidth != "number" || !Number.isFinite(n.strokeWidth) || n.strokeWidth < 0 || n.d !== void 0 && (typeof n.d != "string" || n.d.length > Ht || c(n.d)) || !H(n.x) || !H(n.y) || !H(n.width) || !H(n.height) || e === null) return null;
|
|
1291
1380
|
t.push({
|
|
1292
1381
|
type: n.type,
|
|
1293
1382
|
stroke: n.stroke,
|
|
@@ -1310,81 +1399,81 @@ function Zt(e) {
|
|
|
1310
1399
|
}
|
|
1311
1400
|
};
|
|
1312
1401
|
}
|
|
1313
|
-
function
|
|
1314
|
-
return
|
|
1402
|
+
function rn(e) {
|
|
1403
|
+
return o(e) && typeof e.browser == "string" && e.browser.length <= 255 && typeof e.os == "string" && e.os.length <= 255 && typeof e.windowSize == "string" && e.windowSize.length <= 64 && typeof e.devicePixelRatio == "number" && e.devicePixelRatio > 0 && e.devicePixelRatio <= 16 && (e.type === "desktop" || e.type === "mobile") && (e.deployment === void 0 || typeof e.deployment == "string" && e.deployment.length <= 255);
|
|
1315
1404
|
}
|
|
1316
|
-
function
|
|
1405
|
+
function an(e) {
|
|
1317
1406
|
if (e === void 0) return;
|
|
1318
|
-
if (!
|
|
1319
|
-
let t =
|
|
1407
|
+
if (!o(e)) return null;
|
|
1408
|
+
let t = B(e.description, Lt), n = Qt(e.assignees), r = $t(e.checklist);
|
|
1320
1409
|
if (t === null || n === null || r === null) return null;
|
|
1321
|
-
let i = Array.isArray(e.files) ? e.files.filter((e) => typeof File < "u" && e instanceof File) : void 0,
|
|
1410
|
+
let i = Array.isArray(e.files) ? e.files.filter((e) => typeof File < "u" && e instanceof File) : void 0, a = Array.isArray(e.attachmentIds) ? e.attachmentIds.map((e) => String(e).trim()).filter((e) => e.length > 0 && e.length <= I).slice(0, 20) : void 0;
|
|
1322
1411
|
return {
|
|
1323
|
-
...Array.isArray(e.mentions) ? { mentions: e.mentions.filter((e) =>
|
|
1324
|
-
...typeof e.branch == "string" && e.branch.trim() && e.branch.length <= 255 && !
|
|
1325
|
-
...
|
|
1412
|
+
...Array.isArray(e.mentions) ? { mentions: e.mentions.filter((e) => o(e) && R(e.userId) && typeof e.name == "string").slice(0, 100) } : {},
|
|
1413
|
+
...typeof e.branch == "string" && e.branch.trim() && e.branch.length <= 255 && !c(e.branch) ? { branch: e.branch.trim() } : {},
|
|
1414
|
+
...rn(e.deviceInfo) ? { deviceInfo: e.deviceInfo } : {},
|
|
1326
1415
|
...t === void 0 ? {} : { description: t },
|
|
1327
1416
|
...n === void 0 ? {} : { assignees: n },
|
|
1328
1417
|
...r === void 0 ? {} : { checklist: r },
|
|
1329
1418
|
...i && i.length > 0 ? { files: i } : {},
|
|
1330
|
-
...
|
|
1419
|
+
...a && a.length > 0 ? { attachmentIds: a } : {}
|
|
1331
1420
|
};
|
|
1332
1421
|
}
|
|
1333
|
-
function
|
|
1334
|
-
if (!
|
|
1422
|
+
function on(e) {
|
|
1423
|
+
if (!o(e)) return null;
|
|
1335
1424
|
let t = {};
|
|
1336
1425
|
if ("content" in e) {
|
|
1337
|
-
let n =
|
|
1426
|
+
let n = z(e.content);
|
|
1338
1427
|
if (!n) return null;
|
|
1339
1428
|
t.content = n;
|
|
1340
1429
|
}
|
|
1341
1430
|
if ("status" in e) {
|
|
1342
|
-
if (!
|
|
1431
|
+
if (!Jt.has(e.status)) return null;
|
|
1343
1432
|
t.status = e.status;
|
|
1344
1433
|
}
|
|
1345
1434
|
if ("priority" in e) {
|
|
1346
|
-
if (!
|
|
1435
|
+
if (!qt.has(e.priority)) return null;
|
|
1347
1436
|
t.priority = e.priority;
|
|
1348
1437
|
}
|
|
1349
1438
|
if ("description" in e) {
|
|
1350
|
-
let n =
|
|
1439
|
+
let n = B(e.description, Lt);
|
|
1351
1440
|
if (n === null) return null;
|
|
1352
1441
|
t.description = n;
|
|
1353
1442
|
}
|
|
1354
|
-
if (Array.isArray(e.mentions) && (t.mentions = e.mentions.filter((e) =>
|
|
1355
|
-
let n =
|
|
1443
|
+
if (Array.isArray(e.mentions) && (t.mentions = e.mentions.filter((e) => o(e) && R(e.userId) && typeof e.name == "string").slice(0, 100)), "assignees" in e) {
|
|
1444
|
+
let n = Qt(e.assignees);
|
|
1356
1445
|
if (n === null) return null;
|
|
1357
1446
|
t.assignees = n;
|
|
1358
1447
|
}
|
|
1359
1448
|
if ("checklist" in e) {
|
|
1360
|
-
let n =
|
|
1449
|
+
let n = $t(e.checklist);
|
|
1361
1450
|
if (n === null) return null;
|
|
1362
1451
|
t.checklist = n;
|
|
1363
1452
|
}
|
|
1364
1453
|
if ("textSelection" in e) {
|
|
1365
|
-
let n =
|
|
1454
|
+
let n = en(e.textSelection);
|
|
1366
1455
|
if (n === null) return null;
|
|
1367
1456
|
t.textSelection = n;
|
|
1368
1457
|
}
|
|
1369
1458
|
if ("drawingData" in e) {
|
|
1370
|
-
let n =
|
|
1459
|
+
let n = nn(e.drawingData);
|
|
1371
1460
|
if (n === null) return null;
|
|
1372
1461
|
t.drawingData = n;
|
|
1373
1462
|
}
|
|
1374
1463
|
if ("attachmentIds" in e) {
|
|
1375
1464
|
let n = e.attachmentIds;
|
|
1376
1465
|
if (!Array.isArray(n)) return null;
|
|
1377
|
-
t.attachmentIds = n.map((e) => String(e).trim()).filter((e) => e.length > 0 && e.length <=
|
|
1466
|
+
t.attachmentIds = n.map((e) => String(e).trim()).filter((e) => e.length > 0 && e.length <= I).slice(0, 20);
|
|
1378
1467
|
}
|
|
1379
1468
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
1380
1469
|
}
|
|
1381
|
-
function
|
|
1470
|
+
function U(e) {
|
|
1382
1471
|
return `${e}_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
1383
1472
|
}
|
|
1384
|
-
function
|
|
1473
|
+
function W(e, t) {
|
|
1385
1474
|
return e.getState().comments.some((e) => e.id === t);
|
|
1386
1475
|
}
|
|
1387
|
-
function
|
|
1476
|
+
function G(e, t, n) {
|
|
1388
1477
|
if (e.getState().activeBranch && n.branch !== e.getState().activeBranch) {
|
|
1389
1478
|
e.setState({ comments: e.getState().comments.filter((e) => e.id !== t) });
|
|
1390
1479
|
return;
|
|
@@ -1392,7 +1481,7 @@ function W(e, t, n) {
|
|
|
1392
1481
|
let r = e.getState().comments.filter((e) => e.id !== n.id), i = r.some((e) => e.id === t);
|
|
1393
1482
|
e.setState({ comments: i ? r.map((e) => e.id === t ? n : e) : [...r, n] });
|
|
1394
1483
|
}
|
|
1395
|
-
function
|
|
1484
|
+
function sn(e, t, n, r) {
|
|
1396
1485
|
e.setState({ comments: e.getState().comments.map((e) => {
|
|
1397
1486
|
if (e.id !== t) return e;
|
|
1398
1487
|
let i = e.replies.filter((e) => e.id !== r.id), a = i.some((e) => e.id === n);
|
|
@@ -1405,7 +1494,7 @@ function tn(e, t, n, r) {
|
|
|
1405
1494
|
};
|
|
1406
1495
|
}) });
|
|
1407
1496
|
}
|
|
1408
|
-
function
|
|
1497
|
+
function K(e, t) {
|
|
1409
1498
|
return !t || t === e.status ? e : {
|
|
1410
1499
|
...e,
|
|
1411
1500
|
status: t,
|
|
@@ -1413,10 +1502,10 @@ function G(e, t) {
|
|
|
1413
1502
|
...t === "complete" ? {} : { resolvedAt: void 0 }
|
|
1414
1503
|
};
|
|
1415
1504
|
}
|
|
1416
|
-
function
|
|
1505
|
+
function cn(e, t, n) {
|
|
1417
1506
|
return e.getState().comments.some((e) => e.id === t && e.replies.some((e) => e.id === n));
|
|
1418
1507
|
}
|
|
1419
|
-
async function
|
|
1508
|
+
async function ln(e) {
|
|
1420
1509
|
let t = e.getState().activeBranch;
|
|
1421
1510
|
e.setState({ isLoading: !0 });
|
|
1422
1511
|
try {
|
|
@@ -1432,7 +1521,7 @@ async function rn(e) {
|
|
|
1432
1521
|
e.setState({ isLoading: !1 });
|
|
1433
1522
|
}
|
|
1434
1523
|
}
|
|
1435
|
-
async function
|
|
1524
|
+
async function un(e, t) {
|
|
1436
1525
|
let n = e.getState().activeBranch, r = e.getState().pagination;
|
|
1437
1526
|
if (r && r.hasMore && !t.current) {
|
|
1438
1527
|
t.current = !0;
|
|
@@ -1453,28 +1542,28 @@ async function an(e, t) {
|
|
|
1453
1542
|
}
|
|
1454
1543
|
}
|
|
1455
1544
|
}
|
|
1456
|
-
async function
|
|
1545
|
+
async function dn(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
1457
1546
|
let u = e.getState().currentUser;
|
|
1458
1547
|
if (!u) return;
|
|
1459
|
-
let
|
|
1460
|
-
if (!
|
|
1461
|
-
|
|
1548
|
+
let d = z(i), f = Xt(a), p = en(s), h = nn(c), g = an(l);
|
|
1549
|
+
if (!Kt.has(r) || !d || !f || !qt.has(o) || p === null || h === null || g === null) {
|
|
1550
|
+
L(e, "invalid_comment", "Comment data is invalid");
|
|
1462
1551
|
return;
|
|
1463
1552
|
}
|
|
1464
|
-
let _ = `create:${r}:${
|
|
1553
|
+
let _ = `create:${r}:${d.slice(0, 50)}:${f.x}:${f.y}`;
|
|
1465
1554
|
if (n.has(_)) return;
|
|
1466
1555
|
n.add(_);
|
|
1467
|
-
let v =
|
|
1468
|
-
id:
|
|
1556
|
+
let v = m(), y = g?.files ?? [], ee = y.map((e, t) => ({
|
|
1557
|
+
id: U(`pending-att-${t}`),
|
|
1469
1558
|
type: e.type.startsWith("image/") ? "screenshot" : "file",
|
|
1470
1559
|
url: "",
|
|
1471
1560
|
filename: e.name,
|
|
1472
1561
|
size: e.size
|
|
1473
|
-
})), b =
|
|
1562
|
+
})), b = U("temp"), te = {
|
|
1474
1563
|
id: b,
|
|
1475
1564
|
type: r,
|
|
1476
|
-
content:
|
|
1477
|
-
position:
|
|
1565
|
+
content: d,
|
|
1566
|
+
position: f,
|
|
1478
1567
|
status: "open",
|
|
1479
1568
|
priority: o,
|
|
1480
1569
|
author: u,
|
|
@@ -1494,7 +1583,7 @@ async function on(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1494
1583
|
checklist: g?.checklist,
|
|
1495
1584
|
replies: [],
|
|
1496
1585
|
attachments: ee,
|
|
1497
|
-
textSelection:
|
|
1586
|
+
textSelection: p,
|
|
1498
1587
|
drawingData: h
|
|
1499
1588
|
};
|
|
1500
1589
|
e.setState({
|
|
@@ -1506,7 +1595,7 @@ async function on(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1506
1595
|
isHighlightModeActive: !1
|
|
1507
1596
|
});
|
|
1508
1597
|
try {
|
|
1509
|
-
let { files: n, ...i } = g ?? {}, a = await e.apiClient.createComment(r,
|
|
1598
|
+
let { files: n, ...i } = g ?? {}, a = await e.apiClient.createComment(r, d, f, v, o, p, h, i, b), s = a;
|
|
1510
1599
|
if (y.length > 0) try {
|
|
1511
1600
|
let t = (await Promise.all(y.map(async (t) => {
|
|
1512
1601
|
let n = "." + (t.name.split(".").pop()?.toLowerCase() ?? ""), r = t.type.startsWith("image/") && [
|
|
@@ -1535,7 +1624,7 @@ async function on(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1535
1624
|
attachments: a.attachments ?? []
|
|
1536
1625
|
};
|
|
1537
1626
|
}
|
|
1538
|
-
|
|
1627
|
+
G(e, b, s), e.emit("comment:created", s), t.addActivity({
|
|
1539
1628
|
type: "comment_created",
|
|
1540
1629
|
threadId: s.id,
|
|
1541
1630
|
message: "created a new comment"
|
|
@@ -1543,10 +1632,10 @@ async function on(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1543
1632
|
} catch (n) {
|
|
1544
1633
|
t.shouldQueueMutation(n) && t.queueMutation("createComment", [
|
|
1545
1634
|
r,
|
|
1635
|
+
d,
|
|
1546
1636
|
f,
|
|
1547
|
-
p,
|
|
1548
1637
|
o,
|
|
1549
|
-
|
|
1638
|
+
p,
|
|
1550
1639
|
h,
|
|
1551
1640
|
g ? {
|
|
1552
1641
|
description: g.description,
|
|
@@ -1567,18 +1656,18 @@ async function on(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1567
1656
|
n.delete(_);
|
|
1568
1657
|
}
|
|
1569
1658
|
}
|
|
1570
|
-
async function
|
|
1571
|
-
if (!
|
|
1572
|
-
let i =
|
|
1659
|
+
async function fn(e, t, n, r) {
|
|
1660
|
+
if (!R(n)) return;
|
|
1661
|
+
let i = on(r);
|
|
1573
1662
|
if (i === null) {
|
|
1574
|
-
|
|
1663
|
+
L(e, "invalid_comment_update", "Comment update data is invalid");
|
|
1575
1664
|
return;
|
|
1576
1665
|
}
|
|
1577
1666
|
if (i === void 0) return;
|
|
1578
1667
|
let a = e.getState().comments, o = a.find((e) => e.id === n);
|
|
1579
1668
|
if (o) {
|
|
1580
1669
|
e.setState({ comments: a.map((e) => e.id === n ? {
|
|
1581
|
-
...
|
|
1670
|
+
...K(e, i.status),
|
|
1582
1671
|
...i
|
|
1583
1672
|
} : e) });
|
|
1584
1673
|
try {
|
|
@@ -1589,8 +1678,8 @@ async function sn(e, t, n, r) {
|
|
|
1589
1678
|
}
|
|
1590
1679
|
}
|
|
1591
1680
|
}
|
|
1592
|
-
async function
|
|
1593
|
-
if (!
|
|
1681
|
+
async function pn(e, t, n) {
|
|
1682
|
+
if (!R(n)) return;
|
|
1594
1683
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1595
1684
|
if (!i) return;
|
|
1596
1685
|
let a = e.getState().selectedComment;
|
|
@@ -1610,19 +1699,19 @@ async function cn(e, t, n) {
|
|
|
1610
1699
|
}
|
|
1611
1700
|
}
|
|
1612
1701
|
}
|
|
1613
|
-
async function
|
|
1702
|
+
async function mn(e, t, n, r, i) {
|
|
1614
1703
|
let a = e.getState().currentUser;
|
|
1615
|
-
if (!a || !
|
|
1616
|
-
let o =
|
|
1704
|
+
if (!a || !R(n) || !W(e, n)) return;
|
|
1705
|
+
let o = z(r, Pt);
|
|
1617
1706
|
if (!o) {
|
|
1618
|
-
|
|
1707
|
+
L(e, "invalid_reply", "Reply content is invalid");
|
|
1619
1708
|
return;
|
|
1620
1709
|
}
|
|
1621
|
-
if (i?.replyTo && (!
|
|
1622
|
-
|
|
1710
|
+
if (i?.replyTo && (!R(i.replyTo.id) || i.replyTo.id.startsWith("temp_") || !["comment", "reply"].includes(i.replyTo.type) || (i.replyTo.type === "comment" ? i.replyTo.id !== n : !cn(e, n, i.replyTo.id)))) {
|
|
1711
|
+
L(e, "invalid_reply", "Reply target must belong to this thread");
|
|
1623
1712
|
return;
|
|
1624
1713
|
}
|
|
1625
|
-
let s = e.getState().comments.find((e) => e.id === n), c = i?.replyTo?.type === "comment" ? s : s?.replies.find((e) => e.id === i?.replyTo?.id), l =
|
|
1714
|
+
let s = e.getState().comments.find((e) => e.id === n), c = i?.replyTo?.type === "comment" ? s : s?.replies.find((e) => e.id === i?.replyTo?.id), l = U("temp_reply"), u = {
|
|
1626
1715
|
...c && i?.replyTo ? { replyTo: {
|
|
1627
1716
|
...i.replyTo,
|
|
1628
1717
|
authorName: c.author.name,
|
|
@@ -1639,7 +1728,7 @@ async function ln(e, t, n, r, i) {
|
|
|
1639
1728
|
replies: [...e.replies, u]
|
|
1640
1729
|
} : e) });
|
|
1641
1730
|
try {
|
|
1642
|
-
|
|
1731
|
+
sn(e, n, l, await e.apiClient.addReply(n, o, l, ...i ? [i] : []));
|
|
1643
1732
|
let t = e.getState().comments.find((e) => e.id === n);
|
|
1644
1733
|
t && e.emit("comment:updated", t);
|
|
1645
1734
|
} catch (r) {
|
|
@@ -1653,11 +1742,11 @@ async function ln(e, t, n, r, i) {
|
|
|
1653
1742
|
} : e) }), e.handleError(r));
|
|
1654
1743
|
}
|
|
1655
1744
|
}
|
|
1656
|
-
async function
|
|
1657
|
-
if (!
|
|
1658
|
-
let a =
|
|
1745
|
+
async function hn(e, t, n, r, i) {
|
|
1746
|
+
if (!R(t) || !R(n) || !cn(e, t, n)) return;
|
|
1747
|
+
let a = z(r, Pt);
|
|
1659
1748
|
if (!a) {
|
|
1660
|
-
|
|
1749
|
+
L(e, "invalid_reply", "Reply content is invalid");
|
|
1661
1750
|
return;
|
|
1662
1751
|
}
|
|
1663
1752
|
let o = e.getState().comments, s = o.find((e) => e.id === t)?.replies.find((e) => e.id === n);
|
|
@@ -1684,8 +1773,8 @@ async function un(e, t, n, r, i) {
|
|
|
1684
1773
|
} : e) }), e.handleError(r);
|
|
1685
1774
|
}
|
|
1686
1775
|
}
|
|
1687
|
-
async function
|
|
1688
|
-
if (!
|
|
1776
|
+
async function gn(e, t, n) {
|
|
1777
|
+
if (!R(t) || !R(n) || !cn(e, t, n)) return;
|
|
1689
1778
|
let r = e.getState().comments, i = r.find((e) => e.id === t)?.replies.find((e) => e.id === n);
|
|
1690
1779
|
e.setState({ comments: r.map((e) => e.id === t ? {
|
|
1691
1780
|
...e,
|
|
@@ -1702,10 +1791,10 @@ async function dn(e, t, n) {
|
|
|
1702
1791
|
} : e) }), e.handleError(r);
|
|
1703
1792
|
}
|
|
1704
1793
|
}
|
|
1705
|
-
async function
|
|
1706
|
-
if (!
|
|
1794
|
+
async function _n(e, t, n) {
|
|
1795
|
+
if (!R(n) || !W(e, n)) return;
|
|
1707
1796
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1708
|
-
e.setState({ comments: r.map((e) => e.id === n ?
|
|
1797
|
+
e.setState({ comments: r.map((e) => e.id === n ? K(e, "resolved") : e) });
|
|
1709
1798
|
try {
|
|
1710
1799
|
let r = await e.apiClient.resolveComment(n);
|
|
1711
1800
|
e.setState({ comments: e.getState().comments.map((e) => e.id === n ? r : e) }), e.emit("comment:resolved", r), e.emit("comment:updated", r), t.addActivity({
|
|
@@ -1717,10 +1806,10 @@ async function fn(e, t, n) {
|
|
|
1717
1806
|
t.shouldQueueMutation(r) && t.queueMutation("resolveComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
|
|
1718
1807
|
}
|
|
1719
1808
|
}
|
|
1720
|
-
async function
|
|
1721
|
-
if (!
|
|
1809
|
+
async function vn(e, t, n) {
|
|
1810
|
+
if (!R(n) || !W(e, n)) return;
|
|
1722
1811
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1723
|
-
e.setState({ comments: r.map((e) => e.id === n ?
|
|
1812
|
+
e.setState({ comments: r.map((e) => e.id === n ? K(e, "open") : e) });
|
|
1724
1813
|
try {
|
|
1725
1814
|
let t = await e.apiClient.unresolveComment(n);
|
|
1726
1815
|
e.setState({ comments: e.getState().comments.map((e) => e.id === n ? t : e) }), e.emit("comment:updated", t);
|
|
@@ -1728,10 +1817,10 @@ async function pn(e, t, n) {
|
|
|
1728
1817
|
t.shouldQueueMutation(r) && t.queueMutation("unresolveComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
|
|
1729
1818
|
}
|
|
1730
1819
|
}
|
|
1731
|
-
async function
|
|
1732
|
-
if (!
|
|
1820
|
+
async function yn(e, t, n) {
|
|
1821
|
+
if (!R(n) || !W(e, n)) return;
|
|
1733
1822
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1734
|
-
e.setState({ comments: r.map((e) => e.id === n ?
|
|
1823
|
+
e.setState({ comments: r.map((e) => e.id === n ? K(e, "complete") : e) });
|
|
1735
1824
|
try {
|
|
1736
1825
|
let r = await e.apiClient.markComplete(n);
|
|
1737
1826
|
e.setState({ comments: e.getState().comments.map((e) => e.id === n ? r : e) }), e.emit("comment:completed", r), t.addActivity({
|
|
@@ -1743,15 +1832,15 @@ async function mn(e, t, n) {
|
|
|
1743
1832
|
t.shouldQueueMutation(r) && t.queueMutation("completeComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
|
|
1744
1833
|
}
|
|
1745
1834
|
}
|
|
1746
|
-
async function
|
|
1747
|
-
if (!
|
|
1835
|
+
async function bn(e, t, n, r, i) {
|
|
1836
|
+
if (!R(n) || typeof r != "string") return;
|
|
1748
1837
|
let a = r.trim();
|
|
1749
|
-
if (!a || a.length >
|
|
1750
|
-
let
|
|
1838
|
+
if (!a || a.length > Gt || c(a)) return;
|
|
1839
|
+
let o = e.getState().comments.find((e) => e.id === n);
|
|
1840
|
+
if (!o) return;
|
|
1841
|
+
let s = i ? o.replies.find((e) => e.id === i) : o;
|
|
1751
1842
|
if (!s) return;
|
|
1752
|
-
let
|
|
1753
|
-
if (!c) return;
|
|
1754
|
-
let l = (c.reactions ?? []).filter((e) => typeof e.emoji == "string" && e.emoji.length > 0 && e.emoji.length <= Bt && !o(e.emoji) && typeof e.count == "number" && Number.isInteger(e.count) && e.count >= 0 && e.count <= zt), u = l.find((e) => e.emoji === a)?.reacted, d = [...l];
|
|
1843
|
+
let l = (s.reactions ?? []).filter((e) => typeof e.emoji == "string" && e.emoji.length > 0 && e.emoji.length <= Gt && !c(e.emoji) && typeof e.count == "number" && Number.isInteger(e.count) && e.count >= 0 && e.count <= Wt), u = l.find((e) => e.emoji === a)?.reacted, d = [...l];
|
|
1755
1844
|
if (u) {
|
|
1756
1845
|
let e = d.findIndex((e) => e.emoji === a), t = d[e];
|
|
1757
1846
|
t.count <= 1 ? d.splice(e, 1) : d[e] = {
|
|
@@ -1763,7 +1852,7 @@ async function hn(e, t, n, r, i) {
|
|
|
1763
1852
|
let e = d.findIndex((e) => e.emoji === a), t = e === -1 ? void 0 : d[e];
|
|
1764
1853
|
t ? d[e] = {
|
|
1765
1854
|
...t,
|
|
1766
|
-
count: Math.min(t.count + 1,
|
|
1855
|
+
count: Math.min(t.count + 1, Wt),
|
|
1767
1856
|
reacted: !0
|
|
1768
1857
|
} : d.push({
|
|
1769
1858
|
emoji: a,
|
|
@@ -1808,14 +1897,14 @@ async function hn(e, t, n, r, i) {
|
|
|
1808
1897
|
} : e) }), e.handleError(r));
|
|
1809
1898
|
}
|
|
1810
1899
|
}
|
|
1811
|
-
async function
|
|
1812
|
-
if (!
|
|
1813
|
-
let a =
|
|
1900
|
+
async function xn(e, t, n, r, i) {
|
|
1901
|
+
if (!R(n) || !W(e, n)) return;
|
|
1902
|
+
let a = Xt({
|
|
1814
1903
|
x: r,
|
|
1815
1904
|
y: i
|
|
1816
1905
|
});
|
|
1817
1906
|
if (!a) {
|
|
1818
|
-
|
|
1907
|
+
L(e, "invalid_position", "Comment position is invalid");
|
|
1819
1908
|
return;
|
|
1820
1909
|
}
|
|
1821
1910
|
let o = e.getState().comments, s = o.find((e) => e.id === n);
|
|
@@ -1836,22 +1925,22 @@ async function gn(e, t, n, r, i) {
|
|
|
1836
1925
|
} : e) }), e.handleError(r));
|
|
1837
1926
|
}
|
|
1838
1927
|
}
|
|
1839
|
-
function
|
|
1928
|
+
function Sn(e, t) {
|
|
1840
1929
|
e.setState({ selectedComment: t });
|
|
1841
1930
|
}
|
|
1842
|
-
async function
|
|
1931
|
+
async function Cn(e, t, n, r, i) {
|
|
1843
1932
|
let a = e.getState().currentUser;
|
|
1844
1933
|
if (!a) return;
|
|
1845
|
-
let o =
|
|
1934
|
+
let o = z(i), s = en(r);
|
|
1846
1935
|
if (!o || s == null) {
|
|
1847
|
-
|
|
1936
|
+
L(e, "invalid_highlight", "Highlight data is invalid");
|
|
1848
1937
|
return;
|
|
1849
1938
|
}
|
|
1850
1939
|
let c = `highlight:${s.xpath}:${s.startOffset}:${o.slice(0, 50)}`;
|
|
1851
1940
|
if (n.has(c)) return;
|
|
1852
1941
|
n.add(c);
|
|
1853
|
-
let l =
|
|
1854
|
-
id:
|
|
1942
|
+
let l = m(), u = F(e), d = u ? { branch: u } : void 0, f = U("temp"), p = {
|
|
1943
|
+
id: f,
|
|
1855
1944
|
type: "highlight",
|
|
1856
1945
|
...u ? { branch: u } : {},
|
|
1857
1946
|
content: o,
|
|
@@ -1874,10 +1963,10 @@ async function vn(e, t, n, r, i) {
|
|
|
1874
1963
|
attachments: [],
|
|
1875
1964
|
textSelection: s
|
|
1876
1965
|
};
|
|
1877
|
-
e.setState({ comments: [...e.getState().comments,
|
|
1966
|
+
e.setState({ comments: [...e.getState().comments, p] });
|
|
1878
1967
|
try {
|
|
1879
|
-
let t = await e.apiClient.createHighlight(o, s, l, "medium",
|
|
1880
|
-
|
|
1968
|
+
let t = await e.apiClient.createHighlight(o, s, l, "medium", f, ...d ? [d] : []);
|
|
1969
|
+
G(e, f, t), e.emit("comment:created", t);
|
|
1881
1970
|
} catch (n) {
|
|
1882
1971
|
t.shouldQueueMutation(n) && t.queueMutation("createHighlight", [
|
|
1883
1972
|
o,
|
|
@@ -1887,27 +1976,27 @@ async function vn(e, t, n, r, i) {
|
|
|
1887
1976
|
path: l.path,
|
|
1888
1977
|
title: l.title
|
|
1889
1978
|
},
|
|
1890
|
-
...
|
|
1891
|
-
],
|
|
1979
|
+
...d ? [d] : []
|
|
1980
|
+
], f) || (e.setState({ comments: e.getState().comments.filter((e) => e.id !== f) }), e.handleError(n));
|
|
1892
1981
|
} finally {
|
|
1893
1982
|
n.delete(c);
|
|
1894
1983
|
}
|
|
1895
1984
|
}
|
|
1896
|
-
async function
|
|
1985
|
+
async function wn(e, t, n, r, i, a) {
|
|
1897
1986
|
let o = e.getState().currentUser;
|
|
1898
1987
|
if (!o) return;
|
|
1899
|
-
let s =
|
|
1988
|
+
let s = z(a), c = Xt(i), l = nn(r);
|
|
1900
1989
|
if (!s || !c || l == null) {
|
|
1901
|
-
|
|
1990
|
+
L(e, "invalid_drawing", "Drawing comment data is invalid");
|
|
1902
1991
|
return;
|
|
1903
1992
|
}
|
|
1904
1993
|
let u = `drawing:${c.x}:${c.y}:${s.slice(0, 50)}`;
|
|
1905
1994
|
if (n.has(u)) return;
|
|
1906
1995
|
n.add(u);
|
|
1907
|
-
let
|
|
1996
|
+
let d = m(), f = F(e), p = f ? { branch: f } : void 0, h = U("temp"), g = {
|
|
1908
1997
|
id: h,
|
|
1909
1998
|
type: "drawing",
|
|
1910
|
-
...
|
|
1999
|
+
...f ? { branch: f } : {},
|
|
1911
2000
|
content: s,
|
|
1912
2001
|
position: c,
|
|
1913
2002
|
status: "open",
|
|
@@ -1917,9 +2006,9 @@ async function yn(e, t, n, r, i, a) {
|
|
|
1917
2006
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1918
2007
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1919
2008
|
page: {
|
|
1920
|
-
url:
|
|
1921
|
-
path:
|
|
1922
|
-
title:
|
|
2009
|
+
url: d.url,
|
|
2010
|
+
path: d.path,
|
|
2011
|
+
title: d.title
|
|
1923
2012
|
},
|
|
1924
2013
|
replies: [],
|
|
1925
2014
|
attachments: [],
|
|
@@ -1927,54 +2016,54 @@ async function yn(e, t, n, r, i, a) {
|
|
|
1927
2016
|
};
|
|
1928
2017
|
e.setState({ comments: [...e.getState().comments, g] });
|
|
1929
2018
|
try {
|
|
1930
|
-
let t = await e.apiClient.createDrawing(s, l, c,
|
|
1931
|
-
|
|
2019
|
+
let t = await e.apiClient.createDrawing(s, l, c, d, h, ...p ? [p] : []);
|
|
2020
|
+
G(e, h, t), e.emit("comment:created", t);
|
|
1932
2021
|
} catch (n) {
|
|
1933
2022
|
t.shouldQueueMutation(n) && t.queueMutation("createDrawing", [
|
|
1934
2023
|
s,
|
|
1935
2024
|
l,
|
|
1936
2025
|
c,
|
|
1937
2026
|
{
|
|
1938
|
-
url:
|
|
1939
|
-
path:
|
|
1940
|
-
title:
|
|
2027
|
+
url: d.url,
|
|
2028
|
+
path: d.path,
|
|
2029
|
+
title: d.title
|
|
1941
2030
|
},
|
|
1942
|
-
...
|
|
2031
|
+
...p ? [p] : []
|
|
1943
2032
|
], h) || (e.setState({ comments: e.getState().comments.filter((e) => e.id !== h) }), e.handleError(n));
|
|
1944
2033
|
} finally {
|
|
1945
2034
|
n.delete(u);
|
|
1946
2035
|
}
|
|
1947
2036
|
}
|
|
1948
|
-
var
|
|
2037
|
+
var Tn = {
|
|
1949
2038
|
c: "comment",
|
|
1950
2039
|
e: "select",
|
|
1951
2040
|
d: "draw",
|
|
1952
2041
|
h: "highlight",
|
|
1953
2042
|
s: "screenshot"
|
|
1954
2043
|
};
|
|
1955
|
-
function
|
|
2044
|
+
function En(e) {
|
|
1956
2045
|
return typeof e.composedPath == "function" ? e.composedPath() : e.target ? [e.target] : [];
|
|
1957
2046
|
}
|
|
1958
|
-
function
|
|
2047
|
+
function Dn(e) {
|
|
1959
2048
|
return typeof Element < "u" && e instanceof Element;
|
|
1960
2049
|
}
|
|
1961
|
-
function
|
|
1962
|
-
if (!
|
|
2050
|
+
function On(e) {
|
|
2051
|
+
if (!Dn(e)) return !1;
|
|
1963
2052
|
let t = e.tagName.toLowerCase();
|
|
1964
2053
|
return t === "input" || t === "textarea" || t === "select" || e.isContentEditable || e.getAttribute("role") === "textbox";
|
|
1965
2054
|
}
|
|
1966
|
-
function
|
|
2055
|
+
function kn(e) {
|
|
1967
2056
|
let t = e.activeElement;
|
|
1968
2057
|
for (; t?.shadowRoot?.activeElement;) t = t.shadowRoot.activeElement;
|
|
1969
2058
|
return t;
|
|
1970
2059
|
}
|
|
1971
|
-
function
|
|
1972
|
-
return
|
|
2060
|
+
function An(e) {
|
|
2061
|
+
return En(e).some(On) ? !0 : typeof document > "u" ? !1 : On(kn(document));
|
|
1973
2062
|
}
|
|
1974
|
-
function
|
|
1975
|
-
return
|
|
2063
|
+
function jn(e) {
|
|
2064
|
+
return En(e).some((e) => Dn(e) && (e.hasAttribute("data-commentkit") || e.hasAttribute("data-commentkit-ui") || e.hasAttribute("data-commentkit-host")));
|
|
1976
2065
|
}
|
|
1977
|
-
var
|
|
2066
|
+
var Mn = [
|
|
1978
2067
|
"popover",
|
|
1979
2068
|
"dialog",
|
|
1980
2069
|
"alert-dialog",
|
|
@@ -1984,26 +2073,26 @@ var En = [
|
|
|
1984
2073
|
"select",
|
|
1985
2074
|
"combobox"
|
|
1986
2075
|
].map((e) => `[data-slot="${e}-content"][data-open]`).join(",");
|
|
1987
|
-
function
|
|
1988
|
-
let t =
|
|
1989
|
-
if (
|
|
2076
|
+
function Nn(e) {
|
|
2077
|
+
let t = En(e), n = t.find((e) => Dn(e) && e.hasAttribute("data-commentkit-host"));
|
|
2078
|
+
if (Dn(n)) return !!n.shadowRoot?.querySelector(Mn);
|
|
1990
2079
|
if (typeof document < "u" && (t[0] === document.body || t[0] === document.documentElement)) {
|
|
1991
2080
|
let e = document.querySelectorAll("[data-commentkit-host]");
|
|
1992
|
-
return e.length === 1 && !!e[0]?.shadowRoot?.querySelector(
|
|
2081
|
+
return e.length === 1 && !!e[0]?.shadowRoot?.querySelector(Mn);
|
|
1993
2082
|
}
|
|
1994
2083
|
return !1;
|
|
1995
2084
|
}
|
|
1996
|
-
function
|
|
2085
|
+
function Pn(e) {
|
|
1997
2086
|
return (e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === "K" || e.key === "k" || e.code === "KeyK");
|
|
1998
2087
|
}
|
|
1999
|
-
function
|
|
2088
|
+
function Fn(e) {
|
|
2000
2089
|
let t = e.key.toLowerCase(), n = e.code.startsWith("Key") ? e.code.slice(3).toLowerCase() : "";
|
|
2001
|
-
return
|
|
2090
|
+
return Tn[t] ?? Tn[n] ?? null;
|
|
2002
2091
|
}
|
|
2003
|
-
function
|
|
2092
|
+
function In(e) {
|
|
2004
2093
|
e.preventDefault(), e.stopPropagation();
|
|
2005
2094
|
}
|
|
2006
|
-
function
|
|
2095
|
+
function Ln(e, t) {
|
|
2007
2096
|
if (e.isLoginModalVisible) t.toggleLoginModal();
|
|
2008
2097
|
else if (e.isShortcutsOverlayVisible) t.toggleShortcutsOverlay();
|
|
2009
2098
|
else if (e.activeComment) t.setState({ activeComment: null });
|
|
@@ -2014,28 +2103,28 @@ function An(e, t) {
|
|
|
2014
2103
|
else return !1;
|
|
2015
2104
|
return !0;
|
|
2016
2105
|
}
|
|
2017
|
-
function
|
|
2106
|
+
function Rn(e, t) {
|
|
2018
2107
|
e.isAuthenticated ? t.toggleOverlay() : t.toggleLoginModal();
|
|
2019
2108
|
}
|
|
2020
|
-
function
|
|
2109
|
+
function zn(e, t, n) {
|
|
2021
2110
|
if (e.defaultPrevented || e.repeat || e.isComposing) return;
|
|
2022
|
-
let r =
|
|
2023
|
-
if (
|
|
2111
|
+
let r = An(e), i = jn(e);
|
|
2112
|
+
if (Pn(e)) {
|
|
2024
2113
|
if (r) return;
|
|
2025
|
-
|
|
2114
|
+
In(e), Rn(t, n);
|
|
2026
2115
|
} else if (e.key === "Escape") {
|
|
2027
|
-
if (
|
|
2028
|
-
|
|
2116
|
+
if (Nn(e) || r && !i) return;
|
|
2117
|
+
Ln(t, n) && In(e);
|
|
2029
2118
|
} else if (t.isAuthenticated && (t.isOverlayVisible || t.activeTool !== null) && !r && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
2030
2119
|
if (e.key === "?") {
|
|
2031
|
-
|
|
2120
|
+
In(e), n.toggleShortcutsOverlay();
|
|
2032
2121
|
return;
|
|
2033
2122
|
}
|
|
2034
|
-
let r =
|
|
2035
|
-
r && (
|
|
2123
|
+
let r = Fn(e);
|
|
2124
|
+
r && (In(e), n.setTool(t.activeTool === r ? null : r));
|
|
2036
2125
|
}
|
|
2037
2126
|
}
|
|
2038
|
-
var
|
|
2127
|
+
var Bn = j.PENDING_MUTATIONS, Vn = j.RETRY_DELAY, q = j.ID, Hn = j.CONTENT, Un = j.REPLY_CONTENT, Wn = j.SELECTOR, Gn = j.EMOJI, Kn = /* @__PURE__ */ new Set([
|
|
2039
2128
|
"createComment",
|
|
2040
2129
|
"createHighlight",
|
|
2041
2130
|
"createDrawing",
|
|
@@ -2047,41 +2136,41 @@ var Nn = A.PENDING_MUTATIONS, Pn = A.RETRY_DELAY, J = A.ID, Fn = A.CONTENT, In =
|
|
|
2047
2136
|
"addReply",
|
|
2048
2137
|
"reactToComment",
|
|
2049
2138
|
"updatePosition"
|
|
2050
|
-
]),
|
|
2139
|
+
]), qn = /* @__PURE__ */ new Set([
|
|
2051
2140
|
"pin",
|
|
2052
2141
|
"highlight",
|
|
2053
2142
|
"drawing"
|
|
2054
|
-
]),
|
|
2143
|
+
]), Jn = /* @__PURE__ */ new Set([
|
|
2055
2144
|
"low",
|
|
2056
2145
|
"medium",
|
|
2057
2146
|
"high",
|
|
2058
2147
|
"urgent"
|
|
2059
|
-
]),
|
|
2060
|
-
function
|
|
2061
|
-
return
|
|
2148
|
+
]), Yn = /* @__PURE__ */ new Set(["add", "remove"]);
|
|
2149
|
+
function Xn(t) {
|
|
2150
|
+
return o(t) && e(t.x) && e(t.y) && n(t.element, Wn) && n(t.xpath, Wn);
|
|
2062
2151
|
}
|
|
2063
|
-
function
|
|
2064
|
-
return typeof e == "string" && e.length <=
|
|
2152
|
+
function Zn(e) {
|
|
2153
|
+
return typeof e == "string" && e.length <= j.PAGE && !a(e);
|
|
2065
2154
|
}
|
|
2066
|
-
function
|
|
2067
|
-
return e === void 0 ||
|
|
2155
|
+
function Qn(e) {
|
|
2156
|
+
return e === void 0 || o(e) && Zn(e.url) && Zn(e.path) && Zn(e.title);
|
|
2068
2157
|
}
|
|
2069
|
-
function
|
|
2070
|
-
return typeof e == "string" &&
|
|
2158
|
+
function $n(e) {
|
|
2159
|
+
return typeof e == "string" && Kn.has(e);
|
|
2071
2160
|
}
|
|
2072
|
-
function
|
|
2161
|
+
function er(e) {
|
|
2073
2162
|
return Number.isInteger(e) && Number(e) >= 0;
|
|
2074
2163
|
}
|
|
2075
|
-
function
|
|
2076
|
-
return
|
|
2164
|
+
function tr(e) {
|
|
2165
|
+
return er(e) ? Math.min(e, 5) : 0;
|
|
2077
2166
|
}
|
|
2078
|
-
function
|
|
2167
|
+
function nr(e) {
|
|
2079
2168
|
return e.isNetworkError() || e.code === 408 || e.isRateLimitError();
|
|
2080
2169
|
}
|
|
2081
|
-
function
|
|
2082
|
-
return e instanceof T ?
|
|
2170
|
+
function rr(e) {
|
|
2171
|
+
return e instanceof T ? nr(e) : !0;
|
|
2083
2172
|
}
|
|
2084
|
-
function
|
|
2173
|
+
function ir(e) {
|
|
2085
2174
|
return e instanceof T ? {
|
|
2086
2175
|
error: e.error,
|
|
2087
2176
|
message: e.message,
|
|
@@ -2093,94 +2182,94 @@ function Zn(e) {
|
|
|
2093
2182
|
code: 0
|
|
2094
2183
|
};
|
|
2095
2184
|
}
|
|
2096
|
-
function
|
|
2185
|
+
function ar(e = Date.now()) {
|
|
2097
2186
|
return `mutation_${e}_${typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : Math.random().toString(36).slice(2, 12)}`;
|
|
2098
2187
|
}
|
|
2099
|
-
function
|
|
2100
|
-
return Array.isArray(e) ? e.map((e) =>
|
|
2188
|
+
function or(e) {
|
|
2189
|
+
return Array.isArray(e) ? e.map((e) => or(e)) : o(e) ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e, or(t)])) : e;
|
|
2101
2190
|
}
|
|
2102
|
-
function
|
|
2191
|
+
function sr(e) {
|
|
2103
2192
|
try {
|
|
2104
2193
|
if (typeof structuredClone == "function") return structuredClone(e);
|
|
2105
2194
|
} catch {}
|
|
2106
|
-
return
|
|
2195
|
+
return or(e);
|
|
2107
2196
|
}
|
|
2108
|
-
function
|
|
2197
|
+
function cr(e, t) {
|
|
2109
2198
|
switch (e) {
|
|
2110
2199
|
case "createComment": {
|
|
2111
|
-
let [e,
|
|
2112
|
-
return
|
|
2200
|
+
let [e, n, r, a, s, c, l, u] = t;
|
|
2201
|
+
return t.length >= 3 && t.length <= 8 && qn.has(String(e)) && i(n, Hn) && Xn(r) && (a === void 0 || Jn.has(String(a))) && (s === void 0 || o(s)) && (c === void 0 || o(c)) && (l === void 0 || o(l)) && Qn(u);
|
|
2113
2202
|
}
|
|
2114
2203
|
case "createHighlight": {
|
|
2115
|
-
let [e,
|
|
2116
|
-
return
|
|
2204
|
+
let [e, n, r, a] = t;
|
|
2205
|
+
return t.length >= 2 && t.length <= 4 && i(e, Hn) && o(n) && (a === void 0 || o(a)) && Qn(r);
|
|
2117
2206
|
}
|
|
2118
2207
|
case "createDrawing": {
|
|
2119
|
-
let [e,
|
|
2120
|
-
return
|
|
2208
|
+
let [e, n, r, a, s] = t;
|
|
2209
|
+
return t.length >= 3 && t.length <= 5 && i(e, Hn) && o(n) && Xn(r) && (s === void 0 || o(s)) && Qn(a);
|
|
2121
2210
|
}
|
|
2122
|
-
case "updateComment": return
|
|
2211
|
+
case "updateComment": return t.length === 2 && r(t[0], q) && o(t[1]);
|
|
2123
2212
|
case "deleteComment":
|
|
2124
2213
|
case "resolveComment":
|
|
2125
2214
|
case "unresolveComment":
|
|
2126
|
-
case "completeComment": return
|
|
2127
|
-
case "addReply": return (
|
|
2128
|
-
case "reactToComment": return
|
|
2129
|
-
case "updatePosition": return
|
|
2215
|
+
case "completeComment": return t.length === 1 && r(t[0], q);
|
|
2216
|
+
case "addReply": return (t.length === 2 || t.length === 3) && r(t[0], q) && i(t[1], Un) && (t[2] === void 0 || o(t[2]));
|
|
2217
|
+
case "reactToComment": return t.length >= 2 && t.length <= 4 && r(t[0], q) && r(t[1], Gn) && (t[2] === void 0 || Yn.has(String(t[2]))) && (t[3] === void 0 || r(t[3], q));
|
|
2218
|
+
case "updatePosition": return t.length === 2 && r(t[0], q) && Xn(t[1]);
|
|
2130
2219
|
}
|
|
2131
2220
|
}
|
|
2132
|
-
function
|
|
2133
|
-
return
|
|
2221
|
+
function lr(e) {
|
|
2222
|
+
return o(e) ? r(e.id, q) ? e.ownerId !== void 0 && !r(e.ownerId, q) ? "Queued mutation has an invalid owner id" : $n(e.type) ? Array.isArray(e.args) ? Number.isFinite(e.timestamp) ? er(e.retries) ? n(e.tempId, q) ? cr(e.type, e.args) ? null : "Queued mutation args are invalid" : "Queued mutation has an invalid temp id" : "Queued mutation has an invalid retry count" : "Queued mutation has an invalid timestamp" : "Queued mutation args must be an array" : "Queued mutation has an unsupported type" : "Queued mutation has an invalid id" : "Queued mutation must be an object";
|
|
2134
2223
|
}
|
|
2135
|
-
function
|
|
2136
|
-
let t =
|
|
2224
|
+
function ur(e) {
|
|
2225
|
+
let t = lr(e);
|
|
2137
2226
|
if (t) throw new T("invalid_mutation", t, 400);
|
|
2138
2227
|
}
|
|
2139
|
-
var
|
|
2140
|
-
function
|
|
2228
|
+
var dr = "commentkit:offline-queue:";
|
|
2229
|
+
function fr() {
|
|
2141
2230
|
try {
|
|
2142
2231
|
return typeof localStorage > "u" ? null : localStorage;
|
|
2143
2232
|
} catch {
|
|
2144
2233
|
return null;
|
|
2145
2234
|
}
|
|
2146
2235
|
}
|
|
2147
|
-
function
|
|
2148
|
-
return `${
|
|
2236
|
+
function pr(e) {
|
|
2237
|
+
return `${dr}${e}`;
|
|
2149
2238
|
}
|
|
2150
|
-
function
|
|
2239
|
+
function mr(e, t) {
|
|
2151
2240
|
if (!e) return;
|
|
2152
|
-
let n =
|
|
2241
|
+
let n = fr();
|
|
2153
2242
|
if (n) try {
|
|
2154
|
-
t.length === 0 ? n.removeItem(
|
|
2243
|
+
t.length === 0 ? n.removeItem(pr(e)) : n.setItem(pr(e), JSON.stringify(t));
|
|
2155
2244
|
} catch {}
|
|
2156
2245
|
}
|
|
2157
|
-
function
|
|
2246
|
+
function hr(e) {
|
|
2158
2247
|
if (!e) return [];
|
|
2159
|
-
let t =
|
|
2248
|
+
let t = fr();
|
|
2160
2249
|
if (!t) return [];
|
|
2161
2250
|
try {
|
|
2162
|
-
let n = t.getItem(
|
|
2251
|
+
let n = t.getItem(pr(e));
|
|
2163
2252
|
if (!n) return [];
|
|
2164
2253
|
let r = JSON.parse(n);
|
|
2165
2254
|
if (!Array.isArray(r)) return [];
|
|
2166
2255
|
let i = [];
|
|
2167
2256
|
for (let e of r) {
|
|
2168
|
-
if (i.length >=
|
|
2169
|
-
|
|
2257
|
+
if (i.length >= Bn) break;
|
|
2258
|
+
lr(e) === null && i.push(e);
|
|
2170
2259
|
}
|
|
2171
2260
|
return i;
|
|
2172
2261
|
} catch {
|
|
2173
2262
|
return [];
|
|
2174
2263
|
}
|
|
2175
2264
|
}
|
|
2176
|
-
function
|
|
2265
|
+
function J(e) {
|
|
2177
2266
|
Promise.resolve().then(e);
|
|
2178
2267
|
}
|
|
2179
|
-
function
|
|
2268
|
+
function gr(e, t) {
|
|
2180
2269
|
return e.type !== t.type || e.ownerId !== t.ownerId ? !1 : (t.type === "updatePosition" || t.type === "updateComment") && e.args[0] === t.args[0];
|
|
2181
2270
|
}
|
|
2182
|
-
function
|
|
2183
|
-
return t.type === "updateComment" &&
|
|
2271
|
+
function _r(e, t) {
|
|
2272
|
+
return t.type === "updateComment" && o(e.args[1]) ? {
|
|
2184
2273
|
...t,
|
|
2185
2274
|
args: [t.args[0], {
|
|
2186
2275
|
...e.args[1],
|
|
@@ -2188,32 +2277,32 @@ function ur(e, t) {
|
|
|
2188
2277
|
}]
|
|
2189
2278
|
} : t;
|
|
2190
2279
|
}
|
|
2191
|
-
function
|
|
2192
|
-
let n = e.findIndex((e) =>
|
|
2280
|
+
function vr(e, t) {
|
|
2281
|
+
let n = e.findIndex((e) => gr(e, t));
|
|
2193
2282
|
if (n !== -1) {
|
|
2194
2283
|
let r = [...e];
|
|
2195
|
-
return r[n] =
|
|
2284
|
+
return r[n] = _r(r[n], t), r;
|
|
2196
2285
|
}
|
|
2197
|
-
return e.length >=
|
|
2286
|
+
return e.length >= Bn ? null : [...e, t];
|
|
2198
2287
|
}
|
|
2199
|
-
function
|
|
2288
|
+
function Y(e, t, n) {
|
|
2200
2289
|
e.emit("offline:failed", {
|
|
2201
2290
|
id: t,
|
|
2202
2291
|
error: n
|
|
2203
2292
|
});
|
|
2204
2293
|
}
|
|
2205
|
-
function
|
|
2294
|
+
function yr(e, t) {
|
|
2206
2295
|
return t.isAuthenticated && e.ownerId && e.ownerId === t.currentUser?.id ? null : {
|
|
2207
2296
|
error: "offline_identity_mismatch",
|
|
2208
2297
|
message: e.ownerId ? "Offline change belongs to a different signed-in user and was discarded." : "Offline change has no verified author and was discarded. Please submit it again.",
|
|
2209
2298
|
code: 403
|
|
2210
2299
|
};
|
|
2211
2300
|
}
|
|
2212
|
-
function
|
|
2301
|
+
function br(e) {
|
|
2213
2302
|
let t = e.getState();
|
|
2214
2303
|
if (!t.isAuthenticated) return;
|
|
2215
2304
|
let n = t.pendingMutations.flatMap((e) => {
|
|
2216
|
-
let n =
|
|
2305
|
+
let n = yr(e, t);
|
|
2217
2306
|
return n ? [{
|
|
2218
2307
|
mutation: e,
|
|
2219
2308
|
error: n
|
|
@@ -2222,99 +2311,99 @@ function pr(e) {
|
|
|
2222
2311
|
if (n.length === 0) return;
|
|
2223
2312
|
let r = new Set(n.map(({ mutation: e }) => e.id));
|
|
2224
2313
|
e.setState({ pendingMutations: t.pendingMutations.filter((e) => !r.has(e.id)) });
|
|
2225
|
-
for (let { mutation: t, error: r } of n)
|
|
2314
|
+
for (let { mutation: t, error: r } of n) Y(e, t.id, r);
|
|
2226
2315
|
}
|
|
2227
|
-
function
|
|
2228
|
-
return !e.isOnline || t instanceof T &&
|
|
2316
|
+
function xr(e, t) {
|
|
2317
|
+
return !e.isOnline || t instanceof T && nr(t);
|
|
2229
2318
|
}
|
|
2230
|
-
function
|
|
2231
|
-
let
|
|
2232
|
-
if (!
|
|
2319
|
+
function Sr(e, t, i, a, o) {
|
|
2320
|
+
let s = ar(), c = e.getState(), l = c.currentUser?.id;
|
|
2321
|
+
if (!c.isAuthenticated || !r(l, q)) return Y(e, s, {
|
|
2233
2322
|
error: "unauthenticated",
|
|
2234
2323
|
message: "Sign in before saving changes for offline replay.",
|
|
2235
2324
|
code: 401
|
|
2236
2325
|
}), !1;
|
|
2237
|
-
if (
|
|
2326
|
+
if (!$n(i) || !Array.isArray(a) || !cr(i, a) || !n(o, q)) return Y(e, s, {
|
|
2238
2327
|
error: "invalid_mutation",
|
|
2239
2328
|
message: "Queued mutation args are invalid",
|
|
2240
2329
|
code: 400
|
|
2241
2330
|
}), !1;
|
|
2242
2331
|
let u = {
|
|
2243
|
-
id:
|
|
2244
|
-
ownerId:
|
|
2245
|
-
type:
|
|
2246
|
-
args:
|
|
2332
|
+
id: s,
|
|
2333
|
+
ownerId: l,
|
|
2334
|
+
type: i,
|
|
2335
|
+
args: sr(a),
|
|
2247
2336
|
timestamp: Date.now(),
|
|
2248
2337
|
retries: 0,
|
|
2249
|
-
...
|
|
2250
|
-
}, d =
|
|
2251
|
-
return d ? (e.setState({ pendingMutations: d }), e.emit("offline:queued", u), e.getState().isOnline &&
|
|
2338
|
+
...o === void 0 ? {} : { tempId: o }
|
|
2339
|
+
}, d = vr(e.getState().pendingMutations, u);
|
|
2340
|
+
return d ? (e.setState({ pendingMutations: d }), e.emit("offline:queued", u), e.getState().isOnline && J(t), !0) : (Y(e, s, {
|
|
2252
2341
|
error: "queue_full",
|
|
2253
2342
|
message: "Offline mutation queue is full",
|
|
2254
2343
|
code: 0
|
|
2255
2344
|
}), !1);
|
|
2256
2345
|
}
|
|
2257
|
-
function
|
|
2346
|
+
function Cr(e, t, n) {
|
|
2258
2347
|
if (t.current || e.getState().pendingMutations.length === 0) return;
|
|
2259
2348
|
let r = e.getState().pendingMutations[0];
|
|
2260
2349
|
if (!r) return;
|
|
2261
|
-
let i =
|
|
2350
|
+
let i = tr(r.retries), a = Math.min(Vn, jt * 2 ** i);
|
|
2262
2351
|
t.current = setTimeout(() => {
|
|
2263
2352
|
t.current = null, n();
|
|
2264
2353
|
}, a);
|
|
2265
2354
|
}
|
|
2266
|
-
async function
|
|
2267
|
-
let
|
|
2268
|
-
if (!
|
|
2355
|
+
async function wr(e, t, n, i) {
|
|
2356
|
+
let a = e.getState();
|
|
2357
|
+
if (!a.isOnline || a.pendingMutations.length === 0 || !a.isAuthenticated || t.current) return;
|
|
2269
2358
|
t.current = !0;
|
|
2270
|
-
let
|
|
2271
|
-
if (!
|
|
2359
|
+
let o = e.getState().pendingMutations[0];
|
|
2360
|
+
if (!o) {
|
|
2272
2361
|
t.current = !1;
|
|
2273
2362
|
return;
|
|
2274
2363
|
}
|
|
2275
|
-
let
|
|
2364
|
+
let s = lr(o), c = s ? {
|
|
2276
2365
|
error: "invalid_mutation",
|
|
2277
|
-
message:
|
|
2366
|
+
message: s,
|
|
2278
2367
|
code: 400
|
|
2279
|
-
} :
|
|
2280
|
-
if (
|
|
2281
|
-
let
|
|
2282
|
-
e.setState({ pendingMutations:
|
|
2368
|
+
} : yr(o, e.getState());
|
|
2369
|
+
if (c) {
|
|
2370
|
+
let i = e.getState().pendingMutations.filter((e) => e !== o);
|
|
2371
|
+
e.setState({ pendingMutations: i }), Y(e, r(o.id, q) ? o.id : "invalid", c), i.length > 0 && J(n), t.current = !1;
|
|
2283
2372
|
return;
|
|
2284
2373
|
}
|
|
2285
2374
|
e.emit("offline:retrying", {
|
|
2286
|
-
id:
|
|
2287
|
-
attempt:
|
|
2375
|
+
id: o.id,
|
|
2376
|
+
attempt: o.retries + 1
|
|
2288
2377
|
});
|
|
2289
|
-
let
|
|
2378
|
+
let l = i ?? ((t) => Or(e, t));
|
|
2290
2379
|
try {
|
|
2291
|
-
await
|
|
2292
|
-
let r = e.getState().pendingMutations.filter((e) => e.id !==
|
|
2293
|
-
e.setState({ pendingMutations: r }), e.emit("offline:completed", { id:
|
|
2380
|
+
await l(o);
|
|
2381
|
+
let r = e.getState().pendingMutations.filter((e) => e.id !== o.id);
|
|
2382
|
+
e.setState({ pendingMutations: r }), e.emit("offline:completed", { id: o.id }), r.length > 0 ? J(n) : t.reconcileAfterDrain && (t.reconcileAfterDrain = !1, ln(e));
|
|
2294
2383
|
} catch (r) {
|
|
2295
2384
|
let i = {
|
|
2296
|
-
...
|
|
2297
|
-
retries:
|
|
2385
|
+
...o,
|
|
2386
|
+
retries: tr(o.retries) + 1
|
|
2298
2387
|
};
|
|
2299
|
-
if (
|
|
2300
|
-
let t = e.getState().pendingMutations.map((e) => e.id ===
|
|
2301
|
-
e.setState({ pendingMutations: t }),
|
|
2388
|
+
if (rr(r) && i.retries < 5) {
|
|
2389
|
+
let t = e.getState().pendingMutations.map((e) => e.id === o.id ? i : e);
|
|
2390
|
+
e.setState({ pendingMutations: t }), J(n);
|
|
2302
2391
|
} else {
|
|
2303
|
-
let i = e.getState().pendingMutations.filter((e) => e.id !==
|
|
2304
|
-
e.setState({ pendingMutations: i }),
|
|
2392
|
+
let i = e.getState().pendingMutations.filter((e) => e.id !== o.id);
|
|
2393
|
+
e.setState({ pendingMutations: i }), Y(e, o.id, ir(r)), i.length > 0 ? (t.reconcileAfterDrain = !0, J(n)) : (t.reconcileAfterDrain = !1, ln(e));
|
|
2305
2394
|
}
|
|
2306
2395
|
} finally {
|
|
2307
2396
|
t.current = !1;
|
|
2308
2397
|
}
|
|
2309
2398
|
}
|
|
2310
|
-
function
|
|
2399
|
+
function Tr(e, t, n) {
|
|
2311
2400
|
let r = !1, i = e.getState().pendingMutations.map((e) => e.type !== "createComment" && e.type !== "createHighlight" && e.type !== "createDrawing" && e.args[0] === t ? (r = !0, {
|
|
2312
2401
|
...e,
|
|
2313
2402
|
args: [n, ...e.args.slice(1)]
|
|
2314
2403
|
}) : e);
|
|
2315
2404
|
r && e.setState({ pendingMutations: i });
|
|
2316
2405
|
}
|
|
2317
|
-
function
|
|
2406
|
+
function Er(e, t, n) {
|
|
2318
2407
|
let r = e.getState(), i = (e) => e === t || e === n;
|
|
2319
2408
|
e.setState({
|
|
2320
2409
|
comments: r.comments.filter((e) => !i(e.id)),
|
|
@@ -2322,7 +2411,7 @@ function yr(e, t, n) {
|
|
|
2322
2411
|
activeComment: r.activeComment && i(r.activeComment.id) ? null : r.activeComment
|
|
2323
2412
|
});
|
|
2324
2413
|
}
|
|
2325
|
-
function
|
|
2414
|
+
function X(e, t, n, r, i = !1) {
|
|
2326
2415
|
let a = e.getState(), o = a.comments.find((e) => e.id === r || e.id === n.id), s = n, c = (e) => {
|
|
2327
2416
|
s.status !== e && (s = {
|
|
2328
2417
|
...s,
|
|
@@ -2333,7 +2422,7 @@ function Z(e, t, n, r, i = !1) {
|
|
|
2333
2422
|
};
|
|
2334
2423
|
for (let i of a.pendingMutations) if (!(i.id === t.id || i.ownerId !== t.ownerId || i.args[0] !== r && i.args[0] !== n.id)) switch (i.type) {
|
|
2335
2424
|
case "deleteComment":
|
|
2336
|
-
|
|
2425
|
+
Er(e, n.id, r);
|
|
2337
2426
|
return;
|
|
2338
2427
|
case "updateComment":
|
|
2339
2428
|
i.args[1].status && c(i.args[1].status), s = {
|
|
@@ -2369,69 +2458,69 @@ function Z(e, t, n, r, i = !1) {
|
|
|
2369
2458
|
reactions: o.reactions
|
|
2370
2459
|
});
|
|
2371
2460
|
}
|
|
2372
|
-
i ?
|
|
2461
|
+
i ? G(e, r, s) : e.setState({ comments: a.comments.map((e) => e.id === r ? s : e) });
|
|
2373
2462
|
}
|
|
2374
|
-
function
|
|
2463
|
+
function Dr(e, t, n, r) {
|
|
2375
2464
|
e.setState({ pendingMutations: e.getState().pendingMutations.map((e) => e.type === "reactToComment" && e.args[0] === t && e.args[3] === n ? {
|
|
2376
2465
|
...e,
|
|
2377
2466
|
args: [...e.args.slice(0, 3), r]
|
|
2378
2467
|
} : e) });
|
|
2379
2468
|
}
|
|
2380
|
-
async function
|
|
2381
|
-
|
|
2382
|
-
let n =
|
|
2469
|
+
async function Or(e, t) {
|
|
2470
|
+
ur(t);
|
|
2471
|
+
let n = yr(t, e.getState());
|
|
2383
2472
|
if (n) throw new T(n.error, n.message, n.code);
|
|
2384
2473
|
switch (t.type) {
|
|
2385
2474
|
case "createComment": {
|
|
2386
|
-
let [n, r, i, a, o, s, c, l] = t.args, u = await e.apiClient.createComment(n, r, i, l ??
|
|
2387
|
-
u && t.tempId && (
|
|
2475
|
+
let [n, r, i, a, o, s, c, l] = t.args, u = await e.apiClient.createComment(n, r, i, l ?? m(), a, o, s, c, t.tempId);
|
|
2476
|
+
u && t.tempId && (X(e, t, u, t.tempId, !0), Tr(e, t.tempId, u.id));
|
|
2388
2477
|
break;
|
|
2389
2478
|
}
|
|
2390
2479
|
case "createHighlight": {
|
|
2391
|
-
let [n, r, i, a] = t.args, o = await e.apiClient.createHighlight(n, r, i ??
|
|
2392
|
-
o && t.tempId && (
|
|
2480
|
+
let [n, r, i, a] = t.args, o = await e.apiClient.createHighlight(n, r, i ?? m(), "medium", t.tempId, ...a ? [a] : []);
|
|
2481
|
+
o && t.tempId && (X(e, t, o, t.tempId, !0), Tr(e, t.tempId, o.id));
|
|
2393
2482
|
break;
|
|
2394
2483
|
}
|
|
2395
2484
|
case "createDrawing": {
|
|
2396
|
-
let [n, r, i, a, o] = t.args, s = await e.apiClient.createDrawing(n, r, i, a ??
|
|
2397
|
-
s && t.tempId && (
|
|
2485
|
+
let [n, r, i, a, o] = t.args, s = await e.apiClient.createDrawing(n, r, i, a ?? m(), t.tempId, ...o ? [o] : []);
|
|
2486
|
+
s && t.tempId && (X(e, t, s, t.tempId, !0), Tr(e, t.tempId, s.id));
|
|
2398
2487
|
break;
|
|
2399
2488
|
}
|
|
2400
2489
|
case "updateComment": {
|
|
2401
2490
|
let [n, r] = t.args, i = await e.apiClient.updateComment(n, r);
|
|
2402
|
-
i &&
|
|
2491
|
+
i && X(e, t, i, n);
|
|
2403
2492
|
break;
|
|
2404
2493
|
}
|
|
2405
2494
|
case "deleteComment": {
|
|
2406
2495
|
let [n] = t.args;
|
|
2407
|
-
await e.apiClient.deleteComment(n),
|
|
2496
|
+
await e.apiClient.deleteComment(n), Er(e, n);
|
|
2408
2497
|
break;
|
|
2409
2498
|
}
|
|
2410
2499
|
case "resolveComment": {
|
|
2411
2500
|
let [n] = t.args, r = await e.apiClient.resolveComment(n);
|
|
2412
|
-
r &&
|
|
2501
|
+
r && X(e, t, r, n);
|
|
2413
2502
|
break;
|
|
2414
2503
|
}
|
|
2415
2504
|
case "unresolveComment": {
|
|
2416
2505
|
let [n] = t.args, r = await e.apiClient.unresolveComment(n);
|
|
2417
|
-
r &&
|
|
2506
|
+
r && X(e, t, r, n);
|
|
2418
2507
|
break;
|
|
2419
2508
|
}
|
|
2420
2509
|
case "completeComment": {
|
|
2421
2510
|
let [n] = t.args, r = await e.apiClient.markComplete(n);
|
|
2422
|
-
r &&
|
|
2511
|
+
r && X(e, t, r, n);
|
|
2423
2512
|
break;
|
|
2424
2513
|
}
|
|
2425
2514
|
case "addReply": {
|
|
2426
2515
|
let [n, r, i] = t.args, a = await e.apiClient.addReply(n, r, t.tempId, ...i ? [i] : []);
|
|
2427
2516
|
if (a && t.tempId) {
|
|
2428
2517
|
let r = e.getState().comments.find((e) => e.id === n), i = e.getState().pendingMutations.some((e) => e.type === "reactToComment" && e.ownerId === t.ownerId && e.args[0] === n && e.args[3] === t.tempId), o = r?.replies.find((e) => e.id === t.tempId);
|
|
2429
|
-
|
|
2518
|
+
sn(e, n, t.tempId, i && o ? {
|
|
2430
2519
|
...a,
|
|
2431
2520
|
reactions: o.reactions
|
|
2432
|
-
} : a),
|
|
2521
|
+
} : a), Dr(e, n, t.tempId, a.id);
|
|
2433
2522
|
let s = e.getState().comments.find((e) => e.id === n);
|
|
2434
|
-
s &&
|
|
2523
|
+
s && X(e, t, s, n);
|
|
2435
2524
|
}
|
|
2436
2525
|
break;
|
|
2437
2526
|
}
|
|
@@ -2442,12 +2531,12 @@ async function xr(e, t) {
|
|
|
2442
2531
|
}
|
|
2443
2532
|
case "updatePosition": {
|
|
2444
2533
|
let [n, r] = t.args, i = await e.apiClient.updatePosition(n, r);
|
|
2445
|
-
i &&
|
|
2534
|
+
i && X(e, t, i, n);
|
|
2446
2535
|
break;
|
|
2447
2536
|
}
|
|
2448
2537
|
}
|
|
2449
2538
|
}
|
|
2450
|
-
var
|
|
2539
|
+
var kr = 1e4, Ar = 2048, jr = 10485760, Mr = 20971520, Z = 16384, Nr = 32e6, Pr = 10, Fr = 10485760, Ir = 26214400, Lr = /* @__PURE__ */ new Set([
|
|
2451
2540
|
"jpg",
|
|
2452
2541
|
"jpeg",
|
|
2453
2542
|
"png",
|
|
@@ -2458,7 +2547,7 @@ var Sr = 1e4, Cr = 2048, wr = 10485760, Tr = 20971520, Er = 16384, Dr = 32e6, Or
|
|
|
2458
2547
|
"docx",
|
|
2459
2548
|
"txt",
|
|
2460
2549
|
"csv"
|
|
2461
|
-
]),
|
|
2550
|
+
]), Rr = 15e3, zr = 1e4, Br = {
|
|
2462
2551
|
"image/gif": "gif",
|
|
2463
2552
|
"image/jpeg": "jpg",
|
|
2464
2553
|
"image/png": "png",
|
|
@@ -2468,72 +2557,72 @@ function Q(e, t) {
|
|
|
2468
2557
|
let n = Error(t);
|
|
2469
2558
|
return n.error = e, n.code = 400, n;
|
|
2470
2559
|
}
|
|
2471
|
-
function
|
|
2560
|
+
function Vr(e) {
|
|
2472
2561
|
if (typeof e != "string") throw Q("invalid_position", "Invalid position");
|
|
2473
2562
|
let t = e.trim();
|
|
2474
|
-
if (!t || t.length >
|
|
2563
|
+
if (!t || t.length > Ar || a(t)) throw Q("invalid_position", "Invalid position");
|
|
2475
2564
|
return t;
|
|
2476
2565
|
}
|
|
2477
|
-
function
|
|
2478
|
-
if (!
|
|
2566
|
+
function Hr(t) {
|
|
2567
|
+
if (!o(t) || !e(t.x) || !e(t.y)) throw Q("invalid_position", "Invalid position");
|
|
2479
2568
|
return {
|
|
2480
2569
|
x: t.x,
|
|
2481
2570
|
y: t.y,
|
|
2482
|
-
...t.element === void 0 ? {} : { element:
|
|
2483
|
-
...t.xpath === void 0 ? {} : { xpath:
|
|
2571
|
+
...t.element === void 0 ? {} : { element: Vr(t.element) },
|
|
2572
|
+
...t.xpath === void 0 ? {} : { xpath: Vr(t.xpath) }
|
|
2484
2573
|
};
|
|
2485
2574
|
}
|
|
2486
|
-
function
|
|
2575
|
+
function Ur(e) {
|
|
2487
2576
|
if (typeof e != "string") throw Q("invalid_content", "Screenshot comment is required");
|
|
2488
2577
|
let t = e.trim();
|
|
2489
|
-
if (!t || t.length >
|
|
2578
|
+
if (!t || t.length > kr || a(t)) throw Q("invalid_content", "Screenshot comment is required");
|
|
2490
2579
|
return t;
|
|
2491
2580
|
}
|
|
2492
|
-
function
|
|
2581
|
+
function Wr(e) {
|
|
2493
2582
|
return typeof Blob < "u" && e instanceof Blob;
|
|
2494
2583
|
}
|
|
2495
|
-
function
|
|
2584
|
+
function Gr(e) {
|
|
2496
2585
|
return typeof File < "u" && e instanceof File;
|
|
2497
2586
|
}
|
|
2498
|
-
function
|
|
2587
|
+
function Kr(e) {
|
|
2499
2588
|
return typeof HTMLElement < "u" && e instanceof HTMLElement;
|
|
2500
2589
|
}
|
|
2501
|
-
function
|
|
2590
|
+
function qr(e) {
|
|
2502
2591
|
if (e !== void 0) {
|
|
2503
|
-
if (!
|
|
2592
|
+
if (!Kr(e)) throw Q("invalid_element", "Invalid screenshot target");
|
|
2504
2593
|
return e;
|
|
2505
2594
|
}
|
|
2506
2595
|
if (typeof document > "u" || !document.body) throw Q("invalid_element", "A browser document is required to capture screenshots");
|
|
2507
2596
|
return document.body;
|
|
2508
2597
|
}
|
|
2509
|
-
function
|
|
2598
|
+
function Jr(e) {
|
|
2510
2599
|
let t = /^data:(image\/(?:png|jpeg|gif|webp));base64,/i.exec(e)?.[1];
|
|
2511
2600
|
return t ? t.toLowerCase() : null;
|
|
2512
2601
|
}
|
|
2513
|
-
function
|
|
2514
|
-
if (!
|
|
2602
|
+
function Yr(e) {
|
|
2603
|
+
if (!o(e)) throw Q("invalid_screenshot", "Invalid screenshot result");
|
|
2515
2604
|
let t = typeof e.dataUrl == "string" ? e.dataUrl.trim() : "", n = e.blob, r = e.dimensions;
|
|
2516
|
-
if (!
|
|
2517
|
-
if (!
|
|
2518
|
-
let { width: i, height:
|
|
2519
|
-
if (typeof i != "number" || typeof
|
|
2605
|
+
if (!Jr(t) || t.length > Mr || !Wr(n) || n.size <= 0 || n.size > jr || n.type && !Object.prototype.hasOwnProperty.call(Br, n.type)) throw Q("invalid_screenshot", "Invalid screenshot result");
|
|
2606
|
+
if (!o(r)) throw Q("invalid_screenshot", "Invalid screenshot dimensions");
|
|
2607
|
+
let { width: i, height: a } = r;
|
|
2608
|
+
if (typeof i != "number" || typeof a != "number" || !Number.isFinite(i) || !Number.isFinite(a) || i <= 0 || a <= 0 || i > Z || a > Z) throw Q("invalid_screenshot", "Invalid screenshot dimensions");
|
|
2520
2609
|
return {
|
|
2521
2610
|
dataUrl: t,
|
|
2522
2611
|
blob: n,
|
|
2523
2612
|
dimensions: {
|
|
2524
2613
|
width: i,
|
|
2525
|
-
height:
|
|
2614
|
+
height: a
|
|
2526
2615
|
}
|
|
2527
2616
|
};
|
|
2528
2617
|
}
|
|
2529
|
-
function
|
|
2530
|
-
let t =
|
|
2618
|
+
function Xr(e) {
|
|
2619
|
+
let t = Jr(e.dataUrl);
|
|
2531
2620
|
return e.blob.type || t;
|
|
2532
2621
|
}
|
|
2533
|
-
function
|
|
2534
|
-
return `screenshot.${
|
|
2622
|
+
function Zr(e) {
|
|
2623
|
+
return `screenshot.${Br[Xr(e)]}`;
|
|
2535
2624
|
}
|
|
2536
|
-
function
|
|
2625
|
+
function Qr(e, t, n) {
|
|
2537
2626
|
let r = null;
|
|
2538
2627
|
return new Promise((i, a) => {
|
|
2539
2628
|
r = setTimeout(() => {
|
|
@@ -2545,46 +2634,40 @@ function Kr(e, t, n) {
|
|
|
2545
2634
|
});
|
|
2546
2635
|
});
|
|
2547
2636
|
}
|
|
2548
|
-
function
|
|
2637
|
+
function $r(e) {
|
|
2549
2638
|
return new Promise((t, n) => {
|
|
2550
2639
|
let r = !1, i = setTimeout(() => {
|
|
2551
2640
|
r = !0, n(/* @__PURE__ */ Error("toBlob timed out"));
|
|
2552
|
-
},
|
|
2641
|
+
}, zr);
|
|
2553
2642
|
e.toBlob((e) => {
|
|
2554
2643
|
r || (r = !0, clearTimeout(i), e ? t(e) : n(/* @__PURE__ */ Error("toBlob returned null")));
|
|
2555
2644
|
}, "image/png");
|
|
2556
2645
|
});
|
|
2557
2646
|
}
|
|
2558
|
-
function
|
|
2647
|
+
function ei(e) {
|
|
2559
2648
|
let t = e.lastIndexOf(".");
|
|
2560
2649
|
return t >= 0 ? e.slice(t + 1).toLowerCase() : "";
|
|
2561
2650
|
}
|
|
2562
|
-
function
|
|
2651
|
+
function ti(e) {
|
|
2563
2652
|
if (!Array.isArray(e)) throw Q("invalid_files", "Files must be an array");
|
|
2564
|
-
if (e.length >
|
|
2653
|
+
if (e.length > Pr) throw Q("too_many_files", `Cannot upload more than ${Pr} files at once`);
|
|
2565
2654
|
let t = 0;
|
|
2566
2655
|
for (let n of e) {
|
|
2567
|
-
if (!
|
|
2568
|
-
if (n.size >
|
|
2569
|
-
if (t += n.size, t >
|
|
2570
|
-
if (
|
|
2571
|
-
if (
|
|
2572
|
-
if (!
|
|
2656
|
+
if (!Gr(n)) throw Q("invalid_files", "Invalid file upload");
|
|
2657
|
+
if (n.size > Fr) throw Q("file_too_large", `File "${n.name}" exceeds the ${Fr / 1024 / 1024}MB limit`);
|
|
2658
|
+
if (t += n.size, t > Ir) throw Q("upload_too_large", `Total upload size exceeds the ${Ir / 1024 / 1024}MB limit`);
|
|
2659
|
+
if (a(n.name) || n.name.includes("/") || n.name.includes("\\")) throw Q("invalid_filename", "Filename contains invalid characters");
|
|
2660
|
+
if (u(n.name)) throw Q("invalid_file_type", `File type ".${ei(n.name)}" is not allowed`);
|
|
2661
|
+
if (!Lr.has(ei(n.name))) throw Q("invalid_file_type", `File type ".${ei(n.name)}" is not supported. Allowed: ${[...Lr].map((e) => `.${e}`).join(", ")}`);
|
|
2573
2662
|
}
|
|
2574
2663
|
return e;
|
|
2575
2664
|
}
|
|
2576
|
-
function
|
|
2577
|
-
try {
|
|
2578
|
-
return e.matches?.("input[type=\"password\"],[data-commentkit],[data-commentkit-host],[data-commentkit-ui],[data-commentkit-panel],[data-commentkit-redact],[data-html2canvas-ignore],[autocomplete*=\"cc-\"],[autocomplete=\"current-password\"],[autocomplete=\"new-password\"]") ?? !1;
|
|
2579
|
-
} catch {
|
|
2580
|
-
return !1;
|
|
2581
|
-
}
|
|
2582
|
-
}
|
|
2583
|
-
async function Zr(e, t, n, r = {}) {
|
|
2665
|
+
async function ni(e, t, n, r = {}) {
|
|
2584
2666
|
if (e.isLocalDemo) return null;
|
|
2585
2667
|
try {
|
|
2586
|
-
let e =
|
|
2587
|
-
if (
|
|
2668
|
+
let e = qr(n);
|
|
2669
|
+
if (g(e)) return null;
|
|
2670
|
+
if (t) return Yr(await t(e));
|
|
2588
2671
|
let r;
|
|
2589
2672
|
try {
|
|
2590
2673
|
r = (await import("html2canvas")).default;
|
|
@@ -2592,18 +2675,18 @@ async function Zr(e, t, n, r = {}) {
|
|
|
2592
2675
|
/* v8 ignore next 3 -- dynamic import() can't be intercepted by vi.mock */
|
|
2593
2676
|
throw Error("Screenshot requires either a custom screenshotProvider in config or html2canvas installed. Install html2canvas: npm install html2canvas — or provide config.screenshotProvider.");
|
|
2594
2677
|
}
|
|
2595
|
-
let i = await
|
|
2678
|
+
let i = await Qr(r(e, {
|
|
2596
2679
|
useCORS: !0,
|
|
2597
2680
|
allowTaint: !1,
|
|
2598
2681
|
scale: 2,
|
|
2599
2682
|
logging: !1,
|
|
2600
|
-
ignoreElements:
|
|
2683
|
+
ignoreElements: g,
|
|
2601
2684
|
onclone: (e) => import("./capture-colors-CxSLsU5-.js").then(({ normalizeCaptureColors: t }) => t(e))
|
|
2602
|
-
}),
|
|
2603
|
-
if (i.width >
|
|
2604
|
-
return
|
|
2685
|
+
}), Rr, "html2canvas timed out after 15s");
|
|
2686
|
+
if (i.width > Z || i.height > Z || i.width * i.height > Nr) throw Q("screenshot_too_large", "Captured area is too large to screenshot");
|
|
2687
|
+
return Yr({
|
|
2605
2688
|
dataUrl: i.toDataURL("image/png"),
|
|
2606
|
-
blob: await
|
|
2689
|
+
blob: await $r(i),
|
|
2607
2690
|
dimensions: {
|
|
2608
2691
|
width: i.width,
|
|
2609
2692
|
height: i.height
|
|
@@ -2617,11 +2700,11 @@ async function Zr(e, t, n, r = {}) {
|
|
|
2617
2700
|
})), null;
|
|
2618
2701
|
}
|
|
2619
2702
|
}
|
|
2620
|
-
async function
|
|
2703
|
+
async function ri(e, t, n, r) {
|
|
2621
2704
|
try {
|
|
2622
|
-
let i =
|
|
2705
|
+
let i = Yr(t), a = Ur(n), o = Hr(r);
|
|
2623
2706
|
e.setState({ isLoading: !0 });
|
|
2624
|
-
let s = new File([i.blob],
|
|
2707
|
+
let s = new File([i.blob], Zr(i), { type: Xr(i) }), c = m(), l = F(e), u = await e.apiClient.uploadScreenshot(s, {
|
|
2625
2708
|
content: a,
|
|
2626
2709
|
position: o,
|
|
2627
2710
|
page: c,
|
|
@@ -2636,33 +2719,33 @@ async function Qr(e, t, n, r) {
|
|
|
2636
2719
|
return e.setState({ isLoading: !1 }), e.handleError(t), null;
|
|
2637
2720
|
}
|
|
2638
2721
|
}
|
|
2639
|
-
async function
|
|
2722
|
+
async function ii(e, t, n) {
|
|
2640
2723
|
try {
|
|
2641
|
-
let r =
|
|
2724
|
+
let r = ti(t);
|
|
2642
2725
|
return r.length === 0 ? [] : await e.apiClient.uploadFiles(r, n);
|
|
2643
2726
|
} catch (t) {
|
|
2644
2727
|
return e.handleError(t), [];
|
|
2645
2728
|
}
|
|
2646
2729
|
}
|
|
2647
2730
|
var $ = null;
|
|
2648
|
-
async function
|
|
2649
|
-
return $ || ($ = await import("./realtime-
|
|
2731
|
+
async function ai() {
|
|
2732
|
+
return $ || ($ = await import("./realtime-t5o6fk6w.js"), $);
|
|
2650
2733
|
}
|
|
2651
|
-
var
|
|
2734
|
+
var oi = typeof window < "u", si = /* @__PURE__ */ new Set([
|
|
2652
2735
|
"list",
|
|
2653
2736
|
"detail",
|
|
2654
2737
|
"settings",
|
|
2655
2738
|
"activity",
|
|
2656
2739
|
"dev-export"
|
|
2657
|
-
]),
|
|
2740
|
+
]), ci = /* @__PURE__ */ new Set([
|
|
2658
2741
|
"comment",
|
|
2659
2742
|
"draw",
|
|
2660
2743
|
"highlight",
|
|
2661
2744
|
"screenshot",
|
|
2662
2745
|
"select",
|
|
2663
2746
|
null
|
|
2664
|
-
]),
|
|
2665
|
-
function
|
|
2747
|
+
]), li = 256, ui = "0.7.3";
|
|
2748
|
+
function di(e) {
|
|
2666
2749
|
let t = e.trim().match(/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/);
|
|
2667
2750
|
return t ? [
|
|
2668
2751
|
Number(t[1]),
|
|
@@ -2670,12 +2753,12 @@ function oi(e) {
|
|
|
2670
2753
|
Number(t[3] ?? 0)
|
|
2671
2754
|
] : null;
|
|
2672
2755
|
}
|
|
2673
|
-
function
|
|
2756
|
+
function fi(e) {
|
|
2674
2757
|
return /^v?\d+(?:\.\d+)?(?:\.\d+)?-/.test(e.trim());
|
|
2675
2758
|
}
|
|
2676
|
-
function
|
|
2677
|
-
if (
|
|
2678
|
-
let n =
|
|
2759
|
+
function pi(e, t) {
|
|
2760
|
+
if (fi(e)) return !1;
|
|
2761
|
+
let n = di(e), r = di(t);
|
|
2679
2762
|
if (!n || !r) return !1;
|
|
2680
2763
|
for (let e = 0; e < 3; e++) {
|
|
2681
2764
|
let t = n[e] ?? 0, i = r[e] ?? 0;
|
|
@@ -2684,7 +2767,7 @@ function ci(e, t) {
|
|
|
2684
2767
|
}
|
|
2685
2768
|
return !1;
|
|
2686
2769
|
}
|
|
2687
|
-
var
|
|
2770
|
+
var mi = class extends tt {
|
|
2688
2771
|
get isProcessingQueue() {
|
|
2689
2772
|
return this.queueGuard.current;
|
|
2690
2773
|
}
|
|
@@ -2704,7 +2787,9 @@ var li = class extends Xe {
|
|
|
2704
2787
|
this.retryTimerRef.current = e;
|
|
2705
2788
|
}
|
|
2706
2789
|
constructor(e, t) {
|
|
2707
|
-
super(), this.wsManager = null, this.wsUnsubscribers = [], this.keyboardHandler = null, this.holdActivationHandler = null, this.holdBlurHandler = null, this.toggleHandler = null, this.mouseMoveHandler = null, this.hashChangeHandler = null, this.onlineHandler = null, this.offlineHandler = null, this.initialized = !1, this.destroyed = !1, this.sessionRevision = 0, this.writeRestriction = null, this.authRequestRevision = 0, this.commentsFetchRevision = 0, this.contextFetchRevision = 0, this.deepLinkRequest = null, this.reactionRequests = /* @__PURE__ */ new Map(), this.draftUploads = /* @__PURE__ */ new WeakMap(), this.attachmentRefreshes = /* @__PURE__ */ new Map(), this.screenshotProvider = null, this.bootRetryTimer = null, this.bootAttempts = 0, this.pendingStateUpdates = null, this.flushScheduled = !1, this.isFlushing = !1, this.queueGuard = { current: !1 }, this.activeMutations = /* @__PURE__ */ new Set(), this.sliceSubscribers = /* @__PURE__ */ new Map(), this.retryTimerRef = { current: null }, this.otpFailedAttempts = 0, this.otpCooldownUntil = 0, this.overlayBeforeTool = null, this.loadMoreGuard = { current: !1 }, this.offlinePersistUnsub = null, this.escapeBlockers = /* @__PURE__ */ new Set()
|
|
2790
|
+
super(), this.wsManager = null, this.wsUnsubscribers = [], this.keyboardHandler = null, this.holdActivationHandler = null, this.holdBlurHandler = null, this.toggleHandler = null, this.mouseMoveHandler = null, this.hashChangeHandler = null, this.onlineHandler = null, this.offlineHandler = null, this.initialized = !1, this.destroyed = !1, this.sessionRevision = 0, this.writeRestriction = null, this.authRequestRevision = 0, this.commentsFetchRevision = 0, this.contextFetchRevision = 0, this.deepLinkRequest = null, this.reactionRequests = /* @__PURE__ */ new Map(), this.draftUploads = /* @__PURE__ */ new WeakMap(), this.attachmentRefreshes = /* @__PURE__ */ new Map(), this.screenshotProvider = null, this.bootRetryTimer = null, this.bootAttempts = 0, this.pendingStateUpdates = null, this.flushScheduled = !1, this.isFlushing = !1, this.queueGuard = { current: !1 }, this.activeMutations = /* @__PURE__ */ new Set(), this.sliceSubscribers = /* @__PURE__ */ new Map(), this.retryTimerRef = { current: null }, this.otpFailedAttempts = 0, this.otpCooldownUntil = 0, this.overlayBeforeTool = null, this.loadMoreGuard = { current: !1 }, this.offlinePersistUnsub = null, this.escapeBlockers = /* @__PURE__ */ new Set();
|
|
2791
|
+
let { authToken: n, ...r } = e;
|
|
2792
|
+
this.config = r, this.initialAuthToken = n, this.localDemo = t ?? null, this.localDemo && (this.config.features = {
|
|
2708
2793
|
comments: !0,
|
|
2709
2794
|
drawing: !1,
|
|
2710
2795
|
highlighting: !1,
|
|
@@ -2713,7 +2798,7 @@ var li = class extends Xe {
|
|
|
2713
2798
|
}, this.config.ui = {
|
|
2714
2799
|
...this.config.ui,
|
|
2715
2800
|
loadRemoteFonts: !1
|
|
2716
|
-
}),
|
|
2801
|
+
}), oi && !this.config.environment && (this.config.environment = this.detectEnvironment()), this.apiClient = this.localDemo?.client ?? new ye(this.config), this.apiClient.setOnAuthExpired(() => this.handleAuthExpired()), this.state = Mt(), this.state.activeBranch = typeof e.branch == "string" && e.branch.trim().length <= 255 && !a(e.branch) && e.branch.trim() || null, this.requiresShortcut() && (this.state.isOverlayVisible = !1), this.screenshotProvider = e.screenshotProvider || null, this.ctx = {
|
|
2717
2802
|
getState: () => this.getInternalState(),
|
|
2718
2803
|
setState: (e) => this.setState(e),
|
|
2719
2804
|
apiClient: this.apiClient,
|
|
@@ -2741,7 +2826,7 @@ var li = class extends Xe {
|
|
|
2741
2826
|
mouseMoveHandler: this.mouseMoveHandler
|
|
2742
2827
|
}, this.localDemo && (this.restoreDemoState(), this.localDemo.subscribe((e) => {
|
|
2743
2828
|
e !== "persist" && this.restoreDemoState();
|
|
2744
|
-
})), e.enabled !== !1 &&
|
|
2829
|
+
})), e.enabled !== !1 && oi && Promise.resolve().then(() => this.boot()).catch((e) => this.handleError(e));
|
|
2745
2830
|
/* v8 ignore stop */
|
|
2746
2831
|
}
|
|
2747
2832
|
isLocalDemo() {
|
|
@@ -2751,7 +2836,7 @@ var li = class extends Xe {
|
|
|
2751
2836
|
if (!this.localDemo || this.destroyed) return;
|
|
2752
2837
|
let e = this.localDemo.getSession().expired, t = this.getInternalState().activeBranch ?? null;
|
|
2753
2838
|
this.overlayBeforeTool = null, this.setState({
|
|
2754
|
-
...
|
|
2839
|
+
...Mt(),
|
|
2755
2840
|
currentUser: e ? null : { ...this.localDemo.user },
|
|
2756
2841
|
isAuthenticated: !e,
|
|
2757
2842
|
isOverlayVisible: !e,
|
|
@@ -2796,7 +2881,7 @@ var li = class extends Xe {
|
|
|
2796
2881
|
e?.mode === "hold" && e.key && (this.holdActivationHandler = (e) => {
|
|
2797
2882
|
if (this.destroyed || !this.matchesHoldKey(e)) return;
|
|
2798
2883
|
let t = this.getInternalState().activeTool;
|
|
2799
|
-
e.type === "keydown" && !t ? this.setTool("select") : e.type === "keyup" && t === "select" && this.setTool(null);
|
|
2884
|
+
e.type === "keydown" && !t && !A() ? this.setTool("select") : e.type === "keyup" && t === "select" && this.setTool(null);
|
|
2800
2885
|
}, window.addEventListener("keydown", this.holdActivationHandler), window.addEventListener("keyup", this.holdActivationHandler), this.holdBlurHandler = () => {
|
|
2801
2886
|
this.destroyed || this.getInternalState().activeTool === "select" && this.setTool(null);
|
|
2802
2887
|
}, window.addEventListener("blur", this.holdBlurHandler)), this.toggleHandler = () => this.handleToggleRequest(), window.addEventListener("commentkit:toggle-overlay", this.toggleHandler), this.hashChangeHandler = () => this.handleDeepLink(), window.addEventListener("hashchange", this.hashChangeHandler), this.handleDeepLink(), !this.localDemo && (this.onlineHandler = () => {
|
|
@@ -2844,8 +2929,8 @@ var li = class extends Xe {
|
|
|
2844
2929
|
};
|
|
2845
2930
|
}
|
|
2846
2931
|
let n = e.project?.sdkLatestVersion;
|
|
2847
|
-
n &&
|
|
2848
|
-
current:
|
|
2932
|
+
n && pi(n, "0.7.3") && (console.warn(`[CommentKit] You are using v${ui}. Update to v${n}: npm update @commentkit/comment-kit`), this.emit("sdk:outdated", {
|
|
2933
|
+
current: ui,
|
|
2849
2934
|
latest: n
|
|
2850
2935
|
})), this.setState({
|
|
2851
2936
|
project: e.project,
|
|
@@ -2920,7 +3005,7 @@ var li = class extends Xe {
|
|
|
2920
3005
|
e.activeTool !== void 0 && e.activeTool !== t.activeTool && this.emit("tool:changed", e.activeTool), e.isOverlayVisible !== void 0 && e.isOverlayVisible !== t.isOverlayVisible && this.emit("overlay:toggled", e.isOverlayVisible), e.isSidebarVisible !== void 0 && e.isSidebarVisible !== t.isSidebarVisible && this.emit("sidebar:toggled", e.isSidebarVisible), e.isLoginModalVisible !== void 0 && e.isLoginModalVisible !== t.isLoginModalVisible && this.emit("loginmodal:toggled", e.isLoginModalVisible), e.isShortcutsOverlayVisible !== void 0 && e.isShortcutsOverlayVisible !== t.isShortcutsOverlayVisible && this.emit("shortcuts:toggled", e.isShortcutsOverlayVisible), e.connectionStatus !== void 0 && e.connectionStatus !== t.connectionStatus && this.emit("connection:changed", e.connectionStatus);
|
|
2921
3006
|
let n = Object.keys(e);
|
|
2922
3007
|
for (let [e, t] of this.sliceSubscribers) {
|
|
2923
|
-
let r =
|
|
3008
|
+
let r = kt[e];
|
|
2924
3009
|
if (n.some((e) => r.includes(e))) for (let n of t) try {
|
|
2925
3010
|
n(this.state);
|
|
2926
3011
|
} catch (t) {
|
|
@@ -2949,7 +3034,7 @@ var li = class extends Xe {
|
|
|
2949
3034
|
return this.getWriteAccess().canWrite;
|
|
2950
3035
|
}
|
|
2951
3036
|
getWriteAccess() {
|
|
2952
|
-
return
|
|
3037
|
+
return Ze(this.config, this.getInternalState(), this.writeRestriction);
|
|
2953
3038
|
}
|
|
2954
3039
|
requireCommentWrite() {
|
|
2955
3040
|
let e = this.getWriteAccess();
|
|
@@ -2966,15 +3051,16 @@ var li = class extends Xe {
|
|
|
2966
3051
|
...this.config.enabled !== void 0 && { enabled: this.config.enabled },
|
|
2967
3052
|
screenshotProvider: this.config.screenshotProvider,
|
|
2968
3053
|
branch: this.config.branch,
|
|
3054
|
+
persistence: this.config.persistence,
|
|
2969
3055
|
realtime: this.config.realtime ? { ...this.config.realtime } : void 0,
|
|
2970
3056
|
ui: this.config.ui ? { ...this.config.ui } : void 0
|
|
2971
3057
|
};
|
|
2972
3058
|
}
|
|
2973
3059
|
async validateInvite(e) {
|
|
2974
|
-
if (!(this.destroyed || this.localDemo)) return
|
|
3060
|
+
if (!(this.destroyed || this.localDemo)) return Ot(this.ctx, e, (e) => this.login(e), this.beginAuthRequest());
|
|
2975
3061
|
}
|
|
2976
3062
|
onSlice(e, t) {
|
|
2977
|
-
if (!
|
|
3063
|
+
if (!kt[e] || typeof t != "function" || this.destroyed) return () => {};
|
|
2978
3064
|
let n = this.sliceSubscribers.get(e);
|
|
2979
3065
|
return n || (n = /* @__PURE__ */ new Set(), this.sliceSubscribers.set(e, n)), n.add(t), () => n.delete(t);
|
|
2980
3066
|
}
|
|
@@ -3024,19 +3110,15 @@ var li = class extends Xe {
|
|
|
3024
3110
|
}), this.emit("error", r);
|
|
3025
3111
|
}
|
|
3026
3112
|
async restorePersistedSession() {
|
|
3027
|
-
|
|
3028
|
-
let e =
|
|
3029
|
-
if (e)
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
otpStep: "idle",
|
|
3035
|
-
otpEmail: null,
|
|
3036
|
-
error: null
|
|
3037
|
-
}), this.emit("auth:login", e.user), await this.afterAuthenticated();
|
|
3113
|
+
this.config.persistence === "memory" && ut(this.config.projectId);
|
|
3114
|
+
let e = this.initialAuthToken === void 0 ? this.config.persistence === "memory" ? void 0 : lt(this.config.projectId)?.token : this.initialAuthToken;
|
|
3115
|
+
if (this.initialAuthToken = void 0, e === void 0) return;
|
|
3116
|
+
let t = () => !this.destroyed && this.authRequestRevision === 0;
|
|
3117
|
+
try {
|
|
3118
|
+
let { verifyAndRestoreToken: n } = await import("./token-session-ZzSO1tEl.js");
|
|
3119
|
+
await n(this.ctx, e, t, this.config.persistence !== "memory") && await this.afterAuthenticated();
|
|
3038
3120
|
} catch {
|
|
3039
|
-
this.handleAuthExpired();
|
|
3121
|
+
t() && this.handleAuthExpired();
|
|
3040
3122
|
}
|
|
3041
3123
|
}
|
|
3042
3124
|
async afterAuthenticated(e) {
|
|
@@ -3046,14 +3128,14 @@ var li = class extends Xe {
|
|
|
3046
3128
|
projectContext: null,
|
|
3047
3129
|
activities: [],
|
|
3048
3130
|
seenThreadIds: /* @__PURE__ */ new Set()
|
|
3049
|
-
}),
|
|
3131
|
+
}), br(this.ctx), this.getFeatures().realtime && this.initializeWebSocket(), await Promise.all([this.loadComments(), this.reloadProjectContext()]), this.handleDeepLink(), this.getInternalState().pendingMutations.length > 0 && this.scheduleRetry());
|
|
3050
3132
|
}
|
|
3051
3133
|
beginAuthRequest() {
|
|
3052
3134
|
let e = ++this.authRequestRevision;
|
|
3053
3135
|
return () => !this.destroyed && e === this.authRequestRevision;
|
|
3054
3136
|
}
|
|
3055
3137
|
async login(e) {
|
|
3056
|
-
if (!(this.destroyed || this.localDemo)) return
|
|
3138
|
+
if (!(this.destroyed || this.localDemo)) return xt(this.ctx, e, this.beginAuthRequest());
|
|
3057
3139
|
}
|
|
3058
3140
|
async verifyOtp(e) {
|
|
3059
3141
|
if (this.destroyed || this.localDemo) return;
|
|
@@ -3068,7 +3150,7 @@ var li = class extends Xe {
|
|
|
3068
3150
|
return;
|
|
3069
3151
|
}
|
|
3070
3152
|
let n = this.getInternalState().currentUser?.id;
|
|
3071
|
-
return
|
|
3153
|
+
return St(this.ctx, e, {
|
|
3072
3154
|
isCurrent: this.beginAuthRequest(),
|
|
3073
3155
|
onAuthenticated: async () => {
|
|
3074
3156
|
await this.afterAuthenticated(n);
|
|
@@ -3085,24 +3167,24 @@ var li = class extends Xe {
|
|
|
3085
3167
|
});
|
|
3086
3168
|
}
|
|
3087
3169
|
cancelOtp() {
|
|
3088
|
-
this.destroyed || (this.authRequestRevision++,
|
|
3170
|
+
this.destroyed || (this.authRequestRevision++, Ct(this.ctx));
|
|
3089
3171
|
}
|
|
3090
3172
|
async resendOtp() {
|
|
3091
|
-
if (!(this.destroyed || this.localDemo)) return
|
|
3173
|
+
if (!(this.destroyed || this.localDemo)) return wt(this.ctx, this.beginAuthRequest());
|
|
3092
3174
|
}
|
|
3093
3175
|
logout() {
|
|
3094
3176
|
this.destroyed || (this.authRequestRevision++, this.localDemo ? (this.setTool(null), this.setState({
|
|
3095
3177
|
isOverlayVisible: !1,
|
|
3096
3178
|
isSidebarVisible: !1
|
|
3097
|
-
})) : (this.sessionRevision++, this.draftUploads = /* @__PURE__ */ new WeakMap(), this.writeRestriction = null, this.setState({ projectContext: null }), this.overlayBeforeTool = null,
|
|
3179
|
+
})) : (this.sessionRevision++, this.draftUploads = /* @__PURE__ */ new WeakMap(), this.writeRestriction = null, this.setState({ projectContext: null }), this.overlayBeforeTool = null, Tt(this.ctx, () => {
|
|
3098
3180
|
this.disconnectRealtime(!0);
|
|
3099
3181
|
})));
|
|
3100
3182
|
}
|
|
3101
3183
|
handleAuthExpired() {
|
|
3102
|
-
this.destroyed || (this.authRequestRevision++, this.sessionRevision++, this.draftUploads = /* @__PURE__ */ new WeakMap(), this.writeRestriction = null, this.setState({ projectContext: null }), this.overlayBeforeTool = null, this.disconnectRealtime(!0),
|
|
3184
|
+
this.destroyed || (this.authRequestRevision++, this.sessionRevision++, this.draftUploads = /* @__PURE__ */ new WeakMap(), this.writeRestriction = null, this.setState({ projectContext: null }), this.overlayBeforeTool = null, this.disconnectRealtime(!0), Et(this.ctx));
|
|
3103
3185
|
}
|
|
3104
3186
|
toggleLoginModal() {
|
|
3105
|
-
this.destroyed || this.localDemo ||
|
|
3187
|
+
this.destroyed || this.localDemo || Dt(this.ctx);
|
|
3106
3188
|
}
|
|
3107
3189
|
requiresShortcut() {
|
|
3108
3190
|
return this.localDemo ? !0 : this.config.environment !== "development";
|
|
@@ -3122,7 +3204,7 @@ var li = class extends Xe {
|
|
|
3122
3204
|
this.destroyed || this.setState({ isSidebarVisible: !this.getInternalState().isSidebarVisible });
|
|
3123
3205
|
}
|
|
3124
3206
|
setTool(e) {
|
|
3125
|
-
if (this.destroyed || !
|
|
3207
|
+
if (this.destroyed || !ci.has(e) || this.localDemo && e !== null && e !== "comment" && e !== "select") return;
|
|
3126
3208
|
let t = this.getInternalState();
|
|
3127
3209
|
if (e !== null && e !== "select" && !this.requireCommentWrite()) return;
|
|
3128
3210
|
if (!t.isAuthenticated && e !== "select" && e !== null) {
|
|
@@ -3193,31 +3275,31 @@ var li = class extends Xe {
|
|
|
3193
3275
|
};
|
|
3194
3276
|
}
|
|
3195
3277
|
async loadComments() {
|
|
3196
|
-
return
|
|
3278
|
+
return ln(this.commentsRequestContext(++this.commentsFetchRevision));
|
|
3197
3279
|
}
|
|
3198
3280
|
async loadMoreComments() {
|
|
3199
|
-
this.destroyed || await
|
|
3281
|
+
this.destroyed || await un(this.commentsRequestContext(this.commentsFetchRevision), this.loadMoreGuard);
|
|
3200
3282
|
}
|
|
3201
3283
|
async reloadComments() {
|
|
3202
3284
|
if (!this.destroyed) return this.loadComments();
|
|
3203
3285
|
}
|
|
3204
3286
|
async refreshAttachmentUrl(e) {
|
|
3205
|
-
if (this.destroyed || this.localDemo || !this.getInternalState().isAuthenticated || typeof e != "string" || !e || e.length > 256 ||
|
|
3287
|
+
if (this.destroyed || this.localDemo || !this.getInternalState().isAuthenticated || typeof e != "string" || !e || e.length > 256 || a(e)) return null;
|
|
3206
3288
|
let t = (t) => [...t.attachments ?? [], ...t.replies.flatMap((e) => e.attachments ?? [])].find((t) => t.id === e), n = this.getInternalState().comments.find((e) => t(e));
|
|
3207
3289
|
if (!n) return null;
|
|
3208
|
-
let r = this.sessionRevision,
|
|
3209
|
-
|
|
3290
|
+
let r = this.sessionRevision, i = this.commentsFetchRevision, o = `${r}:${i}:${n.id}`, s = () => !this.destroyed && r === this.sessionRevision && i === this.commentsFetchRevision && this.getInternalState().isAuthenticated, c = this.attachmentRefreshes.get(o);
|
|
3291
|
+
c || (c = (async () => {
|
|
3210
3292
|
try {
|
|
3211
3293
|
let e = await this.apiClient.getComment(n.id);
|
|
3212
|
-
if (!
|
|
3294
|
+
if (!s() || e?.id !== n.id || !Array.isArray(e.replies)) return null;
|
|
3213
3295
|
let t = this.getInternalState(), r = t.comments.find((e) => e.id === n.id);
|
|
3214
3296
|
if (!r) return null;
|
|
3215
3297
|
let i = (e, t) => e?.map((e) => {
|
|
3216
3298
|
let n = t?.find((t) => t.id === e.id);
|
|
3217
|
-
return n &&
|
|
3299
|
+
return n && l(n.url, !0) ? {
|
|
3218
3300
|
...e,
|
|
3219
3301
|
url: n.url,
|
|
3220
|
-
...
|
|
3302
|
+
...l(n.thumbnail, !0) ? { thumbnail: n.thumbnail } : {}
|
|
3221
3303
|
} : e;
|
|
3222
3304
|
}), a = {
|
|
3223
3305
|
...r,
|
|
@@ -3232,17 +3314,17 @@ var li = class extends Xe {
|
|
|
3232
3314
|
...t.selectedComment?.id === n.id ? { selectedComment: a } : {}
|
|
3233
3315
|
}), e;
|
|
3234
3316
|
} catch (e) {
|
|
3235
|
-
return
|
|
3317
|
+
return s() && this.handleError(e), null;
|
|
3236
3318
|
} finally {
|
|
3237
|
-
this.attachmentRefreshes.get(o) ===
|
|
3319
|
+
this.attachmentRefreshes.get(o) === c && this.attachmentRefreshes.delete(o);
|
|
3238
3320
|
}
|
|
3239
|
-
})(), this.attachmentRefreshes.set(o,
|
|
3240
|
-
let u = await
|
|
3241
|
-
if (!
|
|
3321
|
+
})(), this.attachmentRefreshes.set(o, c));
|
|
3322
|
+
let u = await c;
|
|
3323
|
+
if (!s() || !u) return null;
|
|
3242
3324
|
let d = this.getInternalState().comments.find((e) => e.id === n.id);
|
|
3243
3325
|
if (!d || !t(d)) return null;
|
|
3244
3326
|
let f = t(u)?.url;
|
|
3245
|
-
return
|
|
3327
|
+
return l(f, !0) ? f : null;
|
|
3246
3328
|
}
|
|
3247
3329
|
async reloadProjectContext() {
|
|
3248
3330
|
if (this.destroyed || this.localDemo || !this.getInternalState().isAuthenticated) return;
|
|
@@ -3263,7 +3345,7 @@ var li = class extends Xe {
|
|
|
3263
3345
|
}
|
|
3264
3346
|
}
|
|
3265
3347
|
async setBranch(e) {
|
|
3266
|
-
if (this.destroyed || e !== null && (typeof e != "string" || !e.trim() || e.length > 255 ||
|
|
3348
|
+
if (this.destroyed || e !== null && (typeof e != "string" || !e.trim() || e.length > 255 || a(e))) return;
|
|
3267
3349
|
let t = e?.trim() ?? null;
|
|
3268
3350
|
(this.getInternalState().activeBranch ?? null) !== t && (this.setState({
|
|
3269
3351
|
activeBranch: t,
|
|
@@ -3300,45 +3382,45 @@ var li = class extends Xe {
|
|
|
3300
3382
|
});
|
|
3301
3383
|
return;
|
|
3302
3384
|
}
|
|
3303
|
-
let s = o?.[
|
|
3304
|
-
return
|
|
3385
|
+
let s = o?.[nt];
|
|
3386
|
+
return dn(this.operationContext(s), this.operationCallbacks(s), this.activeMutations, e, t, n, r, i, a, {
|
|
3305
3387
|
...o,
|
|
3306
|
-
branch: o?.branch ??
|
|
3388
|
+
branch: o?.branch ?? F(this.ctx)
|
|
3307
3389
|
});
|
|
3308
3390
|
}
|
|
3309
3391
|
async updateComment(e, t) {
|
|
3310
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3392
|
+
if (!this.destroyed && this.requireCommentWrite()) return fn(this.operationContext(), this.operationCallbacks(), e, t);
|
|
3311
3393
|
}
|
|
3312
3394
|
async deleteComment(e) {
|
|
3313
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3395
|
+
if (!this.destroyed && this.requireCommentWrite()) return pn(this.operationContext(), this.operationCallbacks(), e);
|
|
3314
3396
|
}
|
|
3315
3397
|
async addReply(e, t, n) {
|
|
3316
3398
|
if (this.destroyed || !this.requireCommentWrite()) return;
|
|
3317
|
-
let { [
|
|
3318
|
-
return
|
|
3399
|
+
let { [nt]: r, ...i } = n ?? {};
|
|
3400
|
+
return mn(this.operationContext(r), this.operationCallbacks(r), e, t, n ? i : void 0);
|
|
3319
3401
|
}
|
|
3320
3402
|
async updateReply(e, t, n, r) {
|
|
3321
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3403
|
+
if (!this.destroyed && this.requireCommentWrite()) return hn(this.operationContext(), e, t, n, r);
|
|
3322
3404
|
}
|
|
3323
3405
|
async deleteReply(e, t) {
|
|
3324
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3406
|
+
if (!this.destroyed && this.requireCommentWrite()) return gn(this.operationContext(), e, t);
|
|
3325
3407
|
}
|
|
3326
3408
|
async resolveComment(e) {
|
|
3327
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3409
|
+
if (!this.destroyed && this.requireCommentWrite()) return _n(this.operationContext(), this.operationCallbacks(), e);
|
|
3328
3410
|
}
|
|
3329
3411
|
async unresolveComment(e) {
|
|
3330
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3412
|
+
if (!this.destroyed && this.requireCommentWrite()) return vn(this.operationContext(), this.operationCallbacks(), e);
|
|
3331
3413
|
}
|
|
3332
3414
|
selectComment(e) {
|
|
3333
|
-
this.destroyed ||
|
|
3415
|
+
this.destroyed || Sn(this.operationContext(), e);
|
|
3334
3416
|
}
|
|
3335
3417
|
async completeComment(e) {
|
|
3336
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3418
|
+
if (!this.destroyed && this.requireCommentWrite()) return yn(this.operationContext(), this.operationCallbacks(), e);
|
|
3337
3419
|
}
|
|
3338
3420
|
async reactToComment(e, t, n) {
|
|
3339
3421
|
if (this.destroyed || !this.requireCommentWrite()) return;
|
|
3340
3422
|
let r = `${e}:${n ?? "parent"}`, i = this.sessionRevision, a = async () => {
|
|
3341
|
-
!this.destroyed && i === this.sessionRevision && this.requireCommentWrite() && await
|
|
3423
|
+
!this.destroyed && i === this.sessionRevision && this.requireCommentWrite() && await bn(this.operationContext(), this.operationCallbacks(), e, t, n);
|
|
3342
3424
|
}, o = this.reactionRequests.get(r), s = o ? o.then(a, a) : a();
|
|
3343
3425
|
this.reactionRequests.set(r, s);
|
|
3344
3426
|
try {
|
|
@@ -3348,32 +3430,33 @@ var li = class extends Xe {
|
|
|
3348
3430
|
}
|
|
3349
3431
|
}
|
|
3350
3432
|
async updateCommentPosition(e, t, n) {
|
|
3351
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3433
|
+
if (!this.destroyed && this.requireCommentWrite()) return xn(this.operationContext(), this.operationCallbacks(), e, t, n);
|
|
3352
3434
|
}
|
|
3353
3435
|
hydrateOfflineQueue() {
|
|
3354
|
-
|
|
3436
|
+
if (this.config.persistence === "memory") return;
|
|
3437
|
+
let e = hr(this.config.projectId);
|
|
3355
3438
|
if (e.length > 0) {
|
|
3356
3439
|
let t = this.getInternalState().pendingMutations, n = new Set(t.map((e) => e.id)), r = [...t, ...e.filter((e) => !n.has(e.id))];
|
|
3357
|
-
this.setState({ pendingMutations: r }),
|
|
3440
|
+
this.setState({ pendingMutations: r }), br(this.ctx), this.getInternalState().isOnline && this.scheduleRetry();
|
|
3358
3441
|
}
|
|
3359
|
-
this.offlinePersistUnsub?.(), this.offlinePersistUnsub = this.select((e) => e.pendingMutations, (e) =>
|
|
3442
|
+
this.offlinePersistUnsub?.(), this.offlinePersistUnsub = this.select((e) => e.pendingMutations, (e) => mr(this.config.projectId, e));
|
|
3360
3443
|
}
|
|
3361
3444
|
shouldQueueMutation(e) {
|
|
3362
|
-
return !this.localDemo &&
|
|
3445
|
+
return !this.localDemo && xr(this.getInternalState(), e);
|
|
3363
3446
|
}
|
|
3364
3447
|
queueMutation(e, t, n) {
|
|
3365
|
-
return
|
|
3448
|
+
return Sr(this.ctx, () => this.scheduleRetry(), e, t, n);
|
|
3366
3449
|
}
|
|
3367
3450
|
scheduleRetry() {
|
|
3368
|
-
|
|
3451
|
+
Cr(this.ctx, this.retryTimerRef, () => this.processOfflineQueue());
|
|
3369
3452
|
}
|
|
3370
3453
|
async processOfflineQueue() {
|
|
3371
|
-
this.canWriteComments() && await
|
|
3454
|
+
this.canWriteComments() && await wr(this.operationContext(), this.queueGuard, () => this.scheduleRetry(), (e) => this.executeMutation(e));
|
|
3372
3455
|
}
|
|
3373
3456
|
async executeMutation(e) {
|
|
3374
3457
|
let t = this.operationContext();
|
|
3375
3458
|
try {
|
|
3376
|
-
await
|
|
3459
|
+
await Or(t, e);
|
|
3377
3460
|
} catch (e) {
|
|
3378
3461
|
throw e instanceof T && e.code === 402 && t.handleError(e), e;
|
|
3379
3462
|
}
|
|
@@ -3388,7 +3471,7 @@ var li = class extends Xe {
|
|
|
3388
3471
|
!this.destroyed && this.getInternalState().isAuthenticated && (this.wsManager ? this.wsManager.reconnect() : this.initializeWebSocket());
|
|
3389
3472
|
}
|
|
3390
3473
|
markThreadSeen(e) {
|
|
3391
|
-
if (this.destroyed || typeof e != "string" || !e.trim() || e.length >
|
|
3474
|
+
if (this.destroyed || typeof e != "string" || !e.trim() || e.length > li) return;
|
|
3392
3475
|
let t = new Set(this.getInternalState().seenThreadIds);
|
|
3393
3476
|
if (t.add(e), t.size > 1e3) {
|
|
3394
3477
|
let e = Array.from(t);
|
|
@@ -3401,7 +3484,7 @@ var li = class extends Xe {
|
|
|
3401
3484
|
return typeof e != "string" || !e.trim() ? !1 : !this.getInternalState().seenThreadIds.has(e);
|
|
3402
3485
|
}
|
|
3403
3486
|
setPanelView(e) {
|
|
3404
|
-
!this.destroyed &&
|
|
3487
|
+
!this.destroyed && si.has(e) && this.setState({ panelView: e });
|
|
3405
3488
|
}
|
|
3406
3489
|
toggleShortcutsOverlay() {
|
|
3407
3490
|
this.destroyed || this.setState({ isShortcutsOverlayVisible: !this.getInternalState().isShortcutsOverlayVisible });
|
|
@@ -3465,10 +3548,10 @@ var li = class extends Xe {
|
|
|
3465
3548
|
}
|
|
3466
3549
|
}
|
|
3467
3550
|
async createHighlight(e, t) {
|
|
3468
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3551
|
+
if (!this.destroyed && this.requireCommentWrite()) return Cn(this.operationContext(), this.operationCallbacks(), this.activeMutations, e, t);
|
|
3469
3552
|
}
|
|
3470
3553
|
async createDrawing(e, t, n) {
|
|
3471
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3554
|
+
if (!this.destroyed && this.requireCommentWrite()) return wn(this.operationContext(), this.operationCallbacks(), this.activeMutations, e, t, n);
|
|
3472
3555
|
}
|
|
3473
3556
|
setActiveDrawing(e) {
|
|
3474
3557
|
this.destroyed || this.setState({ activeDrawing: e });
|
|
@@ -3477,22 +3560,22 @@ var li = class extends Xe {
|
|
|
3477
3560
|
!this.destroyed && this.requireCommentWrite() && this.wsManager?.sendDrawingStroke(e);
|
|
3478
3561
|
}
|
|
3479
3562
|
async captureScreenshot(e) {
|
|
3480
|
-
return this.destroyed ? null :
|
|
3563
|
+
return this.destroyed ? null : ni(this.ctx, this.screenshotProvider, e);
|
|
3481
3564
|
}
|
|
3482
3565
|
async uploadScreenshot(e, t, n) {
|
|
3483
|
-
return this.destroyed || !this.requireCommentWrite() ? null :
|
|
3566
|
+
return this.destroyed || !this.requireCommentWrite() ? null : ri(this.operationContext(), e, t, n);
|
|
3484
3567
|
}
|
|
3485
3568
|
setActiveScreenshot(e) {
|
|
3486
3569
|
this.destroyed || this.setState({ activeScreenshot: e });
|
|
3487
3570
|
}
|
|
3488
3571
|
async uploadFiles(e, t) {
|
|
3489
|
-
return this.destroyed || !this.requireCommentWrite() ? [] :
|
|
3572
|
+
return this.destroyed || !this.requireCommentWrite() ? [] : ii(this.ctx, e, t);
|
|
3490
3573
|
}
|
|
3491
3574
|
getAgentContext(e) {
|
|
3492
3575
|
return O(this.getInternalState(), e);
|
|
3493
3576
|
}
|
|
3494
3577
|
async getAgentContextAsync(e) {
|
|
3495
|
-
let t = O(this.getInternalState(), e), n = this.localDemo?.getRevision(), r = await
|
|
3578
|
+
let t = O(this.getInternalState(), e), n = this.localDemo?.getRevision(), r = await Ue(t);
|
|
3496
3579
|
return this.localDemo?.checkExpiry(), this.localDemo && n !== this.localDemo.getRevision() ? O(this.getInternalState(), e) : r;
|
|
3497
3580
|
}
|
|
3498
3581
|
formatAgentContext(e) {
|
|
@@ -3504,14 +3587,14 @@ var li = class extends Xe {
|
|
|
3504
3587
|
async copyAgentContext(e) {
|
|
3505
3588
|
if (this.destroyed) return "";
|
|
3506
3589
|
let t = await this.getAgentContextAsync(e), n = k(t);
|
|
3507
|
-
return await
|
|
3590
|
+
return await Xe(n, t), this.emit("agent:context-copied", {
|
|
3508
3591
|
commentCount: t.comments.length,
|
|
3509
3592
|
sourceResolved: t.sourceResolved
|
|
3510
3593
|
}), n;
|
|
3511
3594
|
}
|
|
3512
3595
|
async grabElement(e, t) {
|
|
3513
3596
|
if (this.destroyed) return null;
|
|
3514
|
-
let { grabElement: n } = await import("./dev-grab-
|
|
3597
|
+
let { grabElement: n } = await import("./dev-grab-Cc-lJYBv.js");
|
|
3515
3598
|
if (this.destroyed) return null;
|
|
3516
3599
|
let r = await n(e, this.ctx, this.screenshotProvider, t);
|
|
3517
3600
|
return this.destroyed ? null : (r && this.emit("agent:element-grabbed", {
|
|
@@ -3521,7 +3604,7 @@ var li = class extends Xe {
|
|
|
3521
3604
|
}
|
|
3522
3605
|
async grabElements(e, t) {
|
|
3523
3606
|
if (this.destroyed) return null;
|
|
3524
|
-
let { grabElements: n } = await import("./dev-grab-
|
|
3607
|
+
let { grabElements: n } = await import("./dev-grab-Cc-lJYBv.js");
|
|
3525
3608
|
if (this.destroyed) return null;
|
|
3526
3609
|
let r = await n(e, this.ctx, this.screenshotProvider, t);
|
|
3527
3610
|
return this.destroyed ? null : (r && this.emit("agent:elements-grabbed", { count: r.results.length }), r);
|
|
@@ -3535,16 +3618,16 @@ var li = class extends Xe {
|
|
|
3535
3618
|
}
|
|
3536
3619
|
}
|
|
3537
3620
|
handleToggleRequest() {
|
|
3538
|
-
this.destroyed ||
|
|
3621
|
+
this.destroyed || A() || Rn(this.getInternalState(), this.kbdCallbacks);
|
|
3539
3622
|
}
|
|
3540
3623
|
handleKeyboardShortcuts(e) {
|
|
3541
|
-
if (!this.destroyed) {
|
|
3624
|
+
if (!(this.destroyed || A())) {
|
|
3542
3625
|
if (e.key === "Escape") {
|
|
3543
|
-
if (this.escapeBlockers.size > 0
|
|
3626
|
+
if (this.escapeBlockers.size > 0) return;
|
|
3544
3627
|
let t = e.composedPath()[0];
|
|
3545
3628
|
if (t instanceof Element && t.getRootNode() === document && t.closest("[data-commentkit-ui], [data-commentkit-ignore]")) return;
|
|
3546
3629
|
}
|
|
3547
|
-
|
|
3630
|
+
zn(e, this.getInternalState(), this.kbdCallbacks);
|
|
3548
3631
|
}
|
|
3549
3632
|
}
|
|
3550
3633
|
matchesHoldKey(e) {
|
|
@@ -3558,7 +3641,7 @@ var li = class extends Xe {
|
|
|
3558
3641
|
};
|
|
3559
3642
|
}
|
|
3560
3643
|
initializeWebSocket() {
|
|
3561
|
-
this.destroyed || this.localDemo ||
|
|
3644
|
+
this.destroyed || this.localDemo || ai().then((e) => {
|
|
3562
3645
|
this.destroyed || this.getInternalState().isAuthenticated && (this.syncRealtimeRefs(), e.initializeWebSocket(this.ctx, this.realtimeRefs, {
|
|
3563
3646
|
capture: () => this.commentsRequestContext(this.commentsFetchRevision),
|
|
3564
3647
|
subscribe: (e) => this.on("state:changed", e)
|
|
@@ -3595,7 +3678,7 @@ var li = class extends Xe {
|
|
|
3595
3678
|
this.removeMouseMoveListener(), this.syncRealtimeRefs();
|
|
3596
3679
|
}
|
|
3597
3680
|
destroy() {
|
|
3598
|
-
this.destroyed || (this.destroyed = !0,
|
|
3681
|
+
this.destroyed || (this.destroyed = !0, this.initialAuthToken = void 0, oi && (this.keyboardHandler && window.removeEventListener("keydown", this.keyboardHandler, !0), this.holdActivationHandler && (window.removeEventListener("keydown", this.holdActivationHandler), window.removeEventListener("keyup", this.holdActivationHandler)), this.holdBlurHandler && window.removeEventListener("blur", this.holdBlurHandler), this.toggleHandler && window.removeEventListener("commentkit:toggle-overlay", this.toggleHandler), this.hashChangeHandler && window.removeEventListener("hashchange", this.hashChangeHandler), this.onlineHandler && window.removeEventListener("online", this.onlineHandler), this.offlineHandler && window.removeEventListener("offline", this.offlineHandler)), this.pendingStateUpdates = null, this.flushScheduled = !1, this.activeMutations.clear(), this.offlinePersistUnsub?.(), this.offlinePersistUnsub = null, this.retryTimer &&= (clearTimeout(this.retryTimer), null), this.bootRetryTimer &&= (clearTimeout(this.bootRetryTimer), null), this.disconnectRealtime(!0), this.localDemo?.destroy(), this.sliceSubscribers.clear(), this.removeAllListeners());
|
|
3599
3682
|
}
|
|
3600
3683
|
};
|
|
3601
|
-
export {
|
|
3684
|
+
export { ye as _, yt as a, w as b, nt as c, Ze as d, Ye as f, Te as g, k as h, bt as i, tt as l, O as m, ui as n, ct as o, Xe as p, ni as r, j as s, mi as t, A as u, T as v, xe as x, be as y };
|