@aiden-voice/widget 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.js CHANGED
@@ -3,26 +3,29 @@ function n(n) {
3
3
  return n === void 0 ? e : Number.isInteger(n) && Math.abs(n) <= t ? n : (console.warn(`whoo-aiden-widget: ignoring zIndex ${String(n)} (expected an integer between -${t} and ${t}); using ${e}.`), e);
4
4
  }
5
5
  function r(e) {
6
+ return typeof e == "string" ? e.trim() : "";
7
+ }
8
+ function i(e) {
6
9
  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.");
7
10
  }
8
11
  //#endregion
9
12
  //#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/dist/preact.module.js
10
- var i, a, o, s, c, l, u, d, f, p, m, h, g, _, v = {}, y = [], b = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, x = Array.isArray;
11
- function S(e, t) {
13
+ var a, o, s, c, l, u, d, f, p, m, h, g, _, v, y = {}, b = [], x = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, S = Array.isArray;
14
+ function C(e, t) {
12
15
  for (var n in t) e[n] = t[n];
13
16
  return e;
14
17
  }
15
18
  function ee(e) {
16
19
  e && e.parentNode && e.parentNode.removeChild(e);
17
20
  }
18
- function C(e, t, n) {
19
- var r, a, o, s = {};
20
- for (o in t) o == "key" ? r = t[o] : o == "ref" ? a = t[o] : s[o] = t[o];
21
- if (arguments.length > 2 && (s.children = arguments.length > 3 ? i.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (o in e.defaultProps) s[o] === void 0 && (s[o] = e.defaultProps[o]);
22
- return w(e, s, r, a, null);
21
+ function w(e, t, n) {
22
+ var r, i, o, s = {};
23
+ for (o in t) o == "key" ? r = t[o] : o == "ref" ? i = t[o] : s[o] = t[o];
24
+ if (arguments.length > 2 && (s.children = arguments.length > 3 ? a.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (o in e.defaultProps) s[o] === void 0 && (s[o] = e.defaultProps[o]);
25
+ return T(e, s, r, i, null);
23
26
  }
24
- function w(e, t, n, r, i) {
25
- var s = {
27
+ function T(e, t, n, r, i) {
28
+ var a = {
26
29
  type: e,
27
30
  props: t,
28
31
  key: n,
@@ -33,68 +36,68 @@ function w(e, t, n, r, i) {
33
36
  __e: null,
34
37
  __c: null,
35
38
  constructor: void 0,
36
- __v: i ?? ++o,
39
+ __v: i ?? ++s,
37
40
  __i: -1,
38
41
  __u: 0
39
42
  };
40
- return i == null && a.vnode != null && a.vnode(s), s;
43
+ return i == null && o.vnode != null && o.vnode(a), a;
41
44
  }
42
- function T(e) {
45
+ function E(e) {
43
46
  return e.children;
44
47
  }
45
- function E(e, t) {
48
+ function D(e, t) {
46
49
  this.props = e, this.context = t;
47
50
  }
48
- function D(e, t) {
49
- if (t == null) return e.__ ? D(e.__, e.__i + 1) : null;
51
+ function O(e, t) {
52
+ if (t == null) return e.__ ? O(e.__, e.__i + 1) : null;
50
53
  for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
51
- return typeof e.type == "function" ? D(e) : null;
54
+ return typeof e.type == "function" ? O(e) : null;
52
55
  }
53
- function O(e) {
56
+ function k(e) {
54
57
  if (e.__P && e.__d) {
55
- var t = e.__v, n = t.__e, r = [], i = [], o = S({}, t);
56
- o.__v = t.__v + 1, a.vnode && a.vnode(o), ae(e.__P, o, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? D(t), !!(32 & t.__u), i), o.__v = t.__v, o.__.__k[o.__i] = o, se(r, o, i), t.__e = t.__ = null, o.__e != n && k(o);
58
+ var t = e.__v, n = t.__e, r = [], i = [], a = C({}, t);
59
+ a.__v = t.__v + 1, o.vnode && o.vnode(a), se(e.__P, a, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? O(t), !!(32 & t.__u), i), a.__v = t.__v, a.__.__k[a.__i] = a, le(r, a, i), t.__e = t.__ = null, a.__e != n && A(a);
57
60
  }
58
61
  }
59
- function k(e) {
62
+ function A(e) {
60
63
  if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) {
61
64
  if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e;
62
- }), k(e);
65
+ }), A(e);
63
66
  }
64
- function A(e) {
65
- (!e.__d && (e.__d = !0) && s.push(e) && !j.__r++ || c != a.debounceRendering) && ((c = a.debounceRendering) || l)(j);
67
+ function j(e) {
68
+ (!e.__d && (e.__d = !0) && c.push(e) && !M.__r++ || l != o.debounceRendering) && ((l = o.debounceRendering) || u)(M);
66
69
  }
67
- function j() {
70
+ function M() {
68
71
  try {
69
- for (var e, t = 1; s.length;) s.length > t && s.sort(u), e = s.shift(), t = s.length, O(e);
72
+ for (var e, t = 1; c.length;) c.length > t && c.sort(d), e = c.shift(), t = c.length, k(e);
70
73
  } finally {
71
- s.length = j.__r = 0;
74
+ c.length = M.__r = 0;
72
75
  }
73
76
  }
74
77
  function te(e, t, n, r, i, a, o, s, c, l, u) {
75
- var d, f, p, m, h, g, _ = r && r.__k || y, b = t.length;
76
- for (c = M(n, t, _, c, b), d = 0; d < b; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || v, p.__i = d, g = ae(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && ue(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = N(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
78
+ var d, f, p, m, h, g, _ = r && r.__k || b, v = t.length;
79
+ for (c = N(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || y, p.__i = d, g = se(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && fe(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = ne(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
77
80
  return n.__e = h, c;
78
81
  }
79
- function M(e, t, n, r, i) {
82
+ function N(e, t, n, r, i) {
80
83
  var a, o, s, c, l, u = n.length, d = u, f = 0;
81
- for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = w(null, o, null, null, null) : x(o) ? o = e.__k[a] = w(T, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = w(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = ne(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
82
- if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = D(s)), de(s, s));
84
+ for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = T(null, o, null, null, null) : S(o) ? o = e.__k[a] = T(E, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = T(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = re(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
85
+ if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = O(s)), pe(s, s));
83
86
  return r;
84
87
  }
85
- function N(e, t, n) {
88
+ function ne(e, t, n) {
86
89
  var r, i;
87
90
  if (typeof e.type == "function") {
88
- for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t = N(r[i], t, n));
91
+ for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t = ne(r[i], t, n));
89
92
  return t;
90
93
  }
91
- e.__e != t && (t && e.type && !t.parentNode && (t = D(e)), t = n.insertBefore(e.__e, t || null));
94
+ e.__e != t && (t && e.type && !t.parentNode && (t = O(e)), t = n.insertBefore(e.__e, t || null));
92
95
  do
93
96
  t &&= t.nextSibling;
94
97
  while (t != null && t.nodeType == 8);
95
98
  return t;
96
99
  }
97
- function ne(e, t, n, r) {
100
+ function re(e, t, n, r) {
98
101
  var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && !(2 & l.__u);
99
102
  if (l === null && s == null || u && s == l.key && c == l.type) return n;
100
103
  if (r > +!!u) {
@@ -102,18 +105,18 @@ function ne(e, t, n, r) {
102
105
  }
103
106
  return -1;
104
107
  }
105
- function re(e, t, n) {
106
- t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || b.test(t) ? n : n + "px";
108
+ function ie(e, t, n) {
109
+ t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || x.test(t) ? n : n + "px";
107
110
  }
108
- function P(e, t, n, r, i) {
111
+ function ae(e, t, n, r, i) {
109
112
  var a, o;
110
113
  n: if (t == "style") {
111
114
  if (typeof n == "string") e.style.cssText = n;
112
115
  else {
113
- if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || re(e.style, t, "");
114
- if (n) for (t in n) r && n[t] == r[t] || re(e.style, t, n[t]);
116
+ if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || ie(e.style, t, "");
117
+ if (n) for (t in n) r && n[t] == r[t] || ie(e.style, t, n[t]);
115
118
  }
116
- } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(m, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[p] = r[p] : (n[p] = h, e.addEventListener(t, a ? _ : g, a)) : e.removeEventListener(t, a ? _ : g, a);
119
+ } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(h, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[m] = r[m] : (n[m] = g, e.addEventListener(t, a ? v : _, a)) : e.removeEventListener(t, a ? v : _, a);
117
120
  else {
118
121
  if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
119
122
  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 {
@@ -123,158 +126,158 @@ function P(e, t, n, r, i) {
123
126
  typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
124
127
  }
125
128
  }
126
- function ie(e) {
129
+ function oe(e) {
127
130
  return function(t) {
128
131
  if (this.l) {
129
132
  var n = this.l[t.type + e];
130
- if (t[f] == null) t[f] = h++;
131
- else if (t[f] < n[p]) return;
132
- return n(a.event ? a.event(t) : t);
133
+ if (t[p] == null) t[p] = g++;
134
+ else if (t[p] < n[m]) return;
135
+ return n(o.event ? o.event(t) : t);
133
136
  }
134
137
  };
135
138
  }
136
- function ae(e, t, n, r, i, o, s, c, l, u) {
137
- var d, f, p, m, h, g, _, v, b, C, w, O, k, A, j, M, N = t.type;
139
+ function se(e, t, n, r, i, a, s, c, l, u) {
140
+ var d, f, p, m, h, g, _, v, y, x, w, T, k, A, j, M, N = t.type;
138
141
  if (t.constructor !== void 0) return null;
139
- 128 & n.__u && (l = !!(32 & n.__u), o = [c = t.__e = n.__e]), (d = a.__b) && d(t);
142
+ 128 & n.__u && (l = !!(32 & n.__u), a = [c = t.__e = n.__e]), (d = o.__b) && d(t);
140
143
  n: if (typeof N == "function") {
141
144
  f = s.length;
142
145
  try {
143
- if (b = t.props, C = N.prototype && N.prototype.render, w = (d = N.contextType) && r[d.__c], O = d ? w ? w.props.value : d.__ : r, n.__c ? v = (p = t.__c = n.__c).__ = p.__E : (C ? t.__c = p = new N(b, O) : (t.__c = p = new E(b, O), p.constructor = N, p.render = fe), w && w.sub(p), p.state || (p.state = {}), p.__n = r, m = p.__d = !0, p.__h = [], p._sb = []), C && p.__s == null && (p.__s = p.state), C && N.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = S({}, p.__s)), S(p.__s, N.getDerivedStateFromProps(b, p.__s))), h = p.props, g = p.state, p.__v = t, m) C && N.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), C && p.componentDidMount != null && p.__h.push(p.componentDidMount);
146
+ if (y = t.props, x = N.prototype && N.prototype.render, w = (d = N.contextType) && r[d.__c], T = d ? w ? w.props.value : d.__ : r, n.__c ? v = (p = t.__c = n.__c).__ = p.__E : (x ? t.__c = p = new N(y, T) : (t.__c = p = new D(y, T), p.constructor = N, p.render = me), w && w.sub(p), p.state || (p.state = {}), p.__n = r, m = p.__d = !0, p.__h = [], p._sb = []), x && p.__s == null && (p.__s = p.state), x && N.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = C({}, p.__s)), C(p.__s, N.getDerivedStateFromProps(y, p.__s))), h = p.props, g = p.state, p.__v = t, m) x && N.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), x && p.componentDidMount != null && p.__h.push(p.componentDidMount);
144
147
  else {
145
- if (C && N.getDerivedStateFromProps == null && b !== h && p.componentWillReceiveProps != null && p.componentWillReceiveProps(b, O), t.__v == n.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(b, p.__s, O)) {
146
- t.__v != n.__v && (p.props = b, p.state = p.__s, p.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
148
+ if (x && N.getDerivedStateFromProps == null && y !== h && p.componentWillReceiveProps != null && p.componentWillReceiveProps(y, T), t.__v == n.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(y, p.__s, T)) {
149
+ t.__v != n.__v && (p.props = y, p.state = p.__s, p.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
147
150
  e && (e.__ = t);
148
- }), y.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && s.push(p), c = D(n);
151
+ }), b.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && s.push(p), c = O(n);
149
152
  break n;
150
153
  }
151
- p.componentWillUpdate != null && p.componentWillUpdate(b, p.__s, O), C && p.componentDidUpdate != null && p.__h.push(function() {
154
+ p.componentWillUpdate != null && p.componentWillUpdate(y, p.__s, T), x && p.componentDidUpdate != null && p.__h.push(function() {
152
155
  p.componentDidUpdate(h, g, _);
153
156
  });
154
157
  }
155
- if (p.context = O, p.props = b, p.__P = e, p.__e = !1, k = a.__r, A = 0, C) p.state = p.__s, p.__d = !1, k && k(t), d = p.render(p.props, p.state, p.context), y.push.apply(p.__h, p._sb), p._sb = [];
158
+ if (p.context = T, p.props = y, p.__P = e, p.__e = !1, k = o.__r, A = 0, x) p.state = p.__s, p.__d = !1, k && k(t), d = p.render(p.props, p.state, p.context), b.push.apply(p.__h, p._sb), p._sb = [];
156
159
  else do
157
160
  p.__d = !1, k && k(t), d = p.render(p.props, p.state, p.context), p.state = p.__s;
158
161
  while (p.__d && ++A < 25);
159
- p.state = p.__s, p.getChildContext != null && (r = S(S({}, r), p.getChildContext())), C && !m && p.getSnapshotBeforeUpdate != null && (_ = p.getSnapshotBeforeUpdate(h, g)), j = d != null && d.type === T && d.key == null ? ce(d.props.children) : d, c = te(e, x(j) ? j : [j], t, n, r, i, o, s, c, l, u), p.base = t.__e, t.__u &= -161, p.__h.length && s.push(p), v && (p.__E = p.__ = null);
162
+ p.state = p.__s, p.getChildContext != null && (r = C(C({}, r), p.getChildContext())), x && !m && p.getSnapshotBeforeUpdate != null && (_ = p.getSnapshotBeforeUpdate(h, g)), j = d != null && d.type === E && d.key == null ? ue(d.props.children) : d, c = te(e, S(j) ? j : [j], t, n, r, i, a, s, c, l, u), p.base = t.__e, t.__u &= -161, p.__h.length && s.push(p), v && (p.__E = p.__ = null);
160
163
  } catch (e) {
161
- if (s.length = f, t.__v = null, l || o != null) {
164
+ if (s.length = f, t.__v = null, l || a != null) {
162
165
  if (e.then) {
163
166
  for (t.__u |= l ? 160 : 128; c && c.nodeType == 8 && c.nextSibling;) c = c.nextSibling;
164
- o != null && (o[o.indexOf(c)] = null), t.__e = c;
165
- } else if (o != null) for (M = o.length; M--;) ee(o[M]);
167
+ a != null && (a[a.indexOf(c)] = null), t.__e = c;
168
+ } else if (a != null) for (M = a.length; M--;) ee(a[M]);
166
169
  } else t.__e = n.__e;
167
- t.__k ??= n.__k || [], e.then || oe(t), a.__e(e, t, n);
170
+ t.__k ??= n.__k || [], e.then || ce(t), o.__e(e, t, n);
168
171
  }
169
- } else o == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : c = t.__e = le(n.__e, t, n, r, i, o, s, l, u);
170
- return (d = a.diffed) && d(t), 128 & t.__u ? void 0 : c;
172
+ } else a == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : c = t.__e = de(n.__e, t, n, r, i, a, s, l, u);
173
+ return (d = o.diffed) && d(t), 128 & t.__u ? void 0 : c;
171
174
  }
172
- function oe(e) {
173
- e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(oe));
175
+ function ce(e) {
176
+ e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(ce));
174
177
  }
175
- function se(e, t, n) {
176
- for (var r = 0; r < n.length; r++) ue(n[r], n[++r], n[++r]);
177
- a.__c && a.__c(t, e), e.some(function(t) {
178
+ function le(e, t, n) {
179
+ for (var r = 0; r < n.length; r++) fe(n[r], n[++r], n[++r]);
180
+ o.__c && o.__c(t, e), e.some(function(t) {
178
181
  try {
179
182
  e = t.__h, t.__h = [], e.some(function(e) {
180
183
  e.call(t);
181
184
  });
182
185
  } catch (e) {
183
- a.__e(e, t.__v);
186
+ o.__e(e, t.__v);
184
187
  }
185
188
  });
186
189
  }
187
- function ce(e) {
188
- return typeof e != "object" || !e || e.__b > 0 ? e : x(e) ? e.map(ce) : e.constructor === void 0 ? S({}, e) : null;
190
+ function ue(e) {
191
+ return typeof e != "object" || !e || e.__b > 0 ? e : S(e) ? e.map(ue) : e.constructor === void 0 ? C({}, e) : null;
189
192
  }
190
- function le(e, t, n, r, o, s, c, l, u) {
191
- var d, f, p, m, h, g, _, y = n.props || v, b = t.props, S = t.type;
192
- if (S == "svg" ? o = "http://www.w3.org/2000/svg" : S == "math" ? o = "http://www.w3.org/1998/Math/MathML" : o ||= "http://www.w3.org/1999/xhtml", s != null) {
193
- for (d = 0; d < s.length; d++) if ((h = s[d]) && "setAttribute" in h == !!S && (S ? h.localName == S : h.nodeType == 3)) {
193
+ function de(e, t, n, r, i, s, c, l, u) {
194
+ var d, f, p, m, h, g, _, v = n.props || y, b = t.props, x = t.type;
195
+ 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", s != null) {
196
+ for (d = 0; d < s.length; d++) if ((h = s[d]) && "setAttribute" in h == !!x && (x ? h.localName == x : h.nodeType == 3)) {
194
197
  e = h, s[d] = null;
195
198
  break;
196
199
  }
197
200
  }
198
201
  if (e == null) {
199
- if (S == null) return document.createTextNode(b);
200
- e = document.createElementNS(o, S, b.is && b), l &&= (a.__m && a.__m(t, s), !1), s = null;
202
+ if (x == null) return document.createTextNode(b);
203
+ e = document.createElementNS(i, x, b.is && b), l &&= (o.__m && o.__m(t, s), !1), s = null;
201
204
  }
202
- if (S == null) y === b || l && e.data == b || (e.data = b);
205
+ if (x == null) v === b || l && e.data == b || (e.data = b);
203
206
  else {
204
- if (s = S == "textarea" && b.defaultValue != null ? null : s && i.call(e.childNodes), !l && s != null) for (y = {}, d = 0; d < e.attributes.length; d++) y[(h = e.attributes[d]).name] = h.value;
205
- for (d in y) h = y[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in b || d == "value" && "defaultValue" in b || d == "checked" && "defaultChecked" in b || P(e, d, null, h, o);
206
- for (d in b) h = b[d], d == "children" ? m = h : d == "dangerouslySetInnerHTML" ? f = h : d == "value" ? g = h : d == "checked" ? _ = h : l && typeof h != "function" || y[d] === h || P(e, d, h, y[d], o);
207
+ if (s = x == "textarea" && b.defaultValue != null ? null : s && a.call(e.childNodes), !l && s != null) for (v = {}, d = 0; d < e.attributes.length; d++) v[(h = e.attributes[d]).name] = h.value;
208
+ for (d in v) h = v[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in b || d == "value" && "defaultValue" in b || d == "checked" && "defaultChecked" in b || ae(e, d, null, h, i);
209
+ for (d in b) h = b[d], d == "children" ? m = h : d == "dangerouslySetInnerHTML" ? f = h : d == "value" ? g = h : d == "checked" ? _ = h : l && typeof h != "function" || v[d] === h || ae(e, d, h, v[d], i);
207
210
  if (f) l || p && (f.__html == p.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), t.__k = [];
208
- else if (p && (e.innerHTML = ""), te(t.type == "template" ? e.content : e, x(m) ? m : [m], t, n, r, S == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o, s, c, s ? s[0] : n.__k && D(n, 0), l, u), s != null) for (d = s.length; d--;) ee(s[d]);
209
- l && S != "textarea" || (d = "value", S == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[d] || S == "progress" && !g || S == "option" && g != y[d]) && P(e, d, g, y[d], o), d = "checked", _ != null && _ != e[d] && P(e, d, _, y[d], o));
211
+ else if (p && (e.innerHTML = ""), te(t.type == "template" ? e.content : e, S(m) ? m : [m], t, n, r, x == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, c, s ? s[0] : n.__k && O(n, 0), l, u), s != null) for (d = s.length; d--;) ee(s[d]);
212
+ l && x != "textarea" || (d = "value", x == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[d] || x == "progress" && !g || x == "option" && g != v[d]) && ae(e, d, g, v[d], i), d = "checked", _ != null && _ != e[d] && ae(e, d, _, v[d], i));
210
213
  }
211
214
  return e;
212
215
  }
213
- function ue(e, t, n) {
216
+ function fe(e, t, n) {
214
217
  try {
215
218
  if (typeof e == "function") {
216
219
  var r = typeof e.__u == "function";
217
220
  r && e.__u(), r && t == null || (e.__u = e(t));
218
221
  } else e.current = t;
219
222
  } catch (e) {
220
- a.__e(e, n);
223
+ o.__e(e, n);
221
224
  }
222
225
  }
223
- function de(e, t, n) {
226
+ function pe(e, t, n) {
224
227
  var r, i;
225
- if (a.unmount && a.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || ue(r, null, t)), (r = e.__c) != null) {
228
+ if (o.unmount && o.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || fe(r, null, t)), (r = e.__c) != null) {
226
229
  if (r.componentWillUnmount) try {
227
230
  r.componentWillUnmount();
228
231
  } catch (e) {
229
- a.__e(e, t);
232
+ o.__e(e, t);
230
233
  }
231
234
  r.base = r.__P = r.__n = null;
232
235
  }
233
- if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && de(r[i], t, n || typeof e.type != "function");
236
+ if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && pe(r[i], t, n || typeof e.type != "function");
234
237
  n || ee(e.__e), e.__c = e.__ = e.__e = void 0;
235
238
  }
236
- function fe(e, t, n) {
239
+ function me(e, t, n) {
237
240
  return this.constructor(e, n);
238
241
  }
239
- function pe(e, t, n) {
240
- var r, o, s, c;
241
- t == document && (t = document.documentElement), a.__ && a.__(e, t), o = (r = typeof n == "function") ? null : n && n.__k || t.__k, s = [], c = [], ae(t, e = (!r && n || t).__k = C(T, null, [e]), o || v, v, t.namespaceURI, !r && n ? [n] : o ? null : t.firstChild ? i.call(t.childNodes) : null, s, !r && n ? n : o ? o.__e : t.firstChild, r, c), se(s, e, c), e.props.children = null;
242
+ function he(e, t, n) {
243
+ var r, i, s, c;
244
+ t == document && (t = document.documentElement), o.__ && o.__(e, t), i = (r = typeof n == "function") ? null : n && n.__k || t.__k, s = [], c = [], se(t, e = (!r && n || t).__k = w(E, null, [e]), i || y, y, t.namespaceURI, !r && n ? [n] : i ? null : t.firstChild ? a.call(t.childNodes) : null, s, !r && n ? n : i ? i.__e : t.firstChild, r, c), le(s, e, c), e.props.children = null;
242
245
  }
243
- i = y.slice, a = { __e: function(e, t, n, r) {
246
+ a = b.slice, o = { __e: function(e, t, n, r) {
244
247
  for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
245
248
  if ((a = i.constructor) && a.getDerivedStateFromError != null && (i.setState(a.getDerivedStateFromError(e)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, r || {}), o = i.__d), o) return i.__E = i;
246
249
  } catch (t) {
247
250
  e = t;
248
251
  }
249
252
  throw e;
250
- } }, o = 0, E.prototype.setState = function(e, t) {
251
- var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = S({}, this.state);
252
- typeof e == "function" && (e = e(S({}, n), this.props)), e && S(n, e), e != null && this.__v && (t && this._sb.push(t), A(this));
253
- }, E.prototype.forceUpdate = function(e) {
254
- this.__v && (this.__e = !0, e && this.__h.push(e), A(this));
255
- }, E.prototype.render = T, s = [], l = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, u = function(e, t) {
253
+ } }, s = 0, D.prototype.setState = function(e, t) {
254
+ var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = C({}, this.state);
255
+ typeof e == "function" && (e = e(C({}, n), this.props)), e && C(n, e), e != null && this.__v && (t && this._sb.push(t), j(this));
256
+ }, D.prototype.forceUpdate = function(e) {
257
+ this.__v && (this.__e = !0, e && this.__h.push(e), j(this));
258
+ }, D.prototype.render = E, c = [], u = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, d = function(e, t) {
256
259
  return e.__v.__b - t.__v.__b;
257
- }, j.__r = 0, d = Math.random().toString(8), f = "__d" + d, p = "__a" + d, m = /(PointerCapture)$|Capture$/i, h = 0, g = ie(!1), _ = ie(!0);
260
+ }, M.__r = 0, f = Math.random().toString(8), p = "__d" + f, m = "__a" + f, h = /(PointerCapture)$|Capture$/i, g = 0, _ = oe(!1), v = oe(!0);
258
261
  //#endregion
259
262
  //#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/hooks/dist/hooks.module.js
260
- var F, I, me, he, L = 0, ge = [], R = a, _e = R.__b, ve = R.__r, ye = R.diffed, be = R.__c, xe = R.unmount, Se = R.__;
261
- function Ce(e, t) {
262
- R.__h && R.__h(I, e, L || t), L = 0;
263
- var n = I.__H || (I.__H = {
263
+ var P, F, ge, _e, I = 0, ve = [], L = o, ye = L.__b, be = L.__r, xe = L.diffed, Se = L.__c, Ce = L.unmount, we = L.__;
264
+ function Te(e, t) {
265
+ L.__h && L.__h(F, e, I || t), I = 0;
266
+ var n = F.__H || (F.__H = {
264
267
  __: [],
265
268
  __h: []
266
269
  });
267
270
  return e >= n.__.length && n.__.push({}), n.__[e];
268
271
  }
269
- function z(e) {
270
- return L = 1, we(je, e);
272
+ function R(e) {
273
+ return I = 1, Ee(Ne, e);
271
274
  }
272
- function we(e, t, n) {
273
- var r = Ce(F++, 2);
274
- if (r.t = e, !r.__c && (r.__ = [n ? n(t) : je(void 0, t), function(e) {
275
+ function Ee(e, t, n) {
276
+ var r = Te(P++, 2);
277
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Ne(void 0, t), function(e) {
275
278
  var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
276
279
  t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
277
- }], r.__c = I, !I.__f)) {
280
+ }], r.__c = F, !F.__f)) {
278
281
  var i = function(e, t, n) {
279
282
  if (!r.__c.__H) return !0;
280
283
  var i = !1, o = r.__c.props !== e;
@@ -290,108 +293,108 @@ function we(e, t, n) {
290
293
  }
291
294
  return !i || o;
292
295
  };
293
- I.__f = !0;
294
- var a = I.shouldComponentUpdate, o = I.componentWillUpdate;
295
- I.componentWillUpdate = function(e, t, n) {
296
+ F.__f = !0;
297
+ var a = F.shouldComponentUpdate, o = F.componentWillUpdate;
298
+ F.componentWillUpdate = function(e, t, n) {
296
299
  if (this.__e) {
297
300
  var r = a;
298
301
  a = void 0, i(e, t, n), a = r;
299
302
  }
300
303
  o && o.call(this, e, t, n);
301
- }, I.shouldComponentUpdate = i;
304
+ }, F.shouldComponentUpdate = i;
302
305
  }
303
306
  return r.__N || r.__;
304
307
  }
305
- function B(e, t) {
306
- var n = Ce(F++, 3);
307
- !R.__s && Ae(n.__H, t) && (n.__ = e, n.u = t, I.__H.__h.push(n));
308
+ function z(e, t) {
309
+ var n = Te(P++, 3);
310
+ !L.__s && Me(n.__H, t) && (n.__ = e, n.u = t, F.__H.__h.push(n));
308
311
  }
309
- function V(e) {
310
- return L = 5, Te(function() {
312
+ function B(e) {
313
+ return I = 5, De(function() {
311
314
  return { current: e };
312
315
  }, []);
313
316
  }
314
- function Te(e, t) {
315
- var n = Ce(F++, 7);
316
- return Ae(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
317
+ function De(e, t) {
318
+ var n = Te(P++, 7);
319
+ return Me(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
317
320
  }
318
- function Ee() {
319
- for (var e; e = ge.shift();) {
321
+ function Oe() {
322
+ for (var e; e = ve.shift();) {
320
323
  var t = e.__H;
321
324
  if (e.__P && t) try {
322
- t.__h.some(H), t.__h.some(ke), t.__h = [];
325
+ t.__h.some(V), t.__h.some(je), t.__h = [];
323
326
  } catch (n) {
324
- t.__h = [], R.__e(n, e.__v);
327
+ t.__h = [], L.__e(n, e.__v);
325
328
  }
326
329
  }
327
330
  }
328
- R.__b = function(e) {
329
- I = null, _e && _e(e);
330
- }, R.__ = function(e, t) {
331
- e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Se && Se(e, t);
332
- }, R.__r = function(e) {
333
- ve && ve(e), F = 0;
334
- var t = (I = e.__c).__H;
335
- t && (me === I ? (t.__h = [], I.__h = [], t.__.some(function(e) {
331
+ L.__b = function(e) {
332
+ F = null, ye && ye(e);
333
+ }, L.__ = function(e, t) {
334
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), we && we(e, t);
335
+ }, L.__r = function(e) {
336
+ be && be(e), P = 0;
337
+ var t = (F = e.__c).__H;
338
+ t && (ge === F ? (t.__h = [], F.__h = [], t.__.some(function(e) {
336
339
  e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
337
- })) : (t.__h.some(H), t.__h.some(ke), t.__h = [], F = 0)), me = I;
338
- }, R.diffed = function(e) {
339
- ye && ye(e);
340
+ })) : (t.__h.some(V), t.__h.some(je), t.__h = [], P = 0)), ge = F;
341
+ }, L.diffed = function(e) {
342
+ xe && xe(e);
340
343
  var t = e.__c;
341
- t && t.__H && (t.__H.__h.length && (ge.push(t) !== 1 && he === R.requestAnimationFrame || ((he = R.requestAnimationFrame) || Oe)(Ee)), t.__H.__.some(function(e) {
344
+ t && t.__H && (t.__H.__h.length && (ve.push(t) !== 1 && _e === L.requestAnimationFrame || ((_e = L.requestAnimationFrame) || Ae)(Oe)), t.__H.__.some(function(e) {
342
345
  e.u &&= (e.__H = e.u, void 0);
343
- })), me = I = null;
344
- }, R.__c = function(e, t) {
346
+ })), ge = F = null;
347
+ }, L.__c = function(e, t) {
345
348
  t.some(function(e) {
346
349
  try {
347
- e.__h.some(H), e.__h = e.__h.filter(function(e) {
348
- return !e.__ || ke(e);
350
+ e.__h.some(V), e.__h = e.__h.filter(function(e) {
351
+ return !e.__ || je(e);
349
352
  });
350
353
  } catch (n) {
351
354
  t.some(function(e) {
352
355
  e.__h &&= [];
353
- }), t = [], R.__e(n, e.__v);
356
+ }), t = [], L.__e(n, e.__v);
354
357
  }
355
- }), be && be(e, t);
356
- }, R.unmount = function(e) {
357
- xe && xe(e);
358
+ }), Se && Se(e, t);
359
+ }, L.unmount = function(e) {
360
+ Ce && Ce(e);
358
361
  var t, n = e.__c;
359
362
  n && n.__H && (n.__H.__.some(function(e) {
360
363
  try {
361
- H(e);
364
+ V(e);
362
365
  } catch (e) {
363
366
  t = e;
364
367
  }
365
- }), n.__H = void 0, t && R.__e(t, n.__v));
368
+ }), n.__H = void 0, t && L.__e(t, n.__v));
366
369
  };
367
- var De = typeof requestAnimationFrame == "function";
368
- function Oe(e) {
370
+ var ke = typeof requestAnimationFrame == "function";
371
+ function Ae(e) {
369
372
  var t, n = function() {
370
- clearTimeout(r), De && cancelAnimationFrame(t), setTimeout(e);
373
+ clearTimeout(r), ke && cancelAnimationFrame(t), setTimeout(e);
371
374
  }, r = setTimeout(n, 35);
372
- De && (t = requestAnimationFrame(n));
375
+ ke && (t = requestAnimationFrame(n));
373
376
  }
374
- function H(e) {
375
- var t = I, n = e.__c;
376
- typeof n == "function" && (e.__c = void 0, n()), I = t;
377
+ function V(e) {
378
+ var t = F, n = e.__c;
379
+ typeof n == "function" && (e.__c = void 0, n()), F = t;
377
380
  }
378
- function ke(e) {
379
- var t = I;
380
- e.__c = e.__(), I = t;
381
+ function je(e) {
382
+ var t = F;
383
+ e.__c = e.__(), F = t;
381
384
  }
382
- function Ae(e, t) {
385
+ function Me(e, t) {
383
386
  return !e || e.length !== t.length || t.some(function(t, n) {
384
387
  return t !== e[n];
385
388
  });
386
389
  }
387
- function je(e, t) {
390
+ function Ne(e, t) {
388
391
  return typeof t == "function" ? t(e) : t;
389
392
  }
390
393
  //#endregion
391
394
  //#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
392
- var Me = 0;
395
+ var Pe = 0;
393
396
  Array.isArray;
394
- function U(e, t, n, r, i, o) {
397
+ function H(e, t, n, r, i, a) {
395
398
  t ||= {};
396
399
  var s, c, l = t;
397
400
  if ("ref" in l) for (c in l = {}, t) c == "ref" ? s = t[c] : l[c] = t[c];
@@ -406,19 +409,19 @@ function U(e, t, n, r, i, o) {
406
409
  __e: null,
407
410
  __c: null,
408
411
  constructor: void 0,
409
- __v: --Me,
412
+ __v: --Pe,
410
413
  __i: -1,
411
414
  __u: 0,
412
415
  __source: i,
413
- __self: o
416
+ __self: a
414
417
  };
415
418
  if (typeof e == "function" && (s = e.defaultProps)) for (c in s) l[c] === void 0 && (l[c] = s[c]);
416
- return a.vnode && a.vnode(u), u;
419
+ return o.vnode && o.vnode(u), u;
417
420
  }
418
421
  //#endregion
419
422
  //#region src/components/icons.tsx
420
- function W({ name: e, size: t, children: n }) {
421
- return /* @__PURE__ */ U("svg", {
423
+ function U({ name: e, size: t, children: n }) {
424
+ return /* @__PURE__ */ H("svg", {
422
425
  "data-icon": e,
423
426
  "aria-hidden": "true",
424
427
  focusable: "false",
@@ -433,59 +436,59 @@ function W({ name: e, size: t, children: n }) {
433
436
  children: n
434
437
  });
435
438
  }
436
- function Ne({ size: e = 26 }) {
437
- return /* @__PURE__ */ U(W, {
439
+ function Fe({ size: e = 26 }) {
440
+ return /* @__PURE__ */ H(U, {
438
441
  name: "chat",
439
442
  size: e,
440
- 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", {
443
+ children: [/* @__PURE__ */ H("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__ */ H("path", {
441
444
  d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
442
445
  "stroke-width": "2.5"
443
446
  })]
444
447
  });
445
448
  }
446
- function Pe({ size: e = 26 }) {
447
- return /* @__PURE__ */ U(W, {
449
+ function Ie({ size: e = 26 }) {
450
+ return /* @__PURE__ */ H(U, {
448
451
  name: "chevron-down",
449
452
  size: e,
450
- children: /* @__PURE__ */ U("path", { d: "M6 9l6 6 6-6" })
453
+ children: /* @__PURE__ */ H("path", { d: "M6 9l6 6 6-6" })
451
454
  });
452
455
  }
453
- function Fe({ size: e = 18 }) {
454
- return /* @__PURE__ */ U(W, {
456
+ function Le({ size: e = 18 }) {
457
+ return /* @__PURE__ */ H(U, {
455
458
  name: "close",
456
459
  size: e,
457
- children: /* @__PURE__ */ U("path", { d: "M6 6l12 12M18 6L6 18" })
460
+ children: /* @__PURE__ */ H("path", { d: "M6 6l12 12M18 6L6 18" })
458
461
  });
459
462
  }
460
- var Ie = "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";
461
- function Le({ size: e = 16 }) {
462
- return /* @__PURE__ */ U(W, {
463
+ var Re = "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";
464
+ function ze({ size: e = 16 }) {
465
+ return /* @__PURE__ */ H(U, {
463
466
  name: "thumb-up",
464
467
  size: e,
465
- children: /* @__PURE__ */ U("path", { d: Ie })
468
+ children: /* @__PURE__ */ H("path", { d: Re })
466
469
  });
467
470
  }
468
- function Re({ size: e = 16 }) {
469
- return /* @__PURE__ */ U(W, {
471
+ function Be({ size: e = 16 }) {
472
+ return /* @__PURE__ */ H(U, {
470
473
  name: "thumb-down",
471
474
  size: e,
472
- children: /* @__PURE__ */ U("path", {
473
- d: Ie,
475
+ children: /* @__PURE__ */ H("path", {
476
+ d: Re,
474
477
  transform: "matrix(1 0 0 -1 0 24)"
475
478
  })
476
479
  });
477
480
  }
478
481
  //#endregion
479
482
  //#region src/components/Launcher.tsx
480
- function ze({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
481
- let [i, a] = z("loading"), o = n !== void 0 && i !== "failed", s = o && !e && i === "loaded";
482
- return /* @__PURE__ */ U("button", {
483
+ function Ve({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
484
+ let [i, a] = R("loading"), o = n !== void 0 && i !== "failed", s = o && !e && i === "loaded";
485
+ return /* @__PURE__ */ H("button", {
483
486
  type: "button",
484
487
  class: "whoo-widget-launcher",
485
488
  onClick: t,
486
489
  "aria-label": e ? "Close chat" : "Open chat",
487
490
  ref: r,
488
- children: [e ? /* @__PURE__ */ U(Pe, {}) : s ? null : /* @__PURE__ */ U(Ne, {}), o ? /* @__PURE__ */ U("img", {
491
+ children: [e ? /* @__PURE__ */ H(Ie, {}) : s ? null : /* @__PURE__ */ H(Fe, {}), o ? /* @__PURE__ */ H("img", {
489
492
  class: "whoo-widget-launcher-icon-image",
490
493
  src: n,
491
494
  alt: "",
@@ -498,16 +501,16 @@ function ze({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
498
501
  }
499
502
  //#endregion
500
503
  //#region src/components/Composer.tsx
501
- function Be({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
502
- return /* @__PURE__ */ U("div", {
504
+ function He({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
505
+ return /* @__PURE__ */ H("div", {
503
506
  class: "whoo-widget-composer",
504
507
  children: [
505
- /* @__PURE__ */ U("label", {
508
+ /* @__PURE__ */ H("label", {
506
509
  class: "whoo-widget-sr-only",
507
510
  for: "whoo-widget-composer-input",
508
511
  children: "Message"
509
512
  }),
510
- /* @__PURE__ */ U("input", {
513
+ /* @__PURE__ */ H("input", {
511
514
  id: "whoo-widget-composer-input",
512
515
  class: "whoo-widget-composer-input",
513
516
  value: e,
@@ -519,7 +522,7 @@ function Be({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
519
522
  e.key === "Enter" && n();
520
523
  }
521
524
  }),
522
- /* @__PURE__ */ U("button", {
525
+ /* @__PURE__ */ H("button", {
523
526
  type: "button",
524
527
  class: "whoo-widget-composer-send",
525
528
  onClick: n,
@@ -531,8 +534,8 @@ function Be({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
531
534
  }
532
535
  //#endregion
533
536
  //#region src/components/ErrorBanner.tsx
534
- function Ve({ message: e }) {
535
- return /* @__PURE__ */ U("div", {
537
+ function Ue({ message: e }) {
538
+ return /* @__PURE__ */ H("div", {
536
539
  class: "whoo-widget-error-banner",
537
540
  role: "alert",
538
541
  children: e
@@ -540,8 +543,8 @@ function Ve({ message: e }) {
540
543
  }
541
544
  //#endregion
542
545
  //#region src/markdown/tokenizer.ts
543
- var G = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, K = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, q = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, J = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, Y = /[ \t]*[*+-][ \t]+/y, He = /https?:\/\/\S+/y, Ue = /[.,;:!?)\]}>]+$/;
544
- function We(e) {
546
+ var W = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, G = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, K = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, q = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, J = /[ \t]*[*+-][ \t]+/y, We = /https?:\/\/\S+/y, Ge = /[.,;:!?)\]}>]+$/;
547
+ function Ke(e) {
545
548
  let t = [], n = 0, r = 0, i = (n) => {
546
549
  n > r && t.push({
547
550
  type: "text",
@@ -551,13 +554,13 @@ function We(e) {
551
554
  });
552
555
  };
553
556
  for (; n < e.length;) {
554
- if ((n === 0 || e[n - 1] === "\n") && (Y.lastIndex = n, Y.exec(e))) {
557
+ if ((n === 0 || e[n - 1] === "\n") && (J.lastIndex = n, J.exec(e))) {
555
558
  i(n), t.push({
556
559
  type: "text",
557
560
  value: "• ",
558
561
  start: n,
559
- end: Y.lastIndex
560
- }), n = Y.lastIndex, r = n;
562
+ end: J.lastIndex
563
+ }), n = J.lastIndex, r = n;
561
564
  continue;
562
565
  }
563
566
  if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
@@ -570,56 +573,56 @@ function We(e) {
570
573
  }
571
574
  }
572
575
  if (e[n - 1] !== "!") {
573
- G.lastIndex = n;
574
- let a = G.exec(e);
576
+ W.lastIndex = n;
577
+ let a = W.exec(e);
575
578
  if (a) {
576
579
  i(n), t.push({
577
580
  type: "link",
578
581
  text: a[1],
579
582
  url: a[2],
580
583
  start: n,
581
- end: G.lastIndex
582
- }), n = G.lastIndex, r = n;
584
+ end: W.lastIndex
585
+ }), n = W.lastIndex, r = n;
583
586
  continue;
584
587
  }
585
588
  }
586
- K.lastIndex = n;
587
- let a = K.exec(e);
589
+ G.lastIndex = n;
590
+ let a = G.exec(e);
588
591
  if (a) {
589
592
  i(n), t.push({
590
593
  type: "bold",
591
594
  value: a[1],
592
595
  start: n,
593
- end: K.lastIndex
594
- }), n = K.lastIndex, r = n;
596
+ end: G.lastIndex
597
+ }), n = G.lastIndex, r = n;
595
598
  continue;
596
599
  }
597
- q.lastIndex = n;
598
- let o = q.exec(e);
600
+ K.lastIndex = n;
601
+ let o = K.exec(e);
599
602
  if (o) {
600
603
  i(n), t.push({
601
604
  type: "italic",
602
605
  value: o[1],
603
606
  start: n,
604
- end: q.lastIndex
605
- }), n = q.lastIndex, r = n;
607
+ end: K.lastIndex
608
+ }), n = K.lastIndex, r = n;
606
609
  continue;
607
610
  }
608
- J.lastIndex = n;
609
- let s = J.exec(e);
611
+ q.lastIndex = n;
612
+ let s = q.exec(e);
610
613
  if (s) {
611
614
  i(n), t.push({
612
615
  type: "italic",
613
616
  value: s[1],
614
617
  start: n,
615
- end: J.lastIndex
616
- }), n = J.lastIndex, r = n;
618
+ end: q.lastIndex
619
+ }), n = q.lastIndex, r = n;
617
620
  continue;
618
621
  }
619
- He.lastIndex = n;
620
- let c = He.exec(e);
622
+ We.lastIndex = n;
623
+ let c = We.exec(e);
621
624
  if (c) {
622
- let e = c[0].match(Ue), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
625
+ let e = c[0].match(Ge), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
623
626
  if (a.length > 0) {
624
627
  i(n), t.push({
625
628
  type: "link",
@@ -637,16 +640,16 @@ function We(e) {
637
640
  }
638
641
  //#endregion
639
642
  //#region src/markdown/render.tsx
640
- function Ge(e) {
641
- return We(e).map((e, t) => {
643
+ function qe(e) {
644
+ return Ke(e).map((e, t) => {
642
645
  switch (e.type) {
643
- case "bold": return /* @__PURE__ */ U("strong", { children: Ge(e.value) }, t);
644
- case "italic": return /* @__PURE__ */ U("em", { children: Ge(e.value) }, t);
645
- case "link": return /* @__PURE__ */ U("a", {
646
+ case "bold": return /* @__PURE__ */ H("strong", { children: qe(e.value) }, t);
647
+ case "italic": return /* @__PURE__ */ H("em", { children: qe(e.value) }, t);
648
+ case "link": return /* @__PURE__ */ H("a", {
646
649
  href: e.url,
647
650
  target: "_blank",
648
651
  rel: "noopener noreferrer",
649
- children: [e.text, /* @__PURE__ */ U("span", {
652
+ children: [e.text, /* @__PURE__ */ H("span", {
650
653
  class: "whoo-widget-sr-only",
651
654
  children: " (opens in new tab)"
652
655
  })]
@@ -657,7 +660,7 @@ function Ge(e) {
657
660
  }
658
661
  //#endregion
659
662
  //#region src/components/MessageFeedback.tsx
660
- var Ke = [
663
+ var Je = [
661
664
  {
662
665
  value: "",
663
666
  label: "Select a reason (optional)"
@@ -679,50 +682,50 @@ var Ke = [
679
682
  label: "Other"
680
683
  }
681
684
  ];
682
- function qe({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancel: a }) {
683
- let [o, s] = z(""), [c, l] = z(""), u = V(e.status);
684
- if (B(() => {
685
+ function Ye({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancel: a }) {
686
+ let [o, s] = R(""), [c, l] = R(""), u = B(e.status);
687
+ if (z(() => {
685
688
  let n = u.current;
686
689
  if (u.current = e.status, n === e.status) return;
687
690
  let r = t?.current;
688
691
  if (!r) return;
689
692
  let i = r.getRootNode();
690
693
  r.contains(i.activeElement) || r.focus();
691
- }, [e.status, t]), e.status === "submitted") return /* @__PURE__ */ U("div", {
694
+ }, [e.status, t]), e.status === "submitted") return /* @__PURE__ */ H("div", {
692
695
  class: "whoo-widget-feedback-submitted",
693
696
  role: "status",
694
697
  children: "Thanks for the feedback"
695
698
  });
696
- if (e.status === "expanded") return /* @__PURE__ */ U("div", {
699
+ if (e.status === "expanded") return /* @__PURE__ */ H("div", {
697
700
  class: "whoo-widget-feedback-form",
698
701
  children: [
699
- /* @__PURE__ */ U("label", { children: [/* @__PURE__ */ U("span", {
702
+ /* @__PURE__ */ H("label", { children: [/* @__PURE__ */ H("span", {
700
703
  class: "whoo-widget-sr-only",
701
704
  children: "Additional feedback"
702
- }), /* @__PURE__ */ U("textarea", {
705
+ }), /* @__PURE__ */ H("textarea", {
703
706
  class: "whoo-widget-feedback-textarea",
704
707
  value: o,
705
708
  onInput: (e) => s(e.target.value),
706
709
  placeholder: "What was wrong? (optional)"
707
710
  })] }),
708
- /* @__PURE__ */ U("select", {
711
+ /* @__PURE__ */ H("select", {
709
712
  class: "whoo-widget-feedback-select",
710
713
  "aria-label": "Feedback category",
711
714
  value: c,
712
715
  onChange: (e) => l(e.target.value),
713
- children: Ke.map((e) => /* @__PURE__ */ U("option", {
716
+ children: Je.map((e) => /* @__PURE__ */ H("option", {
714
717
  value: e.value,
715
718
  children: e.label
716
719
  }, e.value))
717
720
  }),
718
- /* @__PURE__ */ U("div", {
721
+ /* @__PURE__ */ H("div", {
719
722
  class: "whoo-widget-feedback-form-buttons",
720
- children: [/* @__PURE__ */ U("button", {
723
+ children: [/* @__PURE__ */ H("button", {
721
724
  type: "button",
722
725
  class: "whoo-widget-feedback-submit",
723
726
  onClick: () => i(o, c),
724
727
  children: "Submit"
725
- }), /* @__PURE__ */ U("button", {
728
+ }), /* @__PURE__ */ H("button", {
726
729
  type: "button",
727
730
  class: "whoo-widget-feedback-cancel",
728
731
  onClick: a,
@@ -732,24 +735,24 @@ function qe({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
732
735
  ]
733
736
  });
734
737
  let d = e.status === "submitting";
735
- return /* @__PURE__ */ U("div", {
738
+ return /* @__PURE__ */ H("div", {
736
739
  class: "whoo-widget-feedback",
737
- children: [/* @__PURE__ */ U("div", {
740
+ children: [/* @__PURE__ */ H("div", {
738
741
  class: "whoo-widget-feedback-buttons",
739
- children: [/* @__PURE__ */ U("button", {
742
+ children: [/* @__PURE__ */ H("button", {
740
743
  type: "button",
741
744
  "aria-label": "Good response",
742
745
  disabled: d,
743
746
  onClick: n,
744
- children: /* @__PURE__ */ U(Le, {})
745
- }), /* @__PURE__ */ U("button", {
747
+ children: /* @__PURE__ */ H(ze, {})
748
+ }), /* @__PURE__ */ H("button", {
746
749
  type: "button",
747
750
  "aria-label": "Bad response",
748
751
  disabled: d,
749
752
  onClick: r,
750
- children: /* @__PURE__ */ U(Re, {})
753
+ children: /* @__PURE__ */ H(Be, {})
751
754
  })]
752
- }), e.status === "error" ? /* @__PURE__ */ U("div", {
755
+ }), e.status === "error" ? /* @__PURE__ */ H("div", {
753
756
  class: "whoo-widget-feedback-error",
754
757
  role: "status",
755
758
  children: "Couldn't send feedback"
@@ -758,27 +761,27 @@ function qe({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
758
761
  }
759
762
  //#endregion
760
763
  //#region src/components/MessageList.tsx
761
- function Je({ isSlowResponse: e }) {
762
- return /* @__PURE__ */ U("div", {
764
+ function Xe({ isSlowResponse: e }) {
765
+ return /* @__PURE__ */ H("div", {
763
766
  class: "whoo-widget-pending",
764
767
  role: "status",
765
- children: [/* @__PURE__ */ U("span", {
768
+ children: [/* @__PURE__ */ H("span", {
766
769
  class: "whoo-widget-typing",
767
770
  "aria-hidden": "true",
768
771
  children: [
769
- /* @__PURE__ */ U("span", {}),
770
- /* @__PURE__ */ U("span", {}),
771
- /* @__PURE__ */ U("span", {})
772
+ /* @__PURE__ */ H("span", {}),
773
+ /* @__PURE__ */ H("span", {}),
774
+ /* @__PURE__ */ H("span", {})
772
775
  ]
773
- }), e ? /* @__PURE__ */ U("span", {
776
+ }), e ? /* @__PURE__ */ H("span", {
774
777
  class: "whoo-widget-pending-text",
775
778
  children: "Looking that up for you…"
776
779
  }) : null]
777
780
  });
778
781
  }
779
- function Ye({ url: e, alt: t }) {
780
- let [n, r] = z(!1);
781
- return n ? null : /* @__PURE__ */ U("img", {
782
+ function Ze({ url: e, alt: t }) {
783
+ let [n, r] = R(!1);
784
+ return n ? null : /* @__PURE__ */ H("img", {
782
785
  class: "whoo-widget-empty-state-image",
783
786
  src: e,
784
787
  alt: t,
@@ -786,13 +789,13 @@ function Ye({ url: e, alt: t }) {
786
789
  onError: () => r(!0)
787
790
  });
788
791
  }
789
- function Xe({ message: e, feedbackState: t, showFeedback: n, pending: r, isSlowResponse: i, onThumbsUp: a, onThumbsDown: o, onSubmitDetailed: s, onCancelFeedback: c }) {
790
- let l = V(null), u = e.id;
791
- return /* @__PURE__ */ U("div", {
792
+ function Qe({ message: e, feedbackState: t, showFeedback: n, pending: r, isSlowResponse: i, onThumbsUp: a, onThumbsDown: o, onSubmitDetailed: s, onCancelFeedback: c }) {
793
+ let l = B(null), u = e.id;
794
+ return /* @__PURE__ */ H("div", {
792
795
  ref: l,
793
796
  tabIndex: -1,
794
797
  class: `whoo-widget-message whoo-widget-message--${e.role}`,
795
- children: [r ? /* @__PURE__ */ U(Je, { isSlowResponse: i }) : Ge(e.content), n && e.role === "assistant" && u ? /* @__PURE__ */ U(qe, {
798
+ children: [r ? /* @__PURE__ */ H(Xe, { isSlowResponse: i }) : qe(e.content), n && e.role === "assistant" && u ? /* @__PURE__ */ H(Ye, {
796
799
  state: t,
797
800
  containerRef: l,
798
801
  onThumbsUp: () => a(u),
@@ -802,15 +805,15 @@ function Xe({ message: e, feedbackState: t, showFeedback: n, pending: r, isSlowR
802
805
  }) : null]
803
806
  });
804
807
  }
805
- function Ze({ messages: e, messageFeedback: t, lastCompletedMessageText: n, emptyStateImage: r, showFeedback: i = !1, isStreaming: a = !1, isSlowResponse: o = !1, onThumbsUp: s, onThumbsDown: c, onSubmitDetailed: l, onCancelFeedback: u }) {
806
- let d = V(null);
807
- return B(() => {
808
+ function $e({ messages: e, messageFeedback: t, lastCompletedMessageText: n, emptyStateImage: r, showFeedback: i = !1, isStreaming: a = !1, isSlowResponse: o = !1, onThumbsUp: s, onThumbsDown: c, onSubmitDetailed: l, onCancelFeedback: u }) {
809
+ let d = B(null);
810
+ return z(() => {
808
811
  let e = d.current;
809
812
  e && (e.scrollTop = e.scrollHeight);
810
- }, [e, o]), /* @__PURE__ */ U(T, { children: [/* @__PURE__ */ U("div", {
813
+ }, [e, o]), /* @__PURE__ */ H(E, { children: [/* @__PURE__ */ H("div", {
811
814
  class: "whoo-widget-message-list",
812
815
  ref: d,
813
- children: [r ? /* @__PURE__ */ U(Ye, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ U(Xe, {
816
+ children: [r ? /* @__PURE__ */ H(Ze, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ H(Qe, {
814
817
  message: n,
815
818
  showFeedback: i,
816
819
  feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
@@ -821,7 +824,7 @@ function Ze({ messages: e, messageFeedback: t, lastCompletedMessageText: n, empt
821
824
  onSubmitDetailed: l,
822
825
  onCancelFeedback: u
823
826
  }, n.id ?? r))]
824
- }), /* @__PURE__ */ U("div", {
827
+ }), /* @__PURE__ */ H("div", {
825
828
  class: "whoo-widget-sr-only",
826
829
  "aria-live": "polite",
827
830
  "aria-atomic": "true",
@@ -830,79 +833,79 @@ function Ze({ messages: e, messageFeedback: t, lastCompletedMessageText: n, empt
830
833
  }
831
834
  //#endregion
832
835
  //#region src/components/Panel.tsx
833
- var Qe = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
834
- function $e(e) {
835
- return Array.from(e.querySelectorAll(Qe)).filter((e) => {
836
+ var et = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
837
+ function tt(e) {
838
+ return Array.from(e.querySelectorAll(et)).filter((e) => {
836
839
  let t = getComputedStyle(e);
837
840
  return t.display !== "none" && t.visibility !== "hidden";
838
841
  });
839
842
  }
840
- function et({ state: e, controller: t, greeting: n }) {
841
- let r = V(null), i = V(null);
842
- B(() => {
843
- i.current?.focus();
843
+ function nt({ state: e, controller: t, greeting: n }) {
844
+ let i = B(null), a = B(null);
845
+ z(() => {
846
+ a.current?.focus();
844
847
  }, []);
845
- let a = (e) => {
848
+ let o = (e) => {
846
849
  if (e.key === "Escape") {
847
850
  t.close();
848
851
  return;
849
852
  }
850
853
  if (e.key !== "Tab") return;
851
- let n = r.current;
854
+ let n = i.current;
852
855
  if (!n) return;
853
- let i = $e(n);
854
- if (i.length === 0) return;
855
- let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
856
+ let r = tt(n);
857
+ if (r.length === 0) return;
858
+ let a = r[0], o = r[r.length - 1], s = n.getRootNode().activeElement;
856
859
  if (!n.contains(s)) {
857
860
  e.preventDefault(), a.focus();
858
861
  return;
859
862
  }
860
863
  e.shiftKey && s === a ? (e.preventDefault(), o.focus()) : !e.shiftKey && s === o && (e.preventDefault(), a.focus());
861
- }, o = () => {
864
+ }, s = () => {
862
865
  let n = e.draft.trim();
863
866
  n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
864
- }, s = `Chat with ${e.agentName ?? (t.config.name?.trim() || "Aiden")}`, c = e.messages.length === 0 && n ? [{
867
+ }, c = `Chat with ${r(t.config.name) || e.agentName || "Aiden"}`, l = e.messages.length === 0 && n ? [{
865
868
  role: "assistant",
866
869
  content: n,
867
870
  id: null
868
- }] : e.messages, l = t.emptyStateImageUrl, u = e.messages.length === 0 && l ? {
869
- url: l,
871
+ }] : e.messages, u = t.emptyStateImageUrl, d = e.messages.length === 0 && u ? {
872
+ url: u,
870
873
  alt: t.emptyStateImageAlt
871
874
  } : void 0;
872
- return /* @__PURE__ */ U("div", {
875
+ return /* @__PURE__ */ H("div", {
873
876
  class: "whoo-widget-panel",
874
877
  role: "dialog",
875
878
  "aria-modal": "true",
876
- "aria-label": s,
877
- ref: r,
878
- onKeyDown: a,
879
+ "aria-label": c,
880
+ ref: i,
881
+ onKeyDown: o,
879
882
  children: [
880
- /* @__PURE__ */ U("div", {
883
+ /* @__PURE__ */ H("div", {
881
884
  class: "whoo-widget-header",
882
- children: [/* @__PURE__ */ U("h2", {
885
+ children: [/* @__PURE__ */ H("h2", {
883
886
  class: "whoo-widget-header-title",
884
- children: s
885
- }), /* @__PURE__ */ U("div", {
887
+ children: c
888
+ }), /* @__PURE__ */ H("div", {
886
889
  class: "whoo-widget-header-actions",
887
- children: [e.messages.length > 0 && /* @__PURE__ */ U("button", {
890
+ children: [e.messages.length > 0 && /* @__PURE__ */ H("button", {
888
891
  type: "button",
889
892
  class: "whoo-widget-header-reset",
890
893
  onClick: () => t.resetConversation(),
891
894
  children: "New conversation"
892
- }), /* @__PURE__ */ U("button", {
895
+ }), /* @__PURE__ */ H("button", {
893
896
  type: "button",
894
897
  class: "whoo-widget-header-close",
895
898
  "aria-label": "Close chat",
896
899
  onClick: () => t.close(),
897
- children: /* @__PURE__ */ U(Fe, {})
900
+ children: /* @__PURE__ */ H(Le, {})
898
901
  })]
899
902
  })]
900
903
  }),
901
- /* @__PURE__ */ U(Ze, {
902
- messages: c,
904
+ /* @__PURE__ */ H($e, {
905
+ messages: l,
903
906
  messageFeedback: e.messageFeedback,
904
907
  lastCompletedMessageText: e.lastCompletedMessageText,
905
- emptyStateImage: u,
908
+ emptyStateImage: d,
906
909
  showFeedback: t.showFeedback,
907
910
  isStreaming: e.isStreaming,
908
911
  isSlowResponse: e.isSlowResponse,
@@ -911,29 +914,29 @@ function et({ state: e, controller: t, greeting: n }) {
911
914
  onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
912
915
  onCancelFeedback: (e) => t.cancelFeedback(e)
913
916
  }),
914
- e.runtimeError && /* @__PURE__ */ U(Ve, { message: e.runtimeError }),
915
- /* @__PURE__ */ U(Be, {
917
+ e.runtimeError && /* @__PURE__ */ H(Ue, { message: e.runtimeError }),
918
+ /* @__PURE__ */ H(He, {
916
919
  value: e.draft,
917
920
  onChange: (e) => t.setDraft(e),
918
- onSend: o,
921
+ onSend: s,
919
922
  disabled: e.isStreaming,
920
- inputRef: i
923
+ inputRef: a
921
924
  })
922
925
  ]
923
926
  });
924
927
  }
925
928
  //#endregion
926
929
  //#region src/components/App.tsx
927
- function tt({ controller: e }) {
928
- let [t, n] = z(e.getState()), r = V(null), i = V(t.isOpen);
929
- return B(() => (n(e.getState()), e.subscribe(n)), [e]), B(() => {
930
+ function rt({ controller: e }) {
931
+ let [t, n] = R(e.getState()), r = B(null), i = B(t.isOpen);
932
+ return z(() => (n(e.getState()), e.subscribe(n)), [e]), z(() => {
930
933
  i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
931
- }, [t.isOpen]), t.initError ? null : /* @__PURE__ */ U(T, { children: [/* @__PURE__ */ U(ze, {
934
+ }, [t.isOpen]), t.initError ? null : /* @__PURE__ */ H(E, { children: [/* @__PURE__ */ H(Ve, {
932
935
  isOpen: t.isOpen,
933
936
  onClick: () => t.isOpen ? e.close() : e.open(),
934
937
  iconUrl: e.launcherIconUrl,
935
938
  buttonRef: r
936
- }), t.isOpen && /* @__PURE__ */ U(et, {
939
+ }), t.isOpen && /* @__PURE__ */ H(nt, {
937
940
  state: t,
938
941
  controller: e,
939
942
  greeting: e.config.greeting
@@ -941,13 +944,13 @@ function tt({ controller: e }) {
941
944
  }
942
945
  //#endregion
943
946
  //#region src/api/client.ts
944
- var nt = class extends Error {
947
+ var Y = class extends Error {
945
948
  status;
946
949
  constructor(e, t) {
947
950
  super(e), this.name = "WidgetApiError", this.status = t;
948
951
  }
949
952
  };
950
- function rt(e) {
953
+ function X(e) {
951
954
  if (typeof e != "string") return null;
952
955
  let t = e.trim();
953
956
  return t === "" ? null : t;
@@ -958,17 +961,27 @@ async function it(e, t) {
958
961
  headers: { "Content-Type": "application/json" },
959
962
  body: JSON.stringify({ publishable_key: t })
960
963
  });
961
- if (!n.ok) throw new nt(`Failed to create widget session (${n.status})`, n.status);
964
+ if (!n.ok) throw new Y(`Failed to create widget session (${n.status})`, n.status);
962
965
  let r = await n.json();
963
966
  return {
964
967
  token: r.token,
965
- primaryColor: r.primary_color ?? null,
966
- name: rt(r.name),
967
- accentColor: rt(r.accent_color),
968
- inkColor: rt(r.ink_color)
968
+ ...at(r)
969
969
  };
970
970
  }
971
- async function at(e, t, n) {
971
+ function at(e) {
972
+ return {
973
+ primaryColor: X(e.primary_color),
974
+ name: X(e.name),
975
+ accentColor: X(e.accent_color),
976
+ inkColor: X(e.ink_color)
977
+ };
978
+ }
979
+ async function ot(e, t) {
980
+ let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
981
+ if (!n.ok) throw new Y(`Failed to load widget branding (${n.status})`, n.status);
982
+ return at(await n.json());
983
+ }
984
+ async function st(e, t, n) {
972
985
  let r = await fetch(`${e}/api/v1/widget/feedback`, {
973
986
  method: "POST",
974
987
  headers: {
@@ -982,11 +995,11 @@ async function at(e, t, n) {
982
995
  category: n.category ?? null
983
996
  })
984
997
  });
985
- if (!r.ok) throw new nt(`Feedback submission failed (${r.status})`, r.status);
998
+ if (!r.ok) throw new Y(`Feedback submission failed (${r.status})`, r.status);
986
999
  }
987
1000
  //#endregion
988
1001
  //#region src/api/sse.ts
989
- async function* ot(e, t, n, r, i) {
1002
+ async function* ct(e, t, n, r, i) {
990
1003
  let a = await fetch(`${e}/api/v1/widget/chat`, {
991
1004
  method: "POST",
992
1005
  headers: {
@@ -999,7 +1012,7 @@ async function* ot(e, t, n, r, i) {
999
1012
  }),
1000
1013
  signal: i
1001
1014
  });
1002
- if (!a.ok || !a.body) throw new nt(`Chat request failed (${a.status})`, a.status);
1015
+ if (!a.ok || !a.body) throw new Y(`Chat request failed (${a.status})`, a.status);
1003
1016
  let o = a.body.getReader(), s = new TextDecoder(), c = "";
1004
1017
  for (;;) {
1005
1018
  let { done: e, value: t } = await o.read();
@@ -1010,11 +1023,11 @@ async function* ot(e, t, n, r, i) {
1010
1023
  let e = c.slice(0, n);
1011
1024
  c = c.slice(n + 2);
1012
1025
  let t = e.split("\n").find((e) => e.startsWith("data: "));
1013
- t && (yield st(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1026
+ t && (yield lt(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1014
1027
  }
1015
1028
  }
1016
1029
  }
1017
- function st(e) {
1030
+ function lt(e) {
1018
1031
  return typeof e.error == "string" ? {
1019
1032
  type: "error",
1020
1033
  error: e.error,
@@ -1037,7 +1050,7 @@ function st(e) {
1037
1050
  }
1038
1051
  //#endregion
1039
1052
  //#region src/imageUrl.ts
1040
- function ct(e, t) {
1053
+ function ut(e, t) {
1041
1054
  if (e != null && e !== "") {
1042
1055
  if (typeof e == "string") try {
1043
1056
  let t = new URL(e);
@@ -1048,16 +1061,16 @@ function ct(e, t) {
1048
1061
  }
1049
1062
  //#endregion
1050
1063
  //#region src/markdown/reveal.ts
1051
- var lt = 40, ut = 120;
1052
- function dt(e) {
1064
+ var dt = 40, ft = 120;
1065
+ function pt(e) {
1053
1066
  let t = [];
1054
- for (let n of We(e)) if (n.type === "text") {
1067
+ for (let n of Ke(e)) if (n.type === "text") {
1055
1068
  let e = n.value.split(/(\s+)/), r = n.start;
1056
1069
  for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
1057
1070
  } else t.push(n.end);
1058
1071
  return t;
1059
1072
  }
1060
- function ft(e) {
1073
+ function mt(e) {
1061
1074
  let t = null;
1062
1075
  return e?.addEventListener("abort", () => {
1063
1076
  t?.();
@@ -1072,36 +1085,154 @@ function ft(e) {
1072
1085
  });
1073
1086
  };
1074
1087
  }
1075
- async function pt(e, t, n) {
1076
- let r = n?.wordIntervalMs ?? lt, i = n?.tokenIntervalMs ?? ut, a = n?.signal, o = We(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = ft(a), l = "";
1077
- for (let n of dt(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1088
+ async function ht(e, t, n) {
1089
+ let r = n?.wordIntervalMs ?? dt, i = n?.tokenIntervalMs ?? ft, a = n?.signal, o = Ke(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = mt(a), l = "";
1090
+ for (let n of pt(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1078
1091
  l !== e && t(e);
1079
1092
  }
1080
1093
  //#endregion
1081
1094
  //#region src/storage.ts
1082
- function mt(e) {
1095
+ function gt(e) {
1083
1096
  return `whoo-aiden-widget:conversation:${e}`;
1084
1097
  }
1085
- function ht(e) {
1098
+ function _t(e) {
1086
1099
  try {
1087
- return window.sessionStorage.getItem(mt(e));
1100
+ return window.sessionStorage.getItem(gt(e));
1088
1101
  } catch {
1089
1102
  return null;
1090
1103
  }
1091
1104
  }
1092
- function gt(e, t) {
1105
+ function vt(e, t) {
1093
1106
  try {
1094
- window.sessionStorage.setItem(mt(e), t);
1107
+ window.sessionStorage.setItem(gt(e), t);
1095
1108
  } catch {}
1096
1109
  }
1097
- function _t(e) {
1110
+ function yt(e) {
1098
1111
  try {
1099
- window.sessionStorage.removeItem(mt(e));
1112
+ window.sessionStorage.removeItem(gt(e));
1100
1113
  } catch {}
1101
1114
  }
1102
1115
  //#endregion
1116
+ //#region src/theme.ts
1117
+ var bt = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1118
+ function xt(e) {
1119
+ if (bt.test(e.trim())) return null;
1120
+ let t = document.createElement("div");
1121
+ if (t.style.color = e, t.style.color === "") return null;
1122
+ let n = document.createElement("div");
1123
+ n.attachShadow({ mode: "open" }).appendChild(t), document.body.appendChild(n);
1124
+ let r = getComputedStyle(t).color;
1125
+ n.remove();
1126
+ let i = r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);
1127
+ if (!i) return null;
1128
+ let a = i[4] === void 0 ? 1 : Number(i[4]);
1129
+ return {
1130
+ rgb: [
1131
+ Number(i[1]),
1132
+ Number(i[2]),
1133
+ Number(i[3])
1134
+ ].map((e) => Math.round(e * a + 255 * (1 - a))),
1135
+ translucent: a < 1
1136
+ };
1137
+ }
1138
+ function St(e) {
1139
+ return xt(e)?.rgb ?? null;
1140
+ }
1141
+ function Z([e, t, n]) {
1142
+ let r = (e) => {
1143
+ let t = e / 255;
1144
+ return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
1145
+ };
1146
+ return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
1147
+ }
1148
+ function Ct(e, t) {
1149
+ let n = Math.max(e, t), r = Math.min(e, t);
1150
+ return (n + .05) / (r + .05);
1151
+ }
1152
+ function wt(e) {
1153
+ let t = St(e);
1154
+ if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
1155
+ let n = Z(t);
1156
+ return Ct(n, Z([
1157
+ 0,
1158
+ 0,
1159
+ 0
1160
+ ])) >= Ct(n, Z([
1161
+ 255,
1162
+ 255,
1163
+ 255
1164
+ ])) ? "#000000" : "#ffffff";
1165
+ }
1166
+ var Q = "#4f46e5", Tt = "#ffffff", Et = "#f0f0f0", Dt = 4.5;
1167
+ function Ot([e, t, n]) {
1168
+ return `#${[
1169
+ e,
1170
+ t,
1171
+ n
1172
+ ].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
1173
+ }
1174
+ function kt(e, t = Tt) {
1175
+ let n = St(e), r = St(t);
1176
+ if (!n || !r) return Q;
1177
+ let i = Z(r), a = (e) => Ct(Z(e), i) >= Dt;
1178
+ if (a(n)) return Ot(n);
1179
+ for (let e = .99; e > 0; e -= .01) {
1180
+ let t = n.map((t) => Math.round(t * e));
1181
+ if (a(t)) return Ot(t);
1182
+ }
1183
+ return "#000000";
1184
+ }
1185
+ var At = "#111111", jt = "#0000ee";
1186
+ function $(e) {
1187
+ if (typeof e != "string" || !e) return null;
1188
+ let t = xt(e);
1189
+ return t ? Ot(t.rgb) : null;
1190
+ }
1191
+ function Mt({ color: e, inkColor: t, accentColor: n }) {
1192
+ let r = $(e), i = r ?? Q, a = kt(i), o = $(t), s = o ? kt(o, Et) : At, c = $(n), l = c ? kt(c, Et) : jt;
1193
+ return {
1194
+ primary: i,
1195
+ textOnPrimary: wt(i),
1196
+ primaryAsText: a,
1197
+ ink: s,
1198
+ link: l,
1199
+ adjusted: {
1200
+ primary: r !== null && a !== i,
1201
+ ink: o !== null && s !== o,
1202
+ link: c !== null && l !== c
1203
+ }
1204
+ };
1205
+ }
1206
+ function Nt(e) {
1207
+ return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
1208
+ }
1209
+ function Pt(e, t, n = Q) {
1210
+ let r = t;
1211
+ $(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Nt(t)} as the theme color; falling back to ${Nt(n)}.`), r = n);
1212
+ let i = Mt({ color: r });
1213
+ 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);
1214
+ }
1215
+ function Ft(e, { inkColor: t, accentColor: n }) {
1216
+ let r = Mt({
1217
+ inkColor: t,
1218
+ accentColor: n
1219
+ });
1220
+ e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
1221
+ }
1222
+ function It(e, t) {
1223
+ e && $(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Nt(e)} as the ${t}; using the default.`);
1224
+ }
1225
+ function Lt(e, t) {
1226
+ Pt(e, t.color ?? Q), It(t.inkColor, "ink color"), It(t.accentColor, "accent color"), Ft(e, {
1227
+ inkColor: t.inkColor,
1228
+ accentColor: t.accentColor
1229
+ });
1230
+ let n = t.position === "bottom-left";
1231
+ e.style.setProperty("--whoo-widget-inset-left", n ? "20px" : "auto"), e.style.setProperty("--whoo-widget-inset-right", n ? "auto" : "20px");
1232
+ }
1233
+ //#endregion
1103
1234
  //#region src/controller.ts
1104
- var vt = 8e3, yt = class {
1235
+ var Rt = 8e3, zt = class {
1105
1236
  config;
1106
1237
  state;
1107
1238
  listeners = /* @__PURE__ */ new Set();
@@ -1116,7 +1247,7 @@ var vt = 8e3, yt = class {
1116
1247
  emptyStateImageAlt;
1117
1248
  showFeedback;
1118
1249
  constructor(e) {
1119
- this.config = e, this.launcherIconUrl = ct(e.launcherIconUrl, "launcherIconUrl"), this.emptyStateImageUrl = ct(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.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
1250
+ this.config = e, this.launcherIconUrl = ut(e.launcherIconUrl, "launcherIconUrl"), this.emptyStateImageUrl = ut(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.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
1120
1251
  isOpen: !1,
1121
1252
  messages: [],
1122
1253
  isStreaming: !1,
@@ -1165,13 +1296,26 @@ var vt = 8e3, yt = class {
1165
1296
  console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
1166
1297
  return;
1167
1298
  }
1168
- this.conversationId = ht(this.storageIdentifier);
1299
+ this.conversationId = _t(this.storageIdentifier), this.config.sessionToken && await this.loadBranding(e, this.config.sessionToken);
1300
+ }
1301
+ async loadBranding(e, t) {
1302
+ try {
1303
+ let n = this.config;
1304
+ if ($(n.color) && $(n.inkColor) && $(n.accentColor) && r(n.name)) return;
1305
+ let { primaryColor: i, name: a, accentColor: o, inkColor: s } = await ot(e, t);
1306
+ this.setState({
1307
+ primaryColor: i,
1308
+ agentName: a,
1309
+ accentColor: o,
1310
+ inkColor: s
1311
+ });
1312
+ } catch {}
1169
1313
  }
1170
1314
  open() {
1171
1315
  this.setState({ isOpen: !0 });
1172
1316
  }
1173
1317
  resetConversation() {
1174
- this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, _t(this.storageIdentifier), this.setState({
1318
+ this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, yt(this.storageIdentifier), this.setState({
1175
1319
  messages: [],
1176
1320
  messageFeedback: {},
1177
1321
  runtimeError: null,
@@ -1216,7 +1360,7 @@ var vt = 8e3, yt = class {
1216
1360
  let { signal: a } = this.activeRequestController;
1217
1361
  this.slowResponseTimer = setTimeout(() => {
1218
1362
  this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
1219
- }, vt);
1363
+ }, Rt);
1220
1364
  let o = () => {
1221
1365
  this.setState({
1222
1366
  runtimeError: "Something went wrong, please try again.",
@@ -1224,10 +1368,10 @@ var vt = 8e3, yt = class {
1224
1368
  });
1225
1369
  }, s = "";
1226
1370
  try {
1227
- for await (let n of ot(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, gt(this.storageIdentifier, n.conversationId);
1228
- else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await pt(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
1371
+ for await (let n of ct(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, vt(this.storageIdentifier, n.conversationId);
1372
+ else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await ht(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
1229
1373
  else if (n.type === "done") {
1230
- if (n.conversationId && (this.conversationId = n.conversationId, gt(this.storageIdentifier, n.conversationId)), n.messageId) {
1374
+ if (n.conversationId && (this.conversationId = n.conversationId, vt(this.storageIdentifier, n.conversationId)), n.messageId) {
1231
1375
  let e = [...this.state.messages];
1232
1376
  e[e.length - 1] = {
1233
1377
  ...e[e.length - 1],
@@ -1268,7 +1412,7 @@ var vt = 8e3, yt = class {
1268
1412
  }
1269
1413
  } });
1270
1414
  try {
1271
- await at(i, this.sessionToken, {
1415
+ await st(i, this.sessionToken, {
1272
1416
  messageId: e,
1273
1417
  rating: t,
1274
1418
  correction: n,
@@ -1290,144 +1434,32 @@ var vt = 8e3, yt = class {
1290
1434
  } });
1291
1435
  }
1292
1436
  }
1293
- }, bt = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:20px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:var(--whoo-widget-color,#4f46e5);width:56px;height:56px;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{display:block}.whoo-widget-launcher-icon-image{object-fit:cover;border-radius:50%;width:32px;height:32px}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:88px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:#fff;border-radius:12px;flex-direction:column;width:360px;max-width:calc(100vw - 40px);height:480px;max-height:calc(100vh - 108px);display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid #e5e5e5;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;display:flex}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:15px;font-weight:600;overflow:hidden}.whoo-widget-header-actions{flex-shrink:0;align-items:center;gap:4px;display:flex}.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:#f3f4f6}.whoo-widget-message-list{flex:1;min-height:100px;padding:12px;overflow-y:auto}.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{white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{color:var(--whoo-widget-ink,#111);background:#f0f0f0}.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:#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{color:#991b1b;background:#fee2e2;padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid #e5e5e5;gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid #6b7280;border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send:disabled,.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:#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:#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;resize:vertical;border:1px solid #6b7280;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid #6b7280;border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{color:#111;cursor:pointer;background:#fff;border:1px solid #6b7280;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:#6b7280;margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:#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-offset:2px;outline:2px solid #111827;box-shadow:0 0 0 4px #fff}", xt = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1294
- function St(e) {
1295
- if (xt.test(e.trim())) return null;
1296
- let t = document.createElement("div");
1297
- if (t.style.color = e, t.style.color === "") return null;
1298
- let n = document.createElement("div");
1299
- n.attachShadow({ mode: "open" }).appendChild(t), document.body.appendChild(n);
1300
- let r = getComputedStyle(t).color;
1301
- n.remove();
1302
- let i = r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);
1303
- if (!i) return null;
1304
- let a = i[4] === void 0 ? 1 : Number(i[4]);
1305
- return {
1306
- rgb: [
1307
- Number(i[1]),
1308
- Number(i[2]),
1309
- Number(i[3])
1310
- ].map((e) => Math.round(e * a + 255 * (1 - a))),
1311
- translucent: a < 1
1312
- };
1313
- }
1314
- function Ct(e) {
1315
- return St(e)?.rgb ?? null;
1316
- }
1317
- function X([e, t, n]) {
1318
- let r = (e) => {
1319
- let t = e / 255;
1320
- return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
1321
- };
1322
- return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
1323
- }
1324
- function Z(e, t) {
1325
- let n = Math.max(e, t), r = Math.min(e, t);
1326
- return (n + .05) / (r + .05);
1327
- }
1328
- function wt(e) {
1329
- let t = Ct(e);
1330
- if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
1331
- let n = X(t);
1332
- return Z(n, X([
1333
- 0,
1334
- 0,
1335
- 0
1336
- ])) >= Z(n, X([
1337
- 255,
1338
- 255,
1339
- 255
1340
- ])) ? "#000000" : "#ffffff";
1341
- }
1342
- var Q = "#4f46e5", Tt = "#ffffff", Et = "#f0f0f0", Dt = 4.5;
1343
- function Ot([e, t, n]) {
1344
- return `#${[
1345
- e,
1346
- t,
1347
- n
1348
- ].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
1349
- }
1350
- function kt(e, t = Tt) {
1351
- let n = Ct(e), r = Ct(t);
1352
- if (!n || !r) return Q;
1353
- let i = X(r), a = (e) => Z(X(e), i) >= Dt;
1354
- if (a(n)) return Ot(n);
1355
- for (let e = .99; e > 0; e -= .01) {
1356
- let t = n.map((t) => Math.round(t * e));
1357
- if (a(t)) return Ot(t);
1358
- }
1359
- return "#000000";
1360
- }
1361
- var At = "#111111", jt = "#0000ee";
1362
- function $(e) {
1363
- if (!e) return null;
1364
- let t = St(e);
1365
- return t ? Ot(t.rgb) : null;
1366
- }
1367
- function Mt({ color: e, inkColor: t, accentColor: n }) {
1368
- let r = $(e), i = r ?? Q, a = kt(i), o = $(t), s = o ? kt(o, Et) : At, c = $(n), l = c ? kt(c, Et) : jt;
1369
- return {
1370
- primary: i,
1371
- textOnPrimary: wt(i),
1372
- primaryAsText: a,
1373
- ink: s,
1374
- link: l,
1375
- adjusted: {
1376
- primary: r !== null && a !== i,
1377
- ink: o !== null && s !== o,
1378
- link: c !== null && l !== c
1379
- }
1380
- };
1381
- }
1382
- function Nt(e, t, n = Q) {
1383
- let r = t;
1384
- $(t) === null && (console.warn(`[whoo-aiden-widget] Could not use "${t}" as the theme color; falling back to "${n}".`), r = n);
1385
- let i = Mt({ color: r });
1386
- 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);
1387
- }
1388
- function Pt(e, { inkColor: t, accentColor: n }) {
1389
- let r = Mt({
1390
- inkColor: t,
1391
- accentColor: n
1392
- });
1393
- e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
1394
- }
1395
- function Ft(e, t) {
1396
- e && $(e) === null && console.warn(`[whoo-aiden-widget] Could not use "${e}" as the ${t}; using the default.`);
1397
- }
1398
- function It(e, t) {
1399
- Nt(e, t.color ?? Q), Ft(t.inkColor, "ink color"), Ft(t.accentColor, "accent color"), Pt(e, {
1400
- inkColor: t.inkColor,
1401
- accentColor: t.accentColor
1402
- });
1403
- let n = t.position === "bottom-left";
1404
- e.style.setProperty("--whoo-widget-inset-left", n ? "20px" : "auto"), e.style.setProperty("--whoo-widget-inset-right", n ? "auto" : "20px");
1405
- }
1437
+ }, Bt = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:20px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:var(--whoo-widget-color,#4f46e5);width:56px;height:56px;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{display:block}.whoo-widget-launcher-icon-image{object-fit:cover;border-radius:50%;width:32px;height:32px}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:88px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:#fff;border-radius:12px;flex-direction:column;width:360px;max-width:calc(100vw - 40px);height:480px;max-height:calc(100vh - 108px);display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid #e5e5e5;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;display:flex}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:15px;font-weight:600;overflow:hidden}.whoo-widget-header-actions{flex-shrink:0;align-items:center;gap:4px;display:flex}.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:#f3f4f6}.whoo-widget-message-list{flex:1;min-height:100px;padding:12px;overflow-y:auto}.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{white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{color:var(--whoo-widget-ink,#111);background:#f0f0f0}.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:#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{color:#991b1b;background:#fee2e2;padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid #e5e5e5;gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid #6b7280;border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send:disabled,.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:#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:#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;resize:vertical;border:1px solid #6b7280;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid #6b7280;border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{color:#111;cursor:pointer;background:#fff;border:1px solid #6b7280;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:#6b7280;margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:#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-offset:2px;outline:2px solid #111827;box-shadow:0 0 0 4px #fff}";
1406
1438
  //#endregion
1407
1439
  //#region src/mount.tsx
1408
- function Lt(e) {
1440
+ function Vt(e) {
1409
1441
  let t = document.createElement("div");
1410
1442
  t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(n(e.zIndex));
1411
1443
  let r = t.attachShadow({ mode: "open" }), i = document.createElement("style");
1412
- i.textContent = bt, r.appendChild(i);
1444
+ i.textContent = Bt, r.appendChild(i);
1413
1445
  let a = document.createElement("div");
1414
- r.appendChild(a), It(a, e);
1415
- let o = new yt(e), s = null, c = "";
1446
+ r.appendChild(a), Lt(a, e);
1447
+ let o = new zt(e), s = $(e.color) !== null, c = null, l = "";
1416
1448
  return o.subscribe((t) => {
1417
- t.primaryColor && t.primaryColor !== s && (s = t.primaryColor, Nt(a, t.primaryColor, e.color));
1449
+ !s && t.primaryColor && t.primaryColor !== c && (c = t.primaryColor, Pt(a, t.primaryColor, e.color));
1418
1450
  let n = `${t.inkColor}|${t.accentColor}`;
1419
- (t.inkColor || t.accentColor) && n !== c && (c = n, Pt(a, {
1420
- inkColor: $(t.inkColor) ? t.inkColor : e.inkColor,
1421
- accentColor: $(t.accentColor) ? t.accentColor : e.accentColor
1451
+ (t.inkColor || t.accentColor) && n !== l && (l = n, Ft(a, {
1452
+ inkColor: $(e.inkColor) ? e.inkColor : t.inkColor,
1453
+ accentColor: $(e.accentColor) ? e.accentColor : t.accentColor
1422
1454
  }));
1423
- }), pe(/* @__PURE__ */ U(tt, { controller: o }), a), o.init(), document.body.appendChild(t), { unmount() {
1424
- pe(null, a), t.remove();
1455
+ }), he(/* @__PURE__ */ H(rt, { controller: o }), a), o.init(), document.body.appendChild(t), { unmount() {
1456
+ he(null, a), t.remove();
1425
1457
  } };
1426
1458
  }
1427
1459
  //#endregion
1428
1460
  //#region src/index.ts
1429
- function Rt(e) {
1430
- return r(e), Lt(e);
1461
+ function Ht(e) {
1462
+ return i(e), Vt(e);
1431
1463
  }
1432
1464
  //#endregion
1433
- export { Rt as init, Mt as resolveTheme };
1465
+ export { Ht as init, Mt as resolveTheme };