@useago/sdk 1.5.6 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +223 -0
  2. package/README.md +59 -0
  3. package/dist/AgoClient-BHegN73y.cjs +9 -0
  4. package/dist/{AgoClient-B_R_qi2s.js → AgoClient-PWPaekcg.js} +656 -387
  5. package/dist/angular.cjs +1 -1
  6. package/dist/angular.d.cts +230 -5
  7. package/dist/angular.d.ts +230 -5
  8. package/dist/angular.js +10 -1
  9. package/dist/{createConversationSession-Dqh7NXK4.cjs → createConversationSession-BbUUukV0.cjs} +1 -1
  10. package/dist/{createConversationSession-CdtI4vrf.js → createConversationSession-BkruoOVm.js} +1 -1
  11. package/dist/{createFormCollector-BjO3oB63.cjs → createFormCollector-C1ixsjV0.cjs} +1 -1
  12. package/dist/{createFormCollector-YwaZ78wU.js → createFormCollector-CvVFNkp6.js} +1 -1
  13. package/dist/{createMockClient-DcuNlufr.js → createMockClient-BDLW6tVc.js} +5 -2
  14. package/dist/createMockClient-BSNuN3ys.cjs +1 -0
  15. package/dist/devtools.d.cts +220 -5
  16. package/dist/devtools.d.ts +220 -5
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.cts +238 -6
  19. package/dist/index.d.ts +238 -6
  20. package/dist/index.js +111 -109
  21. package/dist/react.cjs +40 -3
  22. package/dist/react.d.cts +419 -7
  23. package/dist/react.d.ts +419 -7
  24. package/dist/react.js +1195 -743
  25. package/dist/sheetController-CBUVOroo.js +205 -0
  26. package/dist/sheetController-DY-sC13T.cjs +1 -0
  27. package/dist/testing.cjs +1 -1
  28. package/dist/testing.d.cts +220 -5
  29. package/dist/testing.d.ts +220 -5
  30. package/dist/testing.js +1 -1
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.d.cts +235 -5
  33. package/dist/vue.d.ts +235 -5
  34. package/dist/vue.js +121 -100
  35. package/dist/widget.cjs +4 -4
  36. package/dist/widget.d.cts +328 -5
  37. package/dist/widget.d.ts +328 -5
  38. package/dist/widget.js +721 -629
  39. package/llms-full.txt +202 -14
  40. package/package.json +1 -1
  41. package/dist/AgoClient-DLB9icvv.cjs +0 -8
  42. package/dist/createMockClient-Dw-cyISN.cjs +0 -1
package/dist/widget.js CHANGED
@@ -1,364 +1,348 @@
1
- import { a as qt, b as Kt, i as Xt, o as Yt, s as Qt, t as Zt } from "./AgoClient-B_R_qi2s.js";
2
- import { t as Jt } from "./createConversationSession-CdtI4vrf.js";
3
- import { r as en, t as tn } from "./createFormCollector-YwaZ78wU.js";
4
- var nn = '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', ke = `var(--ago-font, ${nn})`, ut = {
5
- font: "--ago-font",
6
- radius: "--ago-radius",
7
- messageRadius: "--ago-message-radius",
8
- brand: "--ago-brand-color",
9
- brandText: "--ago-brand-text-color",
10
- headerBg: "--ago-header-background",
11
- headerText: "--ago-header-text-color",
12
- panelBg: "--ago-panel-background",
13
- messagesBg: "--ago-messages-background",
14
- text: "--ago-text-color",
15
- mutedText: "--ago-muted-text-color",
16
- border: "--ago-border-color",
17
- accent: "--ago-accent-color",
18
- agentBubbleBg: "--ago-agent-bubble-background"
19
- }, Ae = "var(--ago-brand-color, #03182f)", _e = "var(--ago-brand-text-color, #fff)", on = "var(--ago-header-background, var(--ago-brand-color, #03182f))", mt = "var(--ago-header-text-color, #e8f0fe)", te = "var(--ago-panel-background, #fff)", yt = "var(--ago-messages-background, #fbfbfb)", ee = "var(--ago-text-color, #30373e)", wt = "var(--ago-muted-text-color, #6b6d6f)", N = "var(--ago-border-color, #dee3e8)", De = "var(--ago-accent-color, #1b5fc4)", gt = "var(--ago-agent-bubble-background, #f1f3f5)", rn = "var(--ago-radius, 16px)", ze = "var(--ago-message-radius, 16px)", an = "var(--ago-message-radius, 20px)";
20
- function sn(t, o) {
21
- if (o)
22
- for (const i of Object.keys(ut)) {
23
- const r = o[i];
24
- r != null && t.style.setProperty(ut[i], r);
25
- }
26
- }
27
- function v(t, o) {
28
- Object.assign(t.style, o);
29
- }
30
- function h(t = {}) {
31
- const o = document.createElement("div");
32
- return v(o, t), o;
33
- }
34
- var ht = "ago-chat-widget-keyframes";
35
- function ln() {
36
- if (typeof document > "u" || document.getElementById(ht)) return;
37
- const t = document.createElement("style");
38
- t.id = ht, t.textContent = "@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }", document.head.appendChild(t);
39
- }
40
- function dn(t) {
1
+ import { a as mn, b as hn, i as gn, o as xn, s as bn, t as yn } from "./AgoClient-PWPaekcg.js";
2
+ import { t as wn } from "./createConversationSession-BkruoOVm.js";
3
+ import { r as vn, t as Cn } from "./createFormCollector-CvVFNkp6.js";
4
+ import { C as Qe, S as _t, _ as te, a as T, b as g, c as $e, d as Ot, f as Ye, g as En, h as ne, i as Lt, l as Sn, m as Bt, n as jn, o as Te, p as An, r as Je, s as Me, t as Vn, u as $t, v as Rn, x as kn, y as E } from "./sheetController-CBUVOroo.js";
5
+ function In(n) {
41
6
  let o = [];
42
- const i = document.createElement("form");
43
- v(i, {
7
+ const r = document.createElement("form");
8
+ E(r, {
44
9
  display: "flex",
45
10
  flexDirection: "column",
46
11
  gap: "8px",
47
12
  padding: "12px",
48
- borderTop: `1px solid ${N}`,
49
- backgroundColor: te
50
- }), i.className = "ago-chat-input";
51
- const r = h({
13
+ borderTop: `1px solid ${T}`,
14
+ backgroundColor: ne
15
+ }), r.className = "ago-chat-input";
16
+ const i = g({
52
17
  display: "flex",
53
18
  flexWrap: "wrap",
54
19
  gap: "6px"
55
- }), b = h({
20
+ }), w = g({
56
21
  display: "flex",
57
22
  gap: "8px",
58
23
  alignItems: "flex-end"
59
- }), a = document.createElement("textarea");
60
- a.placeholder = t.placeholder, a.setAttribute("aria-label", t.placeholder), a.rows = 1, v(a, {
24
+ }), s = document.createElement("textarea");
25
+ s.placeholder = n.placeholder, s.setAttribute("aria-label", n.placeholder), s.rows = 1, E(s, {
61
26
  flex: "1",
62
27
  resize: "none",
63
28
  boxSizing: "border-box",
64
29
  padding: "10px 12px",
65
- border: `1px solid ${N}`,
30
+ border: `1px solid ${T}`,
66
31
  borderRadius: "12px",
67
32
  fontSize: "16px",
68
- fontFamily: ke,
33
+ fontFamily: $e,
69
34
  lineHeight: "1.4",
70
35
  maxHeight: "110px",
71
36
  overflowY: "hidden"
72
37
  });
73
- const C = () => {
74
- a.style.height = "auto";
75
- const c = Math.min(a.scrollHeight + 2, 110);
76
- a.style.height = `${c}px`, a.style.overflowY = a.scrollHeight + 2 > 110 ? "auto" : "hidden";
38
+ const k = () => {
39
+ s.style.height = "auto";
40
+ const h = Math.min(s.scrollHeight + 2, 110);
41
+ s.style.height = `${h}px`, s.style.overflowY = s.scrollHeight + 2 > 110 ? "auto" : "hidden";
77
42
  };
78
- a.addEventListener("input", () => {
79
- C(), I();
43
+ s.addEventListener("input", () => {
44
+ k(), F();
80
45
  });
81
- const m = '<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>', x = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>', p = document.createElement("button");
82
- p.type = "submit", p.setAttribute("aria-label", "Send"), p.innerHTML = m, v(p, {
46
+ const m = '<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>', v = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>', f = '<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><rect x="5" y="5" width="14" height="14" rx="2"/></svg>', c = document.createElement("button");
47
+ c.type = "submit", c.setAttribute("aria-label", "Send"), c.innerHTML = m, E(c, {
83
48
  flexShrink: "0",
84
- width: "40px",
85
- height: "40px",
49
+ width: "44px",
50
+ height: "44px",
86
51
  padding: "0",
87
52
  border: "none",
88
53
  borderRadius: "50%",
89
- backgroundColor: Ae,
90
- color: _e,
54
+ backgroundColor: Te,
55
+ color: Me,
91
56
  display: "flex",
92
57
  alignItems: "center",
93
58
  justifyContent: "center",
94
59
  cursor: "pointer"
95
60
  });
96
- let f = !1;
97
- const I = () => {
98
- const l = a.value.trim() !== "" || o.length > 0, c = f || !l;
99
- p.disabled = c, p.innerHTML = f ? x : m, p.style.opacity = c && !f ? "0.5" : "1", p.style.cursor = c ? "default" : "pointer";
61
+ let A = !1;
62
+ const z = () => A && !!n.onStop, F = () => {
63
+ const d = s.value.trim() !== "" || o.length > 0, h = z(), _ = !h && (A || !d);
64
+ c.disabled = _, c.type = h ? "button" : "submit", c.setAttribute("aria-label", h ? "Stop generating" : "Send"), c.innerHTML = h ? f : A ? v : m, c.style.opacity = _ && !A ? "0.5" : "1", c.style.cursor = _ ? "default" : "pointer";
100
65
  };
101
- let R = null, A = null;
102
- t.allowFiles && (R = document.createElement("input"), R.type = "file", R.multiple = !0, v(R, { display: "none" }), A = document.createElement("button"), A.type = "button", A.setAttribute("aria-label", "Attach file"), A.textContent = "📎", v(A, {
103
- padding: "10px 12px",
104
- border: `1px solid ${N}`,
66
+ c.addEventListener("click", () => {
67
+ z() && n.onStop?.();
68
+ });
69
+ let B = null, I = null;
70
+ n.allowFiles && (B = document.createElement("input"), B.type = "file", B.multiple = !0, E(B, { display: "none" }), I = document.createElement("button"), I.type = "button", I.setAttribute("aria-label", "Attach file"), I.textContent = "📎", E(I, {
71
+ flexShrink: "0",
72
+ minWidth: "44px",
73
+ minHeight: "44px",
74
+ display: "flex",
75
+ alignItems: "center",
76
+ justifyContent: "center",
77
+ padding: "0 12px",
78
+ border: `1px solid ${T}`,
105
79
  borderRadius: "12px",
106
- backgroundColor: te,
80
+ backgroundColor: ne,
107
81
  cursor: "pointer",
108
82
  fontSize: "14px"
109
- }), A.addEventListener("click", () => R?.click()), R.addEventListener("change", () => {
110
- o = [...o, ...Array.from(R?.files ?? [])], Q();
83
+ }), I.addEventListener("click", () => B?.click()), B.addEventListener("change", () => {
84
+ o = [...o, ...Array.from(B?.files ?? [])], u();
111
85
  }));
112
- function Q() {
113
- r.replaceChildren(), o.forEach((l, c) => {
114
- const w = h({
86
+ function u() {
87
+ i.replaceChildren(), o.forEach((d, h) => {
88
+ const _ = g({
115
89
  display: "flex",
116
90
  alignItems: "center",
117
91
  gap: "4px",
118
92
  padding: "4px 8px",
119
93
  backgroundColor: "#f0f4ff",
120
- border: `1px solid ${N}`,
94
+ border: `1px solid ${T}`,
121
95
  borderRadius: "8px",
122
96
  fontSize: "12px"
123
- }), B = document.createElement("span");
124
- B.textContent = l.name;
125
- const k = document.createElement("button");
126
- k.type = "button", k.setAttribute("aria-label", `Remove ${l.name}`), k.textContent = "×", v(k, {
97
+ }), K = document.createElement("span");
98
+ K.textContent = d.name;
99
+ const D = document.createElement("button");
100
+ D.type = "button", D.setAttribute("aria-label", `Remove ${d.name}`), D.textContent = "×", E(D, {
101
+ flexShrink: "0",
102
+ width: "44px",
103
+ height: "44px",
104
+ margin: "-14px -12px -14px -4px",
105
+ display: "flex",
106
+ alignItems: "center",
107
+ justifyContent: "center",
127
108
  border: "none",
128
109
  background: "transparent",
129
110
  cursor: "pointer",
130
111
  fontSize: "14px",
131
112
  lineHeight: "1"
132
- }), k.addEventListener("click", () => {
133
- o = o.filter((V, j) => j !== c), Q();
134
- }), w.append(B, k), r.appendChild(w);
135
- }), I();
113
+ }), D.addEventListener("click", () => {
114
+ o = o.filter((M, j) => j !== h), u();
115
+ }), _.append(K, D), i.appendChild(_);
116
+ }), F();
136
117
  }
137
- const D = () => {
138
- const l = a.value, c = o;
139
- return a.value = "", C(), o = [], Q(), {
140
- content: l,
141
- files: c
118
+ const x = () => {
119
+ const d = s.value, h = o;
120
+ return s.value = "", k(), o = [], u(), {
121
+ content: d,
122
+ files: h
142
123
  };
143
- }, g = () => {
144
- const { content: l, files: c } = D();
145
- (l.trim() || c.length > 0) && t.onSend(l.trim(), c.length > 0 ? c : void 0);
124
+ }, y = () => {
125
+ const { content: d, files: h } = x();
126
+ (d.trim() || h.length > 0) && n.onSend(d.trim(), h.length > 0 ? h : void 0);
146
127
  };
147
- return i.addEventListener("submit", (l) => {
148
- l.preventDefault(), g();
149
- }), a.addEventListener("keydown", (l) => {
150
- l.key === "Enter" && !l.shiftKey && (l.preventDefault(), g());
151
- }), A && b.appendChild(A), b.append(a, p), R && i.appendChild(R), i.append(r, b), I(), {
152
- inputRow: i,
153
- getValueAndClear: D,
154
- setDisabled: (l) => {
155
- a.disabled = l, f = l, I();
128
+ return r.addEventListener("submit", (d) => {
129
+ d.preventDefault(), y();
130
+ }), s.addEventListener("keydown", (d) => {
131
+ d.key === "Enter" && !d.shiftKey && (d.preventDefault(), y());
132
+ }), I && w.appendChild(I), w.append(s, c), B && r.appendChild(B), r.append(i, w), F(), {
133
+ inputRow: r,
134
+ getValueAndClear: x,
135
+ setDisabled: (d) => {
136
+ s.disabled = d, A = d, F();
156
137
  },
157
- focus: () => a.focus()
138
+ focus: () => s.focus(),
139
+ restoreDraft: (d, h) => {
140
+ d && !s.value.trim() && (s.value = d, k()), h?.length && (o = [...h, ...o], u()), F();
141
+ }
158
142
  };
159
143
  }
160
- var cn = {
144
+ var _n = {
161
145
  "&": "&amp;",
162
146
  "<": "&lt;",
163
147
  ">": "&gt;",
164
148
  '"': "&quot;",
165
149
  "'": "&#39;"
166
150
  };
167
- function ae(t) {
168
- return t.replace(/[&<>"']/g, (o) => cn[o]);
151
+ function ce(n) {
152
+ return n.replace(/[&<>"']/g, (o) => _n[o]);
169
153
  }
170
- function xt(t) {
171
- const o = t.trim();
154
+ function Nt(n) {
155
+ const o = n.trim();
172
156
  return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o) || !/^[a-z][a-z0-9+.-]*:/i.test(o) ? o : null;
173
157
  }
174
- var Ct = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Se = "";
175
- function ne(t) {
176
- const o = [], i = (b) => (o.push(b), `${Se}${o.length - 1}${Se}`);
177
- let r = t;
178
- return r = r.replace(/`([^`]+)`/g, (b, a) => i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${Ct}">${ae(a)}</code>`)), r = r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (b, a, C) => {
179
- const m = xt(C);
180
- return m ? i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : b;
181
- }), r = r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (b, a, C) => {
182
- const m = xt(C);
183
- return m ? i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${ne(a)}</a>`) : b;
184
- }), r = ae(r), r = r.replace(/\*\*([^*]+?)\*\*/g, "<strong>$1</strong>").replace(/__([^_]+?)__/g, "<strong>$1</strong>").replace(/~~([^~]+?)~~/g, "<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g, "$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g, "$1<em>$2</em>"), r = r.replace(new RegExp(`${Se}(\\d+)${Se}`, "g"), (b, a) => o[Number(a)]), r;
158
+ var Dt = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Le = "";
159
+ function ie(n) {
160
+ const o = [], r = (w) => (o.push(w), `${Le}${o.length - 1}${Le}`);
161
+ let i = n;
162
+ return i = i.replace(/`([^`]+)`/g, (w, s) => r(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${Dt}">${ce(s)}</code>`)), i = i.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (w, s, k) => {
163
+ const m = Nt(k);
164
+ return m ? r(`<img alt="${ce(s)}" src="${ce(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : w;
165
+ }), i = i.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (w, s, k) => {
166
+ const m = Nt(k);
167
+ return m ? r(`<a href="${ce(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${ie(s)}</a>`) : w;
168
+ }), i = ce(i), i = i.replace(/\*\*([^*]+?)\*\*/g, "<strong>$1</strong>").replace(/__([^_]+?)__/g, "<strong>$1</strong>").replace(/~~([^~]+?)~~/g, "<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g, "$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g, "$1<em>$2</em>"), i = i.replace(new RegExp(`${Le}(\\d+)${Le}`, "g"), (w, s) => o[Number(s)]), i;
185
169
  }
186
- function O(t, o, i) {
187
- const r = document.createElement(t);
188
- return Object.assign(r.style, o), i !== void 0 && (r.innerHTML = i), r;
170
+ function P(n, o, r) {
171
+ const i = document.createElement(n);
172
+ return Object.assign(i.style, o), r !== void 0 && (i.innerHTML = r), i;
189
173
  }
190
- var Et = /^ {0,3}([-*_])( *\1){2,} *$/, St = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, Rt = /^ {0,3}(```+|~~~+)/, Ie = /^ {0,3}>\s?/, se = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, pn = [
174
+ var Ht = /^ {0,3}([-*_])( *\1){2,} *$/, zt = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, Ft = /^ {0,3}(```+|~~~+)/, Ne = /^ {0,3}>\s?/, pe = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, Ln = [
191
175
  "20px",
192
176
  "18px",
193
177
  "16px",
194
178
  "15px",
195
179
  "14px",
196
180
  "13px"
197
- ], Fe = (t) => t.match(/^\s*/)?.[0].length ?? 0;
198
- function fn(t) {
199
- return t.trim() === "" || Et.test(t) || St.test(t) || Rt.test(t) || Ie.test(t) || se.test(t);
181
+ ], Ze = (n) => n.match(/^\s*/)?.[0].length ?? 0;
182
+ function $n(n) {
183
+ return n.trim() === "" || Ht.test(n) || zt.test(n) || Ft.test(n) || Ne.test(n) || pe.test(n);
200
184
  }
201
- function kt(t) {
202
- const o = t[0].match(se), i = o[1].length, r = /\d/.test(o[2]), b = O(r ? "ol" : "ul", {
185
+ function Pt(n) {
186
+ const o = n[0].match(pe), r = o[1].length, i = /\d/.test(o[2]), w = P(i ? "ol" : "ul", {
203
187
  margin: "0 0 8px 0",
204
188
  paddingLeft: "20px",
205
- listStyleType: r ? "decimal" : "disc",
189
+ listStyleType: i ? "decimal" : "disc",
206
190
  listStylePosition: "outside"
207
191
  });
208
- let a = 0;
209
- for (; a < t.length; ) {
210
- const C = t[a].match(se), m = [];
211
- for (a++; a < t.length && Fe(t[a]) > i; )
212
- m.push(t[a]), a++;
213
- const x = O("li", {
192
+ let s = 0;
193
+ for (; s < n.length; ) {
194
+ const k = n[s].match(pe), m = [];
195
+ for (s++; s < n.length && Ze(n[s]) > r; )
196
+ m.push(n[s]), s++;
197
+ const v = P("li", {
214
198
  display: "list-item",
215
199
  margin: "2px 0",
216
200
  lineHeight: "1.6"
217
- }), p = C[3].match(/^\[([ xX])\]\s+(.*)$/);
218
- p ? (x.style.listStyleType = "none", x.style.marginLeft = "-20px", x.innerHTML = `<span style="margin-right:6px">${p[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${ne(p[2])}`) : x.innerHTML = ne(C[3]), m.filter((f) => se.test(f)).length > 0 && x.appendChild(kt(m.filter((f) => f.trim() !== ""))), b.appendChild(x);
201
+ }), f = k[3].match(/^\[([ xX])\]\s+(.*)$/);
202
+ f ? (v.style.listStyleType = "none", v.style.marginLeft = "-20px", v.innerHTML = `<span style="margin-right:6px">${f[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${ie(f[2])}`) : v.innerHTML = ie(k[3]), m.filter((c) => pe.test(c)).length > 0 && v.appendChild(Pt(m.filter((c) => c.trim() !== ""))), w.appendChild(v);
219
203
  }
220
- return b;
204
+ return w;
221
205
  }
222
- function un(t) {
223
- const o = (m) => m.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((x) => x.trim()), i = O("div", {
206
+ function Nn(n) {
207
+ const o = (m) => m.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((v) => v.trim()), r = P("div", {
224
208
  overflowX: "auto",
225
209
  margin: "0 0 8px 0"
226
- }), r = O("table", {
210
+ }), i = P("table", {
227
211
  borderCollapse: "collapse",
228
212
  width: "100%",
229
213
  fontSize: "13px"
230
- }), b = document.createElement("thead"), a = document.createElement("tr");
231
- for (const m of o(t[0])) a.appendChild(O("th", {
214
+ }), w = document.createElement("thead"), s = document.createElement("tr");
215
+ for (const m of o(n[0])) s.appendChild(P("th", {
232
216
  border: "1px solid #dee3e8",
233
217
  padding: "6px 10px",
234
218
  textAlign: "left",
235
219
  backgroundColor: "#f5f7fa",
236
220
  fontWeight: "600"
237
- }, ne(m)));
238
- b.appendChild(a), r.appendChild(b);
239
- const C = document.createElement("tbody");
240
- for (const m of t.slice(2)) {
241
- const x = document.createElement("tr");
242
- for (const p of o(m)) x.appendChild(O("td", {
221
+ }, ie(m)));
222
+ w.appendChild(s), i.appendChild(w);
223
+ const k = document.createElement("tbody");
224
+ for (const m of n.slice(2)) {
225
+ const v = document.createElement("tr");
226
+ for (const f of o(m)) v.appendChild(P("td", {
243
227
  border: "1px solid #dee3e8",
244
228
  padding: "6px 10px"
245
- }, ne(p)));
246
- C.appendChild(x);
229
+ }, ie(f)));
230
+ k.appendChild(v);
247
231
  }
248
- return r.appendChild(C), i.appendChild(r), i;
232
+ return i.appendChild(k), r.appendChild(i), r;
249
233
  }
250
- var mn = (t) => !!t && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(t);
251
- function We(t) {
252
- const o = document.createDocumentFragment(), i = t.replace(/\r\n?/g, `
234
+ var Tn = (n) => !!n && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(n);
235
+ function et(n) {
236
+ const o = document.createDocumentFragment(), r = n.replace(/\r\n?/g, `
253
237
  `).split(`
254
238
  `);
255
- let r = 0;
256
- for (; r < i.length; ) {
257
- const a = i[r];
258
- if (a.trim() === "") {
259
- r++;
239
+ let i = 0;
240
+ for (; i < r.length; ) {
241
+ const s = r[i];
242
+ if (s.trim() === "") {
243
+ i++;
260
244
  continue;
261
245
  }
262
- const C = a.match(Rt);
263
- if (C) {
264
- const p = C[1][0], f = [];
265
- for (r++; r < i.length && !new RegExp(`^ {0,3}${p === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(i[r]); )
266
- f.push(i[r]), r++;
267
- r++;
268
- const I = O("pre", { margin: "0 0 8px 0" });
269
- I.appendChild(O("code", {
246
+ const k = s.match(Ft);
247
+ if (k) {
248
+ const f = k[1][0], c = [];
249
+ for (i++; i < r.length && !new RegExp(`^ {0,3}${f === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(r[i]); )
250
+ c.push(r[i]), i++;
251
+ i++;
252
+ const A = P("pre", { margin: "0 0 8px 0" });
253
+ A.appendChild(P("code", {
270
254
  display: "block",
271
255
  background: "#f5f5f5",
272
256
  padding: "8px 12px",
273
257
  borderRadius: "6px",
274
258
  fontSize: "13px",
275
259
  overflowX: "auto",
276
- fontFamily: Ct,
260
+ fontFamily: Dt,
277
261
  whiteSpace: "pre"
278
- }, ae(f.join(`
279
- `)))), o.appendChild(I);
262
+ }, ce(c.join(`
263
+ `)))), o.appendChild(A);
280
264
  continue;
281
265
  }
282
- if (Et.test(a)) {
283
- o.appendChild(O("hr", {
266
+ if (Ht.test(s)) {
267
+ o.appendChild(P("hr", {
284
268
  border: "none",
285
269
  borderTop: "1px solid #dee3e8",
286
270
  margin: "12px 0"
287
- })), r++;
271
+ })), i++;
288
272
  continue;
289
273
  }
290
- const m = a.match(St);
274
+ const m = s.match(zt);
291
275
  if (m) {
292
- const p = m[1].length;
293
- o.appendChild(O(`h${p}`, {
276
+ const f = m[1].length;
277
+ o.appendChild(P(`h${f}`, {
294
278
  margin: "16px 0 8px 0",
295
- fontSize: pn[p - 1],
279
+ fontSize: Ln[f - 1],
296
280
  fontWeight: "600",
297
281
  lineHeight: "1.3"
298
- }, ne(m[2]))), r++;
282
+ }, ie(m[2]))), i++;
299
283
  continue;
300
284
  }
301
- if (Ie.test(a)) {
302
- const p = [];
303
- for (; r < i.length && Ie.test(i[r]); )
304
- p.push(i[r].replace(Ie, "")), r++;
305
- const f = O("blockquote", {
285
+ if (Ne.test(s)) {
286
+ const f = [];
287
+ for (; i < r.length && Ne.test(r[i]); )
288
+ f.push(r[i].replace(Ne, "")), i++;
289
+ const c = P("blockquote", {
306
290
  borderLeft: "4px solid #dee3e8",
307
291
  paddingLeft: "12px",
308
292
  margin: "0 0 8px 0",
309
293
  fontStyle: "italic",
310
294
  color: "#6b6d6f"
311
295
  });
312
- f.appendChild(We(p.join(`
313
- `))), o.appendChild(f);
296
+ c.appendChild(et(f.join(`
297
+ `))), o.appendChild(c);
314
298
  continue;
315
299
  }
316
- if (a.includes("|") && mn(i[r + 1])) {
317
- const p = [a, i[r + 1]];
318
- for (r += 2; r < i.length && i[r].includes("|") && i[r].trim(); )
319
- p.push(i[r]), r++;
320
- o.appendChild(un(p));
300
+ if (s.includes("|") && Tn(r[i + 1])) {
301
+ const f = [s, r[i + 1]];
302
+ for (i += 2; i < r.length && r[i].includes("|") && r[i].trim(); )
303
+ f.push(r[i]), i++;
304
+ o.appendChild(Nn(f));
321
305
  continue;
322
306
  }
323
- if (se.test(a)) {
324
- const p = [], f = Fe(a);
325
- for (; r < i.length && i[r].trim() !== ""; )
326
- if (se.test(i[r]) || Fe(i[r]) > f)
327
- p.push(i[r]), r++;
307
+ if (pe.test(s)) {
308
+ const f = [], c = Ze(s);
309
+ for (; i < r.length && r[i].trim() !== ""; )
310
+ if (pe.test(r[i]) || Ze(r[i]) > c)
311
+ f.push(r[i]), i++;
328
312
  else break;
329
- o.appendChild(kt(p));
313
+ o.appendChild(Pt(f));
330
314
  continue;
331
315
  }
332
- const x = [a];
333
- for (r++; r < i.length && !fn(i[r]); )
334
- x.push(i[r]), r++;
335
- o.appendChild(O("p", {
316
+ const v = [s];
317
+ for (i++; i < r.length && !$n(r[i]); )
318
+ v.push(r[i]), i++;
319
+ o.appendChild(P("p", {
336
320
  margin: "0 0 8px 0",
337
321
  lineHeight: "1.6"
338
- }, x.map((p) => ne(p)).join("<br>")));
322
+ }, v.map((f) => ie(f)).join("<br>")));
339
323
  }
340
- const b = o.lastElementChild;
341
- return b && (b.style.marginBottom = "0"), o;
324
+ const w = o.lastElementChild;
325
+ return w && (w.style.marginBottom = "0"), o;
342
326
  }
343
- function gn(t, o) {
344
- const { isLast: i, isLastOfBlock: r, bubbleStyle: b, showAgentName: a, agentBubble: C, followUpEnabled: m, followUpHandler: x, isMobile: p } = o, f = t.role === "user", I = b === "imessage", R = h({
327
+ function Tt(n, o) {
328
+ const { isLast: r, isLastOfBlock: i, bubbleStyle: w, showAgentName: s, agentBubble: k, followUpEnabled: m, followUpHandler: v, isMobile: f } = o, c = n.role === "user", A = w === "imessage", z = g({
345
329
  display: "flex",
346
330
  flexDirection: "column",
347
- alignItems: f ? "flex-end" : "flex-start",
348
- marginBottom: I && !r ? "2px" : "16px"
331
+ alignItems: c ? "flex-end" : "flex-start",
332
+ marginBottom: A && !i ? "2px" : "16px"
349
333
  });
350
- if (R.className = `ago-message ago-message--${t.role}`, !f && a && t.agent) {
351
- const g = h({
334
+ if (z.className = `ago-message ago-message--${n.role}`, !c && s && n.agent) {
335
+ const u = g({
352
336
  fontSize: "13px",
353
337
  fontWeight: "500",
354
- color: ee,
338
+ color: te,
355
339
  marginBottom: "6px",
356
340
  padding: "0 4px"
357
341
  });
358
- g.className = "ago-message__agent", g.textContent = t.agent.displayName || t.agent.name, R.appendChild(g);
342
+ u.className = "ago-message__agent", u.textContent = n.agent.displayName || n.agent.name, z.appendChild(u);
359
343
  }
360
- if (!f && t.sources && t.sources.length > 0) {
361
- const g = h({
344
+ if (!c && n.sources && n.sources.length > 0) {
345
+ const u = g({
362
346
  display: "grid",
363
347
  gridTemplateColumns: "1fr 1fr",
364
348
  gap: "6px",
@@ -366,28 +350,28 @@ function gn(t, o) {
366
350
  width: "100%",
367
351
  maxWidth: "85%"
368
352
  });
369
- g.className = "ago-message__sources", t.sources.forEach((l, c) => {
370
- const w = l.url ? document.createElement("a") : document.createElement("div");
371
- l.url && w instanceof HTMLAnchorElement && (w.href = l.url, w.target = "_blank", w.rel = "noopener noreferrer"), v(w, {
353
+ u.className = "ago-message__sources", n.sources.forEach((x, y) => {
354
+ const d = x.url ? document.createElement("a") : document.createElement("div");
355
+ x.url && d instanceof HTMLAnchorElement && (d.href = x.url, d.target = "_blank", d.rel = "noopener noreferrer"), E(d, {
372
356
  display: "flex",
373
357
  alignItems: "center",
374
358
  gap: "8px",
375
359
  padding: "8px 10px",
376
- border: `1px solid ${N}`,
360
+ border: `1px solid ${T}`,
377
361
  borderRadius: "8px",
378
- backgroundColor: te,
362
+ backgroundColor: ne,
379
363
  textDecoration: "none",
380
- color: ee,
364
+ color: te,
381
365
  fontSize: "12px",
382
366
  overflow: "hidden"
383
367
  });
384
- const B = h({
368
+ const h = g({
385
369
  flexShrink: "0",
386
370
  width: "18px",
387
371
  height: "18px",
388
372
  borderRadius: "3px",
389
- border: `1px solid ${De}`,
390
- color: De,
373
+ border: `1px solid ${Je}`,
374
+ color: Je,
391
375
  fontSize: "11px",
392
376
  fontWeight: "500",
393
377
  display: "flex",
@@ -395,405 +379,482 @@ function gn(t, o) {
395
379
  justifyContent: "center",
396
380
  backgroundColor: "#f0f4ff"
397
381
  });
398
- B.textContent = String(c + 1);
399
- const k = h({
382
+ h.textContent = String(y + 1);
383
+ const _ = g({
400
384
  overflow: "hidden",
401
385
  textOverflow: "ellipsis",
402
386
  whiteSpace: "nowrap"
403
387
  });
404
- k.textContent = l.title, k.title = l.title, w.append(B, k), g.appendChild(w);
405
- }), R.appendChild(g);
388
+ _.textContent = x.title, _.title = x.title, d.append(h, _), u.appendChild(d);
389
+ }), z.appendChild(u);
406
390
  }
407
- if (t.attachments && t.attachments.length > 0) {
408
- const g = h({
391
+ if (n.attachments && n.attachments.length > 0) {
392
+ const u = g({
409
393
  display: "flex",
410
394
  flexWrap: "wrap",
411
395
  gap: "6px",
412
396
  marginBottom: "6px",
413
- justifyContent: f ? "flex-end" : "flex-start",
397
+ justifyContent: c ? "flex-end" : "flex-start",
414
398
  maxWidth: "75%"
415
399
  });
416
- g.className = "ago-message__attachments";
417
- for (const l of t.attachments) {
418
- const c = Qt(l.url);
419
- if (qt(l) && c) {
400
+ u.className = "ago-message__attachments";
401
+ for (const x of n.attachments) {
402
+ const y = bn(x.url);
403
+ if (mn(x) && y) {
420
404
  const M = document.createElement("a");
421
- M.href = c, M.target = "_blank", M.rel = "noopener noreferrer", v(M, {
405
+ M.href = y, M.target = "_blank", M.rel = "noopener noreferrer", E(M, {
422
406
  display: "inline-block",
423
407
  textDecoration: "none"
424
408
  });
425
- const q = document.createElement("img");
426
- q.src = c, q.alt = l.name, q.loading = "lazy", v(q, {
409
+ const j = document.createElement("img");
410
+ j.src = y, j.alt = x.name, j.loading = "lazy", E(j, {
427
411
  maxWidth: "180px",
428
412
  maxHeight: "160px",
429
413
  objectFit: "cover",
430
414
  borderRadius: "10px",
431
- border: `1px solid ${N}`,
415
+ border: `1px solid ${T}`,
432
416
  display: "block"
433
- }), M.appendChild(q), g.appendChild(M);
417
+ }), M.appendChild(j), u.appendChild(M);
434
418
  continue;
435
419
  }
436
- const w = c ? document.createElement("a") : document.createElement("div");
437
- c && w instanceof HTMLAnchorElement && (w.href = c, w.target = "_blank", w.rel = "noopener noreferrer"), v(w, {
420
+ const d = y ? document.createElement("a") : document.createElement("div");
421
+ y && d instanceof HTMLAnchorElement && (d.href = y, d.target = "_blank", d.rel = "noopener noreferrer"), E(d, {
438
422
  display: "inline-flex",
439
423
  alignItems: "center",
440
424
  gap: "8px",
441
425
  padding: "8px 12px",
442
426
  borderRadius: "10px",
443
- border: `1px solid ${N}`,
444
- backgroundColor: f ? "rgba(255,255,255,0.12)" : te,
445
- color: f ? _e : ee,
427
+ border: `1px solid ${T}`,
428
+ backgroundColor: c ? "rgba(255,255,255,0.12)" : ne,
429
+ color: c ? Me : te,
446
430
  fontSize: "13px",
447
431
  textDecoration: "none",
448
432
  maxWidth: "220px"
449
433
  });
450
- const B = document.createElement("span");
451
- B.textContent = "📄", B.setAttribute("aria-hidden", "true"), v(B, {
434
+ const h = document.createElement("span");
435
+ h.textContent = "📄", h.setAttribute("aria-hidden", "true"), E(h, {
452
436
  fontSize: "16px",
453
437
  lineHeight: "1",
454
438
  flexShrink: "0"
455
439
  });
456
- const k = h({
440
+ const _ = g({
457
441
  display: "flex",
458
442
  flexDirection: "column",
459
443
  minWidth: "0"
460
- }), V = h({
444
+ }), K = g({
461
445
  overflow: "hidden",
462
446
  textOverflow: "ellipsis",
463
447
  whiteSpace: "nowrap",
464
448
  maxWidth: "160px"
465
449
  });
466
- V.textContent = l.name, V.title = l.name, k.appendChild(V);
467
- const j = Yt(l.fileSize);
468
- if (j) {
469
- const M = h({
450
+ K.textContent = x.name, K.title = x.name, _.appendChild(K);
451
+ const D = xn(x.fileSize);
452
+ if (D) {
453
+ const M = g({
470
454
  fontSize: "11px",
471
- color: wt
455
+ color: Bt
472
456
  });
473
- M.textContent = j, k.appendChild(M);
457
+ M.textContent = D, _.appendChild(M);
474
458
  }
475
- w.append(B, k), g.appendChild(w);
459
+ d.append(h, _), u.appendChild(d);
476
460
  }
477
- R.appendChild(g);
461
+ z.appendChild(u);
478
462
  }
479
- const A = f || C || I, Q = !!t.content || t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT", D = h({
480
- maxWidth: A ? I || f ? p ? "88%" : "75%" : p ? "92%" : "85%" : "100%",
481
- padding: A ? "10px 14px" : "2px 8px",
482
- borderRadius: I ? an : A ? ze : "0",
483
- backgroundColor: f ? Ae : A ? gt : "transparent",
484
- color: f ? _e : ee,
463
+ const F = c || k || A, B = !!n.content || n.status === "IN_PROGRESS" || n.status === "WAITING_CLIENT", I = g({
464
+ maxWidth: F ? A || c ? f ? "88%" : "75%" : f ? "92%" : "85%" : "100%",
465
+ padding: F ? "10px 14px" : "2px 8px",
466
+ borderRadius: A ? An : F ? Ye : "0",
467
+ backgroundColor: c ? Te : F ? Lt : "transparent",
468
+ color: c ? Me : te,
485
469
  overflowWrap: "break-word",
486
470
  textWrap: "pretty",
487
471
  fontSize: "16px",
488
472
  lineHeight: "1.6"
489
473
  });
490
- if (D.className = "ago-message__content", I && r) {
491
- D.style.position = "relative";
492
- const g = h({
474
+ if (I.className = "ago-message__content", A && i) {
475
+ I.style.position = "relative";
476
+ const u = g({
493
477
  position: "absolute",
494
478
  zIndex: "0",
495
479
  bottom: "-2px",
496
480
  width: "20px",
497
481
  height: "20px",
498
- background: f ? Ae : gt
482
+ background: c ? Te : Lt
499
483
  });
500
- g.className = "ago-message__tail";
501
- const l = h({
484
+ u.className = "ago-message__tail";
485
+ const x = g({
502
486
  position: "absolute",
503
487
  zIndex: "1",
504
488
  bottom: "-2px",
505
489
  width: "10px",
506
490
  height: "20px",
507
- background: yt
491
+ background: Ot
508
492
  });
509
- l.className = "ago-message__tail-mask", f ? (g.style.right = "-8px", g.style.borderBottomLeftRadius = "16px 14px", l.style.right = "-10px", l.style.borderBottomLeftRadius = "10px") : (g.style.left = "-7px", g.style.borderBottomRightRadius = "16px 14px", l.style.left = "-10px", l.style.borderBottomRightRadius = "10px"), D.append(g, l);
493
+ x.className = "ago-message__tail-mask", c ? (u.style.right = "-8px", u.style.borderBottomLeftRadius = "16px 14px", x.style.right = "-10px", x.style.borderBottomLeftRadius = "10px") : (u.style.left = "-7px", u.style.borderBottomRightRadius = "16px 14px", x.style.left = "-10px", x.style.borderBottomRightRadius = "10px"), I.append(u, x);
510
494
  }
511
- if (t.content ? D.appendChild(We(t.content)) : (t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT") && D.appendChild(xn()), Q && R.appendChild(D), i && t.followUpReplies && t.followUpReplies.length > 0) {
512
- const g = h({
495
+ if (n.content ? I.appendChild(et(n.content)) : (n.status === "IN_PROGRESS" || n.status === "WAITING_CLIENT") && I.appendChild(On()), B && z.appendChild(I), r && n.followUpReplies && n.followUpReplies.length > 0) {
496
+ const u = g({
513
497
  display: "flex",
514
498
  flexWrap: "wrap",
515
499
  gap: "8px",
516
500
  marginTop: "10px"
517
501
  });
518
- g.className = "ago-message__followups";
519
- for (const l of t.followUpReplies) {
520
- const c = document.createElement("button");
521
- c.type = "button", c.className = "ago-message__followup-btn", c.textContent = l, c.disabled = !m, v(c, {
522
- minHeight: "36px",
502
+ u.className = "ago-message__followups";
503
+ for (const x of n.followUpReplies) {
504
+ const y = document.createElement("button");
505
+ y.type = "button", y.className = "ago-message__followup-btn", y.textContent = x, y.disabled = !m, E(y, {
506
+ minHeight: "44px",
523
507
  padding: "6px 14px",
524
508
  fontSize: "14px",
525
- borderRadius: ze,
526
- border: `1px solid ${N}`,
527
- backgroundColor: te,
528
- color: ee,
509
+ borderRadius: Ye,
510
+ border: `1px solid ${T}`,
511
+ backgroundColor: ne,
512
+ color: te,
529
513
  cursor: m ? "pointer" : "default",
530
514
  transition: "border-color 0.15s"
531
- }), x && c.addEventListener("click", () => x(l)), c.addEventListener("mouseenter", () => {
532
- c.style.borderColor = De;
533
- }), c.addEventListener("mouseleave", () => {
534
- c.style.borderColor = N;
535
- }), g.appendChild(c);
515
+ }), v && y.addEventListener("click", () => v(x)), y.addEventListener("mouseenter", () => {
516
+ y.style.borderColor = Je;
517
+ }), y.addEventListener("mouseleave", () => {
518
+ y.style.borderColor = T;
519
+ }), u.appendChild(y);
536
520
  }
537
- R.appendChild(g);
521
+ z.appendChild(u);
538
522
  }
539
- return R;
523
+ return z;
540
524
  }
541
- function hn(t) {
542
- const o = h({
525
+ function Mn(n) {
526
+ const o = g({
543
527
  display: "flex",
544
528
  alignItems: "center",
545
529
  gap: "8px",
546
530
  padding: "10px 14px",
547
531
  backgroundColor: "#f0fdf4",
548
532
  color: "#15803d",
549
- borderRadius: ze,
533
+ borderRadius: Ye,
550
534
  marginTop: "8px",
551
535
  fontSize: "13px",
552
536
  border: "1px solid #bbf7d0"
553
537
  });
554
538
  o.className = "ago-form-notice", o.setAttribute("role", "status");
555
- const i = document.createElement("span");
556
- i.textContent = "✓", i.setAttribute("aria-hidden", "true"), v(i, { fontWeight: "700" });
557
539
  const r = document.createElement("span");
558
- return r.textContent = t, o.append(i, r), o;
540
+ r.textContent = "✓", r.setAttribute("aria-hidden", "true"), E(r, { fontWeight: "700" });
541
+ const i = document.createElement("span");
542
+ return i.textContent = n, o.append(r, i), o;
559
543
  }
560
- function xn() {
561
- const t = h({
544
+ function On() {
545
+ const n = g({
562
546
  display: "flex",
563
547
  gap: "4px",
564
548
  padding: "4px 0"
565
549
  });
566
550
  for (let o = 0; o < 3; o++) {
567
- const i = h({
551
+ const r = g({
568
552
  width: "6px",
569
553
  height: "6px",
570
554
  borderRadius: "50%",
571
- backgroundColor: "#b5bfc8",
555
+ backgroundColor: "currentColor",
556
+ opacity: "0.55",
572
557
  animation: "ago-pulse 1.2s ease-in-out infinite",
573
558
  animationDelay: `${o * 0.2}s`
574
559
  });
575
- t.appendChild(i);
560
+ n.appendChild(r);
576
561
  }
577
- return t;
562
+ return n;
578
563
  }
579
- function bn() {
580
- const t = "http://www.w3.org/2000/svg", o = document.createElementNS(t, "svg");
564
+ function Bn() {
565
+ const n = "http://www.w3.org/2000/svg", o = document.createElementNS(n, "svg");
581
566
  o.setAttribute("width", "26"), o.setAttribute("height", "26"), o.setAttribute("viewBox", "0 0 24 24"), o.setAttribute("fill", "none");
582
- const i = document.createElementNS(t, "path");
583
- return i.setAttribute("d", "M21 11.5a8.38 8.38 0 0 1-8.5 8.5 8.5 8.5 0 0 1-3.8-.9L3 21l1.9-5.7a8.5 8.5 0 0 1-.9-3.8 8.38 8.38 0 0 1 8.5-8.5 8.38 8.38 0 0 1 8.5 8.5z"), i.setAttribute("stroke", "currentColor"), i.setAttribute("stroke-width", "2"), i.setAttribute("stroke-linecap", "round"), i.setAttribute("stroke-linejoin", "round"), o.appendChild(i), o;
567
+ const r = document.createElementNS(n, "path");
568
+ return r.setAttribute("d", "M21 11.5a8.38 8.38 0 0 1-8.5 8.5 8.5 8.5 0 0 1-3.8-.9L3 21l1.9-5.7a8.5 8.5 0 0 1-.9-3.8 8.38 8.38 0 0 1 8.5-8.5 8.38 8.38 0 0 1 8.5 8.5z"), r.setAttribute("stroke", "currentColor"), r.setAttribute("stroke-width", "2"), r.setAttribute("stroke-linecap", "round"), r.setAttribute("stroke-linejoin", "round"), o.appendChild(r), o;
584
569
  }
585
- var bt = "Form submitted.";
586
- function vn(t) {
587
- if (typeof t == "string") return t || null;
588
- if (!t || typeof t != "object") return null;
589
- const o = t;
570
+ var Mt = "Form submitted.";
571
+ function Dn(n) {
572
+ if (typeof n == "string") return n || null;
573
+ if (!n || typeof n != "object") return null;
574
+ const o = n;
590
575
  if (typeof o.message == "string" && o.message) return o.message;
591
- const i = o.result;
592
- if (typeof i == "string" && i) return i;
593
- if (i && typeof i == "object") {
594
- const r = i.message;
595
- if (typeof r == "string" && r) return r;
576
+ const r = o.result;
577
+ if (typeof r == "string" && r) return r;
578
+ if (r && typeof r == "object") {
579
+ const i = r.message;
580
+ if (typeof i == "string" && i) return i;
596
581
  }
597
582
  return null;
598
583
  }
599
- var yn = 0, He = 0, Pe = 0;
600
- function vt() {
601
- if (He++ > 0) return;
602
- Pe = window.scrollY;
603
- const { style: t } = document.body;
604
- t.position = "fixed", t.top = `-${Pe}px`, t.left = "0", t.right = "0", t.width = "100%", document.documentElement.style.overflow = "hidden";
605
- }
606
- function Re() {
607
- if (He === 0 || --He > 0) return;
608
- const { style: t } = document.body;
609
- t.removeProperty("position"), t.removeProperty("top"), t.removeProperty("left"), t.removeProperty("right"), t.removeProperty("width"), document.documentElement.style.removeProperty("overflow"), window.scrollTo(0, Pe);
610
- }
611
- function wn(t) {
612
- const o = typeof t == "string" ? document.querySelector(t) : t;
613
- if (!o) throw new Error(`mountChatWidget: target "${String(t)}" not found.`);
584
+ var Hn = 0;
585
+ function zn(n) {
586
+ const o = typeof n == "string" ? document.querySelector(n) : n;
587
+ if (!o) throw new Error(`mountChatWidget: target "${String(n)}" not found.`);
614
588
  return o;
615
589
  }
616
- function kn(t, o) {
617
- const { title: i = "Chat", welcomeMessage: r = "Hello! How can I help you today?", placeholder: b = "Type a message...", allowFiles: a = !1, height: C = 500, placement: m = "inline", width: x = 400, defaultOpen: p = !1, logoUrl: f, showAgentName: I = !1, agentBubble: R = !1, bubbleStyle: A = "default", showHeader: Q = !0, theme: D, loadThreads: g = !1, forms: l, formSubmittedMessage: c = bt, onFollowUpClick: w, onMessageSent: B, onMessageReceived: k, onFormSubmitted: V, onFormError: j, onOpen: M, onClose: q } = o, oe = typeof r == "string" ? {
618
- message: r,
590
+ function qn(n, o) {
591
+ const { title: r = "Chat", welcomeMessage: i = "Hello! How can I help you today?", placeholder: w = "Type a message...", allowFiles: s = !1, allowStop: k = !0, height: m = 500, placement: v = "inline", width: f = 400, defaultOpen: c = !1, logoUrl: A, showAgentName: z = !1, agentBubble: F = !1, bubbleStyle: B = "default", showHeader: I = !0, theme: u, loadThreads: x = !1, forms: y, formSubmittedMessage: d = Mt, onFollowUpClick: h, onMessageSent: _, onMessageReceived: K, onFormSubmitted: D, onFormError: M, onOpen: j, onClose: tt } = o, re = typeof i == "string" ? {
592
+ message: i,
619
593
  mode: "static"
620
- } : r, Ue = oe.message, Ge = oe.mode ?? "static", It = "speed" in oe && oe.speed || 45, Ve = "followUpReplies" in oe && oe.followUpReplies || void 0;
621
- if (!o.client && !o.config?.baseUrl) throw new Kt("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
622
- const E = o.client ?? new Zt(o.config), je = wn(t), z = m === "left" || m === "right", At = z && (o.launcher ?? !0);
623
- let Z = z ? p : !0, me = !1;
624
- const _t = o.mobile?.breakpoint ?? 768, Le = o.mobile?.trigger ?? "tap", qe = typeof window < "u" && !!window.matchMedia, T = qe ? window.matchMedia(`(max-width: ${_t}px)`) : void 0, Lt = qe ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, re = !z && !!T, Ne = o.persistConversation, ge = Ne ? Jt(Ne === !0 ? {} : Ne) : void 0;
625
- let P = o.conversationId ?? ge?.getLastActiveThread() ?? void 0, u = [], J = !1, le = null, K;
626
- const Ke = [];
627
- function Nt(e) {
628
- if (typeof c == "function") {
629
- const s = c(e);
630
- if (typeof s == "string" && s) return s;
594
+ } : i, nt = re.message, ot = re.mode ?? "static", Wt = "speed" in re && re.speed || 45, it = "followUpReplies" in re && re.followUpReplies || void 0;
595
+ if (!o.client && !o.config?.baseUrl) throw new hn("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
596
+ const C = o.client ?? new yn(o.config), rt = zn(n), L = v === "left" || v === "right", Ut = L && (o.launcher ?? !0);
597
+ let oe = L ? c : !0, Oe = !1;
598
+ const Gt = o.mobile?.breakpoint ?? 768, Be = o.mobile?.trigger ?? "tap", st = typeof window < "u" && !!window.matchMedia, O = st ? window.matchMedia(`(max-width: ${Gt}px), (max-height: 500px) and (orientation: landscape)`) : void 0, jt = st ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, Vt = !!O, fe = !L && !!O, ue = /* @__PURE__ */ Symbol("ago-scroll-lock");
599
+ let se = !1;
600
+ const De = o.persistConversation, be = De ? wn(De === !0 ? {} : De) : void 0;
601
+ let V = o.conversationId ?? be?.getLastActiveThread() ?? void 0, p = [], ye = [], q = !1, ae = null, Q;
602
+ const He = [];
603
+ function qt(e) {
604
+ if (typeof d == "function") {
605
+ const l = d(e);
606
+ if (typeof l == "string" && l) return l;
631
607
  }
632
- const n = vn(e);
633
- return n || (typeof c == "string" ? c : bt);
608
+ const t = Dn(e);
609
+ return t || (typeof d == "string" ? d : Mt);
634
610
  }
635
- const he = [], d = h({
611
+ const we = [], a = g({
636
612
  display: "flex",
637
613
  flexDirection: "column",
638
- height: z ? "100%" : typeof C == "number" ? `${C}px` : C,
639
- border: `1px solid ${N}`,
640
- borderRadius: rn,
614
+ height: L ? "100%" : typeof m == "number" ? `${m}px` : m,
615
+ border: `1px solid ${T}`,
616
+ borderRadius: En,
641
617
  overflow: "hidden",
642
- backgroundColor: te,
643
- fontFamily: ke,
618
+ backgroundColor: ne,
619
+ fontFamily: $e,
644
620
  textAlign: "left",
645
621
  boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
646
622
  });
647
- d.className = "ago-chat-widget", sn(d, D);
648
- let F;
649
- if (Q) {
650
- if (F = h({
623
+ a.className = "ago-chat-widget", Rn(a, u);
624
+ let W;
625
+ if (I) {
626
+ if (W = g({
651
627
  padding: "14px 16px",
652
- borderBottom: `1px solid ${N}`,
653
- backgroundColor: on,
654
- color: mt,
628
+ borderBottom: `1px solid ${T}`,
629
+ backgroundColor: Sn,
630
+ color: $t,
655
631
  display: "flex",
656
632
  alignItems: "center",
657
633
  gap: "10px"
658
- }), F.className = "ago-chat-widget__header", f) {
659
- const n = document.createElement("img");
660
- n.src = f, n.alt = "Logo", v(n, {
634
+ }), W.className = "ago-chat-widget__header", A) {
635
+ const t = document.createElement("img");
636
+ t.src = A, t.alt = "Logo", E(t, {
661
637
  height: "24px",
662
638
  width: "auto"
663
- }), F.appendChild(n);
639
+ }), W.appendChild(t);
664
640
  }
665
641
  const e = document.createElement("h3");
666
- if (e.textContent = i, v(e, {
642
+ if (e.textContent = r, E(e, {
667
643
  margin: "0",
668
644
  fontSize: "15px",
669
645
  fontWeight: "600"
670
- }), F.appendChild(e), z) {
671
- const n = document.createElement("button");
672
- n.type = "button", n.className = "ago-chat-widget__close", n.setAttribute("aria-label", "Close"), n.textContent = "×", v(n, {
646
+ }), W.appendChild(e), L) {
647
+ const t = document.createElement("button");
648
+ t.type = "button", t.className = "ago-chat-widget__close", t.setAttribute("aria-label", "Close"), t.textContent = "×", E(t, {
673
649
  marginLeft: "auto",
650
+ flexShrink: "0",
651
+ display: "flex",
652
+ alignItems: "center",
653
+ justifyContent: "center",
654
+ width: "44px",
655
+ height: "44px",
656
+ margin: "-10px -10px -10px auto",
674
657
  background: "transparent",
675
658
  border: "none",
676
- color: mt,
659
+ color: $t,
677
660
  fontSize: "22px",
678
661
  lineHeight: "1",
679
662
  cursor: "pointer",
680
- padding: "0 2px"
681
- }), n.addEventListener("click", () => Oe()), F.appendChild(n);
663
+ padding: "0"
664
+ }), t.addEventListener("click", () => Ie()), W.appendChild(t);
682
665
  }
683
666
  }
684
- const _ = h({
667
+ const S = g({
685
668
  flex: "1",
686
669
  overflow: "auto",
687
670
  overscrollBehavior: "contain",
688
671
  padding: "16px",
689
- backgroundColor: yt
672
+ backgroundColor: Ot
690
673
  });
691
- _.className = "ago-chat-widget__messages", _.setAttribute("role", "log"), _.setAttribute("aria-live", "polite"), _.setAttribute("aria-relevant", "additions text"), _.setAttribute("aria-atomic", "false");
692
- const { inputRow: Te, setDisabled: Tt, focus: xe } = dn({
693
- placeholder: b,
694
- allowFiles: a,
695
- onSend: (e, n) => {
696
- we(e, n);
674
+ S.className = "ago-chat-widget__messages", S.setAttribute("role", "log"), S.setAttribute("aria-live", "polite"), S.setAttribute("aria-relevant", "additions text"), S.setAttribute("aria-atomic", "false");
675
+ const Xt = 48;
676
+ let le = !0, ze = 0;
677
+ function ve(e) {
678
+ ze++;
679
+ try {
680
+ e();
681
+ } finally {
682
+ const t = () => {
683
+ ze--;
684
+ };
685
+ typeof queueMicrotask == "function" ? queueMicrotask(t) : t();
697
686
  }
687
+ }
688
+ function Kt() {
689
+ return S.scrollHeight - S.scrollTop - S.clientHeight <= Xt;
690
+ }
691
+ const J = document.createElement("button");
692
+ J.type = "button", J.className = "ago-chat-widget__jump", J.setAttribute("aria-label", "Jump to latest message"), J.innerHTML = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14M19 12l-7 7-7-7"/></svg>', E(J, {
693
+ position: "absolute",
694
+ left: "50%",
695
+ bottom: "12px",
696
+ transform: "translateX(-50%)",
697
+ width: "44px",
698
+ height: "44px",
699
+ display: "none",
700
+ alignItems: "center",
701
+ justifyContent: "center",
702
+ border: `1px solid ${T}`,
703
+ borderRadius: "50%",
704
+ backgroundColor: ne,
705
+ color: te,
706
+ boxShadow: "rgba(15, 15, 15, 0.16) 0px 2px 10px 0px",
707
+ cursor: "pointer",
708
+ zIndex: "2"
709
+ }), J.addEventListener("click", () => {
710
+ le = !0, ve(() => {
711
+ S.scrollTop = S.scrollHeight;
712
+ }), Fe();
713
+ });
714
+ function Fe() {
715
+ J.style.display = le ? "none" : "flex";
716
+ }
717
+ function Pe() {
718
+ le && ve(() => {
719
+ S.scrollTop = S.scrollHeight;
720
+ }), Fe();
721
+ }
722
+ S.addEventListener("scroll", () => {
723
+ ze > 0 || (le = Kt(), Fe());
698
724
  });
699
- ln(), d.append(...F ? [F] : [], _, Te);
700
- let be = d, U, $;
701
- const ve = m === "left" ? "left" : "right";
702
- if (z && (U = h({
725
+ const at = g({
726
+ position: "relative",
727
+ flex: "1",
728
+ display: "flex",
729
+ minHeight: "0"
730
+ });
731
+ at.append(S, J);
732
+ const { inputRow: We, setDisabled: Qt, focus: Ce, restoreDraft: Jt } = In({
733
+ placeholder: w,
734
+ allowFiles: s,
735
+ onSend: (e, t) => {
736
+ Re(e, t);
737
+ },
738
+ onStop: k ? () => {
739
+ vt();
740
+ } : void 0
741
+ });
742
+ kn(), a.append(...W ? [W] : [], at, We);
743
+ let Ee = a, $, H;
744
+ const Se = v === "left" ? "left" : "right";
745
+ if (L && ($ = g({
703
746
  position: "fixed",
704
747
  top: "0",
705
748
  bottom: "0",
706
- [ve]: "0",
707
- width: typeof x == "number" ? `${x}px` : x,
749
+ [Se]: "0",
750
+ width: typeof f == "number" ? `${f}px` : f,
708
751
  maxWidth: "100vw",
709
752
  display: "flex",
710
753
  zIndex: "2147483000",
711
754
  transition: "transform 0.3s ease",
712
755
  boxShadow: "rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"
713
- }), U.className = "ago-chat-widget-panel", v(d, {
756
+ }), $.className = "ago-chat-widget-panel", E(a, {
714
757
  height: "100%",
715
758
  width: "100%",
716
759
  borderRadius: "0",
717
760
  border: "none",
718
761
  boxShadow: "none",
719
- [ve === "left" ? "borderRight" : "borderLeft"]: `1px solid ${N}`
720
- }), U.appendChild(d), be = U), At) {
721
- if ($ = document.createElement("button"), $.type = "button", $.className = "ago-chat-widget-launcher", $.setAttribute("aria-label", `Open ${i}`), v($, {
762
+ [Se === "left" ? "borderRight" : "borderLeft"]: `1px solid ${T}`
763
+ }), $.appendChild(a), Ee = $), Ut) {
764
+ if (H = document.createElement("button"), H.type = "button", H.className = "ago-chat-widget-launcher", H.setAttribute("aria-label", `Open ${r}`), E(H, {
722
765
  position: "fixed",
723
766
  bottom: "20px",
724
- [ve]: "20px",
767
+ [Se]: "20px",
725
768
  width: "56px",
726
769
  height: "56px",
727
770
  borderRadius: "50%",
728
771
  border: "none",
729
- backgroundColor: Ae,
730
- color: _e,
772
+ backgroundColor: Te,
773
+ color: Me,
731
774
  cursor: "pointer",
732
775
  display: "flex",
733
776
  alignItems: "center",
734
777
  justifyContent: "center",
735
778
  zIndex: "2147483000",
736
779
  boxShadow: "rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",
737
- fontFamily: ke
738
- }), f) {
780
+ fontFamily: $e
781
+ }), A) {
739
782
  const e = document.createElement("img");
740
- e.src = f, e.alt = "", v(e, {
783
+ e.src = A, e.alt = "", E(e, {
741
784
  width: "26px",
742
785
  height: "26px",
743
786
  objectFit: "contain"
744
- }), $.appendChild(e);
745
- } else $.appendChild(bn());
746
- $.addEventListener("click", () => Me());
787
+ }), H.appendChild(e);
788
+ } else H.appendChild(Bn());
789
+ H.addEventListener("click", () => je());
747
790
  }
748
- const de = re ? `ago-vt-${++yn}` : "", Xe = 52;
749
- let W = !1, ce = 0, ie = 0, H, pe, X;
750
- const ye = {
751
- height: d.style.height,
752
- border: d.style.border,
753
- borderRadius: d.style.borderRadius,
754
- boxShadow: d.style.boxShadow
791
+ const me = fe ? `ago-vt-${++Hn}` : "", lt = 52;
792
+ let X = !1, Y = 0, de = 0, U, he, Z;
793
+ const Ae = {
794
+ height: a.style.height,
795
+ border: a.style.border,
796
+ borderRadius: a.style.borderRadius,
797
+ boxShadow: a.style.boxShadow
755
798
  };
756
- je.appendChild(be), $ && je.appendChild($), Ce(), re && (H = Gt(), d.insertBefore(H, d.firstChild), pe = document.createElement("style"), pe.id = de, pe.textContent = `::view-transition-group(${de}),::view-transition-group(${de}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(pe), (Le === "focus" || Le === "tap") && (d.addEventListener("pointerdown", (e) => {
757
- if (W || !T?.matches) return;
758
- const n = Te.contains(e.target);
759
- if (Le === "tap") {
799
+ rt.appendChild(Ee), H && rt.appendChild(H), ke(), fe && (U = pn(), a.insertBefore(U, a.firstChild), he = document.createElement("style"), he.id = me, he.textContent = `::view-transition-group(${me}),::view-transition-group(${me}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(he), (Be === "focus" || Be === "tap") && (a.addEventListener("pointerdown", (e) => {
800
+ if (X || !O?.matches) return;
801
+ const t = We.contains(e.target);
802
+ if (Be === "tap") {
760
803
  if ((e.target instanceof Element ? e.target : null)?.closest("button,a[href],[role='button']")) return;
761
- } else if (!n) return;
762
- n && e.preventDefault(), fe();
763
- }, !0), d.addEventListener("focusin", (e) => {
764
- T?.matches && Te.contains(e.target) && fe();
765
- })), document.addEventListener("keydown", it)), T && T.addEventListener("change", at);
766
- const $t = w !== !1, Bt = w === !1 ? void 0 : w ?? ((e) => {
767
- re && T?.matches && !W ? fe().then(() => we(e)) : we(e);
804
+ } else if (!t) return;
805
+ t && e.preventDefault(), ge();
806
+ }, !0), a.addEventListener("focusin", (e) => {
807
+ O?.matches && We.contains(e.target) && ge();
808
+ }))), Vt && document.addEventListener("keydown", Et), O && O.addEventListener("change", St);
809
+ const Yt = h !== !1, Zt = h === !1 ? void 0 : h ?? ((e) => {
810
+ fe && O?.matches && !X ? ge().then(() => Re(e)) : Re(e);
768
811
  });
769
- function L() {
770
- if (_.replaceChildren(), u.length === 0) {
771
- if (Ge === "static") {
772
- const n = h({
812
+ function dt(e) {
813
+ const t = p.length - 1;
814
+ return {
815
+ isLast: e === t,
816
+ isLastOfBlock: e === t || p[e + 1].role !== p[e].role,
817
+ bubbleStyle: B,
818
+ showAgentName: z,
819
+ agentBubble: F,
820
+ followUpEnabled: Yt,
821
+ followUpHandler: Zt,
822
+ isMobile: !!O?.matches
823
+ };
824
+ }
825
+ function en() {
826
+ if (ae || He.length > 0) return !1;
827
+ const e = p.length - 1, t = p[e];
828
+ if (!t || t.role !== "assistant") return !1;
829
+ const l = ye[e];
830
+ if (!l || l.parentNode !== S) return !1;
831
+ const R = Tt(t, dt(e));
832
+ return ve(() => S.replaceChild(R, l)), ye[e] = R, Pe(), !0;
833
+ }
834
+ function N() {
835
+ ve(tn), Pe();
836
+ const e = p[p.length - 1], t = q && e?.role === "assistant" && (e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT");
837
+ S.setAttribute("aria-busy", t ? "true" : "false"), Qt(t);
838
+ }
839
+ function tn() {
840
+ if (S.replaceChildren(), ye = [], p.length === 0) {
841
+ if (ot === "static") {
842
+ const e = g({
773
843
  textAlign: "center",
774
- color: wt,
844
+ color: Bt,
775
845
  padding: "24px 16px",
776
846
  fontSize: "16px",
777
847
  lineHeight: "1.5"
778
848
  });
779
- n.appendChild(We(Ue)), _.appendChild(n);
849
+ e.appendChild(et(nt)), S.appendChild(e);
780
850
  }
781
- } else u.forEach((n, s) => {
782
- const S = s === u.length - 1 || u[s + 1].role !== n.role;
783
- _.appendChild(gn(n, {
784
- isLast: s === u.length - 1,
785
- isLastOfBlock: S,
786
- bubbleStyle: A,
787
- showAgentName: I,
788
- agentBubble: R,
789
- followUpEnabled: $t,
790
- followUpHandler: Bt,
791
- isMobile: !!T?.matches
792
- }));
851
+ } else p.forEach((e, t) => {
852
+ const l = Tt(e, dt(t));
853
+ ye[t] = l, S.appendChild(l);
793
854
  });
794
- for (const n of Ke) _.appendChild(hn(n));
795
- if (le) {
796
- const n = h({
855
+ for (const e of He) S.appendChild(Mn(e));
856
+ if (ae) {
857
+ const e = g({
797
858
  padding: "10px 14px",
798
859
  backgroundColor: "#fef2f2",
799
860
  color: "#dc2626",
@@ -802,37 +863,37 @@ function kn(t, o) {
802
863
  fontSize: "13px",
803
864
  border: "1px solid #fecaca"
804
865
  });
805
- n.setAttribute("role", "alert"), n.textContent = le, _.appendChild(n);
866
+ e.setAttribute("role", "alert"), e.textContent = ae, S.appendChild(e);
806
867
  }
807
- _.scrollTop = _.scrollHeight;
808
- const e = u[u.length - 1];
809
- Tt(J && e?.role === "assistant" && (e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT"));
810
868
  }
811
- function Mt() {
812
- for (let e = u.length - 1; e >= 0; e--) {
813
- const n = u[e];
814
- if (n.role === "assistant" && (n.status === "IN_PROGRESS" || n.status === "WAITING_CLIENT")) return n;
869
+ function ct() {
870
+ for (let e = p.length - 1; e >= 0; e--) {
871
+ const t = p[e];
872
+ if (t.role === "assistant" && (t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT")) return t;
815
873
  }
816
874
  }
817
- const Ye = (e) => {
818
- P || (P = e.conversationId);
819
- }, Qe = (e) => {
820
- const n = Mt();
821
- n && (n.content += e.content, L());
822
- }, Ze = (e) => {
823
- const n = u.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
824
- n >= 0 ? u[n] = e : u.push(e), L(), xe();
825
- }, Je = (e) => {
826
- const n = u.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
827
- n >= 0 ? u[n] = e : u.push(e), J = !1, L(), e.status === "DONE" && k?.({
875
+ const pt = (e) => {
876
+ V || (V = e.conversationId);
877
+ }, ft = (e) => {
878
+ const t = ct();
879
+ t && (t.content += e.content, en() || N());
880
+ }, ut = (e) => {
881
+ const t = p.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
882
+ t >= 0 ? p[t] = e : p.push(e), N(), Ve() || Ce();
883
+ }, mt = (e) => {
884
+ const t = p.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
885
+ t >= 0 ? p[t] = e : p.push(e), q = !1, N(), e.status === "DONE" && K?.({
828
886
  id: e.id,
829
887
  content: e.content
830
888
  });
831
- }, et = (e) => {
832
- le = e.error, J = !1, u = u.filter((n) => !n.id.startsWith("temp-")), L();
889
+ }, ht = () => {
890
+ const e = ct();
891
+ e && (e.content ? e.status = "CANCELED" : p = p.filter((t) => t !== e)), q = !1, N();
892
+ }, gt = (e) => {
893
+ ae = e.error, q = !1, p = p.filter((t) => !t.id.startsWith("temp-")), N();
833
894
  };
834
- function Ot(e) {
835
- const n = {
895
+ function nn(e) {
896
+ const t = {
836
897
  id: `ago-intro-${Date.now()}`,
837
898
  conversationId: "",
838
899
  content: "",
@@ -840,240 +901,267 @@ function kn(t, o) {
840
901
  status: "IN_PROGRESS",
841
902
  createdAt: /* @__PURE__ */ new Date()
842
903
  };
843
- u.push(n), L();
844
- const s = e.match(/\S+\s*/g) ?? [e];
845
- let S = 0;
846
- K = setInterval(() => {
847
- if (S >= s.length) {
848
- clearInterval(K), K = void 0, n.status = "DONE", Ve && (n.followUpReplies = Ve), L();
904
+ p.push(t), N();
905
+ const l = e.match(/\S+\s*/g) ?? [e];
906
+ let R = 0;
907
+ Q = setInterval(() => {
908
+ if (R >= l.length) {
909
+ clearInterval(Q), Q = void 0, t.status = "DONE", it && (t.followUpReplies = it), N();
849
910
  return;
850
911
  }
851
- n.content += s[S], S++, L();
852
- }, It);
912
+ t.content += l[R], R++, N();
913
+ }, Wt);
853
914
  }
854
- E.on("message:start", Ye), E.on("message:chunk", Qe), E.on("message:answer-complete", Ze), E.on("message:complete", Je), E.on("message:error", et);
855
- const tt = (e) => V?.(e), nt = (e) => j?.(e);
856
- V && E.on("form:submitted", tt), j && E.on("form:error", nt);
857
- const $e = [];
858
- let ot = !1;
859
- const rt = (e) => {
860
- if (ot) return;
861
- $e.push(e.install(E));
862
- let n = e.store.get().submitted;
863
- const s = e.store.subscribe((S) => {
864
- S.submitted && !n && (Ke.push(Nt(S.submitResult)), L()), n = S.submitted;
915
+ C.on("message:start", pt), C.on("message:chunk", ft), C.on("message:answer-complete", ut), C.on("message:complete", mt), C.on("message:stopped", ht), C.on("message:error", gt);
916
+ const xt = (e) => D?.(e), bt = (e) => M?.(e);
917
+ D && C.on("form:submitted", xt), M && C.on("form:error", bt);
918
+ const Ue = [];
919
+ let yt = !1;
920
+ const wt = (e) => {
921
+ if (yt) return;
922
+ Ue.push(e.install(C));
923
+ let t = e.store.get().submitted;
924
+ const l = e.store.subscribe((R) => {
925
+ R.submitted && !t && (He.push(qt(R.submitResult)), N()), t = R.submitted;
865
926
  });
866
- $e.push(s);
927
+ Ue.push(l);
867
928
  };
868
- for (const e of l ?? []) e.schema != null ? rt(tn(e)) : en(E, e).then((n) => rt(n)).catch(() => {
929
+ for (const e of y ?? []) e.schema != null ? wt(Cn(e)) : vn(C, e).then((t) => wt(t)).catch(() => {
869
930
  });
870
- async function we(e, n) {
871
- const s = e.trim();
872
- if (!s && !n?.length || J) return;
873
- if (B?.(s), J = !0, le = null, K) {
874
- clearInterval(K), K = void 0;
875
- const y = u.find((G) => G.id.startsWith("ago-intro-"));
876
- y && !y.content ? u = u.filter((G) => G !== y) : y && (y.status = "DONE");
931
+ async function Re(e, t) {
932
+ const l = e.trim();
933
+ if (!l && !t?.length || q) return;
934
+ if (_?.(l), q = !0, ae = null, le = !0, Q) {
935
+ clearInterval(Q), Q = void 0;
936
+ const b = p.find((G) => G.id.startsWith("ago-intro-"));
937
+ b && !b.content ? p = p.filter((G) => G !== b) : b && (b.status = "DONE");
877
938
  }
878
- const S = Date.now();
879
- u.push({
880
- id: `temp-user-${S}`,
881
- conversationId: P || "",
882
- content: s,
939
+ const R = Date.now();
940
+ p.push({
941
+ id: `temp-user-${R}`,
942
+ conversationId: V || "",
943
+ content: l,
883
944
  role: "user",
884
945
  status: "DONE",
885
- attachments: n && n.length > 0 ? Xt(n) : void 0,
946
+ attachments: t && t.length > 0 ? gn(t) : void 0,
886
947
  createdAt: /* @__PURE__ */ new Date()
887
- }), u.push({
888
- id: `temp-assistant-${S}`,
889
- conversationId: P || "",
948
+ }), p.push({
949
+ id: `temp-assistant-${R}`,
950
+ conversationId: V || "",
890
951
  content: "",
891
952
  role: "assistant",
892
953
  status: "IN_PROGRESS",
893
954
  createdAt: /* @__PURE__ */ new Date()
894
- }), L();
955
+ }), N();
895
956
  try {
896
- const y = await E.sendMessage(s, {
897
- conversationId: P,
898
- files: n
957
+ const b = await C.sendMessage(l, {
958
+ conversationId: V,
959
+ files: t
899
960
  });
900
- y.conversationId && (P || (P = y.conversationId), ge?.setActiveThread(y.conversationId, y.createdAt));
901
- const G = u.find((Y) => Y.id === `temp-user-${S}`);
902
- if (G && (G.id = `user-${S}`, G.conversationId = y.conversationId), !u.some((Y) => Y.id === y.id)) {
903
- const Y = u.findIndex((jt) => jt.id === `temp-assistant-${S}`);
904
- Y >= 0 ? u[Y] = y : u.push(y);
961
+ b.conversationId && (V || (V = b.conversationId), be?.setActiveThread(b.conversationId, b.createdAt));
962
+ const G = p.find((ee) => ee.id === `temp-user-${R}`);
963
+ if (G && (G.id = `user-${R}`, G.conversationId = b.conversationId), b.id && !p.some((ee) => ee.id === b.id)) {
964
+ const ee = p.findIndex((un) => un.id === `temp-assistant-${R}`);
965
+ ee >= 0 ? p[ee] = b : p.push(b);
905
966
  }
906
- u = u.filter((Y) => !Y.id.startsWith("temp-")), y.status !== "WAITING_CLIENT" && (J = !1), L(), g && Be();
907
- } catch (y) {
908
- le = y instanceof Error ? y.message : "Failed to send message", J = !1, u = u.filter((G) => !G.id.startsWith("temp-")), L();
967
+ p = p.filter((ee) => !ee.id.startsWith("temp-")), b.status !== "WAITING_CLIENT" && (q = !1), N(), x && Ge();
968
+ } catch (b) {
969
+ ae = b instanceof Error ? b.message : "Failed to send message", q = !1, p = p.filter((G) => !G.id.startsWith("temp-")), Jt(l, t), N();
909
970
  }
910
971
  }
911
- async function Be() {
972
+ async function vt() {
973
+ q && await C.stop();
974
+ }
975
+ async function Ge() {
912
976
  try {
913
- const { data: e } = await E.getConversations();
914
- he.splice(0, he.length, ...e);
977
+ const { data: e } = await C.getConversations();
978
+ we.splice(0, we.length, ...e);
915
979
  } catch {
916
980
  }
917
- return he;
981
+ return we;
918
982
  }
919
- async function Dt(e) {
983
+ async function on(e) {
920
984
  try {
921
- const n = (await E.getConversation(e))?.messages ?? [];
922
- n.length > 0 && u.length === 0 && (u = n, L());
985
+ const t = (await C.getConversation(e))?.messages ?? [];
986
+ t.length > 0 && p.length === 0 && (p = t, N());
923
987
  } catch {
924
- u.length === 0 && (ge?.clear(), P = void 0);
988
+ p.length === 0 && (be?.clear(), V = void 0);
925
989
  }
926
990
  }
927
- return L(), re && T?.matches || xe(), P ? Dt(P) : Ge === "streaming" && Ot(Ue), g && Be(), {
928
- client: E,
929
- element: be,
930
- sendMessage: we,
931
- ...z || re ? {
932
- open: Ft,
933
- close: Ht,
934
- toggle: Pt
991
+ return N(), fe && O?.matches || Ce(), V ? on(V) : ot === "streaming" && nn(nt), x && Ge(), {
992
+ client: C,
993
+ element: Ee,
994
+ sendMessage: Re,
995
+ stop: vt,
996
+ ...L || fe ? {
997
+ open: sn,
998
+ close: an,
999
+ toggle: ln
935
1000
  } : {},
936
- session: ge,
937
- threads: he,
938
- refreshThreads: Be,
1001
+ session: be,
1002
+ threads: we,
1003
+ refreshThreads: Ge,
939
1004
  destroy() {
940
- K && clearInterval(K), E.off("message:start", Ye), E.off("message:chunk", Qe), E.off("message:answer-complete", Ze), E.off("message:complete", Je), E.off("message:error", et), V && E.off("form:submitted", tt), j && E.off("form:error", nt), ot = !0, $e.forEach((e) => e()), be.remove(), $?.remove(), H?.remove(), pe?.remove(), X?.remove(), T?.removeEventListener("change", at), re && (document.removeEventListener("keydown", it), dt(), W && Re()), me && (me = !1, Re()), o.client || E.destroy();
1005
+ se || (se = !0, Q && clearInterval(Q), C.off("message:start", pt), C.off("message:chunk", ft), C.off("message:answer-complete", ut), C.off("message:complete", mt), C.off("message:stopped", ht), C.off("message:error", gt), D && C.off("form:submitted", xt), M && C.off("form:error", bt), yt = !0, Ue.forEach((e) => e()), Ee.remove(), H?.remove(), U?.remove(), he?.remove(), Z?.remove(), O?.removeEventListener("change", St), document.removeEventListener("keydown", Et), Ke(), Oe = !1, Qe(ue), o.client || C.destroy());
941
1006
  }
942
1007
  };
943
- function Ce() {
944
- if (!U) return;
1008
+ function ke() {
1009
+ if (!$) return;
945
1010
  {
946
- const s = ve === "left" ? "border-right" : "border-left";
947
- T?.matches ? (U.style.width = "100%", d.style.borderRadius = "0", d.style.removeProperty(s)) : (U.style.width = typeof x == "number" ? `${x}px` : x, d.style.setProperty(s, `1px solid ${N}`));
1011
+ const l = Se === "left" ? "border-right" : "border-left";
1012
+ O?.matches ? ($.style.width = "100%", a.style.borderRadius = "0", a.style.removeProperty(l)) : ($.style.width = typeof f == "number" ? `${f}px` : f, a.style.setProperty(l, `1px solid ${T}`));
948
1013
  }
949
- const e = m === "left" ? "translateX(-100%)" : "translateX(100%)";
950
- U.style.transform = Z ? "translateX(0)" : e, U.setAttribute("aria-hidden", Z ? "false" : "true"), $ && ($.style.display = Z ? "none" : "flex");
951
- const n = Z && !!T?.matches;
952
- n !== me && (me = n, n ? vt() : Re());
1014
+ const e = v === "left" ? "translateX(-100%)" : "translateX(100%)";
1015
+ $.style.transform = oe ? "translateX(0)" : e, $.setAttribute("aria-hidden", oe ? "false" : "true"), H && (H.style.display = oe ? "none" : "flex");
1016
+ const t = Ct();
1017
+ t !== Oe && (Oe = t, t ? (a.setAttribute("role", "dialog"), a.setAttribute("aria-modal", "true"), a.setAttribute("aria-label", r), a.tabIndex = -1, a.style.paddingBottom = "env(safe-area-inset-bottom)", _t(ue), Y = qe(), Xe(), At()) : (Ke(), cn(), Y = 0, a.removeAttribute("role"), a.removeAttribute("aria-modal"), a.removeAttribute("aria-label"), a.style.removeProperty("padding-bottom"), Qe(ue)));
1018
+ }
1019
+ function je() {
1020
+ oe = !0, ke(), Ve() ? a.focus({ preventScroll: !0 }) : Ce(), j?.();
1021
+ }
1022
+ function Ie() {
1023
+ oe = !1, ke(), tt?.();
953
1024
  }
954
- function Me() {
955
- Z = !0, Ce(), xe(), M?.();
1025
+ function rn() {
1026
+ oe ? Ie() : je();
956
1027
  }
957
- function Oe() {
958
- Z = !1, Ce(), q?.();
1028
+ function sn() {
1029
+ L ? je() : ge();
959
1030
  }
960
- function zt() {
961
- Z ? Oe() : Me();
1031
+ function an() {
1032
+ L ? Ie() : xe();
962
1033
  }
963
- function Ft() {
964
- z ? Me() : fe();
1034
+ function ln() {
1035
+ L ? rn() : X ? xe() : ge();
965
1036
  }
966
- function Ht() {
967
- z ? Oe() : ue();
1037
+ function Ve() {
1038
+ return !!O?.matches;
968
1039
  }
969
- function Pt() {
970
- z ? zt() : W ? ue() : fe();
1040
+ function Ct() {
1041
+ return Ve() && (L ? oe : X);
971
1042
  }
972
- function Wt() {
973
- return Array.from(d.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((e) => e.getClientRects().length > 0);
1043
+ function dn() {
1044
+ return Array.from(a.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((e) => e.getClientRects().length > 0);
974
1045
  }
975
- function it(e) {
976
- if (!W) return;
1046
+ function Et(e) {
1047
+ if (!Ct()) return;
977
1048
  if (e.key === "Escape") {
978
- ue();
1049
+ L ? Ie() : xe();
979
1050
  return;
980
1051
  }
981
1052
  if (e.key !== "Tab") return;
982
- const n = Wt();
983
- if (n.length === 0) {
1053
+ const t = dn();
1054
+ if (t.length === 0) {
984
1055
  e.preventDefault();
985
1056
  return;
986
1057
  }
987
- const s = n[0], S = n[n.length - 1], y = document.activeElement;
988
- e.shiftKey && (y === s || !d.contains(y)) ? (e.preventDefault(), S.focus()) : !e.shiftKey && (y === S || !d.contains(y)) && (e.preventDefault(), s.focus());
1058
+ const l = t[0], R = t[t.length - 1], b = document.activeElement;
1059
+ e.shiftKey && (b === l || !a.contains(b)) ? (e.preventDefault(), R.focus()) : !e.shiftKey && (b === R || !a.contains(b)) && (e.preventDefault(), l.focus());
989
1060
  }
990
- function at(e) {
991
- z ? Ce() : !e.matches && W && ue(), L();
1061
+ function St(e) {
1062
+ L ? ke() : !e.matches && X && xe(), N();
992
1063
  }
993
- function st() {
1064
+ function qe() {
994
1065
  return window.visualViewport?.height ?? window.innerHeight;
995
1066
  }
996
- function lt() {
997
- const e = window.visualViewport, n = e?.offsetTop ?? 0, s = e?.height ?? ce, S = Math.min(0, n + s - ce);
998
- d.style.top = `${S}px`, H && (H.style.top = `${n}px`);
1067
+ function Xe() {
1068
+ const e = window.visualViewport, t = e?.offsetTop ?? 0, l = e?.height ?? Y;
1069
+ if (L) {
1070
+ if (!$) return;
1071
+ const b = window.innerHeight || Y, G = Math.max(0, b - (t + l));
1072
+ $.style.bottom = `${G}px`, $.style.top = `${t}px`;
1073
+ return;
1074
+ }
1075
+ const R = Math.min(0, t + l - Y);
1076
+ a.style.top = `${R}px`, U && (U.style.top = `${t}px`);
999
1077
  }
1000
- function Ee() {
1001
- ie || (ie = requestAnimationFrame(() => {
1002
- ie = 0, lt();
1078
+ function cn() {
1079
+ L && $ && ($.style.removeProperty("bottom"), $.style.removeProperty("top"));
1080
+ }
1081
+ function _e() {
1082
+ de || (de = requestAnimationFrame(() => {
1083
+ de = 0, !se && Xe();
1003
1084
  }));
1004
1085
  }
1005
- function Ut() {
1006
- window.visualViewport?.addEventListener("resize", Ee), window.visualViewport?.addEventListener("scroll", Ee);
1086
+ function At() {
1087
+ window.visualViewport?.addEventListener("resize", _e), window.visualViewport?.addEventListener("scroll", _e);
1007
1088
  }
1008
- function dt() {
1009
- window.visualViewport?.removeEventListener("resize", Ee), window.visualViewport?.removeEventListener("scroll", Ee), ie && (cancelAnimationFrame(ie), ie = 0);
1089
+ function Ke() {
1090
+ window.visualViewport?.removeEventListener("resize", _e), window.visualViewport?.removeEventListener("scroll", _e), de && (cancelAnimationFrame(de), de = 0);
1010
1091
  }
1011
- function ct() {
1012
- _.scrollTop = _.scrollHeight;
1092
+ function Rt() {
1093
+ le = !0, Pe();
1013
1094
  }
1014
- function Gt() {
1015
- const e = h({
1095
+ function pn() {
1096
+ const e = g({
1016
1097
  position: "fixed",
1017
1098
  top: "0",
1018
1099
  left: "0",
1019
1100
  right: "0",
1020
- height: `calc(${Xe}px + env(safe-area-inset-top))`,
1101
+ height: `calc(${lt}px + env(safe-area-inset-top))`,
1021
1102
  display: "none",
1022
1103
  alignItems: "center",
1023
1104
  justifyContent: "space-between",
1024
1105
  padding: "env(safe-area-inset-top) 14px 0",
1025
- backgroundColor: te,
1026
- borderBottom: `1px solid ${N}`,
1106
+ backgroundColor: ne,
1107
+ borderBottom: `1px solid ${T}`,
1027
1108
  zIndex: "2147483001",
1028
- fontFamily: ke
1109
+ fontFamily: $e
1029
1110
  });
1030
- if (e.className = "ago-chat-widget-mobile-bar", f) {
1031
- const s = document.createElement("img");
1032
- s.src = f, s.alt = "", v(s, {
1111
+ if (e.className = "ago-chat-widget-mobile-bar", A) {
1112
+ const l = document.createElement("img");
1113
+ l.src = A, l.alt = "", E(l, {
1033
1114
  height: "28px",
1034
1115
  width: "auto"
1035
- }), e.appendChild(s);
1036
- } else if (i) {
1037
- const s = document.createElement("span");
1038
- s.textContent = i, v(s, {
1116
+ }), e.appendChild(l);
1117
+ } else if (r) {
1118
+ const l = document.createElement("span");
1119
+ l.textContent = r, E(l, {
1039
1120
  fontSize: "15px",
1040
1121
  fontWeight: "600",
1041
- color: ee,
1122
+ color: te,
1042
1123
  overflow: "hidden",
1043
1124
  whiteSpace: "nowrap",
1044
1125
  textOverflow: "ellipsis"
1045
- }), e.appendChild(s);
1046
- } else e.appendChild(h({}));
1047
- const n = document.createElement("button");
1048
- return n.type = "button", n.setAttribute("aria-label", "Close"), n.textContent = "×", v(n, {
1126
+ }), e.appendChild(l);
1127
+ } else e.appendChild(g({}));
1128
+ const t = document.createElement("button");
1129
+ return t.type = "button", t.setAttribute("aria-label", "Close"), t.textContent = "×", E(t, {
1130
+ flexShrink: "0",
1131
+ width: "44px",
1132
+ height: "44px",
1133
+ marginRight: "-10px",
1134
+ display: "flex",
1135
+ alignItems: "center",
1136
+ justifyContent: "center",
1049
1137
  border: "none",
1050
1138
  background: "transparent",
1051
1139
  fontSize: "26px",
1052
1140
  lineHeight: "1",
1053
- color: ee,
1141
+ color: te,
1054
1142
  cursor: "pointer",
1055
- padding: "4px 8px"
1056
- }), n.addEventListener("click", () => {
1057
- ue();
1058
- }), e.appendChild(n), e;
1143
+ padding: "0"
1144
+ }), t.addEventListener("click", () => {
1145
+ xe();
1146
+ }), e.appendChild(t), e;
1059
1147
  }
1060
- function Vt() {
1061
- return typeof document.startViewTransition == "function" && !Lt?.matches && !!T?.matches;
1148
+ function fn() {
1149
+ return typeof document.startViewTransition == "function" && !jt?.matches && !!O?.matches;
1062
1150
  }
1063
- function pt(e) {
1064
- const n = document;
1065
- if (Vt() && n.startViewTransition) {
1066
- d.style.setProperty("view-transition-name", de), H?.style.setProperty("view-transition-name", `${de}-bar`);
1067
- const s = () => {
1068
- d.style.removeProperty("view-transition-name"), H?.style.removeProperty("view-transition-name");
1151
+ function kt(e) {
1152
+ const t = document;
1153
+ if (fn() && t.startViewTransition) {
1154
+ a.style.setProperty("view-transition-name", me), U?.style.setProperty("view-transition-name", `${me}-bar`);
1155
+ const l = () => {
1156
+ a.style.removeProperty("view-transition-name"), U?.style.removeProperty("view-transition-name");
1069
1157
  };
1070
- return n.startViewTransition(e).finished.then(s, s);
1158
+ return t.startViewTransition(e).finished.then(l, l);
1071
1159
  }
1072
1160
  return e(), Promise.resolve();
1073
1161
  }
1074
- function ft(e) {
1162
+ function It(e) {
1075
1163
  if (e)
1076
- X && d.parentElement?.insertBefore(X, d), v(d, {
1164
+ Z && a.parentElement?.insertBefore(Z, a), E(a, {
1077
1165
  position: "fixed",
1078
1166
  top: "0",
1079
1167
  left: "0",
@@ -1084,12 +1172,12 @@ function kn(t, o) {
1084
1172
  border: "none",
1085
1173
  borderRadius: "0",
1086
1174
  boxShadow: "none",
1087
- paddingTop: `calc(${Xe}px + env(safe-area-inset-top))`,
1175
+ paddingTop: `calc(${lt}px + env(safe-area-inset-top))`,
1088
1176
  paddingBottom: "env(safe-area-inset-bottom)"
1089
- }), d.setAttribute("role", "dialog"), d.setAttribute("aria-modal", "true"), d.setAttribute("aria-label", i), vt(), F && (F.style.display = "none"), H && (H.style.display = "flex");
1177
+ }), a.setAttribute("role", "dialog"), a.setAttribute("aria-modal", "true"), a.setAttribute("aria-label", r), W && (W.style.display = "none"), U && (U.style.display = "flex");
1090
1178
  else {
1091
- X?.remove(), X = void 0;
1092
- for (const n of [
1179
+ Z?.remove(), Z = void 0;
1180
+ for (const t of [
1093
1181
  "position",
1094
1182
  "top",
1095
1183
  "left",
@@ -1098,31 +1186,35 @@ function kn(t, o) {
1098
1186
  "z-index",
1099
1187
  "padding-top",
1100
1188
  "padding-bottom"
1101
- ]) d.style.removeProperty(n);
1102
- d.style.height = ye.height, d.style.border = ye.border, d.style.borderRadius = ye.borderRadius, d.style.boxShadow = ye.boxShadow, d.removeAttribute("role"), d.removeAttribute("aria-modal"), d.removeAttribute("aria-label"), Re(), F && (F.style.display = "flex"), H && (H.style.display = "none");
1189
+ ]) a.style.removeProperty(t);
1190
+ a.style.height = Ae.height, a.style.border = Ae.border, a.style.borderRadius = Ae.borderRadius, a.style.boxShadow = Ae.boxShadow, a.removeAttribute("role"), a.removeAttribute("aria-modal"), a.removeAttribute("aria-label"), W && (W.style.display = "flex"), U && (U.style.display = "none");
1103
1191
  }
1104
1192
  }
1105
- function fe() {
1106
- if (W || !T?.matches) return Promise.resolve();
1107
- const e = d.getBoundingClientRect();
1108
- if (e.height >= st() * 0.8) return Promise.resolve();
1109
- W = !0, X = h({
1193
+ function ge() {
1194
+ if (se || X || !O?.matches) return Promise.resolve();
1195
+ const e = a.getBoundingClientRect();
1196
+ if (e.height >= qe() * 0.8) return Promise.resolve();
1197
+ X = !0, Z = g({
1110
1198
  width: `${e.width}px`,
1111
1199
  height: `${e.height}px`
1112
- }), X.className = "ago-chat-widget-spacer", X.setAttribute("aria-hidden", "true"), ce = st(), d.style.setProperty("--ago-vh", `${ce}px`), lt(), Ut();
1113
- const n = pt(() => ft(!0));
1114
- return n.then(() => {
1115
- ct(), xe();
1116
- }), ct(), M?.(), n;
1200
+ }), Z.className = "ago-chat-widget-spacer", Z.setAttribute("aria-hidden", "true"), Y = qe(), a.style.setProperty("--ago-vh", `${Y}px`), Xe(), At(), _t(ue);
1201
+ const t = kt(() => It(!0));
1202
+ return t.then(() => {
1203
+ se || (Rt(), Ce());
1204
+ }), Rt(), j?.(), t;
1117
1205
  }
1118
- function ue() {
1119
- if (!W) return Promise.resolve();
1120
- W = !1, dt(), d.querySelector("textarea")?.blur();
1121
- const e = pt(() => ft(!1));
1122
- return e.then(() => d.style.removeProperty("--ago-vh")), ce = 0, q?.(), e;
1206
+ function xe() {
1207
+ if (!X) return Promise.resolve();
1208
+ X = !1, Ke(), Qe(ue), a.querySelector("textarea")?.blur();
1209
+ const e = kt(() => It(!1));
1210
+ return e.then(() => {
1211
+ se || a.style.removeProperty("--ago-vh");
1212
+ }), Y = 0, tt?.(), e;
1123
1213
  }
1124
1214
  }
1125
1215
  export {
1126
- kn as mountChatWidget,
1127
- We as renderMarkdown
1216
+ Vn as compactMediaQuery,
1217
+ jn as createSheetController,
1218
+ qn as mountChatWidget,
1219
+ et as renderMarkdown
1128
1220
  };