@aiden-voice/widget 0.8.0 → 0.9.1
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 +53 -12
- package/dist/components/Composer.d.ts +3 -1
- package/dist/components/MessageFeedback.d.ts +2 -1
- package/dist/components/MessageList.d.ts +6 -1
- package/dist/config.d.ts +1 -0
- package/dist/controller.d.ts +10 -0
- package/dist/i18n/index.d.ts +6 -0
- package/dist/i18n/messages.d.ts +2 -0
- package/dist/markdown/render.d.ts +5 -1
- package/dist/storage.d.ts +2 -0
- package/dist/types.d.ts +24 -0
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +7 -7
- package/dist/widget.js +873 -655
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -25,7 +25,9 @@ var e = {
|
|
|
25
25
|
feedbackFailed: "Couldn't send feedback",
|
|
26
26
|
conversationCleared: "Conversation cleared",
|
|
27
27
|
genericError: "Something went wrong, please try again.",
|
|
28
|
-
sessionExpired: "This chat session has expired. Reload the page to continue."
|
|
28
|
+
sessionExpired: "This chat session has expired. Reload the page to continue.",
|
|
29
|
+
opensInNewTab: "(opens in new tab)",
|
|
30
|
+
agreeToNotice: "I agree"
|
|
29
31
|
}, t = Object.keys(e);
|
|
30
32
|
//#endregion
|
|
31
33
|
//#region src/imageUrl.ts
|
|
@@ -100,27 +102,24 @@ function u(e) {
|
|
|
100
102
|
return typeof e == "string" ? e.trim() : "";
|
|
101
103
|
}
|
|
102
104
|
function d(e) {
|
|
103
|
-
|
|
105
|
+
return /^[\p{White_Space}\p{Cf}\p{M}]*$/u.test(e);
|
|
104
106
|
}
|
|
105
107
|
function f(e) {
|
|
106
|
-
|
|
108
|
+
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.");
|
|
107
109
|
}
|
|
108
110
|
function p(e) {
|
|
111
|
+
console.warn(`whoo-aiden-widget: ${e}`);
|
|
112
|
+
}
|
|
113
|
+
function m(e) {
|
|
109
114
|
let { getSessionToken: t } = e;
|
|
110
115
|
if (t !== void 0) {
|
|
111
|
-
if (typeof t != "function")
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
if (!e.sessionToken) {
|
|
116
|
-
f("ignoring `getSessionToken` -- it is only used with `sessionToken`; with `publishableKey` the widget renews its session by itself.");
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
return t;
|
|
116
|
+
if (typeof t != "function") p("ignoring `getSessionToken` -- expected a function that returns a session token.");
|
|
117
|
+
else if (!e.sessionToken) p("ignoring `getSessionToken` -- it is only used with `sessionToken`; with `publishableKey` the widget renews its session by itself.");
|
|
118
|
+
else return t;
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
|
-
var
|
|
123
|
-
function
|
|
121
|
+
var h = 20;
|
|
122
|
+
function g(e) {
|
|
124
123
|
let t = /* @__PURE__ */ new WeakSet(), n = /* @__PURE__ */ new Set();
|
|
125
124
|
return (r) => {
|
|
126
125
|
if (typeof r == "object" && r || typeof r == "function") {
|
|
@@ -128,63 +127,59 @@ function h(e) {
|
|
|
128
127
|
t.add(r);
|
|
129
128
|
} else {
|
|
130
129
|
if (n.has(r)) return;
|
|
131
|
-
n.size >=
|
|
130
|
+
n.size >= h && n.delete(n.values().next().value), n.add(r);
|
|
132
131
|
}
|
|
133
|
-
|
|
132
|
+
p(e);
|
|
134
133
|
};
|
|
135
134
|
}
|
|
136
|
-
var
|
|
137
|
-
function
|
|
135
|
+
var _ = g("ignoring `theme` -- expected an object."), v = g("ignoring `layout` -- expected an object."), y = g("ignoring `messages` -- expected an object.");
|
|
136
|
+
function b(e) {
|
|
138
137
|
if (e == null) return {};
|
|
139
|
-
if (!
|
|
138
|
+
if (!x(e)) return y(e), {};
|
|
140
139
|
let n = {};
|
|
141
140
|
for (let r of Object.keys(e)) {
|
|
142
141
|
if (!t.includes(r)) {
|
|
143
|
-
|
|
142
|
+
p(`ignoring unknown option \`messages.${r}\`.`);
|
|
144
143
|
continue;
|
|
145
144
|
}
|
|
146
145
|
let i = e[r];
|
|
147
|
-
|
|
148
|
-
f(`ignoring \`messages.${r}\` -- expected a non-blank string.`);
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
r === "chatWith" && !i.includes("{name}") && f("`messages.chatWith` has no {name}, so the agent name is not shown in the title. For a fixed title, use the `title` option."), n[r] = i;
|
|
146
|
+
typeof i != "string" || d(i) ? p(`ignoring \`messages.${r}\` -- expected a non-blank string.`) : (r === "chatWith" && !i.includes("{name}") && p("`messages.chatWith` has no {name}, so the agent name is not shown in the title. For a fixed title, use the `title` option."), n[r] = i);
|
|
152
147
|
}
|
|
153
|
-
for (let t in e) Object.hasOwn(e, t) ||
|
|
148
|
+
for (let t in e) Object.hasOwn(e, t) || p(`ignoring inherited option \`messages.${t}\` -- only the object's own keys are used.`);
|
|
154
149
|
return n;
|
|
155
150
|
}
|
|
156
|
-
function
|
|
151
|
+
function x(e) {
|
|
157
152
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
158
153
|
}
|
|
159
|
-
var
|
|
160
|
-
function
|
|
154
|
+
var S = (e) => e == null || e === "";
|
|
155
|
+
function C(e, t, n) {
|
|
161
156
|
let r = e[t];
|
|
162
|
-
return r == null ? null :
|
|
157
|
+
return r == null ? null : x(r) ? r : (p(`ignoring \`${n}\` -- expected an object.`), null);
|
|
163
158
|
}
|
|
164
|
-
function
|
|
165
|
-
for (let r of Object.keys(e)) t.includes(r) ||
|
|
159
|
+
function w(e, t, n) {
|
|
160
|
+
for (let r of Object.keys(e)) t.includes(r) || p(`ignoring unknown option \`${n}.${r}\`.`);
|
|
166
161
|
}
|
|
167
|
-
function
|
|
168
|
-
if (!
|
|
162
|
+
function T(e, t, n) {
|
|
163
|
+
if (!S(e)) {
|
|
169
164
|
if (typeof e == "string" && t.includes(e)) return e;
|
|
170
|
-
|
|
165
|
+
p(`ignoring \`${n}\` -- expected one of ${t.join(", ")}.`);
|
|
171
166
|
}
|
|
172
167
|
}
|
|
173
|
-
var
|
|
174
|
-
function
|
|
175
|
-
if (!
|
|
168
|
+
var E = 200, D = /url\(|[@;{}\\]/i;
|
|
169
|
+
function O(e) {
|
|
170
|
+
if (!S(e)) {
|
|
176
171
|
if (typeof e == "string") {
|
|
177
172
|
let t = e.trim();
|
|
178
|
-
if (t && t.length <=
|
|
173
|
+
if (t && t.length <= E && !D.test(t)) return t;
|
|
179
174
|
}
|
|
180
|
-
|
|
175
|
+
p(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${E} characters, without url(), @, ;, {, } or \\.`);
|
|
181
176
|
}
|
|
182
177
|
}
|
|
183
|
-
var
|
|
178
|
+
var k = [
|
|
184
179
|
"chat",
|
|
185
180
|
"message",
|
|
186
181
|
"sparkle"
|
|
187
|
-
],
|
|
182
|
+
], A = ["chevron-down", "close"], ee = /* @__PURE__ */ new WeakMap();
|
|
188
183
|
function te(e) {
|
|
189
184
|
let t = {
|
|
190
185
|
colors: {},
|
|
@@ -192,75 +187,75 @@ function te(e) {
|
|
|
192
187
|
launcher: {}
|
|
193
188
|
};
|
|
194
189
|
if (e == null) return t;
|
|
195
|
-
if (!
|
|
196
|
-
let i =
|
|
190
|
+
if (!x(e)) return _(e), t;
|
|
191
|
+
let i = ee.get(e);
|
|
197
192
|
if (i) return i;
|
|
198
|
-
|
|
193
|
+
w(e, [
|
|
199
194
|
"colors",
|
|
200
195
|
"fonts",
|
|
201
196
|
"launcher"
|
|
202
197
|
], "theme");
|
|
203
|
-
let a =
|
|
198
|
+
let a = C(e, "colors", "theme.colors");
|
|
204
199
|
if (a) {
|
|
205
|
-
|
|
200
|
+
w(a, r, "theme.colors");
|
|
206
201
|
for (let e of r) {
|
|
207
202
|
let n = a[e];
|
|
208
|
-
|
|
203
|
+
S(n) || (typeof n == "string" ? t.colors[e] = n : p(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`));
|
|
209
204
|
}
|
|
210
205
|
}
|
|
211
|
-
let o =
|
|
212
|
-
o && (
|
|
213
|
-
let s =
|
|
206
|
+
let o = C(e, "fonts", "theme.fonts");
|
|
207
|
+
o && (w(o, ["family"], "theme.fonts"), t.fontFamily = O(o.family));
|
|
208
|
+
let s = C(e, "launcher", "theme.launcher");
|
|
214
209
|
if (s) {
|
|
215
|
-
|
|
210
|
+
w(s, [
|
|
216
211
|
"icon",
|
|
217
212
|
"iconUrl",
|
|
218
213
|
"openIcon",
|
|
219
214
|
"openIconUrl"
|
|
220
215
|
], "theme.launcher");
|
|
221
|
-
let e =
|
|
216
|
+
let e = T(s.icon, k, "theme.launcher.icon"), r = n(s.iconUrl, "theme.launcher.iconUrl"), i = T(s.openIcon, A, "theme.launcher.openIcon"), a = n(s.openIconUrl, "theme.launcher.openIconUrl");
|
|
222
217
|
e && (t.launcher.icon = e), r && (t.launcher.iconUrl = r), i && (t.launcher.openIcon = i), a && (t.launcher.openIconUrl = a);
|
|
223
218
|
}
|
|
224
|
-
return
|
|
219
|
+
return ee.set(e, t), t;
|
|
225
220
|
}
|
|
226
|
-
var
|
|
221
|
+
var j = {
|
|
227
222
|
offsetX: 20,
|
|
228
223
|
offsetY: 20,
|
|
229
224
|
launcherSize: 56,
|
|
230
225
|
panelWidth: 360,
|
|
231
226
|
panelHeight: 480
|
|
232
227
|
};
|
|
233
|
-
function
|
|
234
|
-
return e == null ? n : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : (
|
|
228
|
+
function M(e, t, n) {
|
|
229
|
+
return e == null ? n : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : (p(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`), n);
|
|
235
230
|
}
|
|
236
231
|
function ne(e, t, n, r) {
|
|
237
232
|
let i = Math.min(r, Math.max(n, e));
|
|
238
|
-
return i !== e &&
|
|
233
|
+
return i !== e && p(`\`${t}\` ${e} is out of range (${r === Infinity ? `at least ${n}` : `${n}-${r}`}); using ${i}.`), i;
|
|
239
234
|
}
|
|
240
235
|
var re = /* @__PURE__ */ new WeakMap();
|
|
241
236
|
function ie(e) {
|
|
242
|
-
let t = { ...
|
|
237
|
+
let t = { ...j };
|
|
243
238
|
if (e == null) return t;
|
|
244
|
-
if (!
|
|
239
|
+
if (!x(e)) return v(e), t;
|
|
245
240
|
let n = re.get(e);
|
|
246
241
|
if (n) return n;
|
|
247
|
-
|
|
242
|
+
w(e, [
|
|
248
243
|
"offset",
|
|
249
244
|
"launcherSize",
|
|
250
245
|
"panel"
|
|
251
246
|
], "layout");
|
|
252
|
-
let r =
|
|
253
|
-
r && (
|
|
254
|
-
let i =
|
|
255
|
-
return i && (
|
|
247
|
+
let r = C(e, "offset", "layout.offset");
|
|
248
|
+
r && (w(r, ["x", "y"], "layout.offset"), t.offsetX = M(r.x, "layout.offset.x", j.offsetX), t.offsetY = M(r.y, "layout.offset.y", j.offsetY)), t.launcherSize = ne(M(e.launcherSize, "layout.launcherSize", j.launcherSize), "layout.launcherSize", 24, 120);
|
|
249
|
+
let i = C(e, "panel", "layout.panel");
|
|
250
|
+
return i && (w(i, ["width", "height"], "layout.panel"), t.panelWidth = ne(M(i.width, "layout.panel.width", j.panelWidth), "layout.panel.width", 280, Infinity), t.panelHeight = ne(M(i.height, "layout.panel.height", j.panelHeight), "layout.panel.height", 320, Infinity)), re.set(e, t), t;
|
|
256
251
|
}
|
|
257
252
|
//#endregion
|
|
258
|
-
//#region node_modules/.pnpm/preact@11.0.
|
|
259
|
-
var
|
|
260
|
-
function
|
|
253
|
+
//#region node_modules/.pnpm/preact@11.0.1/node_modules/preact/dist/preact.mjs
|
|
254
|
+
var N, ae, P, oe, se, ce, le, ue, de, fe, pe = {}, me = [], he = /^m(i|n|o|s|text|space)$/, ge = Array.isArray, _e = me.slice, F = Object.assign;
|
|
255
|
+
function ve(e) {
|
|
261
256
|
e && e.parentNode && e.remove();
|
|
262
257
|
}
|
|
263
|
-
function
|
|
258
|
+
function ye(e, t, n, r, i) {
|
|
264
259
|
var a = {
|
|
265
260
|
type: e,
|
|
266
261
|
props: t,
|
|
@@ -276,12 +271,12 @@ function be(e, t, n, r, i) {
|
|
|
276
271
|
__i: -1,
|
|
277
272
|
__u: 0
|
|
278
273
|
};
|
|
279
|
-
return !i &&
|
|
274
|
+
return !i && N.vnode && N.vnode(a), a;
|
|
280
275
|
}
|
|
281
276
|
function I(e) {
|
|
282
277
|
return e.children;
|
|
283
278
|
}
|
|
284
|
-
function
|
|
279
|
+
function be(e, t) {
|
|
285
280
|
this.props = e, this.context = t, this.__g = 0;
|
|
286
281
|
}
|
|
287
282
|
function L(e, t) {
|
|
@@ -289,30 +284,30 @@ function L(e, t) {
|
|
|
289
284
|
for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) && n.__e) return n.__e;
|
|
290
285
|
return typeof e.type != "function" || e.props.__P ? null : L(e);
|
|
291
286
|
}
|
|
292
|
-
function
|
|
287
|
+
function xe(e) {
|
|
293
288
|
if ((e = e.__) && e.__c && !e.props.__P) return e.__e = null, e.__k.some(function(t) {
|
|
294
289
|
return t && (e.__e = t.__e);
|
|
295
|
-
}),
|
|
290
|
+
}), xe(e);
|
|
296
291
|
}
|
|
297
|
-
function
|
|
298
|
-
(8 & e.__g || !(e.__g |= 8) || !
|
|
292
|
+
function Se(e) {
|
|
293
|
+
(8 & e.__g || !(e.__g |= 8) || !P.push(e) || se++) && oe == N.debounceRendering || ((oe = N.debounceRendering) || queueMicrotask)(Ce);
|
|
299
294
|
}
|
|
300
|
-
function
|
|
295
|
+
function Ce() {
|
|
301
296
|
var e, t, n, r, i, a, o, s, c;
|
|
302
297
|
try {
|
|
303
|
-
for (t = 1;
|
|
298
|
+
for (t = 1; P.length;) P.length > t && P.sort(ce), e = P.shift(), t = P.length, 8 & e.__g && (r = void 0, i = void 0, a = (i = (n = e).__v).__e, o = [], s = [], (c = n.__P) && ((r = F({ constructor: void 0 }, i)).__v = i.__v + 1, N.vnode && N.vnode(r), je(c, r, i, n.__n, c.namespaceURI, 32 & i.__u ? [a] : null, o, a || L(i), 32 & i.__u, s), r.__v = i.__v, r.__.__k[r.__i] = r, Ne(o, r, s), i.__ = i.__e = null, r.__e != a && xe(r)));
|
|
304
299
|
} finally {
|
|
305
|
-
|
|
300
|
+
P.length = se = 0;
|
|
306
301
|
}
|
|
307
302
|
}
|
|
308
|
-
function
|
|
309
|
-
var d, f, p, m, h, g, _ = r.__k ||
|
|
310
|
-
for (c =
|
|
303
|
+
function we(e, t, n, r, i, a, o, s, c, l, u) {
|
|
304
|
+
var d, f, p, m, h, g, _ = r.__k || me, v = t.length;
|
|
305
|
+
for (c = Te(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = ~p.__i && _[p.__i] || pe, p.__i = d, g = je(e, p, f, i, a, o, s, c, l, u), m = p.__e, (f.ref != p.ref || 8 & f.__u) && (f.ref && Fe(f.ref, null, p, f), p.ref && u.push(p.ref, p.__c || m, p)), h ||= m, 4 & p.__u ? (c = Ee(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);
|
|
311
306
|
return n.__e = h, c;
|
|
312
307
|
}
|
|
313
|
-
function
|
|
308
|
+
function Te(e, t, n, r, i) {
|
|
314
309
|
var a, o, s, c, l, u, d, f, p, m, h = n.length, g = h, _ = 0, v = !1, y = e.__k = Array(i);
|
|
315
|
-
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] =
|
|
310
|
+
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] = ye(null, o) : ge(o) ? o = y[a] = ye(I, { children: o }) : o.constructor === void 0 && o.__b ? o = y[a] = ye(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 = De(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;
|
|
316
311
|
if (v) {
|
|
317
312
|
for (u = [], d = [], a = 0; a < i; a++) if ((o = y[a]) && 2 & o.__u) {
|
|
318
313
|
for (f = 0, p = u.length; f < p;) u[m = f + p >> 1] < o.__i ? f = m + 1 : p = m;
|
|
@@ -320,20 +315,21 @@ function Ee(e, t, n, r, i) {
|
|
|
320
315
|
}
|
|
321
316
|
for (_ = u.length; a--;) d[a] && (d[a] == _ ? _-- : y[a].__u |= 4);
|
|
322
317
|
}
|
|
323
|
-
if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r = L(s)),
|
|
318
|
+
if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r = L(s)), Ie(s, s));
|
|
324
319
|
return r;
|
|
325
320
|
}
|
|
326
|
-
function
|
|
327
|
-
var i, a;
|
|
321
|
+
function Ee(e, t, n, r) {
|
|
322
|
+
var i, a, o;
|
|
328
323
|
if (typeof e.type == "function") {
|
|
329
324
|
if (e.props.__P) return t;
|
|
330
|
-
if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t =
|
|
325
|
+
if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t = Ee(i[a], t, n, !1));
|
|
331
326
|
return t;
|
|
332
327
|
}
|
|
333
|
-
for (t && !t.parentNode && (t = L(e)) && !t.parentNode && (t = null),
|
|
328
|
+
for (t && !t.parentNode && (t = L(e)) && !t.parentNode && (t = null), o = t; o && o.nodeType == 8;) o = o.nextSibling;
|
|
329
|
+
for (e.__e != o && (!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;);
|
|
334
330
|
return t;
|
|
335
331
|
}
|
|
336
|
-
function
|
|
332
|
+
function De(e, t, n, r) {
|
|
337
333
|
var i, a, o, s = e.key, c = e.type, l = t[n], u = l && !(2 & l.__u);
|
|
338
334
|
if (l === null && s == null || u && s == l.key && c == l.type) return n;
|
|
339
335
|
if (r > +!!u) {
|
|
@@ -341,18 +337,18 @@ function Oe(e, t, n, r) {
|
|
|
341
337
|
}
|
|
342
338
|
return -1;
|
|
343
339
|
}
|
|
344
|
-
function
|
|
340
|
+
function Oe(e, t, n) {
|
|
345
341
|
n ??= "", t[0] == "-" ? e.setProperty(t, n) : e[t] = n;
|
|
346
342
|
}
|
|
347
|
-
function
|
|
348
|
-
var a;
|
|
343
|
+
function ke(e, t, n, r, i) {
|
|
344
|
+
var a, o;
|
|
349
345
|
n: if (t == "style") {
|
|
350
346
|
if (typeof n == "string") e.style.cssText = n;
|
|
351
347
|
else {
|
|
352
|
-
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n ||
|
|
353
|
-
if (n) for (t in n) r && n[t] == r[t] ||
|
|
348
|
+
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || Oe(e.style, t, "");
|
|
349
|
+
if (n) for (t in n) r && n[t] == r[t] || Oe(e.style, t, n[t]);
|
|
354
350
|
}
|
|
355
|
-
} else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(ue, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()),
|
|
351
|
+
} else if (t[0] == "o" && t[1] == "n") (e.__e ||= {})[t] = n, n && r || (o = fe[t] || (fe[t] = Ae(t)), (e.__a ||= {})[t] = de, a = t != (t = t.replace(ue, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()), n ? e.addEventListener(t, o, a) : e.removeEventListener(t, o, a));
|
|
356
352
|
else {
|
|
357
353
|
if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
358
354
|
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 {
|
|
@@ -362,18 +358,18 @@ function Ae(e, t, n, r, i) {
|
|
|
362
358
|
typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
|
|
363
359
|
}
|
|
364
360
|
}
|
|
365
|
-
function
|
|
361
|
+
function Ae(e) {
|
|
366
362
|
return function(t) {
|
|
367
363
|
if (this.__e) {
|
|
368
|
-
var n = this.__e[
|
|
364
|
+
var n = this.__e[e];
|
|
369
365
|
if (t[le] == null) t[le] = de++;
|
|
370
|
-
else if (t[le] <
|
|
371
|
-
return n(
|
|
366
|
+
else if (t[le] < this.__a[e]) return;
|
|
367
|
+
return n(N.event ? N.event(t) : t);
|
|
372
368
|
}
|
|
373
369
|
};
|
|
374
370
|
}
|
|
375
|
-
function
|
|
376
|
-
var u, d, f, p, m, h, g, _, v, y, b, x, S, C,
|
|
371
|
+
function je(e, t, n, r, i, a, o, s, c, l) {
|
|
372
|
+
var u, d, f, p, m, h, g, _, v, y, b, x, S, C, w, T, E, D, O, k, A = t.type;
|
|
377
373
|
if (t.constructor !== void 0) return null;
|
|
378
374
|
if (128 & n.__u && (c = 32 & n.__u, u = n.__c.__z)) {
|
|
379
375
|
if (t.__u |= c, d = a = [], u.nodeType == 8) for (f = 1, p = u.nextSibling; p; p = p.nextSibling) {
|
|
@@ -386,71 +382,72 @@ function Me(e, t, n, r, i, a, o, s, c, l) {
|
|
|
386
382
|
else a.push(u);
|
|
387
383
|
s = a[0];
|
|
388
384
|
}
|
|
389
|
-
(u =
|
|
390
|
-
n: if (typeof
|
|
385
|
+
(u = N.__b) && u(t);
|
|
386
|
+
n: if (typeof A == "function") {
|
|
391
387
|
m = o.length;
|
|
392
388
|
try {
|
|
393
|
-
if (y = t.props, b = (u =
|
|
394
|
-
if (b && !
|
|
389
|
+
if (y = t.props, b = (u = A.prototype) && u.render, x = (u = A.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 A(y, S) : (t.__c = h = new be(y, S), h.constructor = A, h.render = Le), 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), A.getDerivedStateFromProps && (h.__s == h.state && (h.__s = F({}, h.__s)), F(h.__s, A.getDerivedStateFromProps(y, h.__s)))), g = h.props, _ = h.state, h.__v = t, n.__c) {
|
|
390
|
+
if (b && !A.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)) {
|
|
395
391
|
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) {
|
|
396
392
|
e && (e.__ = t);
|
|
397
|
-
}),
|
|
393
|
+
}), me.push.apply(h.__h, h.__k), h.__k = [], h.__h.length && o.push(h), s = L(n);
|
|
398
394
|
break n;
|
|
399
395
|
}
|
|
400
396
|
h.componentWillUpdate && h.componentWillUpdate(y, h.__s, S), b && h.componentDidUpdate && h.__h.push(function() {
|
|
401
397
|
h.componentDidUpdate(g, _, v);
|
|
402
398
|
});
|
|
403
|
-
} else b && !
|
|
404
|
-
if (h.context = S, h.props = y, h.__P = e, h.__g &= -5, C =
|
|
399
|
+
} else b && !A.getDerivedStateFromProps && h.componentWillMount && h.componentWillMount(), b && h.componentDidMount && h.__h.push(h.componentDidMount);
|
|
400
|
+
if (h.context = S, h.props = y, h.__P = e, h.__g &= -5, C = N.__r, w = 0, b) h.state = h.__s, h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), me.push.apply(h.__h, h.__k), h.__k = [];
|
|
405
401
|
else do
|
|
406
402
|
h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), h.state = h.__s;
|
|
407
|
-
while (8 & h.__g && ++
|
|
408
|
-
h.state = h.__s, h.getChildContext && (r = F({}, r, h.getChildContext())), b && n.__c && h.getSnapshotBeforeUpdate && (v = h.getSnapshotBeforeUpdate(g, _)),
|
|
409
|
-
e &&
|
|
410
|
-
}), n.__k = null), s = n.__k ? L(n, 0) : null), s =
|
|
403
|
+
while (8 & h.__g && ++w < 25);
|
|
404
|
+
h.state = h.__s, h.getChildContext && (r = F({}, r, h.getChildContext())), b && n.__c && h.getSnapshotBeforeUpdate && (v = h.getSnapshotBeforeUpdate(g, _)), T = u && u.type === I && 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) {
|
|
405
|
+
e && Ie(e, e);
|
|
406
|
+
}), n.__k = null), s = n.__k ? L(n, 0) : null), s = we(e, ge(T) ? T : [T], 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(ve), h.__h.length && o.push(h), 1 & h.__g && (h.__g &= -4);
|
|
411
407
|
} catch (e) {
|
|
412
408
|
if (o.length = m, t.__v = null, c || a) {
|
|
413
409
|
if (e.then) {
|
|
414
|
-
if (
|
|
415
|
-
for (
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
410
|
+
if (E = 0, t.__u |= c ? 160 : 128, a) {
|
|
411
|
+
for (~(O = a.indexOf(s || void 0)) || (O = a.length); (k = a[O - 1]) && k.nodeType == 8;) O--;
|
|
412
|
+
for (; O < a.length; O++) if (k = a[O]) {
|
|
413
|
+
if (a[O] = null, k.nodeType == 8) {
|
|
414
|
+
if (k.data.startsWith("$s")) E++ || (D = k);
|
|
415
|
+
else if (E && k.data.startsWith("/$s") && !--E) {
|
|
416
|
+
s = k;
|
|
420
417
|
break;
|
|
421
418
|
}
|
|
422
|
-
} else
|
|
419
|
+
} else if (!E) break;
|
|
423
420
|
}
|
|
424
421
|
}
|
|
425
|
-
if (!
|
|
422
|
+
if (!D) {
|
|
426
423
|
for (; s && s.nodeType == 8 && s.nextSibling;) s = s.nextSibling;
|
|
427
|
-
|
|
424
|
+
D = s;
|
|
428
425
|
}
|
|
429
|
-
t.__c.__z || (t.__c.__z =
|
|
430
|
-
} else a && a.some(
|
|
426
|
+
t.__c.__z || (t.__c.__z = D), t.__e = s;
|
|
427
|
+
} else a && a.some(ve);
|
|
431
428
|
} else t.__e = n.__e;
|
|
432
|
-
t.__k ||= n.__k || [], e.then ||
|
|
429
|
+
t.__k ||= n.__k || [], e.then || Me(t), N.__e(e, t, n);
|
|
433
430
|
}
|
|
434
|
-
} else s = t.__e =
|
|
435
|
-
return (u =
|
|
431
|
+
} else s = t.__e = Pe(n.__e, t, n, r, i, a, o, c, l, e);
|
|
432
|
+
return (u = N.diffed) && u(t), 128 & t.__u ? void 0 : s;
|
|
436
433
|
}
|
|
437
|
-
function
|
|
438
|
-
e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(
|
|
434
|
+
function Me(e) {
|
|
435
|
+
e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(Me));
|
|
439
436
|
}
|
|
440
|
-
function
|
|
441
|
-
for (var r = 0; r < n.length;)
|
|
442
|
-
|
|
437
|
+
function Ne(e, t, n) {
|
|
438
|
+
for (var r = 0; r < n.length;) Fe(n[r++], n[r++], n[r++]);
|
|
439
|
+
N.__c && N.__c(t, e), e.some(function(t) {
|
|
443
440
|
try {
|
|
444
441
|
e = t.__h, t.__h = [], e.some(function(e) {
|
|
445
442
|
e.call(t);
|
|
446
443
|
});
|
|
447
444
|
} catch (e) {
|
|
448
|
-
|
|
445
|
+
N.__e(e, t.__v);
|
|
449
446
|
}
|
|
450
447
|
});
|
|
451
448
|
}
|
|
452
|
-
function
|
|
453
|
-
var u, d, f, p, m, h, g, _, v, y = n.props ||
|
|
449
|
+
function Pe(e, t, n, r, i, a, o, s, c, l) {
|
|
450
|
+
var u, d, f, p, m, h, g, _, v, y = n.props || pe, b = t.props, x = t.type;
|
|
454
451
|
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) {
|
|
455
452
|
for (u = 0; u < a.length; u++) if ((m = a[u]) && (x ? m.localName == x : m.nodeType == 3)) {
|
|
456
453
|
e = m, a[u] = null;
|
|
@@ -459,44 +456,44 @@ function Fe(e, t, n, r, i, a, o, s, c, l) {
|
|
|
459
456
|
}
|
|
460
457
|
if (!e) {
|
|
461
458
|
if (_ = l.ownerDocument || document, !x) return _.createTextNode(b);
|
|
462
|
-
e = _.createElementNS(i, x, b.is && b), s &&= (
|
|
459
|
+
e = _.createElementNS(i, x, b.is && b), s &&= (N.__m && N.__m(t, a), !1), a = null;
|
|
463
460
|
}
|
|
464
461
|
if (x) {
|
|
465
|
-
if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a &&
|
|
466
|
-
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 ||
|
|
467
|
-
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) ||
|
|
468
|
-
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" &&
|
|
462
|
+
if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a && _e.call(l.childNodes), !s && a) for (y = {}, u = 0; u < e.attributes.length; u++) y[(m = e.attributes[u]).name] = m.value;
|
|
463
|
+
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 || ke(e, u, null, m, i);
|
|
464
|
+
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) || ke(e, u, m, y[u], i);
|
|
465
|
+
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" && he.test(x)) && (i = "http://www.w3.org/1999/xhtml"), we(l, ge(p) ? p : [p], t, n, r, i, a, o, a ? a[0] : n.__k && L(n, 0), s, c), a && a.some(ve)), s && x != "textarea" || (u = "value", x == "progress" && h == null ? e.removeAttribute(u) : h == null || h === e[u] && (x != "progress" || h) || ke(e, u, h, y[u], i), u = "checked", g != null && g != e[u] && ke(e, u, g, y[u], i));
|
|
469
466
|
} else y === b || s && e.data == b || (e.data = b);
|
|
470
467
|
return e;
|
|
471
468
|
}
|
|
472
|
-
function
|
|
469
|
+
function Fe(e, t, n, r) {
|
|
473
470
|
try {
|
|
474
|
-
typeof e == "function" ? (
|
|
471
|
+
typeof e == "function" ? t ? t.__x = e(t) || 1 : (r &&= r.__c || r.__e) && (t = r.__x) && (r.__x = null, typeof t == "function" ? t() : e(null)) : e.current = t;
|
|
475
472
|
} catch (e) {
|
|
476
|
-
|
|
473
|
+
N.__e(e, n);
|
|
477
474
|
}
|
|
478
475
|
}
|
|
479
|
-
function
|
|
476
|
+
function Ie(e, t, n) {
|
|
480
477
|
var r, i;
|
|
481
|
-
if (
|
|
478
|
+
if (N.unmount && N.unmount(e), !(r = e.ref) || r.current && r.current != e.__e || Fe(r, null, t, e), r = e.__c) {
|
|
482
479
|
if (r.componentWillUnmount) try {
|
|
483
480
|
r.componentWillUnmount();
|
|
484
481
|
} catch (e) {
|
|
485
|
-
|
|
482
|
+
N.__e(e, t);
|
|
486
483
|
}
|
|
487
484
|
r.__P = r.__n = null;
|
|
488
485
|
}
|
|
489
|
-
if (r = e.__k) for (i = 0; i < r.length; i++) r[i] &&
|
|
490
|
-
(r = e.__e) && (n ||
|
|
486
|
+
if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && Ie(r[i], t, typeof e.type != "function" || n && !e.props.__P);
|
|
487
|
+
(r = e.__e) && (n || ve(r), r.__e && (r.__e = null)), e.__e = e.__c = e.__ = null;
|
|
491
488
|
}
|
|
492
|
-
function
|
|
489
|
+
function Le(e, t, n) {
|
|
493
490
|
return this.constructor(e, n);
|
|
494
491
|
}
|
|
495
|
-
function
|
|
492
|
+
function Re(e, t) {
|
|
496
493
|
var n, r, i, a;
|
|
497
|
-
|
|
494
|
+
N.__ && N.__(e, t), t.nodeType == 9 && (t = t.documentElement), r = (n = e && 32 & e.__u) ? null : t.__k, t.__k = ye(I, { children: [e] }), i = [], a = [], je(t, t.__k, r || pe, pe, t.namespaceURI, r ? null : t.firstChild ? _e.call(t.childNodes) : null, i, r ? r.__e : t.firstChild, n, a), Ne(i, t.__k, a), t.__k.props.children = null;
|
|
498
495
|
}
|
|
499
|
-
|
|
496
|
+
N = { __e: function(e, t, n, r) {
|
|
500
497
|
for (var i, a, o; t = t.__;) if ((i = t.__c) && !(1 & i.__g)) {
|
|
501
498
|
i.__g |= 4;
|
|
502
499
|
try {
|
|
@@ -506,33 +503,33 @@ M = { __e: function(e, t, n, r) {
|
|
|
506
503
|
}
|
|
507
504
|
}
|
|
508
505
|
throw se = 0, e;
|
|
509
|
-
} }, ae = 0,
|
|
506
|
+
} }, ae = 0, be.prototype.setState = function(e, t) {
|
|
510
507
|
var n = this.__s;
|
|
511
|
-
n && n != this.state || (n = this.__s = F({}, this.state)), typeof e == "function" && (e = e(F({}, n), this.props)), e && (F(n, e), this.__v && (t && this.__k.push(t),
|
|
512
|
-
},
|
|
513
|
-
this.__v && (this.__g |= 4, e && this.__h.push(e),
|
|
514
|
-
},
|
|
508
|
+
n && n != this.state || (n = this.__s = F({}, this.state)), typeof e == "function" && (e = e(F({}, n), this.props)), e && (F(n, e), this.__v && (t && this.__k.push(t), Se(this)));
|
|
509
|
+
}, be.prototype.forceUpdate = function(e) {
|
|
510
|
+
this.__v && (this.__g |= 4, e && this.__h.push(e), Se(this));
|
|
511
|
+
}, be.prototype.render = I, P = [], se = 0, ce = function(e, t) {
|
|
515
512
|
return e.__v.__b - t.__v.__b;
|
|
516
|
-
}, le = Symbol(),
|
|
513
|
+
}, le = Symbol(), ue = /(PointerCapture)$|Capture$/i, de = 0, fe = {};
|
|
517
514
|
//#endregion
|
|
518
|
-
//#region node_modules/.pnpm/preact@11.0.
|
|
519
|
-
var R, z, Be, Ve
|
|
520
|
-
function
|
|
521
|
-
B.__h && B.__h(z, e,
|
|
515
|
+
//#region node_modules/.pnpm/preact@11.0.1/node_modules/preact/hooks/dist/hooks.mjs
|
|
516
|
+
var R, z, ze, Be, Ve = Object.is, He = 0, Ue = [], We = [], B = N, Ge = B.__b, Ke = B.__r, qe = B.diffed, Je = B.__c, Ye = B.unmount, Xe = B.__;
|
|
517
|
+
function Ze(e, t) {
|
|
518
|
+
B.__h && B.__h(z, e, He || t), He = 0;
|
|
522
519
|
var n = z.__H || (z.__H = {
|
|
523
520
|
__: [],
|
|
524
521
|
__h: []
|
|
525
522
|
});
|
|
526
523
|
return e >= n.__.length && n.__.push({}), n.__[e];
|
|
527
524
|
}
|
|
528
|
-
function
|
|
529
|
-
return
|
|
525
|
+
function Qe(e) {
|
|
526
|
+
return He = 1, $e(ct, e);
|
|
530
527
|
}
|
|
531
|
-
function
|
|
532
|
-
var r =
|
|
533
|
-
if (r.t = e, !r.__c && (r.__ = [n ? n(t) :
|
|
528
|
+
function $e(e, t, n) {
|
|
529
|
+
var r = Ze(R++, 2);
|
|
530
|
+
if (r.t = e, !r.__c && (r.__ = [n ? n(t) : ct(void 0, t), function(e) {
|
|
534
531
|
var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
|
|
535
|
-
|
|
532
|
+
Ve(t, n) || (r.__N = [n, r.__[1]], r.__c.setState({}));
|
|
536
533
|
}], r.__c = z, !z.__f)) {
|
|
537
534
|
z.__f = !0;
|
|
538
535
|
var i = z.shouldComponentUpdate;
|
|
@@ -541,7 +538,7 @@ function et(e, t, n) {
|
|
|
541
538
|
if (!r) return !0;
|
|
542
539
|
var a = !1, o = this.props != e;
|
|
543
540
|
if (r.__.some(function(e) {
|
|
544
|
-
e.__N && (a = !0,
|
|
541
|
+
e.__N && (a = !0, Ve(e.__[0], e.__N[0]) || (o = !0));
|
|
545
542
|
}), i) {
|
|
546
543
|
var s = i.call(this, e, t, n);
|
|
547
544
|
return a ? s || o : s;
|
|
@@ -551,71 +548,71 @@ function et(e, t, n) {
|
|
|
551
548
|
}
|
|
552
549
|
return r.__;
|
|
553
550
|
}
|
|
554
|
-
function
|
|
555
|
-
var n =
|
|
556
|
-
!B.__s &&
|
|
551
|
+
function et(e, t) {
|
|
552
|
+
var n = Ze(R++, 3);
|
|
553
|
+
!B.__s && st(n.__H, t) && (n.__P = !0, n.__ = e, n.u = t, z.__H.__h.push(n));
|
|
557
554
|
}
|
|
558
|
-
function
|
|
559
|
-
var n =
|
|
560
|
-
!B.__s &&
|
|
555
|
+
function V(e, t) {
|
|
556
|
+
var n = Ze(R++, 4);
|
|
557
|
+
!B.__s && st(n.__H, t) && (n.__P = !1, n.__ = e, n.u = t, z.__h.push(n));
|
|
561
558
|
}
|
|
562
|
-
function
|
|
563
|
-
return
|
|
559
|
+
function H(e) {
|
|
560
|
+
return He = 5, tt(function() {
|
|
564
561
|
return { current: e };
|
|
565
562
|
}, []);
|
|
566
563
|
}
|
|
567
|
-
function
|
|
568
|
-
var n =
|
|
569
|
-
return
|
|
564
|
+
function tt(e, t) {
|
|
565
|
+
var n = Ze(R++, 7);
|
|
566
|
+
return st(n.__H, t) && (n.__ = e(), n.__H = t), n.__;
|
|
570
567
|
}
|
|
571
|
-
function
|
|
568
|
+
function nt() {
|
|
572
569
|
var e;
|
|
573
570
|
do {
|
|
574
|
-
for (; e =
|
|
575
|
-
|
|
571
|
+
for (; e = We.shift();) try {
|
|
572
|
+
U(e);
|
|
576
573
|
} catch (t) {
|
|
577
574
|
B.__e(t, { __: (e = e.__P) && e.__v });
|
|
578
575
|
}
|
|
579
|
-
for (; e =
|
|
576
|
+
for (; e = Ue.shift();) {
|
|
580
577
|
var t = e.__H;
|
|
581
578
|
if (e.__P && t) try {
|
|
582
|
-
t.__h.some(
|
|
579
|
+
t.__h.some(U), t.__h.some(ot), t.__h = [];
|
|
583
580
|
} catch (n) {
|
|
584
581
|
t.__h = [], B.__e(n, e.__v);
|
|
585
582
|
}
|
|
586
583
|
}
|
|
587
|
-
} while (
|
|
584
|
+
} while (We.length);
|
|
588
585
|
}
|
|
589
586
|
B.__b = function(e) {
|
|
590
|
-
z = null,
|
|
587
|
+
z = null, Ge && Ge(e);
|
|
591
588
|
}, B.__ = function(e, t) {
|
|
592
|
-
e && t.__k && t.__k.__m && (e.__m = t.__k.__m),
|
|
589
|
+
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Xe && Xe(e, t);
|
|
593
590
|
}, B.__r = function(e) {
|
|
594
|
-
|
|
591
|
+
Ke && Ke(e), R = 0;
|
|
595
592
|
var t = (z = e.__c).__H;
|
|
596
|
-
t && (
|
|
593
|
+
t && (ze == z ? z.__h = [] : (t.__h.some(U), t.__h.some(ot), R = 0), t.__h = [], t.__.some(function(e) {
|
|
597
594
|
e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
|
|
598
|
-
})),
|
|
595
|
+
})), ze = z;
|
|
599
596
|
}, B.diffed = function(e) {
|
|
600
|
-
|
|
597
|
+
qe && qe(e);
|
|
601
598
|
var t = e.__c;
|
|
602
|
-
t && t.__H && (t.__H.__h.length &&
|
|
599
|
+
t && t.__H && (t.__H.__h.length && at(Ue.push(t)), t.__H.__.some(function(e) {
|
|
603
600
|
e.u && (e.__H = e.u);
|
|
604
|
-
})),
|
|
601
|
+
})), ze = z = null;
|
|
605
602
|
}, B.__c = function(e, t) {
|
|
606
603
|
t.some(function(e) {
|
|
607
604
|
try {
|
|
608
|
-
e.__h.some(
|
|
609
|
-
return !e.__ ||
|
|
605
|
+
e.__h.some(U), e.__h = e.__h.filter(function(e) {
|
|
606
|
+
return !e.__ || ot(e);
|
|
610
607
|
});
|
|
611
608
|
} catch (n) {
|
|
612
609
|
t.some(function(e) {
|
|
613
610
|
e.__h &&= [];
|
|
614
611
|
}), t = [], B.__e(n, e.__v);
|
|
615
612
|
}
|
|
616
|
-
}),
|
|
613
|
+
}), Je && Je(e, t);
|
|
617
614
|
}, B.unmount = function(e) {
|
|
618
|
-
|
|
615
|
+
Ye && Ye(e);
|
|
619
616
|
var t, n, r = e.__c;
|
|
620
617
|
r && r.__H && (r.__H.__.some(function(r) {
|
|
621
618
|
try {
|
|
@@ -624,44 +621,44 @@ B.__b = function(e) {
|
|
|
624
621
|
for (n = e.__; n && (!n.__c || !n.__c.__P);) n = n.__;
|
|
625
622
|
n &&= n.__c;
|
|
626
623
|
}
|
|
627
|
-
r.__P = n,
|
|
628
|
-
} else
|
|
624
|
+
r.__P = n, at(We.push(r));
|
|
625
|
+
} else U(r);
|
|
629
626
|
} catch (e) {
|
|
630
627
|
t = e;
|
|
631
628
|
}
|
|
632
629
|
}), r.__H = void 0, t && B.__e(t, r.__v));
|
|
633
630
|
};
|
|
634
|
-
var
|
|
635
|
-
function
|
|
631
|
+
var rt = typeof requestAnimationFrame == "function";
|
|
632
|
+
function it(e) {
|
|
636
633
|
var t, n = function() {
|
|
637
|
-
clearTimeout(r),
|
|
634
|
+
clearTimeout(r), rt && cancelAnimationFrame(t), setTimeout(e);
|
|
638
635
|
}, r = setTimeout(n, 35);
|
|
639
|
-
|
|
636
|
+
rt && (t = requestAnimationFrame(n));
|
|
640
637
|
}
|
|
641
|
-
function
|
|
642
|
-
e != 1 &&
|
|
638
|
+
function at(e) {
|
|
639
|
+
e != 1 && Be == B.requestAnimationFrame || ((Be = B.requestAnimationFrame) || it)(nt);
|
|
643
640
|
}
|
|
644
|
-
function
|
|
641
|
+
function U(e) {
|
|
645
642
|
var t = z, n = e.__c;
|
|
646
643
|
typeof n == "function" && (e.__c = void 0, n()), z = t;
|
|
647
644
|
}
|
|
648
|
-
function
|
|
645
|
+
function ot(e) {
|
|
649
646
|
var t = z;
|
|
650
647
|
e.__c = e.__(), z = t;
|
|
651
648
|
}
|
|
652
|
-
function
|
|
649
|
+
function st(e, t) {
|
|
653
650
|
return !e || e.length != t.length || t.some(function(t, n) {
|
|
654
|
-
return !
|
|
651
|
+
return !Ve(t, e[n]);
|
|
655
652
|
});
|
|
656
653
|
}
|
|
657
|
-
function
|
|
654
|
+
function ct(e, t) {
|
|
658
655
|
return typeof t == "function" ? t(e) : t;
|
|
659
656
|
}
|
|
660
657
|
//#endregion
|
|
661
|
-
//#region node_modules/.pnpm/preact@11.0.
|
|
662
|
-
var
|
|
658
|
+
//#region node_modules/.pnpm/preact@11.0.1/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
|
|
659
|
+
var lt = 0;
|
|
663
660
|
Array.isArray;
|
|
664
|
-
function
|
|
661
|
+
function W(e, t, n, r, i, a) {
|
|
665
662
|
t ||= {};
|
|
666
663
|
var o, s, c = t;
|
|
667
664
|
if ("ref" in c && typeof e != "function") for (s in c = {}, t) s == "ref" ? o = t[s] : c[s] = t[s];
|
|
@@ -676,16 +673,16 @@ function U(e, t, n, r, i, a) {
|
|
|
676
673
|
__e: null,
|
|
677
674
|
__c: null,
|
|
678
675
|
constructor: void 0,
|
|
679
|
-
__v: --
|
|
676
|
+
__v: --lt,
|
|
680
677
|
__i: -1,
|
|
681
678
|
__u: 0
|
|
682
679
|
};
|
|
683
|
-
return (i || a) && (l.__source = i, l.__self = a),
|
|
680
|
+
return (i || a) && (l.__source = i, l.__self = a), N.vnode && N.vnode(l), l;
|
|
684
681
|
}
|
|
685
682
|
//#endregion
|
|
686
683
|
//#region src/components/icons.tsx
|
|
687
|
-
function
|
|
688
|
-
return /* @__PURE__ */
|
|
684
|
+
function G({ name: e, size: t, children: n }) {
|
|
685
|
+
return /* @__PURE__ */ W("svg", {
|
|
689
686
|
"data-icon": e,
|
|
690
687
|
"aria-hidden": "true",
|
|
691
688
|
focusable: "false",
|
|
@@ -700,83 +697,83 @@ function W({ name: e, size: t, children: n }) {
|
|
|
700
697
|
children: n
|
|
701
698
|
});
|
|
702
699
|
}
|
|
703
|
-
function
|
|
704
|
-
return /* @__PURE__ */
|
|
700
|
+
function ut({ size: e = 26 }) {
|
|
701
|
+
return /* @__PURE__ */ W(G, {
|
|
705
702
|
name: "chat",
|
|
706
703
|
size: e,
|
|
707
|
-
children: [/* @__PURE__ */
|
|
704
|
+
children: [/* @__PURE__ */ W("path", { d: "M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z" }), /* @__PURE__ */ W("path", {
|
|
708
705
|
d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
|
|
709
706
|
"stroke-width": "2.5"
|
|
710
707
|
})]
|
|
711
708
|
});
|
|
712
709
|
}
|
|
713
|
-
function
|
|
714
|
-
return /* @__PURE__ */
|
|
710
|
+
function dt({ size: e = 26 }) {
|
|
711
|
+
return /* @__PURE__ */ W(G, {
|
|
715
712
|
name: "message",
|
|
716
713
|
size: e,
|
|
717
|
-
children: /* @__PURE__ */
|
|
714
|
+
children: /* @__PURE__ */ W("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" })
|
|
718
715
|
});
|
|
719
716
|
}
|
|
720
|
-
function
|
|
721
|
-
return /* @__PURE__ */
|
|
717
|
+
function ft({ size: e = 26 }) {
|
|
718
|
+
return /* @__PURE__ */ W(G, {
|
|
722
719
|
name: "sparkle",
|
|
723
720
|
size: e,
|
|
724
|
-
children: [/* @__PURE__ */
|
|
721
|
+
children: [/* @__PURE__ */ W("path", { d: "M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z" }), /* @__PURE__ */ W("path", { d: "M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z" })]
|
|
725
722
|
});
|
|
726
723
|
}
|
|
727
|
-
function
|
|
728
|
-
return /* @__PURE__ */
|
|
724
|
+
function pt({ size: e = 26 }) {
|
|
725
|
+
return /* @__PURE__ */ W(G, {
|
|
729
726
|
name: "chevron-down",
|
|
730
727
|
size: e,
|
|
731
|
-
children: /* @__PURE__ */
|
|
728
|
+
children: /* @__PURE__ */ W("path", { d: "M6 9l6 6 6-6" })
|
|
732
729
|
});
|
|
733
730
|
}
|
|
734
|
-
function
|
|
735
|
-
return /* @__PURE__ */
|
|
731
|
+
function mt({ size: e = 18 }) {
|
|
732
|
+
return /* @__PURE__ */ W(G, {
|
|
736
733
|
name: "close",
|
|
737
734
|
size: e,
|
|
738
|
-
children: /* @__PURE__ */
|
|
735
|
+
children: /* @__PURE__ */ W("path", { d: "M6 6l12 12M18 6L6 18" })
|
|
739
736
|
});
|
|
740
737
|
}
|
|
741
|
-
var
|
|
742
|
-
function
|
|
743
|
-
return /* @__PURE__ */
|
|
738
|
+
var ht = "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";
|
|
739
|
+
function gt({ size: e = 16 }) {
|
|
740
|
+
return /* @__PURE__ */ W(G, {
|
|
744
741
|
name: "thumb-up",
|
|
745
742
|
size: e,
|
|
746
|
-
children: /* @__PURE__ */
|
|
743
|
+
children: /* @__PURE__ */ W("path", { d: ht })
|
|
747
744
|
});
|
|
748
745
|
}
|
|
749
|
-
function
|
|
750
|
-
return /* @__PURE__ */
|
|
746
|
+
function _t({ size: e = 16 }) {
|
|
747
|
+
return /* @__PURE__ */ W(G, {
|
|
751
748
|
name: "thumb-down",
|
|
752
749
|
size: e,
|
|
753
|
-
children: /* @__PURE__ */
|
|
754
|
-
d:
|
|
750
|
+
children: /* @__PURE__ */ W("path", {
|
|
751
|
+
d: ht,
|
|
755
752
|
transform: "matrix(1 0 0 -1 0 24)"
|
|
756
753
|
})
|
|
757
754
|
});
|
|
758
755
|
}
|
|
759
756
|
//#endregion
|
|
760
757
|
//#region src/components/Launcher.tsx
|
|
761
|
-
var
|
|
762
|
-
chat:
|
|
763
|
-
message:
|
|
764
|
-
sparkle:
|
|
765
|
-
},
|
|
766
|
-
"chevron-down":
|
|
767
|
-
close:
|
|
758
|
+
var vt = {
|
|
759
|
+
chat: ut,
|
|
760
|
+
message: dt,
|
|
761
|
+
sparkle: ft
|
|
762
|
+
}, yt = {
|
|
763
|
+
"chevron-down": pt,
|
|
764
|
+
close: mt
|
|
768
765
|
};
|
|
769
|
-
function
|
|
770
|
-
let [l, u] =
|
|
771
|
-
return /* @__PURE__ */
|
|
766
|
+
function bt({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl: a, openIcon: o = "chevron-down", buttonRef: s, text: c = e }) {
|
|
767
|
+
let [l, u] = Qe("loading"), [d, f] = Qe("loading"), p = r !== void 0 && l !== "failed", m = a !== void 0 && d !== "failed", h = p && !t && l === "loaded", g = m && t && d === "loaded", _ = vt[i] ?? ut, v = yt[o] ?? pt;
|
|
768
|
+
return /* @__PURE__ */ W("button", {
|
|
772
769
|
type: "button",
|
|
773
770
|
class: "whoo-widget-launcher",
|
|
774
771
|
onClick: n,
|
|
775
772
|
"aria-label": t ? c.closeChat : c.openChat,
|
|
776
773
|
ref: s,
|
|
777
774
|
children: [
|
|
778
|
-
t ? g ? null : /* @__PURE__ */
|
|
779
|
-
p ? /* @__PURE__ */
|
|
775
|
+
t ? g ? null : /* @__PURE__ */ W(v, {}) : h ? null : /* @__PURE__ */ W(_, {}),
|
|
776
|
+
p ? /* @__PURE__ */ W("img", {
|
|
780
777
|
class: "whoo-widget-launcher-icon-image",
|
|
781
778
|
src: r,
|
|
782
779
|
alt: "",
|
|
@@ -785,7 +782,7 @@ function St({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl:
|
|
|
785
782
|
onLoad: () => u("loaded"),
|
|
786
783
|
onError: () => u("failed")
|
|
787
784
|
}) : null,
|
|
788
|
-
m ? /* @__PURE__ */
|
|
785
|
+
m ? /* @__PURE__ */ W("img", {
|
|
789
786
|
class: "whoo-widget-launcher-icon-image",
|
|
790
787
|
src: a,
|
|
791
788
|
alt: "",
|
|
@@ -799,7 +796,7 @@ function St({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl:
|
|
|
799
796
|
}
|
|
800
797
|
//#endregion
|
|
801
798
|
//#region src/i18n/index.ts
|
|
802
|
-
var
|
|
799
|
+
var xt = {
|
|
803
800
|
en: e,
|
|
804
801
|
fr: {
|
|
805
802
|
openChat: "Ouvrir le chat",
|
|
@@ -827,7 +824,9 @@ var Ct = {
|
|
|
827
824
|
feedbackFailed: "Impossible d’envoyer votre commentaire",
|
|
828
825
|
conversationCleared: "Conversation effacée",
|
|
829
826
|
genericError: "Une erreur s’est produite. Veuillez réessayer.",
|
|
830
|
-
sessionExpired: "Cette session de chat a expiré. Rechargez la page pour continuer."
|
|
827
|
+
sessionExpired: "Cette session de chat a expiré. Rechargez la page pour continuer.",
|
|
828
|
+
opensInNewTab: "(s’ouvre dans un nouvel onglet)",
|
|
829
|
+
agreeToNotice: "J’accepte"
|
|
831
830
|
},
|
|
832
831
|
es: {
|
|
833
832
|
openChat: "Abrir chat",
|
|
@@ -855,7 +854,9 @@ var Ct = {
|
|
|
855
854
|
feedbackFailed: "No se pudieron enviar sus comentarios",
|
|
856
855
|
conversationCleared: "Se inició una nueva conversación",
|
|
857
856
|
genericError: "Algo salió mal. Inténtelo de nuevo.",
|
|
858
|
-
sessionExpired: "Esta sesión de chat expiró. Vuelva a cargar la página para continuar."
|
|
857
|
+
sessionExpired: "Esta sesión de chat expiró. Vuelva a cargar la página para continuar.",
|
|
858
|
+
opensInNewTab: "(se abre en una pestaña nueva)",
|
|
859
|
+
agreeToNotice: "Acepto"
|
|
859
860
|
},
|
|
860
861
|
pt: {
|
|
861
862
|
openChat: "Abrir chat",
|
|
@@ -883,7 +884,9 @@ var Ct = {
|
|
|
883
884
|
feedbackFailed: "Não foi possível enviar o feedback",
|
|
884
885
|
conversationCleared: "Nova conversa iniciada",
|
|
885
886
|
genericError: "Algo deu errado. Tente novamente.",
|
|
886
|
-
sessionExpired: "Esta sessão de chat expirou. Recarregue a página para continuar."
|
|
887
|
+
sessionExpired: "Esta sessão de chat expirou. Recarregue a página para continuar.",
|
|
888
|
+
opensInNewTab: "(abre em uma nova aba)",
|
|
889
|
+
agreeToNotice: "Concordo"
|
|
887
890
|
},
|
|
888
891
|
de: {
|
|
889
892
|
openChat: "Chat öffnen",
|
|
@@ -911,7 +914,9 @@ var Ct = {
|
|
|
911
914
|
feedbackFailed: "Feedback konnte nicht gesendet werden",
|
|
912
915
|
conversationCleared: "Neue Unterhaltung gestartet",
|
|
913
916
|
genericError: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.",
|
|
914
|
-
sessionExpired: "Diese Chat-Sitzung ist abgelaufen. Laden Sie die Seite neu, um fortzufahren."
|
|
917
|
+
sessionExpired: "Diese Chat-Sitzung ist abgelaufen. Laden Sie die Seite neu, um fortzufahren.",
|
|
918
|
+
opensInNewTab: "(öffnet sich in neuem Tab)",
|
|
919
|
+
agreeToNotice: "Ich stimme zu"
|
|
915
920
|
},
|
|
916
921
|
it: {
|
|
917
922
|
openChat: "Apri la chat",
|
|
@@ -939,7 +944,9 @@ var Ct = {
|
|
|
939
944
|
feedbackFailed: "Impossibile inviare il feedback",
|
|
940
945
|
conversationCleared: "Nuova conversazione avviata",
|
|
941
946
|
genericError: "Si è verificato un errore. Riprovi.",
|
|
942
|
-
sessionExpired: "Questa sessione di chat è scaduta. Ricarichi la pagina per continuare."
|
|
947
|
+
sessionExpired: "Questa sessione di chat è scaduta. Ricarichi la pagina per continuare.",
|
|
948
|
+
opensInNewTab: "(si apre in una nuova scheda)",
|
|
949
|
+
agreeToNotice: "Accetto"
|
|
943
950
|
},
|
|
944
951
|
ja: {
|
|
945
952
|
openChat: "チャットを開く",
|
|
@@ -967,7 +974,9 @@ var Ct = {
|
|
|
967
974
|
feedbackFailed: "フィードバックを送信できませんでした",
|
|
968
975
|
conversationCleared: "会話を消去しました",
|
|
969
976
|
genericError: "エラーが発生しました。もう一度お試しください。",
|
|
970
|
-
sessionExpired: "このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。"
|
|
977
|
+
sessionExpired: "このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。",
|
|
978
|
+
opensInNewTab: "(新しいタブで開きます)",
|
|
979
|
+
agreeToNotice: "同意する"
|
|
971
980
|
},
|
|
972
981
|
zh: {
|
|
973
982
|
openChat: "打开聊天",
|
|
@@ -995,7 +1004,9 @@ var Ct = {
|
|
|
995
1004
|
feedbackFailed: "反馈提交失败",
|
|
996
1005
|
conversationCleared: "对话已清除",
|
|
997
1006
|
genericError: "出了点问题,请重试。",
|
|
998
|
-
sessionExpired: "此聊天会话已过期。请刷新页面后继续。"
|
|
1007
|
+
sessionExpired: "此聊天会话已过期。请刷新页面后继续。",
|
|
1008
|
+
opensInNewTab: "(将在新标签页中打开)",
|
|
1009
|
+
agreeToNotice: "我同意"
|
|
999
1010
|
},
|
|
1000
1011
|
ru: {
|
|
1001
1012
|
openChat: "Открыть чат",
|
|
@@ -1023,7 +1034,9 @@ var Ct = {
|
|
|
1023
1034
|
feedbackFailed: "Не удалось отправить отзыв",
|
|
1024
1035
|
conversationCleared: "Диалог очищен",
|
|
1025
1036
|
genericError: "Что-то пошло не так. Попробуйте ещё раз.",
|
|
1026
|
-
sessionExpired: "Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить."
|
|
1037
|
+
sessionExpired: "Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить.",
|
|
1038
|
+
opensInNewTab: "(откроется в новой вкладке)",
|
|
1039
|
+
agreeToNotice: "Принимаю"
|
|
1027
1040
|
},
|
|
1028
1041
|
hi: {
|
|
1029
1042
|
openChat: "चैट खोलें",
|
|
@@ -1051,7 +1064,9 @@ var Ct = {
|
|
|
1051
1064
|
feedbackFailed: "फ़ीडबैक नहीं भेजा जा सका",
|
|
1052
1065
|
conversationCleared: "बातचीत मिटा दी गई",
|
|
1053
1066
|
genericError: "कुछ ग़लत हो गया। कृपया फिर से कोशिश करें।",
|
|
1054
|
-
sessionExpired: "यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।"
|
|
1067
|
+
sessionExpired: "यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।",
|
|
1068
|
+
opensInNewTab: "(नए टैब में खुलता है)",
|
|
1069
|
+
agreeToNotice: "मैं सहमत हूँ"
|
|
1055
1070
|
},
|
|
1056
1071
|
ar: {
|
|
1057
1072
|
openChat: "فتح الدردشة",
|
|
@@ -1079,35 +1094,59 @@ var Ct = {
|
|
|
1079
1094
|
feedbackFailed: "تعذّر إرسال الملاحظات",
|
|
1080
1095
|
conversationCleared: "تم مسح المحادثة",
|
|
1081
1096
|
genericError: "حدث خطأ ما. يُرجى المحاولة مرة أخرى.",
|
|
1082
|
-
sessionExpired: "انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة."
|
|
1097
|
+
sessionExpired: "انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة.",
|
|
1098
|
+
opensInNewTab: "(يُفتح في علامة تبويب جديدة)",
|
|
1099
|
+
agreeToNotice: "أوافق"
|
|
1083
1100
|
}
|
|
1084
|
-
},
|
|
1101
|
+
}, St = Object.freeze(Object.keys(xt)), Ct = {
|
|
1085
1102
|
pt: "pt-BR",
|
|
1086
1103
|
es: "es-419",
|
|
1087
1104
|
zh: "zh-Hans"
|
|
1088
|
-
},
|
|
1089
|
-
function
|
|
1090
|
-
return
|
|
1105
|
+
}, wt = /* @__PURE__ */ new Set(["ar"]), Tt = /^[a-z]{2,8}([-_][a-z0-9]{1,8})*$/i, Et = /^zh[-_](hant|tw|hk|mo)(?=$|[-_])/i;
|
|
1106
|
+
function Dt(e) {
|
|
1107
|
+
return xt[e];
|
|
1091
1108
|
}
|
|
1092
|
-
function
|
|
1109
|
+
function Ot(e) {
|
|
1093
1110
|
let t = e.trim();
|
|
1094
|
-
if (!
|
|
1111
|
+
if (!Tt.test(t) || Et.test(t)) return null;
|
|
1095
1112
|
let n = t.split(/[-_]/)[0].toLowerCase();
|
|
1096
|
-
return Object.hasOwn(
|
|
1113
|
+
return Object.hasOwn(xt, n) ? n : null;
|
|
1097
1114
|
}
|
|
1098
|
-
function
|
|
1115
|
+
function kt(e, t) {
|
|
1099
1116
|
let n = null;
|
|
1100
|
-
return e != null && e !== "" && (n = typeof e == "string" ?
|
|
1117
|
+
return e != null && e !== "" && (n = typeof e == "string" ? Ot(e) : null, n || console.warn(`whoo-aiden-widget: ignoring \`language\` ${At(e)} -- expected one of ${St.join(", ")} (or a regional tag like pt-BR). Using the page's language instead.`)), n ??= typeof t == "string" ? Ot(t) : null, n ??= "en", {
|
|
1101
1118
|
language: n,
|
|
1102
|
-
tag:
|
|
1103
|
-
dir:
|
|
1119
|
+
tag: Ct[n] ?? n,
|
|
1120
|
+
dir: wt.has(n) ? "rtl" : "ltr"
|
|
1104
1121
|
};
|
|
1105
1122
|
}
|
|
1106
|
-
function
|
|
1123
|
+
function At(e) {
|
|
1107
1124
|
return typeof e == "string" ? JSON.stringify(e) : `(a ${typeof e})`;
|
|
1108
1125
|
}
|
|
1109
|
-
function
|
|
1110
|
-
|
|
1126
|
+
function jt(e) {
|
|
1127
|
+
if (typeof e != "string") return null;
|
|
1128
|
+
let t = e.trim().replace(/_/g, "-");
|
|
1129
|
+
return Tt.test(t) ? t : null;
|
|
1130
|
+
}
|
|
1131
|
+
function Mt(e, t, n) {
|
|
1132
|
+
if (e != null && e !== "") {
|
|
1133
|
+
let t = jt(e);
|
|
1134
|
+
if (t) return t;
|
|
1135
|
+
console.warn(`whoo-aiden-widget: ignoring \`contentLanguage\` ${At(e)} -- expected a language tag such as 'nl' or 'pt-BR'. Using the page's language instead.`);
|
|
1136
|
+
}
|
|
1137
|
+
return jt(t) ?? jt(n) ?? "";
|
|
1138
|
+
}
|
|
1139
|
+
function Nt(e) {
|
|
1140
|
+
let t = e.indexOf("{name}");
|
|
1141
|
+
return t === -1 ? {
|
|
1142
|
+
before: e,
|
|
1143
|
+
after: "",
|
|
1144
|
+
hasName: !1
|
|
1145
|
+
} : {
|
|
1146
|
+
before: e.slice(0, t),
|
|
1147
|
+
after: e.slice(t + 6),
|
|
1148
|
+
hasName: !0
|
|
1149
|
+
};
|
|
1111
1150
|
}
|
|
1112
1151
|
//#endregion
|
|
1113
1152
|
//#region src/viewport.ts
|
|
@@ -1124,6 +1163,8 @@ function Lt(e) {
|
|
|
1124
1163
|
return;
|
|
1125
1164
|
}
|
|
1126
1165
|
e.setAttribute(Ft, ""), e.style.setProperty("--whoo-widget-visible-top", `${Math.max(0, t.offsetTop)}px`), e.style.setProperty("--whoo-widget-visible-height", `${t.height}px`);
|
|
1166
|
+
let o = e.getRootNode().activeElement;
|
|
1167
|
+
o && e.contains(o) && typeof o.scrollIntoView == "function" && o.scrollIntoView({ block: "nearest" });
|
|
1127
1168
|
};
|
|
1128
1169
|
return r(), t.addEventListener("resize", r), t.addEventListener("scroll", r), () => {
|
|
1129
1170
|
t.removeEventListener("resize", r), t.removeEventListener("scroll", r), n();
|
|
@@ -1162,28 +1203,33 @@ function Wt(e) {
|
|
|
1162
1203
|
}
|
|
1163
1204
|
//#endregion
|
|
1164
1205
|
//#region src/components/Composer.tsx
|
|
1165
|
-
function Gt(
|
|
1166
|
-
return
|
|
1206
|
+
function Gt(e) {
|
|
1207
|
+
return e.isComposing || e.keyCode === 229;
|
|
1208
|
+
}
|
|
1209
|
+
function Kt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text: o = e, contentLanguage: s }) {
|
|
1210
|
+
return /* @__PURE__ */ W("div", {
|
|
1167
1211
|
class: "whoo-widget-composer",
|
|
1168
1212
|
children: [
|
|
1169
|
-
/* @__PURE__ */
|
|
1213
|
+
/* @__PURE__ */ W("label", {
|
|
1170
1214
|
class: "whoo-widget-sr-only",
|
|
1171
1215
|
for: "whoo-widget-composer-input",
|
|
1172
1216
|
children: o.message
|
|
1173
1217
|
}),
|
|
1174
|
-
/* @__PURE__ */
|
|
1218
|
+
/* @__PURE__ */ W("input", {
|
|
1175
1219
|
id: "whoo-widget-composer-input",
|
|
1176
1220
|
class: "whoo-widget-composer-input",
|
|
1221
|
+
lang: s,
|
|
1222
|
+
autoFocus: !0,
|
|
1177
1223
|
value: t,
|
|
1178
1224
|
readOnly: i,
|
|
1179
1225
|
"aria-disabled": i,
|
|
1180
1226
|
ref: a,
|
|
1181
1227
|
onInput: (e) => n(e.target.value),
|
|
1182
1228
|
onKeyDown: (e) => {
|
|
1183
|
-
e.key === "Enter" && r();
|
|
1229
|
+
e.key === "Enter" && !Gt(e) && r();
|
|
1184
1230
|
}
|
|
1185
1231
|
}),
|
|
1186
|
-
/* @__PURE__ */
|
|
1232
|
+
/* @__PURE__ */ W("button", {
|
|
1187
1233
|
type: "button",
|
|
1188
1234
|
class: "whoo-widget-composer-send",
|
|
1189
1235
|
"aria-disabled": i,
|
|
@@ -1197,8 +1243,8 @@ function Gt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text:
|
|
|
1197
1243
|
}
|
|
1198
1244
|
//#endregion
|
|
1199
1245
|
//#region src/components/ErrorBanner.tsx
|
|
1200
|
-
function
|
|
1201
|
-
return /* @__PURE__ */
|
|
1246
|
+
function qt({ message: e }) {
|
|
1247
|
+
return /* @__PURE__ */ W("div", {
|
|
1202
1248
|
class: "whoo-widget-error-banner",
|
|
1203
1249
|
role: "alert",
|
|
1204
1250
|
children: e
|
|
@@ -1206,8 +1252,8 @@ function Kt({ message: e }) {
|
|
|
1206
1252
|
}
|
|
1207
1253
|
//#endregion
|
|
1208
1254
|
//#region src/markdown/tokenizer.ts
|
|
1209
|
-
var
|
|
1210
|
-
function
|
|
1255
|
+
var Jt = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, Yt = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, Xt = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, Zt = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, Qt = /[ \t]*[*+-][ \t]+/y, $t = /https?:\/\/\S+/y, en = /[.,;:!?)\]}>]+$/;
|
|
1256
|
+
function tn(e) {
|
|
1211
1257
|
let t = [], n = 0, r = 0, i = (n) => {
|
|
1212
1258
|
n > r && t.push({
|
|
1213
1259
|
type: "text",
|
|
@@ -1217,13 +1263,13 @@ function en(e) {
|
|
|
1217
1263
|
});
|
|
1218
1264
|
};
|
|
1219
1265
|
for (; n < e.length;) {
|
|
1220
|
-
if ((n === 0 || e[n - 1] === "\n") && (
|
|
1266
|
+
if ((n === 0 || e[n - 1] === "\n") && (Qt.lastIndex = n, Qt.exec(e))) {
|
|
1221
1267
|
i(n), t.push({
|
|
1222
1268
|
type: "text",
|
|
1223
1269
|
value: "• ",
|
|
1224
1270
|
start: n,
|
|
1225
|
-
end:
|
|
1226
|
-
}), n =
|
|
1271
|
+
end: Qt.lastIndex
|
|
1272
|
+
}), n = Qt.lastIndex, r = n;
|
|
1227
1273
|
continue;
|
|
1228
1274
|
}
|
|
1229
1275
|
if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
|
|
@@ -1236,56 +1282,56 @@ function en(e) {
|
|
|
1236
1282
|
}
|
|
1237
1283
|
}
|
|
1238
1284
|
if (e[n - 1] !== "!") {
|
|
1239
|
-
|
|
1240
|
-
let a =
|
|
1285
|
+
Jt.lastIndex = n;
|
|
1286
|
+
let a = Jt.exec(e);
|
|
1241
1287
|
if (a) {
|
|
1242
1288
|
i(n), t.push({
|
|
1243
1289
|
type: "link",
|
|
1244
1290
|
text: a[1],
|
|
1245
1291
|
url: a[2],
|
|
1246
1292
|
start: n,
|
|
1247
|
-
end:
|
|
1248
|
-
}), n =
|
|
1293
|
+
end: Jt.lastIndex
|
|
1294
|
+
}), n = Jt.lastIndex, r = n;
|
|
1249
1295
|
continue;
|
|
1250
1296
|
}
|
|
1251
1297
|
}
|
|
1252
|
-
|
|
1253
|
-
let a =
|
|
1298
|
+
Yt.lastIndex = n;
|
|
1299
|
+
let a = Yt.exec(e);
|
|
1254
1300
|
if (a) {
|
|
1255
1301
|
i(n), t.push({
|
|
1256
1302
|
type: "bold",
|
|
1257
1303
|
value: a[1],
|
|
1258
1304
|
start: n,
|
|
1259
|
-
end:
|
|
1260
|
-
}), n =
|
|
1305
|
+
end: Yt.lastIndex
|
|
1306
|
+
}), n = Yt.lastIndex, r = n;
|
|
1261
1307
|
continue;
|
|
1262
1308
|
}
|
|
1263
|
-
|
|
1264
|
-
let o =
|
|
1309
|
+
Xt.lastIndex = n;
|
|
1310
|
+
let o = Xt.exec(e);
|
|
1265
1311
|
if (o) {
|
|
1266
1312
|
i(n), t.push({
|
|
1267
1313
|
type: "italic",
|
|
1268
1314
|
value: o[1],
|
|
1269
1315
|
start: n,
|
|
1270
|
-
end:
|
|
1271
|
-
}), n =
|
|
1316
|
+
end: Xt.lastIndex
|
|
1317
|
+
}), n = Xt.lastIndex, r = n;
|
|
1272
1318
|
continue;
|
|
1273
1319
|
}
|
|
1274
|
-
|
|
1275
|
-
let s =
|
|
1320
|
+
Zt.lastIndex = n;
|
|
1321
|
+
let s = Zt.exec(e);
|
|
1276
1322
|
if (s) {
|
|
1277
1323
|
i(n), t.push({
|
|
1278
1324
|
type: "italic",
|
|
1279
1325
|
value: s[1],
|
|
1280
1326
|
start: n,
|
|
1281
|
-
end:
|
|
1282
|
-
}), n =
|
|
1327
|
+
end: Zt.lastIndex
|
|
1328
|
+
}), n = Zt.lastIndex, r = n;
|
|
1283
1329
|
continue;
|
|
1284
1330
|
}
|
|
1285
|
-
|
|
1286
|
-
let c =
|
|
1331
|
+
$t.lastIndex = n;
|
|
1332
|
+
let c = $t.exec(e);
|
|
1287
1333
|
if (c) {
|
|
1288
|
-
let e = c[0].match(
|
|
1334
|
+
let e = c[0].match(en), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
|
|
1289
1335
|
if (a.length > 0) {
|
|
1290
1336
|
i(n), t.push({
|
|
1291
1337
|
type: "link",
|
|
@@ -1303,8 +1349,12 @@ function en(e) {
|
|
|
1303
1349
|
}
|
|
1304
1350
|
//#endregion
|
|
1305
1351
|
//#region src/markdown/render.tsx
|
|
1306
|
-
var
|
|
1307
|
-
function
|
|
1352
|
+
var nn = /^[ \t]*[*+-][ \t]+(.*)$/, rn = /[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Adlam}\p{Script=Samaritan}\p{Script=Mandaic}\p{Script=Hanifi_Rohingya}\p{Script=Mende_Kikakui}]/u;
|
|
1353
|
+
function an(e) {
|
|
1354
|
+
let t = e.match(/\p{L}/u)?.[0];
|
|
1355
|
+
if (t) return rn.test(t) ? "rtl" : "ltr";
|
|
1356
|
+
}
|
|
1357
|
+
function on(e) {
|
|
1308
1358
|
let t = [], n = [], r = [], i = () => {
|
|
1309
1359
|
n.length > 0 && t.push({
|
|
1310
1360
|
type: "text",
|
|
@@ -1317,7 +1367,7 @@ function nn(e) {
|
|
|
1317
1367
|
}), r = [];
|
|
1318
1368
|
};
|
|
1319
1369
|
for (let t of e.split("\n")) {
|
|
1320
|
-
let e = t.match(
|
|
1370
|
+
let e = t.match(nn);
|
|
1321
1371
|
e ? (i(), r.push(e[1])) : (a(), n.push(t));
|
|
1322
1372
|
}
|
|
1323
1373
|
return i(), a(), t.some((e) => e.type === "list") ? t.flatMap((e, n) => {
|
|
@@ -1329,34 +1379,39 @@ function nn(e) {
|
|
|
1329
1379
|
}];
|
|
1330
1380
|
}) : null;
|
|
1331
1381
|
}
|
|
1332
|
-
function
|
|
1333
|
-
return
|
|
1382
|
+
function K(e, t = {}) {
|
|
1383
|
+
return tn(e).map((e, n) => {
|
|
1334
1384
|
switch (e.type) {
|
|
1335
|
-
case "bold": return /* @__PURE__ */
|
|
1336
|
-
case "italic": return /* @__PURE__ */
|
|
1337
|
-
case "link": return /* @__PURE__ */
|
|
1385
|
+
case "bold": return /* @__PURE__ */ W("strong", { children: K(e.value, t) }, n);
|
|
1386
|
+
case "italic": return /* @__PURE__ */ W("em", { children: K(e.value, t) }, n);
|
|
1387
|
+
case "link": return /* @__PURE__ */ W("a", {
|
|
1338
1388
|
href: e.url,
|
|
1339
1389
|
target: "_blank",
|
|
1340
1390
|
rel: "noopener noreferrer",
|
|
1341
|
-
children: [e.text, /* @__PURE__ */
|
|
1391
|
+
children: [e.text, /* @__PURE__ */ W("span", {
|
|
1342
1392
|
class: "whoo-widget-sr-only",
|
|
1343
|
-
|
|
1393
|
+
lang: t.linkCueLang,
|
|
1394
|
+
children: [" ", t.linkCue ?? "(opens in new tab)"]
|
|
1344
1395
|
})]
|
|
1345
|
-
},
|
|
1396
|
+
}, n);
|
|
1346
1397
|
default: return e.value;
|
|
1347
1398
|
}
|
|
1348
1399
|
});
|
|
1349
1400
|
}
|
|
1350
|
-
function
|
|
1351
|
-
let
|
|
1352
|
-
return
|
|
1401
|
+
function sn(e, t = {}) {
|
|
1402
|
+
let n = e.replace(/\r\n?/g, "\n"), r = on(n);
|
|
1403
|
+
return r ? r.map((e, n) => e.type === "list" ? /* @__PURE__ */ W("ul", {
|
|
1353
1404
|
class: "whoo-widget-list",
|
|
1354
|
-
|
|
1355
|
-
|
|
1405
|
+
dir: an(e.items.find((e) => an(e)) ?? ""),
|
|
1406
|
+
children: e.items.map((e, n) => /* @__PURE__ */ W("li", {
|
|
1407
|
+
dir: an(e),
|
|
1408
|
+
children: K(e, t)
|
|
1409
|
+
}, n))
|
|
1410
|
+
}, n) : /* @__PURE__ */ W("span", { children: K(e.text, t) }, n)) : K(n, t);
|
|
1356
1411
|
}
|
|
1357
1412
|
//#endregion
|
|
1358
1413
|
//#region src/components/MessageFeedback.tsx
|
|
1359
|
-
function
|
|
1414
|
+
function cn(e) {
|
|
1360
1415
|
return [
|
|
1361
1416
|
{
|
|
1362
1417
|
value: "",
|
|
@@ -1380,54 +1435,55 @@ function an(e) {
|
|
|
1380
1435
|
}
|
|
1381
1436
|
];
|
|
1382
1437
|
}
|
|
1383
|
-
function
|
|
1384
|
-
let
|
|
1385
|
-
if (
|
|
1386
|
-
let e =
|
|
1387
|
-
if (
|
|
1438
|
+
function ln({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraftChange: a, onSubmitDetailed: o, onCancel: s, text: c = e, contentLanguage: l }) {
|
|
1439
|
+
let u = t.correction ?? "", d = t.category ?? "", f = H(t.status), p = H(null), m = H(null);
|
|
1440
|
+
if (V(() => {
|
|
1441
|
+
let e = f.current;
|
|
1442
|
+
if (f.current = t.status, e === t.status) return;
|
|
1388
1443
|
if (t.status === "expanded") {
|
|
1389
|
-
|
|
1444
|
+
p.current?.focus();
|
|
1390
1445
|
return;
|
|
1391
1446
|
}
|
|
1392
1447
|
if (e === "expanded" && t.status === "idle") {
|
|
1393
|
-
|
|
1448
|
+
m.current?.focus();
|
|
1394
1449
|
return;
|
|
1395
1450
|
}
|
|
1396
1451
|
let r = n?.current;
|
|
1397
1452
|
if (!r) return;
|
|
1398
|
-
let i = r.getRootNode();
|
|
1399
|
-
|
|
1400
|
-
}, [t.status, n]), t.status === "expanded") return /* @__PURE__ */
|
|
1453
|
+
let i = r.getRootNode(), a = r.ownerDocument, o = i.activeElement;
|
|
1454
|
+
(o === null ? a.activeElement === null || a.activeElement === a.body : o === a.body) && r.focus();
|
|
1455
|
+
}, [t.status, n]), t.status === "expanded") return /* @__PURE__ */ W("div", {
|
|
1401
1456
|
class: "whoo-widget-feedback-form",
|
|
1402
1457
|
children: [
|
|
1403
|
-
/* @__PURE__ */
|
|
1458
|
+
/* @__PURE__ */ W("label", { children: [/* @__PURE__ */ W("span", {
|
|
1404
1459
|
class: "whoo-widget-sr-only",
|
|
1405
1460
|
children: c.additionalFeedback
|
|
1406
|
-
}), /* @__PURE__ */
|
|
1407
|
-
ref:
|
|
1461
|
+
}), /* @__PURE__ */ W("textarea", {
|
|
1462
|
+
ref: p,
|
|
1408
1463
|
class: "whoo-widget-feedback-textarea",
|
|
1409
|
-
|
|
1410
|
-
|
|
1464
|
+
lang: l,
|
|
1465
|
+
value: u,
|
|
1466
|
+
onInput: (e) => a(e.target.value, d),
|
|
1411
1467
|
placeholder: c.feedbackPlaceholder
|
|
1412
1468
|
})] }),
|
|
1413
|
-
/* @__PURE__ */
|
|
1469
|
+
/* @__PURE__ */ W("select", {
|
|
1414
1470
|
class: "whoo-widget-feedback-select",
|
|
1415
1471
|
"aria-label": c.feedbackCategory,
|
|
1416
|
-
value:
|
|
1417
|
-
onChange: (e) => a(
|
|
1418
|
-
children:
|
|
1472
|
+
value: d,
|
|
1473
|
+
onChange: (e) => a(u, e.target.value),
|
|
1474
|
+
children: cn(c).map((e) => /* @__PURE__ */ W("option", {
|
|
1419
1475
|
value: e.value,
|
|
1420
1476
|
children: e.label
|
|
1421
1477
|
}, e.value))
|
|
1422
1478
|
}),
|
|
1423
|
-
/* @__PURE__ */
|
|
1479
|
+
/* @__PURE__ */ W("div", {
|
|
1424
1480
|
class: "whoo-widget-feedback-form-buttons",
|
|
1425
|
-
children: [/* @__PURE__ */
|
|
1481
|
+
children: [/* @__PURE__ */ W("button", {
|
|
1426
1482
|
type: "button",
|
|
1427
1483
|
class: "whoo-widget-feedback-submit",
|
|
1428
|
-
onClick: () => o(
|
|
1484
|
+
onClick: () => o(u, d),
|
|
1429
1485
|
children: c.submit
|
|
1430
|
-
}), /* @__PURE__ */
|
|
1486
|
+
}), /* @__PURE__ */ W("button", {
|
|
1431
1487
|
type: "button",
|
|
1432
1488
|
class: "whoo-widget-feedback-cancel",
|
|
1433
1489
|
onClick: s,
|
|
@@ -1436,211 +1492,289 @@ function on({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraft
|
|
|
1436
1492
|
})
|
|
1437
1493
|
]
|
|
1438
1494
|
});
|
|
1439
|
-
let
|
|
1440
|
-
return /* @__PURE__ */
|
|
1495
|
+
let h = t.status === "submitting", g = t.status === "submitted";
|
|
1496
|
+
return /* @__PURE__ */ W("div", {
|
|
1441
1497
|
class: "whoo-widget-feedback",
|
|
1442
|
-
children: [
|
|
1498
|
+
children: [g ? null : /* @__PURE__ */ W("div", {
|
|
1443
1499
|
class: "whoo-widget-feedback-buttons",
|
|
1444
|
-
children: [/* @__PURE__ */
|
|
1500
|
+
children: [/* @__PURE__ */ W("button", {
|
|
1445
1501
|
type: "button",
|
|
1446
1502
|
"aria-label": c.goodResponse,
|
|
1447
|
-
disabled:
|
|
1448
|
-
onClick:
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1503
|
+
"aria-disabled": h,
|
|
1504
|
+
onClick: () => {
|
|
1505
|
+
h || r();
|
|
1506
|
+
},
|
|
1507
|
+
children: /* @__PURE__ */ W(gt, {})
|
|
1508
|
+
}), /* @__PURE__ */ W("button", {
|
|
1509
|
+
ref: m,
|
|
1452
1510
|
type: "button",
|
|
1453
1511
|
"aria-label": c.badResponse,
|
|
1454
|
-
disabled:
|
|
1455
|
-
onClick:
|
|
1456
|
-
|
|
1512
|
+
"aria-disabled": h,
|
|
1513
|
+
onClick: () => {
|
|
1514
|
+
h || i();
|
|
1515
|
+
},
|
|
1516
|
+
children: /* @__PURE__ */ W(_t, {})
|
|
1457
1517
|
})]
|
|
1458
|
-
}), /* @__PURE__ */
|
|
1518
|
+
}), /* @__PURE__ */ W("div", {
|
|
1459
1519
|
role: "status",
|
|
1460
|
-
class:
|
|
1461
|
-
children:
|
|
1520
|
+
class: g ? "whoo-widget-feedback-submitted" : t.status === "error" ? "whoo-widget-feedback-error" : void 0,
|
|
1521
|
+
children: g ? c.feedbackThanks : t.status === "error" ? c.feedbackFailed : null
|
|
1462
1522
|
})]
|
|
1463
1523
|
});
|
|
1464
1524
|
}
|
|
1465
1525
|
//#endregion
|
|
1466
1526
|
//#region src/components/MessageList.tsx
|
|
1467
|
-
function
|
|
1468
|
-
return /* @__PURE__ */
|
|
1527
|
+
function un({ isSlowResponse: e, text: t }) {
|
|
1528
|
+
return /* @__PURE__ */ W("div", {
|
|
1469
1529
|
class: "whoo-widget-pending",
|
|
1470
1530
|
role: "status",
|
|
1471
|
-
children: [/* @__PURE__ */
|
|
1531
|
+
children: [/* @__PURE__ */ W("span", {
|
|
1472
1532
|
class: "whoo-widget-typing",
|
|
1473
1533
|
"aria-hidden": "true",
|
|
1474
1534
|
children: [
|
|
1475
|
-
/* @__PURE__ */
|
|
1476
|
-
/* @__PURE__ */
|
|
1477
|
-
/* @__PURE__ */
|
|
1535
|
+
/* @__PURE__ */ W("span", {}),
|
|
1536
|
+
/* @__PURE__ */ W("span", {}),
|
|
1537
|
+
/* @__PURE__ */ W("span", {})
|
|
1478
1538
|
]
|
|
1479
|
-
}), e ? /* @__PURE__ */
|
|
1539
|
+
}), e ? /* @__PURE__ */ W("span", {
|
|
1480
1540
|
class: "whoo-widget-pending-text",
|
|
1481
1541
|
children: t.lookingItUp
|
|
1482
1542
|
}) : null]
|
|
1483
1543
|
});
|
|
1484
1544
|
}
|
|
1485
|
-
function
|
|
1486
|
-
let [
|
|
1487
|
-
return
|
|
1545
|
+
function dn({ url: e, alt: t, lang: n }) {
|
|
1546
|
+
let [r, i] = Qe(!1);
|
|
1547
|
+
return r ? null : /* @__PURE__ */ W("img", {
|
|
1488
1548
|
class: "whoo-widget-empty-state-image",
|
|
1489
1549
|
src: e,
|
|
1490
1550
|
alt: t,
|
|
1551
|
+
lang: n,
|
|
1491
1552
|
referrerpolicy: "no-referrer",
|
|
1492
|
-
onError: () =>
|
|
1553
|
+
onError: () => i(!0)
|
|
1493
1554
|
});
|
|
1494
1555
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
return /* @__PURE__ */
|
|
1498
|
-
|
|
1556
|
+
var fn = "whoo-widget-notice";
|
|
1557
|
+
function pn({ notice: e, text: t, contentLanguage: n, languageTag: r }) {
|
|
1558
|
+
return /* @__PURE__ */ W("div", {
|
|
1559
|
+
id: fn,
|
|
1560
|
+
class: "whoo-widget-notice",
|
|
1561
|
+
role: "note",
|
|
1562
|
+
children: /* @__PURE__ */ W("div", {
|
|
1563
|
+
class: "whoo-widget-message-text",
|
|
1564
|
+
dir: "auto",
|
|
1565
|
+
lang: n,
|
|
1566
|
+
children: sn(e, {
|
|
1567
|
+
linkCue: t.opensInNewTab,
|
|
1568
|
+
linkCueLang: r
|
|
1569
|
+
})
|
|
1570
|
+
})
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
function mn({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u, text: d, contentLanguage: f, languageTag: p }) {
|
|
1574
|
+
let m = H(null), h = e.id;
|
|
1575
|
+
return /* @__PURE__ */ W("div", {
|
|
1576
|
+
ref: m,
|
|
1499
1577
|
tabIndex: -1,
|
|
1500
1578
|
class: `whoo-widget-message whoo-widget-message--${e.role}`,
|
|
1501
1579
|
children: [
|
|
1502
|
-
/* @__PURE__ */
|
|
1580
|
+
/* @__PURE__ */ W("span", {
|
|
1503
1581
|
class: "whoo-widget-sr-only",
|
|
1504
|
-
children: [
|
|
1582
|
+
children: [
|
|
1583
|
+
e.role === "assistant" ? /* @__PURE__ */ W("span", {
|
|
1584
|
+
lang: f,
|
|
1585
|
+
children: t
|
|
1586
|
+
}) : t,
|
|
1587
|
+
":",
|
|
1588
|
+
" "
|
|
1589
|
+
]
|
|
1505
1590
|
}),
|
|
1506
|
-
i ? /* @__PURE__ */
|
|
1591
|
+
i ? /* @__PURE__ */ W(un, {
|
|
1507
1592
|
isSlowResponse: a,
|
|
1508
1593
|
text: d
|
|
1509
|
-
}) : /* @__PURE__ */
|
|
1594
|
+
}) : /* @__PURE__ */ W("div", {
|
|
1510
1595
|
class: "whoo-widget-message-text",
|
|
1511
1596
|
dir: "auto",
|
|
1512
|
-
|
|
1597
|
+
lang: f,
|
|
1598
|
+
children: sn(e.content, {
|
|
1599
|
+
linkCue: d.opensInNewTab,
|
|
1600
|
+
linkCueLang: p
|
|
1601
|
+
})
|
|
1513
1602
|
}),
|
|
1514
|
-
r && e.role === "assistant" &&
|
|
1603
|
+
r && e.role === "assistant" && h ? /* @__PURE__ */ W(ln, {
|
|
1515
1604
|
state: n,
|
|
1516
|
-
containerRef:
|
|
1517
|
-
onThumbsUp: () => o(
|
|
1518
|
-
onThumbsDown: () => s(
|
|
1519
|
-
onDraftChange: (e, t) => c(
|
|
1520
|
-
onSubmitDetailed: (e, t) => l(
|
|
1521
|
-
onCancel: () => u(
|
|
1522
|
-
text: d
|
|
1605
|
+
containerRef: m,
|
|
1606
|
+
onThumbsUp: () => o(h),
|
|
1607
|
+
onThumbsDown: () => s(h),
|
|
1608
|
+
onDraftChange: (e, t) => c(h, e, t),
|
|
1609
|
+
onSubmitDetailed: (e, t) => l(h, e, t),
|
|
1610
|
+
onCancel: () => u(h),
|
|
1611
|
+
text: d,
|
|
1612
|
+
contentLanguage: f
|
|
1523
1613
|
}) : null
|
|
1524
1614
|
]
|
|
1525
1615
|
});
|
|
1526
1616
|
}
|
|
1527
|
-
function
|
|
1528
|
-
let
|
|
1529
|
-
return
|
|
1530
|
-
let e =
|
|
1531
|
-
e && (e.scrollTop = e.scrollHeight);
|
|
1532
|
-
}, [
|
|
1617
|
+
function hn({ messages: t, messageFeedback: n, announcement: r, emptyStateImage: i, notice: a, agentName: o = l, showFeedback: s = !1, isStreaming: c = !1, isSlowResponse: u = !1, onThumbsUp: d, onThumbsDown: f, onDraftChange: p = () => {}, onSubmitDetailed: m, onCancelFeedback: h, text: g = e, contentLanguage: _, languageTag: v, announcementIsContent: y = !1 }) {
|
|
1618
|
+
let b = H(null), x = !!a && !t.some((e) => e.role === "user");
|
|
1619
|
+
return et(() => {
|
|
1620
|
+
let e = b.current;
|
|
1621
|
+
e && (e.scrollTop = x ? 0 : e.scrollHeight);
|
|
1622
|
+
}, [
|
|
1623
|
+
t,
|
|
1624
|
+
u,
|
|
1625
|
+
x
|
|
1626
|
+
]), /* @__PURE__ */ W(I, { children: [/* @__PURE__ */ W("section", {
|
|
1533
1627
|
class: "whoo-widget-message-list",
|
|
1534
|
-
ref:
|
|
1535
|
-
"aria-label":
|
|
1628
|
+
ref: b,
|
|
1629
|
+
"aria-label": g.conversation,
|
|
1536
1630
|
tabIndex: 0,
|
|
1537
|
-
children: [
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1631
|
+
children: [
|
|
1632
|
+
i ? /* @__PURE__ */ W(dn, {
|
|
1633
|
+
...i,
|
|
1634
|
+
lang: _
|
|
1635
|
+
}) : null,
|
|
1636
|
+
a ? /* @__PURE__ */ W(pn, {
|
|
1637
|
+
notice: a,
|
|
1638
|
+
text: g,
|
|
1639
|
+
contentLanguage: _,
|
|
1640
|
+
languageTag: v
|
|
1641
|
+
}) : null,
|
|
1642
|
+
t.map((e, r) => /* @__PURE__ */ W(mn, {
|
|
1643
|
+
message: e,
|
|
1644
|
+
speaker: e.role === "user" ? g.you : o,
|
|
1645
|
+
showFeedback: s,
|
|
1646
|
+
feedbackState: e.id ? n[e.id] ?? { status: "idle" } : { status: "idle" },
|
|
1647
|
+
pending: c && r === t.length - 1 && e.role === "assistant" && e.content === "",
|
|
1648
|
+
isSlowResponse: u,
|
|
1649
|
+
onThumbsUp: d,
|
|
1650
|
+
onThumbsDown: f,
|
|
1651
|
+
onDraftChange: p,
|
|
1652
|
+
onSubmitDetailed: m,
|
|
1653
|
+
onCancelFeedback: h,
|
|
1654
|
+
text: g,
|
|
1655
|
+
contentLanguage: _,
|
|
1656
|
+
languageTag: v
|
|
1657
|
+
}, e.id ?? r))
|
|
1658
|
+
]
|
|
1659
|
+
}), /* @__PURE__ */ W("div", {
|
|
1552
1660
|
class: "whoo-widget-sr-only",
|
|
1553
1661
|
"aria-live": "polite",
|
|
1554
1662
|
"aria-atomic": "true",
|
|
1663
|
+
lang: y ? _ : v,
|
|
1555
1664
|
children: r ?? ""
|
|
1556
1665
|
})] });
|
|
1557
1666
|
}
|
|
1558
1667
|
//#endregion
|
|
1559
1668
|
//#region src/components/Panel.tsx
|
|
1560
|
-
var
|
|
1561
|
-
function
|
|
1562
|
-
return Array.from(e.querySelectorAll(
|
|
1669
|
+
var gn = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
|
|
1670
|
+
function _n(e) {
|
|
1671
|
+
return Array.from(e.querySelectorAll(gn)).filter((e) => {
|
|
1563
1672
|
let t = getComputedStyle(e);
|
|
1564
1673
|
return t.display !== "none" && t.visibility !== "hidden";
|
|
1565
1674
|
});
|
|
1566
1675
|
}
|
|
1567
|
-
function
|
|
1568
|
-
let r =
|
|
1569
|
-
|
|
1570
|
-
i.current?.focus();
|
|
1571
|
-
}, []),
|
|
1572
|
-
|
|
1676
|
+
function vn({ state: e, controller: t, greeting: n }) {
|
|
1677
|
+
let r = H(null), i = H(null), a = H(null), o = H(!1);
|
|
1678
|
+
V(() => {
|
|
1679
|
+
(a.current ?? i.current)?.focus();
|
|
1680
|
+
}, []), V(() => {
|
|
1681
|
+
e.noticeAgreed && o.current && (o.current = !1, i.current?.focus());
|
|
1682
|
+
}, [e.noticeAgreed]), V(() => {
|
|
1683
|
+
let e = r.current, n = e ? Lt(e) : () => {}, i = e ? Wt(e) : () => {}, a = () => {
|
|
1684
|
+
e && !e.open && t.close();
|
|
1685
|
+
};
|
|
1686
|
+
e?.addEventListener("close", a);
|
|
1687
|
+
let o = Ut();
|
|
1573
1688
|
return () => {
|
|
1574
|
-
|
|
1689
|
+
n(), i(), e?.removeEventListener("close", a), o();
|
|
1575
1690
|
};
|
|
1576
1691
|
}, []);
|
|
1577
|
-
let
|
|
1578
|
-
if (e.key === "Escape") {
|
|
1692
|
+
let s = (e) => {
|
|
1693
|
+
if (e.key === "Escape" && !Gt(e)) {
|
|
1579
1694
|
e.preventDefault(), t.close();
|
|
1580
1695
|
return;
|
|
1581
1696
|
}
|
|
1582
1697
|
if (e.key !== "Tab") return;
|
|
1583
1698
|
let n = r.current;
|
|
1584
1699
|
if (!n) return;
|
|
1585
|
-
let i =
|
|
1700
|
+
let i = _n(n);
|
|
1586
1701
|
if (i.length === 0) return;
|
|
1587
|
-
let a =
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1702
|
+
let a = n.getRootNode().activeElement;
|
|
1703
|
+
e.preventDefault();
|
|
1704
|
+
let o = i.length - 1, s, c = a ? i.indexOf(a) : -1;
|
|
1705
|
+
if (c !== -1) s = (c + (e.shiftKey ? -1 : 1) + i.length) % i.length;
|
|
1706
|
+
else if (a && a !== n && n.contains(a)) {
|
|
1707
|
+
let t = i.findIndex((e) => a.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING);
|
|
1708
|
+
s = e.shiftKey ? t <= 0 ? o : t - 1 : t === -1 ? 0 : t;
|
|
1709
|
+
} else s = e.shiftKey ? o : 0;
|
|
1710
|
+
i[s].focus();
|
|
1711
|
+
}, c = () => {
|
|
1594
1712
|
let n = e.draft.trim();
|
|
1595
1713
|
n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
|
|
1596
|
-
},
|
|
1714
|
+
}, l = u(t.config.name) || e.agentName || "Aiden", d = u(t.config.title), { before: f, after: p, hasName: m } = Nt(t.text.chatWith), h = e.messages.length === 0 && n ? [{
|
|
1597
1715
|
role: "assistant",
|
|
1598
1716
|
content: n,
|
|
1599
1717
|
id: null
|
|
1600
|
-
}] : e.messages,
|
|
1601
|
-
url:
|
|
1718
|
+
}] : e.messages, g = t.emptyStateImageUrl, _ = e.messages.length === 0 && g ? {
|
|
1719
|
+
url: g,
|
|
1602
1720
|
alt: t.emptyStateImageAlt
|
|
1603
1721
|
} : void 0;
|
|
1604
|
-
return /* @__PURE__ */
|
|
1722
|
+
return /* @__PURE__ */ W("dialog", {
|
|
1605
1723
|
open: !0,
|
|
1606
1724
|
class: "whoo-widget-panel",
|
|
1607
1725
|
"aria-modal": "true",
|
|
1608
|
-
"aria-
|
|
1726
|
+
"aria-labelledby": "whoo-widget-title",
|
|
1727
|
+
"aria-describedby": t.notice && e.noticeAgreed && e.messages.length === 0 ? fn : void 0,
|
|
1609
1728
|
ref: r,
|
|
1610
|
-
onKeyDown:
|
|
1729
|
+
onKeyDown: s,
|
|
1611
1730
|
onCancel: (e) => {
|
|
1612
1731
|
e.preventDefault(), t.close();
|
|
1613
1732
|
},
|
|
1614
1733
|
children: [
|
|
1615
|
-
/* @__PURE__ */
|
|
1734
|
+
/* @__PURE__ */ W("div", {
|
|
1616
1735
|
class: "whoo-widget-header",
|
|
1617
|
-
children: [/* @__PURE__ */
|
|
1736
|
+
children: [d ? /* @__PURE__ */ W("h2", {
|
|
1737
|
+
id: "whoo-widget-title",
|
|
1618
1738
|
class: "whoo-widget-header-title",
|
|
1619
|
-
|
|
1620
|
-
|
|
1739
|
+
lang: t.contentLanguage,
|
|
1740
|
+
dir: "auto",
|
|
1741
|
+
children: d
|
|
1742
|
+
}) : /* @__PURE__ */ W("h2", {
|
|
1743
|
+
id: "whoo-widget-title",
|
|
1744
|
+
class: "whoo-widget-header-title",
|
|
1745
|
+
children: [
|
|
1746
|
+
f,
|
|
1747
|
+
m ? /* @__PURE__ */ W("bdi", {
|
|
1748
|
+
lang: t.contentLanguage,
|
|
1749
|
+
children: l
|
|
1750
|
+
}) : null,
|
|
1751
|
+
p
|
|
1752
|
+
]
|
|
1753
|
+
}), /* @__PURE__ */ W("div", {
|
|
1621
1754
|
class: "whoo-widget-header-actions",
|
|
1622
|
-
children: [e.messages.length > 0 && /* @__PURE__ */
|
|
1755
|
+
children: [e.messages.length > 0 && /* @__PURE__ */ W("button", {
|
|
1623
1756
|
type: "button",
|
|
1624
1757
|
class: "whoo-widget-header-reset",
|
|
1625
1758
|
onClick: () => {
|
|
1626
1759
|
t.resetConversation(), i.current?.focus();
|
|
1627
1760
|
},
|
|
1628
1761
|
children: t.text.newConversation
|
|
1629
|
-
}), /* @__PURE__ */
|
|
1762
|
+
}), /* @__PURE__ */ W("button", {
|
|
1630
1763
|
type: "button",
|
|
1631
1764
|
class: "whoo-widget-header-close",
|
|
1632
1765
|
"aria-label": t.text.closeChat,
|
|
1633
1766
|
onClick: () => t.close(),
|
|
1634
|
-
children: /* @__PURE__ */
|
|
1767
|
+
children: /* @__PURE__ */ W(mt, {})
|
|
1635
1768
|
})]
|
|
1636
1769
|
})]
|
|
1637
1770
|
}),
|
|
1638
|
-
/* @__PURE__ */
|
|
1639
|
-
messages:
|
|
1771
|
+
/* @__PURE__ */ W(hn, {
|
|
1772
|
+
messages: h,
|
|
1640
1773
|
messageFeedback: e.messageFeedback,
|
|
1641
1774
|
announcement: e.announcement,
|
|
1642
|
-
emptyStateImage:
|
|
1643
|
-
|
|
1775
|
+
emptyStateImage: _,
|
|
1776
|
+
notice: t.notice,
|
|
1777
|
+
agentName: l,
|
|
1644
1778
|
showFeedback: t.showFeedback,
|
|
1645
1779
|
isStreaming: e.isStreaming,
|
|
1646
1780
|
isSlowResponse: e.isSlowResponse,
|
|
@@ -1649,27 +1783,44 @@ function pn({ state: e, controller: t, greeting: n }) {
|
|
|
1649
1783
|
onDraftChange: (e, n, r) => t.setFeedbackDraft(e, n, r),
|
|
1650
1784
|
onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
|
|
1651
1785
|
onCancelFeedback: (e) => t.cancelFeedback(e),
|
|
1652
|
-
text: t.text
|
|
1786
|
+
text: t.text,
|
|
1787
|
+
contentLanguage: t.contentLanguage,
|
|
1788
|
+
languageTag: t.languageTag,
|
|
1789
|
+
announcementIsContent: e.announcementIsContent
|
|
1653
1790
|
}),
|
|
1654
|
-
e.runtimeError && /* @__PURE__ */
|
|
1655
|
-
/* @__PURE__ */
|
|
1791
|
+
e.runtimeError && /* @__PURE__ */ W(qt, { message: e.runtimeError }),
|
|
1792
|
+
e.noticeAgreed ? /* @__PURE__ */ W(Kt, {
|
|
1656
1793
|
value: e.draft,
|
|
1657
1794
|
onChange: (e) => t.setDraft(e),
|
|
1658
|
-
onSend:
|
|
1795
|
+
onSend: c,
|
|
1659
1796
|
disabled: e.isStreaming,
|
|
1660
1797
|
inputRef: i,
|
|
1661
|
-
text: t.text
|
|
1798
|
+
text: t.text,
|
|
1799
|
+
contentLanguage: t.contentLanguage
|
|
1800
|
+
}) : /* @__PURE__ */ W("div", {
|
|
1801
|
+
class: "whoo-widget-agreement",
|
|
1802
|
+
children: /* @__PURE__ */ W("button", {
|
|
1803
|
+
type: "button",
|
|
1804
|
+
class: "whoo-widget-agreement-button",
|
|
1805
|
+
ref: a,
|
|
1806
|
+
"aria-describedby": fn,
|
|
1807
|
+
autoFocus: !0,
|
|
1808
|
+
onClick: () => {
|
|
1809
|
+
o.current = !0, t.agreeToNotice();
|
|
1810
|
+
},
|
|
1811
|
+
children: t.text.agreeToNotice
|
|
1812
|
+
})
|
|
1662
1813
|
})
|
|
1663
1814
|
]
|
|
1664
1815
|
});
|
|
1665
1816
|
}
|
|
1666
1817
|
//#endregion
|
|
1667
1818
|
//#region src/components/App.tsx
|
|
1668
|
-
function
|
|
1669
|
-
let [t, n] =
|
|
1670
|
-
return
|
|
1819
|
+
function yn({ controller: e }) {
|
|
1820
|
+
let [t, n] = Qe(e.getState()), r = H(null), i = H(t.isOpen);
|
|
1821
|
+
return et(() => (n(e.getState()), e.subscribe(n)), [e]), V(() => {
|
|
1671
1822
|
i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
|
|
1672
|
-
}, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */
|
|
1823
|
+
}, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ W(I, { children: [/* @__PURE__ */ W(bt, {
|
|
1673
1824
|
isOpen: t.isOpen,
|
|
1674
1825
|
onClick: () => t.isOpen ? e.close() : e.open(),
|
|
1675
1826
|
iconUrl: e.launcher.iconUrl,
|
|
@@ -1678,7 +1829,7 @@ function mn({ controller: e }) {
|
|
|
1678
1829
|
openIcon: e.launcher.openIcon,
|
|
1679
1830
|
buttonRef: r,
|
|
1680
1831
|
text: e.text
|
|
1681
|
-
}), t.isOpen && /* @__PURE__ */
|
|
1832
|
+
}), t.isOpen && /* @__PURE__ */ W(vn, {
|
|
1682
1833
|
state: t,
|
|
1683
1834
|
controller: e,
|
|
1684
1835
|
greeting: e.config.greeting
|
|
@@ -1686,44 +1837,44 @@ function mn({ controller: e }) {
|
|
|
1686
1837
|
}
|
|
1687
1838
|
//#endregion
|
|
1688
1839
|
//#region src/api/client.ts
|
|
1689
|
-
var
|
|
1840
|
+
var bn = class extends Error {
|
|
1690
1841
|
status;
|
|
1691
1842
|
constructor(e, t) {
|
|
1692
1843
|
super(e), this.name = "WidgetApiError", this.status = t;
|
|
1693
1844
|
}
|
|
1694
1845
|
};
|
|
1695
|
-
function
|
|
1846
|
+
function xn(e) {
|
|
1696
1847
|
if (typeof e != "string") return null;
|
|
1697
1848
|
let t = e.trim();
|
|
1698
1849
|
return t === "" ? null : t;
|
|
1699
1850
|
}
|
|
1700
|
-
async function
|
|
1851
|
+
async function Sn(e, t) {
|
|
1701
1852
|
let n = await fetch(`${e}/api/v1/widget/session`, {
|
|
1702
1853
|
method: "POST",
|
|
1703
1854
|
headers: { "Content-Type": "application/json" },
|
|
1704
1855
|
body: JSON.stringify({ publishable_key: t })
|
|
1705
1856
|
});
|
|
1706
|
-
if (!n.ok) throw new
|
|
1857
|
+
if (!n.ok) throw new bn(`Failed to create widget session (${n.status})`, n.status);
|
|
1707
1858
|
let r = await n.json();
|
|
1708
1859
|
return {
|
|
1709
1860
|
token: r.token,
|
|
1710
|
-
...
|
|
1861
|
+
...Cn(r)
|
|
1711
1862
|
};
|
|
1712
1863
|
}
|
|
1713
|
-
function
|
|
1864
|
+
function Cn(e) {
|
|
1714
1865
|
return {
|
|
1715
|
-
primaryColor:
|
|
1716
|
-
name:
|
|
1717
|
-
accentColor:
|
|
1718
|
-
inkColor:
|
|
1866
|
+
primaryColor: xn(e.primary_color),
|
|
1867
|
+
name: xn(e.name),
|
|
1868
|
+
accentColor: xn(e.accent_color),
|
|
1869
|
+
inkColor: xn(e.ink_color)
|
|
1719
1870
|
};
|
|
1720
1871
|
}
|
|
1721
|
-
async function
|
|
1872
|
+
async function wn(e, t) {
|
|
1722
1873
|
let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
|
|
1723
|
-
if (!n.ok) throw new
|
|
1724
|
-
return
|
|
1874
|
+
if (!n.ok) throw new bn(`Failed to load widget branding (${n.status})`, n.status);
|
|
1875
|
+
return Cn(await n.json());
|
|
1725
1876
|
}
|
|
1726
|
-
async function
|
|
1877
|
+
async function Tn(e, t, n) {
|
|
1727
1878
|
let r = await fetch(`${e}/api/v1/widget/feedback`, {
|
|
1728
1879
|
method: "POST",
|
|
1729
1880
|
headers: {
|
|
@@ -1737,11 +1888,11 @@ async function bn(e, t, n) {
|
|
|
1737
1888
|
category: n.category ?? null
|
|
1738
1889
|
})
|
|
1739
1890
|
});
|
|
1740
|
-
if (!r.ok) throw new
|
|
1891
|
+
if (!r.ok) throw new bn(`Feedback submission failed (${r.status})`, r.status);
|
|
1741
1892
|
}
|
|
1742
1893
|
//#endregion
|
|
1743
1894
|
//#region src/api/sse.ts
|
|
1744
|
-
async function*
|
|
1895
|
+
async function* En(e, t, n, r, i) {
|
|
1745
1896
|
let a = await fetch(`${e}/api/v1/widget/chat`, {
|
|
1746
1897
|
method: "POST",
|
|
1747
1898
|
headers: {
|
|
@@ -1754,7 +1905,7 @@ async function* xn(e, t, n, r, i) {
|
|
|
1754
1905
|
}),
|
|
1755
1906
|
signal: i
|
|
1756
1907
|
});
|
|
1757
|
-
if (!a.ok || !a.body) throw new
|
|
1908
|
+
if (!a.ok || !a.body) throw new bn(`Chat request failed (${a.status})`, a.status);
|
|
1758
1909
|
let o = a.body.getReader(), s = new TextDecoder(), c = "";
|
|
1759
1910
|
for (;;) {
|
|
1760
1911
|
let { done: e, value: t } = await o.read();
|
|
@@ -1765,11 +1916,12 @@ async function* xn(e, t, n, r, i) {
|
|
|
1765
1916
|
let e = c.slice(0, n);
|
|
1766
1917
|
c = c.slice(n + 2);
|
|
1767
1918
|
let t = e.split("\n").find((e) => e.startsWith("data: "));
|
|
1768
|
-
|
|
1919
|
+
if (i?.aborted) return;
|
|
1920
|
+
t && (yield Dn(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
|
|
1769
1921
|
}
|
|
1770
1922
|
}
|
|
1771
1923
|
}
|
|
1772
|
-
function
|
|
1924
|
+
function Dn(e) {
|
|
1773
1925
|
return typeof e.error == "string" ? {
|
|
1774
1926
|
type: "error",
|
|
1775
1927
|
error: e.error,
|
|
@@ -1792,11 +1944,11 @@ function Sn(e) {
|
|
|
1792
1944
|
}
|
|
1793
1945
|
//#endregion
|
|
1794
1946
|
//#region src/markdown/plainText.ts
|
|
1795
|
-
function
|
|
1796
|
-
return
|
|
1947
|
+
function On(e) {
|
|
1948
|
+
return tn(e.replace(/\r\n?/g, "\n")).map((e) => {
|
|
1797
1949
|
switch (e.type) {
|
|
1798
1950
|
case "bold":
|
|
1799
|
-
case "italic": return
|
|
1951
|
+
case "italic": return On(e.value);
|
|
1800
1952
|
case "link": return e.text;
|
|
1801
1953
|
default: return e.value;
|
|
1802
1954
|
}
|
|
@@ -1804,16 +1956,16 @@ function Cn(e) {
|
|
|
1804
1956
|
}
|
|
1805
1957
|
//#endregion
|
|
1806
1958
|
//#region src/markdown/reveal.ts
|
|
1807
|
-
var
|
|
1808
|
-
function
|
|
1959
|
+
var kn = 40, An = 120;
|
|
1960
|
+
function jn(e) {
|
|
1809
1961
|
let t = [];
|
|
1810
|
-
for (let n of
|
|
1962
|
+
for (let n of tn(e)) if (n.type === "text") {
|
|
1811
1963
|
let e = n.value.split(/(\s+)/), r = n.start;
|
|
1812
1964
|
for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
|
|
1813
1965
|
} else t.push(n.end);
|
|
1814
1966
|
return t;
|
|
1815
1967
|
}
|
|
1816
|
-
function
|
|
1968
|
+
function Mn(e) {
|
|
1817
1969
|
let t = null;
|
|
1818
1970
|
return e?.addEventListener("abort", () => {
|
|
1819
1971
|
t?.();
|
|
@@ -1828,14 +1980,14 @@ function Dn(e) {
|
|
|
1828
1980
|
});
|
|
1829
1981
|
};
|
|
1830
1982
|
}
|
|
1831
|
-
async function
|
|
1832
|
-
let r = n?.wordIntervalMs ??
|
|
1833
|
-
for (let n of
|
|
1983
|
+
async function Nn(e, t, n) {
|
|
1984
|
+
let r = n?.wordIntervalMs ?? kn, i = n?.tokenIntervalMs ?? An, a = n?.signal, o = tn(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = Mn(a), l = "";
|
|
1985
|
+
for (let n of jn(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
|
|
1834
1986
|
l !== e && t(e);
|
|
1835
1987
|
}
|
|
1836
1988
|
//#endregion
|
|
1837
1989
|
//#region src/sessionToken.ts
|
|
1838
|
-
function
|
|
1990
|
+
function Pn(e) {
|
|
1839
1991
|
let t = e.split(".");
|
|
1840
1992
|
if (t.length !== 3 || t.some((e) => e === "")) return null;
|
|
1841
1993
|
let n = t[1];
|
|
@@ -1849,45 +2001,60 @@ function kn(e) {
|
|
|
1849
2001
|
return null;
|
|
1850
2002
|
}
|
|
1851
2003
|
}
|
|
1852
|
-
function
|
|
1853
|
-
let t =
|
|
2004
|
+
function Fn(e) {
|
|
2005
|
+
let t = Pn(e)?.exp;
|
|
1854
2006
|
return typeof t == "number" ? t * 1e3 : null;
|
|
1855
2007
|
}
|
|
1856
|
-
function
|
|
1857
|
-
let n =
|
|
2008
|
+
function In(e, t = Date.now()) {
|
|
2009
|
+
let n = Fn(e);
|
|
1858
2010
|
return n !== null && n <= t;
|
|
1859
2011
|
}
|
|
1860
|
-
function
|
|
1861
|
-
let n =
|
|
2012
|
+
function Ln(e, t = Date.now()) {
|
|
2013
|
+
let n = Pn(e);
|
|
1862
2014
|
return n?.exp == null ? null : n.iat != null && n.exp > n.iat ? t + (n.exp - n.iat) * 1e3 : n.exp * 1e3;
|
|
1863
2015
|
}
|
|
1864
2016
|
//#endregion
|
|
1865
2017
|
//#region src/storage.ts
|
|
1866
|
-
function
|
|
2018
|
+
function Rn(e) {
|
|
1867
2019
|
return `whoo-aiden-widget:conversation:${e}`;
|
|
1868
2020
|
}
|
|
1869
|
-
function
|
|
2021
|
+
function zn(e) {
|
|
1870
2022
|
try {
|
|
1871
|
-
return window.sessionStorage.getItem(
|
|
2023
|
+
return window.sessionStorage.getItem(Rn(e));
|
|
1872
2024
|
} catch {
|
|
1873
2025
|
return null;
|
|
1874
2026
|
}
|
|
1875
2027
|
}
|
|
1876
|
-
function
|
|
2028
|
+
function Bn(e, t) {
|
|
2029
|
+
try {
|
|
2030
|
+
window.sessionStorage.setItem(Rn(e), t);
|
|
2031
|
+
} catch {}
|
|
2032
|
+
}
|
|
2033
|
+
function Vn(e) {
|
|
2034
|
+
return `whoo-aiden-widget:notice-agreed:${e}`;
|
|
2035
|
+
}
|
|
2036
|
+
function Hn(e, t) {
|
|
2037
|
+
try {
|
|
2038
|
+
return window.sessionStorage.getItem(Vn(e)) === t;
|
|
2039
|
+
} catch {
|
|
2040
|
+
return !1;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
function Un(e, t) {
|
|
1877
2044
|
try {
|
|
1878
|
-
window.sessionStorage.setItem(
|
|
2045
|
+
window.sessionStorage.setItem(Vn(e), t);
|
|
1879
2046
|
} catch {}
|
|
1880
2047
|
}
|
|
1881
|
-
function
|
|
2048
|
+
function Wn(e) {
|
|
1882
2049
|
try {
|
|
1883
|
-
window.sessionStorage.removeItem(
|
|
2050
|
+
window.sessionStorage.removeItem(Rn(e));
|
|
1884
2051
|
} catch {}
|
|
1885
2052
|
}
|
|
1886
2053
|
//#endregion
|
|
1887
2054
|
//#region src/theme.ts
|
|
1888
|
-
var
|
|
1889
|
-
function
|
|
1890
|
-
if (
|
|
2055
|
+
var Gn = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
|
|
2056
|
+
function Kn(e) {
|
|
2057
|
+
if (Gn.test(e.trim())) return null;
|
|
1891
2058
|
let t = document.createElement("div");
|
|
1892
2059
|
if (t.style.color = e, t.style.color === "") return null;
|
|
1893
2060
|
let n = document.createElement("div");
|
|
@@ -1906,69 +2073,69 @@ function Rn(e) {
|
|
|
1906
2073
|
translucent: a < 1
|
|
1907
2074
|
};
|
|
1908
2075
|
}
|
|
1909
|
-
function
|
|
1910
|
-
return
|
|
2076
|
+
function q(e) {
|
|
2077
|
+
return Kn(e)?.rgb ?? null;
|
|
1911
2078
|
}
|
|
1912
|
-
function
|
|
2079
|
+
function J([e, t, n]) {
|
|
1913
2080
|
let r = (e) => {
|
|
1914
2081
|
let t = e / 255;
|
|
1915
2082
|
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
1916
2083
|
};
|
|
1917
2084
|
return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
|
|
1918
2085
|
}
|
|
1919
|
-
function
|
|
2086
|
+
function qn(e, t) {
|
|
1920
2087
|
let n = Math.max(e, t), r = Math.min(e, t);
|
|
1921
2088
|
return (n + .05) / (r + .05);
|
|
1922
2089
|
}
|
|
1923
|
-
function
|
|
1924
|
-
let t =
|
|
2090
|
+
function Jn(e) {
|
|
2091
|
+
let t = q(e);
|
|
1925
2092
|
if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
|
|
1926
|
-
let n =
|
|
1927
|
-
return
|
|
2093
|
+
let n = J(t);
|
|
2094
|
+
return qn(n, J([
|
|
1928
2095
|
0,
|
|
1929
2096
|
0,
|
|
1930
2097
|
0
|
|
1931
|
-
])) >=
|
|
2098
|
+
])) >= qn(n, J([
|
|
1932
2099
|
255,
|
|
1933
2100
|
255,
|
|
1934
2101
|
255
|
|
1935
2102
|
])) ? "#000000" : "#ffffff";
|
|
1936
2103
|
}
|
|
1937
|
-
function
|
|
1938
|
-
let n =
|
|
1939
|
-
return !n || !r ? NaN :
|
|
2104
|
+
function Yn(e, t) {
|
|
2105
|
+
let n = q(e), r = q(t);
|
|
2106
|
+
return !n || !r ? NaN : qn(J(n), J(r));
|
|
1940
2107
|
}
|
|
1941
|
-
var
|
|
1942
|
-
function
|
|
2108
|
+
var Y = i.primary, Xn = i.panel, Zn = i.assistantBubble, Qn = i.headerHover, $n = 4.5;
|
|
2109
|
+
function er([e, t, n]) {
|
|
1943
2110
|
return `#${[
|
|
1944
2111
|
e,
|
|
1945
2112
|
t,
|
|
1946
2113
|
n
|
|
1947
2114
|
].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
1948
2115
|
}
|
|
1949
|
-
function
|
|
1950
|
-
let n =
|
|
1951
|
-
if (!n || !r) return
|
|
1952
|
-
let i =
|
|
1953
|
-
if (a(n)) return
|
|
2116
|
+
function tr(e, t = Xn) {
|
|
2117
|
+
let n = q(e), r = q(t);
|
|
2118
|
+
if (!n || !r) return Y;
|
|
2119
|
+
let i = J(r), a = (e) => qn(J(e), i) >= $n;
|
|
2120
|
+
if (a(n)) return er(n);
|
|
1954
2121
|
for (let e = .99; e > 0; e -= .01) {
|
|
1955
2122
|
let t = n.map((t) => Math.round(t * e));
|
|
1956
|
-
if (a(t)) return
|
|
2123
|
+
if (a(t)) return er(t);
|
|
1957
2124
|
}
|
|
1958
2125
|
return "#000000";
|
|
1959
2126
|
}
|
|
1960
|
-
var
|
|
1961
|
-
function
|
|
2127
|
+
var nr = i.ink, rr = i.link;
|
|
2128
|
+
function X(e) {
|
|
1962
2129
|
if (typeof e != "string" || !e) return null;
|
|
1963
|
-
let t =
|
|
1964
|
-
return t ?
|
|
2130
|
+
let t = Kn(e);
|
|
2131
|
+
return t ? er(t.rgb) : null;
|
|
1965
2132
|
}
|
|
1966
|
-
function
|
|
2133
|
+
function ir(e) {
|
|
1967
2134
|
if (typeof e != "string" || !e) return null;
|
|
1968
|
-
let t =
|
|
1969
|
-
return t ? t.translucent ? e.trim() :
|
|
2135
|
+
let t = Kn(e);
|
|
2136
|
+
return t ? t.translucent ? e.trim() : er(t.rgb) : null;
|
|
1970
2137
|
}
|
|
1971
|
-
var
|
|
2138
|
+
var ar = [
|
|
1972
2139
|
{
|
|
1973
2140
|
role: "onPrimary",
|
|
1974
2141
|
against: ["primary"],
|
|
@@ -2020,8 +2187,8 @@ var Zn = [
|
|
|
2020
2187
|
required: 3
|
|
2021
2188
|
}
|
|
2022
2189
|
];
|
|
2023
|
-
function
|
|
2024
|
-
let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) =>
|
|
2190
|
+
function Z({ color: e, inkColor: t, accentColor: n, overrides: a }) {
|
|
2191
|
+
let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => ir(o[e]), c = X(e), l = s("primary"), u = l ?? c ?? Y, d = s("primaryText"), f = d ?? tr(u, Qn), p = s("onPrimary") ?? Jn(u), m = X(t), h = s("ink") ?? (m ? tr(m, Zn) : nr), g = X(n), _ = s("link") ?? (g ? tr(g, Zn) : rr), v = (e) => s(e) ?? i[e], y = {
|
|
2025
2192
|
primary: u,
|
|
2026
2193
|
onPrimary: p,
|
|
2027
2194
|
primaryText: f,
|
|
@@ -2039,9 +2206,9 @@ function X({ color: e, inkColor: t, accentColor: n, overrides: a }) {
|
|
|
2039
2206
|
inputBorder: v("inputBorder"),
|
|
2040
2207
|
focusRing: v("focusRing")
|
|
2041
2208
|
}, b = Object.fromEntries(r.map((e) => [e, s(e) !== null])), x = [];
|
|
2042
|
-
for (let { role: e, against: t, required: n } of
|
|
2209
|
+
for (let { role: e, against: t, required: n } of ar) for (let r of t) {
|
|
2043
2210
|
if (!b[e] && !b[r]) continue;
|
|
2044
|
-
let t =
|
|
2211
|
+
let t = Yn(y[e], y[r]);
|
|
2045
2212
|
Number.isFinite(t) && t < n && x.push({
|
|
2046
2213
|
role: e,
|
|
2047
2214
|
against: r,
|
|
@@ -2067,71 +2234,92 @@ function X({ color: e, inkColor: t, accentColor: n, overrides: a }) {
|
|
|
2067
2234
|
contrastWarnings: x
|
|
2068
2235
|
};
|
|
2069
2236
|
}
|
|
2070
|
-
function
|
|
2237
|
+
function Q(e) {
|
|
2071
2238
|
return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
|
|
2072
2239
|
}
|
|
2073
|
-
function
|
|
2240
|
+
function or(e, t, n = Y) {
|
|
2074
2241
|
let r = t;
|
|
2075
|
-
|
|
2076
|
-
let i =
|
|
2242
|
+
X(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as the theme color; falling back to ${Q(n)}.`), r = n);
|
|
2243
|
+
let i = Z({ color: r });
|
|
2077
2244
|
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);
|
|
2078
2245
|
}
|
|
2079
|
-
function
|
|
2080
|
-
let r =
|
|
2246
|
+
function sr(e, { inkColor: t, accentColor: n }) {
|
|
2247
|
+
let r = Z({
|
|
2081
2248
|
inkColor: t,
|
|
2082
2249
|
accentColor: n
|
|
2083
2250
|
});
|
|
2084
2251
|
e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
|
|
2085
2252
|
}
|
|
2086
|
-
function
|
|
2087
|
-
let n =
|
|
2253
|
+
function cr(e, t) {
|
|
2254
|
+
let n = Z({ overrides: t });
|
|
2088
2255
|
for (let t of r) {
|
|
2089
2256
|
let r = n.overridden.primary && (t === "onPrimary" || t === "primaryText");
|
|
2090
2257
|
(n.overridden[t] || r) && e.style.setProperty(a[t], n.roles[t]);
|
|
2091
2258
|
}
|
|
2092
2259
|
}
|
|
2093
|
-
function
|
|
2094
|
-
e &&
|
|
2260
|
+
function lr(e, t) {
|
|
2261
|
+
e && X(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`);
|
|
2095
2262
|
}
|
|
2096
|
-
function
|
|
2263
|
+
function ur(e, t, n) {
|
|
2097
2264
|
for (let e of r) {
|
|
2098
2265
|
let n = t[e];
|
|
2099
|
-
n &&
|
|
2266
|
+
n && X(n) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(n)} as theme.colors.${e}; using the calculated color.`);
|
|
2100
2267
|
}
|
|
2101
2268
|
let i = t.primary;
|
|
2102
|
-
typeof i == "string" &&
|
|
2269
|
+
typeof i == "string" && Kn(i)?.translucent && console.warn(`[whoo-aiden-widget] theme.colors.primary ${Q(i)} is translucent. The launcher shows your page through it, so its icon may be unreadable over dark content; pass a solid color.`), dr({
|
|
2103
2270
|
color: e.color,
|
|
2104
2271
|
inkColor: e.inkColor,
|
|
2105
2272
|
accentColor: e.accentColor,
|
|
2106
2273
|
overrides: t
|
|
2107
2274
|
}, n);
|
|
2108
2275
|
}
|
|
2109
|
-
function
|
|
2110
|
-
for (let n of
|
|
2276
|
+
function dr(e, t) {
|
|
2277
|
+
for (let n of Z(e).contrastWarnings) {
|
|
2111
2278
|
let { role: e, against: r, value: i, ratio: a, required: o, overridden: s } = n, c = `${e}|${r}|${i}`;
|
|
2112
2279
|
t.has(c) || (t.add(c), console.warn(s ? `[whoo-aiden-widget] theme.colors.${e} (${i}) has ${a.toFixed(2)}:1 contrast against the ${r} color; ${o}:1 is recommended. Using it as given.` : `[whoo-aiden-widget] the ${e} color (${i}) has ${a.toFixed(2)}:1 contrast against your theme.colors.${r}; ${o}:1 is recommended. Override theme.colors.${e} too.`));
|
|
2113
2280
|
}
|
|
2114
2281
|
}
|
|
2115
|
-
function
|
|
2116
|
-
|
|
2282
|
+
function fr(e, t, n = /* @__PURE__ */ new Set()) {
|
|
2283
|
+
or(e, t.color ?? Y), lr(t.inkColor, "ink color"), lr(t.accentColor, "accent color"), sr(e, {
|
|
2117
2284
|
inkColor: t.inkColor,
|
|
2118
2285
|
accentColor: t.accentColor
|
|
2119
2286
|
});
|
|
2120
2287
|
let r = te(t.theme);
|
|
2121
|
-
|
|
2288
|
+
ur(t, r.colors, n), cr(e, r.colors), r.fontFamily && e.style.setProperty("--whoo-widget-font", r.fontFamily);
|
|
2122
2289
|
}
|
|
2123
2290
|
//#endregion
|
|
2124
2291
|
//#region src/controller.ts
|
|
2125
|
-
var
|
|
2292
|
+
var pr = 8e3, mr = 3e3, hr = 15e3, gr = class extends Error {
|
|
2293
|
+
name = "SessionUnavailableError";
|
|
2294
|
+
};
|
|
2295
|
+
function _r(e, t) {
|
|
2296
|
+
return t ? new Promise((n, r) => {
|
|
2297
|
+
let i = () => r(new DOMException("Aborted", "AbortError"));
|
|
2298
|
+
if (t.aborted) return i();
|
|
2299
|
+
t.addEventListener("abort", i, { once: !0 }), e.then((e) => {
|
|
2300
|
+
t.removeEventListener("abort", i), n(e);
|
|
2301
|
+
}, (e) => {
|
|
2302
|
+
t.removeEventListener("abort", i), r(e);
|
|
2303
|
+
});
|
|
2304
|
+
}) : e;
|
|
2305
|
+
}
|
|
2306
|
+
function vr(e, t) {
|
|
2307
|
+
return e === "refused" ? new br(t) : new gr();
|
|
2308
|
+
}
|
|
2309
|
+
function yr(e) {
|
|
2310
|
+
let t = e?.status;
|
|
2311
|
+
return t === 401 || t === 403 || t === 404;
|
|
2312
|
+
}
|
|
2313
|
+
var br = class extends Error {
|
|
2126
2314
|
name = "SessionExpiredError";
|
|
2127
2315
|
constructor(e) {
|
|
2128
2316
|
super(e instanceof Error ? e.message : "The session has expired.");
|
|
2129
2317
|
}
|
|
2130
2318
|
};
|
|
2131
|
-
function
|
|
2319
|
+
function xr(e) {
|
|
2132
2320
|
return e?.status === 401;
|
|
2133
2321
|
}
|
|
2134
|
-
function
|
|
2322
|
+
function Sr(e, t) {
|
|
2135
2323
|
return new Promise((n) => {
|
|
2136
2324
|
let r = setTimeout(n, t);
|
|
2137
2325
|
e.then(() => {
|
|
@@ -2139,13 +2327,15 @@ function cr(e, t) {
|
|
|
2139
2327
|
});
|
|
2140
2328
|
});
|
|
2141
2329
|
}
|
|
2142
|
-
var
|
|
2330
|
+
var Cr = class {
|
|
2143
2331
|
config;
|
|
2144
2332
|
state;
|
|
2145
2333
|
listeners = /* @__PURE__ */ new Set();
|
|
2146
2334
|
sessionToken = null;
|
|
2147
2335
|
sessionTokenExpiresAt = null;
|
|
2148
2336
|
tokenRenewal = null;
|
|
2337
|
+
renewalGeneration = 0;
|
|
2338
|
+
sendEpoch = 0;
|
|
2149
2339
|
getSessionToken;
|
|
2150
2340
|
conversationId = null;
|
|
2151
2341
|
storageIdentifier;
|
|
@@ -2156,10 +2346,13 @@ var lr = class {
|
|
|
2156
2346
|
launcherIconUrl;
|
|
2157
2347
|
emptyStateImageUrl;
|
|
2158
2348
|
emptyStateImageAlt;
|
|
2349
|
+
notice;
|
|
2350
|
+
requireNoticeAgreement;
|
|
2159
2351
|
showFeedback;
|
|
2160
2352
|
text;
|
|
2161
2353
|
language;
|
|
2162
2354
|
languageTag;
|
|
2355
|
+
contentLanguage;
|
|
2163
2356
|
dir;
|
|
2164
2357
|
constructor(e) {
|
|
2165
2358
|
this.config = e;
|
|
@@ -2167,11 +2360,11 @@ var lr = class {
|
|
|
2167
2360
|
this.launcher = {
|
|
2168
2361
|
...t,
|
|
2169
2362
|
...r ? { iconUrl: r } : {}
|
|
2170
|
-
}, this.launcherIconUrl = r, this.emptyStateImageUrl = n(e.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof e.emptyStateImageAlt == "string" ? e.emptyStateImageAlt.trim() : "", this.showFeedback = e.showFeedback === !0, this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.getSessionToken =
|
|
2171
|
-
let { language: i, tag: a, dir: o } =
|
|
2172
|
-
this.language = i, this.languageTag = a, this.dir = o, this.text = {
|
|
2173
|
-
...
|
|
2174
|
-
...
|
|
2363
|
+
}, this.launcherIconUrl = r, this.emptyStateImageUrl = n(e.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof e.emptyStateImageAlt == "string" ? e.emptyStateImageAlt.trim() : "", this.notice = typeof e.notice == "string" && !d(e.notice) ? e.notice.trim() : "", this.requireNoticeAgreement = e.requireNoticeAgreement === !0 && this.notice !== "", e.requireNoticeAgreement === !0 && !this.notice && console.warn("whoo-aiden-widget: `requireNoticeAgreement` has no effect without a `notice`, so it is ignored."), this.showFeedback = e.showFeedback === !0, this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.getSessionToken = m(e);
|
|
2364
|
+
let { language: i, tag: a, dir: o } = kt(e.language, typeof document > "u" ? void 0 : document.documentElement.lang);
|
|
2365
|
+
this.language = i, this.languageTag = a, this.dir = o, this.contentLanguage = Mt(e.contentLanguage, typeof document > "u" ? void 0 : document.documentElement.lang, e.language), this.text = {
|
|
2366
|
+
...Dt(i),
|
|
2367
|
+
...b(e.messages)
|
|
2175
2368
|
}, this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
|
|
2176
2369
|
isOpen: !1,
|
|
2177
2370
|
messages: [],
|
|
@@ -2185,7 +2378,9 @@ var lr = class {
|
|
|
2185
2378
|
accentColor: null,
|
|
2186
2379
|
inkColor: null,
|
|
2187
2380
|
announcement: null,
|
|
2381
|
+
announcementIsContent: !1,
|
|
2188
2382
|
isSlowResponse: !1,
|
|
2383
|
+
noticeAgreed: !this.requireNoticeAgreement || Hn(this.storageIdentifier, this.notice),
|
|
2189
2384
|
draft: ""
|
|
2190
2385
|
};
|
|
2191
2386
|
}
|
|
@@ -2217,12 +2412,12 @@ var lr = class {
|
|
|
2217
2412
|
let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
|
|
2218
2413
|
try {
|
|
2219
2414
|
if (this.config.sessionToken) {
|
|
2220
|
-
if (
|
|
2221
|
-
if (!await this.renewToken()) throw Error("The sessionToken has expired.");
|
|
2222
|
-
} else this.sessionToken = this.config.sessionToken, this.sessionTokenExpiresAt =
|
|
2415
|
+
if (In(this.config.sessionToken)) {
|
|
2416
|
+
if (!("token" in await this.renewToken())) throw Error("The sessionToken has expired.");
|
|
2417
|
+
} else this.sessionToken = this.config.sessionToken, this.sessionTokenExpiresAt = Fn(this.config.sessionToken);
|
|
2223
2418
|
} else if (this.config.publishableKey) {
|
|
2224
|
-
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await
|
|
2225
|
-
this.sessionToken = t, this.sessionTokenExpiresAt =
|
|
2419
|
+
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await Sn(e, this.config.publishableKey);
|
|
2420
|
+
this.sessionToken = t, this.sessionTokenExpiresAt = Ln(t), this.setState({
|
|
2226
2421
|
primaryColor: n,
|
|
2227
2422
|
agentName: r,
|
|
2228
2423
|
accentColor: i,
|
|
@@ -2233,13 +2428,13 @@ var lr = class {
|
|
|
2233
2428
|
console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
|
|
2234
2429
|
return;
|
|
2235
2430
|
}
|
|
2236
|
-
this.conversationId =
|
|
2431
|
+
this.conversationId = zn(this.storageIdentifier), this.config.sessionToken && await Sr(this.loadBranding(e), mr);
|
|
2237
2432
|
}
|
|
2238
2433
|
async loadBranding(e) {
|
|
2239
2434
|
try {
|
|
2240
2435
|
let t = this.config;
|
|
2241
|
-
if (
|
|
2242
|
-
let { primaryColor: n, name: r, accentColor: i, inkColor: a } = await this.withSession((t) =>
|
|
2436
|
+
if (X(t.color) && X(t.inkColor) && X(t.accentColor) && u(t.name)) return;
|
|
2437
|
+
let { primaryColor: n, name: r, accentColor: i, inkColor: a } = await this.withSession((t) => wn(e, t));
|
|
2243
2438
|
this.setState({
|
|
2244
2439
|
primaryColor: n,
|
|
2245
2440
|
agentName: r,
|
|
@@ -2248,34 +2443,40 @@ var lr = class {
|
|
|
2248
2443
|
});
|
|
2249
2444
|
} catch (e) {
|
|
2250
2445
|
let t = e?.status;
|
|
2251
|
-
(e instanceof
|
|
2446
|
+
(e instanceof br || t === 401 || t === 403) && (this.state.isInitializing ? (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) })) : (console.error("[whoo-aiden-widget] the session was refused after start-up:", e), this.setState({ runtimeError: this.text.sessionExpired })));
|
|
2252
2447
|
}
|
|
2253
2448
|
}
|
|
2254
2449
|
open() {
|
|
2255
2450
|
this.setState({ isOpen: !0 });
|
|
2256
2451
|
}
|
|
2257
2452
|
resetConversation() {
|
|
2258
|
-
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null,
|
|
2453
|
+
this.sendEpoch += 1, this.activeRequestController?.abort("reset"), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, Wn(this.storageIdentifier), this.setState({
|
|
2259
2454
|
messages: [],
|
|
2260
2455
|
messageFeedback: {},
|
|
2261
2456
|
runtimeError: null,
|
|
2262
2457
|
isStreaming: !1,
|
|
2263
|
-
announcement: this.text.conversationCleared
|
|
2458
|
+
announcement: this.text.conversationCleared,
|
|
2459
|
+
announcementIsContent: !1
|
|
2264
2460
|
});
|
|
2265
2461
|
}
|
|
2462
|
+
agreeToNotice() {
|
|
2463
|
+
this.state.noticeAgreed || (Un(this.storageIdentifier, this.notice), this.setState({ noticeAgreed: !0 }));
|
|
2464
|
+
}
|
|
2266
2465
|
setDraft(e) {
|
|
2267
2466
|
this.setState({ draft: e });
|
|
2268
2467
|
}
|
|
2269
2468
|
close() {
|
|
2270
|
-
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isOpen: !1 });
|
|
2469
|
+
this.activeRequestController?.abort("close"), this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isOpen: !1 });
|
|
2271
2470
|
}
|
|
2272
2471
|
async sendMessage(e) {
|
|
2273
|
-
if (!this.sessionToken) return;
|
|
2274
|
-
let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com"
|
|
2472
|
+
if (!this.sessionToken || !this.state.noticeAgreed) return;
|
|
2473
|
+
let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
|
|
2474
|
+
this.sendEpoch += 1;
|
|
2475
|
+
let n = this.sendEpoch, r = () => n === this.sendEpoch, i = {
|
|
2275
2476
|
role: "user",
|
|
2276
2477
|
content: e,
|
|
2277
2478
|
id: null
|
|
2278
|
-
},
|
|
2479
|
+
}, a = {
|
|
2279
2480
|
role: "assistant",
|
|
2280
2481
|
content: "",
|
|
2281
2482
|
id: null
|
|
@@ -2283,58 +2484,63 @@ var lr = class {
|
|
|
2283
2484
|
this.setState({
|
|
2284
2485
|
messages: [
|
|
2285
2486
|
...this.state.messages,
|
|
2286
|
-
|
|
2287
|
-
|
|
2487
|
+
i,
|
|
2488
|
+
a
|
|
2288
2489
|
],
|
|
2289
2490
|
isStreaming: !0,
|
|
2290
2491
|
runtimeError: null,
|
|
2291
2492
|
announcement: null
|
|
2292
2493
|
});
|
|
2293
|
-
let
|
|
2294
|
-
let t =
|
|
2295
|
-
|
|
2296
|
-
...
|
|
2494
|
+
let o = a, s = (e) => {
|
|
2495
|
+
let t = o;
|
|
2496
|
+
o = {
|
|
2497
|
+
...o,
|
|
2297
2498
|
...e
|
|
2298
|
-
}, this.setState({ messages: this.state.messages.map((e) => e === t ?
|
|
2299
|
-
},
|
|
2300
|
-
this.activeRequestController =
|
|
2301
|
-
let { signal:
|
|
2499
|
+
}, this.setState({ messages: this.state.messages.map((e) => e === t ? o : e) });
|
|
2500
|
+
}, c = (e) => s({ content: e }), l = new AbortController();
|
|
2501
|
+
this.activeRequestController = l;
|
|
2502
|
+
let { signal: u } = l, d = !1;
|
|
2302
2503
|
this.slowResponseTimer = setTimeout(() => {
|
|
2303
2504
|
this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
|
|
2304
|
-
},
|
|
2305
|
-
let
|
|
2306
|
-
this.setState({
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
}, l = "";
|
|
2505
|
+
}, pr);
|
|
2506
|
+
let f = !1, p = () => {
|
|
2507
|
+
this.state.draft === "" && (f = !0, this.setState({ draft: e }));
|
|
2508
|
+
}, m = (e = this.text.genericError) => {
|
|
2509
|
+
r() && (this.setState({ runtimeError: e }), p());
|
|
2510
|
+
}, h = "";
|
|
2311
2511
|
try {
|
|
2312
|
-
let { stream: n, first:
|
|
2313
|
-
|
|
2512
|
+
let { stream: n, first: i } = await this.withSession(async (n) => {
|
|
2513
|
+
d = !0;
|
|
2514
|
+
let r = En(t, n, this.conversationId, e, u);
|
|
2314
2515
|
return {
|
|
2315
2516
|
stream: r,
|
|
2316
2517
|
first: await r.next()
|
|
2317
2518
|
};
|
|
2318
|
-
});
|
|
2319
|
-
for (let e =
|
|
2519
|
+
}, u);
|
|
2520
|
+
for (let e = i; !e.done && !u.aborted && r(); e = await n.next()) {
|
|
2320
2521
|
let t = e.value;
|
|
2321
|
-
if (t.type === "conversation_id") this.conversationId = t.conversationId,
|
|
2322
|
-
else if (t.type === "delta") this.clearSlowResponse(), t.verbatim && !this.prefersReducedMotion ? (await
|
|
2323
|
-
else if (t.type === "done") t.conversationId && (this.conversationId = t.conversationId,
|
|
2522
|
+
if (t.type === "conversation_id") this.conversationId = t.conversationId, Bn(this.storageIdentifier, t.conversationId);
|
|
2523
|
+
else if (t.type === "delta") this.clearSlowResponse(), t.verbatim && !this.prefersReducedMotion ? (await Nn(t.delta, (e) => c(e), { signal: u }), h = t.delta) : t.verbatim ? (h = t.delta, c(h)) : (h += t.delta, c(h));
|
|
2524
|
+
else if (t.type === "done") t.conversationId && (this.conversationId = t.conversationId, Bn(this.storageIdentifier, t.conversationId)), t.messageId && s({ id: t.messageId }), r() && this.setState({
|
|
2525
|
+
announcement: On(h),
|
|
2526
|
+
announcementIsContent: !0
|
|
2527
|
+
});
|
|
2324
2528
|
else if (t.type === "error") {
|
|
2325
|
-
console.error("[whoo-aiden-widget] chat error:", t.error),
|
|
2529
|
+
console.error("[whoo-aiden-widget] chat error:", t.error), h.trim() !== "" && r() && this.setState({
|
|
2530
|
+
announcement: On(h),
|
|
2531
|
+
announcementIsContent: !0
|
|
2532
|
+
}), m(), l.abort();
|
|
2326
2533
|
break;
|
|
2327
2534
|
}
|
|
2328
2535
|
}
|
|
2329
2536
|
} catch (e) {
|
|
2330
|
-
|
|
2537
|
+
u.aborted ? u.reason === "close" && r() && !d && p() : e instanceof br ? (console.error("[whoo-aiden-widget] chat request failed: the session has expired.", e), m(this.text.sessionExpired)) : e instanceof gr ? (console.error("[whoo-aiden-widget] chat request failed: no session could be had."), m()) : (console.error("[whoo-aiden-widget] chat request failed:", e), m());
|
|
2331
2538
|
} finally {
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
this.setState({
|
|
2539
|
+
let e = o.id === null && o.content.trim() === "", t = this.state.messages.filter((t) => !(e && t === o) && !(e && f && t === i)), n = t.length !== this.state.messages.length;
|
|
2540
|
+
r() ? (this.activeRequestController = null, this.clearSlowResponse(), this.setState({
|
|
2335
2541
|
isStreaming: !1,
|
|
2336
|
-
...
|
|
2337
|
-
});
|
|
2542
|
+
...n ? { messages: t } : {}
|
|
2543
|
+
})) : n && this.setState({ messages: t });
|
|
2338
2544
|
}
|
|
2339
2545
|
}
|
|
2340
2546
|
expandFeedback(e) {
|
|
@@ -2375,7 +2581,7 @@ var lr = class {
|
|
|
2375
2581
|
}
|
|
2376
2582
|
} });
|
|
2377
2583
|
try {
|
|
2378
|
-
await this.withSession((a) =>
|
|
2584
|
+
await this.withSession((a) => Tn(i, a, {
|
|
2379
2585
|
messageId: e,
|
|
2380
2586
|
rating: t,
|
|
2381
2587
|
correction: n,
|
|
@@ -2399,9 +2605,9 @@ var lr = class {
|
|
|
2399
2605
|
} });
|
|
2400
2606
|
}
|
|
2401
2607
|
}
|
|
2402
|
-
async currentToken() {
|
|
2403
|
-
let
|
|
2404
|
-
return
|
|
2608
|
+
async currentToken(e) {
|
|
2609
|
+
let t = this.sessionToken, n = this.sessionTokenExpiresAt;
|
|
2610
|
+
return t && (n === null || n - Date.now() > 6e4) ? { token: t } : _r(this.renewToken(), e);
|
|
2405
2611
|
}
|
|
2406
2612
|
renewToken() {
|
|
2407
2613
|
return this.tokenRenewal ??= this.fetchNewToken().finally(() => {
|
|
@@ -2409,83 +2615,95 @@ var lr = class {
|
|
|
2409
2615
|
}), this.tokenRenewal;
|
|
2410
2616
|
}
|
|
2411
2617
|
async fetchNewToken() {
|
|
2412
|
-
let e = this.
|
|
2618
|
+
let e = ++this.renewalGeneration, t, n = new Promise((e) => {
|
|
2619
|
+
t = setTimeout(() => {
|
|
2620
|
+
console.error("[whoo-aiden-widget] could not renew the session: it took too long."), e({ failure: "unavailable" });
|
|
2621
|
+
}, hr);
|
|
2622
|
+
});
|
|
2623
|
+
try {
|
|
2624
|
+
return await Promise.race([this.obtainToken(e), n]);
|
|
2625
|
+
} finally {
|
|
2626
|
+
clearTimeout(t);
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
async obtainToken(e) {
|
|
2630
|
+
let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com", n;
|
|
2413
2631
|
try {
|
|
2414
|
-
|
|
2415
|
-
if (this.
|
|
2416
|
-
else
|
|
2417
|
-
else return null;
|
|
2418
|
-
let n = typeof t == "string" ? Mn(t) : null;
|
|
2419
|
-
return typeof t != "string" || t === "" || n !== null && n <= Date.now() ? (console.error("[whoo-aiden-widget] could not renew the session: no usable token was returned."), null) : (this.sessionToken = t, this.sessionTokenExpiresAt = n, t);
|
|
2632
|
+
if (this.config.publishableKey) n = (await Sn(t, this.config.publishableKey)).token;
|
|
2633
|
+
else if (this.getSessionToken) n = await this.getSessionToken();
|
|
2634
|
+
else return { failure: "refused" };
|
|
2420
2635
|
} catch (e) {
|
|
2421
|
-
return console.error("[whoo-aiden-widget] could not renew the session:", e),
|
|
2636
|
+
return console.error("[whoo-aiden-widget] could not renew the session:", e), { failure: this.config.publishableKey && yr(e) ? "refused" : "unavailable" };
|
|
2422
2637
|
}
|
|
2638
|
+
let r = typeof n == "string" ? Ln(n) : null;
|
|
2639
|
+
return typeof n != "string" || n === "" || r !== null && r <= Date.now() ? (console.error("[whoo-aiden-widget] could not renew the session: no usable token was returned."), { failure: "refused" }) : (e === this.renewalGeneration && (this.sessionToken = n, this.sessionTokenExpiresAt = r), { token: n });
|
|
2423
2640
|
}
|
|
2424
|
-
async withSession(e) {
|
|
2425
|
-
let
|
|
2426
|
-
if (!
|
|
2641
|
+
async withSession(e, t) {
|
|
2642
|
+
let n = await this.currentToken(t);
|
|
2643
|
+
if (!("token" in n)) throw vr(n.failure);
|
|
2644
|
+
let { token: r } = n;
|
|
2427
2645
|
try {
|
|
2428
|
-
return await e(
|
|
2646
|
+
return await e(r);
|
|
2429
2647
|
} catch (n) {
|
|
2430
|
-
if (!
|
|
2431
|
-
let
|
|
2432
|
-
if (!
|
|
2648
|
+
if (!xr(n)) throw n;
|
|
2649
|
+
let i = this.sessionToken && this.sessionToken !== r ? { token: this.sessionToken } : await _r(this.renewToken(), t);
|
|
2650
|
+
if (!("token" in i)) throw vr(i.failure, n);
|
|
2433
2651
|
try {
|
|
2434
|
-
return await e(
|
|
2652
|
+
return await e(i.token);
|
|
2435
2653
|
} catch (e) {
|
|
2436
|
-
throw
|
|
2654
|
+
throw xr(e) ? new br(e) : e;
|
|
2437
2655
|
}
|
|
2438
2656
|
}
|
|
2439
2657
|
}
|
|
2440
|
-
}, $ = 20,
|
|
2441
|
-
function
|
|
2658
|
+
}, $ = 20, wr = 12, Tr = 300, Er = 352;
|
|
2659
|
+
function Dr() {
|
|
2442
2660
|
try {
|
|
2443
2661
|
return typeof CSS < "u" && CSS.supports?.("height", "100dvh") ? "dvh" : "vh";
|
|
2444
2662
|
} catch {
|
|
2445
2663
|
return "vh";
|
|
2446
2664
|
}
|
|
2447
2665
|
}
|
|
2448
|
-
function
|
|
2666
|
+
function Or(e, t) {
|
|
2449
2667
|
let { offsetX: n, offsetY: r, launcherSize: i, panelWidth: a, panelHeight: o } = ie(t.layout), s = (e) => typeof t.layout?.offset?.[e] == "number";
|
|
2450
2668
|
if (typeof window < "u" && window.innerWidth > 0 && window.innerHeight > 0) {
|
|
2451
|
-
let e = Math.max($, window.innerWidth -
|
|
2669
|
+
let e = Math.max($, window.innerWidth - Tr), t = Math.max($, window.innerHeight - i - Er);
|
|
2452
2670
|
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.`);
|
|
2453
2671
|
}
|
|
2454
|
-
let c = `100${
|
|
2672
|
+
let c = `100${Dr()}`, l = `min(${n}px, max(${$}px, calc(100vw - ${Tr}px)), calc(100vw - ${i}px))`, u = `min(${r}px, max(${$}px, calc(${c} - ${i + Er}px)), calc(${c} - ${i}px))`, d = `calc(${u} + ${i}px + ${wr}px)`, f = t.position === "bottom-left", p = (t, n) => e.style.setProperty(t, n);
|
|
2455
2673
|
p("--whoo-widget-inset-left", f ? l : "auto"), p("--whoo-widget-inset-right", f ? "auto" : l), p("--whoo-widget-inset-bottom", u), p("--whoo-widget-launcher-size", `${i}px`), p("--whoo-widget-panel-bottom", d), p("--whoo-widget-panel-width", `${a}px`), p("--whoo-widget-panel-height", `${o}px`), p("--whoo-widget-panel-max-width", `calc(100vw - ${l} - ${$}px)`), p("--whoo-widget-panel-max-height", `calc(${c} - ${d} - ${$}px)`);
|
|
2456
2674
|
}
|
|
2457
2675
|
//#endregion
|
|
2458
2676
|
//#region src/styles.css?inline
|
|
2459
|
-
var
|
|
2677
|
+
var kr = ":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);color:inherit;border:none;border-radius:12px;flex-direction:column;margin:0;padding:0;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}button,input,textarea,select{font-family:inherit}.whoo-widget-panel:not([open]){display:none}.whoo-widget-panel::backdrop{background:0 0}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + max(8px, var(--whoo-widget-visible-height,100%) - 8px - var(--whoo-widget-panel-height,480px)));height:min(var(--whoo-widget-panel-height,480px), calc(var(--whoo-widget-visible-height,100%) - 16px));max-height:none;bottom:auto}@media (width<=400px),(height<=420px){.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + 8px);height:calc(var(--whoo-widget-visible-height,100%) - 16px)}}.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-block:8px;padding-inline:16px 8px;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-inline-start: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{overscroll-behavior:contain;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-notice{border:1px solid var(--whoo-widget-border,#e5e5e5);color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;margin-bottom:12px;padding:8px 12px}.whoo-widget-notice a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message-text,.whoo-widget-message-text li{unicode-bidi:plaintext}.whoo-widget-list{margin:4px 0;padding-inline-start:0}.whoo-widget-list li{margin-inline-start:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-inline-start: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);unicode-bidi:plaintext;border-radius:6px;flex:1;min-width:0;padding:8px;font-size:16px}.whoo-widget-agreement{border-top:1px solid var(--whoo-widget-border,#e5e5e5);padding:12px}.whoo-widget-agreement-button{background:var(--whoo-widget-color,#4f46e5);width:100%;min-height:44px;color:var(--whoo-widget-text-on-color,#fff);overflow-wrap:anywhere;cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-weight:600;display:block}.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[aria-disabled=true]{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;unicode-bidi:plaintext;border-radius:6px;width:100%;padding:6px;font-size:16px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;height:2em;min-height:24px;padding:4px;font-size:16px}.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}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-message{border:1px solid canvastext}.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-agreement-button,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
|
|
2460
2678
|
//#endregion
|
|
2461
2679
|
//#region src/mount.tsx
|
|
2462
|
-
function
|
|
2680
|
+
function Ar(e) {
|
|
2463
2681
|
let t = document.createElement("div");
|
|
2464
2682
|
t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(c(e.zIndex));
|
|
2465
2683
|
let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
|
|
2466
|
-
r.textContent =
|
|
2684
|
+
r.textContent = kr, n.appendChild(r);
|
|
2467
2685
|
let i = document.createElement("div");
|
|
2468
2686
|
n.appendChild(i);
|
|
2469
2687
|
let a = /* @__PURE__ */ new Set();
|
|
2470
|
-
|
|
2471
|
-
let o = new
|
|
2688
|
+
fr(i, e, a), Or(i, e);
|
|
2689
|
+
let o = new Cr(e);
|
|
2472
2690
|
i.setAttribute("lang", o.languageTag), i.setAttribute("dir", o.dir);
|
|
2473
|
-
let s =
|
|
2691
|
+
let s = X(e.color) !== null, l = null, u = "", d = te(e.theme).colors, f = Object.keys(d).length > 0, p = {
|
|
2474
2692
|
color: e.color,
|
|
2475
2693
|
inkColor: e.inkColor,
|
|
2476
2694
|
accentColor: e.accentColor
|
|
2477
2695
|
};
|
|
2478
2696
|
return o.subscribe((t) => {
|
|
2479
2697
|
let n = !1;
|
|
2480
|
-
!s && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor,
|
|
2698
|
+
!s && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor, or(i, t.primaryColor, e.color), X(t.primaryColor) && (p = {
|
|
2481
2699
|
...p,
|
|
2482
2700
|
color: t.primaryColor
|
|
2483
2701
|
}), n = !0);
|
|
2484
2702
|
let r = `${t.inkColor}|${t.accentColor}`;
|
|
2485
2703
|
if ((t.inkColor || t.accentColor) && r !== u) {
|
|
2486
2704
|
u = r;
|
|
2487
|
-
let a =
|
|
2488
|
-
|
|
2705
|
+
let a = X(e.inkColor) ? e.inkColor : t.inkColor, o = X(e.accentColor) ? e.accentColor : t.accentColor;
|
|
2706
|
+
sr(i, {
|
|
2489
2707
|
inkColor: a,
|
|
2490
2708
|
accentColor: o
|
|
2491
2709
|
}), p = {
|
|
@@ -2494,18 +2712,18 @@ function gr(e) {
|
|
|
2494
2712
|
accentColor: o
|
|
2495
2713
|
}, n = !0;
|
|
2496
2714
|
}
|
|
2497
|
-
n && (
|
|
2715
|
+
n && (cr(i, d), f && dr({
|
|
2498
2716
|
...p,
|
|
2499
2717
|
overrides: d
|
|
2500
2718
|
}, a));
|
|
2501
|
-
}), o.init(),
|
|
2502
|
-
|
|
2719
|
+
}), o.init(), Re(/* @__PURE__ */ W(yn, { controller: o }), i), document.body.appendChild(t), { unmount() {
|
|
2720
|
+
Re(null, i), t.remove();
|
|
2503
2721
|
} };
|
|
2504
2722
|
}
|
|
2505
2723
|
//#endregion
|
|
2506
2724
|
//#region src/index.ts
|
|
2507
|
-
function
|
|
2508
|
-
return
|
|
2725
|
+
function jr(e) {
|
|
2726
|
+
return f(e), Ar(e);
|
|
2509
2727
|
}
|
|
2510
2728
|
//#endregion
|
|
2511
|
-
export {
|
|
2729
|
+
export { St as SUPPORTED_LANGUAGES, jr as init, Z as resolveTheme };
|