@ariaflowagents/widget 0.6.8 → 0.6.9
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 +335 -357
- package/dist/widget.umd.cjs +3 -3
- package/package.json +3 -2
package/dist/widget.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var B, m, Ee,
|
|
1
|
+
var B, m, Ee, U, me, Te, He, Ie, ce, re, ae, q = {}, Ue = [], at = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, te = Array.isArray;
|
|
2
2
|
function P(t, e) {
|
|
3
3
|
for (var n in e) t[n] = e[n];
|
|
4
4
|
return t;
|
|
@@ -6,86 +6,86 @@ function P(t, e) {
|
|
|
6
6
|
function ue(t) {
|
|
7
7
|
t && t.parentNode && t.parentNode.removeChild(t);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
var
|
|
11
|
-
for (
|
|
12
|
-
if (arguments.length > 2 && (a.children = arguments.length > 3 ? B.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (
|
|
13
|
-
return Q(t, a,
|
|
9
|
+
function R(t, e, n) {
|
|
10
|
+
var o, i, s, a = {};
|
|
11
|
+
for (s in e) s == "key" ? o = e[s] : s == "ref" ? i = e[s] : a[s] = e[s];
|
|
12
|
+
if (arguments.length > 2 && (a.children = arguments.length > 3 ? B.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (s in t.defaultProps) a[s] === void 0 && (a[s] = t.defaultProps[s]);
|
|
13
|
+
return Q(t, a, o, i, null);
|
|
14
14
|
}
|
|
15
|
-
function Q(t, e, n,
|
|
16
|
-
var
|
|
17
|
-
return i == null && m.vnode != null && m.vnode(
|
|
15
|
+
function Q(t, e, n, o, i) {
|
|
16
|
+
var s = { type: t, props: e, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++Ee, __i: -1, __u: 0 };
|
|
17
|
+
return i == null && m.vnode != null && m.vnode(s), s;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function D(t) {
|
|
20
20
|
return t.children;
|
|
21
21
|
}
|
|
22
22
|
function G(t, e) {
|
|
23
23
|
this.props = t, this.context = e;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
if (e == null) return t.__ ?
|
|
25
|
+
function L(t, e) {
|
|
26
|
+
if (e == null) return t.__ ? L(t.__, t.__i + 1) : null;
|
|
27
27
|
for (var n; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) return n.__e;
|
|
28
|
-
return typeof t.type == "function" ?
|
|
28
|
+
return typeof t.type == "function" ? L(t) : null;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function De(t) {
|
|
31
31
|
var e, n;
|
|
32
32
|
if ((t = t.__) != null && t.__c != null) {
|
|
33
33
|
for (t.__e = t.__c.base = null, e = 0; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) {
|
|
34
34
|
t.__e = t.__c.base = n.__e;
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return De(t);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
function ye(t) {
|
|
41
|
-
(!t.__d && (t.__d = !0) &&
|
|
41
|
+
(!t.__d && (t.__d = !0) && U.push(t) && !Y.__r++ || me != m.debounceRendering) && ((me = m.debounceRendering) || Te)(Y);
|
|
42
42
|
}
|
|
43
43
|
function Y() {
|
|
44
|
-
for (var t, e, n,
|
|
44
|
+
for (var t, e, n, o, i, s, a, _ = 1; U.length; ) U.length > _ && U.sort(He), t = U.shift(), _ = U.length, t.__d && (n = void 0, o = void 0, i = (o = (e = t).__v).__e, s = [], a = [], e.__P && ((n = P({}, o)).__v = o.__v + 1, m.vnode && m.vnode(n), ge(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [i] : null, s, i ?? L(o), !!(32 & o.__u), a), n.__v = o.__v, n.__.__k[n.__i] = n, Oe(s, n, a), o.__e = o.__ = null, n.__e != i && De(n)));
|
|
45
45
|
Y.__r = 0;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
var r,
|
|
49
|
-
for (c = lt(n, e,
|
|
50
|
-
return n.__e =
|
|
47
|
+
function Re(t, e, n, o, i, s, a, _, c, l, u) {
|
|
48
|
+
var r, h, g, b, $, y, p, f = o && o.__k || Ue, M = e.length;
|
|
49
|
+
for (c = lt(n, e, f, c, M), r = 0; r < M; r++) (g = n.__k[r]) != null && (h = g.__i == -1 ? q : f[g.__i] || q, g.__i = r, y = ge(t, g, h, i, s, a, _, c, l, u), b = g.__e, g.ref && h.ref != g.ref && (h.ref && de(h.ref, null, g), u.push(g.ref, g.__c || b, g)), $ == null && b != null && ($ = b), (p = !!(4 & g.__u)) || h.__k === g.__k ? c = Le(g, c, t, p) : typeof g.type == "function" && y !== void 0 ? c = y : b && (c = b.nextSibling), g.__u &= -7);
|
|
50
|
+
return n.__e = $, c;
|
|
51
51
|
}
|
|
52
|
-
function lt(t, e, n,
|
|
53
|
-
var
|
|
54
|
-
for (t.__k = new Array(i),
|
|
55
|
-
if (r) for (
|
|
56
|
-
return
|
|
52
|
+
function lt(t, e, n, o, i) {
|
|
53
|
+
var s, a, _, c, l, u = n.length, r = u, h = 0;
|
|
54
|
+
for (t.__k = new Array(i), s = 0; s < i; s++) (a = e[s]) != null && typeof a != "boolean" && typeof a != "function" ? (typeof a == "string" || typeof a == "number" || typeof a == "bigint" || a.constructor == String ? a = t.__k[s] = Q(null, a, null, null, null) : te(a) ? a = t.__k[s] = Q(D, { children: a }, null, null, null) : a.constructor === void 0 && a.__b > 0 ? a = t.__k[s] = Q(a.type, a.props, a.key, a.ref ? a.ref : null, a.__v) : t.__k[s] = a, c = s + h, a.__ = t, a.__b = t.__b + 1, _ = null, (l = a.__i = _t(a, n, c, r)) != -1 && (r--, (_ = n[l]) && (_.__u |= 2)), _ == null || _.__v == null ? (l == -1 && (i > u ? h-- : i < u && h++), typeof a.type != "function" && (a.__u |= 4)) : l != c && (l == c - 1 ? h-- : l == c + 1 ? h++ : (l > c ? h-- : h++, a.__u |= 4))) : t.__k[s] = null;
|
|
55
|
+
if (r) for (s = 0; s < u; s++) (_ = n[s]) != null && !(2 & _.__u) && (_.__e == o && (o = L(_)), qe(_, _));
|
|
56
|
+
return o;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
var i,
|
|
58
|
+
function Le(t, e, n, o) {
|
|
59
|
+
var i, s;
|
|
60
60
|
if (typeof t.type == "function") {
|
|
61
|
-
for (i = t.__k,
|
|
61
|
+
for (i = t.__k, s = 0; i && s < i.length; s++) i[s] && (i[s].__ = t, e = Le(i[s], e, n, o));
|
|
62
62
|
return e;
|
|
63
63
|
}
|
|
64
|
-
t.__e != e && (
|
|
64
|
+
t.__e != e && (o && (e && t.type && !e.parentNode && (e = L(t)), n.insertBefore(t.__e, e || null)), e = t.__e);
|
|
65
65
|
do
|
|
66
66
|
e = e && e.nextSibling;
|
|
67
67
|
while (e != null && e.nodeType == 8);
|
|
68
68
|
return e;
|
|
69
69
|
}
|
|
70
|
-
function _t(t, e, n,
|
|
71
|
-
var i,
|
|
72
|
-
if (
|
|
73
|
-
if (
|
|
74
|
-
for (i = n - 1,
|
|
70
|
+
function _t(t, e, n, o) {
|
|
71
|
+
var i, s, a, _ = t.key, c = t.type, l = e[n], u = l != null && (2 & l.__u) == 0;
|
|
72
|
+
if (l === null && _ == null || u && _ == l.key && c == l.type) return n;
|
|
73
|
+
if (o > (u ? 1 : 0)) {
|
|
74
|
+
for (i = n - 1, s = n + 1; i >= 0 || s < e.length; ) if ((l = e[a = i >= 0 ? i-- : s++]) != null && !(2 & l.__u) && _ == l.key && c == l.type) return a;
|
|
75
75
|
}
|
|
76
76
|
return -1;
|
|
77
77
|
}
|
|
78
78
|
function we(t, e, n) {
|
|
79
79
|
e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || at.test(e) ? n : n + "px";
|
|
80
80
|
}
|
|
81
|
-
function J(t, e, n,
|
|
82
|
-
var
|
|
81
|
+
function J(t, e, n, o, i) {
|
|
82
|
+
var s, a;
|
|
83
83
|
e: if (e == "style") if (typeof n == "string") t.style.cssText = n;
|
|
84
84
|
else {
|
|
85
|
-
if (typeof
|
|
86
|
-
if (n) for (e in n)
|
|
85
|
+
if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || we(t.style, e, "");
|
|
86
|
+
if (n) for (e in n) o && n[e] == o[e] || we(t.style, e, n[e]);
|
|
87
87
|
}
|
|
88
|
-
else if (e[0] == "o" && e[1] == "n")
|
|
88
|
+
else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(Ie, "$1")), a = e.toLowerCase(), e = a in t || e == "onFocusOut" || e == "onFocusIn" ? a.slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + s] = n, n ? o ? n.u = o.u : (n.u = ce, t.addEventListener(e, s ? ae : re, s)) : t.removeEventListener(e, s ? ae : re, s);
|
|
89
89
|
else {
|
|
90
90
|
if (i == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
91
91
|
else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in t) try {
|
|
@@ -106,135 +106,135 @@ function ve(t) {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
function ge(t, e, n,
|
|
110
|
-
var
|
|
109
|
+
function ge(t, e, n, o, i, s, a, _, c, l) {
|
|
110
|
+
var u, r, h, g, b, $, y, p, f, M, N, T, W, z, S, H, I, x = e.type;
|
|
111
111
|
if (e.constructor !== void 0) return null;
|
|
112
|
-
128 & n.__u && (c = !!(32 & n.__u),
|
|
113
|
-
e: if (typeof
|
|
114
|
-
if (p = e.props,
|
|
112
|
+
128 & n.__u && (c = !!(32 & n.__u), s = [_ = e.__e = n.__e]), (u = m.__b) && u(e);
|
|
113
|
+
e: if (typeof x == "function") try {
|
|
114
|
+
if (p = e.props, f = "prototype" in x && x.prototype.render, M = (u = x.contextType) && o[u.__c], N = u ? M ? M.props.value : u.__ : o, n.__c ? y = (r = e.__c = n.__c).__ = r.__E : (f ? e.__c = r = new x(p, N) : (e.__c = r = new G(p, N), r.constructor = x, r.render = ut), M && M.sub(r), r.state || (r.state = {}), r.__n = o, h = r.__d = !0, r.__h = [], r._sb = []), f && r.__s == null && (r.__s = r.state), f && x.getDerivedStateFromProps != null && (r.__s == r.state && (r.__s = P({}, r.__s)), P(r.__s, x.getDerivedStateFromProps(p, r.__s))), g = r.props, b = r.state, r.__v = e, h) f && x.getDerivedStateFromProps == null && r.componentWillMount != null && r.componentWillMount(), f && r.componentDidMount != null && r.__h.push(r.componentDidMount);
|
|
115
115
|
else {
|
|
116
|
-
if (
|
|
117
|
-
for (e.__v != n.__v && (r.props = p, r.state = r.__s, r.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(
|
|
118
|
-
|
|
116
|
+
if (f && x.getDerivedStateFromProps == null && p !== g && r.componentWillReceiveProps != null && r.componentWillReceiveProps(p, N), e.__v == n.__v || !r.__e && r.shouldComponentUpdate != null && r.shouldComponentUpdate(p, r.__s, N) === !1) {
|
|
117
|
+
for (e.__v != n.__v && (r.props = p, r.state = r.__s, r.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(F) {
|
|
118
|
+
F && (F.__ = e);
|
|
119
119
|
}), T = 0; T < r._sb.length; T++) r.__h.push(r._sb[T]);
|
|
120
120
|
r._sb = [], r.__h.length && a.push(r);
|
|
121
121
|
break e;
|
|
122
122
|
}
|
|
123
|
-
r.componentWillUpdate != null && r.componentWillUpdate(p, r.__s, N),
|
|
124
|
-
r.componentDidUpdate(
|
|
123
|
+
r.componentWillUpdate != null && r.componentWillUpdate(p, r.__s, N), f && r.componentDidUpdate != null && r.__h.push(function() {
|
|
124
|
+
r.componentDidUpdate(g, b, $);
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
if (r.context = N, r.props = p, r.__P = t, r.__e = !1,
|
|
128
|
-
for (r.state = r.__s, r.__d = !1,
|
|
127
|
+
if (r.context = N, r.props = p, r.__P = t, r.__e = !1, W = m.__r, z = 0, f) {
|
|
128
|
+
for (r.state = r.__s, r.__d = !1, W && W(e), u = r.render(r.props, r.state, r.context), S = 0; S < r._sb.length; S++) r.__h.push(r._sb[S]);
|
|
129
129
|
r._sb = [];
|
|
130
130
|
} else do
|
|
131
|
-
r.__d = !1,
|
|
131
|
+
r.__d = !1, W && W(e), u = r.render(r.props, r.state, r.context), r.state = r.__s;
|
|
132
132
|
while (r.__d && ++z < 25);
|
|
133
|
-
r.state = r.__s, r.getChildContext != null && (
|
|
134
|
-
} catch (
|
|
135
|
-
if (e.__v = null, c ||
|
|
136
|
-
for (e.__u |= c ? 160 : 128;
|
|
137
|
-
|
|
133
|
+
r.state = r.__s, r.getChildContext != null && (o = P(P({}, o), r.getChildContext())), f && !h && r.getSnapshotBeforeUpdate != null && ($ = r.getSnapshotBeforeUpdate(g, b)), H = u, u != null && u.type === D && u.key == null && (H = Qe(u.props.children)), _ = Re(t, te(H) ? H : [H], e, n, o, i, s, a, _, c, l), r.base = e.__e, e.__u &= -161, r.__h.length && a.push(r), y && (r.__E = r.__ = null);
|
|
134
|
+
} catch (F) {
|
|
135
|
+
if (e.__v = null, c || s != null) if (F.then) {
|
|
136
|
+
for (e.__u |= c ? 160 : 128; _ && _.nodeType == 8 && _.nextSibling; ) _ = _.nextSibling;
|
|
137
|
+
s[s.indexOf(_)] = null, e.__e = _;
|
|
138
138
|
} else {
|
|
139
|
-
for (I =
|
|
139
|
+
for (I = s.length; I--; ) ue(s[I]);
|
|
140
140
|
le(e);
|
|
141
141
|
}
|
|
142
|
-
else e.__e = n.__e, e.__k = n.__k,
|
|
143
|
-
m.__e(
|
|
142
|
+
else e.__e = n.__e, e.__k = n.__k, F.then || le(e);
|
|
143
|
+
m.__e(F, e, n);
|
|
144
144
|
}
|
|
145
|
-
else
|
|
146
|
-
return (
|
|
145
|
+
else s == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : _ = e.__e = ct(n.__e, e, n, o, i, s, a, c, l);
|
|
146
|
+
return (u = m.diffed) && u(e), 128 & e.__u ? void 0 : _;
|
|
147
147
|
}
|
|
148
148
|
function le(t) {
|
|
149
149
|
t && t.__c && (t.__c.__e = !0), t && t.__k && t.__k.forEach(le);
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
for (var
|
|
151
|
+
function Oe(t, e, n) {
|
|
152
|
+
for (var o = 0; o < n.length; o++) de(n[o], n[++o], n[++o]);
|
|
153
153
|
m.__c && m.__c(e, t), t.some(function(i) {
|
|
154
154
|
try {
|
|
155
|
-
t = i.__h, i.__h = [], t.some(function(
|
|
156
|
-
|
|
155
|
+
t = i.__h, i.__h = [], t.some(function(s) {
|
|
156
|
+
s.call(i);
|
|
157
157
|
});
|
|
158
|
-
} catch (
|
|
159
|
-
m.__e(
|
|
158
|
+
} catch (s) {
|
|
159
|
+
m.__e(s, i.__v);
|
|
160
160
|
}
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
function Qe(t) {
|
|
164
164
|
return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : te(t) ? t.map(Qe) : P({}, t);
|
|
165
165
|
}
|
|
166
|
-
function ct(t, e, n,
|
|
167
|
-
var
|
|
168
|
-
if (
|
|
169
|
-
for (
|
|
170
|
-
t =
|
|
166
|
+
function ct(t, e, n, o, i, s, a, _, c) {
|
|
167
|
+
var l, u, r, h, g, b, $, y = n.props || q, p = e.props, f = e.type;
|
|
168
|
+
if (f == "svg" ? i = "http://www.w3.org/2000/svg" : f == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) {
|
|
169
|
+
for (l = 0; l < s.length; l++) if ((g = s[l]) && "setAttribute" in g == !!f && (f ? g.localName == f : g.nodeType == 3)) {
|
|
170
|
+
t = g, s[l] = null;
|
|
171
171
|
break;
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
if (t == null) {
|
|
175
|
-
if (
|
|
176
|
-
t = document.createElementNS(i,
|
|
175
|
+
if (f == null) return document.createTextNode(p);
|
|
176
|
+
t = document.createElementNS(i, f, p.is && p), _ && (m.__m && m.__m(e, s), _ = !1), s = null;
|
|
177
177
|
}
|
|
178
|
-
if (
|
|
178
|
+
if (f == null) y === p || _ && t.data == p || (t.data = p);
|
|
179
179
|
else {
|
|
180
|
-
if (
|
|
181
|
-
for (
|
|
182
|
-
if (
|
|
183
|
-
else if (!(
|
|
184
|
-
if (
|
|
185
|
-
J(t,
|
|
180
|
+
if (s = s && B.call(t.childNodes), !_ && s != null) for (y = {}, l = 0; l < t.attributes.length; l++) y[(g = t.attributes[l]).name] = g.value;
|
|
181
|
+
for (l in y) if (g = y[l], l != "children") {
|
|
182
|
+
if (l == "dangerouslySetInnerHTML") r = g;
|
|
183
|
+
else if (!(l in p)) {
|
|
184
|
+
if (l == "value" && "defaultValue" in p || l == "checked" && "defaultChecked" in p) continue;
|
|
185
|
+
J(t, l, null, g, i);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
for (
|
|
189
|
-
if (
|
|
190
|
-
else if (r && (t.innerHTML = ""),
|
|
191
|
-
|
|
188
|
+
for (l in p) g = p[l], l == "children" ? h = g : l == "dangerouslySetInnerHTML" ? u = g : l == "value" ? b = g : l == "checked" ? $ = g : _ && typeof g != "function" || y[l] === g || J(t, l, g, y[l], i);
|
|
189
|
+
if (u) _ || r && (u.__html == r.__html || u.__html == t.innerHTML) || (t.innerHTML = u.__html), e.__k = [];
|
|
190
|
+
else if (r && (t.innerHTML = ""), Re(e.type == "template" ? t.content : t, te(h) ? h : [h], e, n, o, f == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, a, s ? s[0] : n.__k && L(n, 0), _, c), s != null) for (l = s.length; l--; ) ue(s[l]);
|
|
191
|
+
_ || (l = "value", f == "progress" && b == null ? t.removeAttribute("value") : b != null && (b !== t[l] || f == "progress" && !b || f == "option" && b != y[l]) && J(t, l, b, y[l], i), l = "checked", $ != null && $ != t[l] && J(t, l, $, y[l], i));
|
|
192
192
|
}
|
|
193
193
|
return t;
|
|
194
194
|
}
|
|
195
195
|
function de(t, e, n) {
|
|
196
196
|
try {
|
|
197
197
|
if (typeof t == "function") {
|
|
198
|
-
var
|
|
199
|
-
|
|
198
|
+
var o = typeof t.__u == "function";
|
|
199
|
+
o && t.__u(), o && e == null || (t.__u = t(e));
|
|
200
200
|
} else t.current = e;
|
|
201
201
|
} catch (i) {
|
|
202
202
|
m.__e(i, n);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
function qe(t, e, n) {
|
|
206
|
-
var
|
|
207
|
-
if (m.unmount && m.unmount(t), (
|
|
208
|
-
if (
|
|
209
|
-
|
|
210
|
-
} catch (
|
|
211
|
-
m.__e(
|
|
206
|
+
var o, i;
|
|
207
|
+
if (m.unmount && m.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || de(o, null, e)), (o = t.__c) != null) {
|
|
208
|
+
if (o.componentWillUnmount) try {
|
|
209
|
+
o.componentWillUnmount();
|
|
210
|
+
} catch (s) {
|
|
211
|
+
m.__e(s, e);
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
o.base = o.__P = null;
|
|
214
214
|
}
|
|
215
|
-
if (
|
|
215
|
+
if (o = t.__k) for (i = 0; i < o.length; i++) o[i] && qe(o[i], e, n || typeof t.type != "function");
|
|
216
216
|
n || ue(t.__e), t.__c = t.__ = t.__e = void 0;
|
|
217
217
|
}
|
|
218
218
|
function ut(t, e, n) {
|
|
219
219
|
return this.constructor(t, n);
|
|
220
220
|
}
|
|
221
221
|
function ne(t, e, n) {
|
|
222
|
-
var
|
|
223
|
-
e == document && (e = document.documentElement), m.__ && m.__(t, e), i = (
|
|
222
|
+
var o, i, s, a;
|
|
223
|
+
e == document && (e = document.documentElement), m.__ && m.__(t, e), i = (o = typeof n == "function") ? null : n && n.__k || e.__k, s = [], a = [], ge(e, t = (!o && n || e).__k = R(D, null, [t]), i || q, q, e.namespaceURI, !o && n ? [n] : i ? null : e.firstChild ? B.call(e.childNodes) : null, s, !o && n ? n : i ? i.__e : e.firstChild, o, a), Oe(s, t, a);
|
|
224
224
|
}
|
|
225
225
|
function je(t, e) {
|
|
226
226
|
ne(t, e, je);
|
|
227
227
|
}
|
|
228
228
|
function Be(t, e, n) {
|
|
229
|
-
var
|
|
230
|
-
for (
|
|
231
|
-
return arguments.length > 2 && (
|
|
229
|
+
var o, i, s, a, _ = P({}, t.props);
|
|
230
|
+
for (s in t.type && t.type.defaultProps && (a = t.type.defaultProps), e) s == "key" ? o = e[s] : s == "ref" ? i = e[s] : _[s] = e[s] === void 0 && a != null ? a[s] : e[s];
|
|
231
|
+
return arguments.length > 2 && (_.children = arguments.length > 3 ? B.call(arguments, 2) : n), Q(t.type, _, o || t.key, i || t.ref, null);
|
|
232
232
|
}
|
|
233
|
-
B =
|
|
234
|
-
for (var i,
|
|
235
|
-
if ((
|
|
236
|
-
} catch (
|
|
237
|
-
t =
|
|
233
|
+
B = Ue.slice, m = { __e: function(t, e, n, o) {
|
|
234
|
+
for (var i, s, a; e = e.__; ) if ((i = e.__c) && !i.__) try {
|
|
235
|
+
if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(t)), a = i.__d), i.componentDidCatch != null && (i.componentDidCatch(t, o || {}), a = i.__d), a) return i.__E = i;
|
|
236
|
+
} catch (_) {
|
|
237
|
+
t = _;
|
|
238
238
|
}
|
|
239
239
|
throw t;
|
|
240
240
|
} }, Ee = 0, G.prototype.setState = function(t, e) {
|
|
@@ -242,39 +242,39 @@ B = Re.slice, m = { __e: function(t, e, n, s) {
|
|
|
242
242
|
n = this.__s != null && this.__s != this.state ? this.__s : this.__s = P({}, this.state), typeof t == "function" && (t = t(P({}, n), this.props)), t && P(n, t), t != null && this.__v && (e && this._sb.push(e), ye(this));
|
|
243
243
|
}, G.prototype.forceUpdate = function(t) {
|
|
244
244
|
this.__v && (this.__e = !0, t && this.__h.push(t), ye(this));
|
|
245
|
-
}, G.prototype.render =
|
|
245
|
+
}, G.prototype.render = D, U = [], Te = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, He = function(t, e) {
|
|
246
246
|
return t.__v.__b - e.__v.__b;
|
|
247
247
|
}, Y.__r = 0, Ie = /(PointerCapture)$|Capture$/i, ce = 0, re = ve(!1), ae = ve(!0);
|
|
248
248
|
function Z() {
|
|
249
249
|
return Z = Object.assign ? Object.assign.bind() : function(t) {
|
|
250
250
|
for (var e = 1; e < arguments.length; e++) {
|
|
251
251
|
var n = arguments[e];
|
|
252
|
-
for (var
|
|
252
|
+
for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]);
|
|
253
253
|
}
|
|
254
254
|
return t;
|
|
255
255
|
}, Z.apply(this, arguments);
|
|
256
256
|
}
|
|
257
257
|
function ze(t, e) {
|
|
258
258
|
if (t == null) return {};
|
|
259
|
-
var n,
|
|
260
|
-
for (
|
|
259
|
+
var n, o, i = {}, s = Object.keys(t);
|
|
260
|
+
for (o = 0; o < s.length; o++) e.indexOf(n = s[o]) >= 0 || (i[n] = t[n]);
|
|
261
261
|
return i;
|
|
262
262
|
}
|
|
263
263
|
var gt = ["context", "children"], dt = ["useFragment"];
|
|
264
|
-
function ht(t, e, n,
|
|
264
|
+
function ht(t, e, n, o) {
|
|
265
265
|
function i() {
|
|
266
|
-
var
|
|
267
|
-
return
|
|
266
|
+
var s = Reflect.construct(HTMLElement, [], i);
|
|
267
|
+
return s._vdomComponent = t, s._root = s, s;
|
|
268
268
|
}
|
|
269
269
|
return (i.prototype = Object.create(HTMLElement.prototype)).constructor = i, i.prototype.connectedCallback = function() {
|
|
270
|
-
pt.call(this,
|
|
271
|
-
}, i.prototype.attributeChangedCallback = mt, i.prototype.disconnectedCallback = yt, n = n || t.observedAttributes || Object.keys(t.propTypes || {}), i.observedAttributes = n, t.formAssociated && (i.formAssociated = !0), n.forEach(function(
|
|
272
|
-
Object.defineProperty(i.prototype,
|
|
273
|
-
return this._vdom ? this._vdom.props[
|
|
270
|
+
pt.call(this, o);
|
|
271
|
+
}, i.prototype.attributeChangedCallback = mt, i.prototype.disconnectedCallback = yt, n = n || t.observedAttributes || Object.keys(t.propTypes || {}), i.observedAttributes = n, t.formAssociated && (i.formAssociated = !0), n.forEach(function(s) {
|
|
272
|
+
Object.defineProperty(i.prototype, s, { get: function() {
|
|
273
|
+
return this._vdom ? this._vdom.props[s] : this._props[s];
|
|
274
274
|
}, set: function(a) {
|
|
275
|
-
this._vdom ? this.attributeChangedCallback(
|
|
276
|
-
var
|
|
277
|
-
a != null &&
|
|
275
|
+
this._vdom ? this.attributeChangedCallback(s, null, a) : (this._props || (this._props = {}), this._props[s] = a);
|
|
276
|
+
var _ = typeof a;
|
|
277
|
+
a != null && _ !== "string" && _ !== "boolean" && _ !== "number" || this.setAttribute(s, a);
|
|
278
278
|
} });
|
|
279
279
|
}), customElements.define(e, i), i;
|
|
280
280
|
}
|
|
@@ -287,7 +287,7 @@ function ft(t) {
|
|
|
287
287
|
}
|
|
288
288
|
function pt(t) {
|
|
289
289
|
var e = new CustomEvent("_preact", { detail: {}, bubbles: !0, cancelable: !0 });
|
|
290
|
-
this.dispatchEvent(e), this._vdom =
|
|
290
|
+
this.dispatchEvent(e), this._vdom = R(ft, Z({}, this._props, { context: e.detail.context }), Je(this, this._vdomComponent, t)), (this.hasAttribute("hydrate") ? je : ne)(this._vdom, this._root);
|
|
291
291
|
}
|
|
292
292
|
function Ve(t) {
|
|
293
293
|
return t.replace(/-(\w)/g, function(e, n) {
|
|
@@ -296,43 +296,43 @@ function Ve(t) {
|
|
|
296
296
|
}
|
|
297
297
|
function mt(t, e, n) {
|
|
298
298
|
if (this._vdom) {
|
|
299
|
-
var
|
|
300
|
-
|
|
299
|
+
var o = {};
|
|
300
|
+
o[t] = n = n ?? void 0, o[Ve(t)] = n, this._vdom = Be(this._vdom, o), ne(this._vdom, this._root);
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
function yt() {
|
|
304
304
|
ne(this._vdom = null, this._root);
|
|
305
305
|
}
|
|
306
306
|
function be(t, e) {
|
|
307
|
-
var n = this,
|
|
308
|
-
return
|
|
309
|
-
|
|
307
|
+
var n = this, o = t.useFragment, i = ze(t, dt);
|
|
308
|
+
return R(o ? D : "slot", Z({}, i, { ref: function(s) {
|
|
309
|
+
s ? (n.ref = s, n._listener || (n._listener = function(a) {
|
|
310
310
|
a.stopPropagation(), a.detail.context = e;
|
|
311
|
-
},
|
|
311
|
+
}, s.addEventListener("_preact", n._listener))) : n.ref.removeEventListener("_preact", n._listener);
|
|
312
312
|
} }));
|
|
313
313
|
}
|
|
314
314
|
function Je(t, e, n) {
|
|
315
315
|
if (t.nodeType === 3) return t.data;
|
|
316
316
|
if (t.nodeType !== 1) return null;
|
|
317
|
-
var
|
|
318
|
-
for (
|
|
319
|
-
for (
|
|
320
|
-
var c = Je(
|
|
321
|
-
|
|
317
|
+
var o = [], i = {}, s = 0, a = t.attributes, _ = t.childNodes;
|
|
318
|
+
for (s = a.length; s--; ) a[s].name !== "slot" && (i[a[s].name] = a[s].value, i[Ve(a[s].name)] = a[s].value);
|
|
319
|
+
for (s = _.length; s--; ) {
|
|
320
|
+
var c = Je(_[s], null, n), l = _[s].slot;
|
|
321
|
+
l ? i[l] = R(be, { name: l }, c) : o[s] = c;
|
|
322
322
|
}
|
|
323
|
-
var
|
|
324
|
-
return !
|
|
323
|
+
var u = !(!n || !n.shadow), r = e ? R(be, { useFragment: !u }, o) : o;
|
|
324
|
+
return !u && e && (t.innerHTML = ""), R(e || t.nodeName.toLowerCase(), i, r);
|
|
325
325
|
}
|
|
326
326
|
var wt = 0;
|
|
327
|
-
function
|
|
327
|
+
function d(t, e, n, o, i, s) {
|
|
328
328
|
e || (e = {});
|
|
329
|
-
var a,
|
|
330
|
-
if ("ref" in c) for (
|
|
331
|
-
var
|
|
332
|
-
if (typeof t == "function" && (a = t.defaultProps)) for (
|
|
333
|
-
return m.vnode && m.vnode(
|
|
329
|
+
var a, _, c = e;
|
|
330
|
+
if ("ref" in c) for (_ in c = {}, e) _ == "ref" ? a = e[_] : c[_] = e[_];
|
|
331
|
+
var l = { type: t, props: c, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --wt, __i: -1, __u: 0, __source: i, __self: s };
|
|
332
|
+
if (typeof t == "function" && (a = t.defaultProps)) for (_ in a) c[_] === void 0 && (c[_] = a[_]);
|
|
333
|
+
return m.vnode && m.vnode(l), l;
|
|
334
334
|
}
|
|
335
|
-
var j, v, se, Ce, ee = 0, Ke = [], C = m, ke = C.__b, Ae = C.__r, Se = C.diffed, $e = C.__c,
|
|
335
|
+
var j, v, se, Ce, ee = 0, Ke = [], C = m, ke = C.__b, Ae = C.__r, Se = C.diffed, $e = C.__c, We = C.unmount, Ne = C.__;
|
|
336
336
|
function he(t, e) {
|
|
337
337
|
C.__h && C.__h(v, t, ee || e), ee = 0;
|
|
338
338
|
var n = v.__H || (v.__H = { __: [], __h: [] });
|
|
@@ -342,38 +342,38 @@ function E(t) {
|
|
|
342
342
|
return ee = 1, vt(Xe, t);
|
|
343
343
|
}
|
|
344
344
|
function vt(t, e, n) {
|
|
345
|
-
var
|
|
346
|
-
if (
|
|
347
|
-
var c =
|
|
348
|
-
c !==
|
|
349
|
-
}],
|
|
350
|
-
var i = function(
|
|
351
|
-
if (!
|
|
352
|
-
var
|
|
353
|
-
return !!
|
|
345
|
+
var o = he(j++, 2);
|
|
346
|
+
if (o.t = t, !o.__c && (o.__ = [Xe(void 0, e), function(_) {
|
|
347
|
+
var c = o.__N ? o.__N[0] : o.__[0], l = o.t(c, _);
|
|
348
|
+
c !== l && (o.__N = [l, o.__[1]], o.__c.setState({}));
|
|
349
|
+
}], o.__c = v, !v.__f)) {
|
|
350
|
+
var i = function(_, c, l) {
|
|
351
|
+
if (!o.__c.__H) return !0;
|
|
352
|
+
var u = o.__c.__H.__.filter(function(h) {
|
|
353
|
+
return !!h.__c;
|
|
354
354
|
});
|
|
355
|
-
if (
|
|
356
|
-
return !
|
|
357
|
-
})) return !
|
|
358
|
-
var r =
|
|
359
|
-
return
|
|
360
|
-
if (
|
|
361
|
-
var
|
|
362
|
-
|
|
355
|
+
if (u.every(function(h) {
|
|
356
|
+
return !h.__N;
|
|
357
|
+
})) return !s || s.call(this, _, c, l);
|
|
358
|
+
var r = o.__c.props !== _;
|
|
359
|
+
return u.forEach(function(h) {
|
|
360
|
+
if (h.__N) {
|
|
361
|
+
var g = h.__[0];
|
|
362
|
+
h.__ = h.__N, h.__N = void 0, g !== h.__[0] && (r = !0);
|
|
363
363
|
}
|
|
364
|
-
}),
|
|
364
|
+
}), s && s.call(this, _, c, l) || r;
|
|
365
365
|
};
|
|
366
366
|
v.__f = !0;
|
|
367
|
-
var
|
|
368
|
-
v.componentWillUpdate = function(
|
|
367
|
+
var s = v.shouldComponentUpdate, a = v.componentWillUpdate;
|
|
368
|
+
v.componentWillUpdate = function(_, c, l) {
|
|
369
369
|
if (this.__e) {
|
|
370
|
-
var
|
|
371
|
-
|
|
370
|
+
var u = s;
|
|
371
|
+
s = void 0, i(_, c, l), s = u;
|
|
372
372
|
}
|
|
373
|
-
a && a.call(this,
|
|
373
|
+
a && a.call(this, _, c, l);
|
|
374
374
|
}, v.shouldComponentUpdate = i;
|
|
375
375
|
}
|
|
376
|
-
return
|
|
376
|
+
return o.__N || o.__;
|
|
377
377
|
}
|
|
378
378
|
function xe(t, e) {
|
|
379
379
|
var n = he(j++, 3);
|
|
@@ -398,7 +398,7 @@ function Ct() {
|
|
|
398
398
|
C.__b = function(t) {
|
|
399
399
|
v = null, ke && ke(t);
|
|
400
400
|
}, C.__ = function(t, e) {
|
|
401
|
-
t && e.__k && e.__k.__m && (t.__m = e.__k.__m),
|
|
401
|
+
t && e.__k && e.__k.__m && (t.__m = e.__k.__m), Ne && Ne(t, e);
|
|
402
402
|
}, C.__r = function(t) {
|
|
403
403
|
Ae && Ae(t), j = 0;
|
|
404
404
|
var e = (v = t.__c).__H;
|
|
@@ -414,21 +414,21 @@ C.__b = function(t) {
|
|
|
414
414
|
}, C.__c = function(t, e) {
|
|
415
415
|
e.some(function(n) {
|
|
416
416
|
try {
|
|
417
|
-
n.__h.forEach(X), n.__h = n.__h.filter(function(
|
|
418
|
-
return !
|
|
417
|
+
n.__h.forEach(X), n.__h = n.__h.filter(function(o) {
|
|
418
|
+
return !o.__ || _e(o);
|
|
419
419
|
});
|
|
420
|
-
} catch (
|
|
420
|
+
} catch (o) {
|
|
421
421
|
e.some(function(i) {
|
|
422
422
|
i.__h && (i.__h = []);
|
|
423
|
-
}), e = [], C.__e(
|
|
423
|
+
}), e = [], C.__e(o, n.__v);
|
|
424
424
|
}
|
|
425
425
|
}), $e && $e(t, e);
|
|
426
426
|
}, C.unmount = function(t) {
|
|
427
|
-
|
|
427
|
+
We && We(t);
|
|
428
428
|
var e, n = t.__c;
|
|
429
|
-
n && n.__H && (n.__H.__.forEach(function(
|
|
429
|
+
n && n.__H && (n.__H.__.forEach(function(o) {
|
|
430
430
|
try {
|
|
431
|
-
X(
|
|
431
|
+
X(o);
|
|
432
432
|
} catch (i) {
|
|
433
433
|
e = i;
|
|
434
434
|
}
|
|
@@ -437,8 +437,8 @@ C.__b = function(t) {
|
|
|
437
437
|
var Me = typeof requestAnimationFrame == "function";
|
|
438
438
|
function kt(t) {
|
|
439
439
|
var e, n = function() {
|
|
440
|
-
clearTimeout(
|
|
441
|
-
},
|
|
440
|
+
clearTimeout(o), Me && cancelAnimationFrame(e), setTimeout(t);
|
|
441
|
+
}, o = setTimeout(n, 35);
|
|
442
442
|
Me && (e = requestAnimationFrame(n));
|
|
443
443
|
}
|
|
444
444
|
function X(t) {
|
|
@@ -450,8 +450,8 @@ function _e(t) {
|
|
|
450
450
|
t.__c = t.__(), v = e;
|
|
451
451
|
}
|
|
452
452
|
function Ge(t, e) {
|
|
453
|
-
return !t || t.length !== e.length || e.some(function(n,
|
|
454
|
-
return n !== t[
|
|
453
|
+
return !t || t.length !== e.length || e.some(function(n, o) {
|
|
454
|
+
return n !== t[o];
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
function Xe(t, e) {
|
|
@@ -477,8 +477,8 @@ class St {
|
|
|
477
477
|
try {
|
|
478
478
|
const n = await fetch(`${this.agentUrl}/api/agent/${this.agentId}`);
|
|
479
479
|
if (n.ok) {
|
|
480
|
-
const
|
|
481
|
-
return console.log("[AriaFlow Widget] Agent config received:",
|
|
480
|
+
const o = await n.json();
|
|
481
|
+
return console.log("[AriaFlow Widget] Agent config received:", o), !o || o.status !== "active" ? (console.error("Agent not found or inactive"), null) : (this.agentConfig = o, this.maxReconnectAttempts = o.config.maxRetries || 5, this.reconnectDelay = o.config.reconnectDelay || 1e3, await this.connectToAgent(), o);
|
|
482
482
|
}
|
|
483
483
|
} catch {
|
|
484
484
|
console.warn("[AriaFlow Widget] Agent config endpoint not available, trying fallback");
|
|
@@ -512,23 +512,23 @@ class St {
|
|
|
512
512
|
if (!this.agentConfig?.wsUrl)
|
|
513
513
|
throw new Error("No agent WebSocket URL configured");
|
|
514
514
|
const e = this.getSessionId(), n = `${this.agentConfig.wsUrl}/${e}`;
|
|
515
|
-
return console.log("[AriaFlow Widget] Connecting to WebSocket:", n), new Promise((
|
|
515
|
+
return console.log("[AriaFlow Widget] Connecting to WebSocket:", n), new Promise((o, i) => {
|
|
516
516
|
try {
|
|
517
517
|
this.ws = new WebSocket(n), this.ws.onopen = () => {
|
|
518
|
-
console.log("[Widget] Connected to agent"), this.reconnectAttempts = 0, this.notifyConnectionChange(!0),
|
|
519
|
-
}, this.ws.onmessage = (
|
|
520
|
-
this.handleMessage(
|
|
518
|
+
console.log("[Widget] Connected to agent"), this.reconnectAttempts = 0, this.notifyConnectionChange(!0), o();
|
|
519
|
+
}, this.ws.onmessage = (s) => {
|
|
520
|
+
this.handleMessage(s);
|
|
521
521
|
}, this.ws.onclose = () => {
|
|
522
522
|
if (console.log("[Widget] Disconnected from agent"), this.notifyConnectionChange(!1), this.reconnectAttempts < this.maxReconnectAttempts) {
|
|
523
523
|
this.reconnectAttempts++;
|
|
524
|
-
const
|
|
525
|
-
console.log(`[Widget] Reconnecting in ${
|
|
524
|
+
const s = this.reconnectDelay * Math.pow(2, this.reconnectAttempts - 1);
|
|
525
|
+
console.log(`[Widget] Reconnecting in ${s}ms... (attempt ${this.reconnectAttempts})`), setTimeout(() => this.connectToAgent(), s);
|
|
526
526
|
}
|
|
527
|
-
}, this.ws.onerror = (
|
|
528
|
-
console.error("[Widget] WebSocket error:",
|
|
527
|
+
}, this.ws.onerror = (s) => {
|
|
528
|
+
console.error("[Widget] WebSocket error:", s), i(s);
|
|
529
529
|
};
|
|
530
|
-
} catch (
|
|
531
|
-
i(
|
|
530
|
+
} catch (s) {
|
|
531
|
+
i(s);
|
|
532
532
|
}
|
|
533
533
|
});
|
|
534
534
|
}
|
|
@@ -550,13 +550,13 @@ class St {
|
|
|
550
550
|
try {
|
|
551
551
|
const n = JSON.parse(e.data);
|
|
552
552
|
if (n.type === "text-delta")
|
|
553
|
-
this.isAgentProcessing && this.notifyProcessingChange(!1), this.setMessages((
|
|
554
|
-
const i =
|
|
553
|
+
this.isAgentProcessing && this.notifyProcessingChange(!1), this.setMessages((o) => {
|
|
554
|
+
const i = o[o.length - 1];
|
|
555
555
|
return i && i.role === "assistant" && i.isStreaming ? [
|
|
556
|
-
...
|
|
556
|
+
...o.slice(0, -1),
|
|
557
557
|
{ ...i, content: i.content + n.text }
|
|
558
558
|
] : [
|
|
559
|
-
...
|
|
559
|
+
...o,
|
|
560
560
|
{
|
|
561
561
|
id: K(),
|
|
562
562
|
role: "assistant",
|
|
@@ -567,53 +567,45 @@ class St {
|
|
|
567
567
|
];
|
|
568
568
|
});
|
|
569
569
|
else if (n.type === "done")
|
|
570
|
-
console.log("[Widget] Response complete"), this.notifyProcessingChange(!1), this.setMessages((
|
|
571
|
-
const i =
|
|
570
|
+
console.log("[Widget] Response complete"), this.notifyProcessingChange(!1), this.setMessages((o) => {
|
|
571
|
+
const i = o[o.length - 1];
|
|
572
572
|
return i && i.role === "assistant" && i.isStreaming ? [
|
|
573
|
-
...
|
|
573
|
+
...o.slice(0, -1),
|
|
574
574
|
{ ...i, isStreaming: !1 }
|
|
575
|
-
] :
|
|
575
|
+
] : o;
|
|
576
576
|
}), this.isAgentStreaming = !1, this.notifyStreamingChange(!1), this.processMessageQueue();
|
|
577
577
|
else if (n.type === "step-start" || n.type === "agent-start")
|
|
578
578
|
console.log(`[Widget] ${n.type} received:`, n.agentId || ""), this.isAgentStreaming = !0, this.notifyStreamingChange(!0), this.notifyProcessingChange(!0);
|
|
579
579
|
else if (n.type === "step-end" || n.type === "agent-end")
|
|
580
580
|
console.log(`[Widget] ${n.type} received`), n.type === "agent-end" && this.notifyProcessingChange(!1);
|
|
581
581
|
else if (n.type === "tool-call") {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
name: s,
|
|
599
|
-
arguments: i
|
|
600
|
-
}
|
|
601
|
-
};
|
|
602
|
-
this.setMessages((a) => [...a, o]);
|
|
603
|
-
}
|
|
604
|
-
} else if (n.type === "tool-result") {
|
|
605
|
-
const s = n.toolName || n.tool?.name;
|
|
606
|
-
console.log("[Widget] Tool result:", s), s === "suggest_options" || this.setMessages((i) => {
|
|
607
|
-
const o = i[i.length - 1];
|
|
608
|
-
return o && o.role === "tool" && !o.toolResult ? [
|
|
609
|
-
...i.slice(0, -1),
|
|
610
|
-
{ ...o, content: o.content + `
|
|
611
|
-
Result: ${JSON.stringify(n.result)}`, toolResult: n.result }
|
|
612
|
-
] : i;
|
|
582
|
+
console.log("[Widget] Tool call:", n.tool), this.notifyProcessingChange(!0);
|
|
583
|
+
const o = {
|
|
584
|
+
id: K(),
|
|
585
|
+
role: "tool",
|
|
586
|
+
content: `Calling tool: ${n.tool.name}`,
|
|
587
|
+
timestamp: Date.now(),
|
|
588
|
+
toolCall: {
|
|
589
|
+
name: n.tool.name,
|
|
590
|
+
arguments: n.tool.arguments
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
this.setMessages((i) => [...i, o]), n.tool.name === "suggest_options" && n.tool.arguments?.options && this.setMessages((i) => {
|
|
594
|
+
const s = [...i].reverse().find((a) => a.role === "assistant");
|
|
595
|
+
return s ? i.map(
|
|
596
|
+
(a) => a.id === s.id ? { ...a, suggestions: n.tool.arguments.options } : a
|
|
597
|
+
) : i;
|
|
613
598
|
});
|
|
614
|
-
} else n.type === "
|
|
615
|
-
const i = [
|
|
616
|
-
return i
|
|
599
|
+
} else n.type === "tool-result" ? (console.log("[Widget] Tool result:", n.result), this.setMessages((o) => {
|
|
600
|
+
const i = o[o.length - 1];
|
|
601
|
+
return i && i.role === "tool" && !i.toolResult ? [
|
|
602
|
+
...o.slice(0, -1),
|
|
603
|
+
{ ...i, content: i.content + `
|
|
604
|
+
Result: ${JSON.stringify(n.result)}`, toolResult: n.result }
|
|
605
|
+
] : o;
|
|
606
|
+
})) : n.type === "agent-start" ? (console.log(`[Widget] Agent started: ${n.agentId}`), this.isAgentStreaming = !0, this.notifyStreamingChange(!0)) : n.type === "handoff" ? console.log(`[Widget] Handoff: ${n.from} -> ${n.to}: ${n.reason}`) : n.type === "suggested-questions" ? (console.log("[Widget] Suggestions received:", n.suggestions), this.setMessages((o) => {
|
|
607
|
+
const i = [...o].reverse().find((s) => s.role === "assistant");
|
|
608
|
+
return i ? o.map((s) => s.id === i.id ? { ...s, suggestions: n.suggestions } : s) : o;
|
|
617
609
|
})) : console.log("[Widget] Unknown message type:", n.type);
|
|
618
610
|
} catch (n) {
|
|
619
611
|
console.error("[Widget] Error parsing message:", e.data, n);
|
|
@@ -631,7 +623,7 @@ Result: ${JSON.stringify(n.result)}`, toolResult: n.result }
|
|
|
631
623
|
content: e,
|
|
632
624
|
timestamp: Date.now()
|
|
633
625
|
};
|
|
634
|
-
if (this.setMessages((
|
|
626
|
+
if (this.setMessages((o) => [...o, n]), this.isAgentStreaming) {
|
|
635
627
|
console.log("[Widget] Agent is streaming, queuing message"), this.messageQueue.push(e), this.notifyQueueChange(this.messageQueue.length);
|
|
636
628
|
return;
|
|
637
629
|
}
|
|
@@ -760,90 +752,90 @@ function $t({
|
|
|
760
752
|
agentId: e,
|
|
761
753
|
// Legacy props for backward compatibility
|
|
762
754
|
widgetId: n,
|
|
763
|
-
apiUrl:
|
|
755
|
+
apiUrl: o,
|
|
764
756
|
mode: i = "chat",
|
|
765
|
-
theme:
|
|
757
|
+
theme: s = "light",
|
|
766
758
|
position: a = "bottom-right",
|
|
767
|
-
size:
|
|
759
|
+
size: _ = "full",
|
|
768
760
|
radius: c = "medium",
|
|
769
|
-
baseColor:
|
|
770
|
-
accentColor:
|
|
761
|
+
baseColor: l,
|
|
762
|
+
accentColor: u = "#14B8A6",
|
|
771
763
|
buttonBaseColor: r = "#000000",
|
|
772
|
-
buttonAccentColor:
|
|
773
|
-
title:
|
|
764
|
+
buttonAccentColor: h = "#FFFFFF",
|
|
765
|
+
title: g,
|
|
774
766
|
subtitle: b,
|
|
775
|
-
emptyChatMessage:
|
|
767
|
+
emptyChatMessage: $
|
|
776
768
|
}) {
|
|
777
|
-
const [
|
|
769
|
+
const [y, p] = E(!1), [f, M] = E([]), [N, T] = E(""), [W, z] = E(!1), [S, H] = E(!1), [I, x] = E(null), [F, Ye] = E(!1), [Ze, et] = E(!1), [oe, tt] = E(0), V = Fe(null), fe = Fe(null);
|
|
778
770
|
xe(() => ((async () => {
|
|
779
771
|
if (t && e) {
|
|
780
772
|
console.log("[AriaFlow Widget] Using new agent resolution:", { agentUrl: t, agentId: e });
|
|
781
|
-
const
|
|
782
|
-
V.current =
|
|
773
|
+
const k = new St(t, e);
|
|
774
|
+
V.current = k;
|
|
783
775
|
try {
|
|
784
|
-
|
|
785
|
-
console.log("[AriaFlow Widget] Messages updated:",
|
|
786
|
-
}),
|
|
787
|
-
console.log("[AriaFlow Widget] Connection state:",
|
|
788
|
-
}),
|
|
789
|
-
console.log("[AriaFlow Widget] Streaming state:",
|
|
790
|
-
}),
|
|
791
|
-
console.log("[AriaFlow Widget] Queue count:",
|
|
792
|
-
}),
|
|
793
|
-
console.log("[AriaFlow Widget] Processing state:",
|
|
776
|
+
k.onMessages((A) => {
|
|
777
|
+
console.log("[AriaFlow Widget] Messages updated:", A.length), M(A);
|
|
778
|
+
}), k.onConnectionChange((A) => {
|
|
779
|
+
console.log("[AriaFlow Widget] Connection state:", A), z(A), A && H(!0);
|
|
780
|
+
}), k.onStreamingChange((A) => {
|
|
781
|
+
console.log("[AriaFlow Widget] Streaming state:", A), Ye(A);
|
|
782
|
+
}), k.onQueueChange((A) => {
|
|
783
|
+
console.log("[AriaFlow Widget] Queue count:", A), tt(A);
|
|
784
|
+
}), k.onProcessingChange((A) => {
|
|
785
|
+
console.log("[AriaFlow Widget] Processing state:", A), et(A);
|
|
794
786
|
});
|
|
795
|
-
const
|
|
796
|
-
console.log("[AriaFlow Widget] Agent config received:",
|
|
797
|
-
} catch (
|
|
798
|
-
console.error("[AriaFlow Widget] Initialization error:",
|
|
787
|
+
const O = await k.initWidget();
|
|
788
|
+
console.log("[AriaFlow Widget] Agent config received:", O), O ? (x(O), console.log("[AriaFlow Widget] Widget initialized successfully")) : console.error("[AriaFlow Widget] Agent config fetch failed");
|
|
789
|
+
} catch (O) {
|
|
790
|
+
console.error("[AriaFlow Widget] Initialization error:", O);
|
|
799
791
|
}
|
|
800
|
-
} else t && !e ? (console.warn("[AriaFlow Widget] Direct WebSocket URLs are deprecated. Use agent-url + agent-id instead."), console.error("[AriaFlow Widget] Configuration error: agent-id is required")) :
|
|
792
|
+
} else t && !e ? (console.warn("[AriaFlow Widget] Direct WebSocket URLs are deprecated. Use agent-url + agent-id instead."), console.error("[AriaFlow Widget] Configuration error: agent-id is required")) : o && n ? (console.warn("[AriaFlow Widget] Legacy widget config is deprecated. Use agent-url + agent-id instead."), console.error("[AriaFlow Widget] Configuration error: use agent-url + agent-id instead")) : console.error("[AriaFlow Widget] Invalid configuration. Provide agent-url and agent-id.");
|
|
801
793
|
})(), () => {
|
|
802
794
|
V.current?.dispose();
|
|
803
|
-
}), [t, e, n,
|
|
795
|
+
}), [t, e, n, o]), xe(() => {
|
|
804
796
|
fe.current?.scrollIntoView({ behavior: "smooth" });
|
|
805
|
-
}, [
|
|
797
|
+
}, [f]);
|
|
806
798
|
const pe = async () => {
|
|
807
|
-
if (!N.trim() ||
|
|
808
|
-
const
|
|
799
|
+
if (!N.trim() || !W) return;
|
|
800
|
+
const w = N.trim();
|
|
809
801
|
T("");
|
|
810
802
|
try {
|
|
811
|
-
await V.current?.sendMessage(
|
|
812
|
-
} catch (
|
|
813
|
-
console.error("Failed to send message:",
|
|
803
|
+
await V.current?.sendMessage(w);
|
|
804
|
+
} catch (k) {
|
|
805
|
+
console.error("Failed to send message:", k);
|
|
814
806
|
}
|
|
815
|
-
}, nt = (
|
|
816
|
-
|
|
817
|
-
}, ot = (
|
|
818
|
-
|
|
819
|
-
}, st =
|
|
820
|
-
return console.log("[AriaFlow Widget] Rendering widget component", { isInitialized:
|
|
807
|
+
}, nt = (w) => {
|
|
808
|
+
w.key === "Enter" && !w.shiftKey && (w.preventDefault(), pe());
|
|
809
|
+
}, ot = (w) => {
|
|
810
|
+
!W || F || V.current?.sendMessage(w);
|
|
811
|
+
}, st = g || I?.config.title || "Ninewells Hospital", it = b || I?.config.subtitle || "How can we help you today?", rt = $ || I?.config.emptyChatMessage || "Start a conversation with Ninewells...";
|
|
812
|
+
return console.log("[AriaFlow Widget] Rendering widget component", { isInitialized: S, isOpen: y, position: a }), /* @__PURE__ */ d(
|
|
821
813
|
"div",
|
|
822
814
|
{
|
|
823
|
-
className: `ariaflow-widget-container ariaflow-widget-${a} ariaflow-widget-${
|
|
824
|
-
"data-theme":
|
|
815
|
+
className: `ariaflow-widget-container ariaflow-widget-${a} ariaflow-widget-${_} ariaflow-widget-radius-${c}`,
|
|
816
|
+
"data-theme": s,
|
|
825
817
|
style: {
|
|
826
|
-
"--ariaflow-accent-color":
|
|
827
|
-
"--ariaflow-base-color":
|
|
818
|
+
"--ariaflow-accent-color": u,
|
|
819
|
+
"--ariaflow-base-color": l
|
|
828
820
|
},
|
|
829
821
|
children: [
|
|
830
|
-
!
|
|
822
|
+
!y && /* @__PURE__ */ d(
|
|
831
823
|
"button",
|
|
832
824
|
{
|
|
833
825
|
className: "ariaflow-widget-launcher",
|
|
834
826
|
onClick: () => p(!0),
|
|
835
827
|
style: {
|
|
836
828
|
backgroundColor: r,
|
|
837
|
-
color:
|
|
838
|
-
opacity:
|
|
839
|
-
cursor:
|
|
829
|
+
color: h,
|
|
830
|
+
opacity: S ? 1 : 0.8,
|
|
831
|
+
cursor: S ? "pointer" : "wait",
|
|
840
832
|
position: "relative"
|
|
841
833
|
},
|
|
842
|
-
"aria-label":
|
|
843
|
-
disabled: !
|
|
844
|
-
title:
|
|
834
|
+
"aria-label": S ? "Open chat" : "Connecting to agent...",
|
|
835
|
+
disabled: !S,
|
|
836
|
+
title: S ? "Click to start chat" : "Connecting to agent...",
|
|
845
837
|
children: [
|
|
846
|
-
!
|
|
838
|
+
!S && /* @__PURE__ */ d(
|
|
847
839
|
"div",
|
|
848
840
|
{
|
|
849
841
|
className: "ariaflow-widget-launcher-loading",
|
|
@@ -854,14 +846,14 @@ function $t({
|
|
|
854
846
|
transform: "translate(-50%, -50%)",
|
|
855
847
|
width: "20px",
|
|
856
848
|
height: "20px",
|
|
857
|
-
border: `2px solid ${
|
|
849
|
+
border: `2px solid ${h}`,
|
|
858
850
|
borderTop: "2px solid transparent",
|
|
859
851
|
borderRadius: "50%",
|
|
860
852
|
animation: "spin 1s linear infinite"
|
|
861
853
|
}
|
|
862
854
|
}
|
|
863
855
|
),
|
|
864
|
-
|
|
856
|
+
S && /* @__PURE__ */ d(
|
|
865
857
|
"svg",
|
|
866
858
|
{
|
|
867
859
|
width: "24",
|
|
@@ -870,41 +862,41 @@ function $t({
|
|
|
870
862
|
fill: "none",
|
|
871
863
|
stroke: "currentColor",
|
|
872
864
|
strokeWidth: "2",
|
|
873
|
-
children: /* @__PURE__ */
|
|
865
|
+
children: /* @__PURE__ */ d("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
|
|
874
866
|
}
|
|
875
867
|
)
|
|
876
868
|
]
|
|
877
869
|
}
|
|
878
870
|
),
|
|
879
|
-
|
|
871
|
+
y && S && /* @__PURE__ */ d(
|
|
880
872
|
"div",
|
|
881
873
|
{
|
|
882
874
|
className: "ariaflow-widget-window",
|
|
883
875
|
style: {
|
|
884
|
-
backgroundColor:
|
|
876
|
+
backgroundColor: s === "dark" && l ? l : void 0,
|
|
885
877
|
borderRadius: ie[c]
|
|
886
878
|
},
|
|
887
879
|
children: [
|
|
888
|
-
/* @__PURE__ */
|
|
880
|
+
/* @__PURE__ */ d(
|
|
889
881
|
"div",
|
|
890
882
|
{
|
|
891
883
|
className: "ariaflow-widget-header",
|
|
892
884
|
style: {
|
|
893
|
-
backgroundColor:
|
|
885
|
+
backgroundColor: u,
|
|
894
886
|
borderRadius: c === "none" ? "0" : `${ie[c]} ${ie[c]} 0 0`
|
|
895
887
|
},
|
|
896
888
|
children: [
|
|
897
|
-
/* @__PURE__ */
|
|
898
|
-
/* @__PURE__ */
|
|
899
|
-
/* @__PURE__ */
|
|
889
|
+
/* @__PURE__ */ d("div", { className: "ariaflow-widget-header-content", children: /* @__PURE__ */ d("div", { className: "ariaflow-widget-title-group", children: [
|
|
890
|
+
/* @__PURE__ */ d("h3", { className: "ariaflow-widget-title", children: st }),
|
|
891
|
+
/* @__PURE__ */ d("p", { className: "ariaflow-widget-subtitle", children: it })
|
|
900
892
|
] }) }),
|
|
901
|
-
/* @__PURE__ */
|
|
893
|
+
/* @__PURE__ */ d(
|
|
902
894
|
"button",
|
|
903
895
|
{
|
|
904
896
|
className: "ariaflow-widget-close",
|
|
905
897
|
onClick: () => p(!1),
|
|
906
898
|
"aria-label": "Close chat",
|
|
907
|
-
children: /* @__PURE__ */
|
|
899
|
+
children: /* @__PURE__ */ d(
|
|
908
900
|
"svg",
|
|
909
901
|
{
|
|
910
902
|
width: "20",
|
|
@@ -914,8 +906,8 @@ function $t({
|
|
|
914
906
|
stroke: "currentColor",
|
|
915
907
|
strokeWidth: "2",
|
|
916
908
|
children: [
|
|
917
|
-
/* @__PURE__ */
|
|
918
|
-
/* @__PURE__ */
|
|
909
|
+
/* @__PURE__ */ d("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
910
|
+
/* @__PURE__ */ d("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
919
911
|
]
|
|
920
912
|
}
|
|
921
913
|
)
|
|
@@ -924,86 +916,72 @@ function $t({
|
|
|
924
916
|
]
|
|
925
917
|
}
|
|
926
918
|
),
|
|
927
|
-
|
|
928
|
-
/* @__PURE__ */
|
|
919
|
+
!W && /* @__PURE__ */ d("div", { className: "ariaflow-widget-status", children: [
|
|
920
|
+
/* @__PURE__ */ d("span", { className: "ariaflow-widget-status-dot" }),
|
|
929
921
|
"Connecting..."
|
|
930
922
|
] }),
|
|
931
|
-
/* @__PURE__ */
|
|
932
|
-
|
|
923
|
+
/* @__PURE__ */ d("div", { className: "ariaflow-widget-messages", children: f.length === 0 ? /* @__PURE__ */ d("div", { className: "ariaflow-widget-empty", children: /* @__PURE__ */ d("p", { children: W ? rt : "Connecting to agent..." }) }) : /* @__PURE__ */ d(D, { children: [
|
|
924
|
+
f.map((w, k) => (f.length - 1, w.role === "tool" ? null : /* @__PURE__ */ d(
|
|
933
925
|
"div",
|
|
934
926
|
{
|
|
935
|
-
className: `ariaflow-widget-message ariaflow-widget-message-${
|
|
936
|
-
children: /* @__PURE__ */
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
y.toolCall && /* @__PURE__ */ u("div", { className: "ariaflow-widget-tool-args", children: [
|
|
943
|
-
/* @__PURE__ */ u("strong", { children: "Arguments:" }),
|
|
944
|
-
" ",
|
|
945
|
-
JSON.stringify(y.toolCall.arguments, null, 2)
|
|
946
|
-
] }),
|
|
947
|
-
y.toolResult && /* @__PURE__ */ u("div", { className: "ariaflow-widget-tool-result", children: [
|
|
948
|
-
/* @__PURE__ */ u("strong", { children: "Result:" }),
|
|
949
|
-
" ",
|
|
950
|
-
JSON.stringify(y.toolResult, null, 2)
|
|
951
|
-
] })
|
|
952
|
-
] })
|
|
953
|
-
] }) : /* @__PURE__ */ u(U, { children: [
|
|
954
|
-
y.content,
|
|
955
|
-
y.isStreaming && /* @__PURE__ */ u("span", { className: "ariaflow-widget-typing-indicator", children: [
|
|
956
|
-
/* @__PURE__ */ u("span", { children: "•" }),
|
|
957
|
-
/* @__PURE__ */ u("span", { children: "•" }),
|
|
958
|
-
/* @__PURE__ */ u("span", { children: "•" })
|
|
927
|
+
className: `ariaflow-widget-message ariaflow-widget-message-${w.role}`,
|
|
928
|
+
children: /* @__PURE__ */ d("div", { className: "ariaflow-widget-message-bubble", children: /* @__PURE__ */ d(D, { children: [
|
|
929
|
+
w.content,
|
|
930
|
+
w.isStreaming && /* @__PURE__ */ d("span", { className: "ariaflow-widget-typing-indicator", children: [
|
|
931
|
+
/* @__PURE__ */ d("span", { children: "•" }),
|
|
932
|
+
/* @__PURE__ */ d("span", { children: "•" }),
|
|
933
|
+
/* @__PURE__ */ d("span", { children: "•" })
|
|
959
934
|
] })
|
|
960
935
|
] }) })
|
|
961
936
|
},
|
|
962
|
-
|
|
937
|
+
w.id
|
|
963
938
|
))),
|
|
964
|
-
/* @__PURE__ */
|
|
965
|
-
Ze && !
|
|
966
|
-
/* @__PURE__ */
|
|
967
|
-
/* @__PURE__ */
|
|
968
|
-
/* @__PURE__ */
|
|
939
|
+
/* @__PURE__ */ d("div", { ref: fe }),
|
|
940
|
+
Ze && !F && /* @__PURE__ */ d("div", { className: "ariaflow-widget-message ariaflow-widget-message-assistant", children: /* @__PURE__ */ d("div", { className: "ariaflow-widget-message-bubble", children: /* @__PURE__ */ d("span", { className: "ariaflow-widget-typing-indicator", children: [
|
|
941
|
+
/* @__PURE__ */ d("span", { children: "•" }),
|
|
942
|
+
/* @__PURE__ */ d("span", { children: "•" }),
|
|
943
|
+
/* @__PURE__ */ d("span", { children: "•" })
|
|
969
944
|
] }) }) })
|
|
970
945
|
] }) }),
|
|
971
|
-
!
|
|
972
|
-
"
|
|
973
|
-
{
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
946
|
+
!F && (() => {
|
|
947
|
+
const w = [...f].reverse().find((k) => k.role !== "tool");
|
|
948
|
+
return w?.role === "assistant" && w.suggestions && w.suggestions.length > 0 ? /* @__PURE__ */ d("div", { className: "ariaflow-widget-suggestions", children: w.suggestions.map((k) => /* @__PURE__ */ d(
|
|
949
|
+
"button",
|
|
950
|
+
{
|
|
951
|
+
className: "ariaflow-widget-chip",
|
|
952
|
+
onClick: () => ot(k),
|
|
953
|
+
style: {
|
|
954
|
+
borderColor: u,
|
|
955
|
+
color: u,
|
|
956
|
+
backgroundColor: "rgba(255, 255, 255, 0.95)",
|
|
957
|
+
backdropFilter: "blur(4px)"
|
|
958
|
+
},
|
|
959
|
+
children: k
|
|
981
960
|
},
|
|
982
|
-
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
/* @__PURE__ */ u(
|
|
961
|
+
k
|
|
962
|
+
)) }) : null;
|
|
963
|
+
})(),
|
|
964
|
+
/* @__PURE__ */ d("div", { className: "ariaflow-widget-input", children: [
|
|
965
|
+
/* @__PURE__ */ d(
|
|
988
966
|
"textarea",
|
|
989
967
|
{
|
|
990
968
|
value: N,
|
|
991
|
-
onInput: (
|
|
969
|
+
onInput: (w) => T(w.target.value),
|
|
992
970
|
onKeyDown: nt,
|
|
993
|
-
placeholder:
|
|
971
|
+
placeholder: W ? F ? oe > 0 ? `Agent is responding... (${oe} message${oe > 1 ? "s" : ""} queued)` : "Agent is responding..." : "Type your message..." : "Connecting...",
|
|
994
972
|
rows: 1,
|
|
995
|
-
disabled:
|
|
973
|
+
disabled: !W
|
|
996
974
|
}
|
|
997
975
|
),
|
|
998
|
-
/* @__PURE__ */
|
|
976
|
+
/* @__PURE__ */ d(
|
|
999
977
|
"button",
|
|
1000
978
|
{
|
|
1001
979
|
className: "ariaflow-widget-send",
|
|
1002
980
|
onClick: pe,
|
|
1003
|
-
disabled: !N.trim() ||
|
|
1004
|
-
style: { backgroundColor:
|
|
981
|
+
disabled: !N.trim() || !W,
|
|
982
|
+
style: { backgroundColor: u },
|
|
1005
983
|
"aria-label": "Send message",
|
|
1006
|
-
children: /* @__PURE__ */
|
|
984
|
+
children: /* @__PURE__ */ d(
|
|
1007
985
|
"svg",
|
|
1008
986
|
{
|
|
1009
987
|
width: "18",
|
|
@@ -1013,8 +991,8 @@ function $t({
|
|
|
1013
991
|
stroke: "currentColor",
|
|
1014
992
|
strokeWidth: "2",
|
|
1015
993
|
children: [
|
|
1016
|
-
/* @__PURE__ */
|
|
1017
|
-
/* @__PURE__ */
|
|
994
|
+
/* @__PURE__ */ d("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
|
|
995
|
+
/* @__PURE__ */ d("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
|
|
1018
996
|
]
|
|
1019
997
|
}
|
|
1020
998
|
)
|