makethisbetter 1.1.2 → 1.2.0
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/LICENSE +21 -62
- package/README.md +4 -4
- package/dist/context/frustration.d.ts +1 -1
- package/dist/context/frustration.d.ts.map +1 -1
- package/dist/makethisbetter.cjs.js +13 -27
- package/dist/makethisbetter.cjs.js.map +1 -1
- package/dist/makethisbetter.esm.js +222 -247
- package/dist/makethisbetter.esm.js.map +1 -1
- package/dist/makethisbetter.js +16 -30
- package/dist/makethisbetter.js.map +1 -1
- package/dist/popup/clarify.d.ts +1 -0
- package/dist/popup/clarify.d.ts.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/widget/controller.d.ts +0 -1
- package/dist/widget/controller.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/context/frustration.test.ts +2 -3
- package/src/context/frustration.ts +0 -1
- package/src/popup/clarify.test.ts +103 -0
- package/src/popup/clarify.ts +11 -3
- package/src/types.ts +2 -1
- package/src/widget/controller.test.ts +37 -0
- package/src/widget/controller.ts +12 -19
- package/src/widget/pet.test.ts +34 -32
|
@@ -33,45 +33,8 @@ class nt {
|
|
|
33
33
|
this.el.removeEventListener("click", this.onClick), this.el.remove();
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
width: "3.5",
|
|
39
|
-
linecap: "round",
|
|
40
|
-
linejoin: "round",
|
|
41
|
-
filter: "drop-shadow(0 1px 2px rgba(5,150,105,0.35))"
|
|
42
|
-
};
|
|
43
|
-
class ot {
|
|
44
|
-
constructor(t, e, s) {
|
|
45
|
-
this.onClick = s, this.el = t.el("div", "mtb-pet"), this.el.innerHTML = this.buildSVG(), this.el.setAttribute("role", "button"), this.el.setAttribute("aria-label", e.tab), this.el.tabIndex = 0, this.bubble = t.el("div", "mtb-pet-bubble"), this.bubble.textContent = e.pet.bubble, this.el.appendChild(this.bubble), this.el.addEventListener("click", this.onClick), this.el.addEventListener("keydown", (r) => {
|
|
46
|
-
(r.key === "Enter" || r.key === " ") && (r.preventDefault(), this.onClick());
|
|
47
|
-
}), t.append(this.el);
|
|
48
|
-
}
|
|
49
|
-
buildSVG() {
|
|
50
|
-
return `<svg class="mtb-pet-svg" width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
51
|
-
<circle cx="24" cy="28" r="16" fill="${x}"/>
|
|
52
|
-
<circle cx="24" cy="28" r="14" fill="#10b981"/>
|
|
53
|
-
<circle cx="19" cy="25" r="3" fill="#fff"/>
|
|
54
|
-
<circle cx="29" cy="25" r="3" fill="#fff"/>
|
|
55
|
-
<circle cx="20" cy="24.5" r="1.5" fill="#064e3b"/>
|
|
56
|
-
<circle cx="30" cy="24.5" r="1.5" fill="#064e3b"/>
|
|
57
|
-
<ellipse cx="19.5" cy="23.5" rx="0.8" ry="0.6" fill="#fff" opacity="0.7"/>
|
|
58
|
-
<ellipse cx="29.5" cy="23.5" rx="0.8" ry="0.6" fill="#fff" opacity="0.7"/>
|
|
59
|
-
<path d="M20 31 Q24 34 28 31" stroke="#064e3b" stroke-width="1.5" stroke-linecap="round" fill="none"/>
|
|
60
|
-
<circle cx="15" cy="30" r="2.5" fill="${x}" opacity="0.4"/>
|
|
61
|
-
<circle cx="33" cy="30" r="2.5" fill="${x}" opacity="0.4"/>
|
|
62
|
-
<path d="M14 17 Q16 12 20 15" stroke="#10b981" stroke-width="2" stroke-linecap="round" fill="none"/>
|
|
63
|
-
<path d="M34 17 Q32 12 28 15" stroke="#10b981" stroke-width="2" stroke-linecap="round" fill="none"/>
|
|
64
|
-
</svg>`;
|
|
65
|
-
}
|
|
66
|
-
setActive(t) {
|
|
67
|
-
this.el.classList.toggle("active", t), t && this.bubble.classList.add("hidden");
|
|
68
|
-
}
|
|
69
|
-
destroy() {
|
|
70
|
-
this.el.removeEventListener("click", this.onClick), this.el.remove();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const at = 8e3;
|
|
74
|
-
class lt {
|
|
36
|
+
const ot = 8e3;
|
|
37
|
+
class at {
|
|
75
38
|
constructor(t, e, s) {
|
|
76
39
|
this.el = t.el("div", "mtb-frustration-prompt"), this.el.innerHTML = `
|
|
77
40
|
<div class="mtb-frustration-icon">⚠️</div>
|
|
@@ -80,13 +43,13 @@ class lt {
|
|
|
80
43
|
<button class="mtb-frustration-tell">${e.frustration.action}</button>
|
|
81
44
|
<button class="mtb-frustration-dismiss">${e.frustration.dismiss}</button>
|
|
82
45
|
</div>
|
|
83
|
-
`, this.el.querySelector(".mtb-frustration-tell").addEventListener("click", s.onTell), this.el.querySelector(".mtb-frustration-dismiss").addEventListener("click", s.onDismiss), t.append(this.el), setTimeout(s.onDismiss,
|
|
46
|
+
`, this.el.querySelector(".mtb-frustration-tell").addEventListener("click", s.onTell), this.el.querySelector(".mtb-frustration-dismiss").addEventListener("click", s.onDismiss), t.append(this.el), setTimeout(s.onDismiss, ot);
|
|
84
47
|
}
|
|
85
48
|
destroy() {
|
|
86
49
|
this.el.remove();
|
|
87
50
|
}
|
|
88
51
|
}
|
|
89
|
-
class
|
|
52
|
+
class lt {
|
|
90
53
|
constructor(t, e, s, r) {
|
|
91
54
|
this.currentMode = "markup", this.messages = e, this.el = t.el("div", "mtb-toolbar"), this.el.innerHTML = this.buildHTML(e), t.append(this.el), this.hintEl = this.el.querySelector(".mtb-toolbar-hint"), this.markupBtn = this.el.querySelector(".mtb-toolbar-mode-markup"), this.recordBtn = this.el.querySelector(".mtb-toolbar-mode-record"), this.markupBtn.addEventListener("click", () => {
|
|
92
55
|
this.setMode("markup"), r?.("markup");
|
|
@@ -123,7 +86,7 @@ class ct {
|
|
|
123
86
|
this.el.remove();
|
|
124
87
|
}
|
|
125
88
|
}
|
|
126
|
-
class
|
|
89
|
+
class ct {
|
|
127
90
|
constructor(t, e) {
|
|
128
91
|
this.onMouseDown = e.onMouseDown, this.onMouseMove = e.onMouseMove, this.onMouseUp = e.onMouseUp, this.onMouseLeave = e.onMouseLeave, this.overlayEl = t.el("div", "mtb-overlay"), this.overlayEl.addEventListener("mousedown", this.onMouseDown), this.overlayEl.addEventListener("mousemove", this.onMouseMove), this.overlayEl.addEventListener("mouseup", this.onMouseUp), this.overlayEl.addEventListener("mouseleave", this.onMouseLeave), t.append(this.overlayEl), this.dimEl = t.el("div", "mtb-dim"), t.append(this.dimEl);
|
|
129
92
|
}
|
|
@@ -131,7 +94,7 @@ class ht {
|
|
|
131
94
|
this.overlayEl.removeEventListener("mousedown", this.onMouseDown), this.overlayEl.removeEventListener("mousemove", this.onMouseMove), this.overlayEl.removeEventListener("mouseup", this.onMouseUp), this.overlayEl.removeEventListener("mouseleave", this.onMouseLeave), this.overlayEl.remove(), this.dimEl.remove();
|
|
132
95
|
}
|
|
133
96
|
}
|
|
134
|
-
class
|
|
97
|
+
class ht {
|
|
135
98
|
constructor(t) {
|
|
136
99
|
this.highlightEl = t.el("div", "mtb-highlight"), this.hide(), t.append(this.highlightEl);
|
|
137
100
|
}
|
|
@@ -146,7 +109,7 @@ class dt {
|
|
|
146
109
|
this.highlightEl.remove();
|
|
147
110
|
}
|
|
148
111
|
}
|
|
149
|
-
function
|
|
112
|
+
function dt(i) {
|
|
150
113
|
if (i instanceof HTMLElement) {
|
|
151
114
|
const t = i.getAttribute("aria-label");
|
|
152
115
|
if (t) return t;
|
|
@@ -163,7 +126,7 @@ function ut(i) {
|
|
|
163
126
|
}
|
|
164
127
|
return i.tagName.toLowerCase();
|
|
165
128
|
}
|
|
166
|
-
function
|
|
129
|
+
function ut(i) {
|
|
167
130
|
const t = [];
|
|
168
131
|
let e = i;
|
|
169
132
|
for (; e && e !== document.body && t.length < 5; ) {
|
|
@@ -188,7 +151,7 @@ function pt(i) {
|
|
|
188
151
|
}
|
|
189
152
|
return t.join(" > ");
|
|
190
153
|
}
|
|
191
|
-
class
|
|
154
|
+
class pt {
|
|
192
155
|
constructor(t) {
|
|
193
156
|
this.pins = [], this.shadow = t;
|
|
194
157
|
}
|
|
@@ -204,12 +167,19 @@ class ft {
|
|
|
204
167
|
this.clearAll();
|
|
205
168
|
}
|
|
206
169
|
}
|
|
207
|
-
|
|
170
|
+
const D = "#059669", x = {
|
|
171
|
+
color: D,
|
|
172
|
+
width: "3.5",
|
|
173
|
+
linecap: "round",
|
|
174
|
+
linejoin: "round",
|
|
175
|
+
filter: "drop-shadow(0 1px 2px rgba(5,150,105,0.35))"
|
|
176
|
+
};
|
|
177
|
+
class ft {
|
|
208
178
|
constructor(t, e) {
|
|
209
179
|
this.path = null, this.points = [], this.isDrawing = !1, this.onDrawComplete = e, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.setAttribute("class", "mtb-draw-svg"), t.append(this.svg);
|
|
210
180
|
}
|
|
211
181
|
startDraw(t, e) {
|
|
212
|
-
this.isDrawing = !0, this.points = [[t, e]], this.path = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.path.setAttribute("fill", "none"), this.path.setAttribute("stroke",
|
|
182
|
+
this.isDrawing = !0, this.points = [[t, e]], this.path = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.path.setAttribute("fill", "none"), this.path.setAttribute("stroke", x.color), this.path.setAttribute("stroke-width", x.width), this.path.setAttribute("stroke-linecap", x.linecap), this.path.setAttribute("stroke-linejoin", x.linejoin), this.path.setAttribute("style", `filter:${x.filter}`), this.svg.appendChild(this.path);
|
|
213
183
|
}
|
|
214
184
|
continueDraw(t, e) {
|
|
215
185
|
!this.isDrawing || !this.path || (this.points.push([t, e]), this.path.setAttribute("d", this.buildPathD()));
|
|
@@ -259,12 +229,12 @@ class mt {
|
|
|
259
229
|
this.svg.remove();
|
|
260
230
|
}
|
|
261
231
|
}
|
|
262
|
-
const
|
|
232
|
+
const mt = 5;
|
|
263
233
|
class H {
|
|
264
234
|
constructor(t, e, s) {
|
|
265
|
-
this.messages = e, this.onReady = s, this.pinCount = 0, this.interactionActive = !0, this.pendingHighlightFrame = null, this.lastMoveX = 0, this.lastMoveY = 0, this.highlighter = new
|
|
235
|
+
this.messages = e, this.onReady = s, this.pinCount = 0, this.interactionActive = !0, this.pendingHighlightFrame = null, this.lastMoveX = 0, this.lastMoveY = 0, this.highlighter = new ht(t), this.pinMarker = new pt(t), this.drawLayer = new ft(t, (r) => {
|
|
266
236
|
this.onReady(r, this.messages.annotation.drawing);
|
|
267
|
-
}), this.overlay = new
|
|
237
|
+
}), this.overlay = new ct(t, {
|
|
268
238
|
onMouseDown: (r) => this.handleMouseDown(r),
|
|
269
239
|
onMouseMove: (r) => this.handleMouseMove(r),
|
|
270
240
|
onMouseUp: (r) => this.handleMouseUp(r),
|
|
@@ -295,16 +265,16 @@ class H {
|
|
|
295
265
|
}
|
|
296
266
|
handleMouseUp(t) {
|
|
297
267
|
if (!this.drawLayer.isCurrentlyDrawing()) return;
|
|
298
|
-
if (this.drawLayer.getPointCount() >=
|
|
268
|
+
if (this.drawLayer.getPointCount() >= mt) {
|
|
299
269
|
this.drawLayer.endDraw();
|
|
300
270
|
return;
|
|
301
271
|
}
|
|
302
272
|
this.drawLayer.cancelCurrentDraw();
|
|
303
|
-
const e = $(t.clientX, t.clientY), s = e ?
|
|
273
|
+
const e = $(t.clientX, t.clientY), s = e ? dt(e) : this.messages.annotation.element, r = {
|
|
304
274
|
type: "pin",
|
|
305
275
|
x: t.clientX,
|
|
306
276
|
y: t.clientY,
|
|
307
|
-
targetSelector: e ?
|
|
277
|
+
targetSelector: e ? ut(e) : void 0,
|
|
308
278
|
targetText: e?.textContent?.trim().slice(0, 200) ?? "",
|
|
309
279
|
targetName: s
|
|
310
280
|
};
|
|
@@ -320,7 +290,7 @@ class H {
|
|
|
320
290
|
function $(i, t) {
|
|
321
291
|
return document.elementsFromPoint(i, t).find((e) => e.id !== "mtb-widget-host") ?? null;
|
|
322
292
|
}
|
|
323
|
-
class
|
|
293
|
+
class bt {
|
|
324
294
|
constructor(t, e) {
|
|
325
295
|
this.loading = !1, this.onSubmit = e.onSubmit, this.onClose = e.onClose, this.submitLabel = e.messages.popup.submit, this.el = t.el("div", "mtb-popup"), this.el.innerHTML = this.buildHTML(e), t.append(this.el), this.textarea = this.el.querySelector(".mtb-textarea"), this.submitBtn = this.el.querySelector(".mtb-submit-btn"), this.positionPopup(e.x, e.y), this.bindEvents(e.messages), this.textarea.focus();
|
|
326
296
|
}
|
|
@@ -397,8 +367,8 @@ class gt {
|
|
|
397
367
|
function m(i) {
|
|
398
368
|
return i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
399
369
|
}
|
|
400
|
-
const
|
|
401
|
-
class
|
|
370
|
+
const gt = 2e3, yt = 2e3;
|
|
371
|
+
class xt {
|
|
402
372
|
constructor(t, e) {
|
|
403
373
|
this.pollTimer = null, this.doneTimer = null, this.sending = !1, this.destroyed = !1, this.feedbackId = e.feedbackId, this.apiClient = e.apiClient, this.onDone = e.onDone, this.el = t.el("div", "mtb-clarify"), this.el.style.right = "20px", this.el.style.bottom = "20px", this.el.innerHTML = this.buildHTML(e.messages), t.append(this.el), this.messagesEl = this.el.querySelector(".mtb-clarify-messages"), this.inputEl = this.el.querySelector(".mtb-clarify-input"), this.sendBtn = this.el.querySelector(".mtb-clarify-send"), this.bindEvents(e.messages), this.startConversation();
|
|
404
374
|
}
|
|
@@ -406,7 +376,7 @@ class wt {
|
|
|
406
376
|
return `
|
|
407
377
|
<div class="mtb-clarify-header">
|
|
408
378
|
<div class="mtb-clarify-icon">
|
|
409
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="${
|
|
379
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="${D}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
410
380
|
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
|
|
411
381
|
</svg>
|
|
412
382
|
</div>
|
|
@@ -426,7 +396,7 @@ class wt {
|
|
|
426
396
|
const e = this.inputEl.value.trim().length > 0;
|
|
427
397
|
this.sendBtn.disabled = !e || this.sending;
|
|
428
398
|
}), this.inputEl.addEventListener("keydown", (e) => {
|
|
429
|
-
e.key === "Enter" && (e.preventDefault(), this.sendMessage(t));
|
|
399
|
+
e.isComposing || e.keyCode === 229 || e.key === "Enter" && (e.preventDefault(), this.sendMessage(t));
|
|
430
400
|
}), this.sendBtn.addEventListener("click", () => this.sendMessage(t));
|
|
431
401
|
}
|
|
432
402
|
async startConversation() {
|
|
@@ -434,7 +404,7 @@ class wt {
|
|
|
434
404
|
try {
|
|
435
405
|
const t = await this.apiClient.startClarification(this.feedbackId);
|
|
436
406
|
if (this.destroyed) return;
|
|
437
|
-
this.
|
|
407
|
+
this.renderConversation(t.messages, t.done), t.done ? this.handleDone() : this.startPolling();
|
|
438
408
|
} catch {
|
|
439
409
|
if (this.destroyed) return;
|
|
440
410
|
this.onDone();
|
|
@@ -447,7 +417,7 @@ class wt {
|
|
|
447
417
|
try {
|
|
448
418
|
const s = await this.apiClient.startClarification(this.feedbackId, e);
|
|
449
419
|
if (this.destroyed) return;
|
|
450
|
-
this.
|
|
420
|
+
this.renderConversation(s.messages, s.done), s.done ? this.handleDone() : this.startPolling();
|
|
451
421
|
} catch {
|
|
452
422
|
if (this.destroyed) return;
|
|
453
423
|
this.onDone();
|
|
@@ -457,7 +427,7 @@ class wt {
|
|
|
457
427
|
}
|
|
458
428
|
}
|
|
459
429
|
startPolling() {
|
|
460
|
-
this.stopPolling(), this.pollTimer = setInterval(() => this.poll(),
|
|
430
|
+
this.stopPolling(), this.pollTimer = setInterval(() => this.poll(), gt);
|
|
461
431
|
}
|
|
462
432
|
stopPolling() {
|
|
463
433
|
this.pollTimer !== null && (clearInterval(this.pollTimer), this.pollTimer = null);
|
|
@@ -466,7 +436,7 @@ class wt {
|
|
|
466
436
|
try {
|
|
467
437
|
const t = await this.apiClient.getClarification(this.feedbackId);
|
|
468
438
|
if (this.destroyed) return;
|
|
469
|
-
this.
|
|
439
|
+
this.renderConversation(t.messages, t.done), t.done && (this.stopPolling(), this.handleDone());
|
|
470
440
|
} catch {
|
|
471
441
|
if (this.destroyed) return;
|
|
472
442
|
this.stopPolling();
|
|
@@ -475,7 +445,12 @@ class wt {
|
|
|
475
445
|
handleDone() {
|
|
476
446
|
this.inputEl.disabled = !0, this.sendBtn.disabled = !0, this.doneTimer = setTimeout(() => {
|
|
477
447
|
this.destroyed || this.onDone();
|
|
478
|
-
},
|
|
448
|
+
}, yt);
|
|
449
|
+
}
|
|
450
|
+
renderConversation(t, e) {
|
|
451
|
+
this.renderMessages(t);
|
|
452
|
+
const s = t[t.length - 1];
|
|
453
|
+
!e && (!s || s.role === "user") && this.showThinking();
|
|
479
454
|
}
|
|
480
455
|
renderMessages(t) {
|
|
481
456
|
this.messagesEl.innerHTML = "";
|
|
@@ -498,14 +473,14 @@ class wt {
|
|
|
498
473
|
function T(i) {
|
|
499
474
|
return i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
500
475
|
}
|
|
501
|
-
const
|
|
502
|
-
class
|
|
476
|
+
const wt = 5e3;
|
|
477
|
+
class kt {
|
|
503
478
|
constructor(t, e, s, r) {
|
|
504
479
|
this.el = t.el("div", "mtb-success"), this.el.style.right = "20px", this.el.style.bottom = "20px";
|
|
505
480
|
const n = r ? `<button class="mtb-view-feedback-link">${e.success.view_feedback}</button>` : "";
|
|
506
481
|
this.el.innerHTML = `
|
|
507
482
|
<div class="mtb-success-icon">
|
|
508
|
-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="${
|
|
483
|
+
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="${D}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
509
484
|
<polyline points="20 6 9 17 4 12"/>
|
|
510
485
|
</svg>
|
|
511
486
|
</div>
|
|
@@ -513,13 +488,13 @@ class vt {
|
|
|
513
488
|
<div class="mtb-success-msg">${e.success.message}</div>
|
|
514
489
|
${n}
|
|
515
490
|
<button class="mtb-close-link">${e.success.close}</button>
|
|
516
|
-
`, t.append(this.el), this.el.querySelector(".mtb-close-link").addEventListener("click", s), r && this.el.querySelector(".mtb-view-feedback-link").addEventListener("click", r), setTimeout(() => s(),
|
|
491
|
+
`, t.append(this.el), this.el.querySelector(".mtb-close-link").addEventListener("click", s), r && this.el.querySelector(".mtb-view-feedback-link").addEventListener("click", r), setTimeout(() => s(), wt);
|
|
517
492
|
}
|
|
518
493
|
destroy() {
|
|
519
494
|
this.el.remove();
|
|
520
495
|
}
|
|
521
496
|
}
|
|
522
|
-
function
|
|
497
|
+
function vt(i, t) {
|
|
523
498
|
if (i.match(/^[a-z]+:\/\//i))
|
|
524
499
|
return i;
|
|
525
500
|
if (i.match(/^\/\//))
|
|
@@ -551,19 +526,19 @@ function S(i, t) {
|
|
|
551
526
|
const s = (i.ownerDocument.defaultView || window).getComputedStyle(i).getPropertyValue(t);
|
|
552
527
|
return s ? parseFloat(s.replace("px", "")) : 0;
|
|
553
528
|
}
|
|
554
|
-
function
|
|
529
|
+
function Et(i) {
|
|
555
530
|
const t = S(i, "border-left-width"), e = S(i, "border-right-width");
|
|
556
531
|
return i.clientWidth + t + e;
|
|
557
532
|
}
|
|
558
|
-
function
|
|
533
|
+
function Ct(i) {
|
|
559
534
|
const t = S(i, "border-top-width"), e = S(i, "border-bottom-width");
|
|
560
535
|
return i.clientHeight + t + e;
|
|
561
536
|
}
|
|
562
537
|
function Y(i, t = {}) {
|
|
563
|
-
const e = t.width ||
|
|
538
|
+
const e = t.width || Et(i), s = t.height || Ct(i);
|
|
564
539
|
return { width: e, height: s };
|
|
565
540
|
}
|
|
566
|
-
function
|
|
541
|
+
function Mt() {
|
|
567
542
|
let i, t;
|
|
568
543
|
try {
|
|
569
544
|
t = process;
|
|
@@ -576,7 +551,7 @@ const d = 16384;
|
|
|
576
551
|
function Tt(i) {
|
|
577
552
|
(i.width > d || i.height > d) && (i.width > d && i.height > d ? i.width > i.height ? (i.height *= d / i.width, i.width = d) : (i.width *= d / i.height, i.height = d) : i.width > d ? (i.height *= d / i.width, i.width = d) : (i.width *= d / i.height, i.height = d));
|
|
578
553
|
}
|
|
579
|
-
function
|
|
554
|
+
function E(i) {
|
|
580
555
|
return new Promise((t, e) => {
|
|
581
556
|
const s = new Image();
|
|
582
557
|
s.onload = () => {
|
|
@@ -586,12 +561,12 @@ function C(i) {
|
|
|
586
561
|
}, s.onerror = e, s.crossOrigin = "anonymous", s.decoding = "async", s.src = i;
|
|
587
562
|
});
|
|
588
563
|
}
|
|
589
|
-
async function
|
|
564
|
+
async function Lt(i) {
|
|
590
565
|
return Promise.resolve().then(() => new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then((t) => `data:image/svg+xml;charset=utf-8,${t}`);
|
|
591
566
|
}
|
|
592
|
-
async function
|
|
567
|
+
async function At(i, t, e) {
|
|
593
568
|
const s = "http://www.w3.org/2000/svg", r = document.createElementNS(s, "svg"), n = document.createElementNS(s, "foreignObject");
|
|
594
|
-
return r.setAttribute("width", `${t}`), r.setAttribute("height", `${e}`), r.setAttribute("viewBox", `0 0 ${t} ${e}`), n.setAttribute("width", "100%"), n.setAttribute("height", "100%"), n.setAttribute("x", "0"), n.setAttribute("y", "0"), n.setAttribute("externalResourcesRequired", "true"), r.appendChild(n), n.appendChild(i),
|
|
569
|
+
return r.setAttribute("width", `${t}`), r.setAttribute("height", `${e}`), r.setAttribute("viewBox", `0 0 ${t} ${e}`), n.setAttribute("width", "100%"), n.setAttribute("height", "100%"), n.setAttribute("x", "0"), n.setAttribute("y", "0"), n.setAttribute("externalResourcesRequired", "true"), r.appendChild(n), n.appendChild(i), Lt(r);
|
|
595
570
|
}
|
|
596
571
|
const h = (i, t) => {
|
|
597
572
|
if (i instanceof t)
|
|
@@ -599,18 +574,18 @@ const h = (i, t) => {
|
|
|
599
574
|
const e = Object.getPrototypeOf(i);
|
|
600
575
|
return e === null ? !1 : e.constructor.name === t.name || h(e, t);
|
|
601
576
|
};
|
|
602
|
-
function
|
|
577
|
+
function Rt(i) {
|
|
603
578
|
const t = i.getPropertyValue("content");
|
|
604
579
|
return `${i.cssText} content: '${t.replace(/'|"/g, "")}';`;
|
|
605
580
|
}
|
|
606
|
-
function
|
|
581
|
+
function Dt(i, t) {
|
|
607
582
|
return V(t).map((e) => {
|
|
608
583
|
const s = i.getPropertyValue(e), r = i.getPropertyPriority(e);
|
|
609
584
|
return `${e}: ${s}${r ? " !important" : ""};`;
|
|
610
585
|
}).join(" ");
|
|
611
586
|
}
|
|
612
|
-
function
|
|
613
|
-
const r = `.${i}:${t}`, n = e.cssText ?
|
|
587
|
+
function Pt(i, t, e, s) {
|
|
588
|
+
const r = `.${i}:${t}`, n = e.cssText ? Rt(e) : Dt(e, s);
|
|
614
589
|
return document.createTextNode(`${r}{${n}}`);
|
|
615
590
|
}
|
|
616
591
|
function I(i, t, e, s) {
|
|
@@ -624,12 +599,12 @@ function I(i, t, e, s) {
|
|
|
624
599
|
return;
|
|
625
600
|
}
|
|
626
601
|
const a = document.createElement("style");
|
|
627
|
-
a.appendChild(
|
|
602
|
+
a.appendChild(Pt(o, e, r, s)), t.appendChild(a);
|
|
628
603
|
}
|
|
629
|
-
function
|
|
604
|
+
function _t(i, t, e) {
|
|
630
605
|
I(i, t, ":before", e), I(i, t, ":after", e);
|
|
631
606
|
}
|
|
632
|
-
const O = "application/font-woff", F = "image/jpeg",
|
|
607
|
+
const O = "application/font-woff", F = "image/jpeg", Ht = {
|
|
633
608
|
woff: O,
|
|
634
609
|
woff2: O,
|
|
635
610
|
ttf: "application/font-truetype",
|
|
@@ -642,21 +617,21 @@ const O = "application/font-woff", F = "image/jpeg", $t = {
|
|
|
642
617
|
svg: "image/svg+xml",
|
|
643
618
|
webp: "image/webp"
|
|
644
619
|
};
|
|
645
|
-
function
|
|
620
|
+
function $t(i) {
|
|
646
621
|
const t = /\.([^./]*?)$/g.exec(i);
|
|
647
622
|
return t ? t[1] : "";
|
|
648
623
|
}
|
|
649
|
-
function
|
|
650
|
-
const t =
|
|
651
|
-
return
|
|
624
|
+
function P(i) {
|
|
625
|
+
const t = $t(i).toLowerCase();
|
|
626
|
+
return Ht[t] || "";
|
|
652
627
|
}
|
|
653
|
-
function
|
|
628
|
+
function It(i) {
|
|
654
629
|
return i.split(/,/)[1];
|
|
655
630
|
}
|
|
656
|
-
function
|
|
631
|
+
function A(i) {
|
|
657
632
|
return i.search(/^(data:)/) !== -1;
|
|
658
633
|
}
|
|
659
|
-
function
|
|
634
|
+
function Ot(i, t) {
|
|
660
635
|
return `data:${t};base64,${i}`;
|
|
661
636
|
}
|
|
662
637
|
async function X(i, t, e) {
|
|
@@ -675,64 +650,64 @@ async function X(i, t, e) {
|
|
|
675
650
|
}, a.readAsDataURL(r);
|
|
676
651
|
});
|
|
677
652
|
}
|
|
678
|
-
const
|
|
679
|
-
function
|
|
653
|
+
const L = {};
|
|
654
|
+
function Ft(i, t, e) {
|
|
680
655
|
let s = i.replace(/\?.*/, "");
|
|
681
656
|
return e && (s = i), /ttf|otf|eot|woff2?/i.test(s) && (s = s.replace(/.*\//, "")), t ? `[${t}]${s}` : s;
|
|
682
657
|
}
|
|
683
658
|
async function _(i, t, e) {
|
|
684
|
-
const s =
|
|
685
|
-
if (
|
|
686
|
-
return
|
|
659
|
+
const s = Ft(i, t, e.includeQueryParams);
|
|
660
|
+
if (L[s] != null)
|
|
661
|
+
return L[s];
|
|
687
662
|
e.cacheBust && (i += (/\?/.test(i) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
|
|
688
663
|
let r;
|
|
689
664
|
try {
|
|
690
|
-
const n = await X(i, e.fetchRequestInit, ({ res: o, result: a }) => (t || (t = o.headers.get("Content-Type") || ""),
|
|
691
|
-
r =
|
|
665
|
+
const n = await X(i, e.fetchRequestInit, ({ res: o, result: a }) => (t || (t = o.headers.get("Content-Type") || ""), It(a)));
|
|
666
|
+
r = Ot(n, t);
|
|
692
667
|
} catch (n) {
|
|
693
668
|
r = e.imagePlaceholder || "";
|
|
694
669
|
let o = `Failed to fetch resource: ${i}`;
|
|
695
670
|
n && (o = typeof n == "string" ? n : n.message), o && console.warn(o);
|
|
696
671
|
}
|
|
697
|
-
return
|
|
672
|
+
return L[s] = r, r;
|
|
698
673
|
}
|
|
699
|
-
async function
|
|
674
|
+
async function jt(i) {
|
|
700
675
|
const t = i.toDataURL();
|
|
701
|
-
return t === "data:," ? i.cloneNode(!1) :
|
|
676
|
+
return t === "data:," ? i.cloneNode(!1) : E(t);
|
|
702
677
|
}
|
|
703
|
-
async function
|
|
678
|
+
async function Ut(i, t) {
|
|
704
679
|
if (i.currentSrc) {
|
|
705
680
|
const n = document.createElement("canvas"), o = n.getContext("2d");
|
|
706
681
|
n.width = i.clientWidth, n.height = i.clientHeight, o?.drawImage(i, 0, 0, n.width, n.height);
|
|
707
682
|
const a = n.toDataURL();
|
|
708
|
-
return
|
|
683
|
+
return E(a);
|
|
709
684
|
}
|
|
710
|
-
const e = i.poster, s =
|
|
711
|
-
return
|
|
685
|
+
const e = i.poster, s = P(e), r = await _(e, s, t);
|
|
686
|
+
return E(r);
|
|
712
687
|
}
|
|
713
|
-
async function
|
|
688
|
+
async function zt(i, t) {
|
|
714
689
|
var e;
|
|
715
690
|
try {
|
|
716
691
|
if (!((e = i?.contentDocument) === null || e === void 0) && e.body)
|
|
717
|
-
return await
|
|
692
|
+
return await C(i.contentDocument.body, t, !0);
|
|
718
693
|
} catch {
|
|
719
694
|
}
|
|
720
695
|
return i.cloneNode(!1);
|
|
721
696
|
}
|
|
722
|
-
async function
|
|
723
|
-
return h(i, HTMLCanvasElement) ?
|
|
697
|
+
async function Bt(i, t) {
|
|
698
|
+
return h(i, HTMLCanvasElement) ? jt(i) : h(i, HTMLVideoElement) ? Ut(i, t) : h(i, HTMLIFrameElement) ? zt(i, t) : i.cloneNode(G(i));
|
|
724
699
|
}
|
|
725
|
-
const
|
|
726
|
-
async function
|
|
700
|
+
const qt = (i) => i.tagName != null && i.tagName.toUpperCase() === "SLOT", G = (i) => i.tagName != null && i.tagName.toUpperCase() === "SVG";
|
|
701
|
+
async function Wt(i, t, e) {
|
|
727
702
|
var s, r;
|
|
728
703
|
if (G(t))
|
|
729
704
|
return t;
|
|
730
705
|
let n = [];
|
|
731
|
-
return
|
|
706
|
+
return qt(i) && i.assignedNodes ? n = p(i.assignedNodes()) : h(i, HTMLIFrameElement) && (!((s = i.contentDocument) === null || s === void 0) && s.body) ? n = p(i.contentDocument.body.childNodes) : n = p(((r = i.shadowRoot) !== null && r !== void 0 ? r : i).childNodes), n.length === 0 || h(i, HTMLVideoElement) || await n.reduce((o, a) => o.then(() => C(a, e)).then((l) => {
|
|
732
707
|
l && t.appendChild(l);
|
|
733
708
|
}), Promise.resolve()), t;
|
|
734
709
|
}
|
|
735
|
-
function
|
|
710
|
+
function Nt(i, t, e) {
|
|
736
711
|
const s = t.style;
|
|
737
712
|
if (!s)
|
|
738
713
|
return;
|
|
@@ -742,19 +717,19 @@ function Vt(i, t, e) {
|
|
|
742
717
|
n === "font-size" && o.endsWith("px") && (o = `${Math.floor(parseFloat(o.substring(0, o.length - 2))) - 0.1}px`), h(i, HTMLIFrameElement) && n === "display" && o === "inline" && (o = "block"), n === "d" && t.getAttribute("d") && (o = `path(${t.getAttribute("d")})`), s.setProperty(n, o, r.getPropertyPriority(n));
|
|
743
718
|
});
|
|
744
719
|
}
|
|
745
|
-
function
|
|
720
|
+
function Vt(i, t) {
|
|
746
721
|
h(i, HTMLTextAreaElement) && (t.innerHTML = i.value), h(i, HTMLInputElement) && t.setAttribute("value", i.value);
|
|
747
722
|
}
|
|
748
|
-
function
|
|
723
|
+
function Yt(i, t) {
|
|
749
724
|
if (h(i, HTMLSelectElement)) {
|
|
750
725
|
const e = t, s = Array.from(e.children).find((r) => i.value === r.getAttribute("value"));
|
|
751
726
|
s && s.setAttribute("selected", "");
|
|
752
727
|
}
|
|
753
728
|
}
|
|
754
|
-
function
|
|
755
|
-
return h(t, Element) && (
|
|
729
|
+
function Xt(i, t, e) {
|
|
730
|
+
return h(t, Element) && (Nt(i, t, e), _t(i, t, e), Vt(i, t), Yt(i, t)), t;
|
|
756
731
|
}
|
|
757
|
-
async function
|
|
732
|
+
async function Gt(i, t) {
|
|
758
733
|
const e = i.querySelectorAll ? i.querySelectorAll("use") : [];
|
|
759
734
|
if (e.length === 0)
|
|
760
735
|
return i;
|
|
@@ -763,7 +738,7 @@ async function Kt(i, t) {
|
|
|
763
738
|
const a = e[n].getAttribute("xlink:href");
|
|
764
739
|
if (a) {
|
|
765
740
|
const l = i.querySelector(a), c = document.querySelector(a);
|
|
766
|
-
!l && c && !s[a] && (s[a] = await
|
|
741
|
+
!l && c && !s[a] && (s[a] = await C(c, t, !0));
|
|
767
742
|
}
|
|
768
743
|
}
|
|
769
744
|
const r = Object.values(s);
|
|
@@ -778,31 +753,31 @@ async function Kt(i, t) {
|
|
|
778
753
|
}
|
|
779
754
|
return i;
|
|
780
755
|
}
|
|
781
|
-
async function
|
|
782
|
-
return !e && t.filter && !t.filter(i) ? null : Promise.resolve(i).then((s) =>
|
|
756
|
+
async function C(i, t, e) {
|
|
757
|
+
return !e && t.filter && !t.filter(i) ? null : Promise.resolve(i).then((s) => Bt(s, t)).then((s) => Wt(i, s, t)).then((s) => Xt(i, s, t)).then((s) => Gt(s, t));
|
|
783
758
|
}
|
|
784
|
-
const K = /url\((['"]?)([^'"]+?)\1\)/g,
|
|
785
|
-
function
|
|
759
|
+
const K = /url\((['"]?)([^'"]+?)\1\)/g, Kt = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, Jt = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
|
|
760
|
+
function Qt(i) {
|
|
786
761
|
const t = i.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
|
|
787
762
|
return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`, "g");
|
|
788
763
|
}
|
|
789
|
-
function
|
|
764
|
+
function Zt(i) {
|
|
790
765
|
const t = [];
|
|
791
|
-
return i.replace(K, (e, s, r) => (t.push(r), e)), t.filter((e) => !
|
|
766
|
+
return i.replace(K, (e, s, r) => (t.push(r), e)), t.filter((e) => !A(e));
|
|
792
767
|
}
|
|
793
|
-
async function
|
|
768
|
+
async function te(i, t, e, s, r) {
|
|
794
769
|
try {
|
|
795
|
-
const n = e ?
|
|
770
|
+
const n = e ? vt(t, e) : t, o = P(t);
|
|
796
771
|
let a;
|
|
797
|
-
return r || (a = await _(n, o, s)), i.replace(
|
|
772
|
+
return r || (a = await _(n, o, s)), i.replace(Qt(t), `$1${a}$3`);
|
|
798
773
|
} catch {
|
|
799
774
|
}
|
|
800
775
|
return i;
|
|
801
776
|
}
|
|
802
|
-
function
|
|
803
|
-
return t ? i.replace(
|
|
777
|
+
function ee(i, { preferredFontFormat: t }) {
|
|
778
|
+
return t ? i.replace(Jt, (e) => {
|
|
804
779
|
for (; ; ) {
|
|
805
|
-
const [s, , r] =
|
|
780
|
+
const [s, , r] = Kt.exec(e) || [];
|
|
806
781
|
if (!r)
|
|
807
782
|
return "";
|
|
808
783
|
if (r === t)
|
|
@@ -816,8 +791,8 @@ function J(i) {
|
|
|
816
791
|
async function Q(i, t, e) {
|
|
817
792
|
if (!J(i))
|
|
818
793
|
return i;
|
|
819
|
-
const s =
|
|
820
|
-
return
|
|
794
|
+
const s = ee(i, e);
|
|
795
|
+
return Zt(s).reduce((n, o) => n.then((a) => te(a, o, t, e)), Promise.resolve(s));
|
|
821
796
|
}
|
|
822
797
|
async function g(i, t, e) {
|
|
823
798
|
var s;
|
|
@@ -828,14 +803,14 @@ async function g(i, t, e) {
|
|
|
828
803
|
}
|
|
829
804
|
return !1;
|
|
830
805
|
}
|
|
831
|
-
async function
|
|
806
|
+
async function ie(i, t) {
|
|
832
807
|
await g("background", i, t) || await g("background-image", i, t), await g("mask", i, t) || await g("-webkit-mask", i, t) || await g("mask-image", i, t) || await g("-webkit-mask-image", i, t);
|
|
833
808
|
}
|
|
834
|
-
async function
|
|
809
|
+
async function se(i, t) {
|
|
835
810
|
const e = h(i, HTMLImageElement);
|
|
836
|
-
if (!(e && !
|
|
811
|
+
if (!(e && !A(i.src)) && !(h(i, SVGImageElement) && !A(i.href.baseVal)))
|
|
837
812
|
return;
|
|
838
|
-
const s = e ? i.src : i.href.baseVal, r = await _(s,
|
|
813
|
+
const s = e ? i.src : i.href.baseVal, r = await _(s, P(s), t);
|
|
839
814
|
await new Promise((n, o) => {
|
|
840
815
|
i.onload = n, i.onerror = t.onImageErrorHandler ? (...l) => {
|
|
841
816
|
try {
|
|
@@ -848,14 +823,14 @@ async function re(i, t) {
|
|
|
848
823
|
a.decode && (a.decode = n), a.loading === "lazy" && (a.loading = "eager"), e ? (i.srcset = "", i.src = r) : i.href.baseVal = r;
|
|
849
824
|
});
|
|
850
825
|
}
|
|
851
|
-
async function
|
|
826
|
+
async function re(i, t) {
|
|
852
827
|
const s = p(i.childNodes).map((r) => Z(r, t));
|
|
853
828
|
await Promise.all(s).then(() => i);
|
|
854
829
|
}
|
|
855
830
|
async function Z(i, t) {
|
|
856
|
-
h(i, Element) && (await
|
|
831
|
+
h(i, Element) && (await ie(i, t), await se(i, t), await re(i, t));
|
|
857
832
|
}
|
|
858
|
-
function
|
|
833
|
+
function ne(i, t) {
|
|
859
834
|
const { style: e } = i;
|
|
860
835
|
t.backgroundColor && (e.backgroundColor = t.backgroundColor), t.width && (e.width = `${t.width}px`), t.height && (e.height = `${t.height}px`);
|
|
861
836
|
const s = t.style;
|
|
@@ -905,7 +880,7 @@ function B(i) {
|
|
|
905
880
|
}
|
|
906
881
|
return t;
|
|
907
882
|
}
|
|
908
|
-
async function
|
|
883
|
+
async function oe(i, t) {
|
|
909
884
|
const e = [], s = [];
|
|
910
885
|
return i.forEach((r) => {
|
|
911
886
|
if ("cssRules" in r)
|
|
@@ -913,12 +888,12 @@ async function ae(i, t) {
|
|
|
913
888
|
p(r.cssRules || []).forEach((n, o) => {
|
|
914
889
|
if (n.type === CSSRule.IMPORT_RULE) {
|
|
915
890
|
let a = o + 1;
|
|
916
|
-
const l = n.href, c = U(l).then((u) => z(u, t)).then((u) => B(u).forEach((
|
|
891
|
+
const l = n.href, c = U(l).then((u) => z(u, t)).then((u) => B(u).forEach((M) => {
|
|
917
892
|
try {
|
|
918
|
-
r.insertRule(
|
|
893
|
+
r.insertRule(M, M.startsWith("@import") ? a += 1 : r.cssRules.length);
|
|
919
894
|
} catch (it) {
|
|
920
895
|
console.error("Error inserting rule from remote css", {
|
|
921
|
-
rule:
|
|
896
|
+
rule: M,
|
|
922
897
|
error: it
|
|
923
898
|
});
|
|
924
899
|
}
|
|
@@ -947,19 +922,19 @@ async function ae(i, t) {
|
|
|
947
922
|
}
|
|
948
923
|
}), e));
|
|
949
924
|
}
|
|
950
|
-
function
|
|
925
|
+
function ae(i) {
|
|
951
926
|
return i.filter((t) => t.type === CSSRule.FONT_FACE_RULE).filter((t) => J(t.style.getPropertyValue("src")));
|
|
952
927
|
}
|
|
953
|
-
async function
|
|
928
|
+
async function le(i, t) {
|
|
954
929
|
if (i.ownerDocument == null)
|
|
955
930
|
throw new Error("Provided element is not within a Document");
|
|
956
|
-
const e = p(i.ownerDocument.styleSheets), s = await
|
|
957
|
-
return
|
|
931
|
+
const e = p(i.ownerDocument.styleSheets), s = await oe(e, t);
|
|
932
|
+
return ae(s);
|
|
958
933
|
}
|
|
959
934
|
function tt(i) {
|
|
960
935
|
return i.trim().replace(/["']/g, "");
|
|
961
936
|
}
|
|
962
|
-
function
|
|
937
|
+
function ce(i) {
|
|
963
938
|
const t = /* @__PURE__ */ new Set();
|
|
964
939
|
function e(s) {
|
|
965
940
|
(s.style.fontFamily || getComputedStyle(s).fontFamily).split(",").forEach((n) => {
|
|
@@ -970,56 +945,56 @@ function he(i) {
|
|
|
970
945
|
}
|
|
971
946
|
return e(i), t;
|
|
972
947
|
}
|
|
973
|
-
async function
|
|
974
|
-
const e = await
|
|
948
|
+
async function he(i, t) {
|
|
949
|
+
const e = await le(i, t), s = ce(i);
|
|
975
950
|
return (await Promise.all(e.filter((n) => s.has(tt(n.style.fontFamily))).map((n) => {
|
|
976
951
|
const o = n.parentStyleSheet ? n.parentStyleSheet.href : null;
|
|
977
952
|
return Q(n.cssText, o, t);
|
|
978
953
|
}))).join(`
|
|
979
954
|
`);
|
|
980
955
|
}
|
|
981
|
-
async function
|
|
982
|
-
const e = t.fontEmbedCSS != null ? t.fontEmbedCSS : t.skipFonts ? null : await
|
|
956
|
+
async function de(i, t) {
|
|
957
|
+
const e = t.fontEmbedCSS != null ? t.fontEmbedCSS : t.skipFonts ? null : await he(i, t);
|
|
983
958
|
if (e) {
|
|
984
959
|
const s = document.createElement("style"), r = document.createTextNode(e);
|
|
985
960
|
s.appendChild(r), i.firstChild ? i.insertBefore(s, i.firstChild) : i.appendChild(s);
|
|
986
961
|
}
|
|
987
962
|
}
|
|
988
|
-
async function
|
|
989
|
-
const { width: e, height: s } = Y(i, t), r = await
|
|
990
|
-
return await
|
|
963
|
+
async function ue(i, t = {}) {
|
|
964
|
+
const { width: e, height: s } = Y(i, t), r = await C(i, t, !0);
|
|
965
|
+
return await de(r, t), await Z(r, t), ne(r, t), await At(r, e, s);
|
|
991
966
|
}
|
|
992
|
-
async function
|
|
993
|
-
const { width: e, height: s } = Y(i, t), r = await
|
|
967
|
+
async function pe(i, t = {}) {
|
|
968
|
+
const { width: e, height: s } = Y(i, t), r = await ue(i, t), n = await E(r), o = document.createElement("canvas"), a = o.getContext("2d"), l = t.pixelRatio || Mt(), c = t.canvasWidth || e, u = t.canvasHeight || s;
|
|
994
969
|
return o.width = c * l, o.height = u * l, t.skipAutoScale || Tt(o), o.style.width = `${c}`, o.style.height = `${u}`, t.backgroundColor && (a.fillStyle = t.backgroundColor, a.fillRect(0, 0, o.width, o.height)), a.drawImage(n, 0, 0, o.width, o.height), o;
|
|
995
970
|
}
|
|
996
|
-
async function
|
|
997
|
-
return (await
|
|
971
|
+
async function fe(i, t = {}) {
|
|
972
|
+
return (await pe(i, t)).toDataURL();
|
|
998
973
|
}
|
|
999
|
-
async function
|
|
1000
|
-
const t =
|
|
974
|
+
async function me(i = []) {
|
|
975
|
+
const t = be(i);
|
|
1001
976
|
try {
|
|
1002
|
-
const e = await
|
|
977
|
+
const e = await fe(document.body, {
|
|
1003
978
|
cacheBust: !0,
|
|
1004
979
|
skipAutoScale: !1,
|
|
1005
980
|
filter: (s) => !(s instanceof HTMLElement && s.id === "mtb-widget-host")
|
|
1006
981
|
});
|
|
1007
|
-
return
|
|
982
|
+
return xe(e);
|
|
1008
983
|
} catch {
|
|
1009
984
|
return null;
|
|
1010
985
|
} finally {
|
|
1011
986
|
t?.remove();
|
|
1012
987
|
}
|
|
1013
988
|
}
|
|
1014
|
-
function
|
|
989
|
+
function be(i) {
|
|
1015
990
|
if (i.length === 0) return null;
|
|
1016
991
|
const t = document.createElement("div");
|
|
1017
992
|
t.setAttribute("data-mtb-capture-annotations", "true"), t.setAttribute("aria-hidden", "true"), t.style.cssText = "position:fixed;inset:0;pointer-events:none;z-index:2147483645;";
|
|
1018
993
|
for (const [e, s] of i.entries())
|
|
1019
|
-
s.type === "pin" ? t.appendChild(
|
|
994
|
+
s.type === "pin" ? t.appendChild(ge(s, e + 1)) : s.type === "draw" && s.drawPath && t.appendChild(ye(s.drawPath));
|
|
1020
995
|
return document.body.appendChild(t), t;
|
|
1021
996
|
}
|
|
1022
|
-
function
|
|
997
|
+
function ge(i, t) {
|
|
1023
998
|
const e = document.createElement("div");
|
|
1024
999
|
return e.textContent = String(t), e.style.cssText = [
|
|
1025
1000
|
"position:fixed",
|
|
@@ -1039,19 +1014,19 @@ function ye(i, t) {
|
|
|
1039
1014
|
"transform:translate(-50%,-50%)"
|
|
1040
1015
|
].join(";"), e;
|
|
1041
1016
|
}
|
|
1042
|
-
function
|
|
1017
|
+
function ye(i) {
|
|
1043
1018
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1044
1019
|
t.setAttribute("width", "100%"), t.setAttribute("height", "100%"), t.setAttribute("viewBox", `0 0 ${window.innerWidth} ${window.innerHeight}`), t.style.cssText = "position:fixed;inset:0;width:100%;height:100%;overflow:visible;";
|
|
1045
1020
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1046
1021
|
return e.setAttribute("d", i), e.setAttribute("fill", "none"), e.setAttribute("stroke", "#059669"), e.setAttribute("stroke-width", "3.5"), e.setAttribute("stroke-linecap", "round"), e.setAttribute("stroke-linejoin", "round"), e.setAttribute("filter", "drop-shadow(0 1px 2px rgba(5,150,105,0.35))"), t.appendChild(e), t;
|
|
1047
1022
|
}
|
|
1048
|
-
function
|
|
1023
|
+
function xe(i) {
|
|
1049
1024
|
const [t, e] = i.split(","), s = t.match(/:(.*?);/)?.[1] ?? "image/png", r = atob(e), n = new Uint8Array(r.length);
|
|
1050
1025
|
for (let o = 0; o < r.length; o++)
|
|
1051
1026
|
n[o] = r.charCodeAt(o);
|
|
1052
1027
|
return new Blob([n], { type: s });
|
|
1053
1028
|
}
|
|
1054
|
-
class
|
|
1029
|
+
class we {
|
|
1055
1030
|
constructor() {
|
|
1056
1031
|
this.listeners = /* @__PURE__ */ new Set(), this.originalOnError = null, this.installedOnError = null, this.rejectionHandler = null, this.hooked = !1;
|
|
1057
1032
|
}
|
|
@@ -1073,8 +1048,8 @@ class ke {
|
|
|
1073
1048
|
for (const e of this.listeners) e(t);
|
|
1074
1049
|
}
|
|
1075
1050
|
}
|
|
1076
|
-
const et = new
|
|
1077
|
-
class
|
|
1051
|
+
const et = new we(), ke = 20;
|
|
1052
|
+
class ve {
|
|
1078
1053
|
constructor() {
|
|
1079
1054
|
this.errors = [], this.unsubscribe = null;
|
|
1080
1055
|
}
|
|
@@ -1086,7 +1061,7 @@ class Ee {
|
|
|
1086
1061
|
this.addError(`${t.message}${e}`);
|
|
1087
1062
|
}
|
|
1088
1063
|
addError(t) {
|
|
1089
|
-
this.errors.length >=
|
|
1064
|
+
this.errors.length >= ke || this.errors.includes(t) || this.errors.push(t);
|
|
1090
1065
|
}
|
|
1091
1066
|
getErrors() {
|
|
1092
1067
|
return [...this.errors];
|
|
@@ -1095,7 +1070,7 @@ class Ee {
|
|
|
1095
1070
|
this.unsubscribe?.(), this.unsubscribe = null;
|
|
1096
1071
|
}
|
|
1097
1072
|
}
|
|
1098
|
-
const Se = 3,
|
|
1073
|
+
const Se = 3, Ee = 1e3, Ce = 3, Me = 5e3, Te = 500, Le = 500, Ae = 300, Re = /* @__PURE__ */ new Set([
|
|
1099
1074
|
"A",
|
|
1100
1075
|
"BUTTON",
|
|
1101
1076
|
"INPUT",
|
|
@@ -1104,7 +1079,7 @@ const Se = 3, Ce = 1e3, Me = 3, Le = 5e3, Te = 500, Ae = 500, De = 300, Pe = /*
|
|
|
1104
1079
|
"LABEL",
|
|
1105
1080
|
"SUMMARY",
|
|
1106
1081
|
"DETAILS"
|
|
1107
|
-
]),
|
|
1082
|
+
]), De = /* @__PURE__ */ new Set([
|
|
1108
1083
|
"button",
|
|
1109
1084
|
"link",
|
|
1110
1085
|
"checkbox",
|
|
@@ -1125,7 +1100,7 @@ const Se = 3, Ce = 1e3, Me = 3, Le = 5e3, Te = 500, Ae = 500, De = 300, Pe = /*
|
|
|
1125
1100
|
"page not found",
|
|
1126
1101
|
"server error",
|
|
1127
1102
|
"internal server error"
|
|
1128
|
-
],
|
|
1103
|
+
], k = class k {
|
|
1129
1104
|
constructor(t) {
|
|
1130
1105
|
this.clickHistory = [], this.unsubscribeErrors = null, this.active = !1, this.errorCount = 0, this.deadClickCount = 0, this.cooldownUntil = 0, this.navTimestamps = [], this.boundPopstateHandler = null, this.originalPushState = null, this.originalReplaceState = null, this.installedPushState = null, this.installedReplaceState = null, this.boundSubmitHandler = null, this.boundInvalidHandler = null, this.errorPageUrls = /* @__PURE__ */ new Set(), this.domObserver = null, this.pendingDomChecks = 0, this.lastMutationAt = -1, this.onFrustration = t, this.boundClickHandler = (e) => this.handleClick(e);
|
|
1131
1106
|
}
|
|
@@ -1160,7 +1135,7 @@ const Se = 3, Ce = 1e3, Me = 3, Le = 5e3, Te = 500, Ae = 500, De = 300, Pe = /*
|
|
|
1160
1135
|
if (!e || this.isWidgetElement(e)) return;
|
|
1161
1136
|
const s = Date.now();
|
|
1162
1137
|
this.clickHistory.push({ target: e, time: s });
|
|
1163
|
-
const r = s -
|
|
1138
|
+
const r = s - Ee;
|
|
1164
1139
|
if (this.clickHistory = this.clickHistory.filter((o) => o.time > r), this.clickHistory.filter((o) => o.target === e).length >= Se) {
|
|
1165
1140
|
this.clickHistory = [], this.emitHighPriority({
|
|
1166
1141
|
signal: "rage_click",
|
|
@@ -1178,13 +1153,13 @@ const Se = 3, Ce = 1e3, Me = 3, Le = 5e3, Te = 500, Ae = 500, De = 300, Pe = /*
|
|
|
1178
1153
|
handleNavigation() {
|
|
1179
1154
|
const t = Date.now();
|
|
1180
1155
|
this.navTimestamps.push(t);
|
|
1181
|
-
const e = t -
|
|
1182
|
-
this.navTimestamps = this.navTimestamps.filter((s) => s > e), this.navTimestamps.length >=
|
|
1156
|
+
const e = t - Me;
|
|
1157
|
+
this.navTimestamps = this.navTimestamps.filter((s) => s > e), this.navTimestamps.length >= Ce && (this.navTimestamps = [], this.emitIfReady({
|
|
1183
1158
|
signal: "rapid_navigation",
|
|
1184
1159
|
timestamp: t
|
|
1185
1160
|
})), setTimeout(() => {
|
|
1186
1161
|
this.active && this.checkErrorPage();
|
|
1187
|
-
},
|
|
1162
|
+
}, Ae);
|
|
1188
1163
|
}
|
|
1189
1164
|
handleFormSubmit(t) {
|
|
1190
1165
|
const e = t.target;
|
|
@@ -1245,7 +1220,7 @@ const Se = 3, Ce = 1e3, Me = 3, Le = 5e3, Te = 500, Ae = 500, De = 300, Pe = /*
|
|
|
1245
1220
|
target: y(t),
|
|
1246
1221
|
timestamp: e
|
|
1247
1222
|
});
|
|
1248
|
-
},
|
|
1223
|
+
}, Le));
|
|
1249
1224
|
}
|
|
1250
1225
|
ensureDomObserver() {
|
|
1251
1226
|
this.domObserver || (this.domObserver = new MutationObserver(() => {
|
|
@@ -1270,9 +1245,9 @@ const Se = 3, Ce = 1e3, Me = 3, Le = 5e3, Te = 500, Ae = 500, De = 300, Pe = /*
|
|
|
1270
1245
|
return !1;
|
|
1271
1246
|
}
|
|
1272
1247
|
isInteractive(t) {
|
|
1273
|
-
if (
|
|
1248
|
+
if (Re.has(t.tagName)) return !0;
|
|
1274
1249
|
const e = t.getAttribute("role");
|
|
1275
|
-
return !!(e &&
|
|
1250
|
+
return !!(e && De.has(e) || t.hasAttribute("onclick") || t.hasAttribute("tabindex") || t.contentEditable === "true" || window.getComputedStyle(t).cursor === "pointer" || t.closest('a, button, [role="button"], [role="link"], label'));
|
|
1276
1251
|
}
|
|
1277
1252
|
isWidgetElement(t) {
|
|
1278
1253
|
const e = document.getElementById("mtb-widget-host");
|
|
@@ -1280,40 +1255,40 @@ const Se = 3, Ce = 1e3, Me = 3, Le = 5e3, Te = 500, Ae = 500, De = 300, Pe = /*
|
|
|
1280
1255
|
}
|
|
1281
1256
|
emitIfReady(t) {
|
|
1282
1257
|
const e = Date.now();
|
|
1283
|
-
e < this.cooldownUntil || (this.cooldownUntil = e +
|
|
1258
|
+
e < this.cooldownUntil || (this.cooldownUntil = e + k.COOLDOWN_MS, this.onFrustration(t));
|
|
1284
1259
|
}
|
|
1285
1260
|
emitHighPriority(t) {
|
|
1286
|
-
this.cooldownUntil = Date.now() +
|
|
1261
|
+
this.cooldownUntil = Date.now() + k.COOLDOWN_MS, this.onFrustration(t);
|
|
1287
1262
|
}
|
|
1288
1263
|
};
|
|
1289
|
-
|
|
1290
|
-
let
|
|
1264
|
+
k.COOLDOWN_MS = 6e4;
|
|
1265
|
+
let R = k;
|
|
1291
1266
|
function y(i) {
|
|
1292
1267
|
const t = i.tagName.toLowerCase(), e = i.id ? `#${i.id}` : "", s = i.className && typeof i.className == "string" ? "." + i.className.trim().split(/\s+/).slice(0, 2).join(".") : "", r = i.textContent?.trim().slice(0, 30) ?? "";
|
|
1293
1268
|
return `<${t}${e}${s}>${r ? ` "${r}"` : ""}`;
|
|
1294
1269
|
}
|
|
1295
|
-
function
|
|
1270
|
+
function Pe() {
|
|
1296
1271
|
return {
|
|
1297
1272
|
page_url: window.location.href,
|
|
1298
1273
|
user_agent: navigator.userAgent,
|
|
1299
|
-
browser:
|
|
1300
|
-
os:
|
|
1274
|
+
browser: _e(),
|
|
1275
|
+
os: He(),
|
|
1301
1276
|
screen_width: window.screen.width,
|
|
1302
1277
|
screen_height: window.screen.height
|
|
1303
1278
|
};
|
|
1304
1279
|
}
|
|
1305
|
-
function
|
|
1280
|
+
function _e() {
|
|
1306
1281
|
const i = navigator.userAgent;
|
|
1307
1282
|
return /Edg\//.test(i) ? `Edge ${i.match(/Edg\/(\S+)/)?.[1] ?? ""}` : /OPR\//.test(i) ? `Opera ${i.match(/OPR\/(\S+)/)?.[1] ?? ""}` : /Chrome\//.test(i) ? `Chrome ${i.match(/Chrome\/(\S+)/)?.[1] ?? ""}` : /Safari\//.test(i) && /Version\//.test(i) ? `Safari ${i.match(/Version\/(\S+)/)?.[1] ?? ""}` : /Firefox\//.test(i) ? `Firefox ${i.match(/Firefox\/(\S+)/)?.[1] ?? ""}` : "Unknown";
|
|
1308
1283
|
}
|
|
1309
|
-
function
|
|
1284
|
+
function He() {
|
|
1310
1285
|
const i = navigator.userAgent;
|
|
1311
1286
|
return /Windows NT 10/.test(i) ? "Windows 10/11" : /Windows NT/.test(i) ? "Windows" : /Mac OS X 10_15|macOS 1[56789]/.test(i) || /Mac OS X/.test(i) ? "macOS" : /Android/.test(i) ? `Android ${i.match(/Android (\d+)/)?.[1] ?? ""}` : /iPhone|iPad|iPod/.test(i) ? "iOS" : /Linux/.test(i) ? "Linux" : "Unknown";
|
|
1312
1287
|
}
|
|
1313
|
-
const
|
|
1314
|
-
class
|
|
1288
|
+
const $e = "https://makethisbetter.dev/api/v1";
|
|
1289
|
+
class Ie {
|
|
1315
1290
|
constructor(t, e, s = 1e3, r, n) {
|
|
1316
|
-
this.projectKey = t, this.apiUrl = (e ??
|
|
1291
|
+
this.projectKey = t, this.apiUrl = (e ?? $e).replace(/\/$/, ""), this.retryDelayMs = s, this.userToken = r, this.userTokenFn = n;
|
|
1317
1292
|
}
|
|
1318
1293
|
async resolveUserToken() {
|
|
1319
1294
|
return this.userTokenFn ? this.userTokenFn() : this.userToken;
|
|
@@ -1330,7 +1305,7 @@ class Oe {
|
|
|
1330
1305
|
}
|
|
1331
1306
|
e && s.append("feedback[screenshot]", e, "screenshot.png");
|
|
1332
1307
|
const r = await this.authHeaders();
|
|
1333
|
-
return r["X-Idempotency-Key"] =
|
|
1308
|
+
return r["X-Idempotency-Key"] = Oe(), (await this.fetchWithRetry(`${this.apiUrl}/widget/feedbacks`, {
|
|
1334
1309
|
method: "POST",
|
|
1335
1310
|
headers: r,
|
|
1336
1311
|
body: s
|
|
@@ -1371,10 +1346,10 @@ class Oe {
|
|
|
1371
1346
|
function W(i) {
|
|
1372
1347
|
return i <= 0 ? Promise.resolve() : new Promise((t) => setTimeout(t, i));
|
|
1373
1348
|
}
|
|
1374
|
-
function
|
|
1349
|
+
function Oe() {
|
|
1375
1350
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
1376
1351
|
}
|
|
1377
|
-
function
|
|
1352
|
+
function Fe(i, t, e, s, r, n) {
|
|
1378
1353
|
return {
|
|
1379
1354
|
description: i,
|
|
1380
1355
|
...t,
|
|
@@ -1392,7 +1367,7 @@ function je(i, t, e, s, r, n) {
|
|
|
1392
1367
|
recording_duration: n?.duration
|
|
1393
1368
|
};
|
|
1394
1369
|
}
|
|
1395
|
-
const
|
|
1370
|
+
const je = {
|
|
1396
1371
|
tab: "Feedback",
|
|
1397
1372
|
toolbar: {
|
|
1398
1373
|
markup: "Mark up",
|
|
@@ -1445,7 +1420,7 @@ const Ue = {
|
|
|
1445
1420
|
send: "Send",
|
|
1446
1421
|
skip: "Skip"
|
|
1447
1422
|
}
|
|
1448
|
-
},
|
|
1423
|
+
}, Ue = {
|
|
1449
1424
|
tab: "反馈",
|
|
1450
1425
|
toolbar: {
|
|
1451
1426
|
markup: "标注",
|
|
@@ -1498,7 +1473,7 @@ const Ue = {
|
|
|
1498
1473
|
send: "发送",
|
|
1499
1474
|
skip: "跳过"
|
|
1500
1475
|
}
|
|
1501
|
-
},
|
|
1476
|
+
}, ze = {
|
|
1502
1477
|
tab: "フィードバック",
|
|
1503
1478
|
toolbar: {
|
|
1504
1479
|
markup: "マークアップ",
|
|
@@ -1551,7 +1526,7 @@ const Ue = {
|
|
|
1551
1526
|
send: "送信",
|
|
1552
1527
|
skip: "スキップ"
|
|
1553
1528
|
}
|
|
1554
|
-
},
|
|
1529
|
+
}, Be = {
|
|
1555
1530
|
tab: "피드백",
|
|
1556
1531
|
toolbar: {
|
|
1557
1532
|
markup: "마크업",
|
|
@@ -1604,7 +1579,7 @@ const Ue = {
|
|
|
1604
1579
|
send: "보내기",
|
|
1605
1580
|
skip: "건너뛰기"
|
|
1606
1581
|
}
|
|
1607
|
-
},
|
|
1582
|
+
}, qe = {
|
|
1608
1583
|
tab: "Comentarios",
|
|
1609
1584
|
toolbar: {
|
|
1610
1585
|
markup: "Anotar",
|
|
@@ -1657,7 +1632,7 @@ const Ue = {
|
|
|
1657
1632
|
send: "Enviar",
|
|
1658
1633
|
skip: "Omitir"
|
|
1659
1634
|
}
|
|
1660
|
-
},
|
|
1635
|
+
}, We = {
|
|
1661
1636
|
tab: "Avis",
|
|
1662
1637
|
toolbar: {
|
|
1663
1638
|
markup: "Annoter",
|
|
@@ -1710,7 +1685,7 @@ const Ue = {
|
|
|
1710
1685
|
send: "Envoyer",
|
|
1711
1686
|
skip: "Passer"
|
|
1712
1687
|
}
|
|
1713
|
-
},
|
|
1688
|
+
}, Ne = {
|
|
1714
1689
|
tab: "Feedback",
|
|
1715
1690
|
toolbar: {
|
|
1716
1691
|
markup: "Markieren",
|
|
@@ -1763,29 +1738,29 @@ const Ue = {
|
|
|
1763
1738
|
send: "Senden",
|
|
1764
1739
|
skip: "Überspringen"
|
|
1765
1740
|
}
|
|
1766
|
-
},
|
|
1767
|
-
en:
|
|
1768
|
-
"zh-CN":
|
|
1769
|
-
ja:
|
|
1770
|
-
ko:
|
|
1771
|
-
es:
|
|
1772
|
-
fr:
|
|
1773
|
-
de:
|
|
1741
|
+
}, w = {
|
|
1742
|
+
en: je,
|
|
1743
|
+
"zh-CN": Ue,
|
|
1744
|
+
ja: ze,
|
|
1745
|
+
ko: Be,
|
|
1746
|
+
es: qe,
|
|
1747
|
+
fr: We,
|
|
1748
|
+
de: Ne
|
|
1774
1749
|
};
|
|
1775
|
-
function
|
|
1776
|
-
if (
|
|
1750
|
+
function Ve(i) {
|
|
1751
|
+
if (w[i]) return w[i];
|
|
1777
1752
|
const t = i.split("-")[0];
|
|
1778
|
-
return
|
|
1753
|
+
return w[t] ? w[t] : w.en;
|
|
1779
1754
|
}
|
|
1780
|
-
const
|
|
1781
|
-
let
|
|
1782
|
-
function
|
|
1783
|
-
return
|
|
1755
|
+
const Ye = 60, Xe = "https://cdn.jsdelivr.net/npm/rrweb@2.1.0/dist/rrweb.min.js", Ge = "sha384-6qZKf9GE/E2uhA8IdLwXsQiLN/jVx8mhA0i04rQ1aHLrs2URo3ivHlSbaccG59zt";
|
|
1756
|
+
let v = null;
|
|
1757
|
+
function Ke() {
|
|
1758
|
+
return v || (v = Je().catch(() => Qe()), v);
|
|
1784
1759
|
}
|
|
1785
|
-
async function
|
|
1760
|
+
async function Je() {
|
|
1786
1761
|
return (await import("rrweb")).record;
|
|
1787
1762
|
}
|
|
1788
|
-
function
|
|
1763
|
+
function Qe() {
|
|
1789
1764
|
return new Promise((i, t) => {
|
|
1790
1765
|
const e = globalThis;
|
|
1791
1766
|
if (e.rrweb?.record) {
|
|
@@ -1793,18 +1768,18 @@ function Ze() {
|
|
|
1793
1768
|
return;
|
|
1794
1769
|
}
|
|
1795
1770
|
const s = document.createElement("script");
|
|
1796
|
-
s.src =
|
|
1771
|
+
s.src = Xe, s.integrity = Ge, s.crossOrigin = "anonymous", s.onload = () => {
|
|
1797
1772
|
const r = globalThis;
|
|
1798
1773
|
r.rrweb?.record ? i(r.rrweb.record) : t(new Error("rrweb global not found after script load"));
|
|
1799
1774
|
}, s.onerror = () => t(new Error("Failed to load rrweb from CDN")), document.head.appendChild(s);
|
|
1800
1775
|
});
|
|
1801
1776
|
}
|
|
1802
|
-
class
|
|
1777
|
+
class Ze {
|
|
1803
1778
|
constructor(t, e) {
|
|
1804
1779
|
this.events = [], this.stopFn = null, this.startedAt = 0, this.timer = null, this.clickHandler = null, this.stopped = !1, this.shadow = t, this.onMaxReached = e;
|
|
1805
1780
|
}
|
|
1806
1781
|
async start() {
|
|
1807
|
-
const t = await
|
|
1782
|
+
const t = await Ke();
|
|
1808
1783
|
this.startedAt = Date.now(), this.stopped = !1, this.stopFn = t({
|
|
1809
1784
|
emit: (e) => {
|
|
1810
1785
|
this.stopped || this.events.push(e);
|
|
@@ -1817,7 +1792,7 @@ class ti {
|
|
|
1817
1792
|
});
|
|
1818
1793
|
}, document.addEventListener("click", this.clickHandler, !0), this.timer = setTimeout(() => {
|
|
1819
1794
|
this.onMaxReached?.();
|
|
1820
|
-
},
|
|
1795
|
+
}, Ye * 1e3);
|
|
1821
1796
|
}
|
|
1822
1797
|
stop() {
|
|
1823
1798
|
return this.stopped = !0, this.stopFn?.(), this.stopFn = null, this.cleanupTimer(), this.cleanupClickHandler(), {
|
|
@@ -1842,7 +1817,7 @@ class ti {
|
|
|
1842
1817
|
s.style.left = `${t}px`, s.style.top = `${e}px`, this.shadow.append(s), s.addEventListener("animationend", () => s.remove());
|
|
1843
1818
|
}
|
|
1844
1819
|
}
|
|
1845
|
-
class
|
|
1820
|
+
class ti {
|
|
1846
1821
|
constructor(t, e, s, r) {
|
|
1847
1822
|
this.intervalId = null, this.getDuration = s, this.el = t.el("div", "mtb-record-bar"), this.el.innerHTML = `
|
|
1848
1823
|
<span class="mtb-record-dot"></span>
|
|
@@ -1858,12 +1833,12 @@ class ei {
|
|
|
1858
1833
|
this.intervalId && (clearInterval(this.intervalId), this.intervalId = null), this.el.remove();
|
|
1859
1834
|
}
|
|
1860
1835
|
}
|
|
1861
|
-
class
|
|
1836
|
+
class ei {
|
|
1862
1837
|
constructor() {
|
|
1863
1838
|
this.session = null, this.bar = null, this.result = null;
|
|
1864
1839
|
}
|
|
1865
1840
|
async start(t, e, s) {
|
|
1866
|
-
this.session = new
|
|
1841
|
+
this.session = new Ze(t, s), this.bar = new ti(
|
|
1867
1842
|
t,
|
|
1868
1843
|
e,
|
|
1869
1844
|
() => this.session?.getDuration() ?? 0,
|
|
@@ -1885,10 +1860,10 @@ class ii {
|
|
|
1885
1860
|
}
|
|
1886
1861
|
class N {
|
|
1887
1862
|
constructor(t) {
|
|
1888
|
-
this.tab = null, this.
|
|
1863
|
+
this.tab = null, this.toolbar = null, this.session = null, this.popup = null, this.clarify = null, this.success = null, this.frustrationPrompt = null, this.frustrationDetector = null, this.mode = "idle", this.currentAnnotation = null, this.recordingManager = null, this.config = t, this.messages = Ve(t.locale ?? "en"), this.apiClient = new Ie(t.projectKey, t.apiUrl, void 0, t.userToken, t.userTokenFn), this.consoleCollector = new ve(), this.consoleCollector.start(), this.buildUI(), t.frustrationDetection !== !1 && (this.frustrationDetector = new R(() => this.handleFrustration()), this.frustrationDetector.start());
|
|
1889
1864
|
}
|
|
1890
1865
|
buildUI() {
|
|
1891
|
-
this.shadow = new rt(this.config.theme ?? "auto"),
|
|
1866
|
+
this.shadow = new rt(this.config.theme ?? "auto"), this.tab = new nt(
|
|
1892
1867
|
this.shadow,
|
|
1893
1868
|
this.messages,
|
|
1894
1869
|
this.config.position ?? "right",
|
|
@@ -1900,7 +1875,7 @@ class N {
|
|
|
1900
1875
|
this.mode === "idle" ? (this.dismissFrustrationPrompt(), this.enterAnnotationMode()) : this.exitAll();
|
|
1901
1876
|
}
|
|
1902
1877
|
handleFrustration() {
|
|
1903
|
-
this.mode !== "idle" || this.frustrationPrompt || (this.frustrationPrompt = new
|
|
1878
|
+
this.mode !== "idle" || this.frustrationPrompt || (this.frustrationPrompt = new at(this.shadow, this.messages, {
|
|
1904
1879
|
onTell: () => {
|
|
1905
1880
|
this.dismissFrustrationPrompt(), this.enterAnnotationMode();
|
|
1906
1881
|
},
|
|
@@ -1911,7 +1886,7 @@ class N {
|
|
|
1911
1886
|
this.frustrationPrompt?.destroy(), this.frustrationPrompt = null;
|
|
1912
1887
|
}
|
|
1913
1888
|
enterAnnotationMode() {
|
|
1914
|
-
this.mode = "annotating", this.tab?.setActive(!0), this.
|
|
1889
|
+
this.mode = "annotating", this.tab?.setActive(!0), this.toolbar = new lt(
|
|
1915
1890
|
this.shadow,
|
|
1916
1891
|
this.messages,
|
|
1917
1892
|
() => this.exitAll(),
|
|
@@ -1921,7 +1896,7 @@ class N {
|
|
|
1921
1896
|
});
|
|
1922
1897
|
}
|
|
1923
1898
|
handleToolbarModeChange(t) {
|
|
1924
|
-
t === "record" ? (this.mode = "recording", this.session?.destroy(), this.session = null, this.recordingManager = new
|
|
1899
|
+
t === "record" ? (this.mode = "recording", this.session?.destroy(), this.session = null, this.recordingManager = new ei(), this.recordingManager.start(this.shadow, this.messages, () => {
|
|
1925
1900
|
this.recordingManager && (this.recordingManager.stop(), this.showPopup(window.innerWidth / 2, window.innerHeight / 2, this.messages.record.timer_label));
|
|
1926
1901
|
}).catch(() => {
|
|
1927
1902
|
this.mode === "recording" && (this.toolbar?.setMode("markup"), this.handleToolbarModeChange("markup"));
|
|
@@ -1930,7 +1905,7 @@ class N {
|
|
|
1930
1905
|
})), this.mode = "annotating");
|
|
1931
1906
|
}
|
|
1932
1907
|
showPopup(t, e, s) {
|
|
1933
|
-
this.mode = "popup", this.session?.dismissInteraction(), this.popup = new
|
|
1908
|
+
this.mode = "popup", this.session?.dismissInteraction(), this.popup = new bt(this.shadow, {
|
|
1934
1909
|
targetName: s,
|
|
1935
1910
|
x: t,
|
|
1936
1911
|
y: e,
|
|
@@ -1943,9 +1918,9 @@ class N {
|
|
|
1943
1918
|
if (!this.popup) return;
|
|
1944
1919
|
this.popup.setLoading(!0);
|
|
1945
1920
|
const e = this.currentAnnotation, s = this.recordingManager?.getRecording() ?? void 0, [r, n] = await Promise.all([
|
|
1946
|
-
|
|
1947
|
-
Promise.resolve(
|
|
1948
|
-
]), o =
|
|
1921
|
+
me(e ? [e] : []),
|
|
1922
|
+
Promise.resolve(Pe())
|
|
1923
|
+
]), o = Fe(
|
|
1949
1924
|
t,
|
|
1950
1925
|
n,
|
|
1951
1926
|
this.consoleCollector.getErrors(),
|
|
@@ -1955,13 +1930,13 @@ class N {
|
|
|
1955
1930
|
);
|
|
1956
1931
|
try {
|
|
1957
1932
|
const a = await this.apiClient.submitFeedback(o, r);
|
|
1958
|
-
this.popup?.destroy(), this.popup = null, this.session?.destroy(), this.session = null, this.recordingManager?.destroy(), this.recordingManager = null, this.showClarify(a.id, a.project_id);
|
|
1933
|
+
this.popup?.destroy(), this.popup = null, this.session?.destroy(), this.session = null, this.recordingManager?.destroy(), this.recordingManager = null, a.ai_clarify_available === !1 ? this.showSuccess(a.project_id) : this.showClarify(a.id, a.project_id);
|
|
1959
1934
|
} catch {
|
|
1960
1935
|
this.popup?.setLoading(!1), this.popup?.setError(this.messages.error.submit);
|
|
1961
1936
|
}
|
|
1962
1937
|
}
|
|
1963
1938
|
showClarify(t, e) {
|
|
1964
|
-
this.mode = "idle", this.tab?.setActive(!1), this.
|
|
1939
|
+
this.mode = "idle", this.tab?.setActive(!1), this.clarify = new xt(this.shadow, {
|
|
1965
1940
|
feedbackId: t,
|
|
1966
1941
|
apiClient: this.apiClient,
|
|
1967
1942
|
messages: this.messages,
|
|
@@ -1971,9 +1946,9 @@ class N {
|
|
|
1971
1946
|
});
|
|
1972
1947
|
}
|
|
1973
1948
|
showSuccess(t) {
|
|
1974
|
-
this.mode = "idle", this.tab?.setActive(!1)
|
|
1949
|
+
this.mode = "idle", this.tab?.setActive(!1);
|
|
1975
1950
|
const s = `${this.config.apiUrl ? this.config.apiUrl.replace(/\/api\/v1\/?$/, "") : "https://makethisbetter.dev"}/board/projects/${t}/feedbacks`, r = !!(this.config.userToken || this.config.userTokenFn);
|
|
1976
|
-
this.success = new
|
|
1951
|
+
this.success = new kt(this.shadow, this.messages, () => {
|
|
1977
1952
|
this.success?.destroy(), this.success = null;
|
|
1978
1953
|
}, r ? async () => {
|
|
1979
1954
|
const n = await this.apiClient.resolveUserToken();
|
|
@@ -1981,14 +1956,14 @@ class N {
|
|
|
1981
1956
|
} : void 0);
|
|
1982
1957
|
}
|
|
1983
1958
|
exitAll() {
|
|
1984
|
-
this.mode = "idle", this.tab?.setActive(!1), this.
|
|
1959
|
+
this.mode = "idle", this.tab?.setActive(!1), this.toolbar?.destroy(), this.toolbar = null, this.session?.destroy(), this.session = null, this.popup?.destroy(), this.popup = null, this.clarify?.destroy(), this.clarify = null, this.currentAnnotation = null, this.recordingManager?.destroy(), this.recordingManager = null;
|
|
1985
1960
|
}
|
|
1986
1961
|
destroy() {
|
|
1987
|
-
this.exitAll(), this.consoleCollector.stop(), this.frustrationDetector?.stop(), this.dismissFrustrationPrompt(), this.clarify?.destroy(), this.success?.destroy(), this.tab?.destroy(), this.
|
|
1962
|
+
this.exitAll(), this.consoleCollector.stop(), this.frustrationDetector?.stop(), this.dismissFrustrationPrompt(), this.clarify?.destroy(), this.success?.destroy(), this.tab?.destroy(), this.recordingManager?.destroy(), this.shadow.destroy();
|
|
1988
1963
|
}
|
|
1989
1964
|
}
|
|
1990
1965
|
let f = null;
|
|
1991
|
-
const
|
|
1966
|
+
const ii = {
|
|
1992
1967
|
init(i) {
|
|
1993
1968
|
f && (f.destroy(), f = null), document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => {
|
|
1994
1969
|
f = new N(i);
|
|
@@ -1998,8 +1973,8 @@ const si = {
|
|
|
1998
1973
|
f?.destroy(), f = null;
|
|
1999
1974
|
}
|
|
2000
1975
|
};
|
|
2001
|
-
typeof window < "u" && (window.MakeThisBetter =
|
|
1976
|
+
typeof window < "u" && (window.MakeThisBetter = ii);
|
|
2002
1977
|
export {
|
|
2003
|
-
|
|
1978
|
+
ii as MakeThisBetter
|
|
2004
1979
|
};
|
|
2005
1980
|
//# sourceMappingURL=makethisbetter.esm.js.map
|