@supportwire/messenger-js-sdk 1.0.26 → 1.0.27
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/dist/{index-bfV4xNqW-CRQbrL80.js → index-BWmHLrzv-D5EBMgNv.js} +65 -67
- package/dist/index-BWmHLrzv-D5EBMgNv.js.map +1 -0
- package/dist/{index-bfV4xNqW-ChZOGalc.cjs → index-BWmHLrzv-YDgyeN9x.cjs} +11 -11
- package/dist/index-BWmHLrzv-YDgyeN9x.cjs.map +1 -0
- package/dist/index.cjs +49 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +480 -473
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/index-bfV4xNqW-CRQbrL80.js.map +0 -1
- package/dist/index-bfV4xNqW-ChZOGalc.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -217,12 +217,12 @@ const Ot = (e) => e && typeof e == "string" && e.trim() !== "" ? e.trim().replac
|
|
|
217
217
|
`, document.head.appendChild(t);
|
|
218
218
|
}, At = (e, t, i) => {
|
|
219
219
|
Ht();
|
|
220
|
-
const
|
|
221
|
-
|
|
220
|
+
const o = e.querySelector(".supportwire-widget-tail");
|
|
221
|
+
o && o.remove();
|
|
222
222
|
const r = document.createElement("div");
|
|
223
223
|
r.className = `supportwire-widget-tail ${t || "bottom-right"}`, r.style.background = i === "dark" ? "#1a1a1a" : "#ffffff", e.appendChild(r);
|
|
224
224
|
}, Xe = (e, t) => {
|
|
225
|
-
var i,
|
|
225
|
+
var i, o;
|
|
226
226
|
const r = {
|
|
227
227
|
position: "fixed",
|
|
228
228
|
zIndex: "999999",
|
|
@@ -230,10 +230,10 @@ const Ot = (e) => e && typeof e == "string" && e.trim() !== "" ? e.trim().replac
|
|
|
230
230
|
opacity: "0",
|
|
231
231
|
backgroundColor: t.theme === "dark" ? "#28282a" : "#f1f1f3",
|
|
232
232
|
transition: "width 200ms ease-out, height 200ms ease-out"
|
|
233
|
-
},
|
|
233
|
+
}, n = !t.selector;
|
|
234
234
|
switch (t.widgetType) {
|
|
235
235
|
case "popup": {
|
|
236
|
-
const l = (i = t.triggerPosition) != null && i.endsWith("left") ? "left" : "right", s = (
|
|
236
|
+
const l = (i = t.triggerPosition) != null && i.endsWith("left") ? "left" : "right", s = (o = t.triggerPosition) != null && o.startsWith("top") ? "top" : "bottom", m = A(Se(A({}, r), {
|
|
237
237
|
width: "min(400px, max(0px, -20px + 100vw))",
|
|
238
238
|
height: "min(704px, 100% - 104px)",
|
|
239
239
|
minHeight: "80px",
|
|
@@ -242,8 +242,8 @@ const Ot = (e) => e && typeof e == "string" && e.trim() !== "" ? e.trim().replac
|
|
|
242
242
|
boxShadow: t.theme === "dark" ? "rgba(0, 0, 0, 0.5) 0px 5px 40px 0px" : "rgba(9, 14, 21, 0.12) 0px 5px 40px 0px",
|
|
243
243
|
overflow: "hidden",
|
|
244
244
|
transformOrigin: `${l} ${s}`
|
|
245
|
-
}), zt(t.triggerPosition,
|
|
246
|
-
Object.assign(e.style,
|
|
245
|
+
}), zt(t.triggerPosition, n));
|
|
246
|
+
Object.assign(e.style, m);
|
|
247
247
|
break;
|
|
248
248
|
}
|
|
249
249
|
case "drawer":
|
|
@@ -383,37 +383,37 @@ const Ot = (e) => e && typeof e == "string" && e.trim() !== "" ? e.trim().replac
|
|
|
383
383
|
}
|
|
384
384
|
`, document.head.appendChild(t);
|
|
385
385
|
}, Gt = (e, t) => {
|
|
386
|
-
var i,
|
|
386
|
+
var i, o;
|
|
387
387
|
jt();
|
|
388
388
|
const r = document.createElement("div");
|
|
389
389
|
r.className = "supportwire-trigger-wrapper";
|
|
390
|
-
const
|
|
391
|
-
|
|
390
|
+
const n = document.createElement("button");
|
|
391
|
+
n.className = "supportwire-widget-trigger", n.setAttribute("aria-label", "Open SupportWire chat"), n.style.position = "relative";
|
|
392
392
|
const l = document.createElement("span");
|
|
393
393
|
l.className = "supportwire-trigger-icon supportwire-trigger-icon--visible", l.setAttribute("data-icon", "logo"), l.innerHTML = Wt;
|
|
394
394
|
const s = document.createElement("span");
|
|
395
|
-
s.className = "supportwire-trigger-icon supportwire-trigger-icon--hidden", s.setAttribute("data-icon", "chevron"), s.innerHTML = Bt,
|
|
395
|
+
s.className = "supportwire-trigger-icon supportwire-trigger-icon--hidden", s.setAttribute("data-icon", "chevron"), s.innerHTML = Bt, n.appendChild(l), n.appendChild(s), Object.assign(n.style, {
|
|
396
396
|
backgroundColor: e.theme === "dark" ? "#1a1a1a" : "#ffffff",
|
|
397
397
|
color: e.theme === "dark" ? "#ffffff" : "#1a1a1a",
|
|
398
398
|
boxShadow: "0 1px 6px 0 rgba(0, 0, 0, 0.06), 0 2px 32px 0 rgba(0, 0, 0, 0.16)"
|
|
399
399
|
});
|
|
400
|
-
const
|
|
400
|
+
const m = {
|
|
401
401
|
"bottom-right": { bottom: "20px", right: "20px" },
|
|
402
402
|
"bottom-left": { bottom: "20px", left: "20px" },
|
|
403
403
|
"top-right": { top: "20px", right: "20px" },
|
|
404
404
|
"top-left": { top: "20px", left: "20px" }
|
|
405
|
-
},
|
|
405
|
+
}, h = (i = e.triggerPosition) != null ? i : "bottom-right", u = (o = m[h]) != null ? o : m["bottom-right"];
|
|
406
406
|
return Object.assign(r.style, A({
|
|
407
407
|
position: "fixed",
|
|
408
408
|
zIndex: "999998"
|
|
409
|
-
},
|
|
409
|
+
}, u)), r.appendChild(n), n.addEventListener("click", t), document.body.appendChild(r), r;
|
|
410
410
|
}, qt = (e, t) => {
|
|
411
411
|
const i = {
|
|
412
412
|
"bottom-right": { bottom: "20px", right: "20px", top: "auto", left: "auto" },
|
|
413
413
|
"bottom-left": { bottom: "20px", left: "20px", top: "auto", right: "auto" },
|
|
414
414
|
"top-right": { top: "20px", right: "20px", bottom: "auto", left: "auto" },
|
|
415
415
|
"top-left": { top: "20px", left: "20px", bottom: "auto", right: "auto" }
|
|
416
|
-
},
|
|
416
|
+
}, o = t && i[t] ? t : "bottom-right", r = i[o];
|
|
417
417
|
Object.assign(e.style, r);
|
|
418
418
|
}, Yt = () => {
|
|
419
419
|
const e = "supportwire-widget-badge-styles";
|
|
@@ -478,159 +478,162 @@ const Ot = (e) => e && typeof e == "string" && e.trim() !== "" ? e.trim().replac
|
|
|
478
478
|
Yt();
|
|
479
479
|
let i = e.querySelector(".supportwire-widget-badge");
|
|
480
480
|
if (t > 0) {
|
|
481
|
-
const
|
|
482
|
-
i || (i = document.createElement("span"), i.className = "supportwire-widget-badge", e.appendChild(i)), i.textContent = t > 99 ? "99+" : String(t), i.style.display = "flex", i.removeAttribute("data-animate"), i.offsetWidth, i.setAttribute("data-animate",
|
|
481
|
+
const o = !i || i.style.display === "none";
|
|
482
|
+
i || (i = document.createElement("span"), i.className = "supportwire-widget-badge", e.appendChild(i)), i.textContent = t > 99 ? "99+" : String(t), i.style.display = "flex", i.removeAttribute("data-animate"), i.offsetWidth, i.setAttribute("data-animate", o ? "pop-in" : "pulse");
|
|
483
483
|
} else
|
|
484
484
|
i && (i.style.display = "none", i.removeAttribute("data-animate"));
|
|
485
485
|
}, Le = (e, t, i) => {
|
|
486
|
-
const
|
|
487
|
-
if (!
|
|
488
|
-
const r =
|
|
489
|
-
r &&
|
|
490
|
-
}, Kt = (e, t, i,
|
|
486
|
+
const o = e.querySelector(".supportwire-widget-trigger");
|
|
487
|
+
if (!o) return;
|
|
488
|
+
const r = o.querySelector('[data-icon="logo"]'), n = o.querySelector('[data-icon="chevron"]');
|
|
489
|
+
r && n && (t ? (r.className = "supportwire-trigger-icon supportwire-trigger-icon--hidden", n.className = "supportwire-trigger-icon supportwire-trigger-icon--visible") : (r.className = "supportwire-trigger-icon supportwire-trigger-icon--visible", n.className = "supportwire-trigger-icon supportwire-trigger-icon--hidden")), t ? (o.setAttribute("aria-label", "Close SupportWire chat"), o.style.color = i === "dark" ? "#ffffff" : "#1a1a1a") : (o.setAttribute("aria-label", "Open SupportWire chat"), o.style.color = "");
|
|
490
|
+
}, Kt = (e, t, i, o) => {
|
|
491
491
|
const r = document.createElement("iframe");
|
|
492
|
-
return r.id = t, r.src = `${i}?iframeId=${t}&theme=${
|
|
493
|
-
}, Vt = (e, t, i,
|
|
492
|
+
return r.id = t, r.src = `${i}?iframeId=${t}&theme=${o}`, r.style.width = "100%", r.style.height = "100%", r.style.border = "none", r.style.backgroundColor = o === "dark" ? "#28282a" : "#f1f1f3", r.setAttribute("allow", "clipboard-read; clipboard-write"), r.setAttribute("sandbox", "allow-same-origin allow-scripts allow-forms allow-popups"), e.appendChild(r), r;
|
|
493
|
+
}, Vt = (e, t, i, o) => {
|
|
494
494
|
if (!e || !e.contentWindow)
|
|
495
495
|
return;
|
|
496
|
-
const r = Se(A({},
|
|
496
|
+
const r = Se(A({}, o), {
|
|
497
497
|
iframeId: t
|
|
498
498
|
});
|
|
499
499
|
e.contentWindow.postMessage(r, "*");
|
|
500
|
-
}, Jt = (e, t, i,
|
|
501
|
-
var
|
|
500
|
+
}, Jt = (e, t, i, o) => (r) => {
|
|
501
|
+
var n, l;
|
|
502
502
|
try {
|
|
503
|
-
const
|
|
504
|
-
r.origin !==
|
|
503
|
+
const m = new URL(t).origin;
|
|
504
|
+
r.origin !== m && r.origin;
|
|
505
505
|
} catch {
|
|
506
506
|
}
|
|
507
507
|
const s = r.data;
|
|
508
508
|
if (!(!s || s.iframeId !== e))
|
|
509
509
|
switch (s.type) {
|
|
510
510
|
case "READY":
|
|
511
|
-
|
|
511
|
+
o.onReady && o.onReady();
|
|
512
512
|
break;
|
|
513
513
|
case "OPENED":
|
|
514
|
-
i && (i.style.display = "block", ut(i)),
|
|
514
|
+
i && (i.style.display = "block", ut(i)), o.onOpen();
|
|
515
515
|
break;
|
|
516
516
|
case "CLOSED":
|
|
517
|
-
i && ht(i),
|
|
517
|
+
i && ht(i), o.onClose();
|
|
518
518
|
break;
|
|
519
519
|
case "ERROR":
|
|
520
|
-
|
|
520
|
+
o.onError(new Error(s.error || "Unknown error"));
|
|
521
521
|
break;
|
|
522
522
|
case "UNREAD_COUNT":
|
|
523
|
-
|
|
523
|
+
o.onUnreadCount && s.count !== void 0 && o.onUnreadCount(s.count);
|
|
524
524
|
break;
|
|
525
525
|
case "OPEN_IMAGE_PREVIEW":
|
|
526
|
-
|
|
526
|
+
o.onImagePreview && s.imagePreview && o.onImagePreview(
|
|
527
527
|
s.imagePreview.src,
|
|
528
528
|
s.imagePreview.alt,
|
|
529
529
|
s.imagePreview.filename
|
|
530
530
|
);
|
|
531
531
|
break;
|
|
532
532
|
case "TOGGLE_FULLSCREEN":
|
|
533
|
-
|
|
533
|
+
o.onToggleFullscreen && o.onToggleFullscreen();
|
|
534
534
|
break;
|
|
535
535
|
case "MESSAGE_PREVIEW":
|
|
536
|
-
|
|
536
|
+
o.onMessagePreview && s.messagePreview && o.onMessagePreview(
|
|
537
537
|
s.messagePreview.body,
|
|
538
538
|
s.messagePreview.senderName,
|
|
539
539
|
s.messagePreview.timestamp
|
|
540
540
|
);
|
|
541
541
|
break;
|
|
542
542
|
case "EVENT_RULES_REGISTERED":
|
|
543
|
-
|
|
543
|
+
o.onEventRulesRegistered && s.eventRules && o.onEventRulesRegistered(s.eventRules);
|
|
544
544
|
break;
|
|
545
545
|
case "REQUEST_PAGE_SCREENSHOT":
|
|
546
|
-
|
|
546
|
+
o.onScreenshotRequest && o.onScreenshotRequest((l = (n = s.payload) == null ? void 0 : n.mode) != null ? l : "full");
|
|
547
547
|
break;
|
|
548
548
|
}
|
|
549
549
|
};
|
|
550
|
-
function Xt(e, t) {
|
|
551
|
-
let
|
|
552
|
-
const
|
|
553
|
-
var
|
|
554
|
-
(
|
|
555
|
-
},
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
550
|
+
function Xt(e, t, i = {}) {
|
|
551
|
+
let o = null;
|
|
552
|
+
const r = () => (o || (o = import("./index-BWmHLrzv-D5EBMgNv.js")), o), n = (h) => {
|
|
553
|
+
var u;
|
|
554
|
+
(u = e.contentWindow) == null || u.postMessage(Se(A({}, h), { iframeId: t }), "*");
|
|
555
|
+
}, l = async (h) => {
|
|
556
|
+
var u;
|
|
557
|
+
const p = h.data;
|
|
558
|
+
if (!(!p || typeof p != "object") && !(p.iframeId && p.iframeId !== t))
|
|
559
|
+
switch (p.type) {
|
|
559
560
|
case "RECORDING:START": {
|
|
560
|
-
|
|
561
|
+
const g = await r();
|
|
562
|
+
(u = i.closeWidget) == null || u.call(i), g.recording.start({ guideId: p.guideId, title: p.title });
|
|
561
563
|
return;
|
|
562
564
|
}
|
|
563
565
|
case "RECORDING:STOP": {
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
+
const g = (await r()).recording.stop();
|
|
567
|
+
g && n({
|
|
566
568
|
type: "RECORDING:DONE",
|
|
567
|
-
guideId:
|
|
568
|
-
title:
|
|
569
|
-
steps:
|
|
569
|
+
guideId: g.guideId,
|
|
570
|
+
title: g.title,
|
|
571
|
+
steps: g.steps
|
|
570
572
|
});
|
|
571
573
|
return;
|
|
572
574
|
}
|
|
573
575
|
case "PLAYBACK:START": {
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
|
|
576
|
+
const g = await r();
|
|
577
|
+
g.playback.onDone((y, k, b) => {
|
|
578
|
+
n({
|
|
577
579
|
type: "PLAYBACK:DONE",
|
|
578
|
-
status:
|
|
579
|
-
end_reason:
|
|
580
|
-
current_step:
|
|
580
|
+
status: y,
|
|
581
|
+
end_reason: k,
|
|
582
|
+
current_step: b
|
|
581
583
|
});
|
|
582
|
-
}),
|
|
583
|
-
sessionId:
|
|
584
|
-
guideId:
|
|
585
|
-
versionId:
|
|
586
|
-
version:
|
|
584
|
+
}), g.playback.start({
|
|
585
|
+
sessionId: p.sessionId,
|
|
586
|
+
guideId: p.guideId,
|
|
587
|
+
versionId: p.versionId,
|
|
588
|
+
version: p.version
|
|
587
589
|
});
|
|
588
590
|
return;
|
|
589
591
|
}
|
|
590
592
|
case "OPEN_URL": {
|
|
591
|
-
typeof
|
|
593
|
+
typeof p.url == "string" && window.open(p.url, "_blank", "noopener");
|
|
592
594
|
return;
|
|
593
595
|
}
|
|
594
596
|
}
|
|
595
|
-
},
|
|
596
|
-
const
|
|
597
|
-
|
|
597
|
+
}, s = (h) => {
|
|
598
|
+
const u = h.detail;
|
|
599
|
+
u && n({
|
|
598
600
|
type: "RECORDING:DONE",
|
|
599
|
-
guideId:
|
|
600
|
-
title:
|
|
601
|
-
steps:
|
|
601
|
+
guideId: u.guideId,
|
|
602
|
+
title: u.title,
|
|
603
|
+
steps: u.steps
|
|
602
604
|
});
|
|
603
605
|
};
|
|
604
|
-
window.addEventListener("message",
|
|
605
|
-
|
|
606
|
+
window.addEventListener("message", l), window.addEventListener("sw-guide:recording-done", s), (async () => {
|
|
607
|
+
var h;
|
|
608
|
+
const u = await m();
|
|
606
609
|
if (!u) return;
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
|
|
610
|
+
const p = u.recording.maybeResume();
|
|
611
|
+
p && ((h = i.closeWidget) == null || h.call(i), u.recording.start({ guideId: p.guideId, title: p.title }));
|
|
612
|
+
const g = u.playback.maybeResume();
|
|
613
|
+
g && (u.playback.onDone((k, b, x) => {
|
|
614
|
+
n({
|
|
612
615
|
type: "PLAYBACK:DONE",
|
|
613
|
-
status:
|
|
614
|
-
end_reason:
|
|
615
|
-
current_step:
|
|
616
|
+
status: k,
|
|
617
|
+
end_reason: b,
|
|
618
|
+
current_step: x
|
|
616
619
|
});
|
|
617
620
|
}), u.playback.start({
|
|
618
|
-
sessionId:
|
|
619
|
-
guideId:
|
|
620
|
-
versionId:
|
|
621
|
-
version:
|
|
622
|
-
resumeStepIndex:
|
|
621
|
+
sessionId: g.sessionId,
|
|
622
|
+
guideId: g.guideId,
|
|
623
|
+
versionId: g.versionId,
|
|
624
|
+
version: g.version,
|
|
625
|
+
resumeStepIndex: g.stepIndex
|
|
623
626
|
}));
|
|
624
|
-
const
|
|
625
|
-
|
|
627
|
+
const y = new URLSearchParams(location.search).get("sw_guide");
|
|
628
|
+
y && n({ type: "DEEP_LINK_GUIDE", guideId: y });
|
|
626
629
|
})();
|
|
627
|
-
function
|
|
628
|
-
const
|
|
629
|
-
return !
|
|
630
|
+
function m() {
|
|
631
|
+
const h = !!localStorage.getItem("sw.guide.recording"), u = !!localStorage.getItem("sw.guide.playback"), p = new URLSearchParams(location.search).has("sw_guide");
|
|
632
|
+
return !h && !u && !p ? Promise.resolve(null) : r();
|
|
630
633
|
}
|
|
631
634
|
return {
|
|
632
635
|
teardown: () => {
|
|
633
|
-
window.removeEventListener("message",
|
|
636
|
+
window.removeEventListener("message", l), window.removeEventListener("sw-guide:recording-done", s);
|
|
634
637
|
}
|
|
635
638
|
};
|
|
636
639
|
}
|
|
@@ -883,8 +886,8 @@ function Qe() {
|
|
|
883
886
|
}
|
|
884
887
|
async function ri(e, t) {
|
|
885
888
|
try {
|
|
886
|
-
const i = await (await fetch(e)).blob(),
|
|
887
|
-
r.href =
|
|
889
|
+
const i = await (await fetch(e)).blob(), o = URL.createObjectURL(i), r = document.createElement("a");
|
|
890
|
+
r.href = o, r.download = t || "image", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(o);
|
|
888
891
|
} catch {
|
|
889
892
|
window.open(e, "_blank");
|
|
890
893
|
}
|
|
@@ -896,14 +899,14 @@ function re() {
|
|
|
896
899
|
e.remove(), W === e && (W = null);
|
|
897
900
|
}, 200);
|
|
898
901
|
}
|
|
899
|
-
function
|
|
902
|
+
function oi(e, t, i, o) {
|
|
900
903
|
W && (W.remove(), W = null), Zt(), gt = document.body.style.overflow, document.body.style.overflow = "hidden";
|
|
901
904
|
const r = document.createElement("div");
|
|
902
905
|
r.className = "supportwire-image-preview-backdrop", r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "true"), r.setAttribute("aria-label", t || "Image preview"), r.onclick = (y) => {
|
|
903
906
|
(y.target === r || y.target.classList.contains("supportwire-image-preview-image-container")) && re();
|
|
904
907
|
};
|
|
905
|
-
const
|
|
906
|
-
|
|
908
|
+
const n = document.createElement("div");
|
|
909
|
+
n.className = "supportwire-image-preview-actions";
|
|
907
910
|
const l = document.createElement("button");
|
|
908
911
|
l.className = "supportwire-image-preview-button", l.setAttribute("aria-label", "Copy link"), l.innerHTML = $e(), l.onclick = async (y) => {
|
|
909
912
|
y.stopPropagation();
|
|
@@ -922,57 +925,57 @@ function ni(e, t, i, n) {
|
|
|
922
925
|
s.className = "supportwire-image-preview-button", s.setAttribute("aria-label", "Download image"), s.innerHTML = ei(), s.onclick = (y) => {
|
|
923
926
|
y.stopPropagation(), ri(e, i);
|
|
924
927
|
};
|
|
925
|
-
let
|
|
926
|
-
|
|
928
|
+
let m = null;
|
|
929
|
+
o && (m = document.createElement("button"), m.className = "supportwire-image-preview-button", m.setAttribute("aria-label", "Annotate image"), m.innerHTML = ii(), m.onclick = async (y) => {
|
|
927
930
|
y.stopPropagation();
|
|
928
931
|
try {
|
|
929
|
-
const
|
|
932
|
+
const k = await (await fetch(e)).blob(), b = await new Promise((x, E) => {
|
|
930
933
|
const C = new FileReader();
|
|
931
|
-
C.onload = () =>
|
|
934
|
+
C.onload = () => x(C.result), C.onerror = E, C.readAsDataURL(k);
|
|
932
935
|
});
|
|
933
|
-
re(),
|
|
936
|
+
re(), o(b);
|
|
934
937
|
} catch {
|
|
935
|
-
const b = document.createElement("canvas"),
|
|
936
|
-
|
|
937
|
-
b.width =
|
|
938
|
-
const
|
|
939
|
-
if (
|
|
940
|
-
|
|
938
|
+
const b = document.createElement("canvas"), x = new Image();
|
|
939
|
+
x.crossOrigin = "anonymous", x.onload = () => {
|
|
940
|
+
b.width = x.naturalWidth, b.height = x.naturalHeight;
|
|
941
|
+
const E = b.getContext("2d");
|
|
942
|
+
if (E) {
|
|
943
|
+
E.drawImage(x, 0, 0);
|
|
941
944
|
const C = b.toDataURL("image/png");
|
|
942
|
-
re(),
|
|
945
|
+
re(), o(C);
|
|
943
946
|
}
|
|
944
|
-
},
|
|
947
|
+
}, x.onerror = () => {
|
|
945
948
|
console.warn("Could not load image for annotation");
|
|
946
|
-
},
|
|
949
|
+
}, x.src = e;
|
|
947
950
|
}
|
|
948
951
|
});
|
|
949
|
-
const
|
|
950
|
-
|
|
952
|
+
const h = document.createElement("button");
|
|
953
|
+
h.className = "supportwire-image-preview-button", h.setAttribute("aria-label", "Close preview"), h.innerHTML = ti(), h.onclick = (y) => {
|
|
951
954
|
y.stopPropagation(), re();
|
|
952
|
-
},
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
const
|
|
956
|
-
|
|
957
|
-
const
|
|
958
|
-
if (
|
|
959
|
-
|
|
960
|
-
},
|
|
961
|
-
|
|
955
|
+
}, n.appendChild(l), n.appendChild(s), m && n.appendChild(m), n.appendChild(h);
|
|
956
|
+
const u = document.createElement("div");
|
|
957
|
+
u.className = "supportwire-image-preview-image-container";
|
|
958
|
+
const p = document.createElement("div");
|
|
959
|
+
p.className = "supportwire-image-preview-loader", u.appendChild(p);
|
|
960
|
+
const g = document.createElement("img");
|
|
961
|
+
if (g.className = "supportwire-image-preview-image", g.alt = t || "Image preview", g.onload = () => {
|
|
962
|
+
p.remove();
|
|
963
|
+
}, g.onerror = () => {
|
|
964
|
+
p.remove();
|
|
962
965
|
const y = document.createElement("div");
|
|
963
|
-
y.className = "supportwire-image-preview-error", y.textContent = "Failed to load image",
|
|
964
|
-
},
|
|
966
|
+
y.className = "supportwire-image-preview-error", y.textContent = "Failed to load image", u.appendChild(y);
|
|
967
|
+
}, g.src = e, u.appendChild(g), i) {
|
|
965
968
|
const y = document.createElement("p");
|
|
966
969
|
y.className = "supportwire-image-preview-filename", y.textContent = i, r.appendChild(y);
|
|
967
970
|
}
|
|
968
|
-
r.appendChild(
|
|
971
|
+
r.appendChild(n), r.appendChild(u), document.body.appendChild(r), W = r, requestAnimationFrame(() => {
|
|
969
972
|
r.classList.add("visible");
|
|
970
973
|
}), se = (y) => {
|
|
971
974
|
y.key === "Escape" && re();
|
|
972
|
-
}, document.addEventListener("keydown", se),
|
|
975
|
+
}, document.addEventListener("keydown", se), h.focus();
|
|
973
976
|
}
|
|
974
977
|
let V = null, ae = null, mt = "";
|
|
975
|
-
const c = "supportwire-ss-editor",
|
|
978
|
+
const c = "supportwire-ss-editor", ni = `
|
|
976
979
|
.${c}-backdrop {
|
|
977
980
|
position: fixed;
|
|
978
981
|
inset: 0;
|
|
@@ -1225,7 +1228,7 @@ const c = "supportwire-ss-editor", oi = `
|
|
|
1225
1228
|
function si() {
|
|
1226
1229
|
if (document.getElementById(`${c}-styles`)) return;
|
|
1227
1230
|
const e = document.createElement("style");
|
|
1228
|
-
e.id = `${c}-styles`, e.textContent =
|
|
1231
|
+
e.id = `${c}-styles`, e.textContent = ni, document.head.appendChild(e);
|
|
1229
1232
|
}
|
|
1230
1233
|
const Re = {
|
|
1231
1234
|
select: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"/><path d="M13 13l6 6"/></svg>',
|
|
@@ -1237,9 +1240,9 @@ const Re = {
|
|
|
1237
1240
|
close: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',
|
|
1238
1241
|
undo: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 7v6h6"/><path d="M3 13a9 9 0 0 1 15.36-6.36"/></svg>'
|
|
1239
1242
|
};
|
|
1240
|
-
function ft(e, t, i,
|
|
1241
|
-
const l = Math.min(
|
|
1242
|
-
e.beginPath(), e.moveTo(t + l, i), e.lineTo(t +
|
|
1243
|
+
function ft(e, t, i, o, r, n) {
|
|
1244
|
+
const l = Math.min(n, Math.abs(o) / 2, Math.abs(r) / 2);
|
|
1245
|
+
e.beginPath(), e.moveTo(t + l, i), e.lineTo(t + o - l, i), e.arcTo(t + o, i, t + o, i + l, l), e.lineTo(t + o, i + r - l), e.arcTo(t + o, i + r, t + o - l, i + r, l), e.lineTo(t + l, i + r), e.arcTo(t, i + r, t, i + r - l, l), e.lineTo(t, i + l), e.arcTo(t, i, t + l, i, l), e.closePath(), e.stroke();
|
|
1243
1246
|
}
|
|
1244
1247
|
function Ze(e, t) {
|
|
1245
1248
|
if (e.strokeStyle = t.color, e.fillStyle = t.color, e.lineWidth = "width" in t ? t.width : 2, e.lineCap = "round", e.lineJoin = "round", t.type === "pen" && t.points.length >= 4) {
|
|
@@ -1248,8 +1251,8 @@ function Ze(e, t) {
|
|
|
1248
1251
|
e.stroke();
|
|
1249
1252
|
} else if (t.type === "arrow") {
|
|
1250
1253
|
e.beginPath(), e.moveTo(t.x1, t.y1), e.lineTo(t.x2, t.y2), e.stroke();
|
|
1251
|
-
const i = 10,
|
|
1252
|
-
e.beginPath(), e.moveTo(t.x2, t.y2), e.lineTo(t.x2 - i * Math.cos(
|
|
1254
|
+
const i = 10, o = Math.atan2(t.y2 - t.y1, t.x2 - t.x1);
|
|
1255
|
+
e.beginPath(), e.moveTo(t.x2, t.y2), e.lineTo(t.x2 - i * Math.cos(o - 0.4), t.y2 - i * Math.sin(o - 0.4)), e.lineTo(t.x2 - i * Math.cos(o + 0.4), t.y2 - i * Math.sin(o + 0.4)), e.closePath(), e.fill();
|
|
1253
1256
|
} else t.type === "rect" ? t.radius > 0 ? ft(e, t.x, t.y, t.w, t.h, t.radius) : e.strokeRect(t.x, t.y, t.w, t.h) : t.type === "text" && (e.font = "16px system-ui, sans-serif", e.fillText(t.text, t.x, t.y + 16));
|
|
1254
1257
|
}
|
|
1255
1258
|
function wt(e) {
|
|
@@ -1259,38 +1262,38 @@ function wt(e) {
|
|
|
1259
1262
|
const t = Math.min(e.x1, e.x2), i = Math.min(e.y1, e.y2);
|
|
1260
1263
|
return { x: t, y: i, w: Math.abs(e.x2 - e.x1), h: Math.abs(e.y2 - e.y1) };
|
|
1261
1264
|
} else if (e.type === "pen" && e.points.length >= 4) {
|
|
1262
|
-
let t = e.points[0], i = e.points[0],
|
|
1263
|
-
for (let
|
|
1264
|
-
t = Math.min(t, e.points[
|
|
1265
|
-
return { x: t, y:
|
|
1265
|
+
let t = e.points[0], i = e.points[0], o = e.points[1], r = e.points[1];
|
|
1266
|
+
for (let n = 2; n < e.points.length; n += 2)
|
|
1267
|
+
t = Math.min(t, e.points[n]), i = Math.max(i, e.points[n]), o = Math.min(o, e.points[n + 1]), r = Math.max(r, e.points[n + 1]);
|
|
1268
|
+
return { x: t, y: o, w: i - t, h: r - o };
|
|
1266
1269
|
} else if (e.type === "text")
|
|
1267
1270
|
return { x: e.x, y: e.y, w: 100, h: 20 };
|
|
1268
1271
|
return { x: 0, y: 0, w: 0, h: 0 };
|
|
1269
1272
|
}
|
|
1270
|
-
function ai(e, t, i,
|
|
1271
|
-
const r =
|
|
1273
|
+
function ai(e, t, i, o) {
|
|
1274
|
+
const r = o;
|
|
1272
1275
|
if (e.type === "rect") {
|
|
1273
|
-
const { x:
|
|
1274
|
-
return
|
|
1276
|
+
const { x: n, y: l, w: s, h: m } = e, h = i >= l - r && i <= l + r && t >= n - r && t <= n + s + r, u = i >= l + m - r && i <= l + m + r && t >= n - r && t <= n + s + r, p = t >= n - r && t <= n + r && i >= l - r && i <= l + m + r, g = t >= n + s - r && t <= n + s + r && i >= l - r && i <= l + m + r, y = t >= n && t <= n + s && i >= l && i <= l + m;
|
|
1277
|
+
return h || u || p || g || y;
|
|
1275
1278
|
} else {
|
|
1276
1279
|
if (e.type === "arrow")
|
|
1277
1280
|
return et(t, i, e.x1, e.y1, e.x2, e.y2) <= r + e.width;
|
|
1278
1281
|
if (e.type === "pen" && e.points.length >= 4) {
|
|
1279
|
-
for (let
|
|
1280
|
-
if (et(t, i, e.points[
|
|
1282
|
+
for (let n = 0; n < e.points.length - 2; n += 2)
|
|
1283
|
+
if (et(t, i, e.points[n], e.points[n + 1], e.points[n + 2], e.points[n + 3]) <= r + e.width) return !0;
|
|
1281
1284
|
return !1;
|
|
1282
1285
|
} else if (e.type === "text") {
|
|
1283
|
-
const
|
|
1284
|
-
return t >=
|
|
1286
|
+
const n = wt(e);
|
|
1287
|
+
return t >= n.x - r && t <= n.x + n.w + r && i >= n.y - r && i <= n.y + n.h + r;
|
|
1285
1288
|
}
|
|
1286
1289
|
}
|
|
1287
1290
|
return !1;
|
|
1288
1291
|
}
|
|
1289
|
-
function et(e, t, i,
|
|
1290
|
-
const l = r - i, s =
|
|
1291
|
-
if (
|
|
1292
|
-
let
|
|
1293
|
-
return
|
|
1292
|
+
function et(e, t, i, o, r, n) {
|
|
1293
|
+
const l = r - i, s = n - o, m = l * l + s * s;
|
|
1294
|
+
if (m === 0) return Math.hypot(e - i, t - o);
|
|
1295
|
+
let h = ((e - i) * l + (t - o) * s) / m;
|
|
1296
|
+
return h = Math.max(0, Math.min(1, h)), Math.hypot(e - (i + h * l), t - (o + h * s));
|
|
1294
1297
|
}
|
|
1295
1298
|
function li(e, t, i) {
|
|
1296
1299
|
if (e.type === "rect")
|
|
@@ -1298,31 +1301,31 @@ function li(e, t, i) {
|
|
|
1298
1301
|
else if (e.type === "arrow")
|
|
1299
1302
|
e.x1 += t, e.y1 += i, e.x2 += t, e.y2 += i;
|
|
1300
1303
|
else if (e.type === "pen")
|
|
1301
|
-
for (let
|
|
1302
|
-
e.points[
|
|
1304
|
+
for (let o = 0; o < e.points.length; o += 2)
|
|
1305
|
+
e.points[o] += t, e.points[o + 1] += i;
|
|
1303
1306
|
else e.type === "text" && (e.x += t, e.y += i);
|
|
1304
1307
|
}
|
|
1305
1308
|
function di(e, t) {
|
|
1306
|
-
const i = wt(t),
|
|
1307
|
-
e.save(), e.strokeStyle = "#0091FF", e.lineWidth = 1.5, e.setLineDash([4, 3]), e.strokeRect(i.x -
|
|
1309
|
+
const i = wt(t), o = 6;
|
|
1310
|
+
e.save(), e.strokeStyle = "#0091FF", e.lineWidth = 1.5, e.setLineDash([4, 3]), e.strokeRect(i.x - o, i.y - o, i.w + o * 2, i.h + o * 2), e.setLineDash([]);
|
|
1308
1311
|
const r = 5;
|
|
1309
1312
|
e.fillStyle = "#fff", e.strokeStyle = "#0091FF", e.lineWidth = 1.5;
|
|
1310
|
-
const
|
|
1311
|
-
[i.x -
|
|
1312
|
-
[i.x + i.w +
|
|
1313
|
-
[i.x -
|
|
1314
|
-
[i.x + i.w +
|
|
1313
|
+
const n = [
|
|
1314
|
+
[i.x - o, i.y - o],
|
|
1315
|
+
[i.x + i.w + o, i.y - o],
|
|
1316
|
+
[i.x - o, i.y + i.h + o],
|
|
1317
|
+
[i.x + i.w + o, i.y + i.h + o]
|
|
1315
1318
|
];
|
|
1316
|
-
for (const [l, s] of
|
|
1319
|
+
for (const [l, s] of n)
|
|
1317
1320
|
e.beginPath(), e.arc(l, s, r, 0, Math.PI * 2), e.fill(), e.stroke();
|
|
1318
1321
|
e.restore();
|
|
1319
1322
|
}
|
|
1320
|
-
function
|
|
1323
|
+
function oe() {
|
|
1321
1324
|
V && (ae && (document.removeEventListener("keydown", ae), ae = null), document.body.style.overflow = mt, V.remove(), V = null);
|
|
1322
1325
|
}
|
|
1323
1326
|
function tt(e, t, i) {
|
|
1324
1327
|
V && (V.remove(), V = null), si(), mt = document.body.style.overflow, document.body.style.overflow = "hidden";
|
|
1325
|
-
let
|
|
1328
|
+
let o = "rect", r = "#FF3B30", n = 3, l = 0, s = [], m = e, h = 0, u = 0, p = 1, g = 0, y = 0, k = !1, b = [], x = null, E = null, C = null, N = null, M = null, D = null, K = null;
|
|
1326
1329
|
const ce = document.createElement("div");
|
|
1327
1330
|
ce.className = `${c}-backdrop`;
|
|
1328
1331
|
const X = document.createElement("div");
|
|
@@ -1333,40 +1336,40 @@ function tt(e, t, i) {
|
|
|
1333
1336
|
Me.className = `${c}-title`, Me.textContent = "Edit screenshot";
|
|
1334
1337
|
const Z = document.createElement("button");
|
|
1335
1338
|
Z.className = `${c}-close-btn`, Z.setAttribute("aria-label", "Close"), Z.innerHTML = Re.close, Z.onclick = () => {
|
|
1336
|
-
|
|
1339
|
+
oe(), i();
|
|
1337
1340
|
}, ue.appendChild(Me), ue.appendChild(Z);
|
|
1338
|
-
const
|
|
1339
|
-
|
|
1341
|
+
const S = document.createElement("div");
|
|
1342
|
+
S.className = `${c}-canvas-wrap`;
|
|
1340
1343
|
const j = document.createElement("img");
|
|
1341
1344
|
j.className = `${c}-img`, j.alt = "Screenshot";
|
|
1342
1345
|
const P = document.createElement("canvas");
|
|
1343
|
-
P.className = `${c}-canvas`,
|
|
1346
|
+
P.className = `${c}-canvas`, S.appendChild(j), S.appendChild(P);
|
|
1344
1347
|
const ee = document.createElement("div");
|
|
1345
1348
|
ee.className = `${c}-toolbar`;
|
|
1346
1349
|
const O = document.createElement("div");
|
|
1347
1350
|
O.className = `${c}-tools`;
|
|
1348
1351
|
const He = {}, Et = ["select", "pen", "arrow", "rect", "text", "crop"], Ae = { select: "Select & Move", pen: "Pen", arrow: "Arrow", rect: "Rectangle", text: "Text", crop: "Crop" };
|
|
1349
1352
|
for (const a of Et) {
|
|
1350
|
-
const
|
|
1351
|
-
|
|
1353
|
+
const d = document.createElement("button");
|
|
1354
|
+
d.className = `${c}-tool-btn${a === "rect" ? " active" : ""}`, d.setAttribute("aria-label", Ae[a]), d.title = Ae[a], d.innerHTML = Re[a], d.onclick = () => qe(a), He[a] = d, O.appendChild(d);
|
|
1352
1355
|
}
|
|
1353
1356
|
const De = document.createElement("div");
|
|
1354
1357
|
De.className = `${c}-separator`, O.appendChild(De);
|
|
1355
1358
|
const St = ["#FF3B30", "#FF9500", "#FFCC00", "#34C759", "#0091FF", "#AF52DE", "#FF2D55", "#000000", "#8E8E93"], he = document.createElement("div");
|
|
1356
1359
|
he.className = `${c}-color-swatches`;
|
|
1357
1360
|
const We = [];
|
|
1358
|
-
function
|
|
1359
|
-
We.forEach((
|
|
1361
|
+
function Ie(a) {
|
|
1362
|
+
We.forEach((d) => d.classList.toggle("active", d.dataset.color === a));
|
|
1360
1363
|
}
|
|
1361
1364
|
for (const a of St) {
|
|
1362
|
-
const
|
|
1363
|
-
|
|
1364
|
-
r = a, F.value = a,
|
|
1365
|
-
}, We.push(
|
|
1365
|
+
const d = document.createElement("button");
|
|
1366
|
+
d.className = `${c}-swatch${a === r ? " active" : ""}`, d.style.background = a, d.dataset.color = a, d.setAttribute("aria-label", `Color ${a}`), d.onclick = () => {
|
|
1367
|
+
r = a, F.value = a, Ie(a), ye("color", a);
|
|
1368
|
+
}, We.push(d), he.appendChild(d);
|
|
1366
1369
|
}
|
|
1367
1370
|
const F = document.createElement("input");
|
|
1368
1371
|
F.type = "color", F.value = r, F.className = `${c}-color-picker`, F.setAttribute("aria-label", "Custom color"), F.title = "Custom color", F.oninput = () => {
|
|
1369
|
-
r = F.value,
|
|
1372
|
+
r = F.value, Ie(""), ye("color", r);
|
|
1370
1373
|
}, he.appendChild(F), O.appendChild(he);
|
|
1371
1374
|
const Be = document.createElement("div");
|
|
1372
1375
|
Be.className = `${c}-separator`, O.appendChild(Be);
|
|
@@ -1375,8 +1378,8 @@ function tt(e, t, i) {
|
|
|
1375
1378
|
const te = document.createElement("span");
|
|
1376
1379
|
te.className = `${c}-thickness-label`, te.textContent = "3px";
|
|
1377
1380
|
const U = document.createElement("input");
|
|
1378
|
-
U.type = "range", U.min = "1", U.max = "12", U.value = String(
|
|
1379
|
-
|
|
1381
|
+
U.type = "range", U.min = "1", U.max = "12", U.value = String(n), U.className = `${c}-thickness-slider`, U.setAttribute("aria-label", "Stroke thickness"), U.oninput = () => {
|
|
1382
|
+
n = parseInt(U.value, 10), te.textContent = `${n}px`, ye("width", n);
|
|
1380
1383
|
}, ge.appendChild(U), ge.appendChild(te), O.appendChild(ge);
|
|
1381
1384
|
const je = document.createElement("div");
|
|
1382
1385
|
je.className = `${c}-separator`, O.appendChild(je);
|
|
@@ -1386,189 +1389,189 @@ function tt(e, t, i) {
|
|
|
1386
1389
|
}, O.appendChild(G);
|
|
1387
1390
|
const Ge = document.createElement("div");
|
|
1388
1391
|
Ge.className = `${c}-separator`, O.appendChild(Ge);
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1391
|
-
s.length > 0 && (s.pop(),
|
|
1392
|
-
}, O.appendChild(
|
|
1392
|
+
const T = document.createElement("button");
|
|
1393
|
+
T.className = `${c}-undo-btn`, T.setAttribute("aria-label", "Undo"), T.title = "Undo", T.innerHTML = Re.undo, T.disabled = !0, T.onclick = () => {
|
|
1394
|
+
s.length > 0 && (s.pop(), T.disabled = s.length === 0, C = null, I());
|
|
1395
|
+
}, O.appendChild(T);
|
|
1393
1396
|
const z = document.createElement("button");
|
|
1394
|
-
z.className = `${c}-btn-crop-apply`, z.textContent = "Apply crop", z.style.display = "none", z.onclick =
|
|
1397
|
+
z.className = `${c}-btn-crop-apply`, z.textContent = "Apply crop", z.style.display = "none", z.onclick = It;
|
|
1395
1398
|
const me = document.createElement("div");
|
|
1396
1399
|
me.className = `${c}-actions`;
|
|
1397
1400
|
const fe = document.createElement("button");
|
|
1398
1401
|
fe.className = `${c}-btn-cancel`, fe.textContent = "Cancel", fe.onclick = () => {
|
|
1399
|
-
|
|
1402
|
+
oe(), i();
|
|
1400
1403
|
};
|
|
1401
1404
|
const we = document.createElement("button");
|
|
1402
|
-
we.className = `${c}-btn-done`, we.textContent = "Done", we.onclick = Lt, me.appendChild(fe), me.appendChild(we), ee.appendChild(O), ee.appendChild(z), ee.appendChild(me), X.appendChild(ue), X.appendChild(
|
|
1405
|
+
we.className = `${c}-btn-done`, we.textContent = "Done", we.onclick = Lt, me.appendChild(fe), me.appendChild(we), ee.appendChild(O), ee.appendChild(z), ee.appendChild(me), X.appendChild(ue), X.appendChild(S), X.appendChild(ee), ce.appendChild(X), document.body.appendChild(ce), V = ce;
|
|
1403
1406
|
function qe(a) {
|
|
1404
|
-
|
|
1405
|
-
for (const [
|
|
1406
|
-
|
|
1407
|
-
a !== "crop" && (M = null, D = null, z.style.display = "none"), a !== "select" && (C = null),
|
|
1407
|
+
o = a;
|
|
1408
|
+
for (const [d, w] of Object.entries(He))
|
|
1409
|
+
w.classList.toggle("active", d === a);
|
|
1410
|
+
a !== "crop" && (M = null, D = null, z.style.display = "none"), a !== "select" && (C = null), S.classList.toggle("select-mode", a === "select"), S.classList.remove("select-mode-moving"), ie(), I();
|
|
1408
1411
|
}
|
|
1409
|
-
function ye(a,
|
|
1412
|
+
function ye(a, d) {
|
|
1410
1413
|
if (C === null || C >= s.length) return;
|
|
1411
|
-
const
|
|
1412
|
-
a === "color" ?
|
|
1414
|
+
const w = s[C];
|
|
1415
|
+
a === "color" ? w.color = d : a === "width" && "width" in w ? w.width = d : a === "radius" && w.type === "rect" && (w.radius = d), I();
|
|
1413
1416
|
}
|
|
1414
1417
|
function Mt(a) {
|
|
1415
|
-
r = a.color, F.value = a.color,
|
|
1418
|
+
r = a.color, F.value = a.color, Ie(a.color), "width" in a && (n = a.width, U.value = String(a.width), te.textContent = `${a.width}px`), a.type === "rect" && (l = a.radius, G.classList.toggle("active", a.radius > 0));
|
|
1416
1419
|
}
|
|
1417
|
-
function
|
|
1418
|
-
const
|
|
1420
|
+
function Te(a, d) {
|
|
1421
|
+
const w = S.getBoundingClientRect();
|
|
1419
1422
|
return {
|
|
1420
|
-
x: Math.round((a -
|
|
1421
|
-
y: Math.round((
|
|
1423
|
+
x: Math.round((a - w.left - g) / p),
|
|
1424
|
+
y: Math.round((d - w.top - y) / p)
|
|
1422
1425
|
};
|
|
1423
1426
|
}
|
|
1424
1427
|
function Ye() {
|
|
1425
|
-
if (!
|
|
1426
|
-
const a =
|
|
1427
|
-
|
|
1428
|
+
if (!h || !u) return;
|
|
1429
|
+
const a = S.clientWidth - 32, d = S.clientHeight - 32;
|
|
1430
|
+
p = Math.min(a / h, d / u, 1), g = (S.clientWidth - h * p) / 2, y = (S.clientHeight - u * p) / 2, j.style.width = `${h * p}px`, j.style.height = `${u * p}px`, j.style.marginLeft = `${g}px`, j.style.marginTop = `${y}px`, P.width = S.clientWidth, P.height = S.clientHeight, I();
|
|
1428
1431
|
}
|
|
1429
1432
|
function Ke() {
|
|
1430
1433
|
const a = new Image();
|
|
1431
1434
|
a.onload = () => {
|
|
1432
|
-
|
|
1433
|
-
}, a.src =
|
|
1435
|
+
h = a.naturalWidth, u = a.naturalHeight, j.src = m, Ye();
|
|
1436
|
+
}, a.src = m;
|
|
1434
1437
|
}
|
|
1435
|
-
function
|
|
1438
|
+
function I() {
|
|
1436
1439
|
const a = P.getContext("2d");
|
|
1437
1440
|
if (a) {
|
|
1438
|
-
if (a.clearRect(0, 0, P.width, P.height), a.save(), a.translate(
|
|
1439
|
-
Ze(a,
|
|
1440
|
-
}),
|
|
1441
|
-
a.strokeStyle = r, a.lineWidth =
|
|
1442
|
-
for (let
|
|
1441
|
+
if (a.clearRect(0, 0, P.width, P.height), a.save(), a.translate(g, y), a.scale(p, p), s.forEach((d, w) => {
|
|
1442
|
+
Ze(a, d), w === C && di(a, d);
|
|
1443
|
+
}), k && b.length >= 4 && o === "pen") {
|
|
1444
|
+
a.strokeStyle = r, a.lineWidth = n, a.lineCap = "round", a.lineJoin = "round", a.beginPath(), a.moveTo(b[0], b[1]);
|
|
1445
|
+
for (let d = 2; d < b.length; d += 2) a.lineTo(b[d], b[d + 1]);
|
|
1443
1446
|
a.stroke();
|
|
1444
1447
|
}
|
|
1445
|
-
if (a.restore(),
|
|
1448
|
+
if (a.restore(), o === "crop" && M) {
|
|
1446
1449
|
a.fillStyle = "rgba(0,0,0,0.4)", a.fillRect(0, 0, P.width, P.height);
|
|
1447
|
-
const
|
|
1448
|
-
a.clearRect(
|
|
1450
|
+
const d = g + M.x * p, w = y + M.y * p, f = M.w * p, v = M.h * p;
|
|
1451
|
+
a.clearRect(d, w, f, v), a.strokeStyle = "#0091FF", a.lineWidth = 2, a.strokeRect(d, w, f, v), z.style.display = "";
|
|
1449
1452
|
}
|
|
1450
1453
|
}
|
|
1451
1454
|
}
|
|
1452
|
-
function
|
|
1455
|
+
function It() {
|
|
1453
1456
|
if (!M || M.w < 10 || M.h < 10) return;
|
|
1454
1457
|
const a = new Image();
|
|
1455
1458
|
a.onload = () => {
|
|
1456
|
-
const
|
|
1457
|
-
|
|
1458
|
-
const
|
|
1459
|
-
|
|
1460
|
-
}, a.src =
|
|
1459
|
+
const d = document.createElement("canvas");
|
|
1460
|
+
d.width = M.w, d.height = M.h;
|
|
1461
|
+
const w = d.getContext("2d");
|
|
1462
|
+
w && (w.drawImage(a, M.x, M.y, M.w, M.h, 0, 0, M.w, M.h), m = d.toDataURL("image/png"), s = [], T.disabled = !0, C = null, M = null, D = null, z.style.display = "none", qe("rect"), Ke());
|
|
1463
|
+
}, a.src = m;
|
|
1461
1464
|
}
|
|
1462
1465
|
function ie() {
|
|
1463
1466
|
K && (K.remove(), K = null);
|
|
1464
1467
|
}
|
|
1465
|
-
function
|
|
1468
|
+
function Tt(a, d) {
|
|
1466
1469
|
ie();
|
|
1467
|
-
const
|
|
1468
|
-
|
|
1469
|
-
const
|
|
1470
|
-
|
|
1471
|
-
const
|
|
1472
|
-
|
|
1470
|
+
const w = document.createElement("div");
|
|
1471
|
+
w.className = `${c}-text-overlay`, w.style.left = `${a * p + g}px`, w.style.top = `${d * p + y}px`;
|
|
1472
|
+
const f = document.createElement("input");
|
|
1473
|
+
f.type = "text", f.className = `${c}-text-input`, f.placeholder = "Text...";
|
|
1474
|
+
const v = document.createElement("button");
|
|
1475
|
+
v.className = `${c}-text-ok`, v.textContent = "Add";
|
|
1473
1476
|
const H = () => {
|
|
1474
|
-
const q =
|
|
1475
|
-
q && (s.push({ type: "text", x: a, y:
|
|
1477
|
+
const q = f.value.trim();
|
|
1478
|
+
q && (s.push({ type: "text", x: a, y: d, text: q, color: r }), T.disabled = !1, I()), ie();
|
|
1476
1479
|
};
|
|
1477
|
-
|
|
1480
|
+
f.onkeydown = (q) => {
|
|
1478
1481
|
q.key === "Enter" && H(), q.key === "Escape" && ie();
|
|
1479
|
-
},
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
const { x:
|
|
1483
|
-
if (
|
|
1484
|
-
let
|
|
1485
|
-
for (let
|
|
1486
|
-
if (ai(s[
|
|
1487
|
-
|
|
1482
|
+
}, v.onclick = H, w.appendChild(f), w.appendChild(v), S.appendChild(w), K = w, f.focus();
|
|
1483
|
+
}
|
|
1484
|
+
S.onmousedown = (a) => {
|
|
1485
|
+
const { x: d, y: w } = Te(a.clientX, a.clientY);
|
|
1486
|
+
if (o === "select") {
|
|
1487
|
+
let f = -1;
|
|
1488
|
+
for (let v = s.length - 1; v >= 0; v--)
|
|
1489
|
+
if (ai(s[v], d, w, 8)) {
|
|
1490
|
+
f = v;
|
|
1488
1491
|
break;
|
|
1489
1492
|
}
|
|
1490
|
-
|
|
1493
|
+
f >= 0 ? (C = f, N = { x: d, y: w }, Mt(s[f]), S.classList.add("select-mode-moving")) : C = null, I();
|
|
1491
1494
|
return;
|
|
1492
1495
|
}
|
|
1493
|
-
if (
|
|
1494
|
-
D = { x:
|
|
1496
|
+
if (o === "crop") {
|
|
1497
|
+
D = { x: d, y: w }, M = null, z.style.display = "none";
|
|
1495
1498
|
return;
|
|
1496
1499
|
}
|
|
1497
|
-
K || (C = null,
|
|
1498
|
-
},
|
|
1499
|
-
const { x:
|
|
1500
|
-
if (
|
|
1501
|
-
const
|
|
1502
|
-
(Math.abs(
|
|
1500
|
+
K || (C = null, o === "pen" ? (k = !0, b = [d, w]) : o === "arrow" ? x = { x: d, y: w } : o === "rect" ? E = { x: d, y: w } : o === "text" && Tt(d, w));
|
|
1501
|
+
}, S.onmousemove = (a) => {
|
|
1502
|
+
const { x: d, y: w } = Te(a.clientX, a.clientY);
|
|
1503
|
+
if (o === "select" && N && C !== null) {
|
|
1504
|
+
const f = d - N.x, v = w - N.y;
|
|
1505
|
+
(Math.abs(f) > 1 || Math.abs(v) > 1) && (li(s[C], f, v), N = { x: d, y: w }, I());
|
|
1503
1506
|
return;
|
|
1504
1507
|
}
|
|
1505
|
-
if (
|
|
1506
|
-
const
|
|
1507
|
-
M = { x:
|
|
1508
|
-
} else if (
|
|
1509
|
-
b.push(
|
|
1510
|
-
else if (
|
|
1511
|
-
|
|
1512
|
-
const
|
|
1513
|
-
if (
|
|
1514
|
-
|
|
1515
|
-
const
|
|
1516
|
-
l > 0 ? ft(
|
|
1508
|
+
if (o === "crop" && D) {
|
|
1509
|
+
const f = Math.min(D.x, d), v = Math.min(D.y, w);
|
|
1510
|
+
M = { x: f, y: v, w: Math.max(20, Math.abs(d - D.x)), h: Math.max(20, Math.abs(w - D.y)) }, I();
|
|
1511
|
+
} else if (k && o === "pen")
|
|
1512
|
+
b.push(d, w), I();
|
|
1513
|
+
else if (o === "rect" && E) {
|
|
1514
|
+
I();
|
|
1515
|
+
const f = P.getContext("2d");
|
|
1516
|
+
if (f) {
|
|
1517
|
+
f.save(), f.translate(g, y), f.scale(p, p), f.strokeStyle = r, f.lineWidth = n, f.lineCap = "round", f.lineJoin = "round";
|
|
1518
|
+
const v = Math.min(E.x, d), H = Math.min(E.y, w), q = Math.abs(d - E.x), Ve = Math.abs(w - E.y);
|
|
1519
|
+
l > 0 ? ft(f, v, H, q, Ve, l) : f.strokeRect(v, H, q, Ve), f.restore();
|
|
1517
1520
|
}
|
|
1518
|
-
} else if (
|
|
1519
|
-
|
|
1520
|
-
const
|
|
1521
|
-
if (
|
|
1522
|
-
|
|
1523
|
-
const
|
|
1524
|
-
|
|
1521
|
+
} else if (o === "arrow" && x) {
|
|
1522
|
+
I();
|
|
1523
|
+
const f = P.getContext("2d");
|
|
1524
|
+
if (f) {
|
|
1525
|
+
f.save(), f.translate(g, y), f.scale(p, p), f.strokeStyle = r, f.fillStyle = r, f.lineWidth = n, f.lineCap = "round", f.lineJoin = "round", f.beginPath(), f.moveTo(x.x, x.y), f.lineTo(d, w), f.stroke();
|
|
1526
|
+
const v = 10, H = Math.atan2(w - x.y, d - x.x);
|
|
1527
|
+
f.beginPath(), f.moveTo(d, w), f.lineTo(d - v * Math.cos(H - 0.4), w - v * Math.sin(H - 0.4)), f.lineTo(d - v * Math.cos(H + 0.4), w - v * Math.sin(H + 0.4)), f.closePath(), f.fill(), f.restore();
|
|
1525
1528
|
}
|
|
1526
1529
|
}
|
|
1527
|
-
},
|
|
1528
|
-
const { x:
|
|
1529
|
-
if (
|
|
1530
|
-
N = null,
|
|
1530
|
+
}, S.onmouseup = (a) => {
|
|
1531
|
+
const { x: d, y: w } = Te(a.clientX, a.clientY);
|
|
1532
|
+
if (o === "select") {
|
|
1533
|
+
N = null, S.classList.remove("select-mode-moving");
|
|
1531
1534
|
return;
|
|
1532
1535
|
}
|
|
1533
|
-
if (
|
|
1536
|
+
if (o === "crop") {
|
|
1534
1537
|
D = null;
|
|
1535
1538
|
return;
|
|
1536
1539
|
}
|
|
1537
|
-
if (
|
|
1538
|
-
|
|
1539
|
-
else if (
|
|
1540
|
-
s.push({ type: "arrow", x1:
|
|
1541
|
-
else if (
|
|
1542
|
-
const
|
|
1543
|
-
s.push({ type: "rect", x:
|
|
1540
|
+
if (o === "pen" && k)
|
|
1541
|
+
k = !1, b.length >= 4 && (s.push({ type: "pen", points: [...b], color: r, width: n }), T.disabled = !1, b = []);
|
|
1542
|
+
else if (o === "arrow" && x)
|
|
1543
|
+
s.push({ type: "arrow", x1: x.x, y1: x.y, x2: d, y2: w, color: r, width: n }), T.disabled = !1, x = null;
|
|
1544
|
+
else if (o === "rect" && E) {
|
|
1545
|
+
const f = Math.min(E.x, d), v = Math.min(E.y, w);
|
|
1546
|
+
s.push({ type: "rect", x: f, y: v, w: Math.abs(d - E.x), h: Math.abs(w - E.y), color: r, width: n, radius: l }), T.disabled = !1, E = null;
|
|
1544
1547
|
}
|
|
1545
|
-
|
|
1546
|
-
},
|
|
1547
|
-
if (
|
|
1548
|
-
N = null,
|
|
1548
|
+
I();
|
|
1549
|
+
}, S.onmouseleave = (a) => {
|
|
1550
|
+
if (o === "select" && N) {
|
|
1551
|
+
N = null, S.classList.remove("select-mode-moving");
|
|
1549
1552
|
return;
|
|
1550
1553
|
}
|
|
1551
|
-
|
|
1554
|
+
S.onmouseup(a);
|
|
1552
1555
|
};
|
|
1553
1556
|
function Lt() {
|
|
1554
1557
|
const a = new Image();
|
|
1555
1558
|
a.onload = () => {
|
|
1556
|
-
const
|
|
1557
|
-
|
|
1558
|
-
const
|
|
1559
|
-
if (!
|
|
1560
|
-
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1559
|
+
const d = document.createElement("canvas");
|
|
1560
|
+
d.width = a.naturalWidth, d.height = a.naturalHeight;
|
|
1561
|
+
const w = d.getContext("2d");
|
|
1562
|
+
if (!w) return;
|
|
1563
|
+
w.drawImage(a, 0, 0), s.forEach((v) => Ze(w, v));
|
|
1564
|
+
const f = d.toDataURL("image/png");
|
|
1565
|
+
oe(), t(f);
|
|
1563
1566
|
}, a.onerror = () => {
|
|
1564
|
-
|
|
1565
|
-
}, a.src =
|
|
1567
|
+
oe(), t(m);
|
|
1568
|
+
}, a.src = m;
|
|
1566
1569
|
}
|
|
1567
1570
|
ae = (a) => {
|
|
1568
|
-
a.key === "Escape" ? K ? ie() :
|
|
1571
|
+
a.key === "Escape" ? K ? ie() : o === "crop" && M ? (M = null, z.style.display = "none", I()) : C !== null ? (C = null, I()) : (oe(), i()) : a.key === "z" && (a.ctrlKey || a.metaKey) && !a.shiftKey ? (a.preventDefault(), s.length > 0 && (s.pop(), T.disabled = s.length === 0, C = null, I())) : (a.key === "Delete" || a.key === "Backspace") && C !== null && !K && (a.preventDefault(), s.splice(C, 1), T.disabled = s.length === 0, C = null, I());
|
|
1569
1572
|
}, document.addEventListener("keydown", ae), new ResizeObserver(() => {
|
|
1570
|
-
|
|
1571
|
-
}).observe(
|
|
1573
|
+
h && u && Ye();
|
|
1574
|
+
}).observe(S), Ke();
|
|
1572
1575
|
}
|
|
1573
1576
|
const Pe = 3, it = 8, rt = 14, pi = `<svg width="20" height="20" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1574
1577
|
<defs>
|
|
@@ -1589,11 +1592,11 @@ const Pe = 3, it = 8, rt = 14, pi = `<svg width="20" height="20" viewBox="0 0 20
|
|
|
1589
1592
|
let _ = null, Y = null;
|
|
1590
1593
|
const $ = [];
|
|
1591
1594
|
let le = !1;
|
|
1592
|
-
const
|
|
1595
|
+
const ot = "supportwire-message-preview-styles";
|
|
1593
1596
|
function ci() {
|
|
1594
|
-
if (document.getElementById(
|
|
1597
|
+
if (document.getElementById(ot)) return;
|
|
1595
1598
|
const e = document.createElement("style");
|
|
1596
|
-
e.id =
|
|
1599
|
+
e.id = ot, e.textContent = `
|
|
1597
1600
|
.sw-preview-stack {
|
|
1598
1601
|
position: fixed;
|
|
1599
1602
|
z-index: 999997;
|
|
@@ -1729,8 +1732,8 @@ function Ce() {
|
|
|
1729
1732
|
if (le) {
|
|
1730
1733
|
let e = 0;
|
|
1731
1734
|
for (let t = 0; t < $.length; t++) {
|
|
1732
|
-
const { el: i, height:
|
|
1733
|
-
i.style.zIndex = String(Pe + 1 - t), i.style.transform = `translateY(-${e}px) scale(1)`, i.style.opacity = i.dataset.visible === "true" ? "1" : "0", e +=
|
|
1735
|
+
const { el: i, height: o } = $[t];
|
|
1736
|
+
i.style.zIndex = String(Pe + 1 - t), i.style.transform = `translateY(-${e}px) scale(1)`, i.style.opacity = i.dataset.visible === "true" ? "1" : "0", e += o + it;
|
|
1734
1737
|
}
|
|
1735
1738
|
_.style.height = `${e - it}px`;
|
|
1736
1739
|
} else {
|
|
@@ -1743,44 +1746,44 @@ function Ce() {
|
|
|
1743
1746
|
}
|
|
1744
1747
|
function ui(e) {
|
|
1745
1748
|
if (!Number.isFinite(e) || e <= 0) return "just now";
|
|
1746
|
-
const t = Date.now(), i = e < 1e12 ? e * 1e3 : e,
|
|
1749
|
+
const t = Date.now(), i = e < 1e12 ? e * 1e3 : e, o = Math.max(0, t - i), r = Math.floor(o / 1e3);
|
|
1747
1750
|
if (r < 60) return "just now";
|
|
1748
|
-
const
|
|
1749
|
-
if (
|
|
1750
|
-
const l = Math.floor(
|
|
1751
|
+
const n = Math.floor(r / 60);
|
|
1752
|
+
if (n < 60) return `${n}m ago`;
|
|
1753
|
+
const l = Math.floor(n / 60);
|
|
1751
1754
|
return l < 24 ? `${l}h ago` : `${Math.floor(l / 24)}d ago`;
|
|
1752
1755
|
}
|
|
1753
1756
|
function hi(e, t) {
|
|
1754
1757
|
if (_) return _;
|
|
1755
1758
|
const i = document.createElement("div");
|
|
1756
1759
|
i.className = "sw-preview-stack";
|
|
1757
|
-
const
|
|
1758
|
-
return
|
|
1760
|
+
const o = e.startsWith("bottom"), r = e.endsWith("right"), n = 20, l = 48, s = 8;
|
|
1761
|
+
return o ? i.style.bottom = `${n + l + s}px` : i.style.top = `${n + l + s}px`, r ? i.style.right = `${n}px` : i.style.left = `${n}px`, i.addEventListener("mouseenter", () => {
|
|
1759
1762
|
le = !0, Ce();
|
|
1760
1763
|
}), i.addEventListener("mouseleave", () => {
|
|
1761
1764
|
le = !1, Ce();
|
|
1762
|
-
}), Y = document.createElement("button"), Y.className = `sw-preview-dismiss sw-dismiss-${t}`, Y.setAttribute("aria-label", "Dismiss all message previews"), Y.textContent = "×", Y.addEventListener("click", (
|
|
1763
|
-
|
|
1765
|
+
}), Y = document.createElement("button"), Y.className = `sw-preview-dismiss sw-dismiss-${t}`, Y.setAttribute("aria-label", "Dismiss all message previews"), Y.textContent = "×", Y.addEventListener("click", (m) => {
|
|
1766
|
+
m.stopPropagation(), ke();
|
|
1764
1767
|
}), i.appendChild(Y), document.body.appendChild(i), _ = i, i;
|
|
1765
1768
|
}
|
|
1766
|
-
function gi(e, t, i,
|
|
1769
|
+
function gi(e, t, i, o, r, n) {
|
|
1767
1770
|
ci();
|
|
1768
|
-
const l = hi(
|
|
1771
|
+
const l = hi(o, r);
|
|
1769
1772
|
$.length >= Pe && $.pop().el.remove();
|
|
1770
1773
|
const s = document.createElement("div");
|
|
1771
1774
|
s.className = `sw-preview-card sw-card-${r}`, s.dataset.visible = "false";
|
|
1772
|
-
const
|
|
1773
|
-
|
|
1774
|
-
const d = document.createElement("div");
|
|
1775
|
-
d.className = "sw-preview-logo", d.innerHTML = pi;
|
|
1775
|
+
const m = document.createElement("div");
|
|
1776
|
+
m.className = "sw-preview-header";
|
|
1776
1777
|
const h = document.createElement("div");
|
|
1777
|
-
h.className = "sw-preview-
|
|
1778
|
-
const
|
|
1779
|
-
|
|
1780
|
-
|
|
1778
|
+
h.className = "sw-preview-logo", h.innerHTML = pi;
|
|
1779
|
+
const u = document.createElement("div");
|
|
1780
|
+
u.className = "sw-preview-meta", u.textContent = `${t || "Support"} · ${ui(i)}`, m.appendChild(h), m.appendChild(u);
|
|
1781
|
+
const p = document.createElement("div");
|
|
1782
|
+
p.className = "sw-preview-body", p.textContent = e, s.appendChild(m), s.appendChild(p), s.addEventListener("click", () => {
|
|
1783
|
+
ke(!0), n();
|
|
1781
1784
|
}), l.appendChild(s);
|
|
1782
|
-
const
|
|
1783
|
-
$.unshift({ el: s, height:
|
|
1785
|
+
const g = s.offsetHeight;
|
|
1786
|
+
$.unshift({ el: s, height: g }), Ce(), requestAnimationFrame(() => {
|
|
1784
1787
|
requestAnimationFrame(() => {
|
|
1785
1788
|
s.dataset.visible = "true", Ce();
|
|
1786
1789
|
});
|
|
@@ -1796,10 +1799,10 @@ function ke(e) {
|
|
|
1796
1799
|
$.length = 0;
|
|
1797
1800
|
for (const i of t) {
|
|
1798
1801
|
i.el.dataset.visible = "false", i.el.style.opacity = "0";
|
|
1799
|
-
const
|
|
1800
|
-
i.el.removeEventListener("transitionend",
|
|
1802
|
+
const o = () => {
|
|
1803
|
+
i.el.removeEventListener("transitionend", o), i.el.remove();
|
|
1801
1804
|
};
|
|
1802
|
-
i.el.addEventListener("transitionend",
|
|
1805
|
+
i.el.addEventListener("transitionend", o), setTimeout(() => i.el.remove(), 300);
|
|
1803
1806
|
}
|
|
1804
1807
|
if (_) {
|
|
1805
1808
|
const i = _;
|
|
@@ -1830,15 +1833,15 @@ function fi(e) {
|
|
|
1830
1833
|
}
|
|
1831
1834
|
function wi(e, t) {
|
|
1832
1835
|
try {
|
|
1833
|
-
const i = (
|
|
1836
|
+
const i = (n) => n.replace(/\/+$/, "");
|
|
1834
1837
|
if (!t.includes("*"))
|
|
1835
1838
|
return i(e) === i(t);
|
|
1836
|
-
const
|
|
1839
|
+
const o = t.split("*").map((n) => {
|
|
1837
1840
|
let l = "";
|
|
1838
|
-
for (const s of
|
|
1841
|
+
for (const s of n)
|
|
1839
1842
|
"-/\\^$*+?.()|[]{}".indexOf(s) !== -1 && (l += "\\"), l += s;
|
|
1840
1843
|
return l;
|
|
1841
|
-
}), r = new RegExp("^" +
|
|
1844
|
+
}), r = new RegExp("^" + o.join(".*") + "$");
|
|
1842
1845
|
return r.test(e) || r.test(i(e));
|
|
1843
1846
|
} catch {
|
|
1844
1847
|
return !1;
|
|
@@ -1846,55 +1849,55 @@ function wi(e, t) {
|
|
|
1846
1849
|
}
|
|
1847
1850
|
function yi(e, t) {
|
|
1848
1851
|
var i;
|
|
1849
|
-
const
|
|
1852
|
+
const o = [];
|
|
1850
1853
|
for (const r of e) {
|
|
1851
1854
|
if (r.event_name !== "SW_PAGE_VIEW") continue;
|
|
1852
|
-
const
|
|
1853
|
-
if (
|
|
1855
|
+
const n = (i = r.event_info) == null ? void 0 : i.url;
|
|
1856
|
+
if (n) {
|
|
1854
1857
|
if (fi(r)) {
|
|
1855
1858
|
Ue(r.id);
|
|
1856
1859
|
continue;
|
|
1857
1860
|
}
|
|
1858
|
-
wi(t,
|
|
1861
|
+
wi(t, n) && o.push({
|
|
1859
1862
|
ruleId: r.id,
|
|
1860
1863
|
delay: r.delay,
|
|
1861
1864
|
messagesToSend: r.messages_to_send
|
|
1862
1865
|
});
|
|
1863
1866
|
}
|
|
1864
1867
|
}
|
|
1865
|
-
return
|
|
1868
|
+
return o;
|
|
1866
1869
|
}
|
|
1867
1870
|
function bi(e, t) {
|
|
1868
1871
|
var i;
|
|
1869
|
-
for (const
|
|
1870
|
-
(i =
|
|
1871
|
-
const
|
|
1872
|
-
let
|
|
1872
|
+
for (const u of e)
|
|
1873
|
+
(i = u.event_info) != null && i.url, u.max_executions != null && String(u.max_executions), Ue(u.id);
|
|
1874
|
+
const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
1875
|
+
let n = "";
|
|
1873
1876
|
function l() {
|
|
1874
|
-
const
|
|
1875
|
-
if (
|
|
1876
|
-
|
|
1877
|
-
const
|
|
1878
|
-
for (const
|
|
1879
|
-
if (r.has(
|
|
1877
|
+
const u = window.location.href;
|
|
1878
|
+
if (u === n) return;
|
|
1879
|
+
n = u;
|
|
1880
|
+
const p = yi(e, u);
|
|
1881
|
+
for (const g of p) {
|
|
1882
|
+
if (r.has(g.ruleId))
|
|
1880
1883
|
continue;
|
|
1881
|
-
r.add(
|
|
1882
|
-
const y = (
|
|
1883
|
-
|
|
1884
|
+
r.add(g.ruleId);
|
|
1885
|
+
const y = (g.delay || 0) * 1e3, k = setTimeout(() => {
|
|
1886
|
+
o.delete(k), mi(g.ruleId), t(g);
|
|
1884
1887
|
}, y);
|
|
1885
|
-
|
|
1888
|
+
o.add(k);
|
|
1886
1889
|
}
|
|
1887
1890
|
}
|
|
1888
|
-
const s = history.pushState.bind(history),
|
|
1889
|
-
history.pushState = function(...
|
|
1890
|
-
s(...
|
|
1891
|
-
}, history.replaceState = function(...
|
|
1892
|
-
|
|
1891
|
+
const s = history.pushState.bind(history), m = history.replaceState.bind(history);
|
|
1892
|
+
history.pushState = function(...u) {
|
|
1893
|
+
s(...u), l();
|
|
1894
|
+
}, history.replaceState = function(...u) {
|
|
1895
|
+
m(...u), l();
|
|
1893
1896
|
};
|
|
1894
|
-
const
|
|
1895
|
-
return window.addEventListener("popstate",
|
|
1896
|
-
for (const
|
|
1897
|
-
|
|
1897
|
+
const h = () => l();
|
|
1898
|
+
return window.addEventListener("popstate", h), l(), () => {
|
|
1899
|
+
for (const u of o) clearTimeout(u);
|
|
1900
|
+
o.clear(), history.pushState = s, history.replaceState = m, window.removeEventListener("popstate", h);
|
|
1898
1901
|
};
|
|
1899
1902
|
}
|
|
1900
1903
|
const xi = "supportwire", de = (e, t) => `${xi}-${t}-${e}`, _e = (e, t) => {
|
|
@@ -1921,8 +1924,8 @@ const xi = "supportwire", de = (e, t) => `${xi}-${t}-${e}`, _e = (e, t) => {
|
|
|
1921
1924
|
return null;
|
|
1922
1925
|
}
|
|
1923
1926
|
};
|
|
1924
|
-
var Ei = { success: { pattern: [{ duration: 30, intensity: 0.5 }, { delay: 60, duration: 40, intensity: 1 }] }, warning: { pattern: [{ duration: 40, intensity: 0.8 }, { delay: 100, duration: 40, intensity: 0.6 }] }, error: { pattern: [{ duration: 40, intensity: 0.9 }, { delay: 40, duration: 40, intensity: 0.9 }, { delay: 40, duration: 40, intensity: 0.9 }] }, light: { pattern: [{ duration: 15, intensity: 0.4 }] }, medium: { pattern: [{ duration: 25, intensity: 0.7 }] }, heavy: { pattern: [{ duration: 35, intensity: 1 }] }, soft: { pattern: [{ duration: 40, intensity: 0.5 }] }, rigid: { pattern: [{ duration: 10, intensity: 1 }] }, selection: { pattern: [{ duration: 8, intensity: 0.3 }] }, nudge: { pattern: [{ duration: 80, intensity: 0.8 }, { delay: 80, duration: 50, intensity: 0.3 }] }, buzz: { pattern: [{ duration: 1e3, intensity: 1 }] } }, Si = 16, Mi = 184,
|
|
1925
|
-
function
|
|
1927
|
+
var Ei = { success: { pattern: [{ duration: 30, intensity: 0.5 }, { delay: 60, duration: 40, intensity: 1 }] }, warning: { pattern: [{ duration: 40, intensity: 0.8 }, { delay: 100, duration: 40, intensity: 0.6 }] }, error: { pattern: [{ duration: 40, intensity: 0.9 }, { delay: 40, duration: 40, intensity: 0.9 }, { delay: 40, duration: 40, intensity: 0.9 }] }, light: { pattern: [{ duration: 15, intensity: 0.4 }] }, medium: { pattern: [{ duration: 25, intensity: 0.7 }] }, heavy: { pattern: [{ duration: 35, intensity: 1 }] }, soft: { pattern: [{ duration: 40, intensity: 0.5 }] }, rigid: { pattern: [{ duration: 10, intensity: 1 }] }, selection: { pattern: [{ duration: 8, intensity: 0.3 }] }, nudge: { pattern: [{ duration: 80, intensity: 0.8 }, { delay: 80, duration: 50, intensity: 0.3 }] }, buzz: { pattern: [{ duration: 1e3, intensity: 1 }] } }, Si = 16, Mi = 184, nt = 1e3, xe = 20;
|
|
1928
|
+
function Ii(e) {
|
|
1926
1929
|
if (typeof e == "number") return { vibrations: [{ duration: e }] };
|
|
1927
1930
|
if (typeof e == "string") {
|
|
1928
1931
|
let t = Ei[e];
|
|
@@ -1932,9 +1935,9 @@ function Ti(e) {
|
|
|
1932
1935
|
if (e.length === 0) return { vibrations: [] };
|
|
1933
1936
|
if (typeof e[0] == "number") {
|
|
1934
1937
|
let t = e, i = [];
|
|
1935
|
-
for (let
|
|
1936
|
-
let r =
|
|
1937
|
-
i.push(Se(A({}, r > 0 && { delay: r }), { duration: t[
|
|
1938
|
+
for (let o = 0; o < t.length; o += 2) {
|
|
1939
|
+
let r = o > 0 ? t[o - 1] : 0;
|
|
1940
|
+
i.push(Se(A({}, r > 0 && { delay: r }), { duration: t[o] }));
|
|
1938
1941
|
}
|
|
1939
1942
|
return { vibrations: i };
|
|
1940
1943
|
}
|
|
@@ -1942,31 +1945,31 @@ function Ti(e) {
|
|
|
1942
1945
|
}
|
|
1943
1946
|
return { vibrations: e.pattern.map((t) => A({}, t)) };
|
|
1944
1947
|
}
|
|
1945
|
-
function
|
|
1948
|
+
function Ti(e, t) {
|
|
1946
1949
|
if (t >= 1) return [e];
|
|
1947
1950
|
if (t <= 0) return [];
|
|
1948
|
-
let i = Math.max(1, Math.round(xe * t)),
|
|
1949
|
-
for (;
|
|
1950
|
-
if (
|
|
1951
|
-
let l = Math.max(1, Math.round(
|
|
1951
|
+
let i = Math.max(1, Math.round(xe * t)), o = xe - i, r = [], n = e;
|
|
1952
|
+
for (; n >= xe; ) r.push(i), r.push(o), n -= xe;
|
|
1953
|
+
if (n > 0) {
|
|
1954
|
+
let l = Math.max(1, Math.round(n * t));
|
|
1952
1955
|
r.push(l);
|
|
1953
|
-
let s =
|
|
1956
|
+
let s = n - l;
|
|
1954
1957
|
s > 0 && r.push(s);
|
|
1955
1958
|
}
|
|
1956
1959
|
return r;
|
|
1957
1960
|
}
|
|
1958
1961
|
function Li(e, t) {
|
|
1959
|
-
var i,
|
|
1962
|
+
var i, o;
|
|
1960
1963
|
let r = [];
|
|
1961
|
-
for (let
|
|
1962
|
-
let l = e[
|
|
1963
|
-
|
|
1964
|
-
let
|
|
1965
|
-
if (
|
|
1964
|
+
for (let n = 0; n < e.length; n++) {
|
|
1965
|
+
let l = e[n], s = Math.max(0, Math.min(1, (i = l.intensity) != null ? i : t)), m = (o = l.delay) != null ? o : 0;
|
|
1966
|
+
m > 0 && (r.length > 0 && r.length % 2 === 0 ? r[r.length - 1] += m : (r.length === 0 && r.push(0), r.push(m)));
|
|
1967
|
+
let h = Ti(l.duration, s);
|
|
1968
|
+
if (h.length === 0) {
|
|
1966
1969
|
r.length > 0 && r.length % 2 === 0 ? r[r.length - 1] += l.duration : l.duration > 0 && (r.push(0), r.push(l.duration));
|
|
1967
1970
|
continue;
|
|
1968
1971
|
}
|
|
1969
|
-
for (let
|
|
1972
|
+
for (let u of h) r.push(u);
|
|
1970
1973
|
}
|
|
1971
1974
|
return r;
|
|
1972
1975
|
}
|
|
@@ -1977,25 +1980,25 @@ var $i = 0, Q, Ri = (Q = class {
|
|
|
1977
1980
|
this.instanceId = ++$i, this.debug = (t = e?.debug) != null ? t : !1, this.showSwitch = (i = e?.showSwitch) != null ? i : !1;
|
|
1978
1981
|
}
|
|
1979
1982
|
async trigger(e = [{ duration: 25, intensity: 0.7 }], t) {
|
|
1980
|
-
var i,
|
|
1981
|
-
let l =
|
|
1983
|
+
var i, o, r, n;
|
|
1984
|
+
let l = Ii(e);
|
|
1982
1985
|
if (!l) return;
|
|
1983
1986
|
let { vibrations: s } = l;
|
|
1984
1987
|
if (s.length === 0) return;
|
|
1985
|
-
let
|
|
1986
|
-
for (let
|
|
1988
|
+
let m = Math.max(0, Math.min(1, (i = t?.intensity) != null ? i : 0.5));
|
|
1989
|
+
for (let h of s) if (h.duration > nt && (h.duration = nt), !Number.isFinite(h.duration) || h.duration < 0 || h.delay !== void 0 && (!Number.isFinite(h.delay) || h.delay < 0)) {
|
|
1987
1990
|
console.warn("[web-haptics] Invalid vibration values. Durations and delays must be finite non-negative numbers.");
|
|
1988
1991
|
return;
|
|
1989
1992
|
}
|
|
1990
|
-
if (Q.isSupported && navigator.vibrate(Li(s,
|
|
1993
|
+
if (Q.isSupported && navigator.vibrate(Li(s, m)), !Q.isSupported || this.debug) {
|
|
1991
1994
|
if (this.ensureDOM(), !this.hapticLabel) return;
|
|
1992
1995
|
this.debug && await this.ensureAudio(), this.stopPattern();
|
|
1993
|
-
let
|
|
1994
|
-
if (
|
|
1995
|
-
let
|
|
1996
|
-
this.playClick(
|
|
1996
|
+
let h = ((r = (o = s[0]) == null ? void 0 : o.delay) != null ? r : 0) === 0;
|
|
1997
|
+
if (h && (this.hapticLabel.click(), this.debug && this.audioCtx)) {
|
|
1998
|
+
let u = Math.max(0, Math.min(1, (n = s[0].intensity) != null ? n : m));
|
|
1999
|
+
this.playClick(u);
|
|
1997
2000
|
}
|
|
1998
|
-
await this.runPattern(s,
|
|
2001
|
+
await this.runPattern(s, m, h);
|
|
1999
2002
|
}
|
|
2000
2003
|
}
|
|
2001
2004
|
cancel() {
|
|
@@ -2018,43 +2021,43 @@ var $i = 0, Q, Ri = (Q = class {
|
|
|
2018
2021
|
this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), (e = this.patternResolve) == null || e.call(this), this.patternResolve = null;
|
|
2019
2022
|
}
|
|
2020
2023
|
runPattern(e, t, i) {
|
|
2021
|
-
return new Promise((
|
|
2022
|
-
var r,
|
|
2023
|
-
this.patternResolve =
|
|
2024
|
+
return new Promise((o) => {
|
|
2025
|
+
var r, n;
|
|
2026
|
+
this.patternResolve = o;
|
|
2024
2027
|
let l = [], s = 0;
|
|
2025
|
-
for (let
|
|
2026
|
-
let y = Math.max(0, Math.min(1, (r =
|
|
2027
|
-
|
|
2028
|
+
for (let g of e) {
|
|
2029
|
+
let y = Math.max(0, Math.min(1, (r = g.intensity) != null ? r : t)), k = (n = g.delay) != null ? n : 0;
|
|
2030
|
+
k > 0 && (s += k, l.push({ end: s, isOn: !1, intensity: 0 })), s += g.duration, l.push({ end: s, isOn: !0, intensity: y });
|
|
2028
2031
|
}
|
|
2029
|
-
let
|
|
2030
|
-
var y,
|
|
2031
|
-
|
|
2032
|
-
let b =
|
|
2033
|
-
if (b >=
|
|
2034
|
-
this.rafId = null, this.patternResolve = null,
|
|
2032
|
+
let m = s, h = 0, u = -1, p = (g) => {
|
|
2033
|
+
var y, k;
|
|
2034
|
+
h === 0 && (h = g);
|
|
2035
|
+
let b = g - h;
|
|
2036
|
+
if (b >= m) {
|
|
2037
|
+
this.rafId = null, this.patternResolve = null, o();
|
|
2035
2038
|
return;
|
|
2036
2039
|
}
|
|
2037
|
-
let
|
|
2038
|
-
for (let
|
|
2039
|
-
|
|
2040
|
+
let x = l[0];
|
|
2041
|
+
for (let E of l) if (b < E.end) {
|
|
2042
|
+
x = E;
|
|
2040
2043
|
break;
|
|
2041
2044
|
}
|
|
2042
|
-
if (
|
|
2043
|
-
let
|
|
2044
|
-
|
|
2045
|
+
if (x.isOn) {
|
|
2046
|
+
let E = Si + (1 - x.intensity) * Mi;
|
|
2047
|
+
u === -1 ? (u = g, i || ((y = this.hapticLabel) == null || y.click(), this.debug && this.audioCtx && this.playClick(x.intensity), i = !0)) : g - u >= E && ((k = this.hapticLabel) == null || k.click(), this.debug && this.audioCtx && this.playClick(x.intensity), u = g);
|
|
2045
2048
|
}
|
|
2046
|
-
this.rafId = requestAnimationFrame(
|
|
2049
|
+
this.rafId = requestAnimationFrame(p);
|
|
2047
2050
|
};
|
|
2048
|
-
this.rafId = requestAnimationFrame(
|
|
2051
|
+
this.rafId = requestAnimationFrame(p);
|
|
2049
2052
|
});
|
|
2050
2053
|
}
|
|
2051
2054
|
playClick(e) {
|
|
2052
2055
|
if (!this.audioCtx || !this.audioFilter || !this.audioGain || !this.audioBuffer) return;
|
|
2053
2056
|
let t = this.audioBuffer.getChannelData(0);
|
|
2054
|
-
for (let
|
|
2057
|
+
for (let n = 0; n < t.length; n++) t[n] = (Math.random() * 2 - 1) * Math.exp(-n / 25);
|
|
2055
2058
|
this.audioGain.gain.value = 0.5 * e;
|
|
2056
|
-
let i = 2e3 + e * 2e3,
|
|
2057
|
-
this.audioFilter.frequency.value = i *
|
|
2059
|
+
let i = 2e3 + e * 2e3, o = 1 + (Math.random() - 0.5) * 0.3;
|
|
2060
|
+
this.audioFilter.frequency.value = i * o;
|
|
2058
2061
|
let r = this.audioCtx.createBufferSource();
|
|
2059
2062
|
r.buffer = this.audioBuffer, r.connect(this.audioFilter), r.onended = () => r.disconnect(), r.start();
|
|
2060
2063
|
}
|
|
@@ -2065,7 +2068,7 @@ var $i = 0, Q, Ri = (Q = class {
|
|
|
2065
2068
|
let t = 4e-3;
|
|
2066
2069
|
this.audioBuffer = this.audioCtx.createBuffer(1, this.audioCtx.sampleRate * t, this.audioCtx.sampleRate);
|
|
2067
2070
|
let i = this.audioBuffer.getChannelData(0);
|
|
2068
|
-
for (let
|
|
2071
|
+
for (let o = 0; o < i.length; o++) i[o] = (Math.random() * 2 - 1) * Math.exp(-o / 25);
|
|
2069
2072
|
}
|
|
2070
2073
|
((e = this.audioCtx) == null ? void 0 : e.state) === "suspended" && await this.audioCtx.resume();
|
|
2071
2074
|
}
|
|
@@ -2077,9 +2080,9 @@ var $i = 0, Q, Ri = (Q = class {
|
|
|
2077
2080
|
i.type = "checkbox", i.setAttribute("switch", ""), i.id = e, i.style.all = "initial", i.style.appearance = "auto", this.showSwitch || (t.style.display = "none", i.style.display = "none"), t.appendChild(i), document.body.appendChild(t), this.domInitialized = !0;
|
|
2078
2081
|
}
|
|
2079
2082
|
}, R(Q, "isSupported", typeof navigator < "u" && typeof navigator.vibrate == "function"), Q);
|
|
2080
|
-
const
|
|
2083
|
+
const ne = new Ri(), xt = class ve {
|
|
2081
2084
|
constructor(t) {
|
|
2082
|
-
var i,
|
|
2085
|
+
var i, o, r;
|
|
2083
2086
|
if (this.iframe = null, this.container = null, this.trigger = null, this.isOpen = !1, this.isExpanded = !1, this.messageHandler = null, this.unreadCount = 0, this.titleModified = !1, this.visibilityHandler = null, this.eventRuleCleanup = null, this.triggerClickHandler = null, this.guideBridgeTeardown = null, !t.widgetSlug || typeof t.widgetSlug != "string" || t.widgetSlug.trim() === "")
|
|
2084
2087
|
throw new Error("widgetSlug is required in widget config");
|
|
2085
2088
|
this.config = {
|
|
@@ -2094,13 +2097,13 @@ const oe = new Ri(), xt = class ve {
|
|
|
2094
2097
|
userExternalUserId: t.userExternalUserId || "",
|
|
2095
2098
|
userSignature: t.userSignature || "",
|
|
2096
2099
|
userData: (i = t.userData) != null ? i : {},
|
|
2097
|
-
hideOnLaunch: (
|
|
2100
|
+
hideOnLaunch: (o = t.hideOnLaunch) != null ? o : !1,
|
|
2098
2101
|
enableScreenshot: (r = t.enableScreenshot) != null ? r : !1,
|
|
2099
2102
|
onOpen: t.onOpen || (() => {
|
|
2100
2103
|
}),
|
|
2101
2104
|
onClose: t.onClose || (() => {
|
|
2102
2105
|
}),
|
|
2103
|
-
onError: t.onError || ((
|
|
2106
|
+
onError: t.onError || ((n) => console.error("SupportWireWidget error:", n))
|
|
2104
2107
|
}, this.iframeId = Ft(), this.widgetUrl = this.buildWidgetUrl(), ve.instances.set(this.iframeId, this), this.init();
|
|
2105
2108
|
}
|
|
2106
2109
|
updateDocumentTitle(t) {
|
|
@@ -2121,8 +2124,8 @@ const oe = new Ri(), xt = class ve {
|
|
|
2121
2124
|
try {
|
|
2122
2125
|
const t = this.getUnreadCountKey(), i = localStorage.getItem(t);
|
|
2123
2126
|
if (i) {
|
|
2124
|
-
const
|
|
2125
|
-
return isNaN(
|
|
2127
|
+
const o = parseInt(i, 10);
|
|
2128
|
+
return isNaN(o) ? 0 : o;
|
|
2126
2129
|
}
|
|
2127
2130
|
} catch (t) {
|
|
2128
2131
|
console.error("Failed to load unread count from localStorage:", t);
|
|
@@ -2196,16 +2199,16 @@ const oe = new Ri(), xt = class ve {
|
|
|
2196
2199
|
},
|
|
2197
2200
|
onError: this.config.onError,
|
|
2198
2201
|
onUnreadCount: (t) => {
|
|
2199
|
-
t > this.unreadCount &&
|
|
2202
|
+
t > this.unreadCount && ne.trigger("selection"), this.unreadCount = t, this.saveUnreadCountToStorage(t), this.trigger && be(this.trigger, t), this.updateDocumentTitle(t);
|
|
2200
2203
|
},
|
|
2201
|
-
onImagePreview: (t, i,
|
|
2202
|
-
|
|
2204
|
+
onImagePreview: (t, i, o) => {
|
|
2205
|
+
oi(t, i, o, (r) => {
|
|
2203
2206
|
tt(
|
|
2204
2207
|
r,
|
|
2205
|
-
(
|
|
2208
|
+
(n) => {
|
|
2206
2209
|
this.sendMessageToIframe({
|
|
2207
2210
|
type: "PAGE_SCREENSHOT_RESULT",
|
|
2208
|
-
payload: { dataUrl:
|
|
2211
|
+
payload: { dataUrl: n }
|
|
2209
2212
|
});
|
|
2210
2213
|
},
|
|
2211
2214
|
() => {
|
|
@@ -2216,8 +2219,8 @@ const oe = new Ri(), xt = class ve {
|
|
|
2216
2219
|
onToggleFullscreen: () => {
|
|
2217
2220
|
this.toggleExpand();
|
|
2218
2221
|
},
|
|
2219
|
-
onMessagePreview: (t, i,
|
|
2220
|
-
this.isOpen || gi(t, i,
|
|
2222
|
+
onMessagePreview: (t, i, o) => {
|
|
2223
|
+
this.isOpen || gi(t, i, o, this.config.triggerPosition, this.config.theme, () => this.open());
|
|
2221
2224
|
},
|
|
2222
2225
|
onScreenshotRequest: (t) => {
|
|
2223
2226
|
this.capturePageScreenshot(t);
|
|
@@ -2235,7 +2238,11 @@ const oe = new Ri(), xt = class ve {
|
|
|
2235
2238
|
}));
|
|
2236
2239
|
}
|
|
2237
2240
|
}
|
|
2238
|
-
), window.addEventListener("message", this.messageHandler), this.iframe && (this.guideBridgeTeardown = Xt(this.iframe, this.iframeId
|
|
2241
|
+
), window.addEventListener("message", this.messageHandler), this.iframe && (this.guideBridgeTeardown = Xt(this.iframe, this.iframeId, {
|
|
2242
|
+
closeWidget: () => {
|
|
2243
|
+
this.isOpen && this.close();
|
|
2244
|
+
}
|
|
2245
|
+
}).teardown);
|
|
2239
2246
|
}
|
|
2240
2247
|
setupTrigger() {
|
|
2241
2248
|
if (this.triggerClickHandler = () => this.toggle(), this.config.selector) {
|
|
@@ -2254,10 +2261,10 @@ const oe = new Ri(), xt = class ve {
|
|
|
2254
2261
|
this.isOpen ? this.close() : this.open();
|
|
2255
2262
|
}
|
|
2256
2263
|
open() {
|
|
2257
|
-
!this.container || !this.iframe || (ke(!0), this.showTrigger(), this.isOpen = !0,
|
|
2264
|
+
!this.container || !this.iframe || (ke(!0), this.showTrigger(), this.isOpen = !0, ne.trigger("medium"), _e(this.config.widgetSlug, !0), this.container.style.display = "block", ut(this.container), this.unreadCount = 0, this.saveUnreadCountToStorage(0), this.updateDocumentTitle(0), this.trigger && (be(this.trigger, 0), Le(this.trigger, !0, this.config.theme), window.innerWidth <= 480 && (this.trigger.style.display = "none")), this.sendMessageToIframe({ type: "OPEN" }));
|
|
2258
2265
|
}
|
|
2259
2266
|
close() {
|
|
2260
|
-
this.container && (this.isOpen = !1,
|
|
2267
|
+
this.container && (this.isOpen = !1, ne.trigger("light"), _e(this.config.widgetSlug, !1), this.trigger && (Le(this.trigger, !1, this.config.theme), window.innerWidth <= 480 && (this.trigger.style.display = "")), ht(this.container), this.sendMessageToIframe({ type: "CLOSE" }));
|
|
2261
2268
|
}
|
|
2262
2269
|
showTrigger() {
|
|
2263
2270
|
this.trigger && (this.trigger.style.display = "");
|
|
@@ -2284,15 +2291,15 @@ const oe = new Ri(), xt = class ve {
|
|
|
2284
2291
|
color: "var(--muted-foreground, #999)",
|
|
2285
2292
|
borderRadius: "4px"
|
|
2286
2293
|
}), i.addEventListener("mouseenter", () => {
|
|
2287
|
-
const
|
|
2288
|
-
|
|
2294
|
+
const p = i.querySelector("svg");
|
|
2295
|
+
p && (p.style.opacity = "0.6");
|
|
2289
2296
|
}), i.addEventListener("mouseleave", () => {
|
|
2290
|
-
const
|
|
2291
|
-
|
|
2297
|
+
const p = i.querySelector("svg");
|
|
2298
|
+
p && (p.style.opacity = "0.3");
|
|
2292
2299
|
});
|
|
2293
|
-
const
|
|
2294
|
-
i.addEventListener("dblclick", (
|
|
2295
|
-
|
|
2300
|
+
const o = 320, r = 700, n = 400;
|
|
2301
|
+
i.addEventListener("dblclick", (p) => {
|
|
2302
|
+
p.stopPropagation(), ne.trigger("light"), window.matchMedia("(prefers-reduced-motion: reduce)").matches || (t.style.willChange = "width, height", t.style.transition = "width 250ms cubic-bezier(0.22, 1, 0.36, 1), height 250ms cubic-bezier(0.22, 1, 0.36, 1), max-height 250ms cubic-bezier(0.22, 1, 0.36, 1)", setTimeout(() => {
|
|
2296
2303
|
t.style.willChange = "", t.style.transition = "width 200ms ease-out, height 200ms ease-out";
|
|
2297
2304
|
}, 270)), t.style.width = "min(400px, max(0px, -20px + 100vw))", t.style.height = "min(704px, 100% - 104px)", t.style.maxHeight = "704px";
|
|
2298
2305
|
try {
|
|
@@ -2300,42 +2307,42 @@ const oe = new Ri(), xt = class ve {
|
|
|
2300
2307
|
} catch {
|
|
2301
2308
|
}
|
|
2302
2309
|
});
|
|
2303
|
-
let l = !1, s = 0,
|
|
2304
|
-
i.addEventListener("pointerdown", (
|
|
2305
|
-
|
|
2306
|
-
const
|
|
2307
|
-
|
|
2308
|
-
}), i.addEventListener("pointermove", (
|
|
2310
|
+
let l = !1, s = 0, m = 0, h = 0, u = 0;
|
|
2311
|
+
i.addEventListener("pointerdown", (p) => {
|
|
2312
|
+
p.stopPropagation(), p.preventDefault(), l = !0, s = p.clientX, m = p.clientY;
|
|
2313
|
+
const g = t.getBoundingClientRect();
|
|
2314
|
+
h = g.width, u = g.height, i.setPointerCapture(p.pointerId), t.style.transition = "none";
|
|
2315
|
+
}), i.addEventListener("pointermove", (p) => {
|
|
2309
2316
|
if (!l) return;
|
|
2310
|
-
const
|
|
2317
|
+
const g = s - p.clientX, y = m - p.clientY, k = parseInt(t.style.right) || 20, b = parseInt(t.style.bottom) || 84, x = Math.min(r, window.innerWidth - k - 20), E = window.innerHeight - b - 20, C = Math.max(o, Math.min(x, h + g)), N = Math.max(n, Math.min(E, u + y));
|
|
2311
2318
|
t.style.width = `${C}px`, t.style.height = `${N}px`, t.style.maxHeight = `${N}px`;
|
|
2312
|
-
}), i.addEventListener("pointerup", (
|
|
2319
|
+
}), i.addEventListener("pointerup", (p) => {
|
|
2313
2320
|
if (!l) return;
|
|
2314
|
-
l = !1, i.releasePointerCapture(
|
|
2315
|
-
const
|
|
2321
|
+
l = !1, i.releasePointerCapture(p.pointerId), t.style.transition = "";
|
|
2322
|
+
const g = t.getBoundingClientRect();
|
|
2316
2323
|
Ci(this.config.widgetSlug, {
|
|
2317
|
-
width: Math.round(
|
|
2318
|
-
height: Math.round(
|
|
2324
|
+
width: Math.round(g.width),
|
|
2325
|
+
height: Math.round(g.height)
|
|
2319
2326
|
});
|
|
2320
2327
|
}), t.appendChild(i);
|
|
2321
2328
|
}
|
|
2322
2329
|
toggleExpand() {
|
|
2323
|
-
this.container && (
|
|
2330
|
+
this.container && (ne.trigger("medium"), window.matchMedia("(prefers-reduced-motion: reduce)").matches || (this.container.style.willChange = "width, height", this.container.style.transition = "width 300ms cubic-bezier(0.22, 1, 0.36, 1), height 300ms cubic-bezier(0.22, 1, 0.36, 1), max-height 300ms cubic-bezier(0.22, 1, 0.36, 1), bottom 300ms cubic-bezier(0.22, 1, 0.36, 1)", setTimeout(() => {
|
|
2324
2331
|
this.container && (this.container.style.willChange = "", this.container.style.transition = "width 200ms ease-out, height 200ms ease-out");
|
|
2325
2332
|
}, 320)), this.isExpanded ? (this.container.style.width = "min(400px, max(0px, -20px + 100vw))", this.container.style.height = "min(704px, 100% - 104px)", this.container.style.maxHeight = "704px", this.container.style.bottom = "84px", this.isExpanded = !1) : (this.container.style.width = "min(688px, max(0px, -20px + 100vw))", this.container.style.height = "calc(100% - 40px)", this.container.style.maxHeight = "calc(100% - 40px)", this.container.style.bottom = "20px", this.isExpanded = !0));
|
|
2326
2333
|
}
|
|
2327
2334
|
async capturePageScreenshot(t) {
|
|
2328
|
-
var i,
|
|
2335
|
+
var i, o;
|
|
2329
2336
|
try {
|
|
2330
|
-
const r = (i = this.container) == null ? void 0 : i.style.display,
|
|
2337
|
+
const r = (i = this.container) == null ? void 0 : i.style.display, n = (o = this.trigger) == null ? void 0 : o.style.display;
|
|
2331
2338
|
this.container && (this.container.style.display = "none"), this.trigger && (this.trigger.style.display = "none");
|
|
2332
2339
|
const { snapdom: l } = await import("./snapdom-6yvsn_Iv-6uiY9rZc.js"), s = (await l.toCanvas(document.documentElement, { scale: 1 })).toDataURL("image/png");
|
|
2333
|
-
this.container && (this.container.style.display = r ?? ""), this.trigger && (this.trigger.style.display =
|
|
2340
|
+
this.container && (this.container.style.display = r ?? ""), this.trigger && (this.trigger.style.display = n ?? ""), tt(
|
|
2334
2341
|
s,
|
|
2335
|
-
(
|
|
2342
|
+
(m) => {
|
|
2336
2343
|
this.sendMessageToIframe({
|
|
2337
2344
|
type: "PAGE_SCREENSHOT_RESULT",
|
|
2338
|
-
payload: { dataUrl:
|
|
2345
|
+
payload: { dataUrl: m }
|
|
2339
2346
|
});
|
|
2340
2347
|
},
|
|
2341
2348
|
() => {
|
|
@@ -2347,18 +2354,18 @@ const oe = new Ri(), xt = class ve {
|
|
|
2347
2354
|
);
|
|
2348
2355
|
} catch (r) {
|
|
2349
2356
|
this.container && (this.container.style.display = ""), this.trigger && (this.trigger.style.display = "");
|
|
2350
|
-
const
|
|
2357
|
+
const n = r instanceof Error ? r.message : "Screenshot capture failed";
|
|
2351
2358
|
this.sendMessageToIframe({
|
|
2352
2359
|
type: "PAGE_SCREENSHOT_ERROR",
|
|
2353
|
-
payload: { error:
|
|
2360
|
+
payload: { error: n }
|
|
2354
2361
|
});
|
|
2355
2362
|
}
|
|
2356
2363
|
}
|
|
2357
2364
|
updateConfig(t) {
|
|
2358
2365
|
const i = A({}, this.config);
|
|
2359
2366
|
t.appUrl !== void 0 && (this.config.appUrl = t.appUrl), t.theme !== void 0 && (this.config.theme = t.theme), t.triggerPosition !== void 0 && (this.config.triggerPosition = t.triggerPosition), t.widgetType !== void 0 && (this.config.widgetType = t.widgetType), t.userToken !== void 0 && (this.config.userToken = t.userToken), t.userEmail !== void 0 && (this.config.userEmail = t.userEmail), t.userSignature !== void 0 && (this.config.userSignature = t.userSignature), t.userData !== void 0 && (this.config.userData = t.userData), t.onOpen !== void 0 && (this.config.onOpen = t.onOpen), t.onClose !== void 0 && (this.config.onClose = t.onClose), t.onError !== void 0 && (this.config.onError = t.onError), t.hideOnLaunch !== void 0 && (this.config.hideOnLaunch = t.hideOnLaunch, this.trigger && (this.trigger.style.display = t.hideOnLaunch ? "none" : "")), t.enableScreenshot !== void 0 && (this.config.enableScreenshot = t.enableScreenshot);
|
|
2360
|
-
const
|
|
2361
|
-
(
|
|
2367
|
+
const o = t.appUrl !== void 0 && t.appUrl !== i.appUrl, r = t.theme !== void 0 && t.theme !== i.theme;
|
|
2368
|
+
(o || r) && (r && this.sendMessageToIframe({
|
|
2362
2369
|
type: "THEME",
|
|
2363
2370
|
theme: t.theme
|
|
2364
2371
|
}), this.iframe && (this.widgetUrl = this.buildWidgetUrl(), this.iframe.src = `${this.widgetUrl}?iframeId=${this.iframeId}&theme=${this.config.theme}`)), t.widgetType !== void 0 && t.widgetType !== i.widgetType && this.container && Xe(this.container, this.config), t.triggerPosition !== void 0 && this.trigger && !this.config.selector && (qt(this.trigger, this.config.triggerPosition), this.config.widgetType === "popup" && this.container && Dt(this.container, this.config.triggerPosition, this.config.widgetType)), this.sendMessageToIframe({
|
|
@@ -2385,7 +2392,7 @@ const oe = new Ri(), xt = class ve {
|
|
|
2385
2392
|
*/
|
|
2386
2393
|
static getInstances(t) {
|
|
2387
2394
|
const i = Array.from(ve.instances.values());
|
|
2388
|
-
return t !== void 0 ? i.filter((
|
|
2395
|
+
return t !== void 0 ? i.filter((o) => o.config.widgetSlug === t) : i;
|
|
2389
2396
|
}
|
|
2390
2397
|
};
|
|
2391
2398
|
xt.instances = /* @__PURE__ */ new Map();
|
|
@@ -2426,8 +2433,8 @@ const Ni = [
|
|
|
2426
2433
|
];
|
|
2427
2434
|
function vt(e) {
|
|
2428
2435
|
const t = {};
|
|
2429
|
-
for (const [i,
|
|
2430
|
-
Ni.includes(i) || (t[i] =
|
|
2436
|
+
for (const [i, o] of Object.entries(e))
|
|
2437
|
+
Ni.includes(i) || (t[i] = o);
|
|
2431
2438
|
return e.name !== void 0 && (t.name = e.name), e.phone !== void 0 && (t.phone = e.phone), e.created_at !== void 0 && (t.created_at = e.created_at), e.company !== void 0 && (t.company = e.company), e.companies !== void 0 && (t.companies = e.companies), e.unsubscribed_from_emails !== void 0 && (t.unsubscribed_from_emails = e.unsubscribed_from_emails), {
|
|
2432
2439
|
widgetSlug: String(e.app_id),
|
|
2433
2440
|
userEmail: typeof e.email == "string" ? e.email : void 0,
|
|
@@ -2465,14 +2472,14 @@ function Fi() {
|
|
|
2465
2472
|
if (!e || !e.q) return;
|
|
2466
2473
|
const t = e.q.slice();
|
|
2467
2474
|
e.q.length = 0;
|
|
2468
|
-
const i = (...
|
|
2469
|
-
const [r, ...
|
|
2470
|
-
lt(r, ...
|
|
2475
|
+
const i = (...o) => {
|
|
2476
|
+
const [r, ...n] = o;
|
|
2477
|
+
lt(r, ...n);
|
|
2471
2478
|
};
|
|
2472
2479
|
i.q = [], window.SupportWireMessenger = i;
|
|
2473
|
-
for (const
|
|
2474
|
-
const [r, ...
|
|
2475
|
-
lt(r, ...
|
|
2480
|
+
for (const o of t) {
|
|
2481
|
+
const [r, ...n] = o;
|
|
2482
|
+
lt(r, ...n);
|
|
2476
2483
|
}
|
|
2477
2484
|
}
|
|
2478
2485
|
function lt(e, ...t) {
|
|
@@ -2513,7 +2520,7 @@ function ze(e) {
|
|
|
2513
2520
|
L && (L.destroy(), L = null);
|
|
2514
2521
|
const t = vt(e);
|
|
2515
2522
|
J = e;
|
|
2516
|
-
const i = t.widgetSlug,
|
|
2523
|
+
const i = t.widgetSlug, o = pe;
|
|
2517
2524
|
if (L = new _i({
|
|
2518
2525
|
widgetSlug: i,
|
|
2519
2526
|
userEmail: t.userEmail,
|
|
@@ -2530,7 +2537,7 @@ function ze(e) {
|
|
|
2530
2537
|
onClose: () => {
|
|
2531
2538
|
for (const r of Fe) r();
|
|
2532
2539
|
}
|
|
2533
|
-
}), t.userEmail && t.userEmail !==
|
|
2540
|
+
}), t.userEmail && t.userEmail !== o) {
|
|
2534
2541
|
pe = t.userEmail;
|
|
2535
2542
|
for (const r of Ee) r();
|
|
2536
2543
|
}
|
|
@@ -2543,15 +2550,15 @@ function kt(e) {
|
|
|
2543
2550
|
}
|
|
2544
2551
|
const t = { ...J ?? {}, ...e }, i = pe;
|
|
2545
2552
|
J = t;
|
|
2546
|
-
const
|
|
2553
|
+
const o = vt(t);
|
|
2547
2554
|
if (L.updateConfig({
|
|
2548
|
-
userEmail:
|
|
2549
|
-
userExternalUserId:
|
|
2550
|
-
userSignature:
|
|
2551
|
-
userData:
|
|
2552
|
-
theme:
|
|
2553
|
-
}),
|
|
2554
|
-
pe =
|
|
2555
|
+
userEmail: o.userEmail || void 0,
|
|
2556
|
+
userExternalUserId: o.userExternalUserId || void 0,
|
|
2557
|
+
userSignature: o.userSignature || void 0,
|
|
2558
|
+
userData: o.userData,
|
|
2559
|
+
theme: o.theme
|
|
2560
|
+
}), o.userEmail && o.userEmail !== i) {
|
|
2561
|
+
pe = o.userEmail;
|
|
2555
2562
|
for (const r of Ee) r();
|
|
2556
2563
|
}
|
|
2557
2564
|
}
|
|
@@ -2613,13 +2620,13 @@ function B(e) {
|
|
|
2613
2620
|
};
|
|
2614
2621
|
}
|
|
2615
2622
|
const Vi = B("startTour"), Ji = B("showArticle"), Xi = B("showNews"), Qi = B("startSurvey"), Zi = B("startChecklist"), er = B("showTicket"), tr = B("showConversation"), ir = B("showSpace"), rr = B("showMessages");
|
|
2616
|
-
function
|
|
2623
|
+
function or(e) {
|
|
2617
2624
|
ze(e);
|
|
2618
2625
|
}
|
|
2619
2626
|
export {
|
|
2620
|
-
|
|
2627
|
+
or as SupportWire,
|
|
2621
2628
|
ze as boot,
|
|
2622
|
-
|
|
2629
|
+
or as default,
|
|
2623
2630
|
Yi as getVisitorId,
|
|
2624
2631
|
Hi as hide,
|
|
2625
2632
|
qi as hideNotifications,
|