@8wave/ai-elements 0.126.0-beta.45 → 0.126.0-beta.46

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 (130) hide show
  1. package/dist/_chunks/{PkChatbotFilePreview-CLUH7cTq.js → PkChatbotFilePreview-5mhg2XeB.js} +2 -2
  2. package/dist/_chunks/{PkChatbotFilePreview-CLUH7cTq.js.map → PkChatbotFilePreview-5mhg2XeB.js.map} +1 -1
  3. package/dist/_chunks/{PkFilePreview-BrWWeK4E.js → PkFilePreview-BdthRUlY.js} +3 -3
  4. package/dist/_chunks/{PkFilePreview-BrWWeK4E.js.map → PkFilePreview-BdthRUlY.js.map} +1 -1
  5. package/dist/_chunks/{PkFilePreviewDialog-BRZH_LxY.js → PkFilePreviewDialog-DyQtn85H.js} +2 -2
  6. package/dist/_chunks/{PkFilePreviewDialog-BRZH_LxY.js.map → PkFilePreviewDialog-DyQtn85H.js.map} +1 -1
  7. package/dist/_chunks/{PkImageEditorDialog-D21ggZkD.js → PkImageEditorDialog-DzA_qGj9.js} +2 -2
  8. package/dist/_chunks/{PkImageEditorDialog-D21ggZkD.js.map → PkImageEditorDialog-DzA_qGj9.js.map} +1 -1
  9. package/dist/_chunks/{PkSelectionActions-BLfFobXb.js → PkSelectionActions-BeREUy3h.js} +2 -2
  10. package/dist/_chunks/{PkSelectionActions-BLfFobXb.js.map → PkSelectionActions-BeREUy3h.js.map} +1 -1
  11. package/dist/_chunks/{PkStreamingMarkdown-Bekhx_vG.js → PkStreamingMarkdown-DLyBjSaH.js} +3 -3
  12. package/dist/_chunks/{PkStreamingMarkdown-Bekhx_vG.js.map → PkStreamingMarkdown-DLyBjSaH.js.map} +1 -1
  13. package/dist/_chunks/{PkToolChatFile-BzN4fMaY.js → PkToolChatFile-Ck1uJvaj.js} +3 -3
  14. package/dist/_chunks/{PkToolChatFile-BzN4fMaY.js.map → PkToolChatFile-Ck1uJvaj.js.map} +1 -1
  15. package/dist/_chunks/{PkToolRequestGeolocation-Dj5OxEMP.js → PkToolRequestGeolocation-ZYzgy6kw.js} +2 -2
  16. package/dist/_chunks/{PkToolRequestGeolocation-Dj5OxEMP.js.map → PkToolRequestGeolocation-ZYzgy6kw.js.map} +1 -1
  17. package/dist/_chunks/{PkToolShareDocument-CYBU4LPO.js → PkToolShareDocument-COy3yKqq.js} +2 -2
  18. package/dist/_chunks/{PkToolShareDocument-CYBU4LPO.js.map → PkToolShareDocument-COy3yKqq.js.map} +1 -1
  19. package/dist/_chunks/{PkToolShowArtifact-BkGtejtb.js → PkToolShowArtifact-CePvZJJ9.js} +3 -3
  20. package/dist/_chunks/{PkToolShowArtifact-BkGtejtb.js.map → PkToolShowArtifact-CePvZJJ9.js.map} +1 -1
  21. package/dist/_chunks/{PkToolShowChart-BalU3bxm.js → PkToolShowChart-hUdEF7JC.js} +4 -4
  22. package/dist/_chunks/PkToolShowChart-hUdEF7JC.js.map +1 -0
  23. package/dist/_chunks/{PkToolShowComparison-DeO7cMeF.js → PkToolShowComparison-1odeymnp.js} +2 -2
  24. package/dist/_chunks/PkToolShowComparison-1odeymnp.js.map +1 -0
  25. package/dist/_chunks/{PkToolShowContactForm-BXsvfCKR.js → PkToolShowContactForm-B9u6KgjQ.js} +2 -2
  26. package/dist/_chunks/{PkToolShowContactForm-BXsvfCKR.js.map → PkToolShowContactForm-B9u6KgjQ.js.map} +1 -1
  27. package/dist/_chunks/{PkToolShowDiagram-j3TTzZ5I.js → PkToolShowDiagram-Bc0Ov5Dq.js} +3 -3
  28. package/dist/_chunks/{PkToolShowDiagram-j3TTzZ5I.js.map → PkToolShowDiagram-Bc0Ov5Dq.js.map} +1 -1
  29. package/dist/_chunks/{PkToolShowForm-DeG_AzO9.js → PkToolShowForm-B5A-Zj9m.js} +3 -3
  30. package/dist/_chunks/{PkToolShowForm-DeG_AzO9.js.map → PkToolShowForm-B5A-Zj9m.js.map} +1 -1
  31. package/dist/_chunks/{PkToolShowImageGallery-Dri9KUNg.js → PkToolShowImageGallery-DOb626aG.js} +4 -4
  32. package/dist/_chunks/{PkToolShowImageGallery-Dri9KUNg.js.map → PkToolShowImageGallery-DOb626aG.js.map} +1 -1
  33. package/dist/_chunks/{PkToolShowSources-D5gh7FtU.js → PkToolShowSources-DceDrdbn.js} +3 -3
  34. package/dist/_chunks/PkToolShowSources-DceDrdbn.js.map +1 -0
  35. package/dist/_chunks/{useLightbox-Co8iz61W.js → useLightbox-C6u2eYRL.js} +7 -1
  36. package/dist/_chunks/{useLightbox-Co8iz61W.js.map → useLightbox-C6u2eYRL.js.map} +1 -1
  37. package/dist/_chunks/{utils-C1JaUBI_.js → utils-CEzr10hz.js} +4 -2
  38. package/dist/_chunks/utils-CEzr10hz.js.map +1 -0
  39. package/dist/ai-elements.es.js +45 -22
  40. package/dist/ai-elements.es.js.map +1 -1
  41. package/dist-vue/PkChatbot.js +1 -1
  42. package/dist-vue/PkChatbotEmptyState.js +1 -1
  43. package/dist-vue/PkChatbotFilePreview.js +1 -1
  44. package/dist-vue/PkChatbotInput.js +1 -1
  45. package/dist-vue/PkChatbotMessages.js +1 -1
  46. package/dist-vue/PkChatbotStepPayload.js +1 -1
  47. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  48. package/dist-vue/PkChatbotSteps.js +1 -1
  49. package/dist-vue/PkChatbotViewChat.js +1 -1
  50. package/dist-vue/PkChatbotViewConversations.js +1 -1
  51. package/dist-vue/_chunks/{PkChatbot-DFPnmNO3.js → PkChatbot-BUHFAQYp.js} +5 -5
  52. package/dist-vue/_chunks/{PkChatbot-DFPnmNO3.js.map → PkChatbot-BUHFAQYp.js.map} +1 -1
  53. package/dist-vue/_chunks/{PkChatbotEmptyState-oIgcrKtR.js → PkChatbotEmptyState-CdE2z9C2.js} +2 -2
  54. package/dist-vue/_chunks/{PkChatbotEmptyState-oIgcrKtR.js.map → PkChatbotEmptyState-CdE2z9C2.js.map} +1 -1
  55. package/dist-vue/_chunks/{PkChatbotFilePreview-aKJBtw04.js → PkChatbotFilePreview-BbytSmUB.js} +2 -2
  56. package/dist-vue/_chunks/{PkChatbotFilePreview-aKJBtw04.js.map → PkChatbotFilePreview-BbytSmUB.js.map} +1 -1
  57. package/dist-vue/_chunks/{PkChatbotInput-CunAf5Rq.js → PkChatbotInput-D6khxAJ8.js} +5 -5
  58. package/dist-vue/_chunks/{PkChatbotInput-CunAf5Rq.js.map → PkChatbotInput-D6khxAJ8.js.map} +1 -1
  59. package/dist-vue/_chunks/{PkChatbotMessages-CNOkmuR-.js → PkChatbotMessages-DqoPly0A.js} +20 -20
  60. package/dist-vue/_chunks/{PkChatbotMessages-CNOkmuR-.js.map → PkChatbotMessages-DqoPly0A.js.map} +1 -1
  61. package/dist-vue/_chunks/{PkChatbotStepPayload-BQDpTDgn.js → PkChatbotStepPayload-Ksj_Mp7n.js} +2 -2
  62. package/dist-vue/_chunks/{PkChatbotStepPayload-BQDpTDgn.js.map → PkChatbotStepPayload-Ksj_Mp7n.js.map} +1 -1
  63. package/dist-vue/_chunks/{PkChatbotStepToolDetail-BAmdMTgw.js → PkChatbotStepToolDetail-BqAF4YZl.js} +3 -3
  64. package/dist-vue/_chunks/{PkChatbotStepToolDetail-BAmdMTgw.js.map → PkChatbotStepToolDetail-BqAF4YZl.js.map} +1 -1
  65. package/dist-vue/_chunks/{PkChatbotSteps-QrpF-xj9.js → PkChatbotSteps-C6GAEPfL.js} +5 -5
  66. package/dist-vue/_chunks/{PkChatbotSteps-QrpF-xj9.js.map → PkChatbotSteps-C6GAEPfL.js.map} +1 -1
  67. package/dist-vue/_chunks/{PkChatbotViewChat-DfZznZyZ.js → PkChatbotViewChat-DE0qVYZ-.js} +13 -8
  68. package/dist-vue/_chunks/PkChatbotViewChat-DE0qVYZ-.js.map +1 -0
  69. package/dist-vue/_chunks/{PkChatbotViewConversations-BrgBXjpa.js → PkChatbotViewConversations-HNJPIMeQ.js} +2 -2
  70. package/dist-vue/_chunks/{PkChatbotViewConversations-BrgBXjpa.js.map → PkChatbotViewConversations-HNJPIMeQ.js.map} +1 -1
  71. package/dist-vue/_chunks/{PkFilePreview-Ba1DOTF4.js → PkFilePreview-CGCMa6NV.js} +4 -4
  72. package/dist-vue/_chunks/{PkFilePreview-Ba1DOTF4.js.map → PkFilePreview-CGCMa6NV.js.map} +1 -1
  73. package/dist-vue/_chunks/{PkFilePreviewDialog-Br5tyyL8.js → PkFilePreviewDialog-DRkXUy1_.js} +2 -2
  74. package/dist-vue/_chunks/{PkFilePreviewDialog-Br5tyyL8.js.map → PkFilePreviewDialog-DRkXUy1_.js.map} +1 -1
  75. package/dist-vue/_chunks/{PkImageEditorDialog-B-jW5yE8.js → PkImageEditorDialog-M0xhsEUs.js} +2 -2
  76. package/dist-vue/_chunks/{PkImageEditorDialog-B-jW5yE8.js.map → PkImageEditorDialog-M0xhsEUs.js.map} +1 -1
  77. package/dist-vue/_chunks/{PkStreamingMarkdown-WIueQOg3.js → PkStreamingMarkdown-48T0DPih.js} +3 -3
  78. package/dist-vue/_chunks/{PkStreamingMarkdown-WIueQOg3.js.map → PkStreamingMarkdown-48T0DPih.js.map} +1 -1
  79. package/dist-vue/_chunks/{PkSvgViewer-PAr87kCa.js → PkSvgViewer-BBRyAFWm.js} +2 -2
  80. package/dist-vue/_chunks/{PkSvgViewer-PAr87kCa.js.map → PkSvgViewer-BBRyAFWm.js.map} +1 -1
  81. package/dist-vue/_chunks/{PkToolChatFile-W6OJP7HH.js → PkToolChatFile-qKYe0XRX.js} +3 -3
  82. package/dist-vue/_chunks/{PkToolChatFile-W6OJP7HH.js.map → PkToolChatFile-qKYe0XRX.js.map} +1 -1
  83. package/dist-vue/_chunks/{PkToolRequestGeolocation-BPZfJfR1.js → PkToolRequestGeolocation-BuknnxuZ.js} +2 -2
  84. package/dist-vue/_chunks/{PkToolRequestGeolocation-BPZfJfR1.js.map → PkToolRequestGeolocation-BuknnxuZ.js.map} +1 -1
  85. package/dist-vue/_chunks/{PkToolShareDocument-Bkt9JVqk.js → PkToolShareDocument-CVDYH1kA.js} +2 -2
  86. package/dist-vue/_chunks/{PkToolShareDocument-Bkt9JVqk.js.map → PkToolShareDocument-CVDYH1kA.js.map} +1 -1
  87. package/dist-vue/_chunks/{PkToolShowArtifact-CPBFsUrY.js → PkToolShowArtifact-D51SQ08X.js} +3 -3
  88. package/dist-vue/_chunks/{PkToolShowArtifact-CPBFsUrY.js.map → PkToolShowArtifact-D51SQ08X.js.map} +1 -1
  89. package/dist-vue/_chunks/{PkToolShowChart-BaUS47YU.js → PkToolShowChart-Cf3Hi-Pb.js} +5 -5
  90. package/dist-vue/_chunks/PkToolShowChart-Cf3Hi-Pb.js.map +1 -0
  91. package/dist-vue/_chunks/{PkToolShowComparison-BEHyRNXE.js → PkToolShowComparison-pLrUTlK6.js} +2 -2
  92. package/dist-vue/_chunks/PkToolShowComparison-pLrUTlK6.js.map +1 -0
  93. package/dist-vue/_chunks/{PkToolShowContactForm-6OQ-hjCt.js → PkToolShowContactForm-D8Z4bRx9.js} +2 -2
  94. package/dist-vue/_chunks/{PkToolShowContactForm-6OQ-hjCt.js.map → PkToolShowContactForm-D8Z4bRx9.js.map} +1 -1
  95. package/dist-vue/_chunks/{PkToolShowDiagram-D6hPQVoe.js → PkToolShowDiagram-Bla0_Vc2.js} +4 -4
  96. package/dist-vue/_chunks/{PkToolShowDiagram-D6hPQVoe.js.map → PkToolShowDiagram-Bla0_Vc2.js.map} +1 -1
  97. package/dist-vue/_chunks/{PkToolShowForm-CAadu_Pq.js → PkToolShowForm-BO3NuyAu.js} +3 -3
  98. package/dist-vue/_chunks/{PkToolShowForm-CAadu_Pq.js.map → PkToolShowForm-BO3NuyAu.js.map} +1 -1
  99. package/dist-vue/_chunks/{PkToolShowImageGallery-BlTyCF8h.js → PkToolShowImageGallery-BLISCC3h.js} +5 -5
  100. package/dist-vue/_chunks/{PkToolShowImageGallery-BlTyCF8h.js.map → PkToolShowImageGallery-BLISCC3h.js.map} +1 -1
  101. package/dist-vue/_chunks/{PkToolShowLocation-CyaKgQUX.js → PkToolShowLocation-dTZcp7ah.js} +2 -2
  102. package/dist-vue/_chunks/{PkToolShowLocation-CyaKgQUX.js.map → PkToolShowLocation-dTZcp7ah.js.map} +1 -1
  103. package/dist-vue/_chunks/{PkToolShowProductList-CZFkf9UD.js → PkToolShowProductList-D5JZ6W7c.js} +2 -2
  104. package/dist-vue/_chunks/{PkToolShowProductList-CZFkf9UD.js.map → PkToolShowProductList-D5JZ6W7c.js.map} +1 -1
  105. package/dist-vue/_chunks/{PkToolShowSources-B_2niEa3.js → PkToolShowSources-SnQoTbvq.js} +3 -3
  106. package/dist-vue/_chunks/PkToolShowSources-SnQoTbvq.js.map +1 -0
  107. package/dist-vue/_chunks/{PkToolShowVideo-BnSYdoTJ.js → PkToolShowVideo-D7pwwsfX.js} +2 -2
  108. package/dist-vue/_chunks/{PkToolShowVideo-BnSYdoTJ.js.map → PkToolShowVideo-D7pwwsfX.js.map} +1 -1
  109. package/dist-vue/_chunks/{PkToolShowWebPages-CHrHuFZI.js → PkToolShowWebPages-dbNooGK_.js} +2 -2
  110. package/dist-vue/_chunks/{PkToolShowWebPages-CHrHuFZI.js.map → PkToolShowWebPages-dbNooGK_.js.map} +1 -1
  111. package/dist-vue/_chunks/{useLightbox-DrEFS3gx.js → useLightbox-CQ8WtQNC.js} +7 -1
  112. package/dist-vue/_chunks/{useLightbox-DrEFS3gx.js.map → useLightbox-CQ8WtQNC.js.map} +1 -1
  113. package/dist-vue/_chunks/{utils-BYvQMZLG.js → utils-CaPUJibf.js} +4 -2
  114. package/dist-vue/_chunks/utils-CaPUJibf.js.map +1 -0
  115. package/dist-vue/composables.js +23 -5
  116. package/dist-vue/composables.js.map +1 -1
  117. package/dist-vue/index.js +30 -28
  118. package/dist-vue/index.js.map +1 -1
  119. package/dist-vue/packages/components/src/composables/useLightbox.d.ts +3 -1
  120. package/dist-vue/packages/models/src/schema/ChatTask.d.ts +32 -1
  121. package/package.json +1 -1
  122. package/dist/_chunks/PkToolShowChart-BalU3bxm.js.map +0 -1
  123. package/dist/_chunks/PkToolShowComparison-DeO7cMeF.js.map +0 -1
  124. package/dist/_chunks/PkToolShowSources-D5gh7FtU.js.map +0 -1
  125. package/dist/_chunks/utils-C1JaUBI_.js.map +0 -1
  126. package/dist-vue/_chunks/PkChatbotViewChat-DfZznZyZ.js.map +0 -1
  127. package/dist-vue/_chunks/PkToolShowChart-BaUS47YU.js.map +0 -1
  128. package/dist-vue/_chunks/PkToolShowComparison-BEHyRNXE.js.map +0 -1
  129. package/dist-vue/_chunks/PkToolShowSources-B_2niEa3.js.map +0 -1
  130. package/dist-vue/_chunks/utils-BYvQMZLG.js.map +0 -1
@@ -3,8 +3,8 @@ import { S as t, Tt as n, V as r, f as i, g as a, gt as o, h as s, k as c, kt as
3
3
  import { r as ee } from "./vue-i18n-CDYWo9pX.js";
4
4
  import { i as te, r as _, t as v } from "./excelNumberFormat-D-AQd3Ap.js";
5
5
  import { p as y, y as ne } from "./Agent-DJ6TBi6l.js";
6
- import { t as re } from "./PkChatbotFilePreview-CLUH7cTq.js";
7
- import { u as b } from "./utils-C1JaUBI_.js";
6
+ import { t as re } from "./PkChatbotFilePreview-5mhg2XeB.js";
7
+ import { u as b } from "./utils-CEzr10hz.js";
8
8
  import { t as x } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
9
9
  // ../../packages/components/src/chat/PkToolChatFile.vue?vue&type=script&setup=true&lang.ts
10
10
  c(), n(), u();
@@ -225,4 +225,4 @@ var ie = {
225
225
  }), [["styles", [".pk-tool-chat-file__changes{border:var(--border) solid var(--color-surface-3);border-radius:var(--rounded-lg);background-color:var(--color-surface);max-width:36rem;font-size:var(--text-12);overflow:hidden}.pk-tool-chat-file__summary{padding:var(--spacing-8) var(--spacing-12);border-bottom:var(--border) solid var(--color-surface-3);color:var(--color-word-2);font-size:var(--text-12);font-weight:var(--font-medium);margin:0}.pk-tool-chat-file__summary:last-child{border-bottom:0}.pk-tool-chat-file__scroll{max-height:20rem;overflow-y:auto}.pk-tool-chat-file__table{border-collapse:collapse;width:100%}.pk-tool-chat-file__table th,.pk-tool-chat-file__table td{padding:var(--spacing-8) var(--spacing-12);border-bottom:var(--border) solid var(--color-surface-2);text-align:start;vertical-align:top;overflow-wrap:anywhere}.pk-tool-chat-file__table th{color:var(--color-word-3);font-weight:var(--font-medium)}.pk-tool-chat-file__table tbody:last-child tr:last-child td{border-bottom:0}.pk-tool-chat-file__table .pk-tool-chat-file__sheet{padding-block:var(--spacing-6);background-color:var(--color-surface-1);color:var(--color-word-2)}.pk-tool-chat-file__cell{width:1%;color:var(--color-word-2);font-variant-numeric:tabular-nums;white-space:nowrap}.pk-tool-chat-file__before{width:50%;color:var(--color-word-3)}.pk-tool-chat-file__after{width:50%;color:var(--color-word-1)}.pk-tool-chat-file__paragraphs{margin:0;padding:0;list-style:none}.pk-tool-chat-file__paragraph{gap:var(--spacing-4) var(--spacing-md);padding:var(--spacing-8) var(--spacing-12);border-bottom:var(--border) solid var(--color-surface-2);grid-template-columns:minmax(4rem,max-content) 1fr;display:grid}.pk-tool-chat-file__paragraph:last-child{border-bottom:0}.pk-tool-chat-file__what{color:var(--color-word-3);white-space:nowrap}.pk-tool-chat-file__text{min-width:0;color:var(--color-word-2);overflow-wrap:anywhere}.pk-tool-chat-file__removed{color:var(--u-danger-text);text-decoration:line-through}.pk-tool-chat-file__added{color:var(--u-success-text);font-weight:var(--font-medium);text-underline-offset:.2em;text-decoration:underline}.pk-tool-chat-file__removed+.pk-tool-chat-file__added{margin-inline-start:var(--spacing-4)}.pk-tool-chat-file__note{padding:var(--spacing-8) var(--spacing-12);border-top:var(--border) solid var(--color-surface-2);color:var(--color-word-3);margin:0}.pk-tool-chat-file__more{justify-content:center;align-items:center;gap:var(--spacing-4);width:100%;padding:var(--spacing-8) var(--spacing-12);border:0;border-top:var(--border) solid var(--color-surface-2);color:var(--color-word-2);font:inherit;cursor:pointer;transition:background-color var(--duration-150) var(--ease-out);background:0 0;display:flex}.pk-tool-chat-file__more:hover{background-color:var(--color-surface-1)}.pk-tool-chat-file__more:focus-visible{outline:var(--spacing-2) solid var(--input-focus-color);outline-offset:calc(var(--spacing-2) * -1)}.pk-tool-chat-file__reminder{align-items:flex-start;gap:var(--spacing-8);padding:var(--spacing-8) var(--spacing-12);border-top:var(--border) solid var(--color-surface-2);color:var(--color-word-2);margin:0;display:flex}.pk-tool-chat-file__reminder-icon{margin-top:var(--spacing-2);color:var(--color-word-3);font-size:var(--text-14);flex-shrink:0}"]]]);
226
226
  export { H as default };
227
227
 
228
- //# sourceMappingURL=PkToolChatFile-BzN4fMaY.js.map
228
+ //# sourceMappingURL=PkToolChatFile-Ck1uJvaj.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PkToolChatFile-BzN4fMaY.js","names":["_openBlock","_createElementBlock","_createVNode","PkChatbotFilePreview","_createElementVNode","_toDisplayString","_unref","_Fragment","_renderList","_createTextVNode","De","createVNode","init_shared_esm_bundler","renderList","Fragment","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","isSpreadsheetDateFormat","formatExcelNumber","excelDateText","SPREADSHEET_MIME_TYPE","WORD_MIME_TYPE","PkChatbotFilePreview_default","chatFileName","_plugin_vue_export_helper_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","_hoisted_20","_hoisted_21","_hoisted_22","SHOWN_CHANGES","PkToolChatFile_default","WORD_TOOL_PARTS","props","__props","$t","showAll","withoutLength","text","contextOf","runs","before","after","excerptOf","a","b","common","i","j","push","last","kind","run","k","wordChangeLabel","op","paragraphRow","change","cellRow","legacy","rows","bang","cell","appended","shownAs","raw","format","locale","file","part","output","word","changed","changes","reminders","summary","shown","shownParagraphs","shownSheets","groups","row","group","hiddenRows","olderVersion","latest","restoreThis","openPreview","_component_VvIcon","g","index","s","segment","_cache","reminder"],"sources":["../../../../packages/components/src/chat/PkToolChatFile.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import {\n isSpreadsheetDateFormat,\n SPREADSHEET_MIME_TYPE,\n WORD_MIME_TYPE,\n } from 'models'\n import PkChatbotFilePreview from './PkChatbotFilePreview.vue'\n import { excelDateText, formatExcelNumber } from './excelNumberFormat'\n import {\n chatFileName,\n type ChatFilePreviewTarget,\n type ChatFileRestoreTarget,\n } from './utils'\n\n /**\n * One entry of `changes`: a cell (or an appended row, or a new sheet) of\n * `editSpreadsheet`, a paragraph or a table row of `editWordDocument`.\n */\n type ChatFileChange = {\n cell?: string\n op?: string\n before?: string\n after?: string\n newSheetRows?: number\n /**\n * The number format code of a side that is a number in the file,\n * from edits made since it was added.\n */\n beforeFormat?: string\n afterFormat?: string\n }\n\n /** What the four file tools return that the card shows. */\n type ChatFileOutput = {\n /** The file every version of it answers to. */\n fileId?: string\n storedFileName: string\n filename?: string\n sizeBytes?: number\n version?: number\n changedCells?: number\n changedParagraphs?: number\n changes?: ChatFileChange[]\n moreChanges?: number\n /** Of a Word edit: the changes are revisions. */\n tracked?: boolean\n stalePivots?: true\n staleTableOfContents?: true\n /** Of a restore: the version this one writes again. */\n restoredFrom?: number\n }\n\n /** A run of an excerpt: text kept, taken away or put in. */\n type Segment = { text: string; kind: 'same' | 'removed' | 'added' }\n\n /**\n * A changed cell as a row of the table: its value before and after, or\n * the line that stands for a new sheet.\n */\n type CellRow = {\n sheet: string\n cell?: string\n before?: string\n after?: string\n newSheet?: string\n }\n\n /** The rows of one sheet, under its name. */\n type SheetGroup = { sheet: string; rows: CellRow[] }\n\n /** A changed paragraph or table row: what happened, and its words. */\n type ParagraphRow = { what: string; segments: Segment[] }\n\n /** The tools whose output is a Word document; the others write a spreadsheet. */\n const WORD_TOOL_PARTS = new Set([\n 'tool-editWordDocument',\n 'tool-createWordDocument',\n ])\n\n /** Rows shown before \"View more\": most edits are one to three changes. */\n const SHOWN_CHANGES = 3\n /** Words of context kept on each side of a change in a paragraph. */\n const CONTEXT_WORDS = 6\n\n /**\n * The file a call of `editSpreadsheet`, `editWordDocument`,\n * `createSpreadsheet` or `createWordDocument` wrote, a new version or a\n * new file, to download. Drawn once the call has an output: while it runs,\n * the feed's activity indicator names it, and a refused call is explained\n * by the answer. Under an edit, a frame says what changed, its first\n * rows shown: a table of cells for a spreadsheet, the changed words of\n * each paragraph for a Word document, and what is left to do in Office.\n */\n const props = defineProps<{\n part: unknown\n /** The authenticated download URL of a file stored in this chat. */\n fileUrl: (storedFileName: string) => string\n /** Opens the preview of the file, where the chat has one. */\n preview?: (file: ChatFilePreviewTarget) => void\n /** The latest version of each file the conversation shows, by fileId. */\n latestVersions?: ReadonlyMap<string, number>\n /**\n * Asks the agent to write an earlier version again as the newest one,\n * where the chat can send a message.\n */\n restore?: (file: ChatFileRestoreTarget) => void\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n\n const showAll = ref(false)\n\n /**\n * The services cut a long text for the model and give its length\n * (`… (523 characters)`, the marker of every tool result, written by\n * `wordDocument.service.ts` and `spreadsheet.service.ts`): the card keeps\n * the ellipsis only.\n */\n const withoutLength = (text: string | undefined) =>\n text?.replace(/… \\(\\d+ characters\\)$/, '…')\n\n /**\n * A run of unchanged words cut to a few words on the side of each change\n * it touches: the head of the text keeps its end, the tail its start, a\n * run between two changes both, with an ellipsis where words went.\n */\n const contextOf = (text: string, before: boolean, after: boolean) => {\n const runs = text.split(/(\\s+)/).filter(Boolean)\n // Every word is followed by its space: twice as many runs.\n const keep = CONTEXT_WORDS * 2\n if (runs.length <= (before && after ? keep * 2 : keep)) {\n return text\n }\n if (before && after) {\n return `${runs.slice(0, keep).join('')}… ${runs.slice(-keep).join('')}`\n }\n return after\n ? `…${runs.slice(-keep).join('')}`\n : `${runs.slice(0, keep).join('')}…`\n }\n\n /**\n * The words of `before` and `after` that differ, word by word, so the\n * words two changes share between them stay plain. An echoed paragraph\n * is at most a few hundred characters, a few dozen words for the table.\n */\n const excerptOf = (before: string, after: string): Segment[] => {\n const a = before.split(/(\\s+)/).filter(Boolean)\n const b = after.split(/(\\s+)/).filter(Boolean)\n // Longest common subsequence, from the end\n const common = Array.from({ length: a.length + 1 }, () =>\n new Array<number>(b.length + 1).fill(0),\n )\n for (let i = a.length - 1; i >= 0; i--) {\n for (let j = b.length - 1; j >= 0; j--) {\n common[i][j] =\n a[i] === b[j]\n ? common[i + 1][j + 1] + 1\n : Math.max(common[i + 1][j], common[i][j + 1])\n }\n }\n const runs: Segment[] = []\n const push = (text: string, kind: Segment['kind']) => {\n const last = runs[runs.length - 1]\n if (last?.kind === kind) {\n last.text += text\n } else {\n runs.push({ text, kind })\n }\n }\n let i = 0\n let j = 0\n while (i < a.length || j < b.length) {\n if (i < a.length && j < b.length && a[i] === b[j]) {\n push(a[i++], 'same')\n j++\n } else if (\n j >= b.length ||\n (i < a.length && common[i + 1][j] >= common[i][j + 1])\n ) {\n push(a[i++], 'removed')\n } else {\n push(b[j++], 'added')\n }\n }\n return runs.map((run, k) =>\n run.kind === 'same'\n ? {\n ...run,\n text: contextOf(run.text, k > 0, k < runs.length - 1),\n }\n : run,\n )\n }\n\n /** What a Word operation did, as the row says it. */\n const wordChangeLabel = (op: string | undefined) => {\n switch (op) {\n case 'insertParagraphs':\n return $t('messagePart.chatFileParagraphAdded')\n case 'deleteParagraphs':\n return $t('messagePart.chatFileParagraphDeleted')\n case 'insertTableRow':\n return $t('messagePart.chatFileTableRowAdded')\n case 'deleteTableRow':\n return $t('messagePart.chatFileTableRowDeleted')\n case 'acceptRevisions':\n return $t('messagePart.chatFileRevisionAccepted')\n case 'rejectRevisions':\n return $t('messagePart.chatFileRevisionRejected')\n default:\n return $t('messagePart.chatFileParagraphChanged')\n }\n }\n\n /**\n * A paragraph marked as Word marks a revision, struck where words went\n * and underlined where they came. A paragraph only added or only removed\n * is said by its label: the text added stays plain, the text removed\n * stays struck.\n */\n const paragraphRow = (change: ChatFileChange): ParagraphRow => {\n const before = withoutLength(change.before)\n const after = withoutLength(change.after)\n return {\n what: wordChangeLabel(change.op),\n segments:\n before && after\n ? excerptOf(before, after)\n : [\n before\n ? { text: before, kind: 'removed' }\n : { text: after ?? '', kind: 'same' },\n ],\n }\n }\n\n /**\n * A cell as a person reads it: its sheet heads the group of its rows, so\n * the row says `C5` and not Excel's `Listino!C5`, and a row the edit\n * appended says \"Row 10\" and not `A10:F10`.\n */\n const cellRow = (change: ChatFileChange): CellRow => {\n const ref = change.cell ?? ''\n // A new sheet is named alone, with no cell. An edit made before the\n // card read `newSheetRows` said it only in the model's words.\n const legacy = change.before\n ? undefined\n : /^new sheet, (\\d+) row\\(s\\)$/.exec(change.after ?? '')?.[1]\n const rows =\n change.newSheetRows ?? (legacy ? Number(legacy) : undefined)\n if (rows !== undefined) {\n return {\n sheet: ref,\n newSheet: $t('messagePart.chatFileNewSheet', rows),\n }\n }\n\n const bang = ref.lastIndexOf('!')\n const cell = ref.slice(bang + 1)\n const appended = /^A(\\d+):[A-Z]+(\\d+)$/.exec(cell)\n return {\n sheet: ref.slice(0, Math.max(bang, 0)),\n cell:\n appended && appended[1] === appended[2]\n ? $t('messagePart.chatFileRow', { row: appended[1] })\n : cell,\n before: shownAs(withoutLength(change.before), change.beforeFormat),\n after: shownAs(withoutLength(change.after), change.afterFormat),\n }\n }\n\n /**\n * A value as its cell shows it, `0.05` as `5%` and a date serial as the\n * date; a formula, a text and a cell with no format stay as written.\n */\n const shownAs = (\n raw: string | undefined,\n format: string | undefined,\n ): string | undefined => {\n if (!raw || !format || raw.startsWith('=')) {\n return raw || undefined\n }\n try {\n if (isSpreadsheetDateFormat(format)) {\n return excelDateText(raw, format, locale.value) ?? raw\n }\n return /^-?\\d+(\\.\\d+)?(e[+-]?\\d+)?$/i.test(raw)\n ? formatExcelNumber(format, Number(raw), locale.value).text\n : raw\n } catch {\n // A code the interpreter cannot read: the value as written\n return raw\n }\n }\n\n const file = computed(() => {\n const part = props.part as {\n type?: string\n state?: string\n output?: Partial<ChatFileOutput>\n }\n if (part.state !== 'output-available' || !part.output?.storedFileName) {\n return undefined\n }\n const output = part.output as ChatFileOutput\n const word = WORD_TOOL_PARTS.has(part.type ?? '')\n // A new file has no count of changes. Each key is written out in its\n // own call: the widget ships only the keys it finds that way.\n let changed: string | undefined\n if (word && output.changedParagraphs !== undefined) {\n changed = output.tracked\n ? $t(\n 'messagePart.editWordDocumentRevisions',\n output.changedParagraphs,\n )\n : $t(\n 'messagePart.editWordDocumentParagraphs',\n output.changedParagraphs,\n )\n } else if (!word && output.changedCells !== undefined) {\n changed = $t(\n 'messagePart.editSpreadsheetCells',\n output.changedCells,\n )\n }\n const changes = changed ? (output.changes ?? []) : []\n const reminders: string[] = []\n if (output.stalePivots) {\n reminders.push($t('messagePart.chatFileRefreshPivots'))\n }\n if (output.staleTableOfContents) {\n reminders.push($t('messagePart.chatFileUpdateTableOfContents'))\n }\n let summary =\n changed && output.version\n ? $t('messagePart.chatFileVersionSummary', {\n version: output.version,\n changed,\n })\n : changed\n if (output.restoredFrom) {\n summary = $t('messagePart.chatFileRestored', {\n version: output.version,\n restored: output.restoredFrom,\n })\n }\n return {\n output,\n mediaType: word ? WORD_MIME_TYPE : SPREADSHEET_MIME_TYPE,\n summary,\n cells: word ? [] : changes.map(cellRow),\n paragraphs: word ? changes.map(paragraphRow) : [],\n count: changes.length,\n more: output.moreChanges ?? 0,\n reminders,\n }\n })\n\n const shown = <T,>(rows: T[] | undefined): T[] =>\n showAll.value ? (rows ?? []) : (rows ?? []).slice(0, SHOWN_CHANGES)\n const shownParagraphs = computed(() => shown(file.value?.paragraphs))\n /** The rows shown, a group per sheet in the order the edit reached it. */\n const shownSheets = computed(() => {\n const groups = new Map<string, SheetGroup>()\n for (const row of shown(file.value?.cells)) {\n const group = groups.get(row.sheet)\n if (group) {\n group.rows.push(row)\n } else {\n groups.set(row.sheet, { sheet: row.sheet, rows: [row] })\n }\n }\n return [...groups.values()]\n })\n const hiddenRows = computed(() => (file.value?.count ?? 0) - SHOWN_CHANGES)\n\n /**\n * The version this card wrote, when a later one of the same file is in\n * the conversation: the one the user can ask to have back.\n */\n const olderVersion = computed(() => {\n const output = file.value?.output\n const latest = output?.fileId\n ? props.latestVersions?.get(output.fileId)\n : undefined\n return output?.fileId &&\n output.version &&\n latest &&\n output.version < latest\n ? {\n fileId: output.fileId,\n version: output.version,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n }\n : undefined\n })\n\n /** Asks the agent for this version back. */\n const restoreThis = () => {\n if (olderVersion.value) {\n props.restore?.(olderVersion.value)\n }\n }\n\n /** Opens this version in the chat's viewer. */\n const openPreview = () => {\n const output = file.value?.output\n if (!output || !props.preview) {\n return\n }\n props.preview({\n kind:\n file.value?.mediaType === WORD_MIME_TYPE\n ? 'word'\n : 'spreadsheet',\n storedFileName: output.storedFileName,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n version: output.version,\n fileId: output.fileId,\n })\n }\n</script>\n\n<template>\n <div v-if=\"file\" class=\"pk-tool-chat-file\">\n <!-- Restore and open live in the file, beside its download: a\n bordered button under it weighed more than the file and the\n answer it belongs to -->\n <PkChatbotFilePreview\n :media-type=\"file.mediaType\"\n :url=\"fileUrl(file.output.storedFileName)\"\n :filename=\"file.output.filename\"\n :size=\"file.output.sizeBytes\"\n show-download\n :on-preview=\"preview ? openPreview : undefined\"\n :on-restore=\"restore && olderVersion ? restoreThis : undefined\" />\n <section\n v-if=\"file.count || file.output.restoredFrom\"\n class=\"pk-tool-chat-file__changes mt-xs\">\n <h4 class=\"pk-tool-chat-file__summary\">\n {{ file.summary }}\n </h4>\n <div v-if=\"file.count\" class=\"pk-tool-chat-file__scroll\">\n <table\n v-if=\"file.cells.length\"\n class=\"pk-tool-chat-file__table\">\n <thead>\n <tr>\n <th scope=\"col\" class=\"pk-tool-chat-file__cell\">\n {{ $t('messagePart.chatFileCell') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileBefore') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileAfter') }}\n </th>\n </tr>\n </thead>\n <tbody v-for=\"(group, g) in shownSheets\" :key=\"g\">\n <tr>\n <th\n colspan=\"3\"\n scope=\"rowgroup\"\n class=\"pk-tool-chat-file__sheet\">\n {{\n $t('messagePart.chatFileSheet', {\n name: group.sheet,\n })\n }}\n </th>\n </tr>\n <tr v-for=\"(row, index) in group.rows\" :key=\"index\">\n <td\n v-if=\"row.newSheet\"\n colspan=\"3\"\n class=\"pk-tool-chat-file__after\">\n {{ row.newSheet }}\n </td>\n <template v-else>\n <td class=\"pk-tool-chat-file__cell\">\n {{ row.cell }}\n </td>\n <td class=\"pk-tool-chat-file__before\">\n {{ row.before }}\n </td>\n <td class=\"pk-tool-chat-file__after\">\n {{ row.after }}\n </td>\n </template>\n </tr>\n </tbody>\n </table>\n <ul v-else class=\"pk-tool-chat-file__paragraphs\">\n <li\n v-for=\"(row, index) in shownParagraphs\"\n :key=\"index\"\n class=\"pk-tool-chat-file__paragraph\">\n <span class=\"pk-tool-chat-file__what\">\n {{ row.what }}\n </span>\n <span class=\"pk-tool-chat-file__text\">\n <template\n v-for=\"(segment, s) in row.segments\"\n :key=\"s\">\n <del\n v-if=\"segment.kind === 'removed'\"\n class=\"pk-tool-chat-file__removed\">\n {{ segment.text }}\n </del>\n <ins\n v-else-if=\"segment.kind === 'added'\"\n class=\"pk-tool-chat-file__added\">\n {{ segment.text }}\n </ins>\n <span v-else>{{ segment.text }}</span>\n </template>\n </span>\n </li>\n </ul>\n <p v-if=\"showAll && file.more\" class=\"pk-tool-chat-file__note\">\n {{ $t('messagePart.chatFileMoreChanges', file.more) }}\n </p>\n </div>\n <button\n v-if=\"hiddenRows > 0\"\n type=\"button\"\n class=\"pk-tool-chat-file__more\"\n :aria-expanded=\"showAll\"\n @click=\"showAll = !showAll\">\n <VvIcon\n :name=\"\n showAll ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\n \"\n class=\"text-16\"\n aria-hidden=\"true\" />\n {{\n showAll\n ? $t('action.showLess')\n : $t('action.showMore', { count: hiddenRows })\n }}\n </button>\n <p\n v-for=\"reminder in file.reminders\"\n :key=\"reminder\"\n class=\"pk-tool-chat-file__reminder\">\n <VvIcon\n name=\"ri:information-line\"\n class=\"pk-tool-chat-file__reminder-icon\"\n aria-hidden=\"true\" />\n {{ reminder }}\n </p>\n </section>\n <p v-else-if=\"file.summary\" class=\"text-12 text-word-3 mt-xs mb-0\">\n {{ file.summary }}\n </p>\n </div>\n</template>\n\n<style lang=\"scss\">\n // One frame (DESIGN.md, principle 4): a hairline at surface-3, rounded-lg,\n // a solid ground over the dots of the chat, as wide as a short paragraph\n // while the file above keeps its 280px. Inside it every divider is one\n // hairline at surface-2.\n .pk-tool-chat-file__changes {\n max-width: 36rem;\n overflow: hidden;\n border: var(--border) solid var(--color-surface-3);\n border-radius: var(--rounded-lg);\n background-color: var(--color-surface);\n font-size: var(--text-12);\n }\n\n .pk-tool-chat-file__summary {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-3);\n color: var(--color-word-2);\n font-size: var(--text-12);\n font-weight: var(--font-medium);\n\n // A restore says only what it wrote back\n &:last-child {\n border-bottom: 0;\n }\n }\n\n // Bounded, so fifty changes scroll inside the frame\n .pk-tool-chat-file__scroll {\n max-height: 20rem;\n overflow-y: auto;\n }\n\n .pk-tool-chat-file__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n text-align: start;\n vertical-align: top;\n overflow-wrap: anywhere;\n }\n\n // Told apart by its weight and colour, no heavier rule\n th {\n color: var(--color-word-3);\n font-weight: var(--font-medium);\n }\n\n tbody:last-child tr:last-child td {\n border-bottom: 0;\n }\n }\n\n // The name of a sheet heads its rows, one step of surface under it\n .pk-tool-chat-file__table .pk-tool-chat-file__sheet {\n padding-block: var(--spacing-6);\n background-color: var(--color-surface-1);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__cell {\n width: 1%;\n color: var(--color-word-2);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__before {\n width: 50%;\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__after {\n width: 50%;\n color: var(--color-word-1);\n }\n\n .pk-tool-chat-file__paragraphs {\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n .pk-tool-chat-file__paragraph {\n display: grid;\n grid-template-columns: minmax(4rem, max-content) 1fr;\n gap: var(--spacing-4) var(--spacing-md);\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n\n &:last-child {\n border-bottom: 0;\n }\n }\n\n .pk-tool-chat-file__what {\n color: var(--color-word-3);\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__text {\n min-width: 0;\n color: var(--color-word-2);\n overflow-wrap: anywhere;\n }\n\n // Marked as Word marks a revision, struck where words went and\n // underlined where they came, in the red and green of a comparison: the\n // change is what the row exists to report, the verdict exception of\n // DESIGN.md (principle 2). The readable text tokens hold the contrast in\n // both themes. The base styles take the line off `del`.\n .pk-tool-chat-file__removed {\n color: var(--u-danger-text);\n text-decoration: line-through;\n }\n\n .pk-tool-chat-file__added {\n color: var(--u-success-text);\n font-weight: var(--font-medium);\n text-decoration: underline;\n text-underline-offset: 0.2em;\n }\n\n .pk-tool-chat-file__removed + .pk-tool-chat-file__added {\n margin-inline-start: var(--spacing-4);\n }\n\n .pk-tool-chat-file__note {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__more {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: var(--spacing-4);\n width: 100%;\n padding: var(--spacing-8) var(--spacing-12);\n border: 0;\n border-top: var(--border) solid var(--color-surface-2);\n background: none;\n color: var(--color-word-2);\n font: inherit;\n cursor: pointer;\n transition: background-color var(--duration-150) var(--ease-out);\n\n &:hover {\n background-color: var(--color-surface-1);\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--input-focus-color);\n outline-offset: calc(var(--spacing-2) * -1);\n }\n }\n\n .pk-tool-chat-file__reminder {\n display: flex;\n align-items: flex-start;\n gap: var(--spacing-8);\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__reminder-icon {\n flex-shrink: 0;\n margin-top: var(--spacing-2);\n color: var(--color-word-3);\n font-size: var(--text-14);\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A,GAkFU0D,IAAgB,G;;;;;;;;;;EANtB,IAAME,oBAAkB,IAAI,IAAI,CAC5B,yBACA,yBACJ,CAAC,GAgBKC,IAAQC,GAeR,EAAE,GAAGC,GAAI,cAAWpC,GAAQ,EAAE,UAAU,SAAS,CAAC,GAElDqC,IAAUhD,EAAI,EAAK,GAQnBiD,KAAiB,MACnBC,GAAM,QAAQ,yBAAyB,GAAG,GAOxCC,KAAa,GAAc,GAAiB,MAAmB;GACjE,IAAMC,IAAOF,EAAK,MAAM,OAAO,CAAC,CAAC,OAAO,OAAO;GAS/C,OANIE,EAAK,WAAWC,KAAUC,IAAQ,KAAW,MACtCJ,IAEPG,KAAUC,IACH,GAAGF,EAAK,MAAM,GAAG,EAAI,CAAC,CAAC,KAAK,EAAE,EAAE,IAAIA,EAAK,MAAM,GAAK,CAAC,CAAC,KAAK,EAAE,MAEjEE,IACD,IAAIF,EAAK,MAAM,GAAK,CAAC,CAAC,KAAK,EAAE,MAC7B,GAAGA,EAAK,MAAM,GAAG,EAAI,CAAC,CAAC,KAAK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3,"file":"PkToolChatFile-Ck1uJvaj.js","names":["_openBlock","_createElementBlock","_createVNode","PkChatbotFilePreview","_createElementVNode","_toDisplayString","_unref","_Fragment","_renderList","_createTextVNode","De","createVNode","init_shared_esm_bundler","renderList","Fragment","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","isSpreadsheetDateFormat","formatExcelNumber","excelDateText","SPREADSHEET_MIME_TYPE","WORD_MIME_TYPE","PkChatbotFilePreview_default","chatFileName","_plugin_vue_export_helper_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","_hoisted_20","_hoisted_21","_hoisted_22","SHOWN_CHANGES","PkToolChatFile_default","WORD_TOOL_PARTS","props","__props","$t","showAll","withoutLength","text","contextOf","runs","before","after","excerptOf","a","b","common","i","j","push","last","kind","run","k","wordChangeLabel","op","paragraphRow","change","cellRow","legacy","rows","bang","cell","appended","shownAs","raw","format","locale","file","part","output","word","changed","changes","reminders","summary","shown","shownParagraphs","shownSheets","groups","row","group","hiddenRows","olderVersion","latest","restoreThis","openPreview","_component_VvIcon","g","index","s","segment","_cache","reminder"],"sources":["../../../../packages/components/src/chat/PkToolChatFile.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import {\n isSpreadsheetDateFormat,\n SPREADSHEET_MIME_TYPE,\n WORD_MIME_TYPE,\n } from 'models'\n import PkChatbotFilePreview from './PkChatbotFilePreview.vue'\n import { excelDateText, formatExcelNumber } from './excelNumberFormat'\n import {\n chatFileName,\n type ChatFilePreviewTarget,\n type ChatFileRestoreTarget,\n } from './utils'\n\n /**\n * One entry of `changes`: a cell (or an appended row, or a new sheet) of\n * `editSpreadsheet`, a paragraph or a table row of `editWordDocument`.\n */\n type ChatFileChange = {\n cell?: string\n op?: string\n before?: string\n after?: string\n newSheetRows?: number\n /**\n * The number format code of a side that is a number in the file,\n * from edits made since it was added.\n */\n beforeFormat?: string\n afterFormat?: string\n }\n\n /** What the four file tools return that the card shows. */\n type ChatFileOutput = {\n /** The file every version of it answers to. */\n fileId?: string\n storedFileName: string\n filename?: string\n sizeBytes?: number\n version?: number\n changedCells?: number\n changedParagraphs?: number\n changes?: ChatFileChange[]\n moreChanges?: number\n /** Of a Word edit: the changes are revisions. */\n tracked?: boolean\n stalePivots?: true\n staleTableOfContents?: true\n /** Of a restore: the version this one writes again. */\n restoredFrom?: number\n }\n\n /** A run of an excerpt: text kept, taken away or put in. */\n type Segment = { text: string; kind: 'same' | 'removed' | 'added' }\n\n /**\n * A changed cell as a row of the table: its value before and after, or\n * the line that stands for a new sheet.\n */\n type CellRow = {\n sheet: string\n cell?: string\n before?: string\n after?: string\n newSheet?: string\n }\n\n /** The rows of one sheet, under its name. */\n type SheetGroup = { sheet: string; rows: CellRow[] }\n\n /** A changed paragraph or table row: what happened, and its words. */\n type ParagraphRow = { what: string; segments: Segment[] }\n\n /** The tools whose output is a Word document; the others write a spreadsheet. */\n const WORD_TOOL_PARTS = new Set([\n 'tool-editWordDocument',\n 'tool-createWordDocument',\n ])\n\n /** Rows shown before \"View more\": most edits are one to three changes. */\n const SHOWN_CHANGES = 3\n /** Words of context kept on each side of a change in a paragraph. */\n const CONTEXT_WORDS = 6\n\n /**\n * The file a call of `editSpreadsheet`, `editWordDocument`,\n * `createSpreadsheet` or `createWordDocument` wrote, a new version or a\n * new file, to download. Drawn once the call has an output: while it runs,\n * the feed's activity indicator names it, and a refused call is explained\n * by the answer. Under an edit, a frame says what changed, its first\n * rows shown: a table of cells for a spreadsheet, the changed words of\n * each paragraph for a Word document, and what is left to do in Office.\n */\n const props = defineProps<{\n part: unknown\n /** The authenticated download URL of a file stored in this chat. */\n fileUrl: (storedFileName: string) => string\n /** Opens the preview of the file, where the chat has one. */\n preview?: (file: ChatFilePreviewTarget) => void\n /** The latest version of each file the conversation shows, by fileId. */\n latestVersions?: ReadonlyMap<string, number>\n /**\n * Asks the agent to write an earlier version again as the newest one,\n * where the chat can send a message.\n */\n restore?: (file: ChatFileRestoreTarget) => void\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n\n const showAll = ref(false)\n\n /**\n * The services cut a long text for the model and give its length\n * (`… (523 characters)`, the marker of every tool result, written by\n * `wordDocument.service.ts` and `spreadsheet.service.ts`): the card keeps\n * the ellipsis only.\n */\n const withoutLength = (text: string | undefined) =>\n text?.replace(/… \\(\\d+ characters\\)$/, '…')\n\n /**\n * A run of unchanged words cut to a few words on the side of each change\n * it touches: the head of the text keeps its end, the tail its start, a\n * run between two changes both, with an ellipsis where words went.\n */\n const contextOf = (text: string, before: boolean, after: boolean) => {\n const runs = text.split(/(\\s+)/).filter(Boolean)\n // Every word is followed by its space: twice as many runs.\n const keep = CONTEXT_WORDS * 2\n if (runs.length <= (before && after ? keep * 2 : keep)) {\n return text\n }\n if (before && after) {\n return `${runs.slice(0, keep).join('')}… ${runs.slice(-keep).join('')}`\n }\n return after\n ? `…${runs.slice(-keep).join('')}`\n : `${runs.slice(0, keep).join('')}…`\n }\n\n /**\n * The words of `before` and `after` that differ, word by word, so the\n * words two changes share between them stay plain. An echoed paragraph\n * is at most a few hundred characters, a few dozen words for the table.\n */\n const excerptOf = (before: string, after: string): Segment[] => {\n const a = before.split(/(\\s+)/).filter(Boolean)\n const b = after.split(/(\\s+)/).filter(Boolean)\n // Longest common subsequence, from the end\n const common = Array.from({ length: a.length + 1 }, () =>\n new Array<number>(b.length + 1).fill(0),\n )\n for (let i = a.length - 1; i >= 0; i--) {\n for (let j = b.length - 1; j >= 0; j--) {\n common[i][j] =\n a[i] === b[j]\n ? common[i + 1][j + 1] + 1\n : Math.max(common[i + 1][j], common[i][j + 1])\n }\n }\n const runs: Segment[] = []\n const push = (text: string, kind: Segment['kind']) => {\n const last = runs[runs.length - 1]\n if (last?.kind === kind) {\n last.text += text\n } else {\n runs.push({ text, kind })\n }\n }\n let i = 0\n let j = 0\n while (i < a.length || j < b.length) {\n if (i < a.length && j < b.length && a[i] === b[j]) {\n push(a[i++], 'same')\n j++\n } else if (\n j >= b.length ||\n (i < a.length && common[i + 1][j] >= common[i][j + 1])\n ) {\n push(a[i++], 'removed')\n } else {\n push(b[j++], 'added')\n }\n }\n return runs.map((run, k) =>\n run.kind === 'same'\n ? {\n ...run,\n text: contextOf(run.text, k > 0, k < runs.length - 1),\n }\n : run,\n )\n }\n\n /** What a Word operation did, as the row says it. */\n const wordChangeLabel = (op: string | undefined) => {\n switch (op) {\n case 'insertParagraphs':\n return $t('messagePart.chatFileParagraphAdded')\n case 'deleteParagraphs':\n return $t('messagePart.chatFileParagraphDeleted')\n case 'insertTableRow':\n return $t('messagePart.chatFileTableRowAdded')\n case 'deleteTableRow':\n return $t('messagePart.chatFileTableRowDeleted')\n case 'acceptRevisions':\n return $t('messagePart.chatFileRevisionAccepted')\n case 'rejectRevisions':\n return $t('messagePart.chatFileRevisionRejected')\n default:\n return $t('messagePart.chatFileParagraphChanged')\n }\n }\n\n /**\n * A paragraph marked as Word marks a revision, struck where words went\n * and underlined where they came. A paragraph only added or only removed\n * is said by its label: the text added stays plain, the text removed\n * stays struck.\n */\n const paragraphRow = (change: ChatFileChange): ParagraphRow => {\n const before = withoutLength(change.before)\n const after = withoutLength(change.after)\n return {\n what: wordChangeLabel(change.op),\n segments:\n before && after\n ? excerptOf(before, after)\n : [\n before\n ? { text: before, kind: 'removed' }\n : { text: after ?? '', kind: 'same' },\n ],\n }\n }\n\n /**\n * A cell as a person reads it: its sheet heads the group of its rows, so\n * the row says `C5` and not Excel's `Listino!C5`, and a row the edit\n * appended says \"Row 10\" and not `A10:F10`.\n */\n const cellRow = (change: ChatFileChange): CellRow => {\n const ref = change.cell ?? ''\n // A new sheet is named alone, with no cell. An edit made before the\n // card read `newSheetRows` said it only in the model's words.\n const legacy = change.before\n ? undefined\n : /^new sheet, (\\d+) row\\(s\\)$/.exec(change.after ?? '')?.[1]\n const rows =\n change.newSheetRows ?? (legacy ? Number(legacy) : undefined)\n if (rows !== undefined) {\n return {\n sheet: ref,\n newSheet: $t('messagePart.chatFileNewSheet', rows),\n }\n }\n\n const bang = ref.lastIndexOf('!')\n const cell = ref.slice(bang + 1)\n const appended = /^A(\\d+):[A-Z]+(\\d+)$/.exec(cell)\n return {\n sheet: ref.slice(0, Math.max(bang, 0)),\n cell:\n appended && appended[1] === appended[2]\n ? $t('messagePart.chatFileRow', { row: appended[1] })\n : cell,\n before: shownAs(withoutLength(change.before), change.beforeFormat),\n after: shownAs(withoutLength(change.after), change.afterFormat),\n }\n }\n\n /**\n * A value as its cell shows it, `0.05` as `5%` and a date serial as the\n * date; a formula, a text and a cell with no format stay as written.\n */\n const shownAs = (\n raw: string | undefined,\n format: string | undefined,\n ): string | undefined => {\n if (!raw || !format || raw.startsWith('=')) {\n return raw || undefined\n }\n try {\n if (isSpreadsheetDateFormat(format)) {\n return excelDateText(raw, format, locale.value) ?? raw\n }\n return /^-?\\d+(\\.\\d+)?(e[+-]?\\d+)?$/i.test(raw)\n ? formatExcelNumber(format, Number(raw), locale.value).text\n : raw\n } catch {\n // A code the interpreter cannot read: the value as written\n return raw\n }\n }\n\n const file = computed(() => {\n const part = props.part as {\n type?: string\n state?: string\n output?: Partial<ChatFileOutput>\n }\n if (part.state !== 'output-available' || !part.output?.storedFileName) {\n return undefined\n }\n const output = part.output as ChatFileOutput\n const word = WORD_TOOL_PARTS.has(part.type ?? '')\n // A new file has no count of changes. Each key is written out in its\n // own call: the widget ships only the keys it finds that way.\n let changed: string | undefined\n if (word && output.changedParagraphs !== undefined) {\n changed = output.tracked\n ? $t(\n 'messagePart.editWordDocumentRevisions',\n output.changedParagraphs,\n )\n : $t(\n 'messagePart.editWordDocumentParagraphs',\n output.changedParagraphs,\n )\n } else if (!word && output.changedCells !== undefined) {\n changed = $t(\n 'messagePart.editSpreadsheetCells',\n output.changedCells,\n )\n }\n const changes = changed ? (output.changes ?? []) : []\n const reminders: string[] = []\n if (output.stalePivots) {\n reminders.push($t('messagePart.chatFileRefreshPivots'))\n }\n if (output.staleTableOfContents) {\n reminders.push($t('messagePart.chatFileUpdateTableOfContents'))\n }\n let summary =\n changed && output.version\n ? $t('messagePart.chatFileVersionSummary', {\n version: output.version,\n changed,\n })\n : changed\n if (output.restoredFrom) {\n summary = $t('messagePart.chatFileRestored', {\n version: output.version,\n restored: output.restoredFrom,\n })\n }\n return {\n output,\n mediaType: word ? WORD_MIME_TYPE : SPREADSHEET_MIME_TYPE,\n summary,\n cells: word ? [] : changes.map(cellRow),\n paragraphs: word ? changes.map(paragraphRow) : [],\n count: changes.length,\n more: output.moreChanges ?? 0,\n reminders,\n }\n })\n\n const shown = <T,>(rows: T[] | undefined): T[] =>\n showAll.value ? (rows ?? []) : (rows ?? []).slice(0, SHOWN_CHANGES)\n const shownParagraphs = computed(() => shown(file.value?.paragraphs))\n /** The rows shown, a group per sheet in the order the edit reached it. */\n const shownSheets = computed(() => {\n const groups = new Map<string, SheetGroup>()\n for (const row of shown(file.value?.cells)) {\n const group = groups.get(row.sheet)\n if (group) {\n group.rows.push(row)\n } else {\n groups.set(row.sheet, { sheet: row.sheet, rows: [row] })\n }\n }\n return [...groups.values()]\n })\n const hiddenRows = computed(() => (file.value?.count ?? 0) - SHOWN_CHANGES)\n\n /**\n * The version this card wrote, when a later one of the same file is in\n * the conversation: the one the user can ask to have back.\n */\n const olderVersion = computed(() => {\n const output = file.value?.output\n const latest = output?.fileId\n ? props.latestVersions?.get(output.fileId)\n : undefined\n return output?.fileId &&\n output.version &&\n latest &&\n output.version < latest\n ? {\n fileId: output.fileId,\n version: output.version,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n }\n : undefined\n })\n\n /** Asks the agent for this version back. */\n const restoreThis = () => {\n if (olderVersion.value) {\n props.restore?.(olderVersion.value)\n }\n }\n\n /** Opens this version in the chat's viewer. */\n const openPreview = () => {\n const output = file.value?.output\n if (!output || !props.preview) {\n return\n }\n props.preview({\n kind:\n file.value?.mediaType === WORD_MIME_TYPE\n ? 'word'\n : 'spreadsheet',\n storedFileName: output.storedFileName,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n version: output.version,\n fileId: output.fileId,\n })\n }\n</script>\n\n<template>\n <div v-if=\"file\" class=\"pk-tool-chat-file\">\n <!-- Restore and open live in the file, beside its download: a\n bordered button under it weighed more than the file and the\n answer it belongs to -->\n <PkChatbotFilePreview\n :media-type=\"file.mediaType\"\n :url=\"fileUrl(file.output.storedFileName)\"\n :filename=\"file.output.filename\"\n :size=\"file.output.sizeBytes\"\n show-download\n :on-preview=\"preview ? openPreview : undefined\"\n :on-restore=\"restore && olderVersion ? restoreThis : undefined\" />\n <section\n v-if=\"file.count || file.output.restoredFrom\"\n class=\"pk-tool-chat-file__changes mt-xs\">\n <h4 class=\"pk-tool-chat-file__summary\">\n {{ file.summary }}\n </h4>\n <div v-if=\"file.count\" class=\"pk-tool-chat-file__scroll\">\n <table\n v-if=\"file.cells.length\"\n class=\"pk-tool-chat-file__table\">\n <thead>\n <tr>\n <th scope=\"col\" class=\"pk-tool-chat-file__cell\">\n {{ $t('messagePart.chatFileCell') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileBefore') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileAfter') }}\n </th>\n </tr>\n </thead>\n <tbody v-for=\"(group, g) in shownSheets\" :key=\"g\">\n <tr>\n <th\n colspan=\"3\"\n scope=\"rowgroup\"\n class=\"pk-tool-chat-file__sheet\">\n {{\n $t('messagePart.chatFileSheet', {\n name: group.sheet,\n })\n }}\n </th>\n </tr>\n <tr v-for=\"(row, index) in group.rows\" :key=\"index\">\n <td\n v-if=\"row.newSheet\"\n colspan=\"3\"\n class=\"pk-tool-chat-file__after\">\n {{ row.newSheet }}\n </td>\n <template v-else>\n <td class=\"pk-tool-chat-file__cell\">\n {{ row.cell }}\n </td>\n <td class=\"pk-tool-chat-file__before\">\n {{ row.before }}\n </td>\n <td class=\"pk-tool-chat-file__after\">\n {{ row.after }}\n </td>\n </template>\n </tr>\n </tbody>\n </table>\n <ul v-else class=\"pk-tool-chat-file__paragraphs\">\n <li\n v-for=\"(row, index) in shownParagraphs\"\n :key=\"index\"\n class=\"pk-tool-chat-file__paragraph\">\n <span class=\"pk-tool-chat-file__what\">\n {{ row.what }}\n </span>\n <span class=\"pk-tool-chat-file__text\">\n <template\n v-for=\"(segment, s) in row.segments\"\n :key=\"s\">\n <del\n v-if=\"segment.kind === 'removed'\"\n class=\"pk-tool-chat-file__removed\">\n {{ segment.text }}\n </del>\n <ins\n v-else-if=\"segment.kind === 'added'\"\n class=\"pk-tool-chat-file__added\">\n {{ segment.text }}\n </ins>\n <span v-else>{{ segment.text }}</span>\n </template>\n </span>\n </li>\n </ul>\n <p v-if=\"showAll && file.more\" class=\"pk-tool-chat-file__note\">\n {{ $t('messagePart.chatFileMoreChanges', file.more) }}\n </p>\n </div>\n <button\n v-if=\"hiddenRows > 0\"\n type=\"button\"\n class=\"pk-tool-chat-file__more\"\n :aria-expanded=\"showAll\"\n @click=\"showAll = !showAll\">\n <VvIcon\n :name=\"\n showAll ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\n \"\n class=\"text-16\"\n aria-hidden=\"true\" />\n {{\n showAll\n ? $t('action.showLess')\n : $t('action.showMore', { count: hiddenRows })\n }}\n </button>\n <p\n v-for=\"reminder in file.reminders\"\n :key=\"reminder\"\n class=\"pk-tool-chat-file__reminder\">\n <VvIcon\n name=\"ri:information-line\"\n class=\"pk-tool-chat-file__reminder-icon\"\n aria-hidden=\"true\" />\n {{ reminder }}\n </p>\n </section>\n <p v-else-if=\"file.summary\" class=\"text-12 text-word-3 mt-xs mb-0\">\n {{ file.summary }}\n </p>\n </div>\n</template>\n\n<style lang=\"scss\">\n // One frame (DESIGN.md, principle 4): a hairline at surface-3, rounded-lg,\n // a solid ground over the dots of the chat, as wide as a short paragraph\n // while the file above keeps its 280px. Inside it every divider is one\n // hairline at surface-2.\n .pk-tool-chat-file__changes {\n max-width: 36rem;\n overflow: hidden;\n border: var(--border) solid var(--color-surface-3);\n border-radius: var(--rounded-lg);\n background-color: var(--color-surface);\n font-size: var(--text-12);\n }\n\n .pk-tool-chat-file__summary {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-3);\n color: var(--color-word-2);\n font-size: var(--text-12);\n font-weight: var(--font-medium);\n\n // A restore says only what it wrote back\n &:last-child {\n border-bottom: 0;\n }\n }\n\n // Bounded, so fifty changes scroll inside the frame\n .pk-tool-chat-file__scroll {\n max-height: 20rem;\n overflow-y: auto;\n }\n\n .pk-tool-chat-file__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n text-align: start;\n vertical-align: top;\n overflow-wrap: anywhere;\n }\n\n // Told apart by its weight and colour, no heavier rule\n th {\n color: var(--color-word-3);\n font-weight: var(--font-medium);\n }\n\n tbody:last-child tr:last-child td {\n border-bottom: 0;\n }\n }\n\n // The name of a sheet heads its rows, one step of surface under it\n .pk-tool-chat-file__table .pk-tool-chat-file__sheet {\n padding-block: var(--spacing-6);\n background-color: var(--color-surface-1);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__cell {\n width: 1%;\n color: var(--color-word-2);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__before {\n width: 50%;\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__after {\n width: 50%;\n color: var(--color-word-1);\n }\n\n .pk-tool-chat-file__paragraphs {\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n .pk-tool-chat-file__paragraph {\n display: grid;\n grid-template-columns: minmax(4rem, max-content) 1fr;\n gap: var(--spacing-4) var(--spacing-md);\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n\n &:last-child {\n border-bottom: 0;\n }\n }\n\n .pk-tool-chat-file__what {\n color: var(--color-word-3);\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__text {\n min-width: 0;\n color: var(--color-word-2);\n overflow-wrap: anywhere;\n }\n\n // Marked as Word marks a revision, struck where words went and\n // underlined where they came, in the red and green of a comparison: the\n // change is what the row exists to report, the verdict exception of\n // DESIGN.md (principle 2). The readable text tokens hold the contrast in\n // both themes. The base styles take the line off `del`.\n .pk-tool-chat-file__removed {\n color: var(--u-danger-text);\n text-decoration: line-through;\n }\n\n .pk-tool-chat-file__added {\n color: var(--u-success-text);\n font-weight: var(--font-medium);\n text-decoration: underline;\n text-underline-offset: 0.2em;\n }\n\n .pk-tool-chat-file__removed + .pk-tool-chat-file__added {\n margin-inline-start: var(--spacing-4);\n }\n\n .pk-tool-chat-file__note {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__more {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: var(--spacing-4);\n width: 100%;\n padding: var(--spacing-8) var(--spacing-12);\n border: 0;\n border-top: var(--border) solid var(--color-surface-2);\n background: none;\n color: var(--color-word-2);\n font: inherit;\n cursor: pointer;\n transition: background-color var(--duration-150) var(--ease-out);\n\n &:hover {\n background-color: var(--color-surface-1);\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--input-focus-color);\n outline-offset: calc(var(--spacing-2) * -1);\n }\n }\n\n .pk-tool-chat-file__reminder {\n display: flex;\n align-items: flex-start;\n gap: var(--spacing-8);\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__reminder-ic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;IAIhDc,EAAA,QAAU,KADpB9G,EAAA,GAAAC,EAiBS,UAAA;;KAfL,MAAK;KACL,OAAM;KACL,iBAAe+D,EAAA;KACf,SAAK,AAAAwD,EAAA,QAAA,MAAE,EAAA,QAAO,CAAIxD,EAAA;I,IACnB9D,EAKyBiH,GAAA;KAJpB,MAA+BnD,EAAA,QAAO,uBAAA;KAGvC,OAAM;KACN,eAAY;I,uBAASvD,EAAA,MACzBJ,EACI2D,EAAA,QAAkC1D,EAAAyD,CAAA,CAAE,CAAA,iBAAA,IAA8CzD,EAAAyD,CAAA,CAAE,CAAA,mBAAA,EAAA,OAA6B+C,EAAA,MAAU,CAAA,CAAA,GAAA,CAAA,C;KAKnI9G,EAAA,EAAA,GAAAC,EASIM,GAAA,MAAAC,EARmBwF,EAAA,MAAK,YAAjB,OADXhG,EAAA,GAAAC,EASI,KAAA;KAPC,KAAKwH;KACN,OAAM;I,IACNvH,EAGyBiH,GAAA;KAFrB,MAAK;KACL,OAAM;KACN,eAAY;I,IAAS1G,EAAA,MACzBJ,EAAGoH,CAAQ,GAAA,CAAA,C;G,MAGLzB,EAAA,MAAK,WAAnBhG,EAAA,GAAAC,EAEI,KAFJwD,GAEIpD,EADG2F,EAAA,MAAK,OAAO,GAAA,CAAA,K"}
@@ -4,7 +4,7 @@ import { r as g } from "./vue-i18n-CDYWo9pX.js";
4
4
  import { S as _ } from "./Agent-DJ6TBi6l.js";
5
5
  // ../../packages/components/src/chat/PkToolRequestGeolocation.vue?vue&type=script&setup=true&lang.ts
6
6
  s(), l(), r();
7
- var v = { class: "flex items-center gap-6 text-12 text-word-3 border border-surface-3 rounded-xl px-sm py-10" }, y = /* @__PURE__ */ d({
7
+ var v = { class: "flex items-center gap-6 text-12 text-word-3 border border-surface-3 rounded-xl px-sm py-10 bg-surface" }, y = /* @__PURE__ */ d({
8
8
  __name: "PkToolRequestGeolocation",
9
9
  props: {
10
10
  part: { type: null },
@@ -63,4 +63,4 @@ var v = { class: "flex items-center gap-6 text-12 text-word-3 border border-surf
63
63
  });
64
64
  export { y as default };
65
65
 
66
- //# sourceMappingURL=PkToolRequestGeolocation-Dj5OxEMP.js.map
66
+ //# sourceMappingURL=PkToolRequestGeolocation-ZYzgy6kw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PkToolRequestGeolocation-Dj5OxEMP.js","names":["$n","_openBlock","_createElementBlock","_Fragment","_createVNode","_createElementVNode","_toDisplayString","_unref","_createTextVNode","De","onMounted","createVNode","init_shared_esm_bundler","Fragment","createBaseVNode","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","isVoiceRenderAck","_hoisted_1","PkToolRequestGeolocation_default","__emit","props","__props","emit","$t","toolPart","state","isRenderAck","isOutputAvailable","successOutput","out","errorOutput","mapGeolocationError","code","position","city","latitude","longitude","error","_component_VvIcon","_ctx"],"sources":["../../../../packages/components/src/chat/PkToolRequestGeolocation.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, onMounted } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n\n import type { ReverseGeocodeFn } from 'utils/src/device-context'\n\n type GeolocationOutput =\n | {\n latitude: number\n longitude: number\n accuracy?: number\n city?: string\n }\n | { error: 'permission_denied' | 'position_unavailable' | 'timeout' }\n\n const props = defineProps<{\n part: unknown\n reverseGeocode?: ReverseGeocodeFn\n /**\n * Whether a voice call is on the line right now. A request drawn\n * during a call arrives already resolved with the render ack, and the\n * browser prompt must fire only while the caller who was asked is\n * still there: reopening the conversation later must not ask again.\n */\n callLive?: boolean\n }>()\n\n const emit = defineEmits<{\n result: [output: GeolocationOutput]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n input?: { reason?: string }\n /** The position, or the voice render ack (a string). */\n output?: GeolocationOutput | string\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n\n /**\n * The ack is not a position: it only says the card was drawn during a\n * call (see `isVoiceRenderAck`, same rule as the forms). Besides gating\n * the prompt below, it must be kept away from the output parsing: `in`\n * on a string throws, which broke this card on every spoken turn.\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n const isOutputAvailable = computed(\n () => state.value === 'output-available' && !isRenderAck.value,\n )\n\n const successOutput = computed(() => {\n const out = toolPart.value.output\n if (!out || typeof out === 'string' || 'error' in out) {\n return undefined\n }\n return out\n })\n\n const errorOutput = computed(() => {\n const out = toolPart.value.output\n if (!out || typeof out === 'string' || !('error' in out)) {\n return undefined\n }\n return out\n })\n\n /** Maps GeolocationPositionError.code to a typed string */\n function mapGeolocationError(\n code: number,\n ): 'permission_denied' | 'position_unavailable' | 'timeout' {\n if (code === 1) {\n return 'permission_denied'\n }\n if (code === 3) {\n return 'timeout'\n }\n return 'position_unavailable'\n }\n\n onMounted(() => {\n const isAwaitingPosition =\n state.value === 'input-available' ||\n (isRenderAck.value && props.callLive === true)\n if (!isAwaitingPosition) {\n return\n }\n\n if (!navigator.geolocation) {\n emit('result', { error: 'position_unavailable' })\n return\n }\n\n navigator.geolocation.getCurrentPosition(\n async (position) => {\n const { latitude, longitude, accuracy } = position.coords\n const city = props.reverseGeocode\n ? await props\n .reverseGeocode(latitude, longitude)\n .catch(() => undefined)\n : undefined\n emit('result', { latitude, longitude, accuracy, city })\n },\n (error) => {\n emit('result', { error: mapGeolocationError(error.code) })\n },\n { timeout: 15000 },\n )\n })\n</script>\n\n<template>\n <div\n class=\"flex items-center gap-6 text-12 text-word-3 border border-surface-3 rounded-xl px-sm py-10\">\n <!-- Loading state -->\n <template v-if=\"!isOutputAvailable\">\n <VvIcon name=\"loading-loop\" class=\"text-16\" />\n <span>{{ $t('messagePart.requestGeolocation') }}</span>\n </template>\n\n <!-- Success state -->\n <template v-else-if=\"successOutput\">\n <VvIcon name=\"ri:map-pin-line\" class=\"text-16\" />\n <span>\n {{\n $n(successOutput.latitude, {\n style: 'decimal',\n minimumFractionDigits: 5,\n maximumFractionDigits: 5,\n })\n }},\n {{\n $n(successOutput.longitude, {\n style: 'decimal',\n minimumFractionDigits: 5,\n maximumFractionDigits: 5,\n })\n }}\n <template v-if=\"successOutput.accuracy !== undefined\">\n (±{{\n $n(successOutput.accuracy, {\n style: 'unit',\n unit: 'meter',\n })\n }})\n </template>\n </span>\n </template>\n\n <!-- Error state -->\n <template v-else-if=\"errorOutput\">\n <VvIcon\n name=\"ri:error-warning-line\"\n class=\"w-16 h-16 shrink-0 text-danger\" />\n <span>\n {{\n errorOutput.error === 'permission_denied'\n ? $t('message.geolocationPermissionDenied')\n : $t('message.geolocationUnavailable')\n }}\n </span>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;EAgBI,IAAM8B,IAAQC,GAYRC,IAAOH,GAIP,EAAE,GAAGI,MAAOR,EAAQ,EAAE,UAAU,SAAS,CAAC,GAE1CS,IAAWnB,QACNe,EAAM,IAMhB,GAEKK,IAAQpB,QAAemB,EAAS,MAAM,SAAS,SAAS,GAQxDE,IAAcrB,QAAeW,EAAiBQ,EAAS,MAAM,MAAM,CAAC,GAEpEG,IAAoBtB,QAChBoB,EAAM,UAAU,sBAAsB,CAACC,EAAY,KAC7D,GAEME,IAAgBvB,QAAe;GACjC,IAAMwB,IAAML,EAAS,MAAM;GAC3B,IAAI,GAACK,KAAO,OAAOA,KAAQ,YAAY,WAAWA,IAGlD,OAAOA;EACX,CAAC,GAEKC,IAAczB,QAAe;GAC/B,IAAMwB,IAAML,EAAS,MAAM;GAC3B,IAAKK,KAAO,OAAOA,KAAQ,YAAc,WAAWA,GAGpD,OAAOA;EACX,CAAC;EAGD,SAASE,EACL,GACwD;GAOxD,OANIC,MAAS,IACF,sBAEPA,MAAS,IACF,YAEJ;EACX;E,OAEAhC,QAAgB;GAIZ,CAFIyB,EAAM,UAAU,qBACfC,EAAY,SAASN,EAAM,aAAa,QAKxC,UAAU,cAKf,UAAU,YA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AAA,CAAE,CAAA,gCAAA,CAAA,GAAA,CAAA,C,uBAzCtJhC,EAAA,GAAAC,EAGWC,GAAA,EAAA,KAAA,EAAA,GAAA,CAFPC,EAA8C4C,GAAA;IAAtC,MAAK;IAAe,OAAM;G,IAClC3C,EAAuD,QAAA,MAAAC,EAA9CC,EAAA0B,CAAA,CAAE,CAAA,gCAAA,CAAA,GAAA,CAAA,C"}
1
+ {"version":3,"file":"PkToolRequestGeolocation-ZYzgy6kw.js","names":["$n","_openBlock","_createElementBlock","_Fragment","_createVNode","_createElementVNode","_toDisplayString","_unref","_createTextVNode","De","onMounted","createVNode","init_shared_esm_bundler","Fragment","createBaseVNode","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","isVoiceRenderAck","_hoisted_1","PkToolRequestGeolocation_default","__emit","props","__props","emit","$t","toolPart","state","isRenderAck","isOutputAvailable","successOutput","out","errorOutput","mapGeolocationError","code","position","city","latitude","longitude","error","_component_VvIcon","_ctx"],"sources":["../../../../packages/components/src/chat/PkToolRequestGeolocation.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, onMounted } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n\n import type { ReverseGeocodeFn } from 'utils/src/device-context'\n\n type GeolocationOutput =\n | {\n latitude: number\n longitude: number\n accuracy?: number\n city?: string\n }\n | { error: 'permission_denied' | 'position_unavailable' | 'timeout' }\n\n const props = defineProps<{\n part: unknown\n reverseGeocode?: ReverseGeocodeFn\n /**\n * Whether a voice call is on the line right now. A request drawn\n * during a call arrives already resolved with the render ack, and the\n * browser prompt must fire only while the caller who was asked is\n * still there: reopening the conversation later must not ask again.\n */\n callLive?: boolean\n }>()\n\n const emit = defineEmits<{\n result: [output: GeolocationOutput]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n input?: { reason?: string }\n /** The position, or the voice render ack (a string). */\n output?: GeolocationOutput | string\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n\n /**\n * The ack is not a position: it only says the card was drawn during a\n * call (see `isVoiceRenderAck`, same rule as the forms). Besides gating\n * the prompt below, it must be kept away from the output parsing: `in`\n * on a string throws, which broke this card on every spoken turn.\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n const isOutputAvailable = computed(\n () => state.value === 'output-available' && !isRenderAck.value,\n )\n\n const successOutput = computed(() => {\n const out = toolPart.value.output\n if (!out || typeof out === 'string' || 'error' in out) {\n return undefined\n }\n return out\n })\n\n const errorOutput = computed(() => {\n const out = toolPart.value.output\n if (!out || typeof out === 'string' || !('error' in out)) {\n return undefined\n }\n return out\n })\n\n /** Maps GeolocationPositionError.code to a typed string */\n function mapGeolocationError(\n code: number,\n ): 'permission_denied' | 'position_unavailable' | 'timeout' {\n if (code === 1) {\n return 'permission_denied'\n }\n if (code === 3) {\n return 'timeout'\n }\n return 'position_unavailable'\n }\n\n onMounted(() => {\n const isAwaitingPosition =\n state.value === 'input-available' ||\n (isRenderAck.value && props.callLive === true)\n if (!isAwaitingPosition) {\n return\n }\n\n if (!navigator.geolocation) {\n emit('result', { error: 'position_unavailable' })\n return\n }\n\n navigator.geolocation.getCurrentPosition(\n async (position) => {\n const { latitude, longitude, accuracy } = position.coords\n const city = props.reverseGeocode\n ? await props\n .reverseGeocode(latitude, longitude)\n .catch(() => undefined)\n : undefined\n emit('result', { latitude, longitude, accuracy, city })\n },\n (error) => {\n emit('result', { error: mapGeolocationError(error.code) })\n },\n { timeout: 15000 },\n )\n })\n</script>\n\n<template>\n <div\n class=\"flex items-center gap-6 text-12 text-word-3 border border-surface-3 rounded-xl px-sm py-10 bg-surface\">\n <!-- Loading state -->\n <template v-if=\"!isOutputAvailable\">\n <VvIcon name=\"loading-loop\" class=\"text-16\" />\n <span>{{ $t('messagePart.requestGeolocation') }}</span>\n </template>\n\n <!-- Success state -->\n <template v-else-if=\"successOutput\">\n <VvIcon name=\"ri:map-pin-line\" class=\"text-16\" />\n <span>\n {{\n $n(successOutput.latitude, {\n style: 'decimal',\n minimumFractionDigits: 5,\n maximumFractionDigits: 5,\n })\n }},\n {{\n $n(successOutput.longitude, {\n style: 'decimal',\n minimumFractionDigits: 5,\n maximumFractionDigits: 5,\n })\n }}\n <template v-if=\"successOutput.accuracy !== undefined\">\n (±{{\n $n(successOutput.accuracy, {\n style: 'unit',\n unit: 'meter',\n })\n }})\n </template>\n </span>\n </template>\n\n <!-- Error state -->\n <template v-else-if=\"errorOutput\">\n <VvIcon\n name=\"ri:error-warning-line\"\n class=\"w-16 h-16 shrink-0 text-danger\" />\n <span>\n {{\n errorOutput.error === 'permission_denied'\n ? $t('message.geolocationPermissionDenied')\n : $t('message.geolocationUnavailable')\n }}\n </span>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;EAgBI,IAAM8B,IAAQC,GAYRC,IAAOH,GAIP,EAAE,GAAGI,MAAOR,EAAQ,EAAE,UAAU,SAAS,CAAC,GAE1CS,IAAWnB,QACNe,EAAM,IAMhB,GAEKK,IAAQpB,QAAemB,EAAS,MAAM,SAAS,SAAS,GAQxDE,IAAcrB,QAAeW,EAAiBQ,EAAS,MAAM,MAAM,CAAC,GAEpEG,IAAoBtB,QAChBoB,EAAM,UAAU,sBAAsB,CAACC,EAAY,KAC7D,GAEME,IAAgBvB,QAAe;GACjC,IAAMwB,IAAML,EAAS,MAAM;GAC3B,IAAI,GAACK,KAAO,OAAOA,KAAQ,YAAY,WAAWA,IAGlD,OAAOA;EACX,CAAC,GAEKC,IAAczB,QAAe;GAC/B,IAAMwB,IAAML,EAAS,MAAM;GAC3B,IAAKK,KAAO,OAAOA,KAAQ,YAAc,WAAWA,GAGpD,OAAOA;EACX,CAAC;EAGD,SAASE,EACL,GACwD;GAOxD,OANIC,MAAS,IACF,sBAEPA,MAAS,IACF,YAEJ;EACX;E,OAEAh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AAAC,EAJCkC,EAAA,MAAY,UAAK,sBAAmDjC,EAAA0B,CAAA,CAAE,CAAA,qCAAA,IAAkE1B,EAAA0B,CAAA,CAAE,CAAA,gCAAA,CAAA,GAAA,CAAA,C,uBAzCtJhC,EAAA,GAAAC,EAGWC,GAAA,EAAA,KAAA,EAAA,GAAA,CAFPC,EAA8C4C,GAAA;IAAtC,MAAK;IAAe,OAAM;G,IAClC3C,EAAuD,QAAA,MAAAC,EAA9CC,EAAA0B,CAAA,CAAE,CAAA,gCAAA,CAAA,GAAA,CAAA,C"}
@@ -2,7 +2,7 @@ import { t as e } from "./VvButtonLocalized-D_gumqSJ.js";
2
2
  import { S as t, Tt as n, _ as r, f as i, g as a, h as o, k as s, kt as c, ot as l, v as u, w as d, wt as f, y as p, z as m } from "./vue.runtime.esm-bundler-DZgpK-ja.js";
3
3
  import { r as h } from "./vue-i18n-CDYWo9pX.js";
4
4
  import { D as g, _, i as v } from "./dist-CR8l0inH.js";
5
- import { t as y } from "./PkChatbotFilePreview-CLUH7cTq.js";
5
+ import { t as y } from "./PkChatbotFilePreview-5mhg2XeB.js";
6
6
  // ../../packages/components/src/chat/PkToolShareDocument.vue?vue&type=script&setup=true&lang.ts
7
7
  s(), l(), n();
8
8
  var b = {
@@ -60,4 +60,4 @@ var b = {
60
60
  });
61
61
  export { C as default };
62
62
 
63
- //# sourceMappingURL=PkToolShareDocument-CYBU4LPO.js.map
63
+ //# sourceMappingURL=PkToolShareDocument-COy3yKqq.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PkToolShareDocument-CYBU4LPO.js","names":["_openBlock","_createElementBlock","_createBlock","_Fragment","_createVNode","PkChatbotFilePreview","_createElementVNode","_toDisplayString","_unref","VvButtonLocalized","createVNode","init_shared_esm_bundler","createBlock","Fragment","createBaseVNode","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createElementBlock","openBlock","useI18n","useIntervalFn","useClipboard","PkChatbotFilePreview_default","_hoisted_1","_hoisted_2","_hoisted_3","PkToolShareDocument_default","props","__props","$t","$d","shared","part","expiresAt","now","useNow","tick","isLinkValid","download","documentId","onDownload","_component_VvButton","copied","_cache","copy"],"sources":["../../../../packages/components/src/chat/PkToolShareDocument.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useClipboard, useIntervalFn, useNow } from '@vueuse/core'\n import PkChatbotFilePreview from './PkChatbotFilePreview.vue'\n\n /** What `shareDocument` returns that the card shows. */\n type SharedDocument = {\n documentId: string\n name: string\n /** `file`: a stored file behind a signed link; `url`: a web page. */\n source: 'file' | 'url'\n mimeType?: string\n url: string\n /** ISO date the signed link stops working; `null` for a web page. */\n expiresAt: string | null\n /** The sub-agent holding the document, when it is not the agent's. */\n subAgentName?: string\n }\n\n /**\n * A knowledge base document the agent handed over with `shareDocument`.\n * Download goes through `onDownload` when the host gives it: the sources\n * route, authenticated, which keeps working for as long as the document\n * stays with the agent, also after the signed link has expired. A\n * sub-agent's document downloads through the signed link instead, since\n * that route checks the agent of the chat. The signed link is what \"Copy\n * link\" copies, until it expires. A web page opens at its own address.\n */\n const props = defineProps<{\n part: unknown\n onDownload?: (documentId: string) => void | Promise<void>\n }>()\n\n const { t: $t, d: $d } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const shared = computed(() => {\n const part = props.part as {\n state?: string\n output?: Partial<SharedDocument>\n }\n return part.state === 'output-available' && part.output?.url\n ? (part.output as SharedDocument)\n : undefined\n })\n\n const expiresAt = computed(() =>\n shared.value?.expiresAt ? new Date(shared.value.expiresAt) : undefined,\n )\n // A card left open stops offering the link within a minute of its expiry;\n // the download keeps working.\n const now = useNow({ scheduler: (tick) => useIntervalFn(tick, 60_000) })\n const isLinkValid = computed(\n () =>\n expiresAt.value !== undefined &&\n expiresAt.value.getTime() > now.value.getTime(),\n )\n\n const download = computed(() => {\n const { onDownload } = props\n const documentId = shared.value?.documentId\n return onDownload && documentId && !shared.value?.subAgentName\n ? () => onDownload(documentId)\n : undefined\n })\n</script>\n\n<template>\n <div v-if=\"shared\" class=\"pk-tool-share-document\">\n <VvButton\n v-if=\"shared.source === 'url'\"\n :href=\"shared.url\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n icon=\"external-link\"\n icon-position=\"right\"\n :label=\"shared.name\"\n modifiers=\"link\" />\n <template v-else>\n <PkChatbotFilePreview\n :media-type=\"shared.mimeType ?? 'application/octet-stream'\"\n :url=\"shared.url\"\n :filename=\"shared.name\"\n :on-download=\"download\"\n as-file\n show-download />\n <div\n v-if=\"isLinkValid && expiresAt\"\n class=\"flex items-center justify-between gap-sm mt-xs\">\n <span class=\"text-12 text-word-3\">\n {{\n $t('messagePart.shareDocumentValidUntil', {\n date: $d(expiresAt, 'date-time'),\n })\n }}\n </span>\n <VvButton\n :icon=\"copied ? 'ri:check-line' : 'ri:link'\"\n :label=\"\n copied ? $t('action.copied') : $t('action.copyLink')\n \"\n modifiers=\"action-quiet-small\"\n class=\"shrink-0\"\n @click=\"copy(shared.url)\" />\n </div>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EA6BI,IAAMgC,IAAQC,GAKR,EAAE,GAAGC,GAAOC,MAAOX,EAAQ,EAAE,UAAU,SAAS,CAAC,GACjD,EAAE,SAAM,cAAWE,EAAa,GAEhCU,IAASrB,QAAe;GAC1B,IAAMsB,IAAOL,EAAM;GAInB,OAAOK,EAAK,UAAU,sBAAsBA,EAAK,QAAQ,MAClDA,EAAK,SACN,KAAA;EACV,CAAC,GAEKC,IAAYvB,QACdqB,EAAO,OAAO,YAAY,IAAI,KAAKA,EAAO,MAAM,SAAS,IAAI,KAAA,CACjE,GAGMG,IAAMC,EAAO,EAAE,YAAY,MAASf,EAAcgB,GAAM,GAAM,EAAE,CAAC,GACjEC,IAAc3B,QAEZuB,EAAU,UAAU,KAAA,KACpBA,EAAU,MAAM,QAAQ,IAAIC,EAAI,MAAM,QAAQ,CACtD,GAEMI,IAAW5B,QAAe;GAC5B,IAAM,EAAE,kBAAeiB,GACjBY,IAAaR,EAAO,OAAO;GACjC,OAAOS,KAAcD,KAAc,CAACR,EAAO,OAAO,qBACtCS,EAAWD,CAAU,IAC3B,KAAA;EACV,CAAC;;;GAIU,OAAAR,EAAA,SAAXpC,EAAA,GAAAC,EAsCM,OAtCN2B,GAsCM,CApCQQ,EAAA,MAAO,WAAM,SADvBpC,EAAA,GAAAE,EAQuB4C,GAAA;;IANlB,MAAMV,EAAA,MAAO;IACd,QAAO;IACP,KAAI;IACJ,MAAK;IACL,iBAAc;IACb,OAAOA,EAAA,MAAO;IACf,WAAU;G,mCACdpC,EAAA,GAAAC,EA2BWE,GAAA,EAAA,KAAA,EAAA,GAAA,CA1BPC,EAMoBC,GAAA;IALf,cAAY+B,EAAA,MAAO,YAAQ;IAC3B,KAAKA,EAAA,MAAO;IACZ,UAAUA,EAAA,MAAO;IACjB,eAAaO,EAAA;IACd,WAAA;IACA,iBAAA;;;;;;G,IAEMD,EAAA,SAAeJ,EAAA,SADzBtC,EAAA,GAAAC,EAkBM,OAlBN4B,GAkBM,CAfFvB,EAMO,QANPwB,GAMOvB,EAJCC,EAAA0B,CAAA,CAAE,CAAA,uCAAA,EAA4E,MAAA1B,EAAA2B,CAAA,CAAE,CAACG,EAAA,OAAS,WAAA,E,SAKlGlC,EAOgC0C,GAAA;IAN3B,MAAMtC,EAAAuC,CAAA,IAAM,kBAAA;IACZ,OAAgCvC,EAAAuC,CAAA,IAASvC,EAAA0B,CAAA,CAAE,CAAA,eAAA,IAAoB1B,EAAA0B,CAAA,CAAE,CAAA,iBAAA;IAGlE,WAAU;IACV,OAAM;IACL,SAAK,AAAAc,EAAA,QAAA,MAAExC,EAAAyC,CAAA,CAAI,CAACb,EAAA,MAAO,GAAG"}
1
+ {"version":3,"file":"PkToolShareDocument-COy3yKqq.js","names":["_openBlock","_createElementBlock","_createBlock","_Fragment","_createVNode","PkChatbotFilePreview","_createElementVNode","_toDisplayString","_unref","VvButtonLocalized","createVNode","init_shared_esm_bundler","createBlock","Fragment","createBaseVNode","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createElementBlock","openBlock","useI18n","useIntervalFn","useClipboard","PkChatbotFilePreview_default","_hoisted_1","_hoisted_2","_hoisted_3","PkToolShareDocument_default","props","__props","$t","$d","shared","part","expiresAt","now","useNow","tick","isLinkValid","download","documentId","onDownload","_component_VvButton","copied","_cache","copy"],"sources":["../../../../packages/components/src/chat/PkToolShareDocument.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useClipboard, useIntervalFn, useNow } from '@vueuse/core'\n import PkChatbotFilePreview from './PkChatbotFilePreview.vue'\n\n /** What `shareDocument` returns that the card shows. */\n type SharedDocument = {\n documentId: string\n name: string\n /** `file`: a stored file behind a signed link; `url`: a web page. */\n source: 'file' | 'url'\n mimeType?: string\n url: string\n /** ISO date the signed link stops working; `null` for a web page. */\n expiresAt: string | null\n /** The sub-agent holding the document, when it is not the agent's. */\n subAgentName?: string\n }\n\n /**\n * A knowledge base document the agent handed over with `shareDocument`.\n * Download goes through `onDownload` when the host gives it: the sources\n * route, authenticated, which keeps working for as long as the document\n * stays with the agent, also after the signed link has expired. A\n * sub-agent's document downloads through the signed link instead, since\n * that route checks the agent of the chat. The signed link is what \"Copy\n * link\" copies, until it expires. A web page opens at its own address.\n */\n const props = defineProps<{\n part: unknown\n onDownload?: (documentId: string) => void | Promise<void>\n }>()\n\n const { t: $t, d: $d } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const shared = computed(() => {\n const part = props.part as {\n state?: string\n output?: Partial<SharedDocument>\n }\n return part.state === 'output-available' && part.output?.url\n ? (part.output as SharedDocument)\n : undefined\n })\n\n const expiresAt = computed(() =>\n shared.value?.expiresAt ? new Date(shared.value.expiresAt) : undefined,\n )\n // A card left open stops offering the link within a minute of its expiry;\n // the download keeps working.\n const now = useNow({ scheduler: (tick) => useIntervalFn(tick, 60_000) })\n const isLinkValid = computed(\n () =>\n expiresAt.value !== undefined &&\n expiresAt.value.getTime() > now.value.getTime(),\n )\n\n const download = computed(() => {\n const { onDownload } = props\n const documentId = shared.value?.documentId\n return onDownload && documentId && !shared.value?.subAgentName\n ? () => onDownload(documentId)\n : undefined\n })\n</script>\n\n<template>\n <div v-if=\"shared\" class=\"pk-tool-share-document\">\n <VvButton\n v-if=\"shared.source === 'url'\"\n :href=\"shared.url\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n icon=\"external-link\"\n icon-position=\"right\"\n :label=\"shared.name\"\n modifiers=\"link\" />\n <template v-else>\n <PkChatbotFilePreview\n :media-type=\"shared.mimeType ?? 'application/octet-stream'\"\n :url=\"shared.url\"\n :filename=\"shared.name\"\n :on-download=\"download\"\n as-file\n show-download />\n <div\n v-if=\"isLinkValid && expiresAt\"\n class=\"flex items-center justify-between gap-sm mt-xs\">\n <span class=\"text-12 text-word-3\">\n {{\n $t('messagePart.shareDocumentValidUntil', {\n date: $d(expiresAt, 'date-time'),\n })\n }}\n </span>\n <VvButton\n :icon=\"copied ? 'ri:check-line' : 'ri:link'\"\n :label=\"\n copied ? $t('action.copied') : $t('action.copyLink')\n \"\n modifiers=\"action-quiet-small\"\n class=\"shrink-0\"\n @click=\"copy(shared.url)\" />\n </div>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EA6BI,IAAMgC,IAAQC,GAKR,EAAE,GAAGC,GAAOC,MAAOX,EAAQ,EAAE,UAAU,SAAS,CAAC,GACjD,EAAE,SAAM,cAAWE,EAAa,GAEhCU,IAASrB,QAAe;GAC1B,IAAMsB,IAAOL,EAAM;GAInB,OAAOK,EAAK,UAAU,sBAAsBA,EAAK,QAAQ,MAClDA,EAAK,SACN,KAAA;EACV,CAAC,GAEKC,IAAYvB,QACdqB,EAAO,OAAO,YAAY,IAAI,KA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E,WAAU;IACV,OAAM;IACL,SAAK,AAAAc,EAAA,QAAA,MAAExC,EAAAyC,CAAA,CAAI,CAACb,EAAA,MAAO,GAAG"}
@@ -1,7 +1,7 @@
1
1
  import { t as e } from "./VvButtonLocalized-D_gumqSJ.js";
2
2
  import { Et as t, Q as n, S as r, Tt as i, X as a, _ as o, g as s, gt as c, h as l, k as u, kt as d, ot as f, w as p, x as m, y as h, z as g } from "./vue.runtime.esm-bundler-DZgpK-ja.js";
3
3
  import { i as _ } from "./dist-CR8l0inH.js";
4
- import { n as v, r as y, t as b } from "./PkStreamingMarkdown-Bekhx_vG.js";
4
+ import { n as v, r as y, t as b } from "./PkStreamingMarkdown-DLyBjSaH.js";
5
5
  // ../../packages/components/src/chat/PkCode.vue?vue&type=script&setup=true&lang.ts
6
6
  u(), i(), f();
7
7
  var x = ["innerHTML"], S = /* @__PURE__ */ p({
@@ -39,7 +39,7 @@ var x = ["innerHTML"], S = /* @__PURE__ */ p({
39
39
  });
40
40
  // ../../packages/components/src/chat/PkToolShowArtifact.vue?vue&type=script&setup=true&lang.ts
41
41
  u(), i(), f();
42
- var C = { class: "border border-surface-3 rounded-xl w-full overflow-hidden" }, w = { class: "px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center" }, T = { class: "flex flex-col items-start gap-4" }, E = { class: "text-10 opacity-60 font-normal" }, D = { class: "px-sm py-10 bg-surface" }, O = /* @__PURE__ */ p({
42
+ var C = { class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-surface" }, w = { class: "px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center" }, T = { class: "flex flex-col items-start gap-4" }, E = { class: "text-10 opacity-60 font-normal" }, D = { class: "px-sm py-10 bg-surface" }, O = /* @__PURE__ */ p({
43
43
  __name: "PkToolShowArtifact",
44
44
  props: { part: { type: null } },
45
45
  setup(n) {
@@ -107,4 +107,4 @@ var C = { class: "border border-surface-3 rounded-xl w-full overflow-hidden" },
107
107
  });
108
108
  export { O as default };
109
109
 
110
- //# sourceMappingURL=PkToolShowArtifact-BkGtejtb.js.map
110
+ //# sourceMappingURL=PkToolShowArtifact-CePvZJJ9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PkToolShowArtifact-BkGtejtb.js","names":["$attrs","_openBlock","_createElementBlock","_normalizeClass","_createTextVNode","_createElementVNode","$t","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","_createBlock","PkCode","PkStreamingMarkdown","_normalizeClass","VvButtonLocalized","normalizeClass","watch","createVNode","init_shared_esm_bundler","useTemplateRef","createBlock","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","defineComponent","createTextVNode","createElementBlock","openBlock","useClipboard","copyRich","toClipboardHtml","PkStreamingMarkdown_default","_hoisted_1$1","PkCode_default","props","__props","highlightedHtml","hasCode","highlight","hljs","result","_ctx","_cache","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","PkToolShowArtifact_default","copiedText","toolPart","ARTIFACT_TYPES","artifactTypeKey","type","languageLabel","isCodeType","isMarkdownType","markdownEl","copiedRich","copied","copyContent","content","copy","codeLanguage","_component_VvButton"],"sources":["../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkToolShowArtifact.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref, watch } from 'vue'\n\n defineOptions({\n inheritAttrs: false,\n })\n\n const props = defineProps<{\n code: unknown\n language: string\n line?: boolean\n }>()\n\n const highlightedHtml = ref('')\n\n const hasCode = computed(() => {\n if (typeof props.code === 'string') {\n return props.code\n }\n return JSON.stringify(props.code, null, 2)\n })\n\n async function highlight() {\n const hljs = (await import('highlight.js/lib/common')).default\n try {\n const result = props.language\n ? hljs.highlight(hasCode.value, { language: props.language })\n : hljs.highlightAuto(hasCode.value)\n highlightedHtml.value = result.value\n } catch {\n highlightedHtml.value = hasCode.value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n }\n }\n\n watch(hasCode, highlight, { immediate: true })\n</script>\n\n<template>\n <pre\n :class=\"\n $attrs.class\n ? $attrs.class\n : 'font-mono leading-snug text-smaller bg-surface-1'\n \">\n <code :class=\"['hljs', line ? 'whitespace-pre-line' : 'whitespace-pre', language]\" v-html=\"highlightedHtml\"></code>\n </pre>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import PkCode from './PkCode.vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n import { copyRich, toClipboardHtml } from './richCopy'\n\n const { copy, copied: copiedText } = useClipboard()\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title: string\n content: string\n artifactType: string\n language?: string\n }\n }\n return part\n })\n\n // The kind under the title, in the reader's language (`artifactType.*`)\n const ARTIFACT_TYPES = [\n 'code',\n 'document',\n 'markdown',\n 'json',\n 'xml',\n 'csv',\n 'html',\n 'yaml',\n 'sql',\n 'text',\n ]\n const artifactTypeKey = computed(() => {\n const type = toolPart.value.input?.artifactType\n return type && ARTIFACT_TYPES.includes(type) ? type : 'other'\n })\n\n const languageLabel = computed(() => {\n if (!toolPart.value.input?.language) {\n return ''\n }\n return ` (${toolPart.value.input.language})`\n })\n\n const isCodeType = computed(() => {\n return (\n toolPart.value.input?.artifactType === 'code' ||\n toolPart.value.input?.artifactType === 'json' ||\n toolPart.value.input?.artifactType === 'xml' ||\n toolPart.value.input?.artifactType === 'yaml' ||\n toolPart.value.input?.artifactType === 'html' ||\n toolPart.value.input?.artifactType === 'sql'\n )\n })\n\n const isMarkdownType = computed(() => {\n return toolPart.value.input?.artifactType === 'markdown'\n })\n\n // A markdown document goes to Word and Outlook as it is drawn, with its\n // markdown as the plain text (`richCopy.ts`); any other type as its text\n const markdownEl = useTemplateRef<HTMLElement>('markdownEl')\n const copiedRich = ref(false)\n const copied = computed(() => copiedText.value || copiedRich.value)\n\n async function copyContent() {\n const content = toolPart.value?.input?.content || ''\n if (!isMarkdownType.value || !markdownEl.value) {\n await copy(content)\n return\n }\n if (\n !(await copyRich({\n html: toClipboardHtml([markdownEl.value]),\n text: content,\n }))\n ) {\n return\n }\n copiedRich.value = true\n setTimeout(() => {\n copiedRich.value = false\n }, 1500)\n }\n\n const codeLanguage = computed(() => {\n if (toolPart.value.input?.language) {\n return toolPart.value.input.language\n }\n // Map artifact types to highlight.js languages\n const languageMap: Record<string, string> = {\n json: 'json',\n xml: 'xml',\n yaml: 'yaml',\n html: 'html',\n sql: 'sql',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'plaintext'\n }\n return languageMap[toolPart.value.input.artifactType] || 'plaintext'\n })\n</script>\n\n<template>\n <div class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center\">\n <div class=\"flex flex-col items-start gap-4\">\n <span>{{ toolPart?.input?.title }}</span>\n <span class=\"text-10 opacity-60 font-normal\">\n {{ $t(`artifactType.${artifactTypeKey}`)\n }}{{ languageLabel }}\n </span>\n </div>\n <VvButton\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n modifiers=\"action-quiet-small\"\n :title=\"$t('action.copy')\"\n class=\"shrink-0\"\n @click=\"copyContent\" />\n </div>\n <div class=\"px-sm py-10 bg-surface\">\n <PkCode\n v-if=\"isCodeType\"\n :code=\"toolPart?.input?.content\"\n :language=\"codeLanguage\" />\n <div v-else-if=\"isMarkdownType\" ref=\"markdownEl\">\n <PkStreamingMarkdown\n :markdown=\"toolPart?.input?.content\"\n class=\"wysiwyg text-word-2\" />\n </div>\n <pre\n v-else\n class=\"text-word-2 whitespace-pre-wrap break-words\"\n :class=\"{\n italic:\n toolPart?.input?.artifactType === 'document' ||\n toolPart?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/B9C,EAGO,QAHP0C,GAGOzC,EAFAJ,EAAAA,GAAE,gBAAiBmD,EAAA,OAAe,CAAA,IAAA/C,EAChCiD,EAAA,KAAa,GAAA,CAAA,C,IAG1BhD,EAM2B0D,GAAA;IALtB,MAAML,EAAA,QAAM,kBAAA;IACZ,OAAOA,EAAA,QAAS1D,EAAAA,GAAE,eAAA,IAAoBA,EAAAA,GAAE,aAAA;IACzC,WAAU;IACT,OAAOA,EAAAA,GAAE,aAAA;IACV,OAAM;IACL,SAAO2D;;;;;G,MAEhBxD,EAmBM,OAnBN2C,GAmBM,CAjBQQ,EAAA,SADVrD,EAAA,GAAAK,EAG+BC,GAAA;;IAD1B,MAAM0C,EAAA,OAAU,OAAO;IACvB,UAAUa,EAAA;G,qCACCP,EAAA,SAAhBtD,EAAA,GAAAC,EAIM,OAAA;;IAJ8B,SAAA;IAAJ,KAAIsD;G,IAChCnD,EAEkCG,GAAA;IAD7B,UAAUyC,EAAA,OAAU,OAAO;IAC5B,OAAM;G,qCAEdhD,EAAA,GAAAC,EAQyC,OAAA;;IANrC,OAAKO,EAAA,CAAC,+CAA6C,E,QACWwC,EAAA,OAAU,OAAO,iBAAY,cAA2CA,EAAA,OAAU,OAAO,iBAAY,O;GAK/J,GAAA7C,EAAA6C,EAAA,OAAU,OAAO,OAAO,GAAA,CAAA,E"}
1
+ {"version":3,"file":"PkToolShowArtifact-CePvZJJ9.js","names":["$attrs","_openBlock","_createElementBlock","_normalizeClass","_createTextVNode","_createElementVNode","$t","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","_createBlock","PkCode","PkStreamingMarkdown","_normalizeClass","VvButtonLocalized","normalizeClass","watch","createVNode","init_shared_esm_bundler","useTemplateRef","createBlock","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","defineComponent","createTextVNode","createElementBlock","openBlock","useClipboard","copyRich","toClipboardHtml","PkStreamingMarkdown_default","_hoisted_1$1","PkCode_default","props","__props","highlightedHtml","hasCode","highlight","hljs","result","_ctx","_cache","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","PkToolShowArtifact_default","copiedText","toolPart","ARTIFACT_TYPES","artifactTypeKey","type","languageLabel","isCodeType","isMarkdownType","markdownEl","copiedRich","copied","copyContent","content","copy","codeLanguage","_component_VvButton"],"sources":["../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkToolShowArtifact.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref, watch } from 'vue'\n\n defineOptions({\n inheritAttrs: false,\n })\n\n const props = defineProps<{\n code: unknown\n language: string\n line?: boolean\n }>()\n\n const highlightedHtml = ref('')\n\n const hasCode = computed(() => {\n if (typeof props.code === 'string') {\n return props.code\n }\n return JSON.stringify(props.code, null, 2)\n })\n\n async function highlight() {\n const hljs = (await import('highlight.js/lib/common')).default\n try {\n const result = props.language\n ? hljs.highlight(hasCode.value, { language: props.language })\n : hljs.highlightAuto(hasCode.value)\n highlightedHtml.value = result.value\n } catch {\n highlightedHtml.value = hasCode.value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n }\n }\n\n watch(hasCode, highlight, { immediate: true })\n</script>\n\n<template>\n <pre\n :class=\"\n $attrs.class\n ? $attrs.class\n : 'font-mono leading-snug text-smaller bg-surface-1'\n \">\n <code :class=\"['hljs', line ? 'whitespace-pre-line' : 'whitespace-pre', language]\" v-html=\"highlightedHtml\"></code>\n </pre>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import PkCode from './PkCode.vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n import { copyRich, toClipboardHtml } from './richCopy'\n\n const { copy, copied: copiedText } = useClipboard()\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title: string\n content: string\n artifactType: string\n language?: string\n }\n }\n return part\n })\n\n // The kind under the title, in the reader's language (`artifactType.*`)\n const ARTIFACT_TYPES = [\n 'code',\n 'document',\n 'markdown',\n 'json',\n 'xml',\n 'csv',\n 'html',\n 'yaml',\n 'sql',\n 'text',\n ]\n const artifactTypeKey = computed(() => {\n const type = toolPart.value.input?.artifactType\n return type && ARTIFACT_TYPES.includes(type) ? type : 'other'\n })\n\n const languageLabel = computed(() => {\n if (!toolPart.value.input?.language) {\n return ''\n }\n return ` (${toolPart.value.input.language})`\n })\n\n const isCodeType = computed(() => {\n return (\n toolPart.value.input?.artifactType === 'code' ||\n toolPart.value.input?.artifactType === 'json' ||\n toolPart.value.input?.artifactType === 'xml' ||\n toolPart.value.input?.artifactType === 'yaml' ||\n toolPart.value.input?.artifactType === 'html' ||\n toolPart.value.input?.artifactType === 'sql'\n )\n })\n\n const isMarkdownType = computed(() => {\n return toolPart.value.input?.artifactType === 'markdown'\n })\n\n // A markdown document goes to Word and Outlook as it is drawn, with its\n // markdown as the plain text (`richCopy.ts`); any other type as its text\n const markdownEl = useTemplateRef<HTMLElement>('markdownEl')\n const copiedRich = ref(false)\n const copied = computed(() => copiedText.value || copiedRich.value)\n\n async function copyContent() {\n const content = toolPart.value?.input?.content || ''\n if (!isMarkdownType.value || !markdownEl.value) {\n await copy(content)\n return\n }\n if (\n !(await copyRich({\n html: toClipboardHtml([markdownEl.value]),\n text: content,\n }))\n ) {\n return\n }\n copiedRich.value = true\n setTimeout(() => {\n copiedRich.value = false\n }, 1500)\n }\n\n const codeLanguage = computed(() => {\n if (toolPart.value.input?.language) {\n return toolPart.value.input.language\n }\n // Map artifact types to highlight.js languages\n const languageMap: Record<string, string> = {\n json: 'json',\n xml: 'xml',\n yaml: 'yaml',\n html: 'html',\n sql: 'sql',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'plaintext'\n }\n return languageMap[toolPart.value.input.artifactType] || 'plaintext'\n })\n</script>\n\n<template>\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface\">\n <div\n class=\"px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center\">\n <div class=\"flex flex-col items-start gap-4\">\n <span>{{ toolPart?.input?.title }}</span>\n <span class=\"text-10 opacity-60 font-normal\">\n {{ $t(`artifactType.${artifactTypeKey}`)\n }}{{ languageLabel }}\n </span>\n </div>\n <VvButton\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n modifiers=\"action-quiet-small\"\n :title=\"$t('action.copy')\"\n class=\"shrink-0\"\n @click=\"copyContent\" />\n </div>\n <div class=\"px-sm py-10 bg-surface\">\n <PkCode\n v-if=\"isCodeType\"\n :code=\"toolPart?.input?.content\"\n :language=\"codeLanguage\" />\n <div v-else-if=\"isMarkdownType\" ref=\"markdownEl\">\n <PkStreamingMarkdown\n :markdown=\"toolPart?.input?.content\"\n class=\"wysiwyg text-word-2\" />\n </div>\n <pre\n v-else\n class=\"text-word-2 whitespace-pre-wrap break-words\"\n :class=\"{\n italic:\n toolPart?.input?.artifactType === 'document' ||\n toolPart?.input?.artifactType === 'text',\n }\"\n >{{ toolPart?.input?.content }}</pre>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;EAOI,IAAMuC,IAAQC,GAMRC,IAAkBjB,EAAI,EAAE,GAExBkB,IAAUjB,QACR,OAAOc,EAAM,QAAS,WACfA,EAAM,OAEV,KAAK,UAAUA,EAAM,MAAM,MAAM,CAAC,CAC5C;EAED,eAAeI,IAAY;GACvB,IAAMC,KAAQ,MAAM,OAAO,6DAAA,CAA4B;GACvD,IAAI;IACA,IAAMC,IAASN,EAAM,WACfK,EAAK,UAAUF,EAAQ,OAAO,EAAE,UAAUH,EAAM,SAAS,CAAC,IAC1DK,EAAK,cAAcF,EAAQ,KAAK;IACtC,EAAgB,QAAQG,EAAO;GACnC,QAAQ;IACJ,EAAgB,QAAQH,EAAQ,MAC3B,QAAQ,MAAM,OA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,KAAIsD;G,IAChCnD,EAEkCG,GAAA;IAD7B,UAAUyC,EAAA,OAAU,OAAO;IAC5B,OAAM;G,qCAEdhD,EAAA,GAAAC,EAQyC,OAAA;;IANrC,OAAKO,EAAA,CAAC,+CAA6C,E,QACWwC,EAAA,OAAU,OAAO,iBAAY,cAA2CA,EAAA,OAAU,OAAO,iBAAY,O;GAK/J,GAAA7C,EAAA6C,EAAA,OAAU,OAAO,OAAO,GAAA,CAAA,E"}
@@ -10,7 +10,7 @@ import { n as E, t as D } from "./chartFormat-B1T7y-16.js";
10
10
  import { t as O } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
11
11
  // ../../packages/components/src/chat/PkChartCard.vue?vue&type=script&setup=true&lang.ts
12
12
  f(), m(), i();
13
- var k = { class: "pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden" }, A = { class: "px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8" }, j = { class: "font-bold truncate" }, M = {
13
+ var k = { class: "pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden bg-surface" }, A = { class: "px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8" }, j = { class: "font-bold truncate" }, M = {
14
14
  key: 0,
15
15
  class: "pk-chart-card__table-wrap"
16
16
  }, N = { class: "pk-chart-card__table text-12" }, P = { scope: "col" }, F = { scope: "row" }, I = {
@@ -99,10 +99,10 @@ var z = {
99
99
  class: "flex flex-col gap-sm w-full"
100
100
  }, B = {
101
101
  key: 1,
102
- class: "pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center"
102
+ class: "pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center bg-surface"
103
103
  }, V = {
104
104
  key: 2,
105
- class: "border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm"
105
+ class: "border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm bg-surface"
106
106
  }, H = /*#__PURE__*/ O(/* @__PURE__ */ _({
107
107
  __name: "PkToolShowChart",
108
108
  props: {
@@ -135,4 +135,4 @@ var z = {
135
135
  }), [["styles", [".pk-tool-show-chart__loading{height:360px}"]]]);
136
136
  export { H as default };
137
137
 
138
- //# sourceMappingURL=PkToolShowChart-BalU3bxm.js.map
138
+ //# sourceMappingURL=PkToolShowChart-hUdEF7JC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PkToolShowChart-hUdEF7JC.js","names":["_hoisted_1","_hoisted_2","_hoisted_3","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_withCtx","_createBlock","_Fragment","_renderList","$t","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","PkChartCard","_createVNode","_toDisplayString","ou","De","defineAsyncComponent","createVNode","init_shared_esm_bundler","renderList","useTemplateRef","createBlock","Fragment","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","withCtx","createCommentVNode","defineComponent","unref","openBlock","ShowChartInputSchema","VvButtonLocalized","toSnakeCase","useClipboard","useI18n","chartValueFormatter","chartAsTsv","_plugin_vue_export_helper_default","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","PkChartCard_default","PkChart","props","__props","$t","icon","showTable","format","locale","chartRef","downloadPng","blob","url","anchor","_component_VvIcon","_component_VvButton","_component_VvButtonGroup","createElementBlock","_cache","copied","copy","series","i","category","_hoisted_1","_hoisted_2","_hoisted_3","PkToolShowChart_default","toolPart","streaming","refused","input","parsed","_ctx"],"sources":["../../../../packages/components/src/chat/PkChartCard.vue","../../../../packages/components/src/chat/PkToolShowChart.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, defineAsyncComponent, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import type { Chart } from 'models'\n import { toSnakeCase } from 'utils'\n import { chartAsTsv, chartValueFormatter } from './chartFormat'\n\n // Chart.js comes with it: a separate chunk, loaded with the first chart\n const PkChart = defineAsyncComponent(() => import('./PkChart.vue'))\n\n /**\n * One chart of `showChart` (spec `chat-charts.md`) in its card: the chart,\n * the same numbers as a table, \"Copy data\" for a sheet and the chart as a\n * PNG.\n */\n const props = defineProps<{\n chart: Chart\n /** A note below the chart, e.g. the source of the numbers. */\n caption?: string\n isDark?: boolean\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const icon = computed(() => {\n switch (props.chart.type) {\n case 'line':\n return 'ri:line-chart-line'\n case 'pie':\n return 'ri:pie-chart-line'\n case 'doughnut':\n return 'ri:donut-chart-line'\n default:\n return props.chart.horizontal\n ? 'ri:bar-chart-horizontal-line'\n : 'ri:bar-chart-2-line'\n }\n })\n\n const showTable = ref(false)\n const format = computed(() =>\n chartValueFormatter(locale.value, props.chart.format),\n )\n\n const chartRef = useTemplateRef<{ toBlob: () => Promise<Blob | null> }>(\n 'chartRef',\n )\n const downloadPng = async () => {\n const blob = await chartRef.value?.toBlob()\n if (!blob) {\n return\n }\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(props.chart.title || 'chart')}.png`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n</script>\n\n<template>\n <div\n class=\"pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden bg-surface\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"icon\" class=\"text-16 shrink-0\" />\n <strong class=\"font-bold truncate\">\n {{ chart.title || $t('label.chart') }}\n </strong>\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"pk-chart-card__actions ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"showTable ? icon : 'ri:table-line'\"\n :label=\"\n showTable\n ? $t('chart.showChart')\n : $t('chart.showTable')\n \"\n @click=\"showTable = !showTable\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('chart.copyData')\"\n @click=\"copy(chartAsTsv(chart, locale))\" />\n <VvButton\n v-if=\"!showTable\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n :title=\"$t('chart.downloadPng')\"\n @click=\"downloadPng\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"showTable\" class=\"pk-chart-card__table-wrap\">\n <table class=\"pk-chart-card__table text-12\">\n <thead>\n <tr>\n <th scope=\"col\">{{ chart.categoryLabel ?? '' }}</th>\n <th\n v-for=\"series in chart.series\"\n :key=\"series.name\"\n scope=\"col\">\n {{ series.name }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(category, i) in chart.categories\" :key=\"i\">\n <th scope=\"row\">{{ category }}</th>\n <td v-for=\"series in chart.series\" :key=\"series.name\">\n {{ format(series.values[i] ?? null) }}\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <div v-else class=\"pk-chart-card__stage px-sm py-sm\">\n <PkChart ref=\"chartRef\" :chart :is-dark />\n </div>\n <div\n v-if=\"caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart-card {\n // A container for the narrow card below. It is also the containing\n // block of any `position: fixed` inside it, so a menu added here\n // must open in the top layer (docs/agents/gotchas/frontend.md, \"The\n // chat measures its own width\"): today the card has none.\n container-type: inline-size;\n\n // On a narrow card the actions keep their icon and lose the word on\n // screen, still read by a screen reader: the title keeps the room\n // (at 390px it was cut to \"Fattori di ...\")\n @container (width < 30rem) {\n &__actions .vv-button__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n }\n\n // A fixed stage, as the diagram's: the chart loads in a chunk of its\n // own, and loader and chart must take the same room or the chat's\n // scroll jumps\n &__stage {\n height: 320px;\n }\n\n &__table-wrap {\n max-height: 320px;\n overflow: auto;\n }\n\n &__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-6) var(--spacing-sm);\n border-bottom: 1px solid var(--color-surface-3);\n text-align: right;\n white-space: nowrap;\n }\n\n th:first-child {\n text-align: left;\n white-space: normal;\n }\n\n thead th {\n color: var(--color-word-3);\n font-weight: 600;\n }\n\n tbody th {\n color: var(--color-word-2);\n font-weight: 400;\n }\n\n td {\n color: var(--color-word);\n font-variant-numeric: tabular-nums;\n }\n\n tbody tr:last-child > * {\n border-bottom: 0;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { ShowChartInputSchema } from 'models'\n import PkChartCard from './PkChartCard.vue'\n\n /**\n * The cards of `showChart` (spec `chat-charts.md`): every chart of the\n * call in its own card, one under the other, the caption under the last.\n */\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const toolPart = computed(\n () => props.part as { state?: string; input?: unknown },\n )\n // A half-written input has series shorter than the categories\n const streaming = computed(() => toolPart.value.state === 'input-streaming')\n // A call the tool refused for its input: the model reads why and calls\n // again, and the corrected chart follows it. Nothing to show here.\n const refused = computed(() => toolPart.value.state === 'output-error')\n /** The input as the tool validated it; a stored one that is not stays a message. */\n const input = computed(() => {\n if (streaming.value) {\n return undefined\n }\n const parsed = ShowChartInputSchema.safeParse(toolPart.value.input)\n return parsed.success ? parsed.data : undefined\n })\n</script>\n\n<template>\n <div v-if=\"input\" class=\"flex flex-col gap-sm w-full\">\n <PkChartCard\n v-for=\"(chart, i) in input.charts\"\n :key=\"i\"\n :chart\n :caption=\"i === input.charts.length - 1 ? input.caption : undefined\"\n :is-dark />\n </div>\n <div\n v-else-if=\"streaming\"\n class=\"pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center bg-surface\">\n <VvIcon name=\"loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-else-if=\"!refused\"\n class=\"border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm bg-surface\">\n {{ $t('message.chartRenderError') }}\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-chart {\n // The height of a card while the call is written: the card that\n // replaces it takes about as much, and the chat's scroll stays put\n &__loading {\n height: 360px;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASI,IAAM4D,IAAUpC,QAA2B,OAAO,wBAAgB,GAO5DqC,IAAQC,GAOR,EAAE,GAAGC,GAAI,cAAWjB,EAAQ,EAAE,UAAU,SAAS,CAAC,GAClD,EAAE,SAAM,cAAWD,EAAa,GAEhCmB,IAAO/B,QAAe;GACxB,QAAQ4B,EAAM,MAAM,MAApB;IACI,KAAK,QACD,OAAO;IACX,KAAK,OACD,OAAO;IACX,KAAK,YACD,OAAO;IACX,SACI,OAAOA,EAAM,MAAM,aACb,iCACA;GACd;EACJ,CAAC,GAEKI,IAAYjC,EAAI,EAAK,GACrBkC,IAASjC,QACXc,EAAoBoB,EAAO,OAAON,EAAM,MAAM,MAAM,CACxD,GAEMO,IAAWxC,EACb,UACJ,GACMyC,IAAc,YAAY;GAC5B,IAAMC,IAAO,MAAMF,EAAS,OAAO,OAAO;GAC1C,IAAI,CAACE,GACD;GAEJ,IAAMC,IAAM,IAAI,gBAAgBD,CAAI,GAC9BE,IAAS,SAAS,cAAc,GAAG;GAMzC,AALA,EAAO,OAAOD,GACd,EAAO,WAAW,GAAG3B,EAAYiB,EAAM,MAAM,SAAS,OAAO,EAAE,OAC/D,SAAS,KAAK,YAAYW,CAAM,GAChCA,EAAO,MAAM,GACb,SAAS,KAAK,YAAYA,CAAM,GAChC,IAAI,gBAAgBD,CAAG;EAC3B;;;GAIA,OAAApE,EAAA,GAA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EAAO,UAAUA,EAAO,OAAO,KAAA;EAC1C,CAAC;;;GAIU,OAAAD,EAAA,SAAX5E,EAAA,GAAAC,EAOM,OAPNoE,GAOM,EANFrE,EAAA,EAAA,GAAAC,EAKeC,GAAA,MAAAC,EAJUyE,EAAA,MAAM,SAAnB,GAAO,OADnB5E,EAAA,GAAAI,EAKeC,GAAA;IAHV,KAAK8D;IACL;IACA,SAASA,MAAMS,EAAA,MAAM,OAAO,SAAM,IAAOA,EAAA,MAAM,UAAU,KAAA;IACzD,WAAA5B,EAAA;;;;;G,iBAGM0B,EAAA,SADf1E,EAAA,GAAAC,EAIM,OAJNqE,GAIM,CADFhE,EAA4DqD,GAAA;IAApD,MAAK;IAAe,OAAM;G,QAGtBgB,EAAA,Q,aADhB3E,EAAA,GAAAC,EAIM,OAJNsE,GAIMhE,EADCR,EAAAA,GAAE,0BAAA,CAAA,GAAA,CAAA"}
@@ -7,7 +7,7 @@ import { t as x } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
7
7
  u(), a(), f();
8
8
  var S = {
9
9
  key: 0,
10
- class: "pk-tool-comparison border border-surface-3 rounded-xl w-full overflow-hidden"
10
+ class: "pk-tool-comparison border border-surface-3 rounded-xl w-full overflow-hidden bg-surface"
11
11
  }, C = { class: "px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8" }, w = { class: "font-bold" }, T = { class: "u-table-scroll" }, E = {
12
12
  class: "u-table u-table--stack",
13
13
  role: "table"
@@ -70,4 +70,4 @@ var S = {
70
70
  }), [["styles", [".pk-tool-comparison{--u-table-label-width:8rem}.pk-tool-comparison .pk-tool-comparison__item{font-size:var(--text-14);color:var(--color-word-1)}.pk-tool-comparison .pk-tool-comparison__feature{font-weight:var(--font-medium);color:var(--color-word-3)}.pk-tool-comparison .pk-tool-comparison__cell--highlighted{background-color:var(--color-surface-1)}.pk-tool-comparison__recommended{font-size:var(--text-12);font-weight:var(--font-normal);color:var(--color-word-3);display:block}@container (width<30rem){.pk-tool-comparison .pk-tool-comparison__cell--highlighted{background-color:#0000}.pk-tool-comparison .pk-tool-comparison__cell--highlighted:before{font-weight:var(--font-semibold);color:var(--color-word-1)}}"]]]);
71
71
  export { N as default };
72
72
 
73
- //# sourceMappingURL=PkToolShowComparison-DeO7cMeF.js.map
73
+ //# sourceMappingURL=PkToolShowComparison-1odeymnp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PkToolShowComparison-1odeymnp.js","names":["$t","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_withCtx","_unref","_Fragment","_renderList","_normalizeClass","_createTextVNode","ou","De","VvButtonLocalized","normalizeClass","createVNode","init_shared_esm_bundler","renderList","Fragment","createBaseVNode","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","withCtx","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useClipboard","_plugin_vue_export_helper_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","PkToolShowComparison_default","props","__props","toolPart","features","items","valueColorClass","value","copyTable","header","i","rows","f","_component_VvIcon","_component_VvButton","_component_VvButtonGroup","_ctx","copied","_cache","item","feature"],"sources":["../../../../packages/components/src/chat/PkToolShowComparison.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useClipboard } from '@vueuse/core'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const { copy, copied } = useClipboard()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title?: string\n items: Array<{\n name: string\n values: Record<string, string>\n highlighted?: boolean\n }>\n }\n }\n return part\n })\n\n const features = computed(() => {\n const items = toolPart.value.input?.items\n if (!items || items.length === 0) {\n return []\n }\n return Object.keys(items[0].values)\n })\n\n // The tool contract asks for \"✓\" and \"✗\" on boolean features: the pair is\n // a verdict, so it wears one and the table reads by eye (DESIGN.md).\n const valueColorClass = (value?: string) => {\n if (value === '✓') {\n return 'text-success'\n }\n if (value === '✗') {\n return 'text-danger'\n }\n return 'text-word-2'\n }\n\n const copyTable = () => {\n const items = toolPart.value.input?.items\n if (!items) {\n return\n }\n const header = ['', ...items.map((i) => i.name)].join('\\t')\n const rows = features.value.map((f) =>\n [f.replace(/_/g, ' '), ...items.map((i) => i.values[f] ?? '')].join(\n '\\t',\n ),\n )\n copy([header, ...rows].join('\\n'))\n }\n</script>\n\n<template>\n <div\n v-if=\"toolPart?.input?.items?.length\"\n class=\"pk-tool-comparison border border-surface-3 rounded-xl w-full overflow-hidden bg-surface\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon name=\"ri:scales-line\" class=\"text-16\" />\n <strong class=\"font-bold\">{{\n toolPart.input.title ?? $t('label.comparison')\n }}</strong>\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n @click=\"copyTable\" />\n </VvButtonGroup>\n </div>\n <!-- One row per feature, one column per item. In a narrow message\n each feature becomes a block that lists every item beside its\n value (`u-table--stack`), so a comparison still reads across. -->\n <div class=\"u-table-scroll\">\n <table class=\"u-table u-table--stack\" role=\"table\">\n <thead role=\"rowgroup\">\n <tr role=\"row\">\n <td></td>\n <th\n v-for=\"item in toolPart.input.items\"\n :key=\"item.name\"\n role=\"columnheader\"\n scope=\"col\"\n class=\"pk-tool-comparison__item\"\n :class=\"{\n 'pk-tool-comparison__cell--highlighted':\n item.highlighted,\n }\">\n {{ item.name }}\n <small\n v-if=\"item.highlighted\"\n class=\"pk-tool-comparison__recommended\">\n {{ $t('label.recommended') }}\n </small>\n </th>\n </tr>\n </thead>\n <tbody role=\"rowgroup\">\n <tr v-for=\"feature in features\" :key=\"feature\" role=\"row\">\n <th\n role=\"rowheader\"\n scope=\"row\"\n class=\"pk-tool-comparison__feature\">\n {{ feature.replace(/_/g, ' ') }}\n </th>\n <td\n v-for=\"item in toolPart.input.items\"\n :key=\"item.name\"\n role=\"cell\"\n :data-label=\"item.name\"\n :class=\"[\n valueColorClass(item.values[feature]),\n {\n 'pk-tool-comparison__cell--highlighted':\n item.highlighted,\n },\n ]\">\n {{ item.values[feature] ?? '-' }}\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n // Written under the block so it outweighs the `.u-table` rules.\n .pk-tool-comparison {\n // Stacked, the labels are the names of the items, longer than the\n // headings of a data table.\n --u-table-label-width: 8rem;\n\n // The items are what the table compares: their names are the titles\n // of the columns, not the small headings of a data table.\n & &__item {\n font-size: var(--text-14);\n color: var(--color-word-1);\n }\n\n & &__feature {\n font-weight: var(--font-medium);\n color: var(--color-word-3);\n }\n\n // The recommended item: a ground down its column and a word under its\n // name, no accent colour (DESIGN.md). Stacked, its name weighs more\n // than the others beside its value.\n & &__cell--highlighted {\n background-color: var(--color-surface-1);\n }\n\n &__recommended {\n display: block;\n font-size: var(--text-12);\n font-weight: var(--font-normal);\n color: var(--color-word-3);\n }\n\n @container (width < 30rem) {\n & &__cell--highlighted {\n background-color: transparent;\n\n &::before {\n font-weight: var(--font-semibold);\n color: var(--color-word-1);\n }\n }\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EAII,IAAM8C,IAAQC,GAIR,EAAE,SAAM,cAAWf,EAAa,GAEhCgB,IAAW3B,QACAyB,EAAM,IAWtB,GAEKG,IAAW5B,QAAe;GAC5B,IAAM6B,IAAQF,EAAS,MAAM,OAAO;GAIpC,OAHI,CAACE,KAASA,EAAM,WAAW,IACpB,CAAC,IAEL,OAAO,KAAKA,EAAM,EAAE,CAAC,MAAM;EACtC,CAAC,GAIKC,KAAmB,MACjBC,MAAU,MACH,iBAEPA,MAAU,MACH,gBAEJ,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AAAC,EAgBK,MAAA;IAdA,KAAK8D,EAAK;IACX,MAAK;IACL,OAAM;IACN,OAAKtD,EAAA,CAAC,4BAA0B,E,yCACuFsD,EAAK,Y;G,IAIzHrD,EAAAN,EAAA2D,EAAK,IAAI,IAAG,KACf,CAAA,GACUA,EAAK,eADf/D,EAAA,GAAAC,EAIQ,SAJRuC,GAIQpC,EADDL,EAAAA,GAAE,mBAAA,CAAA,GAAA,CAAA,K,6BAKrBG,EAuBQ,SAvBRuC,GAuBQ,EAtBJzC,EAAA,EAAA,GAAAC,EAqBKM,GAAA,MAAAC,EArBiBwC,EAAA,QAAX,OAAXhD,EAAA,GAAAC,EAqBK,MAAA;IArB4B,KAAK+D;IAAS,MAAK;G,IAChD9D,EAKK,MALLwC,GAKKtC,EADE4D,EAAQ,QAAO,MAAA,GAAA,CAAA,GAAA,CAAA,IAEtBhE,EAAA,EAAA,GAAAC,EAaKM,GAAA,MAAAC,EAZcuC,EAAA,MAAS,MAAM,QAAvB,OADX/C,EAAA,GAAAC,EAaK,MAAA;IAXA,KAAK8D,EAAK;IACX,MAAK;IACJ,cAAYA,EAAK;IACjB,OAAKtD,EAAA,CAAoCyC,EAAgBa,EAAK,OAAOC,EAAO,G,2CAA2JD,EAAK,Y;GAO1O,GAAA3D,EAAA2D,EAAK,OAAOC,MAAO,GAAA,GAAA,IAAArB,CAAA,E"}
@@ -5,7 +5,7 @@ import { Q as a, S as o, Tt as s, V as c, _ as l, f as u, g as d, h as f, k as p
5
5
  import { r as E } from "./vue-i18n-CDYWo9pX.js";
6
6
  import { n as D, r as O, t as k } from "./index.es-DDdkqLT6.js";
7
7
  import { t as A } from "./src-QHwDXo7q.js";
8
- import { t as j } from "./PkStreamingMarkdown-Bekhx_vG.js";
8
+ import { t as j } from "./PkStreamingMarkdown-DLyBjSaH.js";
9
9
  // ../../packages/components/src/chat/PkToolShowContactForm.vue?vue&type=script&setup=true&lang.ts
10
10
  p(), h(), s(), g();
11
11
  var M = { class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-surface" }, N = { class: "px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8 min-h-40" }, P = { class: "font-bold" }, F = {
@@ -154,4 +154,4 @@ var M = { class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-s
154
154
  });
155
155
  export { K as default };
156
156
 
157
- //# sourceMappingURL=PkToolShowContactForm-BXsvfCKR.js.map
157
+ //# sourceMappingURL=PkToolShowContactForm-B9u6KgjQ.js.map