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