@supportwire/messenger-js-sdk 1.0.26
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/README.md +80 -0
- package/dist/index-bfV4xNqW-CRQbrL80.js +1092 -0
- package/dist/index-bfV4xNqW-CRQbrL80.js.map +1 -0
- package/dist/index-bfV4xNqW-ChZOGalc.cjs +162 -0
- package/dist/index-bfV4xNqW-ChZOGalc.cjs.map +1 -0
- package/dist/index.cjs +921 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +149 -0
- package/dist/index.js +2646 -0
- package/dist/index.js.map +1 -0
- package/dist/snapdom-6yvsn_Iv-6uiY9rZc.js +3373 -0
- package/dist/snapdom-6yvsn_Iv-6uiY9rZc.js.map +1 -0
- package/dist/snapdom-6yvsn_Iv-OVmChxqF.cjs +9 -0
- package/dist/snapdom-6yvsn_Iv-OVmChxqF.cjs.map +1 -0
- package/package.json +37 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2646 @@
|
|
|
1
|
+
var $t = Object.defineProperty, Rt = Object.defineProperties, _t = Object.getOwnPropertyDescriptors, Je = Object.getOwnPropertySymbols, Nt = Object.prototype.hasOwnProperty, Pt = Object.prototype.propertyIsEnumerable, Ne = (e, t, i) => t in e ? $t(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i, A = (e, t) => {
|
|
2
|
+
for (var i in t || (t = {}))
|
|
3
|
+
Nt.call(t, i) && Ne(e, i, t[i]);
|
|
4
|
+
if (Je)
|
|
5
|
+
for (var i of Je(t))
|
|
6
|
+
Pt.call(t, i) && Ne(e, i, t[i]);
|
|
7
|
+
return e;
|
|
8
|
+
}, Se = (e, t) => Rt(e, _t(t)), R = (e, t, i) => Ne(e, typeof t != "symbol" ? t + "" : t, i);
|
|
9
|
+
const Ot = (e) => e && typeof e == "string" && e.trim() !== "" ? e.trim().replace(/\/$/, "") : "https://widget.supportwire.app", Ft = () => {
|
|
10
|
+
const e = Date.now(), t = Math.random().toString(36).substring(2, 9);
|
|
11
|
+
return `supportwire-iframe-${e}-${t}`;
|
|
12
|
+
}, Ut = () => {
|
|
13
|
+
if (document.getElementById("supportwire-animation-styles"))
|
|
14
|
+
return;
|
|
15
|
+
const e = document.createElement("style");
|
|
16
|
+
e.id = "supportwire-animation-styles", e.textContent = `
|
|
17
|
+
/* ── Popup: open (fade + rise + subtle scale) ── */
|
|
18
|
+
@keyframes supportwire-slide-up-fade-in {
|
|
19
|
+
from {
|
|
20
|
+
opacity: 0;
|
|
21
|
+
transform: translateY(12px) scale(0.96);
|
|
22
|
+
}
|
|
23
|
+
to {
|
|
24
|
+
opacity: 1;
|
|
25
|
+
transform: translateY(0) scale(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* ── Center modal: open ── */
|
|
30
|
+
@keyframes supportwire-slide-up-fade-in-center {
|
|
31
|
+
from {
|
|
32
|
+
opacity: 0;
|
|
33
|
+
transform: translate(-50%, calc(-50% + 12px)) scale(0.96);
|
|
34
|
+
}
|
|
35
|
+
to {
|
|
36
|
+
opacity: 1;
|
|
37
|
+
transform: translate(-50%, -50%) scale(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* ── Popup: close (faster exit, sink + shrink) ── */
|
|
42
|
+
@keyframes supportwire-slide-down-fade-out {
|
|
43
|
+
from {
|
|
44
|
+
opacity: 1;
|
|
45
|
+
transform: translateY(0) scale(1);
|
|
46
|
+
}
|
|
47
|
+
to {
|
|
48
|
+
opacity: 0;
|
|
49
|
+
transform: translateY(8px) scale(0.98);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* ── Center modal: close ── */
|
|
54
|
+
@keyframes supportwire-slide-down-fade-out-center {
|
|
55
|
+
from {
|
|
56
|
+
opacity: 1;
|
|
57
|
+
transform: translate(-50%, -50%) scale(1);
|
|
58
|
+
}
|
|
59
|
+
to {
|
|
60
|
+
opacity: 0;
|
|
61
|
+
transform: translate(-50%, calc(-50% + 8px)) scale(0.98);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.supportwire-widget-container {
|
|
66
|
+
transition: opacity 250ms cubic-bezier(0.22, 1, 0.36, 1), transform 250ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* ── Popup (overshoot on open for "pop" feel) ── */
|
|
70
|
+
.supportwire-widget-container.supportwire-opening {
|
|
71
|
+
animation: supportwire-slide-up-fade-in 300ms cubic-bezier(0, 1.2, 1, 1) forwards;
|
|
72
|
+
}
|
|
73
|
+
.supportwire-widget-container.supportwire-closing {
|
|
74
|
+
animation: supportwire-slide-down-fade-out 180ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* ── Drawer ── */
|
|
78
|
+
.supportwire-widget-container.supportwire-drawer.supportwire-opening {
|
|
79
|
+
animation: supportwire-slide-up-fade-in 350ms cubic-bezier(0, 1.2, 1, 1) forwards;
|
|
80
|
+
}
|
|
81
|
+
.supportwire-widget-container.supportwire-drawer.supportwire-closing {
|
|
82
|
+
animation: supportwire-slide-down-fade-out 220ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* ── Center modal ── */
|
|
86
|
+
.supportwire-widget-container.supportwire-center\\ modal.supportwire-opening {
|
|
87
|
+
animation: supportwire-slide-up-fade-in-center 300ms cubic-bezier(0, 1.2, 1, 1) forwards;
|
|
88
|
+
}
|
|
89
|
+
.supportwire-widget-container.supportwire-center\\ modal.supportwire-closing {
|
|
90
|
+
animation: supportwire-slide-down-fade-out-center 180ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* ── Reduced motion: fade only, no movement ── */
|
|
94
|
+
@keyframes supportwire-fade-in {
|
|
95
|
+
from { opacity: 0; }
|
|
96
|
+
to { opacity: 1; }
|
|
97
|
+
}
|
|
98
|
+
@keyframes supportwire-fade-out {
|
|
99
|
+
from { opacity: 1; }
|
|
100
|
+
to { opacity: 0; }
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* ── Mobile fullscreen: take over viewport on narrow screens ── */
|
|
104
|
+
@media (max-width: 480px) {
|
|
105
|
+
.supportwire-widget-container.supportwire-popup,
|
|
106
|
+
.supportwire-widget-container.supportwire-drawer,
|
|
107
|
+
.supportwire-widget-container.supportwire-center\\ modal {
|
|
108
|
+
width: 100vw !important;
|
|
109
|
+
height: 100vh !important;
|
|
110
|
+
height: 100dvh !important;
|
|
111
|
+
max-height: none !important;
|
|
112
|
+
min-height: none !important;
|
|
113
|
+
top: 0 !important;
|
|
114
|
+
left: 0 !important;
|
|
115
|
+
right: 0 !important;
|
|
116
|
+
bottom: 0 !important;
|
|
117
|
+
border-radius: 0 !important;
|
|
118
|
+
transform: none !important;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@media (prefers-reduced-motion: reduce) {
|
|
123
|
+
.supportwire-widget-container {
|
|
124
|
+
transition: opacity 150ms ease-out !important;
|
|
125
|
+
}
|
|
126
|
+
.supportwire-widget-container.supportwire-opening,
|
|
127
|
+
.supportwire-widget-container.supportwire-drawer.supportwire-opening,
|
|
128
|
+
.supportwire-widget-container.supportwire-center\\ modal.supportwire-opening {
|
|
129
|
+
animation: supportwire-fade-in 150ms ease-out forwards !important;
|
|
130
|
+
}
|
|
131
|
+
.supportwire-widget-container.supportwire-closing,
|
|
132
|
+
.supportwire-widget-container.supportwire-drawer.supportwire-closing,
|
|
133
|
+
.supportwire-widget-container.supportwire-center\\ modal.supportwire-closing {
|
|
134
|
+
animation: supportwire-fade-out 150ms ease-out forwards !important;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
`, document.head.appendChild(e);
|
|
138
|
+
}, ut = (e) => {
|
|
139
|
+
requestAnimationFrame(() => {
|
|
140
|
+
e.classList.remove("supportwire-closing"), e.classList.add("supportwire-opening");
|
|
141
|
+
});
|
|
142
|
+
}, ht = (e, t) => {
|
|
143
|
+
e.classList.remove("supportwire-opening"), e.classList.add("supportwire-closing"), setTimeout(() => {
|
|
144
|
+
e.style.display = "none", e.classList.remove("supportwire-closing");
|
|
145
|
+
}, 230);
|
|
146
|
+
}, zt = (e, t) => {
|
|
147
|
+
if (!t)
|
|
148
|
+
return {
|
|
149
|
+
bottom: "20px",
|
|
150
|
+
right: "20px"
|
|
151
|
+
};
|
|
152
|
+
switch (e) {
|
|
153
|
+
case "bottom-right":
|
|
154
|
+
return {
|
|
155
|
+
bottom: "84px",
|
|
156
|
+
right: "20px"
|
|
157
|
+
};
|
|
158
|
+
case "bottom-left":
|
|
159
|
+
return {
|
|
160
|
+
bottom: "84px",
|
|
161
|
+
left: "20px"
|
|
162
|
+
};
|
|
163
|
+
case "top-right":
|
|
164
|
+
return {
|
|
165
|
+
top: "84px",
|
|
166
|
+
right: "20px"
|
|
167
|
+
};
|
|
168
|
+
case "top-left":
|
|
169
|
+
return {
|
|
170
|
+
top: "84px",
|
|
171
|
+
left: "20px"
|
|
172
|
+
};
|
|
173
|
+
default:
|
|
174
|
+
return {
|
|
175
|
+
bottom: "84px",
|
|
176
|
+
right: "20px"
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}, Ht = () => {
|
|
180
|
+
const e = "supportwire-widget-tail-styles";
|
|
181
|
+
if (document.getElementById(e)) return;
|
|
182
|
+
const t = document.createElement("style");
|
|
183
|
+
t.id = e, t.textContent = `
|
|
184
|
+
.supportwire-widget-tail {
|
|
185
|
+
position: absolute;
|
|
186
|
+
width: 12px;
|
|
187
|
+
height: 12px;
|
|
188
|
+
background: inherit;
|
|
189
|
+
border-radius: 2px;
|
|
190
|
+
transform: rotate(45deg);
|
|
191
|
+
z-index: -1;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.supportwire-widget-tail.bottom-right {
|
|
195
|
+
bottom: -6px;
|
|
196
|
+
right: 24px;
|
|
197
|
+
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.08);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.supportwire-widget-tail.bottom-left {
|
|
201
|
+
bottom: -6px;
|
|
202
|
+
left: 24px;
|
|
203
|
+
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.08);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.supportwire-widget-tail.top-right {
|
|
207
|
+
top: -6px;
|
|
208
|
+
right: 24px;
|
|
209
|
+
box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.08);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.supportwire-widget-tail.top-left {
|
|
213
|
+
top: -6px;
|
|
214
|
+
left: 24px;
|
|
215
|
+
box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.08);
|
|
216
|
+
}
|
|
217
|
+
`, document.head.appendChild(t);
|
|
218
|
+
}, At = (e, t, i) => {
|
|
219
|
+
Ht();
|
|
220
|
+
const n = e.querySelector(".supportwire-widget-tail");
|
|
221
|
+
n && n.remove();
|
|
222
|
+
const r = document.createElement("div");
|
|
223
|
+
r.className = `supportwire-widget-tail ${t || "bottom-right"}`, r.style.background = i === "dark" ? "#1a1a1a" : "#ffffff", e.appendChild(r);
|
|
224
|
+
}, Xe = (e, t) => {
|
|
225
|
+
var i, n;
|
|
226
|
+
const r = {
|
|
227
|
+
position: "fixed",
|
|
228
|
+
zIndex: "999999",
|
|
229
|
+
display: "none",
|
|
230
|
+
opacity: "0",
|
|
231
|
+
backgroundColor: t.theme === "dark" ? "#28282a" : "#f1f1f3",
|
|
232
|
+
transition: "width 200ms ease-out, height 200ms ease-out"
|
|
233
|
+
}, o = !t.selector;
|
|
234
|
+
switch (t.widgetType) {
|
|
235
|
+
case "popup": {
|
|
236
|
+
const l = (i = t.triggerPosition) != null && i.endsWith("left") ? "left" : "right", s = (n = t.triggerPosition) != null && n.startsWith("top") ? "top" : "bottom", u = A(Se(A({}, r), {
|
|
237
|
+
width: "min(400px, max(0px, -20px + 100vw))",
|
|
238
|
+
height: "min(704px, 100% - 104px)",
|
|
239
|
+
minHeight: "80px",
|
|
240
|
+
maxHeight: "704px",
|
|
241
|
+
borderRadius: "24px",
|
|
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
|
+
overflow: "hidden",
|
|
244
|
+
transformOrigin: `${l} ${s}`
|
|
245
|
+
}), zt(t.triggerPosition, o));
|
|
246
|
+
Object.assign(e.style, u);
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
case "drawer":
|
|
250
|
+
Object.assign(e.style, r, {
|
|
251
|
+
bottom: "0",
|
|
252
|
+
right: "0",
|
|
253
|
+
width: "400px",
|
|
254
|
+
height: "80vh",
|
|
255
|
+
borderTopLeftRadius: "24px",
|
|
256
|
+
boxShadow: t.theme === "dark" ? "rgba(0, 0, 0, 0.5) 0px 5px 40px 0px" : "rgba(9, 14, 21, 0.12) 0px 5px 40px 0px",
|
|
257
|
+
overflow: "hidden"
|
|
258
|
+
});
|
|
259
|
+
break;
|
|
260
|
+
case "center modal":
|
|
261
|
+
Object.assign(e.style, r, {
|
|
262
|
+
top: "50%",
|
|
263
|
+
left: "50%",
|
|
264
|
+
transform: "translate(-50%, -50%)",
|
|
265
|
+
width: "90%",
|
|
266
|
+
maxWidth: "600px",
|
|
267
|
+
height: "80vh",
|
|
268
|
+
borderRadius: "24px",
|
|
269
|
+
boxShadow: t.theme === "dark" ? "rgba(0, 0, 0, 0.5) 0px 5px 40px 0px" : "rgba(9, 14, 21, 0.12) 0px 5px 40px 0px",
|
|
270
|
+
overflow: "hidden"
|
|
271
|
+
});
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
}, Dt = (e, t, i) => {
|
|
275
|
+
if (i === "popup")
|
|
276
|
+
switch (t) {
|
|
277
|
+
case "bottom-right":
|
|
278
|
+
e.style.bottom = "84px", e.style.right = "20px", e.style.top = "auto", e.style.left = "auto";
|
|
279
|
+
break;
|
|
280
|
+
case "bottom-left":
|
|
281
|
+
e.style.bottom = "84px", e.style.left = "20px", e.style.top = "auto", e.style.right = "auto";
|
|
282
|
+
break;
|
|
283
|
+
case "top-right":
|
|
284
|
+
e.style.top = "84px", e.style.right = "20px", e.style.bottom = "auto", e.style.left = "auto";
|
|
285
|
+
break;
|
|
286
|
+
case "top-left":
|
|
287
|
+
e.style.top = "84px", e.style.left = "20px", e.style.bottom = "auto", e.style.right = "auto";
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}, Wt = `
|
|
291
|
+
<svg width="28" height="28" viewBox="0 0 820 820" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
292
|
+
<path d="M306.256 103.089C374.06 121.601 405.862 142.59 421.597 163.509C431.539 176.728 436.259 191.483 438.492 209.449C438.57 210.082 438.643 210.717 438.715 211.352C406.945 214.037 377.275 229.548 354.7 259.981C341.9 277.237 334.444 294.617 333.557 312.794C332.669 330.997 338.511 347.065 346.837 361.327C354.975 375.267 366.267 388.769 377.867 401.971C389.907 415.672 402.475 429.27 415.535 445.247C430.794 463.914 439.389 485.957 441.679 506.319C444.009 527.042 439.644 543.751 432.155 553.715C422.208 566.947 404.553 576.35 383.329 579.578C373.766 558.908 367.432 536.332 364.99 512.317C360.559 468.74 346.585 426.481 324.199 401.287C312.749 388.401 297.053 377.839 277.666 377.481C258.099 377.12 240.782 387.253 226.463 402.846C202.178 429.296 203.512 469.846 215.138 504.134C227.276 539.932 252.808 576.859 289.195 603.059C308.607 617.036 332.485 624.471 356.456 626.188C389.051 678.63 440.001 717.759 499.915 737.633L464.425 790.873C438.535 829.709 381.465 829.709 355.575 790.873L232.25 605.888C227.46 598.704 221.294 592.538 214.11 587.748L29.1257 464.422C-9.70859 438.532-9.70855 381.468 29.1257 355.578L214.11 232.252C221.294 227.462 227.46 221.296 232.25 214.112L306.256 103.089ZM355.575 29.1266C381.465-9.70887 438.535-9.70887 464.425 29.1266L587.75 214.112C592.54 221.296 598.706 227.462 605.891 232.252L790.874 355.578C829.708 381.468 829.708 438.532 790.874 464.422L605.891 587.748C598.706 592.538 592.54 598.704 587.75 605.888L526.423 697.87C478.757 684.856 437.581 657.743 408.598 620.81C431.865 614.079 453.711 601.242 468.756 581.226C485.249 559.283 490.385 529.784 487.171 501.202C483.916 472.257 471.929 441.888 450.986 416.266C437.243 399.454 423.392 384.409 412.264 371.745C400.7 358.583 392.067 347.991 386.376 338.242C380.873 328.815 378.979 321.589 379.298 315.029C379.62 308.442 382.325 299.581 391.473 287.25C405.532 268.298 422.419 259.203 440.574 257.158C440.632 262.282 440.706 267.634 440.836 273.254C441.764 313.257 451.608 353.139 469.184 383.198C486.493 412.8 514.851 437.876 552.829 434.113C574.971 431.918 592.568 421.837 602.933 404.717C612.65 388.669 614.046 369.663 611.774 352.531C607.264 318.532 586.967 281.055 560.251 257.905C537.695 238.36 511.89 223.403 485.121 216.021C484.816 211.889 484.43 207.805 483.933 203.802C481.069 180.754 474.419 157.561 458.191 135.985C435.529 105.855 396.68 82.1759 332.931 63.0831L355.575 29.1266ZM276.816 423.261C279.023 423.301 283.573 424.501 289.975 431.705C303.292 446.695 315.474 477.943 319.44 516.941C321.485 537.048 325.758 556.267 331.954 574.436C326.083 572.154 320.674 569.306 315.946 565.902C287.519 545.433 267.66 516.46 258.497 489.436C248.821 460.902 252.942 441.706 260.189 433.813C269.148 424.057 274.786 423.224 276.816 423.261ZM486.475 264.816C501.078 270.831 515.992 280.136 530.268 292.507C548.705 308.484 563.375 335.868 566.384 358.548C567.87 369.751 566.162 377.039 563.765 381C562.014 383.891 558.471 387.543 548.313 388.55C536.044 389.765 521.828 382.532 508.704 360.087C495.847 338.098 487.398 306.189 486.609 272.194C486.553 269.765 486.511 267.3 486.475 264.816Z" fill="currentColor"/>
|
|
293
|
+
</svg>
|
|
294
|
+
`, Bt = `
|
|
295
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
296
|
+
<path d="M6 9L12 15L18 9" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
297
|
+
</svg>
|
|
298
|
+
`, jt = () => {
|
|
299
|
+
const e = "supportwire-trigger-styles";
|
|
300
|
+
if (document.getElementById(e)) return;
|
|
301
|
+
const t = document.createElement("style");
|
|
302
|
+
t.id = e, t.textContent = `
|
|
303
|
+
/* ── Trigger entrance ── */
|
|
304
|
+
@keyframes supportwire-trigger-enter {
|
|
305
|
+
from {
|
|
306
|
+
opacity: 0;
|
|
307
|
+
transform: scale(0.8);
|
|
308
|
+
}
|
|
309
|
+
to {
|
|
310
|
+
opacity: 1;
|
|
311
|
+
transform: scale(1);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.supportwire-trigger-wrapper {
|
|
316
|
+
position: relative;
|
|
317
|
+
width: 48px;
|
|
318
|
+
height: 48px;
|
|
319
|
+
animation: supportwire-trigger-enter 350ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.supportwire-widget-trigger {
|
|
323
|
+
width: 100%;
|
|
324
|
+
height: 100%;
|
|
325
|
+
border-radius: 50%;
|
|
326
|
+
border: none;
|
|
327
|
+
cursor: pointer;
|
|
328
|
+
display: flex;
|
|
329
|
+
align-items: center;
|
|
330
|
+
justify-content: center;
|
|
331
|
+
transition: transform 150ms cubic-bezier(0.22, 1, 0.36, 1), opacity 100ms ease-out;
|
|
332
|
+
padding: 0;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/* Hover: instant on (0ms via override below), ease off (150ms base) */
|
|
336
|
+
.supportwire-widget-trigger:hover {
|
|
337
|
+
opacity: 0.9;
|
|
338
|
+
transform: translateY(-2px);
|
|
339
|
+
transition-duration: 0ms;
|
|
340
|
+
}
|
|
341
|
+
.supportwire-widget-trigger:not(:hover) {
|
|
342
|
+
transition-duration: 150ms;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.supportwire-widget-trigger:active {
|
|
346
|
+
transform: scale(0.97);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.supportwire-widget-trigger:focus-visible {
|
|
350
|
+
outline: 2px solid #0091FF;
|
|
351
|
+
outline-offset: 2px;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/* ── Icon crossfade ── */
|
|
355
|
+
.supportwire-widget-trigger .supportwire-trigger-icon {
|
|
356
|
+
position: absolute;
|
|
357
|
+
display: flex;
|
|
358
|
+
align-items: center;
|
|
359
|
+
justify-content: center;
|
|
360
|
+
transition: opacity 150ms ease-out, transform 150ms ease-out;
|
|
361
|
+
}
|
|
362
|
+
.supportwire-trigger-icon--hidden {
|
|
363
|
+
opacity: 0;
|
|
364
|
+
transform: scale(0.8);
|
|
365
|
+
}
|
|
366
|
+
.supportwire-trigger-icon--visible {
|
|
367
|
+
opacity: 1;
|
|
368
|
+
transform: scale(1);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
@media (prefers-reduced-motion: reduce) {
|
|
372
|
+
.supportwire-trigger-wrapper {
|
|
373
|
+
animation: none;
|
|
374
|
+
opacity: 1;
|
|
375
|
+
}
|
|
376
|
+
.supportwire-widget-trigger {
|
|
377
|
+
transition: opacity 100ms ease-out;
|
|
378
|
+
}
|
|
379
|
+
.supportwire-widget-trigger .supportwire-trigger-icon {
|
|
380
|
+
transition: opacity 100ms ease-out;
|
|
381
|
+
transform: none !important;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
`, document.head.appendChild(t);
|
|
385
|
+
}, Gt = (e, t) => {
|
|
386
|
+
var i, n;
|
|
387
|
+
jt();
|
|
388
|
+
const r = document.createElement("div");
|
|
389
|
+
r.className = "supportwire-trigger-wrapper";
|
|
390
|
+
const o = document.createElement("button");
|
|
391
|
+
o.className = "supportwire-widget-trigger", o.setAttribute("aria-label", "Open SupportWire chat"), o.style.position = "relative";
|
|
392
|
+
const l = document.createElement("span");
|
|
393
|
+
l.className = "supportwire-trigger-icon supportwire-trigger-icon--visible", l.setAttribute("data-icon", "logo"), l.innerHTML = Wt;
|
|
394
|
+
const s = document.createElement("span");
|
|
395
|
+
s.className = "supportwire-trigger-icon supportwire-trigger-icon--hidden", s.setAttribute("data-icon", "chevron"), s.innerHTML = Bt, o.appendChild(l), o.appendChild(s), Object.assign(o.style, {
|
|
396
|
+
backgroundColor: e.theme === "dark" ? "#1a1a1a" : "#ffffff",
|
|
397
|
+
color: e.theme === "dark" ? "#ffffff" : "#1a1a1a",
|
|
398
|
+
boxShadow: "0 1px 6px 0 rgba(0, 0, 0, 0.06), 0 2px 32px 0 rgba(0, 0, 0, 0.16)"
|
|
399
|
+
});
|
|
400
|
+
const u = {
|
|
401
|
+
"bottom-right": { bottom: "20px", right: "20px" },
|
|
402
|
+
"bottom-left": { bottom: "20px", left: "20px" },
|
|
403
|
+
"top-right": { top: "20px", right: "20px" },
|
|
404
|
+
"top-left": { top: "20px", left: "20px" }
|
|
405
|
+
}, d = (i = e.triggerPosition) != null ? i : "bottom-right", h = (n = u[d]) != null ? n : u["bottom-right"];
|
|
406
|
+
return Object.assign(r.style, A({
|
|
407
|
+
position: "fixed",
|
|
408
|
+
zIndex: "999998"
|
|
409
|
+
}, h)), r.appendChild(o), o.addEventListener("click", t), document.body.appendChild(r), r;
|
|
410
|
+
}, qt = (e, t) => {
|
|
411
|
+
const i = {
|
|
412
|
+
"bottom-right": { bottom: "20px", right: "20px", top: "auto", left: "auto" },
|
|
413
|
+
"bottom-left": { bottom: "20px", left: "20px", top: "auto", right: "auto" },
|
|
414
|
+
"top-right": { top: "20px", right: "20px", bottom: "auto", left: "auto" },
|
|
415
|
+
"top-left": { top: "20px", left: "20px", bottom: "auto", right: "auto" }
|
|
416
|
+
}, n = t && i[t] ? t : "bottom-right", r = i[n];
|
|
417
|
+
Object.assign(e.style, r);
|
|
418
|
+
}, Yt = () => {
|
|
419
|
+
const e = "supportwire-widget-badge-styles";
|
|
420
|
+
if (document.getElementById(e))
|
|
421
|
+
return;
|
|
422
|
+
const t = document.createElement("style");
|
|
423
|
+
t.id = e, t.textContent = `
|
|
424
|
+
.supportwire-widget-badge {
|
|
425
|
+
position: absolute;
|
|
426
|
+
top: -4px;
|
|
427
|
+
right: -4px;
|
|
428
|
+
min-width: 20px;
|
|
429
|
+
height: 20px;
|
|
430
|
+
padding: 0 6px;
|
|
431
|
+
background-color: #ef4444;
|
|
432
|
+
color: #ffffff;
|
|
433
|
+
border-radius: 10px;
|
|
434
|
+
font-size: 11px;
|
|
435
|
+
font-weight: 600;
|
|
436
|
+
display: flex;
|
|
437
|
+
align-items: center;
|
|
438
|
+
justify-content: center;
|
|
439
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
|
440
|
+
line-height: 1;
|
|
441
|
+
z-index: 999999;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.supportwire-widget-badge[data-animate="pop-in"] {
|
|
445
|
+
animation: supportwire-badge-pop-in 280ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.supportwire-widget-badge[data-animate="pulse"] {
|
|
449
|
+
animation: supportwire-badge-pulse 180ms ease-out;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
@keyframes supportwire-badge-pop-in {
|
|
453
|
+
0% { transform: scale(0.95); opacity: 0; }
|
|
454
|
+
100% { transform: scale(1); opacity: 1; }
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
@keyframes supportwire-badge-pulse {
|
|
458
|
+
0% { transform: scale(1); }
|
|
459
|
+
50% { transform: scale(1.05); }
|
|
460
|
+
100% { transform: scale(1); }
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
@keyframes supportwire-badge-fade-in {
|
|
464
|
+
0% { opacity: 0; }
|
|
465
|
+
100% { opacity: 1; }
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
@media (prefers-reduced-motion: reduce) {
|
|
469
|
+
.supportwire-widget-badge[data-animate="pop-in"] {
|
|
470
|
+
animation: supportwire-badge-fade-in 200ms ease-out forwards;
|
|
471
|
+
}
|
|
472
|
+
.supportwire-widget-badge[data-animate="pulse"] {
|
|
473
|
+
animation: none;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
`, document.head.appendChild(t);
|
|
477
|
+
}, be = (e, t) => {
|
|
478
|
+
Yt();
|
|
479
|
+
let i = e.querySelector(".supportwire-widget-badge");
|
|
480
|
+
if (t > 0) {
|
|
481
|
+
const n = !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", n ? "pop-in" : "pulse");
|
|
483
|
+
} else
|
|
484
|
+
i && (i.style.display = "none", i.removeAttribute("data-animate"));
|
|
485
|
+
}, Le = (e, t, i) => {
|
|
486
|
+
const n = e.querySelector(".supportwire-widget-trigger");
|
|
487
|
+
if (!n) return;
|
|
488
|
+
const r = n.querySelector('[data-icon="logo"]'), o = n.querySelector('[data-icon="chevron"]');
|
|
489
|
+
r && o && (t ? (r.className = "supportwire-trigger-icon supportwire-trigger-icon--hidden", o.className = "supportwire-trigger-icon supportwire-trigger-icon--visible") : (r.className = "supportwire-trigger-icon supportwire-trigger-icon--visible", o.className = "supportwire-trigger-icon supportwire-trigger-icon--hidden")), t ? (n.setAttribute("aria-label", "Close SupportWire chat"), n.style.color = i === "dark" ? "#ffffff" : "#1a1a1a") : (n.setAttribute("aria-label", "Open SupportWire chat"), n.style.color = "");
|
|
490
|
+
}, Kt = (e, t, i, n) => {
|
|
491
|
+
const r = document.createElement("iframe");
|
|
492
|
+
return r.id = t, r.src = `${i}?iframeId=${t}&theme=${n}`, r.style.width = "100%", r.style.height = "100%", r.style.border = "none", r.style.backgroundColor = n === "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, n) => {
|
|
494
|
+
if (!e || !e.contentWindow)
|
|
495
|
+
return;
|
|
496
|
+
const r = Se(A({}, n), {
|
|
497
|
+
iframeId: t
|
|
498
|
+
});
|
|
499
|
+
e.contentWindow.postMessage(r, "*");
|
|
500
|
+
}, Jt = (e, t, i, n) => (r) => {
|
|
501
|
+
var o, l;
|
|
502
|
+
try {
|
|
503
|
+
const u = new URL(t).origin;
|
|
504
|
+
r.origin !== u && r.origin;
|
|
505
|
+
} catch {
|
|
506
|
+
}
|
|
507
|
+
const s = r.data;
|
|
508
|
+
if (!(!s || s.iframeId !== e))
|
|
509
|
+
switch (s.type) {
|
|
510
|
+
case "READY":
|
|
511
|
+
n.onReady && n.onReady();
|
|
512
|
+
break;
|
|
513
|
+
case "OPENED":
|
|
514
|
+
i && (i.style.display = "block", ut(i)), n.onOpen();
|
|
515
|
+
break;
|
|
516
|
+
case "CLOSED":
|
|
517
|
+
i && ht(i), n.onClose();
|
|
518
|
+
break;
|
|
519
|
+
case "ERROR":
|
|
520
|
+
n.onError(new Error(s.error || "Unknown error"));
|
|
521
|
+
break;
|
|
522
|
+
case "UNREAD_COUNT":
|
|
523
|
+
n.onUnreadCount && s.count !== void 0 && n.onUnreadCount(s.count);
|
|
524
|
+
break;
|
|
525
|
+
case "OPEN_IMAGE_PREVIEW":
|
|
526
|
+
n.onImagePreview && s.imagePreview && n.onImagePreview(
|
|
527
|
+
s.imagePreview.src,
|
|
528
|
+
s.imagePreview.alt,
|
|
529
|
+
s.imagePreview.filename
|
|
530
|
+
);
|
|
531
|
+
break;
|
|
532
|
+
case "TOGGLE_FULLSCREEN":
|
|
533
|
+
n.onToggleFullscreen && n.onToggleFullscreen();
|
|
534
|
+
break;
|
|
535
|
+
case "MESSAGE_PREVIEW":
|
|
536
|
+
n.onMessagePreview && s.messagePreview && n.onMessagePreview(
|
|
537
|
+
s.messagePreview.body,
|
|
538
|
+
s.messagePreview.senderName,
|
|
539
|
+
s.messagePreview.timestamp
|
|
540
|
+
);
|
|
541
|
+
break;
|
|
542
|
+
case "EVENT_RULES_REGISTERED":
|
|
543
|
+
n.onEventRulesRegistered && s.eventRules && n.onEventRulesRegistered(s.eventRules);
|
|
544
|
+
break;
|
|
545
|
+
case "REQUEST_PAGE_SCREENSHOT":
|
|
546
|
+
n.onScreenshotRequest && n.onScreenshotRequest((l = (o = s.payload) == null ? void 0 : o.mode) != null ? l : "full");
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
function Xt(e, t) {
|
|
551
|
+
let i = null;
|
|
552
|
+
const n = () => (i || (i = import("./index-bfV4xNqW-CRQbrL80.js")), i), r = (u) => {
|
|
553
|
+
var d;
|
|
554
|
+
(d = e.contentWindow) == null || d.postMessage(Se(A({}, u), { iframeId: t }), "*");
|
|
555
|
+
}, o = async (u) => {
|
|
556
|
+
const d = u.data;
|
|
557
|
+
if (!(!d || typeof d != "object") && !(d.iframeId && d.iframeId !== t))
|
|
558
|
+
switch (d.type) {
|
|
559
|
+
case "RECORDING:START": {
|
|
560
|
+
(await n()).recording.start({ guideId: d.guideId, title: d.title });
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
case "RECORDING:STOP": {
|
|
564
|
+
const h = (await n()).recording.stop();
|
|
565
|
+
h && r({
|
|
566
|
+
type: "RECORDING:DONE",
|
|
567
|
+
guideId: h.guideId,
|
|
568
|
+
title: h.title,
|
|
569
|
+
steps: h.steps
|
|
570
|
+
});
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
case "PLAYBACK:START": {
|
|
574
|
+
const h = await n();
|
|
575
|
+
h.playback.onDone((g, w, y) => {
|
|
576
|
+
r({
|
|
577
|
+
type: "PLAYBACK:DONE",
|
|
578
|
+
status: g,
|
|
579
|
+
end_reason: w,
|
|
580
|
+
current_step: y
|
|
581
|
+
});
|
|
582
|
+
}), h.playback.start({
|
|
583
|
+
sessionId: d.sessionId,
|
|
584
|
+
guideId: d.guideId,
|
|
585
|
+
versionId: d.versionId,
|
|
586
|
+
version: d.version
|
|
587
|
+
});
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
case "OPEN_URL": {
|
|
591
|
+
typeof d.url == "string" && window.open(d.url, "_blank", "noopener");
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}, l = (u) => {
|
|
596
|
+
const d = u.detail;
|
|
597
|
+
d && r({
|
|
598
|
+
type: "RECORDING:DONE",
|
|
599
|
+
guideId: d.guideId,
|
|
600
|
+
title: d.title,
|
|
601
|
+
steps: d.steps
|
|
602
|
+
});
|
|
603
|
+
};
|
|
604
|
+
window.addEventListener("message", o), window.addEventListener("sw-guide:recording-done", l), (async () => {
|
|
605
|
+
const u = await s();
|
|
606
|
+
if (!u) return;
|
|
607
|
+
const d = u.recording.maybeResume();
|
|
608
|
+
d && u.recording.start({ guideId: d.guideId, title: d.title });
|
|
609
|
+
const h = u.playback.maybeResume();
|
|
610
|
+
h && (u.playback.onDone((w, y, S) => {
|
|
611
|
+
r({
|
|
612
|
+
type: "PLAYBACK:DONE",
|
|
613
|
+
status: w,
|
|
614
|
+
end_reason: y,
|
|
615
|
+
current_step: S
|
|
616
|
+
});
|
|
617
|
+
}), u.playback.start({
|
|
618
|
+
sessionId: h.sessionId,
|
|
619
|
+
guideId: h.guideId,
|
|
620
|
+
versionId: h.versionId,
|
|
621
|
+
version: h.version,
|
|
622
|
+
resumeStepIndex: h.stepIndex
|
|
623
|
+
}));
|
|
624
|
+
const g = new URLSearchParams(location.search).get("sw_guide");
|
|
625
|
+
g && r({ type: "DEEP_LINK_GUIDE", guideId: g });
|
|
626
|
+
})();
|
|
627
|
+
function s() {
|
|
628
|
+
const u = !!localStorage.getItem("sw.guide.recording"), d = !!localStorage.getItem("sw.guide.playback"), h = new URLSearchParams(location.search).has("sw_guide");
|
|
629
|
+
return !u && !d && !h ? Promise.resolve(null) : n();
|
|
630
|
+
}
|
|
631
|
+
return {
|
|
632
|
+
teardown: () => {
|
|
633
|
+
window.removeEventListener("message", o), window.removeEventListener("sw-guide:recording-done", l);
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
let W = null, se = null, gt = "";
|
|
638
|
+
const Qt = `
|
|
639
|
+
.supportwire-image-preview-backdrop {
|
|
640
|
+
position: fixed;
|
|
641
|
+
top: 0;
|
|
642
|
+
left: 0;
|
|
643
|
+
right: 0;
|
|
644
|
+
bottom: 0;
|
|
645
|
+
background: rgba(0, 0, 0, 0);
|
|
646
|
+
display: flex;
|
|
647
|
+
align-items: center;
|
|
648
|
+
justify-content: center;
|
|
649
|
+
z-index: 2147483647;
|
|
650
|
+
padding: 24px;
|
|
651
|
+
opacity: 0;
|
|
652
|
+
transition: background 200ms ease-out, opacity 200ms ease-out;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.supportwire-image-preview-backdrop.visible {
|
|
656
|
+
background: rgba(0, 0, 0, 0.9);
|
|
657
|
+
opacity: 1;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.supportwire-image-preview-backdrop.closing {
|
|
661
|
+
background: rgba(0, 0, 0, 0);
|
|
662
|
+
opacity: 0;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
@media (prefers-reduced-motion: reduce) {
|
|
666
|
+
.supportwire-image-preview-backdrop {
|
|
667
|
+
transition: none;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/* Floating buttons in top-right corner */
|
|
672
|
+
.supportwire-image-preview-actions {
|
|
673
|
+
position: fixed;
|
|
674
|
+
top: 16px;
|
|
675
|
+
right: 16px;
|
|
676
|
+
display: flex;
|
|
677
|
+
gap: 8px;
|
|
678
|
+
z-index: 2147483647;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.supportwire-image-preview-button {
|
|
682
|
+
display: flex;
|
|
683
|
+
align-items: center;
|
|
684
|
+
justify-content: center;
|
|
685
|
+
width: 36px;
|
|
686
|
+
height: 36px;
|
|
687
|
+
border-radius: 50%;
|
|
688
|
+
background: rgba(255, 255, 255, 0.1);
|
|
689
|
+
backdrop-filter: blur(8px);
|
|
690
|
+
-webkit-backdrop-filter: blur(8px);
|
|
691
|
+
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
692
|
+
color: rgba(255, 255, 255, 0.9);
|
|
693
|
+
cursor: pointer;
|
|
694
|
+
padding: 0;
|
|
695
|
+
transition: background 150ms ease, transform 150ms ease;
|
|
696
|
+
-webkit-tap-highlight-color: transparent;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
.supportwire-image-preview-button:hover {
|
|
700
|
+
background: rgba(255, 255, 255, 0.2);
|
|
701
|
+
transform: scale(1.05);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
.supportwire-image-preview-button:active {
|
|
705
|
+
transform: scale(0.95);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
.supportwire-image-preview-button:focus {
|
|
709
|
+
outline: 2px solid rgba(255, 255, 255, 0.5);
|
|
710
|
+
outline-offset: 2px;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
@media (prefers-reduced-motion: reduce) {
|
|
714
|
+
.supportwire-image-preview-button {
|
|
715
|
+
transition: none;
|
|
716
|
+
}
|
|
717
|
+
.supportwire-image-preview-button:hover,
|
|
718
|
+
.supportwire-image-preview-button:active {
|
|
719
|
+
transform: none;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/* Image container */
|
|
724
|
+
.supportwire-image-preview-image-container {
|
|
725
|
+
display: flex;
|
|
726
|
+
align-items: center;
|
|
727
|
+
justify-content: center;
|
|
728
|
+
position: relative;
|
|
729
|
+
max-width: 90vw;
|
|
730
|
+
max-height: 90vh;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
.supportwire-image-preview-image {
|
|
734
|
+
max-width: 90vw;
|
|
735
|
+
max-height: 90vh;
|
|
736
|
+
object-fit: contain;
|
|
737
|
+
border-radius: 8px;
|
|
738
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
|
|
739
|
+
opacity: 0;
|
|
740
|
+
transform: scale(0.95);
|
|
741
|
+
transition: opacity 200ms ease-out, transform 200ms ease-out;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
.supportwire-image-preview-backdrop.visible .supportwire-image-preview-image {
|
|
745
|
+
opacity: 1;
|
|
746
|
+
transform: scale(1);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
.supportwire-image-preview-backdrop.closing .supportwire-image-preview-image {
|
|
750
|
+
opacity: 0;
|
|
751
|
+
transform: scale(0.95);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
@media (prefers-reduced-motion: reduce) {
|
|
755
|
+
.supportwire-image-preview-image {
|
|
756
|
+
transition: none;
|
|
757
|
+
transform: scale(1);
|
|
758
|
+
opacity: 1;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
.supportwire-image-preview-loader {
|
|
763
|
+
position: absolute;
|
|
764
|
+
width: 32px;
|
|
765
|
+
height: 32px;
|
|
766
|
+
border: 3px solid rgba(255, 255, 255, 0.2);
|
|
767
|
+
border-top-color: #fff;
|
|
768
|
+
border-radius: 50%;
|
|
769
|
+
animation: supportwire-spin 0.8s linear infinite;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
@keyframes supportwire-spin {
|
|
773
|
+
to { transform: rotate(360deg); }
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
@media (prefers-reduced-motion: reduce) {
|
|
777
|
+
.supportwire-image-preview-loader {
|
|
778
|
+
animation: none;
|
|
779
|
+
border-top-color: rgba(255, 255, 255, 0.2);
|
|
780
|
+
border-right-color: #fff;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
.supportwire-image-preview-error {
|
|
785
|
+
color: #fff;
|
|
786
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
787
|
+
font-size: 14px;
|
|
788
|
+
text-align: center;
|
|
789
|
+
padding: 40px;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/* Filename at bottom */
|
|
793
|
+
.supportwire-image-preview-filename {
|
|
794
|
+
position: fixed;
|
|
795
|
+
bottom: 16px;
|
|
796
|
+
left: 50%;
|
|
797
|
+
transform: translateX(-50%);
|
|
798
|
+
font-size: 13px;
|
|
799
|
+
color: rgba(255, 255, 255, 0.7);
|
|
800
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
801
|
+
margin: 0;
|
|
802
|
+
padding: 8px 16px;
|
|
803
|
+
background: rgba(0, 0, 0, 0.5);
|
|
804
|
+
backdrop-filter: blur(8px);
|
|
805
|
+
-webkit-backdrop-filter: blur(8px);
|
|
806
|
+
border-radius: 20px;
|
|
807
|
+
max-width: 80vw;
|
|
808
|
+
white-space: nowrap;
|
|
809
|
+
overflow: hidden;
|
|
810
|
+
text-overflow: ellipsis;
|
|
811
|
+
opacity: 0;
|
|
812
|
+
transition: opacity 200ms ease-out;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
.supportwire-image-preview-backdrop.visible .supportwire-image-preview-filename {
|
|
816
|
+
opacity: 1;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
@media (prefers-reduced-motion: reduce) {
|
|
820
|
+
.supportwire-image-preview-filename {
|
|
821
|
+
transition: none;
|
|
822
|
+
opacity: 1;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/* Mobile responsiveness */
|
|
827
|
+
@media (max-width: 480px) {
|
|
828
|
+
.supportwire-image-preview-backdrop {
|
|
829
|
+
padding: 16px;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
.supportwire-image-preview-actions {
|
|
833
|
+
top: 12px;
|
|
834
|
+
right: 12px;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
.supportwire-image-preview-button {
|
|
838
|
+
width: 40px;
|
|
839
|
+
height: 40px;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
.supportwire-image-preview-filename {
|
|
843
|
+
bottom: 12px;
|
|
844
|
+
font-size: 12px;
|
|
845
|
+
max-width: 90vw;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
`;
|
|
849
|
+
function Zt() {
|
|
850
|
+
if (document.getElementById("supportwire-image-preview-styles")) return;
|
|
851
|
+
const e = document.createElement("style");
|
|
852
|
+
e.id = "supportwire-image-preview-styles", e.textContent = Qt, document.head.appendChild(e);
|
|
853
|
+
}
|
|
854
|
+
function ei() {
|
|
855
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
856
|
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
|
|
857
|
+
<polyline points="7 10 12 15 17 10"/>
|
|
858
|
+
<line x1="12" y1="15" x2="12" y2="3"/>
|
|
859
|
+
</svg>`;
|
|
860
|
+
}
|
|
861
|
+
function ti() {
|
|
862
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
863
|
+
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
864
|
+
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
865
|
+
</svg>`;
|
|
866
|
+
}
|
|
867
|
+
function ii() {
|
|
868
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
869
|
+
<path d="M12 20h9"/>
|
|
870
|
+
<path d="M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z"/>
|
|
871
|
+
</svg>`;
|
|
872
|
+
}
|
|
873
|
+
function $e() {
|
|
874
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
875
|
+
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/>
|
|
876
|
+
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>
|
|
877
|
+
</svg>`;
|
|
878
|
+
}
|
|
879
|
+
function Qe() {
|
|
880
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
881
|
+
<polyline points="20 6 9 17 4 12"/>
|
|
882
|
+
</svg>`;
|
|
883
|
+
}
|
|
884
|
+
async function ri(e, t) {
|
|
885
|
+
try {
|
|
886
|
+
const i = await (await fetch(e)).blob(), n = URL.createObjectURL(i), r = document.createElement("a");
|
|
887
|
+
r.href = n, r.download = t || "image", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(n);
|
|
888
|
+
} catch {
|
|
889
|
+
window.open(e, "_blank");
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
function re() {
|
|
893
|
+
if (!W) return;
|
|
894
|
+
const e = W;
|
|
895
|
+
se && (document.removeEventListener("keydown", se), se = null), document.body.style.overflow = gt, e.classList.remove("visible"), e.classList.add("closing"), window.matchMedia("(prefers-reduced-motion: reduce)").matches ? (e.remove(), W = null) : setTimeout(() => {
|
|
896
|
+
e.remove(), W === e && (W = null);
|
|
897
|
+
}, 200);
|
|
898
|
+
}
|
|
899
|
+
function ni(e, t, i, n) {
|
|
900
|
+
W && (W.remove(), W = null), Zt(), gt = document.body.style.overflow, document.body.style.overflow = "hidden";
|
|
901
|
+
const r = document.createElement("div");
|
|
902
|
+
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
|
+
(y.target === r || y.target.classList.contains("supportwire-image-preview-image-container")) && re();
|
|
904
|
+
};
|
|
905
|
+
const o = document.createElement("div");
|
|
906
|
+
o.className = "supportwire-image-preview-actions";
|
|
907
|
+
const l = document.createElement("button");
|
|
908
|
+
l.className = "supportwire-image-preview-button", l.setAttribute("aria-label", "Copy link"), l.innerHTML = $e(), l.onclick = async (y) => {
|
|
909
|
+
y.stopPropagation();
|
|
910
|
+
try {
|
|
911
|
+
await navigator.clipboard.writeText(e), l.innerHTML = Qe(), setTimeout(() => {
|
|
912
|
+
l.innerHTML = $e();
|
|
913
|
+
}, 2e3);
|
|
914
|
+
} catch {
|
|
915
|
+
const b = document.createElement("textarea");
|
|
916
|
+
b.value = e, b.style.position = "fixed", b.style.opacity = "0", document.body.appendChild(b), b.select(), document.execCommand("copy"), document.body.removeChild(b), l.innerHTML = Qe(), setTimeout(() => {
|
|
917
|
+
l.innerHTML = $e();
|
|
918
|
+
}, 2e3);
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
const s = document.createElement("button");
|
|
922
|
+
s.className = "supportwire-image-preview-button", s.setAttribute("aria-label", "Download image"), s.innerHTML = ei(), s.onclick = (y) => {
|
|
923
|
+
y.stopPropagation(), ri(e, i);
|
|
924
|
+
};
|
|
925
|
+
let u = null;
|
|
926
|
+
n && (u = document.createElement("button"), u.className = "supportwire-image-preview-button", u.setAttribute("aria-label", "Annotate image"), u.innerHTML = ii(), u.onclick = async (y) => {
|
|
927
|
+
y.stopPropagation();
|
|
928
|
+
try {
|
|
929
|
+
const S = await (await fetch(e)).blob(), b = await new Promise((v, k) => {
|
|
930
|
+
const C = new FileReader();
|
|
931
|
+
C.onload = () => v(C.result), C.onerror = k, C.readAsDataURL(S);
|
|
932
|
+
});
|
|
933
|
+
re(), n(b);
|
|
934
|
+
} catch {
|
|
935
|
+
const b = document.createElement("canvas"), v = new Image();
|
|
936
|
+
v.crossOrigin = "anonymous", v.onload = () => {
|
|
937
|
+
b.width = v.naturalWidth, b.height = v.naturalHeight;
|
|
938
|
+
const k = b.getContext("2d");
|
|
939
|
+
if (k) {
|
|
940
|
+
k.drawImage(v, 0, 0);
|
|
941
|
+
const C = b.toDataURL("image/png");
|
|
942
|
+
re(), n(C);
|
|
943
|
+
}
|
|
944
|
+
}, v.onerror = () => {
|
|
945
|
+
console.warn("Could not load image for annotation");
|
|
946
|
+
}, v.src = e;
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
const d = document.createElement("button");
|
|
950
|
+
d.className = "supportwire-image-preview-button", d.setAttribute("aria-label", "Close preview"), d.innerHTML = ti(), d.onclick = (y) => {
|
|
951
|
+
y.stopPropagation(), re();
|
|
952
|
+
}, o.appendChild(l), o.appendChild(s), u && o.appendChild(u), o.appendChild(d);
|
|
953
|
+
const h = document.createElement("div");
|
|
954
|
+
h.className = "supportwire-image-preview-image-container";
|
|
955
|
+
const g = document.createElement("div");
|
|
956
|
+
g.className = "supportwire-image-preview-loader", h.appendChild(g);
|
|
957
|
+
const w = document.createElement("img");
|
|
958
|
+
if (w.className = "supportwire-image-preview-image", w.alt = t || "Image preview", w.onload = () => {
|
|
959
|
+
g.remove();
|
|
960
|
+
}, w.onerror = () => {
|
|
961
|
+
g.remove();
|
|
962
|
+
const y = document.createElement("div");
|
|
963
|
+
y.className = "supportwire-image-preview-error", y.textContent = "Failed to load image", h.appendChild(y);
|
|
964
|
+
}, w.src = e, h.appendChild(w), i) {
|
|
965
|
+
const y = document.createElement("p");
|
|
966
|
+
y.className = "supportwire-image-preview-filename", y.textContent = i, r.appendChild(y);
|
|
967
|
+
}
|
|
968
|
+
r.appendChild(o), r.appendChild(h), document.body.appendChild(r), W = r, requestAnimationFrame(() => {
|
|
969
|
+
r.classList.add("visible");
|
|
970
|
+
}), se = (y) => {
|
|
971
|
+
y.key === "Escape" && re();
|
|
972
|
+
}, document.addEventListener("keydown", se), d.focus();
|
|
973
|
+
}
|
|
974
|
+
let V = null, ae = null, mt = "";
|
|
975
|
+
const c = "supportwire-ss-editor", oi = `
|
|
976
|
+
.${c}-backdrop {
|
|
977
|
+
position: fixed;
|
|
978
|
+
inset: 0;
|
|
979
|
+
z-index: 2147483647;
|
|
980
|
+
background: rgba(0, 0, 0, 0.6);
|
|
981
|
+
display: flex;
|
|
982
|
+
align-items: center;
|
|
983
|
+
justify-content: center;
|
|
984
|
+
padding: 0;
|
|
985
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
986
|
+
}
|
|
987
|
+
.${c}-modal {
|
|
988
|
+
background: #fff;
|
|
989
|
+
border-radius: 16px;
|
|
990
|
+
box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4);
|
|
991
|
+
display: flex;
|
|
992
|
+
flex-direction: column;
|
|
993
|
+
width: 95vw;
|
|
994
|
+
height: 95vh;
|
|
995
|
+
overflow: hidden;
|
|
996
|
+
}
|
|
997
|
+
.${c}-header {
|
|
998
|
+
display: flex;
|
|
999
|
+
align-items: center;
|
|
1000
|
+
justify-content: space-between;
|
|
1001
|
+
padding: 12px 16px;
|
|
1002
|
+
border-bottom: 1px solid #e5e7eb;
|
|
1003
|
+
}
|
|
1004
|
+
.${c}-title {
|
|
1005
|
+
font-size: 14px;
|
|
1006
|
+
font-weight: 600;
|
|
1007
|
+
color: #111;
|
|
1008
|
+
}
|
|
1009
|
+
.${c}-close-btn {
|
|
1010
|
+
display: flex;
|
|
1011
|
+
align-items: center;
|
|
1012
|
+
justify-content: center;
|
|
1013
|
+
width: 32px;
|
|
1014
|
+
height: 32px;
|
|
1015
|
+
border-radius: 50%;
|
|
1016
|
+
border: none;
|
|
1017
|
+
background: transparent;
|
|
1018
|
+
color: #666;
|
|
1019
|
+
cursor: pointer;
|
|
1020
|
+
}
|
|
1021
|
+
.${c}-close-btn:hover { background: #f3f4f6; color: #111; }
|
|
1022
|
+
.${c}-canvas-wrap {
|
|
1023
|
+
position: relative;
|
|
1024
|
+
flex: 1;
|
|
1025
|
+
min-height: 300px;
|
|
1026
|
+
overflow: hidden;
|
|
1027
|
+
cursor: crosshair;
|
|
1028
|
+
background: #f9fafb;
|
|
1029
|
+
}
|
|
1030
|
+
.${c}-canvas-wrap.select-mode { cursor: default; }
|
|
1031
|
+
.${c}-canvas-wrap.select-mode-moving { cursor: grabbing; }
|
|
1032
|
+
.${c}-img {
|
|
1033
|
+
display: block;
|
|
1034
|
+
pointer-events: none;
|
|
1035
|
+
user-select: none;
|
|
1036
|
+
}
|
|
1037
|
+
.${c}-canvas {
|
|
1038
|
+
position: absolute;
|
|
1039
|
+
left: 0;
|
|
1040
|
+
top: 0;
|
|
1041
|
+
pointer-events: none;
|
|
1042
|
+
}
|
|
1043
|
+
.${c}-toolbar {
|
|
1044
|
+
display: flex;
|
|
1045
|
+
align-items: center;
|
|
1046
|
+
justify-content: space-between;
|
|
1047
|
+
flex-wrap: wrap;
|
|
1048
|
+
gap: 8px;
|
|
1049
|
+
padding: 12px 16px;
|
|
1050
|
+
border-top: 1px solid #e5e7eb;
|
|
1051
|
+
}
|
|
1052
|
+
.${c}-tools {
|
|
1053
|
+
display: flex;
|
|
1054
|
+
align-items: center;
|
|
1055
|
+
gap: 4px;
|
|
1056
|
+
}
|
|
1057
|
+
.${c}-tool-btn {
|
|
1058
|
+
display: flex;
|
|
1059
|
+
align-items: center;
|
|
1060
|
+
justify-content: center;
|
|
1061
|
+
width: 36px;
|
|
1062
|
+
height: 36px;
|
|
1063
|
+
border-radius: 50%;
|
|
1064
|
+
border: none;
|
|
1065
|
+
background: transparent;
|
|
1066
|
+
color: #666;
|
|
1067
|
+
cursor: pointer;
|
|
1068
|
+
}
|
|
1069
|
+
.${c}-tool-btn:hover { background: #f3f4f6; color: #111; }
|
|
1070
|
+
.${c}-tool-btn.active { background: #0091FF; color: #fff; }
|
|
1071
|
+
.${c}-color-picker {
|
|
1072
|
+
width: 28px;
|
|
1073
|
+
height: 28px;
|
|
1074
|
+
border: none;
|
|
1075
|
+
border-radius: 50%;
|
|
1076
|
+
cursor: pointer;
|
|
1077
|
+
background: transparent;
|
|
1078
|
+
padding: 0;
|
|
1079
|
+
}
|
|
1080
|
+
.${c}-separator {
|
|
1081
|
+
width: 1px;
|
|
1082
|
+
height: 24px;
|
|
1083
|
+
background: #e5e7eb;
|
|
1084
|
+
margin: 0 4px;
|
|
1085
|
+
}
|
|
1086
|
+
.${c}-color-swatches {
|
|
1087
|
+
display: flex;
|
|
1088
|
+
align-items: center;
|
|
1089
|
+
gap: 3px;
|
|
1090
|
+
}
|
|
1091
|
+
.${c}-swatch {
|
|
1092
|
+
width: 22px;
|
|
1093
|
+
height: 22px;
|
|
1094
|
+
border-radius: 50%;
|
|
1095
|
+
border: 2px solid transparent;
|
|
1096
|
+
cursor: pointer;
|
|
1097
|
+
padding: 0;
|
|
1098
|
+
box-sizing: border-box;
|
|
1099
|
+
}
|
|
1100
|
+
.${c}-swatch.active {
|
|
1101
|
+
border-color: #111;
|
|
1102
|
+
box-shadow: 0 0 0 1px #fff inset;
|
|
1103
|
+
}
|
|
1104
|
+
.${c}-swatch:hover { opacity: 0.8; }
|
|
1105
|
+
.${c}-thickness-wrap {
|
|
1106
|
+
display: flex;
|
|
1107
|
+
align-items: center;
|
|
1108
|
+
gap: 6px;
|
|
1109
|
+
}
|
|
1110
|
+
.${c}-thickness-label {
|
|
1111
|
+
font-size: 11px;
|
|
1112
|
+
color: #888;
|
|
1113
|
+
white-space: nowrap;
|
|
1114
|
+
}
|
|
1115
|
+
.${c}-thickness-slider {
|
|
1116
|
+
width: 80px;
|
|
1117
|
+
height: 4px;
|
|
1118
|
+
accent-color: #0091FF;
|
|
1119
|
+
cursor: pointer;
|
|
1120
|
+
}
|
|
1121
|
+
.${c}-radius-btn {
|
|
1122
|
+
display: flex;
|
|
1123
|
+
align-items: center;
|
|
1124
|
+
justify-content: center;
|
|
1125
|
+
width: 36px;
|
|
1126
|
+
height: 36px;
|
|
1127
|
+
border-radius: 50%;
|
|
1128
|
+
border: none;
|
|
1129
|
+
background: transparent;
|
|
1130
|
+
color: #666;
|
|
1131
|
+
cursor: pointer;
|
|
1132
|
+
font-size: 11px;
|
|
1133
|
+
font-weight: 600;
|
|
1134
|
+
}
|
|
1135
|
+
.${c}-radius-btn:hover { background: #f3f4f6; color: #111; }
|
|
1136
|
+
.${c}-radius-btn.active { background: #0091FF; color: #fff; }
|
|
1137
|
+
.${c}-actions {
|
|
1138
|
+
display: flex;
|
|
1139
|
+
gap: 8px;
|
|
1140
|
+
align-items: center;
|
|
1141
|
+
}
|
|
1142
|
+
.${c}-btn-cancel {
|
|
1143
|
+
padding: 8px 16px;
|
|
1144
|
+
font-size: 13px;
|
|
1145
|
+
border-radius: 8px;
|
|
1146
|
+
background: transparent;
|
|
1147
|
+
color: #333;
|
|
1148
|
+
border: 1px solid #e5e7eb;
|
|
1149
|
+
cursor: pointer;
|
|
1150
|
+
font-family: inherit;
|
|
1151
|
+
}
|
|
1152
|
+
.${c}-btn-cancel:hover { background: #f3f4f6; }
|
|
1153
|
+
.${c}-btn-done {
|
|
1154
|
+
padding: 8px 16px;
|
|
1155
|
+
font-size: 13px;
|
|
1156
|
+
border-radius: 8px;
|
|
1157
|
+
background: #0091FF;
|
|
1158
|
+
color: #fff;
|
|
1159
|
+
border: none;
|
|
1160
|
+
cursor: pointer;
|
|
1161
|
+
font-family: inherit;
|
|
1162
|
+
}
|
|
1163
|
+
.${c}-btn-done:hover { opacity: 0.9; }
|
|
1164
|
+
.${c}-btn-crop-apply {
|
|
1165
|
+
padding: 6px 12px;
|
|
1166
|
+
font-size: 12px;
|
|
1167
|
+
border-radius: 8px;
|
|
1168
|
+
background: #0091FF;
|
|
1169
|
+
color: #fff;
|
|
1170
|
+
border: none;
|
|
1171
|
+
cursor: pointer;
|
|
1172
|
+
font-family: inherit;
|
|
1173
|
+
}
|
|
1174
|
+
.${c}-text-overlay {
|
|
1175
|
+
position: absolute;
|
|
1176
|
+
display: flex;
|
|
1177
|
+
gap: 4px;
|
|
1178
|
+
z-index: 10;
|
|
1179
|
+
background: #fff;
|
|
1180
|
+
border: 1px solid #e5e7eb;
|
|
1181
|
+
border-radius: 8px;
|
|
1182
|
+
padding: 4px;
|
|
1183
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
1184
|
+
}
|
|
1185
|
+
.${c}-text-input {
|
|
1186
|
+
width: 140px;
|
|
1187
|
+
padding: 4px 8px;
|
|
1188
|
+
font-size: 13px;
|
|
1189
|
+
border: none;
|
|
1190
|
+
border-radius: 4px;
|
|
1191
|
+
background: #f3f4f6;
|
|
1192
|
+
color: #111;
|
|
1193
|
+
outline: none;
|
|
1194
|
+
font-family: inherit;
|
|
1195
|
+
}
|
|
1196
|
+
.${c}-text-ok {
|
|
1197
|
+
padding: 4px 8px;
|
|
1198
|
+
font-size: 12px;
|
|
1199
|
+
border-radius: 4px;
|
|
1200
|
+
background: #0091FF;
|
|
1201
|
+
color: #fff;
|
|
1202
|
+
border: none;
|
|
1203
|
+
cursor: pointer;
|
|
1204
|
+
font-family: inherit;
|
|
1205
|
+
}
|
|
1206
|
+
.${c}-undo-btn {
|
|
1207
|
+
display: flex;
|
|
1208
|
+
align-items: center;
|
|
1209
|
+
justify-content: center;
|
|
1210
|
+
width: 36px;
|
|
1211
|
+
height: 36px;
|
|
1212
|
+
border-radius: 50%;
|
|
1213
|
+
border: none;
|
|
1214
|
+
background: transparent;
|
|
1215
|
+
color: #666;
|
|
1216
|
+
cursor: pointer;
|
|
1217
|
+
}
|
|
1218
|
+
.${c}-undo-btn:hover { background: #f3f4f6; color: #111; }
|
|
1219
|
+
.${c}-undo-btn:disabled { opacity: 0.3; cursor: default; }
|
|
1220
|
+
@media (max-width: 540px) {
|
|
1221
|
+
.${c}-modal { width: 100%; height: 100vh; border-radius: 0; }
|
|
1222
|
+
.${c}-backdrop { padding: 0; }
|
|
1223
|
+
}
|
|
1224
|
+
`;
|
|
1225
|
+
function si() {
|
|
1226
|
+
if (document.getElementById(`${c}-styles`)) return;
|
|
1227
|
+
const e = document.createElement("style");
|
|
1228
|
+
e.id = `${c}-styles`, e.textContent = oi, document.head.appendChild(e);
|
|
1229
|
+
}
|
|
1230
|
+
const Re = {
|
|
1231
|
+
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>',
|
|
1232
|
+
pen: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/></svg>',
|
|
1233
|
+
arrow: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14"/><path d="M12 5l7 7-7 7"/></svg>',
|
|
1234
|
+
rect: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/></svg>',
|
|
1235
|
+
text: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 7V4h16v3"/><path d="M9 20h6"/><path d="M12 4v16"/></svg>',
|
|
1236
|
+
crop: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 3v18"/><path d="M18 3v18"/><path d="M3 6h18"/><path d="M3 18h18"/></svg>',
|
|
1237
|
+
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
|
+
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
|
+
};
|
|
1240
|
+
function ft(e, t, i, n, r, o) {
|
|
1241
|
+
const l = Math.min(o, Math.abs(n) / 2, Math.abs(r) / 2);
|
|
1242
|
+
e.beginPath(), e.moveTo(t + l, i), e.lineTo(t + n - l, i), e.arcTo(t + n, i, t + n, i + l, l), e.lineTo(t + n, i + r - l), e.arcTo(t + n, i + r, t + n - 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
|
+
}
|
|
1244
|
+
function Ze(e, t) {
|
|
1245
|
+
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) {
|
|
1246
|
+
e.beginPath(), e.moveTo(t.points[0], t.points[1]);
|
|
1247
|
+
for (let i = 2; i < t.points.length; i += 2) e.lineTo(t.points[i], t.points[i + 1]);
|
|
1248
|
+
e.stroke();
|
|
1249
|
+
} else if (t.type === "arrow") {
|
|
1250
|
+
e.beginPath(), e.moveTo(t.x1, t.y1), e.lineTo(t.x2, t.y2), e.stroke();
|
|
1251
|
+
const i = 10, n = Math.atan2(t.y2 - t.y1, t.x2 - t.x1);
|
|
1252
|
+
e.beginPath(), e.moveTo(t.x2, t.y2), e.lineTo(t.x2 - i * Math.cos(n - 0.4), t.y2 - i * Math.sin(n - 0.4)), e.lineTo(t.x2 - i * Math.cos(n + 0.4), t.y2 - i * Math.sin(n + 0.4)), e.closePath(), e.fill();
|
|
1253
|
+
} 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
|
+
}
|
|
1255
|
+
function wt(e) {
|
|
1256
|
+
if (e.type === "rect")
|
|
1257
|
+
return { x: e.x, y: e.y, w: e.w, h: e.h };
|
|
1258
|
+
if (e.type === "arrow") {
|
|
1259
|
+
const t = Math.min(e.x1, e.x2), i = Math.min(e.y1, e.y2);
|
|
1260
|
+
return { x: t, y: i, w: Math.abs(e.x2 - e.x1), h: Math.abs(e.y2 - e.y1) };
|
|
1261
|
+
} else if (e.type === "pen" && e.points.length >= 4) {
|
|
1262
|
+
let t = e.points[0], i = e.points[0], n = e.points[1], r = e.points[1];
|
|
1263
|
+
for (let o = 2; o < e.points.length; o += 2)
|
|
1264
|
+
t = Math.min(t, e.points[o]), i = Math.max(i, e.points[o]), n = Math.min(n, e.points[o + 1]), r = Math.max(r, e.points[o + 1]);
|
|
1265
|
+
return { x: t, y: n, w: i - t, h: r - n };
|
|
1266
|
+
} else if (e.type === "text")
|
|
1267
|
+
return { x: e.x, y: e.y, w: 100, h: 20 };
|
|
1268
|
+
return { x: 0, y: 0, w: 0, h: 0 };
|
|
1269
|
+
}
|
|
1270
|
+
function ai(e, t, i, n) {
|
|
1271
|
+
const r = n;
|
|
1272
|
+
if (e.type === "rect") {
|
|
1273
|
+
const { x: o, y: l, w: s, h: u } = e, d = i >= l - r && i <= l + r && t >= o - r && t <= o + s + r, h = i >= l + u - r && i <= l + u + r && t >= o - r && t <= o + s + r, g = t >= o - r && t <= o + r && i >= l - r && i <= l + u + r, w = t >= o + s - r && t <= o + s + r && i >= l - r && i <= l + u + r, y = t >= o && t <= o + s && i >= l && i <= l + u;
|
|
1274
|
+
return d || h || g || w || y;
|
|
1275
|
+
} else {
|
|
1276
|
+
if (e.type === "arrow")
|
|
1277
|
+
return et(t, i, e.x1, e.y1, e.x2, e.y2) <= r + e.width;
|
|
1278
|
+
if (e.type === "pen" && e.points.length >= 4) {
|
|
1279
|
+
for (let o = 0; o < e.points.length - 2; o += 2)
|
|
1280
|
+
if (et(t, i, e.points[o], e.points[o + 1], e.points[o + 2], e.points[o + 3]) <= r + e.width) return !0;
|
|
1281
|
+
return !1;
|
|
1282
|
+
} else if (e.type === "text") {
|
|
1283
|
+
const o = wt(e);
|
|
1284
|
+
return t >= o.x - r && t <= o.x + o.w + r && i >= o.y - r && i <= o.y + o.h + r;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
return !1;
|
|
1288
|
+
}
|
|
1289
|
+
function et(e, t, i, n, r, o) {
|
|
1290
|
+
const l = r - i, s = o - n, u = l * l + s * s;
|
|
1291
|
+
if (u === 0) return Math.hypot(e - i, t - n);
|
|
1292
|
+
let d = ((e - i) * l + (t - n) * s) / u;
|
|
1293
|
+
return d = Math.max(0, Math.min(1, d)), Math.hypot(e - (i + d * l), t - (n + d * s));
|
|
1294
|
+
}
|
|
1295
|
+
function li(e, t, i) {
|
|
1296
|
+
if (e.type === "rect")
|
|
1297
|
+
e.x += t, e.y += i;
|
|
1298
|
+
else if (e.type === "arrow")
|
|
1299
|
+
e.x1 += t, e.y1 += i, e.x2 += t, e.y2 += i;
|
|
1300
|
+
else if (e.type === "pen")
|
|
1301
|
+
for (let n = 0; n < e.points.length; n += 2)
|
|
1302
|
+
e.points[n] += t, e.points[n + 1] += i;
|
|
1303
|
+
else e.type === "text" && (e.x += t, e.y += i);
|
|
1304
|
+
}
|
|
1305
|
+
function di(e, t) {
|
|
1306
|
+
const i = wt(t), n = 6;
|
|
1307
|
+
e.save(), e.strokeStyle = "#0091FF", e.lineWidth = 1.5, e.setLineDash([4, 3]), e.strokeRect(i.x - n, i.y - n, i.w + n * 2, i.h + n * 2), e.setLineDash([]);
|
|
1308
|
+
const r = 5;
|
|
1309
|
+
e.fillStyle = "#fff", e.strokeStyle = "#0091FF", e.lineWidth = 1.5;
|
|
1310
|
+
const o = [
|
|
1311
|
+
[i.x - n, i.y - n],
|
|
1312
|
+
[i.x + i.w + n, i.y - n],
|
|
1313
|
+
[i.x - n, i.y + i.h + n],
|
|
1314
|
+
[i.x + i.w + n, i.y + i.h + n]
|
|
1315
|
+
];
|
|
1316
|
+
for (const [l, s] of o)
|
|
1317
|
+
e.beginPath(), e.arc(l, s, r, 0, Math.PI * 2), e.fill(), e.stroke();
|
|
1318
|
+
e.restore();
|
|
1319
|
+
}
|
|
1320
|
+
function ne() {
|
|
1321
|
+
V && (ae && (document.removeEventListener("keydown", ae), ae = null), document.body.style.overflow = mt, V.remove(), V = null);
|
|
1322
|
+
}
|
|
1323
|
+
function tt(e, t, i) {
|
|
1324
|
+
V && (V.remove(), V = null), si(), mt = document.body.style.overflow, document.body.style.overflow = "hidden";
|
|
1325
|
+
let n = "rect", r = "#FF3B30", o = 3, l = 0, s = [], u = e, d = 0, h = 0, g = 1, w = 0, y = 0, S = !1, b = [], v = null, k = null, C = null, N = null, M = null, D = null, K = null;
|
|
1326
|
+
const ce = document.createElement("div");
|
|
1327
|
+
ce.className = `${c}-backdrop`;
|
|
1328
|
+
const X = document.createElement("div");
|
|
1329
|
+
X.className = `${c}-modal`, X.onclick = (a) => a.stopPropagation();
|
|
1330
|
+
const ue = document.createElement("div");
|
|
1331
|
+
ue.className = `${c}-header`;
|
|
1332
|
+
const Me = document.createElement("span");
|
|
1333
|
+
Me.className = `${c}-title`, Me.textContent = "Edit screenshot";
|
|
1334
|
+
const Z = document.createElement("button");
|
|
1335
|
+
Z.className = `${c}-close-btn`, Z.setAttribute("aria-label", "Close"), Z.innerHTML = Re.close, Z.onclick = () => {
|
|
1336
|
+
ne(), i();
|
|
1337
|
+
}, ue.appendChild(Me), ue.appendChild(Z);
|
|
1338
|
+
const E = document.createElement("div");
|
|
1339
|
+
E.className = `${c}-canvas-wrap`;
|
|
1340
|
+
const j = document.createElement("img");
|
|
1341
|
+
j.className = `${c}-img`, j.alt = "Screenshot";
|
|
1342
|
+
const P = document.createElement("canvas");
|
|
1343
|
+
P.className = `${c}-canvas`, E.appendChild(j), E.appendChild(P);
|
|
1344
|
+
const ee = document.createElement("div");
|
|
1345
|
+
ee.className = `${c}-toolbar`;
|
|
1346
|
+
const O = document.createElement("div");
|
|
1347
|
+
O.className = `${c}-tools`;
|
|
1348
|
+
const He = {}, Et = ["select", "pen", "arrow", "rect", "text", "crop"], Ae = { select: "Select & Move", pen: "Pen", arrow: "Arrow", rect: "Rectangle", text: "Text", crop: "Crop" };
|
|
1349
|
+
for (const a of Et) {
|
|
1350
|
+
const p = document.createElement("button");
|
|
1351
|
+
p.className = `${c}-tool-btn${a === "rect" ? " active" : ""}`, p.setAttribute("aria-label", Ae[a]), p.title = Ae[a], p.innerHTML = Re[a], p.onclick = () => qe(a), He[a] = p, O.appendChild(p);
|
|
1352
|
+
}
|
|
1353
|
+
const De = document.createElement("div");
|
|
1354
|
+
De.className = `${c}-separator`, O.appendChild(De);
|
|
1355
|
+
const St = ["#FF3B30", "#FF9500", "#FFCC00", "#34C759", "#0091FF", "#AF52DE", "#FF2D55", "#000000", "#8E8E93"], he = document.createElement("div");
|
|
1356
|
+
he.className = `${c}-color-swatches`;
|
|
1357
|
+
const We = [];
|
|
1358
|
+
function Te(a) {
|
|
1359
|
+
We.forEach((p) => p.classList.toggle("active", p.dataset.color === a));
|
|
1360
|
+
}
|
|
1361
|
+
for (const a of St) {
|
|
1362
|
+
const p = document.createElement("button");
|
|
1363
|
+
p.className = `${c}-swatch${a === r ? " active" : ""}`, p.style.background = a, p.dataset.color = a, p.setAttribute("aria-label", `Color ${a}`), p.onclick = () => {
|
|
1364
|
+
r = a, F.value = a, Te(a), ye("color", a);
|
|
1365
|
+
}, We.push(p), he.appendChild(p);
|
|
1366
|
+
}
|
|
1367
|
+
const F = document.createElement("input");
|
|
1368
|
+
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, Te(""), ye("color", r);
|
|
1370
|
+
}, he.appendChild(F), O.appendChild(he);
|
|
1371
|
+
const Be = document.createElement("div");
|
|
1372
|
+
Be.className = `${c}-separator`, O.appendChild(Be);
|
|
1373
|
+
const ge = document.createElement("div");
|
|
1374
|
+
ge.className = `${c}-thickness-wrap`;
|
|
1375
|
+
const te = document.createElement("span");
|
|
1376
|
+
te.className = `${c}-thickness-label`, te.textContent = "3px";
|
|
1377
|
+
const U = document.createElement("input");
|
|
1378
|
+
U.type = "range", U.min = "1", U.max = "12", U.value = String(o), U.className = `${c}-thickness-slider`, U.setAttribute("aria-label", "Stroke thickness"), U.oninput = () => {
|
|
1379
|
+
o = parseInt(U.value, 10), te.textContent = `${o}px`, ye("width", o);
|
|
1380
|
+
}, ge.appendChild(U), ge.appendChild(te), O.appendChild(ge);
|
|
1381
|
+
const je = document.createElement("div");
|
|
1382
|
+
je.className = `${c}-separator`, O.appendChild(je);
|
|
1383
|
+
const G = document.createElement("button");
|
|
1384
|
+
G.className = `${c}-radius-btn`, G.setAttribute("aria-label", "Rounded corners"), G.title = "Rounded corners", G.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 9a6 6 0 0 1 6-6h6a6 6 0 0 1 6 6v6a6 6 0 0 1-6 6H9a6 6 0 0 1-6-6V9z"/></svg>', G.onclick = () => {
|
|
1385
|
+
l = l === 0 ? 12 : 0, G.classList.toggle("active", l > 0), ye("radius", l);
|
|
1386
|
+
}, O.appendChild(G);
|
|
1387
|
+
const Ge = document.createElement("div");
|
|
1388
|
+
Ge.className = `${c}-separator`, O.appendChild(Ge);
|
|
1389
|
+
const I = document.createElement("button");
|
|
1390
|
+
I.className = `${c}-undo-btn`, I.setAttribute("aria-label", "Undo"), I.title = "Undo", I.innerHTML = Re.undo, I.disabled = !0, I.onclick = () => {
|
|
1391
|
+
s.length > 0 && (s.pop(), I.disabled = s.length === 0, C = null, T());
|
|
1392
|
+
}, O.appendChild(I);
|
|
1393
|
+
const z = document.createElement("button");
|
|
1394
|
+
z.className = `${c}-btn-crop-apply`, z.textContent = "Apply crop", z.style.display = "none", z.onclick = Tt;
|
|
1395
|
+
const me = document.createElement("div");
|
|
1396
|
+
me.className = `${c}-actions`;
|
|
1397
|
+
const fe = document.createElement("button");
|
|
1398
|
+
fe.className = `${c}-btn-cancel`, fe.textContent = "Cancel", fe.onclick = () => {
|
|
1399
|
+
ne(), i();
|
|
1400
|
+
};
|
|
1401
|
+
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(E), X.appendChild(ee), ce.appendChild(X), document.body.appendChild(ce), V = ce;
|
|
1403
|
+
function qe(a) {
|
|
1404
|
+
n = a;
|
|
1405
|
+
for (const [p, f] of Object.entries(He))
|
|
1406
|
+
f.classList.toggle("active", p === a);
|
|
1407
|
+
a !== "crop" && (M = null, D = null, z.style.display = "none"), a !== "select" && (C = null), E.classList.toggle("select-mode", a === "select"), E.classList.remove("select-mode-moving"), ie(), T();
|
|
1408
|
+
}
|
|
1409
|
+
function ye(a, p) {
|
|
1410
|
+
if (C === null || C >= s.length) return;
|
|
1411
|
+
const f = s[C];
|
|
1412
|
+
a === "color" ? f.color = p : a === "width" && "width" in f ? f.width = p : a === "radius" && f.type === "rect" && (f.radius = p), T();
|
|
1413
|
+
}
|
|
1414
|
+
function Mt(a) {
|
|
1415
|
+
r = a.color, F.value = a.color, Te(a.color), "width" in a && (o = 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
|
+
}
|
|
1417
|
+
function Ie(a, p) {
|
|
1418
|
+
const f = E.getBoundingClientRect();
|
|
1419
|
+
return {
|
|
1420
|
+
x: Math.round((a - f.left - w) / g),
|
|
1421
|
+
y: Math.round((p - f.top - y) / g)
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
function Ye() {
|
|
1425
|
+
if (!d || !h) return;
|
|
1426
|
+
const a = E.clientWidth - 32, p = E.clientHeight - 32;
|
|
1427
|
+
g = Math.min(a / d, p / h, 1), w = (E.clientWidth - d * g) / 2, y = (E.clientHeight - h * g) / 2, j.style.width = `${d * g}px`, j.style.height = `${h * g}px`, j.style.marginLeft = `${w}px`, j.style.marginTop = `${y}px`, P.width = E.clientWidth, P.height = E.clientHeight, T();
|
|
1428
|
+
}
|
|
1429
|
+
function Ke() {
|
|
1430
|
+
const a = new Image();
|
|
1431
|
+
a.onload = () => {
|
|
1432
|
+
d = a.naturalWidth, h = a.naturalHeight, j.src = u, Ye();
|
|
1433
|
+
}, a.src = u;
|
|
1434
|
+
}
|
|
1435
|
+
function T() {
|
|
1436
|
+
const a = P.getContext("2d");
|
|
1437
|
+
if (a) {
|
|
1438
|
+
if (a.clearRect(0, 0, P.width, P.height), a.save(), a.translate(w, y), a.scale(g, g), s.forEach((p, f) => {
|
|
1439
|
+
Ze(a, p), f === C && di(a, p);
|
|
1440
|
+
}), S && b.length >= 4 && n === "pen") {
|
|
1441
|
+
a.strokeStyle = r, a.lineWidth = o, a.lineCap = "round", a.lineJoin = "round", a.beginPath(), a.moveTo(b[0], b[1]);
|
|
1442
|
+
for (let p = 2; p < b.length; p += 2) a.lineTo(b[p], b[p + 1]);
|
|
1443
|
+
a.stroke();
|
|
1444
|
+
}
|
|
1445
|
+
if (a.restore(), n === "crop" && M) {
|
|
1446
|
+
a.fillStyle = "rgba(0,0,0,0.4)", a.fillRect(0, 0, P.width, P.height);
|
|
1447
|
+
const p = w + M.x * g, f = y + M.y * g, m = M.w * g, x = M.h * g;
|
|
1448
|
+
a.clearRect(p, f, m, x), a.strokeStyle = "#0091FF", a.lineWidth = 2, a.strokeRect(p, f, m, x), z.style.display = "";
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
function Tt() {
|
|
1453
|
+
if (!M || M.w < 10 || M.h < 10) return;
|
|
1454
|
+
const a = new Image();
|
|
1455
|
+
a.onload = () => {
|
|
1456
|
+
const p = document.createElement("canvas");
|
|
1457
|
+
p.width = M.w, p.height = M.h;
|
|
1458
|
+
const f = p.getContext("2d");
|
|
1459
|
+
f && (f.drawImage(a, M.x, M.y, M.w, M.h, 0, 0, M.w, M.h), u = p.toDataURL("image/png"), s = [], I.disabled = !0, C = null, M = null, D = null, z.style.display = "none", qe("rect"), Ke());
|
|
1460
|
+
}, a.src = u;
|
|
1461
|
+
}
|
|
1462
|
+
function ie() {
|
|
1463
|
+
K && (K.remove(), K = null);
|
|
1464
|
+
}
|
|
1465
|
+
function It(a, p) {
|
|
1466
|
+
ie();
|
|
1467
|
+
const f = document.createElement("div");
|
|
1468
|
+
f.className = `${c}-text-overlay`, f.style.left = `${a * g + w}px`, f.style.top = `${p * g + y}px`;
|
|
1469
|
+
const m = document.createElement("input");
|
|
1470
|
+
m.type = "text", m.className = `${c}-text-input`, m.placeholder = "Text...";
|
|
1471
|
+
const x = document.createElement("button");
|
|
1472
|
+
x.className = `${c}-text-ok`, x.textContent = "Add";
|
|
1473
|
+
const H = () => {
|
|
1474
|
+
const q = m.value.trim();
|
|
1475
|
+
q && (s.push({ type: "text", x: a, y: p, text: q, color: r }), I.disabled = !1, T()), ie();
|
|
1476
|
+
};
|
|
1477
|
+
m.onkeydown = (q) => {
|
|
1478
|
+
q.key === "Enter" && H(), q.key === "Escape" && ie();
|
|
1479
|
+
}, x.onclick = H, f.appendChild(m), f.appendChild(x), E.appendChild(f), K = f, m.focus();
|
|
1480
|
+
}
|
|
1481
|
+
E.onmousedown = (a) => {
|
|
1482
|
+
const { x: p, y: f } = Ie(a.clientX, a.clientY);
|
|
1483
|
+
if (n === "select") {
|
|
1484
|
+
let m = -1;
|
|
1485
|
+
for (let x = s.length - 1; x >= 0; x--)
|
|
1486
|
+
if (ai(s[x], p, f, 8)) {
|
|
1487
|
+
m = x;
|
|
1488
|
+
break;
|
|
1489
|
+
}
|
|
1490
|
+
m >= 0 ? (C = m, N = { x: p, y: f }, Mt(s[m]), E.classList.add("select-mode-moving")) : C = null, T();
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
if (n === "crop") {
|
|
1494
|
+
D = { x: p, y: f }, M = null, z.style.display = "none";
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
K || (C = null, n === "pen" ? (S = !0, b = [p, f]) : n === "arrow" ? v = { x: p, y: f } : n === "rect" ? k = { x: p, y: f } : n === "text" && It(p, f));
|
|
1498
|
+
}, E.onmousemove = (a) => {
|
|
1499
|
+
const { x: p, y: f } = Ie(a.clientX, a.clientY);
|
|
1500
|
+
if (n === "select" && N && C !== null) {
|
|
1501
|
+
const m = p - N.x, x = f - N.y;
|
|
1502
|
+
(Math.abs(m) > 1 || Math.abs(x) > 1) && (li(s[C], m, x), N = { x: p, y: f }, T());
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
if (n === "crop" && D) {
|
|
1506
|
+
const m = Math.min(D.x, p), x = Math.min(D.y, f);
|
|
1507
|
+
M = { x: m, y: x, w: Math.max(20, Math.abs(p - D.x)), h: Math.max(20, Math.abs(f - D.y)) }, T();
|
|
1508
|
+
} else if (S && n === "pen")
|
|
1509
|
+
b.push(p, f), T();
|
|
1510
|
+
else if (n === "rect" && k) {
|
|
1511
|
+
T();
|
|
1512
|
+
const m = P.getContext("2d");
|
|
1513
|
+
if (m) {
|
|
1514
|
+
m.save(), m.translate(w, y), m.scale(g, g), m.strokeStyle = r, m.lineWidth = o, m.lineCap = "round", m.lineJoin = "round";
|
|
1515
|
+
const x = Math.min(k.x, p), H = Math.min(k.y, f), q = Math.abs(p - k.x), Ve = Math.abs(f - k.y);
|
|
1516
|
+
l > 0 ? ft(m, x, H, q, Ve, l) : m.strokeRect(x, H, q, Ve), m.restore();
|
|
1517
|
+
}
|
|
1518
|
+
} else if (n === "arrow" && v) {
|
|
1519
|
+
T();
|
|
1520
|
+
const m = P.getContext("2d");
|
|
1521
|
+
if (m) {
|
|
1522
|
+
m.save(), m.translate(w, y), m.scale(g, g), m.strokeStyle = r, m.fillStyle = r, m.lineWidth = o, m.lineCap = "round", m.lineJoin = "round", m.beginPath(), m.moveTo(v.x, v.y), m.lineTo(p, f), m.stroke();
|
|
1523
|
+
const x = 10, H = Math.atan2(f - v.y, p - v.x);
|
|
1524
|
+
m.beginPath(), m.moveTo(p, f), m.lineTo(p - x * Math.cos(H - 0.4), f - x * Math.sin(H - 0.4)), m.lineTo(p - x * Math.cos(H + 0.4), f - x * Math.sin(H + 0.4)), m.closePath(), m.fill(), m.restore();
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
}, E.onmouseup = (a) => {
|
|
1528
|
+
const { x: p, y: f } = Ie(a.clientX, a.clientY);
|
|
1529
|
+
if (n === "select") {
|
|
1530
|
+
N = null, E.classList.remove("select-mode-moving");
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
if (n === "crop") {
|
|
1534
|
+
D = null;
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
if (n === "pen" && S)
|
|
1538
|
+
S = !1, b.length >= 4 && (s.push({ type: "pen", points: [...b], color: r, width: o }), I.disabled = !1, b = []);
|
|
1539
|
+
else if (n === "arrow" && v)
|
|
1540
|
+
s.push({ type: "arrow", x1: v.x, y1: v.y, x2: p, y2: f, color: r, width: o }), I.disabled = !1, v = null;
|
|
1541
|
+
else if (n === "rect" && k) {
|
|
1542
|
+
const m = Math.min(k.x, p), x = Math.min(k.y, f);
|
|
1543
|
+
s.push({ type: "rect", x: m, y: x, w: Math.abs(p - k.x), h: Math.abs(f - k.y), color: r, width: o, radius: l }), I.disabled = !1, k = null;
|
|
1544
|
+
}
|
|
1545
|
+
T();
|
|
1546
|
+
}, E.onmouseleave = (a) => {
|
|
1547
|
+
if (n === "select" && N) {
|
|
1548
|
+
N = null, E.classList.remove("select-mode-moving");
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
E.onmouseup(a);
|
|
1552
|
+
};
|
|
1553
|
+
function Lt() {
|
|
1554
|
+
const a = new Image();
|
|
1555
|
+
a.onload = () => {
|
|
1556
|
+
const p = document.createElement("canvas");
|
|
1557
|
+
p.width = a.naturalWidth, p.height = a.naturalHeight;
|
|
1558
|
+
const f = p.getContext("2d");
|
|
1559
|
+
if (!f) return;
|
|
1560
|
+
f.drawImage(a, 0, 0), s.forEach((x) => Ze(f, x));
|
|
1561
|
+
const m = p.toDataURL("image/png");
|
|
1562
|
+
ne(), t(m);
|
|
1563
|
+
}, a.onerror = () => {
|
|
1564
|
+
ne(), t(u);
|
|
1565
|
+
}, a.src = u;
|
|
1566
|
+
}
|
|
1567
|
+
ae = (a) => {
|
|
1568
|
+
a.key === "Escape" ? K ? ie() : n === "crop" && M ? (M = null, z.style.display = "none", T()) : C !== null ? (C = null, T()) : (ne(), i()) : a.key === "z" && (a.ctrlKey || a.metaKey) && !a.shiftKey ? (a.preventDefault(), s.length > 0 && (s.pop(), I.disabled = s.length === 0, C = null, T())) : (a.key === "Delete" || a.key === "Backspace") && C !== null && !K && (a.preventDefault(), s.splice(C, 1), I.disabled = s.length === 0, C = null, T());
|
|
1569
|
+
}, document.addEventListener("keydown", ae), new ResizeObserver(() => {
|
|
1570
|
+
d && h && Ye();
|
|
1571
|
+
}).observe(E), Ke();
|
|
1572
|
+
}
|
|
1573
|
+
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
|
+
<defs>
|
|
1575
|
+
<linearGradient id="sw-preview-grad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
1576
|
+
<stop offset="0%" stop-color="#0091FF"/>
|
|
1577
|
+
<stop offset="33%" stop-color="#FF02F0"/>
|
|
1578
|
+
<stop offset="66%" stop-color="#F76808"/>
|
|
1579
|
+
<stop offset="100%" stop-color="#6647F0"/>
|
|
1580
|
+
</linearGradient>
|
|
1581
|
+
<linearGradient id="sw-preview-center" x1="81" y1="96" x2="113" y2="130" gradientUnits="userSpaceOnUse">
|
|
1582
|
+
<stop stop-color="white"/>
|
|
1583
|
+
<stop offset="0.88" stop-color="white" stop-opacity="0.3"/>
|
|
1584
|
+
</linearGradient>
|
|
1585
|
+
</defs>
|
|
1586
|
+
<path d="M100 0C86.1929 0 75 11.1929 75 25V39.2893L65.033 29.3223C55.2699 19.5592 39.4408 19.5592 29.6777 29.3223C19.9146 39.0854 19.9146 54.9146 29.6777 64.6777L40 75H25C11.1929 75 0 86.1929 0 100C0 113.807 11.1929 125 25 125H39L29.2563 134.744C19.4932 144.507 19.4932 160.336 29.2563 170.099C39.0194 179.862 54.8485 179.862 64.6116 170.099L75 159.711V175C75 188.807 86.1929 200 100 200C113.807 200 125 188.807 125 175V160L135.744 170.744C145.507 180.507 161.336 180.507 171.099 170.744C180.862 160.981 180.862 145.151 171.099 135.388L160.711 125H175C188.807 125 200 113.807 200 100C200 86.1929 188.807 75 175 75H159.711L170.678 64.033C180.441 54.2699 180.441 38.4408 170.678 28.6777C160.915 18.9146 145.085 18.9146 135.322 28.6777L125 39V25C125 11.1929 113.807 0 100 0Z" fill="url(#sw-preview-grad)"/>
|
|
1587
|
+
<circle cx="100" cy="100" r="30" fill="url(#sw-preview-center)"/>
|
|
1588
|
+
</svg>`;
|
|
1589
|
+
let _ = null, Y = null;
|
|
1590
|
+
const $ = [];
|
|
1591
|
+
let le = !1;
|
|
1592
|
+
const nt = "supportwire-message-preview-styles";
|
|
1593
|
+
function ci() {
|
|
1594
|
+
if (document.getElementById(nt)) return;
|
|
1595
|
+
const e = document.createElement("style");
|
|
1596
|
+
e.id = nt, e.textContent = `
|
|
1597
|
+
.sw-preview-stack {
|
|
1598
|
+
position: fixed;
|
|
1599
|
+
z-index: 999997;
|
|
1600
|
+
width: 320px;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
.sw-preview-dismiss {
|
|
1604
|
+
position: absolute;
|
|
1605
|
+
bottom: 100%;
|
|
1606
|
+
right: 0;
|
|
1607
|
+
width: 24px;
|
|
1608
|
+
height: 24px;
|
|
1609
|
+
margin-bottom: 4px;
|
|
1610
|
+
border: none;
|
|
1611
|
+
border-radius: 50%;
|
|
1612
|
+
font-size: 15px;
|
|
1613
|
+
line-height: 1;
|
|
1614
|
+
cursor: pointer;
|
|
1615
|
+
display: flex;
|
|
1616
|
+
align-items: center;
|
|
1617
|
+
justify-content: center;
|
|
1618
|
+
opacity: 0;
|
|
1619
|
+
transition: opacity 150ms ease, background 150ms ease;
|
|
1620
|
+
pointer-events: auto;
|
|
1621
|
+
z-index: 10;
|
|
1622
|
+
}
|
|
1623
|
+
.sw-preview-dismiss.sw-dismiss-dark {
|
|
1624
|
+
background: rgba(255, 255, 255, 0.1);
|
|
1625
|
+
color: rgba(255, 255, 255, 0.6);
|
|
1626
|
+
}
|
|
1627
|
+
.sw-preview-dismiss.sw-dismiss-dark:hover {
|
|
1628
|
+
background: rgba(255, 255, 255, 0.18);
|
|
1629
|
+
color: rgba(255, 255, 255, 0.9);
|
|
1630
|
+
}
|
|
1631
|
+
.sw-preview-dismiss.sw-dismiss-light {
|
|
1632
|
+
background: rgba(0, 0, 0, 0.06);
|
|
1633
|
+
color: rgba(0, 0, 0, 0.4);
|
|
1634
|
+
}
|
|
1635
|
+
.sw-preview-dismiss.sw-dismiss-light:hover {
|
|
1636
|
+
background: rgba(0, 0, 0, 0.1);
|
|
1637
|
+
color: rgba(0, 0, 0, 0.7);
|
|
1638
|
+
}
|
|
1639
|
+
.sw-preview-dismiss:active {
|
|
1640
|
+
transform: scale(0.95);
|
|
1641
|
+
}
|
|
1642
|
+
.sw-preview-dismiss:focus-visible {
|
|
1643
|
+
outline: 2px solid #0091FF;
|
|
1644
|
+
outline-offset: 1px;
|
|
1645
|
+
opacity: 1;
|
|
1646
|
+
}
|
|
1647
|
+
.sw-preview-stack:hover .sw-preview-dismiss {
|
|
1648
|
+
opacity: 1;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
.sw-preview-card {
|
|
1652
|
+
position: absolute;
|
|
1653
|
+
bottom: 0;
|
|
1654
|
+
left: 0;
|
|
1655
|
+
width: 100%;
|
|
1656
|
+
border-radius: 16px;
|
|
1657
|
+
padding: 12px 14px;
|
|
1658
|
+
cursor: pointer;
|
|
1659
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
1660
|
+
box-sizing: border-box;
|
|
1661
|
+
pointer-events: auto;
|
|
1662
|
+
transition: transform 200ms cubic-bezier(0.32, 0.72, 0, 1), opacity 200ms cubic-bezier(0.32, 0.72, 0, 1);
|
|
1663
|
+
transform-origin: bottom center;
|
|
1664
|
+
}
|
|
1665
|
+
.sw-preview-card:active {
|
|
1666
|
+
transform: scale(0.97) !important;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
.sw-preview-card.sw-card-dark {
|
|
1670
|
+
background: #1a1a1a;
|
|
1671
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 4px rgba(0, 0, 0, 0.2);
|
|
1672
|
+
}
|
|
1673
|
+
.sw-preview-card.sw-card-light {
|
|
1674
|
+
background: #ffffff;
|
|
1675
|
+
border: 1px solid rgba(0, 0, 0, 0.08);
|
|
1676
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
.sw-preview-header {
|
|
1680
|
+
display: flex;
|
|
1681
|
+
align-items: center;
|
|
1682
|
+
gap: 8px;
|
|
1683
|
+
margin-bottom: 6px;
|
|
1684
|
+
}
|
|
1685
|
+
.sw-preview-logo {
|
|
1686
|
+
flex-shrink: 0;
|
|
1687
|
+
width: 20px;
|
|
1688
|
+
height: 20px;
|
|
1689
|
+
display: flex;
|
|
1690
|
+
align-items: center;
|
|
1691
|
+
justify-content: center;
|
|
1692
|
+
}
|
|
1693
|
+
.sw-preview-meta {
|
|
1694
|
+
font-size: 11px;
|
|
1695
|
+
line-height: 1.2;
|
|
1696
|
+
flex: 1;
|
|
1697
|
+
min-width: 0;
|
|
1698
|
+
overflow: hidden;
|
|
1699
|
+
text-overflow: ellipsis;
|
|
1700
|
+
white-space: nowrap;
|
|
1701
|
+
}
|
|
1702
|
+
.sw-card-dark .sw-preview-meta { color: rgba(255, 255, 255, 0.5); }
|
|
1703
|
+
.sw-card-light .sw-preview-meta { color: rgba(0, 0, 0, 0.45); }
|
|
1704
|
+
|
|
1705
|
+
.sw-preview-body {
|
|
1706
|
+
font-size: 13px;
|
|
1707
|
+
line-height: 1.4;
|
|
1708
|
+
display: -webkit-box;
|
|
1709
|
+
-webkit-line-clamp: 2;
|
|
1710
|
+
-webkit-box-orient: vertical;
|
|
1711
|
+
overflow: hidden;
|
|
1712
|
+
word-break: break-word;
|
|
1713
|
+
}
|
|
1714
|
+
.sw-card-dark .sw-preview-body { color: rgba(255, 255, 255, 0.9); }
|
|
1715
|
+
.sw-card-light .sw-preview-body { color: rgba(0, 0, 0, 0.85); }
|
|
1716
|
+
|
|
1717
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1718
|
+
.sw-preview-card {
|
|
1719
|
+
transition: opacity 200ms ease-out !important;
|
|
1720
|
+
}
|
|
1721
|
+
.sw-preview-dismiss {
|
|
1722
|
+
transition: opacity 150ms ease-out !important;
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
`, document.head.appendChild(e);
|
|
1726
|
+
}
|
|
1727
|
+
function Ce() {
|
|
1728
|
+
if (!(!_ || $.length === 0))
|
|
1729
|
+
if (le) {
|
|
1730
|
+
let e = 0;
|
|
1731
|
+
for (let t = 0; t < $.length; t++) {
|
|
1732
|
+
const { el: i, height: n } = $[t];
|
|
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 += n + it;
|
|
1734
|
+
}
|
|
1735
|
+
_.style.height = `${e - it}px`;
|
|
1736
|
+
} else {
|
|
1737
|
+
for (let e = 0; e < $.length; e++) {
|
|
1738
|
+
const { el: t } = $[e];
|
|
1739
|
+
t.style.zIndex = String(Pe + 1 - e), t.style.transform = `translateY(-${e * rt}px) scale(${1 - e * 0.05})`, t.style.opacity = t.dataset.visible === "true" ? "1" : "0";
|
|
1740
|
+
}
|
|
1741
|
+
_.style.height = `${$[0].height + ($.length - 1) * rt}px`;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
function ui(e) {
|
|
1745
|
+
if (!Number.isFinite(e) || e <= 0) return "just now";
|
|
1746
|
+
const t = Date.now(), i = e < 1e12 ? e * 1e3 : e, n = Math.max(0, t - i), r = Math.floor(n / 1e3);
|
|
1747
|
+
if (r < 60) return "just now";
|
|
1748
|
+
const o = Math.floor(r / 60);
|
|
1749
|
+
if (o < 60) return `${o}m ago`;
|
|
1750
|
+
const l = Math.floor(o / 60);
|
|
1751
|
+
return l < 24 ? `${l}h ago` : `${Math.floor(l / 24)}d ago`;
|
|
1752
|
+
}
|
|
1753
|
+
function hi(e, t) {
|
|
1754
|
+
if (_) return _;
|
|
1755
|
+
const i = document.createElement("div");
|
|
1756
|
+
i.className = "sw-preview-stack";
|
|
1757
|
+
const n = e.startsWith("bottom"), r = e.endsWith("right"), o = 20, l = 48, s = 8;
|
|
1758
|
+
return n ? i.style.bottom = `${o + l + s}px` : i.style.top = `${o + l + s}px`, r ? i.style.right = `${o}px` : i.style.left = `${o}px`, i.addEventListener("mouseenter", () => {
|
|
1759
|
+
le = !0, Ce();
|
|
1760
|
+
}), i.addEventListener("mouseleave", () => {
|
|
1761
|
+
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", (u) => {
|
|
1763
|
+
u.stopPropagation(), ke();
|
|
1764
|
+
}), i.appendChild(Y), document.body.appendChild(i), _ = i, i;
|
|
1765
|
+
}
|
|
1766
|
+
function gi(e, t, i, n, r, o) {
|
|
1767
|
+
ci();
|
|
1768
|
+
const l = hi(n, r);
|
|
1769
|
+
$.length >= Pe && $.pop().el.remove();
|
|
1770
|
+
const s = document.createElement("div");
|
|
1771
|
+
s.className = `sw-preview-card sw-card-${r}`, s.dataset.visible = "false";
|
|
1772
|
+
const u = document.createElement("div");
|
|
1773
|
+
u.className = "sw-preview-header";
|
|
1774
|
+
const d = document.createElement("div");
|
|
1775
|
+
d.className = "sw-preview-logo", d.innerHTML = pi;
|
|
1776
|
+
const h = document.createElement("div");
|
|
1777
|
+
h.className = "sw-preview-meta", h.textContent = `${t || "Support"} · ${ui(i)}`, u.appendChild(d), u.appendChild(h);
|
|
1778
|
+
const g = document.createElement("div");
|
|
1779
|
+
g.className = "sw-preview-body", g.textContent = e, s.appendChild(u), s.appendChild(g), s.addEventListener("click", () => {
|
|
1780
|
+
ke(!0), o();
|
|
1781
|
+
}), l.appendChild(s);
|
|
1782
|
+
const w = s.offsetHeight;
|
|
1783
|
+
$.unshift({ el: s, height: w }), Ce(), requestAnimationFrame(() => {
|
|
1784
|
+
requestAnimationFrame(() => {
|
|
1785
|
+
s.dataset.visible = "true", Ce();
|
|
1786
|
+
});
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
function ke(e) {
|
|
1790
|
+
if (e) {
|
|
1791
|
+
for (const i of $) i.el.remove();
|
|
1792
|
+
$.length = 0, _ && (_.remove(), _ = null), Y = null, le = !1;
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1795
|
+
const t = [...$];
|
|
1796
|
+
$.length = 0;
|
|
1797
|
+
for (const i of t) {
|
|
1798
|
+
i.el.dataset.visible = "false", i.el.style.opacity = "0";
|
|
1799
|
+
const n = () => {
|
|
1800
|
+
i.el.removeEventListener("transitionend", n), i.el.remove();
|
|
1801
|
+
};
|
|
1802
|
+
i.el.addEventListener("transitionend", n), setTimeout(() => i.el.remove(), 300);
|
|
1803
|
+
}
|
|
1804
|
+
if (_) {
|
|
1805
|
+
const i = _;
|
|
1806
|
+
_ = null, Y = null, le = !1, setTimeout(() => i.remove(), 350);
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
const yt = "supportwire-event-rule-executions";
|
|
1810
|
+
function bt() {
|
|
1811
|
+
try {
|
|
1812
|
+
const e = localStorage.getItem(yt);
|
|
1813
|
+
return e ? JSON.parse(e) : {};
|
|
1814
|
+
} catch {
|
|
1815
|
+
return {};
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
function Ue(e) {
|
|
1819
|
+
return bt()[e] || 0;
|
|
1820
|
+
}
|
|
1821
|
+
function mi(e) {
|
|
1822
|
+
try {
|
|
1823
|
+
const t = bt();
|
|
1824
|
+
t[e] = (t[e] || 0) + 1, localStorage.setItem(yt, JSON.stringify(t));
|
|
1825
|
+
} catch {
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
function fi(e) {
|
|
1829
|
+
return e.max_executions == null || e.max_executions <= 0 ? !1 : Ue(e.id) >= e.max_executions;
|
|
1830
|
+
}
|
|
1831
|
+
function wi(e, t) {
|
|
1832
|
+
try {
|
|
1833
|
+
const i = (o) => o.replace(/\/+$/, "");
|
|
1834
|
+
if (!t.includes("*"))
|
|
1835
|
+
return i(e) === i(t);
|
|
1836
|
+
const n = t.split("*").map((o) => {
|
|
1837
|
+
let l = "";
|
|
1838
|
+
for (const s of o)
|
|
1839
|
+
"-/\\^$*+?.()|[]{}".indexOf(s) !== -1 && (l += "\\"), l += s;
|
|
1840
|
+
return l;
|
|
1841
|
+
}), r = new RegExp("^" + n.join(".*") + "$");
|
|
1842
|
+
return r.test(e) || r.test(i(e));
|
|
1843
|
+
} catch {
|
|
1844
|
+
return !1;
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
function yi(e, t) {
|
|
1848
|
+
var i;
|
|
1849
|
+
const n = [];
|
|
1850
|
+
for (const r of e) {
|
|
1851
|
+
if (r.event_name !== "SW_PAGE_VIEW") continue;
|
|
1852
|
+
const o = (i = r.event_info) == null ? void 0 : i.url;
|
|
1853
|
+
if (o) {
|
|
1854
|
+
if (fi(r)) {
|
|
1855
|
+
Ue(r.id);
|
|
1856
|
+
continue;
|
|
1857
|
+
}
|
|
1858
|
+
wi(t, o) && n.push({
|
|
1859
|
+
ruleId: r.id,
|
|
1860
|
+
delay: r.delay,
|
|
1861
|
+
messagesToSend: r.messages_to_send
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
return n;
|
|
1866
|
+
}
|
|
1867
|
+
function bi(e, t) {
|
|
1868
|
+
var i;
|
|
1869
|
+
for (const h of e)
|
|
1870
|
+
(i = h.event_info) != null && i.url, h.max_executions != null && String(h.max_executions), Ue(h.id);
|
|
1871
|
+
const n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
1872
|
+
let o = "";
|
|
1873
|
+
function l() {
|
|
1874
|
+
const h = window.location.href;
|
|
1875
|
+
if (h === o) return;
|
|
1876
|
+
o = h;
|
|
1877
|
+
const g = yi(e, h);
|
|
1878
|
+
for (const w of g) {
|
|
1879
|
+
if (r.has(w.ruleId))
|
|
1880
|
+
continue;
|
|
1881
|
+
r.add(w.ruleId);
|
|
1882
|
+
const y = (w.delay || 0) * 1e3, S = setTimeout(() => {
|
|
1883
|
+
n.delete(S), mi(w.ruleId), t(w);
|
|
1884
|
+
}, y);
|
|
1885
|
+
n.add(S);
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
const s = history.pushState.bind(history), u = history.replaceState.bind(history);
|
|
1889
|
+
history.pushState = function(...h) {
|
|
1890
|
+
s(...h), l();
|
|
1891
|
+
}, history.replaceState = function(...h) {
|
|
1892
|
+
u(...h), l();
|
|
1893
|
+
};
|
|
1894
|
+
const d = () => l();
|
|
1895
|
+
return window.addEventListener("popstate", d), l(), () => {
|
|
1896
|
+
for (const h of n) clearTimeout(h);
|
|
1897
|
+
n.clear(), history.pushState = s, history.replaceState = u, window.removeEventListener("popstate", d);
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
const xi = "supportwire", de = (e, t) => `${xi}-${t}-${e}`, _e = (e, t) => {
|
|
1901
|
+
try {
|
|
1902
|
+
t ? localStorage.setItem(de(e, "open"), "1") : localStorage.removeItem(de(e, "open"));
|
|
1903
|
+
} catch {
|
|
1904
|
+
}
|
|
1905
|
+
}, vi = (e) => {
|
|
1906
|
+
try {
|
|
1907
|
+
return localStorage.getItem(de(e, "open")) === "1";
|
|
1908
|
+
} catch {
|
|
1909
|
+
return !1;
|
|
1910
|
+
}
|
|
1911
|
+
}, Ci = (e, t) => {
|
|
1912
|
+
try {
|
|
1913
|
+
localStorage.setItem(de(e, "widget-size"), JSON.stringify(t));
|
|
1914
|
+
} catch {
|
|
1915
|
+
}
|
|
1916
|
+
}, ki = (e) => {
|
|
1917
|
+
try {
|
|
1918
|
+
const t = localStorage.getItem(de(e, "widget-size"));
|
|
1919
|
+
return t ? JSON.parse(t) : null;
|
|
1920
|
+
} catch {
|
|
1921
|
+
return null;
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
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, ot = 1e3, xe = 20;
|
|
1925
|
+
function Ti(e) {
|
|
1926
|
+
if (typeof e == "number") return { vibrations: [{ duration: e }] };
|
|
1927
|
+
if (typeof e == "string") {
|
|
1928
|
+
let t = Ei[e];
|
|
1929
|
+
return t ? { vibrations: t.pattern.map((i) => A({}, i)) } : (console.warn(`[web-haptics] Unknown preset: "${e}"`), null);
|
|
1930
|
+
}
|
|
1931
|
+
if (Array.isArray(e)) {
|
|
1932
|
+
if (e.length === 0) return { vibrations: [] };
|
|
1933
|
+
if (typeof e[0] == "number") {
|
|
1934
|
+
let t = e, i = [];
|
|
1935
|
+
for (let n = 0; n < t.length; n += 2) {
|
|
1936
|
+
let r = n > 0 ? t[n - 1] : 0;
|
|
1937
|
+
i.push(Se(A({}, r > 0 && { delay: r }), { duration: t[n] }));
|
|
1938
|
+
}
|
|
1939
|
+
return { vibrations: i };
|
|
1940
|
+
}
|
|
1941
|
+
return { vibrations: e.map((t) => A({}, t)) };
|
|
1942
|
+
}
|
|
1943
|
+
return { vibrations: e.pattern.map((t) => A({}, t)) };
|
|
1944
|
+
}
|
|
1945
|
+
function Ii(e, t) {
|
|
1946
|
+
if (t >= 1) return [e];
|
|
1947
|
+
if (t <= 0) return [];
|
|
1948
|
+
let i = Math.max(1, Math.round(xe * t)), n = xe - i, r = [], o = e;
|
|
1949
|
+
for (; o >= xe; ) r.push(i), r.push(n), o -= xe;
|
|
1950
|
+
if (o > 0) {
|
|
1951
|
+
let l = Math.max(1, Math.round(o * t));
|
|
1952
|
+
r.push(l);
|
|
1953
|
+
let s = o - l;
|
|
1954
|
+
s > 0 && r.push(s);
|
|
1955
|
+
}
|
|
1956
|
+
return r;
|
|
1957
|
+
}
|
|
1958
|
+
function Li(e, t) {
|
|
1959
|
+
var i, n;
|
|
1960
|
+
let r = [];
|
|
1961
|
+
for (let o = 0; o < e.length; o++) {
|
|
1962
|
+
let l = e[o], s = Math.max(0, Math.min(1, (i = l.intensity) != null ? i : t)), u = (n = l.delay) != null ? n : 0;
|
|
1963
|
+
u > 0 && (r.length > 0 && r.length % 2 === 0 ? r[r.length - 1] += u : (r.length === 0 && r.push(0), r.push(u)));
|
|
1964
|
+
let d = Ii(l.duration, s);
|
|
1965
|
+
if (d.length === 0) {
|
|
1966
|
+
r.length > 0 && r.length % 2 === 0 ? r[r.length - 1] += l.duration : l.duration > 0 && (r.push(0), r.push(l.duration));
|
|
1967
|
+
continue;
|
|
1968
|
+
}
|
|
1969
|
+
for (let h of d) r.push(h);
|
|
1970
|
+
}
|
|
1971
|
+
return r;
|
|
1972
|
+
}
|
|
1973
|
+
var $i = 0, Q, Ri = (Q = class {
|
|
1974
|
+
constructor(e) {
|
|
1975
|
+
R(this, "hapticLabel", null), R(this, "domInitialized", !1), R(this, "instanceId"), R(this, "debug"), R(this, "showSwitch"), R(this, "rafId", null), R(this, "patternResolve", null), R(this, "audioCtx", null), R(this, "audioFilter", null), R(this, "audioGain", null), R(this, "audioBuffer", null);
|
|
1976
|
+
var t, i;
|
|
1977
|
+
this.instanceId = ++$i, this.debug = (t = e?.debug) != null ? t : !1, this.showSwitch = (i = e?.showSwitch) != null ? i : !1;
|
|
1978
|
+
}
|
|
1979
|
+
async trigger(e = [{ duration: 25, intensity: 0.7 }], t) {
|
|
1980
|
+
var i, n, r, o;
|
|
1981
|
+
let l = Ti(e);
|
|
1982
|
+
if (!l) return;
|
|
1983
|
+
let { vibrations: s } = l;
|
|
1984
|
+
if (s.length === 0) return;
|
|
1985
|
+
let u = Math.max(0, Math.min(1, (i = t?.intensity) != null ? i : 0.5));
|
|
1986
|
+
for (let d of s) if (d.duration > ot && (d.duration = ot), !Number.isFinite(d.duration) || d.duration < 0 || d.delay !== void 0 && (!Number.isFinite(d.delay) || d.delay < 0)) {
|
|
1987
|
+
console.warn("[web-haptics] Invalid vibration values. Durations and delays must be finite non-negative numbers.");
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
if (Q.isSupported && navigator.vibrate(Li(s, u)), !Q.isSupported || this.debug) {
|
|
1991
|
+
if (this.ensureDOM(), !this.hapticLabel) return;
|
|
1992
|
+
this.debug && await this.ensureAudio(), this.stopPattern();
|
|
1993
|
+
let d = ((r = (n = s[0]) == null ? void 0 : n.delay) != null ? r : 0) === 0;
|
|
1994
|
+
if (d && (this.hapticLabel.click(), this.debug && this.audioCtx)) {
|
|
1995
|
+
let h = Math.max(0, Math.min(1, (o = s[0].intensity) != null ? o : u));
|
|
1996
|
+
this.playClick(h);
|
|
1997
|
+
}
|
|
1998
|
+
await this.runPattern(s, u, d);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
cancel() {
|
|
2002
|
+
this.stopPattern(), Q.isSupported && navigator.vibrate(0);
|
|
2003
|
+
}
|
|
2004
|
+
destroy() {
|
|
2005
|
+
this.stopPattern(), this.hapticLabel && (this.hapticLabel.remove(), this.hapticLabel = null, this.domInitialized = !1), this.audioCtx && (this.audioCtx.close(), this.audioCtx = null, this.audioFilter = null, this.audioGain = null, this.audioBuffer = null);
|
|
2006
|
+
}
|
|
2007
|
+
setDebug(e) {
|
|
2008
|
+
this.debug = e, !e && this.audioCtx && (this.audioCtx.close(), this.audioCtx = null, this.audioFilter = null, this.audioGain = null, this.audioBuffer = null);
|
|
2009
|
+
}
|
|
2010
|
+
setShowSwitch(e) {
|
|
2011
|
+
if (this.showSwitch = e, this.hapticLabel) {
|
|
2012
|
+
let t = this.hapticLabel.querySelector("input");
|
|
2013
|
+
this.hapticLabel.style.display = e ? "" : "none", t && (t.style.display = e ? "" : "none");
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
stopPattern() {
|
|
2017
|
+
var e;
|
|
2018
|
+
this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), (e = this.patternResolve) == null || e.call(this), this.patternResolve = null;
|
|
2019
|
+
}
|
|
2020
|
+
runPattern(e, t, i) {
|
|
2021
|
+
return new Promise((n) => {
|
|
2022
|
+
var r, o;
|
|
2023
|
+
this.patternResolve = n;
|
|
2024
|
+
let l = [], s = 0;
|
|
2025
|
+
for (let w of e) {
|
|
2026
|
+
let y = Math.max(0, Math.min(1, (r = w.intensity) != null ? r : t)), S = (o = w.delay) != null ? o : 0;
|
|
2027
|
+
S > 0 && (s += S, l.push({ end: s, isOn: !1, intensity: 0 })), s += w.duration, l.push({ end: s, isOn: !0, intensity: y });
|
|
2028
|
+
}
|
|
2029
|
+
let u = s, d = 0, h = -1, g = (w) => {
|
|
2030
|
+
var y, S;
|
|
2031
|
+
d === 0 && (d = w);
|
|
2032
|
+
let b = w - d;
|
|
2033
|
+
if (b >= u) {
|
|
2034
|
+
this.rafId = null, this.patternResolve = null, n();
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
2037
|
+
let v = l[0];
|
|
2038
|
+
for (let k of l) if (b < k.end) {
|
|
2039
|
+
v = k;
|
|
2040
|
+
break;
|
|
2041
|
+
}
|
|
2042
|
+
if (v.isOn) {
|
|
2043
|
+
let k = Si + (1 - v.intensity) * Mi;
|
|
2044
|
+
h === -1 ? (h = w, i || ((y = this.hapticLabel) == null || y.click(), this.debug && this.audioCtx && this.playClick(v.intensity), i = !0)) : w - h >= k && ((S = this.hapticLabel) == null || S.click(), this.debug && this.audioCtx && this.playClick(v.intensity), h = w);
|
|
2045
|
+
}
|
|
2046
|
+
this.rafId = requestAnimationFrame(g);
|
|
2047
|
+
};
|
|
2048
|
+
this.rafId = requestAnimationFrame(g);
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
playClick(e) {
|
|
2052
|
+
if (!this.audioCtx || !this.audioFilter || !this.audioGain || !this.audioBuffer) return;
|
|
2053
|
+
let t = this.audioBuffer.getChannelData(0);
|
|
2054
|
+
for (let o = 0; o < t.length; o++) t[o] = (Math.random() * 2 - 1) * Math.exp(-o / 25);
|
|
2055
|
+
this.audioGain.gain.value = 0.5 * e;
|
|
2056
|
+
let i = 2e3 + e * 2e3, n = 1 + (Math.random() - 0.5) * 0.3;
|
|
2057
|
+
this.audioFilter.frequency.value = i * n;
|
|
2058
|
+
let r = this.audioCtx.createBufferSource();
|
|
2059
|
+
r.buffer = this.audioBuffer, r.connect(this.audioFilter), r.onended = () => r.disconnect(), r.start();
|
|
2060
|
+
}
|
|
2061
|
+
async ensureAudio() {
|
|
2062
|
+
var e;
|
|
2063
|
+
if (!this.audioCtx && typeof AudioContext < "u") {
|
|
2064
|
+
this.audioCtx = new AudioContext(), this.audioFilter = this.audioCtx.createBiquadFilter(), this.audioFilter.type = "bandpass", this.audioFilter.frequency.value = 4e3, this.audioFilter.Q.value = 8, this.audioGain = this.audioCtx.createGain(), this.audioFilter.connect(this.audioGain), this.audioGain.connect(this.audioCtx.destination);
|
|
2065
|
+
let t = 4e-3;
|
|
2066
|
+
this.audioBuffer = this.audioCtx.createBuffer(1, this.audioCtx.sampleRate * t, this.audioCtx.sampleRate);
|
|
2067
|
+
let i = this.audioBuffer.getChannelData(0);
|
|
2068
|
+
for (let n = 0; n < i.length; n++) i[n] = (Math.random() * 2 - 1) * Math.exp(-n / 25);
|
|
2069
|
+
}
|
|
2070
|
+
((e = this.audioCtx) == null ? void 0 : e.state) === "suspended" && await this.audioCtx.resume();
|
|
2071
|
+
}
|
|
2072
|
+
ensureDOM() {
|
|
2073
|
+
if (this.domInitialized || typeof document > "u") return;
|
|
2074
|
+
let e = `web-haptics-${this.instanceId}`, t = document.createElement("label");
|
|
2075
|
+
t.setAttribute("for", e), t.textContent = "Haptic feedback", t.style.position = "fixed", t.style.bottom = "10px", t.style.left = "10px", t.style.padding = "5px 10px", t.style.backgroundColor = "rgba(0, 0, 0, 0.7)", t.style.color = "white", t.style.fontFamily = "sans-serif", t.style.fontSize = "14px", t.style.borderRadius = "4px", t.style.zIndex = "9999", t.style.userSelect = "none", this.hapticLabel = t;
|
|
2076
|
+
let i = document.createElement("input");
|
|
2077
|
+
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
|
+
}
|
|
2079
|
+
}, R(Q, "isSupported", typeof navigator < "u" && typeof navigator.vibrate == "function"), Q);
|
|
2080
|
+
const oe = new Ri(), xt = class ve {
|
|
2081
|
+
constructor(t) {
|
|
2082
|
+
var i, n, r;
|
|
2083
|
+
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
|
+
throw new Error("widgetSlug is required in widget config");
|
|
2085
|
+
this.config = {
|
|
2086
|
+
widgetSlug: t.widgetSlug,
|
|
2087
|
+
appUrl: t.appUrl,
|
|
2088
|
+
selector: t.selector,
|
|
2089
|
+
theme: t.theme || "light",
|
|
2090
|
+
triggerPosition: t.triggerPosition || "bottom-right",
|
|
2091
|
+
widgetType: t.widgetType || "popup",
|
|
2092
|
+
userToken: t.userToken || "",
|
|
2093
|
+
userEmail: t.userEmail || "",
|
|
2094
|
+
userExternalUserId: t.userExternalUserId || "",
|
|
2095
|
+
userSignature: t.userSignature || "",
|
|
2096
|
+
userData: (i = t.userData) != null ? i : {},
|
|
2097
|
+
hideOnLaunch: (n = t.hideOnLaunch) != null ? n : !1,
|
|
2098
|
+
enableScreenshot: (r = t.enableScreenshot) != null ? r : !1,
|
|
2099
|
+
onOpen: t.onOpen || (() => {
|
|
2100
|
+
}),
|
|
2101
|
+
onClose: t.onClose || (() => {
|
|
2102
|
+
}),
|
|
2103
|
+
onError: t.onError || ((o) => console.error("SupportWireWidget error:", o))
|
|
2104
|
+
}, this.iframeId = Ft(), this.widgetUrl = this.buildWidgetUrl(), ve.instances.set(this.iframeId, this), this.init();
|
|
2105
|
+
}
|
|
2106
|
+
updateDocumentTitle(t) {
|
|
2107
|
+
t > 0 && document.hidden ? (document.title = `(${t}) ${document.title.replace(/^\(\d+\) /, "")}`, this.titleModified = !0) : this.titleModified && (document.title = document.title.replace(/^\(\d+\) /, ""), this.titleModified = !1);
|
|
2108
|
+
}
|
|
2109
|
+
/**
|
|
2110
|
+
* Gets the localStorage key for unread count
|
|
2111
|
+
*/
|
|
2112
|
+
getUnreadCountKey() {
|
|
2113
|
+
return `supportwire-unread-count-${this.config.widgetSlug}`;
|
|
2114
|
+
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Loads unread count from localStorage
|
|
2117
|
+
*/
|
|
2118
|
+
loadUnreadCountFromStorage() {
|
|
2119
|
+
if (typeof window > "u")
|
|
2120
|
+
return 0;
|
|
2121
|
+
try {
|
|
2122
|
+
const t = this.getUnreadCountKey(), i = localStorage.getItem(t);
|
|
2123
|
+
if (i) {
|
|
2124
|
+
const n = parseInt(i, 10);
|
|
2125
|
+
return isNaN(n) ? 0 : n;
|
|
2126
|
+
}
|
|
2127
|
+
} catch (t) {
|
|
2128
|
+
console.error("Failed to load unread count from localStorage:", t);
|
|
2129
|
+
}
|
|
2130
|
+
return 0;
|
|
2131
|
+
}
|
|
2132
|
+
/**
|
|
2133
|
+
* Saves unread count to localStorage
|
|
2134
|
+
*/
|
|
2135
|
+
saveUnreadCountToStorage(t) {
|
|
2136
|
+
if (typeof window < "u")
|
|
2137
|
+
try {
|
|
2138
|
+
const i = this.getUnreadCountKey();
|
|
2139
|
+
t > 0 ? localStorage.setItem(i, String(t)) : localStorage.removeItem(i);
|
|
2140
|
+
} catch (i) {
|
|
2141
|
+
console.error("Failed to save unread count to localStorage:", i);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
buildWidgetUrl() {
|
|
2145
|
+
return `${Ot(this.config.appUrl)}/w/${this.config.widgetSlug.trim()}/chat`;
|
|
2146
|
+
}
|
|
2147
|
+
init() {
|
|
2148
|
+
try {
|
|
2149
|
+
this.unreadCount = this.loadUnreadCountFromStorage(), this.createContainer(), this.createIframe(), this.setupMessageHandler(), this.setupTrigger(), this.config.hideOnLaunch && this.trigger && (this.trigger.style.display = "none"), this.unreadCount > 0 && (this.trigger && be(this.trigger, this.unreadCount), this.updateDocumentTitle(this.unreadCount)), this.visibilityHandler = () => {
|
|
2150
|
+
!document.hidden && this.titleModified && this.updateDocumentTitle(0);
|
|
2151
|
+
}, document.addEventListener("visibilitychange", this.visibilityHandler), vi(this.config.widgetSlug) && this.open();
|
|
2152
|
+
} catch (t) {
|
|
2153
|
+
this.config.onError(t instanceof Error ? t : new Error(String(t)));
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
createContainer() {
|
|
2157
|
+
this.container = document.createElement("div"), this.container.id = `${this.config.widgetSlug}-container`, this.container.className = `supportwire-widget-container supportwire-${this.config.widgetType}`, Ut(), Xe(this.container, this.config);
|
|
2158
|
+
const t = ki(this.config.widgetSlug);
|
|
2159
|
+
t && this.config.widgetType === "popup" && (this.container.style.width = `${t.width}px`, this.container.style.height = `${t.height}px`), this.config.widgetType === "popup" && this.addResizeHandle(this.container), this.config.widgetType === "popup" && !this.config.selector && At(this.container, this.config.triggerPosition, this.config.theme), document.body.appendChild(this.container);
|
|
2160
|
+
}
|
|
2161
|
+
createIframe() {
|
|
2162
|
+
this.container && (this.iframe = Kt(
|
|
2163
|
+
this.container,
|
|
2164
|
+
this.iframeId,
|
|
2165
|
+
this.widgetUrl,
|
|
2166
|
+
this.config.theme
|
|
2167
|
+
));
|
|
2168
|
+
}
|
|
2169
|
+
setupMessageHandler() {
|
|
2170
|
+
this.messageHandler = Jt(
|
|
2171
|
+
this.iframeId,
|
|
2172
|
+
this.widgetUrl,
|
|
2173
|
+
this.container,
|
|
2174
|
+
{
|
|
2175
|
+
onReady: () => {
|
|
2176
|
+
this.sendMessageToIframe({
|
|
2177
|
+
type: "CONFIG",
|
|
2178
|
+
config: {
|
|
2179
|
+
widgetSlug: this.config.widgetSlug,
|
|
2180
|
+
theme: this.config.theme,
|
|
2181
|
+
triggerPosition: this.config.triggerPosition,
|
|
2182
|
+
widgetType: this.config.widgetType,
|
|
2183
|
+
userToken: this.config.userToken,
|
|
2184
|
+
userEmail: this.config.userEmail,
|
|
2185
|
+
userSignature: this.config.userSignature,
|
|
2186
|
+
userData: this.config.userData,
|
|
2187
|
+
enableScreenshot: this.config.enableScreenshot
|
|
2188
|
+
}
|
|
2189
|
+
});
|
|
2190
|
+
},
|
|
2191
|
+
onOpen: () => {
|
|
2192
|
+
this.isOpen = !0, this.unreadCount = 0, this.saveUnreadCountToStorage(0), this.trigger && be(this.trigger, 0), this.config.onOpen();
|
|
2193
|
+
},
|
|
2194
|
+
onClose: () => {
|
|
2195
|
+
this.isOpen = !1, _e(this.config.widgetSlug, !1), this.trigger && (Le(this.trigger, !1, this.config.theme), window.innerWidth <= 480 && (this.trigger.style.display = "")), this.config.onClose();
|
|
2196
|
+
},
|
|
2197
|
+
onError: this.config.onError,
|
|
2198
|
+
onUnreadCount: (t) => {
|
|
2199
|
+
t > this.unreadCount && oe.trigger("selection"), this.unreadCount = t, this.saveUnreadCountToStorage(t), this.trigger && be(this.trigger, t), this.updateDocumentTitle(t);
|
|
2200
|
+
},
|
|
2201
|
+
onImagePreview: (t, i, n) => {
|
|
2202
|
+
ni(t, i, n, (r) => {
|
|
2203
|
+
tt(
|
|
2204
|
+
r,
|
|
2205
|
+
(o) => {
|
|
2206
|
+
this.sendMessageToIframe({
|
|
2207
|
+
type: "PAGE_SCREENSHOT_RESULT",
|
|
2208
|
+
payload: { dataUrl: o }
|
|
2209
|
+
});
|
|
2210
|
+
},
|
|
2211
|
+
() => {
|
|
2212
|
+
}
|
|
2213
|
+
);
|
|
2214
|
+
});
|
|
2215
|
+
},
|
|
2216
|
+
onToggleFullscreen: () => {
|
|
2217
|
+
this.toggleExpand();
|
|
2218
|
+
},
|
|
2219
|
+
onMessagePreview: (t, i, n) => {
|
|
2220
|
+
this.isOpen || gi(t, i, n, this.config.triggerPosition, this.config.theme, () => this.open());
|
|
2221
|
+
},
|
|
2222
|
+
onScreenshotRequest: (t) => {
|
|
2223
|
+
this.capturePageScreenshot(t);
|
|
2224
|
+
},
|
|
2225
|
+
onEventRulesRegistered: (t) => {
|
|
2226
|
+
this.eventRuleCleanup && (this.eventRuleCleanup(), this.eventRuleCleanup = null), t.length !== 0 && (this.eventRuleCleanup = bi(t, (i) => {
|
|
2227
|
+
this.sendMessageToIframe({
|
|
2228
|
+
type: "EVENT_RULE_MATCHED",
|
|
2229
|
+
eventRule: {
|
|
2230
|
+
ruleId: i.ruleId,
|
|
2231
|
+
delay: i.delay,
|
|
2232
|
+
messagesToSend: i.messagesToSend
|
|
2233
|
+
}
|
|
2234
|
+
});
|
|
2235
|
+
}));
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
), window.addEventListener("message", this.messageHandler), this.iframe && (this.guideBridgeTeardown = Xt(this.iframe, this.iframeId).teardown);
|
|
2239
|
+
}
|
|
2240
|
+
setupTrigger() {
|
|
2241
|
+
if (this.triggerClickHandler = () => this.toggle(), this.config.selector) {
|
|
2242
|
+
const t = document.querySelector(this.config.selector);
|
|
2243
|
+
t ? (this.trigger = t, this.trigger.addEventListener("click", this.triggerClickHandler)) : (console.warn(`SupportWireWidget: Selector "${this.config.selector}" not found. Creating default trigger.`), this.createDefaultTrigger());
|
|
2244
|
+
} else
|
|
2245
|
+
this.createDefaultTrigger();
|
|
2246
|
+
}
|
|
2247
|
+
createDefaultTrigger() {
|
|
2248
|
+
this.triggerClickHandler || (this.triggerClickHandler = () => this.toggle()), this.trigger = Gt(this.config, this.triggerClickHandler);
|
|
2249
|
+
}
|
|
2250
|
+
sendMessageToIframe(t) {
|
|
2251
|
+
Vt(this.iframe, this.iframeId, this.widgetUrl, t);
|
|
2252
|
+
}
|
|
2253
|
+
toggle() {
|
|
2254
|
+
this.isOpen ? this.close() : this.open();
|
|
2255
|
+
}
|
|
2256
|
+
open() {
|
|
2257
|
+
!this.container || !this.iframe || (ke(!0), this.showTrigger(), this.isOpen = !0, oe.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
|
+
}
|
|
2259
|
+
close() {
|
|
2260
|
+
this.container && (this.isOpen = !1, oe.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
|
+
}
|
|
2262
|
+
showTrigger() {
|
|
2263
|
+
this.trigger && (this.trigger.style.display = "");
|
|
2264
|
+
}
|
|
2265
|
+
hideTrigger() {
|
|
2266
|
+
this.trigger && (this.trigger.style.display = "none");
|
|
2267
|
+
}
|
|
2268
|
+
addResizeHandle(t) {
|
|
2269
|
+
const i = document.createElement("div");
|
|
2270
|
+
i.innerHTML = `<svg width="10" height="10" viewBox="0 0 10 10" fill="none" style="opacity:0.3;transform:rotate(180deg)">
|
|
2271
|
+
<line x1="9" y1="1" x2="1" y2="9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
2272
|
+
<line x1="9" y1="5" x2="5" y2="9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
2273
|
+
</svg>`, Object.assign(i.style, {
|
|
2274
|
+
position: "absolute",
|
|
2275
|
+
top: "4px",
|
|
2276
|
+
left: "4px",
|
|
2277
|
+
width: "20px",
|
|
2278
|
+
height: "20px",
|
|
2279
|
+
cursor: "nw-resize",
|
|
2280
|
+
zIndex: "10",
|
|
2281
|
+
display: "flex",
|
|
2282
|
+
alignItems: "center",
|
|
2283
|
+
justifyContent: "center",
|
|
2284
|
+
color: "var(--muted-foreground, #999)",
|
|
2285
|
+
borderRadius: "4px"
|
|
2286
|
+
}), i.addEventListener("mouseenter", () => {
|
|
2287
|
+
const g = i.querySelector("svg");
|
|
2288
|
+
g && (g.style.opacity = "0.6");
|
|
2289
|
+
}), i.addEventListener("mouseleave", () => {
|
|
2290
|
+
const g = i.querySelector("svg");
|
|
2291
|
+
g && (g.style.opacity = "0.3");
|
|
2292
|
+
});
|
|
2293
|
+
const n = 320, r = 700, o = 400;
|
|
2294
|
+
i.addEventListener("dblclick", (g) => {
|
|
2295
|
+
g.stopPropagation(), oe.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
|
+
t.style.willChange = "", t.style.transition = "width 200ms ease-out, height 200ms ease-out";
|
|
2297
|
+
}, 270)), t.style.width = "min(400px, max(0px, -20px + 100vw))", t.style.height = "min(704px, 100% - 104px)", t.style.maxHeight = "704px";
|
|
2298
|
+
try {
|
|
2299
|
+
localStorage.removeItem(`supportwire-widget-size-${this.config.widgetSlug}`);
|
|
2300
|
+
} catch {
|
|
2301
|
+
}
|
|
2302
|
+
});
|
|
2303
|
+
let l = !1, s = 0, u = 0, d = 0, h = 0;
|
|
2304
|
+
i.addEventListener("pointerdown", (g) => {
|
|
2305
|
+
g.stopPropagation(), g.preventDefault(), l = !0, s = g.clientX, u = g.clientY;
|
|
2306
|
+
const w = t.getBoundingClientRect();
|
|
2307
|
+
d = w.width, h = w.height, i.setPointerCapture(g.pointerId), t.style.transition = "none";
|
|
2308
|
+
}), i.addEventListener("pointermove", (g) => {
|
|
2309
|
+
if (!l) return;
|
|
2310
|
+
const w = s - g.clientX, y = u - g.clientY, S = parseInt(t.style.right) || 20, b = parseInt(t.style.bottom) || 84, v = Math.min(r, window.innerWidth - S - 20), k = window.innerHeight - b - 20, C = Math.max(n, Math.min(v, d + w)), N = Math.max(o, Math.min(k, h + y));
|
|
2311
|
+
t.style.width = `${C}px`, t.style.height = `${N}px`, t.style.maxHeight = `${N}px`;
|
|
2312
|
+
}), i.addEventListener("pointerup", (g) => {
|
|
2313
|
+
if (!l) return;
|
|
2314
|
+
l = !1, i.releasePointerCapture(g.pointerId), t.style.transition = "";
|
|
2315
|
+
const w = t.getBoundingClientRect();
|
|
2316
|
+
Ci(this.config.widgetSlug, {
|
|
2317
|
+
width: Math.round(w.width),
|
|
2318
|
+
height: Math.round(w.height)
|
|
2319
|
+
});
|
|
2320
|
+
}), t.appendChild(i);
|
|
2321
|
+
}
|
|
2322
|
+
toggleExpand() {
|
|
2323
|
+
this.container && (oe.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
|
+
this.container && (this.container.style.willChange = "", this.container.style.transition = "width 200ms ease-out, height 200ms ease-out");
|
|
2325
|
+
}, 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
|
+
}
|
|
2327
|
+
async capturePageScreenshot(t) {
|
|
2328
|
+
var i, n;
|
|
2329
|
+
try {
|
|
2330
|
+
const r = (i = this.container) == null ? void 0 : i.style.display, o = (n = this.trigger) == null ? void 0 : n.style.display;
|
|
2331
|
+
this.container && (this.container.style.display = "none"), this.trigger && (this.trigger.style.display = "none");
|
|
2332
|
+
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 = o ?? ""), tt(
|
|
2334
|
+
s,
|
|
2335
|
+
(u) => {
|
|
2336
|
+
this.sendMessageToIframe({
|
|
2337
|
+
type: "PAGE_SCREENSHOT_RESULT",
|
|
2338
|
+
payload: { dataUrl: u }
|
|
2339
|
+
});
|
|
2340
|
+
},
|
|
2341
|
+
() => {
|
|
2342
|
+
this.sendMessageToIframe({
|
|
2343
|
+
type: "PAGE_SCREENSHOT_ERROR",
|
|
2344
|
+
payload: { error: "Screenshot cancelled" }
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
);
|
|
2348
|
+
} catch (r) {
|
|
2349
|
+
this.container && (this.container.style.display = ""), this.trigger && (this.trigger.style.display = "");
|
|
2350
|
+
const o = r instanceof Error ? r.message : "Screenshot capture failed";
|
|
2351
|
+
this.sendMessageToIframe({
|
|
2352
|
+
type: "PAGE_SCREENSHOT_ERROR",
|
|
2353
|
+
payload: { error: o }
|
|
2354
|
+
});
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
updateConfig(t) {
|
|
2358
|
+
const i = A({}, this.config);
|
|
2359
|
+
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 n = t.appUrl !== void 0 && t.appUrl !== i.appUrl, r = t.theme !== void 0 && t.theme !== i.theme;
|
|
2361
|
+
(n || r) && (r && this.sendMessageToIframe({
|
|
2362
|
+
type: "THEME",
|
|
2363
|
+
theme: t.theme
|
|
2364
|
+
}), 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({
|
|
2365
|
+
type: "UPDATE_CONFIG",
|
|
2366
|
+
config: t
|
|
2367
|
+
});
|
|
2368
|
+
}
|
|
2369
|
+
sendMessage(t, i) {
|
|
2370
|
+
if (!t || typeof t != "string" || t.trim() === "") {
|
|
2371
|
+
this.config.onError(new Error("Message must be a non-empty string"));
|
|
2372
|
+
return;
|
|
2373
|
+
}
|
|
2374
|
+
i?.openWidget !== !1 && !this.isOpen && this.open(), this.sendMessageToIframe({
|
|
2375
|
+
type: "SEND_MESSAGE",
|
|
2376
|
+
message: t,
|
|
2377
|
+
openWidget: i?.openWidget
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
destroy() {
|
|
2381
|
+
ke(!0), this.updateDocumentTitle(0), this.eventRuleCleanup && (this.eventRuleCleanup(), this.eventRuleCleanup = null), this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.messageHandler && (window.removeEventListener("message", this.messageHandler), this.messageHandler = null), this.guideBridgeTeardown && (this.guideBridgeTeardown(), this.guideBridgeTeardown = null), this.trigger && this.triggerClickHandler && this.trigger.removeEventListener("click", this.triggerClickHandler), this.trigger && !this.config.selector && this.trigger.remove(), this.trigger = null, this.triggerClickHandler = null, this.container && (this.container.remove(), this.container = null), this.iframe = null, this.isOpen = !1, ve.instances.delete(this.iframeId);
|
|
2382
|
+
}
|
|
2383
|
+
/**
|
|
2384
|
+
* Returns all initialized widget instances, optionally filtered by widgetSlug.
|
|
2385
|
+
*/
|
|
2386
|
+
static getInstances(t) {
|
|
2387
|
+
const i = Array.from(ve.instances.values());
|
|
2388
|
+
return t !== void 0 ? i.filter((n) => n.config.widgetSlug === t) : i;
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
xt.instances = /* @__PURE__ */ new Map();
|
|
2392
|
+
let _i = xt;
|
|
2393
|
+
const Ni = [
|
|
2394
|
+
"app_id",
|
|
2395
|
+
"user_id",
|
|
2396
|
+
"email",
|
|
2397
|
+
"user_hash",
|
|
2398
|
+
"name",
|
|
2399
|
+
"created_at",
|
|
2400
|
+
"phone",
|
|
2401
|
+
"avatar",
|
|
2402
|
+
"unsubscribed_from_emails",
|
|
2403
|
+
"language_override",
|
|
2404
|
+
"utm_campaign",
|
|
2405
|
+
"utm_content",
|
|
2406
|
+
"utm_medium",
|
|
2407
|
+
"utm_source",
|
|
2408
|
+
"utm_term",
|
|
2409
|
+
"page_title",
|
|
2410
|
+
"company",
|
|
2411
|
+
"companies",
|
|
2412
|
+
"alignment",
|
|
2413
|
+
"horizontal_padding",
|
|
2414
|
+
"vertical_padding",
|
|
2415
|
+
"hide_default_launcher",
|
|
2416
|
+
"hide_notifications",
|
|
2417
|
+
"custom_launcher_selector",
|
|
2418
|
+
"z_index",
|
|
2419
|
+
"action_color",
|
|
2420
|
+
"background_color",
|
|
2421
|
+
"link_color",
|
|
2422
|
+
"theme_mode",
|
|
2423
|
+
"session_duration",
|
|
2424
|
+
"region",
|
|
2425
|
+
"api_base"
|
|
2426
|
+
];
|
|
2427
|
+
function vt(e) {
|
|
2428
|
+
const t = {};
|
|
2429
|
+
for (const [i, n] of Object.entries(e))
|
|
2430
|
+
Ni.includes(i) || (t[i] = n);
|
|
2431
|
+
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
|
+
widgetSlug: String(e.app_id),
|
|
2433
|
+
userEmail: typeof e.email == "string" ? e.email : void 0,
|
|
2434
|
+
userExternalUserId: typeof e.user_id == "string" ? e.user_id : void 0,
|
|
2435
|
+
userSignature: typeof e.user_hash == "string" ? e.user_hash : void 0,
|
|
2436
|
+
userData: t,
|
|
2437
|
+
theme: e.theme_mode === "dark" || e.theme_mode === "light" ? e.theme_mode : void 0,
|
|
2438
|
+
selector: typeof e.custom_launcher_selector == "string" ? e.custom_launcher_selector : void 0,
|
|
2439
|
+
hideOnLaunch: typeof e.hide_default_launcher == "boolean" ? e.hide_default_launcher : void 0,
|
|
2440
|
+
triggerPosition: Pi(e.alignment)
|
|
2441
|
+
};
|
|
2442
|
+
}
|
|
2443
|
+
function Pi(e) {
|
|
2444
|
+
if (e === "left") return "bottom-left";
|
|
2445
|
+
if (e === "right") return "bottom-right";
|
|
2446
|
+
}
|
|
2447
|
+
let L = null, J = null;
|
|
2448
|
+
const Oe = /* @__PURE__ */ new Set(), Fe = /* @__PURE__ */ new Set(), st = /* @__PURE__ */ new Set(), Ee = /* @__PURE__ */ new Set();
|
|
2449
|
+
let Ct = 0, pe = null;
|
|
2450
|
+
function Oi() {
|
|
2451
|
+
if (typeof window > "u") return at();
|
|
2452
|
+
if (window.SupportWireMessenger) return window.SupportWireMessenger;
|
|
2453
|
+
const e = at();
|
|
2454
|
+
return window.SupportWireMessenger = e, e;
|
|
2455
|
+
}
|
|
2456
|
+
function at() {
|
|
2457
|
+
const e = [], t = (...i) => {
|
|
2458
|
+
e.push(i);
|
|
2459
|
+
};
|
|
2460
|
+
return t.q = e, t;
|
|
2461
|
+
}
|
|
2462
|
+
function Fi() {
|
|
2463
|
+
if (typeof window > "u") return;
|
|
2464
|
+
const e = window.SupportWireMessenger;
|
|
2465
|
+
if (!e || !e.q) return;
|
|
2466
|
+
const t = e.q.slice();
|
|
2467
|
+
e.q.length = 0;
|
|
2468
|
+
const i = (...n) => {
|
|
2469
|
+
const [r, ...o] = n;
|
|
2470
|
+
lt(r, ...o);
|
|
2471
|
+
};
|
|
2472
|
+
i.q = [], window.SupportWireMessenger = i;
|
|
2473
|
+
for (const n of t) {
|
|
2474
|
+
const [r, ...o] = n;
|
|
2475
|
+
lt(r, ...o);
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
function lt(e, ...t) {
|
|
2479
|
+
switch (e) {
|
|
2480
|
+
case "boot":
|
|
2481
|
+
ze(t[0]);
|
|
2482
|
+
break;
|
|
2483
|
+
case "update":
|
|
2484
|
+
kt(t[0]);
|
|
2485
|
+
break;
|
|
2486
|
+
case "shutdown":
|
|
2487
|
+
Ui();
|
|
2488
|
+
break;
|
|
2489
|
+
case "show":
|
|
2490
|
+
zi();
|
|
2491
|
+
break;
|
|
2492
|
+
case "hide":
|
|
2493
|
+
Hi();
|
|
2494
|
+
break;
|
|
2495
|
+
case "showNewMessage":
|
|
2496
|
+
Ai(t[0]);
|
|
2497
|
+
break;
|
|
2498
|
+
case "trackEvent":
|
|
2499
|
+
Di(t[0], t[1]);
|
|
2500
|
+
break;
|
|
2501
|
+
default:
|
|
2502
|
+
console.warn(`[SupportWireMessenger] unknown command: ${e}`);
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
function ze(e) {
|
|
2506
|
+
if (typeof window > "u") return;
|
|
2507
|
+
if (!e || typeof e.app_id != "string" || e.app_id === "")
|
|
2508
|
+
throw new Error("[SupportWireMessenger] `app_id` is required");
|
|
2509
|
+
if (Oi(), L && J && J.app_id === e.app_id) {
|
|
2510
|
+
kt(e);
|
|
2511
|
+
return;
|
|
2512
|
+
}
|
|
2513
|
+
L && (L.destroy(), L = null);
|
|
2514
|
+
const t = vt(e);
|
|
2515
|
+
J = e;
|
|
2516
|
+
const i = t.widgetSlug, n = pe;
|
|
2517
|
+
if (L = new _i({
|
|
2518
|
+
widgetSlug: i,
|
|
2519
|
+
userEmail: t.userEmail,
|
|
2520
|
+
userExternalUserId: t.userExternalUserId,
|
|
2521
|
+
userSignature: t.userSignature,
|
|
2522
|
+
userData: t.userData,
|
|
2523
|
+
theme: t.theme,
|
|
2524
|
+
selector: t.selector,
|
|
2525
|
+
hideOnLaunch: t.hideOnLaunch,
|
|
2526
|
+
triggerPosition: t.triggerPosition,
|
|
2527
|
+
onOpen: () => {
|
|
2528
|
+
for (const r of Oe) r();
|
|
2529
|
+
},
|
|
2530
|
+
onClose: () => {
|
|
2531
|
+
for (const r of Fe) r();
|
|
2532
|
+
}
|
|
2533
|
+
}), t.userEmail && t.userEmail !== n) {
|
|
2534
|
+
pe = t.userEmail;
|
|
2535
|
+
for (const r of Ee) r();
|
|
2536
|
+
}
|
|
2537
|
+
Fi();
|
|
2538
|
+
}
|
|
2539
|
+
function kt(e) {
|
|
2540
|
+
if (!L) {
|
|
2541
|
+
e && typeof e.app_id == "string" && ze(e);
|
|
2542
|
+
return;
|
|
2543
|
+
}
|
|
2544
|
+
const t = { ...J ?? {}, ...e }, i = pe;
|
|
2545
|
+
J = t;
|
|
2546
|
+
const n = vt(t);
|
|
2547
|
+
if (L.updateConfig({
|
|
2548
|
+
userEmail: n.userEmail || void 0,
|
|
2549
|
+
userExternalUserId: n.userExternalUserId || void 0,
|
|
2550
|
+
userSignature: n.userSignature || void 0,
|
|
2551
|
+
userData: n.userData,
|
|
2552
|
+
theme: n.theme
|
|
2553
|
+
}), n.userEmail && n.userEmail !== i) {
|
|
2554
|
+
pe = n.userEmail;
|
|
2555
|
+
for (const r of Ee) r();
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
function Ui() {
|
|
2559
|
+
if (!L) return;
|
|
2560
|
+
const e = J?.app_id;
|
|
2561
|
+
if (L.destroy(), L = null, J = null, pe = null, Ct = 0, typeof window < "u" && typeof localStorage < "u" && typeof e == "string") {
|
|
2562
|
+
for (const t of Object.keys(localStorage))
|
|
2563
|
+
if (t === `supportwire-unread-count-${e}` || t.startsWith("supportwire-widget-") && t.endsWith(`-${e}`))
|
|
2564
|
+
try {
|
|
2565
|
+
localStorage.removeItem(t);
|
|
2566
|
+
} catch {
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
function zi() {
|
|
2571
|
+
L?.open();
|
|
2572
|
+
}
|
|
2573
|
+
function Hi() {
|
|
2574
|
+
L?.close();
|
|
2575
|
+
}
|
|
2576
|
+
function Ai(e) {
|
|
2577
|
+
L && (L.open(), e && e.trim() !== "" && L.sendMessage(e));
|
|
2578
|
+
}
|
|
2579
|
+
let dt = !1;
|
|
2580
|
+
function Di(e, t) {
|
|
2581
|
+
dt || (console.warn(
|
|
2582
|
+
`[SupportWireMessenger] trackEvent("${e}", ...) is a no-op until POST /v2/track_event ships.`
|
|
2583
|
+
), dt = !0);
|
|
2584
|
+
}
|
|
2585
|
+
function Wi(e) {
|
|
2586
|
+
return Oe.add(e), () => Oe.delete(e);
|
|
2587
|
+
}
|
|
2588
|
+
function Bi(e) {
|
|
2589
|
+
return Fe.add(e), () => Fe.delete(e);
|
|
2590
|
+
}
|
|
2591
|
+
function ji(e) {
|
|
2592
|
+
return st.add(e), e(Ct), () => st.delete(e);
|
|
2593
|
+
}
|
|
2594
|
+
function Gi(e) {
|
|
2595
|
+
return Ee.add(e), () => Ee.delete(e);
|
|
2596
|
+
}
|
|
2597
|
+
let pt = !1;
|
|
2598
|
+
function qi(e) {
|
|
2599
|
+
pt || (console.warn(
|
|
2600
|
+
"[SupportWireMessenger] hideNotifications is a no-op for now; preview suppression lives in the widget app."
|
|
2601
|
+
), pt = !0);
|
|
2602
|
+
}
|
|
2603
|
+
function Yi() {
|
|
2604
|
+
return null;
|
|
2605
|
+
}
|
|
2606
|
+
function Ki() {
|
|
2607
|
+
return null;
|
|
2608
|
+
}
|
|
2609
|
+
const ct = /* @__PURE__ */ new Map();
|
|
2610
|
+
function B(e) {
|
|
2611
|
+
return (...t) => {
|
|
2612
|
+
ct.get(e) || (console.warn(`[SupportWireMessenger] ${e} is not implemented; ignoring call.`), ct.set(e, !0));
|
|
2613
|
+
};
|
|
2614
|
+
}
|
|
2615
|
+
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 nr(e) {
|
|
2617
|
+
ze(e);
|
|
2618
|
+
}
|
|
2619
|
+
export {
|
|
2620
|
+
nr as SupportWire,
|
|
2621
|
+
ze as boot,
|
|
2622
|
+
nr as default,
|
|
2623
|
+
Yi as getVisitorId,
|
|
2624
|
+
Hi as hide,
|
|
2625
|
+
qi as hideNotifications,
|
|
2626
|
+
Bi as onHide,
|
|
2627
|
+
Wi as onShow,
|
|
2628
|
+
ji as onUnreadCountChange,
|
|
2629
|
+
Gi as onUserEmailSupplied,
|
|
2630
|
+
zi as show,
|
|
2631
|
+
Ji as showArticle,
|
|
2632
|
+
tr as showConversation,
|
|
2633
|
+
rr as showMessages,
|
|
2634
|
+
Ai as showNewMessage,
|
|
2635
|
+
Xi as showNews,
|
|
2636
|
+
ir as showSpace,
|
|
2637
|
+
er as showTicket,
|
|
2638
|
+
Ui as shutdown,
|
|
2639
|
+
Zi as startChecklist,
|
|
2640
|
+
Qi as startSurvey,
|
|
2641
|
+
Vi as startTour,
|
|
2642
|
+
Di as trackEvent,
|
|
2643
|
+
kt as update,
|
|
2644
|
+
Ki as whoami
|
|
2645
|
+
};
|
|
2646
|
+
//# sourceMappingURL=index.js.map
|