@inkeep/agents-ui 0.0.0-dev-20260508215802 → 0.0.0-dev-20260508234956

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 (21) hide show
  1. package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +2 -2
  2. package/dist/primitives/components/embedded-chat/use-inkeep-chat.d.ts +0 -13
  3. package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +183 -181
  4. package/dist/styled/components/message.cjs +1 -1
  5. package/dist/styled/components/message.js +210 -272
  6. package/dist/styled/inkeep.css.cjs +0 -78
  7. package/dist/styled/inkeep.css.js +0 -78
  8. package/package.json +1 -2
  9. package/dist/node_modules/.pnpm/@hookform_resolvers@5.2.2_react-hook-form@7.70.0_react@19.3.0-canary-87ae75b3-20260128_/node_modules/@hookform/resolvers/zod/dist/zod.cjs +0 -1
  10. package/dist/node_modules/.pnpm/@hookform_resolvers@5.2.2_react-hook-form@7.70.0_react@19.3.0-canary-87ae75b3-20260128_/node_modules/@hookform/resolvers/zod/dist/zod.js +0 -93
  11. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.cjs +0 -1
  12. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js +0 -49
  13. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.cjs +0 -1
  14. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js +0 -19
  15. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.cjs +0 -1
  16. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.js +0 -28
  17. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.cjs +0 -1
  18. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js +0 -23
  19. package/dist/styled/components/ask-user-form.cjs +0 -1
  20. package/dist/styled/components/ask-user-form.d.ts +0 -96
  21. package/dist/styled/components/ask-user-form.js +0 -672
@@ -1,34 +1,34 @@
1
1
  "use client";
2
- import { useChat as at } from "@ai-sdk/react";
3
- import { normalizeFileType as xe } from "./file-upload-input.js";
4
- import { DefaultChatTransport as it } from "ai";
5
- import { useRef as c, useEffect as x, useState as F, useMemo as Fe, useCallback as $, useImperativeHandle as lt } from "react";
6
- import { useModal as ct } from "../modal/modal-provider.js";
7
- import { useOptionalChatBubble as ut } from "../../providers/chat-bubble-provider.js";
8
- import { useOptionalSidebarChat as pt } from "../../providers/sidebar-chat-provider.js";
9
- import { useInkeepConfig as dt } from "../../providers/config-provider.js";
10
- import { useCaptcha as ft } from "./use-captcha.js";
11
- import { useMediaQuery as mt } from "../../hooks/use-media-query.js";
12
- import { useAnonymousSession as gt } from "../../hooks/use-anonymous-session.js";
13
- import { useAuthToken as ht } from "../../hooks/use-auth-token.js";
14
- import { useConversationLoader as vt } from "../../hooks/use-conversation-loader.js";
15
- import { useInitialConversation as yt } from "../../hooks/use-initial-conversation.js";
2
+ import { useChat as it } from "@ai-sdk/react";
3
+ import { normalizeFileType as Oe } from "./file-upload-input.js";
4
+ import { DefaultChatTransport as lt } from "ai";
5
+ import { useRef as c, useEffect as x, useState as F, useMemo as _e, useCallback as $, useImperativeHandle as ct } from "react";
6
+ import { useModal as ut } from "../modal/modal-provider.js";
7
+ import { useOptionalChatBubble as pt } from "../../providers/chat-bubble-provider.js";
8
+ import { useOptionalSidebarChat as dt } from "../../providers/sidebar-chat-provider.js";
9
+ import { useInkeepConfig as ft } from "../../providers/config-provider.js";
10
+ import { useCaptcha as mt } from "./use-captcha.js";
11
+ import { useMediaQuery as gt } from "../../hooks/use-media-query.js";
12
+ import { useAnonymousSession as ht } from "../../hooks/use-anonymous-session.js";
13
+ import { useAuthToken as vt } from "../../hooks/use-auth-token.js";
14
+ import { useConversationLoader as yt } from "../../hooks/use-conversation-loader.js";
15
+ import { useInitialConversation as Ct } from "../../hooks/use-initial-conversation.js";
16
16
  import { generateUid as U } from "../../utils/generate-uid.js";
17
- import { useBaseEvents as Ct } from "../../providers/base-events-provider.js";
18
- import { useChatForm as At } from "../../providers/chat-form-provider.js";
19
- import { useWidget as St } from "../../providers/widget-provider.js";
20
- import { useControllableState as bt } from "@radix-ui/react-use-controllable-state";
17
+ import { useBaseEvents as At } from "../../providers/base-events-provider.js";
18
+ import { useChatForm as St } from "../../providers/chat-form-provider.js";
19
+ import { useWidget as bt } from "../../providers/widget-provider.js";
20
+ import { useControllableState as Rt } from "@radix-ui/react-use-controllable-state";
21
21
  import { useStreamingEvents as It } from "../../hooks/use-streaming-events.js";
22
- import { useInputNotification as Rt } from "../../hooks/use-input-notification.js";
23
- import { resolveStreamingAuthError as Tt, DEFAULT_ERROR_MESSAGE as ie, isRecoverableError as wt, RECOVERABLE_NOTIFICATION_DURATION_MS as Et, resolveHttpStatusCode as kt, RATE_LIMIT_MESSAGE as Mt, RECOVERABLE_FALLBACK_MESSAGE as Oe } from "./chat-error-helpers.js";
24
- const Xt = () => {
25
- const { baseSettings: q, aiChatSettings: y } = dt(), [i = "", g] = bt({
22
+ import { useInputNotification as wt } from "../../hooks/use-input-notification.js";
23
+ import { resolveStreamingAuthError as Tt, DEFAULT_ERROR_MESSAGE as ce, isRecoverableError as kt, RECOVERABLE_NOTIFICATION_DURATION_MS as Et, resolveHttpStatusCode as Mt, RATE_LIMIT_MESSAGE as xt, RECOVERABLE_FALLBACK_MESSAGE as Ne } from "./chat-error-helpers.js";
24
+ const Yt = () => {
25
+ const { baseSettings: q, aiChatSettings: y } = ft(), [i = "", g] = Rt({
26
26
  prop: y.conversationIdOverride,
27
27
  defaultProp: y.conversationIdOverride ?? ""
28
- }), _e = ct(), Ne = ut(), Pe = pt(), { logEvent: m } = Ct(), { setConversationId: Le, emitToParent: O } = It(), le = c(i);
28
+ }), Pe = ut(), Le = pt(), De = dt(), { logEvent: m } = At(), { setConversationId: Be, emitToParent: O } = It(), ue = c(i);
29
29
  x(() => {
30
- const e = le.current;
31
- le.current = i, e !== i && m({
30
+ const e = ue.current;
31
+ ue.current = i, e !== i && m({
32
32
  eventName: "chat_conversation_changed",
33
33
  properties: {
34
34
  conversationId: i,
@@ -36,94 +36,98 @@ const Xt = () => {
36
36
  }
37
37
  });
38
38
  }, [i, m]);
39
- const [C, A] = F(""), De = (e) => A(e.target.value), {
40
- shouldBypassCaptcha: ce,
41
- filters: ue,
42
- privacyPreferences: Be,
43
- userProperties: z
44
- } = q, { authToken: _, isLoading: $e, refreshToken: pe } = ht(), de = !!q.getAuthToken, d = !!_, {
45
- onInputMessageChange: Ue,
46
- filters: fe,
39
+ const [C, A] = F(""), $e = (e) => A(e.target.value), {
40
+ shouldBypassCaptcha: pe,
41
+ filters: de,
42
+ privacyPreferences: Ue,
43
+ userProperties: z,
44
+ analyticsProperties: H
45
+ } = q, { authToken: _, isLoading: qe, refreshToken: fe } = vt(), me = !!q.getAuthToken, d = !!_, {
46
+ onInputMessageChange: ze,
47
+ filters: ge,
47
48
  baseUrl: N,
48
- agentUrl: qe,
49
- context: me,
50
- headers: ge,
49
+ agentUrl: He,
50
+ context: he,
51
+ headers: ve,
51
52
  appId: S,
52
53
  apiKey: h,
53
54
  files: b
54
- } = y, ze = _e?.isOpen ?? Ne?.isOpen ?? Pe?.isOpen ?? !0, { getCaptchaHeader: I, invalidate: u } = ft({
55
+ } = y, Ke = Pe?.isOpen ?? Le?.isOpen ?? De?.isOpen ?? !0, { getCaptchaHeader: R, invalidate: u } = mt({
55
56
  baseUrl: N,
56
- shouldBypassCaptcha: ce || !!h,
57
- shouldMakeInitialRequest: ze
58
- }), he = c(I);
59
- he.current = I;
60
- const ve = qe || `${N}/run/api/chat`, { sessionToken: H, refreshSession: K } = gt({
57
+ shouldBypassCaptcha: pe || !!h,
58
+ shouldMakeInitialRequest: Ke
59
+ }), ye = c(R);
60
+ ye.current = R;
61
+ const Ce = He || `${N}/run/api/chat`, { sessionToken: K, refreshSession: J } = ht({
61
62
  baseUrl: N,
62
63
  appId: S,
63
- getCaptchaHeader: I,
64
+ getCaptchaHeader: R,
64
65
  invalidateCaptcha: u,
65
- optOutAllAnalytics: Be?.optOutAllAnalytics,
66
- enabled: !d && !$e
67
- }), ye = h ?? (d ? _ : H), { loadConversation: Ce } = vt({
66
+ optOutAllAnalytics: Ue?.optOutAllAnalytics,
67
+ enabled: !d && !qe
68
+ }), Ae = h ?? (d ? _ : K), { loadConversation: Se } = yt({
68
69
  baseUrl: N,
69
70
  appId: S,
70
- authToken: ye,
71
- getCaptchaHeader: I,
71
+ authToken: Ae,
72
+ getCaptchaHeader: R,
72
73
  invalidateCaptcha: u,
73
- refreshSession: h || d ? void 0 : K
74
- }), [He, Ae] = F(!1), G = c(null);
75
- G.current = H;
76
- const J = c(null);
77
- J.current = _;
74
+ refreshSession: h || d ? void 0 : J
75
+ }), [Je, be] = F(!1), j = c(null);
76
+ j.current = K;
77
+ const G = c(null);
78
+ G.current = _;
78
79
  const V = c(void 0);
79
80
  V.current = z && Object.keys(z).length > 0 ? JSON.stringify(z) : void 0;
80
- const v = c(0), j = c(null), W = c(null), R = c(void 0), Ke = b?.map(
81
+ const W = c(void 0);
82
+ W.current = H && Object.keys(H).length > 0 ? JSON.stringify(H) : void 0;
83
+ const v = c(0), Q = c(null), Z = c(null), I = c(void 0), je = b?.map(
81
84
  (e) => `${e.filename ?? ""}:${e.mediaType}:${e.url.length}:${e.url.slice(0, 64)}:${e.url.slice(-32)}`
82
85
  ).join(`
83
86
  `) ?? "";
84
87
  x(() => {
85
- R.current = b?.length ? b : void 0;
86
- }, [Ke]);
87
- const Se = c(ge);
88
- Se.current = ge;
89
- const Q = c(void 0);
90
- Q.current = ue || fe ? JSON.stringify({ ...ue, ...fe }) : void 0;
88
+ I.current = b?.length ? b : void 0;
89
+ }, [je]);
90
+ const Re = c(ve);
91
+ Re.current = ve;
92
+ const X = c(void 0);
93
+ X.current = de || ge ? JSON.stringify({ ...de, ...ge }) : void 0;
91
94
  const Ge = (e) => {
92
- switch (kt(e)) {
95
+ switch (Mt(e)) {
93
96
  case 400:
94
97
  try {
95
98
  const t = JSON.parse(e.message ?? "");
96
- return t.detail ?? t.error?.message ?? Oe;
99
+ return t.detail ?? t.error?.message ?? Ne;
97
100
  } catch {
98
- return e.message?.trim() || Oe;
101
+ return e.message?.trim() || Ne;
99
102
  }
100
103
  case 401:
101
- return de ? "Authentication failed. Please try again." : ie;
104
+ return me ? "Authentication failed. Please try again." : ce;
102
105
  case 403:
103
106
  return `There seems to be a configuration error. Please contact ${q.organizationDisplayName ?? "Administrator"}`;
104
107
  case 429:
105
- return Mt;
108
+ return xt;
106
109
  default:
107
- return ie;
110
+ return ce;
108
111
  }
109
- }, [P, Z] = F([]), Je = Fe(
110
- () => new it({
111
- api: ve,
112
+ }, [P, Y] = F([]), Ve = _e(
113
+ () => new lt({
114
+ api: Ce,
112
115
  headers: () => {
113
- const e = h ?? J.current ?? G.current;
116
+ const e = h ?? G.current ?? j.current;
114
117
  return {
115
118
  "x-inkeep-client-timezone": Intl.DateTimeFormat().resolvedOptions().timeZone,
116
119
  "x-inkeep-client-timestamp": (/* @__PURE__ */ new Date()).toISOString(),
117
120
  "x-inkeep-invocation-type": "chat_widget",
118
121
  ...S ? { "x-inkeep-app-id": S } : {},
119
122
  ...e ? { Authorization: `Bearer ${e}` } : {},
120
- ...Q.current ? { "inkeep-filters": Q.current } : {},
123
+ ...X.current ? { "inkeep-filters": X.current } : {},
121
124
  ...V.current ? { "x-inkeep-user-properties": V.current } : {},
122
- ...Se.current
125
+ ...W.current ? { "x-inkeep-properties": W.current } : {},
126
+ ...Re.current
123
127
  };
124
128
  },
125
129
  prepareSendMessagesRequest: async (e) => {
126
- const a = await he.current(), t = e.messages[e.messages.length - 1];
130
+ const a = await ye.current(), t = e.messages[e.messages.length - 1];
127
131
  return t || console.warn(
128
132
  "[useInkeepChat] prepareSendMessagesRequest called with empty messages array"
129
133
  ), {
@@ -141,21 +145,20 @@ const Xt = () => {
141
145
  };
142
146
  },
143
147
  body: {
144
- requestContext: me
148
+ requestContext: he
145
149
  }
146
150
  }),
147
- [ve, me, S, h]
151
+ [Ce, he, S, h]
148
152
  ), {
149
153
  messages: L,
150
- sendMessage: X,
151
- addToolApprovalResponse: Y,
152
- addToolOutput: Ve,
153
- status: be,
154
+ sendMessage: ee,
155
+ addToolApprovalResponse: te,
156
+ status: Ie,
154
157
  setMessages: f,
155
158
  stop: D,
156
159
  error: B
157
- } = at({
158
- transport: Je,
160
+ } = it({
161
+ transport: Ve,
159
162
  onData(e) {
160
163
  O(e.type, e.data);
161
164
  },
@@ -174,47 +177,47 @@ const Xt = () => {
174
177
  },
175
178
  onError(e) {
176
179
  console.error("onError", { code: e.code, message: e.message });
177
- const a = ce || h ? null : Tt(e);
180
+ const a = pe || h ? null : Tt(e);
178
181
  if (a !== null && v.current < 1) {
179
182
  v.current++;
180
- const n = W.current, s = j.current;
183
+ const n = Z.current, s = Q.current;
181
184
  (async () => {
182
- if (a === "session" && de) {
183
- const l = await pe();
185
+ if (a === "session" && me) {
186
+ const l = await fe();
184
187
  if (!l) throw new Error("Auth token refresh failed");
185
- J.current = l;
188
+ G.current = l;
186
189
  } else if (a === "session") {
187
- const l = await K();
188
- l && (G.current = l);
190
+ const l = await J();
191
+ l && (j.current = l);
189
192
  } else
190
193
  u();
191
194
  if (n) {
192
- Y(n);
195
+ te(n);
193
196
  return;
194
197
  }
195
198
  s && (f((l) => {
196
199
  let r = [...l];
197
200
  return r.at(-1)?.role === "assistant" && (r = r.slice(0, -1)), r.at(-1)?.role === "user" && (r = r.slice(0, -1)), r;
198
- }), X(
201
+ }), ee(
199
202
  s.files?.length ? { parts: [{ type: "text", text: s.content }, ...s.files] } : { text: s.content },
200
203
  { body: s.body }
201
204
  ));
202
205
  })().catch(() => {
203
206
  v.current = 0, u(), f((l) => {
204
- const r = [...l], E = r[r.length - 1];
205
- if (!E) return r;
206
- const k = ie;
207
- return E.role === "user" ? r.push({
207
+ const r = [...l], k = r[r.length - 1];
208
+ if (!k) return r;
209
+ const E = ce;
210
+ return k.role === "user" ? r.push({
208
211
  id: U(16),
209
212
  role: "assistant",
210
- parts: [{ type: "text", text: k }]
211
- }) : E.parts = [{ type: "text", text: k }], r;
213
+ parts: [{ type: "text", text: E }]
214
+ }) : k.parts = [{ type: "text", text: E }], r;
212
215
  });
213
216
  });
214
217
  return;
215
218
  }
216
219
  v.current = 0, a !== null && u();
217
- const t = wt(e), p = Ge(e);
220
+ const t = kt(e), p = Ge(e);
218
221
  if (m({
219
222
  eventName: "chat_error",
220
223
  properties: {
@@ -222,15 +225,15 @@ const Xt = () => {
222
225
  error: e.message
223
226
  }
224
227
  }), t) {
225
- ne(
228
+ ae(
226
229
  { title: "Request failed", message: p },
227
230
  Et
228
231
  ), f((s) => {
229
232
  let o = [...s];
230
233
  return o.at(-1)?.role === "assistant" && (o = o.slice(0, -1)), o.at(-1)?.role === "user" && (o = o.slice(0, -1)), o;
231
234
  });
232
- const n = j.current?.content;
233
- n && A(n), re.current = e;
235
+ const n = Q.current?.content;
236
+ n && A(n), oe.current = e;
234
237
  return;
235
238
  }
236
239
  f((n) => {
@@ -242,12 +245,12 @@ const Xt = () => {
242
245
  }) : o.parts = [{ type: "text", text: p }]), s;
243
246
  });
244
247
  }
245
- }), Ie = c(d);
248
+ }), we = c(d);
246
249
  x(() => {
247
- const e = Ie.current;
248
- Ie.current = d, e !== d && (D(), T(null), f([]), g(""), A(""), Z([]), u());
250
+ const e = we.current;
251
+ we.current = d, e !== d && (D(), w(null), f([]), g(""), A(""), Y([]), u());
249
252
  }, [d, D, f, g, u]);
250
- const Re = be === "submitted", ee = be === "streaming", je = Fe(() => {
253
+ const Te = Ie === "submitted", se = Ie === "streaming", We = _e(() => {
251
254
  const e = (n) => {
252
255
  if (!n || typeof n != "object") return !1;
253
256
  const s = n;
@@ -255,62 +258,62 @@ const Xt = () => {
255
258
  }, t = [...L ?? []].reverse().find((n) => n.role === "assistant");
256
259
  if (!t) return !1;
257
260
  const p = t.parts?.at(-1);
258
- return !(!e(p) || p.state !== "output-available" || !p.approval?.id || ee);
259
- }, [L, ee]), [We, te] = F(!1), Te = ee || je && !We, we = Re || Te, Qe = L.length === 0, se = !C.trim() && P.length === 0 || we, Ze = mt("(max-width: 768px)"), [Xe, T] = F(null), re = c(null);
261
+ return !(!e(p) || p.state !== "output-available" || !p.approval?.id || se);
262
+ }, [L, se]), [Qe, re] = F(!1), ke = se || We && !Qe, Ee = Te || ke, Ze = L.length === 0, ne = !C.trim() && P.length === 0 || Ee, Xe = gt("(max-width: 768px)"), [Ye, w] = F(null), oe = c(null);
260
263
  x(() => {
261
264
  if (B) {
262
- if (re.current === B) {
263
- re.current = null;
265
+ if (oe.current === B) {
266
+ oe.current = null;
264
267
  return;
265
268
  }
266
- T(B);
269
+ w(B);
267
270
  }
268
271
  }, [B]);
269
- const Ye = () => T(null), { inputNotification: et, showInputNotification: ne, clearInputNotification: tt } = Rt(), Ee = c(null);
272
+ const et = () => w(null), { inputNotification: tt, showInputNotification: ae, clearInputNotification: st } = wt(), Me = c(null);
270
273
  x(() => {
271
- Ue?.(C);
274
+ ze?.(C);
272
275
  }, [C]);
273
- const st = (e) => {
274
- e.key === "Enter" && !e.shiftKey && !se && !e.nativeEvent.isComposing && (e.preventDefault(), oe());
275
- }, oe = async (e = C) => {
276
- if (se && (!e || e.trim().length === 0) && P.length === 0) return;
276
+ const rt = (e) => {
277
+ e.key === "Enter" && !e.shiftKey && !ne && !e.nativeEvent.isComposing && (e.preventDefault(), ie());
278
+ }, ie = async (e = C) => {
279
+ if (ne && (!e || e.trim().length === 0) && P.length === 0) return;
277
280
  const a = P;
278
- Z([]), A(""), v.current = 0, W.current = null, te(!1), await m({
281
+ Y([]), A(""), v.current = 0, Z.current = null, re(!1), await m({
279
282
  eventName: "user_message_submitted",
280
283
  properties: {
281
284
  conversationId: i
282
285
  }
283
286
  });
284
287
  let t = i;
285
- t || (t = `conv_${U(16)}`, g(t)), Le(t);
286
- const p = R.current;
287
- R.current = void 0;
288
+ t || (t = `conv_${U(16)}`, g(t)), Be(t);
289
+ const p = I.current;
290
+ I.current = void 0;
288
291
  let n, s;
289
292
  if (p?.length) {
290
293
  let o;
291
294
  try {
292
295
  o = await Promise.all(
293
296
  a.map((l) => {
294
- const r = xe(l);
295
- return new Promise((E, k) => {
297
+ const r = Oe(l);
298
+ return new Promise((k, E) => {
296
299
  const M = new FileReader();
297
300
  M.onload = () => {
298
301
  if (typeof M.result != "string") {
299
- k(new Error(`Failed to read file "${r.name}"`));
302
+ E(new Error(`Failed to read file "${r.name}"`));
300
303
  return;
301
304
  }
302
- E({
305
+ k({
303
306
  type: "file",
304
307
  url: M.result,
305
308
  mediaType: r.type,
306
309
  filename: r.name
307
310
  });
308
- }, M.onerror = () => k(new Error(`Failed to read file "${r.name}"`)), M.readAsDataURL(r);
311
+ }, M.onerror = () => E(new Error(`Failed to read file "${r.name}"`)), M.readAsDataURL(r);
309
312
  });
310
313
  })
311
314
  );
312
315
  } catch {
313
- ne({
316
+ ae({
314
317
  title: "Failed to attach files",
315
318
  message: "Could not read one or more files. Please try again."
316
319
  });
@@ -319,44 +322,44 @@ const Xt = () => {
319
322
  s = [...o, ...p], n = e.trim() ? { parts: [{ type: "text", text: e }, ...s] } : { parts: s };
320
323
  } else if (a.length > 0) {
321
324
  const o = new DataTransfer();
322
- for (const r of a) o.items.add(xe(r));
325
+ for (const r of a) o.items.add(Oe(r));
323
326
  const l = o.files;
324
327
  n = e.trim() ? { text: e, files: l } : { files: l };
325
328
  } else
326
329
  n = { text: e };
327
- j.current = {
330
+ Q.current = {
328
331
  content: e,
329
332
  body: { conversationId: t },
330
333
  files: s
331
- }, X(n, {
334
+ }, ee(n, {
332
335
  body: { conversationId: t }
333
336
  });
334
- }, rt = $(
337
+ }, nt = $(
335
338
  (e) => {
336
- v.current = 0, W.current = e, te(!1), Y(e);
339
+ v.current = 0, Z.current = e, re(!1), te(e);
337
340
  },
338
- [Y]
339
- ), ae = $(() => {
340
- te(!0), D().then(() => {
341
+ [te]
342
+ ), le = $(() => {
343
+ re(!0), D().then(() => {
341
344
  O("aborted", { conversationId: i });
342
345
  });
343
- }, [D, i, O]), ke = () => {
344
- Ye(), f([]), g(""), u(), R.current = b?.length ? b : void 0, m({
346
+ }, [D, i, O]), xe = () => {
347
+ et(), f([]), g(""), u(), I.current = b?.length ? b : void 0, m({
345
348
  eventName: "chat_clear_button_clicked",
346
349
  properties: {
347
350
  conversationId: i
348
351
  }
349
352
  });
350
- }, w = $(
353
+ }, T = $(
351
354
  (e, a) => {
352
- T(null), f(a), g(e), u(), R.current = void 0;
355
+ w(null), f(a), g(e), u(), I.current = void 0;
353
356
  },
354
357
  [f, g, u]
355
- ), Me = $(
358
+ ), Fe = $(
356
359
  async (e, a) => {
357
- ae(), w(e, []), Ae(!0);
360
+ le(), T(e, []), be(!0);
358
361
  try {
359
- const t = await Ce(e, a);
362
+ const t = await Se(e, a);
360
363
  if (t === null) return !1;
361
364
  const n = t[t.length - 1]?.role === "user" ? [
362
365
  ...t,
@@ -371,67 +374,66 @@ const Xt = () => {
371
374
  ]
372
375
  }
373
376
  ] : t;
374
- return w(e, n), !0;
377
+ return T(e, n), !0;
375
378
  } finally {
376
- a?.aborted || Ae(!1);
379
+ a?.aborted || be(!1);
377
380
  }
378
381
  },
379
- [w, Ce, ae]
382
+ [T, Se, le]
380
383
  );
381
- yt({
384
+ Ct({
382
385
  conversationId: y.conversationId,
383
- effectiveAuthToken: ye,
384
- loadAndRestoreSession: Me,
385
- onLoadFailed: () => w("", [])
386
+ effectiveAuthToken: Ae,
387
+ loadAndRestoreSession: Fe,
388
+ onLoadFailed: () => T("", [])
386
389
  });
387
- const { openForm: nt } = At(), ot = St();
388
- return lt(y.chatFunctionsRef, () => ({
389
- submitMessage: oe,
390
+ const { openForm: ot } = St(), at = bt();
391
+ return ct(y.chatFunctionsRef, () => ({
392
+ submitMessage: ie,
390
393
  updateInputMessage(e) {
391
394
  A(e);
392
395
  },
393
- clearChat: ke,
396
+ clearChat: xe,
394
397
  openForm: (e) => {
395
- ot?.setView("chat"), nt(e, void 0);
398
+ at?.setView("chat"), ot(e, void 0);
396
399
  },
397
400
  focusInput: () => {
398
- Ee.current?.focus();
401
+ Me.current?.focus();
399
402
  }
400
403
  })), {
401
404
  messages: L,
402
- sendMessage: X,
403
- addToolApprovalResponse: rt,
404
- addToolOutput: Ve,
405
- isLoading: Re,
406
- isStreaming: Te,
407
- isBusy: we,
408
- error: Xe,
409
- setError: T,
410
- isSubmitDisabled: se,
405
+ sendMessage: ee,
406
+ addToolApprovalResponse: nt,
407
+ isLoading: Te,
408
+ isStreaming: ke,
409
+ isBusy: Ee,
410
+ error: Ye,
411
+ setError: w,
412
+ isSubmitDisabled: ne,
411
413
  input: C,
412
- handleInputChange: De,
413
- handleInputKeyDown: st,
414
- handleSubmit: oe,
415
- stop: ae,
416
- clear: ke,
417
- inputRef: Ee,
418
- isMobile: Ze,
414
+ handleInputChange: $e,
415
+ handleInputKeyDown: rt,
416
+ handleSubmit: ie,
417
+ stop: le,
418
+ clear: xe,
419
+ inputRef: Me,
420
+ isMobile: Xe,
419
421
  files: P,
420
- setFiles: Z,
421
- isNewChat: Qe,
422
+ setFiles: Y,
423
+ isNewChat: Ze,
422
424
  conversationId: i,
423
- restoreSession: w,
424
- loadAndRestoreSession: Me,
425
- isSessionLoading: He,
426
- authToken: d ? _ : H,
427
- refreshSession: d ? pe : K,
428
- getCaptchaHeader: I,
425
+ restoreSession: T,
426
+ loadAndRestoreSession: Fe,
427
+ isSessionLoading: Je,
428
+ authToken: d ? _ : K,
429
+ refreshSession: d ? fe : J,
430
+ getCaptchaHeader: R,
429
431
  invalidateCaptcha: u,
430
- inputNotification: et,
431
- showInputNotification: ne,
432
- clearInputNotification: tt
432
+ inputNotification: tt,
433
+ showInputNotification: ae,
434
+ clearInputNotification: st
433
435
  };
434
436
  };
435
437
  export {
436
- Xt as useInkeepChat
438
+ Yt as useInkeepChat
437
439
  };