@commentkit/comment-kit 0.7.4 → 0.7.5
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 +13 -0
- package/README.md +2 -2
- package/SECURITY.md +1 -1
- package/dist/angular.es.js +2 -2
- package/dist/comment-kit.es.js +3 -3
- package/dist/demo.es.js +24 -15
- package/dist/headless.es.js +2 -2
- 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-DD6a0QaI.js +11 -0
- package/dist/shared/annotation-toolbar-DgqxkHy8.js +1085 -0
- package/dist/shared/{attachment-refresh-DmVkfPtl.js → attachment-refresh-DRX7dKDI.js} +3 -3
- package/dist/shared/{button-By0hGrJK.js → button-D4GHW6oZ.js} +133 -164
- package/dist/shared/{button-group-C285iSkZ.js → button-group-BVR7iT-S.js} +13 -13
- package/dist/shared/{comment-drawing-canvas-zIPS1dnW.js → comment-drawing-canvas-hSdcLShI.js} +2 -2
- package/dist/shared/{comment-icon-4SQd3nlz.js → comment-icon-D8JTCEJ7.js} +109 -110
- package/dist/shared/{comment-image-lightbox-CdMNf0_y.js → comment-image-lightbox-4zroOCCG.js} +7 -7
- package/dist/shared/{comment-images-content-DqeqmQnb.js → comment-images-content-D4hTya6e.js} +28 -28
- package/dist/shared/{comment-kit-core-C-0JJS2i.js → comment-kit-core-D068rcdY.js} +467 -503
- package/dist/shared/{comment-kit-ui-CBaz7L3u.js → comment-kit-ui-BDzNt0jv.js} +5077 -5253
- package/dist/shared/{comment-screenshot-annotator-CuYmKafz.js → comment-screenshot-annotator-BGnu_NgP.js} +2 -2
- package/dist/shared/{comment-screenshot-overlay-Dw81osel.js → comment-screenshot-overlay-BCRmojWB.js} +4 -4
- package/dist/shared/{dev-export-panel-D08M2LKD.js → dev-export-panel-CYmUKmIV.js} +3 -3
- package/dist/shared/{dev-grab-BJLZZ2xU.js → dev-grab-BYsCpsGI.js} +48 -47
- package/dist/shared/dist-D9A5k-N4.js +617 -0
- package/dist/shared/{element-selector-Biyn2cpR.js → element-selector-79Oo5pit.js} +4 -4
- package/dist/shared/{mount-ui-DXdL3p9b.js → mount-ui-DuHk132g.js} +4 -4
- package/dist/shared/{pusher-D4M5K6Dk.js → pusher-3jyUauYd.js} +1 -1
- package/dist/shared/{realtime-BTqYEy8s.js → realtime-DspH16g5.js} +41 -28
- package/dist/shared/{realtime-recovery-BSVMwsXJ.js → realtime-recovery-BjlV-ewc.js} +57 -30
- package/dist/shared/screenshot-BIuEaRiu.js +199 -0
- package/dist/shared/{separator-aphZiRoJ.js → separator-UhJb0Row.js} +1222 -1288
- package/dist/shared/{shadow-root-C58Ap5Nu.js → shadow-root-3-yGIhMs.js} +3 -5
- package/dist/shared/{token-session-D0Y_HZw0.js → token-session-_Pi4fOEi.js} +1 -1
- package/dist/shared/{useRender-D1z_X_BY.js → useRender-Uxk1OPK-.js} +1 -1
- package/dist/shared/{useValueChanged-CrzfD8l-.js → useValueChanged-DKq5cMot.js} +13 -13
- package/dist/shared/{websocket-manager-BFKa95TO.js → websocket-manager-CvgZSo_L.js} +2 -2
- package/dist/solid.es.js +2 -2
- package/dist/svelte.es.js +2 -2
- package/dist/types/core/api-client.d.ts +17 -9
- package/dist/types/core/comment-kit-core.d.ts +4 -2
- package/dist/types/core/types.d.ts +37 -4
- package/dist/vue.es.js +2 -2
- package/docs/api-reference.md +29 -17
- package/package.json +1 -1
- package/dist/shared/ShadowRootContext-CjciYxVN.js +0 -13
- package/dist/shared/annotation-toolbar-CpPKy0oq.js +0 -1094
- package/dist/shared/dist-De294MVF.js +0 -623
|
@@ -31,6 +31,9 @@ var b = "https://api.commentkit.dev/api", te = 3e4, ne = 10485760, re = 10, ie =
|
|
|
31
31
|
auth_failed: "Sign-in failed. Please check your email and try again.",
|
|
32
32
|
otp_cooldown: "A code was sent recently — please wait a minute before requesting another.",
|
|
33
33
|
otp_not_found: "No verification code found. Request a new one.",
|
|
34
|
+
mfa_invalid: "Incorrect authenticator or recovery code. Try again.",
|
|
35
|
+
mfa_expired: "This sign-in attempt expired. Start again with your email.",
|
|
36
|
+
mfa_max_attempts: "Too many incorrect codes. Start again with your email.",
|
|
34
37
|
otp_expired: "That verification code has expired. Request a new one.",
|
|
35
38
|
otp_max_attempts: "Too many incorrect attempts. Request a new code.",
|
|
36
39
|
otp_invalid: "Incorrect verification code. Please try again.",
|
|
@@ -40,7 +43,7 @@ var b = "https://api.commentkit.dev/api", te = 3e4, ne = 10485760, re = 10, ie =
|
|
|
40
43
|
};
|
|
41
44
|
function fe(e, t) {
|
|
42
45
|
let n = {};
|
|
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) => ({
|
|
46
|
+
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.checklistPatch !== void 0 && (n.checklist_patch = e.checklistPatch), e.checklist !== void 0 && (n.checklist = e.checklist.map((e) => ({
|
|
44
47
|
...e,
|
|
45
48
|
id: /^\d+$/.test(e.id) ? Number(e.id) : null
|
|
46
49
|
}))), 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;
|
|
@@ -56,40 +59,40 @@ function me(e) {
|
|
|
56
59
|
if (e.protocol !== "https:" && e.protocol !== "http:") throw Error("unsupported protocol");
|
|
57
60
|
if (e.protocol === "http:" && !pe(e.hostname)) throw Error("insecure protocol");
|
|
58
61
|
} catch {
|
|
59
|
-
throw new
|
|
62
|
+
throw new E("invalid_base_url", "Invalid API base URL", 400);
|
|
60
63
|
}
|
|
61
64
|
return t;
|
|
62
65
|
}
|
|
63
66
|
function S(e) {
|
|
64
67
|
let t = String(e).trim();
|
|
65
|
-
if (!t || a(t)) throw new
|
|
68
|
+
if (!t || a(t)) throw new E("invalid_id", "Invalid identifier", 400);
|
|
66
69
|
return encodeURIComponent(t);
|
|
67
70
|
}
|
|
68
|
-
function
|
|
69
|
-
if (typeof e != "string" || a(e)) throw new
|
|
71
|
+
function C(e) {
|
|
72
|
+
if (typeof e != "string" || a(e)) throw new E("invalid_email", "A valid email address is required", 400);
|
|
70
73
|
let t = e.trim();
|
|
71
|
-
if (!s(t, oe)) throw new
|
|
74
|
+
if (!s(t, oe)) throw new E("invalid_email", "A valid email address is required", 400);
|
|
72
75
|
return t;
|
|
73
76
|
}
|
|
74
|
-
function
|
|
75
|
-
if (a(e)) throw new
|
|
77
|
+
function he(e) {
|
|
78
|
+
if (a(e)) throw new E("invalid_otp", "A valid OTP code is required", 400);
|
|
76
79
|
let t = e.trim();
|
|
77
|
-
if (t.length !== se || /\s/.test(t)) throw new
|
|
80
|
+
if (t.length !== se || /\s/.test(t)) throw new E("invalid_otp", "A valid OTP code is required", 400);
|
|
78
81
|
return t;
|
|
79
82
|
}
|
|
80
|
-
function
|
|
81
|
-
if (a(e)) throw new
|
|
83
|
+
function ge(e) {
|
|
84
|
+
if (a(e)) throw new E("invalid_token", "A valid invite token is required", 400);
|
|
82
85
|
let t = e.trim();
|
|
83
|
-
if (t.length !== 64 || !/^[\w-]+$/.test(t)) throw new
|
|
86
|
+
if (t.length !== 64 || !/^[\w-]+$/.test(t)) throw new E("invalid_token", "A valid invite token is required", 400);
|
|
84
87
|
return t;
|
|
85
88
|
}
|
|
86
|
-
function
|
|
89
|
+
function w(e, t, n = ie) {
|
|
87
90
|
let r = e.trim();
|
|
88
|
-
if (!r) throw new
|
|
89
|
-
if (r.length > n) throw new
|
|
91
|
+
if (!r) throw new E("invalid_content", `${t} cannot be empty`, 400);
|
|
92
|
+
if (r.length > n) throw new E("content_too_long", `${t} exceeds maximum length of ${n} characters`, 400);
|
|
90
93
|
return r;
|
|
91
94
|
}
|
|
92
|
-
function
|
|
95
|
+
function _e(e, t) {
|
|
93
96
|
let n = {};
|
|
94
97
|
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
98
|
if (o(t)) {
|
|
@@ -105,7 +108,7 @@ function ve(e, t) {
|
|
|
105
108
|
}
|
|
106
109
|
return Object.keys(n).length > 0 ? n : void 0;
|
|
107
110
|
}
|
|
108
|
-
var
|
|
111
|
+
var ve = class {
|
|
109
112
|
constructor(e) {
|
|
110
113
|
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;
|
|
111
114
|
}
|
|
@@ -113,10 +116,10 @@ var ye = class {
|
|
|
113
116
|
this.projectId = String(e).trim(), this.channelProjectId = String(t).trim();
|
|
114
117
|
}
|
|
115
118
|
setUserEmail(e) {
|
|
116
|
-
this.userEmail = e ?
|
|
119
|
+
this.userEmail = e ? C(e) : null;
|
|
117
120
|
}
|
|
118
121
|
setAuthToken(e) {
|
|
119
|
-
if (e && (a(e) || e.length > ce)) throw new
|
|
122
|
+
if (e && (a(e) || e.length > ce)) throw new E("invalid_token", "A valid auth token is required", 400);
|
|
120
123
|
let t = e?.trim() || null;
|
|
121
124
|
this.authToken = t, this.authRevision++;
|
|
122
125
|
}
|
|
@@ -127,7 +130,7 @@ var ye = class {
|
|
|
127
130
|
this.onAuthExpired = e;
|
|
128
131
|
}
|
|
129
132
|
buildHeaders(e) {
|
|
130
|
-
if (typeof this.apiKey != "string" || a(this.apiKey)) throw new
|
|
133
|
+
if (typeof this.apiKey != "string" || a(this.apiKey)) throw new E("invalid_api_key", "Authentication failed. Please check your API key.", 401);
|
|
131
134
|
return {
|
|
132
135
|
"X-API-Key": this.apiKey,
|
|
133
136
|
...this.userEmail ? { "X-User-Email": this.userEmail } : {},
|
|
@@ -145,19 +148,19 @@ var ye = class {
|
|
|
145
148
|
referrerPolicy: "no-referrer",
|
|
146
149
|
signal: c.signal
|
|
147
150
|
});
|
|
148
|
-
if (s.type === "opaqueredirect" || s.status >= 300 && s.status < 400) throw new
|
|
151
|
+
if (s.type === "opaqueredirect" || s.status >= 300 && s.status < 400) throw new E("unexpected_redirect", "The API endpoint redirected. Check the configured API URL before retrying.", 400);
|
|
149
152
|
let l = await this.parseResponseBody(s);
|
|
150
153
|
if (!s.ok) {
|
|
151
154
|
s.status === 401 && a && i === this.authRevision && (this.setAuthToken(null), this.onAuthExpired?.());
|
|
152
155
|
let e = o(l) ? l : {}, t = typeof e.error == "string" ? e.error : s.status === 403 ? "unauthorized" : n;
|
|
153
|
-
throw new
|
|
156
|
+
throw new E(t, x[t] ?? r, s.status, _e(e.details, e.quota));
|
|
154
157
|
}
|
|
155
158
|
return l;
|
|
156
159
|
} catch (e) {
|
|
157
|
-
if (e instanceof
|
|
158
|
-
if (e instanceof DOMException && e.name === "AbortError") throw new
|
|
159
|
-
if (e instanceof TypeError) throw new
|
|
160
|
-
let t = new
|
|
160
|
+
if (e instanceof E) throw e;
|
|
161
|
+
if (e instanceof DOMException && e.name === "AbortError") throw new E("timeout", "Request timed out. Please try again.", 408);
|
|
162
|
+
if (e instanceof TypeError) throw new E("network_error", "Unable to connect to servers. Please check your connection.", 0);
|
|
163
|
+
let t = new E("unknown_error", "An unexpected error occurred", 500);
|
|
161
164
|
throw t.cause = e, t;
|
|
162
165
|
} finally {
|
|
163
166
|
clearTimeout(l), s?.();
|
|
@@ -170,20 +173,20 @@ var ye = class {
|
|
|
170
173
|
let n = await e.text();
|
|
171
174
|
if (!n) return {};
|
|
172
175
|
if (t && !t.toLowerCase().includes("application/json")) {
|
|
173
|
-
if (e.ok) throw new
|
|
176
|
+
if (e.ok) throw new E("invalid_response", "Invalid server response", 502);
|
|
174
177
|
return {};
|
|
175
178
|
}
|
|
176
179
|
try {
|
|
177
180
|
return JSON.parse(n);
|
|
178
181
|
} catch {
|
|
179
|
-
if (e.ok) throw new
|
|
182
|
+
if (e.ok) throw new E("invalid_response", "Invalid server response", 502);
|
|
180
183
|
return {};
|
|
181
184
|
}
|
|
182
185
|
}
|
|
183
186
|
if (typeof e.json == "function") try {
|
|
184
187
|
return await e.json();
|
|
185
188
|
} catch {
|
|
186
|
-
if (e.ok) throw new
|
|
189
|
+
if (e.ok) throw new E("invalid_response", "Invalid server response", 502);
|
|
187
190
|
}
|
|
188
191
|
return {};
|
|
189
192
|
}
|
|
@@ -197,16 +200,16 @@ var ye = class {
|
|
|
197
200
|
headers: r
|
|
198
201
|
}, "request_failed", "An error occurred");
|
|
199
202
|
}
|
|
200
|
-
async requestFormData(e, t) {
|
|
201
|
-
let
|
|
202
|
-
return this.executeRequest(
|
|
203
|
+
async requestFormData(e, t, n) {
|
|
204
|
+
let r = `${this.baseUrl}${e}`, i = this.buildHeaders(n);
|
|
205
|
+
return this.executeRequest(r, {
|
|
203
206
|
method: "POST",
|
|
204
|
-
headers:
|
|
207
|
+
headers: i,
|
|
205
208
|
body: t
|
|
206
209
|
}, "upload_failed", "Upload failed");
|
|
207
210
|
}
|
|
208
211
|
requireProjectId() {
|
|
209
|
-
if (!this.projectId) throw new
|
|
212
|
+
if (!this.projectId) throw new E("missing_project_id", "Project ID is required", 400);
|
|
210
213
|
return this.projectId;
|
|
211
214
|
}
|
|
212
215
|
async validateApiKey() {
|
|
@@ -219,8 +222,8 @@ var ye = class {
|
|
|
219
222
|
return this.request("/auth/me");
|
|
220
223
|
}
|
|
221
224
|
async authorizeChannel(e, t) {
|
|
222
|
-
if (!this.authToken) throw new
|
|
223
|
-
if (!/^\d+\.\d+$/.test(e) || a(e) || e.length > 128 || !this.channelProjectId || t !== `presence-project.${this.channelProjectId}`) throw new
|
|
225
|
+
if (!this.authToken) throw new E("unauthorized", x.unauthorized, 401);
|
|
226
|
+
if (!/^\d+\.\d+$/.test(e) || a(e) || e.length > 128 || !this.channelProjectId || t !== `presence-project.${this.channelProjectId}`) throw new E("invalid_channel", "Invalid realtime channel request.", 400);
|
|
224
227
|
let n = this.authRevision, r = await this.request("/broadcasting/auth", {
|
|
225
228
|
method: "POST",
|
|
226
229
|
body: JSON.stringify({
|
|
@@ -228,29 +231,29 @@ var ye = class {
|
|
|
228
231
|
channel_name: t
|
|
229
232
|
})
|
|
230
233
|
});
|
|
231
|
-
if (n !== this.authRevision) throw new
|
|
232
|
-
if (!o(r) || typeof r.auth != "string" || !r.auth || typeof r.channel_data != "string") throw new
|
|
234
|
+
if (n !== this.authRevision) throw new E("unauthorized", x.unauthorized, 401);
|
|
235
|
+
if (!o(r) || typeof r.auth != "string" || !r.auth || typeof r.channel_data != "string") throw new E("invalid_response", x.invalid_response, 502);
|
|
233
236
|
let i;
|
|
234
237
|
try {
|
|
235
238
|
i = JSON.parse(r.channel_data);
|
|
236
239
|
} catch {
|
|
237
|
-
throw new
|
|
240
|
+
throw new E("invalid_response", x.invalid_response, 502);
|
|
238
241
|
}
|
|
239
|
-
if (!o(i) || !i.user_id) throw new
|
|
242
|
+
if (!o(i) || !i.user_id) throw new E("invalid_response", x.invalid_response, 502);
|
|
240
243
|
return {
|
|
241
244
|
auth: r.auth,
|
|
242
245
|
channel_data: r.channel_data
|
|
243
246
|
};
|
|
244
247
|
}
|
|
245
248
|
async requestOtp(e) {
|
|
246
|
-
let t =
|
|
249
|
+
let t = C(e);
|
|
247
250
|
return this.request("/auth/otp/request", {
|
|
248
251
|
method: "POST",
|
|
249
252
|
body: JSON.stringify({ email: t })
|
|
250
253
|
});
|
|
251
254
|
}
|
|
252
255
|
async verifyOtp(e, t) {
|
|
253
|
-
let n =
|
|
256
|
+
let n = C(e), r = he(t);
|
|
254
257
|
return this.request("/auth/otp/verify", {
|
|
255
258
|
method: "POST",
|
|
256
259
|
body: JSON.stringify({
|
|
@@ -259,8 +262,18 @@ var ye = class {
|
|
|
259
262
|
})
|
|
260
263
|
});
|
|
261
264
|
}
|
|
265
|
+
async verifyMfa(e, t) {
|
|
266
|
+
if (typeof e != "string" || !/^[0-9]+\|[A-Za-z0-9]{64}$/.test(e) || typeof t != "string" || t.trim().length < 6 || t.trim().length > 100 || a(t)) throw new E("mfa_invalid", "A valid authenticator or recovery code is required.", 400);
|
|
267
|
+
return this.request("/auth/mfa/verify", {
|
|
268
|
+
method: "POST",
|
|
269
|
+
body: JSON.stringify({
|
|
270
|
+
challenge: e,
|
|
271
|
+
code: t.trim()
|
|
272
|
+
})
|
|
273
|
+
});
|
|
274
|
+
}
|
|
262
275
|
async validateInvite(e, t) {
|
|
263
|
-
let n =
|
|
276
|
+
let n = ge(e), r = C(t);
|
|
264
277
|
return this.request("/auth/validate-invite", {
|
|
265
278
|
method: "POST",
|
|
266
279
|
body: JSON.stringify({
|
|
@@ -269,31 +282,33 @@ var ye = class {
|
|
|
269
282
|
})
|
|
270
283
|
});
|
|
271
284
|
}
|
|
272
|
-
async getComments(e, t = "all", n = 1, r = 50, i, a) {
|
|
273
|
-
let
|
|
274
|
-
e &&
|
|
275
|
-
let
|
|
276
|
-
|
|
277
|
-
let
|
|
285
|
+
async getComments(e, t = "all", n = 1, r = 50, i, a, o) {
|
|
286
|
+
let s = this.requireProjectId(), c = new URLSearchParams();
|
|
287
|
+
e && c.append("page_path", e), t !== "all" && c.append("status", t), i && c.append("environment", i), a && c.append("branch", a);
|
|
288
|
+
let l = Number.isFinite(n) ? Math.max(1, Math.floor(n)) : 1, u = Number.isFinite(r) ? Math.min(100, Math.max(1, Math.floor(r))) : 50;
|
|
289
|
+
c.append("page", String(l)), c.append("limit", String(u)), o?.pagination && c.set("pagination", o.pagination), o?.view && c.set("view", o.view), o?.cursor && c.set("cursor", o.cursor), o?.search?.trim() && c.set("search", o.search.trim().slice(0, 200)), o?.priority && o.priority !== "all" && c.set("priority", o.priority), o?.user && c.set("user", o.user), o?.assignee && o.assignee !== "all" && c.set("assignee", o.assignee), o?.sort && c.set("sort", o.sort), o?.excludeComplete && c.set("exclude_complete", "1");
|
|
290
|
+
let d = c.toString(), f = `/projects/${S(s)}/comments${d ? `?${d}` : ""}`, p = await this.request(f), m = p.comments ?? [];
|
|
278
291
|
return {
|
|
279
|
-
comments:
|
|
280
|
-
pagination:
|
|
281
|
-
total:
|
|
282
|
-
hasMore:
|
|
283
|
-
page:
|
|
284
|
-
limit:
|
|
292
|
+
comments: m,
|
|
293
|
+
pagination: p.pagination ?? {
|
|
294
|
+
total: m.length,
|
|
295
|
+
hasMore: m.length >= u,
|
|
296
|
+
page: l,
|
|
297
|
+
limit: u
|
|
285
298
|
}
|
|
286
299
|
};
|
|
287
300
|
}
|
|
288
|
-
async getComment(e) {
|
|
289
|
-
let
|
|
290
|
-
|
|
301
|
+
async getComment(e, t) {
|
|
302
|
+
let n = this.requireProjectId(), r = new URLSearchParams();
|
|
303
|
+
t?.repliesLimit && r.set("replies_limit", String(Math.min(100, Math.max(1, Math.floor(t.repliesLimit))))), t?.repliesBefore && r.set("replies_before", t.repliesBefore);
|
|
304
|
+
let i = r.size ? `?${r}` : "";
|
|
305
|
+
return (await this.request(`/projects/${S(n)}/comments/${S(e)}${i}`)).comment;
|
|
291
306
|
}
|
|
292
307
|
idempotencyHeaders(e) {
|
|
293
308
|
return typeof e == "string" && e.length > 0 && e.length <= 256 && !a(e) ? { "Idempotency-Key": e } : {};
|
|
294
309
|
}
|
|
295
310
|
async createComment(e, t, n, r, i = "medium", a, o, s, c) {
|
|
296
|
-
let l =
|
|
311
|
+
let l = w(t, "Comment content"), u = this.requireProjectId(), d = s?.mentions ?? T(l);
|
|
297
312
|
return (await this.request(`/projects/${S(u)}/comments`, {
|
|
298
313
|
method: "POST",
|
|
299
314
|
headers: this.idempotencyHeaders(c),
|
|
@@ -320,7 +335,7 @@ var ye = class {
|
|
|
320
335
|
})).comment;
|
|
321
336
|
}
|
|
322
337
|
async updateComment(e, t) {
|
|
323
|
-
let n = this.requireProjectId(), r = t.content === void 0 ? void 0 :
|
|
338
|
+
let n = this.requireProjectId(), r = t.content === void 0 ? void 0 : w(t.content, "Comment content"), i = t.mentions ?? (r ? T(r) : void 0), a = fe({
|
|
324
339
|
...t,
|
|
325
340
|
...r === void 0 ? {} : { content: r }
|
|
326
341
|
}, i);
|
|
@@ -334,7 +349,7 @@ var ye = class {
|
|
|
334
349
|
await this.request(`/projects/${S(t)}/comments/${S(e)}`, { method: "DELETE" });
|
|
335
350
|
}
|
|
336
351
|
async addReply(e, t, n, r) {
|
|
337
|
-
let i = this.requireProjectId(), a =
|
|
352
|
+
let i = this.requireProjectId(), a = w(t, "Reply content", ae), o = r?.mentions ?? T(a);
|
|
338
353
|
return (await this.request(`/projects/${S(i)}/comments/${S(e)}/replies`, {
|
|
339
354
|
method: "POST",
|
|
340
355
|
headers: this.idempotencyHeaders(n),
|
|
@@ -347,7 +362,7 @@ var ye = class {
|
|
|
347
362
|
})).reply;
|
|
348
363
|
}
|
|
349
364
|
async updateReply(e, t, n, r) {
|
|
350
|
-
let i = this.requireProjectId(), a =
|
|
365
|
+
let i = this.requireProjectId(), a = w(n, "Reply content", ae);
|
|
351
366
|
return (await this.request(`/projects/${S(i)}/comments/${S(e)}/replies/${S(t)}`, {
|
|
352
367
|
method: "PUT",
|
|
353
368
|
body: JSON.stringify({
|
|
@@ -411,15 +426,15 @@ var ye = class {
|
|
|
411
426
|
return this.createComment("drawing", e, n, r, "medium", void 0, t, a, i);
|
|
412
427
|
}
|
|
413
428
|
validateFile(e, t = !1) {
|
|
414
|
-
if (e.size > ne) throw new
|
|
415
|
-
if (a(e.name) || e.name.includes("/") || e.name.includes("\\")) throw new
|
|
429
|
+
if (e.size > ne) throw new E("file_too_large", `File size (${Math.round(e.size / 1024 / 1024)}MB) exceeds maximum of ${ne / 1024 / 1024}MB`, 400);
|
|
430
|
+
if (a(e.name) || e.name.includes("/") || e.name.includes("\\")) throw new E("invalid_filename", "Filename contains invalid characters", 400);
|
|
416
431
|
if (t) {
|
|
417
432
|
/* v8 ignore next -- pop() always returns a value since file has a name */
|
|
418
433
|
let t = "." + (e.name.split(".").pop()?.toLowerCase() ?? "");
|
|
419
|
-
if ((e.name.match(/\./g) || []).length > 1) throw new
|
|
420
|
-
if (!ue.includes(e.type) || !le.includes(t)) throw new
|
|
434
|
+
if ((e.name.match(/\./g) || []).length > 1) throw new E("invalid_filename", "Filenames with multiple extensions are not allowed", 400);
|
|
435
|
+
if (!ue.includes(e.type) || !le.includes(t)) throw new E("invalid_file_type", `Only image files are allowed (${le.join(", ")})`, 400);
|
|
421
436
|
}
|
|
422
|
-
if (u(e.name)) throw new
|
|
437
|
+
if (u(e.name)) throw new E("invalid_file_type", "This file type is not allowed", 400);
|
|
423
438
|
}
|
|
424
439
|
async uploadFile(e, t, n) {
|
|
425
440
|
this.validateFile(e, t === "screenshot" || t === "drawing");
|
|
@@ -438,12 +453,12 @@ var ye = class {
|
|
|
438
453
|
}
|
|
439
454
|
async uploadScreenshot(e, t) {
|
|
440
455
|
this.validateFile(e, !0);
|
|
441
|
-
let n =
|
|
456
|
+
let n = w(t.content, "Screenshot comment"), r = this.requireProjectId(), i = new FormData();
|
|
442
457
|
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));
|
|
443
|
-
return (await this.requestFormData(`/projects/${S(r)}/screenshots`, i)).comment;
|
|
458
|
+
return (await this.requestFormData(`/projects/${S(r)}/screenshots`, i, this.idempotencyHeaders(t.idempotencyKey))).comment;
|
|
444
459
|
}
|
|
445
460
|
async uploadFiles(e, t) {
|
|
446
|
-
if (e.length > re) throw new
|
|
461
|
+
if (e.length > re) throw new E("too_many_files", `Cannot upload more than ${re} files at once`, 400);
|
|
447
462
|
let n = await Promise.allSettled(e.map((e) => {
|
|
448
463
|
/* v8 ignore next -- pop() always returns a value since file has a name */
|
|
449
464
|
let n = "." + (e.name.split(".").pop()?.toLowerCase() ?? ""), r = ue.includes(e.type) && le.includes(n);
|
|
@@ -451,10 +466,10 @@ var ye = class {
|
|
|
451
466
|
})), r = n.filter((e) => e.status === "fulfilled").map((e) => e.value.id), i = n.find((e) => e.status === "rejected");
|
|
452
467
|
if (i) {
|
|
453
468
|
let e = i.reason;
|
|
454
|
-
throw e instanceof
|
|
469
|
+
throw e instanceof E ? new E(e.error, e.message, e.code, {
|
|
455
470
|
...e.details,
|
|
456
471
|
uploadedIds: r
|
|
457
|
-
}) : new
|
|
472
|
+
}) : new E("upload_failed", "Upload failed", 0, { uploadedIds: r });
|
|
458
473
|
}
|
|
459
474
|
return r;
|
|
460
475
|
}
|
|
@@ -467,7 +482,7 @@ var ye = class {
|
|
|
467
482
|
return (await this.request(`/projects/${S(e)}/members`)).members ?? [];
|
|
468
483
|
}
|
|
469
484
|
};
|
|
470
|
-
function
|
|
485
|
+
function T(e) {
|
|
471
486
|
let t = [], n;
|
|
472
487
|
for (de.lastIndex = 0; (n = de.exec(e)) !== null;) {
|
|
473
488
|
let e = n[1]?.trim(), r = n[2]?.trim();
|
|
@@ -479,13 +494,13 @@ function w(e) {
|
|
|
479
494
|
}
|
|
480
495
|
return t;
|
|
481
496
|
}
|
|
482
|
-
function
|
|
497
|
+
function ye(e) {
|
|
483
498
|
return `@[${e.name.replace(/\]/g, "")}](${e.id.replace(/\)/g, "")})`;
|
|
484
499
|
}
|
|
485
|
-
function
|
|
500
|
+
function be(e) {
|
|
486
501
|
return e.replace(de, "@$1");
|
|
487
502
|
}
|
|
488
|
-
var
|
|
503
|
+
var E = class extends Error {
|
|
489
504
|
constructor(e, t, n, r) {
|
|
490
505
|
super(t), this.name = "ApiClientError", this.error = e, this.code = n, this.details = r;
|
|
491
506
|
}
|
|
@@ -501,16 +516,16 @@ var T = class extends Error {
|
|
|
501
516
|
isPremiumFeatureError() {
|
|
502
517
|
return this.code === 402;
|
|
503
518
|
}
|
|
504
|
-
},
|
|
519
|
+
}, xe = null, Se = 0, Ce = 3;
|
|
505
520
|
function we() {
|
|
506
|
-
return
|
|
521
|
+
return xe || (xe = (async () => {
|
|
507
522
|
try {
|
|
508
523
|
let e = await import("element-source");
|
|
509
524
|
return typeof e?.resolveElementInfo == "function" ? e : null;
|
|
510
525
|
} catch {
|
|
511
|
-
return Se += 1, Se < Ce && (
|
|
526
|
+
return Se += 1, Se < Ce && (xe = null), null;
|
|
512
527
|
}
|
|
513
|
-
})(),
|
|
528
|
+
})(), xe);
|
|
514
529
|
}
|
|
515
530
|
async function Te(e) {
|
|
516
531
|
let t = await we();
|
|
@@ -633,6 +648,7 @@ function Ve(e, t, n) {
|
|
|
633
648
|
attachments: r,
|
|
634
649
|
element: Re(e.position, t.includeHtml === !0, Fe(e, n)),
|
|
635
650
|
...i ? { screenshotUrl: i } : {},
|
|
651
|
+
repliesCount: e.repliesCount ?? e.replies.length,
|
|
636
652
|
replies: e.replies.map(ze)
|
|
637
653
|
};
|
|
638
654
|
}
|
|
@@ -779,8 +795,8 @@ function We(e) {
|
|
|
779
795
|
done: t
|
|
780
796
|
})) } : {},
|
|
781
797
|
...e.attachments?.length ? { attachments: e.attachments.map(D) } : {},
|
|
782
|
-
replyCount: e.replies.length,
|
|
783
|
-
...e.replies.length > 12 ? { omittedReplies: e.replies.length - 12 } : {},
|
|
798
|
+
replyCount: e.repliesCount ?? e.replies.length,
|
|
799
|
+
...(e.repliesCount ?? e.replies.length) > Math.min(12, e.replies.length) ? { omittedReplies: (e.repliesCount ?? e.replies.length) - Math.min(12, e.replies.length) } : {},
|
|
784
800
|
replies: e.replies.slice(-12).map((e) => ({
|
|
785
801
|
id: e.id,
|
|
786
802
|
content: n(e.content),
|
|
@@ -1019,14 +1035,16 @@ async function xt(e, t, n = () => !0) {
|
|
|
1019
1035
|
if (!r) e.setState({
|
|
1020
1036
|
isLoading: !1,
|
|
1021
1037
|
otpStep: "idle",
|
|
1022
|
-
otpEmail: null
|
|
1038
|
+
otpEmail: null,
|
|
1039
|
+
otpMfaChallenge: null
|
|
1023
1040
|
}), e.handleError(N("invalid_email", "A valid email address is required", 400));
|
|
1024
1041
|
else try {
|
|
1025
1042
|
e.setState({
|
|
1026
1043
|
isLoading: !0,
|
|
1027
1044
|
error: null,
|
|
1028
1045
|
otpStep: "requesting",
|
|
1029
|
-
otpEmail: r
|
|
1046
|
+
otpEmail: r,
|
|
1047
|
+
otpMfaChallenge: null
|
|
1030
1048
|
});
|
|
1031
1049
|
let t = await e.apiClient.requestOtp(r);
|
|
1032
1050
|
if (!n()) return;
|
|
@@ -1039,28 +1057,43 @@ async function xt(e, t, n = () => !0) {
|
|
|
1039
1057
|
})) : (e.setState({
|
|
1040
1058
|
isLoading: !1,
|
|
1041
1059
|
otpStep: "idle",
|
|
1042
|
-
otpEmail: null
|
|
1060
|
+
otpEmail: null,
|
|
1061
|
+
otpMfaChallenge: null
|
|
1043
1062
|
}), e.handleError(N("otp_failed", "Failed to send OTP. Please try again.", 500)));
|
|
1044
1063
|
} catch (t) {
|
|
1045
1064
|
if (!n()) return;
|
|
1046
1065
|
e.setState({
|
|
1047
1066
|
isLoading: !1,
|
|
1048
1067
|
otpStep: "idle",
|
|
1049
|
-
otpEmail: null
|
|
1068
|
+
otpEmail: null,
|
|
1069
|
+
otpMfaChallenge: null
|
|
1050
1070
|
}), e.handleError(t);
|
|
1051
1071
|
}
|
|
1052
1072
|
}
|
|
1053
1073
|
async function St(e, t, n) {
|
|
1054
|
-
let { onAuthenticated: i, onWrongOtp:
|
|
1055
|
-
if (!
|
|
1056
|
-
|
|
1074
|
+
let { onAuthenticated: i, onWrongOtp: o, onSuccess: s, isCurrent: c = () => !0 } = typeof n == "function" ? { onAuthenticated: n } : n, { otpEmail: l, otpMfaChallenge: u, otpStep: d } = e.getState();
|
|
1075
|
+
if (!l) {
|
|
1076
|
+
e.handleError(N("no_email", "No OTP request in progress", 400));
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
let f = d === "mfa";
|
|
1080
|
+
if (!(f ? typeof t == "string" && !a(t) && t.trim().length >= 6 && t.trim().length <= 100 : vt(t)) || f && !u) e.setState({ isLoading: !1 }), e.handleError(N("invalid_otp", "Invalid or expired OTP code", 401));
|
|
1057
1081
|
else try {
|
|
1058
1082
|
e.setState({
|
|
1059
1083
|
isLoading: !0,
|
|
1060
1084
|
error: null
|
|
1061
1085
|
});
|
|
1062
|
-
let n = await e.apiClient.verifyOtp(
|
|
1063
|
-
if (!
|
|
1086
|
+
let n = f && u ? await e.apiClient.verifyMfa(u, t.trim()) : await e.apiClient.verifyOtp(l, t);
|
|
1087
|
+
if (!c()) return;
|
|
1088
|
+
if (!f && n.success && n.verified === !1 && n.mfaRequired === !0 && typeof n.challenge == "string" && /^[0-9]+\|[A-Za-z0-9]{64}$/.test(n.challenge)) {
|
|
1089
|
+
e.setState({
|
|
1090
|
+
otpStep: "mfa",
|
|
1091
|
+
otpMfaChallenge: n.challenge,
|
|
1092
|
+
isLoading: !1,
|
|
1093
|
+
error: null
|
|
1094
|
+
});
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1064
1097
|
if (n.verified && r(n.token, ht) && yt(n.user) && bt(n.project)) {
|
|
1065
1098
|
if (e.apiClient.setAuthToken(n.token), e.apiClient.setUserEmail(n.user.email), e.config.persistence !== "memory" && ct(e.config.projectId, {
|
|
1066
1099
|
token: n.token,
|
|
@@ -1074,12 +1107,13 @@ async function St(e, t, n) {
|
|
|
1074
1107
|
isOverlayVisible: !0,
|
|
1075
1108
|
isLoading: !1,
|
|
1076
1109
|
otpStep: "idle",
|
|
1077
|
-
otpEmail: null
|
|
1078
|
-
|
|
1110
|
+
otpEmail: null,
|
|
1111
|
+
otpMfaChallenge: null
|
|
1112
|
+
}), s?.(), e.emit("auth:otp-verified", n.user), !c() || (e.emit("auth:login", n.user), !c())) return;
|
|
1079
1113
|
await i();
|
|
1080
|
-
} else e.setState({ isLoading: !1 }),
|
|
1114
|
+
} else e.setState({ isLoading: !1 }), o?.(), e.handleError(N("invalid_otp", "Invalid or expired OTP code", 401));
|
|
1081
1115
|
} catch (t) {
|
|
1082
|
-
if (!
|
|
1116
|
+
if (!c()) return;
|
|
1083
1117
|
e.setState({ isLoading: !1 }), e.handleError(t);
|
|
1084
1118
|
}
|
|
1085
1119
|
}
|
|
@@ -1087,6 +1121,7 @@ function Ct(e) {
|
|
|
1087
1121
|
e.setState({
|
|
1088
1122
|
otpStep: "idle",
|
|
1089
1123
|
otpEmail: null,
|
|
1124
|
+
otpMfaChallenge: null,
|
|
1090
1125
|
error: null,
|
|
1091
1126
|
isLoading: !1
|
|
1092
1127
|
});
|
|
@@ -1114,6 +1149,7 @@ function Tt(e, t) {
|
|
|
1114
1149
|
isSidebarVisible: !1,
|
|
1115
1150
|
otpStep: "idle",
|
|
1116
1151
|
otpEmail: null,
|
|
1152
|
+
otpMfaChallenge: null,
|
|
1117
1153
|
pagination: null,
|
|
1118
1154
|
pendingMutations: [],
|
|
1119
1155
|
activities: [],
|
|
@@ -1140,6 +1176,9 @@ function Et(e) {
|
|
|
1140
1176
|
panelView: "list",
|
|
1141
1177
|
connectionStatus: "disconnected",
|
|
1142
1178
|
isLoginModalVisible: !0,
|
|
1179
|
+
otpStep: "idle",
|
|
1180
|
+
otpEmail: null,
|
|
1181
|
+
otpMfaChallenge: null,
|
|
1143
1182
|
error: "Your session has expired. Please sign in again.",
|
|
1144
1183
|
isLoading: !1
|
|
1145
1184
|
}), e.emit("error", {
|
|
@@ -1183,7 +1222,8 @@ var kt = Object.freeze({
|
|
|
1183
1222
|
"projectContext",
|
|
1184
1223
|
"isLoginModalVisible",
|
|
1185
1224
|
"otpStep",
|
|
1186
|
-
"otpEmail"
|
|
1225
|
+
"otpEmail",
|
|
1226
|
+
"otpMfaChallenge"
|
|
1187
1227
|
]),
|
|
1188
1228
|
ui: P([
|
|
1189
1229
|
"isOverlayVisible",
|
|
@@ -1207,7 +1247,9 @@ var kt = Object.freeze({
|
|
|
1207
1247
|
"comments",
|
|
1208
1248
|
"pagination",
|
|
1209
1249
|
"seenThreadIds",
|
|
1210
|
-
"activeBranch"
|
|
1250
|
+
"activeBranch",
|
|
1251
|
+
"commentQuery",
|
|
1252
|
+
"loadingThreadId"
|
|
1211
1253
|
]),
|
|
1212
1254
|
realtime: P([
|
|
1213
1255
|
"onlineUsers",
|
|
@@ -1236,6 +1278,8 @@ function Mt() {
|
|
|
1236
1278
|
projectContext: null,
|
|
1237
1279
|
activeBranch: null,
|
|
1238
1280
|
comments: [],
|
|
1281
|
+
commentQuery: void 0,
|
|
1282
|
+
loadingThreadId: null,
|
|
1239
1283
|
activeTool: null,
|
|
1240
1284
|
selectedComment: null,
|
|
1241
1285
|
activeComment: null,
|
|
@@ -1250,6 +1294,7 @@ function Mt() {
|
|
|
1250
1294
|
error: null,
|
|
1251
1295
|
otpStep: "idle",
|
|
1252
1296
|
otpEmail: null,
|
|
1297
|
+
otpMfaChallenge: null,
|
|
1253
1298
|
pagination: null,
|
|
1254
1299
|
pendingMutations: [],
|
|
1255
1300
|
isOnline: At()
|
|
@@ -1280,7 +1325,7 @@ var I = j.ID, Nt = j.CONTENT, Pt = j.REPLY_CONTENT, Ft = j.SELECTOR, It = j.TEXT
|
|
|
1280
1325
|
"text"
|
|
1281
1326
|
]);
|
|
1282
1327
|
function L(e, t, n) {
|
|
1283
|
-
e.handleError(new
|
|
1328
|
+
e.handleError(new E(t, n, 400));
|
|
1284
1329
|
}
|
|
1285
1330
|
function R(e) {
|
|
1286
1331
|
return r(e, I);
|
|
@@ -1445,6 +1490,14 @@ function on(e) {
|
|
|
1445
1490
|
if (n === null) return null;
|
|
1446
1491
|
t.assignees = n;
|
|
1447
1492
|
}
|
|
1493
|
+
if ("checklistPatch" in e) {
|
|
1494
|
+
let n = e.checklistPatch;
|
|
1495
|
+
if ("checklist" in e || !o(n) || !R(n.id) || typeof n.done != "boolean") return null;
|
|
1496
|
+
t.checklistPatch = {
|
|
1497
|
+
id: n.id,
|
|
1498
|
+
done: n.done
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1448
1501
|
if ("checklist" in e) {
|
|
1449
1502
|
let n = $t(e.checklist);
|
|
1450
1503
|
if (n === null) return null;
|
|
@@ -1506,14 +1559,24 @@ function cn(e, t, n) {
|
|
|
1506
1559
|
return e.getState().comments.some((e) => e.id === t && e.replies.some((e) => e.id === n));
|
|
1507
1560
|
}
|
|
1508
1561
|
async function ln(e) {
|
|
1509
|
-
let t = e.getState().activeBranch;
|
|
1562
|
+
let t = e.getState().activeBranch, n = e.getState().commentQuery;
|
|
1510
1563
|
e.setState({ isLoading: !0 });
|
|
1511
1564
|
try {
|
|
1512
|
-
let
|
|
1513
|
-
|
|
1565
|
+
let r = await e.apiClient.getComments(n?.pagePath, n?.status ?? "all", 1, 50, void 0, t, {
|
|
1566
|
+
...n,
|
|
1567
|
+
pagination: "cursor",
|
|
1568
|
+
view: "summary"
|
|
1569
|
+
});
|
|
1570
|
+
if (t !== e.getState().activeBranch || e.isCurrent?.() === !1) return;
|
|
1571
|
+
let i = e.getState().selectedComment?.id, a = i && r.comments.find((e) => e.id === i);
|
|
1572
|
+
if (a && a.detailLoaded === !1) {
|
|
1573
|
+
let n = await e.apiClient.getComment(a.id, { repliesLimit: 50 });
|
|
1574
|
+
if (e.isCurrent?.() === !1 || t !== e.getState().activeBranch) return;
|
|
1575
|
+
r.comments = r.comments.map((e) => e.id === n.id ? n : e);
|
|
1576
|
+
}
|
|
1514
1577
|
e.setState({
|
|
1515
|
-
comments:
|
|
1516
|
-
pagination:
|
|
1578
|
+
comments: r.comments,
|
|
1579
|
+
pagination: r.pagination
|
|
1517
1580
|
});
|
|
1518
1581
|
} catch (t) {
|
|
1519
1582
|
e.handleError(t);
|
|
@@ -1522,16 +1585,21 @@ async function ln(e) {
|
|
|
1522
1585
|
}
|
|
1523
1586
|
}
|
|
1524
1587
|
async function un(e, t) {
|
|
1525
|
-
let n = e.getState().activeBranch, r = e.getState().pagination;
|
|
1588
|
+
let n = e.getState().activeBranch, r = e.getState().pagination, i = e.getState().commentQuery;
|
|
1526
1589
|
if (r && r.hasMore && !t.current) {
|
|
1527
1590
|
t.current = !0;
|
|
1528
1591
|
try {
|
|
1529
1592
|
e.setState({ isLoading: !0 });
|
|
1530
|
-
let t = await e.apiClient.getComments(
|
|
1531
|
-
|
|
1532
|
-
|
|
1593
|
+
let t = await e.apiClient.getComments(i?.pagePath, i?.status ?? "all", r.page + 1, r.limit, void 0, n, {
|
|
1594
|
+
...i,
|
|
1595
|
+
pagination: "cursor",
|
|
1596
|
+
view: "summary",
|
|
1597
|
+
cursor: r.nextCursor
|
|
1598
|
+
});
|
|
1599
|
+
if (n !== e.getState().activeBranch || i !== e.getState().commentQuery || e.isCurrent?.() === !1) return;
|
|
1600
|
+
let a = new Set(e.getState().comments.map((e) => e.id)), o = t.comments.filter((e) => !a.has(e.id));
|
|
1533
1601
|
e.setState({
|
|
1534
|
-
comments: [...e.getState().comments, ...
|
|
1602
|
+
comments: [...e.getState().comments, ...o],
|
|
1535
1603
|
pagination: t.pagination,
|
|
1536
1604
|
isLoading: !1
|
|
1537
1605
|
});
|
|
@@ -1542,7 +1610,38 @@ async function un(e, t) {
|
|
|
1542
1610
|
}
|
|
1543
1611
|
}
|
|
1544
1612
|
}
|
|
1545
|
-
async function dn(e, t, n
|
|
1613
|
+
async function dn(e, t, n) {
|
|
1614
|
+
if (R(t)) {
|
|
1615
|
+
e.setState({ loadingThreadId: t });
|
|
1616
|
+
try {
|
|
1617
|
+
let r = await e.apiClient.getComment(t, {
|
|
1618
|
+
repliesLimit: 50,
|
|
1619
|
+
...n ? { repliesBefore: n } : {}
|
|
1620
|
+
});
|
|
1621
|
+
if (e.isCurrent?.() === !1 || e.getState().selectedComment?.id !== t) return;
|
|
1622
|
+
let i = e.getState().comments.find((e) => e.id === t), a = n && i ? [...new Map([...r.replies, ...i.replies].map((e) => [e.id, e])).values()] : r.replies, o = n && i ? {
|
|
1623
|
+
...i,
|
|
1624
|
+
detailLoaded: !0,
|
|
1625
|
+
replies: a,
|
|
1626
|
+
repliesPagination: r.repliesPagination,
|
|
1627
|
+
repliesCount: Math.max(i.repliesCount ?? i.replies.length, r.repliesCount ?? r.replies.length)
|
|
1628
|
+
} : {
|
|
1629
|
+
...r,
|
|
1630
|
+
detailLoaded: !0,
|
|
1631
|
+
replies: a
|
|
1632
|
+
};
|
|
1633
|
+
e.setState({
|
|
1634
|
+
comments: e.getState().comments.map((e) => e.id === t ? o : e),
|
|
1635
|
+
selectedComment: o
|
|
1636
|
+
});
|
|
1637
|
+
} catch (t) {
|
|
1638
|
+
e.handleError(t);
|
|
1639
|
+
} finally {
|
|
1640
|
+
e.getState().loadingThreadId === t && e.setState({ loadingThreadId: null });
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
async function fn(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
1546
1645
|
let u = e.getState().currentUser;
|
|
1547
1646
|
if (!u) return;
|
|
1548
1647
|
let d = z(i), f = Xt(a), p = en(s), h = nn(c), g = an(l);
|
|
@@ -1656,7 +1755,7 @@ async function dn(e, t, n, r, i, a, o = "medium", s, c, l) {
|
|
|
1656
1755
|
n.delete(_);
|
|
1657
1756
|
}
|
|
1658
1757
|
}
|
|
1659
|
-
async function
|
|
1758
|
+
async function pn(e, t, n, r) {
|
|
1660
1759
|
if (!R(n)) return;
|
|
1661
1760
|
let i = on(r);
|
|
1662
1761
|
if (i === null) {
|
|
@@ -1665,20 +1764,24 @@ async function fn(e, t, n, r) {
|
|
|
1665
1764
|
}
|
|
1666
1765
|
if (i === void 0) return;
|
|
1667
1766
|
let a = e.getState().comments, o = a.find((e) => e.id === n);
|
|
1668
|
-
if (o)
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
|
|
1767
|
+
if (!o) return;
|
|
1768
|
+
let { checklistPatch: s, ...c } = i;
|
|
1769
|
+
e.setState({ comments: a.map((e) => e.id === n ? {
|
|
1770
|
+
...K(e, i.status),
|
|
1771
|
+
...c,
|
|
1772
|
+
...s ? { checklist: e.checklist?.map((e) => e.id === s.id ? {
|
|
1773
|
+
...e,
|
|
1774
|
+
done: s.done
|
|
1775
|
+
} : e) } : {}
|
|
1776
|
+
} : e) });
|
|
1777
|
+
try {
|
|
1778
|
+
let t = await e.apiClient.updateComment(n, i);
|
|
1779
|
+
e.setState({ comments: e.getState().comments.map((e) => e.id === n ? t : e) }), e.emit("comment:updated", t);
|
|
1780
|
+
} catch (r) {
|
|
1781
|
+
t.shouldQueueMutation(r) && t.queueMutation("updateComment", [n, i]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n ? o : e) }), e.handleError(r));
|
|
1679
1782
|
}
|
|
1680
1783
|
}
|
|
1681
|
-
async function
|
|
1784
|
+
async function mn(e, t, n) {
|
|
1682
1785
|
if (!R(n)) return;
|
|
1683
1786
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1684
1787
|
if (!i) return;
|
|
@@ -1699,7 +1802,7 @@ async function pn(e, t, n) {
|
|
|
1699
1802
|
}
|
|
1700
1803
|
}
|
|
1701
1804
|
}
|
|
1702
|
-
async function
|
|
1805
|
+
async function hn(e, t, n, r, i) {
|
|
1703
1806
|
let a = e.getState().currentUser;
|
|
1704
1807
|
if (!a || !R(n) || !W(e, n)) return;
|
|
1705
1808
|
let o = z(r, Pt);
|
|
@@ -1725,6 +1828,7 @@ async function mn(e, t, n, r, i) {
|
|
|
1725
1828
|
};
|
|
1726
1829
|
e.setState({ comments: e.getState().comments.map((e) => e.id === n ? {
|
|
1727
1830
|
...e,
|
|
1831
|
+
repliesCount: (e.repliesCount ?? e.replies.length) + 1,
|
|
1728
1832
|
replies: [...e.replies, u]
|
|
1729
1833
|
} : e) });
|
|
1730
1834
|
try {
|
|
@@ -1738,11 +1842,12 @@ async function mn(e, t, n, r, i) {
|
|
|
1738
1842
|
i
|
|
1739
1843
|
] : [n, o], l) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n ? {
|
|
1740
1844
|
...e,
|
|
1845
|
+
repliesCount: Math.max(0, (e.repliesCount ?? e.replies.length) - 1),
|
|
1741
1846
|
replies: e.replies.filter((e) => e.id !== l)
|
|
1742
1847
|
} : e) }), e.handleError(r));
|
|
1743
1848
|
}
|
|
1744
1849
|
}
|
|
1745
|
-
async function
|
|
1850
|
+
async function gn(e, t, n, r, i) {
|
|
1746
1851
|
if (!R(t) || !R(n) || !cn(e, t, n)) return;
|
|
1747
1852
|
let a = z(r, Pt);
|
|
1748
1853
|
if (!a) {
|
|
@@ -1773,11 +1878,12 @@ async function hn(e, t, n, r, i) {
|
|
|
1773
1878
|
} : e) }), e.handleError(r);
|
|
1774
1879
|
}
|
|
1775
1880
|
}
|
|
1776
|
-
async function
|
|
1881
|
+
async function _n(e, t, n) {
|
|
1777
1882
|
if (!R(t) || !R(n) || !cn(e, t, n)) return;
|
|
1778
1883
|
let r = e.getState().comments, i = r.find((e) => e.id === t)?.replies.find((e) => e.id === n);
|
|
1779
1884
|
e.setState({ comments: r.map((e) => e.id === t ? {
|
|
1780
1885
|
...e,
|
|
1886
|
+
repliesCount: Math.max(0, (e.repliesCount ?? e.replies.length) - 1),
|
|
1781
1887
|
replies: e.replies.filter((e) => e.id !== n)
|
|
1782
1888
|
} : e) });
|
|
1783
1889
|
try {
|
|
@@ -1787,11 +1893,12 @@ async function gn(e, t, n) {
|
|
|
1787
1893
|
} catch (r) {
|
|
1788
1894
|
e.setState({ comments: e.getState().comments.map((e) => e.id === t && i && !e.replies.some((e) => e.id === n) ? {
|
|
1789
1895
|
...e,
|
|
1896
|
+
repliesCount: (e.repliesCount ?? e.replies.length) + 1,
|
|
1790
1897
|
replies: [...e.replies, i]
|
|
1791
1898
|
} : e) }), e.handleError(r);
|
|
1792
1899
|
}
|
|
1793
1900
|
}
|
|
1794
|
-
async function
|
|
1901
|
+
async function vn(e, t, n) {
|
|
1795
1902
|
if (!R(n) || !W(e, n)) return;
|
|
1796
1903
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1797
1904
|
e.setState({ comments: r.map((e) => e.id === n ? K(e, "resolved") : e) });
|
|
@@ -1806,7 +1913,7 @@ async function _n(e, t, n) {
|
|
|
1806
1913
|
t.shouldQueueMutation(r) && t.queueMutation("resolveComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
|
|
1807
1914
|
}
|
|
1808
1915
|
}
|
|
1809
|
-
async function
|
|
1916
|
+
async function yn(e, t, n) {
|
|
1810
1917
|
if (!R(n) || !W(e, n)) return;
|
|
1811
1918
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1812
1919
|
e.setState({ comments: r.map((e) => e.id === n ? K(e, "open") : e) });
|
|
@@ -1817,7 +1924,7 @@ async function vn(e, t, n) {
|
|
|
1817
1924
|
t.shouldQueueMutation(r) && t.queueMutation("unresolveComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
|
|
1818
1925
|
}
|
|
1819
1926
|
}
|
|
1820
|
-
async function
|
|
1927
|
+
async function bn(e, t, n) {
|
|
1821
1928
|
if (!R(n) || !W(e, n)) return;
|
|
1822
1929
|
let r = e.getState().comments, i = r.find((e) => e.id === n);
|
|
1823
1930
|
e.setState({ comments: r.map((e) => e.id === n ? K(e, "complete") : e) });
|
|
@@ -1832,7 +1939,7 @@ async function yn(e, t, n) {
|
|
|
1832
1939
|
t.shouldQueueMutation(r) && t.queueMutation("completeComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
|
|
1833
1940
|
}
|
|
1834
1941
|
}
|
|
1835
|
-
async function
|
|
1942
|
+
async function xn(e, t, n, r, i) {
|
|
1836
1943
|
if (!R(n) || typeof r != "string") return;
|
|
1837
1944
|
let a = r.trim();
|
|
1838
1945
|
if (!a || a.length > Gt || c(a)) return;
|
|
@@ -1897,7 +2004,7 @@ async function bn(e, t, n, r, i) {
|
|
|
1897
2004
|
} : e) }), e.handleError(r));
|
|
1898
2005
|
}
|
|
1899
2006
|
}
|
|
1900
|
-
async function
|
|
2007
|
+
async function Sn(e, t, n, r, i) {
|
|
1901
2008
|
if (!R(n) || !W(e, n)) return;
|
|
1902
2009
|
let a = Xt({
|
|
1903
2010
|
x: r,
|
|
@@ -1925,10 +2032,10 @@ async function xn(e, t, n, r, i) {
|
|
|
1925
2032
|
} : e) }), e.handleError(r));
|
|
1926
2033
|
}
|
|
1927
2034
|
}
|
|
1928
|
-
function
|
|
2035
|
+
function Cn(e, t) {
|
|
1929
2036
|
e.setState({ selectedComment: t });
|
|
1930
2037
|
}
|
|
1931
|
-
async function
|
|
2038
|
+
async function wn(e, t, n, r, i) {
|
|
1932
2039
|
let a = e.getState().currentUser;
|
|
1933
2040
|
if (!a) return;
|
|
1934
2041
|
let o = z(i), s = en(r);
|
|
@@ -1982,7 +2089,7 @@ async function Cn(e, t, n, r, i) {
|
|
|
1982
2089
|
n.delete(c);
|
|
1983
2090
|
}
|
|
1984
2091
|
}
|
|
1985
|
-
async function
|
|
2092
|
+
async function Tn(e, t, n, r, i, a) {
|
|
1986
2093
|
let o = e.getState().currentUser;
|
|
1987
2094
|
if (!o) return;
|
|
1988
2095
|
let s = z(a), c = Xt(i), l = nn(r);
|
|
@@ -2034,21 +2141,21 @@ async function wn(e, t, n, r, i, a) {
|
|
|
2034
2141
|
n.delete(u);
|
|
2035
2142
|
}
|
|
2036
2143
|
}
|
|
2037
|
-
var
|
|
2144
|
+
var En = {
|
|
2038
2145
|
c: "comment",
|
|
2039
2146
|
e: "select",
|
|
2040
2147
|
d: "draw",
|
|
2041
2148
|
h: "highlight",
|
|
2042
2149
|
s: "screenshot"
|
|
2043
2150
|
};
|
|
2044
|
-
function
|
|
2151
|
+
function Dn(e) {
|
|
2045
2152
|
return typeof e.composedPath == "function" ? e.composedPath() : e.target ? [e.target] : [];
|
|
2046
2153
|
}
|
|
2047
|
-
function
|
|
2154
|
+
function q(e) {
|
|
2048
2155
|
return typeof Element < "u" && e instanceof Element;
|
|
2049
2156
|
}
|
|
2050
2157
|
function On(e) {
|
|
2051
|
-
if (!
|
|
2158
|
+
if (!q(e)) return !1;
|
|
2052
2159
|
let t = e.tagName.toLowerCase();
|
|
2053
2160
|
return t === "input" || t === "textarea" || t === "select" || e.isContentEditable || e.getAttribute("role") === "textbox";
|
|
2054
2161
|
}
|
|
@@ -2058,10 +2165,10 @@ function kn(e) {
|
|
|
2058
2165
|
return t;
|
|
2059
2166
|
}
|
|
2060
2167
|
function An(e) {
|
|
2061
|
-
return
|
|
2168
|
+
return Dn(e).some(On) ? !0 : typeof document > "u" ? !1 : On(kn(document));
|
|
2062
2169
|
}
|
|
2063
2170
|
function jn(e) {
|
|
2064
|
-
return
|
|
2171
|
+
return Dn(e).some((e) => q(e) && (e.hasAttribute("data-commentkit") || e.hasAttribute("data-commentkit-ui") || e.hasAttribute("data-commentkit-host")));
|
|
2065
2172
|
}
|
|
2066
2173
|
var Mn = [
|
|
2067
2174
|
"popover",
|
|
@@ -2074,8 +2181,8 @@ var Mn = [
|
|
|
2074
2181
|
"combobox"
|
|
2075
2182
|
].map((e) => `[data-slot="${e}-content"][data-open]`).join(",");
|
|
2076
2183
|
function Nn(e) {
|
|
2077
|
-
let t =
|
|
2078
|
-
if (
|
|
2184
|
+
let t = Dn(e), n = t.find((e) => q(e) && e.hasAttribute("data-commentkit-host"));
|
|
2185
|
+
if (q(n)) return !!n.shadowRoot?.querySelector(Mn);
|
|
2079
2186
|
if (typeof document < "u" && (t[0] === document.body || t[0] === document.documentElement)) {
|
|
2080
2187
|
let e = document.querySelectorAll("[data-commentkit-host]");
|
|
2081
2188
|
return e.length === 1 && !!e[0]?.shadowRoot?.querySelector(Mn);
|
|
@@ -2087,12 +2194,12 @@ function Pn(e) {
|
|
|
2087
2194
|
}
|
|
2088
2195
|
function Fn(e) {
|
|
2089
2196
|
let t = e.key.toLowerCase(), n = e.code.startsWith("Key") ? e.code.slice(3).toLowerCase() : "";
|
|
2090
|
-
return
|
|
2197
|
+
return En[t] ?? En[n] ?? null;
|
|
2091
2198
|
}
|
|
2092
|
-
function
|
|
2199
|
+
function J(e) {
|
|
2093
2200
|
e.preventDefault(), e.stopPropagation();
|
|
2094
2201
|
}
|
|
2095
|
-
function
|
|
2202
|
+
function In(e, t) {
|
|
2096
2203
|
if (e.isLoginModalVisible) t.toggleLoginModal();
|
|
2097
2204
|
else if (e.isShortcutsOverlayVisible) t.toggleShortcutsOverlay();
|
|
2098
2205
|
else if (e.activeComment) t.setState({ activeComment: null });
|
|
@@ -2103,28 +2210,28 @@ function Ln(e, t) {
|
|
|
2103
2210
|
else return !1;
|
|
2104
2211
|
return !0;
|
|
2105
2212
|
}
|
|
2106
|
-
function
|
|
2213
|
+
function Ln(e, t) {
|
|
2107
2214
|
e.isAuthenticated ? t.toggleOverlay() : t.toggleLoginModal();
|
|
2108
2215
|
}
|
|
2109
|
-
function
|
|
2216
|
+
function Rn(e, t, n) {
|
|
2110
2217
|
if (e.defaultPrevented || e.repeat || e.isComposing) return;
|
|
2111
2218
|
let r = An(e), i = jn(e);
|
|
2112
2219
|
if (Pn(e)) {
|
|
2113
2220
|
if (r) return;
|
|
2114
|
-
|
|
2221
|
+
J(e), Ln(t, n);
|
|
2115
2222
|
} else if (e.key === "Escape") {
|
|
2116
2223
|
if (Nn(e) || r && !i) return;
|
|
2117
|
-
|
|
2224
|
+
In(t, n) && J(e);
|
|
2118
2225
|
} else if (t.isAuthenticated && (t.isOverlayVisible || t.activeTool !== null) && !r && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
2119
2226
|
if (e.key === "?") {
|
|
2120
|
-
|
|
2227
|
+
J(e), n.toggleShortcutsOverlay();
|
|
2121
2228
|
return;
|
|
2122
2229
|
}
|
|
2123
2230
|
let r = Fn(e);
|
|
2124
|
-
r && (
|
|
2231
|
+
r && (J(e), n.setTool(t.activeTool === r ? null : r));
|
|
2125
2232
|
}
|
|
2126
2233
|
}
|
|
2127
|
-
var
|
|
2234
|
+
var zn = j.PENDING_MUTATIONS, Bn = j.RETRY_DELAY, Y = j.ID, Vn = j.CONTENT, Hn = j.REPLY_CONTENT, Un = j.SELECTOR, Wn = j.EMOJI, Gn = /* @__PURE__ */ new Set([
|
|
2128
2235
|
"createComment",
|
|
2129
2236
|
"createHighlight",
|
|
2130
2237
|
"createDrawing",
|
|
@@ -2136,42 +2243,42 @@ var Bn = j.PENDING_MUTATIONS, Vn = j.RETRY_DELAY, q = j.ID, Hn = j.CONTENT, Un =
|
|
|
2136
2243
|
"addReply",
|
|
2137
2244
|
"reactToComment",
|
|
2138
2245
|
"updatePosition"
|
|
2139
|
-
]),
|
|
2246
|
+
]), Kn = /* @__PURE__ */ new Set([
|
|
2140
2247
|
"pin",
|
|
2141
2248
|
"highlight",
|
|
2142
2249
|
"drawing"
|
|
2143
|
-
]),
|
|
2250
|
+
]), qn = /* @__PURE__ */ new Set([
|
|
2144
2251
|
"low",
|
|
2145
2252
|
"medium",
|
|
2146
2253
|
"high",
|
|
2147
2254
|
"urgent"
|
|
2148
|
-
]),
|
|
2149
|
-
function
|
|
2150
|
-
return o(t) && e(t.x) && e(t.y) && n(t.element,
|
|
2255
|
+
]), Jn = /* @__PURE__ */ new Set(["add", "remove"]);
|
|
2256
|
+
function Yn(t) {
|
|
2257
|
+
return o(t) && e(t.x) && e(t.y) && n(t.element, Un) && n(t.xpath, Un);
|
|
2151
2258
|
}
|
|
2152
|
-
function
|
|
2259
|
+
function Xn(e) {
|
|
2153
2260
|
return typeof e == "string" && e.length <= j.PAGE && !a(e);
|
|
2154
2261
|
}
|
|
2262
|
+
function Zn(e) {
|
|
2263
|
+
return e === void 0 || o(e) && Xn(e.url) && Xn(e.path) && Xn(e.title);
|
|
2264
|
+
}
|
|
2155
2265
|
function Qn(e) {
|
|
2156
|
-
return
|
|
2266
|
+
return typeof e == "string" && Gn.has(e);
|
|
2157
2267
|
}
|
|
2158
2268
|
function $n(e) {
|
|
2159
|
-
return
|
|
2269
|
+
return Number.isInteger(e) && Number(e) >= 0;
|
|
2160
2270
|
}
|
|
2161
2271
|
function er(e) {
|
|
2162
|
-
return
|
|
2272
|
+
return $n(e) ? Math.min(e, 5) : 0;
|
|
2163
2273
|
}
|
|
2164
2274
|
function tr(e) {
|
|
2165
|
-
return
|
|
2275
|
+
return e.isNetworkError() || e.code === 408 || e.isRateLimitError();
|
|
2166
2276
|
}
|
|
2167
2277
|
function nr(e) {
|
|
2168
|
-
return e
|
|
2278
|
+
return e instanceof E ? tr(e) : !0;
|
|
2169
2279
|
}
|
|
2170
2280
|
function rr(e) {
|
|
2171
|
-
return e instanceof
|
|
2172
|
-
}
|
|
2173
|
-
function ir(e) {
|
|
2174
|
-
return e instanceof T ? {
|
|
2281
|
+
return e instanceof E ? {
|
|
2175
2282
|
error: e.error,
|
|
2176
2283
|
message: e.message,
|
|
2177
2284
|
code: e.code,
|
|
@@ -2182,93 +2289,98 @@ function ir(e) {
|
|
|
2182
2289
|
code: 0
|
|
2183
2290
|
};
|
|
2184
2291
|
}
|
|
2185
|
-
function
|
|
2292
|
+
function ir(e = Date.now()) {
|
|
2186
2293
|
return `mutation_${e}_${typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : Math.random().toString(36).slice(2, 12)}`;
|
|
2187
2294
|
}
|
|
2188
|
-
function
|
|
2189
|
-
return Array.isArray(e) ? e.map((e) =>
|
|
2295
|
+
function ar(e) {
|
|
2296
|
+
return Array.isArray(e) ? e.map((e) => ar(e)) : o(e) ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e, ar(t)])) : e;
|
|
2190
2297
|
}
|
|
2191
|
-
function
|
|
2298
|
+
function or(e) {
|
|
2192
2299
|
try {
|
|
2193
2300
|
if (typeof structuredClone == "function") return structuredClone(e);
|
|
2194
2301
|
} catch {}
|
|
2195
|
-
return
|
|
2302
|
+
return ar(e);
|
|
2196
2303
|
}
|
|
2197
|
-
function
|
|
2304
|
+
function sr(e, t) {
|
|
2198
2305
|
switch (e) {
|
|
2199
2306
|
case "createComment": {
|
|
2200
2307
|
let [e, n, r, a, s, c, l, u] = t;
|
|
2201
|
-
return t.length >= 3 && t.length <= 8 &&
|
|
2308
|
+
return t.length >= 3 && t.length <= 8 && Kn.has(String(e)) && i(n, Vn) && Yn(r) && (a === void 0 || qn.has(String(a))) && (s === void 0 || o(s)) && (c === void 0 || o(c)) && (l === void 0 || o(l)) && Zn(u);
|
|
2202
2309
|
}
|
|
2203
2310
|
case "createHighlight": {
|
|
2204
2311
|
let [e, n, r, a] = t;
|
|
2205
|
-
return t.length >= 2 && t.length <= 4 && i(e,
|
|
2312
|
+
return t.length >= 2 && t.length <= 4 && i(e, Vn) && o(n) && (a === void 0 || o(a)) && Zn(r);
|
|
2206
2313
|
}
|
|
2207
2314
|
case "createDrawing": {
|
|
2208
2315
|
let [e, n, r, a, s] = t;
|
|
2209
|
-
return t.length >= 3 && t.length <= 5 && i(e,
|
|
2316
|
+
return t.length >= 3 && t.length <= 5 && i(e, Vn) && o(n) && Yn(r) && (s === void 0 || o(s)) && Zn(a);
|
|
2210
2317
|
}
|
|
2211
|
-
case "updateComment": return t.length === 2 && r(t[0],
|
|
2318
|
+
case "updateComment": return t.length === 2 && r(t[0], Y) && o(t[1]);
|
|
2212
2319
|
case "deleteComment":
|
|
2213
2320
|
case "resolveComment":
|
|
2214
2321
|
case "unresolveComment":
|
|
2215
|
-
case "completeComment": return t.length === 1 && r(t[0],
|
|
2216
|
-
case "addReply": return (t.length === 2 || t.length === 3) && r(t[0],
|
|
2217
|
-
case "reactToComment": return t.length >= 2 && t.length <= 4 && r(t[0],
|
|
2218
|
-
case "updatePosition": return t.length === 2 && r(t[0],
|
|
2322
|
+
case "completeComment": return t.length === 1 && r(t[0], Y);
|
|
2323
|
+
case "addReply": return (t.length === 2 || t.length === 3) && r(t[0], Y) && i(t[1], Hn) && (t[2] === void 0 || o(t[2]));
|
|
2324
|
+
case "reactToComment": return t.length >= 2 && t.length <= 4 && r(t[0], Y) && r(t[1], Wn) && (t[2] === void 0 || Jn.has(String(t[2]))) && (t[3] === void 0 || r(t[3], Y));
|
|
2325
|
+
case "updatePosition": return t.length === 2 && r(t[0], Y) && Yn(t[1]);
|
|
2219
2326
|
}
|
|
2220
2327
|
}
|
|
2221
|
-
function
|
|
2222
|
-
return o(e) ? r(e.id,
|
|
2328
|
+
function cr(e) {
|
|
2329
|
+
return o(e) ? r(e.id, Y) ? e.ownerId !== void 0 && !r(e.ownerId, Y) ? "Queued mutation has an invalid owner id" : Qn(e.type) ? Array.isArray(e.args) ? Number.isFinite(e.timestamp) ? $n(e.retries) ? n(e.tempId, Y) ? sr(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";
|
|
2223
2330
|
}
|
|
2224
|
-
function
|
|
2225
|
-
let t =
|
|
2226
|
-
if (t) throw new
|
|
2331
|
+
function lr(e) {
|
|
2332
|
+
let t = cr(e);
|
|
2333
|
+
if (t) throw new E("invalid_mutation", t, 400);
|
|
2227
2334
|
}
|
|
2228
|
-
var
|
|
2229
|
-
function
|
|
2335
|
+
var ur = "commentkit:offline-queue:";
|
|
2336
|
+
function dr() {
|
|
2230
2337
|
try {
|
|
2231
2338
|
return typeof localStorage > "u" ? null : localStorage;
|
|
2232
2339
|
} catch {
|
|
2233
2340
|
return null;
|
|
2234
2341
|
}
|
|
2235
2342
|
}
|
|
2236
|
-
function
|
|
2237
|
-
return `${
|
|
2343
|
+
function fr(e) {
|
|
2344
|
+
return `${ur}${e}`;
|
|
2238
2345
|
}
|
|
2239
|
-
function
|
|
2346
|
+
function pr(e, t) {
|
|
2240
2347
|
if (!e) return;
|
|
2241
|
-
let n =
|
|
2348
|
+
let n = dr();
|
|
2242
2349
|
if (n) try {
|
|
2243
|
-
t.length === 0 ? n.removeItem(
|
|
2350
|
+
t.length === 0 ? n.removeItem(fr(e)) : n.setItem(fr(e), JSON.stringify(t));
|
|
2244
2351
|
} catch {}
|
|
2245
2352
|
}
|
|
2246
|
-
function
|
|
2353
|
+
function mr(e) {
|
|
2247
2354
|
if (!e) return [];
|
|
2248
|
-
let t =
|
|
2355
|
+
let t = dr();
|
|
2249
2356
|
if (!t) return [];
|
|
2250
2357
|
try {
|
|
2251
|
-
let n = t.getItem(
|
|
2358
|
+
let n = t.getItem(fr(e));
|
|
2252
2359
|
if (!n) return [];
|
|
2253
2360
|
let r = JSON.parse(n);
|
|
2254
2361
|
if (!Array.isArray(r)) return [];
|
|
2255
2362
|
let i = [];
|
|
2256
2363
|
for (let e of r) {
|
|
2257
|
-
if (i.length >=
|
|
2258
|
-
|
|
2364
|
+
if (i.length >= zn) break;
|
|
2365
|
+
cr(e) === null && i.push(e);
|
|
2259
2366
|
}
|
|
2260
2367
|
return i;
|
|
2261
2368
|
} catch {
|
|
2262
2369
|
return [];
|
|
2263
2370
|
}
|
|
2264
2371
|
}
|
|
2265
|
-
function
|
|
2372
|
+
function X(e) {
|
|
2266
2373
|
Promise.resolve().then(e);
|
|
2267
2374
|
}
|
|
2268
|
-
function
|
|
2269
|
-
|
|
2375
|
+
function hr(e, t) {
|
|
2376
|
+
if (e.type !== t.type || e.ownerId !== t.ownerId) return !1;
|
|
2377
|
+
if (t.type === "updateComment") {
|
|
2378
|
+
let n = e.args[1]?.checklistPatch, r = t.args[1]?.checklistPatch;
|
|
2379
|
+
if ((n || r) && n?.id !== r?.id) return !1;
|
|
2380
|
+
}
|
|
2381
|
+
return (t.type === "updatePosition" || t.type === "updateComment") && e.args[0] === t.args[0];
|
|
2270
2382
|
}
|
|
2271
|
-
function
|
|
2383
|
+
function gr(e, t) {
|
|
2272
2384
|
return t.type === "updateComment" && o(e.args[1]) ? {
|
|
2273
2385
|
...t,
|
|
2274
2386
|
args: [t.args[0], {
|
|
@@ -2277,32 +2389,32 @@ function _r(e, t) {
|
|
|
2277
2389
|
}]
|
|
2278
2390
|
} : t;
|
|
2279
2391
|
}
|
|
2280
|
-
function
|
|
2281
|
-
let n = e.findIndex((e) =>
|
|
2392
|
+
function _r(e, t) {
|
|
2393
|
+
let n = e.findIndex((e) => hr(e, t));
|
|
2282
2394
|
if (n !== -1) {
|
|
2283
2395
|
let r = [...e];
|
|
2284
|
-
return r[n] =
|
|
2396
|
+
return r[n] = gr(r[n], t), r;
|
|
2285
2397
|
}
|
|
2286
|
-
return e.length >=
|
|
2398
|
+
return e.length >= zn ? null : [...e, t];
|
|
2287
2399
|
}
|
|
2288
|
-
function
|
|
2400
|
+
function Z(e, t, n) {
|
|
2289
2401
|
e.emit("offline:failed", {
|
|
2290
2402
|
id: t,
|
|
2291
2403
|
error: n
|
|
2292
2404
|
});
|
|
2293
2405
|
}
|
|
2294
|
-
function
|
|
2406
|
+
function vr(e, t) {
|
|
2295
2407
|
return t.isAuthenticated && e.ownerId && e.ownerId === t.currentUser?.id ? null : {
|
|
2296
2408
|
error: "offline_identity_mismatch",
|
|
2297
2409
|
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.",
|
|
2298
2410
|
code: 403
|
|
2299
2411
|
};
|
|
2300
2412
|
}
|
|
2301
|
-
function
|
|
2413
|
+
function yr(e) {
|
|
2302
2414
|
let t = e.getState();
|
|
2303
2415
|
if (!t.isAuthenticated) return;
|
|
2304
2416
|
let n = t.pendingMutations.flatMap((e) => {
|
|
2305
|
-
let n =
|
|
2417
|
+
let n = vr(e, t);
|
|
2306
2418
|
return n ? [{
|
|
2307
2419
|
mutation: e,
|
|
2308
2420
|
error: n
|
|
@@ -2311,19 +2423,19 @@ function br(e) {
|
|
|
2311
2423
|
if (n.length === 0) return;
|
|
2312
2424
|
let r = new Set(n.map(({ mutation: e }) => e.id));
|
|
2313
2425
|
e.setState({ pendingMutations: t.pendingMutations.filter((e) => !r.has(e.id)) });
|
|
2314
|
-
for (let { mutation: t, error: r } of n)
|
|
2426
|
+
for (let { mutation: t, error: r } of n) Z(e, t.id, r);
|
|
2315
2427
|
}
|
|
2316
|
-
function
|
|
2317
|
-
return !e.isOnline || t instanceof
|
|
2428
|
+
function br(e, t) {
|
|
2429
|
+
return !e.isOnline || t instanceof E && tr(t);
|
|
2318
2430
|
}
|
|
2319
|
-
function
|
|
2320
|
-
let s =
|
|
2321
|
-
if (!c.isAuthenticated || !r(l,
|
|
2431
|
+
function xr(e, t, i, a, o) {
|
|
2432
|
+
let s = ir(), c = e.getState(), l = c.currentUser?.id;
|
|
2433
|
+
if (!c.isAuthenticated || !r(l, Y)) return Z(e, s, {
|
|
2322
2434
|
error: "unauthenticated",
|
|
2323
2435
|
message: "Sign in before saving changes for offline replay.",
|
|
2324
2436
|
code: 401
|
|
2325
2437
|
}), !1;
|
|
2326
|
-
if (
|
|
2438
|
+
if (!Qn(i) || !Array.isArray(a) || !sr(i, a) || !n(o, Y)) return Z(e, s, {
|
|
2327
2439
|
error: "invalid_mutation",
|
|
2328
2440
|
message: "Queued mutation args are invalid",
|
|
2329
2441
|
code: 400
|
|
@@ -2332,27 +2444,27 @@ function Sr(e, t, i, a, o) {
|
|
|
2332
2444
|
id: s,
|
|
2333
2445
|
ownerId: l,
|
|
2334
2446
|
type: i,
|
|
2335
|
-
args:
|
|
2447
|
+
args: or(a),
|
|
2336
2448
|
timestamp: Date.now(),
|
|
2337
2449
|
retries: 0,
|
|
2338
2450
|
...o === void 0 ? {} : { tempId: o }
|
|
2339
|
-
}, d =
|
|
2340
|
-
return d ? (e.setState({ pendingMutations: d }), e.emit("offline:queued", u), e.getState().isOnline &&
|
|
2451
|
+
}, d = _r(e.getState().pendingMutations, u);
|
|
2452
|
+
return d ? (e.setState({ pendingMutations: d }), e.emit("offline:queued", u), e.getState().isOnline && X(t), !0) : (Z(e, s, {
|
|
2341
2453
|
error: "queue_full",
|
|
2342
2454
|
message: "Offline mutation queue is full",
|
|
2343
2455
|
code: 0
|
|
2344
2456
|
}), !1);
|
|
2345
2457
|
}
|
|
2346
|
-
function
|
|
2458
|
+
function Sr(e, t, n) {
|
|
2347
2459
|
if (t.current || e.getState().pendingMutations.length === 0) return;
|
|
2348
2460
|
let r = e.getState().pendingMutations[0];
|
|
2349
2461
|
if (!r) return;
|
|
2350
|
-
let i =
|
|
2462
|
+
let i = er(r.retries), a = Math.min(Bn, jt * 2 ** i);
|
|
2351
2463
|
t.current = setTimeout(() => {
|
|
2352
2464
|
t.current = null, n();
|
|
2353
2465
|
}, a);
|
|
2354
2466
|
}
|
|
2355
|
-
async function
|
|
2467
|
+
async function Cr(e, t, n, i) {
|
|
2356
2468
|
let a = e.getState();
|
|
2357
2469
|
if (!a.isOnline || a.pendingMutations.length === 0 || !a.isAuthenticated || t.current) return;
|
|
2358
2470
|
t.current = !0;
|
|
@@ -2361,49 +2473,49 @@ async function wr(e, t, n, i) {
|
|
|
2361
2473
|
t.current = !1;
|
|
2362
2474
|
return;
|
|
2363
2475
|
}
|
|
2364
|
-
let s =
|
|
2476
|
+
let s = cr(o), c = s ? {
|
|
2365
2477
|
error: "invalid_mutation",
|
|
2366
2478
|
message: s,
|
|
2367
2479
|
code: 400
|
|
2368
|
-
} :
|
|
2480
|
+
} : vr(o, e.getState());
|
|
2369
2481
|
if (c) {
|
|
2370
2482
|
let i = e.getState().pendingMutations.filter((e) => e !== o);
|
|
2371
|
-
e.setState({ pendingMutations: i }),
|
|
2483
|
+
e.setState({ pendingMutations: i }), Z(e, r(o.id, Y) ? o.id : "invalid", c), i.length > 0 && X(n), t.current = !1;
|
|
2372
2484
|
return;
|
|
2373
2485
|
}
|
|
2374
2486
|
e.emit("offline:retrying", {
|
|
2375
2487
|
id: o.id,
|
|
2376
2488
|
attempt: o.retries + 1
|
|
2377
2489
|
});
|
|
2378
|
-
let l = i ?? ((t) =>
|
|
2490
|
+
let l = i ?? ((t) => Dr(e, t));
|
|
2379
2491
|
try {
|
|
2380
2492
|
await l(o);
|
|
2381
2493
|
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 ?
|
|
2494
|
+
e.setState({ pendingMutations: r }), e.emit("offline:completed", { id: o.id }), r.length > 0 ? X(n) : t.reconcileAfterDrain && (t.reconcileAfterDrain = !1, ln(e));
|
|
2383
2495
|
} catch (r) {
|
|
2384
2496
|
let i = {
|
|
2385
2497
|
...o,
|
|
2386
|
-
retries:
|
|
2498
|
+
retries: er(o.retries) + 1
|
|
2387
2499
|
};
|
|
2388
|
-
if (
|
|
2500
|
+
if (nr(r) && i.retries < 5) {
|
|
2389
2501
|
let t = e.getState().pendingMutations.map((e) => e.id === o.id ? i : e);
|
|
2390
|
-
e.setState({ pendingMutations: t }),
|
|
2502
|
+
e.setState({ pendingMutations: t }), X(n);
|
|
2391
2503
|
} else {
|
|
2392
2504
|
let i = e.getState().pendingMutations.filter((e) => e.id !== o.id);
|
|
2393
|
-
e.setState({ pendingMutations: i }),
|
|
2505
|
+
e.setState({ pendingMutations: i }), Z(e, o.id, rr(r)), i.length > 0 ? (t.reconcileAfterDrain = !0, X(n)) : (t.reconcileAfterDrain = !1, ln(e));
|
|
2394
2506
|
}
|
|
2395
2507
|
} finally {
|
|
2396
2508
|
t.current = !1;
|
|
2397
2509
|
}
|
|
2398
2510
|
}
|
|
2399
|
-
function
|
|
2511
|
+
function wr(e, t, n) {
|
|
2400
2512
|
let r = !1, i = e.getState().pendingMutations.map((e) => e.type !== "createComment" && e.type !== "createHighlight" && e.type !== "createDrawing" && e.args[0] === t ? (r = !0, {
|
|
2401
2513
|
...e,
|
|
2402
2514
|
args: [n, ...e.args.slice(1)]
|
|
2403
2515
|
}) : e);
|
|
2404
2516
|
r && e.setState({ pendingMutations: i });
|
|
2405
2517
|
}
|
|
2406
|
-
function
|
|
2518
|
+
function Tr(e, t, n) {
|
|
2407
2519
|
let r = e.getState(), i = (e) => e === t || e === n;
|
|
2408
2520
|
e.setState({
|
|
2409
2521
|
comments: r.comments.filter((e) => !i(e.id)),
|
|
@@ -2411,7 +2523,7 @@ function Er(e, t, n) {
|
|
|
2411
2523
|
activeComment: r.activeComment && i(r.activeComment.id) ? null : r.activeComment
|
|
2412
2524
|
});
|
|
2413
2525
|
}
|
|
2414
|
-
function
|
|
2526
|
+
function Q(e, t, n, r, i = !1) {
|
|
2415
2527
|
let a = e.getState(), o = a.comments.find((e) => e.id === r || e.id === n.id), s = n, c = (e) => {
|
|
2416
2528
|
s.status !== e && (s = {
|
|
2417
2529
|
...s,
|
|
@@ -2422,13 +2534,20 @@ function X(e, t, n, r, i = !1) {
|
|
|
2422
2534
|
};
|
|
2423
2535
|
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) {
|
|
2424
2536
|
case "deleteComment":
|
|
2425
|
-
|
|
2537
|
+
Tr(e, n.id, r);
|
|
2426
2538
|
return;
|
|
2427
2539
|
case "updateComment":
|
|
2428
|
-
i.args[1].status && c(i.args[1].status)
|
|
2429
|
-
|
|
2430
|
-
...i.args[1]
|
|
2431
|
-
|
|
2540
|
+
i.args[1].status && c(i.args[1].status);
|
|
2541
|
+
{
|
|
2542
|
+
let { checklistPatch: e, ...t } = i.args[1];
|
|
2543
|
+
s = {
|
|
2544
|
+
...s,
|
|
2545
|
+
...t
|
|
2546
|
+
}, e && (s.checklist = s.checklist?.map((t) => t.id === e.id ? {
|
|
2547
|
+
...t,
|
|
2548
|
+
done: e.done
|
|
2549
|
+
} : t));
|
|
2550
|
+
}
|
|
2432
2551
|
break;
|
|
2433
2552
|
case "resolveComment":
|
|
2434
2553
|
c("resolved");
|
|
@@ -2460,55 +2579,55 @@ function X(e, t, n, r, i = !1) {
|
|
|
2460
2579
|
}
|
|
2461
2580
|
i ? G(e, r, s) : e.setState({ comments: a.comments.map((e) => e.id === r ? s : e) });
|
|
2462
2581
|
}
|
|
2463
|
-
function
|
|
2582
|
+
function Er(e, t, n, r) {
|
|
2464
2583
|
e.setState({ pendingMutations: e.getState().pendingMutations.map((e) => e.type === "reactToComment" && e.args[0] === t && e.args[3] === n ? {
|
|
2465
2584
|
...e,
|
|
2466
2585
|
args: [...e.args.slice(0, 3), r]
|
|
2467
2586
|
} : e) });
|
|
2468
2587
|
}
|
|
2469
|
-
async function
|
|
2470
|
-
|
|
2471
|
-
let n =
|
|
2472
|
-
if (n) throw new
|
|
2588
|
+
async function Dr(e, t) {
|
|
2589
|
+
lr(t);
|
|
2590
|
+
let n = vr(t, e.getState());
|
|
2591
|
+
if (n) throw new E(n.error, n.message, n.code);
|
|
2473
2592
|
switch (t.type) {
|
|
2474
2593
|
case "createComment": {
|
|
2475
2594
|
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 && (
|
|
2595
|
+
u && t.tempId && (Q(e, t, u, t.tempId, !0), wr(e, t.tempId, u.id));
|
|
2477
2596
|
break;
|
|
2478
2597
|
}
|
|
2479
2598
|
case "createHighlight": {
|
|
2480
2599
|
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 && (
|
|
2600
|
+
o && t.tempId && (Q(e, t, o, t.tempId, !0), wr(e, t.tempId, o.id));
|
|
2482
2601
|
break;
|
|
2483
2602
|
}
|
|
2484
2603
|
case "createDrawing": {
|
|
2485
2604
|
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 && (
|
|
2605
|
+
s && t.tempId && (Q(e, t, s, t.tempId, !0), wr(e, t.tempId, s.id));
|
|
2487
2606
|
break;
|
|
2488
2607
|
}
|
|
2489
2608
|
case "updateComment": {
|
|
2490
2609
|
let [n, r] = t.args, i = await e.apiClient.updateComment(n, r);
|
|
2491
|
-
i &&
|
|
2610
|
+
i && Q(e, t, i, n);
|
|
2492
2611
|
break;
|
|
2493
2612
|
}
|
|
2494
2613
|
case "deleteComment": {
|
|
2495
2614
|
let [n] = t.args;
|
|
2496
|
-
await e.apiClient.deleteComment(n),
|
|
2615
|
+
await e.apiClient.deleteComment(n), Tr(e, n);
|
|
2497
2616
|
break;
|
|
2498
2617
|
}
|
|
2499
2618
|
case "resolveComment": {
|
|
2500
2619
|
let [n] = t.args, r = await e.apiClient.resolveComment(n);
|
|
2501
|
-
r &&
|
|
2620
|
+
r && Q(e, t, r, n);
|
|
2502
2621
|
break;
|
|
2503
2622
|
}
|
|
2504
2623
|
case "unresolveComment": {
|
|
2505
2624
|
let [n] = t.args, r = await e.apiClient.unresolveComment(n);
|
|
2506
|
-
r &&
|
|
2625
|
+
r && Q(e, t, r, n);
|
|
2507
2626
|
break;
|
|
2508
2627
|
}
|
|
2509
2628
|
case "completeComment": {
|
|
2510
2629
|
let [n] = t.args, r = await e.apiClient.markComplete(n);
|
|
2511
|
-
r &&
|
|
2630
|
+
r && Q(e, t, r, n);
|
|
2512
2631
|
break;
|
|
2513
2632
|
}
|
|
2514
2633
|
case "addReply": {
|
|
@@ -2518,9 +2637,9 @@ async function Or(e, t) {
|
|
|
2518
2637
|
sn(e, n, t.tempId, i && o ? {
|
|
2519
2638
|
...a,
|
|
2520
2639
|
reactions: o.reactions
|
|
2521
|
-
} : a),
|
|
2640
|
+
} : a), Er(e, n, t.tempId, a.id);
|
|
2522
2641
|
let s = e.getState().comments.find((e) => e.id === n);
|
|
2523
|
-
s &&
|
|
2642
|
+
s && Q(e, t, s, n);
|
|
2524
2643
|
}
|
|
2525
2644
|
break;
|
|
2526
2645
|
}
|
|
@@ -2531,221 +2650,30 @@ async function Or(e, t) {
|
|
|
2531
2650
|
}
|
|
2532
2651
|
case "updatePosition": {
|
|
2533
2652
|
let [n, r] = t.args, i = await e.apiClient.updatePosition(n, r);
|
|
2534
|
-
i &&
|
|
2653
|
+
i && Q(e, t, i, n);
|
|
2535
2654
|
break;
|
|
2536
2655
|
}
|
|
2537
2656
|
}
|
|
2538
2657
|
}
|
|
2539
|
-
var kr = 1e4, Ar = 2048, jr = 10485760, Mr = 20971520, Z = 16384, Nr = 32e6, Pr = 10, Fr = 10485760, Ir = 26214400, Lr = /* @__PURE__ */ new Set([
|
|
2540
|
-
"jpg",
|
|
2541
|
-
"jpeg",
|
|
2542
|
-
"png",
|
|
2543
|
-
"gif",
|
|
2544
|
-
"webp",
|
|
2545
|
-
"pdf",
|
|
2546
|
-
"doc",
|
|
2547
|
-
"docx",
|
|
2548
|
-
"txt",
|
|
2549
|
-
"csv"
|
|
2550
|
-
]), Rr = 15e3, zr = 1e4, Br = {
|
|
2551
|
-
"image/gif": "gif",
|
|
2552
|
-
"image/jpeg": "jpg",
|
|
2553
|
-
"image/png": "png",
|
|
2554
|
-
"image/webp": "webp"
|
|
2555
|
-
};
|
|
2556
|
-
function Q(e, t) {
|
|
2557
|
-
let n = Error(t);
|
|
2558
|
-
return n.error = e, n.code = 400, n;
|
|
2559
|
-
}
|
|
2560
|
-
function Vr(e) {
|
|
2561
|
-
if (typeof e != "string") throw Q("invalid_position", "Invalid position");
|
|
2562
|
-
let t = e.trim();
|
|
2563
|
-
if (!t || t.length > Ar || a(t)) throw Q("invalid_position", "Invalid position");
|
|
2564
|
-
return t;
|
|
2565
|
-
}
|
|
2566
|
-
function Hr(t) {
|
|
2567
|
-
if (!o(t) || !e(t.x) || !e(t.y)) throw Q("invalid_position", "Invalid position");
|
|
2568
|
-
return {
|
|
2569
|
-
x: t.x,
|
|
2570
|
-
y: t.y,
|
|
2571
|
-
...t.element === void 0 ? {} : { element: Vr(t.element) },
|
|
2572
|
-
...t.xpath === void 0 ? {} : { xpath: Vr(t.xpath) }
|
|
2573
|
-
};
|
|
2574
|
-
}
|
|
2575
|
-
function Ur(e) {
|
|
2576
|
-
if (typeof e != "string") throw Q("invalid_content", "Screenshot comment is required");
|
|
2577
|
-
let t = e.trim();
|
|
2578
|
-
if (!t || t.length > kr || a(t)) throw Q("invalid_content", "Screenshot comment is required");
|
|
2579
|
-
return t;
|
|
2580
|
-
}
|
|
2581
|
-
function Wr(e) {
|
|
2582
|
-
return typeof Blob < "u" && e instanceof Blob;
|
|
2583
|
-
}
|
|
2584
|
-
function Gr(e) {
|
|
2585
|
-
return typeof File < "u" && e instanceof File;
|
|
2586
|
-
}
|
|
2587
|
-
function Kr(e) {
|
|
2588
|
-
return typeof HTMLElement < "u" && e instanceof HTMLElement;
|
|
2589
|
-
}
|
|
2590
|
-
function qr(e) {
|
|
2591
|
-
if (e !== void 0) {
|
|
2592
|
-
if (!Kr(e)) throw Q("invalid_element", "Invalid screenshot target");
|
|
2593
|
-
return e;
|
|
2594
|
-
}
|
|
2595
|
-
if (typeof document > "u" || !document.body) throw Q("invalid_element", "A browser document is required to capture screenshots");
|
|
2596
|
-
return document.body;
|
|
2597
|
-
}
|
|
2598
|
-
function Jr(e) {
|
|
2599
|
-
let t = /^data:(image\/(?:png|jpeg|gif|webp));base64,/i.exec(e)?.[1];
|
|
2600
|
-
return t ? t.toLowerCase() : null;
|
|
2601
|
-
}
|
|
2602
|
-
function Yr(e) {
|
|
2603
|
-
if (!o(e)) throw Q("invalid_screenshot", "Invalid screenshot result");
|
|
2604
|
-
let t = typeof e.dataUrl == "string" ? e.dataUrl.trim() : "", n = e.blob, r = e.dimensions;
|
|
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");
|
|
2609
|
-
return {
|
|
2610
|
-
dataUrl: t,
|
|
2611
|
-
blob: n,
|
|
2612
|
-
dimensions: {
|
|
2613
|
-
width: i,
|
|
2614
|
-
height: a
|
|
2615
|
-
}
|
|
2616
|
-
};
|
|
2617
|
-
}
|
|
2618
|
-
function Xr(e) {
|
|
2619
|
-
let t = Jr(e.dataUrl);
|
|
2620
|
-
return e.blob.type || t;
|
|
2621
|
-
}
|
|
2622
|
-
function Zr(e) {
|
|
2623
|
-
return `screenshot.${Br[Xr(e)]}`;
|
|
2624
|
-
}
|
|
2625
|
-
function Qr(e, t, n) {
|
|
2626
|
-
let r = null;
|
|
2627
|
-
return new Promise((i, a) => {
|
|
2628
|
-
r = setTimeout(() => {
|
|
2629
|
-
r = null, a(Error(n));
|
|
2630
|
-
}, t), e.then((e) => {
|
|
2631
|
-
r && clearTimeout(r), r = null, i(e);
|
|
2632
|
-
}, (e) => {
|
|
2633
|
-
r && clearTimeout(r), r = null, a(e);
|
|
2634
|
-
});
|
|
2635
|
-
});
|
|
2636
|
-
}
|
|
2637
|
-
function $r(e) {
|
|
2638
|
-
return new Promise((t, n) => {
|
|
2639
|
-
let r = !1, i = setTimeout(() => {
|
|
2640
|
-
r = !0, n(/* @__PURE__ */ Error("toBlob timed out"));
|
|
2641
|
-
}, zr);
|
|
2642
|
-
e.toBlob((e) => {
|
|
2643
|
-
r || (r = !0, clearTimeout(i), e ? t(e) : n(/* @__PURE__ */ Error("toBlob returned null")));
|
|
2644
|
-
}, "image/png");
|
|
2645
|
-
});
|
|
2646
|
-
}
|
|
2647
|
-
function ei(e) {
|
|
2648
|
-
let t = e.lastIndexOf(".");
|
|
2649
|
-
return t >= 0 ? e.slice(t + 1).toLowerCase() : "";
|
|
2650
|
-
}
|
|
2651
|
-
function ti(e) {
|
|
2652
|
-
if (!Array.isArray(e)) throw Q("invalid_files", "Files must be an array");
|
|
2653
|
-
if (e.length > Pr) throw Q("too_many_files", `Cannot upload more than ${Pr} files at once`);
|
|
2654
|
-
let t = 0;
|
|
2655
|
-
for (let n of e) {
|
|
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(", ")}`);
|
|
2662
|
-
}
|
|
2663
|
-
return e;
|
|
2664
|
-
}
|
|
2665
|
-
async function ni(e, t, n, r = {}) {
|
|
2666
|
-
if (e.isLocalDemo) return null;
|
|
2667
|
-
try {
|
|
2668
|
-
let e = qr(n);
|
|
2669
|
-
if (g(e)) return null;
|
|
2670
|
-
if (t) return Yr(await t(e));
|
|
2671
|
-
let r;
|
|
2672
|
-
try {
|
|
2673
|
-
r = (await import("html2canvas")).default;
|
|
2674
|
-
} catch {
|
|
2675
|
-
/* v8 ignore next 3 -- dynamic import() can't be intercepted by vi.mock */
|
|
2676
|
-
throw Error("Screenshot requires either a custom screenshotProvider in config or html2canvas installed. Install html2canvas: npm install html2canvas — or provide config.screenshotProvider.");
|
|
2677
|
-
}
|
|
2678
|
-
let i = await Qr(r(e, {
|
|
2679
|
-
useCORS: !0,
|
|
2680
|
-
allowTaint: !1,
|
|
2681
|
-
scale: 2,
|
|
2682
|
-
logging: !1,
|
|
2683
|
-
ignoreElements: g,
|
|
2684
|
-
onclone: (e) => import("./capture-colors-D0uLr-vZ.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({
|
|
2688
|
-
dataUrl: i.toDataURL("image/png"),
|
|
2689
|
-
blob: await $r(i),
|
|
2690
|
-
dimensions: {
|
|
2691
|
-
width: i.width,
|
|
2692
|
-
height: i.height
|
|
2693
|
-
}
|
|
2694
|
-
});
|
|
2695
|
-
} catch (t) {
|
|
2696
|
-
return r.reportErrors !== !1 && (console.error("[CommentKit] Screenshot failed:", t), e.handleError({
|
|
2697
|
-
error: "screenshot_failed",
|
|
2698
|
-
message: "Failed to capture screenshot",
|
|
2699
|
-
code: 500
|
|
2700
|
-
})), null;
|
|
2701
|
-
}
|
|
2702
|
-
}
|
|
2703
|
-
async function ri(e, t, n, r) {
|
|
2704
|
-
try {
|
|
2705
|
-
let i = Yr(t), a = Ur(n), o = Hr(r);
|
|
2706
|
-
e.setState({ isLoading: !0 });
|
|
2707
|
-
let s = new File([i.blob], Zr(i), { type: Xr(i) }), c = m(), l = F(e), u = await e.apiClient.uploadScreenshot(s, {
|
|
2708
|
-
content: a,
|
|
2709
|
-
position: o,
|
|
2710
|
-
page: c,
|
|
2711
|
-
...l ? { branch: l } : {}
|
|
2712
|
-
});
|
|
2713
|
-
return e.setState({
|
|
2714
|
-
comments: !e.getState().activeBranch || e.getState().activeBranch === u.branch ? [...e.getState().comments, u] : e.getState().comments,
|
|
2715
|
-
isLoading: !1,
|
|
2716
|
-
activeScreenshot: null
|
|
2717
|
-
}), e.emit("comment:created", u), u;
|
|
2718
|
-
} catch (t) {
|
|
2719
|
-
return e.setState({ isLoading: !1 }), e.handleError(t), null;
|
|
2720
|
-
}
|
|
2721
|
-
}
|
|
2722
|
-
async function ii(e, t, n) {
|
|
2723
|
-
try {
|
|
2724
|
-
let r = ti(t);
|
|
2725
|
-
return r.length === 0 ? [] : await e.apiClient.uploadFiles(r, n);
|
|
2726
|
-
} catch (t) {
|
|
2727
|
-
return e.handleError(t), [];
|
|
2728
|
-
}
|
|
2729
|
-
}
|
|
2730
2658
|
var $ = null;
|
|
2731
|
-
async function
|
|
2732
|
-
return $ || ($ = await import("./realtime-
|
|
2659
|
+
async function Or() {
|
|
2660
|
+
return $ || ($ = await import("./realtime-DspH16g5.js"), $);
|
|
2733
2661
|
}
|
|
2734
|
-
var
|
|
2662
|
+
var kr = typeof window < "u", Ar = /* @__PURE__ */ new Set([
|
|
2735
2663
|
"list",
|
|
2736
2664
|
"detail",
|
|
2737
2665
|
"settings",
|
|
2738
2666
|
"activity",
|
|
2739
2667
|
"dev-export"
|
|
2740
|
-
]),
|
|
2668
|
+
]), jr = /* @__PURE__ */ new Set([
|
|
2741
2669
|
"comment",
|
|
2742
2670
|
"draw",
|
|
2743
2671
|
"highlight",
|
|
2744
2672
|
"screenshot",
|
|
2745
2673
|
"select",
|
|
2746
2674
|
null
|
|
2747
|
-
]),
|
|
2748
|
-
function
|
|
2675
|
+
]), Mr = 256, Nr = "0.7.5";
|
|
2676
|
+
function Pr(e) {
|
|
2749
2677
|
let t = e.trim().match(/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/);
|
|
2750
2678
|
return t ? [
|
|
2751
2679
|
Number(t[1]),
|
|
@@ -2753,12 +2681,12 @@ function di(e) {
|
|
|
2753
2681
|
Number(t[3] ?? 0)
|
|
2754
2682
|
] : null;
|
|
2755
2683
|
}
|
|
2756
|
-
function
|
|
2684
|
+
function Fr(e) {
|
|
2757
2685
|
return /^v?\d+(?:\.\d+)?(?:\.\d+)?-/.test(e.trim());
|
|
2758
2686
|
}
|
|
2759
|
-
function
|
|
2760
|
-
if (
|
|
2761
|
-
let n =
|
|
2687
|
+
function Ir(e, t) {
|
|
2688
|
+
if (Fr(e)) return !1;
|
|
2689
|
+
let n = Pr(e), r = Pr(t);
|
|
2762
2690
|
if (!n || !r) return !1;
|
|
2763
2691
|
for (let e = 0; e < 3; e++) {
|
|
2764
2692
|
let t = n[e] ?? 0, i = r[e] ?? 0;
|
|
@@ -2767,7 +2695,7 @@ function pi(e, t) {
|
|
|
2767
2695
|
}
|
|
2768
2696
|
return !1;
|
|
2769
2697
|
}
|
|
2770
|
-
var
|
|
2698
|
+
var Lr = class extends tt {
|
|
2771
2699
|
get isProcessingQueue() {
|
|
2772
2700
|
return this.queueGuard.current;
|
|
2773
2701
|
}
|
|
@@ -2798,7 +2726,7 @@ var mi = class extends tt {
|
|
|
2798
2726
|
}, this.config.ui = {
|
|
2799
2727
|
...this.config.ui,
|
|
2800
2728
|
loadRemoteFonts: !1
|
|
2801
|
-
}),
|
|
2729
|
+
}), kr && !this.config.environment && (this.config.environment = this.detectEnvironment()), this.apiClient = this.localDemo?.client ?? new ve(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 = {
|
|
2802
2730
|
getState: () => this.getInternalState(),
|
|
2803
2731
|
setState: (e) => this.setState(e),
|
|
2804
2732
|
apiClient: this.apiClient,
|
|
@@ -2826,7 +2754,7 @@ var mi = class extends tt {
|
|
|
2826
2754
|
mouseMoveHandler: this.mouseMoveHandler
|
|
2827
2755
|
}, this.localDemo && (this.restoreDemoState(), this.localDemo.subscribe((e) => {
|
|
2828
2756
|
e !== "persist" && this.restoreDemoState();
|
|
2829
|
-
})), e.enabled !== !1 &&
|
|
2757
|
+
})), e.enabled !== !1 && kr && Promise.resolve().then(() => this.boot()).catch((e) => this.handleError(e));
|
|
2830
2758
|
/* v8 ignore stop */
|
|
2831
2759
|
}
|
|
2832
2760
|
isLocalDemo() {
|
|
@@ -2929,8 +2857,8 @@ var mi = class extends tt {
|
|
|
2929
2857
|
};
|
|
2930
2858
|
}
|
|
2931
2859
|
let n = e.project?.sdkLatestVersion;
|
|
2932
|
-
n &&
|
|
2933
|
-
current:
|
|
2860
|
+
n && Ir(n, "0.7.5") && (console.warn(`[CommentKit] You are using v${Nr}. Update to v${n}: npm update @commentkit/comment-kit`), this.emit("sdk:outdated", {
|
|
2861
|
+
current: Nr,
|
|
2934
2862
|
latest: n
|
|
2935
2863
|
})), this.setState({
|
|
2936
2864
|
project: e.project,
|
|
@@ -2965,6 +2893,7 @@ var mi = class extends tt {
|
|
|
2965
2893
|
project: e.project ? structuredClone(e.project) : null,
|
|
2966
2894
|
projectContext: e.projectContext ? structuredClone(e.projectContext) : null,
|
|
2967
2895
|
comments: structuredClone(e.comments),
|
|
2896
|
+
commentQuery: e.commentQuery ? { ...e.commentQuery } : void 0,
|
|
2968
2897
|
selectedComment: e.selectedComment ? structuredClone(e.selectedComment) : null,
|
|
2969
2898
|
activeComment: e.activeComment ? structuredClone(e.activeComment) : null,
|
|
2970
2899
|
activeDrawing: e.activeDrawing ? structuredClone(e.activeDrawing) : null,
|
|
@@ -3115,7 +3044,7 @@ var mi = class extends tt {
|
|
|
3115
3044
|
if (this.initialAuthToken = void 0, e === void 0) return;
|
|
3116
3045
|
let t = () => !this.destroyed && this.authRequestRevision === 0;
|
|
3117
3046
|
try {
|
|
3118
|
-
let { verifyAndRestoreToken: n } = await import("./token-session-
|
|
3047
|
+
let { verifyAndRestoreToken: n } = await import("./token-session-_Pi4fOEi.js");
|
|
3119
3048
|
await n(this.ctx, e, t, this.config.persistence !== "memory") && await this.afterAuthenticated();
|
|
3120
3049
|
} catch {
|
|
3121
3050
|
t() && this.handleAuthExpired();
|
|
@@ -3128,7 +3057,7 @@ var mi = class extends tt {
|
|
|
3128
3057
|
projectContext: null,
|
|
3129
3058
|
activities: [],
|
|
3130
3059
|
seenThreadIds: /* @__PURE__ */ new Set()
|
|
3131
|
-
}),
|
|
3060
|
+
}), yr(this.ctx), this.getFeatures().realtime && this.initializeWebSocket(), await Promise.all([this.loadComments(), this.reloadProjectContext()]), this.handleDeepLink(), this.getInternalState().pendingMutations.length > 0 && this.scheduleRetry());
|
|
3132
3061
|
}
|
|
3133
3062
|
beginAuthRequest() {
|
|
3134
3063
|
let e = ++this.authRequestRevision;
|
|
@@ -3184,7 +3113,7 @@ var mi = class extends tt {
|
|
|
3184
3113
|
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));
|
|
3185
3114
|
}
|
|
3186
3115
|
toggleLoginModal() {
|
|
3187
|
-
this.destroyed || this.localDemo || Dt(this.ctx);
|
|
3116
|
+
this.destroyed || this.localDemo || (this.getInternalState().isLoginModalVisible && this.cancelOtp(), Dt(this.ctx));
|
|
3188
3117
|
}
|
|
3189
3118
|
requiresShortcut() {
|
|
3190
3119
|
return this.localDemo ? !0 : this.config.environment !== "development";
|
|
@@ -3204,7 +3133,7 @@ var mi = class extends tt {
|
|
|
3204
3133
|
this.destroyed || this.setState({ isSidebarVisible: !this.getInternalState().isSidebarVisible });
|
|
3205
3134
|
}
|
|
3206
3135
|
setTool(e) {
|
|
3207
|
-
if (this.destroyed || !
|
|
3136
|
+
if (this.destroyed || !jr.has(e) || this.localDemo && e !== null && e !== "comment" && e !== "select") return;
|
|
3208
3137
|
let t = this.getInternalState();
|
|
3209
3138
|
if (e !== null && e !== "select" && !this.requireCommentWrite()) return;
|
|
3210
3139
|
if (!t.isAuthenticated && e !== "select" && e !== null) {
|
|
@@ -3280,6 +3209,22 @@ var mi = class extends tt {
|
|
|
3280
3209
|
async loadMoreComments() {
|
|
3281
3210
|
this.destroyed || await un(this.commentsRequestContext(this.commentsFetchRevision), this.loadMoreGuard);
|
|
3282
3211
|
}
|
|
3212
|
+
async setCommentQuery(e) {
|
|
3213
|
+
if (this.destroyed || !this.getInternalState().isAuthenticated || this.localDemo) return;
|
|
3214
|
+
let t = {
|
|
3215
|
+
...e,
|
|
3216
|
+
search: e.search?.trim().slice(0, 200) || void 0
|
|
3217
|
+
};
|
|
3218
|
+
if (JSON.stringify(t) !== JSON.stringify(this.getInternalState().commentQuery)) return this.setState({
|
|
3219
|
+
commentQuery: t,
|
|
3220
|
+
pagination: null,
|
|
3221
|
+
selectedComment: null
|
|
3222
|
+
}), this.loadComments();
|
|
3223
|
+
}
|
|
3224
|
+
async loadEarlierReplies() {
|
|
3225
|
+
let e = this.getInternalState(), t = e.comments.find((t) => t.id === e.selectedComment?.id);
|
|
3226
|
+
if (!(this.destroyed || e.loadingThreadId || !t?.repliesPagination?.nextCursor)) return dn(this.operationContext(), t.id, t.repliesPagination.nextCursor);
|
|
3227
|
+
}
|
|
3283
3228
|
async reloadComments() {
|
|
3284
3229
|
if (!this.destroyed) return this.loadComments();
|
|
3285
3230
|
}
|
|
@@ -3383,44 +3328,44 @@ var mi = class extends tt {
|
|
|
3383
3328
|
return;
|
|
3384
3329
|
}
|
|
3385
3330
|
let s = o?.[nt];
|
|
3386
|
-
return
|
|
3331
|
+
return fn(this.operationContext(s), this.operationCallbacks(s), this.activeMutations, e, t, n, r, i, a, {
|
|
3387
3332
|
...o,
|
|
3388
3333
|
branch: o?.branch ?? F(this.ctx)
|
|
3389
3334
|
});
|
|
3390
3335
|
}
|
|
3391
3336
|
async updateComment(e, t) {
|
|
3392
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3337
|
+
if (!this.destroyed && this.requireCommentWrite()) return pn(this.operationContext(), this.operationCallbacks(), e, t);
|
|
3393
3338
|
}
|
|
3394
3339
|
async deleteComment(e) {
|
|
3395
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3340
|
+
if (!this.destroyed && this.requireCommentWrite()) return mn(this.operationContext(), this.operationCallbacks(), e);
|
|
3396
3341
|
}
|
|
3397
3342
|
async addReply(e, t, n) {
|
|
3398
3343
|
if (this.destroyed || !this.requireCommentWrite()) return;
|
|
3399
3344
|
let { [nt]: r, ...i } = n ?? {};
|
|
3400
|
-
return
|
|
3345
|
+
return hn(this.operationContext(r), this.operationCallbacks(r), e, t, n ? i : void 0);
|
|
3401
3346
|
}
|
|
3402
3347
|
async updateReply(e, t, n, r) {
|
|
3403
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3348
|
+
if (!this.destroyed && this.requireCommentWrite()) return gn(this.operationContext(), e, t, n, r);
|
|
3404
3349
|
}
|
|
3405
3350
|
async deleteReply(e, t) {
|
|
3406
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3351
|
+
if (!this.destroyed && this.requireCommentWrite()) return _n(this.operationContext(), e, t);
|
|
3407
3352
|
}
|
|
3408
3353
|
async resolveComment(e) {
|
|
3409
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3354
|
+
if (!this.destroyed && this.requireCommentWrite()) return vn(this.operationContext(), this.operationCallbacks(), e);
|
|
3410
3355
|
}
|
|
3411
3356
|
async unresolveComment(e) {
|
|
3412
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3357
|
+
if (!this.destroyed && this.requireCommentWrite()) return yn(this.operationContext(), this.operationCallbacks(), e);
|
|
3413
3358
|
}
|
|
3414
3359
|
selectComment(e) {
|
|
3415
|
-
this.destroyed ||
|
|
3360
|
+
this.destroyed || (Cn(this.operationContext(), e), e?.detailLoaded === !1 && !this.localDemo && dn(this.operationContext(), e.id));
|
|
3416
3361
|
}
|
|
3417
3362
|
async completeComment(e) {
|
|
3418
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3363
|
+
if (!this.destroyed && this.requireCommentWrite()) return bn(this.operationContext(), this.operationCallbacks(), e);
|
|
3419
3364
|
}
|
|
3420
3365
|
async reactToComment(e, t, n) {
|
|
3421
3366
|
if (this.destroyed || !this.requireCommentWrite()) return;
|
|
3422
3367
|
let r = `${e}:${n ?? "parent"}`, i = this.sessionRevision, a = async () => {
|
|
3423
|
-
!this.destroyed && i === this.sessionRevision && this.requireCommentWrite() && await
|
|
3368
|
+
!this.destroyed && i === this.sessionRevision && this.requireCommentWrite() && await xn(this.operationContext(), this.operationCallbacks(), e, t, n);
|
|
3424
3369
|
}, o = this.reactionRequests.get(r), s = o ? o.then(a, a) : a();
|
|
3425
3370
|
this.reactionRequests.set(r, s);
|
|
3426
3371
|
try {
|
|
@@ -3430,35 +3375,35 @@ var mi = class extends tt {
|
|
|
3430
3375
|
}
|
|
3431
3376
|
}
|
|
3432
3377
|
async updateCommentPosition(e, t, n) {
|
|
3433
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3378
|
+
if (!this.destroyed && this.requireCommentWrite()) return Sn(this.operationContext(), this.operationCallbacks(), e, t, n);
|
|
3434
3379
|
}
|
|
3435
3380
|
hydrateOfflineQueue() {
|
|
3436
3381
|
if (this.config.persistence === "memory") return;
|
|
3437
|
-
let e =
|
|
3382
|
+
let e = mr(this.config.projectId);
|
|
3438
3383
|
if (e.length > 0) {
|
|
3439
3384
|
let t = this.getInternalState().pendingMutations, n = new Set(t.map((e) => e.id)), r = [...t, ...e.filter((e) => !n.has(e.id))];
|
|
3440
|
-
this.setState({ pendingMutations: r }),
|
|
3385
|
+
this.setState({ pendingMutations: r }), yr(this.ctx), this.getInternalState().isOnline && this.scheduleRetry();
|
|
3441
3386
|
}
|
|
3442
|
-
this.offlinePersistUnsub?.(), this.offlinePersistUnsub = this.select((e) => e.pendingMutations, (e) =>
|
|
3387
|
+
this.offlinePersistUnsub?.(), this.offlinePersistUnsub = this.select((e) => e.pendingMutations, (e) => pr(this.config.projectId, e));
|
|
3443
3388
|
}
|
|
3444
3389
|
shouldQueueMutation(e) {
|
|
3445
|
-
return !this.localDemo &&
|
|
3390
|
+
return !this.localDemo && br(this.getInternalState(), e);
|
|
3446
3391
|
}
|
|
3447
3392
|
queueMutation(e, t, n) {
|
|
3448
|
-
return
|
|
3393
|
+
return xr(this.ctx, () => this.scheduleRetry(), e, t, n);
|
|
3449
3394
|
}
|
|
3450
3395
|
scheduleRetry() {
|
|
3451
|
-
|
|
3396
|
+
Sr(this.ctx, this.retryTimerRef, () => this.processOfflineQueue());
|
|
3452
3397
|
}
|
|
3453
3398
|
async processOfflineQueue() {
|
|
3454
|
-
this.canWriteComments() && await
|
|
3399
|
+
this.canWriteComments() && await Cr(this.operationContext(), this.queueGuard, () => this.scheduleRetry(), (e) => this.executeMutation(e));
|
|
3455
3400
|
}
|
|
3456
3401
|
async executeMutation(e) {
|
|
3457
3402
|
let t = this.operationContext();
|
|
3458
3403
|
try {
|
|
3459
|
-
await
|
|
3404
|
+
await Dr(t, e);
|
|
3460
3405
|
} catch (e) {
|
|
3461
|
-
throw e instanceof
|
|
3406
|
+
throw e instanceof E && e.code === 402 && t.handleError(e), e;
|
|
3462
3407
|
}
|
|
3463
3408
|
}
|
|
3464
3409
|
getPendingMutationCount() {
|
|
@@ -3471,7 +3416,7 @@ var mi = class extends tt {
|
|
|
3471
3416
|
!this.destroyed && this.getInternalState().isAuthenticated && (this.wsManager ? this.wsManager.reconnect() : this.initializeWebSocket());
|
|
3472
3417
|
}
|
|
3473
3418
|
markThreadSeen(e) {
|
|
3474
|
-
if (this.destroyed || typeof e != "string" || !e.trim() || e.length >
|
|
3419
|
+
if (this.destroyed || typeof e != "string" || !e.trim() || e.length > Mr) return;
|
|
3475
3420
|
let t = new Set(this.getInternalState().seenThreadIds);
|
|
3476
3421
|
if (t.add(e), t.size > 1e3) {
|
|
3477
3422
|
let e = Array.from(t);
|
|
@@ -3484,7 +3429,7 @@ var mi = class extends tt {
|
|
|
3484
3429
|
return typeof e != "string" || !e.trim() ? !1 : !this.getInternalState().seenThreadIds.has(e);
|
|
3485
3430
|
}
|
|
3486
3431
|
setPanelView(e) {
|
|
3487
|
-
!this.destroyed &&
|
|
3432
|
+
!this.destroyed && Ar.has(e) && this.setState({ panelView: e });
|
|
3488
3433
|
}
|
|
3489
3434
|
toggleShortcutsOverlay() {
|
|
3490
3435
|
this.destroyed || this.setState({ isShortcutsOverlayVisible: !this.getInternalState().isShortcutsOverlayVisible });
|
|
@@ -3531,7 +3476,7 @@ var mi = class extends tt {
|
|
|
3531
3476
|
else if (this.getInternalState().isAuthenticated && n.length <= 256 && this.deepLinkRequest !== e) {
|
|
3532
3477
|
this.deepLinkRequest = e;
|
|
3533
3478
|
let t = this.sessionRevision;
|
|
3534
|
-
this.apiClient.getComment(n).then(async (r) => {
|
|
3479
|
+
this.apiClient.getComment(n, { repliesLimit: 50 }).then(async (r) => {
|
|
3535
3480
|
if (this.destroyed || t !== this.sessionRevision || window.location.hash !== e || r.id !== n) return;
|
|
3536
3481
|
let i = this.getInternalState().activeBranch;
|
|
3537
3482
|
i && i !== r.branch && await this.setBranch(r.branch ?? null), !(this.destroyed || t !== this.sessionRevision || window.location.hash !== e) && (this.setState({
|
|
@@ -3548,10 +3493,10 @@ var mi = class extends tt {
|
|
|
3548
3493
|
}
|
|
3549
3494
|
}
|
|
3550
3495
|
async createHighlight(e, t) {
|
|
3551
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3496
|
+
if (!this.destroyed && this.requireCommentWrite()) return wn(this.operationContext(), this.operationCallbacks(), this.activeMutations, e, t);
|
|
3552
3497
|
}
|
|
3553
3498
|
async createDrawing(e, t, n) {
|
|
3554
|
-
if (!this.destroyed && this.requireCommentWrite()) return
|
|
3499
|
+
if (!this.destroyed && this.requireCommentWrite()) return Tn(this.operationContext(), this.operationCallbacks(), this.activeMutations, e, t, n);
|
|
3555
3500
|
}
|
|
3556
3501
|
setActiveDrawing(e) {
|
|
3557
3502
|
this.destroyed || this.setState({ activeDrawing: e });
|
|
@@ -3560,23 +3505,42 @@ var mi = class extends tt {
|
|
|
3560
3505
|
!this.destroyed && this.requireCommentWrite() && this.wsManager?.sendDrawingStroke(e);
|
|
3561
3506
|
}
|
|
3562
3507
|
async captureScreenshot(e) {
|
|
3563
|
-
|
|
3508
|
+
if (this.destroyed) return null;
|
|
3509
|
+
let { captureScreenshot: t } = await import("./screenshot-BIuEaRiu.js");
|
|
3510
|
+
return this.destroyed ? null : t(this.ctx, this.screenshotProvider, e);
|
|
3564
3511
|
}
|
|
3565
3512
|
async uploadScreenshot(e, t, n) {
|
|
3566
|
-
|
|
3513
|
+
if (this.destroyed || !this.requireCommentWrite()) return null;
|
|
3514
|
+
let r = this.operationContext(), { uploadScreenshot: i } = await import("./screenshot-BIuEaRiu.js");
|
|
3515
|
+
return this.destroyed || r.isCurrent?.() === !1 || !this.requireCommentWrite() ? null : i(r, e, t, n);
|
|
3567
3516
|
}
|
|
3568
3517
|
setActiveScreenshot(e) {
|
|
3569
3518
|
this.destroyed || this.setState({ activeScreenshot: e });
|
|
3570
3519
|
}
|
|
3571
3520
|
async uploadFiles(e, t) {
|
|
3572
|
-
|
|
3521
|
+
if (this.destroyed || !this.requireCommentWrite()) return [];
|
|
3522
|
+
let n = this.operationContext(), { uploadFiles: r } = await import("./screenshot-BIuEaRiu.js");
|
|
3523
|
+
return this.destroyed || n.isCurrent?.() === !1 || !this.requireCommentWrite() ? [] : r(n, e, t);
|
|
3573
3524
|
}
|
|
3574
3525
|
getAgentContext(e) {
|
|
3575
3526
|
return O(this.getInternalState(), e);
|
|
3576
3527
|
}
|
|
3577
3528
|
async getAgentContextAsync(e) {
|
|
3578
|
-
let t =
|
|
3579
|
-
|
|
3529
|
+
let t = this.getInternalState(), n = O(t, e);
|
|
3530
|
+
if (!this.localDemo && t.isAuthenticated) {
|
|
3531
|
+
let r = new Set(n.comments.map((e) => e.id)), i = t.comments.filter((e) => r.has(e.id) && e.detailLoaded === !1), a = /* @__PURE__ */ new Map(), o = this.sessionRevision;
|
|
3532
|
+
for (let e = 0; e < i.length; e += 4) {
|
|
3533
|
+
let t = await Promise.all(i.slice(e, e + 4).map((e) => this.apiClient.getComment(e.id, { repliesLimit: 12 })));
|
|
3534
|
+
if (this.destroyed || o !== this.sessionRevision || !this.getInternalState().isAuthenticated) throw new E("unauthorized", "Sign in again to copy feedback.", 401);
|
|
3535
|
+
for (let e of t) a.set(e.id, e);
|
|
3536
|
+
}
|
|
3537
|
+
a.size && (n = O({
|
|
3538
|
+
...t,
|
|
3539
|
+
comments: t.comments.map((e) => a.get(e.id) ?? e)
|
|
3540
|
+
}, e));
|
|
3541
|
+
}
|
|
3542
|
+
let r = this.localDemo?.getRevision(), i = await Ue(n);
|
|
3543
|
+
return this.localDemo?.checkExpiry(), this.localDemo && r !== this.localDemo.getRevision() ? O(this.getInternalState(), e) : i;
|
|
3580
3544
|
}
|
|
3581
3545
|
formatAgentContext(e) {
|
|
3582
3546
|
return k(this.getAgentContext(e));
|
|
@@ -3594,7 +3558,7 @@ var mi = class extends tt {
|
|
|
3594
3558
|
}
|
|
3595
3559
|
async grabElement(e, t) {
|
|
3596
3560
|
if (this.destroyed) return null;
|
|
3597
|
-
let { grabElement: n } = await import("./dev-grab-
|
|
3561
|
+
let { grabElement: n } = await import("./dev-grab-BYsCpsGI.js");
|
|
3598
3562
|
if (this.destroyed) return null;
|
|
3599
3563
|
let r = await n(e, this.ctx, this.screenshotProvider, t);
|
|
3600
3564
|
return this.destroyed ? null : (r && this.emit("agent:element-grabbed", {
|
|
@@ -3604,7 +3568,7 @@ var mi = class extends tt {
|
|
|
3604
3568
|
}
|
|
3605
3569
|
async grabElements(e, t) {
|
|
3606
3570
|
if (this.destroyed) return null;
|
|
3607
|
-
let { grabElements: n } = await import("./dev-grab-
|
|
3571
|
+
let { grabElements: n } = await import("./dev-grab-BYsCpsGI.js");
|
|
3608
3572
|
if (this.destroyed) return null;
|
|
3609
3573
|
let r = await n(e, this.ctx, this.screenshotProvider, t);
|
|
3610
3574
|
return this.destroyed ? null : (r && this.emit("agent:elements-grabbed", { count: r.results.length }), r);
|
|
@@ -3618,7 +3582,7 @@ var mi = class extends tt {
|
|
|
3618
3582
|
}
|
|
3619
3583
|
}
|
|
3620
3584
|
handleToggleRequest() {
|
|
3621
|
-
this.destroyed || A() ||
|
|
3585
|
+
this.destroyed || A() || Ln(this.getInternalState(), this.kbdCallbacks);
|
|
3622
3586
|
}
|
|
3623
3587
|
handleKeyboardShortcuts(e) {
|
|
3624
3588
|
if (!(this.destroyed || A())) {
|
|
@@ -3627,7 +3591,7 @@ var mi = class extends tt {
|
|
|
3627
3591
|
let t = e.composedPath()[0];
|
|
3628
3592
|
if (t instanceof Element && t.getRootNode() === document && t.closest("[data-commentkit-ui], [data-commentkit-ignore]")) return;
|
|
3629
3593
|
}
|
|
3630
|
-
|
|
3594
|
+
Rn(e, this.getInternalState(), this.kbdCallbacks);
|
|
3631
3595
|
}
|
|
3632
3596
|
}
|
|
3633
3597
|
matchesHoldKey(e) {
|
|
@@ -3641,7 +3605,7 @@ var mi = class extends tt {
|
|
|
3641
3605
|
};
|
|
3642
3606
|
}
|
|
3643
3607
|
initializeWebSocket() {
|
|
3644
|
-
this.destroyed || this.localDemo ||
|
|
3608
|
+
this.destroyed || this.localDemo || Or().then((e) => {
|
|
3645
3609
|
this.destroyed || this.getInternalState().isAuthenticated && (this.syncRealtimeRefs(), e.initializeWebSocket(this.ctx, this.realtimeRefs, {
|
|
3646
3610
|
capture: () => this.commentsRequestContext(this.commentsFetchRevision),
|
|
3647
3611
|
subscribe: (e) => this.on("state:changed", e)
|
|
@@ -3678,7 +3642,7 @@ var mi = class extends tt {
|
|
|
3678
3642
|
this.removeMouseMoveListener(), this.syncRealtimeRefs();
|
|
3679
3643
|
}
|
|
3680
3644
|
destroy() {
|
|
3681
|
-
this.destroyed || (this.destroyed = !0, this.initialAuthToken = void 0,
|
|
3645
|
+
this.destroyed || (this.destroyed = !0, this.initialAuthToken = void 0, kr && (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());
|
|
3682
3646
|
}
|
|
3683
3647
|
};
|
|
3684
|
-
export {
|
|
3648
|
+
export { ve as _, yt as a, T 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, Nr as n, ct as o, Xe as p, F as r, j as s, Lr as t, A as u, E as v, be as x, ye as y };
|