@8wave/ai-elements 0.126.0-beta.31 → 0.126.0-beta.33
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.
- package/dist/_chunks/{Agent-COa7L9GK.js → Agent-DZEyfr8D.js} +2 -1
- package/dist/_chunks/Agent-DZEyfr8D.js.map +1 -0
- package/dist/_chunks/{PkFilePreview-SBGa95Ca.js → PkFilePreview-C6ZZablL.js} +3 -3
- package/dist/_chunks/{PkFilePreview-SBGa95Ca.js.map → PkFilePreview-C6ZZablL.js.map} +1 -1
- package/dist/_chunks/{PkFilePreviewDialog-Cc7iZWCl.js → PkFilePreviewDialog-BzBHAt8l.js} +2 -2
- package/dist/_chunks/{PkFilePreviewDialog-Cc7iZWCl.js.map → PkFilePreviewDialog-BzBHAt8l.js.map} +1 -1
- package/dist/_chunks/{PkImageEditorDialog-D13bWv-N.js → PkImageEditorDialog-Dm34WFmS.js} +2 -2
- package/dist/_chunks/{PkImageEditorDialog-D13bWv-N.js.map → PkImageEditorDialog-Dm34WFmS.js.map} +1 -1
- package/dist/_chunks/{PkSelectionActions-BaX_rsCt.js → PkSelectionActions-CYqbMEjg.js} +2 -2
- package/dist/_chunks/{PkSelectionActions-BaX_rsCt.js.map → PkSelectionActions-CYqbMEjg.js.map} +1 -1
- package/dist/_chunks/{PkStreamingMarkdown-GRB3Gg_x.js → PkStreamingMarkdown-B8rZbprU.js} +3 -3
- package/dist/_chunks/{PkStreamingMarkdown-GRB3Gg_x.js.map → PkStreamingMarkdown-B8rZbprU.js.map} +1 -1
- package/dist/_chunks/{PkToolChatFile-DTm5-CE4.js → PkToolChatFile-C0emIVfS.js} +3 -3
- package/dist/_chunks/{PkToolChatFile-DTm5-CE4.js.map → PkToolChatFile-C0emIVfS.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestGeolocation-DZenn1az.js → PkToolRequestGeolocation-DNzNRszE.js} +2 -2
- package/dist/_chunks/{PkToolRequestGeolocation-DZenn1az.js.map → PkToolRequestGeolocation-DNzNRszE.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestOAuthConnection-Dz0qfYu5.js → PkToolRequestOAuthConnection-BDxYXz4s.js} +2 -2
- package/dist/_chunks/{PkToolRequestOAuthConnection-Dz0qfYu5.js.map → PkToolRequestOAuthConnection-BDxYXz4s.js.map} +1 -1
- package/dist/_chunks/{PkToolShowArtifact-C9_DHr5Y.js → PkToolShowArtifact-B_KIIjEn.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-C9_DHr5Y.js.map → PkToolShowArtifact-B_KIIjEn.js.map} +1 -1
- package/dist/_chunks/{PkToolShowContactForm-DhyelktO.js → PkToolShowContactForm-DiHb3fRQ.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-DhyelktO.js.map → PkToolShowContactForm-DiHb3fRQ.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-Dz2Hnzts.js → PkToolShowForm-BmUAhIQy.js} +4 -4
- package/dist/_chunks/{PkToolShowForm-Dz2Hnzts.js.map → PkToolShowForm-BmUAhIQy.js.map} +1 -1
- package/dist/_chunks/{PkToolShowImageGallery-CiDfIboY.js → PkToolShowImageGallery-CZ394fdT.js} +2 -2
- package/dist/_chunks/{PkToolShowImageGallery-CiDfIboY.js.map → PkToolShowImageGallery-CZ394fdT.js.map} +1 -1
- package/dist/_chunks/{PkToolShowProductList-CY96IGWn.js → PkToolShowProductList-uNvUr2s9.js} +2 -2
- package/dist/_chunks/{PkToolShowProductList-CY96IGWn.js.map → PkToolShowProductList-uNvUr2s9.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-CRk-MOoE.js → PkToolShowSources-Dm0L4prK.js} +3 -3
- package/dist/_chunks/{PkToolShowSources-CRk-MOoE.js.map → PkToolShowSources-Dm0L4prK.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSuggestedReply-DKuV4mmV.js → PkToolShowSuggestedReply-B_dRrZfj.js} +2 -2
- package/dist/_chunks/{PkToolShowSuggestedReply-DKuV4mmV.js.map → PkToolShowSuggestedReply-B_dRrZfj.js.map} +1 -1
- package/dist/_chunks/{PkToolShowVideo-DI6ohcVU.js → PkToolShowVideo-DLgQjTq_.js} +2 -2
- package/dist/_chunks/{PkToolShowVideo-DI6ohcVU.js.map → PkToolShowVideo-DLgQjTq_.js.map} +1 -1
- package/dist/_chunks/{PkToolShowWebPages-Dh6L_n9T.js → PkToolShowWebPages-Cj2mJrs5.js} +2 -2
- package/dist/_chunks/{PkToolShowWebPages-Dh6L_n9T.js.map → PkToolShowWebPages-Cj2mJrs5.js.map} +1 -1
- package/dist/_chunks/{chatImagePolicy-Ckz-KAHA.js → chatImagePolicy-DMt6O5iK.js} +2 -2
- package/dist/_chunks/{chatImagePolicy-Ckz-KAHA.js.map → chatImagePolicy-DMt6O5iK.js.map} +1 -1
- package/dist/_chunks/{markdown-DHayRAiy.js → markdown-nw5sXwU0.js} +2 -2
- package/dist/_chunks/{markdown-DHayRAiy.js.map → markdown-nw5sXwU0.js.map} +1 -1
- package/dist/_chunks/{utils-3jpXeGGy.js → utils-DPGBO-HU.js} +2 -2
- package/dist/_chunks/{utils-3jpXeGGy.js.map → utils-DPGBO-HU.js.map} +1 -1
- package/dist/ai-elements.es.js +3927 -3858
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotEmptyState.js +1 -1
- package/dist-vue/PkChatbotInput.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotStepPayload.js +1 -1
- package/dist-vue/PkChatbotStepToolDetail.js +1 -1
- package/dist-vue/PkChatbotSteps.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/PkChatbotViewConversations.js +1 -1
- package/dist-vue/PkChatbotViewFiles.js +1 -1
- package/dist-vue/PkChatbotViewProfile.js +1 -1
- package/dist-vue/_chunks/{Agent-CRwhrv5Z.js → Agent-CBAd3F7k.js} +2 -1
- package/dist-vue/_chunks/Agent-CBAd3F7k.js.map +1 -0
- package/dist-vue/_chunks/{Document-Bp-qpa8v.js → Document-B3w5H0R0.js} +2 -2
- package/dist-vue/_chunks/{Document-Bp-qpa8v.js.map → Document-B3w5H0R0.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbot-CtrcDgBe.js → PkChatbot-CXpftmWm.js} +8 -8
- package/dist-vue/_chunks/{PkChatbot-CtrcDgBe.js.map → PkChatbot-CXpftmWm.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotEmptyState-BF3Odn3v.js → PkChatbotEmptyState-vA2v4FES.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-BF3Odn3v.js.map → PkChatbotEmptyState-vA2v4FES.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotInput-CIIJ1bpF.js +584 -0
- package/dist-vue/_chunks/PkChatbotInput-CIIJ1bpF.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotMessages-10eBKpC5.js → PkChatbotMessages-15R8RxAq.js} +18 -18
- package/dist-vue/_chunks/{PkChatbotMessages-10eBKpC5.js.map → PkChatbotMessages-15R8RxAq.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepPayload-C4ahOq6Z.js → PkChatbotStepPayload-BbNSav-U.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-C4ahOq6Z.js.map → PkChatbotStepPayload-BbNSav-U.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-CkIX0aKu.js → PkChatbotStepToolDetail-B_4pmbLe.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-CkIX0aKu.js.map → PkChatbotStepToolDetail-B_4pmbLe.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotSteps-BalLo6DZ.js → PkChatbotSteps-h4E6DH_g.js} +5 -5
- package/dist-vue/_chunks/{PkChatbotSteps-BalLo6DZ.js.map → PkChatbotSteps-h4E6DH_g.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotViewChat-CLQ0J9_f.js +1382 -0
- package/dist-vue/_chunks/PkChatbotViewChat-CLQ0J9_f.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotViewConversations-D0vDYTyo.js → PkChatbotViewConversations-DFBbypGg.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewConversations-D0vDYTyo.js.map → PkChatbotViewConversations-DFBbypGg.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewFiles-BwfAnywk.js → PkChatbotViewFiles-PHdrHZOf.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewFiles-BwfAnywk.js.map → PkChatbotViewFiles-PHdrHZOf.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewProfile-GW0WuMOy.js → PkChatbotViewProfile-B0AZvHTr.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewProfile-GW0WuMOy.js.map → PkChatbotViewProfile-B0AZvHTr.js.map} +1 -1
- package/dist-vue/_chunks/{PkFilePreview-qizsvSVW.js → PkFilePreview-Cb-1YRPN.js} +616 -666
- package/dist-vue/_chunks/PkFilePreview-Cb-1YRPN.js.map +1 -0
- package/dist-vue/_chunks/{PkFilePreviewDialog-WsVzH9hg.js → PkFilePreviewDialog-Bd7kEoCB.js} +2 -2
- package/dist-vue/_chunks/{PkFilePreviewDialog-WsVzH9hg.js.map → PkFilePreviewDialog-Bd7kEoCB.js.map} +1 -1
- package/dist-vue/_chunks/{PkImageEditorDialog-NQFpdqCU.js → PkImageEditorDialog-Bj4sUHXM.js} +2 -2
- package/dist-vue/_chunks/{PkImageEditorDialog-NQFpdqCU.js.map → PkImageEditorDialog-Bj4sUHXM.js.map} +1 -1
- package/dist-vue/_chunks/{PkStreamingMarkdown-CMxiJTMR.js → PkStreamingMarkdown-BcUq4ThC.js} +3 -3
- package/dist-vue/_chunks/{PkStreamingMarkdown-CMxiJTMR.js.map → PkStreamingMarkdown-BcUq4ThC.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolChatFile-Bd6Ci7i1.js → PkToolChatFile-BOexrlLt.js} +3 -3
- package/dist-vue/_chunks/{PkToolChatFile-Bd6Ci7i1.js.map → PkToolChatFile-BOexrlLt.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestGeolocation-C2OmF31d.js → PkToolRequestGeolocation-CyL_M1Rm.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestGeolocation-C2OmF31d.js.map → PkToolRequestGeolocation-CyL_M1Rm.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-CgD-o99C.js → PkToolRequestOAuthConnection-DWkeVLpx.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-CgD-o99C.js.map → PkToolRequestOAuthConnection-DWkeVLpx.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowArtifact-rlZ-AGWh.js → PkToolShowArtifact-C4gHB6lH.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-rlZ-AGWh.js.map → PkToolShowArtifact-C4gHB6lH.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowChart-B8xJi1yY.js → PkToolShowChart-CsPXNAb9.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowChart-B8xJi1yY.js.map → PkToolShowChart-CsPXNAb9.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowContactForm-BVBL7Unx.js → PkToolShowContactForm-2_HBPZaa.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-BVBL7Unx.js.map → PkToolShowContactForm-2_HBPZaa.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-Bs39QQZ3.js → PkToolShowDiagram-cCbeL6MK.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-Bs39QQZ3.js.map → PkToolShowDiagram-cCbeL6MK.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-D-RJeA2F.js → PkToolShowForm-DjB3fji5.js} +4 -4
- package/dist-vue/_chunks/{PkToolShowForm-D-RJeA2F.js.map → PkToolShowForm-DjB3fji5.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowImageGallery-CrkkKCVI.js → PkToolShowImageGallery-C22TCUKW.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowImageGallery-CrkkKCVI.js.map → PkToolShowImageGallery-C22TCUKW.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-BwfUG41_.js → PkToolShowProductList-BvtmiHBf.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-BwfUG41_.js.map → PkToolShowProductList-BvtmiHBf.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-q9gQIuam.js → PkToolShowSources-uKO4MQgd.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowSources-q9gQIuam.js.map → PkToolShowSources-uKO4MQgd.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-75Kc8-OQ.js → PkToolShowSuggestedReply-wKgwHTRO.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-75Kc8-OQ.js.map → PkToolShowSuggestedReply-wKgwHTRO.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowVideo-BK-jDVJd.js → PkToolShowVideo-DKj5N1vo.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowVideo-BK-jDVJd.js.map → PkToolShowVideo-DKj5N1vo.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-K3Jml1f7.js → PkToolShowWebPages-BNZmbCSf.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-K3Jml1f7.js.map → PkToolShowWebPages-BNZmbCSf.js.map} +1 -1
- package/dist-vue/_chunks/{createChatbotApiClient-Pb7_cU2s.js → createChatbotApiClient-DBKfGL6y.js} +5 -2
- package/dist-vue/_chunks/{createChatbotApiClient-Pb7_cU2s.js.map → createChatbotApiClient-DBKfGL6y.js.map} +1 -1
- package/dist-vue/_chunks/{useChatbotStore-ChrZVIDt.js → useChatbotStore-Hb5EjISl.js} +94 -85
- package/dist-vue/_chunks/useChatbotStore-Hb5EjISl.js.map +1 -0
- package/dist-vue/_chunks/{utils-Bdk5kFfi.js → utils-waie4Gfn.js} +2 -2
- package/dist-vue/_chunks/{utils-Bdk5kFfi.js.map → utils-waie4Gfn.js.map} +1 -1
- package/dist-vue/api.js +1 -1
- package/dist-vue/apps/web-component/src/composables/useChatbotAgent.d.ts +2 -0
- package/dist-vue/composables.js +8 -8
- package/dist-vue/index.js +408 -389
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +6 -0
- package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +9 -2
- package/dist-vue/packages/components/src/chat/PkChatbotInput.d.ts +6 -0
- package/dist-vue/packages/composable/src/chatbot/api/createChatbotApiClient.d.ts +5 -0
- package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +10 -1
- package/dist-vue/packages/models/src/schema/Agent.d.ts +8 -0
- package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +2 -0
- package/dist-vue/packages/models/src/schema/SubAgent.d.ts +2 -0
- package/dist-vue/packages/models/src/schema/constants.d.ts +11 -2
- package/dist-vue/style.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/Agent-COa7L9GK.js.map +0 -1
- package/dist-vue/_chunks/Agent-CRwhrv5Z.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotInput-DNXvFvyG.js +0 -520
- package/dist-vue/_chunks/PkChatbotInput-DNXvFvyG.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotViewChat-U6T-gG-c.js +0 -1336
- package/dist-vue/_chunks/PkChatbotViewChat-U6T-gG-c.js.map +0 -1
- package/dist-vue/_chunks/PkFilePreview-qizsvSVW.js.map +0 -1
- package/dist-vue/_chunks/useChatbotStore-ChrZVIDt.js.map +0 -1
|
@@ -2,9 +2,9 @@ import { r as e } from "./index.es-BYhSukum.js";
|
|
|
2
2
|
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 l, ot as u, v as d, w as f, wt as p, x as m, y as h, z as g } from "./vue.runtime.esm-bundler-DZgpK-ja.js";
|
|
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
|
-
import { p as y, y as ne } from "./Agent-
|
|
5
|
+
import { p as y, y as ne } from "./Agent-DZEyfr8D.js";
|
|
6
6
|
import { t as re } from "./PkChatbotFilePreview-B4vbUkNp.js";
|
|
7
|
-
import { u as b } from "./utils-
|
|
7
|
+
import { u as b } from "./utils-DPGBO-HU.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-
|
|
228
|
+
//# sourceMappingURL=PkToolChatFile-C0emIVfS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolChatFile-DTm5-CE4.js","names":["_openBlock","_createElementBlock","_createVNode","PkChatbotFilePreview","_createElementVNode","_toDisplayString","_unref","_Fragment","_renderList","_createTextVNode","Ee","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,EAAE,EAAE;EAC1C,GAOMG,KAAa,GAAgB,MAA6B;GAC5D,IAAMC,IAAIH,EAAO,MAAM,OAAO,CAAC,CAAC,OAAO,OAAO,GACxCI,IAAIH,EAAM,MAAM,OAAO,CAAC,CAAC,OAAO,OAAO,GAEvCI,IAAS,MAAM,KAAK,EAAE,QAAQF,EAAE,SAAS,EAAE,SACzC,MAAcC,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAC1C;GACA,KAAK,IAAIE,IAAIH,EAAE,SAAS,GAAGG,KAAK,GAAG,KAC/B,KAAK,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EAAAyD,CAAA,CAAE,CAAA,mCAAoCiC,EAAA,MAAK,IAAI,CAAA,GAAA,CAAA,K;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"}
|
|
1
|
+
{"version":3,"file":"PkToolChatFile-C0emIVfS.js","names":["_openBlock","_createElementBlock","_createVNode","PkChatbotFilePreview","_createElementVNode","_toDisplayString","_unref","_Fragment","_renderList","_createTextVNode","Ee","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,GAQn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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"}
|
package/dist/_chunks/{PkToolRequestGeolocation-DZenn1az.js → PkToolRequestGeolocation-DNzNRszE.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as e } from "./index.es-BYhSukum.js";
|
|
2
2
|
import { L as t, S as n, Tt 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, x as p, y as m, z as h } from "./vue.runtime.esm-bundler-DZgpK-ja.js";
|
|
3
3
|
import { r as g } from "./vue-i18n-CDYWo9pX.js";
|
|
4
|
-
import { S as _ } from "./Agent-
|
|
4
|
+
import { S as _ } from "./Agent-DZEyfr8D.js";
|
|
5
5
|
// ../../packages/components/src/chat/PkToolRequestGeolocation.vue?vue&type=script&setup=true&lang.ts
|
|
6
6
|
s(), l(), r();
|
|
7
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({
|
|
@@ -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-
|
|
66
|
+
//# sourceMappingURL=PkToolRequestGeolocation-DNzNRszE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolRequestGeolocation-
|
|
1
|
+
{"version":3,"file":"PkToolRequestGeolocation-DNzNRszE.js","names":["$n","_openBlock","_createElementBlock","_Fragment","_createVNode","_createElementVNode","_toDisplayString","_unref","_createTextVNode","Ee","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,YAAY,mBAClB,OAAO,MAAa;IAChB,IAAM,EAAE,aAAU,cAAW,gBAAaa,EAAS,QAC7CC,IAAOd,EAAM,iBACb,MAAMA,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AAA,CAFPC,EAA8C4C,GAAA;IAAtC,MAAK;IAAe,OAAM;G,IAClC3C,EAAuD,QAAA,MAAAC,EAA9CC,EAAA0B,CAAA,CAAE,CAAA,gCAAA,CAAA,GAAA,CAAA,C"}
|
|
@@ -3,7 +3,7 @@ import { r as t } from "./index.es-BYhSukum.js";
|
|
|
3
3
|
import { L as n, R as r, S as i, Tt as a, _ as o, f as s, g as c, gt as l, h as u, k as d, kt as f, ot as p, v as m, w as h, wt as g, y as _, z as v } from "./vue.runtime.esm-bundler-DZgpK-ja.js";
|
|
4
4
|
import { r as y } from "./vue-i18n-CDYWo9pX.js";
|
|
5
5
|
import { i as b } from "./url-validation-CJV9pp4v.js";
|
|
6
|
-
import { S as x } from "./Agent-
|
|
6
|
+
import { S as x } from "./Agent-DZEyfr8D.js";
|
|
7
7
|
import "./src-QHwDXo7q.js";
|
|
8
8
|
function S(e, t, n) {
|
|
9
9
|
return e.data?.type === "mcp-oauth-complete" && !!t && e.source === t && e.origin === b(n);
|
|
@@ -119,4 +119,4 @@ var C = { class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-s
|
|
|
119
119
|
});
|
|
120
120
|
export { P as default };
|
|
121
121
|
|
|
122
|
-
//# sourceMappingURL=PkToolRequestOAuthConnection-
|
|
122
|
+
//# sourceMappingURL=PkToolRequestOAuthConnection-BDxYXz4s.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolRequestOAuthConnection-Dz0qfYu5.js","names":["_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_createBlock","_Fragment","VvButtonLocalized","Ee","onMounted","onUnmounted","createVNode","init_shared_esm_bundler","createBlock","Fragment","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createElementBlock","openBlock","useI18n","urlOrigin","isVoiceRenderAck","isMcpOAuthReport","event","signInWindow","backendUrl","_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","POLL_INTERVAL_MS","POLL_TIMEOUT_MS","PkToolRequestOAuthConnection_default","__emit","props","__props","emit","$t","toolPart","state","serverName","isRenderAck","isConnectedByOutput","isAwaitingConnection","mcpServerId","hasConnected","isSigningIn","oauthError","isDone","canConnect","isConnectedNow","status","pollTimer","signInAttempt","stopWatching","settleConnected","connectedServerId","watchForConnection","attempt","popup","deadline","tick","connected","onMessage","reportedServerId","openAuthWindow","connection","err","_component_VvIcon","_component_VvButton"],"sources":["../../../../packages/components/src/chat/mcpOAuthReport.ts","../../../../packages/components/src/chat/PkToolRequestOAuthConnection.vue"],"sourcesContent":["import { urlOrigin } from 'utils'\n\n/** The `type` the MCP sign-in callback page posts (mcpOAuth.controller.ts). */\nexport const MCP_OAUTH_REPORT_TYPE = 'mcp-oauth-complete'\n\n/**\n * Whether a `message` event is the report of the MCP sign-in a page opened:\n * posted by that window while it shows the callback page, which runs on the\n * backend's origin. Any other window holding the page could post the same\n * message, success included, and so could the provider's own pages, which run\n * in that same window before the callback. Without the window or the backend\n * URL nothing is a report, and the caller relies on reading the connection.\n */\nexport function isMcpOAuthReport(\n event: MessageEvent,\n signInWindow: Window | null | undefined,\n backendUrl: string | undefined,\n): boolean {\n return (\n event.data?.type === MCP_OAUTH_REPORT_TYPE &&\n !!signInWindow &&\n event.source === signInWindow &&\n event.origin === urlOrigin(backendUrl)\n )\n}\n","<script setup lang=\"ts\">\n import { computed, onMounted, onUnmounted, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n import { isMcpOAuthReport } from './mcpOAuthReport'\n\n const props = defineProps<{\n part: unknown\n /**\n * The backend the chat talks to, where the sign-in's callback page\n * runs. Without it the card hears no report and relies on its poll.\n */\n backendUrl?: string\n resolveConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; authorizeUrl: string }>\n checkConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; connected: boolean }>\n }>()\n\n const emit = defineEmits<{\n connected: [mcpServerId: string]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n /** How often the connection is re-read while the sign-in window is out. */\n const POLL_INTERVAL_MS = 2000\n /**\n * How long we keep asking. The only end to a sign-in nobody finishes:\n * `popup.closed` cannot be that signal, because the browser disowns the\n * handle when the provider severs the opener (that is what\n * `Cross-Origin-Opener-Policy` does), so it reads as closed from the first\n * check of the very flow this watch exists for. Long enough for a password\n * manager and a second factor.\n */\n const POLL_TIMEOUT_MS = 5 * 60 * 1000\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n toolCallId?: string\n input?: { serverName: string }\n output?: unknown\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n const serverName = computed(() => toolPart.value.input?.serverName)\n\n /**\n * A card drawn during a CALL arrives already \"answered\": the turn could\n * not wait for the connection, so the backend closed the tool with a note\n * saying the card was drawn (see `isVoiceRenderAck`, same rule as the\n * forms). That note is not a connection, and without this the card\n * rendered its inert fallback: the caller was told to connect the account\n * and given nothing to click (measured 2026-08-07).\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n /** The output this card wrote itself once the connection went through. */\n const isConnectedByOutput = computed(\n () =>\n (toolPart.value.output as { connected?: unknown } | undefined)\n ?.connected === true,\n )\n\n const isAwaitingConnection = computed(\n () => state.value === 'input-available' || isRenderAck.value,\n )\n\n const mcpServerId = ref<string | null>(null)\n /**\n * Set once THIS card's sign-in went through, and never from a plain read of\n * the connection: a card still asking is the turn saying it could not use\n * that integration, and a token row can outlive its usefulness (a refresh\n * that failed transiently keeps the row, so the turn sees no usable token\n * while a status read still sees one). Trusting the read there would have\n * left the card claiming success, with no button, on a turn still waiting.\n * It doubles as the guard that resumes the turn exactly once, whichever\n * channel got there first.\n */\n const hasConnected = ref(false)\n /** A sign-in window we opened is still out there. */\n const isSigningIn = ref(false)\n const oauthError = ref<string | null>(null)\n\n const isDone = computed(\n () => hasConnected.value || isConnectedByOutput.value,\n )\n const canConnect = computed(\n () => Boolean(serverName.value) && Boolean(props.resolveConnection),\n )\n\n /**\n * Whether the server says this user has connected, asked without minting\n * anything: no OAuth `state` is burned by looking.\n */\n async function isConnectedNow(): Promise<boolean> {\n if (!serverName.value || !props.checkConnection) {\n return false\n }\n try {\n const status = await props.checkConnection(serverName.value)\n mcpServerId.value = status.mcpServerId\n return status.connected\n } catch {\n // Not knowing is not an error to show: the sign-in window is still\n // out there and the next read may well answer.\n return false\n }\n }\n\n let pollTimer: ReturnType<typeof setTimeout> | undefined\n /**\n * Which sign-in a running tick belongs to. A tick suspended on its read\n * outlives the attempt that scheduled it: without this it woke up inside\n * the NEXT attempt, restarted its own chain over that one's timer and then\n * stopped it on its own older deadline.\n */\n let signInAttempt = 0\n /** The window this attempt opened, the only sender we accept a report from. */\n let signInWindow: Window | null = null\n\n function stopWatching() {\n if (pollTimer !== undefined) {\n clearTimeout(pollTimer)\n pollTimer = undefined\n }\n signInAttempt += 1\n signInWindow = null\n isSigningIn.value = false\n }\n\n function settleConnected(connectedServerId: string) {\n stopWatching()\n if (hasConnected.value) {\n return\n }\n hasConnected.value = true\n mcpServerId.value = connectedServerId\n oauthError.value = null\n emit('connected', connectedServerId)\n }\n\n /**\n * Watches the connection from THIS window while the sign-in window is away.\n *\n * The callback page reports through `window.opener`, and a provider that\n * sends `Cross-Origin-Opener-Policy` anywhere in its redirect chain takes\n * that opener away: the connection then succeeds with nobody listening, the\n * card stays on its button and the suspended turn is never resumed\n * (reported 2026-08-27). This channel never goes through that window, so it\n * survives whatever the provider does to it. Chained rather than periodic:\n * a read slower than the interval would otherwise overlap the next one.\n */\n function watchForConnection(popup: Window) {\n stopWatching()\n const attempt = signInAttempt\n signInWindow = popup\n isSigningIn.value = true\n const deadline = Date.now() + POLL_TIMEOUT_MS\n const tick = async () => {\n if (attempt !== signInAttempt || Date.now() > deadline) {\n if (attempt === signInAttempt) {\n stopWatching()\n }\n return\n }\n const connected = await isConnectedNow()\n if (attempt !== signInAttempt) {\n return\n }\n if (connected && mcpServerId.value) {\n settleConnected(mcpServerId.value)\n return\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n\n /**\n * The callback page's own report, when the browser let it through: faster\n * than the poll, and the only channel carrying the failure reason.\n *\n * Accepted only as {@link isMcpOAuthReport} says, and only while that\n * sign-in is out: the listener stays up for as long as the card is on\n * screen, and nothing else with a handle on this page may resume a turn by\n * posting a message at it.\n */\n function onMessage(event: MessageEvent) {\n if (\n !isSigningIn.value ||\n !isMcpOAuthReport(event, signInWindow, props.backendUrl)\n ) {\n return\n }\n const reportedServerId = event.data.mcpServerId as string | undefined\n if (\n reportedServerId &&\n mcpServerId.value &&\n reportedServerId !== mcpServerId.value\n ) {\n return\n }\n if (!event.data.success) {\n // A failure carries no server id: the callback never got that far.\n stopWatching()\n oauthError.value = event.data.error ?? 'Unknown error'\n return\n }\n const connectedServerId = reportedServerId ?? mcpServerId.value\n if (connectedServerId) {\n settleConnected(connectedServerId)\n }\n }\n\n /**\n * Opens the provider's sign-in, on an authorize URL minted NOW.\n *\n * The URL carries an OAuth `state` that lives ten minutes server-side.\n * Minted when the card rendered, it was routinely expired by the time\n * anyone clicked, and the callback then failed on a sign-in the user had\n * just completed. The window is opened blank first, synchronously, or the\n * popup blocker kills it while we wait for the URL.\n */\n async function openAuthWindow() {\n if (\n !serverName.value ||\n !props.resolveConnection ||\n isSigningIn.value\n ) {\n return\n }\n oauthError.value = null\n const popup = window.open(\n '',\n 'mcp_oauth',\n 'width=600,height=700,menubar=no,toolbar=no',\n )\n if (!popup) {\n oauthError.value = $t('auth.popupBlocked')\n return\n }\n watchForConnection(popup)\n try {\n const connection = await props.resolveConnection(serverName.value)\n mcpServerId.value = connection.mcpServerId\n popup.location.href = connection.authorizeUrl\n } catch (err) {\n stopWatching()\n popup.close()\n oauthError.value =\n err instanceof Error ? err.message : 'Failed to resolve OAuth'\n }\n }\n\n // For the card's whole life, not just between the click and the answer: a\n // card that re-renders while the sign-in window is away used to lose the\n // listener with it, and the completion landed on nobody.\n onMounted(() => window.addEventListener('message', onMessage))\n onUnmounted(() => {\n window.removeEventListener('message', onMessage)\n stopWatching()\n })\n</script>\n\n<template>\n <!-- The same frame and header as the other tool cards: this was the only\n one drawing itself as a tinted box (DESIGN.md). -->\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface text-12\">\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:link\" class=\"text-16 shrink-0\" />\n <strong class=\"truncate\">{{ serverName }}</strong>\n </div>\n <div class=\"p-sm\">\n <!-- Connected: just now, or by this card on an earlier visit -->\n <template v-if=\"isDone\">\n <div class=\"flex items-center gap-8\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <strong class=\"font-medium text-word-1\">\n {{\n $t('messagePart.requestOAuthConnectionSuccess', {\n name: serverName,\n })\n }}\n </strong>\n </div>\n </template>\n\n <!-- Signing in: the window is out and we are watching for it -->\n <template v-else-if=\"isSigningIn\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"loading-loop\" />\n <span class=\"text-10\">{{\n $t('messagePart.requestOAuthConnection')\n }}</span>\n </div>\n </template>\n\n <!-- OAuth error -->\n <template v-else-if=\"oauthError\">\n <div class=\"flex flex-col gap-xs\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:close-line\" class=\"text-danger\" />\n <strong class=\"text-10\">\n {{ oauthError }}\n </strong>\n </div>\n <VvButton\n v-if=\"canConnect\"\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </div>\n </template>\n\n <!-- Waiting on the user: show the connect button -->\n <template v-else-if=\"isAwaitingConnection && canConnect\">\n <div class=\"flex items-center gap-6 text-word-3 mb-xs\">\n <span>\n {{\n $t('messagePart.requestOAuthConnectionPrompt', {\n name: serverName,\n })\n }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </template>\n <!-- Fallback for unknown state -->\n <template v-else>\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:link\" />\n <span class=\"text-10\">\n {{\n $t('messagePart.requestOAuthConnectionInfo', {\n name: serverName,\n })\n }}\n </span>\n </div>\n </template>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;AAaA,SAAgB8B,EACZ,GACA,GACA,GACO;CACP,OACIC,EAAM,MAAM,SAAA,wBACZ,CAAC,CAACC,KACFD,EAAM,WAAWC,KACjBD,EAAM,WAAWH,EAAUK,CAAU;AAE7C;;;;;;;;;;;;;;;A,6BCIUe,IAAmB,KASnBC,IAAkB,K;;;;;;;;;;EA/BxB,IAAMG,IAAQC,GAeRC,IAAOH,GAIP,EAAE,GAAGI,MAAO5B,EAAQ,EAAE,UAAU,SAAS,CAAC,GAc1C6B,IAAWtC,QACNkC,EAAM,IAMhB,GAEKK,IAAQvC,QAAesC,EAAS,MAAM,SAAS,SAAS,GACxDE,IAAaxC,QAAesC,EAAS,MAAM,OAAO,UAAU,GAU5DG,IAAczC,QAAeW,EAAiB2B,EAAS,MAAM,MAAM,CAAC,GAGpEI,IAAsB1C,QAEnBsC,EAAS,MAAM,QACV,cAAc,EAC5B,GAEMK,IAAuB3C,QACnBuC,EAAM,UAAU,qBAAqBE,EAAY,KAC3D,GAEMG,IAAc7C,EAAmB,IAAI,GAWrC8C,IAAe9C,EAAI,EAAK,GAExB+C,IAAc/C,EAAI,EAAK,GACvBgD,IAAahD,EAAmB,IA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YXz4s.js","names":["_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_createBlock","_Fragment","VvButtonLocalized","Ee","onMounted","onUnmounted","createVNode","init_shared_esm_bundler","createBlock","Fragment","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createElementBlock","openBlock","useI18n","urlOrigin","isVoiceRenderAck","isMcpOAuthReport","event","signInWindow","backendUrl","_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","POLL_INTERVAL_MS","POLL_TIMEOUT_MS","PkToolRequestOAuthConnection_default","__emit","props","__props","emit","$t","toolPart","state","serverName","isRenderAck","isConnectedByOutput","isAwaitingConnection","mcpServerId","hasConnected","isSigningIn","oauthError","isDone","canConnect","isConnectedNow","status","pollTimer","signInAttempt","stopWatching","settleConnected","connectedServerId","watchForConnection","attempt","popup","deadline","tick","connected","onMessage","reportedServerId","openAuthWindow","connection","err","_component_VvIcon","_component_VvButton"],"sources":["../../../../packages/components/src/chat/mcpOAuthReport.ts","../../../../packages/components/src/chat/PkToolRequestOAuthConnection.vue"],"sourcesContent":["import { urlOrigin } from 'utils'\n\n/** The `type` the MCP sign-in callback page posts (mcpOAuth.controller.ts). */\nexport const MCP_OAUTH_REPORT_TYPE = 'mcp-oauth-complete'\n\n/**\n * Whether a `message` event is the report of the MCP sign-in a page opened:\n * posted by that window while it shows the callback page, which runs on the\n * backend's origin. Any other window holding the page could post the same\n * message, success included, and so could the provider's own pages, which run\n * in that same window before the callback. Without the window or the backend\n * URL nothing is a report, and the caller relies on reading the connection.\n */\nexport function isMcpOAuthReport(\n event: MessageEvent,\n signInWindow: Window | null | undefined,\n backendUrl: string | undefined,\n): boolean {\n return (\n event.data?.type === MCP_OAUTH_REPORT_TYPE &&\n !!signInWindow &&\n event.source === signInWindow &&\n event.origin === urlOrigin(backendUrl)\n )\n}\n","<script setup lang=\"ts\">\n import { computed, onMounted, onUnmounted, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n import { isMcpOAuthReport } from './mcpOAuthReport'\n\n const props = defineProps<{\n part: unknown\n /**\n * The backend the chat talks to, where the sign-in's callback page\n * runs. Without it the card hears no report and relies on its poll.\n */\n backendUrl?: string\n resolveConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; authorizeUrl: string }>\n checkConnection?: (\n serverName: string,\n ) => Promise<{ mcpServerId: string; connected: boolean }>\n }>()\n\n const emit = defineEmits<{\n connected: [mcpServerId: string]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n /** How often the connection is re-read while the sign-in window is out. */\n const POLL_INTERVAL_MS = 2000\n /**\n * How long we keep asking. The only end to a sign-in nobody finishes:\n * `popup.closed` cannot be that signal, because the browser disowns the\n * handle when the provider severs the opener (that is what\n * `Cross-Origin-Opener-Policy` does), so it reads as closed from the first\n * check of the very flow this watch exists for. Long enough for a password\n * manager and a second factor.\n */\n const POLL_TIMEOUT_MS = 5 * 60 * 1000\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n toolCallId?: string\n input?: { serverName: string }\n output?: unknown\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n const serverName = computed(() => toolPart.value.input?.serverName)\n\n /**\n * A card drawn during a CALL arrives already \"answered\": the turn could\n * not wait for the connection, so the backend closed the tool with a note\n * saying the card was drawn (see `isVoiceRenderAck`, same rule as the\n * forms). That note is not a connection, and without this the card\n * rendered its inert fallback: the caller was told to connect the account\n * and given nothing to click (measured 2026-08-07).\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n /** The output this card wrote itself once the connection went through. */\n const isConnectedByOutput = computed(\n () =>\n (toolPart.value.output as { connected?: unknown } | undefined)\n ?.connected === true,\n )\n\n const isAwaitingConnection = computed(\n () => state.value === 'input-available' || isRenderAck.value,\n )\n\n const mcpServerId = ref<string | null>(null)\n /**\n * Set once THIS card's sign-in went through, and never from a plain read of\n * the connection: a card still asking is the turn saying it could not use\n * that integration, and a token row can outlive its usefulness (a refresh\n * that failed transiently keeps the row, so the turn sees no usable token\n * while a status read still sees one). Trusting the read there would have\n * left the card claiming success, with no button, on a turn still waiting.\n * It doubles as the guard that resumes the turn exactly once, whichever\n * channel got there first.\n */\n const hasConnected = ref(false)\n /** A sign-in window we opened is still out there. */\n const isSigningIn = ref(false)\n const oauthError = ref<string | null>(null)\n\n const isDone = computed(\n () => hasConnected.value || isConnectedByOutput.value,\n )\n const canConnect = computed(\n () => Boolean(serverName.value) && Boolean(props.resolveConnection),\n )\n\n /**\n * Whether the server says this user has connected, asked without minting\n * anything: no OAuth `state` is burned by looking.\n */\n async function isConnectedNow(): Promise<boolean> {\n if (!serverName.value || !props.checkConnection) {\n return false\n }\n try {\n const status = await props.checkConnection(serverName.value)\n mcpServerId.value = status.mcpServerId\n return status.connected\n } catch {\n // Not knowing is not an error to show: the sign-in window is still\n // out there and the next read may well answer.\n return false\n }\n }\n\n let pollTimer: ReturnType<typeof setTimeout> | undefined\n /**\n * Which sign-in a running tick belongs to. A tick suspended on its read\n * outlives the attempt that scheduled it: without this it woke up inside\n * the NEXT attempt, restarted its own chain over that one's timer and then\n * stopped it on its own older deadline.\n */\n let signInAttempt = 0\n /** The window this attempt opened, the only sender we accept a report from. */\n let signInWindow: Window | null = null\n\n function stopWatching() {\n if (pollTimer !== undefined) {\n clearTimeout(pollTimer)\n pollTimer = undefined\n }\n signInAttempt += 1\n signInWindow = null\n isSigningIn.value = false\n }\n\n function settleConnected(connectedServerId: string) {\n stopWatching()\n if (hasConnected.value) {\n return\n }\n hasConnected.value = true\n mcpServerId.value = connectedServerId\n oauthError.value = null\n emit('connected', connectedServerId)\n }\n\n /**\n * Watches the connection from THIS window while the sign-in window is away.\n *\n * The callback page reports through `window.opener`, and a provider that\n * sends `Cross-Origin-Opener-Policy` anywhere in its redirect chain takes\n * that opener away: the connection then succeeds with nobody listening, the\n * card stays on its button and the suspended turn is never resumed\n * (reported 2026-08-27). This channel never goes through that window, so it\n * survives whatever the provider does to it. Chained rather than periodic:\n * a read slower than the interval would otherwise overlap the next one.\n */\n function watchForConnection(popup: Window) {\n stopWatching()\n const attempt = signInAttempt\n signInWindow = popup\n isSigningIn.value = true\n const deadline = Date.now() + POLL_TIMEOUT_MS\n const tick = async () => {\n if (attempt !== signInAttempt || Date.now() > deadline) {\n if (attempt === signInAttempt) {\n stopWatching()\n }\n return\n }\n const connected = await isConnectedNow()\n if (attempt !== signInAttempt) {\n return\n }\n if (connected && mcpServerId.value) {\n settleConnected(mcpServerId.value)\n return\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n pollTimer = setTimeout(tick, POLL_INTERVAL_MS)\n }\n\n /**\n * The callback page's own report, when the browser let it through: faster\n * than the poll, and the only channel carrying the failure reason.\n *\n * Accepted only as {@link isMcpOAuthReport} says, and only while that\n * sign-in is out: the listener stays up for as long as the card is on\n * screen, and nothing else with a handle on this page may resume a turn by\n * posting a message at it.\n */\n function onMessage(event: MessageEvent) {\n if (\n !isSigningIn.value ||\n !isMcpOAuthReport(event, signInWindow, props.backendUrl)\n ) {\n return\n }\n const reportedServerId = event.data.mcpServerId as string | undefined\n if (\n reportedServerId &&\n mcpServerId.value &&\n reportedServerId !== mcpServerId.value\n ) {\n return\n }\n if (!event.data.success) {\n // A failure carries no server id: the callback never got that far.\n stopWatching()\n oauthError.value = event.data.error ?? 'Unknown error'\n return\n }\n const connectedServerId = reportedServerId ?? mcpServerId.value\n if (connectedServerId) {\n settleConnected(connectedServerId)\n }\n }\n\n /**\n * Opens the provider's sign-in, on an authorize URL minted NOW.\n *\n * The URL carries an OAuth `state` that lives ten minutes server-side.\n * Minted when the card rendered, it was routinely expired by the time\n * anyone clicked, and the callback then failed on a sign-in the user had\n * just completed. The window is opened blank first, synchronously, or the\n * popup blocker kills it while we wait for the URL.\n */\n async function openAuthWindow() {\n if (\n !serverName.value ||\n !props.resolveConnection ||\n isSigningIn.value\n ) {\n return\n }\n oauthError.value = null\n const popup = window.open(\n '',\n 'mcp_oauth',\n 'width=600,height=700,menubar=no,toolbar=no',\n )\n if (!popup) {\n oauthError.value = $t('auth.popupBlocked')\n return\n }\n watchForConnection(popup)\n try {\n const connection = await props.resolveConnection(serverName.value)\n mcpServerId.value = connection.mcpServerId\n popup.location.href = connection.authorizeUrl\n } catch (err) {\n stopWatching()\n popup.close()\n oauthError.value =\n err instanceof Error ? err.message : 'Failed to resolve OAuth'\n }\n }\n\n // For the card's whole life, not just between the click and the answer: a\n // card that re-renders while the sign-in window is away used to lose the\n // listener with it, and the completion landed on nobody.\n onMounted(() => window.addEventListener('message', onMessage))\n onUnmounted(() => {\n window.removeEventListener('message', onMessage)\n stopWatching()\n })\n</script>\n\n<template>\n <!-- The same frame and header as the other tool cards: this was the only\n one drawing itself as a tinted box (DESIGN.md). -->\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface text-12\">\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:link\" class=\"text-16 shrink-0\" />\n <strong class=\"truncate\">{{ serverName }}</strong>\n </div>\n <div class=\"p-sm\">\n <!-- Connected: just now, or by this card on an earlier visit -->\n <template v-if=\"isDone\">\n <div class=\"flex items-center gap-8\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <strong class=\"font-medium text-word-1\">\n {{\n $t('messagePart.requestOAuthConnectionSuccess', {\n name: serverName,\n })\n }}\n </strong>\n </div>\n </template>\n\n <!-- Signing in: the window is out and we are watching for it -->\n <template v-else-if=\"isSigningIn\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"loading-loop\" />\n <span class=\"text-10\">{{\n $t('messagePart.requestOAuthConnection')\n }}</span>\n </div>\n </template>\n\n <!-- OAuth error -->\n <template v-else-if=\"oauthError\">\n <div class=\"flex flex-col gap-xs\">\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:close-line\" class=\"text-danger\" />\n <strong class=\"text-10\">\n {{ oauthError }}\n </strong>\n </div>\n <VvButton\n v-if=\"canConnect\"\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </div>\n </template>\n\n <!-- Waiting on the user: show the connect button -->\n <template v-else-if=\"isAwaitingConnection && canConnect\">\n <div class=\"flex items-center gap-6 text-word-3 mb-xs\">\n <span>\n {{\n $t('messagePart.requestOAuthConnectionPrompt', {\n name: serverName,\n })\n }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary-small\"\n icon=\"ri:external-link-line\"\n :label=\"\n $t('messagePart.requestOAuthConnectionButton', {\n name: serverName,\n })\n \"\n @click=\"openAuthWindow\" />\n </template>\n <!-- Fallback for unknown state -->\n <template v-else>\n <div class=\"flex items-center gap-8 text-word-3\">\n <VvIcon name=\"ri:link\" />\n <span class=\"text-10\">\n {{\n $t('messagePart.requestOAuthConnectionInfo', {\n name: serverName,\n })\n }}\n </span>\n </div>\n </template>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;AAaA,SAAgB8B,EACZ,GACA,GACA,GACO;CACP,OACIC,EAAM,MAAM,SAAA,wBACZ,CAAC,CAACC,KACFD,EAAM,WAAWC,KACjBD,EAAM,WAAWH,EAAUK,CAAU;AAE7C;;;;;;;;;;;;;;;A,6BCIUe,IAAmB,KASnBC,IAAkB,K;;;;;;;;;;EA/BxB,IAAMG,IAAQC,GAeRC,IAAOH,GAIP,EAAE,GAAGI,MAAO5B,EAAQ,EAAE,UAAU,SAAS,CAAC,GAc1C6B,IAAWtC,QACNkC,EAAM,IAMhB,GAEKK,IAAQvC,QAAesC,EAAS,MAAM,SAAS,SAAS,GACxDE,IAAax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K;IACJ,OAAgClF,EAAAkD,CAAA,CAAE,CAAA,4CAAA,EAAiF,MAAAG,EAAA,M;IAKnH,SAAOyB;G,iCAIZnF,EAAA,GAAAC,EASM,OATN6C,GASM,CARF3C,EAAyBmF,GAAA,EAAjB,MAAK,UAAS,CAAA,GACtBpF,EAMO,QANP6C,GAMO3C,EAJCC,EAAAkD,CAAA,CAAE,CAAA,0CAAA,EAAmF,MAAAG,EAAA,M"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./VvButtonLocalized-BgY-V26j.js";
|
|
2
2
|
import { Et as t, Q as n, S as r, Tt as i, _ as a, g as o, gt as s, h as c, k as l, kt as u, ot as d, w as f, wt 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 { t as v } from "./PkStreamingMarkdown-
|
|
4
|
+
import { t as v } from "./PkStreamingMarkdown-B8rZbprU.js";
|
|
5
5
|
// ../../packages/components/src/chat/PkCode.vue?vue&type=script&setup=true&lang.ts
|
|
6
6
|
l(), i(), d();
|
|
7
7
|
var y = ["innerHTML"], b = /* @__PURE__ */ f({
|
|
@@ -91,4 +91,4 @@ var x = { class: "border border-surface-3 rounded-xl w-full overflow-hidden" },
|
|
|
91
91
|
});
|
|
92
92
|
export { E as default };
|
|
93
93
|
|
|
94
|
-
//# sourceMappingURL=PkToolShowArtifact-
|
|
94
|
+
//# sourceMappingURL=PkToolShowArtifact-B_KIIjEn.js.map
|
package/dist/_chunks/{PkToolShowArtifact-C9_DHr5Y.js.map → PkToolShowArtifact-B_KIIjEn.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowArtifact-
|
|
1
|
+
{"version":3,"file":"PkToolShowArtifact-B_KIIjEn.js","names":["$attrs","_openBlock","_createElementBlock","_normalizeClass","_createTextVNode","_createElementVNode","$t","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","_unref","_createBlock","PkCode","PkStreamingMarkdown","_normalizeClass","VvButtonLocalized","normalizeClass","watch","createVNode","init_shared_esm_bundler","createBlock","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useClipboard","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","toolPart","artifactTypeLabel","languageLabel","isCodeType","isMarkdownType","codeLanguage","_component_VvButton","copied","copy"],"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, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\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 } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import PkCode from './PkCode.vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { copy, copied } = 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 const artifactTypeLabel = computed(() => {\n const labels: Record<string, string> = {\n code: 'Code',\n document: 'Document',\n markdown: 'Markdown',\n json: 'JSON',\n xml: 'XML',\n csv: 'CSV',\n html: 'HTML',\n yaml: 'YAML',\n sql: 'SQL',\n text: 'Text',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'Artifact'\n }\n return labels[toolPart.value.input.artifactType] || 'Artifact'\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 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 {{ artifactTypeLabel }}{{ 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=\"copy(toolPart?.input?.content || '')\" />\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 <PkStreamingMarkdown\n v-else-if=\"isMarkdownType\"\n :markdown=\"toolPart?.input?.content\"\n class=\"wysiwyg text-word-2\" />\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,IAAMsC,IAAQC,GAMRC,IAAkBhB,EAAI,EAAE,GAExBiB,IAAUhB,QACR,OAAOa,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,OAAO,CAAA,CACrB,QAAQ,MAAM,MAAM,CAAA,CACpB,QAAQ,MAAM,MAAM;GAC7B;EACJ;E,OAEAtB,EAAMsB,GAASC,GAAW,EAAE,WAAW,GAAK,CAAC,I,UAI7CzC,EAAA,GAAAC,EAOM,OAAA,EAND,OAAKC,EAAeH,EAAAA,OAAO,QAAwBA,EAAAA,O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yC,QAAA,MAAAC,EAAhC2C,EAAA,OAAU,OAAO,KAAK,GAAA,CAAA,GAC/B5C,EAEO,QAFPyC,GAEOxC,EADA4C,EAAA,KAAiB,IAAA5C,EAAM6C,EAAA,KAAa,GAAA,CAAA,C,IAG/C5C,EAMoDgD,GAAA;IAL/C,MAAM/C,EAAAgD,CAAA,IAAM,kBAAA;IACZ,OAAOhD,EAAAgD,CAAA,IAAStD,EAAAA,GAAE,eAAA,IAAoBA,EAAAA,GAAE,aAAA;IACzC,WAAU;IACT,OAAOA,EAAAA,GAAE,aAAA;IACV,OAAM;IACL,SAAK,AAAAwC,EAAA,QAAA,MAAElC,EAAAiD,CAAA,CAAI,CAACR,EAAA,OAAU,OAAO,WAAO,EAAA;;;;;G,MAE7C5C,EAkBM,OAlBN0C,GAkBM,CAhBQK,EAAA,SADVjD,EAAA,GAAAM,EAG+BC,GAAA;;IAD1B,MAAMuC,EAAA,OAAU,OAAO;IACvB,UAAUK,EAAA;G,qCAEAD,EAAA,SADflD,EAAA,GAAAM,EAGkCE,GAAA;;IAD7B,UAAUsC,EAAA,OAAU,OAAO;IAC5B,OAAM;G,8BACV9C,EAAA,GAAAC,EAQyC,OAAA;;IANrC,OAAKQ,EAAA,CAAC,+CAA6C,E,QACWqC,EAAA,OAAU,OAAO,iBAAY,cAA2CA,EAAA,OAAU,OAAO,iBAAY,O;GAK/J,GAAA3C,EAAA2C,EAAA,OAAU,OAAO,OAAO,GAAA,CAAA,E"}
|
package/dist/_chunks/{PkToolShowContactForm-DhyelktO.js → PkToolShowContactForm-DiHb3fRQ.js}
RENAMED
|
@@ -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-CPvSmI-B.js";
|
|
7
7
|
import { t as A } from "./src-QHwDXo7q.js";
|
|
8
|
-
import { t as j } from "./PkStreamingMarkdown-
|
|
8
|
+
import { t as j } from "./PkStreamingMarkdown-B8rZbprU.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-
|
|
157
|
+
//# sourceMappingURL=PkToolShowContactForm-DiHb3fRQ.js.map
|
package/dist/_chunks/{PkToolShowContactForm-DhyelktO.js.map → PkToolShowContactForm-DiHb3fRQ.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowContactForm-DhyelktO.js","names":["z.object","z.string","z.email","useForm","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_Transition","_withCtx","_Fragment","_renderList","_isRef","_createBlock","_createTextVNode","PkStreamingMarkdown","object","string","email","VvButtonLocalized","ao","Ee","watch","createVNode","init_shared_esm_bundler","renderList","createBlock","Fragment","createBaseVNode","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","init_runtime_dom_esm_bundler","Transition","withCtx","isRef","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","useLocalizedString","useSafeLocalStorage","Se","formatPhoneNumber","PkStreamingMarkdown_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","PkToolShowContactForm_default","__emit","$t","props","__props","toolPart","input","prefilled","value","field","localSubmitted","LeadFormSchema","emit","newInput","submitted","isSubmitted","submitLead","data","privacyNotice","_component_VvIcon","_component_VvAlert","_component_VvButton","VvForm","formData","_cache","$event","VvFormField"],"sources":["../../../../packages/components/src/chat/PkToolShowContactForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, watch } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useForm } from '@volverjs/form-vue'\n import * as z from 'zod'\n import { useSafeLocalStorage, useLocalizedString } from 'composables'\n import type { LocalizedString } from 'models'\n import { formatPhoneNumber } from 'utils'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const props = defineProps<{\n part: unknown\n submitted?: boolean\n loading?: boolean\n error?: string\n readonly?: boolean\n privacyPolicyNotice?: LocalizedString\n /**\n * A conversation read back (the chat logs): the card is the record\n * of the form the agent showed, its prefilled values as text. Nothing\n * in the part says whether the visitor sent it, only the contacts do.\n */\n record?: boolean\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n type: string\n toolCallId: string\n input?: {\n name: string\n email: string\n phone?: string\n conversationContext?: Record<string, unknown>\n }\n }\n return part\n })\n\n const input = computed(() => toolPart.value.input)\n\n const prefilled = computed(() =>\n (\n [\n { name: 'name', label: $t('label.name') },\n { name: 'email', label: $t('label.email') },\n { name: 'phone', label: $t('label.phone') },\n ] as const\n )\n .map((field) => {\n const value = input.value?.[field.name]?.trim()\n return {\n ...field,\n // Written as the contacts page writes it\n value:\n field.name === 'phone' && value\n ? formatPhoneNumber(value) || value\n : value,\n }\n })\n .filter((field) => field.value),\n )\n\n const localSubmitted = useSafeLocalStorage<boolean>(\n computed(\n () =>\n `${toolPart.value.toolCallId}-${toolPart.value.type}-submitted`,\n ),\n false,\n )\n\n const LeadFormSchema = z.object({\n name: z.string().min(1).max(255).default(''),\n email: z.email().max(255).default(''),\n phone: z\n .string()\n .max(50)\n .regex(/^[+0-9\\s\\-.()]*$/, $t('validation.invalidPhoneNumber'))\n .optional(),\n })\n\n const emit = defineEmits<{\n submit: [data: Record<string, unknown>]\n }>()\n\n const { VvForm, VvFormField, formData } = useForm(LeadFormSchema, {\n lazyLoad: true,\n })\n\n // Pre-populate form with input values\n watch(\n input,\n (newInput) => {\n formData.value = {\n name: newInput?.name || '',\n email: newInput?.email || '',\n phone: newInput?.phone || '',\n }\n },\n { immediate: true },\n )\n\n watch(\n () => props.submitted,\n (submitted) => {\n if (submitted) {\n localSubmitted.value = true\n }\n },\n { immediate: true },\n )\n\n const isSubmitted = computed(() => {\n return props.submitted || localSubmitted.value\n })\n\n const submitLead = async (data: Record<string, unknown>): Promise<void> => {\n emit('submit', { ...data, metadata: input.value?.conversationContext })\n }\n\n const privacyNotice = useLocalizedString(\n () => props.privacyPolicyNotice,\n 'message.defaultPrivacyPolicyNotice',\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 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8 min-h-40\">\n <VvIcon name=\"ri:send-plane-2-line\" class=\"text-16\" />\n <strong class=\"font-bold\">{{ $t('label.contactUs') }}</strong>\n </div>\n\n <Transition mode=\"out-in\">\n <div v-if=\"record\" class=\"p-sm flex flex-col gap-sm text-14\">\n <p class=\"text-word-2\">\n {{\n prefilled.length\n ? $t('message.contactFormRecordPrefilled')\n : $t('message.contactFormRecord')\n }}\n </p>\n <dl\n v-if=\"prefilled.length\"\n class=\"flex flex-wrap gap-x-lg gap-y-sm\">\n <div\n v-for=\"field in prefilled\"\n :key=\"field.name\"\n class=\"flex flex-col gap-4 min-w-0\">\n <dt class=\"text-12 text-word-3\">{{ field.label }}</dt>\n <dd class=\"text-word-1 break-words\">\n {{ field.value }}\n </dd>\n </div>\n </dl>\n </div>\n <div v-else-if=\"!isSubmitted\" class=\"p-sm\">\n <VvForm v-model=\"formData\" :readonly @submit=\"submitLead\">\n <VvFormField\n name=\"name\"\n type=\"text\"\n :label=\"$t('label.name')\"\n :placeholder=\"$t('placeholder.name')\"\n icon=\"ri:user-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"email\"\n type=\"email\"\n :label=\"$t('label.email')\"\n :placeholder=\"$t('placeholder.email')\"\n icon=\"ri:mail-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"phone\"\n type=\"tel\"\n :label=\"$t('label.phone')\"\n :placeholder=\"$t('placeholder.phone')\"\n icon=\"ri:phone-line\"\n class=\"mb-md\"\n modifiers=\"compact\" />\n\n <!-- A send that failed says so: the reason reached the\n card and was never drawn -->\n <VvAlert v-if=\"error\" modifiers=\"danger\" class=\"mb-md\">\n {{ error }}\n </VvAlert>\n\n <div class=\"flex justify-between items-center gap-16 mt-xs\">\n <div\n class=\"text-smaller text-word-3 flex items-center gap-8\">\n <VvIcon\n name=\"ri:shield-check-line\"\n class=\"text-16 shrink-0\" />\n <PkStreamingMarkdown\n :markdown=\"privacyNotice\"\n class=\"wysiwyg\" />\n </div>\n <!-- The library's default button is the brand, and in\n the chat the brand is the agent's color, as on the\n rest of the card: `primary` drew it neutral dark -->\n <VvButton\n type=\"submit\"\n :loading\n :disabled=\"loading || readonly\"\n icon-position=\"right\"\n class=\"shrink-0\"\n :label=\"$t('action.submit')\" />\n </div>\n </VvForm>\n </div>\n <div v-else class=\"p-sm\">\n <!-- One confirmation row across every tool card: a green\n check, the title in weight, the body quiet. The check is\n the outcome, so it alone carries the colour (DESIGN.md). -->\n <div class=\"flex items-center gap-sm\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <div>\n <strong class=\"font-medium block text-word-1\">\n {{ $t('message.leadSubmittedTitle') }}\n </strong>\n <p class=\"text-word-3\">\n {{ $t('message.leadSubmittedMessage') }}\n </p>\n </div>\n </div>\n </div>\n </Transition>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;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A,KAAK,GAAA,CAAA,C;;;MAGZhE,EAoBM,OApBNsD,GAoBM,CAnBFtD,EAQM,OARNuD,GAQM,CANFtD,EAE+B8E,GAAA;OAD3B,MAAK;OACL,OAAM;M,IACV9E,EAEsBU,GAAA;OADjB,UAAUR,EAAA2E,EAAA;OACX,OAAM;M,6BAKd7E,EAMmCgF,GAAA;OAL/B,MAAK;OACJ,SAAAjB,EAAA;OACA,UAAUA,EAAA,WAAWA,EAAA;OACtB,iBAAc;OACd,OAAM;OACL,OAAO7D,EAAA2D,CAAA,CAAE,CAAA,eAAA"}
|
|
1
|
+
{"version":3,"file":"PkToolShowContactForm-DiHb3fRQ.js","names":["z.object","z.string","z.email","useForm","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_Transition","_withCtx","_Fragment","_renderList","_isRef","_createBlock","_createTextVNode","PkStreamingMarkdown","object","string","email","VvButtonLocalized","ao","Ee","watch","createVNode","init_shared_esm_bundler","renderList","createBlock","Fragment","createBaseVNode","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","init_runtime_dom_esm_bundler","Transition","withCtx","isRef","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","useLocalizedString","useSafeLocalStorage","Se","formatPhoneNumber","PkStreamingMarkdown_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","PkToolShowContactForm_default","__emit","$t","props","__props","toolPart","input","prefilled","value","field","localSubmitted","LeadFormSchema","emit","newInput","submitted","isSubmitted","submitLead","data","privacyNotice","_component_VvIcon","_component_VvAlert","_component_VvButton","VvForm","formData","_cache","$event","VvFormField"],"sources":["../../../../packages/components/src/chat/PkToolShowContactForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, watch } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useForm } from '@volverjs/form-vue'\n import * as z from 'zod'\n import { useSafeLocalStorage, useLocalizedString } from 'composables'\n import type { LocalizedString } from 'models'\n import { formatPhoneNumber } from 'utils'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const props = defineProps<{\n part: unknown\n submitted?: boolean\n loading?: boolean\n error?: string\n readonly?: boolean\n privacyPolicyNotice?: LocalizedString\n /**\n * A conversation read back (the chat logs): the card is the record\n * of the form the agent showed, its prefilled values as text. Nothing\n * in the part says whether the visitor sent it, only the contacts do.\n */\n record?: boolean\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n type: string\n toolCallId: string\n input?: {\n name: string\n email: string\n phone?: string\n conversationContext?: Record<string, unknown>\n }\n }\n return part\n })\n\n const input = computed(() => toolPart.value.input)\n\n const prefilled = computed(() =>\n (\n [\n { name: 'name', label: $t('label.name') },\n { name: 'email', label: $t('label.email') },\n { name: 'phone', label: $t('label.phone') },\n ] as const\n )\n .map((field) => {\n const value = input.value?.[field.name]?.trim()\n return {\n ...field,\n // Written as the contacts page writes it\n value:\n field.name === 'phone' && value\n ? formatPhoneNumber(value) || value\n : value,\n }\n })\n .filter((field) => field.value),\n )\n\n const localSubmitted = useSafeLocalStorage<boolean>(\n computed(\n () =>\n `${toolPart.value.toolCallId}-${toolPart.value.type}-submitted`,\n ),\n false,\n )\n\n const LeadFormSchema = z.object({\n name: z.string().min(1).max(255).default(''),\n email: z.email().max(255).default(''),\n phone: z\n .string()\n .max(50)\n .regex(/^[+0-9\\s\\-.()]*$/, $t('validation.invalidPhoneNumber'))\n .optional(),\n })\n\n const emit = defineEmits<{\n submit: [data: Record<string, unknown>]\n }>()\n\n const { VvForm, VvFormField, formData } = useForm(LeadFormSchema, {\n lazyLoad: true,\n })\n\n // Pre-populate form with input values\n watch(\n input,\n (newInput) => {\n formData.value = {\n name: newInput?.name || '',\n email: newInput?.email || '',\n phone: newInput?.phone || '',\n }\n },\n { immediate: true },\n )\n\n watch(\n () => props.submitted,\n (submitted) => {\n if (submitted) {\n localSubmitted.value = true\n }\n },\n { immediate: true },\n )\n\n const isSubmitted = computed(() => {\n return props.submitted || localSubmitted.value\n })\n\n const submitLead = async (data: Record<string, unknown>): Promise<void> => {\n emit('submit', { ...data, metadata: input.value?.conversationContext })\n }\n\n const privacyNotice = useLocalizedString(\n () => props.privacyPolicyNotice,\n 'message.defaultPrivacyPolicyNotice',\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 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8 min-h-40\">\n <VvIcon name=\"ri:send-plane-2-line\" class=\"text-16\" />\n <strong class=\"font-bold\">{{ $t('label.contactUs') }}</strong>\n </div>\n\n <Transition mode=\"out-in\">\n <div v-if=\"record\" class=\"p-sm flex flex-col gap-sm text-14\">\n <p class=\"text-word-2\">\n {{\n prefilled.length\n ? $t('message.contactFormRecordPrefilled')\n : $t('message.contactFormRecord')\n }}\n </p>\n <dl\n v-if=\"prefilled.length\"\n class=\"flex flex-wrap gap-x-lg gap-y-sm\">\n <div\n v-for=\"field in prefilled\"\n :key=\"field.name\"\n class=\"flex flex-col gap-4 min-w-0\">\n <dt class=\"text-12 text-word-3\">{{ field.label }}</dt>\n <dd class=\"text-word-1 break-words\">\n {{ field.value }}\n </dd>\n </div>\n </dl>\n </div>\n <div v-else-if=\"!isSubmitted\" class=\"p-sm\">\n <VvForm v-model=\"formData\" :readonly @submit=\"submitLead\">\n <VvFormField\n name=\"name\"\n type=\"text\"\n :label=\"$t('label.name')\"\n :placeholder=\"$t('placeholder.name')\"\n icon=\"ri:user-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"email\"\n type=\"email\"\n :label=\"$t('label.email')\"\n :placeholder=\"$t('placeholder.email')\"\n icon=\"ri:mail-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"phone\"\n type=\"tel\"\n :label=\"$t('label.phone')\"\n :placeholder=\"$t('placeholder.phone')\"\n icon=\"ri:phone-line\"\n class=\"mb-md\"\n modifiers=\"compact\" />\n\n <!-- A send that failed says so: the reason reached the\n card and was never drawn -->\n <VvAlert v-if=\"error\" modifiers=\"danger\" class=\"mb-md\">\n {{ error }}\n </VvAlert>\n\n <div class=\"flex justify-between items-center gap-16 mt-xs\">\n <div\n class=\"text-smaller text-word-3 flex items-center gap-8\">\n <VvIcon\n name=\"ri:shield-check-line\"\n class=\"text-16 shrink-0\" />\n <PkStreamingMarkdown\n :markdown=\"privacyNotice\"\n class=\"wysiwyg\" />\n </div>\n <!-- The library's default button is the brand, and in\n the chat the brand is the agent's color, as on the\n rest of the card: `primary` drew it neutral dark -->\n <VvButton\n type=\"submit\"\n :loading\n :disabled=\"loading || readonly\"\n icon-position=\"right\"\n class=\"shrink-0\"\n :label=\"$t('action.submit')\" />\n </div>\n </VvForm>\n </div>\n <div v-else class=\"p-sm\">\n <!-- One confirmation row across every tool card: a green\n check, the title in weight, the body quiet. The check is\n the outcome, so it alone carries the colour (DESIGN.md). -->\n <div class=\"flex items-center gap-sm\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <div>\n <strong class=\"font-medium block text-word-1\">\n {{ $t('message.leadSubmittedTitle') }}\n </strong>\n <p class=\"text-word-3\">\n {{ $t('message.leadSubmittedMessage') }}\n </p>\n </div>\n </div>\n </div>\n </Transition>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUI,IAAM,EAAE,GAAGoE,MAAOvB,EAAQ,EAAE,UAAU,SAAS,CAAC,GAE1CwB,IAAQC,GAeRC,IAAWxC,QACAsC,EAAM,IAWtB,GAEKG,IAAQzC,QAAewC,EAAS,MAAM,KAAK,GAE3CE,IAAY1C,QAEV;GACI;IAAE,MAAM;IAAQ,OAAOqC,EAAG,YAAY;GAAE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