@8wave/ai-elements 0.125.0-beta.26 → 0.125.0-beta.28

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 (121) hide show
  1. package/dist/_chunks/{PkChatbotFilePreview-CFGqa-tX.js → PkChatbotFilePreview-CqxtVySb.js} +100 -59
  2. package/dist/_chunks/PkChatbotFilePreview-CqxtVySb.js.map +1 -0
  3. package/dist/_chunks/{PkFilePreview-BPsD2P7s.js → PkFilePreview-DiLMoL-6.js} +32 -32
  4. package/dist/_chunks/{PkFilePreview-BPsD2P7s.js.map → PkFilePreview-DiLMoL-6.js.map} +1 -1
  5. package/dist/_chunks/{PkFilePreviewDialog-BW-Rubk2.js → PkFilePreviewDialog-CHBtxpoB.js} +2 -2
  6. package/dist/_chunks/{PkFilePreviewDialog-BW-Rubk2.js.map → PkFilePreviewDialog-CHBtxpoB.js.map} +1 -1
  7. package/dist/_chunks/PkImageEditorDialog-Cq8y_PtC.js +555 -0
  8. package/dist/_chunks/PkImageEditorDialog-Cq8y_PtC.js.map +1 -0
  9. package/dist/_chunks/{PkSelectionActions-DkETXtSL.js → PkSelectionActions-DFyvcEyl.js} +2 -2
  10. package/dist/_chunks/{PkSelectionActions-DkETXtSL.js.map → PkSelectionActions-DFyvcEyl.js.map} +1 -1
  11. package/dist/_chunks/{PkStreamingMarkdown-CqLpNWQv.js → PkStreamingMarkdown-0hE_Cx4W.js} +2 -2
  12. package/dist/_chunks/{PkStreamingMarkdown-CqLpNWQv.js.map → PkStreamingMarkdown-0hE_Cx4W.js.map} +1 -1
  13. package/dist/_chunks/{PkToolChatFile-iE4ZokYD.js → PkToolChatFile-DtQ9xY4w.js} +3 -3
  14. package/dist/_chunks/{PkToolChatFile-iE4ZokYD.js.map → PkToolChatFile-DtQ9xY4w.js.map} +1 -1
  15. package/dist/_chunks/{PkToolShareDocument-lTHNZodf.js → PkToolShareDocument-BvHklbzb.js} +2 -2
  16. package/dist/_chunks/{PkToolShareDocument-lTHNZodf.js.map → PkToolShareDocument-BvHklbzb.js.map} +1 -1
  17. package/dist/_chunks/{PkToolShowArtifact-BNQrM5fY.js → PkToolShowArtifact-BdkKU6P1.js} +2 -2
  18. package/dist/_chunks/{PkToolShowArtifact-BNQrM5fY.js.map → PkToolShowArtifact-BdkKU6P1.js.map} +1 -1
  19. package/dist/_chunks/{PkToolShowContactForm-CvQoLumn.js → PkToolShowContactForm-BmM2MbOK.js} +2 -2
  20. package/dist/_chunks/{PkToolShowContactForm-CvQoLumn.js.map → PkToolShowContactForm-BmM2MbOK.js.map} +1 -1
  21. package/dist/_chunks/{PkToolShowForm-DcPccCEU.js → PkToolShowForm-CoFlgA-I.js} +3 -3
  22. package/dist/_chunks/{PkToolShowForm-DcPccCEU.js.map → PkToolShowForm-CoFlgA-I.js.map} +1 -1
  23. package/dist/_chunks/{PkToolShowSources-B3VpJBVE.js → PkToolShowSources-DDBlLBt6.js} +2 -2
  24. package/dist/_chunks/{PkToolShowSources-B3VpJBVE.js.map → PkToolShowSources-DDBlLBt6.js.map} +1 -1
  25. package/dist/_chunks/{utils-BZuri2jT.js → utils-ChmRkK0t.js} +12 -5
  26. package/dist/_chunks/utils-ChmRkK0t.js.map +1 -0
  27. package/dist/ai-elements.es.js +3197 -3115
  28. package/dist/ai-elements.es.js.map +1 -1
  29. package/dist-vue/PkChatbot.js +1 -1
  30. package/dist-vue/PkChatbotEmptyState.js +1 -1
  31. package/dist-vue/PkChatbotFilePreview.js +1 -1
  32. package/dist-vue/PkChatbotInput.js +1 -1
  33. package/dist-vue/PkChatbotMessages.js +1 -1
  34. package/dist-vue/PkChatbotStepPayload.js +1 -1
  35. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  36. package/dist-vue/PkChatbotSteps.js +1 -1
  37. package/dist-vue/PkChatbotViewChat.js +1 -1
  38. package/dist-vue/PkChatbotViewConversations.js +1 -1
  39. package/dist-vue/PkChatbotViewFiles.js +1 -1
  40. package/dist-vue/PkChatbotViewProfile.js +1 -1
  41. package/dist-vue/_chunks/{PkChatbot-DyzEuNED.js → PkChatbot-BjJzskl7.js} +8 -8
  42. package/dist-vue/_chunks/{PkChatbot-DyzEuNED.js.map → PkChatbot-BjJzskl7.js.map} +1 -1
  43. package/dist-vue/_chunks/{PkChatbotEmptyState-COya3H3C.js → PkChatbotEmptyState-CZC2gP3I.js} +2 -2
  44. package/dist-vue/_chunks/{PkChatbotEmptyState-COya3H3C.js.map → PkChatbotEmptyState-CZC2gP3I.js.map} +1 -1
  45. package/dist-vue/_chunks/{PkChatbotFilePreview-BsvT6orx.js → PkChatbotFilePreview-j_8sDZUE.js} +112 -71
  46. package/dist-vue/_chunks/PkChatbotFilePreview-j_8sDZUE.js.map +1 -0
  47. package/dist-vue/_chunks/PkChatbotInput-BmTdIJZ9.js +509 -0
  48. package/dist-vue/_chunks/PkChatbotInput-BmTdIJZ9.js.map +1 -0
  49. package/dist-vue/_chunks/PkChatbotMessages-b2lupEv9.js +1049 -0
  50. package/dist-vue/_chunks/{PkChatbotMessages-BISaZu4z.js.map → PkChatbotMessages-b2lupEv9.js.map} +1 -1
  51. package/dist-vue/_chunks/{PkChatbotStepPayload-cuYclK_2.js → PkChatbotStepPayload-D4w1XlF2.js} +2 -2
  52. package/dist-vue/_chunks/{PkChatbotStepPayload-cuYclK_2.js.map → PkChatbotStepPayload-D4w1XlF2.js.map} +1 -1
  53. package/dist-vue/_chunks/{PkChatbotStepToolDetail-Yd8cUQJP.js → PkChatbotStepToolDetail-DFTcjzoX.js} +3 -3
  54. package/dist-vue/_chunks/{PkChatbotStepToolDetail-Yd8cUQJP.js.map → PkChatbotStepToolDetail-DFTcjzoX.js.map} +1 -1
  55. package/dist-vue/_chunks/{PkChatbotSteps-_Aqft0em.js → PkChatbotSteps-D3zLulMo.js} +5 -5
  56. package/dist-vue/_chunks/{PkChatbotSteps-_Aqft0em.js.map → PkChatbotSteps-D3zLulMo.js.map} +1 -1
  57. package/dist-vue/_chunks/{PkChatbotViewChat-CIfotKyM.js → PkChatbotViewChat-DawyiUjq.js} +323 -345
  58. package/dist-vue/_chunks/PkChatbotViewChat-DawyiUjq.js.map +1 -0
  59. package/dist-vue/_chunks/{PkChatbotViewConversations-DjhiHp8-.js → PkChatbotViewConversations-Bs246dtL.js} +3 -3
  60. package/dist-vue/_chunks/{PkChatbotViewConversations-DjhiHp8-.js.map → PkChatbotViewConversations-Bs246dtL.js.map} +1 -1
  61. package/dist-vue/_chunks/{PkChatbotViewFiles-C4oGN4Xj.js → PkChatbotViewFiles-uzZ5H4Fd.js} +2 -2
  62. package/dist-vue/_chunks/{PkChatbotViewFiles-C4oGN4Xj.js.map → PkChatbotViewFiles-uzZ5H4Fd.js.map} +1 -1
  63. package/dist-vue/_chunks/{PkChatbotViewProfile-NfTamy9j.js → PkChatbotViewProfile-BhIvfT_n.js} +2 -2
  64. package/dist-vue/_chunks/{PkChatbotViewProfile-NfTamy9j.js.map → PkChatbotViewProfile-BhIvfT_n.js.map} +1 -1
  65. package/dist-vue/_chunks/{PkFilePreview-DEKgCMkr.js → PkFilePreview-DfD48QQ_.js} +48 -48
  66. package/dist-vue/_chunks/{PkFilePreview-DEKgCMkr.js.map → PkFilePreview-DfD48QQ_.js.map} +1 -1
  67. package/dist-vue/_chunks/{PkFilePreviewDialog-0qrzDWID.js → PkFilePreviewDialog-DFCBpQf3.js} +2 -2
  68. package/dist-vue/_chunks/{PkFilePreviewDialog-0qrzDWID.js.map → PkFilePreviewDialog-DFCBpQf3.js.map} +1 -1
  69. package/dist-vue/_chunks/PkImageEditorDialog-BLUyILVi.js +550 -0
  70. package/dist-vue/_chunks/PkImageEditorDialog-BLUyILVi.js.map +1 -0
  71. package/dist-vue/_chunks/{PkStreamingMarkdown-2FN4WMQD.js → PkStreamingMarkdown-ChMbSviw.js} +2 -2
  72. package/dist-vue/_chunks/{PkStreamingMarkdown-2FN4WMQD.js.map → PkStreamingMarkdown-ChMbSviw.js.map} +1 -1
  73. package/dist-vue/_chunks/{PkToolChatFile-DAT1tv52.js → PkToolChatFile-DQtABEaI.js} +3 -3
  74. package/dist-vue/_chunks/{PkToolChatFile-DAT1tv52.js.map → PkToolChatFile-DQtABEaI.js.map} +1 -1
  75. package/dist-vue/_chunks/{PkToolShareDocument-Qb2Lu5vh.js → PkToolShareDocument-cMUqik6v.js} +2 -2
  76. package/dist-vue/_chunks/{PkToolShareDocument-Qb2Lu5vh.js.map → PkToolShareDocument-cMUqik6v.js.map} +1 -1
  77. package/dist-vue/_chunks/{PkToolShowArtifact-Bskomw05.js → PkToolShowArtifact-w6SxjLPW.js} +2 -2
  78. package/dist-vue/_chunks/{PkToolShowArtifact-Bskomw05.js.map → PkToolShowArtifact-w6SxjLPW.js.map} +1 -1
  79. package/dist-vue/_chunks/{PkToolShowContactForm-iQrlqv7j.js → PkToolShowContactForm-BQ7bBTQU.js} +2 -2
  80. package/dist-vue/_chunks/{PkToolShowContactForm-iQrlqv7j.js.map → PkToolShowContactForm-BQ7bBTQU.js.map} +1 -1
  81. package/dist-vue/_chunks/{PkToolShowDiagram-C-43uUoh.js → PkToolShowDiagram-D-yQgdOL.js} +2 -2
  82. package/dist-vue/_chunks/{PkToolShowDiagram-C-43uUoh.js.map → PkToolShowDiagram-D-yQgdOL.js.map} +1 -1
  83. package/dist-vue/_chunks/{PkToolShowForm-CKXpqQxy.js → PkToolShowForm-CF00JLpa.js} +3 -3
  84. package/dist-vue/_chunks/{PkToolShowForm-CKXpqQxy.js.map → PkToolShowForm-CF00JLpa.js.map} +1 -1
  85. package/dist-vue/_chunks/{PkToolShowImageGallery-DLTn6JmU.js → PkToolShowImageGallery-ZJMWOWHq.js} +2 -2
  86. package/dist-vue/_chunks/{PkToolShowImageGallery-DLTn6JmU.js.map → PkToolShowImageGallery-ZJMWOWHq.js.map} +1 -1
  87. package/dist-vue/_chunks/{PkToolShowProductList-hhSBAQVC.js → PkToolShowProductList-CeKI9H36.js} +2 -2
  88. package/dist-vue/_chunks/{PkToolShowProductList-hhSBAQVC.js.map → PkToolShowProductList-CeKI9H36.js.map} +1 -1
  89. package/dist-vue/_chunks/{PkToolShowSources-BMo_i8sv.js → PkToolShowSources-CXZqanmw.js} +2 -2
  90. package/dist-vue/_chunks/{PkToolShowSources-BMo_i8sv.js.map → PkToolShowSources-CXZqanmw.js.map} +1 -1
  91. package/dist-vue/_chunks/{PkToolShowVideo-DJhsbDuX.js → PkToolShowVideo-BCs-i6xQ.js} +2 -2
  92. package/dist-vue/_chunks/{PkToolShowVideo-DJhsbDuX.js.map → PkToolShowVideo-BCs-i6xQ.js.map} +1 -1
  93. package/dist-vue/_chunks/{PkToolShowWebPages-BAv66f5H.js → PkToolShowWebPages-Bixa0CjQ.js} +2 -2
  94. package/dist-vue/_chunks/{PkToolShowWebPages-BAv66f5H.js.map → PkToolShowWebPages-Bixa0CjQ.js.map} +1 -1
  95. package/dist-vue/_chunks/{useChatbotStore-BZ1n3Hyx.js → useChatbotStore-BIjCGX0B.js} +858 -835
  96. package/dist-vue/_chunks/useChatbotStore-BIjCGX0B.js.map +1 -0
  97. package/dist-vue/_chunks/{utils-RwaXl9-x.js → utils-CaYEz-0A.js} +11 -4
  98. package/dist-vue/_chunks/utils-CaYEz-0A.js.map +1 -0
  99. package/dist-vue/composables.js +56 -4
  100. package/dist-vue/composables.js.map +1 -1
  101. package/dist-vue/index.js +49 -49
  102. package/dist-vue/index.js.map +1 -1
  103. package/dist-vue/locales.js +56 -0
  104. package/dist-vue/packages/components/src/chat/PkChatbotFilePreview.d.ts +14 -0
  105. package/dist-vue/packages/components/src/chat/PkChatbotInput.d.ts +17 -3
  106. package/dist-vue/packages/components/src/chat/PkImageEditor.d.ts +37 -0
  107. package/dist-vue/packages/components/src/chat/PkImageEditorDialog.d.ts +19 -0
  108. package/dist-vue/packages/components/src/chat/imageEdits.d.ts +106 -0
  109. package/dist-vue/packages/components/src/chat/utils.d.ts +7 -0
  110. package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +7 -1
  111. package/dist-vue/style.css +1 -1
  112. package/package.json +1 -1
  113. package/dist/_chunks/PkChatbotFilePreview-CFGqa-tX.js.map +0 -1
  114. package/dist/_chunks/utils-BZuri2jT.js.map +0 -1
  115. package/dist-vue/_chunks/PkChatbotFilePreview-BsvT6orx.js.map +0 -1
  116. package/dist-vue/_chunks/PkChatbotInput-D0KUEkAs.js +0 -478
  117. package/dist-vue/_chunks/PkChatbotInput-D0KUEkAs.js.map +0 -1
  118. package/dist-vue/_chunks/PkChatbotMessages-BISaZu4z.js +0 -1049
  119. package/dist-vue/_chunks/PkChatbotViewChat-CIfotKyM.js.map +0 -1
  120. package/dist-vue/_chunks/useChatbotStore-BZ1n3Hyx.js.map +0 -1
  121. package/dist-vue/_chunks/utils-RwaXl9-x.js.map +0 -1
@@ -532,7 +532,7 @@ function P() {
532
532
  }
533
533
  function St(e, t) {
534
534
  let n = { type: "array" };
535
- return e.type?._def && e.type?._def?.typeName !== "ZodAny" && (n.items = J(e.type._def, {
535
+ return e.type?._def && e.type?._def?.typeName !== "ZodAny" && (n.items = q(e.type._def, {
536
536
  ...t,
537
537
  currentPath: [...t.currentPath, "items"]
538
538
  })), e.minLength && (n.minItems = e.minLength.value), e.maxLength && (n.maxItems = e.maxLength.value), e.exactLength && (n.minItems = e.exactLength.value, n.maxItems = e.exactLength.value), n;
@@ -558,9 +558,9 @@ function wt() {
558
558
  return { type: "boolean" };
559
559
  }
560
560
  function Tt(e, t) {
561
- return J(e.type._def, t);
561
+ return q(e.type._def, t);
562
562
  }
563
- var F = (e, t) => J(e.innerType._def, t);
563
+ var F = (e, t) => q(e.innerType._def, t);
564
564
  function Et(e, t, n) {
565
565
  let r = n ?? t.dateStrategy;
566
566
  if (Array.isArray(r)) return { anyOf: r.map((n) => Et(e, t, n)) };
@@ -592,12 +592,12 @@ var Dt = (e) => {
592
592
  };
593
593
  function Ot(e, t) {
594
594
  return {
595
- ...J(e.innerType._def, t),
595
+ ...q(e.innerType._def, t),
596
596
  default: e.defaultValue()
597
597
  };
598
598
  }
599
599
  function I(e, t) {
600
- return t.effectStrategy === "input" ? J(e.schema._def, t) : P();
600
+ return t.effectStrategy === "input" ? q(e.schema._def, t) : P();
601
601
  }
602
602
  function L(e) {
603
603
  return {
@@ -607,14 +607,14 @@ function L(e) {
607
607
  }
608
608
  var R = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
609
609
  function kt(e, t) {
610
- let n = [J(e.left._def, {
610
+ let n = [q(e.left._def, {
611
611
  ...t,
612
612
  currentPath: [
613
613
  ...t.currentPath,
614
614
  "allOf",
615
615
  "0"
616
616
  ]
617
- }), J(e.right._def, {
617
+ }), q(e.right._def, {
618
618
  ...t,
619
619
  currentPath: [
620
620
  ...t.currentPath,
@@ -812,7 +812,7 @@ function Ft(e, t) {
812
812
  function It(e, t) {
813
813
  let n = {
814
814
  type: "object",
815
- additionalProperties: J(e.valueType._def, {
815
+ additionalProperties: q(e.valueType._def, {
816
816
  ...t,
817
817
  currentPath: [...t.currentPath, "additionalProperties"]
818
818
  }) ?? t.allowedAdditionalProperties
@@ -843,7 +843,7 @@ function Lt(e, t) {
843
843
  maxItems: 125,
844
844
  items: {
845
845
  type: "array",
846
- items: [J(e.keyType._def, {
846
+ items: [q(e.keyType._def, {
847
847
  ...t,
848
848
  currentPath: [
849
849
  ...t.currentPath,
@@ -851,7 +851,7 @@ function Lt(e, t) {
851
851
  "items",
852
852
  "0"
853
853
  ]
854
- }) || P(), J(e.valueType._def, {
854
+ }) || P(), q(e.valueType._def, {
855
855
  ...t,
856
856
  currentPath: [
857
857
  ...t.currentPath,
@@ -920,7 +920,7 @@ function Vt(e, t) {
920
920
  return Ht(e, t);
921
921
  }
922
922
  var Ht = (e, t) => {
923
- let n = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map((e, n) => J(e._def, {
923
+ let n = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map((e, n) => q(e._def, {
924
924
  ...t,
925
925
  currentPath: [
926
926
  ...t.currentPath,
@@ -930,7 +930,7 @@ var Ht = (e, t) => {
930
930
  })).filter((e) => !!e && (!t.strictUnions || typeof e == "object" && Object.keys(e).length > 0));
931
931
  return n.length ? { anyOf: n } : void 0;
932
932
  };
933
- function W(e, t) {
933
+ function Ut(e, t) {
934
934
  if ([
935
935
  "ZodString",
936
936
  "ZodNumber",
@@ -938,7 +938,7 @@ function W(e, t) {
938
938
  "ZodBoolean",
939
939
  "ZodNull"
940
940
  ].includes(e.innerType._def.typeName) && (!e.innerType._def.checks || !e.innerType._def.checks.length)) return { type: [Bt[e.innerType._def.typeName], "null"] };
941
- let n = J(e.innerType._def, {
941
+ let n = q(e.innerType._def, {
942
942
  ...t,
943
943
  currentPath: [
944
944
  ...t.currentPath,
@@ -948,7 +948,7 @@ function W(e, t) {
948
948
  });
949
949
  return n && { anyOf: [n, { type: "null" }] };
950
950
  }
951
- function Ut(e) {
951
+ function Wt(e) {
952
952
  let t = { type: "number" };
953
953
  if (!e.checks) return t;
954
954
  for (let n of e.checks) switch (n.kind) {
@@ -965,7 +965,7 @@ function Ut(e) {
965
965
  }
966
966
  return t;
967
967
  }
968
- function Wt(e, t) {
968
+ function Gt(e, t) {
969
969
  let n = {
970
970
  type: "object",
971
971
  properties: {}
@@ -973,7 +973,7 @@ function Wt(e, t) {
973
973
  for (let e in i) {
974
974
  let a = i[e];
975
975
  if (a === void 0 || a._def === void 0) continue;
976
- let o = Kt(a), s = J(a._def, {
976
+ let o = qt(a), s = q(a._def, {
977
977
  ...t,
978
978
  currentPath: [
979
979
  ...t.currentPath,
@@ -989,11 +989,11 @@ function Wt(e, t) {
989
989
  s !== void 0 && (n.properties[e] = s, o || r.push(e));
990
990
  }
991
991
  r.length && (n.required = r);
992
- let a = Gt(e, t);
992
+ let a = Kt(e, t);
993
993
  return a !== void 0 && (n.additionalProperties = a), n;
994
994
  }
995
- function Gt(e, t) {
996
- if (e.catchall._def.typeName !== "ZodNever") return J(e.catchall._def, {
995
+ function Kt(e, t) {
996
+ if (e.catchall._def.typeName !== "ZodNever") return q(e.catchall._def, {
997
997
  ...t,
998
998
  currentPath: [...t.currentPath, "additionalProperties"]
999
999
  });
@@ -1003,16 +1003,16 @@ function Gt(e, t) {
1003
1003
  case "strip": return t.removeAdditionalStrategy === "strict" ? t.allowedAdditionalProperties : t.rejectedAdditionalProperties;
1004
1004
  }
1005
1005
  }
1006
- function Kt(e) {
1006
+ function qt(e) {
1007
1007
  try {
1008
1008
  return e.isOptional();
1009
1009
  } catch {
1010
1010
  return !0;
1011
1011
  }
1012
1012
  }
1013
- var qt = (e, t) => {
1014
- if (t.currentPath.toString() === t.propertyPath?.toString()) return J(e.innerType._def, t);
1015
- let n = J(e.innerType._def, {
1013
+ var Jt = (e, t) => {
1014
+ if (t.currentPath.toString() === t.propertyPath?.toString()) return q(e.innerType._def, t);
1015
+ let n = q(e.innerType._def, {
1016
1016
  ...t,
1017
1017
  currentPath: [
1018
1018
  ...t.currentPath,
@@ -1021,10 +1021,10 @@ var qt = (e, t) => {
1021
1021
  ]
1022
1022
  });
1023
1023
  return n ? { anyOf: [{ not: P() }, n] } : P();
1024
- }, Jt = (e, t) => {
1025
- if (t.pipeStrategy === "input") return J(e.in._def, t);
1026
- if (t.pipeStrategy === "output") return J(e.out._def, t);
1027
- let n = J(e.in._def, {
1024
+ }, Yt = (e, t) => {
1025
+ if (t.pipeStrategy === "input") return q(e.in._def, t);
1026
+ if (t.pipeStrategy === "output") return q(e.out._def, t);
1027
+ let n = q(e.in._def, {
1028
1028
  ...t,
1029
1029
  currentPath: [
1030
1030
  ...t.currentPath,
@@ -1032,7 +1032,7 @@ var qt = (e, t) => {
1032
1032
  "0"
1033
1033
  ]
1034
1034
  });
1035
- return { allOf: [n, J(e.out._def, {
1035
+ return { allOf: [n, q(e.out._def, {
1036
1036
  ...t,
1037
1037
  currentPath: [
1038
1038
  ...t.currentPath,
@@ -1041,25 +1041,25 @@ var qt = (e, t) => {
1041
1041
  ]
1042
1042
  })].filter((e) => e !== void 0) };
1043
1043
  };
1044
- function Yt(e, t) {
1045
- return J(e.type._def, t);
1046
- }
1047
1044
  function Xt(e, t) {
1045
+ return q(e.type._def, t);
1046
+ }
1047
+ function Zt(e, t) {
1048
1048
  let n = {
1049
1049
  type: "array",
1050
1050
  uniqueItems: !0,
1051
- items: J(e.valueType._def, {
1051
+ items: q(e.valueType._def, {
1052
1052
  ...t,
1053
1053
  currentPath: [...t.currentPath, "items"]
1054
1054
  })
1055
1055
  };
1056
1056
  return e.minSize && (n.minItems = e.minSize.value), e.maxSize && (n.maxItems = e.maxSize.value), n;
1057
1057
  }
1058
- function Zt(e, t) {
1058
+ function Qt(e, t) {
1059
1059
  return e.rest ? {
1060
1060
  type: "array",
1061
1061
  minItems: e.items.length,
1062
- items: e.items.map((e, n) => J(e._def, {
1062
+ items: e.items.map((e, n) => q(e._def, {
1063
1063
  ...t,
1064
1064
  currentPath: [
1065
1065
  ...t.currentPath,
@@ -1067,7 +1067,7 @@ function Zt(e, t) {
1067
1067
  `${n}`
1068
1068
  ]
1069
1069
  })).reduce((e, t) => t === void 0 ? e : [...e, t], []),
1070
- additionalItems: J(e.rest._def, {
1070
+ additionalItems: q(e.rest._def, {
1071
1071
  ...t,
1072
1072
  currentPath: [...t.currentPath, "additionalItems"]
1073
1073
  })
@@ -1075,7 +1075,7 @@ function Zt(e, t) {
1075
1075
  type: "array",
1076
1076
  minItems: e.items.length,
1077
1077
  maxItems: e.items.length,
1078
- items: e.items.map((e, n) => J(e._def, {
1078
+ items: e.items.map((e, n) => q(e._def, {
1079
1079
  ...t,
1080
1080
  currentPath: [
1081
1081
  ...t.currentPath,
@@ -1085,47 +1085,47 @@ function Zt(e, t) {
1085
1085
  })).reduce((e, t) => t === void 0 ? e : [...e, t], [])
1086
1086
  };
1087
1087
  }
1088
- function Qt() {
1088
+ function $t() {
1089
1089
  return { not: P() };
1090
1090
  }
1091
- function $t() {
1091
+ function en() {
1092
1092
  return P();
1093
1093
  }
1094
- var G = (e, t) => J(e.innerType._def, t), K = (e, t, n) => {
1094
+ var W = (e, t) => q(e.innerType._def, t), G = (e, t, n) => {
1095
1095
  switch (t) {
1096
1096
  case "ZodString": return Mt(e, n);
1097
- case "ZodNumber": return Ut(e);
1098
- case "ZodObject": return Wt(e, n);
1097
+ case "ZodNumber": return Wt(e);
1098
+ case "ZodObject": return Gt(e, n);
1099
1099
  case "ZodBigInt": return Ct(e);
1100
1100
  case "ZodBoolean": return wt();
1101
1101
  case "ZodDate": return Et(e, n);
1102
- case "ZodUndefined": return Qt();
1102
+ case "ZodUndefined": return $t();
1103
1103
  case "ZodNull": return zt();
1104
1104
  case "ZodArray": return St(e, n);
1105
1105
  case "ZodUnion":
1106
1106
  case "ZodDiscriminatedUnion": return Vt(e, n);
1107
1107
  case "ZodIntersection": return kt(e, n);
1108
- case "ZodTuple": return Zt(e, n);
1108
+ case "ZodTuple": return Qt(e, n);
1109
1109
  case "ZodRecord": return It(e, n);
1110
1110
  case "ZodLiteral": return At(e);
1111
1111
  case "ZodEnum": return L(e);
1112
1112
  case "ZodNativeEnum": return U(e);
1113
- case "ZodNullable": return W(e, n);
1114
- case "ZodOptional": return qt(e, n);
1113
+ case "ZodNullable": return Ut(e, n);
1114
+ case "ZodOptional": return Jt(e, n);
1115
1115
  case "ZodMap": return Lt(e, n);
1116
- case "ZodSet": return Xt(e, n);
1116
+ case "ZodSet": return Zt(e, n);
1117
1117
  case "ZodLazy": return () => e.getter()._def;
1118
- case "ZodPromise": return Yt(e, n);
1118
+ case "ZodPromise": return Xt(e, n);
1119
1119
  case "ZodNaN":
1120
1120
  case "ZodNever": return Rt();
1121
1121
  case "ZodEffects": return I(e, n);
1122
1122
  case "ZodAny": return P();
1123
- case "ZodUnknown": return $t();
1123
+ case "ZodUnknown": return en();
1124
1124
  case "ZodDefault": return Ot(e, n);
1125
1125
  case "ZodBranded": return Tt(e, n);
1126
- case "ZodReadonly": return G(e, n);
1126
+ case "ZodReadonly": return W(e, n);
1127
1127
  case "ZodCatch": return F(e, n);
1128
- case "ZodPipeline": return Jt(e, n);
1128
+ case "ZodPipeline": return Yt(e, n);
1129
1129
  case "ZodFunction":
1130
1130
  case "ZodVoid":
1131
1131
  case "ZodSymbol": return;
@@ -1133,19 +1133,19 @@ var G = (e, t) => J(e.innerType._def, t), K = (e, t, n) => {
1133
1133
  /* c8 ignore next */
1134
1134
  return ((e) => void 0)(t);
1135
1135
  }
1136
- }, q = (e, t) => {
1136
+ }, K = (e, t) => {
1137
1137
  let n = 0;
1138
1138
  for (; n < e.length && n < t.length && e[n] === t[n]; n++);
1139
1139
  return [(e.length - n).toString(), ...t.slice(n)].join("/");
1140
1140
  };
1141
- function J(e, t, n = !1) {
1141
+ function q(e, t, n = !1) {
1142
1142
  let r = t.seen.get(e);
1143
1143
  if (t.override) {
1144
1144
  let i = t.override?.(e, t, r, n);
1145
1145
  if (i !== yt) return i;
1146
1146
  }
1147
1147
  if (r && !n) {
1148
- let e = en(r, t);
1148
+ let e = tn(r, t);
1149
1149
  if (e !== void 0) return e;
1150
1150
  }
1151
1151
  let i = {
@@ -1154,21 +1154,21 @@ function J(e, t, n = !1) {
1154
1154
  jsonSchema: void 0
1155
1155
  };
1156
1156
  t.seen.set(e, i);
1157
- let a = K(e, e.typeName, t), o = typeof a == "function" ? J(a(), t) : a;
1158
- if (o && tn(e, t, o), t.postProcess) {
1157
+ let a = G(e, e.typeName, t), o = typeof a == "function" ? q(a(), t) : a;
1158
+ if (o && nn(e, t, o), t.postProcess) {
1159
1159
  let n = t.postProcess(o, e, t);
1160
1160
  return i.jsonSchema = o, n;
1161
1161
  }
1162
1162
  return i.jsonSchema = o, o;
1163
1163
  }
1164
- var en = (e, t) => {
1164
+ var tn = (e, t) => {
1165
1165
  switch (t.$refStrategy) {
1166
1166
  case "root": return { $ref: e.path.join("/") };
1167
- case "relative": return { $ref: q(t.currentPath, e.path) };
1167
+ case "relative": return { $ref: K(t.currentPath, e.path) };
1168
1168
  case "none":
1169
1169
  case "seen": return e.path.length < t.currentPath.length && e.path.every((e, n) => t.currentPath[n] === e) ? (console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`), P()) : t.$refStrategy === "seen" ? P() : void 0;
1170
1170
  }
1171
- }, tn = (e, t, n) => (e.description && (n.description = e.description), n), nn = (e) => {
1171
+ }, nn = (e, t, n) => (e.description && (n.description = e.description), n), rn = (e) => {
1172
1172
  let t = xt(e), n = t.name === void 0 ? t.basePath : [
1173
1173
  ...t.basePath,
1174
1174
  t.definitionPath,
@@ -1188,10 +1188,10 @@ var en = (e, t) => {
1188
1188
  jsonSchema: void 0
1189
1189
  }]))
1190
1190
  };
1191
- }, rn = (e, t) => {
1192
- let n = nn(t), r = typeof t == "object" && t.definitions ? Object.entries(t.definitions).reduce((e, [t, r]) => ({
1191
+ }, an = (e, t) => {
1192
+ let n = rn(t), r = typeof t == "object" && t.definitions ? Object.entries(t.definitions).reduce((e, [t, r]) => ({
1193
1193
  ...e,
1194
- [t]: J(r._def, {
1194
+ [t]: q(r._def, {
1195
1195
  ...n,
1196
1196
  currentPath: [
1197
1197
  ...n.basePath,
@@ -1199,7 +1199,7 @@ var en = (e, t) => {
1199
1199
  t
1200
1200
  ]
1201
1201
  }, !0) ?? P()
1202
- }), {}) : void 0, i = typeof t == "string" ? t : t?.nameStrategy === "title" ? void 0 : t?.name, a = J(e._def, i === void 0 ? n : {
1202
+ }), {}) : void 0, i = typeof t == "string" ? t : t?.nameStrategy === "title" ? void 0 : t?.name, a = q(e._def, i === void 0 ? n : {
1203
1203
  ...n,
1204
1204
  currentPath: [
1205
1205
  ...n.basePath,
@@ -1223,14 +1223,14 @@ var en = (e, t) => {
1223
1223
  }
1224
1224
  };
1225
1225
  return s.$schema = "http://json-schema.org/draft-07/schema#", s;
1226
- }, an = Symbol.for("vercel.ai.schema");
1227
- function on(e) {
1226
+ }, on = Symbol.for("vercel.ai.schema");
1227
+ function sn(e) {
1228
1228
  let t;
1229
1229
  return () => (t ??= e(), t);
1230
1230
  }
1231
- function sn(e, { validate: t } = {}) {
1231
+ function cn(e, { validate: t } = {}) {
1232
1232
  return {
1233
- [an]: !0,
1233
+ [on]: !0,
1234
1234
  _type: void 0,
1235
1235
  get jsonSchema() {
1236
1236
  return typeof e == "function" && (e = e()), e;
@@ -1238,19 +1238,19 @@ function sn(e, { validate: t } = {}) {
1238
1238
  validate: t
1239
1239
  };
1240
1240
  }
1241
- function cn(e) {
1242
- return typeof e == "object" && !!e && an in e && e[an] === !0 && "jsonSchema" in e && "validate" in e;
1243
- }
1244
1241
  function ln(e) {
1245
- return e == null ? sn({
1242
+ return typeof e == "object" && !!e && on in e && e[on] === !0 && "jsonSchema" in e && "validate" in e;
1243
+ }
1244
+ function un(e) {
1245
+ return e == null ? cn({
1246
1246
  type: "object",
1247
1247
  properties: {},
1248
1248
  additionalProperties: !1
1249
- }) : cn(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? hn(e) : un(e) : e();
1249
+ }) : ln(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? gn(e) : dn(e) : e();
1250
1250
  }
1251
- function un(e) {
1252
- return sn(() => {
1253
- if (!dn(e)) throw Error(`Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`);
1251
+ function dn(e) {
1252
+ return cn(() => {
1253
+ if (!fn(e)) throw Error(`Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`);
1254
1254
  return vt(e["~standard"].jsonSchema.input({ target: "draft-07" }));
1255
1255
  }, { validate: async (t) => {
1256
1256
  let n = await e["~standard"].validate(t);
@@ -1266,12 +1266,12 @@ function un(e) {
1266
1266
  };
1267
1267
  } });
1268
1268
  }
1269
- function dn(e) {
1269
+ function fn(e) {
1270
1270
  return e["~standard"].jsonSchema != null;
1271
1271
  }
1272
- function fn(e, t) {
1272
+ function pn(e, t) {
1273
1273
  let n = t?.useReferences ?? !1;
1274
- return sn(() => rn(e, { $refStrategy: n ? "root" : "none" }), { validate: async (t) => {
1274
+ return cn(() => an(e, { $refStrategy: n ? "root" : "none" }), { validate: async (t) => {
1275
1275
  let n = await e.safeParseAsync(t);
1276
1276
  return n.success ? {
1277
1277
  success: !0,
@@ -1282,9 +1282,9 @@ function fn(e, t) {
1282
1282
  };
1283
1283
  } });
1284
1284
  }
1285
- function pn(e, r) {
1285
+ function mn(e, r) {
1286
1286
  let i = r?.useReferences ?? !1;
1287
- return sn(() => vt(n(e, {
1287
+ return cn(() => vt(n(e, {
1288
1288
  target: "draft-7",
1289
1289
  io: "input",
1290
1290
  reused: i ? "ref" : "inline"
@@ -1299,14 +1299,14 @@ function pn(e, r) {
1299
1299
  };
1300
1300
  } });
1301
1301
  }
1302
- function mn(e) {
1302
+ function hn(e) {
1303
1303
  return "_zod" in e;
1304
1304
  }
1305
- function hn(e, t) {
1306
- return mn(e) ? pn(e, t) : fn(e, t);
1305
+ function gn(e, t) {
1306
+ return hn(e) ? mn(e, t) : pn(e, t);
1307
1307
  }
1308
- async function gn({ value: e, schema: t, context: n }) {
1309
- let r = await _n({
1308
+ async function _n({ value: e, schema: t, context: n }) {
1309
+ let r = await vn({
1310
1310
  value: e,
1311
1311
  schema: t,
1312
1312
  context: n
@@ -1318,8 +1318,8 @@ async function gn({ value: e, schema: t, context: n }) {
1318
1318
  });
1319
1319
  return r.value;
1320
1320
  }
1321
- async function _n({ value: e, schema: t, context: n }) {
1322
- let r = ln(t);
1321
+ async function vn({ value: e, schema: t, context: n }) {
1322
+ let r = un(t);
1323
1323
  try {
1324
1324
  if (r.validate == null) return {
1325
1325
  success: !0,
@@ -1352,14 +1352,14 @@ async function _n({ value: e, schema: t, context: n }) {
1352
1352
  };
1353
1353
  }
1354
1354
  }
1355
- async function vn({ text: e, schema: t }) {
1355
+ async function yn({ text: e, schema: t }) {
1356
1356
  try {
1357
1357
  let n = M(e);
1358
1358
  return t == null ? {
1359
1359
  success: !0,
1360
1360
  value: n,
1361
1361
  rawValue: n
1362
- } : await _n({
1362
+ } : await vn({
1363
1363
  value: n,
1364
1364
  schema: t
1365
1365
  });
@@ -1374,41 +1374,41 @@ async function vn({ text: e, schema: t }) {
1374
1374
  };
1375
1375
  }
1376
1376
  }
1377
- function yn({ stream: e, schema: t }) {
1377
+ function bn({ stream: e, schema: t }) {
1378
1378
  return e.pipeThrough(new TextDecoderStream()).pipeThrough(new lt()).pipeThrough(new TransformStream({ async transform({ data: e }, n) {
1379
- e !== "[DONE]" && n.enqueue(await vn({
1379
+ e !== "[DONE]" && n.enqueue(await yn({
1380
1380
  text: e,
1381
1381
  schema: t
1382
1382
  }));
1383
1383
  } }));
1384
1384
  }
1385
- async function bn(e) {
1385
+ async function xn(e) {
1386
1386
  return typeof e == "function" && (e = e()), e;
1387
1387
  }
1388
1388
  new TextDecoder();
1389
1389
  // ../../node_modules/.pnpm/ai@7.0.154_zod@4.6.7/node_modules/ai/dist/index.js
1390
- var xn = "AI_InvalidArgumentError", Y = `vercel.ai.error.${xn}`, Sn = Symbol.for(Y), Cn = class extends w {
1390
+ var Sn = "AI_InvalidArgumentError", J = `vercel.ai.error.${Sn}`, Cn = Symbol.for(J), wn = class extends w {
1391
1391
  constructor({ parameter: e, value: t, message: n }) {
1392
1392
  super({
1393
- name: xn,
1393
+ name: Sn,
1394
1394
  message: `Invalid argument for parameter ${e}: ${n}`
1395
- }), this[Sn] = !0, this.parameter = e, this.value = t;
1395
+ }), this[Cn] = !0, this.parameter = e, this.value = t;
1396
1396
  }
1397
1397
  static isInstance(e) {
1398
- return w.hasMarker(e, Y);
1398
+ return w.hasMarker(e, J);
1399
1399
  }
1400
- }, wn = "AI_UIMessageStreamError", Tn = `vercel.ai.error.${wn}`, En = Symbol.for(Tn), Dn = class extends w {
1400
+ }, Tn = "AI_UIMessageStreamError", En = `vercel.ai.error.${Tn}`, Dn = Symbol.for(En), On = class extends w {
1401
1401
  constructor({ chunkType: e, chunkId: t, message: n }) {
1402
1402
  super({
1403
- name: wn,
1403
+ name: Tn,
1404
1404
  message: n
1405
- }), this[En] = !0, this.chunkType = e, this.chunkId = t;
1405
+ }), this[Dn] = !0, this.chunkType = e, this.chunkId = t;
1406
1406
  }
1407
1407
  static isInstance(e) {
1408
- return w.hasMarker(e, Tn);
1408
+ return w.hasMarker(e, En);
1409
1409
  }
1410
1410
  };
1411
- function On(e, t) {
1411
+ function kn(e, t) {
1412
1412
  if (e === void 0 && t === void 0) return;
1413
1413
  if (e === void 0) return t;
1414
1414
  if (t === void 0) return e;
@@ -1417,11 +1417,11 @@ function On(e, t) {
1417
1417
  let i = t[r];
1418
1418
  if (i === void 0) continue;
1419
1419
  let a = r in e ? e[r] : void 0, o = typeof i == "object" && !!i && !Array.isArray(i) && !(i instanceof Date) && !(i instanceof RegExp), s = typeof a == "object" && !!a && !Array.isArray(a) && !(a instanceof Date) && !(a instanceof RegExp);
1420
- n[r] = o && s ? On(a, i) : i;
1420
+ n[r] = o && s ? kn(a, i) : i;
1421
1421
  }
1422
1422
  return n;
1423
1423
  }
1424
- var X = {
1424
+ var Y = {
1425
1425
  array: d,
1426
1426
  boolean: m,
1427
1427
  custom: l,
@@ -1439,236 +1439,236 @@ var X = {
1439
1439
  string: r,
1440
1440
  union: e,
1441
1441
  unknown: _
1442
- }, kn = X.lazy(() => X.union([
1443
- X.null(),
1444
- X.string(),
1445
- X.number(),
1446
- X.boolean(),
1447
- X.record(X.string(), kn.optional()),
1448
- X.array(kn)
1449
- ])), Z = X.record(X.string(), X.record(X.string(), kn.optional())), An = X.union([
1450
- X.string(),
1451
- X.instanceof(Uint8Array),
1452
- X.instanceof(ArrayBuffer),
1453
- X.custom(pt, { message: "Must be a Buffer" })
1454
- ]), jn = X.record(X.string(), X.string()), Mn = X.object({
1455
- type: X.literal("text"),
1456
- text: X.string(),
1457
- providerOptions: Z.optional()
1458
- }), Nn = X.object({
1459
- type: X.literal("image"),
1460
- image: X.union([
1461
- An,
1462
- X.instanceof(URL),
1463
- jn
1442
+ }, An = Y.lazy(() => Y.union([
1443
+ Y.null(),
1444
+ Y.string(),
1445
+ Y.number(),
1446
+ Y.boolean(),
1447
+ Y.record(Y.string(), An.optional()),
1448
+ Y.array(An)
1449
+ ])), X = Y.record(Y.string(), Y.record(Y.string(), An.optional())), jn = Y.union([
1450
+ Y.string(),
1451
+ Y.instanceof(Uint8Array),
1452
+ Y.instanceof(ArrayBuffer),
1453
+ Y.custom(pt, { message: "Must be a Buffer" })
1454
+ ]), Mn = Y.record(Y.string(), Y.string()), Nn = Y.object({
1455
+ type: Y.literal("text"),
1456
+ text: Y.string(),
1457
+ providerOptions: X.optional()
1458
+ }), Pn = Y.object({
1459
+ type: Y.literal("image"),
1460
+ image: Y.union([
1461
+ jn,
1462
+ Y.instanceof(URL),
1463
+ Mn
1464
1464
  ]),
1465
- mediaType: X.string().optional(),
1466
- providerOptions: Z.optional()
1467
- }), Pn = X.discriminatedUnion("type", [
1468
- X.object({
1469
- type: X.literal("data"),
1470
- data: An
1465
+ mediaType: Y.string().optional(),
1466
+ providerOptions: X.optional()
1467
+ }), Fn = Y.discriminatedUnion("type", [
1468
+ Y.object({
1469
+ type: Y.literal("data"),
1470
+ data: jn
1471
1471
  }),
1472
- X.object({
1473
- type: X.literal("url"),
1474
- url: X.instanceof(URL)
1472
+ Y.object({
1473
+ type: Y.literal("url"),
1474
+ url: Y.instanceof(URL)
1475
1475
  }),
1476
- X.object({
1477
- type: X.literal("reference"),
1478
- reference: jn
1476
+ Y.object({
1477
+ type: Y.literal("reference"),
1478
+ reference: Mn
1479
1479
  }),
1480
- X.object({
1481
- type: X.literal("text"),
1482
- text: X.string()
1480
+ Y.object({
1481
+ type: Y.literal("text"),
1482
+ text: Y.string()
1483
1483
  })
1484
- ]), Fn = X.discriminatedUnion("type", [X.object({
1485
- type: X.literal("data"),
1486
- data: An
1487
- }), X.object({
1488
- type: X.literal("url"),
1489
- url: X.instanceof(URL)
1490
- })]), In = X.object({
1491
- type: X.literal("file"),
1492
- data: X.union([
1493
- Pn,
1494
- An,
1495
- X.instanceof(URL),
1496
- jn
1497
- ]),
1498
- filename: X.string().optional(),
1499
- mediaType: X.string(),
1500
- providerOptions: Z.optional()
1501
- }), Ln = X.object({
1502
- type: X.literal("reasoning"),
1503
- text: X.string(),
1504
- providerOptions: Z.optional()
1505
- }), Rn = X.object({
1506
- type: X.literal("custom"),
1507
- kind: X.string().transform((e) => e),
1508
- providerOptions: Z.optional()
1509
- }), zn = X.object({
1510
- type: X.literal("reasoning-file"),
1511
- data: X.union([
1484
+ ]), In = Y.discriminatedUnion("type", [Y.object({
1485
+ type: Y.literal("data"),
1486
+ data: jn
1487
+ }), Y.object({
1488
+ type: Y.literal("url"),
1489
+ url: Y.instanceof(URL)
1490
+ })]), Ln = Y.object({
1491
+ type: Y.literal("file"),
1492
+ data: Y.union([
1512
1493
  Fn,
1513
- An,
1514
- X.instanceof(URL)
1494
+ jn,
1495
+ Y.instanceof(URL),
1496
+ Mn
1515
1497
  ]),
1516
- mediaType: X.string(),
1517
- providerOptions: Z.optional()
1518
- }), Bn = X.object({
1519
- type: X.literal("tool-call"),
1520
- toolCallId: X.string(),
1521
- toolName: X.string(),
1522
- input: X.unknown(),
1523
- providerOptions: Z.optional(),
1524
- providerExecuted: X.boolean().optional()
1525
- }), Vn = X.discriminatedUnion("type", [
1526
- X.object({
1527
- type: X.literal("text"),
1528
- value: X.string(),
1529
- providerOptions: Z.optional()
1498
+ filename: Y.string().optional(),
1499
+ mediaType: Y.string(),
1500
+ providerOptions: X.optional()
1501
+ }), Rn = Y.object({
1502
+ type: Y.literal("reasoning"),
1503
+ text: Y.string(),
1504
+ providerOptions: X.optional()
1505
+ }), zn = Y.object({
1506
+ type: Y.literal("custom"),
1507
+ kind: Y.string().transform((e) => e),
1508
+ providerOptions: X.optional()
1509
+ }), Bn = Y.object({
1510
+ type: Y.literal("reasoning-file"),
1511
+ data: Y.union([
1512
+ In,
1513
+ jn,
1514
+ Y.instanceof(URL)
1515
+ ]),
1516
+ mediaType: Y.string(),
1517
+ providerOptions: X.optional()
1518
+ }), Vn = Y.object({
1519
+ type: Y.literal("tool-call"),
1520
+ toolCallId: Y.string(),
1521
+ toolName: Y.string(),
1522
+ input: Y.unknown(),
1523
+ providerOptions: X.optional(),
1524
+ providerExecuted: Y.boolean().optional()
1525
+ }), Hn = Y.discriminatedUnion("type", [
1526
+ Y.object({
1527
+ type: Y.literal("text"),
1528
+ value: Y.string(),
1529
+ providerOptions: X.optional()
1530
1530
  }),
1531
- X.object({
1532
- type: X.literal("json"),
1533
- value: kn,
1534
- providerOptions: Z.optional()
1531
+ Y.object({
1532
+ type: Y.literal("json"),
1533
+ value: An,
1534
+ providerOptions: X.optional()
1535
1535
  }),
1536
- X.object({
1537
- type: X.literal("execution-denied"),
1538
- reason: X.string().optional(),
1539
- providerOptions: Z.optional()
1536
+ Y.object({
1537
+ type: Y.literal("execution-denied"),
1538
+ reason: Y.string().optional(),
1539
+ providerOptions: X.optional()
1540
1540
  }),
1541
- X.object({
1542
- type: X.literal("error-text"),
1543
- value: X.string(),
1544
- providerOptions: Z.optional()
1541
+ Y.object({
1542
+ type: Y.literal("error-text"),
1543
+ value: Y.string(),
1544
+ providerOptions: X.optional()
1545
1545
  }),
1546
- X.object({
1547
- type: X.literal("error-json"),
1548
- value: kn,
1549
- providerOptions: Z.optional()
1546
+ Y.object({
1547
+ type: Y.literal("error-json"),
1548
+ value: An,
1549
+ providerOptions: X.optional()
1550
1550
  }),
1551
- X.object({
1552
- type: X.literal("content"),
1553
- value: X.array(X.union([
1554
- X.object({
1555
- type: X.literal("text"),
1556
- text: X.string(),
1557
- providerOptions: Z.optional()
1551
+ Y.object({
1552
+ type: Y.literal("content"),
1553
+ value: Y.array(Y.union([
1554
+ Y.object({
1555
+ type: Y.literal("text"),
1556
+ text: Y.string(),
1557
+ providerOptions: X.optional()
1558
1558
  }),
1559
- X.object({
1560
- type: X.literal("file"),
1561
- data: Pn,
1562
- mediaType: X.string(),
1563
- filename: X.string().optional(),
1564
- providerOptions: Z.optional()
1559
+ Y.object({
1560
+ type: Y.literal("file"),
1561
+ data: Fn,
1562
+ mediaType: Y.string(),
1563
+ filename: Y.string().optional(),
1564
+ providerOptions: X.optional()
1565
1565
  }),
1566
- X.object({
1567
- type: X.literal("file-data"),
1568
- data: X.string(),
1569
- mediaType: X.string(),
1570
- filename: X.string().optional(),
1571
- providerOptions: Z.optional()
1566
+ Y.object({
1567
+ type: Y.literal("file-data"),
1568
+ data: Y.string(),
1569
+ mediaType: Y.string(),
1570
+ filename: Y.string().optional(),
1571
+ providerOptions: X.optional()
1572
1572
  }),
1573
- X.object({
1574
- type: X.literal("file-url"),
1575
- url: X.string(),
1576
- mediaType: X.string().optional(),
1577
- providerOptions: Z.optional()
1573
+ Y.object({
1574
+ type: Y.literal("file-url"),
1575
+ url: Y.string(),
1576
+ mediaType: Y.string().optional(),
1577
+ providerOptions: X.optional()
1578
1578
  }),
1579
- X.object({
1580
- type: X.literal("file-id"),
1581
- fileId: X.union([X.string(), X.record(X.string(), X.string())]),
1582
- providerOptions: Z.optional()
1579
+ Y.object({
1580
+ type: Y.literal("file-id"),
1581
+ fileId: Y.union([Y.string(), Y.record(Y.string(), Y.string())]),
1582
+ providerOptions: X.optional()
1583
1583
  }),
1584
- X.object({
1585
- type: X.literal("file-reference"),
1586
- providerReference: X.record(X.string(), X.string()),
1587
- providerOptions: Z.optional()
1584
+ Y.object({
1585
+ type: Y.literal("file-reference"),
1586
+ providerReference: Y.record(Y.string(), Y.string()),
1587
+ providerOptions: X.optional()
1588
1588
  }),
1589
- X.object({
1590
- type: X.literal("image-data"),
1591
- data: X.string(),
1592
- mediaType: X.string(),
1593
- providerOptions: Z.optional()
1589
+ Y.object({
1590
+ type: Y.literal("image-data"),
1591
+ data: Y.string(),
1592
+ mediaType: Y.string(),
1593
+ providerOptions: X.optional()
1594
1594
  }),
1595
- X.object({
1596
- type: X.literal("image-url"),
1597
- url: X.string(),
1598
- providerOptions: Z.optional()
1595
+ Y.object({
1596
+ type: Y.literal("image-url"),
1597
+ url: Y.string(),
1598
+ providerOptions: X.optional()
1599
1599
  }),
1600
- X.object({
1601
- type: X.literal("image-file-id"),
1602
- fileId: X.union([X.string(), X.record(X.string(), X.string())]),
1603
- providerOptions: Z.optional()
1600
+ Y.object({
1601
+ type: Y.literal("image-file-id"),
1602
+ fileId: Y.union([Y.string(), Y.record(Y.string(), Y.string())]),
1603
+ providerOptions: X.optional()
1604
1604
  }),
1605
- X.object({
1606
- type: X.literal("image-file-reference"),
1607
- providerReference: X.record(X.string(), X.string()),
1608
- providerOptions: Z.optional()
1605
+ Y.object({
1606
+ type: Y.literal("image-file-reference"),
1607
+ providerReference: Y.record(Y.string(), Y.string()),
1608
+ providerOptions: X.optional()
1609
1609
  }),
1610
- X.object({
1611
- type: X.literal("custom"),
1612
- providerOptions: Z.optional()
1610
+ Y.object({
1611
+ type: Y.literal("custom"),
1612
+ providerOptions: X.optional()
1613
1613
  })
1614
1614
  ]))
1615
1615
  })
1616
- ]), Hn = X.object({
1617
- type: X.literal("tool-result"),
1618
- toolCallId: X.string(),
1619
- toolName: X.string(),
1620
- output: Vn,
1621
- providerOptions: Z.optional()
1622
- }), Un = X.object({
1623
- type: X.literal("tool-approval-request"),
1624
- approvalId: X.string(),
1625
- toolCallId: X.string(),
1626
- reason: X.string().optional(),
1627
- isAutomatic: X.boolean().optional(),
1628
- signature: X.string().optional(),
1629
- inputSchemaInput: X.unknown().optional()
1630
- }), Wn = X.object({
1631
- type: X.literal("tool-approval-response"),
1632
- approvalId: X.string(),
1633
- approved: X.boolean(),
1634
- reason: X.string().optional()
1635
- }), Gn = X.object({
1636
- role: X.literal("system"),
1637
- content: X.string(),
1638
- providerOptions: Z.optional()
1639
- }), Kn = X.object({
1640
- role: X.literal("user"),
1641
- content: X.union([X.string(), X.array(X.union([
1642
- Mn,
1616
+ ]), Un = Y.object({
1617
+ type: Y.literal("tool-result"),
1618
+ toolCallId: Y.string(),
1619
+ toolName: Y.string(),
1620
+ output: Hn,
1621
+ providerOptions: X.optional()
1622
+ }), Wn = Y.object({
1623
+ type: Y.literal("tool-approval-request"),
1624
+ approvalId: Y.string(),
1625
+ toolCallId: Y.string(),
1626
+ reason: Y.string().optional(),
1627
+ isAutomatic: Y.boolean().optional(),
1628
+ signature: Y.string().optional(),
1629
+ inputSchemaInput: Y.unknown().optional()
1630
+ }), Gn = Y.object({
1631
+ type: Y.literal("tool-approval-response"),
1632
+ approvalId: Y.string(),
1633
+ approved: Y.boolean(),
1634
+ reason: Y.string().optional()
1635
+ }), Kn = Y.object({
1636
+ role: Y.literal("system"),
1637
+ content: Y.string(),
1638
+ providerOptions: X.optional()
1639
+ }), qn = Y.object({
1640
+ role: Y.literal("user"),
1641
+ content: Y.union([Y.string(), Y.array(Y.union([
1643
1642
  Nn,
1644
- In
1643
+ Pn,
1644
+ Ln
1645
1645
  ]))]),
1646
- providerOptions: Z.optional()
1647
- }), qn = X.object({
1648
- role: X.literal("assistant"),
1649
- content: X.union([X.string(), X.array(X.union([
1650
- Mn,
1651
- Rn,
1652
- In,
1653
- Ln,
1646
+ providerOptions: X.optional()
1647
+ }), Jn = Y.object({
1648
+ role: Y.literal("assistant"),
1649
+ content: Y.union([Y.string(), Y.array(Y.union([
1650
+ Nn,
1654
1651
  zn,
1652
+ Ln,
1653
+ Rn,
1655
1654
  Bn,
1656
- Hn,
1657
- Un
1655
+ Vn,
1656
+ Un,
1657
+ Wn
1658
1658
  ]))]),
1659
- providerOptions: Z.optional()
1660
- }), Jn = X.object({
1661
- role: X.literal("tool"),
1662
- content: X.array(X.union([Hn, Wn])),
1663
- providerOptions: Z.optional()
1659
+ providerOptions: X.optional()
1660
+ }), Yn = Y.object({
1661
+ role: Y.literal("tool"),
1662
+ content: Y.array(Y.union([Un, Gn])),
1663
+ providerOptions: X.optional()
1664
1664
  });
1665
- X.union([
1666
- Gn,
1665
+ Y.union([
1667
1666
  Kn,
1668
1667
  qn,
1669
- Jn
1668
+ Jn,
1669
+ Yn
1670
1670
  ]);
1671
- function Yn(e) {
1671
+ function Xn(e) {
1672
1672
  let t = ["ROOT"], n = -1, r = null, i = 0;
1673
1673
  function a(e) {
1674
1674
  return e >= "0" && e <= "9" || e >= "A" && e <= "F" || e >= "a" && e <= "f";
@@ -1850,16 +1850,16 @@ function Yn(e) {
1850
1850
  }
1851
1851
  return l;
1852
1852
  }
1853
- async function Xn(e) {
1853
+ async function Zn(e) {
1854
1854
  if (e === void 0) return {
1855
1855
  value: void 0,
1856
1856
  state: "undefined-input"
1857
1857
  };
1858
- let t = await vn({ text: e });
1858
+ let t = await yn({ text: e });
1859
1859
  return t.success ? {
1860
1860
  value: t.value,
1861
1861
  state: "successful-parse"
1862
- } : (t = await vn({ text: Yn(e) }), t.success ? {
1862
+ } : (t = await yn({ text: Xn(e) }), t.success ? {
1863
1863
  value: t.value,
1864
1864
  state: "repaired-parse"
1865
1865
  } : {
@@ -1877,193 +1877,193 @@ j({
1877
1877
  prefix: "call",
1878
1878
  size: 24
1879
1879
  }), TransformStream;
1880
- var Zn = X.object({
1881
- source: X.discriminatedUnion("sourceType", [X.object({
1882
- type: X.literal("source"),
1883
- sourceType: X.literal("url"),
1884
- id: X.string(),
1885
- url: X.string(),
1886
- title: X.string().optional(),
1887
- providerMetadata: Z.optional()
1888
- }), X.object({
1889
- type: X.literal("source"),
1890
- sourceType: X.literal("document"),
1891
- id: X.string(),
1892
- mediaType: X.string(),
1893
- title: X.string(),
1894
- filename: X.string().optional(),
1895
- providerMetadata: Z.optional()
1880
+ var Qn = Y.object({
1881
+ source: Y.discriminatedUnion("sourceType", [Y.object({
1882
+ type: Y.literal("source"),
1883
+ sourceType: Y.literal("url"),
1884
+ id: Y.string(),
1885
+ url: Y.string(),
1886
+ title: Y.string().optional(),
1887
+ providerMetadata: X.optional()
1888
+ }), Y.object({
1889
+ type: Y.literal("source"),
1890
+ sourceType: Y.literal("document"),
1891
+ id: Y.string(),
1892
+ mediaType: Y.string(),
1893
+ title: Y.string(),
1894
+ filename: Y.string().optional(),
1895
+ providerMetadata: X.optional()
1896
1896
  })]),
1897
- startIndex: X.number().int().nonnegative().optional(),
1898
- endIndex: X.number().int().nonnegative().optional(),
1899
- citedText: X.string().optional()
1900
- }), Qn = X.record(X.string(), kn.optional()), $n = on(() => hn(X.union([
1901
- X.looseObject({
1902
- type: X.literal("text-start"),
1903
- id: X.string(),
1904
- providerMetadata: Z.optional()
1897
+ startIndex: Y.number().int().nonnegative().optional(),
1898
+ endIndex: Y.number().int().nonnegative().optional(),
1899
+ citedText: Y.string().optional()
1900
+ }), $n = Y.record(Y.string(), An.optional()), er = sn(() => gn(Y.union([
1901
+ Y.looseObject({
1902
+ type: Y.literal("text-start"),
1903
+ id: Y.string(),
1904
+ providerMetadata: X.optional()
1905
1905
  }),
1906
- X.looseObject({
1907
- type: X.literal("text-delta"),
1908
- id: X.string(),
1909
- delta: X.string(),
1910
- providerMetadata: Z.optional()
1906
+ Y.looseObject({
1907
+ type: Y.literal("text-delta"),
1908
+ id: Y.string(),
1909
+ delta: Y.string(),
1910
+ providerMetadata: X.optional()
1911
1911
  }),
1912
- X.looseObject({
1913
- type: X.literal("text-end"),
1914
- id: X.string(),
1915
- citations: X.array(Zn).optional(),
1916
- providerMetadata: Z.optional()
1912
+ Y.looseObject({
1913
+ type: Y.literal("text-end"),
1914
+ id: Y.string(),
1915
+ citations: Y.array(Qn).optional(),
1916
+ providerMetadata: X.optional()
1917
1917
  }),
1918
- X.looseObject({
1919
- type: X.literal("error"),
1920
- errorText: X.string()
1918
+ Y.looseObject({
1919
+ type: Y.literal("error"),
1920
+ errorText: Y.string()
1921
1921
  }),
1922
- X.looseObject({
1923
- type: X.literal("tool-input-start"),
1924
- toolCallId: X.string(),
1925
- toolName: X.string(),
1926
- inputEncoding: X.enum(["json", "text"]).optional(),
1927
- providerExecuted: X.boolean().optional(),
1928
- providerMetadata: Z.optional(),
1929
- toolMetadata: Qn.optional(),
1930
- dynamic: X.boolean().optional(),
1931
- title: X.string().optional()
1922
+ Y.looseObject({
1923
+ type: Y.literal("tool-input-start"),
1924
+ toolCallId: Y.string(),
1925
+ toolName: Y.string(),
1926
+ inputEncoding: Y.enum(["json", "text"]).optional(),
1927
+ providerExecuted: Y.boolean().optional(),
1928
+ providerMetadata: X.optional(),
1929
+ toolMetadata: $n.optional(),
1930
+ dynamic: Y.boolean().optional(),
1931
+ title: Y.string().optional()
1932
1932
  }),
1933
- X.looseObject({
1934
- type: X.literal("tool-input-delta"),
1935
- toolCallId: X.string(),
1936
- inputTextDelta: X.string()
1933
+ Y.looseObject({
1934
+ type: Y.literal("tool-input-delta"),
1935
+ toolCallId: Y.string(),
1936
+ inputTextDelta: Y.string()
1937
1937
  }),
1938
- X.looseObject({
1939
- type: X.literal("tool-input-available"),
1940
- toolCallId: X.string(),
1941
- toolName: X.string(),
1942
- input: X.unknown(),
1943
- providerExecuted: X.boolean().optional(),
1944
- providerMetadata: Z.optional(),
1945
- toolMetadata: Qn.optional(),
1946
- dynamic: X.boolean().optional(),
1947
- title: X.string().optional()
1938
+ Y.looseObject({
1939
+ type: Y.literal("tool-input-available"),
1940
+ toolCallId: Y.string(),
1941
+ toolName: Y.string(),
1942
+ input: Y.unknown(),
1943
+ providerExecuted: Y.boolean().optional(),
1944
+ providerMetadata: X.optional(),
1945
+ toolMetadata: $n.optional(),
1946
+ dynamic: Y.boolean().optional(),
1947
+ title: Y.string().optional()
1948
1948
  }),
1949
- X.looseObject({
1950
- type: X.literal("tool-input-error"),
1951
- toolCallId: X.string(),
1952
- toolName: X.string(),
1953
- input: X.unknown(),
1954
- providerExecuted: X.boolean().optional(),
1955
- providerMetadata: Z.optional(),
1956
- toolMetadata: Qn.optional(),
1957
- dynamic: X.boolean().optional(),
1958
- errorText: X.string(),
1959
- title: X.string().optional()
1949
+ Y.looseObject({
1950
+ type: Y.literal("tool-input-error"),
1951
+ toolCallId: Y.string(),
1952
+ toolName: Y.string(),
1953
+ input: Y.unknown(),
1954
+ providerExecuted: Y.boolean().optional(),
1955
+ providerMetadata: X.optional(),
1956
+ toolMetadata: $n.optional(),
1957
+ dynamic: Y.boolean().optional(),
1958
+ errorText: Y.string(),
1959
+ title: Y.string().optional()
1960
1960
  }),
1961
- X.looseObject({
1962
- type: X.literal("tool-approval-request"),
1963
- approvalId: X.string(),
1964
- toolCallId: X.string(),
1965
- approvalDescriptor: X.unknown().optional(),
1966
- inputSchemaInput: X.unknown().optional(),
1967
- reason: X.string().optional(),
1968
- isAutomatic: X.boolean().optional(),
1969
- signature: X.string().optional()
1961
+ Y.looseObject({
1962
+ type: Y.literal("tool-approval-request"),
1963
+ approvalId: Y.string(),
1964
+ toolCallId: Y.string(),
1965
+ approvalDescriptor: Y.unknown().optional(),
1966
+ inputSchemaInput: Y.unknown().optional(),
1967
+ reason: Y.string().optional(),
1968
+ isAutomatic: Y.boolean().optional(),
1969
+ signature: Y.string().optional()
1970
1970
  }),
1971
- X.looseObject({
1972
- type: X.literal("tool-approval-response"),
1973
- approvalId: X.string(),
1974
- approved: X.boolean(),
1975
- reason: X.string().optional(),
1976
- providerExecuted: X.boolean().optional(),
1977
- providerMetadata: Z.optional()
1971
+ Y.looseObject({
1972
+ type: Y.literal("tool-approval-response"),
1973
+ approvalId: Y.string(),
1974
+ approved: Y.boolean(),
1975
+ reason: Y.string().optional(),
1976
+ providerExecuted: Y.boolean().optional(),
1977
+ providerMetadata: X.optional()
1978
1978
  }),
1979
- X.looseObject({
1980
- type: X.literal("tool-output-available"),
1981
- toolCallId: X.string(),
1982
- output: X.unknown(),
1983
- providerExecuted: X.boolean().optional(),
1984
- providerMetadata: Z.optional(),
1985
- toolMetadata: Qn.optional(),
1986
- dynamic: X.boolean().optional(),
1987
- preliminary: X.boolean().optional()
1979
+ Y.looseObject({
1980
+ type: Y.literal("tool-output-available"),
1981
+ toolCallId: Y.string(),
1982
+ output: Y.unknown(),
1983
+ providerExecuted: Y.boolean().optional(),
1984
+ providerMetadata: X.optional(),
1985
+ toolMetadata: $n.optional(),
1986
+ dynamic: Y.boolean().optional(),
1987
+ preliminary: Y.boolean().optional()
1988
1988
  }),
1989
- X.looseObject({
1990
- type: X.literal("tool-output-error"),
1991
- toolCallId: X.string(),
1992
- errorText: X.string(),
1993
- providerExecuted: X.boolean().optional(),
1994
- providerMetadata: Z.optional(),
1995
- toolMetadata: Qn.optional(),
1996
- dynamic: X.boolean().optional()
1989
+ Y.looseObject({
1990
+ type: Y.literal("tool-output-error"),
1991
+ toolCallId: Y.string(),
1992
+ errorText: Y.string(),
1993
+ providerExecuted: Y.boolean().optional(),
1994
+ providerMetadata: X.optional(),
1995
+ toolMetadata: $n.optional(),
1996
+ dynamic: Y.boolean().optional()
1997
1997
  }),
1998
- X.looseObject({
1999
- type: X.literal("tool-output-denied"),
2000
- toolCallId: X.string()
1998
+ Y.looseObject({
1999
+ type: Y.literal("tool-output-denied"),
2000
+ toolCallId: Y.string()
2001
2001
  }),
2002
- X.looseObject({
2003
- type: X.literal("reasoning-start"),
2004
- id: X.string(),
2005
- providerMetadata: Z.optional()
2002
+ Y.looseObject({
2003
+ type: Y.literal("reasoning-start"),
2004
+ id: Y.string(),
2005
+ providerMetadata: X.optional()
2006
2006
  }),
2007
- X.looseObject({
2008
- type: X.literal("reasoning-delta"),
2009
- id: X.string(),
2010
- delta: X.string(),
2011
- providerMetadata: Z.optional()
2007
+ Y.looseObject({
2008
+ type: Y.literal("reasoning-delta"),
2009
+ id: Y.string(),
2010
+ delta: Y.string(),
2011
+ providerMetadata: X.optional()
2012
2012
  }),
2013
- X.looseObject({
2014
- type: X.literal("reasoning-end"),
2015
- id: X.string(),
2016
- providerMetadata: Z.optional()
2013
+ Y.looseObject({
2014
+ type: Y.literal("reasoning-end"),
2015
+ id: Y.string(),
2016
+ providerMetadata: X.optional()
2017
2017
  }),
2018
- X.looseObject({
2019
- type: X.literal("custom"),
2020
- kind: X.string().transform((e) => e),
2021
- providerMetadata: Z.optional()
2018
+ Y.looseObject({
2019
+ type: Y.literal("custom"),
2020
+ kind: Y.string().transform((e) => e),
2021
+ providerMetadata: X.optional()
2022
2022
  }),
2023
- X.looseObject({
2024
- type: X.literal("source-url"),
2025
- sourceId: X.string(),
2026
- url: X.string(),
2027
- title: X.string().optional(),
2028
- providerMetadata: Z.optional()
2023
+ Y.looseObject({
2024
+ type: Y.literal("source-url"),
2025
+ sourceId: Y.string(),
2026
+ url: Y.string(),
2027
+ title: Y.string().optional(),
2028
+ providerMetadata: X.optional()
2029
2029
  }),
2030
- X.looseObject({
2031
- type: X.literal("source-document"),
2032
- sourceId: X.string(),
2033
- mediaType: X.string(),
2034
- title: X.string(),
2035
- filename: X.string().optional(),
2036
- providerMetadata: Z.optional()
2030
+ Y.looseObject({
2031
+ type: Y.literal("source-document"),
2032
+ sourceId: Y.string(),
2033
+ mediaType: Y.string(),
2034
+ title: Y.string(),
2035
+ filename: Y.string().optional(),
2036
+ providerMetadata: X.optional()
2037
2037
  }),
2038
- X.looseObject({
2039
- type: X.literal("file"),
2040
- url: X.string(),
2041
- mediaType: X.string(),
2042
- providerMetadata: Z.optional()
2038
+ Y.looseObject({
2039
+ type: Y.literal("file"),
2040
+ url: Y.string(),
2041
+ mediaType: Y.string(),
2042
+ providerMetadata: X.optional()
2043
2043
  }),
2044
- X.looseObject({
2045
- type: X.literal("reasoning-file"),
2046
- url: X.string(),
2047
- mediaType: X.string(),
2048
- providerMetadata: Z.optional()
2044
+ Y.looseObject({
2045
+ type: Y.literal("reasoning-file"),
2046
+ url: Y.string(),
2047
+ mediaType: Y.string(),
2048
+ providerMetadata: X.optional()
2049
2049
  }),
2050
- X.looseObject({
2051
- type: X.custom((e) => typeof e == "string" && e.startsWith("data-"), { message: "Type must start with \"data-\"" }),
2052
- id: X.string().optional(),
2053
- data: X.unknown(),
2054
- transient: X.boolean().optional()
2050
+ Y.looseObject({
2051
+ type: Y.custom((e) => typeof e == "string" && e.startsWith("data-"), { message: "Type must start with \"data-\"" }),
2052
+ id: Y.string().optional(),
2053
+ data: Y.unknown(),
2054
+ transient: Y.boolean().optional()
2055
2055
  }),
2056
- X.looseObject({ type: X.literal("start-step") }),
2057
- X.looseObject({ type: X.literal("finish-step") }),
2058
- X.looseObject({ type: X.literal("reset-step") }),
2059
- X.looseObject({
2060
- type: X.literal("start"),
2061
- messageId: X.string().optional(),
2062
- messageMetadata: X.unknown().optional()
2056
+ Y.looseObject({ type: Y.literal("start-step") }),
2057
+ Y.looseObject({ type: Y.literal("finish-step") }),
2058
+ Y.looseObject({ type: Y.literal("reset-step") }),
2059
+ Y.looseObject({
2060
+ type: Y.literal("start"),
2061
+ messageId: Y.string().optional(),
2062
+ messageMetadata: Y.unknown().optional()
2063
2063
  }),
2064
- X.looseObject({
2065
- type: X.literal("finish"),
2066
- finishReason: X.enum([
2064
+ Y.looseObject({
2065
+ type: Y.literal("finish"),
2066
+ finishReason: Y.enum([
2067
2067
  "stop",
2068
2068
  "length",
2069
2069
  "content-filter",
@@ -2072,50 +2072,50 @@ var Zn = X.object({
2072
2072
  "interrupted",
2073
2073
  "other"
2074
2074
  ]).optional(),
2075
- messageMetadata: X.unknown().optional()
2075
+ messageMetadata: Y.unknown().optional()
2076
2076
  }),
2077
- X.looseObject({
2078
- type: X.literal("abort"),
2079
- reason: X.string().optional()
2077
+ Y.looseObject({
2078
+ type: Y.literal("abort"),
2079
+ reason: Y.string().optional()
2080
2080
  }),
2081
- X.looseObject({
2082
- type: X.literal("message-metadata"),
2083
- messageMetadata: X.unknown()
2081
+ Y.looseObject({
2082
+ type: Y.literal("message-metadata"),
2083
+ messageMetadata: Y.unknown()
2084
2084
  })
2085
2085
  ])));
2086
- function er(e) {
2086
+ function tr(e) {
2087
2087
  return e.type.startsWith("data-");
2088
2088
  }
2089
- function tr() {
2089
+ function nr() {
2090
2090
  return Object.create(null);
2091
2091
  }
2092
- function nr(e) {
2092
+ function rr(e) {
2093
2093
  return e.type.startsWith("tool-");
2094
2094
  }
2095
- function rr(e) {
2095
+ function ir(e) {
2096
2096
  return e.type === "dynamic-tool";
2097
2097
  }
2098
- function Q(e) {
2099
- return nr(e) || rr(e);
2098
+ function Z(e) {
2099
+ return rr(e) || ir(e);
2100
2100
  }
2101
- function ir(e) {
2101
+ function ar(e) {
2102
2102
  return e.type.split("-").slice(1).join("-");
2103
2103
  }
2104
- function ar({ lastMessage: e, messageId: t }) {
2104
+ function or({ lastMessage: e, messageId: t }) {
2105
2105
  let n = e?.role === "assistant" ? e : {
2106
2106
  id: t,
2107
2107
  metadata: void 0,
2108
2108
  role: "assistant",
2109
2109
  parts: []
2110
- }, r = tr(), i = n.parts.findLastIndex((e) => e.type === "step-start"), a = 0;
2110
+ }, r = nr(), i = n.parts.findLastIndex((e) => e.type === "step-start"), a = 0;
2111
2111
  for (let e of n.parts.slice(i + 1)) {
2112
- if (!Q(e)) continue;
2112
+ if (!Z(e)) continue;
2113
2113
  let t = a;
2114
- nr(e) && a++, e.state === "input-streaming" && (r[e.toolCallId] = {
2114
+ rr(e) && a++, e.state === "input-streaming" && (r[e.toolCallId] = {
2115
2115
  text: e.rawInput ?? "",
2116
2116
  inputEncoding: e.inputEncoding,
2117
2117
  index: t,
2118
- toolName: e.type === "dynamic-tool" ? e.toolName : ir(e),
2118
+ toolName: e.type === "dynamic-tool" ? e.toolName : ar(e),
2119
2119
  dynamic: e.type === "dynamic-tool",
2120
2120
  title: e.title,
2121
2121
  toolMetadata: e.toolMetadata
@@ -2123,12 +2123,12 @@ function ar({ lastMessage: e, messageId: t }) {
2123
2123
  }
2124
2124
  return {
2125
2125
  message: n,
2126
- activeTextParts: tr(),
2127
- activeReasoningParts: tr(),
2126
+ activeTextParts: nr(),
2127
+ activeReasoningParts: nr(),
2128
2128
  partialToolCalls: r
2129
2129
  };
2130
2130
  }
2131
- function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdateMessageJob: r, onError: i, onToolCall: a, onData: o, resetStateOnMessageIdChange: s = !1, resetStateOnFirstMessageStart: c = !1 }) {
2131
+ function sr({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdateMessageJob: r, onError: i, onToolCall: a, onData: o, resetStateOnMessageIdChange: s = !1, resetStateOnFirstMessageStart: c = !1 }) {
2132
2132
  let l = !0;
2133
2133
  return e.pipeThrough(new TransformStream({ async transform(e, u) {
2134
2134
  await r(async ({ state: r, write: d }) => {
@@ -2138,7 +2138,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2138
2138
  return e.slice(t + 1);
2139
2139
  }
2140
2140
  function p() {
2141
- return f().filter(Q);
2141
+ return f().filter(Z);
2142
2142
  }
2143
2143
  function m(e) {
2144
2144
  let t = p().find((t) => t.toolCallId === e);
@@ -2146,13 +2146,13 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2146
2146
  let n = r.message.parts;
2147
2147
  for (let r = n.length - 1; r >= 0; r--) {
2148
2148
  let i = n[r];
2149
- if (Q(i) && i.toolCallId === e) {
2149
+ if (Z(i) && i.toolCallId === e) {
2150
2150
  t = i;
2151
2151
  break;
2152
2152
  }
2153
2153
  }
2154
2154
  }
2155
- if (t == null) throw new Dn({
2155
+ if (t == null) throw new On({
2156
2156
  chunkType: "tool-invocation",
2157
2157
  chunkId: e,
2158
2158
  message: `No tool invocation found for tool call ID "${e}".`
@@ -2160,8 +2160,8 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2160
2160
  return t;
2161
2161
  }
2162
2162
  function h(e) {
2163
- let t = r.message.parts.filter(Q).find((t) => t.approval?.id === e);
2164
- if (t == null) throw new Dn({
2163
+ let t = r.message.parts.filter(Z).find((t) => t.approval?.id === e);
2164
+ if (t == null) throw new On({
2165
2165
  chunkType: "tool-approval-response",
2166
2166
  chunkId: e,
2167
2167
  message: `No tool invocation found for approval ID "${e}".`
@@ -2169,7 +2169,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2169
2169
  return t;
2170
2170
  }
2171
2171
  function g(e, t) {
2172
- let n = t ?? f().find((t) => nr(t) && t.toolCallId === e.toolCallId), i = e, a = n;
2172
+ let n = t ?? f().find((t) => rr(t) && t.toolCallId === e.toolCallId), i = e, a = n;
2173
2173
  if (n != null) {
2174
2174
  n.state = e.state, a.type = `tool-${e.toolName}`, a.input = i.input, a.output = i.output, a.errorText = i.errorText, a.rawInput = i.rawInput, i.inputEncoding == null ? delete a.inputEncoding : a.inputEncoding = i.inputEncoding, a.preliminary = i.preliminary, e.title !== void 0 && (a.title = e.title), e.toolMetadata !== void 0 && (a.toolMetadata = e.toolMetadata), a.providerExecuted = i.providerExecuted ?? n.providerExecuted;
2175
2175
  let t = i.providerMetadata;
@@ -2226,8 +2226,8 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2226
2226
  }
2227
2227
  async function v(e) {
2228
2228
  if (e != null) {
2229
- let n = r.message.metadata == null ? e : On(r.message.metadata, e);
2230
- t != null && await gn({
2229
+ let n = r.message.metadata == null ? e : kn(r.message.metadata, e);
2230
+ t != null && await _n({
2231
2231
  value: n,
2232
2232
  schema: t,
2233
2233
  context: {
@@ -2250,7 +2250,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2250
2250
  }
2251
2251
  case "text-delta": {
2252
2252
  let t = r.activeTextParts[e.id];
2253
- if (t == null) throw new Dn({
2253
+ if (t == null) throw new On({
2254
2254
  chunkType: "text-delta",
2255
2255
  chunkId: e.id,
2256
2256
  message: `Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`
@@ -2260,7 +2260,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2260
2260
  }
2261
2261
  case "text-end": {
2262
2262
  let t = r.activeTextParts[e.id];
2263
- if (t == null) throw new Dn({
2263
+ if (t == null) throw new On({
2264
2264
  chunkType: "text-end",
2265
2265
  chunkId: e.id,
2266
2266
  message: `Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`
@@ -2290,7 +2290,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2290
2290
  }
2291
2291
  case "reasoning-delta": {
2292
2292
  let t = r.activeReasoningParts[e.id];
2293
- if (t == null) throw new Dn({
2293
+ if (t == null) throw new On({
2294
2294
  chunkType: "reasoning-delta",
2295
2295
  chunkId: e.id,
2296
2296
  message: `Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`
@@ -2300,7 +2300,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2300
2300
  }
2301
2301
  case "reasoning-end": {
2302
2302
  let t = r.activeReasoningParts[e.id];
2303
- if (t == null) throw new Dn({
2303
+ if (t == null) throw new On({
2304
2304
  chunkType: "reasoning-end",
2305
2305
  chunkId: e.id,
2306
2306
  message: `Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`
@@ -2337,7 +2337,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2337
2337
  }), d();
2338
2338
  break;
2339
2339
  case "tool-input-start": {
2340
- let t = f().filter(nr);
2340
+ let t = f().filter(rr);
2341
2341
  r.partialToolCalls[e.toolCallId] = {
2342
2342
  text: "",
2343
2343
  inputEncoding: e.inputEncoding,
@@ -2371,13 +2371,13 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2371
2371
  }
2372
2372
  case "tool-input-delta": {
2373
2373
  let t = r.partialToolCalls[e.toolCallId];
2374
- if (t == null) throw new Dn({
2374
+ if (t == null) throw new On({
2375
2375
  chunkType: "tool-input-delta",
2376
2376
  chunkId: e.toolCallId,
2377
2377
  message: `Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`
2378
2378
  });
2379
2379
  t.text += e.inputTextDelta;
2380
- let n = t.inputEncoding === "text" ? t.text : (await Xn(t.text)).value;
2380
+ let n = t.inputEncoding === "text" ? t.text : (await Zn(t.text)).value;
2381
2381
  t.dynamic ? _({
2382
2382
  toolCallId: e.toolCallId,
2383
2383
  toolName: t.toolName,
@@ -2421,7 +2421,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2421
2421
  }), d(), a && !e.providerExecuted && await a({ toolCall: e });
2422
2422
  break;
2423
2423
  case "tool-input-error": {
2424
- let t = f().filter(Q).find((t) => t.toolCallId === e.toolCallId);
2424
+ let t = f().filter(Z).find((t) => t.toolCallId === e.toolCallId);
2425
2425
  (t == null ? e.dynamic : t.type === "dynamic-tool") ? _({
2426
2426
  toolCallId: e.toolCallId,
2427
2427
  toolName: e.toolName,
@@ -2485,7 +2485,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2485
2485
  toolMetadata: e.toolMetadata ?? t.toolMetadata
2486
2486
  }, t) : g({
2487
2487
  toolCallId: e.toolCallId,
2488
- toolName: ir(t),
2488
+ toolName: ar(t),
2489
2489
  state: "output-available",
2490
2490
  input: t.input,
2491
2491
  output: e.output,
@@ -2511,7 +2511,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2511
2511
  toolMetadata: e.toolMetadata ?? t.toolMetadata
2512
2512
  }, t) : g({
2513
2513
  toolCallId: e.toolCallId,
2514
- toolName: ir(t),
2514
+ toolName: ar(t),
2515
2515
  state: "output-error",
2516
2516
  input: t.input,
2517
2517
  rawInput: t.rawInput,
@@ -2529,12 +2529,12 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2529
2529
  case "finish-step": break;
2530
2530
  case "reset-step": {
2531
2531
  let e = f();
2532
- r.activeTextParts = tr(), r.activeReasoningParts = tr(), r.partialToolCalls = tr(), e.length > 0 && (r.message.parts.splice(r.message.parts.length - e.length, e.length), d());
2532
+ r.activeTextParts = nr(), r.activeReasoningParts = nr(), r.partialToolCalls = nr(), e.length > 0 && (r.message.parts.splice(r.message.parts.length - e.length, e.length), d());
2533
2533
  break;
2534
2534
  }
2535
2535
  case "start": {
2536
2536
  let t = c && l || s && e.messageId != null && e.messageId !== r.message.id;
2537
- l = !1, t && Object.assign(r, ar({
2537
+ l = !1, t && Object.assign(r, or({
2538
2538
  lastMessage: void 0,
2539
2539
  messageId: e.messageId ?? r.message.id
2540
2540
  }), { finishReason: void 0 }), e.messageId != null && (r.message.id = e.messageId), await v(e.messageMetadata), (t || e.messageId != null || e.messageMetadata != null) && d({ updateStatus: !1 });
@@ -2549,10 +2549,10 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2549
2549
  case "error":
2550
2550
  i?.(Error(e.errorText));
2551
2551
  break;
2552
- default: if (er(e)) {
2552
+ default: if (tr(e)) {
2553
2553
  if (n?.[e.type] != null) {
2554
2554
  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;
2555
- await gn({
2555
+ await _n({
2556
2556
  value: e.data,
2557
2557
  schema: n[e.type],
2558
2558
  context: {
@@ -2575,7 +2575,7 @@ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2575
2575
  });
2576
2576
  } }));
2577
2577
  }
2578
- async function sr({ stream: e, onError: t, abortSignal: n }) {
2578
+ async function cr({ stream: e, onError: t, abortSignal: n }) {
2579
2579
  let r = e.getReader(), i = () => {
2580
2580
  r.cancel().catch(() => {});
2581
2581
  };
@@ -2591,7 +2591,7 @@ async function sr({ stream: e, onError: t, abortSignal: n }) {
2591
2591
  n?.removeEventListener("abort", i), r.releaseLock();
2592
2592
  }
2593
2593
  }
2594
- function cr() {
2594
+ function lr() {
2595
2595
  let e, t;
2596
2596
  return {
2597
2597
  promise: new Promise((n, r) => {
@@ -2613,7 +2613,7 @@ j({
2613
2613
  }), j({
2614
2614
  prefix: "call",
2615
2615
  size: 24
2616
- }), X.record(X.string(), kn.optional()), X.record(X.string(), X.string()), j({
2616
+ }), Y.record(Y.string(), An.optional()), Y.record(Y.string(), Y.string()), j({
2617
2617
  prefix: "call",
2618
2618
  size: 24
2619
2619
  }), j({
@@ -2626,7 +2626,7 @@ j({
2626
2626
  prefix: "aiobj",
2627
2627
  size: 24
2628
2628
  });
2629
- var { atob: lr } = globalThis, ur = class {
2629
+ var { atob: ur } = globalThis, dr = class {
2630
2630
  constructor() {
2631
2631
  this.queue = [], this.isProcessing = !1, this.idleWaiters = [];
2632
2632
  }
@@ -2664,9 +2664,9 @@ j({
2664
2664
  }), j({
2665
2665
  prefix: "call",
2666
2666
  size: 24
2667
- }), X.object({
2668
- token: X.string().refine((e) => e.trim().length > 0),
2669
- url: X.string().refine((e) => {
2667
+ }), Y.object({
2668
+ token: Y.string().refine((e) => e.trim().length > 0),
2669
+ url: Y.string().refine((e) => {
2670
2670
  try {
2671
2671
  let t = new URL(e);
2672
2672
  return (t.protocol === "ws:" || t.protocol === "wss:") && t.hostname !== "";
@@ -2674,12 +2674,12 @@ j({
2674
2674
  return !1;
2675
2675
  }
2676
2676
  }),
2677
- expiresAt: X.number().positive().max(2 ** 53 - 1).optional(),
2678
- tools: X.array(X.object({
2679
- type: X.literal("function"),
2680
- name: X.string().min(1),
2681
- description: X.string().optional(),
2682
- parameters: X.record(X.string(), X.unknown())
2677
+ expiresAt: Y.number().positive().max(2 ** 53 - 1).optional(),
2678
+ tools: Y.array(Y.object({
2679
+ type: Y.literal("function"),
2680
+ name: Y.string().min(1),
2681
+ description: Y.string().optional(),
2682
+ parameters: Y.record(Y.string(), Y.unknown())
2683
2683
  })).optional()
2684
2684
  }), j({
2685
2685
  prefix: "call",
@@ -2691,7 +2691,7 @@ j({
2691
2691
  prefix: "call",
2692
2692
  size: 24
2693
2693
  });
2694
- async function dr({ response: e, url: t, fallbackMessage: n }) {
2694
+ async function fr({ response: e, url: t, fallbackMessage: n }) {
2695
2695
  let r = await e.text();
2696
2696
  return new Re({
2697
2697
  message: r || n,
@@ -2701,7 +2701,7 @@ async function dr({ response: e, url: t, fallbackMessage: n }) {
2701
2701
  responseBody: r
2702
2702
  });
2703
2703
  }
2704
- async function fr(e) {
2704
+ async function pr(e) {
2705
2705
  if (e == null) return [];
2706
2706
  if (!globalThis.FileList || !(e instanceof globalThis.FileList)) throw new nt({
2707
2707
  functionality: "FileList",
@@ -2722,16 +2722,16 @@ async function fr(e) {
2722
2722
  };
2723
2723
  }));
2724
2724
  }
2725
- function pr(e, t) {
2725
+ function mr(e, t) {
2726
2726
  let n = e.search(/[?#]/), r = n === -1 ? e : e.slice(0, n), i = n === -1 ? "" : e.slice(n);
2727
2727
  return `${r.endsWith("/") && t.startsWith("/") ? r.slice(0, -1) : r}${t}${i}`;
2728
2728
  }
2729
- var mr = class {
2729
+ var hr = class {
2730
2730
  constructor({ api: e = "/api/chat", credentials: t, headers: n, body: r, fetch: i, prepareSendMessagesRequest: a, prepareReconnectToStreamRequest: o }) {
2731
2731
  this.api = e, this.credentials = t, this.headers = n, this.body = r, this.fetch = i, this.prepareSendMessagesRequest = a, this.prepareReconnectToStreamRequest = o;
2732
2732
  }
2733
2733
  async sendMessages({ abortSignal: e, ...t }) {
2734
- let n = await bn(this.body), r = await bn(this.headers), i = await bn(this.credentials), a = {
2734
+ let n = await xn(this.body), r = await xn(this.headers), i = await xn(this.credentials), a = {
2735
2735
  ...A(r),
2736
2736
  ...A(t.headers)
2737
2737
  }, o = await this.prepareSendMessagesRequest?.({
@@ -2764,7 +2764,7 @@ var mr = class {
2764
2764
  credentials: u,
2765
2765
  signal: e
2766
2766
  });
2767
- if (!d.ok) throw await dr({
2767
+ if (!d.ok) throw await fr({
2768
2768
  response: d,
2769
2769
  url: s,
2770
2770
  fallbackMessage: "Failed to fetch the chat response."
@@ -2773,7 +2773,7 @@ var mr = class {
2773
2773
  return this.processResponseStream(d.body);
2774
2774
  }
2775
2775
  async reconnectToStream(e) {
2776
- let t = await bn(this.body), n = await bn(this.headers), r = await bn(this.credentials), i = {
2776
+ let t = await xn(this.body), n = await xn(this.headers), r = await xn(this.credentials), i = {
2777
2777
  ...A(n),
2778
2778
  ...A(e.headers)
2779
2779
  }, a = await this.prepareReconnectToStreamRequest?.({
@@ -2788,12 +2788,12 @@ var mr = class {
2788
2788
  requestMetadata: e.metadata
2789
2789
  }), o = a?.api;
2790
2790
  if (o == null) {
2791
- if (e.chatId === "." || e.chatId === "..") throw new Cn({
2791
+ if (e.chatId === "." || e.chatId === "..") throw new wn({
2792
2792
  parameter: "chatId",
2793
2793
  value: e.chatId,
2794
2794
  message: "Chat IDs must not be \".\" or \"..\" when using the default reconnect URL."
2795
2795
  });
2796
- o = pr(this.api, `/${encodeURIComponent(e.chatId)}/stream`);
2796
+ o = mr(this.api, `/${encodeURIComponent(e.chatId)}/stream`);
2797
2797
  }
2798
2798
  let s = a?.headers === void 0 ? i : A(a.headers), c = a?.credentials ?? r, l = await (this.fetch ?? globalThis.fetch)(o, {
2799
2799
  method: "GET",
@@ -2802,7 +2802,7 @@ var mr = class {
2802
2802
  signal: e.abortSignal
2803
2803
  });
2804
2804
  if (l.status === 204) return null;
2805
- if (!l.ok) throw await dr({
2805
+ if (!l.ok) throw await fr({
2806
2806
  response: l,
2807
2807
  url: o,
2808
2808
  fallbackMessage: "Failed to fetch the chat response."
@@ -2810,32 +2810,32 @@ var mr = class {
2810
2810
  if (!l.body) throw new He({ message: "The response body is empty." });
2811
2811
  return this.processResponseStream(l.body);
2812
2812
  }
2813
- }, hr = class extends mr {
2813
+ }, gr = class extends hr {
2814
2814
  constructor({ resumeStreamIsReplay: e = !0, ...t } = {}) {
2815
2815
  super(t), this.resumeStreamIsReplay = e;
2816
2816
  }
2817
2817
  processResponseStream(e) {
2818
- return yn({
2818
+ return bn({
2819
2819
  stream: e,
2820
- schema: $n
2820
+ schema: er
2821
2821
  }).pipeThrough(new TransformStream({ async transform(e, t) {
2822
2822
  if (!e.success) throw e.error;
2823
2823
  t.enqueue(e.value);
2824
2824
  } }));
2825
2825
  }
2826
- }, gr = class {
2826
+ }, _r = class {
2827
2827
  get id() {
2828
2828
  return this._id ??= this.generateId();
2829
2829
  }
2830
- 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 }) {
2831
- 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) => {
2830
+ constructor({ generateId: e = ft, id: t, transport: n = new gr(), messageMetadataSchema: r, dataPartSchemas: i, state: a, onError: o, onToolCall: s, onFinish: c, onData: l, sendAutomaticallyWhen: u }) {
2831
+ 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 dr(), this.activeStopCount = 0, this.stopGeneration = 0, this.sendMessage = async (e, t) => {
2832
2832
  if (e == null) {
2833
2833
  let e = this.pendingApprovalMessageId;
2834
2834
  if (e == null) {
2835
2835
  e = this.lastMessage?.id;
2836
2836
  for (let t = this.state.messages.length - 1; t >= 0; t--) {
2837
2837
  let n = this.state.messages[t];
2838
- if (n.role === "assistant" && n.parts.some((e) => Q(e) && e.state === "approval-responded")) {
2838
+ if (n.role === "assistant" && n.parts.some((e) => Z(e) && e.state === "approval-responded")) {
2839
2839
  e = n.id;
2840
2840
  break;
2841
2841
  }
@@ -2855,7 +2855,7 @@ var mr = class {
2855
2855
  this.pendingMessagePreparations.add(t);
2856
2856
  let r;
2857
2857
  try {
2858
- r = Array.isArray(e.files) ? e.files : await fr(e.files);
2858
+ r = Array.isArray(e.files) ? e.files : await pr(e.files);
2859
2859
  } finally {
2860
2860
  this.pendingMessagePreparations.delete(t);
2861
2861
  }
@@ -2867,12 +2867,12 @@ var mr = class {
2867
2867
  } else n = e;
2868
2868
  if (e.messageId != null) {
2869
2869
  let t = this.state.messages.findIndex((t) => t.id === e.messageId);
2870
- if (t === -1) throw new Cn({
2870
+ if (t === -1) throw new wn({
2871
2871
  parameter: "message.messageId",
2872
2872
  value: e.messageId,
2873
2873
  message: `message with id ${e.messageId} not found`
2874
2874
  });
2875
- if (this.state.messages[t].role !== "user") throw new Cn({
2875
+ if (this.state.messages[t].role !== "user") throw new wn({
2876
2876
  parameter: "message.messageId",
2877
2877
  value: e.messageId,
2878
2878
  message: `message with id ${e.messageId} is not a user message`
@@ -2896,7 +2896,7 @@ var mr = class {
2896
2896
  });
2897
2897
  }, this.regenerate = async ({ messageId: e, ...t } = {}) => {
2898
2898
  let n = e == null ? this.state.messages.length - 1 : this.state.messages.findIndex((t) => t.id === e);
2899
- if (n === -1) throw new Cn({
2899
+ if (n === -1) throw new wn({
2900
2900
  parameter: "messageId",
2901
2901
  value: e,
2902
2902
  message: `message ${e} not found`
@@ -2917,7 +2917,7 @@ var mr = class {
2917
2917
  }, this.clearError = () => {
2918
2918
  this.status === "error" && (this.state.error = void 0, this.setStatus({ status: "ready" }));
2919
2919
  }, this.addToolApprovalResponse = async ({ id: e, approved: t, reason: n, options: r }) => this.jobExecutor.run(async () => {
2920
- let i = this.state.messages, a = (r) => Q(r) && r.state === "approval-requested" && r.approval.id === e ? {
2920
+ let i = this.state.messages, a = (r) => Z(r) && r.state === "approval-requested" && r.approval.id === e ? {
2921
2921
  ...r,
2922
2922
  state: "approval-responded",
2923
2923
  approval: {
@@ -2926,7 +2926,7 @@ var mr = class {
2926
2926
  approved: t,
2927
2927
  reason: n
2928
2928
  }
2929
- } : r, o = i.findIndex((t) => t.parts.some((t) => Q(t) && t.state === "approval-requested" && t.approval.id === e));
2929
+ } : r, o = i.findIndex((t) => t.parts.some((t) => Z(t) && t.state === "approval-requested" && t.approval.id === e));
2930
2930
  if (o !== -1) {
2931
2931
  let e = i[o];
2932
2932
  this.state.replaceMessage(o, {
@@ -2947,7 +2947,7 @@ var mr = class {
2947
2947
  }
2948
2948
  }), this.addToolOutput = async ({ state: e, toolCallId: t, output: n, errorText: r, options: i }) => this.jobExecutor.run(async () => {
2949
2949
  let a = this.state.messages, o = (i) => {
2950
- if (!Q(i) || i.toolCallId !== t) return i;
2950
+ if (!Z(i) || i.toolCallId !== t) return i;
2951
2951
  let { approval: a, ...o } = i, s = a?.approved === !0 ? { approval: {
2952
2952
  ...a,
2953
2953
  approved: a.approved
@@ -2967,7 +2967,7 @@ var mr = class {
2967
2967
  output: n,
2968
2968
  errorText: void 0
2969
2969
  };
2970
- }, s = a.findIndex((e) => e.parts.some((e) => Q(e) && e.toolCallId === t));
2970
+ }, s = a.findIndex((e) => e.parts.some((e) => Z(e) && e.toolCallId === t));
2971
2971
  if (s !== -1) {
2972
2972
  let e = a[s];
2973
2973
  this.state.replaceMessage(s, {
@@ -3031,7 +3031,7 @@ var mr = class {
3031
3031
  }), r && this.status === "error" && this.pendingApprovalMessageId == null && (this.pendingApprovalMessageId = this.state.messages[t]?.id ?? e);
3032
3032
  }
3033
3033
  async makeRequest(e) {
3034
- let t = cr();
3034
+ let t = lr();
3035
3035
  try {
3036
3036
  await this.makeRequestImpl({
3037
3037
  ...e,
@@ -3084,10 +3084,10 @@ var mr = class {
3084
3084
  status: "submitted",
3085
3085
  error: void 0
3086
3086
  });
3087
- let d = this.lastMessage, f = e === "submit-message" && i != null ? this.state.messages.findIndex((e) => e.id === i) : this.state.messages.length - 1, p = f === -1 ? d : this.state.messages[f], m = p?.id, h = e === "resume-stream" && p?.role === "assistant" && p.parts.some((e) => Q(e) && (e.state === "input-streaming" || e.state === "input-available" && e.providerExecuted || e.state === "approval-responded")) ? this.state.snapshot(p) : void 0, g = f !== -1 && f < this.state.messages.length - 1 && p?.role === "assistant", _ = !1, v = !1, ee = !1, y;
3087
+ let d = this.lastMessage, f = e === "submit-message" && i != null ? this.state.messages.findIndex((e) => e.id === i) : this.state.messages.length - 1, p = f === -1 ? d : this.state.messages[f], m = p?.id, h = e === "resume-stream" && p?.role === "assistant" && p.parts.some((e) => Z(e) && (e.state === "input-streaming" || e.state === "input-available" && e.providerExecuted || e.state === "approval-responded")) ? this.state.snapshot(p) : void 0, g = f !== -1 && f < this.state.messages.length - 1 && p?.role === "assistant", _ = !1, v = !1, ee = !1, y;
3088
3088
  try {
3089
3089
  let s = {
3090
- state: e === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState : ar({
3090
+ state: e === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState : or({
3091
3091
  lastMessage: e === "resume-stream" ? h : e === "regenerate-message" ? void 0 : this.state.snapshot(p),
3092
3092
  messageId: this.generateId()
3093
3093
  }),
@@ -3107,8 +3107,8 @@ var mr = class {
3107
3107
  body: r,
3108
3108
  trigger: e,
3109
3109
  messageId: i
3110
- }), await sr({
3111
- stream: or({
3110
+ }), await cr({
3111
+ stream: sr({
3112
3112
  stream: l,
3113
3113
  resetStateOnMessageIdChange: e === "resume-stream",
3114
3114
  resetStateOnFirstMessageStart: e === "resume-stream" && this.transport.resumeStreamIsReplay,
@@ -3176,37 +3176,37 @@ var mr = class {
3176
3176
  }));
3177
3177
  }
3178
3178
  };
3179
- function _r({ messages: e }) {
3179
+ function vr({ messages: e }) {
3180
3180
  let t = e[e.length - 1];
3181
3181
  if (!t || t.role !== "assistant") return !1;
3182
- let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter(Q);
3182
+ let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter(Z);
3183
3183
  return r.filter((e) => e.state === "approval-responded").length > 0 && r.every((e) => e.state === "output-available" && e.preliminary !== !0 || e.state === "output-error" || e.state === "output-denied" || e.state === "approval-responded");
3184
3184
  }
3185
3185
  // ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.44_typescript@6.0.3_/node_modules/swrv/esm/lib/hash.js
3186
- var vr = /* @__PURE__ */ new WeakMap(), yr = 0;
3187
- function br(e) {
3186
+ var yr = /* @__PURE__ */ new WeakMap(), br = 0;
3187
+ function xr(e) {
3188
3188
  if (!e.length) return "";
3189
3189
  for (var t = "arg", n = 0; n < e.length; ++n) {
3190
3190
  var r = void 0;
3191
- e[n] === null || typeof e[n] != "object" && typeof e[n] != "function" ? r = typeof e[n] == "string" ? "\"" + e[n] + "\"" : String(e[n]) : vr.has(e[n]) ? r = vr.get(e[n]) : (r = yr, vr.set(e[n], yr++)), t += "@" + r;
3191
+ e[n] === null || typeof e[n] != "object" && typeof e[n] != "function" ? r = typeof e[n] == "string" ? "\"" + e[n] + "\"" : String(e[n]) : yr.has(e[n]) ? r = yr.get(e[n]) : (r = br, yr.set(e[n], br++)), t += "@" + r;
3192
3192
  }
3193
3193
  return t;
3194
3194
  }
3195
3195
  // ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.44_typescript@6.0.3_/node_modules/swrv/esm/cache/index.js
3196
- function xr(e) {
3196
+ function Sr(e) {
3197
3197
  if (typeof e == "function") try {
3198
3198
  e = e();
3199
3199
  } catch {
3200
3200
  e = "";
3201
3201
  }
3202
- return e = Array.isArray(e) ? br(e) : String(e || ""), e;
3202
+ return e = Array.isArray(e) ? xr(e) : String(e || ""), e;
3203
3203
  }
3204
- var Sr = function() {
3204
+ var Cr = function() {
3205
3205
  function e(e) {
3206
3206
  e === void 0 && (e = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = e;
3207
3207
  }
3208
3208
  return e.prototype.serializeKey = function(e) {
3209
- return xr(e);
3209
+ return Sr(e);
3210
3210
  }, e.prototype.get = function(e) {
3211
3211
  var t = this.serializeKey(e);
3212
3212
  return this.items.get(t);
@@ -3227,26 +3227,26 @@ var Sr = function() {
3227
3227
  }, e;
3228
3228
  }();
3229
3229
  // ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.44_typescript@6.0.3_/node_modules/swrv/esm/lib/web-preset.js
3230
- function Cr() {
3230
+ function wr() {
3231
3231
  return navigator.onLine === void 0 || navigator.onLine;
3232
3232
  }
3233
- function wr() {
3233
+ function Tr() {
3234
3234
  return typeof document < "u" && document.visibilityState !== void 0 ? document.visibilityState !== "hidden" : !0;
3235
3235
  }
3236
- var Tr = {
3237
- isOnline: Cr,
3238
- isDocumentVisible: wr,
3236
+ var Er = {
3237
+ isOnline: wr,
3238
+ isDocumentVisible: Tr,
3239
3239
  fetcher: function(e) {
3240
3240
  return fetch(e).then(function(e) {
3241
3241
  return e.json();
3242
3242
  });
3243
3243
  }
3244
- }, $ = function() {
3245
- return $ = Object.assign || function(e) {
3244
+ }, Q = function() {
3245
+ return Q = Object.assign || function(e) {
3246
3246
  for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n], t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
3247
3247
  return e;
3248
- }, $.apply(this, arguments);
3249
- }, Er = function(e, t, n, r) {
3248
+ }, Q.apply(this, arguments);
3249
+ }, $ = function(e, t, n, r) {
3250
3250
  function i(e) {
3251
3251
  return e instanceof n ? e : new n(function(t) {
3252
3252
  t(e);
@@ -3364,7 +3364,7 @@ var Tr = {
3364
3364
  }, kr = function(e, t, n) {
3365
3365
  if (n || arguments.length === 2) for (var r = 0, i = t.length, a; r < i; r++) (a || !(r in t)) && (a ||= Array.prototype.slice.call(t, 0, r), a[r] = t[r]);
3366
3366
  return e.concat(a || Array.prototype.slice.call(t));
3367
- }, Ar = new Sr(), jr = new Sr(), Mr = new Sr(), Nr = {
3367
+ }, Ar = new Cr(), jr = new Cr(), Mr = new Cr(), Nr = {
3368
3368
  cache: Ar,
3369
3369
  refreshInterval: 0,
3370
3370
  ttl: 0,
@@ -3375,9 +3375,9 @@ var Tr = {
3375
3375
  shouldRetryOnError: !0,
3376
3376
  errorRetryInterval: 5e3,
3377
3377
  errorRetryCount: 5,
3378
- fetcher: Tr.fetcher,
3379
- isOnline: Tr.isOnline,
3380
- isDocumentVisible: Tr.isDocumentVisible
3378
+ fetcher: Er.fetcher,
3379
+ isOnline: Er.isOnline,
3380
+ isDocumentVisible: Er.isDocumentVisible
3381
3381
  };
3382
3382
  function Pr(e, t, n) {
3383
3383
  var r = jr.get(e);
@@ -3399,7 +3399,7 @@ function Ir(e) {
3399
3399
  return typeof n == "function" ? n(r) : typeof n == "boolean" ? n : Nr.shouldRetryOnError;
3400
3400
  }
3401
3401
  var Lr = function(e, t, n, r) {
3402
- return n === void 0 && (n = Ar), r === void 0 && (r = Nr.ttl), Er(void 0, void 0, void 0, function() {
3402
+ return n === void 0 && (n = Ar), r === void 0 && (r = Nr.ttl), $(void 0, void 0, void 0, function() {
3403
3403
  var i, a, o, s, c, l, u;
3404
3404
  return Dr(this, function(d) {
3405
3405
  switch (d.label) {
@@ -3437,10 +3437,10 @@ var Lr = function(e, t, n, r) {
3437
3437
  };
3438
3438
  function Rr() {
3439
3439
  for (var e = this, t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
3440
- var r, i, a = $({}, Nr), o = !1, s = !1;
3440
+ var r, i, a = Q({}, Nr), o = !1, s = !1;
3441
3441
  if (!me()) return console.error("useSWRV must be called inside setup() or an active effectScope()."), null;
3442
3442
  var c = typeof window > "u" || typeof document > "u";
3443
- t.length >= 1 && (r = t[0]), t.length >= 2 && (i = t[1]), t.length > 2 && (a = $($({}, a), t[2]));
3443
+ t.length >= 1 && (r = t[0]), t.length >= 2 && (i = t[1]), t.length > 2 && (a = Q(Q({}, a), t[2]));
3444
3444
  var l = c ? a.serverTTL : a.ttl, u = typeof r == "function" ? r : x(r);
3445
3445
  i === void 0 && (i = a.fetcher);
3446
3446
  var d = null;
@@ -3452,12 +3452,12 @@ function Rr() {
3452
3452
  key: null
3453
3453
  });
3454
3454
  var f = function(t, n) {
3455
- return Er(e, void 0, void 0, function() {
3455
+ return $(e, void 0, void 0, function() {
3456
3456
  var e, r, s, c, p, m, h, g = this;
3457
3457
  return Dr(this, function(_) {
3458
3458
  switch (_.label) {
3459
3459
  case 0: return e = d.data === void 0, r = u.value, r ? (s = a.cache.get(r), c = s && s.data, d.isValidating = !0, d.isLoading = !c, c && (d.data = c.data, d.error = c.error), p = t || i, !p || !a.isDocumentVisible() && !e || n?.forceRevalidate !== void 0 && !n?.forceRevalidate || s && (m = !!(Date.now() - s.createdAt >= a.dedupingInterval || n?.forceRevalidate), !m) ? (d.isValidating = !1, d.isLoading = !1, [2]) : (h = function() {
3460
- return Er(g, void 0, void 0, function() {
3460
+ return $(g, void 0, void 0, function() {
3461
3461
  var e, t, i, s, c, u;
3462
3462
  return Dr(this, function(m) {
3463
3463
  switch (m.label) {
@@ -3476,7 +3476,7 @@ function Rr() {
3476
3476
  });
3477
3477
  });
3478
3478
  }, c && a.revalidateDebounce ? (setTimeout(function() {
3479
- return Er(g, void 0, void 0, function() {
3479
+ return $(g, void 0, void 0, function() {
3480
3480
  return Dr(this, function(e) {
3481
3481
  switch (e.label) {
3482
3482
  case 0: return o ? [3, 2] : [4, h()];
@@ -3493,7 +3493,7 @@ function Rr() {
3493
3493
  });
3494
3494
  });
3495
3495
  }, p = function() {
3496
- return Er(e, void 0, void 0, function() {
3496
+ return $(e, void 0, void 0, function() {
3497
3497
  return Dr(this, function(e) {
3498
3498
  return [2, f(null, { shouldRetryOnError: !1 })];
3499
3499
  });
@@ -3501,7 +3501,7 @@ function Rr() {
3501
3501
  }, m = null;
3502
3502
  if (!c) {
3503
3503
  var h = function() {
3504
- return Er(e, void 0, void 0, function() {
3504
+ return $(e, void 0, void 0, function() {
3505
3505
  return Dr(this, function(e) {
3506
3506
  switch (e.label) {
3507
3507
  case 0: return d.error || !a.isOnline() ? [3, 2] : [4, f()];
@@ -3526,8 +3526,8 @@ function Rr() {
3526
3526
  he(u) || (u.value = e), d.key = e, d.isValidating = !!e, Pr(u.value, d, l), !c && !s && u.value && f(), s = !1;
3527
3527
  }, { immediate: !0 });
3528
3528
  } catch {}
3529
- return $($({}, ye(d)), { mutate: function(e, t) {
3530
- return f(e, $($({}, t), { forceRevalidate: !0 }));
3529
+ return Q(Q({}, ye(d)), { mutate: function(e, t) {
3530
+ return f(e, Q(Q({}, t), { forceRevalidate: !0 }));
3531
3531
  } });
3532
3532
  }
3533
3533
  function zr(e) {
@@ -3605,7 +3605,7 @@ var Ur = class {
3605
3605
  this.isPublishing = !1;
3606
3606
  }
3607
3607
  }
3608
- }, Wr = class extends gr {
3608
+ }, Wr = class extends _r {
3609
3609
  constructor({ state: e, ...t }) {
3610
3610
  super({
3611
3611
  ...t,
@@ -3852,7 +3852,7 @@ function di(e) {
3852
3852
  });
3853
3853
  }
3854
3854
  async function St() {
3855
- Ct(), P(), w.value = void 0, Be.value = !1, q.value = "", await B.value.stop();
3855
+ Ct(), P(), w.value = void 0, Be.value = !1, K.value = "", await B.value.stop();
3856
3856
  }
3857
3857
  function Ct() {
3858
3858
  _t.cancelAll(), A.value && !M.has(A.value.toolCallId) && A.value.answer(!1);
@@ -3866,7 +3866,7 @@ function di(e) {
3866
3866
  I.value.includes(e) || (I.value = [...I.value, e]), kt.set(e, Date.now()), n ? At.add(e) : At.delete(e), t && (R.value = {
3867
3867
  ...R.value,
3868
3868
  [e]: t
3869
- }), Un || Kn();
3869
+ }), Wn || qn();
3870
3870
  }
3871
3871
  function z(e) {
3872
3872
  R.value = Object.fromEntries(Object.entries(R.value).filter(([t]) => t !== e));
@@ -3876,7 +3876,7 @@ function di(e) {
3876
3876
  }
3877
3877
  let Nt = Gr(() => ({
3878
3878
  id: E.value,
3879
- transport: new hr({
3879
+ transport: new gr({
3880
3880
  api: k.value.getChatEndpoint(o.value, T.value ? "reasoning" : "chat"),
3881
3881
  prepareReconnectToStreamRequest: ({ id: e }) => ({ api: k.value.getChatStreamEndpoint(o.value, e) }),
3882
3882
  prepareSendMessagesRequest: ({ messages: e, id: t }) => ({ body: {
@@ -3905,7 +3905,7 @@ function di(e) {
3905
3905
  credentials: "include",
3906
3906
  headers: () => p.value ?? {}
3907
3907
  }),
3908
- sendAutomaticallyWhen: (e) => ui(e) || _r(e),
3908
+ sendAutomaticallyWhen: (e) => ui(e) || vr(e),
3909
3909
  onError: (e) => {
3910
3910
  Tt ? le.warn(e) : ct(e);
3911
3911
  },
@@ -3926,15 +3926,15 @@ function di(e) {
3926
3926
  },
3927
3927
  onFinish: () => {
3928
3928
  let e = E.value;
3929
- !T.value && !U.value.some((t) => t.id === e) && dn(o.value);
3929
+ !T.value && !U.value.some((t) => t.id === e) && fn(o.value);
3930
3930
  }
3931
3931
  })), B = b(() => ve(Nt)), Pt = () => B.value.messages[B.value.messages.length - 1];
3932
3932
  C(E, (e, t) => {
3933
- if (t && !T.value && (Y() || F?.chatId === t)) {
3933
+ if (t && !T.value && (J() || F?.chatId === t)) {
3934
3934
  let e = B.value.messages.filter((e) => e.role === "user"), n = e[e.length - 1];
3935
3935
  jt(t, n ? de(n) ?? "" : "", B.value.status === "streaming" || F?.chatId === t);
3936
3936
  }
3937
- Mt(e), Dt = void 0, clearTimeout(zn), Rn.value = !1, B.value.stop();
3937
+ Mt(e), Dt = void 0, clearTimeout(Bn), zn.value = !1, B.value.stop();
3938
3938
  }, { flush: "sync" });
3939
3939
  let V = b(() => {
3940
3940
  let e = u.value?.initialMessage;
@@ -3969,29 +3969,29 @@ function di(e) {
3969
3969
  }), Lt = b(() => {
3970
3970
  let e = u.value?.messagePlaceholder;
3971
3971
  return e?.[r.value] ? e[r.value] : n("placeholder.askAnything") ? t("placeholder.askAnything") : "";
3972
- }), U = x([]), Rt = x(!1), zt = x(1), Bt = x(!1), Vt = x(!1), Ht, W = x([]), Ut = x(!1), Wt = x("chat"), Gt = x(0), Kt = x([]), qt = x(), Jt = x(!1), Yt = x(!1), Xt = x(), Zt = x(!1), Qt = x(!1), $t = x(), G = x(""), K = x([]), q = x(""), J = x(!0), en = S(), tn = x(0), nn = fe(b(() => `${o.value}-queue`), {}), rn = b(() => nn.value[E.value] ?? []), an = b(() => !T.value);
3973
- function on(e, t) {
3974
- let n = Object.fromEntries(Object.entries(nn.value).filter(([t]) => t !== e));
3975
- nn.value = t.length > 0 ? {
3972
+ }), U = x([]), Rt = x(!1), zt = x(1), Bt = x(!1), Vt = x(!1), Ht, Ut = x([]), Wt = x(!1), Gt = x("chat"), Kt = x(0), qt = x([]), Jt = x(), Yt = x(!1), Xt = x(!1), Zt = x(), Qt = x(!1), $t = x(!1), en = x(), W = x(""), G = x([]), K = x(""), q = x(!0), tn = S(), nn = x(0), rn = fe(b(() => `${o.value}-queue`), {}), an = b(() => rn.value[E.value] ?? []), on = b(() => !T.value);
3973
+ function sn(e, t) {
3974
+ let n = Object.fromEntries(Object.entries(rn.value).filter(([t]) => t !== e));
3975
+ rn.value = t.length > 0 ? {
3976
3976
  ...n,
3977
3977
  [e]: t
3978
3978
  } : n;
3979
3979
  }
3980
- function sn(e) {
3981
- let t = (nn.value[e] ?? []).join(si);
3982
- return on(e, []), t;
3983
- }
3984
3980
  function cn(e) {
3985
- e && (G.value = G.value ? `${G.value}${si}${e}` : e);
3981
+ let t = (rn.value[e] ?? []).join(si);
3982
+ return sn(e, []), t;
3986
3983
  }
3987
3984
  function ln(e) {
3988
- on(E.value, rn.value.filter((t, n) => n !== e));
3985
+ e && (W.value = W.value ? `${W.value}${si}${e}` : e);
3989
3986
  }
3990
3987
  function un(e) {
3991
- let t = rn.value[e];
3992
- ln(e), cn(t ?? "");
3988
+ sn(E.value, an.value.filter((t, n) => n !== e));
3989
+ }
3990
+ function dn(e) {
3991
+ let t = an.value[e];
3992
+ un(e), ln(t ?? "");
3993
3993
  }
3994
- async function dn(e) {
3994
+ async function fn(e) {
3995
3995
  if (T.value) U.value = [];
3996
3996
  else {
3997
3997
  Rt.value = !0;
@@ -4017,10 +4017,10 @@ function di(e) {
4017
4017
  } finally {
4018
4018
  Rt.value = !1;
4019
4019
  }
4020
- qn([.../* @__PURE__ */ new Set([...Vn(), ...U.value.map((e) => e.id)])]);
4020
+ Jn([.../* @__PURE__ */ new Set([...Hn(), ...U.value.map((e) => e.id)])]);
4021
4021
  }
4022
4022
  }
4023
- async function fn() {
4023
+ async function pn() {
4024
4024
  if (!Bt.value || Vt.value || T.value) return;
4025
4025
  Vt.value = !0;
4026
4026
  let e = Ht;
@@ -4033,50 +4033,50 @@ function di(e) {
4033
4033
  Vt.value = !1;
4034
4034
  }
4035
4035
  }
4036
- async function pn(e) {
4036
+ async function mn(e) {
4037
4037
  return T.value ? [] : k.value.getConversations(o.value, l.value, { search: e });
4038
4038
  }
4039
- async function mn() {
4039
+ async function hn() {
4040
4040
  let e = E.value;
4041
- if (!e) W.value = [];
4041
+ if (!e) Ut.value = [];
4042
4042
  else {
4043
- Ut.value = !0;
4043
+ Wt.value = !0;
4044
4044
  try {
4045
- W.value = await k.value.getChatFiles(e);
4045
+ Ut.value = await k.value.getChatFiles(e);
4046
4046
  } catch {
4047
- W.value = [];
4047
+ Ut.value = [];
4048
4048
  } finally {
4049
- Ut.value = !1;
4049
+ Wt.value = !1;
4050
4050
  }
4051
4051
  }
4052
4052
  }
4053
- function hn(e, t = !1) {
4053
+ function gn(e, t = !1) {
4054
4054
  return k.value.getChatFileDownloadUrl(e, t);
4055
4055
  }
4056
- function gn(e) {
4056
+ function _n(e) {
4057
4057
  return k.value.getChatFilePreviewUrl(e);
4058
4058
  }
4059
- async function _n(e) {
4059
+ async function vn(e) {
4060
4060
  await k.value.deleteChatFile(e);
4061
- let t = W.value.find((t) => t.documentId === e), n = t?.kind === "spreadsheet" ? t.sourceAttachmentId ?? t.documentId : void 0;
4062
- W.value = W.value.filter((t) => t.documentId !== e && (!n || t.documentId !== n && t.sourceAttachmentId !== n));
4061
+ let t = Ut.value.find((t) => t.documentId === e), n = t?.kind === "spreadsheet" ? t.sourceAttachmentId ?? t.documentId : void 0;
4062
+ Ut.value = Ut.value.filter((t) => t.documentId !== e && (!n || t.documentId !== n && t.sourceAttachmentId !== n));
4063
4063
  }
4064
- async function vn(e, t) {
4064
+ async function yn(e, t) {
4065
4065
  if (!T.value) try {
4066
4066
  let n = await k.value.getChat(e, t);
4067
4067
  if (t !== E.value || B.value.status !== "ready" || B.value.messages.length > 0) return;
4068
- n && (B.value.messages = n.messages, O.value = n.blocked ?? !1, yn(e, t, n.turnInProgress === !0));
4068
+ n && (B.value.messages = n.messages, O.value = n.blocked ?? !1, bn(e, t, n.turnInProgress === !0));
4069
4069
  } catch {}
4070
4070
  }
4071
- async function yn(e, t, n) {
4072
- n && (await bn(t), t !== E.value || Y()) || (await xn(e, t), t === E.value && await Tn());
4071
+ async function bn(e, t, n) {
4072
+ n && (await xn(t), t !== E.value || J()) || (await Sn(e, t), t === E.value && await En());
4073
4073
  }
4074
- async function bn(e) {
4074
+ async function xn(e) {
4075
4075
  let t = { chatId: e };
4076
4076
  F = t, Et.value = e;
4077
4077
  let n = () => F === t && e === E.value, r = Date.now() + $r;
4078
4078
  try {
4079
- for (; n() && !Y() && Date.now() < r;) {
4079
+ for (; n() && !J() && Date.now() < r;) {
4080
4080
  Tt = !0;
4081
4081
  try {
4082
4082
  await B.value.resumeStream();
@@ -4086,7 +4086,7 @@ function di(e) {
4086
4086
  if (!n()) return;
4087
4087
  B.value.clearError();
4088
4088
  let t = await k.value.getChat(o.value, e).catch(() => null);
4089
- if (!t || !n() || Y()) return;
4089
+ if (!t || !n() || J()) return;
4090
4090
  if (!t.turnInProgress) {
4091
4091
  B.value.messages = t.messages;
4092
4092
  return;
@@ -4097,7 +4097,7 @@ function di(e) {
4097
4097
  F === t && (F = void 0, Et.value = void 0);
4098
4098
  }
4099
4099
  }
4100
- async function xn(e, t) {
4100
+ async function Sn(e, t) {
4101
4101
  let n;
4102
4102
  try {
4103
4103
  n = Number(sessionStorage.getItem(Oe)), sessionStorage.removeItem(Oe);
@@ -4130,90 +4130,91 @@ function di(e) {
4130
4130
  }
4131
4131
  }
4132
4132
  }
4133
- let Y = () => {
4133
+ let J = () => {
4134
4134
  let e = B.value.status;
4135
4135
  return e === "submitted" || e === "streaming";
4136
- }, Sn = () => Y() || F?.chatId === E.value || he.value > 0, Cn = () => {
4136
+ }, Cn = () => J() || F?.chatId === E.value || he.value > 0, wn = () => {
4137
4137
  let e = Pt();
4138
4138
  return A.value !== void 0 || Jr(e) || li(e);
4139
- }, wn = /* @__PURE__ */ new Set();
4140
- async function Tn() {
4139
+ }, Tn = /* @__PURE__ */ new Set();
4140
+ async function En() {
4141
4141
  let e = E.value;
4142
- if (!(wn.has(e) || rn.value.length === 0 || Sn() || at.value)) {
4143
- if (Cn()) cn(sn(e));
4142
+ if (!(Tn.has(e) || an.value.length === 0 || Cn() || at.value)) {
4143
+ if (wn()) ln(cn(e));
4144
4144
  else {
4145
- wn.add(e);
4145
+ Tn.add(e);
4146
4146
  try {
4147
4147
  let t = Date.now() + ii;
4148
4148
  for (; Date.now() < t && (await Promise.race([k.value.getRunningTurns(o.value, [e]).catch(() => []), new Promise((t) => setTimeout(() => t([e]), oi))])).includes(e);) await new Promise((e) => setTimeout(e, ai));
4149
- if (e !== E.value || Sn()) return;
4150
- let n = sn(e);
4151
- n && Pn(n);
4149
+ if (e !== E.value || Cn()) return;
4150
+ let n = cn(e);
4151
+ n && Fn(n);
4152
4152
  } finally {
4153
- wn.delete(e);
4153
+ Tn.delete(e);
4154
4154
  }
4155
4155
  }
4156
4156
  }
4157
4157
  }
4158
- let En = 0, Dn = 0;
4159
- async function On() {
4160
- if (T.value || Y()) return "indeterminate";
4161
- let e = E.value, t = En += 1;
4158
+ let Dn = 0, On = 0;
4159
+ async function kn() {
4160
+ if (T.value || J()) return "indeterminate";
4161
+ let e = E.value, t = Dn += 1;
4162
4162
  try {
4163
4163
  let n = await k.value.getChat(o.value, e);
4164
- if (!n || e !== E.value || Y() || t <= Dn) return "indeterminate";
4165
- Dn = t;
4164
+ if (!n || e !== E.value || J() || t <= On) return "indeterminate";
4165
+ On = t;
4166
4166
  let r = n.messages, i = Qr(r, B.value.messages);
4167
4167
  return B.value.messages = [...r, ...i], O.value = n.blocked ?? !1, i.length > 0 ? "pending" : "caught-up";
4168
4168
  } catch {}
4169
4169
  return "indeterminate";
4170
4170
  }
4171
- function X(e) {
4171
+ function Y(e) {
4172
4172
  B.value.messages = [...B.value.messages, e];
4173
4173
  }
4174
- async function kn(e) {
4174
+ async function An(e) {
4175
4175
  try {
4176
- Kt.value = await k.value.getMessageFeedbacks(e);
4176
+ qt.value = await k.value.getMessageFeedbacks(e);
4177
4177
  } catch {
4178
- Kt.value = [];
4178
+ qt.value = [];
4179
4179
  }
4180
4180
  }
4181
- function Z(e) {
4182
- let t = Kt.value.findIndex((t) => t.messageId === e.messageId);
4183
- t >= 0 ? Kt.value[t] = e : Kt.value.push(e);
4181
+ function X(e) {
4182
+ let t = qt.value.findIndex((t) => t.messageId === e.messageId);
4183
+ t >= 0 ? qt.value[t] = e : qt.value.push(e);
4184
4184
  }
4185
- function An(e) {
4185
+ function jn(e) {
4186
4186
  let t = It.value, n = t.findIndex((t) => t.id === e.id), r = de(e) ?? "", i = t.slice(0, n).reverse().find((e) => e.role === "user");
4187
4187
  return {
4188
4188
  userQuestion: de(i ?? e) ?? "",
4189
4189
  assistantMessage: r
4190
4190
  };
4191
4191
  }
4192
- async function jn(e, t) {
4192
+ async function Mn(e, t) {
4193
4193
  await Promise.all([
4194
- vn(e, t),
4195
- dn(e),
4196
- kn(t)
4194
+ yn(e, t),
4195
+ fn(e),
4196
+ An(t)
4197
4197
  ]), lt.value || De((e, t) => k.value.reverseGeocode(e, t, r.value)).then((e) => {
4198
4198
  e && (lt.value = e);
4199
4199
  });
4200
4200
  }
4201
- async function Mn() {
4202
- let e = G.value.trim(), t = K.value.filter((e) => e.state === "done" && e.mediaSource !== void 0).map((e) => ({
4201
+ async function Nn() {
4202
+ if (G.value.some((e) => e.state !== "done")) return;
4203
+ let e = W.value.trim(), t = G.value.filter((e) => e.state === "done" && e.mediaSource !== void 0).map((e) => ({
4203
4204
  type: "file",
4204
4205
  mediaType: e.mediaSource.mimeType,
4205
4206
  url: e.localUrl,
4206
4207
  filename: e.mediaSource.name,
4207
4208
  providerMetadata: { "8bot": { media: e.mediaSource } }
4208
4209
  })), n = tt.value ? Fe.value : void 0;
4209
- !T.value && Sn() ? e && t.length === 0 && !n && (on(E.value, [...rn.value, e]), G.value = "") : (T.value && It.value.length > 0 && await Qn(), Pn(e, t, n && { pagePointer: n }), G.value = "", Fe.value = void 0, Zn());
4210
+ !T.value && Cn() ? e && t.length === 0 && !n && (sn(E.value, [...an.value, e]), W.value = "") : (T.value && It.value.length > 0 && await $n(), Fn(e, t, n && { pagePointer: n }), W.value = "", Fe.value = void 0, Qn());
4210
4211
  }
4211
- function Nn(e, t) {
4212
+ function Pn(e, t) {
4212
4213
  let n = e.trim();
4213
- return !n || O.value || Sn() || B.value.status !== "ready" ? !1 : (Pn(n, [], t, { toInput: !1 }), !0);
4214
+ return !n || O.value || Cn() || B.value.status !== "ready" ? !1 : (Fn(n, [], t, { toInput: !1 }), !0);
4214
4215
  }
4215
- function Pn(e, t = [], n, { toInput: r = !0 } = {}) {
4216
- Ct(), q.value = e, J.value = r, en.value = r && n && "pagePointer" in n ? n.pagePointer : void 0, tn.value = B.value.messages.length;
4216
+ function Fn(e, t = [], n, { toInput: r = !0 } = {}) {
4217
+ Ct(), K.value = e, q.value = r, tn.value = r && n && "pagePointer" in n ? n.pagePointer : void 0, nn.value = B.value.messages.length;
4217
4218
  let i = B.value.sendMessage;
4218
4219
  i({
4219
4220
  text: e,
@@ -4221,7 +4222,7 @@ function di(e) {
4221
4222
  ...n && { metadata: n }
4222
4223
  });
4223
4224
  }
4224
- function Fn(e) {
4225
+ function In(e) {
4225
4226
  let t = e.trim();
4226
4227
  if (!t) return;
4227
4228
  if (B.value.status !== "ready") {
@@ -4231,25 +4232,25 @@ function di(e) {
4231
4232
  let n = B.value.sendMessage;
4232
4233
  Ct(), n({ text: t });
4233
4234
  }
4234
- async function In() {
4235
- let e = B.value.messages.slice(tn.value).some((e) => e.parts.some(re)), t = q.value, n = J.value, r = en.value, i = t.length > 0 && !e, a = E.value, s = tn.value, c = F?.chatId === a, l = Dt, u = sn(a), d = (e = "") => {
4236
- G.value = [
4235
+ async function Ln() {
4236
+ let e = B.value.messages.slice(nn.value).some((e) => e.parts.some(re)), t = K.value, n = q.value, r = tn.value, i = t.length > 0 && !e, a = E.value, s = nn.value, c = F?.chatId === a, l = Dt, u = cn(a), d = (e = "") => {
4237
+ W.value = [
4237
4238
  e,
4238
4239
  u,
4239
- G.value
4240
+ W.value
4240
4241
  ].filter(Boolean).join(si);
4241
- }, f = () => a === E.value && !Y() && tn.value === s ? !1 : (u && on(a, [u, ...nn.value[a] ?? []]), !0);
4242
+ }, f = () => a === E.value && !J() && nn.value === s ? !1 : (u && sn(a, [u, ...rn.value[a] ?? []]), !0);
4242
4243
  F = void 0, Et.value = void 0, Ct(), await B.value.stop();
4243
4244
  let p = T.value || e && !c || await k.value.stopChatTurn(o.value, a, l).catch(() => !0);
4244
4245
  if (!f()) {
4245
4246
  if (c || !p) {
4246
- if (await On(), f()) return;
4247
- if (c || B.value.messages.length > tn.value) {
4248
- q.value = "", d();
4247
+ if (await kn(), f()) return;
4248
+ if (c || B.value.messages.length > nn.value) {
4249
+ K.value = "", d();
4249
4250
  return;
4250
4251
  }
4251
4252
  }
4252
- i ? (d(n ? t : ""), Fe.value ??= r, B.value.messages = B.value.messages.slice(0, tn.value), q.value = "") : d();
4253
+ i ? (d(n ? t : ""), Fe.value ??= r, B.value.messages = B.value.messages.slice(0, nn.value), K.value = "") : d();
4253
4254
  }
4254
4255
  }
4255
4256
  C(() => B.value.messages, (e) => {
@@ -4258,92 +4259,92 @@ function di(e) {
4258
4259
  }), C(() => B.value.status, (e) => {
4259
4260
  e === "submitted" && (Ve.value++, Dt = void 0);
4260
4261
  });
4261
- let Ln;
4262
+ let Rn;
4262
4263
  C(() => [
4263
4264
  B.value.status,
4264
4265
  he.value,
4265
4266
  ye.value
4266
4267
  ], ([e, t, n]) => {
4267
- clearTimeout(Ln), e === "ready" && t === 0 && n === 0 && (Ln = setTimeout(() => {
4268
+ clearTimeout(Rn), e === "ready" && t === 0 && n === 0 && (Rn = setTimeout(() => {
4268
4269
  Be.value = !1;
4269
4270
  }, 1500));
4270
4271
  });
4271
- let Rn = x(!1), zn;
4272
- C(() => !A.value && !Jr(Pt()) && (Y() || he.value > 0), (e) => {
4273
- clearTimeout(zn), e ? Rn.value = !0 : zn = setTimeout(() => {
4274
- Rn.value = !1;
4272
+ let zn = x(!1), Bn;
4273
+ C(() => !A.value && !Jr(Pt()) && (J() || he.value > 0), (e) => {
4274
+ clearTimeout(Bn), e ? zn.value = !0 : Bn = setTimeout(() => {
4275
+ zn.value = !1;
4275
4276
  }, 400);
4276
4277
  }, { immediate: !0 });
4277
- let Bn = b(() => {
4278
+ let Vn = b(() => {
4278
4279
  let e = Ot.value.filter((e) => e !== E.value);
4279
- return Rn.value || Et.value === E.value ? [...e, E.value] : e;
4280
- }), Vn = () => [.../* @__PURE__ */ new Set([...Ot.value, ...I.value])], Hn = Ce(), Un, Wn = 0, Gn = 0;
4281
- function Kn() {
4282
- clearTimeout(Un), Un = void 0, Vn().length !== 0 && Hn.value === "visible" && (Un = setTimeout(() => {
4283
- Un = void 0, qn(Vn());
4280
+ return zn.value || Et.value === E.value ? [...e, E.value] : e;
4281
+ }), Hn = () => [.../* @__PURE__ */ new Set([...Ot.value, ...I.value])], Un = Ce(), Wn, Gn = 0, Kn = 0;
4282
+ function qn() {
4283
+ clearTimeout(Wn), Wn = void 0, Hn().length !== 0 && Un.value === "visible" && (Wn = setTimeout(() => {
4284
+ Wn = void 0, Jn(Hn());
4284
4285
  }, ti));
4285
4286
  }
4286
- async function qn(e) {
4287
+ async function Jn(e) {
4287
4288
  let t = e.slice(0, ni);
4288
4289
  if (T.value || t.length === 0) {
4289
- Kn();
4290
+ qn();
4290
4291
  return;
4291
4292
  }
4292
- let n = Wn += 1, r;
4293
+ let n = Gn += 1, r;
4293
4294
  try {
4294
4295
  r = await k.value.getRunningTurns(o.value, t);
4295
4296
  } catch {
4296
- Kn();
4297
+ qn();
4297
4298
  return;
4298
4299
  }
4299
- if (n <= Gn) return;
4300
- Gn = n;
4300
+ if (n <= Kn) return;
4301
+ Kn = n;
4301
4302
  for (let e of r) At.add(e);
4302
- let i = new Set(t), a = Vn().filter((e) => i.has(e) && !r.includes(e)), s = (e) => I.value.includes(e) && !At.has(e), c = a.filter((e) => s(e) && Date.now() - (kt.get(e) ?? 0) > ri), l = a.filter((e) => !s(e));
4303
+ let i = new Set(t), a = Hn().filter((e) => i.has(e) && !r.includes(e)), s = (e) => I.value.includes(e) && !At.has(e), c = a.filter((e) => s(e) && Date.now() - (kt.get(e) ?? 0) > ri), l = a.filter((e) => !s(e));
4303
4304
  Ot.value = [...Ot.value.filter((e) => !i.has(e)), ...r];
4304
4305
  let u = l.filter((e) => I.value.includes(e));
4305
- (u.length > 0 || c.length > 0) && (I.value = I.value.filter((e) => !u.includes(e) && !c.includes(e)), L.value = [...L.value, ...u.filter((e) => e !== E.value && !L.value.includes(e))]), l.length > 0 && dn(o.value), Kn();
4306
+ (u.length > 0 || c.length > 0) && (I.value = I.value.filter((e) => !u.includes(e) && !c.includes(e)), L.value = [...L.value, ...u.filter((e) => e !== E.value && !L.value.includes(e))]), l.length > 0 && fn(o.value), qn();
4306
4307
  }
4307
- C(Hn, (e) => {
4308
- e === "visible" ? qn(Vn()) : (clearTimeout(Un), Un = void 0);
4309
- }), _e(() => clearTimeout(Un));
4310
- let Jn = b(() => L.value.map((e) => ({
4308
+ C(Un, (e) => {
4309
+ e === "visible" ? Jn(Hn()) : (clearTimeout(Wn), Wn = void 0);
4310
+ }), _e(() => clearTimeout(Wn));
4311
+ let Yn = b(() => L.value.map((e) => ({
4311
4312
  chatId: e,
4312
4313
  title: U.value.find((t) => t.id === e)?.title || R.value[e] || void 0
4313
4314
  })));
4314
- function Yn(e) {
4315
- Mt(e), E.value = e, xr("chat");
4316
- }
4317
4315
  function Xn(e) {
4316
+ Mt(e), E.value = e, Er("chat");
4317
+ }
4318
+ function Zn(e) {
4318
4319
  L.value = L.value.filter((t) => t !== e), z(e);
4319
4320
  }
4320
4321
  C(() => [B.value.status, B.value.id], ([e, t], [n, r]) => {
4321
4322
  if (t === r) {
4322
- if (e === "error") F?.chatId !== E.value && cn(sn(E.value));
4323
+ if (e === "error") F?.chatId !== E.value && ln(cn(E.value));
4323
4324
  else if (e === "ready" && (n === "streaming" || n === "submitted")) {
4324
- if (Cn()) {
4325
- cn(sn(E.value));
4325
+ if (wn()) {
4326
+ ln(cn(E.value));
4326
4327
  return;
4327
4328
  }
4328
- Tn();
4329
+ En();
4329
4330
  }
4330
4331
  }
4331
4332
  }), C(he, (e) => {
4332
- e === 0 && B.value.status === "ready" && Tn();
4333
+ e === 0 && B.value.status === "ready" && En();
4333
4334
  }), C(() => B.value.status, (e) => {
4334
- e === "ready" && q.value.length > 0 && (q.value = "");
4335
+ e === "ready" && K.value.length > 0 && (K.value = "");
4335
4336
  });
4336
- function Zn(e = !1) {
4337
- for (let t of K.value) (e || t.state !== "done") && URL.revokeObjectURL(t.localUrl);
4338
- K.value = [], or.value = null;
4337
+ function Qn(e = !1) {
4338
+ for (let t of G.value) (e || t.state !== "done") && URL.revokeObjectURL(t.localUrl);
4339
+ G.value = [], sr.value = null;
4339
4340
  }
4340
- async function Qn() {
4341
- return q.value = "", Re.value = {}, ze.value = {}, E.value = ft(), await ge(), B.value.clearError(), at.value = void 0, O.value = !1, Zn(!0), xr("chat"), E.value;
4341
+ async function $n() {
4342
+ return K.value = "", Re.value = {}, ze.value = {}, E.value = ft(), await ge(), B.value.clearError(), at.value = void 0, O.value = !1, Qn(!0), Er("chat"), E.value;
4342
4343
  }
4343
- async function $n(e) {
4344
- B.value.status !== "ready" && (q.value = "", await In()), Ct(), await B.value.regenerate(e);
4344
+ async function er(e) {
4345
+ B.value.status !== "ready" && (K.value = "", await Ln()), Ct(), await B.value.regenerate(e);
4345
4346
  }
4346
- function er(e) {
4347
+ function tr(e) {
4347
4348
  if (e.tool === "requestGeolocation") {
4348
4349
  let t = e.output;
4349
4350
  "latitude" in t && (lt.value = {
@@ -4355,64 +4356,84 @@ function di(e) {
4355
4356
  }
4356
4357
  B.value.addToolOutput(e);
4357
4358
  }
4358
- function tr(e) {
4359
+ function nr(e) {
4359
4360
  B.value.addToolApprovalResponse(e);
4360
4361
  }
4361
- let nr = b(() => B.value.messages.reduce((e, t) => e + t.parts.filter((e) => e.type === "file").length, 0)), rr = b(() => _.value?.maxFilesPerMessage ?? 5), Q = b(() => _.value?.maxFilesPerChat ?? 20), ir = b(() => Math.max(0, Math.min(rr.value - K.value.length, Q.value - nr.value - K.value.length))), ar = b(() => ir.value <= 0), or = x(null), sr = () => {
4362
- or.value = null;
4362
+ let rr = b(() => B.value.messages.reduce((e, t) => e + t.parts.filter((e) => e.type === "file").length, 0)), ir = b(() => _.value?.maxFilesPerMessage ?? 5), Z = b(() => _.value?.maxFilesPerChat ?? 20), ar = b(() => Math.max(0, Math.min(ir.value - G.value.length, Z.value - rr.value - G.value.length))), or = b(() => ar.value <= 0), sr = x(null), cr = () => {
4363
+ sr.value = null;
4363
4364
  };
4364
- C(ar, (e) => {
4365
- e || (or.value = null);
4365
+ C(or, (e) => {
4366
+ e || (sr.value = null);
4366
4367
  });
4367
- async function cr(e) {
4368
- if (ar.value) {
4369
- or.value = Q.value - nr.value - K.value.length <= rr.value - K.value.length ? {
4368
+ async function lr(e) {
4369
+ if (or.value) {
4370
+ sr.value = Z.value - rr.value - G.value.length <= ir.value - G.value.length ? {
4370
4371
  reason: "per-chat",
4371
- max: Q.value
4372
+ max: Z.value
4372
4373
  } : {
4373
4374
  reason: "per-message",
4374
- max: rr.value
4375
+ max: ir.value
4375
4376
  };
4376
4377
  return;
4377
4378
  }
4378
- let t = ft(), n = {
4379
- id: t,
4379
+ let t = fr(e);
4380
+ G.value = [...G.value, t], await pr(t);
4381
+ }
4382
+ async function ur(e, t) {
4383
+ let n = G.value.find((t) => t.id === e.id);
4384
+ if (!n) return;
4385
+ URL.revokeObjectURL(n.localUrl);
4386
+ let r = fr(t);
4387
+ G.value = G.value.map((e) => e.id === n.id ? r : e), await Promise.all([mr(n), pr(r)]);
4388
+ }
4389
+ async function dr(e) {
4390
+ let t = G.value.find((t) => t.id === e.id && t.state === "error");
4391
+ t && (G.value = G.value.map((e) => e.id === t.id ? {
4392
+ ...e,
4393
+ state: "uploading",
4394
+ error: void 0
4395
+ } : e), await pr(t));
4396
+ }
4397
+ function fr(e) {
4398
+ return {
4399
+ id: ft(),
4380
4400
  file: e,
4381
4401
  localUrl: URL.createObjectURL(e),
4382
4402
  state: "uploading"
4383
4403
  };
4384
- K.value = [...K.value, n];
4404
+ }
4405
+ async function pr({ id: e, file: t }) {
4385
4406
  try {
4386
- let n = await k.value.uploadMedia(o.value, E.value, e);
4387
- if (!K.value.some((e) => e.id === t)) {
4388
- await ur(n);
4407
+ let n = await k.value.uploadMedia(o.value, E.value, t);
4408
+ if (!G.value.some((t) => t.id === e)) {
4409
+ await hr(n);
4389
4410
  return;
4390
4411
  }
4391
- K.value = K.value.map((e) => e.id === t ? {
4392
- ...e,
4412
+ G.value = G.value.map((t) => t.id === e ? {
4413
+ ...t,
4393
4414
  state: "done",
4394
4415
  mediaSource: n
4395
- } : e);
4396
- } catch (e) {
4397
- let n = e instanceof Error ? e.message : "Upload failed";
4398
- K.value = K.value.map((e) => e.id === t ? {
4399
- ...e,
4416
+ } : t);
4417
+ } catch (t) {
4418
+ let n = t instanceof Error ? t.message : "Upload failed";
4419
+ G.value = G.value.map((t) => t.id === e ? {
4420
+ ...t,
4400
4421
  state: "error",
4401
4422
  error: n
4402
- } : e);
4423
+ } : t);
4403
4424
  }
4404
4425
  }
4405
- async function lr(e) {
4406
- e.mediaSource && await ur(e.mediaSource);
4426
+ async function mr(e) {
4427
+ e.mediaSource && await hr(e.mediaSource);
4407
4428
  }
4408
- async function ur(e) {
4429
+ async function hr(e) {
4409
4430
  try {
4410
4431
  await k.value.discardMedia(e);
4411
4432
  } catch {}
4412
4433
  }
4413
- async function dr(e, t) {
4414
- let { userQuestion: n, assistantMessage: r } = An(e);
4415
- Z(await k.value.submitMessageFeedback({
4434
+ async function _r(e, t) {
4435
+ let { userQuestion: n, assistantMessage: r } = jn(e);
4436
+ X(await k.value.submitMessageFeedback({
4416
4437
  messageId: e.id,
4417
4438
  chatId: E.value,
4418
4439
  agentId: o.value,
@@ -4421,73 +4442,73 @@ function di(e) {
4421
4442
  assistantMessage: r
4422
4443
  }));
4423
4444
  }
4424
- async function fr(e) {
4425
- await dr(e, "upvote");
4445
+ async function yr(e) {
4446
+ await _r(e, "upvote");
4426
4447
  }
4427
- async function pr(e) {
4428
- await dr(e, "downvote");
4448
+ async function br(e) {
4449
+ await _r(e, "downvote");
4429
4450
  }
4430
- function mr(e) {
4431
- Yt.value = !1, Xt.value = void 0, qt.value = e;
4451
+ function xr(e) {
4452
+ Xt.value = !1, Zt.value = void 0, Jt.value = e;
4432
4453
  }
4433
- async function gr(e) {
4434
- if (qt.value) try {
4435
- Jt.value = !0, Yt.value = !1, Xt.value = void 0;
4436
- let { userQuestion: t, assistantMessage: n } = An(qt.value);
4437
- Z(await k.value.submitMessageFeedback({
4438
- messageId: qt.value.id,
4454
+ async function Sr(e) {
4455
+ if (Jt.value) try {
4456
+ Yt.value = !0, Xt.value = !1, Zt.value = void 0;
4457
+ let { userQuestion: t, assistantMessage: n } = jn(Jt.value);
4458
+ X(await k.value.submitMessageFeedback({
4459
+ messageId: Jt.value.id,
4439
4460
  chatId: E.value,
4440
4461
  agentId: o.value,
4441
4462
  userQuestion: t,
4442
4463
  assistantMessage: n,
4443
4464
  comment: e
4444
- })), Yt.value = !0, await kn(E.value);
4465
+ })), Xt.value = !0, await An(E.value);
4445
4466
  } catch {
4446
- Xt.value = n("message.feedbackSubmitError") ? t("message.feedbackSubmitError") : "Failed to submit feedback";
4467
+ Zt.value = n("message.feedbackSubmitError") ? t("message.feedbackSubmitError") : "Failed to submit feedback";
4447
4468
  } finally {
4448
- Jt.value = !1;
4469
+ Yt.value = !1;
4449
4470
  }
4450
4471
  }
4451
- async function vr(e) {
4472
+ async function Cr(e) {
4452
4473
  try {
4453
- Qt.value = !0, Zt.value = !1, $t.value = void 0, await k.value.submitLead({
4474
+ $t.value = !0, Qt.value = !1, en.value = void 0, await k.value.submitLead({
4454
4475
  agentId: o.value,
4455
4476
  chatId: E.value,
4456
4477
  ...e
4457
- }), Zt.value = !0;
4478
+ }), Qt.value = !0;
4458
4479
  } catch {
4459
- $t.value = n("message.leadSubmitError") ? t("message.leadSubmitError") : "Failed to submit lead";
4480
+ en.value = n("message.leadSubmitError") ? t("message.leadSubmitError") : "Failed to submit lead";
4460
4481
  } finally {
4461
- Qt.value = !1;
4482
+ $t.value = !1;
4462
4483
  }
4463
4484
  }
4464
- async function yr(e, t) {
4485
+ async function wr(e, t) {
4465
4486
  let n = await k.value.updateChatTitle(o.value, e, t);
4466
4487
  U.value = U.value.map((t) => t.id === e ? {
4467
4488
  ...t,
4468
4489
  title: n.title
4469
4490
  } : t);
4470
4491
  }
4471
- async function br(e) {
4472
- await k.value.deleteChat(o.value, e), U.value = U.value.filter((t) => t.id !== e), E.value === e && await Qn();
4492
+ async function Tr(e) {
4493
+ await k.value.deleteChat(o.value, e), U.value = U.value.filter((t) => t.id !== e), E.value === e && await $n();
4473
4494
  }
4474
- function xr(e) {
4475
- Wt.value = e;
4495
+ function Er(e) {
4496
+ Gt.value = e;
4476
4497
  }
4477
- function Sr() {
4478
- xr("chat"), Gt.value++;
4498
+ function Q() {
4499
+ Er("chat"), Kt.value++;
4479
4500
  }
4480
- let Cr;
4481
- function wr(e) {
4501
+ let $;
4502
+ function Dr(e) {
4482
4503
  let t = () => k.value.getChat(o.value, e).then((e) => e !== null);
4483
4504
  return t().catch(() => t().catch(() => !1));
4484
4505
  }
4485
4506
  return C(l, async (e) => {
4486
- if (!e || e === Cr) return;
4487
- let t = Cr;
4488
- if (Cr = e, t === void 0) return;
4489
- let n = E.value, r = !T.value && await wr(n);
4490
- l.value === e && E.value === n && (r ? dn(o.value) : (U.value = [], Kt.value = [], W.value = [], Ot.value = [], I.value = [], L.value = [], R.value = {}, await Qn(), G.value = ""));
4507
+ if (!e || e === $) return;
4508
+ let t = $;
4509
+ if ($ = e, t === void 0) return;
4510
+ let n = E.value, r = !T.value && await Dr(n);
4511
+ l.value === e && E.value === n && (r ? fn(o.value) : (U.value = [], qt.value = [], Ut.value = [], Ot.value = [], I.value = [], L.value = [], R.value = {}, await $n(), W.value = ""));
4491
4512
  }), {
4492
4513
  apiClient: k,
4493
4514
  baseUrl: i,
@@ -4519,7 +4540,7 @@ function di(e) {
4519
4540
  hostStepTitles: Re,
4520
4541
  hostStepChanges: ze,
4521
4542
  pageControlActive: Be,
4522
- isWorking: Rn,
4543
+ isWorking: zn,
4523
4544
  stopHostActions: St,
4524
4545
  voicePageTools: xt,
4525
4546
  cancelVoicePageCalls: P,
@@ -4532,7 +4553,7 @@ function di(e) {
4532
4553
  setPageAccessOff: wt,
4533
4554
  agentConfirmations: Te,
4534
4555
  agentSelectionActions: ke,
4535
- sendSelection: Nn,
4556
+ sendSelection: Pn,
4536
4557
  confirmationsAvailable: Qe,
4537
4558
  confirmationMode: $e,
4538
4559
  setConfirmationMode: et,
@@ -4549,68 +4570,70 @@ function di(e) {
4549
4570
  isLoadingConversations: Rt,
4550
4571
  hasMoreConversations: Bt,
4551
4572
  isLoadingMoreConversations: Vt,
4552
- chatFiles: W,
4553
- isLoadingChatFiles: Ut,
4554
- input: G,
4555
- pendingAttachments: K,
4556
- isAttachmentLimitReached: ar,
4557
- fileLimitError: or,
4573
+ chatFiles: Ut,
4574
+ isLoadingChatFiles: Wt,
4575
+ input: W,
4576
+ pendingAttachments: G,
4577
+ isAttachmentLimitReached: or,
4578
+ fileLimitError: sr,
4558
4579
  localChatId: E,
4559
4580
  isConversationBlocked: O,
4560
4581
  inputMessagePlaceholder: Lt,
4561
4582
  chatError: at,
4562
- runningChatIds: Bn,
4563
- backgroundAnswers: Jn,
4564
- openBackgroundAnswer: Yn,
4565
- dismissBackgroundAnswer: Xn,
4566
- canQueue: an,
4567
- queuedMessages: rn,
4568
- removeQueuedMessage: ln,
4569
- editQueuedMessage: un,
4570
- activeView: Wt,
4571
- inputFocusRequest: Gt,
4572
- messageFeedbacks: Kt,
4573
- feedbackDialogMessage: qt,
4574
- isFeedbackSubmitting: Jt,
4575
- isFeedbackSubmitted: Yt,
4576
- feedbackSubmitError: Xt,
4577
- isLeadSubmitted: Zt,
4578
- isLoadingSubmitLead: Qt,
4579
- submitLeadError: $t,
4583
+ runningChatIds: Vn,
4584
+ backgroundAnswers: Yn,
4585
+ openBackgroundAnswer: Xn,
4586
+ dismissBackgroundAnswer: Zn,
4587
+ canQueue: on,
4588
+ queuedMessages: an,
4589
+ removeQueuedMessage: un,
4590
+ editQueuedMessage: dn,
4591
+ activeView: Gt,
4592
+ inputFocusRequest: Kt,
4593
+ messageFeedbacks: qt,
4594
+ feedbackDialogMessage: Jt,
4595
+ isFeedbackSubmitting: Yt,
4596
+ isFeedbackSubmitted: Xt,
4597
+ feedbackSubmitError: Zt,
4598
+ isLeadSubmitted: Qt,
4599
+ isLoadingSubmitLead: $t,
4600
+ submitLeadError: en,
4580
4601
  buildDeviceContext: ut,
4581
- initialize: jn,
4582
- loadConversations: dn,
4583
- loadMoreConversations: fn,
4584
- searchConversations: pn,
4585
- loadChatFiles: mn,
4586
- refreshMessages: On,
4587
- appendMessage: X,
4588
- getChatFileUrl: hn,
4589
- getChatFilePreviewUrl: gn,
4590
- deleteChatFile: _n,
4591
- handleSubmit: Mn,
4592
- sendMessage: Fn,
4593
- stopGeneration: In,
4594
- startNewChat: Qn,
4595
- regenerate: $n,
4596
- addToolOutput: er,
4597
- addToolApprovalResponse: tr,
4598
- handleFileSelect: cr,
4599
- discardPendingAttachment: lr,
4600
- clearFileLimitError: sr,
4601
- clearPendingAttachments: Zn,
4602
- onUpvote: fr,
4603
- onDownvote: pr,
4604
- onFeedback: mr,
4605
- onFeedbackSubmit: gr,
4606
- onLeadSubmit: vr,
4607
- navigate: xr,
4608
- focusInput: Sr,
4609
- renameChatTitle: yr,
4610
- deleteChat: br
4602
+ initialize: Mn,
4603
+ loadConversations: fn,
4604
+ loadMoreConversations: pn,
4605
+ searchConversations: mn,
4606
+ loadChatFiles: hn,
4607
+ refreshMessages: kn,
4608
+ appendMessage: Y,
4609
+ getChatFileUrl: gn,
4610
+ getChatFilePreviewUrl: _n,
4611
+ deleteChatFile: vn,
4612
+ handleSubmit: Nn,
4613
+ sendMessage: In,
4614
+ stopGeneration: Ln,
4615
+ startNewChat: $n,
4616
+ regenerate: er,
4617
+ addToolOutput: tr,
4618
+ addToolApprovalResponse: nr,
4619
+ handleFileSelect: lr,
4620
+ discardPendingAttachment: mr,
4621
+ replacePendingAttachment: ur,
4622
+ retryPendingAttachment: dr,
4623
+ clearFileLimitError: cr,
4624
+ clearPendingAttachments: Qn,
4625
+ onUpvote: yr,
4626
+ onDownvote: br,
4627
+ onFeedback: xr,
4628
+ onFeedbackSubmit: Sr,
4629
+ onLeadSubmit: Cr,
4630
+ navigate: Er,
4631
+ focusInput: Q,
4632
+ renameChatTitle: wr,
4633
+ deleteChat: Tr
4611
4634
  };
4612
4635
  })();
4613
4636
  }
4614
- export { ft as a, hr as i, di as n, Gr as r, Kr as t };
4637
+ export { ft as a, gr as i, di as n, Gr as r, Kr as t };
4615
4638
 
4616
- //# sourceMappingURL=useChatbotStore-BZ1n3Hyx.js.map
4639
+ //# sourceMappingURL=useChatbotStore-BIjCGX0B.js.map