@8wave/ai-elements 0.125.0-beta.41 → 0.125.0-beta.42

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 (161) hide show
  1. package/dist/_chunks/{Agent-CeZ3bgZ3.js → Agent-DMvYDpLa.js} +123 -122
  2. package/dist/_chunks/Agent-DMvYDpLa.js.map +1 -0
  3. package/dist/_chunks/{PkFilePreview-D_1ZgiiA.js → PkFilePreview-DC4iX7Yc.js} +234 -209
  4. package/dist/_chunks/PkFilePreview-DC4iX7Yc.js.map +1 -0
  5. package/dist/_chunks/{PkFilePreviewDialog-CI22huzK.js → PkFilePreviewDialog-bcTkTcYk.js} +12 -7
  6. package/dist/_chunks/PkFilePreviewDialog-bcTkTcYk.js.map +1 -0
  7. package/dist/_chunks/{PkImageEditorDialog-CAEninFi.js → PkImageEditorDialog-FpbyhV3t.js} +2 -2
  8. package/dist/_chunks/{PkImageEditorDialog-CAEninFi.js.map → PkImageEditorDialog-FpbyhV3t.js.map} +1 -1
  9. package/dist/_chunks/{PkSelectionActions-BriGyWCi.js → PkSelectionActions-BbfVZY0R.js} +140 -13
  10. package/dist/_chunks/PkSelectionActions-BbfVZY0R.js.map +1 -0
  11. package/dist/_chunks/{PkStreamingMarkdown--9i0feuM.js → PkStreamingMarkdown-COSOOhCg.js} +3 -3
  12. package/dist/_chunks/{PkStreamingMarkdown--9i0feuM.js.map → PkStreamingMarkdown-COSOOhCg.js.map} +1 -1
  13. package/dist/_chunks/{PkToolChatFile-BKGUnWrj.js → PkToolChatFile-C_gS0X1j.js} +3 -3
  14. package/dist/_chunks/{PkToolChatFile-BKGUnWrj.js.map → PkToolChatFile-C_gS0X1j.js.map} +1 -1
  15. package/dist/_chunks/{PkToolRequestGeolocation-DktrQJvA.js → PkToolRequestGeolocation-CwDQnr7u.js} +2 -2
  16. package/dist/_chunks/{PkToolRequestGeolocation-DktrQJvA.js.map → PkToolRequestGeolocation-CwDQnr7u.js.map} +1 -1
  17. package/dist/_chunks/{PkToolRequestOAuthConnection-DkcLwFWl.js → PkToolRequestOAuthConnection-DkrnVowp.js} +2 -2
  18. package/dist/_chunks/{PkToolRequestOAuthConnection-DkcLwFWl.js.map → PkToolRequestOAuthConnection-DkrnVowp.js.map} +1 -1
  19. package/dist/_chunks/{PkToolShowArtifact-BfLpz2-W.js → PkToolShowArtifact-fpFtKrZo.js} +2 -2
  20. package/dist/_chunks/{PkToolShowArtifact-BfLpz2-W.js.map → PkToolShowArtifact-fpFtKrZo.js.map} +1 -1
  21. package/dist/_chunks/{PkToolShowContactForm-BsF6DFzV.js → PkToolShowContactForm-BAM772bm.js} +2 -2
  22. package/dist/_chunks/{PkToolShowContactForm-BsF6DFzV.js.map → PkToolShowContactForm-BAM772bm.js.map} +1 -1
  23. package/dist/_chunks/{PkToolShowForm-w6RvbKEB.js → PkToolShowForm-DJcL0bgw.js} +4 -4
  24. package/dist/_chunks/{PkToolShowForm-w6RvbKEB.js.map → PkToolShowForm-DJcL0bgw.js.map} +1 -1
  25. package/dist/_chunks/{PkToolShowImageGallery-BEddh4He.js → PkToolShowImageGallery-DhB_ucYe.js} +2 -2
  26. package/dist/_chunks/{PkToolShowImageGallery-BEddh4He.js.map → PkToolShowImageGallery-DhB_ucYe.js.map} +1 -1
  27. package/dist/_chunks/{PkToolShowProductList-k-VB4pUB.js → PkToolShowProductList-DfcJJrOC.js} +2 -2
  28. package/dist/_chunks/{PkToolShowProductList-k-VB4pUB.js.map → PkToolShowProductList-DfcJJrOC.js.map} +1 -1
  29. package/dist/_chunks/{PkToolShowSources-CGESvGrm.js → PkToolShowSources-GeWAMHYC.js} +3 -3
  30. package/dist/_chunks/{PkToolShowSources-CGESvGrm.js.map → PkToolShowSources-GeWAMHYC.js.map} +1 -1
  31. package/dist/_chunks/{PkToolShowSuggestedReply-DTAq41wP.js → PkToolShowSuggestedReply-gpuWzpoh.js} +2 -2
  32. package/dist/_chunks/{PkToolShowSuggestedReply-DTAq41wP.js.map → PkToolShowSuggestedReply-gpuWzpoh.js.map} +1 -1
  33. package/dist/_chunks/{PkToolShowVideo-DeexblEL.js → PkToolShowVideo-CikqhGpT.js} +2 -2
  34. package/dist/_chunks/{PkToolShowVideo-DeexblEL.js.map → PkToolShowVideo-CikqhGpT.js.map} +1 -1
  35. package/dist/_chunks/{PkToolShowWebPages-C42FNo8K.js → PkToolShowWebPages-B-LuiAtg.js} +2 -2
  36. package/dist/_chunks/{PkToolShowWebPages-C42FNo8K.js.map → PkToolShowWebPages-B-LuiAtg.js.map} +1 -1
  37. package/dist/_chunks/{chatImagePolicy-DlZPHhW-.js → chatImagePolicy-Dv_WHhDs.js} +2 -2
  38. package/dist/_chunks/{chatImagePolicy-DlZPHhW-.js.map → chatImagePolicy-Dv_WHhDs.js.map} +1 -1
  39. package/dist/_chunks/{markdown-DNPhTO5l.js → markdown-BYpvcbWH.js} +2 -2
  40. package/dist/_chunks/{markdown-DNPhTO5l.js.map → markdown-BYpvcbWH.js.map} +1 -1
  41. package/dist/_chunks/{utils-zkq8kMz-.js → utils-DMvy5QRR.js} +2 -2
  42. package/dist/_chunks/{utils-zkq8kMz-.js.map → utils-DMvy5QRR.js.map} +1 -1
  43. package/dist/ai-elements.es.js +405 -135
  44. package/dist/ai-elements.es.js.map +1 -1
  45. package/dist-vue/PkChatbot.js +1 -1
  46. package/dist-vue/PkChatbotEmptyState.js +1 -1
  47. package/dist-vue/PkChatbotInput.js +1 -1
  48. package/dist-vue/PkChatbotMessages.js +1 -1
  49. package/dist-vue/PkChatbotStepPayload.js +1 -1
  50. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  51. package/dist-vue/PkChatbotSteps.js +1 -1
  52. package/dist-vue/PkChatbotViewChat.js +1 -1
  53. package/dist-vue/PkChatbotViewConversations.js +1 -1
  54. package/dist-vue/PkChatbotViewFiles.js +1 -1
  55. package/dist-vue/PkChatbotViewProfile.js +1 -1
  56. package/dist-vue/_chunks/{Agent-ldDZiq6E.js → Agent-B9iJ1WvR.js} +131 -130
  57. package/dist-vue/_chunks/Agent-B9iJ1WvR.js.map +1 -0
  58. package/dist-vue/_chunks/{Document-BfjAfogy.js → Document-DnsOE7s6.js} +2 -2
  59. package/dist-vue/_chunks/{Document-BfjAfogy.js.map → Document-DnsOE7s6.js.map} +1 -1
  60. package/dist-vue/_chunks/{PkChart-DyyBXkd3.js → PkChart-D-K7nc0g.js} +2 -2
  61. package/dist-vue/_chunks/{PkChart-DyyBXkd3.js.map → PkChart-D-K7nc0g.js.map} +1 -1
  62. package/dist-vue/_chunks/{PkChatbot-wsqj3EpU.js → PkChatbot-DVQ-Bb7n.js} +8 -8
  63. package/dist-vue/_chunks/{PkChatbot-wsqj3EpU.js.map → PkChatbot-DVQ-Bb7n.js.map} +1 -1
  64. package/dist-vue/_chunks/{PkChatbotEmptyState-DcgIfNkX.js → PkChatbotEmptyState-OlgewA4_.js} +2 -2
  65. package/dist-vue/_chunks/{PkChatbotEmptyState-DcgIfNkX.js.map → PkChatbotEmptyState-OlgewA4_.js.map} +1 -1
  66. package/dist-vue/_chunks/{PkChatbotInput-CN4rmNgu.js → PkChatbotInput-D_I0Gf_u.js} +4 -4
  67. package/dist-vue/_chunks/{PkChatbotInput-CN4rmNgu.js.map → PkChatbotInput-D_I0Gf_u.js.map} +1 -1
  68. package/dist-vue/_chunks/{PkChatbotMessages-BlF4Xp0_.js → PkChatbotMessages-CAXnEfXK.js} +18 -18
  69. package/dist-vue/_chunks/{PkChatbotMessages-BlF4Xp0_.js.map → PkChatbotMessages-CAXnEfXK.js.map} +1 -1
  70. package/dist-vue/_chunks/{PkChatbotStepPayload-q9uXE5mr.js → PkChatbotStepPayload-EBri1L10.js} +2 -2
  71. package/dist-vue/_chunks/{PkChatbotStepPayload-q9uXE5mr.js.map → PkChatbotStepPayload-EBri1L10.js.map} +1 -1
  72. package/dist-vue/_chunks/{PkChatbotStepToolDetail-BJz6Qwh3.js → PkChatbotStepToolDetail-DiQEa0UV.js} +3 -3
  73. package/dist-vue/_chunks/{PkChatbotStepToolDetail-BJz6Qwh3.js.map → PkChatbotStepToolDetail-DiQEa0UV.js.map} +1 -1
  74. package/dist-vue/_chunks/{PkChatbotSteps-DvJYNl_k.js → PkChatbotSteps-BgLnv2J1.js} +5 -5
  75. package/dist-vue/_chunks/{PkChatbotSteps-DvJYNl_k.js.map → PkChatbotSteps-BgLnv2J1.js.map} +1 -1
  76. package/dist-vue/_chunks/{PkChatbotViewChat-tmHyxxT3.js → PkChatbotViewChat-CmjD1IXf.js} +360 -355
  77. package/dist-vue/_chunks/PkChatbotViewChat-CmjD1IXf.js.map +1 -0
  78. package/dist-vue/_chunks/{PkChatbotViewConversations-DOzUh_A7.js → PkChatbotViewConversations-CVZH5dXx.js} +3 -3
  79. package/dist-vue/_chunks/{PkChatbotViewConversations-DOzUh_A7.js.map → PkChatbotViewConversations-CVZH5dXx.js.map} +1 -1
  80. package/dist-vue/_chunks/{PkChatbotViewFiles-CsL8OhcA.js → PkChatbotViewFiles-CO4gv9nd.js} +3 -3
  81. package/dist-vue/_chunks/{PkChatbotViewFiles-CsL8OhcA.js.map → PkChatbotViewFiles-CO4gv9nd.js.map} +1 -1
  82. package/dist-vue/_chunks/{PkChatbotViewProfile-CFqxCK2f.js → PkChatbotViewProfile-CriJtak0.js} +2 -2
  83. package/dist-vue/_chunks/{PkChatbotViewProfile-CFqxCK2f.js.map → PkChatbotViewProfile-CriJtak0.js.map} +1 -1
  84. package/dist-vue/_chunks/{PkFilePreview-Bp5-Pl54.js → PkFilePreview-k5gEl3n8.js} +586 -434
  85. package/dist-vue/_chunks/PkFilePreview-k5gEl3n8.js.map +1 -0
  86. package/dist-vue/_chunks/{PkFilePreviewDialog-CS885vBR.js → PkFilePreviewDialog-DUwZPErE.js} +12 -7
  87. package/dist-vue/_chunks/PkFilePreviewDialog-DUwZPErE.js.map +1 -0
  88. package/dist-vue/_chunks/{PkImageEditorDialog-BhfdnsmX.js → PkImageEditorDialog-DQPXePae.js} +2 -2
  89. package/dist-vue/_chunks/{PkImageEditorDialog-BhfdnsmX.js.map → PkImageEditorDialog-DQPXePae.js.map} +1 -1
  90. package/dist-vue/_chunks/{PkStreamingMarkdown-NgrJUZPI.js → PkStreamingMarkdown-ZasabxE0.js} +3 -3
  91. package/dist-vue/_chunks/{PkStreamingMarkdown-NgrJUZPI.js.map → PkStreamingMarkdown-ZasabxE0.js.map} +1 -1
  92. package/dist-vue/_chunks/{PkToolChatFile-DnmiNGF4.js → PkToolChatFile-CD26Q2xp.js} +3 -3
  93. package/dist-vue/_chunks/{PkToolChatFile-DnmiNGF4.js.map → PkToolChatFile-CD26Q2xp.js.map} +1 -1
  94. package/dist-vue/_chunks/{PkToolRequestGeolocation-D1XNCvdr.js → PkToolRequestGeolocation-Bhh7UomV.js} +2 -2
  95. package/dist-vue/_chunks/{PkToolRequestGeolocation-D1XNCvdr.js.map → PkToolRequestGeolocation-Bhh7UomV.js.map} +1 -1
  96. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-OTvMRYaL.js → PkToolRequestOAuthConnection-8GJlt5G1.js} +2 -2
  97. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-OTvMRYaL.js.map → PkToolRequestOAuthConnection-8GJlt5G1.js.map} +1 -1
  98. package/dist-vue/_chunks/{PkToolShowArtifact-C8ueuIGQ.js → PkToolShowArtifact-BhVd_ZQ8.js} +2 -2
  99. package/dist-vue/_chunks/{PkToolShowArtifact-C8ueuIGQ.js.map → PkToolShowArtifact-BhVd_ZQ8.js.map} +1 -1
  100. package/dist-vue/_chunks/{PkToolShowChart-BWO6Hzlq.js → PkToolShowChart-BQXxaPIO.js} +3 -3
  101. package/dist-vue/_chunks/{PkToolShowChart-BWO6Hzlq.js.map → PkToolShowChart-BQXxaPIO.js.map} +1 -1
  102. package/dist-vue/_chunks/{PkToolShowContactForm-BBcDsLEO.js → PkToolShowContactForm-CackCDGD.js} +2 -2
  103. package/dist-vue/_chunks/{PkToolShowContactForm-BBcDsLEO.js.map → PkToolShowContactForm-CackCDGD.js.map} +1 -1
  104. package/dist-vue/_chunks/{PkToolShowDiagram-BzUcxOKy.js → PkToolShowDiagram-CABPsFi8.js} +2 -2
  105. package/dist-vue/_chunks/{PkToolShowDiagram-BzUcxOKy.js.map → PkToolShowDiagram-CABPsFi8.js.map} +1 -1
  106. package/dist-vue/_chunks/{PkToolShowForm-B6uhHzJ8.js → PkToolShowForm-BStbk4Iu.js} +4 -4
  107. package/dist-vue/_chunks/{PkToolShowForm-B6uhHzJ8.js.map → PkToolShowForm-BStbk4Iu.js.map} +1 -1
  108. package/dist-vue/_chunks/{PkToolShowImageGallery-C39nlJrJ.js → PkToolShowImageGallery-BeeHsdTp.js} +2 -2
  109. package/dist-vue/_chunks/{PkToolShowImageGallery-C39nlJrJ.js.map → PkToolShowImageGallery-BeeHsdTp.js.map} +1 -1
  110. package/dist-vue/_chunks/{PkToolShowProductList-FLLkRCnm.js → PkToolShowProductList-BfUiap9U.js} +2 -2
  111. package/dist-vue/_chunks/{PkToolShowProductList-FLLkRCnm.js.map → PkToolShowProductList-BfUiap9U.js.map} +1 -1
  112. package/dist-vue/_chunks/{PkToolShowSources-Cb7r5jrX.js → PkToolShowSources-CgEkcyRg.js} +3 -3
  113. package/dist-vue/_chunks/{PkToolShowSources-Cb7r5jrX.js.map → PkToolShowSources-CgEkcyRg.js.map} +1 -1
  114. package/dist-vue/_chunks/{PkToolShowSuggestedReply-BVLCX5Sm.js → PkToolShowSuggestedReply-DxlGhMvE.js} +2 -2
  115. package/dist-vue/_chunks/{PkToolShowSuggestedReply-BVLCX5Sm.js.map → PkToolShowSuggestedReply-DxlGhMvE.js.map} +1 -1
  116. package/dist-vue/_chunks/{PkToolShowVideo-QDLhVlau.js → PkToolShowVideo-CqSRnDNC.js} +2 -2
  117. package/dist-vue/_chunks/{PkToolShowVideo-QDLhVlau.js.map → PkToolShowVideo-CqSRnDNC.js.map} +1 -1
  118. package/dist-vue/_chunks/{PkToolShowWebPages-P6PdJTEE.js → PkToolShowWebPages-B-qIS8qY.js} +2 -2
  119. package/dist-vue/_chunks/{PkToolShowWebPages-P6PdJTEE.js.map → PkToolShowWebPages-B-qIS8qY.js.map} +1 -1
  120. package/dist-vue/_chunks/{createChatbotApiClient-CGeNprai.js → createChatbotApiClient-DmPcjwB3.js} +7 -7
  121. package/dist-vue/_chunks/{createChatbotApiClient-CGeNprai.js.map → createChatbotApiClient-DmPcjwB3.js.map} +1 -1
  122. package/dist-vue/_chunks/{useChatbotStore-KXAltGz3.js → useChatbotStore-B6ILfm5Z.js} +17 -17
  123. package/dist-vue/_chunks/{useChatbotStore-KXAltGz3.js.map → useChatbotStore-B6ILfm5Z.js.map} +1 -1
  124. package/dist-vue/_chunks/{utils-D4B1FVGF.js → utils-KBB6SDPn.js} +2 -2
  125. package/dist-vue/_chunks/{utils-D4B1FVGF.js.map → utils-KBB6SDPn.js.map} +1 -1
  126. package/dist-vue/api.js +1 -1
  127. package/dist-vue/apps/web-component/src/composables/useChatbotAgent.d.ts +6 -0
  128. package/dist-vue/composables.js +270 -6
  129. package/dist-vue/composables.js.map +1 -1
  130. package/dist-vue/index.js +5325 -5232
  131. package/dist-vue/index.js.map +1 -1
  132. package/dist-vue/locales.js +12 -0
  133. package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +6 -0
  134. package/dist-vue/packages/components/src/chat/PkFilePreview.d.ts +8 -0
  135. package/dist-vue/packages/components/src/chat/PkFilePreviewDialog.d.ts +4 -0
  136. package/dist-vue/packages/components/src/chat/PkSelectionActionIconPicker.d.ts +19 -0
  137. package/dist-vue/packages/components/src/chat/PkSelectionActions.d.ts +3 -0
  138. package/dist-vue/packages/components/src/chat/selectionActionEdits.d.ts +1 -0
  139. package/dist-vue/packages/components/src/chat/selectionActionIcons.d.ts +9 -0
  140. package/dist-vue/packages/components/src/chat/useChatFilePreview.d.ts +12 -12
  141. package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +18 -0
  142. package/dist-vue/packages/models/src/schema/Agent.d.ts +2688 -0
  143. package/dist-vue/packages/models/src/schema/Chart.d.ts +4 -4
  144. package/dist-vue/packages/models/src/schema/Lead.d.ts +6 -6
  145. package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +768 -0
  146. package/dist-vue/packages/models/src/schema/SelectionAction.d.ts +1415 -0
  147. package/dist-vue/packages/models/src/schema/SelectionActionPreview.d.ts +38 -0
  148. package/dist-vue/packages/models/src/schema/SpreadsheetPreview.d.ts +6 -6
  149. package/dist-vue/packages/models/src/schema/SubAgent.d.ts +768 -0
  150. package/dist-vue/packages/models/src/schema/WordPreview.d.ts +13 -13
  151. package/dist-vue/packages/models/src/schema/index.d.ts +1 -0
  152. package/dist-vue/style.css +1 -1
  153. package/package.json +1 -1
  154. package/dist/_chunks/Agent-CeZ3bgZ3.js.map +0 -1
  155. package/dist/_chunks/PkFilePreview-D_1ZgiiA.js.map +0 -1
  156. package/dist/_chunks/PkFilePreviewDialog-CI22huzK.js.map +0 -1
  157. package/dist/_chunks/PkSelectionActions-BriGyWCi.js.map +0 -1
  158. package/dist-vue/_chunks/Agent-ldDZiq6E.js.map +0 -1
  159. package/dist-vue/_chunks/PkChatbotViewChat-tmHyxxT3.js.map +0 -1
  160. package/dist-vue/_chunks/PkFilePreview-Bp5-Pl54.js.map +0 -1
  161. package/dist-vue/_chunks/PkFilePreviewDialog-CS885vBR.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { B as e, C as t, M as n, O as r, n as i, ot as a } from "./Agent-ldDZiq6E.js";
1
+ import { B as e, C as t, M as n, O as r, n as i, st as a } from "./Agent-B9iJ1WvR.js";
2
2
  import "./src-nb8MU1sh.js";
3
3
  import { c as o, i as s, l as c, u as l } from "./message-DuibQyHy.js";
4
4
  import "vue";
@@ -466,4 +466,4 @@ function je({ start: e, bottom: t, bar: n, bounds: r, touch: i = !1, gap: a = 8,
466
466
  }
467
467
  export { f as $, Ae as A, je as B, ue as C, O as D, N as E, m as F, Q as G, Y as H, _ as I, Ee as J, xe as K, ge as L, C as M, D as N, ke as O, _e as P, d as Q, R, ve as S, le as T, Te as U, V, Se as W, X, Z as Y, p as Z, se as _, K as a, me as b, P as c, v as d, ee as et, U as f, y as g, B as h, ae as i, j, ie as k, De as l, W as m, ne as n, Ce as o, G as p, we as q, x as r, z as s, E as t, te as u, de as v, H as w, k as x, A as y, I as z };
468
468
 
469
- //# sourceMappingURL=utils-D4B1FVGF.js.map
469
+ //# sourceMappingURL=utils-KBB6SDPn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils-D4B1FVGF.js","names":["isPresentationTool","MCP_TOOL_PREFIX","WEB_SEARCH_TOOL_KEYS","SUBAGENT_TOOL_PREFIX","API_TOOL_PREFIX","isHostToolPart","isReasoningPart","getToolPartName","isTextPart","isToolPart","removeAccents","str","fromAnyCase","toKebabCase","toSnakeCase","capitalizeFirstLetter","mergeConsecutiveTextParts","merged","part","parts","prev","isWidgetPart","dropCorrectedWidgetErrors","lastDrawn","index","isStreamingPart","FILE_OUTPUT_PARTS","moveFileOutputsLast","files","feedPartKey","toolCallId","getHostCallPart","PAGE_TOOL_STEPS","HOST_STEP_TITLES","HOST_STEP_CHANGES","FORM_TOOL_STEP","pageToolStep","host","isHostActionPart","LIVE_REASONING_TAIL_LENGTH","FENCE_LINE","getMarkdownTail","markdown","maxLength","from","limit","boundary","length","cut","openFence","match","marker","rest","TOOL_APPROVAL_STATES","isToolApprovalPart","CONFIRM_TOOL_NAME","isToolConfirmPart","isConfirmationCardPart","getToolApprovalId","getPartState","isLoadingState","state","getContrast","hex","hexcolor","char","r","g","b","linearize","c","isAchromaticColor","channels","at","channelsToHex","value","readCssColor","expression","computed","probe","srgb","rgb","resolveGlowTints","readGlowTints","source","mainColor","sourceHex","neutral","middle","color","hueShift","first","second","secondColor","tones","resolveContrastColor","textColor","agentThemeStyle","contrastColor","formatDuration","ms","$n","stringifyPayload","json","hasPayload","formAnswerAsSpoken","input","answer","question","questionById","step","said","id","formStepOptions","option","formAnswerSlots","slots","output","steps","assign","list","WEB_SEARCH_TOOL_TYPES","key","RICH_DETAIL_TOOL_TYPES","hasRichToolDetail","asRecord","pickString","keys","record","getToolPartSummary","queries","valid","query","sheet","range","getPartIcon","TOOL_KEY_PREFIXES","toolLabel","te","name","prefix","p","PART_TYPE_LABELS","t","getPartTypeLabel","translator","label","PROVIDER_NAMES","providerLabel","slug","localizeSummaryLabels","summary","labels","colon","getToolPartLabel","live","hostStepTitles","page","$t","WORD_FONT_STACKS","WORD_LINE_FACTORS","wordLineFactor","font","wordFontStack","WORD_PREVIEW_IMAGES","wordPictureSrc","src","images","ref","wordPageAnchorCss","anchor","picture","wordPicturePlacement","wordKeptRuns","runs","mode","hasWordText","wordFlowItems","out","breakPending","sectionPending","push","opens","section","row","breakBefore","keepNext","skip","blocks","block","breaks","cell","cells","wordPageAnchors","run","chatFileName","version","filename","EDITABLE_IMAGE_TYPES","isEditableImage","mediaType","isImeComposing","event","selectionBarPosition","above","start","gap","bar","placement","touch","bounds","margin","bottom"],"sources":["../../../../packages/utils/src/text.ts","../../../../packages/components/src/chat/utils.ts"],"sourcesContent":["export const removeAccents = (str: string) =>\n str.normalize('NFD').replace(/[\\u0300-\\u036f]/g, '')\n\nexport const toCamelCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/[^a-zA-Z0-9]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^(.)/, (match) => match.toLowerCase()) as unknown as T\n}\n\nexport const fromCamelCase = (str?: string): string => {\n if (!str) {\n return ''\n }\n return str.replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n}\n\nexport const fromAnyCase = (str?: string): string => {\n if (!str) {\n return ''\n }\n return str\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/[-_]+/g, ' ')\n}\n\nexport const toPascalCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/[^a-zA-Z0-9]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^(.)/, (match) => match.toUpperCase()) as unknown as T\n}\n\nexport const toKebabCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[^a-zA-Z0-9]+/g, '-')\n .toLowerCase() as unknown as T\n}\n\nexport const fromKebabCase = (str?: string): string => {\n if (!str) {\n return ''\n }\n return str.replace(/-/g, ' ')\n}\n\nexport const toSnakeCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/[^a-zA-Z0-9]+/g, '_')\n .toLowerCase() as unknown as T\n}\n\nexport const capitalizeFirstLetter = (str?: string) => {\n if (!str) {\n return ''\n }\n return str.charAt(0).toUpperCase() + str.slice(1)\n}\n\nexport const lowercaseFirstLetter = (str?: string) => {\n if (!str) {\n return ''\n }\n return str.charAt(0).toLowerCase() + str.slice(1)\n}\n","import type { UIMessage } from 'ai'\nimport type { CSSProperties, InjectionKey, Ref } from 'vue'\nimport {\n API_TOOL_PREFIX,\n MCP_TOOL_PREFIX,\n SUBAGENT_TOOL_PREFIX,\n WEB_SEARCH_TOOL_KEYS,\n isHostToolPart,\n isPresentationTool,\n type WordPreviewBlock,\n type WordPreviewPage,\n type WordPreviewPicture,\n type WordPreviewRun,\n} from 'models'\nimport {\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n hasPartText,\n hasTextPart,\n getTextPart,\n getMessageText,\n getToolPartName,\n capitalizeFirstLetter,\n fromAnyCase,\n} from 'utils'\n\nexport {\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n hasPartText,\n hasTextPart,\n getTextPart,\n getMessageText,\n}\n\n/**\n * Merges consecutive text parts into a single text part.\n * Claude (and other models) often produce multiple text parts during streaming\n * that should logically be a single block of text.\n */\nexport function mergeConsecutiveTextParts(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const merged: UIMessage['parts'] = []\n for (const part of parts) {\n if (!isTextPart(part)) {\n merged.push(part)\n continue\n }\n const prev = merged[merged.length - 1]\n if (prev && isTextPart(prev)) {\n merged[merged.length - 1] = { ...prev, text: prev.text + part.text }\n } else {\n merged.push(part)\n }\n }\n return merged\n}\n\nconst isWidgetPart = (\n part: UIMessage['parts'][number],\n): part is Extract<UIMessage['parts'][number], { type: `tool-${string}` }> =>\n isToolPart(part) && isPresentationTool(getToolPartName(part))\n\n/**\n * Drops a widget call refused for its arguments when a later call of the same\n * widget in the message was drawn: the turn corrected it (the backend's\n * `correctableInputRefusals`), and the refusal would sit next to the working\n * widget, `showForm` drawing its render error above the form. A refusal with\n * nothing drawn after it stays. Only the feed reads this: the steps timeline\n * keeps every call, the refused one included.\n */\nexport function dropCorrectedWidgetErrors(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const lastDrawn = new Map<string, number>()\n for (const [index, part] of parts.entries()) {\n if (\n isWidgetPart(part) &&\n part.state !== 'output-error' &&\n !isStreamingPart(part)\n ) {\n lastDrawn.set(part.type, index)\n }\n }\n return parts.filter(\n (part, index) =>\n !(\n isWidgetPart(part) &&\n part.state === 'output-error' &&\n (lastDrawn.get(part.type) ?? -1) > index\n ),\n )\n}\n\n/**\n * Tool calls whose output is a file for the user to download. The feed draws\n * them after the answer, where the reader arrives, wherever in the message the\n * model made the call: a version written before a long answer sat above it,\n * out of sight.\n */\nconst FILE_OUTPUT_PARTS: ReadonlySet<string> = new Set([\n 'tool-editSpreadsheet',\n 'tool-shareDocument',\n 'tool-editWordDocument',\n 'tool-createSpreadsheet',\n 'tool-createWordDocument',\n])\n\n/** The parts with the file outputs moved last, in their own order. */\nexport function moveFileOutputsLast(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const files = parts.filter((part) => FILE_OUTPUT_PARTS.has(part.type))\n return files.length > 0\n ? [\n ...parts.filter((part) => !FILE_OUTPUT_PARTS.has(part.type)),\n ...files,\n ]\n : parts\n}\n\n/**\n * The key of a part in the feed. Its position, except for a file output: that\n * one is always last, so its position moves as the answer grows, and keyed by\n * it the card would be redrawn at every new part.\n */\nexport function feedPartKey(\n part: UIMessage['parts'][number],\n index: number,\n): string | number {\n const toolCallId = (part as { toolCallId?: string }).toolCallId\n return FILE_OUTPUT_PARTS.has(part.type) && toolCallId\n ? `file-${toolCallId}`\n : index\n}\n\n/** A call the embedding page runs, as the backend stamped it (spec `host-tools.md`). */\ninterface HostCallPart {\n toolCallId?: string\n toolName: string\n title?: string\n state?: string\n errorText?: string\n toolMetadata?: { readOnly?: boolean; provider?: 'app' | 'page' }\n}\n\nexport function getHostCallPart(\n part: UIMessage['parts'][number] | null | undefined,\n): HostCallPart | undefined {\n return isHostToolPart(part) ? (part as unknown as HostCallPart) : undefined\n}\n\n/**\n * The page tools of the widget (spec `page-tools.md`): defined by the backend,\n * so their step is ours to name, in the user's language. A tool the app\n * registered is named by its own `title`.\n */\nconst PAGE_TOOL_STEPS: Record<string, { icon: string; label: string }> = {\n page_snapshot: {\n icon: 'ri:pages-line',\n label: 'messagePart.pageTool.snapshot',\n },\n page_read: {\n icon: 'ri:file-text-line',\n label: 'messagePart.pageTool.read',\n },\n page_click: { icon: 'ri:cursor-line', label: 'messagePart.pageTool.click' },\n page_fill: { icon: 'ri:edit-line', label: 'messagePart.pageTool.fill' },\n page_scroll: {\n icon: 'ri:arrow-up-down-line',\n label: 'messagePart.pageTool.scroll',\n },\n page_find: { icon: 'ri:search-line', label: 'messagePart.pageTool.find' },\n page_wait: { icon: 'ri:time-line', label: 'messagePart.pageTool.wait' },\n page_hover: {\n icon: 'ri:cursor-line',\n label: 'messagePart.pageTool.hover',\n },\n page_press: {\n icon: 'ri:keyboard-line',\n label: 'messagePart.pageTool.press',\n },\n page_back: {\n icon: 'ri:arrow-go-back-line',\n label: 'messagePart.pageTool.back',\n },\n page_navigate: {\n icon: 'ri:links-line',\n label: 'messagePart.pageTool.navigate',\n },\n}\n\n/**\n * The titles the widget gave this page's steps, by call, naming what each\n * acts on (spec `page-tools-improvements.md`, M8): provided by the chat view\n * from its store, read by the views that list the steps.\n */\nexport const HOST_STEP_TITLES: InjectionKey<Ref<Record<string, string>>> =\n Symbol('hostStepTitles')\n\n/** A setting a step changes: what it was, what it becomes. */\nexport type StepFieldChange = { label: string; value: string; before?: string }\n\n/**\n * What the steps the automatic confirmations ran without a card changed, by\n * call (spec `auto-confirmations.md`): provided by the chat view from its\n * store, shown under each step's line.\n */\nexport const HOST_STEP_CHANGES: InjectionKey<\n Ref<\n Record<\n string,\n {\n details?: StepFieldChange[]\n unchanged?: { label: string; value: string }[]\n }\n >\n >\n> = Symbol('hostStepChanges')\n\n/** A form the site annotated for agents: its tool is named `form_<toolname>`. */\nconst FORM_TOOL_STEP = {\n icon: 'ri:survey-line',\n label: 'messagePart.pageTool.form',\n}\n\nconst pageToolStep = (host: HostCallPart) =>\n host.toolMetadata?.provider === 'page'\n ? (PAGE_TOOL_STEPS[host.toolName] ??\n (host.toolName.startsWith('form_') ? FORM_TOOL_STEP : undefined))\n : undefined\n\n/**\n * A host call that changes something in the app or on the page: the feed\n * shows it even without the steps timeline, because what it did stays done.\n */\nexport function isHostActionPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return getHostCallPart(part)?.toolMetadata?.readOnly === false\n}\n\nexport function isStreamingPart(\n part: UIMessage['parts'][number] | null | undefined,\n): part is Extract<UIMessage['parts'][number], { streaming?: boolean }> {\n if (!part) {\n return false\n }\n if ('state' in part) {\n return part.state === 'streaming' || part.state === 'input-streaming'\n }\n return false\n}\n\n/**\n * How much of a reasoning still being written its live box renders. The box is\n * a few lines tall and follows the bottom, while the reasoning of one turn runs\n * to tens of kilobytes: chat `st0Eg8iG0zUX0HQN` wrote 92KB, and parsing all of\n * it at every delta froze the tab. Four thousand characters leave a few screens\n * to scroll back through, and a finished step renders all of it.\n */\nexport const LIVE_REASONING_TAIL_LENGTH = 4000\n\n// A fence opener or closer, also inside a list item or a quote, whose markers\n// and indentation are skipped. The rest of the line tells them apart: a\n// closing fence carries no info string.\nconst FENCE_LINE =\n /^[ \\t]*(?:(?:[-*+]|\\d{1,9}[.)])[ \\t]+|>[ \\t]?)*(`{3,}|~{3,})(.*)$/gm\n\n/**\n * The end of a markdown text, at most `maxLength` characters long, cut on a\n * blank line (a line break when there is none) so it does not open on half a\n * paragraph. A table or a formula can still be cut in two. An ellipsis marks\n * the cut. A cut inside a fenced code block reopens the fence, or the rest of\n * the text would render as code and the code as prose.\n */\nexport function getMarkdownTail(markdown: string, maxLength: number): string {\n if (markdown.length <= maxLength) {\n return markdown\n }\n const from = markdown.length - maxLength\n // The boundary is looked for in the first half of the window only: the one\n // blank line of the window can be the last thing written, and cutting there\n // would leave nothing to render.\n const limit = from + maxLength / 2\n const boundary = (index: number, length: number) =>\n index !== -1 && index < limit ? index + length : undefined\n const cut =\n boundary(markdown.indexOf('\\n\\n', from), 2) ??\n boundary(markdown.indexOf('\\n', from), 1) ??\n from\n let openFence: string | undefined\n for (const match of markdown.matchAll(FENCE_LINE)) {\n if (match.index >= cut) {\n break\n }\n const [, marker, rest] = match\n if (!openFence) {\n // A backtick in a backtick fence's info string makes it inline\n // code, not a fence.\n if (marker[0] === '`' && rest.includes('`')) {\n continue\n }\n openFence = marker\n } else if (\n marker[0] === openFence[0] &&\n marker.length >= openFence.length &&\n !rest.trim()\n ) {\n openFence = undefined\n }\n }\n const reopen = openFence ? `${openFence}\\n` : ''\n return `…\\n\\n${reopen}${markdown.slice(cut)}`\n}\n\n/**\n * States a tool part goes through when it needs the user's approval. They are\n * rendered by `PkToolApprovalCard` whatever the tool is, so the decision (and\n * its outcome) stays visible in the transcript.\n */\nconst TOOL_APPROVAL_STATES = new Set([\n 'approval-requested',\n 'approval-responded',\n 'output-denied',\n])\n\nexport function isToolApprovalPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n if (!isToolPart(part)) {\n return false\n }\n if (TOOL_APPROVAL_STATES.has(part.state)) {\n return true\n }\n // An executed (or errored) call that went through the gate keeps its\n // verdict in `approval`: the card stays in the transcript, so the user's\n // decision remains visible in the chat and in the log viewers (parity\n // with requestConfirm, whose 'confirmed' output is persisted).\n return (part as { approval?: unknown }).approval != null\n}\n\n/**\n * The client-side tool the model uses to have an action it described approved.\n * It predates the SDK's approval gate and keeps its own round-trip (it resolves\n * through `addToolOutput`), but it asks the user the very same question, so it\n * shares `PkToolApprovalCard` instead of having a card of its own.\n */\nexport const CONFIRM_TOOL_NAME = 'requestConfirm'\n\nexport function isToolConfirmPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return isToolPart(part) && part.type === `tool-${CONFIRM_TOOL_NAME}`\n}\n\n/** True for any part the confirmation card is responsible for. */\nexport function isConfirmationCardPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return isToolApprovalPart(part) || isToolConfirmPart(part)\n}\n\n/** The id of the pending approval request on a tool part, if any. */\nexport function getToolApprovalId(\n part: UIMessage['parts'][number] | null | undefined,\n): string | undefined {\n if (!isToolPart(part)) {\n return undefined\n }\n return (part as { approval?: { id?: string } }).approval?.id\n}\n\nexport function getPartState(\n part: UIMessage['parts'][number] | null | undefined,\n): string | undefined {\n if (!part) {\n return undefined\n }\n if ('state' in part) {\n return part.state\n }\n return undefined\n}\n\nexport function isLoadingState(state?: string): boolean {\n if (!state) {\n return false\n }\n return ['streaming'].includes(state)\n}\n\nexport function getContrast(hexcolor: string = '000000'): 'black' | 'white' {\n let hex = hexcolor.replace('#', '')\n\n // Expand 3-character hex to 6-character (e.g., #ccc -> #cccccc)\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map((char) => char + char)\n .join('')\n }\n\n // WCAG relative luminance\n const r = parseInt(hex.substring(0, 2), 16) / 255\n const g = parseInt(hex.substring(2, 4), 16) / 255\n const b = parseInt(hex.substring(4, 6), 16) / 255\n\n const linearize = (c: number) =>\n c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n\n const luminance =\n 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b)\n\n return luminance > 0.179 ? 'black' : 'white'\n}\n\n/**\n * True for a hex color with almost no hue: black, white and the grays between.\n * Anything else, a color the function cannot read included, counts as colored.\n */\nexport function isAchromaticColor(hexcolor: string | undefined): boolean {\n let hex = hexcolor?.trim().replace('#', '') ?? ''\n if (/^[0-9a-f]{3}$/i.test(hex)) {\n hex = hex\n .split('')\n .map((char) => char + char)\n .join('')\n }\n if (!/^[0-9a-f]{6}$/i.test(hex)) {\n return false\n }\n const channels = [0, 2, 4].map((at) =>\n parseInt(hex.substring(at, at + 2), 16),\n )\n return Math.max(...channels) - Math.min(...channels) < 32\n}\n\n/** A color as the glow's shader takes it: three channels, 0-255. */\nexport type RgbChannels = [number, number, number]\n\n/** The two tints of the empty chat's glow, and whether the second shows. */\nexport type GlowTints = {\n first: RgbChannels\n second: RgbChannels\n duo: boolean\n}\n\n/** `#rrggbb` from three 0-255 channels. */\nexport const channelsToHex = (channels: RgbChannels) =>\n `#${channels.map((value) => value.toString(16).padStart(2, '0')).join('')}`\n\n/**\n * The color a CSS expression resolves to where `probe` sits. Mixed into sRGB\n * first, it computes to `color(srgb r g b)` whatever syntax it was written in\n * (the design system's tokens derive with the relative color syntax). A\n * browser without `color-mix()` would drop the mix and leave the inherited\n * color for every expression: it reads the bare one, which computes to `rgb()`.\n */\nfunction readCssColor(\n probe: HTMLElement,\n expression: string,\n): RgbChannels | null {\n probe.style.color = CSS.supports(\n 'color',\n 'color-mix(in srgb, red 100%, transparent)',\n )\n ? `color-mix(in srgb, ${expression} 100%, transparent)`\n : expression\n const computed = getComputedStyle(probe).color\n probe.style.color = ''\n const srgb = computed.match(/^color\\(srgb ([^\\s)]+) ([^\\s)]+) ([^\\s)]+)/)\n const rgb = computed.match(/rgba?\\(([\\d.]+)[,\\s]+([\\d.]+)[,\\s]+([\\d.]+)/)\n if (srgb) {\n return [srgb[1], srgb[2], srgb[3]].map((value) =>\n Math.round(Math.min(1, Math.max(0, Number(value))) * 255),\n ) as RgbChannels\n }\n if (rgb) {\n return [rgb[1], rgb[2], rgb[3]].map((value) =>\n Math.round(Number(value)),\n ) as RgbChannels\n }\n return null\n}\n\n/**\n * The two tints of the glow behind the empty chat's input. A color without a\n * hue (black, the default, white, a gray) drew a grey smudge on the light\n * theme and nothing on the dark one: the platform's accent lights it instead,\n * with its info color as the second tone, as the working beam does. Any other\n * color gives its neighbour 40° along the hue wheel as the second tone,\n * unless the agent chose one. Every tone is held to a middle lightness, like\n * the beam's, so a chosen second color that matches the one shown keeps the\n * glow as it was. `auto` shows the second tone only for a color without a hue.\n *\n * The colors resolve where `host` sits (its tokens, its theme); without\n * `mainColor` the glow starts from the host's own color. Null when the\n * browser cannot read them.\n */\nexport function resolveGlowTints(\n host: HTMLElement,\n {\n mainColor,\n tones = 'auto',\n secondColor,\n }: {\n mainColor?: string\n tones?: 'auto' | 'one' | 'two'\n secondColor?: string\n },\n): GlowTints | null {\n // A throwaway child inherits the host's color and custom properties, and\n // reading through it leaves the host's own style alone\n const probe = document.createElement('span')\n probe.hidden = true\n host.append(probe)\n try {\n return readGlowTints(probe, { mainColor, tones, secondColor })\n } finally {\n probe.remove()\n }\n}\n\nfunction readGlowTints(\n probe: HTMLElement,\n {\n mainColor,\n tones,\n secondColor,\n }: {\n mainColor?: string\n tones: 'auto' | 'one' | 'two'\n secondColor?: string\n },\n): GlowTints | null {\n const source = readCssColor(probe, mainColor ?? 'currentcolor')\n if (!source) {\n return null\n }\n const sourceHex = channelsToHex(source)\n const neutral = isAchromaticColor(sourceHex)\n // Where the browser can derive it; the color as it is otherwise\n const middle = (color: string, hueShift = 0) =>\n CSS.supports('color', 'oklch(from red l c h)')\n ? `oklch(from ${color} clamp(0.55, l, 0.75) c calc(h + ${hueShift}))`\n : color\n const first = readCssColor(\n probe,\n middle(neutral ? 'var(--color-accent)' : sourceHex),\n )\n const second = readCssColor(\n probe,\n secondColor\n ? middle(secondColor)\n : neutral\n ? middle('var(--color-info)')\n : middle(sourceHex, 40),\n )\n if (!first || !second) {\n return null\n }\n return {\n first,\n second,\n duo: tones === 'two' || (tones === 'auto' && neutral),\n }\n}\n\n/**\n * Resolves the contrast color based on the user's `textColor` preference.\n * Falls back to WCAG auto-detection via `getContrast` when set to `'auto'` or `undefined`.\n */\nexport function resolveContrastColor(\n textColor: 'auto' | 'white' | 'black' | undefined,\n mainColor: string | undefined,\n): 'black' | 'white' {\n if (textColor === 'white' || textColor === 'black') {\n return textColor\n }\n return getContrast(mainColor)\n}\n\n/**\n * The style of a chat root (PkChatbot, the widget's shell): the agent's color\n * as the brand. Volver derives every role of the brand (graphic, readable,\n * contrast, tinted surface) on any element with `.theme`, which both roots\n * carry, so the focus ring, the primary buttons, the links and the checkboxes\n * take the agent's color with the contrast each theme needs, instead of the\n * platform's purple. The fields' focus takes the brand's graphic role in both\n * themes, since the dark theme's accent is the platform's too.\n */\nexport function agentThemeStyle(\n mainColor: string | undefined,\n contrastColor: 'black' | 'white',\n): Record<string, string> | undefined {\n if (!mainColor) {\n return undefined\n }\n return {\n '--chatbot-main-color': mainColor,\n '--chatbot-contrast-color': contrastColor,\n '--color-brand': mainColor,\n '--color-brand-contrast': contrastColor,\n '--input-focus-color': 'var(--color-brand-graphic)',\n }\n}\n\n/**\n * Formats a duration in milliseconds using the i18n `seconds` number format\n * (e.g. \"12,4 secondi\" / \"12.4 seconds\"). Returns undefined for durations\n * that would render as \"0 seconds\" (less than 0.05s).\n */\nexport function formatDuration(\n $n: (value: number, format: string) => string,\n ms?: number,\n): string | undefined {\n if (ms === undefined || ms < 50) {\n return undefined\n }\n return $n(ms / 1000, 'seconds')\n}\n\n/**\n * Stringifies a tool payload for the raw fallback view. Returns undefined for\n * empty values so the caller can skip rendering the block entirely.\n */\nexport function stringifyPayload(value: unknown): string | undefined {\n if (value === undefined) {\n return undefined\n }\n if (typeof value === 'string') {\n return value.trim() || undefined\n }\n try {\n const json = JSON.stringify(value, null, 2)\n return json === '{}' || json === '[]' ? undefined : json\n } catch {\n return undefined\n }\n}\n\n/**\n * True when a tool payload carries something worth rendering, so a caller can\n * skip the block without stringifying the value twice.\n */\nexport function hasPayload(value: unknown): boolean {\n return stringifyPayload(value) !== undefined\n}\n\n/**\n * Turns the answers of a form into the sentence the caller would have said.\n *\n * On a call the tool loop is over by the time the form is on screen, so the\n * answers go back to the agent as a user message (see `sendUserMessage` in\n * `useVoiceSession`). Each answer is paired with its question, because that is\n * how a person would say it and because the agent hears it with no widget\n * attached.\n */\nexport function formAnswerAsSpoken(\n part: unknown,\n answer: string | { answers: { id: string; value: unknown }[] },\n): string {\n const input = (\n part as {\n input?: {\n steps?: { id: string; question?: string }[]\n question?: string\n }\n }\n )?.input\n\n if (typeof answer === 'string') {\n const question = input?.question ?? input?.steps?.[0]?.question\n return question ? `${question} ${answer}` : answer\n }\n\n const questionById = new Map(\n (input?.steps ?? []).map((step) => [step.id, step.question]),\n )\n const lines = answer.answers\n .filter(\n ({ value }) =>\n value !== null &&\n value !== '' &&\n !(Array.isArray(value) && !value.length),\n )\n .map(({ id, value }) => {\n const said = Array.isArray(value) ? value.join(', ') : String(value)\n const question = questionById.get(id)\n return question ? `${question} ${said}` : said\n })\n\n return lines.join('. ')\n}\n\n/**\n * The choices of a form step, as the radio and checkbox editors take them.\n *\n * The `value` is the LABEL and not the position, because it is what travels\n * back to the model as the answer: it reads the words it wrote, not an index.\n * Nothing here caps the list, and nothing should: the number of options an\n * agent configures is advice to the model, so a step can legitimately carry\n * more (see `showForm.tool.ts`).\n */\nexport function formStepOptions(\n step: { options?: { label: string; description?: string }[] } | undefined,\n): { label: string; value: string; description?: string }[] {\n if (!step?.options) {\n return []\n }\n return step.options.map((option) => ({\n label: option.label,\n value: option.label,\n description: option.description,\n }))\n}\n\n/**\n * Spreads the answers a form comes back with onto one slot PER STEP.\n *\n * A form's answers travel paired with step ids, and the tool schema does not\n * enforce that those ids are unique: a `.refine()` there would refuse the whole\n * form over a duplicate, which is the failure the schema was just cured of (see\n * the gotchas entry \"A configurable cap does not belong in an inputSchema\").\n * So the duplicate has to be survivable here. Keyed by id, two steps sharing\n * one collapsed onto a single answer: the second question showed the first\n * one's reply, and submitting sent that reply twice. Keyed by position, each\n * step keeps its own.\n *\n * A duplicated id restores the same incoming value to every step claiming it,\n * which is as much as the payload allows: the ids are all it says.\n */\nexport function formAnswerSlots(\n steps: { id: string }[],\n output: unknown,\n): Record<number, unknown> {\n const slots: Record<number, unknown> = {}\n if (output === undefined || output === null) {\n return slots\n }\n // A legacy single-choice answer is the plain string, and it can only\n // belong to a single-step form.\n if (typeof output === 'string') {\n if (steps.length === 1) {\n slots[0] = output\n }\n return slots\n }\n const assign = (id: string, value: unknown) => {\n steps.forEach((step, index) => {\n if (step.id === id) {\n slots[index] = value\n }\n })\n }\n const list = (output as { answers?: unknown }).answers\n if (Array.isArray(list)) {\n for (const answer of list as { id?: unknown; value?: unknown }[]) {\n if (typeof answer?.id === 'string') {\n assign(answer.id, answer.value)\n }\n }\n return slots\n }\n // Forms answered on a platform channel (the Teams modal) come back as a\n // flat record keyed by step id.\n for (const [id, value] of Object.entries(\n output as Record<string, unknown>,\n )) {\n if (value !== undefined) {\n assign(id, value)\n }\n }\n return slots\n}\n\n// Web search tool part types, gateway and provider-native\nexport const WEB_SEARCH_TOOL_TYPES: string[] = WEB_SEARCH_TOOL_KEYS.map(\n (key) => `tool-${key}`,\n)\n\n// Tool part types with a dedicated rich rendering in PkChatbotStepToolDetail\nconst RICH_DETAIL_TOOL_TYPES = new Set([\n 'tool-searchInKnowledgeBase',\n 'tool-retrieveRevisedAnswers',\n 'tool-expandChunkContext',\n 'tool-readDocumentFile',\n 'tool-getWeather',\n 'tool-geocode',\n 'tool-recallUserMemory',\n 'tool-saveUserMemory',\n ...WEB_SEARCH_TOOL_TYPES,\n])\n\nexport function hasRichToolDetail(\n part?: UIMessage['parts'][number] | null,\n): boolean {\n return isToolPart(part) && RICH_DETAIL_TOOL_TYPES.has(part.type)\n}\n\nconst asRecord = (value: unknown): Record<string, unknown> | undefined =>\n value && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined\n\nconst pickString = (\n record: Record<string, unknown> | undefined,\n ...keys: string[]\n): string | undefined => {\n for (const key of keys) {\n const value = record?.[key]\n if (typeof value === 'string' && value.trim()) {\n return value\n }\n }\n return undefined\n}\n\n/**\n * Returns a short inline summary for a tool part (search queries, location,\n * document name, ...) to be shown next to the step label without expanding\n * the step body.\n */\nexport function getToolPartSummary(\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n if (!isToolPart(part)) {\n return undefined\n }\n const input = asRecord('input' in part ? part.input : undefined)\n const output = asRecord('output' in part ? part.output : undefined)\n if (\n part.type === 'tool-searchInKnowledgeBase' ||\n WEB_SEARCH_TOOL_TYPES.includes(part.type)\n ) {\n const queries = input?.queries\n if (Array.isArray(queries)) {\n const valid = queries.filter(\n (query): query is string =>\n typeof query === 'string' && Boolean(query.trim()),\n )\n return valid.length ? valid.join(' · ') : undefined\n }\n return pickString(input, 'query', 'objective')\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return pickString(input, 'query')\n }\n if (part.type === 'tool-getWeather') {\n return (\n pickString(output, 'location') ?? pickString(input, 'locationName')\n )\n }\n if (part.type === 'tool-geocode') {\n return pickString(input, 'locationName')\n }\n if (part.type === 'tool-expandChunkContext') {\n return pickString(output, 'documentName')\n }\n if (\n part.type === 'tool-readDocumentFile' ||\n part.type === 'tool-readChatAttachment' ||\n part.type === 'tool-sendChatFile' ||\n part.type === 'tool-shareDocument'\n ) {\n return pickString(output, 'name')\n }\n if (part.type === 'tool-readSpreadsheet') {\n const sheet = pickString(input, 'sheet')\n const range = pickString(input, 'range')\n return sheet && range ? `${sheet}!${range}` : sheet\n }\n if (part.type === 'tool-editSpreadsheet') {\n return pickString(output, 'filename')\n }\n if (part.type === 'tool-readWordDocument') {\n return pickString(input, 'search') ?? pickString(input, 'from')\n }\n if (part.type === 'tool-editWordDocument') {\n return pickString(output, 'filename')\n }\n if (\n part.type === 'tool-createSpreadsheet' ||\n part.type === 'tool-createWordDocument'\n ) {\n // The name the file got, or while the call runs the one asked for.\n return pickString(output, 'filename') ?? pickString(input, 'filename')\n }\n if (part.type === 'tool-querySpreadsheet') {\n // The file when the step asked for the schema; a query has no name.\n return pickString(output, 'file')\n }\n if (part.type === 'tool-recallUserMemory') {\n return pickString(input, 'query')\n }\n if (part.type === 'tool-saveUserMemory') {\n return pickString(input, 'content', 'query')\n }\n return undefined\n}\n\n// Get part icon\nexport function getPartIcon(\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n const host = getHostCallPart(part)\n if (host) {\n return pageToolStep(host)?.icon ?? 'ri:apps-line'\n }\n if (isToolPart(part)) {\n if (part.type.includes('tool-subagent')) {\n return 'ri:robot-2-line'\n }\n if (part.type === 'tool-runWorker') {\n return 'ri:flow-chart'\n }\n if (part.type === 'tool-scheduleWakeup') {\n return 'ri:alarm-line'\n }\n if (part.type === 'tool-fetchTeamsChannelHistory') {\n return 'ri:chat-history-line'\n }\n if (part.type === 'tool-readEarlierMessages') {\n return 'ri:history-line'\n }\n if (part.type === 'tool-readChatAttachment') {\n return 'ri:attachment-line'\n }\n if (part.type === 'tool-sendChatFile') {\n return 'ri:send-plane-line'\n }\n if (part.type === 'tool-enableTools') {\n return 'ri:toggle-line'\n }\n if (part.type.includes('tool-mcp')) {\n return 'mcp'\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return 'ri:file-edit-line'\n }\n if (part.type === 'tool-searchInKnowledgeBase') {\n return 'ri:search-line'\n }\n if (part.type === 'tool-expandChunkContext') {\n return 'ri:file-search-line'\n }\n if (part.type === 'tool-readDocumentFile') {\n return 'ri:file-text-line'\n }\n if (part.type === 'tool-readSpreadsheet') {\n return 'ri:table-line'\n }\n if (\n part.type === 'tool-editSpreadsheet' ||\n part.type === 'tool-createSpreadsheet'\n ) {\n return 'ri:file-excel-2-line'\n }\n if (part.type === 'tool-shareDocument') {\n return 'ri:file-download-line'\n }\n if (part.type === 'tool-readWordDocument') {\n return 'ri:file-text-line'\n }\n if (\n part.type === 'tool-editWordDocument' ||\n part.type === 'tool-createWordDocument'\n ) {\n return 'ri:file-word-2-line'\n }\n if (part.type === 'tool-querySpreadsheet') {\n return 'ri:database-2-line'\n }\n if (part.type === 'tool-geocode') {\n return 'ri:map-2-line'\n }\n if (part.type === 'tool-getWeather') {\n return 'ri:sun-cloudy-line'\n }\n if (part.type === 'tool-recallUserMemory') {\n return 'ri:brain-line'\n }\n if (part.type === 'tool-saveUserMemory') {\n return 'ri:save-3-line'\n }\n if (part.type === 'tool-showWeather') {\n return 'ri:sun-line'\n }\n if (part.type === 'tool-showChart') {\n return 'ri:bar-chart-2-line'\n }\n if (part.type === 'tool-showDiagram') {\n return 'ri:flow-chart'\n }\n if (part.type === 'tool-showSources') {\n return 'ri:book-2-line'\n }\n if (part.type === 'tool-showForm') {\n return 'ri:survey-line'\n }\n if (part.type === 'tool-showMultipleChoice') {\n return 'ri:checkbox-multiple-line'\n }\n if (part.type === 'tool-showArtifact') {\n return 'ri:file-code-line'\n }\n if (part.type === 'tool-showEmail') {\n return 'ri:mail-line'\n }\n if (part.type === 'tool-showMessage') {\n return 'ri:chat-1-line'\n }\n if (part.type === 'tool-showWebPages') {\n return 'ri:pages-line'\n }\n if (part.type === 'tool-showProductList') {\n return 'ri:shopping-bag-line'\n }\n if (part.type === 'tool-showContactForm') {\n return 'ri:send-plane-2-line'\n }\n if (part.type === 'tool-showCalendarEvent') {\n return 'ri:calendar-event-line'\n }\n if (part.type === 'tool-showComparison') {\n return 'ri:scales-line'\n }\n if (part.type === 'tool-showLocation') {\n return 'ri:map-pin-line'\n }\n if (part.type === 'tool-showQrCode') {\n return 'ri:qr-code-line'\n }\n if (part.type === 'tool-showImageGallery') {\n return 'ri:image-line'\n }\n if (part.type === 'tool-showVideo') {\n return 'ri:film-line'\n }\n if (part.type === 'tool-showSuggestedReply') {\n return 'ri:corner-down-right-line'\n }\n if (part.type === 'tool-requestGeolocation') {\n return 'ri:map-pin-user-line'\n }\n if (part.type === 'tool-disconnectOAuthConnection') {\n return 'ri:link-unlink'\n }\n if (part.type === 'tool-requestAccountLink') {\n return 'ri:link'\n }\n if (part.type === 'tool-unlinkAccount') {\n return 'ri:link-unlink'\n }\n if (WEB_SEARCH_TOOL_TYPES.includes(part.type)) {\n return 'ri:global-line'\n }\n return 'ri:tools-line'\n }\n if (isReasoningPart(part)) {\n return 'ri:lightbulb-line'\n }\n if (isTextPart(part)) {\n return 'ri:double-quotes-r'\n }\n return undefined\n}\n\n/** What `toolLabel` and `getPartTypeLabel` need from vue-i18n. */\nexport interface LabelTranslator {\n t: (key: string) => string\n te: (key: string) => boolean\n}\n\nconst TOOL_KEY_PREFIXES = [\n API_TOOL_PREFIX,\n MCP_TOOL_PREFIX,\n SUBAGENT_TOOL_PREFIX,\n] as const\n\n/**\n * The name a person reads for a tool of the turn: the translated label of a\n * built-in tool, otherwise the name the agent configured, without its\n * tool-set prefix and in words (`api-festivita_nazionali` reads \"Festivita\n * nazionali\"). Never the raw key, and never an i18n key with no translation,\n * which vue-i18n would print as the key itself.\n */\nexport function toolLabel(name: string, { t, te }: LabelTranslator): string {\n if (te(`agent.tool.${name}`)) {\n return t(`agent.tool.${name}`)\n }\n const prefix = TOOL_KEY_PREFIXES.find((p) => name.startsWith(p))\n const bare = prefix ? name.slice(prefix.length) : name\n return capitalizeFirstLetter(fromAnyCase(bare).trim().toLowerCase())\n}\n\n/**\n * The kinds of message part a person can meet, each with its label. Written\n * as literal keys so the widget's library build, which keeps only the keys it\n * finds written out (apps/web-component/vite-plugins/chatLocales.ts), ships\n * them too.\n */\nconst PART_TYPE_LABELS: Record<string, (t: LabelTranslator['t']) => string> = {\n custom: (t) => t('messagePart.type.custom'),\n data: (t) => t('messagePart.type.data'),\n file: (t) => t('messagePart.type.file'),\n reasoning: (t) => t('messagePart.type.reasoning'),\n 'source-document': (t) => t('messagePart.type.sourceDocument'),\n 'source-url': (t) => t('messagePart.type.sourceUrl'),\n 'step-start': (t) => t('messagePart.type.stepStart'),\n text: (t) => t('messagePart.type.text'),\n}\n\n/**\n * The label of a message part in the message details: the tool for a tool\n * call, the translated kind otherwise (text, reasoning, provider data...),\n * and the kind in words for one the catalog does not know yet.\n */\nexport function getPartTypeLabel(\n part: UIMessage['parts'][number],\n translator: LabelTranslator,\n): string {\n if (isToolPart(part)) {\n return toolLabel(getToolPartName(part), translator)\n }\n if (part.type === 'dynamic-tool') {\n return toolLabel(part.toolName, translator)\n }\n const kind = part.type.startsWith('data-') ? 'data' : part.type\n const label = PART_TYPE_LABELS[kind]\n return label\n ? label(translator.t)\n : capitalizeFirstLetter(fromAnyCase(part.type))\n}\n\n/**\n * The commercial name of a provider the gateway routed a turn through, from\n * its slug (`anthropic`, `bedrock`): proper nouns, so no translation. A slug\n * not listed here shows with a capital, never as the bare id.\n */\nconst PROVIDER_NAMES: Record<string, string> = {\n alibaba: 'Alibaba Cloud',\n anthropic: 'Anthropic',\n azure: 'Microsoft Azure',\n baseten: 'Baseten',\n bedrock: 'Amazon Bedrock',\n cerebras: 'Cerebras',\n cohere: 'Cohere',\n deepinfra: 'DeepInfra',\n deepseek: 'DeepSeek',\n fireworks: 'Fireworks AI',\n google: 'Google',\n groq: 'Groq',\n mistral: 'Mistral AI',\n moonshotai: 'Moonshot AI',\n openai: 'OpenAI',\n perplexity: 'Perplexity',\n togetherai: 'Together AI',\n vertex: 'Google Vertex AI',\n xai: 'xAI',\n zai: 'Z.ai',\n}\n\n/** The name of a provider slug, see `PROVIDER_NAMES`. */\nexport function providerLabel(slug: string): string {\n return (\n PROVIDER_NAMES[slug.toLowerCase()] ??\n capitalizeFirstLetter(fromAnyCase(slug))\n )\n}\n\n/**\n * The conversation summary in the reader's language. The analysis asks the\n * model for four bold labels (`SUMMARY_FORMAT` in\n * apps/backend/src/prompts/analysis.prompt.ts) and the model copies them in\n * English whatever the conversation's language, so every stored summary\n * holds them: they are translated where a summary is read. An empty summary\n * comes back as it is, so a `??` fallback after it still works.\n */\nexport function localizeSummaryLabels<T extends string | null | undefined>(\n summary: T,\n t: (key: string) => string,\n): T {\n if (!summary) {\n return summary\n }\n const labels: Record<string, string> = {\n Intent: t('conversationSummary.intent'),\n 'Topics covered': t('conversationSummary.topicsCovered'),\n 'Key facts': t('conversationSummary.keyFacts'),\n 'Open questions': t('conversationSummary.openQuestions'),\n }\n return summary.replace(\n /\\*\\*(Intent|Topics covered|Key facts|Open questions)(:?)\\*\\*/g,\n (_, label: string, colon: string) => `**${labels[label]}${colon}**`,\n ) as T\n}\n\n// Get part label\nexport function getToolPartLabel(\n $t: (key: string) => string,\n part?: UIMessage['parts'][number] | null,\n /** The live titles of the page's steps, by call: they win when present. */\n hostStepTitles?: Record<string, string>,\n): string | undefined {\n const host = getHostCallPart(part)\n if (host) {\n const live = host.toolCallId\n ? hostStepTitles?.[host.toolCallId]\n : undefined\n if (live) {\n return live\n }\n const page = pageToolStep(host)\n return page ? $t(page.label) : host.title || host.toolName\n }\n if (isToolPart(part)) {\n if (part.type.includes('tool-subagent')) {\n return $t(`messagePart.runSubagent`)\n }\n if (part.type === 'tool-runWorker') {\n return $t(`messagePart.runWorker`)\n }\n if (part.type === 'tool-scheduleWakeup') {\n return $t(`messagePart.scheduleWakeup`)\n }\n if (part.type === 'tool-fetchTeamsChannelHistory') {\n return $t(`messagePart.fetchTeamsChannelHistory`)\n }\n if (part.type === 'tool-readEarlierMessages') {\n return $t(`messagePart.readEarlierMessages`)\n }\n if (part.type === 'tool-readChatAttachment') {\n return $t(`messagePart.readChatAttachment`)\n }\n if (part.type === 'tool-sendChatFile') {\n return $t(`messagePart.sendChatFile`)\n }\n if (part.type === 'tool-enableTools') {\n return $t(`messagePart.enableTools`)\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return $t(`messagePart.revisedAnswers`)\n }\n if (part.type === 'tool-searchInKnowledgeBase') {\n return $t(`messagePart.searchingDocuments`)\n }\n if (part.type === 'tool-expandChunkContext') {\n return $t(`messagePart.expandChunkContext`)\n }\n if (part.type === 'tool-readDocumentFile') {\n return $t(`messagePart.readDocumentFile`)\n }\n if (part.type === 'tool-readSpreadsheet') {\n return $t(`messagePart.readSpreadsheet`)\n }\n if (part.type === 'tool-editSpreadsheet') {\n return $t(`messagePart.editSpreadsheet`)\n }\n if (part.type === 'tool-shareDocument') {\n return $t(`messagePart.shareDocument`)\n }\n if (part.type === 'tool-readWordDocument') {\n return $t(`messagePart.readWordDocument`)\n }\n if (part.type === 'tool-editWordDocument') {\n return $t(`messagePart.editWordDocument`)\n }\n if (part.type === 'tool-createSpreadsheet') {\n return $t(`messagePart.createSpreadsheet`)\n }\n if (part.type === 'tool-createWordDocument') {\n return $t(`messagePart.createWordDocument`)\n }\n if (part.type === 'tool-querySpreadsheet') {\n return $t(`messagePart.querySpreadsheet`)\n }\n if (part.type === 'tool-geocode') {\n return $t(`messagePart.geocode`)\n }\n if (part.type === 'tool-getWeather') {\n return $t(`messagePart.getWeather`)\n }\n if (part.type === 'tool-recallUserMemory') {\n return $t(`messagePart.recallUserMemory`)\n }\n if (part.type === 'tool-saveUserMemory') {\n return $t(`messagePart.saveUserMemory`)\n }\n if (part.type === 'tool-showWeather') {\n return $t(`messagePart.showWeather`)\n }\n if (part.type === 'tool-showForm') {\n return $t(`messagePart.showForm`)\n }\n if (part.type === 'tool-showChart') {\n return $t(`messagePart.showChart`)\n }\n if (part.type === 'tool-showDiagram') {\n return $t(`messagePart.showDiagram`)\n }\n if (part.type === 'tool-showSources') {\n return $t(`messagePart.showSources`)\n }\n if (part.type === 'tool-showMultipleChoice') {\n return $t(`messagePart.showMultipleChoice`)\n }\n if (part.type === 'tool-showArtifact') {\n return $t(`messagePart.showArtifact`)\n }\n if (part.type === 'tool-showEmail') {\n return $t(`messagePart.showEmail`)\n }\n if (part.type === 'tool-showMessage') {\n return $t(`messagePart.showMessage`)\n }\n if (part.type === 'tool-showWebPages') {\n return $t(`messagePart.showWebPages`)\n }\n if (part.type === 'tool-showProducts') {\n return $t(`messagePart.showProducts`)\n }\n if (part.type === 'tool-showContactForm') {\n return $t(`messagePart.showContactForm`)\n }\n if (part.type === 'tool-showCalendarEvent') {\n return $t(`messagePart.showCalendarEvent`)\n }\n if (part.type === 'tool-showComparison') {\n return $t(`messagePart.showComparison`)\n }\n if (part.type === 'tool-showLocation') {\n return $t(`messagePart.showLocation`)\n }\n if (part.type === 'tool-showQrCode') {\n return $t(`messagePart.showQrCode`)\n }\n if (part.type === 'tool-showImageGallery') {\n return $t(`messagePart.showImageGallery`)\n }\n if (part.type === 'tool-showVideo') {\n return $t(`messagePart.showVideo`)\n }\n if (part.type === 'tool-showSuggestedReply') {\n return $t(`messagePart.showSuggestedReply`)\n }\n if (part.type === 'tool-requestGeolocation') {\n return $t(`messagePart.requestGeolocation`)\n }\n if (part.type === 'tool-disconnectOAuthConnection') {\n return $t(`messagePart.disconnectOAuthConnection`)\n }\n if (part.type === 'tool-requestAccountLink') {\n return $t(`messagePart.requestAccountLink`)\n }\n if (part.type === 'tool-unlinkAccount') {\n return $t(`messagePart.unlinkAccount`)\n }\n if (WEB_SEARCH_TOOL_TYPES.includes(part.type)) {\n return $t(`messagePart.webSearch`)\n }\n return $t(`messagePart.tool`)\n }\n if (isReasoningPart(part)) {\n return $t(`messagePart.reasoning`)\n }\n return $t(`messagePart.streaming`)\n}\n\n/** The version of a file stored in the chat that a preview opens. */\nexport type ChatFilePreviewTarget = {\n kind: 'word' | 'spreadsheet'\n storedFileName: string\n /** The name of the file, not of its version. */\n filename: string\n version?: number\n /** The file all its versions belong to, as the agent names it. */\n fileId?: string\n}\n\n/**\n * How the viewer draws a Word document's tracked changes: marked as Word\n * marks them, as if accepted, or as before them.\n */\nexport type WordPreviewMode = 'markup' | 'accepted' | 'original'\n\n/**\n * The fonts that stand in for Office's where the reader's system lacks them:\n * the metric-compatible ones of Linux and Chrome OS first, so the lines break\n * where Word breaks them, then the closest common ones.\n */\nconst WORD_FONT_STACKS: Record<string, string> = {\n calibri: 'Calibri, Carlito, \"Segoe UI\", Arial, sans-serif',\n 'calibri light':\n '\"Calibri Light\", Calibri, Carlito, \"Segoe UI\", sans-serif',\n aptos: 'Aptos, Calibri, Carlito, \"Segoe UI\", Arial, sans-serif',\n 'aptos display': '\"Aptos Display\", Aptos, Calibri, Carlito, sans-serif',\n cambria: 'Cambria, Caladea, Georgia, serif',\n 'times new roman':\n '\"Times New Roman\", Tinos, \"Liberation Serif\", Times, serif',\n arial: 'Arial, Arimo, \"Liberation Sans\", Helvetica, sans-serif',\n helvetica: 'Helvetica, Arial, Arimo, sans-serif',\n 'courier new': '\"Courier New\", Cousine, \"Liberation Mono\", monospace',\n garamond: 'Garamond, \"EB Garamond\", Georgia, serif',\n georgia: 'Georgia, serif',\n verdana: 'Verdana, \"DejaVu Sans\", sans-serif',\n tahoma: 'Tahoma, Verdana, sans-serif',\n}\n\n/**\n * Word's single line as a multiple of the font size, from the font's ascent,\n * descent and line gap: the lines keep the height of the document's font\n * where another font stands in for it.\n */\nconst WORD_LINE_FACTORS: Record<string, number> = {\n calibri: 1.22,\n 'calibri light': 1.22,\n cambria: 1.17,\n 'times new roman': 1.15,\n arial: 1.15,\n helvetica: 1.15,\n 'courier new': 1.13,\n georgia: 1.14,\n verdana: 1.22,\n tahoma: 1.21,\n}\n\n/** Word's single line for a font a Word document names. */\nexport const wordLineFactor = (font: string): number =>\n WORD_LINE_FACTORS[font.toLowerCase()] ?? 1.17\n\n/** The CSS font stack for a font a Word document names. */\nexport const wordFontStack = (font: string): string =>\n WORD_FONT_STACKS[font.toLowerCase()] ??\n `\"${font.replace(/\"/g, '')}\", ${\n /roman|garamond|cambria|georgia|serif|book|times/i.test(font)\n ? 'Georgia, serif'\n : 'Calibri, Carlito, \"Segoe UI\", Arial, sans-serif'\n }`\n\n/**\n * The images of the Word document in the viewer, by reference, which its\n * runs draw (`PkWordPreview` provides them).\n */\nexport const WORD_PREVIEW_IMAGES: InjectionKey<\n Ref<Record<string, string> | undefined>\n> = Symbol('wordPreviewImages')\n\n/**\n * The image a run draws, only a WebP the server wrote: anything else in the\n * map is not drawn.\n */\nexport const wordPictureSrc = (\n images: Record<string, string> | undefined,\n ref: string,\n): string | undefined => {\n const src = images?.[ref]\n return src?.startsWith('data:image/webp;base64,') ? src : undefined\n}\n\n/** The numbers the page number fields of a page show. */\nexport type WordPageNumbers = {\n page: number\n pages: number\n sectionPages: number\n}\n\n/**\n * Where an image Word positions on the page sits on it: from the page's top\n * left corner, in points, under the text or over it.\n */\nexport const wordPageAnchorCss = (\n picture: WordPreviewPicture,\n page: WordPreviewPage,\n): CSSProperties => {\n const anchor = picture.anchor!\n return {\n left: `${anchor.xFrom === 'page' ? anchor.x : page.margins.left + anchor.x}pt`,\n top: `${anchor.yFrom === 'page' ? anchor.y : page.margins.top + anchor.y}pt`,\n width: `${picture.width}pt`,\n height: `${picture.height}pt`,\n zIndex: anchor.wrap === 'behind' ? -1 : 1,\n }\n}\n\n/**\n * How an image of a run is placed: in the text, beside the text of its\n * paragraph, on a line of its own, from its paragraph, or on the page,\n * which the page draws.\n */\nexport const wordPicturePlacement = (\n picture: WordPreviewPicture,\n): 'inline' | 'around' | 'block' | 'paragraph' | 'page' => {\n const anchor = picture.anchor\n return !anchor\n ? 'inline'\n : anchor.wrap === 'around'\n ? 'around'\n : anchor.wrap === 'block'\n ? 'block'\n : anchor.yFrom === 'paragraph'\n ? 'paragraph'\n : 'page'\n}\n\n/** The runs a mode keeps: a deletion is gone once accepted. */\nexport const wordKeptRuns = (\n runs: WordPreviewRun[],\n mode: WordPreviewMode,\n): WordPreviewRun[] =>\n runs.filter((r) =>\n mode === 'accepted'\n ? r.change !== 'deleted'\n : mode === 'original'\n ? r.change !== 'inserted'\n : true,\n )\n\nconst hasWordText = (runs: WordPreviewRun[]) =>\n runs.some((r) => r.image || r.text.trim())\n\n/** A piece of a Word document's flow: a paragraph or a table row. */\nexport type WordFlowItem = {\n key: string\n block: number\n row?: number\n breakBefore: boolean\n /** The section it opens. */\n section?: number\n /** Stays on the page of the next piece (Word's \"Keep with next\"). */\n keepNext?: true\n}\n\n/**\n * The pieces of `blocks` in order, as the pages hold them. A paragraph or a\n * table row a mode empties is gone (a row inserted, as the original); one\n * empty in the document stays, a blank line as in Word. A section a gone\n * piece opened, with its page break, passes to the next one.\n */\nexport const wordFlowItems = (\n blocks: WordPreviewBlock[],\n mode: WordPreviewMode,\n): WordFlowItem[] => {\n const out: WordFlowItem[] = []\n let breakPending = false\n let sectionPending: number | undefined\n const push = (\n key: string,\n block: number,\n row: number | undefined,\n breakBefore: boolean,\n section: number | undefined,\n keepNext: boolean,\n ) => {\n const opens = section ?? sectionPending\n out.push({\n key,\n block,\n ...(row !== undefined ? { row } : {}),\n breakBefore: breakBefore || breakPending,\n ...(opens !== undefined ? { section: opens } : {}),\n ...(keepNext ? { keepNext: true as const } : {}),\n })\n breakPending = false\n sectionPending = undefined\n }\n // A gone piece's own page break goes with it; a section's start stays\n const skip = (breakBefore: boolean, section: number | undefined) => {\n breakPending ||= breakBefore && section !== undefined\n sectionPending = section ?? sectionPending\n }\n blocks.forEach((block, b) => {\n if (block.kind === 'table') {\n // The table's break and section go with its first row shown\n let breaks = !!block.pageBreakBefore\n let opens = block.section\n block.rows.forEach((cells, r) => {\n const filled = cells.some((cell) => cell.runs.length)\n if (\n filled &&\n !cells.some((cell) =>\n hasWordText(wordKeptRuns(cell.runs, mode)),\n )\n ) {\n return\n }\n push(\n `${b}:${r}`,\n b,\n r,\n breaks,\n opens,\n cells.some((cell) => cell.keepNext),\n )\n breaks = false\n opens = undefined\n })\n skip(breaks, opens)\n } else if (\n !block.runs.length ||\n hasWordText(wordKeptRuns(block.runs, mode))\n ) {\n push(\n `${b}`,\n b,\n undefined,\n !!block.style?.pageBreakBefore,\n block.section,\n !!block.style?.keepNext,\n )\n } else {\n skip(!!block.style?.pageBreakBefore, block.section)\n }\n })\n return out\n}\n\n/** The images Word positions on the page among the paragraphs of `blocks`. */\nexport const wordPageAnchors = (\n blocks: WordPreviewBlock[],\n mode: WordPreviewMode,\n): WordPreviewPicture[] =>\n blocks.flatMap((block) =>\n block.kind === 'table'\n ? []\n : wordKeptRuns(block.runs, mode).flatMap((run) =>\n run.picture && wordPicturePlacement(run.picture) === 'page'\n ? [run.picture]\n : [],\n ),\n )\n\n/** An earlier version of a file of the chat, for the agent to restore. */\nexport type ChatFileRestoreTarget = {\n /** The id the agent names the file with: the stored name of version 1. */\n fileId: string\n version: number\n filename: string\n}\n\n/**\n * The name of a file, not of its version: `listino (v2).xlsx` is version 2\n * of `listino.xlsx`.\n */\nexport const chatFileName = (filename: string, version?: number): string =>\n version\n ? filename.replace(new RegExp(` \\\\(v${version}\\\\)(\\\\.\\\\w+)$`), '$1')\n : filename\n\nconst EDITABLE_IMAGE_TYPES = new Set(['image/jpeg', 'image/png', 'image/webp'])\n\n/**\n * Whether the image editor (spec `chat-image-editor.md`) opens on a file of\n * this type: one a canvas reads and writes back as the same type, so not a\n * GIF, an SVG or a HEIC. Here and not in `imageEdits.ts`, which the\n * composer would otherwise pull into the main bundle of the widget.\n */\nexport function isEditableImage(mediaType: string): boolean {\n return EDITABLE_IMAGE_TYPES.has(mediaType)\n}\n\n/**\n * An input method (Japanese, Chinese, Korean) is composing a word: its\n * Enter and Esc confirm or drop the word. Safari reports the Enter that\n * confirms it with `isComposing` already false, hence the 229.\n */\nexport function isImeComposing(event: KeyboardEvent): boolean {\n return event.isComposing || event.keyCode === 229\n}\n\n/**\n * Whether a chat stands in front of the place of the bar that shows the\n * agent acting on the page (`PkPageControlBar`): the top centre of the\n * window, from the bar's `top` of 48px to about its 44px of height below.\n * There the bar would only cover the chat's header, and the chat shows the\n * steps and their stop itself.\n */\nexport function chatCoversPageControlBar(\n chat: Pick<DOMRect, 'left' | 'right' | 'top' | 'bottom'>,\n windowWidth: number,\n): boolean {\n const center = windowWidth / 2\n return (\n chat.left <= center &&\n chat.right >= center &&\n chat.top <= 92 &&\n chat.bottom >= 48\n )\n}\n\n/** Where a selection bar goes, in the coordinates of its `bounds`. */\nexport type SelectionBarPosition = {\n top: number\n left: number\n placement: 'above' | 'below'\n}\n\n/**\n * Where the bar of a selection goes (spec `selection-actions.md`, \"Dove\"):\n * above the start of the selection, where it covers what was already read,\n * and below it only without room above; always below on a touch screen, away\n * from the menu the system opens above a selection. `start` is the box of the\n * selection's first line, `bottom` its lowest edge, `bounds` the box the bar\n * stays in, all in one coordinate space, the result's too.\n */\nexport function selectionBarPosition({\n start,\n bottom,\n bar,\n bounds,\n touch = false,\n gap = 8,\n margin = 8,\n}: {\n start: Pick<DOMRect, 'top' | 'left'>\n bottom: number\n bar: { width: number; height: number }\n bounds: Pick<DOMRect, 'top' | 'left' | 'width' | 'height'>\n touch?: boolean\n gap?: number\n margin?: number\n}): SelectionBarPosition {\n const above = start.top - gap - bar.height\n const placement = !touch && above >= bounds.top + margin ? 'above' : 'below'\n const top =\n placement === 'above'\n ? above\n : Math.max(\n bounds.top + margin,\n Math.min(\n bottom + gap,\n bounds.top + bounds.height - margin - bar.height,\n ),\n )\n const left = Math.max(\n bounds.left + margin,\n Math.min(start.left, bounds.left + bounds.width - margin - bar.width),\n )\n return { top, left, placement }\n}\n"],"mappings":";;;;;AAAA,IAAaU,KAAiB,MAC1BC,EAAI,UAAU,KAAK,CAAC,CAAC,QAAQ,oBAAoB,EAAE,GAkB1CC,KAAe,MACnBD,IAGEA,EACF,QAAQ,sBAAsB,OAAO,CAAC,CACtC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,UAAU,GAAG,IALf,IAiBFE,KAAiC,MACrCF,IAGED,EAAcC,CAAG,CAAC,CACpB,QAAQ,sBAAsB,OAAO,CAAC,CACtC,QAAQ,kBAAkB,GAAG,CAAC,CAC9B,YAAY,IALN,IAeFG,MAAiC,MACrCH,IAGED,EAAcC,CAAG,CAAC,CACpB,QAAQ,s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MC,GACb,KAAK,IACDC,IAASN,GACTI,EAAO,MAAMA,EAAO,SAASC,IAASJ,EAAI,MAC9C,CACJ;EAKI,MAJD,KAAK,IACdG,EAAO,OAAOC,GACd,KAAK,IAAIN,EAAM,MAAMK,EAAO,OAAOA,EAAO,QAAQC,IAASJ,EAAI,KAAK,CAE1D;EAAM;CAAU;AAClC"}
1
+ {"version":3,"file":"utils-KBB6SDPn.js","names":["isPresentationTool","MCP_TOOL_PREFIX","WEB_SEARCH_TOOL_KEYS","SUBAGENT_TOOL_PREFIX","API_TOOL_PREFIX","isHostToolPart","isReasoningPart","getToolPartName","isTextPart","isToolPart","removeAccents","str","fromAnyCase","toKebabCase","toSnakeCase","capitalizeFirstLetter","mergeConsecutiveTextParts","merged","part","parts","prev","isWidgetPart","dropCorrectedWidgetErrors","lastDrawn","index","isStreamingPart","FILE_OUTPUT_PARTS","moveFileOutputsLast","files","feedPartKey","toolCallId","getHostCallPart","PAGE_TOOL_STEPS","HOST_STEP_TITLES","HOST_STEP_CHANGES","FORM_TOOL_STEP","pageToolStep","host","isHostActionPart","LIVE_REASONING_TAIL_LENGTH","FENCE_LINE","getMarkdownTail","markdown","maxLength","from","limit","boundary","length","cut","openFence","match","marker","rest","TOOL_APPROVAL_STATES","isToolApprovalPart","CONFIRM_TOOL_NAME","isToolConfirmPart","isConfirmationCardPart","getToolApprovalId","getPartState","isLoadingState","state","getContrast","hex","hexcolor","char","r","g","b","linearize","c","isAchromaticColor","channels","at","channelsToHex","value","readCssColor","expression","computed","probe","srgb","rgb","resolveGlowTints","readGlowTints","source","mainColor","sourceHex","neutral","middle","color","hueShift","first","second","secondColor","tones","resolveContrastColor","textColor","agentThemeStyle","contrastColor","formatDuration","ms","$n","stringifyPayload","json","hasPayload","formAnswerAsSpoken","input","answer","question","questionById","step","said","id","formStepOptions","option","formAnswerSlots","slots","output","steps","assign","list","WEB_SEARCH_TOOL_TYPES","key","RICH_DETAIL_TOOL_TYPES","hasRichToolDetail","asRecord","pickString","keys","record","getToolPartSummary","queries","valid","query","sheet","range","getPartIcon","TOOL_KEY_PREFIXES","toolLabel","te","name","prefix","p","PART_TYPE_LABELS","t","getPartTypeLabel","translator","label","PROVIDER_NAMES","providerLabel","slug","localizeSummaryLabels","summary","labels","colon","getToolPartLabel","live","hostStepTitles","page","$t","WORD_FONT_STACKS","WORD_LINE_FACTORS","wordLineFactor","font","wordFontStack","WORD_PREVIEW_IMAGES","wordPictureSrc","src","images","ref","wordPageAnchorCss","anchor","picture","wordPicturePlacement","wordKeptRuns","runs","mode","hasWordText","wordFlowItems","out","breakPending","sectionPending","push","opens","section","row","breakBefore","keepNext","skip","blocks","block","breaks","cell","cells","wordPageAnchors","run","chatFileName","version","filename","EDITABLE_IMAGE_TYPES","isEditableImage","mediaType","isImeComposing","event","selectionBarPosition","above","start","gap","bar","placement","touch","bounds","margin","bottom"],"sources":["../../../../packages/utils/src/text.ts","../../../../packages/components/src/chat/utils.ts"],"sourcesContent":["export const removeAccents = (str: string) =>\n str.normalize('NFD').replace(/[\\u0300-\\u036f]/g, '')\n\nexport const toCamelCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/[^a-zA-Z0-9]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^(.)/, (match) => match.toLowerCase()) as unknown as T\n}\n\nexport const fromCamelCase = (str?: string): string => {\n if (!str) {\n return ''\n }\n return str.replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n}\n\nexport const fromAnyCase = (str?: string): string => {\n if (!str) {\n return ''\n }\n return str\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/[-_]+/g, ' ')\n}\n\nexport const toPascalCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/[^a-zA-Z0-9]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^(.)/, (match) => match.toUpperCase()) as unknown as T\n}\n\nexport const toKebabCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[^a-zA-Z0-9]+/g, '-')\n .toLowerCase() as unknown as T\n}\n\nexport const fromKebabCase = (str?: string): string => {\n if (!str) {\n return ''\n }\n return str.replace(/-/g, ' ')\n}\n\nexport const toSnakeCase = <T extends string>(str?: string): T => {\n if (!str) {\n return '' as unknown as T\n }\n return removeAccents(str)\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/[^a-zA-Z0-9]+/g, '_')\n .toLowerCase() as unknown as T\n}\n\nexport const capitalizeFirstLetter = (str?: string) => {\n if (!str) {\n return ''\n }\n return str.charAt(0).toUpperCase() + str.slice(1)\n}\n\nexport const lowercaseFirstLetter = (str?: string) => {\n if (!str) {\n return ''\n }\n return str.charAt(0).toLowerCase() + str.slice(1)\n}\n","import type { UIMessage } from 'ai'\nimport type { CSSProperties, InjectionKey, Ref } from 'vue'\nimport {\n API_TOOL_PREFIX,\n MCP_TOOL_PREFIX,\n SUBAGENT_TOOL_PREFIX,\n WEB_SEARCH_TOOL_KEYS,\n isHostToolPart,\n isPresentationTool,\n type WordPreviewBlock,\n type WordPreviewPage,\n type WordPreviewPicture,\n type WordPreviewRun,\n} from 'models'\nimport {\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n hasPartText,\n hasTextPart,\n getTextPart,\n getMessageText,\n getToolPartName,\n capitalizeFirstLetter,\n fromAnyCase,\n} from 'utils'\n\nexport {\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n hasPartText,\n hasTextPart,\n getTextPart,\n getMessageText,\n}\n\n/**\n * Merges consecutive text parts into a single text part.\n * Claude (and other models) often produce multiple text parts during streaming\n * that should logically be a single block of text.\n */\nexport function mergeConsecutiveTextParts(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const merged: UIMessage['parts'] = []\n for (const part of parts) {\n if (!isTextPart(part)) {\n merged.push(part)\n continue\n }\n const prev = merged[merged.length - 1]\n if (prev && isTextPart(prev)) {\n merged[merged.length - 1] = { ...prev, text: prev.text + part.text }\n } else {\n merged.push(part)\n }\n }\n return merged\n}\n\nconst isWidgetPart = (\n part: UIMessage['parts'][number],\n): part is Extract<UIMessage['parts'][number], { type: `tool-${string}` }> =>\n isToolPart(part) && isPresentationTool(getToolPartName(part))\n\n/**\n * Drops a widget call refused for its arguments when a later call of the same\n * widget in the message was drawn: the turn corrected it (the backend's\n * `correctableInputRefusals`), and the refusal would sit next to the working\n * widget, `showForm` drawing its render error above the form. A refusal with\n * nothing drawn after it stays. Only the feed reads this: the steps timeline\n * keeps every call, the refused one included.\n */\nexport function dropCorrectedWidgetErrors(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const lastDrawn = new Map<string, number>()\n for (const [index, part] of parts.entries()) {\n if (\n isWidgetPart(part) &&\n part.state !== 'output-error' &&\n !isStreamingPart(part)\n ) {\n lastDrawn.set(part.type, index)\n }\n }\n return parts.filter(\n (part, index) =>\n !(\n isWidgetPart(part) &&\n part.state === 'output-error' &&\n (lastDrawn.get(part.type) ?? -1) > index\n ),\n )\n}\n\n/**\n * Tool calls whose output is a file for the user to download. The feed draws\n * them after the answer, where the reader arrives, wherever in the message the\n * model made the call: a version written before a long answer sat above it,\n * out of sight.\n */\nconst FILE_OUTPUT_PARTS: ReadonlySet<string> = new Set([\n 'tool-editSpreadsheet',\n 'tool-shareDocument',\n 'tool-editWordDocument',\n 'tool-createSpreadsheet',\n 'tool-createWordDocument',\n])\n\n/** The parts with the file outputs moved last, in their own order. */\nexport function moveFileOutputsLast(\n parts: UIMessage['parts'],\n): UIMessage['parts'] {\n const files = parts.filter((part) => FILE_OUTPUT_PARTS.has(part.type))\n return files.length > 0\n ? [\n ...parts.filter((part) => !FILE_OUTPUT_PARTS.has(part.type)),\n ...files,\n ]\n : parts\n}\n\n/**\n * The key of a part in the feed. Its position, except for a file output: that\n * one is always last, so its position moves as the answer grows, and keyed by\n * it the card would be redrawn at every new part.\n */\nexport function feedPartKey(\n part: UIMessage['parts'][number],\n index: number,\n): string | number {\n const toolCallId = (part as { toolCallId?: string }).toolCallId\n return FILE_OUTPUT_PARTS.has(part.type) && toolCallId\n ? `file-${toolCallId}`\n : index\n}\n\n/** A call the embedding page runs, as the backend stamped it (spec `host-tools.md`). */\ninterface HostCallPart {\n toolCallId?: string\n toolName: string\n title?: string\n state?: string\n errorText?: string\n toolMetadata?: { readOnly?: boolean; provider?: 'app' | 'page' }\n}\n\nexport function getHostCallPart(\n part: UIMessage['parts'][number] | null | undefined,\n): HostCallPart | undefined {\n return isHostToolPart(part) ? (part as unknown as HostCallPart) : undefined\n}\n\n/**\n * The page tools of the widget (spec `page-tools.md`): defined by the backend,\n * so their step is ours to name, in the user's language. A tool the app\n * registered is named by its own `title`.\n */\nconst PAGE_TOOL_STEPS: Record<string, { icon: string; label: string }> = {\n page_snapshot: {\n icon: 'ri:pages-line',\n label: 'messagePart.pageTool.snapshot',\n },\n page_read: {\n icon: 'ri:file-text-line',\n label: 'messagePart.pageTool.read',\n },\n page_click: { icon: 'ri:cursor-line', label: 'messagePart.pageTool.click' },\n page_fill: { icon: 'ri:edit-line', label: 'messagePart.pageTool.fill' },\n page_scroll: {\n icon: 'ri:arrow-up-down-line',\n label: 'messagePart.pageTool.scroll',\n },\n page_find: { icon: 'ri:search-line', label: 'messagePart.pageTool.find' },\n page_wait: { icon: 'ri:time-line', label: 'messagePart.pageTool.wait' },\n page_hover: {\n icon: 'ri:cursor-line',\n label: 'messagePart.pageTool.hover',\n },\n page_press: {\n icon: 'ri:keyboard-line',\n label: 'messagePart.pageTool.press',\n },\n page_back: {\n icon: 'ri:arrow-go-back-line',\n label: 'messagePart.pageTool.back',\n },\n page_navigate: {\n icon: 'ri:links-line',\n label: 'messagePart.pageTool.navigate',\n },\n}\n\n/**\n * The titles the widget gave this page's steps, by call, naming what each\n * acts on (spec `page-tools-improvements.md`, M8): provided by the chat view\n * from its store, read by the views that list the steps.\n */\nexport const HOST_STEP_TITLES: InjectionKey<Ref<Record<string, string>>> =\n Symbol('hostStepTitles')\n\n/** A setting a step changes: what it was, what it becomes. */\nexport type StepFieldChange = { label: string; value: string; before?: string }\n\n/**\n * What the steps the automatic confirmations ran without a card changed, by\n * call (spec `auto-confirmations.md`): provided by the chat view from its\n * store, shown under each step's line.\n */\nexport const HOST_STEP_CHANGES: InjectionKey<\n Ref<\n Record<\n string,\n {\n details?: StepFieldChange[]\n unchanged?: { label: string; value: string }[]\n }\n >\n >\n> = Symbol('hostStepChanges')\n\n/** A form the site annotated for agents: its tool is named `form_<toolname>`. */\nconst FORM_TOOL_STEP = {\n icon: 'ri:survey-line',\n label: 'messagePart.pageTool.form',\n}\n\nconst pageToolStep = (host: HostCallPart) =>\n host.toolMetadata?.provider === 'page'\n ? (PAGE_TOOL_STEPS[host.toolName] ??\n (host.toolName.startsWith('form_') ? FORM_TOOL_STEP : undefined))\n : undefined\n\n/**\n * A host call that changes something in the app or on the page: the feed\n * shows it even without the steps timeline, because what it did stays done.\n */\nexport function isHostActionPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return getHostCallPart(part)?.toolMetadata?.readOnly === false\n}\n\nexport function isStreamingPart(\n part: UIMessage['parts'][number] | null | undefined,\n): part is Extract<UIMessage['parts'][number], { streaming?: boolean }> {\n if (!part) {\n return false\n }\n if ('state' in part) {\n return part.state === 'streaming' || part.state === 'input-streaming'\n }\n return false\n}\n\n/**\n * How much of a reasoning still being written its live box renders. The box is\n * a few lines tall and follows the bottom, while the reasoning of one turn runs\n * to tens of kilobytes: chat `st0Eg8iG0zUX0HQN` wrote 92KB, and parsing all of\n * it at every delta froze the tab. Four thousand characters leave a few screens\n * to scroll back through, and a finished step renders all of it.\n */\nexport const LIVE_REASONING_TAIL_LENGTH = 4000\n\n// A fence opener or closer, also inside a list item or a quote, whose markers\n// and indentation are skipped. The rest of the line tells them apart: a\n// closing fence carries no info string.\nconst FENCE_LINE =\n /^[ \\t]*(?:(?:[-*+]|\\d{1,9}[.)])[ \\t]+|>[ \\t]?)*(`{3,}|~{3,})(.*)$/gm\n\n/**\n * The end of a markdown text, at most `maxLength` characters long, cut on a\n * blank line (a line break when there is none) so it does not open on half a\n * paragraph. A table or a formula can still be cut in two. An ellipsis marks\n * the cut. A cut inside a fenced code block reopens the fence, or the rest of\n * the text would render as code and the code as prose.\n */\nexport function getMarkdownTail(markdown: string, maxLength: number): string {\n if (markdown.length <= maxLength) {\n return markdown\n }\n const from = markdown.length - maxLength\n // The boundary is looked for in the first half of the window only: the one\n // blank line of the window can be the last thing written, and cutting there\n // would leave nothing to render.\n const limit = from + maxLength / 2\n const boundary = (index: number, length: number) =>\n index !== -1 && index < limit ? index + length : undefined\n const cut =\n boundary(markdown.indexOf('\\n\\n', from), 2) ??\n boundary(markdown.indexOf('\\n', from), 1) ??\n from\n let openFence: string | undefined\n for (const match of markdown.matchAll(FENCE_LINE)) {\n if (match.index >= cut) {\n break\n }\n const [, marker, rest] = match\n if (!openFence) {\n // A backtick in a backtick fence's info string makes it inline\n // code, not a fence.\n if (marker[0] === '`' && rest.includes('`')) {\n continue\n }\n openFence = marker\n } else if (\n marker[0] === openFence[0] &&\n marker.length >= openFence.length &&\n !rest.trim()\n ) {\n openFence = undefined\n }\n }\n const reopen = openFence ? `${openFence}\\n` : ''\n return `…\\n\\n${reopen}${markdown.slice(cut)}`\n}\n\n/**\n * States a tool part goes through when it needs the user's approval. They are\n * rendered by `PkToolApprovalCard` whatever the tool is, so the decision (and\n * its outcome) stays visible in the transcript.\n */\nconst TOOL_APPROVAL_STATES = new Set([\n 'approval-requested',\n 'approval-responded',\n 'output-denied',\n])\n\nexport function isToolApprovalPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n if (!isToolPart(part)) {\n return false\n }\n if (TOOL_APPROVAL_STATES.has(part.state)) {\n return true\n }\n // An executed (or errored) call that went through the gate keeps its\n // verdict in `approval`: the card stays in the transcript, so the user's\n // decision remains visible in the chat and in the log viewers (parity\n // with requestConfirm, whose 'confirmed' output is persisted).\n return (part as { approval?: unknown }).approval != null\n}\n\n/**\n * The client-side tool the model uses to have an action it described approved.\n * It predates the SDK's approval gate and keeps its own round-trip (it resolves\n * through `addToolOutput`), but it asks the user the very same question, so it\n * shares `PkToolApprovalCard` instead of having a card of its own.\n */\nexport const CONFIRM_TOOL_NAME = 'requestConfirm'\n\nexport function isToolConfirmPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return isToolPart(part) && part.type === `tool-${CONFIRM_TOOL_NAME}`\n}\n\n/** True for any part the confirmation card is responsible for. */\nexport function isConfirmationCardPart(\n part: UIMessage['parts'][number] | null | undefined,\n): boolean {\n return isToolApprovalPart(part) || isToolConfirmPart(part)\n}\n\n/** The id of the pending approval request on a tool part, if any. */\nexport function getToolApprovalId(\n part: UIMessage['parts'][number] | null | undefined,\n): string | undefined {\n if (!isToolPart(part)) {\n return undefined\n }\n return (part as { approval?: { id?: string } }).approval?.id\n}\n\nexport function getPartState(\n part: UIMessage['parts'][number] | null | undefined,\n): string | undefined {\n if (!part) {\n return undefined\n }\n if ('state' in part) {\n return part.state\n }\n return undefined\n}\n\nexport function isLoadingState(state?: string): boolean {\n if (!state) {\n return false\n }\n return ['streaming'].includes(state)\n}\n\nexport function getContrast(hexcolor: string = '000000'): 'black' | 'white' {\n let hex = hexcolor.replace('#', '')\n\n // Expand 3-character hex to 6-character (e.g., #ccc -> #cccccc)\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map((char) => char + char)\n .join('')\n }\n\n // WCAG relative luminance\n const r = parseInt(hex.substring(0, 2), 16) / 255\n const g = parseInt(hex.substring(2, 4), 16) / 255\n const b = parseInt(hex.substring(4, 6), 16) / 255\n\n const linearize = (c: number) =>\n c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n\n const luminance =\n 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b)\n\n return luminance > 0.179 ? 'black' : 'white'\n}\n\n/**\n * True for a hex color with almost no hue: black, white and the grays between.\n * Anything else, a color the function cannot read included, counts as colored.\n */\nexport function isAchromaticColor(hexcolor: string | undefined): boolean {\n let hex = hexcolor?.trim().replace('#', '') ?? ''\n if (/^[0-9a-f]{3}$/i.test(hex)) {\n hex = hex\n .split('')\n .map((char) => char + char)\n .join('')\n }\n if (!/^[0-9a-f]{6}$/i.test(hex)) {\n return false\n }\n const channels = [0, 2, 4].map((at) =>\n parseInt(hex.substring(at, at + 2), 16),\n )\n return Math.max(...channels) - Math.min(...channels) < 32\n}\n\n/** A color as the glow's shader takes it: three channels, 0-255. */\nexport type RgbChannels = [number, number, number]\n\n/** The two tints of the empty chat's glow, and whether the second shows. */\nexport type GlowTints = {\n first: RgbChannels\n second: RgbChannels\n duo: boolean\n}\n\n/** `#rrggbb` from three 0-255 channels. */\nexport const channelsToHex = (channels: RgbChannels) =>\n `#${channels.map((value) => value.toString(16).padStart(2, '0')).join('')}`\n\n/**\n * The color a CSS expression resolves to where `probe` sits. Mixed into sRGB\n * first, it computes to `color(srgb r g b)` whatever syntax it was written in\n * (the design system's tokens derive with the relative color syntax). A\n * browser without `color-mix()` would drop the mix and leave the inherited\n * color for every expression: it reads the bare one, which computes to `rgb()`.\n */\nfunction readCssColor(\n probe: HTMLElement,\n expression: string,\n): RgbChannels | null {\n probe.style.color = CSS.supports(\n 'color',\n 'color-mix(in srgb, red 100%, transparent)',\n )\n ? `color-mix(in srgb, ${expression} 100%, transparent)`\n : expression\n const computed = getComputedStyle(probe).color\n probe.style.color = ''\n const srgb = computed.match(/^color\\(srgb ([^\\s)]+) ([^\\s)]+) ([^\\s)]+)/)\n const rgb = computed.match(/rgba?\\(([\\d.]+)[,\\s]+([\\d.]+)[,\\s]+([\\d.]+)/)\n if (srgb) {\n return [srgb[1], srgb[2], srgb[3]].map((value) =>\n Math.round(Math.min(1, Math.max(0, Number(value))) * 255),\n ) as RgbChannels\n }\n if (rgb) {\n return [rgb[1], rgb[2], rgb[3]].map((value) =>\n Math.round(Number(value)),\n ) as RgbChannels\n }\n return null\n}\n\n/**\n * The two tints of the glow behind the empty chat's input. A color without a\n * hue (black, the default, white, a gray) drew a grey smudge on the light\n * theme and nothing on the dark one: the platform's accent lights it instead,\n * with its info color as the second tone, as the working beam does. Any other\n * color gives its neighbour 40° along the hue wheel as the second tone,\n * unless the agent chose one. Every tone is held to a middle lightness, like\n * the beam's, so a chosen second color that matches the one shown keeps the\n * glow as it was. `auto` shows the second tone only for a color without a hue.\n *\n * The colors resolve where `host` sits (its tokens, its theme); without\n * `mainColor` the glow starts from the host's own color. Null when the\n * browser cannot read them.\n */\nexport function resolveGlowTints(\n host: HTMLElement,\n {\n mainColor,\n tones = 'auto',\n secondColor,\n }: {\n mainColor?: string\n tones?: 'auto' | 'one' | 'two'\n secondColor?: string\n },\n): GlowTints | null {\n // A throwaway child inherits the host's color and custom properties, and\n // reading through it leaves the host's own style alone\n const probe = document.createElement('span')\n probe.hidden = true\n host.append(probe)\n try {\n return readGlowTints(probe, { mainColor, tones, secondColor })\n } finally {\n probe.remove()\n }\n}\n\nfunction readGlowTints(\n probe: HTMLElement,\n {\n mainColor,\n tones,\n secondColor,\n }: {\n mainColor?: string\n tones: 'auto' | 'one' | 'two'\n secondColor?: string\n },\n): GlowTints | null {\n const source = readCssColor(probe, mainColor ?? 'currentcolor')\n if (!source) {\n return null\n }\n const sourceHex = channelsToHex(source)\n const neutral = isAchromaticColor(sourceHex)\n // Where the browser can derive it; the color as it is otherwise\n const middle = (color: string, hueShift = 0) =>\n CSS.supports('color', 'oklch(from red l c h)')\n ? `oklch(from ${color} clamp(0.55, l, 0.75) c calc(h + ${hueShift}))`\n : color\n const first = readCssColor(\n probe,\n middle(neutral ? 'var(--color-accent)' : sourceHex),\n )\n const second = readCssColor(\n probe,\n secondColor\n ? middle(secondColor)\n : neutral\n ? middle('var(--color-info)')\n : middle(sourceHex, 40),\n )\n if (!first || !second) {\n return null\n }\n return {\n first,\n second,\n duo: tones === 'two' || (tones === 'auto' && neutral),\n }\n}\n\n/**\n * Resolves the contrast color based on the user's `textColor` preference.\n * Falls back to WCAG auto-detection via `getContrast` when set to `'auto'` or `undefined`.\n */\nexport function resolveContrastColor(\n textColor: 'auto' | 'white' | 'black' | undefined,\n mainColor: string | undefined,\n): 'black' | 'white' {\n if (textColor === 'white' || textColor === 'black') {\n return textColor\n }\n return getContrast(mainColor)\n}\n\n/**\n * The style of a chat root (PkChatbot, the widget's shell): the agent's color\n * as the brand. Volver derives every role of the brand (graphic, readable,\n * contrast, tinted surface) on any element with `.theme`, which both roots\n * carry, so the focus ring, the primary buttons, the links and the checkboxes\n * take the agent's color with the contrast each theme needs, instead of the\n * platform's purple. The fields' focus takes the brand's graphic role in both\n * themes, since the dark theme's accent is the platform's too.\n */\nexport function agentThemeStyle(\n mainColor: string | undefined,\n contrastColor: 'black' | 'white',\n): Record<string, string> | undefined {\n if (!mainColor) {\n return undefined\n }\n return {\n '--chatbot-main-color': mainColor,\n '--chatbot-contrast-color': contrastColor,\n '--color-brand': mainColor,\n '--color-brand-contrast': contrastColor,\n '--input-focus-color': 'var(--color-brand-graphic)',\n }\n}\n\n/**\n * Formats a duration in milliseconds using the i18n `seconds` number format\n * (e.g. \"12,4 secondi\" / \"12.4 seconds\"). Returns undefined for durations\n * that would render as \"0 seconds\" (less than 0.05s).\n */\nexport function formatDuration(\n $n: (value: number, format: string) => string,\n ms?: number,\n): string | undefined {\n if (ms === undefined || ms < 50) {\n return undefined\n }\n return $n(ms / 1000, 'seconds')\n}\n\n/**\n * Stringifies a tool payload for the raw fallback view. Returns undefined for\n * empty values so the caller can skip rendering the block entirely.\n */\nexport function stringifyPayload(value: unknown): string | undefined {\n if (value === undefined) {\n return undefined\n }\n if (typeof value === 'string') {\n return value.trim() || undefined\n }\n try {\n const json = JSON.stringify(value, null, 2)\n return json === '{}' || json === '[]' ? undefined : json\n } catch {\n return undefined\n }\n}\n\n/**\n * True when a tool payload carries something worth rendering, so a caller can\n * skip the block without stringifying the value twice.\n */\nexport function hasPayload(value: unknown): boolean {\n return stringifyPayload(value) !== undefined\n}\n\n/**\n * Turns the answers of a form into the sentence the caller would have said.\n *\n * On a call the tool loop is over by the time the form is on screen, so the\n * answers go back to the agent as a user message (see `sendUserMessage` in\n * `useVoiceSession`). Each answer is paired with its question, because that is\n * how a person would say it and because the agent hears it with no widget\n * attached.\n */\nexport function formAnswerAsSpoken(\n part: unknown,\n answer: string | { answers: { id: string; value: unknown }[] },\n): string {\n const input = (\n part as {\n input?: {\n steps?: { id: string; question?: string }[]\n question?: string\n }\n }\n )?.input\n\n if (typeof answer === 'string') {\n const question = input?.question ?? input?.steps?.[0]?.question\n return question ? `${question} ${answer}` : answer\n }\n\n const questionById = new Map(\n (input?.steps ?? []).map((step) => [step.id, step.question]),\n )\n const lines = answer.answers\n .filter(\n ({ value }) =>\n value !== null &&\n value !== '' &&\n !(Array.isArray(value) && !value.length),\n )\n .map(({ id, value }) => {\n const said = Array.isArray(value) ? value.join(', ') : String(value)\n const question = questionById.get(id)\n return question ? `${question} ${said}` : said\n })\n\n return lines.join('. ')\n}\n\n/**\n * The choices of a form step, as the radio and checkbox editors take them.\n *\n * The `value` is the LABEL and not the position, because it is what travels\n * back to the model as the answer: it reads the words it wrote, not an index.\n * Nothing here caps the list, and nothing should: the number of options an\n * agent configures is advice to the model, so a step can legitimately carry\n * more (see `showForm.tool.ts`).\n */\nexport function formStepOptions(\n step: { options?: { label: string; description?: string }[] } | undefined,\n): { label: string; value: string; description?: string }[] {\n if (!step?.options) {\n return []\n }\n return step.options.map((option) => ({\n label: option.label,\n value: option.label,\n description: option.description,\n }))\n}\n\n/**\n * Spreads the answers a form comes back with onto one slot PER STEP.\n *\n * A form's answers travel paired with step ids, and the tool schema does not\n * enforce that those ids are unique: a `.refine()` there would refuse the whole\n * form over a duplicate, which is the failure the schema was just cured of (see\n * the gotchas entry \"A configurable cap does not belong in an inputSchema\").\n * So the duplicate has to be survivable here. Keyed by id, two steps sharing\n * one collapsed onto a single answer: the second question showed the first\n * one's reply, and submitting sent that reply twice. Keyed by position, each\n * step keeps its own.\n *\n * A duplicated id restores the same incoming value to every step claiming it,\n * which is as much as the payload allows: the ids are all it says.\n */\nexport function formAnswerSlots(\n steps: { id: string }[],\n output: unknown,\n): Record<number, unknown> {\n const slots: Record<number, unknown> = {}\n if (output === undefined || output === null) {\n return slots\n }\n // A legacy single-choice answer is the plain string, and it can only\n // belong to a single-step form.\n if (typeof output === 'string') {\n if (steps.length === 1) {\n slots[0] = output\n }\n return slots\n }\n const assign = (id: string, value: unknown) => {\n steps.forEach((step, index) => {\n if (step.id === id) {\n slots[index] = value\n }\n })\n }\n const list = (output as { answers?: unknown }).answers\n if (Array.isArray(list)) {\n for (const answer of list as { id?: unknown; value?: unknown }[]) {\n if (typeof answer?.id === 'string') {\n assign(answer.id, answer.value)\n }\n }\n return slots\n }\n // Forms answered on a platform channel (the Teams modal) come back as a\n // flat record keyed by step id.\n for (const [id, value] of Object.entries(\n output as Record<string, unknown>,\n )) {\n if (value !== undefined) {\n assign(id, value)\n }\n }\n return slots\n}\n\n// Web search tool part types, gateway and provider-native\nexport const WEB_SEARCH_TOOL_TYPES: string[] = WEB_SEARCH_TOOL_KEYS.map(\n (key) => `tool-${key}`,\n)\n\n// Tool part types with a dedicated rich rendering in PkChatbotStepToolDetail\nconst RICH_DETAIL_TOOL_TYPES = new Set([\n 'tool-searchInKnowledgeBase',\n 'tool-retrieveRevisedAnswers',\n 'tool-expandChunkContext',\n 'tool-readDocumentFile',\n 'tool-getWeather',\n 'tool-geocode',\n 'tool-recallUserMemory',\n 'tool-saveUserMemory',\n ...WEB_SEARCH_TOOL_TYPES,\n])\n\nexport function hasRichToolDetail(\n part?: UIMessage['parts'][number] | null,\n): boolean {\n return isToolPart(part) && RICH_DETAIL_TOOL_TYPES.has(part.type)\n}\n\nconst asRecord = (value: unknown): Record<string, unknown> | undefined =>\n value && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined\n\nconst pickString = (\n record: Record<string, unknown> | undefined,\n ...keys: string[]\n): string | undefined => {\n for (const key of keys) {\n const value = record?.[key]\n if (typeof value === 'string' && value.trim()) {\n return value\n }\n }\n return undefined\n}\n\n/**\n * Returns a short inline summary for a tool part (search queries, location,\n * document name, ...) to be shown next to the step label without expanding\n * the step body.\n */\nexport function getToolPartSummary(\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n if (!isToolPart(part)) {\n return undefined\n }\n const input = asRecord('input' in part ? part.input : undefined)\n const output = asRecord('output' in part ? part.output : undefined)\n if (\n part.type === 'tool-searchInKnowledgeBase' ||\n WEB_SEARCH_TOOL_TYPES.includes(part.type)\n ) {\n const queries = input?.queries\n if (Array.isArray(queries)) {\n const valid = queries.filter(\n (query): query is string =>\n typeof query === 'string' && Boolean(query.trim()),\n )\n return valid.length ? valid.join(' · ') : undefined\n }\n return pickString(input, 'query', 'objective')\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return pickString(input, 'query')\n }\n if (part.type === 'tool-getWeather') {\n return (\n pickString(output, 'location') ?? pickString(input, 'locationName')\n )\n }\n if (part.type === 'tool-geocode') {\n return pickString(input, 'locationName')\n }\n if (part.type === 'tool-expandChunkContext') {\n return pickString(output, 'documentName')\n }\n if (\n part.type === 'tool-readDocumentFile' ||\n part.type === 'tool-readChatAttachment' ||\n part.type === 'tool-sendChatFile' ||\n part.type === 'tool-shareDocument'\n ) {\n return pickString(output, 'name')\n }\n if (part.type === 'tool-readSpreadsheet') {\n const sheet = pickString(input, 'sheet')\n const range = pickString(input, 'range')\n return sheet && range ? `${sheet}!${range}` : sheet\n }\n if (part.type === 'tool-editSpreadsheet') {\n return pickString(output, 'filename')\n }\n if (part.type === 'tool-readWordDocument') {\n return pickString(input, 'search') ?? pickString(input, 'from')\n }\n if (part.type === 'tool-editWordDocument') {\n return pickString(output, 'filename')\n }\n if (\n part.type === 'tool-createSpreadsheet' ||\n part.type === 'tool-createWordDocument'\n ) {\n // The name the file got, or while the call runs the one asked for.\n return pickString(output, 'filename') ?? pickString(input, 'filename')\n }\n if (part.type === 'tool-querySpreadsheet') {\n // The file when the step asked for the schema; a query has no name.\n return pickString(output, 'file')\n }\n if (part.type === 'tool-recallUserMemory') {\n return pickString(input, 'query')\n }\n if (part.type === 'tool-saveUserMemory') {\n return pickString(input, 'content', 'query')\n }\n return undefined\n}\n\n// Get part icon\nexport function getPartIcon(\n part?: UIMessage['parts'][number] | null,\n): string | undefined {\n const host = getHostCallPart(part)\n if (host) {\n return pageToolStep(host)?.icon ?? 'ri:apps-line'\n }\n if (isToolPart(part)) {\n if (part.type.includes('tool-subagent')) {\n return 'ri:robot-2-line'\n }\n if (part.type === 'tool-runWorker') {\n return 'ri:flow-chart'\n }\n if (part.type === 'tool-scheduleWakeup') {\n return 'ri:alarm-line'\n }\n if (part.type === 'tool-fetchTeamsChannelHistory') {\n return 'ri:chat-history-line'\n }\n if (part.type === 'tool-readEarlierMessages') {\n return 'ri:history-line'\n }\n if (part.type === 'tool-readChatAttachment') {\n return 'ri:attachment-line'\n }\n if (part.type === 'tool-sendChatFile') {\n return 'ri:send-plane-line'\n }\n if (part.type === 'tool-enableTools') {\n return 'ri:toggle-line'\n }\n if (part.type.includes('tool-mcp')) {\n return 'mcp'\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return 'ri:file-edit-line'\n }\n if (part.type === 'tool-searchInKnowledgeBase') {\n return 'ri:search-line'\n }\n if (part.type === 'tool-expandChunkContext') {\n return 'ri:file-search-line'\n }\n if (part.type === 'tool-readDocumentFile') {\n return 'ri:file-text-line'\n }\n if (part.type === 'tool-readSpreadsheet') {\n return 'ri:table-line'\n }\n if (\n part.type === 'tool-editSpreadsheet' ||\n part.type === 'tool-createSpreadsheet'\n ) {\n return 'ri:file-excel-2-line'\n }\n if (part.type === 'tool-shareDocument') {\n return 'ri:file-download-line'\n }\n if (part.type === 'tool-readWordDocument') {\n return 'ri:file-text-line'\n }\n if (\n part.type === 'tool-editWordDocument' ||\n part.type === 'tool-createWordDocument'\n ) {\n return 'ri:file-word-2-line'\n }\n if (part.type === 'tool-querySpreadsheet') {\n return 'ri:database-2-line'\n }\n if (part.type === 'tool-geocode') {\n return 'ri:map-2-line'\n }\n if (part.type === 'tool-getWeather') {\n return 'ri:sun-cloudy-line'\n }\n if (part.type === 'tool-recallUserMemory') {\n return 'ri:brain-line'\n }\n if (part.type === 'tool-saveUserMemory') {\n return 'ri:save-3-line'\n }\n if (part.type === 'tool-showWeather') {\n return 'ri:sun-line'\n }\n if (part.type === 'tool-showChart') {\n return 'ri:bar-chart-2-line'\n }\n if (part.type === 'tool-showDiagram') {\n return 'ri:flow-chart'\n }\n if (part.type === 'tool-showSources') {\n return 'ri:book-2-line'\n }\n if (part.type === 'tool-showForm') {\n return 'ri:survey-line'\n }\n if (part.type === 'tool-showMultipleChoice') {\n return 'ri:checkbox-multiple-line'\n }\n if (part.type === 'tool-showArtifact') {\n return 'ri:file-code-line'\n }\n if (part.type === 'tool-showEmail') {\n return 'ri:mail-line'\n }\n if (part.type === 'tool-showMessage') {\n return 'ri:chat-1-line'\n }\n if (part.type === 'tool-showWebPages') {\n return 'ri:pages-line'\n }\n if (part.type === 'tool-showProductList') {\n return 'ri:shopping-bag-line'\n }\n if (part.type === 'tool-showContactForm') {\n return 'ri:send-plane-2-line'\n }\n if (part.type === 'tool-showCalendarEvent') {\n return 'ri:calendar-event-line'\n }\n if (part.type === 'tool-showComparison') {\n return 'ri:scales-line'\n }\n if (part.type === 'tool-showLocation') {\n return 'ri:map-pin-line'\n }\n if (part.type === 'tool-showQrCode') {\n return 'ri:qr-code-line'\n }\n if (part.type === 'tool-showImageGallery') {\n return 'ri:image-line'\n }\n if (part.type === 'tool-showVideo') {\n return 'ri:film-line'\n }\n if (part.type === 'tool-showSuggestedReply') {\n return 'ri:corner-down-right-line'\n }\n if (part.type === 'tool-requestGeolocation') {\n return 'ri:map-pin-user-line'\n }\n if (part.type === 'tool-disconnectOAuthConnection') {\n return 'ri:link-unlink'\n }\n if (part.type === 'tool-requestAccountLink') {\n return 'ri:link'\n }\n if (part.type === 'tool-unlinkAccount') {\n return 'ri:link-unlink'\n }\n if (WEB_SEARCH_TOOL_TYPES.includes(part.type)) {\n return 'ri:global-line'\n }\n return 'ri:tools-line'\n }\n if (isReasoningPart(part)) {\n return 'ri:lightbulb-line'\n }\n if (isTextPart(part)) {\n return 'ri:double-quotes-r'\n }\n return undefined\n}\n\n/** What `toolLabel` and `getPartTypeLabel` need from vue-i18n. */\nexport interface LabelTranslator {\n t: (key: string) => string\n te: (key: string) => boolean\n}\n\nconst TOOL_KEY_PREFIXES = [\n API_TOOL_PREFIX,\n MCP_TOOL_PREFIX,\n SUBAGENT_TOOL_PREFIX,\n] as const\n\n/**\n * The name a person reads for a tool of the turn: the translated label of a\n * built-in tool, otherwise the name the agent configured, without its\n * tool-set prefix and in words (`api-festivita_nazionali` reads \"Festivita\n * nazionali\"). Never the raw key, and never an i18n key with no translation,\n * which vue-i18n would print as the key itself.\n */\nexport function toolLabel(name: string, { t, te }: LabelTranslator): string {\n if (te(`agent.tool.${name}`)) {\n return t(`agent.tool.${name}`)\n }\n const prefix = TOOL_KEY_PREFIXES.find((p) => name.startsWith(p))\n const bare = prefix ? name.slice(prefix.length) : name\n return capitalizeFirstLetter(fromAnyCase(bare).trim().toLowerCase())\n}\n\n/**\n * The kinds of message part a person can meet, each with its label. Written\n * as literal keys so the widget's library build, which keeps only the keys it\n * finds written out (apps/web-component/vite-plugins/chatLocales.ts), ships\n * them too.\n */\nconst PART_TYPE_LABELS: Record<string, (t: LabelTranslator['t']) => string> = {\n custom: (t) => t('messagePart.type.custom'),\n data: (t) => t('messagePart.type.data'),\n file: (t) => t('messagePart.type.file'),\n reasoning: (t) => t('messagePart.type.reasoning'),\n 'source-document': (t) => t('messagePart.type.sourceDocument'),\n 'source-url': (t) => t('messagePart.type.sourceUrl'),\n 'step-start': (t) => t('messagePart.type.stepStart'),\n text: (t) => t('messagePart.type.text'),\n}\n\n/**\n * The label of a message part in the message details: the tool for a tool\n * call, the translated kind otherwise (text, reasoning, provider data...),\n * and the kind in words for one the catalog does not know yet.\n */\nexport function getPartTypeLabel(\n part: UIMessage['parts'][number],\n translator: LabelTranslator,\n): string {\n if (isToolPart(part)) {\n return toolLabel(getToolPartName(part), translator)\n }\n if (part.type === 'dynamic-tool') {\n return toolLabel(part.toolName, translator)\n }\n const kind = part.type.startsWith('data-') ? 'data' : part.type\n const label = PART_TYPE_LABELS[kind]\n return label\n ? label(translator.t)\n : capitalizeFirstLetter(fromAnyCase(part.type))\n}\n\n/**\n * The commercial name of a provider the gateway routed a turn through, from\n * its slug (`anthropic`, `bedrock`): proper nouns, so no translation. A slug\n * not listed here shows with a capital, never as the bare id.\n */\nconst PROVIDER_NAMES: Record<string, string> = {\n alibaba: 'Alibaba Cloud',\n anthropic: 'Anthropic',\n azure: 'Microsoft Azure',\n baseten: 'Baseten',\n bedrock: 'Amazon Bedrock',\n cerebras: 'Cerebras',\n cohere: 'Cohere',\n deepinfra: 'DeepInfra',\n deepseek: 'DeepSeek',\n fireworks: 'Fireworks AI',\n google: 'Google',\n groq: 'Groq',\n mistral: 'Mistral AI',\n moonshotai: 'Moonshot AI',\n openai: 'OpenAI',\n perplexity: 'Perplexity',\n togetherai: 'Together AI',\n vertex: 'Google Vertex AI',\n xai: 'xAI',\n zai: 'Z.ai',\n}\n\n/** The name of a provider slug, see `PROVIDER_NAMES`. */\nexport function providerLabel(slug: string): string {\n return (\n PROVIDER_NAMES[slug.toLowerCase()] ??\n capitalizeFirstLetter(fromAnyCase(slug))\n )\n}\n\n/**\n * The conversation summary in the reader's language. The analysis asks the\n * model for four bold labels (`SUMMARY_FORMAT` in\n * apps/backend/src/prompts/analysis.prompt.ts) and the model copies them in\n * English whatever the conversation's language, so every stored summary\n * holds them: they are translated where a summary is read. An empty summary\n * comes back as it is, so a `??` fallback after it still works.\n */\nexport function localizeSummaryLabels<T extends string | null | undefined>(\n summary: T,\n t: (key: string) => string,\n): T {\n if (!summary) {\n return summary\n }\n const labels: Record<string, string> = {\n Intent: t('conversationSummary.intent'),\n 'Topics covered': t('conversationSummary.topicsCovered'),\n 'Key facts': t('conversationSummary.keyFacts'),\n 'Open questions': t('conversationSummary.openQuestions'),\n }\n return summary.replace(\n /\\*\\*(Intent|Topics covered|Key facts|Open questions)(:?)\\*\\*/g,\n (_, label: string, colon: string) => `**${labels[label]}${colon}**`,\n ) as T\n}\n\n// Get part label\nexport function getToolPartLabel(\n $t: (key: string) => string,\n part?: UIMessage['parts'][number] | null,\n /** The live titles of the page's steps, by call: they win when present. */\n hostStepTitles?: Record<string, string>,\n): string | undefined {\n const host = getHostCallPart(part)\n if (host) {\n const live = host.toolCallId\n ? hostStepTitles?.[host.toolCallId]\n : undefined\n if (live) {\n return live\n }\n const page = pageToolStep(host)\n return page ? $t(page.label) : host.title || host.toolName\n }\n if (isToolPart(part)) {\n if (part.type.includes('tool-subagent')) {\n return $t(`messagePart.runSubagent`)\n }\n if (part.type === 'tool-runWorker') {\n return $t(`messagePart.runWorker`)\n }\n if (part.type === 'tool-scheduleWakeup') {\n return $t(`messagePart.scheduleWakeup`)\n }\n if (part.type === 'tool-fetchTeamsChannelHistory') {\n return $t(`messagePart.fetchTeamsChannelHistory`)\n }\n if (part.type === 'tool-readEarlierMessages') {\n return $t(`messagePart.readEarlierMessages`)\n }\n if (part.type === 'tool-readChatAttachment') {\n return $t(`messagePart.readChatAttachment`)\n }\n if (part.type === 'tool-sendChatFile') {\n return $t(`messagePart.sendChatFile`)\n }\n if (part.type === 'tool-enableTools') {\n return $t(`messagePart.enableTools`)\n }\n if (part.type === 'tool-retrieveRevisedAnswers') {\n return $t(`messagePart.revisedAnswers`)\n }\n if (part.type === 'tool-searchInKnowledgeBase') {\n return $t(`messagePart.searchingDocuments`)\n }\n if (part.type === 'tool-expandChunkContext') {\n return $t(`messagePart.expandChunkContext`)\n }\n if (part.type === 'tool-readDocumentFile') {\n return $t(`messagePart.readDocumentFile`)\n }\n if (part.type === 'tool-readSpreadsheet') {\n return $t(`messagePart.readSpreadsheet`)\n }\n if (part.type === 'tool-editSpreadsheet') {\n return $t(`messagePart.editSpreadsheet`)\n }\n if (part.type === 'tool-shareDocument') {\n return $t(`messagePart.shareDocument`)\n }\n if (part.type === 'tool-readWordDocument') {\n return $t(`messagePart.readWordDocument`)\n }\n if (part.type === 'tool-editWordDocument') {\n return $t(`messagePart.editWordDocument`)\n }\n if (part.type === 'tool-createSpreadsheet') {\n return $t(`messagePart.createSpreadsheet`)\n }\n if (part.type === 'tool-createWordDocument') {\n return $t(`messagePart.createWordDocument`)\n }\n if (part.type === 'tool-querySpreadsheet') {\n return $t(`messagePart.querySpreadsheet`)\n }\n if (part.type === 'tool-geocode') {\n return $t(`messagePart.geocode`)\n }\n if (part.type === 'tool-getWeather') {\n return $t(`messagePart.getWeather`)\n }\n if (part.type === 'tool-recallUserMemory') {\n return $t(`messagePart.recallUserMemory`)\n }\n if (part.type === 'tool-saveUserMemory') {\n return $t(`messagePart.saveUserMemory`)\n }\n if (part.type === 'tool-showWeather') {\n return $t(`messagePart.showWeather`)\n }\n if (part.type === 'tool-showForm') {\n return $t(`messagePart.showForm`)\n }\n if (part.type === 'tool-showChart') {\n return $t(`messagePart.showChart`)\n }\n if (part.type === 'tool-showDiagram') {\n return $t(`messagePart.showDiagram`)\n }\n if (part.type === 'tool-showSources') {\n return $t(`messagePart.showSources`)\n }\n if (part.type === 'tool-showMultipleChoice') {\n return $t(`messagePart.showMultipleChoice`)\n }\n if (part.type === 'tool-showArtifact') {\n return $t(`messagePart.showArtifact`)\n }\n if (part.type === 'tool-showEmail') {\n return $t(`messagePart.showEmail`)\n }\n if (part.type === 'tool-showMessage') {\n return $t(`messagePart.showMessage`)\n }\n if (part.type === 'tool-showWebPages') {\n return $t(`messagePart.showWebPages`)\n }\n if (part.type === 'tool-showProducts') {\n return $t(`messagePart.showProducts`)\n }\n if (part.type === 'tool-showContactForm') {\n return $t(`messagePart.showContactForm`)\n }\n if (part.type === 'tool-showCalendarEvent') {\n return $t(`messagePart.showCalendarEvent`)\n }\n if (part.type === 'tool-showComparison') {\n return $t(`messagePart.showComparison`)\n }\n if (part.type === 'tool-showLocation') {\n return $t(`messagePart.showLocation`)\n }\n if (part.type === 'tool-showQrCode') {\n return $t(`messagePart.showQrCode`)\n }\n if (part.type === 'tool-showImageGallery') {\n return $t(`messagePart.showImageGallery`)\n }\n if (part.type === 'tool-showVideo') {\n return $t(`messagePart.showVideo`)\n }\n if (part.type === 'tool-showSuggestedReply') {\n return $t(`messagePart.showSuggestedReply`)\n }\n if (part.type === 'tool-requestGeolocation') {\n return $t(`messagePart.requestGeolocation`)\n }\n if (part.type === 'tool-disconnectOAuthConnection') {\n return $t(`messagePart.disconnectOAuthConnection`)\n }\n if (part.type === 'tool-requestAccountLink') {\n return $t(`messagePart.requestAccountLink`)\n }\n if (part.type === 'tool-unlinkAccount') {\n return $t(`messagePart.unlinkAccount`)\n }\n if (WEB_SEARCH_TOOL_TYPES.includes(part.type)) {\n return $t(`messagePart.webSearch`)\n }\n return $t(`messagePart.tool`)\n }\n if (isReasoningPart(part)) {\n return $t(`messagePart.reasoning`)\n }\n return $t(`messagePart.streaming`)\n}\n\n/** The version of a file stored in the chat that a preview opens. */\nexport type ChatFilePreviewTarget = {\n kind: 'word' | 'spreadsheet'\n storedFileName: string\n /** The name of the file, not of its version. */\n filename: string\n version?: number\n /** The file all its versions belong to, as the agent names it. */\n fileId?: string\n}\n\n/**\n * How the viewer draws a Word document's tracked changes: marked as Word\n * marks them, as if accepted, or as before them.\n */\nexport type WordPreviewMode = 'markup' | 'accepted' | 'original'\n\n/**\n * The fonts that stand in for Office's where the reader's system lacks them:\n * the metric-compatible ones of Linux and Chrome OS first, so the lines break\n * where Word breaks them, then the closest common ones.\n */\nconst WORD_FONT_STACKS: Record<string, string> = {\n calibri: 'Calibri, Carlito, \"Segoe UI\", Arial, sans-serif',\n 'calibri light':\n '\"Calibri Light\", Calibri, Carlito, \"Segoe UI\", sans-serif',\n aptos: 'Aptos, Calibri, Carlito, \"Segoe UI\", Arial, sans-serif',\n 'aptos display': '\"Aptos Display\", Aptos, Calibri, Carlito, sans-serif',\n cambria: 'Cambria, Caladea, Georgia, serif',\n 'times new roman':\n '\"Times New Roman\", Tinos, \"Liberation Serif\", Times, serif',\n arial: 'Arial, Arimo, \"Liberation Sans\", Helvetica, sans-serif',\n helvetica: 'Helvetica, Arial, Arimo, sans-serif',\n 'courier new': '\"Courier New\", Cousine, \"Liberation Mono\", monospace',\n garamond: 'Garamond, \"EB Garamond\", Georgia, serif',\n georgia: 'Georgia, serif',\n verdana: 'Verdana, \"DejaVu Sans\", sans-serif',\n tahoma: 'Tahoma, Verdana, sans-serif',\n}\n\n/**\n * Word's single line as a multiple of the font size, from the font's ascent,\n * descent and line gap: the lines keep the height of the document's font\n * where another font stands in for it.\n */\nconst WORD_LINE_FACTORS: Record<string, number> = {\n calibri: 1.22,\n 'calibri light': 1.22,\n cambria: 1.17,\n 'times new roman': 1.15,\n arial: 1.15,\n helvetica: 1.15,\n 'courier new': 1.13,\n georgia: 1.14,\n verdana: 1.22,\n tahoma: 1.21,\n}\n\n/** Word's single line for a font a Word document names. */\nexport const wordLineFactor = (font: string): number =>\n WORD_LINE_FACTORS[font.toLowerCase()] ?? 1.17\n\n/** The CSS font stack for a font a Word document names. */\nexport const wordFontStack = (font: string): string =>\n WORD_FONT_STACKS[font.toLowerCase()] ??\n `\"${font.replace(/\"/g, '')}\", ${\n /roman|garamond|cambria|georgia|serif|book|times/i.test(font)\n ? 'Georgia, serif'\n : 'Calibri, Carlito, \"Segoe UI\", Arial, sans-serif'\n }`\n\n/**\n * The images of the Word document in the viewer, by reference, which its\n * runs draw (`PkWordPreview` provides them).\n */\nexport const WORD_PREVIEW_IMAGES: InjectionKey<\n Ref<Record<string, string> | undefined>\n> = Symbol('wordPreviewImages')\n\n/**\n * The image a run draws, only a WebP the server wrote: anything else in the\n * map is not drawn.\n */\nexport const wordPictureSrc = (\n images: Record<string, string> | undefined,\n ref: string,\n): string | undefined => {\n const src = images?.[ref]\n return src?.startsWith('data:image/webp;base64,') ? src : undefined\n}\n\n/** The numbers the page number fields of a page show. */\nexport type WordPageNumbers = {\n page: number\n pages: number\n sectionPages: number\n}\n\n/**\n * Where an image Word positions on the page sits on it: from the page's top\n * left corner, in points, under the text or over it.\n */\nexport const wordPageAnchorCss = (\n picture: WordPreviewPicture,\n page: WordPreviewPage,\n): CSSProperties => {\n const anchor = picture.anchor!\n return {\n left: `${anchor.xFrom === 'page' ? anchor.x : page.margins.left + anchor.x}pt`,\n top: `${anchor.yFrom === 'page' ? anchor.y : page.margins.top + anchor.y}pt`,\n width: `${picture.width}pt`,\n height: `${picture.height}pt`,\n zIndex: anchor.wrap === 'behind' ? -1 : 1,\n }\n}\n\n/**\n * How an image of a run is placed: in the text, beside the text of its\n * paragraph, on a line of its own, from its paragraph, or on the page,\n * which the page draws.\n */\nexport const wordPicturePlacement = (\n picture: WordPreviewPicture,\n): 'inline' | 'around' | 'block' | 'paragraph' | 'page' => {\n const anchor = picture.anchor\n return !anchor\n ? 'inline'\n : anchor.wrap === 'around'\n ? 'around'\n : anchor.wrap === 'block'\n ? 'block'\n : anchor.yFrom === 'paragraph'\n ? 'paragraph'\n : 'page'\n}\n\n/** The runs a mode keeps: a deletion is gone once accepted. */\nexport const wordKeptRuns = (\n runs: WordPreviewRun[],\n mode: WordPreviewMode,\n): WordPreviewRun[] =>\n runs.filter((r) =>\n mode === 'accepted'\n ? r.change !== 'deleted'\n : mode === 'original'\n ? r.change !== 'inserted'\n : true,\n )\n\nconst hasWordText = (runs: WordPreviewRun[]) =>\n runs.some((r) => r.image || r.text.trim())\n\n/** A piece of a Word document's flow: a paragraph or a table row. */\nexport type WordFlowItem = {\n key: string\n block: number\n row?: number\n breakBefore: boolean\n /** The section it opens. */\n section?: number\n /** Stays on the page of the next piece (Word's \"Keep with next\"). */\n keepNext?: true\n}\n\n/**\n * The pieces of `blocks` in order, as the pages hold them. A paragraph or a\n * table row a mode empties is gone (a row inserted, as the original); one\n * empty in the document stays, a blank line as in Word. A section a gone\n * piece opened, with its page break, passes to the next one.\n */\nexport const wordFlowItems = (\n blocks: WordPreviewBlock[],\n mode: WordPreviewMode,\n): WordFlowItem[] => {\n const out: WordFlowItem[] = []\n let breakPending = false\n let sectionPending: number | undefined\n const push = (\n key: string,\n block: number,\n row: number | undefined,\n breakBefore: boolean,\n section: number | undefined,\n keepNext: boolean,\n ) => {\n const opens = section ?? sectionPending\n out.push({\n key,\n block,\n ...(row !== undefined ? { row } : {}),\n breakBefore: breakBefore || breakPending,\n ...(opens !== undefined ? { section: opens } : {}),\n ...(keepNext ? { keepNext: true as const } : {}),\n })\n breakPending = false\n sectionPending = undefined\n }\n // A gone piece's own page break goes with it; a section's start stays\n const skip = (breakBefore: boolean, section: number | undefined) => {\n breakPending ||= breakBefore && section !== undefined\n sectionPending = section ?? sectionPending\n }\n blocks.forEach((block, b) => {\n if (block.kind === 'table') {\n // The table's break and section go with its first row shown\n let breaks = !!block.pageBreakBefore\n let opens = block.section\n block.rows.forEach((cells, r) => {\n const filled = cells.some((cell) => cell.runs.length)\n if (\n filled &&\n !cells.some((cell) =>\n hasWordText(wordKeptRuns(cell.runs, mode)),\n )\n ) {\n return\n }\n push(\n `${b}:${r}`,\n b,\n r,\n breaks,\n opens,\n cells.some((cell) => cell.keepNext),\n )\n breaks = false\n opens = undefined\n })\n skip(breaks, opens)\n } else if (\n !block.runs.length ||\n hasWordText(wordKeptRuns(block.runs, mode))\n ) {\n push(\n `${b}`,\n b,\n undefined,\n !!block.style?.pageBreakBefore,\n block.section,\n !!block.style?.keepNext,\n )\n } else {\n skip(!!block.style?.pageBreakBefore, block.section)\n }\n })\n return out\n}\n\n/** The images Word positions on the page among the paragraphs of `blocks`. */\nexport const wordPageAnchors = (\n blocks: WordPreviewBlock[],\n mode: WordPreviewMode,\n): WordPreviewPicture[] =>\n blocks.flatMap((block) =>\n block.kind === 'table'\n ? []\n : wordKeptRuns(block.runs, mode).flatMap((run) =>\n run.picture && wordPicturePlacement(run.picture) === 'page'\n ? [run.picture]\n : [],\n ),\n )\n\n/** An earlier version of a file of the chat, for the agent to restore. */\nexport type ChatFileRestoreTarget = {\n /** The id the agent names the file with: the stored name of version 1. */\n fileId: string\n version: number\n filename: string\n}\n\n/**\n * The name of a file, not of its version: `listino (v2).xlsx` is version 2\n * of `listino.xlsx`.\n */\nexport const chatFileName = (filename: string, version?: number): string =>\n version\n ? filename.replace(new RegExp(` \\\\(v${version}\\\\)(\\\\.\\\\w+)$`), '$1')\n : filename\n\nconst EDITABLE_IMAGE_TYPES = new Set(['image/jpeg', 'image/png', 'image/webp'])\n\n/**\n * Whether the image editor (spec `chat-image-editor.md`) opens on a file of\n * this type: one a canvas reads and writes back as the same type, so not a\n * GIF, an SVG or a HEIC. Here and not in `imageEdits.ts`, which the\n * composer would otherwise pull into the main bundle of the widget.\n */\nexport function isEditableImage(mediaType: string): boolean {\n return EDITABLE_IMAGE_TYPES.has(mediaType)\n}\n\n/**\n * An input method (Japanese, Chinese, Korean) is composing a word: its\n * Enter and Esc confirm or drop the word. Safari reports the Enter that\n * confirms it with `isComposing` already false, hence the 229.\n */\nexport function isImeComposing(event: KeyboardEvent): boolean {\n return event.isComposing || event.keyCode === 229\n}\n\n/**\n * Whether a chat stands in front of the place of the bar that shows the\n * agent acting on the page (`PkPageControlBar`): the top centre of the\n * window, from the bar's `top` of 48px to about its 44px of height below.\n * There the bar would only cover the chat's header, and the chat shows the\n * steps and their stop itself.\n */\nexport function chatCoversPageControlBar(\n chat: Pick<DOMRect, 'left' | 'right' | 'top' | 'bottom'>,\n windowWidth: number,\n): boolean {\n const center = windowWidth / 2\n return (\n chat.left <= center &&\n chat.right >= center &&\n chat.top <= 92 &&\n chat.bottom >= 48\n )\n}\n\n/** Where a selection bar goes, in the coordinates of its `bounds`. */\nexport type SelectionBarPosition = {\n top: number\n left: number\n placement: 'above' | 'below'\n}\n\n/**\n * Where the bar of a selection goes (spec `selection-actions.md`, \"Dove\"):\n * above the start of the selection, where it covers what was already read,\n * and below it only without room above; always below on a touch screen, away\n * from the menu the system opens above a selection. `start` is the box of the\n * selection's first line, `bottom` its lowest edge, `bounds` the box the bar\n * stays in, all in one coordinate space, the result's too.\n */\nexport function selectionBarPosition({\n start,\n bottom,\n bar,\n bounds,\n touch = false,\n gap = 8,\n margin = 8,\n}: {\n start: Pick<DOMRect, 'top' | 'left'>\n bottom: number\n bar: { width: number; height: number }\n bounds: Pick<DOMRect, 'top' | 'left' | 'width' | 'height'>\n touch?: boolean\n gap?: number\n margin?: number\n}): SelectionBarPosition {\n const above = start.top - gap - bar.height\n const placement = !touch && above >= bounds.top + margin ? 'above' : 'below'\n const top =\n placement === 'above'\n ? above\n : Math.max(\n bounds.top + margin,\n Math.min(\n bottom + gap,\n bounds.top + bounds.height - margin - bar.height,\n ),\n )\n const left = Math.max(\n bounds.left + margin,\n Math.min(start.left, bounds.left + bounds.width - margin - bar.width),\n )\n return { top, left, placement }\n}\n"],"mappings":";;;;;AAAA,IAAaU,KAAiB,MAC1BC,EAAI,UAAU,KAAK,CAAC,CAAC,QAAQ,oBAAoB,EAAE,GAkB1CC,KAAe,MACnBD,IAGEA,EACF,QAAQ,sBAAsB,OAAO,CAAC,CACtC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,UAAU,GAAG,IALf,IAiBFE,KAAiC,MACrCF,IAGED,EAAcC,CAAG,CAAC,CACpB,QAAQ,sBAAsB,OAAO,CAAC,CACtC,QAAQ,kBAAkB,GAAG,CAAC,CAC9B,YAAY,IALN,IAeFG,MAAiC,MACrCH,IAGED,EAAcC,CAAG,CAAC,CACpB,QAAQ,sBAAsB,OAAO,CAAC,CACtC,QAAQ,kBAAkB,GAAG,CAAC,CAC9B,YAAY,IALN,IAQFI,KA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J;EAKI,MAJD,KAAK,IACdG,EAAO,OAAOC,GACd,KAAK,IAAIN,EAAM,MAAMK,EAAO,OAAOA,EAAO,QAAQC,IAASJ,EAAI,KAAK,CAE1D;EAAM;CAAU;AAClC"}
package/dist-vue/api.js CHANGED
@@ -1 +1 @@
1
- export { t as createChatbotApiClient } from "./_chunks/createChatbotApiClient-CGeNprai.js";
1
+ export { t as createChatbotApiClient } from "./_chunks/createChatbotApiClient-DmPcjwB3.js";
@@ -163,6 +163,7 @@ export declare function useChatbotAgent(options: {
163
163
  id: string;
164
164
  label: Record<string, string>;
165
165
  prompt: Record<string, string>;
166
+ icon?: "map" | "filter" | "card" | "check" | "text" | "key" | "sparkles" | "magic" | "idea" | "star" | "heart" | "lightning" | "fire" | "rocket" | "pen" | "pencil" | "paragraph" | "quote" | "list" | "checklist" | "highlighter" | "document" | "folder" | "book" | "bookmark" | "clipboard" | "draft" | "contract" | "attachment" | "archive" | "search" | "eye" | "questions" | "pie-chart" | "line-chart" | "table" | "database" | "calculator" | "percent" | "scales" | "euro" | "dollar" | "wallet" | "bank" | "cart" | "price-tag" | "bill" | "gift" | "shop" | "truck" | "shield" | "lock" | "gavel" | "institution" | "passport" | "person" | "team" | "group" | "smile" | "handshake" | "support" | "contacts" | "mail" | "send" | "speech" | "phone" | "megaphone" | "bell" | "share" | "link" | "globe" | "calendar" | "event" | "clock" | "timer" | "history" | "hourglass" | "plane" | "car" | "train" | "ship" | "pin" | "compass" | "bed" | "suitcase" | "home" | "building" | "flag" | "earth" | "sun" | "umbrella" | "heartbeat" | "capsule" | "first-aid" | "restaurant" | "cup" | "leaf" | "plant" | "recycle" | "school" | "graduation" | "brain" | "puzzle" | "award" | "trophy" | "settings" | "tools" | "code" | "bug" | "robot" | "cloud" | "flask" | "microscope" | "cross" | "warning" | "information" | "refresh" | "swap" | "arrow" | "thumbs-up" | "target" | "palette" | "image" | "music" | "video" | "microphone" | undefined;
166
167
  }[];
167
168
  } | undefined;
168
169
  word?: {
@@ -171,6 +172,7 @@ export declare function useChatbotAgent(options: {
171
172
  id: string;
172
173
  label: Record<string, string>;
173
174
  prompt: Record<string, string>;
175
+ icon?: "map" | "filter" | "card" | "check" | "text" | "key" | "sparkles" | "magic" | "idea" | "star" | "heart" | "lightning" | "fire" | "rocket" | "pen" | "pencil" | "paragraph" | "quote" | "list" | "checklist" | "highlighter" | "document" | "folder" | "book" | "bookmark" | "clipboard" | "draft" | "contract" | "attachment" | "archive" | "search" | "eye" | "questions" | "pie-chart" | "line-chart" | "table" | "database" | "calculator" | "percent" | "scales" | "euro" | "dollar" | "wallet" | "bank" | "cart" | "price-tag" | "bill" | "gift" | "shop" | "truck" | "shield" | "lock" | "gavel" | "institution" | "passport" | "person" | "team" | "group" | "smile" | "handshake" | "support" | "contacts" | "mail" | "send" | "speech" | "phone" | "megaphone" | "bell" | "share" | "link" | "globe" | "calendar" | "event" | "clock" | "timer" | "history" | "hourglass" | "plane" | "car" | "train" | "ship" | "pin" | "compass" | "bed" | "suitcase" | "home" | "building" | "flag" | "earth" | "sun" | "umbrella" | "heartbeat" | "capsule" | "first-aid" | "restaurant" | "cup" | "leaf" | "plant" | "recycle" | "school" | "graduation" | "brain" | "puzzle" | "award" | "trophy" | "settings" | "tools" | "code" | "bug" | "robot" | "cloud" | "flask" | "microscope" | "cross" | "warning" | "information" | "refresh" | "swap" | "arrow" | "thumbs-up" | "target" | "palette" | "image" | "music" | "video" | "microphone" | undefined;
174
176
  }[];
175
177
  } | undefined;
176
178
  excel?: {
@@ -179,6 +181,7 @@ export declare function useChatbotAgent(options: {
179
181
  id: string;
180
182
  label: Record<string, string>;
181
183
  prompt: Record<string, string>;
184
+ icon?: "map" | "filter" | "card" | "check" | "text" | "key" | "sparkles" | "magic" | "idea" | "star" | "heart" | "lightning" | "fire" | "rocket" | "pen" | "pencil" | "paragraph" | "quote" | "list" | "checklist" | "highlighter" | "document" | "folder" | "book" | "bookmark" | "clipboard" | "draft" | "contract" | "attachment" | "archive" | "search" | "eye" | "questions" | "pie-chart" | "line-chart" | "table" | "database" | "calculator" | "percent" | "scales" | "euro" | "dollar" | "wallet" | "bank" | "cart" | "price-tag" | "bill" | "gift" | "shop" | "truck" | "shield" | "lock" | "gavel" | "institution" | "passport" | "person" | "team" | "group" | "smile" | "handshake" | "support" | "contacts" | "mail" | "send" | "speech" | "phone" | "megaphone" | "bell" | "share" | "link" | "globe" | "calendar" | "event" | "clock" | "timer" | "history" | "hourglass" | "plane" | "car" | "train" | "ship" | "pin" | "compass" | "bed" | "suitcase" | "home" | "building" | "flag" | "earth" | "sun" | "umbrella" | "heartbeat" | "capsule" | "first-aid" | "restaurant" | "cup" | "leaf" | "plant" | "recycle" | "school" | "graduation" | "brain" | "puzzle" | "award" | "trophy" | "settings" | "tools" | "code" | "bug" | "robot" | "cloud" | "flask" | "microscope" | "cross" | "warning" | "information" | "refresh" | "swap" | "arrow" | "thumbs-up" | "target" | "palette" | "image" | "music" | "video" | "microphone" | undefined;
182
185
  }[];
183
186
  } | undefined;
184
187
  } | undefined;
@@ -332,6 +335,7 @@ export declare function useChatbotAgent(options: {
332
335
  id: string;
333
336
  label: Record<string, string>;
334
337
  prompt: Record<string, string>;
338
+ icon?: "map" | "filter" | "card" | "check" | "text" | "key" | "sparkles" | "magic" | "idea" | "star" | "heart" | "lightning" | "fire" | "rocket" | "pen" | "pencil" | "paragraph" | "quote" | "list" | "checklist" | "highlighter" | "document" | "folder" | "book" | "bookmark" | "clipboard" | "draft" | "contract" | "attachment" | "archive" | "search" | "eye" | "questions" | "pie-chart" | "line-chart" | "table" | "database" | "calculator" | "percent" | "scales" | "euro" | "dollar" | "wallet" | "bank" | "cart" | "price-tag" | "bill" | "gift" | "shop" | "truck" | "shield" | "lock" | "gavel" | "institution" | "passport" | "person" | "team" | "group" | "smile" | "handshake" | "support" | "contacts" | "mail" | "send" | "speech" | "phone" | "megaphone" | "bell" | "share" | "link" | "globe" | "calendar" | "event" | "clock" | "timer" | "history" | "hourglass" | "plane" | "car" | "train" | "ship" | "pin" | "compass" | "bed" | "suitcase" | "home" | "building" | "flag" | "earth" | "sun" | "umbrella" | "heartbeat" | "capsule" | "first-aid" | "restaurant" | "cup" | "leaf" | "plant" | "recycle" | "school" | "graduation" | "brain" | "puzzle" | "award" | "trophy" | "settings" | "tools" | "code" | "bug" | "robot" | "cloud" | "flask" | "microscope" | "cross" | "warning" | "information" | "refresh" | "swap" | "arrow" | "thumbs-up" | "target" | "palette" | "image" | "music" | "video" | "microphone" | undefined;
335
339
  }[];
336
340
  } | undefined;
337
341
  word?: {
@@ -340,6 +344,7 @@ export declare function useChatbotAgent(options: {
340
344
  id: string;
341
345
  label: Record<string, string>;
342
346
  prompt: Record<string, string>;
347
+ icon?: "map" | "filter" | "card" | "check" | "text" | "key" | "sparkles" | "magic" | "idea" | "star" | "heart" | "lightning" | "fire" | "rocket" | "pen" | "pencil" | "paragraph" | "quote" | "list" | "checklist" | "highlighter" | "document" | "folder" | "book" | "bookmark" | "clipboard" | "draft" | "contract" | "attachment" | "archive" | "search" | "eye" | "questions" | "pie-chart" | "line-chart" | "table" | "database" | "calculator" | "percent" | "scales" | "euro" | "dollar" | "wallet" | "bank" | "cart" | "price-tag" | "bill" | "gift" | "shop" | "truck" | "shield" | "lock" | "gavel" | "institution" | "passport" | "person" | "team" | "group" | "smile" | "handshake" | "support" | "contacts" | "mail" | "send" | "speech" | "phone" | "megaphone" | "bell" | "share" | "link" | "globe" | "calendar" | "event" | "clock" | "timer" | "history" | "hourglass" | "plane" | "car" | "train" | "ship" | "pin" | "compass" | "bed" | "suitcase" | "home" | "building" | "flag" | "earth" | "sun" | "umbrella" | "heartbeat" | "capsule" | "first-aid" | "restaurant" | "cup" | "leaf" | "plant" | "recycle" | "school" | "graduation" | "brain" | "puzzle" | "award" | "trophy" | "settings" | "tools" | "code" | "bug" | "robot" | "cloud" | "flask" | "microscope" | "cross" | "warning" | "information" | "refresh" | "swap" | "arrow" | "thumbs-up" | "target" | "palette" | "image" | "music" | "video" | "microphone" | undefined;
343
348
  }[];
344
349
  } | undefined;
345
350
  excel?: {
@@ -348,6 +353,7 @@ export declare function useChatbotAgent(options: {
348
353
  id: string;
349
354
  label: Record<string, string>;
350
355
  prompt: Record<string, string>;
356
+ icon?: "map" | "filter" | "card" | "check" | "text" | "key" | "sparkles" | "magic" | "idea" | "star" | "heart" | "lightning" | "fire" | "rocket" | "pen" | "pencil" | "paragraph" | "quote" | "list" | "checklist" | "highlighter" | "document" | "folder" | "book" | "bookmark" | "clipboard" | "draft" | "contract" | "attachment" | "archive" | "search" | "eye" | "questions" | "pie-chart" | "line-chart" | "table" | "database" | "calculator" | "percent" | "scales" | "euro" | "dollar" | "wallet" | "bank" | "cart" | "price-tag" | "bill" | "gift" | "shop" | "truck" | "shield" | "lock" | "gavel" | "institution" | "passport" | "person" | "team" | "group" | "smile" | "handshake" | "support" | "contacts" | "mail" | "send" | "speech" | "phone" | "megaphone" | "bell" | "share" | "link" | "globe" | "calendar" | "event" | "clock" | "timer" | "history" | "hourglass" | "plane" | "car" | "train" | "ship" | "pin" | "compass" | "bed" | "suitcase" | "home" | "building" | "flag" | "earth" | "sun" | "umbrella" | "heartbeat" | "capsule" | "first-aid" | "restaurant" | "cup" | "leaf" | "plant" | "recycle" | "school" | "graduation" | "brain" | "puzzle" | "award" | "trophy" | "settings" | "tools" | "code" | "bug" | "robot" | "cloud" | "flask" | "microscope" | "cross" | "warning" | "information" | "refresh" | "swap" | "arrow" | "thumbs-up" | "target" | "palette" | "image" | "music" | "video" | "microphone" | undefined;
351
357
  }[];
352
358
  } | undefined;
353
359
  } | undefined;