@commentkit/comment-kit 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -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 +36 -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-CZI1KVdW.js +1094 -0
- package/dist/shared/attachment-refresh-mQw-L7hB.js +94 -0
- package/dist/shared/{button-group-Cl9CrvvU.js → button-group-C285iSkZ.js} +14 -16
- package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
- package/dist/shared/capture-privacy-DUROnio5.js +77 -0
- package/dist/shared/{comment-drawing-canvas-Dzb5YoFw.js → comment-drawing-canvas-CYFFKgCm.js} +2 -2
- package/dist/shared/{comment-utils-BycYTSxA.js → comment-icon-4SQd3nlz.js} +30 -24
- package/dist/shared/comment-image-lightbox-DmTNxuqX.js +190 -0
- package/dist/shared/comment-images-content-BX4DQ9Ol.js +214 -0
- package/dist/shared/{comment-kit-core-BaSuMzp9.js → comment-kit-core-VuIidMeu.js} +1096 -793
- package/dist/shared/{comment-kit-ui-CzfdAZs2.js → comment-kit-ui-BjJ1ZLiv.js} +6091 -6486
- package/dist/shared/{comment-screenshot-annotator-C7X-_bm6.js → comment-screenshot-annotator-CMOG1md7.js} +5 -5
- package/dist/shared/{comment-screenshot-overlay-wIrZrcRy.js → comment-screenshot-overlay-iWW-V-Iw.js} +114 -118
- package/dist/shared/comment-shortcut-groups-CfEmkitU.js +153 -0
- package/dist/shared/{dev-export-panel-FwFVdady.js → dev-export-panel-CrRENbMn.js} +9 -10
- package/dist/shared/dev-grab-Ca4MlS2Y.js +196 -0
- package/dist/shared/{element-selector-BhJm-NSs.js → element-selector-g1bTvdEA.js} +450 -408
- package/dist/shared/{mount-ui--ijs8pWT.js → mount-ui-Dz5QLq4W.js} +121 -106
- package/dist/shared/{pusher-ipHMJnO_.js → pusher-ue0D83de.js} +1 -1
- package/dist/shared/realtime-CieWAnsW.js +321 -0
- package/dist/shared/realtime-recovery-BSVMwsXJ.js +135 -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-C5v-T8lQ.js → shadow-root-Cv1aLuFf.js} +31 -31
- package/dist/shared/{styles-D3yMtaec.js → styles-CnYsLS2f.js} +1 -1
- package/dist/shared/text-B4HHZNaa.js +23 -0
- package/dist/shared/token-session-CPQpt3-u.js +25 -0
- package/dist/shared/useRender-D1z_X_BY.js +5 -0
- package/dist/shared/{validation-C7QG8j7Z.js → validation-3wbbbuX0.js} +26 -1
- package/dist/shared/websocket-manager-BnK55c3U.js +381 -0
- package/dist/solid.es.js +2 -2
- package/dist/svelte.es.js +2 -2
- package/dist/types/core/api-client.d.ts +11 -2
- package/dist/types/core/comment-kit-core.d.ts +11 -5
- package/dist/types/core/types.d.ts +54 -2
- package/dist/types/core/websocket-manager.d.ts +13 -0
- package/dist/types/core/write-access.d.ts +9 -0
- package/dist/vue.es.js +2 -2
- package/docs/api-reference.md +25 -4
- package/package.json +3 -2
- package/dist/shared/annotation-toolbar-B9SxYqoF.js +0 -1093
- package/dist/shared/comment-image-lightbox-BPYJT1sB.js +0 -183
- package/dist/shared/dev-grab-DDqg0LQf.js +0 -203
- package/dist/shared/realtime-Dk41VwKg.js +0 -302
- package/dist/shared/websocket-manager-DhLWh3Jr.js +0 -302
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { a as e, c as t,
|
|
2
|
-
import {
|
|
3
|
-
|
|
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 = [
|
|
4
7
|
".png",
|
|
5
8
|
".jpg",
|
|
6
9
|
".jpeg",
|
|
7
10
|
".gif",
|
|
8
11
|
".webp"
|
|
9
|
-
],
|
|
12
|
+
], ue = [
|
|
10
13
|
"image/png",
|
|
11
14
|
"image/jpeg",
|
|
12
15
|
"image/gif",
|
|
13
16
|
"image/webp"
|
|
14
|
-
],
|
|
17
|
+
], de = /@\[([^\]]+)\]\(([^)]+)\)/g, x = {
|
|
15
18
|
invalid_api_key: "Authentication failed. Please check your API key.",
|
|
16
19
|
missing_api_key: "Authentication failed. Please check your API key.",
|
|
17
20
|
origin_not_allowed: "This domain is not allowed to use this project's API key.",
|
|
@@ -35,74 +38,85 @@ var d = "https://api.commentkit.dev/api", f = 3e4, p = 10485760, m = 10, h = 1e4
|
|
|
35
38
|
email_mismatch: "This invite was issued for a different email address.",
|
|
36
39
|
quota_exceeded: "This project has reached its plan limit."
|
|
37
40
|
};
|
|
38
|
-
function
|
|
41
|
+
function fe(e, t) {
|
|
39
42
|
let n = {};
|
|
40
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) => ({
|
|
41
44
|
...e,
|
|
42
45
|
id: /^\d+$/.test(e.id) ? Number(e.id) : null
|
|
43
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;
|
|
44
47
|
}
|
|
45
|
-
function
|
|
48
|
+
function pe(e) {
|
|
46
49
|
return e === "localhost" || e === "127.0.0.1" || e === "[::1]" || e.endsWith(".localhost");
|
|
47
50
|
}
|
|
48
|
-
function
|
|
49
|
-
let t = (e ||
|
|
51
|
+
function me(e) {
|
|
52
|
+
let t = (e || b).trim().replace(/\/+$/, "");
|
|
50
53
|
try {
|
|
51
54
|
let e = new URL(t);
|
|
55
|
+
if (e.username || e.password || e.search || e.hash || a(t)) throw Error("ambiguous endpoint");
|
|
52
56
|
if (e.protocol !== "https:" && e.protocol !== "http:") throw Error("unsupported protocol");
|
|
53
|
-
if (e.protocol === "http:" && !
|
|
57
|
+
if (e.protocol === "http:" && !pe(e.hostname)) throw Error("insecure protocol");
|
|
54
58
|
} catch {
|
|
55
|
-
throw new
|
|
59
|
+
throw new T("invalid_base_url", "Invalid API base URL", 400);
|
|
56
60
|
}
|
|
57
61
|
return t;
|
|
58
62
|
}
|
|
59
63
|
function S(e) {
|
|
60
64
|
let t = String(e).trim();
|
|
61
|
-
if (!t ||
|
|
65
|
+
if (!t || a(t)) throw new T("invalid_id", "Invalid identifier", 400);
|
|
62
66
|
return encodeURIComponent(t);
|
|
63
67
|
}
|
|
64
|
-
function
|
|
65
|
-
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);
|
|
66
70
|
let t = e.trim();
|
|
67
|
-
if (!
|
|
71
|
+
if (!s(t, oe)) throw new T("invalid_email", "A valid email address is required", 400);
|
|
68
72
|
return t;
|
|
69
73
|
}
|
|
70
|
-
function
|
|
71
|
-
if (
|
|
74
|
+
function ge(e) {
|
|
75
|
+
if (a(e)) throw new T("invalid_otp", "A valid OTP code is required", 400);
|
|
72
76
|
let t = e.trim();
|
|
73
|
-
if (t.length !==
|
|
77
|
+
if (t.length !== se || /\s/.test(t)) throw new T("invalid_otp", "A valid OTP code is required", 400);
|
|
74
78
|
return t;
|
|
75
79
|
}
|
|
76
|
-
function
|
|
77
|
-
if (
|
|
80
|
+
function _e(e) {
|
|
81
|
+
if (a(e)) throw new T("invalid_token", "A valid invite token is required", 400);
|
|
78
82
|
let t = e.trim();
|
|
79
|
-
if (t.length !== 64 || !/^[\w-]+$/.test(t)) throw new
|
|
83
|
+
if (t.length !== 64 || !/^[\w-]+$/.test(t)) throw new T("invalid_token", "A valid invite token is required", 400);
|
|
80
84
|
return t;
|
|
81
85
|
}
|
|
82
|
-
function
|
|
86
|
+
function C(e, t, n = ie) {
|
|
83
87
|
let r = e.trim();
|
|
84
|
-
if (!r) throw new
|
|
85
|
-
if (r.length > n) throw new
|
|
88
|
+
if (!r) throw new T("invalid_content", `${t} cannot be empty`, 400);
|
|
89
|
+
if (r.length > n) throw new T("content_too_long", `${t} exceeds maximum length of ${n} characters`, 400);
|
|
86
90
|
return r;
|
|
87
91
|
}
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
let t
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
function ve(e, t) {
|
|
93
|
+
let n = {};
|
|
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)) {
|
|
96
|
+
let e = {};
|
|
97
|
+
for (let n of [
|
|
98
|
+
"type",
|
|
99
|
+
"feature",
|
|
100
|
+
"plan",
|
|
101
|
+
"reason"
|
|
102
|
+
]) typeof t[n] == "string" && (e[n] = t[n].slice(0, 64));
|
|
103
|
+
for (let n of ["current", "limit"]) typeof t[n] == "number" && Number.isFinite(t[n]) && (e[n] = t[n]);
|
|
104
|
+
Object.keys(e).length && (n.quota = e);
|
|
105
|
+
}
|
|
106
|
+
return Object.keys(n).length > 0 ? n : void 0;
|
|
107
|
+
}
|
|
108
|
+
var ye = class {
|
|
95
109
|
constructor(e) {
|
|
96
|
-
this.projectId = 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;
|
|
97
111
|
}
|
|
98
|
-
setProject(e) {
|
|
99
|
-
this.projectId = String(e).trim();
|
|
112
|
+
setProject(e, t = e) {
|
|
113
|
+
this.projectId = String(e).trim(), this.channelProjectId = String(t).trim();
|
|
100
114
|
}
|
|
101
115
|
setUserEmail(e) {
|
|
102
|
-
this.userEmail = e ?
|
|
116
|
+
this.userEmail = e ? he(e) : null;
|
|
103
117
|
}
|
|
104
118
|
setAuthToken(e) {
|
|
105
|
-
if (e && (
|
|
119
|
+
if (e && (a(e) || e.length > ce)) throw new T("invalid_token", "A valid auth token is required", 400);
|
|
106
120
|
let t = e?.trim() || null;
|
|
107
121
|
this.authToken = t, this.authRevision++;
|
|
108
122
|
}
|
|
@@ -113,7 +127,7 @@ var ce = class {
|
|
|
113
127
|
this.onAuthExpired = e;
|
|
114
128
|
}
|
|
115
129
|
buildHeaders(e) {
|
|
116
|
-
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);
|
|
117
131
|
return {
|
|
118
132
|
"X-API-Key": this.apiKey,
|
|
119
133
|
...this.userEmail ? { "X-User-Email": this.userEmail } : {},
|
|
@@ -122,26 +136,31 @@ var ce = class {
|
|
|
122
136
|
};
|
|
123
137
|
}
|
|
124
138
|
async executeRequest(e, t, n, r) {
|
|
125
|
-
let
|
|
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);
|
|
126
140
|
try {
|
|
127
|
-
let
|
|
141
|
+
let s = await fetch(e, {
|
|
128
142
|
...t,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
c.
|
|
133
|
-
|
|
134
|
-
|
|
143
|
+
credentials: "omit",
|
|
144
|
+
redirect: "manual",
|
|
145
|
+
referrerPolicy: "no-referrer",
|
|
146
|
+
signal: c.signal
|
|
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);
|
|
150
|
+
if (!s.ok) {
|
|
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 : n;
|
|
153
|
+
throw new T(t, x[t] ?? r, s.status, ve(e.details, e.quota));
|
|
135
154
|
}
|
|
136
155
|
return l;
|
|
137
156
|
} catch (e) {
|
|
138
|
-
if (e instanceof
|
|
139
|
-
if (e instanceof DOMException && e.name === "AbortError") throw new
|
|
140
|
-
if (e instanceof TypeError) throw new
|
|
141
|
-
let t = new
|
|
157
|
+
if (e instanceof T) throw e;
|
|
158
|
+
if (e instanceof DOMException && e.name === "AbortError") throw new T("timeout", "Request timed out. Please try again.", 408);
|
|
159
|
+
if (e instanceof TypeError) throw new T("network_error", "Unable to connect to servers. Please check your connection.", 0);
|
|
160
|
+
let t = new T("unknown_error", "An unexpected error occurred", 500);
|
|
142
161
|
throw t.cause = e, t;
|
|
143
162
|
} finally {
|
|
144
|
-
clearTimeout(
|
|
163
|
+
clearTimeout(l), s?.();
|
|
145
164
|
}
|
|
146
165
|
}
|
|
147
166
|
async parseResponseBody(e) {
|
|
@@ -151,20 +170,20 @@ var ce = class {
|
|
|
151
170
|
let n = await e.text();
|
|
152
171
|
if (!n) return {};
|
|
153
172
|
if (t && !t.toLowerCase().includes("application/json")) {
|
|
154
|
-
if (e.ok) throw new
|
|
173
|
+
if (e.ok) throw new T("invalid_response", "Invalid server response", 502);
|
|
155
174
|
return {};
|
|
156
175
|
}
|
|
157
176
|
try {
|
|
158
177
|
return JSON.parse(n);
|
|
159
178
|
} catch {
|
|
160
|
-
if (e.ok) throw new
|
|
179
|
+
if (e.ok) throw new T("invalid_response", "Invalid server response", 502);
|
|
161
180
|
return {};
|
|
162
181
|
}
|
|
163
182
|
}
|
|
164
183
|
if (typeof e.json == "function") try {
|
|
165
184
|
return await e.json();
|
|
166
185
|
} catch {
|
|
167
|
-
if (e.ok) throw new
|
|
186
|
+
if (e.ok) throw new T("invalid_response", "Invalid server response", 502);
|
|
168
187
|
}
|
|
169
188
|
return {};
|
|
170
189
|
}
|
|
@@ -187,7 +206,7 @@ var ce = class {
|
|
|
187
206
|
}, "upload_failed", "Upload failed");
|
|
188
207
|
}
|
|
189
208
|
requireProjectId() {
|
|
190
|
-
if (!this.projectId) throw new
|
|
209
|
+
if (!this.projectId) throw new T("missing_project_id", "Project ID is required", 400);
|
|
191
210
|
return this.projectId;
|
|
192
211
|
}
|
|
193
212
|
async validateApiKey() {
|
|
@@ -196,15 +215,42 @@ var ce = class {
|
|
|
196
215
|
body: JSON.stringify({})
|
|
197
216
|
});
|
|
198
217
|
}
|
|
218
|
+
async verifySession() {
|
|
219
|
+
return this.request("/auth/me");
|
|
220
|
+
}
|
|
221
|
+
async authorizeChannel(e, t) {
|
|
222
|
+
if (!this.authToken) throw new T("unauthorized", x.unauthorized, 401);
|
|
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);
|
|
224
|
+
let n = this.authRevision, r = await this.request("/broadcasting/auth", {
|
|
225
|
+
method: "POST",
|
|
226
|
+
body: JSON.stringify({
|
|
227
|
+
socket_id: e,
|
|
228
|
+
channel_name: t
|
|
229
|
+
})
|
|
230
|
+
});
|
|
231
|
+
if (n !== this.authRevision) throw new T("unauthorized", x.unauthorized, 401);
|
|
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;
|
|
234
|
+
try {
|
|
235
|
+
i = JSON.parse(r.channel_data);
|
|
236
|
+
} catch {
|
|
237
|
+
throw new T("invalid_response", x.invalid_response, 502);
|
|
238
|
+
}
|
|
239
|
+
if (!o(i) || !i.user_id) throw new T("invalid_response", x.invalid_response, 502);
|
|
240
|
+
return {
|
|
241
|
+
auth: r.auth,
|
|
242
|
+
channel_data: r.channel_data
|
|
243
|
+
};
|
|
244
|
+
}
|
|
199
245
|
async requestOtp(e) {
|
|
200
|
-
let t =
|
|
246
|
+
let t = he(e);
|
|
201
247
|
return this.request("/auth/otp/request", {
|
|
202
248
|
method: "POST",
|
|
203
249
|
body: JSON.stringify({ email: t })
|
|
204
250
|
});
|
|
205
251
|
}
|
|
206
252
|
async verifyOtp(e, t) {
|
|
207
|
-
let n =
|
|
253
|
+
let n = he(e), r = ge(t);
|
|
208
254
|
return this.request("/auth/otp/verify", {
|
|
209
255
|
method: "POST",
|
|
210
256
|
body: JSON.stringify({
|
|
@@ -214,7 +260,7 @@ var ce = class {
|
|
|
214
260
|
});
|
|
215
261
|
}
|
|
216
262
|
async validateInvite(e, t) {
|
|
217
|
-
let n =
|
|
263
|
+
let n = _e(e), r = he(t);
|
|
218
264
|
return this.request("/auth/validate-invite", {
|
|
219
265
|
method: "POST",
|
|
220
266
|
body: JSON.stringify({
|
|
@@ -244,10 +290,10 @@ var ce = class {
|
|
|
244
290
|
return (await this.request(`/projects/${S(t)}/comments/${S(e)}`)).comment;
|
|
245
291
|
}
|
|
246
292
|
idempotencyHeaders(e) {
|
|
247
|
-
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 } : {};
|
|
248
294
|
}
|
|
249
295
|
async createComment(e, t, n, r, i = "medium", a, o, s, c) {
|
|
250
|
-
let l =
|
|
296
|
+
let l = C(t, "Comment content"), u = this.requireProjectId(), d = s?.mentions ?? w(l);
|
|
251
297
|
return (await this.request(`/projects/${S(u)}/comments`, {
|
|
252
298
|
method: "POST",
|
|
253
299
|
headers: this.idempotencyHeaders(c),
|
|
@@ -260,7 +306,7 @@ var ce = class {
|
|
|
260
306
|
environment: this.environment || void 0,
|
|
261
307
|
branch: s?.branch,
|
|
262
308
|
device_info: s?.deviceInfo,
|
|
263
|
-
...
|
|
309
|
+
...fe({
|
|
264
310
|
content: l,
|
|
265
311
|
priority: i,
|
|
266
312
|
description: s?.description,
|
|
@@ -274,7 +320,7 @@ var ce = class {
|
|
|
274
320
|
})).comment;
|
|
275
321
|
}
|
|
276
322
|
async updateComment(e, t) {
|
|
277
|
-
let n = this.requireProjectId(), r = t.content === void 0 ? void 0 :
|
|
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({
|
|
278
324
|
...t,
|
|
279
325
|
...r === void 0 ? {} : { content: r }
|
|
280
326
|
}, i);
|
|
@@ -288,7 +334,7 @@ var ce = class {
|
|
|
288
334
|
await this.request(`/projects/${S(t)}/comments/${S(e)}`, { method: "DELETE" });
|
|
289
335
|
}
|
|
290
336
|
async addReply(e, t, n, r) {
|
|
291
|
-
let i = this.requireProjectId(), a =
|
|
337
|
+
let i = this.requireProjectId(), a = C(t, "Reply content", ae), o = r?.mentions ?? w(a);
|
|
292
338
|
return (await this.request(`/projects/${S(i)}/comments/${S(e)}/replies`, {
|
|
293
339
|
method: "POST",
|
|
294
340
|
headers: this.idempotencyHeaders(n),
|
|
@@ -301,7 +347,7 @@ var ce = class {
|
|
|
301
347
|
})).reply;
|
|
302
348
|
}
|
|
303
349
|
async updateReply(e, t, n, r) {
|
|
304
|
-
let i = this.requireProjectId(), a =
|
|
350
|
+
let i = this.requireProjectId(), a = C(n, "Reply content", ae);
|
|
305
351
|
return (await this.request(`/projects/${S(i)}/comments/${S(e)}/replies/${S(t)}`, {
|
|
306
352
|
method: "PUT",
|
|
307
353
|
body: JSON.stringify({
|
|
@@ -365,15 +411,15 @@ var ce = class {
|
|
|
365
411
|
return this.createComment("drawing", e, n, r, "medium", void 0, t, a, i);
|
|
366
412
|
}
|
|
367
413
|
validateFile(e, t = !1) {
|
|
368
|
-
if (e.size >
|
|
369
|
-
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);
|
|
370
416
|
if (t) {
|
|
371
417
|
/* v8 ignore next -- pop() always returns a value since file has a name */
|
|
372
418
|
let t = "." + (e.name.split(".").pop()?.toLowerCase() ?? "");
|
|
373
|
-
if ((e.name.match(/\./g) || []).length > 1) throw new
|
|
374
|
-
if (!
|
|
419
|
+
if ((e.name.match(/\./g) || []).length > 1) throw new T("invalid_filename", "Filenames with multiple extensions are not allowed", 400);
|
|
420
|
+
if (!ue.includes(e.type) || !le.includes(t)) throw new T("invalid_file_type", `Only image files are allowed (${le.join(", ")})`, 400);
|
|
375
421
|
}
|
|
376
|
-
if (
|
|
422
|
+
if (u(e.name)) throw new T("invalid_file_type", "This file type is not allowed", 400);
|
|
377
423
|
}
|
|
378
424
|
async uploadFile(e, t, n) {
|
|
379
425
|
this.validateFile(e, t === "screenshot" || t === "drawing");
|
|
@@ -392,23 +438,23 @@ var ce = class {
|
|
|
392
438
|
}
|
|
393
439
|
async uploadScreenshot(e, t) {
|
|
394
440
|
this.validateFile(e, !0);
|
|
395
|
-
let n =
|
|
441
|
+
let n = C(t.content, "Screenshot comment"), r = this.requireProjectId(), i = new FormData();
|
|
396
442
|
if (i.append("file", e), i.append("content", n), i.append("position_x", String(t.position.x)), i.append("position_y", String(t.position.y)), i.append("page_url", t.page.url), i.append("page_path", t.page.path), i.append("page_title", t.page.title), t.branch && i.append("branch", t.branch), t.deviceInfo) for (let [e, n] of Object.entries(t.deviceInfo)) n !== void 0 && i.append(`device_info[${e}]`, String(n));
|
|
397
443
|
return (await this.requestFormData(`/projects/${S(r)}/screenshots`, i)).comment;
|
|
398
444
|
}
|
|
399
445
|
async uploadFiles(e, t) {
|
|
400
|
-
if (e.length >
|
|
446
|
+
if (e.length > re) throw new T("too_many_files", `Cannot upload more than ${re} files at once`, 400);
|
|
401
447
|
let n = await Promise.allSettled(e.map((e) => {
|
|
402
448
|
/* v8 ignore next -- pop() always returns a value since file has a name */
|
|
403
|
-
let n = "." + (e.name.split(".").pop()?.toLowerCase() ?? ""), r =
|
|
449
|
+
let n = "." + (e.name.split(".").pop()?.toLowerCase() ?? ""), r = ue.includes(e.type) && le.includes(n);
|
|
404
450
|
return this.uploadFile(e, r ? "screenshot" : "attachment", t);
|
|
405
451
|
})), r = n.filter((e) => e.status === "fulfilled").map((e) => e.value.id), i = n.find((e) => e.status === "rejected");
|
|
406
452
|
if (i) {
|
|
407
453
|
let e = i.reason;
|
|
408
|
-
throw e instanceof
|
|
454
|
+
throw e instanceof T ? new T(e.error, e.message, e.code, {
|
|
409
455
|
...e.details,
|
|
410
456
|
uploadedIds: r
|
|
411
|
-
}) : new
|
|
457
|
+
}) : new T("upload_failed", "Upload failed", 0, { uploadedIds: r });
|
|
412
458
|
}
|
|
413
459
|
return r;
|
|
414
460
|
}
|
|
@@ -421,9 +467,9 @@ var ce = class {
|
|
|
421
467
|
return (await this.request(`/projects/${S(e)}/members`)).members ?? [];
|
|
422
468
|
}
|
|
423
469
|
};
|
|
424
|
-
function
|
|
470
|
+
function w(e) {
|
|
425
471
|
let t = [], n;
|
|
426
|
-
for (
|
|
472
|
+
for (de.lastIndex = 0; (n = de.exec(e)) !== null;) {
|
|
427
473
|
let e = n[1]?.trim(), r = n[2]?.trim();
|
|
428
474
|
e && r && /^[\w-]+$/.test(r) && t.push({
|
|
429
475
|
name: e,
|
|
@@ -433,13 +479,13 @@ function T(e) {
|
|
|
433
479
|
}
|
|
434
480
|
return t;
|
|
435
481
|
}
|
|
436
|
-
function
|
|
482
|
+
function be(e) {
|
|
437
483
|
return `@[${e.name.replace(/\]/g, "")}](${e.id.replace(/\)/g, "")})`;
|
|
438
484
|
}
|
|
439
|
-
function
|
|
440
|
-
return e.replace(
|
|
485
|
+
function xe(e) {
|
|
486
|
+
return e.replace(de, "@$1");
|
|
441
487
|
}
|
|
442
|
-
var
|
|
488
|
+
var T = class extends Error {
|
|
443
489
|
constructor(e, t, n, r) {
|
|
444
490
|
super(t), this.name = "ApiClientError", this.error = e, this.code = n, this.details = r;
|
|
445
491
|
}
|
|
@@ -455,26 +501,19 @@ var E = class extends Error {
|
|
|
455
501
|
isPremiumFeatureError() {
|
|
456
502
|
return this.code === 402;
|
|
457
503
|
}
|
|
458
|
-
};
|
|
459
|
-
function
|
|
460
|
-
return
|
|
461
|
-
}
|
|
462
|
-
function D(e, t) {
|
|
463
|
-
return (e ?? "").replace(/\s+/g, " ").replace(/`/g, "'").trim().slice(0, t);
|
|
464
|
-
}
|
|
465
|
-
var O = null, fe = 0, pe = 3;
|
|
466
|
-
function me() {
|
|
467
|
-
return O || (O = (async () => {
|
|
504
|
+
}, E = null, Se = 0, Ce = 3;
|
|
505
|
+
function we() {
|
|
506
|
+
return E || (E = (async () => {
|
|
468
507
|
try {
|
|
469
508
|
let e = await import("element-source");
|
|
470
509
|
return typeof e?.resolveElementInfo == "function" ? e : null;
|
|
471
510
|
} catch {
|
|
472
|
-
return
|
|
511
|
+
return Se += 1, Se < Ce && (E = null), null;
|
|
473
512
|
}
|
|
474
|
-
})(),
|
|
513
|
+
})(), E);
|
|
475
514
|
}
|
|
476
|
-
async function
|
|
477
|
-
let t = await
|
|
515
|
+
async function Te(e) {
|
|
516
|
+
let t = await we();
|
|
478
517
|
if (!t) return null;
|
|
479
518
|
try {
|
|
480
519
|
return await t.resolveElementInfo(e);
|
|
@@ -482,27 +521,27 @@ async function he(e) {
|
|
|
482
521
|
return null;
|
|
483
522
|
}
|
|
484
523
|
}
|
|
485
|
-
var
|
|
486
|
-
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) {
|
|
487
526
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
488
527
|
}
|
|
489
|
-
function
|
|
490
|
-
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));
|
|
491
530
|
}
|
|
492
|
-
function
|
|
531
|
+
function Pe(e) {
|
|
493
532
|
return {
|
|
494
533
|
id: e.id,
|
|
495
534
|
name: e.name,
|
|
496
535
|
email: e.email
|
|
497
536
|
};
|
|
498
537
|
}
|
|
499
|
-
function
|
|
538
|
+
function Fe(e, t) {
|
|
500
539
|
return e.page.path === t.path || e.page.url === t.url;
|
|
501
540
|
}
|
|
502
|
-
function
|
|
503
|
-
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));
|
|
504
543
|
}
|
|
505
|
-
function
|
|
544
|
+
function Le(e) {
|
|
506
545
|
let t = e.getBoundingClientRect();
|
|
507
546
|
return {
|
|
508
547
|
top: t.top,
|
|
@@ -511,59 +550,93 @@ function De(e) {
|
|
|
511
550
|
height: t.height
|
|
512
551
|
};
|
|
513
552
|
}
|
|
514
|
-
function
|
|
515
|
-
let
|
|
553
|
+
function Re(e, t, n) {
|
|
554
|
+
let r = n ? p(e.element ?? "", e.xpath) : null, i = {
|
|
516
555
|
...e.element ? { selector: e.element } : {},
|
|
517
556
|
...e.xpath ? { xpath: e.xpath } : {}
|
|
518
557
|
};
|
|
519
|
-
if (!
|
|
520
|
-
...
|
|
558
|
+
if (!r || g(r)) return {
|
|
559
|
+
...i,
|
|
521
560
|
found: !1
|
|
522
561
|
};
|
|
523
|
-
let
|
|
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");
|
|
524
563
|
return {
|
|
525
|
-
...
|
|
564
|
+
...i,
|
|
526
565
|
found: !0,
|
|
527
|
-
tagName:
|
|
528
|
-
...
|
|
529
|
-
...
|
|
530
|
-
...
|
|
531
|
-
...
|
|
532
|
-
...
|
|
533
|
-
rect:
|
|
534
|
-
...
|
|
566
|
+
tagName: r.tagName.toLowerCase(),
|
|
567
|
+
...r.id ? { id: r.id } : {},
|
|
568
|
+
...c ? { className: c } : {},
|
|
569
|
+
...l ? { role: l } : {},
|
|
570
|
+
...u ? { ariaLabel: u } : {},
|
|
571
|
+
...o ? { text: o } : {},
|
|
572
|
+
rect: Le(r),
|
|
573
|
+
...s ? { htmlPreview: s } : {}
|
|
535
574
|
};
|
|
536
575
|
}
|
|
537
|
-
function
|
|
576
|
+
function ze(e) {
|
|
538
577
|
return {
|
|
539
578
|
id: e.id,
|
|
540
579
|
content: e.content,
|
|
541
|
-
author:
|
|
542
|
-
createdAt: e.createdAt
|
|
580
|
+
author: Pe(e.author),
|
|
581
|
+
createdAt: e.createdAt,
|
|
582
|
+
isEdited: e.isEdited,
|
|
583
|
+
replyTo: e.replyTo,
|
|
584
|
+
mentions: e.mentions,
|
|
585
|
+
reactions: e.reactions,
|
|
586
|
+
attachments: e.attachments?.map(D)
|
|
543
587
|
};
|
|
544
588
|
}
|
|
545
|
-
function
|
|
546
|
-
return e.
|
|
589
|
+
function Be(e) {
|
|
590
|
+
return e && e.length <= 4096 && !/[?#]/.test(e) && /^https?:\/\//i.test(e) && d(e) ? e : void 0;
|
|
547
591
|
}
|
|
548
|
-
function
|
|
549
|
-
let n =
|
|
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
|
+
};
|
|
602
|
+
}
|
|
603
|
+
function Ve(e, t, n) {
|
|
604
|
+
let r = e.attachments.map(D), i = r.find((e) => e.type === "screenshot" && e.url)?.url;
|
|
550
605
|
return {
|
|
551
606
|
id: e.id,
|
|
552
607
|
type: e.type,
|
|
553
608
|
status: e.status,
|
|
554
609
|
priority: e.priority,
|
|
555
610
|
content: e.content,
|
|
556
|
-
author:
|
|
611
|
+
author: Pe(e.author),
|
|
557
612
|
createdAt: e.createdAt,
|
|
558
613
|
updatedAt: e.updatedAt,
|
|
559
|
-
|
|
614
|
+
environment: e.environment,
|
|
615
|
+
branch: e.branch,
|
|
616
|
+
deviceInfo: e.deviceInfo,
|
|
617
|
+
description: e.description,
|
|
618
|
+
assignees: e.assignees?.map(Pe),
|
|
619
|
+
mentions: e.mentions,
|
|
620
|
+
checklist: e.checklist,
|
|
621
|
+
reactions: e.reactions,
|
|
622
|
+
isEdited: e.isEdited,
|
|
623
|
+
resolvedAt: e.resolvedAt,
|
|
624
|
+
completedAt: e.completedAt,
|
|
625
|
+
page: {
|
|
626
|
+
...e.page,
|
|
627
|
+
url: _(e.page.url),
|
|
628
|
+
path: _(e.page.path)
|
|
629
|
+
},
|
|
560
630
|
position: e.position,
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
631
|
+
textSelection: e.textSelection,
|
|
632
|
+
drawingData: e.drawingData,
|
|
633
|
+
attachments: r,
|
|
634
|
+
element: Re(e.position, t.includeHtml === !0, Fe(e, n)),
|
|
635
|
+
...i ? { screenshotUrl: i } : {},
|
|
636
|
+
replies: e.replies.map(ze)
|
|
564
637
|
};
|
|
565
638
|
}
|
|
566
|
-
function
|
|
639
|
+
function He(e) {
|
|
567
640
|
return {
|
|
568
641
|
filePath: e.filePath,
|
|
569
642
|
lineNumber: e.lineNumber,
|
|
@@ -571,30 +644,49 @@ function Me(e) {
|
|
|
571
644
|
componentName: e.componentName
|
|
572
645
|
};
|
|
573
646
|
}
|
|
574
|
-
function
|
|
575
|
-
let n =
|
|
647
|
+
function O(e, t = {}) {
|
|
648
|
+
let n = m(), r = {
|
|
576
649
|
url: n.url,
|
|
577
650
|
path: n.path,
|
|
578
651
|
title: n.title
|
|
579
|
-
}, 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));
|
|
580
653
|
return {
|
|
581
654
|
version: 1,
|
|
582
655
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
583
|
-
instructions:
|
|
584
|
-
page:
|
|
585
|
-
|
|
656
|
+
instructions: v(t.instructions, 2e3) || je,
|
|
657
|
+
page: {
|
|
658
|
+
...r,
|
|
659
|
+
url: _(r.url),
|
|
660
|
+
path: _(r.path)
|
|
661
|
+
},
|
|
662
|
+
comments: s,
|
|
663
|
+
...e.project ? { project: {
|
|
664
|
+
id: e.project.id,
|
|
665
|
+
name: e.project.name,
|
|
666
|
+
slug: e.project.slug
|
|
667
|
+
} } : {},
|
|
668
|
+
scope: {
|
|
669
|
+
activeBranch: e.activeBranch ?? null,
|
|
670
|
+
currentPageOnly: t.currentPageOnly === !0,
|
|
671
|
+
includeResolved: t.includeResolved === !0,
|
|
672
|
+
loadedCommentCount: e.comments.length,
|
|
673
|
+
matchingCommentCount: o.length,
|
|
674
|
+
exportedCommentCount: s.length,
|
|
675
|
+
hasMoreOnServer: e.pagination?.hasMore === !0,
|
|
676
|
+
truncated: o.length > s.length
|
|
677
|
+
},
|
|
586
678
|
sourceResolved: !1
|
|
587
679
|
};
|
|
588
680
|
}
|
|
589
|
-
async function
|
|
681
|
+
async function Ue(e) {
|
|
590
682
|
let t = !1, n = await Promise.all(e.comments.map(async (e) => {
|
|
591
683
|
if (!e.element.found) return e;
|
|
592
|
-
let n =
|
|
593
|
-
if (!n) return e;
|
|
594
|
-
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);
|
|
595
687
|
if (!r || !r.source) return e;
|
|
596
688
|
t = !0;
|
|
597
|
-
let i =
|
|
689
|
+
let i = He(r.source), a = r.stack.map(He), o = r.componentName ?? void 0;
|
|
598
690
|
return {
|
|
599
691
|
...e,
|
|
600
692
|
element: {
|
|
@@ -611,47 +703,121 @@ async function Ne(e) {
|
|
|
611
703
|
sourceResolved: t
|
|
612
704
|
};
|
|
613
705
|
}
|
|
614
|
-
function
|
|
615
|
-
let t =
|
|
616
|
-
return e.componentName ? `${e.componentName} (${t})` : t;
|
|
617
|
-
}
|
|
618
|
-
function A(e) {
|
|
706
|
+
function k(e) {
|
|
707
|
+
let t = We(e);
|
|
619
708
|
return [
|
|
620
709
|
"# CommentKit Agent Context",
|
|
621
710
|
"",
|
|
622
|
-
e.instructions,
|
|
711
|
+
v(e.instructions, 2e3),
|
|
712
|
+
"",
|
|
713
|
+
ee,
|
|
623
714
|
"",
|
|
624
|
-
`
|
|
625
|
-
|
|
715
|
+
`Comments: ${e.comments.length}`,
|
|
716
|
+
...e.scope?.truncated || e.scope?.hasMoreOnServer ? ["Incomplete snapshot: additional comments may be unloaded."] : [],
|
|
626
717
|
"",
|
|
627
|
-
...e.comments.map((e, t) => {
|
|
628
|
-
let n = e.element.found ? `${e.element.tagName}${e.element.id ? `#${e.element.id}` : ""}` : "not found", r = [
|
|
629
|
-
`## ${t + 1}. ${D(e.content, 300)}`,
|
|
630
|
-
`- Status: ${e.status}`,
|
|
631
|
-
`- Priority: ${e.priority}`,
|
|
632
|
-
`- Author: ${e.author.name} <${e.author.email}>`,
|
|
633
|
-
`- Page: ${e.page.url}`,
|
|
634
|
-
`- Element: ${n}`
|
|
635
|
-
];
|
|
636
|
-
return e.element.source && r.push(`- Source: ${Pe(e.element.source)}`), e.element.stack && e.element.stack.length > 0 && r.push("- Stack:", ...e.element.stack.map((e) => ` - ${Pe(e)}`)), e.element.source || r.push(`- Selector: ${e.element.selector ?? "none"}`, `- XPath: ${e.element.xpath ?? "none"}`), e.screenshotUrl && r.push(`- Screenshot: ${e.screenshotUrl}`), r.push(e.replies.length > 0 ? `- Replies: ${e.replies.length}` : "- Replies: 0", ""), r.join("\n");
|
|
637
|
-
}),
|
|
638
718
|
"```json",
|
|
639
|
-
JSON.stringify(
|
|
719
|
+
JSON.stringify(t, null, 2).replace(/[<>&`]/g, (e) => `\\u${e.charCodeAt(0).toString(16).padStart(4, "0")}`),
|
|
640
720
|
"```"
|
|
641
721
|
].join("\n");
|
|
642
722
|
}
|
|
643
|
-
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) {
|
|
644
810
|
return {
|
|
645
811
|
version: e?.version ?? 1,
|
|
646
812
|
generatedAt: e?.generatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
647
813
|
commentCount: e?.comments.length ?? 0,
|
|
648
|
-
context: e
|
|
814
|
+
context: e ? We(e) : null
|
|
649
815
|
};
|
|
650
816
|
}
|
|
651
|
-
function
|
|
817
|
+
function qe(e, t) {
|
|
652
818
|
if (typeof document > "u" || !document.body || typeof document.execCommand != "function") return !1;
|
|
653
819
|
let n = JSON.stringify(t), r = (t) => {
|
|
654
|
-
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);
|
|
655
821
|
}, i = document.createElement("textarea");
|
|
656
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();
|
|
657
823
|
try {
|
|
@@ -660,10 +826,10 @@ function Ie(e, t) {
|
|
|
660
826
|
document.removeEventListener("copy", r), i.remove();
|
|
661
827
|
}
|
|
662
828
|
}
|
|
663
|
-
async function
|
|
829
|
+
async function Je(e, t) {
|
|
664
830
|
if (typeof navigator > "u" || typeof navigator.clipboard?.write != "function" || typeof ClipboardItem > "u") return !1;
|
|
665
831
|
try {
|
|
666
|
-
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";
|
|
667
833
|
return await navigator.clipboard.write([new ClipboardItem({
|
|
668
834
|
"text/plain": r,
|
|
669
835
|
"text/html": n,
|
|
@@ -673,30 +839,43 @@ async function Le(e, t) {
|
|
|
673
839
|
return !1;
|
|
674
840
|
}
|
|
675
841
|
}
|
|
676
|
-
async function
|
|
677
|
-
return t && await
|
|
842
|
+
async function Ye(e, t) {
|
|
843
|
+
return t && await Je(e, t) ? !0 : (await Xe(e), !1);
|
|
678
844
|
}
|
|
679
|
-
async function
|
|
680
|
-
if (!
|
|
845
|
+
async function Xe(e, t = null) {
|
|
846
|
+
if (!qe(e, Ke(t))) {
|
|
681
847
|
if (typeof navigator < "u" && typeof navigator.clipboard?.writeText == "function") await navigator.clipboard.writeText(e);
|
|
682
848
|
else throw Error("Clipboard is unavailable");
|
|
683
849
|
}
|
|
684
850
|
}
|
|
685
|
-
|
|
686
|
-
|
|
851
|
+
function Ze(e, t, n = null) {
|
|
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;
|
|
853
|
+
return {
|
|
854
|
+
canWrite: o,
|
|
855
|
+
canManageComments: o && (r?.permissions.canManageComments ?? !1),
|
|
856
|
+
planRequired: a,
|
|
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."
|
|
858
|
+
};
|
|
859
|
+
}
|
|
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) {
|
|
687
866
|
return typeof e == "function";
|
|
688
867
|
}
|
|
689
|
-
var
|
|
868
|
+
var tt = class {
|
|
690
869
|
constructor() {
|
|
691
870
|
this.listeners = /* @__PURE__ */ new Map(), this.onceWrappers = /* @__PURE__ */ new Map();
|
|
692
871
|
}
|
|
693
872
|
on(e, t) {
|
|
694
|
-
if (!
|
|
873
|
+
if (!et(t)) return console.warn(`[CommentKit] Ignoring non-function listener for '${String(e)}'`), $e;
|
|
695
874
|
let n = this.listeners.get(e);
|
|
696
|
-
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);
|
|
697
876
|
}
|
|
698
877
|
off(e, t) {
|
|
699
|
-
if (!
|
|
878
|
+
if (!et(t)) return;
|
|
700
879
|
let n = this.listeners.get(e);
|
|
701
880
|
if (n) {
|
|
702
881
|
n.delete(t);
|
|
@@ -713,7 +892,7 @@ var Ue = class {
|
|
|
713
892
|
}
|
|
714
893
|
}
|
|
715
894
|
once(e, t) {
|
|
716
|
-
if (!
|
|
895
|
+
if (!et(t)) return console.warn(`[CommentKit] Ignoring non-function listener for '${String(e)}'`), $e;
|
|
717
896
|
let n = (n) => {
|
|
718
897
|
this.off(e, t), t(n);
|
|
719
898
|
}, r = this.onceWrappers.get(e);
|
|
@@ -725,7 +904,7 @@ var Ue = class {
|
|
|
725
904
|
listenerCount(e) {
|
|
726
905
|
return this.listeners.get(e)?.size ?? 0;
|
|
727
906
|
}
|
|
728
|
-
}, j = Object.freeze({
|
|
907
|
+
}, nt = Symbol(), j = Object.freeze({
|
|
729
908
|
ID: 256,
|
|
730
909
|
CONTENT: 1e4,
|
|
731
910
|
REPLY_CONTENT: 5e3,
|
|
@@ -750,8 +929,8 @@ var Ue = class {
|
|
|
750
929
|
REACTION_COUNT: 1e6,
|
|
751
930
|
PENDING_MUTATIONS: 1e3,
|
|
752
931
|
RETRY_DELAY: 3e4
|
|
753
|
-
}),
|
|
754
|
-
function
|
|
932
|
+
}), rt = "commentkit:session:", it = 4096;
|
|
933
|
+
function at() {
|
|
755
934
|
try {
|
|
756
935
|
return typeof sessionStorage > "u" ? null : sessionStorage;
|
|
757
936
|
} catch {
|
|
@@ -759,30 +938,30 @@ function Ke() {
|
|
|
759
938
|
}
|
|
760
939
|
}
|
|
761
940
|
function M(e) {
|
|
762
|
-
return `${
|
|
941
|
+
return `${rt}${e}`;
|
|
763
942
|
}
|
|
764
|
-
function
|
|
765
|
-
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);
|
|
766
945
|
}
|
|
767
|
-
function
|
|
768
|
-
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);
|
|
769
948
|
}
|
|
770
|
-
function
|
|
949
|
+
function ct(e, t) {
|
|
771
950
|
if (!e) return;
|
|
772
|
-
let n =
|
|
951
|
+
let n = at();
|
|
773
952
|
if (n) try {
|
|
774
953
|
n.setItem(M(e), JSON.stringify(t));
|
|
775
954
|
} catch {}
|
|
776
955
|
}
|
|
777
|
-
function
|
|
956
|
+
function lt(e) {
|
|
778
957
|
if (!e) return null;
|
|
779
|
-
let t =
|
|
958
|
+
let t = at();
|
|
780
959
|
if (!t) return null;
|
|
781
960
|
try {
|
|
782
961
|
let n = t.getItem(M(e));
|
|
783
962
|
if (!n) return null;
|
|
784
963
|
let r = JSON.parse(n);
|
|
785
|
-
return
|
|
964
|
+
return st(r) ? {
|
|
786
965
|
token: r.token.trim(),
|
|
787
966
|
email: r.email.trim(),
|
|
788
967
|
user: {
|
|
@@ -796,14 +975,14 @@ function Xe(e) {
|
|
|
796
975
|
return null;
|
|
797
976
|
}
|
|
798
977
|
}
|
|
799
|
-
function
|
|
978
|
+
function ut(e) {
|
|
800
979
|
if (!e) return;
|
|
801
|
-
let t =
|
|
980
|
+
let t = at();
|
|
802
981
|
if (t) try {
|
|
803
982
|
t.removeItem(M(e));
|
|
804
983
|
} catch {}
|
|
805
984
|
}
|
|
806
|
-
function
|
|
985
|
+
function dt(e, t) {
|
|
807
986
|
for (let n of e.getState().pendingMutations) e.emit("offline:failed", {
|
|
808
987
|
id: n.id,
|
|
809
988
|
error: {
|
|
@@ -813,20 +992,20 @@ function Qe(e, t) {
|
|
|
813
992
|
}
|
|
814
993
|
});
|
|
815
994
|
}
|
|
816
|
-
var
|
|
817
|
-
function
|
|
995
|
+
var ft = j.EMAIL, pt = j.NAME, mt = j.ID, ht = 4096, gt = 6;
|
|
996
|
+
function _t(e) {
|
|
818
997
|
if (typeof e != "string") return null;
|
|
819
998
|
let t = e.trim();
|
|
820
|
-
return
|
|
999
|
+
return s(t, ft) ? t : null;
|
|
821
1000
|
}
|
|
822
|
-
function
|
|
823
|
-
return !
|
|
1001
|
+
function vt(e) {
|
|
1002
|
+
return !a(e) && e.trim().length === gt;
|
|
824
1003
|
}
|
|
825
|
-
function
|
|
826
|
-
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;
|
|
827
1006
|
}
|
|
828
|
-
function
|
|
829
|
-
return
|
|
1007
|
+
function bt(e) {
|
|
1008
|
+
return o(e) && r(e.id, mt);
|
|
830
1009
|
}
|
|
831
1010
|
function N(e, t, n) {
|
|
832
1011
|
return {
|
|
@@ -835,8 +1014,8 @@ function N(e, t, n) {
|
|
|
835
1014
|
code: n
|
|
836
1015
|
};
|
|
837
1016
|
}
|
|
838
|
-
async function
|
|
839
|
-
let r =
|
|
1017
|
+
async function xt(e, t, n = () => !0) {
|
|
1018
|
+
let r = _t(t);
|
|
840
1019
|
if (!r) e.setState({
|
|
841
1020
|
isLoading: !1,
|
|
842
1021
|
otpStep: "idle",
|
|
@@ -871,32 +1050,32 @@ async function ct(e, t, n = () => !0) {
|
|
|
871
1050
|
}), e.handleError(t);
|
|
872
1051
|
}
|
|
873
1052
|
}
|
|
874
|
-
async function
|
|
875
|
-
let { onAuthenticated: i, onWrongOtp: a, onSuccess: o, isCurrent: s = () => !0 } = typeof
|
|
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;
|
|
876
1055
|
if (!c) e.handleError(N("no_email", "No OTP request in progress", 400));
|
|
877
|
-
else if (!
|
|
1056
|
+
else if (!vt(t)) e.setState({ isLoading: !1 }), e.handleError(N("invalid_otp", "Invalid or expired OTP code", 401));
|
|
878
1057
|
else try {
|
|
879
1058
|
e.setState({
|
|
880
1059
|
isLoading: !0,
|
|
881
1060
|
error: null
|
|
882
1061
|
});
|
|
883
|
-
let
|
|
1062
|
+
let n = await e.apiClient.verifyOtp(c, t);
|
|
884
1063
|
if (!s()) return;
|
|
885
|
-
if (
|
|
886
|
-
if (e.apiClient.setAuthToken(
|
|
887
|
-
token:
|
|
888
|
-
email:
|
|
889
|
-
user:
|
|
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, {
|
|
1066
|
+
token: n.token,
|
|
1067
|
+
email: n.user.email,
|
|
1068
|
+
user: n.user
|
|
890
1069
|
}), e.setState({
|
|
891
|
-
currentUser:
|
|
892
|
-
project:
|
|
1070
|
+
currentUser: n.user,
|
|
1071
|
+
project: n.project,
|
|
893
1072
|
isAuthenticated: !0,
|
|
894
1073
|
isLoginModalVisible: !1,
|
|
895
1074
|
isOverlayVisible: !0,
|
|
896
1075
|
isLoading: !1,
|
|
897
1076
|
otpStep: "idle",
|
|
898
1077
|
otpEmail: null
|
|
899
|
-
}), o?.(), e.emit("auth:otp-verified",
|
|
1078
|
+
}), o?.(), e.emit("auth:otp-verified", n.user), !s() || (e.emit("auth:login", n.user), !s())) return;
|
|
900
1079
|
await i();
|
|
901
1080
|
} else e.setState({ isLoading: !1 }), a?.(), e.handleError(N("invalid_otp", "Invalid or expired OTP code", 401));
|
|
902
1081
|
} catch (t) {
|
|
@@ -904,7 +1083,7 @@ async function lt(e, t, r) {
|
|
|
904
1083
|
e.setState({ isLoading: !1 }), e.handleError(t);
|
|
905
1084
|
}
|
|
906
1085
|
}
|
|
907
|
-
function
|
|
1086
|
+
function Ct(e) {
|
|
908
1087
|
e.setState({
|
|
909
1088
|
otpStep: "idle",
|
|
910
1089
|
otpEmail: null,
|
|
@@ -912,12 +1091,12 @@ function ut(e) {
|
|
|
912
1091
|
isLoading: !1
|
|
913
1092
|
});
|
|
914
1093
|
}
|
|
915
|
-
async function
|
|
1094
|
+
async function wt(e, t = () => !0) {
|
|
916
1095
|
let n = e.getState().otpEmail;
|
|
917
|
-
n && await
|
|
1096
|
+
n && await xt(e, n, t);
|
|
918
1097
|
}
|
|
919
|
-
function
|
|
920
|
-
|
|
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({
|
|
921
1100
|
isAuthenticated: !1,
|
|
922
1101
|
currentUser: null,
|
|
923
1102
|
comments: [],
|
|
@@ -945,8 +1124,8 @@ function ft(e, t) {
|
|
|
945
1124
|
isLoading: !1
|
|
946
1125
|
}), e.emit("auth:logout", void 0);
|
|
947
1126
|
}
|
|
948
|
-
function
|
|
949
|
-
|
|
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({
|
|
950
1129
|
isAuthenticated: !1,
|
|
951
1130
|
currentUser: null,
|
|
952
1131
|
comments: [],
|
|
@@ -969,16 +1148,16 @@ function pt(e) {
|
|
|
969
1148
|
code: 401
|
|
970
1149
|
});
|
|
971
1150
|
}
|
|
972
|
-
function
|
|
1151
|
+
function Dt(e) {
|
|
973
1152
|
e.setState({ isLoginModalVisible: !e.getState().isLoginModalVisible });
|
|
974
1153
|
}
|
|
975
|
-
async function
|
|
1154
|
+
async function Ot(e, t, n, r = () => !0) {
|
|
976
1155
|
let i = e.config.inviteToken;
|
|
977
1156
|
if (!i) {
|
|
978
1157
|
e.handleError(N("no_invite", "No invite token found", 400));
|
|
979
1158
|
return;
|
|
980
1159
|
}
|
|
981
|
-
let a =
|
|
1160
|
+
let a = _t(t);
|
|
982
1161
|
if (!a) e.setState({ isLoading: !1 }), e.handleError(N("invalid_email", "A valid email address is required", 400));
|
|
983
1162
|
else try {
|
|
984
1163
|
e.setState({
|
|
@@ -993,52 +1172,139 @@ async function ht(e, t, n, r = () => !0) {
|
|
|
993
1172
|
e.setState({ isLoading: !1 }), e.handleError(t);
|
|
994
1173
|
}
|
|
995
1174
|
}
|
|
996
|
-
|
|
1175
|
+
function P(e) {
|
|
1176
|
+
return Object.freeze(e);
|
|
1177
|
+
}
|
|
1178
|
+
var kt = Object.freeze({
|
|
1179
|
+
auth: P([
|
|
1180
|
+
"isAuthenticated",
|
|
1181
|
+
"currentUser",
|
|
1182
|
+
"project",
|
|
1183
|
+
"projectContext",
|
|
1184
|
+
"isLoginModalVisible",
|
|
1185
|
+
"otpStep",
|
|
1186
|
+
"otpEmail"
|
|
1187
|
+
]),
|
|
1188
|
+
ui: P([
|
|
1189
|
+
"isOverlayVisible",
|
|
1190
|
+
"isSidebarVisible",
|
|
1191
|
+
"isShortcutsOverlayVisible",
|
|
1192
|
+
"activeTool",
|
|
1193
|
+
"isCommentModeActive",
|
|
1194
|
+
"isDrawingModeActive",
|
|
1195
|
+
"isHighlightModeActive",
|
|
1196
|
+
"isScreenshotModeActive",
|
|
1197
|
+
"selectedComment",
|
|
1198
|
+
"activeComment",
|
|
1199
|
+
"activeDrawing",
|
|
1200
|
+
"activeScreenshot",
|
|
1201
|
+
"panelView",
|
|
1202
|
+
"activities",
|
|
1203
|
+
"isLoading",
|
|
1204
|
+
"error"
|
|
1205
|
+
]),
|
|
1206
|
+
comments: P([
|
|
1207
|
+
"comments",
|
|
1208
|
+
"pagination",
|
|
1209
|
+
"seenThreadIds",
|
|
1210
|
+
"activeBranch"
|
|
1211
|
+
]),
|
|
1212
|
+
realtime: P([
|
|
1213
|
+
"onlineUsers",
|
|
1214
|
+
"connectionStatus",
|
|
1215
|
+
"pendingMutations",
|
|
1216
|
+
"isOnline"
|
|
1217
|
+
])
|
|
1218
|
+
});
|
|
1219
|
+
function At() {
|
|
1220
|
+
return typeof navigator < "u" && typeof navigator.onLine == "boolean" ? navigator.onLine : !0;
|
|
1221
|
+
}
|
|
1222
|
+
var jt = 2e3;
|
|
1223
|
+
function Mt() {
|
|
1224
|
+
return {
|
|
1225
|
+
isAuthenticated: !1,
|
|
1226
|
+
isOverlayVisible: !0,
|
|
1227
|
+
isCommentModeActive: !1,
|
|
1228
|
+
isDrawingModeActive: !1,
|
|
1229
|
+
isHighlightModeActive: !1,
|
|
1230
|
+
isScreenshotModeActive: !1,
|
|
1231
|
+
isSidebarVisible: !1,
|
|
1232
|
+
isLoginModalVisible: !1,
|
|
1233
|
+
isShortcutsOverlayVisible: !1,
|
|
1234
|
+
currentUser: null,
|
|
1235
|
+
project: null,
|
|
1236
|
+
projectContext: null,
|
|
1237
|
+
activeBranch: null,
|
|
1238
|
+
comments: [],
|
|
1239
|
+
activeTool: null,
|
|
1240
|
+
selectedComment: null,
|
|
1241
|
+
activeComment: null,
|
|
1242
|
+
activeDrawing: null,
|
|
1243
|
+
activeScreenshot: null,
|
|
1244
|
+
onlineUsers: [],
|
|
1245
|
+
connectionStatus: "disconnected",
|
|
1246
|
+
activities: [],
|
|
1247
|
+
seenThreadIds: /* @__PURE__ */ new Set(),
|
|
1248
|
+
panelView: "list",
|
|
1249
|
+
isLoading: !1,
|
|
1250
|
+
error: null,
|
|
1251
|
+
otpStep: "idle",
|
|
1252
|
+
otpEmail: null,
|
|
1253
|
+
pagination: null,
|
|
1254
|
+
pendingMutations: [],
|
|
1255
|
+
isOnline: At()
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
function F(e) {
|
|
1259
|
+
let t = e.config.branch ?? e.getState().activeBranch;
|
|
1260
|
+
if (!(typeof t != "string" || t.length > 255 || a(t))) return t.trim() || void 0;
|
|
1261
|
+
}
|
|
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([
|
|
997
1263
|
"pin",
|
|
998
1264
|
"highlight",
|
|
999
1265
|
"drawing"
|
|
1000
|
-
]),
|
|
1266
|
+
]), qt = /* @__PURE__ */ new Set([
|
|
1001
1267
|
"low",
|
|
1002
1268
|
"medium",
|
|
1003
1269
|
"high",
|
|
1004
1270
|
"urgent"
|
|
1005
|
-
]),
|
|
1271
|
+
]), Jt = /* @__PURE__ */ new Set([
|
|
1006
1272
|
"open",
|
|
1007
1273
|
"resolved",
|
|
1008
1274
|
"complete"
|
|
1009
|
-
]),
|
|
1275
|
+
]), Yt = /* @__PURE__ */ new Set([
|
|
1010
1276
|
"path",
|
|
1011
1277
|
"line",
|
|
1012
1278
|
"rectangle",
|
|
1013
1279
|
"circle",
|
|
1014
1280
|
"text"
|
|
1015
1281
|
]);
|
|
1016
|
-
function
|
|
1017
|
-
e.handleError(new
|
|
1282
|
+
function L(e, t, n) {
|
|
1283
|
+
e.handleError(new T(t, n, 400));
|
|
1018
1284
|
}
|
|
1019
|
-
function
|
|
1020
|
-
return
|
|
1285
|
+
function R(e) {
|
|
1286
|
+
return r(e, I);
|
|
1021
1287
|
}
|
|
1022
|
-
function
|
|
1288
|
+
function z(e, t = Nt) {
|
|
1023
1289
|
if (typeof e != "string") return null;
|
|
1024
1290
|
let n = e.trim();
|
|
1025
|
-
return !n || n.length > t ||
|
|
1291
|
+
return !n || n.length > t || c(n) ? null : n;
|
|
1026
1292
|
}
|
|
1027
|
-
function
|
|
1293
|
+
function B(e, t) {
|
|
1028
1294
|
if (e === void 0) return;
|
|
1029
1295
|
if (typeof e != "string") return null;
|
|
1030
1296
|
let n = e.trim();
|
|
1031
|
-
return n.length > t ||
|
|
1297
|
+
return n.length > t || c(n) ? null : n;
|
|
1032
1298
|
}
|
|
1033
|
-
function
|
|
1299
|
+
function V(e) {
|
|
1034
1300
|
if (e === void 0) return;
|
|
1035
1301
|
if (typeof e != "string") return null;
|
|
1036
1302
|
let t = e.trim();
|
|
1037
|
-
return !t || t.length >
|
|
1303
|
+
return !t || t.length > Ft || c(t) ? null : t;
|
|
1038
1304
|
}
|
|
1039
|
-
function
|
|
1040
|
-
if (!
|
|
1041
|
-
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);
|
|
1042
1308
|
return n === null || r === null ? null : {
|
|
1043
1309
|
x: t.x,
|
|
1044
1310
|
y: t.y,
|
|
@@ -1046,10 +1312,10 @@ function Nt(t) {
|
|
|
1046
1312
|
...r === void 0 ? {} : { xpath: r }
|
|
1047
1313
|
};
|
|
1048
1314
|
}
|
|
1049
|
-
function
|
|
1050
|
-
if (!
|
|
1051
|
-
let t =
|
|
1052
|
-
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 : {
|
|
1053
1319
|
id: e.id.trim(),
|
|
1054
1320
|
name: e.name.trim(),
|
|
1055
1321
|
email: e.email.trim(),
|
|
@@ -1057,25 +1323,25 @@ function Pt(e) {
|
|
|
1057
1323
|
...n === void 0 ? {} : { organizationId: n }
|
|
1058
1324
|
};
|
|
1059
1325
|
}
|
|
1060
|
-
function
|
|
1326
|
+
function Qt(e) {
|
|
1061
1327
|
if (e === void 0) return;
|
|
1062
|
-
if (!Array.isArray(e) || e.length >
|
|
1328
|
+
if (!Array.isArray(e) || e.length > Rt) return null;
|
|
1063
1329
|
let t = [];
|
|
1064
1330
|
for (let n of e) {
|
|
1065
|
-
let e =
|
|
1331
|
+
let e = Zt(n);
|
|
1066
1332
|
if (!e) return null;
|
|
1067
1333
|
t.push(e);
|
|
1068
1334
|
}
|
|
1069
1335
|
return t;
|
|
1070
1336
|
}
|
|
1071
|
-
function
|
|
1337
|
+
function $t(e) {
|
|
1072
1338
|
if (e === void 0) return;
|
|
1073
|
-
if (!Array.isArray(e) || e.length >
|
|
1339
|
+
if (!Array.isArray(e) || e.length > zt) return null;
|
|
1074
1340
|
let t = [];
|
|
1075
1341
|
for (let n of e) {
|
|
1076
|
-
if (!
|
|
1077
|
-
let e =
|
|
1078
|
-
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;
|
|
1079
1345
|
t.push({
|
|
1080
1346
|
id: n.id.trim(),
|
|
1081
1347
|
label: e,
|
|
@@ -1085,11 +1351,11 @@ function It(e) {
|
|
|
1085
1351
|
}
|
|
1086
1352
|
return t;
|
|
1087
1353
|
}
|
|
1088
|
-
function
|
|
1354
|
+
function en(e) {
|
|
1089
1355
|
if (e === void 0) return;
|
|
1090
|
-
if (!
|
|
1091
|
-
let t = e.text.trim(), n =
|
|
1092
|
-
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 : {
|
|
1093
1359
|
text: t,
|
|
1094
1360
|
startOffset: e.startOffset,
|
|
1095
1361
|
endOffset: e.endOffset,
|
|
@@ -1097,20 +1363,20 @@ function Lt(e) {
|
|
|
1097
1363
|
xpath: r
|
|
1098
1364
|
};
|
|
1099
1365
|
}
|
|
1100
|
-
function
|
|
1101
|
-
return typeof e == "string" && e.length > 0 && e.length <= j.COLOR &&
|
|
1366
|
+
function tn(e) {
|
|
1367
|
+
return typeof e == "string" && e.length > 0 && e.length <= j.COLOR && t(e);
|
|
1102
1368
|
}
|
|
1103
|
-
function
|
|
1369
|
+
function H(e) {
|
|
1104
1370
|
return e === void 0 || typeof e == "number" && Number.isFinite(e);
|
|
1105
1371
|
}
|
|
1106
|
-
function
|
|
1372
|
+
function nn(e) {
|
|
1107
1373
|
if (e === void 0) return;
|
|
1108
|
-
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;
|
|
1109
1375
|
let t = [];
|
|
1110
1376
|
for (let n of e.paths) {
|
|
1111
|
-
if (!
|
|
1112
|
-
let e =
|
|
1113
|
-
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;
|
|
1114
1380
|
t.push({
|
|
1115
1381
|
type: n.type,
|
|
1116
1382
|
stroke: n.stroke,
|
|
@@ -1133,81 +1399,81 @@ function zt(e) {
|
|
|
1133
1399
|
}
|
|
1134
1400
|
};
|
|
1135
1401
|
}
|
|
1136
|
-
function
|
|
1137
|
-
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);
|
|
1138
1404
|
}
|
|
1139
|
-
function
|
|
1405
|
+
function an(e) {
|
|
1140
1406
|
if (e === void 0) return;
|
|
1141
|
-
if (!
|
|
1142
|
-
let t =
|
|
1407
|
+
if (!o(e)) return null;
|
|
1408
|
+
let t = B(e.description, Lt), n = Qt(e.assignees), r = $t(e.checklist);
|
|
1143
1409
|
if (t === null || n === null || r === null) return null;
|
|
1144
|
-
let
|
|
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;
|
|
1145
1411
|
return {
|
|
1146
|
-
...Array.isArray(e.mentions) ? { mentions: e.mentions.filter((e) =>
|
|
1147
|
-
...typeof e.branch == "string" && e.branch.trim() && e.branch.length <= 255 && !
|
|
1148
|
-
...
|
|
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 } : {},
|
|
1149
1415
|
...t === void 0 ? {} : { description: t },
|
|
1150
1416
|
...n === void 0 ? {} : { assignees: n },
|
|
1151
1417
|
...r === void 0 ? {} : { checklist: r },
|
|
1152
|
-
...
|
|
1153
|
-
...
|
|
1418
|
+
...i && i.length > 0 ? { files: i } : {},
|
|
1419
|
+
...a && a.length > 0 ? { attachmentIds: a } : {}
|
|
1154
1420
|
};
|
|
1155
1421
|
}
|
|
1156
|
-
function
|
|
1157
|
-
if (!
|
|
1422
|
+
function on(e) {
|
|
1423
|
+
if (!o(e)) return null;
|
|
1158
1424
|
let t = {};
|
|
1159
1425
|
if ("content" in e) {
|
|
1160
|
-
let n =
|
|
1426
|
+
let n = z(e.content);
|
|
1161
1427
|
if (!n) return null;
|
|
1162
1428
|
t.content = n;
|
|
1163
1429
|
}
|
|
1164
1430
|
if ("status" in e) {
|
|
1165
|
-
if (!
|
|
1431
|
+
if (!Jt.has(e.status)) return null;
|
|
1166
1432
|
t.status = e.status;
|
|
1167
1433
|
}
|
|
1168
1434
|
if ("priority" in e) {
|
|
1169
|
-
if (!
|
|
1435
|
+
if (!qt.has(e.priority)) return null;
|
|
1170
1436
|
t.priority = e.priority;
|
|
1171
1437
|
}
|
|
1172
1438
|
if ("description" in e) {
|
|
1173
|
-
let n =
|
|
1439
|
+
let n = B(e.description, Lt);
|
|
1174
1440
|
if (n === null) return null;
|
|
1175
1441
|
t.description = n;
|
|
1176
1442
|
}
|
|
1177
|
-
if (Array.isArray(e.mentions) && (t.mentions = e.mentions.filter((e) =>
|
|
1178
|
-
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);
|
|
1179
1445
|
if (n === null) return null;
|
|
1180
1446
|
t.assignees = n;
|
|
1181
1447
|
}
|
|
1182
1448
|
if ("checklist" in e) {
|
|
1183
|
-
let n =
|
|
1449
|
+
let n = $t(e.checklist);
|
|
1184
1450
|
if (n === null) return null;
|
|
1185
1451
|
t.checklist = n;
|
|
1186
1452
|
}
|
|
1187
1453
|
if ("textSelection" in e) {
|
|
1188
|
-
let n =
|
|
1454
|
+
let n = en(e.textSelection);
|
|
1189
1455
|
if (n === null) return null;
|
|
1190
1456
|
t.textSelection = n;
|
|
1191
1457
|
}
|
|
1192
1458
|
if ("drawingData" in e) {
|
|
1193
|
-
let n =
|
|
1459
|
+
let n = nn(e.drawingData);
|
|
1194
1460
|
if (n === null) return null;
|
|
1195
1461
|
t.drawingData = n;
|
|
1196
1462
|
}
|
|
1197
1463
|
if ("attachmentIds" in e) {
|
|
1198
1464
|
let n = e.attachmentIds;
|
|
1199
1465
|
if (!Array.isArray(n)) return null;
|
|
1200
|
-
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);
|
|
1201
1467
|
}
|
|
1202
1468
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
1203
1469
|
}
|
|
1204
|
-
function
|
|
1470
|
+
function U(e) {
|
|
1205
1471
|
return `${e}_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
1206
1472
|
}
|
|
1207
|
-
function
|
|
1473
|
+
function W(e, t) {
|
|
1208
1474
|
return e.getState().comments.some((e) => e.id === t);
|
|
1209
1475
|
}
|
|
1210
|
-
function
|
|
1476
|
+
function G(e, t, n) {
|
|
1211
1477
|
if (e.getState().activeBranch && n.branch !== e.getState().activeBranch) {
|
|
1212
1478
|
e.setState({ comments: e.getState().comments.filter((e) => e.id !== t) });
|
|
1213
1479
|
return;
|
|
@@ -1215,7 +1481,7 @@ function U(e, t, n) {
|
|
|
1215
1481
|
let r = e.getState().comments.filter((e) => e.id !== n.id), i = r.some((e) => e.id === t);
|
|
1216
1482
|
e.setState({ comments: i ? r.map((e) => e.id === t ? n : e) : [...r, n] });
|
|
1217
1483
|
}
|
|
1218
|
-
function
|
|
1484
|
+
function sn(e, t, n, r) {
|
|
1219
1485
|
e.setState({ comments: e.getState().comments.map((e) => {
|
|
1220
1486
|
if (e.id !== t) return e;
|
|
1221
1487
|
let i = e.replies.filter((e) => e.id !== r.id), a = i.some((e) => e.id === n);
|
|
@@ -1228,7 +1494,7 @@ function Ut(e, t, n, r) {
|
|
|
1228
1494
|
};
|
|
1229
1495
|
}) });
|
|
1230
1496
|
}
|
|
1231
|
-
function
|
|
1497
|
+
function K(e, t) {
|
|
1232
1498
|
return !t || t === e.status ? e : {
|
|
1233
1499
|
...e,
|
|
1234
1500
|
status: t,
|
|
@@ -1236,10 +1502,10 @@ function W(e, t) {
|
|
|
1236
1502
|
...t === "complete" ? {} : { resolvedAt: void 0 }
|
|
1237
1503
|
};
|
|
1238
1504
|
}
|
|
1239
|
-
function
|
|
1505
|
+
function cn(e, t, n) {
|
|
1240
1506
|
return e.getState().comments.some((e) => e.id === t && e.replies.some((e) => e.id === n));
|
|
1241
1507
|
}
|
|
1242
|
-
async function
|
|
1508
|
+
async function ln(e) {
|
|
1243
1509
|
let t = e.getState().activeBranch;
|
|
1244
1510
|
e.setState({ isLoading: !0 });
|
|
1245
1511
|
try {
|
|
@@ -1255,7 +1521,7 @@ async function Gt(e) {
|
|
|
1255
1521
|
e.setState({ isLoading: !1 });
|
|
1256
1522
|
}
|
|
1257
1523
|
}
|
|
1258
|
-
async function
|
|
1524
|
+
async function un(e, t) {
|
|
1259
1525
|
let n = e.getState().activeBranch, r = e.getState().pagination;
|
|
1260
1526
|
if (r && r.hasMore && !t.current) {
|
|
1261
1527
|
t.current = !0;
|
|
@@ -1276,32 +1542,32 @@ async function Kt(e, t) {
|
|
|
1276
1542
|
}
|
|
1277
1543
|
}
|
|
1278
1544
|
}
|
|
1279
|
-
async function
|
|
1280
|
-
let
|
|
1281
|
-
if (!
|
|
1282
|
-
let
|
|
1283
|
-
if (!
|
|
1284
|
-
|
|
1545
|
+
async function dn(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
1546
|
+
let u = e.getState().currentUser;
|
|
1547
|
+
if (!u) return;
|
|
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");
|
|
1285
1551
|
return;
|
|
1286
1552
|
}
|
|
1287
|
-
let _ = `create:${r}:${
|
|
1553
|
+
let _ = `create:${r}:${d.slice(0, 50)}:${f.x}:${f.y}`;
|
|
1288
1554
|
if (n.has(_)) return;
|
|
1289
1555
|
n.add(_);
|
|
1290
|
-
let v =
|
|
1291
|
-
id:
|
|
1556
|
+
let v = m(), y = g?.files ?? [], ee = y.map((e, t) => ({
|
|
1557
|
+
id: U(`pending-att-${t}`),
|
|
1292
1558
|
type: e.type.startsWith("image/") ? "screenshot" : "file",
|
|
1293
1559
|
url: "",
|
|
1294
1560
|
filename: e.name,
|
|
1295
1561
|
size: e.size
|
|
1296
|
-
})), b =
|
|
1562
|
+
})), b = U("temp"), te = {
|
|
1297
1563
|
id: b,
|
|
1298
1564
|
type: r,
|
|
1299
|
-
content:
|
|
1300
|
-
position:
|
|
1565
|
+
content: d,
|
|
1566
|
+
position: f,
|
|
1301
1567
|
status: "open",
|
|
1302
1568
|
priority: o,
|
|
1303
|
-
author:
|
|
1304
|
-
userId:
|
|
1569
|
+
author: u,
|
|
1570
|
+
userId: u.id,
|
|
1305
1571
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1306
1572
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1307
1573
|
page: {
|
|
@@ -1316,12 +1582,12 @@ async function qt(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1316
1582
|
assignees: g?.assignees,
|
|
1317
1583
|
checklist: g?.checklist,
|
|
1318
1584
|
replies: [],
|
|
1319
|
-
attachments:
|
|
1320
|
-
textSelection:
|
|
1585
|
+
attachments: ee,
|
|
1586
|
+
textSelection: p,
|
|
1321
1587
|
drawingData: h
|
|
1322
1588
|
};
|
|
1323
1589
|
e.setState({
|
|
1324
|
-
comments: [...e.getState().comments,
|
|
1590
|
+
comments: [...e.getState().comments, te],
|
|
1325
1591
|
activeComment: null,
|
|
1326
1592
|
activeTool: null,
|
|
1327
1593
|
isCommentModeActive: !1,
|
|
@@ -1329,9 +1595,9 @@ async function qt(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1329
1595
|
isHighlightModeActive: !1
|
|
1330
1596
|
});
|
|
1331
1597
|
try {
|
|
1332
|
-
let { files: n, ...i } = g ?? {}, a = await e.apiClient.createComment(r,
|
|
1333
|
-
if (
|
|
1334
|
-
let t = (await Promise.all(
|
|
1598
|
+
let { files: n, ...i } = g ?? {}, a = await e.apiClient.createComment(r, d, f, v, o, p, h, i, b), s = a;
|
|
1599
|
+
if (y.length > 0) try {
|
|
1600
|
+
let t = (await Promise.all(y.map(async (t) => {
|
|
1335
1601
|
let n = "." + (t.name.split(".").pop()?.toLowerCase() ?? ""), r = t.type.startsWith("image/") && [
|
|
1336
1602
|
".jpg",
|
|
1337
1603
|
".jpeg",
|
|
@@ -1358,7 +1624,7 @@ async function qt(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1358
1624
|
attachments: a.attachments ?? []
|
|
1359
1625
|
};
|
|
1360
1626
|
}
|
|
1361
|
-
|
|
1627
|
+
G(e, b, s), e.emit("comment:created", s), t.addActivity({
|
|
1362
1628
|
type: "comment_created",
|
|
1363
1629
|
threadId: s.id,
|
|
1364
1630
|
message: "created a new comment"
|
|
@@ -1366,10 +1632,10 @@ async function qt(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1366
1632
|
} catch (n) {
|
|
1367
1633
|
t.shouldQueueMutation(n) && t.queueMutation("createComment", [
|
|
1368
1634
|
r,
|
|
1635
|
+
d,
|
|
1369
1636
|
f,
|
|
1370
|
-
p,
|
|
1371
1637
|
o,
|
|
1372
|
-
|
|
1638
|
+
p,
|
|
1373
1639
|
h,
|
|
1374
1640
|
g ? {
|
|
1375
1641
|
description: g.description,
|
|
@@ -1390,18 +1656,18 @@ async function qt(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1390
1656
|
n.delete(_);
|
|
1391
1657
|
}
|
|
1392
1658
|
}
|
|
1393
|
-
async function
|
|
1394
|
-
if (!
|
|
1395
|
-
let i =
|
|
1659
|
+
async function fn(e, t, n, r) {
|
|
1660
|
+
if (!R(n)) return;
|
|
1661
|
+
let i = on(r);
|
|
1396
1662
|
if (i === null) {
|
|
1397
|
-
|
|
1663
|
+
L(e, "invalid_comment_update", "Comment update data is invalid");
|
|
1398
1664
|
return;
|
|
1399
1665
|
}
|
|
1400
1666
|
if (i === void 0) return;
|
|
1401
1667
|
let a = e.getState().comments, o = a.find((e) => e.id === n);
|
|
1402
1668
|
if (o) {
|
|
1403
1669
|
e.setState({ comments: a.map((e) => e.id === n ? {
|
|
1404
|
-
...
|
|
1670
|
+
...K(e, i.status),
|
|
1405
1671
|
...i
|
|
1406
1672
|
} : e) });
|
|
1407
1673
|
try {
|
|
@@ -1412,8 +1678,8 @@ async function Jt(e, t, n, r) {
|
|
|
1412
1678
|
}
|
|
1413
1679
|
}
|
|
1414
1680
|
}
|
|
1415
|
-
async function
|
|
1416
|
-
if (!
|
|
1681
|
+
async function pn(e, t, n) {
|
|
1682
|
+
if (!R(n)) return;
|
|
1417
1683
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1418
1684
|
if (!i) return;
|
|
1419
1685
|
let a = e.getState().selectedComment;
|
|
@@ -1433,19 +1699,19 @@ async function Yt(e, t, n) {
|
|
|
1433
1699
|
}
|
|
1434
1700
|
}
|
|
1435
1701
|
}
|
|
1436
|
-
async function
|
|
1702
|
+
async function mn(e, t, n, r, i) {
|
|
1437
1703
|
let a = e.getState().currentUser;
|
|
1438
|
-
if (!a || !
|
|
1439
|
-
let o =
|
|
1704
|
+
if (!a || !R(n) || !W(e, n)) return;
|
|
1705
|
+
let o = z(r, Pt);
|
|
1440
1706
|
if (!o) {
|
|
1441
|
-
|
|
1707
|
+
L(e, "invalid_reply", "Reply content is invalid");
|
|
1442
1708
|
return;
|
|
1443
1709
|
}
|
|
1444
|
-
if (i?.replyTo && (!
|
|
1445
|
-
|
|
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");
|
|
1446
1712
|
return;
|
|
1447
1713
|
}
|
|
1448
|
-
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 = {
|
|
1449
1715
|
...c && i?.replyTo ? { replyTo: {
|
|
1450
1716
|
...i.replyTo,
|
|
1451
1717
|
authorName: c.author.name,
|
|
@@ -1462,7 +1728,7 @@ async function Xt(e, t, n, r, i) {
|
|
|
1462
1728
|
replies: [...e.replies, u]
|
|
1463
1729
|
} : e) });
|
|
1464
1730
|
try {
|
|
1465
|
-
|
|
1731
|
+
sn(e, n, l, await e.apiClient.addReply(n, o, l, ...i ? [i] : []));
|
|
1466
1732
|
let t = e.getState().comments.find((e) => e.id === n);
|
|
1467
1733
|
t && e.emit("comment:updated", t);
|
|
1468
1734
|
} catch (r) {
|
|
@@ -1476,11 +1742,11 @@ async function Xt(e, t, n, r, i) {
|
|
|
1476
1742
|
} : e) }), e.handleError(r));
|
|
1477
1743
|
}
|
|
1478
1744
|
}
|
|
1479
|
-
async function
|
|
1480
|
-
if (!
|
|
1481
|
-
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);
|
|
1482
1748
|
if (!a) {
|
|
1483
|
-
|
|
1749
|
+
L(e, "invalid_reply", "Reply content is invalid");
|
|
1484
1750
|
return;
|
|
1485
1751
|
}
|
|
1486
1752
|
let o = e.getState().comments, s = o.find((e) => e.id === t)?.replies.find((e) => e.id === n);
|
|
@@ -1507,8 +1773,8 @@ async function Zt(e, t, n, r, i) {
|
|
|
1507
1773
|
} : e) }), e.handleError(r);
|
|
1508
1774
|
}
|
|
1509
1775
|
}
|
|
1510
|
-
async function
|
|
1511
|
-
if (!
|
|
1776
|
+
async function gn(e, t, n) {
|
|
1777
|
+
if (!R(t) || !R(n) || !cn(e, t, n)) return;
|
|
1512
1778
|
let r = e.getState().comments, i = r.find((e) => e.id === t)?.replies.find((e) => e.id === n);
|
|
1513
1779
|
e.setState({ comments: r.map((e) => e.id === t ? {
|
|
1514
1780
|
...e,
|
|
@@ -1525,10 +1791,10 @@ async function Qt(e, t, n) {
|
|
|
1525
1791
|
} : e) }), e.handleError(r);
|
|
1526
1792
|
}
|
|
1527
1793
|
}
|
|
1528
|
-
async function
|
|
1529
|
-
if (!
|
|
1794
|
+
async function _n(e, t, n) {
|
|
1795
|
+
if (!R(n) || !W(e, n)) return;
|
|
1530
1796
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1531
|
-
e.setState({ comments: r.map((e) => e.id === n ?
|
|
1797
|
+
e.setState({ comments: r.map((e) => e.id === n ? K(e, "resolved") : e) });
|
|
1532
1798
|
try {
|
|
1533
1799
|
let r = await e.apiClient.resolveComment(n);
|
|
1534
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({
|
|
@@ -1540,10 +1806,10 @@ async function $t(e, t, n) {
|
|
|
1540
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));
|
|
1541
1807
|
}
|
|
1542
1808
|
}
|
|
1543
|
-
async function
|
|
1544
|
-
if (!
|
|
1809
|
+
async function vn(e, t, n) {
|
|
1810
|
+
if (!R(n) || !W(e, n)) return;
|
|
1545
1811
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1546
|
-
e.setState({ comments: r.map((e) => e.id === n ?
|
|
1812
|
+
e.setState({ comments: r.map((e) => e.id === n ? K(e, "open") : e) });
|
|
1547
1813
|
try {
|
|
1548
1814
|
let t = await e.apiClient.unresolveComment(n);
|
|
1549
1815
|
e.setState({ comments: e.getState().comments.map((e) => e.id === n ? t : e) }), e.emit("comment:updated", t);
|
|
@@ -1551,10 +1817,10 @@ async function en(e, t, n) {
|
|
|
1551
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));
|
|
1552
1818
|
}
|
|
1553
1819
|
}
|
|
1554
|
-
async function
|
|
1555
|
-
if (!
|
|
1820
|
+
async function yn(e, t, n) {
|
|
1821
|
+
if (!R(n) || !W(e, n)) return;
|
|
1556
1822
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1557
|
-
e.setState({ comments: r.map((e) => e.id === n ?
|
|
1823
|
+
e.setState({ comments: r.map((e) => e.id === n ? K(e, "complete") : e) });
|
|
1558
1824
|
try {
|
|
1559
1825
|
let r = await e.apiClient.markComplete(n);
|
|
1560
1826
|
e.setState({ comments: e.getState().comments.map((e) => e.id === n ? r : e) }), e.emit("comment:completed", r), t.addActivity({
|
|
@@ -1566,30 +1832,30 @@ async function tn(e, t, n) {
|
|
|
1566
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));
|
|
1567
1833
|
}
|
|
1568
1834
|
}
|
|
1569
|
-
async function
|
|
1570
|
-
if (!
|
|
1571
|
-
let
|
|
1572
|
-
if (!
|
|
1573
|
-
let
|
|
1835
|
+
async function bn(e, t, n, r, i) {
|
|
1836
|
+
if (!R(n) || typeof r != "string") return;
|
|
1837
|
+
let a = r.trim();
|
|
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;
|
|
1574
1842
|
if (!s) return;
|
|
1575
|
-
let
|
|
1576
|
-
if (!c) return;
|
|
1577
|
-
let l = (c.reactions ?? []).filter((e) => typeof e.emoji == "string" && e.emoji.length > 0 && e.emoji.length <= Ot && !a(e.emoji) && typeof e.count == "number" && Number.isInteger(e.count) && e.count >= 0 && e.count <= Dt), u = l.find((e) => e.emoji === o)?.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];
|
|
1578
1844
|
if (u) {
|
|
1579
|
-
let e = d.findIndex((e) => e.emoji ===
|
|
1845
|
+
let e = d.findIndex((e) => e.emoji === a), t = d[e];
|
|
1580
1846
|
t.count <= 1 ? d.splice(e, 1) : d[e] = {
|
|
1581
1847
|
...t,
|
|
1582
1848
|
count: t.count - 1,
|
|
1583
1849
|
reacted: !1
|
|
1584
1850
|
};
|
|
1585
1851
|
} else {
|
|
1586
|
-
let e = d.findIndex((e) => e.emoji ===
|
|
1852
|
+
let e = d.findIndex((e) => e.emoji === a), t = e === -1 ? void 0 : d[e];
|
|
1587
1853
|
t ? d[e] = {
|
|
1588
1854
|
...t,
|
|
1589
|
-
count: Math.min(t.count + 1,
|
|
1855
|
+
count: Math.min(t.count + 1, Wt),
|
|
1590
1856
|
reacted: !0
|
|
1591
1857
|
} : d.push({
|
|
1592
|
-
emoji:
|
|
1858
|
+
emoji: a,
|
|
1593
1859
|
count: 1,
|
|
1594
1860
|
reacted: !0
|
|
1595
1861
|
});
|
|
@@ -1606,17 +1872,17 @@ async function nn(e, t, n, r, i) {
|
|
|
1606
1872
|
reactions: d
|
|
1607
1873
|
} : e) });
|
|
1608
1874
|
try {
|
|
1609
|
-
u ? await e.apiClient.removeReaction(n,
|
|
1875
|
+
u ? await e.apiClient.removeReaction(n, a, ...i ? [i] : []) : await e.apiClient.addReaction(n, a, ...i ? [i] : []);
|
|
1610
1876
|
let t = e.getState().comments.find((e) => e.id === n);
|
|
1611
1877
|
t && e.emit("comment:reaction", {
|
|
1612
1878
|
commentId: n,
|
|
1613
|
-
emoji:
|
|
1879
|
+
emoji: a,
|
|
1614
1880
|
comment: t
|
|
1615
1881
|
});
|
|
1616
1882
|
} catch (r) {
|
|
1617
1883
|
t.shouldQueueMutation(r) && t.queueMutation("reactToComment", [
|
|
1618
1884
|
n,
|
|
1619
|
-
|
|
1885
|
+
a,
|
|
1620
1886
|
u ? "remove" : "add",
|
|
1621
1887
|
...i ? [i] : []
|
|
1622
1888
|
]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n ? i ? {
|
|
@@ -1631,14 +1897,14 @@ async function nn(e, t, n, r, i) {
|
|
|
1631
1897
|
} : e) }), e.handleError(r));
|
|
1632
1898
|
}
|
|
1633
1899
|
}
|
|
1634
|
-
async function
|
|
1635
|
-
if (!
|
|
1636
|
-
let a =
|
|
1900
|
+
async function xn(e, t, n, r, i) {
|
|
1901
|
+
if (!R(n) || !W(e, n)) return;
|
|
1902
|
+
let a = Xt({
|
|
1637
1903
|
x: r,
|
|
1638
1904
|
y: i
|
|
1639
1905
|
});
|
|
1640
1906
|
if (!a) {
|
|
1641
|
-
|
|
1907
|
+
L(e, "invalid_position", "Comment position is invalid");
|
|
1642
1908
|
return;
|
|
1643
1909
|
}
|
|
1644
1910
|
let o = e.getState().comments, s = o.find((e) => e.id === n);
|
|
@@ -1659,24 +1925,24 @@ async function rn(e, t, n, r, i) {
|
|
|
1659
1925
|
} : e) }), e.handleError(r));
|
|
1660
1926
|
}
|
|
1661
1927
|
}
|
|
1662
|
-
function
|
|
1928
|
+
function Sn(e, t) {
|
|
1663
1929
|
e.setState({ selectedComment: t });
|
|
1664
1930
|
}
|
|
1665
|
-
async function
|
|
1931
|
+
async function Cn(e, t, n, r, i) {
|
|
1666
1932
|
let a = e.getState().currentUser;
|
|
1667
1933
|
if (!a) return;
|
|
1668
|
-
let o =
|
|
1934
|
+
let o = z(i), s = en(r);
|
|
1669
1935
|
if (!o || s == null) {
|
|
1670
|
-
|
|
1936
|
+
L(e, "invalid_highlight", "Highlight data is invalid");
|
|
1671
1937
|
return;
|
|
1672
1938
|
}
|
|
1673
1939
|
let c = `highlight:${s.xpath}:${s.startOffset}:${o.slice(0, 50)}`;
|
|
1674
1940
|
if (n.has(c)) return;
|
|
1675
1941
|
n.add(c);
|
|
1676
|
-
let l =
|
|
1677
|
-
id:
|
|
1942
|
+
let l = m(), u = F(e), d = u ? { branch: u } : void 0, f = U("temp"), p = {
|
|
1943
|
+
id: f,
|
|
1678
1944
|
type: "highlight",
|
|
1679
|
-
...
|
|
1945
|
+
...u ? { branch: u } : {},
|
|
1680
1946
|
content: o,
|
|
1681
1947
|
position: {
|
|
1682
1948
|
x: 0,
|
|
@@ -1697,10 +1963,10 @@ async function on(e, t, n, r, i) {
|
|
|
1697
1963
|
attachments: [],
|
|
1698
1964
|
textSelection: s
|
|
1699
1965
|
};
|
|
1700
|
-
e.setState({ comments: [...e.getState().comments,
|
|
1966
|
+
e.setState({ comments: [...e.getState().comments, p] });
|
|
1701
1967
|
try {
|
|
1702
|
-
let t = await e.apiClient.createHighlight(o, s, l, "medium",
|
|
1703
|
-
|
|
1968
|
+
let t = await e.apiClient.createHighlight(o, s, l, "medium", f, ...d ? [d] : []);
|
|
1969
|
+
G(e, f, t), e.emit("comment:created", t);
|
|
1704
1970
|
} catch (n) {
|
|
1705
1971
|
t.shouldQueueMutation(n) && t.queueMutation("createHighlight", [
|
|
1706
1972
|
o,
|
|
@@ -1710,27 +1976,27 @@ async function on(e, t, n, r, i) {
|
|
|
1710
1976
|
path: l.path,
|
|
1711
1977
|
title: l.title
|
|
1712
1978
|
},
|
|
1713
|
-
...
|
|
1714
|
-
],
|
|
1979
|
+
...d ? [d] : []
|
|
1980
|
+
], f) || (e.setState({ comments: e.getState().comments.filter((e) => e.id !== f) }), e.handleError(n));
|
|
1715
1981
|
} finally {
|
|
1716
1982
|
n.delete(c);
|
|
1717
1983
|
}
|
|
1718
1984
|
}
|
|
1719
|
-
async function
|
|
1985
|
+
async function wn(e, t, n, r, i, a) {
|
|
1720
1986
|
let o = e.getState().currentUser;
|
|
1721
1987
|
if (!o) return;
|
|
1722
|
-
let s =
|
|
1988
|
+
let s = z(a), c = Xt(i), l = nn(r);
|
|
1723
1989
|
if (!s || !c || l == null) {
|
|
1724
|
-
|
|
1990
|
+
L(e, "invalid_drawing", "Drawing comment data is invalid");
|
|
1725
1991
|
return;
|
|
1726
1992
|
}
|
|
1727
|
-
let
|
|
1728
|
-
if (n.has(
|
|
1729
|
-
n.add(
|
|
1730
|
-
let
|
|
1993
|
+
let u = `drawing:${c.x}:${c.y}:${s.slice(0, 50)}`;
|
|
1994
|
+
if (n.has(u)) return;
|
|
1995
|
+
n.add(u);
|
|
1996
|
+
let d = m(), f = F(e), p = f ? { branch: f } : void 0, h = U("temp"), g = {
|
|
1731
1997
|
id: h,
|
|
1732
1998
|
type: "drawing",
|
|
1733
|
-
...
|
|
1999
|
+
...f ? { branch: f } : {},
|
|
1734
2000
|
content: s,
|
|
1735
2001
|
position: c,
|
|
1736
2002
|
status: "open",
|
|
@@ -1740,9 +2006,9 @@ async function sn(e, t, n, r, i, a) {
|
|
|
1740
2006
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1741
2007
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1742
2008
|
page: {
|
|
1743
|
-
url:
|
|
1744
|
-
path:
|
|
1745
|
-
title:
|
|
2009
|
+
url: d.url,
|
|
2010
|
+
path: d.path,
|
|
2011
|
+
title: d.title
|
|
1746
2012
|
},
|
|
1747
2013
|
replies: [],
|
|
1748
2014
|
attachments: [],
|
|
@@ -1750,64 +2016,83 @@ async function sn(e, t, n, r, i, a) {
|
|
|
1750
2016
|
};
|
|
1751
2017
|
e.setState({ comments: [...e.getState().comments, g] });
|
|
1752
2018
|
try {
|
|
1753
|
-
let t = await e.apiClient.createDrawing(s, l, c,
|
|
1754
|
-
|
|
2019
|
+
let t = await e.apiClient.createDrawing(s, l, c, d, h, ...p ? [p] : []);
|
|
2020
|
+
G(e, h, t), e.emit("comment:created", t);
|
|
1755
2021
|
} catch (n) {
|
|
1756
2022
|
t.shouldQueueMutation(n) && t.queueMutation("createDrawing", [
|
|
1757
2023
|
s,
|
|
1758
2024
|
l,
|
|
1759
2025
|
c,
|
|
1760
2026
|
{
|
|
1761
|
-
url:
|
|
1762
|
-
path:
|
|
1763
|
-
title:
|
|
2027
|
+
url: d.url,
|
|
2028
|
+
path: d.path,
|
|
2029
|
+
title: d.title
|
|
1764
2030
|
},
|
|
1765
|
-
...
|
|
2031
|
+
...p ? [p] : []
|
|
1766
2032
|
], h) || (e.setState({ comments: e.getState().comments.filter((e) => e.id !== h) }), e.handleError(n));
|
|
1767
2033
|
} finally {
|
|
1768
|
-
n.delete(
|
|
2034
|
+
n.delete(u);
|
|
1769
2035
|
}
|
|
1770
2036
|
}
|
|
1771
|
-
var
|
|
2037
|
+
var Tn = {
|
|
1772
2038
|
c: "comment",
|
|
1773
2039
|
e: "select",
|
|
1774
2040
|
d: "draw",
|
|
1775
2041
|
h: "highlight",
|
|
1776
2042
|
s: "screenshot"
|
|
1777
2043
|
};
|
|
1778
|
-
function
|
|
2044
|
+
function En(e) {
|
|
1779
2045
|
return typeof e.composedPath == "function" ? e.composedPath() : e.target ? [e.target] : [];
|
|
1780
2046
|
}
|
|
1781
|
-
function
|
|
2047
|
+
function Dn(e) {
|
|
1782
2048
|
return typeof Element < "u" && e instanceof Element;
|
|
1783
2049
|
}
|
|
1784
|
-
function
|
|
1785
|
-
if (!
|
|
2050
|
+
function On(e) {
|
|
2051
|
+
if (!Dn(e)) return !1;
|
|
1786
2052
|
let t = e.tagName.toLowerCase();
|
|
1787
2053
|
return t === "input" || t === "textarea" || t === "select" || e.isContentEditable || e.getAttribute("role") === "textbox";
|
|
1788
2054
|
}
|
|
1789
|
-
function
|
|
2055
|
+
function kn(e) {
|
|
1790
2056
|
let t = e.activeElement;
|
|
1791
2057
|
for (; t?.shadowRoot?.activeElement;) t = t.shadowRoot.activeElement;
|
|
1792
2058
|
return t;
|
|
1793
2059
|
}
|
|
1794
|
-
function
|
|
1795
|
-
return
|
|
2060
|
+
function An(e) {
|
|
2061
|
+
return En(e).some(On) ? !0 : typeof document > "u" ? !1 : On(kn(document));
|
|
2062
|
+
}
|
|
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")));
|
|
1796
2065
|
}
|
|
1797
|
-
|
|
1798
|
-
|
|
2066
|
+
var Mn = [
|
|
2067
|
+
"popover",
|
|
2068
|
+
"dialog",
|
|
2069
|
+
"alert-dialog",
|
|
2070
|
+
"sheet",
|
|
2071
|
+
"dropdown-menu",
|
|
2072
|
+
"dropdown-menu-sub",
|
|
2073
|
+
"select",
|
|
2074
|
+
"combobox"
|
|
2075
|
+
].map((e) => `[data-slot="${e}-content"][data-open]`).join(",");
|
|
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);
|
|
2079
|
+
if (typeof document < "u" && (t[0] === document.body || t[0] === document.documentElement)) {
|
|
2080
|
+
let e = document.querySelectorAll("[data-commentkit-host]");
|
|
2081
|
+
return e.length === 1 && !!e[0]?.shadowRoot?.querySelector(Mn);
|
|
2082
|
+
}
|
|
2083
|
+
return !1;
|
|
1799
2084
|
}
|
|
1800
|
-
function
|
|
2085
|
+
function Pn(e) {
|
|
1801
2086
|
return (e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === "K" || e.key === "k" || e.code === "KeyK");
|
|
1802
2087
|
}
|
|
1803
|
-
function
|
|
2088
|
+
function Fn(e) {
|
|
1804
2089
|
let t = e.key.toLowerCase(), n = e.code.startsWith("Key") ? e.code.slice(3).toLowerCase() : "";
|
|
1805
|
-
return
|
|
2090
|
+
return Tn[t] ?? Tn[n] ?? null;
|
|
1806
2091
|
}
|
|
1807
|
-
function
|
|
2092
|
+
function In(e) {
|
|
1808
2093
|
e.preventDefault(), e.stopPropagation();
|
|
1809
2094
|
}
|
|
1810
|
-
function
|
|
2095
|
+
function Ln(e, t) {
|
|
1811
2096
|
if (e.isLoginModalVisible) t.toggleLoginModal();
|
|
1812
2097
|
else if (e.isShortcutsOverlayVisible) t.toggleShortcutsOverlay();
|
|
1813
2098
|
else if (e.activeComment) t.setState({ activeComment: null });
|
|
@@ -1818,111 +2103,28 @@ function _n(e, t) {
|
|
|
1818
2103
|
else return !1;
|
|
1819
2104
|
return !0;
|
|
1820
2105
|
}
|
|
1821
|
-
function
|
|
2106
|
+
function Rn(e, t) {
|
|
1822
2107
|
e.isAuthenticated ? t.toggleOverlay() : t.toggleLoginModal();
|
|
1823
2108
|
}
|
|
1824
|
-
function
|
|
2109
|
+
function zn(e, t, n) {
|
|
1825
2110
|
if (e.defaultPrevented || e.repeat || e.isComposing) return;
|
|
1826
|
-
let r =
|
|
1827
|
-
if (
|
|
2111
|
+
let r = An(e), i = jn(e);
|
|
2112
|
+
if (Pn(e)) {
|
|
1828
2113
|
if (r) return;
|
|
1829
|
-
|
|
2114
|
+
In(e), Rn(t, n);
|
|
1830
2115
|
} else if (e.key === "Escape") {
|
|
1831
|
-
if (r && !i) return;
|
|
1832
|
-
|
|
2116
|
+
if (Nn(e) || r && !i) return;
|
|
2117
|
+
Ln(t, n) && In(e);
|
|
1833
2118
|
} else if (t.isAuthenticated && (t.isOverlayVisible || t.activeTool !== null) && !r && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
1834
2119
|
if (e.key === "?") {
|
|
1835
|
-
|
|
2120
|
+
In(e), n.toggleShortcutsOverlay();
|
|
1836
2121
|
return;
|
|
1837
2122
|
}
|
|
1838
|
-
let r =
|
|
1839
|
-
r && (
|
|
2123
|
+
let r = Fn(e);
|
|
2124
|
+
r && (In(e), n.setTool(t.activeTool === r ? null : r));
|
|
1840
2125
|
}
|
|
1841
2126
|
}
|
|
1842
|
-
|
|
1843
|
-
return Object.freeze(e);
|
|
1844
|
-
}
|
|
1845
|
-
var bn = Object.freeze({
|
|
1846
|
-
auth: K([
|
|
1847
|
-
"isAuthenticated",
|
|
1848
|
-
"currentUser",
|
|
1849
|
-
"project",
|
|
1850
|
-
"projectContext",
|
|
1851
|
-
"isLoginModalVisible",
|
|
1852
|
-
"otpStep",
|
|
1853
|
-
"otpEmail"
|
|
1854
|
-
]),
|
|
1855
|
-
ui: K([
|
|
1856
|
-
"isOverlayVisible",
|
|
1857
|
-
"isSidebarVisible",
|
|
1858
|
-
"isShortcutsOverlayVisible",
|
|
1859
|
-
"activeTool",
|
|
1860
|
-
"isCommentModeActive",
|
|
1861
|
-
"isDrawingModeActive",
|
|
1862
|
-
"isHighlightModeActive",
|
|
1863
|
-
"isScreenshotModeActive",
|
|
1864
|
-
"selectedComment",
|
|
1865
|
-
"activeComment",
|
|
1866
|
-
"activeDrawing",
|
|
1867
|
-
"activeScreenshot",
|
|
1868
|
-
"panelView",
|
|
1869
|
-
"activities",
|
|
1870
|
-
"isLoading",
|
|
1871
|
-
"error"
|
|
1872
|
-
]),
|
|
1873
|
-
comments: K([
|
|
1874
|
-
"comments",
|
|
1875
|
-
"pagination",
|
|
1876
|
-
"seenThreadIds",
|
|
1877
|
-
"activeBranch"
|
|
1878
|
-
]),
|
|
1879
|
-
realtime: K([
|
|
1880
|
-
"onlineUsers",
|
|
1881
|
-
"connectionStatus",
|
|
1882
|
-
"pendingMutations",
|
|
1883
|
-
"isOnline"
|
|
1884
|
-
])
|
|
1885
|
-
});
|
|
1886
|
-
function xn() {
|
|
1887
|
-
return typeof navigator < "u" && typeof navigator.onLine == "boolean" ? navigator.onLine : !0;
|
|
1888
|
-
}
|
|
1889
|
-
var Sn = 2e3;
|
|
1890
|
-
function Cn() {
|
|
1891
|
-
return {
|
|
1892
|
-
isAuthenticated: !1,
|
|
1893
|
-
isOverlayVisible: !0,
|
|
1894
|
-
isCommentModeActive: !1,
|
|
1895
|
-
isDrawingModeActive: !1,
|
|
1896
|
-
isHighlightModeActive: !1,
|
|
1897
|
-
isScreenshotModeActive: !1,
|
|
1898
|
-
isSidebarVisible: !1,
|
|
1899
|
-
isLoginModalVisible: !1,
|
|
1900
|
-
isShortcutsOverlayVisible: !1,
|
|
1901
|
-
currentUser: null,
|
|
1902
|
-
project: null,
|
|
1903
|
-
projectContext: null,
|
|
1904
|
-
activeBranch: null,
|
|
1905
|
-
comments: [],
|
|
1906
|
-
activeTool: null,
|
|
1907
|
-
selectedComment: null,
|
|
1908
|
-
activeComment: null,
|
|
1909
|
-
activeDrawing: null,
|
|
1910
|
-
activeScreenshot: null,
|
|
1911
|
-
onlineUsers: [],
|
|
1912
|
-
connectionStatus: "disconnected",
|
|
1913
|
-
activities: [],
|
|
1914
|
-
seenThreadIds: /* @__PURE__ */ new Set(),
|
|
1915
|
-
panelView: "list",
|
|
1916
|
-
isLoading: !1,
|
|
1917
|
-
error: null,
|
|
1918
|
-
otpStep: "idle",
|
|
1919
|
-
otpEmail: null,
|
|
1920
|
-
pagination: null,
|
|
1921
|
-
pendingMutations: [],
|
|
1922
|
-
isOnline: xn()
|
|
1923
|
-
};
|
|
1924
|
-
}
|
|
1925
|
-
var wn = j.PENDING_MUTATIONS, Tn = j.RETRY_DELAY, q = j.ID, En = j.CONTENT, Dn = j.REPLY_CONTENT, On = j.SELECTOR, kn = j.EMOJI, An = /* @__PURE__ */ new Set([
|
|
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([
|
|
1926
2128
|
"createComment",
|
|
1927
2129
|
"createHighlight",
|
|
1928
2130
|
"createDrawing",
|
|
@@ -1934,42 +2136,42 @@ var wn = j.PENDING_MUTATIONS, Tn = j.RETRY_DELAY, q = j.ID, En = j.CONTENT, Dn =
|
|
|
1934
2136
|
"addReply",
|
|
1935
2137
|
"reactToComment",
|
|
1936
2138
|
"updatePosition"
|
|
1937
|
-
]),
|
|
2139
|
+
]), qn = /* @__PURE__ */ new Set([
|
|
1938
2140
|
"pin",
|
|
1939
2141
|
"highlight",
|
|
1940
2142
|
"drawing"
|
|
1941
|
-
]),
|
|
2143
|
+
]), Jn = /* @__PURE__ */ new Set([
|
|
1942
2144
|
"low",
|
|
1943
2145
|
"medium",
|
|
1944
2146
|
"high",
|
|
1945
2147
|
"urgent"
|
|
1946
|
-
]),
|
|
1947
|
-
function
|
|
1948
|
-
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);
|
|
1949
2151
|
}
|
|
1950
|
-
function
|
|
1951
|
-
return typeof e == "string" && e.length <= j.PAGE && !
|
|
2152
|
+
function Zn(e) {
|
|
2153
|
+
return typeof e == "string" && e.length <= j.PAGE && !a(e);
|
|
1952
2154
|
}
|
|
1953
|
-
function
|
|
1954
|
-
return e === void 0 ||
|
|
2155
|
+
function Qn(e) {
|
|
2156
|
+
return e === void 0 || o(e) && Zn(e.url) && Zn(e.path) && Zn(e.title);
|
|
1955
2157
|
}
|
|
1956
|
-
function
|
|
1957
|
-
return typeof e == "string" &&
|
|
2158
|
+
function $n(e) {
|
|
2159
|
+
return typeof e == "string" && Kn.has(e);
|
|
1958
2160
|
}
|
|
1959
|
-
function
|
|
2161
|
+
function er(e) {
|
|
1960
2162
|
return Number.isInteger(e) && Number(e) >= 0;
|
|
1961
2163
|
}
|
|
1962
|
-
function
|
|
1963
|
-
return
|
|
2164
|
+
function tr(e) {
|
|
2165
|
+
return er(e) ? Math.min(e, 5) : 0;
|
|
1964
2166
|
}
|
|
1965
|
-
function
|
|
2167
|
+
function nr(e) {
|
|
1966
2168
|
return e.isNetworkError() || e.code === 408 || e.isRateLimitError();
|
|
1967
2169
|
}
|
|
1968
|
-
function
|
|
1969
|
-
return e instanceof
|
|
2170
|
+
function rr(e) {
|
|
2171
|
+
return e instanceof T ? nr(e) : !0;
|
|
1970
2172
|
}
|
|
1971
|
-
function
|
|
1972
|
-
return e instanceof
|
|
2173
|
+
function ir(e) {
|
|
2174
|
+
return e instanceof T ? {
|
|
1973
2175
|
error: e.error,
|
|
1974
2176
|
message: e.message,
|
|
1975
2177
|
code: e.code,
|
|
@@ -1980,80 +2182,80 @@ function Hn(e) {
|
|
|
1980
2182
|
code: 0
|
|
1981
2183
|
};
|
|
1982
2184
|
}
|
|
1983
|
-
function
|
|
2185
|
+
function ar(e = Date.now()) {
|
|
1984
2186
|
return `mutation_${e}_${typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : Math.random().toString(36).slice(2, 12)}`;
|
|
1985
2187
|
}
|
|
1986
|
-
function
|
|
1987
|
-
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;
|
|
1988
2190
|
}
|
|
1989
|
-
function
|
|
2191
|
+
function sr(e) {
|
|
1990
2192
|
try {
|
|
1991
2193
|
if (typeof structuredClone == "function") return structuredClone(e);
|
|
1992
2194
|
} catch {}
|
|
1993
|
-
return
|
|
2195
|
+
return or(e);
|
|
1994
2196
|
}
|
|
1995
|
-
function
|
|
2197
|
+
function cr(e, t) {
|
|
1996
2198
|
switch (e) {
|
|
1997
2199
|
case "createComment": {
|
|
1998
2200
|
let [e, n, r, a, s, c, l, u] = t;
|
|
1999
|
-
return t.length >= 3 && t.length <= 8 &&
|
|
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);
|
|
2000
2202
|
}
|
|
2001
2203
|
case "createHighlight": {
|
|
2002
2204
|
let [e, n, r, a] = t;
|
|
2003
|
-
return t.length >= 2 && t.length <= 4 &&
|
|
2205
|
+
return t.length >= 2 && t.length <= 4 && i(e, Hn) && o(n) && (a === void 0 || o(a)) && Qn(r);
|
|
2004
2206
|
}
|
|
2005
2207
|
case "createDrawing": {
|
|
2006
2208
|
let [e, n, r, a, s] = t;
|
|
2007
|
-
return t.length >= 3 && t.length <= 5 &&
|
|
2209
|
+
return t.length >= 3 && t.length <= 5 && i(e, Hn) && o(n) && Xn(r) && (s === void 0 || o(s)) && Qn(a);
|
|
2008
2210
|
}
|
|
2009
|
-
case "updateComment": return t.length === 2 &&
|
|
2211
|
+
case "updateComment": return t.length === 2 && r(t[0], q) && o(t[1]);
|
|
2010
2212
|
case "deleteComment":
|
|
2011
2213
|
case "resolveComment":
|
|
2012
2214
|
case "unresolveComment":
|
|
2013
|
-
case "completeComment": return t.length === 1 &&
|
|
2014
|
-
case "addReply": return (t.length === 2 || t.length === 3) &&
|
|
2015
|
-
case "reactToComment": return t.length >= 2 && t.length <= 4 &&
|
|
2016
|
-
case "updatePosition": return t.length === 2 &&
|
|
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]);
|
|
2017
2219
|
}
|
|
2018
2220
|
}
|
|
2019
|
-
function
|
|
2020
|
-
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";
|
|
2021
2223
|
}
|
|
2022
|
-
function
|
|
2023
|
-
let t =
|
|
2024
|
-
if (t) throw new
|
|
2224
|
+
function ur(e) {
|
|
2225
|
+
let t = lr(e);
|
|
2226
|
+
if (t) throw new T("invalid_mutation", t, 400);
|
|
2025
2227
|
}
|
|
2026
|
-
var
|
|
2027
|
-
function
|
|
2228
|
+
var dr = "commentkit:offline-queue:";
|
|
2229
|
+
function fr() {
|
|
2028
2230
|
try {
|
|
2029
2231
|
return typeof localStorage > "u" ? null : localStorage;
|
|
2030
2232
|
} catch {
|
|
2031
2233
|
return null;
|
|
2032
2234
|
}
|
|
2033
2235
|
}
|
|
2034
|
-
function
|
|
2035
|
-
return `${
|
|
2236
|
+
function pr(e) {
|
|
2237
|
+
return `${dr}${e}`;
|
|
2036
2238
|
}
|
|
2037
|
-
function
|
|
2239
|
+
function mr(e, t) {
|
|
2038
2240
|
if (!e) return;
|
|
2039
|
-
let n =
|
|
2241
|
+
let n = fr();
|
|
2040
2242
|
if (n) try {
|
|
2041
|
-
t.length === 0 ? n.removeItem(
|
|
2243
|
+
t.length === 0 ? n.removeItem(pr(e)) : n.setItem(pr(e), JSON.stringify(t));
|
|
2042
2244
|
} catch {}
|
|
2043
2245
|
}
|
|
2044
|
-
function
|
|
2246
|
+
function hr(e) {
|
|
2045
2247
|
if (!e) return [];
|
|
2046
|
-
let t =
|
|
2248
|
+
let t = fr();
|
|
2047
2249
|
if (!t) return [];
|
|
2048
2250
|
try {
|
|
2049
|
-
let n = t.getItem(
|
|
2251
|
+
let n = t.getItem(pr(e));
|
|
2050
2252
|
if (!n) return [];
|
|
2051
2253
|
let r = JSON.parse(n);
|
|
2052
2254
|
if (!Array.isArray(r)) return [];
|
|
2053
2255
|
let i = [];
|
|
2054
2256
|
for (let e of r) {
|
|
2055
|
-
if (i.length >=
|
|
2056
|
-
|
|
2257
|
+
if (i.length >= Bn) break;
|
|
2258
|
+
lr(e) === null && i.push(e);
|
|
2057
2259
|
}
|
|
2058
2260
|
return i;
|
|
2059
2261
|
} catch {
|
|
@@ -2063,11 +2265,11 @@ function $n(e) {
|
|
|
2063
2265
|
function J(e) {
|
|
2064
2266
|
Promise.resolve().then(e);
|
|
2065
2267
|
}
|
|
2066
|
-
function
|
|
2268
|
+
function gr(e, t) {
|
|
2067
2269
|
return e.type !== t.type || e.ownerId !== t.ownerId ? !1 : (t.type === "updatePosition" || t.type === "updateComment") && e.args[0] === t.args[0];
|
|
2068
2270
|
}
|
|
2069
|
-
function
|
|
2070
|
-
return t.type === "updateComment" &&
|
|
2271
|
+
function _r(e, t) {
|
|
2272
|
+
return t.type === "updateComment" && o(e.args[1]) ? {
|
|
2071
2273
|
...t,
|
|
2072
2274
|
args: [t.args[0], {
|
|
2073
2275
|
...e.args[1],
|
|
@@ -2075,13 +2277,13 @@ function tr(e, t) {
|
|
|
2075
2277
|
}]
|
|
2076
2278
|
} : t;
|
|
2077
2279
|
}
|
|
2078
|
-
function
|
|
2079
|
-
let n = e.findIndex((e) =>
|
|
2280
|
+
function vr(e, t) {
|
|
2281
|
+
let n = e.findIndex((e) => gr(e, t));
|
|
2080
2282
|
if (n !== -1) {
|
|
2081
2283
|
let r = [...e];
|
|
2082
|
-
return r[n] =
|
|
2284
|
+
return r[n] = _r(r[n], t), r;
|
|
2083
2285
|
}
|
|
2084
|
-
return e.length >=
|
|
2286
|
+
return e.length >= Bn ? null : [...e, t];
|
|
2085
2287
|
}
|
|
2086
2288
|
function Y(e, t, n) {
|
|
2087
2289
|
e.emit("offline:failed", {
|
|
@@ -2089,18 +2291,18 @@ function Y(e, t, n) {
|
|
|
2089
2291
|
error: n
|
|
2090
2292
|
});
|
|
2091
2293
|
}
|
|
2092
|
-
function
|
|
2294
|
+
function yr(e, t) {
|
|
2093
2295
|
return t.isAuthenticated && e.ownerId && e.ownerId === t.currentUser?.id ? null : {
|
|
2094
2296
|
error: "offline_identity_mismatch",
|
|
2095
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.",
|
|
2096
2298
|
code: 403
|
|
2097
2299
|
};
|
|
2098
2300
|
}
|
|
2099
|
-
function
|
|
2301
|
+
function br(e) {
|
|
2100
2302
|
let t = e.getState();
|
|
2101
2303
|
if (!t.isAuthenticated) return;
|
|
2102
2304
|
let n = t.pendingMutations.flatMap((e) => {
|
|
2103
|
-
let n =
|
|
2305
|
+
let n = yr(e, t);
|
|
2104
2306
|
return n ? [{
|
|
2105
2307
|
mutation: e,
|
|
2106
2308
|
error: n
|
|
@@ -2111,17 +2313,17 @@ function ir(e) {
|
|
|
2111
2313
|
e.setState({ pendingMutations: t.pendingMutations.filter((e) => !r.has(e.id)) });
|
|
2112
2314
|
for (let { mutation: t, error: r } of n) Y(e, t.id, r);
|
|
2113
2315
|
}
|
|
2114
|
-
function
|
|
2115
|
-
return !e.isOnline || t instanceof
|
|
2316
|
+
function xr(e, t) {
|
|
2317
|
+
return !e.isOnline || t instanceof T && nr(t);
|
|
2116
2318
|
}
|
|
2117
|
-
function
|
|
2118
|
-
let s =
|
|
2119
|
-
if (!c.isAuthenticated || !
|
|
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, {
|
|
2120
2322
|
error: "unauthenticated",
|
|
2121
2323
|
message: "Sign in before saving changes for offline replay.",
|
|
2122
2324
|
code: 401
|
|
2123
2325
|
}), !1;
|
|
2124
|
-
if (
|
|
2326
|
+
if (!$n(i) || !Array.isArray(a) || !cr(i, a) || !n(o, q)) return Y(e, s, {
|
|
2125
2327
|
error: "invalid_mutation",
|
|
2126
2328
|
message: "Queued mutation args are invalid",
|
|
2127
2329
|
code: 400
|
|
@@ -2130,27 +2332,27 @@ function or(e, r, i, a, o) {
|
|
|
2130
2332
|
id: s,
|
|
2131
2333
|
ownerId: l,
|
|
2132
2334
|
type: i,
|
|
2133
|
-
args:
|
|
2335
|
+
args: sr(a),
|
|
2134
2336
|
timestamp: Date.now(),
|
|
2135
2337
|
retries: 0,
|
|
2136
2338
|
...o === void 0 ? {} : { tempId: o }
|
|
2137
|
-
}, d =
|
|
2138
|
-
return d ? (e.setState({ pendingMutations: d }), e.emit("offline:queued", u), e.getState().isOnline && J(
|
|
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, {
|
|
2139
2341
|
error: "queue_full",
|
|
2140
2342
|
message: "Offline mutation queue is full",
|
|
2141
2343
|
code: 0
|
|
2142
2344
|
}), !1);
|
|
2143
2345
|
}
|
|
2144
|
-
function
|
|
2346
|
+
function Cr(e, t, n) {
|
|
2145
2347
|
if (t.current || e.getState().pendingMutations.length === 0) return;
|
|
2146
2348
|
let r = e.getState().pendingMutations[0];
|
|
2147
2349
|
if (!r) return;
|
|
2148
|
-
let i =
|
|
2350
|
+
let i = tr(r.retries), a = Math.min(Vn, jt * 2 ** i);
|
|
2149
2351
|
t.current = setTimeout(() => {
|
|
2150
2352
|
t.current = null, n();
|
|
2151
2353
|
}, a);
|
|
2152
2354
|
}
|
|
2153
|
-
async function
|
|
2355
|
+
async function wr(e, t, n, i) {
|
|
2154
2356
|
let a = e.getState();
|
|
2155
2357
|
if (!a.isOnline || a.pendingMutations.length === 0 || !a.isAuthenticated || t.current) return;
|
|
2156
2358
|
t.current = !0;
|
|
@@ -2159,49 +2361,49 @@ async function cr(e, t, r, i) {
|
|
|
2159
2361
|
t.current = !1;
|
|
2160
2362
|
return;
|
|
2161
2363
|
}
|
|
2162
|
-
let s =
|
|
2364
|
+
let s = lr(o), c = s ? {
|
|
2163
2365
|
error: "invalid_mutation",
|
|
2164
2366
|
message: s,
|
|
2165
2367
|
code: 400
|
|
2166
|
-
} :
|
|
2368
|
+
} : yr(o, e.getState());
|
|
2167
2369
|
if (c) {
|
|
2168
2370
|
let i = e.getState().pendingMutations.filter((e) => e !== o);
|
|
2169
|
-
e.setState({ pendingMutations: i }), Y(e,
|
|
2371
|
+
e.setState({ pendingMutations: i }), Y(e, r(o.id, q) ? o.id : "invalid", c), i.length > 0 && J(n), t.current = !1;
|
|
2170
2372
|
return;
|
|
2171
2373
|
}
|
|
2172
2374
|
e.emit("offline:retrying", {
|
|
2173
2375
|
id: o.id,
|
|
2174
2376
|
attempt: o.retries + 1
|
|
2175
2377
|
});
|
|
2176
|
-
let l = i ?? ((t) =>
|
|
2378
|
+
let l = i ?? ((t) => Or(e, t));
|
|
2177
2379
|
try {
|
|
2178
2380
|
await l(o);
|
|
2179
|
-
let
|
|
2180
|
-
e.setState({ pendingMutations:
|
|
2181
|
-
} catch (
|
|
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));
|
|
2383
|
+
} catch (r) {
|
|
2182
2384
|
let i = {
|
|
2183
2385
|
...o,
|
|
2184
|
-
retries:
|
|
2386
|
+
retries: tr(o.retries) + 1
|
|
2185
2387
|
};
|
|
2186
|
-
if (
|
|
2388
|
+
if (rr(r) && i.retries < 5) {
|
|
2187
2389
|
let t = e.getState().pendingMutations.map((e) => e.id === o.id ? i : e);
|
|
2188
|
-
e.setState({ pendingMutations: t }), J(
|
|
2390
|
+
e.setState({ pendingMutations: t }), J(n);
|
|
2189
2391
|
} else {
|
|
2190
2392
|
let i = e.getState().pendingMutations.filter((e) => e.id !== o.id);
|
|
2191
|
-
e.setState({ pendingMutations: i }), Y(e, 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));
|
|
2192
2394
|
}
|
|
2193
2395
|
} finally {
|
|
2194
2396
|
t.current = !1;
|
|
2195
2397
|
}
|
|
2196
2398
|
}
|
|
2197
|
-
function
|
|
2399
|
+
function Tr(e, t, n) {
|
|
2198
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, {
|
|
2199
2401
|
...e,
|
|
2200
2402
|
args: [n, ...e.args.slice(1)]
|
|
2201
2403
|
}) : e);
|
|
2202
2404
|
r && e.setState({ pendingMutations: i });
|
|
2203
2405
|
}
|
|
2204
|
-
function
|
|
2406
|
+
function Er(e, t, n) {
|
|
2205
2407
|
let r = e.getState(), i = (e) => e === t || e === n;
|
|
2206
2408
|
e.setState({
|
|
2207
2409
|
comments: r.comments.filter((e) => !i(e.id)),
|
|
@@ -2220,7 +2422,7 @@ function X(e, t, n, r, i = !1) {
|
|
|
2220
2422
|
};
|
|
2221
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) {
|
|
2222
2424
|
case "deleteComment":
|
|
2223
|
-
|
|
2425
|
+
Er(e, n.id, r);
|
|
2224
2426
|
return;
|
|
2225
2427
|
case "updateComment":
|
|
2226
2428
|
i.args[1].status && c(i.args[1].status), s = {
|
|
@@ -2256,32 +2458,32 @@ function X(e, t, n, r, i = !1) {
|
|
|
2256
2458
|
reactions: o.reactions
|
|
2257
2459
|
});
|
|
2258
2460
|
}
|
|
2259
|
-
i ?
|
|
2461
|
+
i ? G(e, r, s) : e.setState({ comments: a.comments.map((e) => e.id === r ? s : e) });
|
|
2260
2462
|
}
|
|
2261
|
-
function
|
|
2463
|
+
function Dr(e, t, n, r) {
|
|
2262
2464
|
e.setState({ pendingMutations: e.getState().pendingMutations.map((e) => e.type === "reactToComment" && e.args[0] === t && e.args[3] === n ? {
|
|
2263
2465
|
...e,
|
|
2264
2466
|
args: [...e.args.slice(0, 3), r]
|
|
2265
2467
|
} : e) });
|
|
2266
2468
|
}
|
|
2267
|
-
async function
|
|
2268
|
-
|
|
2269
|
-
let n =
|
|
2270
|
-
if (n) throw new
|
|
2469
|
+
async function Or(e, t) {
|
|
2470
|
+
ur(t);
|
|
2471
|
+
let n = yr(t, e.getState());
|
|
2472
|
+
if (n) throw new T(n.error, n.message, n.code);
|
|
2271
2473
|
switch (t.type) {
|
|
2272
2474
|
case "createComment": {
|
|
2273
|
-
let [n, r, i, a, o, s, c, l] = t.args,
|
|
2274
|
-
|
|
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));
|
|
2275
2477
|
break;
|
|
2276
2478
|
}
|
|
2277
2479
|
case "createHighlight": {
|
|
2278
|
-
let [n, r, i, a] = t.args, o = await e.apiClient.createHighlight(n, r, i ??
|
|
2279
|
-
o && t.tempId && (X(e, t, o, t.tempId, !0),
|
|
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));
|
|
2280
2482
|
break;
|
|
2281
2483
|
}
|
|
2282
2484
|
case "createDrawing": {
|
|
2283
|
-
let [n, r, i, a, o] = t.args, s = await e.apiClient.createDrawing(n, r, i, a ??
|
|
2284
|
-
s && t.tempId && (X(e, t, s, t.tempId, !0),
|
|
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));
|
|
2285
2487
|
break;
|
|
2286
2488
|
}
|
|
2287
2489
|
case "updateComment": {
|
|
@@ -2291,7 +2493,7 @@ async function fr(e, t) {
|
|
|
2291
2493
|
}
|
|
2292
2494
|
case "deleteComment": {
|
|
2293
2495
|
let [n] = t.args;
|
|
2294
|
-
await e.apiClient.deleteComment(n),
|
|
2496
|
+
await e.apiClient.deleteComment(n), Er(e, n);
|
|
2295
2497
|
break;
|
|
2296
2498
|
}
|
|
2297
2499
|
case "resolveComment": {
|
|
@@ -2313,10 +2515,10 @@ async function fr(e, t) {
|
|
|
2313
2515
|
let [n, r, i] = t.args, a = await e.apiClient.addReply(n, r, t.tempId, ...i ? [i] : []);
|
|
2314
2516
|
if (a && t.tempId) {
|
|
2315
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);
|
|
2316
|
-
|
|
2518
|
+
sn(e, n, t.tempId, i && o ? {
|
|
2317
2519
|
...a,
|
|
2318
2520
|
reactions: o.reactions
|
|
2319
|
-
} : a),
|
|
2521
|
+
} : a), Dr(e, n, t.tempId, a.id);
|
|
2320
2522
|
let s = e.getState().comments.find((e) => e.id === n);
|
|
2321
2523
|
s && X(e, t, s, n);
|
|
2322
2524
|
}
|
|
@@ -2334,7 +2536,7 @@ async function fr(e, t) {
|
|
|
2334
2536
|
}
|
|
2335
2537
|
}
|
|
2336
2538
|
}
|
|
2337
|
-
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([
|
|
2338
2540
|
"jpg",
|
|
2339
2541
|
"jpeg",
|
|
2340
2542
|
"png",
|
|
@@ -2345,7 +2547,7 @@ var pr = 1e4, mr = 2048, hr = 10485760, gr = 20971520, Z = 16384, _r = 32e6, vr
|
|
|
2345
2547
|
"docx",
|
|
2346
2548
|
"txt",
|
|
2347
2549
|
"csv"
|
|
2348
|
-
]),
|
|
2550
|
+
]), Rr = 15e3, zr = 1e4, Br = {
|
|
2349
2551
|
"image/gif": "gif",
|
|
2350
2552
|
"image/jpeg": "jpg",
|
|
2351
2553
|
"image/png": "png",
|
|
@@ -2355,72 +2557,72 @@ function Q(e, t) {
|
|
|
2355
2557
|
let n = Error(t);
|
|
2356
2558
|
return n.error = e, n.code = 400, n;
|
|
2357
2559
|
}
|
|
2358
|
-
function
|
|
2560
|
+
function Vr(e) {
|
|
2359
2561
|
if (typeof e != "string") throw Q("invalid_position", "Invalid position");
|
|
2360
2562
|
let t = e.trim();
|
|
2361
|
-
if (!t || t.length >
|
|
2563
|
+
if (!t || t.length > Ar || a(t)) throw Q("invalid_position", "Invalid position");
|
|
2362
2564
|
return t;
|
|
2363
2565
|
}
|
|
2364
|
-
function
|
|
2365
|
-
if (!
|
|
2566
|
+
function Hr(t) {
|
|
2567
|
+
if (!o(t) || !e(t.x) || !e(t.y)) throw Q("invalid_position", "Invalid position");
|
|
2366
2568
|
return {
|
|
2367
2569
|
x: t.x,
|
|
2368
2570
|
y: t.y,
|
|
2369
|
-
...t.element === void 0 ? {} : { element:
|
|
2370
|
-
...t.xpath === void 0 ? {} : { xpath:
|
|
2571
|
+
...t.element === void 0 ? {} : { element: Vr(t.element) },
|
|
2572
|
+
...t.xpath === void 0 ? {} : { xpath: Vr(t.xpath) }
|
|
2371
2573
|
};
|
|
2372
2574
|
}
|
|
2373
|
-
function
|
|
2575
|
+
function Ur(e) {
|
|
2374
2576
|
if (typeof e != "string") throw Q("invalid_content", "Screenshot comment is required");
|
|
2375
2577
|
let t = e.trim();
|
|
2376
|
-
if (!t || t.length >
|
|
2578
|
+
if (!t || t.length > kr || a(t)) throw Q("invalid_content", "Screenshot comment is required");
|
|
2377
2579
|
return t;
|
|
2378
2580
|
}
|
|
2379
|
-
function
|
|
2581
|
+
function Wr(e) {
|
|
2380
2582
|
return typeof Blob < "u" && e instanceof Blob;
|
|
2381
2583
|
}
|
|
2382
|
-
function
|
|
2584
|
+
function Gr(e) {
|
|
2383
2585
|
return typeof File < "u" && e instanceof File;
|
|
2384
2586
|
}
|
|
2385
|
-
function
|
|
2587
|
+
function Kr(e) {
|
|
2386
2588
|
return typeof HTMLElement < "u" && e instanceof HTMLElement;
|
|
2387
2589
|
}
|
|
2388
|
-
function
|
|
2590
|
+
function qr(e) {
|
|
2389
2591
|
if (e !== void 0) {
|
|
2390
|
-
if (!
|
|
2592
|
+
if (!Kr(e)) throw Q("invalid_element", "Invalid screenshot target");
|
|
2391
2593
|
return e;
|
|
2392
2594
|
}
|
|
2393
2595
|
if (typeof document > "u" || !document.body) throw Q("invalid_element", "A browser document is required to capture screenshots");
|
|
2394
2596
|
return document.body;
|
|
2395
2597
|
}
|
|
2396
|
-
function
|
|
2598
|
+
function Jr(e) {
|
|
2397
2599
|
let t = /^data:(image\/(?:png|jpeg|gif|webp));base64,/i.exec(e)?.[1];
|
|
2398
2600
|
return t ? t.toLowerCase() : null;
|
|
2399
2601
|
}
|
|
2400
|
-
function
|
|
2401
|
-
if (!
|
|
2602
|
+
function Yr(e) {
|
|
2603
|
+
if (!o(e)) throw Q("invalid_screenshot", "Invalid screenshot result");
|
|
2402
2604
|
let t = typeof e.dataUrl == "string" ? e.dataUrl.trim() : "", n = e.blob, r = e.dimensions;
|
|
2403
|
-
if (!
|
|
2404
|
-
if (!
|
|
2405
|
-
let { width:
|
|
2406
|
-
if (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");
|
|
2407
2609
|
return {
|
|
2408
2610
|
dataUrl: t,
|
|
2409
2611
|
blob: n,
|
|
2410
2612
|
dimensions: {
|
|
2411
|
-
width:
|
|
2412
|
-
height:
|
|
2613
|
+
width: i,
|
|
2614
|
+
height: a
|
|
2413
2615
|
}
|
|
2414
2616
|
};
|
|
2415
2617
|
}
|
|
2416
|
-
function
|
|
2417
|
-
let t =
|
|
2618
|
+
function Xr(e) {
|
|
2619
|
+
let t = Jr(e.dataUrl);
|
|
2418
2620
|
return e.blob.type || t;
|
|
2419
2621
|
}
|
|
2420
|
-
function
|
|
2421
|
-
return `screenshot.${
|
|
2622
|
+
function Zr(e) {
|
|
2623
|
+
return `screenshot.${Br[Xr(e)]}`;
|
|
2422
2624
|
}
|
|
2423
|
-
function
|
|
2625
|
+
function Qr(e, t, n) {
|
|
2424
2626
|
let r = null;
|
|
2425
2627
|
return new Promise((i, a) => {
|
|
2426
2628
|
r = setTimeout(() => {
|
|
@@ -2432,46 +2634,40 @@ function Ir(e, t, n) {
|
|
|
2432
2634
|
});
|
|
2433
2635
|
});
|
|
2434
2636
|
}
|
|
2435
|
-
function
|
|
2637
|
+
function $r(e) {
|
|
2436
2638
|
return new Promise((t, n) => {
|
|
2437
2639
|
let r = !1, i = setTimeout(() => {
|
|
2438
2640
|
r = !0, n(/* @__PURE__ */ Error("toBlob timed out"));
|
|
2439
|
-
},
|
|
2641
|
+
}, zr);
|
|
2440
2642
|
e.toBlob((e) => {
|
|
2441
2643
|
r || (r = !0, clearTimeout(i), e ? t(e) : n(/* @__PURE__ */ Error("toBlob returned null")));
|
|
2442
2644
|
}, "image/png");
|
|
2443
2645
|
});
|
|
2444
2646
|
}
|
|
2445
|
-
function
|
|
2647
|
+
function ei(e) {
|
|
2446
2648
|
let t = e.lastIndexOf(".");
|
|
2447
2649
|
return t >= 0 ? e.slice(t + 1).toLowerCase() : "";
|
|
2448
2650
|
}
|
|
2449
|
-
function
|
|
2651
|
+
function ti(e) {
|
|
2450
2652
|
if (!Array.isArray(e)) throw Q("invalid_files", "Files must be an array");
|
|
2451
|
-
if (e.length >
|
|
2653
|
+
if (e.length > Pr) throw Q("too_many_files", `Cannot upload more than ${Pr} files at once`);
|
|
2452
2654
|
let t = 0;
|
|
2453
2655
|
for (let n of e) {
|
|
2454
|
-
if (!
|
|
2455
|
-
if (n.size >
|
|
2456
|
-
if (t += n.size, t >
|
|
2457
|
-
if (
|
|
2458
|
-
if (
|
|
2459
|
-
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(", ")}`);
|
|
2460
2662
|
}
|
|
2461
2663
|
return e;
|
|
2462
2664
|
}
|
|
2463
|
-
function
|
|
2464
|
-
try {
|
|
2465
|
-
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;
|
|
2466
|
-
} catch {
|
|
2467
|
-
return !1;
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
async function Vr(e, t, n, r = {}) {
|
|
2665
|
+
async function ni(e, t, n, r = {}) {
|
|
2471
2666
|
if (e.isLocalDemo) return null;
|
|
2472
2667
|
try {
|
|
2473
|
-
let e =
|
|
2474
|
-
if (
|
|
2668
|
+
let e = qr(n);
|
|
2669
|
+
if (g(e)) return null;
|
|
2670
|
+
if (t) return Yr(await t(e));
|
|
2475
2671
|
let r;
|
|
2476
2672
|
try {
|
|
2477
2673
|
r = (await import("html2canvas")).default;
|
|
@@ -2479,17 +2675,18 @@ async function Vr(e, t, n, r = {}) {
|
|
|
2479
2675
|
/* v8 ignore next 3 -- dynamic import() can't be intercepted by vi.mock */
|
|
2480
2676
|
throw Error("Screenshot requires either a custom screenshotProvider in config or html2canvas installed. Install html2canvas: npm install html2canvas — or provide config.screenshotProvider.");
|
|
2481
2677
|
}
|
|
2482
|
-
let i = await
|
|
2678
|
+
let i = await Qr(r(e, {
|
|
2483
2679
|
useCORS: !0,
|
|
2484
2680
|
allowTaint: !1,
|
|
2485
2681
|
scale: 2,
|
|
2486
2682
|
logging: !1,
|
|
2487
|
-
ignoreElements:
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2683
|
+
ignoreElements: g,
|
|
2684
|
+
onclone: (e) => import("./capture-colors-CxSLsU5-.js").then(({ normalizeCaptureColors: t }) => t(e))
|
|
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({
|
|
2491
2688
|
dataUrl: i.toDataURL("image/png"),
|
|
2492
|
-
blob: await
|
|
2689
|
+
blob: await $r(i),
|
|
2493
2690
|
dimensions: {
|
|
2494
2691
|
width: i.width,
|
|
2495
2692
|
height: i.height
|
|
@@ -2503,52 +2700,52 @@ async function Vr(e, t, n, r = {}) {
|
|
|
2503
2700
|
})), null;
|
|
2504
2701
|
}
|
|
2505
2702
|
}
|
|
2506
|
-
async function
|
|
2703
|
+
async function ri(e, t, n, r) {
|
|
2507
2704
|
try {
|
|
2508
|
-
let i =
|
|
2705
|
+
let i = Yr(t), a = Ur(n), o = Hr(r);
|
|
2509
2706
|
e.setState({ isLoading: !0 });
|
|
2510
|
-
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, {
|
|
2511
2708
|
content: a,
|
|
2512
2709
|
position: o,
|
|
2513
2710
|
page: c,
|
|
2514
2711
|
...l ? { branch: l } : {}
|
|
2515
2712
|
});
|
|
2516
2713
|
return e.setState({
|
|
2517
|
-
comments: !e.getState().activeBranch || e.getState().activeBranch ===
|
|
2714
|
+
comments: !e.getState().activeBranch || e.getState().activeBranch === u.branch ? [...e.getState().comments, u] : e.getState().comments,
|
|
2518
2715
|
isLoading: !1,
|
|
2519
2716
|
activeScreenshot: null
|
|
2520
|
-
}), e.emit("comment:created",
|
|
2717
|
+
}), e.emit("comment:created", u), u;
|
|
2521
2718
|
} catch (t) {
|
|
2522
2719
|
return e.setState({ isLoading: !1 }), e.handleError(t), null;
|
|
2523
2720
|
}
|
|
2524
2721
|
}
|
|
2525
|
-
async function
|
|
2722
|
+
async function ii(e, t, n) {
|
|
2526
2723
|
try {
|
|
2527
|
-
let r =
|
|
2724
|
+
let r = ti(t);
|
|
2528
2725
|
return r.length === 0 ? [] : await e.apiClient.uploadFiles(r, n);
|
|
2529
2726
|
} catch (t) {
|
|
2530
2727
|
return e.handleError(t), [];
|
|
2531
2728
|
}
|
|
2532
2729
|
}
|
|
2533
2730
|
var $ = null;
|
|
2534
|
-
async function
|
|
2535
|
-
return $ || ($ = await import("./realtime-
|
|
2731
|
+
async function ai() {
|
|
2732
|
+
return $ || ($ = await import("./realtime-CieWAnsW.js"), $);
|
|
2536
2733
|
}
|
|
2537
|
-
var
|
|
2734
|
+
var oi = typeof window < "u", si = /* @__PURE__ */ new Set([
|
|
2538
2735
|
"list",
|
|
2539
2736
|
"detail",
|
|
2540
2737
|
"settings",
|
|
2541
2738
|
"activity",
|
|
2542
2739
|
"dev-export"
|
|
2543
|
-
]),
|
|
2740
|
+
]), ci = /* @__PURE__ */ new Set([
|
|
2544
2741
|
"comment",
|
|
2545
2742
|
"draw",
|
|
2546
2743
|
"highlight",
|
|
2547
2744
|
"screenshot",
|
|
2548
2745
|
"select",
|
|
2549
2746
|
null
|
|
2550
|
-
]),
|
|
2551
|
-
function
|
|
2747
|
+
]), li = 256, ui = "0.7.2";
|
|
2748
|
+
function di(e) {
|
|
2552
2749
|
let t = e.trim().match(/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/);
|
|
2553
2750
|
return t ? [
|
|
2554
2751
|
Number(t[1]),
|
|
@@ -2556,12 +2753,12 @@ function Xr(e) {
|
|
|
2556
2753
|
Number(t[3] ?? 0)
|
|
2557
2754
|
] : null;
|
|
2558
2755
|
}
|
|
2559
|
-
function
|
|
2756
|
+
function fi(e) {
|
|
2560
2757
|
return /^v?\d+(?:\.\d+)?(?:\.\d+)?-/.test(e.trim());
|
|
2561
2758
|
}
|
|
2562
|
-
function
|
|
2563
|
-
if (
|
|
2564
|
-
let n =
|
|
2759
|
+
function pi(e, t) {
|
|
2760
|
+
if (fi(e)) return !1;
|
|
2761
|
+
let n = di(e), r = di(t);
|
|
2565
2762
|
if (!n || !r) return !1;
|
|
2566
2763
|
for (let e = 0; e < 3; e++) {
|
|
2567
2764
|
let t = n[e] ?? 0, i = r[e] ?? 0;
|
|
@@ -2570,7 +2767,7 @@ function Qr(e, t) {
|
|
|
2570
2767
|
}
|
|
2571
2768
|
return !1;
|
|
2572
2769
|
}
|
|
2573
|
-
var
|
|
2770
|
+
var mi = class extends tt {
|
|
2574
2771
|
get isProcessingQueue() {
|
|
2575
2772
|
return this.queueGuard.current;
|
|
2576
2773
|
}
|
|
@@ -2590,7 +2787,9 @@ var $r = class extends Ue {
|
|
|
2590
2787
|
this.retryTimerRef.current = e;
|
|
2591
2788
|
}
|
|
2592
2789
|
constructor(e, t) {
|
|
2593
|
-
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.authRequestRevision = 0, this.commentsFetchRevision = 0, this.contextFetchRevision = 0, this.deepLinkRequest = null, this.reactionRequests = /* @__PURE__ */ new Map(), this.draftUploads = /* @__PURE__ */ new WeakMap(), 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 = {
|
|
2594
2793
|
comments: !0,
|
|
2595
2794
|
drawing: !1,
|
|
2596
2795
|
highlighting: !1,
|
|
@@ -2599,7 +2798,7 @@ var $r = class extends Ue {
|
|
|
2599
2798
|
}, this.config.ui = {
|
|
2600
2799
|
...this.config.ui,
|
|
2601
2800
|
loadRemoteFonts: !1
|
|
2602
|
-
}),
|
|
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 = {
|
|
2603
2802
|
getState: () => this.getInternalState(),
|
|
2604
2803
|
setState: (e) => this.setState(e),
|
|
2605
2804
|
apiClient: this.apiClient,
|
|
@@ -2627,7 +2826,7 @@ var $r = class extends Ue {
|
|
|
2627
2826
|
mouseMoveHandler: this.mouseMoveHandler
|
|
2628
2827
|
}, this.localDemo && (this.restoreDemoState(), this.localDemo.subscribe((e) => {
|
|
2629
2828
|
e !== "persist" && this.restoreDemoState();
|
|
2630
|
-
})), e.enabled !== !1 &&
|
|
2829
|
+
})), e.enabled !== !1 && oi && Promise.resolve().then(() => this.boot()).catch((e) => this.handleError(e));
|
|
2631
2830
|
/* v8 ignore stop */
|
|
2632
2831
|
}
|
|
2633
2832
|
isLocalDemo() {
|
|
@@ -2637,7 +2836,7 @@ var $r = class extends Ue {
|
|
|
2637
2836
|
if (!this.localDemo || this.destroyed) return;
|
|
2638
2837
|
let e = this.localDemo.getSession().expired, t = this.getInternalState().activeBranch ?? null;
|
|
2639
2838
|
this.overlayBeforeTool = null, this.setState({
|
|
2640
|
-
...
|
|
2839
|
+
...Mt(),
|
|
2641
2840
|
currentUser: e ? null : { ...this.localDemo.user },
|
|
2642
2841
|
isAuthenticated: !e,
|
|
2643
2842
|
isOverlayVisible: !e,
|
|
@@ -2682,7 +2881,7 @@ var $r = class extends Ue {
|
|
|
2682
2881
|
e?.mode === "hold" && e.key && (this.holdActivationHandler = (e) => {
|
|
2683
2882
|
if (this.destroyed || !this.matchesHoldKey(e)) return;
|
|
2684
2883
|
let t = this.getInternalState().activeTool;
|
|
2685
|
-
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);
|
|
2686
2885
|
}, window.addEventListener("keydown", this.holdActivationHandler), window.addEventListener("keyup", this.holdActivationHandler), this.holdBlurHandler = () => {
|
|
2687
2886
|
this.destroyed || this.getInternalState().activeTool === "select" && this.setTool(null);
|
|
2688
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 = () => {
|
|
@@ -2720,7 +2919,7 @@ var $r = class extends Ue {
|
|
|
2720
2919
|
}
|
|
2721
2920
|
e.project?.id && (this.config.projectId = String(e.project.id), this.hydrateOfflineQueue());
|
|
2722
2921
|
let t = e.project?.slug ?? e.project?.id;
|
|
2723
|
-
if (t && this.apiClient.setProject(String(t)), e.project?.features && (this.config.features = e.project.features), e.project?.reverb && e.project.features?.realtime) {
|
|
2922
|
+
if (t && this.apiClient.setProject(String(t), this.config.projectId), e.project?.features && (this.config.features = e.project.features), e.project?.reverb && e.project.features?.realtime) {
|
|
2724
2923
|
let t = e.project.reverb;
|
|
2725
2924
|
this.config.reverb = {
|
|
2726
2925
|
key: t.key,
|
|
@@ -2730,8 +2929,8 @@ var $r = class extends Ue {
|
|
|
2730
2929
|
};
|
|
2731
2930
|
}
|
|
2732
2931
|
let n = e.project?.sdkLatestVersion;
|
|
2733
|
-
n &&
|
|
2734
|
-
current:
|
|
2932
|
+
n && pi(n, "0.7.2") && (console.warn(`[CommentKit] You are using v${ui}. Update to v${n}: npm update @commentkit/comment-kit`), this.emit("sdk:outdated", {
|
|
2933
|
+
current: ui,
|
|
2735
2934
|
latest: n
|
|
2736
2935
|
})), this.setState({
|
|
2737
2936
|
project: e.project,
|
|
@@ -2748,7 +2947,7 @@ var $r = class extends Ue {
|
|
|
2748
2947
|
}
|
|
2749
2948
|
}
|
|
2750
2949
|
setState(e) {
|
|
2751
|
-
this.destroyed || (
|
|
2950
|
+
this.destroyed || (e.activeTool === null && e.isOverlayVisible === void 0 && this.overlayBeforeTool !== null && (e = {
|
|
2752
2951
|
...e,
|
|
2753
2952
|
isOverlayVisible: this.overlayBeforeTool
|
|
2754
2953
|
}, this.overlayBeforeTool = null), this.pendingStateUpdates ? Object.assign(this.pendingStateUpdates, e) : this.pendingStateUpdates = { ...e }, this.flushScheduled || (this.flushScheduled = !0, Promise.resolve().then(() => this.flushState())));
|
|
@@ -2806,7 +3005,7 @@ var $r = class extends Ue {
|
|
|
2806
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);
|
|
2807
3006
|
let n = Object.keys(e);
|
|
2808
3007
|
for (let [e, t] of this.sliceSubscribers) {
|
|
2809
|
-
let r =
|
|
3008
|
+
let r = kt[e];
|
|
2810
3009
|
if (n.some((e) => r.includes(e))) for (let n of t) try {
|
|
2811
3010
|
n(this.state);
|
|
2812
3011
|
} catch (t) {
|
|
@@ -2822,14 +3021,29 @@ var $r = class extends Ue {
|
|
|
2822
3021
|
return this.localDemo?.checkExpiry(), this.flushStateSync(), this.cloneStateSnapshot(this.state);
|
|
2823
3022
|
}
|
|
2824
3023
|
getFeatures() {
|
|
3024
|
+
let e = this.canWriteComments();
|
|
2825
3025
|
return {
|
|
2826
|
-
comments:
|
|
2827
|
-
drawing: this.config.features?.drawing ?? !0,
|
|
2828
|
-
highlighting: this.config.features?.highlighting ?? !0,
|
|
2829
|
-
screenshots: this.config.features?.screenshots ?? !0,
|
|
3026
|
+
comments: e,
|
|
3027
|
+
drawing: e && (this.config.features?.drawing ?? !0),
|
|
3028
|
+
highlighting: e && (this.config.features?.highlighting ?? !0),
|
|
3029
|
+
screenshots: e && (this.config.features?.screenshots ?? !0),
|
|
2830
3030
|
realtime: this.config.features?.realtime ?? !0
|
|
2831
3031
|
};
|
|
2832
3032
|
}
|
|
3033
|
+
canWriteComments() {
|
|
3034
|
+
return this.getWriteAccess().canWrite;
|
|
3035
|
+
}
|
|
3036
|
+
getWriteAccess() {
|
|
3037
|
+
return Ze(this.config, this.getInternalState(), this.writeRestriction);
|
|
3038
|
+
}
|
|
3039
|
+
requireCommentWrite() {
|
|
3040
|
+
let e = this.getWriteAccess();
|
|
3041
|
+
return e.canWrite ? !0 : (this.handleError({
|
|
3042
|
+
error: e.planRequired ? "plan_required" : "feature_disabled",
|
|
3043
|
+
message: e.message,
|
|
3044
|
+
code: e.planRequired ? 402 : 403
|
|
3045
|
+
}), !1);
|
|
3046
|
+
}
|
|
2833
3047
|
getConfig() {
|
|
2834
3048
|
return {
|
|
2835
3049
|
apiKey: this.config.apiKey,
|
|
@@ -2837,15 +3051,16 @@ var $r = class extends Ue {
|
|
|
2837
3051
|
...this.config.enabled !== void 0 && { enabled: this.config.enabled },
|
|
2838
3052
|
screenshotProvider: this.config.screenshotProvider,
|
|
2839
3053
|
branch: this.config.branch,
|
|
3054
|
+
persistence: this.config.persistence,
|
|
2840
3055
|
realtime: this.config.realtime ? { ...this.config.realtime } : void 0,
|
|
2841
3056
|
ui: this.config.ui ? { ...this.config.ui } : void 0
|
|
2842
3057
|
};
|
|
2843
3058
|
}
|
|
2844
3059
|
async validateInvite(e) {
|
|
2845
|
-
if (!(this.destroyed || this.localDemo)) return
|
|
3060
|
+
if (!(this.destroyed || this.localDemo)) return Ot(this.ctx, e, (e) => this.login(e), this.beginAuthRequest());
|
|
2846
3061
|
}
|
|
2847
3062
|
onSlice(e, t) {
|
|
2848
|
-
if (!
|
|
3063
|
+
if (!kt[e] || typeof t != "function" || this.destroyed) return () => {};
|
|
2849
3064
|
let n = this.sliceSubscribers.get(e);
|
|
2850
3065
|
return n || (n = /* @__PURE__ */ new Set(), this.sliceSubscribers.set(e, n)), n.add(t), () => n.delete(t);
|
|
2851
3066
|
}
|
|
@@ -2873,26 +3088,37 @@ var $r = class extends Ue {
|
|
|
2873
3088
|
message: n,
|
|
2874
3089
|
code: typeof t?.code == "number" && Number.isFinite(t.code) ? t.code : 0,
|
|
2875
3090
|
...t?.details && typeof t.details == "object" ? { details: t.details } : {}
|
|
2876
|
-
};
|
|
3091
|
+
}, i = r.details?.quota, a = i && typeof i == "object" ? i : null, o = r.error === "quota_exceeded" && a?.type === "feature" && a.feature === "comments";
|
|
3092
|
+
if (r.code === 402 && (r.error === "plan_required" || o)) {
|
|
3093
|
+
this.writeRestriction = r.error === "plan_required" || a?.reason === "plan_required" || !a?.reason && a?.plan === "none" ? "plan_required" : "feature_disabled";
|
|
3094
|
+
let e = this.getInternalState().projectContext;
|
|
3095
|
+
e && this.setState({ projectContext: {
|
|
3096
|
+
...e,
|
|
3097
|
+
permissions: {
|
|
3098
|
+
...e.permissions,
|
|
3099
|
+
canWriteComments: !1,
|
|
3100
|
+
writeRestriction: this.writeRestriction,
|
|
3101
|
+
canManageComments: !1
|
|
3102
|
+
}
|
|
3103
|
+
} });
|
|
3104
|
+
let t = this.getInternalState().activeTool;
|
|
3105
|
+
t !== null && t !== "select" && this.setTool(null);
|
|
3106
|
+
}
|
|
2877
3107
|
console.error("[CommentKit]", r.message), this.setState({
|
|
2878
3108
|
error: r.message,
|
|
2879
3109
|
isLoading: !1
|
|
2880
3110
|
}), this.emit("error", r);
|
|
2881
3111
|
}
|
|
2882
3112
|
async restorePersistedSession() {
|
|
2883
|
-
|
|
2884
|
-
let e =
|
|
2885
|
-
if (e)
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
otpStep: "idle",
|
|
2891
|
-
otpEmail: null,
|
|
2892
|
-
error: null
|
|
2893
|
-
}), 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-CPQpt3-u.js");
|
|
3119
|
+
await n(this.ctx, e, t, this.config.persistence !== "memory") && await this.afterAuthenticated();
|
|
2894
3120
|
} catch {
|
|
2895
|
-
this.handleAuthExpired();
|
|
3121
|
+
t() && this.handleAuthExpired();
|
|
2896
3122
|
}
|
|
2897
3123
|
}
|
|
2898
3124
|
async afterAuthenticated(e) {
|
|
@@ -2902,14 +3128,14 @@ var $r = class extends Ue {
|
|
|
2902
3128
|
projectContext: null,
|
|
2903
3129
|
activities: [],
|
|
2904
3130
|
seenThreadIds: /* @__PURE__ */ new Set()
|
|
2905
|
-
}),
|
|
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());
|
|
2906
3132
|
}
|
|
2907
3133
|
beginAuthRequest() {
|
|
2908
3134
|
let e = ++this.authRequestRevision;
|
|
2909
3135
|
return () => !this.destroyed && e === this.authRequestRevision;
|
|
2910
3136
|
}
|
|
2911
3137
|
async login(e) {
|
|
2912
|
-
if (!(this.destroyed || this.localDemo)) return
|
|
3138
|
+
if (!(this.destroyed || this.localDemo)) return xt(this.ctx, e, this.beginAuthRequest());
|
|
2913
3139
|
}
|
|
2914
3140
|
async verifyOtp(e) {
|
|
2915
3141
|
if (this.destroyed || this.localDemo) return;
|
|
@@ -2924,7 +3150,7 @@ var $r = class extends Ue {
|
|
|
2924
3150
|
return;
|
|
2925
3151
|
}
|
|
2926
3152
|
let n = this.getInternalState().currentUser?.id;
|
|
2927
|
-
return
|
|
3153
|
+
return St(this.ctx, e, {
|
|
2928
3154
|
isCurrent: this.beginAuthRequest(),
|
|
2929
3155
|
onAuthenticated: async () => {
|
|
2930
3156
|
await this.afterAuthenticated(n);
|
|
@@ -2941,24 +3167,24 @@ var $r = class extends Ue {
|
|
|
2941
3167
|
});
|
|
2942
3168
|
}
|
|
2943
3169
|
cancelOtp() {
|
|
2944
|
-
this.destroyed || (this.authRequestRevision++,
|
|
3170
|
+
this.destroyed || (this.authRequestRevision++, Ct(this.ctx));
|
|
2945
3171
|
}
|
|
2946
3172
|
async resendOtp() {
|
|
2947
|
-
if (!(this.destroyed || this.localDemo)) return
|
|
3173
|
+
if (!(this.destroyed || this.localDemo)) return wt(this.ctx, this.beginAuthRequest());
|
|
2948
3174
|
}
|
|
2949
3175
|
logout() {
|
|
2950
3176
|
this.destroyed || (this.authRequestRevision++, this.localDemo ? (this.setTool(null), this.setState({
|
|
2951
3177
|
isOverlayVisible: !1,
|
|
2952
3178
|
isSidebarVisible: !1
|
|
2953
|
-
})) : (this.sessionRevision++, this.draftUploads = /* @__PURE__ */ new WeakMap(), 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, () => {
|
|
2954
3180
|
this.disconnectRealtime(!0);
|
|
2955
3181
|
})));
|
|
2956
3182
|
}
|
|
2957
3183
|
handleAuthExpired() {
|
|
2958
|
-
this.destroyed || (this.authRequestRevision++, this.sessionRevision++, this.draftUploads = /* @__PURE__ */ new WeakMap(), 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));
|
|
2959
3185
|
}
|
|
2960
3186
|
toggleLoginModal() {
|
|
2961
|
-
this.destroyed || this.localDemo ||
|
|
3187
|
+
this.destroyed || this.localDemo || Dt(this.ctx);
|
|
2962
3188
|
}
|
|
2963
3189
|
requiresShortcut() {
|
|
2964
3190
|
return this.localDemo ? !0 : this.config.environment !== "development";
|
|
@@ -2978,8 +3204,9 @@ var $r = class extends Ue {
|
|
|
2978
3204
|
this.destroyed || this.setState({ isSidebarVisible: !this.getInternalState().isSidebarVisible });
|
|
2979
3205
|
}
|
|
2980
3206
|
setTool(e) {
|
|
2981
|
-
if (this.destroyed || !
|
|
3207
|
+
if (this.destroyed || !ci.has(e) || this.localDemo && e !== null && e !== "comment" && e !== "select") return;
|
|
2982
3208
|
let t = this.getInternalState();
|
|
3209
|
+
if (e !== null && e !== "select" && !this.requireCommentWrite()) return;
|
|
2983
3210
|
if (!t.isAuthenticated && e !== "select" && e !== null) {
|
|
2984
3211
|
this.toggleLoginModal();
|
|
2985
3212
|
return;
|
|
@@ -2998,29 +3225,39 @@ var $r = class extends Ue {
|
|
|
2998
3225
|
activeScreenshot: null
|
|
2999
3226
|
});
|
|
3000
3227
|
}
|
|
3001
|
-
operationContext() {
|
|
3228
|
+
operationContext(e) {
|
|
3002
3229
|
this.localDemo?.refresh();
|
|
3003
|
-
let
|
|
3230
|
+
let t = this.localDemo?.getRevision(), n = this.sessionRevision, r = () => !this.destroyed && n === this.sessionRevision && t === this.localDemo?.getRevision();
|
|
3004
3231
|
return {
|
|
3005
3232
|
...this.ctx,
|
|
3233
|
+
isCurrent: r,
|
|
3006
3234
|
setState: (e) => {
|
|
3007
|
-
|
|
3235
|
+
r() && this.ctx.setState(e);
|
|
3008
3236
|
},
|
|
3009
|
-
emit: (
|
|
3010
|
-
|
|
3237
|
+
emit: (t, n) => {
|
|
3238
|
+
r() && (e && (t === "comment:created" || t === "comment:updated") && (e.result = {
|
|
3239
|
+
status: "confirmed",
|
|
3240
|
+
commentId: n.id
|
|
3241
|
+
}), this.ctx.emit(t, n));
|
|
3011
3242
|
},
|
|
3012
3243
|
handleError: (e) => {
|
|
3013
|
-
|
|
3244
|
+
r() && this.ctx.handleError(e);
|
|
3014
3245
|
}
|
|
3015
3246
|
};
|
|
3016
3247
|
}
|
|
3017
|
-
operationCallbacks() {
|
|
3018
|
-
let
|
|
3248
|
+
operationCallbacks(e) {
|
|
3249
|
+
let t = this.localDemo?.getRevision(), n = this.sessionRevision, r = () => !this.destroyed && n === this.sessionRevision && t === this.localDemo?.getRevision();
|
|
3019
3250
|
return {
|
|
3020
3251
|
...this.commentCb,
|
|
3021
|
-
queueMutation: (...
|
|
3252
|
+
queueMutation: (...t) => {
|
|
3253
|
+
let n = r() && this.commentCb.queueMutation(...t);
|
|
3254
|
+
return n && e && r() && (e.result = {
|
|
3255
|
+
status: "queued",
|
|
3256
|
+
commentId: t[2]
|
|
3257
|
+
}), n;
|
|
3258
|
+
},
|
|
3022
3259
|
addActivity: (e) => {
|
|
3023
|
-
|
|
3260
|
+
r() && this.commentCb.addActivity(e);
|
|
3024
3261
|
}
|
|
3025
3262
|
};
|
|
3026
3263
|
}
|
|
@@ -3028,6 +3265,7 @@ var $r = class extends Ue {
|
|
|
3028
3265
|
let t = this.operationContext();
|
|
3029
3266
|
return {
|
|
3030
3267
|
...t,
|
|
3268
|
+
isCurrent: () => e === this.commentsFetchRevision && !!t.isCurrent?.(),
|
|
3031
3269
|
setState: (n) => {
|
|
3032
3270
|
e === this.commentsFetchRevision && t.setState(n);
|
|
3033
3271
|
},
|
|
@@ -3037,27 +3275,77 @@ var $r = class extends Ue {
|
|
|
3037
3275
|
};
|
|
3038
3276
|
}
|
|
3039
3277
|
async loadComments() {
|
|
3040
|
-
return
|
|
3278
|
+
return ln(this.commentsRequestContext(++this.commentsFetchRevision));
|
|
3041
3279
|
}
|
|
3042
3280
|
async loadMoreComments() {
|
|
3043
|
-
this.destroyed || await
|
|
3281
|
+
this.destroyed || await un(this.commentsRequestContext(this.commentsFetchRevision), this.loadMoreGuard);
|
|
3044
3282
|
}
|
|
3045
3283
|
async reloadComments() {
|
|
3046
3284
|
if (!this.destroyed) return this.loadComments();
|
|
3047
3285
|
}
|
|
3286
|
+
async refreshAttachmentUrl(e) {
|
|
3287
|
+
if (this.destroyed || this.localDemo || !this.getInternalState().isAuthenticated || typeof e != "string" || !e || e.length > 256 || a(e)) return null;
|
|
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));
|
|
3289
|
+
if (!n) return null;
|
|
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 () => {
|
|
3292
|
+
try {
|
|
3293
|
+
let e = await this.apiClient.getComment(n.id);
|
|
3294
|
+
if (!s() || e?.id !== n.id || !Array.isArray(e.replies)) return null;
|
|
3295
|
+
let t = this.getInternalState(), r = t.comments.find((e) => e.id === n.id);
|
|
3296
|
+
if (!r) return null;
|
|
3297
|
+
let i = (e, t) => e?.map((e) => {
|
|
3298
|
+
let n = t?.find((t) => t.id === e.id);
|
|
3299
|
+
return n && l(n.url, !0) ? {
|
|
3300
|
+
...e,
|
|
3301
|
+
url: n.url,
|
|
3302
|
+
...l(n.thumbnail, !0) ? { thumbnail: n.thumbnail } : {}
|
|
3303
|
+
} : e;
|
|
3304
|
+
}), a = {
|
|
3305
|
+
...r,
|
|
3306
|
+
attachments: i(r.attachments, e.attachments) ?? [],
|
|
3307
|
+
replies: r.replies.map((t) => ({
|
|
3308
|
+
...t,
|
|
3309
|
+
attachments: i(t.attachments, e.replies.find((e) => e.id === t.id)?.attachments)
|
|
3310
|
+
}))
|
|
3311
|
+
};
|
|
3312
|
+
return this.setState({
|
|
3313
|
+
comments: t.comments.map((e) => e.id === n.id ? a : e),
|
|
3314
|
+
...t.selectedComment?.id === n.id ? { selectedComment: a } : {}
|
|
3315
|
+
}), e;
|
|
3316
|
+
} catch (e) {
|
|
3317
|
+
return s() && this.handleError(e), null;
|
|
3318
|
+
} finally {
|
|
3319
|
+
this.attachmentRefreshes.get(o) === c && this.attachmentRefreshes.delete(o);
|
|
3320
|
+
}
|
|
3321
|
+
})(), this.attachmentRefreshes.set(o, c));
|
|
3322
|
+
let u = await c;
|
|
3323
|
+
if (!s() || !u) return null;
|
|
3324
|
+
let d = this.getInternalState().comments.find((e) => e.id === n.id);
|
|
3325
|
+
if (!d || !t(d)) return null;
|
|
3326
|
+
let f = t(u)?.url;
|
|
3327
|
+
return l(f, !0) ? f : null;
|
|
3328
|
+
}
|
|
3048
3329
|
async reloadProjectContext() {
|
|
3049
3330
|
if (this.destroyed || this.localDemo || !this.getInternalState().isAuthenticated) return;
|
|
3050
|
-
let e = this.operationContext(), t = ++this.contextFetchRevision;
|
|
3331
|
+
let e = this.operationContext(), t = this.sessionRevision, n = ++this.contextFetchRevision;
|
|
3051
3332
|
try {
|
|
3052
|
-
let
|
|
3053
|
-
if (t !== this.contextFetchRevision) return;
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3333
|
+
let r = await this.apiClient.getProjectContext();
|
|
3334
|
+
if (this.destroyed || t !== this.sessionRevision || n !== this.contextFetchRevision) return;
|
|
3335
|
+
if (r?.project && Array.isArray(r.members)) {
|
|
3336
|
+
let t = this.canWriteComments();
|
|
3337
|
+
if (r.permissions.canWriteComments !== void 0 && (this.writeRestriction = null), e.setState({ projectContext: r }), r.permissions.canWriteComments === !1) {
|
|
3338
|
+
let e = this.getInternalState().activeTool;
|
|
3339
|
+
e !== null && e !== "select" && this.setTool(null);
|
|
3340
|
+
}
|
|
3341
|
+
!t && this.canWriteComments() && this.getInternalState().isOnline && this.scheduleRetry();
|
|
3342
|
+
}
|
|
3343
|
+
} catch (t) {
|
|
3344
|
+
n === this.contextFetchRevision && t.code !== 404 && e.handleError(t);
|
|
3057
3345
|
}
|
|
3058
3346
|
}
|
|
3059
3347
|
async setBranch(e) {
|
|
3060
|
-
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;
|
|
3061
3349
|
let t = e?.trim() ?? null;
|
|
3062
3350
|
(this.getInternalState().activeBranch ?? null) !== t && (this.setState({
|
|
3063
3351
|
activeBranch: t,
|
|
@@ -3069,6 +3357,7 @@ var $r = class extends Ue {
|
|
|
3069
3357
|
}
|
|
3070
3358
|
async uploadDraftFiles(e) {
|
|
3071
3359
|
if (this.destroyed || this.localDemo || !this.getInternalState().isAuthenticated) throw Error("Sign in to attach files.");
|
|
3360
|
+
if (!this.requireCommentWrite()) throw Error("This workspace is read-only.");
|
|
3072
3361
|
if (!Array.isArray(e) || e.length > 10) throw Error("Attach up to 10 files.");
|
|
3073
3362
|
let t = this.sessionRevision, n = [], r = this.draftUploads;
|
|
3074
3363
|
for (let i of e) {
|
|
@@ -3077,56 +3366,61 @@ var $r = class extends Ue {
|
|
|
3077
3366
|
try {
|
|
3078
3367
|
n.push(await e);
|
|
3079
3368
|
} catch (e) {
|
|
3080
|
-
throw r.delete(i), e;
|
|
3369
|
+
throw r.delete(i), !this.destroyed && t === this.sessionRevision && this.handleError(e), e;
|
|
3081
3370
|
}
|
|
3082
3371
|
if (this.destroyed || t !== this.sessionRevision) throw Error("Your session changed. Please sign in again.");
|
|
3083
3372
|
}
|
|
3084
3373
|
return n;
|
|
3085
3374
|
}
|
|
3086
3375
|
async createComment(e, t, n, r = "medium", i, a, o) {
|
|
3087
|
-
if (!this.
|
|
3088
|
-
|
|
3376
|
+
if (this.destroyed || !this.requireCommentWrite()) return;
|
|
3377
|
+
if (this.localDemo && (e !== "pin" || o?.files?.length || o?.attachmentIds?.length)) {
|
|
3378
|
+
this.handleError({
|
|
3089
3379
|
error: "demo_unavailable",
|
|
3090
3380
|
message: "Files and drawings are unavailable in the private browser demo.",
|
|
3091
3381
|
code: 400
|
|
3092
3382
|
});
|
|
3093
|
-
|
|
3094
|
-
...o,
|
|
3095
|
-
branch: o?.branch ?? this.getInternalState().activeBranch ?? void 0
|
|
3096
|
-
});
|
|
3383
|
+
return;
|
|
3097
3384
|
}
|
|
3385
|
+
let s = o?.[nt];
|
|
3386
|
+
return dn(this.operationContext(s), this.operationCallbacks(s), this.activeMutations, e, t, n, r, i, a, {
|
|
3387
|
+
...o,
|
|
3388
|
+
branch: o?.branch ?? F(this.ctx)
|
|
3389
|
+
});
|
|
3098
3390
|
}
|
|
3099
3391
|
async updateComment(e, t) {
|
|
3100
|
-
if (!this.destroyed) return
|
|
3392
|
+
if (!this.destroyed && this.requireCommentWrite()) return fn(this.operationContext(), this.operationCallbacks(), e, t);
|
|
3101
3393
|
}
|
|
3102
3394
|
async deleteComment(e) {
|
|
3103
|
-
if (!this.destroyed) return
|
|
3395
|
+
if (!this.destroyed && this.requireCommentWrite()) return pn(this.operationContext(), this.operationCallbacks(), e);
|
|
3104
3396
|
}
|
|
3105
3397
|
async addReply(e, t, n) {
|
|
3106
|
-
if (
|
|
3398
|
+
if (this.destroyed || !this.requireCommentWrite()) return;
|
|
3399
|
+
let { [nt]: r, ...i } = n ?? {};
|
|
3400
|
+
return mn(this.operationContext(r), this.operationCallbacks(r), e, t, n ? i : void 0);
|
|
3107
3401
|
}
|
|
3108
3402
|
async updateReply(e, t, n, r) {
|
|
3109
|
-
if (!this.destroyed) return
|
|
3403
|
+
if (!this.destroyed && this.requireCommentWrite()) return hn(this.operationContext(), e, t, n, r);
|
|
3110
3404
|
}
|
|
3111
3405
|
async deleteReply(e, t) {
|
|
3112
|
-
if (!this.destroyed) return
|
|
3406
|
+
if (!this.destroyed && this.requireCommentWrite()) return gn(this.operationContext(), e, t);
|
|
3113
3407
|
}
|
|
3114
3408
|
async resolveComment(e) {
|
|
3115
|
-
if (!this.destroyed) return
|
|
3409
|
+
if (!this.destroyed && this.requireCommentWrite()) return _n(this.operationContext(), this.operationCallbacks(), e);
|
|
3116
3410
|
}
|
|
3117
3411
|
async unresolveComment(e) {
|
|
3118
|
-
if (!this.destroyed) return
|
|
3412
|
+
if (!this.destroyed && this.requireCommentWrite()) return vn(this.operationContext(), this.operationCallbacks(), e);
|
|
3119
3413
|
}
|
|
3120
3414
|
selectComment(e) {
|
|
3121
|
-
this.destroyed ||
|
|
3415
|
+
this.destroyed || Sn(this.operationContext(), e);
|
|
3122
3416
|
}
|
|
3123
3417
|
async completeComment(e) {
|
|
3124
|
-
if (!this.destroyed) return
|
|
3418
|
+
if (!this.destroyed && this.requireCommentWrite()) return yn(this.operationContext(), this.operationCallbacks(), e);
|
|
3125
3419
|
}
|
|
3126
3420
|
async reactToComment(e, t, n) {
|
|
3127
|
-
if (this.destroyed) return;
|
|
3421
|
+
if (this.destroyed || !this.requireCommentWrite()) return;
|
|
3128
3422
|
let r = `${e}:${n ?? "parent"}`, i = this.sessionRevision, a = async () => {
|
|
3129
|
-
this.destroyed
|
|
3423
|
+
!this.destroyed && i === this.sessionRevision && this.requireCommentWrite() && await bn(this.operationContext(), this.operationCallbacks(), e, t, n);
|
|
3130
3424
|
}, o = this.reactionRequests.get(r), s = o ? o.then(a, a) : a();
|
|
3131
3425
|
this.reactionRequests.set(r, s);
|
|
3132
3426
|
try {
|
|
@@ -3136,30 +3430,36 @@ var $r = class extends Ue {
|
|
|
3136
3430
|
}
|
|
3137
3431
|
}
|
|
3138
3432
|
async updateCommentPosition(e, t, n) {
|
|
3139
|
-
if (!this.destroyed) return
|
|
3433
|
+
if (!this.destroyed && this.requireCommentWrite()) return xn(this.operationContext(), this.operationCallbacks(), e, t, n);
|
|
3140
3434
|
}
|
|
3141
3435
|
hydrateOfflineQueue() {
|
|
3142
|
-
|
|
3436
|
+
if (this.config.persistence === "memory") return;
|
|
3437
|
+
let e = hr(this.config.projectId);
|
|
3143
3438
|
if (e.length > 0) {
|
|
3144
3439
|
let t = this.getInternalState().pendingMutations, n = new Set(t.map((e) => e.id)), r = [...t, ...e.filter((e) => !n.has(e.id))];
|
|
3145
|
-
this.setState({ pendingMutations: r }),
|
|
3440
|
+
this.setState({ pendingMutations: r }), br(this.ctx), this.getInternalState().isOnline && this.scheduleRetry();
|
|
3146
3441
|
}
|
|
3147
|
-
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));
|
|
3148
3443
|
}
|
|
3149
3444
|
shouldQueueMutation(e) {
|
|
3150
|
-
return !this.localDemo &&
|
|
3445
|
+
return !this.localDemo && xr(this.getInternalState(), e);
|
|
3151
3446
|
}
|
|
3152
3447
|
queueMutation(e, t, n) {
|
|
3153
|
-
return
|
|
3448
|
+
return Sr(this.ctx, () => this.scheduleRetry(), e, t, n);
|
|
3154
3449
|
}
|
|
3155
3450
|
scheduleRetry() {
|
|
3156
|
-
|
|
3451
|
+
Cr(this.ctx, this.retryTimerRef, () => this.processOfflineQueue());
|
|
3157
3452
|
}
|
|
3158
3453
|
async processOfflineQueue() {
|
|
3159
|
-
await
|
|
3454
|
+
this.canWriteComments() && await wr(this.operationContext(), this.queueGuard, () => this.scheduleRetry(), (e) => this.executeMutation(e));
|
|
3160
3455
|
}
|
|
3161
3456
|
async executeMutation(e) {
|
|
3162
|
-
|
|
3457
|
+
let t = this.operationContext();
|
|
3458
|
+
try {
|
|
3459
|
+
await Or(t, e);
|
|
3460
|
+
} catch (e) {
|
|
3461
|
+
throw e instanceof T && e.code === 402 && t.handleError(e), e;
|
|
3462
|
+
}
|
|
3163
3463
|
}
|
|
3164
3464
|
getPendingMutationCount() {
|
|
3165
3465
|
return this.getInternalState().pendingMutations.length;
|
|
@@ -3171,7 +3471,7 @@ var $r = class extends Ue {
|
|
|
3171
3471
|
!this.destroyed && this.getInternalState().isAuthenticated && (this.wsManager ? this.wsManager.reconnect() : this.initializeWebSocket());
|
|
3172
3472
|
}
|
|
3173
3473
|
markThreadSeen(e) {
|
|
3174
|
-
if (this.destroyed || typeof e != "string" || !e.trim() || e.length >
|
|
3474
|
+
if (this.destroyed || typeof e != "string" || !e.trim() || e.length > li) return;
|
|
3175
3475
|
let t = new Set(this.getInternalState().seenThreadIds);
|
|
3176
3476
|
if (t.add(e), t.size > 1e3) {
|
|
3177
3477
|
let e = Array.from(t);
|
|
@@ -3184,7 +3484,7 @@ var $r = class extends Ue {
|
|
|
3184
3484
|
return typeof e != "string" || !e.trim() ? !1 : !this.getInternalState().seenThreadIds.has(e);
|
|
3185
3485
|
}
|
|
3186
3486
|
setPanelView(e) {
|
|
3187
|
-
!this.destroyed &&
|
|
3487
|
+
!this.destroyed && si.has(e) && this.setState({ panelView: e });
|
|
3188
3488
|
}
|
|
3189
3489
|
toggleShortcutsOverlay() {
|
|
3190
3490
|
this.destroyed || this.setState({ isShortcutsOverlayVisible: !this.getInternalState().isShortcutsOverlayVisible });
|
|
@@ -3248,53 +3548,53 @@ var $r = class extends Ue {
|
|
|
3248
3548
|
}
|
|
3249
3549
|
}
|
|
3250
3550
|
async createHighlight(e, t) {
|
|
3251
|
-
if (!this.destroyed) return
|
|
3551
|
+
if (!this.destroyed && this.requireCommentWrite()) return Cn(this.operationContext(), this.operationCallbacks(), this.activeMutations, e, t);
|
|
3252
3552
|
}
|
|
3253
3553
|
async createDrawing(e, t, n) {
|
|
3254
|
-
if (!this.destroyed) return
|
|
3554
|
+
if (!this.destroyed && this.requireCommentWrite()) return wn(this.operationContext(), this.operationCallbacks(), this.activeMutations, e, t, n);
|
|
3255
3555
|
}
|
|
3256
3556
|
setActiveDrawing(e) {
|
|
3257
3557
|
this.destroyed || this.setState({ activeDrawing: e });
|
|
3258
3558
|
}
|
|
3259
3559
|
sendDrawingStroke(e) {
|
|
3260
|
-
this.destroyed
|
|
3560
|
+
!this.destroyed && this.requireCommentWrite() && this.wsManager?.sendDrawingStroke(e);
|
|
3261
3561
|
}
|
|
3262
3562
|
async captureScreenshot(e) {
|
|
3263
|
-
return this.destroyed ? null :
|
|
3563
|
+
return this.destroyed ? null : ni(this.ctx, this.screenshotProvider, e);
|
|
3264
3564
|
}
|
|
3265
3565
|
async uploadScreenshot(e, t, n) {
|
|
3266
|
-
return this.destroyed ? null :
|
|
3566
|
+
return this.destroyed || !this.requireCommentWrite() ? null : ri(this.operationContext(), e, t, n);
|
|
3267
3567
|
}
|
|
3268
3568
|
setActiveScreenshot(e) {
|
|
3269
3569
|
this.destroyed || this.setState({ activeScreenshot: e });
|
|
3270
3570
|
}
|
|
3271
3571
|
async uploadFiles(e, t) {
|
|
3272
|
-
return this.destroyed ? [] :
|
|
3572
|
+
return this.destroyed || !this.requireCommentWrite() ? [] : ii(this.ctx, e, t);
|
|
3273
3573
|
}
|
|
3274
3574
|
getAgentContext(e) {
|
|
3275
|
-
return
|
|
3575
|
+
return O(this.getInternalState(), e);
|
|
3276
3576
|
}
|
|
3277
3577
|
async getAgentContextAsync(e) {
|
|
3278
|
-
let t =
|
|
3279
|
-
return this.localDemo?.checkExpiry(), this.localDemo && n !== this.localDemo.getRevision() ?
|
|
3578
|
+
let t = O(this.getInternalState(), e), n = this.localDemo?.getRevision(), r = await Ue(t);
|
|
3579
|
+
return this.localDemo?.checkExpiry(), this.localDemo && n !== this.localDemo.getRevision() ? O(this.getInternalState(), e) : r;
|
|
3280
3580
|
}
|
|
3281
3581
|
formatAgentContext(e) {
|
|
3282
|
-
return
|
|
3582
|
+
return k(this.getAgentContext(e));
|
|
3283
3583
|
}
|
|
3284
3584
|
async formatAgentContextAsync(e) {
|
|
3285
|
-
return
|
|
3585
|
+
return k(await this.getAgentContextAsync(e));
|
|
3286
3586
|
}
|
|
3287
3587
|
async copyAgentContext(e) {
|
|
3288
3588
|
if (this.destroyed) return "";
|
|
3289
|
-
let t = await this.getAgentContextAsync(e), n =
|
|
3290
|
-
return await
|
|
3589
|
+
let t = await this.getAgentContextAsync(e), n = k(t);
|
|
3590
|
+
return await Xe(n, t), this.emit("agent:context-copied", {
|
|
3291
3591
|
commentCount: t.comments.length,
|
|
3292
3592
|
sourceResolved: t.sourceResolved
|
|
3293
3593
|
}), n;
|
|
3294
3594
|
}
|
|
3295
3595
|
async grabElement(e, t) {
|
|
3296
3596
|
if (this.destroyed) return null;
|
|
3297
|
-
let { grabElement: n } = await import("./dev-grab-
|
|
3597
|
+
let { grabElement: n } = await import("./dev-grab-Ca4MlS2Y.js");
|
|
3298
3598
|
if (this.destroyed) return null;
|
|
3299
3599
|
let r = await n(e, this.ctx, this.screenshotProvider, t);
|
|
3300
3600
|
return this.destroyed ? null : (r && this.emit("agent:element-grabbed", {
|
|
@@ -3304,7 +3604,7 @@ var $r = class extends Ue {
|
|
|
3304
3604
|
}
|
|
3305
3605
|
async grabElements(e, t) {
|
|
3306
3606
|
if (this.destroyed) return null;
|
|
3307
|
-
let { grabElements: n } = await import("./dev-grab-
|
|
3607
|
+
let { grabElements: n } = await import("./dev-grab-Ca4MlS2Y.js");
|
|
3308
3608
|
if (this.destroyed) return null;
|
|
3309
3609
|
let r = await n(e, this.ctx, this.screenshotProvider, t);
|
|
3310
3610
|
return this.destroyed ? null : (r && this.emit("agent:elements-grabbed", { count: r.results.length }), r);
|
|
@@ -3318,16 +3618,16 @@ var $r = class extends Ue {
|
|
|
3318
3618
|
}
|
|
3319
3619
|
}
|
|
3320
3620
|
handleToggleRequest() {
|
|
3321
|
-
this.destroyed ||
|
|
3621
|
+
this.destroyed || A() || Rn(this.getInternalState(), this.kbdCallbacks);
|
|
3322
3622
|
}
|
|
3323
3623
|
handleKeyboardShortcuts(e) {
|
|
3324
|
-
if (!this.destroyed) {
|
|
3624
|
+
if (!(this.destroyed || A())) {
|
|
3325
3625
|
if (e.key === "Escape") {
|
|
3326
|
-
if (this.escapeBlockers.size > 0
|
|
3626
|
+
if (this.escapeBlockers.size > 0) return;
|
|
3327
3627
|
let t = e.composedPath()[0];
|
|
3328
3628
|
if (t instanceof Element && t.getRootNode() === document && t.closest("[data-commentkit-ui], [data-commentkit-ignore]")) return;
|
|
3329
3629
|
}
|
|
3330
|
-
|
|
3630
|
+
zn(e, this.getInternalState(), this.kbdCallbacks);
|
|
3331
3631
|
}
|
|
3332
3632
|
}
|
|
3333
3633
|
matchesHoldKey(e) {
|
|
@@ -3341,8 +3641,11 @@ var $r = class extends Ue {
|
|
|
3341
3641
|
};
|
|
3342
3642
|
}
|
|
3343
3643
|
initializeWebSocket() {
|
|
3344
|
-
this.destroyed || this.localDemo ||
|
|
3345
|
-
this.destroyed || this.getInternalState().isAuthenticated && (this.syncRealtimeRefs(), e.initializeWebSocket(this.ctx, this.realtimeRefs
|
|
3644
|
+
this.destroyed || this.localDemo || ai().then((e) => {
|
|
3645
|
+
this.destroyed || this.getInternalState().isAuthenticated && (this.syncRealtimeRefs(), e.initializeWebSocket(this.ctx, this.realtimeRefs, {
|
|
3646
|
+
capture: () => this.commentsRequestContext(this.commentsFetchRevision),
|
|
3647
|
+
subscribe: (e) => this.on("state:changed", e)
|
|
3648
|
+
}), this.syncFromRealtimeRefs());
|
|
3346
3649
|
}).catch((e) => {
|
|
3347
3650
|
this.ctx.handleError(e);
|
|
3348
3651
|
});
|
|
@@ -3375,7 +3678,7 @@ var $r = class extends Ue {
|
|
|
3375
3678
|
this.removeMouseMoveListener(), this.syncRealtimeRefs();
|
|
3376
3679
|
}
|
|
3377
3680
|
destroy() {
|
|
3378
|
-
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());
|
|
3379
3682
|
}
|
|
3380
3683
|
};
|
|
3381
|
-
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 };
|