@ariaflowagents/widget 0.6.11 → 0.6.12
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 +251 -251
- package/dist/widget.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
var
|
|
1
|
+
var z, m, Te, D, ye, He, Ie, Ue, ue, ae, le, j = {}, De = [], lt = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, ne = Array.isArray;
|
|
2
2
|
function P(t, e) {
|
|
3
3
|
for (var n in e) t[n] = e[n];
|
|
4
4
|
return t;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function ge(t) {
|
|
7
7
|
t && t.parentNode && t.parentNode.removeChild(t);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function O(t, e, n) {
|
|
10
10
|
var o, i, s, a = {};
|
|
11
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 ?
|
|
13
|
-
return
|
|
12
|
+
if (arguments.length > 2 && (a.children = arguments.length > 3 ? z.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
|
|
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 ?? ++
|
|
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 ?? ++Te, __i: -1, __u: 0 };
|
|
17
17
|
return i == null && m.vnode != null && m.vnode(s), s;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function R(t) {
|
|
20
20
|
return t.children;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function X(t, e) {
|
|
23
23
|
this.props = t, this.context = e;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
if (e == null) return t.__ ?
|
|
25
|
+
function Q(t, e) {
|
|
26
|
+
if (e == null) return t.__ ? Q(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" ? Q(t) : null;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function Re(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 Re(t);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
(!t.__d && (t.__d = !0) &&
|
|
40
|
+
function we(t) {
|
|
41
|
+
(!t.__d && (t.__d = !0) && D.push(t) && !Z.__r++ || ye != m.debounceRendering) && ((ye = m.debounceRendering) || He)(Z);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
for (var t, e, n, o, i, s, a, _ = 1;
|
|
45
|
-
|
|
43
|
+
function Z() {
|
|
44
|
+
for (var t, e, n, o, i, s, a, _ = 1; D.length; ) D.length > _ && D.sort(Ie), t = D.shift(), _ = D.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), de(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [i] : null, s, i ?? Q(o), !!(32 & o.__u), a), n.__v = o.__v, n.__.__k[n.__i] = n, Qe(s, n, a), o.__e = o.__ = null, n.__e != i && Re(n)));
|
|
45
|
+
Z.__r = 0;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
var r, h, g,
|
|
49
|
-
for (c =
|
|
47
|
+
function Le(t, e, n, o, i, s, a, _, c, l, u) {
|
|
48
|
+
var r, h, g, v, $, y, p, f = o && o.__k || De, F = e.length;
|
|
49
|
+
for (c = _t(n, e, f, c, F), r = 0; r < F; r++) (g = n.__k[r]) != null && (h = g.__i == -1 ? j : f[g.__i] || j, g.__i = r, y = de(t, g, h, i, s, a, _, c, l, u), v = g.__e, g.ref && h.ref != g.ref && (h.ref && he(h.ref, null, g), u.push(g.ref, g.__c || v, g)), $ == null && v != null && ($ = v), (p = !!(4 & g.__u)) || h.__k === g.__k ? c = Oe(g, c, t, p) : typeof g.type == "function" && y !== void 0 ? c = y : v && (c = v.nextSibling), g.__u &= -7);
|
|
50
50
|
return n.__e = $, c;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function _t(t, e, n, o, i) {
|
|
53
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] =
|
|
55
|
-
if (r) for (s = 0; s < u; s++) (_ = n[s]) != null && !(2 & _.__u) && (_.__e == o && (o =
|
|
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) : ne(a) ? a = t.__k[s] = q(R, { 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 = ct(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 = Q(_)), je(_, _));
|
|
56
56
|
return o;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function Oe(t, e, n, o) {
|
|
59
59
|
var i, s;
|
|
60
60
|
if (typeof t.type == "function") {
|
|
61
|
-
for (i = t.__k, s = 0; i && s < i.length; s++) i[s] && (i[s].__ = t, e =
|
|
61
|
+
for (i = t.__k, s = 0; i && s < i.length; s++) i[s] && (i[s].__ = t, e = Oe(i[s], e, n, o));
|
|
62
62
|
return e;
|
|
63
63
|
}
|
|
64
|
-
t.__e != e && (o && (e && t.type && !e.parentNode && (e =
|
|
64
|
+
t.__e != e && (o && (e && t.type && !e.parentNode && (e = Q(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
|
|
70
|
+
function ct(t, e, n, o) {
|
|
71
71
|
var i, s, a, _ = t.key, c = t.type, l = e[n], u = l != null && (2 & l.__u) == 0;
|
|
72
72
|
if (l === null && _ == null || u && _ == l.key && c == l.type) return n;
|
|
73
73
|
if (o > (u ? 1 : 0)) {
|
|
@@ -75,17 +75,17 @@ function _t(t, e, n, o) {
|
|
|
75
75
|
}
|
|
76
76
|
return -1;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" ||
|
|
78
|
+
function ve(t, e, n) {
|
|
79
|
+
e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || lt.test(e) ? n : n + "px";
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function K(t, e, n, o, i) {
|
|
82
82
|
var s, a;
|
|
83
83
|
e: if (e == "style") if (typeof n == "string") t.style.cssText = n;
|
|
84
84
|
else {
|
|
85
|
-
if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n ||
|
|
86
|
-
if (n) for (e in n) o && n[e] == o[e] ||
|
|
85
|
+
if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || ve(t.style, e, "");
|
|
86
|
+
if (n) for (e in n) o && n[e] == o[e] || ve(t.style, e, n[e]);
|
|
87
87
|
}
|
|
88
|
-
else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(
|
|
88
|
+
else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(Ue, "$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 = ue, t.addEventListener(e, s ? le : ae, s)) : t.removeEventListener(e, s ? le : ae, 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 {
|
|
@@ -96,60 +96,60 @@ function J(t, e, n, o, i) {
|
|
|
96
96
|
typeof n == "function" || (n == null || n === !1 && e[4] != "-" ? t.removeAttribute(e) : t.setAttribute(e, e == "popover" && n == 1 ? "" : n));
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function be(t) {
|
|
100
100
|
return function(e) {
|
|
101
101
|
if (this.l) {
|
|
102
102
|
var n = this.l[e.type + t];
|
|
103
|
-
if (e.t == null) e.t =
|
|
103
|
+
if (e.t == null) e.t = ue++;
|
|
104
104
|
else if (e.t < n.u) return;
|
|
105
105
|
return n(m.event ? m.event(e) : e);
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
var u, r, h, g,
|
|
109
|
+
function de(t, e, n, o, i, s, a, _, c, l) {
|
|
110
|
+
var u, r, h, g, v, $, y, p, f, F, x, H, W, V, A, I, U, N = e.type;
|
|
111
111
|
if (e.constructor !== void 0) return null;
|
|
112
112
|
128 & n.__u && (c = !!(32 & n.__u), s = [_ = e.__e = n.__e]), (u = m.__b) && u(e);
|
|
113
|
-
e: if (typeof
|
|
114
|
-
if (p = e.props, f = "prototype" in
|
|
113
|
+
e: if (typeof N == "function") try {
|
|
114
|
+
if (p = e.props, f = "prototype" in N && N.prototype.render, F = (u = N.contextType) && o[u.__c], x = u ? F ? F.props.value : u.__ : o, n.__c ? y = (r = e.__c = n.__c).__ = r.__E : (f ? e.__c = r = new N(p, x) : (e.__c = r = new X(p, x), r.constructor = N, r.render = gt), F && F.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 && N.getDerivedStateFromProps != null && (r.__s == r.state && (r.__s = P({}, r.__s)), P(r.__s, N.getDerivedStateFromProps(p, r.__s))), g = r.props, v = r.state, r.__v = e, h) f && N.getDerivedStateFromProps == null && r.componentWillMount != null && r.componentWillMount(), f && r.componentDidMount != null && r.__h.push(r.componentDidMount);
|
|
115
115
|
else {
|
|
116
|
-
if (f &&
|
|
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
|
-
|
|
119
|
-
}),
|
|
116
|
+
if (f && N.getDerivedStateFromProps == null && p !== g && r.componentWillReceiveProps != null && r.componentWillReceiveProps(p, x), e.__v == n.__v || !r.__e && r.shouldComponentUpdate != null && r.shouldComponentUpdate(p, r.__s, x) === !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(M) {
|
|
118
|
+
M && (M.__ = e);
|
|
119
|
+
}), H = 0; H < r._sb.length; H++) r.__h.push(r._sb[H]);
|
|
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,
|
|
124
|
-
r.componentDidUpdate(g,
|
|
123
|
+
r.componentWillUpdate != null && r.componentWillUpdate(p, r.__s, x), f && r.componentDidUpdate != null && r.__h.push(function() {
|
|
124
|
+
r.componentDidUpdate(g, v, $);
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
if (r.context =
|
|
128
|
-
for (r.state = r.__s, r.__d = !1, W && W(e), u = r.render(r.props, r.state, r.context),
|
|
127
|
+
if (r.context = x, r.props = p, r.__P = t, r.__e = !1, W = m.__r, V = 0, f) {
|
|
128
|
+
for (r.state = r.__s, r.__d = !1, W && W(e), u = r.render(r.props, r.state, r.context), A = 0; A < r._sb.length; A++) r.__h.push(r._sb[A]);
|
|
129
129
|
r._sb = [];
|
|
130
130
|
} else do
|
|
131
131
|
r.__d = !1, W && W(e), u = r.render(r.props, r.state, r.context), r.state = r.__s;
|
|
132
|
-
while (r.__d && ++
|
|
133
|
-
r.state = r.__s, r.getChildContext != null && (o = P(P({}, o), r.getChildContext())), f && !h && r.getSnapshotBeforeUpdate != null && ($ = r.getSnapshotBeforeUpdate(g,
|
|
134
|
-
} catch (
|
|
135
|
-
if (e.__v = null, c || s != null) if (
|
|
132
|
+
while (r.__d && ++V < 25);
|
|
133
|
+
r.state = r.__s, r.getChildContext != null && (o = P(P({}, o), r.getChildContext())), f && !h && r.getSnapshotBeforeUpdate != null && ($ = r.getSnapshotBeforeUpdate(g, v)), I = u, u != null && u.type === R && u.key == null && (I = qe(u.props.children)), _ = Le(t, ne(I) ? I : [I], 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 (M) {
|
|
135
|
+
if (e.__v = null, c || s != null) if (M.then) {
|
|
136
136
|
for (e.__u |= c ? 160 : 128; _ && _.nodeType == 8 && _.nextSibling; ) _ = _.nextSibling;
|
|
137
137
|
s[s.indexOf(_)] = null, e.__e = _;
|
|
138
138
|
} else {
|
|
139
|
-
for (
|
|
140
|
-
|
|
139
|
+
for (U = s.length; U--; ) ge(s[U]);
|
|
140
|
+
_e(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, M.then || _e(e);
|
|
143
|
+
m.__e(M, e, n);
|
|
144
144
|
}
|
|
145
|
-
else s == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : _ = e.__e =
|
|
145
|
+
else s == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : _ = e.__e = ut(n.__e, e, n, o, i, s, a, c, l);
|
|
146
146
|
return (u = m.diffed) && u(e), 128 & e.__u ? void 0 : _;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
t && t.__c && (t.__c.__e = !0), t && t.__k && t.__k.forEach(
|
|
148
|
+
function _e(t) {
|
|
149
|
+
t && t.__c && (t.__c.__e = !0), t && t.__k && t.__k.forEach(_e);
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
for (var o = 0; o < n.length; o++)
|
|
151
|
+
function Qe(t, e, n) {
|
|
152
|
+
for (var o = 0; o < n.length; o++) he(n[o], n[++o], n[++o]);
|
|
153
153
|
m.__c && m.__c(e, t), t.some(function(i) {
|
|
154
154
|
try {
|
|
155
155
|
t = i.__h, i.__h = [], t.some(function(s) {
|
|
@@ -160,11 +160,11 @@ function Oe(t, e, n) {
|
|
|
160
160
|
}
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
|
-
function
|
|
164
|
-
return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t :
|
|
163
|
+
function qe(t) {
|
|
164
|
+
return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : ne(t) ? t.map(qe) : P({}, t);
|
|
165
165
|
}
|
|
166
|
-
function
|
|
167
|
-
var l, u, r, h, g,
|
|
166
|
+
function ut(t, e, n, o, i, s, a, _, c) {
|
|
167
|
+
var l, u, r, h, g, v, $, y = n.props || j, p = e.props, f = e.type;
|
|
168
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
169
|
for (l = 0; l < s.length; l++) if ((g = s[l]) && "setAttribute" in g == !!f && (f ? g.localName == f : g.nodeType == 3)) {
|
|
170
170
|
t = g, s[l] = null;
|
|
@@ -177,22 +177,22 @@ function ct(t, e, n, o, i, s, a, _, c) {
|
|
|
177
177
|
}
|
|
178
178
|
if (f == null) y === p || _ && t.data == p || (t.data = p);
|
|
179
179
|
else {
|
|
180
|
-
if (s = s &&
|
|
180
|
+
if (s = s && z.call(t.childNodes), !_ && s != null) for (y = {}, l = 0; l < t.attributes.length; l++) y[(g = t.attributes[l]).name] = g.value;
|
|
181
181
|
for (l in y) if (g = y[l], l != "children") {
|
|
182
182
|
if (l == "dangerouslySetInnerHTML") r = g;
|
|
183
183
|
else if (!(l in p)) {
|
|
184
184
|
if (l == "value" && "defaultValue" in p || l == "checked" && "defaultChecked" in p) continue;
|
|
185
|
-
|
|
185
|
+
K(t, l, null, g, i);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
for (l in p) g = p[l], l == "children" ? h = g : l == "dangerouslySetInnerHTML" ? u = g : l == "value" ?
|
|
188
|
+
for (l in p) g = p[l], l == "children" ? h = g : l == "dangerouslySetInnerHTML" ? u = g : l == "value" ? v = g : l == "checked" ? $ = g : _ && typeof g != "function" || y[l] === g || K(t, l, g, y[l], i);
|
|
189
189
|
if (u) _ || r && (u.__html == r.__html || u.__html == t.innerHTML) || (t.innerHTML = u.__html), e.__k = [];
|
|
190
|
-
else if (r && (t.innerHTML = ""),
|
|
191
|
-
_ || (l = "value", f == "progress" &&
|
|
190
|
+
else if (r && (t.innerHTML = ""), Le(e.type == "template" ? t.content : t, ne(h) ? h : [h], e, n, o, f == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, a, s ? s[0] : n.__k && Q(n, 0), _, c), s != null) for (l = s.length; l--; ) ge(s[l]);
|
|
191
|
+
_ || (l = "value", f == "progress" && v == null ? t.removeAttribute("value") : v != null && (v !== t[l] || f == "progress" && !v || f == "option" && v != y[l]) && K(t, l, v, y[l], i), l = "checked", $ != null && $ != t[l] && K(t, l, $, y[l], i));
|
|
192
192
|
}
|
|
193
193
|
return t;
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function he(t, e, n) {
|
|
196
196
|
try {
|
|
197
197
|
if (typeof t == "function") {
|
|
198
198
|
var o = typeof t.__u == "function";
|
|
@@ -202,9 +202,9 @@ function de(t, e, n) {
|
|
|
202
202
|
m.__e(i, n);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function je(t, e, n) {
|
|
206
206
|
var o, i;
|
|
207
|
-
if (m.unmount && m.unmount(t), (o = t.ref) && (o.current && o.current != t.__e ||
|
|
207
|
+
if (m.unmount && m.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || he(o, null, e)), (o = t.__c) != null) {
|
|
208
208
|
if (o.componentWillUnmount) try {
|
|
209
209
|
o.componentWillUnmount();
|
|
210
210
|
} catch (s) {
|
|
@@ -212,63 +212,63 @@ function qe(t, e, n) {
|
|
|
212
212
|
}
|
|
213
213
|
o.base = o.__P = null;
|
|
214
214
|
}
|
|
215
|
-
if (o = t.__k) for (i = 0; i < o.length; i++) o[i] &&
|
|
216
|
-
n ||
|
|
215
|
+
if (o = t.__k) for (i = 0; i < o.length; i++) o[i] && je(o[i], e, n || typeof t.type != "function");
|
|
216
|
+
n || ge(t.__e), t.__c = t.__ = t.__e = void 0;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
218
|
+
function gt(t, e, n) {
|
|
219
219
|
return this.constructor(t, n);
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function oe(t, e, n) {
|
|
222
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 = [],
|
|
223
|
+
e == document && (e = document.documentElement), m.__ && m.__(t, e), i = (o = typeof n == "function") ? null : n && n.__k || e.__k, s = [], a = [], de(e, t = (!o && n || e).__k = O(R, null, [t]), i || j, j, e.namespaceURI, !o && n ? [n] : i ? null : e.firstChild ? z.call(e.childNodes) : null, s, !o && n ? n : i ? i.__e : e.firstChild, o, a), Qe(s, t, a);
|
|
224
224
|
}
|
|
225
|
-
function
|
|
226
|
-
|
|
225
|
+
function Be(t, e) {
|
|
226
|
+
oe(t, e, Be);
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function ze(t, e, n) {
|
|
229
229
|
var o, i, s, a, _ = P({}, t.props);
|
|
230
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 ?
|
|
231
|
+
return arguments.length > 2 && (_.children = arguments.length > 3 ? z.call(arguments, 2) : n), q(t.type, _, o || t.key, i || t.ref, null);
|
|
232
232
|
}
|
|
233
|
-
|
|
233
|
+
z = De.slice, m = { __e: function(t, e, n, o) {
|
|
234
234
|
for (var i, s, a; e = e.__; ) if ((i = e.__c) && !i.__) try {
|
|
235
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
236
|
} catch (_) {
|
|
237
237
|
t = _;
|
|
238
238
|
}
|
|
239
239
|
throw t;
|
|
240
|
-
} },
|
|
240
|
+
} }, Te = 0, X.prototype.setState = function(t, e) {
|
|
241
241
|
var n;
|
|
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),
|
|
243
|
-
},
|
|
244
|
-
this.__v && (this.__e = !0, t && this.__h.push(t),
|
|
245
|
-
},
|
|
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), we(this));
|
|
243
|
+
}, X.prototype.forceUpdate = function(t) {
|
|
244
|
+
this.__v && (this.__e = !0, t && this.__h.push(t), we(this));
|
|
245
|
+
}, X.prototype.render = R, D = [], He = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, Ie = function(t, e) {
|
|
246
246
|
return t.__v.__b - e.__v.__b;
|
|
247
|
-
},
|
|
248
|
-
function
|
|
249
|
-
return
|
|
247
|
+
}, Z.__r = 0, Ue = /(PointerCapture)$|Capture$/i, ue = 0, ae = be(!1), le = be(!0);
|
|
248
|
+
function ee() {
|
|
249
|
+
return ee = Object.assign ? Object.assign.bind() : function(t) {
|
|
250
250
|
for (var e = 1; e < arguments.length; e++) {
|
|
251
251
|
var n = arguments[e];
|
|
252
252
|
for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]);
|
|
253
253
|
}
|
|
254
254
|
return t;
|
|
255
|
-
},
|
|
255
|
+
}, ee.apply(this, arguments);
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function Ve(t, e) {
|
|
258
258
|
if (t == null) return {};
|
|
259
259
|
var n, o, i = {}, s = Object.keys(t);
|
|
260
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
|
-
var
|
|
264
|
-
function
|
|
263
|
+
var dt = ["context", "children"], ht = ["useFragment"];
|
|
264
|
+
function ft(t, e, n, o) {
|
|
265
265
|
function i() {
|
|
266
266
|
var s = Reflect.construct(HTMLElement, [], i);
|
|
267
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
|
-
|
|
271
|
-
}, i.prototype.attributeChangedCallback =
|
|
270
|
+
mt.call(this, o);
|
|
271
|
+
}, i.prototype.attributeChangedCallback = yt, i.prototype.disconnectedCallback = wt, n = n || t.observedAttributes || Object.keys(t.propTypes || {}), i.observedAttributes = n, t.formAssociated && (i.formAssociated = !0), n.forEach(function(s) {
|
|
272
272
|
Object.defineProperty(i.prototype, s, { get: function() {
|
|
273
273
|
return this._vdom ? this._vdom.props[s] : this._props[s];
|
|
274
274
|
}, set: function(a) {
|
|
@@ -278,75 +278,75 @@ function ht(t, e, n, o) {
|
|
|
278
278
|
} });
|
|
279
279
|
}), customElements.define(e, i), i;
|
|
280
280
|
}
|
|
281
|
-
function
|
|
281
|
+
function pt(t) {
|
|
282
282
|
this.getChildContext = function() {
|
|
283
283
|
return t.context;
|
|
284
284
|
};
|
|
285
|
-
var e = t.children, n =
|
|
286
|
-
return
|
|
285
|
+
var e = t.children, n = Ve(t, dt);
|
|
286
|
+
return ze(e, n);
|
|
287
287
|
}
|
|
288
|
-
function
|
|
288
|
+
function mt(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 = O(pt, ee({}, this._props, { context: e.detail.context }), Ke(this, this._vdomComponent, t)), (this.hasAttribute("hydrate") ? Be : oe)(this._vdom, this._root);
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function Je(t) {
|
|
293
293
|
return t.replace(/-(\w)/g, function(e, n) {
|
|
294
294
|
return n ? n.toUpperCase() : "";
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function yt(t, e, n) {
|
|
298
298
|
if (this._vdom) {
|
|
299
299
|
var o = {};
|
|
300
|
-
o[t] = n = n ?? void 0, o[
|
|
300
|
+
o[t] = n = n ?? void 0, o[Je(t)] = n, this._vdom = ze(this._vdom, o), oe(this._vdom, this._root);
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
|
|
303
|
+
function wt() {
|
|
304
|
+
oe(this._vdom = null, this._root);
|
|
305
305
|
}
|
|
306
|
-
function
|
|
307
|
-
var n = this, o = t.useFragment, i =
|
|
308
|
-
return
|
|
306
|
+
function Ce(t, e) {
|
|
307
|
+
var n = this, o = t.useFragment, i = Ve(t, ht);
|
|
308
|
+
return O(o ? R : "slot", ee({}, i, { ref: function(s) {
|
|
309
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
|
-
function
|
|
314
|
+
function Ke(t, e, n) {
|
|
315
315
|
if (t.nodeType === 3) return t.data;
|
|
316
316
|
if (t.nodeType !== 1) return null;
|
|
317
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[
|
|
318
|
+
for (s = a.length; s--; ) a[s].name !== "slot" && (i[a[s].name] = a[s].value, i[Je(a[s].name)] = a[s].value);
|
|
319
319
|
for (s = _.length; s--; ) {
|
|
320
|
-
var c =
|
|
321
|
-
l ? i[l] =
|
|
320
|
+
var c = Ke(_[s], null, n), l = _[s].slot;
|
|
321
|
+
l ? i[l] = O(Ce, { name: l }, c) : o[s] = c;
|
|
322
322
|
}
|
|
323
|
-
var u = !(!n || !n.shadow), r = e ?
|
|
324
|
-
return !u && e && (t.innerHTML = ""),
|
|
323
|
+
var u = !(!n || !n.shadow), r = e ? O(Ce, { useFragment: !u }, o) : o;
|
|
324
|
+
return !u && e && (t.innerHTML = ""), O(e || t.nodeName.toLowerCase(), i, r);
|
|
325
325
|
}
|
|
326
|
-
var
|
|
326
|
+
var vt = 0;
|
|
327
327
|
function d(t, e, n, o, i, s) {
|
|
328
328
|
e || (e = {});
|
|
329
329
|
var a, _, c = e;
|
|
330
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: --
|
|
331
|
+
var l = { type: t, props: c, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --vt, __i: -1, __u: 0, __source: i, __self: s };
|
|
332
332
|
if (typeof t == "function" && (a = t.defaultProps)) for (_ in a) c[_] === void 0 && (c[_] = a[_]);
|
|
333
333
|
return m.vnode && m.vnode(l), l;
|
|
334
334
|
}
|
|
335
|
-
var
|
|
336
|
-
function
|
|
337
|
-
C.__h && C.__h(
|
|
338
|
-
var n =
|
|
335
|
+
var B, w, ie, ke, te = 0, Ge = [], C = m, Ae = C.__b, Se = C.__r, $e = C.diffed, We = C.__c, xe = C.unmount, Ne = C.__;
|
|
336
|
+
function fe(t, e) {
|
|
337
|
+
C.__h && C.__h(w, t, te || e), te = 0;
|
|
338
|
+
var n = w.__H || (w.__H = { __: [], __h: [] });
|
|
339
339
|
return t >= n.__.length && n.__.push({}), n.__[t];
|
|
340
340
|
}
|
|
341
341
|
function E(t) {
|
|
342
|
-
return
|
|
342
|
+
return te = 1, bt(Ye, t);
|
|
343
343
|
}
|
|
344
|
-
function
|
|
345
|
-
var o =
|
|
346
|
-
if (o.t = t, !o.__c && (o.__ = [
|
|
344
|
+
function bt(t, e, n) {
|
|
345
|
+
var o = fe(B++, 2);
|
|
346
|
+
if (o.t = t, !o.__c && (o.__ = [Ye(void 0, e), function(_) {
|
|
347
347
|
var c = o.__N ? o.__N[0] : o.__[0], l = o.t(c, _);
|
|
348
348
|
c !== l && (o.__N = [l, o.__[1]], o.__c.setState({}));
|
|
349
|
-
}], o.__c =
|
|
349
|
+
}], o.__c = w, !w.__f)) {
|
|
350
350
|
var i = function(_, c, l) {
|
|
351
351
|
if (!o.__c.__H) return !0;
|
|
352
352
|
var u = o.__c.__H.__.filter(function(h) {
|
|
@@ -363,108 +363,108 @@ function vt(t, e, n) {
|
|
|
363
363
|
}
|
|
364
364
|
}), s && s.call(this, _, c, l) || r;
|
|
365
365
|
};
|
|
366
|
-
|
|
367
|
-
var s =
|
|
368
|
-
|
|
366
|
+
w.__f = !0;
|
|
367
|
+
var s = w.shouldComponentUpdate, a = w.componentWillUpdate;
|
|
368
|
+
w.componentWillUpdate = function(_, c, l) {
|
|
369
369
|
if (this.__e) {
|
|
370
370
|
var u = s;
|
|
371
371
|
s = void 0, i(_, c, l), s = u;
|
|
372
372
|
}
|
|
373
373
|
a && a.call(this, _, c, l);
|
|
374
|
-
},
|
|
374
|
+
}, w.shouldComponentUpdate = i;
|
|
375
375
|
}
|
|
376
376
|
return o.__N || o.__;
|
|
377
377
|
}
|
|
378
|
-
function
|
|
379
|
-
var n =
|
|
380
|
-
!C.__s &&
|
|
378
|
+
function Me(t, e) {
|
|
379
|
+
var n = fe(B++, 3);
|
|
380
|
+
!C.__s && Xe(n.__H, e) && (n.__ = t, n.u = e, w.__H.__h.push(n));
|
|
381
381
|
}
|
|
382
382
|
function Fe(t) {
|
|
383
|
-
return
|
|
383
|
+
return te = 5, Ct(function() {
|
|
384
384
|
return { current: t };
|
|
385
385
|
}, []);
|
|
386
386
|
}
|
|
387
|
-
function
|
|
388
|
-
var n =
|
|
389
|
-
return
|
|
387
|
+
function Ct(t, e) {
|
|
388
|
+
var n = fe(B++, 7);
|
|
389
|
+
return Xe(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
|
|
390
390
|
}
|
|
391
|
-
function
|
|
392
|
-
for (var t; t =
|
|
393
|
-
t.__H.__h.forEach(
|
|
391
|
+
function kt() {
|
|
392
|
+
for (var t; t = Ge.shift(); ) if (t.__P && t.__H) try {
|
|
393
|
+
t.__H.__h.forEach(Y), t.__H.__h.forEach(ce), t.__H.__h = [];
|
|
394
394
|
} catch (e) {
|
|
395
395
|
t.__H.__h = [], C.__e(e, t.__v);
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
C.__b = function(t) {
|
|
399
|
-
|
|
399
|
+
w = null, Ae && Ae(t);
|
|
400
400
|
}, C.__ = function(t, e) {
|
|
401
401
|
t && e.__k && e.__k.__m && (t.__m = e.__k.__m), Ne && Ne(t, e);
|
|
402
402
|
}, C.__r = function(t) {
|
|
403
|
-
|
|
404
|
-
var e = (
|
|
405
|
-
e && (
|
|
403
|
+
Se && Se(t), B = 0;
|
|
404
|
+
var e = (w = t.__c).__H;
|
|
405
|
+
e && (ie === w ? (e.__h = [], w.__h = [], e.__.forEach(function(n) {
|
|
406
406
|
n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
|
|
407
|
-
})) : (e.__h.forEach(
|
|
407
|
+
})) : (e.__h.forEach(Y), e.__h.forEach(ce), e.__h = [], B = 0)), ie = w;
|
|
408
408
|
}, C.diffed = function(t) {
|
|
409
|
-
|
|
409
|
+
$e && $e(t);
|
|
410
410
|
var e = t.__c;
|
|
411
|
-
e && e.__H && (e.__H.__h.length && (
|
|
411
|
+
e && e.__H && (e.__H.__h.length && (Ge.push(e) !== 1 && ke === C.requestAnimationFrame || ((ke = C.requestAnimationFrame) || At)(kt)), e.__H.__.forEach(function(n) {
|
|
412
412
|
n.u && (n.__H = n.u), n.u = void 0;
|
|
413
|
-
})),
|
|
413
|
+
})), ie = w = null;
|
|
414
414
|
}, C.__c = function(t, e) {
|
|
415
415
|
e.some(function(n) {
|
|
416
416
|
try {
|
|
417
|
-
n.__h.forEach(
|
|
418
|
-
return !o.__ ||
|
|
417
|
+
n.__h.forEach(Y), n.__h = n.__h.filter(function(o) {
|
|
418
|
+
return !o.__ || ce(o);
|
|
419
419
|
});
|
|
420
420
|
} catch (o) {
|
|
421
421
|
e.some(function(i) {
|
|
422
422
|
i.__h && (i.__h = []);
|
|
423
423
|
}), e = [], C.__e(o, n.__v);
|
|
424
424
|
}
|
|
425
|
-
}),
|
|
425
|
+
}), We && We(t, e);
|
|
426
426
|
}, C.unmount = function(t) {
|
|
427
|
-
|
|
427
|
+
xe && xe(t);
|
|
428
428
|
var e, n = t.__c;
|
|
429
429
|
n && n.__H && (n.__H.__.forEach(function(o) {
|
|
430
430
|
try {
|
|
431
|
-
|
|
431
|
+
Y(o);
|
|
432
432
|
} catch (i) {
|
|
433
433
|
e = i;
|
|
434
434
|
}
|
|
435
435
|
}), n.__H = void 0, e && C.__e(e, n.__v));
|
|
436
436
|
};
|
|
437
|
-
var
|
|
438
|
-
function
|
|
437
|
+
var Pe = typeof requestAnimationFrame == "function";
|
|
438
|
+
function At(t) {
|
|
439
439
|
var e, n = function() {
|
|
440
|
-
clearTimeout(o),
|
|
440
|
+
clearTimeout(o), Pe && cancelAnimationFrame(e), setTimeout(t);
|
|
441
441
|
}, o = setTimeout(n, 35);
|
|
442
|
-
|
|
442
|
+
Pe && (e = requestAnimationFrame(n));
|
|
443
443
|
}
|
|
444
|
-
function
|
|
445
|
-
var e =
|
|
446
|
-
typeof n == "function" && (t.__c = void 0, n()),
|
|
444
|
+
function Y(t) {
|
|
445
|
+
var e = w, n = t.__c;
|
|
446
|
+
typeof n == "function" && (t.__c = void 0, n()), w = e;
|
|
447
447
|
}
|
|
448
|
-
function
|
|
449
|
-
var e =
|
|
450
|
-
t.__c = t.__(),
|
|
448
|
+
function ce(t) {
|
|
449
|
+
var e = w;
|
|
450
|
+
t.__c = t.__(), w = e;
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function Xe(t, e) {
|
|
453
453
|
return !t || t.length !== e.length || e.some(function(n, o) {
|
|
454
454
|
return n !== t[o];
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
|
-
function
|
|
457
|
+
function Ye(t, e) {
|
|
458
458
|
return typeof e == "function" ? e(t) : e;
|
|
459
459
|
}
|
|
460
|
-
const
|
|
461
|
-
let
|
|
460
|
+
const St = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
461
|
+
let G = (t = 21) => {
|
|
462
462
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
|
|
463
463
|
for (; t--; )
|
|
464
|
-
e +=
|
|
464
|
+
e += St[n[t] & 63];
|
|
465
465
|
return e;
|
|
466
466
|
};
|
|
467
|
-
class
|
|
467
|
+
class $t {
|
|
468
468
|
constructor(e, n) {
|
|
469
469
|
this.agentUrl = e, this.agentId = n, this.agentConfig = null, this.ws = null, this.messageCallbacks = /* @__PURE__ */ new Set(), this.connectionCallbacks = /* @__PURE__ */ new Set(), this.streamingCallbacks = /* @__PURE__ */ new Set(), this.processingCallbacks = /* @__PURE__ */ new Set(), this.queueCallbacks = /* @__PURE__ */ new Set(), this.messages = [], this.reconnectAttempts = 0, this.maxReconnectAttempts = 5, this.reconnectDelay = 1e3, this.isAgentStreaming = !1, this.isAgentProcessing = !1, this.messageQueue = [];
|
|
470
470
|
}
|
|
@@ -558,7 +558,7 @@ class St {
|
|
|
558
558
|
] : [
|
|
559
559
|
...o,
|
|
560
560
|
{
|
|
561
|
-
id:
|
|
561
|
+
id: G(),
|
|
562
562
|
role: "assistant",
|
|
563
563
|
content: n.text,
|
|
564
564
|
timestamp: Date.now(),
|
|
@@ -581,7 +581,7 @@ class St {
|
|
|
581
581
|
else if (n.type === "tool-call") {
|
|
582
582
|
console.log("[Widget] Tool call:", n.tool), this.notifyProcessingChange(!0);
|
|
583
583
|
const o = {
|
|
584
|
-
id:
|
|
584
|
+
id: G(),
|
|
585
585
|
role: "tool",
|
|
586
586
|
content: `Calling tool: ${n.tool.name}`,
|
|
587
587
|
timestamp: Date.now(),
|
|
@@ -618,7 +618,7 @@ Result: ${JSON.stringify(n.result)}`, toolResult: n.result }
|
|
|
618
618
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN)
|
|
619
619
|
throw new Error("Not connected to agent");
|
|
620
620
|
const n = {
|
|
621
|
-
id:
|
|
621
|
+
id: G(),
|
|
622
622
|
role: "user",
|
|
623
623
|
content: e,
|
|
624
624
|
timestamp: Date.now()
|
|
@@ -658,7 +658,7 @@ Result: ${JSON.stringify(n.result)}`, toolResult: n.result }
|
|
|
658
658
|
*/
|
|
659
659
|
getSessionId() {
|
|
660
660
|
let e = sessionStorage.getItem("ariaflow_session_id");
|
|
661
|
-
return e || (e =
|
|
661
|
+
return e || (e = G(), sessionStorage.setItem("ariaflow_session_id", e)), e;
|
|
662
662
|
}
|
|
663
663
|
/**
|
|
664
664
|
* Update messages state
|
|
@@ -741,13 +741,13 @@ Result: ${JSON.stringify(n.result)}`, toolResult: n.result }
|
|
|
741
741
|
this.ws && (this.ws.close(), this.ws = null), this.messageCallbacks.clear(), this.connectionCallbacks.clear();
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
|
-
const
|
|
744
|
+
const re = {
|
|
745
745
|
none: "0",
|
|
746
746
|
small: "0.375rem",
|
|
747
747
|
medium: "0.75rem",
|
|
748
748
|
large: "1rem"
|
|
749
749
|
};
|
|
750
|
-
function
|
|
750
|
+
function Wt({
|
|
751
751
|
agentUrl: t,
|
|
752
752
|
agentId: e,
|
|
753
753
|
// Legacy props for backward compatibility
|
|
@@ -763,53 +763,53 @@ function $t({
|
|
|
763
763
|
buttonBaseColor: r = "#000000",
|
|
764
764
|
buttonAccentColor: h = "#FFFFFF",
|
|
765
765
|
title: g,
|
|
766
|
-
subtitle:
|
|
766
|
+
subtitle: v,
|
|
767
767
|
emptyChatMessage: $
|
|
768
768
|
}) {
|
|
769
|
-
const [y, p] = E(!1), [f,
|
|
770
|
-
|
|
769
|
+
const [y, p] = E(!1), [f, F] = E([]), [x, H] = E(""), [W, V] = E(!1), [A, I] = E(!1), [U, N] = E(null), [M, Ze] = E(!1), [et, tt] = E(!1), [se, nt] = E(0), J = Fe(null), pe = Fe(null);
|
|
770
|
+
Me(() => ((async () => {
|
|
771
771
|
if (t && e) {
|
|
772
772
|
console.log("[AriaFlow Widget] Using new agent resolution:", { agentUrl: t, agentId: e });
|
|
773
|
-
const
|
|
774
|
-
|
|
773
|
+
const S = new $t(t, e);
|
|
774
|
+
J.current = S;
|
|
775
775
|
try {
|
|
776
|
-
|
|
777
|
-
console.log("[AriaFlow Widget] Messages updated:",
|
|
778
|
-
}),
|
|
779
|
-
console.log("[AriaFlow Widget] Connection state:",
|
|
780
|
-
}),
|
|
781
|
-
console.log("[AriaFlow Widget] Streaming state:",
|
|
782
|
-
}),
|
|
783
|
-
console.log("[AriaFlow Widget] Queue count:",
|
|
784
|
-
}),
|
|
785
|
-
console.log("[AriaFlow Widget] Processing state:",
|
|
776
|
+
S.onMessages((k) => {
|
|
777
|
+
console.log("[AriaFlow Widget] Messages updated:", k.length), F(k);
|
|
778
|
+
}), S.onConnectionChange((k) => {
|
|
779
|
+
console.log("[AriaFlow Widget] Connection state:", k), V(k), k && I(!0);
|
|
780
|
+
}), S.onStreamingChange((k) => {
|
|
781
|
+
console.log("[AriaFlow Widget] Streaming state:", k), Ze(k);
|
|
782
|
+
}), S.onQueueChange((k) => {
|
|
783
|
+
console.log("[AriaFlow Widget] Queue count:", k), nt(k);
|
|
784
|
+
}), S.onProcessingChange((k) => {
|
|
785
|
+
console.log("[AriaFlow Widget] Processing state:", k), tt(k);
|
|
786
786
|
});
|
|
787
|
-
const
|
|
788
|
-
console.log("[AriaFlow Widget] Agent config received:",
|
|
789
|
-
} catch (
|
|
790
|
-
console.error("[AriaFlow Widget] Initialization error:",
|
|
787
|
+
const L = await S.initWidget();
|
|
788
|
+
console.log("[AriaFlow Widget] Agent config received:", L), L ? (N(L), console.log("[AriaFlow Widget] Widget initialized successfully (v0.6.11)")) : console.error("[AriaFlow Widget] Agent config fetch failed");
|
|
789
|
+
} catch (L) {
|
|
790
|
+
console.error("[AriaFlow Widget] Initialization error:", L);
|
|
791
791
|
}
|
|
792
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.");
|
|
793
793
|
})(), () => {
|
|
794
|
-
|
|
795
|
-
}), [t, e, n, o]),
|
|
796
|
-
|
|
794
|
+
J.current?.dispose();
|
|
795
|
+
}), [t, e, n, o]), Me(() => {
|
|
796
|
+
pe.current?.scrollIntoView({ behavior: "smooth" });
|
|
797
797
|
}, [f]);
|
|
798
|
-
const
|
|
799
|
-
if (!
|
|
800
|
-
const
|
|
801
|
-
|
|
798
|
+
const me = async () => {
|
|
799
|
+
if (!x.trim() || !W) return;
|
|
800
|
+
const b = x.trim();
|
|
801
|
+
H("");
|
|
802
802
|
try {
|
|
803
|
-
await
|
|
804
|
-
} catch (
|
|
805
|
-
console.error("Failed to send message:",
|
|
803
|
+
await J.current?.sendMessage(b);
|
|
804
|
+
} catch (S) {
|
|
805
|
+
console.error("Failed to send message:", S);
|
|
806
806
|
}
|
|
807
|
-
},
|
|
808
|
-
|
|
809
|
-
},
|
|
810
|
-
!W ||
|
|
811
|
-
},
|
|
812
|
-
return console.log("[AriaFlow Widget] Rendering widget component", { isInitialized:
|
|
807
|
+
}, ot = (b) => {
|
|
808
|
+
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), me());
|
|
809
|
+
}, st = (b) => {
|
|
810
|
+
!W || M || J.current?.sendMessage(b);
|
|
811
|
+
}, it = g || U?.config.title || "Ninewells Hospital", rt = v || U?.config.subtitle || "How can we help you today?", at = $ || U?.config.emptyChatMessage || "Start a conversation with Ninewells...";
|
|
812
|
+
return console.log("[AriaFlow Widget] Rendering widget component", { isInitialized: A, isOpen: y, position: a }), /* @__PURE__ */ d(
|
|
813
813
|
"div",
|
|
814
814
|
{
|
|
815
815
|
className: `ariaflow-widget-container ariaflow-widget-${a} ariaflow-widget-${_} ariaflow-widget-radius-${c}`,
|
|
@@ -827,15 +827,15 @@ function $t({
|
|
|
827
827
|
style: {
|
|
828
828
|
backgroundColor: r,
|
|
829
829
|
color: h,
|
|
830
|
-
opacity:
|
|
831
|
-
cursor:
|
|
830
|
+
opacity: A ? 1 : 0.8,
|
|
831
|
+
cursor: A ? "pointer" : "wait",
|
|
832
832
|
position: "relative"
|
|
833
833
|
},
|
|
834
|
-
"aria-label":
|
|
835
|
-
disabled: !
|
|
836
|
-
title:
|
|
834
|
+
"aria-label": A ? "Open chat" : "Connecting to agent...",
|
|
835
|
+
disabled: !A,
|
|
836
|
+
title: A ? "Click to start chat" : "Connecting to agent...",
|
|
837
837
|
children: [
|
|
838
|
-
!
|
|
838
|
+
!A && /* @__PURE__ */ d(
|
|
839
839
|
"div",
|
|
840
840
|
{
|
|
841
841
|
className: "ariaflow-widget-launcher-loading",
|
|
@@ -853,7 +853,7 @@ function $t({
|
|
|
853
853
|
}
|
|
854
854
|
}
|
|
855
855
|
),
|
|
856
|
-
|
|
856
|
+
A && /* @__PURE__ */ d(
|
|
857
857
|
"svg",
|
|
858
858
|
{
|
|
859
859
|
width: "24",
|
|
@@ -868,13 +868,13 @@ function $t({
|
|
|
868
868
|
]
|
|
869
869
|
}
|
|
870
870
|
),
|
|
871
|
-
y &&
|
|
871
|
+
y && A && /* @__PURE__ */ d(
|
|
872
872
|
"div",
|
|
873
873
|
{
|
|
874
874
|
className: "ariaflow-widget-window",
|
|
875
875
|
style: {
|
|
876
876
|
backgroundColor: s === "dark" && l ? l : void 0,
|
|
877
|
-
borderRadius:
|
|
877
|
+
borderRadius: re[c]
|
|
878
878
|
},
|
|
879
879
|
children: [
|
|
880
880
|
/* @__PURE__ */ d(
|
|
@@ -883,12 +883,12 @@ function $t({
|
|
|
883
883
|
className: "ariaflow-widget-header",
|
|
884
884
|
style: {
|
|
885
885
|
backgroundColor: u,
|
|
886
|
-
borderRadius: c === "none" ? "0" : `${
|
|
886
|
+
borderRadius: c === "none" ? "0" : `${re[c]} ${re[c]} 0 0`
|
|
887
887
|
},
|
|
888
888
|
children: [
|
|
889
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:
|
|
891
|
-
/* @__PURE__ */ d("p", { className: "ariaflow-widget-subtitle", children:
|
|
890
|
+
/* @__PURE__ */ d("h3", { className: "ariaflow-widget-title", children: it }),
|
|
891
|
+
/* @__PURE__ */ d("p", { className: "ariaflow-widget-subtitle", children: rt })
|
|
892
892
|
] }) }),
|
|
893
893
|
/* @__PURE__ */ d(
|
|
894
894
|
"button",
|
|
@@ -920,55 +920,55 @@ function $t({
|
|
|
920
920
|
/* @__PURE__ */ d("span", { className: "ariaflow-widget-status-dot" }),
|
|
921
921
|
"Connecting..."
|
|
922
922
|
] }),
|
|
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 ?
|
|
924
|
-
f.map((
|
|
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 ? at : "Connecting to agent..." }) }) : /* @__PURE__ */ d(R, { children: [
|
|
924
|
+
f.map((b, S) => (f.length - 1, b.role === "tool" ? null : /* @__PURE__ */ d(
|
|
925
925
|
"div",
|
|
926
926
|
{
|
|
927
|
-
className: `ariaflow-widget-message ariaflow-widget-message-${
|
|
928
|
-
children: /* @__PURE__ */ d("div", { className: "ariaflow-widget-message-bubble", children: /* @__PURE__ */ d(
|
|
929
|
-
|
|
930
|
-
|
|
927
|
+
className: `ariaflow-widget-message ariaflow-widget-message-${b.role}`,
|
|
928
|
+
children: /* @__PURE__ */ d("div", { className: "ariaflow-widget-message-bubble", children: /* @__PURE__ */ d(R, { children: [
|
|
929
|
+
b.content,
|
|
930
|
+
b.isStreaming && /* @__PURE__ */ d("span", { className: "ariaflow-widget-typing-indicator", children: [
|
|
931
931
|
/* @__PURE__ */ d("span", { children: "•" }),
|
|
932
932
|
/* @__PURE__ */ d("span", { children: "•" }),
|
|
933
933
|
/* @__PURE__ */ d("span", { children: "•" })
|
|
934
934
|
] })
|
|
935
935
|
] }) })
|
|
936
936
|
},
|
|
937
|
-
|
|
937
|
+
b.id
|
|
938
938
|
))),
|
|
939
|
-
/* @__PURE__ */ d("div", { ref:
|
|
940
|
-
|
|
939
|
+
/* @__PURE__ */ d("div", { ref: pe }),
|
|
940
|
+
et && !M && /* @__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
941
|
/* @__PURE__ */ d("span", { children: "•" }),
|
|
942
942
|
/* @__PURE__ */ d("span", { children: "•" }),
|
|
943
943
|
/* @__PURE__ */ d("span", { children: "•" })
|
|
944
944
|
] }) }) })
|
|
945
945
|
] }) }),
|
|
946
|
-
!
|
|
947
|
-
const
|
|
948
|
-
return
|
|
946
|
+
!M && (() => {
|
|
947
|
+
const b = [...f].reverse(), S = b.findIndex((T) => T.role === "user"), k = (S === -1 ? b : b.slice(0, S)).find((T) => T.suggestions && T.suggestions.length > 0);
|
|
948
|
+
return k && k.suggestions ? /* @__PURE__ */ d("div", { className: "ariaflow-widget-suggestions", children: k.suggestions.map((T) => /* @__PURE__ */ d(
|
|
949
949
|
"button",
|
|
950
950
|
{
|
|
951
951
|
className: "ariaflow-widget-chip",
|
|
952
|
-
onClick: () =>
|
|
952
|
+
onClick: () => st(T),
|
|
953
953
|
style: {
|
|
954
954
|
borderColor: u,
|
|
955
955
|
color: u,
|
|
956
956
|
backgroundColor: "rgba(255, 255, 255, 0.95)",
|
|
957
957
|
backdropFilter: "blur(4px)"
|
|
958
958
|
},
|
|
959
|
-
children:
|
|
959
|
+
children: T
|
|
960
960
|
},
|
|
961
|
-
|
|
961
|
+
T
|
|
962
962
|
)) }) : null;
|
|
963
963
|
})(),
|
|
964
964
|
/* @__PURE__ */ d("div", { className: "ariaflow-widget-input", children: [
|
|
965
965
|
/* @__PURE__ */ d(
|
|
966
966
|
"textarea",
|
|
967
967
|
{
|
|
968
|
-
value:
|
|
969
|
-
onInput: (
|
|
970
|
-
onKeyDown:
|
|
971
|
-
placeholder: W ?
|
|
968
|
+
value: x,
|
|
969
|
+
onInput: (b) => H(b.target.value),
|
|
970
|
+
onKeyDown: ot,
|
|
971
|
+
placeholder: W ? M ? se > 0 ? `Agent is responding... (${se} message${se > 1 ? "s" : ""} queued)` : "Agent is responding..." : "Type your message..." : "Connecting...",
|
|
972
972
|
rows: 1,
|
|
973
973
|
disabled: !W
|
|
974
974
|
}
|
|
@@ -977,8 +977,8 @@ function $t({
|
|
|
977
977
|
"button",
|
|
978
978
|
{
|
|
979
979
|
className: "ariaflow-widget-send",
|
|
980
|
-
onClick:
|
|
981
|
-
disabled: !
|
|
980
|
+
onClick: me,
|
|
981
|
+
disabled: !x.trim() || !W,
|
|
982
982
|
style: { backgroundColor: u },
|
|
983
983
|
"aria-label": "Send message",
|
|
984
984
|
children: /* @__PURE__ */ d(
|
|
@@ -1006,8 +1006,8 @@ function $t({
|
|
|
1006
1006
|
}
|
|
1007
1007
|
);
|
|
1008
1008
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1009
|
+
ft(
|
|
1010
|
+
Wt,
|
|
1011
1011
|
"ariaflow-widget",
|
|
1012
1012
|
// Properties to observe from HTML attributes (mirror Vapi's naming convention)
|
|
1013
1013
|
[
|
|
@@ -1033,12 +1033,12 @@ ht(
|
|
|
1033
1033
|
// Shadow DOM (optional, set to false for light DOM)
|
|
1034
1034
|
!1
|
|
1035
1035
|
);
|
|
1036
|
-
typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
1037
|
-
function
|
|
1036
|
+
typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", Ee) : Ee());
|
|
1037
|
+
function Ee() {
|
|
1038
1038
|
const t = document.querySelectorAll("ariaflow-widget");
|
|
1039
1039
|
console.log(`[AriaFlow] Initializing ${t.length} widget(s)`);
|
|
1040
1040
|
}
|
|
1041
1041
|
export {
|
|
1042
|
-
|
|
1043
|
-
|
|
1042
|
+
Wt as Widget,
|
|
1043
|
+
$t as WidgetClient
|
|
1044
1044
|
};
|
package/dist/widget.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(H,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(H=typeof globalThis<"u"?globalThis:H||self,E(H.AriaFlowWidget={}))})(this,function(H){"use strict";var E,m,pe,I,me,ye,we,ve,ie,se,re,q={},be=[],tt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,V=Array.isArray;function M(t,e){for(var n in e)t[n]=e[n];return t}function ae(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function L(t,e,n){var o,s,i,a={};for(i in e)i=="key"?o=e[i]:i=="ref"?s=e[i]:a[i]=e[i];if(arguments.length>2&&(a.children=arguments.length>3?E.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)a[i]===void 0&&(a[i]=t.defaultProps[i]);return j(t,a,o,s,null)}function j(t,e,n,o,s){var i={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++pe,__i:-1,__u:0};return s==null&&m.vnode!=null&&m.vnode(i),i}function U(t){return t.children}function J(t,e){this.props=t,this.context=e}function Q(t,e){if(e==null)return t.__?Q(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Q(t):null}function Ce(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Ce(t)}}function ke(t){(!t.__d&&(t.__d=!0)&&I.push(t)&&!K.__r++||me!=m.debounceRendering)&&((me=m.debounceRendering)||ye)(K)}function K(){for(var t,e,n,o,s,i,a,_=1;I.length;)I.length>_&&I.sort(we),t=I.shift(),_=I.length,t.__d&&(n=void 0,o=void 0,s=(o=(e=t).__v).__e,i=[],a=[],e.__P&&((n=M({},o)).__v=o.__v+1,m.vnode&&m.vnode(n),le(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[s]:null,i,s??Q(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__k[n.__i]=n,Ne(i,n,a),o.__e=o.__=null,n.__e!=s&&Ce(n)));K.__r=0}function Ae(t,e,n,o,s,i,a,_,c,l,u){var r,h,g,C,$,w,p,f=o&&o.__k||be,P=e.length;for(c=nt(n,e,f,c,P),r=0;r<P;r++)(g=n.__k[r])!=null&&(h=g.__i==-1?q:f[g.__i]||q,g.__i=r,w=le(t,g,h,s,i,a,_,c,l,u),C=g.__e,g.ref&&h.ref!=g.ref&&(h.ref&&ce(h.ref,null,g),u.push(g.ref,g.__c||C,g)),$==null&&C!=null&&($=C),(p=!!(4&g.__u))||h.__k===g.__k?c=Se(g,c,t,p):typeof g.type=="function"&&w!==void 0?c=w:C&&(c=C.nextSibling),g.__u&=-7);return n.__e=$,c}function nt(t,e,n,o,s){var i,a,_,c,l,u=n.length,r=u,h=0;for(t.__k=new Array(s),i=0;i<s;i++)(a=e[i])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=t.__k[i]=j(null,a,null,null,null):V(a)?a=t.__k[i]=j(U,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[i]=j(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[i]=a,c=i+h,a.__=t,a.__b=t.__b+1,_=null,(l=a.__i=ot(a,n,c,r))!=-1&&(r--,(_=n[l])&&(_.__u|=2)),_==null||_.__v==null?(l==-1&&(s>u?h--:s<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[i]=null;if(r)for(i=0;i<u;i++)(_=n[i])!=null&&!(2&_.__u)&&(_.__e==o&&(o=Q(_)),Fe(_,_));return o}function Se(t,e,n,o){var s,i;if(typeof t.type=="function"){for(s=t.__k,i=0;s&&i<s.length;i++)s[i]&&(s[i].__=t,e=Se(s[i],e,n,o));return e}t.__e!=e&&(o&&(e&&t.type&&!e.parentNode&&(e=Q(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ot(t,e,n,o){var s,i,a,_=t.key,c=t.type,l=e[n],u=l!=null&&(2&l.__u)==0;if(l===null&&_==null||u&&_==l.key&&c==l.type)return n;if(o>(u?1:0)){for(s=n-1,i=n+1;s>=0||i<e.length;)if((l=e[a=s>=0?s--:i++])!=null&&!(2&l.__u)&&_==l.key&&c==l.type)return a}return-1}function $e(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||tt.test(e)?n:n+"px"}function G(t,e,n,o,s){var i,a;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||$e(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||$e(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(ve,"$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+i]=n,n?o?n.u=o.u:(n.u=ie,t.addEventListener(e,i?re:se,i)):t.removeEventListener(e,i?re:se,i);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");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{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function We(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ie++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function le(t,e,n,o,s,i,a,_,c,l){var u,r,h,g,C,$,w,p,f,P,N,D,W,ne,S,R,O,x=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),i=[_=e.__e=n.__e]),(u=m.__b)&&u(e);e:if(typeof x=="function")try{if(p=e.props,f="prototype"in x&&x.prototype.render,P=(u=x.contextType)&&o[u.__c],N=u?P?P.props.value:u.__:o,n.__c?w=(r=e.__c=n.__c).__=r.__E:(f?e.__c=r=new x(p,N):(e.__c=r=new J(p,N),r.constructor=x,r.render=st),P&&P.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=M({},r.__s)),M(r.__s,x.getDerivedStateFromProps(p,r.__s))),g=r.props,C=r.state,r.__v=e,h)f&&x.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),f&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{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){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){F&&(F.__=e)}),D=0;D<r._sb.length;D++)r.__h.push(r._sb[D]);r._sb=[],r.__h.length&&a.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(p,r.__s,N),f&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(g,C,$)})}if(r.context=N,r.props=p,r.__P=t,r.__e=!1,W=m.__r,ne=0,f){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]);r._sb=[]}else do r.__d=!1,W&&W(e),u=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++ne<25);r.state=r.__s,r.getChildContext!=null&&(o=M(M({},o),r.getChildContext())),f&&!h&&r.getSnapshotBeforeUpdate!=null&&($=r.getSnapshotBeforeUpdate(g,C)),R=u,u!=null&&u.type===U&&u.key==null&&(R=xe(u.props.children)),_=Ae(t,V(R)?R:[R],e,n,o,s,i,a,_,c,l),r.base=e.__e,e.__u&=-161,r.__h.length&&a.push(r),w&&(r.__E=r.__=null)}catch(F){if(e.__v=null,c||i!=null)if(F.then){for(e.__u|=c?160:128;_&&_.nodeType==8&&_.nextSibling;)_=_.nextSibling;i[i.indexOf(_)]=null,e.__e=_}else{for(O=i.length;O--;)ae(i[O]);_e(e)}else e.__e=n.__e,e.__k=n.__k,F.then||_e(e);m.__e(F,e,n)}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):_=e.__e=it(n.__e,e,n,o,s,i,a,c,l);return(u=m.diffed)&&u(e),128&e.__u?void 0:_}function _e(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(_e)}function Ne(t,e,n){for(var o=0;o<n.length;o++)ce(n[o],n[++o],n[++o]);m.__c&&m.__c(e,t),t.some(function(s){try{t=s.__h,s.__h=[],t.some(function(i){i.call(s)})}catch(i){m.__e(i,s.__v)}})}function xe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:V(t)?t.map(xe):M({},t)}function it(t,e,n,o,s,i,a,_,c){var l,u,r,h,g,C,$,w=n.props||q,p=e.props,f=e.type;if(f=="svg"?s="http://www.w3.org/2000/svg":f=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),i!=null){for(l=0;l<i.length;l++)if((g=i[l])&&"setAttribute"in g==!!f&&(f?g.localName==f:g.nodeType==3)){t=g,i[l]=null;break}}if(t==null){if(f==null)return document.createTextNode(p);t=document.createElementNS(s,f,p.is&&p),_&&(m.__m&&m.__m(e,i),_=!1),i=null}if(f==null)w===p||_&&t.data==p||(t.data=p);else{if(i=i&&E.call(t.childNodes),!_&&i!=null)for(w={},l=0;l<t.attributes.length;l++)w[(g=t.attributes[l]).name]=g.value;for(l in w)if(g=w[l],l!="children"){if(l=="dangerouslySetInnerHTML")r=g;else if(!(l in p)){if(l=="value"&&"defaultValue"in p||l=="checked"&&"defaultChecked"in p)continue;G(t,l,null,g,s)}}for(l in p)g=p[l],l=="children"?h=g:l=="dangerouslySetInnerHTML"?u=g:l=="value"?C=g:l=="checked"?$=g:_&&typeof g!="function"||w[l]===g||G(t,l,g,w[l],s);if(u)_||r&&(u.__html==r.__html||u.__html==t.innerHTML)||(t.innerHTML=u.__html),e.__k=[];else if(r&&(t.innerHTML=""),Ae(e.type=="template"?t.content:t,V(h)?h:[h],e,n,o,f=="foreignObject"?"http://www.w3.org/1999/xhtml":s,i,a,i?i[0]:n.__k&&Q(n,0),_,c),i!=null)for(l=i.length;l--;)ae(i[l]);_||(l="value",f=="progress"&&C==null?t.removeAttribute("value"):C!=null&&(C!==t[l]||f=="progress"&&!C||f=="option"&&C!=w[l])&&G(t,l,C,w[l],s),l="checked",$!=null&&$!=t[l]&&G(t,l,$,w[l],s))}return t}function ce(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(s){m.__e(s,n)}}function Fe(t,e,n){var o,s;if(m.unmount&&m.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||ce(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(i){m.__e(i,e)}o.base=o.__P=null}if(o=t.__k)for(s=0;s<o.length;s++)o[s]&&Fe(o[s],e,n||typeof t.type!="function");n||ae(t.__e),t.__c=t.__=t.__e=void 0}function st(t,e,n){return this.constructor(t,n)}function X(t,e,n){var o,s,i,a;e==document&&(e=document.documentElement),m.__&&m.__(t,e),s=(o=typeof n=="function")?null:n&&n.__k||e.__k,i=[],a=[],le(e,t=(!o&&n||e).__k=L(U,null,[t]),s||q,q,e.namespaceURI,!o&&n?[n]:s?null:e.firstChild?E.call(e.childNodes):null,i,!o&&n?n:s?s.__e:e.firstChild,o,a),Ne(i,t,a)}function Me(t,e){X(t,e,Me)}function Pe(t,e,n){var o,s,i,a,_=M({},t.props);for(i in t.type&&t.type.defaultProps&&(a=t.type.defaultProps),e)i=="key"?o=e[i]:i=="ref"?s=e[i]:_[i]=e[i]===void 0&&a!=null?a[i]:e[i];return arguments.length>2&&(_.children=arguments.length>3?E.call(arguments,2):n),j(t.type,_,o||t.key,s||t.ref,null)}E=be.slice,m={__e:function(t,e,n,o){for(var s,i,a;e=e.__;)if((s=e.__c)&&!s.__)try{if((i=s.constructor)&&i.getDerivedStateFromError!=null&&(s.setState(i.getDerivedStateFromError(t)),a=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(t,o||{}),a=s.__d),a)return s.__E=s}catch(_){t=_}throw t}},pe=0,J.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=M({},this.state),typeof t=="function"&&(t=t(M({},n),this.props)),t&&M(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ke(this))},J.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ke(this))},J.prototype.render=U,I=[],ye=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,we=function(t,e){return t.__v.__b-e.__v.__b},K.__r=0,ve=/(PointerCapture)$|Capture$/i,ie=0,se=We(!1),re=We(!0);function Y(){return Y=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Y.apply(this,arguments)}function Ee(t,e){if(t==null)return{};var n,o,s={},i=Object.keys(t);for(o=0;o<i.length;o++)e.indexOf(n=i[o])>=0||(s[n]=t[n]);return s}var rt=["context","children"],at=["useFragment"];function lt(t,e,n,o){function s(){var i=Reflect.construct(HTMLElement,[],s);return i._vdomComponent=t,i._root=i,i}return(s.prototype=Object.create(HTMLElement.prototype)).constructor=s,s.prototype.connectedCallback=function(){ct.call(this,o)},s.prototype.attributeChangedCallback=ut,s.prototype.disconnectedCallback=gt,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),s.observedAttributes=n,t.formAssociated&&(s.formAssociated=!0),n.forEach(function(i){Object.defineProperty(s.prototype,i,{get:function(){return this._vdom?this._vdom.props[i]:this._props[i]},set:function(a){this._vdom?this.attributeChangedCallback(i,null,a):(this._props||(this._props={}),this._props[i]=a);var _=typeof a;a!=null&&_!=="string"&&_!=="boolean"&&_!=="number"||this.setAttribute(i,a)}})}),customElements.define(e,s),s}function _t(t){this.getChildContext=function(){return t.context};var e=t.children,n=Ee(t,rt);return Pe(e,n)}function ct(t){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=L(_t,Y({},this._props,{context:e.detail.context}),Ie(this,this._vdomComponent,t)),(this.hasAttribute("hydrate")?Me:X)(this._vdom,this._root)}function Te(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function ut(t,e,n){if(this._vdom){var o={};o[t]=n=n??void 0,o[Te(t)]=n,this._vdom=Pe(this._vdom,o),X(this._vdom,this._root)}}function gt(){X(this._vdom=null,this._root)}function He(t,e){var n=this,o=t.useFragment,s=Ee(t,at);return L(o?U:"slot",Y({},s,{ref:function(i){i?(n.ref=i,n._listener||(n._listener=function(a){a.stopPropagation(),a.detail.context=e},i.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function Ie(t,e,n){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var o=[],s={},i=0,a=t.attributes,_=t.childNodes;for(i=a.length;i--;)a[i].name!=="slot"&&(s[a[i].name]=a[i].value,s[Te(a[i].name)]=a[i].value);for(i=_.length;i--;){var c=Ie(_[i],null,n),l=_[i].slot;l?s[l]=L(He,{name:l},c):o[i]=c}var u=!(!n||!n.shadow),r=e?L(He,{useFragment:!u},o):o;return!u&&e&&(t.innerHTML=""),L(e||t.nodeName.toLowerCase(),s,r)}var dt=0;function d(t,e,n,o,s,i){e||(e={});var a,_,c=e;if("ref"in c)for(_ in c={},e)_=="ref"?a=e[_]:c[_]=e[_];var l={type:t,props:c,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--dt,__i:-1,__u:0,__source:s,__self:i};if(typeof t=="function"&&(a=t.defaultProps))for(_ in a)c[_]===void 0&&(c[_]=a[_]);return m.vnode&&m.vnode(l),l}var B,y,ue,Ue,Z=0,De=[],b=m,Re=b.__b,Oe=b.__r,Le=b.diffed,Qe=b.__c,qe=b.unmount,je=b.__;function ge(t,e){b.__h&&b.__h(y,t,Z||e),Z=0;var n=y.__H||(y.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function T(t){return Z=1,ht(Ke,t)}function ht(t,e,n){var o=ge(B++,2);if(o.t=t,!o.__c&&(o.__=[Ke(void 0,e),function(_){var c=o.__N?o.__N[0]:o.__[0],l=o.t(c,_);c!==l&&(o.__N=[l,o.__[1]],o.__c.setState({}))}],o.__c=y,!y.__f)){var s=function(_,c,l){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(h){return!!h.__c});if(u.every(function(h){return!h.__N}))return!i||i.call(this,_,c,l);var r=o.__c.props!==_;return u.forEach(function(h){if(h.__N){var g=h.__[0];h.__=h.__N,h.__N=void 0,g!==h.__[0]&&(r=!0)}}),i&&i.call(this,_,c,l)||r};y.__f=!0;var i=y.shouldComponentUpdate,a=y.componentWillUpdate;y.componentWillUpdate=function(_,c,l){if(this.__e){var u=i;i=void 0,s(_,c,l),i=u}a&&a.call(this,_,c,l)},y.shouldComponentUpdate=s}return o.__N||o.__}function Be(t,e){var n=ge(B++,3);!b.__s&&Je(n.__H,e)&&(n.__=t,n.u=e,y.__H.__h.push(n))}function ze(t){return Z=5,ft(function(){return{current:t}},[])}function ft(t,e){var n=ge(B++,7);return Je(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function pt(){for(var t;t=De.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ee),t.__H.__h.forEach(de),t.__H.__h=[]}catch(e){t.__H.__h=[],b.__e(e,t.__v)}}b.__b=function(t){y=null,Re&&Re(t)},b.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),je&&je(t,e)},b.__r=function(t){Oe&&Oe(t),B=0;var e=(y=t.__c).__H;e&&(ue===y?(e.__h=[],y.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ee),e.__h.forEach(de),e.__h=[],B=0)),ue=y},b.diffed=function(t){Le&&Le(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(De.push(e)!==1&&Ue===b.requestAnimationFrame||((Ue=b.requestAnimationFrame)||mt)(pt)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ue=y=null},b.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ee),n.__h=n.__h.filter(function(o){return!o.__||de(o)})}catch(o){e.some(function(s){s.__h&&(s.__h=[])}),e=[],b.__e(o,n.__v)}}),Qe&&Qe(t,e)},b.unmount=function(t){qe&&qe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{ee(o)}catch(s){e=s}}),n.__H=void 0,e&&b.__e(e,n.__v))};var Ve=typeof requestAnimationFrame=="function";function mt(t){var e,n=function(){clearTimeout(o),Ve&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,35);Ve&&(e=requestAnimationFrame(n))}function ee(t){var e=y,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),y=e}function de(t){var e=y;t.__c=t.__(),y=e}function Je(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function Ke(t,e){return typeof e=="function"?e(t):e}const yt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let te=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=yt[n[t]&63];return e};class Ge{constructor(e,n){this.agentUrl=e,this.agentId=n,this.agentConfig=null,this.ws=null,this.messageCallbacks=new Set,this.connectionCallbacks=new Set,this.streamingCallbacks=new Set,this.processingCallbacks=new Set,this.queueCallbacks=new Set,this.messages=[],this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3,this.isAgentStreaming=!1,this.isAgentProcessing=!1,this.messageQueue=[]}async initWidget(){try{console.log("[AriaFlow Widget] Fetching agent config...",{agentUrl:this.agentUrl,agentId:this.agentId});try{const n=await fetch(`${this.agentUrl}/api/agent/${this.agentId}`);if(n.ok){const o=await n.json();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)}}catch{console.warn("[AriaFlow Widget] Agent config endpoint not available, trying fallback")}console.log("[AriaFlow Widget] Using fallback config for Railway deployment");const e={id:this.agentId,name:this.agentId==="hospital"?"Hospital Support":"Support Agent",wsUrl:`${this.agentUrl.replace(/^https/,"wss")}/ws`,status:"active",capabilities:["chat","streaming"],config:{primaryColor:"#14B8A6",position:"bottom-right",theme:"light",title:this.agentId==="hospital"?"Hospital Support":"Chat Support",subtitle:"We're here to help!",maxRetries:3,reconnectDelay:1e3}};return this.agentConfig=e,await this.connectToAgent(),e}catch(e){return console.error("Failed to initialize widget:",e),null}}async connectToAgent(){if(!this.agentConfig?.wsUrl)throw new Error("No agent WebSocket URL configured");const e=this.getSessionId(),n=`${this.agentConfig.wsUrl}/${e}`;return console.log("[AriaFlow Widget] Connecting to WebSocket:",n),new Promise((o,s)=>{try{this.ws=new WebSocket(n),this.ws.onopen=()=>{console.log("[Widget] Connected to agent"),this.reconnectAttempts=0,this.notifyConnectionChange(!0),o()},this.ws.onmessage=i=>{this.handleMessage(i)},this.ws.onclose=()=>{if(console.log("[Widget] Disconnected from agent"),this.notifyConnectionChange(!1),this.reconnectAttempts<this.maxReconnectAttempts){this.reconnectAttempts++;const i=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.log(`[Widget] Reconnecting in ${i}ms... (attempt ${this.reconnectAttempts})`),setTimeout(()=>this.connectToAgent(),i)}},this.ws.onerror=i=>{console.error("[Widget] WebSocket error:",i),s(i)}}catch(i){s(i)}})}onProcessingChange(e){return this.processingCallbacks.add(e),()=>{this.processingCallbacks.delete(e)}}notifyProcessingChange(e){this.isAgentProcessing=e,this.processingCallbacks.forEach(n=>n(e))}handleMessage(e){try{const n=JSON.parse(e.data);if(n.type==="text-delta")this.isAgentProcessing&&this.notifyProcessingChange(!1),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,content:s.content+n.text}]:[...o,{id:te(),role:"assistant",content:n.text,timestamp:Date.now(),isStreaming:!0}]});else if(n.type==="done")console.log("[Widget] Response complete"),this.notifyProcessingChange(!1),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,isStreaming:!1}]:o}),this.isAgentStreaming=!1,this.notifyStreamingChange(!1),this.processMessageQueue();else if(n.type==="step-start"||n.type==="agent-start")console.log(`[Widget] ${n.type} received:`,n.agentId||""),this.isAgentStreaming=!0,this.notifyStreamingChange(!0),this.notifyProcessingChange(!0);else if(n.type==="step-end"||n.type==="agent-end")console.log(`[Widget] ${n.type} received`),n.type==="agent-end"&&this.notifyProcessingChange(!1);else if(n.type==="tool-call"){console.log("[Widget] Tool call:",n.tool),this.notifyProcessingChange(!0);const o={id:te(),role:"tool",content:`Calling tool: ${n.tool.name}`,timestamp:Date.now(),toolCall:{name:n.tool.name,arguments:n.tool.arguments}};this.setMessages(s=>[...s,o]),n.tool.name==="suggest_options"&&n.tool.arguments?.options&&this.setMessages(s=>{const i=[...s].reverse().find(a=>a.role==="assistant");return i?s.map(a=>a.id===i.id?{...a,suggestions:n.tool.arguments.options}:a):s})}else n.type==="tool-result"?(console.log("[Widget] Tool result:",n.result),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="tool"&&!s.toolResult?[...o.slice(0,-1),{...s,content:s.content+`
|
|
2
|
-
Result: ${JSON.stringify(n.result)}`,toolResult:n.result}]:o})):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=>{const
|
|
1
|
+
(function(I,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(I=typeof globalThis<"u"?globalThis:I||self,T(I.AriaFlowWidget={}))})(this,function(I){"use strict";var T,m,me,U,ye,we,ve,be,ie,re,ae,B={},Ce=[],nt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,J=Array.isArray;function F(t,e){for(var n in e)t[n]=e[n];return t}function le(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Q(t,e,n){var o,i,s,a={};for(s in e)s=="key"?o=e[s]:s=="ref"?i=e[s]:a[s]=e[s];if(arguments.length>2&&(a.children=arguments.length>3?T.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)a[s]===void 0&&(a[s]=t.defaultProps[s]);return z(t,a,o,i,null)}function z(t,e,n,o,i){var s={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++me,__i:-1,__u:0};return i==null&&m.vnode!=null&&m.vnode(s),s}function D(t){return t.children}function K(t,e){this.props=t,this.context=e}function q(t,e){if(e==null)return t.__?q(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?q(t):null}function ke(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return ke(t)}}function Ae(t){(!t.__d&&(t.__d=!0)&&U.push(t)&&!G.__r++||ye!=m.debounceRendering)&&((ye=m.debounceRendering)||we)(G)}function G(){for(var t,e,n,o,i,s,a,_=1;U.length;)U.length>_&&U.sort(ve),t=U.shift(),_=U.length,t.__d&&(n=void 0,o=void 0,i=(o=(e=t).__v).__e,s=[],a=[],e.__P&&((n=F({},o)).__v=o.__v+1,m.vnode&&m.vnode(n),_e(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[i]:null,s,i??q(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__k[n.__i]=n,Ne(s,n,a),o.__e=o.__=null,n.__e!=i&&ke(n)));G.__r=0}function Se(t,e,n,o,i,s,a,_,c,l,u){var r,h,g,b,W,w,p,f=o&&o.__k||Ce,P=e.length;for(c=ot(n,e,f,c,P),r=0;r<P;r++)(g=n.__k[r])!=null&&(h=g.__i==-1?B:f[g.__i]||B,g.__i=r,w=_e(t,g,h,i,s,a,_,c,l,u),b=g.__e,g.ref&&h.ref!=g.ref&&(h.ref&&ue(h.ref,null,g),u.push(g.ref,g.__c||b,g)),W==null&&b!=null&&(W=b),(p=!!(4&g.__u))||h.__k===g.__k?c=We(g,c,t,p):typeof g.type=="function"&&w!==void 0?c=w:b&&(c=b.nextSibling),g.__u&=-7);return n.__e=W,c}function ot(t,e,n,o,i){var s,a,_,c,l,u=n.length,r=u,h=0;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]=z(null,a,null,null,null):J(a)?a=t.__k[s]=z(D,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[s]=z(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=st(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;if(r)for(s=0;s<u;s++)(_=n[s])!=null&&!(2&_.__u)&&(_.__e==o&&(o=q(_)),Fe(_,_));return o}function We(t,e,n,o){var i,s;if(typeof t.type=="function"){for(i=t.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=t,e=We(i[s],e,n,o));return e}t.__e!=e&&(o&&(e&&t.type&&!e.parentNode&&(e=q(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function st(t,e,n,o){var i,s,a,_=t.key,c=t.type,l=e[n],u=l!=null&&(2&l.__u)==0;if(l===null&&_==null||u&&_==l.key&&c==l.type)return n;if(o>(u?1:0)){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}return-1}function $e(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||nt.test(e)?n:n+"px"}function X(t,e,n,o,i){var s,a;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||$e(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||$e(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(be,"$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=ie,t.addEventListener(e,s?ae:re,s)):t.removeEventListener(e,s?ae:re,s);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");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{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function xe(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ie++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function _e(t,e,n,o,i,s,a,_,c,l){var u,r,h,g,b,W,w,p,f,P,x,R,$,oe,A,O,L,N=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),s=[_=e.__e=n.__e]),(u=m.__b)&&u(e);e:if(typeof N=="function")try{if(p=e.props,f="prototype"in N&&N.prototype.render,P=(u=N.contextType)&&o[u.__c],x=u?P?P.props.value:u.__:o,n.__c?w=(r=e.__c=n.__c).__=r.__E:(f?e.__c=r=new N(p,x):(e.__c=r=new K(p,x),r.constructor=N,r.render=rt),P&&P.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&&N.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=F({},r.__s)),F(r.__s,N.getDerivedStateFromProps(p,r.__s))),g=r.props,b=r.state,r.__v=e,h)f&&N.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),f&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(f&&N.getDerivedStateFromProps==null&&p!==g&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(p,x),e.__v==n.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(p,r.__s,x)===!1){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(M){M&&(M.__=e)}),R=0;R<r._sb.length;R++)r.__h.push(r._sb[R]);r._sb=[],r.__h.length&&a.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(p,r.__s,x),f&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(g,b,W)})}if(r.context=x,r.props=p,r.__P=t,r.__e=!1,$=m.__r,oe=0,f){for(r.state=r.__s,r.__d=!1,$&&$(e),u=r.render(r.props,r.state,r.context),A=0;A<r._sb.length;A++)r.__h.push(r._sb[A]);r._sb=[]}else do r.__d=!1,$&&$(e),u=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++oe<25);r.state=r.__s,r.getChildContext!=null&&(o=F(F({},o),r.getChildContext())),f&&!h&&r.getSnapshotBeforeUpdate!=null&&(W=r.getSnapshotBeforeUpdate(g,b)),O=u,u!=null&&u.type===D&&u.key==null&&(O=Me(u.props.children)),_=Se(t,J(O)?O:[O],e,n,o,i,s,a,_,c,l),r.base=e.__e,e.__u&=-161,r.__h.length&&a.push(r),w&&(r.__E=r.__=null)}catch(M){if(e.__v=null,c||s!=null)if(M.then){for(e.__u|=c?160:128;_&&_.nodeType==8&&_.nextSibling;)_=_.nextSibling;s[s.indexOf(_)]=null,e.__e=_}else{for(L=s.length;L--;)le(s[L]);ce(e)}else e.__e=n.__e,e.__k=n.__k,M.then||ce(e);m.__e(M,e,n)}else s==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):_=e.__e=it(n.__e,e,n,o,i,s,a,c,l);return(u=m.diffed)&&u(e),128&e.__u?void 0:_}function ce(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(ce)}function Ne(t,e,n){for(var o=0;o<n.length;o++)ue(n[o],n[++o],n[++o]);m.__c&&m.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){m.__e(s,i.__v)}})}function Me(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:J(t)?t.map(Me):F({},t)}function it(t,e,n,o,i,s,a,_,c){var l,u,r,h,g,b,W,w=n.props||B,p=e.props,f=e.type;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){for(l=0;l<s.length;l++)if((g=s[l])&&"setAttribute"in g==!!f&&(f?g.localName==f:g.nodeType==3)){t=g,s[l]=null;break}}if(t==null){if(f==null)return document.createTextNode(p);t=document.createElementNS(i,f,p.is&&p),_&&(m.__m&&m.__m(e,s),_=!1),s=null}if(f==null)w===p||_&&t.data==p||(t.data=p);else{if(s=s&&T.call(t.childNodes),!_&&s!=null)for(w={},l=0;l<t.attributes.length;l++)w[(g=t.attributes[l]).name]=g.value;for(l in w)if(g=w[l],l!="children"){if(l=="dangerouslySetInnerHTML")r=g;else if(!(l in p)){if(l=="value"&&"defaultValue"in p||l=="checked"&&"defaultChecked"in p)continue;X(t,l,null,g,i)}}for(l in p)g=p[l],l=="children"?h=g:l=="dangerouslySetInnerHTML"?u=g:l=="value"?b=g:l=="checked"?W=g:_&&typeof g!="function"||w[l]===g||X(t,l,g,w[l],i);if(u)_||r&&(u.__html==r.__html||u.__html==t.innerHTML)||(t.innerHTML=u.__html),e.__k=[];else if(r&&(t.innerHTML=""),Se(e.type=="template"?t.content:t,J(h)?h:[h],e,n,o,f=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,a,s?s[0]:n.__k&&q(n,0),_,c),s!=null)for(l=s.length;l--;)le(s[l]);_||(l="value",f=="progress"&&b==null?t.removeAttribute("value"):b!=null&&(b!==t[l]||f=="progress"&&!b||f=="option"&&b!=w[l])&&X(t,l,b,w[l],i),l="checked",W!=null&&W!=t[l]&&X(t,l,W,w[l],i))}return t}function ue(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(i){m.__e(i,n)}}function Fe(t,e,n){var o,i;if(m.unmount&&m.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||ue(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){m.__e(s,e)}o.base=o.__P=null}if(o=t.__k)for(i=0;i<o.length;i++)o[i]&&Fe(o[i],e,n||typeof t.type!="function");n||le(t.__e),t.__c=t.__=t.__e=void 0}function rt(t,e,n){return this.constructor(t,n)}function Y(t,e,n){var o,i,s,a;e==document&&(e=document.documentElement),m.__&&m.__(t,e),i=(o=typeof n=="function")?null:n&&n.__k||e.__k,s=[],a=[],_e(e,t=(!o&&n||e).__k=Q(D,null,[t]),i||B,B,e.namespaceURI,!o&&n?[n]:i?null:e.firstChild?T.call(e.childNodes):null,s,!o&&n?n:i?i.__e:e.firstChild,o,a),Ne(s,t,a)}function Pe(t,e){Y(t,e,Pe)}function Te(t,e,n){var o,i,s,a,_=F({},t.props);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];return arguments.length>2&&(_.children=arguments.length>3?T.call(arguments,2):n),z(t.type,_,o||t.key,i||t.ref,null)}T=Ce.slice,m={__e:function(t,e,n,o){for(var i,s,a;e=e.__;)if((i=e.__c)&&!i.__)try{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}catch(_){t=_}throw t}},me=0,K.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=F({},this.state),typeof t=="function"&&(t=t(F({},n),this.props)),t&&F(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),Ae(this))},K.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Ae(this))},K.prototype.render=D,U=[],we=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ve=function(t,e){return t.__v.__b-e.__v.__b},G.__r=0,be=/(PointerCapture)$|Capture$/i,ie=0,re=xe(!1),ae=xe(!0);function Z(){return Z=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Z.apply(this,arguments)}function Ee(t,e){if(t==null)return{};var n,o,i={},s=Object.keys(t);for(o=0;o<s.length;o++)e.indexOf(n=s[o])>=0||(i[n]=t[n]);return i}var at=["context","children"],lt=["useFragment"];function _t(t,e,n,o){function i(){var s=Reflect.construct(HTMLElement,[],i);return s._vdomComponent=t,s._root=s,s}return(i.prototype=Object.create(HTMLElement.prototype)).constructor=i,i.prototype.connectedCallback=function(){ut.call(this,o)},i.prototype.attributeChangedCallback=gt,i.prototype.disconnectedCallback=dt,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),i.observedAttributes=n,t.formAssociated&&(i.formAssociated=!0),n.forEach(function(s){Object.defineProperty(i.prototype,s,{get:function(){return this._vdom?this._vdom.props[s]:this._props[s]},set:function(a){this._vdom?this.attributeChangedCallback(s,null,a):(this._props||(this._props={}),this._props[s]=a);var _=typeof a;a!=null&&_!=="string"&&_!=="boolean"&&_!=="number"||this.setAttribute(s,a)}})}),customElements.define(e,i),i}function ct(t){this.getChildContext=function(){return t.context};var e=t.children,n=Ee(t,at);return Te(e,n)}function ut(t){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=Q(ct,Z({},this._props,{context:e.detail.context}),Ue(this,this._vdomComponent,t)),(this.hasAttribute("hydrate")?Pe:Y)(this._vdom,this._root)}function He(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function gt(t,e,n){if(this._vdom){var o={};o[t]=n=n??void 0,o[He(t)]=n,this._vdom=Te(this._vdom,o),Y(this._vdom,this._root)}}function dt(){Y(this._vdom=null,this._root)}function Ie(t,e){var n=this,o=t.useFragment,i=Ee(t,lt);return Q(o?D:"slot",Z({},i,{ref:function(s){s?(n.ref=s,n._listener||(n._listener=function(a){a.stopPropagation(),a.detail.context=e},s.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function Ue(t,e,n){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var o=[],i={},s=0,a=t.attributes,_=t.childNodes;for(s=a.length;s--;)a[s].name!=="slot"&&(i[a[s].name]=a[s].value,i[He(a[s].name)]=a[s].value);for(s=_.length;s--;){var c=Ue(_[s],null,n),l=_[s].slot;l?i[l]=Q(Ie,{name:l},c):o[s]=c}var u=!(!n||!n.shadow),r=e?Q(Ie,{useFragment:!u},o):o;return!u&&e&&(t.innerHTML=""),Q(e||t.nodeName.toLowerCase(),i,r)}var ht=0;function d(t,e,n,o,i,s){e||(e={});var a,_,c=e;if("ref"in c)for(_ in c={},e)_=="ref"?a=e[_]:c[_]=e[_];var l={type:t,props:c,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ht,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(a=t.defaultProps))for(_ in a)c[_]===void 0&&(c[_]=a[_]);return m.vnode&&m.vnode(l),l}var V,y,ge,De,ee=0,Re=[],v=m,Oe=v.__b,Le=v.__r,Qe=v.diffed,qe=v.__c,je=v.unmount,Be=v.__;function de(t,e){v.__h&&v.__h(y,t,ee||e),ee=0;var n=y.__H||(y.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function E(t){return ee=1,ft(Ge,t)}function ft(t,e,n){var o=de(V++,2);if(o.t=t,!o.__c&&(o.__=[Ge(void 0,e),function(_){var c=o.__N?o.__N[0]:o.__[0],l=o.t(c,_);c!==l&&(o.__N=[l,o.__[1]],o.__c.setState({}))}],o.__c=y,!y.__f)){var i=function(_,c,l){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(h){return!!h.__c});if(u.every(function(h){return!h.__N}))return!s||s.call(this,_,c,l);var r=o.__c.props!==_;return u.forEach(function(h){if(h.__N){var g=h.__[0];h.__=h.__N,h.__N=void 0,g!==h.__[0]&&(r=!0)}}),s&&s.call(this,_,c,l)||r};y.__f=!0;var s=y.shouldComponentUpdate,a=y.componentWillUpdate;y.componentWillUpdate=function(_,c,l){if(this.__e){var u=s;s=void 0,i(_,c,l),s=u}a&&a.call(this,_,c,l)},y.shouldComponentUpdate=i}return o.__N||o.__}function ze(t,e){var n=de(V++,3);!v.__s&&Ke(n.__H,e)&&(n.__=t,n.u=e,y.__H.__h.push(n))}function Ve(t){return ee=5,pt(function(){return{current:t}},[])}function pt(t,e){var n=de(V++,7);return Ke(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function mt(){for(var t;t=Re.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(te),t.__H.__h.forEach(he),t.__H.__h=[]}catch(e){t.__H.__h=[],v.__e(e,t.__v)}}v.__b=function(t){y=null,Oe&&Oe(t)},v.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Be&&Be(t,e)},v.__r=function(t){Le&&Le(t),V=0;var e=(y=t.__c).__H;e&&(ge===y?(e.__h=[],y.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(te),e.__h.forEach(he),e.__h=[],V=0)),ge=y},v.diffed=function(t){Qe&&Qe(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Re.push(e)!==1&&De===v.requestAnimationFrame||((De=v.requestAnimationFrame)||yt)(mt)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ge=y=null},v.__c=function(t,e){e.some(function(n){try{n.__h.forEach(te),n.__h=n.__h.filter(function(o){return!o.__||he(o)})}catch(o){e.some(function(i){i.__h&&(i.__h=[])}),e=[],v.__e(o,n.__v)}}),qe&&qe(t,e)},v.unmount=function(t){je&&je(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{te(o)}catch(i){e=i}}),n.__H=void 0,e&&v.__e(e,n.__v))};var Je=typeof requestAnimationFrame=="function";function yt(t){var e,n=function(){clearTimeout(o),Je&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,35);Je&&(e=requestAnimationFrame(n))}function te(t){var e=y,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),y=e}function he(t){var e=y;t.__c=t.__(),y=e}function Ke(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function Ge(t,e){return typeof e=="function"?e(t):e}const wt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ne=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=wt[n[t]&63];return e};class Xe{constructor(e,n){this.agentUrl=e,this.agentId=n,this.agentConfig=null,this.ws=null,this.messageCallbacks=new Set,this.connectionCallbacks=new Set,this.streamingCallbacks=new Set,this.processingCallbacks=new Set,this.queueCallbacks=new Set,this.messages=[],this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3,this.isAgentStreaming=!1,this.isAgentProcessing=!1,this.messageQueue=[]}async initWidget(){try{console.log("[AriaFlow Widget] Fetching agent config...",{agentUrl:this.agentUrl,agentId:this.agentId});try{const n=await fetch(`${this.agentUrl}/api/agent/${this.agentId}`);if(n.ok){const o=await n.json();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)}}catch{console.warn("[AriaFlow Widget] Agent config endpoint not available, trying fallback")}console.log("[AriaFlow Widget] Using fallback config for Railway deployment");const e={id:this.agentId,name:this.agentId==="hospital"?"Hospital Support":"Support Agent",wsUrl:`${this.agentUrl.replace(/^https/,"wss")}/ws`,status:"active",capabilities:["chat","streaming"],config:{primaryColor:"#14B8A6",position:"bottom-right",theme:"light",title:this.agentId==="hospital"?"Hospital Support":"Chat Support",subtitle:"We're here to help!",maxRetries:3,reconnectDelay:1e3}};return this.agentConfig=e,await this.connectToAgent(),e}catch(e){return console.error("Failed to initialize widget:",e),null}}async connectToAgent(){if(!this.agentConfig?.wsUrl)throw new Error("No agent WebSocket URL configured");const e=this.getSessionId(),n=`${this.agentConfig.wsUrl}/${e}`;return console.log("[AriaFlow Widget] Connecting to WebSocket:",n),new Promise((o,i)=>{try{this.ws=new WebSocket(n),this.ws.onopen=()=>{console.log("[Widget] Connected to agent"),this.reconnectAttempts=0,this.notifyConnectionChange(!0),o()},this.ws.onmessage=s=>{this.handleMessage(s)},this.ws.onclose=()=>{if(console.log("[Widget] Disconnected from agent"),this.notifyConnectionChange(!1),this.reconnectAttempts<this.maxReconnectAttempts){this.reconnectAttempts++;const s=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.log(`[Widget] Reconnecting in ${s}ms... (attempt ${this.reconnectAttempts})`),setTimeout(()=>this.connectToAgent(),s)}},this.ws.onerror=s=>{console.error("[Widget] WebSocket error:",s),i(s)}}catch(s){i(s)}})}onProcessingChange(e){return this.processingCallbacks.add(e),()=>{this.processingCallbacks.delete(e)}}notifyProcessingChange(e){this.isAgentProcessing=e,this.processingCallbacks.forEach(n=>n(e))}handleMessage(e){try{const n=JSON.parse(e.data);if(n.type==="text-delta")this.isAgentProcessing&&this.notifyProcessingChange(!1),this.setMessages(o=>{const i=o[o.length-1];return i&&i.role==="assistant"&&i.isStreaming?[...o.slice(0,-1),{...i,content:i.content+n.text}]:[...o,{id:ne(),role:"assistant",content:n.text,timestamp:Date.now(),isStreaming:!0}]});else if(n.type==="done")console.log("[Widget] Response complete"),this.notifyProcessingChange(!1),this.setMessages(o=>{const i=o[o.length-1];return i&&i.role==="assistant"&&i.isStreaming?[...o.slice(0,-1),{...i,isStreaming:!1}]:o}),this.isAgentStreaming=!1,this.notifyStreamingChange(!1),this.processMessageQueue();else if(n.type==="step-start"||n.type==="agent-start")console.log(`[Widget] ${n.type} received:`,n.agentId||""),this.isAgentStreaming=!0,this.notifyStreamingChange(!0),this.notifyProcessingChange(!0);else if(n.type==="step-end"||n.type==="agent-end")console.log(`[Widget] ${n.type} received`),n.type==="agent-end"&&this.notifyProcessingChange(!1);else if(n.type==="tool-call"){console.log("[Widget] Tool call:",n.tool),this.notifyProcessingChange(!0);const o={id:ne(),role:"tool",content:`Calling tool: ${n.tool.name}`,timestamp:Date.now(),toolCall:{name:n.tool.name,arguments:n.tool.arguments}};this.setMessages(i=>[...i,o]),n.tool.name==="suggest_options"&&n.tool.arguments?.options&&this.setMessages(i=>{const s=[...i].reverse().find(a=>a.role==="assistant");return s?i.map(a=>a.id===s.id?{...a,suggestions:n.tool.arguments.options}:a):i})}else n.type==="tool-result"?(console.log("[Widget] Tool result:",n.result),this.setMessages(o=>{const i=o[o.length-1];return i&&i.role==="tool"&&!i.toolResult?[...o.slice(0,-1),{...i,content:i.content+`
|
|
2
|
+
Result: ${JSON.stringify(n.result)}`,toolResult:n.result}]:o})):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=>{const i=[...o].reverse().find(s=>s.role==="assistant");return i?o.map(s=>s.id===i.id?{...s,suggestions:n.suggestions}:s):o})):console.log("[Widget] Unknown message type:",n.type)}catch(n){console.error("[Widget] Error parsing message:",e.data,n)}}async sendMessage(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("Not connected to agent");const n={id:ne(),role:"user",content:e,timestamp:Date.now()};if(this.setMessages(o=>[...o,n]),this.isAgentStreaming){console.log("[Widget] Agent is streaming, queuing message"),this.messageQueue.push(e),this.notifyQueueChange(this.messageQueue.length);return}this.sendToAgent(e)}async sendToAgent(e){const n=this.getSessionId();this.ws.send(JSON.stringify({message:e,sessionId:n}))}async processMessageQueue(){if(this.messageQueue.length!==0){if(this.messageQueue.length===1){const e=this.messageQueue.shift();console.log("[Widget] Sending queued message:",e),this.sendToAgent(e)}else{const e=this.messageQueue.join(`
|
|
3
3
|
|
|
4
|
-
`);this.messageQueue.length=0,console.log("[Widget] Sending combined queued messages:",e),this.sendToAgent(e)}this.notifyQueueChange(this.messageQueue.length)}}getSessionId(){let e=sessionStorage.getItem("ariaflow_session_id");return e||(e=
|
|
4
|
+
`);this.messageQueue.length=0,console.log("[Widget] Sending combined queued messages:",e),this.sendToAgent(e)}this.notifyQueueChange(this.messageQueue.length)}}getSessionId(){let e=sessionStorage.getItem("ariaflow_session_id");return e||(e=ne(),sessionStorage.setItem("ariaflow_session_id",e)),e}setMessages(e){this.messages=e(this.messages),this.messageCallbacks.forEach(n=>n(this.messages))}onMessages(e){return this.messageCallbacks.add(e),e(this.messages),()=>{this.messageCallbacks.delete(e)}}onConnectionChange(e){return this.connectionCallbacks.add(e),()=>{this.connectionCallbacks.delete(e)}}onStreamingChange(e){return this.streamingCallbacks.add(e),()=>{this.streamingCallbacks.delete(e)}}onQueueChange(e){return this.queueCallbacks.add(e),()=>{this.queueCallbacks.delete(e)}}notifyConnectionChange(e){this.connectionCallbacks.forEach(n=>n(e))}notifyStreamingChange(e){this.streamingCallbacks.forEach(n=>n(e))}notifyQueueChange(e){this.queueCallbacks.forEach(n=>n(e))}getMessages(){return this.messages}getConfig(){return this.agentConfig}isConnected(){return this.ws?.readyState===WebSocket.OPEN}dispose(){this.ws&&(this.ws.close(),this.ws=null),this.messageCallbacks.clear(),this.connectionCallbacks.clear()}}const fe={none:"0",small:"0.375rem",medium:"0.75rem",large:"1rem"};function Ye({agentUrl:t,agentId:e,widgetId:n,apiUrl:o,mode:i="chat",theme:s="light",position:a="bottom-right",size:_="full",radius:c="medium",baseColor:l,accentColor:u="#14B8A6",buttonBaseColor:r="#000000",buttonAccentColor:h="#FFFFFF",title:g,subtitle:b,emptyChatMessage:W}){const[w,p]=E(!1),[f,P]=E([]),[x,R]=E(""),[$,oe]=E(!1),[A,O]=E(!1),[L,N]=E(null),[M,vt]=E(!1),[bt,Ct]=E(!1),[pe,kt]=E(0),se=Ve(null),et=Ve(null);ze(()=>((async()=>{if(t&&e){console.log("[AriaFlow Widget] Using new agent resolution:",{agentUrl:t,agentId:e});const S=new Xe(t,e);se.current=S;try{S.onMessages(k=>{console.log("[AriaFlow Widget] Messages updated:",k.length),P(k)}),S.onConnectionChange(k=>{console.log("[AriaFlow Widget] Connection state:",k),oe(k),k&&O(!0)}),S.onStreamingChange(k=>{console.log("[AriaFlow Widget] Streaming state:",k),vt(k)}),S.onQueueChange(k=>{console.log("[AriaFlow Widget] Queue count:",k),kt(k)}),S.onProcessingChange(k=>{console.log("[AriaFlow Widget] Processing state:",k),Ct(k)});const j=await S.initWidget();console.log("[AriaFlow Widget] Agent config received:",j),j?(N(j),console.log("[AriaFlow Widget] Widget initialized successfully (v0.6.11)")):console.error("[AriaFlow Widget] Agent config fetch failed")}catch(j){console.error("[AriaFlow Widget] Initialization error:",j)}}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.")})(),()=>{se.current?.dispose()}),[t,e,n,o]),ze(()=>{et.current?.scrollIntoView({behavior:"smooth"})},[f]);const tt=async()=>{if(!x.trim()||!$)return;const C=x.trim();R("");try{await se.current?.sendMessage(C)}catch(S){console.error("Failed to send message:",S)}},At=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),tt())},St=C=>{!$||M||se.current?.sendMessage(C)},Wt=g||L?.config.title||"Ninewells Hospital",$t=b||L?.config.subtitle||"How can we help you today?",xt=W||L?.config.emptyChatMessage||"Start a conversation with Ninewells...";return console.log("[AriaFlow Widget] Rendering widget component",{isInitialized:A,isOpen:w,position:a}),d("div",{className:`ariaflow-widget-container ariaflow-widget-${a} ariaflow-widget-${_} ariaflow-widget-radius-${c}`,"data-theme":s,style:{"--ariaflow-accent-color":u,"--ariaflow-base-color":l},children:[!w&&d("button",{className:"ariaflow-widget-launcher",onClick:()=>p(!0),style:{backgroundColor:r,color:h,opacity:A?1:.8,cursor:A?"pointer":"wait",position:"relative"},"aria-label":A?"Open chat":"Connecting to agent...",disabled:!A,title:A?"Click to start chat":"Connecting to agent...",children:[!A&&d("div",{className:"ariaflow-widget-launcher-loading",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"20px",height:"20px",border:`2px solid ${h}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),A&&d("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children: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"})})]}),w&&A&&d("div",{className:"ariaflow-widget-window",style:{backgroundColor:s==="dark"&&l?l:void 0,borderRadius:fe[c]},children:[d("div",{className:"ariaflow-widget-header",style:{backgroundColor:u,borderRadius:c==="none"?"0":`${fe[c]} ${fe[c]} 0 0`},children:[d("div",{className:"ariaflow-widget-header-content",children:d("div",{className:"ariaflow-widget-title-group",children:[d("h3",{className:"ariaflow-widget-title",children:Wt}),d("p",{className:"ariaflow-widget-subtitle",children:$t})]})}),d("button",{className:"ariaflow-widget-close",onClick:()=>p(!1),"aria-label":"Close chat",children:d("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),!$&&d("div",{className:"ariaflow-widget-status",children:[d("span",{className:"ariaflow-widget-status-dot"}),"Connecting..."]}),d("div",{className:"ariaflow-widget-messages",children:f.length===0?d("div",{className:"ariaflow-widget-empty",children:d("p",{children:$?xt:"Connecting to agent..."})}):d(D,{children:[f.map((C,S)=>(f.length-1,C.role==="tool"?null:d("div",{className:`ariaflow-widget-message ariaflow-widget-message-${C.role}`,children:d("div",{className:"ariaflow-widget-message-bubble",children:d(D,{children:[C.content,C.isStreaming&&d("span",{className:"ariaflow-widget-typing-indicator",children:[d("span",{children:"•"}),d("span",{children:"•"}),d("span",{children:"•"})]})]})})},C.id))),d("div",{ref:et}),bt&&!M&&d("div",{className:"ariaflow-widget-message ariaflow-widget-message-assistant",children:d("div",{className:"ariaflow-widget-message-bubble",children:d("span",{className:"ariaflow-widget-typing-indicator",children:[d("span",{children:"•"}),d("span",{children:"•"}),d("span",{children:"•"})]})})})]})}),!M&&(()=>{const C=[...f].reverse(),S=C.findIndex(H=>H.role==="user"),k=(S===-1?C:C.slice(0,S)).find(H=>H.suggestions&&H.suggestions.length>0);return k&&k.suggestions?d("div",{className:"ariaflow-widget-suggestions",children:k.suggestions.map(H=>d("button",{className:"ariaflow-widget-chip",onClick:()=>St(H),style:{borderColor:u,color:u,backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(4px)"},children:H},H))}):null})(),d("div",{className:"ariaflow-widget-input",children:[d("textarea",{value:x,onInput:C=>R(C.target.value),onKeyDown:At,placeholder:$?M?pe>0?`Agent is responding... (${pe} message${pe>1?"s":""} queued)`:"Agent is responding...":"Type your message...":"Connecting...",rows:1,disabled:!$}),d("button",{className:"ariaflow-widget-send",onClick:tt,disabled:!x.trim()||!$,style:{backgroundColor:u},"aria-label":"Send message",children:d("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),d("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})]})}_t(Ye,"ariaflow-widget",["agent-url","agent-id","widget-id","api-url","mode","theme","position","size","radius","base-color","accent-color","button-base-color","button-accent-color","title","subtitle","empty-chat-message"],!1),typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ze):Ze());function Ze(){const t=document.querySelectorAll("ariaflow-widget");console.log(`[AriaFlow] Initializing ${t.length} widget(s)`)}I.Widget=Ye,I.WidgetClient=Xe,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
|