@8wave/ai-elements 0.123.0-beta.2 → 0.123.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/_chunks/{Agent-BcmcalNN.js → Agent-C0JtGK2t.js} +3 -2
  2. package/dist/_chunks/{Agent-BcmcalNN.js.map → Agent-C0JtGK2t.js.map} +1 -1
  3. package/dist/_chunks/{PkStreamingMarkdown-Dc0R0GHe.js → PkStreamingMarkdown-De3ihxaM.js} +3 -3
  4. package/dist/_chunks/{PkStreamingMarkdown-Dc0R0GHe.js.map → PkStreamingMarkdown-De3ihxaM.js.map} +1 -1
  5. package/dist/_chunks/{PkToolChatFile-3fYhbFSi.js → PkToolChatFile-CRp81vG5.js} +2 -2
  6. package/dist/_chunks/{PkToolChatFile-3fYhbFSi.js.map → PkToolChatFile-CRp81vG5.js.map} +1 -1
  7. package/dist/_chunks/{PkToolRequestGeolocation-n1W_drCv.js → PkToolRequestGeolocation-GlUmGHpD.js} +2 -2
  8. package/dist/_chunks/{PkToolRequestGeolocation-n1W_drCv.js.map → PkToolRequestGeolocation-GlUmGHpD.js.map} +1 -1
  9. package/dist/_chunks/{PkToolRequestOAuthConnection-DmMeSF2m.js → PkToolRequestOAuthConnection-7OvDQZe5.js} +2 -2
  10. package/dist/_chunks/{PkToolRequestOAuthConnection-DmMeSF2m.js.map → PkToolRequestOAuthConnection-7OvDQZe5.js.map} +1 -1
  11. package/dist/_chunks/{PkToolShowArtifact-BUnSqAWQ.js → PkToolShowArtifact-DmVWtJit.js} +2 -2
  12. package/dist/_chunks/{PkToolShowArtifact-BUnSqAWQ.js.map → PkToolShowArtifact-DmVWtJit.js.map} +1 -1
  13. package/dist/_chunks/{PkToolShowContactForm-YX1BuolZ.js → PkToolShowContactForm-9Kv-ZdN9.js} +2 -2
  14. package/dist/_chunks/{PkToolShowContactForm-YX1BuolZ.js.map → PkToolShowContactForm-9Kv-ZdN9.js.map} +1 -1
  15. package/dist/_chunks/{PkToolShowForm-CkpMsrEo.js → PkToolShowForm-CbKhYut7.js} +3 -3
  16. package/dist/_chunks/{PkToolShowForm-CkpMsrEo.js.map → PkToolShowForm-CbKhYut7.js.map} +1 -1
  17. package/dist/_chunks/{PkToolShowImageGallery-BnUnjFeU.js → PkToolShowImageGallery-6rZZHDOj.js} +2 -2
  18. package/dist/_chunks/{PkToolShowImageGallery-BnUnjFeU.js.map → PkToolShowImageGallery-6rZZHDOj.js.map} +1 -1
  19. package/dist/_chunks/{PkToolShowProductList-CPqmqS-Q.js → PkToolShowProductList-U9hglluW.js} +2 -2
  20. package/dist/_chunks/{PkToolShowProductList-CPqmqS-Q.js.map → PkToolShowProductList-U9hglluW.js.map} +1 -1
  21. package/dist/_chunks/{PkToolShowSources-BO1IhnmO.js → PkToolShowSources-BB7w_tMo.js} +3 -3
  22. package/dist/_chunks/{PkToolShowSources-BO1IhnmO.js.map → PkToolShowSources-BB7w_tMo.js.map} +1 -1
  23. package/dist/_chunks/{PkToolShowSuggestedReply-79UAjTL4.js → PkToolShowSuggestedReply-BxCeHVdn.js} +2 -2
  24. package/dist/_chunks/{PkToolShowSuggestedReply-79UAjTL4.js.map → PkToolShowSuggestedReply-BxCeHVdn.js.map} +1 -1
  25. package/dist/_chunks/{PkToolShowVideo-DYnH3VIc.js → PkToolShowVideo-BnLOMaQn.js} +2 -2
  26. package/dist/_chunks/{PkToolShowVideo-DYnH3VIc.js.map → PkToolShowVideo-BnLOMaQn.js.map} +1 -1
  27. package/dist/_chunks/{PkToolShowWebPages-Ci_Yut6X.js → PkToolShowWebPages-CBAQf2pg.js} +2 -2
  28. package/dist/_chunks/{PkToolShowWebPages-Ci_Yut6X.js.map → PkToolShowWebPages-CBAQf2pg.js.map} +1 -1
  29. package/dist/_chunks/{chatImagePolicy-B5-NwmIR.js → chatImagePolicy-B3-RzU9W.js} +2 -2
  30. package/dist/_chunks/{chatImagePolicy-B5-NwmIR.js.map → chatImagePolicy-B3-RzU9W.js.map} +1 -1
  31. package/dist/_chunks/{markdown-_sL6w03k.js → markdown-BxOlM5SY.js} +2 -2
  32. package/dist/_chunks/{markdown-_sL6w03k.js.map → markdown-BxOlM5SY.js.map} +1 -1
  33. package/dist/ai-elements.es.js +2674 -2593
  34. package/dist/ai-elements.es.js.map +1 -1
  35. package/dist-vue/PkChatbot.js +1 -1
  36. package/dist-vue/PkChatbotEmptyState.js +1 -1
  37. package/dist-vue/PkChatbotInput.js +1 -1
  38. package/dist-vue/PkChatbotMessages.js +1 -1
  39. package/dist-vue/PkChatbotStepPayload.js +1 -1
  40. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  41. package/dist-vue/PkChatbotSteps.js +1 -1
  42. package/dist-vue/PkChatbotViewChat.js +1 -1
  43. package/dist-vue/PkChatbotViewConversations.js +1 -1
  44. package/dist-vue/PkChatbotViewFiles.js +1 -1
  45. package/dist-vue/PkChatbotViewProfile.js +1 -1
  46. package/dist-vue/_chunks/{Agent-BWwjGG2f.js → Agent-Dsi_xGvV.js} +10 -9
  47. package/dist-vue/_chunks/{Agent-BWwjGG2f.js.map → Agent-Dsi_xGvV.js.map} +1 -1
  48. package/dist-vue/_chunks/{Document-DvRaziIf.js → Document-B5R1PJnc.js} +2 -2
  49. package/dist-vue/_chunks/{Document-DvRaziIf.js.map → Document-B5R1PJnc.js.map} +1 -1
  50. package/dist-vue/_chunks/{PkChatbot-D3KGDerg.js → PkChatbot-B0EC0aOA.js} +8 -8
  51. package/dist-vue/_chunks/{PkChatbot-D3KGDerg.js.map → PkChatbot-B0EC0aOA.js.map} +1 -1
  52. package/dist-vue/_chunks/{PkChatbotEmptyState-B76oD7fB.js → PkChatbotEmptyState-yO8Z-3p4.js} +2 -2
  53. package/dist-vue/_chunks/{PkChatbotEmptyState-B76oD7fB.js.map → PkChatbotEmptyState-yO8Z-3p4.js.map} +1 -1
  54. package/dist-vue/_chunks/{PkChatbotInput-BT51V-v4.js → PkChatbotInput-CiNeclez.js} +2 -2
  55. package/dist-vue/_chunks/{PkChatbotInput-BT51V-v4.js.map → PkChatbotInput-CiNeclez.js.map} +1 -1
  56. package/dist-vue/_chunks/PkChatbotMessages-CcR2PKp3.js +982 -0
  57. package/dist-vue/_chunks/PkChatbotMessages-CcR2PKp3.js.map +1 -0
  58. package/dist-vue/_chunks/{PkChatbotStepPayload-BYChvULZ.js → PkChatbotStepPayload-CWJmmF6k.js} +2 -2
  59. package/dist-vue/_chunks/{PkChatbotStepPayload-BYChvULZ.js.map → PkChatbotStepPayload-CWJmmF6k.js.map} +1 -1
  60. package/dist-vue/_chunks/{PkChatbotStepToolDetail-BysPl2ko.js → PkChatbotStepToolDetail-gT-CpGZH.js} +3 -3
  61. package/dist-vue/_chunks/{PkChatbotStepToolDetail-BysPl2ko.js.map → PkChatbotStepToolDetail-gT-CpGZH.js.map} +1 -1
  62. package/dist-vue/_chunks/{PkChatbotSteps-p8-SuGGe.js → PkChatbotSteps-CUznAYXB.js} +5 -5
  63. package/dist-vue/_chunks/{PkChatbotSteps-p8-SuGGe.js.map → PkChatbotSteps-CUznAYXB.js.map} +1 -1
  64. package/dist-vue/_chunks/{PkChatbotViewChat-BNaSv86u.js → PkChatbotViewChat-DDnJ-2Ic.js} +377 -371
  65. package/dist-vue/_chunks/PkChatbotViewChat-DDnJ-2Ic.js.map +1 -0
  66. package/dist-vue/_chunks/{PkChatbotViewConversations-C1vl8z4o.js → PkChatbotViewConversations-D0I6g4QO.js} +3 -3
  67. package/dist-vue/_chunks/{PkChatbotViewConversations-C1vl8z4o.js.map → PkChatbotViewConversations-D0I6g4QO.js.map} +1 -1
  68. package/dist-vue/_chunks/{PkChatbotViewFiles-DiKHsdPE.js → PkChatbotViewFiles-UjuW1UGm.js} +3 -3
  69. package/dist-vue/_chunks/{PkChatbotViewFiles-DiKHsdPE.js.map → PkChatbotViewFiles-UjuW1UGm.js.map} +1 -1
  70. package/dist-vue/_chunks/{PkChatbotViewProfile-CuQ0MAX7.js → PkChatbotViewProfile-Dvqk0e3I.js} +2 -2
  71. package/dist-vue/_chunks/{PkChatbotViewProfile-CuQ0MAX7.js.map → PkChatbotViewProfile-Dvqk0e3I.js.map} +1 -1
  72. package/dist-vue/_chunks/{PkStreamingMarkdown-B-sEx8BP.js → PkStreamingMarkdown-C_4h85DA.js} +3 -3
  73. package/dist-vue/_chunks/{PkStreamingMarkdown-B-sEx8BP.js.map → PkStreamingMarkdown-C_4h85DA.js.map} +1 -1
  74. package/dist-vue/_chunks/{PkToolChatFile-BJsDSu1Q.js → PkToolChatFile-CMcJl0hu.js} +2 -2
  75. package/dist-vue/_chunks/{PkToolChatFile-BJsDSu1Q.js.map → PkToolChatFile-CMcJl0hu.js.map} +1 -1
  76. package/dist-vue/_chunks/{PkToolRequestGeolocation-e8vyxTI_.js → PkToolRequestGeolocation-Bzu1fQ-X.js} +2 -2
  77. package/dist-vue/_chunks/{PkToolRequestGeolocation-e8vyxTI_.js.map → PkToolRequestGeolocation-Bzu1fQ-X.js.map} +1 -1
  78. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-3zLvNF_c.js → PkToolRequestOAuthConnection-C8t_5YtB.js} +2 -2
  79. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-3zLvNF_c.js.map → PkToolRequestOAuthConnection-C8t_5YtB.js.map} +1 -1
  80. package/dist-vue/_chunks/{PkToolShowArtifact-BRwa5pGY.js → PkToolShowArtifact-Pvi63K3m.js} +2 -2
  81. package/dist-vue/_chunks/{PkToolShowArtifact-BRwa5pGY.js.map → PkToolShowArtifact-Pvi63K3m.js.map} +1 -1
  82. package/dist-vue/_chunks/{PkToolShowContactForm-xHBTmITM.js → PkToolShowContactForm-BNta1jh0.js} +2 -2
  83. package/dist-vue/_chunks/{PkToolShowContactForm-xHBTmITM.js.map → PkToolShowContactForm-BNta1jh0.js.map} +1 -1
  84. package/dist-vue/_chunks/{PkToolShowDiagram-DrJs92dg.js → PkToolShowDiagram-BRHpp_P-.js} +2 -2
  85. package/dist-vue/_chunks/{PkToolShowDiagram-DrJs92dg.js.map → PkToolShowDiagram-BRHpp_P-.js.map} +1 -1
  86. package/dist-vue/_chunks/{PkToolShowForm-Fv4iV0VY.js → PkToolShowForm-DuX1By1C.js} +4 -4
  87. package/dist-vue/_chunks/{PkToolShowForm-Fv4iV0VY.js.map → PkToolShowForm-DuX1By1C.js.map} +1 -1
  88. package/dist-vue/_chunks/{PkToolShowImageGallery-DD_RGcL6.js → PkToolShowImageGallery-9n-B5Jqo.js} +2 -2
  89. package/dist-vue/_chunks/{PkToolShowImageGallery-DD_RGcL6.js.map → PkToolShowImageGallery-9n-B5Jqo.js.map} +1 -1
  90. package/dist-vue/_chunks/{PkToolShowProductList-8UQSQvRr.js → PkToolShowProductList-BE_nXuEa.js} +2 -2
  91. package/dist-vue/_chunks/{PkToolShowProductList-8UQSQvRr.js.map → PkToolShowProductList-BE_nXuEa.js.map} +1 -1
  92. package/dist-vue/_chunks/{PkToolShowSources-C4rKpypf.js → PkToolShowSources-89OXReX8.js} +3 -3
  93. package/dist-vue/_chunks/{PkToolShowSources-C4rKpypf.js.map → PkToolShowSources-89OXReX8.js.map} +1 -1
  94. package/dist-vue/_chunks/{PkToolShowSuggestedReply-Bnhgsh4l.js → PkToolShowSuggestedReply-CxOyvAB6.js} +2 -2
  95. package/dist-vue/_chunks/{PkToolShowSuggestedReply-Bnhgsh4l.js.map → PkToolShowSuggestedReply-CxOyvAB6.js.map} +1 -1
  96. package/dist-vue/_chunks/{PkToolShowVideo-NOwtZPgI.js → PkToolShowVideo-C3SbJ3Zb.js} +2 -2
  97. package/dist-vue/_chunks/{PkToolShowVideo-NOwtZPgI.js.map → PkToolShowVideo-C3SbJ3Zb.js.map} +1 -1
  98. package/dist-vue/_chunks/{PkToolShowWebPages-DcPboNwp.js → PkToolShowWebPages-CjNhdQbq.js} +2 -2
  99. package/dist-vue/_chunks/{PkToolShowWebPages-DcPboNwp.js.map → PkToolShowWebPages-CjNhdQbq.js.map} +1 -1
  100. package/dist-vue/_chunks/{createChatbotApiClient-DAh91HyT.js → createChatbotApiClient-CesweDUX.js} +4 -3
  101. package/dist-vue/_chunks/{createChatbotApiClient-DAh91HyT.js.map → createChatbotApiClient-CesweDUX.js.map} +1 -1
  102. package/dist-vue/_chunks/{useChatbotStore-D1U24qc8.js → useChatbotStore-CNcPLoPf.js} +695 -635
  103. package/dist-vue/_chunks/useChatbotStore-CNcPLoPf.js.map +1 -0
  104. package/dist-vue/_chunks/{utils-DaAIWTtt.js → utils-PU7OuUYN.js} +2 -2
  105. package/dist-vue/_chunks/{utils-DaAIWTtt.js.map → utils-PU7OuUYN.js.map} +1 -1
  106. package/dist-vue/api.js +1 -1
  107. package/dist-vue/composables.js +4 -4
  108. package/dist-vue/index.js +24 -24
  109. package/dist-vue/packages/components/src/chat/useVoiceSession.d.ts +6 -0
  110. package/dist-vue/packages/composable/src/chatbot/api/createChatbotApiClient.d.ts +2 -0
  111. package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +61 -1
  112. package/dist-vue/packages/models/src/schema/Agent.d.ts +1 -0
  113. package/package.json +1 -1
  114. package/dist-vue/_chunks/PkChatbotMessages-qkodgdDE.js +0 -968
  115. package/dist-vue/_chunks/PkChatbotMessages-qkodgdDE.js.map +0 -1
  116. package/dist-vue/_chunks/PkChatbotViewChat-BNaSv86u.js.map +0 -1
  117. package/dist-vue/_chunks/useChatbotStore-D1U24qc8.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { C as e, D as t, O as n, S as r, _ as i, a, g as o, h as s, i as c, l, m as u, o as d, p as f, r as p, s as m, u as h, v as g, w as _, x as v } from "./schemas-BO5QlXAp.js";
2
- import { $ as y, B as b, G as ee, Q as te, W as ne, Y as re, et as ie, q as ae } from "./Agent-BWwjGG2f.js";
3
- import { r as oe, t as se } from "./createChatbotApiClient-DAh91HyT.js";
2
+ import { $ as y, B as b, G as ee, Q as te, W as ne, Y as re, et as ie, q as ae } from "./Agent-Dsi_xGvV.js";
3
+ import { r as oe, t as se } from "./createChatbotApiClient-CesweDUX.js";
4
4
  import { n as ce } from "./src-B-ZKEhTU.js";
5
5
  import { d as le, r as ue } from "./message-DuibQyHy.js";
6
6
  import { n as de, t as fe } from "./useSafeLocalStorage-a2eHEqAi.js";
@@ -172,18 +172,18 @@ var Ne = "vercel.ai.error", Pe = Symbol.for(Ne), w = class e extends Error {
172
172
  static isInstance(e) {
173
173
  return w.hasMarker(e, Ie);
174
174
  }
175
- }, T = "AI_EmptyResponseBodyError", ze = `vercel.ai.error.${T}`, Be = Symbol.for(ze), E = class extends w {
175
+ }, ze = "AI_EmptyResponseBodyError", T = `vercel.ai.error.${ze}`, Be = Symbol.for(T), Ve = class extends w {
176
176
  constructor({ message: e = "Empty response body" } = {}) {
177
177
  super({
178
- name: T,
178
+ name: ze,
179
179
  message: e
180
180
  }), this[Be] = !0;
181
181
  }
182
182
  static isInstance(e) {
183
- return w.hasMarker(e, ze);
183
+ return w.hasMarker(e, T);
184
184
  }
185
185
  };
186
- function Ve(e) {
186
+ function E(e) {
187
187
  return e == null ? "unknown error" : typeof e == "string" ? e : e instanceof Error ? e.toString() : JSON.stringify(e);
188
188
  }
189
189
  var He = "AI_InvalidArgumentError", Ue = `vercel.ai.error.${He}`, We = Symbol.for(Ue), Ge = class extends w {
@@ -201,14 +201,14 @@ var He = "AI_InvalidArgumentError", Ue = `vercel.ai.error.${He}`, We = Symbol.fo
201
201
  constructor({ text: e, cause: t }) {
202
202
  super({
203
203
  name: Ke,
204
- message: `JSON parsing failed: Text: ${e}.\nError message: ${Ve(t)}`,
204
+ message: `JSON parsing failed: Text: ${e}.\nError message: ${E(t)}`,
205
205
  cause: t
206
206
  }), this[Je] = !0, this.text = e;
207
207
  }
208
208
  static isInstance(e) {
209
209
  return w.hasMarker(e, qe);
210
210
  }
211
- }, Xe = "AI_TypeValidationError", Ze = `vercel.ai.error.${Xe}`, Qe = Symbol.for(Ze), D = class e extends w {
211
+ }, Xe = "AI_TypeValidationError", Ze = `vercel.ai.error.${Xe}`, Qe = Symbol.for(Ze), $e = class e extends w {
212
212
  constructor({ value: e, cause: t, context: n }) {
213
213
  let r = "Type validation failed";
214
214
  if (n?.field && (r += ` for ${n.field}`), n?.entityName || n?.entityId) {
@@ -218,7 +218,7 @@ var He = "AI_InvalidArgumentError", Ue = `vercel.ai.error.${He}`, We = Symbol.fo
218
218
  }
219
219
  super({
220
220
  name: Xe,
221
- message: `${r}: Value: ${JSON.stringify(e)}.\nError message: ${Ve(t)}`,
221
+ message: `${r}: Value: ${JSON.stringify(e)}.\nError message: ${E(t)}`,
222
222
  cause: t
223
223
  }), this[Qe] = !0, this.value = e, this.context = n;
224
224
  }
@@ -232,25 +232,25 @@ var He = "AI_InvalidArgumentError", Ue = `vercel.ai.error.${He}`, We = Symbol.fo
232
232
  context: r
233
233
  });
234
234
  }
235
- }, $e = "AI_UnsupportedFunctionalityError", et = `vercel.ai.error.${$e}`, tt = Symbol.for(et), O = class extends w {
235
+ }, D = "AI_UnsupportedFunctionalityError", et = `vercel.ai.error.${D}`, tt = Symbol.for(et), nt = class extends w {
236
236
  constructor({ functionality: e, message: t = `'${e}' functionality not supported.` }) {
237
237
  super({
238
- name: $e,
238
+ name: D,
239
239
  message: t
240
240
  }), this[tt] = !0, this.functionality = e;
241
241
  }
242
242
  static isInstance(e) {
243
243
  return w.hasMarker(e, et);
244
244
  }
245
- }, nt = class extends Error {
245
+ }, O = class extends Error {
246
246
  constructor(e, t) {
247
247
  super(e), this.name = "ParseError", this.type = t.type, this.field = t.field, this.value = t.value, this.line = t.line;
248
248
  }
249
249
  }, rt = 10, it = 13, k = 32;
250
- function A(e) {}
251
- function at(e) {
250
+ function at(e) {}
251
+ function ot(e) {
252
252
  if (typeof e == "function") throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
253
- let { onEvent: t = A, onError: n = A, onRetry: r = A, onComment: i, maxBufferSize: a } = e, o = [], s = 0, c = !0, l, u = "", d = 0, f, p = !1;
253
+ let { onEvent: t = at, onError: n = at, onRetry: r = at, onComment: i, maxBufferSize: a } = e, o = [], s = 0, c = !0, l, u = "", d = 0, f, p = !1;
254
254
  function m(e) {
255
255
  if (p) throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
256
256
  if (c && (c = !1, e.charCodeAt(0) === 239 && e.charCodeAt(1) === 187 && e.charCodeAt(2) === 191 && (e = e.slice(3))), o.length === 0) {
@@ -269,7 +269,7 @@ function at(e) {
269
269
  n !== "" && (o.push(n), s = n.length), h();
270
270
  }
271
271
  function h() {
272
- a !== void 0 && (s + u.length <= a || (p = !0, o.length = 0, s = 0, l = void 0, u = "", d = 0, f = void 0, n(new nt(`Buffered data exceeded max buffer size of ${a} characters`, { type: "max-buffer-size-exceeded" }))));
272
+ a !== void 0 && (s + u.length <= a || (p = !0, o.length = 0, s = 0, l = void 0, u = "", d = 0, f = void 0, n(new O(`Buffered data exceeded max buffer size of ${a} characters`, { type: "max-buffer-size-exceeded" }))));
273
273
  }
274
274
  function g(e) {
275
275
  let n = 0;
@@ -285,7 +285,7 @@ function at(e) {
285
285
  continue;
286
286
  }
287
287
  let i = e.charCodeAt(n);
288
- if (ot(e, n, i)) {
288
+ if (A(e, n, i)) {
289
289
  let i = e.charCodeAt(n + 5) === k ? n + 6 : n + 5, a = e.slice(i, r);
290
290
  if (d === 0 && e.charCodeAt(r + 1) === rt) {
291
291
  t({
@@ -297,7 +297,7 @@ function at(e) {
297
297
  }
298
298
  u = d === 0 ? a : `${u}
299
299
  ${a}`, d++;
300
- } else j(e, n, i) ? f = e.slice(e.charCodeAt(n + 6) === k ? n + 7 : n + 6, r) || void 0 : _(e, n, r);
300
+ } else st(e, n, i) ? f = e.slice(e.charCodeAt(n + 6) === k ? n + 7 : n + 6, r) || void 0 : _(e, n, r);
301
301
  n = r + 1, r = e.indexOf("\n", n);
302
302
  }
303
303
  return e.slice(n);
@@ -315,13 +315,13 @@ ${a}`, d++;
315
315
  return;
316
316
  }
317
317
  let r = e.charCodeAt(t);
318
- if (ot(e, t, r)) {
318
+ if (A(e, t, r)) {
319
319
  let r = e.charCodeAt(t + 5) === k ? t + 6 : t + 5, i = e.slice(r, n);
320
320
  u = d === 0 ? i : `${u}
321
321
  ${i}`, d++;
322
322
  return;
323
323
  }
324
- if (j(e, t, r)) {
324
+ if (st(e, t, r)) {
325
325
  f = e.slice(e.charCodeAt(t + 6) === k ? t + 7 : t + 6, n) || void 0;
326
326
  return;
327
327
  }
@@ -358,13 +358,13 @@ ${t}`, d++;
358
358
  l = t.includes("\0") ? void 0 : t;
359
359
  break;
360
360
  case "retry":
361
- /^\d+$/.test(t) ? r(parseInt(t, 10)) : n(new nt(`Invalid \`retry\` value: "${t}"`, {
361
+ /^\d+$/.test(t) ? r(parseInt(t, 10)) : n(new O(`Invalid \`retry\` value: "${t}"`, {
362
362
  type: "invalid-retry",
363
363
  value: t,
364
364
  line: i
365
365
  }));
366
366
  break;
367
- default: n(new nt(`Unknown field "${e.length > 20 ? `${e.slice(0, 20)}\u2026` : e}"`, {
367
+ default: n(new O(`Unknown field "${e.length > 20 ? `${e.slice(0, 20)}\u2026` : e}"`, {
368
368
  type: "unknown-field",
369
369
  field: e,
370
370
  value: t,
@@ -391,19 +391,19 @@ ${t}`, d++;
391
391
  reset: b
392
392
  };
393
393
  }
394
- function ot(e, t, n) {
394
+ function A(e, t, n) {
395
395
  return n === 100 && e.charCodeAt(t + 1) === 97 && e.charCodeAt(t + 2) === 116 && e.charCodeAt(t + 3) === 97 && e.charCodeAt(t + 4) === 58;
396
396
  }
397
- function j(e, t, n) {
397
+ function st(e, t, n) {
398
398
  return n === 101 && e.charCodeAt(t + 1) === 118 && e.charCodeAt(t + 2) === 101 && e.charCodeAt(t + 3) === 110 && e.charCodeAt(t + 4) === 116 && e.charCodeAt(t + 5) === 58;
399
399
  }
400
400
  // ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
401
- var st = class extends TransformStream {
401
+ var ct = class extends TransformStream {
402
402
  constructor({ onError: e, onRetry: t, onComment: n, maxBufferSize: r } = {}) {
403
403
  let i;
404
404
  super({
405
405
  start(a) {
406
- i = at({
406
+ i = ot({
407
407
  onEvent: (e) => {
408
408
  a.enqueue(e);
409
409
  },
@@ -422,8 +422,8 @@ var st = class extends TransformStream {
422
422
  }
423
423
  };
424
424
  new TextDecoder();
425
- var { btoa: ct, atob: lt } = globalThis;
426
- function M(e) {
425
+ var { btoa: lt, atob: ut } = globalThis;
426
+ function dt(e) {
427
427
  if (e == null) return {};
428
428
  let t = {};
429
429
  if (e instanceof Headers) e.forEach((e, n) => {
@@ -435,7 +435,7 @@ function M(e) {
435
435
  }
436
436
  return t;
437
437
  }
438
- var N = ({ prefix: e, size: t = 16, alphabet: n = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", separator: r = "-" } = {}) => {
438
+ var j = ({ prefix: e, size: t = 16, alphabet: n = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", separator: r = "-" } = {}) => {
439
439
  let i = () => {
440
440
  let e = n.length, r = Array(t);
441
441
  for (let i = 0; i < t; i++) r[i] = n[Math.random() * e | 0];
@@ -447,16 +447,16 @@ var N = ({ prefix: e, size: t = 16, alphabet: n = "0123456789ABCDEFGHIJKLMNOPQRS
447
447
  message: `The separator "${r}" must not be part of the alphabet "${n}".`
448
448
  });
449
449
  return () => `${e}${r}${i()}`;
450
- }, ut = N();
451
- function P(e) {
450
+ }, ft = j();
451
+ function pt(e) {
452
452
  return globalThis.Buffer?.isBuffer(e) ?? !1;
453
453
  }
454
- var dt = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, ft = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
455
- function pt(e) {
454
+ var mt = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, ht = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
455
+ function M(e) {
456
456
  let t = JSON.parse(e);
457
- return typeof t != "object" || !t || dt.test(e) === !1 && ft.test(e) === !1 ? t : mt(t);
457
+ return typeof t != "object" || !t || mt.test(e) === !1 && ht.test(e) === !1 ? t : gt(t);
458
458
  }
459
- function mt(e) {
459
+ function gt(e) {
460
460
  let t = [e];
461
461
  for (; t.length;) {
462
462
  let e = t;
@@ -471,35 +471,35 @@ function mt(e) {
471
471
  }
472
472
  return e;
473
473
  }
474
- function ht(e) {
474
+ function _t(e) {
475
475
  let { stackTraceLimit: t } = Error;
476
476
  try {
477
477
  Error.stackTraceLimit = 0;
478
478
  } catch {
479
- return pt(e);
479
+ return M(e);
480
480
  }
481
481
  try {
482
- return pt(e);
482
+ return M(e);
483
483
  } finally {
484
484
  Error.stackTraceLimit = t;
485
485
  }
486
486
  }
487
- function gt(e) {
487
+ function vt(e) {
488
488
  if (e.type === "object" || Array.isArray(e.type) && e.type.includes("object")) {
489
489
  let { additionalProperties: t } = e;
490
- e.additionalProperties = t != null && typeof t != "boolean" && F(t);
490
+ e.additionalProperties = t != null && typeof t != "boolean" && N(t);
491
491
  let { properties: n } = e;
492
- if (n != null) for (let e of Object.keys(n)) n[e] = F(n[e]);
492
+ if (n != null) for (let e of Object.keys(n)) n[e] = N(n[e]);
493
493
  }
494
- e.items != null && (e.items = Array.isArray(e.items) ? e.items.map(F) : F(e.items)), e.anyOf != null && (e.anyOf = e.anyOf.map(F)), e.allOf != null && (e.allOf = e.allOf.map(F)), e.oneOf != null && (e.oneOf = e.oneOf.map(F));
494
+ e.items != null && (e.items = Array.isArray(e.items) ? e.items.map(N) : N(e.items)), e.anyOf != null && (e.anyOf = e.anyOf.map(N)), e.allOf != null && (e.allOf = e.allOf.map(N)), e.oneOf != null && (e.oneOf = e.oneOf.map(N));
495
495
  let { definitions: t } = e;
496
- if (t != null) for (let e of Object.keys(t)) t[e] = F(t[e]);
496
+ if (t != null) for (let e of Object.keys(t)) t[e] = N(t[e]);
497
497
  return e;
498
498
  }
499
- function F(e) {
500
- return typeof e == "boolean" ? e : gt(e);
499
+ function N(e) {
500
+ return typeof e == "boolean" ? e : vt(e);
501
501
  }
502
- var _t = Symbol("Let zodToJsonSchema decide on which parser to use"), vt = {
502
+ var P = Symbol("Let zodToJsonSchema decide on which parser to use"), F = {
503
503
  name: void 0,
504
504
  $refStrategy: "root",
505
505
  basePath: ["#"],
@@ -520,10 +520,10 @@ var _t = Symbol("Let zodToJsonSchema decide on which parser to use"), vt = {
520
520
  base64Strategy: "contentEncoding:base64",
521
521
  nameStrategy: "ref"
522
522
  }, yt = (e) => typeof e == "string" ? {
523
- ...vt,
523
+ ...F,
524
524
  name: e
525
525
  } : {
526
- ...vt,
526
+ ...F,
527
527
  ...e
528
528
  };
529
529
  function I() {
@@ -553,13 +553,13 @@ function xt(e) {
553
553
  }
554
554
  return t;
555
555
  }
556
- function L() {
556
+ function St() {
557
557
  return { type: "boolean" };
558
558
  }
559
- function St(e, t) {
559
+ function Ct(e, t) {
560
560
  return q(e.type._def, t);
561
561
  }
562
- var Ct = (e, t) => q(e.innerType._def, t);
562
+ var L = (e, t) => q(e.innerType._def, t);
563
563
  function wt(e, t, n) {
564
564
  let r = n ?? t.dateStrategy;
565
565
  if (Array.isArray(r)) return { anyOf: r.map((n) => wt(e, t, n)) };
@@ -595,17 +595,17 @@ function Et(e, t) {
595
595
  default: e.defaultValue()
596
596
  };
597
597
  }
598
- function R(e, t) {
598
+ function Dt(e, t) {
599
599
  return t.effectStrategy === "input" ? q(e.schema._def, t) : I();
600
600
  }
601
- function Dt(e) {
601
+ function Ot(e) {
602
602
  return {
603
603
  type: "string",
604
604
  enum: Array.from(e.values)
605
605
  };
606
606
  }
607
- var Ot = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
608
- function kt(e, t) {
607
+ var kt = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
608
+ function R(e, t) {
609
609
  let n = [q(e.left._def, {
610
610
  ...t,
611
611
  currentPath: [
@@ -622,7 +622,7 @@ function kt(e, t) {
622
622
  ]
623
623
  })].filter((e) => !!e), r = [];
624
624
  return n.forEach((e) => {
625
- if (Ot(e)) r.push(...e.allOf);
625
+ if (kt(e)) r.push(...e.allOf);
626
626
  else {
627
627
  let t = e;
628
628
  if ("additionalProperties" in e && e.additionalProperties === !1) {
@@ -633,19 +633,19 @@ function kt(e, t) {
633
633
  }
634
634
  }), r.length ? { allOf: r } : void 0;
635
635
  }
636
- function z(e) {
636
+ function At(e) {
637
637
  let t = typeof e.value;
638
638
  return t !== "bigint" && t !== "number" && t !== "boolean" && t !== "string" ? { type: Array.isArray(e.value) ? "array" : "object" } : {
639
639
  type: t === "bigint" ? "integer" : t,
640
640
  const: e.value
641
641
  };
642
642
  }
643
- var B = void 0, V = {
643
+ var z = void 0, B = {
644
644
  cuid: /^[cC][^\s-]{8,}$/,
645
645
  cuid2: /^[0-9a-z]+$/,
646
646
  ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
647
647
  email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
648
- emoji: () => (B === void 0 && (B = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), B),
648
+ emoji: () => (z === void 0 && (z = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), z),
649
649
  uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
650
650
  ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
651
651
  ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
@@ -656,7 +656,7 @@ var B = void 0, V = {
656
656
  nanoid: /^[a-zA-Z0-9_-]{21}$/,
657
657
  jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
658
658
  };
659
- function At(e, t) {
659
+ function jt(e, t) {
660
660
  let n = { type: "string" };
661
661
  if (e.checks) for (let r of e.checks) switch (r.kind) {
662
662
  case "min":
@@ -673,7 +673,7 @@ function At(e, t) {
673
673
  case "format:idn-email":
674
674
  H(n, "idn-email", r.message, t);
675
675
  break;
676
- case "pattern:zod": U(n, V.email, r.message, t);
676
+ case "pattern:zod": U(n, B.email, r.message, t);
677
677
  }
678
678
  break;
679
679
  case "url":
@@ -686,16 +686,16 @@ function At(e, t) {
686
686
  U(n, r.regex, r.message, t);
687
687
  break;
688
688
  case "cuid":
689
- U(n, V.cuid, r.message, t);
689
+ U(n, B.cuid, r.message, t);
690
690
  break;
691
691
  case "cuid2":
692
- U(n, V.cuid2, r.message, t);
692
+ U(n, B.cuid2, r.message, t);
693
693
  break;
694
694
  case "startsWith":
695
- U(n, RegExp(`^${jt(r.value, t)}`), r.message, t);
695
+ U(n, RegExp(`^${Mt(r.value, t)}`), r.message, t);
696
696
  break;
697
697
  case "endsWith":
698
- U(n, RegExp(`${jt(r.value, t)}$`), r.message, t);
698
+ U(n, RegExp(`${Mt(r.value, t)}$`), r.message, t);
699
699
  break;
700
700
  case "datetime":
701
701
  H(n, "date-time", r.message, t);
@@ -713,25 +713,25 @@ function At(e, t) {
713
713
  n.minLength = typeof n.minLength == "number" ? Math.max(n.minLength, r.value) : r.value, n.maxLength = typeof n.maxLength == "number" ? Math.min(n.maxLength, r.value) : r.value;
714
714
  break;
715
715
  case "includes":
716
- U(n, RegExp(jt(r.value, t)), r.message, t);
716
+ U(n, RegExp(Mt(r.value, t)), r.message, t);
717
717
  break;
718
718
  case "ip":
719
719
  r.version !== "v6" && H(n, "ipv4", r.message, t), r.version !== "v4" && H(n, "ipv6", r.message, t);
720
720
  break;
721
721
  case "base64url":
722
- U(n, V.base64url, r.message, t);
722
+ U(n, B.base64url, r.message, t);
723
723
  break;
724
724
  case "jwt":
725
- U(n, V.jwt, r.message, t);
725
+ U(n, B.jwt, r.message, t);
726
726
  break;
727
727
  case "cidr":
728
- r.version !== "v6" && U(n, V.ipv4Cidr, r.message, t), r.version !== "v4" && U(n, V.ipv6Cidr, r.message, t);
728
+ r.version !== "v6" && U(n, B.ipv4Cidr, r.message, t), r.version !== "v4" && U(n, B.ipv6Cidr, r.message, t);
729
729
  break;
730
730
  case "emoji":
731
- U(n, V.emoji(), r.message, t);
731
+ U(n, B.emoji(), r.message, t);
732
732
  break;
733
733
  case "ulid":
734
- U(n, V.ulid, r.message, t);
734
+ U(n, B.ulid, r.message, t);
735
735
  break;
736
736
  case "base64":
737
737
  switch (t.base64Strategy) {
@@ -741,20 +741,20 @@ function At(e, t) {
741
741
  case "contentEncoding:base64":
742
742
  n.contentEncoding = "base64";
743
743
  break;
744
- case "pattern:zod": U(n, V.base64, r.message, t);
744
+ case "pattern:zod": U(n, B.base64, r.message, t);
745
745
  }
746
746
  break;
747
- case "nanoid": U(n, V.nanoid, r.message, t);
747
+ case "nanoid": U(n, B.nanoid, r.message, t);
748
748
  }
749
749
  return n;
750
750
  }
751
- function jt(e, t) {
751
+ function Mt(e, t) {
752
752
  return t.patternStrategy === "escape" ? Nt(e) : e;
753
753
  }
754
- var Mt = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
754
+ var V = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
755
755
  function Nt(e) {
756
756
  let t = "";
757
- for (let n = 0; n < e.length; n++) Mt.has(e[n]) || (t += "\\"), t += e[n];
757
+ for (let n = 0; n < e.length; n++) V.has(e[n]) || (t += "\\"), t += e[n];
758
758
  return t;
759
759
  }
760
760
  function H(e, t, n, r) {
@@ -765,11 +765,11 @@ function H(e, t, n, r) {
765
765
  }
766
766
  function U(e, t, n, r) {
767
767
  e.pattern || e.allOf?.some((e) => e.pattern) ? (e.allOf ||= [], e.pattern && (e.allOf.push({ pattern: e.pattern }), delete e.pattern), e.allOf.push({
768
- pattern: W(t, r),
768
+ pattern: Pt(t, r),
769
769
  ...n && r.errorMessages && { errorMessage: { pattern: n } }
770
- })) : e.pattern = W(t, r);
770
+ })) : e.pattern = Pt(t, r);
771
771
  }
772
- function W(e, t) {
772
+ function Pt(e, t) {
773
773
  if (!t.applyRegexFlags || !e.flags) return e.source;
774
774
  let n = {
775
775
  i: e.flags.includes("i"),
@@ -808,7 +808,7 @@ function W(e, t) {
808
808
  }
809
809
  return i;
810
810
  }
811
- function G(e, t) {
811
+ function Ft(e, t) {
812
812
  let n = {
813
813
  type: "object",
814
814
  additionalProperties: q(e.valueType._def, {
@@ -817,7 +817,7 @@ function G(e, t) {
817
817
  }) ?? t.allowedAdditionalProperties
818
818
  };
819
819
  if (e.keyType?._def.typeName === "ZodString" && e.keyType._def.checks?.length) {
820
- let { type: r, ...i } = At(e.keyType._def, t);
820
+ let { type: r, ...i } = jt(e.keyType._def, t);
821
821
  return {
822
822
  ...n,
823
823
  propertyNames: i
@@ -828,7 +828,7 @@ function G(e, t) {
828
828
  propertyNames: { enum: e.keyType._def.values }
829
829
  };
830
830
  if (e.keyType?._def.typeName === "ZodBranded" && e.keyType._def.type._def.typeName === "ZodString" && e.keyType._def.type._def.checks?.length) {
831
- let { type: r, ...i } = St(e.keyType._def, t);
831
+ let { type: r, ...i } = Ct(e.keyType._def, t);
832
832
  return {
833
833
  ...n,
834
834
  propertyNames: i
@@ -836,8 +836,8 @@ function G(e, t) {
836
836
  }
837
837
  return n;
838
838
  }
839
- function Pt(e, t) {
840
- return t.mapStrategy === "record" ? G(e, t) : {
839
+ function It(e, t) {
840
+ return t.mapStrategy === "record" ? Ft(e, t) : {
841
841
  type: "array",
842
842
  maxItems: 125,
843
843
  items: {
@@ -864,31 +864,31 @@ function Pt(e, t) {
864
864
  }
865
865
  };
866
866
  }
867
- function Ft(e) {
867
+ function Lt(e) {
868
868
  let t = e.values, n = Object.keys(e.values).filter((e) => typeof t[t[e]] != "number").map((e) => t[e]), r = Array.from(new Set(n.map((e) => typeof e)));
869
869
  return {
870
870
  type: r.length === 1 ? r[0] === "string" ? "string" : "number" : ["string", "number"],
871
871
  enum: n
872
872
  };
873
873
  }
874
- function It() {
874
+ function Rt() {
875
875
  return { not: I() };
876
876
  }
877
- function Lt() {
877
+ function zt() {
878
878
  return { type: "null" };
879
879
  }
880
- var Rt = {
880
+ var Bt = {
881
881
  ZodString: "string",
882
882
  ZodNumber: "number",
883
883
  ZodBigInt: "integer",
884
884
  ZodBoolean: "boolean",
885
885
  ZodNull: "null"
886
886
  };
887
- function zt(e, t) {
887
+ function Vt(e, t) {
888
888
  let n = e.options instanceof Map ? Array.from(e.options.values()) : e.options;
889
- if (n.every((e) => e._def.typeName in Rt && (!e._def.checks || !e._def.checks.length))) {
889
+ if (n.every((e) => e._def.typeName in Bt && (!e._def.checks || !e._def.checks.length))) {
890
890
  let e = n.reduce((e, t) => {
891
- let n = Rt[t._def.typeName];
891
+ let n = Bt[t._def.typeName];
892
892
  return n && !e.includes(n) ? [...e, n] : e;
893
893
  }, []);
894
894
  return { type: e.length > 1 ? e : e[0] };
@@ -916,9 +916,9 @@ function zt(e, t) {
916
916
  type: "string",
917
917
  enum: n.reduce((e, t) => [...e, ...t._def.values.filter((t) => !e.includes(t))], [])
918
918
  };
919
- return Bt(e, t);
919
+ return W(e, t);
920
920
  }
921
- var Bt = (e, t) => {
921
+ var W = (e, t) => {
922
922
  let n = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map((e, n) => q(e._def, {
923
923
  ...t,
924
924
  currentPath: [
@@ -929,14 +929,14 @@ var Bt = (e, t) => {
929
929
  })).filter((e) => !!e && (!t.strictUnions || typeof e == "object" && Object.keys(e).length > 0));
930
930
  return n.length ? { anyOf: n } : void 0;
931
931
  };
932
- function Vt(e, t) {
932
+ function G(e, t) {
933
933
  if ([
934
934
  "ZodString",
935
935
  "ZodNumber",
936
936
  "ZodBigInt",
937
937
  "ZodBoolean",
938
938
  "ZodNull"
939
- ].includes(e.innerType._def.typeName) && (!e.innerType._def.checks || !e.innerType._def.checks.length)) return { type: [Rt[e.innerType._def.typeName], "null"] };
939
+ ].includes(e.innerType._def.typeName) && (!e.innerType._def.checks || !e.innerType._def.checks.length)) return { type: [Bt[e.innerType._def.typeName], "null"] };
940
940
  let n = q(e.innerType._def, {
941
941
  ...t,
942
942
  currentPath: [
@@ -947,7 +947,7 @@ function Vt(e, t) {
947
947
  });
948
948
  return n && { anyOf: [n, { type: "null" }] };
949
949
  }
950
- function Ht(e) {
950
+ function K(e) {
951
951
  let t = { type: "number" };
952
952
  if (!e.checks) return t;
953
953
  for (let n of e.checks) switch (n.kind) {
@@ -964,7 +964,7 @@ function Ht(e) {
964
964
  }
965
965
  return t;
966
966
  }
967
- function Ut(e, t) {
967
+ function Ht(e, t) {
968
968
  let n = {
969
969
  type: "object",
970
970
  properties: {}
@@ -972,7 +972,7 @@ function Ut(e, t) {
972
972
  for (let e in i) {
973
973
  let a = i[e];
974
974
  if (a === void 0 || a._def === void 0) continue;
975
- let o = Gt(a), s = q(a._def, {
975
+ let o = Wt(a), s = q(a._def, {
976
976
  ...t,
977
977
  currentPath: [
978
978
  ...t.currentPath,
@@ -988,10 +988,10 @@ function Ut(e, t) {
988
988
  s !== void 0 && (n.properties[e] = s, o || r.push(e));
989
989
  }
990
990
  r.length && (n.required = r);
991
- let a = Wt(e, t);
991
+ let a = Ut(e, t);
992
992
  return a !== void 0 && (n.additionalProperties = a), n;
993
993
  }
994
- function Wt(e, t) {
994
+ function Ut(e, t) {
995
995
  if (e.catchall._def.typeName !== "ZodNever") return q(e.catchall._def, {
996
996
  ...t,
997
997
  currentPath: [...t.currentPath, "additionalProperties"]
@@ -1002,14 +1002,14 @@ function Wt(e, t) {
1002
1002
  case "strip": return t.removeAdditionalStrategy === "strict" ? t.allowedAdditionalProperties : t.rejectedAdditionalProperties;
1003
1003
  }
1004
1004
  }
1005
- function Gt(e) {
1005
+ function Wt(e) {
1006
1006
  try {
1007
1007
  return e.isOptional();
1008
1008
  } catch {
1009
1009
  return !0;
1010
1010
  }
1011
1011
  }
1012
- var Kt = (e, t) => {
1012
+ var Gt = (e, t) => {
1013
1013
  if (t.currentPath.toString() === t.propertyPath?.toString()) return q(e.innerType._def, t);
1014
1014
  let n = q(e.innerType._def, {
1015
1015
  ...t,
@@ -1020,7 +1020,7 @@ var Kt = (e, t) => {
1020
1020
  ]
1021
1021
  });
1022
1022
  return n ? { anyOf: [{ not: I() }, n] } : I();
1023
- }, qt = (e, t) => {
1023
+ }, Kt = (e, t) => {
1024
1024
  if (t.pipeStrategy === "input") return q(e.in._def, t);
1025
1025
  if (t.pipeStrategy === "output") return q(e.out._def, t);
1026
1026
  let n = q(e.in._def, {
@@ -1040,10 +1040,10 @@ var Kt = (e, t) => {
1040
1040
  ]
1041
1041
  })].filter((e) => e !== void 0) };
1042
1042
  };
1043
- function Jt(e, t) {
1043
+ function qt(e, t) {
1044
1044
  return q(e.type._def, t);
1045
1045
  }
1046
- function Yt(e, t) {
1046
+ function Jt(e, t) {
1047
1047
  let n = {
1048
1048
  type: "array",
1049
1049
  uniqueItems: !0,
@@ -1054,7 +1054,7 @@ function Yt(e, t) {
1054
1054
  };
1055
1055
  return e.minSize && (n.minItems = e.minSize.value), e.maxSize && (n.maxItems = e.maxSize.value), n;
1056
1056
  }
1057
- function Xt(e, t) {
1057
+ function Yt(e, t) {
1058
1058
  return e.rest ? {
1059
1059
  type: "array",
1060
1060
  minItems: e.items.length,
@@ -1084,47 +1084,47 @@ function Xt(e, t) {
1084
1084
  })).reduce((e, t) => t === void 0 ? e : [...e, t], [])
1085
1085
  };
1086
1086
  }
1087
- function Zt() {
1087
+ function Xt() {
1088
1088
  return { not: I() };
1089
1089
  }
1090
- function Qt() {
1090
+ function Zt() {
1091
1091
  return I();
1092
1092
  }
1093
- var $t = (e, t) => q(e.innerType._def, t), K = (e, t, n) => {
1093
+ var Qt = (e, t) => q(e.innerType._def, t), $t = (e, t, n) => {
1094
1094
  switch (t) {
1095
- case "ZodString": return At(e, n);
1096
- case "ZodNumber": return Ht(e);
1097
- case "ZodObject": return Ut(e, n);
1095
+ case "ZodString": return jt(e, n);
1096
+ case "ZodNumber": return K(e);
1097
+ case "ZodObject": return Ht(e, n);
1098
1098
  case "ZodBigInt": return xt(e);
1099
- case "ZodBoolean": return L();
1099
+ case "ZodBoolean": return St();
1100
1100
  case "ZodDate": return wt(e, n);
1101
- case "ZodUndefined": return Zt();
1102
- case "ZodNull": return Lt();
1101
+ case "ZodUndefined": return Xt();
1102
+ case "ZodNull": return zt();
1103
1103
  case "ZodArray": return bt(e, n);
1104
1104
  case "ZodUnion":
1105
- case "ZodDiscriminatedUnion": return zt(e, n);
1106
- case "ZodIntersection": return kt(e, n);
1107
- case "ZodTuple": return Xt(e, n);
1108
- case "ZodRecord": return G(e, n);
1109
- case "ZodLiteral": return z(e);
1110
- case "ZodEnum": return Dt(e);
1111
- case "ZodNativeEnum": return Ft(e);
1112
- case "ZodNullable": return Vt(e, n);
1113
- case "ZodOptional": return Kt(e, n);
1114
- case "ZodMap": return Pt(e, n);
1115
- case "ZodSet": return Yt(e, n);
1105
+ case "ZodDiscriminatedUnion": return Vt(e, n);
1106
+ case "ZodIntersection": return R(e, n);
1107
+ case "ZodTuple": return Yt(e, n);
1108
+ case "ZodRecord": return Ft(e, n);
1109
+ case "ZodLiteral": return At(e);
1110
+ case "ZodEnum": return Ot(e);
1111
+ case "ZodNativeEnum": return Lt(e);
1112
+ case "ZodNullable": return G(e, n);
1113
+ case "ZodOptional": return Gt(e, n);
1114
+ case "ZodMap": return It(e, n);
1115
+ case "ZodSet": return Jt(e, n);
1116
1116
  case "ZodLazy": return () => e.getter()._def;
1117
- case "ZodPromise": return Jt(e, n);
1117
+ case "ZodPromise": return qt(e, n);
1118
1118
  case "ZodNaN":
1119
- case "ZodNever": return It();
1120
- case "ZodEffects": return R(e, n);
1119
+ case "ZodNever": return Rt();
1120
+ case "ZodEffects": return Dt(e, n);
1121
1121
  case "ZodAny": return I();
1122
- case "ZodUnknown": return Qt();
1122
+ case "ZodUnknown": return Zt();
1123
1123
  case "ZodDefault": return Et(e, n);
1124
- case "ZodBranded": return St(e, n);
1125
- case "ZodReadonly": return $t(e, n);
1126
- case "ZodCatch": return Ct(e, n);
1127
- case "ZodPipeline": return qt(e, n);
1124
+ case "ZodBranded": return Ct(e, n);
1125
+ case "ZodReadonly": return Qt(e, n);
1126
+ case "ZodCatch": return L(e, n);
1127
+ case "ZodPipeline": return Kt(e, n);
1128
1128
  case "ZodFunction":
1129
1129
  case "ZodVoid":
1130
1130
  case "ZodSymbol": return;
@@ -1141,7 +1141,7 @@ function q(e, t, n = !1) {
1141
1141
  let r = t.seen.get(e);
1142
1142
  if (t.override) {
1143
1143
  let i = t.override?.(e, t, r, n);
1144
- if (i !== _t) return i;
1144
+ if (i !== P) return i;
1145
1145
  }
1146
1146
  if (r && !n) {
1147
1147
  let e = tn(r, t);
@@ -1153,7 +1153,7 @@ function q(e, t, n = !1) {
1153
1153
  jsonSchema: void 0
1154
1154
  };
1155
1155
  t.seen.set(e, i);
1156
- let a = K(e, e.typeName, t), o = typeof a == "function" ? q(a(), t) : a;
1156
+ let a = $t(e, e.typeName, t), o = typeof a == "function" ? q(a(), t) : a;
1157
1157
  if (o && nn(e, t, o), t.postProcess) {
1158
1158
  let n = t.postProcess(o, e, t);
1159
1159
  return i.jsonSchema = o, n;
@@ -1227,7 +1227,7 @@ function sn(e) {
1227
1227
  let t;
1228
1228
  return () => (t ??= e(), t);
1229
1229
  }
1230
- function cn(e, { validate: t } = {}) {
1230
+ function J(e, { validate: t } = {}) {
1231
1231
  return {
1232
1232
  [on]: !0,
1233
1233
  _type: void 0,
@@ -1237,20 +1237,20 @@ function cn(e, { validate: t } = {}) {
1237
1237
  validate: t
1238
1238
  };
1239
1239
  }
1240
- function ln(e) {
1240
+ function cn(e) {
1241
1241
  return typeof e == "object" && !!e && on in e && e[on] === !0 && "jsonSchema" in e && "validate" in e;
1242
1242
  }
1243
- function un(e) {
1244
- return e == null ? cn({
1243
+ function ln(e) {
1244
+ return e == null ? J({
1245
1245
  type: "object",
1246
1246
  properties: {},
1247
1247
  additionalProperties: !1
1248
- }) : ln(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? gn(e) : dn(e) : e();
1248
+ }) : cn(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? hn(e) : un(e) : e();
1249
1249
  }
1250
- function dn(e) {
1251
- return cn(() => {
1252
- if (!fn(e)) throw Error(`Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`);
1253
- return gt(e["~standard"].jsonSchema.input({ target: "draft-07" }));
1250
+ function un(e) {
1251
+ return J(() => {
1252
+ if (!dn(e)) throw Error(`Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`);
1253
+ return vt(e["~standard"].jsonSchema.input({ target: "draft-07" }));
1254
1254
  }, { validate: async (t) => {
1255
1255
  let n = await e["~standard"].validate(t);
1256
1256
  return "value" in n ? {
@@ -1258,19 +1258,19 @@ function dn(e) {
1258
1258
  value: n.value
1259
1259
  } : {
1260
1260
  success: !1,
1261
- error: new D({
1261
+ error: new $e({
1262
1262
  value: t,
1263
1263
  cause: n.issues
1264
1264
  })
1265
1265
  };
1266
1266
  } });
1267
1267
  }
1268
- function fn(e) {
1268
+ function dn(e) {
1269
1269
  return e["~standard"].jsonSchema != null;
1270
1270
  }
1271
- function pn(e, t) {
1271
+ function fn(e, t) {
1272
1272
  let n = t?.useReferences ?? !1;
1273
- return cn(() => an(e, { $refStrategy: n ? "root" : "none" }), { validate: async (t) => {
1273
+ return J(() => an(e, { $refStrategy: n ? "root" : "none" }), { validate: async (t) => {
1274
1274
  let n = await e.safeParseAsync(t);
1275
1275
  return n.success ? {
1276
1276
  success: !0,
@@ -1281,9 +1281,9 @@ function pn(e, t) {
1281
1281
  };
1282
1282
  } });
1283
1283
  }
1284
- function mn(e, r) {
1284
+ function pn(e, r) {
1285
1285
  let i = r?.useReferences ?? !1;
1286
- return cn(() => gt(n(e, {
1286
+ return J(() => vt(n(e, {
1287
1287
  target: "draft-7",
1288
1288
  io: "input",
1289
1289
  reused: i ? "ref" : "inline"
@@ -1298,27 +1298,27 @@ function mn(e, r) {
1298
1298
  };
1299
1299
  } });
1300
1300
  }
1301
- function hn(e) {
1301
+ function mn(e) {
1302
1302
  return "_zod" in e;
1303
1303
  }
1304
- function gn(e, t) {
1305
- return hn(e) ? mn(e, t) : pn(e, t);
1304
+ function hn(e, t) {
1305
+ return mn(e) ? pn(e, t) : fn(e, t);
1306
1306
  }
1307
- async function _n({ value: e, schema: t, context: n }) {
1308
- let r = await vn({
1307
+ async function gn({ value: e, schema: t, context: n }) {
1308
+ let r = await _n({
1309
1309
  value: e,
1310
1310
  schema: t,
1311
1311
  context: n
1312
1312
  });
1313
- if (!r.success) throw D.wrap({
1313
+ if (!r.success) throw $e.wrap({
1314
1314
  value: e,
1315
1315
  cause: r.error,
1316
1316
  context: n
1317
1317
  });
1318
1318
  return r.value;
1319
1319
  }
1320
- async function vn({ value: e, schema: t, context: n }) {
1321
- let r = un(t);
1320
+ async function _n({ value: e, schema: t, context: n }) {
1321
+ let r = ln(t);
1322
1322
  try {
1323
1323
  if (r.validate == null) return {
1324
1324
  success: !0,
@@ -1332,7 +1332,7 @@ async function vn({ value: e, schema: t, context: n }) {
1332
1332
  rawValue: e
1333
1333
  } : {
1334
1334
  success: !1,
1335
- error: D.wrap({
1335
+ error: $e.wrap({
1336
1336
  value: e,
1337
1337
  cause: t.error,
1338
1338
  context: n
@@ -1342,7 +1342,7 @@ async function vn({ value: e, schema: t, context: n }) {
1342
1342
  } catch (t) {
1343
1343
  return {
1344
1344
  success: !1,
1345
- error: D.wrap({
1345
+ error: $e.wrap({
1346
1346
  value: e,
1347
1347
  cause: t,
1348
1348
  context: n
@@ -1351,14 +1351,14 @@ async function vn({ value: e, schema: t, context: n }) {
1351
1351
  };
1352
1352
  }
1353
1353
  }
1354
- async function yn({ text: e, schema: t }) {
1354
+ async function vn({ text: e, schema: t }) {
1355
1355
  try {
1356
- let n = ht(e);
1356
+ let n = _t(e);
1357
1357
  return t == null ? {
1358
1358
  success: !0,
1359
1359
  value: n,
1360
1360
  rawValue: n
1361
- } : await vn({
1361
+ } : await _n({
1362
1362
  value: n,
1363
1363
  schema: t
1364
1364
  });
@@ -1373,23 +1373,23 @@ async function yn({ text: e, schema: t }) {
1373
1373
  };
1374
1374
  }
1375
1375
  }
1376
- function bn({ stream: e, schema: t }) {
1377
- return e.pipeThrough(new TextDecoderStream()).pipeThrough(new st()).pipeThrough(new TransformStream({ async transform({ data: e }, n) {
1378
- e !== "[DONE]" && n.enqueue(await yn({
1376
+ function yn({ stream: e, schema: t }) {
1377
+ return e.pipeThrough(new TextDecoderStream()).pipeThrough(new ct()).pipeThrough(new TransformStream({ async transform({ data: e }, n) {
1378
+ e !== "[DONE]" && n.enqueue(await vn({
1379
1379
  text: e,
1380
1380
  schema: t
1381
1381
  }));
1382
1382
  } }));
1383
1383
  }
1384
- async function xn(e) {
1384
+ async function bn(e) {
1385
1385
  return typeof e == "function" && (e = e()), e;
1386
1386
  }
1387
1387
  new TextDecoder();
1388
1388
  // ../../node_modules/.pnpm/ai@7.0.154_zod@4.6.7/node_modules/ai/dist/index.js
1389
- var J = "AI_InvalidArgumentError", Sn = `vercel.ai.error.${J}`, Cn = Symbol.for(Sn), wn = class extends w {
1389
+ var xn = "AI_InvalidArgumentError", Sn = `vercel.ai.error.${xn}`, Cn = Symbol.for(Sn), wn = class extends w {
1390
1390
  constructor({ parameter: e, value: t, message: n }) {
1391
1391
  super({
1392
- name: J,
1392
+ name: xn,
1393
1393
  message: `Invalid argument for parameter ${e}: ${n}`
1394
1394
  }), this[Cn] = !0, this.parameter = e, this.value = t;
1395
1395
  }
@@ -1449,7 +1449,7 @@ var X = {
1449
1449
  X.string(),
1450
1450
  X.instanceof(Uint8Array),
1451
1451
  X.instanceof(ArrayBuffer),
1452
- X.custom(P, { message: "Must be a Buffer" })
1452
+ X.custom(pt, { message: "Must be a Buffer" })
1453
1453
  ]), jn = X.record(X.string(), X.string()), Mn = X.object({
1454
1454
  type: X.literal("text"),
1455
1455
  text: X.string(),
@@ -1854,11 +1854,11 @@ async function Xn(e) {
1854
1854
  value: void 0,
1855
1855
  state: "undefined-input"
1856
1856
  };
1857
- let t = await yn({ text: e });
1857
+ let t = await vn({ text: e });
1858
1858
  return t.success ? {
1859
1859
  value: t.value,
1860
1860
  state: "successful-parse"
1861
- } : (t = await yn({ text: Yn(e) }), t.success ? {
1861
+ } : (t = await vn({ text: Yn(e) }), t.success ? {
1862
1862
  value: t.value,
1863
1863
  state: "repaired-parse"
1864
1864
  } : {
@@ -1866,13 +1866,13 @@ async function Xn(e) {
1866
1866
  state: "failed-parse"
1867
1867
  });
1868
1868
  }
1869
- N({
1869
+ j({
1870
1870
  prefix: "steer",
1871
1871
  size: 24
1872
- }), new TextEncoder(), new TextEncoder(), N({
1872
+ }), new TextEncoder(), new TextEncoder(), j({
1873
1873
  prefix: "aitxt",
1874
1874
  size: 24
1875
- }), N({
1875
+ }), j({
1876
1876
  prefix: "call",
1877
1877
  size: 24
1878
1878
  }), TransformStream;
@@ -1896,7 +1896,7 @@ var Zn = X.object({
1896
1896
  startIndex: X.number().int().nonnegative().optional(),
1897
1897
  endIndex: X.number().int().nonnegative().optional(),
1898
1898
  citedText: X.string().optional()
1899
- }), Qn = X.record(X.string(), kn.optional()), $n = sn(() => gn(X.union([
1899
+ }), Qn = X.record(X.string(), kn.optional()), $n = sn(() => hn(X.union([
1900
1900
  X.looseObject({
1901
1901
  type: X.literal("text-start"),
1902
1902
  id: X.string(),
@@ -2226,7 +2226,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2226
2226
  async function v(e) {
2227
2227
  if (e != null) {
2228
2228
  let n = r.message.metadata == null ? e : On(r.message.metadata, e);
2229
- t != null && await _n({
2229
+ t != null && await gn({
2230
2230
  value: n,
2231
2231
  schema: t,
2232
2232
  context: {
@@ -2551,7 +2551,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2551
2551
  default: if (er(e)) {
2552
2552
  if (n?.[e.type] != null) {
2553
2553
  let t = r.message.parts.findIndex((t) => "id" in t && "data" in t && t.id === e.id && t.type === e.type), i = t >= 0 ? t : r.message.parts.length;
2554
- await _n({
2554
+ await gn({
2555
2555
  value: e.data,
2556
2556
  schema: n[e.type],
2557
2557
  context: {
@@ -2600,28 +2600,28 @@ function cr() {
2600
2600
  reject: t
2601
2601
  };
2602
2602
  }
2603
- N({
2603
+ j({
2604
2604
  prefix: "aitxt",
2605
2605
  size: 24
2606
- }), N({
2606
+ }), j({
2607
2607
  prefix: "call",
2608
2608
  size: 24
2609
- }), N({
2609
+ }), j({
2610
2610
  prefix: "aitxt",
2611
2611
  size: 24
2612
- }), N({
2612
+ }), j({
2613
2613
  prefix: "call",
2614
2614
  size: 24
2615
- }), X.record(X.string(), kn.optional()), X.record(X.string(), X.string()), N({
2615
+ }), X.record(X.string(), kn.optional()), X.record(X.string(), X.string()), j({
2616
2616
  prefix: "call",
2617
2617
  size: 24
2618
- }), N({
2618
+ }), j({
2619
2619
  prefix: "call",
2620
2620
  size: 24
2621
- }), new TextEncoder(), N({
2621
+ }), new TextEncoder(), j({
2622
2622
  prefix: "call",
2623
2623
  size: 24
2624
- }), N({
2624
+ }), j({
2625
2625
  prefix: "aiobj",
2626
2626
  size: 24
2627
2627
  });
@@ -2657,10 +2657,10 @@ var { atob: lr } = globalThis, ur = class {
2657
2657
  });
2658
2658
  }
2659
2659
  };
2660
- N({
2660
+ j({
2661
2661
  prefix: "aiobj",
2662
2662
  size: 24
2663
- }), N({
2663
+ }), j({
2664
2664
  prefix: "call",
2665
2665
  size: 24
2666
2666
  }), X.object({
@@ -2680,13 +2680,13 @@ N({
2680
2680
  description: X.string().optional(),
2681
2681
  parameters: X.record(X.string(), X.unknown())
2682
2682
  })).optional()
2683
- }), N({
2683
+ }), j({
2684
2684
  prefix: "call",
2685
2685
  size: 24
2686
- }), N({
2686
+ }), j({
2687
2687
  prefix: "call",
2688
2688
  size: 24
2689
- }), N({
2689
+ }), j({
2690
2690
  prefix: "call",
2691
2691
  size: 24
2692
2692
  });
@@ -2702,7 +2702,7 @@ async function dr({ response: e, url: t, fallbackMessage: n }) {
2702
2702
  }
2703
2703
  async function fr(e) {
2704
2704
  if (e == null) return [];
2705
- if (!globalThis.FileList || !(e instanceof globalThis.FileList)) throw new O({
2705
+ if (!globalThis.FileList || !(e instanceof globalThis.FileList)) throw new nt({
2706
2706
  functionality: "FileList",
2707
2707
  message: "FileList is not supported in the current environment"
2708
2708
  });
@@ -2730,9 +2730,9 @@ var mr = class {
2730
2730
  this.api = e, this.credentials = t, this.headers = n, this.body = r, this.fetch = i, this.prepareSendMessagesRequest = a, this.prepareReconnectToStreamRequest = o;
2731
2731
  }
2732
2732
  async sendMessages({ abortSignal: e, ...t }) {
2733
- let n = await xn(this.body), r = await xn(this.headers), i = await xn(this.credentials), a = {
2734
- ...M(r),
2735
- ...M(t.headers)
2733
+ let n = await bn(this.body), r = await bn(this.headers), i = await bn(this.credentials), a = {
2734
+ ...dt(r),
2735
+ ...dt(t.headers)
2736
2736
  }, o = await this.prepareSendMessagesRequest?.({
2737
2737
  api: this.api,
2738
2738
  id: t.chatId,
@@ -2746,7 +2746,7 @@ var mr = class {
2746
2746
  requestMetadata: t.metadata,
2747
2747
  trigger: t.trigger,
2748
2748
  messageId: t.messageId
2749
- }), s = o?.api ?? this.api, c = o?.headers === void 0 ? a : M(o.headers), l = o?.body === void 0 ? {
2749
+ }), s = o?.api ?? this.api, c = o?.headers === void 0 ? a : dt(o.headers), l = o?.body === void 0 ? {
2750
2750
  ...n,
2751
2751
  ...t.body,
2752
2752
  id: t.chatId,
@@ -2768,13 +2768,13 @@ var mr = class {
2768
2768
  url: s,
2769
2769
  fallbackMessage: "Failed to fetch the chat response."
2770
2770
  });
2771
- if (!d.body) throw new E({ message: "The response body is empty." });
2771
+ if (!d.body) throw new Ve({ message: "The response body is empty." });
2772
2772
  return this.processResponseStream(d.body);
2773
2773
  }
2774
2774
  async reconnectToStream(e) {
2775
- let t = await xn(this.body), n = await xn(this.headers), r = await xn(this.credentials), i = {
2776
- ...M(n),
2777
- ...M(e.headers)
2775
+ let t = await bn(this.body), n = await bn(this.headers), r = await bn(this.credentials), i = {
2776
+ ...dt(n),
2777
+ ...dt(e.headers)
2778
2778
  }, a = await this.prepareReconnectToStreamRequest?.({
2779
2779
  api: this.api,
2780
2780
  id: e.chatId,
@@ -2794,7 +2794,7 @@ var mr = class {
2794
2794
  });
2795
2795
  o = pr(this.api, `/${encodeURIComponent(e.chatId)}/stream`);
2796
2796
  }
2797
- let s = a?.headers === void 0 ? i : M(a.headers), c = a?.credentials ?? r, l = await (this.fetch ?? globalThis.fetch)(o, {
2797
+ let s = a?.headers === void 0 ? i : dt(a.headers), c = a?.credentials ?? r, l = await (this.fetch ?? globalThis.fetch)(o, {
2798
2798
  method: "GET",
2799
2799
  headers: s,
2800
2800
  credentials: c,
@@ -2806,7 +2806,7 @@ var mr = class {
2806
2806
  url: o,
2807
2807
  fallbackMessage: "Failed to fetch the chat response."
2808
2808
  });
2809
- if (!l.body) throw new E({ message: "The response body is empty." });
2809
+ if (!l.body) throw new Ve({ message: "The response body is empty." });
2810
2810
  return this.processResponseStream(l.body);
2811
2811
  }
2812
2812
  }, hr = class extends mr {
@@ -2814,7 +2814,7 @@ var mr = class {
2814
2814
  super(t), this.resumeStreamIsReplay = e;
2815
2815
  }
2816
2816
  processResponseStream(e) {
2817
- return bn({
2817
+ return yn({
2818
2818
  stream: e,
2819
2819
  schema: $n
2820
2820
  }).pipeThrough(new TransformStream({ async transform(e, t) {
@@ -2826,7 +2826,7 @@ var mr = class {
2826
2826
  get id() {
2827
2827
  return this._id ??= this.generateId();
2828
2828
  }
2829
- constructor({ generateId: e = ut, id: t, transport: n = new hr(), messageMetadataSchema: r, dataPartSchemas: i, state: a, onError: o, onToolCall: s, onFinish: c, onData: l, sendAutomaticallyWhen: u }) {
2829
+ constructor({ generateId: e = ft, id: t, transport: n = new hr(), messageMetadataSchema: r, dataPartSchemas: i, state: a, onError: o, onToolCall: s, onFinish: c, onData: l, sendAutomaticallyWhen: u }) {
2830
2830
  this.pendingMessagePreparations = /* @__PURE__ */ new Set(), this.interruptedMessageIds = /* @__PURE__ */ new Set(), this.activeResponse = void 0, this.activeResumeRequest = void 0, this.resumableStreamState = void 0, this.jobExecutor = new ur(), this.activeStopCount = 0, this.stopGeneration = 0, this.sendMessage = async (e, t) => {
2831
2831
  if (e == null) {
2832
2832
  let e = this.pendingApprovalMessageId;
@@ -3646,52 +3646,52 @@ function Gr(e) {
3646
3646
  };
3647
3647
  }
3648
3648
  // ../../packages/composable/src/chatbot/useChatbotStore.ts
3649
- var Kr = "voice-", qr = (e) => e?.role === "assistant" && e.parts.some((e) => e.state === "approval-requested"), Jr = (e) => e.replace(/\s+/g, " ").trim().toLowerCase(), Yr = (e) => Jr(e.parts.filter((e) => e.type === "text").map((e) => "text" in e ? e.text : "").join(" ")), Xr = 8, Zr = (e, t) => {
3649
+ var Kr = "voice-", qr = 300, Jr = (e) => e?.role === "assistant" && e.parts.some((e) => e.state === "approval-requested"), Yr = (e) => e.replace(/\s+/g, " ").trim().toLowerCase(), Xr = (e) => Yr(e.parts.filter((e) => e.type === "text").map((e) => "text" in e ? e.text : "").join(" ")), Zr = 8, Qr = (e, t) => {
3650
3650
  let n = new Set(t.map((e) => e.id)), r = e.filter((e) => e.role === "user" && !n.has(e.id)).map((e) => ({
3651
- text: Yr(e),
3651
+ text: Xr(e),
3652
3652
  taken: !1
3653
3653
  }));
3654
3654
  return t.filter((e) => {
3655
3655
  if (!e.id.startsWith("voice-") || e.role !== "user") return !1;
3656
- let t = Yr(e), n = r.find((e) => !e.taken && e.text.length > 0 && (e.text === t || e.text.length >= Xr && t.endsWith(e.text)));
3656
+ let t = Xr(e), n = r.find((e) => !e.taken && e.text.length > 0 && (e.text === t || e.text.length >= Zr && t.endsWith(e.text)));
3657
3657
  return !n || (n.taken = !0, !1);
3658
3658
  });
3659
- }, Qr = 12e4, $r = 1e3, ei = 5e3, ti = 100, ni = 3e4, ri = 5e3, ii = 250, ai = 1e3, oi = "\n\n", si = (e) => {
3659
+ }, $r = 12e4, ei = 1e3, ti = 5e3, ni = 100, ri = 3e4, ii = 5e3, ai = 250, oi = 1e3, si = "\n\n", ci = (e) => {
3660
3660
  let t = e.type ?? "";
3661
3661
  return t === "dynamic-tool" ? e.toolName ?? "" : t.startsWith("tool-") ? t.slice(5) : "";
3662
- }, ci = (e) => e?.role === "assistant" && e.parts.some((e) => b(si(e)) && !e.providerExecuted && !oe.has(e.state ?? "")), li = ({ messages: e }) => {
3662
+ }, li = (e) => e?.role === "assistant" && e.parts.some((e) => b(ci(e)) && !e.providerExecuted && !oe.has(e.state ?? "")), ui = ({ messages: e }) => {
3663
3663
  let t = e[e.length - 1];
3664
3664
  if (!t || t.role !== "assistant") return !1;
3665
- let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter((e) => !e.providerExecuted && (b(si(e)) || ie(e)));
3665
+ let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter((e) => !e.providerExecuted && (b(ci(e)) || ie(e)));
3666
3666
  return r.length > 0 && r.every((e) => oe.has(e.state ?? ""));
3667
3667
  };
3668
- function ui(e) {
3668
+ function di(e) {
3669
3669
  return Te(`chatbot-${e}`, () => {
3670
- let { t, te: n, locale: r } = Se({ useScope: "global" }), i = S(""), a = S(), o = S(e), s = S(), c = S(), l = S(), u = S(), d = S(), f = S(), p = S(), m = S(), h = S(), g = S(), _ = S(), v = S(), y = S(), b = S(), te = S(), oe = S(), pe = ve(), me = S(0), ye = S(), be = ve(), Te = ve(), ke = S(), Ne = S({}), Pe = S(!1), w = S(0), Fe = S(), Ie = S(!1), Le = we(), Re = x(() => {
3670
+ let { t, te: n, locale: r } = Se({ useScope: "global" }), i = S(""), a = S(), o = S(e), s = S(), c = S(), l = S(), u = S(), d = S(), f = S(), p = S(), m = S(), h = S(), g = S(), _ = S(), v = S(), y = S(), b = S(), te = S(), oe = S(), pe = ve(), me = S(0), ye = S(0), be = S(), Te = ve(), ke = ve(), Ne = S(), Pe = S({}), w = S(!1), Fe = S(0), Ie = S(), Le = S(!1), Re = we(), ze = x(() => {
3671
3671
  let e = u.value?.theme;
3672
- return e && e !== "auto" || (e = Fe.value), e ? e === "dark" : Le.value;
3673
- }), T = x(() => c.value === "reasoning"), ze = x(() => T.value ? g.value?.filter((e) => ![
3672
+ return e && e !== "auto" || (e = Ie.value), e ? e === "dark" : Re.value;
3673
+ }), T = x(() => c.value === "reasoning"), Be = x(() => T.value ? g.value?.filter((e) => ![
3674
3674
  "upvote",
3675
3675
  "downvote",
3676
3676
  "feedback"
3677
- ].includes(e)) : g.value), Be = fe(x(() => `${o.value}-chatId`), null);
3677
+ ].includes(e)) : g.value), Ve = fe(x(() => `${o.value}-chatId`), null);
3678
3678
  xe(() => {
3679
- Be.value ||= ut();
3679
+ Ve.value ||= ft();
3680
3680
  });
3681
3681
  let E = x({
3682
- get: () => Be.value,
3682
+ get: () => Ve.value,
3683
3683
  set: (e) => {
3684
- Be.value = e;
3684
+ Ve.value = e;
3685
3685
  }
3686
- }), Ve = de(x(() => `${o.value}-pageAccessOff`), !1), He = x(() => Ve.value ? [] : be.value ?? []), Ue = () => Ve.value ? [] : Te.value?.() ?? [], We = x(() => !!(ye.value && be.value?.length)), Ge = fe(x(() => `${o.value}-pageNotice`), null), Ke = x(() => {
3687
- let e = ye.value?.level;
3688
- return e && e !== ee.Off && He.value.length && !re(Ge.value ?? void 0, e) ? e : void 0;
3686
+ }), He = de(x(() => `${o.value}-pageAccessOff`), !1), Ue = x(() => He.value ? [] : Te.value ?? []), We = () => He.value ? [] : ke.value?.() ?? [], Ge = x(() => !!(be.value && Te.value?.length)), Ke = fe(x(() => `${o.value}-pageNotice`), null), qe = x(() => {
3687
+ let e = be.value?.level;
3688
+ return e && e !== ee.Off && Ue.value.length && !re(Ke.value ?? void 0, e) ? e : void 0;
3689
3689
  });
3690
- function qe() {
3691
- Ge.value = ye.value?.level ?? null;
3690
+ function Je() {
3691
+ Ke.value = be.value?.level ?? null;
3692
3692
  }
3693
- let Je = S(), Ye = S(!1), Xe = x(() => Je.value?.message?.toLowerCase().includes("conversation-blocked") ?? !1);
3694
- function Ze(e) {
3693
+ let Ye = S(), Xe = S(!1), Ze = x(() => Ye.value?.message?.toLowerCase().includes("conversation-blocked") ?? !1);
3694
+ function Qe(e) {
3695
3695
  try {
3696
3696
  let t = JSON.parse(e.message);
3697
3697
  return t.status === 404 || t.type?.includes("entity-not-found");
@@ -3699,31 +3699,31 @@ function ui(e) {
3699
3699
  return !1;
3700
3700
  }
3701
3701
  }
3702
- function Qe(e) {
3703
- if (Ze(e)) {
3704
- let e = F.value.messages.filter((e) => e.role === "user"), t = e[e.length - 1], n = t ? ue(t) : void 0;
3705
- E.value = ut(), Je.value = void 0, he(() => {
3706
- F.value.clearError(), n && F.value.sendMessage({ text: n });
3702
+ function $e(e) {
3703
+ if (Qe(e)) {
3704
+ let e = L.value.messages.filter((e) => e.role === "user"), t = e[e.length - 1], n = t ? ue(t) : void 0;
3705
+ E.value = ft(), Ye.value = void 0, he(() => {
3706
+ L.value.clearError(), n && L.value.sendMessage({ text: n });
3707
3707
  });
3708
- } else ce.error(e), Je.value = e, Xe.value && (Ye.value = !0);
3708
+ } else ce.error(e), Ye.value = e, Ze.value && (Xe.value = !0);
3709
3709
  }
3710
3710
  let D = x(() => se({
3711
3711
  baseUrl: i.value,
3712
3712
  basePath: a.value,
3713
3713
  headers: () => p.value
3714
- })), $e = S(null), et = () => ({
3714
+ })), et = S(null), tt = () => ({
3715
3715
  ...Ee(),
3716
- ...$e.value ?? {}
3717
- }), tt = () => {
3718
- let e = w.value;
3716
+ ...et.value ?? {}
3717
+ }), nt = () => {
3718
+ let e = Fe.value;
3719
3719
  return new Promise((t) => {
3720
3720
  let n = setTimeout(() => {
3721
3721
  r(), t(!1);
3722
- }, 3e4), r = C(() => [w.value, F.value.status], ([i, a]) => {
3722
+ }, 3e4), r = C(() => [Fe.value, L.value.status], ([i, a]) => {
3723
3723
  i > e && a === "streaming" && (clearTimeout(n), r(), t(!0));
3724
3724
  });
3725
3725
  });
3726
- }, O = ve(), nt = (e, t) => new Promise((n) => {
3726
+ }, O = ve(), rt = (e, t) => new Promise((n) => {
3727
3727
  O.value?.answer(!1), O.value = {
3728
3728
  toolCallId: e.toolCallId,
3729
3729
  question: t?.question,
@@ -3733,63 +3733,126 @@ function ui(e) {
3733
3733
  }
3734
3734
  };
3735
3735
  });
3736
- function rt(e) {
3736
+ function it(e) {
3737
3737
  O.value?.answer(e);
3738
3738
  }
3739
- let it = Me({
3739
+ let k = ({ forms: e }) => be.value && Ue.value.length ? {
3740
+ version: 1,
3741
+ features: [...ne],
3742
+ forms: e ? We().map(({ name: e, description: t, inputSchema: n, annotations: r }) => ({
3743
+ name: e,
3744
+ description: t,
3745
+ inputSchema: n,
3746
+ annotations: r
3747
+ })) : []
3748
+ } : void 0, at = (e) => {
3749
+ if (e?.provider !== "page") {
3750
+ Ne.value = void 0;
3751
+ return;
3752
+ }
3753
+ let t = [...Ue.value, ...We()].find((t) => t.name === e.toolName), n;
3754
+ try {
3755
+ n = t?.describe?.(e.input);
3756
+ } catch {
3757
+ n = void 0;
3758
+ }
3759
+ n && (Pe.value = {
3760
+ ...Pe.value,
3761
+ [e.toolCallId]: n
3762
+ }), e.readOnly ? Ne.value = void 0 : (Ne.value = { title: n ?? t?.annotations?.title ?? e.toolName }, w.value = !0);
3763
+ }, ot = Me({
3740
3764
  registry: () => [
3741
3765
  ...(pe.value ?? []).filter((e) => !ae(e.name)),
3742
- ...He.value,
3743
- ...Ue()
3766
+ ...Ue.value,
3767
+ ...We()
3744
3768
  ],
3745
3769
  capability: () => oe.value,
3746
- addToolOutput: (e) => void F.value.addToolOutput(e),
3747
- confirm: nt,
3748
- waitForResume: tt,
3770
+ addToolOutput: (e) => void L.value.addToolOutput(e),
3771
+ confirm: rt,
3772
+ waitForResume: nt,
3749
3773
  onPendingChange: (e) => {
3750
3774
  me.value = e;
3751
3775
  },
3752
- onActivity: (e) => {
3753
- if (e?.provider !== "page") {
3754
- ke.value = void 0;
3755
- return;
3756
- }
3757
- let t = [...He.value, ...Ue()].find((t) => t.name === e.toolName), n;
3758
- try {
3759
- n = t?.describe?.(e.input);
3760
- } catch {
3761
- n = void 0;
3762
- }
3763
- n && (Ne.value = {
3764
- ...Ne.value,
3765
- [e.toolCallId]: n
3766
- }), e.readOnly ? ke.value = void 0 : (ke.value = { title: n ?? t?.annotations?.title ?? e.toolName }, Pe.value = !0);
3767
- }
3776
+ onActivity: at
3777
+ }), A = /* @__PURE__ */ new Map(), st = 0, ct = (e, t) => {
3778
+ let n = A.get(e);
3779
+ A.delete(e), n?.(JSON.stringify(t));
3780
+ }, lt = Me({
3781
+ registry: () => Ue.value,
3782
+ capability: () => oe.value,
3783
+ addToolOutput: (e) => ct(e.toolCallId, "output" in e ? e.output : {
3784
+ content: [{
3785
+ type: "text",
3786
+ text: e.errorText
3787
+ }],
3788
+ isError: !0
3789
+ }),
3790
+ confirm: async (e, t) => {
3791
+ for (; O.value;) await new Promise((e) => {
3792
+ let t = C(O, (n) => {
3793
+ n || (t(), e());
3794
+ });
3795
+ });
3796
+ return A.has(e.toolCallId) ? rt(e, t) : !1;
3797
+ },
3798
+ waitForResume: () => new Promise((e) => setTimeout(() => e(!0), qr)),
3799
+ onPendingChange: (e) => {
3800
+ ye.value = e;
3801
+ },
3802
+ onActivity: at
3768
3803
  });
3769
- async function k() {
3770
- A(), ke.value = void 0, Pe.value = !1, G.value = "", await F.value.stop();
3804
+ function ut() {
3805
+ let e = k({ forms: !1 });
3806
+ if (e) return {
3807
+ declaration: e,
3808
+ clientTools: Object.fromEntries(Ue.value.map((e) => [e.name, (t) => new Promise((n) => {
3809
+ st += 1;
3810
+ let r = `page-call-${st}`;
3811
+ A.set(r, n), lt.enqueue({
3812
+ toolCallId: r,
3813
+ toolName: e.name,
3814
+ input: t ?? {},
3815
+ messageId: wt()?.id ?? "",
3816
+ readOnly: e.annotations?.readOnlyHint === !0,
3817
+ provider: "page"
3818
+ });
3819
+ })]))
3820
+ };
3821
+ }
3822
+ function dt() {
3823
+ lt.cancelAll(), O.value && A.has(O.value.toolCallId) && O.value.answer(!1);
3824
+ for (let e of [...A.keys()]) ct(e, {
3825
+ content: [{
3826
+ type: "text",
3827
+ text: "Stopped by the user."
3828
+ }],
3829
+ isError: !0
3830
+ });
3771
3831
  }
3772
- function A() {
3773
- it.cancelAll(), O.value?.answer(!1);
3832
+ async function j() {
3833
+ pt(), dt(), Ne.value = void 0, w.value = !1, K.value = "", await L.value.stop();
3774
3834
  }
3775
- async function at(e) {
3776
- Ve.value = e, e && await k();
3835
+ function pt() {
3836
+ ot.cancelAll(), O.value && !A.has(O.value.toolCallId) && O.value.answer(!1);
3777
3837
  }
3778
- C(E, () => A(), { flush: "sync" });
3779
- let ot = !1, j, st = S(), ct, lt = S([]), M = S([]), N = S([]), P = S({}), dt = /* @__PURE__ */ new Map(), ft = /* @__PURE__ */ new Set();
3780
- function pt(e, t, n) {
3781
- M.value.includes(e) || (M.value = [...M.value, e]), dt.set(e, Date.now()), n ? ft.add(e) : ft.delete(e), t && (P.value = {
3782
- ...P.value,
3838
+ async function mt(e) {
3839
+ He.value = e, e && await j();
3840
+ }
3841
+ C(E, () => pt(), { flush: "sync" });
3842
+ let ht = !1, M, gt = S(), _t, vt = S([]), N = S([]), P = S([]), F = S({}), yt = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Set();
3843
+ function bt(e, t, n) {
3844
+ N.value.includes(e) || (N.value = [...N.value, e]), yt.set(e, Date.now()), n ? I.add(e) : I.delete(e), t && (F.value = {
3845
+ ...F.value,
3783
3846
  [e]: t
3784
- }), J || wn();
3847
+ }), X || An();
3785
3848
  }
3786
- function mt(e) {
3787
- P.value = Object.fromEntries(Object.entries(P.value).filter(([t]) => t !== e));
3849
+ function xt(e) {
3850
+ F.value = Object.fromEntries(Object.entries(F.value).filter(([t]) => t !== e));
3788
3851
  }
3789
- function ht(e) {
3790
- dt.delete(e), M.value = M.value.filter((t) => t !== e), N.value = N.value.filter((t) => t !== e), mt(e);
3852
+ function St(e) {
3853
+ yt.delete(e), N.value = N.value.filter((t) => t !== e), P.value = P.value.filter((t) => t !== e), xt(e);
3791
3854
  }
3792
- let gt = Gr(() => ({
3855
+ let Ct = Gr(() => ({
3793
3856
  id: E.value,
3794
3857
  transport: new hr({
3795
3858
  api: D.value.getChatEndpoint(o.value, T.value ? "reasoning" : "chat"),
@@ -3808,68 +3871,59 @@ function ui(e) {
3808
3871
  reasoning: d.value?.reasoning,
3809
3872
  webSearch: f.value?.webSearch,
3810
3873
  smoothStream: u.value?.smoothStream,
3811
- deviceContext: et(),
3874
+ deviceContext: tt(),
3812
3875
  externalContext: te.value,
3813
3876
  disabledTools: f.value?.disabled,
3814
3877
  fallbackModels: y.value,
3815
3878
  gatewayOptions: b.value,
3816
3879
  hostTools: je(pe.value, oe.value),
3817
- pageTools: ye.value && He.value.length ? {
3818
- version: 1,
3819
- features: [...ne],
3820
- forms: Ue().map(({ name: e, description: t, inputSchema: n, annotations: r }) => ({
3821
- name: e,
3822
- description: t,
3823
- inputSchema: n,
3824
- annotations: r
3825
- }))
3826
- } : void 0
3880
+ pageTools: k({ forms: !0 })
3827
3881
  } }),
3828
3882
  credentials: "include",
3829
3883
  headers: () => p.value ?? {}
3830
3884
  }),
3831
- sendAutomaticallyWhen: (e) => li(e) || _r(e),
3885
+ sendAutomaticallyWhen: (e) => ui(e) || _r(e),
3832
3886
  onError: (e) => {
3833
- ot ? ce.warn(e) : Qe(e);
3887
+ ht ? ce.warn(e) : $e(e);
3834
3888
  },
3835
3889
  onToolCall: ({ toolCall: e }) => {
3836
- if (!Ae(e) || ot) return;
3890
+ if (!Ae(e) || ht) return;
3837
3891
  let t = e;
3838
- it.enqueue({
3892
+ ot.enqueue({
3839
3893
  toolCallId: t.toolCallId,
3840
3894
  toolName: t.toolName,
3841
3895
  input: t.input,
3842
- messageId: _t()?.id ?? "",
3896
+ messageId: wt()?.id ?? "",
3843
3897
  readOnly: t.toolMetadata?.readOnly === !0,
3844
3898
  provider: t.toolMetadata?.provider === "page" ? "page" : "app"
3845
3899
  });
3846
3900
  },
3847
3901
  onData: (e) => {
3848
- e.type === "data-turnStream" ? ct = e.data.streamId : e.type === "data-audioTranscripts" && (F.value.messages = le(F.value.messages, e.data));
3902
+ e.type === "data-turnStream" ? _t = e.data.streamId : e.type === "data-audioTranscripts" && (L.value.messages = le(L.value.messages, e.data));
3849
3903
  },
3850
3904
  onFinish: () => {
3851
3905
  let e = E.value;
3852
- !T.value && !L.value.some((t) => t.id === e) && Ut(o.value);
3906
+ !T.value && !R.value.some((t) => t.id === e) && Zt(o.value);
3853
3907
  }
3854
- })), F = x(() => _e(gt)), _t = () => F.value.messages[F.value.messages.length - 1];
3908
+ })), L = x(() => _e(Ct)), wt = () => L.value.messages[L.value.messages.length - 1];
3855
3909
  C(E, (e, t) => {
3856
- if (t && !T.value && (K() || j?.chatId === t)) {
3857
- let e = F.value.messages.filter((e) => e.role === "user"), n = e[e.length - 1];
3858
- pt(t, n ? ue(n) ?? "" : "", F.value.status === "streaming" || j?.chatId === t);
3910
+ if (t && !T.value && (J() || M?.chatId === t)) {
3911
+ let e = L.value.messages.filter((e) => e.role === "user"), n = e[e.length - 1];
3912
+ bt(t, n ? ue(n) ?? "" : "", L.value.status === "streaming" || M?.chatId === t);
3859
3913
  }
3860
- ht(e), ct = void 0, clearTimeout(vn), _n.value = !1, F.value.stop();
3914
+ St(e), _t = void 0, clearTimeout(En), Tn.value = !1, L.value.stop();
3861
3915
  }, { flush: "sync" });
3862
- let vt = x(() => {
3916
+ let Tt = x(() => {
3863
3917
  let e = u.value?.initialMessage;
3864
3918
  return e?.[r.value] ? e[r.value] : n("message.defaultAgentWelcome") ? t("message.defaultAgentWelcome") : "";
3865
- }), yt = ut(), I = x(() => ({
3866
- id: yt,
3919
+ }), Et = ft(), Dt = x(() => ({
3920
+ id: Et,
3867
3921
  role: "assistant",
3868
3922
  parts: [{
3869
3923
  type: "text",
3870
- text: vt.value
3924
+ text: Tt.value
3871
3925
  }]
3872
- })), bt = x(() => {
3926
+ })), Ot = x(() => {
3873
3927
  let e = (e) => e.map((e) => e.role !== "user" || !e.parts.some((e) => e.type === "file") ? e : {
3874
3928
  ...e,
3875
3929
  parts: e.parts.map((e) => {
@@ -3887,152 +3941,152 @@ function ui(e) {
3887
3941
  url: D.value.appendAuthToken(t.url)
3888
3942
  };
3889
3943
  })
3890
- }), t = F.value.id === E.value ? F.value.messages : [];
3891
- return T.value ? e(t) : !Ie.value && t[0]?.role !== "assistant" ? [I.value, ...e(t)] : e(t);
3892
- }), xt = x(() => {
3944
+ }), t = L.value.id === E.value ? L.value.messages : [];
3945
+ return T.value ? e(t) : !Le.value && t[0]?.role !== "assistant" ? [Dt.value, ...e(t)] : e(t);
3946
+ }), kt = x(() => {
3893
3947
  let e = u.value?.messagePlaceholder;
3894
3948
  return e?.[r.value] ? e[r.value] : n("placeholder.askAnything") ? t("placeholder.askAnything") : "";
3895
- }), L = S([]), St = S(!1), Ct = S(1), wt = S(!1), Tt = S(!1), Et, R = S([]), Dt = S(!1), Ot = S("chat"), kt = S(0), z = S([]), B = S(), V = S(!1), At = S(!1), jt = S(), Mt = S(!1), Nt = S(!1), H = S(), U = S(""), W = S([]), G = S(""), Pt = S(0), Ft = de(x(() => `${o.value}-queue`), {}), It = x(() => Ft.value[E.value] ?? []), Lt = x(() => !T.value);
3896
- function Rt(e, t) {
3897
- let n = Object.fromEntries(Object.entries(Ft.value).filter(([t]) => t !== e));
3898
- Ft.value = t.length > 0 ? {
3949
+ }), R = S([]), At = S(!1), z = S(1), B = S(!1), jt = S(!1), Mt, V = S([]), Nt = S(!1), H = S("chat"), U = S(0), Pt = S([]), Ft = S(), It = S(!1), Lt = S(!1), Rt = S(), zt = S(!1), Bt = S(!1), Vt = S(), W = S(""), G = S([]), K = S(""), Ht = S(0), Ut = de(x(() => `${o.value}-queue`), {}), Wt = x(() => Ut.value[E.value] ?? []), Gt = x(() => !T.value);
3950
+ function Kt(e, t) {
3951
+ let n = Object.fromEntries(Object.entries(Ut.value).filter(([t]) => t !== e));
3952
+ Ut.value = t.length > 0 ? {
3899
3953
  ...n,
3900
3954
  [e]: t
3901
3955
  } : n;
3902
3956
  }
3903
- function zt(e) {
3904
- let t = (Ft.value[e] ?? []).join(oi);
3905
- return Rt(e, []), t;
3957
+ function qt(e) {
3958
+ let t = (Ut.value[e] ?? []).join(si);
3959
+ return Kt(e, []), t;
3906
3960
  }
3907
- function Bt(e) {
3908
- e && (U.value = U.value ? `${U.value}${oi}${e}` : e);
3961
+ function Jt(e) {
3962
+ e && (W.value = W.value ? `${W.value}${si}${e}` : e);
3909
3963
  }
3910
- function Vt(e) {
3911
- Rt(E.value, It.value.filter((t, n) => n !== e));
3964
+ function Yt(e) {
3965
+ Kt(E.value, Wt.value.filter((t, n) => n !== e));
3912
3966
  }
3913
- function Ht(e) {
3914
- let t = It.value[e];
3915
- Vt(e), Bt(t ?? "");
3967
+ function Xt(e) {
3968
+ let t = Wt.value[e];
3969
+ Yt(e), Jt(t ?? "");
3916
3970
  }
3917
- async function Ut(e) {
3918
- if (T.value) L.value = [];
3971
+ async function Zt(e) {
3972
+ if (T.value) R.value = [];
3919
3973
  else {
3920
- St.value = !0;
3974
+ At.value = !0;
3921
3975
  try {
3922
- let t = await D.value.getConversations(e, l.value), n = new Set(t.map((e) => e.id)), r = M.value.filter((e) => !n.has(e) && P.value[e]).map((t) => ({
3976
+ let t = await D.value.getConversations(e, l.value), n = new Set(t.map((e) => e.id)), r = N.value.filter((e) => !n.has(e) && F.value[e]).map((t) => ({
3923
3977
  id: t,
3924
3978
  agentId: e,
3925
- title: P.value[t],
3979
+ title: F.value[t],
3926
3980
  summary: null,
3927
3981
  messages: [],
3928
3982
  lastMessageAt: /* @__PURE__ */ new Date()
3929
3983
  })), i = `${e}:${l.value ?? ""}`;
3930
- i !== Et && (Ct.value = 1);
3931
- let a = new Set(r.map((e) => e.id)), o = Ct.value > 1 ? L.value.filter((e) => !n.has(e.id) && !a.has(e.id)) : [];
3932
- L.value = [
3984
+ i !== Mt && (z.value = 1);
3985
+ let a = new Set(r.map((e) => e.id)), o = z.value > 1 ? R.value.filter((e) => !n.has(e.id) && !a.has(e.id)) : [];
3986
+ R.value = [
3933
3987
  ...r,
3934
3988
  ...t,
3935
3989
  ...o
3936
- ], Et = i, Ct.value === 1 && (wt.value = t.length >= 100);
3990
+ ], Mt = i, z.value === 1 && (B.value = t.length >= 100);
3937
3991
  } catch {
3938
- L.value = [], Ct.value = 1, Et = void 0, wt.value = !1;
3992
+ R.value = [], z.value = 1, Mt = void 0, B.value = !1;
3939
3993
  return;
3940
3994
  } finally {
3941
- St.value = !1;
3995
+ At.value = !1;
3942
3996
  }
3943
- Tn([.../* @__PURE__ */ new Set([...bn(), ...L.value.map((e) => e.id)])]);
3997
+ jn([.../* @__PURE__ */ new Set([...Y(), ...R.value.map((e) => e.id)])]);
3944
3998
  }
3945
3999
  }
3946
- async function Wt() {
3947
- if (!wt.value || Tt.value || T.value) return;
3948
- Tt.value = !0;
3949
- let e = Et;
4000
+ async function Qt() {
4001
+ if (!B.value || jt.value || T.value) return;
4002
+ jt.value = !0;
4003
+ let e = Mt;
3950
4004
  try {
3951
- let t = Ct.value + 1, n = await D.value.getConversations(o.value, l.value, { page: t });
3952
- if (e !== Et) return;
3953
- let r = new Set(L.value.map((e) => e.id));
3954
- L.value = [...L.value, ...n.filter((e) => !r.has(e.id))], Ct.value = t, wt.value = n.length >= 100;
4005
+ let t = z.value + 1, n = await D.value.getConversations(o.value, l.value, { page: t });
4006
+ if (e !== Mt) return;
4007
+ let r = new Set(R.value.map((e) => e.id));
4008
+ R.value = [...R.value, ...n.filter((e) => !r.has(e.id))], z.value = t, B.value = n.length >= 100;
3955
4009
  } catch {} finally {
3956
- Tt.value = !1;
4010
+ jt.value = !1;
3957
4011
  }
3958
4012
  }
3959
- async function Gt(e) {
4013
+ async function $t(e) {
3960
4014
  return T.value ? [] : D.value.getConversations(o.value, l.value, { search: e });
3961
4015
  }
3962
- async function Kt() {
4016
+ async function en() {
3963
4017
  let e = E.value;
3964
- if (!e) R.value = [];
4018
+ if (!e) V.value = [];
3965
4019
  else {
3966
- Dt.value = !0;
4020
+ Nt.value = !0;
3967
4021
  try {
3968
- R.value = await D.value.getChatFiles(e);
4022
+ V.value = await D.value.getChatFiles(e);
3969
4023
  } catch {
3970
- R.value = [];
4024
+ V.value = [];
3971
4025
  } finally {
3972
- Dt.value = !1;
4026
+ Nt.value = !1;
3973
4027
  }
3974
4028
  }
3975
4029
  }
3976
- function qt(e, t = !1) {
4030
+ function q(e, t = !1) {
3977
4031
  return D.value.getChatFileDownloadUrl(e, t);
3978
4032
  }
3979
- function Jt(e) {
4033
+ function tn(e) {
3980
4034
  return D.value.getChatFilePreviewUrl(e);
3981
4035
  }
3982
- async function Yt(e) {
4036
+ async function nn(e) {
3983
4037
  await D.value.deleteChatFile(e);
3984
- let t = R.value.find((t) => t.documentId === e), n = t?.kind === "spreadsheet" ? t.sourceAttachmentId ?? t.documentId : void 0;
3985
- R.value = R.value.filter((t) => t.documentId !== e && (!n || t.documentId !== n && t.sourceAttachmentId !== n));
4038
+ let t = V.value.find((t) => t.documentId === e), n = t?.kind === "spreadsheet" ? t.sourceAttachmentId ?? t.documentId : void 0;
4039
+ V.value = V.value.filter((t) => t.documentId !== e && (!n || t.documentId !== n && t.sourceAttachmentId !== n));
3986
4040
  }
3987
- async function Xt(e, t) {
4041
+ async function rn(e, t) {
3988
4042
  if (!T.value) try {
3989
4043
  let n = await D.value.getChat(e, t);
3990
- if (t !== E.value || F.value.status !== "ready" || F.value.messages.length > 0) return;
3991
- n && (F.value.messages = n.messages, Ye.value = n.blocked ?? !1, Zt(e, t, n.turnInProgress === !0));
4044
+ if (t !== E.value || L.value.status !== "ready" || L.value.messages.length > 0) return;
4045
+ n && (L.value.messages = n.messages, Xe.value = n.blocked ?? !1, an(e, t, n.turnInProgress === !0));
3992
4046
  } catch {}
3993
4047
  }
3994
- async function Zt(e, t, n) {
3995
- n && (await Qt(t), t !== E.value || K()) || (await $t(e, t), t === E.value && await nn());
4048
+ async function an(e, t, n) {
4049
+ n && (await on(t), t !== E.value || J()) || (await sn(e, t), t === E.value && await dn());
3996
4050
  }
3997
- async function Qt(e) {
4051
+ async function on(e) {
3998
4052
  let t = { chatId: e };
3999
- j = t, st.value = e;
4000
- let n = () => j === t && e === E.value, r = Date.now() + Qr;
4053
+ M = t, gt.value = e;
4054
+ let n = () => M === t && e === E.value, r = Date.now() + $r;
4001
4055
  try {
4002
- for (; n() && !K() && Date.now() < r;) {
4003
- ot = !0;
4056
+ for (; n() && !J() && Date.now() < r;) {
4057
+ ht = !0;
4004
4058
  try {
4005
- await F.value.resumeStream();
4059
+ await L.value.resumeStream();
4006
4060
  } finally {
4007
- ot = !1;
4061
+ ht = !1;
4008
4062
  }
4009
4063
  if (!n()) return;
4010
- F.value.clearError();
4064
+ L.value.clearError();
4011
4065
  let t = await D.value.getChat(o.value, e).catch(() => null);
4012
- if (!t || !n() || K()) return;
4066
+ if (!t || !n() || J()) return;
4013
4067
  if (!t.turnInProgress) {
4014
- F.value.messages = t.messages;
4068
+ L.value.messages = t.messages;
4015
4069
  return;
4016
4070
  }
4017
- await new Promise((e) => setTimeout(e, $r));
4071
+ await new Promise((e) => setTimeout(e, ei));
4018
4072
  }
4019
4073
  } finally {
4020
- j === t && (j = void 0, st.value = void 0);
4074
+ M === t && (M = void 0, gt.value = void 0);
4021
4075
  }
4022
4076
  }
4023
- async function $t(e, t) {
4077
+ async function sn(e, t) {
4024
4078
  let n;
4025
4079
  try {
4026
4080
  n = Number(sessionStorage.getItem(Oe)), sessionStorage.removeItem(Oe);
4027
4081
  } catch {
4028
4082
  return;
4029
4083
  }
4030
- if (!(!n || Date.now() - n > 6e4 || Ve.value)) for (let n = 0; n < 12; n++) {
4031
- let n = F.value.messages[F.value.messages.length - 1];
4084
+ if (!(!n || Date.now() - n > 6e4 || He.value)) for (let n = 0; n < 12; n++) {
4085
+ let n = L.value.messages[L.value.messages.length - 1];
4032
4086
  if (n?.role === "assistant") {
4033
4087
  let e = n.parts.filter((e) => ie(e) && e.state === "input-available"), t = e.filter((e) => e.toolMetadata?.provider === "page" && e.toolMetadata.readOnly === !0);
4034
4088
  if (e.length > 0) {
4035
- if (t.length === e.length && !Ve.value) for (let e of t) it.enqueue({
4089
+ if (t.length === e.length && !He.value) for (let e of t) ot.enqueue({
4036
4090
  toolCallId: e.toolCallId,
4037
4091
  toolName: e.toolName,
4038
4092
  input: e.input,
@@ -4044,277 +4098,281 @@ function ui(e) {
4044
4098
  }
4045
4099
  if (n.parts[n.parts.length - 1]?.type === "text") return;
4046
4100
  }
4047
- if (await new Promise((e) => setTimeout(e, 1500)), t !== E.value || F.value.status !== "ready") return;
4101
+ if (await new Promise((e) => setTimeout(e, 1500)), t !== E.value || L.value.status !== "ready") return;
4048
4102
  try {
4049
4103
  let n = await D.value.getChat(e, t);
4050
- n && t === E.value && (F.value.messages = n.messages);
4104
+ n && t === E.value && (L.value.messages = n.messages);
4051
4105
  } catch {
4052
4106
  return;
4053
4107
  }
4054
4108
  }
4055
4109
  }
4056
- let K = () => {
4057
- let e = F.value.status;
4110
+ let J = () => {
4111
+ let e = L.value.status;
4058
4112
  return e === "submitted" || e === "streaming";
4059
- }, en = () => K() || j?.chatId === E.value || me.value > 0, q = () => {
4060
- let e = _t();
4061
- return O.value !== void 0 || qr(e) || ci(e);
4062
- }, tn = /* @__PURE__ */ new Set();
4063
- async function nn() {
4113
+ }, cn = () => J() || M?.chatId === E.value || me.value > 0, ln = () => {
4114
+ let e = wt();
4115
+ return O.value !== void 0 || Jr(e) || li(e);
4116
+ }, un = /* @__PURE__ */ new Set();
4117
+ async function dn() {
4064
4118
  let e = E.value;
4065
- if (!(tn.has(e) || It.value.length === 0 || en() || Je.value)) {
4066
- if (q()) Bt(zt(e));
4119
+ if (!(un.has(e) || Wt.value.length === 0 || cn() || Ye.value)) {
4120
+ if (ln()) Jt(qt(e));
4067
4121
  else {
4068
- tn.add(e);
4122
+ un.add(e);
4069
4123
  try {
4070
- let t = Date.now() + ri;
4071
- for (; Date.now() < t && (await Promise.race([D.value.getRunningTurns(o.value, [e]).catch(() => []), new Promise((t) => setTimeout(() => t([e]), ai))])).includes(e);) await new Promise((e) => setTimeout(e, ii));
4072
- if (e !== E.value || en()) return;
4073
- let n = zt(e);
4074
- n && pn(n);
4124
+ let t = Date.now() + ii;
4125
+ for (; Date.now() < t && (await Promise.race([D.value.getRunningTurns(o.value, [e]).catch(() => []), new Promise((t) => setTimeout(() => t([e]), oi))])).includes(e);) await new Promise((e) => setTimeout(e, ai));
4126
+ if (e !== E.value || cn()) return;
4127
+ let n = qt(e);
4128
+ n && xn(n);
4075
4129
  } finally {
4076
- tn.delete(e);
4130
+ un.delete(e);
4077
4131
  }
4078
4132
  }
4079
4133
  }
4080
4134
  }
4081
- let rn = 0, an = 0;
4082
- async function on() {
4083
- if (T.value || K()) return "indeterminate";
4084
- let e = E.value, t = rn += 1;
4135
+ let fn = 0, pn = 0;
4136
+ async function mn() {
4137
+ if (T.value || J()) return "indeterminate";
4138
+ let e = E.value, t = fn += 1;
4085
4139
  try {
4086
4140
  let n = await D.value.getChat(o.value, e);
4087
- if (!n || e !== E.value || K() || t <= an) return "indeterminate";
4088
- an = t;
4089
- let r = n.messages, i = Zr(r, F.value.messages);
4090
- return F.value.messages = [...r, ...i], Ye.value = n.blocked ?? !1, i.length > 0 ? "pending" : "caught-up";
4141
+ if (!n || e !== E.value || J() || t <= pn) return "indeterminate";
4142
+ pn = t;
4143
+ let r = n.messages, i = Qr(r, L.value.messages);
4144
+ return L.value.messages = [...r, ...i], Xe.value = n.blocked ?? !1, i.length > 0 ? "pending" : "caught-up";
4091
4145
  } catch {}
4092
4146
  return "indeterminate";
4093
4147
  }
4094
- function sn(e) {
4095
- F.value.messages = [...F.value.messages, e];
4148
+ function hn(e) {
4149
+ L.value.messages = [...L.value.messages, e];
4096
4150
  }
4097
- async function cn(e) {
4151
+ async function gn(e) {
4098
4152
  try {
4099
- z.value = await D.value.getMessageFeedbacks(e);
4153
+ Pt.value = await D.value.getMessageFeedbacks(e);
4100
4154
  } catch {
4101
- z.value = [];
4155
+ Pt.value = [];
4102
4156
  }
4103
4157
  }
4104
- function ln(e) {
4105
- let t = z.value.findIndex((t) => t.messageId === e.messageId);
4106
- t >= 0 ? z.value[t] = e : z.value.push(e);
4158
+ function _n(e) {
4159
+ let t = Pt.value.findIndex((t) => t.messageId === e.messageId);
4160
+ t >= 0 ? Pt.value[t] = e : Pt.value.push(e);
4107
4161
  }
4108
- function un(e) {
4109
- let t = bt.value, n = t.findIndex((t) => t.id === e.id), r = ue(e) ?? "", i = t.slice(0, n).reverse().find((e) => e.role === "user");
4162
+ function vn(e) {
4163
+ let t = Ot.value, n = t.findIndex((t) => t.id === e.id), r = ue(e) ?? "", i = t.slice(0, n).reverse().find((e) => e.role === "user");
4110
4164
  return {
4111
4165
  userQuestion: ue(i ?? e) ?? "",
4112
4166
  assistantMessage: r
4113
4167
  };
4114
4168
  }
4115
- async function dn(e, t) {
4169
+ async function yn(e, t) {
4116
4170
  await Promise.all([
4117
- Xt(e, t),
4118
- Ut(e),
4119
- cn(t)
4120
- ]), $e.value || De((e, t) => D.value.reverseGeocode(e, t, r.value)).then((e) => {
4121
- e && ($e.value = e);
4171
+ rn(e, t),
4172
+ Zt(e),
4173
+ gn(t)
4174
+ ]), et.value || De((e, t) => D.value.reverseGeocode(e, t, r.value)).then((e) => {
4175
+ e && (et.value = e);
4122
4176
  });
4123
4177
  }
4124
- async function fn() {
4125
- let e = U.value.trim(), t = W.value.filter((e) => e.state === "done" && e.mediaSource !== void 0).map((e) => ({
4178
+ async function bn() {
4179
+ let e = W.value.trim(), t = G.value.filter((e) => e.state === "done" && e.mediaSource !== void 0).map((e) => ({
4126
4180
  type: "file",
4127
4181
  mediaType: e.mediaSource.mimeType,
4128
4182
  url: e.localUrl,
4129
4183
  filename: e.mediaSource.name,
4130
4184
  providerMetadata: { "8bot": { media: e.mediaSource } }
4131
4185
  }));
4132
- !T.value && en() ? e && t.length === 0 && (Rt(E.value, [...It.value, e]), U.value = "") : (T.value && bt.value.length > 0 && await X(), pn(e, t), U.value = "", On());
4186
+ !T.value && cn() ? e && t.length === 0 && (Kt(E.value, [...Wt.value, e]), W.value = "") : (T.value && Ot.value.length > 0 && await In(), xn(e, t), W.value = "", Fn());
4133
4187
  }
4134
- function pn(e, t = []) {
4135
- A(), G.value = e, Pt.value = F.value.messages.length;
4136
- let n = F.value.sendMessage;
4188
+ function xn(e, t = []) {
4189
+ pt(), K.value = e, Ht.value = L.value.messages.length;
4190
+ let n = L.value.sendMessage;
4137
4191
  n({
4138
4192
  text: e,
4139
4193
  files: t.length > 0 ? t : void 0
4140
4194
  });
4141
4195
  }
4142
- function mn(e) {
4196
+ function Sn(e) {
4143
4197
  let t = e.trim();
4144
4198
  if (!t) return;
4145
- if (F.value.status !== "ready") {
4199
+ if (L.value.status !== "ready") {
4146
4200
  ce.warn("[useChatbotStore] sendMessage called before chat is ready. Listen for the \"ready\" event on the widget element.");
4147
4201
  return;
4148
4202
  }
4149
- let n = F.value.sendMessage;
4150
- A(), n({ text: t });
4203
+ let n = L.value.sendMessage;
4204
+ pt(), n({ text: t });
4151
4205
  }
4152
- async function hn() {
4153
- let e = F.value.messages.slice(Pt.value).some((e) => e.parts.some(ie)), t = G.value, n = t.length > 0 && !e, r = E.value, i = Pt.value, a = j?.chatId === r, s = ct, c = zt(r), l = (e = "") => {
4154
- U.value = [
4206
+ async function Cn() {
4207
+ let e = L.value.messages.slice(Ht.value).some((e) => e.parts.some(ie)), t = K.value, n = t.length > 0 && !e, r = E.value, i = Ht.value, a = M?.chatId === r, s = _t, c = qt(r), l = (e = "") => {
4208
+ W.value = [
4155
4209
  e,
4156
4210
  c,
4157
- U.value
4158
- ].filter(Boolean).join(oi);
4159
- }, u = () => r === E.value && !K() && Pt.value === i ? !1 : (c && Rt(r, [c, ...Ft.value[r] ?? []]), !0);
4160
- j = void 0, st.value = void 0, A(), await F.value.stop();
4211
+ W.value
4212
+ ].filter(Boolean).join(si);
4213
+ }, u = () => r === E.value && !J() && Ht.value === i ? !1 : (c && Kt(r, [c, ...Ut.value[r] ?? []]), !0);
4214
+ M = void 0, gt.value = void 0, pt(), await L.value.stop();
4161
4215
  let d = T.value || e && !a || await D.value.stopChatTurn(o.value, r, s).catch(() => !0);
4162
4216
  if (!u()) {
4163
4217
  if (a || !d) {
4164
- if (await on(), u()) return;
4165
- if (a || F.value.messages.length > Pt.value) {
4166
- G.value = "", l();
4218
+ if (await mn(), u()) return;
4219
+ if (a || L.value.messages.length > Ht.value) {
4220
+ K.value = "", l();
4167
4221
  return;
4168
4222
  }
4169
4223
  }
4170
- n ? (l(t), F.value.messages = F.value.messages.slice(0, Pt.value), G.value = "") : l();
4224
+ n ? (l(t), L.value.messages = L.value.messages.slice(0, Ht.value), K.value = "") : l();
4171
4225
  }
4172
4226
  }
4173
- C(() => F.value.messages, (e) => {
4227
+ C(() => L.value.messages, (e) => {
4174
4228
  let t = O.value?.toolCallId;
4175
- t && !e.some((e) => e.parts.some((e) => e.toolCallId === t)) && A();
4176
- }), C(() => F.value.status, (e) => {
4177
- e === "submitted" && (w.value++, ct = void 0);
4229
+ t && !A.has(t) && !e.some((e) => e.parts.some((e) => e.toolCallId === t)) && pt();
4230
+ }), C(() => L.value.status, (e) => {
4231
+ e === "submitted" && (Fe.value++, _t = void 0);
4178
4232
  });
4179
- let gn;
4180
- C(() => [F.value.status, me.value], ([e, t]) => {
4181
- clearTimeout(gn), e === "ready" && t === 0 && (gn = setTimeout(() => {
4182
- Pe.value = !1;
4233
+ let wn;
4234
+ C(() => [
4235
+ L.value.status,
4236
+ me.value,
4237
+ ye.value
4238
+ ], ([e, t, n]) => {
4239
+ clearTimeout(wn), e === "ready" && t === 0 && n === 0 && (wn = setTimeout(() => {
4240
+ w.value = !1;
4183
4241
  }, 1500));
4184
4242
  });
4185
- let _n = S(!1), vn;
4186
- C(() => !O.value && !qr(_t()) && (K() || me.value > 0), (e) => {
4187
- clearTimeout(vn), e ? _n.value = !0 : vn = setTimeout(() => {
4188
- _n.value = !1;
4243
+ let Tn = S(!1), En;
4244
+ C(() => !O.value && !Jr(wt()) && (J() || me.value > 0), (e) => {
4245
+ clearTimeout(En), e ? Tn.value = !0 : En = setTimeout(() => {
4246
+ Tn.value = !1;
4189
4247
  }, 400);
4190
4248
  }, { immediate: !0 });
4191
- let yn = x(() => {
4192
- let e = lt.value.filter((e) => e !== E.value);
4193
- return _n.value || st.value === E.value ? [...e, E.value] : e;
4194
- }), bn = () => [.../* @__PURE__ */ new Set([...lt.value, ...M.value])], xn = Ce(), J, Sn = 0, Cn = 0;
4195
- function wn() {
4196
- clearTimeout(J), J = void 0, bn().length !== 0 && xn.value === "visible" && (J = setTimeout(() => {
4197
- J = void 0, Tn(bn());
4198
- }, ei));
4249
+ let Dn = x(() => {
4250
+ let e = vt.value.filter((e) => e !== E.value);
4251
+ return Tn.value || gt.value === E.value ? [...e, E.value] : e;
4252
+ }), Y = () => [.../* @__PURE__ */ new Set([...vt.value, ...N.value])], On = Ce(), X, kn = 0, Z = 0;
4253
+ function An() {
4254
+ clearTimeout(X), X = void 0, Y().length !== 0 && On.value === "visible" && (X = setTimeout(() => {
4255
+ X = void 0, jn(Y());
4256
+ }, ti));
4199
4257
  }
4200
- async function Tn(e) {
4201
- let t = e.slice(0, ti);
4258
+ async function jn(e) {
4259
+ let t = e.slice(0, ni);
4202
4260
  if (T.value || t.length === 0) {
4203
- wn();
4261
+ An();
4204
4262
  return;
4205
4263
  }
4206
- let n = Sn += 1, r;
4264
+ let n = kn += 1, r;
4207
4265
  try {
4208
4266
  r = await D.value.getRunningTurns(o.value, t);
4209
4267
  } catch {
4210
- wn();
4268
+ An();
4211
4269
  return;
4212
4270
  }
4213
- if (n <= Cn) return;
4214
- Cn = n;
4215
- for (let e of r) ft.add(e);
4216
- let i = new Set(t), a = bn().filter((e) => i.has(e) && !r.includes(e)), s = (e) => M.value.includes(e) && !ft.has(e), c = a.filter((e) => s(e) && Date.now() - (dt.get(e) ?? 0) > ni), l = a.filter((e) => !s(e));
4217
- lt.value = [...lt.value.filter((e) => !i.has(e)), ...r];
4218
- let u = l.filter((e) => M.value.includes(e));
4219
- (u.length > 0 || c.length > 0) && (M.value = M.value.filter((e) => !u.includes(e) && !c.includes(e)), N.value = [...N.value, ...u.filter((e) => e !== E.value && !N.value.includes(e))]), l.length > 0 && Ut(o.value), wn();
4271
+ if (n <= Z) return;
4272
+ Z = n;
4273
+ for (let e of r) I.add(e);
4274
+ let i = new Set(t), a = Y().filter((e) => i.has(e) && !r.includes(e)), s = (e) => N.value.includes(e) && !I.has(e), c = a.filter((e) => s(e) && Date.now() - (yt.get(e) ?? 0) > ri), l = a.filter((e) => !s(e));
4275
+ vt.value = [...vt.value.filter((e) => !i.has(e)), ...r];
4276
+ let u = l.filter((e) => N.value.includes(e));
4277
+ (u.length > 0 || c.length > 0) && (N.value = N.value.filter((e) => !u.includes(e) && !c.includes(e)), P.value = [...P.value, ...u.filter((e) => e !== E.value && !P.value.includes(e))]), l.length > 0 && Zt(o.value), An();
4220
4278
  }
4221
- C(xn, (e) => {
4222
- e === "visible" ? Tn(bn()) : (clearTimeout(J), J = void 0);
4223
- }), ge(() => clearTimeout(J));
4224
- let En = x(() => N.value.map((e) => ({
4279
+ C(On, (e) => {
4280
+ e === "visible" ? jn(Y()) : (clearTimeout(X), X = void 0);
4281
+ }), ge(() => clearTimeout(X));
4282
+ let Mn = x(() => P.value.map((e) => ({
4225
4283
  chatId: e,
4226
- title: L.value.find((t) => t.id === e)?.title || P.value[e] || void 0
4284
+ title: R.value.find((t) => t.id === e)?.title || F.value[e] || void 0
4227
4285
  })));
4228
- function Dn(e) {
4229
- ht(e), E.value = e, qn("chat");
4286
+ function Nn(e) {
4287
+ St(e), E.value = e, nr("chat");
4230
4288
  }
4231
- function Y(e) {
4232
- N.value = N.value.filter((t) => t !== e), mt(e);
4289
+ function Pn(e) {
4290
+ P.value = P.value.filter((t) => t !== e), xt(e);
4233
4291
  }
4234
- C(() => [F.value.status, F.value.id], ([e, t], [n, r]) => {
4292
+ C(() => [L.value.status, L.value.id], ([e, t], [n, r]) => {
4235
4293
  if (t === r) {
4236
- if (e === "error") j?.chatId !== E.value && Bt(zt(E.value));
4294
+ if (e === "error") M?.chatId !== E.value && Jt(qt(E.value));
4237
4295
  else if (e === "ready" && (n === "streaming" || n === "submitted")) {
4238
- if (q()) {
4239
- Bt(zt(E.value));
4296
+ if (ln()) {
4297
+ Jt(qt(E.value));
4240
4298
  return;
4241
4299
  }
4242
- nn();
4300
+ dn();
4243
4301
  }
4244
4302
  }
4245
4303
  }), C(me, (e) => {
4246
- e === 0 && F.value.status === "ready" && nn();
4247
- }), C(() => F.value.status, (e) => {
4248
- e === "ready" && G.value.length > 0 && (G.value = "");
4304
+ e === 0 && L.value.status === "ready" && dn();
4305
+ }), C(() => L.value.status, (e) => {
4306
+ e === "ready" && K.value.length > 0 && (K.value = "");
4249
4307
  });
4250
- function On(e = !1) {
4251
- for (let t of W.value) (e || t.state !== "done") && URL.revokeObjectURL(t.localUrl);
4252
- W.value = [], In.value = null;
4308
+ function Fn(e = !1) {
4309
+ for (let t of G.value) (e || t.state !== "done") && URL.revokeObjectURL(t.localUrl);
4310
+ G.value = [], Gn.value = null;
4253
4311
  }
4254
- async function X() {
4255
- return G.value = "", Ne.value = {}, E.value = ut(), await he(), F.value.clearError(), Je.value = void 0, Ye.value = !1, On(!0), qn("chat"), E.value;
4312
+ async function In() {
4313
+ return K.value = "", Pe.value = {}, E.value = ft(), await he(), L.value.clearError(), Ye.value = void 0, Xe.value = !1, Fn(!0), nr("chat"), E.value;
4256
4314
  }
4257
- async function kn(e) {
4258
- F.value.status !== "ready" && (G.value = "", await hn()), A(), await F.value.regenerate(e);
4315
+ async function Ln(e) {
4316
+ L.value.status !== "ready" && (K.value = "", await Cn()), pt(), await L.value.regenerate(e);
4259
4317
  }
4260
- function Z(e) {
4318
+ function Rn(e) {
4261
4319
  if (e.tool === "requestGeolocation") {
4262
4320
  let t = e.output;
4263
- "latitude" in t && ($e.value = {
4321
+ "latitude" in t && (et.value = {
4264
4322
  geolocationLatitude: t.latitude,
4265
4323
  geolocationLongitude: t.longitude,
4266
4324
  geolocationAccuracy: t.accuracy,
4267
4325
  geolocationCity: t.city
4268
4326
  });
4269
4327
  }
4270
- F.value.addToolOutput(e);
4328
+ L.value.addToolOutput(e);
4271
4329
  }
4272
- function An(e) {
4273
- F.value.addToolApprovalResponse(e);
4330
+ function zn(e) {
4331
+ L.value.addToolApprovalResponse(e);
4274
4332
  }
4275
- let jn = x(() => F.value.messages.reduce((e, t) => e + t.parts.filter((e) => e.type === "file").length, 0)), Mn = x(() => _.value?.maxFilesPerMessage ?? 5), Nn = x(() => _.value?.maxFilesPerChat ?? 20), Pn = x(() => Math.max(0, Math.min(Mn.value - W.value.length, Nn.value - jn.value - W.value.length))), Fn = x(() => Pn.value <= 0), In = S(null), Ln = () => {
4276
- In.value = null;
4333
+ let Bn = x(() => L.value.messages.reduce((e, t) => e + t.parts.filter((e) => e.type === "file").length, 0)), Vn = x(() => _.value?.maxFilesPerMessage ?? 5), Hn = x(() => _.value?.maxFilesPerChat ?? 20), Un = x(() => Math.max(0, Math.min(Vn.value - G.value.length, Hn.value - Bn.value - G.value.length))), Wn = x(() => Un.value <= 0), Gn = S(null), Kn = () => {
4334
+ Gn.value = null;
4277
4335
  };
4278
- C(Fn, (e) => {
4279
- e || (In.value = null);
4336
+ C(Wn, (e) => {
4337
+ e || (Gn.value = null);
4280
4338
  });
4281
- async function Rn(e) {
4282
- if (Fn.value) {
4283
- In.value = Nn.value - jn.value - W.value.length <= Mn.value - W.value.length ? {
4339
+ async function qn(e) {
4340
+ if (Wn.value) {
4341
+ Gn.value = Hn.value - Bn.value - G.value.length <= Vn.value - G.value.length ? {
4284
4342
  reason: "per-chat",
4285
- max: Nn.value
4343
+ max: Hn.value
4286
4344
  } : {
4287
4345
  reason: "per-message",
4288
- max: Mn.value
4346
+ max: Vn.value
4289
4347
  };
4290
4348
  return;
4291
4349
  }
4292
- let t = ut(), n = {
4350
+ let t = ft(), n = {
4293
4351
  id: t,
4294
4352
  file: e,
4295
4353
  localUrl: URL.createObjectURL(e),
4296
4354
  state: "uploading"
4297
4355
  };
4298
- W.value = [...W.value, n];
4356
+ G.value = [...G.value, n];
4299
4357
  try {
4300
4358
  let n = await D.value.uploadMedia(o.value, E.value, e);
4301
- W.value = W.value.map((e) => e.id === t ? {
4359
+ G.value = G.value.map((e) => e.id === t ? {
4302
4360
  ...e,
4303
4361
  state: "done",
4304
4362
  mediaSource: n
4305
4363
  } : e);
4306
4364
  } catch (e) {
4307
4365
  let n = e instanceof Error ? e.message : "Upload failed";
4308
- W.value = W.value.map((e) => e.id === t ? {
4366
+ G.value = G.value.map((e) => e.id === t ? {
4309
4367
  ...e,
4310
4368
  state: "error",
4311
4369
  error: n
4312
4370
  } : e);
4313
4371
  }
4314
4372
  }
4315
- async function zn(e, t) {
4316
- let { userQuestion: n, assistantMessage: r } = un(e);
4317
- ln(await D.value.submitMessageFeedback({
4373
+ async function Jn(e, t) {
4374
+ let { userQuestion: n, assistantMessage: r } = vn(e);
4375
+ _n(await D.value.submitMessageFeedback({
4318
4376
  messageId: e.id,
4319
4377
  chatId: E.value,
4320
4378
  agentId: o.value,
@@ -4323,73 +4381,73 @@ function ui(e) {
4323
4381
  assistantMessage: r
4324
4382
  }));
4325
4383
  }
4326
- async function Bn(e) {
4327
- await zn(e, "upvote");
4384
+ async function Yn(e) {
4385
+ await Jn(e, "upvote");
4328
4386
  }
4329
- async function Vn(e) {
4330
- await zn(e, "downvote");
4387
+ async function Xn(e) {
4388
+ await Jn(e, "downvote");
4331
4389
  }
4332
- function Hn(e) {
4333
- At.value = !1, jt.value = void 0, B.value = e;
4390
+ function Zn(e) {
4391
+ Lt.value = !1, Rt.value = void 0, Ft.value = e;
4334
4392
  }
4335
- async function Un(e) {
4336
- if (B.value) try {
4337
- V.value = !0, At.value = !1, jt.value = void 0;
4338
- let { userQuestion: t, assistantMessage: n } = un(B.value);
4339
- ln(await D.value.submitMessageFeedback({
4340
- messageId: B.value.id,
4393
+ async function Qn(e) {
4394
+ if (Ft.value) try {
4395
+ It.value = !0, Lt.value = !1, Rt.value = void 0;
4396
+ let { userQuestion: t, assistantMessage: n } = vn(Ft.value);
4397
+ _n(await D.value.submitMessageFeedback({
4398
+ messageId: Ft.value.id,
4341
4399
  chatId: E.value,
4342
4400
  agentId: o.value,
4343
4401
  userQuestion: t,
4344
4402
  assistantMessage: n,
4345
4403
  comment: e
4346
- })), At.value = !0, await cn(E.value);
4404
+ })), Lt.value = !0, await gn(E.value);
4347
4405
  } catch {
4348
- jt.value = n("message.feedbackSubmitError") ? t("message.feedbackSubmitError") : "Failed to submit feedback";
4406
+ Rt.value = n("message.feedbackSubmitError") ? t("message.feedbackSubmitError") : "Failed to submit feedback";
4349
4407
  } finally {
4350
- V.value = !1;
4408
+ It.value = !1;
4351
4409
  }
4352
4410
  }
4353
- async function Wn(e) {
4411
+ async function $n(e) {
4354
4412
  try {
4355
- Nt.value = !0, Mt.value = !1, H.value = void 0, await D.value.submitLead({
4413
+ Bt.value = !0, zt.value = !1, Vt.value = void 0, await D.value.submitLead({
4356
4414
  agentId: o.value,
4357
4415
  chatId: E.value,
4358
4416
  ...e
4359
- }), Mt.value = !0;
4417
+ }), zt.value = !0;
4360
4418
  } catch {
4361
- H.value = n("message.leadSubmitError") ? t("message.leadSubmitError") : "Failed to submit lead";
4419
+ Vt.value = n("message.leadSubmitError") ? t("message.leadSubmitError") : "Failed to submit lead";
4362
4420
  } finally {
4363
- Nt.value = !1;
4421
+ Bt.value = !1;
4364
4422
  }
4365
4423
  }
4366
- async function Gn(e, t) {
4424
+ async function er(e, t) {
4367
4425
  let n = await D.value.updateChatTitle(o.value, e, t);
4368
- L.value = L.value.map((t) => t.id === e ? {
4426
+ R.value = R.value.map((t) => t.id === e ? {
4369
4427
  ...t,
4370
4428
  title: n.title
4371
4429
  } : t);
4372
4430
  }
4373
- async function Kn(e) {
4374
- await D.value.deleteChat(o.value, e), L.value = L.value.filter((t) => t.id !== e), E.value === e && await X();
4431
+ async function tr(e) {
4432
+ await D.value.deleteChat(o.value, e), R.value = R.value.filter((t) => t.id !== e), E.value === e && await In();
4375
4433
  }
4376
- function qn(e) {
4377
- Ot.value = e;
4434
+ function nr(e) {
4435
+ H.value = e;
4378
4436
  }
4379
- function Jn() {
4380
- qn("chat"), kt.value++;
4437
+ function rr() {
4438
+ nr("chat"), U.value++;
4381
4439
  }
4382
- let Yn;
4383
- function Xn(e) {
4440
+ let Q;
4441
+ function ir(e) {
4384
4442
  let t = () => D.value.getChat(o.value, e).then((e) => e !== null);
4385
4443
  return t().catch(() => t().catch(() => !1));
4386
4444
  }
4387
4445
  return C(l, async (e) => {
4388
- if (!e || e === Yn) return;
4389
- let t = Yn;
4390
- if (Yn = e, t === void 0) return;
4391
- let n = E.value, r = !T.value && await Xn(n);
4392
- l.value === e && E.value === n && (r ? Ut(o.value) : (L.value = [], z.value = [], R.value = [], lt.value = [], M.value = [], N.value = [], P.value = {}, await X(), U.value = ""));
4446
+ if (!e || e === Q) return;
4447
+ let t = Q;
4448
+ if (Q = e, t === void 0) return;
4449
+ let n = E.value, r = !T.value && await ir(n);
4450
+ l.value === e && E.value === n && (r ? Zt(o.value) : (R.value = [], Pt.value = [], V.value = [], vt.value = [], N.value = [], P.value = [], F.value = {}, await In(), W.value = ""));
4393
4451
  }), {
4394
4452
  apiClient: D,
4395
4453
  baseUrl: i,
@@ -4405,7 +4463,7 @@ function ui(e) {
4405
4463
  revisedAnswers: m,
4406
4464
  model: h,
4407
4465
  actionsInput: g,
4408
- actions: ze,
4466
+ actions: Be,
4409
4467
  agentFileUpload: _,
4410
4468
  agentVoice: v,
4411
4469
  fallbackModels: y,
@@ -4414,91 +4472,93 @@ function ui(e) {
4414
4472
  agentHostTools: oe,
4415
4473
  hostToolRegistry: pe,
4416
4474
  hostToolsPending: me,
4417
- agentPageAccess: ye,
4418
- pageToolRegistry: be,
4419
- pageFormsProvider: Te,
4420
- pageAction: ke,
4421
- hostStepTitles: Ne,
4422
- pageControlActive: Pe,
4423
- isWorking: _n,
4424
- stopHostActions: k,
4425
- pageNoticeLevel: Ke,
4426
- closePageNotice: qe,
4475
+ agentPageAccess: be,
4476
+ pageToolRegistry: Te,
4477
+ pageFormsProvider: ke,
4478
+ pageAction: Ne,
4479
+ hostStepTitles: Pe,
4480
+ pageControlActive: w,
4481
+ isWorking: Tn,
4482
+ stopHostActions: j,
4483
+ voicePageTools: ut,
4484
+ cancelVoicePageCalls: dt,
4485
+ pageNoticeLevel: qe,
4486
+ closePageNotice: Je,
4427
4487
  hostConfirmation: O,
4428
- respondHostConfirmation: rt,
4429
- pageAccessAvailable: We,
4430
- pageAccessOff: Ve,
4431
- setPageAccessOff: at,
4432
- systemTheme: Fe,
4433
- hideWelcomeMessage: Ie,
4434
- isDark: Re,
4435
- chat: F,
4436
- messages: bt,
4437
- conversations: L,
4438
- isLoadingConversations: St,
4439
- hasMoreConversations: wt,
4440
- isLoadingMoreConversations: Tt,
4441
- chatFiles: R,
4442
- isLoadingChatFiles: Dt,
4443
- input: U,
4444
- pendingAttachments: W,
4445
- isAttachmentLimitReached: Fn,
4446
- fileLimitError: In,
4488
+ respondHostConfirmation: it,
4489
+ pageAccessAvailable: Ge,
4490
+ pageAccessOff: He,
4491
+ setPageAccessOff: mt,
4492
+ systemTheme: Ie,
4493
+ hideWelcomeMessage: Le,
4494
+ isDark: ze,
4495
+ chat: L,
4496
+ messages: Ot,
4497
+ conversations: R,
4498
+ isLoadingConversations: At,
4499
+ hasMoreConversations: B,
4500
+ isLoadingMoreConversations: jt,
4501
+ chatFiles: V,
4502
+ isLoadingChatFiles: Nt,
4503
+ input: W,
4504
+ pendingAttachments: G,
4505
+ isAttachmentLimitReached: Wn,
4506
+ fileLimitError: Gn,
4447
4507
  localChatId: E,
4448
- isConversationBlocked: Ye,
4449
- inputMessagePlaceholder: xt,
4450
- chatError: Je,
4451
- runningChatIds: yn,
4452
- backgroundAnswers: En,
4453
- openBackgroundAnswer: Dn,
4454
- dismissBackgroundAnswer: Y,
4455
- canQueue: Lt,
4456
- queuedMessages: It,
4457
- removeQueuedMessage: Vt,
4458
- editQueuedMessage: Ht,
4459
- activeView: Ot,
4460
- inputFocusRequest: kt,
4461
- messageFeedbacks: z,
4462
- feedbackDialogMessage: B,
4463
- isFeedbackSubmitting: V,
4464
- isFeedbackSubmitted: At,
4465
- feedbackSubmitError: jt,
4466
- isLeadSubmitted: Mt,
4467
- isLoadingSubmitLead: Nt,
4468
- submitLeadError: H,
4469
- buildDeviceContext: et,
4470
- initialize: dn,
4471
- loadConversations: Ut,
4472
- loadMoreConversations: Wt,
4473
- searchConversations: Gt,
4474
- loadChatFiles: Kt,
4475
- refreshMessages: on,
4476
- appendMessage: sn,
4477
- getChatFileUrl: qt,
4478
- getChatFilePreviewUrl: Jt,
4479
- deleteChatFile: Yt,
4480
- handleSubmit: fn,
4481
- sendMessage: mn,
4482
- stopGeneration: hn,
4483
- startNewChat: X,
4484
- regenerate: kn,
4485
- addToolOutput: Z,
4486
- addToolApprovalResponse: An,
4487
- handleFileSelect: Rn,
4488
- clearFileLimitError: Ln,
4489
- clearPendingAttachments: On,
4490
- onUpvote: Bn,
4491
- onDownvote: Vn,
4492
- onFeedback: Hn,
4493
- onFeedbackSubmit: Un,
4494
- onLeadSubmit: Wn,
4495
- navigate: qn,
4496
- focusInput: Jn,
4497
- renameChatTitle: Gn,
4498
- deleteChat: Kn
4508
+ isConversationBlocked: Xe,
4509
+ inputMessagePlaceholder: kt,
4510
+ chatError: Ye,
4511
+ runningChatIds: Dn,
4512
+ backgroundAnswers: Mn,
4513
+ openBackgroundAnswer: Nn,
4514
+ dismissBackgroundAnswer: Pn,
4515
+ canQueue: Gt,
4516
+ queuedMessages: Wt,
4517
+ removeQueuedMessage: Yt,
4518
+ editQueuedMessage: Xt,
4519
+ activeView: H,
4520
+ inputFocusRequest: U,
4521
+ messageFeedbacks: Pt,
4522
+ feedbackDialogMessage: Ft,
4523
+ isFeedbackSubmitting: It,
4524
+ isFeedbackSubmitted: Lt,
4525
+ feedbackSubmitError: Rt,
4526
+ isLeadSubmitted: zt,
4527
+ isLoadingSubmitLead: Bt,
4528
+ submitLeadError: Vt,
4529
+ buildDeviceContext: tt,
4530
+ initialize: yn,
4531
+ loadConversations: Zt,
4532
+ loadMoreConversations: Qt,
4533
+ searchConversations: $t,
4534
+ loadChatFiles: en,
4535
+ refreshMessages: mn,
4536
+ appendMessage: hn,
4537
+ getChatFileUrl: q,
4538
+ getChatFilePreviewUrl: tn,
4539
+ deleteChatFile: nn,
4540
+ handleSubmit: bn,
4541
+ sendMessage: Sn,
4542
+ stopGeneration: Cn,
4543
+ startNewChat: In,
4544
+ regenerate: Ln,
4545
+ addToolOutput: Rn,
4546
+ addToolApprovalResponse: zn,
4547
+ handleFileSelect: qn,
4548
+ clearFileLimitError: Kn,
4549
+ clearPendingAttachments: Fn,
4550
+ onUpvote: Yn,
4551
+ onDownvote: Xn,
4552
+ onFeedback: Zn,
4553
+ onFeedbackSubmit: Qn,
4554
+ onLeadSubmit: $n,
4555
+ navigate: nr,
4556
+ focusInput: rr,
4557
+ renameChatTitle: er,
4558
+ deleteChat: tr
4499
4559
  };
4500
4560
  })();
4501
4561
  }
4502
- export { ut as a, hr as i, ui as n, Gr as r, Kr as t };
4562
+ export { ft as a, hr as i, di as n, Gr as r, Kr as t };
4503
4563
 
4504
- //# sourceMappingURL=useChatbotStore-D1U24qc8.js.map
4564
+ //# sourceMappingURL=useChatbotStore-CNcPLoPf.js.map