@aiden-voice/widget 0.7.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.js CHANGED
@@ -1,5 +1,36 @@
1
+ //#region src/i18n/messages.ts
2
+ var e = {
3
+ openChat: "Open chat",
4
+ closeChat: "Close chat",
5
+ chatWith: "Chat with {name}",
6
+ newConversation: "New conversation",
7
+ conversation: "Conversation",
8
+ you: "You",
9
+ message: "Message",
10
+ send: "Send",
11
+ lookingItUp: "Looking that up for you…",
12
+ goodResponse: "Good response",
13
+ badResponse: "Bad response",
14
+ additionalFeedback: "Additional feedback",
15
+ feedbackPlaceholder: "What was wrong? (optional)",
16
+ feedbackCategory: "Feedback category",
17
+ selectReason: "Select a reason (optional)",
18
+ categoryFactual: "Factual error",
19
+ categoryIncomplete: "Incomplete",
20
+ categoryTone: "Off tone",
21
+ categoryOther: "Other",
22
+ submit: "Submit",
23
+ cancel: "Cancel",
24
+ feedbackThanks: "Thanks for the feedback",
25
+ feedbackFailed: "Couldn't send feedback",
26
+ conversationCleared: "Conversation cleared",
27
+ genericError: "Something went wrong, please try again.",
28
+ sessionExpired: "This chat session has expired. Reload the page to continue.",
29
+ opensInNewTab: "(opens in new tab)"
30
+ }, t = Object.keys(e);
31
+ //#endregion
1
32
  //#region src/imageUrl.ts
2
- function e(e, t) {
33
+ function n(e, t) {
3
34
  if (e != null && e !== "") {
4
35
  if (typeof e == "string") try {
5
36
  let t = new URL(e);
@@ -10,7 +41,7 @@ function e(e, t) {
10
41
  }
11
42
  //#endregion
12
43
  //#region src/themeRoles.ts
13
- var t = [
44
+ var r = [
14
45
  "primary",
15
46
  "onPrimary",
16
47
  "primaryText",
@@ -27,7 +58,7 @@ var t = [
27
58
  "errorText",
28
59
  "inputBorder",
29
60
  "focusRing"
30
- ], n = {
61
+ ], i = {
31
62
  primary: "#4f46e5",
32
63
  onPrimary: "#ffffff",
33
64
  primaryText: "#4f46e5",
@@ -44,7 +75,7 @@ var t = [
44
75
  errorText: "#991b1b",
45
76
  inputBorder: "#6b7280",
46
77
  focusRing: "#111827"
47
- }, r = {
78
+ }, a = {
48
79
  primary: "--whoo-widget-color",
49
80
  onPrimary: "--whoo-widget-text-on-color",
50
81
  primaryText: "--whoo-widget-color-text",
@@ -61,22 +92,36 @@ var t = [
61
92
  errorText: "--whoo-widget-error-text",
62
93
  inputBorder: "--whoo-widget-input-border",
63
94
  focusRing: "--whoo-widget-focus-ring"
64
- }, i = 2147483e3, a = 2147483647;
65
- function o(e) {
66
- return e === void 0 ? i : Number.isInteger(e) && Math.abs(e) <= a ? e : (console.warn(`whoo-aiden-widget: ignoring zIndex ${String(e)} (expected an integer between -${a} and ${a}); using ${i}.`), i);
67
- }
68
- var s = "Aiden";
95
+ }, o = 2147483e3, s = 2147483647;
69
96
  function c(e) {
97
+ return e === void 0 ? o : Number.isInteger(e) && Math.abs(e) <= s ? e : (console.warn(`whoo-aiden-widget: ignoring zIndex ${String(e)} (expected an integer between -${s} and ${s}); using ${o}.`), o);
98
+ }
99
+ var l = "Aiden";
100
+ function u(e) {
70
101
  return typeof e == "string" ? e.trim() : "";
71
102
  }
72
- function l(e) {
103
+ function d(e) {
73
104
  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.");
74
105
  }
75
- function u(e) {
106
+ function f(e) {
76
107
  console.warn(`whoo-aiden-widget: ${e}`);
77
108
  }
78
- var d = 20;
79
- function f(e) {
109
+ function p(e) {
110
+ let { getSessionToken: t } = e;
111
+ if (t !== void 0) {
112
+ if (typeof t != "function") {
113
+ f("ignoring `getSessionToken` -- expected a function that returns a session token.");
114
+ return;
115
+ }
116
+ if (!e.sessionToken) {
117
+ f("ignoring `getSessionToken` -- it is only used with `sessionToken`; with `publishableKey` the widget renews its session by itself.");
118
+ return;
119
+ }
120
+ return t;
121
+ }
122
+ }
123
+ var m = 20;
124
+ function h(e) {
80
125
  let t = /* @__PURE__ */ new WeakSet(), n = /* @__PURE__ */ new Set();
81
126
  return (r) => {
82
127
  if (typeof r == "object" && r || typeof r == "function") {
@@ -84,120 +129,139 @@ function f(e) {
84
129
  t.add(r);
85
130
  } else {
86
131
  if (n.has(r)) return;
87
- n.size >= d && n.delete(n.values().next().value), n.add(r);
132
+ n.size >= m && n.delete(n.values().next().value), n.add(r);
88
133
  }
89
- u(e);
134
+ f(e);
90
135
  };
91
136
  }
92
- var p = f("ignoring `theme` -- expected an object."), m = f("ignoring `layout` -- expected an object.");
93
- function h(e) {
137
+ var g = h("ignoring `theme` -- expected an object."), _ = h("ignoring `layout` -- expected an object."), v = h("ignoring `messages` -- expected an object.");
138
+ function y(e) {
139
+ if (e == null) return {};
140
+ if (!b(e)) return v(e), {};
141
+ let n = {};
142
+ for (let r of Object.keys(e)) {
143
+ if (!t.includes(r)) {
144
+ f(`ignoring unknown option \`messages.${r}\`.`);
145
+ continue;
146
+ }
147
+ let i = e[r];
148
+ if (typeof i != "string" || /^[\p{White_Space}\p{Cf}\p{M}]*$/u.test(i)) {
149
+ f(`ignoring \`messages.${r}\` -- expected a non-blank string.`);
150
+ continue;
151
+ }
152
+ 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;
153
+ }
154
+ for (let t in e) Object.hasOwn(e, t) || f(`ignoring inherited option \`messages.${t}\` -- only the object's own keys are used.`);
155
+ return n;
156
+ }
157
+ function b(e) {
94
158
  return typeof e == "object" && !!e && !Array.isArray(e);
95
159
  }
96
- var g = (e) => e == null || e === "";
97
- function _(e, t, n) {
160
+ var x = (e) => e == null || e === "";
161
+ function S(e, t, n) {
98
162
  let r = e[t];
99
- return r == null ? null : h(r) ? r : (u(`ignoring \`${n}\` -- expected an object.`), null);
163
+ return r == null ? null : b(r) ? r : (f(`ignoring \`${n}\` -- expected an object.`), null);
100
164
  }
101
- function v(e, t, n) {
102
- for (let r of Object.keys(e)) t.includes(r) || u(`ignoring unknown option \`${n}.${r}\`.`);
165
+ function C(e, t, n) {
166
+ for (let r of Object.keys(e)) t.includes(r) || f(`ignoring unknown option \`${n}.${r}\`.`);
103
167
  }
104
- function y(e, t, n) {
105
- if (!g(e)) {
168
+ function ee(e, t, n) {
169
+ if (!x(e)) {
106
170
  if (typeof e == "string" && t.includes(e)) return e;
107
- u(`ignoring \`${n}\` -- expected one of ${t.join(", ")}.`);
171
+ f(`ignoring \`${n}\` -- expected one of ${t.join(", ")}.`);
108
172
  }
109
173
  }
110
- var b = 200, x = /url\(|[@;{}\\]/i;
111
- function S(e) {
112
- if (!g(e)) {
174
+ var w = 200, T = /url\(|[@;{}\\]/i;
175
+ function E(e) {
176
+ if (!x(e)) {
113
177
  if (typeof e == "string") {
114
178
  let t = e.trim();
115
- if (t && t.length <= b && !x.test(t)) return t;
179
+ if (t && t.length <= w && !T.test(t)) return t;
116
180
  }
117
- u(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${b} characters, without url(), @, ;, {, } or \\.`);
181
+ f(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${w} characters, without url(), @, ;, {, } or \\.`);
118
182
  }
119
183
  }
120
- var C = [
184
+ var D = [
121
185
  "chat",
122
186
  "message",
123
187
  "sparkle"
124
- ], ee = ["chevron-down", "close"], w = /* @__PURE__ */ new WeakMap();
125
- function T(n) {
126
- let r = {
188
+ ], O = ["chevron-down", "close"], k = /* @__PURE__ */ new WeakMap();
189
+ function te(e) {
190
+ let t = {
127
191
  colors: {},
128
192
  fontFamily: void 0,
129
193
  launcher: {}
130
194
  };
131
- if (n == null) return r;
132
- if (!h(n)) return p(n), r;
133
- let i = w.get(n);
195
+ if (e == null) return t;
196
+ if (!b(e)) return g(e), t;
197
+ let i = k.get(e);
134
198
  if (i) return i;
135
- v(n, [
199
+ C(e, [
136
200
  "colors",
137
201
  "fonts",
138
202
  "launcher"
139
203
  ], "theme");
140
- let a = _(n, "colors", "theme.colors");
204
+ let a = S(e, "colors", "theme.colors");
141
205
  if (a) {
142
- v(a, t, "theme.colors");
143
- for (let e of t) {
144
- let t = a[e];
145
- g(t) || (typeof t == "string" ? r.colors[e] = t : u(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`));
206
+ C(a, r, "theme.colors");
207
+ for (let e of r) {
208
+ let n = a[e];
209
+ x(n) || (typeof n == "string" ? t.colors[e] = n : f(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`));
146
210
  }
147
211
  }
148
- let o = _(n, "fonts", "theme.fonts");
149
- o && (v(o, ["family"], "theme.fonts"), r.fontFamily = S(o.family));
150
- let s = _(n, "launcher", "theme.launcher");
212
+ let o = S(e, "fonts", "theme.fonts");
213
+ o && (C(o, ["family"], "theme.fonts"), t.fontFamily = E(o.family));
214
+ let s = S(e, "launcher", "theme.launcher");
151
215
  if (s) {
152
- v(s, [
216
+ C(s, [
153
217
  "icon",
154
218
  "iconUrl",
155
219
  "openIcon",
156
220
  "openIconUrl"
157
221
  ], "theme.launcher");
158
- let t = y(s.icon, C, "theme.launcher.icon"), n = e(s.iconUrl, "theme.launcher.iconUrl"), i = y(s.openIcon, ee, "theme.launcher.openIcon"), a = e(s.openIconUrl, "theme.launcher.openIconUrl");
159
- t && (r.launcher.icon = t), n && (r.launcher.iconUrl = n), i && (r.launcher.openIcon = i), a && (r.launcher.openIconUrl = a);
222
+ let e = ee(s.icon, D, "theme.launcher.icon"), r = n(s.iconUrl, "theme.launcher.iconUrl"), i = ee(s.openIcon, O, "theme.launcher.openIcon"), a = n(s.openIconUrl, "theme.launcher.openIconUrl");
223
+ e && (t.launcher.icon = e), r && (t.launcher.iconUrl = r), i && (t.launcher.openIcon = i), a && (t.launcher.openIconUrl = a);
160
224
  }
161
- return w.set(n, r), r;
225
+ return k.set(e, t), t;
162
226
  }
163
- var E = {
227
+ var A = {
164
228
  offsetX: 20,
165
229
  offsetY: 20,
166
230
  launcherSize: 56,
167
231
  panelWidth: 360,
168
232
  panelHeight: 480
169
233
  };
170
- function D(e, t, n) {
171
- return e == null ? n : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : (u(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`), n);
234
+ function j(e, t, n) {
235
+ return e == null ? n : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : (f(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`), n);
172
236
  }
173
- function O(e, t, n, r) {
237
+ function ne(e, t, n, r) {
174
238
  let i = Math.min(r, Math.max(n, e));
175
- return i !== e && u(`\`${t}\` ${e} is out of range (${r === Infinity ? `at least ${n}` : `${n}-${r}`}); using ${i}.`), i;
239
+ return i !== e && f(`\`${t}\` ${e} is out of range (${r === Infinity ? `at least ${n}` : `${n}-${r}`}); using ${i}.`), i;
176
240
  }
177
- var k = /* @__PURE__ */ new WeakMap();
178
- function te(e) {
179
- let t = { ...E };
241
+ var re = /* @__PURE__ */ new WeakMap();
242
+ function ie(e) {
243
+ let t = { ...A };
180
244
  if (e == null) return t;
181
- if (!h(e)) return m(e), t;
182
- let n = k.get(e);
245
+ if (!b(e)) return _(e), t;
246
+ let n = re.get(e);
183
247
  if (n) return n;
184
- v(e, [
248
+ C(e, [
185
249
  "offset",
186
250
  "launcherSize",
187
251
  "panel"
188
252
  ], "layout");
189
- let r = _(e, "offset", "layout.offset");
190
- r && (v(r, ["x", "y"], "layout.offset"), t.offsetX = D(r.x, "layout.offset.x", E.offsetX), t.offsetY = D(r.y, "layout.offset.y", E.offsetY)), t.launcherSize = O(D(e.launcherSize, "layout.launcherSize", E.launcherSize), "layout.launcherSize", 24, 120);
191
- let i = _(e, "panel", "layout.panel");
192
- return i && (v(i, ["width", "height"], "layout.panel"), t.panelWidth = O(D(i.width, "layout.panel.width", E.panelWidth), "layout.panel.width", 280, Infinity), t.panelHeight = O(D(i.height, "layout.panel.height", E.panelHeight), "layout.panel.height", 320, Infinity)), k.set(e, t), t;
253
+ let r = S(e, "offset", "layout.offset");
254
+ r && (C(r, ["x", "y"], "layout.offset"), t.offsetX = j(r.x, "layout.offset.x", A.offsetX), t.offsetY = j(r.y, "layout.offset.y", A.offsetY)), t.launcherSize = ne(j(e.launcherSize, "layout.launcherSize", A.launcherSize), "layout.launcherSize", 24, 120);
255
+ let i = S(e, "panel", "layout.panel");
256
+ return i && (C(i, ["width", "height"], "layout.panel"), t.panelWidth = ne(j(i.width, "layout.panel.width", A.panelWidth), "layout.panel.width", 280, Infinity), t.panelHeight = ne(j(i.height, "layout.panel.height", A.panelHeight), "layout.panel.height", 320, Infinity)), re.set(e, t), t;
193
257
  }
194
258
  //#endregion
195
259
  //#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/dist/preact.mjs
196
- var A, ne, j, re, M, ie, ae, N, oe, se, ce, le, ue = {}, P = [], de = /^m(i|n|o|s|text|space)$/, fe = Array.isArray, pe = P.slice, F = Object.assign;
197
- function me(e) {
260
+ var M, ae, N, oe, se, ce, le, P, ue, de, fe, pe, me = {}, he = [], ge = /^m(i|n|o|s|text|space)$/, _e = Array.isArray, ve = he.slice, F = Object.assign;
261
+ function ye(e) {
198
262
  e && e.parentNode && e.remove();
199
263
  }
200
- function he(e, t, n, r, i) {
264
+ function be(e, t, n, r, i) {
201
265
  var a = {
202
266
  type: e,
203
267
  props: t,
@@ -209,16 +273,16 @@ function he(e, t, n, r, i) {
209
273
  __e: null,
210
274
  __c: null,
211
275
  constructor: void 0,
212
- __v: i || ++ne,
276
+ __v: i || ++ae,
213
277
  __i: -1,
214
278
  __u: 0
215
279
  };
216
- return !i && A.vnode && A.vnode(a), a;
280
+ return !i && M.vnode && M.vnode(a), a;
217
281
  }
218
282
  function I(e) {
219
283
  return e.children;
220
284
  }
221
- function ge(e, t) {
285
+ function xe(e, t) {
222
286
  this.props = e, this.context = t, this.__g = 0;
223
287
  }
224
288
  function L(e, t) {
@@ -226,30 +290,30 @@ function L(e, t) {
226
290
  for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) && n.__e) return n.__e;
227
291
  return typeof e.type != "function" || e.props.__P ? null : L(e);
228
292
  }
229
- function _e(e) {
293
+ function Se(e) {
230
294
  if ((e = e.__) && e.__c && !e.props.__P) return e.__e = null, e.__k.some(function(t) {
231
295
  return t && (e.__e = t.__e);
232
- }), _e(e);
296
+ }), Se(e);
233
297
  }
234
- function ve(e) {
235
- (8 & e.__g || !(e.__g |= 8) || !j.push(e) || M++) && re == A.debounceRendering || ((re = A.debounceRendering) || queueMicrotask)(ye);
298
+ function Ce(e) {
299
+ (8 & e.__g || !(e.__g |= 8) || !N.push(e) || se++) && oe == M.debounceRendering || ((oe = M.debounceRendering) || queueMicrotask)(we);
236
300
  }
237
- function ye() {
301
+ function we() {
238
302
  var e, t, n, r, i, a, o, s, c;
239
303
  try {
240
- for (t = 1; j.length;) j.length > t && j.sort(ie), e = j.shift(), t = j.length, 8 & e.__g && (r = void 0, i = void 0, a = (i = (n = e).__v).__e, o = [], s = [], (c = n.__P) && ((r = F({ constructor: void 0 }, i)).__v = i.__v + 1, A.vnode && A.vnode(r), De(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, ke(o, r, s), i.__ = i.__e = null, r.__e != a && _e(r)));
304
+ for (t = 1; N.length;) N.length > t && N.sort(ce), e = N.shift(), t = N.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, M.vnode && M.vnode(r), Me(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, Pe(o, r, s), i.__ = i.__e = null, r.__e != a && Se(r)));
241
305
  } finally {
242
- j.length = M = 0;
306
+ N.length = se = 0;
243
307
  }
244
308
  }
245
- function be(e, t, n, r, i, a, o, s, c, l, u) {
246
- var d, f, p, m, h, g, _ = r.__k || P, v = t.length;
247
- for (c = xe(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = ~p.__i && _[p.__i] || ue, p.__i = d, g = De(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && (f.ref != p.ref || 8 & f.__u) && (f.ref != p.ref && f.ref && je(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h ||= m, 4 & p.__u ? (c = Se(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);
309
+ function Te(e, t, n, r, i, a, o, s, c, l, u) {
310
+ var d, f, p, m, h, g, _ = r.__k || he, v = t.length;
311
+ for (c = Ee(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = ~p.__i && _[p.__i] || me, p.__i = d, g = Me(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && (f.ref != p.ref || 8 & f.__u) && (f.ref != p.ref && f.ref && Ie(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h ||= m, 4 & p.__u ? (c = De(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);
248
312
  return n.__e = h, c;
249
313
  }
250
- function xe(e, t, n, r, i) {
314
+ function Ee(e, t, n, r, i) {
251
315
  var a, o, s, c, l, u, d, f, p, m, h = n.length, g = h, _ = 0, v = !1, y = e.__k = Array(i);
252
- for (a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o != "object" || o.constructor == String ? o = y[a] = he(null, o) : fe(o) ? o = y[a] = he(I, { children: o }) : o.constructor === void 0 && o.__b ? o = y[a] = he(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 = Ce(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
+ 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] = be(null, o) : _e(o) ? o = y[a] = be(I, { children: o }) : o.constructor === void 0 && o.__b ? o = y[a] = be(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 = Oe(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;
253
317
  if (v) {
254
318
  for (u = [], d = [], a = 0; a < i; a++) if ((o = y[a]) && 2 & o.__u) {
255
319
  for (f = 0, p = u.length; f < p;) u[m = f + p >> 1] < o.__i ? f = m + 1 : p = m;
@@ -257,20 +321,20 @@ function xe(e, t, n, r, i) {
257
321
  }
258
322
  for (_ = u.length; a--;) d[a] && (d[a] == _ ? _-- : y[a].__u |= 4);
259
323
  }
260
- if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r = L(s)), Me(s, s));
324
+ if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r = L(s)), Le(s, s));
261
325
  return r;
262
326
  }
263
- function Se(e, t, n, r) {
327
+ function De(e, t, n, r) {
264
328
  var i, a;
265
329
  if (typeof e.type == "function") {
266
330
  if (e.props.__P) return t;
267
- if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t = Se(i[a], t, n, !1));
331
+ if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t = De(i[a], t, n, !1));
268
332
  return t;
269
333
  }
270
334
  for (t && !t.parentNode && (t = L(e)) && !t.parentNode && (t = null), e.__e != t && (!r && n.moveBefore && e.__e.parentNode ? n.moveBefore(e.__e, t) : n.insertBefore(e.__e, t || null)), t = e.__e; (t &&= t.nextSibling) && t.nodeType == 8;);
271
335
  return t;
272
336
  }
273
- function Ce(e, t, n, r) {
337
+ function Oe(e, t, n, r) {
274
338
  var i, a, o, s = e.key, c = e.type, l = t[n], u = l && !(2 & l.__u);
275
339
  if (l === null && s == null || u && s == l.key && c == l.type) return n;
276
340
  if (r > +!!u) {
@@ -278,18 +342,18 @@ function Ce(e, t, n, r) {
278
342
  }
279
343
  return -1;
280
344
  }
281
- function we(e, t, n) {
345
+ function ke(e, t, n) {
282
346
  n ??= "", t[0] == "-" ? e.setProperty(t, n) : e[t] = n;
283
347
  }
284
- function Te(e, t, n, r, i) {
348
+ function Ae(e, t, n, r, i) {
285
349
  var a;
286
350
  n: if (t == "style") {
287
351
  if (typeof n == "string") e.style.cssText = n;
288
352
  else {
289
- if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || we(e.style, t, "");
290
- if (n) for (t in n) r && n[t] == r[t] || we(e.style, t, n[t]);
353
+ if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || ke(e.style, t, "");
354
+ if (n) for (t in n) r && n[t] == r[t] || ke(e.style, t, n[t]);
291
355
  }
292
- } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(oe, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()), (e.__e ||= {})[t + a] = n, n ? r ? n[N] = r[N] : (n[N] = se, e.addEventListener(t, a ? le : ce, a)) : e.removeEventListener(t, a ? le : ce, a);
356
+ } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(ue, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()), (e.__e ||= {})[t + a] = n, n ? r ? n[P] = r[P] : (n[P] = de, e.addEventListener(t, a ? pe : fe, a)) : e.removeEventListener(t, a ? pe : fe, a);
293
357
  else {
294
358
  if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
295
359
  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 {
@@ -299,17 +363,17 @@ function Te(e, t, n, r, i) {
299
363
  typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
300
364
  }
301
365
  }
302
- function Ee(e) {
366
+ function je(e) {
303
367
  return function(t) {
304
368
  if (this.__e) {
305
369
  var n = this.__e[t.type + e];
306
- if (t[ae] == null) t[ae] = se++;
307
- else if (t[ae] < n[N]) return;
308
- return n(A.event ? A.event(t) : t);
370
+ if (t[le] == null) t[le] = de++;
371
+ else if (t[le] < n[P]) return;
372
+ return n(M.event ? M.event(t) : t);
309
373
  }
310
374
  };
311
375
  }
312
- function De(e, t, n, r, i, a, o, s, c, l) {
376
+ function Me(e, t, n, r, i, a, o, s, c, l) {
313
377
  var u, d, f, p, m, h, g, _, v, y, b, x, S, C, ee, w, T, E, D, O, k = t.type;
314
378
  if (t.constructor !== void 0) return null;
315
379
  if (128 & n.__u && (c = 32 & n.__u, u = n.__c.__z)) {
@@ -323,28 +387,28 @@ function De(e, t, n, r, i, a, o, s, c, l) {
323
387
  else a.push(u);
324
388
  s = a[0];
325
389
  }
326
- (u = A.__b) && u(t);
390
+ (u = M.__b) && u(t);
327
391
  n: if (typeof k == "function") {
328
392
  m = o.length;
329
393
  try {
330
- if (y = t.props, b = (u = k.prototype) && u.render, x = (u = k.contextType) && r[u.__c], S = u ? x ? x.props.value : u.__ : r, n.__c ? 2 & (h = t.__c = n.__c).__g && (h.__g |= 1) : (b ? t.__c = h = new k(y, S) : (t.__c = h = new ge(y, S), h.constructor = k, h.render = Ne), x && x.sub(h), h.state || (h.state = {}), h.__n = r, h.__g |= 8, h.__h = [], h.__k = []), b && (h.__s || (h.__s = h.state), k.getDerivedStateFromProps && (h.__s == h.state && (h.__s = F({}, h.__s)), F(h.__s, k.getDerivedStateFromProps(y, h.__s)))), g = h.props, _ = h.state, h.__v = t, n.__c) {
394
+ if (y = t.props, b = (u = k.prototype) && u.render, x = (u = k.contextType) && r[u.__c], S = u ? x ? x.props.value : u.__ : r, n.__c ? 2 & (h = t.__c = n.__c).__g && (h.__g |= 1) : (b ? t.__c = h = new k(y, S) : (t.__c = h = new xe(y, S), h.constructor = k, h.render = Re), x && x.sub(h), h.state || (h.state = {}), h.__n = r, h.__g |= 8, h.__h = [], h.__k = []), b && (h.__s || (h.__s = h.state), k.getDerivedStateFromProps && (h.__s == h.state && (h.__s = F({}, h.__s)), F(h.__s, k.getDerivedStateFromProps(y, h.__s)))), g = h.props, _ = h.state, h.__v = t, n.__c) {
331
395
  if (b && !k.getDerivedStateFromProps && y !== g && h.componentWillReceiveProps && h.componentWillReceiveProps(y, S), t.__v == n.__v && !(8 & h.__g) || !(4 & h.__g) && h.shouldComponentUpdate && !1 === h.shouldComponentUpdate(y, h.__s, S)) {
332
396
  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) {
333
397
  e && (e.__ = t);
334
- }), P.push.apply(h.__h, h.__k), h.__k = [], h.__h.length && o.push(h), s = L(n);
398
+ }), he.push.apply(h.__h, h.__k), h.__k = [], h.__h.length && o.push(h), s = L(n);
335
399
  break n;
336
400
  }
337
401
  h.componentWillUpdate && h.componentWillUpdate(y, h.__s, S), b && h.componentDidUpdate && h.__h.push(function() {
338
402
  h.componentDidUpdate(g, _, v);
339
403
  });
340
404
  } else b && !k.getDerivedStateFromProps && h.componentWillMount && h.componentWillMount(), b && h.componentDidMount && h.__h.push(h.componentDidMount);
341
- if (h.context = S, h.props = y, h.__P = e, h.__g &= -5, C = A.__r, ee = 0, b) h.state = h.__s, h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), P.push.apply(h.__h, h.__k), h.__k = [];
405
+ if (h.context = S, h.props = y, h.__P = e, h.__g &= -5, C = M.__r, ee = 0, b) h.state = h.__s, h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), he.push.apply(h.__h, h.__k), h.__k = [];
342
406
  else do
343
407
  h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), h.state = h.__s;
344
408
  while (8 & h.__g && ++ee < 25);
345
409
  h.state = h.__s, h.getChildContext && (r = F({}, r, h.getChildContext())), b && n.__c && h.getSnapshotBeforeUpdate && (v = h.getSnapshotBeforeUpdate(g, _)), w = 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) {
346
- e && Me(e, e);
347
- }), n.__k = null), s = n.__k ? L(n, 0) : null), s = be(e, fe(w) ? w : [w], t, n, r, i, a, o, s, c, l), y.__P && (t.__e = null, s = u), t.__u &= -161, 128 & n.__u && (h.__z = null), d && d.some(me), h.__h.length && o.push(h), 1 & h.__g && (h.__g &= -4);
410
+ e && Le(e, e);
411
+ }), n.__k = null), s = n.__k ? L(n, 0) : null), s = Te(e, _e(w) ? w : [w], t, n, r, i, a, o, s, c, l), y.__P && (t.__e = null, s = u), t.__u &= -161, 128 & n.__u && (h.__z = null), d && d.some(ye), h.__h.length && o.push(h), 1 & h.__g && (h.__g &= -4);
348
412
  } catch (e) {
349
413
  if (o.length = m, t.__v = null, c || a) {
350
414
  if (e.then) {
@@ -364,30 +428,30 @@ function De(e, t, n, r, i, a, o, s, c, l) {
364
428
  a && (a[a.indexOf(s)] = null), E = s;
365
429
  }
366
430
  t.__c.__z || (t.__c.__z = E), t.__e = s;
367
- } else a && a.some(me);
431
+ } else a && a.some(ye);
368
432
  } else t.__e = n.__e;
369
- t.__k ||= n.__k || [], e.then || Oe(t), A.__e(e, t, n);
433
+ t.__k ||= n.__k || [], e.then || Ne(t), M.__e(e, t, n);
370
434
  }
371
- } else s = t.__e = Ae(n.__e, t, n, r, i, a, o, c, l, e);
372
- return (u = A.diffed) && u(t), 128 & t.__u ? void 0 : s;
435
+ } else s = t.__e = Fe(n.__e, t, n, r, i, a, o, c, l, e);
436
+ return (u = M.diffed) && u(t), 128 & t.__u ? void 0 : s;
373
437
  }
374
- function Oe(e) {
375
- e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(Oe));
438
+ function Ne(e) {
439
+ e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(Ne));
376
440
  }
377
- function ke(e, t, n) {
378
- for (var r = 0; r < n.length;) je(n[r++], n[r++], n[r++]);
379
- A.__c && A.__c(t, e), e.some(function(t) {
441
+ function Pe(e, t, n) {
442
+ for (var r = 0; r < n.length;) Ie(n[r++], n[r++], n[r++]);
443
+ M.__c && M.__c(t, e), e.some(function(t) {
380
444
  try {
381
445
  e = t.__h, t.__h = [], e.some(function(e) {
382
446
  e.call(t);
383
447
  });
384
448
  } catch (e) {
385
- A.__e(e, t.__v);
449
+ M.__e(e, t.__v);
386
450
  }
387
451
  });
388
452
  }
389
- function Ae(e, t, n, r, i, a, o, s, c, l) {
390
- var u, d, f, p, m, h, g, _, v, y = n.props || ue, b = t.props, x = t.type;
453
+ function Fe(e, t, n, r, i, a, o, s, c, l) {
454
+ var u, d, f, p, m, h, g, _, v, y = n.props || me, b = t.props, x = t.type;
391
455
  if (x == "svg" ? i = "http://www.w3.org/2000/svg" : x == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i ||= "http://www.w3.org/1999/xhtml", a) {
392
456
  for (u = 0; u < a.length; u++) if ((m = a[u]) && (x ? m.localName == x : m.nodeType == 3)) {
393
457
  e = m, a[u] = null;
@@ -396,44 +460,44 @@ function Ae(e, t, n, r, i, a, o, s, c, l) {
396
460
  }
397
461
  if (!e) {
398
462
  if (_ = l.ownerDocument || document, !x) return _.createTextNode(b);
399
- e = _.createElementNS(i, x, b.is && b), s &&= (A.__m && A.__m(t, a), !1), a = null;
463
+ e = _.createElementNS(i, x, b.is && b), s &&= (M.__m && M.__m(t, a), !1), a = null;
400
464
  }
401
465
  if (x) {
402
- if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a && pe.call(l.childNodes), !s && a) for (y = {}, u = 0; u < e.attributes.length; u++) y[(m = e.attributes[u]).name] = m.value;
403
- for (u in y) m = y[u], u == "dangerouslySetInnerHTML" ? f = m : u == "children" || u in b || u == "value" && "defaultValue" in b || u == "checked" && "defaultChecked" in b || Te(e, u, null, m, i);
404
- for (u in v = 1 & n.__u, b) m = b[u], u == "children" ? p = m : u == "dangerouslySetInnerHTML" ? d = m : u == "value" ? h = m : u == "checked" ? g = m : s && typeof m != "function" || !(y[u] !== m || v && m != null) || Te(e, u, m, y[u], i);
405
- d ? (s || f && (d.__html == f.__html || d.__html == e.innerHTML) || (e.innerHTML = d.__html), t.__k = []) : (f && (e.textContent = ""), (x == "foreignObject" || i == "http://www.w3.org/1998/Math/MathML" && de.test(x)) && (i = "http://www.w3.org/1999/xhtml"), be(l, fe(p) ? p : [p], t, n, r, i, a, o, a ? a[0] : n.__k && L(n, 0), s, c), a && a.some(me)), s && x != "textarea" || (u = "value", x == "progress" && h == null ? e.removeAttribute(u) : h == null || h === e[u] && (x != "progress" || h) || Te(e, u, h, y[u], i), u = "checked", g != null && g != e[u] && Te(e, u, g, y[u], i));
466
+ if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a && ve.call(l.childNodes), !s && a) for (y = {}, u = 0; u < e.attributes.length; u++) y[(m = e.attributes[u]).name] = m.value;
467
+ 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 || Ae(e, u, null, m, i);
468
+ 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) || Ae(e, u, m, y[u], i);
469
+ 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" && ge.test(x)) && (i = "http://www.w3.org/1999/xhtml"), Te(l, _e(p) ? p : [p], t, n, r, i, a, o, a ? a[0] : n.__k && L(n, 0), s, c), a && a.some(ye)), s && x != "textarea" || (u = "value", x == "progress" && h == null ? e.removeAttribute(u) : h == null || h === e[u] && (x != "progress" || h) || Ae(e, u, h, y[u], i), u = "checked", g != null && g != e[u] && Ae(e, u, g, y[u], i));
406
470
  } else y === b || s && e.data == b || (e.data = b);
407
471
  return e;
408
472
  }
409
- function je(e, t, n) {
473
+ function Ie(e, t, n) {
410
474
  try {
411
475
  typeof e == "function" ? (typeof e.__u == "function" && e.__u(), (typeof e.__u != "function" || t) && (e.__u = e(t))) : e.current = t;
412
476
  } catch (e) {
413
- A.__e(e, n);
477
+ M.__e(e, n);
414
478
  }
415
479
  }
416
- function Me(e, t, n) {
480
+ function Le(e, t, n) {
417
481
  var r, i;
418
- if (A.unmount && A.unmount(e), !(r = e.ref) || r.current && r.current != e.__e || je(r, null, t), r = e.__c) {
482
+ if (M.unmount && M.unmount(e), !(r = e.ref) || r.current && r.current != e.__e || Ie(r, null, t), r = e.__c) {
419
483
  if (r.componentWillUnmount) try {
420
484
  r.componentWillUnmount();
421
485
  } catch (e) {
422
- A.__e(e, t);
486
+ M.__e(e, t);
423
487
  }
424
488
  r.__P = r.__n = null;
425
489
  }
426
- if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && Me(r[i], t, typeof e.type != "function" || n && !e.props.__P);
427
- (r = e.__e) && (n || me(r), r.__e && (r.__e = null)), e.__e = e.__c = e.__ = null;
490
+ if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && Le(r[i], t, typeof e.type != "function" || n && !e.props.__P);
491
+ (r = e.__e) && (n || ye(r), r.__e && (r.__e = null)), e.__e = e.__c = e.__ = null;
428
492
  }
429
- function Ne(e, t, n) {
493
+ function Re(e, t, n) {
430
494
  return this.constructor(e, n);
431
495
  }
432
- function Pe(e, t) {
496
+ function ze(e, t) {
433
497
  var n, r, i, a;
434
- A.__ && A.__(e, t), t.nodeType == 9 && (t = t.documentElement), r = (n = e && 32 & e.__u) ? null : t.__k, t.__k = he(I, { children: [e] }), i = [], a = [], De(t, t.__k, r || ue, ue, t.namespaceURI, r ? null : t.firstChild ? pe.call(t.childNodes) : null, i, r ? r.__e : t.firstChild, n, a), ke(i, t.__k, a), t.__k.props.children = null;
498
+ M.__ && M.__(e, t), t.nodeType == 9 && (t = t.documentElement), r = (n = e && 32 & e.__u) ? null : t.__k, t.__k = be(I, { children: [e] }), i = [], a = [], Me(t, t.__k, r || me, me, t.namespaceURI, r ? null : t.firstChild ? ve.call(t.childNodes) : null, i, r ? r.__e : t.firstChild, n, a), Pe(i, t.__k, a), t.__k.props.children = null;
435
499
  }
436
- A = { __e: function(e, t, n, r) {
500
+ M = { __e: function(e, t, n, r) {
437
501
  for (var i, a, o; t = t.__;) if ((i = t.__c) && !(1 & i.__g)) {
438
502
  i.__g |= 4;
439
503
  try {
@@ -442,34 +506,34 @@ A = { __e: function(e, t, n, r) {
442
506
  e = t, o = 0;
443
507
  }
444
508
  }
445
- throw M = 0, e;
446
- } }, ne = 0, ge.prototype.setState = function(e, t) {
509
+ throw se = 0, e;
510
+ } }, ae = 0, xe.prototype.setState = function(e, t) {
447
511
  var n = this.__s;
448
- 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), ve(this)));
449
- }, ge.prototype.forceUpdate = function(e) {
450
- this.__v && (this.__g |= 4, e && this.__h.push(e), ve(this));
451
- }, ge.prototype.render = I, j = [], M = 0, ie = function(e, t) {
512
+ 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), Ce(this)));
513
+ }, xe.prototype.forceUpdate = function(e) {
514
+ this.__v && (this.__g |= 4, e && this.__h.push(e), Ce(this));
515
+ }, xe.prototype.render = I, N = [], se = 0, ce = function(e, t) {
452
516
  return e.__v.__b - t.__v.__b;
453
- }, ae = Symbol(), N = Symbol(), oe = /(PointerCapture)$|Capture$/i, se = 0, ce = Ee(!1), le = Ee(!0);
517
+ }, le = Symbol(), P = Symbol(), ue = /(PointerCapture)$|Capture$/i, de = 0, fe = je(!1), pe = je(!0);
454
518
  //#endregion
455
519
  //#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/hooks/dist/hooks.mjs
456
- var R, z, Fe, Ie, Le = Object.is, B = 0, Re = [], ze = [], V = A, Be = V.__b, Ve = V.__r, He = V.diffed, Ue = V.__c, We = V.unmount, Ge = V.__;
457
- function Ke(e, t) {
458
- V.__h && V.__h(z, e, B || t), B = 0;
520
+ var R, z, Be, Ve, He = Object.is, Ue = 0, We = [], Ge = [], B = M, Ke = B.__b, qe = B.__r, Je = B.diffed, Ye = B.__c, Xe = B.unmount, Ze = B.__;
521
+ function Qe(e, t) {
522
+ B.__h && B.__h(z, e, Ue || t), Ue = 0;
459
523
  var n = z.__H || (z.__H = {
460
524
  __: [],
461
525
  __h: []
462
526
  });
463
527
  return e >= n.__.length && n.__.push({}), n.__[e];
464
528
  }
465
- function qe(e) {
466
- return B = 1, Je(nt, e);
529
+ function V(e) {
530
+ return Ue = 1, $e(lt, e);
467
531
  }
468
- function Je(e, t, n) {
469
- var r = Ke(R++, 2);
470
- if (r.t = e, !r.__c && (r.__ = [n ? n(t) : nt(void 0, t), function(e) {
532
+ function $e(e, t, n) {
533
+ var r = Qe(R++, 2);
534
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : lt(void 0, t), function(e) {
471
535
  var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
472
- Le(t, n) || (r.__N = [n, r.__[1]], r.__c.setState({}));
536
+ He(t, n) || (r.__N = [n, r.__[1]], r.__c.setState({}));
473
537
  }], r.__c = z, !z.__f)) {
474
538
  z.__f = !0;
475
539
  var i = z.shouldComponentUpdate;
@@ -478,7 +542,7 @@ function Je(e, t, n) {
478
542
  if (!r) return !0;
479
543
  var a = !1, o = this.props != e;
480
544
  if (r.__.some(function(e) {
481
- e.__N && (a = !0, Le(e.__[0], e.__N[0]) || (o = !0));
545
+ e.__N && (a = !0, He(e.__[0], e.__N[0]) || (o = !0));
482
546
  }), i) {
483
547
  var s = i.call(this, e, t, n);
484
548
  return a ? s || o : s;
@@ -488,67 +552,71 @@ function Je(e, t, n) {
488
552
  }
489
553
  return r.__;
490
554
  }
491
- function H(e, t) {
492
- var n = Ke(R++, 3);
493
- !V.__s && tt(n.__H, t) && (n.__P = !0, n.__ = e, n.u = t, z.__H.__h.push(n));
555
+ function et(e, t) {
556
+ var n = Qe(R++, 3);
557
+ !B.__s && ct(n.__H, t) && (n.__P = !0, n.__ = e, n.u = t, z.__H.__h.push(n));
494
558
  }
495
- function U(e) {
496
- return B = 5, Ye(function() {
559
+ function tt(e, t) {
560
+ var n = Qe(R++, 4);
561
+ !B.__s && ct(n.__H, t) && (n.__P = !1, n.__ = e, n.u = t, z.__h.push(n));
562
+ }
563
+ function H(e) {
564
+ return Ue = 5, nt(function() {
497
565
  return { current: e };
498
566
  }, []);
499
567
  }
500
- function Ye(e, t) {
501
- var n = Ke(R++, 7);
502
- return tt(n.__H, t) && (n.__ = e(), n.__H = t), n.__;
568
+ function nt(e, t) {
569
+ var n = Qe(R++, 7);
570
+ return ct(n.__H, t) && (n.__ = e(), n.__H = t), n.__;
503
571
  }
504
- function Xe() {
572
+ function rt() {
505
573
  var e;
506
574
  do {
507
- for (; e = ze.shift();) try {
508
- W(e);
575
+ for (; e = Ge.shift();) try {
576
+ U(e);
509
577
  } catch (t) {
510
- V.__e(t, { __: (e = e.__P) && e.__v });
578
+ B.__e(t, { __: (e = e.__P) && e.__v });
511
579
  }
512
- for (; e = Re.shift();) {
580
+ for (; e = We.shift();) {
513
581
  var t = e.__H;
514
582
  if (e.__P && t) try {
515
- t.__h.some(W), t.__h.some(et), t.__h = [];
583
+ t.__h.some(U), t.__h.some(st), t.__h = [];
516
584
  } catch (n) {
517
- t.__h = [], V.__e(n, e.__v);
585
+ t.__h = [], B.__e(n, e.__v);
518
586
  }
519
587
  }
520
- } while (ze.length);
521
- }
522
- V.__b = function(e) {
523
- z = null, Be && Be(e);
524
- }, V.__ = function(e, t) {
525
- e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Ge && Ge(e, t);
526
- }, V.__r = function(e) {
527
- Ve && Ve(e), R = 0;
588
+ } while (Ge.length);
589
+ }
590
+ B.__b = function(e) {
591
+ z = null, Ke && Ke(e);
592
+ }, B.__ = function(e, t) {
593
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Ze && Ze(e, t);
594
+ }, B.__r = function(e) {
595
+ qe && qe(e), R = 0;
528
596
  var t = (z = e.__c).__H;
529
- t && (Fe == z ? z.__h = [] : (t.__h.some(W), t.__h.some(et), R = 0), t.__h = [], t.__.some(function(e) {
597
+ t && (Be == z ? z.__h = [] : (t.__h.some(U), t.__h.some(st), R = 0), t.__h = [], t.__.some(function(e) {
530
598
  e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
531
- })), Fe = z;
532
- }, V.diffed = function(e) {
533
- He && He(e);
599
+ })), Be = z;
600
+ }, B.diffed = function(e) {
601
+ Je && Je(e);
534
602
  var t = e.__c;
535
- t && t.__H && (t.__H.__h.length && $e(Re.push(t)), t.__H.__.some(function(e) {
603
+ t && t.__H && (t.__H.__h.length && ot(We.push(t)), t.__H.__.some(function(e) {
536
604
  e.u && (e.__H = e.u);
537
- })), Fe = z = null;
538
- }, V.__c = function(e, t) {
605
+ })), Be = z = null;
606
+ }, B.__c = function(e, t) {
539
607
  t.some(function(e) {
540
608
  try {
541
- e.__h.some(W), e.__h = e.__h.filter(function(e) {
542
- return !e.__ || et(e);
609
+ e.__h.some(U), e.__h = e.__h.filter(function(e) {
610
+ return !e.__ || st(e);
543
611
  });
544
612
  } catch (n) {
545
613
  t.some(function(e) {
546
614
  e.__h &&= [];
547
- }), t = [], V.__e(n, e.__v);
615
+ }), t = [], B.__e(n, e.__v);
548
616
  }
549
- }), Ue && Ue(e, t);
550
- }, V.unmount = function(e) {
551
- We && We(e);
617
+ }), Ye && Ye(e, t);
618
+ }, B.unmount = function(e) {
619
+ Xe && Xe(e);
552
620
  var t, n, r = e.__c;
553
621
  r && r.__H && (r.__H.__.some(function(r) {
554
622
  try {
@@ -557,44 +625,44 @@ V.__b = function(e) {
557
625
  for (n = e.__; n && (!n.__c || !n.__c.__P);) n = n.__;
558
626
  n &&= n.__c;
559
627
  }
560
- r.__P = n, $e(ze.push(r));
561
- } else W(r);
628
+ r.__P = n, ot(Ge.push(r));
629
+ } else U(r);
562
630
  } catch (e) {
563
631
  t = e;
564
632
  }
565
- }), r.__H = void 0, t && V.__e(t, r.__v));
633
+ }), r.__H = void 0, t && B.__e(t, r.__v));
566
634
  };
567
- var Ze = typeof requestAnimationFrame == "function";
568
- function Qe(e) {
635
+ var it = typeof requestAnimationFrame == "function";
636
+ function at(e) {
569
637
  var t, n = function() {
570
- clearTimeout(r), Ze && cancelAnimationFrame(t), setTimeout(e);
638
+ clearTimeout(r), it && cancelAnimationFrame(t), setTimeout(e);
571
639
  }, r = setTimeout(n, 35);
572
- Ze && (t = requestAnimationFrame(n));
640
+ it && (t = requestAnimationFrame(n));
573
641
  }
574
- function $e(e) {
575
- e != 1 && Ie == V.requestAnimationFrame || ((Ie = V.requestAnimationFrame) || Qe)(Xe);
642
+ function ot(e) {
643
+ e != 1 && Ve == B.requestAnimationFrame || ((Ve = B.requestAnimationFrame) || at)(rt);
576
644
  }
577
- function W(e) {
645
+ function U(e) {
578
646
  var t = z, n = e.__c;
579
647
  typeof n == "function" && (e.__c = void 0, n()), z = t;
580
648
  }
581
- function et(e) {
649
+ function st(e) {
582
650
  var t = z;
583
651
  e.__c = e.__(), z = t;
584
652
  }
585
- function tt(e, t) {
653
+ function ct(e, t) {
586
654
  return !e || e.length != t.length || t.some(function(t, n) {
587
- return !Le(t, e[n]);
655
+ return !He(t, e[n]);
588
656
  });
589
657
  }
590
- function nt(e, t) {
658
+ function lt(e, t) {
591
659
  return typeof t == "function" ? t(e) : t;
592
660
  }
593
661
  //#endregion
594
662
  //#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
595
- var rt = 0;
663
+ var ut = 0;
596
664
  Array.isArray;
597
- function G(e, t, n, r, i, a) {
665
+ function W(e, t, n, r, i, a) {
598
666
  t ||= {};
599
667
  var o, s, c = t;
600
668
  if ("ref" in c && typeof e != "function") for (s in c = {}, t) s == "ref" ? o = t[s] : c[s] = t[s];
@@ -609,16 +677,16 @@ function G(e, t, n, r, i, a) {
609
677
  __e: null,
610
678
  __c: null,
611
679
  constructor: void 0,
612
- __v: --rt,
680
+ __v: --ut,
613
681
  __i: -1,
614
682
  __u: 0
615
683
  };
616
- return (i || a) && (l.__source = i, l.__self = a), A.vnode && A.vnode(l), l;
684
+ return (i || a) && (l.__source = i, l.__self = a), M.vnode && M.vnode(l), l;
617
685
  }
618
686
  //#endregion
619
687
  //#region src/components/icons.tsx
620
- function K({ name: e, size: t, children: n }) {
621
- return /* @__PURE__ */ G("svg", {
688
+ function G({ name: e, size: t, children: n }) {
689
+ return /* @__PURE__ */ W("svg", {
622
690
  "data-icon": e,
623
691
  "aria-hidden": "true",
624
692
  focusable: "false",
@@ -633,180 +701,544 @@ function K({ name: e, size: t, children: n }) {
633
701
  children: n
634
702
  });
635
703
  }
636
- function it({ size: e = 26 }) {
637
- return /* @__PURE__ */ G(K, {
704
+ function dt({ size: e = 26 }) {
705
+ return /* @__PURE__ */ W(G, {
638
706
  name: "chat",
639
707
  size: e,
640
- children: [/* @__PURE__ */ G("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__ */ G("path", {
708
+ 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", {
641
709
  d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
642
710
  "stroke-width": "2.5"
643
711
  })]
644
712
  });
645
713
  }
646
- function at({ size: e = 26 }) {
647
- return /* @__PURE__ */ G(K, {
714
+ function ft({ size: e = 26 }) {
715
+ return /* @__PURE__ */ W(G, {
648
716
  name: "message",
649
717
  size: e,
650
- children: /* @__PURE__ */ G("path", { d: "M21 11.5a8.5 8.5 0 0 1-12.4 7.5L3 20.5l1.6-5.1A8.5 8.5 0 1 1 21 11.5z" })
718
+ 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" })
651
719
  });
652
720
  }
653
- function ot({ size: e = 26 }) {
654
- return /* @__PURE__ */ G(K, {
721
+ function pt({ size: e = 26 }) {
722
+ return /* @__PURE__ */ W(G, {
655
723
  name: "sparkle",
656
724
  size: e,
657
- children: [/* @__PURE__ */ G("path", { d: "M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z" }), /* @__PURE__ */ G("path", { d: "M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z" })]
725
+ 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" })]
658
726
  });
659
727
  }
660
- function st({ size: e = 26 }) {
661
- return /* @__PURE__ */ G(K, {
728
+ function mt({ size: e = 26 }) {
729
+ return /* @__PURE__ */ W(G, {
662
730
  name: "chevron-down",
663
731
  size: e,
664
- children: /* @__PURE__ */ G("path", { d: "M6 9l6 6 6-6" })
732
+ children: /* @__PURE__ */ W("path", { d: "M6 9l6 6 6-6" })
665
733
  });
666
734
  }
667
- function ct({ size: e = 18 }) {
668
- return /* @__PURE__ */ G(K, {
735
+ function ht({ size: e = 18 }) {
736
+ return /* @__PURE__ */ W(G, {
669
737
  name: "close",
670
738
  size: e,
671
- children: /* @__PURE__ */ G("path", { d: "M6 6l12 12M18 6L6 18" })
739
+ children: /* @__PURE__ */ W("path", { d: "M6 6l12 12M18 6L6 18" })
672
740
  });
673
741
  }
674
- var lt = "M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7";
675
- function ut({ size: e = 16 }) {
676
- return /* @__PURE__ */ G(K, {
742
+ var gt = "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";
743
+ function _t({ size: e = 16 }) {
744
+ return /* @__PURE__ */ W(G, {
677
745
  name: "thumb-up",
678
746
  size: e,
679
- children: /* @__PURE__ */ G("path", { d: lt })
747
+ children: /* @__PURE__ */ W("path", { d: gt })
680
748
  });
681
749
  }
682
- function dt({ size: e = 16 }) {
683
- return /* @__PURE__ */ G(K, {
750
+ function vt({ size: e = 16 }) {
751
+ return /* @__PURE__ */ W(G, {
684
752
  name: "thumb-down",
685
753
  size: e,
686
- children: /* @__PURE__ */ G("path", {
687
- d: lt,
754
+ children: /* @__PURE__ */ W("path", {
755
+ d: gt,
688
756
  transform: "matrix(1 0 0 -1 0 24)"
689
757
  })
690
758
  });
691
759
  }
692
760
  //#endregion
693
761
  //#region src/components/Launcher.tsx
694
- var ft = {
695
- chat: it,
696
- message: at,
697
- sparkle: ot
698
- }, pt = {
699
- "chevron-down": st,
700
- close: ct
762
+ var yt = {
763
+ chat: dt,
764
+ message: ft,
765
+ sparkle: pt
766
+ }, bt = {
767
+ "chevron-down": mt,
768
+ close: ht
701
769
  };
702
- function mt({ isOpen: e, onClick: t, iconUrl: n, icon: r = "chat", openIconUrl: i, openIcon: a = "chevron-down", buttonRef: o }) {
703
- let [s, c] = qe("loading"), [l, u] = qe("loading"), d = n !== void 0 && s !== "failed", f = i !== void 0 && l !== "failed", p = d && !e && s === "loaded", m = f && e && l === "loaded", h = ft[r] ?? it, g = pt[a] ?? st;
704
- return /* @__PURE__ */ G("button", {
770
+ function xt({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl: a, openIcon: o = "chevron-down", buttonRef: s, text: c = e }) {
771
+ let [l, u] = V("loading"), [d, f] = V("loading"), p = r !== void 0 && l !== "failed", m = a !== void 0 && d !== "failed", h = p && !t && l === "loaded", g = m && t && d === "loaded", _ = yt[i] ?? dt, v = bt[o] ?? mt;
772
+ return /* @__PURE__ */ W("button", {
705
773
  type: "button",
706
774
  class: "whoo-widget-launcher",
707
- onClick: t,
708
- "aria-label": e ? "Close chat" : "Open chat",
709
- ref: o,
775
+ onClick: n,
776
+ "aria-label": t ? c.closeChat : c.openChat,
777
+ ref: s,
710
778
  children: [
711
- e ? m ? null : /* @__PURE__ */ G(g, {}) : p ? null : /* @__PURE__ */ G(h, {}),
712
- d ? /* @__PURE__ */ G("img", {
779
+ t ? g ? null : /* @__PURE__ */ W(v, {}) : h ? null : /* @__PURE__ */ W(_, {}),
780
+ p ? /* @__PURE__ */ W("img", {
713
781
  class: "whoo-widget-launcher-icon-image",
714
- src: n,
782
+ src: r,
715
783
  alt: "",
716
784
  referrerpolicy: "no-referrer",
717
- hidden: !p,
718
- onLoad: () => c("loaded"),
719
- onError: () => c("failed")
785
+ hidden: !h,
786
+ onLoad: () => u("loaded"),
787
+ onError: () => u("failed")
720
788
  }) : null,
721
- f ? /* @__PURE__ */ G("img", {
789
+ m ? /* @__PURE__ */ W("img", {
722
790
  class: "whoo-widget-launcher-icon-image",
723
- src: i,
791
+ src: a,
724
792
  alt: "",
725
793
  referrerpolicy: "no-referrer",
726
- hidden: !m,
727
- onLoad: () => u("loaded"),
728
- onError: () => u("failed")
794
+ hidden: !g,
795
+ onLoad: () => f("loaded"),
796
+ onError: () => f("failed")
729
797
  }) : null
730
798
  ]
731
799
  });
732
800
  }
733
801
  //#endregion
802
+ //#region src/i18n/index.ts
803
+ var St = {
804
+ en: e,
805
+ fr: {
806
+ openChat: "Ouvrir le chat",
807
+ closeChat: "Fermer le chat",
808
+ chatWith: "Discuter avec {name}",
809
+ newConversation: "Nouvelle conversation",
810
+ conversation: "Conversation",
811
+ you: "Vous",
812
+ message: "Message",
813
+ send: "Envoyer",
814
+ lookingItUp: "Je recherche l’information pour vous…",
815
+ goodResponse: "Réponse utile",
816
+ badResponse: "Réponse peu utile",
817
+ additionalFeedback: "Commentaire supplémentaire",
818
+ feedbackPlaceholder: "Qu’est-ce qui n’allait pas ? (facultatif)",
819
+ feedbackCategory: "Catégorie du commentaire",
820
+ selectReason: "Choisissez un motif (facultatif)",
821
+ categoryFactual: "Erreur factuelle",
822
+ categoryIncomplete: "Réponse incomplète",
823
+ categoryTone: "Ton inapproprié",
824
+ categoryOther: "Autre",
825
+ submit: "Envoyer le commentaire",
826
+ cancel: "Annuler",
827
+ feedbackThanks: "Merci pour votre commentaire",
828
+ feedbackFailed: "Impossible d’envoyer votre commentaire",
829
+ conversationCleared: "Conversation effacée",
830
+ genericError: "Une erreur s’est produite. Veuillez réessayer.",
831
+ sessionExpired: "Cette session de chat a expiré. Rechargez la page pour continuer.",
832
+ opensInNewTab: "(s’ouvre dans un nouvel onglet)"
833
+ },
834
+ es: {
835
+ openChat: "Abrir chat",
836
+ closeChat: "Cerrar chat",
837
+ chatWith: "Chat con {name}",
838
+ newConversation: "Nueva conversación",
839
+ conversation: "Conversación",
840
+ you: "Usted",
841
+ message: "Mensaje",
842
+ send: "Enviar",
843
+ lookingItUp: "Estoy buscando esa información…",
844
+ goodResponse: "Buena respuesta",
845
+ badResponse: "Mala respuesta",
846
+ additionalFeedback: "Comentarios adicionales",
847
+ feedbackPlaceholder: "¿Qué estuvo mal? (opcional)",
848
+ feedbackCategory: "Tipo de problema",
849
+ selectReason: "Seleccione un motivo (opcional)",
850
+ categoryFactual: "Información incorrecta",
851
+ categoryIncomplete: "Respuesta incompleta",
852
+ categoryTone: "Tono inadecuado",
853
+ categoryOther: "Otro",
854
+ submit: "Enviar comentarios",
855
+ cancel: "Cancelar",
856
+ feedbackThanks: "Gracias por sus comentarios",
857
+ feedbackFailed: "No se pudieron enviar sus comentarios",
858
+ conversationCleared: "Se inició una nueva conversación",
859
+ genericError: "Algo salió mal. Inténtelo de nuevo.",
860
+ sessionExpired: "Esta sesión de chat expiró. Vuelva a cargar la página para continuar.",
861
+ opensInNewTab: "(se abre en una pestaña nueva)"
862
+ },
863
+ pt: {
864
+ openChat: "Abrir chat",
865
+ closeChat: "Fechar chat",
866
+ chatWith: "Conversa com {name}",
867
+ newConversation: "Nova conversa",
868
+ conversation: "Conversa",
869
+ you: "Você",
870
+ message: "Mensagem",
871
+ send: "Enviar",
872
+ lookingItUp: "Estou buscando essa informação…",
873
+ goodResponse: "Boa resposta",
874
+ badResponse: "Resposta ruim",
875
+ additionalFeedback: "Comentários adicionais",
876
+ feedbackPlaceholder: "O que estava errado? (opcional)",
877
+ feedbackCategory: "Categoria do feedback",
878
+ selectReason: "Selecione um motivo (opcional)",
879
+ categoryFactual: "Informação incorreta",
880
+ categoryIncomplete: "Resposta incompleta",
881
+ categoryTone: "Tom inadequado",
882
+ categoryOther: "Outro",
883
+ submit: "Enviar feedback",
884
+ cancel: "Cancelar",
885
+ feedbackThanks: "Agradecemos seu feedback",
886
+ feedbackFailed: "Não foi possível enviar o feedback",
887
+ conversationCleared: "Nova conversa iniciada",
888
+ genericError: "Algo deu errado. Tente novamente.",
889
+ sessionExpired: "Esta sessão de chat expirou. Recarregue a página para continuar.",
890
+ opensInNewTab: "(abre em uma nova aba)"
891
+ },
892
+ de: {
893
+ openChat: "Chat öffnen",
894
+ closeChat: "Chat schließen",
895
+ chatWith: "Chat mit {name}",
896
+ newConversation: "Neue Unterhaltung",
897
+ conversation: "Unterhaltung",
898
+ you: "Sie",
899
+ message: "Nachricht",
900
+ send: "Senden",
901
+ lookingItUp: "Ich suche die Informationen für Sie heraus…",
902
+ goodResponse: "Gute Antwort",
903
+ badResponse: "Schlechte Antwort",
904
+ additionalFeedback: "Zusätzliches Feedback",
905
+ feedbackPlaceholder: "Was war falsch? (optional)",
906
+ feedbackCategory: "Feedback-Kategorie",
907
+ selectReason: "Grund auswählen (optional)",
908
+ categoryFactual: "Faktenfehler",
909
+ categoryIncomplete: "Unvollständig",
910
+ categoryTone: "Unpassender Ton",
911
+ categoryOther: "Sonstiges",
912
+ submit: "Absenden",
913
+ cancel: "Abbrechen",
914
+ feedbackThanks: "Danke für Ihr Feedback",
915
+ feedbackFailed: "Feedback konnte nicht gesendet werden",
916
+ conversationCleared: "Neue Unterhaltung gestartet",
917
+ genericError: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.",
918
+ sessionExpired: "Diese Chat-Sitzung ist abgelaufen. Laden Sie die Seite neu, um fortzufahren.",
919
+ opensInNewTab: "(öffnet sich in neuem Tab)"
920
+ },
921
+ it: {
922
+ openChat: "Apri la chat",
923
+ closeChat: "Chiudi la chat",
924
+ chatWith: "Chat con {name}",
925
+ newConversation: "Nuova conversazione",
926
+ conversation: "Conversazione",
927
+ you: "Tu",
928
+ message: "Messaggio",
929
+ send: "Invia",
930
+ lookingItUp: "Sto cercando le informazioni richieste…",
931
+ goodResponse: "Risposta utile",
932
+ badResponse: "Risposta non utile",
933
+ additionalFeedback: "Commenti aggiuntivi",
934
+ feedbackPlaceholder: "Che cosa non andava? (facoltativo)",
935
+ feedbackCategory: "Categoria del feedback",
936
+ selectReason: "Seleziona un motivo (facoltativo)",
937
+ categoryFactual: "Informazione errata",
938
+ categoryIncomplete: "Risposta incompleta",
939
+ categoryTone: "Tono non adeguato",
940
+ categoryOther: "Altro",
941
+ submit: "Invia feedback",
942
+ cancel: "Annulla",
943
+ feedbackThanks: "Grazie per il feedback",
944
+ feedbackFailed: "Impossibile inviare il feedback",
945
+ conversationCleared: "Nuova conversazione avviata",
946
+ genericError: "Si è verificato un errore. Riprovi.",
947
+ sessionExpired: "Questa sessione di chat è scaduta. Ricarichi la pagina per continuare.",
948
+ opensInNewTab: "(si apre in una nuova scheda)"
949
+ },
950
+ ja: {
951
+ openChat: "チャットを開く",
952
+ closeChat: "チャットを閉じる",
953
+ chatWith: "{name}とチャット",
954
+ newConversation: "新しい会話",
955
+ conversation: "会話",
956
+ you: "あなた",
957
+ message: "メッセージ",
958
+ send: "送信",
959
+ lookingItUp: "確認しています…",
960
+ goodResponse: "良い回答",
961
+ badResponse: "良くない回答",
962
+ additionalFeedback: "追加のフィードバック",
963
+ feedbackPlaceholder: "何が問題でしたか?(任意)",
964
+ feedbackCategory: "フィードバックの種類",
965
+ selectReason: "理由を選択(任意)",
966
+ categoryFactual: "事実の誤り",
967
+ categoryIncomplete: "回答が不十分",
968
+ categoryTone: "不適切な口調",
969
+ categoryOther: "その他",
970
+ submit: "フィードバックを送信",
971
+ cancel: "キャンセル",
972
+ feedbackThanks: "フィードバックありがとうございます",
973
+ feedbackFailed: "フィードバックを送信できませんでした",
974
+ conversationCleared: "会話を消去しました",
975
+ genericError: "エラーが発生しました。もう一度お試しください。",
976
+ sessionExpired: "このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。",
977
+ opensInNewTab: "(新しいタブで開きます)"
978
+ },
979
+ zh: {
980
+ openChat: "打开聊天",
981
+ closeChat: "关闭聊天",
982
+ chatWith: "与{name}聊天",
983
+ newConversation: "新对话",
984
+ conversation: "对话",
985
+ you: "您",
986
+ message: "消息",
987
+ send: "发送",
988
+ lookingItUp: "正在为您查找……",
989
+ goodResponse: "回答很好",
990
+ badResponse: "回答不好",
991
+ additionalFeedback: "补充反馈",
992
+ feedbackPlaceholder: "哪里有问题?(可选)",
993
+ feedbackCategory: "反馈类别",
994
+ selectReason: "选择原因(可选)",
995
+ categoryFactual: "事实错误",
996
+ categoryIncomplete: "回答不完整",
997
+ categoryTone: "语气不当",
998
+ categoryOther: "其他",
999
+ submit: "提交",
1000
+ cancel: "取消",
1001
+ feedbackThanks: "感谢您的反馈",
1002
+ feedbackFailed: "反馈提交失败",
1003
+ conversationCleared: "对话已清除",
1004
+ genericError: "出了点问题,请重试。",
1005
+ sessionExpired: "此聊天会话已过期。请刷新页面后继续。",
1006
+ opensInNewTab: "(将在新标签页中打开)"
1007
+ },
1008
+ ru: {
1009
+ openChat: "Открыть чат",
1010
+ closeChat: "Закрыть чат",
1011
+ chatWith: "Чат с ассистентом {name}",
1012
+ newConversation: "Новый диалог",
1013
+ conversation: "Диалог",
1014
+ you: "Вы",
1015
+ message: "Сообщение",
1016
+ send: "Отправить",
1017
+ lookingItUp: "Ищу информацию…",
1018
+ goodResponse: "Хороший ответ",
1019
+ badResponse: "Плохой ответ",
1020
+ additionalFeedback: "Дополнительный комментарий",
1021
+ feedbackPlaceholder: "Что было не так? (необязательно)",
1022
+ feedbackCategory: "Категория отзыва",
1023
+ selectReason: "Выберите причину (необязательно)",
1024
+ categoryFactual: "Фактическая ошибка",
1025
+ categoryIncomplete: "Неполный ответ",
1026
+ categoryTone: "Неподходящий тон",
1027
+ categoryOther: "Другое",
1028
+ submit: "Отправить отзыв",
1029
+ cancel: "Отмена",
1030
+ feedbackThanks: "Спасибо за отзыв",
1031
+ feedbackFailed: "Не удалось отправить отзыв",
1032
+ conversationCleared: "Диалог очищен",
1033
+ genericError: "Что-то пошло не так. Попробуйте ещё раз.",
1034
+ sessionExpired: "Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить.",
1035
+ opensInNewTab: "(откроется в новой вкладке)"
1036
+ },
1037
+ hi: {
1038
+ openChat: "चैट खोलें",
1039
+ closeChat: "चैट बंद करें",
1040
+ chatWith: "{name} से चैट करें",
1041
+ newConversation: "नई बातचीत",
1042
+ conversation: "बातचीत",
1043
+ you: "आप",
1044
+ message: "संदेश",
1045
+ send: "भेजें",
1046
+ lookingItUp: "आपके लिए जानकारी खोजी जा रही है…",
1047
+ goodResponse: "अच्छा जवाब",
1048
+ badResponse: "ख़राब जवाब",
1049
+ additionalFeedback: "अतिरिक्त फ़ीडबैक",
1050
+ feedbackPlaceholder: "क्या ग़लत था? (वैकल्पिक)",
1051
+ feedbackCategory: "फ़ीडबैक की श्रेणी",
1052
+ selectReason: "कारण चुनें (वैकल्पिक)",
1053
+ categoryFactual: "तथ्यात्मक त्रुटि",
1054
+ categoryIncomplete: "अधूरा जवाब",
1055
+ categoryTone: "अनुचित लहजा",
1056
+ categoryOther: "अन्य",
1057
+ submit: "सबमिट करें",
1058
+ cancel: "रद्द करें",
1059
+ feedbackThanks: "आपके फ़ीडबैक के लिए धन्यवाद",
1060
+ feedbackFailed: "फ़ीडबैक नहीं भेजा जा सका",
1061
+ conversationCleared: "बातचीत मिटा दी गई",
1062
+ genericError: "कुछ ग़लत हो गया। कृपया फिर से कोशिश करें।",
1063
+ sessionExpired: "यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।",
1064
+ opensInNewTab: "(नए टैब में खुलता है)"
1065
+ },
1066
+ ar: {
1067
+ openChat: "فتح الدردشة",
1068
+ closeChat: "إغلاق الدردشة",
1069
+ chatWith: "الدردشة مع {name}",
1070
+ newConversation: "محادثة جديدة",
1071
+ conversation: "المحادثة",
1072
+ you: "أنت",
1073
+ message: "الرسالة",
1074
+ send: "إرسال",
1075
+ lookingItUp: "جارٍ البحث عن المعلومات…",
1076
+ goodResponse: "إجابة جيدة",
1077
+ badResponse: "إجابة سيئة",
1078
+ additionalFeedback: "ملاحظات إضافية",
1079
+ feedbackPlaceholder: "ما المشكلة؟ (اختياري)",
1080
+ feedbackCategory: "فئة الملاحظات",
1081
+ selectReason: "اختر سببًا (اختياري)",
1082
+ categoryFactual: "معلومات غير صحيحة",
1083
+ categoryIncomplete: "إجابة غير مكتملة",
1084
+ categoryTone: "أسلوب غير مناسب",
1085
+ categoryOther: "أخرى",
1086
+ submit: "إرسال الملاحظات",
1087
+ cancel: "إلغاء",
1088
+ feedbackThanks: "شكرًا على ملاحظاتك",
1089
+ feedbackFailed: "تعذّر إرسال الملاحظات",
1090
+ conversationCleared: "تم مسح المحادثة",
1091
+ genericError: "حدث خطأ ما. يُرجى المحاولة مرة أخرى.",
1092
+ sessionExpired: "انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة.",
1093
+ opensInNewTab: "(يُفتح في علامة تبويب جديدة)"
1094
+ }
1095
+ }, Ct = Object.freeze(Object.keys(St)), wt = {
1096
+ pt: "pt-BR",
1097
+ es: "es-419",
1098
+ zh: "zh-Hans"
1099
+ }, Tt = /* @__PURE__ */ new Set(["ar"]), Et = /^[a-z]{2,8}([-_][a-z0-9]{1,8})*$/i, Dt = /^zh[-_](hant|tw|hk|mo)(?=$|[-_])/i;
1100
+ function Ot(e) {
1101
+ return St[e];
1102
+ }
1103
+ function kt(e) {
1104
+ let t = e.trim();
1105
+ if (!Et.test(t) || Dt.test(t)) return null;
1106
+ let n = t.split(/[-_]/)[0].toLowerCase();
1107
+ return Object.hasOwn(St, n) ? n : null;
1108
+ }
1109
+ function At(e, t) {
1110
+ let n = null;
1111
+ return e != null && e !== "" && (n = typeof e == "string" ? kt(e) : null, n || console.warn(`whoo-aiden-widget: ignoring \`language\` ${jt(e)} -- expected one of ${Ct.join(", ")} (or a regional tag like pt-BR). Using the page's language instead.`)), n ??= typeof t == "string" ? kt(t) : null, n ??= "en", {
1112
+ language: n,
1113
+ tag: wt[n] ?? n,
1114
+ dir: Tt.has(n) ? "rtl" : "ltr"
1115
+ };
1116
+ }
1117
+ function jt(e) {
1118
+ return typeof e == "string" ? JSON.stringify(e) : `(a ${typeof e})`;
1119
+ }
1120
+ function Mt(e) {
1121
+ if (typeof e != "string") return null;
1122
+ let t = e.trim().replace(/_/g, "-");
1123
+ return Et.test(t) ? t : null;
1124
+ }
1125
+ function Nt(e, t, n) {
1126
+ if (e != null && e !== "") {
1127
+ let t = Mt(e);
1128
+ if (t) return t;
1129
+ console.warn(`whoo-aiden-widget: ignoring \`contentLanguage\` ${jt(e)} -- expected a language tag such as 'nl' or 'pt-BR'. Using the page's language instead.`);
1130
+ }
1131
+ return Mt(t) ?? Mt(n) ?? "";
1132
+ }
1133
+ function Pt(e) {
1134
+ let t = e.indexOf("{name}");
1135
+ return t === -1 ? {
1136
+ before: e,
1137
+ after: "",
1138
+ hasName: !1
1139
+ } : {
1140
+ before: e.slice(0, t),
1141
+ after: e.slice(t + 6),
1142
+ hasName: !0
1143
+ };
1144
+ }
1145
+ //#endregion
734
1146
  //#region src/viewport.ts
735
- var ht = "(max-width: 400px), (max-height: 420px)", gt = "data-fit-visible", _t = 40;
736
- function vt(e) {
1147
+ var Ft = "(max-width: 400px), (max-height: 420px)", It = "data-fit-visible", Lt = 40;
1148
+ function Rt(e) {
737
1149
  let t = typeof window < "u" ? window.visualViewport : null;
738
1150
  if (!t) return () => {};
739
1151
  let n = () => {
740
- e.removeAttribute(gt), e.style.removeProperty("--whoo-widget-visible-top"), e.style.removeProperty("--whoo-widget-visible-height");
1152
+ e.removeAttribute(It), e.style.removeProperty("--whoo-widget-visible-top"), e.style.removeProperty("--whoo-widget-visible-height");
741
1153
  }, r = () => {
742
1154
  let r = document.documentElement.clientHeight, i = Math.abs(t.scale - 1) > .01, a = r - t.height;
743
- if (i || r === 0 || a < _t) {
1155
+ if (i || r === 0 || a < Lt) {
744
1156
  n();
745
1157
  return;
746
1158
  }
747
- e.setAttribute(gt, ""), e.style.setProperty("--whoo-widget-visible-top", `${Math.max(0, t.offsetTop)}px`), e.style.setProperty("--whoo-widget-visible-height", `${t.height}px`);
1159
+ e.setAttribute(It, ""), e.style.setProperty("--whoo-widget-visible-top", `${Math.max(0, t.offsetTop)}px`), e.style.setProperty("--whoo-widget-visible-height", `${t.height}px`);
1160
+ let o = e.getRootNode().activeElement;
1161
+ o && e.contains(o) && typeof o.scrollIntoView == "function" && o.scrollIntoView({ block: "nearest" });
748
1162
  };
749
1163
  return r(), t.addEventListener("resize", r), t.addEventListener("scroll", r), () => {
750
1164
  t.removeEventListener("resize", r), t.removeEventListener("scroll", r), n();
751
1165
  };
752
1166
  }
753
- var yt = 0, bt = "";
754
- function xt() {
755
- yt++ === 0 && (bt = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden");
1167
+ function zt(e, t) {
1168
+ return typeof e.addEventListener == "function" ? (e.addEventListener("change", t), () => e.removeEventListener("change", t)) : typeof e.addListener == "function" ? (e.addListener(t), () => e.removeListener(t)) : () => {};
1169
+ }
1170
+ var Bt = 0, Vt = "";
1171
+ function Ht() {
1172
+ Bt++ === 0 && (Vt = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden");
756
1173
  }
757
- function St() {
758
- --yt === 0 && (document.documentElement.style.overflow = bt);
1174
+ function Ut() {
1175
+ --Bt === 0 && (document.documentElement.style.overflow = Vt);
759
1176
  }
760
- function Ct() {
1177
+ function Wt() {
761
1178
  if (typeof window > "u" || typeof window.matchMedia != "function") return () => {};
762
- let e = window.matchMedia(ht), t = !1, n = () => {
763
- e.matches && !t ? (t = !0, xt()) : !e.matches && t && (t = !1, St());
764
- }, r = (t) => {
765
- typeof e.addEventListener == "function" ? t ? e.addEventListener("change", n) : e.removeEventListener("change", n) : typeof e.addListener == "function" && (t ? e.addListener(n) : e.removeListener(n));
1179
+ let e = window.matchMedia(Ft), t = !1, n = () => {
1180
+ e.matches && !t ? (t = !0, Ht()) : !e.matches && t && (t = !1, Ut());
766
1181
  };
767
- return n(), r(!0), () => {
768
- r(!1), t && (t = !1, St());
1182
+ n();
1183
+ let r = zt(e, n);
1184
+ return () => {
1185
+ r(), t && (t = !1, Ut());
769
1186
  };
770
1187
  }
1188
+ function Gt(e) {
1189
+ if (typeof window > "u" || typeof window.matchMedia != "function" || typeof e.showModal != "function") return () => {};
1190
+ let t = window.matchMedia(Ft), n = !1, r = () => {
1191
+ if (t.matches === n || !e.isConnected) return;
1192
+ n = t.matches;
1193
+ let r = e.getRootNode().activeElement;
1194
+ e.close(), n ? e.showModal() : e.show(), r && e.contains(r) && r.focus({ preventScroll: !0 });
1195
+ };
1196
+ return r(), zt(t, r);
1197
+ }
771
1198
  //#endregion
772
1199
  //#region src/components/Composer.tsx
773
- function wt({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
774
- return /* @__PURE__ */ G("div", {
1200
+ function Kt(e) {
1201
+ return e.isComposing || e.keyCode === 229;
1202
+ }
1203
+ function qt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text: o = e, contentLanguage: s }) {
1204
+ return /* @__PURE__ */ W("div", {
775
1205
  class: "whoo-widget-composer",
776
1206
  children: [
777
- /* @__PURE__ */ G("label", {
1207
+ /* @__PURE__ */ W("label", {
778
1208
  class: "whoo-widget-sr-only",
779
1209
  for: "whoo-widget-composer-input",
780
- children: "Message"
1210
+ children: o.message
781
1211
  }),
782
- /* @__PURE__ */ G("input", {
1212
+ /* @__PURE__ */ W("input", {
783
1213
  id: "whoo-widget-composer-input",
784
1214
  class: "whoo-widget-composer-input",
785
- value: e,
786
- readOnly: r,
787
- "aria-disabled": r,
788
- ref: i,
789
- onInput: (e) => t(e.target.value),
1215
+ lang: s,
1216
+ autoFocus: !0,
1217
+ value: t,
1218
+ readOnly: i,
1219
+ "aria-disabled": i,
1220
+ ref: a,
1221
+ onInput: (e) => n(e.target.value),
790
1222
  onKeyDown: (e) => {
791
- e.key === "Enter" && n();
1223
+ e.key === "Enter" && !Kt(e) && r();
792
1224
  }
793
1225
  }),
794
- /* @__PURE__ */ G("button", {
1226
+ /* @__PURE__ */ W("button", {
795
1227
  type: "button",
796
1228
  class: "whoo-widget-composer-send",
797
- "aria-disabled": r,
1229
+ "aria-disabled": i,
798
1230
  onClick: () => {
799
- r || n();
1231
+ i || r();
800
1232
  },
801
- children: "Send"
1233
+ children: o.send
802
1234
  })
803
1235
  ]
804
1236
  });
805
1237
  }
806
1238
  //#endregion
807
1239
  //#region src/components/ErrorBanner.tsx
808
- function Tt({ message: e }) {
809
- return /* @__PURE__ */ G("div", {
1240
+ function Jt({ message: e }) {
1241
+ return /* @__PURE__ */ W("div", {
810
1242
  class: "whoo-widget-error-banner",
811
1243
  role: "alert",
812
1244
  children: e
@@ -814,8 +1246,8 @@ function Tt({ message: e }) {
814
1246
  }
815
1247
  //#endregion
816
1248
  //#region src/markdown/tokenizer.ts
817
- var Et = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, Dt = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, Ot = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, kt = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, At = /[ \t]*[*+-][ \t]+/y, jt = /https?:\/\/\S+/y, Mt = /[.,;:!?)\]}>]+$/;
818
- function Nt(e) {
1249
+ var Yt = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, K = /\*\*([^*\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 = /[.,;:!?)\]}>]+$/;
1250
+ function tn(e) {
819
1251
  let t = [], n = 0, r = 0, i = (n) => {
820
1252
  n > r && t.push({
821
1253
  type: "text",
@@ -825,13 +1257,13 @@ function Nt(e) {
825
1257
  });
826
1258
  };
827
1259
  for (; n < e.length;) {
828
- if ((n === 0 || e[n - 1] === "\n") && (At.lastIndex = n, At.exec(e))) {
1260
+ if ((n === 0 || e[n - 1] === "\n") && (Qt.lastIndex = n, Qt.exec(e))) {
829
1261
  i(n), t.push({
830
1262
  type: "text",
831
1263
  value: "• ",
832
1264
  start: n,
833
- end: At.lastIndex
834
- }), n = At.lastIndex, r = n;
1265
+ end: Qt.lastIndex
1266
+ }), n = Qt.lastIndex, r = n;
835
1267
  continue;
836
1268
  }
837
1269
  if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
@@ -844,56 +1276,56 @@ function Nt(e) {
844
1276
  }
845
1277
  }
846
1278
  if (e[n - 1] !== "!") {
847
- Et.lastIndex = n;
848
- let a = Et.exec(e);
1279
+ Yt.lastIndex = n;
1280
+ let a = Yt.exec(e);
849
1281
  if (a) {
850
1282
  i(n), t.push({
851
1283
  type: "link",
852
1284
  text: a[1],
853
1285
  url: a[2],
854
1286
  start: n,
855
- end: Et.lastIndex
856
- }), n = Et.lastIndex, r = n;
1287
+ end: Yt.lastIndex
1288
+ }), n = Yt.lastIndex, r = n;
857
1289
  continue;
858
1290
  }
859
1291
  }
860
- Dt.lastIndex = n;
861
- let a = Dt.exec(e);
1292
+ K.lastIndex = n;
1293
+ let a = K.exec(e);
862
1294
  if (a) {
863
1295
  i(n), t.push({
864
1296
  type: "bold",
865
1297
  value: a[1],
866
1298
  start: n,
867
- end: Dt.lastIndex
868
- }), n = Dt.lastIndex, r = n;
1299
+ end: K.lastIndex
1300
+ }), n = K.lastIndex, r = n;
869
1301
  continue;
870
1302
  }
871
- Ot.lastIndex = n;
872
- let o = Ot.exec(e);
1303
+ Xt.lastIndex = n;
1304
+ let o = Xt.exec(e);
873
1305
  if (o) {
874
1306
  i(n), t.push({
875
1307
  type: "italic",
876
1308
  value: o[1],
877
1309
  start: n,
878
- end: Ot.lastIndex
879
- }), n = Ot.lastIndex, r = n;
1310
+ end: Xt.lastIndex
1311
+ }), n = Xt.lastIndex, r = n;
880
1312
  continue;
881
1313
  }
882
- kt.lastIndex = n;
883
- let s = kt.exec(e);
1314
+ Zt.lastIndex = n;
1315
+ let s = Zt.exec(e);
884
1316
  if (s) {
885
1317
  i(n), t.push({
886
1318
  type: "italic",
887
1319
  value: s[1],
888
1320
  start: n,
889
- end: kt.lastIndex
890
- }), n = kt.lastIndex, r = n;
1321
+ end: Zt.lastIndex
1322
+ }), n = Zt.lastIndex, r = n;
891
1323
  continue;
892
1324
  }
893
- jt.lastIndex = n;
894
- let c = jt.exec(e);
1325
+ $t.lastIndex = n;
1326
+ let c = $t.exec(e);
895
1327
  if (c) {
896
- let e = c[0].match(Mt), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
1328
+ let e = c[0].match(en), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
897
1329
  if (a.length > 0) {
898
1330
  i(n), t.push({
899
1331
  type: "link",
@@ -911,8 +1343,12 @@ function Nt(e) {
911
1343
  }
912
1344
  //#endregion
913
1345
  //#region src/markdown/render.tsx
914
- var Pt = /^[ \t]*[*+-][ \t]+(.*)$/;
915
- function Ft(e) {
1346
+ 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;
1347
+ function an(e) {
1348
+ let t = e.match(/\p{L}/u)?.[0];
1349
+ if (t) return rn.test(t) ? "rtl" : "ltr";
1350
+ }
1351
+ function on(e) {
916
1352
  let t = [], n = [], r = [], i = () => {
917
1353
  n.length > 0 && t.push({
918
1354
  type: "text",
@@ -925,7 +1361,7 @@ function Ft(e) {
925
1361
  }), r = [];
926
1362
  };
927
1363
  for (let t of e.split("\n")) {
928
- let e = t.match(Pt);
1364
+ let e = t.match(nn);
929
1365
  e ? (i(), r.push(e[1])) : (a(), n.push(t));
930
1366
  }
931
1367
  return i(), a(), t.some((e) => e.type === "list") ? t.flatMap((e, n) => {
@@ -937,303 +1373,367 @@ function Ft(e) {
937
1373
  }];
938
1374
  }) : null;
939
1375
  }
940
- function q(e) {
941
- return Nt(e).map((e, t) => {
1376
+ function q(e, t = {}) {
1377
+ return tn(e).map((e, n) => {
942
1378
  switch (e.type) {
943
- case "bold": return /* @__PURE__ */ G("strong", { children: q(e.value) }, t);
944
- case "italic": return /* @__PURE__ */ G("em", { children: q(e.value) }, t);
945
- case "link": return /* @__PURE__ */ G("a", {
1379
+ case "bold": return /* @__PURE__ */ W("strong", { children: q(e.value, t) }, n);
1380
+ case "italic": return /* @__PURE__ */ W("em", { children: q(e.value, t) }, n);
1381
+ case "link": return /* @__PURE__ */ W("a", {
946
1382
  href: e.url,
947
1383
  target: "_blank",
948
1384
  rel: "noopener noreferrer",
949
- children: [e.text, /* @__PURE__ */ G("span", {
1385
+ children: [e.text, /* @__PURE__ */ W("span", {
950
1386
  class: "whoo-widget-sr-only",
951
- children: " (opens in new tab)"
1387
+ lang: t.linkCueLang,
1388
+ children: [" ", t.linkCue ?? "(opens in new tab)"]
952
1389
  })]
953
- }, t);
1390
+ }, n);
954
1391
  default: return e.value;
955
1392
  }
956
1393
  });
957
1394
  }
958
- function It(e) {
959
- let t = e.replace(/\r\n?/g, "\n"), n = Ft(t);
960
- return n ? n.map((e, t) => e.type === "list" ? /* @__PURE__ */ G("ul", {
1395
+ function sn(e, t = {}) {
1396
+ let n = e.replace(/\r\n?/g, "\n"), r = on(n);
1397
+ return r ? r.map((e, n) => e.type === "list" ? /* @__PURE__ */ W("ul", {
961
1398
  class: "whoo-widget-list",
962
- children: e.items.map((e, t) => /* @__PURE__ */ G("li", { children: q(e) }, t))
963
- }, t) : /* @__PURE__ */ G("span", { children: q(e.text) }, t)) : q(t);
1399
+ dir: an(e.items.find((e) => an(e)) ?? ""),
1400
+ children: e.items.map((e, n) => /* @__PURE__ */ W("li", {
1401
+ dir: an(e),
1402
+ children: q(e, t)
1403
+ }, n))
1404
+ }, n) : /* @__PURE__ */ W("span", { children: q(e.text, t) }, n)) : q(n, t);
964
1405
  }
965
1406
  //#endregion
966
1407
  //#region src/components/MessageFeedback.tsx
967
- var Lt = [
968
- {
969
- value: "",
970
- label: "Select a reason (optional)"
971
- },
972
- {
973
- value: "factual",
974
- label: "Factual error"
975
- },
976
- {
977
- value: "incomplete",
978
- label: "Incomplete"
979
- },
980
- {
981
- value: "tone",
982
- label: "Off tone"
983
- },
984
- {
985
- value: "other",
986
- label: "Other"
987
- }
988
- ];
989
- function Rt({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraftChange: i, onSubmitDetailed: a, onCancel: o }) {
990
- let s = e.correction ?? "", c = e.category ?? "", l = U(e.status), u = U(null), d = U(null);
991
- if (H(() => {
992
- let n = l.current;
993
- if (l.current = e.status, n === e.status) return;
994
- if (e.status === "expanded") {
995
- u.current?.focus();
1408
+ function cn(e) {
1409
+ return [
1410
+ {
1411
+ value: "",
1412
+ label: e.selectReason
1413
+ },
1414
+ {
1415
+ value: "factual",
1416
+ label: e.categoryFactual
1417
+ },
1418
+ {
1419
+ value: "incomplete",
1420
+ label: e.categoryIncomplete
1421
+ },
1422
+ {
1423
+ value: "tone",
1424
+ label: e.categoryTone
1425
+ },
1426
+ {
1427
+ value: "other",
1428
+ label: e.categoryOther
1429
+ }
1430
+ ];
1431
+ }
1432
+ function ln({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraftChange: a, onSubmitDetailed: o, onCancel: s, text: c = e, contentLanguage: l }) {
1433
+ let u = t.correction ?? "", d = t.category ?? "", f = H(t.status), p = H(null), m = H(null);
1434
+ if (tt(() => {
1435
+ let e = f.current;
1436
+ if (f.current = t.status, e === t.status) return;
1437
+ if (t.status === "expanded") {
1438
+ p.current?.focus();
996
1439
  return;
997
1440
  }
998
- if (n === "expanded" && e.status === "idle") {
999
- d.current?.focus();
1441
+ if (e === "expanded" && t.status === "idle") {
1442
+ m.current?.focus();
1000
1443
  return;
1001
1444
  }
1002
- let r = t?.current;
1445
+ let r = n?.current;
1003
1446
  if (!r) return;
1004
- let i = r.getRootNode();
1005
- r.contains(i.activeElement) || r.focus();
1006
- }, [e.status, t]), e.status === "expanded") return /* @__PURE__ */ G("div", {
1447
+ let i = r.getRootNode(), a = r.ownerDocument, o = i.activeElement;
1448
+ (o === null ? a.activeElement === null || a.activeElement === a.body : o === a.body) && r.focus();
1449
+ }, [t.status, n]), t.status === "expanded") return /* @__PURE__ */ W("div", {
1007
1450
  class: "whoo-widget-feedback-form",
1008
1451
  children: [
1009
- /* @__PURE__ */ G("label", { children: [/* @__PURE__ */ G("span", {
1452
+ /* @__PURE__ */ W("label", { children: [/* @__PURE__ */ W("span", {
1010
1453
  class: "whoo-widget-sr-only",
1011
- children: "Additional feedback"
1012
- }), /* @__PURE__ */ G("textarea", {
1013
- ref: u,
1454
+ children: c.additionalFeedback
1455
+ }), /* @__PURE__ */ W("textarea", {
1456
+ ref: p,
1014
1457
  class: "whoo-widget-feedback-textarea",
1015
- value: s,
1016
- onInput: (e) => i(e.target.value, c),
1017
- placeholder: "What was wrong? (optional)"
1458
+ lang: l,
1459
+ value: u,
1460
+ onInput: (e) => a(e.target.value, d),
1461
+ placeholder: c.feedbackPlaceholder
1018
1462
  })] }),
1019
- /* @__PURE__ */ G("select", {
1463
+ /* @__PURE__ */ W("select", {
1020
1464
  class: "whoo-widget-feedback-select",
1021
- "aria-label": "Feedback category",
1022
- value: c,
1023
- onChange: (e) => i(s, e.target.value),
1024
- children: Lt.map((e) => /* @__PURE__ */ G("option", {
1465
+ "aria-label": c.feedbackCategory,
1466
+ value: d,
1467
+ onChange: (e) => a(u, e.target.value),
1468
+ children: cn(c).map((e) => /* @__PURE__ */ W("option", {
1025
1469
  value: e.value,
1026
1470
  children: e.label
1027
1471
  }, e.value))
1028
1472
  }),
1029
- /* @__PURE__ */ G("div", {
1473
+ /* @__PURE__ */ W("div", {
1030
1474
  class: "whoo-widget-feedback-form-buttons",
1031
- children: [/* @__PURE__ */ G("button", {
1475
+ children: [/* @__PURE__ */ W("button", {
1032
1476
  type: "button",
1033
1477
  class: "whoo-widget-feedback-submit",
1034
- onClick: () => a(s, c),
1035
- children: "Submit"
1036
- }), /* @__PURE__ */ G("button", {
1478
+ onClick: () => o(u, d),
1479
+ children: c.submit
1480
+ }), /* @__PURE__ */ W("button", {
1037
1481
  type: "button",
1038
1482
  class: "whoo-widget-feedback-cancel",
1039
- onClick: o,
1040
- children: "Cancel"
1483
+ onClick: s,
1484
+ children: c.cancel
1041
1485
  })]
1042
1486
  })
1043
1487
  ]
1044
1488
  });
1045
- let f = e.status === "submitting", p = e.status === "submitted";
1046
- return /* @__PURE__ */ G("div", {
1489
+ let h = t.status === "submitting", g = t.status === "submitted";
1490
+ return /* @__PURE__ */ W("div", {
1047
1491
  class: "whoo-widget-feedback",
1048
- children: [p ? null : /* @__PURE__ */ G("div", {
1492
+ children: [g ? null : /* @__PURE__ */ W("div", {
1049
1493
  class: "whoo-widget-feedback-buttons",
1050
- children: [/* @__PURE__ */ G("button", {
1494
+ children: [/* @__PURE__ */ W("button", {
1051
1495
  type: "button",
1052
- "aria-label": "Good response",
1053
- disabled: f,
1054
- onClick: n,
1055
- children: /* @__PURE__ */ G(ut, {})
1056
- }), /* @__PURE__ */ G("button", {
1057
- ref: d,
1496
+ "aria-label": c.goodResponse,
1497
+ "aria-disabled": h,
1498
+ onClick: () => {
1499
+ h || r();
1500
+ },
1501
+ children: /* @__PURE__ */ W(_t, {})
1502
+ }), /* @__PURE__ */ W("button", {
1503
+ ref: m,
1058
1504
  type: "button",
1059
- "aria-label": "Bad response",
1060
- disabled: f,
1061
- onClick: r,
1062
- children: /* @__PURE__ */ G(dt, {})
1505
+ "aria-label": c.badResponse,
1506
+ "aria-disabled": h,
1507
+ onClick: () => {
1508
+ h || i();
1509
+ },
1510
+ children: /* @__PURE__ */ W(vt, {})
1063
1511
  })]
1064
- }), /* @__PURE__ */ G("div", {
1512
+ }), /* @__PURE__ */ W("div", {
1065
1513
  role: "status",
1066
- class: p ? "whoo-widget-feedback-submitted" : e.status === "error" ? "whoo-widget-feedback-error" : void 0,
1067
- children: p ? "Thanks for the feedback" : e.status === "error" ? "Couldn't send feedback" : null
1514
+ class: g ? "whoo-widget-feedback-submitted" : t.status === "error" ? "whoo-widget-feedback-error" : void 0,
1515
+ children: g ? c.feedbackThanks : t.status === "error" ? c.feedbackFailed : null
1068
1516
  })]
1069
1517
  });
1070
1518
  }
1071
1519
  //#endregion
1072
1520
  //#region src/components/MessageList.tsx
1073
- function zt({ isSlowResponse: e }) {
1074
- return /* @__PURE__ */ G("div", {
1521
+ function un({ isSlowResponse: e, text: t }) {
1522
+ return /* @__PURE__ */ W("div", {
1075
1523
  class: "whoo-widget-pending",
1076
1524
  role: "status",
1077
- children: [/* @__PURE__ */ G("span", {
1525
+ children: [/* @__PURE__ */ W("span", {
1078
1526
  class: "whoo-widget-typing",
1079
1527
  "aria-hidden": "true",
1080
1528
  children: [
1081
- /* @__PURE__ */ G("span", {}),
1082
- /* @__PURE__ */ G("span", {}),
1083
- /* @__PURE__ */ G("span", {})
1529
+ /* @__PURE__ */ W("span", {}),
1530
+ /* @__PURE__ */ W("span", {}),
1531
+ /* @__PURE__ */ W("span", {})
1084
1532
  ]
1085
- }), e ? /* @__PURE__ */ G("span", {
1533
+ }), e ? /* @__PURE__ */ W("span", {
1086
1534
  class: "whoo-widget-pending-text",
1087
- children: "Looking that up for you…"
1535
+ children: t.lookingItUp
1088
1536
  }) : null]
1089
1537
  });
1090
1538
  }
1091
- function Bt({ url: e, alt: t }) {
1092
- let [n, r] = qe(!1);
1093
- return n ? null : /* @__PURE__ */ G("img", {
1539
+ function dn({ url: e, alt: t, lang: n }) {
1540
+ let [r, i] = V(!1);
1541
+ return r ? null : /* @__PURE__ */ W("img", {
1094
1542
  class: "whoo-widget-empty-state-image",
1095
1543
  src: e,
1096
1544
  alt: t,
1545
+ lang: n,
1097
1546
  referrerpolicy: "no-referrer",
1098
- onError: () => r(!0)
1547
+ onError: () => i(!0)
1099
1548
  });
1100
1549
  }
1101
- function Vt({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u }) {
1102
- let d = U(null), f = e.id;
1103
- return /* @__PURE__ */ G("div", {
1104
- ref: d,
1550
+ function fn({ 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 }) {
1551
+ let m = H(null), h = e.id;
1552
+ return /* @__PURE__ */ W("div", {
1553
+ ref: m,
1105
1554
  tabIndex: -1,
1106
1555
  class: `whoo-widget-message whoo-widget-message--${e.role}`,
1107
1556
  children: [
1108
- /* @__PURE__ */ G("span", {
1557
+ /* @__PURE__ */ W("span", {
1109
1558
  class: "whoo-widget-sr-only",
1110
- children: [t, ": "]
1559
+ children: [
1560
+ e.role === "assistant" ? /* @__PURE__ */ W("span", {
1561
+ lang: f,
1562
+ children: t
1563
+ }) : t,
1564
+ ":",
1565
+ " "
1566
+ ]
1567
+ }),
1568
+ i ? /* @__PURE__ */ W(un, {
1569
+ isSlowResponse: a,
1570
+ text: d
1571
+ }) : /* @__PURE__ */ W("div", {
1572
+ class: "whoo-widget-message-text",
1573
+ dir: "auto",
1574
+ lang: f,
1575
+ children: sn(e.content, {
1576
+ linkCue: d.opensInNewTab,
1577
+ linkCueLang: p
1578
+ })
1111
1579
  }),
1112
- i ? /* @__PURE__ */ G(zt, { isSlowResponse: a }) : It(e.content),
1113
- r && e.role === "assistant" && f ? /* @__PURE__ */ G(Rt, {
1580
+ r && e.role === "assistant" && h ? /* @__PURE__ */ W(ln, {
1114
1581
  state: n,
1115
- containerRef: d,
1116
- onThumbsUp: () => o(f),
1117
- onThumbsDown: () => s(f),
1118
- onDraftChange: (e, t) => c(f, e, t),
1119
- onSubmitDetailed: (e, t) => l(f, e, t),
1120
- onCancel: () => u(f)
1582
+ containerRef: m,
1583
+ onThumbsUp: () => o(h),
1584
+ onThumbsDown: () => s(h),
1585
+ onDraftChange: (e, t) => c(h, e, t),
1586
+ onSubmitDetailed: (e, t) => l(h, e, t),
1587
+ onCancel: () => u(h),
1588
+ text: d,
1589
+ contentLanguage: f
1121
1590
  }) : null
1122
1591
  ]
1123
1592
  });
1124
1593
  }
1125
- function Ht({ messages: e, messageFeedback: t, announcement: n, emptyStateImage: r, agentName: i = s, showFeedback: a = !1, isStreaming: o = !1, isSlowResponse: c = !1, onThumbsUp: l, onThumbsDown: u, onDraftChange: d = () => {}, onSubmitDetailed: f, onCancelFeedback: p }) {
1126
- let m = U(null);
1127
- return H(() => {
1128
- let e = m.current;
1594
+ function pn({ messages: t, messageFeedback: n, announcement: r, emptyStateImage: i, agentName: a = l, showFeedback: o = !1, isStreaming: s = !1, isSlowResponse: c = !1, onThumbsUp: u, onThumbsDown: d, onDraftChange: f = () => {}, onSubmitDetailed: p, onCancelFeedback: m, text: h = e, contentLanguage: g, languageTag: _, announcementIsContent: v = !1 }) {
1595
+ let y = H(null);
1596
+ return et(() => {
1597
+ let e = y.current;
1129
1598
  e && (e.scrollTop = e.scrollHeight);
1130
- }, [e, c]), /* @__PURE__ */ G(I, { children: [/* @__PURE__ */ G("section", {
1599
+ }, [t, c]), /* @__PURE__ */ W(I, { children: [/* @__PURE__ */ W("section", {
1131
1600
  class: "whoo-widget-message-list",
1132
- ref: m,
1133
- "aria-label": "Conversation",
1601
+ ref: y,
1602
+ "aria-label": h.conversation,
1134
1603
  tabIndex: 0,
1135
- children: [r ? /* @__PURE__ */ G(Bt, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ G(Vt, {
1136
- message: n,
1137
- speaker: n.role === "user" ? "You" : i,
1138
- showFeedback: a,
1139
- feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
1140
- pending: o && r === e.length - 1 && n.role === "assistant" && n.content === "",
1604
+ children: [i ? /* @__PURE__ */ W(dn, {
1605
+ ...i,
1606
+ lang: g
1607
+ }) : null, t.map((e, r) => /* @__PURE__ */ W(fn, {
1608
+ message: e,
1609
+ speaker: e.role === "user" ? h.you : a,
1610
+ showFeedback: o,
1611
+ feedbackState: e.id ? n[e.id] ?? { status: "idle" } : { status: "idle" },
1612
+ pending: s && r === t.length - 1 && e.role === "assistant" && e.content === "",
1141
1613
  isSlowResponse: c,
1142
- onThumbsUp: l,
1143
- onThumbsDown: u,
1144
- onDraftChange: d,
1145
- onSubmitDetailed: f,
1146
- onCancelFeedback: p
1147
- }, n.id ?? r))]
1148
- }), /* @__PURE__ */ G("div", {
1614
+ onThumbsUp: u,
1615
+ onThumbsDown: d,
1616
+ onDraftChange: f,
1617
+ onSubmitDetailed: p,
1618
+ onCancelFeedback: m,
1619
+ text: h,
1620
+ contentLanguage: g,
1621
+ languageTag: _
1622
+ }, e.id ?? r))]
1623
+ }), /* @__PURE__ */ W("div", {
1149
1624
  class: "whoo-widget-sr-only",
1150
1625
  "aria-live": "polite",
1151
1626
  "aria-atomic": "true",
1152
- children: n ?? ""
1627
+ lang: v ? g : _,
1628
+ children: r ?? ""
1153
1629
  })] });
1154
1630
  }
1155
1631
  //#endregion
1156
1632
  //#region src/components/Panel.tsx
1157
- var Ut = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
1158
- function Wt(e) {
1159
- return Array.from(e.querySelectorAll(Ut)).filter((e) => {
1633
+ var mn = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
1634
+ function hn(e) {
1635
+ return Array.from(e.querySelectorAll(mn)).filter((e) => {
1160
1636
  let t = getComputedStyle(e);
1161
1637
  return t.display !== "none" && t.visibility !== "hidden";
1162
1638
  });
1163
1639
  }
1164
- function Gt({ state: e, controller: t, greeting: n }) {
1165
- let r = U(null), i = U(null);
1166
- H(() => {
1640
+ function gn({ state: e, controller: t, greeting: n }) {
1641
+ let r = H(null), i = H(null);
1642
+ tt(() => {
1167
1643
  i.current?.focus();
1168
- }, []), H(() => {
1169
- let e = r.current, t = e ? vt(e) : () => {}, n = Ct();
1644
+ }, []), tt(() => {
1645
+ let e = r.current, n = e ? Rt(e) : () => {}, i = e ? Gt(e) : () => {}, a = () => {
1646
+ e && !e.open && t.close();
1647
+ };
1648
+ e?.addEventListener("close", a);
1649
+ let o = Wt();
1170
1650
  return () => {
1171
- t(), n();
1651
+ n(), i(), e?.removeEventListener("close", a), o();
1172
1652
  };
1173
1653
  }, []);
1174
1654
  let a = (e) => {
1175
- if (e.key === "Escape") {
1176
- t.close();
1655
+ if (e.key === "Escape" && !Kt(e)) {
1656
+ e.preventDefault(), t.close();
1177
1657
  return;
1178
1658
  }
1179
1659
  if (e.key !== "Tab") return;
1180
1660
  let n = r.current;
1181
1661
  if (!n) return;
1182
- let i = Wt(n);
1662
+ let i = hn(n);
1183
1663
  if (i.length === 0) return;
1184
- let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
1185
- if (!n.contains(s)) {
1186
- e.preventDefault(), a.focus();
1187
- return;
1188
- }
1189
- e.shiftKey && s === a ? (e.preventDefault(), o.focus()) : !e.shiftKey && s === o && (e.preventDefault(), a.focus());
1664
+ let a = n.getRootNode().activeElement;
1665
+ e.preventDefault();
1666
+ let o = i.length - 1, s, c = a ? i.indexOf(a) : -1;
1667
+ if (c !== -1) s = (c + (e.shiftKey ? -1 : 1) + i.length) % i.length;
1668
+ else if (a && a !== n && n.contains(a)) {
1669
+ let t = i.findIndex((e) => a.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING);
1670
+ s = e.shiftKey ? t <= 0 ? o : t - 1 : t === -1 ? 0 : t;
1671
+ } else s = e.shiftKey ? o : 0;
1672
+ i[s].focus();
1190
1673
  }, o = () => {
1191
1674
  let n = e.draft.trim();
1192
1675
  n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
1193
- }, s = c(t.config.name) || e.agentName || "Aiden", l = c(t.config.title) || `Chat with ${s}`, u = e.messages.length === 0 && n ? [{
1676
+ }, s = u(t.config.name) || e.agentName || "Aiden", c = u(t.config.title), { before: l, after: d, hasName: f } = Pt(t.text.chatWith), p = e.messages.length === 0 && n ? [{
1194
1677
  role: "assistant",
1195
1678
  content: n,
1196
1679
  id: null
1197
- }] : e.messages, d = t.emptyStateImageUrl, f = e.messages.length === 0 && d ? {
1198
- url: d,
1680
+ }] : e.messages, m = t.emptyStateImageUrl, h = e.messages.length === 0 && m ? {
1681
+ url: m,
1199
1682
  alt: t.emptyStateImageAlt
1200
1683
  } : void 0;
1201
- return /* @__PURE__ */ G("div", {
1684
+ return /* @__PURE__ */ W("dialog", {
1685
+ open: !0,
1202
1686
  class: "whoo-widget-panel",
1203
- role: "dialog",
1204
1687
  "aria-modal": "true",
1205
- "aria-label": l,
1688
+ "aria-labelledby": "whoo-widget-title",
1206
1689
  ref: r,
1207
1690
  onKeyDown: a,
1691
+ onCancel: (e) => {
1692
+ e.preventDefault(), t.close();
1693
+ },
1208
1694
  children: [
1209
- /* @__PURE__ */ G("div", {
1695
+ /* @__PURE__ */ W("div", {
1210
1696
  class: "whoo-widget-header",
1211
- children: [/* @__PURE__ */ G("h2", {
1697
+ children: [c ? /* @__PURE__ */ W("h2", {
1698
+ id: "whoo-widget-title",
1699
+ class: "whoo-widget-header-title",
1700
+ lang: t.contentLanguage,
1701
+ dir: "auto",
1702
+ children: c
1703
+ }) : /* @__PURE__ */ W("h2", {
1704
+ id: "whoo-widget-title",
1212
1705
  class: "whoo-widget-header-title",
1213
- children: l
1214
- }), /* @__PURE__ */ G("div", {
1706
+ children: [
1707
+ l,
1708
+ f ? /* @__PURE__ */ W("bdi", {
1709
+ lang: t.contentLanguage,
1710
+ children: s
1711
+ }) : null,
1712
+ d
1713
+ ]
1714
+ }), /* @__PURE__ */ W("div", {
1215
1715
  class: "whoo-widget-header-actions",
1216
- children: [e.messages.length > 0 && /* @__PURE__ */ G("button", {
1716
+ children: [e.messages.length > 0 && /* @__PURE__ */ W("button", {
1217
1717
  type: "button",
1218
1718
  class: "whoo-widget-header-reset",
1219
1719
  onClick: () => {
1220
1720
  t.resetConversation(), i.current?.focus();
1221
1721
  },
1222
- children: "New conversation"
1223
- }), /* @__PURE__ */ G("button", {
1722
+ children: t.text.newConversation
1723
+ }), /* @__PURE__ */ W("button", {
1224
1724
  type: "button",
1225
1725
  class: "whoo-widget-header-close",
1226
- "aria-label": "Close chat",
1726
+ "aria-label": t.text.closeChat,
1227
1727
  onClick: () => t.close(),
1228
- children: /* @__PURE__ */ G(ct, {})
1728
+ children: /* @__PURE__ */ W(ht, {})
1229
1729
  })]
1230
1730
  })]
1231
1731
  }),
1232
- /* @__PURE__ */ G(Ht, {
1233
- messages: u,
1732
+ /* @__PURE__ */ W(pn, {
1733
+ messages: p,
1234
1734
  messageFeedback: e.messageFeedback,
1235
1735
  announcement: e.announcement,
1236
- emptyStateImage: f,
1736
+ emptyStateImage: h,
1237
1737
  agentName: s,
1238
1738
  showFeedback: t.showFeedback,
1239
1739
  isStreaming: e.isStreaming,
@@ -1242,34 +1742,41 @@ function Gt({ state: e, controller: t, greeting: n }) {
1242
1742
  onThumbsDown: (e) => t.expandFeedback(e),
1243
1743
  onDraftChange: (e, n, r) => t.setFeedbackDraft(e, n, r),
1244
1744
  onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
1245
- onCancelFeedback: (e) => t.cancelFeedback(e)
1745
+ onCancelFeedback: (e) => t.cancelFeedback(e),
1746
+ text: t.text,
1747
+ contentLanguage: t.contentLanguage,
1748
+ languageTag: t.languageTag,
1749
+ announcementIsContent: e.announcementIsContent
1246
1750
  }),
1247
- e.runtimeError && /* @__PURE__ */ G(Tt, { message: e.runtimeError }),
1248
- /* @__PURE__ */ G(wt, {
1751
+ e.runtimeError && /* @__PURE__ */ W(Jt, { message: e.runtimeError }),
1752
+ /* @__PURE__ */ W(qt, {
1249
1753
  value: e.draft,
1250
1754
  onChange: (e) => t.setDraft(e),
1251
1755
  onSend: o,
1252
1756
  disabled: e.isStreaming,
1253
- inputRef: i
1757
+ inputRef: i,
1758
+ text: t.text,
1759
+ contentLanguage: t.contentLanguage
1254
1760
  })
1255
1761
  ]
1256
1762
  });
1257
1763
  }
1258
1764
  //#endregion
1259
1765
  //#region src/components/App.tsx
1260
- function Kt({ controller: e }) {
1261
- let [t, n] = qe(e.getState()), r = U(null), i = U(t.isOpen);
1262
- return H(() => (n(e.getState()), e.subscribe(n)), [e]), H(() => {
1766
+ function _n({ controller: e }) {
1767
+ let [t, n] = V(e.getState()), r = H(null), i = H(t.isOpen);
1768
+ return et(() => (n(e.getState()), e.subscribe(n)), [e]), tt(() => {
1263
1769
  i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
1264
- }, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ G(I, { children: [/* @__PURE__ */ G(mt, {
1770
+ }, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ W(I, { children: [/* @__PURE__ */ W(xt, {
1265
1771
  isOpen: t.isOpen,
1266
1772
  onClick: () => t.isOpen ? e.close() : e.open(),
1267
1773
  iconUrl: e.launcher.iconUrl,
1268
1774
  icon: e.launcher.icon,
1269
1775
  openIconUrl: e.launcher.openIconUrl,
1270
1776
  openIcon: e.launcher.openIcon,
1271
- buttonRef: r
1272
- }), t.isOpen && /* @__PURE__ */ G(Gt, {
1777
+ buttonRef: r,
1778
+ text: e.text
1779
+ }), t.isOpen && /* @__PURE__ */ W(gn, {
1273
1780
  state: t,
1274
1781
  controller: e,
1275
1782
  greeting: e.config.greeting
@@ -1277,44 +1784,44 @@ function Kt({ controller: e }) {
1277
1784
  }
1278
1785
  //#endregion
1279
1786
  //#region src/api/client.ts
1280
- var qt = class extends Error {
1787
+ var vn = class extends Error {
1281
1788
  status;
1282
1789
  constructor(e, t) {
1283
1790
  super(e), this.name = "WidgetApiError", this.status = t;
1284
1791
  }
1285
1792
  };
1286
- function Jt(e) {
1793
+ function yn(e) {
1287
1794
  if (typeof e != "string") return null;
1288
1795
  let t = e.trim();
1289
1796
  return t === "" ? null : t;
1290
1797
  }
1291
- async function Yt(e, t) {
1798
+ async function bn(e, t) {
1292
1799
  let n = await fetch(`${e}/api/v1/widget/session`, {
1293
1800
  method: "POST",
1294
1801
  headers: { "Content-Type": "application/json" },
1295
1802
  body: JSON.stringify({ publishable_key: t })
1296
1803
  });
1297
- if (!n.ok) throw new qt(`Failed to create widget session (${n.status})`, n.status);
1804
+ if (!n.ok) throw new vn(`Failed to create widget session (${n.status})`, n.status);
1298
1805
  let r = await n.json();
1299
1806
  return {
1300
1807
  token: r.token,
1301
- ...Xt(r)
1808
+ ...xn(r)
1302
1809
  };
1303
1810
  }
1304
- function Xt(e) {
1811
+ function xn(e) {
1305
1812
  return {
1306
- primaryColor: Jt(e.primary_color),
1307
- name: Jt(e.name),
1308
- accentColor: Jt(e.accent_color),
1309
- inkColor: Jt(e.ink_color)
1813
+ primaryColor: yn(e.primary_color),
1814
+ name: yn(e.name),
1815
+ accentColor: yn(e.accent_color),
1816
+ inkColor: yn(e.ink_color)
1310
1817
  };
1311
1818
  }
1312
- async function Zt(e, t) {
1819
+ async function Sn(e, t) {
1313
1820
  let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
1314
- if (!n.ok) throw new qt(`Failed to load widget branding (${n.status})`, n.status);
1315
- return Xt(await n.json());
1821
+ if (!n.ok) throw new vn(`Failed to load widget branding (${n.status})`, n.status);
1822
+ return xn(await n.json());
1316
1823
  }
1317
- async function Qt(e, t, n) {
1824
+ async function Cn(e, t, n) {
1318
1825
  let r = await fetch(`${e}/api/v1/widget/feedback`, {
1319
1826
  method: "POST",
1320
1827
  headers: {
@@ -1328,11 +1835,11 @@ async function Qt(e, t, n) {
1328
1835
  category: n.category ?? null
1329
1836
  })
1330
1837
  });
1331
- if (!r.ok) throw new qt(`Feedback submission failed (${r.status})`, r.status);
1838
+ if (!r.ok) throw new vn(`Feedback submission failed (${r.status})`, r.status);
1332
1839
  }
1333
1840
  //#endregion
1334
1841
  //#region src/api/sse.ts
1335
- async function* $t(e, t, n, r, i) {
1842
+ async function* wn(e, t, n, r, i) {
1336
1843
  let a = await fetch(`${e}/api/v1/widget/chat`, {
1337
1844
  method: "POST",
1338
1845
  headers: {
@@ -1345,7 +1852,7 @@ async function* $t(e, t, n, r, i) {
1345
1852
  }),
1346
1853
  signal: i
1347
1854
  });
1348
- if (!a.ok || !a.body) throw new qt(`Chat request failed (${a.status})`, a.status);
1855
+ if (!a.ok || !a.body) throw new vn(`Chat request failed (${a.status})`, a.status);
1349
1856
  let o = a.body.getReader(), s = new TextDecoder(), c = "";
1350
1857
  for (;;) {
1351
1858
  let { done: e, value: t } = await o.read();
@@ -1356,11 +1863,12 @@ async function* $t(e, t, n, r, i) {
1356
1863
  let e = c.slice(0, n);
1357
1864
  c = c.slice(n + 2);
1358
1865
  let t = e.split("\n").find((e) => e.startsWith("data: "));
1359
- t && (yield en(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1866
+ if (i?.aborted) return;
1867
+ t && (yield Tn(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1360
1868
  }
1361
1869
  }
1362
1870
  }
1363
- function en(e) {
1871
+ function Tn(e) {
1364
1872
  return typeof e.error == "string" ? {
1365
1873
  type: "error",
1366
1874
  error: e.error,
@@ -1383,11 +1891,11 @@ function en(e) {
1383
1891
  }
1384
1892
  //#endregion
1385
1893
  //#region src/markdown/plainText.ts
1386
- function tn(e) {
1387
- return Nt(e.replace(/\r\n?/g, "\n")).map((e) => {
1894
+ function En(e) {
1895
+ return tn(e.replace(/\r\n?/g, "\n")).map((e) => {
1388
1896
  switch (e.type) {
1389
1897
  case "bold":
1390
- case "italic": return tn(e.value);
1898
+ case "italic": return En(e.value);
1391
1899
  case "link": return e.text;
1392
1900
  default: return e.value;
1393
1901
  }
@@ -1395,16 +1903,16 @@ function tn(e) {
1395
1903
  }
1396
1904
  //#endregion
1397
1905
  //#region src/markdown/reveal.ts
1398
- var nn = 40, rn = 120;
1399
- function an(e) {
1906
+ var Dn = 40, On = 120;
1907
+ function kn(e) {
1400
1908
  let t = [];
1401
- for (let n of Nt(e)) if (n.type === "text") {
1909
+ for (let n of tn(e)) if (n.type === "text") {
1402
1910
  let e = n.value.split(/(\s+)/), r = n.start;
1403
1911
  for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
1404
1912
  } else t.push(n.end);
1405
1913
  return t;
1406
1914
  }
1407
- function on(e) {
1915
+ function An(e) {
1408
1916
  let t = null;
1409
1917
  return e?.addEventListener("abort", () => {
1410
1918
  t?.();
@@ -1419,51 +1927,66 @@ function on(e) {
1419
1927
  });
1420
1928
  };
1421
1929
  }
1422
- async function sn(e, t, n) {
1423
- let r = n?.wordIntervalMs ?? nn, i = n?.tokenIntervalMs ?? rn, a = n?.signal, o = Nt(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = on(a), l = "";
1424
- for (let n of an(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1930
+ async function jn(e, t, n) {
1931
+ let r = n?.wordIntervalMs ?? Dn, i = n?.tokenIntervalMs ?? On, a = n?.signal, o = tn(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = An(a), l = "";
1932
+ for (let n of kn(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1425
1933
  l !== e && t(e);
1426
1934
  }
1427
1935
  //#endregion
1428
1936
  //#region src/sessionToken.ts
1429
- function cn(e, t = Date.now()) {
1430
- let n = e.split(".");
1431
- if (n.length !== 3 || n.some((e) => e === "")) return !1;
1432
- let r = n[1];
1937
+ function Mn(e) {
1938
+ let t = e.split(".");
1939
+ if (t.length !== 3 || t.some((e) => e === "")) return null;
1940
+ let n = t[1];
1433
1941
  try {
1434
- let e = r.replace(/-/g, "+").replace(/_/g, "/"), n = JSON.parse(atob(e.padEnd(Math.ceil(e.length / 4) * 4, "=")))?.exp;
1435
- return typeof n == "number" && Number.isFinite(n) && n * 1e3 <= t;
1942
+ let e = n.replace(/-/g, "+").replace(/_/g, "/"), t = JSON.parse(atob(e.padEnd(Math.ceil(e.length / 4) * 4, "="))), r = (e) => typeof e == "number" && Number.isFinite(e) ? e : null, { exp: i, iat: a } = t ?? {};
1943
+ return {
1944
+ exp: r(i),
1945
+ iat: r(a)
1946
+ };
1436
1947
  } catch {
1437
- return !1;
1948
+ return null;
1438
1949
  }
1439
1950
  }
1951
+ function Nn(e) {
1952
+ let t = Mn(e)?.exp;
1953
+ return typeof t == "number" ? t * 1e3 : null;
1954
+ }
1955
+ function Pn(e, t = Date.now()) {
1956
+ let n = Nn(e);
1957
+ return n !== null && n <= t;
1958
+ }
1959
+ function Fn(e, t = Date.now()) {
1960
+ let n = Mn(e);
1961
+ return n?.exp == null ? null : n.iat != null && n.exp > n.iat ? t + (n.exp - n.iat) * 1e3 : n.exp * 1e3;
1962
+ }
1440
1963
  //#endregion
1441
1964
  //#region src/storage.ts
1442
- function ln(e) {
1965
+ function In(e) {
1443
1966
  return `whoo-aiden-widget:conversation:${e}`;
1444
1967
  }
1445
- function un(e) {
1968
+ function Ln(e) {
1446
1969
  try {
1447
- return window.sessionStorage.getItem(ln(e));
1970
+ return window.sessionStorage.getItem(In(e));
1448
1971
  } catch {
1449
1972
  return null;
1450
1973
  }
1451
1974
  }
1452
- function dn(e, t) {
1975
+ function Rn(e, t) {
1453
1976
  try {
1454
- window.sessionStorage.setItem(ln(e), t);
1977
+ window.sessionStorage.setItem(In(e), t);
1455
1978
  } catch {}
1456
1979
  }
1457
- function fn(e) {
1980
+ function zn(e) {
1458
1981
  try {
1459
- window.sessionStorage.removeItem(ln(e));
1982
+ window.sessionStorage.removeItem(In(e));
1460
1983
  } catch {}
1461
1984
  }
1462
1985
  //#endregion
1463
1986
  //#region src/theme.ts
1464
- var pn = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1465
- function mn(e) {
1466
- if (pn.test(e.trim())) return null;
1987
+ var Bn = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1988
+ function Vn(e) {
1989
+ if (Bn.test(e.trim())) return null;
1467
1990
  let t = document.createElement("div");
1468
1991
  if (t.style.color = e, t.style.color === "") return null;
1469
1992
  let n = document.createElement("div");
@@ -1483,7 +2006,7 @@ function mn(e) {
1483
2006
  };
1484
2007
  }
1485
2008
  function J(e) {
1486
- return mn(e)?.rgb ?? null;
2009
+ return Vn(e)?.rgb ?? null;
1487
2010
  }
1488
2011
  function Y([e, t, n]) {
1489
2012
  let r = (e) => {
@@ -1492,59 +2015,59 @@ function Y([e, t, n]) {
1492
2015
  };
1493
2016
  return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
1494
2017
  }
1495
- function hn(e, t) {
2018
+ function Hn(e, t) {
1496
2019
  let n = Math.max(e, t), r = Math.min(e, t);
1497
2020
  return (n + .05) / (r + .05);
1498
2021
  }
1499
- function gn(e) {
2022
+ function Un(e) {
1500
2023
  let t = J(e);
1501
2024
  if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
1502
2025
  let n = Y(t);
1503
- return hn(n, Y([
2026
+ return Hn(n, Y([
1504
2027
  0,
1505
2028
  0,
1506
2029
  0
1507
- ])) >= hn(n, Y([
2030
+ ])) >= Hn(n, Y([
1508
2031
  255,
1509
2032
  255,
1510
2033
  255
1511
2034
  ])) ? "#000000" : "#ffffff";
1512
2035
  }
1513
- function _n(e, t) {
2036
+ function Wn(e, t) {
1514
2037
  let n = J(e), r = J(t);
1515
- return !n || !r ? NaN : hn(Y(n), Y(r));
2038
+ return !n || !r ? NaN : Hn(Y(n), Y(r));
1516
2039
  }
1517
- var vn = n.primary, yn = n.panel, bn = n.assistantBubble, xn = n.headerHover, Sn = 4.5;
1518
- function Cn([e, t, n]) {
2040
+ var Gn = i.primary, Kn = i.panel, qn = i.assistantBubble, Jn = i.headerHover, Yn = 4.5;
2041
+ function Xn([e, t, n]) {
1519
2042
  return `#${[
1520
2043
  e,
1521
2044
  t,
1522
2045
  n
1523
2046
  ].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
1524
2047
  }
1525
- function wn(e, t = yn) {
2048
+ function Zn(e, t = Kn) {
1526
2049
  let n = J(e), r = J(t);
1527
- if (!n || !r) return vn;
1528
- let i = Y(r), a = (e) => hn(Y(e), i) >= Sn;
1529
- if (a(n)) return Cn(n);
2050
+ if (!n || !r) return Gn;
2051
+ let i = Y(r), a = (e) => Hn(Y(e), i) >= Yn;
2052
+ if (a(n)) return Xn(n);
1530
2053
  for (let e = .99; e > 0; e -= .01) {
1531
2054
  let t = n.map((t) => Math.round(t * e));
1532
- if (a(t)) return Cn(t);
2055
+ if (a(t)) return Xn(t);
1533
2056
  }
1534
2057
  return "#000000";
1535
2058
  }
1536
- var Tn = n.ink, En = n.link;
2059
+ var Qn = i.ink, $n = i.link;
1537
2060
  function X(e) {
1538
2061
  if (typeof e != "string" || !e) return null;
1539
- let t = mn(e);
1540
- return t ? Cn(t.rgb) : null;
2062
+ let t = Vn(e);
2063
+ return t ? Xn(t.rgb) : null;
1541
2064
  }
1542
- function Dn(e) {
2065
+ function er(e) {
1543
2066
  if (typeof e != "string" || !e) return null;
1544
- let t = mn(e);
1545
- return t ? t.translucent ? e.trim() : Cn(t.rgb) : null;
2067
+ let t = Vn(e);
2068
+ return t ? t.translucent ? e.trim() : Xn(t.rgb) : null;
1546
2069
  }
1547
- var On = [
2070
+ var tr = [
1548
2071
  {
1549
2072
  role: "onPrimary",
1550
2073
  against: ["primary"],
@@ -1596,8 +2119,8 @@ var On = [
1596
2119
  required: 3
1597
2120
  }
1598
2121
  ];
1599
- function Z({ color: e, inkColor: r, accentColor: i, overrides: a }) {
1600
- let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => Dn(o[e]), c = X(e), l = s("primary"), u = l ?? c ?? vn, d = s("primaryText"), f = d ?? wn(u, xn), p = s("onPrimary") ?? gn(u), m = X(r), h = s("ink") ?? (m ? wn(m, bn) : Tn), g = X(i), _ = s("link") ?? (g ? wn(g, bn) : En), v = (e) => s(e) ?? n[e], y = {
2122
+ function Z({ color: e, inkColor: t, accentColor: n, overrides: a }) {
2123
+ let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => er(o[e]), c = X(e), l = s("primary"), u = l ?? c ?? Gn, d = s("primaryText"), f = d ?? Zn(u, Jn), p = s("onPrimary") ?? Un(u), m = X(t), h = s("ink") ?? (m ? Zn(m, qn) : Qn), g = X(n), _ = s("link") ?? (g ? Zn(g, qn) : $n), v = (e) => s(e) ?? i[e], y = {
1601
2124
  primary: u,
1602
2125
  onPrimary: p,
1603
2126
  primaryText: f,
@@ -1614,10 +2137,10 @@ function Z({ color: e, inkColor: r, accentColor: i, overrides: a }) {
1614
2137
  errorText: v("errorText"),
1615
2138
  inputBorder: v("inputBorder"),
1616
2139
  focusRing: v("focusRing")
1617
- }, b = Object.fromEntries(t.map((e) => [e, s(e) !== null])), x = [];
1618
- for (let { role: e, against: t, required: n } of On) for (let r of t) {
2140
+ }, b = Object.fromEntries(r.map((e) => [e, s(e) !== null])), x = [];
2141
+ for (let { role: e, against: t, required: n } of tr) for (let r of t) {
1619
2142
  if (!b[e] && !b[r]) continue;
1620
- let t = _n(y[e], y[r]);
2143
+ let t = Wn(y[e], y[r]);
1621
2144
  Number.isFinite(t) && t < n && x.push({
1622
2145
  role: e,
1623
2146
  against: r,
@@ -1646,60 +2169,89 @@ function Z({ color: e, inkColor: r, accentColor: i, overrides: a }) {
1646
2169
  function Q(e) {
1647
2170
  return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
1648
2171
  }
1649
- function kn(e, t, n = vn) {
2172
+ function nr(e, t, n = Gn) {
1650
2173
  let r = t;
1651
2174
  X(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as the theme color; falling back to ${Q(n)}.`), r = n);
1652
2175
  let i = Z({ color: r });
1653
2176
  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);
1654
2177
  }
1655
- function An(e, { inkColor: t, accentColor: n }) {
2178
+ function rr(e, { inkColor: t, accentColor: n }) {
1656
2179
  let r = Z({
1657
2180
  inkColor: t,
1658
2181
  accentColor: n
1659
2182
  });
1660
2183
  e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
1661
2184
  }
1662
- function jn(e, n) {
1663
- let i = Z({ overrides: n });
1664
- for (let n of t) {
1665
- let t = i.overridden.primary && (n === "onPrimary" || n === "primaryText");
1666
- (i.overridden[n] || t) && e.style.setProperty(r[n], i.roles[n]);
2185
+ function ir(e, t) {
2186
+ let n = Z({ overrides: t });
2187
+ for (let t of r) {
2188
+ let r = n.overridden.primary && (t === "onPrimary" || t === "primaryText");
2189
+ (n.overridden[t] || r) && e.style.setProperty(a[t], n.roles[t]);
1667
2190
  }
1668
2191
  }
1669
- function Mn(e, t) {
2192
+ function ar(e, t) {
1670
2193
  e && X(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`);
1671
2194
  }
1672
- function Nn(e, n, r) {
1673
- for (let e of t) {
1674
- let t = n[e];
1675
- t && X(t) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as theme.colors.${e}; using the calculated color.`);
2195
+ function or(e, t, n) {
2196
+ for (let e of r) {
2197
+ let n = t[e];
2198
+ n && X(n) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(n)} as theme.colors.${e}; using the calculated color.`);
1676
2199
  }
1677
- let i = n.primary;
1678
- typeof i == "string" && mn(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.`), Pn({
2200
+ let i = t.primary;
2201
+ typeof i == "string" && Vn(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.`), sr({
1679
2202
  color: e.color,
1680
2203
  inkColor: e.inkColor,
1681
2204
  accentColor: e.accentColor,
1682
- overrides: n
1683
- }, r);
2205
+ overrides: t
2206
+ }, n);
1684
2207
  }
1685
- function Pn(e, t) {
2208
+ function sr(e, t) {
1686
2209
  for (let n of Z(e).contrastWarnings) {
1687
2210
  let { role: e, against: r, value: i, ratio: a, required: o, overridden: s } = n, c = `${e}|${r}|${i}`;
1688
2211
  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.`));
1689
2212
  }
1690
2213
  }
1691
- function Fn(e, t, n = /* @__PURE__ */ new Set()) {
1692
- kn(e, t.color ?? vn), Mn(t.inkColor, "ink color"), Mn(t.accentColor, "accent color"), An(e, {
2214
+ function cr(e, t, n = /* @__PURE__ */ new Set()) {
2215
+ nr(e, t.color ?? Gn), ar(t.inkColor, "ink color"), ar(t.accentColor, "accent color"), rr(e, {
1693
2216
  inkColor: t.inkColor,
1694
2217
  accentColor: t.accentColor
1695
2218
  });
1696
- let r = T(t.theme);
1697
- Nn(t, r.colors, n), jn(e, r.colors), r.fontFamily && (e.style.setProperty("--whoo-widget-font", r.fontFamily), e.setAttribute("data-whoo-custom-font", ""));
2219
+ let r = te(t.theme);
2220
+ or(t, r.colors, n), ir(e, r.colors), r.fontFamily && e.style.setProperty("--whoo-widget-font", r.fontFamily);
1698
2221
  }
1699
2222
  //#endregion
1700
2223
  //#region src/controller.ts
1701
- var In = 8e3, Ln = 3e3;
1702
- function Rn(e, t) {
2224
+ var lr = 8e3, ur = 3e3, dr = 15e3, fr = class extends Error {
2225
+ name = "SessionUnavailableError";
2226
+ };
2227
+ function pr(e, t) {
2228
+ return t ? new Promise((n, r) => {
2229
+ let i = () => r(new DOMException("Aborted", "AbortError"));
2230
+ if (t.aborted) return i();
2231
+ t.addEventListener("abort", i, { once: !0 }), e.then((e) => {
2232
+ t.removeEventListener("abort", i), n(e);
2233
+ }, (e) => {
2234
+ t.removeEventListener("abort", i), r(e);
2235
+ });
2236
+ }) : e;
2237
+ }
2238
+ function mr(e, t) {
2239
+ return e === "refused" ? new gr(t) : new fr();
2240
+ }
2241
+ function hr(e) {
2242
+ let t = e?.status;
2243
+ return t === 401 || t === 403 || t === 404;
2244
+ }
2245
+ var gr = class extends Error {
2246
+ name = "SessionExpiredError";
2247
+ constructor(e) {
2248
+ super(e instanceof Error ? e.message : "The session has expired.");
2249
+ }
2250
+ };
2251
+ function _r(e) {
2252
+ return e?.status === 401;
2253
+ }
2254
+ function vr(e, t) {
1703
2255
  return new Promise((n) => {
1704
2256
  let r = setTimeout(n, t);
1705
2257
  e.then(() => {
@@ -1707,11 +2259,16 @@ function Rn(e, t) {
1707
2259
  });
1708
2260
  });
1709
2261
  }
1710
- var zn = class {
2262
+ var yr = class {
1711
2263
  config;
1712
2264
  state;
1713
2265
  listeners = /* @__PURE__ */ new Set();
1714
2266
  sessionToken = null;
2267
+ sessionTokenExpiresAt = null;
2268
+ tokenRenewal = null;
2269
+ renewalGeneration = 0;
2270
+ sendEpoch = 0;
2271
+ getSessionToken;
1715
2272
  conversationId = null;
1716
2273
  storageIdentifier;
1717
2274
  activeRequestController = null;
@@ -1722,13 +2279,23 @@ var zn = class {
1722
2279
  emptyStateImageUrl;
1723
2280
  emptyStateImageAlt;
1724
2281
  showFeedback;
1725
- constructor(t) {
1726
- this.config = t;
1727
- let n = T(t.theme).launcher, r = n.iconUrl ?? e(t.launcherIconUrl, "launcherIconUrl");
2282
+ text;
2283
+ language;
2284
+ languageTag;
2285
+ contentLanguage;
2286
+ dir;
2287
+ constructor(e) {
2288
+ this.config = e;
2289
+ let t = te(e.theme).launcher, r = t.iconUrl ?? n(e.launcherIconUrl, "launcherIconUrl");
1728
2290
  this.launcher = {
1729
- ...n,
2291
+ ...t,
1730
2292
  ...r ? { iconUrl: r } : {}
1731
- }, this.launcherIconUrl = r, this.emptyStateImageUrl = e(t.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof t.emptyStateImageAlt == "string" ? t.emptyStateImageAlt.trim() : "", this.showFeedback = t.showFeedback === !0, this.storageIdentifier = t.publishableKey ?? "session-token-mode", this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
2293
+ }, 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 = p(e);
2294
+ let { language: i, tag: a, dir: o } = At(e.language, typeof document > "u" ? void 0 : document.documentElement.lang);
2295
+ this.language = i, this.languageTag = a, this.dir = o, this.contentLanguage = Nt(e.contentLanguage, typeof document > "u" ? void 0 : document.documentElement.lang, e.language), this.text = {
2296
+ ...Ot(i),
2297
+ ...y(e.messages)
2298
+ }, this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
1732
2299
  isOpen: !1,
1733
2300
  messages: [],
1734
2301
  isStreaming: !1,
@@ -1741,6 +2308,7 @@ var zn = class {
1741
2308
  accentColor: null,
1742
2309
  inkColor: null,
1743
2310
  announcement: null,
2311
+ announcementIsContent: !1,
1744
2312
  isSlowResponse: !1,
1745
2313
  draft: ""
1746
2314
  };
@@ -1773,11 +2341,12 @@ var zn = class {
1773
2341
  let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
1774
2342
  try {
1775
2343
  if (this.config.sessionToken) {
1776
- if (cn(this.config.sessionToken)) throw Error("The sessionToken has expired.");
1777
- this.sessionToken = this.config.sessionToken;
2344
+ if (Pn(this.config.sessionToken)) {
2345
+ if (!("token" in await this.renewToken())) throw Error("The sessionToken has expired.");
2346
+ } else this.sessionToken = this.config.sessionToken, this.sessionTokenExpiresAt = Nn(this.config.sessionToken);
1778
2347
  } else if (this.config.publishableKey) {
1779
- let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await Yt(e, this.config.publishableKey);
1780
- this.sessionToken = t, this.setState({
2348
+ let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await bn(e, this.config.publishableKey);
2349
+ this.sessionToken = t, this.sessionTokenExpiresAt = Fn(t), this.setState({
1781
2350
  primaryColor: n,
1782
2351
  agentName: r,
1783
2352
  accentColor: i,
@@ -1788,49 +2357,52 @@ var zn = class {
1788
2357
  console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
1789
2358
  return;
1790
2359
  }
1791
- this.conversationId = un(this.storageIdentifier), this.config.sessionToken && await Rn(this.loadBranding(e, this.config.sessionToken), Ln);
2360
+ this.conversationId = Ln(this.storageIdentifier), this.config.sessionToken && await vr(this.loadBranding(e), ur);
1792
2361
  }
1793
- async loadBranding(e, t) {
2362
+ async loadBranding(e) {
1794
2363
  try {
1795
- let n = this.config;
1796
- if (X(n.color) && X(n.inkColor) && X(n.accentColor) && c(n.name)) return;
1797
- let { primaryColor: r, name: i, accentColor: a, inkColor: o } = await Zt(e, t);
2364
+ let t = this.config;
2365
+ if (X(t.color) && X(t.inkColor) && X(t.accentColor) && u(t.name)) return;
2366
+ let { primaryColor: n, name: r, accentColor: i, inkColor: a } = await this.withSession((t) => Sn(e, t));
1798
2367
  this.setState({
1799
- primaryColor: r,
1800
- agentName: i,
1801
- accentColor: a,
1802
- inkColor: o
2368
+ primaryColor: n,
2369
+ agentName: r,
2370
+ accentColor: i,
2371
+ inkColor: a
1803
2372
  });
1804
2373
  } catch (e) {
1805
2374
  let t = e?.status;
1806
- (t === 401 || t === 403) && (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) }));
2375
+ (e instanceof gr || 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 })));
1807
2376
  }
1808
2377
  }
1809
2378
  open() {
1810
2379
  this.setState({ isOpen: !0 });
1811
2380
  }
1812
2381
  resetConversation() {
1813
- this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, fn(this.storageIdentifier), this.setState({
2382
+ this.sendEpoch += 1, this.activeRequestController?.abort("reset"), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, zn(this.storageIdentifier), this.setState({
1814
2383
  messages: [],
1815
2384
  messageFeedback: {},
1816
2385
  runtimeError: null,
1817
2386
  isStreaming: !1,
1818
- announcement: "Conversation cleared"
2387
+ announcement: this.text.conversationCleared,
2388
+ announcementIsContent: !1
1819
2389
  });
1820
2390
  }
1821
2391
  setDraft(e) {
1822
2392
  this.setState({ draft: e });
1823
2393
  }
1824
2394
  close() {
1825
- this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isOpen: !1 });
2395
+ this.activeRequestController?.abort("close"), this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isOpen: !1 });
1826
2396
  }
1827
2397
  async sendMessage(e) {
1828
2398
  if (!this.sessionToken) return;
1829
- let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com", n = {
2399
+ let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
2400
+ this.sendEpoch += 1;
2401
+ let n = this.sendEpoch, r = () => n === this.sendEpoch, i = {
1830
2402
  role: "user",
1831
2403
  content: e,
1832
2404
  id: null
1833
- }, r = {
2405
+ }, a = {
1834
2406
  role: "assistant",
1835
2407
  content: "",
1836
2408
  id: null
@@ -1838,48 +2410,63 @@ var zn = class {
1838
2410
  this.setState({
1839
2411
  messages: [
1840
2412
  ...this.state.messages,
1841
- n,
1842
- r
2413
+ i,
2414
+ a
1843
2415
  ],
1844
2416
  isStreaming: !0,
1845
2417
  runtimeError: null,
1846
2418
  announcement: null
1847
2419
  });
1848
- let i = r, a = (e) => {
1849
- let t = i;
1850
- i = {
1851
- ...i,
2420
+ let o = a, s = (e) => {
2421
+ let t = o;
2422
+ o = {
2423
+ ...o,
1852
2424
  ...e
1853
- }, this.setState({ messages: this.state.messages.map((e) => e === t ? i : e) });
1854
- }, o = (e) => a({ content: e });
1855
- this.activeRequestController = new AbortController();
1856
- let { signal: s } = this.activeRequestController;
2425
+ }, this.setState({ messages: this.state.messages.map((e) => e === t ? o : e) });
2426
+ }, c = (e) => s({ content: e }), l = new AbortController();
2427
+ this.activeRequestController = l;
2428
+ let { signal: u } = l, d = !1;
1857
2429
  this.slowResponseTimer = setTimeout(() => {
1858
2430
  this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
1859
- }, In);
1860
- let c = () => {
1861
- this.setState({
1862
- runtimeError: "Something went wrong, please try again.",
1863
- ...this.state.draft === "" ? { draft: e } : {}
1864
- });
1865
- }, l = "";
2431
+ }, lr);
2432
+ let f = !1, p = () => {
2433
+ this.state.draft === "" && (f = !0, this.setState({ draft: e }));
2434
+ }, m = (e = this.text.genericError) => {
2435
+ r() && (this.setState({ runtimeError: e }), p());
2436
+ }, h = "";
1866
2437
  try {
1867
- for await (let n of $t(t, this.sessionToken, this.conversationId, e, s)) if (n.type === "conversation_id") this.conversationId = n.conversationId, dn(this.storageIdentifier, n.conversationId);
1868
- else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await sn(n.delta, (e) => o(e), { signal: s }), l = n.delta) : n.verbatim ? (l = n.delta, o(l)) : (l += n.delta, o(l));
1869
- else if (n.type === "done") n.conversationId && (this.conversationId = n.conversationId, dn(this.storageIdentifier, n.conversationId)), n.messageId && a({ id: n.messageId }), this.setState({ announcement: tn(l) });
1870
- else if (n.type === "error") {
1871
- console.error("[whoo-aiden-widget] chat error:", n.error), c(), this.activeRequestController?.abort();
1872
- break;
2438
+ let { stream: n, first: i } = await this.withSession(async (n) => {
2439
+ d = !0;
2440
+ let r = wn(t, n, this.conversationId, e, u);
2441
+ return {
2442
+ stream: r,
2443
+ first: await r.next()
2444
+ };
2445
+ }, u);
2446
+ for (let e = i; !e.done && !u.aborted && r(); e = await n.next()) {
2447
+ let t = e.value;
2448
+ if (t.type === "conversation_id") this.conversationId = t.conversationId, Rn(this.storageIdentifier, t.conversationId);
2449
+ else if (t.type === "delta") this.clearSlowResponse(), t.verbatim && !this.prefersReducedMotion ? (await jn(t.delta, (e) => c(e), { signal: u }), h = t.delta) : t.verbatim ? (h = t.delta, c(h)) : (h += t.delta, c(h));
2450
+ else if (t.type === "done") t.conversationId && (this.conversationId = t.conversationId, Rn(this.storageIdentifier, t.conversationId)), t.messageId && s({ id: t.messageId }), r() && this.setState({
2451
+ announcement: En(h),
2452
+ announcementIsContent: !0
2453
+ });
2454
+ else if (t.type === "error") {
2455
+ console.error("[whoo-aiden-widget] chat error:", t.error), h.trim() !== "" && r() && this.setState({
2456
+ announcement: En(h),
2457
+ announcementIsContent: !0
2458
+ }), m(), l.abort();
2459
+ break;
2460
+ }
1873
2461
  }
1874
2462
  } catch (e) {
1875
- e?.name === "AbortError" || (console.error("[whoo-aiden-widget] chat request failed:", e), c());
2463
+ u.aborted ? u.reason === "close" && r() && !d && p() : e instanceof gr ? (console.error("[whoo-aiden-widget] chat request failed: the session has expired.", e), m(this.text.sessionExpired)) : e instanceof fr ? (console.error("[whoo-aiden-widget] chat request failed: no session could be had."), m()) : (console.error("[whoo-aiden-widget] chat request failed:", e), m());
1876
2464
  } finally {
1877
- this.activeRequestController = null, this.clearSlowResponse();
1878
- let e = i.id === null && i.content.trim() === "" ? this.state.messages.filter((e) => e !== i) : this.state.messages;
1879
- this.setState({
2465
+ 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;
2466
+ r() ? (this.activeRequestController = null, this.clearSlowResponse(), this.setState({
1880
2467
  isStreaming: !1,
1881
- ...e.length === this.state.messages.length ? {} : { messages: e }
1882
- });
2468
+ ...n ? { messages: t } : {}
2469
+ })) : n && this.setState({ messages: t });
1883
2470
  }
1884
2471
  }
1885
2472
  expandFeedback(e) {
@@ -1920,12 +2507,12 @@ var zn = class {
1920
2507
  }
1921
2508
  } });
1922
2509
  try {
1923
- await Qt(i, this.sessionToken, {
2510
+ await this.withSession((a) => Cn(i, a, {
1924
2511
  messageId: e,
1925
2512
  rating: t,
1926
2513
  correction: n,
1927
2514
  category: r
1928
- }), this.setState({ messageFeedback: {
2515
+ })), this.setState({ messageFeedback: {
1929
2516
  ...this.state.messageFeedback,
1930
2517
  [e]: {
1931
2518
  status: "submitted",
@@ -1944,45 +2531,97 @@ var zn = class {
1944
2531
  } });
1945
2532
  }
1946
2533
  }
1947
- }, $ = 20, Bn = 12, Vn = 300, Hn = 352;
1948
- function Un() {
2534
+ async currentToken(e) {
2535
+ let t = this.sessionToken, n = this.sessionTokenExpiresAt;
2536
+ return t && (n === null || n - Date.now() > 6e4) ? { token: t } : pr(this.renewToken(), e);
2537
+ }
2538
+ renewToken() {
2539
+ return this.tokenRenewal ??= this.fetchNewToken().finally(() => {
2540
+ this.tokenRenewal = null;
2541
+ }), this.tokenRenewal;
2542
+ }
2543
+ async fetchNewToken() {
2544
+ let e = ++this.renewalGeneration, t, n = new Promise((e) => {
2545
+ t = setTimeout(() => {
2546
+ console.error("[whoo-aiden-widget] could not renew the session: it took too long."), e({ failure: "unavailable" });
2547
+ }, dr);
2548
+ });
2549
+ try {
2550
+ return await Promise.race([this.obtainToken(e), n]);
2551
+ } finally {
2552
+ clearTimeout(t);
2553
+ }
2554
+ }
2555
+ async obtainToken(e) {
2556
+ let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com", n;
2557
+ try {
2558
+ if (this.config.publishableKey) n = (await bn(t, this.config.publishableKey)).token;
2559
+ else if (this.getSessionToken) n = await this.getSessionToken();
2560
+ else return { failure: "refused" };
2561
+ } catch (e) {
2562
+ return console.error("[whoo-aiden-widget] could not renew the session:", e), { failure: this.config.publishableKey && hr(e) ? "refused" : "unavailable" };
2563
+ }
2564
+ let r = typeof n == "string" ? Fn(n) : null;
2565
+ 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 });
2566
+ }
2567
+ async withSession(e, t) {
2568
+ let n = await this.currentToken(t);
2569
+ if (!("token" in n)) throw mr(n.failure);
2570
+ let { token: r } = n;
2571
+ try {
2572
+ return await e(r);
2573
+ } catch (n) {
2574
+ if (!_r(n)) throw n;
2575
+ let i = this.sessionToken && this.sessionToken !== r ? { token: this.sessionToken } : await pr(this.renewToken(), t);
2576
+ if (!("token" in i)) throw mr(i.failure, n);
2577
+ try {
2578
+ return await e(i.token);
2579
+ } catch (e) {
2580
+ throw _r(e) ? new gr(e) : e;
2581
+ }
2582
+ }
2583
+ }
2584
+ }, $ = 20, br = 12, xr = 300, Sr = 352;
2585
+ function Cr() {
1949
2586
  try {
1950
2587
  return typeof CSS < "u" && CSS.supports?.("height", "100dvh") ? "dvh" : "vh";
1951
2588
  } catch {
1952
2589
  return "vh";
1953
2590
  }
1954
2591
  }
1955
- function Wn(e, t) {
1956
- let { offsetX: n, offsetY: r, launcherSize: i, panelWidth: a, panelHeight: o } = te(t.layout), s = (e) => typeof t.layout?.offset?.[e] == "number";
2592
+ function wr(e, t) {
2593
+ let { offsetX: n, offsetY: r, launcherSize: i, panelWidth: a, panelHeight: o } = ie(t.layout), s = (e) => typeof t.layout?.offset?.[e] == "number";
1957
2594
  if (typeof window < "u" && window.innerWidth > 0 && window.innerHeight > 0) {
1958
- let e = Math.max($, window.innerWidth - Vn), t = Math.max($, window.innerHeight - i - Hn);
2595
+ let e = Math.max($, window.innerWidth - xr), t = Math.max($, window.innerHeight - i - Sr);
1959
2596
  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.`);
1960
2597
  }
1961
- let c = `100${Un()}`, l = `min(${n}px, max(${$}px, calc(100vw - ${Vn}px)), calc(100vw - ${i}px))`, u = `min(${r}px, max(${$}px, calc(${c} - ${i + Hn}px)), calc(${c} - ${i}px))`, d = `calc(${u} + ${i}px + ${Bn}px)`, f = t.position === "bottom-left", p = (t, n) => e.style.setProperty(t, n);
2598
+ let c = `100${Cr()}`, l = `min(${n}px, max(${$}px, calc(100vw - ${xr}px)), calc(100vw - ${i}px))`, u = `min(${r}px, max(${$}px, calc(${c} - ${i + Sr}px)), calc(${c} - ${i}px))`, d = `calc(${u} + ${i}px + ${br}px)`, f = t.position === "bottom-left", p = (t, n) => e.style.setProperty(t, n);
1962
2599
  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)`);
1963
2600
  }
1964
2601
  //#endregion
1965
2602
  //#region src/styles.css?inline
1966
- var Gn = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif);border-radius:12px;flex-direction:column;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-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:8px 8px 8px 16px;display:flex;overflow-y:auto}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;flex:auto;min-width:0;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-left:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{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-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-list{margin:4px 0;padding-left:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:var(--whoo-widget-typing-dots,#6b7280);border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;flex:1;min-width:0;padding:8px;font-size:16px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:var(--whoo-widget-muted,#4b5563);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:var(--whoo-widget-text,#111);background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;border-radius:6px;width:100%;padding:6px;font-size: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}[data-whoo-custom-font] button,[data-whoo-custom-font] input,[data-whoo-custom-font] textarea,[data-whoo-custom-font] select{font-family:inherit}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
2603
+ var Tr = ":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-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-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-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
1967
2604
  //#endregion
1968
2605
  //#region src/mount.tsx
1969
- function Kn(e) {
2606
+ function Er(e) {
1970
2607
  let t = document.createElement("div");
1971
- t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(o(e.zIndex));
2608
+ t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(c(e.zIndex));
1972
2609
  let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
1973
- r.textContent = Gn, n.appendChild(r);
2610
+ r.textContent = Tr, n.appendChild(r);
1974
2611
  let i = document.createElement("div");
1975
2612
  n.appendChild(i);
1976
2613
  let a = /* @__PURE__ */ new Set();
1977
- Fn(i, e, a), Wn(i, e);
1978
- let s = new zn(e), c = X(e.color) !== null, l = null, u = "", d = T(e.theme).colors, f = Object.keys(d).length > 0, p = {
2614
+ cr(i, e, a), wr(i, e);
2615
+ let o = new yr(e);
2616
+ i.setAttribute("lang", o.languageTag), i.setAttribute("dir", o.dir);
2617
+ let s = X(e.color) !== null, l = null, u = "", d = te(e.theme).colors, f = Object.keys(d).length > 0, p = {
1979
2618
  color: e.color,
1980
2619
  inkColor: e.inkColor,
1981
2620
  accentColor: e.accentColor
1982
2621
  };
1983
- return s.subscribe((t) => {
2622
+ return o.subscribe((t) => {
1984
2623
  let n = !1;
1985
- !c && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor, kn(i, t.primaryColor, e.color), X(t.primaryColor) && (p = {
2624
+ !s && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor, nr(i, t.primaryColor, e.color), X(t.primaryColor) && (p = {
1986
2625
  ...p,
1987
2626
  color: t.primaryColor
1988
2627
  }), n = !0);
@@ -1990,7 +2629,7 @@ function Kn(e) {
1990
2629
  if ((t.inkColor || t.accentColor) && r !== u) {
1991
2630
  u = r;
1992
2631
  let a = X(e.inkColor) ? e.inkColor : t.inkColor, o = X(e.accentColor) ? e.accentColor : t.accentColor;
1993
- An(i, {
2632
+ rr(i, {
1994
2633
  inkColor: a,
1995
2634
  accentColor: o
1996
2635
  }), p = {
@@ -1999,18 +2638,18 @@ function Kn(e) {
1999
2638
  accentColor: o
2000
2639
  }, n = !0;
2001
2640
  }
2002
- n && (jn(i, d), f && Pn({
2641
+ n && (ir(i, d), f && sr({
2003
2642
  ...p,
2004
2643
  overrides: d
2005
2644
  }, a));
2006
- }), s.init(), Pe(/* @__PURE__ */ G(Kt, { controller: s }), i), document.body.appendChild(t), { unmount() {
2007
- Pe(null, i), t.remove();
2645
+ }), o.init(), ze(/* @__PURE__ */ W(_n, { controller: o }), i), document.body.appendChild(t), { unmount() {
2646
+ ze(null, i), t.remove();
2008
2647
  } };
2009
2648
  }
2010
2649
  //#endregion
2011
2650
  //#region src/index.ts
2012
- function qn(e) {
2013
- return l(e), Kn(e);
2651
+ function Dr(e) {
2652
+ return d(e), Er(e);
2014
2653
  }
2015
2654
  //#endregion
2016
- export { qn as init, Z as resolveTheme };
2655
+ export { Ct as SUPPORTED_LANGUAGES, Dr as init, Z as resolveTheme };