@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.
Files changed (129) hide show
  1. package/dist/_chunks/Chart-1vt0m6l_.js +87 -0
  2. package/dist/_chunks/Chart-1vt0m6l_.js.map +1 -0
  3. package/dist/_chunks/{PkChart-CbtMRGWc.js → PkChart-CYFx_UDq.js} +741 -623
  4. package/dist/_chunks/PkChart-CYFx_UDq.js.map +1 -0
  5. package/dist/_chunks/PkFilePreview-yjdtArag.js +1745 -0
  6. package/dist/_chunks/PkFilePreview-yjdtArag.js.map +1 -0
  7. package/dist/_chunks/{PkFilePreviewDialog-bcTkTcYk.js → PkFilePreviewDialog-Df0Lt40J.js} +2 -2
  8. package/dist/_chunks/{PkFilePreviewDialog-bcTkTcYk.js.map → PkFilePreviewDialog-Df0Lt40J.js.map} +1 -1
  9. package/dist/_chunks/{PkImageEditorDialog-FpbyhV3t.js → PkImageEditorDialog-PVf3IHGB.js} +2 -2
  10. package/dist/_chunks/{PkImageEditorDialog-FpbyhV3t.js.map → PkImageEditorDialog-PVf3IHGB.js.map} +1 -1
  11. package/dist/_chunks/{PkSelectionActions-BbfVZY0R.js → PkSelectionActions-CMyg_x8h.js} +2 -2
  12. package/dist/_chunks/{PkSelectionActions-BbfVZY0R.js.map → PkSelectionActions-CMyg_x8h.js.map} +1 -1
  13. package/dist/_chunks/{PkStreamingMarkdown-COSOOhCg.js → PkStreamingMarkdown-BDXbU2tz.js} +2 -2
  14. package/dist/_chunks/{PkStreamingMarkdown-COSOOhCg.js.map → PkStreamingMarkdown-BDXbU2tz.js.map} +1 -1
  15. package/dist/_chunks/{PkToolChatFile-C_gS0X1j.js → PkToolChatFile-CMQdMs-9.js} +3 -3
  16. package/dist/_chunks/{PkToolChatFile-C_gS0X1j.js.map → PkToolChatFile-CMQdMs-9.js.map} +1 -1
  17. package/dist/_chunks/{PkToolShowArtifact-fpFtKrZo.js → PkToolShowArtifact-YrC54qxc.js} +2 -2
  18. package/dist/_chunks/{PkToolShowArtifact-fpFtKrZo.js.map → PkToolShowArtifact-YrC54qxc.js.map} +1 -1
  19. package/dist/_chunks/PkToolShowChart-D3E_xBJv.js +138 -0
  20. package/dist/_chunks/PkToolShowChart-D3E_xBJv.js.map +1 -0
  21. package/dist/_chunks/{PkToolShowContactForm-BAM772bm.js → PkToolShowContactForm-Dio2FNkA.js} +2 -2
  22. package/dist/_chunks/{PkToolShowContactForm-BAM772bm.js.map → PkToolShowContactForm-Dio2FNkA.js.map} +1 -1
  23. package/dist/_chunks/{PkToolShowForm-DJcL0bgw.js → PkToolShowForm-w9HGhvCy.js} +3 -3
  24. package/dist/_chunks/{PkToolShowForm-DJcL0bgw.js.map → PkToolShowForm-w9HGhvCy.js.map} +1 -1
  25. package/dist/_chunks/{PkToolShowSources-GeWAMHYC.js → PkToolShowSources-DXFvFHOo.js} +2 -2
  26. package/dist/_chunks/{PkToolShowSources-GeWAMHYC.js.map → PkToolShowSources-DXFvFHOo.js.map} +1 -1
  27. package/dist/_chunks/chartFormat-B1T7y-16.js +27 -0
  28. package/dist/_chunks/chartFormat-B1T7y-16.js.map +1 -0
  29. package/dist/_chunks/{excelNumberFormat-BhQjife9.js → excelNumberFormat-CcXF_wJK.js} +101 -88
  30. package/dist/_chunks/excelNumberFormat-CcXF_wJK.js.map +1 -0
  31. package/dist/_chunks/{utils-DMvy5QRR.js → utils-BBoaLDYF.js} +14 -14
  32. package/dist/_chunks/utils-BBoaLDYF.js.map +1 -0
  33. package/dist/ai-elements.es.js +178 -172
  34. package/dist/ai-elements.es.js.map +1 -1
  35. package/dist-vue/PkChatbot.js +1 -1
  36. package/dist-vue/PkChatbotEmptyState.js +1 -1
  37. package/dist-vue/PkChatbotInput.js +1 -1
  38. package/dist-vue/PkChatbotMessages.js +1 -1
  39. package/dist-vue/PkChatbotStepPayload.js +1 -1
  40. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  41. package/dist-vue/PkChatbotSteps.js +1 -1
  42. package/dist-vue/PkChatbotViewChat.js +1 -1
  43. package/dist-vue/PkChatbotViewConversations.js +1 -1
  44. package/dist-vue/_chunks/Chart-DsBNs5rS.js +87 -0
  45. package/dist-vue/_chunks/Chart-DsBNs5rS.js.map +1 -0
  46. package/dist-vue/_chunks/{PkChart-D-K7nc0g.js → PkChart-CrZqhEpp.js} +112 -74
  47. package/dist-vue/_chunks/PkChart-CrZqhEpp.js.map +1 -0
  48. package/dist-vue/_chunks/{PkChatbot-DVQ-Bb7n.js → PkChatbot-CxkTubw8.js} +6 -6
  49. package/dist-vue/_chunks/{PkChatbot-DVQ-Bb7n.js.map → PkChatbot-CxkTubw8.js.map} +1 -1
  50. package/dist-vue/_chunks/{PkChatbotEmptyState-OlgewA4_.js → PkChatbotEmptyState-CUoHkCgO.js} +2 -2
  51. package/dist-vue/_chunks/{PkChatbotEmptyState-OlgewA4_.js.map → PkChatbotEmptyState-CUoHkCgO.js.map} +1 -1
  52. package/dist-vue/_chunks/{PkChatbotInput-D_I0Gf_u.js → PkChatbotInput-CPf7wqiQ.js} +4 -4
  53. package/dist-vue/_chunks/{PkChatbotInput-D_I0Gf_u.js.map → PkChatbotInput-CPf7wqiQ.js.map} +1 -1
  54. package/dist-vue/_chunks/{PkChatbotMessages-CAXnEfXK.js → PkChatbotMessages-CLNu2dTm.js} +307 -307
  55. package/dist-vue/_chunks/{PkChatbotMessages-CAXnEfXK.js.map → PkChatbotMessages-CLNu2dTm.js.map} +1 -1
  56. package/dist-vue/_chunks/{PkChatbotStepPayload-EBri1L10.js → PkChatbotStepPayload-Cf7mJPjL.js} +2 -2
  57. package/dist-vue/_chunks/{PkChatbotStepPayload-EBri1L10.js.map → PkChatbotStepPayload-Cf7mJPjL.js.map} +1 -1
  58. package/dist-vue/_chunks/{PkChatbotStepToolDetail-DiQEa0UV.js → PkChatbotStepToolDetail-D6nwNnHv.js} +16 -16
  59. package/dist-vue/_chunks/{PkChatbotStepToolDetail-DiQEa0UV.js.map → PkChatbotStepToolDetail-D6nwNnHv.js.map} +1 -1
  60. package/dist-vue/_chunks/{PkChatbotSteps-BgLnv2J1.js → PkChatbotSteps-xkxdaX7O.js} +38 -38
  61. package/dist-vue/_chunks/{PkChatbotSteps-BgLnv2J1.js.map → PkChatbotSteps-xkxdaX7O.js.map} +1 -1
  62. package/dist-vue/_chunks/{PkChatbotViewChat-CmjD1IXf.js → PkChatbotViewChat-BkkyjiFl.js} +22 -22
  63. package/dist-vue/_chunks/{PkChatbotViewChat-CmjD1IXf.js.map → PkChatbotViewChat-BkkyjiFl.js.map} +1 -1
  64. package/dist-vue/_chunks/{PkChatbotViewConversations-CVZH5dXx.js → PkChatbotViewConversations-hgqSO1hx.js} +2 -2
  65. package/dist-vue/_chunks/{PkChatbotViewConversations-CVZH5dXx.js.map → PkChatbotViewConversations-hgqSO1hx.js.map} +1 -1
  66. package/dist-vue/_chunks/{PkFilePreview-k5gEl3n8.js → PkFilePreview-CmsT6lSP.js} +701 -624
  67. package/dist-vue/_chunks/PkFilePreview-CmsT6lSP.js.map +1 -0
  68. package/dist-vue/_chunks/{PkFilePreviewDialog-DUwZPErE.js → PkFilePreviewDialog-DIiTt9iK.js} +2 -2
  69. package/dist-vue/_chunks/{PkFilePreviewDialog-DUwZPErE.js.map → PkFilePreviewDialog-DIiTt9iK.js.map} +1 -1
  70. package/dist-vue/_chunks/{PkImageEditorDialog-DQPXePae.js → PkImageEditorDialog-CE0Y5Pwr.js} +2 -2
  71. package/dist-vue/_chunks/{PkImageEditorDialog-DQPXePae.js.map → PkImageEditorDialog-CE0Y5Pwr.js.map} +1 -1
  72. package/dist-vue/_chunks/{PkStreamingMarkdown-ZasabxE0.js → PkStreamingMarkdown-BBvCtDlO.js} +2 -2
  73. package/dist-vue/_chunks/{PkStreamingMarkdown-ZasabxE0.js.map → PkStreamingMarkdown-BBvCtDlO.js.map} +1 -1
  74. package/dist-vue/_chunks/{PkToolChatFile-CD26Q2xp.js → PkToolChatFile-DVhunkPS.js} +3 -3
  75. package/dist-vue/_chunks/{PkToolChatFile-CD26Q2xp.js.map → PkToolChatFile-DVhunkPS.js.map} +1 -1
  76. package/dist-vue/_chunks/{PkToolShowArtifact-BhVd_ZQ8.js → PkToolShowArtifact-DKOTsP9C.js} +2 -2
  77. package/dist-vue/_chunks/{PkToolShowArtifact-BhVd_ZQ8.js.map → PkToolShowArtifact-DKOTsP9C.js.map} +1 -1
  78. package/dist-vue/_chunks/PkToolShowChart-CNBUjDc7.js +133 -0
  79. package/dist-vue/_chunks/PkToolShowChart-CNBUjDc7.js.map +1 -0
  80. package/dist-vue/_chunks/{PkToolShowContactForm-CackCDGD.js → PkToolShowContactForm-D1Ff15Zf.js} +2 -2
  81. package/dist-vue/_chunks/{PkToolShowContactForm-CackCDGD.js.map → PkToolShowContactForm-D1Ff15Zf.js.map} +1 -1
  82. package/dist-vue/_chunks/{PkToolShowDiagram-CABPsFi8.js → PkToolShowDiagram-CBwqjy6a.js} +2 -2
  83. package/dist-vue/_chunks/{PkToolShowDiagram-CABPsFi8.js.map → PkToolShowDiagram-CBwqjy6a.js.map} +1 -1
  84. package/dist-vue/_chunks/{PkToolShowForm-BStbk4Iu.js → PkToolShowForm-D-rzzwJa.js} +3 -3
  85. package/dist-vue/_chunks/{PkToolShowForm-BStbk4Iu.js.map → PkToolShowForm-D-rzzwJa.js.map} +1 -1
  86. package/dist-vue/_chunks/{PkToolShowImageGallery-BeeHsdTp.js → PkToolShowImageGallery-Cre2zSGV.js} +2 -2
  87. package/dist-vue/_chunks/{PkToolShowImageGallery-BeeHsdTp.js.map → PkToolShowImageGallery-Cre2zSGV.js.map} +1 -1
  88. package/dist-vue/_chunks/{PkToolShowProductList-BfUiap9U.js → PkToolShowProductList-D4FAfMS-.js} +2 -2
  89. package/dist-vue/_chunks/{PkToolShowProductList-BfUiap9U.js.map → PkToolShowProductList-D4FAfMS-.js.map} +1 -1
  90. package/dist-vue/_chunks/{PkToolShowSources-CgEkcyRg.js → PkToolShowSources-BC6YJl-O.js} +2 -2
  91. package/dist-vue/_chunks/{PkToolShowSources-CgEkcyRg.js.map → PkToolShowSources-BC6YJl-O.js.map} +1 -1
  92. package/dist-vue/_chunks/{PkToolShowVideo-CqSRnDNC.js → PkToolShowVideo-CxN7z_cZ.js} +2 -2
  93. package/dist-vue/_chunks/{PkToolShowVideo-CqSRnDNC.js.map → PkToolShowVideo-CxN7z_cZ.js.map} +1 -1
  94. package/dist-vue/_chunks/{PkToolShowWebPages-B-qIS8qY.js → PkToolShowWebPages-0Ux6n8G1.js} +2 -2
  95. package/dist-vue/_chunks/{PkToolShowWebPages-B-qIS8qY.js.map → PkToolShowWebPages-0Ux6n8G1.js.map} +1 -1
  96. package/dist-vue/_chunks/chartFormat-B1T7y-16.js +27 -0
  97. package/dist-vue/_chunks/chartFormat-B1T7y-16.js.map +1 -0
  98. package/dist-vue/_chunks/{excelNumberFormat-C1sCQrOz.js → excelNumberFormat-BxRi0Y3e.js} +101 -88
  99. package/dist-vue/_chunks/excelNumberFormat-BxRi0Y3e.js.map +1 -0
  100. package/dist-vue/_chunks/{utils-KBB6SDPn.js → utils-C9l078yb.js} +10 -10
  101. package/dist-vue/_chunks/utils-C9l078yb.js.map +1 -0
  102. package/dist-vue/composables.js +9 -3
  103. package/dist-vue/composables.js.map +1 -1
  104. package/dist-vue/index.js +42 -42
  105. package/dist-vue/index.js.map +1 -1
  106. package/dist-vue/locales.js +6 -0
  107. package/dist-vue/packages/components/src/chat/PkChart.d.ts +8 -0
  108. package/dist-vue/packages/components/src/chat/PkFileChart.d.ts +14 -0
  109. package/dist-vue/packages/components/src/chat/PkWordPreviewRuns.d.ts +4 -1
  110. package/dist-vue/packages/components/src/chat/useChatFilePreview.d.ts +240 -0
  111. package/dist-vue/packages/components/src/chat/utils.d.ts +6 -1
  112. package/dist-vue/packages/models/src/schema/Chart.d.ts +91 -0
  113. package/dist-vue/packages/models/src/schema/SpreadsheetPreview.d.ts +381 -0
  114. package/dist-vue/packages/models/src/schema/WordPreview.d.ts +304 -0
  115. package/dist-vue/style.css +1 -1
  116. package/package.json +1 -1
  117. package/dist/_chunks/PkChart-CbtMRGWc.js.map +0 -1
  118. package/dist/_chunks/PkFilePreview-DC4iX7Yc.js +0 -1665
  119. package/dist/_chunks/PkFilePreview-DC4iX7Yc.js.map +0 -1
  120. package/dist/_chunks/PkToolShowChart-DZWu3Yuo.js +0 -224
  121. package/dist/_chunks/PkToolShowChart-DZWu3Yuo.js.map +0 -1
  122. package/dist/_chunks/excelNumberFormat-BhQjife9.js.map +0 -1
  123. package/dist/_chunks/utils-DMvy5QRR.js.map +0 -1
  124. package/dist-vue/_chunks/PkChart-D-K7nc0g.js.map +0 -1
  125. package/dist-vue/_chunks/PkFilePreview-k5gEl3n8.js.map +0 -1
  126. package/dist-vue/_chunks/PkToolShowChart-BQXxaPIO.js +0 -217
  127. package/dist-vue/_chunks/PkToolShowChart-BQXxaPIO.js.map +0 -1
  128. package/dist-vue/_chunks/excelNumberFormat-C1sCQrOz.js.map +0 -1
  129. package/dist-vue/_chunks/utils-KBB6SDPn.js.map +0 -1
@@ -0,0 +1,87 @@
1
+ import { _ as e, b as t, g as n, o as r, r as i, s as a } from "./zod-Cty6wiWN.js";
2
+ // ../../packages/models/src/schema/Chart.ts
3
+ var o = [
4
+ "bar",
5
+ "line",
6
+ "pie",
7
+ "doughnut"
8
+ ], s = [
9
+ "positive",
10
+ "warning",
11
+ "negative",
12
+ "critical",
13
+ "neutral"
14
+ ], c = [
15
+ "number",
16
+ "percent",
17
+ "currency"
18
+ ], l = {
19
+ maxCategories: 50,
20
+ maxSeries: 8,
21
+ maxSlices: 12,
22
+ maxCharts: 4
23
+ }, u = (e) => e === "pie" || e === "doughnut", d = 120, f = e({
24
+ name: t().min(1).max(d).describe("Series name, shown in the legend"),
25
+ values: r(n().nullable()).max(l.maxCategories).describe("One number per category, in the same order; null for none"),
26
+ tone: i(s).optional().describe("Only when the series means a judgement (e.g. high risk = negative): it takes that color")
27
+ }), p = e({
28
+ type: i(o).describe("bar to compare amounts, line for a trend over time, pie or doughnut for the shares of one whole"),
29
+ title: t().max(200).optional().describe("Short title above the chart"),
30
+ horizontal: a().optional().describe("bar only: categories on the vertical axis, for long labels"),
31
+ stacked: a().optional().describe("bar only: the series stacked into one bar per category"),
32
+ categories: r(t().max(d)).min(1).max(l.maxCategories, `At most ${l.maxCategories} categories: group the smallest ones.`).describe("The labels of the x axis (or of the slices), in display order"),
33
+ series: r(f).min(1).max(l.maxSeries, `At most ${l.maxSeries} series.`).describe("One or more named series; exactly one for pie or doughnut"),
34
+ valueLabel: t().max(d).optional().describe("What the numbers measure, with the unit (e.g. \"Clienti\")"),
35
+ categoryLabel: t().max(d).optional().describe("What the categories are (e.g. \"Fascia di rating\")"),
36
+ format: i(c).optional().describe("How values read: percent means 0.25 is 25%, currency is in euro")
37
+ }), m = p.superRefine((e, t) => {
38
+ let { type: n, categories: r, series: i } = e, a = (e, n) => t.addIssue({
39
+ code: "custom",
40
+ message: e,
41
+ path: n
42
+ });
43
+ i.forEach((e, t) => {
44
+ e.values.length !== r.length && a(`Series "${e.name}" has ${e.values.length} values for ${r.length} categories: give one value per category.`, [
45
+ "series",
46
+ t,
47
+ "values"
48
+ ]), e.values.every((e) => e === null) && a(`Series "${e.name}" has no values: leave it out, or give its numbers.`, [
49
+ "series",
50
+ t,
51
+ "values"
52
+ ]);
53
+ }), u(n) && (i.length !== 1 && a(`A ${n} chart has exactly one series: ${i.length} given. Use a bar chart to compare several.`, ["series"]), r.length > l.maxSlices && a(`${r.length} slices: at most ${l.maxSlices} in a ${n}. Group the smallest into one, or use a bar chart.`, ["categories"]), i[0]?.values.some((e) => e !== null && e < 0) ? a(`A ${n} chart cannot show negative values.`, [
54
+ "series",
55
+ 0,
56
+ "values"
57
+ ]) : i[0]?.values.some((e) => e !== null) && !i[0].values.some((e) => e !== null && e > 0) && a(`A ${n} chart needs at least one value above zero: every slice is empty.`, [
58
+ "series",
59
+ 0,
60
+ "values"
61
+ ]));
62
+ }), h = e({
63
+ charts: r(m).min(1).max(l.maxCharts).describe("Every chart the user asked for, one entry each (e.g. a pie and a bar chart of the same numbers)"),
64
+ caption: t().max(500).optional().describe("Optional note below the charts, e.g. the source")
65
+ }), g = {
66
+ maxCategories: 500,
67
+ maxSeries: 24
68
+ }, _ = p.extend({
69
+ categories: r(t().max(d)).min(1).max(g.maxCategories),
70
+ series: r(f.extend({
71
+ name: t().max(d),
72
+ values: r(n().nullable()).max(g.maxCategories)
73
+ })).min(1).max(g.maxSeries)
74
+ }), v = e({
75
+ chart: _.optional(),
76
+ colors: r(t()).optional(),
77
+ legend: i([
78
+ "top",
79
+ "bottom",
80
+ "left",
81
+ "right"
82
+ ]).optional(),
83
+ title: t().max(200).optional()
84
+ });
85
+ export { h as n, u as r, v as t };
86
+
87
+ //# sourceMappingURL=Chart-1vt0m6l_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chart-1vt0m6l_.js","names":["z.object","z.string","z.array","z.number","z.enum","z.boolean","object","string","number","array","_enum","boolean","CHART_TYPES","CHART_TONES","CHART_FORMATS","CHART_LIMITS","isRoundChart","type","LABEL_MAX","ChartSeriesSchema","ChartFieldsSchema","ChartSchema","chart","issue","ctx","series","s","categories","i","v","ShowChartInputSchema","FILE_CHART_LIMITS","FileChartSchema","PreviewChartSchema"],"sources":["../../../../packages/models/src/schema/Chart.ts"],"sourcesContent":["import * as z from 'zod'\nimport { AgentBuiltInTool } from './Agent'\n\n// A chart as the model describes it (spec `chat-charts.md`): categories and\n// named series of numbers, no colors or code. `showChart` draws it in the\n// chat; the Excel and Word files the agent creates write the same shape as a\n// native Office chart.\n\nexport const CHART_TYPES = ['bar', 'line', 'pie', 'doughnut'] as const\nexport type ChartType = (typeof CHART_TYPES)[number]\n\n/** The meaning a series' color carries, drawn with the semantic colors. */\nexport const CHART_TONES = [\n 'positive',\n 'warning',\n 'negative',\n 'critical',\n 'neutral',\n] as const\nexport type ChartTone = (typeof CHART_TONES)[number]\n\nexport const CHART_FORMATS = ['number', 'percent', 'currency'] as const\nexport type ChartFormat = (typeof CHART_FORMATS)[number]\n\nexport const CHART_LIMITS = {\n maxCategories: 50,\n maxSeries: 8,\n /** Slices of a pie or a doughnut: more do not read. */\n maxSlices: 12,\n /** Charts in one `showChart` call. */\n maxCharts: 4,\n} as const\n\n/**\n * The agent can draw a chart in the chat: with `showChart`, or with the\n * Mermaid XY chart of `showDiagram` when it has not got the first. What the\n * \"Make a chart\" selection action needs.\n */\nexport const hasChatChartTool = (\n disabledTools: readonly AgentBuiltInTool[],\n): boolean =>\n !disabledTools.includes(AgentBuiltInTool.ShowChart) ||\n !disabledTools.includes(AgentBuiltInTool.ShowDiagram)\n\n/** A pie or a doughnut: one series, its values the slices. */\nexport const isRoundChart = (type: ChartType): boolean =>\n type === 'pie' || type === 'doughnut'\n\n/** Labels short enough for a legend, an axis and a slice. */\nconst LABEL_MAX = 120\n\nexport const ChartSeriesSchema = z.object({\n name: z\n .string()\n .min(1)\n .max(LABEL_MAX)\n .describe('Series name, shown in the legend'),\n values: z\n .array(z.number().nullable())\n .max(CHART_LIMITS.maxCategories)\n .describe('One number per category, in the same order; null for none'),\n tone: z\n .enum(CHART_TONES)\n .optional()\n .describe(\n 'Only when the series means a judgement (e.g. high risk = negative): it takes that color',\n ),\n})\nexport type ChartSeries = z.infer<typeof ChartSeriesSchema>\n\n/**\n * The fields of a chart, without the checks across them: the schema a tool\n * extends before {@link refineChart} adds those checks.\n */\nexport const ChartFieldsSchema = z.object({\n type: z\n .enum(CHART_TYPES)\n .describe(\n 'bar to compare amounts, line for a trend over time, pie or doughnut for the shares of one whole',\n ),\n title: z\n .string()\n .max(200)\n .optional()\n .describe('Short title above the chart'),\n horizontal: z\n .boolean()\n .optional()\n .describe('bar only: categories on the vertical axis, for long labels'),\n stacked: z\n .boolean()\n .optional()\n .describe('bar only: the series stacked into one bar per category'),\n // The limits in the schema, so the model reads them before it writes\n categories: z\n .array(z.string().max(LABEL_MAX))\n .min(1)\n .max(\n CHART_LIMITS.maxCategories,\n `At most ${CHART_LIMITS.maxCategories} categories: group the smallest ones.`,\n )\n .describe(\n 'The labels of the x axis (or of the slices), in display order',\n ),\n series: z\n .array(ChartSeriesSchema)\n .min(1)\n .max(\n CHART_LIMITS.maxSeries,\n `At most ${CHART_LIMITS.maxSeries} series.`,\n )\n .describe('One or more named series; exactly one for pie or doughnut'),\n valueLabel: z\n .string()\n .max(LABEL_MAX)\n .optional()\n .describe('What the numbers measure, with the unit (e.g. \"Clienti\")'),\n categoryLabel: z\n .string()\n .max(LABEL_MAX)\n .optional()\n .describe('What the categories are (e.g. \"Fascia di rating\")'),\n format: z\n .enum(CHART_FORMATS)\n .optional()\n .describe(\n 'How values read: percent means 0.25 is 25%, currency is in euro',\n ),\n})\n\n/**\n * The checks JSON Schema cannot state, worded for the model that wrote the\n * chart: it reads the message and calls again.\n */\nexport const refineChart = (\n chart: z.infer<typeof ChartFieldsSchema>,\n ctx: z.RefinementCtx,\n) => {\n const { type, categories, series } = chart\n const issue = (message: string, path: (string | number)[]) =>\n ctx.addIssue({ code: 'custom', message, path })\n series.forEach((s, i) => {\n if (s.values.length !== categories.length) {\n issue(\n `Series \"${s.name}\" has ${s.values.length} values for ${categories.length} categories: give one value per category.`,\n ['series', i, 'values'],\n )\n }\n if (s.values.every((v) => v === null)) {\n issue(\n `Series \"${s.name}\" has no values: leave it out, or give its numbers.`,\n ['series', i, 'values'],\n )\n }\n })\n if (isRoundChart(type)) {\n if (series.length !== 1) {\n issue(\n `A ${type} chart has exactly one series: ${series.length} given. Use a bar chart to compare several.`,\n ['series'],\n )\n }\n if (categories.length > CHART_LIMITS.maxSlices) {\n issue(\n `${categories.length} slices: at most ${CHART_LIMITS.maxSlices} in a ${type}. Group the smallest into one, or use a bar chart.`,\n ['categories'],\n )\n }\n if (series[0]?.values.some((v) => v !== null && v < 0)) {\n issue(`A ${type} chart cannot show negative values.`, [\n 'series',\n 0,\n 'values',\n ])\n } else if (\n series[0]?.values.some((v) => v !== null) &&\n !series[0].values.some((v) => v !== null && v > 0)\n ) {\n issue(\n `A ${type} chart needs at least one value above zero: every slice is empty.`,\n ['series', 0, 'values'],\n )\n }\n }\n}\n\nexport const ChartSchema = ChartFieldsSchema.superRefine(refineChart)\nexport type Chart = z.infer<typeof ChartSchema>\n\n/**\n * The input of `showChart`: every chart the user asked for in one call. A\n * presentation tool ends the turn, and a model that calls one chart at a\n * time (GPT-6.1 Sol, asked for a pie and a bar chart, drew the pie only)\n * would never draw the second.\n */\nexport const ShowChartInputSchema = z.object({\n charts: z\n .array(ChartSchema)\n .min(1)\n .max(CHART_LIMITS.maxCharts)\n .describe(\n 'Every chart the user asked for, one entry each (e.g. a pie and a bar chart of the same numbers)',\n ),\n caption: z\n .string()\n .max(500)\n .optional()\n .describe('Optional note below the charts, e.g. the source'),\n})\nexport type ShowChartInput = z.infer<typeof ShowChartInputSchema>\n\n/**\n * A chart read from an Excel or a Word file holds as many points as the file\n * does: a year of days is a line chart. Past these the viewer leaves it\n * undrawn.\n */\nexport const FILE_CHART_LIMITS = {\n maxCategories: 500,\n maxSeries: 24,\n} as const\n\n/**\n * The chart the viewer draws from a file (spec `chat-charts.md`, F4): the\n * fields of {@link ChartFieldsSchema}, as many points as\n * {@link FILE_CHART_LIMITS} allows, and a series the file leaves unnamed.\n */\nexport const FileChartSchema = ChartFieldsSchema.extend({\n categories: z\n .array(z.string().max(LABEL_MAX))\n .min(1)\n .max(FILE_CHART_LIMITS.maxCategories),\n series: z\n .array(\n ChartSeriesSchema.extend({\n /** Empty where the file names none: the viewer numbers it. */\n name: z.string().max(LABEL_MAX),\n values: z\n .array(z.number().nullable())\n .max(FILE_CHART_LIMITS.maxCategories),\n }),\n )\n .min(1)\n .max(FILE_CHART_LIMITS.maxSeries),\n})\nexport type FileChart = z.infer<typeof FileChartSchema>\n\n/**\n * A chart of a file in the viewer: drawn with the file's colors and legend,\n * or, for a kind the chat cannot draw (area, scatter, a combination), a\n * placeholder named by its title.\n */\nexport const PreviewChartSchema = z.object({\n chart: FileChartSchema.optional(),\n /** `#rrggbb`: one per series, or one per slice of a pie or a doughnut. */\n colors: z.array(z.string()).optional(),\n /** Where the file puts the legend; none when it has none. */\n legend: z.enum(['top', 'bottom', 'left', 'right']).optional(),\n /** The title of a chart the viewer does not draw. */\n title: z.string().max(200).optional(),\n})\nexport type PreviewChart = z.infer<typeof PreviewChartSchema>\n"],"mappings":";;AAQA,IAAaY,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,IAAoBnB,EAAS;CACtC,MAAMC,EACM,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAIiB,CAAS,CAAC,CACd,SAAS,kCAAkC;CAChD,QAAQhB,EACGC,EAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAC5B,IAAIY,EAAa,aAAa,CAAC,CAC/B,SAAS,2DAA2D;CACzE,MAAMX,EACIS,CAAW,CAAC,CACjB,SAAS,CAAC,CACV,SACG,yFACJ;AACR,CAAC,GAOYO,IAAoBpB,EAAS;CACtC,MAAMI,EACIQ,CAAW,CAAC,CACjB,SACG,iGACJ;CACJ,OAAOX,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,IAAIiB,CAAS,CAAC,CAAC,CAChC,IAAI,CAAC,CAAC,CACN,IACGH,EAAa,eACb,WAA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