@aiden-voice/widget 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -1
- package/dist/components/Launcher.d.ts +5 -1
- package/dist/components/icons.d.ts +6 -0
- package/dist/config.d.ts +33 -1
- package/dist/controller.d.ts +2 -0
- package/dist/index.d.ts +4 -3
- package/dist/layout.d.ts +2 -0
- package/dist/theme.d.ts +21 -2
- package/dist/themeRoles.d.ts +5 -0
- package/dist/types.d.ts +76 -1
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +7 -7
- package/dist/widget.js +779 -440
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -1,21 +1,204 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
|
|
1
|
+
//#region src/imageUrl.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (e != null && e !== "") {
|
|
4
|
+
if (typeof e == "string") try {
|
|
5
|
+
let t = new URL(e);
|
|
6
|
+
if (t.protocol === "https:" || t.protocol === "data:" && t.pathname.toLowerCase().startsWith("image/")) return e;
|
|
7
|
+
} catch {}
|
|
8
|
+
console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`);
|
|
9
|
+
}
|
|
4
10
|
}
|
|
5
|
-
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/themeRoles.ts
|
|
13
|
+
var t = [
|
|
14
|
+
"primary",
|
|
15
|
+
"onPrimary",
|
|
16
|
+
"primaryText",
|
|
17
|
+
"ink",
|
|
18
|
+
"link",
|
|
19
|
+
"text",
|
|
20
|
+
"panel",
|
|
21
|
+
"border",
|
|
22
|
+
"headerHover",
|
|
23
|
+
"assistantBubble",
|
|
24
|
+
"muted",
|
|
25
|
+
"typingDots",
|
|
26
|
+
"errorBackground",
|
|
27
|
+
"errorText",
|
|
28
|
+
"inputBorder",
|
|
29
|
+
"focusRing"
|
|
30
|
+
], n = {
|
|
31
|
+
primary: "#4f46e5",
|
|
32
|
+
onPrimary: "#ffffff",
|
|
33
|
+
primaryText: "#4f46e5",
|
|
34
|
+
ink: "#111111",
|
|
35
|
+
link: "#0000ee",
|
|
36
|
+
text: "#111111",
|
|
37
|
+
panel: "#ffffff",
|
|
38
|
+
border: "#e5e5e5",
|
|
39
|
+
headerHover: "#f3f4f6",
|
|
40
|
+
assistantBubble: "#f0f0f0",
|
|
41
|
+
muted: "#4b5563",
|
|
42
|
+
typingDots: "#6b7280",
|
|
43
|
+
errorBackground: "#fee2e2",
|
|
44
|
+
errorText: "#991b1b",
|
|
45
|
+
inputBorder: "#6b7280",
|
|
46
|
+
focusRing: "#111827"
|
|
47
|
+
}, r = {
|
|
48
|
+
primary: "--whoo-widget-color",
|
|
49
|
+
onPrimary: "--whoo-widget-text-on-color",
|
|
50
|
+
primaryText: "--whoo-widget-color-text",
|
|
51
|
+
ink: "--whoo-widget-ink",
|
|
52
|
+
link: "--whoo-widget-link-color",
|
|
53
|
+
text: "--whoo-widget-text",
|
|
54
|
+
panel: "--whoo-widget-panel",
|
|
55
|
+
border: "--whoo-widget-border",
|
|
56
|
+
headerHover: "--whoo-widget-header-hover",
|
|
57
|
+
assistantBubble: "--whoo-widget-assistant-bubble",
|
|
58
|
+
muted: "--whoo-widget-muted",
|
|
59
|
+
typingDots: "--whoo-widget-typing-dots",
|
|
60
|
+
errorBackground: "--whoo-widget-error-bg",
|
|
61
|
+
errorText: "--whoo-widget-error-text",
|
|
62
|
+
inputBorder: "--whoo-widget-input-border",
|
|
63
|
+
focusRing: "--whoo-widget-focus-ring"
|
|
64
|
+
}, i = 2147483e3, a = 2147483647;
|
|
65
|
+
function o(e) {
|
|
66
|
+
return e === void 0 ? i : Number.isInteger(e) && Math.abs(e) <= a ? e : (console.warn(`whoo-aiden-widget: ignoring zIndex ${String(e)} (expected an integer between -${a} and ${a}); using ${i}.`), i);
|
|
67
|
+
}
|
|
68
|
+
var s = "Aiden";
|
|
69
|
+
function c(e) {
|
|
6
70
|
return typeof e == "string" ? e.trim() : "";
|
|
7
71
|
}
|
|
8
|
-
function
|
|
72
|
+
function l(e) {
|
|
9
73
|
if ((typeof e.publishableKey == "string" && e.publishableKey.length > 0) == (typeof e.sessionToken == "string" && e.sessionToken.length > 0)) throw Error("whoo-aiden-widget: init() requires exactly one of `publishableKey` or `sessionToken`, not both or neither.");
|
|
10
74
|
}
|
|
75
|
+
function u(e) {
|
|
76
|
+
console.warn(`whoo-aiden-widget: ${e}`);
|
|
77
|
+
}
|
|
78
|
+
var d = 20;
|
|
79
|
+
function f(e) {
|
|
80
|
+
let t = /* @__PURE__ */ new WeakSet(), n = /* @__PURE__ */ new Set();
|
|
81
|
+
return (r) => {
|
|
82
|
+
if (typeof r == "object" && r || typeof r == "function") {
|
|
83
|
+
if (t.has(r)) return;
|
|
84
|
+
t.add(r);
|
|
85
|
+
} else {
|
|
86
|
+
if (n.has(r)) return;
|
|
87
|
+
n.size >= d && n.delete(n.values().next().value), n.add(r);
|
|
88
|
+
}
|
|
89
|
+
u(e);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
var p = f("ignoring `theme` -- expected an object."), m = f("ignoring `layout` -- expected an object.");
|
|
93
|
+
function h(e) {
|
|
94
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
95
|
+
}
|
|
96
|
+
var g = (e) => e == null || e === "";
|
|
97
|
+
function _(e, t, n) {
|
|
98
|
+
let r = e[t];
|
|
99
|
+
return r == null ? null : h(r) ? r : (u(`ignoring \`${n}\` -- expected an object.`), null);
|
|
100
|
+
}
|
|
101
|
+
function v(e, t, n) {
|
|
102
|
+
for (let r of Object.keys(e)) t.includes(r) || u(`ignoring unknown option \`${n}.${r}\`.`);
|
|
103
|
+
}
|
|
104
|
+
function y(e, t, n) {
|
|
105
|
+
if (!g(e)) {
|
|
106
|
+
if (typeof e == "string" && t.includes(e)) return e;
|
|
107
|
+
u(`ignoring \`${n}\` -- expected one of ${t.join(", ")}.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
var b = 200, x = /url\(|[@;{}\\]/i;
|
|
111
|
+
function S(e) {
|
|
112
|
+
if (!g(e)) {
|
|
113
|
+
if (typeof e == "string") {
|
|
114
|
+
let t = e.trim();
|
|
115
|
+
if (t && t.length <= b && !x.test(t)) return t;
|
|
116
|
+
}
|
|
117
|
+
u(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${b} characters, without url(), @, ;, {, } or \\.`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
var C = [
|
|
121
|
+
"chat",
|
|
122
|
+
"message",
|
|
123
|
+
"sparkle"
|
|
124
|
+
], ee = ["chevron-down", "close"], w = /* @__PURE__ */ new WeakMap();
|
|
125
|
+
function T(n) {
|
|
126
|
+
let r = {
|
|
127
|
+
colors: {},
|
|
128
|
+
fontFamily: void 0,
|
|
129
|
+
launcher: {}
|
|
130
|
+
};
|
|
131
|
+
if (n == null) return r;
|
|
132
|
+
if (!h(n)) return p(n), r;
|
|
133
|
+
let i = w.get(n);
|
|
134
|
+
if (i) return i;
|
|
135
|
+
v(n, [
|
|
136
|
+
"colors",
|
|
137
|
+
"fonts",
|
|
138
|
+
"launcher"
|
|
139
|
+
], "theme");
|
|
140
|
+
let a = _(n, "colors", "theme.colors");
|
|
141
|
+
if (a) {
|
|
142
|
+
v(a, t, "theme.colors");
|
|
143
|
+
for (let e of t) {
|
|
144
|
+
let t = a[e];
|
|
145
|
+
g(t) || (typeof t == "string" ? r.colors[e] = t : u(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
let o = _(n, "fonts", "theme.fonts");
|
|
149
|
+
o && (v(o, ["family"], "theme.fonts"), r.fontFamily = S(o.family));
|
|
150
|
+
let s = _(n, "launcher", "theme.launcher");
|
|
151
|
+
if (s) {
|
|
152
|
+
v(s, [
|
|
153
|
+
"icon",
|
|
154
|
+
"iconUrl",
|
|
155
|
+
"openIcon",
|
|
156
|
+
"openIconUrl"
|
|
157
|
+
], "theme.launcher");
|
|
158
|
+
let t = y(s.icon, C, "theme.launcher.icon"), n = e(s.iconUrl, "theme.launcher.iconUrl"), i = y(s.openIcon, ee, "theme.launcher.openIcon"), a = e(s.openIconUrl, "theme.launcher.openIconUrl");
|
|
159
|
+
t && (r.launcher.icon = t), n && (r.launcher.iconUrl = n), i && (r.launcher.openIcon = i), a && (r.launcher.openIconUrl = a);
|
|
160
|
+
}
|
|
161
|
+
return w.set(n, r), r;
|
|
162
|
+
}
|
|
163
|
+
var E = {
|
|
164
|
+
offsetX: 20,
|
|
165
|
+
offsetY: 20,
|
|
166
|
+
launcherSize: 56,
|
|
167
|
+
panelWidth: 360,
|
|
168
|
+
panelHeight: 480
|
|
169
|
+
};
|
|
170
|
+
function D(e, t, n) {
|
|
171
|
+
return e == null ? n : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : (u(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`), n);
|
|
172
|
+
}
|
|
173
|
+
function O(e, t, n, r) {
|
|
174
|
+
let i = Math.min(r, Math.max(n, e));
|
|
175
|
+
return i !== e && u(`\`${t}\` ${e} is out of range (${r === Infinity ? `at least ${n}` : `${n}-${r}`}); using ${i}.`), i;
|
|
176
|
+
}
|
|
177
|
+
var k = /* @__PURE__ */ new WeakMap();
|
|
178
|
+
function te(e) {
|
|
179
|
+
let t = { ...E };
|
|
180
|
+
if (e == null) return t;
|
|
181
|
+
if (!h(e)) return m(e), t;
|
|
182
|
+
let n = k.get(e);
|
|
183
|
+
if (n) return n;
|
|
184
|
+
v(e, [
|
|
185
|
+
"offset",
|
|
186
|
+
"launcherSize",
|
|
187
|
+
"panel"
|
|
188
|
+
], "layout");
|
|
189
|
+
let r = _(e, "offset", "layout.offset");
|
|
190
|
+
r && (v(r, ["x", "y"], "layout.offset"), t.offsetX = D(r.x, "layout.offset.x", E.offsetX), t.offsetY = D(r.y, "layout.offset.y", E.offsetY)), t.launcherSize = O(D(e.launcherSize, "layout.launcherSize", E.launcherSize), "layout.launcherSize", 24, 120);
|
|
191
|
+
let i = _(e, "panel", "layout.panel");
|
|
192
|
+
return i && (v(i, ["width", "height"], "layout.panel"), t.panelWidth = O(D(i.width, "layout.panel.width", E.panelWidth), "layout.panel.width", 280, Infinity), t.panelHeight = O(D(i.height, "layout.panel.height", E.panelHeight), "layout.panel.height", 320, Infinity)), k.set(e, t), t;
|
|
193
|
+
}
|
|
11
194
|
//#endregion
|
|
12
195
|
//#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/dist/preact.mjs
|
|
13
|
-
var
|
|
14
|
-
function
|
|
196
|
+
var A, ne, j, re, ie, ae, oe, M, se, ce, le, ue, N = {}, de = [], fe = /^m(i|n|o|s|text|space)$/, pe = Array.isArray, me = de.slice, P = Object.assign;
|
|
197
|
+
function he(e) {
|
|
15
198
|
e && e.parentNode && e.remove();
|
|
16
199
|
}
|
|
17
|
-
function
|
|
18
|
-
var
|
|
200
|
+
function ge(e, t, n, r, i) {
|
|
201
|
+
var a = {
|
|
19
202
|
type: e,
|
|
20
203
|
props: t,
|
|
21
204
|
key: n,
|
|
@@ -26,47 +209,47 @@ function C(e, t, n, r, i) {
|
|
|
26
209
|
__e: null,
|
|
27
210
|
__c: null,
|
|
28
211
|
constructor: void 0,
|
|
29
|
-
__v: i || ++
|
|
212
|
+
__v: i || ++ne,
|
|
30
213
|
__i: -1,
|
|
31
214
|
__u: 0
|
|
32
215
|
};
|
|
33
|
-
return !i &&
|
|
216
|
+
return !i && A.vnode && A.vnode(a), a;
|
|
34
217
|
}
|
|
35
|
-
function
|
|
218
|
+
function F(e) {
|
|
36
219
|
return e.children;
|
|
37
220
|
}
|
|
38
|
-
function
|
|
221
|
+
function _e(e, t) {
|
|
39
222
|
this.props = e, this.context = t, this.__g = 0;
|
|
40
223
|
}
|
|
41
|
-
function
|
|
42
|
-
if (t == null) return e.__ ?
|
|
224
|
+
function I(e, t) {
|
|
225
|
+
if (t == null) return e.__ ? I(e.__, e.__i + 1) : null;
|
|
43
226
|
for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) && n.__e) return n.__e;
|
|
44
|
-
return typeof e.type != "function" || e.props.__P ? null :
|
|
227
|
+
return typeof e.type != "function" || e.props.__P ? null : I(e);
|
|
45
228
|
}
|
|
46
|
-
function
|
|
229
|
+
function ve(e) {
|
|
47
230
|
if ((e = e.__) && e.__c && !e.props.__P) return e.__e = null, e.__k.some(function(t) {
|
|
48
231
|
return t && (e.__e = t.__e);
|
|
49
|
-
}),
|
|
232
|
+
}), ve(e);
|
|
50
233
|
}
|
|
51
|
-
function
|
|
52
|
-
(8 & e.__g || !(e.__g |= 8) || !
|
|
234
|
+
function ye(e) {
|
|
235
|
+
(8 & e.__g || !(e.__g |= 8) || !j.push(e) || ie++) && re == A.debounceRendering || ((re = A.debounceRendering) || queueMicrotask)(be);
|
|
53
236
|
}
|
|
54
|
-
function
|
|
55
|
-
var e, t, n, r, i,
|
|
237
|
+
function be() {
|
|
238
|
+
var e, t, n, r, i, a, o, s, c;
|
|
56
239
|
try {
|
|
57
|
-
for (t = 1;
|
|
240
|
+
for (t = 1; j.length;) j.length > t && j.sort(ae), e = j.shift(), t = j.length, 8 & e.__g && (r = void 0, i = void 0, a = (i = (n = e).__v).__e, o = [], s = [], (c = n.__P) && ((r = P({ constructor: void 0 }, i)).__v = i.__v + 1, A.vnode && A.vnode(r), Oe(c, r, i, n.__n, c.namespaceURI, 32 & i.__u ? [a] : null, o, a || I(i), 32 & i.__u, s), r.__v = i.__v, r.__.__k[r.__i] = r, Ae(o, r, s), i.__ = i.__e = null, r.__e != a && ve(r)));
|
|
58
241
|
} finally {
|
|
59
|
-
|
|
242
|
+
j.length = ie = 0;
|
|
60
243
|
}
|
|
61
244
|
}
|
|
62
|
-
function
|
|
63
|
-
var d, f, p, m, h, g,
|
|
64
|
-
for (c =
|
|
245
|
+
function xe(e, t, n, r, i, a, o, s, c, l, u) {
|
|
246
|
+
var d, f, p, m, h, g, _ = r.__k || de, v = t.length;
|
|
247
|
+
for (c = Se(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = ~p.__i && _[p.__i] || N, p.__i = d, g = Oe(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && (f.ref != p.ref || 8 & f.__u) && (f.ref != p.ref && f.ref && Me(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h ||= m, 4 & p.__u ? (c = Ce(p, c, e, !f.__v), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
|
|
65
248
|
return n.__e = h, c;
|
|
66
249
|
}
|
|
67
|
-
function
|
|
250
|
+
function Se(e, t, n, r, i) {
|
|
68
251
|
var a, o, s, c, l, u, d, f, p, m, h = n.length, g = h, _ = 0, v = !1, y = e.__k = Array(i);
|
|
69
|
-
for (a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o != "object" || o.constructor == String ? o = y[a] =
|
|
252
|
+
for (a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o != "object" || o.constructor == String ? o = y[a] = ge(null, o) : pe(o) ? o = y[a] = ge(F, { children: o }) : o.constructor === void 0 && o.__b ? o = y[a] = ge(o.type, o.props, o.key, o.ref, o.__v) : y[a] = o, c = a + _, o.__ = e, o.__b = e.__b + 1, s = null, ~(l = o.__i = we(o, n, c, g)) && (g--, (s = n[l]) && (s.__u |= 2)), s && s.__v ? (o.__u |= 2, l == c - 1 ? _-- : l == c + 1 ? _++ : l != c && (l > c ? _-- : _++, v = !0)) : (~l || (i > h ? _-- : i < h && _++), typeof o.type != "function" && (o.__u |= 4))) : y[a] = null;
|
|
70
253
|
if (v) {
|
|
71
254
|
for (u = [], d = [], a = 0; a < i; a++) if ((o = y[a]) && 2 & o.__u) {
|
|
72
255
|
for (f = 0, p = u.length; f < p;) u[m = f + p >> 1] < o.__i ? f = m + 1 : p = m;
|
|
@@ -74,20 +257,20 @@ function A(e, t, n, r, i) {
|
|
|
74
257
|
}
|
|
75
258
|
for (_ = u.length; a--;) d[a] && (d[a] == _ ? _-- : y[a].__u |= 4);
|
|
76
259
|
}
|
|
77
|
-
if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r =
|
|
260
|
+
if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r = I(s)), Ne(s, s));
|
|
78
261
|
return r;
|
|
79
262
|
}
|
|
80
|
-
function
|
|
263
|
+
function Ce(e, t, n, r) {
|
|
81
264
|
var i, a;
|
|
82
265
|
if (typeof e.type == "function") {
|
|
83
266
|
if (e.props.__P) return t;
|
|
84
|
-
if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t =
|
|
267
|
+
if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t = Ce(i[a], t, n, !1));
|
|
85
268
|
return t;
|
|
86
269
|
}
|
|
87
|
-
for (t && !t.parentNode && (t =
|
|
270
|
+
for (t && !t.parentNode && (t = I(e)) && !t.parentNode && (t = null), e.__e != t && (!r && n.moveBefore && e.__e.parentNode ? n.moveBefore(e.__e, t) : n.insertBefore(e.__e, t || null)), t = e.__e; (t &&= t.nextSibling) && t.nodeType == 8;);
|
|
88
271
|
return t;
|
|
89
272
|
}
|
|
90
|
-
function
|
|
273
|
+
function we(e, t, n, r) {
|
|
91
274
|
var i, a, o, s = e.key, c = e.type, l = t[n], u = l && !(2 & l.__u);
|
|
92
275
|
if (l === null && s == null || u && s == l.key && c == l.type) return n;
|
|
93
276
|
if (r > +!!u) {
|
|
@@ -95,18 +278,18 @@ function M(e, t, n, r) {
|
|
|
95
278
|
}
|
|
96
279
|
return -1;
|
|
97
280
|
}
|
|
98
|
-
function
|
|
281
|
+
function Te(e, t, n) {
|
|
99
282
|
n ??= "", t[0] == "-" ? e.setProperty(t, n) : e[t] = n;
|
|
100
283
|
}
|
|
101
|
-
function
|
|
284
|
+
function Ee(e, t, n, r, i) {
|
|
102
285
|
var a;
|
|
103
286
|
n: if (t == "style") {
|
|
104
287
|
if (typeof n == "string") e.style.cssText = n;
|
|
105
288
|
else {
|
|
106
|
-
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n ||
|
|
107
|
-
if (n) for (t in n) r && n[t] == r[t] ||
|
|
289
|
+
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || Te(e.style, t, "");
|
|
290
|
+
if (n) for (t in n) r && n[t] == r[t] || Te(e.style, t, n[t]);
|
|
108
291
|
}
|
|
109
|
-
} else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(
|
|
292
|
+
} else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(se, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()), (e.__e ||= {})[t + a] = n, n ? r ? n[M] = r[M] : (n[M] = ce, e.addEventListener(t, a ? ue : le, a)) : e.removeEventListener(t, a ? ue : le, a);
|
|
110
293
|
else {
|
|
111
294
|
if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
112
295
|
else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
|
|
@@ -116,141 +299,141 @@ function P(e, t, n, r, i) {
|
|
|
116
299
|
typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
|
|
117
300
|
}
|
|
118
301
|
}
|
|
119
|
-
function
|
|
302
|
+
function De(e) {
|
|
120
303
|
return function(t) {
|
|
121
304
|
if (this.__e) {
|
|
122
305
|
var n = this.__e[t.type + e];
|
|
123
|
-
if (t[
|
|
124
|
-
else if (t[
|
|
125
|
-
return n(
|
|
306
|
+
if (t[oe] == null) t[oe] = ce++;
|
|
307
|
+
else if (t[oe] < n[M]) return;
|
|
308
|
+
return n(A.event ? A.event(t) : t);
|
|
126
309
|
}
|
|
127
310
|
};
|
|
128
311
|
}
|
|
129
|
-
function
|
|
130
|
-
var d, f, p, m, h, g, _,
|
|
312
|
+
function Oe(e, t, n, r, i, a, o, s, c, l) {
|
|
313
|
+
var u, d, f, p, m, h, g, _, v, y, b, x, S, C, ee, w, T, E, D, O, k = t.type;
|
|
131
314
|
if (t.constructor !== void 0) return null;
|
|
132
|
-
if (128 & n.__u && (
|
|
133
|
-
if (t.__u |=
|
|
134
|
-
if (
|
|
135
|
-
if (
|
|
136
|
-
else if (
|
|
315
|
+
if (128 & n.__u && (c = 32 & n.__u, u = n.__c.__z)) {
|
|
316
|
+
if (t.__u |= c, d = a = [], u.nodeType == 8) for (f = 1, p = u.nextSibling; p; p = p.nextSibling) {
|
|
317
|
+
if (p.nodeType == 8) {
|
|
318
|
+
if (p.data.startsWith("$s")) f++;
|
|
319
|
+
else if (p.data.startsWith("/$s") && !--f) break;
|
|
137
320
|
}
|
|
138
|
-
|
|
321
|
+
a.push(p);
|
|
139
322
|
}
|
|
140
|
-
else
|
|
141
|
-
|
|
323
|
+
else a.push(u);
|
|
324
|
+
s = a[0];
|
|
142
325
|
}
|
|
143
|
-
(
|
|
144
|
-
n: if (typeof
|
|
145
|
-
|
|
326
|
+
(u = A.__b) && u(t);
|
|
327
|
+
n: if (typeof k == "function") {
|
|
328
|
+
m = o.length;
|
|
146
329
|
try {
|
|
147
|
-
if (
|
|
148
|
-
if (
|
|
149
|
-
t.__v != n.__v && (
|
|
330
|
+
if (y = t.props, b = (u = k.prototype) && u.render, x = (u = k.contextType) && r[u.__c], S = u ? x ? x.props.value : u.__ : r, n.__c ? 2 & (h = t.__c = n.__c).__g && (h.__g |= 1) : (b ? t.__c = h = new k(y, S) : (t.__c = h = new _e(y, S), h.constructor = k, h.render = Pe), x && x.sub(h), h.state || (h.state = {}), h.__n = r, h.__g |= 8, h.__h = [], h.__k = []), b && (h.__s || (h.__s = h.state), k.getDerivedStateFromProps && (h.__s == h.state && (h.__s = P({}, h.__s)), P(h.__s, k.getDerivedStateFromProps(y, h.__s)))), g = h.props, _ = h.state, h.__v = t, n.__c) {
|
|
331
|
+
if (b && !k.getDerivedStateFromProps && y !== g && h.componentWillReceiveProps && h.componentWillReceiveProps(y, S), t.__v == n.__v && !(8 & h.__g) || !(4 & h.__g) && h.shouldComponentUpdate && !1 === h.shouldComponentUpdate(y, h.__s, S)) {
|
|
332
|
+
t.__v != n.__v && (h.props = y, h.state = h.__s, h.__g &= -9), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
|
|
150
333
|
e && (e.__ = t);
|
|
151
|
-
}),
|
|
334
|
+
}), de.push.apply(h.__h, h.__k), h.__k = [], h.__h.length && o.push(h), s = I(n);
|
|
152
335
|
break n;
|
|
153
336
|
}
|
|
154
|
-
|
|
155
|
-
|
|
337
|
+
h.componentWillUpdate && h.componentWillUpdate(y, h.__s, S), b && h.componentDidUpdate && h.__h.push(function() {
|
|
338
|
+
h.componentDidUpdate(g, _, v);
|
|
156
339
|
});
|
|
157
|
-
} else
|
|
158
|
-
if (
|
|
340
|
+
} else b && !k.getDerivedStateFromProps && h.componentWillMount && h.componentWillMount(), b && h.componentDidMount && h.__h.push(h.componentDidMount);
|
|
341
|
+
if (h.context = S, h.props = y, h.__P = e, h.__g &= -5, C = A.__r, ee = 0, b) h.state = h.__s, h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), de.push.apply(h.__h, h.__k), h.__k = [];
|
|
159
342
|
else do
|
|
160
|
-
|
|
161
|
-
while (8 &
|
|
162
|
-
|
|
163
|
-
e &&
|
|
164
|
-
}), n.__k = null),
|
|
343
|
+
h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), h.state = h.__s;
|
|
344
|
+
while (8 & h.__g && ++ee < 25);
|
|
345
|
+
h.state = h.__s, h.getChildContext && (r = P({}, r, h.getChildContext())), b && n.__c && h.getSnapshotBeforeUpdate && (v = h.getSnapshotBeforeUpdate(g, _)), w = u && u.type === F && u.key == null ? u.props.children : u, y.__P && (u = s, i = (e = y.__P).namespaceURI, c = a = null, n.props && n.props.__P != e && (n.__k.some(function(e) {
|
|
346
|
+
e && Ne(e, e);
|
|
347
|
+
}), n.__k = null), s = n.__k ? I(n, 0) : null), s = xe(e, pe(w) ? w : [w], t, n, r, i, a, o, s, c, l), y.__P && (t.__e = null, s = u), t.__u &= -161, 128 & n.__u && (h.__z = null), d && d.some(he), h.__h.length && o.push(h), 1 & h.__g && (h.__g &= -4);
|
|
165
348
|
} catch (e) {
|
|
166
|
-
if (
|
|
349
|
+
if (o.length = m, t.__v = null, c || a) {
|
|
167
350
|
if (e.then) {
|
|
168
|
-
if (
|
|
169
|
-
for (
|
|
170
|
-
if (
|
|
171
|
-
if (
|
|
172
|
-
else if (
|
|
173
|
-
|
|
351
|
+
if (T = 0, t.__u |= c ? 160 : 128, a) {
|
|
352
|
+
for (D = 0; D < a.length; D++) if (O = a[D]) {
|
|
353
|
+
if (O.nodeType == 8) {
|
|
354
|
+
if (a[D] = null, O.data.startsWith("$s")) T++ || (E = O);
|
|
355
|
+
else if (O.data.startsWith("/$s") && !--T) {
|
|
356
|
+
s = O;
|
|
174
357
|
break;
|
|
175
358
|
}
|
|
176
|
-
} else
|
|
359
|
+
} else T && (a[D] = null);
|
|
177
360
|
}
|
|
178
361
|
}
|
|
179
|
-
if (!
|
|
180
|
-
for (;
|
|
181
|
-
|
|
362
|
+
if (!E) {
|
|
363
|
+
for (; s && s.nodeType == 8 && s.nextSibling;) s = s.nextSibling;
|
|
364
|
+
a && (a[a.indexOf(s)] = null), E = s;
|
|
182
365
|
}
|
|
183
|
-
t.__c.__z || (t.__c.__z =
|
|
184
|
-
} else
|
|
366
|
+
t.__c.__z || (t.__c.__z = E), t.__e = s;
|
|
367
|
+
} else a && a.some(he);
|
|
185
368
|
} else t.__e = n.__e;
|
|
186
|
-
t.__k ||= n.__k || [], e.then ||
|
|
369
|
+
t.__k ||= n.__k || [], e.then || ke(t), A.__e(e, t, n);
|
|
187
370
|
}
|
|
188
|
-
} else
|
|
189
|
-
return (
|
|
371
|
+
} else s = t.__e = je(n.__e, t, n, r, i, a, o, c, l, e);
|
|
372
|
+
return (u = A.diffed) && u(t), 128 & t.__u ? void 0 : s;
|
|
190
373
|
}
|
|
191
|
-
function
|
|
192
|
-
e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(
|
|
374
|
+
function ke(e) {
|
|
375
|
+
e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(ke));
|
|
193
376
|
}
|
|
194
|
-
function
|
|
195
|
-
for (var r = 0; r < n.length;)
|
|
196
|
-
|
|
377
|
+
function Ae(e, t, n) {
|
|
378
|
+
for (var r = 0; r < n.length;) Me(n[r++], n[r++], n[r++]);
|
|
379
|
+
A.__c && A.__c(t, e), e.some(function(t) {
|
|
197
380
|
try {
|
|
198
381
|
e = t.__h, t.__h = [], e.some(function(e) {
|
|
199
382
|
e.call(t);
|
|
200
383
|
});
|
|
201
384
|
} catch (e) {
|
|
202
|
-
|
|
385
|
+
A.__e(e, t.__v);
|
|
203
386
|
}
|
|
204
387
|
});
|
|
205
388
|
}
|
|
206
|
-
function
|
|
207
|
-
var d, f, p, m, h, g,
|
|
208
|
-
if (
|
|
209
|
-
for (
|
|
210
|
-
e =
|
|
389
|
+
function je(e, t, n, r, i, a, o, s, c, l) {
|
|
390
|
+
var u, d, f, p, m, h, g, _, v, y = n.props || N, b = t.props, x = t.type;
|
|
391
|
+
if (x == "svg" ? i = "http://www.w3.org/2000/svg" : x == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i ||= "http://www.w3.org/1999/xhtml", a) {
|
|
392
|
+
for (u = 0; u < a.length; u++) if ((m = a[u]) && (x ? m.localName == x : m.nodeType == 3)) {
|
|
393
|
+
e = m, a[u] = null;
|
|
211
394
|
break;
|
|
212
395
|
}
|
|
213
396
|
}
|
|
214
397
|
if (!e) {
|
|
215
|
-
if (
|
|
216
|
-
e =
|
|
398
|
+
if (_ = l.ownerDocument || document, !x) return _.createTextNode(b);
|
|
399
|
+
e = _.createElementNS(i, x, b.is && b), s &&= (A.__m && A.__m(t, a), !1), a = null;
|
|
217
400
|
}
|
|
218
|
-
if (
|
|
219
|
-
if (
|
|
220
|
-
for (
|
|
221
|
-
for (
|
|
222
|
-
|
|
223
|
-
} else
|
|
401
|
+
if (x) {
|
|
402
|
+
if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a && me.call(l.childNodes), !s && a) for (y = {}, u = 0; u < e.attributes.length; u++) y[(m = e.attributes[u]).name] = m.value;
|
|
403
|
+
for (u in y) m = y[u], u == "dangerouslySetInnerHTML" ? f = m : u == "children" || u in b || u == "value" && "defaultValue" in b || u == "checked" && "defaultChecked" in b || Ee(e, u, null, m, i);
|
|
404
|
+
for (u in v = 1 & n.__u, b) m = b[u], u == "children" ? p = m : u == "dangerouslySetInnerHTML" ? d = m : u == "value" ? h = m : u == "checked" ? g = m : s && typeof m != "function" || !(y[u] !== m || v && m != null) || Ee(e, u, m, y[u], i);
|
|
405
|
+
d ? (s || f && (d.__html == f.__html || d.__html == e.innerHTML) || (e.innerHTML = d.__html), t.__k = []) : (f && (e.textContent = ""), (x == "foreignObject" || i == "http://www.w3.org/1998/Math/MathML" && fe.test(x)) && (i = "http://www.w3.org/1999/xhtml"), xe(l, pe(p) ? p : [p], t, n, r, i, a, o, a ? a[0] : n.__k && I(n, 0), s, c), a && a.some(he)), s && x != "textarea" || (u = "value", x == "progress" && h == null ? e.removeAttribute(u) : h == null || h === e[u] && (x != "progress" || h) || Ee(e, u, h, y[u], i), u = "checked", g != null && g != e[u] && Ee(e, u, g, y[u], i));
|
|
406
|
+
} else y === b || s && e.data == b || (e.data = b);
|
|
224
407
|
return e;
|
|
225
408
|
}
|
|
226
|
-
function
|
|
409
|
+
function Me(e, t, n) {
|
|
227
410
|
try {
|
|
228
411
|
typeof e == "function" ? (typeof e.__u == "function" && e.__u(), (typeof e.__u != "function" || t) && (e.__u = e(t))) : e.current = t;
|
|
229
412
|
} catch (e) {
|
|
230
|
-
|
|
413
|
+
A.__e(e, n);
|
|
231
414
|
}
|
|
232
415
|
}
|
|
233
|
-
function
|
|
416
|
+
function Ne(e, t, n) {
|
|
234
417
|
var r, i;
|
|
235
|
-
if (
|
|
418
|
+
if (A.unmount && A.unmount(e), !(r = e.ref) || r.current && r.current != e.__e || Me(r, null, t), r = e.__c) {
|
|
236
419
|
if (r.componentWillUnmount) try {
|
|
237
420
|
r.componentWillUnmount();
|
|
238
421
|
} catch (e) {
|
|
239
|
-
|
|
422
|
+
A.__e(e, t);
|
|
240
423
|
}
|
|
241
424
|
r.__P = r.__n = null;
|
|
242
425
|
}
|
|
243
|
-
if (r = e.__k) for (i = 0; i < r.length; i++) r[i] &&
|
|
244
|
-
(r = e.__e) && (n ||
|
|
426
|
+
if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && Ne(r[i], t, typeof e.type != "function" || n && !e.props.__P);
|
|
427
|
+
(r = e.__e) && (n || he(r), r.__e && (r.__e = null)), e.__e = e.__c = e.__ = null;
|
|
245
428
|
}
|
|
246
|
-
function
|
|
429
|
+
function Pe(e, t, n) {
|
|
247
430
|
return this.constructor(e, n);
|
|
248
431
|
}
|
|
249
|
-
function
|
|
250
|
-
var n, r, i,
|
|
251
|
-
|
|
432
|
+
function Fe(e, t) {
|
|
433
|
+
var n, r, i, a;
|
|
434
|
+
A.__ && A.__(e, t), t.nodeType == 9 && (t = t.documentElement), r = (n = e && 32 & e.__u) ? null : t.__k, t.__k = ge(F, { children: [e] }), i = [], a = [], Oe(t, t.__k, r || N, N, t.namespaceURI, r ? null : t.firstChild ? me.call(t.childNodes) : null, i, r ? r.__e : t.firstChild, n, a), Ae(i, t.__k, a), t.__k.props.children = null;
|
|
252
435
|
}
|
|
253
|
-
|
|
436
|
+
A = { __e: function(e, t, n, r) {
|
|
254
437
|
for (var i, a, o; t = t.__;) if ((i = t.__c) && !(1 & i.__g)) {
|
|
255
438
|
i.__g |= 4;
|
|
256
439
|
try {
|
|
@@ -259,43 +442,43 @@ a = { __e: function(e, t, n, r) {
|
|
|
259
442
|
e = t, o = 0;
|
|
260
443
|
}
|
|
261
444
|
}
|
|
262
|
-
throw
|
|
263
|
-
} },
|
|
445
|
+
throw ie = 0, e;
|
|
446
|
+
} }, ne = 0, _e.prototype.setState = function(e, t) {
|
|
264
447
|
var n = this.__s;
|
|
265
|
-
n && n != this.state || (n = this.__s =
|
|
266
|
-
},
|
|
267
|
-
this.__v && (this.__g |= 4, e && this.__h.push(e),
|
|
268
|
-
},
|
|
448
|
+
n && n != this.state || (n = this.__s = P({}, this.state)), typeof e == "function" && (e = e(P({}, n), this.props)), e && (P(n, e), this.__v && (t && this.__k.push(t), ye(this)));
|
|
449
|
+
}, _e.prototype.forceUpdate = function(e) {
|
|
450
|
+
this.__v && (this.__g |= 4, e && this.__h.push(e), ye(this));
|
|
451
|
+
}, _e.prototype.render = F, j = [], ie = 0, ae = function(e, t) {
|
|
269
452
|
return e.__v.__b - t.__v.__b;
|
|
270
|
-
},
|
|
453
|
+
}, oe = Symbol(), M = Symbol(), se = /(PointerCapture)$|Capture$/i, ce = 0, le = De(!1), ue = De(!0);
|
|
271
454
|
//#endregion
|
|
272
455
|
//#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/hooks/dist/hooks.mjs
|
|
273
|
-
var
|
|
274
|
-
function
|
|
275
|
-
|
|
276
|
-
var n =
|
|
456
|
+
var L, R, Ie, Le, Re = Object.is, z = 0, ze = [], Be = [], B = A, Ve = B.__b, He = B.__r, Ue = B.diffed, We = B.__c, Ge = B.unmount, Ke = B.__;
|
|
457
|
+
function qe(e, t) {
|
|
458
|
+
B.__h && B.__h(R, e, z || t), z = 0;
|
|
459
|
+
var n = R.__H || (R.__H = {
|
|
277
460
|
__: [],
|
|
278
461
|
__h: []
|
|
279
462
|
});
|
|
280
463
|
return e >= n.__.length && n.__.push({}), n.__[e];
|
|
281
464
|
}
|
|
282
|
-
function
|
|
283
|
-
return
|
|
465
|
+
function V(e) {
|
|
466
|
+
return z = 1, Je(nt, e);
|
|
284
467
|
}
|
|
285
|
-
function
|
|
286
|
-
var r =
|
|
287
|
-
if (r.t = e, !r.__c && (r.__ = [n ? n(t) :
|
|
468
|
+
function Je(e, t, n) {
|
|
469
|
+
var r = qe(L++, 2);
|
|
470
|
+
if (r.t = e, !r.__c && (r.__ = [n ? n(t) : nt(void 0, t), function(e) {
|
|
288
471
|
var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
|
|
289
|
-
|
|
290
|
-
}], r.__c =
|
|
291
|
-
|
|
292
|
-
var i =
|
|
293
|
-
|
|
472
|
+
Re(t, n) || (r.__N = [n, r.__[1]], r.__c.setState({}));
|
|
473
|
+
}], r.__c = R, !R.__f)) {
|
|
474
|
+
R.__f = !0;
|
|
475
|
+
var i = R.shouldComponentUpdate;
|
|
476
|
+
R.shouldComponentUpdate = function(e, t, n) {
|
|
294
477
|
var r = this.__H;
|
|
295
478
|
if (!r) return !0;
|
|
296
479
|
var a = !1, o = this.props != e;
|
|
297
480
|
if (r.__.some(function(e) {
|
|
298
|
-
e.__N && (a = !0,
|
|
481
|
+
e.__N && (a = !0, Re(e.__[0], e.__N[0]) || (o = !0));
|
|
299
482
|
}), i) {
|
|
300
483
|
var s = i.call(this, e, t, n);
|
|
301
484
|
return a ? s || o : s;
|
|
@@ -306,66 +489,66 @@ function xe(e, t, n) {
|
|
|
306
489
|
return r.__;
|
|
307
490
|
}
|
|
308
491
|
function H(e, t) {
|
|
309
|
-
var n =
|
|
310
|
-
!
|
|
492
|
+
var n = qe(L++, 3);
|
|
493
|
+
!B.__s && tt(n.__H, t) && (n.__P = !0, n.__ = e, n.u = t, R.__H.__h.push(n));
|
|
311
494
|
}
|
|
312
495
|
function U(e) {
|
|
313
|
-
return
|
|
496
|
+
return z = 5, Ye(function() {
|
|
314
497
|
return { current: e };
|
|
315
498
|
}, []);
|
|
316
499
|
}
|
|
317
|
-
function
|
|
318
|
-
var n =
|
|
319
|
-
return
|
|
500
|
+
function Ye(e, t) {
|
|
501
|
+
var n = qe(L++, 7);
|
|
502
|
+
return tt(n.__H, t) && (n.__ = e(), n.__H = t), n.__;
|
|
320
503
|
}
|
|
321
|
-
function
|
|
504
|
+
function Xe() {
|
|
322
505
|
var e;
|
|
323
506
|
do {
|
|
324
|
-
for (; e =
|
|
507
|
+
for (; e = Be.shift();) try {
|
|
325
508
|
W(e);
|
|
326
509
|
} catch (t) {
|
|
327
|
-
|
|
510
|
+
B.__e(t, { __: (e = e.__P) && e.__v });
|
|
328
511
|
}
|
|
329
|
-
for (; e =
|
|
512
|
+
for (; e = ze.shift();) {
|
|
330
513
|
var t = e.__H;
|
|
331
514
|
if (e.__P && t) try {
|
|
332
|
-
t.__h.some(W), t.__h.some(
|
|
515
|
+
t.__h.some(W), t.__h.some(et), t.__h = [];
|
|
333
516
|
} catch (n) {
|
|
334
|
-
t.__h = [],
|
|
517
|
+
t.__h = [], B.__e(n, e.__v);
|
|
335
518
|
}
|
|
336
519
|
}
|
|
337
|
-
} while (
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
},
|
|
342
|
-
e && t.__k && t.__k.__m && (e.__m = t.__k.__m),
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
var t = (
|
|
346
|
-
t && (
|
|
520
|
+
} while (Be.length);
|
|
521
|
+
}
|
|
522
|
+
B.__b = function(e) {
|
|
523
|
+
R = null, Ve && Ve(e);
|
|
524
|
+
}, B.__ = function(e, t) {
|
|
525
|
+
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Ke && Ke(e, t);
|
|
526
|
+
}, B.__r = function(e) {
|
|
527
|
+
He && He(e), L = 0;
|
|
528
|
+
var t = (R = e.__c).__H;
|
|
529
|
+
t && (Ie == R ? R.__h = [] : (t.__h.some(W), t.__h.some(et), L = 0), t.__h = [], t.__.some(function(e) {
|
|
347
530
|
e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
|
|
348
|
-
})),
|
|
349
|
-
},
|
|
350
|
-
|
|
531
|
+
})), Ie = R;
|
|
532
|
+
}, B.diffed = function(e) {
|
|
533
|
+
Ue && Ue(e);
|
|
351
534
|
var t = e.__c;
|
|
352
|
-
t && t.__H && (t.__H.__h.length &&
|
|
535
|
+
t && t.__H && (t.__H.__h.length && $e(ze.push(t)), t.__H.__.some(function(e) {
|
|
353
536
|
e.u && (e.__H = e.u);
|
|
354
|
-
})),
|
|
355
|
-
},
|
|
537
|
+
})), Ie = R = null;
|
|
538
|
+
}, B.__c = function(e, t) {
|
|
356
539
|
t.some(function(e) {
|
|
357
540
|
try {
|
|
358
541
|
e.__h.some(W), e.__h = e.__h.filter(function(e) {
|
|
359
|
-
return !e.__ ||
|
|
542
|
+
return !e.__ || et(e);
|
|
360
543
|
});
|
|
361
544
|
} catch (n) {
|
|
362
545
|
t.some(function(e) {
|
|
363
546
|
e.__h &&= [];
|
|
364
|
-
}), t = [],
|
|
547
|
+
}), t = [], B.__e(n, e.__v);
|
|
365
548
|
}
|
|
366
|
-
}),
|
|
367
|
-
},
|
|
368
|
-
|
|
549
|
+
}), We && We(e, t);
|
|
550
|
+
}, B.unmount = function(e) {
|
|
551
|
+
Ge && Ge(e);
|
|
369
552
|
var t, n, r = e.__c;
|
|
370
553
|
r && r.__H && (r.__H.__.some(function(r) {
|
|
371
554
|
try {
|
|
@@ -374,63 +557,63 @@ V.__b = function(e) {
|
|
|
374
557
|
for (n = e.__; n && (!n.__c || !n.__c.__P);) n = n.__;
|
|
375
558
|
n &&= n.__c;
|
|
376
559
|
}
|
|
377
|
-
r.__P = n,
|
|
560
|
+
r.__P = n, $e(Be.push(r));
|
|
378
561
|
} else W(r);
|
|
379
562
|
} catch (e) {
|
|
380
563
|
t = e;
|
|
381
564
|
}
|
|
382
|
-
}), r.__H = void 0, t &&
|
|
565
|
+
}), r.__H = void 0, t && B.__e(t, r.__v));
|
|
383
566
|
};
|
|
384
|
-
var
|
|
385
|
-
function
|
|
567
|
+
var Ze = typeof requestAnimationFrame == "function";
|
|
568
|
+
function Qe(e) {
|
|
386
569
|
var t, n = function() {
|
|
387
|
-
clearTimeout(r),
|
|
570
|
+
clearTimeout(r), Ze && cancelAnimationFrame(t), setTimeout(e);
|
|
388
571
|
}, r = setTimeout(n, 35);
|
|
389
|
-
|
|
572
|
+
Ze && (t = requestAnimationFrame(n));
|
|
390
573
|
}
|
|
391
|
-
function
|
|
392
|
-
e != 1 &&
|
|
574
|
+
function $e(e) {
|
|
575
|
+
e != 1 && Le == B.requestAnimationFrame || ((Le = B.requestAnimationFrame) || Qe)(Xe);
|
|
393
576
|
}
|
|
394
577
|
function W(e) {
|
|
395
|
-
var t =
|
|
396
|
-
typeof n == "function" && (e.__c = void 0, n()),
|
|
578
|
+
var t = R, n = e.__c;
|
|
579
|
+
typeof n == "function" && (e.__c = void 0, n()), R = t;
|
|
397
580
|
}
|
|
398
|
-
function
|
|
399
|
-
var t =
|
|
400
|
-
e.__c = e.__(),
|
|
581
|
+
function et(e) {
|
|
582
|
+
var t = R;
|
|
583
|
+
e.__c = e.__(), R = t;
|
|
401
584
|
}
|
|
402
|
-
function
|
|
585
|
+
function tt(e, t) {
|
|
403
586
|
return !e || e.length != t.length || t.some(function(t, n) {
|
|
404
|
-
return !
|
|
587
|
+
return !Re(t, e[n]);
|
|
405
588
|
});
|
|
406
589
|
}
|
|
407
|
-
function
|
|
590
|
+
function nt(e, t) {
|
|
408
591
|
return typeof t == "function" ? t(e) : t;
|
|
409
592
|
}
|
|
410
593
|
//#endregion
|
|
411
594
|
//#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
|
|
412
|
-
var
|
|
595
|
+
var rt = 0;
|
|
413
596
|
Array.isArray;
|
|
414
|
-
function G(e, t, n, r, i,
|
|
597
|
+
function G(e, t, n, r, i, a) {
|
|
415
598
|
t ||= {};
|
|
416
|
-
var s, c
|
|
417
|
-
if ("ref" in
|
|
418
|
-
var
|
|
599
|
+
var o, s, c = t;
|
|
600
|
+
if ("ref" in c && typeof e != "function") for (s in c = {}, t) s == "ref" ? o = t[s] : c[s] = t[s];
|
|
601
|
+
var l = {
|
|
419
602
|
type: e,
|
|
420
|
-
props:
|
|
603
|
+
props: c,
|
|
421
604
|
key: n,
|
|
422
|
-
ref:
|
|
605
|
+
ref: o,
|
|
423
606
|
__k: null,
|
|
424
607
|
__: null,
|
|
425
608
|
__b: 0,
|
|
426
609
|
__e: null,
|
|
427
610
|
__c: null,
|
|
428
611
|
constructor: void 0,
|
|
429
|
-
__v: --
|
|
612
|
+
__v: --rt,
|
|
430
613
|
__i: -1,
|
|
431
614
|
__u: 0
|
|
432
615
|
};
|
|
433
|
-
return (i ||
|
|
616
|
+
return (i || a) && (l.__source = i, l.__self = a), A.vnode && A.vnode(l), l;
|
|
434
617
|
}
|
|
435
618
|
//#endregion
|
|
436
619
|
//#region src/components/icons.tsx
|
|
@@ -450,7 +633,7 @@ function K({ name: e, size: t, children: n }) {
|
|
|
450
633
|
children: n
|
|
451
634
|
});
|
|
452
635
|
}
|
|
453
|
-
function
|
|
636
|
+
function it({ size: e = 26 }) {
|
|
454
637
|
return /* @__PURE__ */ G(K, {
|
|
455
638
|
name: "chat",
|
|
456
639
|
size: e,
|
|
@@ -460,62 +643,96 @@ function je({ size: e = 26 }) {
|
|
|
460
643
|
})]
|
|
461
644
|
});
|
|
462
645
|
}
|
|
463
|
-
function
|
|
646
|
+
function at({ size: e = 26 }) {
|
|
647
|
+
return /* @__PURE__ */ G(K, {
|
|
648
|
+
name: "message",
|
|
649
|
+
size: e,
|
|
650
|
+
children: /* @__PURE__ */ G("path", { d: "M21 11.5a8.5 8.5 0 0 1-12.4 7.5L3 20.5l1.6-5.1A8.5 8.5 0 1 1 21 11.5z" })
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
function ot({ size: e = 26 }) {
|
|
654
|
+
return /* @__PURE__ */ G(K, {
|
|
655
|
+
name: "sparkle",
|
|
656
|
+
size: e,
|
|
657
|
+
children: [/* @__PURE__ */ G("path", { d: "M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z" }), /* @__PURE__ */ G("path", { d: "M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z" })]
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
function st({ size: e = 26 }) {
|
|
464
661
|
return /* @__PURE__ */ G(K, {
|
|
465
662
|
name: "chevron-down",
|
|
466
663
|
size: e,
|
|
467
664
|
children: /* @__PURE__ */ G("path", { d: "M6 9l6 6 6-6" })
|
|
468
665
|
});
|
|
469
666
|
}
|
|
470
|
-
function
|
|
667
|
+
function ct({ size: e = 18 }) {
|
|
471
668
|
return /* @__PURE__ */ G(K, {
|
|
472
669
|
name: "close",
|
|
473
670
|
size: e,
|
|
474
671
|
children: /* @__PURE__ */ G("path", { d: "M6 6l12 12M18 6L6 18" })
|
|
475
672
|
});
|
|
476
673
|
}
|
|
477
|
-
var
|
|
478
|
-
function
|
|
674
|
+
var lt = "M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7";
|
|
675
|
+
function ut({ size: e = 16 }) {
|
|
479
676
|
return /* @__PURE__ */ G(K, {
|
|
480
677
|
name: "thumb-up",
|
|
481
678
|
size: e,
|
|
482
|
-
children: /* @__PURE__ */ G("path", { d:
|
|
679
|
+
children: /* @__PURE__ */ G("path", { d: lt })
|
|
483
680
|
});
|
|
484
681
|
}
|
|
485
|
-
function
|
|
682
|
+
function dt({ size: e = 16 }) {
|
|
486
683
|
return /* @__PURE__ */ G(K, {
|
|
487
684
|
name: "thumb-down",
|
|
488
685
|
size: e,
|
|
489
686
|
children: /* @__PURE__ */ G("path", {
|
|
490
|
-
d:
|
|
687
|
+
d: lt,
|
|
491
688
|
transform: "matrix(1 0 0 -1 0 24)"
|
|
492
689
|
})
|
|
493
690
|
});
|
|
494
691
|
}
|
|
495
692
|
//#endregion
|
|
496
693
|
//#region src/components/Launcher.tsx
|
|
497
|
-
|
|
498
|
-
|
|
694
|
+
var ft = {
|
|
695
|
+
chat: it,
|
|
696
|
+
message: at,
|
|
697
|
+
sparkle: ot
|
|
698
|
+
}, pt = {
|
|
699
|
+
"chevron-down": st,
|
|
700
|
+
close: ct
|
|
701
|
+
};
|
|
702
|
+
function mt({ isOpen: e, onClick: t, iconUrl: n, icon: r = "chat", openIconUrl: i, openIcon: a = "chevron-down", buttonRef: o }) {
|
|
703
|
+
let [s, c] = V("loading"), [l, u] = V("loading"), d = n !== void 0 && s !== "failed", f = i !== void 0 && l !== "failed", p = d && !e && s === "loaded", m = f && e && l === "loaded", h = ft[r] ?? it, g = pt[a] ?? st;
|
|
499
704
|
return /* @__PURE__ */ G("button", {
|
|
500
705
|
type: "button",
|
|
501
706
|
class: "whoo-widget-launcher",
|
|
502
707
|
onClick: t,
|
|
503
708
|
"aria-label": e ? "Close chat" : "Open chat",
|
|
504
|
-
ref:
|
|
505
|
-
children: [
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
709
|
+
ref: o,
|
|
710
|
+
children: [
|
|
711
|
+
e ? m ? null : /* @__PURE__ */ G(g, {}) : p ? null : /* @__PURE__ */ G(h, {}),
|
|
712
|
+
d ? /* @__PURE__ */ G("img", {
|
|
713
|
+
class: "whoo-widget-launcher-icon-image",
|
|
714
|
+
src: n,
|
|
715
|
+
alt: "",
|
|
716
|
+
referrerpolicy: "no-referrer",
|
|
717
|
+
hidden: !p,
|
|
718
|
+
onLoad: () => c("loaded"),
|
|
719
|
+
onError: () => c("failed")
|
|
720
|
+
}) : null,
|
|
721
|
+
f ? /* @__PURE__ */ G("img", {
|
|
722
|
+
class: "whoo-widget-launcher-icon-image",
|
|
723
|
+
src: i,
|
|
724
|
+
alt: "",
|
|
725
|
+
referrerpolicy: "no-referrer",
|
|
726
|
+
hidden: !m,
|
|
727
|
+
onLoad: () => u("loaded"),
|
|
728
|
+
onError: () => u("failed")
|
|
729
|
+
}) : null
|
|
730
|
+
]
|
|
514
731
|
});
|
|
515
732
|
}
|
|
516
733
|
//#endregion
|
|
517
734
|
//#region src/components/Composer.tsx
|
|
518
|
-
function
|
|
735
|
+
function ht({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
519
736
|
return /* @__PURE__ */ G("div", {
|
|
520
737
|
class: "whoo-widget-composer",
|
|
521
738
|
children: [
|
|
@@ -550,7 +767,7 @@ function Re({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
|
550
767
|
}
|
|
551
768
|
//#endregion
|
|
552
769
|
//#region src/components/ErrorBanner.tsx
|
|
553
|
-
function
|
|
770
|
+
function gt({ message: e }) {
|
|
554
771
|
return /* @__PURE__ */ G("div", {
|
|
555
772
|
class: "whoo-widget-error-banner",
|
|
556
773
|
role: "alert",
|
|
@@ -559,8 +776,8 @@ function ze({ message: e }) {
|
|
|
559
776
|
}
|
|
560
777
|
//#endregion
|
|
561
778
|
//#region src/markdown/tokenizer.ts
|
|
562
|
-
var
|
|
563
|
-
function
|
|
779
|
+
var _t = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, vt = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, yt = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, bt = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, xt = /[ \t]*[*+-][ \t]+/y, St = /https?:\/\/\S+/y, Ct = /[.,;:!?)\]}>]+$/;
|
|
780
|
+
function wt(e) {
|
|
564
781
|
let t = [], n = 0, r = 0, i = (n) => {
|
|
565
782
|
n > r && t.push({
|
|
566
783
|
type: "text",
|
|
@@ -570,13 +787,13 @@ function Ue(e) {
|
|
|
570
787
|
});
|
|
571
788
|
};
|
|
572
789
|
for (; n < e.length;) {
|
|
573
|
-
if ((n === 0 || e[n - 1] === "\n") && (
|
|
790
|
+
if ((n === 0 || e[n - 1] === "\n") && (xt.lastIndex = n, xt.exec(e))) {
|
|
574
791
|
i(n), t.push({
|
|
575
792
|
type: "text",
|
|
576
793
|
value: "• ",
|
|
577
794
|
start: n,
|
|
578
|
-
end:
|
|
579
|
-
}), n =
|
|
795
|
+
end: xt.lastIndex
|
|
796
|
+
}), n = xt.lastIndex, r = n;
|
|
580
797
|
continue;
|
|
581
798
|
}
|
|
582
799
|
if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
|
|
@@ -589,56 +806,56 @@ function Ue(e) {
|
|
|
589
806
|
}
|
|
590
807
|
}
|
|
591
808
|
if (e[n - 1] !== "!") {
|
|
592
|
-
|
|
593
|
-
let a =
|
|
809
|
+
_t.lastIndex = n;
|
|
810
|
+
let a = _t.exec(e);
|
|
594
811
|
if (a) {
|
|
595
812
|
i(n), t.push({
|
|
596
813
|
type: "link",
|
|
597
814
|
text: a[1],
|
|
598
815
|
url: a[2],
|
|
599
816
|
start: n,
|
|
600
|
-
end:
|
|
601
|
-
}), n =
|
|
817
|
+
end: _t.lastIndex
|
|
818
|
+
}), n = _t.lastIndex, r = n;
|
|
602
819
|
continue;
|
|
603
820
|
}
|
|
604
821
|
}
|
|
605
|
-
|
|
606
|
-
let a =
|
|
822
|
+
vt.lastIndex = n;
|
|
823
|
+
let a = vt.exec(e);
|
|
607
824
|
if (a) {
|
|
608
825
|
i(n), t.push({
|
|
609
826
|
type: "bold",
|
|
610
827
|
value: a[1],
|
|
611
828
|
start: n,
|
|
612
|
-
end:
|
|
613
|
-
}), n =
|
|
829
|
+
end: vt.lastIndex
|
|
830
|
+
}), n = vt.lastIndex, r = n;
|
|
614
831
|
continue;
|
|
615
832
|
}
|
|
616
|
-
|
|
617
|
-
let o =
|
|
833
|
+
yt.lastIndex = n;
|
|
834
|
+
let o = yt.exec(e);
|
|
618
835
|
if (o) {
|
|
619
836
|
i(n), t.push({
|
|
620
837
|
type: "italic",
|
|
621
838
|
value: o[1],
|
|
622
839
|
start: n,
|
|
623
|
-
end:
|
|
624
|
-
}), n =
|
|
840
|
+
end: yt.lastIndex
|
|
841
|
+
}), n = yt.lastIndex, r = n;
|
|
625
842
|
continue;
|
|
626
843
|
}
|
|
627
|
-
|
|
628
|
-
let s =
|
|
844
|
+
bt.lastIndex = n;
|
|
845
|
+
let s = bt.exec(e);
|
|
629
846
|
if (s) {
|
|
630
847
|
i(n), t.push({
|
|
631
848
|
type: "italic",
|
|
632
849
|
value: s[1],
|
|
633
850
|
start: n,
|
|
634
|
-
end:
|
|
635
|
-
}), n =
|
|
851
|
+
end: bt.lastIndex
|
|
852
|
+
}), n = bt.lastIndex, r = n;
|
|
636
853
|
continue;
|
|
637
854
|
}
|
|
638
|
-
|
|
639
|
-
let c =
|
|
855
|
+
St.lastIndex = n;
|
|
856
|
+
let c = St.exec(e);
|
|
640
857
|
if (c) {
|
|
641
|
-
let e = c[0].match(
|
|
858
|
+
let e = c[0].match(Ct), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
|
|
642
859
|
if (a.length > 0) {
|
|
643
860
|
i(n), t.push({
|
|
644
861
|
type: "link",
|
|
@@ -656,8 +873,8 @@ function Ue(e) {
|
|
|
656
873
|
}
|
|
657
874
|
//#endregion
|
|
658
875
|
//#region src/markdown/render.tsx
|
|
659
|
-
var
|
|
660
|
-
function
|
|
876
|
+
var Tt = /^[ \t]*[*+-][ \t]+(.*)$/;
|
|
877
|
+
function Et(e) {
|
|
661
878
|
let t = [], n = [], r = [], i = () => {
|
|
662
879
|
n.length > 0 && t.push({
|
|
663
880
|
type: "text",
|
|
@@ -670,7 +887,7 @@ function Ge(e) {
|
|
|
670
887
|
}), r = [];
|
|
671
888
|
};
|
|
672
889
|
for (let t of e.split("\n")) {
|
|
673
|
-
let e = t.match(
|
|
890
|
+
let e = t.match(Tt);
|
|
674
891
|
e ? (i(), r.push(e[1])) : (a(), n.push(t));
|
|
675
892
|
}
|
|
676
893
|
return i(), a(), t.some((e) => e.type === "list") ? t.flatMap((e, n) => {
|
|
@@ -682,11 +899,11 @@ function Ge(e) {
|
|
|
682
899
|
}];
|
|
683
900
|
}) : null;
|
|
684
901
|
}
|
|
685
|
-
function
|
|
686
|
-
return
|
|
902
|
+
function q(e) {
|
|
903
|
+
return wt(e).map((e, t) => {
|
|
687
904
|
switch (e.type) {
|
|
688
|
-
case "bold": return /* @__PURE__ */ G("strong", { children:
|
|
689
|
-
case "italic": return /* @__PURE__ */ G("em", { children:
|
|
905
|
+
case "bold": return /* @__PURE__ */ G("strong", { children: q(e.value) }, t);
|
|
906
|
+
case "italic": return /* @__PURE__ */ G("em", { children: q(e.value) }, t);
|
|
690
907
|
case "link": return /* @__PURE__ */ G("a", {
|
|
691
908
|
href: e.url,
|
|
692
909
|
target: "_blank",
|
|
@@ -700,16 +917,16 @@ function Z(e) {
|
|
|
700
917
|
}
|
|
701
918
|
});
|
|
702
919
|
}
|
|
703
|
-
function
|
|
704
|
-
let t = e.replace(/\r\n?/g, "\n"), n =
|
|
920
|
+
function Dt(e) {
|
|
921
|
+
let t = e.replace(/\r\n?/g, "\n"), n = Et(t);
|
|
705
922
|
return n ? n.map((e, t) => e.type === "list" ? /* @__PURE__ */ G("ul", {
|
|
706
923
|
class: "whoo-widget-list",
|
|
707
|
-
children: e.items.map((e, t) => /* @__PURE__ */ G("li", { children:
|
|
708
|
-
}, t) : /* @__PURE__ */ G("span", { children:
|
|
924
|
+
children: e.items.map((e, t) => /* @__PURE__ */ G("li", { children: q(e) }, t))
|
|
925
|
+
}, t) : /* @__PURE__ */ G("span", { children: q(e.text) }, t)) : q(t);
|
|
709
926
|
}
|
|
710
927
|
//#endregion
|
|
711
928
|
//#region src/components/MessageFeedback.tsx
|
|
712
|
-
var
|
|
929
|
+
var Ot = [
|
|
713
930
|
{
|
|
714
931
|
value: "",
|
|
715
932
|
label: "Select a reason (optional)"
|
|
@@ -731,7 +948,7 @@ var qe = [
|
|
|
731
948
|
label: "Other"
|
|
732
949
|
}
|
|
733
950
|
];
|
|
734
|
-
function
|
|
951
|
+
function kt({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraftChange: i, onSubmitDetailed: a, onCancel: o }) {
|
|
735
952
|
let s = e.correction ?? "", c = e.category ?? "", l = U(e.status);
|
|
736
953
|
if (H(() => {
|
|
737
954
|
let n = l.current;
|
|
@@ -757,7 +974,7 @@ function Je({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraft
|
|
|
757
974
|
"aria-label": "Feedback category",
|
|
758
975
|
value: c,
|
|
759
976
|
onChange: (e) => i(s, e.target.value),
|
|
760
|
-
children:
|
|
977
|
+
children: Ot.map((e) => /* @__PURE__ */ G("option", {
|
|
761
978
|
value: e.value,
|
|
762
979
|
children: e.label
|
|
763
980
|
}, e.value))
|
|
@@ -788,13 +1005,13 @@ function Je({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraft
|
|
|
788
1005
|
"aria-label": "Good response",
|
|
789
1006
|
disabled: u,
|
|
790
1007
|
onClick: n,
|
|
791
|
-
children: /* @__PURE__ */ G(
|
|
1008
|
+
children: /* @__PURE__ */ G(ut, {})
|
|
792
1009
|
}), /* @__PURE__ */ G("button", {
|
|
793
1010
|
type: "button",
|
|
794
1011
|
"aria-label": "Bad response",
|
|
795
1012
|
disabled: u,
|
|
796
1013
|
onClick: r,
|
|
797
|
-
children: /* @__PURE__ */ G(
|
|
1014
|
+
children: /* @__PURE__ */ G(dt, {})
|
|
798
1015
|
})]
|
|
799
1016
|
}), /* @__PURE__ */ G("div", {
|
|
800
1017
|
role: "status",
|
|
@@ -805,7 +1022,7 @@ function Je({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraft
|
|
|
805
1022
|
}
|
|
806
1023
|
//#endregion
|
|
807
1024
|
//#region src/components/MessageList.tsx
|
|
808
|
-
function
|
|
1025
|
+
function At({ isSlowResponse: e }) {
|
|
809
1026
|
return /* @__PURE__ */ G("div", {
|
|
810
1027
|
class: "whoo-widget-pending",
|
|
811
1028
|
role: "status",
|
|
@@ -823,8 +1040,8 @@ function Ye({ isSlowResponse: e }) {
|
|
|
823
1040
|
}) : null]
|
|
824
1041
|
});
|
|
825
1042
|
}
|
|
826
|
-
function
|
|
827
|
-
let [n, r] =
|
|
1043
|
+
function jt({ url: e, alt: t }) {
|
|
1044
|
+
let [n, r] = V(!1);
|
|
828
1045
|
return n ? null : /* @__PURE__ */ G("img", {
|
|
829
1046
|
class: "whoo-widget-empty-state-image",
|
|
830
1047
|
src: e,
|
|
@@ -833,7 +1050,7 @@ function Xe({ url: e, alt: t }) {
|
|
|
833
1050
|
onError: () => r(!0)
|
|
834
1051
|
});
|
|
835
1052
|
}
|
|
836
|
-
function
|
|
1053
|
+
function Mt({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u }) {
|
|
837
1054
|
let d = U(null), f = e.id;
|
|
838
1055
|
return /* @__PURE__ */ G("div", {
|
|
839
1056
|
ref: d,
|
|
@@ -844,8 +1061,8 @@ function Ze({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending
|
|
|
844
1061
|
class: "whoo-widget-sr-only",
|
|
845
1062
|
children: [t, ": "]
|
|
846
1063
|
}),
|
|
847
|
-
i ? /* @__PURE__ */ G(
|
|
848
|
-
r && e.role === "assistant" && f ? /* @__PURE__ */ G(
|
|
1064
|
+
i ? /* @__PURE__ */ G(At, { isSlowResponse: a }) : Dt(e.content),
|
|
1065
|
+
r && e.role === "assistant" && f ? /* @__PURE__ */ G(kt, {
|
|
849
1066
|
state: n,
|
|
850
1067
|
containerRef: d,
|
|
851
1068
|
onThumbsUp: () => o(f),
|
|
@@ -857,28 +1074,28 @@ function Ze({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending
|
|
|
857
1074
|
]
|
|
858
1075
|
});
|
|
859
1076
|
}
|
|
860
|
-
function
|
|
861
|
-
let
|
|
1077
|
+
function Nt({ messages: e, messageFeedback: t, announcement: n, emptyStateImage: r, agentName: i = s, showFeedback: a = !1, isStreaming: o = !1, isSlowResponse: c = !1, onThumbsUp: l, onThumbsDown: u, onDraftChange: d = () => {}, onSubmitDetailed: f, onCancelFeedback: p }) {
|
|
1078
|
+
let m = U(null);
|
|
862
1079
|
return H(() => {
|
|
863
|
-
let e =
|
|
1080
|
+
let e = m.current;
|
|
864
1081
|
e && (e.scrollTop = e.scrollHeight);
|
|
865
|
-
}, [e,
|
|
1082
|
+
}, [e, c]), /* @__PURE__ */ G(F, { children: [/* @__PURE__ */ G("section", {
|
|
866
1083
|
class: "whoo-widget-message-list",
|
|
867
|
-
ref:
|
|
1084
|
+
ref: m,
|
|
868
1085
|
"aria-label": "Conversation",
|
|
869
1086
|
tabIndex: 0,
|
|
870
|
-
children: [r ? /* @__PURE__ */ G(
|
|
1087
|
+
children: [r ? /* @__PURE__ */ G(jt, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ G(Mt, {
|
|
871
1088
|
message: n,
|
|
872
1089
|
speaker: n.role === "user" ? "You" : i,
|
|
873
1090
|
showFeedback: a,
|
|
874
1091
|
feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
|
|
875
1092
|
pending: o && r === e.length - 1 && n.role === "assistant" && n.content === "",
|
|
876
|
-
isSlowResponse:
|
|
877
|
-
onThumbsUp:
|
|
878
|
-
onThumbsDown:
|
|
879
|
-
onDraftChange:
|
|
880
|
-
onSubmitDetailed:
|
|
881
|
-
onCancelFeedback:
|
|
1093
|
+
isSlowResponse: c,
|
|
1094
|
+
onThumbsUp: l,
|
|
1095
|
+
onThumbsDown: u,
|
|
1096
|
+
onDraftChange: d,
|
|
1097
|
+
onSubmitDetailed: f,
|
|
1098
|
+
onCancelFeedback: p
|
|
882
1099
|
}, n.id ?? r))]
|
|
883
1100
|
}), /* @__PURE__ */ G("div", {
|
|
884
1101
|
class: "whoo-widget-sr-only",
|
|
@@ -889,38 +1106,38 @@ function Qe({ messages: e, messageFeedback: t, announcement: n, emptyStateImage:
|
|
|
889
1106
|
}
|
|
890
1107
|
//#endregion
|
|
891
1108
|
//#region src/components/Panel.tsx
|
|
892
|
-
var
|
|
893
|
-
function
|
|
894
|
-
return Array.from(e.querySelectorAll(
|
|
1109
|
+
var Pt = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
|
|
1110
|
+
function Ft(e) {
|
|
1111
|
+
return Array.from(e.querySelectorAll(Pt)).filter((e) => {
|
|
895
1112
|
let t = getComputedStyle(e);
|
|
896
1113
|
return t.display !== "none" && t.visibility !== "hidden";
|
|
897
1114
|
});
|
|
898
1115
|
}
|
|
899
|
-
function
|
|
900
|
-
let
|
|
1116
|
+
function It({ state: e, controller: t, greeting: n }) {
|
|
1117
|
+
let r = U(null), i = U(null);
|
|
901
1118
|
H(() => {
|
|
902
|
-
|
|
1119
|
+
i.current?.focus();
|
|
903
1120
|
}, []);
|
|
904
|
-
let
|
|
1121
|
+
let a = (e) => {
|
|
905
1122
|
if (e.key === "Escape") {
|
|
906
1123
|
t.close();
|
|
907
1124
|
return;
|
|
908
1125
|
}
|
|
909
1126
|
if (e.key !== "Tab") return;
|
|
910
|
-
let n =
|
|
1127
|
+
let n = r.current;
|
|
911
1128
|
if (!n) return;
|
|
912
|
-
let
|
|
913
|
-
if (
|
|
914
|
-
let a =
|
|
1129
|
+
let i = Ft(n);
|
|
1130
|
+
if (i.length === 0) return;
|
|
1131
|
+
let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
|
|
915
1132
|
if (!n.contains(s)) {
|
|
916
1133
|
e.preventDefault(), a.focus();
|
|
917
1134
|
return;
|
|
918
1135
|
}
|
|
919
1136
|
e.shiftKey && s === a ? (e.preventDefault(), o.focus()) : !e.shiftKey && s === o && (e.preventDefault(), a.focus());
|
|
920
|
-
},
|
|
1137
|
+
}, o = () => {
|
|
921
1138
|
let n = e.draft.trim();
|
|
922
1139
|
n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
|
|
923
|
-
},
|
|
1140
|
+
}, s = c(t.config.name) || e.agentName || "Aiden", l = `Chat with ${s}`, u = e.messages.length === 0 && n ? [{
|
|
924
1141
|
role: "assistant",
|
|
925
1142
|
content: n,
|
|
926
1143
|
id: null
|
|
@@ -933,8 +1150,8 @@ function tt({ state: e, controller: t, greeting: n }) {
|
|
|
933
1150
|
role: "dialog",
|
|
934
1151
|
"aria-modal": "true",
|
|
935
1152
|
"aria-label": l,
|
|
936
|
-
ref:
|
|
937
|
-
onKeyDown:
|
|
1153
|
+
ref: r,
|
|
1154
|
+
onKeyDown: a,
|
|
938
1155
|
children: [
|
|
939
1156
|
/* @__PURE__ */ G("div", {
|
|
940
1157
|
class: "whoo-widget-header",
|
|
@@ -947,7 +1164,7 @@ function tt({ state: e, controller: t, greeting: n }) {
|
|
|
947
1164
|
type: "button",
|
|
948
1165
|
class: "whoo-widget-header-reset",
|
|
949
1166
|
onClick: () => {
|
|
950
|
-
t.resetConversation(),
|
|
1167
|
+
t.resetConversation(), i.current?.focus();
|
|
951
1168
|
},
|
|
952
1169
|
children: "New conversation"
|
|
953
1170
|
}), /* @__PURE__ */ G("button", {
|
|
@@ -955,16 +1172,16 @@ function tt({ state: e, controller: t, greeting: n }) {
|
|
|
955
1172
|
class: "whoo-widget-header-close",
|
|
956
1173
|
"aria-label": "Close chat",
|
|
957
1174
|
onClick: () => t.close(),
|
|
958
|
-
children: /* @__PURE__ */ G(
|
|
1175
|
+
children: /* @__PURE__ */ G(ct, {})
|
|
959
1176
|
})]
|
|
960
1177
|
})]
|
|
961
1178
|
}),
|
|
962
|
-
/* @__PURE__ */ G(
|
|
1179
|
+
/* @__PURE__ */ G(Nt, {
|
|
963
1180
|
messages: u,
|
|
964
1181
|
messageFeedback: e.messageFeedback,
|
|
965
1182
|
announcement: e.announcement,
|
|
966
1183
|
emptyStateImage: f,
|
|
967
|
-
agentName:
|
|
1184
|
+
agentName: s,
|
|
968
1185
|
showFeedback: t.showFeedback,
|
|
969
1186
|
isStreaming: e.isStreaming,
|
|
970
1187
|
isSlowResponse: e.isSlowResponse,
|
|
@@ -974,29 +1191,32 @@ function tt({ state: e, controller: t, greeting: n }) {
|
|
|
974
1191
|
onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
|
|
975
1192
|
onCancelFeedback: (e) => t.cancelFeedback(e)
|
|
976
1193
|
}),
|
|
977
|
-
e.runtimeError && /* @__PURE__ */ G(
|
|
978
|
-
/* @__PURE__ */ G(
|
|
1194
|
+
e.runtimeError && /* @__PURE__ */ G(gt, { message: e.runtimeError }),
|
|
1195
|
+
/* @__PURE__ */ G(ht, {
|
|
979
1196
|
value: e.draft,
|
|
980
1197
|
onChange: (e) => t.setDraft(e),
|
|
981
|
-
onSend:
|
|
1198
|
+
onSend: o,
|
|
982
1199
|
disabled: e.isStreaming,
|
|
983
|
-
inputRef:
|
|
1200
|
+
inputRef: i
|
|
984
1201
|
})
|
|
985
1202
|
]
|
|
986
1203
|
});
|
|
987
1204
|
}
|
|
988
1205
|
//#endregion
|
|
989
1206
|
//#region src/components/App.tsx
|
|
990
|
-
function
|
|
991
|
-
let [t, n] =
|
|
1207
|
+
function Lt({ controller: e }) {
|
|
1208
|
+
let [t, n] = V(e.getState()), r = U(null), i = U(t.isOpen);
|
|
992
1209
|
return H(() => (n(e.getState()), e.subscribe(n)), [e]), H(() => {
|
|
993
1210
|
i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
|
|
994
|
-
}, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ G(
|
|
1211
|
+
}, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ G(F, { children: [/* @__PURE__ */ G(mt, {
|
|
995
1212
|
isOpen: t.isOpen,
|
|
996
1213
|
onClick: () => t.isOpen ? e.close() : e.open(),
|
|
997
|
-
iconUrl: e.
|
|
1214
|
+
iconUrl: e.launcher.iconUrl,
|
|
1215
|
+
icon: e.launcher.icon,
|
|
1216
|
+
openIconUrl: e.launcher.openIconUrl,
|
|
1217
|
+
openIcon: e.launcher.openIcon,
|
|
998
1218
|
buttonRef: r
|
|
999
|
-
}), t.isOpen && /* @__PURE__ */ G(
|
|
1219
|
+
}), t.isOpen && /* @__PURE__ */ G(It, {
|
|
1000
1220
|
state: t,
|
|
1001
1221
|
controller: e,
|
|
1002
1222
|
greeting: e.config.greeting
|
|
@@ -1004,44 +1224,44 @@ function nt({ controller: e }) {
|
|
|
1004
1224
|
}
|
|
1005
1225
|
//#endregion
|
|
1006
1226
|
//#region src/api/client.ts
|
|
1007
|
-
var
|
|
1227
|
+
var Rt = class extends Error {
|
|
1008
1228
|
status;
|
|
1009
1229
|
constructor(e, t) {
|
|
1010
1230
|
super(e), this.name = "WidgetApiError", this.status = t;
|
|
1011
1231
|
}
|
|
1012
1232
|
};
|
|
1013
|
-
function
|
|
1233
|
+
function zt(e) {
|
|
1014
1234
|
if (typeof e != "string") return null;
|
|
1015
1235
|
let t = e.trim();
|
|
1016
1236
|
return t === "" ? null : t;
|
|
1017
1237
|
}
|
|
1018
|
-
async function
|
|
1238
|
+
async function Bt(e, t) {
|
|
1019
1239
|
let n = await fetch(`${e}/api/v1/widget/session`, {
|
|
1020
1240
|
method: "POST",
|
|
1021
1241
|
headers: { "Content-Type": "application/json" },
|
|
1022
1242
|
body: JSON.stringify({ publishable_key: t })
|
|
1023
1243
|
});
|
|
1024
|
-
if (!n.ok) throw new
|
|
1244
|
+
if (!n.ok) throw new Rt(`Failed to create widget session (${n.status})`, n.status);
|
|
1025
1245
|
let r = await n.json();
|
|
1026
1246
|
return {
|
|
1027
1247
|
token: r.token,
|
|
1028
|
-
...
|
|
1248
|
+
...Vt(r)
|
|
1029
1249
|
};
|
|
1030
1250
|
}
|
|
1031
|
-
function
|
|
1251
|
+
function Vt(e) {
|
|
1032
1252
|
return {
|
|
1033
|
-
primaryColor:
|
|
1034
|
-
name:
|
|
1035
|
-
accentColor:
|
|
1036
|
-
inkColor:
|
|
1253
|
+
primaryColor: zt(e.primary_color),
|
|
1254
|
+
name: zt(e.name),
|
|
1255
|
+
accentColor: zt(e.accent_color),
|
|
1256
|
+
inkColor: zt(e.ink_color)
|
|
1037
1257
|
};
|
|
1038
1258
|
}
|
|
1039
|
-
async function
|
|
1259
|
+
async function Ht(e, t) {
|
|
1040
1260
|
let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
|
|
1041
|
-
if (!n.ok) throw new
|
|
1042
|
-
return
|
|
1261
|
+
if (!n.ok) throw new Rt(`Failed to load widget branding (${n.status})`, n.status);
|
|
1262
|
+
return Vt(await n.json());
|
|
1043
1263
|
}
|
|
1044
|
-
async function
|
|
1264
|
+
async function Ut(e, t, n) {
|
|
1045
1265
|
let r = await fetch(`${e}/api/v1/widget/feedback`, {
|
|
1046
1266
|
method: "POST",
|
|
1047
1267
|
headers: {
|
|
@@ -1055,11 +1275,11 @@ async function ct(e, t, n) {
|
|
|
1055
1275
|
category: n.category ?? null
|
|
1056
1276
|
})
|
|
1057
1277
|
});
|
|
1058
|
-
if (!r.ok) throw new
|
|
1278
|
+
if (!r.ok) throw new Rt(`Feedback submission failed (${r.status})`, r.status);
|
|
1059
1279
|
}
|
|
1060
1280
|
//#endregion
|
|
1061
1281
|
//#region src/api/sse.ts
|
|
1062
|
-
async function*
|
|
1282
|
+
async function* Wt(e, t, n, r, i) {
|
|
1063
1283
|
let a = await fetch(`${e}/api/v1/widget/chat`, {
|
|
1064
1284
|
method: "POST",
|
|
1065
1285
|
headers: {
|
|
@@ -1072,7 +1292,7 @@ async function* lt(e, t, n, r, i) {
|
|
|
1072
1292
|
}),
|
|
1073
1293
|
signal: i
|
|
1074
1294
|
});
|
|
1075
|
-
if (!a.ok || !a.body) throw new
|
|
1295
|
+
if (!a.ok || !a.body) throw new Rt(`Chat request failed (${a.status})`, a.status);
|
|
1076
1296
|
let o = a.body.getReader(), s = new TextDecoder(), c = "";
|
|
1077
1297
|
for (;;) {
|
|
1078
1298
|
let { done: e, value: t } = await o.read();
|
|
@@ -1083,11 +1303,11 @@ async function* lt(e, t, n, r, i) {
|
|
|
1083
1303
|
let e = c.slice(0, n);
|
|
1084
1304
|
c = c.slice(n + 2);
|
|
1085
1305
|
let t = e.split("\n").find((e) => e.startsWith("data: "));
|
|
1086
|
-
t && (yield
|
|
1306
|
+
t && (yield Gt(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
|
|
1087
1307
|
}
|
|
1088
1308
|
}
|
|
1089
1309
|
}
|
|
1090
|
-
function
|
|
1310
|
+
function Gt(e) {
|
|
1091
1311
|
return typeof e.error == "string" ? {
|
|
1092
1312
|
type: "error",
|
|
1093
1313
|
error: e.error,
|
|
@@ -1109,23 +1329,12 @@ function ut(e) {
|
|
|
1109
1329
|
};
|
|
1110
1330
|
}
|
|
1111
1331
|
//#endregion
|
|
1112
|
-
//#region src/imageUrl.ts
|
|
1113
|
-
function dt(e, t) {
|
|
1114
|
-
if (e != null && e !== "") {
|
|
1115
|
-
if (typeof e == "string") try {
|
|
1116
|
-
let t = new URL(e);
|
|
1117
|
-
if (t.protocol === "https:" || t.protocol === "data:" && t.pathname.toLowerCase().startsWith("image/")) return e;
|
|
1118
|
-
} catch {}
|
|
1119
|
-
console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`);
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
//#endregion
|
|
1123
1332
|
//#region src/markdown/plainText.ts
|
|
1124
|
-
function
|
|
1125
|
-
return
|
|
1333
|
+
function Kt(e) {
|
|
1334
|
+
return wt(e.replace(/\r\n?/g, "\n")).map((e) => {
|
|
1126
1335
|
switch (e.type) {
|
|
1127
1336
|
case "bold":
|
|
1128
|
-
case "italic": return
|
|
1337
|
+
case "italic": return Kt(e.value);
|
|
1129
1338
|
case "link": return e.text;
|
|
1130
1339
|
default: return e.value;
|
|
1131
1340
|
}
|
|
@@ -1133,16 +1342,16 @@ function ft(e) {
|
|
|
1133
1342
|
}
|
|
1134
1343
|
//#endregion
|
|
1135
1344
|
//#region src/markdown/reveal.ts
|
|
1136
|
-
var
|
|
1137
|
-
function
|
|
1345
|
+
var qt = 40, Jt = 120;
|
|
1346
|
+
function Yt(e) {
|
|
1138
1347
|
let t = [];
|
|
1139
|
-
for (let n of
|
|
1348
|
+
for (let n of wt(e)) if (n.type === "text") {
|
|
1140
1349
|
let e = n.value.split(/(\s+)/), r = n.start;
|
|
1141
1350
|
for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
|
|
1142
1351
|
} else t.push(n.end);
|
|
1143
1352
|
return t;
|
|
1144
1353
|
}
|
|
1145
|
-
function
|
|
1354
|
+
function Xt(e) {
|
|
1146
1355
|
let t = null;
|
|
1147
1356
|
return e?.addEventListener("abort", () => {
|
|
1148
1357
|
t?.();
|
|
@@ -1157,14 +1366,14 @@ function gt(e) {
|
|
|
1157
1366
|
});
|
|
1158
1367
|
};
|
|
1159
1368
|
}
|
|
1160
|
-
async function
|
|
1161
|
-
let r = n?.wordIntervalMs ??
|
|
1162
|
-
for (let n of
|
|
1369
|
+
async function Zt(e, t, n) {
|
|
1370
|
+
let r = n?.wordIntervalMs ?? qt, i = n?.tokenIntervalMs ?? Jt, a = n?.signal, o = wt(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = Xt(a), l = "";
|
|
1371
|
+
for (let n of Yt(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
|
|
1163
1372
|
l !== e && t(e);
|
|
1164
1373
|
}
|
|
1165
1374
|
//#endregion
|
|
1166
1375
|
//#region src/sessionToken.ts
|
|
1167
|
-
function
|
|
1376
|
+
function Qt(e, t = Date.now()) {
|
|
1168
1377
|
let n = e.split(".");
|
|
1169
1378
|
if (n.length !== 3 || n.some((e) => e === "")) return !1;
|
|
1170
1379
|
let r = n[1];
|
|
@@ -1177,31 +1386,31 @@ function vt(e, t = Date.now()) {
|
|
|
1177
1386
|
}
|
|
1178
1387
|
//#endregion
|
|
1179
1388
|
//#region src/storage.ts
|
|
1180
|
-
function
|
|
1389
|
+
function $t(e) {
|
|
1181
1390
|
return `whoo-aiden-widget:conversation:${e}`;
|
|
1182
1391
|
}
|
|
1183
|
-
function
|
|
1392
|
+
function en(e) {
|
|
1184
1393
|
try {
|
|
1185
|
-
return window.sessionStorage.getItem(
|
|
1394
|
+
return window.sessionStorage.getItem($t(e));
|
|
1186
1395
|
} catch {
|
|
1187
1396
|
return null;
|
|
1188
1397
|
}
|
|
1189
1398
|
}
|
|
1190
|
-
function
|
|
1399
|
+
function tn(e, t) {
|
|
1191
1400
|
try {
|
|
1192
|
-
window.sessionStorage.setItem(
|
|
1401
|
+
window.sessionStorage.setItem($t(e), t);
|
|
1193
1402
|
} catch {}
|
|
1194
1403
|
}
|
|
1195
|
-
function
|
|
1404
|
+
function nn(e) {
|
|
1196
1405
|
try {
|
|
1197
|
-
window.sessionStorage.removeItem(
|
|
1406
|
+
window.sessionStorage.removeItem($t(e));
|
|
1198
1407
|
} catch {}
|
|
1199
1408
|
}
|
|
1200
1409
|
//#endregion
|
|
1201
1410
|
//#region src/theme.ts
|
|
1202
|
-
var
|
|
1203
|
-
function
|
|
1204
|
-
if (
|
|
1411
|
+
var rn = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
|
|
1412
|
+
function an(e) {
|
|
1413
|
+
if (rn.test(e.trim())) return null;
|
|
1205
1414
|
let t = document.createElement("div");
|
|
1206
1415
|
if (t.style.color = e, t.style.color === "") return null;
|
|
1207
1416
|
let n = document.createElement("div");
|
|
@@ -1220,105 +1429,216 @@ function wt(e) {
|
|
|
1220
1429
|
translucent: a < 1
|
|
1221
1430
|
};
|
|
1222
1431
|
}
|
|
1223
|
-
function
|
|
1224
|
-
return
|
|
1432
|
+
function J(e) {
|
|
1433
|
+
return an(e)?.rgb ?? null;
|
|
1225
1434
|
}
|
|
1226
|
-
function
|
|
1435
|
+
function Y([e, t, n]) {
|
|
1227
1436
|
let r = (e) => {
|
|
1228
1437
|
let t = e / 255;
|
|
1229
1438
|
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
1230
1439
|
};
|
|
1231
1440
|
return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
|
|
1232
1441
|
}
|
|
1233
|
-
function
|
|
1442
|
+
function on(e, t) {
|
|
1234
1443
|
let n = Math.max(e, t), r = Math.min(e, t);
|
|
1235
1444
|
return (n + .05) / (r + .05);
|
|
1236
1445
|
}
|
|
1237
|
-
function
|
|
1238
|
-
let t =
|
|
1446
|
+
function sn(e) {
|
|
1447
|
+
let t = J(e);
|
|
1239
1448
|
if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
|
|
1240
|
-
let n =
|
|
1241
|
-
return
|
|
1449
|
+
let n = Y(t);
|
|
1450
|
+
return on(n, Y([
|
|
1242
1451
|
0,
|
|
1243
1452
|
0,
|
|
1244
1453
|
0
|
|
1245
|
-
])) >=
|
|
1454
|
+
])) >= on(n, Y([
|
|
1246
1455
|
255,
|
|
1247
1456
|
255,
|
|
1248
1457
|
255
|
|
1249
1458
|
])) ? "#000000" : "#ffffff";
|
|
1250
1459
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1460
|
+
function cn(e, t) {
|
|
1461
|
+
let n = J(e), r = J(t);
|
|
1462
|
+
return !n || !r ? NaN : on(Y(n), Y(r));
|
|
1463
|
+
}
|
|
1464
|
+
var ln = n.primary, un = n.panel, dn = n.assistantBubble, fn = n.headerHover, pn = 4.5;
|
|
1465
|
+
function mn([e, t, n]) {
|
|
1253
1466
|
return `#${[
|
|
1254
1467
|
e,
|
|
1255
1468
|
t,
|
|
1256
1469
|
n
|
|
1257
1470
|
].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
1258
1471
|
}
|
|
1259
|
-
function
|
|
1260
|
-
let n =
|
|
1261
|
-
if (!n || !r) return
|
|
1262
|
-
let i =
|
|
1263
|
-
if (a(n)) return
|
|
1472
|
+
function hn(e, t = un) {
|
|
1473
|
+
let n = J(e), r = J(t);
|
|
1474
|
+
if (!n || !r) return ln;
|
|
1475
|
+
let i = Y(r), a = (e) => on(Y(e), i) >= pn;
|
|
1476
|
+
if (a(n)) return mn(n);
|
|
1264
1477
|
for (let e = .99; e > 0; e -= .01) {
|
|
1265
1478
|
let t = n.map((t) => Math.round(t * e));
|
|
1266
|
-
if (a(t)) return
|
|
1479
|
+
if (a(t)) return mn(t);
|
|
1267
1480
|
}
|
|
1268
1481
|
return "#000000";
|
|
1269
1482
|
}
|
|
1270
|
-
var
|
|
1271
|
-
function
|
|
1483
|
+
var gn = n.ink, _n = n.link;
|
|
1484
|
+
function X(e) {
|
|
1272
1485
|
if (typeof e != "string" || !e) return null;
|
|
1273
|
-
let t =
|
|
1274
|
-
return t ?
|
|
1486
|
+
let t = an(e);
|
|
1487
|
+
return t ? mn(t.rgb) : null;
|
|
1275
1488
|
}
|
|
1276
|
-
function
|
|
1277
|
-
|
|
1489
|
+
function vn(e) {
|
|
1490
|
+
if (typeof e != "string" || !e) return null;
|
|
1491
|
+
let t = an(e);
|
|
1492
|
+
return t ? t.translucent ? e.trim() : mn(t.rgb) : null;
|
|
1493
|
+
}
|
|
1494
|
+
var yn = [
|
|
1495
|
+
{
|
|
1496
|
+
role: "onPrimary",
|
|
1497
|
+
against: ["primary"],
|
|
1498
|
+
required: 4.5
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
role: "primaryText",
|
|
1502
|
+
against: ["panel", "headerHover"],
|
|
1503
|
+
required: 4.5
|
|
1504
|
+
},
|
|
1505
|
+
{
|
|
1506
|
+
role: "ink",
|
|
1507
|
+
against: ["assistantBubble", "panel"],
|
|
1508
|
+
required: 4.5
|
|
1509
|
+
},
|
|
1510
|
+
{
|
|
1511
|
+
role: "link",
|
|
1512
|
+
against: ["assistantBubble"],
|
|
1513
|
+
required: 4.5
|
|
1514
|
+
},
|
|
1515
|
+
{
|
|
1516
|
+
role: "muted",
|
|
1517
|
+
against: ["assistantBubble"],
|
|
1518
|
+
required: 4.5
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
role: "text",
|
|
1522
|
+
against: ["panel", "assistantBubble"],
|
|
1523
|
+
required: 4.5
|
|
1524
|
+
},
|
|
1525
|
+
{
|
|
1526
|
+
role: "errorText",
|
|
1527
|
+
against: ["errorBackground"],
|
|
1528
|
+
required: 4.5
|
|
1529
|
+
},
|
|
1530
|
+
{
|
|
1531
|
+
role: "typingDots",
|
|
1532
|
+
against: ["assistantBubble"],
|
|
1533
|
+
required: 3
|
|
1534
|
+
},
|
|
1535
|
+
{
|
|
1536
|
+
role: "inputBorder",
|
|
1537
|
+
against: ["panel"],
|
|
1538
|
+
required: 3
|
|
1539
|
+
},
|
|
1540
|
+
{
|
|
1541
|
+
role: "focusRing",
|
|
1542
|
+
against: ["panel"],
|
|
1543
|
+
required: 3
|
|
1544
|
+
}
|
|
1545
|
+
];
|
|
1546
|
+
function Z({ color: e, inkColor: r, accentColor: i, overrides: a }) {
|
|
1547
|
+
let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => vn(o[e]), c = X(e), l = s("primary"), u = l ?? c ?? ln, d = s("primaryText"), f = d ?? hn(u, fn), p = s("onPrimary") ?? sn(u), m = X(r), h = s("ink") ?? (m ? hn(m, dn) : gn), g = X(i), _ = s("link") ?? (g ? hn(g, dn) : _n), v = (e) => s(e) ?? n[e], y = {
|
|
1548
|
+
primary: u,
|
|
1549
|
+
onPrimary: p,
|
|
1550
|
+
primaryText: f,
|
|
1551
|
+
ink: h,
|
|
1552
|
+
link: _,
|
|
1553
|
+
text: v("text"),
|
|
1554
|
+
panel: v("panel"),
|
|
1555
|
+
border: v("border"),
|
|
1556
|
+
headerHover: v("headerHover"),
|
|
1557
|
+
assistantBubble: v("assistantBubble"),
|
|
1558
|
+
muted: v("muted"),
|
|
1559
|
+
typingDots: v("typingDots"),
|
|
1560
|
+
errorBackground: v("errorBackground"),
|
|
1561
|
+
errorText: v("errorText"),
|
|
1562
|
+
inputBorder: v("inputBorder"),
|
|
1563
|
+
focusRing: v("focusRing")
|
|
1564
|
+
}, b = Object.fromEntries(t.map((e) => [e, s(e) !== null])), x = [];
|
|
1565
|
+
for (let { role: e, against: t, required: n } of yn) if (b[e]) for (let r of t) {
|
|
1566
|
+
let t = cn(y[e], y[r]);
|
|
1567
|
+
Number.isFinite(t) && t < n && x.push({
|
|
1568
|
+
role: e,
|
|
1569
|
+
against: r,
|
|
1570
|
+
value: y[e],
|
|
1571
|
+
ratio: t,
|
|
1572
|
+
required: n
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1278
1575
|
return {
|
|
1279
|
-
primary:
|
|
1280
|
-
textOnPrimary:
|
|
1281
|
-
primaryAsText:
|
|
1282
|
-
ink:
|
|
1283
|
-
link:
|
|
1576
|
+
primary: u,
|
|
1577
|
+
textOnPrimary: p,
|
|
1578
|
+
primaryAsText: f,
|
|
1579
|
+
ink: h,
|
|
1580
|
+
link: _,
|
|
1284
1581
|
adjusted: {
|
|
1285
|
-
primary:
|
|
1286
|
-
ink:
|
|
1287
|
-
link:
|
|
1288
|
-
}
|
|
1582
|
+
primary: l === null && d === null && c !== null && f !== u,
|
|
1583
|
+
ink: !b.ink && m !== null && h !== m,
|
|
1584
|
+
link: !b.link && g !== null && _ !== g
|
|
1585
|
+
},
|
|
1586
|
+
roles: y,
|
|
1587
|
+
overridden: b,
|
|
1588
|
+
contrastWarnings: x
|
|
1289
1589
|
};
|
|
1290
1590
|
}
|
|
1291
|
-
function
|
|
1591
|
+
function Q(e) {
|
|
1292
1592
|
return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
|
|
1293
1593
|
}
|
|
1294
|
-
function
|
|
1594
|
+
function bn(e, t, n = ln) {
|
|
1295
1595
|
let r = t;
|
|
1296
|
-
|
|
1297
|
-
let i =
|
|
1596
|
+
X(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as the theme color; falling back to ${Q(n)}.`), r = n);
|
|
1597
|
+
let i = Z({ color: r });
|
|
1298
1598
|
e.style.setProperty("--whoo-widget-color", i.primary), e.style.setProperty("--whoo-widget-text-on-color", i.textOnPrimary), e.style.setProperty("--whoo-widget-color-text", i.primaryAsText);
|
|
1299
1599
|
}
|
|
1300
|
-
function
|
|
1301
|
-
let r =
|
|
1600
|
+
function xn(e, { inkColor: t, accentColor: n }) {
|
|
1601
|
+
let r = Z({
|
|
1302
1602
|
inkColor: t,
|
|
1303
1603
|
accentColor: n
|
|
1304
1604
|
});
|
|
1305
1605
|
e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
|
|
1306
1606
|
}
|
|
1307
|
-
function
|
|
1308
|
-
|
|
1607
|
+
function Sn(e, n) {
|
|
1608
|
+
let i = Z({ overrides: n });
|
|
1609
|
+
for (let n of t) {
|
|
1610
|
+
let t = i.overridden.primary && (n === "onPrimary" || n === "primaryText");
|
|
1611
|
+
(i.overridden[n] || t) && e.style.setProperty(r[n], i.roles[n]);
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
function Cn(e, t) {
|
|
1615
|
+
e && X(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`);
|
|
1616
|
+
}
|
|
1617
|
+
function wn(e, n) {
|
|
1618
|
+
for (let e of t) {
|
|
1619
|
+
let t = n[e];
|
|
1620
|
+
t && X(t) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as theme.colors.${e}; using the calculated color.`);
|
|
1621
|
+
}
|
|
1622
|
+
let { contrastWarnings: r } = Z({
|
|
1623
|
+
color: e.color,
|
|
1624
|
+
inkColor: e.inkColor,
|
|
1625
|
+
accentColor: e.accentColor,
|
|
1626
|
+
overrides: n
|
|
1627
|
+
});
|
|
1628
|
+
for (let { role: e, against: t, value: n, ratio: i, required: a } of r) console.warn(`[whoo-aiden-widget] theme.colors.${e} (${n}) has ${i.toFixed(2)}:1 contrast against the ${t} color; ${a}:1 is recommended. Using it as given.`);
|
|
1309
1629
|
}
|
|
1310
|
-
function
|
|
1311
|
-
|
|
1630
|
+
function Tn(e, t) {
|
|
1631
|
+
bn(e, t.color ?? ln), Cn(t.inkColor, "ink color"), Cn(t.accentColor, "accent color"), xn(e, {
|
|
1312
1632
|
inkColor: t.inkColor,
|
|
1313
1633
|
accentColor: t.accentColor
|
|
1314
1634
|
});
|
|
1315
|
-
let n = t.
|
|
1316
|
-
e.style.setProperty("--whoo-widget-
|
|
1635
|
+
let n = T(t.theme);
|
|
1636
|
+
wn(t, n.colors), Sn(e, n.colors), n.fontFamily && (e.style.setProperty("--whoo-widget-font", n.fontFamily), e.setAttribute("data-whoo-custom-font", ""));
|
|
1317
1637
|
}
|
|
1318
1638
|
//#endregion
|
|
1319
1639
|
//#region src/controller.ts
|
|
1320
|
-
var
|
|
1321
|
-
function
|
|
1640
|
+
var En = 8e3, Dn = 3e3;
|
|
1641
|
+
function On(e, t) {
|
|
1322
1642
|
return new Promise((n) => {
|
|
1323
1643
|
let r = setTimeout(n, t);
|
|
1324
1644
|
e.then(() => {
|
|
@@ -1326,7 +1646,7 @@ function Gt(e, t) {
|
|
|
1326
1646
|
});
|
|
1327
1647
|
});
|
|
1328
1648
|
}
|
|
1329
|
-
var
|
|
1649
|
+
var kn = class {
|
|
1330
1650
|
config;
|
|
1331
1651
|
state;
|
|
1332
1652
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -1336,12 +1656,18 @@ var Kt = class {
|
|
|
1336
1656
|
activeRequestController = null;
|
|
1337
1657
|
slowResponseTimer = null;
|
|
1338
1658
|
prefersReducedMotion;
|
|
1659
|
+
launcher;
|
|
1339
1660
|
launcherIconUrl;
|
|
1340
1661
|
emptyStateImageUrl;
|
|
1341
1662
|
emptyStateImageAlt;
|
|
1342
1663
|
showFeedback;
|
|
1343
|
-
constructor(
|
|
1344
|
-
this.config =
|
|
1664
|
+
constructor(t) {
|
|
1665
|
+
this.config = t;
|
|
1666
|
+
let n = T(t.theme).launcher, r = n.iconUrl ?? e(t.launcherIconUrl, "launcherIconUrl");
|
|
1667
|
+
this.launcher = {
|
|
1668
|
+
...n,
|
|
1669
|
+
...r ? { iconUrl: r } : {}
|
|
1670
|
+
}, this.launcherIconUrl = r, this.emptyStateImageUrl = e(t.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof t.emptyStateImageAlt == "string" ? t.emptyStateImageAlt.trim() : "", this.showFeedback = t.showFeedback === !0, this.storageIdentifier = t.publishableKey ?? "session-token-mode", this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
|
|
1345
1671
|
isOpen: !1,
|
|
1346
1672
|
messages: [],
|
|
1347
1673
|
isStreaming: !1,
|
|
@@ -1386,10 +1712,10 @@ var Kt = class {
|
|
|
1386
1712
|
let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
|
|
1387
1713
|
try {
|
|
1388
1714
|
if (this.config.sessionToken) {
|
|
1389
|
-
if (
|
|
1715
|
+
if (Qt(this.config.sessionToken)) throw Error("The sessionToken has expired.");
|
|
1390
1716
|
this.sessionToken = this.config.sessionToken;
|
|
1391
1717
|
} else if (this.config.publishableKey) {
|
|
1392
|
-
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await
|
|
1718
|
+
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await Bt(e, this.config.publishableKey);
|
|
1393
1719
|
this.sessionToken = t, this.setState({
|
|
1394
1720
|
primaryColor: n,
|
|
1395
1721
|
agentName: r,
|
|
@@ -1401,18 +1727,18 @@ var Kt = class {
|
|
|
1401
1727
|
console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
|
|
1402
1728
|
return;
|
|
1403
1729
|
}
|
|
1404
|
-
this.conversationId =
|
|
1730
|
+
this.conversationId = en(this.storageIdentifier), this.config.sessionToken && await On(this.loadBranding(e, this.config.sessionToken), Dn);
|
|
1405
1731
|
}
|
|
1406
1732
|
async loadBranding(e, t) {
|
|
1407
1733
|
try {
|
|
1408
1734
|
let n = this.config;
|
|
1409
|
-
if (
|
|
1410
|
-
let { primaryColor:
|
|
1735
|
+
if (X(n.color) && X(n.inkColor) && X(n.accentColor) && c(n.name)) return;
|
|
1736
|
+
let { primaryColor: r, name: i, accentColor: a, inkColor: o } = await Ht(e, t);
|
|
1411
1737
|
this.setState({
|
|
1412
|
-
primaryColor:
|
|
1413
|
-
agentName:
|
|
1414
|
-
accentColor:
|
|
1415
|
-
inkColor:
|
|
1738
|
+
primaryColor: r,
|
|
1739
|
+
agentName: i,
|
|
1740
|
+
accentColor: a,
|
|
1741
|
+
inkColor: o
|
|
1416
1742
|
});
|
|
1417
1743
|
} catch (e) {
|
|
1418
1744
|
let t = e?.status;
|
|
@@ -1423,7 +1749,7 @@ var Kt = class {
|
|
|
1423
1749
|
this.setState({ isOpen: !0 });
|
|
1424
1750
|
}
|
|
1425
1751
|
resetConversation() {
|
|
1426
|
-
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null,
|
|
1752
|
+
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, nn(this.storageIdentifier), this.setState({
|
|
1427
1753
|
messages: [],
|
|
1428
1754
|
messageFeedback: {},
|
|
1429
1755
|
runtimeError: null,
|
|
@@ -1469,7 +1795,7 @@ var Kt = class {
|
|
|
1469
1795
|
let { signal: a } = this.activeRequestController;
|
|
1470
1796
|
this.slowResponseTimer = setTimeout(() => {
|
|
1471
1797
|
this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
|
|
1472
|
-
},
|
|
1798
|
+
}, En);
|
|
1473
1799
|
let o = () => {
|
|
1474
1800
|
this.setState({
|
|
1475
1801
|
runtimeError: "Something went wrong, please try again.",
|
|
@@ -1477,17 +1803,17 @@ var Kt = class {
|
|
|
1477
1803
|
});
|
|
1478
1804
|
}, s = "";
|
|
1479
1805
|
try {
|
|
1480
|
-
for await (let n of
|
|
1481
|
-
else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await
|
|
1806
|
+
for await (let n of Wt(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, tn(this.storageIdentifier, n.conversationId);
|
|
1807
|
+
else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await Zt(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
|
|
1482
1808
|
else if (n.type === "done") {
|
|
1483
|
-
if (n.conversationId && (this.conversationId = n.conversationId,
|
|
1809
|
+
if (n.conversationId && (this.conversationId = n.conversationId, tn(this.storageIdentifier, n.conversationId)), n.messageId) {
|
|
1484
1810
|
let e = [...this.state.messages];
|
|
1485
1811
|
e[e.length - 1] = {
|
|
1486
1812
|
...e[e.length - 1],
|
|
1487
1813
|
id: n.messageId
|
|
1488
1814
|
}, this.setState({ messages: e });
|
|
1489
1815
|
}
|
|
1490
|
-
this.setState({ announcement:
|
|
1816
|
+
this.setState({ announcement: Kt(s) });
|
|
1491
1817
|
} else if (n.type === "error") {
|
|
1492
1818
|
console.error("[whoo-aiden-widget] chat error:", n.error), o(), this.activeRequestController?.abort();
|
|
1493
1819
|
break;
|
|
@@ -1536,7 +1862,7 @@ var Kt = class {
|
|
|
1536
1862
|
}
|
|
1537
1863
|
} });
|
|
1538
1864
|
try {
|
|
1539
|
-
await
|
|
1865
|
+
await Ut(i, this.sessionToken, {
|
|
1540
1866
|
messageId: e,
|
|
1541
1867
|
rating: t,
|
|
1542
1868
|
correction: n,
|
|
@@ -1560,32 +1886,45 @@ var Kt = class {
|
|
|
1560
1886
|
} });
|
|
1561
1887
|
}
|
|
1562
1888
|
}
|
|
1563
|
-
},
|
|
1889
|
+
}, $ = 20, An = 12, jn = 300, Mn = 352;
|
|
1890
|
+
function Nn(e, t) {
|
|
1891
|
+
let { offsetX: n, offsetY: r, launcherSize: i, panelWidth: a, panelHeight: o } = te(t.layout), s = (e) => typeof t.layout?.offset?.[e] == "number";
|
|
1892
|
+
if (typeof window < "u" && window.innerWidth > 0 && window.innerHeight > 0) {
|
|
1893
|
+
let e = Math.max($, window.innerWidth - jn), t = Math.max($, window.innerHeight - i - Mn);
|
|
1894
|
+
s("x") && (n > e || n > window.innerWidth - i) && console.warn(`whoo-aiden-widget: \`layout.offset.x\` ${n} leaves no room for the launcher and panel in this viewport; it is held back.`), s("y") && (r > t || r > window.innerHeight - i) && console.warn(`whoo-aiden-widget: \`layout.offset.y\` ${r} leaves no room for the launcher and panel in this viewport; it is held back.`);
|
|
1895
|
+
}
|
|
1896
|
+
let c = `min(${n}px, max(${$}px, calc(100vw - ${jn}px)), calc(100vw - ${i}px))`, l = `min(${r}px, max(${$}px, calc(100vh - ${i + Mn}px)), calc(100vh - ${i}px))`, u = `calc(${l} + ${i}px + ${An}px)`, d = t.position === "bottom-left", f = (t, n) => e.style.setProperty(t, n);
|
|
1897
|
+
f("--whoo-widget-inset-left", d ? c : "auto"), f("--whoo-widget-inset-right", d ? "auto" : c), f("--whoo-widget-inset-bottom", l), f("--whoo-widget-launcher-size", `${i}px`), f("--whoo-widget-panel-bottom", u), f("--whoo-widget-panel-width", `${a}px`), f("--whoo-widget-panel-height", `${o}px`), f("--whoo-widget-panel-max-width", `calc(100vw - ${c} - ${$}px)`), f("--whoo-widget-panel-max-height", `calc(100vh - ${u} - ${$}px)`);
|
|
1898
|
+
}
|
|
1899
|
+
//#endregion
|
|
1900
|
+
//#region src/styles.css?inline
|
|
1901
|
+
var Pn = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif);border-radius:12px;flex-direction:column;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid var(--whoo-widget-border,#e5e5e5);flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding:8px 8px 8px 16px;display:flex;overflow-y:auto}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;flex:auto;min-width:0;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-left:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-list{margin:4px 0;padding-left:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:var(--whoo-widget-typing-dots,#6b7280);border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:var(--whoo-widget-muted,#4b5563);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:var(--whoo-widget-text,#111);background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{border:1px solid var(--whoo-widget-input-border,#6b7280);background:var(--whoo-widget-panel,#fff);color:var(--whoo-widget-text,#111);cursor:pointer;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:var(--whoo-widget-muted,#4b5563);margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:var(--whoo-widget-error-text,#991b1b);font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}[data-whoo-custom-font] button,[data-whoo-custom-font] input,[data-whoo-custom-font] textarea,[data-whoo-custom-font] select{font-family:inherit}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
|
|
1564
1902
|
//#endregion
|
|
1565
1903
|
//#region src/mount.tsx
|
|
1566
|
-
function
|
|
1904
|
+
function Fn(e) {
|
|
1567
1905
|
let t = document.createElement("div");
|
|
1568
|
-
t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(
|
|
1569
|
-
let
|
|
1570
|
-
|
|
1571
|
-
let
|
|
1572
|
-
|
|
1573
|
-
let
|
|
1574
|
-
return
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1906
|
+
t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(o(e.zIndex));
|
|
1907
|
+
let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
|
|
1908
|
+
r.textContent = Pn, n.appendChild(r);
|
|
1909
|
+
let i = document.createElement("div");
|
|
1910
|
+
n.appendChild(i), Tn(i, e), Nn(i, e);
|
|
1911
|
+
let a = new kn(e), s = X(e.color) !== null, c = null, l = "", u = T(e.theme).colors;
|
|
1912
|
+
return a.subscribe((t) => {
|
|
1913
|
+
let n = !1;
|
|
1914
|
+
!s && t.primaryColor && t.primaryColor !== c && (c = t.primaryColor, bn(i, t.primaryColor, e.color), n = !0);
|
|
1915
|
+
let r = `${t.inkColor}|${t.accentColor}`;
|
|
1916
|
+
(t.inkColor || t.accentColor) && r !== l && (l = r, xn(i, {
|
|
1917
|
+
inkColor: X(e.inkColor) ? e.inkColor : t.inkColor,
|
|
1918
|
+
accentColor: X(e.accentColor) ? e.accentColor : t.accentColor
|
|
1919
|
+
}), n = !0), n && Sn(i, u);
|
|
1920
|
+
}), a.init(), Fe(/* @__PURE__ */ G(Lt, { controller: a }), i), document.body.appendChild(t), { unmount() {
|
|
1921
|
+
Fe(null, i), t.remove();
|
|
1583
1922
|
} };
|
|
1584
1923
|
}
|
|
1585
1924
|
//#endregion
|
|
1586
1925
|
//#region src/index.ts
|
|
1587
|
-
function
|
|
1588
|
-
return
|
|
1926
|
+
function In(e) {
|
|
1927
|
+
return l(e), Fn(e);
|
|
1589
1928
|
}
|
|
1590
1929
|
//#endregion
|
|
1591
|
-
export {
|
|
1930
|
+
export { In as init, Z as resolveTheme };
|