@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
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import { r as e } from "./rolldown-runtime-9rEmUaIe.js";
|
|
2
|
-
import { _ as t, b as n, g as r, o as i, r as a, s as o } from "./zod-Cty6wiWN.js";
|
|
3
|
-
import { C as s, S as c, Tt as l, V as u, X as d, _ as f, f as p, g as m, gt as h, h as g, k as _, kt as v, ot as y, tt as b, v as x, w as S, wt as C, y as w, z as T } from "./vue.runtime.esm-bundler-C2U5uTqB.js";
|
|
4
|
-
import { r as ee } from "./vue-i18n-POtLvOl1.js";
|
|
5
|
-
import "./src-JJyCGvqH.js";
|
|
6
|
-
import { r as E } from "./text-5F7L8EHi.js";
|
|
7
|
-
import { i as D } from "./dist-D6oUr4J_.js";
|
|
8
|
-
import { d as O, r as k } from "./index.es-DIHz5I8K.js";
|
|
9
|
-
import { t as A } from "./VvButtonLocalized-C8S7XJGv.js";
|
|
10
|
-
import { t as j } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
|
|
11
|
-
// ../../packages/models/src/schema/Chart.ts
|
|
12
|
-
var M = [
|
|
13
|
-
"bar",
|
|
14
|
-
"line",
|
|
15
|
-
"pie",
|
|
16
|
-
"doughnut"
|
|
17
|
-
], N = [
|
|
18
|
-
"positive",
|
|
19
|
-
"warning",
|
|
20
|
-
"negative",
|
|
21
|
-
"critical",
|
|
22
|
-
"neutral"
|
|
23
|
-
], P = [
|
|
24
|
-
"number",
|
|
25
|
-
"percent",
|
|
26
|
-
"currency"
|
|
27
|
-
], F = {
|
|
28
|
-
maxCategories: 50,
|
|
29
|
-
maxSeries: 8,
|
|
30
|
-
maxSlices: 12,
|
|
31
|
-
maxCharts: 4
|
|
32
|
-
}, I = (e) => e === "pie" || e === "doughnut", L = 120, R = t({
|
|
33
|
-
name: n().min(1).max(L).describe("Series name, shown in the legend"),
|
|
34
|
-
values: i(r().nullable()).max(F.maxCategories).describe("One number per category, in the same order; null for none"),
|
|
35
|
-
tone: a(N).optional().describe("Only when the series means a judgement (e.g. high risk = negative): it takes that color")
|
|
36
|
-
}), z = t({
|
|
37
|
-
type: a(M).describe("bar to compare amounts, line for a trend over time, pie or doughnut for the shares of one whole"),
|
|
38
|
-
title: n().max(200).optional().describe("Short title above the chart"),
|
|
39
|
-
horizontal: o().optional().describe("bar only: categories on the vertical axis, for long labels"),
|
|
40
|
-
stacked: o().optional().describe("bar only: the series stacked into one bar per category"),
|
|
41
|
-
categories: i(n().max(L)).min(1).max(F.maxCategories, `At most ${F.maxCategories} categories: group the smallest ones.`).describe("The labels of the x axis (or of the slices), in display order"),
|
|
42
|
-
series: i(R).min(1).max(F.maxSeries, `At most ${F.maxSeries} series.`).describe("One or more named series; exactly one for pie or doughnut"),
|
|
43
|
-
valueLabel: n().max(L).optional().describe("What the numbers measure, with the unit (e.g. \"Clienti\")"),
|
|
44
|
-
categoryLabel: n().max(L).optional().describe("What the categories are (e.g. \"Fascia di rating\")"),
|
|
45
|
-
format: a(P).optional().describe("How values read: percent means 0.25 is 25%, currency is in euro")
|
|
46
|
-
}).superRefine((e, t) => {
|
|
47
|
-
let { type: n, categories: r, series: i } = e, a = (e, n) => t.addIssue({
|
|
48
|
-
code: "custom",
|
|
49
|
-
message: e,
|
|
50
|
-
path: n
|
|
51
|
-
});
|
|
52
|
-
i.forEach((e, t) => {
|
|
53
|
-
e.values.length !== r.length && a(`Series "${e.name}" has ${e.values.length} values for ${r.length} categories: give one value per category.`, [
|
|
54
|
-
"series",
|
|
55
|
-
t,
|
|
56
|
-
"values"
|
|
57
|
-
]), e.values.every((e) => e === null) && a(`Series "${e.name}" has no values: leave it out, or give its numbers.`, [
|
|
58
|
-
"series",
|
|
59
|
-
t,
|
|
60
|
-
"values"
|
|
61
|
-
]);
|
|
62
|
-
}), I(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 > F.maxSlices && a(`${r.length} slices: at most ${F.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.`, [
|
|
63
|
-
"series",
|
|
64
|
-
0,
|
|
65
|
-
"values"
|
|
66
|
-
]) : 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.`, [
|
|
67
|
-
"series",
|
|
68
|
-
0,
|
|
69
|
-
"values"
|
|
70
|
-
]));
|
|
71
|
-
}), B = t({
|
|
72
|
-
charts: i(z).min(1).max(F.maxCharts).describe("Every chart the user asked for, one entry each (e.g. a pie and a bar chart of the same numbers)"),
|
|
73
|
-
caption: n().max(500).optional().describe("Optional note below the charts, e.g. the source")
|
|
74
|
-
}), V = (e, t = "number") => {
|
|
75
|
-
let n = new Intl.NumberFormat(e, t === "percent" ? {
|
|
76
|
-
style: "percent",
|
|
77
|
-
maximumFractionDigits: 1
|
|
78
|
-
} : t === "currency" ? {
|
|
79
|
-
style: "currency",
|
|
80
|
-
currency: "EUR",
|
|
81
|
-
maximumFractionDigits: 0
|
|
82
|
-
} : { maximumFractionDigits: 2 }), r = t === "currency" ? new Intl.NumberFormat(e, {
|
|
83
|
-
style: "currency",
|
|
84
|
-
currency: "EUR"
|
|
85
|
-
}) : n;
|
|
86
|
-
return (e) => e === null || !Number.isFinite(e) ? "" : (Number.isInteger(e) ? n : r).format(e);
|
|
87
|
-
}, H = (e, t) => {
|
|
88
|
-
let n = new Intl.NumberFormat(t, {
|
|
89
|
-
useGrouping: !1,
|
|
90
|
-
maximumFractionDigits: 10
|
|
91
|
-
}), r = (e) => e.replace(/[\t\r\n]+/g, " ");
|
|
92
|
-
return [[e.categoryLabel ?? "", ...e.series.map((e) => e.name)], ...e.categories.map((t, r) => [t, ...e.series.map((e) => {
|
|
93
|
-
let t = e.values[r];
|
|
94
|
-
return t == null ? "" : n.format(t);
|
|
95
|
-
})])].map((e) => e.map(r).join(" ")).join("\n");
|
|
96
|
-
};
|
|
97
|
-
// ../../packages/components/src/chat/PkChartCard.vue?vue&type=script&setup=true&lang.ts
|
|
98
|
-
_(), y(), l();
|
|
99
|
-
var U = { class: "pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden" }, W = { class: "px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8" }, G = { class: "font-bold truncate" }, K = {
|
|
100
|
-
key: 0,
|
|
101
|
-
class: "pk-chart-card__table-wrap"
|
|
102
|
-
}, q = { class: "pk-chart-card__table text-12" }, J = { scope: "col" }, Y = { scope: "row" }, X = {
|
|
103
|
-
key: 1,
|
|
104
|
-
class: "pk-chart-card__stage px-sm py-sm"
|
|
105
|
-
}, Z = {
|
|
106
|
-
key: 2,
|
|
107
|
-
class: "px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3"
|
|
108
|
-
}, Q = /*#__PURE__*/ j(/* @__PURE__ */ S({
|
|
109
|
-
__name: "PkChartCard",
|
|
110
|
-
props: {
|
|
111
|
-
chart: { type: null },
|
|
112
|
-
caption: { type: String },
|
|
113
|
-
isDark: { type: Boolean }
|
|
114
|
-
},
|
|
115
|
-
setup(e) {
|
|
116
|
-
let t = s(() => import("./PkChart-CbtMRGWc.js")), n = e, { t: r, locale: i } = ee({ useScope: "global" }), { copy: a, copied: o } = D(), l = g(() => {
|
|
117
|
-
switch (n.chart.type) {
|
|
118
|
-
case "line": return "ri:line-chart-line";
|
|
119
|
-
case "pie": return "ri:pie-chart-line";
|
|
120
|
-
case "doughnut": return "ri:donut-chart-line";
|
|
121
|
-
default: return n.chart.horizontal ? "ri:bar-chart-horizontal-line" : "ri:bar-chart-2-line";
|
|
122
|
-
}
|
|
123
|
-
}), _ = h(!1), y = g(() => V(i.value, n.chart.format)), S = d("chartRef"), j = async () => {
|
|
124
|
-
let e = await S.value?.toBlob();
|
|
125
|
-
if (!e) return;
|
|
126
|
-
let t = URL.createObjectURL(e), r = document.createElement("a");
|
|
127
|
-
r.href = t, r.download = `${E(n.chart.title || "chart")}.png`, document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(t);
|
|
128
|
-
};
|
|
129
|
-
return (n, s) => {
|
|
130
|
-
let d = k, h = A, g = O;
|
|
131
|
-
return T(), w("div", U, [
|
|
132
|
-
m("div", W, [
|
|
133
|
-
c(d, {
|
|
134
|
-
name: l.value,
|
|
135
|
-
class: "text-16 shrink-0"
|
|
136
|
-
}, null, 8, ["name"]),
|
|
137
|
-
m("strong", G, v(e.chart.title || C(r)("label.chart")), 1),
|
|
138
|
-
c(g, {
|
|
139
|
-
modifiers: "compact",
|
|
140
|
-
class: "pk-chart-card__actions ml-auto shrink-0"
|
|
141
|
-
}, {
|
|
142
|
-
default: b(() => [
|
|
143
|
-
c(h, {
|
|
144
|
-
modifiers: "action-quiet-small",
|
|
145
|
-
icon: _.value ? l.value : "ri:table-line",
|
|
146
|
-
label: _.value ? C(r)("chart.showChart") : C(r)("chart.showTable"),
|
|
147
|
-
onClick: s[0] ||= (e) => _.value = !_.value
|
|
148
|
-
}, null, 8, ["icon", "label"]),
|
|
149
|
-
c(h, {
|
|
150
|
-
modifiers: "action-quiet-small",
|
|
151
|
-
icon: C(o) ? "ri:check-line" : "ri:file-copy-line",
|
|
152
|
-
label: C(o) ? C(r)("action.copied") : C(r)("chart.copyData"),
|
|
153
|
-
onClick: s[1] ||= (t) => C(a)(C(H)(e.chart, C(i)))
|
|
154
|
-
}, null, 8, ["icon", "label"]),
|
|
155
|
-
_.value ? x("", !0) : (T(), f(h, {
|
|
156
|
-
key: 0,
|
|
157
|
-
modifiers: "action-quiet-small",
|
|
158
|
-
icon: "ri:download-line",
|
|
159
|
-
label: C(r)("action.download"),
|
|
160
|
-
title: C(r)("chart.downloadPng"),
|
|
161
|
-
onClick: j
|
|
162
|
-
}, null, 8, ["label", "title"]))
|
|
163
|
-
]),
|
|
164
|
-
_: 1
|
|
165
|
-
})
|
|
166
|
-
]),
|
|
167
|
-
_.value ? (T(), w("div", K, [m("table", q, [m("thead", null, [m("tr", null, [m("th", J, v(e.chart.categoryLabel ?? ""), 1), (T(!0), w(p, null, u(e.chart.series, (e) => (T(), w("th", {
|
|
168
|
-
key: e.name,
|
|
169
|
-
scope: "col"
|
|
170
|
-
}, v(e.name), 1))), 128))])]), m("tbody", null, [(T(!0), w(p, null, u(e.chart.categories, (t, n) => (T(), w("tr", { key: n }, [m("th", Y, v(t), 1), (T(!0), w(p, null, u(e.chart.series, (e) => (T(), w("td", { key: e.name }, v(y.value(e.values[n] ?? null)), 1))), 128))]))), 128))])])])) : (T(), w("div", X, [c(C(t), {
|
|
171
|
-
ref_key: "chartRef",
|
|
172
|
-
ref: S,
|
|
173
|
-
chart: e.chart,
|
|
174
|
-
"is-dark": e.isDark
|
|
175
|
-
}, null, 8, ["chart", "is-dark"])])),
|
|
176
|
-
e.caption ? (T(), w("div", Z, v(e.caption), 1)) : x("", !0)
|
|
177
|
-
]);
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
}), [["styles", [".pk-chart-card{container-type:inline-size}@container (width<30rem){.pk-chart-card__actions .vv-button__label{clip-path:inset(50%);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}}.pk-chart-card__stage{height:320px}.pk-chart-card__table-wrap{max-height:320px;overflow:auto}.pk-chart-card__table{border-collapse:collapse;width:100%}.pk-chart-card__table th,.pk-chart-card__table td{padding:var(--spacing-6) var(--spacing-sm);border-bottom:1px solid var(--color-surface-3);text-align:right;white-space:nowrap}.pk-chart-card__table th:first-child{text-align:left;white-space:normal}.pk-chart-card__table thead th{color:var(--color-word-3);font-weight:600}.pk-chart-card__table tbody th{color:var(--color-word-2);font-weight:400}.pk-chart-card__table td{color:var(--color-word);font-variant-numeric:tabular-nums}.pk-chart-card__table tbody tr:last-child>*{border-bottom:0}"]]]);
|
|
181
|
-
// ../../packages/components/src/chat/PkToolShowChart.vue?vue&type=script&setup=true&lang.ts
|
|
182
|
-
_(), l();
|
|
183
|
-
var te = {
|
|
184
|
-
key: 0,
|
|
185
|
-
class: "flex flex-col gap-sm w-full"
|
|
186
|
-
}, ne = {
|
|
187
|
-
key: 1,
|
|
188
|
-
class: "pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center"
|
|
189
|
-
}, re = {
|
|
190
|
-
key: 2,
|
|
191
|
-
class: "border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm"
|
|
192
|
-
}, ie = /*@__PURE__*/ S({
|
|
193
|
-
__name: "PkToolShowChart",
|
|
194
|
-
props: {
|
|
195
|
-
part: { type: null },
|
|
196
|
-
isDark: { type: Boolean }
|
|
197
|
-
},
|
|
198
|
-
setup(e) {
|
|
199
|
-
let t = e, n = g(() => t.part), r = g(() => n.value.state === "input-streaming"), i = g(() => n.value.state === "output-error"), a = g(() => {
|
|
200
|
-
if (r.value) return;
|
|
201
|
-
let e = B.safeParse(n.value.input);
|
|
202
|
-
return e.success ? e.data : void 0;
|
|
203
|
-
});
|
|
204
|
-
return (t, n) => {
|
|
205
|
-
let o = k;
|
|
206
|
-
return a.value ? (T(), w("div", te, [(T(!0), w(p, null, u(a.value.charts, (t, n) => (T(), f(Q, {
|
|
207
|
-
key: n,
|
|
208
|
-
chart: t,
|
|
209
|
-
caption: n === a.value.charts.length - 1 ? a.value.caption : void 0,
|
|
210
|
-
"is-dark": e.isDark
|
|
211
|
-
}, null, 8, [
|
|
212
|
-
"chart",
|
|
213
|
-
"caption",
|
|
214
|
-
"is-dark"
|
|
215
|
-
]))), 128))])) : r.value ? (T(), w("div", ne, [c(o, {
|
|
216
|
-
name: "loading-loop",
|
|
217
|
-
class: "w-24 h-24 text-word-5"
|
|
218
|
-
})])) : i.value ? x("", !0) : (T(), w("div", re, v(t.$t("message.chartRenderError")), 1));
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
}), ae = ".pk-tool-show-chart__loading{height:360px}", oe = /* @__PURE__ */ e({ default: () => $ }), $ = /*#__PURE__*/ j(ie, [["styles", [ae]]]);
|
|
222
|
-
export { $ as default, V as n, I as r, oe as t };
|
|
223
|
-
|
|
224
|
-
//# sourceMappingURL=PkToolShowChart-DZWu3Yuo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowChart-DZWu3Yuo.js","names":["z.object","z.string","z.array","z.number","z.enum","z.boolean","_hoisted_1","_hoisted_2","_hoisted_3","__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_withCtx","_createBlock","_createCommentVNode","_Fragment","_renderList","_sfc_main","_style_0","$t","__unplugin_components_0","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","PkChartCard","_createVNode","_toDisplayString","_createCommentVNode","_sfc_main","_style_0","__exportAll","object","string","number","array","_enum","boolean","defineAsyncComponent","createVNode","init_shared_esm_bundler","renderList","useTemplateRef","createBlock","Fragment","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","withCtx","createCommentVNode","defineComponent","unref","createElementBlock","openBlock","useI18n","toSnakeCase","useClipboard","ou","Ee","VvButtonLocalized","_plugin_vue_export_helper_default","CHART_TYPES","CHART_TONES","CHART_FORMATS","CHART_LIMITS","isRoundChart","type","LABEL_MAX","ChartSeriesSchema","ChartSchema","chart","issue","ctx","series","s","categories","i","v","ShowChartInputSchema","chartValueFormatter","formatter","locale","format","cents","value","chartAsTsv","clean","text","category","row","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","PkChartCard_default","PkChart","props","__props","$t","icon","showTable","chartRef","downloadPng","blob","url","anchor","_component_VvIcon","_component_VvButton","_component_VvButtonGroup","_cache","copied","copy","_hoisted_1","_hoisted_2","_hoisted_3","PkToolShowChart_vue_vue_type_script_setup_true_lang_default","toolPart","streaming","refused","input","parsed","_ctx","PkToolShowChart_vue_vue_type_style_index_0_inline_lang_default","PkToolShowChart_exports","PkToolShowChart_default"],"sources":["../../../../packages/models/src/schema/Chart.ts","../../../../packages/components/src/chat/chartFormat.ts","../../../../packages/components/src/chat/PkChartCard.vue","../../../../packages/components/src/chat/PkChartCard.vue","../../../../packages/components/src/chat/PkChartCard.vue","../../../../packages/components/src/chat/PkToolShowChart.vue","../../../../packages/components/src/chat/PkToolShowChart.vue","../../../../packages/components/src/chat/PkToolShowChart.vue"],"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","import type { ChartFormat } from 'models'\n\n/**\n * How the values of a chart read, on its axis, in its tooltip and in its\n * table: `percent` takes 0.25 as 25%, `currency` is in euro, as the model is\n * told (spec `chat-charts.md`).\n */\nexport const chartValueFormatter = (\n locale: string,\n format: ChartFormat = 'number',\n): ((value: number | null) => string) => {\n const formatter = new Intl.NumberFormat(\n locale,\n format === 'percent'\n ? { style: 'percent', maximumFractionDigits: 1 }\n : format === 'currency'\n ? { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 }\n : { maximumFractionDigits: 2 },\n )\n // 160.000 € on an axis, 12,50 € where there are cents\n const cents =\n format === 'currency'\n ? new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: 'EUR',\n })\n : formatter\n return (value) =>\n value === null || !Number.isFinite(value)\n ? ''\n : (Number.isInteger(value) ? formatter : cents).format(value)\n}\n\n/**\n * The chart as tab-separated text: pasted in Excel or Sheets it lands in\n * cells, one row per category and one column per series. The numbers are\n * written in the reader's locale without grouping: an Italian Excel reads\n * \"12.5\" as text or a date, \"12,5\" as the number.\n */\nexport const chartAsTsv = (\n chart: {\n categories: string[]\n series: { name: string; values: (number | null)[] }[]\n categoryLabel?: string\n },\n locale: string,\n): string => {\n const number = new Intl.NumberFormat(locale, {\n useGrouping: false,\n maximumFractionDigits: 10,\n })\n const clean = (text: string) => text.replace(/[\\t\\r\\n]+/g, ' ')\n const rows = [\n [chart.categoryLabel ?? '', ...chart.series.map((s) => s.name)],\n ...chart.categories.map((category, i) => [\n category,\n ...chart.series.map((s) => {\n const value = s.values[i]\n return value === null || value === undefined\n ? ''\n : number.format(value)\n }),\n ]),\n ]\n return rows.map((row) => row.map(clean).join('\\t')).join('\\n')\n}\n","<script setup lang=\"ts\">\n import { computed, defineAsyncComponent, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import type { Chart } from 'models'\n import { toSnakeCase } from 'utils'\n import { chartAsTsv, chartValueFormatter } from './chartFormat'\n\n // Chart.js comes with it: a separate chunk, loaded with the first chart\n const PkChart = defineAsyncComponent(() => import('./PkChart.vue'))\n\n /**\n * One chart of `showChart` (spec `chat-charts.md`) in its card: the chart,\n * the same numbers as a table, \"Copy data\" for a sheet and the chart as a\n * PNG.\n */\n const props = defineProps<{\n chart: Chart\n /** A note below the chart, e.g. the source of the numbers. */\n caption?: string\n isDark?: boolean\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const icon = computed(() => {\n switch (props.chart.type) {\n case 'line':\n return 'ri:line-chart-line'\n case 'pie':\n return 'ri:pie-chart-line'\n case 'doughnut':\n return 'ri:donut-chart-line'\n default:\n return props.chart.horizontal\n ? 'ri:bar-chart-horizontal-line'\n : 'ri:bar-chart-2-line'\n }\n })\n\n const showTable = ref(false)\n const format = computed(() =>\n chartValueFormatter(locale.value, props.chart.format),\n )\n\n const chartRef = useTemplateRef<{ toBlob: () => Promise<Blob | null> }>(\n 'chartRef',\n )\n const downloadPng = async () => {\n const blob = await chartRef.value?.toBlob()\n if (!blob) {\n return\n }\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(props.chart.title || 'chart')}.png`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n</script>\n\n<template>\n <div\n class=\"pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"icon\" class=\"text-16 shrink-0\" />\n <strong class=\"font-bold truncate\">\n {{ chart.title || $t('label.chart') }}\n </strong>\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"pk-chart-card__actions ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"showTable ? icon : 'ri:table-line'\"\n :label=\"\n showTable\n ? $t('chart.showChart')\n : $t('chart.showTable')\n \"\n @click=\"showTable = !showTable\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('chart.copyData')\"\n @click=\"copy(chartAsTsv(chart, locale))\" />\n <VvButton\n v-if=\"!showTable\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n :title=\"$t('chart.downloadPng')\"\n @click=\"downloadPng\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"showTable\" class=\"pk-chart-card__table-wrap\">\n <table class=\"pk-chart-card__table text-12\">\n <thead>\n <tr>\n <th scope=\"col\">{{ chart.categoryLabel ?? '' }}</th>\n <th\n v-for=\"series in chart.series\"\n :key=\"series.name\"\n scope=\"col\">\n {{ series.name }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(category, i) in chart.categories\" :key=\"i\">\n <th scope=\"row\">{{ category }}</th>\n <td v-for=\"series in chart.series\" :key=\"series.name\">\n {{ format(series.values[i] ?? null) }}\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <div v-else class=\"pk-chart-card__stage px-sm py-sm\">\n <PkChart ref=\"chartRef\" :chart :is-dark />\n </div>\n <div\n v-if=\"caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart-card {\n // A container for the narrow card below. It is also the containing\n // block of any `position: fixed` inside it, so a menu added here\n // must open in the top layer (docs/agents/gotchas/frontend.md, \"The\n // chat measures its own width\"): today the card has none.\n container-type: inline-size;\n\n // On a narrow card the actions keep their icon and lose the word on\n // screen, still read by a screen reader: the title keeps the room\n // (at 390px it was cut to \"Fattori di ...\")\n @container (width < 30rem) {\n &__actions .vv-button__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n }\n\n // A fixed stage, as the diagram's: the chart loads in a chunk of its\n // own, and loader and chart must take the same room or the chat's\n // scroll jumps\n &__stage {\n height: 320px;\n }\n\n &__table-wrap {\n max-height: 320px;\n overflow: auto;\n }\n\n &__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-6) var(--spacing-sm);\n border-bottom: 1px solid var(--color-surface-3);\n text-align: right;\n white-space: nowrap;\n }\n\n th:first-child {\n text-align: left;\n white-space: normal;\n }\n\n thead th {\n color: var(--color-word-3);\n font-weight: 600;\n }\n\n tbody th {\n color: var(--color-word-2);\n font-weight: 400;\n }\n\n td {\n color: var(--color-word);\n font-variant-numeric: tabular-nums;\n }\n\n tbody tr:last-child > * {\n border-bottom: 0;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed, defineAsyncComponent, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import type { Chart } from 'models'\n import { toSnakeCase } from 'utils'\n import { chartAsTsv, chartValueFormatter } from './chartFormat'\n\n // Chart.js comes with it: a separate chunk, loaded with the first chart\n const PkChart = defineAsyncComponent(() => import('./PkChart.vue'))\n\n /**\n * One chart of `showChart` (spec `chat-charts.md`) in its card: the chart,\n * the same numbers as a table, \"Copy data\" for a sheet and the chart as a\n * PNG.\n */\n const props = defineProps<{\n chart: Chart\n /** A note below the chart, e.g. the source of the numbers. */\n caption?: string\n isDark?: boolean\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const icon = computed(() => {\n switch (props.chart.type) {\n case 'line':\n return 'ri:line-chart-line'\n case 'pie':\n return 'ri:pie-chart-line'\n case 'doughnut':\n return 'ri:donut-chart-line'\n default:\n return props.chart.horizontal\n ? 'ri:bar-chart-horizontal-line'\n : 'ri:bar-chart-2-line'\n }\n })\n\n const showTable = ref(false)\n const format = computed(() =>\n chartValueFormatter(locale.value, props.chart.format),\n )\n\n const chartRef = useTemplateRef<{ toBlob: () => Promise<Blob | null> }>(\n 'chartRef',\n )\n const downloadPng = async () => {\n const blob = await chartRef.value?.toBlob()\n if (!blob) {\n return\n }\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(props.chart.title || 'chart')}.png`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n</script>\n\n<template>\n <div\n class=\"pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"icon\" class=\"text-16 shrink-0\" />\n <strong class=\"font-bold truncate\">\n {{ chart.title || $t('label.chart') }}\n </strong>\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"pk-chart-card__actions ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"showTable ? icon : 'ri:table-line'\"\n :label=\"\n showTable\n ? $t('chart.showChart')\n : $t('chart.showTable')\n \"\n @click=\"showTable = !showTable\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('chart.copyData')\"\n @click=\"copy(chartAsTsv(chart, locale))\" />\n <VvButton\n v-if=\"!showTable\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n :title=\"$t('chart.downloadPng')\"\n @click=\"downloadPng\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"showTable\" class=\"pk-chart-card__table-wrap\">\n <table class=\"pk-chart-card__table text-12\">\n <thead>\n <tr>\n <th scope=\"col\">{{ chart.categoryLabel ?? '' }}</th>\n <th\n v-for=\"series in chart.series\"\n :key=\"series.name\"\n scope=\"col\">\n {{ series.name }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(category, i) in chart.categories\" :key=\"i\">\n <th scope=\"row\">{{ category }}</th>\n <td v-for=\"series in chart.series\" :key=\"series.name\">\n {{ format(series.values[i] ?? null) }}\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <div v-else class=\"pk-chart-card__stage px-sm py-sm\">\n <PkChart ref=\"chartRef\" :chart :is-dark />\n </div>\n <div\n v-if=\"caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart-card {\n // A container for the narrow card below. It is also the containing\n // block of any `position: fixed` inside it, so a menu added here\n // must open in the top layer (docs/agents/gotchas/frontend.md, \"The\n // chat measures its own width\"): today the card has none.\n container-type: inline-size;\n\n // On a narrow card the actions keep their icon and lose the word on\n // screen, still read by a screen reader: the title keeps the room\n // (at 390px it was cut to \"Fattori di ...\")\n @container (width < 30rem) {\n &__actions .vv-button__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n }\n\n // A fixed stage, as the diagram's: the chart loads in a chunk of its\n // own, and loader and chart must take the same room or the chat's\n // scroll jumps\n &__stage {\n height: 320px;\n }\n\n &__table-wrap {\n max-height: 320px;\n overflow: auto;\n }\n\n &__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-6) var(--spacing-sm);\n border-bottom: 1px solid var(--color-surface-3);\n text-align: right;\n white-space: nowrap;\n }\n\n th:first-child {\n text-align: left;\n white-space: normal;\n }\n\n thead th {\n color: var(--color-word-3);\n font-weight: 600;\n }\n\n tbody th {\n color: var(--color-word-2);\n font-weight: 400;\n }\n\n td {\n color: var(--color-word);\n font-variant-numeric: tabular-nums;\n }\n\n tbody tr:last-child > * {\n border-bottom: 0;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed, defineAsyncComponent, ref, useTemplateRef } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import type { Chart } from 'models'\n import { toSnakeCase } from 'utils'\n import { chartAsTsv, chartValueFormatter } from './chartFormat'\n\n // Chart.js comes with it: a separate chunk, loaded with the first chart\n const PkChart = defineAsyncComponent(() => import('./PkChart.vue'))\n\n /**\n * One chart of `showChart` (spec `chat-charts.md`) in its card: the chart,\n * the same numbers as a table, \"Copy data\" for a sheet and the chart as a\n * PNG.\n */\n const props = defineProps<{\n chart: Chart\n /** A note below the chart, e.g. the source of the numbers. */\n caption?: string\n isDark?: boolean\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n const { copy, copied } = useClipboard()\n\n const icon = computed(() => {\n switch (props.chart.type) {\n case 'line':\n return 'ri:line-chart-line'\n case 'pie':\n return 'ri:pie-chart-line'\n case 'doughnut':\n return 'ri:donut-chart-line'\n default:\n return props.chart.horizontal\n ? 'ri:bar-chart-horizontal-line'\n : 'ri:bar-chart-2-line'\n }\n })\n\n const showTable = ref(false)\n const format = computed(() =>\n chartValueFormatter(locale.value, props.chart.format),\n )\n\n const chartRef = useTemplateRef<{ toBlob: () => Promise<Blob | null> }>(\n 'chartRef',\n )\n const downloadPng = async () => {\n const blob = await chartRef.value?.toBlob()\n if (!blob) {\n return\n }\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(props.chart.title || 'chart')}.png`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n</script>\n\n<template>\n <div\n class=\"pk-chart-card border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"icon\" class=\"text-16 shrink-0\" />\n <strong class=\"font-bold truncate\">\n {{ chart.title || $t('label.chart') }}\n </strong>\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"pk-chart-card__actions ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"showTable ? icon : 'ri:table-line'\"\n :label=\"\n showTable\n ? $t('chart.showChart')\n : $t('chart.showTable')\n \"\n @click=\"showTable = !showTable\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('chart.copyData')\"\n @click=\"copy(chartAsTsv(chart, locale))\" />\n <VvButton\n v-if=\"!showTable\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n :title=\"$t('chart.downloadPng')\"\n @click=\"downloadPng\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"showTable\" class=\"pk-chart-card__table-wrap\">\n <table class=\"pk-chart-card__table text-12\">\n <thead>\n <tr>\n <th scope=\"col\">{{ chart.categoryLabel ?? '' }}</th>\n <th\n v-for=\"series in chart.series\"\n :key=\"series.name\"\n scope=\"col\">\n {{ series.name }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(category, i) in chart.categories\" :key=\"i\">\n <th scope=\"row\">{{ category }}</th>\n <td v-for=\"series in chart.series\" :key=\"series.name\">\n {{ format(series.values[i] ?? null) }}\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n <div v-else class=\"pk-chart-card__stage px-sm py-sm\">\n <PkChart ref=\"chartRef\" :chart :is-dark />\n </div>\n <div\n v-if=\"caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chart-card {\n // A container for the narrow card below. It is also the containing\n // block of any `position: fixed` inside it, so a menu added here\n // must open in the top layer (docs/agents/gotchas/frontend.md, \"The\n // chat measures its own width\"): today the card has none.\n container-type: inline-size;\n\n // On a narrow card the actions keep their icon and lose the word on\n // screen, still read by a screen reader: the title keeps the room\n // (at 390px it was cut to \"Fattori di ...\")\n @container (width < 30rem) {\n &__actions .vv-button__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n }\n\n // A fixed stage, as the diagram's: the chart loads in a chunk of its\n // own, and loader and chart must take the same room or the chat's\n // scroll jumps\n &__stage {\n height: 320px;\n }\n\n &__table-wrap {\n max-height: 320px;\n overflow: auto;\n }\n\n &__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-6) var(--spacing-sm);\n border-bottom: 1px solid var(--color-surface-3);\n text-align: right;\n white-space: nowrap;\n }\n\n th:first-child {\n text-align: left;\n white-space: normal;\n }\n\n thead th {\n color: var(--color-word-3);\n font-weight: 600;\n }\n\n tbody th {\n color: var(--color-word-2);\n font-weight: 400;\n }\n\n td {\n color: var(--color-word);\n font-variant-numeric: tabular-nums;\n }\n\n tbody tr:last-child > * {\n border-bottom: 0;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { ShowChartInputSchema } from 'models'\n import PkChartCard from './PkChartCard.vue'\n\n /**\n * The cards of `showChart` (spec `chat-charts.md`): every chart of the\n * call in its own card, one under the other, the caption under the last.\n */\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const toolPart = computed(\n () => props.part as { state?: string; input?: unknown },\n )\n // A half-written input has series shorter than the categories\n const streaming = computed(() => toolPart.value.state === 'input-streaming')\n // A call the tool refused for its input: the model reads why and calls\n // again, and the corrected chart follows it. Nothing to show here.\n const refused = computed(() => toolPart.value.state === 'output-error')\n /** The input as the tool validated it; a stored one that is not stays a message. */\n const input = computed(() => {\n if (streaming.value) {\n return undefined\n }\n const parsed = ShowChartInputSchema.safeParse(toolPart.value.input)\n return parsed.success ? parsed.data : undefined\n })\n</script>\n\n<template>\n <div v-if=\"input\" class=\"flex flex-col gap-sm w-full\">\n <PkChartCard\n v-for=\"(chart, i) in input.charts\"\n :key=\"i\"\n :chart\n :caption=\"i === input.charts.length - 1 ? input.caption : undefined\"\n :is-dark />\n </div>\n <div\n v-else-if=\"streaming\"\n class=\"pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center\">\n <VvIcon name=\"loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-else-if=\"!refused\"\n class=\"border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm\">\n {{ $t('message.chartRenderError') }}\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-chart {\n // The height of a card while the call is written: the card that\n // replaces it takes about as much, and the chat's scroll stays put\n &__loading {\n height: 360px;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { ShowChartInputSchema } from 'models'\n import PkChartCard from './PkChartCard.vue'\n\n /**\n * The cards of `showChart` (spec `chat-charts.md`): every chart of the\n * call in its own card, one under the other, the caption under the last.\n */\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const toolPart = computed(\n () => props.part as { state?: string; input?: unknown },\n )\n // A half-written input has series shorter than the categories\n const streaming = computed(() => toolPart.value.state === 'input-streaming')\n // A call the tool refused for its input: the model reads why and calls\n // again, and the corrected chart follows it. Nothing to show here.\n const refused = computed(() => toolPart.value.state === 'output-error')\n /** The input as the tool validated it; a stored one that is not stays a message. */\n const input = computed(() => {\n if (streaming.value) {\n return undefined\n }\n const parsed = ShowChartInputSchema.safeParse(toolPart.value.input)\n return parsed.success ? parsed.data : undefined\n })\n</script>\n\n<template>\n <div v-if=\"input\" class=\"flex flex-col gap-sm w-full\">\n <PkChartCard\n v-for=\"(chart, i) in input.charts\"\n :key=\"i\"\n :chart\n :caption=\"i === input.charts.length - 1 ? input.caption : undefined\"\n :is-dark />\n </div>\n <div\n v-else-if=\"streaming\"\n class=\"pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center\">\n <VvIcon name=\"loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-else-if=\"!refused\"\n class=\"border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm\">\n {{ $t('message.chartRenderError') }}\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-chart {\n // The height of a card while the call is written: the card that\n // replaces it takes about as much, and the chat's scroll stays put\n &__loading {\n height: 360px;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { ShowChartInputSchema } from 'models'\n import PkChartCard from './PkChartCard.vue'\n\n /**\n * The cards of `showChart` (spec `chat-charts.md`): every chart of the\n * call in its own card, one under the other, the caption under the last.\n */\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const toolPart = computed(\n () => props.part as { state?: string; input?: unknown },\n )\n // A half-written input has series shorter than the categories\n const streaming = computed(() => toolPart.value.state === 'input-streaming')\n // A call the tool refused for its input: the model reads why and calls\n // again, and the corrected chart follows it. Nothing to show here.\n const refused = computed(() => toolPart.value.state === 'output-error')\n /** The input as the tool validated it; a stored one that is not stays a message. */\n const input = computed(() => {\n if (streaming.value) {\n return undefined\n }\n const parsed = ShowChartInputSchema.safeParse(toolPart.value.input)\n return parsed.success ? parsed.data : undefined\n })\n</script>\n\n<template>\n <div v-if=\"input\" class=\"flex flex-col gap-sm w-full\">\n <PkChartCard\n v-for=\"(chart, i) in input.charts\"\n :key=\"i\"\n :chart\n :caption=\"i === input.charts.length - 1 ? input.caption : undefined\"\n :is-dark />\n </div>\n <div\n v-else-if=\"streaming\"\n class=\"pk-tool-show-chart__loading border border-surface-3 rounded-xl w-full flex justify-center items-center\">\n <VvIcon name=\"loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-else-if=\"!refused\"\n class=\"border border-surface-3 rounded-xl w-full text-12 text-danger py-8 px-sm\">\n {{ $t('message.chartRenderError') }}\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-chart {\n // The height of a card while the call is written: the card that\n // replaces it takes about as much, and the chat's scroll stays put\n &__loading {\n height: 360px;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;AAQA,IAAauE,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,IAAoB9E,EAAS;CACtC,MAAMC,EACM,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI4E,CAAS,CAAC,CACd,SAAS,kCAAkC;CAChD,QAAQ3E,EACGC,EAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAC5B,IAAIuE,EAAa,aAAa,CAAC,CAC/B,SAAS,2DAA2D;CACzE,MAAMtE,EACIoE,CAAW,CAAC,CACjB,SAAS,CAAC,CACV,SACG,yFACJ;AACR,CAAC,GAuHYO,IAhHoB/E,EAAS;CACtC,MAAMI,EACImE,CAAW,CAAC,CACjB,SACG,iGACJ;CACJ,OAAOtE,EACK,CAAC,CACR,IAAI,GAAG,CAAC,CACR,SAAS,CAAC,CACV,SAAS,6BAA6B;CAC3C,YAAYI,EACC,CAAC,CACT,SAAS,CAAC,CACV,SAAS,4DAA4D;CAC1E,SAASA,EACI,CAAC,CACT,SAAS,CAAC,CACV,SAAS,wDAAwD;CAEtE,YAAYH,EACDD,EAAS,CAAC,CAAC,IAAI4E,CAAS,CAAC,CAA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,OAAAD,EAAA,SAAX3G,EAAA,GAAAC,EAOM,OAPNmG,IAOM,EANFpG,EAAA,EAAA,GAAAC,EAKeC,GAAA,MAAAC,EAJUwG,EAAA,MAAM,SAAnB,GAAO,OADnB3G,EAAA,GAAAI,EAKeC,GAAA;IAHV,KAAKsD;IACL;IACA,SAASA,MAAMgD,EAAA,MAAM,OAAO,SAAM,IAAOA,EAAA,MAAM,UAAU,KAAA;IACzD,WAAAtB,EAAA;;;;;G,iBAGMoB,EAAA,SADfzG,EAAA,GAAAC,EAIM,OAJNoG,IAIM,CADF/F,EAA4DwF,GAAA;IAApD,MAAK;IAAe,OAAM;G,QAGtBY,EAAA,Q,aADhB1G,EAAA,GAAAC,EAIM,OAJNqG,IAIM/F,EADCT,EAAAA,GAAE,0BAAA,CAAA,GAAA,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"excelNumberFormat-BhQjife9.js","names":["z.object","z.number","z.enum","z.string","z.literal","z.array","z.discriminatedUnion","z.boolean","z.record","z.object","z.string","z.number","z.literal","z.enum","z.union","z.boolean","z.array","z.discriminatedUnion","object","string","number","array","literal","_enum","boolean","discriminatedUnion","union","record","WordPreviewAnchorSchema","WordPreviewPictureSchema","WordPreviewRunSchema","WordPreviewParagraphStyleSchema","WordPreviewCellSchema","sectionStart","WordPreviewBlockSchema","WordPreviewPageSchema","WordPreviewPartsOfSectionSchema","WordPreviewSectionSchema","WordPreviewSchema","SpreadsheetPreviewBorderSchema","SpreadsheetPreviewStyleSchema","SpreadsheetPreviewCellSchema","SpreadsheetPreviewRowSchema","SpreadsheetPreviewColumnSchema","SpreadsheetPreviewSheetSchema","SpreadsheetPreviewSchema","isSpreadsheetDateFormat","code","COLORS","sectionsOf","out","current","i","ch","close","stop","parseSection","tokens","section","text","last","t","source","end","inner","condition","symbol","satisfies","op","value","than","sectionFor","first","second","third","sections","memo","kept","key","make","limit","numberFormats","intlNumber","locale","options","formatDecimal","format","x","partsOfDecimal","separatorsOf","marksOf","parts","p","textOf","MAX_DECIMALS","layInteger","chars","digits","slots","pattern","taken","laid","group","run","layFraction","convergent","p0","q0","p1","q1","rest","a","p2","q2","most","left","parsedSections","sectionsFor","formatExcelNumber","tint","signed","minus","shown","n","general","at","before","scaled","exponentAt","mantissa","pointAt","whole","fraction","plus","width","m","decimal","power","slash","gap","top","below","fixed","found","units","q","wholeText","intEnd","scale","intTokens","grouped","u","places","decimals","LCIDS","SYSTEM_DATES","parseDate","lower","elapsed","tag","k","size","short","part","after","parsedDates","dayOf","date1904","days","d","date","dateFormats","nameOf","LAST_SERIAL","formatExcelDate","serial","sources","chosen","tagged","names","ampm","unit","total","within","day","hour","minute","weekdayAt","pad","excelDateText","written","raw"],"sources":["../../../../packages/models/src/schema/WordPreview.ts","../../../../packages/models/src/schema/SpreadsheetPreview.ts","../../../../packages/components/src/chat/excelNumberFormat.ts"],"sourcesContent":["import * as z from 'zod'\n\n// The preview of a Word document stored in a chat (spec `chat-office-files.md`,\n// F6, item 3, and the viewer of its follow-ups): typed blocks the server\n// reads from the document, with the look its styles give them, and the size\n// of its page, its headers, footers and images. The chat draws them as text,\n// never as HTML, and the images as `<img>` of WebP the server wrote, so a\n// document someone uploaded cannot inject markup into the page.\n\n/**\n * Where an image anchored to the page or to a paragraph sits, in points, and\n * how the text goes around it: under or over it, beside it, or above and\n * below it.\n */\nexport const WordPreviewAnchorSchema = z.object({\n x: z.number(),\n y: z.number(),\n /** What `x` counts from: the page's edge or the left margin. */\n xFrom: z.enum(['page', 'margin']),\n /** What `y` counts from: the page's edge, the top margin or the paragraph. */\n yFrom: z.enum(['page', 'margin', 'paragraph']),\n wrap: z.enum(['behind', 'front', 'around', 'block']),\n})\n\n/** An image the preview draws, its size in points. */\nexport const WordPreviewPictureSchema = z.object({\n /** Its key in the preview's `images`. */\n ref: z.string(),\n width: z.number(),\n height: z.number(),\n /** Set for an image Word positions itself; one in the text has none. */\n anchor: WordPreviewAnchorSchema.optional(),\n})\n\nexport const WordPreviewRunSchema = z.object({\n text: z.string(),\n /** A tracked change not accepted yet, and who made it. */\n change: z.enum(['inserted', 'deleted']).optional(),\n author: z.string().optional(),\n bold: z.literal(true).optional(),\n italic: z.literal(true).optional(),\n underline: z.literal(true).optional(),\n strike: z.literal(true).optional(),\n caps: z.literal(true).optional(),\n vertAlign: z.enum(['super', 'sub']).optional(),\n /** Font, size in points and `#rrggbb` color, where not the document's. */\n font: z.string().optional(),\n size: z.number().optional(),\n color: z.string().optional(),\n /** The highlighter's color, `#rrggbb`. */\n highlight: z.string().optional(),\n /** Stands for an image, a chart or an object. */\n image: z.literal(true).optional(),\n /** The image itself, when the preview draws it; otherwise a placeholder. */\n picture: WordPreviewPictureSchema.optional(),\n /** The result of a page number field, written again on each page. */\n field: z.enum(['page', 'pages', 'sectionPages']).optional(),\n /** The number or bullet of a list item in a cell: Word's, not the text's. */\n label: z.literal(true).optional(),\n})\n\n/** How a paragraph sits on the page; lengths in points. */\nexport const WordPreviewParagraphStyleSchema = z.object({\n align: z.enum(['left', 'center', 'right', 'justify']).optional(),\n indentLeft: z.number().optional(),\n indentRight: z.number().optional(),\n /** The first line's indent; negative for a hanging one. */\n firstLine: z.number().optional(),\n spaceBefore: z.number().optional(),\n spaceAfter: z.number().optional(),\n /**\n * Line height as a multiple of the font's, `lineExact` points, or at\n * least `lineAtLeast` points (Word's \"At least\").\n */\n lineHeight: z.number().optional(),\n lineExact: z.number().optional(),\n lineAtLeast: z.number().optional(),\n /** Starts on a new page: a page break or the paragraph's setting. */\n pageBreakBefore: z.literal(true).optional(),\n /** Stays on the page of the block after it (Word's \"Keep with next\"). */\n keepNext: z.literal(true).optional(),\n /** The paragraph's shading, `#rrggbb`. */\n shading: z.string().optional(),\n /**\n * The size of its paragraph mark in points, where not the document's:\n * the height of a blank line, and the least of each line.\n */\n size: z.number().optional(),\n})\n\nexport const WordPreviewCellSchema = z.object({\n runs: z.array(WordPreviewRunSchema),\n /** The grid columns a merged cell spans, when more than one. */\n span: z.number().optional(),\n /** The cell's shading, `#rrggbb`. */\n fill: z.string().optional(),\n /** How its first paragraph is aligned, when not to the left. */\n align: z.enum(['left', 'center', 'right', 'justify']).optional(),\n /** The size of its first paragraph's mark, where not the document's. */\n size: z.number().optional(),\n /** A paragraph of it keeps its row with the next one. */\n keepNext: z.literal(true).optional(),\n /** The ids of the paragraphs it draws, as `readWordDocument` names them. */\n ids: z.array(z.string()).optional(),\n})\n\n/** The first block of a section after the first: its index in `sections`. */\nconst sectionStart = z.number().optional()\n\nexport const WordPreviewBlockSchema = z.discriminatedUnion('kind', [\n z.object({\n kind: z.literal('heading'),\n /** The paragraph's id, as `readWordDocument` names it. */\n id: z.string().optional(),\n /** 0 for the title, then the outline level from 1. */\n level: z.number(),\n /** The number Word draws before a numbered heading (\"1.\", \"Art. 2\"). */\n label: z.string().optional(),\n runs: z.array(WordPreviewRunSchema),\n style: WordPreviewParagraphStyleSchema.optional(),\n section: sectionStart,\n }),\n z.object({\n kind: z.literal('paragraph'),\n /** The paragraph's id, as `readWordDocument` names it. */\n id: z.string().optional(),\n /** The number or bullet Word draws before a list item. */\n label: z.string().optional(),\n runs: z.array(WordPreviewRunSchema),\n style: WordPreviewParagraphStyleSchema.optional(),\n section: sectionStart,\n }),\n z.object({\n kind: z.literal('table'),\n /** Rows of cells, each cell its paragraphs' runs. */\n rows: z.array(z.array(WordPreviewCellSchema)),\n /** The widths of the grid's columns in points, when the file says. */\n widths: z.array(z.number()).optional(),\n /** The table draws lines between its cells. */\n borders: z.boolean(),\n /** Starts on a new page. */\n pageBreakBefore: z.literal(true).optional(),\n section: sectionStart,\n }),\n])\n\n/** The page of the document's first section, in points. */\nexport const WordPreviewPageSchema = z.object({\n width: z.number(),\n height: z.number(),\n margins: z.object({\n top: z.number(),\n right: z.number(),\n bottom: z.number(),\n left: z.number(),\n }),\n})\n\n/** The headers or the footers of a section: keys in the preview's `parts`. */\nconst WordPreviewPartsOfSectionSchema = z.object({\n default: z.string().optional(),\n /** On the section's first page, when it has a different one. */\n first: z.string().optional(),\n /** On even pages, when the document has different ones. */\n even: z.string().optional(),\n})\n\n/** A section of the body: its page, its header and footer, its numbering. */\nexport const WordPreviewSectionSchema = z.object({\n page: WordPreviewPageSchema,\n /** From the page's top edge to the header, from the bottom to the footer. */\n headerDistance: z.number(),\n footerDistance: z.number(),\n headers: WordPreviewPartsOfSectionSchema,\n footers: WordPreviewPartsOfSectionSchema,\n /** Its first page takes the `first` header and footer. */\n titlePage: z.literal(true).optional(),\n /** The number of its first page, when it restarts the count. */\n pageStart: z.number().optional(),\n})\n\nexport const WordPreviewSchema = z.object({\n kind: z.literal('word'),\n blocks: z.array(WordPreviewBlockSchema),\n /** The body went on past what a preview shows. */\n truncated: z.boolean(),\n /** Whose tracked changes the document holds, for the legend. */\n revisionAuthors: z.array(z.string()),\n page: WordPreviewPageSchema,\n /** The font, size and color of the document's normal text. */\n defaults: z.object({\n font: z.string(),\n size: z.number(),\n color: z.string().optional(),\n }),\n /** The sections of the body in order; the first one holds `page`. */\n sections: z.array(WordPreviewSectionSchema).optional(),\n /** The headers and footers the sections use, as blocks, by part. */\n parts: z.record(z.string(), z.array(WordPreviewBlockSchema)).optional(),\n /** Even pages take the `even` header and footer. */\n evenAndOddHeaders: z.literal(true).optional(),\n /** The images the runs draw, by `ref`: `data:image/webp` URIs. */\n images: z.record(z.string(), z.string()).optional(),\n})\n\nexport type WordPreviewAnchor = z.infer<typeof WordPreviewAnchorSchema>\nexport type WordPreviewPicture = z.infer<typeof WordPreviewPictureSchema>\nexport type WordPreviewSection = z.infer<typeof WordPreviewSectionSchema>\nexport type WordPreviewRun = z.infer<typeof WordPreviewRunSchema>\nexport type WordPreviewParagraphStyle = z.infer<\n typeof WordPreviewParagraphStyleSchema\n>\nexport type WordPreviewCell = z.infer<typeof WordPreviewCellSchema>\nexport type WordPreviewBlock = z.infer<typeof WordPreviewBlockSchema>\nexport type WordPreviewPage = z.infer<typeof WordPreviewPageSchema>\nexport type WordPreview = z.infer<typeof WordPreviewSchema>\n","import * as z from 'zod'\nimport { WordPreviewSchema } from './WordPreview'\n\n// The preview of a spreadsheet stored in a chat (spec `chat-office-files.md`,\n// F6, item 4, and the viewer of its follow-ups): the rows of each sheet as\n// typed cells with the look the file gives them, which the chat draws as a\n// grid with Excel's column letters and row numbers, and formats in the\n// reader's language.\n\n/** One side of a cell's border: its color and its width in pixels. */\nexport const SpreadsheetPreviewBorderSchema = z.object({\n color: z.string(),\n width: z.number(),\n})\n\n/**\n * The look of a cell as the file sets it. Colors are `#rrggbb`, resolved\n * from the theme and the palette. The cells name a style by its index.\n */\nexport const SpreadsheetPreviewStyleSchema = z.object({\n bold: z.literal(true).optional(),\n italic: z.literal(true).optional(),\n underline: z.literal(true).optional(),\n strike: z.literal(true).optional(),\n /** Font size in points, when not the sheet's 11. */\n size: z.number().optional(),\n color: z.string().optional(),\n fill: z.string().optional(),\n align: z.enum(['left', 'center', 'right']).optional(),\n valign: z.enum(['top', 'middle']).optional(),\n wrap: z.literal(true).optional(),\n /** Indent steps of the alignment, about three characters each. */\n indent: z.number().optional(),\n borders: z\n .object({\n top: SpreadsheetPreviewBorderSchema.optional(),\n right: SpreadsheetPreviewBorderSchema.optional(),\n bottom: SpreadsheetPreviewBorderSchema.optional(),\n left: SpreadsheetPreviewBorderSchema.optional(),\n })\n .optional(),\n})\n\nexport const SpreadsheetPreviewCellSchema = z.object({\n /** Its column, from 1 for A. */\n col: z.number(),\n /** Absent for an empty cell. A date is `YYYY-MM-DD`. */\n value: z.union([z.string(), z.number(), z.boolean()]).optional(),\n format: z.enum(['currency', 'percent', 'date', 'error']).optional(),\n /** Decimals the cell's number format shows. */\n decimals: z.number().optional(),\n /** Decimals it shows at most, when some are optional (`0.0#`). */\n maxDecimals: z.number().optional(),\n /** ISO code of a currency format: EUR, USD, GBP, CAD. */\n currency: z.string().optional(),\n /** Its number format separates the thousands (`#,##0`). */\n grouped: z.literal(true).optional(),\n /**\n * Index of its number format in the preview's `numberFormats`, for a\n * number or a date; the fields above describe the same format to an\n * older client.\n */\n numFmt: z.number().optional(),\n /**\n * A date or a time as the workbook holds it: days since its day 0, in\n * its date system (`date1904` of the preview).\n */\n serial: z.number().optional(),\n /** A formula whose result the file does not hold yet. */\n missing: z.literal(true).optional(),\n /** The formula as Excel shows it in its bar, without the `=`. */\n formula: z.string().optional(),\n /** Index of its look in the preview's `styles`. */\n style: z.number().optional(),\n /** The first cell of merged cells: the rows and columns they cover. */\n span: z.object({ rows: z.number(), cols: z.number() }).optional(),\n})\n\nexport const SpreadsheetPreviewRowSchema = z.object({\n /** Its number, from 1: hidden rows are left out. */\n row: z.number(),\n /** In pixels, when not the default. */\n height: z.number().optional(),\n /** The cells that hold something or have a look, by column. */\n cells: z.array(SpreadsheetPreviewCellSchema),\n})\n\nexport const SpreadsheetPreviewColumnSchema = z.object({\n col: z.number(),\n /** In pixels, when not the default. */\n width: z.number().optional(),\n hidden: z.literal(true).optional(),\n})\n\nexport const SpreadsheetPreviewSheetSchema = z.object({\n name: z.string(),\n rows: z.array(SpreadsheetPreviewRowSchema),\n /** The columns whose width the file sets. */\n columns: z.array(SpreadsheetPreviewColumnSchema),\n /** The rows Excel hides, which the grid skips as Excel does. */\n hiddenRows: z.array(z.number()).optional(),\n /** The last row and column the preview shows. */\n lastRow: z.number(),\n lastColumn: z.number(),\n /** Rows and columns frozen at the top and at the left. */\n frozen: z.object({ rows: z.number(), cols: z.number() }).optional(),\n /** Excel draws the grid lines of the sheet. */\n gridlines: z.boolean(),\n /** Rows and columns past what the preview shows. */\n moreRows: z.number(),\n moreColumns: z.number(),\n})\n\nexport const SpreadsheetPreviewSchema = z.object({\n kind: z.literal('spreadsheet'),\n sheets: z.array(SpreadsheetPreviewSheetSchema),\n styles: z.array(SpreadsheetPreviewStyleSchema),\n /** The number format codes the cells name by `numFmt` (`#,##0.00 \"€\"`). */\n numberFormats: z.array(z.string()).optional(),\n /** The workbook counts its dates from 1904, as some Mac files do. */\n date1904: z.literal(true).optional(),\n /** Formula results old or missing until Excel opens the file. */\n staleFormulas: z.boolean(),\n /** Formula results computed in the chat, which Excel computes again. */\n computedFormulas: z.boolean(),\n})\n\n/** What the preview route answers, by the kind of file. */\nexport const ChatFilePreviewSchema = z.discriminatedUnion('kind', [\n WordPreviewSchema,\n SpreadsheetPreviewSchema,\n])\n\n/**\n * An Excel number format of dates or times: outside its text, its colors\n * and its locale tags it names days, months, years, hours, minutes or\n * seconds (`dd/mm/yyyy`, `hh:mm`, `[h]:mm`).\n */\nexport const isSpreadsheetDateFormat = (code: string): boolean =>\n /[dmyhs]|am\\/pm|a\\/p/i.test(\n code.replace(/\"[^\"]*\"|\\\\.|\\[(?![hms]+\\])[^\\]]*\\]/gi, ''),\n )\n\nexport type SpreadsheetPreviewBorder = z.infer<\n typeof SpreadsheetPreviewBorderSchema\n>\nexport type SpreadsheetPreviewStyle = z.infer<\n typeof SpreadsheetPreviewStyleSchema\n>\nexport type SpreadsheetPreviewCell = z.infer<\n typeof SpreadsheetPreviewCellSchema\n>\nexport type SpreadsheetPreviewRow = z.infer<typeof SpreadsheetPreviewRowSchema>\nexport type SpreadsheetPreviewColumn = z.infer<\n typeof SpreadsheetPreviewColumnSchema\n>\nexport type SpreadsheetPreviewSheet = z.infer<\n typeof SpreadsheetPreviewSheetSchema\n>\nexport type SpreadsheetPreview = z.infer<typeof SpreadsheetPreviewSchema>\nexport type ChatFilePreview = z.infer<typeof ChatFilePreviewSchema>\n","/**\n * A number as Excel shows it under a number format code (`#,##0.00 \"€\"`,\n * `#,##0;[Red](#,##0)`, `0.0,\"k\"`), with the reader's separators: the\n * section for the value's sign or condition, its literal text, its color,\n * grouping, decimals, percent, thousands scaling, leading zeros, digits\n * mixed with text (`000-000`), fractions and scientific notation; and a date\n * or a time in the order, digits and names its code writes. Checked cell by\n * cell against Excel for Mac (the widget's `excelNumberFormat.test.ts`).\n */\n\n/** Excel's eight color names, as a number format writes them. */\nconst COLORS: Record<string, string> = {\n black: '#000000',\n blue: '#0000ff',\n cyan: '#00ffff',\n green: '#00ff00',\n magenta: '#ff00ff',\n red: '#ff0000',\n white: '#ffffff',\n yellow: '#ffff00',\n}\n\ntype Token =\n | { kind: 'digit'; char: '0' | '#' | '?' }\n | { kind: 'point' }\n | { kind: 'comma' }\n | { kind: 'percent' }\n | { kind: 'exponent'; plus: boolean }\n | { kind: 'text'; text: string }\n | { kind: 'general' }\n\ntype Section = {\n tokens: Token[]\n color?: string\n condition?: { op: string; than: number }\n}\n\n/** The code's sections, split outside quotes, escapes and brackets. */\nconst sectionsOf = (code: string): string[] => {\n const out: string[] = []\n let current = ''\n for (let i = 0; i < code.length; i++) {\n const ch = code[i]\n const close =\n ch === '\"'\n ? code.indexOf('\"', i + 1)\n : ch === '['\n ? code.indexOf(']', i)\n : -2\n if (close !== -2) {\n const stop = close === -1 ? code.length : close\n current += code.slice(i, stop + 1)\n i = stop\n } else if (ch === '\\\\' || ch === '_' || ch === '*') {\n current += code.slice(i, i + 2)\n i++\n } else if (ch === ';') {\n out.push(current)\n current = ''\n } else {\n current += ch\n }\n }\n return [...out, current]\n}\n\n/** The tokens of one section, with its color and condition. */\nconst parseSection = (source: string): Section => {\n const tokens: Token[] = []\n const section: Section = { tokens }\n const text = (t: string) => {\n const last = tokens[tokens.length - 1]\n if (last?.kind === 'text') {\n last.text += t\n } else if (t) {\n tokens.push({ kind: 'text', text: t })\n }\n }\n for (let i = 0; i < source.length; i++) {\n const ch = source[i]\n if (ch === '\"') {\n const end = source.indexOf('\"', i + 1)\n const stop = end === -1 ? source.length : end\n text(source.slice(i + 1, stop))\n i = stop\n } else if (ch === '\\\\') {\n text(source[i + 1] ?? '')\n i++\n } else if (ch === '_') {\n // Room for a character: a space comes near enough\n text(' ')\n i++\n } else if (ch === '*') {\n // A character repeated across the column: once is enough here\n text(source[i + 1] ?? '')\n i++\n } else if (ch === '[') {\n const end = source.indexOf(']', i)\n const inner = source.slice(i + 1, end === -1 ? undefined : end)\n i = end === -1 ? source.length : end\n const condition = /^(<=|>=|<>|<|>|=)\\s*(-?[\\d.]+)$/.exec(inner)\n const symbol = /^\\$([^-]*)(?:-[0-9a-f]+)?$/i.exec(inner)\n if (condition) {\n section.condition = {\n op: condition[1],\n than: Number(condition[2]),\n }\n } else if (COLORS[inner.toLowerCase()]) {\n section.color = COLORS[inner.toLowerCase()]\n } else if (symbol) {\n text(symbol[1])\n }\n // `[Color10]`, `[h]` and the like draw nothing here\n } else if (ch === '0' || ch === '#' || ch === '?') {\n tokens.push({ kind: 'digit', char: ch })\n } else if (ch === '.') {\n tokens.push({ kind: 'point' })\n } else if (ch === ',') {\n tokens.push({ kind: 'comma' })\n } else if (ch === '%') {\n tokens.push({ kind: 'percent' })\n text('%')\n } else if (/[eE][+-]/.test(source.slice(i, i + 2))) {\n tokens.push({ kind: 'exponent', plus: source[i + 1] === '+' })\n i++\n } else if (/^general/i.test(source.slice(i, i + 7))) {\n tokens.push({ kind: 'general' })\n i += 6\n } else if (ch === '@') {\n // A number under the text format shows as General\n tokens.push({ kind: 'general' })\n } else {\n text(ch)\n }\n }\n return section\n}\n\nconst satisfies = (\n value: number,\n { op, than }: { op: string; than: number },\n): boolean =>\n op === '<'\n ? value < than\n : op === '<='\n ? value <= than\n : op === '>'\n ? value > than\n : op === '>='\n ? value >= than\n : op === '='\n ? value === than\n : value !== than\n\n/**\n * The section that shows `value`, and whether Excel writes the minus sign\n * itself: not in the section for negatives, nor in one a condition chose,\n * whose own text carries the sign.\n */\nconst sectionFor = (\n sections: Section[],\n value: number,\n): { section: Section; minus: boolean } => {\n const [first, second, third] = sections\n if (first.condition || second?.condition) {\n if (first.condition && satisfies(value, first.condition)) {\n return { section: first, minus: false }\n }\n if (second?.condition && satisfies(value, second.condition)) {\n return { section: second, minus: false }\n }\n const rest = third ?? (second && !second.condition ? second : first)\n return { section: rest, minus: value < 0 }\n }\n if (value < 0 && second) {\n return { section: second, minus: false }\n }\n if (value === 0 && third) {\n return { section: third, minus: false }\n }\n return { section: first, minus: value < 0 }\n}\n\n/** Kept results that a grid asks for again and again, emptied past a size. */\nconst memo = <T>(limit = 2000) => {\n const kept = new Map<string, T>()\n return (key: string, make: () => T): T => {\n let value = kept.get(key)\n if (value === undefined) {\n value = make()\n if (kept.size >= limit) {\n kept.clear()\n }\n kept.set(key, value)\n }\n return value\n }\n}\n\nconst numberFormats = memo<Intl.NumberFormat>()\nconst intlNumber = (locale: string, options: Intl.NumberFormatOptions) =>\n numberFormats(\n `${locale}|${JSON.stringify(options)}`,\n () => new Intl.NumberFormat(locale, options),\n )\n\n/**\n * `x` formatted from its 15 significant digits, as Excel holds a number:\n * 1.005, stored as 1.00499…, rounds to 1.01 as in Excel. Intl formats the\n * decimal string exactly where the browser can, the number elsewhere.\n */\nconst formatDecimal = (format: Intl.NumberFormat, x: number): string =>\n format.format(\n (Number.isFinite(x) ? x.toPrecision(15) : x) as unknown as number,\n )\n\nconst partsOfDecimal = (format: Intl.NumberFormat, x: number) =>\n format.formatToParts(\n (Number.isFinite(x) ? x.toPrecision(15) : x) as unknown as number,\n )\n\n/** The reader's decimal point and thousands separator. */\nconst separatorsOf = memo<{ decimal: string; group: string }>()\nconst marksOf = (locale: string) =>\n separatorsOf(locale, () => {\n const parts = intlNumber(locale, {}).formatToParts(12345.6)\n return {\n decimal: parts.find((p) => p.type === 'decimal')?.value ?? '.',\n group: parts.find((p) => p.type === 'group')?.value ?? ',',\n }\n })\n\nconst textOf = (tokens: Token[]): string =>\n tokens.map((t) => (t.kind === 'text' ? t.text : '')).join('')\n\n/** Excel shows at most 30 decimals; a code asking more draws 20 here. */\nconst MAX_DECIMALS = 20\n\n/**\n * The digits of a whole number laid right to left into the placeholders of\n * `pattern`, with its text between them (`000-000`): `0` writes a zero where\n * no digit is left, `?` a space, `#` nothing; the digits past the first\n * placeholder all go there, as in Excel.\n */\nconst layInteger = (\n digits: string,\n pattern: Token[],\n group: string | undefined,\n): string => {\n const chars = [...(digits === '0' ? '' : digits)]\n let slots = pattern.filter((t) => t.kind === 'digit').length\n const out: string[] = []\n for (let i = pattern.length - 1; i >= 0; i--) {\n const t = pattern[i]\n if (t.kind === 'text') {\n out.unshift(t.text)\n } else if (t.kind === 'digit') {\n slots--\n const taken = slots === 0 ? chars.splice(0).join('') : chars.pop()\n out.unshift(\n taken || (t.char === '0' ? '0' : t.char === '?' ? ' ' : ''),\n )\n }\n }\n const laid = out.join('')\n return group\n ? laid.replace(/\\d+/, (run) => run.replace(/\\B(?=(\\d{3})+$)/g, group))\n : laid\n}\n\n/**\n * Decimal digits laid left to right into the placeholders after the point,\n * with their text (`0.0\"x\"0` shows 1.23 as 1.2x3): a `?` left over is a\n * space, as Excel keeps the column of decimals in line.\n */\nconst layFraction = (digits: string, pattern: Token[]): string => {\n const chars = [...digits]\n return pattern\n .map((t) =>\n t.kind === 'text'\n ? t.text\n : t.kind === 'digit'\n ? (chars.shift() ??\n (t.char === '0' ? '0' : t.char === '?' ? ' ' : ''))\n : '',\n )\n .join('')\n}\n\n/**\n * The fraction of `x` Excel writes with a denominator up to `most`: the last\n * convergent of its continued fraction that fits, as Excel's results show\n * (0.07 under `?/?` is 0, not 1/9).\n */\nconst convergent = (x: number, most: number): { p: number; q: number } => {\n let [p0, q0, p1, q1] = [0, 1, 1, 0]\n let rest = x\n for (let i = 0; i < 64; i++) {\n const a = Math.floor(rest)\n const p2 = a * p1 + p0\n const q2 = a * q1 + q0\n if (q2 > most) {\n break\n }\n ;[p0, q0, p1, q1] = [p1, q1, p2, q2]\n const left = rest - a\n if (left < 1e-12) {\n break\n }\n rest = 1 / left\n }\n return q1 === 0 ? { p: 0, q: 1 } : { p: p1, q: q1 }\n}\n\n/** The sections of each code met, read once: a grid repeats a few codes. */\nconst parsedSections = memo<Section[]>()\nconst sectionsFor = (code: string): Section[] =>\n parsedSections(code, () => sectionsOf(code).slice(0, 3).map(parseSection))\n\n/**\n * `value` as Excel shows it under `code`, with the separators of `locale`,\n * and the color the section names, if any.\n */\nexport const formatExcelNumber = (\n code: string,\n value: number,\n locale: string,\n): { text: string; color?: string } => {\n const { section, minus } = sectionFor(sectionsFor(code), value)\n const { tokens } = section\n const tint = section.color ? { color: section.color } : {}\n const signed = (text: string, shown: boolean) => ({\n text: (minus && shown ? '-' : '') + text,\n ...tint,\n })\n const n = Math.abs(value)\n\n if (!tokens.length) {\n // An empty section hides the value, as `;;;` does\n return { text: '', ...tint }\n }\n if (tokens.some((t) => t.kind === 'general')) {\n const general = formatDecimal(\n intlNumber(locale, {\n maximumFractionDigits: 10,\n useGrouping: false,\n }),\n n,\n )\n const words = tokens.map((t) =>\n t.kind === 'general' ? general : t.kind === 'text' ? t.text : '',\n )\n return signed(words.join(''), n !== 0)\n }\n const first = tokens.findIndex((t) => t.kind === 'digit')\n if (first === -1) {\n // Text alone, as the `\"-\"` an accounting format writes for a zero\n return signed(textOf(tokens), n !== 0)\n }\n const { decimal, group } = marksOf(locale)\n const last = tokens.reduce((at, t, i) => (t.kind === 'digit' ? i : at), -1)\n const before = textOf(tokens.slice(0, first))\n const percent = tokens.filter((t) => t.kind === 'percent').length\n const scaled = n * 100 ** percent\n\n const exponentAt = tokens.findIndex((t) => t.kind === 'exponent')\n if (exponentAt !== -1) {\n const mantissa = tokens.slice(first, exponentAt)\n const pointAt = mantissa.findIndex((t) => t.kind === 'point')\n const whole = (\n pointAt === -1 ? mantissa : mantissa.slice(0, pointAt)\n ).filter((t) => t.kind === 'digit').length\n const fraction =\n pointAt === -1\n ? []\n : mantissa.slice(pointAt).filter((t) => t.kind === 'digit')\n const plus = (tokens[exponentAt] as { plus: boolean }).plus\n const width = tokens\n .slice(exponentAt)\n .filter((t) => t.kind === 'digit').length\n // `##0.0E+0` keeps the exponent a multiple of three, as Excel does\n const parts = partsOfDecimal(\n intlNumber('en-US', {\n notation: whole >= 3 ? 'engineering' : 'scientific',\n minimumFractionDigits: Math.min(\n fraction.filter((t) => t.kind === 'digit' && t.char === '0')\n .length,\n MAX_DECIMALS,\n ),\n maximumFractionDigits: Math.min(fraction.length, MAX_DECIMALS),\n useGrouping: false,\n }),\n scaled,\n )\n const at = parts.findIndex((p) => p.type === 'exponentSeparator')\n const m = parts\n .slice(0, at)\n .map((p) => (p.type === 'decimal' ? decimal : p.value))\n .join('')\n const power = Number(\n parts\n .slice(at + 1)\n .map((p) => (p.type === 'exponentMinusSign' ? '-' : p.value))\n .join(''),\n )\n const sign = power < 0 ? '-' : plus ? '+' : ''\n return signed(\n `${before}${m}E${sign}${String(Math.abs(power)).padStart(width, '0')}${textOf(tokens.slice(last + 1))}`,\n n !== 0,\n )\n }\n\n const slash = tokens.findIndex(\n (t, i) =>\n t.kind === 'text' &&\n t.text.includes('/') &&\n i > first &&\n i <= last + 1,\n )\n if (slash !== -1) {\n // `# ?/?`: a whole part, then a fraction; `# ?/8` names its denominator\n const gap = tokens.findIndex(\n (t, i) => t.kind === 'text' && i > first && i < slash,\n )\n const top = tokens.slice(gap === -1 ? first : gap + 1, slash)\n const below = tokens.slice(slash + 1, last + 1)\n const fixed = /\\/\\s*(\\d+)/.exec(\n (tokens[slash] as { text: string }).text,\n )\n const whole = gap === -1 ? 0 : Math.floor(n)\n const rest = n - whole\n const found = fixed\n ? { p: Math.round(rest * Number(fixed[1])), q: Number(fixed[1]) }\n : convergent(\n rest,\n 10 **\n Math.min(\n below.filter((t) => t.kind === 'digit').length,\n 6,\n ) -\n 1,\n )\n const { q } = found\n let { p } = found\n let units = whole\n // A fraction that rounds to a whole one adds a unit, as 2.99 to 3\n if (p === q && gap !== -1) {\n units++\n p = 0\n }\n const wholeText =\n gap === -1\n ? ''\n : layInteger(String(units), tokens.slice(first, gap), undefined)\n const body = p\n ? `${wholeText}${gap === -1 ? '' : textOf([tokens[gap]])}${layInteger(String(p), top, undefined)}${fixed ? textOf([tokens[slash]]) : `/${layFraction(String(q), below)}`}`\n : wholeText || '0'\n // A named denominator is the text after the last placeholder\n return signed(\n before + body + textOf(tokens.slice(Math.max(last, slash) + 1)),\n units !== 0 || p !== 0,\n )\n }\n\n const pointAt = tokens.findIndex(\n (t, i) => t.kind === 'point' && i > first && i <= last,\n )\n const intEnd = pointAt === -1 ? last : pointAt - 1\n // Commas right after the last placeholder divide by a thousand each\n let scale = 0\n while (tokens[last + 1 + scale]?.kind === 'comma') {\n scale++\n }\n const intTokens = tokens.slice(first, intEnd + 1)\n const grouped = intTokens.some(\n (t, i) =>\n t.kind === 'comma' &&\n intTokens.slice(0, i).some((u) => u.kind === 'digit') &&\n intTokens.slice(i + 1).some((u) => u.kind === 'digit'),\n )\n const fraction = pointAt === -1 ? [] : tokens.slice(pointAt + 1, last + 1)\n const places = fraction.filter((t) => t.kind === 'digit')\n const fixed = formatDecimal(\n intlNumber('en-US', {\n minimumFractionDigits: Math.min(\n places.filter((t) => t.kind === 'digit' && t.char === '0')\n .length,\n MAX_DECIMALS,\n ),\n maximumFractionDigits: Math.min(places.length, MAX_DECIMALS),\n useGrouping: false,\n }),\n scaled / 1000 ** scale,\n )\n const [whole, decimals = ''] = fixed.split('.')\n const integer = layInteger(\n whole,\n intTokens.filter((t) => t.kind !== 'comma'),\n grouped ? group : undefined,\n )\n const body =\n integer +\n (pointAt === -1 ? '' : decimal + layFraction(decimals, fraction))\n return signed(\n before + body + textOf(tokens.slice(last + 1 + scale)),\n Number(whole) !== 0 || Number(decimals) !== 0,\n )\n}\n\n/** The locales of the tags dates name their months in (`[$-410]`). */\nconst LCIDS: Record<string, string> = {\n '409': 'en-US',\n '809': 'en-GB',\n '410': 'it-IT',\n '40c': 'fr-FR',\n '407': 'de-DE',\n c0a: 'es-ES',\n '416': 'pt-BR',\n}\n\ntype DatePart =\n | { kind: 'text'; text: string }\n | { kind: 'year'; size: number }\n | { kind: 'month'; size: number }\n | { kind: 'day'; size: number }\n | { kind: 'hour'; size: number; elapsed: boolean }\n | { kind: 'minute'; size: number; elapsed: boolean }\n | { kind: 'second'; size: number; elapsed: boolean; decimals: number }\n | { kind: 'ampm'; short: boolean }\n\n/**\n * The codes Excel keeps for the system's short date, as the file loader\n * names its built-in formats 14 and 22: the reader's date, as Excel shows\n * them in the reader's language.\n */\nconst SYSTEM_DATES = new Set(['mm-dd-yy', 'm/d/yy h:mm'])\n\n/** The parts of one section of a date format, with the locale it tags. */\nconst parseDate = (source: string): { parts: DatePart[]; locale?: string } => {\n const parts: DatePart[] = []\n let locale: string | undefined\n const text = (t: string) => {\n const last = parts[parts.length - 1]\n if (last?.kind === 'text') {\n last.text += t\n } else if (t) {\n parts.push({ kind: 'text', text: t })\n }\n }\n for (let i = 0; i < source.length; i++) {\n const rest = source.slice(i)\n const ch = source[i]\n const run = (/^([a-z])\\1*/i.exec(rest)?.[0] ?? ch).length\n const lower = ch.toLowerCase()\n if (ch === '\"') {\n const end = source.indexOf('\"', i + 1)\n const stop = end === -1 ? source.length : end\n text(source.slice(i + 1, stop))\n i = stop\n } else if (ch === '\\\\') {\n text(source[i + 1] ?? '')\n i++\n } else if (ch === '_' || ch === '*') {\n text(ch === '_' ? ' ' : (source[i + 1] ?? ''))\n i++\n } else if (ch === '[') {\n const end = source.indexOf(']', i)\n const inner = source.slice(i + 1, end === -1 ? undefined : end)\n i = end === -1 ? source.length : end\n const elapsed = /^(h+|m+|s+)$/i.exec(inner)\n const tag = /^\\$[^-]*-([0-9a-f]+)$/i.exec(inner)\n if (elapsed) {\n const k = elapsed[1][0].toLowerCase()\n const size = elapsed[1].length\n // `[s].00`: hundredths of the elapsed seconds\n const decimals =\n k === 's'\n ? (/^\\.(0+)/.exec(source.slice(i + 1))?.[1].length ?? 0)\n : 0\n i += decimals ? decimals + 1 : 0\n parts.push(\n k === 'h'\n ? { kind: 'hour', size, elapsed: true }\n : k === 'm'\n ? { kind: 'minute', size, elapsed: true }\n : { kind: 'second', size, elapsed: true, decimals },\n )\n } else if (tag) {\n locale = LCIDS[tag[1].toLowerCase().slice(-3)] ?? locale\n }\n } else if (/^(am\\/pm|a\\/p)/i.test(rest)) {\n const short = /^a\\/p/i.test(rest)\n parts.push({ kind: 'ampm', short })\n i += short ? 2 : 4\n } else if (lower === 'y') {\n parts.push({ kind: 'year', size: run })\n i += run - 1\n } else if (lower === 'd') {\n parts.push({ kind: 'day', size: run })\n i += run - 1\n } else if (lower === 'h') {\n parts.push({ kind: 'hour', size: run, elapsed: false })\n i += run - 1\n } else if (lower === 's') {\n // `ss.00`: tenths and hundredths of a second\n const decimals = /^s+\\.(0+)/i.exec(rest)?.[1].length ?? 0\n parts.push({ kind: 'second', size: run, elapsed: false, decimals })\n i += run - 1 + (decimals ? decimals + 1 : 0)\n } else if (lower === 'm') {\n parts.push({ kind: 'month', size: run })\n i += run - 1\n } else {\n text(ch)\n }\n }\n // An `m` after an hour or before a second is a minute, as in Excel\n parts.forEach((part, i) => {\n if (part.kind !== 'month' || part.size > 2) {\n return\n }\n const before = parts\n .slice(0, i)\n .reverse()\n .find((p) => p.kind !== 'text')\n const after = parts.slice(i + 1).find((p) => p.kind !== 'text')\n if (before?.kind === 'hour' || after?.kind === 'second') {\n parts[i] = { kind: 'minute', size: part.size, elapsed: false }\n }\n })\n return { parts, locale }\n}\n\nconst parsedDates = memo<{ parts: DatePart[]; locale?: string }>()\n\n/**\n * The day of a serial: in Excel's 1900 system, which counts a 29 February\n * 1900 that never was and a day 0 (`{ y: 1900, m: 1, d: 0 }` for serial 0),\n * or in the 1904 system some Mac workbooks use.\n */\nconst dayOf = (days: number, date1904: boolean) => {\n if (!date1904 && days < 61) {\n const d = days === 60 ? 29 : days > 31 ? days - 31 : days\n const m = days === 60 || days > 31 ? 2 : 1\n return { y: 1900, m, d, weekday: (days + 6) % 7 }\n }\n const date = new Date(\n (date1904 ? Date.UTC(1904, 0, 1) : Date.UTC(1899, 11, 30)) +\n days * 86_400_000,\n )\n return {\n y: date.getUTCFullYear(),\n m: date.getUTCMonth() + 1,\n d: date.getUTCDate(),\n weekday: date.getUTCDay(),\n }\n}\n\nconst dateFormats = memo<Intl.DateTimeFormat>()\nconst nameOf = (\n locale: string,\n options: Intl.DateTimeFormatOptions,\n at: Date,\n) =>\n dateFormats(\n `${locale}|${JSON.stringify(options)}`,\n () => new Intl.DateTimeFormat(locale, { ...options, timeZone: 'UTC' }),\n ).format(at)\n\n/** Excel's last day, 31 December 9999: past it Excel shows `#####`. */\nconst LAST_SERIAL = 2_958_466\n\n/**\n * A date or a time Excel holds as `serial` (days since its day 0, the time\n * as the fraction), as `code` writes it: the section for the value and its\n * color, the order, digits and names of the format, with the month and day\n * names of the locale it tags or else of the reader. Undefined for a serial\n * Excel cannot show as a date.\n */\nexport const formatExcelDate = (\n code: string,\n serial: number,\n locale: string,\n date1904 = false,\n): { text: string; color?: string } | undefined => {\n if (!Number.isFinite(serial) || serial < 0 || serial >= LAST_SERIAL) {\n return undefined\n }\n const sources = sectionsOf(code).slice(0, 3)\n const sections = sectionsFor(code)\n const chosen = sectionFor(sections, serial).section\n const source = sources[sections.indexOf(chosen)] ?? sources[0]\n const tint = chosen.color ? { color: chosen.color } : {}\n const { parts, locale: tagged } = parsedDates(source, () =>\n parseDate(source),\n )\n const names = tagged ?? locale\n const ampm = parts.some((p) => p.kind === 'ampm')\n // Seconds rounded as Excel shows them, to the decimals the code asks\n const decimals = Math.max(\n 0,\n ...parts.map((p) => (p.kind === 'second' ? p.decimals : 0)),\n )\n const unit = 86_400 * 10 ** decimals\n const total = Math.round(serial * unit)\n const days = Math.floor(total / unit)\n const within = total - days * unit\n const second = Math.floor(within / 10 ** decimals)\n const day = dayOf(days, date1904)\n const hour = Math.floor(second / 3600)\n const minute = Math.floor((second % 3600) / 60)\n if (SYSTEM_DATES.has(source.replace(/\\[[^\\]]*\\]/g, '').trim())) {\n const date = new Date(Date.UTC(day.y, day.m - 1, Math.max(day.d, 1)))\n const short = nameOf(\n locale,\n /^en(-US)?$/i.test(locale)\n ? { year: 'numeric', month: 'numeric', day: 'numeric' }\n : { year: 'numeric', month: '2-digit', day: '2-digit' },\n date,\n )\n const time = /h/i.test(source)\n ? ` ${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}`\n : ''\n return { text: short + time, ...tint }\n }\n const at = new Date(Date.UTC(2000, day.m - 1, Math.max(day.d, 1)))\n const weekdayAt = new Date(Date.UTC(2023, 0, 1 + day.weekday))\n const pad = (n: number, size: number) =>\n String(n).padStart(Math.min(size, 2), '0')\n const text = parts\n .map((p) => {\n switch (p.kind) {\n case 'text':\n return p.text\n case 'year':\n return p.size <= 2\n ? String(day.y % 100).padStart(2, '0')\n : String(day.y)\n case 'month':\n return p.size <= 2\n ? pad(day.m, p.size)\n : p.size === 3\n ? nameOf(names, { month: 'short' }, at).replace(\n /\\.$/,\n '',\n )\n : p.size === 4\n ? nameOf(names, { month: 'long' }, at)\n : nameOf(names, { month: 'long' }, at)[0]\n case 'day':\n return p.size <= 2\n ? pad(day.d, p.size)\n : nameOf(\n names,\n { weekday: p.size === 3 ? 'short' : 'long' },\n weekdayAt,\n ).replace(/\\.$/, '')\n case 'hour': {\n if (p.elapsed) {\n return pad(days * 24 + hour, p.size)\n }\n return pad(ampm ? hour % 12 || 12 : hour, p.size)\n }\n case 'minute':\n return pad(\n p.elapsed ? (days * 24 + hour) * 60 + minute : minute,\n p.size,\n )\n case 'second': {\n const whole = p.elapsed\n ? Math.floor(total / 10 ** decimals)\n : second % 60\n const fraction = p.decimals\n ? `.${String(within % 10 ** decimals)\n .padStart(decimals, '0')\n .slice(0, p.decimals)}`\n : ''\n return pad(whole, p.size) + fraction\n }\n case 'ampm':\n return p.short\n ? hour < 12\n ? 'A'\n : 'P'\n : hour < 12\n ? 'AM'\n : 'PM'\n }\n })\n .join('')\n return { text, ...tint }\n}\n\n/**\n * A date or a time written as Excel holds it (`46000.5`), as `YYYY-MM-DD`,\n * `YYYY-MM-DD HH:mm` or `HH:mm`, as its format shows it; undefined for\n * anything else.\n */\nexport const excelDateText = (\n raw: string,\n code: string,\n locale: string,\n): string | undefined => {\n const written =\n /^(?:(\\d{4}-\\d{2}-\\d{2}))?[ T]?(?:(\\d{1,2}):(\\d{2})(?::(\\d{2}))?)?$/.exec(\n raw.trim(),\n )\n const serial = /^-?\\d+(\\.\\d+)?$/.test(raw)\n ? Number(raw)\n : written && (written[1] || written[2])\n ? (written[1]\n ? Date.parse(`${written[1]}T00:00:00Z`) / 86_400_000 + 25_569\n : 0) +\n (Number(written[2] ?? 0) * 3600 +\n Number(written[3] ?? 0) * 60 +\n Number(written[4] ?? 0)) /\n 86_400\n : undefined\n return serial === undefined || Number.isNaN(serial)\n ? undefined\n : formatExcelDate(code, serial, locale)?.text\n}\n"],"mappings":";;AAcA,IAAa4B,IAA0B5B,EAAS;CAC5C,GAAGC,EAAS;CACZ,GAAGA,EAAS;CAEZ,OAAOC,EAAO,CAAC,QAAQ,QAAQ,CAAC;CAEhC,OAAOA,EAAO;EAAC;EAAQ;EAAU;CAAW,CAAC;CAC7C,MAAMA,EAAO;EAAC;EAAU;EAAS;EAAU;CAAO,CAAC;AACvD,CAAC,GAGY2B,IAA2B7B,EAAS;CAE7C,KAAKG,EAAS;CACd,OAAOF,EAAS;CAChB,QAAQA,EAAS;CAEjB,QAAQ2B,EAAwB,SAAS;AAC7C,CAAC,GAEYE,IAAuB9B,EAAS;CACzC,MAAMG,EAAS;CAEf,QAAQD,EAAO,CAAC,YAAY,SAAS,CAAC,CAAC,CAAC,SAAS;CACjD,QAAQC,EAAS,CAAC,CAAC,SAAS;CAC5B,MAAMC,EAAU,EAAI,CAAC,CAAC,SAAS;CAC/B,QAAQA,EAAU,EAAI,CAAC,CAAC,SAAS;CACjC,WAAWA,EAAU,EAAI,CAAC,CAAC,SAAS;CACpC,QAAQA,EAAU,EAAI,CAAC,CAAC,SAAS;CACjC,MAAMA,EAAU,EAAI,CAAC,CAAC,SAAS;CAC/B,WAAWF,EAAO,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,SAAS;CAE7C,MAAMC,EAAS,CAAC,CAAC,SAAS;CAC1B,MAAMF,EAAS,CAAC,CAAC,SAAS;CAC1B,OAAOE,EAAS,CAAC,CAAC,SAAS;CAE3B,WAAWA,EAAS,CAAC,CAAC,SAAS;CAE/B,OA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