@8wave/ai-elements 0.125.0-beta.42 → 0.125.0-beta.43
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/Chart-1vt0m6l_.js +87 -0
- package/dist/_chunks/Chart-1vt0m6l_.js.map +1 -0
- package/dist/_chunks/{PkChart-CbtMRGWc.js → PkChart-CYFx_UDq.js} +741 -623
- package/dist/_chunks/PkChart-CYFx_UDq.js.map +1 -0
- package/dist/_chunks/PkFilePreview-yjdtArag.js +1745 -0
- package/dist/_chunks/PkFilePreview-yjdtArag.js.map +1 -0
- package/dist/_chunks/{PkFilePreviewDialog-bcTkTcYk.js → PkFilePreviewDialog-Df0Lt40J.js} +2 -2
- package/dist/_chunks/{PkFilePreviewDialog-bcTkTcYk.js.map → PkFilePreviewDialog-Df0Lt40J.js.map} +1 -1
- package/dist/_chunks/{PkImageEditorDialog-FpbyhV3t.js → PkImageEditorDialog-PVf3IHGB.js} +2 -2
- package/dist/_chunks/{PkImageEditorDialog-FpbyhV3t.js.map → PkImageEditorDialog-PVf3IHGB.js.map} +1 -1
- package/dist/_chunks/{PkSelectionActions-BbfVZY0R.js → PkSelectionActions-CMyg_x8h.js} +2 -2
- package/dist/_chunks/{PkSelectionActions-BbfVZY0R.js.map → PkSelectionActions-CMyg_x8h.js.map} +1 -1
- package/dist/_chunks/{PkStreamingMarkdown-COSOOhCg.js → PkStreamingMarkdown-BDXbU2tz.js} +2 -2
- package/dist/_chunks/{PkStreamingMarkdown-COSOOhCg.js.map → PkStreamingMarkdown-BDXbU2tz.js.map} +1 -1
- package/dist/_chunks/{PkToolChatFile-C_gS0X1j.js → PkToolChatFile-CMQdMs-9.js} +3 -3
- package/dist/_chunks/{PkToolChatFile-C_gS0X1j.js.map → PkToolChatFile-CMQdMs-9.js.map} +1 -1
- package/dist/_chunks/{PkToolShowArtifact-fpFtKrZo.js → PkToolShowArtifact-YrC54qxc.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-fpFtKrZo.js.map → PkToolShowArtifact-YrC54qxc.js.map} +1 -1
- package/dist/_chunks/PkToolShowChart-D3E_xBJv.js +138 -0
- package/dist/_chunks/PkToolShowChart-D3E_xBJv.js.map +1 -0
- package/dist/_chunks/{PkToolShowContactForm-BAM772bm.js → PkToolShowContactForm-Dio2FNkA.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-BAM772bm.js.map → PkToolShowContactForm-Dio2FNkA.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-DJcL0bgw.js → PkToolShowForm-w9HGhvCy.js} +3 -3
- package/dist/_chunks/{PkToolShowForm-DJcL0bgw.js.map → PkToolShowForm-w9HGhvCy.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-GeWAMHYC.js → PkToolShowSources-DXFvFHOo.js} +2 -2
- package/dist/_chunks/{PkToolShowSources-GeWAMHYC.js.map → PkToolShowSources-DXFvFHOo.js.map} +1 -1
- package/dist/_chunks/chartFormat-B1T7y-16.js +27 -0
- package/dist/_chunks/chartFormat-B1T7y-16.js.map +1 -0
- package/dist/_chunks/{excelNumberFormat-BhQjife9.js → excelNumberFormat-CcXF_wJK.js} +101 -88
- package/dist/_chunks/excelNumberFormat-CcXF_wJK.js.map +1 -0
- package/dist/_chunks/{utils-DMvy5QRR.js → utils-BBoaLDYF.js} +14 -14
- package/dist/_chunks/utils-BBoaLDYF.js.map +1 -0
- package/dist/ai-elements.es.js +178 -172
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotEmptyState.js +1 -1
- package/dist-vue/PkChatbotInput.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotStepPayload.js +1 -1
- package/dist-vue/PkChatbotStepToolDetail.js +1 -1
- package/dist-vue/PkChatbotSteps.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/PkChatbotViewConversations.js +1 -1
- package/dist-vue/_chunks/Chart-DsBNs5rS.js +87 -0
- package/dist-vue/_chunks/Chart-DsBNs5rS.js.map +1 -0
- package/dist-vue/_chunks/{PkChart-D-K7nc0g.js → PkChart-CrZqhEpp.js} +112 -74
- package/dist-vue/_chunks/PkChart-CrZqhEpp.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbot-DVQ-Bb7n.js → PkChatbot-CxkTubw8.js} +6 -6
- package/dist-vue/_chunks/{PkChatbot-DVQ-Bb7n.js.map → PkChatbot-CxkTubw8.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotEmptyState-OlgewA4_.js → PkChatbotEmptyState-CUoHkCgO.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-OlgewA4_.js.map → PkChatbotEmptyState-CUoHkCgO.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotInput-D_I0Gf_u.js → PkChatbotInput-CPf7wqiQ.js} +4 -4
- package/dist-vue/_chunks/{PkChatbotInput-D_I0Gf_u.js.map → PkChatbotInput-CPf7wqiQ.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotMessages-CAXnEfXK.js → PkChatbotMessages-CLNu2dTm.js} +307 -307
- package/dist-vue/_chunks/{PkChatbotMessages-CAXnEfXK.js.map → PkChatbotMessages-CLNu2dTm.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepPayload-EBri1L10.js → PkChatbotStepPayload-Cf7mJPjL.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-EBri1L10.js.map → PkChatbotStepPayload-Cf7mJPjL.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-DiQEa0UV.js → PkChatbotStepToolDetail-D6nwNnHv.js} +16 -16
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-DiQEa0UV.js.map → PkChatbotStepToolDetail-D6nwNnHv.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotSteps-BgLnv2J1.js → PkChatbotSteps-xkxdaX7O.js} +38 -38
- package/dist-vue/_chunks/{PkChatbotSteps-BgLnv2J1.js.map → PkChatbotSteps-xkxdaX7O.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-CmjD1IXf.js → PkChatbotViewChat-BkkyjiFl.js} +22 -22
- package/dist-vue/_chunks/{PkChatbotViewChat-CmjD1IXf.js.map → PkChatbotViewChat-BkkyjiFl.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewConversations-CVZH5dXx.js → PkChatbotViewConversations-hgqSO1hx.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewConversations-CVZH5dXx.js.map → PkChatbotViewConversations-hgqSO1hx.js.map} +1 -1
- package/dist-vue/_chunks/{PkFilePreview-k5gEl3n8.js → PkFilePreview-CmsT6lSP.js} +701 -624
- package/dist-vue/_chunks/PkFilePreview-CmsT6lSP.js.map +1 -0
- package/dist-vue/_chunks/{PkFilePreviewDialog-DUwZPErE.js → PkFilePreviewDialog-DIiTt9iK.js} +2 -2
- package/dist-vue/_chunks/{PkFilePreviewDialog-DUwZPErE.js.map → PkFilePreviewDialog-DIiTt9iK.js.map} +1 -1
- package/dist-vue/_chunks/{PkImageEditorDialog-DQPXePae.js → PkImageEditorDialog-CE0Y5Pwr.js} +2 -2
- package/dist-vue/_chunks/{PkImageEditorDialog-DQPXePae.js.map → PkImageEditorDialog-CE0Y5Pwr.js.map} +1 -1
- package/dist-vue/_chunks/{PkStreamingMarkdown-ZasabxE0.js → PkStreamingMarkdown-BBvCtDlO.js} +2 -2
- package/dist-vue/_chunks/{PkStreamingMarkdown-ZasabxE0.js.map → PkStreamingMarkdown-BBvCtDlO.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolChatFile-CD26Q2xp.js → PkToolChatFile-DVhunkPS.js} +3 -3
- package/dist-vue/_chunks/{PkToolChatFile-CD26Q2xp.js.map → PkToolChatFile-DVhunkPS.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowArtifact-BhVd_ZQ8.js → PkToolShowArtifact-DKOTsP9C.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-BhVd_ZQ8.js.map → PkToolShowArtifact-DKOTsP9C.js.map} +1 -1
- package/dist-vue/_chunks/PkToolShowChart-CNBUjDc7.js +133 -0
- package/dist-vue/_chunks/PkToolShowChart-CNBUjDc7.js.map +1 -0
- package/dist-vue/_chunks/{PkToolShowContactForm-CackCDGD.js → PkToolShowContactForm-D1Ff15Zf.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-CackCDGD.js.map → PkToolShowContactForm-D1Ff15Zf.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-CABPsFi8.js → PkToolShowDiagram-CBwqjy6a.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-CABPsFi8.js.map → PkToolShowDiagram-CBwqjy6a.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-BStbk4Iu.js → PkToolShowForm-D-rzzwJa.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowForm-BStbk4Iu.js.map → PkToolShowForm-D-rzzwJa.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowImageGallery-BeeHsdTp.js → PkToolShowImageGallery-Cre2zSGV.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowImageGallery-BeeHsdTp.js.map → PkToolShowImageGallery-Cre2zSGV.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-BfUiap9U.js → PkToolShowProductList-D4FAfMS-.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-BfUiap9U.js.map → PkToolShowProductList-D4FAfMS-.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-CgEkcyRg.js → PkToolShowSources-BC6YJl-O.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSources-CgEkcyRg.js.map → PkToolShowSources-BC6YJl-O.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowVideo-CqSRnDNC.js → PkToolShowVideo-CxN7z_cZ.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowVideo-CqSRnDNC.js.map → PkToolShowVideo-CxN7z_cZ.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-B-qIS8qY.js → PkToolShowWebPages-0Ux6n8G1.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-B-qIS8qY.js.map → PkToolShowWebPages-0Ux6n8G1.js.map} +1 -1
- package/dist-vue/_chunks/chartFormat-B1T7y-16.js +27 -0
- package/dist-vue/_chunks/chartFormat-B1T7y-16.js.map +1 -0
- package/dist-vue/_chunks/{excelNumberFormat-C1sCQrOz.js → excelNumberFormat-BxRi0Y3e.js} +101 -88
- package/dist-vue/_chunks/excelNumberFormat-BxRi0Y3e.js.map +1 -0
- package/dist-vue/_chunks/{utils-KBB6SDPn.js → utils-C9l078yb.js} +10 -10
- package/dist-vue/_chunks/utils-C9l078yb.js.map +1 -0
- package/dist-vue/composables.js +9 -3
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/index.js +42 -42
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +6 -0
- package/dist-vue/packages/components/src/chat/PkChart.d.ts +8 -0
- package/dist-vue/packages/components/src/chat/PkFileChart.d.ts +14 -0
- package/dist-vue/packages/components/src/chat/PkWordPreviewRuns.d.ts +4 -1
- package/dist-vue/packages/components/src/chat/useChatFilePreview.d.ts +240 -0
- package/dist-vue/packages/components/src/chat/utils.d.ts +6 -1
- package/dist-vue/packages/models/src/schema/Chart.d.ts +91 -0
- package/dist-vue/packages/models/src/schema/SpreadsheetPreview.d.ts +381 -0
- package/dist-vue/packages/models/src/schema/WordPreview.d.ts +304 -0
- package/dist-vue/style.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/PkChart-CbtMRGWc.js.map +0 -1
- package/dist/_chunks/PkFilePreview-DC4iX7Yc.js +0 -1665
- package/dist/_chunks/PkFilePreview-DC4iX7Yc.js.map +0 -1
- package/dist/_chunks/PkToolShowChart-DZWu3Yuo.js +0 -224
- package/dist/_chunks/PkToolShowChart-DZWu3Yuo.js.map +0 -1
- package/dist/_chunks/excelNumberFormat-BhQjife9.js.map +0 -1
- package/dist/_chunks/utils-DMvy5QRR.js.map +0 -1
- package/dist-vue/_chunks/PkChart-D-K7nc0g.js.map +0 -1
- package/dist-vue/_chunks/PkFilePreview-k5gEl3n8.js.map +0 -1
- package/dist-vue/_chunks/PkToolShowChart-BQXxaPIO.js +0 -217
- package/dist-vue/_chunks/PkToolShowChart-BQXxaPIO.js.map +0 -1
- package/dist-vue/_chunks/excelNumberFormat-C1sCQrOz.js.map +0 -1
- package/dist-vue/_chunks/utils-KBB6SDPn.js.map +0 -1
package/dist-vue/PkChatbot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbot-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbot-CxkTubw8.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbotEmptyState-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbotEmptyState-CUoHkCgO.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbotInput-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbotInput-CPf7wqiQ.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbotMessages-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbotMessages-CLNu2dTm.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbotStepPayload-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbotStepPayload-Cf7mJPjL.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbotStepToolDetail-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbotStepToolDetail-D6nwNnHv.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbotSteps-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbotSteps-xkxdaX7O.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbotViewChat-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbotViewChat-BkkyjiFl.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./_chunks/PkChatbotViewConversations-
|
|
1
|
+
export { t as default } from "./_chunks/PkChatbotViewConversations-hgqSO1hx.js";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { S as e, _ as t, o as n, r, s as i, v as a } from "./schemas-BO5QlXAp.js";
|
|
2
|
+
// ../../packages/models/src/schema/Chart.ts
|
|
3
|
+
var o = [
|
|
4
|
+
"bar",
|
|
5
|
+
"line",
|
|
6
|
+
"pie",
|
|
7
|
+
"doughnut"
|
|
8
|
+
], s = [
|
|
9
|
+
"positive",
|
|
10
|
+
"warning",
|
|
11
|
+
"negative",
|
|
12
|
+
"critical",
|
|
13
|
+
"neutral"
|
|
14
|
+
], c = [
|
|
15
|
+
"number",
|
|
16
|
+
"percent",
|
|
17
|
+
"currency"
|
|
18
|
+
], l = {
|
|
19
|
+
maxCategories: 50,
|
|
20
|
+
maxSeries: 8,
|
|
21
|
+
maxSlices: 12,
|
|
22
|
+
maxCharts: 4
|
|
23
|
+
}, u = (e) => e === "pie" || e === "doughnut", d = 120, f = a({
|
|
24
|
+
name: e().min(1).max(d).describe("Series name, shown in the legend"),
|
|
25
|
+
values: n(t().nullable()).max(l.maxCategories).describe("One number per category, in the same order; null for none"),
|
|
26
|
+
tone: r(s).optional().describe("Only when the series means a judgement (e.g. high risk = negative): it takes that color")
|
|
27
|
+
}), p = a({
|
|
28
|
+
type: r(o).describe("bar to compare amounts, line for a trend over time, pie or doughnut for the shares of one whole"),
|
|
29
|
+
title: e().max(200).optional().describe("Short title above the chart"),
|
|
30
|
+
horizontal: i().optional().describe("bar only: categories on the vertical axis, for long labels"),
|
|
31
|
+
stacked: i().optional().describe("bar only: the series stacked into one bar per category"),
|
|
32
|
+
categories: n(e().max(d)).min(1).max(l.maxCategories, `At most ${l.maxCategories} categories: group the smallest ones.`).describe("The labels of the x axis (or of the slices), in display order"),
|
|
33
|
+
series: n(f).min(1).max(l.maxSeries, `At most ${l.maxSeries} series.`).describe("One or more named series; exactly one for pie or doughnut"),
|
|
34
|
+
valueLabel: e().max(d).optional().describe("What the numbers measure, with the unit (e.g. \"Clienti\")"),
|
|
35
|
+
categoryLabel: e().max(d).optional().describe("What the categories are (e.g. \"Fascia di rating\")"),
|
|
36
|
+
format: r(c).optional().describe("How values read: percent means 0.25 is 25%, currency is in euro")
|
|
37
|
+
}), m = p.superRefine((e, t) => {
|
|
38
|
+
let { type: n, categories: r, series: i } = e, a = (e, n) => t.addIssue({
|
|
39
|
+
code: "custom",
|
|
40
|
+
message: e,
|
|
41
|
+
path: n
|
|
42
|
+
});
|
|
43
|
+
i.forEach((e, t) => {
|
|
44
|
+
e.values.length !== r.length && a(`Series "${e.name}" has ${e.values.length} values for ${r.length} categories: give one value per category.`, [
|
|
45
|
+
"series",
|
|
46
|
+
t,
|
|
47
|
+
"values"
|
|
48
|
+
]), e.values.every((e) => e === null) && a(`Series "${e.name}" has no values: leave it out, or give its numbers.`, [
|
|
49
|
+
"series",
|
|
50
|
+
t,
|
|
51
|
+
"values"
|
|
52
|
+
]);
|
|
53
|
+
}), u(n) && (i.length !== 1 && a(`A ${n} chart has exactly one series: ${i.length} given. Use a bar chart to compare several.`, ["series"]), r.length > l.maxSlices && a(`${r.length} slices: at most ${l.maxSlices} in a ${n}. Group the smallest into one, or use a bar chart.`, ["categories"]), i[0]?.values.some((e) => e !== null && e < 0) ? a(`A ${n} chart cannot show negative values.`, [
|
|
54
|
+
"series",
|
|
55
|
+
0,
|
|
56
|
+
"values"
|
|
57
|
+
]) : i[0]?.values.some((e) => e !== null) && !i[0].values.some((e) => e !== null && e > 0) && a(`A ${n} chart needs at least one value above zero: every slice is empty.`, [
|
|
58
|
+
"series",
|
|
59
|
+
0,
|
|
60
|
+
"values"
|
|
61
|
+
]));
|
|
62
|
+
}), h = a({
|
|
63
|
+
charts: n(m).min(1).max(l.maxCharts).describe("Every chart the user asked for, one entry each (e.g. a pie and a bar chart of the same numbers)"),
|
|
64
|
+
caption: e().max(500).optional().describe("Optional note below the charts, e.g. the source")
|
|
65
|
+
}), g = {
|
|
66
|
+
maxCategories: 500,
|
|
67
|
+
maxSeries: 24
|
|
68
|
+
}, _ = p.extend({
|
|
69
|
+
categories: n(e().max(d)).min(1).max(g.maxCategories),
|
|
70
|
+
series: n(f.extend({
|
|
71
|
+
name: e().max(d),
|
|
72
|
+
values: n(t().nullable()).max(g.maxCategories)
|
|
73
|
+
})).min(1).max(g.maxSeries)
|
|
74
|
+
}), v = a({
|
|
75
|
+
chart: _.optional(),
|
|
76
|
+
colors: n(e()).optional(),
|
|
77
|
+
legend: r([
|
|
78
|
+
"top",
|
|
79
|
+
"bottom",
|
|
80
|
+
"left",
|
|
81
|
+
"right"
|
|
82
|
+
]).optional(),
|
|
83
|
+
title: e().max(200).optional()
|
|
84
|
+
});
|
|
85
|
+
export { h as n, u as r, v as t };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=Chart-DsBNs5rS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chart-DsBNs5rS.js","names":["z.object","z.string","z.array","z.number","z.enum","z.boolean","string","number","array","boolean","object","CHART_TYPES","CHART_TONES","CHART_FORMATS","CHART_LIMITS","isRoundChart","type","LABEL_MAX","ChartSeriesSchema","_enum","ChartFieldsSchema","ChartSchema","chart","issue","ctx","series","s","categories","i","v","ShowChartInputSchema","FILE_CHART_LIMITS","FileChartSchema","PreviewChartSchema"],"sources":["../../../../packages/models/src/schema/Chart.ts"],"sourcesContent":["import * as z from 'zod'\nimport { AgentBuiltInTool } from './Agent'\n\n// A chart as the model describes it (spec `chat-charts.md`): categories and\n// named series of numbers, no colors or code. `showChart` draws it in the\n// chat; the Excel and Word files the agent creates write the same shape as a\n// native Office chart.\n\nexport const CHART_TYPES = ['bar', 'line', 'pie', 'doughnut'] as const\nexport type ChartType = (typeof CHART_TYPES)[number]\n\n/** The meaning a series' color carries, drawn with the semantic colors. */\nexport const CHART_TONES = [\n 'positive',\n 'warning',\n 'negative',\n 'critical',\n 'neutral',\n] as const\nexport type ChartTone = (typeof CHART_TONES)[number]\n\nexport const CHART_FORMATS = ['number', 'percent', 'currency'] as const\nexport type ChartFormat = (typeof CHART_FORMATS)[number]\n\nexport const CHART_LIMITS = {\n maxCategories: 50,\n maxSeries: 8,\n /** Slices of a pie or a doughnut: more do not read. */\n maxSlices: 12,\n /** Charts in one `showChart` call. */\n maxCharts: 4,\n} as const\n\n/**\n * The agent can draw a chart in the chat: with `showChart`, or with the\n * Mermaid XY chart of `showDiagram` when it has not got the first. What the\n * \"Make a chart\" selection action needs.\n */\nexport const hasChatChartTool = (\n disabledTools: readonly AgentBuiltInTool[],\n): boolean =>\n !disabledTools.includes(AgentBuiltInTool.ShowChart) ||\n !disabledTools.includes(AgentBuiltInTool.ShowDiagram)\n\n/** A pie or a doughnut: one series, its values the slices. */\nexport const isRoundChart = (type: ChartType): boolean =>\n type === 'pie' || type === 'doughnut'\n\n/** Labels short enough for a legend, an axis and a slice. */\nconst LABEL_MAX = 120\n\nexport const ChartSeriesSchema = z.object({\n name: z\n .string()\n .min(1)\n .max(LABEL_MAX)\n .describe('Series name, shown in the legend'),\n values: z\n .array(z.number().nullable())\n .max(CHART_LIMITS.maxCategories)\n .describe('One number per category, in the same order; null for none'),\n tone: z\n .enum(CHART_TONES)\n .optional()\n .describe(\n 'Only when the series means a judgement (e.g. high risk = negative): it takes that color',\n ),\n})\nexport type ChartSeries = z.infer<typeof ChartSeriesSchema>\n\n/**\n * The fields of a chart, without the checks across them: the schema a tool\n * extends before {@link refineChart} adds those checks.\n */\nexport const ChartFieldsSchema = z.object({\n type: z\n .enum(CHART_TYPES)\n .describe(\n 'bar to compare amounts, line for a trend over time, pie or doughnut for the shares of one whole',\n ),\n title: z\n .string()\n .max(200)\n .optional()\n .describe('Short title above the chart'),\n horizontal: z\n .boolean()\n .optional()\n .describe('bar only: categories on the vertical axis, for long labels'),\n stacked: z\n .boolean()\n .optional()\n .describe('bar only: the series stacked into one bar per category'),\n // The limits in the schema, so the model reads them before it writes\n categories: z\n .array(z.string().max(LABEL_MAX))\n .min(1)\n .max(\n CHART_LIMITS.maxCategories,\n `At most ${CHART_LIMITS.maxCategories} categories: group the smallest ones.`,\n )\n .describe(\n 'The labels of the x axis (or of the slices), in display order',\n ),\n series: z\n .array(ChartSeriesSchema)\n .min(1)\n .max(\n CHART_LIMITS.maxSeries,\n `At most ${CHART_LIMITS.maxSeries} series.`,\n )\n .describe('One or more named series; exactly one for pie or doughnut'),\n valueLabel: z\n .string()\n .max(LABEL_MAX)\n .optional()\n .describe('What the numbers measure, with the unit (e.g. \"Clienti\")'),\n categoryLabel: z\n .string()\n .max(LABEL_MAX)\n .optional()\n .describe('What the categories are (e.g. \"Fascia di rating\")'),\n format: z\n .enum(CHART_FORMATS)\n .optional()\n .describe(\n 'How values read: percent means 0.25 is 25%, currency is in euro',\n ),\n})\n\n/**\n * The checks JSON Schema cannot state, worded for the model that wrote the\n * chart: it reads the message and calls again.\n */\nexport const refineChart = (\n chart: z.infer<typeof ChartFieldsSchema>,\n ctx: z.RefinementCtx,\n) => {\n const { type, categories, series } = chart\n const issue = (message: string, path: (string | number)[]) =>\n ctx.addIssue({ code: 'custom', message, path })\n series.forEach((s, i) => {\n if (s.values.length !== categories.length) {\n issue(\n `Series \"${s.name}\" has ${s.values.length} values for ${categories.length} categories: give one value per category.`,\n ['series', i, 'values'],\n )\n }\n if (s.values.every((v) => v === null)) {\n issue(\n `Series \"${s.name}\" has no values: leave it out, or give its numbers.`,\n ['series', i, 'values'],\n )\n }\n })\n if (isRoundChart(type)) {\n if (series.length !== 1) {\n issue(\n `A ${type} chart has exactly one series: ${series.length} given. Use a bar chart to compare several.`,\n ['series'],\n )\n }\n if (categories.length > CHART_LIMITS.maxSlices) {\n issue(\n `${categories.length} slices: at most ${CHART_LIMITS.maxSlices} in a ${type}. Group the smallest into one, or use a bar chart.`,\n ['categories'],\n )\n }\n if (series[0]?.values.some((v) => v !== null && v < 0)) {\n issue(`A ${type} chart cannot show negative values.`, [\n 'series',\n 0,\n 'values',\n ])\n } else if (\n series[0]?.values.some((v) => v !== null) &&\n !series[0].values.some((v) => v !== null && v > 0)\n ) {\n issue(\n `A ${type} chart needs at least one value above zero: every slice is empty.`,\n ['series', 0, 'values'],\n )\n }\n }\n}\n\nexport const ChartSchema = ChartFieldsSchema.superRefine(refineChart)\nexport type Chart = z.infer<typeof ChartSchema>\n\n/**\n * The input of `showChart`: every chart the user asked for in one call. A\n * presentation tool ends the turn, and a model that calls one chart at a\n * time (GPT-6.1 Sol, asked for a pie and a bar chart, drew the pie only)\n * would never draw the second.\n */\nexport const ShowChartInputSchema = z.object({\n charts: z\n .array(ChartSchema)\n .min(1)\n .max(CHART_LIMITS.maxCharts)\n .describe(\n 'Every chart the user asked for, one entry each (e.g. a pie and a bar chart of the same numbers)',\n ),\n caption: z\n .string()\n .max(500)\n .optional()\n .describe('Optional note below the charts, e.g. the source'),\n})\nexport type ShowChartInput = z.infer<typeof ShowChartInputSchema>\n\n/**\n * A chart read from an Excel or a Word file holds as many points as the file\n * does: a year of days is a line chart. Past these the viewer leaves it\n * undrawn.\n */\nexport const FILE_CHART_LIMITS = {\n maxCategories: 500,\n maxSeries: 24,\n} as const\n\n/**\n * The chart the viewer draws from a file (spec `chat-charts.md`, F4): the\n * fields of {@link ChartFieldsSchema}, as many points as\n * {@link FILE_CHART_LIMITS} allows, and a series the file leaves unnamed.\n */\nexport const FileChartSchema = ChartFieldsSchema.extend({\n categories: z\n .array(z.string().max(LABEL_MAX))\n .min(1)\n .max(FILE_CHART_LIMITS.maxCategories),\n series: z\n .array(\n ChartSeriesSchema.extend({\n /** Empty where the file names none: the viewer numbers it. */\n name: z.string().max(LABEL_MAX),\n values: z\n .array(z.number().nullable())\n .max(FILE_CHART_LIMITS.maxCategories),\n }),\n )\n .min(1)\n .max(FILE_CHART_LIMITS.maxSeries),\n})\nexport type FileChart = z.infer<typeof FileChartSchema>\n\n/**\n * A chart of a file in the viewer: drawn with the file's colors and legend,\n * or, for a kind the chat cannot draw (area, scatter, a combination), a\n * placeholder named by its title.\n */\nexport const PreviewChartSchema = z.object({\n chart: FileChartSchema.optional(),\n /** `#rrggbb`: one per series, or one per slice of a pie or a doughnut. */\n colors: z.array(z.string()).optional(),\n /** Where the file puts the legend; none when it has none. */\n legend: z.enum(['top', 'bottom', 'left', 'right']).optional(),\n /** The title of a chart the viewer does not draw. */\n title: z.string().max(200).optional(),\n})\nexport type PreviewChart = z.infer<typeof PreviewChartSchema>\n"],"mappings":";;AAQA,IAAaW,IAAc;CAAC;CAAO;CAAQ;CAAO;AAAU,GAI/CC,IAAc;CACvB;CACA;CACA;CACA;CACA;AACJ,GAGaC,IAAgB;CAAC;CAAU;CAAW;AAAU,GAGhDC,IAAe;CACxB,eAAe;CACf,WAAW;CAEX,WAAW;CAEX,WAAW;AACf,GAcaC,KAAgB,MACzBC,MAAS,SAASA,MAAS,YAGzBC,IAAY,KAELC,IAAoBlB,EAAS;CACtC,MAAMC,EACM,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAIgB,CAAS,CAAC,CACd,SAAS,kCAAkC;CAChD,QAAQf,EACGC,EAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAC5B,IAAIW,EAAa,aAAa,CAAC,CAC/B,SAAS,2DAA2D;CACzE,MAAMV,EACIQ,CAAW,CAAC,CACjB,SAAS,CAAC,CACV,SACG,yFACJ;AACR,CAAC,GAOYQ,IAAoBpB,EAAS;CACtC,MAAMI,EACIO,CAAW,CAAC,CACjB,SACG,iGACJ;CACJ,OAAOV,EACK,CAAC,CACR,IAAI,GAAG,CAAC,CACR,SAAS,CAAC,CACV,SAAS,6BAA6B;CAC3C,YAAYI,EACC,CAAC,CACT,SAAS,CAA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AAC;EAAO;EAAU;EAAQ;CAAO,CAAC,CAAC,CAAC,SAAS;CAE5D,OAAOH,EAAS,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS;AACxC,CAAC"}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as e } from "./Chart-DsBNs5rS.js";
|
|
2
|
+
import { n as t } from "./chartFormat-B1T7y-16.js";
|
|
2
3
|
import { createElementBlock as n, createElementVNode as r, defineComponent as i, nextTick as a, onBeforeUnmount as o, onMounted as s, openBlock as c, useTemplateRef as l, watch as u } from "vue";
|
|
3
4
|
import { useI18n as d } from "vue-i18n";
|
|
4
|
-
import { ArcElement as f, BarController as p, BarElement as m, CategoryScale as h, Chart as g, DoughnutController as _, Legend as v, LineController as y, LineElement as b, LinearScale as x, PieController as S, PointElement as C,
|
|
5
|
+
import { ArcElement as f, BarController as p, BarElement as m, CategoryScale as h, Chart as g, DoughnutController as _, Legend as v, LineController as y, LineElement as b, LinearScale as x, PieController as S, PointElement as C, Title as w, Tooltip as T } from "chart.js";
|
|
5
6
|
// ../../packages/composable/src/cssColor.ts
|
|
6
|
-
var
|
|
7
|
-
function
|
|
7
|
+
var E, D = () => typeof CSS < "u" && CSS.supports("color", "color(from red xyz-d65 x y z)") && CSS.supports("color", "color-mix(in srgb, red 50%, blue)"), O = (e) => Math.round(Math.min(1, Math.max(0, Number(e))) * 255);
|
|
8
|
+
function k(e) {
|
|
8
9
|
let t = e.match(/^color\(srgb (\S+) (\S+) (\S+)(?: \/ (\S+))?\)$/);
|
|
9
10
|
return t ? {
|
|
10
|
-
r:
|
|
11
|
-
g:
|
|
12
|
-
b:
|
|
11
|
+
r: O(t[1]),
|
|
12
|
+
g: O(t[2]),
|
|
13
|
+
b: O(t[3]),
|
|
13
14
|
a: t[4] === void 0 ? 1 : Number(t[4])
|
|
14
15
|
} : null;
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
if (
|
|
17
|
+
function A(e) {
|
|
18
|
+
if (E ??= document.createElement("canvas").getContext("2d", { willReadFrequently: !0 }), !E) return {
|
|
18
19
|
r: 0,
|
|
19
20
|
g: 0,
|
|
20
21
|
b: 0,
|
|
21
22
|
a: 1
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
-
let [t, n, r, i] =
|
|
24
|
+
E.clearRect(0, 0, 1, 1), E.fillStyle = e, E.fillRect(0, 0, 1, 1);
|
|
25
|
+
let [t, n, r, i] = E.getImageData(0, 0, 1, 1).data;
|
|
25
26
|
return {
|
|
26
27
|
r: t,
|
|
27
28
|
g: n,
|
|
@@ -29,53 +30,56 @@ function k(e) {
|
|
|
29
30
|
a: Math.round(i / 255 * 1e3) / 1e3
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
+
function j(e, t) {
|
|
33
34
|
e.style.color = `color-mix(in srgb, ${t} 100%, transparent)`;
|
|
34
35
|
let n = getComputedStyle(e).color;
|
|
35
|
-
return
|
|
36
|
+
return k(n) ?? A(n);
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
+
function M(e, t) {
|
|
38
39
|
let n = document.createElement("span");
|
|
39
40
|
n.setAttribute("aria-hidden", "true"), n.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none", e.append(n);
|
|
40
41
|
try {
|
|
41
|
-
return t.map((e) =>
|
|
42
|
+
return t.map((e) => j(n, e));
|
|
42
43
|
} finally {
|
|
43
44
|
n.remove();
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
|
-
var
|
|
47
|
+
var N = ({ r: e, g: t, b: n }) => `#${[
|
|
47
48
|
e,
|
|
48
49
|
t,
|
|
49
50
|
n
|
|
50
|
-
].map((e) => e.toString(16).padStart(2, "0")).join("")}`,
|
|
51
|
+
].map((e) => e.toString(16).padStart(2, "0")).join("")}`, P = ["aria-label"], F = /* @__PURE__ */ i({
|
|
51
52
|
__name: "PkChart",
|
|
52
53
|
props: {
|
|
53
54
|
chart: {},
|
|
54
|
-
isDark: { type: Boolean }
|
|
55
|
+
isDark: { type: Boolean },
|
|
56
|
+
paper: { type: Boolean },
|
|
57
|
+
colors: {},
|
|
58
|
+
legend: {}
|
|
55
59
|
},
|
|
56
|
-
setup(i, { expose:
|
|
57
|
-
g.register(f, p, m, h, _, v, x, y, b, S, C, w);
|
|
58
|
-
let
|
|
60
|
+
setup(i, { expose: E }) {
|
|
61
|
+
g.register(f, p, m, h, _, v, x, y, b, S, C, w, T);
|
|
62
|
+
let O = i, { locale: k, t: A } = d({ useScope: "global" }), j = l("root"), F = l("canvas"), I, L = [
|
|
59
63
|
"accent",
|
|
60
64
|
"brand",
|
|
61
65
|
"info"
|
|
62
|
-
],
|
|
66
|
+
], R = [
|
|
63
67
|
[100, "surface"],
|
|
64
68
|
[55, "surface"],
|
|
65
69
|
[70, "word"],
|
|
66
70
|
[30, "surface"]
|
|
67
|
-
].flatMap(([e, t]) =>
|
|
71
|
+
].flatMap(([e, t]) => L.map((n) => e === 100 ? `var(--color-${n}-graphic)` : `color-mix(in srgb, var(--color-${n}-graphic) ${e}%, var(--color-${t}))`)), z = {
|
|
68
72
|
positive: "var(--color-success-graphic)",
|
|
69
73
|
warning: "var(--color-warning-graphic)",
|
|
70
74
|
negative: "var(--color-danger-graphic)",
|
|
71
75
|
critical: "color-mix(in srgb, var(--color-danger-graphic) 60%, var(--color-word))",
|
|
72
76
|
neutral: "color-mix(in srgb, var(--color-word) 35%, var(--color-surface))"
|
|
73
|
-
},
|
|
77
|
+
}, B = [
|
|
74
78
|
"var(--color-word-2)",
|
|
75
79
|
"var(--color-word-3)",
|
|
76
80
|
"var(--color-surface-3)",
|
|
77
81
|
"var(--color-surface)"
|
|
78
|
-
],
|
|
82
|
+
], V = (e) => ({
|
|
79
83
|
categorical: [
|
|
80
84
|
"#9365ff",
|
|
81
85
|
"#004775",
|
|
@@ -97,13 +101,26 @@ var M = ({ r: e, g: t, b: n }) => `#${[
|
|
|
97
101
|
tick: e ? "#9ca3af" : "#6b7280",
|
|
98
102
|
grid: e ? "#374151" : "#f3f4f6",
|
|
99
103
|
surface: e ? "#1f2937" : "#ffffff"
|
|
100
|
-
}),
|
|
101
|
-
|
|
104
|
+
}), H = {
|
|
105
|
+
text: "#595959",
|
|
106
|
+
tick: "#595959",
|
|
107
|
+
grid: "#d9d9d9",
|
|
108
|
+
surface: "#ffffff"
|
|
109
|
+
}, U = () => {
|
|
110
|
+
if (O.paper) {
|
|
111
|
+
let e = V(!1);
|
|
112
|
+
return {
|
|
113
|
+
...e,
|
|
114
|
+
...H,
|
|
115
|
+
categorical: O.colors?.length ? O.colors : e.categorical
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (!D()) return V(!!O.isDark);
|
|
102
119
|
let e = [
|
|
103
|
-
...
|
|
104
|
-
...Object.values(
|
|
105
|
-
...
|
|
106
|
-
], t = j
|
|
120
|
+
...R,
|
|
121
|
+
...Object.values(z),
|
|
122
|
+
...B
|
|
123
|
+
], t = M(j.value, e).map(N), n = t.slice(0, R.length), r = Object.fromEntries(Object.keys(z).map((e, n) => [e, t[R.length + n]])), [i, a, o, s] = t.slice(-B.length);
|
|
107
124
|
return {
|
|
108
125
|
categorical: n,
|
|
109
126
|
tones: r,
|
|
@@ -112,41 +129,42 @@ var M = ({ r: e, g: t, b: n }) => `#${[
|
|
|
112
129
|
grid: o,
|
|
113
130
|
surface: s
|
|
114
131
|
};
|
|
115
|
-
},
|
|
116
|
-
let { chart: n } =
|
|
117
|
-
family: getComputedStyle(
|
|
132
|
+
}, W = () => {
|
|
133
|
+
let { chart: n } = O, r = U(), i = {
|
|
134
|
+
family: getComputedStyle(j.value).fontFamily,
|
|
118
135
|
size: 11
|
|
119
|
-
}, a =
|
|
136
|
+
}, a = t(k.value, n.format), o = window.matchMedia("(prefers-reduced-motion: reduce)").matches, s = e(n.type), c = !!O.paper, l = 0, u = n.series.map((e, t) => {
|
|
137
|
+
let i = e.name || A("chart.series", { n: t + 1 });
|
|
120
138
|
if (s) return {
|
|
121
|
-
label:
|
|
139
|
+
label: i,
|
|
122
140
|
data: e.values,
|
|
123
141
|
backgroundColor: n.categories.map((e, t) => r.categorical[t % r.categorical.length]),
|
|
124
142
|
borderColor: r.surface,
|
|
125
143
|
borderWidth: 2
|
|
126
144
|
};
|
|
127
|
-
let
|
|
145
|
+
let a = e.tone ? r.tones[e.tone] : r.categorical[l++ % r.categorical.length];
|
|
128
146
|
return n.type === "line" ? {
|
|
129
|
-
label:
|
|
147
|
+
label: i,
|
|
130
148
|
data: e.values,
|
|
131
|
-
borderColor:
|
|
132
|
-
backgroundColor:
|
|
149
|
+
borderColor: a,
|
|
150
|
+
backgroundColor: a,
|
|
133
151
|
borderWidth: 2,
|
|
134
152
|
pointRadius: 3,
|
|
135
|
-
cubicInterpolationMode: "monotone",
|
|
153
|
+
cubicInterpolationMode: c ? "default" : "monotone",
|
|
136
154
|
spanGaps: !1
|
|
137
155
|
} : {
|
|
138
|
-
label:
|
|
156
|
+
label: i,
|
|
139
157
|
data: e.values,
|
|
140
|
-
backgroundColor:
|
|
141
|
-
borderRadius: 3,
|
|
142
|
-
maxBarThickness: 48
|
|
158
|
+
backgroundColor: a,
|
|
159
|
+
borderRadius: c ? 0 : 3,
|
|
160
|
+
maxBarThickness: c ? void 0 : 48
|
|
143
161
|
};
|
|
144
|
-
}),
|
|
162
|
+
}), d = (e) => ({
|
|
145
163
|
display: !!e,
|
|
146
164
|
text: e ?? "",
|
|
147
165
|
color: r.tick,
|
|
148
166
|
font: i
|
|
149
|
-
}),
|
|
167
|
+
}), f = {
|
|
150
168
|
beginAtZero: !0,
|
|
151
169
|
stacked: !!n.stacked,
|
|
152
170
|
ticks: {
|
|
@@ -159,8 +177,8 @@ var M = ({ r: e, g: t, b: n }) => `#${[
|
|
|
159
177
|
drawTicks: !1
|
|
160
178
|
},
|
|
161
179
|
border: { display: !1 },
|
|
162
|
-
title:
|
|
163
|
-
},
|
|
180
|
+
title: d(n.valueLabel)
|
|
181
|
+
}, p = {
|
|
164
182
|
stacked: !!n.stacked,
|
|
165
183
|
ticks: {
|
|
166
184
|
color: r.tick,
|
|
@@ -169,31 +187,45 @@ var M = ({ r: e, g: t, b: n }) => `#${[
|
|
|
169
187
|
},
|
|
170
188
|
grid: { display: !1 },
|
|
171
189
|
border: { display: !1 },
|
|
172
|
-
title:
|
|
173
|
-
},
|
|
190
|
+
title: d(n.categoryLabel)
|
|
191
|
+
}, m = n.type === "bar" && !!n.horizontal;
|
|
174
192
|
return {
|
|
175
193
|
type: n.type,
|
|
176
194
|
data: {
|
|
177
195
|
labels: n.categories,
|
|
178
|
-
datasets:
|
|
196
|
+
datasets: u
|
|
179
197
|
},
|
|
180
198
|
options: {
|
|
181
199
|
responsive: !0,
|
|
182
200
|
maintainAspectRatio: !1,
|
|
183
201
|
animation: !o && { duration: 400 },
|
|
184
|
-
indexAxis:
|
|
202
|
+
indexAxis: m ? "y" : "x",
|
|
185
203
|
...s && { cutout: n.type === "doughnut" ? "55%" : 0 },
|
|
186
|
-
scales: s ? {} :
|
|
187
|
-
x: d,
|
|
188
|
-
y: f
|
|
189
|
-
} : {
|
|
204
|
+
scales: s ? {} : m ? {
|
|
190
205
|
x: f,
|
|
191
|
-
y:
|
|
206
|
+
y: p
|
|
207
|
+
} : {
|
|
208
|
+
x: p,
|
|
209
|
+
y: f
|
|
192
210
|
},
|
|
193
211
|
plugins: {
|
|
212
|
+
title: {
|
|
213
|
+
display: c && !!n.title,
|
|
214
|
+
text: n.title ?? "",
|
|
215
|
+
color: r.text,
|
|
216
|
+
font: {
|
|
217
|
+
...i,
|
|
218
|
+
size: 14,
|
|
219
|
+
weight: "normal"
|
|
220
|
+
},
|
|
221
|
+
padding: {
|
|
222
|
+
top: 4,
|
|
223
|
+
bottom: 8
|
|
224
|
+
}
|
|
225
|
+
},
|
|
194
226
|
legend: {
|
|
195
|
-
display: s || n.series.length > 1,
|
|
196
|
-
position: "bottom",
|
|
227
|
+
display: c ? !!O.legend : s || n.series.length > 1,
|
|
228
|
+
position: c && O.legend || "bottom",
|
|
197
229
|
labels: {
|
|
198
230
|
color: r.text,
|
|
199
231
|
font: i,
|
|
@@ -206,7 +238,7 @@ var M = ({ r: e, g: t, b: n }) => `#${[
|
|
|
206
238
|
tooltip: { callbacks: { label: (e) => {
|
|
207
239
|
let t = Number(e.raw);
|
|
208
240
|
if (!s) return `${e.dataset.label}: ${a(t)}`;
|
|
209
|
-
let n = e.dataset.data.filter((e) => typeof e == "number").reduce((e, t) => e + t, 0), r = n ? new Intl.NumberFormat(
|
|
241
|
+
let n = e.dataset.data.filter((e) => typeof e == "number").reduce((e, t) => e + t, 0), r = n ? new Intl.NumberFormat(k.value, {
|
|
210
242
|
style: "percent",
|
|
211
243
|
maximumFractionDigits: 1
|
|
212
244
|
}).format(t / n) : "";
|
|
@@ -215,29 +247,35 @@ var M = ({ r: e, g: t, b: n }) => `#${[
|
|
|
215
247
|
}
|
|
216
248
|
}
|
|
217
249
|
};
|
|
218
|
-
},
|
|
219
|
-
await a(),
|
|
250
|
+
}, G = async () => {
|
|
251
|
+
await a(), F.value && j.value && (I?.destroy(), I = new g(F.value, W()));
|
|
220
252
|
};
|
|
221
|
-
return
|
|
222
|
-
if (!
|
|
253
|
+
return E({ toBlob: async () => {
|
|
254
|
+
if (!F.value || !j.value) return null;
|
|
223
255
|
let e = document.createElement("canvas");
|
|
224
|
-
e.width =
|
|
256
|
+
e.width = F.value.width, e.height = F.value.height;
|
|
225
257
|
let t = e.getContext("2d");
|
|
226
|
-
return t ? (t.fillStyle =
|
|
227
|
-
} }), s(
|
|
228
|
-
|
|
258
|
+
return t ? (t.fillStyle = U().surface, t.fillRect(0, 0, e.width, e.height), t.drawImage(F.value, 0, 0), new Promise((t) => e.toBlob(t, "image/png"))) : null;
|
|
259
|
+
} }), s(G), u(() => JSON.stringify([
|
|
260
|
+
O.isDark,
|
|
261
|
+
O.paper,
|
|
262
|
+
O.legend,
|
|
263
|
+
O.colors,
|
|
264
|
+
O.chart
|
|
265
|
+
]), G), o(() => {
|
|
266
|
+
I?.destroy(), I = void 0;
|
|
229
267
|
}), (e, t) => (c(), n("div", {
|
|
230
268
|
ref_key: "root",
|
|
231
|
-
ref:
|
|
269
|
+
ref: j,
|
|
232
270
|
class: "pk-chart"
|
|
233
271
|
}, [r("canvas", {
|
|
234
272
|
ref_key: "canvas",
|
|
235
|
-
ref:
|
|
273
|
+
ref: F,
|
|
236
274
|
role: "img",
|
|
237
275
|
"aria-label": i.chart.title || i.chart.series.map((e) => e.name).join(", ")
|
|
238
|
-
}, null, 8,
|
|
276
|
+
}, null, 8, P)], 512));
|
|
239
277
|
}
|
|
240
278
|
});
|
|
241
|
-
export {
|
|
279
|
+
export { F as default };
|
|
242
280
|
|
|
243
|
-
//# sourceMappingURL=PkChart-
|
|
281
|
+
//# sourceMappingURL=PkChart-CrZqhEpp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PkChart-CrZqhEpp.js","names":["ChartJS","_openBlock","_createElementBlock","_createElementVNode","_sfc_main","isRoundChart","chartValueFormatter","pixel","supportsColorRoles","channel","value","parseSrgb","match","computed","parseOnCanvas","r","g","b","a","readColor","expression","probe","resolveCssColorsIn","element","expressions","hexString","_hoisted_1","PkChart_default","defineComponent","__expose","ArcElement","BarController","BarElement","CategoryScale","DoughnutController","Legend","LinearScale","LineController","LineElement","PieController","PointElement","Title","Tooltip","props","__props","$t","useI18n","root","useTemplateRef","canvas","instance","ROLES","CATEGORICAL","strength","toward","role","TONES","INK","fallbackColors","dark","OFFICE_INK","readColors","light","hex","categorical","tones","tone","i","text","tick","grid","surface","configuration","colors","font","format","locale","chart","reducedMotion","round","paper","untoned","datasets","label","series","index","color","axisTitle","valueAxis","categoryAxis","horizontal","item","total","v","sum","share","draw","nextTick","Chart","copy","context","resolve","onMounted","watch","onBeforeUnmount","openBlock","createElementBlock","createElementVNode","s"],"sources":["../../../../packages/composable/src/cssColor.ts","../../../../packages/components/src/chat/PkChart.vue","../../../../packages/components/src/chat/PkChart.vue"],"sourcesContent":["/** A color as a canvas draws it: channels 0-255, alpha 0-1. */\nexport type RgbaColor = { r: number; g: number; b: number; a: number }\n\nlet scopes: Record<'light' | 'dark', HTMLElement> | undefined\nlet pixel: CanvasRenderingContext2D | null | undefined\nlet memoRevision = ''\nconst memo = new Map<string, RgbaColor>()\n\n/**\n * Whether this browser computes the color roles of the design system, which\n * derive from the palette with the relative color syntax and `color-mix()`.\n */\nexport const supportsColorRoles = () =>\n typeof CSS !== 'undefined' &&\n CSS.supports('color', 'color(from red xyz-d65 x y z)') &&\n CSS.supports('color', 'color-mix(in srgb, red 50%, blue)')\n\n/**\n * A hidden element per theme, with the classes that pin it: the colors of a\n * theme resolve inside it whatever the document's own theme is at that\n * moment, which during a switch is not yet the one being drawn.\n */\nfunction scopeOf(theme: 'light' | 'dark') {\n if (!scopes) {\n const make = (name: 'light' | 'dark') => {\n const element = document.createElement('span')\n element.className = `theme theme--${name}`\n element.setAttribute('aria-hidden', 'true')\n element.style.cssText =\n 'position:fixed;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none'\n document.body.append(element)\n return element\n }\n scopes = { light: make('light'), dark: make('dark') }\n }\n return scopes[theme]\n}\n\nconst channel = (value: string) =>\n Math.round(Math.min(1, Math.max(0, Number(value))) * 255)\n\n/** `color(srgb r g b / a)`, the form a color mixed in sRGB computes to. */\nfunction parseSrgb(computed: string): RgbaColor | null {\n const match = computed.match(\n /^color\\(srgb (\\S+) (\\S+) (\\S+)(?: \\/ (\\S+))?\\)$/,\n )\n if (!match) {\n return null\n }\n return {\n r: channel(match[1]),\n g: channel(match[2]),\n b: channel(match[3]),\n a: match[4] === undefined ? 1 : Number(match[4]),\n }\n}\n\n/** Any other form the browser computed, read back from one pixel. */\nfunction parseOnCanvas(computed: string): RgbaColor {\n pixel ??= document\n .createElement('canvas')\n .getContext('2d', { willReadFrequently: true })\n if (!pixel) {\n return { r: 0, g: 0, b: 0, a: 1 }\n }\n pixel.clearRect(0, 0, 1, 1)\n pixel.fillStyle = computed\n pixel.fillRect(0, 0, 1, 1)\n const [r, g, b, a] = pixel.getImageData(0, 0, 1, 1).data\n return { r, g, b, a: Math.round((a / 255) * 1000) / 1000 }\n}\n\n/**\n * The color a CSS expression (`var(--color-accent-graphic)`, a `color-mix()`)\n * resolves to in a theme, in channels a canvas understands. Chart.js draws on\n * a canvas, which reads no custom property, and the design system derives its\n * roles in XYZ with the relative color syntax: the expression is mixed into\n * sRGB first, so the browser hands it back as `color(srgb ...)`.\n *\n * Results are kept while `revision` stays the same: the caller passes what\n * changes the colors, the theme's version and its stylesheet.\n */\nexport function resolveCssColor(\n expression: string,\n theme: 'light' | 'dark',\n revision: string,\n): RgbaColor {\n if (revision !== memoRevision) {\n memo.clear()\n memoRevision = revision\n }\n const id = `${theme}|${expression}`\n const known = memo.get(id)\n if (known) {\n return known\n }\n const color = readColor(scopeOf(theme), expression)\n memo.set(id, color)\n return color\n}\n\n/** The expression mixed into sRGB on `probe`, read back as channels. */\nfunction readColor(probe: HTMLElement, expression: string): RgbaColor {\n probe.style.color = `color-mix(in srgb, ${expression} 100%, transparent)`\n const computed = getComputedStyle(probe).color\n return parseSrgb(computed) ?? parseOnCanvas(computed)\n}\n\n/**\n * The colors of CSS expressions as they resolve inside `element`, with the\n * theme and the custom properties that reach it there. In the widget that is\n * its shadow root, which the theme scopes of {@link resolveCssColor}, on the\n * document's body, never see. Nothing is memoized: the caller reads again\n * when the theme changes.\n */\nexport function resolveCssColorsIn(\n element: Element,\n expressions: readonly string[],\n): RgbaColor[] {\n const probe = document.createElement('span')\n probe.setAttribute('aria-hidden', 'true')\n probe.style.cssText =\n 'position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none'\n element.append(probe)\n try {\n return expressions.map((expression) => readColor(probe, expression))\n } finally {\n probe.remove()\n }\n}\n\n/** `#rrggbb`, ready for the hex alpha some charts append. */\nexport const hexString = ({ r, g, b }: RgbaColor) =>\n `#${[r, g, b].map((value) => value.toString(16).padStart(2, '0')).join('')}`\n\n/** A `#rrggbb` color as an `rgba()` string with the alpha given. */\nexport function hexWithAlpha(hex: string, alpha: number) {\n const value = Number.parseInt(hex.slice(1, 7), 16)\n return `rgba(${(value >> 16) & 255}, ${(value >> 8) & 255}, ${value & 255}, ${alpha})`\n}\n\nconst channelsOf = (hex: string) => {\n const value = Number.parseInt(hex.slice(1, 7), 16)\n return [(value >> 16) & 255, (value >> 8) & 255, value & 255]\n}\n\n/** WCAG relative luminance of a `#rrggbb` color. */\nconst luminanceOf = (hex: string) => {\n const [r, g, b] = channelsOf(hex).map((channel) => {\n const value = channel / 255\n return value <= 0.03928\n ? value / 12.92\n : ((value + 0.055) / 1.055) ** 2.4\n })\n return 0.2126 * r + 0.7152 * g + 0.0722 * b\n}\n\nconst contrastOf = (a: string, b: string) => {\n const [high, low] = [luminanceOf(a), luminanceOf(b)].sort((x, y) => y - x)\n return (high + 0.05) / (low + 0.05)\n}\n\n/**\n * `color` as a chart mark on `ground`: unchanged when it already stands 3:1\n * off it, the contrast WCAG asks of a graphic (1.4.11), otherwise mixed\n * toward `toward` (white on a dark ground, black on a light one) a tenth at\n * a time until it does. An agent's own color is often black, which vanished\n * from the bars of the dark theme, and the palette's two dark teals did too.\n * A color that is not `#rgb` or `#rrggbb` is returned as it is.\n */\nexport function readableOn(color: string, ground: string, toward: string) {\n const short = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(color)\n const hex = short\n ? `#${short[1]}${short[1]}${short[2]}${short[2]}${short[3]}${short[3]}`\n : color\n if (!/^#[0-9a-f]{6}$/i.test(hex) || contrastOf(hex, ground) >= 3) {\n return color\n }\n const from = channelsOf(hex)\n const to = channelsOf(toward)\n for (let step = 1; step <= 10; step++) {\n const mixed = hexString({\n r: Math.round(from[0] + ((to[0] - from[0]) * step) / 10),\n g: Math.round(from[1] + ((to[1] - from[1]) * step) / 10),\n b: Math.round(from[2] + ((to[2] - from[2]) * step) / 10),\n a: 1,\n })\n if (contrastOf(mixed, ground) >= 3) {\n return mixed\n }\n }\n return toward\n}\n","<script setup lang=\"ts\">\n import {\n nextTick,\n onBeforeUnmount,\n onMounted,\n useTemplateRef,\n watch,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import {\n ArcElement,\n BarController,\n BarElement,\n CategoryScale,\n Chart as ChartJS,\n DoughnutController,\n Legend,\n LinearScale,\n LineController,\n LineElement,\n PieController,\n PointElement,\n Title,\n Tooltip,\n type ChartConfiguration,\n type TooltipItem,\n } from 'chart.js'\n import {\n hexString,\n resolveCssColorsIn,\n supportsColorRoles,\n } from 'composables'\n import { isRoundChart, type Chart, type ChartTone } from 'models'\n import { chartValueFormatter } from './chartFormat'\n\n ChartJS.register(\n ArcElement,\n BarController,\n BarElement,\n CategoryScale,\n DoughnutController,\n Legend,\n LinearScale,\n LineController,\n LineElement,\n PieController,\n PointElement,\n Title,\n Tooltip,\n )\n\n /**\n * Draws a chart described as data (spec `chat-charts.md`) with Chart.js,\n * in the colors of the theme it sits in: the categorical palette from the\n * design system's graphic roles, the tones from its semantic ones. The\n * colors are read inside this element, so in the widget they are the\n * widget's own and not the host page's.\n *\n * On `paper` it draws a chart of a file in the file's viewer (F4): on the\n * white of the sheet or the page in both themes, in Office's grey ink,\n * with the file's `colors` (one per series, or one per slice), its\n * `legend` where the file puts one, and its title inside.\n */\n const props = defineProps<{\n chart: Chart\n isDark?: boolean\n paper?: boolean\n colors?: string[]\n legend?: 'top' | 'bottom' | 'left' | 'right'\n }>()\n\n const { locale, t: $t } = useI18n({ useScope: 'global' })\n\n const root = useTemplateRef<HTMLElement>('root')\n const canvas = useTemplateRef<HTMLCanvasElement>('canvas')\n let instance: ChartJS | undefined\n\n const ROLES = ['accent', 'brand', 'info'] as const\n /**\n * Twelve categorical colors, enough for the slices of a pie: the three\n * graphic roles, then the same roles toward the surface (a tint in the\n * light theme, a shade in the dark one), then toward the text, then\n * further toward the surface. Mixing the default brand, a near black\n * navy, toward the text alone gave two slices nobody could tell apart.\n * Interleaved, so neighbours never share a hue.\n */\n const CATEGORICAL = (\n [\n [100, 'surface'],\n [55, 'surface'],\n [70, 'word'],\n [30, 'surface'],\n ] as const\n ).flatMap(([strength, toward]) =>\n ROLES.map((role) =>\n strength === 100\n ? `var(--color-${role}-graphic)`\n : `color-mix(in srgb, var(--color-${role}-graphic) ${strength}%, var(--color-${toward}))`,\n ),\n )\n const TONES: Record<ChartTone, string> = {\n positive: 'var(--color-success-graphic)',\n warning: 'var(--color-warning-graphic)',\n negative: 'var(--color-danger-graphic)',\n critical:\n 'color-mix(in srgb, var(--color-danger-graphic) 60%, var(--color-word))',\n neutral:\n 'color-mix(in srgb, var(--color-word) 35%, var(--color-surface))',\n }\n const INK = [\n 'var(--color-word-2)',\n 'var(--color-word-3)',\n 'var(--color-surface-3)',\n 'var(--color-surface)',\n ]\n\n /**\n * A browser that cannot compute the design system's roles (no\n * `color-mix()` or relative colors) would draw every series in the text\n * color: it gets the dashboard's colors for the default theme instead.\n */\n const fallbackColors = (dark: boolean) => ({\n categorical: [\n '#9365ff',\n '#004775',\n '#6e66ed',\n '#003d5c',\n '#4b63d9',\n '#0058a8',\n '#285ec1',\n '#00508f',\n ],\n tones: {\n positive: '#5cb327',\n warning: '#e0a800',\n negative: '#fe4242',\n critical: '#991b1b',\n neutral: dark ? '#4b4b5c' : '#c4c9d4',\n } satisfies Record<ChartTone, string>,\n text: dark ? '#d1d5db' : '#4b5563',\n tick: dark ? '#9ca3af' : '#6b7280',\n grid: dark ? '#374151' : '#f3f4f6',\n surface: dark ? '#1f2937' : '#ffffff',\n })\n\n /** The grey Office draws a chart's text and lines in, on white. */\n const OFFICE_INK = {\n text: '#595959',\n tick: '#595959',\n grid: '#d9d9d9',\n surface: '#ffffff',\n }\n\n const readColors = () => {\n if (props.paper) {\n const light = fallbackColors(false)\n return {\n ...light,\n ...OFFICE_INK,\n categorical: props.colors?.length\n ? props.colors\n : light.categorical,\n }\n }\n if (!supportsColorRoles()) {\n return fallbackColors(!!props.isDark)\n }\n const expressions = [...CATEGORICAL, ...Object.values(TONES), ...INK]\n const hex = resolveCssColorsIn(root.value!, expressions).map(hexString)\n const categorical = hex.slice(0, CATEGORICAL.length)\n const tones = Object.fromEntries(\n Object.keys(TONES).map((tone, i) => [\n tone,\n hex[CATEGORICAL.length + i],\n ]),\n ) as Record<ChartTone, string>\n const [text, tick, grid, surface] = hex.slice(-INK.length)\n return { categorical, tones, text, tick, grid, surface }\n }\n\n const configuration = (): ChartConfiguration => {\n const { chart } = props\n const colors = readColors()\n const font = {\n family: getComputedStyle(root.value!).fontFamily,\n size: 11,\n }\n const format = chartValueFormatter(locale.value, chart.format)\n const reducedMotion = window.matchMedia(\n '(prefers-reduced-motion: reduce)',\n ).matches\n const round = isRoundChart(chart.type)\n const paper = !!props.paper\n let untoned = 0\n const datasets = chart.series.map((series, index) => {\n // A file can leave a series unnamed: numbered, as Excel does\n const label = series.name || $t('chart.series', { n: index + 1 })\n if (round) {\n return {\n label,\n data: series.values,\n backgroundColor: chart.categories.map(\n (_, i) =>\n colors.categorical[i % colors.categorical.length],\n ),\n borderColor: colors.surface,\n borderWidth: 2,\n }\n }\n const color = series.tone\n ? colors.tones[series.tone]\n : colors.categorical[untoned++ % colors.categorical.length]\n // On paper, straight lines and square bars, as Office draws them\n return chart.type === 'line'\n ? {\n label,\n data: series.values,\n borderColor: color,\n backgroundColor: color,\n borderWidth: 2,\n pointRadius: 3,\n // Smooth without overshooting a value\n cubicInterpolationMode: paper ? 'default' : 'monotone',\n // A missing value stays a gap, not a guess\n spanGaps: false,\n }\n : {\n label,\n data: series.values,\n backgroundColor: color,\n borderRadius: paper ? 0 : 3,\n maxBarThickness: paper ? undefined : 48,\n }\n })\n const axisTitle = (text?: string) => ({\n display: !!text,\n text: text ?? '',\n color: colors.tick,\n font,\n })\n const valueAxis = {\n beginAtZero: true,\n stacked: !!chart.stacked,\n ticks: {\n color: colors.tick,\n font,\n callback: (value: string | number) => format(Number(value)),\n },\n grid: { color: colors.grid, drawTicks: false },\n border: { display: false },\n title: axisTitle(chart.valueLabel),\n }\n const categoryAxis = {\n stacked: !!chart.stacked,\n ticks: { color: colors.tick, font, autoSkip: true },\n grid: { display: false },\n border: { display: false },\n title: axisTitle(chart.categoryLabel),\n }\n const horizontal = chart.type === 'bar' && !!chart.horizontal\n return {\n type: chart.type,\n data: { labels: chart.categories, datasets },\n options: {\n responsive: true,\n maintainAspectRatio: false,\n animation: reducedMotion ? false : { duration: 400 },\n indexAxis: horizontal ? 'y' : 'x',\n // The hole of a doughnut, and the slices drawn whole in a pie\n ...(round && {\n cutout: chart.type === 'doughnut' ? '55%' : 0,\n }),\n scales: round\n ? {}\n : horizontal\n ? { x: valueAxis, y: categoryAxis }\n : { x: categoryAxis, y: valueAxis },\n plugins: {\n // The card says the title of a chart in the chat; a\n // file's chart carries its own\n title: {\n display: paper && !!chart.title,\n text: chart.title ?? '',\n color: colors.text,\n font: { ...font, size: 14, weight: 'normal' },\n padding: { top: 4, bottom: 8 },\n },\n legend: {\n display: paper\n ? !!props.legend\n : round || chart.series.length > 1,\n position: (paper && props.legend) || 'bottom',\n labels: {\n color: colors.text,\n font,\n boxWidth: 10,\n boxHeight: 10,\n useBorderRadius: true,\n borderRadius: 2,\n },\n },\n tooltip: {\n callbacks: {\n label: (item: TooltipItem<typeof chart.type>) => {\n const value = Number(item.raw)\n if (!round) {\n return `${item.dataset.label}: ${format(value)}`\n }\n const total = (item.dataset.data as number[])\n .filter((v) => typeof v === 'number')\n .reduce((sum, v) => sum + v, 0)\n const share = total\n ? new Intl.NumberFormat(locale.value, {\n style: 'percent',\n maximumFractionDigits: 1,\n }).format(value / total)\n : ''\n return `${item.label}: ${format(value)}${share ? ` (${share})` : ''}`\n },\n },\n },\n },\n },\n } as ChartConfiguration\n }\n\n const draw = async () => {\n await nextTick()\n if (!canvas.value || !root.value) {\n return\n }\n instance?.destroy()\n instance = new ChartJS(canvas.value, configuration())\n }\n\n /**\n * The chart as a PNG on the surface it is drawn on: the canvas itself is\n * transparent, and a transparent PNG pasted on a dark slide loses its\n * text.\n */\n const toBlob = async (): Promise<Blob | null> => {\n if (!canvas.value || !root.value) {\n return null\n }\n const copy = document.createElement('canvas')\n copy.width = canvas.value.width\n copy.height = canvas.value.height\n const context = copy.getContext('2d')\n if (!context) {\n return null\n }\n context.fillStyle = readColors().surface\n context.fillRect(0, 0, copy.width, copy.height)\n context.drawImage(canvas.value, 0, 0)\n return new Promise((resolve) => copy.toBlob(resolve, 'image/png'))\n }\n\n defineExpose({ toBlob })\n\n onMounted(draw)\n // Redrawn when the numbers or the theme change, not when the parent hands\n // over the same chart as a new object (each update of the message parses\n // the input again): that replayed the animation. The colors are read\n // again with the theme classes.\n watch(\n () =>\n JSON.stringify([\n props.isDark,\n props.paper,\n props.legend,\n props.colors,\n props.chart,\n ]),\n draw,\n )\n onBeforeUnmount(() => {\n instance?.destroy()\n instance = undefined\n })\n</script>\n\n<template>\n <div ref=\"root\" class=\"pk-chart\">\n <canvas\n ref=\"canvas\"\n role=\"img\"\n :aria-label=\"\n chart.title || chart.series.map((s) => s.name).join(', ')\n \" />\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart {\n position: relative;\n width: 100%;\n height: 100%;\n min-height: 0;\n }\n</style>\n","<script setup lang=\"ts\">\n import {\n nextTick,\n onBeforeUnmount,\n onMounted,\n useTemplateRef,\n watch,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import {\n ArcElement,\n BarController,\n BarElement,\n CategoryScale,\n Chart as ChartJS,\n DoughnutController,\n Legend,\n LinearScale,\n LineController,\n LineElement,\n PieController,\n PointElement,\n Title,\n Tooltip,\n type ChartConfiguration,\n type TooltipItem,\n } from 'chart.js'\n import {\n hexString,\n resolveCssColorsIn,\n supportsColorRoles,\n } from 'composables'\n import { isRoundChart, type Chart, type ChartTone } from 'models'\n import { chartValueFormatter } from './chartFormat'\n\n ChartJS.register(\n ArcElement,\n BarController,\n BarElement,\n CategoryScale,\n DoughnutController,\n Legend,\n LinearScale,\n LineController,\n LineElement,\n PieController,\n PointElement,\n Title,\n Tooltip,\n )\n\n /**\n * Draws a chart described as data (spec `chat-charts.md`) with Chart.js,\n * in the colors of the theme it sits in: the categorical palette from the\n * design system's graphic roles, the tones from its semantic ones. The\n * colors are read inside this element, so in the widget they are the\n * widget's own and not the host page's.\n *\n * On `paper` it draws a chart of a file in the file's viewer (F4): on the\n * white of the sheet or the page in both themes, in Office's grey ink,\n * with the file's `colors` (one per series, or one per slice), its\n * `legend` where the file puts one, and its title inside.\n */\n const props = defineProps<{\n chart: Chart\n isDark?: boolean\n paper?: boolean\n colors?: string[]\n legend?: 'top' | 'bottom' | 'left' | 'right'\n }>()\n\n const { locale, t: $t } = useI18n({ useScope: 'global' })\n\n const root = useTemplateRef<HTMLElement>('root')\n const canvas = useTemplateRef<HTMLCanvasElement>('canvas')\n let instance: ChartJS | undefined\n\n const ROLES = ['accent', 'brand', 'info'] as const\n /**\n * Twelve categorical colors, enough for the slices of a pie: the three\n * graphic roles, then the same roles toward the surface (a tint in the\n * light theme, a shade in the dark one), then toward the text, then\n * further toward the surface. Mixing the default brand, a near black\n * navy, toward the text alone gave two slices nobody could tell apart.\n * Interleaved, so neighbours never share a hue.\n */\n const CATEGORICAL = (\n [\n [100, 'surface'],\n [55, 'surface'],\n [70, 'word'],\n [30, 'surface'],\n ] as const\n ).flatMap(([strength, toward]) =>\n ROLES.map((role) =>\n strength === 100\n ? `var(--color-${role}-graphic)`\n : `color-mix(in srgb, var(--color-${role}-graphic) ${strength}%, var(--color-${toward}))`,\n ),\n )\n const TONES: Record<ChartTone, string> = {\n positive: 'var(--color-success-graphic)',\n warning: 'var(--color-warning-graphic)',\n negative: 'var(--color-danger-graphic)',\n critical:\n 'color-mix(in srgb, var(--color-danger-graphic) 60%, var(--color-word))',\n neutral:\n 'color-mix(in srgb, var(--color-word) 35%, var(--color-surface))',\n }\n const INK = [\n 'var(--color-word-2)',\n 'var(--color-word-3)',\n 'var(--color-surface-3)',\n 'var(--color-surface)',\n ]\n\n /**\n * A browser that cannot compute the design system's roles (no\n * `color-mix()` or relative colors) would draw every series in the text\n * color: it gets the dashboard's colors for the default theme instead.\n */\n const fallbackColors = (dark: boolean) => ({\n categorical: [\n '#9365ff',\n '#004775',\n '#6e66ed',\n '#003d5c',\n '#4b63d9',\n '#0058a8',\n '#285ec1',\n '#00508f',\n ],\n tones: {\n positive: '#5cb327',\n warning: '#e0a800',\n negative: '#fe4242',\n critical: '#991b1b',\n neutral: dark ? '#4b4b5c' : '#c4c9d4',\n } satisfies Record<ChartTone, string>,\n text: dark ? '#d1d5db' : '#4b5563',\n tick: dark ? '#9ca3af' : '#6b7280',\n grid: dark ? '#374151' : '#f3f4f6',\n surface: dark ? '#1f2937' : '#ffffff',\n })\n\n /** The grey Office draws a chart's text and lines in, on white. */\n const OFFICE_INK = {\n text: '#595959',\n tick: '#595959',\n grid: '#d9d9d9',\n surface: '#ffffff',\n }\n\n const readColors = () => {\n if (props.paper) {\n const light = fallbackColors(false)\n return {\n ...light,\n ...OFFICE_INK,\n categorical: props.colors?.length\n ? props.colors\n : light.categorical,\n }\n }\n if (!supportsColorRoles()) {\n return fallbackColors(!!props.isDark)\n }\n const expressions = [...CATEGORICAL, ...Object.values(TONES), ...INK]\n const hex = resolveCssColorsIn(root.value!, expressions).map(hexString)\n const categorical = hex.slice(0, CATEGORICAL.length)\n const tones = Object.fromEntries(\n Object.keys(TONES).map((tone, i) => [\n tone,\n hex[CATEGORICAL.length + i],\n ]),\n ) as Record<ChartTone, string>\n const [text, tick, grid, surface] = hex.slice(-INK.length)\n return { categorical, tones, text, tick, grid, surface }\n }\n\n const configuration = (): ChartConfiguration => {\n const { chart } = props\n const colors = readColors()\n const font = {\n family: getComputedStyle(root.value!).fontFamily,\n size: 11,\n }\n const format = chartValueFormatter(locale.value, chart.format)\n const reducedMotion = window.matchMedia(\n '(prefers-reduced-motion: reduce)',\n ).matches\n const round = isRoundChart(chart.type)\n const paper = !!props.paper\n let untoned = 0\n const datasets = chart.series.map((series, index) => {\n // A file can leave a series unnamed: numbered, as Excel does\n const label = series.name || $t('chart.series', { n: index + 1 })\n if (round) {\n return {\n label,\n data: series.values,\n backgroundColor: chart.categories.map(\n (_, i) =>\n colors.categorical[i % colors.categorical.length],\n ),\n borderColor: colors.surface,\n borderWidth: 2,\n }\n }\n const color = series.tone\n ? colors.tones[series.tone]\n : colors.categorical[untoned++ % colors.categorical.length]\n // On paper, straight lines and square bars, as Office draws them\n return chart.type === 'line'\n ? {\n label,\n data: series.values,\n borderColor: color,\n backgroundColor: color,\n borderWidth: 2,\n pointRadius: 3,\n // Smooth without overshooting a value\n cubicInterpolationMode: paper ? 'default' : 'monotone',\n // A missing value stays a gap, not a guess\n spanGaps: false,\n }\n : {\n label,\n data: series.values,\n backgroundColor: color,\n borderRadius: paper ? 0 : 3,\n maxBarThickness: paper ? undefined : 48,\n }\n })\n const axisTitle = (text?: string) => ({\n display: !!text,\n text: text ?? '',\n color: colors.tick,\n font,\n })\n const valueAxis = {\n beginAtZero: true,\n stacked: !!chart.stacked,\n ticks: {\n color: colors.tick,\n font,\n callback: (value: string | number) => format(Number(value)),\n },\n grid: { color: colors.grid, drawTicks: false },\n border: { display: false },\n title: axisTitle(chart.valueLabel),\n }\n const categoryAxis = {\n stacked: !!chart.stacked,\n ticks: { color: colors.tick, font, autoSkip: true },\n grid: { display: false },\n border: { display: false },\n title: axisTitle(chart.categoryLabel),\n }\n const horizontal = chart.type === 'bar' && !!chart.horizontal\n return {\n type: chart.type,\n data: { labels: chart.categories, datasets },\n options: {\n responsive: true,\n maintainAspectRatio: false,\n animation: reducedMotion ? false : { duration: 400 },\n indexAxis: horizontal ? 'y' : 'x',\n // The hole of a doughnut, and the slices drawn whole in a pie\n ...(round && {\n cutout: chart.type === 'doughnut' ? '55%' : 0,\n }),\n scales: round\n ? {}\n : horizontal\n ? { x: valueAxis, y: categoryAxis }\n : { x: categoryAxis, y: valueAxis },\n plugins: {\n // The card says the title of a chart in the chat; a\n // file's chart carries its own\n title: {\n display: paper && !!chart.title,\n text: chart.title ?? '',\n color: colors.text,\n font: { ...font, size: 14, weight: 'normal' },\n padding: { top: 4, bottom: 8 },\n },\n legend: {\n display: paper\n ? !!props.legend\n : round || chart.series.length > 1,\n position: (paper && props.legend) || 'bottom',\n labels: {\n color: colors.text,\n font,\n boxWidth: 10,\n boxHeight: 10,\n useBorderRadius: true,\n borderRadius: 2,\n },\n },\n tooltip: {\n callbacks: {\n label: (item: TooltipItem<typeof chart.type>) => {\n const value = Number(item.raw)\n if (!round) {\n return `${item.dataset.label}: ${format(value)}`\n }\n const total = (item.dataset.data as number[])\n .filter((v) => typeof v === 'number')\n .reduce((sum, v) => sum + v, 0)\n const share = total\n ? new Intl.NumberFormat(locale.value, {\n style: 'percent',\n maximumFractionDigits: 1,\n }).format(value / total)\n : ''\n return `${item.label}: ${format(value)}${share ? ` (${share})` : ''}`\n },\n },\n },\n },\n },\n } as ChartConfiguration\n }\n\n const draw = async () => {\n await nextTick()\n if (!canvas.value || !root.value) {\n return\n }\n instance?.destroy()\n instance = new ChartJS(canvas.value, configuration())\n }\n\n /**\n * The chart as a PNG on the surface it is drawn on: the canvas itself is\n * transparent, and a transparent PNG pasted on a dark slide loses its\n * text.\n */\n const toBlob = async (): Promise<Blob | null> => {\n if (!canvas.value || !root.value) {\n return null\n }\n const copy = document.createElement('canvas')\n copy.width = canvas.value.width\n copy.height = canvas.value.height\n const context = copy.getContext('2d')\n if (!context) {\n return null\n }\n context.fillStyle = readColors().surface\n context.fillRect(0, 0, copy.width, copy.height)\n context.drawImage(canvas.value, 0, 0)\n return new Promise((resolve) => copy.toBlob(resolve, 'image/png'))\n }\n\n defineExpose({ toBlob })\n\n onMounted(draw)\n // Redrawn when the numbers or the theme change, not when the parent hands\n // over the same chart as a new object (each update of the message parses\n // the input again): that replayed the animation. The colors are read\n // again with the theme classes.\n watch(\n () =>\n JSON.stringify([\n props.isDark,\n props.paper,\n props.legend,\n props.colors,\n props.chart,\n ]),\n draw,\n )\n onBeforeUnmount(() => {\n instance?.destroy()\n instance = undefined\n })\n</script>\n\n<template>\n <div ref=\"root\" class=\"pk-chart\">\n <canvas\n ref=\"canvas\"\n role=\"img\"\n :aria-label=\"\n chart.title || chart.series.map((s) => s.name).join(', ')\n \" />\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart {\n position: relative;\n width: 100%;\n height: 100%;\n min-height: 0;\n }\n</style>\n"],"mappings":";;;;;;AAIA,IAAIO,GAQSC,UACT,OAAO,MAAQ,OACf,IAAI,SAAS,SAAS,+BAA+B,KACrD,IAAI,SAAS,SAAS,mCAAmC,GAuBvDC,KAAW,MACb,KAAK,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,OAAOC,CAAK,CAAC,CAAC,IAAI,GAAG;AAG5D,SAASC,EAAU,GAAoC;CACnD,IAAMC,IAAQC,EAAS,MACnB,iDACJ;CAIA,OAHKD,IAGE;EACH,GAAGH,EAAQG,EAAM,EAAE;EACnB,GAAGH,EAAQG,EAAM,EAAE;EACnB,GAAGH,EAAQG,EAAM,EAAE;EACnB,GAAGA,EAAM,OAAO,KAAA,IAAY,IAAI,OAAOA,EAAM,EAAE;CACnD,IAPW;AAQf;AAGA,SAASE,EAAc,GAA6B;CAIhD,IAHA,MAAU,SACL,cAAc,QAAQ,CAAC,CACvB,WAAW,MAAM,EAAE,oBAAoB,GAAK,CAAC,GAC9C,CAACP,GACD,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE;CAIpC,AAFAA,EAAM,UAAU,GAAG,GAAG,GAAG,CAAC,GAC1B,EAAM,YAAYM,GAClBN,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC;CACzB,IAAM,CAACQ,GAAGC,GAAGC,GAAGC,KAAKX,EAAM,aAAa,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;CACpD,OAAO;EAAE;EAAG;EAAG;EAAG,GAAG,KAAK,MAAOW,IAAI,MAAO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AM;E,IAClB5C,EAKQ,UAAA;GAJA,SAAA;GAAJ,KAAI8C;GACJ,MAAK;GACJ,cAA6BL,EAAA,MAAM,SAASA,EAAA,MAAM,OAAO,KAAK,MAAMgE,EAAE,IAAI,CAAA,CAAE,KAAI,IAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as e } from "./VvButtonLocalized-C-vx25u4.js";
|
|
2
|
-
import { n as t, t as n } from "./PkStreamingMarkdown-
|
|
2
|
+
import { n as t, t as n } from "./PkStreamingMarkdown-BBvCtDlO.js";
|
|
3
3
|
import { n as r } from "./useChatbotStore-B6ILfm5Z.js";
|
|
4
|
-
import {
|
|
5
|
-
import { t as ee } from "./PkChatbotViewConversations-
|
|
6
|
-
import { t as te } from "./PkChatbotViewChat-
|
|
4
|
+
import { c as i, z as a } from "./utils-C9l078yb.js";
|
|
5
|
+
import { t as ee } from "./PkChatbotViewConversations-hgqSO1hx.js";
|
|
6
|
+
import { t as te } from "./PkChatbotViewChat-BkkyjiFl.js";
|
|
7
7
|
import { t as o } from "./useShortUrlResolver-KJDk7QLj.js";
|
|
8
8
|
import { t as ne } from "./PkChatbotViewFiles-CO4gv9nd.js";
|
|
9
9
|
import { t as re } from "./useLocalizedString-Dmn92nix.js";
|
|
@@ -91,7 +91,7 @@ var Ce = { class: "pk-chatbot__header-start" }, we = ["title"], Te = { key: 1 },
|
|
|
91
91
|
M("error", t);
|
|
92
92
|
} catch {}
|
|
93
93
|
});
|
|
94
|
-
let ze = c(() => j.modifier === "fullscreen"), J = c(() => j.modifier === "panel"), Be = ve("chatbotEl"), { width: Y } = xe(Be), Ve = c(() => Y.value > 0 && Y.value < 576), He = c(() => Y.value > 0 && Y.value < 640), Ue = c(() => Y.value >= 848), X = c(() => j.agentType === "reasoning"), We = c(() => X.value && !P.value.some((e) => e.role === "user")), Z = c(() => !J.value && j.agentInterface?.useColorsForAgentHeader), Ge = c(() => !J.value || K.value || q.value || L.value || z.value || j.closable || !!j.userFilesEnabled && !!F.value), Ke = c(() => ["theme", `theme--${Pe.value ? "dark" : "light"}`]), Q = c(() => j.agentInterface?.mainColor), $ = c(() =>
|
|
94
|
+
let ze = c(() => j.modifier === "fullscreen"), J = c(() => j.modifier === "panel"), Be = ve("chatbotEl"), { width: Y } = xe(Be), Ve = c(() => Y.value > 0 && Y.value < 576), He = c(() => Y.value > 0 && Y.value < 640), Ue = c(() => Y.value >= 848), X = c(() => j.agentType === "reasoning"), We = c(() => X.value && !P.value.some((e) => e.role === "user")), Z = c(() => !J.value && j.agentInterface?.useColorsForAgentHeader), Ge = c(() => !J.value || K.value || q.value || L.value || z.value || j.closable || !!j.userFilesEnabled && !!F.value), Ke = c(() => ["theme", `theme--${Pe.value ? "dark" : "light"}`]), Q = c(() => j.agentInterface?.mainColor), $ = c(() => a(j.agentInterface?.textColor, Q.value)), qe = c(() => i(Q.value, $.value)), Je = re(() => j.agentInterface?.footerMessage), Ye = c(() => I.value === "conversations" ? A("label.conversations") : I.value === "profile" ? A("label.profile") : I.value === "auth" ? A("label.authentication") : I.value === "files" ? A("userFiles.chatFilesTitle") : j.name), Xe = c(() => P.value?.[P.value.length - 1]);
|
|
95
95
|
return v({
|
|
96
96
|
startNewChat: H,
|
|
97
97
|
regenerate: Fe,
|
|
@@ -295,4 +295,4 @@ var Ce = { class: "pk-chatbot__header-start" }, we = ["title"], Te = { key: 1 },
|
|
|
295
295
|
});
|
|
296
296
|
export { O as t };
|
|
297
297
|
|
|
298
|
-
//# sourceMappingURL=PkChatbot-
|
|
298
|
+
//# sourceMappingURL=PkChatbot-CxkTubw8.js.map
|