@useago/sdk 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/AgoClient-CMDVqNaH.cjs +8 -0
- package/dist/{AgoClient-BdtuHX7k.js → AgoClient-S8oeNnAE.js} +273 -157
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +121 -4
- package/dist/angular.d.ts +121 -4
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-B8zfTL78.cjs → createConversationSession-CmBq7uGi.cjs} +1 -1
- package/dist/{createConversationSession-CWpf4u6I.js → createConversationSession-DoUHdVNR.js} +1 -1
- package/dist/{createFormCollector-BB_l0Sia.cjs → createFormCollector-Bz_0IJ0Q.cjs} +1 -1
- package/dist/{createFormCollector-B4n0_diV.js → createFormCollector-vy-QvFja.js} +1 -1
- package/dist/createMockClient-BSr-UV8R.cjs +1 -0
- package/dist/{createMockClient-d-arlmCq.js → createMockClient-bAZ9KBHC.js} +18 -15
- package/dist/devtools.d.cts +120 -3
- package/dist/devtools.d.ts +120 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +132 -3
- package/dist/index.d.ts +132 -3
- package/dist/index.js +4 -4
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +134 -9
- package/dist/react.d.ts +134 -9
- package/dist/react.js +440 -429
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +120 -3
- package/dist/testing.d.ts +120 -3
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +127 -4
- package/dist/vue.d.ts +127 -4
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +3 -3
- package/dist/widget.d.cts +120 -3
- package/dist/widget.d.ts +120 -3
- package/dist/widget.js +120 -120
- package/package.json +1 -1
- package/dist/AgoClient-CRAnT4qE.cjs +0 -8
- package/dist/createMockClient-ucPENDzz.cjs +0 -1
package/dist/react.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { a as J, i as j, o as V, s as Y, t as X } from "./AgoClient-
|
|
2
|
-
import { i as Q, n as
|
|
3
|
-
import { t as _e } from "./createMockClient-
|
|
4
|
-
import Z, { createContext as ee, useCallback as R, useContext as
|
|
5
|
-
import { Fragment as B, jsx as
|
|
1
|
+
import { a as J, i as j, o as V, s as Y, t as X } from "./AgoClient-S8oeNnAE.js";
|
|
2
|
+
import { i as Q, n as Pe, r as O, t as $ } from "./createFormCollector-vy-QvFja.js";
|
|
3
|
+
import { t as _e } from "./createMockClient-bAZ9KBHC.js";
|
|
4
|
+
import Z, { createContext as ee, useCallback as R, useContext as G, useEffect as k, useId as te, useMemo as F, useRef as A, useState as M, useSyncExternalStore as ne } from "react";
|
|
5
|
+
import { Fragment as B, jsx as i, jsxs as N } from "react/jsx-runtime";
|
|
6
6
|
import re from "react-markdown";
|
|
7
7
|
import oe from "remark-gfm";
|
|
8
8
|
function ae(e) {
|
|
9
|
-
const [
|
|
10
|
-
if (
|
|
11
|
-
const
|
|
12
|
-
return
|
|
9
|
+
const [n, r] = M(!1), t = A(null), o = F(() => {
|
|
10
|
+
if (t.current && (t.current.destroy(), t.current = null), !e) return null;
|
|
11
|
+
const s = new X(e);
|
|
12
|
+
return t.current = s, s;
|
|
13
13
|
}, [e?.baseUrl, e?.widgetId]);
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
}), [o]),
|
|
17
|
-
|
|
14
|
+
return k(() => (r(!0), () => {
|
|
15
|
+
t.current?.destroy(), t.current = null;
|
|
16
|
+
}), [o]), k(() => {
|
|
17
|
+
t.current && e && t.current.updateConfig({
|
|
18
18
|
agent: e.agent,
|
|
19
19
|
defaultAgentId: e.defaultAgentId,
|
|
20
20
|
permission: e.permission,
|
|
@@ -33,130 +33,136 @@ function ae(e) {
|
|
|
33
33
|
e?.warnOnEmptyReply
|
|
34
34
|
]), {
|
|
35
35
|
client: o,
|
|
36
|
-
isReady:
|
|
36
|
+
isReady: n
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
var
|
|
40
|
-
const { client: c } = ae(
|
|
41
|
-
return
|
|
39
|
+
var L = ee(null), He = ({ children: e, client: n, tools: r, helpers: t, pageContext: o, ...s }) => {
|
|
40
|
+
const { client: c } = ae(n ? null : s), l = n || c;
|
|
41
|
+
return k(() => {
|
|
42
42
|
if (!(!r || r.length === 0)) {
|
|
43
43
|
for (const g of r) l.register(g);
|
|
44
44
|
return () => {
|
|
45
45
|
for (const g of r) l.unregisterFunction(g.name);
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
}, [l, r]),
|
|
49
|
-
if (!
|
|
48
|
+
}, [l, r]), k(() => {
|
|
49
|
+
if (!t) return;
|
|
50
50
|
const g = [];
|
|
51
|
-
return import("./functions-CApuQZ2b.js").then((
|
|
52
|
-
for (const [
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
55
|
-
console.warn(`[AGO] Unknown helper: "${
|
|
51
|
+
return import("./functions-CApuQZ2b.js").then((d) => d.n).then((d) => {
|
|
52
|
+
for (const [v, y] of Object.entries(t)) {
|
|
53
|
+
const I = d[v];
|
|
54
|
+
if (!I) {
|
|
55
|
+
console.warn(`[AGO] Unknown helper: "${v}"`);
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
...
|
|
60
|
-
handler:
|
|
58
|
+
const f = y === !0 ? I : {
|
|
59
|
+
...I,
|
|
60
|
+
handler: y
|
|
61
61
|
};
|
|
62
|
-
l.register(
|
|
62
|
+
l.register(f), g.push(f.name);
|
|
63
63
|
}
|
|
64
64
|
}), () => {
|
|
65
|
-
for (const
|
|
65
|
+
for (const d of g) l.unregisterFunction(d);
|
|
66
66
|
};
|
|
67
|
-
}, [l,
|
|
67
|
+
}, [l, t]), k(() => {
|
|
68
68
|
o === "auto" && l.enableAutoPageContext();
|
|
69
|
-
}, [l, o]), /* @__PURE__ */
|
|
69
|
+
}, [l, o]), /* @__PURE__ */ i(L.Provider, {
|
|
70
70
|
value: l,
|
|
71
71
|
children: e
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
|
-
function
|
|
75
|
-
const e =
|
|
74
|
+
function _() {
|
|
75
|
+
const e = G(L);
|
|
76
76
|
if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
|
|
77
77
|
return e;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
79
|
+
function W() {
|
|
80
|
+
return G(L);
|
|
81
81
|
}
|
|
82
|
-
function U({ client: e, conversationId:
|
|
83
|
-
const r =
|
|
84
|
-
if (!
|
|
85
|
-
const [o,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}, [
|
|
89
|
-
const
|
|
82
|
+
function U({ client: e, conversationId: n } = {}) {
|
|
83
|
+
const r = W(), t = e || r;
|
|
84
|
+
if (!t) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
85
|
+
const [o, s] = M([]), [c, l] = M(n), [g, d] = M(!1), [v, y] = M(null);
|
|
86
|
+
k(() => {
|
|
87
|
+
n && n !== c && (l(n), I(n));
|
|
88
|
+
}, [n]);
|
|
89
|
+
const I = async (f) => {
|
|
90
90
|
try {
|
|
91
|
-
|
|
91
|
+
s((await t.getMessages(f)).filter((m) => !m.hidden));
|
|
92
92
|
} catch (m) {
|
|
93
|
-
|
|
93
|
+
y(m instanceof Error ? m : /* @__PURE__ */ new Error("Failed to load messages"));
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
return
|
|
97
|
-
const
|
|
98
|
-
c || l(
|
|
99
|
-
id
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
content: y.content + f.content
|
|
112
|
-
}] : d;
|
|
96
|
+
return k(() => {
|
|
97
|
+
const f = (u) => u === "IN_PROGRESS" || u === "WAITING_CLIENT", m = (u) => {
|
|
98
|
+
c || l(u.conversationId), d(!0), s((p) => {
|
|
99
|
+
const b = p.findIndex((h) => h.id === u.messageId);
|
|
100
|
+
return b >= 0 ? p.map((h, D) => D === b ? {
|
|
101
|
+
...h,
|
|
102
|
+
status: "IN_PROGRESS"
|
|
103
|
+
} : h) : p.some((h) => h.role === "assistant" && f(h.status)) ? p : [...p, {
|
|
104
|
+
id: u.messageId,
|
|
105
|
+
conversationId: u.conversationId,
|
|
106
|
+
content: "",
|
|
107
|
+
role: "assistant",
|
|
108
|
+
status: "IN_PROGRESS",
|
|
109
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
110
|
+
}];
|
|
113
111
|
});
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
}, S = (u) => {
|
|
113
|
+
s((p) => {
|
|
114
|
+
const b = p.findIndex((h) => h.id === u.messageId);
|
|
115
|
+
return b < 0 ? p : p.map((h, D) => D === b ? {
|
|
116
|
+
...h,
|
|
117
|
+
content: h.content + u.content
|
|
118
|
+
} : h);
|
|
119
|
+
});
|
|
120
|
+
}, w = (u) => {
|
|
121
|
+
s((p) => {
|
|
122
|
+
let b = -1;
|
|
123
|
+
for (let h = p.length - 1; h >= 0; h--) if (p[h].role === "assistant" && f(p[h].status)) {
|
|
124
|
+
b = h;
|
|
119
125
|
break;
|
|
120
126
|
}
|
|
121
|
-
return
|
|
122
|
-
...
|
|
127
|
+
return b < 0 ? p : [
|
|
128
|
+
...p.slice(0, b),
|
|
123
129
|
{
|
|
124
|
-
...
|
|
125
|
-
...
|
|
130
|
+
...p[b],
|
|
131
|
+
...u
|
|
126
132
|
},
|
|
127
|
-
...
|
|
133
|
+
...p.slice(b + 1)
|
|
128
134
|
];
|
|
129
135
|
});
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
return
|
|
134
|
-
...
|
|
135
|
-
|
|
136
|
-
...
|
|
137
|
-
] : [...
|
|
138
|
-
}),
|
|
139
|
-
},
|
|
140
|
-
|
|
136
|
+
}, a = (u) => {
|
|
137
|
+
s((p) => {
|
|
138
|
+
const b = p.findIndex((h) => h.id === u.id);
|
|
139
|
+
return b >= 0 ? [
|
|
140
|
+
...p.slice(0, b),
|
|
141
|
+
u,
|
|
142
|
+
...p.slice(b + 1)
|
|
143
|
+
] : [...p, u];
|
|
144
|
+
}), d(!1);
|
|
145
|
+
}, x = (u) => {
|
|
146
|
+
y(new Error(u.error)), d(!1);
|
|
141
147
|
};
|
|
142
|
-
return
|
|
143
|
-
|
|
148
|
+
return t.on("message:start", m), t.on("message:chunk", S), t.on("message:answer-complete", w), t.on("message:complete", a), t.on("message:error", x), () => {
|
|
149
|
+
t.off("message:start", m), t.off("message:chunk", S), t.off("message:answer-complete", w), t.off("message:complete", a), t.off("message:error", x);
|
|
144
150
|
};
|
|
145
|
-
}, [
|
|
151
|
+
}, [t, c]), {
|
|
146
152
|
messages: o,
|
|
147
153
|
isLoading: g,
|
|
148
|
-
error:
|
|
149
|
-
sendMessage: R(async (
|
|
150
|
-
|
|
151
|
-
const
|
|
154
|
+
error: v,
|
|
155
|
+
sendMessage: R(async (f, m) => {
|
|
156
|
+
d(!0), y(null);
|
|
157
|
+
const S = {
|
|
152
158
|
id: `temp-${Date.now()}`,
|
|
153
159
|
conversationId: c || "",
|
|
154
|
-
content:
|
|
160
|
+
content: f,
|
|
155
161
|
role: "user",
|
|
156
162
|
status: "DONE",
|
|
157
163
|
attachments: m && m.length > 0 ? j(m) : void 0,
|
|
158
164
|
createdAt: /* @__PURE__ */ new Date()
|
|
159
|
-
},
|
|
165
|
+
}, w = {
|
|
160
166
|
id: `temp-assistant-${Date.now()}`,
|
|
161
167
|
conversationId: c || "",
|
|
162
168
|
content: "",
|
|
@@ -164,61 +170,61 @@ function U({ client: e, conversationId: t } = {}) {
|
|
|
164
170
|
status: "IN_PROGRESS",
|
|
165
171
|
createdAt: /* @__PURE__ */ new Date()
|
|
166
172
|
};
|
|
167
|
-
|
|
173
|
+
s((a) => [
|
|
168
174
|
...a,
|
|
169
|
-
|
|
170
|
-
|
|
175
|
+
S,
|
|
176
|
+
w
|
|
171
177
|
]);
|
|
172
178
|
try {
|
|
173
|
-
const a = await
|
|
179
|
+
const a = await t.sendMessage(f, {
|
|
174
180
|
conversationId: c,
|
|
175
181
|
files: m
|
|
176
182
|
});
|
|
177
|
-
return a.conversationId && !c && l(a.conversationId),
|
|
178
|
-
const
|
|
179
|
-
...
|
|
180
|
-
id:
|
|
183
|
+
return a.conversationId && !c && l(a.conversationId), s((x) => {
|
|
184
|
+
const u = x.filter((b) => !b.id.startsWith("temp-")), p = {
|
|
185
|
+
...S,
|
|
186
|
+
id: S.id.replace("temp-", "user-"),
|
|
181
187
|
conversationId: a.conversationId
|
|
182
188
|
};
|
|
183
|
-
return
|
|
184
|
-
...
|
|
185
|
-
|
|
189
|
+
return u.some((b) => b.id === a.id) ? [...u, p].sort((b, h) => new Date(b.createdAt).getTime() - new Date(h.createdAt).getTime()) : [
|
|
190
|
+
...u,
|
|
191
|
+
p,
|
|
186
192
|
a
|
|
187
193
|
];
|
|
188
194
|
}), a;
|
|
189
195
|
} catch (a) {
|
|
190
|
-
return
|
|
196
|
+
return y(a instanceof Error ? a : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((x) => x.filter((u) => !u.id.startsWith("temp-"))), null;
|
|
191
197
|
}
|
|
192
|
-
}, [
|
|
198
|
+
}, [t, c]),
|
|
193
199
|
clearMessages: R(() => {
|
|
194
|
-
|
|
200
|
+
s([]), l(void 0), y(null);
|
|
195
201
|
}, []),
|
|
196
202
|
conversationId: c
|
|
197
203
|
};
|
|
198
204
|
}
|
|
199
|
-
var se = ({ onSend: e, disabled:
|
|
200
|
-
const [
|
|
201
|
-
const a =
|
|
205
|
+
var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", allowFiles: t = !1, className: o = "" }) => {
|
|
206
|
+
const [s, c] = M(""), [l, g] = M([]), d = A(null), v = A(null), y = R(() => {
|
|
207
|
+
const a = v.current;
|
|
202
208
|
if (!a) return;
|
|
203
|
-
const
|
|
204
|
-
a.style.height = "auto", a.style.height = `${Math.min(a.scrollHeight + 2,
|
|
205
|
-
}, []),
|
|
206
|
-
a.preventDefault(), (
|
|
209
|
+
const x = 110;
|
|
210
|
+
a.style.height = "auto", a.style.height = `${Math.min(a.scrollHeight + 2, x)}px`, a.style.overflowY = a.scrollHeight + 2 > x ? "auto" : "hidden";
|
|
211
|
+
}, []), I = R((a) => {
|
|
212
|
+
a.preventDefault(), (s.trim() || l.length > 0) && (e(s.trim(), l.length > 0 ? l : void 0), c(""), g([]), requestAnimationFrame(y));
|
|
207
213
|
}, [
|
|
208
|
-
|
|
214
|
+
s,
|
|
209
215
|
l,
|
|
210
216
|
e,
|
|
211
|
-
|
|
212
|
-
]),
|
|
213
|
-
a.key === "Enter" && !a.shiftKey && (a.preventDefault(),
|
|
214
|
-
}, [
|
|
215
|
-
const
|
|
216
|
-
g((
|
|
217
|
-
}, []),
|
|
218
|
-
g((
|
|
219
|
-
}, []),
|
|
220
|
-
return /* @__PURE__ */
|
|
221
|
-
onSubmit:
|
|
217
|
+
y
|
|
218
|
+
]), f = R((a) => {
|
|
219
|
+
a.key === "Enter" && !a.shiftKey && (a.preventDefault(), I(a));
|
|
220
|
+
}, [I]), m = R((a) => {
|
|
221
|
+
const x = Array.from(a.target.files || []);
|
|
222
|
+
g((u) => [...u, ...x]);
|
|
223
|
+
}, []), S = R((a) => {
|
|
224
|
+
g((x) => x.filter((u, p) => p !== a));
|
|
225
|
+
}, []), w = s.trim() || l.length > 0;
|
|
226
|
+
return /* @__PURE__ */ N("form", {
|
|
227
|
+
onSubmit: I,
|
|
222
228
|
className: `ago-chat-input ${o}`,
|
|
223
229
|
style: {
|
|
224
230
|
display: "flex",
|
|
@@ -228,14 +234,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
228
234
|
borderTop: "1px solid #dee3e8",
|
|
229
235
|
backgroundColor: "#fff"
|
|
230
236
|
},
|
|
231
|
-
children: [l.length > 0 && /* @__PURE__ */
|
|
237
|
+
children: [l.length > 0 && /* @__PURE__ */ i("div", {
|
|
232
238
|
className: "ago-chat-input__files",
|
|
233
239
|
style: {
|
|
234
240
|
display: "flex",
|
|
235
241
|
flexWrap: "wrap",
|
|
236
242
|
gap: "6px"
|
|
237
243
|
},
|
|
238
|
-
children: l.map((a,
|
|
244
|
+
children: l.map((a, x) => /* @__PURE__ */ N("div", {
|
|
239
245
|
style: {
|
|
240
246
|
display: "flex",
|
|
241
247
|
alignItems: "center",
|
|
@@ -246,7 +252,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
246
252
|
fontSize: "12px",
|
|
247
253
|
color: "#30373e"
|
|
248
254
|
},
|
|
249
|
-
children: [/* @__PURE__ */
|
|
255
|
+
children: [/* @__PURE__ */ i("span", {
|
|
250
256
|
style: {
|
|
251
257
|
maxWidth: "120px",
|
|
252
258
|
overflow: "hidden",
|
|
@@ -254,9 +260,9 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
254
260
|
whiteSpace: "nowrap"
|
|
255
261
|
},
|
|
256
262
|
children: a.name
|
|
257
|
-
}), /* @__PURE__ */
|
|
263
|
+
}), /* @__PURE__ */ i("button", {
|
|
258
264
|
type: "button",
|
|
259
|
-
onClick: () =>
|
|
265
|
+
onClick: () => S(x),
|
|
260
266
|
"aria-label": `Remove ${a.name}`,
|
|
261
267
|
style: {
|
|
262
268
|
border: "none",
|
|
@@ -269,47 +275,47 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
269
275
|
},
|
|
270
276
|
children: "×"
|
|
271
277
|
})]
|
|
272
|
-
},
|
|
273
|
-
}), /* @__PURE__ */
|
|
278
|
+
}, x))
|
|
279
|
+
}), /* @__PURE__ */ N("div", {
|
|
274
280
|
style: {
|
|
275
281
|
display: "flex",
|
|
276
282
|
gap: "8px",
|
|
277
283
|
alignItems: "flex-end"
|
|
278
284
|
},
|
|
279
285
|
children: [
|
|
280
|
-
|
|
286
|
+
t && /* @__PURE__ */ N(B, { children: [/* @__PURE__ */ i("button", {
|
|
281
287
|
type: "button",
|
|
282
|
-
onClick: () =>
|
|
283
|
-
disabled:
|
|
288
|
+
onClick: () => d.current?.click(),
|
|
289
|
+
disabled: n,
|
|
284
290
|
"aria-label": "Attach file",
|
|
285
291
|
style: {
|
|
286
292
|
padding: "8px",
|
|
287
293
|
border: "1px solid #dee3e8",
|
|
288
294
|
borderRadius: "8px",
|
|
289
295
|
backgroundColor: "#fff",
|
|
290
|
-
cursor:
|
|
296
|
+
cursor: n ? "not-allowed" : "pointer",
|
|
291
297
|
color: "#6b6d6f",
|
|
292
298
|
fontSize: "16px",
|
|
293
299
|
lineHeight: 1
|
|
294
300
|
},
|
|
295
301
|
children: "+"
|
|
296
|
-
}), /* @__PURE__ */
|
|
297
|
-
ref:
|
|
302
|
+
}), /* @__PURE__ */ i("input", {
|
|
303
|
+
ref: d,
|
|
298
304
|
type: "file",
|
|
299
305
|
multiple: !0,
|
|
300
306
|
onChange: m,
|
|
301
307
|
style: { display: "none" }
|
|
302
308
|
})] }),
|
|
303
|
-
/* @__PURE__ */
|
|
304
|
-
ref:
|
|
305
|
-
value:
|
|
309
|
+
/* @__PURE__ */ i("textarea", {
|
|
310
|
+
ref: v,
|
|
311
|
+
value: s,
|
|
306
312
|
onChange: (a) => {
|
|
307
|
-
c(a.target.value),
|
|
313
|
+
c(a.target.value), y();
|
|
308
314
|
},
|
|
309
|
-
onKeyDown:
|
|
315
|
+
onKeyDown: f,
|
|
310
316
|
placeholder: r,
|
|
311
317
|
"aria-label": r,
|
|
312
|
-
disabled:
|
|
318
|
+
disabled: n,
|
|
313
319
|
rows: 1,
|
|
314
320
|
style: {
|
|
315
321
|
flex: 1,
|
|
@@ -335,16 +341,16 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
335
341
|
a.currentTarget.style.borderColor = "#dee3e8";
|
|
336
342
|
}
|
|
337
343
|
}),
|
|
338
|
-
/* @__PURE__ */
|
|
344
|
+
/* @__PURE__ */ i("button", {
|
|
339
345
|
type: "submit",
|
|
340
|
-
disabled:
|
|
346
|
+
disabled: n || !w,
|
|
341
347
|
style: {
|
|
342
348
|
padding: "10px 18px",
|
|
343
349
|
border: "none",
|
|
344
350
|
borderRadius: "20px",
|
|
345
|
-
backgroundColor:
|
|
351
|
+
backgroundColor: n || !w ? "#b5bfc8" : "#03182f",
|
|
346
352
|
color: "#fff",
|
|
347
|
-
cursor:
|
|
353
|
+
cursor: n || !w ? "not-allowed" : "pointer",
|
|
348
354
|
fontWeight: 500,
|
|
349
355
|
fontSize: "16px",
|
|
350
356
|
transition: "background-color 0.15s"
|
|
@@ -354,7 +360,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
354
360
|
]
|
|
355
361
|
})]
|
|
356
362
|
});
|
|
357
|
-
}, ie = ({ href: e, children:
|
|
363
|
+
}, ie = ({ href: e, children: n, ...r }) => /* @__PURE__ */ i("a", {
|
|
358
364
|
href: e,
|
|
359
365
|
target: "_blank",
|
|
360
366
|
rel: "noopener noreferrer",
|
|
@@ -363,53 +369,53 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
363
369
|
textDecoration: "underline"
|
|
364
370
|
},
|
|
365
371
|
...r,
|
|
366
|
-
children:
|
|
367
|
-
}), le = ({ children: e, ...
|
|
372
|
+
children: n
|
|
373
|
+
}), le = ({ children: e, ...n }) => /* @__PURE__ */ i("p", {
|
|
368
374
|
style: {
|
|
369
375
|
margin: "0 0 8px 0",
|
|
370
376
|
lineHeight: "1.6"
|
|
371
377
|
},
|
|
372
|
-
...
|
|
378
|
+
...n,
|
|
373
379
|
children: e
|
|
374
|
-
}),
|
|
375
|
-
const r = ({ children:
|
|
380
|
+
}), P = (e, n) => {
|
|
381
|
+
const r = ({ children: t, ...o }) => Z.createElement(`h${e}`, {
|
|
376
382
|
style: {
|
|
377
383
|
margin: "16px 0 8px 0",
|
|
378
|
-
fontSize:
|
|
384
|
+
fontSize: n,
|
|
379
385
|
fontWeight: 600,
|
|
380
386
|
lineHeight: "1.3"
|
|
381
387
|
},
|
|
382
388
|
...o
|
|
383
|
-
},
|
|
389
|
+
}, t);
|
|
384
390
|
return r.displayName = `MarkdownHeading${e}`, r;
|
|
385
|
-
}, ce = ({ children: e, ...
|
|
391
|
+
}, ce = ({ children: e, ...n }) => /* @__PURE__ */ i("ul", {
|
|
386
392
|
style: {
|
|
387
393
|
margin: "0 0 8px 0",
|
|
388
394
|
paddingLeft: "20px",
|
|
389
395
|
listStyleType: "disc",
|
|
390
396
|
listStylePosition: "outside"
|
|
391
397
|
},
|
|
392
|
-
...
|
|
398
|
+
...n,
|
|
393
399
|
children: e
|
|
394
|
-
}), de = ({ children: e, ...
|
|
400
|
+
}), de = ({ children: e, ...n }) => /* @__PURE__ */ i("ol", {
|
|
395
401
|
style: {
|
|
396
402
|
margin: "0 0 8px 0",
|
|
397
403
|
paddingLeft: "20px",
|
|
398
404
|
listStyleType: "decimal",
|
|
399
405
|
listStylePosition: "outside"
|
|
400
406
|
},
|
|
401
|
-
...
|
|
407
|
+
...n,
|
|
402
408
|
children: e
|
|
403
|
-
}), ue = ({ children: e, ...
|
|
409
|
+
}), ue = ({ children: e, ...n }) => /* @__PURE__ */ i("li", {
|
|
404
410
|
style: {
|
|
405
411
|
display: "list-item",
|
|
406
412
|
margin: "2px 0",
|
|
407
413
|
lineHeight: "1.6"
|
|
408
414
|
},
|
|
409
|
-
...
|
|
415
|
+
...n,
|
|
410
416
|
children: e
|
|
411
|
-
}), fe = ({ className: e, children:
|
|
412
|
-
`) ? /* @__PURE__ */
|
|
417
|
+
}), fe = ({ className: e, children: n, ...r }) => e !== void 0 || String(n).includes(`
|
|
418
|
+
`) ? /* @__PURE__ */ i("code", {
|
|
413
419
|
style: {
|
|
414
420
|
display: "block",
|
|
415
421
|
background: "#f5f5f5",
|
|
@@ -420,8 +426,8 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
420
426
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
421
427
|
},
|
|
422
428
|
...r,
|
|
423
|
-
children:
|
|
424
|
-
}) : /* @__PURE__ */
|
|
429
|
+
children: n
|
|
430
|
+
}) : /* @__PURE__ */ i("code", {
|
|
425
431
|
style: {
|
|
426
432
|
background: "#f0f2f5",
|
|
427
433
|
padding: "2px 5px",
|
|
@@ -430,12 +436,12 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
430
436
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
431
437
|
},
|
|
432
438
|
...r,
|
|
433
|
-
children:
|
|
434
|
-
}), ge = ({ children: e, ...
|
|
439
|
+
children: n
|
|
440
|
+
}), ge = ({ children: e, ...n }) => /* @__PURE__ */ i("pre", {
|
|
435
441
|
style: { margin: "0 0 8px 0" },
|
|
436
|
-
...
|
|
442
|
+
...n,
|
|
437
443
|
children: e
|
|
438
|
-
}), pe = ({ children: e, ...
|
|
444
|
+
}), pe = ({ children: e, ...n }) => /* @__PURE__ */ i("blockquote", {
|
|
439
445
|
style: {
|
|
440
446
|
borderLeft: "4px solid #dee3e8",
|
|
441
447
|
paddingLeft: "12px",
|
|
@@ -443,23 +449,23 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
443
449
|
fontStyle: "italic",
|
|
444
450
|
color: "#6b6d6f"
|
|
445
451
|
},
|
|
446
|
-
...
|
|
452
|
+
...n,
|
|
447
453
|
children: e
|
|
448
|
-
}), me = ({ children: e, ...
|
|
454
|
+
}), me = ({ children: e, ...n }) => /* @__PURE__ */ i("div", {
|
|
449
455
|
style: {
|
|
450
456
|
overflowX: "auto",
|
|
451
457
|
margin: "0 0 8px 0"
|
|
452
458
|
},
|
|
453
|
-
children: /* @__PURE__ */
|
|
459
|
+
children: /* @__PURE__ */ i("table", {
|
|
454
460
|
style: {
|
|
455
461
|
borderCollapse: "collapse",
|
|
456
462
|
width: "100%",
|
|
457
463
|
fontSize: "13px"
|
|
458
464
|
},
|
|
459
|
-
...
|
|
465
|
+
...n,
|
|
460
466
|
children: e
|
|
461
467
|
})
|
|
462
|
-
}), he = ({ children: e, ...
|
|
468
|
+
}), he = ({ children: e, ...n }) => /* @__PURE__ */ i("th", {
|
|
463
469
|
style: {
|
|
464
470
|
border: "1px solid #dee3e8",
|
|
465
471
|
padding: "6px 10px",
|
|
@@ -467,24 +473,24 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
467
473
|
backgroundColor: "#f5f7fa",
|
|
468
474
|
fontWeight: 600
|
|
469
475
|
},
|
|
470
|
-
...
|
|
476
|
+
...n,
|
|
471
477
|
children: e
|
|
472
|
-
}), xe = ({ children: e, ...
|
|
478
|
+
}), xe = ({ children: e, ...n }) => /* @__PURE__ */ i("td", {
|
|
473
479
|
style: {
|
|
474
480
|
border: "1px solid #dee3e8",
|
|
475
481
|
padding: "6px 10px"
|
|
476
482
|
},
|
|
477
|
-
...
|
|
483
|
+
...n,
|
|
478
484
|
children: e
|
|
479
|
-
}), ye = ({ alt: e, ...
|
|
485
|
+
}), ye = ({ alt: e, ...n }) => /* @__PURE__ */ i("img", {
|
|
480
486
|
alt: e ?? "",
|
|
481
487
|
style: {
|
|
482
488
|
maxWidth: "100%",
|
|
483
489
|
borderRadius: "8px",
|
|
484
490
|
margin: "4px 0"
|
|
485
491
|
},
|
|
486
|
-
...
|
|
487
|
-
}), be = (e) => /* @__PURE__ */
|
|
492
|
+
...n
|
|
493
|
+
}), be = (e) => /* @__PURE__ */ i("hr", {
|
|
488
494
|
style: {
|
|
489
495
|
border: "none",
|
|
490
496
|
borderTop: "1px solid #dee3e8",
|
|
@@ -494,12 +500,12 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
494
500
|
}), ve = {
|
|
495
501
|
a: ie,
|
|
496
502
|
p: le,
|
|
497
|
-
h1:
|
|
498
|
-
h2:
|
|
499
|
-
h3:
|
|
500
|
-
h4:
|
|
501
|
-
h5:
|
|
502
|
-
h6:
|
|
503
|
+
h1: P(1, "20px"),
|
|
504
|
+
h2: P(2, "18px"),
|
|
505
|
+
h3: P(3, "16px"),
|
|
506
|
+
h4: P(4, "15px"),
|
|
507
|
+
h5: P(5, "14px"),
|
|
508
|
+
h6: P(6, "13px"),
|
|
503
509
|
ul: ce,
|
|
504
510
|
ol: de,
|
|
505
511
|
li: ue,
|
|
@@ -511,13 +517,13 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
511
517
|
td: xe,
|
|
512
518
|
img: ye,
|
|
513
519
|
hr: be
|
|
514
|
-
}, we = [oe], Se = ({ content: e }) => /* @__PURE__ */
|
|
520
|
+
}, we = [oe], Se = ({ content: e }) => /* @__PURE__ */ i(re, {
|
|
515
521
|
remarkPlugins: we,
|
|
516
522
|
components: ve,
|
|
517
523
|
children: e
|
|
518
|
-
}), Ce = ({ attachment: e, isUser:
|
|
524
|
+
}), Ce = ({ attachment: e, isUser: n }) => {
|
|
519
525
|
const r = Y(e.url);
|
|
520
|
-
if (J(e)) return /* @__PURE__ */
|
|
526
|
+
if (J(e)) return /* @__PURE__ */ i("a", {
|
|
521
527
|
href: r,
|
|
522
528
|
target: "_blank",
|
|
523
529
|
rel: "noopener noreferrer",
|
|
@@ -525,7 +531,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
525
531
|
display: "inline-block",
|
|
526
532
|
textDecoration: "none"
|
|
527
533
|
},
|
|
528
|
-
children: /* @__PURE__ */
|
|
534
|
+
children: /* @__PURE__ */ i("img", {
|
|
529
535
|
src: r,
|
|
530
536
|
alt: e.name,
|
|
531
537
|
loading: "lazy",
|
|
@@ -539,7 +545,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
539
545
|
}
|
|
540
546
|
})
|
|
541
547
|
});
|
|
542
|
-
const
|
|
548
|
+
const t = V(e.fileSize), o = /* @__PURE__ */ N(B, { children: [/* @__PURE__ */ i("span", {
|
|
543
549
|
style: {
|
|
544
550
|
fontSize: "16px",
|
|
545
551
|
lineHeight: 1,
|
|
@@ -547,13 +553,13 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
547
553
|
},
|
|
548
554
|
"aria-hidden": !0,
|
|
549
555
|
children: "📄"
|
|
550
|
-
}), /* @__PURE__ */
|
|
556
|
+
}), /* @__PURE__ */ N("span", {
|
|
551
557
|
style: {
|
|
552
558
|
display: "flex",
|
|
553
559
|
flexDirection: "column",
|
|
554
560
|
minWidth: 0
|
|
555
561
|
},
|
|
556
|
-
children: [/* @__PURE__ */
|
|
562
|
+
children: [/* @__PURE__ */ i("span", {
|
|
557
563
|
style: {
|
|
558
564
|
overflow: "hidden",
|
|
559
565
|
textOverflow: "ellipsis",
|
|
@@ -562,38 +568,38 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
562
568
|
},
|
|
563
569
|
title: e.name,
|
|
564
570
|
children: e.name
|
|
565
|
-
}),
|
|
571
|
+
}), t && /* @__PURE__ */ i("span", {
|
|
566
572
|
style: {
|
|
567
573
|
fontSize: "11px",
|
|
568
574
|
color: "#6b6d6f"
|
|
569
575
|
},
|
|
570
|
-
children:
|
|
576
|
+
children: t
|
|
571
577
|
})]
|
|
572
|
-
})] }),
|
|
578
|
+
})] }), s = {
|
|
573
579
|
display: "inline-flex",
|
|
574
580
|
alignItems: "center",
|
|
575
581
|
gap: "8px",
|
|
576
582
|
padding: "8px 12px",
|
|
577
583
|
borderRadius: "10px",
|
|
578
584
|
border: "1px solid #dee3e8",
|
|
579
|
-
backgroundColor:
|
|
580
|
-
color:
|
|
585
|
+
backgroundColor: n ? "rgba(255,255,255,0.12)" : "#fff",
|
|
586
|
+
color: n ? "#fff" : "#30373e",
|
|
581
587
|
fontSize: "13px",
|
|
582
588
|
textDecoration: "none",
|
|
583
589
|
maxWidth: "220px"
|
|
584
590
|
};
|
|
585
|
-
return r ? /* @__PURE__ */
|
|
591
|
+
return r ? /* @__PURE__ */ i("a", {
|
|
586
592
|
href: r,
|
|
587
593
|
target: "_blank",
|
|
588
594
|
rel: "noopener noreferrer",
|
|
589
|
-
style:
|
|
595
|
+
style: s,
|
|
590
596
|
children: o
|
|
591
|
-
}) : /* @__PURE__ */
|
|
592
|
-
style:
|
|
597
|
+
}) : /* @__PURE__ */ i("div", {
|
|
598
|
+
style: s,
|
|
593
599
|
children: o
|
|
594
600
|
});
|
|
595
|
-
},
|
|
596
|
-
const r = /* @__PURE__ */
|
|
601
|
+
}, Ie = ({ source: e, index: n }) => {
|
|
602
|
+
const r = /* @__PURE__ */ N("div", {
|
|
597
603
|
style: {
|
|
598
604
|
display: "flex",
|
|
599
605
|
alignItems: "center",
|
|
@@ -601,7 +607,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
601
607
|
width: "100%",
|
|
602
608
|
minWidth: 0
|
|
603
609
|
},
|
|
604
|
-
children: [/* @__PURE__ */
|
|
610
|
+
children: [/* @__PURE__ */ i("div", {
|
|
605
611
|
style: {
|
|
606
612
|
flexShrink: 0,
|
|
607
613
|
width: "18px",
|
|
@@ -616,8 +622,8 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
616
622
|
justifyContent: "center",
|
|
617
623
|
backgroundColor: "#f0f4ff"
|
|
618
624
|
},
|
|
619
|
-
children:
|
|
620
|
-
}), /* @__PURE__ */
|
|
625
|
+
children: n + 1
|
|
626
|
+
}), /* @__PURE__ */ i("div", {
|
|
621
627
|
style: {
|
|
622
628
|
fontSize: "12px",
|
|
623
629
|
overflow: "hidden",
|
|
@@ -628,7 +634,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
628
634
|
title: e.title,
|
|
629
635
|
children: e.title
|
|
630
636
|
})]
|
|
631
|
-
}),
|
|
637
|
+
}), t = {
|
|
632
638
|
display: "flex",
|
|
633
639
|
alignItems: "center",
|
|
634
640
|
padding: "8px 10px",
|
|
@@ -641,11 +647,11 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
641
647
|
minWidth: 0,
|
|
642
648
|
transition: "border-color 0.15s"
|
|
643
649
|
};
|
|
644
|
-
return e.url ? /* @__PURE__ */
|
|
650
|
+
return e.url ? /* @__PURE__ */ i("a", {
|
|
645
651
|
href: e.url,
|
|
646
652
|
target: "_blank",
|
|
647
653
|
rel: "noopener noreferrer",
|
|
648
|
-
style:
|
|
654
|
+
style: t,
|
|
649
655
|
onMouseEnter: (o) => {
|
|
650
656
|
o.currentTarget.style.borderColor = "#1b5fc4";
|
|
651
657
|
},
|
|
@@ -653,11 +659,11 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
653
659
|
o.currentTarget.style.borderColor = "#dee3e8";
|
|
654
660
|
},
|
|
655
661
|
children: r
|
|
656
|
-
}) : /* @__PURE__ */
|
|
657
|
-
style:
|
|
662
|
+
}) : /* @__PURE__ */ i("div", {
|
|
663
|
+
style: t,
|
|
658
664
|
children: r
|
|
659
665
|
});
|
|
660
|
-
},
|
|
666
|
+
}, ke = () => /* @__PURE__ */ N("div", {
|
|
661
667
|
style: {
|
|
662
668
|
display: "flex",
|
|
663
669
|
gap: "4px",
|
|
@@ -667,31 +673,31 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
667
673
|
0,
|
|
668
674
|
1,
|
|
669
675
|
2
|
|
670
|
-
].map((e) => /* @__PURE__ */
|
|
676
|
+
].map((e) => /* @__PURE__ */ i("div", { style: {
|
|
671
677
|
width: "6px",
|
|
672
678
|
height: "6px",
|
|
673
679
|
borderRadius: "50%",
|
|
674
680
|
backgroundColor: "#b5bfc8",
|
|
675
681
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
676
682
|
animationDelay: `${e * 0.2}s`
|
|
677
|
-
} }, e)), /* @__PURE__ */
|
|
683
|
+
} }, e)), /* @__PURE__ */ i("style", { children: `
|
|
678
684
|
@keyframes ago-pulse {
|
|
679
685
|
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
|
|
680
686
|
40% { opacity: 1; transform: scale(1); }
|
|
681
687
|
}
|
|
682
688
|
` })]
|
|
683
|
-
}), Me = ({ message: e, className:
|
|
684
|
-
const
|
|
685
|
-
return /* @__PURE__ */
|
|
686
|
-
className: `ago-message ago-message--${e.role} ${
|
|
689
|
+
}), Me = ({ message: e, className: n = "", showAgentName: r = !1, isLast: t = !1, onFollowUpClick: o }) => {
|
|
690
|
+
const s = e.role === "user", c = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
|
|
691
|
+
return /* @__PURE__ */ N("div", {
|
|
692
|
+
className: `ago-message ago-message--${e.role} ${n}`,
|
|
687
693
|
style: {
|
|
688
694
|
display: "flex",
|
|
689
695
|
flexDirection: "column",
|
|
690
|
-
alignItems:
|
|
696
|
+
alignItems: s ? "flex-end" : "flex-start",
|
|
691
697
|
marginBottom: "16px"
|
|
692
698
|
},
|
|
693
699
|
children: [
|
|
694
|
-
!
|
|
700
|
+
!s && r && e.agent && /* @__PURE__ */ i("div", {
|
|
695
701
|
className: "ago-message__agent",
|
|
696
702
|
style: {
|
|
697
703
|
display: "flex",
|
|
@@ -705,7 +711,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
705
711
|
},
|
|
706
712
|
children: e.agent.displayName || e.agent.name
|
|
707
713
|
}),
|
|
708
|
-
!
|
|
714
|
+
!s && e.sources && e.sources.length > 0 && /* @__PURE__ */ i("div", {
|
|
709
715
|
className: "ago-message__sources",
|
|
710
716
|
style: {
|
|
711
717
|
display: "grid",
|
|
@@ -715,41 +721,41 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
715
721
|
width: "100%",
|
|
716
722
|
maxWidth: "85%"
|
|
717
723
|
},
|
|
718
|
-
children: e.sources.map((l, g) => /* @__PURE__ */
|
|
724
|
+
children: e.sources.map((l, g) => /* @__PURE__ */ i(Ie, {
|
|
719
725
|
source: l,
|
|
720
726
|
index: g
|
|
721
727
|
}, l.id))
|
|
722
728
|
}),
|
|
723
|
-
e.attachments && e.attachments.length > 0 && /* @__PURE__ */
|
|
729
|
+
e.attachments && e.attachments.length > 0 && /* @__PURE__ */ i("div", {
|
|
724
730
|
className: "ago-message__attachments",
|
|
725
731
|
style: {
|
|
726
732
|
display: "flex",
|
|
727
733
|
flexWrap: "wrap",
|
|
728
734
|
gap: "6px",
|
|
729
735
|
marginBottom: "6px",
|
|
730
|
-
justifyContent:
|
|
736
|
+
justifyContent: s ? "flex-end" : "flex-start",
|
|
731
737
|
maxWidth: "75%"
|
|
732
738
|
},
|
|
733
|
-
children: e.attachments.map((l) => /* @__PURE__ */
|
|
739
|
+
children: e.attachments.map((l) => /* @__PURE__ */ i(Ce, {
|
|
734
740
|
attachment: l,
|
|
735
|
-
isUser:
|
|
741
|
+
isUser: s
|
|
736
742
|
}, l.id))
|
|
737
743
|
}),
|
|
738
|
-
(e.content || c) && /* @__PURE__ */
|
|
744
|
+
(e.content || c) && /* @__PURE__ */ i("div", {
|
|
739
745
|
className: "ago-message__content",
|
|
740
746
|
style: {
|
|
741
|
-
maxWidth:
|
|
742
|
-
padding:
|
|
743
|
-
borderRadius:
|
|
744
|
-
backgroundColor:
|
|
745
|
-
color:
|
|
747
|
+
maxWidth: s ? "75%" : "100%",
|
|
748
|
+
padding: s ? "10px 14px" : "2px 8px",
|
|
749
|
+
borderRadius: s ? "16px" : "0",
|
|
750
|
+
backgroundColor: s ? "#03182f" : "transparent",
|
|
751
|
+
color: s ? "#fff" : "#30373e",
|
|
746
752
|
wordBreak: "break-word",
|
|
747
753
|
fontSize: "16px",
|
|
748
754
|
lineHeight: "1.6"
|
|
749
755
|
},
|
|
750
|
-
children: e.content ? /* @__PURE__ */
|
|
756
|
+
children: e.content ? /* @__PURE__ */ i(Se, { content: e.content }) : c && /* @__PURE__ */ i(ke, {})
|
|
751
757
|
}),
|
|
752
|
-
|
|
758
|
+
t && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ i("div", {
|
|
753
759
|
className: "ago-message__followups",
|
|
754
760
|
style: {
|
|
755
761
|
display: "flex",
|
|
@@ -757,7 +763,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
757
763
|
gap: "8px",
|
|
758
764
|
marginTop: "10px"
|
|
759
765
|
},
|
|
760
|
-
children: e.followUpReplies.map((l, g) => /* @__PURE__ */
|
|
766
|
+
children: e.followUpReplies.map((l, g) => /* @__PURE__ */ i("button", {
|
|
761
767
|
type: "button",
|
|
762
768
|
className: "ago-message__followup-btn",
|
|
763
769
|
disabled: !o,
|
|
@@ -773,52 +779,52 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
773
779
|
cursor: o ? "pointer" : "default",
|
|
774
780
|
transition: "border-color 0.15s"
|
|
775
781
|
},
|
|
776
|
-
onMouseEnter: (
|
|
777
|
-
|
|
782
|
+
onMouseEnter: (d) => {
|
|
783
|
+
d.currentTarget.style.borderColor = "#1b5fc4";
|
|
778
784
|
},
|
|
779
|
-
onMouseLeave: (
|
|
780
|
-
|
|
785
|
+
onMouseLeave: (d) => {
|
|
786
|
+
d.currentTarget.style.borderColor = "#dee3e8";
|
|
781
787
|
},
|
|
782
788
|
children: l
|
|
783
789
|
}, g))
|
|
784
790
|
})
|
|
785
791
|
]
|
|
786
792
|
});
|
|
787
|
-
}, Oe = ({ client: e, conversationId:
|
|
788
|
-
const m = A(null),
|
|
793
|
+
}, Oe = ({ client: e, conversationId: n, title: r = "Chat", welcomeMessage: t = "Hello! How can I help you today?", placeholder: o = "Type a message...", allowFiles: s = !1, height: c = 500, logoUrl: l, showAgentName: g = !1, forms: d, onFollowUpClick: v, className: y = "", onMessageSent: I, onMessageReceived: f }) => {
|
|
794
|
+
const m = A(null), S = W(), w = e ?? S, { messages: a, isLoading: x, error: u, sendMessage: p } = U({
|
|
789
795
|
client: e,
|
|
790
|
-
conversationId:
|
|
796
|
+
conversationId: n
|
|
791
797
|
});
|
|
792
|
-
|
|
793
|
-
if (!
|
|
794
|
-
let
|
|
795
|
-
const
|
|
796
|
-
return Promise.all(
|
|
797
|
-
if (!
|
|
798
|
-
for (const
|
|
798
|
+
k(() => {
|
|
799
|
+
if (!w || !d || d.length === 0) return;
|
|
800
|
+
let C = !1;
|
|
801
|
+
const T = [];
|
|
802
|
+
return Promise.all(d.map((E) => E.schema != null ? Promise.resolve($(E)) : O(w, E))).then((E) => {
|
|
803
|
+
if (!C)
|
|
804
|
+
for (const q of E) T.push(q.install(w));
|
|
799
805
|
}).catch(() => {
|
|
800
806
|
}), () => {
|
|
801
|
-
|
|
807
|
+
C = !0, T.forEach((E) => E());
|
|
802
808
|
};
|
|
803
|
-
}, [
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
])) : ""]),
|
|
809
|
+
}, [w, d ? JSON.stringify(d.map((C) => [
|
|
810
|
+
C.name,
|
|
811
|
+
C.schema ?? null,
|
|
812
|
+
C.submit ?? !1,
|
|
813
|
+
C.description ?? null
|
|
814
|
+
])) : ""]), k(() => {
|
|
809
815
|
m.current?.scrollIntoView({ behavior: "smooth" });
|
|
810
|
-
}, [a]),
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
id:
|
|
814
|
-
content:
|
|
816
|
+
}, [a]), k(() => {
|
|
817
|
+
const C = a[a.length - 1];
|
|
818
|
+
C && C.role === "assistant" && C.status === "DONE" && f && f({
|
|
819
|
+
id: C.id,
|
|
820
|
+
content: C.content
|
|
815
821
|
});
|
|
816
|
-
}, [a,
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
},
|
|
820
|
-
return /* @__PURE__ */
|
|
821
|
-
className: `ago-chat-widget ${
|
|
822
|
+
}, [a, f]);
|
|
823
|
+
const b = async (C, T) => {
|
|
824
|
+
I?.(C), await p(C, T);
|
|
825
|
+
}, h = a[a.length - 1], D = x && h?.role === "assistant" && (h.status === "IN_PROGRESS" || h.status === "WAITING_CLIENT"), K = v === !1 ? void 0 : v ?? ((C) => b(C));
|
|
826
|
+
return /* @__PURE__ */ N("div", {
|
|
827
|
+
className: `ago-chat-widget ${y}`,
|
|
822
828
|
style: {
|
|
823
829
|
display: "flex",
|
|
824
830
|
flexDirection: "column",
|
|
@@ -832,7 +838,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
832
838
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
833
839
|
},
|
|
834
840
|
children: [
|
|
835
|
-
/* @__PURE__ */
|
|
841
|
+
/* @__PURE__ */ N("div", {
|
|
836
842
|
className: "ago-chat-widget__header",
|
|
837
843
|
style: {
|
|
838
844
|
padding: "14px 16px",
|
|
@@ -843,14 +849,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
843
849
|
alignItems: "center",
|
|
844
850
|
gap: "10px"
|
|
845
851
|
},
|
|
846
|
-
children: [l && /* @__PURE__ */
|
|
852
|
+
children: [l && /* @__PURE__ */ i("img", {
|
|
847
853
|
src: l,
|
|
848
854
|
alt: "Logo",
|
|
849
855
|
style: {
|
|
850
856
|
height: "24px",
|
|
851
857
|
width: "auto"
|
|
852
858
|
}
|
|
853
|
-
}), /* @__PURE__ */
|
|
859
|
+
}), /* @__PURE__ */ i("h3", {
|
|
854
860
|
style: {
|
|
855
861
|
margin: 0,
|
|
856
862
|
fontSize: "15px",
|
|
@@ -859,7 +865,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
859
865
|
children: r
|
|
860
866
|
})]
|
|
861
867
|
}),
|
|
862
|
-
/* @__PURE__ */
|
|
868
|
+
/* @__PURE__ */ N("div", {
|
|
863
869
|
className: "ago-chat-widget__messages",
|
|
864
870
|
role: "log",
|
|
865
871
|
"aria-live": "polite",
|
|
@@ -872,7 +878,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
872
878
|
backgroundColor: "#fbfbfb"
|
|
873
879
|
},
|
|
874
880
|
children: [
|
|
875
|
-
a.length === 0 ? /* @__PURE__ */
|
|
881
|
+
a.length === 0 ? /* @__PURE__ */ i("div", {
|
|
876
882
|
style: {
|
|
877
883
|
textAlign: "center",
|
|
878
884
|
color: "#6b6d6f",
|
|
@@ -880,14 +886,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
880
886
|
fontSize: "16px",
|
|
881
887
|
lineHeight: "1.5"
|
|
882
888
|
},
|
|
883
|
-
children:
|
|
884
|
-
}) : a.map((
|
|
885
|
-
message:
|
|
889
|
+
children: t
|
|
890
|
+
}) : a.map((C, T) => /* @__PURE__ */ i(Me, {
|
|
891
|
+
message: C,
|
|
886
892
|
showAgentName: g,
|
|
887
|
-
isLast:
|
|
888
|
-
onFollowUpClick:
|
|
889
|
-
},
|
|
890
|
-
|
|
893
|
+
isLast: T === a.length - 1,
|
|
894
|
+
onFollowUpClick: K
|
|
895
|
+
}, C.id)),
|
|
896
|
+
u && /* @__PURE__ */ i("div", {
|
|
891
897
|
role: "alert",
|
|
892
898
|
style: {
|
|
893
899
|
padding: "10px 14px",
|
|
@@ -898,73 +904,73 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
898
904
|
fontSize: "13px",
|
|
899
905
|
border: "1px solid #fecaca"
|
|
900
906
|
},
|
|
901
|
-
children:
|
|
907
|
+
children: u.message
|
|
902
908
|
}),
|
|
903
|
-
/* @__PURE__ */
|
|
909
|
+
/* @__PURE__ */ i("div", { ref: m })
|
|
904
910
|
]
|
|
905
911
|
}),
|
|
906
|
-
/* @__PURE__ */
|
|
907
|
-
onSend:
|
|
908
|
-
disabled:
|
|
912
|
+
/* @__PURE__ */ i(se, {
|
|
913
|
+
onSend: b,
|
|
914
|
+
disabled: D,
|
|
909
915
|
placeholder: o,
|
|
910
|
-
allowFiles:
|
|
916
|
+
allowFiles: s
|
|
911
917
|
})
|
|
912
918
|
]
|
|
913
919
|
});
|
|
914
920
|
};
|
|
915
|
-
function
|
|
916
|
-
const r =
|
|
917
|
-
if (!
|
|
918
|
-
const [o,
|
|
919
|
-
|
|
921
|
+
function Ne({ client: e, autoLoad: n = !0 } = {}) {
|
|
922
|
+
const r = W(), t = e || r;
|
|
923
|
+
if (!t) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
924
|
+
const [o, s] = M([]), [c, l] = M(null), [g, d] = M(!1), [v, y] = M(null), I = R(async () => {
|
|
925
|
+
d(!0), y(null);
|
|
920
926
|
try {
|
|
921
|
-
|
|
922
|
-
} catch (
|
|
923
|
-
|
|
927
|
+
s(await t.getConversations());
|
|
928
|
+
} catch (S) {
|
|
929
|
+
y(S instanceof Error ? S : /* @__PURE__ */ new Error("Failed to load conversations"));
|
|
924
930
|
} finally {
|
|
925
|
-
|
|
931
|
+
d(!1);
|
|
926
932
|
}
|
|
927
|
-
}, [
|
|
928
|
-
|
|
933
|
+
}, [t]), f = R(async (S) => {
|
|
934
|
+
d(!0), y(null);
|
|
929
935
|
try {
|
|
930
|
-
l(await
|
|
931
|
-
} catch (
|
|
932
|
-
|
|
936
|
+
l(await t.getConversation(S));
|
|
937
|
+
} catch (w) {
|
|
938
|
+
y(w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
933
939
|
} finally {
|
|
934
|
-
|
|
940
|
+
d(!1);
|
|
935
941
|
}
|
|
936
|
-
}, [
|
|
942
|
+
}, [t]), m = R(() => {
|
|
937
943
|
l(null);
|
|
938
944
|
}, []);
|
|
939
|
-
return
|
|
940
|
-
|
|
941
|
-
}, [
|
|
945
|
+
return k(() => {
|
|
946
|
+
n && I();
|
|
947
|
+
}, [n, I]), {
|
|
942
948
|
conversations: o,
|
|
943
949
|
currentConversation: c,
|
|
944
950
|
isLoading: g,
|
|
945
|
-
error:
|
|
946
|
-
selectConversation:
|
|
951
|
+
error: v,
|
|
952
|
+
selectConversation: f,
|
|
947
953
|
startNewConversation: m,
|
|
948
|
-
refreshConversations:
|
|
954
|
+
refreshConversations: I
|
|
949
955
|
};
|
|
950
956
|
}
|
|
951
957
|
function $e(e = {}) {
|
|
952
|
-
const
|
|
958
|
+
const n = W(), r = e.client || n;
|
|
953
959
|
if (!r) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
954
|
-
const
|
|
960
|
+
const t = U({
|
|
955
961
|
client: r,
|
|
956
962
|
conversationId: e.conversationId
|
|
957
|
-
}), o =
|
|
963
|
+
}), o = Ne({
|
|
958
964
|
client: r,
|
|
959
965
|
autoLoad: e.autoLoad
|
|
960
966
|
});
|
|
961
967
|
return {
|
|
962
|
-
messages:
|
|
963
|
-
isLoading:
|
|
964
|
-
error:
|
|
965
|
-
sendMessage:
|
|
966
|
-
clearMessages:
|
|
967
|
-
conversationId:
|
|
968
|
+
messages: t.messages,
|
|
969
|
+
isLoading: t.isLoading,
|
|
970
|
+
error: t.error || o.error,
|
|
971
|
+
sendMessage: t.sendMessage,
|
|
972
|
+
clearMessages: t.clearMessages,
|
|
973
|
+
conversationId: t.conversationId,
|
|
968
974
|
conversations: o.conversations,
|
|
969
975
|
currentConversation: o.currentConversation,
|
|
970
976
|
isConversationsLoading: o.isLoading,
|
|
@@ -973,36 +979,36 @@ function $e(e = {}) {
|
|
|
973
979
|
refreshConversations: o.refreshConversations
|
|
974
980
|
};
|
|
975
981
|
}
|
|
976
|
-
function
|
|
977
|
-
const r =
|
|
982
|
+
function Ge(e, n) {
|
|
983
|
+
const r = _(), { name: t, description: o, parameters: s, handler: c } = typeof e == "string" ? {
|
|
978
984
|
name: e,
|
|
979
|
-
...
|
|
985
|
+
...n
|
|
980
986
|
} : e, l = A(c);
|
|
981
|
-
l.current = c,
|
|
982
|
-
const g = (
|
|
983
|
-
return r.registerFunction(
|
|
987
|
+
l.current = c, k(() => {
|
|
988
|
+
const g = (d) => l.current(d);
|
|
989
|
+
return r.registerFunction(t, g, {
|
|
984
990
|
description: o,
|
|
985
|
-
parameters:
|
|
991
|
+
parameters: s
|
|
986
992
|
}), () => {
|
|
987
|
-
r.unregisterFunction(
|
|
993
|
+
r.unregisterFunction(t);
|
|
988
994
|
};
|
|
989
995
|
}, [
|
|
990
996
|
r,
|
|
991
|
-
|
|
997
|
+
t,
|
|
992
998
|
o,
|
|
993
|
-
|
|
999
|
+
s
|
|
994
1000
|
]);
|
|
995
1001
|
}
|
|
996
|
-
function
|
|
997
|
-
const r =
|
|
998
|
-
|
|
1002
|
+
function Be(e, n) {
|
|
1003
|
+
const r = _(), t = A(e);
|
|
1004
|
+
t.current = e, k(() => (r.registerNavigationFunction((o) => t.current(o), n), () => {
|
|
999
1005
|
r.unregisterNavigationFunction();
|
|
1000
|
-
}), [r,
|
|
1006
|
+
}), [r, n]);
|
|
1001
1007
|
}
|
|
1002
|
-
function
|
|
1003
|
-
const r =
|
|
1004
|
-
o.current = e,
|
|
1005
|
-
const
|
|
1008
|
+
function Ue(e, n) {
|
|
1009
|
+
const r = _(), t = n?.functionName ?? "setPageState", o = A(e);
|
|
1010
|
+
o.current = e, k(() => {
|
|
1011
|
+
const s = o.current.map((c) => {
|
|
1006
1012
|
const l = () => o.current.find((g) => g.name === c.name) ?? c;
|
|
1007
1013
|
return {
|
|
1008
1014
|
name: c.name,
|
|
@@ -1012,81 +1018,86 @@ function Ke(e, t) {
|
|
|
1012
1018
|
set: (g) => l().set(g)
|
|
1013
1019
|
};
|
|
1014
1020
|
});
|
|
1015
|
-
return r.registerPageStateFunction(
|
|
1016
|
-
r.unregisterPageStateFunction(
|
|
1021
|
+
return r.registerPageStateFunction(s, { functionName: t }), () => {
|
|
1022
|
+
r.unregisterPageStateFunction(t);
|
|
1017
1023
|
};
|
|
1018
|
-
}, [r,
|
|
1024
|
+
}, [r, t]);
|
|
1019
1025
|
}
|
|
1020
|
-
var
|
|
1021
|
-
function
|
|
1026
|
+
var Re = "You have navigated the user to a new page. That page now exposes its editable state through the available setPageState function, and its current values in the page context. If the user's latest request also asked to change something on this page, call setPageState now to apply exactly those changes and nothing else. Otherwise, reply with a short confirmation only.";
|
|
1027
|
+
function z(e) {
|
|
1022
1028
|
return {
|
|
1023
1029
|
navigationFunctions: e?.navigationFunctions ?? ["navigateToPage"],
|
|
1024
1030
|
pageStateFunctionName: e?.pageStateFunctionName ?? "setPageState",
|
|
1025
|
-
continuationPrompt: e?.continuationPrompt ??
|
|
1031
|
+
continuationPrompt: e?.continuationPrompt ?? Re,
|
|
1026
1032
|
maxDepth: e?.maxDepth ?? 1,
|
|
1027
1033
|
readinessTimeoutMs: e?.readinessTimeoutMs ?? 4e3,
|
|
1028
1034
|
settleMs: e?.settleMs ?? 150,
|
|
1029
1035
|
enabled: e?.enabled ?? !0
|
|
1030
1036
|
};
|
|
1031
1037
|
}
|
|
1032
|
-
function
|
|
1033
|
-
const
|
|
1034
|
-
r.current =
|
|
1035
|
-
const
|
|
1038
|
+
function Ke(e) {
|
|
1039
|
+
const n = _(), r = A(z(e));
|
|
1040
|
+
r.current = z(e), k(() => {
|
|
1041
|
+
const t = {
|
|
1036
1042
|
navigated: !1,
|
|
1043
|
+
pausedTurnNavigated: !1,
|
|
1037
1044
|
depth: 0,
|
|
1038
1045
|
runId: 0,
|
|
1039
1046
|
ourSendPending: !1
|
|
1040
|
-
}, o = () =>
|
|
1041
|
-
let
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1044
|
-
},
|
|
1045
|
-
if (
|
|
1046
|
-
o() && (
|
|
1047
|
-
},
|
|
1048
|
-
o() ?
|
|
1049
|
-
}), c = async (
|
|
1050
|
-
const
|
|
1051
|
-
if (!(!await
|
|
1052
|
-
|
|
1047
|
+
}, o = () => n.getRegisteredFunctions().some((f) => f.name === r.current.pageStateFunctionName), s = (f) => new Promise((m) => {
|
|
1048
|
+
let S = !1;
|
|
1049
|
+
const w = (p) => {
|
|
1050
|
+
S || (S = !0, clearTimeout(u), n.off("context:changed", x), m(p));
|
|
1051
|
+
}, a = () => setTimeout(() => w(f === t.runId && o()), r.current.settleMs), x = () => {
|
|
1052
|
+
if (f !== t.runId) return w(!1);
|
|
1053
|
+
o() && (n.off("context:changed", x), a());
|
|
1054
|
+
}, u = setTimeout(() => w(!1), r.current.readinessTimeoutMs);
|
|
1055
|
+
o() ? a() : n.on("context:changed", x);
|
|
1056
|
+
}), c = async (f) => {
|
|
1057
|
+
const m = ++t.runId;
|
|
1058
|
+
if (!(!await s(m) || m !== t.runId)) {
|
|
1059
|
+
t.depth += 1, t.ourSendPending = !0;
|
|
1053
1060
|
try {
|
|
1054
|
-
await
|
|
1055
|
-
conversationId:
|
|
1061
|
+
await n.sendMessage(r.current.continuationPrompt, {
|
|
1062
|
+
conversationId: f,
|
|
1056
1063
|
hidden: !0
|
|
1057
1064
|
});
|
|
1058
1065
|
} catch {
|
|
1059
|
-
|
|
1066
|
+
t.ourSendPending = !1;
|
|
1060
1067
|
}
|
|
1061
1068
|
}
|
|
1062
|
-
}, l = (
|
|
1063
|
-
r.current.navigationFunctions.includes(
|
|
1064
|
-
}, g = () => {
|
|
1065
|
-
|
|
1066
|
-
},
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
},
|
|
1071
|
-
|
|
1069
|
+
}, l = (f) => {
|
|
1070
|
+
r.current.navigationFunctions.includes(f.functionName) && (t.navigated = !0);
|
|
1071
|
+
}, g = n.registerResumeGate(async () => {
|
|
1072
|
+
r.current.enabled && t.pausedTurnNavigated && (t.pausedTurnNavigated = !1, await s(++t.runId));
|
|
1073
|
+
}), d = () => {
|
|
1074
|
+
t.pausedTurnNavigated = t.navigated, t.navigated = !1;
|
|
1075
|
+
}, v = () => {
|
|
1076
|
+
t.ourSendPending || (t.depth = 0, t.runId += 1);
|
|
1077
|
+
}, y = (f) => {
|
|
1078
|
+
t.ourSendPending = !1;
|
|
1079
|
+
const m = t.navigated;
|
|
1080
|
+
t.navigated = !1, r.current.enabled && m && (t.depth >= r.current.maxDepth || c(f.conversationId));
|
|
1081
|
+
}, I = () => {
|
|
1082
|
+
t.ourSendPending = !1;
|
|
1072
1083
|
};
|
|
1073
|
-
return
|
|
1074
|
-
|
|
1084
|
+
return n.on("function:invoke", l), n.on("message:start", v), n.on("message:waiting-client", d), n.on("message:complete", y), n.on("message:error", I), () => {
|
|
1085
|
+
t.runId += 1, g(), n.off("function:invoke", l), n.off("message:start", v), n.off("message:waiting-client", d), n.off("message:complete", y), n.off("message:error", I);
|
|
1075
1086
|
};
|
|
1076
|
-
}, [
|
|
1087
|
+
}, [n]);
|
|
1077
1088
|
}
|
|
1078
|
-
function
|
|
1079
|
-
const r =
|
|
1080
|
-
|
|
1089
|
+
function qe(e, n) {
|
|
1090
|
+
const r = _(), t = te(), o = n ?? t, s = A(e);
|
|
1091
|
+
s.current = e;
|
|
1081
1092
|
const c = typeof e == "function";
|
|
1082
|
-
|
|
1083
|
-
if (typeof
|
|
1084
|
-
const l = () =>
|
|
1093
|
+
k(() => {
|
|
1094
|
+
if (typeof s.current == "function") {
|
|
1095
|
+
const l = () => s.current();
|
|
1085
1096
|
return r.addDynamicContext(o, l), () => {
|
|
1086
1097
|
r.removeDynamicContext(o);
|
|
1087
1098
|
};
|
|
1088
1099
|
}
|
|
1089
|
-
return r.setContext(o,
|
|
1100
|
+
return r.setContext(o, s.current), () => {
|
|
1090
1101
|
r.removeContext(o);
|
|
1091
1102
|
};
|
|
1092
1103
|
}, [
|
|
@@ -1096,70 +1107,70 @@ function Ge(e, t) {
|
|
|
1096
1107
|
c ? "" : JSON.stringify(e)
|
|
1097
1108
|
]);
|
|
1098
1109
|
}
|
|
1099
|
-
function
|
|
1110
|
+
function Ae(e) {
|
|
1100
1111
|
return ne(e.subscribe, e.get, e.get);
|
|
1101
1112
|
}
|
|
1102
|
-
var
|
|
1113
|
+
var H = {
|
|
1103
1114
|
missing: [],
|
|
1104
1115
|
complete: !1
|
|
1105
1116
|
};
|
|
1106
1117
|
function Je(e) {
|
|
1107
|
-
const
|
|
1118
|
+
const n = _(), r = e.schema != null, t = JSON.stringify(e.schema ?? null), o = e.submit, s = o ? typeof o == "string" ? `client:${o}` : o.via === "backend" ? "backend" : "handler" in o ? "client:handler" : `client:${o.url}` : "none", c = JSON.stringify(e.initialValues ?? null), l = F(() => r ? $(e) : null, [
|
|
1108
1119
|
r,
|
|
1109
1120
|
e.name,
|
|
1110
|
-
|
|
1111
|
-
|
|
1121
|
+
t,
|
|
1122
|
+
s,
|
|
1112
1123
|
c,
|
|
1113
1124
|
e.autoSubmit
|
|
1114
|
-
]), [g,
|
|
1125
|
+
]), [g, d] = M({
|
|
1115
1126
|
collector: null,
|
|
1116
1127
|
loading: !r,
|
|
1117
1128
|
error: null
|
|
1118
1129
|
});
|
|
1119
|
-
|
|
1130
|
+
k(() => {
|
|
1120
1131
|
if (r) return;
|
|
1121
|
-
let
|
|
1122
|
-
return
|
|
1132
|
+
let x = !1;
|
|
1133
|
+
return d({
|
|
1123
1134
|
collector: null,
|
|
1124
1135
|
loading: !0,
|
|
1125
1136
|
error: null
|
|
1126
|
-
}),
|
|
1127
|
-
|
|
1128
|
-
collector:
|
|
1137
|
+
}), O(n, e).then((u) => {
|
|
1138
|
+
x || d({
|
|
1139
|
+
collector: u,
|
|
1129
1140
|
loading: !1,
|
|
1130
1141
|
error: null
|
|
1131
1142
|
});
|
|
1132
|
-
}).catch((
|
|
1133
|
-
|
|
1143
|
+
}).catch((u) => {
|
|
1144
|
+
x || d({
|
|
1134
1145
|
collector: null,
|
|
1135
1146
|
loading: !1,
|
|
1136
|
-
error:
|
|
1147
|
+
error: u instanceof Error ? u : new Error(String(u))
|
|
1137
1148
|
});
|
|
1138
1149
|
}), () => {
|
|
1139
|
-
|
|
1150
|
+
x = !0;
|
|
1140
1151
|
};
|
|
1141
1152
|
}, [
|
|
1142
|
-
|
|
1153
|
+
n,
|
|
1143
1154
|
r,
|
|
1144
1155
|
e.name,
|
|
1145
|
-
|
|
1156
|
+
s,
|
|
1146
1157
|
c,
|
|
1147
1158
|
e.autoSubmit
|
|
1148
1159
|
]);
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1151
|
-
if (
|
|
1152
|
-
return
|
|
1153
|
-
}, [
|
|
1154
|
-
const
|
|
1160
|
+
const v = r ? l : g.collector, y = r ? !1 : g.loading, I = r ? null : g.error;
|
|
1161
|
+
k(() => {
|
|
1162
|
+
if (v)
|
|
1163
|
+
return v.install(n);
|
|
1164
|
+
}, [n, v]);
|
|
1165
|
+
const f = F(() => Q({
|
|
1155
1166
|
values: e.initialValues ?? {},
|
|
1156
1167
|
submitted: !1
|
|
1157
|
-
}), [c]), m =
|
|
1168
|
+
}), [c]), m = Ae(v?.store ?? f), S = F(() => v?.getStatus() ?? H, [m, v]), w = F(() => ({
|
|
1158
1169
|
...m,
|
|
1159
|
-
...
|
|
1160
|
-
}), [m,
|
|
1170
|
+
...S
|
|
1171
|
+
}), [m, S]), a = F(() => ({
|
|
1161
1172
|
name: e.name,
|
|
1162
|
-
store:
|
|
1173
|
+
store: f,
|
|
1163
1174
|
functions: [],
|
|
1164
1175
|
contextKey: `form:${e.name}`,
|
|
1165
1176
|
contextProvider: () => ({
|
|
@@ -1174,18 +1185,18 @@ function Je(e) {
|
|
|
1174
1185
|
ok: !1,
|
|
1175
1186
|
error: "Form definition not loaded yet."
|
|
1176
1187
|
}),
|
|
1177
|
-
getValues: () =>
|
|
1188
|
+
getValues: () => f.get().values,
|
|
1178
1189
|
setValues: () => {
|
|
1179
1190
|
},
|
|
1180
1191
|
reset: () => {
|
|
1181
1192
|
},
|
|
1182
|
-
getStatus: () =>
|
|
1183
|
-
}), [e.name,
|
|
1193
|
+
getStatus: () => H
|
|
1194
|
+
}), [e.name, f]);
|
|
1184
1195
|
return {
|
|
1185
|
-
...
|
|
1186
|
-
state:
|
|
1187
|
-
loading:
|
|
1188
|
-
error:
|
|
1196
|
+
...v ?? a,
|
|
1197
|
+
state: w,
|
|
1198
|
+
loading: y,
|
|
1199
|
+
error: I
|
|
1189
1200
|
};
|
|
1190
1201
|
}
|
|
1191
1202
|
export {
|
|
@@ -1194,21 +1205,21 @@ export {
|
|
|
1194
1205
|
Oe as ChatWidget,
|
|
1195
1206
|
Se as Markdown,
|
|
1196
1207
|
Me as Message,
|
|
1197
|
-
|
|
1208
|
+
$ as createFormCollector,
|
|
1198
1209
|
_e as createMockClient,
|
|
1199
|
-
|
|
1200
|
-
|
|
1210
|
+
Pe as deriveFormStatus,
|
|
1211
|
+
O as loadFormCollector,
|
|
1201
1212
|
ae as useAgo,
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1213
|
+
Ke as useAgoAutoContinueAfterNavigation,
|
|
1214
|
+
_ as useAgoClient,
|
|
1215
|
+
qe as useAgoContext,
|
|
1216
|
+
Ge as useAgoFunction,
|
|
1217
|
+
Be as useAgoNavigation,
|
|
1218
|
+
Ue as useAgoPageState,
|
|
1219
|
+
Ae as useAgoStore,
|
|
1209
1220
|
$e as useChat,
|
|
1210
|
-
|
|
1221
|
+
Ne as useConversation,
|
|
1211
1222
|
Je as useFormCollector,
|
|
1212
1223
|
U as useMessages,
|
|
1213
|
-
|
|
1224
|
+
W as useOptionalAgoClient
|
|
1214
1225
|
};
|