@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.
- package/CHANGELOG.md +223 -0
- package/README.md +59 -0
- package/dist/AgoClient-BHegN73y.cjs +9 -0
- package/dist/{AgoClient-B_R_qi2s.js → AgoClient-PWPaekcg.js} +656 -387
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +230 -5
- package/dist/angular.d.ts +230 -5
- package/dist/angular.js +10 -1
- package/dist/{createConversationSession-Dqh7NXK4.cjs → createConversationSession-BbUUukV0.cjs} +1 -1
- package/dist/{createConversationSession-CdtI4vrf.js → createConversationSession-BkruoOVm.js} +1 -1
- package/dist/{createFormCollector-BjO3oB63.cjs → createFormCollector-C1ixsjV0.cjs} +1 -1
- package/dist/{createFormCollector-YwaZ78wU.js → createFormCollector-CvVFNkp6.js} +1 -1
- package/dist/{createMockClient-DcuNlufr.js → createMockClient-BDLW6tVc.js} +5 -2
- package/dist/createMockClient-BSNuN3ys.cjs +1 -0
- package/dist/devtools.d.cts +220 -5
- package/dist/devtools.d.ts +220 -5
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +238 -6
- package/dist/index.d.ts +238 -6
- package/dist/index.js +111 -109
- package/dist/react.cjs +40 -3
- package/dist/react.d.cts +419 -7
- package/dist/react.d.ts +419 -7
- package/dist/react.js +1195 -743
- package/dist/sheetController-CBUVOroo.js +205 -0
- package/dist/sheetController-DY-sC13T.cjs +1 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +220 -5
- package/dist/testing.d.ts +220 -5
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +235 -5
- package/dist/vue.d.ts +235 -5
- package/dist/vue.js +121 -100
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +328 -5
- package/dist/widget.d.ts +328 -5
- package/dist/widget.js +721 -629
- package/llms-full.txt +202 -14
- package/package.json +1 -1
- package/dist/AgoClient-DLB9icvv.cjs +0 -8
- package/dist/createMockClient-Dw-cyISN.cjs +0 -1
package/dist/widget.js
CHANGED
|
@@ -1,364 +1,348 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as
|
|
3
|
-
import { r as
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
43
|
-
|
|
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 ${
|
|
49
|
-
backgroundColor:
|
|
50
|
-
}),
|
|
51
|
-
const
|
|
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
|
-
}),
|
|
20
|
+
}), w = g({
|
|
56
21
|
display: "flex",
|
|
57
22
|
gap: "8px",
|
|
58
23
|
alignItems: "flex-end"
|
|
59
|
-
}),
|
|
60
|
-
|
|
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 ${
|
|
30
|
+
border: `1px solid ${T}`,
|
|
66
31
|
borderRadius: "12px",
|
|
67
32
|
fontSize: "16px",
|
|
68
|
-
fontFamily:
|
|
33
|
+
fontFamily: $e,
|
|
69
34
|
lineHeight: "1.4",
|
|
70
35
|
maxHeight: "110px",
|
|
71
36
|
overflowY: "hidden"
|
|
72
37
|
});
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
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
|
-
|
|
79
|
-
|
|
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>',
|
|
82
|
-
|
|
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: "
|
|
85
|
-
height: "
|
|
49
|
+
width: "44px",
|
|
50
|
+
height: "44px",
|
|
86
51
|
padding: "0",
|
|
87
52
|
border: "none",
|
|
88
53
|
borderRadius: "50%",
|
|
89
|
-
backgroundColor:
|
|
90
|
-
color:
|
|
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
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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:
|
|
80
|
+
backgroundColor: ne,
|
|
107
81
|
cursor: "pointer",
|
|
108
82
|
fontSize: "14px"
|
|
109
|
-
}),
|
|
110
|
-
o = [...o, ...Array.from(
|
|
83
|
+
}), I.addEventListener("click", () => B?.click()), B.addEventListener("change", () => {
|
|
84
|
+
o = [...o, ...Array.from(B?.files ?? [])], u();
|
|
111
85
|
}));
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
const
|
|
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 ${
|
|
94
|
+
border: `1px solid ${T}`,
|
|
121
95
|
borderRadius: "8px",
|
|
122
96
|
fontSize: "12px"
|
|
123
|
-
}),
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
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
|
-
}),
|
|
133
|
-
o = o.filter((
|
|
134
|
-
}),
|
|
135
|
-
}),
|
|
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
|
|
138
|
-
const
|
|
139
|
-
return
|
|
140
|
-
content:
|
|
141
|
-
files:
|
|
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
|
-
},
|
|
144
|
-
const { content:
|
|
145
|
-
(
|
|
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
|
|
148
|
-
|
|
149
|
-
}),
|
|
150
|
-
|
|
151
|
-
}),
|
|
152
|
-
inputRow:
|
|
153
|
-
getValueAndClear:
|
|
154
|
-
setDisabled: (
|
|
155
|
-
|
|
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: () =>
|
|
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
|
|
144
|
+
var _n = {
|
|
161
145
|
"&": "&",
|
|
162
146
|
"<": "<",
|
|
163
147
|
">": ">",
|
|
164
148
|
'"': """,
|
|
165
149
|
"'": "'"
|
|
166
150
|
};
|
|
167
|
-
function
|
|
168
|
-
return
|
|
151
|
+
function ce(n) {
|
|
152
|
+
return n.replace(/[&<>"']/g, (o) => _n[o]);
|
|
169
153
|
}
|
|
170
|
-
function
|
|
171
|
-
const o =
|
|
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
|
|
175
|
-
function
|
|
176
|
-
const o = [],
|
|
177
|
-
let
|
|
178
|
-
return
|
|
179
|
-
const m =
|
|
180
|
-
return m ?
|
|
181
|
-
}),
|
|
182
|
-
const m =
|
|
183
|
-
return m ?
|
|
184
|
-
}),
|
|
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
|
|
187
|
-
const
|
|
188
|
-
return Object.assign(
|
|
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
|
|
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
|
-
],
|
|
198
|
-
function
|
|
199
|
-
return
|
|
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
|
|
202
|
-
const o =
|
|
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:
|
|
189
|
+
listStyleType: i ? "decimal" : "disc",
|
|
206
190
|
listStylePosition: "outside"
|
|
207
191
|
});
|
|
208
|
-
let
|
|
209
|
-
for (;
|
|
210
|
-
const
|
|
211
|
-
for (
|
|
212
|
-
m.push(
|
|
213
|
-
const
|
|
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
|
-
}),
|
|
218
|
-
|
|
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
|
|
204
|
+
return w;
|
|
221
205
|
}
|
|
222
|
-
function
|
|
223
|
-
const o = (m) => m.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((
|
|
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
|
-
}),
|
|
210
|
+
}), i = P("table", {
|
|
227
211
|
borderCollapse: "collapse",
|
|
228
212
|
width: "100%",
|
|
229
213
|
fontSize: "13px"
|
|
230
|
-
}),
|
|
231
|
-
for (const m of o(
|
|
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
|
-
},
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
for (const m of
|
|
241
|
-
const
|
|
242
|
-
for (const
|
|
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
|
-
},
|
|
246
|
-
|
|
229
|
+
}, ie(f)));
|
|
230
|
+
k.appendChild(v);
|
|
247
231
|
}
|
|
248
|
-
return
|
|
232
|
+
return i.appendChild(k), r.appendChild(i), r;
|
|
249
233
|
}
|
|
250
|
-
var
|
|
251
|
-
function
|
|
252
|
-
const o = document.createDocumentFragment(),
|
|
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
|
|
256
|
-
for (;
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
259
|
-
|
|
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
|
|
263
|
-
if (
|
|
264
|
-
const
|
|
265
|
-
for (
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
|
|
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:
|
|
260
|
+
fontFamily: Dt,
|
|
277
261
|
whiteSpace: "pre"
|
|
278
|
-
},
|
|
279
|
-
`)))), o.appendChild(
|
|
262
|
+
}, ce(c.join(`
|
|
263
|
+
`)))), o.appendChild(A);
|
|
280
264
|
continue;
|
|
281
265
|
}
|
|
282
|
-
if (
|
|
283
|
-
o.appendChild(
|
|
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
|
-
})),
|
|
271
|
+
})), i++;
|
|
288
272
|
continue;
|
|
289
273
|
}
|
|
290
|
-
const m =
|
|
274
|
+
const m = s.match(zt);
|
|
291
275
|
if (m) {
|
|
292
|
-
const
|
|
293
|
-
o.appendChild(
|
|
276
|
+
const f = m[1].length;
|
|
277
|
+
o.appendChild(P(`h${f}`, {
|
|
294
278
|
margin: "16px 0 8px 0",
|
|
295
|
-
fontSize:
|
|
279
|
+
fontSize: Ln[f - 1],
|
|
296
280
|
fontWeight: "600",
|
|
297
281
|
lineHeight: "1.3"
|
|
298
|
-
},
|
|
282
|
+
}, ie(m[2]))), i++;
|
|
299
283
|
continue;
|
|
300
284
|
}
|
|
301
|
-
if (
|
|
302
|
-
const
|
|
303
|
-
for (;
|
|
304
|
-
|
|
305
|
-
const
|
|
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
|
-
|
|
313
|
-
`))), o.appendChild(
|
|
296
|
+
c.appendChild(et(f.join(`
|
|
297
|
+
`))), o.appendChild(c);
|
|
314
298
|
continue;
|
|
315
299
|
}
|
|
316
|
-
if (
|
|
317
|
-
const
|
|
318
|
-
for (
|
|
319
|
-
|
|
320
|
-
o.appendChild(
|
|
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 (
|
|
324
|
-
const
|
|
325
|
-
for (;
|
|
326
|
-
if (
|
|
327
|
-
|
|
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(
|
|
313
|
+
o.appendChild(Pt(f));
|
|
330
314
|
continue;
|
|
331
315
|
}
|
|
332
|
-
const
|
|
333
|
-
for (
|
|
334
|
-
|
|
335
|
-
o.appendChild(
|
|
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
|
-
},
|
|
322
|
+
}, v.map((f) => ie(f)).join("<br>")));
|
|
339
323
|
}
|
|
340
|
-
const
|
|
341
|
-
return
|
|
324
|
+
const w = o.lastElementChild;
|
|
325
|
+
return w && (w.style.marginBottom = "0"), o;
|
|
342
326
|
}
|
|
343
|
-
function
|
|
344
|
-
const { isLast:
|
|
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:
|
|
348
|
-
marginBottom:
|
|
331
|
+
alignItems: c ? "flex-end" : "flex-start",
|
|
332
|
+
marginBottom: A && !i ? "2px" : "16px"
|
|
349
333
|
});
|
|
350
|
-
if (
|
|
351
|
-
const
|
|
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:
|
|
338
|
+
color: te,
|
|
355
339
|
marginBottom: "6px",
|
|
356
340
|
padding: "0 4px"
|
|
357
341
|
});
|
|
358
|
-
|
|
342
|
+
u.className = "ago-message__agent", u.textContent = n.agent.displayName || n.agent.name, z.appendChild(u);
|
|
359
343
|
}
|
|
360
|
-
if (!
|
|
361
|
-
const
|
|
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
|
-
|
|
370
|
-
const
|
|
371
|
-
|
|
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 ${
|
|
360
|
+
border: `1px solid ${T}`,
|
|
377
361
|
borderRadius: "8px",
|
|
378
|
-
backgroundColor:
|
|
362
|
+
backgroundColor: ne,
|
|
379
363
|
textDecoration: "none",
|
|
380
|
-
color:
|
|
364
|
+
color: te,
|
|
381
365
|
fontSize: "12px",
|
|
382
366
|
overflow: "hidden"
|
|
383
367
|
});
|
|
384
|
-
const
|
|
368
|
+
const h = g({
|
|
385
369
|
flexShrink: "0",
|
|
386
370
|
width: "18px",
|
|
387
371
|
height: "18px",
|
|
388
372
|
borderRadius: "3px",
|
|
389
|
-
border: `1px solid ${
|
|
390
|
-
color:
|
|
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
|
-
|
|
399
|
-
const
|
|
382
|
+
h.textContent = String(y + 1);
|
|
383
|
+
const _ = g({
|
|
400
384
|
overflow: "hidden",
|
|
401
385
|
textOverflow: "ellipsis",
|
|
402
386
|
whiteSpace: "nowrap"
|
|
403
387
|
});
|
|
404
|
-
|
|
405
|
-
}),
|
|
388
|
+
_.textContent = x.title, _.title = x.title, d.append(h, _), u.appendChild(d);
|
|
389
|
+
}), z.appendChild(u);
|
|
406
390
|
}
|
|
407
|
-
if (
|
|
408
|
-
const
|
|
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:
|
|
397
|
+
justifyContent: c ? "flex-end" : "flex-start",
|
|
414
398
|
maxWidth: "75%"
|
|
415
399
|
});
|
|
416
|
-
|
|
417
|
-
for (const
|
|
418
|
-
const
|
|
419
|
-
if (
|
|
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 =
|
|
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
|
|
426
|
-
|
|
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 ${
|
|
415
|
+
border: `1px solid ${T}`,
|
|
432
416
|
display: "block"
|
|
433
|
-
}), M.appendChild(
|
|
417
|
+
}), M.appendChild(j), u.appendChild(M);
|
|
434
418
|
continue;
|
|
435
419
|
}
|
|
436
|
-
const
|
|
437
|
-
|
|
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 ${
|
|
444
|
-
backgroundColor:
|
|
445
|
-
color:
|
|
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
|
|
451
|
-
|
|
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
|
|
440
|
+
const _ = g({
|
|
457
441
|
display: "flex",
|
|
458
442
|
flexDirection: "column",
|
|
459
443
|
minWidth: "0"
|
|
460
|
-
}),
|
|
444
|
+
}), K = g({
|
|
461
445
|
overflow: "hidden",
|
|
462
446
|
textOverflow: "ellipsis",
|
|
463
447
|
whiteSpace: "nowrap",
|
|
464
448
|
maxWidth: "160px"
|
|
465
449
|
});
|
|
466
|
-
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
469
|
-
const M =
|
|
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:
|
|
455
|
+
color: Bt
|
|
472
456
|
});
|
|
473
|
-
M.textContent =
|
|
457
|
+
M.textContent = D, _.appendChild(M);
|
|
474
458
|
}
|
|
475
|
-
|
|
459
|
+
d.append(h, _), u.appendChild(d);
|
|
476
460
|
}
|
|
477
|
-
|
|
461
|
+
z.appendChild(u);
|
|
478
462
|
}
|
|
479
|
-
const
|
|
480
|
-
maxWidth:
|
|
481
|
-
padding:
|
|
482
|
-
borderRadius:
|
|
483
|
-
backgroundColor:
|
|
484
|
-
color:
|
|
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 (
|
|
491
|
-
|
|
492
|
-
const
|
|
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:
|
|
482
|
+
background: c ? Te : Lt
|
|
499
483
|
});
|
|
500
|
-
|
|
501
|
-
const
|
|
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:
|
|
491
|
+
background: Ot
|
|
508
492
|
});
|
|
509
|
-
|
|
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 (
|
|
512
|
-
const
|
|
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
|
-
|
|
519
|
-
for (const
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
minHeight: "
|
|
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:
|
|
526
|
-
border: `1px solid ${
|
|
527
|
-
backgroundColor:
|
|
528
|
-
color:
|
|
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
|
-
}),
|
|
532
|
-
|
|
533
|
-
}),
|
|
534
|
-
|
|
535
|
-
}),
|
|
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
|
-
|
|
521
|
+
z.appendChild(u);
|
|
538
522
|
}
|
|
539
|
-
return
|
|
523
|
+
return z;
|
|
540
524
|
}
|
|
541
|
-
function
|
|
542
|
-
const o =
|
|
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:
|
|
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
|
-
|
|
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
|
|
561
|
-
const
|
|
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
|
|
551
|
+
const r = g({
|
|
568
552
|
width: "6px",
|
|
569
553
|
height: "6px",
|
|
570
554
|
borderRadius: "50%",
|
|
571
|
-
backgroundColor: "
|
|
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
|
-
|
|
560
|
+
n.appendChild(r);
|
|
576
561
|
}
|
|
577
|
-
return
|
|
562
|
+
return n;
|
|
578
563
|
}
|
|
579
|
-
function
|
|
580
|
-
const
|
|
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
|
|
583
|
-
return
|
|
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
|
|
586
|
-
function
|
|
587
|
-
if (typeof
|
|
588
|
-
if (!
|
|
589
|
-
const o =
|
|
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
|
|
592
|
-
if (typeof
|
|
593
|
-
if (
|
|
594
|
-
const
|
|
595
|
-
if (typeof
|
|
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
|
|
600
|
-
function
|
|
601
|
-
|
|
602
|
-
|
|
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
|
|
617
|
-
const { title:
|
|
618
|
-
message:
|
|
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
|
-
} :
|
|
621
|
-
if (!o.client && !o.config?.baseUrl) throw new
|
|
622
|
-
const
|
|
623
|
-
let
|
|
624
|
-
const
|
|
625
|
-
let
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
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
|
|
633
|
-
return
|
|
608
|
+
const t = Dn(e);
|
|
609
|
+
return t || (typeof d == "string" ? d : Mt);
|
|
634
610
|
}
|
|
635
|
-
const
|
|
611
|
+
const we = [], a = g({
|
|
636
612
|
display: "flex",
|
|
637
613
|
flexDirection: "column",
|
|
638
|
-
height:
|
|
639
|
-
border: `1px solid ${
|
|
640
|
-
borderRadius:
|
|
614
|
+
height: L ? "100%" : typeof m == "number" ? `${m}px` : m,
|
|
615
|
+
border: `1px solid ${T}`,
|
|
616
|
+
borderRadius: En,
|
|
641
617
|
overflow: "hidden",
|
|
642
|
-
backgroundColor:
|
|
643
|
-
fontFamily:
|
|
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
|
-
|
|
648
|
-
let
|
|
649
|
-
if (
|
|
650
|
-
if (
|
|
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 ${
|
|
653
|
-
backgroundColor:
|
|
654
|
-
color:
|
|
628
|
+
borderBottom: `1px solid ${T}`,
|
|
629
|
+
backgroundColor: Sn,
|
|
630
|
+
color: $t,
|
|
655
631
|
display: "flex",
|
|
656
632
|
alignItems: "center",
|
|
657
633
|
gap: "10px"
|
|
658
|
-
}),
|
|
659
|
-
const
|
|
660
|
-
|
|
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
|
-
}),
|
|
639
|
+
}), W.appendChild(t);
|
|
664
640
|
}
|
|
665
641
|
const e = document.createElement("h3");
|
|
666
|
-
if (e.textContent =
|
|
642
|
+
if (e.textContent = r, E(e, {
|
|
667
643
|
margin: "0",
|
|
668
644
|
fontSize: "15px",
|
|
669
645
|
fontWeight: "600"
|
|
670
|
-
}),
|
|
671
|
-
const
|
|
672
|
-
|
|
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:
|
|
659
|
+
color: $t,
|
|
677
660
|
fontSize: "22px",
|
|
678
661
|
lineHeight: "1",
|
|
679
662
|
cursor: "pointer",
|
|
680
|
-
padding: "0
|
|
681
|
-
}),
|
|
663
|
+
padding: "0"
|
|
664
|
+
}), t.addEventListener("click", () => Ie()), W.appendChild(t);
|
|
682
665
|
}
|
|
683
666
|
}
|
|
684
|
-
const
|
|
667
|
+
const S = g({
|
|
685
668
|
flex: "1",
|
|
686
669
|
overflow: "auto",
|
|
687
670
|
overscrollBehavior: "contain",
|
|
688
671
|
padding: "16px",
|
|
689
|
-
backgroundColor:
|
|
672
|
+
backgroundColor: Ot
|
|
690
673
|
});
|
|
691
|
-
|
|
692
|
-
const
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
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
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
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
|
-
[
|
|
707
|
-
width: typeof
|
|
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
|
-
}),
|
|
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
|
-
[
|
|
720
|
-
}),
|
|
721
|
-
if (
|
|
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
|
-
[
|
|
767
|
+
[Se]: "20px",
|
|
725
768
|
width: "56px",
|
|
726
769
|
height: "56px",
|
|
727
770
|
borderRadius: "50%",
|
|
728
771
|
border: "none",
|
|
729
|
-
backgroundColor:
|
|
730
|
-
color:
|
|
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:
|
|
738
|
-
}),
|
|
780
|
+
fontFamily: $e
|
|
781
|
+
}), A) {
|
|
739
782
|
const e = document.createElement("img");
|
|
740
|
-
e.src =
|
|
783
|
+
e.src = A, e.alt = "", E(e, {
|
|
741
784
|
width: "26px",
|
|
742
785
|
height: "26px",
|
|
743
786
|
objectFit: "contain"
|
|
744
|
-
}),
|
|
745
|
-
} else
|
|
746
|
-
|
|
787
|
+
}), H.appendChild(e);
|
|
788
|
+
} else H.appendChild(Bn());
|
|
789
|
+
H.addEventListener("click", () => je());
|
|
747
790
|
}
|
|
748
|
-
const
|
|
749
|
-
let
|
|
750
|
-
const
|
|
751
|
-
height:
|
|
752
|
-
border:
|
|
753
|
-
borderRadius:
|
|
754
|
-
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
|
-
|
|
757
|
-
if (
|
|
758
|
-
const
|
|
759
|
-
if (
|
|
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 (!
|
|
762
|
-
|
|
763
|
-
}, !0),
|
|
764
|
-
|
|
765
|
-
})), document.addEventListener("keydown",
|
|
766
|
-
const
|
|
767
|
-
|
|
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
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
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:
|
|
844
|
+
color: Bt,
|
|
775
845
|
padding: "24px 16px",
|
|
776
846
|
fontSize: "16px",
|
|
777
847
|
lineHeight: "1.5"
|
|
778
848
|
});
|
|
779
|
-
|
|
849
|
+
e.appendChild(et(nt)), S.appendChild(e);
|
|
780
850
|
}
|
|
781
|
-
} else
|
|
782
|
-
const
|
|
783
|
-
|
|
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
|
|
795
|
-
if (
|
|
796
|
-
const
|
|
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
|
-
|
|
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
|
|
812
|
-
for (let e =
|
|
813
|
-
const
|
|
814
|
-
if (
|
|
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
|
|
818
|
-
|
|
819
|
-
},
|
|
820
|
-
const
|
|
821
|
-
|
|
822
|
-
},
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
},
|
|
826
|
-
const
|
|
827
|
-
|
|
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
|
-
},
|
|
832
|
-
|
|
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
|
|
835
|
-
const
|
|
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
|
-
|
|
844
|
-
const
|
|
845
|
-
let
|
|
846
|
-
|
|
847
|
-
if (
|
|
848
|
-
clearInterval(
|
|
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
|
-
|
|
852
|
-
},
|
|
912
|
+
t.content += l[R], R++, N();
|
|
913
|
+
}, Wt);
|
|
853
914
|
}
|
|
854
|
-
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
const
|
|
858
|
-
let
|
|
859
|
-
const
|
|
860
|
-
if (
|
|
861
|
-
|
|
862
|
-
let
|
|
863
|
-
const
|
|
864
|
-
|
|
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
|
-
|
|
927
|
+
Ue.push(l);
|
|
867
928
|
};
|
|
868
|
-
for (const e of
|
|
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
|
|
871
|
-
const
|
|
872
|
-
if (!
|
|
873
|
-
if (
|
|
874
|
-
clearInterval(
|
|
875
|
-
const
|
|
876
|
-
|
|
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
|
|
879
|
-
|
|
880
|
-
id: `temp-user-${
|
|
881
|
-
conversationId:
|
|
882
|
-
content:
|
|
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:
|
|
946
|
+
attachments: t && t.length > 0 ? gn(t) : void 0,
|
|
886
947
|
createdAt: /* @__PURE__ */ new Date()
|
|
887
|
-
}),
|
|
888
|
-
id: `temp-assistant-${
|
|
889
|
-
conversationId:
|
|
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
|
-
}),
|
|
955
|
+
}), N();
|
|
895
956
|
try {
|
|
896
|
-
const
|
|
897
|
-
conversationId:
|
|
898
|
-
files:
|
|
957
|
+
const b = await C.sendMessage(l, {
|
|
958
|
+
conversationId: V,
|
|
959
|
+
files: t
|
|
899
960
|
});
|
|
900
|
-
|
|
901
|
-
const G =
|
|
902
|
-
if (G && (G.id = `user-${
|
|
903
|
-
const
|
|
904
|
-
|
|
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
|
-
|
|
907
|
-
} catch (
|
|
908
|
-
|
|
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
|
|
972
|
+
async function vt() {
|
|
973
|
+
q && await C.stop();
|
|
974
|
+
}
|
|
975
|
+
async function Ge() {
|
|
912
976
|
try {
|
|
913
|
-
const { data: e } = await
|
|
914
|
-
|
|
977
|
+
const { data: e } = await C.getConversations();
|
|
978
|
+
we.splice(0, we.length, ...e);
|
|
915
979
|
} catch {
|
|
916
980
|
}
|
|
917
|
-
return
|
|
981
|
+
return we;
|
|
918
982
|
}
|
|
919
|
-
async function
|
|
983
|
+
async function on(e) {
|
|
920
984
|
try {
|
|
921
|
-
const
|
|
922
|
-
|
|
985
|
+
const t = (await C.getConversation(e))?.messages ?? [];
|
|
986
|
+
t.length > 0 && p.length === 0 && (p = t, N());
|
|
923
987
|
} catch {
|
|
924
|
-
|
|
988
|
+
p.length === 0 && (be?.clear(), V = void 0);
|
|
925
989
|
}
|
|
926
990
|
}
|
|
927
|
-
return
|
|
928
|
-
client:
|
|
929
|
-
element:
|
|
930
|
-
sendMessage:
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
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:
|
|
937
|
-
threads:
|
|
938
|
-
refreshThreads:
|
|
1001
|
+
session: be,
|
|
1002
|
+
threads: we,
|
|
1003
|
+
refreshThreads: Ge,
|
|
939
1004
|
destroy() {
|
|
940
|
-
|
|
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
|
|
944
|
-
if (
|
|
1008
|
+
function ke() {
|
|
1009
|
+
if (!$) return;
|
|
945
1010
|
{
|
|
946
|
-
const
|
|
947
|
-
|
|
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 =
|
|
950
|
-
|
|
951
|
-
const
|
|
952
|
-
|
|
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
|
|
955
|
-
|
|
1025
|
+
function rn() {
|
|
1026
|
+
oe ? Ie() : je();
|
|
956
1027
|
}
|
|
957
|
-
function
|
|
958
|
-
|
|
1028
|
+
function sn() {
|
|
1029
|
+
L ? je() : ge();
|
|
959
1030
|
}
|
|
960
|
-
function
|
|
961
|
-
|
|
1031
|
+
function an() {
|
|
1032
|
+
L ? Ie() : xe();
|
|
962
1033
|
}
|
|
963
|
-
function
|
|
964
|
-
|
|
1034
|
+
function ln() {
|
|
1035
|
+
L ? rn() : X ? xe() : ge();
|
|
965
1036
|
}
|
|
966
|
-
function
|
|
967
|
-
|
|
1037
|
+
function Ve() {
|
|
1038
|
+
return !!O?.matches;
|
|
968
1039
|
}
|
|
969
|
-
function
|
|
970
|
-
|
|
1040
|
+
function Ct() {
|
|
1041
|
+
return Ve() && (L ? oe : X);
|
|
971
1042
|
}
|
|
972
|
-
function
|
|
973
|
-
return Array.from(
|
|
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
|
|
976
|
-
if (!
|
|
1046
|
+
function Et(e) {
|
|
1047
|
+
if (!Ct()) return;
|
|
977
1048
|
if (e.key === "Escape") {
|
|
978
|
-
|
|
1049
|
+
L ? Ie() : xe();
|
|
979
1050
|
return;
|
|
980
1051
|
}
|
|
981
1052
|
if (e.key !== "Tab") return;
|
|
982
|
-
const
|
|
983
|
-
if (
|
|
1053
|
+
const t = dn();
|
|
1054
|
+
if (t.length === 0) {
|
|
984
1055
|
e.preventDefault();
|
|
985
1056
|
return;
|
|
986
1057
|
}
|
|
987
|
-
const
|
|
988
|
-
e.shiftKey && (
|
|
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
|
|
991
|
-
|
|
1061
|
+
function St(e) {
|
|
1062
|
+
L ? ke() : !e.matches && X && xe(), N();
|
|
992
1063
|
}
|
|
993
|
-
function
|
|
1064
|
+
function qe() {
|
|
994
1065
|
return window.visualViewport?.height ?? window.innerHeight;
|
|
995
1066
|
}
|
|
996
|
-
function
|
|
997
|
-
const e = window.visualViewport,
|
|
998
|
-
|
|
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
|
|
1001
|
-
|
|
1002
|
-
|
|
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
|
|
1006
|
-
window.visualViewport?.addEventListener("resize",
|
|
1086
|
+
function At() {
|
|
1087
|
+
window.visualViewport?.addEventListener("resize", _e), window.visualViewport?.addEventListener("scroll", _e);
|
|
1007
1088
|
}
|
|
1008
|
-
function
|
|
1009
|
-
window.visualViewport?.removeEventListener("resize",
|
|
1089
|
+
function Ke() {
|
|
1090
|
+
window.visualViewport?.removeEventListener("resize", _e), window.visualViewport?.removeEventListener("scroll", _e), de && (cancelAnimationFrame(de), de = 0);
|
|
1010
1091
|
}
|
|
1011
|
-
function
|
|
1012
|
-
|
|
1092
|
+
function Rt() {
|
|
1093
|
+
le = !0, Pe();
|
|
1013
1094
|
}
|
|
1014
|
-
function
|
|
1015
|
-
const e =
|
|
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(${
|
|
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:
|
|
1026
|
-
borderBottom: `1px solid ${
|
|
1106
|
+
backgroundColor: ne,
|
|
1107
|
+
borderBottom: `1px solid ${T}`,
|
|
1027
1108
|
zIndex: "2147483001",
|
|
1028
|
-
fontFamily:
|
|
1109
|
+
fontFamily: $e
|
|
1029
1110
|
});
|
|
1030
|
-
if (e.className = "ago-chat-widget-mobile-bar",
|
|
1031
|
-
const
|
|
1032
|
-
|
|
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(
|
|
1036
|
-
} else if (
|
|
1037
|
-
const
|
|
1038
|
-
|
|
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:
|
|
1122
|
+
color: te,
|
|
1042
1123
|
overflow: "hidden",
|
|
1043
1124
|
whiteSpace: "nowrap",
|
|
1044
1125
|
textOverflow: "ellipsis"
|
|
1045
|
-
}), e.appendChild(
|
|
1046
|
-
} else e.appendChild(
|
|
1047
|
-
const
|
|
1048
|
-
return
|
|
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:
|
|
1141
|
+
color: te,
|
|
1054
1142
|
cursor: "pointer",
|
|
1055
|
-
padding: "
|
|
1056
|
-
}),
|
|
1057
|
-
|
|
1058
|
-
}), e.appendChild(
|
|
1143
|
+
padding: "0"
|
|
1144
|
+
}), t.addEventListener("click", () => {
|
|
1145
|
+
xe();
|
|
1146
|
+
}), e.appendChild(t), e;
|
|
1059
1147
|
}
|
|
1060
|
-
function
|
|
1061
|
-
return typeof document.startViewTransition == "function" && !
|
|
1148
|
+
function fn() {
|
|
1149
|
+
return typeof document.startViewTransition == "function" && !jt?.matches && !!O?.matches;
|
|
1062
1150
|
}
|
|
1063
|
-
function
|
|
1064
|
-
const
|
|
1065
|
-
if (
|
|
1066
|
-
|
|
1067
|
-
const
|
|
1068
|
-
|
|
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
|
|
1158
|
+
return t.startViewTransition(e).finished.then(l, l);
|
|
1071
1159
|
}
|
|
1072
1160
|
return e(), Promise.resolve();
|
|
1073
1161
|
}
|
|
1074
|
-
function
|
|
1162
|
+
function It(e) {
|
|
1075
1163
|
if (e)
|
|
1076
|
-
|
|
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(${
|
|
1175
|
+
paddingTop: `calc(${lt}px + env(safe-area-inset-top))`,
|
|
1088
1176
|
paddingBottom: "env(safe-area-inset-bottom)"
|
|
1089
|
-
}),
|
|
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
|
-
|
|
1092
|
-
for (const
|
|
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
|
-
])
|
|
1102
|
-
|
|
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
|
|
1106
|
-
if (
|
|
1107
|
-
const e =
|
|
1108
|
-
if (e.height >=
|
|
1109
|
-
|
|
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
|
-
}),
|
|
1113
|
-
const
|
|
1114
|
-
return
|
|
1115
|
-
|
|
1116
|
-
}),
|
|
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
|
|
1119
|
-
if (!
|
|
1120
|
-
|
|
1121
|
-
const e =
|
|
1122
|
-
return e.then(() =>
|
|
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
|
-
|
|
1127
|
-
|
|
1216
|
+
Vn as compactMediaQuery,
|
|
1217
|
+
jn as createSheetController,
|
|
1218
|
+
qn as mountChatWidget,
|
|
1219
|
+
et as renderMarkdown
|
|
1128
1220
|
};
|