@useago/sdk 1.0.0 → 1.0.1
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/README.md +103 -74
- package/dist/{AgoClient-CPqPT5s6.cjs → AgoClient-0x2Du_62.cjs} +1 -1
- package/dist/{AgoClient-BrYhSO5M.js → AgoClient-CZYNL25R.js} +29 -20
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +89 -0
- package/dist/angular.d.ts +89 -0
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-CGRO0bs2.cjs → createConversationSession-BLZvXMmM.cjs} +1 -1
- package/dist/{createConversationSession-Dmqd80DX.js → createConversationSession-Bmqj2rSS.js} +1 -1
- package/dist/createFormCollector-Bk0DRhUf.js +257 -0
- package/dist/createFormCollector-Ca8wRrxc.cjs +1 -0
- package/dist/devtools.d.cts +89 -0
- package/dist/devtools.d.ts +89 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +47 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +68 -67
- package/dist/react.cjs +23 -23
- package/dist/react.d.cts +74 -23
- package/dist/react.d.ts +74 -23
- package/dist/react.js +2154 -2075
- package/dist/testing.d.cts +89 -0
- package/dist/testing.d.ts +89 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +89 -0
- package/dist/vue.d.ts +89 -0
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +73 -4
- package/dist/widget.d.ts +73 -4
- package/dist/widget.js +410 -317
- package/package.json +1 -1
- package/dist/createFormCollector-CPS2phYq.js +0 -245
- package/dist/createFormCollector-DaWZsBsI.cjs +0 -1
package/dist/widget.js
CHANGED
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
var
|
|
1
|
+
import { t as Xe } from "./AgoClient-CZYNL25R.js";
|
|
2
|
+
import { r as Ke, t as qe } from "./createFormCollector-Bk0DRhUf.js";
|
|
3
|
+
import { t as Ve } from "./createConversationSession-Bmqj2rSS.js";
|
|
4
|
+
var Qe = {
|
|
5
5
|
"&": "&",
|
|
6
6
|
"<": "<",
|
|
7
7
|
">": ">",
|
|
8
8
|
'"': """,
|
|
9
9
|
"'": "'"
|
|
10
10
|
};
|
|
11
|
-
function
|
|
12
|
-
return o.replace(/[&<>"']/g, (n) =>
|
|
11
|
+
function F(o) {
|
|
12
|
+
return o.replace(/[&<>"']/g, (n) => Qe[n]);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function ke(o) {
|
|
15
15
|
const n = o.trim();
|
|
16
16
|
return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(n) || !/^[a-z][a-z0-9+.-]*:/i.test(n) ? n : null;
|
|
17
17
|
}
|
|
18
|
-
var
|
|
19
|
-
function
|
|
20
|
-
const n = [], r = (
|
|
21
|
-
let
|
|
22
|
-
return
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
}),
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
}),
|
|
18
|
+
var Le = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Q = "";
|
|
19
|
+
function M(o) {
|
|
20
|
+
const n = [], r = (u) => (n.push(u), `${Q}${n.length - 1}${Q}`);
|
|
21
|
+
let t = o;
|
|
22
|
+
return t = t.replace(/`([^`]+)`/g, (u, i) => r(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${Le}">${F(i)}</code>`)), t = t.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (u, i, f) => {
|
|
23
|
+
const s = ke(f);
|
|
24
|
+
return s ? r(`<img alt="${F(i)}" src="${F(s)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : u;
|
|
25
|
+
}), t = t.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (u, i, f) => {
|
|
26
|
+
const s = ke(f);
|
|
27
|
+
return s ? r(`<a href="${F(s)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${M(i)}</a>`) : u;
|
|
28
|
+
}), t = F(t), t = t.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>"), t = t.replace(new RegExp(`${Q}(\\d+)${Q}`, "g"), (u, i) => n[Number(i)]), t;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
const
|
|
32
|
-
return Object.assign(
|
|
30
|
+
function R(o, n, r) {
|
|
31
|
+
const t = document.createElement(o);
|
|
32
|
+
return Object.assign(t.style, n), r !== void 0 && (t.innerHTML = r), t;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var Oe = /^ {0,3}([-*_])( *\1){2,} *$/, Te = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, De = /^ {0,3}(```+|~~~+)/, Z = /^ {0,3}>\s?/, P = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, Ye = [
|
|
35
35
|
"20px",
|
|
36
36
|
"18px",
|
|
37
37
|
"16px",
|
|
38
38
|
"15px",
|
|
39
39
|
"14px",
|
|
40
40
|
"13px"
|
|
41
|
-
],
|
|
42
|
-
function
|
|
43
|
-
return o.trim() === "" ||
|
|
41
|
+
], ce = (o) => o.match(/^\s*/)?.[0].length ?? 0;
|
|
42
|
+
function Ze(o) {
|
|
43
|
+
return o.trim() === "" || Oe.test(o) || Te.test(o) || De.test(o) || Z.test(o) || P.test(o);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const n = o[0].match(
|
|
45
|
+
function Me(o) {
|
|
46
|
+
const n = o[0].match(P), r = n[1].length, t = /\d/.test(n[2]), u = R(t ? "ol" : "ul", {
|
|
47
47
|
margin: "0 0 8px 0",
|
|
48
48
|
paddingLeft: "20px",
|
|
49
|
-
listStyleType:
|
|
49
|
+
listStyleType: t ? "decimal" : "disc",
|
|
50
50
|
listStylePosition: "outside"
|
|
51
51
|
});
|
|
52
|
-
let
|
|
53
|
-
for (;
|
|
54
|
-
const
|
|
55
|
-
for (
|
|
56
|
-
|
|
57
|
-
const
|
|
52
|
+
let i = 0;
|
|
53
|
+
for (; i < o.length; ) {
|
|
54
|
+
const f = o[i].match(P), s = [];
|
|
55
|
+
for (i++; i < o.length && ce(o[i]) > r; )
|
|
56
|
+
s.push(o[i]), i++;
|
|
57
|
+
const p = R("li", {
|
|
58
58
|
display: "list-item",
|
|
59
59
|
margin: "2px 0",
|
|
60
60
|
lineHeight: "1.6"
|
|
61
|
-
}),
|
|
62
|
-
|
|
61
|
+
}), c = f[3].match(/^\[([ xX])\]\s+(.*)$/);
|
|
62
|
+
c ? (p.style.listStyleType = "none", p.style.marginLeft = "-20px", p.innerHTML = `<span style="margin-right:6px">${c[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${M(c[2])}`) : p.innerHTML = M(f[3]), s.filter((m) => P.test(m)).length > 0 && p.appendChild(Me(s.filter((m) => m.trim() !== ""))), u.appendChild(p);
|
|
63
63
|
}
|
|
64
|
-
return
|
|
64
|
+
return u;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
const n = (
|
|
66
|
+
function Je(o) {
|
|
67
|
+
const n = (s) => s.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((p) => p.trim()), r = R("div", {
|
|
68
68
|
overflowX: "auto",
|
|
69
69
|
margin: "0 0 8px 0"
|
|
70
|
-
}),
|
|
70
|
+
}), t = R("table", {
|
|
71
71
|
borderCollapse: "collapse",
|
|
72
72
|
width: "100%",
|
|
73
73
|
fontSize: "13px"
|
|
74
|
-
}),
|
|
75
|
-
for (const
|
|
74
|
+
}), u = document.createElement("thead"), i = document.createElement("tr");
|
|
75
|
+
for (const s of n(o[0])) i.appendChild(R("th", {
|
|
76
76
|
border: "1px solid #dee3e8",
|
|
77
77
|
padding: "6px 10px",
|
|
78
78
|
textAlign: "left",
|
|
79
79
|
backgroundColor: "#f5f7fa",
|
|
80
80
|
fontWeight: "600"
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
for (const
|
|
85
|
-
const
|
|
86
|
-
for (const
|
|
81
|
+
}, M(s)));
|
|
82
|
+
u.appendChild(i), t.appendChild(u);
|
|
83
|
+
const f = document.createElement("tbody");
|
|
84
|
+
for (const s of o.slice(2)) {
|
|
85
|
+
const p = document.createElement("tr");
|
|
86
|
+
for (const c of n(s)) p.appendChild(R("td", {
|
|
87
87
|
border: "1px solid #dee3e8",
|
|
88
88
|
padding: "6px 10px"
|
|
89
|
-
},
|
|
90
|
-
|
|
89
|
+
}, M(c)));
|
|
90
|
+
f.appendChild(p);
|
|
91
91
|
}
|
|
92
|
-
return
|
|
92
|
+
return t.appendChild(f), r.appendChild(t), r;
|
|
93
93
|
}
|
|
94
|
-
var
|
|
95
|
-
function
|
|
94
|
+
var et = (o) => !!o && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(o);
|
|
95
|
+
function Be(o) {
|
|
96
96
|
const n = document.createDocumentFragment(), r = o.replace(/\r\n?/g, `
|
|
97
97
|
`).split(`
|
|
98
98
|
`);
|
|
99
|
-
let
|
|
100
|
-
for (;
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
103
|
-
|
|
99
|
+
let t = 0;
|
|
100
|
+
for (; t < r.length; ) {
|
|
101
|
+
const i = r[t];
|
|
102
|
+
if (i.trim() === "") {
|
|
103
|
+
t++;
|
|
104
104
|
continue;
|
|
105
105
|
}
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
for (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
106
|
+
const f = i.match(De);
|
|
107
|
+
if (f) {
|
|
108
|
+
const c = f[1][0], m = [];
|
|
109
|
+
for (t++; t < r.length && !new RegExp(`^ {0,3}${c === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(r[t]); )
|
|
110
|
+
m.push(r[t]), t++;
|
|
111
|
+
t++;
|
|
112
|
+
const L = R("pre", { margin: "0 0 8px 0" });
|
|
113
|
+
L.appendChild(R("code", {
|
|
114
114
|
display: "block",
|
|
115
115
|
background: "#f5f5f5",
|
|
116
116
|
padding: "8px 12px",
|
|
117
117
|
borderRadius: "6px",
|
|
118
118
|
fontSize: "13px",
|
|
119
119
|
overflowX: "auto",
|
|
120
|
-
fontFamily:
|
|
120
|
+
fontFamily: Le,
|
|
121
121
|
whiteSpace: "pre"
|
|
122
|
-
},
|
|
123
|
-
`)))), n.appendChild(
|
|
122
|
+
}, F(m.join(`
|
|
123
|
+
`)))), n.appendChild(L);
|
|
124
124
|
continue;
|
|
125
125
|
}
|
|
126
|
-
if (
|
|
127
|
-
n.appendChild(
|
|
126
|
+
if (Oe.test(i)) {
|
|
127
|
+
n.appendChild(R("hr", {
|
|
128
128
|
border: "none",
|
|
129
129
|
borderTop: "1px solid #dee3e8",
|
|
130
130
|
margin: "12px 0"
|
|
131
|
-
})),
|
|
131
|
+
})), t++;
|
|
132
132
|
continue;
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
const
|
|
137
|
-
n.appendChild(
|
|
134
|
+
const s = i.match(Te);
|
|
135
|
+
if (s) {
|
|
136
|
+
const c = s[1].length;
|
|
137
|
+
n.appendChild(R(`h${c}`, {
|
|
138
138
|
margin: "16px 0 8px 0",
|
|
139
|
-
fontSize:
|
|
139
|
+
fontSize: Ye[c - 1],
|
|
140
140
|
fontWeight: "600",
|
|
141
141
|
lineHeight: "1.3"
|
|
142
|
-
},
|
|
142
|
+
}, M(s[2]))), t++;
|
|
143
143
|
continue;
|
|
144
144
|
}
|
|
145
|
-
if (
|
|
146
|
-
const
|
|
147
|
-
for (;
|
|
148
|
-
|
|
149
|
-
const
|
|
145
|
+
if (Z.test(i)) {
|
|
146
|
+
const c = [];
|
|
147
|
+
for (; t < r.length && Z.test(r[t]); )
|
|
148
|
+
c.push(r[t].replace(Z, "")), t++;
|
|
149
|
+
const m = R("blockquote", {
|
|
150
150
|
borderLeft: "4px solid #dee3e8",
|
|
151
151
|
paddingLeft: "12px",
|
|
152
152
|
margin: "0 0 8px 0",
|
|
153
153
|
fontStyle: "italic",
|
|
154
154
|
color: "#6b6d6f"
|
|
155
155
|
});
|
|
156
|
-
|
|
157
|
-
`))), n.appendChild(
|
|
156
|
+
m.appendChild(Be(c.join(`
|
|
157
|
+
`))), n.appendChild(m);
|
|
158
158
|
continue;
|
|
159
159
|
}
|
|
160
|
-
if (
|
|
161
|
-
const
|
|
162
|
-
for (
|
|
163
|
-
|
|
164
|
-
n.appendChild(
|
|
160
|
+
if (i.includes("|") && et(r[t + 1])) {
|
|
161
|
+
const c = [i, r[t + 1]];
|
|
162
|
+
for (t += 2; t < r.length && r[t].includes("|") && r[t].trim(); )
|
|
163
|
+
c.push(r[t]), t++;
|
|
164
|
+
n.appendChild(Je(c));
|
|
165
165
|
continue;
|
|
166
166
|
}
|
|
167
|
-
if (
|
|
168
|
-
const
|
|
169
|
-
for (;
|
|
170
|
-
if (
|
|
171
|
-
|
|
167
|
+
if (P.test(i)) {
|
|
168
|
+
const c = [], m = ce(i);
|
|
169
|
+
for (; t < r.length && r[t].trim() !== ""; )
|
|
170
|
+
if (P.test(r[t]) || ce(r[t]) > m)
|
|
171
|
+
c.push(r[t]), t++;
|
|
172
172
|
else break;
|
|
173
|
-
n.appendChild(
|
|
173
|
+
n.appendChild(Me(c));
|
|
174
174
|
continue;
|
|
175
175
|
}
|
|
176
|
-
const
|
|
177
|
-
for (
|
|
178
|
-
|
|
179
|
-
n.appendChild(
|
|
176
|
+
const p = [i];
|
|
177
|
+
for (t++; t < r.length && !Ze(r[t]); )
|
|
178
|
+
p.push(r[t]), t++;
|
|
179
|
+
n.appendChild(R("p", {
|
|
180
180
|
margin: "0 0 8px 0",
|
|
181
181
|
lineHeight: "1.6"
|
|
182
|
-
},
|
|
182
|
+
}, p.map((c) => M(c)).join("<br>")));
|
|
183
183
|
}
|
|
184
|
-
const
|
|
185
|
-
return
|
|
184
|
+
const u = n.lastElementChild;
|
|
185
|
+
return u && (u.style.marginBottom = "0"), n;
|
|
186
186
|
}
|
|
187
|
-
var
|
|
187
|
+
var pe = 'var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)', $e = {
|
|
188
188
|
font: "--ago-font",
|
|
189
189
|
radius: "--ago-radius",
|
|
190
190
|
messageRadius: "--ago-message-radius",
|
|
@@ -198,109 +198,172 @@ var Ce = 'var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "S
|
|
|
198
198
|
mutedText: "--ago-muted-text-color",
|
|
199
199
|
border: "--ago-border-color",
|
|
200
200
|
accent: "--ago-accent-color"
|
|
201
|
-
},
|
|
202
|
-
function
|
|
201
|
+
}, fe = "var(--ago-brand-color, #03182f)", ue = "var(--ago-brand-text-color, #fff)", tt = "var(--ago-header-background, var(--ago-brand-color, #03182f))", Ie = "var(--ago-header-text-color, #e8f0fe)", j = "var(--ago-panel-background, #fff)", nt = "var(--ago-messages-background, #fbfbfb)", Y = "var(--ago-text-color, #30373e)", ot = "var(--ago-muted-text-color, #6b6d6f)", $ = "var(--ago-border-color, #dee3e8)", de = "var(--ago-accent-color, #1b5fc4)", rt = "var(--ago-radius, 16px)", Ae = "var(--ago-message-radius, 16px)";
|
|
202
|
+
function at(o, n) {
|
|
203
203
|
if (n)
|
|
204
|
-
for (const r of Object.keys(
|
|
205
|
-
const
|
|
206
|
-
|
|
204
|
+
for (const r of Object.keys($e)) {
|
|
205
|
+
const t = n[r];
|
|
206
|
+
t != null && o.style.setProperty($e[r], t);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function y(o, n) {
|
|
210
210
|
Object.assign(o.style, n);
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function b(o = {}) {
|
|
213
213
|
const n = document.createElement("div");
|
|
214
|
-
return
|
|
214
|
+
return y(n, o), n;
|
|
215
215
|
}
|
|
216
|
-
var
|
|
217
|
-
function
|
|
218
|
-
if (typeof document > "u" || document.getElementById(
|
|
216
|
+
var Ne = "ago-chat-widget-keyframes";
|
|
217
|
+
function it() {
|
|
218
|
+
if (typeof document > "u" || document.getElementById(Ne)) return;
|
|
219
219
|
const o = document.createElement("style");
|
|
220
|
-
o.id =
|
|
220
|
+
o.id = Ne, o.textContent = "@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }", document.head.appendChild(o);
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function st(o) {
|
|
223
223
|
const n = typeof o == "string" ? document.querySelector(o) : o;
|
|
224
224
|
if (!n) throw new Error(`mountChatWidget: target "${String(o)}" not found.`);
|
|
225
225
|
return n;
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
const { title: r = "Chat", welcomeMessage:
|
|
227
|
+
function ft(o, n) {
|
|
228
|
+
const { title: r = "Chat", welcomeMessage: t = "Hello! How can I help you today?", placeholder: u = "Type a message...", allowFiles: i = !1, height: f = 500, placement: s = "inline", width: p = 400, defaultOpen: c = !1, logoUrl: m, showAgentName: L = !1, theme: x, loadThreads: _ = !1, forms: X, onFollowUpClick: B, onMessageSent: O, onMessageReceived: ge } = n;
|
|
229
229
|
if (!n.client && !n.config?.baseUrl) throw new Error("mountChatWidget requires either `client` or `config` (with a baseUrl).");
|
|
230
|
-
const h = n.client ?? new
|
|
231
|
-
let
|
|
232
|
-
const
|
|
230
|
+
const h = n.client ?? new Xe(n.config), he = st(o), z = s === "left" || s === "right", ze = z && (n.launcher ?? !0);
|
|
231
|
+
let H = z ? c : !0;
|
|
232
|
+
const J = n.persistConversation, K = J ? Ve(J === !0 ? {} : J) : void 0;
|
|
233
|
+
let k = n.conversationId ?? K?.getLastActiveThread() ?? void 0, d = [], A = !1, W = null;
|
|
234
|
+
const q = [], U = b({
|
|
233
235
|
display: "flex",
|
|
234
236
|
flexDirection: "column",
|
|
235
|
-
height: typeof
|
|
237
|
+
height: z ? "100%" : typeof f == "number" ? `${f}px` : f,
|
|
236
238
|
border: `1px solid ${$}`,
|
|
237
|
-
borderRadius:
|
|
239
|
+
borderRadius: rt,
|
|
238
240
|
overflow: "hidden",
|
|
239
|
-
backgroundColor:
|
|
240
|
-
fontFamily:
|
|
241
|
+
backgroundColor: j,
|
|
242
|
+
fontFamily: pe,
|
|
241
243
|
textAlign: "left",
|
|
242
244
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
243
245
|
});
|
|
244
|
-
|
|
245
|
-
const G =
|
|
246
|
+
U.className = "ago-chat-widget", at(U, x);
|
|
247
|
+
const G = b({
|
|
246
248
|
padding: "14px 16px",
|
|
247
249
|
borderBottom: `1px solid ${$}`,
|
|
248
|
-
backgroundColor:
|
|
249
|
-
color:
|
|
250
|
+
backgroundColor: tt,
|
|
251
|
+
color: Ie,
|
|
250
252
|
display: "flex",
|
|
251
253
|
alignItems: "center",
|
|
252
254
|
gap: "10px"
|
|
253
255
|
});
|
|
254
|
-
if (G.className = "ago-chat-widget__header",
|
|
255
|
-
const
|
|
256
|
-
|
|
256
|
+
if (G.className = "ago-chat-widget__header", m) {
|
|
257
|
+
const e = document.createElement("img");
|
|
258
|
+
e.src = m, e.alt = "Logo", y(e, {
|
|
257
259
|
height: "24px",
|
|
258
260
|
width: "auto"
|
|
259
|
-
}), G.appendChild(
|
|
261
|
+
}), G.appendChild(e);
|
|
260
262
|
}
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
+
const ee = document.createElement("h3");
|
|
264
|
+
if (ee.textContent = r, y(ee, {
|
|
263
265
|
margin: "0",
|
|
264
266
|
fontSize: "15px",
|
|
265
267
|
fontWeight: "600"
|
|
266
|
-
}), G.appendChild(
|
|
267
|
-
|
|
268
|
+
}), G.appendChild(ee), z) {
|
|
269
|
+
const e = document.createElement("button");
|
|
270
|
+
e.type = "button", e.className = "ago-chat-widget__close", e.setAttribute("aria-label", "Close"), e.textContent = "×", y(e, {
|
|
271
|
+
marginLeft: "auto",
|
|
272
|
+
background: "transparent",
|
|
273
|
+
border: "none",
|
|
274
|
+
color: Ie,
|
|
275
|
+
fontSize: "22px",
|
|
276
|
+
lineHeight: "1",
|
|
277
|
+
cursor: "pointer",
|
|
278
|
+
padding: "0 2px"
|
|
279
|
+
}), e.addEventListener("click", () => se()), G.appendChild(e);
|
|
280
|
+
}
|
|
281
|
+
const N = b({
|
|
268
282
|
flex: "1",
|
|
269
283
|
overflow: "auto",
|
|
270
284
|
padding: "16px",
|
|
271
|
-
backgroundColor:
|
|
285
|
+
backgroundColor: nt
|
|
272
286
|
});
|
|
273
|
-
|
|
274
|
-
const { inputRow:
|
|
275
|
-
placeholder:
|
|
276
|
-
allowFiles:
|
|
277
|
-
onSend: (
|
|
278
|
-
|
|
287
|
+
N.className = "ago-chat-widget__messages";
|
|
288
|
+
const { inputRow: He, setDisabled: Ue, focus: me } = lt({
|
|
289
|
+
placeholder: u,
|
|
290
|
+
allowFiles: i,
|
|
291
|
+
onSend: (e, a) => {
|
|
292
|
+
oe(e, a);
|
|
279
293
|
}
|
|
280
294
|
});
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
295
|
+
it(), U.append(G, N, He);
|
|
296
|
+
let V = U, T, E;
|
|
297
|
+
const te = s === "left" ? "left" : "right";
|
|
298
|
+
if (z && (T = b({
|
|
299
|
+
position: "fixed",
|
|
300
|
+
top: "0",
|
|
301
|
+
bottom: "0",
|
|
302
|
+
[te]: "0",
|
|
303
|
+
width: typeof p == "number" ? `${p}px` : p,
|
|
304
|
+
maxWidth: "100vw",
|
|
305
|
+
display: "flex",
|
|
306
|
+
zIndex: "2147483000",
|
|
307
|
+
transition: "transform 0.3s ease",
|
|
308
|
+
boxShadow: "rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"
|
|
309
|
+
}), T.className = "ago-chat-widget-panel", y(U, {
|
|
310
|
+
height: "100%",
|
|
311
|
+
width: "100%",
|
|
312
|
+
borderRadius: "0",
|
|
313
|
+
border: "none",
|
|
314
|
+
boxShadow: "none",
|
|
315
|
+
[te === "left" ? "borderRight" : "borderLeft"]: `1px solid ${$}`
|
|
316
|
+
}), T.appendChild(U), V = T), ze) {
|
|
317
|
+
if (E = document.createElement("button"), E.type = "button", E.className = "ago-chat-widget-launcher", E.setAttribute("aria-label", `Open ${r}`), y(E, {
|
|
318
|
+
position: "fixed",
|
|
319
|
+
bottom: "20px",
|
|
320
|
+
[te]: "20px",
|
|
321
|
+
width: "56px",
|
|
322
|
+
height: "56px",
|
|
323
|
+
borderRadius: "50%",
|
|
324
|
+
border: "none",
|
|
325
|
+
backgroundColor: fe,
|
|
326
|
+
color: ue,
|
|
327
|
+
cursor: "pointer",
|
|
328
|
+
display: "flex",
|
|
329
|
+
alignItems: "center",
|
|
330
|
+
justifyContent: "center",
|
|
331
|
+
zIndex: "2147483000",
|
|
332
|
+
boxShadow: "rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",
|
|
333
|
+
fontFamily: pe
|
|
334
|
+
}), m) {
|
|
335
|
+
const e = document.createElement("img");
|
|
336
|
+
e.src = m, e.alt = "", y(e, {
|
|
337
|
+
width: "26px",
|
|
338
|
+
height: "26px",
|
|
339
|
+
objectFit: "contain"
|
|
340
|
+
}), E.appendChild(e);
|
|
341
|
+
} else E.appendChild(je());
|
|
342
|
+
E.addEventListener("click", () => ie());
|
|
343
|
+
}
|
|
344
|
+
he.appendChild(V), E && he.appendChild(E), ae();
|
|
345
|
+
const xe = B !== !1, be = B === !1 ? void 0 : B ?? ((e) => {
|
|
346
|
+
oe(e);
|
|
284
347
|
});
|
|
285
|
-
function
|
|
286
|
-
const
|
|
348
|
+
function Fe(e, a) {
|
|
349
|
+
const l = e.role === "user", S = b({
|
|
287
350
|
display: "flex",
|
|
288
351
|
flexDirection: "column",
|
|
289
|
-
alignItems:
|
|
352
|
+
alignItems: l ? "flex-end" : "flex-start",
|
|
290
353
|
marginBottom: "16px"
|
|
291
354
|
});
|
|
292
|
-
if (
|
|
293
|
-
const
|
|
355
|
+
if (S.className = `ago-message ago-message--${e.role}`, !l && L && e.agent) {
|
|
356
|
+
const g = b({
|
|
294
357
|
fontSize: "13px",
|
|
295
358
|
fontWeight: "500",
|
|
296
|
-
color:
|
|
359
|
+
color: Y,
|
|
297
360
|
marginBottom: "6px",
|
|
298
361
|
padding: "0 4px"
|
|
299
362
|
});
|
|
300
|
-
|
|
363
|
+
g.className = "ago-message__agent", g.textContent = e.agent.displayName || e.agent.name, S.appendChild(g);
|
|
301
364
|
}
|
|
302
|
-
if (!
|
|
303
|
-
const
|
|
365
|
+
if (!l && e.sources && e.sources.length > 0) {
|
|
366
|
+
const g = b({
|
|
304
367
|
display: "grid",
|
|
305
368
|
gridTemplateColumns: "1fr 1fr",
|
|
306
369
|
gap: "6px",
|
|
@@ -308,28 +371,28 @@ function Ve(o, n) {
|
|
|
308
371
|
width: "100%",
|
|
309
372
|
maxWidth: "85%"
|
|
310
373
|
});
|
|
311
|
-
|
|
312
|
-
const
|
|
313
|
-
C.url &&
|
|
374
|
+
g.className = "ago-message__sources", e.sources.forEach((C, v) => {
|
|
375
|
+
const D = C.url ? document.createElement("a") : document.createElement("div");
|
|
376
|
+
C.url && D instanceof HTMLAnchorElement && (D.href = C.url, D.target = "_blank", D.rel = "noopener noreferrer"), y(D, {
|
|
314
377
|
display: "flex",
|
|
315
378
|
alignItems: "center",
|
|
316
379
|
gap: "8px",
|
|
317
380
|
padding: "8px 10px",
|
|
318
381
|
border: `1px solid ${$}`,
|
|
319
382
|
borderRadius: "8px",
|
|
320
|
-
backgroundColor:
|
|
383
|
+
backgroundColor: j,
|
|
321
384
|
textDecoration: "none",
|
|
322
|
-
color:
|
|
385
|
+
color: Y,
|
|
323
386
|
fontSize: "12px",
|
|
324
387
|
overflow: "hidden"
|
|
325
388
|
});
|
|
326
|
-
const
|
|
389
|
+
const _e = b({
|
|
327
390
|
flexShrink: "0",
|
|
328
391
|
width: "18px",
|
|
329
392
|
height: "18px",
|
|
330
393
|
borderRadius: "3px",
|
|
331
|
-
border: `1px solid ${
|
|
332
|
-
color:
|
|
394
|
+
border: `1px solid ${de}`,
|
|
395
|
+
color: de,
|
|
333
396
|
fontSize: "11px",
|
|
334
397
|
fontWeight: "500",
|
|
335
398
|
display: "flex",
|
|
@@ -337,76 +400,76 @@ function Ve(o, n) {
|
|
|
337
400
|
justifyContent: "center",
|
|
338
401
|
backgroundColor: "#f0f4ff"
|
|
339
402
|
});
|
|
340
|
-
|
|
341
|
-
const
|
|
403
|
+
_e.textContent = String(v + 1);
|
|
404
|
+
const le = b({
|
|
342
405
|
overflow: "hidden",
|
|
343
406
|
textOverflow: "ellipsis",
|
|
344
407
|
whiteSpace: "nowrap"
|
|
345
408
|
});
|
|
346
|
-
|
|
347
|
-
}),
|
|
409
|
+
le.textContent = C.title, le.title = C.title, D.append(_e, le), g.appendChild(D);
|
|
410
|
+
}), S.appendChild(g);
|
|
348
411
|
}
|
|
349
|
-
const
|
|
350
|
-
maxWidth:
|
|
351
|
-
padding:
|
|
352
|
-
borderRadius:
|
|
353
|
-
backgroundColor:
|
|
354
|
-
color:
|
|
412
|
+
const w = b({
|
|
413
|
+
maxWidth: l ? "75%" : "100%",
|
|
414
|
+
padding: l ? "10px 14px" : "2px 8px",
|
|
415
|
+
borderRadius: l ? Ae : "0",
|
|
416
|
+
backgroundColor: l ? fe : "transparent",
|
|
417
|
+
color: l ? ue : Y,
|
|
355
418
|
wordBreak: "break-word",
|
|
356
419
|
fontSize: "14px",
|
|
357
420
|
lineHeight: "1.6"
|
|
358
421
|
});
|
|
359
|
-
if (
|
|
360
|
-
const
|
|
422
|
+
if (w.className = "ago-message__content", e.content ? w.appendChild(Be(e.content)) : e.status === "IN_PROGRESS" && w.appendChild(Re()), S.appendChild(w), a && A && e.role === "assistant" && e.status === "DONE" && !(e.followUpReplies && e.followUpReplies.length > 0)) {
|
|
423
|
+
const g = b({
|
|
361
424
|
marginTop: "10px",
|
|
362
425
|
paddingLeft: "8px"
|
|
363
426
|
});
|
|
364
|
-
|
|
427
|
+
g.className = "ago-message__followups-loading", g.appendChild(Re()), S.appendChild(g);
|
|
365
428
|
}
|
|
366
|
-
if (
|
|
367
|
-
const
|
|
429
|
+
if (a && e.followUpReplies && e.followUpReplies.length > 0) {
|
|
430
|
+
const g = b({
|
|
368
431
|
display: "flex",
|
|
369
432
|
flexWrap: "wrap",
|
|
370
433
|
gap: "8px",
|
|
371
434
|
marginTop: "10px"
|
|
372
435
|
});
|
|
373
|
-
|
|
374
|
-
for (const C of
|
|
375
|
-
const
|
|
376
|
-
|
|
436
|
+
g.className = "ago-message__followups";
|
|
437
|
+
for (const C of e.followUpReplies) {
|
|
438
|
+
const v = document.createElement("button");
|
|
439
|
+
v.type = "button", v.className = "ago-message__followup-btn", v.textContent = C, v.disabled = !xe, y(v, {
|
|
377
440
|
padding: "6px 14px",
|
|
378
441
|
fontSize: "13px",
|
|
379
|
-
borderRadius:
|
|
442
|
+
borderRadius: Ae,
|
|
380
443
|
border: `1px solid ${$}`,
|
|
381
|
-
backgroundColor:
|
|
382
|
-
color:
|
|
383
|
-
cursor:
|
|
444
|
+
backgroundColor: j,
|
|
445
|
+
color: Y,
|
|
446
|
+
cursor: xe ? "pointer" : "default",
|
|
384
447
|
transition: "border-color 0.15s"
|
|
385
|
-
}),
|
|
386
|
-
|
|
387
|
-
}),
|
|
388
|
-
|
|
389
|
-
}),
|
|
448
|
+
}), be && v.addEventListener("click", () => be(C)), v.addEventListener("mouseenter", () => {
|
|
449
|
+
v.style.borderColor = de;
|
|
450
|
+
}), v.addEventListener("mouseleave", () => {
|
|
451
|
+
v.style.borderColor = $;
|
|
452
|
+
}), g.appendChild(v);
|
|
390
453
|
}
|
|
391
|
-
|
|
454
|
+
S.appendChild(g);
|
|
392
455
|
}
|
|
393
|
-
return
|
|
456
|
+
return S;
|
|
394
457
|
}
|
|
395
|
-
function
|
|
396
|
-
if (
|
|
397
|
-
const
|
|
458
|
+
function I() {
|
|
459
|
+
if (N.replaceChildren(), d.length === 0) {
|
|
460
|
+
const a = b({
|
|
398
461
|
textAlign: "center",
|
|
399
|
-
color:
|
|
462
|
+
color: ot,
|
|
400
463
|
padding: "24px 16px",
|
|
401
464
|
fontSize: "14px",
|
|
402
465
|
lineHeight: "1.5"
|
|
403
466
|
});
|
|
404
|
-
|
|
405
|
-
} else
|
|
406
|
-
|
|
467
|
+
a.textContent = t, N.appendChild(a);
|
|
468
|
+
} else d.forEach((a, l) => {
|
|
469
|
+
N.appendChild(Fe(a, l === d.length - 1));
|
|
407
470
|
});
|
|
408
|
-
if (
|
|
409
|
-
const
|
|
471
|
+
if (W) {
|
|
472
|
+
const a = b({
|
|
410
473
|
padding: "10px 14px",
|
|
411
474
|
backgroundColor: "#fef2f2",
|
|
412
475
|
color: "#dc2626",
|
|
@@ -415,177 +478,207 @@ function Ve(o, n) {
|
|
|
415
478
|
fontSize: "13px",
|
|
416
479
|
border: "1px solid #fecaca"
|
|
417
480
|
});
|
|
418
|
-
|
|
481
|
+
a.textContent = W, N.appendChild(a);
|
|
419
482
|
}
|
|
420
|
-
|
|
421
|
-
const
|
|
422
|
-
|
|
483
|
+
N.scrollTop = N.scrollHeight;
|
|
484
|
+
const e = d[d.length - 1];
|
|
485
|
+
Ue(A && e?.role === "assistant" && e.status === "IN_PROGRESS");
|
|
423
486
|
}
|
|
424
|
-
function
|
|
425
|
-
for (let
|
|
426
|
-
const
|
|
427
|
-
if (
|
|
487
|
+
function Pe() {
|
|
488
|
+
for (let e = d.length - 1; e >= 0; e--) {
|
|
489
|
+
const a = d[e];
|
|
490
|
+
if (a.role === "assistant" && a.status === "IN_PROGRESS") return a;
|
|
428
491
|
}
|
|
429
492
|
}
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
},
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
},
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
},
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
id:
|
|
442
|
-
content:
|
|
493
|
+
const Ce = (e) => {
|
|
494
|
+
k || (k = e.conversationId);
|
|
495
|
+
}, we = (e) => {
|
|
496
|
+
const a = Pe();
|
|
497
|
+
a && (a.content += e.content, I());
|
|
498
|
+
}, ve = (e) => {
|
|
499
|
+
const a = d.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
|
|
500
|
+
a >= 0 ? d[a] = e : d.push(e), I();
|
|
501
|
+
}, ye = (e) => {
|
|
502
|
+
const a = d.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
|
|
503
|
+
a >= 0 ? d[a] = e : d.push(e), A = !1, I(), e.status === "DONE" && ge?.({
|
|
504
|
+
id: e.id,
|
|
505
|
+
content: e.content
|
|
443
506
|
});
|
|
444
|
-
},
|
|
445
|
-
|
|
507
|
+
}, Ee = (e) => {
|
|
508
|
+
W = e.error, A = !1, d = d.filter((a) => !a.id.startsWith("temp-")), I();
|
|
446
509
|
};
|
|
447
|
-
h.on("message:start",
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
510
|
+
h.on("message:start", Ce), h.on("message:chunk", we), h.on("message:answer-complete", ve), h.on("message:complete", ye), h.on("message:error", Ee);
|
|
511
|
+
const ne = [];
|
|
512
|
+
let Se = !1;
|
|
513
|
+
for (const e of X ?? []) e.schema != null ? ne.push(qe(e).install(h)) : Ke(h, e).then((a) => {
|
|
514
|
+
Se || ne.push(a.install(h));
|
|
515
|
+
}).catch(() => {
|
|
516
|
+
});
|
|
517
|
+
async function oe(e, a) {
|
|
518
|
+
const l = e.trim();
|
|
519
|
+
if (!l && !a?.length || A) return;
|
|
520
|
+
O?.(l), A = !0, W = null;
|
|
521
|
+
const S = Date.now();
|
|
522
|
+
d.push({
|
|
523
|
+
id: `temp-user-${S}`,
|
|
524
|
+
conversationId: k || "",
|
|
525
|
+
content: l,
|
|
458
526
|
role: "user",
|
|
459
527
|
status: "DONE",
|
|
460
528
|
createdAt: /* @__PURE__ */ new Date()
|
|
461
|
-
}),
|
|
462
|
-
id: `temp-assistant-${
|
|
463
|
-
conversationId:
|
|
529
|
+
}), d.push({
|
|
530
|
+
id: `temp-assistant-${S}`,
|
|
531
|
+
conversationId: k || "",
|
|
464
532
|
content: "",
|
|
465
533
|
role: "assistant",
|
|
466
534
|
status: "IN_PROGRESS",
|
|
467
535
|
createdAt: /* @__PURE__ */ new Date()
|
|
468
|
-
}),
|
|
536
|
+
}), I();
|
|
469
537
|
try {
|
|
470
|
-
const
|
|
471
|
-
conversationId:
|
|
472
|
-
files:
|
|
538
|
+
const w = await h.sendMessage(l, {
|
|
539
|
+
conversationId: k,
|
|
540
|
+
files: a
|
|
473
541
|
});
|
|
474
|
-
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
477
|
-
const C =
|
|
478
|
-
C >= 0 ?
|
|
542
|
+
w.conversationId && (k || (k = w.conversationId), K?.setActiveThread(w.conversationId, w.createdAt));
|
|
543
|
+
const g = d.find((C) => C.id === `temp-user-${S}`);
|
|
544
|
+
if (g && (g.id = `user-${S}`, g.conversationId = w.conversationId), !d.some((C) => C.id === w.id)) {
|
|
545
|
+
const C = d.findIndex((v) => v.id === `temp-assistant-${S}`);
|
|
546
|
+
C >= 0 ? d[C] = w : d.push(w);
|
|
479
547
|
}
|
|
480
|
-
|
|
481
|
-
} catch (
|
|
482
|
-
|
|
548
|
+
d = d.filter((C) => !C.id.startsWith("temp-")), A = !1, I(), _ && re();
|
|
549
|
+
} catch (w) {
|
|
550
|
+
W = w instanceof Error ? w.message : "Failed to send message", A = !1, d = d.filter((g) => !g.id.startsWith("temp-")), I();
|
|
483
551
|
}
|
|
484
552
|
}
|
|
485
|
-
async function
|
|
553
|
+
async function re() {
|
|
486
554
|
try {
|
|
487
|
-
const
|
|
488
|
-
|
|
555
|
+
const e = await h.getConversations();
|
|
556
|
+
q.splice(0, q.length, ...e);
|
|
489
557
|
} catch {
|
|
490
558
|
}
|
|
491
|
-
return
|
|
559
|
+
return q;
|
|
492
560
|
}
|
|
493
|
-
async function
|
|
561
|
+
async function We(e) {
|
|
494
562
|
try {
|
|
495
|
-
const
|
|
496
|
-
|
|
563
|
+
const a = (await h.getConversation(e))?.messages ?? [];
|
|
564
|
+
a.length > 0 && d.length === 0 && (d = a, I());
|
|
497
565
|
} catch {
|
|
498
|
-
|
|
566
|
+
d.length === 0 && (K?.clear(), k = void 0);
|
|
499
567
|
}
|
|
500
568
|
}
|
|
501
|
-
return
|
|
569
|
+
return I(), me(), k && We(k), _ && re(), {
|
|
502
570
|
client: h,
|
|
503
|
-
element:
|
|
504
|
-
sendMessage:
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
571
|
+
element: V,
|
|
572
|
+
sendMessage: oe,
|
|
573
|
+
...z ? {
|
|
574
|
+
open: ie,
|
|
575
|
+
close: se,
|
|
576
|
+
toggle: Ge
|
|
577
|
+
} : {},
|
|
578
|
+
session: K,
|
|
579
|
+
threads: q,
|
|
580
|
+
refreshThreads: re,
|
|
508
581
|
destroy() {
|
|
509
|
-
h.off("message:start",
|
|
582
|
+
h.off("message:start", Ce), h.off("message:chunk", we), h.off("message:answer-complete", ve), h.off("message:complete", ye), h.off("message:error", Ee), Se = !0, ne.forEach((e) => e()), V.remove(), E?.remove(), n.client || h.destroy();
|
|
510
583
|
}
|
|
511
584
|
};
|
|
585
|
+
function ae() {
|
|
586
|
+
if (!T) return;
|
|
587
|
+
const e = s === "left" ? "translateX(-100%)" : "translateX(100%)";
|
|
588
|
+
T.style.transform = H ? "translateX(0)" : e, T.setAttribute("aria-hidden", H ? "false" : "true"), E && (E.style.display = H ? "none" : "flex");
|
|
589
|
+
}
|
|
512
590
|
function ie() {
|
|
513
|
-
|
|
591
|
+
H = !0, ae(), me();
|
|
592
|
+
}
|
|
593
|
+
function se() {
|
|
594
|
+
H = !1, ae();
|
|
595
|
+
}
|
|
596
|
+
function Ge() {
|
|
597
|
+
H ? se() : ie();
|
|
598
|
+
}
|
|
599
|
+
function je() {
|
|
600
|
+
const e = "http://www.w3.org/2000/svg", a = document.createElementNS(e, "svg");
|
|
601
|
+
a.setAttribute("width", "26"), a.setAttribute("height", "26"), a.setAttribute("viewBox", "0 0 24 24"), a.setAttribute("fill", "none");
|
|
602
|
+
const l = document.createElementNS(e, "path");
|
|
603
|
+
return l.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"), l.setAttribute("stroke", "currentColor"), l.setAttribute("stroke-width", "2"), l.setAttribute("stroke-linecap", "round"), l.setAttribute("stroke-linejoin", "round"), a.appendChild(l), a;
|
|
604
|
+
}
|
|
605
|
+
function Re() {
|
|
606
|
+
const e = b({
|
|
514
607
|
display: "flex",
|
|
515
608
|
gap: "4px",
|
|
516
609
|
padding: "4px 0"
|
|
517
610
|
});
|
|
518
|
-
for (let
|
|
519
|
-
const
|
|
611
|
+
for (let a = 0; a < 3; a++) {
|
|
612
|
+
const l = b({
|
|
520
613
|
width: "6px",
|
|
521
614
|
height: "6px",
|
|
522
615
|
borderRadius: "50%",
|
|
523
616
|
backgroundColor: "#b5bfc8",
|
|
524
617
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
525
|
-
animationDelay: `${
|
|
618
|
+
animationDelay: `${a * 0.2}s`
|
|
526
619
|
});
|
|
527
|
-
|
|
620
|
+
e.appendChild(l);
|
|
528
621
|
}
|
|
529
|
-
return
|
|
622
|
+
return e;
|
|
530
623
|
}
|
|
531
624
|
}
|
|
532
|
-
function
|
|
625
|
+
function lt(o) {
|
|
533
626
|
let n = [];
|
|
534
627
|
const r = document.createElement("form");
|
|
535
|
-
|
|
628
|
+
y(r, {
|
|
536
629
|
display: "flex",
|
|
537
630
|
flexDirection: "column",
|
|
538
631
|
gap: "8px",
|
|
539
632
|
padding: "12px",
|
|
540
633
|
borderTop: `1px solid ${$}`,
|
|
541
|
-
backgroundColor:
|
|
634
|
+
backgroundColor: j
|
|
542
635
|
}), r.className = "ago-chat-input";
|
|
543
|
-
const
|
|
636
|
+
const t = b({
|
|
544
637
|
display: "flex",
|
|
545
638
|
flexWrap: "wrap",
|
|
546
639
|
gap: "6px"
|
|
547
|
-
}),
|
|
640
|
+
}), u = b({
|
|
548
641
|
display: "flex",
|
|
549
642
|
gap: "8px",
|
|
550
643
|
alignItems: "flex-end"
|
|
551
|
-
}),
|
|
552
|
-
|
|
644
|
+
}), i = document.createElement("textarea");
|
|
645
|
+
i.placeholder = o.placeholder, i.rows = 1, y(i, {
|
|
553
646
|
flex: "1",
|
|
554
647
|
resize: "none",
|
|
555
648
|
padding: "10px 12px",
|
|
556
649
|
border: `1px solid ${$}`,
|
|
557
650
|
borderRadius: "12px",
|
|
558
651
|
fontSize: "14px",
|
|
559
|
-
fontFamily:
|
|
652
|
+
fontFamily: pe,
|
|
560
653
|
lineHeight: "1.4",
|
|
561
654
|
maxHeight: "120px",
|
|
562
655
|
outline: "none"
|
|
563
656
|
});
|
|
564
|
-
const
|
|
565
|
-
|
|
657
|
+
const f = document.createElement("button");
|
|
658
|
+
f.type = "submit", f.textContent = "Send", y(f, {
|
|
566
659
|
padding: "10px 16px",
|
|
567
660
|
border: "none",
|
|
568
661
|
borderRadius: "12px",
|
|
569
|
-
backgroundColor:
|
|
570
|
-
color:
|
|
662
|
+
backgroundColor: fe,
|
|
663
|
+
color: ue,
|
|
571
664
|
fontSize: "14px",
|
|
572
665
|
fontWeight: "500",
|
|
573
666
|
cursor: "pointer"
|
|
574
667
|
});
|
|
575
|
-
let
|
|
576
|
-
o.allowFiles && (
|
|
668
|
+
let s = null, p = null;
|
|
669
|
+
o.allowFiles && (s = document.createElement("input"), s.type = "file", s.multiple = !0, y(s, { display: "none" }), p = document.createElement("button"), p.type = "button", p.textContent = "📎", y(p, {
|
|
577
670
|
padding: "10px 12px",
|
|
578
671
|
border: `1px solid ${$}`,
|
|
579
672
|
borderRadius: "12px",
|
|
580
|
-
backgroundColor:
|
|
673
|
+
backgroundColor: j,
|
|
581
674
|
cursor: "pointer",
|
|
582
675
|
fontSize: "14px"
|
|
583
|
-
}),
|
|
584
|
-
n = [...n, ...Array.from(
|
|
676
|
+
}), p.addEventListener("click", () => s?.click()), s.addEventListener("change", () => {
|
|
677
|
+
n = [...n, ...Array.from(s?.files ?? [])], c();
|
|
585
678
|
}));
|
|
586
|
-
function
|
|
587
|
-
|
|
588
|
-
const
|
|
679
|
+
function c() {
|
|
680
|
+
t.replaceChildren(), n.forEach((x, _) => {
|
|
681
|
+
const X = b({
|
|
589
682
|
display: "flex",
|
|
590
683
|
alignItems: "center",
|
|
591
684
|
gap: "4px",
|
|
@@ -594,44 +687,44 @@ function je(o) {
|
|
|
594
687
|
border: `1px solid ${$}`,
|
|
595
688
|
borderRadius: "8px",
|
|
596
689
|
fontSize: "12px"
|
|
597
|
-
}),
|
|
598
|
-
|
|
690
|
+
}), B = document.createElement("span");
|
|
691
|
+
B.textContent = x.name;
|
|
599
692
|
const O = document.createElement("button");
|
|
600
|
-
O.type = "button", O.textContent = "×",
|
|
693
|
+
O.type = "button", O.textContent = "×", y(O, {
|
|
601
694
|
border: "none",
|
|
602
695
|
background: "transparent",
|
|
603
696
|
cursor: "pointer",
|
|
604
697
|
fontSize: "14px",
|
|
605
698
|
lineHeight: "1"
|
|
606
699
|
}), O.addEventListener("click", () => {
|
|
607
|
-
n = n.filter((
|
|
608
|
-
}),
|
|
700
|
+
n = n.filter((ge, h) => h !== _), c();
|
|
701
|
+
}), X.append(B, O), t.appendChild(X);
|
|
609
702
|
});
|
|
610
703
|
}
|
|
611
|
-
const
|
|
612
|
-
const
|
|
613
|
-
return
|
|
614
|
-
content:
|
|
704
|
+
const m = () => {
|
|
705
|
+
const x = i.value, _ = n;
|
|
706
|
+
return i.value = "", n = [], c(), {
|
|
707
|
+
content: x,
|
|
615
708
|
files: _
|
|
616
709
|
};
|
|
617
|
-
},
|
|
618
|
-
const { content:
|
|
619
|
-
(
|
|
710
|
+
}, L = () => {
|
|
711
|
+
const { content: x, files: _ } = m();
|
|
712
|
+
(x.trim() || _.length > 0) && o.onSend(x.trim(), _.length > 0 ? _ : void 0);
|
|
620
713
|
};
|
|
621
|
-
return r.addEventListener("submit", (
|
|
622
|
-
|
|
623
|
-
}),
|
|
624
|
-
|
|
625
|
-
}),
|
|
714
|
+
return r.addEventListener("submit", (x) => {
|
|
715
|
+
x.preventDefault(), L();
|
|
716
|
+
}), i.addEventListener("keydown", (x) => {
|
|
717
|
+
x.key === "Enter" && !x.shiftKey && (x.preventDefault(), L());
|
|
718
|
+
}), p && u.appendChild(p), u.append(i, f), s && r.appendChild(s), r.append(t, u), {
|
|
626
719
|
inputRow: r,
|
|
627
|
-
getValueAndClear:
|
|
628
|
-
setDisabled: (
|
|
629
|
-
|
|
720
|
+
getValueAndClear: m,
|
|
721
|
+
setDisabled: (x) => {
|
|
722
|
+
i.disabled = x, f.disabled = x, f.style.opacity = x ? "0.6" : "1", f.style.cursor = x ? "not-allowed" : "pointer";
|
|
630
723
|
},
|
|
631
|
-
focus: () =>
|
|
724
|
+
focus: () => i.focus()
|
|
632
725
|
};
|
|
633
726
|
}
|
|
634
727
|
export {
|
|
635
|
-
|
|
636
|
-
|
|
728
|
+
ft as mountChatWidget,
|
|
729
|
+
Be as renderMarkdown
|
|
637
730
|
};
|