@useago/sdk 1.4.2 → 1.4.4
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-CLmtYTJx.cjs +8 -0
- package/dist/{AgoClient-BdtuHX7k.js → AgoClient-Ozz2b1dQ.js} +301 -161
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +151 -6
- package/dist/angular.d.ts +151 -6
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-B8zfTL78.cjs → createConversationSession-CUkNp6mZ.cjs} +1 -1
- package/dist/{createConversationSession-CWpf4u6I.js → createConversationSession-QIBN0gLx.js} +1 -1
- package/dist/{createFormCollector-BB_l0Sia.cjs → createFormCollector-DHT1ObOb.cjs} +1 -1
- package/dist/{createFormCollector-B4n0_diV.js → createFormCollector-F3YJfsbg.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 +149 -4
- package/dist/devtools.d.ts +149 -4
- package/dist/helpers.d.cts +6 -0
- package/dist/helpers.d.ts +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +181 -5
- package/dist/index.d.ts +181 -5
- package/dist/index.js +4 -4
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +169 -10
- package/dist/react.d.ts +169 -10
- package/dist/react.js +441 -428
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +149 -4
- package/dist/testing.d.ts +149 -4
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +162 -5
- package/dist/vue.d.ts +162 -5
- package/dist/vue.js +22 -21
- package/dist/widget.cjs +3 -3
- package/dist/widget.d.cts +149 -4
- package/dist/widget.d.ts +149 -4
- package/dist/widget.js +120 -120
- package/llms-full.txt +1910 -0
- package/package.json +5 -3
- 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
|
|
5
|
-
import { Fragment as
|
|
1
|
+
import { a as J, i as j, o as V, s as Y, t as X } from "./AgoClient-Ozz2b1dQ.js";
|
|
2
|
+
import { i as Q, n as Pe, r as O, t as $ } from "./createFormCollector-F3YJfsbg.js";
|
|
3
|
+
import { t as _e } from "./createMockClient-bAZ9KBHC.js";
|
|
4
|
+
import Z, { createContext as ee, useCallback as N, useContext as B, useEffect as k, useId as te, useMemo as F, useRef as A, useState as M, useSyncExternalStore as ne } from "react";
|
|
5
|
+
import { Fragment as G, jsx as i, jsxs as R } 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 [y, b] of Object.entries(t)) {
|
|
53
|
+
const I = d[y];
|
|
54
|
+
if (!I) {
|
|
55
|
+
console.warn(`[AGO] Unknown helper: "${y}"`);
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
...
|
|
60
|
-
handler:
|
|
58
|
+
const f = b === !0 ? I : {
|
|
59
|
+
...I,
|
|
60
|
+
handler: b
|
|
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 = B(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 B(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), [y, b] = 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
|
+
b(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 v = p.findIndex((h) => h.id === u.messageId);
|
|
100
|
+
return v >= 0 ? p.map((h, D) => D === v ? {
|
|
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 v = p.findIndex((h) => h.id === u.messageId);
|
|
115
|
+
return v < 0 ? p : p.map((h, D) => D === v ? {
|
|
116
|
+
...h,
|
|
117
|
+
content: h.content + u.content
|
|
118
|
+
} : h);
|
|
119
|
+
});
|
|
120
|
+
}, w = (u) => {
|
|
121
|
+
s((p) => {
|
|
122
|
+
let v = -1;
|
|
123
|
+
for (let h = p.length - 1; h >= 0; h--) if (p[h].role === "assistant" && f(p[h].status)) {
|
|
124
|
+
v = h;
|
|
119
125
|
break;
|
|
120
126
|
}
|
|
121
|
-
return
|
|
122
|
-
...
|
|
127
|
+
return v < 0 ? p : [
|
|
128
|
+
...p.slice(0, v),
|
|
123
129
|
{
|
|
124
|
-
...
|
|
125
|
-
...
|
|
130
|
+
...p[v],
|
|
131
|
+
...u
|
|
126
132
|
},
|
|
127
|
-
...
|
|
133
|
+
...p.slice(v + 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 v = p.findIndex((h) => h.id === u.id);
|
|
139
|
+
return v >= 0 ? [
|
|
140
|
+
...p.slice(0, v),
|
|
141
|
+
u,
|
|
142
|
+
...p.slice(v + 1)
|
|
143
|
+
] : [...p, u];
|
|
144
|
+
}), d(!1);
|
|
145
|
+
}, x = (u) => {
|
|
146
|
+
b(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:
|
|
150
|
-
|
|
151
|
-
const
|
|
154
|
+
error: y,
|
|
155
|
+
sendMessage: N(async (f, m) => {
|
|
156
|
+
d(!0), b(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((v) => !v.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((v) => v.id === a.id) ? [...u, p].sort((v, h) => new Date(v.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 b(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
|
-
}, [
|
|
193
|
-
clearMessages:
|
|
194
|
-
|
|
198
|
+
}, [t, c]),
|
|
199
|
+
clearMessages: N(() => {
|
|
200
|
+
s([]), l(void 0), b(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), y = A(null), b = N(() => {
|
|
207
|
+
const a = y.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 = N((a) => {
|
|
212
|
+
a.preventDefault(), (s.trim() || l.length > 0) && (e(s.trim(), l.length > 0 ? l : void 0), c(""), g([]), requestAnimationFrame(b));
|
|
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
|
+
b
|
|
218
|
+
]), f = N((a) => {
|
|
219
|
+
a.key === "Enter" && !a.shiftKey && (a.preventDefault(), I(a));
|
|
220
|
+
}, [I]), m = N((a) => {
|
|
221
|
+
const x = Array.from(a.target.files || []);
|
|
222
|
+
g((u) => [...u, ...x]);
|
|
223
|
+
}, []), S = N((a) => {
|
|
224
|
+
g((x) => x.filter((u, p) => p !== a));
|
|
225
|
+
}, []), w = s.trim() || l.length > 0;
|
|
226
|
+
return /* @__PURE__ */ R("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__ */ R("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__ */ R("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__ */ R(G, { 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: y,
|
|
311
|
+
value: s,
|
|
306
312
|
onChange: (a) => {
|
|
307
|
-
c(a.target.value),
|
|
313
|
+
c(a.target.value), b();
|
|
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__ */ R(G, { 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__ */ R("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__ */ R("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__ */ R("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__ */ R("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: y, className: b = "", 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 v = 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 = y === !1 ? void 0 : y ?? ((C) => v(C));
|
|
826
|
+
return /* @__PURE__ */ R("div", {
|
|
827
|
+
className: `ago-chat-widget ${b}`,
|
|
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__ */ R("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__ */ R("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,60 +904,60 @@ 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: v,
|
|
914
|
+
disabled: D,
|
|
909
915
|
placeholder: o,
|
|
910
|
-
allowFiles:
|
|
916
|
+
allowFiles: s
|
|
911
917
|
})
|
|
912
918
|
]
|
|
913
919
|
});
|
|
914
920
|
};
|
|
915
|
-
function Re({ client: e, autoLoad:
|
|
916
|
-
const r =
|
|
917
|
-
if (!
|
|
918
|
-
const [o,
|
|
919
|
-
|
|
921
|
+
function Re({ 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), [y, b] = M(null), I = N(async () => {
|
|
925
|
+
d(!0), b(null);
|
|
920
926
|
try {
|
|
921
|
-
|
|
922
|
-
} catch (
|
|
923
|
-
|
|
927
|
+
s(await t.getConversations());
|
|
928
|
+
} catch (S) {
|
|
929
|
+
b(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 = N(async (S) => {
|
|
934
|
+
d(!0), b(null);
|
|
929
935
|
try {
|
|
930
|
-
l(await
|
|
931
|
-
} catch (
|
|
932
|
-
|
|
936
|
+
l(await t.getConversation(S));
|
|
937
|
+
} catch (w) {
|
|
938
|
+
b(w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
933
939
|
} finally {
|
|
934
|
-
|
|
940
|
+
d(!1);
|
|
935
941
|
}
|
|
936
|
-
}, [
|
|
942
|
+
}, [t]), m = N(() => {
|
|
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: y,
|
|
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
963
|
}), o = Re({
|
|
@@ -959,12 +965,12 @@ function $e(e = {}) {
|
|
|
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,38 @@ function $e(e = {}) {
|
|
|
973
979
|
refreshConversations: o.refreshConversations
|
|
974
980
|
};
|
|
975
981
|
}
|
|
976
|
-
function Be(e,
|
|
977
|
-
const r =
|
|
982
|
+
function Be(e, n) {
|
|
983
|
+
const r = _(), { name: t, description: o, parameters: s, handler: c, maxResultBytes: l } = typeof e == "string" ? {
|
|
978
984
|
name: e,
|
|
979
|
-
...
|
|
980
|
-
} : e,
|
|
981
|
-
|
|
982
|
-
const
|
|
983
|
-
return r.registerFunction(
|
|
985
|
+
...n
|
|
986
|
+
} : e, g = A(c);
|
|
987
|
+
g.current = c, k(() => {
|
|
988
|
+
const d = (y) => g.current(y);
|
|
989
|
+
return r.registerFunction(t, d, {
|
|
984
990
|
description: o,
|
|
985
|
-
parameters:
|
|
991
|
+
parameters: s,
|
|
992
|
+
maxResultBytes: l
|
|
986
993
|
}), () => {
|
|
987
|
-
r.unregisterFunction(
|
|
994
|
+
r.unregisterFunction(t);
|
|
988
995
|
};
|
|
989
996
|
}, [
|
|
990
997
|
r,
|
|
991
|
-
|
|
998
|
+
t,
|
|
992
999
|
o,
|
|
993
|
-
|
|
1000
|
+
s,
|
|
1001
|
+
l
|
|
994
1002
|
]);
|
|
995
1003
|
}
|
|
996
|
-
function
|
|
997
|
-
const r =
|
|
998
|
-
|
|
1004
|
+
function Ge(e, n) {
|
|
1005
|
+
const r = _(), t = A(e);
|
|
1006
|
+
t.current = e, k(() => (r.registerNavigationFunction((o) => t.current(o), n), () => {
|
|
999
1007
|
r.unregisterNavigationFunction();
|
|
1000
|
-
}), [r,
|
|
1008
|
+
}), [r, n]);
|
|
1001
1009
|
}
|
|
1002
|
-
function
|
|
1003
|
-
const r =
|
|
1004
|
-
o.current = e,
|
|
1005
|
-
const
|
|
1010
|
+
function Ue(e, n) {
|
|
1011
|
+
const r = _(), t = n?.functionName ?? "setPageState", o = A(e);
|
|
1012
|
+
o.current = e, k(() => {
|
|
1013
|
+
const s = o.current.map((c) => {
|
|
1006
1014
|
const l = () => o.current.find((g) => g.name === c.name) ?? c;
|
|
1007
1015
|
return {
|
|
1008
1016
|
name: c.name,
|
|
@@ -1012,81 +1020,86 @@ function Ke(e, t) {
|
|
|
1012
1020
|
set: (g) => l().set(g)
|
|
1013
1021
|
};
|
|
1014
1022
|
});
|
|
1015
|
-
return r.registerPageStateFunction(
|
|
1016
|
-
r.unregisterPageStateFunction(
|
|
1023
|
+
return r.registerPageStateFunction(s, { functionName: t }), () => {
|
|
1024
|
+
r.unregisterPageStateFunction(t);
|
|
1017
1025
|
};
|
|
1018
|
-
}, [r,
|
|
1026
|
+
}, [r, t]);
|
|
1019
1027
|
}
|
|
1020
|
-
var
|
|
1021
|
-
function
|
|
1028
|
+
var Ne = "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.";
|
|
1029
|
+
function z(e) {
|
|
1022
1030
|
return {
|
|
1023
1031
|
navigationFunctions: e?.navigationFunctions ?? ["navigateToPage"],
|
|
1024
1032
|
pageStateFunctionName: e?.pageStateFunctionName ?? "setPageState",
|
|
1025
|
-
continuationPrompt: e?.continuationPrompt ??
|
|
1033
|
+
continuationPrompt: e?.continuationPrompt ?? Ne,
|
|
1026
1034
|
maxDepth: e?.maxDepth ?? 1,
|
|
1027
1035
|
readinessTimeoutMs: e?.readinessTimeoutMs ?? 4e3,
|
|
1028
1036
|
settleMs: e?.settleMs ?? 150,
|
|
1029
1037
|
enabled: e?.enabled ?? !0
|
|
1030
1038
|
};
|
|
1031
1039
|
}
|
|
1032
|
-
function
|
|
1033
|
-
const
|
|
1034
|
-
r.current =
|
|
1035
|
-
const
|
|
1040
|
+
function Ke(e) {
|
|
1041
|
+
const n = _(), r = A(z(e));
|
|
1042
|
+
r.current = z(e), k(() => {
|
|
1043
|
+
const t = {
|
|
1036
1044
|
navigated: !1,
|
|
1045
|
+
pausedTurnNavigated: !1,
|
|
1037
1046
|
depth: 0,
|
|
1038
1047
|
runId: 0,
|
|
1039
1048
|
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
|
-
|
|
1049
|
+
}, o = () => n.getRegisteredFunctions().some((f) => f.name === r.current.pageStateFunctionName), s = (f) => new Promise((m) => {
|
|
1050
|
+
let S = !1;
|
|
1051
|
+
const w = (p) => {
|
|
1052
|
+
S || (S = !0, clearTimeout(u), n.off("context:changed", x), m(p));
|
|
1053
|
+
}, a = () => setTimeout(() => w(f === t.runId && o()), r.current.settleMs), x = () => {
|
|
1054
|
+
if (f !== t.runId) return w(!1);
|
|
1055
|
+
o() && (n.off("context:changed", x), a());
|
|
1056
|
+
}, u = setTimeout(() => w(!1), r.current.readinessTimeoutMs);
|
|
1057
|
+
o() ? a() : n.on("context:changed", x);
|
|
1058
|
+
}), c = async (f) => {
|
|
1059
|
+
const m = ++t.runId;
|
|
1060
|
+
if (!(!await s(m) || m !== t.runId)) {
|
|
1061
|
+
t.depth += 1, t.ourSendPending = !0;
|
|
1053
1062
|
try {
|
|
1054
|
-
await
|
|
1055
|
-
conversationId:
|
|
1063
|
+
await n.sendMessage(r.current.continuationPrompt, {
|
|
1064
|
+
conversationId: f,
|
|
1056
1065
|
hidden: !0
|
|
1057
1066
|
});
|
|
1058
1067
|
} catch {
|
|
1059
|
-
|
|
1068
|
+
t.ourSendPending = !1;
|
|
1060
1069
|
}
|
|
1061
1070
|
}
|
|
1062
|
-
}, l = (
|
|
1063
|
-
r.current.navigationFunctions.includes(
|
|
1064
|
-
}, g = () => {
|
|
1065
|
-
|
|
1066
|
-
},
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
}, b = () => {
|
|
1071
|
-
|
|
1071
|
+
}, l = (f) => {
|
|
1072
|
+
r.current.navigationFunctions.includes(f.functionName) && (t.navigated = !0);
|
|
1073
|
+
}, g = n.registerResumeGate(async () => {
|
|
1074
|
+
r.current.enabled && t.pausedTurnNavigated && (t.pausedTurnNavigated = !1, await s(++t.runId));
|
|
1075
|
+
}), d = () => {
|
|
1076
|
+
t.pausedTurnNavigated = t.navigated, t.navigated = !1;
|
|
1077
|
+
}, y = () => {
|
|
1078
|
+
t.ourSendPending || (t.depth = 0, t.runId += 1);
|
|
1079
|
+
}, b = (f) => {
|
|
1080
|
+
t.ourSendPending = !1;
|
|
1081
|
+
const m = t.navigated;
|
|
1082
|
+
t.navigated = !1, r.current.enabled && m && (t.depth >= r.current.maxDepth || c(f.conversationId));
|
|
1083
|
+
}, I = () => {
|
|
1084
|
+
t.ourSendPending = !1;
|
|
1072
1085
|
};
|
|
1073
|
-
return
|
|
1074
|
-
|
|
1086
|
+
return n.on("function:invoke", l), n.on("message:start", y), n.on("message:waiting-client", d), n.on("message:complete", b), n.on("message:error", I), () => {
|
|
1087
|
+
t.runId += 1, g(), n.off("function:invoke", l), n.off("message:start", y), n.off("message:waiting-client", d), n.off("message:complete", b), n.off("message:error", I);
|
|
1075
1088
|
};
|
|
1076
|
-
}, [
|
|
1089
|
+
}, [n]);
|
|
1077
1090
|
}
|
|
1078
|
-
function
|
|
1079
|
-
const r =
|
|
1080
|
-
|
|
1091
|
+
function qe(e, n) {
|
|
1092
|
+
const r = _(), t = te(), o = n ?? t, s = A(e);
|
|
1093
|
+
s.current = e;
|
|
1081
1094
|
const c = typeof e == "function";
|
|
1082
|
-
|
|
1083
|
-
if (typeof
|
|
1084
|
-
const l = () =>
|
|
1095
|
+
k(() => {
|
|
1096
|
+
if (typeof s.current == "function") {
|
|
1097
|
+
const l = () => s.current();
|
|
1085
1098
|
return r.addDynamicContext(o, l), () => {
|
|
1086
1099
|
r.removeDynamicContext(o);
|
|
1087
1100
|
};
|
|
1088
1101
|
}
|
|
1089
|
-
return r.setContext(o,
|
|
1102
|
+
return r.setContext(o, s.current), () => {
|
|
1090
1103
|
r.removeContext(o);
|
|
1091
1104
|
};
|
|
1092
1105
|
}, [
|
|
@@ -1096,70 +1109,70 @@ function Ge(e, t) {
|
|
|
1096
1109
|
c ? "" : JSON.stringify(e)
|
|
1097
1110
|
]);
|
|
1098
1111
|
}
|
|
1099
|
-
function
|
|
1112
|
+
function Ae(e) {
|
|
1100
1113
|
return ne(e.subscribe, e.get, e.get);
|
|
1101
1114
|
}
|
|
1102
|
-
var
|
|
1115
|
+
var H = {
|
|
1103
1116
|
missing: [],
|
|
1104
1117
|
complete: !1
|
|
1105
1118
|
};
|
|
1106
1119
|
function Je(e) {
|
|
1107
|
-
const
|
|
1120
|
+
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
1121
|
r,
|
|
1109
1122
|
e.name,
|
|
1110
|
-
|
|
1111
|
-
|
|
1123
|
+
t,
|
|
1124
|
+
s,
|
|
1112
1125
|
c,
|
|
1113
1126
|
e.autoSubmit
|
|
1114
|
-
]), [g,
|
|
1127
|
+
]), [g, d] = M({
|
|
1115
1128
|
collector: null,
|
|
1116
1129
|
loading: !r,
|
|
1117
1130
|
error: null
|
|
1118
1131
|
});
|
|
1119
|
-
|
|
1132
|
+
k(() => {
|
|
1120
1133
|
if (r) return;
|
|
1121
|
-
let
|
|
1122
|
-
return
|
|
1134
|
+
let x = !1;
|
|
1135
|
+
return d({
|
|
1123
1136
|
collector: null,
|
|
1124
1137
|
loading: !0,
|
|
1125
1138
|
error: null
|
|
1126
|
-
}),
|
|
1127
|
-
|
|
1128
|
-
collector:
|
|
1139
|
+
}), O(n, e).then((u) => {
|
|
1140
|
+
x || d({
|
|
1141
|
+
collector: u,
|
|
1129
1142
|
loading: !1,
|
|
1130
1143
|
error: null
|
|
1131
1144
|
});
|
|
1132
|
-
}).catch((
|
|
1133
|
-
|
|
1145
|
+
}).catch((u) => {
|
|
1146
|
+
x || d({
|
|
1134
1147
|
collector: null,
|
|
1135
1148
|
loading: !1,
|
|
1136
|
-
error:
|
|
1149
|
+
error: u instanceof Error ? u : new Error(String(u))
|
|
1137
1150
|
});
|
|
1138
1151
|
}), () => {
|
|
1139
|
-
|
|
1152
|
+
x = !0;
|
|
1140
1153
|
};
|
|
1141
1154
|
}, [
|
|
1142
|
-
|
|
1155
|
+
n,
|
|
1143
1156
|
r,
|
|
1144
1157
|
e.name,
|
|
1145
|
-
|
|
1158
|
+
s,
|
|
1146
1159
|
c,
|
|
1147
1160
|
e.autoSubmit
|
|
1148
1161
|
]);
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1151
|
-
if (
|
|
1152
|
-
return
|
|
1153
|
-
}, [
|
|
1154
|
-
const
|
|
1162
|
+
const y = r ? l : g.collector, b = r ? !1 : g.loading, I = r ? null : g.error;
|
|
1163
|
+
k(() => {
|
|
1164
|
+
if (y)
|
|
1165
|
+
return y.install(n);
|
|
1166
|
+
}, [n, y]);
|
|
1167
|
+
const f = F(() => Q({
|
|
1155
1168
|
values: e.initialValues ?? {},
|
|
1156
1169
|
submitted: !1
|
|
1157
|
-
}), [c]), m =
|
|
1170
|
+
}), [c]), m = Ae(y?.store ?? f), S = F(() => y?.getStatus() ?? H, [m, y]), w = F(() => ({
|
|
1158
1171
|
...m,
|
|
1159
|
-
...
|
|
1160
|
-
}), [m,
|
|
1172
|
+
...S
|
|
1173
|
+
}), [m, S]), a = F(() => ({
|
|
1161
1174
|
name: e.name,
|
|
1162
|
-
store:
|
|
1175
|
+
store: f,
|
|
1163
1176
|
functions: [],
|
|
1164
1177
|
contextKey: `form:${e.name}`,
|
|
1165
1178
|
contextProvider: () => ({
|
|
@@ -1174,18 +1187,18 @@ function Je(e) {
|
|
|
1174
1187
|
ok: !1,
|
|
1175
1188
|
error: "Form definition not loaded yet."
|
|
1176
1189
|
}),
|
|
1177
|
-
getValues: () =>
|
|
1190
|
+
getValues: () => f.get().values,
|
|
1178
1191
|
setValues: () => {
|
|
1179
1192
|
},
|
|
1180
1193
|
reset: () => {
|
|
1181
1194
|
},
|
|
1182
|
-
getStatus: () =>
|
|
1183
|
-
}), [e.name,
|
|
1195
|
+
getStatus: () => H
|
|
1196
|
+
}), [e.name, f]);
|
|
1184
1197
|
return {
|
|
1185
|
-
...
|
|
1186
|
-
state:
|
|
1187
|
-
loading:
|
|
1188
|
-
error:
|
|
1198
|
+
...y ?? a,
|
|
1199
|
+
state: w,
|
|
1200
|
+
loading: b,
|
|
1201
|
+
error: I
|
|
1189
1202
|
};
|
|
1190
1203
|
}
|
|
1191
1204
|
export {
|
|
@@ -1194,21 +1207,21 @@ export {
|
|
|
1194
1207
|
Oe as ChatWidget,
|
|
1195
1208
|
Se as Markdown,
|
|
1196
1209
|
Me as Message,
|
|
1197
|
-
|
|
1210
|
+
$ as createFormCollector,
|
|
1198
1211
|
_e as createMockClient,
|
|
1199
|
-
|
|
1200
|
-
|
|
1212
|
+
Pe as deriveFormStatus,
|
|
1213
|
+
O as loadFormCollector,
|
|
1201
1214
|
ae as useAgo,
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1215
|
+
Ke as useAgoAutoContinueAfterNavigation,
|
|
1216
|
+
_ as useAgoClient,
|
|
1217
|
+
qe as useAgoContext,
|
|
1205
1218
|
Be as useAgoFunction,
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1219
|
+
Ge as useAgoNavigation,
|
|
1220
|
+
Ue as useAgoPageState,
|
|
1221
|
+
Ae as useAgoStore,
|
|
1209
1222
|
$e as useChat,
|
|
1210
1223
|
Re as useConversation,
|
|
1211
1224
|
Je as useFormCollector,
|
|
1212
1225
|
U as useMessages,
|
|
1213
|
-
|
|
1226
|
+
W as useOptionalAgoClient
|
|
1214
1227
|
};
|