@ariaflowagents/widget 0.6.1 → 0.6.3

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/style.css CHANGED
@@ -1 +1 @@
1
- .ariaflow-widget-container{position:fixed;z-index:9999;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,sans-serif;--ariaflow-accent-color: #14B8A6;--ariaflow-base-color: #ffffff;--ariaflow-window-bg: #ffffff;--ariaflow-messages-bg: #f8fafc;--ariaflow-text-primary: #1e293b;--ariaflow-text-secondary: #64748b;--ariaflow-border-color: #e2e8f0;--ariaflow-input-bg: #ffffff;--ariaflow-assistant-bubble-bg: #ffffff;--ariaflow-assistant-bubble-text: #1e293b;--ariaflow-input-focus-border: var(--ariaflow-accent-color)}@keyframes spin{0%{transform:translate(-50%,-50%) rotate(0)}to{transform:translate(-50%,-50%) rotate(360deg)}}.ariaflow-widget-bottom-right{bottom:20px;right:20px}.ariaflow-widget-bottom-left{bottom:20px;left:20px}.ariaflow-widget-top-right{top:20px;right:20px}.ariaflow-widget-top-left{top:20px;left:20px}.ariaflow-widget-launcher{width:60px;height:60px;border-radius:30px;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;color:#fff;box-shadow:0 4px 12px #00000026;transition:transform .2s,box-shadow .2s}.ariaflow-widget-launcher:hover{transform:scale(1.05);box-shadow:0 6px 16px #0003}.ariaflow-widget-window{max-height:calc(100vh - 40px);background:#fff;border-radius:16px;box-shadow:0 8px 32px #00000026;display:flex;flex-direction:column;overflow:hidden;animation:ariaflow-slide-up .3s ease-out}.ariaflow-widget-tiny .ariaflow-widget-window{width:320px;height:400px}.ariaflow-widget-compact .ariaflow-widget-window{width:360px;height:500px}.ariaflow-widget-full .ariaflow-widget-window{width:380px;height:600px}@keyframes ariaflow-slide-up{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.ariaflow-widget-header{padding:16px 20px;color:#fff;display:flex;align-items:center;justify-content:space-between}.ariaflow-widget-header-content{display:flex;align-items:center;gap:12px}.ariaflow-widget-avatar{width:40px;height:40px;border-radius:20px;object-fit:cover}.ariaflow-widget-title-group{display:flex;flex-direction:column;gap:2px}.ariaflow-widget-title{margin:0;font-size:16px;font-weight:600}.ariaflow-widget-subtitle{margin:0;font-size:13px;opacity:.9}.ariaflow-widget-close{background:#fff3;border:none;border-radius:20px;width:32px;height:32px;display:flex;align-items:center;justify-content:center;color:#fff;cursor:pointer;transition:background .2s}.ariaflow-widget-close:hover{background:#ffffff4d}.ariaflow-widget-status{padding:8px 16px;display:flex;align-items:center;gap:8px;font-size:13px;color:#64748b;background:#f1f5f9}.ariaflow-widget-status-dot{width:8px;height:8px;border-radius:50%;background:#fbbf24;animation:ariaflow-pulse 1.5s infinite}@keyframes ariaflow-pulse{0%,to{opacity:1}50%{opacity:.5}}.ariaflow-widget-messages{flex:1;padding:16px;overflow-y:auto;display:flex;flex-direction:column;gap:12px;background:#f8fafc}.ariaflow-widget-empty{display:flex;align-items:center;justify-content:center;height:100%;color:#64748b;font-size:14px}.ariaflow-widget-message{display:flex}.ariaflow-widget-message-user{justify-content:flex-end}.ariaflow-widget-message-assistant{justify-content:flex-start}.ariaflow-widget-message-bubble{max-width:80%;padding:12px 16px;border-radius:16px;font-size:14px;line-height:1.5;word-wrap:break-word;white-space:pre-wrap}.ariaflow-widget-message-user .ariaflow-widget-message-bubble{background:var(--ariaflow-accent-color, #14B8A6);color:#fff;border-bottom-right-radius:4px}.ariaflow-widget-message-assistant .ariaflow-widget-message-bubble{background:var(--ariaflow-assistant-bubble-bg, #ffffff);color:var(--ariaflow-assistant-bubble-text, #1e293b);border:1px solid var(--ariaflow-border-color, #e2e8f0);border-bottom-left-radius:4px}.ariaflow-widget-message-tool{justify-content:flex-start}.ariaflow-widget-message-tool .ariaflow-widget-message-bubble{background:var(--ariaflow-tool-bubble-bg, #f1f5f9);color:var(--ariaflow-tool-bubble-text, #334155);border:1px solid var(--ariaflow-tool-border, #cbd5e1);font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:13px;max-width:90%}.ariaflow-widget-chips-container{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.ariaflow-widget-chip{background:#fff;border:1px solid var(--ariaflow-accent-color);color:var(--ariaflow-accent-color);padding:8px 16px;border-radius:20px;font-size:13px;font-weight:500;cursor:pointer;transition:all .2s cubic-bezier(.4,0,.2,1);white-space:nowrap;box-shadow:0 2px 4px #0000000d;animation:ariaflow-chip-entrance .4s ease-out backwards}.ariaflow-widget-chip:hover{background:var(--ariaflow-accent-color);color:#fff;transform:translateY(-2px);box-shadow:0 4px 8px #0000001a}.ariaflow-widget-chip:active{transform:translateY(0)}@keyframes ariaflow-chip-entrance{0%{opacity:0;transform:translateY(10px) scale(.95);filter:blur(4px)}to{opacity:1;transform:translateY(0) scale(1);filter:blur(0)}}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-chip{background:var(--ariaflow-messages-bg)}.ariaflow-widget-tool-message{display:flex;flex-direction:column;gap:8px}.ariaflow-widget-tool-header{font-weight:600;color:#059669;font-size:12px;text-transform:uppercase;letter-spacing:.5px}.ariaflow-widget-tool-args,.ariaflow-widget-tool-result{margin-top:4px}.ariaflow-widget-tool-args strong,.ariaflow-widget-tool-result strong{color:#475569;font-weight:600}.ariaflow-widget-typing-indicator{display:inline-flex;gap:2px;margin-left:8px;align-items:center}.ariaflow-widget-typing-indicator span{animation:typing 1.4s infinite ease-in-out}.ariaflow-widget-typing-indicator span:nth-child(1){animation-delay:0s}.ariaflow-widget-typing-indicator span:nth-child(2){animation-delay:.2s}.ariaflow-widget-typing-indicator span:nth-child(3){animation-delay:.4s}@keyframes typing{0%,60%,to{opacity:.3;transform:translateY(0)}30%{opacity:1;transform:translateY(-2px)}}.ariaflow-widget-input{padding:12px 16px;background:#fff;border-top:1px solid #e2e8f0;display:flex;gap:8px;align-items:flex-end}.ariaflow-widget-input textarea{flex:1;border:1px solid #e2e8f0;border-radius:20px;padding:10px 14px;font-size:14px;font-family:inherit;resize:none;max-height:100px;outline:none;transition:border-color .2s}.ariaflow-widget-input textarea:focus{border-color:var(--ariaflow-input-focus-border, #2563eb)}.ariaflow-widget-input textarea::placeholder{color:#94a3b8}.ariaflow-widget-send{width:40px;height:40px;border-radius:20px;border:none;color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:opacity .2s,transform .2s;flex-shrink:0}.ariaflow-widget-send:hover:not(:disabled){transform:scale(1.05)}.ariaflow-widget-send:disabled{opacity:.5;cursor:not-allowed}.ariaflow-widget-container[data-theme=dark]{--ariaflow-window-bg: var(--ariaflow-base-color, #1e293b);--ariaflow-messages-bg: #0f172a;--ariaflow-text-primary: #f1f5f9;--ariaflow-text-secondary: #94a3b8;--ariaflow-border-color: #334155;--ariaflow-input-bg: #1e293b;--ariaflow-assistant-bubble-bg: #334155;--ariaflow-assistant-bubble-text: #f1f5f9;--ariaflow-input-focus-border: #3b82f6}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-window{background:var(--ariaflow-window-bg)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-messages{background:var(--ariaflow-messages-bg)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-message-assistant .ariaflow-widget-message-bubble{background:var(--ariaflow-assistant-bubble-bg);color:var(--ariaflow-assistant-bubble-text);border-color:var(--ariaflow-border-color)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-input{background:var(--ariaflow-input-bg);border-top-color:var(--ariaflow-border-color)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-input textarea{background:var(--ariaflow-messages-bg);border-color:var(--ariaflow-border-color);color:var(--ariaflow-text-primary)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-input textarea:focus{border-color:var(--ariaflow-input-focus-border)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-input textarea::placeholder{color:var(--ariaflow-text-secondary)}.ariaflow-widget-messages::-webkit-scrollbar{width:6px}.ariaflow-widget-messages::-webkit-scrollbar-track{background:transparent}.ariaflow-widget-messages::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:3px}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-messages::-webkit-scrollbar-thumb{background:#475569}.ariaflow-widget-messages::-webkit-scrollbar-thumb:hover{background:#94a3b8}
1
+ .ariaflow-widget-container{position:fixed;z-index:9999;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,sans-serif;--ariaflow-accent-color: #14B8A6;--ariaflow-base-color: #ffffff;--ariaflow-window-bg: #ffffff;--ariaflow-messages-bg: #f8fafc;--ariaflow-text-primary: #1e293b;--ariaflow-text-secondary: #64748b;--ariaflow-border-color: #e2e8f0;--ariaflow-input-bg: #ffffff;--ariaflow-assistant-bubble-bg: #ffffff;--ariaflow-assistant-bubble-text: #1e293b;--ariaflow-input-focus-border: var(--ariaflow-accent-color)}@keyframes spin{0%{transform:translate(-50%,-50%) rotate(0)}to{transform:translate(-50%,-50%) rotate(360deg)}}.ariaflow-widget-bottom-right{bottom:20px;right:20px}.ariaflow-widget-bottom-left{bottom:20px;left:20px}.ariaflow-widget-top-right{top:20px;right:20px}.ariaflow-widget-top-left{top:20px;left:20px}.ariaflow-widget-launcher{width:60px;height:60px;border-radius:30px;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;color:#fff;box-shadow:0 4px 12px #00000026;transition:transform .2s,box-shadow .2s}.ariaflow-widget-launcher:hover{transform:scale(1.05);box-shadow:0 6px 16px #0003}.ariaflow-widget-window{max-height:calc(100vh - 40px);background:#fff;border-radius:16px;box-shadow:0 8px 32px #00000026;display:flex;flex-direction:column;overflow:hidden;animation:ariaflow-slide-up .3s ease-out}.ariaflow-widget-tiny .ariaflow-widget-window{width:320px;height:400px}.ariaflow-widget-compact .ariaflow-widget-window{width:360px;height:500px}.ariaflow-widget-full .ariaflow-widget-window{width:380px;height:600px}@keyframes ariaflow-slide-up{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.ariaflow-widget-header{padding:16px 20px;color:#fff;display:flex;align-items:center;justify-content:space-between}.ariaflow-widget-header-content{display:flex;align-items:center;gap:12px}.ariaflow-widget-avatar{width:40px;height:40px;border-radius:20px;object-fit:cover}.ariaflow-widget-title-group{display:flex;flex-direction:column;gap:2px}.ariaflow-widget-title{margin:0;font-size:16px;font-weight:600}.ariaflow-widget-subtitle{margin:0;font-size:13px;opacity:.9}.ariaflow-widget-close{background:#fff3;border:none;border-radius:20px;width:32px;height:32px;display:flex;align-items:center;justify-content:center;color:#fff;cursor:pointer;transition:background .2s}.ariaflow-widget-close:hover{background:#ffffff4d}.ariaflow-widget-status{padding:8px 16px;display:flex;align-items:center;gap:8px;font-size:13px;color:#64748b;background:#f1f5f9}.ariaflow-widget-status-dot{width:8px;height:8px;border-radius:50%;background:#fbbf24;animation:ariaflow-pulse 1.5s infinite}@keyframes ariaflow-pulse{0%,to{opacity:1}50%{opacity:.5}}.ariaflow-widget-messages{flex:1;padding:16px;overflow-y:auto;display:flex;flex-direction:column;gap:12px;background:#f8fafc}.ariaflow-widget-empty{display:flex;align-items:center;justify-content:center;height:100%;color:#64748b;font-size:14px}.ariaflow-widget-message{display:flex}.ariaflow-widget-message-user{justify-content:flex-end}.ariaflow-widget-message-assistant{justify-content:flex-start}.ariaflow-widget-message-bubble{max-width:80%;padding:12px 16px;border-radius:16px;font-size:14px;line-height:1.5;word-wrap:break-word;white-space:pre-wrap}.ariaflow-widget-message-user .ariaflow-widget-message-bubble{background:var(--ariaflow-accent-color, #14B8A6);color:#fff;border-bottom-right-radius:4px}.ariaflow-widget-message-assistant .ariaflow-widget-message-bubble{background:var(--ariaflow-assistant-bubble-bg, #ffffff);color:var(--ariaflow-assistant-bubble-text, #1e293b);border:1px solid var(--ariaflow-border-color, #e2e8f0);border-bottom-left-radius:4px}.ariaflow-widget-message-tool{justify-content:flex-start}.ariaflow-widget-message-tool .ariaflow-widget-message-bubble{background:var(--ariaflow-tool-bubble-bg, #f1f5f9);color:var(--ariaflow-tool-bubble-text, #334155);border:1px solid var(--ariaflow-tool-border, #cbd5e1);font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:13px;max-width:90%}.ariaflow-widget-suggestions{display:flex;gap:8px;padding:12px 16px;overflow-x:auto;white-space:nowrap;background:linear-gradient(to top,#fff,#fff0);border-top:1px solid transparent;width:100%;box-sizing:border-box;-webkit-overflow-scrolling:touch;scrollbar-width:none;-ms-overflow-style:none}.ariaflow-widget-suggestions::-webkit-scrollbar{display:none}.ariaflow-widget-chips-container{display:none}.ariaflow-widget-chip{background:#fff;border:1px solid var(--ariaflow-accent-color);color:var(--ariaflow-accent-color);padding:8px 16px;border-radius:20px;font-size:13px;font-weight:500;cursor:pointer;transition:all .2s cubic-bezier(.4,0,.2,1);white-space:nowrap;box-shadow:0 2px 4px #0000000d;animation:ariaflow-chip-entrance .4s ease-out backwards}.ariaflow-widget-chip:hover{background:var(--ariaflow-accent-color);color:#fff;transform:translateY(-2px);box-shadow:0 4px 8px #0000001a}.ariaflow-widget-chip:active{transform:translateY(0)}@keyframes ariaflow-chip-entrance{0%{opacity:0;transform:translateY(10px) scale(.95);filter:blur(4px)}to{opacity:1;transform:translateY(0) scale(1);filter:blur(0)}}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-chip{background:var(--ariaflow-messages-bg)}.ariaflow-widget-tool-message{display:flex;flex-direction:column;gap:8px}.ariaflow-widget-tool-header{font-weight:600;color:#059669;font-size:12px;text-transform:uppercase;letter-spacing:.5px}.ariaflow-widget-tool-args,.ariaflow-widget-tool-result{margin-top:4px}.ariaflow-widget-tool-args strong,.ariaflow-widget-tool-result strong{color:#475569;font-weight:600}.ariaflow-widget-typing-indicator{display:inline-flex;gap:2px;margin-left:8px;align-items:center}.ariaflow-widget-typing-indicator span{animation:typing 1.4s infinite ease-in-out}.ariaflow-widget-typing-indicator span:nth-child(1){animation-delay:0s}.ariaflow-widget-typing-indicator span:nth-child(2){animation-delay:.2s}.ariaflow-widget-typing-indicator span:nth-child(3){animation-delay:.4s}@keyframes typing{0%,60%,to{opacity:.3;transform:translateY(0)}30%{opacity:1;transform:translateY(-2px)}}.ariaflow-widget-input{padding:12px 16px;background:#fff;border-top:1px solid #e2e8f0;display:flex;gap:8px;align-items:flex-end}.ariaflow-widget-input textarea{flex:1;border:1px solid #e2e8f0;border-radius:20px;padding:10px 14px;font-size:14px;font-family:inherit;resize:none;max-height:100px;outline:none;transition:border-color .2s}.ariaflow-widget-input textarea:focus{border-color:var(--ariaflow-input-focus-border, #2563eb)}.ariaflow-widget-input textarea::placeholder{color:#94a3b8}.ariaflow-widget-send{width:40px;height:40px;border-radius:20px;border:none;color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:opacity .2s,transform .2s;flex-shrink:0}.ariaflow-widget-send:hover:not(:disabled){transform:scale(1.05)}.ariaflow-widget-send:disabled{opacity:.5;cursor:not-allowed}.ariaflow-widget-container[data-theme=dark]{--ariaflow-window-bg: var(--ariaflow-base-color, #1e293b);--ariaflow-messages-bg: #0f172a;--ariaflow-text-primary: #f1f5f9;--ariaflow-text-secondary: #94a3b8;--ariaflow-border-color: #334155;--ariaflow-input-bg: #1e293b;--ariaflow-assistant-bubble-bg: #334155;--ariaflow-assistant-bubble-text: #f1f5f9;--ariaflow-input-focus-border: #3b82f6}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-window{background:var(--ariaflow-window-bg)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-messages{background:var(--ariaflow-messages-bg)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-message-assistant .ariaflow-widget-message-bubble{background:var(--ariaflow-assistant-bubble-bg);color:var(--ariaflow-assistant-bubble-text);border-color:var(--ariaflow-border-color)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-input{background:var(--ariaflow-input-bg);border-top-color:var(--ariaflow-border-color)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-input textarea{background:var(--ariaflow-messages-bg);border-color:var(--ariaflow-border-color);color:var(--ariaflow-text-primary)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-input textarea:focus{border-color:var(--ariaflow-input-focus-border)}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-input textarea::placeholder{color:var(--ariaflow-text-secondary)}.ariaflow-widget-messages::-webkit-scrollbar{width:6px}.ariaflow-widget-messages::-webkit-scrollbar-track{background:transparent}.ariaflow-widget-messages::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:3px}.ariaflow-widget-container[data-theme=dark] .ariaflow-widget-messages::-webkit-scrollbar-thumb{background:#475569}.ariaflow-widget-messages::-webkit-scrollbar-thumb:hover{background:#94a3b8}
package/dist/widget.js CHANGED
@@ -1,19 +1,19 @@
1
- var B, m, He, R, ye, Pe, Ie, Re, ue, le, ae, q = {}, Ue = [], rt = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, te = Array.isArray;
1
+ var B, m, Te, R, me, He, Pe, Ie, ce, re, le, q = {}, Re = [], st = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, te = Array.isArray;
2
2
  function E(t, e) {
3
3
  for (var n in e) t[n] = e[n];
4
4
  return t;
5
5
  }
6
- function de(t) {
6
+ function ue(t) {
7
7
  t && t.parentNode && t.parentNode.removeChild(t);
8
8
  }
9
- function L(t, e, n) {
9
+ function D(t, e, n) {
10
10
  var o, s, i, l = {};
11
11
  for (i in e) i == "key" ? o = e[i] : i == "ref" ? s = e[i] : l[i] = e[i];
12
12
  if (arguments.length > 2 && (l.children = arguments.length > 3 ? B.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (i in t.defaultProps) l[i] === void 0 && (l[i] = t.defaultProps[i]);
13
13
  return Q(t, l, o, s, null);
14
14
  }
15
15
  function Q(t, e, n, o, s) {
16
- var i = { type: t, props: e, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: s ?? ++He, __i: -1, __u: 0 };
16
+ var i = { type: t, props: e, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: s ?? ++Te, __i: -1, __u: 0 };
17
17
  return s == null && m.vnode != null && m.vnode(i), i;
18
18
  }
19
19
  function U(t) {
@@ -27,32 +27,32 @@ function O(t, e) {
27
27
  for (var n; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) return n.__e;
28
28
  return typeof t.type == "function" ? O(t) : null;
29
29
  }
30
- function De(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 De(t);
37
+ return Ue(t);
38
38
  }
39
39
  }
40
- function we(t) {
41
- (!t.__d && (t.__d = !0) && R.push(t) && !Y.__r++ || ye != m.debounceRendering) && ((ye = m.debounceRendering) || Pe)(Y);
40
+ function ye(t) {
41
+ (!t.__d && (t.__d = !0) && R.push(t) && !Y.__r++ || me != m.debounceRendering) && ((me = m.debounceRendering) || He)(Y);
42
42
  }
43
43
  function Y() {
44
- for (var t, e, n, o, s, i, l, _ = 1; R.length; ) R.length > _ && R.sort(Ie), t = R.shift(), _ = R.length, t.__d && (n = void 0, o = void 0, s = (o = (e = t).__v).__e, i = [], l = [], e.__P && ((n = E({}, o)).__v = o.__v + 1, m.vnode && m.vnode(n), ge(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [s] : null, i, s ?? O(o), !!(32 & o.__u), l), n.__v = o.__v, n.__.__k[n.__i] = n, Qe(i, n, l), o.__e = o.__ = null, n.__e != s && De(n)));
44
+ for (var t, e, n, o, s, i, l, _ = 1; R.length; ) R.length > _ && R.sort(Pe), t = R.shift(), _ = R.length, t.__d && (n = void 0, o = void 0, s = (o = (e = t).__v).__e, i = [], l = [], e.__P && ((n = E({}, o)).__v = o.__v + 1, m.vnode && m.vnode(n), de(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [s] : null, i, s ?? O(o), !!(32 & o.__u), l), n.__v = o.__v, n.__.__k[n.__i] = n, Le(i, n, l), o.__e = o.__ = null, n.__e != s && Ue(n)));
45
45
  Y.__r = 0;
46
46
  }
47
- function Le(t, e, n, o, s, i, l, _, c, a, u) {
48
- var r, h, d, b, S, w, p, f = o && o.__k || Ue, x = e.length;
49
- for (c = lt(n, e, f, c, x), r = 0; r < x; r++) (d = n.__k[r]) != null && (h = d.__i == -1 ? q : f[d.__i] || q, d.__i = r, w = ge(t, d, h, s, i, l, _, c, a, u), b = d.__e, d.ref && h.ref != d.ref && (h.ref && he(h.ref, null, d), u.push(d.ref, d.__c || b, d)), S == null && b != null && (S = b), (p = !!(4 & d.__u)) || h.__k === d.__k ? c = Oe(d, c, t, p) : typeof d.type == "function" && w !== void 0 ? c = w : b && (c = b.nextSibling), d.__u &= -7);
50
- return n.__e = S, c;
47
+ function De(t, e, n, o, s, i, l, _, c, a, u) {
48
+ var r, f, d, b, A, w, p, h = o && o.__k || Re, x = e.length;
49
+ for (c = rt(n, e, h, c, x), r = 0; r < x; r++) (d = n.__k[r]) != null && (f = d.__i == -1 ? q : h[d.__i] || q, d.__i = r, w = de(t, d, f, s, i, l, _, c, a, u), b = d.__e, d.ref && f.ref != d.ref && (f.ref && ge(f.ref, null, d), u.push(d.ref, d.__c || b, d)), A == null && b != null && (A = b), (p = !!(4 & d.__u)) || f.__k === d.__k ? c = Oe(d, c, t, p) : typeof d.type == "function" && w !== void 0 ? c = w : b && (c = b.nextSibling), d.__u &= -7);
50
+ return n.__e = A, c;
51
51
  }
52
- function lt(t, e, n, o, s) {
53
- var i, l, _, c, a, u = n.length, r = u, h = 0;
54
- for (t.__k = new Array(s), i = 0; i < s; i++) (l = e[i]) != null && typeof l != "boolean" && typeof l != "function" ? (typeof l == "string" || typeof l == "number" || typeof l == "bigint" || l.constructor == String ? l = t.__k[i] = Q(null, l, null, null, null) : te(l) ? l = t.__k[i] = Q(U, { children: l }, null, null, null) : l.constructor === void 0 && l.__b > 0 ? l = t.__k[i] = Q(l.type, l.props, l.key, l.ref ? l.ref : null, l.__v) : t.__k[i] = l, c = i + h, l.__ = t, l.__b = t.__b + 1, _ = null, (a = l.__i = at(l, n, c, r)) != -1 && (r--, (_ = n[a]) && (_.__u |= 2)), _ == null || _.__v == null ? (a == -1 && (s > u ? h-- : s < u && h++), typeof l.type != "function" && (l.__u |= 4)) : a != c && (a == c - 1 ? h-- : a == c + 1 ? h++ : (a > c ? h-- : h++, l.__u |= 4))) : t.__k[i] = null;
55
- if (r) for (i = 0; i < u; i++) (_ = n[i]) != null && !(2 & _.__u) && (_.__e == o && (o = O(_)), je(_, _));
52
+ function rt(t, e, n, o, s) {
53
+ var i, l, _, c, a, u = n.length, r = u, f = 0;
54
+ for (t.__k = new Array(s), i = 0; i < s; i++) (l = e[i]) != null && typeof l != "boolean" && typeof l != "function" ? (typeof l == "string" || typeof l == "number" || typeof l == "bigint" || l.constructor == String ? l = t.__k[i] = Q(null, l, null, null, null) : te(l) ? l = t.__k[i] = Q(U, { children: l }, null, null, null) : l.constructor === void 0 && l.__b > 0 ? l = t.__k[i] = Q(l.type, l.props, l.key, l.ref ? l.ref : null, l.__v) : t.__k[i] = l, c = i + f, l.__ = t, l.__b = t.__b + 1, _ = null, (a = l.__i = lt(l, n, c, r)) != -1 && (r--, (_ = n[a]) && (_.__u |= 2)), _ == null || _.__v == null ? (a == -1 && (s > u ? f-- : s < u && f++), typeof l.type != "function" && (l.__u |= 4)) : a != c && (a == c - 1 ? f-- : a == c + 1 ? f++ : (a > c ? f-- : f++, l.__u |= 4))) : t.__k[i] = null;
55
+ if (r) for (i = 0; i < u; i++) (_ = n[i]) != null && !(2 & _.__u) && (_.__e == o && (o = O(_)), qe(_, _));
56
56
  return o;
57
57
  }
58
58
  function Oe(t, e, n, o) {
@@ -67,7 +67,7 @@ function Oe(t, e, n, o) {
67
67
  while (e != null && e.nodeType == 8);
68
68
  return e;
69
69
  }
70
- function at(t, e, n, o) {
70
+ function lt(t, e, n, o) {
71
71
  var s, i, l, _ = t.key, c = t.type, a = e[n], u = a != null && (2 & a.__u) == 0;
72
72
  if (a === null && _ == null || u && _ == a.key && c == a.type) return n;
73
73
  if (o > (u ? 1 : 0)) {
@@ -75,17 +75,17 @@ function at(t, e, n, o) {
75
75
  }
76
76
  return -1;
77
77
  }
78
- function ve(t, e, n) {
79
- e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || rt.test(e) ? n : n + "px";
78
+ function we(t, e, n) {
79
+ e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || st.test(e) ? n : n + "px";
80
80
  }
81
81
  function J(t, e, n, o, s) {
82
82
  var i, l;
83
83
  e: if (e == "style") if (typeof n == "string") t.style.cssText = n;
84
84
  else {
85
- if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || ve(t.style, e, "");
86
- if (n) for (e in n) o && n[e] == o[e] || ve(t.style, e, n[e]);
85
+ if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || we(t.style, e, "");
86
+ if (n) for (e in n) o && n[e] == o[e] || we(t.style, e, n[e]);
87
87
  }
88
- else if (e[0] == "o" && e[1] == "n") i = e != (e = e.replace(Re, "$1")), l = e.toLowerCase(), e = l in t || e == "onFocusOut" || e == "onFocusIn" ? l.slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + i] = n, n ? o ? n.u = o.u : (n.u = ue, t.addEventListener(e, i ? ae : le, i)) : t.removeEventListener(e, i ? ae : le, i);
88
+ else if (e[0] == "o" && e[1] == "n") i = e != (e = e.replace(Ie, "$1")), l = e.toLowerCase(), e = l in t || e == "onFocusOut" || e == "onFocusIn" ? l.slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + i] = n, n ? o ? n.u = o.u : (n.u = ce, t.addEventListener(e, i ? le : re, i)) : t.removeEventListener(e, i ? le : re, i);
89
89
  else {
90
90
  if (s == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
91
91
  else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in t) try {
@@ -96,60 +96,60 @@ function J(t, e, n, o, s) {
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 be(t) {
99
+ function ve(t) {
100
100
  return function(e) {
101
101
  if (this.l) {
102
102
  var n = this.l[e.type + t];
103
- if (e.t == null) e.t = ue++;
103
+ if (e.t == null) e.t = ce++;
104
104
  else if (e.t < n.u) return;
105
105
  return n(m.event ? m.event(e) : e);
106
106
  }
107
107
  };
108
108
  }
109
- function ge(t, e, n, o, s, i, l, _, c, a) {
110
- var u, r, h, d, b, S, w, p, f, x, W, H, $, z, k, P, I, N = e.type;
109
+ function de(t, e, n, o, s, i, l, _, c, a) {
110
+ var u, r, f, d, b, A, w, p, h, x, $, H, S, z, k, P, I, W = e.type;
111
111
  if (e.constructor !== void 0) return null;
112
112
  128 & n.__u && (c = !!(32 & n.__u), i = [_ = e.__e = n.__e]), (u = m.__b) && u(e);
113
- e: if (typeof N == "function") try {
114
- if (p = e.props, f = "prototype" in N && N.prototype.render, x = (u = N.contextType) && o[u.__c], W = u ? x ? x.props.value : u.__ : o, n.__c ? w = (r = e.__c = n.__c).__ = r.__E : (f ? e.__c = r = new N(p, W) : (e.__c = r = new G(p, W), r.constructor = N, r.render = ct), x && x.sub(r), r.state || (r.state = {}), r.__n = o, h = r.__d = !0, r.__h = [], r._sb = []), f && r.__s == null && (r.__s = r.state), f && N.getDerivedStateFromProps != null && (r.__s == r.state && (r.__s = E({}, r.__s)), E(r.__s, N.getDerivedStateFromProps(p, r.__s))), d = r.props, b = r.state, r.__v = e, h) f && N.getDerivedStateFromProps == null && r.componentWillMount != null && r.componentWillMount(), f && r.componentDidMount != null && r.__h.push(r.componentDidMount);
113
+ e: if (typeof W == "function") try {
114
+ if (p = e.props, h = "prototype" in W && W.prototype.render, x = (u = W.contextType) && o[u.__c], $ = u ? x ? x.props.value : u.__ : o, n.__c ? w = (r = e.__c = n.__c).__ = r.__E : (h ? e.__c = r = new W(p, $) : (e.__c = r = new G(p, $), r.constructor = W, r.render = _t), x && x.sub(r), r.state || (r.state = {}), r.__n = o, f = r.__d = !0, r.__h = [], r._sb = []), h && r.__s == null && (r.__s = r.state), h && W.getDerivedStateFromProps != null && (r.__s == r.state && (r.__s = E({}, r.__s)), E(r.__s, W.getDerivedStateFromProps(p, r.__s))), d = r.props, b = r.state, r.__v = e, f) h && W.getDerivedStateFromProps == null && r.componentWillMount != null && r.componentWillMount(), h && r.componentDidMount != null && r.__h.push(r.componentDidMount);
115
115
  else {
116
- if (f && N.getDerivedStateFromProps == null && p !== d && r.componentWillReceiveProps != null && r.componentWillReceiveProps(p, W), e.__v == n.__v || !r.__e && r.shouldComponentUpdate != null && r.shouldComponentUpdate(p, r.__s, W) === !1) {
116
+ if (h && W.getDerivedStateFromProps == null && p !== d && r.componentWillReceiveProps != null && r.componentWillReceiveProps(p, $), e.__v == n.__v || !r.__e && r.shouldComponentUpdate != null && r.shouldComponentUpdate(p, r.__s, $) === !1) {
117
117
  for (e.__v != n.__v && (r.props = p, r.state = r.__s, r.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(F) {
118
118
  F && (F.__ = e);
119
119
  }), H = 0; H < r._sb.length; H++) r.__h.push(r._sb[H]);
120
120
  r._sb = [], r.__h.length && l.push(r);
121
121
  break e;
122
122
  }
123
- r.componentWillUpdate != null && r.componentWillUpdate(p, r.__s, W), f && r.componentDidUpdate != null && r.__h.push(function() {
124
- r.componentDidUpdate(d, b, S);
123
+ r.componentWillUpdate != null && r.componentWillUpdate(p, r.__s, $), h && r.componentDidUpdate != null && r.__h.push(function() {
124
+ r.componentDidUpdate(d, b, A);
125
125
  });
126
126
  }
127
- if (r.context = W, r.props = p, r.__P = t, r.__e = !1, $ = m.__r, z = 0, f) {
128
- for (r.state = r.__s, r.__d = !1, $ && $(e), u = r.render(r.props, r.state, r.context), k = 0; k < r._sb.length; k++) r.__h.push(r._sb[k]);
127
+ if (r.context = $, r.props = p, r.__P = t, r.__e = !1, S = m.__r, z = 0, h) {
128
+ for (r.state = r.__s, r.__d = !1, S && S(e), u = r.render(r.props, r.state, r.context), k = 0; k < r._sb.length; k++) r.__h.push(r._sb[k]);
129
129
  r._sb = [];
130
130
  } else do
131
- r.__d = !1, $ && $(e), u = r.render(r.props, r.state, r.context), r.state = r.__s;
131
+ r.__d = !1, S && S(e), u = r.render(r.props, r.state, r.context), r.state = r.__s;
132
132
  while (r.__d && ++z < 25);
133
- r.state = r.__s, r.getChildContext != null && (o = E(E({}, o), r.getChildContext())), f && !h && r.getSnapshotBeforeUpdate != null && (S = r.getSnapshotBeforeUpdate(d, b)), P = u, u != null && u.type === U && u.key == null && (P = qe(u.props.children)), _ = Le(t, te(P) ? P : [P], e, n, o, s, i, l, _, c, a), r.base = e.__e, e.__u &= -161, r.__h.length && l.push(r), w && (r.__E = r.__ = null);
133
+ r.state = r.__s, r.getChildContext != null && (o = E(E({}, o), r.getChildContext())), h && !f && r.getSnapshotBeforeUpdate != null && (A = r.getSnapshotBeforeUpdate(d, b)), P = u, u != null && u.type === U && u.key == null && (P = Qe(u.props.children)), _ = De(t, te(P) ? P : [P], e, n, o, s, i, l, _, c, a), r.base = e.__e, e.__u &= -161, r.__h.length && l.push(r), w && (r.__E = r.__ = null);
134
134
  } catch (F) {
135
135
  if (e.__v = null, c || i != null) if (F.then) {
136
136
  for (e.__u |= c ? 160 : 128; _ && _.nodeType == 8 && _.nextSibling; ) _ = _.nextSibling;
137
137
  i[i.indexOf(_)] = null, e.__e = _;
138
138
  } else {
139
- for (I = i.length; I--; ) de(i[I]);
140
- _e(e);
139
+ for (I = i.length; I--; ) ue(i[I]);
140
+ ae(e);
141
141
  }
142
- else e.__e = n.__e, e.__k = n.__k, F.then || _e(e);
142
+ else e.__e = n.__e, e.__k = n.__k, F.then || ae(e);
143
143
  m.__e(F, e, n);
144
144
  }
145
- else i == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : _ = e.__e = _t(n.__e, e, n, o, s, i, l, c, a);
145
+ else i == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : _ = e.__e = at(n.__e, e, n, o, s, i, l, c, a);
146
146
  return (u = m.diffed) && u(e), 128 & e.__u ? void 0 : _;
147
147
  }
148
- function _e(t) {
149
- t && t.__c && (t.__c.__e = !0), t && t.__k && t.__k.forEach(_e);
148
+ function ae(t) {
149
+ t && t.__c && (t.__c.__e = !0), t && t.__k && t.__k.forEach(ae);
150
150
  }
151
- function Qe(t, e, n) {
152
- for (var o = 0; o < n.length; o++) he(n[o], n[++o], n[++o]);
151
+ function Le(t, e, n) {
152
+ for (var o = 0; o < n.length; o++) ge(n[o], n[++o], n[++o]);
153
153
  m.__c && m.__c(e, t), t.some(function(s) {
154
154
  try {
155
155
  t = s.__h, s.__h = [], t.some(function(i) {
@@ -160,22 +160,22 @@ function Qe(t, e, n) {
160
160
  }
161
161
  });
162
162
  }
163
- function qe(t) {
164
- return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : te(t) ? t.map(qe) : E({}, t);
163
+ function Qe(t) {
164
+ return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : te(t) ? t.map(Qe) : E({}, t);
165
165
  }
166
- function _t(t, e, n, o, s, i, l, _, c) {
167
- var a, u, r, h, d, b, S, w = n.props || q, p = e.props, f = e.type;
168
- if (f == "svg" ? s = "http://www.w3.org/2000/svg" : f == "math" ? s = "http://www.w3.org/1998/Math/MathML" : s || (s = "http://www.w3.org/1999/xhtml"), i != null) {
169
- for (a = 0; a < i.length; a++) if ((d = i[a]) && "setAttribute" in d == !!f && (f ? d.localName == f : d.nodeType == 3)) {
166
+ function at(t, e, n, o, s, i, l, _, c) {
167
+ var a, u, r, f, d, b, A, w = n.props || q, p = e.props, h = e.type;
168
+ if (h == "svg" ? s = "http://www.w3.org/2000/svg" : h == "math" ? s = "http://www.w3.org/1998/Math/MathML" : s || (s = "http://www.w3.org/1999/xhtml"), i != null) {
169
+ for (a = 0; a < i.length; a++) if ((d = i[a]) && "setAttribute" in d == !!h && (h ? d.localName == h : d.nodeType == 3)) {
170
170
  t = d, i[a] = null;
171
171
  break;
172
172
  }
173
173
  }
174
174
  if (t == null) {
175
- if (f == null) return document.createTextNode(p);
176
- t = document.createElementNS(s, f, p.is && p), _ && (m.__m && m.__m(e, i), _ = !1), i = null;
175
+ if (h == null) return document.createTextNode(p);
176
+ t = document.createElementNS(s, h, p.is && p), _ && (m.__m && m.__m(e, i), _ = !1), i = null;
177
177
  }
178
- if (f == null) w === p || _ && t.data == p || (t.data = p);
178
+ if (h == null) w === p || _ && t.data == p || (t.data = p);
179
179
  else {
180
180
  if (i = i && B.call(t.childNodes), !_ && i != null) for (w = {}, a = 0; a < t.attributes.length; a++) w[(d = t.attributes[a]).name] = d.value;
181
181
  for (a in w) if (d = w[a], a != "children") {
@@ -185,14 +185,14 @@ function _t(t, e, n, o, s, i, l, _, c) {
185
185
  J(t, a, null, d, s);
186
186
  }
187
187
  }
188
- for (a in p) d = p[a], a == "children" ? h = d : a == "dangerouslySetInnerHTML" ? u = d : a == "value" ? b = d : a == "checked" ? S = d : _ && typeof d != "function" || w[a] === d || J(t, a, d, w[a], s);
188
+ for (a in p) d = p[a], a == "children" ? f = d : a == "dangerouslySetInnerHTML" ? u = d : a == "value" ? b = d : a == "checked" ? A = d : _ && typeof d != "function" || w[a] === d || J(t, a, d, w[a], s);
189
189
  if (u) _ || r && (u.__html == r.__html || u.__html == t.innerHTML) || (t.innerHTML = u.__html), e.__k = [];
190
- else if (r && (t.innerHTML = ""), Le(e.type == "template" ? t.content : t, te(h) ? h : [h], e, n, o, f == "foreignObject" ? "http://www.w3.org/1999/xhtml" : s, i, l, i ? i[0] : n.__k && O(n, 0), _, c), i != null) for (a = i.length; a--; ) de(i[a]);
191
- _ || (a = "value", f == "progress" && b == null ? t.removeAttribute("value") : b != null && (b !== t[a] || f == "progress" && !b || f == "option" && b != w[a]) && J(t, a, b, w[a], s), a = "checked", S != null && S != t[a] && J(t, a, S, w[a], s));
190
+ else if (r && (t.innerHTML = ""), De(e.type == "template" ? t.content : t, te(f) ? f : [f], e, n, o, h == "foreignObject" ? "http://www.w3.org/1999/xhtml" : s, i, l, i ? i[0] : n.__k && O(n, 0), _, c), i != null) for (a = i.length; a--; ) ue(i[a]);
191
+ _ || (a = "value", h == "progress" && b == null ? t.removeAttribute("value") : b != null && (b !== t[a] || h == "progress" && !b || h == "option" && b != w[a]) && J(t, a, b, w[a], s), a = "checked", A != null && A != t[a] && J(t, a, A, w[a], s));
192
192
  }
193
193
  return t;
194
194
  }
195
- function he(t, e, n) {
195
+ function ge(t, e, n) {
196
196
  try {
197
197
  if (typeof t == "function") {
198
198
  var o = typeof t.__u == "function";
@@ -202,9 +202,9 @@ function he(t, e, n) {
202
202
  m.__e(s, n);
203
203
  }
204
204
  }
205
- function je(t, e, n) {
205
+ function qe(t, e, n) {
206
206
  var o, s;
207
- if (m.unmount && m.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || he(o, null, e)), (o = t.__c) != null) {
207
+ if (m.unmount && m.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || ge(o, null, e)), (o = t.__c) != null) {
208
208
  if (o.componentWillUnmount) try {
209
209
  o.componentWillUnmount();
210
210
  } catch (i) {
@@ -212,39 +212,39 @@ function je(t, e, n) {
212
212
  }
213
213
  o.base = o.__P = null;
214
214
  }
215
- if (o = t.__k) for (s = 0; s < o.length; s++) o[s] && je(o[s], e, n || typeof t.type != "function");
216
- n || de(t.__e), t.__c = t.__ = t.__e = void 0;
215
+ if (o = t.__k) for (s = 0; s < o.length; s++) o[s] && qe(o[s], e, n || typeof t.type != "function");
216
+ n || ue(t.__e), t.__c = t.__ = t.__e = void 0;
217
217
  }
218
- function ct(t, e, n) {
218
+ function _t(t, e, n) {
219
219
  return this.constructor(t, n);
220
220
  }
221
221
  function ne(t, e, n) {
222
222
  var o, s, i, l;
223
- e == document && (e = document.documentElement), m.__ && m.__(t, e), s = (o = typeof n == "function") ? null : n && n.__k || e.__k, i = [], l = [], ge(e, t = (!o && n || e).__k = L(U, null, [t]), s || q, q, e.namespaceURI, !o && n ? [n] : s ? null : e.firstChild ? B.call(e.childNodes) : null, i, !o && n ? n : s ? s.__e : e.firstChild, o, l), Qe(i, t, l);
223
+ e == document && (e = document.documentElement), m.__ && m.__(t, e), s = (o = typeof n == "function") ? null : n && n.__k || e.__k, i = [], l = [], de(e, t = (!o && n || e).__k = D(U, null, [t]), s || q, q, e.namespaceURI, !o && n ? [n] : s ? null : e.firstChild ? B.call(e.childNodes) : null, i, !o && n ? n : s ? s.__e : e.firstChild, o, l), Le(i, t, l);
224
224
  }
225
- function Be(t, e) {
226
- ne(t, e, Be);
225
+ function je(t, e) {
226
+ ne(t, e, je);
227
227
  }
228
- function ze(t, e, n) {
228
+ function Be(t, e, n) {
229
229
  var o, s, i, l, _ = E({}, t.props);
230
230
  for (i in t.type && t.type.defaultProps && (l = t.type.defaultProps), e) i == "key" ? o = e[i] : i == "ref" ? s = e[i] : _[i] = e[i] === void 0 && l != null ? l[i] : e[i];
231
231
  return arguments.length > 2 && (_.children = arguments.length > 3 ? B.call(arguments, 2) : n), Q(t.type, _, o || t.key, s || t.ref, null);
232
232
  }
233
- B = Ue.slice, m = { __e: function(t, e, n, o) {
233
+ B = Re.slice, m = { __e: function(t, e, n, o) {
234
234
  for (var s, i, l; e = e.__; ) if ((s = e.__c) && !s.__) try {
235
235
  if ((i = s.constructor) && i.getDerivedStateFromError != null && (s.setState(i.getDerivedStateFromError(t)), l = s.__d), s.componentDidCatch != null && (s.componentDidCatch(t, o || {}), l = s.__d), l) return s.__E = s;
236
236
  } catch (_) {
237
237
  t = _;
238
238
  }
239
239
  throw t;
240
- } }, He = 0, G.prototype.setState = function(t, e) {
240
+ } }, Te = 0, G.prototype.setState = function(t, e) {
241
241
  var n;
242
- n = this.__s != null && this.__s != this.state ? this.__s : this.__s = E({}, this.state), typeof t == "function" && (t = t(E({}, n), this.props)), t && E(n, t), t != null && this.__v && (e && this._sb.push(e), we(this));
242
+ n = this.__s != null && this.__s != this.state ? this.__s : this.__s = E({}, this.state), typeof t == "function" && (t = t(E({}, n), this.props)), t && E(n, t), t != null && this.__v && (e && this._sb.push(e), ye(this));
243
243
  }, G.prototype.forceUpdate = function(t) {
244
- this.__v && (this.__e = !0, t && this.__h.push(t), we(this));
245
- }, G.prototype.render = U, R = [], Pe = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, Ie = function(t, e) {
244
+ this.__v && (this.__e = !0, t && this.__h.push(t), ye(this));
245
+ }, G.prototype.render = U, R = [], He = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, Pe = function(t, e) {
246
246
  return t.__v.__b - e.__v.__b;
247
- }, Y.__r = 0, Re = /(PointerCapture)$|Capture$/i, ue = 0, le = be(!1), ae = be(!0);
247
+ }, Y.__r = 0, Ie = /(PointerCapture)$|Capture$/i, ce = 0, re = ve(!1), le = ve(!0);
248
248
  function Z() {
249
249
  return Z = Object.assign ? Object.assign.bind() : function(t) {
250
250
  for (var e = 1; e < arguments.length; e++) {
@@ -254,21 +254,21 @@ function Z() {
254
254
  return t;
255
255
  }, Z.apply(this, arguments);
256
256
  }
257
- function Ve(t, e) {
257
+ function ze(t, e) {
258
258
  if (t == null) return {};
259
259
  var n, o, s = {}, i = Object.keys(t);
260
260
  for (o = 0; o < i.length; o++) e.indexOf(n = i[o]) >= 0 || (s[n] = t[n]);
261
261
  return s;
262
262
  }
263
- var ut = ["context", "children"], dt = ["useFragment"];
264
- function gt(t, e, n, o) {
263
+ var ct = ["context", "children"], ut = ["useFragment"];
264
+ function dt(t, e, n, o) {
265
265
  function s() {
266
266
  var i = Reflect.construct(HTMLElement, [], s);
267
267
  return i._vdomComponent = t, i._root = i, i;
268
268
  }
269
269
  return (s.prototype = Object.create(HTMLElement.prototype)).constructor = s, s.prototype.connectedCallback = function() {
270
- ft.call(this, o);
271
- }, s.prototype.attributeChangedCallback = pt, s.prototype.disconnectedCallback = mt, n = n || t.observedAttributes || Object.keys(t.propTypes || {}), s.observedAttributes = n, t.formAssociated && (s.formAssociated = !0), n.forEach(function(i) {
270
+ ht.call(this, o);
271
+ }, s.prototype.attributeChangedCallback = ft, s.prototype.disconnectedCallback = pt, n = n || t.observedAttributes || Object.keys(t.propTypes || {}), s.observedAttributes = n, t.formAssociated && (s.formAssociated = !0), n.forEach(function(i) {
272
272
  Object.defineProperty(s.prototype, i, { get: function() {
273
273
  return this._vdom ? this._vdom.props[i] : this._props[i];
274
274
  }, set: function(l) {
@@ -278,88 +278,88 @@ function gt(t, e, n, o) {
278
278
  } });
279
279
  }), customElements.define(e, s), s;
280
280
  }
281
- function ht(t) {
281
+ function gt(t) {
282
282
  this.getChildContext = function() {
283
283
  return t.context;
284
284
  };
285
- var e = t.children, n = Ve(t, ut);
286
- return ze(e, n);
285
+ var e = t.children, n = ze(t, ct);
286
+ return Be(e, n);
287
287
  }
288
- function ft(t) {
288
+ function ht(t) {
289
289
  var e = new CustomEvent("_preact", { detail: {}, bubbles: !0, cancelable: !0 });
290
- this.dispatchEvent(e), this._vdom = L(ht, Z({}, this._props, { context: e.detail.context }), Ke(this, this._vdomComponent, t)), (this.hasAttribute("hydrate") ? Be : ne)(this._vdom, this._root);
290
+ this.dispatchEvent(e), this._vdom = D(gt, Z({}, this._props, { context: e.detail.context }), Je(this, this._vdomComponent, t)), (this.hasAttribute("hydrate") ? je : ne)(this._vdom, this._root);
291
291
  }
292
- function Je(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 pt(t, e, n) {
297
+ function ft(t, e, n) {
298
298
  if (this._vdom) {
299
299
  var o = {};
300
- o[t] = n = n ?? void 0, o[Je(t)] = n, this._vdom = ze(this._vdom, o), ne(this._vdom, this._root);
300
+ o[t] = n = n ?? void 0, o[Ve(t)] = n, this._vdom = Be(this._vdom, o), ne(this._vdom, this._root);
301
301
  }
302
302
  }
303
- function mt() {
303
+ function pt() {
304
304
  ne(this._vdom = null, this._root);
305
305
  }
306
- function Ce(t, e) {
307
- var n = this, o = t.useFragment, s = Ve(t, dt);
308
- return L(o ? U : "slot", Z({}, s, { ref: function(i) {
306
+ function be(t, e) {
307
+ var n = this, o = t.useFragment, s = ze(t, ut);
308
+ return D(o ? U : "slot", Z({}, s, { ref: function(i) {
309
309
  i ? (n.ref = i, n._listener || (n._listener = function(l) {
310
310
  l.stopPropagation(), l.detail.context = e;
311
311
  }, i.addEventListener("_preact", n._listener))) : n.ref.removeEventListener("_preact", n._listener);
312
312
  } }));
313
313
  }
314
- function Ke(t, e, n) {
314
+ function Je(t, e, n) {
315
315
  if (t.nodeType === 3) return t.data;
316
316
  if (t.nodeType !== 1) return null;
317
317
  var o = [], s = {}, i = 0, l = t.attributes, _ = t.childNodes;
318
- for (i = l.length; i--; ) l[i].name !== "slot" && (s[l[i].name] = l[i].value, s[Je(l[i].name)] = l[i].value);
318
+ for (i = l.length; i--; ) l[i].name !== "slot" && (s[l[i].name] = l[i].value, s[Ve(l[i].name)] = l[i].value);
319
319
  for (i = _.length; i--; ) {
320
- var c = Ke(_[i], null, n), a = _[i].slot;
321
- a ? s[a] = L(Ce, { name: a }, c) : o[i] = c;
320
+ var c = Je(_[i], null, n), a = _[i].slot;
321
+ a ? s[a] = D(be, { name: a }, c) : o[i] = c;
322
322
  }
323
- var u = !(!n || !n.shadow), r = e ? L(Ce, { useFragment: !u }, o) : o;
324
- return !u && e && (t.innerHTML = ""), L(e || t.nodeName.toLowerCase(), s, r);
323
+ var u = !(!n || !n.shadow), r = e ? D(be, { useFragment: !u }, o) : o;
324
+ return !u && e && (t.innerHTML = ""), D(e || t.nodeName.toLowerCase(), s, r);
325
325
  }
326
- var yt = 0;
326
+ var mt = 0;
327
327
  function g(t, e, n, o, s, i) {
328
328
  e || (e = {});
329
329
  var l, _, c = e;
330
330
  if ("ref" in c) for (_ in c = {}, e) _ == "ref" ? l = e[_] : c[_] = e[_];
331
- var a = { type: t, props: c, key: n, ref: l, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --yt, __i: -1, __u: 0, __source: s, __self: i };
331
+ var a = { type: t, props: c, key: n, ref: l, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --mt, __i: -1, __u: 0, __source: s, __self: i };
332
332
  if (typeof t == "function" && (l = t.defaultProps)) for (_ in l) c[_] === void 0 && (c[_] = l[_]);
333
333
  return m.vnode && m.vnode(a), a;
334
334
  }
335
- var j, v, se, ke, ee = 0, Ge = [], C = m, Ae = C.__b, Se = C.__r, $e = C.diffed, We = C.__c, Ne = C.unmount, xe = C.__;
336
- function fe(t, e) {
335
+ var j, v, ie, Ce, ee = 0, Ke = [], C = m, ke = C.__b, Ae = C.__r, Se = C.diffed, $e = C.__c, We = C.unmount, Ne = C.__;
336
+ function he(t, e) {
337
337
  C.__h && C.__h(v, t, ee || e), ee = 0;
338
338
  var n = v.__H || (v.__H = { __: [], __h: [] });
339
339
  return t >= n.__.length && n.__.push({}), n.__[t];
340
340
  }
341
341
  function T(t) {
342
- return ee = 1, wt(Ye, t);
342
+ return ee = 1, yt(Xe, t);
343
343
  }
344
- function wt(t, e, n) {
345
- var o = fe(j++, 2);
346
- if (o.t = t, !o.__c && (o.__ = [Ye(void 0, e), function(_) {
344
+ function yt(t, e, n) {
345
+ var o = he(j++, 2);
346
+ if (o.t = t, !o.__c && (o.__ = [Xe(void 0, e), function(_) {
347
347
  var c = o.__N ? o.__N[0] : o.__[0], a = o.t(c, _);
348
348
  c !== a && (o.__N = [a, o.__[1]], o.__c.setState({}));
349
349
  }], o.__c = v, !v.__f)) {
350
350
  var s = function(_, c, a) {
351
351
  if (!o.__c.__H) return !0;
352
- var u = o.__c.__H.__.filter(function(h) {
353
- return !!h.__c;
352
+ var u = o.__c.__H.__.filter(function(f) {
353
+ return !!f.__c;
354
354
  });
355
- if (u.every(function(h) {
356
- return !h.__N;
355
+ if (u.every(function(f) {
356
+ return !f.__N;
357
357
  })) return !i || i.call(this, _, c, a);
358
358
  var r = o.__c.props !== _;
359
- return u.forEach(function(h) {
360
- if (h.__N) {
361
- var d = h.__[0];
362
- h.__ = h.__N, h.__N = void 0, d !== h.__[0] && (r = !0);
359
+ return u.forEach(function(f) {
360
+ if (f.__N) {
361
+ var d = f.__[0];
362
+ f.__ = f.__N, f.__N = void 0, d !== f.__[0] && (r = !0);
363
363
  }
364
364
  }), i && i.call(this, _, c, a) || r;
365
365
  };
@@ -375,56 +375,56 @@ function wt(t, e, n) {
375
375
  }
376
376
  return o.__N || o.__;
377
377
  }
378
- function Fe(t, e) {
379
- var n = fe(j++, 3);
380
- !C.__s && Xe(n.__H, e) && (n.__ = t, n.u = e, v.__H.__h.push(n));
378
+ function xe(t, e) {
379
+ var n = he(j++, 3);
380
+ !C.__s && Ge(n.__H, e) && (n.__ = t, n.u = e, v.__H.__h.push(n));
381
381
  }
382
- function Me(t) {
383
- return ee = 5, vt(function() {
382
+ function Fe(t) {
383
+ return ee = 5, wt(function() {
384
384
  return { current: t };
385
385
  }, []);
386
386
  }
387
- function vt(t, e) {
388
- var n = fe(j++, 7);
389
- return Xe(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
387
+ function wt(t, e) {
388
+ var n = he(j++, 7);
389
+ return Ge(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
390
390
  }
391
- function bt() {
392
- for (var t; t = Ge.shift(); ) if (t.__P && t.__H) try {
393
- t.__H.__h.forEach(X), t.__H.__h.forEach(ce), t.__H.__h = [];
391
+ function vt() {
392
+ for (var t; t = Ke.shift(); ) if (t.__P && t.__H) try {
393
+ t.__H.__h.forEach(X), t.__H.__h.forEach(_e), t.__H.__h = [];
394
394
  } catch (e) {
395
395
  t.__H.__h = [], C.__e(e, t.__v);
396
396
  }
397
397
  }
398
398
  C.__b = function(t) {
399
- v = null, Ae && Ae(t);
399
+ v = null, ke && ke(t);
400
400
  }, C.__ = 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), Ne && Ne(t, e);
402
402
  }, C.__r = function(t) {
403
- Se && Se(t), j = 0;
403
+ Ae && Ae(t), j = 0;
404
404
  var e = (v = t.__c).__H;
405
- e && (se === v ? (e.__h = [], v.__h = [], e.__.forEach(function(n) {
405
+ e && (ie === v ? (e.__h = [], v.__h = [], e.__.forEach(function(n) {
406
406
  n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
407
- })) : (e.__h.forEach(X), e.__h.forEach(ce), e.__h = [], j = 0)), se = v;
407
+ })) : (e.__h.forEach(X), e.__h.forEach(_e), e.__h = [], j = 0)), ie = v;
408
408
  }, C.diffed = function(t) {
409
- $e && $e(t);
409
+ Se && Se(t);
410
410
  var e = t.__c;
411
- e && e.__H && (e.__H.__h.length && (Ge.push(e) !== 1 && ke === C.requestAnimationFrame || ((ke = C.requestAnimationFrame) || Ct)(bt)), e.__H.__.forEach(function(n) {
411
+ e && e.__H && (e.__H.__h.length && (Ke.push(e) !== 1 && Ce === C.requestAnimationFrame || ((Ce = C.requestAnimationFrame) || bt)(vt)), e.__H.__.forEach(function(n) {
412
412
  n.u && (n.__H = n.u), n.u = void 0;
413
- })), se = v = null;
413
+ })), ie = v = null;
414
414
  }, C.__c = function(t, e) {
415
415
  e.some(function(n) {
416
416
  try {
417
417
  n.__h.forEach(X), n.__h = n.__h.filter(function(o) {
418
- return !o.__ || ce(o);
418
+ return !o.__ || _e(o);
419
419
  });
420
420
  } catch (o) {
421
421
  e.some(function(s) {
422
422
  s.__h && (s.__h = []);
423
423
  }), e = [], C.__e(o, n.__v);
424
424
  }
425
- }), We && We(t, e);
425
+ }), $e && $e(t, e);
426
426
  }, C.unmount = function(t) {
427
- Ne && Ne(t);
427
+ We && We(t);
428
428
  var e, n = t.__c;
429
429
  n && n.__H && (n.__H.__.forEach(function(o) {
430
430
  try {
@@ -434,37 +434,37 @@ C.__b = function(t) {
434
434
  }
435
435
  }), n.__H = void 0, e && C.__e(e, n.__v));
436
436
  };
437
- var Ee = typeof requestAnimationFrame == "function";
438
- function Ct(t) {
437
+ var Me = typeof requestAnimationFrame == "function";
438
+ function bt(t) {
439
439
  var e, n = function() {
440
- clearTimeout(o), Ee && cancelAnimationFrame(e), setTimeout(t);
440
+ clearTimeout(o), Me && cancelAnimationFrame(e), setTimeout(t);
441
441
  }, o = setTimeout(n, 35);
442
- Ee && (e = requestAnimationFrame(n));
442
+ Me && (e = requestAnimationFrame(n));
443
443
  }
444
444
  function X(t) {
445
445
  var e = v, n = t.__c;
446
446
  typeof n == "function" && (t.__c = void 0, n()), v = e;
447
447
  }
448
- function ce(t) {
448
+ function _e(t) {
449
449
  var e = v;
450
450
  t.__c = t.__(), v = e;
451
451
  }
452
- function Xe(t, e) {
452
+ function Ge(t, e) {
453
453
  return !t || t.length !== e.length || e.some(function(n, o) {
454
454
  return n !== t[o];
455
455
  });
456
456
  }
457
- function Ye(t, e) {
457
+ function Xe(t, e) {
458
458
  return typeof e == "function" ? e(t) : e;
459
459
  }
460
- const kt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
460
+ const Ct = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
461
461
  let K = (t = 21) => {
462
462
  let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
463
463
  for (; t--; )
464
- e += kt[n[t] & 63];
464
+ e += Ct[n[t] & 63];
465
465
  return e;
466
466
  };
467
- class At {
467
+ class kt {
468
468
  constructor(e, n) {
469
469
  this.agentUrl = e, this.agentId = n, this.agentConfig = null, this.ws = null, this.messageCallbacks = /* @__PURE__ */ new Set(), this.connectionCallbacks = /* @__PURE__ */ new Set(), this.streamingCallbacks = /* @__PURE__ */ new Set(), this.queueCallbacks = /* @__PURE__ */ new Set(), this.messages = [], this.reconnectAttempts = 0, this.maxReconnectAttempts = 5, this.reconnectDelay = 1e3, this.isAgentStreaming = !1, this.messageQueue = [];
470
470
  }
@@ -730,13 +730,13 @@ Result: ${JSON.stringify(n.result)}`, toolResult: n.result }
730
730
  this.ws && (this.ws.close(), this.ws = null), this.messageCallbacks.clear(), this.connectionCallbacks.clear();
731
731
  }
732
732
  }
733
- const re = {
733
+ const se = {
734
734
  none: "0",
735
735
  small: "0.375rem",
736
736
  medium: "0.75rem",
737
737
  large: "1rem"
738
738
  };
739
- function St({
739
+ function At({
740
740
  agentUrl: t,
741
741
  agentId: e,
742
742
  // Legacy props for backward compatibility
@@ -750,52 +750,52 @@ function St({
750
750
  baseColor: a,
751
751
  accentColor: u = "#14B8A6",
752
752
  buttonBaseColor: r = "#000000",
753
- buttonAccentColor: h = "#FFFFFF",
753
+ buttonAccentColor: f = "#FFFFFF",
754
754
  title: d,
755
755
  subtitle: b,
756
- emptyChatMessage: S
756
+ emptyChatMessage: A
757
757
  }) {
758
- const [w, p] = T(!1), [f, x] = T([]), [W, H] = T(""), [$, z] = T(!1), [k, P] = T(!1), [I, N] = T(null), [F, Ze] = T(!1), [oe, et] = T(0), V = Me(null), pe = Me(null);
759
- Fe(() => ((async () => {
758
+ const [w, p] = T(!1), [h, x] = T([]), [$, H] = T(""), [S, z] = T(!1), [k, P] = T(!1), [I, W] = T(null), [F, Ye] = T(!1), [oe, Ze] = T(0), V = Fe(null), fe = Fe(null);
759
+ xe(() => ((async () => {
760
760
  if (t && e) {
761
761
  console.log("[AriaFlow Widget] Using new agent resolution:", { agentUrl: t, agentId: e });
762
- const M = new At(t, e);
762
+ const M = new kt(t, e);
763
763
  V.current = M;
764
764
  try {
765
- M.onMessages((A) => {
766
- console.log("[AriaFlow Widget] Messages updated:", A.length), x(A);
767
- }), M.onConnectionChange((A) => {
768
- console.log("[AriaFlow Widget] Connection state:", A), z(A), A && P(!0);
769
- }), M.onStreamingChange((A) => {
770
- console.log("[AriaFlow Widget] Streaming state:", A), Ze(A);
771
- }), M.onQueueChange((A) => {
772
- console.log("[AriaFlow Widget] Queue count:", A), et(A);
765
+ M.onMessages((N) => {
766
+ console.log("[AriaFlow Widget] Messages updated:", N.length), x(N);
767
+ }), M.onConnectionChange((N) => {
768
+ console.log("[AriaFlow Widget] Connection state:", N), z(N), N && P(!0);
769
+ }), M.onStreamingChange((N) => {
770
+ console.log("[AriaFlow Widget] Streaming state:", N), Ye(N);
771
+ }), M.onQueueChange((N) => {
772
+ console.log("[AriaFlow Widget] Queue count:", N), Ze(N);
773
773
  });
774
- const D = await M.initWidget();
775
- console.log("[AriaFlow Widget] Agent config received:", D), D ? (N(D), console.log("[AriaFlow Widget] Widget initialized successfully")) : console.error("[AriaFlow Widget] Agent config fetch failed");
776
- } catch (D) {
777
- console.error("[AriaFlow Widget] Initialization error:", D);
774
+ const L = await M.initWidget();
775
+ console.log("[AriaFlow Widget] Agent config received:", L), L ? (W(L), console.log("[AriaFlow Widget] Widget initialized successfully")) : console.error("[AriaFlow Widget] Agent config fetch failed");
776
+ } catch (L) {
777
+ console.error("[AriaFlow Widget] Initialization error:", L);
778
778
  }
779
779
  } else t && !e ? (console.warn("[AriaFlow Widget] Direct WebSocket URLs are deprecated. Use agent-url + agent-id instead."), console.error("[AriaFlow Widget] Configuration error: agent-id is required")) : o && n ? (console.warn("[AriaFlow Widget] Legacy widget config is deprecated. Use agent-url + agent-id instead."), console.error("[AriaFlow Widget] Configuration error: use agent-url + agent-id instead")) : console.error("[AriaFlow Widget] Invalid configuration. Provide agent-url and agent-id.");
780
780
  })(), () => {
781
781
  V.current?.dispose();
782
- }), [t, e, n, o]), Fe(() => {
783
- pe.current?.scrollIntoView({ behavior: "smooth" });
784
- }, [f]);
785
- const me = async () => {
786
- if (!W.trim() || !$) return;
787
- const y = W.trim();
782
+ }), [t, e, n, o]), xe(() => {
783
+ fe.current?.scrollIntoView({ behavior: "smooth" });
784
+ }, [h]);
785
+ const pe = async () => {
786
+ if (!$.trim() || !S) return;
787
+ const y = $.trim();
788
788
  H("");
789
789
  try {
790
790
  await V.current?.sendMessage(y);
791
791
  } catch (M) {
792
792
  console.error("Failed to send message:", M);
793
793
  }
794
+ }, et = (y) => {
795
+ y.key === "Enter" && !y.shiftKey && (y.preventDefault(), pe());
794
796
  }, tt = (y) => {
795
- y.key === "Enter" && !y.shiftKey && (y.preventDefault(), me());
796
- }, nt = (y) => {
797
- !$ || F || V.current?.sendMessage(y);
798
- }, ot = d || I?.config.title || "Ninewells Hospital", it = b || I?.config.subtitle || "How can we help you today?", st = S || I?.config.emptyChatMessage || "Start a conversation with Ninewells...";
797
+ !S || F || V.current?.sendMessage(y);
798
+ }, nt = d || I?.config.title || "Ninewells Hospital", ot = b || I?.config.subtitle || "How can we help you today?", it = A || I?.config.emptyChatMessage || "Start a conversation with Ninewells...";
799
799
  return console.log("[AriaFlow Widget] Rendering widget component", { isInitialized: k, isOpen: w, position: l }), /* @__PURE__ */ g(
800
800
  "div",
801
801
  {
@@ -813,7 +813,7 @@ function St({
813
813
  onClick: () => p(!0),
814
814
  style: {
815
815
  backgroundColor: r,
816
- color: h,
816
+ color: f,
817
817
  opacity: k ? 1 : 0.8,
818
818
  cursor: k ? "pointer" : "wait",
819
819
  position: "relative"
@@ -833,7 +833,7 @@ function St({
833
833
  transform: "translate(-50%, -50%)",
834
834
  width: "20px",
835
835
  height: "20px",
836
- border: `2px solid ${h}`,
836
+ border: `2px solid ${f}`,
837
837
  borderTop: "2px solid transparent",
838
838
  borderRadius: "50%",
839
839
  animation: "spin 1s linear infinite"
@@ -861,7 +861,7 @@ function St({
861
861
  className: "ariaflow-widget-window",
862
862
  style: {
863
863
  backgroundColor: i === "dark" && a ? a : void 0,
864
- borderRadius: re[c]
864
+ borderRadius: se[c]
865
865
  },
866
866
  children: [
867
867
  /* @__PURE__ */ g(
@@ -870,12 +870,12 @@ function St({
870
870
  className: "ariaflow-widget-header",
871
871
  style: {
872
872
  backgroundColor: u,
873
- borderRadius: c === "none" ? "0" : `${re[c]} ${re[c]} 0 0`
873
+ borderRadius: c === "none" ? "0" : `${se[c]} ${se[c]} 0 0`
874
874
  },
875
875
  children: [
876
876
  /* @__PURE__ */ g("div", { className: "ariaflow-widget-header-content", children: /* @__PURE__ */ g("div", { className: "ariaflow-widget-title-group", children: [
877
- /* @__PURE__ */ g("h3", { className: "ariaflow-widget-title", children: ot }),
878
- /* @__PURE__ */ g("p", { className: "ariaflow-widget-subtitle", children: it })
877
+ /* @__PURE__ */ g("h3", { className: "ariaflow-widget-title", children: nt }),
878
+ /* @__PURE__ */ g("p", { className: "ariaflow-widget-subtitle", children: ot })
879
879
  ] }) }),
880
880
  /* @__PURE__ */ g(
881
881
  "button",
@@ -903,81 +903,78 @@ function St({
903
903
  ]
904
904
  }
905
905
  ),
906
- !$ && /* @__PURE__ */ g("div", { className: "ariaflow-widget-status", children: [
906
+ !S && /* @__PURE__ */ g("div", { className: "ariaflow-widget-status", children: [
907
907
  /* @__PURE__ */ g("span", { className: "ariaflow-widget-status-dot" }),
908
908
  "Connecting..."
909
909
  ] }),
910
- /* @__PURE__ */ g("div", { className: "ariaflow-widget-messages", children: f.length === 0 ? /* @__PURE__ */ g("div", { className: "ariaflow-widget-empty", children: /* @__PURE__ */ g("p", { children: $ ? st : "Connecting to agent..." }) }) : /* @__PURE__ */ g(U, { children: [
911
- f.map((y, M) => {
912
- const A = M === f.length - 1 && y.role === "assistant" && !F && y.suggestions && y.suggestions.length > 0;
913
- return /* @__PURE__ */ g(
914
- "div",
915
- {
916
- className: `ariaflow-widget-message ariaflow-widget-message-${y.role}`,
917
- children: [
918
- /* @__PURE__ */ g("div", { className: "ariaflow-widget-message-bubble", children: y.role === "tool" ? /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-message", children: [
919
- /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-header", children: [
920
- "🔧 ",
921
- y.toolCall?.name
922
- ] }),
923
- /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-content", children: [
924
- y.toolCall && /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-args", children: [
925
- /* @__PURE__ */ g("strong", { children: "Arguments:" }),
926
- " ",
927
- JSON.stringify(y.toolCall.arguments, null, 2)
928
- ] }),
929
- y.toolResult && /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-result", children: [
930
- /* @__PURE__ */ g("strong", { children: "Result:" }),
931
- " ",
932
- JSON.stringify(y.toolResult, null, 2)
933
- ] })
934
- ] })
935
- ] }) : /* @__PURE__ */ g(U, { children: [
936
- y.content,
937
- y.isStreaming && /* @__PURE__ */ g("span", { className: "ariaflow-widget-typing-indicator", children: [
938
- /* @__PURE__ */ g("span", { children: "•" }),
939
- /* @__PURE__ */ g("span", { children: "•" }),
940
- /* @__PURE__ */ g("span", { children: "•" })
941
- ] })
942
- ] }) }),
943
- A && /* @__PURE__ */ g("div", { className: "ariaflow-widget-chips-container", children: y.suggestions?.map((ie) => /* @__PURE__ */ g(
944
- "button",
945
- {
946
- className: "ariaflow-widget-chip",
947
- onClick: () => nt(ie),
948
- style: {
949
- borderColor: u,
950
- color: u
951
- },
952
- children: ie
953
- },
954
- ie
955
- )) })
956
- ]
957
- },
958
- y.id
959
- );
960
- }),
961
- /* @__PURE__ */ g("div", { ref: pe })
910
+ /* @__PURE__ */ g("div", { className: "ariaflow-widget-messages", children: h.length === 0 ? /* @__PURE__ */ g("div", { className: "ariaflow-widget-empty", children: /* @__PURE__ */ g("p", { children: S ? it : "Connecting to agent..." }) }) : /* @__PURE__ */ g(U, { children: [
911
+ h.map((y, M) => (h.length - 1, /* @__PURE__ */ g(
912
+ "div",
913
+ {
914
+ className: `ariaflow-widget-message ariaflow-widget-message-${y.role}`,
915
+ children: /* @__PURE__ */ g("div", { className: "ariaflow-widget-message-bubble", children: y.role === "tool" ? /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-message", children: [
916
+ /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-header", children: [
917
+ "🔧 ",
918
+ y.toolCall?.name
919
+ ] }),
920
+ /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-content", children: [
921
+ y.toolCall && /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-args", children: [
922
+ /* @__PURE__ */ g("strong", { children: "Arguments:" }),
923
+ " ",
924
+ JSON.stringify(y.toolCall.arguments, null, 2)
925
+ ] }),
926
+ y.toolResult && /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-result", children: [
927
+ /* @__PURE__ */ g("strong", { children: "Result:" }),
928
+ " ",
929
+ JSON.stringify(y.toolResult, null, 2)
930
+ ] })
931
+ ] })
932
+ ] }) : /* @__PURE__ */ g(U, { children: [
933
+ y.content,
934
+ y.isStreaming && /* @__PURE__ */ g("span", { className: "ariaflow-widget-typing-indicator", children: [
935
+ /* @__PURE__ */ g("span", { children: "•" }),
936
+ /* @__PURE__ */ g("span", { children: "•" }),
937
+ /* @__PURE__ */ g("span", { children: "" })
938
+ ] })
939
+ ] }) })
940
+ },
941
+ y.id
942
+ ))),
943
+ /* @__PURE__ */ g("div", { ref: fe })
962
944
  ] }) }),
945
+ !F && h.length > 0 && h[h.length - 1].role === "assistant" && h[h.length - 1].suggestions && h[h.length - 1].suggestions.length > 0 && /* @__PURE__ */ g("div", { className: "ariaflow-widget-suggestions", children: h[h.length - 1].suggestions.map((y) => /* @__PURE__ */ g(
946
+ "button",
947
+ {
948
+ className: "ariaflow-widget-chip",
949
+ onClick: () => tt(y),
950
+ style: {
951
+ borderColor: u,
952
+ color: u,
953
+ backgroundColor: "rgba(255, 255, 255, 0.95)",
954
+ backdropFilter: "blur(4px)"
955
+ },
956
+ children: y
957
+ },
958
+ y
959
+ )) }),
963
960
  /* @__PURE__ */ g("div", { className: "ariaflow-widget-input", children: [
964
961
  /* @__PURE__ */ g(
965
962
  "textarea",
966
963
  {
967
- value: W,
964
+ value: $,
968
965
  onInput: (y) => H(y.target.value),
969
- onKeyDown: tt,
970
- placeholder: $ ? F ? oe > 0 ? `Agent is responding... (${oe} message${oe > 1 ? "s" : ""} queued)` : "Agent is responding..." : "Type your message..." : "Connecting...",
966
+ onKeyDown: et,
967
+ placeholder: S ? F ? oe > 0 ? `Agent is responding... (${oe} message${oe > 1 ? "s" : ""} queued)` : "Agent is responding..." : "Type your message..." : "Connecting...",
971
968
  rows: 1,
972
- disabled: !$
969
+ disabled: !S
973
970
  }
974
971
  ),
975
972
  /* @__PURE__ */ g(
976
973
  "button",
977
974
  {
978
975
  className: "ariaflow-widget-send",
979
- onClick: me,
980
- disabled: !W.trim() || !$,
976
+ onClick: pe,
977
+ disabled: !$.trim() || !S,
981
978
  style: { backgroundColor: u },
982
979
  "aria-label": "Send message",
983
980
  children: /* @__PURE__ */ g(
@@ -1005,8 +1002,8 @@ function St({
1005
1002
  }
1006
1003
  );
1007
1004
  }
1008
- gt(
1009
- St,
1005
+ dt(
1006
+ At,
1010
1007
  "ariaflow-widget",
1011
1008
  // Properties to observe from HTML attributes (mirror Vapi's naming convention)
1012
1009
  [
@@ -1032,12 +1029,12 @@ gt(
1032
1029
  // Shadow DOM (optional, set to false for light DOM)
1033
1030
  !1
1034
1031
  );
1035
- typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", Te) : Te());
1036
- function Te() {
1032
+ typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", Ee) : Ee());
1033
+ function Ee() {
1037
1034
  const t = document.querySelectorAll("ariaflow-widget");
1038
1035
  console.log(`[AriaFlow] Initializing ${t.length} widget(s)`);
1039
1036
  }
1040
1037
  export {
1041
- St as Widget,
1042
- At as WidgetClient
1038
+ At as Widget,
1039
+ kt as WidgetClient
1043
1040
  };
@@ -1,4 +1,4 @@
1
- (function(P,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(P=typeof globalThis<"u"?globalThis:P||self,T(P.AriaFlowWidget={}))})(this,function(P){"use strict";var T,m,me,I,ye,we,ve,be,ie,se,re,j={},Ce=[],nt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,V=Array.isArray;function x(t,e){for(var n in e)t[n]=e[n];return t}function le(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function L(t,e,n){var o,s,i,l={};for(i in e)i=="key"?o=e[i]:i=="ref"?s=e[i]:l[i]=e[i];if(arguments.length>2&&(l.children=arguments.length>3?T.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)l[i]===void 0&&(l[i]=t.defaultProps[i]);return B(t,l,o,s,null)}function B(t,e,n,o,s){var i={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++me,__i:-1,__u:0};return s==null&&m.vnode!=null&&m.vnode(i),i}function R(t){return t.children}function J(t,e){this.props=t,this.context=e}function Q(t,e){if(e==null)return t.__?Q(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Q(t):null}function ke(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return ke(t)}}function Ae(t){(!t.__d&&(t.__d=!0)&&I.push(t)&&!K.__r++||ye!=m.debounceRendering)&&((ye=m.debounceRendering)||we)(K)}function K(){for(var t,e,n,o,s,i,l,_=1;I.length;)I.length>_&&I.sort(ve),t=I.shift(),_=I.length,t.__d&&(n=void 0,o=void 0,s=(o=(e=t).__v).__e,i=[],l=[],e.__P&&((n=x({},o)).__v=o.__v+1,m.vnode&&m.vnode(n),ae(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[s]:null,i,s??Q(o),!!(32&o.__u),l),n.__v=o.__v,n.__.__k[n.__i]=n,xe(i,n,l),o.__e=o.__=null,n.__e!=s&&ke(n)));K.__r=0}function Se(t,e,n,o,s,i,l,_,c,a,u){var r,h,d,C,S,v,p,f=o&&o.__k||Ce,F=e.length;for(c=ot(n,e,f,c,F),r=0;r<F;r++)(d=n.__k[r])!=null&&(h=d.__i==-1?j:f[d.__i]||j,d.__i=r,v=ae(t,d,h,s,i,l,_,c,a,u),C=d.__e,d.ref&&h.ref!=d.ref&&(h.ref&&ce(h.ref,null,d),u.push(d.ref,d.__c||C,d)),S==null&&C!=null&&(S=C),(p=!!(4&d.__u))||h.__k===d.__k?c=$e(d,c,t,p):typeof d.type=="function"&&v!==void 0?c=v:C&&(c=C.nextSibling),d.__u&=-7);return n.__e=S,c}function ot(t,e,n,o,s){var i,l,_,c,a,u=n.length,r=u,h=0;for(t.__k=new Array(s),i=0;i<s;i++)(l=e[i])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=t.__k[i]=B(null,l,null,null,null):V(l)?l=t.__k[i]=B(R,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=t.__k[i]=B(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):t.__k[i]=l,c=i+h,l.__=t,l.__b=t.__b+1,_=null,(a=l.__i=it(l,n,c,r))!=-1&&(r--,(_=n[a])&&(_.__u|=2)),_==null||_.__v==null?(a==-1&&(s>u?h--:s<u&&h++),typeof l.type!="function"&&(l.__u|=4)):a!=c&&(a==c-1?h--:a==c+1?h++:(a>c?h--:h++,l.__u|=4))):t.__k[i]=null;if(r)for(i=0;i<u;i++)(_=n[i])!=null&&!(2&_.__u)&&(_.__e==o&&(o=Q(_)),Me(_,_));return o}function $e(t,e,n,o){var s,i;if(typeof t.type=="function"){for(s=t.__k,i=0;s&&i<s.length;i++)s[i]&&(s[i].__=t,e=$e(s[i],e,n,o));return e}t.__e!=e&&(o&&(e&&t.type&&!e.parentNode&&(e=Q(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function it(t,e,n,o){var s,i,l,_=t.key,c=t.type,a=e[n],u=a!=null&&(2&a.__u)==0;if(a===null&&_==null||u&&_==a.key&&c==a.type)return n;if(o>(u?1:0)){for(s=n-1,i=n+1;s>=0||i<e.length;)if((a=e[l=s>=0?s--:i++])!=null&&!(2&a.__u)&&_==a.key&&c==a.type)return l}return-1}function We(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||nt.test(e)?n:n+"px"}function G(t,e,n,o,s){var i,l;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||We(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||We(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(be,"$1")),l=e.toLowerCase(),e=l in t||e=="onFocusOut"||e=="onFocusIn"?l.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=n,n?o?n.u=o.u:(n.u=ie,t.addEventListener(e,i?re:se,i)):t.removeEventListener(e,i?re:se,i);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function Ne(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ie++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function ae(t,e,n,o,s,i,l,_,c,a){var u,r,h,d,C,S,v,p,f,F,W,U,$,ne,k,D,O,N=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),i=[_=e.__e=n.__e]),(u=m.__b)&&u(e);e:if(typeof N=="function")try{if(p=e.props,f="prototype"in N&&N.prototype.render,F=(u=N.contextType)&&o[u.__c],W=u?F?F.props.value:u.__:o,n.__c?v=(r=e.__c=n.__c).__=r.__E:(f?e.__c=r=new N(p,W):(e.__c=r=new J(p,W),r.constructor=N,r.render=rt),F&&F.sub(r),r.state||(r.state={}),r.__n=o,h=r.__d=!0,r.__h=[],r._sb=[]),f&&r.__s==null&&(r.__s=r.state),f&&N.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=x({},r.__s)),x(r.__s,N.getDerivedStateFromProps(p,r.__s))),d=r.props,C=r.state,r.__v=e,h)f&&N.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),f&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(f&&N.getDerivedStateFromProps==null&&p!==d&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(p,W),e.__v==n.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(p,r.__s,W)===!1){for(e.__v!=n.__v&&(r.props=p,r.state=r.__s,r.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(M){M&&(M.__=e)}),U=0;U<r._sb.length;U++)r.__h.push(r._sb[U]);r._sb=[],r.__h.length&&l.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(p,r.__s,W),f&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(d,C,S)})}if(r.context=W,r.props=p,r.__P=t,r.__e=!1,$=m.__r,ne=0,f){for(r.state=r.__s,r.__d=!1,$&&$(e),u=r.render(r.props,r.state,r.context),k=0;k<r._sb.length;k++)r.__h.push(r._sb[k]);r._sb=[]}else do r.__d=!1,$&&$(e),u=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++ne<25);r.state=r.__s,r.getChildContext!=null&&(o=x(x({},o),r.getChildContext())),f&&!h&&r.getSnapshotBeforeUpdate!=null&&(S=r.getSnapshotBeforeUpdate(d,C)),D=u,u!=null&&u.type===R&&u.key==null&&(D=Fe(u.props.children)),_=Se(t,V(D)?D:[D],e,n,o,s,i,l,_,c,a),r.base=e.__e,e.__u&=-161,r.__h.length&&l.push(r),v&&(r.__E=r.__=null)}catch(M){if(e.__v=null,c||i!=null)if(M.then){for(e.__u|=c?160:128;_&&_.nodeType==8&&_.nextSibling;)_=_.nextSibling;i[i.indexOf(_)]=null,e.__e=_}else{for(O=i.length;O--;)le(i[O]);_e(e)}else e.__e=n.__e,e.__k=n.__k,M.then||_e(e);m.__e(M,e,n)}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):_=e.__e=st(n.__e,e,n,o,s,i,l,c,a);return(u=m.diffed)&&u(e),128&e.__u?void 0:_}function _e(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(_e)}function xe(t,e,n){for(var o=0;o<n.length;o++)ce(n[o],n[++o],n[++o]);m.__c&&m.__c(e,t),t.some(function(s){try{t=s.__h,s.__h=[],t.some(function(i){i.call(s)})}catch(i){m.__e(i,s.__v)}})}function Fe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:V(t)?t.map(Fe):x({},t)}function st(t,e,n,o,s,i,l,_,c){var a,u,r,h,d,C,S,v=n.props||j,p=e.props,f=e.type;if(f=="svg"?s="http://www.w3.org/2000/svg":f=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),i!=null){for(a=0;a<i.length;a++)if((d=i[a])&&"setAttribute"in d==!!f&&(f?d.localName==f:d.nodeType==3)){t=d,i[a]=null;break}}if(t==null){if(f==null)return document.createTextNode(p);t=document.createElementNS(s,f,p.is&&p),_&&(m.__m&&m.__m(e,i),_=!1),i=null}if(f==null)v===p||_&&t.data==p||(t.data=p);else{if(i=i&&T.call(t.childNodes),!_&&i!=null)for(v={},a=0;a<t.attributes.length;a++)v[(d=t.attributes[a]).name]=d.value;for(a in v)if(d=v[a],a!="children"){if(a=="dangerouslySetInnerHTML")r=d;else if(!(a in p)){if(a=="value"&&"defaultValue"in p||a=="checked"&&"defaultChecked"in p)continue;G(t,a,null,d,s)}}for(a in p)d=p[a],a=="children"?h=d:a=="dangerouslySetInnerHTML"?u=d:a=="value"?C=d:a=="checked"?S=d:_&&typeof d!="function"||v[a]===d||G(t,a,d,v[a],s);if(u)_||r&&(u.__html==r.__html||u.__html==t.innerHTML)||(t.innerHTML=u.__html),e.__k=[];else if(r&&(t.innerHTML=""),Se(e.type=="template"?t.content:t,V(h)?h:[h],e,n,o,f=="foreignObject"?"http://www.w3.org/1999/xhtml":s,i,l,i?i[0]:n.__k&&Q(n,0),_,c),i!=null)for(a=i.length;a--;)le(i[a]);_||(a="value",f=="progress"&&C==null?t.removeAttribute("value"):C!=null&&(C!==t[a]||f=="progress"&&!C||f=="option"&&C!=v[a])&&G(t,a,C,v[a],s),a="checked",S!=null&&S!=t[a]&&G(t,a,S,v[a],s))}return t}function ce(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(s){m.__e(s,n)}}function Me(t,e,n){var o,s;if(m.unmount&&m.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||ce(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(i){m.__e(i,e)}o.base=o.__P=null}if(o=t.__k)for(s=0;s<o.length;s++)o[s]&&Me(o[s],e,n||typeof t.type!="function");n||le(t.__e),t.__c=t.__=t.__e=void 0}function rt(t,e,n){return this.constructor(t,n)}function X(t,e,n){var o,s,i,l;e==document&&(e=document.documentElement),m.__&&m.__(t,e),s=(o=typeof n=="function")?null:n&&n.__k||e.__k,i=[],l=[],ae(e,t=(!o&&n||e).__k=L(R,null,[t]),s||j,j,e.namespaceURI,!o&&n?[n]:s?null:e.firstChild?T.call(e.childNodes):null,i,!o&&n?n:s?s.__e:e.firstChild,o,l),xe(i,t,l)}function Ee(t,e){X(t,e,Ee)}function Te(t,e,n){var o,s,i,l,_=x({},t.props);for(i in t.type&&t.type.defaultProps&&(l=t.type.defaultProps),e)i=="key"?o=e[i]:i=="ref"?s=e[i]:_[i]=e[i]===void 0&&l!=null?l[i]:e[i];return arguments.length>2&&(_.children=arguments.length>3?T.call(arguments,2):n),B(t.type,_,o||t.key,s||t.ref,null)}T=Ce.slice,m={__e:function(t,e,n,o){for(var s,i,l;e=e.__;)if((s=e.__c)&&!s.__)try{if((i=s.constructor)&&i.getDerivedStateFromError!=null&&(s.setState(i.getDerivedStateFromError(t)),l=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(t,o||{}),l=s.__d),l)return s.__E=s}catch(_){t=_}throw t}},me=0,J.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=x({},this.state),typeof t=="function"&&(t=t(x({},n),this.props)),t&&x(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),Ae(this))},J.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Ae(this))},J.prototype.render=R,I=[],we=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ve=function(t,e){return t.__v.__b-e.__v.__b},K.__r=0,be=/(PointerCapture)$|Capture$/i,ie=0,se=Ne(!1),re=Ne(!0);function Y(){return Y=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Y.apply(this,arguments)}function He(t,e){if(t==null)return{};var n,o,s={},i=Object.keys(t);for(o=0;o<i.length;o++)e.indexOf(n=i[o])>=0||(s[n]=t[n]);return s}var lt=["context","children"],at=["useFragment"];function _t(t,e,n,o){function s(){var i=Reflect.construct(HTMLElement,[],s);return i._vdomComponent=t,i._root=i,i}return(s.prototype=Object.create(HTMLElement.prototype)).constructor=s,s.prototype.connectedCallback=function(){ut.call(this,o)},s.prototype.attributeChangedCallback=dt,s.prototype.disconnectedCallback=gt,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),s.observedAttributes=n,t.formAssociated&&(s.formAssociated=!0),n.forEach(function(i){Object.defineProperty(s.prototype,i,{get:function(){return this._vdom?this._vdom.props[i]:this._props[i]},set:function(l){this._vdom?this.attributeChangedCallback(i,null,l):(this._props||(this._props={}),this._props[i]=l);var _=typeof l;l!=null&&_!=="string"&&_!=="boolean"&&_!=="number"||this.setAttribute(i,l)}})}),customElements.define(e,s),s}function ct(t){this.getChildContext=function(){return t.context};var e=t.children,n=He(t,lt);return Te(e,n)}function ut(t){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=L(ct,Y({},this._props,{context:e.detail.context}),Re(this,this._vdomComponent,t)),(this.hasAttribute("hydrate")?Ee:X)(this._vdom,this._root)}function Pe(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function dt(t,e,n){if(this._vdom){var o={};o[t]=n=n??void 0,o[Pe(t)]=n,this._vdom=Te(this._vdom,o),X(this._vdom,this._root)}}function gt(){X(this._vdom=null,this._root)}function Ie(t,e){var n=this,o=t.useFragment,s=He(t,at);return L(o?R:"slot",Y({},s,{ref:function(i){i?(n.ref=i,n._listener||(n._listener=function(l){l.stopPropagation(),l.detail.context=e},i.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function Re(t,e,n){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var o=[],s={},i=0,l=t.attributes,_=t.childNodes;for(i=l.length;i--;)l[i].name!=="slot"&&(s[l[i].name]=l[i].value,s[Pe(l[i].name)]=l[i].value);for(i=_.length;i--;){var c=Re(_[i],null,n),a=_[i].slot;a?s[a]=L(Ie,{name:a},c):o[i]=c}var u=!(!n||!n.shadow),r=e?L(Ie,{useFragment:!u},o):o;return!u&&e&&(t.innerHTML=""),L(e||t.nodeName.toLowerCase(),s,r)}var ht=0;function g(t,e,n,o,s,i){e||(e={});var l,_,c=e;if("ref"in c)for(_ in c={},e)_=="ref"?l=e[_]:c[_]=e[_];var a={type:t,props:c,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ht,__i:-1,__u:0,__source:s,__self:i};if(typeof t=="function"&&(l=t.defaultProps))for(_ in l)c[_]===void 0&&(c[_]=l[_]);return m.vnode&&m.vnode(a),a}var z,w,ue,Ue,Z=0,De=[],b=m,Oe=b.__b,Le=b.__r,Qe=b.diffed,qe=b.__c,je=b.unmount,Be=b.__;function de(t,e){b.__h&&b.__h(w,t,Z||e),Z=0;var n=w.__H||(w.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function H(t){return Z=1,ft(Ge,t)}function ft(t,e,n){var o=de(z++,2);if(o.t=t,!o.__c&&(o.__=[Ge(void 0,e),function(_){var c=o.__N?o.__N[0]:o.__[0],a=o.t(c,_);c!==a&&(o.__N=[a,o.__[1]],o.__c.setState({}))}],o.__c=w,!w.__f)){var s=function(_,c,a){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(h){return!!h.__c});if(u.every(function(h){return!h.__N}))return!i||i.call(this,_,c,a);var r=o.__c.props!==_;return u.forEach(function(h){if(h.__N){var d=h.__[0];h.__=h.__N,h.__N=void 0,d!==h.__[0]&&(r=!0)}}),i&&i.call(this,_,c,a)||r};w.__f=!0;var i=w.shouldComponentUpdate,l=w.componentWillUpdate;w.componentWillUpdate=function(_,c,a){if(this.__e){var u=i;i=void 0,s(_,c,a),i=u}l&&l.call(this,_,c,a)},w.shouldComponentUpdate=s}return o.__N||o.__}function ze(t,e){var n=de(z++,3);!b.__s&&Ke(n.__H,e)&&(n.__=t,n.u=e,w.__H.__h.push(n))}function Ve(t){return Z=5,pt(function(){return{current:t}},[])}function pt(t,e){var n=de(z++,7);return Ke(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function mt(){for(var t;t=De.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ee),t.__H.__h.forEach(ge),t.__H.__h=[]}catch(e){t.__H.__h=[],b.__e(e,t.__v)}}b.__b=function(t){w=null,Oe&&Oe(t)},b.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Be&&Be(t,e)},b.__r=function(t){Le&&Le(t),z=0;var e=(w=t.__c).__H;e&&(ue===w?(e.__h=[],w.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ee),e.__h.forEach(ge),e.__h=[],z=0)),ue=w},b.diffed=function(t){Qe&&Qe(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(De.push(e)!==1&&Ue===b.requestAnimationFrame||((Ue=b.requestAnimationFrame)||yt)(mt)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ue=w=null},b.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ee),n.__h=n.__h.filter(function(o){return!o.__||ge(o)})}catch(o){e.some(function(s){s.__h&&(s.__h=[])}),e=[],b.__e(o,n.__v)}}),qe&&qe(t,e)},b.unmount=function(t){je&&je(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{ee(o)}catch(s){e=s}}),n.__H=void 0,e&&b.__e(e,n.__v))};var Je=typeof requestAnimationFrame=="function";function yt(t){var e,n=function(){clearTimeout(o),Je&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,35);Je&&(e=requestAnimationFrame(n))}function ee(t){var e=w,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),w=e}function ge(t){var e=w;t.__c=t.__(),w=e}function Ke(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function Ge(t,e){return typeof e=="function"?e(t):e}const wt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let te=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=wt[n[t]&63];return e};class Xe{constructor(e,n){this.agentUrl=e,this.agentId=n,this.agentConfig=null,this.ws=null,this.messageCallbacks=new Set,this.connectionCallbacks=new Set,this.streamingCallbacks=new Set,this.queueCallbacks=new Set,this.messages=[],this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3,this.isAgentStreaming=!1,this.messageQueue=[]}async initWidget(){try{console.log("[AriaFlow Widget] Fetching agent config...",{agentUrl:this.agentUrl,agentId:this.agentId});try{const n=await fetch(`${this.agentUrl}/api/agent/${this.agentId}`);if(n.ok){const o=await n.json();return console.log("[AriaFlow Widget] Agent config received:",o),!o||o.status!=="active"?(console.error("Agent not found or inactive"),null):(this.agentConfig=o,this.maxReconnectAttempts=o.config.maxRetries||5,this.reconnectDelay=o.config.reconnectDelay||1e3,await this.connectToAgent(),o)}}catch{console.warn("[AriaFlow Widget] Agent config endpoint not available, trying fallback")}console.log("[AriaFlow Widget] Using fallback config for Railway deployment");const e={id:this.agentId,name:this.agentId==="hospital"?"Hospital Support":"Support Agent",wsUrl:`${this.agentUrl.replace(/^https/,"wss")}/ws`,status:"active",capabilities:["chat","streaming"],config:{primaryColor:"#14B8A6",position:"bottom-right",theme:"light",title:this.agentId==="hospital"?"Hospital Support":"Chat Support",subtitle:"We're here to help!",maxRetries:3,reconnectDelay:1e3}};return this.agentConfig=e,await this.connectToAgent(),e}catch(e){return console.error("Failed to initialize widget:",e),null}}async connectToAgent(){if(!this.agentConfig?.wsUrl)throw new Error("No agent WebSocket URL configured");const e=this.getSessionId(),n=`${this.agentConfig.wsUrl}/${e}`;return console.log("[AriaFlow Widget] Connecting to WebSocket:",n),new Promise((o,s)=>{try{this.ws=new WebSocket(n),this.ws.onopen=()=>{console.log("[Widget] Connected to agent"),this.reconnectAttempts=0,this.notifyConnectionChange(!0),o()},this.ws.onmessage=i=>{this.handleMessage(i)},this.ws.onclose=()=>{if(console.log("[Widget] Disconnected from agent"),this.notifyConnectionChange(!1),this.reconnectAttempts<this.maxReconnectAttempts){this.reconnectAttempts++;const i=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.log(`[Widget] Reconnecting in ${i}ms... (attempt ${this.reconnectAttempts})`),setTimeout(()=>this.connectToAgent(),i)}},this.ws.onerror=i=>{console.error("[Widget] WebSocket error:",i),s(i)}}catch(i){s(i)}})}handleMessage(e){try{const n=JSON.parse(e.data);if(n.type==="text-delta")this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,content:s.content+n.text}]:[...o,{id:te(),role:"assistant",content:n.text,timestamp:Date.now(),isStreaming:!0}]});else if(n.type==="done")console.log("[Widget] Response complete"),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,isStreaming:!1}]:o}),this.isAgentStreaming=!1,this.notifyStreamingChange(!1),this.processMessageQueue();else if(n.type==="step-start"||n.type==="agent-start")console.log(`[Widget] ${n.type} received:`,n.agentId||""),this.isAgentStreaming=!0,this.notifyStreamingChange(!0);else if(n.type==="step-end"||n.type==="agent-end")console.log(`[Widget] ${n.type} received`);else if(n.type==="tool-call"){console.log("[Widget] Tool call:",n.tool);const o={id:te(),role:"tool",content:`Calling tool: ${n.tool.name}`,timestamp:Date.now(),toolCall:{name:n.tool.name,arguments:n.tool.arguments}};this.setMessages(s=>[...s,o]),n.tool.name==="suggest_options"&&n.tool.arguments?.options&&this.setMessages(s=>{const i=[...s].reverse().find(l=>l.role==="assistant");return i?s.map(l=>l.id===i.id?{...l,suggestions:n.tool.arguments.options}:l):s})}else n.type==="tool-result"?(console.log("[Widget] Tool result:",n.result),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="tool"&&!s.toolResult?[...o.slice(0,-1),{...s,content:s.content+`
1
+ (function(P,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(P=typeof globalThis<"u"?globalThis:P||self,T(P.AriaFlowWidget={}))})(this,function(P){"use strict";var T,m,pe,I,me,ye,we,ve,ie,se,re,q={},be=[],tt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,V=Array.isArray;function x(t,e){for(var n in e)t[n]=e[n];return t}function le(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function L(t,e,n){var o,s,i,l={};for(i in e)i=="key"?o=e[i]:i=="ref"?s=e[i]:l[i]=e[i];if(arguments.length>2&&(l.children=arguments.length>3?T.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)l[i]===void 0&&(l[i]=t.defaultProps[i]);return j(t,l,o,s,null)}function j(t,e,n,o,s){var i={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++pe,__i:-1,__u:0};return s==null&&m.vnode!=null&&m.vnode(i),i}function R(t){return t.children}function J(t,e){this.props=t,this.context=e}function Q(t,e){if(e==null)return t.__?Q(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Q(t):null}function Ce(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Ce(t)}}function ke(t){(!t.__d&&(t.__d=!0)&&I.push(t)&&!K.__r++||me!=m.debounceRendering)&&((me=m.debounceRendering)||ye)(K)}function K(){for(var t,e,n,o,s,i,l,_=1;I.length;)I.length>_&&I.sort(we),t=I.shift(),_=I.length,t.__d&&(n=void 0,o=void 0,s=(o=(e=t).__v).__e,i=[],l=[],e.__P&&((n=x({},o)).__v=o.__v+1,m.vnode&&m.vnode(n),ae(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[s]:null,i,s??Q(o),!!(32&o.__u),l),n.__v=o.__v,n.__.__k[n.__i]=n,Ne(i,n,l),o.__e=o.__=null,n.__e!=s&&Ce(n)));K.__r=0}function Ae(t,e,n,o,s,i,l,_,c,a,u){var r,f,d,C,A,v,p,h=o&&o.__k||be,F=e.length;for(c=nt(n,e,h,c,F),r=0;r<F;r++)(d=n.__k[r])!=null&&(f=d.__i==-1?q:h[d.__i]||q,d.__i=r,v=ae(t,d,f,s,i,l,_,c,a,u),C=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&ce(f.ref,null,d),u.push(d.ref,d.__c||C,d)),A==null&&C!=null&&(A=C),(p=!!(4&d.__u))||f.__k===d.__k?c=Se(d,c,t,p):typeof d.type=="function"&&v!==void 0?c=v:C&&(c=C.nextSibling),d.__u&=-7);return n.__e=A,c}function nt(t,e,n,o,s){var i,l,_,c,a,u=n.length,r=u,f=0;for(t.__k=new Array(s),i=0;i<s;i++)(l=e[i])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=t.__k[i]=j(null,l,null,null,null):V(l)?l=t.__k[i]=j(R,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=t.__k[i]=j(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):t.__k[i]=l,c=i+f,l.__=t,l.__b=t.__b+1,_=null,(a=l.__i=ot(l,n,c,r))!=-1&&(r--,(_=n[a])&&(_.__u|=2)),_==null||_.__v==null?(a==-1&&(s>u?f--:s<u&&f++),typeof l.type!="function"&&(l.__u|=4)):a!=c&&(a==c-1?f--:a==c+1?f++:(a>c?f--:f++,l.__u|=4))):t.__k[i]=null;if(r)for(i=0;i<u;i++)(_=n[i])!=null&&!(2&_.__u)&&(_.__e==o&&(o=Q(_)),Fe(_,_));return o}function Se(t,e,n,o){var s,i;if(typeof t.type=="function"){for(s=t.__k,i=0;s&&i<s.length;i++)s[i]&&(s[i].__=t,e=Se(s[i],e,n,o));return e}t.__e!=e&&(o&&(e&&t.type&&!e.parentNode&&(e=Q(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ot(t,e,n,o){var s,i,l,_=t.key,c=t.type,a=e[n],u=a!=null&&(2&a.__u)==0;if(a===null&&_==null||u&&_==a.key&&c==a.type)return n;if(o>(u?1:0)){for(s=n-1,i=n+1;s>=0||i<e.length;)if((a=e[l=s>=0?s--:i++])!=null&&!(2&a.__u)&&_==a.key&&c==a.type)return l}return-1}function $e(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||tt.test(e)?n:n+"px"}function G(t,e,n,o,s){var i,l;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||$e(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||$e(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(ve,"$1")),l=e.toLowerCase(),e=l in t||e=="onFocusOut"||e=="onFocusIn"?l.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=n,n?o?n.u=o.u:(n.u=ie,t.addEventListener(e,i?re:se,i)):t.removeEventListener(e,i?re:se,i);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function We(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ie++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function ae(t,e,n,o,s,i,l,_,c,a){var u,r,f,d,C,A,v,p,h,F,$,U,S,ne,k,D,O,W=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),i=[_=e.__e=n.__e]),(u=m.__b)&&u(e);e:if(typeof W=="function")try{if(p=e.props,h="prototype"in W&&W.prototype.render,F=(u=W.contextType)&&o[u.__c],$=u?F?F.props.value:u.__:o,n.__c?v=(r=e.__c=n.__c).__=r.__E:(h?e.__c=r=new W(p,$):(e.__c=r=new J(p,$),r.constructor=W,r.render=st),F&&F.sub(r),r.state||(r.state={}),r.__n=o,f=r.__d=!0,r.__h=[],r._sb=[]),h&&r.__s==null&&(r.__s=r.state),h&&W.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=x({},r.__s)),x(r.__s,W.getDerivedStateFromProps(p,r.__s))),d=r.props,C=r.state,r.__v=e,f)h&&W.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),h&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(h&&W.getDerivedStateFromProps==null&&p!==d&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(p,$),e.__v==n.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(p,r.__s,$)===!1){for(e.__v!=n.__v&&(r.props=p,r.state=r.__s,r.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(M){M&&(M.__=e)}),U=0;U<r._sb.length;U++)r.__h.push(r._sb[U]);r._sb=[],r.__h.length&&l.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(p,r.__s,$),h&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(d,C,A)})}if(r.context=$,r.props=p,r.__P=t,r.__e=!1,S=m.__r,ne=0,h){for(r.state=r.__s,r.__d=!1,S&&S(e),u=r.render(r.props,r.state,r.context),k=0;k<r._sb.length;k++)r.__h.push(r._sb[k]);r._sb=[]}else do r.__d=!1,S&&S(e),u=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++ne<25);r.state=r.__s,r.getChildContext!=null&&(o=x(x({},o),r.getChildContext())),h&&!f&&r.getSnapshotBeforeUpdate!=null&&(A=r.getSnapshotBeforeUpdate(d,C)),D=u,u!=null&&u.type===R&&u.key==null&&(D=xe(u.props.children)),_=Ae(t,V(D)?D:[D],e,n,o,s,i,l,_,c,a),r.base=e.__e,e.__u&=-161,r.__h.length&&l.push(r),v&&(r.__E=r.__=null)}catch(M){if(e.__v=null,c||i!=null)if(M.then){for(e.__u|=c?160:128;_&&_.nodeType==8&&_.nextSibling;)_=_.nextSibling;i[i.indexOf(_)]=null,e.__e=_}else{for(O=i.length;O--;)le(i[O]);_e(e)}else e.__e=n.__e,e.__k=n.__k,M.then||_e(e);m.__e(M,e,n)}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):_=e.__e=it(n.__e,e,n,o,s,i,l,c,a);return(u=m.diffed)&&u(e),128&e.__u?void 0:_}function _e(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(_e)}function Ne(t,e,n){for(var o=0;o<n.length;o++)ce(n[o],n[++o],n[++o]);m.__c&&m.__c(e,t),t.some(function(s){try{t=s.__h,s.__h=[],t.some(function(i){i.call(s)})}catch(i){m.__e(i,s.__v)}})}function xe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:V(t)?t.map(xe):x({},t)}function it(t,e,n,o,s,i,l,_,c){var a,u,r,f,d,C,A,v=n.props||q,p=e.props,h=e.type;if(h=="svg"?s="http://www.w3.org/2000/svg":h=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),i!=null){for(a=0;a<i.length;a++)if((d=i[a])&&"setAttribute"in d==!!h&&(h?d.localName==h:d.nodeType==3)){t=d,i[a]=null;break}}if(t==null){if(h==null)return document.createTextNode(p);t=document.createElementNS(s,h,p.is&&p),_&&(m.__m&&m.__m(e,i),_=!1),i=null}if(h==null)v===p||_&&t.data==p||(t.data=p);else{if(i=i&&T.call(t.childNodes),!_&&i!=null)for(v={},a=0;a<t.attributes.length;a++)v[(d=t.attributes[a]).name]=d.value;for(a in v)if(d=v[a],a!="children"){if(a=="dangerouslySetInnerHTML")r=d;else if(!(a in p)){if(a=="value"&&"defaultValue"in p||a=="checked"&&"defaultChecked"in p)continue;G(t,a,null,d,s)}}for(a in p)d=p[a],a=="children"?f=d:a=="dangerouslySetInnerHTML"?u=d:a=="value"?C=d:a=="checked"?A=d:_&&typeof d!="function"||v[a]===d||G(t,a,d,v[a],s);if(u)_||r&&(u.__html==r.__html||u.__html==t.innerHTML)||(t.innerHTML=u.__html),e.__k=[];else if(r&&(t.innerHTML=""),Ae(e.type=="template"?t.content:t,V(f)?f:[f],e,n,o,h=="foreignObject"?"http://www.w3.org/1999/xhtml":s,i,l,i?i[0]:n.__k&&Q(n,0),_,c),i!=null)for(a=i.length;a--;)le(i[a]);_||(a="value",h=="progress"&&C==null?t.removeAttribute("value"):C!=null&&(C!==t[a]||h=="progress"&&!C||h=="option"&&C!=v[a])&&G(t,a,C,v[a],s),a="checked",A!=null&&A!=t[a]&&G(t,a,A,v[a],s))}return t}function ce(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(s){m.__e(s,n)}}function Fe(t,e,n){var o,s;if(m.unmount&&m.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||ce(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(i){m.__e(i,e)}o.base=o.__P=null}if(o=t.__k)for(s=0;s<o.length;s++)o[s]&&Fe(o[s],e,n||typeof t.type!="function");n||le(t.__e),t.__c=t.__=t.__e=void 0}function st(t,e,n){return this.constructor(t,n)}function X(t,e,n){var o,s,i,l;e==document&&(e=document.documentElement),m.__&&m.__(t,e),s=(o=typeof n=="function")?null:n&&n.__k||e.__k,i=[],l=[],ae(e,t=(!o&&n||e).__k=L(R,null,[t]),s||q,q,e.namespaceURI,!o&&n?[n]:s?null:e.firstChild?T.call(e.childNodes):null,i,!o&&n?n:s?s.__e:e.firstChild,o,l),Ne(i,t,l)}function Me(t,e){X(t,e,Me)}function Ee(t,e,n){var o,s,i,l,_=x({},t.props);for(i in t.type&&t.type.defaultProps&&(l=t.type.defaultProps),e)i=="key"?o=e[i]:i=="ref"?s=e[i]:_[i]=e[i]===void 0&&l!=null?l[i]:e[i];return arguments.length>2&&(_.children=arguments.length>3?T.call(arguments,2):n),j(t.type,_,o||t.key,s||t.ref,null)}T=be.slice,m={__e:function(t,e,n,o){for(var s,i,l;e=e.__;)if((s=e.__c)&&!s.__)try{if((i=s.constructor)&&i.getDerivedStateFromError!=null&&(s.setState(i.getDerivedStateFromError(t)),l=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(t,o||{}),l=s.__d),l)return s.__E=s}catch(_){t=_}throw t}},pe=0,J.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=x({},this.state),typeof t=="function"&&(t=t(x({},n),this.props)),t&&x(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ke(this))},J.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ke(this))},J.prototype.render=R,I=[],ye=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,we=function(t,e){return t.__v.__b-e.__v.__b},K.__r=0,ve=/(PointerCapture)$|Capture$/i,ie=0,se=We(!1),re=We(!0);function Y(){return Y=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Y.apply(this,arguments)}function Te(t,e){if(t==null)return{};var n,o,s={},i=Object.keys(t);for(o=0;o<i.length;o++)e.indexOf(n=i[o])>=0||(s[n]=t[n]);return s}var rt=["context","children"],lt=["useFragment"];function at(t,e,n,o){function s(){var i=Reflect.construct(HTMLElement,[],s);return i._vdomComponent=t,i._root=i,i}return(s.prototype=Object.create(HTMLElement.prototype)).constructor=s,s.prototype.connectedCallback=function(){ct.call(this,o)},s.prototype.attributeChangedCallback=ut,s.prototype.disconnectedCallback=dt,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),s.observedAttributes=n,t.formAssociated&&(s.formAssociated=!0),n.forEach(function(i){Object.defineProperty(s.prototype,i,{get:function(){return this._vdom?this._vdom.props[i]:this._props[i]},set:function(l){this._vdom?this.attributeChangedCallback(i,null,l):(this._props||(this._props={}),this._props[i]=l);var _=typeof l;l!=null&&_!=="string"&&_!=="boolean"&&_!=="number"||this.setAttribute(i,l)}})}),customElements.define(e,s),s}function _t(t){this.getChildContext=function(){return t.context};var e=t.children,n=Te(t,rt);return Ee(e,n)}function ct(t){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=L(_t,Y({},this._props,{context:e.detail.context}),Ie(this,this._vdomComponent,t)),(this.hasAttribute("hydrate")?Me:X)(this._vdom,this._root)}function He(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function ut(t,e,n){if(this._vdom){var o={};o[t]=n=n??void 0,o[He(t)]=n,this._vdom=Ee(this._vdom,o),X(this._vdom,this._root)}}function dt(){X(this._vdom=null,this._root)}function Pe(t,e){var n=this,o=t.useFragment,s=Te(t,lt);return L(o?R:"slot",Y({},s,{ref:function(i){i?(n.ref=i,n._listener||(n._listener=function(l){l.stopPropagation(),l.detail.context=e},i.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function Ie(t,e,n){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var o=[],s={},i=0,l=t.attributes,_=t.childNodes;for(i=l.length;i--;)l[i].name!=="slot"&&(s[l[i].name]=l[i].value,s[He(l[i].name)]=l[i].value);for(i=_.length;i--;){var c=Ie(_[i],null,n),a=_[i].slot;a?s[a]=L(Pe,{name:a},c):o[i]=c}var u=!(!n||!n.shadow),r=e?L(Pe,{useFragment:!u},o):o;return!u&&e&&(t.innerHTML=""),L(e||t.nodeName.toLowerCase(),s,r)}var gt=0;function g(t,e,n,o,s,i){e||(e={});var l,_,c=e;if("ref"in c)for(_ in c={},e)_=="ref"?l=e[_]:c[_]=e[_];var a={type:t,props:c,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--gt,__i:-1,__u:0,__source:s,__self:i};if(typeof t=="function"&&(l=t.defaultProps))for(_ in l)c[_]===void 0&&(c[_]=l[_]);return m.vnode&&m.vnode(a),a}var B,w,ue,Re,Z=0,Ue=[],b=m,De=b.__b,Oe=b.__r,Le=b.diffed,Qe=b.__c,qe=b.unmount,je=b.__;function de(t,e){b.__h&&b.__h(w,t,Z||e),Z=0;var n=w.__H||(w.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function H(t){return Z=1,ht(Ke,t)}function ht(t,e,n){var o=de(B++,2);if(o.t=t,!o.__c&&(o.__=[Ke(void 0,e),function(_){var c=o.__N?o.__N[0]:o.__[0],a=o.t(c,_);c!==a&&(o.__N=[a,o.__[1]],o.__c.setState({}))}],o.__c=w,!w.__f)){var s=function(_,c,a){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(f){return!!f.__c});if(u.every(function(f){return!f.__N}))return!i||i.call(this,_,c,a);var r=o.__c.props!==_;return u.forEach(function(f){if(f.__N){var d=f.__[0];f.__=f.__N,f.__N=void 0,d!==f.__[0]&&(r=!0)}}),i&&i.call(this,_,c,a)||r};w.__f=!0;var i=w.shouldComponentUpdate,l=w.componentWillUpdate;w.componentWillUpdate=function(_,c,a){if(this.__e){var u=i;i=void 0,s(_,c,a),i=u}l&&l.call(this,_,c,a)},w.shouldComponentUpdate=s}return o.__N||o.__}function Be(t,e){var n=de(B++,3);!b.__s&&Je(n.__H,e)&&(n.__=t,n.u=e,w.__H.__h.push(n))}function ze(t){return Z=5,ft(function(){return{current:t}},[])}function ft(t,e){var n=de(B++,7);return Je(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function pt(){for(var t;t=Ue.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ee),t.__H.__h.forEach(ge),t.__H.__h=[]}catch(e){t.__H.__h=[],b.__e(e,t.__v)}}b.__b=function(t){w=null,De&&De(t)},b.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),je&&je(t,e)},b.__r=function(t){Oe&&Oe(t),B=0;var e=(w=t.__c).__H;e&&(ue===w?(e.__h=[],w.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ee),e.__h.forEach(ge),e.__h=[],B=0)),ue=w},b.diffed=function(t){Le&&Le(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Ue.push(e)!==1&&Re===b.requestAnimationFrame||((Re=b.requestAnimationFrame)||mt)(pt)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ue=w=null},b.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ee),n.__h=n.__h.filter(function(o){return!o.__||ge(o)})}catch(o){e.some(function(s){s.__h&&(s.__h=[])}),e=[],b.__e(o,n.__v)}}),Qe&&Qe(t,e)},b.unmount=function(t){qe&&qe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{ee(o)}catch(s){e=s}}),n.__H=void 0,e&&b.__e(e,n.__v))};var Ve=typeof requestAnimationFrame=="function";function mt(t){var e,n=function(){clearTimeout(o),Ve&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,35);Ve&&(e=requestAnimationFrame(n))}function ee(t){var e=w,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),w=e}function ge(t){var e=w;t.__c=t.__(),w=e}function Je(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function Ke(t,e){return typeof e=="function"?e(t):e}const yt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let te=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=yt[n[t]&63];return e};class Ge{constructor(e,n){this.agentUrl=e,this.agentId=n,this.agentConfig=null,this.ws=null,this.messageCallbacks=new Set,this.connectionCallbacks=new Set,this.streamingCallbacks=new Set,this.queueCallbacks=new Set,this.messages=[],this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3,this.isAgentStreaming=!1,this.messageQueue=[]}async initWidget(){try{console.log("[AriaFlow Widget] Fetching agent config...",{agentUrl:this.agentUrl,agentId:this.agentId});try{const n=await fetch(`${this.agentUrl}/api/agent/${this.agentId}`);if(n.ok){const o=await n.json();return console.log("[AriaFlow Widget] Agent config received:",o),!o||o.status!=="active"?(console.error("Agent not found or inactive"),null):(this.agentConfig=o,this.maxReconnectAttempts=o.config.maxRetries||5,this.reconnectDelay=o.config.reconnectDelay||1e3,await this.connectToAgent(),o)}}catch{console.warn("[AriaFlow Widget] Agent config endpoint not available, trying fallback")}console.log("[AriaFlow Widget] Using fallback config for Railway deployment");const e={id:this.agentId,name:this.agentId==="hospital"?"Hospital Support":"Support Agent",wsUrl:`${this.agentUrl.replace(/^https/,"wss")}/ws`,status:"active",capabilities:["chat","streaming"],config:{primaryColor:"#14B8A6",position:"bottom-right",theme:"light",title:this.agentId==="hospital"?"Hospital Support":"Chat Support",subtitle:"We're here to help!",maxRetries:3,reconnectDelay:1e3}};return this.agentConfig=e,await this.connectToAgent(),e}catch(e){return console.error("Failed to initialize widget:",e),null}}async connectToAgent(){if(!this.agentConfig?.wsUrl)throw new Error("No agent WebSocket URL configured");const e=this.getSessionId(),n=`${this.agentConfig.wsUrl}/${e}`;return console.log("[AriaFlow Widget] Connecting to WebSocket:",n),new Promise((o,s)=>{try{this.ws=new WebSocket(n),this.ws.onopen=()=>{console.log("[Widget] Connected to agent"),this.reconnectAttempts=0,this.notifyConnectionChange(!0),o()},this.ws.onmessage=i=>{this.handleMessage(i)},this.ws.onclose=()=>{if(console.log("[Widget] Disconnected from agent"),this.notifyConnectionChange(!1),this.reconnectAttempts<this.maxReconnectAttempts){this.reconnectAttempts++;const i=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.log(`[Widget] Reconnecting in ${i}ms... (attempt ${this.reconnectAttempts})`),setTimeout(()=>this.connectToAgent(),i)}},this.ws.onerror=i=>{console.error("[Widget] WebSocket error:",i),s(i)}}catch(i){s(i)}})}handleMessage(e){try{const n=JSON.parse(e.data);if(n.type==="text-delta")this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,content:s.content+n.text}]:[...o,{id:te(),role:"assistant",content:n.text,timestamp:Date.now(),isStreaming:!0}]});else if(n.type==="done")console.log("[Widget] Response complete"),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,isStreaming:!1}]:o}),this.isAgentStreaming=!1,this.notifyStreamingChange(!1),this.processMessageQueue();else if(n.type==="step-start"||n.type==="agent-start")console.log(`[Widget] ${n.type} received:`,n.agentId||""),this.isAgentStreaming=!0,this.notifyStreamingChange(!0);else if(n.type==="step-end"||n.type==="agent-end")console.log(`[Widget] ${n.type} received`);else if(n.type==="tool-call"){console.log("[Widget] Tool call:",n.tool);const o={id:te(),role:"tool",content:`Calling tool: ${n.tool.name}`,timestamp:Date.now(),toolCall:{name:n.tool.name,arguments:n.tool.arguments}};this.setMessages(s=>[...s,o]),n.tool.name==="suggest_options"&&n.tool.arguments?.options&&this.setMessages(s=>{const i=[...s].reverse().find(l=>l.role==="assistant");return i?s.map(l=>l.id===i.id?{...l,suggestions:n.tool.arguments.options}:l):s})}else n.type==="tool-result"?(console.log("[Widget] Tool result:",n.result),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="tool"&&!s.toolResult?[...o.slice(0,-1),{...s,content:s.content+`
2
2
  Result: ${JSON.stringify(n.result)}`,toolResult:n.result}]:o})):n.type==="agent-start"?(console.log(`[Widget] Agent started: ${n.agentId}`),this.isAgentStreaming=!0,this.notifyStreamingChange(!0)):n.type==="handoff"?console.log(`[Widget] Handoff: ${n.from} -> ${n.to}: ${n.reason}`):n.type==="suggested-questions"?(console.log("[Widget] Suggestions received:",n.suggestions),this.setMessages(o=>{const s=[...o].reverse().find(i=>i.role==="assistant");return s?o.map(i=>i.id===s.id?{...i,suggestions:n.suggestions}:i):o})):console.log("[Widget] Unknown message type:",n.type)}catch(n){console.error("[Widget] Error parsing message:",e.data,n)}}async sendMessage(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("Not connected to agent");const n={id:te(),role:"user",content:e,timestamp:Date.now()};if(this.setMessages(o=>[...o,n]),this.isAgentStreaming){console.log("[Widget] Agent is streaming, queuing message"),this.messageQueue.push(e),this.notifyQueueChange(this.messageQueue.length);return}this.sendToAgent(e)}async sendToAgent(e){const n=this.getSessionId();this.ws.send(JSON.stringify({message:e,sessionId:n}))}async processMessageQueue(){if(this.messageQueue.length!==0){if(this.messageQueue.length===1){const e=this.messageQueue.shift();console.log("[Widget] Sending queued message:",e),this.sendToAgent(e)}else{const e=this.messageQueue.join(`
3
3
 
4
- `);this.messageQueue.length=0,console.log("[Widget] Sending combined queued messages:",e),this.sendToAgent(e)}this.notifyQueueChange(this.messageQueue.length)}}getSessionId(){let e=sessionStorage.getItem("ariaflow_session_id");return e||(e=te(),sessionStorage.setItem("ariaflow_session_id",e)),e}setMessages(e){this.messages=e(this.messages),this.messageCallbacks.forEach(n=>n(this.messages))}onMessages(e){return this.messageCallbacks.add(e),e(this.messages),()=>{this.messageCallbacks.delete(e)}}onConnectionChange(e){return this.connectionCallbacks.add(e),()=>{this.connectionCallbacks.delete(e)}}onStreamingChange(e){return this.streamingCallbacks.add(e),()=>{this.streamingCallbacks.delete(e)}}onQueueChange(e){return this.queueCallbacks.add(e),()=>{this.queueCallbacks.delete(e)}}notifyConnectionChange(e){this.connectionCallbacks.forEach(n=>n(e))}notifyStreamingChange(e){this.streamingCallbacks.forEach(n=>n(e))}notifyQueueChange(e){this.queueCallbacks.forEach(n=>n(e))}getMessages(){return this.messages}getConfig(){return this.agentConfig}isConnected(){return this.ws?.readyState===WebSocket.OPEN}dispose(){this.ws&&(this.ws.close(),this.ws=null),this.messageCallbacks.clear(),this.connectionCallbacks.clear()}}const he={none:"0",small:"0.375rem",medium:"0.75rem",large:"1rem"};function Ye({agentUrl:t,agentId:e,widgetId:n,apiUrl:o,mode:s="chat",theme:i="light",position:l="bottom-right",size:_="full",radius:c="medium",baseColor:a,accentColor:u="#14B8A6",buttonBaseColor:r="#000000",buttonAccentColor:h="#FFFFFF",title:d,subtitle:C,emptyChatMessage:S}){const[v,p]=H(!1),[f,F]=H([]),[W,U]=H(""),[$,ne]=H(!1),[k,D]=H(!1),[O,N]=H(null),[M,vt]=H(!1),[fe,bt]=H(0),oe=Ve(null),et=Ve(null);ze(()=>((async()=>{if(t&&e){console.log("[AriaFlow Widget] Using new agent resolution:",{agentUrl:t,agentId:e});const E=new Xe(t,e);oe.current=E;try{E.onMessages(A=>{console.log("[AriaFlow Widget] Messages updated:",A.length),F(A)}),E.onConnectionChange(A=>{console.log("[AriaFlow Widget] Connection state:",A),ne(A),A&&D(!0)}),E.onStreamingChange(A=>{console.log("[AriaFlow Widget] Streaming state:",A),vt(A)}),E.onQueueChange(A=>{console.log("[AriaFlow Widget] Queue count:",A),bt(A)});const q=await E.initWidget();console.log("[AriaFlow Widget] Agent config received:",q),q?(N(q),console.log("[AriaFlow Widget] Widget initialized successfully")):console.error("[AriaFlow Widget] Agent config fetch failed")}catch(q){console.error("[AriaFlow Widget] Initialization error:",q)}}else t&&!e?(console.warn("[AriaFlow Widget] Direct WebSocket URLs are deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: agent-id is required")):o&&n?(console.warn("[AriaFlow Widget] Legacy widget config is deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: use agent-url + agent-id instead")):console.error("[AriaFlow Widget] Invalid configuration. Provide agent-url and agent-id.")})(),()=>{oe.current?.dispose()}),[t,e,n,o]),ze(()=>{et.current?.scrollIntoView({behavior:"smooth"})},[f]);const tt=async()=>{if(!W.trim()||!$)return;const y=W.trim();U("");try{await oe.current?.sendMessage(y)}catch(E){console.error("Failed to send message:",E)}},Ct=y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),tt())},kt=y=>{!$||M||oe.current?.sendMessage(y)},At=d||O?.config.title||"Ninewells Hospital",St=C||O?.config.subtitle||"How can we help you today?",$t=S||O?.config.emptyChatMessage||"Start a conversation with Ninewells...";return console.log("[AriaFlow Widget] Rendering widget component",{isInitialized:k,isOpen:v,position:l}),g("div",{className:`ariaflow-widget-container ariaflow-widget-${l} ariaflow-widget-${_} ariaflow-widget-radius-${c}`,"data-theme":i,style:{"--ariaflow-accent-color":u,"--ariaflow-base-color":a},children:[!v&&g("button",{className:"ariaflow-widget-launcher",onClick:()=>p(!0),style:{backgroundColor:r,color:h,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&&g("div",{className:"ariaflow-widget-launcher-loading",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"20px",height:"20px",border:`2px solid ${h}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),k&&g("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children: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"})})]}),v&&k&&g("div",{className:"ariaflow-widget-window",style:{backgroundColor:i==="dark"&&a?a:void 0,borderRadius:he[c]},children:[g("div",{className:"ariaflow-widget-header",style:{backgroundColor:u,borderRadius:c==="none"?"0":`${he[c]} ${he[c]} 0 0`},children:[g("div",{className:"ariaflow-widget-header-content",children:g("div",{className:"ariaflow-widget-title-group",children:[g("h3",{className:"ariaflow-widget-title",children:At}),g("p",{className:"ariaflow-widget-subtitle",children:St})]})}),g("button",{className:"ariaflow-widget-close",onClick:()=>p(!1),"aria-label":"Close chat",children:g("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[g("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),g("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),!$&&g("div",{className:"ariaflow-widget-status",children:[g("span",{className:"ariaflow-widget-status-dot"}),"Connecting..."]}),g("div",{className:"ariaflow-widget-messages",children:f.length===0?g("div",{className:"ariaflow-widget-empty",children:g("p",{children:$?$t:"Connecting to agent..."})}):g(R,{children:[f.map((y,E)=>{const A=E===f.length-1&&y.role==="assistant"&&!M&&y.suggestions&&y.suggestions.length>0;return g("div",{className:`ariaflow-widget-message ariaflow-widget-message-${y.role}`,children:[g("div",{className:"ariaflow-widget-message-bubble",children:y.role==="tool"?g("div",{className:"ariaflow-widget-tool-message",children:[g("div",{className:"ariaflow-widget-tool-header",children:["🔧 ",y.toolCall?.name]}),g("div",{className:"ariaflow-widget-tool-content",children:[y.toolCall&&g("div",{className:"ariaflow-widget-tool-args",children:[g("strong",{children:"Arguments:"})," ",JSON.stringify(y.toolCall.arguments,null,2)]}),y.toolResult&&g("div",{className:"ariaflow-widget-tool-result",children:[g("strong",{children:"Result:"})," ",JSON.stringify(y.toolResult,null,2)]})]})]}):g(R,{children:[y.content,y.isStreaming&&g("span",{className:"ariaflow-widget-typing-indicator",children:[g("span",{children:"•"}),g("span",{children:"•"}),g("span",{children:"•"})]})]})}),A&&g("div",{className:"ariaflow-widget-chips-container",children:y.suggestions?.map(pe=>g("button",{className:"ariaflow-widget-chip",onClick:()=>kt(pe),style:{borderColor:u,color:u},children:pe},pe))})]},y.id)}),g("div",{ref:et})]})}),g("div",{className:"ariaflow-widget-input",children:[g("textarea",{value:W,onInput:y=>U(y.target.value),onKeyDown:Ct,placeholder:$?M?fe>0?`Agent is responding... (${fe} message${fe>1?"s":""} queued)`:"Agent is responding...":"Type your message...":"Connecting...",rows:1,disabled:!$}),g("button",{className:"ariaflow-widget-send",onClick:tt,disabled:!W.trim()||!$,style:{backgroundColor:u},"aria-label":"Send message",children:g("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[g("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),g("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})]})}_t(Ye,"ariaflow-widget",["agent-url","agent-id","widget-id","api-url","mode","theme","position","size","radius","base-color","accent-color","button-base-color","button-accent-color","title","subtitle","empty-chat-message"],!1),typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ze):Ze());function Ze(){const t=document.querySelectorAll("ariaflow-widget");console.log(`[AriaFlow] Initializing ${t.length} widget(s)`)}P.Widget=Ye,P.WidgetClient=Xe,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
4
+ `);this.messageQueue.length=0,console.log("[Widget] Sending combined queued messages:",e),this.sendToAgent(e)}this.notifyQueueChange(this.messageQueue.length)}}getSessionId(){let e=sessionStorage.getItem("ariaflow_session_id");return e||(e=te(),sessionStorage.setItem("ariaflow_session_id",e)),e}setMessages(e){this.messages=e(this.messages),this.messageCallbacks.forEach(n=>n(this.messages))}onMessages(e){return this.messageCallbacks.add(e),e(this.messages),()=>{this.messageCallbacks.delete(e)}}onConnectionChange(e){return this.connectionCallbacks.add(e),()=>{this.connectionCallbacks.delete(e)}}onStreamingChange(e){return this.streamingCallbacks.add(e),()=>{this.streamingCallbacks.delete(e)}}onQueueChange(e){return this.queueCallbacks.add(e),()=>{this.queueCallbacks.delete(e)}}notifyConnectionChange(e){this.connectionCallbacks.forEach(n=>n(e))}notifyStreamingChange(e){this.streamingCallbacks.forEach(n=>n(e))}notifyQueueChange(e){this.queueCallbacks.forEach(n=>n(e))}getMessages(){return this.messages}getConfig(){return this.agentConfig}isConnected(){return this.ws?.readyState===WebSocket.OPEN}dispose(){this.ws&&(this.ws.close(),this.ws=null),this.messageCallbacks.clear(),this.connectionCallbacks.clear()}}const he={none:"0",small:"0.375rem",medium:"0.75rem",large:"1rem"};function Xe({agentUrl:t,agentId:e,widgetId:n,apiUrl:o,mode:s="chat",theme:i="light",position:l="bottom-right",size:_="full",radius:c="medium",baseColor:a,accentColor:u="#14B8A6",buttonBaseColor:r="#000000",buttonAccentColor:f="#FFFFFF",title:d,subtitle:C,emptyChatMessage:A}){const[v,p]=H(!1),[h,F]=H([]),[$,U]=H(""),[S,ne]=H(!1),[k,D]=H(!1),[O,W]=H(null),[M,wt]=H(!1),[fe,vt]=H(0),oe=ze(null),Ze=ze(null);Be(()=>((async()=>{if(t&&e){console.log("[AriaFlow Widget] Using new agent resolution:",{agentUrl:t,agentId:e});const E=new Ge(t,e);oe.current=E;try{E.onMessages(N=>{console.log("[AriaFlow Widget] Messages updated:",N.length),F(N)}),E.onConnectionChange(N=>{console.log("[AriaFlow Widget] Connection state:",N),ne(N),N&&D(!0)}),E.onStreamingChange(N=>{console.log("[AriaFlow Widget] Streaming state:",N),wt(N)}),E.onQueueChange(N=>{console.log("[AriaFlow Widget] Queue count:",N),vt(N)});const z=await E.initWidget();console.log("[AriaFlow Widget] Agent config received:",z),z?(W(z),console.log("[AriaFlow Widget] Widget initialized successfully")):console.error("[AriaFlow Widget] Agent config fetch failed")}catch(z){console.error("[AriaFlow Widget] Initialization error:",z)}}else t&&!e?(console.warn("[AriaFlow Widget] Direct WebSocket URLs are deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: agent-id is required")):o&&n?(console.warn("[AriaFlow Widget] Legacy widget config is deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: use agent-url + agent-id instead")):console.error("[AriaFlow Widget] Invalid configuration. Provide agent-url and agent-id.")})(),()=>{oe.current?.dispose()}),[t,e,n,o]),Be(()=>{Ze.current?.scrollIntoView({behavior:"smooth"})},[h]);const et=async()=>{if(!$.trim()||!S)return;const y=$.trim();U("");try{await oe.current?.sendMessage(y)}catch(E){console.error("Failed to send message:",E)}},bt=y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),et())},Ct=y=>{!S||M||oe.current?.sendMessage(y)},kt=d||O?.config.title||"Ninewells Hospital",At=C||O?.config.subtitle||"How can we help you today?",St=A||O?.config.emptyChatMessage||"Start a conversation with Ninewells...";return console.log("[AriaFlow Widget] Rendering widget component",{isInitialized:k,isOpen:v,position:l}),g("div",{className:`ariaflow-widget-container ariaflow-widget-${l} ariaflow-widget-${_} ariaflow-widget-radius-${c}`,"data-theme":i,style:{"--ariaflow-accent-color":u,"--ariaflow-base-color":a},children:[!v&&g("button",{className:"ariaflow-widget-launcher",onClick:()=>p(!0),style:{backgroundColor:r,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&&g("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&&g("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children: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"})})]}),v&&k&&g("div",{className:"ariaflow-widget-window",style:{backgroundColor:i==="dark"&&a?a:void 0,borderRadius:he[c]},children:[g("div",{className:"ariaflow-widget-header",style:{backgroundColor:u,borderRadius:c==="none"?"0":`${he[c]} ${he[c]} 0 0`},children:[g("div",{className:"ariaflow-widget-header-content",children:g("div",{className:"ariaflow-widget-title-group",children:[g("h3",{className:"ariaflow-widget-title",children:kt}),g("p",{className:"ariaflow-widget-subtitle",children:At})]})}),g("button",{className:"ariaflow-widget-close",onClick:()=>p(!1),"aria-label":"Close chat",children:g("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[g("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),g("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),!S&&g("div",{className:"ariaflow-widget-status",children:[g("span",{className:"ariaflow-widget-status-dot"}),"Connecting..."]}),g("div",{className:"ariaflow-widget-messages",children:h.length===0?g("div",{className:"ariaflow-widget-empty",children:g("p",{children:S?St:"Connecting to agent..."})}):g(R,{children:[h.map((y,E)=>(h.length-1,g("div",{className:`ariaflow-widget-message ariaflow-widget-message-${y.role}`,children:g("div",{className:"ariaflow-widget-message-bubble",children:y.role==="tool"?g("div",{className:"ariaflow-widget-tool-message",children:[g("div",{className:"ariaflow-widget-tool-header",children:["🔧 ",y.toolCall?.name]}),g("div",{className:"ariaflow-widget-tool-content",children:[y.toolCall&&g("div",{className:"ariaflow-widget-tool-args",children:[g("strong",{children:"Arguments:"})," ",JSON.stringify(y.toolCall.arguments,null,2)]}),y.toolResult&&g("div",{className:"ariaflow-widget-tool-result",children:[g("strong",{children:"Result:"})," ",JSON.stringify(y.toolResult,null,2)]})]})]}):g(R,{children:[y.content,y.isStreaming&&g("span",{className:"ariaflow-widget-typing-indicator",children:[g("span",{children:"•"}),g("span",{children:"•"}),g("span",{children:"•"})]})]})})},y.id))),g("div",{ref:Ze})]})}),!M&&h.length>0&&h[h.length-1].role==="assistant"&&h[h.length-1].suggestions&&h[h.length-1].suggestions.length>0&&g("div",{className:"ariaflow-widget-suggestions",children:h[h.length-1].suggestions.map(y=>g("button",{className:"ariaflow-widget-chip",onClick:()=>Ct(y),style:{borderColor:u,color:u,backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(4px)"},children:y},y))}),g("div",{className:"ariaflow-widget-input",children:[g("textarea",{value:$,onInput:y=>U(y.target.value),onKeyDown:bt,placeholder:S?M?fe>0?`Agent is responding... (${fe} message${fe>1?"s":""} queued)`:"Agent is responding...":"Type your message...":"Connecting...",rows:1,disabled:!S}),g("button",{className:"ariaflow-widget-send",onClick:et,disabled:!$.trim()||!S,style:{backgroundColor:u},"aria-label":"Send message",children:g("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[g("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),g("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})]})}at(Xe,"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",Ye):Ye());function Ye(){const t=document.querySelectorAll("ariaflow-widget");console.log(`[AriaFlow] Initializing ${t.length} widget(s)`)}P.Widget=Xe,P.WidgetClient=Ge,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariaflowagents/widget",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "description": "Embeddable chat widget for AriaFlow Universal Inbox",
6
6
  "main": "./dist/widget.js",