@aiden-voice/widget 0.8.0 → 0.9.1

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