@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/README.md +18 -6
- package/dist/api/client.d.ts +5 -2
- package/dist/components/App.d.ts +1 -1
- package/dist/components/Composer.d.ts +1 -1
- package/dist/components/ErrorBanner.d.ts +1 -1
- package/dist/components/Launcher.d.ts +1 -1
- package/dist/components/MessageFeedback.d.ts +1 -1
- package/dist/components/MessageList.d.ts +1 -1
- package/dist/components/Panel.d.ts +1 -1
- package/dist/components/icons.d.ts +5 -5
- package/dist/config.d.ts +1 -0
- package/dist/controller.d.ts +1 -0
- package/dist/theme.d.ts +1 -1
- package/dist/types.d.ts +7 -5
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +4 -4
- package/dist/widget.js +498 -466
- package/package.json +1 -1
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
|
|
11
|
-
function
|
|
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
|
|
19
|
-
var r,
|
|
20
|
-
for (o in t) o == "key" ? r = t[o] : o == "ref" ?
|
|
21
|
-
if (arguments.length > 2 && (s.children = arguments.length > 3 ?
|
|
22
|
-
return
|
|
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
|
|
25
|
-
var
|
|
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 ?? ++
|
|
39
|
+
__v: i ?? ++s,
|
|
37
40
|
__i: -1,
|
|
38
41
|
__u: 0
|
|
39
42
|
};
|
|
40
|
-
return i == null &&
|
|
43
|
+
return i == null && o.vnode != null && o.vnode(a), a;
|
|
41
44
|
}
|
|
42
|
-
function
|
|
45
|
+
function E(e) {
|
|
43
46
|
return e.children;
|
|
44
47
|
}
|
|
45
|
-
function
|
|
48
|
+
function D(e, t) {
|
|
46
49
|
this.props = e, this.context = t;
|
|
47
50
|
}
|
|
48
|
-
function
|
|
49
|
-
if (t == null) return e.__ ?
|
|
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" ?
|
|
54
|
+
return typeof e.type == "function" ? O(e) : null;
|
|
52
55
|
}
|
|
53
|
-
function
|
|
56
|
+
function k(e) {
|
|
54
57
|
if (e.__P && e.__d) {
|
|
55
|
-
var t = e.__v, n = t.__e, r = [], i = [],
|
|
56
|
-
|
|
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
|
|
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
|
-
}),
|
|
65
|
+
}), A(e);
|
|
63
66
|
}
|
|
64
|
-
function
|
|
65
|
-
(!e.__d && (e.__d = !0) &&
|
|
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
|
|
70
|
+
function M() {
|
|
68
71
|
try {
|
|
69
|
-
for (var e, t = 1;
|
|
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
|
-
|
|
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 ||
|
|
76
|
-
for (c =
|
|
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
|
|
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] =
|
|
82
|
-
if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r =
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
|
106
|
-
t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" ||
|
|
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
|
|
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 ||
|
|
114
|
-
if (n) for (t in n) r && n[t] == r[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(
|
|
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
|
|
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[
|
|
131
|
-
else if (t[
|
|
132
|
-
return n(
|
|
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
|
|
137
|
-
var d, f, p, m, h, g, _, v,
|
|
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),
|
|
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 (
|
|
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 (
|
|
146
|
-
t.__v != n.__v && (p.props =
|
|
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
|
-
}),
|
|
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(
|
|
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 =
|
|
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 =
|
|
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 ||
|
|
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
|
-
|
|
165
|
-
} else if (
|
|
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 ||
|
|
170
|
+
t.__k ??= n.__k || [], e.then || ce(t), o.__e(e, t, n);
|
|
168
171
|
}
|
|
169
|
-
} else
|
|
170
|
-
return (d =
|
|
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
|
|
173
|
-
e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(
|
|
175
|
+
function ce(e) {
|
|
176
|
+
e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(ce));
|
|
174
177
|
}
|
|
175
|
-
function
|
|
176
|
-
for (var r = 0; r < n.length; r++)
|
|
177
|
-
|
|
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
|
-
|
|
186
|
+
o.__e(e, t.__v);
|
|
184
187
|
}
|
|
185
188
|
});
|
|
186
189
|
}
|
|
187
|
-
function
|
|
188
|
-
return typeof e != "object" || !e || e.__b > 0 ? e :
|
|
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
|
|
191
|
-
var d, f, p, m, h, g, _,
|
|
192
|
-
if (
|
|
193
|
-
for (d = 0; d < s.length; d++) if ((h = s[d]) && "setAttribute" in h == !!
|
|
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 (
|
|
200
|
-
e = document.createElementNS(
|
|
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 (
|
|
205
|
+
if (x == null) v === b || l && e.data == b || (e.data = b);
|
|
203
206
|
else {
|
|
204
|
-
if (s =
|
|
205
|
-
for (d in
|
|
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" ||
|
|
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,
|
|
209
|
-
l &&
|
|
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
|
|
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
|
-
|
|
223
|
+
o.__e(e, n);
|
|
221
224
|
}
|
|
222
225
|
}
|
|
223
|
-
function
|
|
226
|
+
function pe(e, t, n) {
|
|
224
227
|
var r, i;
|
|
225
|
-
if (
|
|
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
|
-
|
|
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] &&
|
|
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
|
|
239
|
+
function me(e, t, n) {
|
|
237
240
|
return this.constructor(e, n);
|
|
238
241
|
}
|
|
239
|
-
function
|
|
240
|
-
var r,
|
|
241
|
-
t == document && (t = document.documentElement),
|
|
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
|
-
|
|
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
|
-
} },
|
|
251
|
-
var n = this.__s != null && this.__s != this.state ? this.__s : this.__s =
|
|
252
|
-
typeof e == "function" && (e = e(
|
|
253
|
-
},
|
|
254
|
-
this.__v && (this.__e = !0, e && this.__h.push(e),
|
|
255
|
-
},
|
|
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
|
-
},
|
|
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
|
|
261
|
-
function
|
|
262
|
-
|
|
263
|
-
var n =
|
|
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
|
|
270
|
-
return
|
|
272
|
+
function R(e) {
|
|
273
|
+
return I = 1, Ee(Ne, e);
|
|
271
274
|
}
|
|
272
|
-
function
|
|
273
|
-
var r =
|
|
274
|
-
if (r.t = e, !r.__c && (r.__ = [n ? n(t) :
|
|
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 =
|
|
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
|
-
|
|
294
|
-
var a =
|
|
295
|
-
|
|
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
|
-
},
|
|
304
|
+
}, F.shouldComponentUpdate = i;
|
|
302
305
|
}
|
|
303
306
|
return r.__N || r.__;
|
|
304
307
|
}
|
|
305
|
-
function
|
|
306
|
-
var n =
|
|
307
|
-
!
|
|
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
|
|
310
|
-
return
|
|
312
|
+
function B(e) {
|
|
313
|
+
return I = 5, De(function() {
|
|
311
314
|
return { current: e };
|
|
312
315
|
}, []);
|
|
313
316
|
}
|
|
314
|
-
function
|
|
315
|
-
var n =
|
|
316
|
-
return
|
|
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
|
|
319
|
-
for (var e; e =
|
|
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(
|
|
325
|
+
t.__h.some(V), t.__h.some(je), t.__h = [];
|
|
323
326
|
} catch (n) {
|
|
324
|
-
t.__h = [],
|
|
327
|
+
t.__h = [], L.__e(n, e.__v);
|
|
325
328
|
}
|
|
326
329
|
}
|
|
327
330
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
},
|
|
331
|
-
e && t.__k && t.__k.__m && (e.__m = t.__k.__m),
|
|
332
|
-
},
|
|
333
|
-
|
|
334
|
-
var t = (
|
|
335
|
-
t && (
|
|
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(
|
|
338
|
-
},
|
|
339
|
-
|
|
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 && (
|
|
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
|
-
})),
|
|
344
|
-
},
|
|
346
|
+
})), ge = F = null;
|
|
347
|
+
}, L.__c = function(e, t) {
|
|
345
348
|
t.some(function(e) {
|
|
346
349
|
try {
|
|
347
|
-
e.__h.some(
|
|
348
|
-
return !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 = [],
|
|
356
|
+
}), t = [], L.__e(n, e.__v);
|
|
354
357
|
}
|
|
355
|
-
}),
|
|
356
|
-
},
|
|
357
|
-
|
|
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
|
-
|
|
364
|
+
V(e);
|
|
362
365
|
} catch (e) {
|
|
363
366
|
t = e;
|
|
364
367
|
}
|
|
365
|
-
}), n.__H = void 0, t &&
|
|
368
|
+
}), n.__H = void 0, t && L.__e(t, n.__v));
|
|
366
369
|
};
|
|
367
|
-
var
|
|
368
|
-
function
|
|
370
|
+
var ke = typeof requestAnimationFrame == "function";
|
|
371
|
+
function Ae(e) {
|
|
369
372
|
var t, n = function() {
|
|
370
|
-
clearTimeout(r),
|
|
373
|
+
clearTimeout(r), ke && cancelAnimationFrame(t), setTimeout(e);
|
|
371
374
|
}, r = setTimeout(n, 35);
|
|
372
|
-
|
|
375
|
+
ke && (t = requestAnimationFrame(n));
|
|
373
376
|
}
|
|
374
|
-
function
|
|
375
|
-
var t =
|
|
376
|
-
typeof n == "function" && (e.__c = void 0, n()),
|
|
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
|
|
379
|
-
var t =
|
|
380
|
-
e.__c = e.__(),
|
|
381
|
+
function je(e) {
|
|
382
|
+
var t = F;
|
|
383
|
+
e.__c = e.__(), F = t;
|
|
381
384
|
}
|
|
382
|
-
function
|
|
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
|
|
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
|
|
395
|
+
var Pe = 0;
|
|
393
396
|
Array.isArray;
|
|
394
|
-
function
|
|
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: --
|
|
412
|
+
__v: --Pe,
|
|
410
413
|
__i: -1,
|
|
411
414
|
__u: 0,
|
|
412
415
|
__source: i,
|
|
413
|
-
__self:
|
|
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
|
|
419
|
+
return o.vnode && o.vnode(u), u;
|
|
417
420
|
}
|
|
418
421
|
//#endregion
|
|
419
422
|
//#region src/components/icons.tsx
|
|
420
|
-
function
|
|
421
|
-
return /* @__PURE__ */
|
|
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
|
|
437
|
-
return /* @__PURE__ */ U
|
|
439
|
+
function Fe({ size: e = 26 }) {
|
|
440
|
+
return /* @__PURE__ */ H(U, {
|
|
438
441
|
name: "chat",
|
|
439
442
|
size: e,
|
|
440
|
-
children: [/* @__PURE__ */
|
|
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
|
|
447
|
-
return /* @__PURE__ */ U
|
|
449
|
+
function Ie({ size: e = 26 }) {
|
|
450
|
+
return /* @__PURE__ */ H(U, {
|
|
448
451
|
name: "chevron-down",
|
|
449
452
|
size: e,
|
|
450
|
-
children: /* @__PURE__ */
|
|
453
|
+
children: /* @__PURE__ */ H("path", { d: "M6 9l6 6 6-6" })
|
|
451
454
|
});
|
|
452
455
|
}
|
|
453
|
-
function
|
|
454
|
-
return /* @__PURE__ */ U
|
|
456
|
+
function Le({ size: e = 18 }) {
|
|
457
|
+
return /* @__PURE__ */ H(U, {
|
|
455
458
|
name: "close",
|
|
456
459
|
size: e,
|
|
457
|
-
children: /* @__PURE__ */
|
|
460
|
+
children: /* @__PURE__ */ H("path", { d: "M6 6l12 12M18 6L6 18" })
|
|
458
461
|
});
|
|
459
462
|
}
|
|
460
|
-
var
|
|
461
|
-
function
|
|
462
|
-
return /* @__PURE__ */ U
|
|
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__ */
|
|
468
|
+
children: /* @__PURE__ */ H("path", { d: Re })
|
|
466
469
|
});
|
|
467
470
|
}
|
|
468
|
-
function
|
|
469
|
-
return /* @__PURE__ */ U
|
|
471
|
+
function Be({ size: e = 16 }) {
|
|
472
|
+
return /* @__PURE__ */ H(U, {
|
|
470
473
|
name: "thumb-down",
|
|
471
474
|
size: e,
|
|
472
|
-
children: /* @__PURE__ */
|
|
473
|
-
d:
|
|
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
|
|
481
|
-
let [i, a] =
|
|
482
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
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
|
|
502
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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
|
|
535
|
-
return /* @__PURE__ */
|
|
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
|
|
544
|
-
function
|
|
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") && (
|
|
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:
|
|
560
|
-
}), 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
|
-
|
|
574
|
-
let a =
|
|
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:
|
|
582
|
-
}), n =
|
|
584
|
+
end: W.lastIndex
|
|
585
|
+
}), n = W.lastIndex, r = n;
|
|
583
586
|
continue;
|
|
584
587
|
}
|
|
585
588
|
}
|
|
586
|
-
|
|
587
|
-
let a =
|
|
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:
|
|
594
|
-
}), n =
|
|
596
|
+
end: G.lastIndex
|
|
597
|
+
}), n = G.lastIndex, r = n;
|
|
595
598
|
continue;
|
|
596
599
|
}
|
|
597
|
-
|
|
598
|
-
let o =
|
|
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:
|
|
605
|
-
}), n =
|
|
607
|
+
end: K.lastIndex
|
|
608
|
+
}), n = K.lastIndex, r = n;
|
|
606
609
|
continue;
|
|
607
610
|
}
|
|
608
|
-
|
|
609
|
-
let s =
|
|
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:
|
|
616
|
-
}), n =
|
|
618
|
+
end: q.lastIndex
|
|
619
|
+
}), n = q.lastIndex, r = n;
|
|
617
620
|
continue;
|
|
618
621
|
}
|
|
619
|
-
|
|
620
|
-
let c =
|
|
622
|
+
We.lastIndex = n;
|
|
623
|
+
let c = We.exec(e);
|
|
621
624
|
if (c) {
|
|
622
|
-
let e = c[0].match(
|
|
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
|
|
641
|
-
return
|
|
643
|
+
function qe(e) {
|
|
644
|
+
return Ke(e).map((e, t) => {
|
|
642
645
|
switch (e.type) {
|
|
643
|
-
case "bold": return /* @__PURE__ */
|
|
644
|
-
case "italic": return /* @__PURE__ */
|
|
645
|
-
case "link": return /* @__PURE__ */
|
|
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__ */
|
|
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
|
|
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
|
|
683
|
-
let [o, s] =
|
|
684
|
-
if (
|
|
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__ */
|
|
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__ */
|
|
699
|
+
if (e.status === "expanded") return /* @__PURE__ */ H("div", {
|
|
697
700
|
class: "whoo-widget-feedback-form",
|
|
698
701
|
children: [
|
|
699
|
-
/* @__PURE__ */
|
|
702
|
+
/* @__PURE__ */ H("label", { children: [/* @__PURE__ */ H("span", {
|
|
700
703
|
class: "whoo-widget-sr-only",
|
|
701
704
|
children: "Additional feedback"
|
|
702
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
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:
|
|
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__ */
|
|
721
|
+
/* @__PURE__ */ H("div", {
|
|
719
722
|
class: "whoo-widget-feedback-form-buttons",
|
|
720
|
-
children: [/* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
738
|
+
return /* @__PURE__ */ H("div", {
|
|
736
739
|
class: "whoo-widget-feedback",
|
|
737
|
-
children: [/* @__PURE__ */
|
|
740
|
+
children: [/* @__PURE__ */ H("div", {
|
|
738
741
|
class: "whoo-widget-feedback-buttons",
|
|
739
|
-
children: [/* @__PURE__ */
|
|
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__ */
|
|
745
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
753
|
+
children: /* @__PURE__ */ H(Be, {})
|
|
751
754
|
})]
|
|
752
|
-
}), e.status === "error" ? /* @__PURE__ */
|
|
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
|
|
762
|
-
return /* @__PURE__ */
|
|
764
|
+
function Xe({ isSlowResponse: e }) {
|
|
765
|
+
return /* @__PURE__ */ H("div", {
|
|
763
766
|
class: "whoo-widget-pending",
|
|
764
767
|
role: "status",
|
|
765
|
-
children: [/* @__PURE__ */
|
|
768
|
+
children: [/* @__PURE__ */ H("span", {
|
|
766
769
|
class: "whoo-widget-typing",
|
|
767
770
|
"aria-hidden": "true",
|
|
768
771
|
children: [
|
|
769
|
-
/* @__PURE__ */
|
|
770
|
-
/* @__PURE__ */
|
|
771
|
-
/* @__PURE__ */
|
|
772
|
+
/* @__PURE__ */ H("span", {}),
|
|
773
|
+
/* @__PURE__ */ H("span", {}),
|
|
774
|
+
/* @__PURE__ */ H("span", {})
|
|
772
775
|
]
|
|
773
|
-
}), e ? /* @__PURE__ */
|
|
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
|
|
780
|
-
let [n, r] =
|
|
781
|
-
return n ? null : /* @__PURE__ */
|
|
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
|
|
790
|
-
let l =
|
|
791
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
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
|
|
806
|
-
let d =
|
|
807
|
-
return
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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
|
|
834
|
-
function
|
|
835
|
-
return Array.from(e.querySelectorAll(
|
|
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
|
|
841
|
-
let
|
|
842
|
-
|
|
843
|
-
|
|
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
|
|
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 =
|
|
854
|
+
let n = i.current;
|
|
852
855
|
if (!n) return;
|
|
853
|
-
let
|
|
854
|
-
if (
|
|
855
|
-
let a =
|
|
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
|
-
},
|
|
864
|
+
}, s = () => {
|
|
862
865
|
let n = e.draft.trim();
|
|
863
866
|
n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
|
|
864
|
-
},
|
|
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,
|
|
869
|
-
url:
|
|
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__ */
|
|
875
|
+
return /* @__PURE__ */ H("div", {
|
|
873
876
|
class: "whoo-widget-panel",
|
|
874
877
|
role: "dialog",
|
|
875
878
|
"aria-modal": "true",
|
|
876
|
-
"aria-label":
|
|
877
|
-
ref:
|
|
878
|
-
onKeyDown:
|
|
879
|
+
"aria-label": c,
|
|
880
|
+
ref: i,
|
|
881
|
+
onKeyDown: o,
|
|
879
882
|
children: [
|
|
880
|
-
/* @__PURE__ */
|
|
883
|
+
/* @__PURE__ */ H("div", {
|
|
881
884
|
class: "whoo-widget-header",
|
|
882
|
-
children: [/* @__PURE__ */
|
|
885
|
+
children: [/* @__PURE__ */ H("h2", {
|
|
883
886
|
class: "whoo-widget-header-title",
|
|
884
|
-
children:
|
|
885
|
-
}), /* @__PURE__ */
|
|
887
|
+
children: c
|
|
888
|
+
}), /* @__PURE__ */ H("div", {
|
|
886
889
|
class: "whoo-widget-header-actions",
|
|
887
|
-
children: [e.messages.length > 0 && /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
900
|
+
children: /* @__PURE__ */ H(Le, {})
|
|
898
901
|
})]
|
|
899
902
|
})]
|
|
900
903
|
}),
|
|
901
|
-
/* @__PURE__ */
|
|
902
|
-
messages:
|
|
904
|
+
/* @__PURE__ */ H($e, {
|
|
905
|
+
messages: l,
|
|
903
906
|
messageFeedback: e.messageFeedback,
|
|
904
907
|
lastCompletedMessageText: e.lastCompletedMessageText,
|
|
905
|
-
emptyStateImage:
|
|
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__ */
|
|
915
|
-
/* @__PURE__ */
|
|
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:
|
|
921
|
+
onSend: s,
|
|
919
922
|
disabled: e.isStreaming,
|
|
920
|
-
inputRef:
|
|
923
|
+
inputRef: a
|
|
921
924
|
})
|
|
922
925
|
]
|
|
923
926
|
});
|
|
924
927
|
}
|
|
925
928
|
//#endregion
|
|
926
929
|
//#region src/components/App.tsx
|
|
927
|
-
function
|
|
928
|
-
let [t, n] =
|
|
929
|
-
return
|
|
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__ */
|
|
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__ */
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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*
|
|
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
|
|
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
|
|
1026
|
+
t && (yield lt(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
|
|
1014
1027
|
}
|
|
1015
1028
|
}
|
|
1016
1029
|
}
|
|
1017
|
-
function
|
|
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
|
|
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
|
|
1052
|
-
function
|
|
1064
|
+
var dt = 40, ft = 120;
|
|
1065
|
+
function pt(e) {
|
|
1053
1066
|
let t = [];
|
|
1054
|
-
for (let n of
|
|
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
|
|
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
|
|
1076
|
-
let r = n?.wordIntervalMs ??
|
|
1077
|
-
for (let n of
|
|
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
|
|
1095
|
+
function gt(e) {
|
|
1083
1096
|
return `whoo-aiden-widget:conversation:${e}`;
|
|
1084
1097
|
}
|
|
1085
|
-
function
|
|
1098
|
+
function _t(e) {
|
|
1086
1099
|
try {
|
|
1087
|
-
return window.sessionStorage.getItem(
|
|
1100
|
+
return window.sessionStorage.getItem(gt(e));
|
|
1088
1101
|
} catch {
|
|
1089
1102
|
return null;
|
|
1090
1103
|
}
|
|
1091
1104
|
}
|
|
1092
|
-
function
|
|
1105
|
+
function vt(e, t) {
|
|
1093
1106
|
try {
|
|
1094
|
-
window.sessionStorage.setItem(
|
|
1107
|
+
window.sessionStorage.setItem(gt(e), t);
|
|
1095
1108
|
} catch {}
|
|
1096
1109
|
}
|
|
1097
|
-
function
|
|
1110
|
+
function yt(e) {
|
|
1098
1111
|
try {
|
|
1099
|
-
window.sessionStorage.removeItem(
|
|
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
|
|
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 =
|
|
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 =
|
|
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,
|
|
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
|
-
},
|
|
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
|
|
1228
|
-
else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await
|
|
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,
|
|
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
|
|
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
|
-
},
|
|
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
|
|
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 =
|
|
1444
|
+
i.textContent = Bt, r.appendChild(i);
|
|
1413
1445
|
let a = document.createElement("div");
|
|
1414
|
-
r.appendChild(a),
|
|
1415
|
-
let o = new
|
|
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 !==
|
|
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 !==
|
|
1420
|
-
inkColor: $(
|
|
1421
|
-
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
|
-
}),
|
|
1424
|
-
|
|
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
|
|
1430
|
-
return
|
|
1461
|
+
function Ht(e) {
|
|
1462
|
+
return i(e), Vt(e);
|
|
1431
1463
|
}
|
|
1432
1464
|
//#endregion
|
|
1433
|
-
export {
|
|
1465
|
+
export { Ht as init, Mt as resolveTheme };
|