@ariaflowagents/widget 0.5.7 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.js CHANGED
@@ -1,58 +1,58 @@
1
- var q, m, Ee, H, he, Me, Fe, Te, le, ie, re, B = {}, He = [], Ze = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, Z = Array.isArray;
2
- function W(t, e) {
1
+ var V, m, Ee, T, ge, Me, He, Te, le, ie, re, B = {}, Pe = [], et = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, Z = Array.isArray;
2
+ function F(t, e) {
3
3
  for (var n in e) t[n] = e[n];
4
4
  return t;
5
5
  }
6
6
  function ae(t) {
7
7
  t && t.parentNode && t.parentNode.removeChild(t);
8
8
  }
9
- function D(t, e, n) {
9
+ function I(t, e, n) {
10
10
  var i, r, o, _ = {};
11
11
  for (o in e) o == "key" ? i = e[o] : o == "ref" ? r = e[o] : _[o] = e[o];
12
- if (arguments.length > 2 && (_.children = arguments.length > 3 ? q.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (o in t.defaultProps) _[o] === void 0 && (_[o] = t.defaultProps[o]);
13
- return z(t, _, i, r, null);
12
+ if (arguments.length > 2 && (_.children = arguments.length > 3 ? V.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (o in t.defaultProps) _[o] === void 0 && (_[o] = t.defaultProps[o]);
13
+ return j(t, _, i, r, null);
14
14
  }
15
- function z(t, e, n, i, r) {
15
+ function j(t, e, n, i, r) {
16
16
  var o = { type: t, props: e, key: n, ref: i, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: r ?? ++Ee, __i: -1, __u: 0 };
17
17
  return r == null && m.vnode != null && m.vnode(o), o;
18
18
  }
19
- function O(t) {
19
+ function R(t) {
20
20
  return t.children;
21
21
  }
22
22
  function J(t, e) {
23
23
  this.props = t, this.context = e;
24
24
  }
25
- function I(t, e) {
26
- if (e == null) return t.__ ? I(t.__, t.__i + 1) : null;
25
+ function D(t, e) {
26
+ if (e == null) return t.__ ? D(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" ? I(t) : null;
28
+ return typeof t.type == "function" ? D(t) : null;
29
29
  }
30
- function Pe(t) {
30
+ function Ue(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 Pe(t);
37
+ return Ue(t);
38
38
  }
39
39
  }
40
40
  function pe(t) {
41
- (!t.__d && (t.__d = !0) && H.push(t) && !Q.__r++ || he != m.debounceRendering) && ((he = m.debounceRendering) || Me)(Q);
41
+ (!t.__d && (t.__d = !0) && T.push(t) && !Q.__r++ || ge != m.debounceRendering) && ((ge = m.debounceRendering) || Me)(Q);
42
42
  }
43
43
  function Q() {
44
- for (var t, e, n, i, r, o, _, l = 1; H.length; ) H.length > l && H.sort(Fe), t = H.shift(), l = H.length, t.__d && (n = void 0, i = void 0, r = (i = (e = t).__v).__e, o = [], _ = [], e.__P && ((n = W({}, i)).__v = i.__v + 1, m.vnode && m.vnode(n), ce(e.__P, n, i, e.__n, e.__P.namespaceURI, 32 & i.__u ? [r] : null, o, r ?? I(i), !!(32 & i.__u), _), n.__v = i.__v, n.__.__k[n.__i] = n, Ie(o, n, _), i.__e = i.__ = null, n.__e != r && Pe(n)));
44
+ for (var t, e, n, i, r, o, _, a = 1; T.length; ) T.length > a && T.sort(He), t = T.shift(), a = T.length, t.__d && (n = void 0, i = void 0, r = (i = (e = t).__v).__e, o = [], _ = [], e.__P && ((n = F({}, i)).__v = i.__v + 1, m.vnode && m.vnode(n), ce(e.__P, n, i, e.__n, e.__P.namespaceURI, 32 & i.__u ? [r] : null, o, r ?? D(i), !!(32 & i.__u), _), n.__v = i.__v, n.__.__k[n.__i] = n, Re(o, n, _), i.__e = i.__ = null, n.__e != r && Ue(n)));
45
45
  Q.__r = 0;
46
46
  }
47
- function Ue(t, e, n, i, r, o, _, l, c, a, d) {
48
- var s, f, u, y, k, w, p, g = i && i.__k || He, $ = e.length;
49
- for (c = et(n, e, g, c, $), s = 0; s < $; s++) (u = n.__k[s]) != null && (f = u.__i == -1 ? B : g[u.__i] || B, u.__i = s, w = ce(t, u, f, r, o, _, l, c, a, d), y = u.__e, u.ref && f.ref != u.ref && (f.ref && ue(f.ref, null, u), d.push(u.ref, u.__c || y, u)), k == null && y != null && (k = y), (p = !!(4 & u.__u)) || f.__k === u.__k ? c = De(u, c, t, p) : typeof u.type == "function" && w !== void 0 ? c = w : y && (c = y.nextSibling), u.__u &= -7);
50
- return n.__e = k, c;
47
+ function Ie(t, e, n, i, r, o, _, a, c, l, d) {
48
+ var s, f, u, w, C, v, p, h = i && i.__k || Pe, S = e.length;
49
+ for (c = tt(n, e, h, c, S), s = 0; s < S; s++) (u = n.__k[s]) != null && (f = u.__i == -1 ? B : h[u.__i] || B, u.__i = s, v = ce(t, u, f, r, o, _, a, c, l, d), w = u.__e, u.ref && f.ref != u.ref && (f.ref && ue(f.ref, null, u), d.push(u.ref, u.__c || w, u)), C == null && w != null && (C = w), (p = !!(4 & u.__u)) || f.__k === u.__k ? c = De(u, c, t, p) : typeof u.type == "function" && v !== void 0 ? c = v : w && (c = w.nextSibling), u.__u &= -7);
50
+ return n.__e = C, c;
51
51
  }
52
- function et(t, e, n, i, r) {
53
- var o, _, l, c, a, d = n.length, s = d, f = 0;
54
- for (t.__k = new Array(r), o = 0; o < r; o++) (_ = e[o]) != null && typeof _ != "boolean" && typeof _ != "function" ? (typeof _ == "string" || typeof _ == "number" || typeof _ == "bigint" || _.constructor == String ? _ = t.__k[o] = z(null, _, null, null, null) : Z(_) ? _ = t.__k[o] = z(O, { children: _ }, null, null, null) : _.constructor === void 0 && _.__b > 0 ? _ = t.__k[o] = z(_.type, _.props, _.key, _.ref ? _.ref : null, _.__v) : t.__k[o] = _, c = o + f, _.__ = t, _.__b = t.__b + 1, l = null, (a = _.__i = tt(_, n, c, s)) != -1 && (s--, (l = n[a]) && (l.__u |= 2)), l == null || l.__v == null ? (a == -1 && (r > d ? f-- : r < d && f++), typeof _.type != "function" && (_.__u |= 4)) : a != c && (a == c - 1 ? f-- : a == c + 1 ? f++ : (a > c ? f-- : f++, _.__u |= 4))) : t.__k[o] = null;
55
- if (s) for (o = 0; o < d; o++) (l = n[o]) != null && !(2 & l.__u) && (l.__e == i && (i = I(l)), Le(l, l));
52
+ function tt(t, e, n, i, r) {
53
+ var o, _, a, c, l, d = n.length, s = d, f = 0;
54
+ for (t.__k = new Array(r), o = 0; o < r; o++) (_ = e[o]) != null && typeof _ != "boolean" && typeof _ != "function" ? (typeof _ == "string" || typeof _ == "number" || typeof _ == "bigint" || _.constructor == String ? _ = t.__k[o] = j(null, _, null, null, null) : Z(_) ? _ = t.__k[o] = j(R, { children: _ }, null, null, null) : _.constructor === void 0 && _.__b > 0 ? _ = t.__k[o] = j(_.type, _.props, _.key, _.ref ? _.ref : null, _.__v) : t.__k[o] = _, c = o + f, _.__ = t, _.__b = t.__b + 1, a = null, (l = _.__i = nt(_, n, c, s)) != -1 && (s--, (a = n[l]) && (a.__u |= 2)), a == null || a.__v == null ? (l == -1 && (r > d ? f-- : r < d && f++), typeof _.type != "function" && (_.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, _.__u |= 4))) : t.__k[o] = null;
55
+ if (s) for (o = 0; o < d; o++) (a = n[o]) != null && !(2 & a.__u) && (a.__e == i && (i = D(a)), Oe(a, a));
56
56
  return i;
57
57
  }
58
58
  function De(t, e, n, i) {
@@ -61,29 +61,29 @@ function De(t, e, n, i) {
61
61
  for (r = t.__k, o = 0; r && o < r.length; o++) r[o] && (r[o].__ = t, e = De(r[o], e, n, i));
62
62
  return e;
63
63
  }
64
- t.__e != e && (i && (e && t.type && !e.parentNode && (e = I(t)), n.insertBefore(t.__e, e || null)), e = t.__e);
64
+ t.__e != e && (i && (e && t.type && !e.parentNode && (e = D(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 tt(t, e, n, i) {
71
- var r, o, _, l = t.key, c = t.type, a = e[n], d = a != null && (2 & a.__u) == 0;
72
- if (a === null && l == null || d && l == a.key && c == a.type) return n;
70
+ function nt(t, e, n, i) {
71
+ var r, o, _, a = t.key, c = t.type, l = e[n], d = l != null && (2 & l.__u) == 0;
72
+ if (l === null && a == null || d && a == l.key && c == l.type) return n;
73
73
  if (i > (d ? 1 : 0)) {
74
- for (r = n - 1, o = n + 1; r >= 0 || o < e.length; ) if ((a = e[_ = r >= 0 ? r-- : o++]) != null && !(2 & a.__u) && l == a.key && c == a.type) return _;
74
+ for (r = n - 1, o = n + 1; r >= 0 || o < e.length; ) if ((l = e[_ = r >= 0 ? r-- : o++]) != null && !(2 & l.__u) && a == l.key && c == l.type) return _;
75
75
  }
76
76
  return -1;
77
77
  }
78
- function ge(t, e, n) {
79
- e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || Ze.test(e) ? n : n + "px";
78
+ function me(t, e, n) {
79
+ e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || et.test(e) ? n : n + "px";
80
80
  }
81
81
  function K(t, e, n, i, r) {
82
82
  var o, _;
83
83
  e: if (e == "style") if (typeof n == "string") t.style.cssText = n;
84
84
  else {
85
- if (typeof i == "string" && (t.style.cssText = i = ""), i) for (e in i) n && e in n || ge(t.style, e, "");
86
- if (n) for (e in n) i && n[e] == i[e] || ge(t.style, e, n[e]);
85
+ if (typeof i == "string" && (t.style.cssText = i = ""), i) for (e in i) n && e in n || me(t.style, e, "");
86
+ if (n) for (e in n) i && n[e] == i[e] || me(t.style, e, n[e]);
87
87
  }
88
88
  else if (e[0] == "o" && e[1] == "n") o = e != (e = e.replace(Te, "$1")), _ = e.toLowerCase(), e = _ in t || e == "onFocusOut" || e == "onFocusIn" ? _.slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + o] = n, n ? i ? n.u = i.u : (n.u = le, t.addEventListener(e, o ? re : ie, o)) : t.removeEventListener(e, o ? re : ie, o);
89
89
  else {
@@ -96,7 +96,7 @@ function K(t, e, n, i, r) {
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 me(t) {
99
+ function ve(t) {
100
100
  return function(e) {
101
101
  if (this.l) {
102
102
  var n = this.l[e.type + t];
@@ -106,49 +106,49 @@ function me(t) {
106
106
  }
107
107
  };
108
108
  }
109
- function ce(t, e, n, i, r, o, _, l, c, a) {
110
- var d, s, f, u, y, k, w, p, g, $, S, N, F, x, P, E, L, C = e.type;
109
+ function ce(t, e, n, i, r, o, _, a, c, l) {
110
+ var d, s, f, u, w, C, v, p, h, S, A, E, $, q, k, M, H, W = e.type;
111
111
  if (e.constructor !== void 0) return null;
112
- 128 & n.__u && (c = !!(32 & n.__u), o = [l = e.__e = n.__e]), (d = m.__b) && d(e);
113
- e: if (typeof C == "function") try {
114
- if (p = e.props, g = "prototype" in C && C.prototype.render, $ = (d = C.contextType) && i[d.__c], S = d ? $ ? $.props.value : d.__ : i, n.__c ? w = (s = e.__c = n.__c).__ = s.__E : (g ? e.__c = s = new C(p, S) : (e.__c = s = new J(p, S), s.constructor = C, s.render = ot), $ && $.sub(s), s.state || (s.state = {}), s.__n = i, f = s.__d = !0, s.__h = [], s._sb = []), g && s.__s == null && (s.__s = s.state), g && C.getDerivedStateFromProps != null && (s.__s == s.state && (s.__s = W({}, s.__s)), W(s.__s, C.getDerivedStateFromProps(p, s.__s))), u = s.props, y = s.state, s.__v = e, f) g && C.getDerivedStateFromProps == null && s.componentWillMount != null && s.componentWillMount(), g && s.componentDidMount != null && s.__h.push(s.componentDidMount);
112
+ 128 & n.__u && (c = !!(32 & n.__u), o = [a = e.__e = n.__e]), (d = m.__b) && d(e);
113
+ e: if (typeof W == "function") try {
114
+ if (p = e.props, h = "prototype" in W && W.prototype.render, S = (d = W.contextType) && i[d.__c], A = d ? S ? S.props.value : d.__ : i, n.__c ? v = (s = e.__c = n.__c).__ = s.__E : (h ? e.__c = s = new W(p, A) : (e.__c = s = new J(p, A), s.constructor = W, s.render = it), S && S.sub(s), s.state || (s.state = {}), s.__n = i, f = s.__d = !0, s.__h = [], s._sb = []), h && s.__s == null && (s.__s = s.state), h && W.getDerivedStateFromProps != null && (s.__s == s.state && (s.__s = F({}, s.__s)), F(s.__s, W.getDerivedStateFromProps(p, s.__s))), u = s.props, w = s.state, s.__v = e, f) h && W.getDerivedStateFromProps == null && s.componentWillMount != null && s.componentWillMount(), h && s.componentDidMount != null && s.__h.push(s.componentDidMount);
115
115
  else {
116
- if (g && C.getDerivedStateFromProps == null && p !== u && s.componentWillReceiveProps != null && s.componentWillReceiveProps(p, S), e.__v == n.__v || !s.__e && s.shouldComponentUpdate != null && s.shouldComponentUpdate(p, s.__s, S) === !1) {
117
- for (e.__v != n.__v && (s.props = p, s.state = s.__s, s.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(M) {
118
- M && (M.__ = e);
119
- }), N = 0; N < s._sb.length; N++) s.__h.push(s._sb[N]);
116
+ if (h && W.getDerivedStateFromProps == null && p !== u && s.componentWillReceiveProps != null && s.componentWillReceiveProps(p, A), e.__v == n.__v || !s.__e && s.shouldComponentUpdate != null && s.shouldComponentUpdate(p, s.__s, A) === !1) {
117
+ for (e.__v != n.__v && (s.props = p, s.state = s.__s, s.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(N) {
118
+ N && (N.__ = e);
119
+ }), E = 0; E < s._sb.length; E++) s.__h.push(s._sb[E]);
120
120
  s._sb = [], s.__h.length && _.push(s);
121
121
  break e;
122
122
  }
123
- s.componentWillUpdate != null && s.componentWillUpdate(p, s.__s, S), g && s.componentDidUpdate != null && s.__h.push(function() {
124
- s.componentDidUpdate(u, y, k);
123
+ s.componentWillUpdate != null && s.componentWillUpdate(p, s.__s, A), h && s.componentDidUpdate != null && s.__h.push(function() {
124
+ s.componentDidUpdate(u, w, C);
125
125
  });
126
126
  }
127
- if (s.context = S, s.props = p, s.__P = t, s.__e = !1, F = m.__r, x = 0, g) {
128
- for (s.state = s.__s, s.__d = !1, F && F(e), d = s.render(s.props, s.state, s.context), P = 0; P < s._sb.length; P++) s.__h.push(s._sb[P]);
127
+ if (s.context = A, s.props = p, s.__P = t, s.__e = !1, $ = m.__r, q = 0, h) {
128
+ for (s.state = s.__s, s.__d = !1, $ && $(e), d = s.render(s.props, s.state, s.context), k = 0; k < s._sb.length; k++) s.__h.push(s._sb[k]);
129
129
  s._sb = [];
130
130
  } else do
131
- s.__d = !1, F && F(e), d = s.render(s.props, s.state, s.context), s.state = s.__s;
132
- while (s.__d && ++x < 25);
133
- s.state = s.__s, s.getChildContext != null && (i = W(W({}, i), s.getChildContext())), g && !f && s.getSnapshotBeforeUpdate != null && (k = s.getSnapshotBeforeUpdate(u, y)), E = d, d != null && d.type === O && d.key == null && (E = Oe(d.props.children)), l = Ue(t, Z(E) ? E : [E], e, n, i, r, o, _, l, c, a), s.base = e.__e, e.__u &= -161, s.__h.length && _.push(s), w && (s.__E = s.__ = null);
134
- } catch (M) {
135
- if (e.__v = null, c || o != null) if (M.then) {
136
- for (e.__u |= c ? 160 : 128; l && l.nodeType == 8 && l.nextSibling; ) l = l.nextSibling;
137
- o[o.indexOf(l)] = null, e.__e = l;
131
+ s.__d = !1, $ && $(e), d = s.render(s.props, s.state, s.context), s.state = s.__s;
132
+ while (s.__d && ++q < 25);
133
+ s.state = s.__s, s.getChildContext != null && (i = F(F({}, i), s.getChildContext())), h && !f && s.getSnapshotBeforeUpdate != null && (C = s.getSnapshotBeforeUpdate(u, w)), M = d, d != null && d.type === R && d.key == null && (M = Le(d.props.children)), a = Ie(t, Z(M) ? M : [M], e, n, i, r, o, _, a, c, l), s.base = e.__e, e.__u &= -161, s.__h.length && _.push(s), v && (s.__E = s.__ = null);
134
+ } catch (N) {
135
+ if (e.__v = null, c || o != null) if (N.then) {
136
+ for (e.__u |= c ? 160 : 128; a && a.nodeType == 8 && a.nextSibling; ) a = a.nextSibling;
137
+ o[o.indexOf(a)] = null, e.__e = a;
138
138
  } else {
139
- for (L = o.length; L--; ) ae(o[L]);
139
+ for (H = o.length; H--; ) ae(o[H]);
140
140
  se(e);
141
141
  }
142
- else e.__e = n.__e, e.__k = n.__k, M.then || se(e);
143
- m.__e(M, e, n);
142
+ else e.__e = n.__e, e.__k = n.__k, N.then || se(e);
143
+ m.__e(N, e, n);
144
144
  }
145
- else o == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : l = e.__e = nt(n.__e, e, n, i, r, o, _, c, a);
146
- return (d = m.diffed) && d(e), 128 & e.__u ? void 0 : l;
145
+ else o == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : a = e.__e = ot(n.__e, e, n, i, r, o, _, c, l);
146
+ return (d = m.diffed) && d(e), 128 & e.__u ? void 0 : a;
147
147
  }
148
148
  function se(t) {
149
149
  t && t.__c && (t.__c.__e = !0), t && t.__k && t.__k.forEach(se);
150
150
  }
151
- function Ie(t, e, n) {
151
+ function Re(t, e, n) {
152
152
  for (var i = 0; i < n.length; i++) ue(n[i], n[++i], n[++i]);
153
153
  m.__c && m.__c(e, t), t.some(function(r) {
154
154
  try {
@@ -160,35 +160,35 @@ function Ie(t, e, n) {
160
160
  }
161
161
  });
162
162
  }
163
- function Oe(t) {
164
- return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : Z(t) ? t.map(Oe) : W({}, t);
163
+ function Le(t) {
164
+ return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : Z(t) ? t.map(Le) : F({}, t);
165
165
  }
166
- function nt(t, e, n, i, r, o, _, l, c) {
167
- var a, d, s, f, u, y, k, w = n.props || B, p = e.props, g = e.type;
168
- if (g == "svg" ? r = "http://www.w3.org/2000/svg" : g == "math" ? r = "http://www.w3.org/1998/Math/MathML" : r || (r = "http://www.w3.org/1999/xhtml"), o != null) {
169
- for (a = 0; a < o.length; a++) if ((u = o[a]) && "setAttribute" in u == !!g && (g ? u.localName == g : u.nodeType == 3)) {
170
- t = u, o[a] = null;
166
+ function ot(t, e, n, i, r, o, _, a, c) {
167
+ var l, d, s, f, u, w, C, v = n.props || B, p = e.props, h = e.type;
168
+ if (h == "svg" ? r = "http://www.w3.org/2000/svg" : h == "math" ? r = "http://www.w3.org/1998/Math/MathML" : r || (r = "http://www.w3.org/1999/xhtml"), o != null) {
169
+ for (l = 0; l < o.length; l++) if ((u = o[l]) && "setAttribute" in u == !!h && (h ? u.localName == h : u.nodeType == 3)) {
170
+ t = u, o[l] = null;
171
171
  break;
172
172
  }
173
173
  }
174
174
  if (t == null) {
175
- if (g == null) return document.createTextNode(p);
176
- t = document.createElementNS(r, g, p.is && p), l && (m.__m && m.__m(e, o), l = !1), o = null;
175
+ if (h == null) return document.createTextNode(p);
176
+ t = document.createElementNS(r, h, p.is && p), a && (m.__m && m.__m(e, o), a = !1), o = null;
177
177
  }
178
- if (g == null) w === p || l && t.data == p || (t.data = p);
178
+ if (h == null) v === p || a && t.data == p || (t.data = p);
179
179
  else {
180
- if (o = o && q.call(t.childNodes), !l && o != null) for (w = {}, a = 0; a < t.attributes.length; a++) w[(u = t.attributes[a]).name] = u.value;
181
- for (a in w) if (u = w[a], a != "children") {
182
- if (a == "dangerouslySetInnerHTML") s = u;
183
- else if (!(a in p)) {
184
- if (a == "value" && "defaultValue" in p || a == "checked" && "defaultChecked" in p) continue;
185
- K(t, a, null, u, r);
180
+ if (o = o && V.call(t.childNodes), !a && o != null) for (v = {}, l = 0; l < t.attributes.length; l++) v[(u = t.attributes[l]).name] = u.value;
181
+ for (l in v) if (u = v[l], l != "children") {
182
+ if (l == "dangerouslySetInnerHTML") s = u;
183
+ else if (!(l in p)) {
184
+ if (l == "value" && "defaultValue" in p || l == "checked" && "defaultChecked" in p) continue;
185
+ K(t, l, null, u, r);
186
186
  }
187
187
  }
188
- for (a in p) u = p[a], a == "children" ? f = u : a == "dangerouslySetInnerHTML" ? d = u : a == "value" ? y = u : a == "checked" ? k = u : l && typeof u != "function" || w[a] === u || K(t, a, u, w[a], r);
189
- if (d) l || s && (d.__html == s.__html || d.__html == t.innerHTML) || (t.innerHTML = d.__html), e.__k = [];
190
- else if (s && (t.innerHTML = ""), Ue(e.type == "template" ? t.content : t, Z(f) ? f : [f], e, n, i, g == "foreignObject" ? "http://www.w3.org/1999/xhtml" : r, o, _, o ? o[0] : n.__k && I(n, 0), l, c), o != null) for (a = o.length; a--; ) ae(o[a]);
191
- l || (a = "value", g == "progress" && y == null ? t.removeAttribute("value") : y != null && (y !== t[a] || g == "progress" && !y || g == "option" && y != w[a]) && K(t, a, y, w[a], r), a = "checked", k != null && k != t[a] && K(t, a, k, w[a], r));
188
+ for (l in p) u = p[l], l == "children" ? f = u : l == "dangerouslySetInnerHTML" ? d = u : l == "value" ? w = u : l == "checked" ? C = u : a && typeof u != "function" || v[l] === u || K(t, l, u, v[l], r);
189
+ if (d) a || s && (d.__html == s.__html || d.__html == t.innerHTML) || (t.innerHTML = d.__html), e.__k = [];
190
+ else if (s && (t.innerHTML = ""), Ie(e.type == "template" ? t.content : t, Z(f) ? f : [f], e, n, i, h == "foreignObject" ? "http://www.w3.org/1999/xhtml" : r, o, _, o ? o[0] : n.__k && D(n, 0), a, c), o != null) for (l = o.length; l--; ) ae(o[l]);
191
+ a || (l = "value", h == "progress" && w == null ? t.removeAttribute("value") : w != null && (w !== t[l] || h == "progress" && !w || h == "option" && w != v[l]) && K(t, l, w, v[l], r), l = "checked", C != null && C != t[l] && K(t, l, C, v[l], r));
192
192
  }
193
193
  return t;
194
194
  }
@@ -202,7 +202,7 @@ function ue(t, e, n) {
202
202
  m.__e(r, n);
203
203
  }
204
204
  }
205
- function Le(t, e, n) {
205
+ function Oe(t, e, n) {
206
206
  var i, r;
207
207
  if (m.unmount && m.unmount(t), (i = t.ref) && (i.current && i.current != t.__e || ue(i, null, e)), (i = t.__c) != null) {
208
208
  if (i.componentWillUnmount) try {
@@ -212,39 +212,39 @@ function Le(t, e, n) {
212
212
  }
213
213
  i.base = i.__P = null;
214
214
  }
215
- if (i = t.__k) for (r = 0; r < i.length; r++) i[r] && Le(i[r], e, n || typeof t.type != "function");
215
+ if (i = t.__k) for (r = 0; r < i.length; r++) i[r] && Oe(i[r], e, n || typeof t.type != "function");
216
216
  n || ae(t.__e), t.__c = t.__ = t.__e = void 0;
217
217
  }
218
- function ot(t, e, n) {
218
+ function it(t, e, n) {
219
219
  return this.constructor(t, n);
220
220
  }
221
221
  function ee(t, e, n) {
222
222
  var i, r, o, _;
223
- e == document && (e = document.documentElement), m.__ && m.__(t, e), r = (i = typeof n == "function") ? null : n && n.__k || e.__k, o = [], _ = [], ce(e, t = (!i && n || e).__k = D(O, null, [t]), r || B, B, e.namespaceURI, !i && n ? [n] : r ? null : e.firstChild ? q.call(e.childNodes) : null, o, !i && n ? n : r ? r.__e : e.firstChild, i, _), Ie(o, t, _);
223
+ e == document && (e = document.documentElement), m.__ && m.__(t, e), r = (i = typeof n == "function") ? null : n && n.__k || e.__k, o = [], _ = [], ce(e, t = (!i && n || e).__k = I(R, null, [t]), r || B, B, e.namespaceURI, !i && n ? [n] : r ? null : e.firstChild ? V.call(e.childNodes) : null, o, !i && n ? n : r ? r.__e : e.firstChild, i, _), Re(o, t, _);
224
224
  }
225
- function Re(t, e) {
226
- ee(t, e, Re);
225
+ function je(t, e) {
226
+ ee(t, e, je);
227
227
  }
228
- function je(t, e, n) {
229
- var i, r, o, _, l = W({}, t.props);
230
- for (o in t.type && t.type.defaultProps && (_ = t.type.defaultProps), e) o == "key" ? i = e[o] : o == "ref" ? r = e[o] : l[o] = e[o] === void 0 && _ != null ? _[o] : e[o];
231
- return arguments.length > 2 && (l.children = arguments.length > 3 ? q.call(arguments, 2) : n), z(t.type, l, i || t.key, r || t.ref, null);
228
+ function Be(t, e, n) {
229
+ var i, r, o, _, a = F({}, t.props);
230
+ for (o in t.type && t.type.defaultProps && (_ = t.type.defaultProps), e) o == "key" ? i = e[o] : o == "ref" ? r = e[o] : a[o] = e[o] === void 0 && _ != null ? _[o] : e[o];
231
+ return arguments.length > 2 && (a.children = arguments.length > 3 ? V.call(arguments, 2) : n), j(t.type, a, i || t.key, r || t.ref, null);
232
232
  }
233
- q = He.slice, m = { __e: function(t, e, n, i) {
233
+ V = Pe.slice, m = { __e: function(t, e, n, i) {
234
234
  for (var r, o, _; e = e.__; ) if ((r = e.__c) && !r.__) try {
235
235
  if ((o = r.constructor) && o.getDerivedStateFromError != null && (r.setState(o.getDerivedStateFromError(t)), _ = r.__d), r.componentDidCatch != null && (r.componentDidCatch(t, i || {}), _ = r.__d), _) return r.__E = r;
236
- } catch (l) {
237
- t = l;
236
+ } catch (a) {
237
+ t = a;
238
238
  }
239
239
  throw t;
240
240
  } }, Ee = 0, J.prototype.setState = function(t, e) {
241
241
  var n;
242
- n = this.__s != null && this.__s != this.state ? this.__s : this.__s = W({}, this.state), typeof t == "function" && (t = t(W({}, n), this.props)), t && W(n, t), t != null && this.__v && (e && this._sb.push(e), pe(this));
242
+ 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), pe(this));
243
243
  }, J.prototype.forceUpdate = function(t) {
244
244
  this.__v && (this.__e = !0, t && this.__h.push(t), pe(this));
245
- }, J.prototype.render = O, H = [], Me = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, Fe = function(t, e) {
245
+ }, J.prototype.render = R, T = [], Me = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, He = function(t, e) {
246
246
  return t.__v.__b - e.__v.__b;
247
- }, Q.__r = 0, Te = /(PointerCapture)$|Capture$/i, le = 0, ie = me(!1), re = me(!0);
247
+ }, Q.__r = 0, Te = /(PointerCapture)$|Capture$/i, le = 0, ie = ve(!1), re = ve(!0);
248
248
  function X() {
249
249
  return X = Object.assign ? Object.assign.bind() : function(t) {
250
250
  for (var e = 1; e < arguments.length; e++) {
@@ -260,157 +260,157 @@ function ze(t, e) {
260
260
  for (i = 0; i < o.length; i++) e.indexOf(n = o[i]) >= 0 || (r[n] = t[n]);
261
261
  return r;
262
262
  }
263
- var it = ["context", "children"], rt = ["useFragment"];
264
- function st(t, e, n, i) {
263
+ var rt = ["context", "children"], st = ["useFragment"];
264
+ function _t(t, e, n, i) {
265
265
  function r() {
266
266
  var o = Reflect.construct(HTMLElement, [], r);
267
267
  return o._vdomComponent = t, o._root = o, o;
268
268
  }
269
269
  return (r.prototype = Object.create(HTMLElement.prototype)).constructor = r, r.prototype.connectedCallback = function() {
270
- lt.call(this, i);
271
- }, r.prototype.attributeChangedCallback = at, r.prototype.disconnectedCallback = ct, n = n || t.observedAttributes || Object.keys(t.propTypes || {}), r.observedAttributes = n, t.formAssociated && (r.formAssociated = !0), n.forEach(function(o) {
270
+ at.call(this, i);
271
+ }, r.prototype.attributeChangedCallback = ct, r.prototype.disconnectedCallback = ut, n = n || t.observedAttributes || Object.keys(t.propTypes || {}), r.observedAttributes = n, t.formAssociated && (r.formAssociated = !0), n.forEach(function(o) {
272
272
  Object.defineProperty(r.prototype, o, { get: function() {
273
273
  return this._vdom ? this._vdom.props[o] : this._props[o];
274
274
  }, set: function(_) {
275
275
  this._vdom ? this.attributeChangedCallback(o, null, _) : (this._props || (this._props = {}), this._props[o] = _);
276
- var l = typeof _;
277
- _ != null && l !== "string" && l !== "boolean" && l !== "number" || this.setAttribute(o, _);
276
+ var a = typeof _;
277
+ _ != null && a !== "string" && a !== "boolean" && a !== "number" || this.setAttribute(o, _);
278
278
  } });
279
279
  }), customElements.define(e, r), r;
280
280
  }
281
- function _t(t) {
281
+ function lt(t) {
282
282
  this.getChildContext = function() {
283
283
  return t.context;
284
284
  };
285
- var e = t.children, n = ze(t, it);
286
- return je(e, n);
285
+ var e = t.children, n = ze(t, rt);
286
+ return Be(e, n);
287
287
  }
288
- function lt(t) {
288
+ function at(t) {
289
289
  var e = new CustomEvent("_preact", { detail: {}, bubbles: !0, cancelable: !0 });
290
- this.dispatchEvent(e), this._vdom = D(_t, X({}, this._props, { context: e.detail.context }), Ve(this, this._vdomComponent, t)), (this.hasAttribute("hydrate") ? Re : ee)(this._vdom, this._root);
290
+ this.dispatchEvent(e), this._vdom = I(lt, X({}, this._props, { context: e.detail.context }), qe(this, this._vdomComponent, t)), (this.hasAttribute("hydrate") ? je : ee)(this._vdom, this._root);
291
291
  }
292
- function Be(t) {
292
+ function Ve(t) {
293
293
  return t.replace(/-(\w)/g, function(e, n) {
294
294
  return n ? n.toUpperCase() : "";
295
295
  });
296
296
  }
297
- function at(t, e, n) {
297
+ function ct(t, e, n) {
298
298
  if (this._vdom) {
299
299
  var i = {};
300
- i[t] = n = n ?? void 0, i[Be(t)] = n, this._vdom = je(this._vdom, i), ee(this._vdom, this._root);
300
+ i[t] = n = n ?? void 0, i[Ve(t)] = n, this._vdom = Be(this._vdom, i), ee(this._vdom, this._root);
301
301
  }
302
302
  }
303
- function ct() {
303
+ function ut() {
304
304
  ee(this._vdom = null, this._root);
305
305
  }
306
- function ve(t, e) {
307
- var n = this, i = t.useFragment, r = ze(t, rt);
308
- return D(i ? O : "slot", X({}, r, { ref: function(o) {
306
+ function ye(t, e) {
307
+ var n = this, i = t.useFragment, r = ze(t, st);
308
+ return I(i ? R : "slot", X({}, r, { ref: function(o) {
309
309
  o ? (n.ref = o, n._listener || (n._listener = function(_) {
310
310
  _.stopPropagation(), _.detail.context = e;
311
311
  }, o.addEventListener("_preact", n._listener))) : n.ref.removeEventListener("_preact", n._listener);
312
312
  } }));
313
313
  }
314
- function Ve(t, e, n) {
314
+ function qe(t, e, n) {
315
315
  if (t.nodeType === 3) return t.data;
316
316
  if (t.nodeType !== 1) return null;
317
- var i = [], r = {}, o = 0, _ = t.attributes, l = t.childNodes;
318
- for (o = _.length; o--; ) _[o].name !== "slot" && (r[_[o].name] = _[o].value, r[Be(_[o].name)] = _[o].value);
319
- for (o = l.length; o--; ) {
320
- var c = Ve(l[o], null, n), a = l[o].slot;
321
- a ? r[a] = D(ve, { name: a }, c) : i[o] = c;
317
+ var i = [], r = {}, o = 0, _ = t.attributes, a = t.childNodes;
318
+ for (o = _.length; o--; ) _[o].name !== "slot" && (r[_[o].name] = _[o].value, r[Ve(_[o].name)] = _[o].value);
319
+ for (o = a.length; o--; ) {
320
+ var c = qe(a[o], null, n), l = a[o].slot;
321
+ l ? r[l] = I(ye, { name: l }, c) : i[o] = c;
322
322
  }
323
- var d = !(!n || !n.shadow), s = e ? D(ve, { useFragment: !d }, i) : i;
324
- return !d && e && (t.innerHTML = ""), D(e || t.nodeName.toLowerCase(), r, s);
323
+ var d = !(!n || !n.shadow), s = e ? I(ye, { useFragment: !d }, i) : i;
324
+ return !d && e && (t.innerHTML = ""), I(e || t.nodeName.toLowerCase(), r, s);
325
325
  }
326
- var ut = 0;
327
- function h(t, e, n, i, r, o) {
326
+ var dt = 0;
327
+ function g(t, e, n, i, r, o) {
328
328
  e || (e = {});
329
- var _, l, c = e;
330
- if ("ref" in c) for (l in c = {}, e) l == "ref" ? _ = e[l] : c[l] = e[l];
331
- var a = { type: t, props: c, key: n, ref: _, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --ut, __i: -1, __u: 0, __source: r, __self: o };
332
- if (typeof t == "function" && (_ = t.defaultProps)) for (l in _) c[l] === void 0 && (c[l] = _[l]);
333
- return m.vnode && m.vnode(a), a;
329
+ var _, a, c = e;
330
+ if ("ref" in c) for (a in c = {}, e) a == "ref" ? _ = e[a] : c[a] = e[a];
331
+ var l = { type: t, props: c, key: n, ref: _, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --dt, __i: -1, __u: 0, __source: r, __self: o };
332
+ if (typeof t == "function" && (_ = t.defaultProps)) for (a in _) c[a] === void 0 && (c[a] = _[a]);
333
+ return m.vnode && m.vnode(l), l;
334
334
  }
335
- var V, v, te, ye, Y = 0, qe = [], b = m, we = b.__b, be = b.__r, ke = b.diffed, Ce = b.__c, $e = b.unmount, xe = b.__;
335
+ var z, y, te, we, Y = 0, Ke = [], b = m, be = b.__b, ke = b.__r, Ce = b.diffed, Ae = b.__c, $e = b.unmount, We = b.__;
336
336
  function de(t, e) {
337
- b.__h && b.__h(v, t, Y || e), Y = 0;
338
- var n = v.__H || (v.__H = { __: [], __h: [] });
337
+ b.__h && b.__h(y, t, Y || e), Y = 0;
338
+ var n = y.__H || (y.__H = { __: [], __h: [] });
339
339
  return t >= n.__.length && n.__.push({}), n.__[t];
340
340
  }
341
341
  function U(t) {
342
- return Y = 1, dt(Je, t);
343
- }
344
- function dt(t, e, n) {
345
- var i = de(V++, 2);
346
- if (i.t = t, !i.__c && (i.__ = [Je(void 0, e), function(l) {
347
- var c = i.__N ? i.__N[0] : i.__[0], a = i.t(c, l);
348
- c !== a && (i.__N = [a, i.__[1]], i.__c.setState({}));
349
- }], i.__c = v, !v.__f)) {
350
- var r = function(l, c, a) {
342
+ return Y = 1, ft(Ge, t);
343
+ }
344
+ function ft(t, e, n) {
345
+ var i = de(z++, 2);
346
+ if (i.t = t, !i.__c && (i.__ = [Ge(void 0, e), function(a) {
347
+ var c = i.__N ? i.__N[0] : i.__[0], l = i.t(c, a);
348
+ c !== l && (i.__N = [l, i.__[1]], i.__c.setState({}));
349
+ }], i.__c = y, !y.__f)) {
350
+ var r = function(a, c, l) {
351
351
  if (!i.__c.__H) return !0;
352
352
  var d = i.__c.__H.__.filter(function(f) {
353
353
  return !!f.__c;
354
354
  });
355
355
  if (d.every(function(f) {
356
356
  return !f.__N;
357
- })) return !o || o.call(this, l, c, a);
358
- var s = i.__c.props !== l;
357
+ })) return !o || o.call(this, a, c, l);
358
+ var s = i.__c.props !== a;
359
359
  return d.forEach(function(f) {
360
360
  if (f.__N) {
361
361
  var u = f.__[0];
362
362
  f.__ = f.__N, f.__N = void 0, u !== f.__[0] && (s = !0);
363
363
  }
364
- }), o && o.call(this, l, c, a) || s;
364
+ }), o && o.call(this, a, c, l) || s;
365
365
  };
366
- v.__f = !0;
367
- var o = v.shouldComponentUpdate, _ = v.componentWillUpdate;
368
- v.componentWillUpdate = function(l, c, a) {
366
+ y.__f = !0;
367
+ var o = y.shouldComponentUpdate, _ = y.componentWillUpdate;
368
+ y.componentWillUpdate = function(a, c, l) {
369
369
  if (this.__e) {
370
370
  var d = o;
371
- o = void 0, r(l, c, a), o = d;
371
+ o = void 0, r(a, c, l), o = d;
372
372
  }
373
- _ && _.call(this, l, c, a);
374
- }, v.shouldComponentUpdate = r;
373
+ _ && _.call(this, a, c, l);
374
+ }, y.shouldComponentUpdate = r;
375
375
  }
376
376
  return i.__N || i.__;
377
377
  }
378
- function Ae(t, e) {
379
- var n = de(V++, 3);
380
- !b.__s && Ke(n.__H, e) && (n.__ = t, n.u = e, v.__H.__h.push(n));
378
+ function xe(t, e) {
379
+ var n = de(z++, 3);
380
+ !b.__s && Je(n.__H, e) && (n.__ = t, n.u = e, y.__H.__h.push(n));
381
381
  }
382
- function Ne(t) {
383
- return Y = 5, ft(function() {
382
+ function Se(t) {
383
+ return Y = 5, ht(function() {
384
384
  return { current: t };
385
385
  }, []);
386
386
  }
387
- function ft(t, e) {
388
- var n = de(V++, 7);
389
- return Ke(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
387
+ function ht(t, e) {
388
+ var n = de(z++, 7);
389
+ return Je(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
390
390
  }
391
- function ht() {
392
- for (var t; t = qe.shift(); ) if (t.__P && t.__H) try {
391
+ function gt() {
392
+ for (var t; t = Ke.shift(); ) if (t.__P && t.__H) try {
393
393
  t.__H.__h.forEach(G), t.__H.__h.forEach(_e), t.__H.__h = [];
394
394
  } catch (e) {
395
395
  t.__H.__h = [], b.__e(e, t.__v);
396
396
  }
397
397
  }
398
398
  b.__b = function(t) {
399
- v = null, we && we(t);
399
+ y = null, be && be(t);
400
400
  }, b.__ = function(t, e) {
401
- t && e.__k && e.__k.__m && (t.__m = e.__k.__m), xe && xe(t, e);
401
+ t && e.__k && e.__k.__m && (t.__m = e.__k.__m), We && We(t, e);
402
402
  }, b.__r = function(t) {
403
- be && be(t), V = 0;
404
- var e = (v = t.__c).__H;
405
- e && (te === v ? (e.__h = [], v.__h = [], e.__.forEach(function(n) {
403
+ ke && ke(t), z = 0;
404
+ var e = (y = t.__c).__H;
405
+ e && (te === y ? (e.__h = [], y.__h = [], e.__.forEach(function(n) {
406
406
  n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
407
- })) : (e.__h.forEach(G), e.__h.forEach(_e), e.__h = [], V = 0)), te = v;
407
+ })) : (e.__h.forEach(G), e.__h.forEach(_e), e.__h = [], z = 0)), te = y;
408
408
  }, b.diffed = function(t) {
409
- ke && ke(t);
409
+ Ce && Ce(t);
410
410
  var e = t.__c;
411
- e && e.__H && (e.__H.__h.length && (qe.push(e) !== 1 && ye === b.requestAnimationFrame || ((ye = b.requestAnimationFrame) || pt)(ht)), e.__H.__.forEach(function(n) {
411
+ e && e.__H && (e.__H.__h.length && (Ke.push(e) !== 1 && we === b.requestAnimationFrame || ((we = b.requestAnimationFrame) || pt)(gt)), e.__H.__.forEach(function(n) {
412
412
  n.u && (n.__H = n.u), n.u = void 0;
413
- })), te = v = null;
413
+ })), te = y = null;
414
414
  }, b.__c = function(t, e) {
415
415
  e.some(function(n) {
416
416
  try {
@@ -422,7 +422,7 @@ b.__b = function(t) {
422
422
  r.__h && (r.__h = []);
423
423
  }), e = [], b.__e(i, n.__v);
424
424
  }
425
- }), Ce && Ce(t, e);
425
+ }), Ae && Ae(t, e);
426
426
  }, b.unmount = function(t) {
427
427
  $e && $e(t);
428
428
  var e, n = t.__c;
@@ -434,70 +434,85 @@ b.__b = function(t) {
434
434
  }
435
435
  }), n.__H = void 0, e && b.__e(e, n.__v));
436
436
  };
437
- var Se = typeof requestAnimationFrame == "function";
437
+ var Ne = typeof requestAnimationFrame == "function";
438
438
  function pt(t) {
439
439
  var e, n = function() {
440
- clearTimeout(i), Se && cancelAnimationFrame(e), setTimeout(t);
440
+ clearTimeout(i), Ne && cancelAnimationFrame(e), setTimeout(t);
441
441
  }, i = setTimeout(n, 35);
442
- Se && (e = requestAnimationFrame(n));
442
+ Ne && (e = requestAnimationFrame(n));
443
443
  }
444
444
  function G(t) {
445
- var e = v, n = t.__c;
446
- typeof n == "function" && (t.__c = void 0, n()), v = e;
445
+ var e = y, n = t.__c;
446
+ typeof n == "function" && (t.__c = void 0, n()), y = e;
447
447
  }
448
448
  function _e(t) {
449
- var e = v;
450
- t.__c = t.__(), v = e;
449
+ var e = y;
450
+ t.__c = t.__(), y = e;
451
451
  }
452
- function Ke(t, e) {
452
+ function Je(t, e) {
453
453
  return !t || t.length !== e.length || e.some(function(n, i) {
454
454
  return n !== t[i];
455
455
  });
456
456
  }
457
- function Je(t, e) {
457
+ function Ge(t, e) {
458
458
  return typeof e == "function" ? e(t) : e;
459
459
  }
460
- const gt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
460
+ const mt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
461
461
  let ne = (t = 21) => {
462
462
  let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
463
463
  for (; t--; )
464
- e += gt[n[t] & 63];
464
+ e += mt[n[t] & 63];
465
465
  return e;
466
466
  };
467
- class mt {
467
+ class vt {
468
468
  constructor(e, n) {
469
- this.apiUrl = e, this.directAgentUrl = n, this.config = null, this.ws = null, this.messageCallbacks = /* @__PURE__ */ new Set(), this.connectionCallbacks = /* @__PURE__ */ new Set(), this.messages = [], this.reconnectAttempts = 0, this.maxReconnectAttempts = 5, this.reconnectDelay = 1e3;
469
+ this.agentUrl = e, this.agentId = n, this.agentConfig = null, this.ws = null, this.messageCallbacks = /* @__PURE__ */ new Set(), this.connectionCallbacks = /* @__PURE__ */ new Set(), this.messages = [], this.reconnectAttempts = 0, this.maxReconnectAttempts = 5, this.reconnectDelay = 1e3;
470
470
  }
471
471
  /**
472
- * Initialize the widget - either fetch config or use direct agent URL
472
+ * Initialize the widget by fetching agent configuration
473
473
  */
474
- async initWidget(e) {
474
+ async initWidget() {
475
475
  try {
476
- if (this.directAgentUrl)
477
- return this.config = {
478
- name: "Direct Agent Connection",
479
- agentUrl: this.directAgentUrl,
480
- agentId: "direct"
481
- }, await this.connectToAgent(), this.config;
482
- if (!this.apiUrl || !e)
483
- throw new Error("Either agent-url prop or both api-url and widget-id are required");
484
- const n = await fetch(`${this.apiUrl}/api/widget/${e}`);
485
- if (!n.ok)
486
- throw new Error(`Failed to fetch widget config: ${n.status}`);
487
- const i = await n.json();
488
- return !i || !i.isActive ? (console.error("Widget not found or inactive"), null) : (this.config = i, await this.connectToAgent(), i);
489
- } catch (n) {
490
- return console.error("Failed to initialize widget:", n), null;
476
+ console.log("[AriaFlow Widget] Fetching agent config...", { agentUrl: this.agentUrl, agentId: this.agentId });
477
+ try {
478
+ const n = await fetch(`${this.agentUrl}/api/agent/${this.agentId}`);
479
+ if (n.ok) {
480
+ const i = await n.json();
481
+ return console.log("[AriaFlow Widget] Agent config received:", i), !i || i.status !== "active" ? (console.error("Agent not found or inactive"), null) : (this.agentConfig = i, this.maxReconnectAttempts = i.config.maxRetries || 5, this.reconnectDelay = i.config.reconnectDelay || 1e3, await this.connectToAgent(), i);
482
+ }
483
+ } catch {
484
+ console.warn("[AriaFlow Widget] Agent config endpoint not available, trying fallback");
485
+ }
486
+ console.log("[AriaFlow Widget] Using fallback config for Railway deployment");
487
+ const e = {
488
+ id: this.agentId,
489
+ name: this.agentId === "hospital" ? "Hospital Support" : "Support Agent",
490
+ wsUrl: `${this.agentUrl.replace(/^https/, "wss")}/ws`,
491
+ status: "active",
492
+ capabilities: ["chat", "streaming"],
493
+ config: {
494
+ primaryColor: "#14B8A6",
495
+ position: "bottom-right",
496
+ theme: "light",
497
+ title: this.agentId === "hospital" ? "Hospital Support" : "Chat Support",
498
+ subtitle: "We're here to help!",
499
+ maxRetries: 3,
500
+ reconnectDelay: 1e3
501
+ }
502
+ };
503
+ return this.agentConfig = e, await this.connectToAgent(), e;
504
+ } catch (e) {
505
+ return console.error("Failed to initialize widget:", e), null;
491
506
  }
492
507
  }
493
508
  /**
494
- * Connect directly to the agent via WebSocket
509
+ * Connect to the agent via WebSocket using resolved config
495
510
  */
496
511
  async connectToAgent() {
497
- if (!this.config?.agentUrl)
498
- throw new Error("No agent URL configured");
499
- const e = this.getSessionId(), n = `${this.config.agentUrl}/agents/chat/${e}`;
500
- return new Promise((i, r) => {
512
+ if (!this.agentConfig?.wsUrl)
513
+ throw new Error("No agent WebSocket URL configured");
514
+ const e = this.getSessionId(), n = `${this.agentConfig.wsUrl}/${e}`;
515
+ return console.log("[AriaFlow Widget] Connecting to WebSocket:", n), new Promise((i, r) => {
501
516
  try {
502
517
  this.ws = new WebSocket(n), this.ws.onopen = () => {
503
518
  console.log("[Widget] Connected to agent"), this.reconnectAttempts = 0, this.notifyConnectionChange(!0), i();
@@ -595,10 +610,10 @@ class mt {
595
610
  return this.messages;
596
611
  }
597
612
  /**
598
- * Get the current configuration
613
+ * Get the current agent configuration
599
614
  */
600
615
  getConfig() {
601
- return this.config;
616
+ return this.agentConfig;
602
617
  }
603
618
  /**
604
619
  * Check if connected
@@ -619,82 +634,86 @@ const oe = {
619
634
  medium: "0.75rem",
620
635
  large: "1rem"
621
636
  };
622
- function vt({
623
- widgetId: t,
624
- apiUrl: e,
625
- agentUrl: n,
626
- mode: i = "chat",
627
- theme: r = "light",
628
- position: o = "bottom-right",
629
- size: _ = "full",
630
- radius: l = "medium",
631
- baseColor: c,
632
- accentColor: a = "#14B8A6",
633
- buttonBaseColor: d = "#000000",
634
- buttonAccentColor: s = "#FFFFFF",
635
- title: f,
636
- subtitle: u,
637
- emptyChatMessage: y
637
+ function yt({
638
+ agentUrl: t,
639
+ agentId: e,
640
+ // Legacy props for backward compatibility
641
+ widgetId: n,
642
+ apiUrl: i,
643
+ mode: r = "chat",
644
+ theme: o = "light",
645
+ position: _ = "bottom-right",
646
+ size: a = "full",
647
+ radius: c = "medium",
648
+ baseColor: l,
649
+ accentColor: d = "#14B8A6",
650
+ buttonBaseColor: s = "#000000",
651
+ buttonAccentColor: f = "#FFFFFF",
652
+ title: u,
653
+ subtitle: w,
654
+ emptyChatMessage: C
638
655
  }) {
639
- const [k, w] = U(!1), [p, g] = U([]), [$, S] = U(""), [N, F] = U(!1), [x, P] = U(!1), [E, L] = U(null), C = Ne(null), M = Ne(null);
640
- Ae(() => ((async () => {
641
- console.log("[AriaFlow Widget] Starting initialization...", { agentUrl: n, widgetId: t, apiUrl: e });
642
- const T = new mt(e, n);
643
- C.current = T;
644
- try {
645
- const R = n ? await T.initWidget() : await T.initWidget(t);
646
- console.log("[AriaFlow Widget] Initialization result:", R), R ? (L(R), P(!0), console.log("[AriaFlow Widget] Widget initialized successfully"), T.onMessages((j) => {
647
- console.log("[AriaFlow Widget] Messages updated:", j.length), g(j);
648
- }), T.onConnectionChange((j) => {
649
- console.log("[AriaFlow Widget] Connection state:", j), F(j);
650
- })) : console.error("[AriaFlow Widget] Widget initialization failed - no config returned");
651
- } catch (R) {
652
- console.error("[AriaFlow Widget] Initialization error:", R);
653
- }
656
+ const [v, p] = U(!1), [h, S] = U([]), [A, E] = U(""), [$, q] = U(!1), [k, M] = U(!1), [H, W] = U(null), N = Se(null), fe = Se(null);
657
+ xe(() => ((async () => {
658
+ if (t && e) {
659
+ console.log("[AriaFlow Widget] Using new agent resolution:", { agentUrl: t, agentId: e });
660
+ const P = new vt(t, e);
661
+ N.current = P;
662
+ try {
663
+ const L = await P.initWidget();
664
+ console.log("[AriaFlow Widget] Agent config received:", L), L ? (W(L), M(!0), console.log("[AriaFlow Widget] Widget initialized successfully"), P.onMessages((O) => {
665
+ console.log("[AriaFlow Widget] Messages updated:", O.length), S(O);
666
+ }), P.onConnectionChange((O) => {
667
+ console.log("[AriaFlow Widget] Connection state:", O), q(O);
668
+ })) : console.error("[AriaFlow Widget] Agent config fetch failed");
669
+ } catch (L) {
670
+ console.error("[AriaFlow Widget] Initialization error:", L);
671
+ }
672
+ } 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")) : i && 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.");
654
673
  })(), () => {
655
- C.current?.dispose();
656
- }), [t, e, n]), Ae(() => {
657
- M.current?.scrollIntoView({ behavior: "smooth" });
658
- }, [p]);
659
- const fe = async () => {
660
- if (!$.trim() || !N) return;
661
- const A = $.trim();
662
- S("");
674
+ N.current?.dispose();
675
+ }), [t, e, n, i]), xe(() => {
676
+ fe.current?.scrollIntoView({ behavior: "smooth" });
677
+ }, [h]);
678
+ const he = async () => {
679
+ if (!A.trim() || !$) return;
680
+ const x = A.trim();
681
+ E("");
663
682
  try {
664
- await C.current?.sendMessage(A);
665
- } catch (T) {
666
- console.error("Failed to send message:", T);
683
+ await N.current?.sendMessage(x);
684
+ } catch (P) {
685
+ console.error("Failed to send message:", P);
667
686
  }
668
- }, Ge = (A) => {
669
- A.key === "Enter" && !A.shiftKey && (A.preventDefault(), fe());
670
- }, Qe = f || E?.title || "Chat with us", Xe = u || E?.subtitle || "We typically reply within minutes", Ye = y || E?.config?.emptyChatMessage || "Start a conversation...";
671
- return console.log("[AriaFlow Widget] Rendering widget component", { isInitialized: x, isOpen: k, position: o }), /* @__PURE__ */ h(
687
+ }, Qe = (x) => {
688
+ x.key === "Enter" && !x.shiftKey && (x.preventDefault(), he());
689
+ }, Xe = u || H?.title || "Chat with us", Ye = w || H?.subtitle || "We typically reply within minutes", Ze = C || H?.config?.emptyChatMessage || "Start a conversation...";
690
+ return console.log("[AriaFlow Widget] Rendering widget component", { isInitialized: k, isOpen: v, position: _ }), /* @__PURE__ */ g(
672
691
  "div",
673
692
  {
674
- className: `ariaflow-widget-container ariaflow-widget-${o} ariaflow-widget-${_} ariaflow-widget-radius-${l}`,
675
- "data-theme": r,
693
+ className: `ariaflow-widget-container ariaflow-widget-${_} ariaflow-widget-${a} ariaflow-widget-radius-${c}`,
694
+ "data-theme": o,
676
695
  style: {
677
- "--ariaflow-accent-color": a,
678
- "--ariaflow-base-color": c
696
+ "--ariaflow-accent-color": d,
697
+ "--ariaflow-base-color": l
679
698
  },
680
699
  children: [
681
- !k && /* @__PURE__ */ h(
700
+ !v && /* @__PURE__ */ g(
682
701
  "button",
683
702
  {
684
703
  className: "ariaflow-widget-launcher",
685
- onClick: () => w(!0),
704
+ onClick: () => p(!0),
686
705
  style: {
687
- backgroundColor: d,
688
- color: s,
689
- opacity: x ? 1 : 0.8,
690
- cursor: x ? "pointer" : "wait",
706
+ backgroundColor: s,
707
+ color: f,
708
+ opacity: k ? 1 : 0.8,
709
+ cursor: k ? "pointer" : "wait",
691
710
  position: "relative"
692
711
  },
693
- "aria-label": x ? "Open chat" : "Connecting to agent...",
694
- disabled: !x,
695
- title: x ? "Click to start chat" : "Connecting to agent...",
712
+ "aria-label": k ? "Open chat" : "Connecting to agent...",
713
+ disabled: !k,
714
+ title: k ? "Click to start chat" : "Connecting to agent...",
696
715
  children: [
697
- !x && /* @__PURE__ */ h(
716
+ !k && /* @__PURE__ */ g(
698
717
  "div",
699
718
  {
700
719
  className: "ariaflow-widget-launcher-loading",
@@ -705,14 +724,14 @@ function vt({
705
724
  transform: "translate(-50%, -50%)",
706
725
  width: "20px",
707
726
  height: "20px",
708
- border: `2px solid ${s}`,
727
+ border: `2px solid ${f}`,
709
728
  borderTop: "2px solid transparent",
710
729
  borderRadius: "50%",
711
730
  animation: "spin 1s linear infinite"
712
731
  }
713
732
  }
714
733
  ),
715
- x && /* @__PURE__ */ h(
734
+ k && /* @__PURE__ */ g(
716
735
  "svg",
717
736
  {
718
737
  width: "24",
@@ -721,41 +740,41 @@ function vt({
721
740
  fill: "none",
722
741
  stroke: "currentColor",
723
742
  strokeWidth: "2",
724
- children: /* @__PURE__ */ h("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
743
+ children: /* @__PURE__ */ g("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
725
744
  }
726
745
  )
727
746
  ]
728
747
  }
729
748
  ),
730
- k && x && /* @__PURE__ */ h(
749
+ v && k && /* @__PURE__ */ g(
731
750
  "div",
732
751
  {
733
752
  className: "ariaflow-widget-window",
734
753
  style: {
735
- backgroundColor: r === "dark" && c ? c : void 0,
736
- borderRadius: oe[l]
754
+ backgroundColor: o === "dark" && l ? l : void 0,
755
+ borderRadius: oe[c]
737
756
  },
738
757
  children: [
739
- /* @__PURE__ */ h(
758
+ /* @__PURE__ */ g(
740
759
  "div",
741
760
  {
742
761
  className: "ariaflow-widget-header",
743
762
  style: {
744
- backgroundColor: a,
745
- borderRadius: l === "none" ? "0" : `${oe[l]} ${oe[l]} 0 0`
763
+ backgroundColor: d,
764
+ borderRadius: c === "none" ? "0" : `${oe[c]} ${oe[c]} 0 0`
746
765
  },
747
766
  children: [
748
- /* @__PURE__ */ h("div", { className: "ariaflow-widget-header-content", children: /* @__PURE__ */ h("div", { className: "ariaflow-widget-title-group", children: [
749
- /* @__PURE__ */ h("h3", { className: "ariaflow-widget-title", children: Qe }),
750
- /* @__PURE__ */ h("p", { className: "ariaflow-widget-subtitle", children: Xe })
767
+ /* @__PURE__ */ g("div", { className: "ariaflow-widget-header-content", children: /* @__PURE__ */ g("div", { className: "ariaflow-widget-title-group", children: [
768
+ /* @__PURE__ */ g("h3", { className: "ariaflow-widget-title", children: Xe }),
769
+ /* @__PURE__ */ g("p", { className: "ariaflow-widget-subtitle", children: Ye })
751
770
  ] }) }),
752
- /* @__PURE__ */ h(
771
+ /* @__PURE__ */ g(
753
772
  "button",
754
773
  {
755
774
  className: "ariaflow-widget-close",
756
- onClick: () => w(!1),
775
+ onClick: () => p(!1),
757
776
  "aria-label": "Close chat",
758
- children: /* @__PURE__ */ h(
777
+ children: /* @__PURE__ */ g(
759
778
  "svg",
760
779
  {
761
780
  width: "20",
@@ -765,8 +784,8 @@ function vt({
765
784
  stroke: "currentColor",
766
785
  strokeWidth: "2",
767
786
  children: [
768
- /* @__PURE__ */ h("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
769
- /* @__PURE__ */ h("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
787
+ /* @__PURE__ */ g("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
788
+ /* @__PURE__ */ g("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
770
789
  ]
771
790
  }
772
791
  )
@@ -775,42 +794,42 @@ function vt({
775
794
  ]
776
795
  }
777
796
  ),
778
- !N && /* @__PURE__ */ h("div", { className: "ariaflow-widget-status", children: [
779
- /* @__PURE__ */ h("span", { className: "ariaflow-widget-status-dot" }),
797
+ !$ && /* @__PURE__ */ g("div", { className: "ariaflow-widget-status", children: [
798
+ /* @__PURE__ */ g("span", { className: "ariaflow-widget-status-dot" }),
780
799
  "Connecting..."
781
800
  ] }),
782
- /* @__PURE__ */ h("div", { className: "ariaflow-widget-messages", children: p.length === 0 ? /* @__PURE__ */ h("div", { className: "ariaflow-widget-empty", children: /* @__PURE__ */ h("p", { children: N ? Ye : "Connecting to agent..." }) }) : /* @__PURE__ */ h(O, { children: [
783
- p.map((A) => /* @__PURE__ */ h(
801
+ /* @__PURE__ */ g("div", { className: "ariaflow-widget-messages", children: h.length === 0 ? /* @__PURE__ */ g("div", { className: "ariaflow-widget-empty", children: /* @__PURE__ */ g("p", { children: $ ? Ze : "Connecting to agent..." }) }) : /* @__PURE__ */ g(R, { children: [
802
+ h.map((x) => /* @__PURE__ */ g(
784
803
  "div",
785
804
  {
786
- className: `ariaflow-widget-message ariaflow-widget-message-${A.role}`,
787
- children: /* @__PURE__ */ h("div", { className: "ariaflow-widget-message-bubble", children: A.content })
805
+ className: `ariaflow-widget-message ariaflow-widget-message-${x.role}`,
806
+ children: /* @__PURE__ */ g("div", { className: "ariaflow-widget-message-bubble", children: x.content })
788
807
  },
789
- A.id
808
+ x.id
790
809
  )),
791
- /* @__PURE__ */ h("div", { ref: M })
810
+ /* @__PURE__ */ g("div", { ref: fe })
792
811
  ] }) }),
793
- /* @__PURE__ */ h("div", { className: "ariaflow-widget-input", children: [
794
- /* @__PURE__ */ h(
812
+ /* @__PURE__ */ g("div", { className: "ariaflow-widget-input", children: [
813
+ /* @__PURE__ */ g(
795
814
  "textarea",
796
815
  {
797
- value: $,
798
- onInput: (A) => S(A.target.value),
799
- onKeyDown: Ge,
800
- placeholder: N ? "Type your message..." : "Connecting...",
816
+ value: A,
817
+ onInput: (x) => E(x.target.value),
818
+ onKeyDown: Qe,
819
+ placeholder: $ ? "Type your message..." : "Connecting...",
801
820
  rows: 1,
802
- disabled: !N
821
+ disabled: !$
803
822
  }
804
823
  ),
805
- /* @__PURE__ */ h(
824
+ /* @__PURE__ */ g(
806
825
  "button",
807
826
  {
808
827
  className: "ariaflow-widget-send",
809
- onClick: fe,
810
- disabled: !$.trim() || !N,
811
- style: { backgroundColor: a },
828
+ onClick: he,
829
+ disabled: !A.trim() || !$,
830
+ style: { backgroundColor: d },
812
831
  "aria-label": "Send message",
813
- children: /* @__PURE__ */ h(
832
+ children: /* @__PURE__ */ g(
814
833
  "svg",
815
834
  {
816
835
  width: "18",
@@ -820,8 +839,8 @@ function vt({
820
839
  stroke: "currentColor",
821
840
  strokeWidth: "2",
822
841
  children: [
823
- /* @__PURE__ */ h("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
824
- /* @__PURE__ */ h("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
842
+ /* @__PURE__ */ g("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
843
+ /* @__PURE__ */ g("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
825
844
  ]
826
845
  }
827
846
  )
@@ -835,14 +854,17 @@ function vt({
835
854
  }
836
855
  );
837
856
  }
838
- st(
839
- vt,
857
+ _t(
858
+ yt,
840
859
  "ariaflow-widget",
841
860
  // Properties to observe from HTML attributes (mirror Vapi's naming convention)
842
861
  [
862
+ "agent-url",
863
+ "agent-id",
864
+ // Legacy support
843
865
  "widget-id",
844
866
  "api-url",
845
- "agent-url",
867
+ // Other options
846
868
  "mode",
847
869
  "theme",
848
870
  "position",
@@ -859,12 +881,12 @@ st(
859
881
  // Shadow DOM (optional, set to false for light DOM)
860
882
  !1
861
883
  );
862
- typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", We) : We());
863
- function We() {
884
+ typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", Fe) : Fe());
885
+ function Fe() {
864
886
  const t = document.querySelectorAll("ariaflow-widget");
865
887
  console.log(`[AriaFlow] Initializing ${t.length} widget(s)`);
866
888
  }
867
889
  export {
868
- vt as Widget,
869
- mt as WidgetClient
890
+ yt as Widget,
891
+ vt as WidgetClient
870
892
  };
@@ -1 +1 @@
1
- (function(F,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(F=typeof globalThis<"u"?globalThis:F||self,E(F.AriaFlowWidget={}))})(this,function(F){"use strict";var E,m,he,H,pe,ge,me,ve,ne,oe,ie,j={},ye=[],Ye=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,J=Array.isArray;function S(t,e){for(var n in e)t[n]=e[n];return t}function re(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function D(t,e,n){var i,r,o,_={};for(o in e)o=="key"?i=e[o]:o=="ref"?r=e[o]:_[o]=e[o];if(arguments.length>2&&(_.children=arguments.length>3?E.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)_[o]===void 0&&(_[o]=t.defaultProps[o]);return z(t,_,i,r,null)}function z(t,e,n,i,r){var o={type:t,props:e,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++he,__i:-1,__u:0};return r==null&&m.vnode!=null&&m.vnode(o),o}function I(t){return t.children}function G(t,e){this.props=t,this.context=e}function O(t,e){if(e==null)return t.__?O(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"?O(t):null}function we(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 we(t)}}function be(t){(!t.__d&&(t.__d=!0)&&H.push(t)&&!Q.__r++||pe!=m.debounceRendering)&&((pe=m.debounceRendering)||ge)(Q)}function Q(){for(var t,e,n,i,r,o,_,l=1;H.length;)H.length>l&&H.sort(me),t=H.shift(),l=H.length,t.__d&&(n=void 0,i=void 0,r=(i=(e=t).__v).__e,o=[],_=[],e.__P&&((n=S({},i)).__v=i.__v+1,m.vnode&&m.vnode(n),se(e.__P,n,i,e.__n,e.__P.namespaceURI,32&i.__u?[r]:null,o,r??O(i),!!(32&i.__u),_),n.__v=i.__v,n.__.__k[n.__i]=n,xe(o,n,_),i.__e=i.__=null,n.__e!=r&&we(n)));Q.__r=0}function ke(t,e,n,i,r,o,_,l,c,a,d){var s,f,u,w,k,b,p,g=i&&i.__k||ye,$=e.length;for(c=Ze(n,e,g,c,$),s=0;s<$;s++)(u=n.__k[s])!=null&&(f=u.__i==-1?j:g[u.__i]||j,u.__i=s,b=se(t,u,f,r,o,_,l,c,a,d),w=u.__e,u.ref&&f.ref!=u.ref&&(f.ref&&le(f.ref,null,u),d.push(u.ref,u.__c||w,u)),k==null&&w!=null&&(k=w),(p=!!(4&u.__u))||f.__k===u.__k?c=Ce(u,c,t,p):typeof u.type=="function"&&b!==void 0?c=b:w&&(c=w.nextSibling),u.__u&=-7);return n.__e=k,c}function Ze(t,e,n,i,r){var o,_,l,c,a,d=n.length,s=d,f=0;for(t.__k=new Array(r),o=0;o<r;o++)(_=e[o])!=null&&typeof _!="boolean"&&typeof _!="function"?(typeof _=="string"||typeof _=="number"||typeof _=="bigint"||_.constructor==String?_=t.__k[o]=z(null,_,null,null,null):J(_)?_=t.__k[o]=z(I,{children:_},null,null,null):_.constructor===void 0&&_.__b>0?_=t.__k[o]=z(_.type,_.props,_.key,_.ref?_.ref:null,_.__v):t.__k[o]=_,c=o+f,_.__=t,_.__b=t.__b+1,l=null,(a=_.__i=et(_,n,c,s))!=-1&&(s--,(l=n[a])&&(l.__u|=2)),l==null||l.__v==null?(a==-1&&(r>d?f--:r<d&&f++),typeof _.type!="function"&&(_.__u|=4)):a!=c&&(a==c-1?f--:a==c+1?f++:(a>c?f--:f++,_.__u|=4))):t.__k[o]=null;if(s)for(o=0;o<d;o++)(l=n[o])!=null&&!(2&l.__u)&&(l.__e==i&&(i=O(l)),Se(l,l));return i}function Ce(t,e,n,i){var r,o;if(typeof t.type=="function"){for(r=t.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=t,e=Ce(r[o],e,n,i));return e}t.__e!=e&&(i&&(e&&t.type&&!e.parentNode&&(e=O(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function et(t,e,n,i){var r,o,_,l=t.key,c=t.type,a=e[n],d=a!=null&&(2&a.__u)==0;if(a===null&&l==null||d&&l==a.key&&c==a.type)return n;if(i>(d?1:0)){for(r=n-1,o=n+1;r>=0||o<e.length;)if((a=e[_=r>=0?r--:o++])!=null&&!(2&a.__u)&&l==a.key&&c==a.type)return _}return-1}function $e(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Ye.test(e)?n:n+"px"}function X(t,e,n,i,r){var o,_;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof i=="string"&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||$e(t.style,e,"");if(n)for(e in n)i&&n[e]==i[e]||$e(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(ve,"$1")),_=e.toLowerCase(),e=_ in t||e=="onFocusOut"||e=="onFocusIn"?_.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?i?n.u=i.u:(n.u=ne,t.addEventListener(e,o?ie:oe,o)):t.removeEventListener(e,o?ie:oe,o);else{if(r=="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 Ae(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ne++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function se(t,e,n,i,r,o,_,l,c,a){var d,s,f,u,w,k,b,p,g,$,W,N,P,A,R,M,V,C=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),o=[l=e.__e=n.__e]),(d=m.__b)&&d(e);e:if(typeof C=="function")try{if(p=e.props,g="prototype"in C&&C.prototype.render,$=(d=C.contextType)&&i[d.__c],W=d?$?$.props.value:d.__:i,n.__c?b=(s=e.__c=n.__c).__=s.__E:(g?e.__c=s=new C(p,W):(e.__c=s=new G(p,W),s.constructor=C,s.render=nt),$&&$.sub(s),s.state||(s.state={}),s.__n=i,f=s.__d=!0,s.__h=[],s._sb=[]),g&&s.__s==null&&(s.__s=s.state),g&&C.getDerivedStateFromProps!=null&&(s.__s==s.state&&(s.__s=S({},s.__s)),S(s.__s,C.getDerivedStateFromProps(p,s.__s))),u=s.props,w=s.state,s.__v=e,f)g&&C.getDerivedStateFromProps==null&&s.componentWillMount!=null&&s.componentWillMount(),g&&s.componentDidMount!=null&&s.__h.push(s.componentDidMount);else{if(g&&C.getDerivedStateFromProps==null&&p!==u&&s.componentWillReceiveProps!=null&&s.componentWillReceiveProps(p,W),e.__v==n.__v||!s.__e&&s.shouldComponentUpdate!=null&&s.shouldComponentUpdate(p,s.__s,W)===!1){for(e.__v!=n.__v&&(s.props=p,s.state=s.__s,s.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(T){T&&(T.__=e)}),N=0;N<s._sb.length;N++)s.__h.push(s._sb[N]);s._sb=[],s.__h.length&&_.push(s);break e}s.componentWillUpdate!=null&&s.componentWillUpdate(p,s.__s,W),g&&s.componentDidUpdate!=null&&s.__h.push(function(){s.componentDidUpdate(u,w,k)})}if(s.context=W,s.props=p,s.__P=t,s.__e=!1,P=m.__r,A=0,g){for(s.state=s.__s,s.__d=!1,P&&P(e),d=s.render(s.props,s.state,s.context),R=0;R<s._sb.length;R++)s.__h.push(s._sb[R]);s._sb=[]}else do s.__d=!1,P&&P(e),d=s.render(s.props,s.state,s.context),s.state=s.__s;while(s.__d&&++A<25);s.state=s.__s,s.getChildContext!=null&&(i=S(S({},i),s.getChildContext())),g&&!f&&s.getSnapshotBeforeUpdate!=null&&(k=s.getSnapshotBeforeUpdate(u,w)),M=d,d!=null&&d.type===I&&d.key==null&&(M=Ne(d.props.children)),l=ke(t,J(M)?M:[M],e,n,i,r,o,_,l,c,a),s.base=e.__e,e.__u&=-161,s.__h.length&&_.push(s),b&&(s.__E=s.__=null)}catch(T){if(e.__v=null,c||o!=null)if(T.then){for(e.__u|=c?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;o[o.indexOf(l)]=null,e.__e=l}else{for(V=o.length;V--;)re(o[V]);_e(e)}else e.__e=n.__e,e.__k=n.__k,T.then||_e(e);m.__e(T,e,n)}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):l=e.__e=tt(n.__e,e,n,i,r,o,_,c,a);return(d=m.diffed)&&d(e),128&e.__u?void 0:l}function _e(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(_e)}function xe(t,e,n){for(var i=0;i<n.length;i++)le(n[i],n[++i],n[++i]);m.__c&&m.__c(e,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(o){o.call(r)})}catch(o){m.__e(o,r.__v)}})}function Ne(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:J(t)?t.map(Ne):S({},t)}function tt(t,e,n,i,r,o,_,l,c){var a,d,s,f,u,w,k,b=n.props||j,p=e.props,g=e.type;if(g=="svg"?r="http://www.w3.org/2000/svg":g=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),o!=null){for(a=0;a<o.length;a++)if((u=o[a])&&"setAttribute"in u==!!g&&(g?u.localName==g:u.nodeType==3)){t=u,o[a]=null;break}}if(t==null){if(g==null)return document.createTextNode(p);t=document.createElementNS(r,g,p.is&&p),l&&(m.__m&&m.__m(e,o),l=!1),o=null}if(g==null)b===p||l&&t.data==p||(t.data=p);else{if(o=o&&E.call(t.childNodes),!l&&o!=null)for(b={},a=0;a<t.attributes.length;a++)b[(u=t.attributes[a]).name]=u.value;for(a in b)if(u=b[a],a!="children"){if(a=="dangerouslySetInnerHTML")s=u;else if(!(a in p)){if(a=="value"&&"defaultValue"in p||a=="checked"&&"defaultChecked"in p)continue;X(t,a,null,u,r)}}for(a in p)u=p[a],a=="children"?f=u:a=="dangerouslySetInnerHTML"?d=u:a=="value"?w=u:a=="checked"?k=u:l&&typeof u!="function"||b[a]===u||X(t,a,u,b[a],r);if(d)l||s&&(d.__html==s.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(s&&(t.innerHTML=""),ke(e.type=="template"?t.content:t,J(f)?f:[f],e,n,i,g=="foreignObject"?"http://www.w3.org/1999/xhtml":r,o,_,o?o[0]:n.__k&&O(n,0),l,c),o!=null)for(a=o.length;a--;)re(o[a]);l||(a="value",g=="progress"&&w==null?t.removeAttribute("value"):w!=null&&(w!==t[a]||g=="progress"&&!w||g=="option"&&w!=b[a])&&X(t,a,w,b[a],r),a="checked",k!=null&&k!=t[a]&&X(t,a,k,b[a],r))}return t}function le(t,e,n){try{if(typeof t=="function"){var i=typeof t.__u=="function";i&&t.__u(),i&&e==null||(t.__u=t(e))}else t.current=e}catch(r){m.__e(r,n)}}function Se(t,e,n){var i,r;if(m.unmount&&m.unmount(t),(i=t.ref)&&(i.current&&i.current!=t.__e||le(i,null,e)),(i=t.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(o){m.__e(o,e)}i.base=i.__P=null}if(i=t.__k)for(r=0;r<i.length;r++)i[r]&&Se(i[r],e,n||typeof t.type!="function");n||re(t.__e),t.__c=t.__=t.__e=void 0}function nt(t,e,n){return this.constructor(t,n)}function Y(t,e,n){var i,r,o,_;e==document&&(e=document.documentElement),m.__&&m.__(t,e),r=(i=typeof n=="function")?null:n&&n.__k||e.__k,o=[],_=[],se(e,t=(!i&&n||e).__k=D(I,null,[t]),r||j,j,e.namespaceURI,!i&&n?[n]:r?null:e.firstChild?E.call(e.childNodes):null,o,!i&&n?n:r?r.__e:e.firstChild,i,_),xe(o,t,_)}function We(t,e){Y(t,e,We)}function Ee(t,e,n){var i,r,o,_,l=S({},t.props);for(o in t.type&&t.type.defaultProps&&(_=t.type.defaultProps),e)o=="key"?i=e[o]:o=="ref"?r=e[o]:l[o]=e[o]===void 0&&_!=null?_[o]:e[o];return arguments.length>2&&(l.children=arguments.length>3?E.call(arguments,2):n),z(t.type,l,i||t.key,r||t.ref,null)}E=ye.slice,m={__e:function(t,e,n,i){for(var r,o,_;e=e.__;)if((r=e.__c)&&!r.__)try{if((o=r.constructor)&&o.getDerivedStateFromError!=null&&(r.setState(o.getDerivedStateFromError(t)),_=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,i||{}),_=r.__d),_)return r.__E=r}catch(l){t=l}throw t}},he=0,G.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=S({},this.state),typeof t=="function"&&(t=t(S({},n),this.props)),t&&S(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),be(this))},G.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),be(this))},G.prototype.render=I,H=[],ge=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,me=function(t,e){return t.__v.__b-e.__v.__b},Q.__r=0,ve=/(PointerCapture)$|Capture$/i,ne=0,oe=Ae(!1),ie=Ae(!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 i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Z.apply(this,arguments)}function Me(t,e){if(t==null)return{};var n,i,r={},o=Object.keys(t);for(i=0;i<o.length;i++)e.indexOf(n=o[i])>=0||(r[n]=t[n]);return r}var ot=["context","children"],it=["useFragment"];function rt(t,e,n,i){function r(){var o=Reflect.construct(HTMLElement,[],r);return o._vdomComponent=t,o._root=o,o}return(r.prototype=Object.create(HTMLElement.prototype)).constructor=r,r.prototype.connectedCallback=function(){_t.call(this,i)},r.prototype.attributeChangedCallback=lt,r.prototype.disconnectedCallback=at,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),r.observedAttributes=n,t.formAssociated&&(r.formAssociated=!0),n.forEach(function(o){Object.defineProperty(r.prototype,o,{get:function(){return this._vdom?this._vdom.props[o]:this._props[o]},set:function(_){this._vdom?this.attributeChangedCallback(o,null,_):(this._props||(this._props={}),this._props[o]=_);var l=typeof _;_!=null&&l!=="string"&&l!=="boolean"&&l!=="number"||this.setAttribute(o,_)}})}),customElements.define(e,r),r}function st(t){this.getChildContext=function(){return t.context};var e=t.children,n=Me(t,ot);return Ee(e,n)}function _t(t){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=D(st,Z({},this._props,{context:e.detail.context}),He(this,this._vdomComponent,t)),(this.hasAttribute("hydrate")?We:Y)(this._vdom,this._root)}function Te(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function lt(t,e,n){if(this._vdom){var i={};i[t]=n=n??void 0,i[Te(t)]=n,this._vdom=Ee(this._vdom,i),Y(this._vdom,this._root)}}function at(){Y(this._vdom=null,this._root)}function Fe(t,e){var n=this,i=t.useFragment,r=Me(t,it);return D(i?I:"slot",Z({},r,{ref:function(o){o?(n.ref=o,n._listener||(n._listener=function(_){_.stopPropagation(),_.detail.context=e},o.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function He(t,e,n){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var i=[],r={},o=0,_=t.attributes,l=t.childNodes;for(o=_.length;o--;)_[o].name!=="slot"&&(r[_[o].name]=_[o].value,r[Te(_[o].name)]=_[o].value);for(o=l.length;o--;){var c=He(l[o],null,n),a=l[o].slot;a?r[a]=D(Fe,{name:a},c):i[o]=c}var d=!(!n||!n.shadow),s=e?D(Fe,{useFragment:!d},i):i;return!d&&e&&(t.innerHTML=""),D(e||t.nodeName.toLowerCase(),r,s)}var ct=0;function h(t,e,n,i,r,o){e||(e={});var _,l,c=e;if("ref"in c)for(l in c={},e)l=="ref"?_=e[l]:c[l]=e[l];var a={type:t,props:c,key:n,ref:_,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ct,__i:-1,__u:0,__source:r,__self:o};if(typeof t=="function"&&(_=t.defaultProps))for(l in _)c[l]===void 0&&(c[l]=_[l]);return m.vnode&&m.vnode(a),a}var B,v,ae,Pe,ee=0,Ue=[],y=m,De=y.__b,Ie=y.__r,Oe=y.diffed,Le=y.__c,Re=y.unmount,je=y.__;function ce(t,e){y.__h&&y.__h(v,t,ee||e),ee=0;var n=v.__H||(v.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function L(t){return ee=1,ut(Ke,t)}function ut(t,e,n){var i=ce(B++,2);if(i.t=t,!i.__c&&(i.__=[Ke(void 0,e),function(l){var c=i.__N?i.__N[0]:i.__[0],a=i.t(c,l);c!==a&&(i.__N=[a,i.__[1]],i.__c.setState({}))}],i.__c=v,!v.__f)){var r=function(l,c,a){if(!i.__c.__H)return!0;var d=i.__c.__H.__.filter(function(f){return!!f.__c});if(d.every(function(f){return!f.__N}))return!o||o.call(this,l,c,a);var s=i.__c.props!==l;return d.forEach(function(f){if(f.__N){var u=f.__[0];f.__=f.__N,f.__N=void 0,u!==f.__[0]&&(s=!0)}}),o&&o.call(this,l,c,a)||s};v.__f=!0;var o=v.shouldComponentUpdate,_=v.componentWillUpdate;v.componentWillUpdate=function(l,c,a){if(this.__e){var d=o;o=void 0,r(l,c,a),o=d}_&&_.call(this,l,c,a)},v.shouldComponentUpdate=r}return i.__N||i.__}function ze(t,e){var n=ce(B++,3);!y.__s&&qe(n.__H,e)&&(n.__=t,n.u=e,v.__H.__h.push(n))}function Be(t){return ee=5,dt(function(){return{current:t}},[])}function dt(t,e){var n=ce(B++,7);return qe(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function ft(){for(var t;t=Ue.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(te),t.__H.__h.forEach(ue),t.__H.__h=[]}catch(e){t.__H.__h=[],y.__e(e,t.__v)}}y.__b=function(t){v=null,De&&De(t)},y.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),je&&je(t,e)},y.__r=function(t){Ie&&Ie(t),B=0;var e=(v=t.__c).__H;e&&(ae===v?(e.__h=[],v.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(te),e.__h.forEach(ue),e.__h=[],B=0)),ae=v},y.diffed=function(t){Oe&&Oe(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Ue.push(e)!==1&&Pe===y.requestAnimationFrame||((Pe=y.requestAnimationFrame)||ht)(ft)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ae=v=null},y.__c=function(t,e){e.some(function(n){try{n.__h.forEach(te),n.__h=n.__h.filter(function(i){return!i.__||ue(i)})}catch(i){e.some(function(r){r.__h&&(r.__h=[])}),e=[],y.__e(i,n.__v)}}),Le&&Le(t,e)},y.unmount=function(t){Re&&Re(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(i){try{te(i)}catch(r){e=r}}),n.__H=void 0,e&&y.__e(e,n.__v))};var Ve=typeof requestAnimationFrame=="function";function ht(t){var e,n=function(){clearTimeout(i),Ve&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,35);Ve&&(e=requestAnimationFrame(n))}function te(t){var e=v,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),v=e}function ue(t){var e=v;t.__c=t.__(),v=e}function qe(t,e){return!t||t.length!==e.length||e.some(function(n,i){return n!==t[i]})}function Ke(t,e){return typeof e=="function"?e(t):e}const pt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let de=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=pt[n[t]&63];return e};class Je{constructor(e,n){this.apiUrl=e,this.directAgentUrl=n,this.config=null,this.ws=null,this.messageCallbacks=new Set,this.connectionCallbacks=new Set,this.messages=[],this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3}async initWidget(e){try{if(this.directAgentUrl)return this.config={name:"Direct Agent Connection",agentUrl:this.directAgentUrl,agentId:"direct"},await this.connectToAgent(),this.config;if(!this.apiUrl||!e)throw new Error("Either agent-url prop or both api-url and widget-id are required");const n=await fetch(`${this.apiUrl}/api/widget/${e}`);if(!n.ok)throw new Error(`Failed to fetch widget config: ${n.status}`);const i=await n.json();return!i||!i.isActive?(console.error("Widget not found or inactive"),null):(this.config=i,await this.connectToAgent(),i)}catch(n){return console.error("Failed to initialize widget:",n),null}}async connectToAgent(){if(!this.config?.agentUrl)throw new Error("No agent URL configured");const e=this.getSessionId(),n=`${this.config.agentUrl}/agents/chat/${e}`;return new Promise((i,r)=>{try{this.ws=new WebSocket(n),this.ws.onopen=()=>{console.log("[Widget] Connected to agent"),this.reconnectAttempts=0,this.notifyConnectionChange(!0),i()},this.ws.onmessage=o=>{this.handleMessage(o)},this.ws.onclose=()=>{if(console.log("[Widget] Disconnected from agent"),this.notifyConnectionChange(!1),this.reconnectAttempts<this.maxReconnectAttempts){this.reconnectAttempts++;const o=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.log(`[Widget] Reconnecting in ${o}ms... (attempt ${this.reconnectAttempts})`),setTimeout(()=>this.connectToAgent(),o)}},this.ws.onerror=o=>{console.error("[Widget] WebSocket error:",o),r(o)}}catch(o){r(o)}})}handleMessage(e){try{const n=JSON.parse(e.data);n.type==="text-delta"?this.setMessages(i=>{const r=i[i.length-1];return r&&r.role==="assistant"?[...i.slice(0,-1),{...r,content:r.content+n.text}]:[...i,{id:de(),role:"assistant",content:n.text,timestamp:Date.now()}]}):n.type==="done"?console.log("[Widget] Response complete"):n.type==="handoff"?console.log(`[Widget] Handoff: ${n.from} -> ${n.to}: ${n.reason}`):n.type==="tool-call"?console.log("[Widget] Tool call:",n.tool):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:de(),role:"user",content:e,timestamp:Date.now()};this.setMessages(r=>[...r,n]);const i=this.getSessionId();this.ws.send(JSON.stringify({message:e,sessionId:i}))}getSessionId(){let e=sessionStorage.getItem("ariaflow_session_id");return e||(e=de(),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)}}notifyConnectionChange(e){this.connectionCallbacks.forEach(n=>n(e))}getMessages(){return this.messages}getConfig(){return this.config}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 Ge({widgetId:t,apiUrl:e,agentUrl:n,mode:i="chat",theme:r="light",position:o="bottom-right",size:_="full",radius:l="medium",baseColor:c,accentColor:a="#14B8A6",buttonBaseColor:d="#000000",buttonAccentColor:s="#FFFFFF",title:f,subtitle:u,emptyChatMessage:w}){const[k,b]=L(!1),[p,g]=L([]),[$,W]=L(""),[N,P]=L(!1),[A,R]=L(!1),[M,V]=L(null),C=Be(null),T=Be(null);ze(()=>((async()=>{console.log("[AriaFlow Widget] Starting initialization...",{agentUrl:n,widgetId:t,apiUrl:e});const U=new Je(e,n);C.current=U;try{const q=n?await U.initWidget():await U.initWidget(t);console.log("[AriaFlow Widget] Initialization result:",q),q?(V(q),R(!0),console.log("[AriaFlow Widget] Widget initialized successfully"),U.onMessages(K=>{console.log("[AriaFlow Widget] Messages updated:",K.length),g(K)}),U.onConnectionChange(K=>{console.log("[AriaFlow Widget] Connection state:",K),P(K)})):console.error("[AriaFlow Widget] Widget initialization failed - no config returned")}catch(q){console.error("[AriaFlow Widget] Initialization error:",q)}})(),()=>{C.current?.dispose()}),[t,e,n]),ze(()=>{T.current?.scrollIntoView({behavior:"smooth"})},[p]);const Xe=async()=>{if(!$.trim()||!N)return;const x=$.trim();W("");try{await C.current?.sendMessage(x)}catch(U){console.error("Failed to send message:",U)}},gt=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),Xe())},mt=f||M?.title||"Chat with us",vt=u||M?.subtitle||"We typically reply within minutes",yt=w||M?.config?.emptyChatMessage||"Start a conversation...";return console.log("[AriaFlow Widget] Rendering widget component",{isInitialized:A,isOpen:k,position:o}),h("div",{className:`ariaflow-widget-container ariaflow-widget-${o} ariaflow-widget-${_} ariaflow-widget-radius-${l}`,"data-theme":r,style:{"--ariaflow-accent-color":a,"--ariaflow-base-color":c},children:[!k&&h("button",{className:"ariaflow-widget-launcher",onClick:()=>b(!0),style:{backgroundColor:d,color:s,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&&h("div",{className:"ariaflow-widget-launcher-loading",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"20px",height:"20px",border:`2px solid ${s}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),A&&h("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})]}),k&&A&&h("div",{className:"ariaflow-widget-window",style:{backgroundColor:r==="dark"&&c?c:void 0,borderRadius:fe[l]},children:[h("div",{className:"ariaflow-widget-header",style:{backgroundColor:a,borderRadius:l==="none"?"0":`${fe[l]} ${fe[l]} 0 0`},children:[h("div",{className:"ariaflow-widget-header-content",children:h("div",{className:"ariaflow-widget-title-group",children:[h("h3",{className:"ariaflow-widget-title",children:mt}),h("p",{className:"ariaflow-widget-subtitle",children:vt})]})}),h("button",{className:"ariaflow-widget-close",onClick:()=>b(!1),"aria-label":"Close chat",children:h("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),!N&&h("div",{className:"ariaflow-widget-status",children:[h("span",{className:"ariaflow-widget-status-dot"}),"Connecting..."]}),h("div",{className:"ariaflow-widget-messages",children:p.length===0?h("div",{className:"ariaflow-widget-empty",children:h("p",{children:N?yt:"Connecting to agent..."})}):h(I,{children:[p.map(x=>h("div",{className:`ariaflow-widget-message ariaflow-widget-message-${x.role}`,children:h("div",{className:"ariaflow-widget-message-bubble",children:x.content})},x.id)),h("div",{ref:T})]})}),h("div",{className:"ariaflow-widget-input",children:[h("textarea",{value:$,onInput:x=>W(x.target.value),onKeyDown:gt,placeholder:N?"Type your message...":"Connecting...",rows:1,disabled:!N}),h("button",{className:"ariaflow-widget-send",onClick:Xe,disabled:!$.trim()||!N,style:{backgroundColor:a},"aria-label":"Send message",children:h("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),h("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})]})}rt(Ge,"ariaflow-widget",["widget-id","api-url","agent-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",Qe):Qe());function Qe(){const t=document.querySelectorAll("ariaflow-widget");console.log(`[AriaFlow] Initializing ${t.length} widget(s)`)}F.Widget=Ge,F.WidgetClient=Je,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
1
+ (function(M,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(M=typeof globalThis<"u"?globalThis:M||self,E(M.AriaFlowWidget={}))})(this,function(M){"use strict";var E,m,he,T,ge,pe,me,ve,ne,oe,ie,j={},ye=[],Ze=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,K=Array.isArray;function S(t,e){for(var n in e)t[n]=e[n];return t}function re(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function I(t,e,n){var i,r,o,_={};for(o in e)o=="key"?i=e[o]:o=="ref"?r=e[o]:_[o]=e[o];if(arguments.length>2&&(_.children=arguments.length>3?E.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)_[o]===void 0&&(_[o]=t.defaultProps[o]);return B(t,_,i,r,null)}function B(t,e,n,i,r){var o={type:t,props:e,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++he,__i:-1,__u:0};return r==null&&m.vnode!=null&&m.vnode(o),o}function D(t){return t.children}function J(t,e){this.props=t,this.context=e}function R(t,e){if(e==null)return t.__?R(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"?R(t):null}function we(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 we(t)}}function be(t){(!t.__d&&(t.__d=!0)&&T.push(t)&&!G.__r++||ge!=m.debounceRendering)&&((ge=m.debounceRendering)||pe)(G)}function G(){for(var t,e,n,i,r,o,_,a=1;T.length;)T.length>a&&T.sort(me),t=T.shift(),a=T.length,t.__d&&(n=void 0,i=void 0,r=(i=(e=t).__v).__e,o=[],_=[],e.__P&&((n=S({},i)).__v=i.__v+1,m.vnode&&m.vnode(n),se(e.__P,n,i,e.__n,e.__P.namespaceURI,32&i.__u?[r]:null,o,r??R(i),!!(32&i.__u),_),n.__v=i.__v,n.__.__k[n.__i]=n,We(o,n,_),i.__e=i.__=null,n.__e!=r&&we(n)));G.__r=0}function ke(t,e,n,i,r,o,_,a,c,l,d){var s,f,u,b,C,y,p,g=i&&i.__k||ye,N=e.length;for(c=et(n,e,g,c,N),s=0;s<N;s++)(u=n.__k[s])!=null&&(f=u.__i==-1?j:g[u.__i]||j,u.__i=s,y=se(t,u,f,r,o,_,a,c,l,d),b=u.__e,u.ref&&f.ref!=u.ref&&(f.ref&&le(f.ref,null,u),d.push(u.ref,u.__c||b,u)),C==null&&b!=null&&(C=b),(p=!!(4&u.__u))||f.__k===u.__k?c=Ce(u,c,t,p):typeof u.type=="function"&&y!==void 0?c=y:b&&(c=b.nextSibling),u.__u&=-7);return n.__e=C,c}function et(t,e,n,i,r){var o,_,a,c,l,d=n.length,s=d,f=0;for(t.__k=new Array(r),o=0;o<r;o++)(_=e[o])!=null&&typeof _!="boolean"&&typeof _!="function"?(typeof _=="string"||typeof _=="number"||typeof _=="bigint"||_.constructor==String?_=t.__k[o]=B(null,_,null,null,null):K(_)?_=t.__k[o]=B(D,{children:_},null,null,null):_.constructor===void 0&&_.__b>0?_=t.__k[o]=B(_.type,_.props,_.key,_.ref?_.ref:null,_.__v):t.__k[o]=_,c=o+f,_.__=t,_.__b=t.__b+1,a=null,(l=_.__i=tt(_,n,c,s))!=-1&&(s--,(a=n[l])&&(a.__u|=2)),a==null||a.__v==null?(l==-1&&(r>d?f--:r<d&&f++),typeof _.type!="function"&&(_.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,_.__u|=4))):t.__k[o]=null;if(s)for(o=0;o<d;o++)(a=n[o])!=null&&!(2&a.__u)&&(a.__e==i&&(i=R(a)),Se(a,a));return i}function Ce(t,e,n,i){var r,o;if(typeof t.type=="function"){for(r=t.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=t,e=Ce(r[o],e,n,i));return e}t.__e!=e&&(i&&(e&&t.type&&!e.parentNode&&(e=R(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function tt(t,e,n,i){var r,o,_,a=t.key,c=t.type,l=e[n],d=l!=null&&(2&l.__u)==0;if(l===null&&a==null||d&&a==l.key&&c==l.type)return n;if(i>(d?1:0)){for(r=n-1,o=n+1;r>=0||o<e.length;)if((l=e[_=r>=0?r--:o++])!=null&&!(2&l.__u)&&a==l.key&&c==l.type)return _}return-1}function Ae(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Ze.test(e)?n:n+"px"}function Q(t,e,n,i,r){var o,_;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof i=="string"&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||Ae(t.style,e,"");if(n)for(e in n)i&&n[e]==i[e]||Ae(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(ve,"$1")),_=e.toLowerCase(),e=_ in t||e=="onFocusOut"||e=="onFocusIn"?_.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?i?n.u=i.u:(n.u=ne,t.addEventListener(e,o?ie:oe,o)):t.removeEventListener(e,o?ie:oe,o);else{if(r=="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 $e(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ne++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function se(t,e,n,i,r,o,_,a,c,l){var d,s,f,u,b,C,y,p,g,N,A,H,$,te,k,P,U,W=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),o=[a=e.__e=n.__e]),(d=m.__b)&&d(e);e:if(typeof W=="function")try{if(p=e.props,g="prototype"in W&&W.prototype.render,N=(d=W.contextType)&&i[d.__c],A=d?N?N.props.value:d.__:i,n.__c?y=(s=e.__c=n.__c).__=s.__E:(g?e.__c=s=new W(p,A):(e.__c=s=new J(p,A),s.constructor=W,s.render=ot),N&&N.sub(s),s.state||(s.state={}),s.__n=i,f=s.__d=!0,s.__h=[],s._sb=[]),g&&s.__s==null&&(s.__s=s.state),g&&W.getDerivedStateFromProps!=null&&(s.__s==s.state&&(s.__s=S({},s.__s)),S(s.__s,W.getDerivedStateFromProps(p,s.__s))),u=s.props,b=s.state,s.__v=e,f)g&&W.getDerivedStateFromProps==null&&s.componentWillMount!=null&&s.componentWillMount(),g&&s.componentDidMount!=null&&s.__h.push(s.componentDidMount);else{if(g&&W.getDerivedStateFromProps==null&&p!==u&&s.componentWillReceiveProps!=null&&s.componentWillReceiveProps(p,A),e.__v==n.__v||!s.__e&&s.shouldComponentUpdate!=null&&s.shouldComponentUpdate(p,s.__s,A)===!1){for(e.__v!=n.__v&&(s.props=p,s.state=s.__s,s.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(F){F&&(F.__=e)}),H=0;H<s._sb.length;H++)s.__h.push(s._sb[H]);s._sb=[],s.__h.length&&_.push(s);break e}s.componentWillUpdate!=null&&s.componentWillUpdate(p,s.__s,A),g&&s.componentDidUpdate!=null&&s.__h.push(function(){s.componentDidUpdate(u,b,C)})}if(s.context=A,s.props=p,s.__P=t,s.__e=!1,$=m.__r,te=0,g){for(s.state=s.__s,s.__d=!1,$&&$(e),d=s.render(s.props,s.state,s.context),k=0;k<s._sb.length;k++)s.__h.push(s._sb[k]);s._sb=[]}else do s.__d=!1,$&&$(e),d=s.render(s.props,s.state,s.context),s.state=s.__s;while(s.__d&&++te<25);s.state=s.__s,s.getChildContext!=null&&(i=S(S({},i),s.getChildContext())),g&&!f&&s.getSnapshotBeforeUpdate!=null&&(C=s.getSnapshotBeforeUpdate(u,b)),P=d,d!=null&&d.type===D&&d.key==null&&(P=xe(d.props.children)),a=ke(t,K(P)?P:[P],e,n,i,r,o,_,a,c,l),s.base=e.__e,e.__u&=-161,s.__h.length&&_.push(s),y&&(s.__E=s.__=null)}catch(F){if(e.__v=null,c||o!=null)if(F.then){for(e.__u|=c?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,e.__e=a}else{for(U=o.length;U--;)re(o[U]);_e(e)}else e.__e=n.__e,e.__k=n.__k,F.then||_e(e);m.__e(F,e,n)}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):a=e.__e=nt(n.__e,e,n,i,r,o,_,c,l);return(d=m.diffed)&&d(e),128&e.__u?void 0:a}function _e(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(_e)}function We(t,e,n){for(var i=0;i<n.length;i++)le(n[i],n[++i],n[++i]);m.__c&&m.__c(e,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(o){o.call(r)})}catch(o){m.__e(o,r.__v)}})}function xe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:K(t)?t.map(xe):S({},t)}function nt(t,e,n,i,r,o,_,a,c){var l,d,s,f,u,b,C,y=n.props||j,p=e.props,g=e.type;if(g=="svg"?r="http://www.w3.org/2000/svg":g=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),o!=null){for(l=0;l<o.length;l++)if((u=o[l])&&"setAttribute"in u==!!g&&(g?u.localName==g:u.nodeType==3)){t=u,o[l]=null;break}}if(t==null){if(g==null)return document.createTextNode(p);t=document.createElementNS(r,g,p.is&&p),a&&(m.__m&&m.__m(e,o),a=!1),o=null}if(g==null)y===p||a&&t.data==p||(t.data=p);else{if(o=o&&E.call(t.childNodes),!a&&o!=null)for(y={},l=0;l<t.attributes.length;l++)y[(u=t.attributes[l]).name]=u.value;for(l in y)if(u=y[l],l!="children"){if(l=="dangerouslySetInnerHTML")s=u;else if(!(l in p)){if(l=="value"&&"defaultValue"in p||l=="checked"&&"defaultChecked"in p)continue;Q(t,l,null,u,r)}}for(l in p)u=p[l],l=="children"?f=u:l=="dangerouslySetInnerHTML"?d=u:l=="value"?b=u:l=="checked"?C=u:a&&typeof u!="function"||y[l]===u||Q(t,l,u,y[l],r);if(d)a||s&&(d.__html==s.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(s&&(t.innerHTML=""),ke(e.type=="template"?t.content:t,K(f)?f:[f],e,n,i,g=="foreignObject"?"http://www.w3.org/1999/xhtml":r,o,_,o?o[0]:n.__k&&R(n,0),a,c),o!=null)for(l=o.length;l--;)re(o[l]);a||(l="value",g=="progress"&&b==null?t.removeAttribute("value"):b!=null&&(b!==t[l]||g=="progress"&&!b||g=="option"&&b!=y[l])&&Q(t,l,b,y[l],r),l="checked",C!=null&&C!=t[l]&&Q(t,l,C,y[l],r))}return t}function le(t,e,n){try{if(typeof t=="function"){var i=typeof t.__u=="function";i&&t.__u(),i&&e==null||(t.__u=t(e))}else t.current=e}catch(r){m.__e(r,n)}}function Se(t,e,n){var i,r;if(m.unmount&&m.unmount(t),(i=t.ref)&&(i.current&&i.current!=t.__e||le(i,null,e)),(i=t.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(o){m.__e(o,e)}i.base=i.__P=null}if(i=t.__k)for(r=0;r<i.length;r++)i[r]&&Se(i[r],e,n||typeof t.type!="function");n||re(t.__e),t.__c=t.__=t.__e=void 0}function ot(t,e,n){return this.constructor(t,n)}function X(t,e,n){var i,r,o,_;e==document&&(e=document.documentElement),m.__&&m.__(t,e),r=(i=typeof n=="function")?null:n&&n.__k||e.__k,o=[],_=[],se(e,t=(!i&&n||e).__k=I(D,null,[t]),r||j,j,e.namespaceURI,!i&&n?[n]:r?null:e.firstChild?E.call(e.childNodes):null,o,!i&&n?n:r?r.__e:e.firstChild,i,_),We(o,t,_)}function Ne(t,e){X(t,e,Ne)}function Fe(t,e,n){var i,r,o,_,a=S({},t.props);for(o in t.type&&t.type.defaultProps&&(_=t.type.defaultProps),e)o=="key"?i=e[o]:o=="ref"?r=e[o]:a[o]=e[o]===void 0&&_!=null?_[o]:e[o];return arguments.length>2&&(a.children=arguments.length>3?E.call(arguments,2):n),B(t.type,a,i||t.key,r||t.ref,null)}E=ye.slice,m={__e:function(t,e,n,i){for(var r,o,_;e=e.__;)if((r=e.__c)&&!r.__)try{if((o=r.constructor)&&o.getDerivedStateFromError!=null&&(r.setState(o.getDerivedStateFromError(t)),_=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,i||{}),_=r.__d),_)return r.__E=r}catch(a){t=a}throw t}},he=0,J.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=S({},this.state),typeof t=="function"&&(t=t(S({},n),this.props)),t&&S(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),be(this))},J.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),be(this))},J.prototype.render=D,T=[],pe=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,me=function(t,e){return t.__v.__b-e.__v.__b},G.__r=0,ve=/(PointerCapture)$|Capture$/i,ne=0,oe=$e(!1),ie=$e(!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 i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Y.apply(this,arguments)}function Ee(t,e){if(t==null)return{};var n,i,r={},o=Object.keys(t);for(i=0;i<o.length;i++)e.indexOf(n=o[i])>=0||(r[n]=t[n]);return r}var it=["context","children"],rt=["useFragment"];function st(t,e,n,i){function r(){var o=Reflect.construct(HTMLElement,[],r);return o._vdomComponent=t,o._root=o,o}return(r.prototype=Object.create(HTMLElement.prototype)).constructor=r,r.prototype.connectedCallback=function(){lt.call(this,i)},r.prototype.attributeChangedCallback=at,r.prototype.disconnectedCallback=ct,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),r.observedAttributes=n,t.formAssociated&&(r.formAssociated=!0),n.forEach(function(o){Object.defineProperty(r.prototype,o,{get:function(){return this._vdom?this._vdom.props[o]:this._props[o]},set:function(_){this._vdom?this.attributeChangedCallback(o,null,_):(this._props||(this._props={}),this._props[o]=_);var a=typeof _;_!=null&&a!=="string"&&a!=="boolean"&&a!=="number"||this.setAttribute(o,_)}})}),customElements.define(e,r),r}function _t(t){this.getChildContext=function(){return t.context};var e=t.children,n=Ee(t,it);return Fe(e,n)}function lt(t){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=I(_t,Y({},this._props,{context:e.detail.context}),He(this,this._vdomComponent,t)),(this.hasAttribute("hydrate")?Ne:X)(this._vdom,this._root)}function Me(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function at(t,e,n){if(this._vdom){var i={};i[t]=n=n??void 0,i[Me(t)]=n,this._vdom=Fe(this._vdom,i),X(this._vdom,this._root)}}function ct(){X(this._vdom=null,this._root)}function Te(t,e){var n=this,i=t.useFragment,r=Ee(t,rt);return I(i?D:"slot",Y({},r,{ref:function(o){o?(n.ref=o,n._listener||(n._listener=function(_){_.stopPropagation(),_.detail.context=e},o.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function He(t,e,n){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var i=[],r={},o=0,_=t.attributes,a=t.childNodes;for(o=_.length;o--;)_[o].name!=="slot"&&(r[_[o].name]=_[o].value,r[Me(_[o].name)]=_[o].value);for(o=a.length;o--;){var c=He(a[o],null,n),l=a[o].slot;l?r[l]=I(Te,{name:l},c):i[o]=c}var d=!(!n||!n.shadow),s=e?I(Te,{useFragment:!d},i):i;return!d&&e&&(t.innerHTML=""),I(e||t.nodeName.toLowerCase(),r,s)}var ut=0;function h(t,e,n,i,r,o){e||(e={});var _,a,c=e;if("ref"in c)for(a in c={},e)a=="ref"?_=e[a]:c[a]=e[a];var l={type:t,props:c,key:n,ref:_,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ut,__i:-1,__u:0,__source:r,__self:o};if(typeof t=="function"&&(_=t.defaultProps))for(a in _)c[a]===void 0&&(c[a]=_[a]);return m.vnode&&m.vnode(l),l}var z,v,ae,Pe,Z=0,Ue=[],w=m,Ie=w.__b,De=w.__r,Re=w.diffed,Le=w.__c,Oe=w.unmount,je=w.__;function ce(t,e){w.__h&&w.__h(v,t,Z||e),Z=0;var n=v.__H||(v.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function L(t){return Z=1,dt(Ke,t)}function dt(t,e,n){var i=ce(z++,2);if(i.t=t,!i.__c&&(i.__=[Ke(void 0,e),function(a){var c=i.__N?i.__N[0]:i.__[0],l=i.t(c,a);c!==l&&(i.__N=[l,i.__[1]],i.__c.setState({}))}],i.__c=v,!v.__f)){var r=function(a,c,l){if(!i.__c.__H)return!0;var d=i.__c.__H.__.filter(function(f){return!!f.__c});if(d.every(function(f){return!f.__N}))return!o||o.call(this,a,c,l);var s=i.__c.props!==a;return d.forEach(function(f){if(f.__N){var u=f.__[0];f.__=f.__N,f.__N=void 0,u!==f.__[0]&&(s=!0)}}),o&&o.call(this,a,c,l)||s};v.__f=!0;var o=v.shouldComponentUpdate,_=v.componentWillUpdate;v.componentWillUpdate=function(a,c,l){if(this.__e){var d=o;o=void 0,r(a,c,l),o=d}_&&_.call(this,a,c,l)},v.shouldComponentUpdate=r}return i.__N||i.__}function Be(t,e){var n=ce(z++,3);!w.__s&&qe(n.__H,e)&&(n.__=t,n.u=e,v.__H.__h.push(n))}function ze(t){return Z=5,ft(function(){return{current:t}},[])}function ft(t,e){var n=ce(z++,7);return qe(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function ht(){for(var t;t=Ue.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ee),t.__H.__h.forEach(ue),t.__H.__h=[]}catch(e){t.__H.__h=[],w.__e(e,t.__v)}}w.__b=function(t){v=null,Ie&&Ie(t)},w.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),je&&je(t,e)},w.__r=function(t){De&&De(t),z=0;var e=(v=t.__c).__H;e&&(ae===v?(e.__h=[],v.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ee),e.__h.forEach(ue),e.__h=[],z=0)),ae=v},w.diffed=function(t){Re&&Re(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Ue.push(e)!==1&&Pe===w.requestAnimationFrame||((Pe=w.requestAnimationFrame)||gt)(ht)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ae=v=null},w.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ee),n.__h=n.__h.filter(function(i){return!i.__||ue(i)})}catch(i){e.some(function(r){r.__h&&(r.__h=[])}),e=[],w.__e(i,n.__v)}}),Le&&Le(t,e)},w.unmount=function(t){Oe&&Oe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(i){try{ee(i)}catch(r){e=r}}),n.__H=void 0,e&&w.__e(e,n.__v))};var Ve=typeof requestAnimationFrame=="function";function gt(t){var e,n=function(){clearTimeout(i),Ve&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,35);Ve&&(e=requestAnimationFrame(n))}function ee(t){var e=v,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),v=e}function ue(t){var e=v;t.__c=t.__(),v=e}function qe(t,e){return!t||t.length!==e.length||e.some(function(n,i){return n!==t[i]})}function Ke(t,e){return typeof e=="function"?e(t):e}const pt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let de=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=pt[n[t]&63];return e};class Je{constructor(e,n){this.agentUrl=e,this.agentId=n,this.agentConfig=null,this.ws=null,this.messageCallbacks=new Set,this.connectionCallbacks=new Set,this.messages=[],this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3}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 i=await n.json();return console.log("[AriaFlow Widget] Agent config received:",i),!i||i.status!=="active"?(console.error("Agent not found or inactive"),null):(this.agentConfig=i,this.maxReconnectAttempts=i.config.maxRetries||5,this.reconnectDelay=i.config.reconnectDelay||1e3,await this.connectToAgent(),i)}}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((i,r)=>{try{this.ws=new WebSocket(n),this.ws.onopen=()=>{console.log("[Widget] Connected to agent"),this.reconnectAttempts=0,this.notifyConnectionChange(!0),i()},this.ws.onmessage=o=>{this.handleMessage(o)},this.ws.onclose=()=>{if(console.log("[Widget] Disconnected from agent"),this.notifyConnectionChange(!1),this.reconnectAttempts<this.maxReconnectAttempts){this.reconnectAttempts++;const o=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.log(`[Widget] Reconnecting in ${o}ms... (attempt ${this.reconnectAttempts})`),setTimeout(()=>this.connectToAgent(),o)}},this.ws.onerror=o=>{console.error("[Widget] WebSocket error:",o),r(o)}}catch(o){r(o)}})}handleMessage(e){try{const n=JSON.parse(e.data);n.type==="text-delta"?this.setMessages(i=>{const r=i[i.length-1];return r&&r.role==="assistant"?[...i.slice(0,-1),{...r,content:r.content+n.text}]:[...i,{id:de(),role:"assistant",content:n.text,timestamp:Date.now()}]}):n.type==="done"?console.log("[Widget] Response complete"):n.type==="handoff"?console.log(`[Widget] Handoff: ${n.from} -> ${n.to}: ${n.reason}`):n.type==="tool-call"?console.log("[Widget] Tool call:",n.tool):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:de(),role:"user",content:e,timestamp:Date.now()};this.setMessages(r=>[...r,n]);const i=this.getSessionId();this.ws.send(JSON.stringify({message:e,sessionId:i}))}getSessionId(){let e=sessionStorage.getItem("ariaflow_session_id");return e||(e=de(),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)}}notifyConnectionChange(e){this.connectionCallbacks.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 Ge({agentUrl:t,agentId:e,widgetId:n,apiUrl:i,mode:r="chat",theme:o="light",position:_="bottom-right",size:a="full",radius:c="medium",baseColor:l,accentColor:d="#14B8A6",buttonBaseColor:s="#000000",buttonAccentColor:f="#FFFFFF",title:u,subtitle:b,emptyChatMessage:C}){const[y,p]=L(!1),[g,N]=L([]),[A,H]=L(""),[$,te]=L(!1),[k,P]=L(!1),[U,W]=L(null),F=ze(null),Xe=ze(null);Be(()=>((async()=>{if(t&&e){console.log("[AriaFlow Widget] Using new agent resolution:",{agentUrl:t,agentId:e});const O=new Je(t,e);F.current=O;try{const V=await O.initWidget();console.log("[AriaFlow Widget] Agent config received:",V),V?(W(V),P(!0),console.log("[AriaFlow Widget] Widget initialized successfully"),O.onMessages(q=>{console.log("[AriaFlow Widget] Messages updated:",q.length),N(q)}),O.onConnectionChange(q=>{console.log("[AriaFlow Widget] Connection state:",q),te(q)})):console.error("[AriaFlow Widget] Agent config fetch failed")}catch(V){console.error("[AriaFlow Widget] Initialization error:",V)}}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")):i&&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.")})(),()=>{F.current?.dispose()}),[t,e,n,i]),Be(()=>{Xe.current?.scrollIntoView({behavior:"smooth"})},[g]);const Ye=async()=>{if(!A.trim()||!$)return;const x=A.trim();H("");try{await F.current?.sendMessage(x)}catch(O){console.error("Failed to send message:",O)}},mt=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),Ye())},vt=u||U?.title||"Chat with us",yt=b||U?.subtitle||"We typically reply within minutes",wt=C||U?.config?.emptyChatMessage||"Start a conversation...";return console.log("[AriaFlow Widget] Rendering widget component",{isInitialized:k,isOpen:y,position:_}),h("div",{className:`ariaflow-widget-container ariaflow-widget-${_} ariaflow-widget-${a} ariaflow-widget-radius-${c}`,"data-theme":o,style:{"--ariaflow-accent-color":d,"--ariaflow-base-color":l},children:[!y&&h("button",{className:"ariaflow-widget-launcher",onClick:()=>p(!0),style:{backgroundColor:s,color:f,opacity:k?1:.8,cursor:k?"pointer":"wait",position:"relative"},"aria-label":k?"Open chat":"Connecting to agent...",disabled:!k,title:k?"Click to start chat":"Connecting to agent...",children:[!k&&h("div",{className:"ariaflow-widget-launcher-loading",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"20px",height:"20px",border:`2px solid ${f}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),k&&h("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})]}),y&&k&&h("div",{className:"ariaflow-widget-window",style:{backgroundColor:o==="dark"&&l?l:void 0,borderRadius:fe[c]},children:[h("div",{className:"ariaflow-widget-header",style:{backgroundColor:d,borderRadius:c==="none"?"0":`${fe[c]} ${fe[c]} 0 0`},children:[h("div",{className:"ariaflow-widget-header-content",children:h("div",{className:"ariaflow-widget-title-group",children:[h("h3",{className:"ariaflow-widget-title",children:vt}),h("p",{className:"ariaflow-widget-subtitle",children:yt})]})}),h("button",{className:"ariaflow-widget-close",onClick:()=>p(!1),"aria-label":"Close chat",children:h("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),!$&&h("div",{className:"ariaflow-widget-status",children:[h("span",{className:"ariaflow-widget-status-dot"}),"Connecting..."]}),h("div",{className:"ariaflow-widget-messages",children:g.length===0?h("div",{className:"ariaflow-widget-empty",children:h("p",{children:$?wt:"Connecting to agent..."})}):h(D,{children:[g.map(x=>h("div",{className:`ariaflow-widget-message ariaflow-widget-message-${x.role}`,children:h("div",{className:"ariaflow-widget-message-bubble",children:x.content})},x.id)),h("div",{ref:Xe})]})}),h("div",{className:"ariaflow-widget-input",children:[h("textarea",{value:A,onInput:x=>H(x.target.value),onKeyDown:mt,placeholder:$?"Type your message...":"Connecting...",rows:1,disabled:!$}),h("button",{className:"ariaflow-widget-send",onClick:Ye,disabled:!A.trim()||!$,style:{backgroundColor:d},"aria-label":"Send message",children:h("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),h("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})]})}st(Ge,"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",Qe):Qe());function Qe(){const t=document.querySelectorAll("ariaflow-widget");console.log(`[AriaFlow] Initializing ${t.length} widget(s)`)}M.Widget=Ge,M.WidgetClient=Je,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariaflowagents/widget",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "type": "module",
5
5
  "description": "Embeddable chat widget for AriaFlow Universal Inbox",
6
6
  "main": "./dist/widget.js",