@8wave/ai-elements 0.112.0-beta.9 → 0.114.0-beta.14
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-D3ODaN3E.js +566 -0
- package/dist/_chunks/Agent-D3ODaN3E.js.map +1 -0
- package/dist/_chunks/{PkStreamingMarkdown-CRlRDGYl.js → PkStreamingMarkdown-CYOm47PX.js} +1276 -453
- package/dist/_chunks/PkStreamingMarkdown-CYOm47PX.js.map +1 -0
- package/dist/_chunks/{PkToolRequestGeolocation-BbxYKt-9.js → PkToolRequestGeolocation-BY7nXImb.js} +2 -2
- package/dist/_chunks/{PkToolRequestGeolocation-BbxYKt-9.js.map → PkToolRequestGeolocation-BY7nXImb.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestOAuthConnection-CTp2w60F.js → PkToolRequestOAuthConnection-DFOTALFt.js} +2 -2
- package/dist/_chunks/{PkToolRequestOAuthConnection-CTp2w60F.js.map → PkToolRequestOAuthConnection-DFOTALFt.js.map} +1 -1
- package/dist/_chunks/{PkToolShowArtifact-CNnt82aH.js → PkToolShowArtifact-DzHRWoru.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-CNnt82aH.js.map → PkToolShowArtifact-DzHRWoru.js.map} +1 -1
- package/dist/_chunks/{PkToolShowContactForm-D77gyjQG.js → PkToolShowContactForm-1J6_1AA2.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-D77gyjQG.js.map → PkToolShowContactForm-1J6_1AA2.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-DP4LLAk3.js → PkToolShowForm-DmQYj3v1.js} +5 -5
- package/dist/_chunks/{PkToolShowForm-DP4LLAk3.js.map → PkToolShowForm-DmQYj3v1.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-Bwy0Ptmi.js → PkToolShowSources-BO8V5rlS.js} +3 -3
- package/dist/_chunks/{PkToolShowSources-Bwy0Ptmi.js.map → PkToolShowSources-BO8V5rlS.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSuggestedReply-CFO8wV1b.js → PkToolShowSuggestedReply-CTWVG1Zk.js} +2 -2
- package/dist/_chunks/{PkToolShowSuggestedReply-CFO8wV1b.js.map → PkToolShowSuggestedReply-CTWVG1Zk.js.map} +1 -1
- package/dist/_chunks/{PkToolShowVideo-Djr8Ofsz.js → PkToolShowVideo-p6Y9j3-B.js} +3 -3
- package/dist/_chunks/PkToolShowVideo-p6Y9j3-B.js.map +1 -0
- package/dist/_chunks/{browser-B0Xnbqi7.js → browser-Ct5TRDgj.js} +521 -518
- package/dist/_chunks/{browser-B0Xnbqi7.js.map → browser-Ct5TRDgj.js.map} +1 -1
- package/dist/_chunks/{markdown-BRD-hDrH.js → markdown-JpLFzufn.js} +7 -7
- package/dist/_chunks/markdown-JpLFzufn.js.map +1 -0
- package/dist/_chunks/url-validation-uLMZ5-AU.js.map +1 -1
- package/dist/_chunks/{web-Dzr6HJ14.js → web-CEmtEYdH.js} +89 -65
- package/dist/_chunks/web-CEmtEYdH.js.map +1 -0
- package/dist/ai-elements.es.js +2109 -2321
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotAuth.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/{Document-B6RpxFr9.js → Document-2X01-F4Z.js} +2 -2
- package/dist-vue/_chunks/Document-2X01-F4Z.js.map +1 -0
- package/dist-vue/_chunks/Media-_HfFLHGD.js.map +1 -1
- package/dist-vue/_chunks/{PkChatbot-CI9ucJ2M.js → PkChatbot-BdvDl_Gw.js} +8 -8
- package/dist-vue/_chunks/{PkChatbot-CI9ucJ2M.js.map → PkChatbot-BdvDl_Gw.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotAuth-AxAOI9t2.js → PkChatbotAuth-Bi508F1u.js} +57 -57
- package/dist-vue/_chunks/PkChatbotAuth-Bi508F1u.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotEmptyState-CacY4o02.js → PkChatbotEmptyState-DycCrfwz.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-CacY4o02.js.map → PkChatbotEmptyState-DycCrfwz.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotInput-Dkz3SNAk.js → PkChatbotInput-BCuqLdkT.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotInput-Dkz3SNAk.js.map → PkChatbotInput-BCuqLdkT.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotMessages-PjKRDNYJ.js +776 -0
- package/dist-vue/_chunks/PkChatbotMessages-PjKRDNYJ.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotStepPayload-DU0W-eUp.js → PkChatbotStepPayload-CI98RiNv.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-DU0W-eUp.js.map → PkChatbotStepPayload-CI98RiNv.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-etlBryOg.js → PkChatbotStepToolDetail-B8zXJOdI.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-etlBryOg.js.map → PkChatbotStepToolDetail-B8zXJOdI.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotSteps-CL27pMFS.js +190 -0
- package/dist-vue/_chunks/{PkChatbotSteps-jW07Q-4x.js.map → PkChatbotSteps-CL27pMFS.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-jEBBPmSo.js → PkChatbotViewChat-CS-OSJfX.js} +8 -8
- package/dist-vue/_chunks/{PkChatbotViewChat-jEBBPmSo.js.map → PkChatbotViewChat-CS-OSJfX.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewConversations-CWSrP36z.js → PkChatbotViewConversations-BCdolW0R.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewConversations-CWSrP36z.js.map → PkChatbotViewConversations-BCdolW0R.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewFiles-DzLp1WfU.js → PkChatbotViewFiles-Cudao8ew.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewFiles-DzLp1WfU.js.map → PkChatbotViewFiles-Cudao8ew.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewProfile-CHbn3W6F.js → PkChatbotViewProfile-DDsKOkcC.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewProfile-CHbn3W6F.js.map → PkChatbotViewProfile-DDsKOkcC.js.map} +1 -1
- package/dist-vue/_chunks/PkStreamingMarkdown-B2iju0WK.js +3245 -0
- package/dist-vue/_chunks/PkStreamingMarkdown-B2iju0WK.js.map +1 -0
- package/dist-vue/_chunks/{PkToolShowArtifact-BnwU7CV2.js → PkToolShowArtifact-C0J71YF6.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-BnwU7CV2.js.map → PkToolShowArtifact-C0J71YF6.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowContactForm-_x_dbiHn.js → PkToolShowContactForm-De3Od9mC.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-_x_dbiHn.js.map → PkToolShowContactForm-De3Od9mC.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-CjJcLvWs.js → PkToolShowDiagram-DmY_hhAS.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-CjJcLvWs.js.map → PkToolShowDiagram-DmY_hhAS.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowEmail-CRQjoJr1.js → PkToolShowEmail-D_Z15wCS.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowEmail-CRQjoJr1.js.map → PkToolShowEmail-D_Z15wCS.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-IPAkJIXh.js → PkToolShowForm-DUGysIxj.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowForm-IPAkJIXh.js.map → PkToolShowForm-DUGysIxj.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowMessage-joTzAg9N.js → PkToolShowMessage-e5_EI5mV.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowMessage-joTzAg9N.js.map → PkToolShowMessage-e5_EI5mV.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-tOYjd2bq.js → PkToolShowProductList-B3X7Svyc.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-tOYjd2bq.js.map → PkToolShowProductList-B3X7Svyc.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-Cc26LzRd.js → PkToolShowSources-BUjBSGc5.js} +4 -4
- package/dist-vue/_chunks/{PkToolShowSources-Cc26LzRd.js.map → PkToolShowSources-BUjBSGc5.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowVideo-Bv9kMd88.js → PkToolShowVideo-BZOTu2Qe.js} +3 -3
- package/dist-vue/_chunks/PkToolShowVideo-BZOTu2Qe.js.map +1 -0
- package/dist-vue/_chunks/{PkToolShowWebPages-D3Xy4iUs.js → PkToolShowWebPages-DEih8h5k.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-D3Xy4iUs.js.map → PkToolShowWebPages-DEih8h5k.js.map} +1 -1
- package/dist-vue/_chunks/{PkUrl-BgMBemSz.js → PkUrl-3NH9t-WA.js} +2 -2
- package/dist-vue/_chunks/{PkUrl-BgMBemSz.js.map → PkUrl-3NH9t-WA.js.map} +1 -1
- package/dist-vue/_chunks/url-validation-uLMZ5-AU.js.map +1 -1
- package/dist-vue/_chunks/{useChatbotStore-CMS2zFht.js → useChatbotStore-BwrBZJCq.js} +944 -1259
- package/dist-vue/_chunks/useChatbotStore-BwrBZJCq.js.map +1 -0
- package/dist-vue/_chunks/utils-BL4Ppr2R.js +184 -0
- package/dist-vue/_chunks/utils-BL4Ppr2R.js.map +1 -0
- package/dist-vue/_chunks/{web-Dzr6HJ14.js → web-CEmtEYdH.js} +89 -65
- package/dist-vue/_chunks/web-CEmtEYdH.js.map +1 -0
- package/dist-vue/apps/web-component/src/composables/useChatbotAuth.d.ts +1 -3
- package/dist-vue/apps/web-component/src/composables/useChatbotAuthForm.d.ts +0 -1
- package/dist-vue/composables.js +2841 -103
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/index.js +261 -206
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +16 -20
- package/dist-vue/packages/auth/src/social-redirect-plugin.d.ts +18 -12
- package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +2 -2
- package/dist-vue/packages/components/src/chat/markdownHtml.d.ts +20 -0
- package/dist-vue/packages/components/src/chat/utils.d.ts +9 -0
- package/dist-vue/packages/models/src/schema/AgentApiTool.d.ts +70 -0
- package/dist-vue/packages/models/src/schema/Lead.d.ts +13 -0
- package/dist-vue/packages/models/src/schema/Media.d.ts +0 -1
- package/dist-vue/packages/models/src/schema/ModelProvider.d.ts +12 -3
- package/dist-vue/packages/models/src/schema/Organization.d.ts +3 -3
- package/dist-vue/packages/models/src/schema/User.d.ts +10 -0
- package/dist-vue/packages/models/src/schema/constants.d.ts +1 -1
- package/dist-vue/style.css +1 -1
- package/package.json +4 -3
- package/dist/_chunks/Agent-DTLrWpzX.js +0 -460
- package/dist/_chunks/Agent-DTLrWpzX.js.map +0 -1
- package/dist/_chunks/Media-Cft7Pwrh.js +0 -108
- package/dist/_chunks/Media-Cft7Pwrh.js.map +0 -1
- package/dist/_chunks/PkStreamingMarkdown-CRlRDGYl.js.map +0 -1
- package/dist/_chunks/PkToolShowVideo-Djr8Ofsz.js.map +0 -1
- package/dist/_chunks/markdown-BRD-hDrH.js.map +0 -1
- package/dist/_chunks/web-Dzr6HJ14.js.map +0 -1
- package/dist-vue/_chunks/Document-B6RpxFr9.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotAuth-AxAOI9t2.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotMessages-BsT48S-h.js +0 -776
- package/dist-vue/_chunks/PkChatbotMessages-BsT48S-h.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotSteps-jW07Q-4x.js +0 -190
- package/dist-vue/_chunks/PkStreamingMarkdown-BoEpwaYQ.js +0 -2430
- package/dist-vue/_chunks/PkStreamingMarkdown-BoEpwaYQ.js.map +0 -1
- package/dist-vue/_chunks/PkToolShowVideo-Bv9kMd88.js.map +0 -1
- package/dist-vue/_chunks/useChatbotStore-CMS2zFht.js.map +0 -1
- package/dist-vue/_chunks/utils-h4C7rRcu.js +0 -177
- package/dist-vue/_chunks/utils-h4C7rRcu.js.map +0 -1
- package/dist-vue/_chunks/web-Dzr6HJ14.js.map +0 -1
package/dist-vue/_chunks/{PkToolShowSources-Cc26LzRd.js.map → PkToolShowSources-BUjBSGc5.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowSources-Cc26LzRd.js","names":["$t"],"sources":["../../../../packages/components/src/chat/PkChunkPreview.vue","../../../../packages/components/src/chat/PkChunkPreview.vue","../../../../packages/components/src/chat/PkDocumentHeader.vue","../../../../packages/components/src/chat/PkDocumentHeader.vue","../../../../packages/components/src/chat/PkToolShowSources.vue","../../../../packages/components/src/chat/PkToolShowSources.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { stripMarkdown } from 'utils'\n\n const props = defineProps<{\n content: string\n similarity?: number\n maxSimilarity?: number\n expanded: boolean\n }>()\n\n const similarityPercent = computed(() => {\n if (props.similarity == null) {\n return null\n }\n const max =\n props.maxSimilarity && props.maxSimilarity > 0\n ? props.maxSimilarity\n : 1\n return Math.round((props.similarity / max) * 100)\n })\n</script>\n\n<template>\n <VvIcon name=\"ri:text-snippet\" class=\"shrink-0 text-12 text-word-4\" />\n <span class=\"text-10 text-word-2 truncate flex-1\" :title=\"content\">\n {{ stripMarkdown(content) }}\n </span>\n <span v-if=\"similarityPercent != null\" class=\"text-10 text-word-4 shrink-0\">\n {{ similarityPercent }}%\n </span>\n <VvIcon\n :name=\"expanded ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\"\n class=\"text-14 text-word-4 shrink-0\" />\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { stripMarkdown } from 'utils'\n\n const props = defineProps<{\n content: string\n similarity?: number\n maxSimilarity?: number\n expanded: boolean\n }>()\n\n const similarityPercent = computed(() => {\n if (props.similarity == null) {\n return null\n }\n const max =\n props.maxSimilarity && props.maxSimilarity > 0\n ? props.maxSimilarity\n : 1\n return Math.round((props.similarity / max) * 100)\n })\n</script>\n\n<template>\n <VvIcon name=\"ri:text-snippet\" class=\"shrink-0 text-12 text-word-4\" />\n <span class=\"text-10 text-word-2 truncate flex-1\" :title=\"content\">\n {{ stripMarkdown(content) }}\n </span>\n <span v-if=\"similarityPercent != null\" class=\"text-10 text-word-4 shrink-0\">\n {{ similarityPercent }}%\n </span>\n <VvIcon\n :name=\"expanded ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\"\n class=\"text-14 text-word-4 shrink-0\" />\n</template>\n","<script setup lang=\"ts\">\n import type { DocumentType } from 'models'\n import { getTypeIcon } from 'models'\n import PkUrl from '../PkUrl.vue'\n\n defineProps<{\n type: string\n name: string\n url?: string\n filename?: string\n }>()\n</script>\n\n<template>\n <VvIcon\n :name=\"getTypeIcon(type as DocumentType)\"\n class=\"shrink-0 text-14 text-word-3\" />\n <div class=\"flex flex-col gap-2 min-w-0 flex-1\">\n <strong class=\"font-bold text-12 text-word-1 truncate block\">\n {{ name }}\n </strong>\n <span v-if=\"filename\" class=\"text-10 text-word-4 truncate\">\n {{ filename }}\n </span>\n <span\n v-if=\"url\"\n class=\"text-10 text-word-4 truncate flex items-center gap-4\">\n <VvIcon name=\"ri:link\" class=\"shrink-0 text-10\" />\n <PkUrl :url=\"url\" />\n </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import type { DocumentType } from 'models'\n import { getTypeIcon } from 'models'\n import PkUrl from '../PkUrl.vue'\n\n defineProps<{\n type: string\n name: string\n url?: string\n filename?: string\n }>()\n</script>\n\n<template>\n <VvIcon\n :name=\"getTypeIcon(type as DocumentType)\"\n class=\"shrink-0 text-14 text-word-3\" />\n <div class=\"flex flex-col gap-2 min-w-0 flex-1\">\n <strong class=\"font-bold text-12 text-word-1 truncate block\">\n {{ name }}\n </strong>\n <span v-if=\"filename\" class=\"text-10 text-word-4 truncate\">\n {{ filename }}\n </span>\n <span\n v-if=\"url\"\n class=\"text-10 text-word-4 truncate flex items-center gap-4\">\n <VvIcon name=\"ri:link\" class=\"shrink-0 text-10\" />\n <PkUrl :url=\"url\" />\n </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref, reactive } from 'vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n import PkChunkPreview from './PkChunkPreview.vue'\n import PkDocumentHeader from './PkDocumentHeader.vue'\n\n interface SourceItem {\n chunkId: string\n documentId: string\n documentName: string\n documentType: string\n language: string\n content: string\n chunkIndex?: number | null\n similarity?: number\n sourceUrl?: string\n sourceFilename?: string\n sourceDescription?: string\n sourceImageUrl?: string\n }\n\n const props = defineProps<{\n part: unknown\n onExpandContext?: (payload: {\n documentId: string\n chunkIndex: number\n }) => Promise<string>\n onDownload?: (documentId: string) => void\n }>()\n\n const toolPart = computed(() => {\n return props.part as {\n input?: {\n sources: SourceItem[]\n }\n }\n })\n\n const sources = computed(() => toolPart.value.input?.sources || [])\n\n const groupedSources = computed(() => {\n const groups = new Map<\n string,\n { document: SourceItem; chunks: SourceItem[] }\n >()\n for (const source of sources.value) {\n const existing = groups.get(source.documentId)\n if (existing) {\n existing.chunks.push(source)\n } else {\n groups.set(source.documentId, {\n document: source,\n chunks: [source],\n })\n }\n }\n return [...groups.values()]\n })\n\n const maxSimilarity = computed(() => {\n return Math.max(...sources.value.map((s) => s.similarity ?? 0), 0)\n })\n\n const expandedDocuments = reactive(new Set<string>())\n const expandedChunks = reactive(new Set<string>())\n const contextData = reactive(new Map<string, string>())\n const loadingContext = reactive(new Set<string>())\n\n const toggleDocument = (documentId: string) => {\n if (expandedDocuments.has(documentId)) {\n expandedDocuments.delete(documentId)\n } else {\n expandedDocuments.add(documentId)\n }\n }\n\n const toggleChunk = (chunkId: string) => {\n if (expandedChunks.has(chunkId)) {\n expandedChunks.delete(chunkId)\n } else {\n expandedChunks.add(chunkId)\n }\n }\n\n const handleExpandContext = async (source: SourceItem) => {\n if (source.chunkIndex == null || !props.onExpandContext) {\n return\n }\n loadingContext.add(source.chunkId)\n try {\n const content = await props.onExpandContext({\n documentId: source.documentId,\n chunkIndex: source.chunkIndex,\n })\n contextData.set(source.chunkId, content)\n } finally {\n loadingContext.delete(source.chunkId)\n }\n }\n\n const clearContext = (chunkId: string) => {\n contextData.delete(chunkId)\n }\n\n const showMore = ref(false)\n const visibleGroups = computed(() => {\n if (showMore.value) {\n return groupedSources.value\n }\n return groupedSources.value.slice(0, 3)\n })\n const hasMore = computed(() => groupedSources.value.length > 3)\n</script>\n\n<template>\n <div v-if=\"sources.length\" class=\"flex flex-col gap-xs w-full\">\n <div class=\"flex items-center gap-4 text-12 text-word-3 font-semibold\">\n <VvIcon name=\"ri:article-line\" class=\"text-14\" />\n {{ $t('label.sources') }}\n <span class=\"text-word-4 font-normal\">\n ({{ groupedSources.length }})\n </span>\n </div>\n\n <ul class=\"flex flex-col gap-xs\">\n <li\n v-for=\"group in visibleGroups\"\n :key=\"group.document.documentId\"\n class=\"border border-surface-3 rounded-xl overflow-hidden\">\n <!-- Document header -->\n <button\n class=\"flex items-center gap-8 p-8 w-full text-left hover:bg-surface-1 transition-colors cursor-pointer\"\n @click=\"toggleDocument(group.document.documentId)\">\n <PkDocumentHeader\n :type=\"group.document.documentType\"\n :name=\"group.document.documentName\"\n :url=\"group.document.sourceUrl\"\n :filename=\"group.document.sourceFilename\" />\n <div class=\"flex items-center gap-4 shrink-0\">\n <span\n v-if=\"group.chunks.length > 1\"\n class=\"text-10 text-word-4 bg-surface-2 rounded px-4 py-2\">\n {{ group.chunks.length }}\n </span>\n <span\n class=\"text-10 text-word-4 bg-surface-2 rounded px-4 py-2 uppercase\">\n {{ group.document.language }}\n </span>\n <VvIcon\n :name=\"\n expandedDocuments.has(group.document.documentId)\n ? 'ri:arrow-up-s-line'\n : 'ri:arrow-down-s-line'\n \"\n class=\"text-16 text-word-3\" />\n </div>\n </button>\n\n <!-- Expanded content -->\n <div\n v-if=\"expandedDocuments.has(group.document.documentId)\"\n class=\"border-t border-surface-3\">\n <PkStreamingMarkdown\n v-if=\"group.document.sourceDescription\"\n :markdown=\"group.document.sourceDescription\"\n class=\"px-8 py-4 text-10 text-word-3 bg-surface-1 border-b border-surface-3\" />\n\n <!-- Chunk excerpts -->\n <div\n v-for=\"chunk in group.chunks\"\n :key=\"chunk.chunkId\"\n class=\"border-b border-surface-3 last:border-b-0\">\n <button\n class=\"flex items-center gap-8 px-8 py-6 w-full text-left hover:bg-surface-1 transition-colors cursor-pointer\"\n @click=\"toggleChunk(chunk.chunkId)\">\n <PkChunkPreview\n :content=\"chunk.content\"\n :similarity=\"chunk.similarity\"\n :max-similarity=\"maxSimilarity\"\n :expanded=\"expandedChunks.has(chunk.chunkId)\" />\n </button>\n\n <!-- Expanded chunk content -->\n <div\n v-if=\"expandedChunks.has(chunk.chunkId)\"\n class=\"bg-surface-1 border-t border-surface-3\">\n <div class=\"p-8 text-10 text-word-3\">\n <transition mode=\"out-in\">\n <!-- Context expansion -->\n <PkStreamingMarkdown\n v-if=\"contextData.has(chunk.chunkId)\"\n :markdown=\"\n contextData.get(chunk.chunkId)!\n \"\n class=\"wysiwyg\" />\n\n <!-- Chunk content -->\n <PkStreamingMarkdown\n v-else\n :markdown=\"chunk.content\"\n class=\"wysiwyg\" />\n </transition>\n </div>\n\n <!-- Actions bar -->\n <div\n class=\"flex items-center gap-8 px-8 py-6 border-t border-surface-3 bg-surface\">\n <!-- Expand / collapse context -->\n <button\n v-if=\"\n onExpandContext &&\n chunk.chunkIndex != null &&\n !contextData.has(chunk.chunkId)\n \"\n class=\"text-10 text-word-3 hover:text-word flex items-center gap-4 cursor-pointer\"\n :disabled=\"\n loadingContext.has(chunk.chunkId)\n \"\n @click=\"handleExpandContext(chunk)\">\n <VvIcon\n :name=\"\n loadingContext.has(chunk.chunkId)\n ? 'loading-loop'\n : 'ri:expand-up-down-line'\n \"\n class=\"text-12\" />\n {{ $t('label.expandContext') }}\n </button>\n <button\n v-else-if=\"contextData.has(chunk.chunkId)\"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 cursor-pointer\"\n @click=\"clearContext(chunk.chunkId)\">\n <VvIcon\n name=\"ri:collapse-vertical-line\"\n class=\"text-12\" />\n {{ $t('label.collapseContext') }}\n </button>\n\n <!-- Open source URL -->\n <a\n v-if=\"chunk.sourceUrl\"\n :href=\"chunk.sourceUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 ml-auto\">\n <VvIcon\n name=\"ri:external-link-line\"\n class=\"text-12\" />\n {{ $t('label.openSource') }}\n </a>\n\n <!-- Download file -->\n <button\n v-if=\"\n onDownload &&\n chunk.documentType === 'file'\n \"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 cursor-pointer\"\n :class=\"{\n 'ml-auto': !chunk.sourceUrl,\n }\"\n @click=\"onDownload(chunk.documentId)\">\n <VvIcon\n name=\"ri:download-line\"\n class=\"text-12\" />\n {{ $t('label.downloadFile') }}\n </button>\n </div>\n </div>\n </div>\n </div>\n </li>\n </ul>\n\n <!-- Show more -->\n <button\n v-if=\"hasMore\"\n class=\"text-12 text-word-3 cursor-pointer hover:underline flex items-center gap-4 mx-auto\"\n @click=\"showMore = !showMore\">\n <VvIcon\n :name=\"showMore ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\"\n class=\"text-16\" />\n {{\n showMore\n ? $t('action.showLess')\n : $t('action.showMore', {\n count: groupedSources.length - 3,\n })\n }}\n </button>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref, reactive } from 'vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n import PkChunkPreview from './PkChunkPreview.vue'\n import PkDocumentHeader from './PkDocumentHeader.vue'\n\n interface SourceItem {\n chunkId: string\n documentId: string\n documentName: string\n documentType: string\n language: string\n content: string\n chunkIndex?: number | null\n similarity?: number\n sourceUrl?: string\n sourceFilename?: string\n sourceDescription?: string\n sourceImageUrl?: string\n }\n\n const props = defineProps<{\n part: unknown\n onExpandContext?: (payload: {\n documentId: string\n chunkIndex: number\n }) => Promise<string>\n onDownload?: (documentId: string) => void\n }>()\n\n const toolPart = computed(() => {\n return props.part as {\n input?: {\n sources: SourceItem[]\n }\n }\n })\n\n const sources = computed(() => toolPart.value.input?.sources || [])\n\n const groupedSources = computed(() => {\n const groups = new Map<\n string,\n { document: SourceItem; chunks: SourceItem[] }\n >()\n for (const source of sources.value) {\n const existing = groups.get(source.documentId)\n if (existing) {\n existing.chunks.push(source)\n } else {\n groups.set(source.documentId, {\n document: source,\n chunks: [source],\n })\n }\n }\n return [...groups.values()]\n })\n\n const maxSimilarity = computed(() => {\n return Math.max(...sources.value.map((s) => s.similarity ?? 0), 0)\n })\n\n const expandedDocuments = reactive(new Set<string>())\n const expandedChunks = reactive(new Set<string>())\n const contextData = reactive(new Map<string, string>())\n const loadingContext = reactive(new Set<string>())\n\n const toggleDocument = (documentId: string) => {\n if (expandedDocuments.has(documentId)) {\n expandedDocuments.delete(documentId)\n } else {\n expandedDocuments.add(documentId)\n }\n }\n\n const toggleChunk = (chunkId: string) => {\n if (expandedChunks.has(chunkId)) {\n expandedChunks.delete(chunkId)\n } else {\n expandedChunks.add(chunkId)\n }\n }\n\n const handleExpandContext = async (source: SourceItem) => {\n if (source.chunkIndex == null || !props.onExpandContext) {\n return\n }\n loadingContext.add(source.chunkId)\n try {\n const content = await props.onExpandContext({\n documentId: source.documentId,\n chunkIndex: source.chunkIndex,\n })\n contextData.set(source.chunkId, content)\n } finally {\n loadingContext.delete(source.chunkId)\n }\n }\n\n const clearContext = (chunkId: string) => {\n contextData.delete(chunkId)\n }\n\n const showMore = ref(false)\n const visibleGroups = computed(() => {\n if (showMore.value) {\n return groupedSources.value\n }\n return groupedSources.value.slice(0, 3)\n })\n const hasMore = computed(() => groupedSources.value.length > 3)\n</script>\n\n<template>\n <div v-if=\"sources.length\" class=\"flex flex-col gap-xs w-full\">\n <div class=\"flex items-center gap-4 text-12 text-word-3 font-semibold\">\n <VvIcon name=\"ri:article-line\" class=\"text-14\" />\n {{ $t('label.sources') }}\n <span class=\"text-word-4 font-normal\">\n ({{ groupedSources.length }})\n </span>\n </div>\n\n <ul class=\"flex flex-col gap-xs\">\n <li\n v-for=\"group in visibleGroups\"\n :key=\"group.document.documentId\"\n class=\"border border-surface-3 rounded-xl overflow-hidden\">\n <!-- Document header -->\n <button\n class=\"flex items-center gap-8 p-8 w-full text-left hover:bg-surface-1 transition-colors cursor-pointer\"\n @click=\"toggleDocument(group.document.documentId)\">\n <PkDocumentHeader\n :type=\"group.document.documentType\"\n :name=\"group.document.documentName\"\n :url=\"group.document.sourceUrl\"\n :filename=\"group.document.sourceFilename\" />\n <div class=\"flex items-center gap-4 shrink-0\">\n <span\n v-if=\"group.chunks.length > 1\"\n class=\"text-10 text-word-4 bg-surface-2 rounded px-4 py-2\">\n {{ group.chunks.length }}\n </span>\n <span\n class=\"text-10 text-word-4 bg-surface-2 rounded px-4 py-2 uppercase\">\n {{ group.document.language }}\n </span>\n <VvIcon\n :name=\"\n expandedDocuments.has(group.document.documentId)\n ? 'ri:arrow-up-s-line'\n : 'ri:arrow-down-s-line'\n \"\n class=\"text-16 text-word-3\" />\n </div>\n </button>\n\n <!-- Expanded content -->\n <div\n v-if=\"expandedDocuments.has(group.document.documentId)\"\n class=\"border-t border-surface-3\">\n <PkStreamingMarkdown\n v-if=\"group.document.sourceDescription\"\n :markdown=\"group.document.sourceDescription\"\n class=\"px-8 py-4 text-10 text-word-3 bg-surface-1 border-b border-surface-3\" />\n\n <!-- Chunk excerpts -->\n <div\n v-for=\"chunk in group.chunks\"\n :key=\"chunk.chunkId\"\n class=\"border-b border-surface-3 last:border-b-0\">\n <button\n class=\"flex items-center gap-8 px-8 py-6 w-full text-left hover:bg-surface-1 transition-colors cursor-pointer\"\n @click=\"toggleChunk(chunk.chunkId)\">\n <PkChunkPreview\n :content=\"chunk.content\"\n :similarity=\"chunk.similarity\"\n :max-similarity=\"maxSimilarity\"\n :expanded=\"expandedChunks.has(chunk.chunkId)\" />\n </button>\n\n <!-- Expanded chunk content -->\n <div\n v-if=\"expandedChunks.has(chunk.chunkId)\"\n class=\"bg-surface-1 border-t border-surface-3\">\n <div class=\"p-8 text-10 text-word-3\">\n <transition mode=\"out-in\">\n <!-- Context expansion -->\n <PkStreamingMarkdown\n v-if=\"contextData.has(chunk.chunkId)\"\n :markdown=\"\n contextData.get(chunk.chunkId)!\n \"\n class=\"wysiwyg\" />\n\n <!-- Chunk content -->\n <PkStreamingMarkdown\n v-else\n :markdown=\"chunk.content\"\n class=\"wysiwyg\" />\n </transition>\n </div>\n\n <!-- Actions bar -->\n <div\n class=\"flex items-center gap-8 px-8 py-6 border-t border-surface-3 bg-surface\">\n <!-- Expand / collapse context -->\n <button\n v-if=\"\n onExpandContext &&\n chunk.chunkIndex != null &&\n !contextData.has(chunk.chunkId)\n \"\n class=\"text-10 text-word-3 hover:text-word flex items-center gap-4 cursor-pointer\"\n :disabled=\"\n loadingContext.has(chunk.chunkId)\n \"\n @click=\"handleExpandContext(chunk)\">\n <VvIcon\n :name=\"\n loadingContext.has(chunk.chunkId)\n ? 'loading-loop'\n : 'ri:expand-up-down-line'\n \"\n class=\"text-12\" />\n {{ $t('label.expandContext') }}\n </button>\n <button\n v-else-if=\"contextData.has(chunk.chunkId)\"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 cursor-pointer\"\n @click=\"clearContext(chunk.chunkId)\">\n <VvIcon\n name=\"ri:collapse-vertical-line\"\n class=\"text-12\" />\n {{ $t('label.collapseContext') }}\n </button>\n\n <!-- Open source URL -->\n <a\n v-if=\"chunk.sourceUrl\"\n :href=\"chunk.sourceUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 ml-auto\">\n <VvIcon\n name=\"ri:external-link-line\"\n class=\"text-12\" />\n {{ $t('label.openSource') }}\n </a>\n\n <!-- Download file -->\n <button\n v-if=\"\n onDownload &&\n chunk.documentType === 'file'\n \"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 cursor-pointer\"\n :class=\"{\n 'ml-auto': !chunk.sourceUrl,\n }\"\n @click=\"onDownload(chunk.documentId)\">\n <VvIcon\n name=\"ri:download-line\"\n class=\"text-12\" />\n {{ $t('label.downloadFile') }}\n </button>\n </div>\n </div>\n </div>\n </div>\n </li>\n </ul>\n\n <!-- Show more -->\n <button\n v-if=\"hasMore\"\n class=\"text-12 text-word-3 cursor-pointer hover:underline flex items-center gap-4 mx-auto\"\n @click=\"showMore = !showMore\">\n <VvIcon\n :name=\"showMore ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\"\n class=\"text-16\" />\n {{\n showMore\n ? $t('action.showLess')\n : $t('action.showMore', {\n count: groupedSources.length - 3,\n })\n }}\n </button>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAII,IAAM,IAAQ,GAOR,IAAoB,QAAe;GACrC,IAAI,EAAM,cAAc,MACpB,OAAO;GAEX,IAAM,IACF,EAAM,iBAAiB,EAAM,gBAAgB,IACvC,EAAM,gBACN;GACV,OAAO,KAAK,MAAO,EAA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A,EAAA,IAAA,EAAA"}
|
|
1
|
+
{"version":3,"file":"PkToolShowSources-BUjBSGc5.js","names":["$t"],"sources":["../../../../packages/components/src/chat/PkChunkPreview.vue","../../../../packages/components/src/chat/PkChunkPreview.vue","../../../../packages/components/src/chat/PkDocumentHeader.vue","../../../../packages/components/src/chat/PkDocumentHeader.vue","../../../../packages/components/src/chat/PkToolShowSources.vue","../../../../packages/components/src/chat/PkToolShowSources.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { stripMarkdown } from 'utils'\n\n const props = defineProps<{\n content: string\n similarity?: number\n maxSimilarity?: number\n expanded: boolean\n }>()\n\n const similarityPercent = computed(() => {\n if (props.similarity == null) {\n return null\n }\n const max =\n props.maxSimilarity && props.maxSimilarity > 0\n ? props.maxSimilarity\n : 1\n return Math.round((props.similarity / max) * 100)\n })\n</script>\n\n<template>\n <VvIcon name=\"ri:text-snippet\" class=\"shrink-0 text-12 text-word-4\" />\n <span class=\"text-10 text-word-2 truncate flex-1\" :title=\"content\">\n {{ stripMarkdown(content) }}\n </span>\n <span v-if=\"similarityPercent != null\" class=\"text-10 text-word-4 shrink-0\">\n {{ similarityPercent }}%\n </span>\n <VvIcon\n :name=\"expanded ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\"\n class=\"text-14 text-word-4 shrink-0\" />\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { stripMarkdown } from 'utils'\n\n const props = defineProps<{\n content: string\n similarity?: number\n maxSimilarity?: number\n expanded: boolean\n }>()\n\n const similarityPercent = computed(() => {\n if (props.similarity == null) {\n return null\n }\n const max =\n props.maxSimilarity && props.maxSimilarity > 0\n ? props.maxSimilarity\n : 1\n return Math.round((props.similarity / max) * 100)\n })\n</script>\n\n<template>\n <VvIcon name=\"ri:text-snippet\" class=\"shrink-0 text-12 text-word-4\" />\n <span class=\"text-10 text-word-2 truncate flex-1\" :title=\"content\">\n {{ stripMarkdown(content) }}\n </span>\n <span v-if=\"similarityPercent != null\" class=\"text-10 text-word-4 shrink-0\">\n {{ similarityPercent }}%\n </span>\n <VvIcon\n :name=\"expanded ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\"\n class=\"text-14 text-word-4 shrink-0\" />\n</template>\n","<script setup lang=\"ts\">\n import type { DocumentType } from 'models'\n import { getTypeIcon } from 'models'\n import PkUrl from '../PkUrl.vue'\n\n defineProps<{\n type: string\n name: string\n url?: string\n filename?: string\n }>()\n</script>\n\n<template>\n <VvIcon\n :name=\"getTypeIcon(type as DocumentType)\"\n class=\"shrink-0 text-14 text-word-3\" />\n <div class=\"flex flex-col gap-2 min-w-0 flex-1\">\n <strong class=\"font-bold text-12 text-word-1 truncate block\">\n {{ name }}\n </strong>\n <span v-if=\"filename\" class=\"text-10 text-word-4 truncate\">\n {{ filename }}\n </span>\n <span\n v-if=\"url\"\n class=\"text-10 text-word-4 truncate flex items-center gap-4\">\n <VvIcon name=\"ri:link\" class=\"shrink-0 text-10\" />\n <PkUrl :url=\"url\" />\n </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import type { DocumentType } from 'models'\n import { getTypeIcon } from 'models'\n import PkUrl from '../PkUrl.vue'\n\n defineProps<{\n type: string\n name: string\n url?: string\n filename?: string\n }>()\n</script>\n\n<template>\n <VvIcon\n :name=\"getTypeIcon(type as DocumentType)\"\n class=\"shrink-0 text-14 text-word-3\" />\n <div class=\"flex flex-col gap-2 min-w-0 flex-1\">\n <strong class=\"font-bold text-12 text-word-1 truncate block\">\n {{ name }}\n </strong>\n <span v-if=\"filename\" class=\"text-10 text-word-4 truncate\">\n {{ filename }}\n </span>\n <span\n v-if=\"url\"\n class=\"text-10 text-word-4 truncate flex items-center gap-4\">\n <VvIcon name=\"ri:link\" class=\"shrink-0 text-10\" />\n <PkUrl :url=\"url\" />\n </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref, reactive } from 'vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n import PkChunkPreview from './PkChunkPreview.vue'\n import PkDocumentHeader from './PkDocumentHeader.vue'\n\n interface SourceItem {\n chunkId: string\n documentId: string\n documentName: string\n documentType: string\n language: string\n content: string\n chunkIndex?: number | null\n similarity?: number\n sourceUrl?: string\n sourceFilename?: string\n sourceDescription?: string\n sourceImageUrl?: string\n }\n\n const props = defineProps<{\n part: unknown\n onExpandContext?: (payload: {\n documentId: string\n chunkIndex: number\n }) => Promise<string>\n onDownload?: (documentId: string) => void\n }>()\n\n const toolPart = computed(() => {\n return props.part as {\n input?: {\n sources: SourceItem[]\n }\n }\n })\n\n const sources = computed(() => toolPart.value.input?.sources || [])\n\n const groupedSources = computed(() => {\n const groups = new Map<\n string,\n { document: SourceItem; chunks: SourceItem[] }\n >()\n for (const source of sources.value) {\n const existing = groups.get(source.documentId)\n if (existing) {\n existing.chunks.push(source)\n } else {\n groups.set(source.documentId, {\n document: source,\n chunks: [source],\n })\n }\n }\n return [...groups.values()]\n })\n\n const maxSimilarity = computed(() => {\n return Math.max(...sources.value.map((s) => s.similarity ?? 0), 0)\n })\n\n const expandedDocuments = reactive(new Set<string>())\n const expandedChunks = reactive(new Set<string>())\n const contextData = reactive(new Map<string, string>())\n const loadingContext = reactive(new Set<string>())\n\n const toggleDocument = (documentId: string) => {\n if (expandedDocuments.has(documentId)) {\n expandedDocuments.delete(documentId)\n } else {\n expandedDocuments.add(documentId)\n }\n }\n\n const toggleChunk = (chunkId: string) => {\n if (expandedChunks.has(chunkId)) {\n expandedChunks.delete(chunkId)\n } else {\n expandedChunks.add(chunkId)\n }\n }\n\n const handleExpandContext = async (source: SourceItem) => {\n if (source.chunkIndex == null || !props.onExpandContext) {\n return\n }\n loadingContext.add(source.chunkId)\n try {\n const content = await props.onExpandContext({\n documentId: source.documentId,\n chunkIndex: source.chunkIndex,\n })\n contextData.set(source.chunkId, content)\n } finally {\n loadingContext.delete(source.chunkId)\n }\n }\n\n const clearContext = (chunkId: string) => {\n contextData.delete(chunkId)\n }\n\n const showMore = ref(false)\n const visibleGroups = computed(() => {\n if (showMore.value) {\n return groupedSources.value\n }\n return groupedSources.value.slice(0, 3)\n })\n const hasMore = computed(() => groupedSources.value.length > 3)\n</script>\n\n<template>\n <div v-if=\"sources.length\" class=\"flex flex-col gap-xs w-full\">\n <div class=\"flex items-center gap-4 text-12 text-word-3 font-semibold\">\n <VvIcon name=\"ri:article-line\" class=\"text-14\" />\n {{ $t('label.sources') }}\n <span class=\"text-word-4 font-normal\">\n ({{ groupedSources.length }})\n </span>\n </div>\n\n <ul class=\"flex flex-col gap-xs\">\n <li\n v-for=\"group in visibleGroups\"\n :key=\"group.document.documentId\"\n class=\"border border-surface-3 rounded-xl overflow-hidden\">\n <!-- Document header -->\n <button\n class=\"flex items-center gap-8 p-8 w-full text-left hover:bg-surface-1 transition-colors cursor-pointer\"\n @click=\"toggleDocument(group.document.documentId)\">\n <PkDocumentHeader\n :type=\"group.document.documentType\"\n :name=\"group.document.documentName\"\n :url=\"group.document.sourceUrl\"\n :filename=\"group.document.sourceFilename\" />\n <div class=\"flex items-center gap-4 shrink-0\">\n <span\n v-if=\"group.chunks.length > 1\"\n class=\"text-10 text-word-4 bg-surface-2 rounded px-4 py-2\">\n {{ group.chunks.length }}\n </span>\n <span\n class=\"text-10 text-word-4 bg-surface-2 rounded px-4 py-2 uppercase\">\n {{ group.document.language }}\n </span>\n <VvIcon\n :name=\"\n expandedDocuments.has(group.document.documentId)\n ? 'ri:arrow-up-s-line'\n : 'ri:arrow-down-s-line'\n \"\n class=\"text-16 text-word-3\" />\n </div>\n </button>\n\n <!-- Expanded content -->\n <div\n v-if=\"expandedDocuments.has(group.document.documentId)\"\n class=\"border-t border-surface-3\">\n <PkStreamingMarkdown\n v-if=\"group.document.sourceDescription\"\n :markdown=\"group.document.sourceDescription\"\n class=\"px-8 py-4 text-10 text-word-3 bg-surface-1 border-b border-surface-3\" />\n\n <!-- Chunk excerpts -->\n <div\n v-for=\"chunk in group.chunks\"\n :key=\"chunk.chunkId\"\n class=\"border-b border-surface-3 last:border-b-0\">\n <button\n class=\"flex items-center gap-8 px-8 py-6 w-full text-left hover:bg-surface-1 transition-colors cursor-pointer\"\n @click=\"toggleChunk(chunk.chunkId)\">\n <PkChunkPreview\n :content=\"chunk.content\"\n :similarity=\"chunk.similarity\"\n :max-similarity=\"maxSimilarity\"\n :expanded=\"expandedChunks.has(chunk.chunkId)\" />\n </button>\n\n <!-- Expanded chunk content -->\n <div\n v-if=\"expandedChunks.has(chunk.chunkId)\"\n class=\"bg-surface-1 border-t border-surface-3\">\n <div class=\"p-8 text-10 text-word-3\">\n <transition mode=\"out-in\">\n <!-- Context expansion -->\n <PkStreamingMarkdown\n v-if=\"contextData.has(chunk.chunkId)\"\n :markdown=\"\n contextData.get(chunk.chunkId)!\n \"\n class=\"wysiwyg\" />\n\n <!-- Chunk content -->\n <PkStreamingMarkdown\n v-else\n :markdown=\"chunk.content\"\n class=\"wysiwyg\" />\n </transition>\n </div>\n\n <!-- Actions bar -->\n <div\n class=\"flex items-center gap-8 px-8 py-6 border-t border-surface-3 bg-surface\">\n <!-- Expand / collapse context -->\n <button\n v-if=\"\n onExpandContext &&\n chunk.chunkIndex != null &&\n !contextData.has(chunk.chunkId)\n \"\n class=\"text-10 text-word-3 hover:text-word flex items-center gap-4 cursor-pointer\"\n :disabled=\"\n loadingContext.has(chunk.chunkId)\n \"\n @click=\"handleExpandContext(chunk)\">\n <VvIcon\n :name=\"\n loadingContext.has(chunk.chunkId)\n ? 'loading-loop'\n : 'ri:expand-up-down-line'\n \"\n class=\"text-12\" />\n {{ $t('label.expandContext') }}\n </button>\n <button\n v-else-if=\"contextData.has(chunk.chunkId)\"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 cursor-pointer\"\n @click=\"clearContext(chunk.chunkId)\">\n <VvIcon\n name=\"ri:collapse-vertical-line\"\n class=\"text-12\" />\n {{ $t('label.collapseContext') }}\n </button>\n\n <!-- Open source URL -->\n <a\n v-if=\"chunk.sourceUrl\"\n :href=\"chunk.sourceUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 ml-auto\">\n <VvIcon\n name=\"ri:external-link-line\"\n class=\"text-12\" />\n {{ $t('label.openSource') }}\n </a>\n\n <!-- Download file -->\n <button\n v-if=\"\n onDownload &&\n chunk.documentType === 'file'\n \"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 cursor-pointer\"\n :class=\"{\n 'ml-auto': !chunk.sourceUrl,\n }\"\n @click=\"onDownload(chunk.documentId)\">\n <VvIcon\n name=\"ri:download-line\"\n class=\"text-12\" />\n {{ $t('label.downloadFile') }}\n </button>\n </div>\n </div>\n </div>\n </div>\n </li>\n </ul>\n\n <!-- Show more -->\n <button\n v-if=\"hasMore\"\n class=\"text-12 text-word-3 cursor-pointer hover:underline flex items-center gap-4 mx-auto\"\n @click=\"showMore = !showMore\">\n <VvIcon\n :name=\"showMore ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\"\n class=\"text-16\" />\n {{\n showMore\n ? $t('action.showLess')\n : $t('action.showMore', {\n count: groupedSources.length - 3,\n })\n }}\n </button>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref, reactive } from 'vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n import PkChunkPreview from './PkChunkPreview.vue'\n import PkDocumentHeader from './PkDocumentHeader.vue'\n\n interface SourceItem {\n chunkId: string\n documentId: string\n documentName: string\n documentType: string\n language: string\n content: string\n chunkIndex?: number | null\n similarity?: number\n sourceUrl?: string\n sourceFilename?: string\n sourceDescription?: string\n sourceImageUrl?: string\n }\n\n const props = defineProps<{\n part: unknown\n onExpandContext?: (payload: {\n documentId: string\n chunkIndex: number\n }) => Promise<string>\n onDownload?: (documentId: string) => void\n }>()\n\n const toolPart = computed(() => {\n return props.part as {\n input?: {\n sources: SourceItem[]\n }\n }\n })\n\n const sources = computed(() => toolPart.value.input?.sources || [])\n\n const groupedSources = computed(() => {\n const groups = new Map<\n string,\n { document: SourceItem; chunks: SourceItem[] }\n >()\n for (const source of sources.value) {\n const existing = groups.get(source.documentId)\n if (existing) {\n existing.chunks.push(source)\n } else {\n groups.set(source.documentId, {\n document: source,\n chunks: [source],\n })\n }\n }\n return [...groups.values()]\n })\n\n const maxSimilarity = computed(() => {\n return Math.max(...sources.value.map((s) => s.similarity ?? 0), 0)\n })\n\n const expandedDocuments = reactive(new Set<string>())\n const expandedChunks = reactive(new Set<string>())\n const contextData = reactive(new Map<string, string>())\n const loadingContext = reactive(new Set<string>())\n\n const toggleDocument = (documentId: string) => {\n if (expandedDocuments.has(documentId)) {\n expandedDocuments.delete(documentId)\n } else {\n expandedDocuments.add(documentId)\n }\n }\n\n const toggleChunk = (chunkId: string) => {\n if (expandedChunks.has(chunkId)) {\n expandedChunks.delete(chunkId)\n } else {\n expandedChunks.add(chunkId)\n }\n }\n\n const handleExpandContext = async (source: SourceItem) => {\n if (source.chunkIndex == null || !props.onExpandContext) {\n return\n }\n loadingContext.add(source.chunkId)\n try {\n const content = await props.onExpandContext({\n documentId: source.documentId,\n chunkIndex: source.chunkIndex,\n })\n contextData.set(source.chunkId, content)\n } finally {\n loadingContext.delete(source.chunkId)\n }\n }\n\n const clearContext = (chunkId: string) => {\n contextData.delete(chunkId)\n }\n\n const showMore = ref(false)\n const visibleGroups = computed(() => {\n if (showMore.value) {\n return groupedSources.value\n }\n return groupedSources.value.slice(0, 3)\n })\n const hasMore = computed(() => groupedSources.value.length > 3)\n</script>\n\n<template>\n <div v-if=\"sources.length\" class=\"flex flex-col gap-xs w-full\">\n <div class=\"flex items-center gap-4 text-12 text-word-3 font-semibold\">\n <VvIcon name=\"ri:article-line\" class=\"text-14\" />\n {{ $t('label.sources') }}\n <span class=\"text-word-4 font-normal\">\n ({{ groupedSources.length }})\n </span>\n </div>\n\n <ul class=\"flex flex-col gap-xs\">\n <li\n v-for=\"group in visibleGroups\"\n :key=\"group.document.documentId\"\n class=\"border border-surface-3 rounded-xl overflow-hidden\">\n <!-- Document header -->\n <button\n class=\"flex items-center gap-8 p-8 w-full text-left hover:bg-surface-1 transition-colors cursor-pointer\"\n @click=\"toggleDocument(group.document.documentId)\">\n <PkDocumentHeader\n :type=\"group.document.documentType\"\n :name=\"group.document.documentName\"\n :url=\"group.document.sourceUrl\"\n :filename=\"group.document.sourceFilename\" />\n <div class=\"flex items-center gap-4 shrink-0\">\n <span\n v-if=\"group.chunks.length > 1\"\n class=\"text-10 text-word-4 bg-surface-2 rounded px-4 py-2\">\n {{ group.chunks.length }}\n </span>\n <span\n class=\"text-10 text-word-4 bg-surface-2 rounded px-4 py-2 uppercase\">\n {{ group.document.language }}\n </span>\n <VvIcon\n :name=\"\n expandedDocuments.has(group.document.documentId)\n ? 'ri:arrow-up-s-line'\n : 'ri:arrow-down-s-line'\n \"\n class=\"text-16 text-word-3\" />\n </div>\n </button>\n\n <!-- Expanded content -->\n <div\n v-if=\"expandedDocuments.has(group.document.documentId)\"\n class=\"border-t border-surface-3\">\n <PkStreamingMarkdown\n v-if=\"group.document.sourceDescription\"\n :markdown=\"group.document.sourceDescription\"\n class=\"px-8 py-4 text-10 text-word-3 bg-surface-1 border-b border-surface-3\" />\n\n <!-- Chunk excerpts -->\n <div\n v-for=\"chunk in group.chunks\"\n :key=\"chunk.chunkId\"\n class=\"border-b border-surface-3 last:border-b-0\">\n <button\n class=\"flex items-center gap-8 px-8 py-6 w-full text-left hover:bg-surface-1 transition-colors cursor-pointer\"\n @click=\"toggleChunk(chunk.chunkId)\">\n <PkChunkPreview\n :content=\"chunk.content\"\n :similarity=\"chunk.similarity\"\n :max-similarity=\"maxSimilarity\"\n :expanded=\"expandedChunks.has(chunk.chunkId)\" />\n </button>\n\n <!-- Expanded chunk content -->\n <div\n v-if=\"expandedChunks.has(chunk.chunkId)\"\n class=\"bg-surface-1 border-t border-surface-3\">\n <div class=\"p-8 text-10 text-word-3\">\n <transition mode=\"out-in\">\n <!-- Context expansion -->\n <PkStreamingMarkdown\n v-if=\"contextData.has(chunk.chunkId)\"\n :markdown=\"\n contextData.get(chunk.chunkId)!\n \"\n class=\"wysiwyg\" />\n\n <!-- Chunk content -->\n <PkStreamingMarkdown\n v-else\n :markdown=\"chunk.content\"\n class=\"wysiwyg\" />\n </transition>\n </div>\n\n <!-- Actions bar -->\n <div\n class=\"flex items-center gap-8 px-8 py-6 border-t border-surface-3 bg-surface\">\n <!-- Expand / collapse context -->\n <button\n v-if=\"\n onExpandContext &&\n chunk.chunkIndex != null &&\n !contextData.has(chunk.chunkId)\n \"\n class=\"text-10 text-word-3 hover:text-word flex items-center gap-4 cursor-pointer\"\n :disabled=\"\n loadingContext.has(chunk.chunkId)\n \"\n @click=\"handleExpandContext(chunk)\">\n <VvIcon\n :name=\"\n loadingContext.has(chunk.chunkId)\n ? 'loading-loop'\n : 'ri:expand-up-down-line'\n \"\n class=\"text-12\" />\n {{ $t('label.expandContext') }}\n </button>\n <button\n v-else-if=\"contextData.has(chunk.chunkId)\"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 cursor-pointer\"\n @click=\"clearContext(chunk.chunkId)\">\n <VvIcon\n name=\"ri:collapse-vertical-line\"\n class=\"text-12\" />\n {{ $t('label.collapseContext') }}\n </button>\n\n <!-- Open source URL -->\n <a\n v-if=\"chunk.sourceUrl\"\n :href=\"chunk.sourceUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 ml-auto\">\n <VvIcon\n name=\"ri:external-link-line\"\n class=\"text-12\" />\n {{ $t('label.openSource') }}\n </a>\n\n <!-- Download file -->\n <button\n v-if=\"\n onDownload &&\n chunk.documentType === 'file'\n \"\n class=\"text-10 text-word-3 hover:text-word-1 flex items-center gap-4 cursor-pointer\"\n :class=\"{\n 'ml-auto': !chunk.sourceUrl,\n }\"\n @click=\"onDownload(chunk.documentId)\">\n <VvIcon\n name=\"ri:download-line\"\n class=\"text-12\" />\n {{ $t('label.downloadFile') }}\n </button>\n </div>\n </div>\n </div>\n </div>\n </li>\n </ul>\n\n <!-- Show more -->\n <button\n v-if=\"hasMore\"\n class=\"text-12 text-word-3 cursor-pointer hover:underline flex items-center gap-4 mx-auto\"\n @click=\"showMore = !showMore\">\n <VvIcon\n :name=\"showMore ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\"\n class=\"text-16\" />\n {{\n showMore\n ? $t('action.showLess')\n : $t('action.showMore', {\n count: groupedSources.length - 3,\n })\n }}\n </button>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAII,IAAM,IAAQ,GAOR,IAAoB,QAAe;GACrC,IAAI,EAAM,cAAc,MACpB,OAAO;GAEX,IAAM,IACF,EAAM,iBAAiB,EAAM,gBAAgB,IACvC,EAAM,gBACN;GACV,OAAO,KAAK,MAAO,EAAM,aAAa,IAAO,GAAG;EACpD,CAAC;;;;IAID,EAAsE,GAAA;KAA9D,MAAK;KAAkB,OAAM;;IACrC,EAEO,QAAA;KAFD,OAAM;KAAuC,OAAO,EAAA;IACnD,GAAA,EAAA,EAAA,CAAA,CAAa,CAAC,EAAA,OAAO,CAAA,GAAA,GAAA,CAAA;IAEhB,EAAA,SAAiB,OAE7B,EAAA,IAAA,EAAA,KAFA,EAAA,GAAA,EAEO,QAFP,GAEO,EADA,EAAA,KAAiB,IAAG,MAC3B,CAAA;IACA,EAE2C,GAAA;KADtC,MAAM,EAAA,WAAQ,uBAAA;KACf,OAAM;;;;;;;;;;;;;;;;;;;;;;GEnBV,OAAA,EAAA,GAAA,EAAA,GAAA,MAAA,CAAA,EAE2C,GAAA;IADtC,MAAM,EAAA,CAAA,CAAW,CAAC,EAAA,IAAI;IACvB,OAAM;GACV,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,GAAA,EAaM,OAbN,GAaM;IAZF,EAES,UAFT,GAES,EADF,EAAA,IAAI,GAAA,CAAA;IAEC,EAAA,YAAZ,EAAA,GAAA,EAE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MADlB,MAAK;MACL,OAAM;KAAY,CAAA,GAAA,EAAA,MACtB,EAAGA,EAAAA,GAAE,oBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,IAAA,CAAA,KAAA,EAAA,IAAA,EAAA;;IAWvB,EAAA,SADV,EAAA,GAAA,EAcS,UAAA;;KAZL,OAAM;KACL,SAAK,AAAA,EAAA,QAAA,MAAE,EAAA,QAAQ,CAAI,EAAA;IACpB,GAAA,CAAA,EAEsB,GAAA;KADjB,MAAM,EAAA,QAAQ,uBAAA;KACf,OAAM;IAAY,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,GAAA,EAAA,MACtB,EACI,EAAA,QAA+BA,EAAAA,GAAE,iBAAA,IAA0CA,EAAAA,GAAE,mBAAA,EAAuD,OAAA,EAAA,MAAe,SAAM,EAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,KAAA,EAAA,IAAA,EAAA"}
|
|
@@ -6,7 +6,7 @@ var d = (e) => e.replace(/[^a-zA-Z0-9_-]/g, ""), f = (e, t) => e === t || e.ends
|
|
|
6
6
|
if (e.hostname.endsWith("youtu.be")) return d(e.pathname.split("/")[1] ?? "") || null;
|
|
7
7
|
let t = e.searchParams.get("v");
|
|
8
8
|
if (t) return d(t) || null;
|
|
9
|
-
let n = e.pathname.match(/^\/(?:shorts|embed|v)\/([^/?#]+)/);
|
|
9
|
+
let n = e.pathname.match(/^\/(?:shorts|live|embed|v)\/([^/?#]+)/);
|
|
10
10
|
return n && d(n[1]) || null;
|
|
11
11
|
}, m = (e) => {
|
|
12
12
|
let t = e.pathname.match(/(?:^|\/)(\d+)(?:$|[/?#])/);
|
|
@@ -40,7 +40,7 @@ function h(e, t) {
|
|
|
40
40
|
provider: "vimeo",
|
|
41
41
|
url: e,
|
|
42
42
|
videoId: t,
|
|
43
|
-
embedUrl: `https://player.vimeo.com/video/${t}`
|
|
43
|
+
embedUrl: `https://player.vimeo.com/video/${t}?dnt=1`
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
return t && t !== "file" ? {
|
|
@@ -119,4 +119,4 @@ var g = {
|
|
|
119
119
|
//#endregion
|
|
120
120
|
export { D as default };
|
|
121
121
|
|
|
122
|
-
//# sourceMappingURL=PkToolShowVideo-
|
|
122
|
+
//# sourceMappingURL=PkToolShowVideo-BZOTu2Qe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PkToolShowVideo-BZOTu2Qe.js","names":["$t"],"sources":["../../../../packages/utils/src/video-source.ts","../../../../packages/components/src/chat/PkToolShowVideo.vue","../../../../packages/components/src/chat/PkToolShowVideo.vue"],"sourcesContent":["/**\n * Video source parsing shared by the backend platform renderer and the frontend\n * player component, so both classify a video URL the same way.\n *\n * A URL is either a known provider (YouTube/Vimeo), which plays through the\n * provider's iframe embed, or a direct media file (`file`), which plays in a\n * native `<video>` element. Detection is by URL shape; an explicit `hint` is\n * used only as a fallback when the URL alone is inconclusive.\n */\n\nexport type VideoProvider = 'youtube' | 'vimeo' | 'file'\n\nexport interface ParsedVideoSource {\n provider: VideoProvider\n /** The original URL, unchanged. */\n url: string\n /**\n * The URL to actually load: the provider iframe embed URL for\n * YouTube/Vimeo, or the direct file URL for `file`.\n */\n embedUrl: string\n /** The provider video id (providers only). */\n videoId?: string\n /**\n * A preview image URL derived from the provider, when one is available\n * without an extra API call (currently YouTube only). Lets a link-only\n * surface (e.g. a Teams card) show a thumbnail instead of a bare link.\n */\n thumbnailUrl?: string\n}\n\n/** Keep only characters that are legal in a provider video id. */\nconst sanitizeId = (raw: string): string => raw.replace(/[^a-zA-Z0-9_-]/g, '')\n\n/**\n * True when `host` is exactly `domain` or a subdomain of it. Guards against\n * lookalike hosts (e.g. `notyoutube.com`) that a bare substring check would\n * misclassify.\n */\nconst hostMatches = (host: string, domain: string): boolean =>\n host === domain || host.endsWith(`.${domain}`)\n\n/** Extract the YouTube video id from any of its URL shapes, or null. */\nconst youtubeId = (u: URL): string | null => {\n // youtu.be/<id>\n if (u.hostname.endsWith('youtu.be')) {\n return sanitizeId(u.pathname.split('/')[1] ?? '') || null\n }\n // youtube.com/watch?v=<id>\n const v = u.searchParams.get('v')\n if (v) {\n return sanitizeId(v) || null\n }\n // youtube.com/shorts/<id>, /live/<id>, /embed/<id>, /v/<id>\n const m = u.pathname.match(/^\\/(?:shorts|live|embed|v)\\/([^/?#]+)/)\n return m ? sanitizeId(m[1]) || null : null\n}\n\n/** Extract the Vimeo (numeric) video id, or null. */\nconst vimeoId = (u: URL): string | null => {\n // player.vimeo.com/video/<id> or vimeo.com/<id>\n const m = u.pathname.match(/(?:^|\\/)(\\d+)(?:$|[/?#])/)\n return m ? m[1] : null\n}\n\n/**\n * Classify a video URL into a provider + a loadable embed/file URL.\n * Falls back to `file` (native `<video>`) for anything not recognized as a\n * supported provider, or when a provider is matched but no id can be extracted.\n */\nexport function parseVideoSource(\n url: string,\n hint?: VideoProvider,\n): ParsedVideoSource {\n let u: URL | undefined\n try {\n u = new URL(url)\n } catch {\n // Not an absolute URL: treat as a direct file reference.\n return { provider: 'file', url, embedUrl: url }\n }\n\n const host = u.hostname.toLowerCase()\n\n const isYouTube =\n hostMatches(host, 'youtube.com') ||\n hostMatches(host, 'youtu.be') ||\n hostMatches(host, 'youtube-nocookie.com')\n if (isYouTube) {\n const id = youtubeId(u)\n if (id) {\n return {\n provider: 'youtube',\n url,\n videoId: id,\n embedUrl: `https://www.youtube-nocookie.com/embed/${id}`,\n thumbnailUrl: `https://img.youtube.com/vi/${id}/hqdefault.jpg`,\n }\n }\n }\n\n if (hostMatches(host, 'vimeo.com')) {\n const id = vimeoId(u)\n if (id) {\n return {\n provider: 'vimeo',\n url,\n videoId: id,\n // `dnt=1`: the player sets no cookies and records no session\n // data, the Vimeo counterpart of youtube-nocookie above.\n embedUrl: `https://player.vimeo.com/video/${id}?dnt=1`,\n }\n }\n }\n\n // Honor an explicit provider hint only if we could not extract an id from a\n // provider URL (so a caller-tagged provider link still routes to an iframe\n // via its original URL rather than a broken native <video>).\n if (hint && hint !== 'file') {\n return { provider: hint, url, embedUrl: url }\n }\n\n return { provider: 'file', url, embedUrl: url }\n}\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { parseVideoSource, type VideoProvider } from 'utils'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n interface VideoInput {\n url: string\n title?: string\n description?: string\n poster?: string\n provider?: VideoProvider\n }\n\n // Permissions granted to provider embeds (YouTube/Vimeo players).\n const IFRAME_ALLOW =\n 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share'\n\n const videos = computed(() => {\n const part = props.part as { input?: { videos?: VideoInput[] } }\n return (part.input?.videos ?? []).map((video) => ({\n ...video,\n source: parseVideoSource(video.url, video.provider),\n }))\n })\n</script>\n\n<template>\n <div\n v-if=\"videos.length\"\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 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8 min-h-40\">\n <VvIcon name=\"ri:film-line\" class=\"text-16\" />\n <strong class=\"font-bold\">\n {{ $t('label.video') }}\n </strong>\n </div>\n <div class=\"p-sm flex flex-col gap-16\">\n <div v-for=\"video in videos\" :key=\"video.url\" class=\"flex flex-col\">\n <strong v-if=\"video.title\" class=\"font-bold text-14 mb-sm\">\n {{ video.title }}\n </strong>\n <!-- Direct file: native player. Handles MP4/WebM/OGG and works\n inside the widget's Shadow DOM without any extra CSS. -->\n <video\n v-if=\"video.source.provider === 'file'\"\n :src=\"video.source.embedUrl\"\n :poster=\"video.poster\"\n controls\n preload=\"metadata\"\n playsinline\n class=\"w-full rounded-xl bg-word-1\"\n style=\"aspect-ratio: 16 / 9; max-height: 480px\">\n <a\n :href=\"video.url\"\n target=\"_blank\"\n rel=\"noopener noreferrer\">\n {{ video.title ?? video.url }}\n </a>\n </video>\n <!-- Provider (YouTube/Vimeo): iframe embed, 16:9 responsive. -->\n <div\n v-else\n class=\"relative w-full overflow-hidden rounded-xl bg-word-1\"\n style=\"aspect-ratio: 16 / 9\">\n <iframe\n :src=\"video.source.embedUrl\"\n :title=\"video.title ?? video.url\"\n loading=\"lazy\"\n referrerpolicy=\"strict-origin-when-cross-origin\"\n :allow=\"IFRAME_ALLOW\"\n allowfullscreen\n class=\"absolute inset-0 w-full h-full border-0\"></iframe>\n </div>\n <span\n v-if=\"video.description\"\n class=\"text-12 text-word-3 mt-sm\">\n {{ video.description }}\n </span>\n </div>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { parseVideoSource, type VideoProvider } from 'utils'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n interface VideoInput {\n url: string\n title?: string\n description?: string\n poster?: string\n provider?: VideoProvider\n }\n\n // Permissions granted to provider embeds (YouTube/Vimeo players).\n const IFRAME_ALLOW =\n 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share'\n\n const videos = computed(() => {\n const part = props.part as { input?: { videos?: VideoInput[] } }\n return (part.input?.videos ?? []).map((video) => ({\n ...video,\n source: parseVideoSource(video.url, video.provider),\n }))\n })\n</script>\n\n<template>\n <div\n v-if=\"videos.length\"\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 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8 min-h-40\">\n <VvIcon name=\"ri:film-line\" class=\"text-16\" />\n <strong class=\"font-bold\">\n {{ $t('label.video') }}\n </strong>\n </div>\n <div class=\"p-sm flex flex-col gap-16\">\n <div v-for=\"video in videos\" :key=\"video.url\" class=\"flex flex-col\">\n <strong v-if=\"video.title\" class=\"font-bold text-14 mb-sm\">\n {{ video.title }}\n </strong>\n <!-- Direct file: native player. Handles MP4/WebM/OGG and works\n inside the widget's Shadow DOM without any extra CSS. -->\n <video\n v-if=\"video.source.provider === 'file'\"\n :src=\"video.source.embedUrl\"\n :poster=\"video.poster\"\n controls\n preload=\"metadata\"\n playsinline\n class=\"w-full rounded-xl bg-word-1\"\n style=\"aspect-ratio: 16 / 9; max-height: 480px\">\n <a\n :href=\"video.url\"\n target=\"_blank\"\n rel=\"noopener noreferrer\">\n {{ video.title ?? video.url }}\n </a>\n </video>\n <!-- Provider (YouTube/Vimeo): iframe embed, 16:9 responsive. -->\n <div\n v-else\n class=\"relative w-full overflow-hidden rounded-xl bg-word-1\"\n style=\"aspect-ratio: 16 / 9\">\n <iframe\n :src=\"video.source.embedUrl\"\n :title=\"video.title ?? video.url\"\n loading=\"lazy\"\n referrerpolicy=\"strict-origin-when-cross-origin\"\n :allow=\"IFRAME_ALLOW\"\n allowfullscreen\n class=\"absolute inset-0 w-full h-full border-0\"></iframe>\n </div>\n <span\n v-if=\"video.description\"\n class=\"text-12 text-word-3 mt-sm\">\n {{ video.description }}\n </span>\n </div>\n </div>\n </div>\n</template>\n"],"mappings":";;;;AAgCA,IAAM,KAAc,MAAwB,EAAI,QAAQ,mBAAmB,EAAE,GAOvE,KAAe,GAAc,MAC/B,MAAS,KAAU,EAAK,SAAS,IAAI,GAAQ,GAG3C,KAAa,MAA0B;CAEzC,IAAI,EAAE,SAAS,SAAS,UAAU,GAC9B,OAAO,EAAW,EAAE,SAAS,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK;CAGzD,IAAM,IAAI,EAAE,aAAa,IAAI,GAAG;CAChC,IAAI,GACA,OAAO,EAAW,CAAC,KAAK;CAG5B,IAAM,IAAI,EAAE,SAAS,MAAM,uCAAuC;CAClE,OAAO,KAAI,EAAW,EAAE,EAAE,KAAY;AAC1C,GAGM,KAAW,MAA0B;CAEvC,IAAM,IAAI,EAAE,SAAS,MAAM,0BAA0B;CACrD,OAAO,IAAI,EAAE,KAAK;AACtB;AAOA,SAAgB,EACZ,GACA,GACiB;CACjB,IAAI;CACJ,IAAI;EACA,IAAI,IAAI,IAAI,CAAG;CACnB,QAAQ;EAEJ,OAAO;GAAE,UAAU;GAAQ;GAAK,UAAU;EAAI;CAClD;C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Q,UAD/B,EAAA,GAAA,EAeQ,SAAA;;KAbH,KAAK,EAAM,OAAO;KAClB,QAAQ,EAAM;KACf,UAAA;KACA,SAAQ;KACR,aAAA;KACA,OAAM;KACN,OAAA;MAAA,gBAAA;MAAA,cAAA;KAAA;IACA,GAAA,CAAA,EAKI,KAAA;KAJC,MAAM,EAAM;KACb,QAAO;KACP,KAAI;IACD,GAAA,EAAA,EAAM,SAAS,EAAM,GAAG,GAAA,GAAA,CAAA,CAAA,GAAA,GAAA,CAAA,MAInC,EAAA,GAAA,EAYM,OAZN,GAYM,CARF,EAO6D,UAAA;KANxD,KAAK,EAAM,OAAO;KAClB,OAAO,EAAM,SAAS,EAAM;KAC7B,SAAQ;KACR,gBAAe;KACd,OAAO;KACR,iBAAA;KACA,OAAM;;IAGJ,EAAM,eADhB,EAAA,GAAA,EAIO,QAJP,GAIO,EADA,EAAM,WAAW,GAAA,CAAA,KAAA,EAAA,IAAA,EAAA"}
|
|
@@ -2,7 +2,7 @@ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
|
2
2
|
import "./src-DT8FLE4_.js";
|
|
3
3
|
import { n as t } from "./url-validation-uLMZ5-AU.js";
|
|
4
4
|
import { t as n } from "./PkLazyImg-CDxX9xnq.js";
|
|
5
|
-
import { t as r } from "./PkUrl-
|
|
5
|
+
import { t as r } from "./PkUrl-3NH9t-WA.js";
|
|
6
6
|
import { VvIcon as i } from "@volverjs/ui-vue/components";
|
|
7
7
|
import { Fragment as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createTextVNode as d, createVNode as f, defineComponent as p, openBlock as m, ref as h, renderList as g, toDisplayString as _, unref as v } from "vue";
|
|
8
8
|
//#region ../../packages/components/src/chat/PkToolShowWebPages.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -76,4 +76,4 @@ var y = {
|
|
|
76
76
|
//#endregion
|
|
77
77
|
export { D as n, O as t };
|
|
78
78
|
|
|
79
|
-
//# sourceMappingURL=PkToolShowWebPages-
|
|
79
|
+
//# sourceMappingURL=PkToolShowWebPages-DEih8h5k.js.map
|
package/dist-vue/_chunks/{PkToolShowWebPages-D3Xy4iUs.js.map → PkToolShowWebPages-DEih8h5k.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowWebPages-D3Xy4iUs.js","names":["$t"],"sources":["../../../../packages/components/src/chat/PkToolShowWebPages.vue","../../../../packages/components/src/chat/PkToolShowWebPages.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref } from 'vue'\n import { isSameSite } from 'utils'\n import PkLazyImg from '../PkLazyImg.vue'\n import PkUrl from '../PkUrl.vue'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n pages: Array<{\n title: string\n url: string\n image?: string\n description?: string\n }>\n }\n }\n return part\n })\n\n // The model often passes the same URL several times (e.g. multiple KB\n // chunks from one page), so collapse duplicates, keeping the first (richest)\n // entry. Normalize by dropping the hash and any trailing slash.\n const normalizeUrl = (url: string) => {\n try {\n const u = new URL(url)\n u.hash = ''\n return u.toString().replace(/\\/$/, '')\n } catch {\n return url.trim().replace(/\\/$/, '')\n }\n }\n const uniquePages = computed(() => {\n const seen = new Set<string>()\n const result: NonNullable<typeof toolPart.value.input>['pages'] = []\n for (const page of toolPart.value.input?.pages || []) {\n const key = normalizeUrl(page.url)\n if (seen.has(key)) {\n continue\n }\n seen.add(key)\n result.push(page)\n }\n return result\n })\n\n const showMore = ref(false)\n const pages = computed(() => {\n if (showMore.value) {\n return uniquePages.value\n }\n return uniquePages.value.slice(0, 2)\n })\n const hasMore = computed(() => uniquePages.value.length > 2)\n</script>\n\n<template>\n <ul v-if=\"pages?.length\" class=\"u-pick-list w-full shrink-0\">\n <li\n v-for=\"(page, index) in pages\"\n :key=\"index\"\n class=\"u-pick-list__row\">\n <a\n :href=\"page.url\"\n :title=\"$t('action.open')\"\n :target=\"isSameSite(page.url) ? undefined : '_blank'\"\n :rel=\"isSameSite(page.url) ? undefined : 'noopener noreferrer'\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy u-pick-list__entry--top\">\n <!-- og:images the model scraped are third-party urls: a dead one\n degrades to an icon instead of breaking the card layout -->\n <PkLazyImg\n v-if=\"page.image\"\n :src=\"page.image\"\n :alt=\"page.title\"\n fallback-icon=\"ri:image-off-line\"\n class=\"w-48 h-48 object-contain rounded-lg shrink-0 border border-surface-3 bg-surface\" />\n <div class=\"flex flex-col gap-4 min-w-0 flex-1\">\n <strong\n class=\"u-pick-list__label font-medium text-12 text-word-1\">\n {{ page.title }}\n </strong>\n <span\n class=\"text-10 text-word-4 truncate flex items-center gap-4\">\n <VvIcon name=\"ri:link\" class=\"shrink-0 text-12\" />\n <PkUrl :url=\"page.url\" />\n </span>\n <p\n v-if=\"page.description\"\n class=\"text-12 text-word-3 line-clamp-2\">\n {{ page.description }}\n </p>\n </div>\n </a>\n </li>\n <li v-if=\"hasMore\" class=\"u-pick-list__row\">\n <button\n class=\"u-pick-list__entry text-12 text-word-3 justify-center cursor-pointer\"\n @click=\"showMore = !showMore\">\n <VvIcon\n :name=\"\n showMore ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\n \"\n class=\"text-16\" />\n {{\n showMore\n ? $t('action.showLess')\n : $t('action.showMore', {\n count: uniquePages.length - 2,\n })\n }}\n </button>\n </li>\n </ul>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref } from 'vue'\n import { isSameSite } from 'utils'\n import PkLazyImg from '../PkLazyImg.vue'\n import PkUrl from '../PkUrl.vue'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n pages: Array<{\n title: string\n url: string\n image?: string\n description?: string\n }>\n }\n }\n return part\n })\n\n // The model often passes the same URL several times (e.g. multiple KB\n // chunks from one page), so collapse duplicates, keeping the first (richest)\n // entry. Normalize by dropping the hash and any trailing slash.\n const normalizeUrl = (url: string) => {\n try {\n const u = new URL(url)\n u.hash = ''\n return u.toString().replace(/\\/$/, '')\n } catch {\n return url.trim().replace(/\\/$/, '')\n }\n }\n const uniquePages = computed(() => {\n const seen = new Set<string>()\n const result: NonNullable<typeof toolPart.value.input>['pages'] = []\n for (const page of toolPart.value.input?.pages || []) {\n const key = normalizeUrl(page.url)\n if (seen.has(key)) {\n continue\n }\n seen.add(key)\n result.push(page)\n }\n return result\n })\n\n const showMore = ref(false)\n const pages = computed(() => {\n if (showMore.value) {\n return uniquePages.value\n }\n return uniquePages.value.slice(0, 2)\n })\n const hasMore = computed(() => uniquePages.value.length > 2)\n</script>\n\n<template>\n <ul v-if=\"pages?.length\" class=\"u-pick-list w-full shrink-0\">\n <li\n v-for=\"(page, index) in pages\"\n :key=\"index\"\n class=\"u-pick-list__row\">\n <a\n :href=\"page.url\"\n :title=\"$t('action.open')\"\n :target=\"isSameSite(page.url) ? undefined : '_blank'\"\n :rel=\"isSameSite(page.url) ? undefined : 'noopener noreferrer'\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy u-pick-list__entry--top\">\n <!-- og:images the model scraped are third-party urls: a dead one\n degrades to an icon instead of breaking the card layout -->\n <PkLazyImg\n v-if=\"page.image\"\n :src=\"page.image\"\n :alt=\"page.title\"\n fallback-icon=\"ri:image-off-line\"\n class=\"w-48 h-48 object-contain rounded-lg shrink-0 border border-surface-3 bg-surface\" />\n <div class=\"flex flex-col gap-4 min-w-0 flex-1\">\n <strong\n class=\"u-pick-list__label font-medium text-12 text-word-1\">\n {{ page.title }}\n </strong>\n <span\n class=\"text-10 text-word-4 truncate flex items-center gap-4\">\n <VvIcon name=\"ri:link\" class=\"shrink-0 text-12\" />\n <PkUrl :url=\"page.url\" />\n </span>\n <p\n v-if=\"page.description\"\n class=\"text-12 text-word-3 line-clamp-2\">\n {{ page.description }}\n </p>\n </div>\n </a>\n </li>\n <li v-if=\"hasMore\" class=\"u-pick-list__row\">\n <button\n class=\"u-pick-list__entry text-12 text-word-3 justify-center cursor-pointer\"\n @click=\"showMore = !showMore\">\n <VvIcon\n :name=\"\n showMore ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\n \"\n class=\"text-16\" />\n {{\n showMore\n ? $t('action.showLess')\n : $t('action.showMore', {\n count: uniquePages.length - 2,\n })\n }}\n </button>\n </li>\n </ul>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAMI,IAAM,IAAQ,GAIR,IAAW,QACA,EAAM,IAWtB,GAKK,KAAgB,MAAgB;GAClC,IAAI;IACA,IAAM,IAAI,IAAI,IAAI,CAAG;IAErB,OADA,EAAE,OAAO,IACF,EAAE,SAAS,CAAC,CAAC,QAAQ,OAAO,EAAE;GACzC,QAAQ;IACJ,OAAO,EAAI,KAAK,CAAC,CAAC,QAAQ,OAAO,EAAE;GACvC;EACJ,GACM,IAAc,QAAe;GAC/B,IAAM,oBAAO,IAAI,IAAY,GACvB,IAA4D,CAAC;GACnE,KAAK,IAAM,KAAQ,EAAS,MAAM,OAAO,SAAS,CAAC,GAAG;IAClD,IAAM,IAAM,EAAa,EAAK,GAAG;IACjC,AAAI,EAAK,IAAI,CAAG,MAGhB,EAAK,IAAI,CAAG,GACZ,EAAO,KAAK,CAAI;GACpB;GACA,OAAO;EACX,CAAC,GAEK,IAAW,EAAI,EAAK,GACpB,IAAQ,QACN,EAAS,QACF,EAAY,QAEhB,EAAY,MAAM,MAAM,GAAG,CAAC,CACtC,GACK,IAAU,QAAe,EAAY,MAAM,SAAS,CAAC;;;GAIjD,OAAA,EAAA,OAAO,UAAjB,EAAA,GAAA,EAuDK,MAvDL,GAuDK,EAtDD,EAAA,EAAA,GAAA,EAmCK,GAAA,MAAA,EAlCuB,EAAA,QAAhB,GAAM,OADlB,EAAA,GAAA,EAmCK,MAAA;IAjCA,KAAK;IACN,OAAM;GACN,GAAA,CAAA,EA8BI,KAAA;IA7BC,MAAM,EAAK;IACX,OAAOA,EAAAA,GAAE,aAAA;IACT,QAAQ,EAAA,C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":["$t"],"sources":["../../../../packages/components/src/chat/PkToolShowWebPages.vue","../../../../packages/components/src/chat/PkToolShowWebPages.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref } from 'vue'\n import { isSameSite } from 'utils'\n import PkLazyImg from '../PkLazyImg.vue'\n import PkUrl from '../PkUrl.vue'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n pages: Array<{\n title: string\n url: string\n image?: string\n description?: string\n }>\n }\n }\n return part\n })\n\n // The model often passes the same URL several times (e.g. multiple KB\n // chunks from one page), so collapse duplicates, keeping the first (richest)\n // entry. Normalize by dropping the hash and any trailing slash.\n const normalizeUrl = (url: string) => {\n try {\n const u = new URL(url)\n u.hash = ''\n return u.toString().replace(/\\/$/, '')\n } catch {\n return url.trim().replace(/\\/$/, '')\n }\n }\n const uniquePages = computed(() => {\n const seen = new Set<string>()\n const result: NonNullable<typeof toolPart.value.input>['pages'] = []\n for (const page of toolPart.value.input?.pages || []) {\n const key = normalizeUrl(page.url)\n if (seen.has(key)) {\n continue\n }\n seen.add(key)\n result.push(page)\n }\n return result\n })\n\n const showMore = ref(false)\n const pages = computed(() => {\n if (showMore.value) {\n return uniquePages.value\n }\n return uniquePages.value.slice(0, 2)\n })\n const hasMore = computed(() => uniquePages.value.length > 2)\n</script>\n\n<template>\n <ul v-if=\"pages?.length\" class=\"u-pick-list w-full shrink-0\">\n <li\n v-for=\"(page, index) in pages\"\n :key=\"index\"\n class=\"u-pick-list__row\">\n <a\n :href=\"page.url\"\n :title=\"$t('action.open')\"\n :target=\"isSameSite(page.url) ? undefined : '_blank'\"\n :rel=\"isSameSite(page.url) ? undefined : 'noopener noreferrer'\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy u-pick-list__entry--top\">\n <!-- og:images the model scraped are third-party urls: a dead one\n degrades to an icon instead of breaking the card layout -->\n <PkLazyImg\n v-if=\"page.image\"\n :src=\"page.image\"\n :alt=\"page.title\"\n fallback-icon=\"ri:image-off-line\"\n class=\"w-48 h-48 object-contain rounded-lg shrink-0 border border-surface-3 bg-surface\" />\n <div class=\"flex flex-col gap-4 min-w-0 flex-1\">\n <strong\n class=\"u-pick-list__label font-medium text-12 text-word-1\">\n {{ page.title }}\n </strong>\n <span\n class=\"text-10 text-word-4 truncate flex items-center gap-4\">\n <VvIcon name=\"ri:link\" class=\"shrink-0 text-12\" />\n <PkUrl :url=\"page.url\" />\n </span>\n <p\n v-if=\"page.description\"\n class=\"text-12 text-word-3 line-clamp-2\">\n {{ page.description }}\n </p>\n </div>\n </a>\n </li>\n <li v-if=\"hasMore\" class=\"u-pick-list__row\">\n <button\n class=\"u-pick-list__entry text-12 text-word-3 justify-center cursor-pointer\"\n @click=\"showMore = !showMore\">\n <VvIcon\n :name=\"\n showMore ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\n \"\n class=\"text-16\" />\n {{\n showMore\n ? $t('action.showLess')\n : $t('action.showMore', {\n count: uniquePages.length - 2,\n })\n }}\n </button>\n </li>\n </ul>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref } from 'vue'\n import { isSameSite } from 'utils'\n import PkLazyImg from '../PkLazyImg.vue'\n import PkUrl from '../PkUrl.vue'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n pages: Array<{\n title: string\n url: string\n image?: string\n description?: string\n }>\n }\n }\n return part\n })\n\n // The model often passes the same URL several times (e.g. multiple KB\n // chunks from one page), so collapse duplicates, keeping the first (richest)\n // entry. Normalize by dropping the hash and any trailing slash.\n const normalizeUrl = (url: string) => {\n try {\n const u = new URL(url)\n u.hash = ''\n return u.toString().replace(/\\/$/, '')\n } catch {\n return url.trim().replace(/\\/$/, '')\n }\n }\n const uniquePages = computed(() => {\n const seen = new Set<string>()\n const result: NonNullable<typeof toolPart.value.input>['pages'] = []\n for (const page of toolPart.value.input?.pages || []) {\n const key = normalizeUrl(page.url)\n if (seen.has(key)) {\n continue\n }\n seen.add(key)\n result.push(page)\n }\n return result\n })\n\n const showMore = ref(false)\n const pages = computed(() => {\n if (showMore.value) {\n return uniquePages.value\n }\n return uniquePages.value.slice(0, 2)\n })\n const hasMore = computed(() => uniquePages.value.length > 2)\n</script>\n\n<template>\n <ul v-if=\"pages?.length\" class=\"u-pick-list w-full shrink-0\">\n <li\n v-for=\"(page, index) in pages\"\n :key=\"index\"\n class=\"u-pick-list__row\">\n <a\n :href=\"page.url\"\n :title=\"$t('action.open')\"\n :target=\"isSameSite(page.url) ? undefined : '_blank'\"\n :rel=\"isSameSite(page.url) ? undefined : 'noopener noreferrer'\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy u-pick-list__entry--top\">\n <!-- og:images the model scraped are third-party urls: a dead one\n degrades to an icon instead of breaking the card layout -->\n <PkLazyImg\n v-if=\"page.image\"\n :src=\"page.image\"\n :alt=\"page.title\"\n fallback-icon=\"ri:image-off-line\"\n class=\"w-48 h-48 object-contain rounded-lg shrink-0 border border-surface-3 bg-surface\" />\n <div class=\"flex flex-col gap-4 min-w-0 flex-1\">\n <strong\n class=\"u-pick-list__label font-medium text-12 text-word-1\">\n {{ page.title }}\n </strong>\n <span\n class=\"text-10 text-word-4 truncate flex items-center gap-4\">\n <VvIcon name=\"ri:link\" class=\"shrink-0 text-12\" />\n <PkUrl :url=\"page.url\" />\n </span>\n <p\n v-if=\"page.description\"\n class=\"text-12 text-word-3 line-clamp-2\">\n {{ page.description }}\n </p>\n </div>\n </a>\n </li>\n <li v-if=\"hasMore\" class=\"u-pick-list__row\">\n <button\n class=\"u-pick-list__entry text-12 text-word-3 justify-center cursor-pointer\"\n @click=\"showMore = !showMore\">\n <VvIcon\n :name=\"\n showMore ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\n \"\n class=\"text-16\" />\n {{\n showMore\n ? $t('action.showLess')\n : $t('action.showMore', {\n count: uniquePages.length - 2,\n })\n }}\n </button>\n </li>\n </ul>\n</template>\n"],"mappings":";;;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Ac;IACd,OAAM;GACV,GAAA,MAAA,GAAA,CAAA,OAAA,KAAA,CAAA,KAAA,EAAA,IAAA,EAAA,GAAA,EAeM,OAfN,GAeM;IAdF,EAGS,UAHT,GAGS,EADF,EAAK,KAAK,GAAA,CAAA;IAEjB,EAIO,QAJP,GAIO,CAFH,EAAkD,GAAA;KAA1C,MAAK;KAAU,OAAM;IAC7B,CAAA,GAAA,EAAyB,GAAA,EAAjB,KAAK,EAAK,IAAA,GAAA,MAAA,GAAA,CAAA,KAAA,CAAA,CAAA,CAAA;IAGZ,EAAK,eADf,EAAA,GAAA,EAII,KAJJ,GAII,EADG,EAAK,WAAW,GAAA,CAAA,KAAA,EAAA,IAAA,EAAA;gBAKzB,GAAA,GAAA,IAAA,EAAA,SAAV,EAAA,GAAA,EAiBK,MAjBL,GAiBK,CAhBD,EAeS,UAAA;IAdL,OAAM;IACL,SAAK,AAAA,EAAA,QAAA,MAAE,EAAA,QAAQ,CAAI,EAAA;GACpB,GAAA,CAAA,EAIsB,GAAA;IAHjB,MAA+B,EAAA,QAAQ,uBAAA;IAGxC,OAAM;GAAY,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,GAAA,EAAA,MACtB,EACI,EAAA,QAAmCA,EAAAA,GAAE,iBAAA,IAA8CA,EAAAA,GAAE,mBAAA,EAA2D,OAAA,EAAA,MAAY,SAAM,EAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,CAAA,KAAA,EAAA,IAAA,EAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as e } from "./PkStreamingMarkdown-
|
|
1
|
+
import { r as e } from "./PkStreamingMarkdown-B2iju0WK.js";
|
|
2
2
|
import { Fragment as t, computed as n, createBlock as r, createElementBlock as i, createElementVNode as a, defineComponent as o, normalizeClass as s, openBlock as c, renderList as l, resolveDynamicComponent as u, toDisplayString as d, withCtx as f } from "vue";
|
|
3
3
|
//#region ../../packages/components/src/PkUrl.vue?vue&type=script&setup=true&lang.ts
|
|
4
4
|
var p = {
|
|
@@ -80,4 +80,4 @@ var p = {
|
|
|
80
80
|
//#endregion
|
|
81
81
|
export { h as t };
|
|
82
82
|
|
|
83
|
-
//# sourceMappingURL=PkUrl-
|
|
83
|
+
//# sourceMappingURL=PkUrl-3NH9t-WA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkUrl-BgMBemSz.js","names":[],"sources":["../../../../packages/components/src/PkUrl.vue","../../../../packages/components/src/PkUrl.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useShortUrlResolver } from 'composables'\n\n interface Props {\n url: string\n maxLength?: number\n domainClass?: string\n target?: '_blank' | '_self' | '_parent' | '_top'\n rel?: string\n muted?: boolean\n }\n\n const props = withDefaults(defineProps<Props>(), {\n maxLength: 60,\n domainClass: undefined,\n target: '_blank',\n rel: 'noopener noreferrer',\n muted: false,\n })\n\n // Only the displayed URL text is resolved to its real target; the href is\n // kept as the short url so the redirect endpoint still handles tracking.\n const { resolve } = useShortUrlResolver()\n const resolved = resolve(() => props.url)\n const displayUrl = computed(() => resolved.value.url)\n const isResolving = computed(() => resolved.value.loading)\n\n const parsedUrl = computed(() => {\n try {\n const urlObj = new URL(displayUrl.value ?? props.url)\n let hostname = urlObj.hostname\n\n // Remove www. prefix\n if (hostname.startsWith('www.')) {\n hostname = hostname.substring(4)\n }\n\n // Get pathname and remove trailing slash\n let pathname = urlObj.pathname\n if (pathname === '/') {\n pathname = ''\n }\n\n // Split pathname into segments\n const segments = pathname\n .split('/')\n .filter((segment) => segment.length > 0)\n\n return {\n domain: hostname,\n segments,\n fullPath: hostname + pathname,\n }\n } catch {\n // If URL parsing fails, return the original URL\n const fallback = displayUrl.value ?? props.url\n return {\n domain: fallback,\n segments: [],\n fullPath: fallback,\n }\n }\n })\n\n const truncatedUrl = computed(() => {\n if (parsedUrl.value.fullPath.length <= props.maxLength) {\n return parsedUrl.value\n }\n\n // If too long, truncate segments from the beginning\n const domain = parsedUrl.value.domain\n const allSegments = parsedUrl.value.segments\n\n // Always show at least the last segment\n if (allSegments.length === 0) {\n return {\n domain,\n segments: [],\n fullPath: domain,\n }\n }\n\n const segments: string[] = []\n\n // Calculate from the end\n let currentLength = domain.length\n\n // Try to fit segments from the end\n for (let i = allSegments.length - 1; i >= 0; i--) {\n const segment = allSegments[i]\n\n // Always include at least the last segment\n if (segments.length === 0) {\n currentLength += segment.length + 1\n segments.unshift(segment)\n } else if (currentLength + segment.length + 1 <= props.maxLength) {\n currentLength += segment.length + 1\n segments.unshift(segment)\n } else {\n segments.unshift('...')\n break\n }\n }\n\n return {\n domain,\n segments,\n fullPath: domain + '/' + segments.join('/'),\n }\n })\n</script>\n\n<template>\n <Component\n :is=\"muted ? 'span' : 'a'\"\n class=\"pk-url\"\n :href=\"muted ? undefined : props.url\"\n :target=\"muted ? undefined : props.target\"\n :rel=\"muted ? undefined : props.rel\">\n <span v-if=\"isResolving\" class=\"pk-url__skeleton vv-skeleton\">\n <span class=\"vv-skeleton__item\" />\n </span>\n <template v-else>\n <span :class=\"['pk-url__domain', domainClass]\">{{\n truncatedUrl.domain\n }}</span>\n <template\n v-for=\"(segment, index) in truncatedUrl.segments\"\n :key=\"index\">\n <span class=\"pk-url__separator\">›</span>\n <span class=\"pk-url__segment\">{{ segment }}</span>\n </template>\n </template>\n </Component>\n</template>\n\n<style lang=\"scss\">\n @layer volver.components {\n .pk-url {\n display: inline-flex;\n align-items: center;\n gap: 0.5ch;\n }\n\n .pk-url__skeleton {\n display: inline-flex;\n width: 12ch;\n max-width: 100%;\n\n .vv-skeleton__item {\n width: 100%;\n height: 1em;\n border-radius: 0.25em;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useShortUrlResolver } from 'composables'\n\n interface Props {\n url: string\n maxLength?: number\n domainClass?: string\n target?: '_blank' | '_self' | '_parent' | '_top'\n rel?: string\n muted?: boolean\n }\n\n const props = withDefaults(defineProps<Props>(), {\n maxLength: 60,\n domainClass: undefined,\n target: '_blank',\n rel: 'noopener noreferrer',\n muted: false,\n })\n\n // Only the displayed URL text is resolved to its real target; the href is\n // kept as the short url so the redirect endpoint still handles tracking.\n const { resolve } = useShortUrlResolver()\n const resolved = resolve(() => props.url)\n const displayUrl = computed(() => resolved.value.url)\n const isResolving = computed(() => resolved.value.loading)\n\n const parsedUrl = computed(() => {\n try {\n const urlObj = new URL(displayUrl.value ?? props.url)\n let hostname = urlObj.hostname\n\n // Remove www. prefix\n if (hostname.startsWith('www.')) {\n hostname = hostname.substring(4)\n }\n\n // Get pathname and remove trailing slash\n let pathname = urlObj.pathname\n if (pathname === '/') {\n pathname = ''\n }\n\n // Split pathname into segments\n const segments = pathname\n .split('/')\n .filter((segment) => segment.length > 0)\n\n return {\n domain: hostname,\n segments,\n fullPath: hostname + pathname,\n }\n } catch {\n // If URL parsing fails, return the original URL\n const fallback = displayUrl.value ?? props.url\n return {\n domain: fallback,\n segments: [],\n fullPath: fallback,\n }\n }\n })\n\n const truncatedUrl = computed(() => {\n if (parsedUrl.value.fullPath.length <= props.maxLength) {\n return parsedUrl.value\n }\n\n // If too long, truncate segments from the beginning\n const domain = parsedUrl.value.domain\n const allSegments = parsedUrl.value.segments\n\n // Always show at least the last segment\n if (allSegments.length === 0) {\n return {\n domain,\n segments: [],\n fullPath: domain,\n }\n }\n\n const segments: string[] = []\n\n // Calculate from the end\n let currentLength = domain.length\n\n // Try to fit segments from the end\n for (let i = allSegments.length - 1; i >= 0; i--) {\n const segment = allSegments[i]\n\n // Always include at least the last segment\n if (segments.length === 0) {\n currentLength += segment.length + 1\n segments.unshift(segment)\n } else if (currentLength + segment.length + 1 <= props.maxLength) {\n currentLength += segment.length + 1\n segments.unshift(segment)\n } else {\n segments.unshift('...')\n break\n }\n }\n\n return {\n domain,\n segments,\n fullPath: domain + '/' + segments.join('/'),\n }\n })\n</script>\n\n<template>\n <Component\n :is=\"muted ? 'span' : 'a'\"\n class=\"pk-url\"\n :href=\"muted ? undefined : props.url\"\n :target=\"muted ? undefined : props.target\"\n :rel=\"muted ? undefined : props.rel\">\n <span v-if=\"isResolving\" class=\"pk-url__skeleton vv-skeleton\">\n <span class=\"vv-skeleton__item\" />\n </span>\n <template v-else>\n <span :class=\"['pk-url__domain', domainClass]\">{{\n truncatedUrl.domain\n }}</span>\n <template\n v-for=\"(segment, index) in truncatedUrl.segments\"\n :key=\"index\">\n <span class=\"pk-url__separator\">›</span>\n <span class=\"pk-url__segment\">{{ segment }}</span>\n </template>\n </template>\n </Component>\n</template>\n\n<style lang=\"scss\">\n @layer volver.components {\n .pk-url {\n display: inline-flex;\n align-items: center;\n gap: 0.5ch;\n }\n\n .pk-url__skeleton {\n display: inline-flex;\n width: 12ch;\n max-width: 100%;\n\n .vv-skeleton__item {\n width: 100%;\n height: 1em;\n border-radius: 0.25em;\n }\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAaI,IAAM,IAAQ,GAUR,EAAE,eAAY,EAAoB,GAClC,IAAW,QAAc,EAAM,GAAG,GAClC,IAAa,QAAe,EAAS,MAAM,GAAG,GAC9C,IAAc,QAAe,EAAS,MAAM,OAAO,GAEnD,IAAY,QAAe;GAC7B,IAAI;IACA,IAAM,IAAS,IAAI,IAAI,EAAW,SAAS,EAAM,GAAG,GAChD,IAAW,EAAO;IAGtB,AAAI,EAAS,WAAW,MAAM,MAC1B,IAAW,EAAS,UAAU,CAAC;IAInC,IAAI,IAAW,EAAO;IACtB,AAAI,MAAa,QACb,IAAW;IAIf,IAAM,IAAW,EACZ,MAAM,GAAG,CAAA,CACT,QAAQ,MAAY,EAAQ,SAAS,CAAC;IAE3C,OAAO;KACH,QAAQ;KACR;KACA,UAAU,IAAW;IACzB;GACJ,QAAQ;IAEJ,IAAM,IAAW,EAAW,SAAS,EAAM;IAC3C,OAAO;KACH,QAAQ;KACR,UAAU,CAAC;KACX,UAAU;IACd;GACJ;EACJ,C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A,EAKW,GAAA,MAAA,EAJoB,EAAA,MAAa,WAAhC,GAAS,OACX,EAAA,GAAA,EAAA,GAAA,EAAA,KAAA,EAAK,GAAA,CACX,AAAA,EAAA,OAAA,EAAwC,QAAA,EAAlC,OAAM,oBAAmB,GAAC,KAAC,EAAA,GACjC,EAAkD,QAAlD,GAAkD,EAAjB,CAAO,GAAA,CAAA,CAAA,GAAA,EAAA"}
|
|
1
|
+
{"version":3,"file":"PkUrl-3NH9t-WA.js","names":[],"sources":["../../../../packages/components/src/PkUrl.vue","../../../../packages/components/src/PkUrl.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useShortUrlResolver } from 'composables'\n\n interface Props {\n url: string\n maxLength?: number\n domainClass?: string\n target?: '_blank' | '_self' | '_parent' | '_top'\n rel?: string\n muted?: boolean\n }\n\n const props = withDefaults(defineProps<Props>(), {\n maxLength: 60,\n domainClass: undefined,\n target: '_blank',\n rel: 'noopener noreferrer',\n muted: false,\n })\n\n // Only the displayed URL text is resolved to its real target; the href is\n // kept as the short url so the redirect endpoint still handles tracking.\n const { resolve } = useShortUrlResolver()\n const resolved = resolve(() => props.url)\n const displayUrl = computed(() => resolved.value.url)\n const isResolving = computed(() => resolved.value.loading)\n\n const parsedUrl = computed(() => {\n try {\n const urlObj = new URL(displayUrl.value ?? props.url)\n let hostname = urlObj.hostname\n\n // Remove www. prefix\n if (hostname.startsWith('www.')) {\n hostname = hostname.substring(4)\n }\n\n // Get pathname and remove trailing slash\n let pathname = urlObj.pathname\n if (pathname === '/') {\n pathname = ''\n }\n\n // Split pathname into segments\n const segments = pathname\n .split('/')\n .filter((segment) => segment.length > 0)\n\n return {\n domain: hostname,\n segments,\n fullPath: hostname + pathname,\n }\n } catch {\n // If URL parsing fails, return the original URL\n const fallback = displayUrl.value ?? props.url\n return {\n domain: fallback,\n segments: [],\n fullPath: fallback,\n }\n }\n })\n\n const truncatedUrl = computed(() => {\n if (parsedUrl.value.fullPath.length <= props.maxLength) {\n return parsedUrl.value\n }\n\n // If too long, truncate segments from the beginning\n const domain = parsedUrl.value.domain\n const allSegments = parsedUrl.value.segments\n\n // Always show at least the last segment\n if (allSegments.length === 0) {\n return {\n domain,\n segments: [],\n fullPath: domain,\n }\n }\n\n const segments: string[] = []\n\n // Calculate from the end\n let currentLength = domain.length\n\n // Try to fit segments from the end\n for (let i = allSegments.length - 1; i >= 0; i--) {\n const segment = allSegments[i]\n\n // Always include at least the last segment\n if (segments.length === 0) {\n currentLength += segment.length + 1\n segments.unshift(segment)\n } else if (currentLength + segment.length + 1 <= props.maxLength) {\n currentLength += segment.length + 1\n segments.unshift(segment)\n } else {\n segments.unshift('...')\n break\n }\n }\n\n return {\n domain,\n segments,\n fullPath: domain + '/' + segments.join('/'),\n }\n })\n</script>\n\n<template>\n <Component\n :is=\"muted ? 'span' : 'a'\"\n class=\"pk-url\"\n :href=\"muted ? undefined : props.url\"\n :target=\"muted ? undefined : props.target\"\n :rel=\"muted ? undefined : props.rel\">\n <span v-if=\"isResolving\" class=\"pk-url__skeleton vv-skeleton\">\n <span class=\"vv-skeleton__item\" />\n </span>\n <template v-else>\n <span :class=\"['pk-url__domain', domainClass]\">{{\n truncatedUrl.domain\n }}</span>\n <template\n v-for=\"(segment, index) in truncatedUrl.segments\"\n :key=\"index\">\n <span class=\"pk-url__separator\">›</span>\n <span class=\"pk-url__segment\">{{ segment }}</span>\n </template>\n </template>\n </Component>\n</template>\n\n<style lang=\"scss\">\n @layer volver.components {\n .pk-url {\n display: inline-flex;\n align-items: center;\n gap: 0.5ch;\n }\n\n .pk-url__skeleton {\n display: inline-flex;\n width: 12ch;\n max-width: 100%;\n\n .vv-skeleton__item {\n width: 100%;\n height: 1em;\n border-radius: 0.25em;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useShortUrlResolver } from 'composables'\n\n interface Props {\n url: string\n maxLength?: number\n domainClass?: string\n target?: '_blank' | '_self' | '_parent' | '_top'\n rel?: string\n muted?: boolean\n }\n\n const props = withDefaults(defineProps<Props>(), {\n maxLength: 60,\n domainClass: undefined,\n target: '_blank',\n rel: 'noopener noreferrer',\n muted: false,\n })\n\n // Only the displayed URL text is resolved to its real target; the href is\n // kept as the short url so the redirect endpoint still handles tracking.\n const { resolve } = useShortUrlResolver()\n const resolved = resolve(() => props.url)\n const displayUrl = computed(() => resolved.value.url)\n const isResolving = computed(() => resolved.value.loading)\n\n const parsedUrl = computed(() => {\n try {\n const urlObj = new URL(displayUrl.value ?? props.url)\n let hostname = urlObj.hostname\n\n // Remove www. prefix\n if (hostname.startsWith('www.')) {\n hostname = hostname.substring(4)\n }\n\n // Get pathname and remove trailing slash\n let pathname = urlObj.pathname\n if (pathname === '/') {\n pathname = ''\n }\n\n // Split pathname into segments\n const segments = pathname\n .split('/')\n .filter((segment) => segment.length > 0)\n\n return {\n domain: hostname,\n segments,\n fullPath: hostname + pathname,\n }\n } catch {\n // If URL parsing fails, return the original URL\n const fallback = displayUrl.value ?? props.url\n return {\n domain: fallback,\n segments: [],\n fullPath: fallback,\n }\n }\n })\n\n const truncatedUrl = computed(() => {\n if (parsedUrl.value.fullPath.length <= props.maxLength) {\n return parsedUrl.value\n }\n\n // If too long, truncate segments from the beginning\n const domain = parsedUrl.value.domain\n const allSegments = parsedUrl.value.segments\n\n // Always show at least the last segment\n if (allSegments.length === 0) {\n return {\n domain,\n segments: [],\n fullPath: domain,\n }\n }\n\n const segments: string[] = []\n\n // Calculate from the end\n let currentLength = domain.length\n\n // Try to fit segments from the end\n for (let i = allSegments.length - 1; i >= 0; i--) {\n const segment = allSegments[i]\n\n // Always include at least the last segment\n if (segments.length === 0) {\n currentLength += segment.length + 1\n segments.unshift(segment)\n } else if (currentLength + segment.length + 1 <= props.maxLength) {\n currentLength += segment.length + 1\n segments.unshift(segment)\n } else {\n segments.unshift('...')\n break\n }\n }\n\n return {\n domain,\n segments,\n fullPath: domain + '/' + segments.join('/'),\n }\n })\n</script>\n\n<template>\n <Component\n :is=\"muted ? 'span' : 'a'\"\n class=\"pk-url\"\n :href=\"muted ? undefined : props.url\"\n :target=\"muted ? undefined : props.target\"\n :rel=\"muted ? undefined : props.rel\">\n <span v-if=\"isResolving\" class=\"pk-url__skeleton vv-skeleton\">\n <span class=\"vv-skeleton__item\" />\n </span>\n <template v-else>\n <span :class=\"['pk-url__domain', domainClass]\">{{\n truncatedUrl.domain\n }}</span>\n <template\n v-for=\"(segment, index) in truncatedUrl.segments\"\n :key=\"index\">\n <span class=\"pk-url__separator\">›</span>\n <span class=\"pk-url__segment\">{{ segment }}</span>\n </template>\n </template>\n </Component>\n</template>\n\n<style lang=\"scss\">\n @layer volver.components {\n .pk-url {\n display: inline-flex;\n align-items: center;\n gap: 0.5ch;\n }\n\n .pk-url__skeleton {\n display: inline-flex;\n width: 12ch;\n max-width: 100%;\n\n .vv-skeleton__item {\n width: 100%;\n height: 1em;\n border-radius: 0.25em;\n }\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAaI,IAAM,IAAQ,GAUR,EAAE,eAAY,EAAoB,GAClC,IAAW,QAAc,EAAM,GAAG,GAClC,IAAa,QAAe,EAAS,MAAM,GAAG,GAC9C,IAAc,QAAe,EAAS,MAAM,OAAO,GAEnD,IAAY,QAAe;GAC7B,IAAI;IACA,IAAM,IAAS,IAAI,IAAI,EAAW,SAAS,EAAM,GAAG,GAChD,IAAW,EAAO;IAGtB,AAAI,EAAS,WAAW,MAAM,MAC1B,IAAW,EAAS,UAAU,CAAC;IAInC,IAAI,IAAW,EAAO;IACtB,AAAI,MAAa,QACb,IAAW;IAIf,IAAM,IAAW,EACZ,MAAM,GAAG,CAAA,CACT,QAAQ,MAAY,EAAQ,SAAS,CAAC;IAE3C,OAAO;KACH,QAAQ;KACR;KACA,UAAU,IAAW;IACzB;GACJ,QAAQ;IAEJ,IAAM,IAAW,EAAW,SAAS,EAAM;IAC3C,OAAO;KACH,QAAQ;KACR,UAAU,CAAC;KACX,UAAU;IACd;G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A,EAAA,GAAA,EAKW,GAAA,MAAA,EAJoB,EAAA,MAAa,WAAhC,GAAS,OACX,EAAA,GAAA,EAAA,GAAA,EAAA,KAAA,EAAK,GAAA,CACX,AAAA,EAAA,OAAA,EAAwC,QAAA,EAAlC,OAAM,oBAAmB,GAAC,KAAC,EAAA,GACjC,EAAkD,QAAlD,GAAkD,EAAjB,CAAO,GAAA,CAAA,CAAA,GAAA,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-validation-uLMZ5-AU.js","names":[],"sources":["../../../../packages/utils/src/url-validation.ts"],"sourcesContent":["/**\n * Check if URL points to an HTML page based on extension and content-type\n * @param url - The URL to check\n * @param contentType - Optional content-type header from response\n * @returns true if URL appears to be HTML, false otherwise\n */\nexport function isHtmlUrl(url: string, contentType?: string): boolean {\n // Check content-type if available\n if (contentType) {\n return contentType.includes('text/html')\n }\n\n // Check URL extension\n let urlObj: URL\n try {\n urlObj = new URL(url)\n } catch {\n return false\n }\n const pathname = urlObj.pathname.toLowerCase()\n\n // Exclude common non-HTML extensions\n const nonHtmlExtensions = [\n '.pdf',\n '.doc',\n '.docx',\n '.xls',\n '.xlsx',\n '.ppt',\n '.pptx',\n '.zip',\n '.rar',\n '.tar',\n '.gz',\n '.jpg',\n '.jpeg',\n '.png',\n '.gif',\n '.svg',\n '.webp',\n '.mp4',\n '.avi',\n '.mov',\n '.mp3',\n '.wav',\n '.css',\n '.js',\n '.json',\n '.xml',\n '.txt',\n ]\n\n return !nonHtmlExtensions.some((ext) => pathname.endsWith(ext))\n}\n\n/**\n * Checks if a URL has an initial slash\n * @param url - The URL string to check\n * @returns true if URL has an initial slash, false otherwise\n */\nexport function hasInitialSlash(url: string): boolean {\n return url.startsWith('/')\n}\n\n/**\n * Adds an initial slash to a URL if it doesn't already have one\n * @param url - The URL string to modify\n * @returns The URL string with an initial slash\n */\nexport function addInitialSlash(url: string): string {\n return hasInitialSlash(url) ? url : `/${url}`\n}\n\n/**\n * Checks if a URL has a trailing slash\n * @param url - The URL string to check\n * @returns true if URL has a trailing slash, false otherwise\n */\nexport function hasTrailingSlash(url: string): boolean {\n return url.endsWith('/')\n}\n\n/**\n * Checks whether a URL belongs to the same site as the current page.\n * Relative URLs and malformed URLs are treated as same-site.\n * Comparison is based on hostname only, so http and https variants of\n * the same domain are considered the same site.\n * @param url - The URL to check\n * @returns true if the URL is same-site or relative/malformed, false otherwise\n */\nexport function isSameSite(url: string): boolean {\n try {\n const target = new URL(url, window.location.origin)\n return target.hostname === window.location.hostname\n } catch {\n return true\n }\n}\n\n/**\n * Removes the trailing slash from a URL if it exists\n * @param url - The URL string to modify\n * @returns The URL string without a trailing slash\n */\nexport function removeTrailingSlash(url: string): string {\n return hasTrailingSlash(url) ? url.slice(0, -1) : url\n}\n"],"mappings":";AA4DA,SAAgB,EAAgB,GAAsB;CAClD,OAAO,EAAI,WAAW,GAAG;AAC7B;AAOA,SAAgB,EAAgB,GAAqB;CACjD,OAAO,EAAgB,CAAG,IAAI,IAAM,IAAI;AAC5C;AAOA,SAAgB,EAAiB,GAAsB;CACnD,OAAO,EAAI,SAAS,GAAG;AAC3B;AAUA,SAAgB,EAAW,GAAsB;CAC7C,IAAI;EAEA,OAAO,IADY,IAAI,GAAK,OAAO,SAAS,MACrC,CAAA,CAAO,aAAa,OAAO,SAAS;CAC/C,QAAQ;EACJ,OAAO;CACX;AACJ;AAOA,SAAgB,EAAoB,GAAqB;CACrD,OAAO,EAAiB,CAAG,IAAI,EAAI,MAAM,GAAG,EAAE,IAAI;AACtD"}
|
|
1
|
+
{"version":3,"file":"url-validation-uLMZ5-AU.js","names":[],"sources":["../../../../packages/utils/src/url-validation.ts"],"sourcesContent":["/**\n * Check if URL points to an HTML page based on extension and content-type\n * @param url - The URL to check\n * @param contentType - Optional content-type header from response\n * @returns true if URL appears to be HTML, false otherwise\n */\nexport function isHtmlUrl(url: string, contentType?: string): boolean {\n // Check content-type if available\n if (contentType) {\n return contentType.includes('text/html')\n }\n\n // Check URL extension\n let urlObj: URL\n try {\n urlObj = new URL(url)\n } catch {\n return false\n }\n const pathname = urlObj.pathname.toLowerCase()\n\n // Exclude common non-HTML extensions\n const nonHtmlExtensions = [\n '.pdf',\n '.doc',\n '.docx',\n '.xls',\n '.xlsx',\n '.ppt',\n '.pptx',\n '.zip',\n '.rar',\n '.tar',\n '.gz',\n '.jpg',\n '.jpeg',\n '.png',\n '.gif',\n '.svg',\n '.webp',\n '.mp4',\n '.avi',\n '.mov',\n '.mp3',\n '.wav',\n '.css',\n '.js',\n '.json',\n '.xml',\n '.txt',\n ]\n\n return !nonHtmlExtensions.some((ext) => pathname.endsWith(ext))\n}\n\n/**\n * Checks if a URL has an initial slash\n * @param url - The URL string to check\n * @returns true if URL has an initial slash, false otherwise\n */\nexport function hasInitialSlash(url: string): boolean {\n return url.startsWith('/')\n}\n\n/**\n * Adds an initial slash to a URL if it doesn't already have one\n * @param url - The URL string to modify\n * @returns The URL string with an initial slash\n */\nexport function addInitialSlash(url: string): string {\n return hasInitialSlash(url) ? url : `/${url}`\n}\n\n/**\n * Checks if a URL has a trailing slash\n * @param url - The URL string to check\n * @returns true if URL has a trailing slash, false otherwise\n */\nexport function hasTrailingSlash(url: string): boolean {\n return url.endsWith('/')\n}\n\n/**\n * Checks whether a URL belongs to the same site as the current page.\n * Relative URLs and malformed URLs are treated as same-site.\n * Comparison is based on hostname only, so http and https variants of\n * the same domain are considered the same site.\n * @param url - The URL to check\n * @returns true if the URL is same-site or relative/malformed, false otherwise\n */\nexport function isSameSite(url: string): boolean {\n try {\n const target = new URL(url, window.location.origin)\n return target.hostname === window.location.hostname\n } catch {\n return true\n }\n}\n\n/**\n * Removes the trailing slash from a URL if it exists\n * @param url - The URL string to modify\n * @returns The URL string without a trailing slash\n */\nexport function removeTrailingSlash(url: string): string {\n return hasTrailingSlash(url) ? url.slice(0, -1) : url\n}\n\n/**\n * The origin a URL points to (scheme, host and port), or `undefined` when it\n * does not parse. An API tool's secret parameters are sent only to the origin\n * they were typed for: backend and panel compare with this.\n */\nexport function urlOrigin(url: string | undefined): string | undefined {\n if (!url) {\n return undefined\n }\n try {\n return new URL(url).origin\n } catch {\n return undefined\n }\n}\n"],"mappings":";AA4DA,SAAgB,EAAgB,GAAsB;CAClD,OAAO,EAAI,WAAW,GAAG;AAC7B;AAOA,SAAgB,EAAgB,GAAqB;CACjD,OAAO,EAAgB,CAAG,IAAI,IAAM,IAAI;AAC5C;AAOA,SAAgB,EAAiB,GAAsB;CACnD,OAAO,EAAI,SAAS,GAAG;AAC3B;AAUA,SAAgB,EAAW,GAAsB;CAC7C,IAAI;EAEA,OAAO,IADY,IAAI,GAAK,OAAO,SAAS,MACrC,CAAA,CAAO,aAAa,OAAO,SAAS;CAC/C,QAAQ;EACJ,OAAO;CACX;AACJ;AAOA,SAAgB,EAAoB,GAAqB;CACrD,OAAO,EAAiB,CAAG,IAAI,EAAI,MAAM,GAAG,EAAE,IAAI;AACtD"}
|