@useago/sdk 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/AgoClient-5VGybmvz.cjs +8 -0
  3. package/dist/AgoClient-DXrH2AMi.js +964 -0
  4. package/dist/angular.cjs +1 -1
  5. package/dist/angular.d.cts +79 -2
  6. package/dist/angular.d.ts +79 -2
  7. package/dist/angular.js +2 -2
  8. package/dist/{createConversationSession-BBYfQLLS.cjs → createConversationSession-0WTqcCLK.cjs} +1 -1
  9. package/dist/{createConversationSession-DCSWShaW.js → createConversationSession-DPrrr70o.js} +1 -1
  10. package/dist/createFormCollector-1GKKwQV_.cjs +1 -0
  11. package/dist/{createFormCollector-sB6rMccD.js → createFormCollector-DYh90kiG.js} +97 -91
  12. package/dist/devtools.d.cts +79 -2
  13. package/dist/devtools.d.ts +79 -2
  14. package/dist/functions-CPs7omgM.cjs +1 -0
  15. package/dist/helpers.cjs +1 -1
  16. package/dist/helpers.d.cts +5 -0
  17. package/dist/helpers.d.ts +5 -0
  18. package/dist/helpers.js +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +95 -4
  21. package/dist/index.d.ts +95 -4
  22. package/dist/index.js +6 -6
  23. package/dist/react.cjs +3 -3
  24. package/dist/react.d.cts +186 -4
  25. package/dist/react.d.ts +186 -4
  26. package/dist/react.js +670 -475
  27. package/dist/testing.cjs +1 -1
  28. package/dist/testing.d.cts +79 -2
  29. package/dist/testing.d.ts +79 -2
  30. package/dist/testing.js +1 -1
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.d.cts +79 -2
  33. package/dist/vue.d.ts +79 -2
  34. package/dist/vue.js +1 -1
  35. package/dist/widget.cjs +4 -4
  36. package/dist/widget.d.cts +79 -2
  37. package/dist/widget.d.ts +79 -2
  38. package/dist/widget.js +437 -423
  39. package/llms-full.txt +74 -2
  40. package/package.json +1 -1
  41. package/dist/AgoClient-q39FIjSC.js +0 -912
  42. package/dist/AgoClient-wcPRaIMs.cjs +0 -8
  43. package/dist/createFormCollector-eimwwWEi.cjs +0 -1
  44. package/dist/functions-IGSjjvF4.cjs +0 -1
  45. package/dist/rolldown-runtime-16Nf8qvH.cjs +0 -1
  46. /package/dist/{autoContinue-D3Mmaaca.js → autoContinue-CC8K9mBU.js} +0 -0
  47. /package/dist/{autoContinue-CcCTva-D.cjs → autoContinue-CP9pJR-V.cjs} +0 -0
  48. /package/dist/{createMockClient-CjdCqixj.cjs → createMockClient-C-wrjb2C.cjs} +0 -0
  49. /package/dist/{createMockClient-BUc9PSbo.js → createMockClient-we-XoPom.js} +0 -0
  50. /package/dist/{functions-CApuQZ2b.js → functions-tzyOZNp6.js} +0 -0
package/dist/react.js CHANGED
@@ -1,21 +1,21 @@
1
- import { a as q, i as J, o as j, s as V, t as Y } from "./AgoClient-q39FIjSC.js";
2
- import { t as X } from "./autoContinue-D3Mmaaca.js";
3
- import { i as Q, n as _e, r as H, t as O } from "./createFormCollector-sB6rMccD.js";
4
- import { t as Pe } from "./createMockClient-BUc9PSbo.js";
5
- import Z, { createContext as ee, useCallback as A, useContext as $, useEffect as k, useId as te, useMemo as T, useRef as E, useState as M, useSyncExternalStore as ne } from "react";
6
- import { Fragment as B, jsx as a, jsxs as R } from "react/jsx-runtime";
7
- import re from "react-markdown";
8
- import oe from "remark-gfm";
9
- function ae(e) {
10
- const [t, r] = M(!1), n = E(null), o = T(() => {
11
- if (n.current && (n.current.destroy(), n.current = null), !e) return null;
12
- const i = new Y(e);
13
- return n.current = i, i;
1
+ import { a as V, i as Y, m as X, o as Z, s as Q, t as ee } from "./AgoClient-DXrH2AMi.js";
2
+ import { t as te } from "./autoContinue-CC8K9mBU.js";
3
+ import { i as ne, n as He, r as O, t as j } from "./createFormCollector-DYh90kiG.js";
4
+ import { t as qe } from "./createMockClient-we-XoPom.js";
5
+ import re, { createContext as oe, useCallback as R, useContext as B, useEffect as N, useId as ae, useMemo as D, useRef as T, useState as E, useSyncExternalStore as se } from "react";
6
+ import { Fragment as G, jsx as l, jsxs as F } from "react/jsx-runtime";
7
+ import ie from "react-markdown";
8
+ import le from "remark-gfm";
9
+ function ce(e) {
10
+ const [t, r] = E(!1), o = T(null), n = D(() => {
11
+ if (o.current && (o.current.destroy(), o.current = null), !e) return null;
12
+ const s = new ee(e);
13
+ return o.current = s, s;
14
14
  }, [e?.baseUrl, e?.widgetId]);
15
- return k(() => (r(!0), () => {
16
- n.current?.destroy(), n.current = null;
17
- }), [o]), k(() => {
18
- n.current && e && n.current.updateConfig({
15
+ return N(() => (r(!0), () => {
16
+ o.current?.destroy(), o.current = null;
17
+ }), [n]), N(() => {
18
+ o.current && e && o.current.updateConfig({
19
19
  agent: e.agent,
20
20
  defaultAgentId: e.defaultAgentId,
21
21
  permission: e.permission,
@@ -33,200 +33,200 @@ function ae(e) {
33
33
  e?.debug,
34
34
  e?.warnOnEmptyReply
35
35
  ]), {
36
- client: o,
36
+ client: n,
37
37
  isReady: t
38
38
  };
39
39
  }
40
- var L = ee(null), He = ({ children: e, client: t, tools: r, helpers: n, pageContext: o, ...i }) => {
41
- const { client: c } = ae(t ? null : i), l = t || c;
42
- return k(() => {
40
+ var z = oe(null), Ke = ({ children: e, client: t, tools: r, helpers: o, pageContext: n, ...s }) => {
41
+ const { client: f } = ce(t ? null : s), i = t || f;
42
+ return N(() => {
43
43
  if (!(!r || r.length === 0)) {
44
- for (const f of r) l.register(f);
44
+ for (const m of r) i.register(m);
45
45
  return () => {
46
- for (const f of r) l.unregisterFunction(f.name);
46
+ for (const m of r) i.unregisterFunction(m.name);
47
47
  };
48
48
  }
49
- }, [l, r]), k(() => {
50
- if (!n) return;
51
- const f = [];
52
- return import("./functions-CApuQZ2b.js").then((u) => u.n).then((u) => {
53
- for (const [y, v] of Object.entries(n)) {
54
- const I = u[y];
55
- if (!I) {
56
- console.warn(`[AGO] Unknown helper: "${y}"`);
49
+ }, [i, r]), N(() => {
50
+ if (!o) return;
51
+ const m = [];
52
+ return import("./functions-tzyOZNp6.js").then((u) => u.n).then((u) => {
53
+ for (const [g, C] of Object.entries(o)) {
54
+ const A = u[g];
55
+ if (!A) {
56
+ console.warn(`[AGO] Unknown helper: "${g}"`);
57
57
  continue;
58
58
  }
59
- const x = v === !0 ? I : {
60
- ...I,
61
- handler: v
59
+ const S = C === !0 ? A : {
60
+ ...A,
61
+ handler: C
62
62
  };
63
- l.register(x), f.push(x.name);
63
+ i.register(S), m.push(S.name);
64
64
  }
65
65
  }), () => {
66
- for (const u of f) l.unregisterFunction(u);
66
+ for (const u of m) i.unregisterFunction(u);
67
67
  };
68
- }, [l, n]), k(() => {
69
- o === "auto" && l.enableAutoPageContext();
70
- }, [l, o]), /* @__PURE__ */ a(L.Provider, {
71
- value: l,
68
+ }, [i, o]), N(() => {
69
+ n === "auto" && i.enableAutoPageContext();
70
+ }, [i, n]), /* @__PURE__ */ l(z.Provider, {
71
+ value: i,
72
72
  children: e
73
73
  });
74
74
  };
75
- function P() {
76
- const e = $(L);
75
+ function W() {
76
+ const e = B(z);
77
77
  if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
78
78
  return e;
79
79
  }
80
- function z() {
81
- return $(L);
80
+ function L() {
81
+ return B(z);
82
82
  }
83
- function G({ client: e, conversationId: t } = {}) {
84
- const r = z(), n = e || r;
85
- if (!n) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
86
- const [o, i] = M([]), [c, l] = M(t), [f, u] = M(!1), [y, v] = M(null);
87
- k(() => {
88
- t && t !== c && (l(t), I(t));
83
+ function K({ client: e, conversationId: t } = {}) {
84
+ const r = L(), o = e || r;
85
+ if (!o) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
86
+ const [n, s] = E([]), [f, i] = E(t), [m, u] = E(!1), [g, C] = E(null);
87
+ N(() => {
88
+ t && t !== f && (i(t), A(t));
89
89
  }, [t]);
90
- const I = async (x) => {
90
+ const A = async (S) => {
91
91
  try {
92
- i((await n.getMessages(x)).filter((h) => !h.hidden));
93
- } catch (h) {
94
- v(h instanceof Error ? h : /* @__PURE__ */ new Error("Failed to load messages"));
92
+ s((await o.getMessages(S)).filter((k) => !k.hidden));
93
+ } catch (k) {
94
+ C(k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to load messages"));
95
95
  }
96
96
  };
97
- return k(() => {
98
- const x = (d) => d === "IN_PROGRESS" || d === "WAITING_CLIENT", h = (d) => {
99
- c || l(d.conversationId), u(!0), i((p) => {
100
- const m = p.findIndex((g) => g.id === d.messageId);
101
- return m >= 0 ? p.map((g, W) => W === m ? {
102
- ...g,
97
+ return N(() => {
98
+ const S = (c) => c === "IN_PROGRESS" || c === "WAITING_CLIENT", k = (c) => {
99
+ f || i(c.conversationId), u(!0), s((h) => {
100
+ const w = h.findIndex((b) => b.id === c.messageId);
101
+ return w >= 0 ? h.map((b, _) => _ === w ? {
102
+ ...b,
103
103
  status: "IN_PROGRESS"
104
- } : g) : p.some((g) => g.role === "assistant" && x(g.status)) ? p : [...p, {
105
- id: d.messageId,
106
- conversationId: d.conversationId,
104
+ } : b) : h.some((b) => b.role === "assistant" && S(b.status)) ? h : [...h, {
105
+ id: c.messageId,
106
+ conversationId: c.conversationId,
107
107
  content: "",
108
108
  role: "assistant",
109
109
  status: "IN_PROGRESS",
110
110
  createdAt: /* @__PURE__ */ new Date()
111
111
  }];
112
112
  });
113
- }, C = (d) => {
114
- i((p) => {
115
- const m = p.findIndex((g) => g.id === d.messageId);
116
- return m < 0 ? p : p.map((g, W) => W === m ? {
117
- ...g,
118
- content: g.content + d.content
119
- } : g);
113
+ }, d = (c) => {
114
+ s((h) => {
115
+ const w = h.findIndex((b) => b.id === c.messageId);
116
+ return w < 0 ? h : h.map((b, _) => _ === w ? {
117
+ ...b,
118
+ content: b.content + c.content
119
+ } : b);
120
120
  });
121
- }, S = (d) => {
122
- i((p) => {
123
- let m = -1;
124
- for (let g = p.length - 1; g >= 0; g--) if (p[g].role === "assistant" && x(p[g].status)) {
125
- m = g;
121
+ }, x = (c) => {
122
+ s((h) => {
123
+ let w = -1;
124
+ for (let b = h.length - 1; b >= 0; b--) if (h[b].role === "assistant" && S(h[b].status)) {
125
+ w = b;
126
126
  break;
127
127
  }
128
- return m < 0 ? p : [
129
- ...p.slice(0, m),
128
+ return w < 0 ? h : [
129
+ ...h.slice(0, w),
130
130
  {
131
- ...p[m],
132
- ...d
131
+ ...h[w],
132
+ ...c
133
133
  },
134
- ...p.slice(m + 1)
134
+ ...h.slice(w + 1)
135
135
  ];
136
136
  });
137
- }, s = (d) => {
138
- i((p) => {
139
- const m = p.findIndex((g) => g.id === d.id);
140
- return m >= 0 ? [
141
- ...p.slice(0, m),
142
- d,
143
- ...p.slice(m + 1)
144
- ] : [...p, d];
137
+ }, a = (c) => {
138
+ s((h) => {
139
+ const w = h.findIndex((b) => b.id === c.id);
140
+ return w >= 0 ? [
141
+ ...h.slice(0, w),
142
+ c,
143
+ ...h.slice(w + 1)
144
+ ] : [...h, c];
145
145
  }), u(!1);
146
- }, b = (d) => {
147
- v(new Error(d.error)), u(!1);
146
+ }, v = (c) => {
147
+ C(new Error(c.error)), u(!1);
148
148
  };
149
- return n.on("message:start", h), n.on("message:chunk", C), n.on("message:answer-complete", S), n.on("message:complete", s), n.on("message:error", b), () => {
150
- n.off("message:start", h), n.off("message:chunk", C), n.off("message:answer-complete", S), n.off("message:complete", s), n.off("message:error", b);
149
+ return o.on("message:start", k), o.on("message:chunk", d), o.on("message:answer-complete", x), o.on("message:complete", a), o.on("message:error", v), () => {
150
+ o.off("message:start", k), o.off("message:chunk", d), o.off("message:answer-complete", x), o.off("message:complete", a), o.off("message:error", v);
151
151
  };
152
- }, [n, c]), {
153
- messages: o,
154
- isLoading: f,
155
- error: y,
156
- sendMessage: A(async (x, h) => {
157
- u(!0), v(null);
158
- const C = {
152
+ }, [o, f]), {
153
+ messages: n,
154
+ isLoading: m,
155
+ error: g,
156
+ sendMessage: R(async (S, k) => {
157
+ u(!0), C(null);
158
+ const d = {
159
159
  id: `temp-${Date.now()}`,
160
- conversationId: c || "",
161
- content: x,
160
+ conversationId: f || "",
161
+ content: S,
162
162
  role: "user",
163
163
  status: "DONE",
164
- attachments: h && h.length > 0 ? J(h) : void 0,
164
+ attachments: k && k.length > 0 ? Y(k) : void 0,
165
165
  createdAt: /* @__PURE__ */ new Date()
166
- }, S = {
166
+ }, x = {
167
167
  id: `temp-assistant-${Date.now()}`,
168
- conversationId: c || "",
168
+ conversationId: f || "",
169
169
  content: "",
170
170
  role: "assistant",
171
171
  status: "IN_PROGRESS",
172
172
  createdAt: /* @__PURE__ */ new Date()
173
173
  };
174
- i((s) => [
175
- ...s,
176
- C,
177
- S
174
+ s((a) => [
175
+ ...a,
176
+ d,
177
+ x
178
178
  ]);
179
179
  try {
180
- const s = await n.sendMessage(x, {
181
- conversationId: c,
182
- files: h
180
+ const a = await o.sendMessage(S, {
181
+ conversationId: f,
182
+ files: k
183
183
  });
184
- return s.conversationId && !c && l(s.conversationId), i((b) => {
185
- const d = b.filter((m) => !m.id.startsWith("temp-")), p = {
186
- ...C,
187
- id: C.id.replace("temp-", "user-"),
188
- conversationId: s.conversationId
189
- };
190
- return d.some((m) => m.id === s.id) ? [...d, p].sort((m, g) => new Date(m.createdAt).getTime() - new Date(g.createdAt).getTime()) : [
184
+ return a.conversationId && !f && i(a.conversationId), s((v) => {
185
+ const c = v.filter((w) => !w.id.startsWith("temp-")), h = {
191
186
  ...d,
192
- p,
193
- s
187
+ id: d.id.replace("temp-", "user-"),
188
+ conversationId: a.conversationId
189
+ };
190
+ return c.some((w) => w.id === a.id) ? [...c, h].sort((w, b) => new Date(w.createdAt).getTime() - new Date(b.createdAt).getTime()) : [
191
+ ...c,
192
+ h,
193
+ a
194
194
  ];
195
- }), s;
196
- } catch (s) {
197
- return v(s instanceof Error ? s : /* @__PURE__ */ new Error("Failed to send message")), u(!1), i((b) => b.filter((d) => !d.id.startsWith("temp-"))), null;
195
+ }), a;
196
+ } catch (a) {
197
+ return C(a instanceof Error ? a : /* @__PURE__ */ new Error("Failed to send message")), u(!1), s((v) => v.filter((c) => !c.id.startsWith("temp-"))), null;
198
198
  }
199
- }, [n, c]),
200
- clearMessages: A(() => {
201
- i([]), l(void 0), v(null);
199
+ }, [o, f]),
200
+ clearMessages: R(() => {
201
+ s([]), i(void 0), C(null);
202
202
  }, []),
203
- conversationId: c
203
+ conversationId: f
204
204
  };
205
205
  }
206
- var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", allowFiles: n = !1, className: o = "" }) => {
207
- const [i, c] = M(""), [l, f] = M([]), u = E(null), y = E(null), v = A(() => {
208
- const s = y.current;
209
- if (!s) return;
210
- const b = 110;
211
- s.style.height = "auto", s.style.height = `${Math.min(s.scrollHeight + 2, b)}px`, s.style.overflowY = s.scrollHeight + 2 > b ? "auto" : "hidden";
212
- }, []), I = A((s) => {
213
- s.preventDefault(), (i.trim() || l.length > 0) && (e(i.trim(), l.length > 0 ? l : void 0), c(""), f([]), requestAnimationFrame(v));
206
+ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", allowFiles: o = !1, className: n = "" }) => {
207
+ const [s, f] = E(""), [i, m] = E([]), u = T(null), g = T(null), C = R(() => {
208
+ const a = g.current;
209
+ if (!a) return;
210
+ const v = 110;
211
+ a.style.height = "auto", a.style.height = `${Math.min(a.scrollHeight + 2, v)}px`, a.style.overflowY = a.scrollHeight + 2 > v ? "auto" : "hidden";
212
+ }, []), A = R((a) => {
213
+ a.preventDefault(), (s.trim() || i.length > 0) && (e(s.trim(), i.length > 0 ? i : void 0), f(""), m([]), requestAnimationFrame(C));
214
214
  }, [
215
+ s,
215
216
  i,
216
- l,
217
217
  e,
218
- v
219
- ]), x = A((s) => {
220
- s.key === "Enter" && !s.shiftKey && (s.preventDefault(), I(s));
221
- }, [I]), h = A((s) => {
222
- const b = Array.from(s.target.files || []);
223
- f((d) => [...d, ...b]);
224
- }, []), C = A((s) => {
225
- f((b) => b.filter((d, p) => p !== s));
226
- }, []), S = i.trim() || l.length > 0;
227
- return /* @__PURE__ */ R("form", {
228
- onSubmit: I,
229
- className: `ago-chat-input ${o}`,
218
+ C
219
+ ]), S = R((a) => {
220
+ a.key === "Enter" && !a.shiftKey && (a.preventDefault(), A(a));
221
+ }, [A]), k = R((a) => {
222
+ const v = Array.from(a.target.files || []);
223
+ m((c) => [...c, ...v]);
224
+ }, []), d = R((a) => {
225
+ m((v) => v.filter((c, h) => h !== a));
226
+ }, []), x = s.trim() || i.length > 0;
227
+ return /* @__PURE__ */ F("form", {
228
+ onSubmit: A,
229
+ className: `ago-chat-input ${n}`,
230
230
  style: {
231
231
  display: "flex",
232
232
  flexDirection: "column",
@@ -235,14 +235,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
235
235
  borderTop: "1px solid #dee3e8",
236
236
  backgroundColor: "#fff"
237
237
  },
238
- children: [l.length > 0 && /* @__PURE__ */ a("div", {
238
+ children: [i.length > 0 && /* @__PURE__ */ l("div", {
239
239
  className: "ago-chat-input__files",
240
240
  style: {
241
241
  display: "flex",
242
242
  flexWrap: "wrap",
243
243
  gap: "6px"
244
244
  },
245
- children: l.map((s, b) => /* @__PURE__ */ R("div", {
245
+ children: i.map((a, v) => /* @__PURE__ */ F("div", {
246
246
  style: {
247
247
  display: "flex",
248
248
  alignItems: "center",
@@ -253,18 +253,18 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
253
253
  fontSize: "12px",
254
254
  color: "#30373e"
255
255
  },
256
- children: [/* @__PURE__ */ a("span", {
256
+ children: [/* @__PURE__ */ l("span", {
257
257
  style: {
258
258
  maxWidth: "120px",
259
259
  overflow: "hidden",
260
260
  textOverflow: "ellipsis",
261
261
  whiteSpace: "nowrap"
262
262
  },
263
- children: s.name
264
- }), /* @__PURE__ */ a("button", {
263
+ children: a.name
264
+ }), /* @__PURE__ */ l("button", {
265
265
  type: "button",
266
- onClick: () => C(b),
267
- "aria-label": `Remove ${s.name}`,
266
+ onClick: () => d(v),
267
+ "aria-label": `Remove ${a.name}`,
268
268
  style: {
269
269
  border: "none",
270
270
  background: "none",
@@ -276,15 +276,15 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
276
276
  },
277
277
  children: "×"
278
278
  })]
279
- }, b))
280
- }), /* @__PURE__ */ R("div", {
279
+ }, v))
280
+ }), /* @__PURE__ */ F("div", {
281
281
  style: {
282
282
  display: "flex",
283
283
  gap: "8px",
284
284
  alignItems: "flex-end"
285
285
  },
286
286
  children: [
287
- n && /* @__PURE__ */ R(B, { children: [/* @__PURE__ */ a("button", {
287
+ o && /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ l("button", {
288
288
  type: "button",
289
289
  onClick: () => u.current?.click(),
290
290
  disabled: t,
@@ -300,20 +300,20 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
300
300
  lineHeight: 1
301
301
  },
302
302
  children: "+"
303
- }), /* @__PURE__ */ a("input", {
303
+ }), /* @__PURE__ */ l("input", {
304
304
  ref: u,
305
305
  type: "file",
306
306
  multiple: !0,
307
- onChange: h,
307
+ onChange: k,
308
308
  style: { display: "none" }
309
309
  })] }),
310
- /* @__PURE__ */ a("textarea", {
311
- ref: y,
312
- value: i,
313
- onChange: (s) => {
314
- c(s.target.value), v();
310
+ /* @__PURE__ */ l("textarea", {
311
+ ref: g,
312
+ value: s,
313
+ onChange: (a) => {
314
+ f(a.target.value), C();
315
315
  },
316
- onKeyDown: x,
316
+ onKeyDown: S,
317
317
  placeholder: r,
318
318
  "aria-label": r,
319
319
  disabled: t,
@@ -335,23 +335,23 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
335
335
  backgroundColor: "#f8f8f8",
336
336
  transition: "border-color 0.15s"
337
337
  },
338
- onFocus: (s) => {
339
- s.currentTarget.style.borderColor = "#1b5fc4";
338
+ onFocus: (a) => {
339
+ a.currentTarget.style.borderColor = "#1b5fc4";
340
340
  },
341
- onBlur: (s) => {
342
- s.currentTarget.style.borderColor = "#dee3e8";
341
+ onBlur: (a) => {
342
+ a.currentTarget.style.borderColor = "#dee3e8";
343
343
  }
344
344
  }),
345
- /* @__PURE__ */ a("button", {
345
+ /* @__PURE__ */ l("button", {
346
346
  type: "submit",
347
- disabled: t || !S,
347
+ disabled: t || !x,
348
348
  style: {
349
349
  padding: "10px 18px",
350
350
  border: "none",
351
351
  borderRadius: "20px",
352
- backgroundColor: t || !S ? "#b5bfc8" : "#03182f",
352
+ backgroundColor: t || !x ? "#b5bfc8" : "#03182f",
353
353
  color: "#fff",
354
- cursor: t || !S ? "not-allowed" : "pointer",
354
+ cursor: t || !x ? "not-allowed" : "pointer",
355
355
  fontWeight: 500,
356
356
  fontSize: "16px",
357
357
  transition: "background-color 0.15s"
@@ -361,7 +361,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
361
361
  ]
362
362
  })]
363
363
  });
364
- }, ie = ({ href: e, children: t, ...r }) => /* @__PURE__ */ a("a", {
364
+ }, ue = ({ href: e, children: t, ...r }) => /* @__PURE__ */ l("a", {
365
365
  href: e,
366
366
  target: "_blank",
367
367
  rel: "noopener noreferrer",
@@ -371,25 +371,25 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
371
371
  },
372
372
  ...r,
373
373
  children: t
374
- }), le = ({ children: e, ...t }) => /* @__PURE__ */ a("p", {
374
+ }), fe = ({ children: e, ...t }) => /* @__PURE__ */ l("p", {
375
375
  style: {
376
376
  margin: "0 0 8px 0",
377
377
  lineHeight: "1.6"
378
378
  },
379
379
  ...t,
380
380
  children: e
381
- }), _ = (e, t) => {
382
- const r = ({ children: n, ...o }) => Z.createElement(`h${e}`, {
381
+ }), P = (e, t) => {
382
+ const r = ({ children: o, ...n }) => re.createElement(`h${e}`, {
383
383
  style: {
384
384
  margin: "16px 0 8px 0",
385
385
  fontSize: t,
386
386
  fontWeight: 600,
387
387
  lineHeight: "1.3"
388
388
  },
389
- ...o
390
- }, n);
389
+ ...n
390
+ }, o);
391
391
  return r.displayName = `MarkdownHeading${e}`, r;
392
- }, ce = ({ children: e, ...t }) => /* @__PURE__ */ a("ul", {
392
+ }, pe = ({ children: e, ...t }) => /* @__PURE__ */ l("ul", {
393
393
  style: {
394
394
  margin: "0 0 8px 0",
395
395
  paddingLeft: "20px",
@@ -398,7 +398,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
398
398
  },
399
399
  ...t,
400
400
  children: e
401
- }), de = ({ children: e, ...t }) => /* @__PURE__ */ a("ol", {
401
+ }), ge = ({ children: e, ...t }) => /* @__PURE__ */ l("ol", {
402
402
  style: {
403
403
  margin: "0 0 8px 0",
404
404
  paddingLeft: "20px",
@@ -407,7 +407,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
407
407
  },
408
408
  ...t,
409
409
  children: e
410
- }), ue = ({ children: e, ...t }) => /* @__PURE__ */ a("li", {
410
+ }), me = ({ children: e, ...t }) => /* @__PURE__ */ l("li", {
411
411
  style: {
412
412
  display: "list-item",
413
413
  margin: "2px 0",
@@ -415,8 +415,8 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
415
415
  },
416
416
  ...t,
417
417
  children: e
418
- }), fe = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
419
- `) ? /* @__PURE__ */ a("code", {
418
+ }), xe = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
419
+ `) ? /* @__PURE__ */ l("code", {
420
420
  style: {
421
421
  display: "block",
422
422
  background: "#f5f5f5",
@@ -428,7 +428,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
428
428
  },
429
429
  ...r,
430
430
  children: t
431
- }) : /* @__PURE__ */ a("code", {
431
+ }) : /* @__PURE__ */ l("code", {
432
432
  style: {
433
433
  background: "#f0f2f5",
434
434
  padding: "2px 5px",
@@ -438,11 +438,11 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
438
438
  },
439
439
  ...r,
440
440
  children: t
441
- }), pe = ({ children: e, ...t }) => /* @__PURE__ */ a("pre", {
441
+ }), he = ({ children: e, ...t }) => /* @__PURE__ */ l("pre", {
442
442
  style: { margin: "0 0 8px 0" },
443
443
  ...t,
444
444
  children: e
445
- }), ge = ({ children: e, ...t }) => /* @__PURE__ */ a("blockquote", {
445
+ }), ye = ({ children: e, ...t }) => /* @__PURE__ */ l("blockquote", {
446
446
  style: {
447
447
  borderLeft: "4px solid #dee3e8",
448
448
  paddingLeft: "12px",
@@ -452,12 +452,12 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
452
452
  },
453
453
  ...t,
454
454
  children: e
455
- }), me = ({ children: e, ...t }) => /* @__PURE__ */ a("div", {
455
+ }), ve = ({ children: e, ...t }) => /* @__PURE__ */ l("div", {
456
456
  style: {
457
457
  overflowX: "auto",
458
458
  margin: "0 0 8px 0"
459
459
  },
460
- children: /* @__PURE__ */ a("table", {
460
+ children: /* @__PURE__ */ l("table", {
461
461
  style: {
462
462
  borderCollapse: "collapse",
463
463
  width: "100%",
@@ -466,7 +466,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
466
466
  ...t,
467
467
  children: e
468
468
  })
469
- }), xe = ({ children: e, ...t }) => /* @__PURE__ */ a("th", {
469
+ }), be = ({ children: e, ...t }) => /* @__PURE__ */ l("th", {
470
470
  style: {
471
471
  border: "1px solid #dee3e8",
472
472
  padding: "6px 10px",
@@ -476,14 +476,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
476
476
  },
477
477
  ...t,
478
478
  children: e
479
- }), he = ({ children: e, ...t }) => /* @__PURE__ */ a("td", {
479
+ }), we = ({ children: e, ...t }) => /* @__PURE__ */ l("td", {
480
480
  style: {
481
481
  border: "1px solid #dee3e8",
482
482
  padding: "6px 10px"
483
483
  },
484
484
  ...t,
485
485
  children: e
486
- }), ye = ({ alt: e, ...t }) => /* @__PURE__ */ a("img", {
486
+ }), Ce = ({ alt: e, ...t }) => /* @__PURE__ */ l("img", {
487
487
  alt: e ?? "",
488
488
  style: {
489
489
  maxWidth: "100%",
@@ -491,40 +491,40 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
491
491
  margin: "4px 0"
492
492
  },
493
493
  ...t
494
- }), be = (e) => /* @__PURE__ */ a("hr", {
494
+ }), Se = (e) => /* @__PURE__ */ l("hr", {
495
495
  style: {
496
496
  border: "none",
497
497
  borderTop: "1px solid #dee3e8",
498
498
  margin: "12px 0"
499
499
  },
500
500
  ...e
501
- }), ve = {
502
- a: ie,
503
- p: le,
504
- h1: _(1, "20px"),
505
- h2: _(2, "18px"),
506
- h3: _(3, "16px"),
507
- h4: _(4, "15px"),
508
- h5: _(5, "14px"),
509
- h6: _(6, "13px"),
510
- ul: ce,
511
- ol: de,
512
- li: ue,
513
- code: fe,
514
- pre: pe,
515
- blockquote: ge,
516
- table: me,
517
- th: xe,
518
- td: he,
519
- img: ye,
520
- hr: be
521
- }, we = [oe], Ce = ({ content: e }) => /* @__PURE__ */ a(re, {
522
- remarkPlugins: we,
523
- components: ve,
501
+ }), ke = {
502
+ a: ue,
503
+ p: fe,
504
+ h1: P(1, "20px"),
505
+ h2: P(2, "18px"),
506
+ h3: P(3, "16px"),
507
+ h4: P(4, "15px"),
508
+ h5: P(5, "14px"),
509
+ h6: P(6, "13px"),
510
+ ul: pe,
511
+ ol: ge,
512
+ li: me,
513
+ code: xe,
514
+ pre: he,
515
+ blockquote: ye,
516
+ table: ve,
517
+ th: be,
518
+ td: we,
519
+ img: Ce,
520
+ hr: Se
521
+ }, Ie = [le], Ae = ({ content: e }) => /* @__PURE__ */ l(ie, {
522
+ remarkPlugins: Ie,
523
+ components: ke,
524
524
  children: e
525
- }), Se = ({ attachment: e, isUser: t }) => {
526
- const r = V(e.url);
527
- if (q(e)) return /* @__PURE__ */ a("a", {
525
+ }), Ne = ({ attachment: e, isUser: t }) => {
526
+ const r = Q(e.url);
527
+ if (V(e)) return /* @__PURE__ */ l("a", {
528
528
  href: r,
529
529
  target: "_blank",
530
530
  rel: "noopener noreferrer",
@@ -532,7 +532,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
532
532
  display: "inline-block",
533
533
  textDecoration: "none"
534
534
  },
535
- children: /* @__PURE__ */ a("img", {
535
+ children: /* @__PURE__ */ l("img", {
536
536
  src: r,
537
537
  alt: e.name,
538
538
  loading: "lazy",
@@ -546,7 +546,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
546
546
  }
547
547
  })
548
548
  });
549
- const n = j(e.fileSize), o = /* @__PURE__ */ R(B, { children: [/* @__PURE__ */ a("span", {
549
+ const o = Z(e.fileSize), n = /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ l("span", {
550
550
  style: {
551
551
  fontSize: "16px",
552
552
  lineHeight: 1,
@@ -554,13 +554,13 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
554
554
  },
555
555
  "aria-hidden": !0,
556
556
  children: "📄"
557
- }), /* @__PURE__ */ R("span", {
557
+ }), /* @__PURE__ */ F("span", {
558
558
  style: {
559
559
  display: "flex",
560
560
  flexDirection: "column",
561
561
  minWidth: 0
562
562
  },
563
- children: [/* @__PURE__ */ a("span", {
563
+ children: [/* @__PURE__ */ l("span", {
564
564
  style: {
565
565
  overflow: "hidden",
566
566
  textOverflow: "ellipsis",
@@ -569,14 +569,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
569
569
  },
570
570
  title: e.name,
571
571
  children: e.name
572
- }), n && /* @__PURE__ */ a("span", {
572
+ }), o && /* @__PURE__ */ l("span", {
573
573
  style: {
574
574
  fontSize: "11px",
575
575
  color: "#6b6d6f"
576
576
  },
577
- children: n
577
+ children: o
578
578
  })]
579
- })] }), i = {
579
+ })] }), s = {
580
580
  display: "inline-flex",
581
581
  alignItems: "center",
582
582
  gap: "8px",
@@ -589,18 +589,18 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
589
589
  textDecoration: "none",
590
590
  maxWidth: "220px"
591
591
  };
592
- return r ? /* @__PURE__ */ a("a", {
592
+ return r ? /* @__PURE__ */ l("a", {
593
593
  href: r,
594
594
  target: "_blank",
595
595
  rel: "noopener noreferrer",
596
- style: i,
597
- children: o
598
- }) : /* @__PURE__ */ a("div", {
599
- style: i,
600
- children: o
596
+ style: s,
597
+ children: n
598
+ }) : /* @__PURE__ */ l("div", {
599
+ style: s,
600
+ children: n
601
601
  });
602
- }, ke = ({ source: e, index: t }) => {
603
- const r = /* @__PURE__ */ R("div", {
602
+ }, Re = ({ source: e, index: t }) => {
603
+ const r = /* @__PURE__ */ F("div", {
604
604
  style: {
605
605
  display: "flex",
606
606
  alignItems: "center",
@@ -608,7 +608,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
608
608
  width: "100%",
609
609
  minWidth: 0
610
610
  },
611
- children: [/* @__PURE__ */ a("div", {
611
+ children: [/* @__PURE__ */ l("div", {
612
612
  style: {
613
613
  flexShrink: 0,
614
614
  width: "18px",
@@ -624,7 +624,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
624
624
  backgroundColor: "#f0f4ff"
625
625
  },
626
626
  children: t + 1
627
- }), /* @__PURE__ */ a("div", {
627
+ }), /* @__PURE__ */ l("div", {
628
628
  style: {
629
629
  fontSize: "12px",
630
630
  overflow: "hidden",
@@ -635,7 +635,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
635
635
  title: e.title,
636
636
  children: e.title
637
637
  })]
638
- }), n = {
638
+ }), o = {
639
639
  display: "flex",
640
640
  alignItems: "center",
641
641
  padding: "8px 10px",
@@ -648,23 +648,23 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
648
648
  minWidth: 0,
649
649
  transition: "border-color 0.15s"
650
650
  };
651
- return e.url ? /* @__PURE__ */ a("a", {
651
+ return e.url ? /* @__PURE__ */ l("a", {
652
652
  href: e.url,
653
653
  target: "_blank",
654
654
  rel: "noopener noreferrer",
655
- style: n,
656
- onMouseEnter: (o) => {
657
- o.currentTarget.style.borderColor = "#1b5fc4";
655
+ style: o,
656
+ onMouseEnter: (n) => {
657
+ n.currentTarget.style.borderColor = "#1b5fc4";
658
658
  },
659
- onMouseLeave: (o) => {
660
- o.currentTarget.style.borderColor = "#dee3e8";
659
+ onMouseLeave: (n) => {
660
+ n.currentTarget.style.borderColor = "#dee3e8";
661
661
  },
662
662
  children: r
663
- }) : /* @__PURE__ */ a("div", {
664
- style: n,
663
+ }) : /* @__PURE__ */ l("div", {
664
+ style: o,
665
665
  children: r
666
666
  });
667
- }, Ie = () => /* @__PURE__ */ R("div", {
667
+ }, Me = () => /* @__PURE__ */ F("div", {
668
668
  style: {
669
669
  display: "flex",
670
670
  gap: "4px",
@@ -674,31 +674,31 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
674
674
  0,
675
675
  1,
676
676
  2
677
- ].map((e) => /* @__PURE__ */ a("div", { style: {
677
+ ].map((e) => /* @__PURE__ */ l("div", { style: {
678
678
  width: "6px",
679
679
  height: "6px",
680
680
  borderRadius: "50%",
681
681
  backgroundColor: "#b5bfc8",
682
682
  animation: "ago-pulse 1.2s ease-in-out infinite",
683
683
  animationDelay: `${e * 0.2}s`
684
- } }, e)), /* @__PURE__ */ a("style", { children: `
684
+ } }, e)), /* @__PURE__ */ l("style", { children: `
685
685
  @keyframes ago-pulse {
686
686
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
687
687
  40% { opacity: 1; transform: scale(1); }
688
688
  }
689
689
  ` })]
690
- }), Me = ({ message: e, className: t = "", showAgentName: r = !1, isLast: n = !1, onFollowUpClick: o }) => {
691
- const i = e.role === "user", c = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
692
- return /* @__PURE__ */ R("div", {
690
+ }), Ee = ({ message: e, className: t = "", showAgentName: r = !1, isLast: o = !1, onFollowUpClick: n }) => {
691
+ const s = e.role === "user", f = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
692
+ return /* @__PURE__ */ F("div", {
693
693
  className: `ago-message ago-message--${e.role} ${t}`,
694
694
  style: {
695
695
  display: "flex",
696
696
  flexDirection: "column",
697
- alignItems: i ? "flex-end" : "flex-start",
697
+ alignItems: s ? "flex-end" : "flex-start",
698
698
  marginBottom: "16px"
699
699
  },
700
700
  children: [
701
- !i && r && e.agent && /* @__PURE__ */ a("div", {
701
+ !s && r && e.agent && /* @__PURE__ */ l("div", {
702
702
  className: "ago-message__agent",
703
703
  style: {
704
704
  display: "flex",
@@ -712,7 +712,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
712
712
  },
713
713
  children: e.agent.displayName || e.agent.name
714
714
  }),
715
- !i && e.sources && e.sources.length > 0 && /* @__PURE__ */ a("div", {
715
+ !s && e.sources && e.sources.length > 0 && /* @__PURE__ */ l("div", {
716
716
  className: "ago-message__sources",
717
717
  style: {
718
718
  display: "grid",
@@ -722,41 +722,41 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
722
722
  width: "100%",
723
723
  maxWidth: "85%"
724
724
  },
725
- children: e.sources.map((l, f) => /* @__PURE__ */ a(ke, {
726
- source: l,
727
- index: f
728
- }, l.id))
725
+ children: e.sources.map((i, m) => /* @__PURE__ */ l(Re, {
726
+ source: i,
727
+ index: m
728
+ }, i.id))
729
729
  }),
730
- e.attachments && e.attachments.length > 0 && /* @__PURE__ */ a("div", {
730
+ e.attachments && e.attachments.length > 0 && /* @__PURE__ */ l("div", {
731
731
  className: "ago-message__attachments",
732
732
  style: {
733
733
  display: "flex",
734
734
  flexWrap: "wrap",
735
735
  gap: "6px",
736
736
  marginBottom: "6px",
737
- justifyContent: i ? "flex-end" : "flex-start",
737
+ justifyContent: s ? "flex-end" : "flex-start",
738
738
  maxWidth: "75%"
739
739
  },
740
- children: e.attachments.map((l) => /* @__PURE__ */ a(Se, {
741
- attachment: l,
742
- isUser: i
743
- }, l.id))
740
+ children: e.attachments.map((i) => /* @__PURE__ */ l(Ne, {
741
+ attachment: i,
742
+ isUser: s
743
+ }, i.id))
744
744
  }),
745
- (e.content || c) && /* @__PURE__ */ a("div", {
745
+ (e.content || f) && /* @__PURE__ */ l("div", {
746
746
  className: "ago-message__content",
747
747
  style: {
748
- maxWidth: i ? "75%" : "100%",
749
- padding: i ? "10px 14px" : "2px 8px",
750
- borderRadius: i ? "16px" : "0",
751
- backgroundColor: i ? "#03182f" : "transparent",
752
- color: i ? "#fff" : "#30373e",
748
+ maxWidth: s ? "75%" : "100%",
749
+ padding: s ? "10px 14px" : "2px 8px",
750
+ borderRadius: s ? "16px" : "0",
751
+ backgroundColor: s ? "#03182f" : "transparent",
752
+ color: s ? "#fff" : "#30373e",
753
753
  wordBreak: "break-word",
754
754
  fontSize: "16px",
755
755
  lineHeight: "1.6"
756
756
  },
757
- children: e.content ? /* @__PURE__ */ a(Ce, { content: e.content }) : c && /* @__PURE__ */ a(Ie, {})
757
+ children: e.content ? /* @__PURE__ */ l(Ae, { content: e.content }) : f && /* @__PURE__ */ l(Me, {})
758
758
  }),
759
- n && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
759
+ o && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ l("div", {
760
760
  className: "ago-message__followups",
761
761
  style: {
762
762
  display: "flex",
@@ -764,11 +764,11 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
764
764
  gap: "8px",
765
765
  marginTop: "10px"
766
766
  },
767
- children: e.followUpReplies.map((l, f) => /* @__PURE__ */ a("button", {
767
+ children: e.followUpReplies.map((i, m) => /* @__PURE__ */ l("button", {
768
768
  type: "button",
769
769
  className: "ago-message__followup-btn",
770
- disabled: !o,
771
- onClick: o ? () => o(l) : void 0,
770
+ disabled: !n,
771
+ onClick: n ? () => n(i) : void 0,
772
772
  style: {
773
773
  minHeight: "36px",
774
774
  padding: "6px 14px",
@@ -777,7 +777,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
777
777
  border: "1px solid #dee3e8",
778
778
  backgroundColor: "#fff",
779
779
  color: "#30373e",
780
- cursor: o ? "pointer" : "default",
780
+ cursor: n ? "pointer" : "default",
781
781
  transition: "border-color 0.15s"
782
782
  },
783
783
  onMouseEnter: (u) => {
@@ -786,50 +786,50 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
786
786
  onMouseLeave: (u) => {
787
787
  u.currentTarget.style.borderColor = "#dee3e8";
788
788
  },
789
- children: l
790
- }, f))
789
+ children: i
790
+ }, m))
791
791
  })
792
792
  ]
793
793
  });
794
- }, Oe = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: o = "Type a message...", allowFiles: i = !1, height: c = 500, logoUrl: l, showAgentName: f = !1, forms: u, onFollowUpClick: y, className: v = "", onMessageSent: I, onMessageReceived: x }) => {
795
- const h = E(null), C = z(), S = e ?? C, { messages: s, isLoading: b, error: d, sendMessage: p } = G({
794
+ }, Ue = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: o = "Hello! How can I help you today?", placeholder: n = "Type a message...", allowFiles: s = !1, height: f = 500, logoUrl: i, showAgentName: m = !1, forms: u, onFollowUpClick: g, className: C = "", onMessageSent: A, onMessageReceived: S }) => {
795
+ const k = T(null), d = L(), x = e ?? d, { messages: a, isLoading: v, error: c, sendMessage: h } = K({
796
796
  client: e,
797
797
  conversationId: t
798
798
  });
799
- k(() => {
800
- if (!S || !u || u.length === 0) return;
801
- let w = !1;
802
- const F = [];
803
- return Promise.all(u.map((N) => N.schema != null ? Promise.resolve(O(N)) : H(S, N))).then((N) => {
804
- if (!w)
805
- for (const U of N) F.push(U.install(S));
799
+ N(() => {
800
+ if (!x || !u || u.length === 0) return;
801
+ let p = !1;
802
+ const I = [];
803
+ return Promise.all(u.map((M) => M.schema != null ? Promise.resolve(j(M)) : O(x, M))).then((M) => {
804
+ if (!p)
805
+ for (const J of M) I.push(J.install(x));
806
806
  }).catch(() => {
807
807
  }), () => {
808
- w = !0, F.forEach((N) => N());
808
+ p = !0, I.forEach((M) => M());
809
809
  };
810
- }, [S, u ? JSON.stringify(u.map((w) => [
811
- w.name,
812
- w.schema ?? null,
813
- w.submit ?? !1,
814
- w.description ?? null
815
- ])) : ""]), k(() => {
816
- h.current?.scrollIntoView({ behavior: "smooth" });
817
- }, [s]), k(() => {
818
- const w = s[s.length - 1];
819
- w && w.role === "assistant" && w.status === "DONE" && x && x({
820
- id: w.id,
821
- content: w.content
810
+ }, [x, u ? JSON.stringify(u.map((p) => [
811
+ p.name,
812
+ p.schema ?? null,
813
+ p.submit ?? !1,
814
+ p.description ?? null
815
+ ])) : ""]), N(() => {
816
+ k.current?.scrollIntoView({ behavior: "smooth" });
817
+ }, [a]), N(() => {
818
+ const p = a[a.length - 1];
819
+ p && p.role === "assistant" && p.status === "DONE" && S && S({
820
+ id: p.id,
821
+ content: p.content
822
822
  });
823
- }, [s, x]);
824
- const m = async (w, F) => {
825
- I?.(w), await p(w, F);
826
- }, g = s[s.length - 1], W = b && g?.role === "assistant" && (g.status === "IN_PROGRESS" || g.status === "WAITING_CLIENT"), K = y === !1 ? void 0 : y ?? ((w) => m(w));
827
- return /* @__PURE__ */ R("div", {
828
- className: `ago-chat-widget ${v}`,
823
+ }, [a, S]);
824
+ const w = async (p, I) => {
825
+ A?.(p), await h(p, I);
826
+ }, b = a[a.length - 1], _ = v && b?.role === "assistant" && (b.status === "IN_PROGRESS" || b.status === "WAITING_CLIENT"), y = g === !1 ? void 0 : g ?? ((p) => w(p));
827
+ return /* @__PURE__ */ F("div", {
828
+ className: `ago-chat-widget ${C}`,
829
829
  style: {
830
830
  display: "flex",
831
831
  flexDirection: "column",
832
- height: typeof c == "number" ? `${c}px` : c,
832
+ height: typeof f == "number" ? `${f}px` : f,
833
833
  border: "1px solid #dee3e8",
834
834
  borderRadius: "16px",
835
835
  overflow: "hidden",
@@ -839,7 +839,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
839
839
  boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
840
840
  },
841
841
  children: [
842
- /* @__PURE__ */ R("div", {
842
+ /* @__PURE__ */ F("div", {
843
843
  className: "ago-chat-widget__header",
844
844
  style: {
845
845
  padding: "14px 16px",
@@ -850,14 +850,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
850
850
  alignItems: "center",
851
851
  gap: "10px"
852
852
  },
853
- children: [l && /* @__PURE__ */ a("img", {
854
- src: l,
853
+ children: [i && /* @__PURE__ */ l("img", {
854
+ src: i,
855
855
  alt: "Logo",
856
856
  style: {
857
857
  height: "24px",
858
858
  width: "auto"
859
859
  }
860
- }), /* @__PURE__ */ a("h3", {
860
+ }), /* @__PURE__ */ l("h3", {
861
861
  style: {
862
862
  margin: 0,
863
863
  fontSize: "15px",
@@ -866,7 +866,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
866
866
  children: r
867
867
  })]
868
868
  }),
869
- /* @__PURE__ */ R("div", {
869
+ /* @__PURE__ */ F("div", {
870
870
  className: "ago-chat-widget__messages",
871
871
  role: "log",
872
872
  "aria-live": "polite",
@@ -879,7 +879,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
879
879
  backgroundColor: "#fbfbfb"
880
880
  },
881
881
  children: [
882
- s.length === 0 ? /* @__PURE__ */ a("div", {
882
+ a.length === 0 ? /* @__PURE__ */ l("div", {
883
883
  style: {
884
884
  textAlign: "center",
885
885
  color: "#6b6d6f",
@@ -887,14 +887,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
887
887
  fontSize: "16px",
888
888
  lineHeight: "1.5"
889
889
  },
890
- children: n
891
- }) : s.map((w, F) => /* @__PURE__ */ a(Me, {
892
- message: w,
893
- showAgentName: f,
894
- isLast: F === s.length - 1,
895
- onFollowUpClick: K
896
- }, w.id)),
897
- d && /* @__PURE__ */ a("div", {
890
+ children: o
891
+ }) : a.map((p, I) => /* @__PURE__ */ l(Ee, {
892
+ message: p,
893
+ showAgentName: m,
894
+ isLast: I === a.length - 1,
895
+ onFollowUpClick: y
896
+ }, p.id)),
897
+ c && /* @__PURE__ */ l("div", {
898
898
  role: "alert",
899
899
  style: {
900
900
  padding: "10px 14px",
@@ -905,222 +905,416 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
905
905
  fontSize: "13px",
906
906
  border: "1px solid #fecaca"
907
907
  },
908
- children: d.message
908
+ children: c.message
909
909
  }),
910
- /* @__PURE__ */ a("div", { ref: h })
910
+ /* @__PURE__ */ l("div", { ref: k })
911
911
  ]
912
912
  }),
913
- /* @__PURE__ */ a(se, {
914
- onSend: m,
915
- disabled: W,
916
- placeholder: o,
917
- allowFiles: i
913
+ /* @__PURE__ */ l(de, {
914
+ onSend: w,
915
+ disabled: _,
916
+ placeholder: n,
917
+ allowFiles: s
918
918
  })
919
919
  ]
920
920
  });
921
921
  };
922
- function Re({ client: e, autoLoad: t = !0 } = {}) {
923
- const r = z(), n = e || r;
924
- if (!n) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
925
- const [o, i] = M([]), [c, l] = M(null), [f, u] = M(!1), [y, v] = M(null), I = A(async () => {
926
- u(!0), v(null);
922
+ function Fe({ client: e, autoLoad: t = !0 } = {}) {
923
+ const r = L(), o = e || r;
924
+ if (!o) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
925
+ const [n, s] = E([]), [f, i] = E(null), [m, u] = E(!1), [g, C] = E(null), A = R(async () => {
926
+ u(!0), C(null);
927
927
  try {
928
- i(await n.getConversations());
929
- } catch (C) {
930
- v(C instanceof Error ? C : /* @__PURE__ */ new Error("Failed to load conversations"));
928
+ s(await o.getConversations());
929
+ } catch (d) {
930
+ C(d instanceof Error ? d : /* @__PURE__ */ new Error("Failed to load conversations"));
931
931
  } finally {
932
932
  u(!1);
933
933
  }
934
- }, [n]), x = A(async (C) => {
935
- u(!0), v(null);
934
+ }, [o]), S = R(async (d) => {
935
+ u(!0), C(null);
936
936
  try {
937
- l(await n.getConversation(C));
938
- } catch (S) {
939
- v(S instanceof Error ? S : /* @__PURE__ */ new Error("Failed to load conversation"));
937
+ i(await o.getConversation(d));
938
+ } catch (x) {
939
+ C(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to load conversation"));
940
940
  } finally {
941
941
  u(!1);
942
942
  }
943
- }, [n]), h = A(() => {
944
- l(null);
943
+ }, [o]), k = R(() => {
944
+ i(null);
945
945
  }, []);
946
- return k(() => {
947
- t && I();
948
- }, [t, I]), {
949
- conversations: o,
950
- currentConversation: c,
951
- isLoading: f,
952
- error: y,
953
- selectConversation: x,
954
- startNewConversation: h,
955
- refreshConversations: I
946
+ return N(() => {
947
+ t && A();
948
+ }, [t, A]), {
949
+ conversations: n,
950
+ currentConversation: f,
951
+ isLoading: m,
952
+ error: g,
953
+ selectConversation: S,
954
+ startNewConversation: k,
955
+ refreshConversations: A
956
956
  };
957
957
  }
958
- function $e(e = {}) {
959
- const t = z(), r = e.client || t;
958
+ function Je(e = {}) {
959
+ const t = L(), r = e.client || t;
960
960
  if (!r) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
961
- const n = G({
961
+ const o = K({
962
962
  client: r,
963
963
  conversationId: e.conversationId
964
- }), o = Re({
964
+ }), n = Fe({
965
965
  client: r,
966
966
  autoLoad: e.autoLoad
967
967
  });
968
968
  return {
969
- messages: n.messages,
970
- isLoading: n.isLoading,
971
- error: n.error || o.error,
972
- sendMessage: n.sendMessage,
973
- clearMessages: n.clearMessages,
974
- conversationId: n.conversationId,
975
- conversations: o.conversations,
976
- currentConversation: o.currentConversation,
977
- isConversationsLoading: o.isLoading,
978
- selectConversation: o.selectConversation,
979
- startNewConversation: o.startNewConversation,
980
- refreshConversations: o.refreshConversations
969
+ messages: o.messages,
970
+ isLoading: o.isLoading,
971
+ error: o.error || n.error,
972
+ sendMessage: o.sendMessage,
973
+ clearMessages: o.clearMessages,
974
+ conversationId: o.conversationId,
975
+ conversations: n.conversations,
976
+ currentConversation: n.currentConversation,
977
+ isConversationsLoading: n.isLoading,
978
+ selectConversation: n.selectConversation,
979
+ startNewConversation: n.startNewConversation,
980
+ refreshConversations: n.refreshConversations
981
981
  };
982
982
  }
983
- function Be(e, t) {
984
- const r = P(), { name: n, description: o, parameters: i, handler: c, maxResultBytes: l } = typeof e == "string" ? {
983
+ function Ve(e, t) {
984
+ const r = W(), { name: o, description: n, parameters: s, handler: f, maxResultBytes: i, requiresApproval: m } = typeof e == "string" ? {
985
985
  name: e,
986
986
  ...t
987
- } : e, f = E(c);
988
- f.current = c, k(() => {
989
- const u = (y) => f.current(y);
990
- return r.registerFunction(n, u, {
991
- description: o,
992
- parameters: i,
993
- maxResultBytes: l
987
+ } : e, u = T(f);
988
+ u.current = f, N(() => {
989
+ const g = (C) => u.current(C);
990
+ return r.registerFunction(o, g, {
991
+ description: n,
992
+ parameters: s,
993
+ maxResultBytes: i,
994
+ requiresApproval: m
994
995
  }), () => {
995
- r.unregisterFunction(n);
996
+ r.unregisterFunction(o);
996
997
  };
997
998
  }, [
998
999
  r,
999
- n,
1000
1000
  o,
1001
+ n,
1002
+ s,
1001
1003
  i,
1002
- l
1004
+ m
1003
1005
  ]);
1004
1006
  }
1005
- function Ge(e, t) {
1006
- const r = P(), n = E(e);
1007
- n.current = e, k(() => (r.registerNavigationFunction((o) => n.current(o), t), () => {
1007
+ function Ye(e, t) {
1008
+ const r = W(), o = T(e);
1009
+ o.current = e, N(() => (r.registerNavigationFunction((n) => o.current(n), t), () => {
1008
1010
  r.unregisterNavigationFunction();
1009
1011
  }), [r, t]);
1010
1012
  }
1011
- function Ke(e, t) {
1012
- const r = P(), n = t?.functionName ?? "setPageState", o = E(e);
1013
- o.current = e, k(() => {
1014
- const i = o.current.map((c) => {
1015
- const l = () => o.current.find((f) => f.name === c.name) ?? c;
1013
+ function Xe(e, t) {
1014
+ const r = W(), o = t?.functionName ?? "setPageState", n = t?.requiresApproval, s = T(e);
1015
+ s.current = e, N(() => {
1016
+ const f = s.current.map((i) => {
1017
+ const m = () => s.current.find((u) => u.name === i.name) ?? i;
1016
1018
  return {
1017
- name: c.name,
1018
- description: c.description,
1019
- schema: c.schema,
1020
- get: c.get ? () => l().get?.() : void 0,
1021
- set: (f) => l().set(f)
1019
+ name: i.name,
1020
+ description: i.description,
1021
+ schema: i.schema,
1022
+ get: i.get ? () => m().get?.() : void 0,
1023
+ set: (u) => m().set(u)
1022
1024
  };
1023
1025
  });
1024
- return r.registerPageStateFunction(i, { functionName: n }), () => {
1025
- r.unregisterPageStateFunction(n);
1026
+ return r.registerPageStateFunction(f, {
1027
+ functionName: o,
1028
+ requiresApproval: n
1029
+ }), () => {
1030
+ r.unregisterPageStateFunction(o);
1026
1031
  };
1027
- }, [r, n]);
1032
+ }, [
1033
+ r,
1034
+ o,
1035
+ n
1036
+ ]);
1037
+ }
1038
+ function Ze(e) {
1039
+ const t = W(), r = T(e);
1040
+ r.current = e, N(() => te(t, () => r.current), [t]);
1041
+ }
1042
+ var Te = /* @__PURE__ */ new Set(["awaiting-approval"]);
1043
+ function U(e) {
1044
+ switch (e) {
1045
+ case "progress_indicator":
1046
+ return "progress";
1047
+ case "reasoning":
1048
+ return "reasoning";
1049
+ case "confirmation_input":
1050
+ return "confirmation";
1051
+ case "form":
1052
+ return "form";
1053
+ default:
1054
+ return "status";
1055
+ }
1028
1056
  }
1029
- function Ue(e) {
1030
- const t = P(), r = E(e);
1031
- r.current = e, k(() => X(t, () => r.current), [t]);
1057
+ function _e(e) {
1058
+ return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : U(e.type);
1059
+ }
1060
+ function H(e, t) {
1061
+ const r = (e ?? "").toLowerCase();
1062
+ return r.includes("reject") ? "rejected" : r.includes("error") || r.includes("fail") ? "error" : r.includes("done") || r.includes("complet") ? "done" : (r.includes("waiting") || r.includes("pending")) && (t === "confirmation" || t === "form") ? "awaiting-approval" : "running";
1063
+ }
1064
+ function $(e) {
1065
+ return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (t) => t.toUpperCase()).trim();
1066
+ }
1067
+ function Pe(e) {
1068
+ switch (e.kind) {
1069
+ case "navigation":
1070
+ return `Navigating to ${$(e.arguments?.page)}`;
1071
+ case "action":
1072
+ return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || $(e.functionName) || "Working";
1073
+ case "progress":
1074
+ return e.message || "Working";
1075
+ case "reasoning":
1076
+ return e.message || "Thinking";
1077
+ case "confirmation":
1078
+ return e.message || "Waiting for your confirmation";
1079
+ case "form":
1080
+ return e.message || e.toolDisplayName || "Please fill in the form";
1081
+ default:
1082
+ return e.message || e.toolDisplayName || e.toolName || "Working";
1083
+ }
1084
+ }
1085
+ function Qe(e = {}) {
1086
+ const { includeReasoning: t = !1, labelFor: r } = e, o = L(), n = e.client || o;
1087
+ if (!n) throw new X("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
1088
+ const [s, f] = E([]), i = T(/* @__PURE__ */ new Set()), m = T(void 0), u = T(r);
1089
+ u.current = r;
1090
+ const g = R((d, x) => {
1091
+ f((a) => {
1092
+ const v = a.findIndex((h) => h.id === d), c = {
1093
+ ...v >= 0 ? a[v] : {
1094
+ id: d,
1095
+ kind: "status",
1096
+ label: "",
1097
+ status: "running",
1098
+ requiresApproval: !1,
1099
+ createdAt: /* @__PURE__ */ new Date()
1100
+ },
1101
+ ...x
1102
+ };
1103
+ return c.label = u.current?.(c) ?? Pe(c), v >= 0 ? [
1104
+ ...a.slice(0, v),
1105
+ c,
1106
+ ...a.slice(v + 1)
1107
+ ] : [...a, c];
1108
+ });
1109
+ }, []);
1110
+ N(() => {
1111
+ const d = (y) => {
1112
+ m.current = y.messageId;
1113
+ }, x = (y) => {
1114
+ const p = U(y.type);
1115
+ p === "reasoning" && !t || g(y.id, {
1116
+ kind: p,
1117
+ status: H(y.status, p),
1118
+ messageId: m.current,
1119
+ toolName: y.toolName,
1120
+ toolDisplayName: y.toolDisplayName,
1121
+ message: y.message,
1122
+ data: y.data,
1123
+ formSchema: y.formSchema,
1124
+ requiresApproval: p === "confirmation" || p === "form"
1125
+ });
1126
+ }, a = (y) => {
1127
+ y.invocationId && g(y.invocationId, {
1128
+ kind: y.functionName === "navigateToPage" ? "navigation" : "action",
1129
+ status: "running",
1130
+ messageId: m.current,
1131
+ functionName: y.functionName,
1132
+ arguments: y.arguments
1133
+ });
1134
+ }, v = (y) => {
1135
+ y.invocationId && g(y.invocationId, {
1136
+ kind: y.functionName === "navigateToPage" ? "navigation" : "action",
1137
+ status: "awaiting-approval",
1138
+ messageId: m.current,
1139
+ functionName: y.functionName,
1140
+ arguments: y.arguments,
1141
+ requiresApproval: !0
1142
+ });
1143
+ }, c = (y) => {
1144
+ if (!y.invocationId) return;
1145
+ const p = y.result, I = typeof y.result == "object" && p !== null && p.approved === !1 && p.reason === "user_rejected";
1146
+ g(y.invocationId, {
1147
+ status: y.error ? "error" : I ? "rejected" : "done",
1148
+ requiresApproval: !1
1149
+ });
1150
+ }, h = (y) => {
1151
+ for (const p of y.messages ?? [])
1152
+ if (p.role === "assistant")
1153
+ for (const I of p.toolCalls ?? []) {
1154
+ const M = _e(I);
1155
+ M === "reasoning" && !t || /waiting/i.test(I.status ?? "") || g(I.id, {
1156
+ kind: M,
1157
+ status: H(I.status, M),
1158
+ messageId: p.id,
1159
+ toolName: I.toolName,
1160
+ toolDisplayName: I.toolDisplayName,
1161
+ functionName: I.functionName,
1162
+ arguments: I.arguments,
1163
+ message: I.message,
1164
+ data: I.data,
1165
+ formSchema: I.formSchema,
1166
+ requiresApproval: M === "confirmation" || M === "form"
1167
+ });
1168
+ }
1169
+ }, w = (y) => {
1170
+ f((p) => p.map((I) => I.status === "running" || I.status === "awaiting-approval" ? {
1171
+ ...I,
1172
+ status: y
1173
+ } : I));
1174
+ }, b = () => w("done"), _ = () => w("error");
1175
+ return n.on("message:start", d), n.on("toolCall:received", x), n.on("function:invoke", a), n.on("function:awaiting-approval", v), n.on("function:result", c), n.on("conversation:loaded", h), n.on("message:complete", b), n.on("message:error", _), () => {
1176
+ n.off("message:start", d), n.off("toolCall:received", x), n.off("function:invoke", a), n.off("function:awaiting-approval", v), n.off("function:result", c), n.off("conversation:loaded", h), n.off("message:complete", b), n.off("message:error", _);
1177
+ };
1178
+ }, [
1179
+ n,
1180
+ t,
1181
+ g
1182
+ ]);
1183
+ const C = R(async (d) => {
1184
+ const x = s.find((a) => a.id === d);
1185
+ !x || x.status !== "awaiting-approval" || i.current.has(d) || x.kind !== "form" && (i.current.add(d), g(d, {
1186
+ status: "running",
1187
+ requiresApproval: !1
1188
+ }), x.functionName ? await n.approveFunction(d) : await n.confirmToolCall(d));
1189
+ }, [
1190
+ n,
1191
+ s,
1192
+ g
1193
+ ]), A = R(async (d) => {
1194
+ const x = s.find((a) => a.id === d);
1195
+ !x || x.status !== "awaiting-approval" || i.current.has(d) || (i.current.add(d), g(d, {
1196
+ status: "rejected",
1197
+ requiresApproval: !1
1198
+ }), x.functionName ? await n.rejectFunction(d) : await n.rejectToolCall(d));
1199
+ }, [
1200
+ n,
1201
+ s,
1202
+ g
1203
+ ]), S = R(async (d, x) => {
1204
+ g(d, {
1205
+ status: "running",
1206
+ requiresApproval: !1
1207
+ }), await n.submitToolCallForm(d, x), g(d, { status: "done" });
1208
+ }, [n, g]), k = R(() => {
1209
+ i.current.clear(), f([]);
1210
+ }, []);
1211
+ return {
1212
+ items: s,
1213
+ latest: s.length > 0 ? s[s.length - 1] : void 0,
1214
+ isAwaitingApproval: s.some((d) => Te.has(d.status)),
1215
+ approve: C,
1216
+ reject: A,
1217
+ submitForm: S,
1218
+ clear: k
1219
+ };
1032
1220
  }
1033
- function qe(e, t) {
1034
- const r = P(), n = te(), o = t ?? n, i = E(e);
1035
- i.current = e;
1036
- const c = typeof e == "function";
1037
- k(() => {
1038
- if (typeof i.current == "function") {
1039
- const l = () => i.current();
1040
- return r.addDynamicContext(o, l), () => {
1041
- r.removeDynamicContext(o);
1221
+ function et(e, t) {
1222
+ const r = W(), o = ae(), n = t ?? o, s = T(e);
1223
+ s.current = e;
1224
+ const f = typeof e == "function";
1225
+ N(() => {
1226
+ if (typeof s.current == "function") {
1227
+ const i = () => s.current();
1228
+ return r.addDynamicContext(n, i), () => {
1229
+ r.removeDynamicContext(n);
1042
1230
  };
1043
1231
  }
1044
- return r.setContext(o, i.current), () => {
1045
- r.removeContext(o);
1232
+ return r.setContext(n, s.current), () => {
1233
+ r.removeContext(n);
1046
1234
  };
1047
1235
  }, [
1048
1236
  r,
1049
- o,
1050
- c,
1051
- c ? "" : JSON.stringify(e)
1237
+ n,
1238
+ f,
1239
+ f ? "" : JSON.stringify(e)
1052
1240
  ]);
1053
1241
  }
1054
- function Ae(e) {
1055
- return ne(e.subscribe, e.get, e.get);
1242
+ function De(e) {
1243
+ return se(e.subscribe, e.get, e.get);
1056
1244
  }
1057
- var D = {
1245
+ var q = {
1058
1246
  missing: [],
1059
1247
  complete: !1
1060
1248
  };
1061
- function Je(e) {
1062
- const t = P(), r = e.schema != null, n = JSON.stringify(e.schema ?? null), o = e.submit, i = 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 = T(() => r ? O(e) : null, [
1249
+ function tt(e) {
1250
+ const t = W(), r = e.schema != null, o = JSON.stringify(e.schema ?? null), n = e.submit, s = n ? typeof n == "string" ? `client:${n}` : n.via === "backend" ? "backend" : "handler" in n ? "client:handler" : `client:${n.url}` : "none", f = JSON.stringify(e.initialValues ?? null), i = D(() => r ? j(e) : null, [
1063
1251
  r,
1064
1252
  e.name,
1065
- n,
1066
- i,
1067
- c,
1253
+ o,
1254
+ s,
1255
+ f,
1068
1256
  e.autoSubmit
1069
- ]), [f, u] = M({
1257
+ ]), [m, u] = E({
1070
1258
  collector: null,
1071
1259
  loading: !r,
1072
1260
  error: null
1073
1261
  });
1074
- k(() => {
1262
+ N(() => {
1075
1263
  if (r) return;
1076
- let b = !1;
1264
+ let v = !1;
1077
1265
  return u({
1078
1266
  collector: null,
1079
1267
  loading: !0,
1080
1268
  error: null
1081
- }), H(t, e).then((d) => {
1082
- b || u({
1083
- collector: d,
1269
+ }), O(t, e).then((c) => {
1270
+ v || u({
1271
+ collector: c,
1084
1272
  loading: !1,
1085
1273
  error: null
1086
1274
  });
1087
- }).catch((d) => {
1088
- b || u({
1275
+ }).catch((c) => {
1276
+ v || u({
1089
1277
  collector: null,
1090
1278
  loading: !1,
1091
- error: d instanceof Error ? d : new Error(String(d))
1279
+ error: c instanceof Error ? c : new Error(String(c))
1092
1280
  });
1093
1281
  }), () => {
1094
- b = !0;
1282
+ v = !0;
1095
1283
  };
1096
1284
  }, [
1097
1285
  t,
1098
1286
  r,
1099
1287
  e.name,
1100
- i,
1101
- c,
1288
+ s,
1289
+ f,
1102
1290
  e.autoSubmit
1103
1291
  ]);
1104
- const y = r ? l : f.collector, v = r ? !1 : f.loading, I = r ? null : f.error;
1105
- k(() => {
1106
- if (y)
1107
- return y.install(t);
1108
- }, [t, y]);
1109
- const x = T(() => Q({
1292
+ const g = r ? i : m.collector, C = r ? !1 : m.loading, A = r ? null : m.error;
1293
+ N(() => {
1294
+ if (g)
1295
+ return g.install(t);
1296
+ }, [t, g]);
1297
+ const S = D(() => ne({
1110
1298
  values: e.initialValues ?? {},
1111
1299
  submitted: !1
1112
- }), [c]), h = Ae(y?.store ?? x), C = T(() => y?.getStatus() ?? D, [h, y]), S = T(() => ({
1113
- ...h,
1114
- ...C
1115
- }), [h, C]), s = T(() => ({
1300
+ }), [f]), k = De(g?.store ?? S), d = D(() => g?.getStatus() ?? q, [k, g]), x = D(() => ({
1301
+ ...k,
1302
+ ...d
1303
+ }), [k, d]), a = D(() => ({
1116
1304
  name: e.name,
1117
- store: x,
1305
+ store: S,
1118
1306
  functions: [],
1119
1307
  contextKey: `form:${e.name}`,
1120
1308
  contextProvider: () => ({
1121
1309
  name: `Form: ${e.name}`,
1122
1310
  description: ""
1123
1311
  }),
1312
+ definitionContextKey: `form:${e.name}:definition`,
1313
+ definitionContextProvider: () => ({
1314
+ name: `Form definition: ${e.name}`,
1315
+ description: "",
1316
+ stable: !0
1317
+ }),
1124
1318
  install: () => () => {
1125
1319
  },
1126
1320
  hydrate: () => {
@@ -1129,41 +1323,42 @@ function Je(e) {
1129
1323
  ok: !1,
1130
1324
  error: "Form definition not loaded yet."
1131
1325
  }),
1132
- getValues: () => x.get().values,
1326
+ getValues: () => S.get().values,
1133
1327
  setValues: () => {
1134
1328
  },
1135
1329
  reset: () => {
1136
1330
  },
1137
- getStatus: () => D
1138
- }), [e.name, x]);
1331
+ getStatus: () => q
1332
+ }), [e.name, S]);
1139
1333
  return {
1140
- ...y ?? s,
1141
- state: S,
1142
- loading: v,
1143
- error: I
1334
+ ...g ?? a,
1335
+ state: x,
1336
+ loading: C,
1337
+ error: A
1144
1338
  };
1145
1339
  }
1146
1340
  export {
1147
- He as AgoProvider,
1148
- se as ChatInput,
1149
- Oe as ChatWidget,
1150
- Ce as Markdown,
1151
- Me as Message,
1152
- O as createFormCollector,
1153
- Pe as createMockClient,
1154
- _e as deriveFormStatus,
1155
- H as loadFormCollector,
1156
- ae as useAgo,
1157
- Ue as useAgoAutoContinueAfterNavigation,
1158
- P as useAgoClient,
1159
- qe as useAgoContext,
1160
- Be as useAgoFunction,
1161
- Ge as useAgoNavigation,
1162
- Ke as useAgoPageState,
1163
- Ae as useAgoStore,
1164
- $e as useChat,
1165
- Re as useConversation,
1166
- Je as useFormCollector,
1167
- G as useMessages,
1168
- z as useOptionalAgoClient
1341
+ Ke as AgoProvider,
1342
+ de as ChatInput,
1343
+ Ue as ChatWidget,
1344
+ Ae as Markdown,
1345
+ Ee as Message,
1346
+ j as createFormCollector,
1347
+ qe as createMockClient,
1348
+ He as deriveFormStatus,
1349
+ O as loadFormCollector,
1350
+ ce as useAgo,
1351
+ Qe as useAgoActivity,
1352
+ Ze as useAgoAutoContinueAfterNavigation,
1353
+ W as useAgoClient,
1354
+ et as useAgoContext,
1355
+ Ve as useAgoFunction,
1356
+ Ye as useAgoNavigation,
1357
+ Xe as useAgoPageState,
1358
+ De as useAgoStore,
1359
+ Je as useChat,
1360
+ Fe as useConversation,
1361
+ tt as useFormCollector,
1362
+ K as useMessages,
1363
+ L as useOptionalAgoClient
1169
1364
  };