@8wave/ai-elements 0.77.0 → 0.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/_chunks/{PkStreamingMarkdown-COZApJzT.js → PkStreamingMarkdown-gIAvEY1t.js} +370 -301
  2. package/dist/_chunks/PkStreamingMarkdown-gIAvEY1t.js.map +1 -0
  3. package/dist/_chunks/{PkToolShowArtifact-BZQixk9z.js → PkToolShowArtifact-BwW4Yn6k.js} +2 -2
  4. package/dist/_chunks/{PkToolShowArtifact-BZQixk9z.js.map → PkToolShowArtifact-BwW4Yn6k.js.map} +1 -1
  5. package/dist/_chunks/{PkToolShowContactForm-thS7c8iL.js → PkToolShowContactForm-DTE-iF_c.js} +2 -2
  6. package/dist/_chunks/{PkToolShowContactForm-thS7c8iL.js.map → PkToolShowContactForm-DTE-iF_c.js.map} +1 -1
  7. package/dist/_chunks/PkToolShowImageGallery-CGL-HL6v.js +60 -0
  8. package/dist/_chunks/PkToolShowImageGallery-CGL-HL6v.js.map +1 -0
  9. package/dist/_chunks/{PkToolShowProductList-DEo7XogW.js → PkToolShowProductList-C8YIh0Dw.js} +2 -2
  10. package/dist/_chunks/{PkToolShowProductList-DEo7XogW.js.map → PkToolShowProductList-C8YIh0Dw.js.map} +1 -1
  11. package/dist/_chunks/{PkToolShowSources-BMXftK6O.js → PkToolShowSources-TSjtd1ps.js} +3 -3
  12. package/dist/_chunks/{PkToolShowSources-BMXftK6O.js.map → PkToolShowSources-TSjtd1ps.js.map} +1 -1
  13. package/dist/_chunks/{PkToolShowSuggestedReply-CPAnHI0c.js → PkToolShowSuggestedReply-c9sLv4n4.js} +2 -2
  14. package/dist/_chunks/{PkToolShowSuggestedReply-CPAnHI0c.js.map → PkToolShowSuggestedReply-c9sLv4n4.js.map} +1 -1
  15. package/dist/_chunks/{PkToolShowWeather-DcSUbzx0.js → PkToolShowWeather-ChJ5lB4K.js} +48 -48
  16. package/dist/_chunks/PkToolShowWeather-ChJ5lB4K.js.map +1 -0
  17. package/dist/_chunks/{PkToolShowWebPages-aH_GarEV.js → PkToolShowWebPages-CL2mYxh-.js} +2 -2
  18. package/dist/_chunks/{PkToolShowWebPages-aH_GarEV.js.map → PkToolShowWebPages-CL2mYxh-.js.map} +1 -1
  19. package/dist/_chunks/{PkUrl-BHD0_pal.js → PkUrl-CvztUywv.js} +2 -2
  20. package/dist/_chunks/{PkUrl-BHD0_pal.js.map → PkUrl-CvztUywv.js.map} +1 -1
  21. package/dist/_chunks/{useLightbox-DL_oVBep.js → useLightbox-Ddvue042.js} +5 -3
  22. package/{dist-vue/_chunks/useLightbox-1sB7fmFb.js.map → dist/_chunks/useLightbox-Ddvue042.js.map} +1 -1
  23. package/dist/ai-elements.es.js +3097 -3010
  24. package/dist/ai-elements.es.js.map +1 -1
  25. package/dist-vue/PkChatbot.js +1 -1
  26. package/dist-vue/PkChatbotFilePreview.js +1 -1
  27. package/dist-vue/PkChatbotInput.js +1 -1
  28. package/dist-vue/PkChatbotMessages.js +1 -1
  29. package/dist-vue/PkChatbotViewChat.js +1 -1
  30. package/dist-vue/_chunks/{PkChatbot-B9RSkQmJ.js → PkChatbot-BEJTYq-D.js} +4 -4
  31. package/dist-vue/_chunks/{PkChatbot-B9RSkQmJ.js.map → PkChatbot-BEJTYq-D.js.map} +1 -1
  32. package/dist-vue/_chunks/{PkChatbotFilePreview-DHzuGtz5.js → PkChatbotFilePreview-hRNtv2OJ.js} +2 -2
  33. package/dist-vue/_chunks/{PkChatbotFilePreview-DHzuGtz5.js.map → PkChatbotFilePreview-hRNtv2OJ.js.map} +1 -1
  34. package/dist-vue/_chunks/{PkChatbotInput-C5QSmt21.js → PkChatbotInput-BbGLBVim.js} +124 -116
  35. package/dist-vue/_chunks/PkChatbotInput-BbGLBVim.js.map +1 -0
  36. package/dist-vue/_chunks/PkChatbotMessages-j3ALQmGG.js +467 -0
  37. package/dist-vue/_chunks/PkChatbotMessages-j3ALQmGG.js.map +1 -0
  38. package/dist-vue/_chunks/{PkChatbotViewChat-C2FuDayB.js → PkChatbotViewChat-Z05fqNFE.js} +5 -5
  39. package/dist-vue/_chunks/{PkChatbotViewChat-C2FuDayB.js.map → PkChatbotViewChat-Z05fqNFE.js.map} +1 -1
  40. package/dist-vue/_chunks/{PkStreamingMarkdown-BAhC3uGK.js → PkStreamingMarkdown-BBTAwHd_.js} +311 -252
  41. package/dist-vue/_chunks/PkStreamingMarkdown-BBTAwHd_.js.map +1 -0
  42. package/dist-vue/_chunks/{PkToolShowArtifact-RzrDPcEQ.js → PkToolShowArtifact-CbqpjzCA.js} +2 -2
  43. package/dist-vue/_chunks/{PkToolShowArtifact-RzrDPcEQ.js.map → PkToolShowArtifact-CbqpjzCA.js.map} +1 -1
  44. package/dist-vue/_chunks/{PkToolShowContactForm-5H4jfq1F.js → PkToolShowContactForm-BkgfSyw7.js} +2 -2
  45. package/dist-vue/_chunks/{PkToolShowContactForm-5H4jfq1F.js.map → PkToolShowContactForm-BkgfSyw7.js.map} +1 -1
  46. package/dist-vue/_chunks/{PkToolShowImageGallery-B7Bt6ZGv.js → PkToolShowImageGallery-Ckyxa0mx.js} +18 -21
  47. package/dist-vue/_chunks/PkToolShowImageGallery-Ckyxa0mx.js.map +1 -0
  48. package/dist-vue/_chunks/{PkToolShowSources-Dv0uuvqS.js → PkToolShowSources-7Xt3iK2Z.js} +2 -2
  49. package/dist-vue/_chunks/{PkToolShowSources-Dv0uuvqS.js.map → PkToolShowSources-7Xt3iK2Z.js.map} +1 -1
  50. package/dist-vue/_chunks/{PkToolShowWeather-Coq6H0iv.js → PkToolShowWeather-B5Wp8WAt.js} +26 -26
  51. package/dist-vue/_chunks/PkToolShowWeather-B5Wp8WAt.js.map +1 -0
  52. package/dist-vue/_chunks/{useLightbox-1sB7fmFb.js → useLightbox-Cl8REkfc.js} +5 -3
  53. package/{dist/_chunks/useLightbox-DL_oVBep.js.map → dist-vue/_chunks/useLightbox-Cl8REkfc.js.map} +1 -1
  54. package/dist-vue/index.js +11 -11
  55. package/dist-vue/packages/components/src/chat/PkChatbotMessages.d.ts +4 -5
  56. package/dist-vue/packages/components/src/chat/PkStreamingMarkdown.d.ts +9 -1
  57. package/dist-vue/packages/components/src/chat/useChatScroll.d.ts +15 -0
  58. package/dist-vue/style.css +1 -1
  59. package/package.json +1 -1
  60. package/dist/_chunks/PkStreamingMarkdown-COZApJzT.js.map +0 -1
  61. package/dist/_chunks/PkToolShowImageGallery-DmJztS-Z.js +0 -63
  62. package/dist/_chunks/PkToolShowImageGallery-DmJztS-Z.js.map +0 -1
  63. package/dist/_chunks/PkToolShowWeather-DcSUbzx0.js.map +0 -1
  64. package/dist-vue/_chunks/PkChatbotInput-C5QSmt21.js.map +0 -1
  65. package/dist-vue/_chunks/PkChatbotMessages-DOeUT6YL.js +0 -388
  66. package/dist-vue/_chunks/PkChatbotMessages-DOeUT6YL.js.map +0 -1
  67. package/dist-vue/_chunks/PkStreamingMarkdown-BAhC3uGK.js.map +0 -1
  68. package/dist-vue/_chunks/PkToolShowImageGallery-B7Bt6ZGv.js.map +0 -1
  69. package/dist-vue/_chunks/PkToolShowWeather-Coq6H0iv.js.map +0 -1
  70. /package/dist/_chunks/{_plugin-vue_export-helper-BI3pHb34.js → _plugin-vue_export-helper-C6kC663S.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { n as e } from "./rolldown-runtime-D9KsE1-l.js";
2
2
  import { n as t } from "./src-EtGd6cRz.js";
3
- import { n, t as r } from "./useLightbox-1sB7fmFb.js";
3
+ import { n, t as r } from "./useLightbox-Cl8REkfc.js";
4
4
  import { Fragment as i, computed as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createVNode as l, defineComponent as u, normalizeClass as d, onMounted as f, openBlock as p, ref as m, renderList as h, toDisplayString as g, unref as _ } from "vue";
5
5
  import { VvIcon as v } from "@volverjs/ui-vue/components";
6
6
  //#region ../../packages/components/src/chat/PkToolShowImageGallery.vue?vue&type=script&setup=true&lang.ts
@@ -16,37 +16,34 @@ var y = {
16
16
  "title",
17
17
  "target",
18
18
  "rel"
19
- ], w = ["src", "alt"], T = {
20
- key: 0,
21
- class: "absolute inset-0 bg-black/50 flex items-center justify-center text-white font-semibold text-16 rounded-lg"
22
- }, E = /* @__PURE__ */ u({
19
+ ], w = ["src", "alt"], T = /* @__PURE__ */ u({
23
20
  __name: "PkToolShowImageGallery",
24
21
  props: { part: {} },
25
22
  setup(e) {
26
- let u = e, E = a(() => u.part), D = m(), { preload: O, getSize: k } = r(), A = a(() => E.value.input?.images ?? []), j = a(() => A.value.length > 6 ? A.value.length - 5 : 0), M = a(() => {
27
- let e = A.value.length;
23
+ let u = e, T = a(() => u.part), E = m(), { preload: D, getSize: O } = r(), k = a(() => T.value.input?.images ?? []), A = a(() => {
24
+ let e = k.value.length;
28
25
  return e === 1 ? "grid-cols-1" : e === 2 ? "grid-cols-2" : "grid-cols-3";
29
- }), { init: N } = n({ gallery: D });
26
+ }), { init: j } = n({ gallery: E });
30
27
  return f(async () => {
31
- O(A.value), await N();
28
+ D(k.value), await j();
32
29
  }), (e, n) => {
33
30
  let r = v;
34
- return A.value.length ? (p(), s("div", y, [c("div", b, [l(r, {
31
+ return k.value.length ? (p(), s("div", y, [c("div", b, [l(r, {
35
32
  name: "ri:image-line",
36
33
  class: "text-16"
37
- }), c("strong", x, g(e.$t("label.gallery", { count: A.value.length })), 1)]), c("div", S, [c("div", {
34
+ }), c("strong", x, g(e.$t("label.gallery", { count: k.value.length })), 1)]), c("div", S, [c("div", {
38
35
  ref_key: "galleryRef",
39
- ref: D,
40
- class: d(["grid gap-8", M.value])
41
- }, [(p(!0), s(i, null, h(A.value, (e, n) => (p(), s("a", {
36
+ ref: E,
37
+ class: d(["grid gap-8", A.value])
38
+ }, [(p(!0), s(i, null, h(k.value, (e) => (p(), s("a", {
42
39
  key: e.url,
43
40
  href: e.url,
44
41
  "data-pswp-src": e.url,
45
- "data-pswp-width": _(k)(e.url).width,
46
- "data-pswp-height": _(k)(e.url).height,
42
+ "data-pswp-width": _(O)(e.url).width,
43
+ "data-pswp-height": _(O)(e.url).height,
47
44
  "data-pswp-caption": e.caption ?? e.alt ?? "",
48
45
  "data-cropped": !0,
49
- class: d(["relative block aspect-square overflow-hidden rounded-lg cursor-pointer group", n >= 5 && j.value > 0 ? "hidden" : ""]),
46
+ class: "relative block aspect-square overflow-hidden rounded-lg cursor-pointer group",
50
47
  title: e.caption ?? e.alt ?? "",
51
48
  target: _(t)(e.url) ? void 0 : "_blank",
52
49
  rel: _(t)(e.url) ? void 0 : "noopener noreferrer"
@@ -54,11 +51,11 @@ var y = {
54
51
  src: e.url,
55
52
  alt: e.alt ?? e.caption ?? "",
56
53
  class: "w-full h-full object-cover transition-opacity group-hover:opacity-80"
57
- }, null, 8, w), j.value > 0 && n === 4 ? (p(), s("div", T, " +" + g(j.value), 1)) : o("", !0)], 10, C))), 128))], 2)])])) : o("", !0);
54
+ }, null, 8, w)], 8, C))), 128))], 2)])])) : o("", !0);
58
55
  };
59
56
  }
60
- }), D = /* @__PURE__ */ e({ default: () => O }), O = E;
57
+ }), E = /* @__PURE__ */ e({ default: () => D }), D = T;
61
58
  //#endregion
62
- export { D as n, O as t };
59
+ export { E as n, D as t };
63
60
 
64
- //# sourceMappingURL=PkToolShowImageGallery-B7Bt6ZGv.js.map
61
+ //# sourceMappingURL=PkToolShowImageGallery-Ckyxa0mx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PkToolShowImageGallery-Ckyxa0mx.js","names":["$t"],"sources":["../../../../packages/components/src/chat/PkToolShowImageGallery.vue","../../../../packages/components/src/chat/PkToolShowImageGallery.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref, onMounted } from 'vue'\n import { isSameSite } from 'utils'\n import { useLightbox, useImageSizes } from '../composables/useLightbox'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n images: Array<{\n url: string\n caption?: string\n alt?: string\n }>\n }\n }\n return part\n })\n\n const galleryRef = ref<HTMLElement>()\n const { preload, getSize } = useImageSizes()\n\n const images = computed(() => toolPart.value.input?.images ?? [])\n\n const gridCols = computed(() => {\n const count = images.value.length\n if (count === 1) {\n return 'grid-cols-1'\n }\n if (count === 2) {\n return 'grid-cols-2'\n }\n return 'grid-cols-3'\n })\n\n const { init } = useLightbox({ gallery: galleryRef })\n\n onMounted(async () => {\n preload(images.value)\n await init()\n })\n</script>\n\n<template>\n <div\n v-if=\"images.length\"\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\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:image-line\" class=\"text-16\" />\n <strong class=\"font-bold\">\n {{ $t('label.gallery', { count: images.length }) }}\n </strong>\n </div>\n <div class=\"p-sm\">\n <div ref=\"galleryRef\" class=\"grid gap-8\" :class=\"gridCols\">\n <a\n v-for=\"image in images\"\n :key=\"image.url\"\n :href=\"image.url\"\n :data-pswp-src=\"image.url\"\n :data-pswp-width=\"getSize(image.url).width\"\n :data-pswp-height=\"getSize(image.url).height\"\n :data-pswp-caption=\"image.caption ?? image.alt ?? ''\"\n :data-cropped=\"true\"\n class=\"relative block aspect-square overflow-hidden rounded-lg cursor-pointer group\"\n :title=\"image.caption ?? image.alt ?? ''\"\n :target=\"isSameSite(image.url) ? undefined : '_blank'\"\n :rel=\"\n isSameSite(image.url)\n ? undefined\n : 'noopener noreferrer'\n \">\n <img\n :src=\"image.url\"\n :alt=\"image.alt ?? image.caption ?? ''\"\n class=\"w-full h-full object-cover transition-opacity group-hover:opacity-80\" />\n </a>\n </div>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref, onMounted } from 'vue'\n import { isSameSite } from 'utils'\n import { useLightbox, useImageSizes } from '../composables/useLightbox'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n images: Array<{\n url: string\n caption?: string\n alt?: string\n }>\n }\n }\n return part\n })\n\n const galleryRef = ref<HTMLElement>()\n const { preload, getSize } = useImageSizes()\n\n const images = computed(() => toolPart.value.input?.images ?? [])\n\n const gridCols = computed(() => {\n const count = images.value.length\n if (count === 1) {\n return 'grid-cols-1'\n }\n if (count === 2) {\n return 'grid-cols-2'\n }\n return 'grid-cols-3'\n })\n\n const { init } = useLightbox({ gallery: galleryRef })\n\n onMounted(async () => {\n preload(images.value)\n await init()\n })\n</script>\n\n<template>\n <div\n v-if=\"images.length\"\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\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:image-line\" class=\"text-16\" />\n <strong class=\"font-bold\">\n {{ $t('label.gallery', { count: images.length }) }}\n </strong>\n </div>\n <div class=\"p-sm\">\n <div ref=\"galleryRef\" class=\"grid gap-8\" :class=\"gridCols\">\n <a\n v-for=\"image in images\"\n :key=\"image.url\"\n :href=\"image.url\"\n :data-pswp-src=\"image.url\"\n :data-pswp-width=\"getSize(image.url).width\"\n :data-pswp-height=\"getSize(image.url).height\"\n :data-pswp-caption=\"image.caption ?? image.alt ?? ''\"\n :data-cropped=\"true\"\n class=\"relative block aspect-square overflow-hidden rounded-lg cursor-pointer group\"\n :title=\"image.caption ?? image.alt ?? ''\"\n :target=\"isSameSite(image.url) ? undefined : '_blank'\"\n :rel=\"\n isSameSite(image.url)\n ? undefined\n : 'noopener noreferrer'\n \">\n <img\n :src=\"image.url\"\n :alt=\"image.alt ?? image.caption ?? ''\"\n class=\"w-full h-full object-cover transition-opacity group-hover:opacity-80\" />\n </a>\n </div>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EAKI,IAAM,IAAQ,GAIR,IAAW,QACA,EAAM,KAUtB,EAEK,IAAa,GAAiB,EAC9B,EAAE,YAAS,eAAY,GAAc,EA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l, y as
3
3
  import { a as d, c as f, i as p, l as m, n as h, s as g } from "./Media-kK7BnZGr.js";
4
4
  import { m as _ } from "./src-EtGd6cRz.js";
5
5
  import { t as ee } from "./PkUrl-CGbSBfuP.js";
6
- import { t as v } from "./PkStreamingMarkdown-BAhC3uGK.js";
6
+ import { t as v } from "./PkStreamingMarkdown-BBTAwHd_.js";
7
7
  import { Fragment as y, Transition as b, computed as x, createBlock as S, createCommentVNode as C, createElementBlock as w, createElementVNode as T, createTextVNode as E, createVNode as D, defineComponent as O, normalizeClass as k, openBlock as A, reactive as j, ref as te, renderList as M, toDisplayString as N, unref as P, withCtx as F } from "vue";
8
8
  import { VvIcon as I } from "@volverjs/ui-vue/components";
9
9
  var L = t(i({
@@ -416,4 +416,4 @@ var V = (e) => {
416
416
  //#endregion
417
417
  export { H as a, G as i, ye as n, X as r, $ as t };
418
418
 
419
- //# sourceMappingURL=PkToolShowSources-Dv0uuvqS.js.map
419
+ //# sourceMappingURL=PkToolShowSources-7Xt3iK2Z.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PkToolShowSources-Dv0uuvqS.js","names":["$t"],"sources":["../../../../packages/models/src/schema/Header.ts","../../../../packages/models/src/schema/Document.ts","../../../../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":["import * as z from 'zod'\n\nexport const HeaderSchema = z.object({\n key: z.string().optional(),\n value: z.string().optional(),\n})\n\nexport const HeadesSchema = z.array(HeaderSchema).transform((headers) => {\n return headers?.filter(\n (header) => header.key?.trim() && header.value?.trim(),\n ) as Array<{ key: string; value: string }>\n})\n\nexport type Header = z.infer<typeof HeaderSchema>\nexport type Headers = z.infer<typeof HeadesSchema>\n","import * as z from 'zod'\nimport { zodQs } from '../utils'\nimport {\n SupportedLanguage,\n ExtractionStrategy,\n BrowserEngine,\n} from './constants'\nimport { MediaSchema } from './Media'\nimport { HeadesSchema } from './Header'\n\n/**\n * Processing status for document indexing and embedding generation\n */\nexport enum IndexStatus {\n Pending = 'pending',\n Processing = 'processing',\n Success = 'success',\n Failed = 'failed',\n}\n\n// ===== Document Source Types =====\n\n/**\n * Conversion options for document processing\n * Used when creating or reprocessing documents\n */\nexport const ConversionOptionsSchema = z.object({\n extractionStrategy: z.enum(ExtractionStrategy).optional(),\n browserEngine: z.enum(BrowserEngine).optional(),\n headers: HeadesSchema.nullish(),\n aiDescriptionModel: z.string().optional(),\n aiDescriptionPrompt: z.string().max(5000).optional(),\n language: z.string().optional(),\n forceOcr: z.boolean().default(false),\n pages: z\n .string()\n .max(100)\n .regex(/^\\d+(\\s*-\\s*\\d+)?(\\s*,\\s*\\d+(\\s*-\\s*\\d+)?)*$/)\n .optional(),\n})\n\nexport type ConversionOptions = z.infer<typeof ConversionOptionsSchema>\n\n/**\n * Metadata structure for document.metadata column\n * Consolidates all metadata from converters and source info\n */\nexport const DocumentMetadataSchema = z\n .object({\n // === Source Info (URL documents only) ===\n source: z\n .object({\n url: z.string(),\n lastScrapedAt: z.string(),\n })\n .optional(),\n\n // === Media Info (File documents only) ===\n media: MediaSchema.optional(),\n\n // === Common Fields (all document types) ===\n title: z.string().optional(),\n author: z.string().optional(),\n description: z.string().optional(),\n summary: z.string().optional(),\n keywords: z.array(z.string()).optional(),\n\n // === PDF Specific ===\n subject: z.string().optional(),\n creator: z.string().optional(), // Original application\n producer: z.string().optional(), // PDF generator software\n creationDate: z.string().optional(),\n modificationDate: z.string().optional(),\n pageCount: z\n .union([z.number(), z.array(z.unknown())])\n .transform((val) => (Array.isArray(val) ? val.length : val))\n .optional(),\n encrypted: z.boolean().optional(),\n\n // === DOCX Specific ===\n characterCount: z.number().optional(),\n lineCount: z.number().optional(),\n\n // === URL Specific ===\n siteName: z.string().optional(),\n canonicalUrl: z.url().optional(),\n imageUrl: z.url().optional(),\n favicon: z.url().optional(),\n type: z.string().optional(), // og:type (article, website, etc.)\n locale: z.string().optional(),\n tags: z.array(z.string()).optional(),\n publishedTime: z.string().optional(),\n modifiedTime: z.string().optional(),\n\n // === Metrics (all document types) ===\n wordCount: z.number().optional(),\n paragraphCount: z.number().optional(),\n readingTime: z.number().optional(), // in minutes\n\n // === OCR (PDF documents) ===\n ocrUsed: z.boolean().optional(),\n ocrProvider: z.string().optional(),\n ocrModel: z.string().optional(),\n ocrPages: z.string().optional(),\n ocrCost: z.number().optional(),\n ocrError: z.string().optional(),\n\n // === Conversion Options (for reprocessing) ===\n conversionOptions: ConversionOptionsSchema.optional(),\n })\n .loose() // Allow additional custom fields\n\nexport type DocumentMetadata = z.infer<typeof DocumentMetadataSchema>\n\n/**\n * Document type enum\n *\n * - 'file': Document created from uploaded file (PDF, DOCX)\n * - 'url': Document created from web scraping\n * - 'revised-answer': Document created from revised AI answer\n * - 'plain-text': Document created from plain text input\n */\nexport enum DocumentType {\n File = 'file',\n Url = 'url',\n RevisedAnswer = 'revised-answer',\n PlainText = 'plain-text',\n}\n\n// ===== Schemas =====\n\n/**\n * Full document schema from database\n * Extended with computed field chunksCount\n */\nconst BaseDocumentSchema = z.object({\n id: z.string(),\n externalId: z.string().nullable(),\n name: z.string(),\n content: z.string(),\n type: z.string(),\n language: z.string(),\n metadata: z.record(z.string(), z.unknown()),\n indexStatus: z.string(),\n processedAt: z.coerce.date().nullable(),\n createdAt: z.coerce.date(),\n createdBy: z.string(),\n updatedAt: z.coerce.date(),\n updatedBy: z.string(),\n deleted: z.boolean(),\n deletedAt: z.coerce.date().nullable(),\n deletedBy: z.string().nullable(),\n organizationId: z.string(),\n})\n\nexport const DocumentSchema = BaseDocumentSchema.extend({\n type: z.enum(DocumentType),\n indexStatus: z.enum(IndexStatus),\n metadata: DocumentMetadataSchema,\n // Add computed field for chunks count (populated by service layer)\n chunksCount: z.number().optional(),\n})\n\n/**\n * Query parameters for listing documents with pagination, sorting, and filters\n */\nexport const DocumentQuerystringSchema = z.object({\n ...zodQs.pagination(),\n ...zodQs.sort(['id', 'updatedAt', 'createdAt', 'name']),\n ...zodQs.filters(['type', 'language', 'agentId', 'indexStatus']),\n ...zodQs.fullText(),\n ...zodQs.ids(),\n 'filter[similarity]': z.string().optional(),\n})\n\n/**\n * Document creation schema for POST /documents endpoint\n *\n * Supports three types:\n * - 'file': Requires media object with uploaded file info\n * - 'url': Requires url string for web scraping\n * - 'revised-answer': Requires content (created from revisedAnswer service)\n */\nexport const DocumentCreateDtoSchema = z\n .object({\n type: z.enum(DocumentType).default(DocumentType.File),\n name: z.string().min(1).max(255).optional(),\n language: z.enum(SupportedLanguage).optional(),\n organizationId: z.string(),\n agentIds: z.array(z.string()).min(1, 'At least one agent is required'),\n media: MediaSchema.optional(),\n url: z.url().optional(),\n content: z.string().optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n extractionStrategy: z.enum(ExtractionStrategy).optional(),\n browserEngine: z.enum(BrowserEngine).optional(),\n headers: HeadesSchema.nullish().default([]),\n aiDescriptionModel: z.string().optional(),\n aiDescriptionPrompt: z.string().max(5000).optional(),\n forceOcr: z.boolean().default(false),\n pages: z\n .string()\n .max(100)\n .regex(/^\\d+(\\s*-\\s*\\d+)?(\\s*,\\s*\\d+(\\s*-\\s*\\d+)?)*$/)\n .optional(),\n })\n .superRefine((data, ctx) => {\n if (data.type === DocumentType.File && !data.media) {\n ctx.addIssue({\n code: 'custom',\n params: {\n i18n: 'errors.required',\n },\n path: ['media'],\n })\n return\n }\n if (data.type === DocumentType.Url && !data.url) {\n ctx.addIssue({\n code: 'custom',\n params: {\n i18n: 'errors.required',\n },\n path: ['url'],\n })\n }\n if (\n data.type === DocumentType.PlainText &&\n !(data.name || data.language)\n ) {\n if (!data.name) {\n ctx.addIssue({\n code: 'custom',\n params: {\n i18n: 'errors.required',\n },\n path: ['name'],\n })\n }\n if (!data.language) {\n ctx.addIssue({\n code: 'custom',\n params: {\n i18n: 'errors.required',\n },\n path: ['language'],\n })\n }\n }\n })\n\n/**\n * Document update schema for PUT /documents/:id endpoint\n *\n * All fields are optional, but at least one must be provided\n */\nexport const DocumentUpdateDtoSchema = z.object({\n id: z.string(),\n organizationId: z.string(),\n content: z.string().optional(),\n name: z.string().min(1).max(255).optional(),\n language: z.enum(SupportedLanguage).optional(),\n agentIds: z.array(z.string()).min(1).optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n})\n\n// ===== Type Exports =====\n\nexport type Document = z.infer<typeof DocumentSchema>\nexport type DocumentQuerystring = z.infer<typeof DocumentQuerystringSchema>\nexport type DocumentCreateDto = z.infer<typeof DocumentCreateDtoSchema>\nexport type DocumentUpdateDto = z.infer<typeof DocumentUpdateDtoSchema>\n\n// ===== Helper Functions =====\n\nexport const getStatusColor = (status: IndexStatus) => {\n switch (status) {\n case IndexStatus.Success:\n return 'success'\n case IndexStatus.Failed:\n return 'danger'\n case IndexStatus.Processing:\n return 'warning'\n default:\n return 'info'\n }\n}\n\nexport const getStatusIcon = (status: IndexStatus) => {\n switch (status) {\n case IndexStatus.Success:\n return 'ri:check-line'\n case IndexStatus.Failed:\n return 'ri:error-warning-line'\n case IndexStatus.Processing:\n return 'ri:hourglass-line'\n default:\n return 'ri:time-line'\n }\n}\n\nexport const getTypeIcon = (type: DocumentType) => {\n switch (type) {\n case DocumentType.File:\n return 'ri:file-line'\n case DocumentType.Url:\n return 'ri:link'\n case DocumentType.RevisedAnswer:\n return 'ri:feedback-line'\n default:\n return 'ri:input-method-line'\n }\n}\n\nexport const getFileIcon = (extension: string) => {\n const ext = (\n extension.startsWith('.') ? extension.slice(1) : extension\n ).toLowerCase()\n switch (ext) {\n case 'pdf':\n return 'ri:file-pdf-2-line'\n case 'doc':\n case 'docx':\n return 'ri:file-word-line'\n case 'xls':\n case 'xlsx':\n return 'ri:file-excel-line'\n case 'ppt':\n case 'pptx':\n return 'ri:file-ppt-line'\n case 'txt':\n return 'ri:file-text-line'\n case 'mp3':\n case 'wav':\n case 'ogg':\n return 'ri:file-music-line'\n case 'mp4':\n case 'avi':\n case 'mkv':\n return 'ri:file-video-line'\n case 'jpg':\n case 'jpeg':\n case 'png':\n case 'gif':\n case 'bmp':\n case 'svg':\n return 'ri:file-image-line'\n case 'zip':\n case 'rar':\n case '7z':\n return 'ri:file-zip-line'\n default:\n return 'ri:file-line'\n }\n}\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 { 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-lg 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 ? 'line-md: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-lg 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 ? 'line-md: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":";;;;;;;;AAOA,IAAa,IAAe,EALA,EAAS;CACjC,KAAK,GAAU,CAAC,UAAU;CAC1B,OAAO,GAAU,CAAC,UAAU;CAC/B,CAEmC,CAAa,CAAC,WAAW,MAClD,GAAS,QACX,MAAW,EAAO,KAAK,MAAM,IAAI,EAAO,OAAO,MAAM,CACzD,CACH,ECEU,KAAL,yBAAA,GAAA;QACH,EAAA,UAAU,WACV,EAAA,aAAa,cACb,EAAA,UAAU,WACV,EAAA,SAAS;KACZ,EAQY,IAA0B,EAAS;CAC5C,oBAAoB,EAAO,EAAmB,CAAC,UAAU;CACzD,eAAe,EAAO,EAAc,CAAC,UAAU;CAC/C,SAAS,EAAa,SAAS;CAC/B,oBAAoB,GAAU,CAAC,UAAU;CACzC,qBAAqB,GAAU,CAAC,IAAI,IAAK,CAAC,UAAU;CACpD,UAAU,GAAU,CAAC,UAAU;CAC/B,UAAU,GAAW,CAAC,QAAQ,GAAM;CACpC,OAAO,GACM,CACR,IAAI,IAAI,CACR,MAAM,+CAA+C,CACrD,UAAU;CAClB,CAAC,EAQW,IAAyB,EAC1B;CAEJ,QAAQ,EACI;EACJ,KAAK,GAAU;EACf,eAAe,GAAU;EAC5B,CAAC,CACD,UAAU;CAGf,OAAO,EAAY,UAAU;CAG7B,OAAO,GAAU,CAAC,UAAU;CAC5B,QAAQ,GAAU,CAAC,UAAU;CAC7B,aAAa,GAAU,CAAC,UAAU;CAClC,SAAS,GAAU,CAAC,UAAU;CAC9B,U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t3iK2Z.js","names":["$t"],"sources":["../../../../packages/models/src/schema/Header.ts","../../../../packages/models/src/schema/Document.ts","../../../../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":["import * as z from 'zod'\n\nexport const HeaderSchema = z.object({\n key: z.string().optional(),\n value: z.string().optional(),\n})\n\nexport const HeadesSchema = z.array(HeaderSchema).transform((headers) => {\n return headers?.filter(\n (header) => header.key?.trim() && header.value?.trim(),\n ) as Array<{ key: string; value: string }>\n})\n\nexport type Header = z.infer<typeof HeaderSchema>\nexport type Headers = z.infer<typeof HeadesSchema>\n","import * as z from 'zod'\nimport { zodQs } from '../utils'\nimport {\n SupportedLanguage,\n ExtractionStrategy,\n BrowserEngine,\n} from './constants'\nimport { MediaSchema } from './Media'\nimport { HeadesSchema } from './Header'\n\n/**\n * Processing status for document indexing and embedding generation\n */\nexport enum IndexStatus {\n Pending = 'pending',\n Processing = 'processing',\n Success = 'success',\n Failed = 'failed',\n}\n\n// ===== Document Source Types =====\n\n/**\n * Conversion options for document processing\n * Used when creating or reprocessing documents\n */\nexport const ConversionOptionsSchema = z.object({\n extractionStrategy: z.enum(ExtractionStrategy).optional(),\n browserEngine: z.enum(BrowserEngine).optional(),\n headers: HeadesSchema.nullish(),\n aiDescriptionModel: z.string().optional(),\n aiDescriptionPrompt: z.string().max(5000).optional(),\n language: z.string().optional(),\n forceOcr: z.boolean().default(false),\n pages: z\n .string()\n .max(100)\n .regex(/^\\d+(\\s*-\\s*\\d+)?(\\s*,\\s*\\d+(\\s*-\\s*\\d+)?)*$/)\n .optional(),\n})\n\nexport type ConversionOptions = z.infer<typeof ConversionOptionsSchema>\n\n/**\n * Metadata structure for document.metadata column\n * Consolidates all metadata from converters and source info\n */\nexport const DocumentMetadataSchema = z\n .object({\n // === Source Info (URL documents only) ===\n source: z\n .object({\n url: z.string(),\n lastScrapedAt: z.string(),\n })\n .optional(),\n\n // === Media Info (File documents only) ===\n media: MediaSchema.optional(),\n\n // === Common Fields (all document types) ===\n title: z.string().optional(),\n author: z.string().optional(),\n description: z.string().optional(),\n summary: z.string().optional(),\n keywords: z.array(z.string()).optional(),\n\n // === PDF Specific ===\n subject: z.string().optional(),\n creator: z.string().optional(), // Original application\n producer: z.string().optional(), // PDF generator software\n creationDate: z.string().optional(),\n modificationDate: z.string().optional(),\n pageCount: z\n .union([z.number(), z.array(z.unknown())])\n .transform((val) => (Array.isArray(val) ? val.length : val))\n .optional(),\n encrypted: z.boolean().optional(),\n\n // === DOCX Specific ===\n characterCount: z.number().optional(),\n lineCount: z.number().optional(),\n\n // === URL Specific ===\n siteName: z.string().optional(),\n canonicalUrl: z.url().optional(),\n imageUrl: z.url().optional(),\n favicon: z.url().optional(),\n type: z.string().optional(), // og:type (article, website, etc.)\n locale: z.string().optional(),\n tags: z.array(z.string()).optional(),\n publishedTime: z.string().optional(),\n modifiedTime: z.string().optional(),\n\n // === Metrics (all document types) ===\n wordCount: z.number().optional(),\n paragraphCount: z.number().optional(),\n readingTime: z.number().optional(), // in minutes\n\n // === OCR (PDF documents) ===\n ocrUsed: z.boolean().optional(),\n ocrProvider: z.string().optional(),\n ocrModel: z.string().optional(),\n ocrPages: z.string().optional(),\n ocrCost: z.number().optional(),\n ocrError: z.string().optional(),\n\n // === Conversion Options (for reprocessing) ===\n conversionOptions: ConversionOptionsSchema.optional(),\n })\n .loose() // Allow additional custom fields\n\nexport type DocumentMetadata = z.infer<typeof DocumentMetadataSchema>\n\n/**\n * Document type enum\n *\n * - 'file': Document created from uploaded file (PDF, DOCX)\n * - 'url': Document created from web scraping\n * - 'revised-answer': Document created from revised AI answer\n * - 'plain-text': Document created from plain text input\n */\nexport enum DocumentType {\n File = 'file',\n Url = 'url',\n RevisedAnswer = 'revised-answer',\n PlainText = 'plain-text',\n}\n\n// ===== Schemas =====\n\n/**\n * Full document schema from database\n * Extended with computed field chunksCount\n */\nconst BaseDocumentSchema = z.object({\n id: z.string(),\n externalId: z.string().nullable(),\n name: z.string(),\n content: z.string(),\n type: z.string(),\n language: z.string(),\n metadata: z.record(z.string(), z.unknown()),\n indexStatus: z.string(),\n processedAt: z.coerce.date().nullable(),\n createdAt: z.coerce.date(),\n createdBy: z.string(),\n updatedAt: z.coerce.date(),\n updatedBy: z.string(),\n deleted: z.boolean(),\n deletedAt: z.coerce.date().nullable(),\n deletedBy: z.string().nullable(),\n organizationId: z.string(),\n})\n\nexport const DocumentSchema = BaseDocumentSchema.extend({\n type: z.enum(DocumentType),\n indexStatus: z.enum(IndexStatus),\n metadata: DocumentMetadataSchema,\n // Add computed field for chunks count (populated by service layer)\n chunksCount: z.number().optional(),\n})\n\n/**\n * Query parameters for listing documents with pagination, sorting, and filters\n */\nexport const DocumentQuerystringSchema = z.object({\n ...zodQs.pagination(),\n ...zodQs.sort(['id', 'updatedAt', 'createdAt', 'name']),\n ...zodQs.filters(['type', 'language', 'agentId', 'indexStatus']),\n ...zodQs.fullText(),\n ...zodQs.ids(),\n 'filter[similarity]': z.string().optional(),\n})\n\n/**\n * Document creation schema for POST /documents endpoint\n *\n * Supports three types:\n * - 'file': Requires media object with uploaded file info\n * - 'url': Requires url string for web scraping\n * - 'revised-answer': Requires content (created from revisedAnswer service)\n */\nexport const DocumentCreateDtoSchema = z\n .object({\n type: z.enum(DocumentType).default(DocumentType.File),\n name: z.string().min(1).max(255).optional(),\n language: z.enum(SupportedLanguage).optional(),\n organizationId: z.string(),\n agentIds: z.array(z.string()).min(1, 'At least one agent is required'),\n media: MediaSchema.optional(),\n url: z.url().optional(),\n content: z.string().optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n extractionStrategy: z.enum(ExtractionStrategy).optional(),\n browserEngine: z.enum(BrowserEngine).optional(),\n headers: HeadesSchema.nullish().default([]),\n aiDescriptionModel: z.string().optional(),\n aiDescriptionPrompt: z.string().max(5000).optional(),\n forceOcr: z.boolean().default(false),\n pages: z\n .string()\n .max(100)\n .regex(/^\\d+(\\s*-\\s*\\d+)?(\\s*,\\s*\\d+(\\s*-\\s*\\d+)?)*$/)\n .optional(),\n })\n .superRefine((data, ctx) => {\n if (data.type === DocumentType.File && !data.media) {\n ctx.addIssue({\n code: 'custom',\n params: {\n i18n: 'errors.required',\n },\n path: ['media'],\n })\n return\n }\n if (data.type === DocumentType.Url && !data.url) {\n ctx.addIssue({\n code: 'custom',\n params: {\n i18n: 'errors.required',\n },\n path: ['url'],\n })\n }\n if (\n data.type === DocumentType.PlainText &&\n !(data.name || data.language)\n ) {\n if (!data.name) {\n ctx.addIssue({\n code: 'custom',\n params: {\n i18n: 'errors.required',\n },\n path: ['name'],\n })\n }\n if (!data.language) {\n ctx.addIssue({\n code: 'custom',\n params: {\n i18n: 'errors.required',\n },\n path: ['language'],\n })\n }\n }\n })\n\n/**\n * Document update schema for PUT /documents/:id endpoint\n *\n * All fields are optional, but at least one must be provided\n */\nexport const DocumentUpdateDtoSchema = z.object({\n id: z.string(),\n organizationId: z.string(),\n content: z.string().optional(),\n name: z.string().min(1).max(255).optional(),\n language: z.enum(SupportedLanguage).optional(),\n agentIds: z.array(z.string()).min(1).optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n})\n\n// ===== Type Exports =====\n\nexport type Document = z.infer<typeof DocumentSchema>\nexport type DocumentQuerystring = z.infer<typeof DocumentQuerystringSchema>\nexport type DocumentCreateDto = z.infer<typeof DocumentCreateDtoSchema>\nexport type DocumentUpdateDto = z.infer<typeof DocumentUpdateDtoSchema>\n\n// ===== Helper Functions =====\n\nexport const getStatusColor = (status: IndexStatus) => {\n switch (status) {\n case IndexStatus.Success:\n return 'success'\n case IndexStatus.Failed:\n return 'danger'\n case IndexStatus.Processing:\n return 'warning'\n default:\n return 'info'\n }\n}\n\nexport const getStatusIcon = (status: IndexStatus) => {\n switch (status) {\n case IndexStatus.Success:\n return 'ri:check-line'\n case IndexStatus.Failed:\n return 'ri:error-warning-line'\n case IndexStatus.Processing:\n return 'ri:hourglass-line'\n default:\n return 'ri:time-line'\n }\n}\n\nexport const getTypeIcon = (type: DocumentType) => {\n switch (type) {\n case DocumentType.File:\n return 'ri:file-line'\n case DocumentType.Url:\n return 'ri:link'\n case DocumentType.RevisedAnswer:\n return 'ri:feedback-line'\n default:\n return 'ri:input-method-line'\n }\n}\n\nexport const getFileIcon = (extension: string) => {\n const ext = (\n extension.startsWith('.') ? extension.slice(1) : extension\n ).toLowerCase()\n switch (ext) {\n case 'pdf':\n return 'ri:file-pdf-2-line'\n case 'doc':\n case 'docx':\n return 'ri:file-word-line'\n case 'xls':\n case 'xlsx':\n return 'ri:file-excel-line'\n case 'ppt':\n case 'pptx':\n return 'ri:file-ppt-line'\n case 'txt':\n return 'ri:file-text-line'\n case 'mp3':\n case 'wav':\n case 'ogg':\n return 'ri:file-music-line'\n case 'mp4':\n case 'avi':\n case 'mkv':\n return 'ri:file-video-line'\n case 'jpg':\n case 'jpeg':\n case 'png':\n case 'gif':\n case 'bmp':\n case 'svg':\n return 'ri:file-image-line'\n case 'zip':\n case 'rar':\n case '7z':\n return 'ri:file-zip-line'\n default:\n return 'ri:file-line'\n }\n}\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 { 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-lg 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 ? 'line-md: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-lg 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 ? 'line-md: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":";;;;;;;;AAOA,IAAa,IAAe,EALA,EAAS;CACjC,KAAK,GAAU,CAAC,UAAU;CAC1B,OAAO,GAAU,CAAC,UAAU;CAC/B,CAEmC,CAAa,CAAC,WAAW,MAClD,GAAS,QACX,MAAW,EAAO,KAAK,MAAM,IAAI,EAAO,OAAO,MAAM,CACzD,CACH,ECEU,KAAL,yBAAA,GAAA;QACH,EAAA,UAAU,WACV,EAAA,aAAa,cACb,EAAA,UAAU,WACV,EAAA,SAAS;KACZ,EAQY,IAA0B,EAAS;CAC5C,oBAAoB,EAAO,EAAmB,CAA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AW,EAAM,WAAA;SACzB,EAEsB,GAAA;MADlB,MAAK;MACL,OAAM;WAAY,MACtB,EAAGA,EAAAA,GAAE,qBAAA,CAAA,EAAA,EAAA,CAAA,EAAA,IAAA,GAAA,IAAA,EAAA,IAAA,GAAA;;IAWvB,EAAA,SAAA,GAAA,EADV,EAcS,UAAA;;KAZL,OAAM;KACL,SAAK,AAAA,EAAA,QAAA,MAAE,EAAA,QAAQ,CAAI,EAAA;QACpB,EAEsB,GAAA;KADjB,MAAM,EAAA,QAAQ,uBAAA;KACf,OAAM;6BAAY,MACtB,EACI,EAAA,QAA+BA,EAAAA,GAAE,kBAAA,GAA0CA,EAAAA,GAAE,mBAAA,EAAA,OAAuD,EAAA,MAAe,SAAM,GAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,IAAA,EAAA,IAAA,GAAA"}
@@ -1,17 +1,17 @@
1
1
  import { Fragment as e, Transition as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, normalizeClass as u, openBlock as d, ref as f, renderList as p, toDisplayString as m, unref as h, watch as g, withCtx as _ } from "vue";
2
- import { VvAccordion as v, VvIcon as ee } from "@volverjs/ui-vue/components";
3
- import { useI18n as te } from "vue-i18n";
2
+ import { VvAccordion as ee, VvIcon as te } from "@volverjs/ui-vue/components";
3
+ import { useI18n as ne } from "vue-i18n";
4
4
  //#region ../../packages/components/src/chat/PkToolShowWeather.vue?vue&type=script&setup=true&lang.ts
5
- var ne = {
5
+ var re = {
6
6
  key: 0,
7
7
  class: "border border-surface-3 rounded-xl w-full overflow-hidden"
8
- }, re = { 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" }, ie = { class: "font-bold truncate" }, ae = { class: "ml-auto shrink-0 capitalize" }, oe = {
8
+ }, ie = { 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" }, ae = { class: "font-bold truncate" }, oe = { class: "ml-auto shrink-0 capitalize" }, se = {
9
9
  key: 0,
10
10
  class: "px-sm py-md flex items-center gap-md flex-wrap"
11
- }, se = { class: "flex items-center gap-8" }, ce = { class: "text-48 font-light leading-none text-word-1" }, le = { class: "flex flex-col gap-4 text-12 text-word-3" }, ue = { class: "flex items-center gap-6" }, de = { class: "flex items-center gap-6" }, fe = { class: "flex items-center gap-6" }, pe = {
11
+ }, v = { class: "flex items-center gap-8" }, y = { class: "text-48 font-light leading-none text-word-1" }, ce = { class: "flex flex-col gap-4 text-12 text-word-3" }, le = { class: "flex items-center gap-6" }, ue = { class: "flex items-center gap-6" }, de = { class: "flex items-center gap-6" }, fe = {
12
12
  key: 0,
13
13
  class: "flex items-center gap-6"
14
- }, y = {
14
+ }, pe = {
15
15
  key: 1,
16
16
  class: "px-sm py-md flex items-center gap-md flex-wrap"
17
17
  }, b = { class: "flex items-center gap-8" }, x = { class: "flex flex-col leading-none" }, S = { class: "text-48 font-light text-word-1" }, C = { class: "text-20 text-word-3" }, w = { class: "flex flex-col gap-4 text-12 text-word-3" }, T = {
@@ -26,7 +26,7 @@ var ne = {
26
26
  }, k = { class: "flex overflow-x-auto gap-2 px-sm py-8 light-scrollbar" }, A = { class: "text-word-3" }, j = { class: "font-medium text-word-1" }, M = {
27
27
  key: 0,
28
28
  class: "text-word-5 text-smaller"
29
- }, N = ["onClick"], me = { class: "w-48 shrink-0 text-word-3 capitalize" }, P = {
29
+ }, N = ["onClick"], P = { class: "w-48 shrink-0 text-word-3 capitalize" }, me = {
30
30
  key: 0,
31
31
  class: "text-word-5 text-11 w-32 shrink-0"
32
32
  }, F = {
@@ -39,7 +39,7 @@ var ne = {
39
39
  __name: "PkToolShowWeather",
40
40
  props: { part: {} },
41
41
  setup(l) {
42
- let B = l, { t: V, d: H, n: U } = te({ useScope: "global" }), W = n(() => B.part), G = n(() => W.value.input), K = f(0), q = f(!G.value?.current);
42
+ let B = l, { t: V, d: H, n: U } = ne({ useScope: "global" }), W = n(() => B.part), G = n(() => W.value.output ?? W.value.input ?? null), K = f(0), q = f(!G.value?.current);
43
43
  g(K, (e) => {
44
44
  e > 0 && (q.value = !0);
45
45
  });
@@ -82,9 +82,9 @@ var ne = {
82
82
  let he = n(() => {
83
83
  if (J.value) {
84
84
  let e = X(J.value.date + "T12:00:00");
85
- if (!Number.isNaN(e.getTime())) return Q(J.value.date, K.value, G.value.daily.length);
85
+ if (!Number.isNaN(e.getTime())) return Q(J.value.date, K.value, G.value?.daily?.length ?? 1);
86
86
  }
87
- return Q(X((/* @__PURE__ */ new Date()).toISOString().slice(0, 10)), 0, 1);
87
+ return Q((/* @__PURE__ */ new Date()).toISOString().slice(0, 10), 0, 1);
88
88
  });
89
89
  function $(e) {
90
90
  return e <= 20 ? {
@@ -120,34 +120,34 @@ var ne = {
120
120
  ][Math.round(e / 45) % 8];
121
121
  }
122
122
  return (n, l) => {
123
- let f = ee, g = v;
124
- return G.value ? (d(), a("div", ne, [
125
- o("div", re, [
123
+ let f = te, g = ee;
124
+ return G.value ? (d(), a("div", re, [
125
+ o("div", ie, [
126
126
  c(f, {
127
127
  name: "ri:temp-cold-line",
128
128
  class: "text-16"
129
129
  }),
130
- o("strong", ie, m(G.value.locationName), 1),
131
- o("span", ae, m(he.value), 1)
130
+ o("strong", ae, m(G.value.locationName), 1),
131
+ o("span", oe, m(he.value), 1)
132
132
  ]),
133
- G.value.current && K.value === 0 ? (d(), a("div", oe, [o("div", se, [c(f, {
133
+ G.value.current && K.value === 0 ? (d(), a("div", se, [o("div", v, [c(f, {
134
134
  name: Z(G.value.current.weatherCode),
135
135
  class: "text-48 text-word-2 shrink-0"
136
- }, null, 8, ["name"]), o("span", ce, m(h(U)(G.value.current.temperature, "integer")) + "° ", 1)]), o("div", le, [
137
- o("div", ue, m(h(V)("weather.feelsLike")) + " " + m(h(U)(G.value.current.feelsLike, "integer")) + "° ", 1),
138
- o("div", de, [c(f, {
136
+ }, null, 8, ["name"]), o("span", y, m(h(U)(G.value.current.temperature, "integer")) + "° ", 1)]), o("div", ce, [
137
+ o("div", le, m(h(V)("weather.feelsLike")) + " " + m(h(U)(G.value.current.feelsLike, "integer")) + "° ", 1),
138
+ o("div", ue, [c(f, {
139
139
  name: "ri:water-percent-line",
140
140
  class: "text-14"
141
141
  }), s(" " + m(G.value.current.humidity) + "% ", 1)]),
142
- o("div", fe, [c(f, {
142
+ o("div", de, [c(f, {
143
143
  name: "ri:windy-line",
144
144
  class: "text-14"
145
145
  }), s(" " + m(h(U)(G.value.current.windSpeed, "integer")) + " km/h " + m(ge(G.value.current.windDirection)), 1)]),
146
- G.value.current.uvIndex > 0 ? (d(), a("div", pe, [c(f, {
146
+ G.value.current.uvIndex > 0 ? (d(), a("div", fe, [c(f, {
147
147
  name: "ri:sun-line",
148
148
  class: "text-14"
149
149
  }), s(" UV " + m(h(U)(G.value.current.uvIndex, "integer")), 1)])) : i("", !0)
150
- ])])) : J.value ? (d(), a("div", y, [o("div", b, [c(f, {
150
+ ])])) : J.value ? (d(), a("div", pe, [o("div", b, [c(f, {
151
151
  name: Z(J.value.weatherCode),
152
152
  class: "text-48 text-word-2 shrink-0"
153
153
  }, null, 8, ["name"]), o("div", x, [o("span", S, m(h(U)(J.value.maxTemp, "integer")) + "° ", 1), o("span", C, m(h(U)(J.value.minTemp, "integer")) + "° ", 1)])]), o("div", w, [
@@ -180,7 +180,7 @@ var ne = {
180
180
  _: 1
181
181
  }),
182
182
  c(t, null, {
183
- default: _(() => [G.value.daily.length > 1 ? (d(), r(g, {
183
+ default: _(() => [G.value.daily?.length > 1 ? (d(), r(g, {
184
184
  key: 0,
185
185
  modelValue: q.value,
186
186
  "onUpdate:modelValue": l[0] ||= (e) => q.value = e,
@@ -194,12 +194,12 @@ var ne = {
194
194
  class: u(["flex items-center gap-sm px-sm py-8 text-12 w-full text-left transition-colors cursor-pointer border-t border-surface-3", t === K.value ? "bg-surface-2" : "hover:bg-surface-1"]),
195
195
  onClick: (e) => K.value = t
196
196
  }, [
197
- o("span", me, m(Q(e.date, t, G.value.daily.length)), 1),
197
+ o("span", P, m(Q(e.date, t, G.value.daily.length)), 1),
198
198
  c(f, {
199
199
  name: Z(e.weatherCode),
200
200
  class: "text-18 text-word-2 shrink-0"
201
201
  }, null, 8, ["name"]),
202
- e.precipitationProbabilityMax > 0 ? (d(), a("span", P, m(e.precipitationProbabilityMax) + "% ", 1)) : (d(), a("span", F)),
202
+ e.precipitationProbabilityMax > 0 ? (d(), a("span", me, m(e.precipitationProbabilityMax) + "% ", 1)) : (d(), a("span", F)),
203
203
  o("div", I, [o("span", L, m(h(U)(e.maxTemp, "integer")) + "° ", 1), o("span", null, m(h(U)(e.minTemp, "integer")) + "°", 1)])
204
204
  ], 10, N))), 128))]),
205
205
  _: 1
@@ -221,4 +221,4 @@ var ne = {
221
221
  //#endregion
222
222
  export { B as default };
223
223
 
224
- //# sourceMappingURL=PkToolShowWeather-Coq6H0iv.js.map
224
+ //# sourceMappingURL=PkToolShowWeather-B5Wp8WAt.js.map