@pixerate/editor 0.49.0 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/canvas/index.cjs +151 -25
  2. package/dist/canvas/index.cjs.map +1 -1
  3. package/dist/canvas/index.d.cts +109 -3
  4. package/dist/canvas/index.d.ts +109 -3
  5. package/dist/canvas/index.js +127 -1
  6. package/dist/canvas/index.js.map +1 -1
  7. package/dist/chart/index.cjs +197 -52
  8. package/dist/chart/index.cjs.map +1 -1
  9. package/dist/chart/index.d.cts +88 -3
  10. package/dist/chart/index.d.ts +88 -3
  11. package/dist/chart/index.js +151 -6
  12. package/dist/chart/index.js.map +1 -1
  13. package/dist/{chunk-3LHWTGHW.js → chunk-TO22LX34.js} +11 -1
  14. package/dist/chunk-TO22LX34.js.map +1 -0
  15. package/dist/{chunk-VNYRI265.cjs → chunk-YNSK4MGT.cjs} +12 -2
  16. package/dist/chunk-YNSK4MGT.cjs.map +1 -0
  17. package/dist/{controller-DtbEo3om.d.ts → controller-BdKzaxs2.d.ts} +1 -1
  18. package/dist/{controller-ChjCCMLl.d.cts → controller-DS3drIvy.d.cts} +1 -1
  19. package/dist/extensions/index.d.cts +2 -2
  20. package/dist/extensions/index.d.ts +2 -2
  21. package/dist/image-editor/index.cjs +141 -1
  22. package/dist/image-editor/index.cjs.map +1 -1
  23. package/dist/image-editor/index.d.cts +42 -1
  24. package/dist/image-editor/index.d.ts +42 -1
  25. package/dist/image-editor/index.js +140 -0
  26. package/dist/image-editor/index.js.map +1 -1
  27. package/dist/{index-DoHqT1mq.d.cts → index-DOy9HzfC.d.cts} +1 -1
  28. package/dist/{index-YLZ0fKqE.d.ts → index-Dt9lzydb.d.ts} +1 -1
  29. package/dist/index.d.cts +3 -3
  30. package/dist/index.d.ts +3 -3
  31. package/dist/{pathfinder-D98S2lV5.d.ts → pathfinder-B9xh_pCZ.d.ts} +2 -1
  32. package/dist/{pathfinder-DKRcXiLS.d.cts → pathfinder-QdG70sr9.d.cts} +2 -1
  33. package/dist/vector/index.cjs +153 -153
  34. package/dist/vector/index.d.cts +1 -1
  35. package/dist/vector/index.d.ts +1 -1
  36. package/dist/vector/index.js +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-3LHWTGHW.js.map +0 -1
  39. package/dist/chunk-VNYRI265.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { C as ChartNumberFormat, a as ChartValue, b as ChartRect, c as ChartScene, d as ChartSpec, e as ChartLayoutOptions, f as ChartWarning, g as ChartAxis, h as ChartLegend, i as ChartType, j as ChartStacking, k as ChartSeries, l as ChartIssue, m as ChartController, n as ChartValueScale, o as ChartSelection, p as ChartSpecPatch } from '../controller-ChjCCMLl.cjs';
2
- export { q as CHART_AXIS_KINDS, r as CHART_CURVES, s as CHART_LABEL_POSITIONS, t as CHART_LEGEND_POSITIONS, u as CHART_MARKERS, v as CHART_NUMBER_STYLES, w as CHART_ORIENTATIONS, x as CHART_SERIES_TYPES, y as CHART_STACKINGS, z as CHART_TRENDLINE_TYPES, A as CHART_TYPES, B as CHART_TYPE_LABELS, D as CSS_VARIABLE_CHART_THEME, E as ChartActionResult, F as ChartCircleMark, G as ChartControllerOptions, H as ChartCurve, I as ChartDomSpec, J as ChartEditOptions, K as ChartFamily, L as ChartLabelPosition, M as ChartLegendPosition, N as ChartLineMark, O as ChartMark, P as ChartMarkRole, Q as ChartMarker, R as ChartOrientation, S as ChartPathMark, T as ChartRectMark, U as ChartSeriesInput, V as ChartSeriesPatch, W as ChartSeriesType, X as ChartSparklineKind, Y as ChartSparklineOptions, Z as ChartState, _ as ChartSvgOptions, $ as ChartTableData, a0 as ChartTableOptions, a1 as ChartTextMark, a2 as ChartTextMeasure, a3 as ChartTheme, a4 as ChartTrendFit, a5 as ChartTrendline, a6 as ChartTrendlineType, a7 as DEFAULT_CHART_PALETTE, a8 as DEFAULT_CHART_THEME, a9 as chartColorInputValue, aa as chartColorsByCategory, ab as chartDataFromTable, ac as chartDataToTable, ad as chartFamily, ae as chartMovingAverage, af as chartPointColor, ag as chartSceneToDomSpec, ah as chartSceneToSvg, ai as chartSeriesColor, aj as chartSeriesType, ak as chartSliceColor, al as chartSupportsTrendlines, am as chartTextBaseline, an as chartTextTransform, ao as chartToSvg, ap as chartTrendlineName, aq as cloneChartSeries, ar as cloneChartSpec, as as contrastingTextColor, at as createChartController, au as createChartSpec, av as defaultChartAxis, aw as estimateChartTextWidth, ax as fitChartTrendline, ay as isCartesianChart, az as isXyChart, aA as layoutSparkline, aB as normalizeChartAxis, aC as normalizeChartSpec, aD as normalizeChartTrendline, aE as normalizeChartValues, aF as parseChartValue, aG as sameChartSelection, aH as sparklineToSvg, aI as trendNumberText, aJ as uniqueChartSeriesId } from '../controller-ChjCCMLl.cjs';
1
+ import { C as ChartNumberFormat, a as ChartValue, b as ChartRect, c as ChartScene, d as ChartSpec, e as ChartLayoutOptions, f as ChartTheme, g as ChartWarning, h as ChartAxis, i as ChartLegend, j as ChartType, k as ChartStacking, l as ChartSeries, m as ChartIssue, n as ChartController, o as ChartValueScale, p as ChartSelection, q as ChartSpecPatch } from '../controller-DS3drIvy.cjs';
2
+ export { r as CHART_AXIS_KINDS, s as CHART_CURVES, t as CHART_LABEL_POSITIONS, u as CHART_LEGEND_POSITIONS, v as CHART_MARKERS, w as CHART_NUMBER_STYLES, x as CHART_ORIENTATIONS, y as CHART_SERIES_TYPES, z as CHART_STACKINGS, A as CHART_TRENDLINE_TYPES, B as CHART_TYPES, D as CHART_TYPE_LABELS, E as CSS_VARIABLE_CHART_THEME, F as ChartActionResult, G as ChartCircleMark, H as ChartControllerOptions, I as ChartCurve, J as ChartDomSpec, K as ChartEditOptions, L as ChartFamily, M as ChartLabelPosition, N as ChartLegendPosition, O as ChartLineMark, P as ChartMark, Q as ChartMarkRole, R as ChartMarker, S as ChartOrientation, T as ChartPathMark, U as ChartRectMark, V as ChartSeriesInput, W as ChartSeriesPatch, X as ChartSeriesType, Y as ChartSparklineKind, Z as ChartSparklineOptions, _ as ChartState, $ as ChartSvgOptions, a0 as ChartTableData, a1 as ChartTableOptions, a2 as ChartTextMark, a3 as ChartTextMeasure, a4 as ChartTrendFit, a5 as ChartTrendline, a6 as ChartTrendlineType, a7 as DEFAULT_CHART_PALETTE, a8 as DEFAULT_CHART_THEME, a9 as chartColorInputValue, aa as chartColorsByCategory, ab as chartDataFromTable, ac as chartDataToTable, ad as chartFamily, ae as chartMovingAverage, af as chartPointColor, ag as chartSceneToDomSpec, ah as chartSceneToSvg, ai as chartSeriesColor, aj as chartSeriesType, ak as chartSliceColor, al as chartSupportsTrendlines, am as chartTextBaseline, an as chartTextTransform, ao as chartToSvg, ap as chartTrendlineName, aq as cloneChartSeries, ar as cloneChartSpec, as as contrastingTextColor, at as createChartController, au as createChartSpec, av as defaultChartAxis, aw as estimateChartTextWidth, ax as fitChartTrendline, ay as isCartesianChart, az as isXyChart, aA as layoutSparkline, aB as normalizeChartAxis, aC as normalizeChartSpec, aD as normalizeChartTrendline, aE as normalizeChartValues, aF as parseChartValue, aG as sameChartSelection, aH as sparklineToSvg, aI as trendNumberText, aJ as uniqueChartSeriesId } from '../controller-DS3drIvy.cjs';
3
3
  import { C as CommandSpec } from '../registry-CaR7LC6W.cjs';
4
4
  import { A as AgentToolProvider } from '../registry-B4l-lYts.cjs';
5
5
  import '../HistoryManager-DeQQMBCj.cjs';
@@ -287,6 +287,86 @@ declare const MAX_CHART_LINE_POINTS = 2000;
287
287
  /** Markers beyond this many are thinned to one per 2px cell. */
288
288
  declare const MAX_CHART_MARKERS = 1000;
289
289
 
290
+ /** Longest side, in pixels, of a rasterized chart unless `maxSize` says otherwise. */
291
+ declare const CHART_RASTER_MAX_SIZE = 1024;
292
+ interface ChartPaintScope {
293
+ /**
294
+ * Element whose CSS variables, `color` and `font-family` stand in for `var(--x)`,
295
+ * `currentColor` and `inherit` (default: the document's root element). Pass the chart's
296
+ * container when its theme is scoped (e.g. a `.dark` wrapper).
297
+ */
298
+ scope?: Element | null;
299
+ /** Looks up a custom property (`--name`) instead of `getComputedStyle(scope)`. Return '' when unset. */
300
+ lookup?: (name: string) => string;
301
+ }
302
+ interface RasterizeChartOptions extends ChartPaintScope {
303
+ /** Size of the chart in CSS pixels (the SVG's own size). */
304
+ width: number;
305
+ height: number;
306
+ /** Pixels per CSS pixel (default 2), reduced so the longest side stays within `maxSize`. */
307
+ scale?: number;
308
+ /** Longest side of the image in pixels (default 1024). */
309
+ maxSize?: number;
310
+ /** Fill behind the chart (default white; `transparent` keeps the alpha channel). */
311
+ background?: string;
312
+ /** Document to create the canvas and image in (default: the global one). */
313
+ document?: Document;
314
+ }
315
+ interface ChartRasterImage {
316
+ /** Base64 PNG, without the `data:` prefix. */
317
+ data: string;
318
+ mimeType: 'image/png';
319
+ /** Size of the image in pixels. */
320
+ width: number;
321
+ height: number;
322
+ }
323
+ /** Pixel size of the image for a chart of `width` × `height` CSS pixels: `scale` × the size, longest side ≤ `maxSize`. */
324
+ declare function chartRasterSize(width: number, height: number, scale?: number, maxSize?: number): {
325
+ width: number;
326
+ height: number;
327
+ scale: number;
328
+ };
329
+ /**
330
+ * Makes a chart SVG drawable on its own (as an `<img>` or on a canvas, where the page's CSS
331
+ * does not apply): `var(--x, fallback)` becomes the variable's value on `scope` (or the
332
+ * fallback), `currentColor` the scope's colour and `font-family="inherit"` its font. An
333
+ * attribute left empty is dropped, so the renderer's default applies instead of an invalid
334
+ * paint. Text content is left alone.
335
+ */
336
+ declare function resolveChartSvgPaints(svg: string, options?: ChartPaintScope): string;
337
+ /**
338
+ * Turns a chart SVG (from `chartToSvg`, `chartSceneToSvg` or a live chart's `<svg>`) into a
339
+ * PNG in the browser: resolves CSS-variable paints first (see `resolveChartSvgPaints`, without
340
+ * which they draw black), draws it through an `Image` onto a canvas at `scale` (longest side
341
+ * ≤ `maxSize`, default 1024) over `background`, and returns base64 data. Throws a message
342
+ * saying what to do instead when there is no DOM or canvas.
343
+ */
344
+ declare function rasterizeChartSvg(svg: string, options: RasterizeChartOptions): Promise<ChartRasterImage>;
345
+ /**
346
+ * A `rasterize` function for `createChartToolProvider` (so `render_chart { format: "png" }`
347
+ * works), or `undefined` when there is no DOM to draw with. The React and Svelte
348
+ * `useChartToolProvider` pass one by default.
349
+ */
350
+ declare function createChartRasterizer(options?: Omit<RasterizeChartOptions, 'width' | 'height'>): ((svg: string, size: {
351
+ width: number;
352
+ height: number;
353
+ }) => Promise<ChartRasterImage>) | undefined;
354
+ interface DownloadChartPngOptions extends Omit<RasterizeChartOptions, 'width' | 'height'> {
355
+ /** Chart size in CSS pixels (default 800 × 450). */
356
+ width?: number;
357
+ height?: number;
358
+ /** File name (default: the chart title, else `chart`, plus `.png`). */
359
+ filename?: string;
360
+ /** Colours and type (default: the light default theme, with concrete colours). */
361
+ theme?: Partial<ChartTheme>;
362
+ }
363
+ /** A file name for a chart: its title in lower case with dashes, else `chart`, plus the extension. */
364
+ declare function chartFileName(spec: Pick<ChartSpec, 'title'>, extension: string): string;
365
+ /** Renders a chart to PNG (see `rasterizeChartSvg`) and saves it through a download link. Returns the image and the file name. */
366
+ declare function downloadChartPng(spec: ChartSpec, options?: DownloadChartPngOptions): Promise<ChartRasterImage & {
367
+ filename: string;
368
+ }>;
369
+
290
370
  interface ChartSummary {
291
371
  type: ChartSpec['type'];
292
372
  title: string;
@@ -822,6 +902,11 @@ interface ChartToolProviderOptions {
822
902
  mimeType: string;
823
903
  };
824
904
  }
905
+ /**
906
+ * When to look at the chart, for `render_chart`'s description (after vectorcraft's
907
+ * `render_preview` and Ursula's VIEW_DIAGRAM_INSTRUCTIONS).
908
+ */
909
+ declare const RENDER_CHART_INSTRUCTIONS = "Draws the chart without changing it so you can check how it looks: SVG text by default, or a PNG image with format \"png\" when the host can rasterize. Returns the layout warnings (hidden or thinned labels, dropped markers) alongside. An image costs tokens, so render after a batch of edits rather than after each one, and use it to check what text cannot tell you: overlapping or cut-off labels, a crowded legend, unreadable colours, whether the chart reads at the given size. For values, ids and warnings alone, get_chart is cheaper.";
825
910
  /**
826
911
  * Agent tools for a chart editor, for a `ToolRegistry`: one tool per operation with strict
827
912
  * schemas. Reads (`get_chart`, `render_chart`, `check_chart_colors`, `recommend_chart`,
@@ -877,4 +962,4 @@ declare function blendChartScenes(from: ChartScene | null, to: ChartScene, t: nu
877
962
  /** Ease-out cubic, for tweens. */
878
963
  declare const easeChartTween: (t: number) => number;
879
964
 
880
- export { CHART_COLOR_SCHEMES, CHART_DATE_STEPS, CHART_LAYOUT_PRESETS, CHART_MERMAID_META_PREFIX, CHART_OOXML_CONTENT_TYPE, CHART_OOXML_NS, CHART_OOXML_RELATIONSHIP, CHART_PALETTE_SHADES, CHART_PRESENCE_COLORS, type ChartAgentCommand, ChartAxis, type ChartBoxStats, type ChartClock, type ChartColorCheck, type ChartColorCheckOptions, type ChartColorPair, type ChartColorScheme, type ChartCommandOptions, ChartController, type ChartDateLabels, type ChartDateStep, ChartDirector, type ChartDirectorActor, type ChartDirectorOptions, type ChartDragMoveOptions, type ChartFormatCode, type ChartFromTable, type ChartHistogramBin, ChartIssue, type ChartKeyInput, ChartLayoutOptions, type ChartLayoutPreset, ChartLegend, type ChartMermaidFamily, type ChartMermaidOptions, type ChartMermaidParseOptions, type ChartMermaidResult, ChartNumberFormat, type ChartOoxmlReadOptions, type ChartOoxmlReadResult, type ChartOoxmlWriteResult, type ChartPerformanceResult, type ChartPerformanceStep, type ChartPointDrag, ChartPresence, type ChartPresenceActor, type ChartPresenceState, type ChartPresetPatch, type ChartRecommendation, ChartRect, type ChartRgb, ChartScene, ChartSelection, ChartSeries, type ChartSeriesSummary, type ChartSnapOptions, ChartSpec, ChartSpecPatch, ChartStacking, ChartStream, type ChartStreamFormat, type ChartStreamResult, type ChartSummary, type ChartTableShape, type ChartToolProviderOptions, ChartType, ChartValue, ChartValueScale, type ChartVision, ChartWarning, type FoundChartMermaid, MAX_CHART_DATA_LABELS, MAX_CHART_LINE_POINTS, MAX_CHART_MARKERS, type NiceScale, analyzeChartTable, blendChartScenes, canDragChartPoint, chartBoxStats, chartClientToScene, chartColorDistance, chartContrastRatio, chartDateLabels, chartDateToSerial, chartFormatToCode, chartFromMermaid, chartFromOoxml, chartFromTable, chartHistogram, chartHitTest, chartLuminance, chartMermaidFamily, chartPointAnchor, chartPresetPatch, chartQuantile, chartRgbToHex, chartRgbToOklab, chartSerialToDate, chartSquarify, chartTextOn, chartToMermaid, chartToOoxml, chartValueAtPoint, chartXAtPoint, checkChartColors, compileChartFormatCode, createChartCommands, createChartToolProvider, createInstantChartClock, cyclePaletteColor, decimateChartPoints, describeChart, describeChartSelection, easeChartTween, findMermaidCharts, formatChartDate, formatChartNumber, formatChartValueWithCode, handleChartKey, layoutChart, linearMap, monochromeChartPalette, niceScale, niceStep, parseChartColor, parseChartDate, parsePartialChartJson, planChartCommand, realChartClock, recommendChartTypes, recommendForShape, shadeChartColor, simulateChartVision, snapChartDragValue, snapChartValue, startChartPointDrag, stepDecimals, summarizeChart, summarizeChartSeries };
965
+ export { CHART_COLOR_SCHEMES, CHART_DATE_STEPS, CHART_LAYOUT_PRESETS, CHART_MERMAID_META_PREFIX, CHART_OOXML_CONTENT_TYPE, CHART_OOXML_NS, CHART_OOXML_RELATIONSHIP, CHART_PALETTE_SHADES, CHART_PRESENCE_COLORS, CHART_RASTER_MAX_SIZE, type ChartAgentCommand, ChartAxis, type ChartBoxStats, type ChartClock, type ChartColorCheck, type ChartColorCheckOptions, type ChartColorPair, type ChartColorScheme, type ChartCommandOptions, ChartController, type ChartDateLabels, type ChartDateStep, ChartDirector, type ChartDirectorActor, type ChartDirectorOptions, type ChartDragMoveOptions, type ChartFormatCode, type ChartFromTable, type ChartHistogramBin, ChartIssue, type ChartKeyInput, ChartLayoutOptions, type ChartLayoutPreset, ChartLegend, type ChartMermaidFamily, type ChartMermaidOptions, type ChartMermaidParseOptions, type ChartMermaidResult, ChartNumberFormat, type ChartOoxmlReadOptions, type ChartOoxmlReadResult, type ChartOoxmlWriteResult, type ChartPaintScope, type ChartPerformanceResult, type ChartPerformanceStep, type ChartPointDrag, ChartPresence, type ChartPresenceActor, type ChartPresenceState, type ChartPresetPatch, type ChartRasterImage, type ChartRecommendation, ChartRect, type ChartRgb, ChartScene, ChartSelection, ChartSeries, type ChartSeriesSummary, type ChartSnapOptions, ChartSpec, ChartSpecPatch, ChartStacking, ChartStream, type ChartStreamFormat, type ChartStreamResult, type ChartSummary, type ChartTableShape, ChartTheme, type ChartToolProviderOptions, ChartType, ChartValue, ChartValueScale, type ChartVision, ChartWarning, type DownloadChartPngOptions, type FoundChartMermaid, MAX_CHART_DATA_LABELS, MAX_CHART_LINE_POINTS, MAX_CHART_MARKERS, type NiceScale, RENDER_CHART_INSTRUCTIONS, type RasterizeChartOptions, analyzeChartTable, blendChartScenes, canDragChartPoint, chartBoxStats, chartClientToScene, chartColorDistance, chartContrastRatio, chartDateLabels, chartDateToSerial, chartFileName, chartFormatToCode, chartFromMermaid, chartFromOoxml, chartFromTable, chartHistogram, chartHitTest, chartLuminance, chartMermaidFamily, chartPointAnchor, chartPresetPatch, chartQuantile, chartRasterSize, chartRgbToHex, chartRgbToOklab, chartSerialToDate, chartSquarify, chartTextOn, chartToMermaid, chartToOoxml, chartValueAtPoint, chartXAtPoint, checkChartColors, compileChartFormatCode, createChartCommands, createChartRasterizer, createChartToolProvider, createInstantChartClock, cyclePaletteColor, decimateChartPoints, describeChart, describeChartSelection, downloadChartPng, easeChartTween, findMermaidCharts, formatChartDate, formatChartNumber, formatChartValueWithCode, handleChartKey, layoutChart, linearMap, monochromeChartPalette, niceScale, niceStep, parseChartColor, parseChartDate, parsePartialChartJson, planChartCommand, rasterizeChartSvg, realChartClock, recommendChartTypes, recommendForShape, resolveChartSvgPaints, shadeChartColor, simulateChartVision, snapChartDragValue, snapChartValue, startChartPointDrag, stepDecimals, summarizeChart, summarizeChartSeries };
@@ -1,5 +1,5 @@
1
- import { C as ChartNumberFormat, a as ChartValue, b as ChartRect, c as ChartScene, d as ChartSpec, e as ChartLayoutOptions, f as ChartWarning, g as ChartAxis, h as ChartLegend, i as ChartType, j as ChartStacking, k as ChartSeries, l as ChartIssue, m as ChartController, n as ChartValueScale, o as ChartSelection, p as ChartSpecPatch } from '../controller-DtbEo3om.js';
2
- export { q as CHART_AXIS_KINDS, r as CHART_CURVES, s as CHART_LABEL_POSITIONS, t as CHART_LEGEND_POSITIONS, u as CHART_MARKERS, v as CHART_NUMBER_STYLES, w as CHART_ORIENTATIONS, x as CHART_SERIES_TYPES, y as CHART_STACKINGS, z as CHART_TRENDLINE_TYPES, A as CHART_TYPES, B as CHART_TYPE_LABELS, D as CSS_VARIABLE_CHART_THEME, E as ChartActionResult, F as ChartCircleMark, G as ChartControllerOptions, H as ChartCurve, I as ChartDomSpec, J as ChartEditOptions, K as ChartFamily, L as ChartLabelPosition, M as ChartLegendPosition, N as ChartLineMark, O as ChartMark, P as ChartMarkRole, Q as ChartMarker, R as ChartOrientation, S as ChartPathMark, T as ChartRectMark, U as ChartSeriesInput, V as ChartSeriesPatch, W as ChartSeriesType, X as ChartSparklineKind, Y as ChartSparklineOptions, Z as ChartState, _ as ChartSvgOptions, $ as ChartTableData, a0 as ChartTableOptions, a1 as ChartTextMark, a2 as ChartTextMeasure, a3 as ChartTheme, a4 as ChartTrendFit, a5 as ChartTrendline, a6 as ChartTrendlineType, a7 as DEFAULT_CHART_PALETTE, a8 as DEFAULT_CHART_THEME, a9 as chartColorInputValue, aa as chartColorsByCategory, ab as chartDataFromTable, ac as chartDataToTable, ad as chartFamily, ae as chartMovingAverage, af as chartPointColor, ag as chartSceneToDomSpec, ah as chartSceneToSvg, ai as chartSeriesColor, aj as chartSeriesType, ak as chartSliceColor, al as chartSupportsTrendlines, am as chartTextBaseline, an as chartTextTransform, ao as chartToSvg, ap as chartTrendlineName, aq as cloneChartSeries, ar as cloneChartSpec, as as contrastingTextColor, at as createChartController, au as createChartSpec, av as defaultChartAxis, aw as estimateChartTextWidth, ax as fitChartTrendline, ay as isCartesianChart, az as isXyChart, aA as layoutSparkline, aB as normalizeChartAxis, aC as normalizeChartSpec, aD as normalizeChartTrendline, aE as normalizeChartValues, aF as parseChartValue, aG as sameChartSelection, aH as sparklineToSvg, aI as trendNumberText, aJ as uniqueChartSeriesId } from '../controller-DtbEo3om.js';
1
+ import { C as ChartNumberFormat, a as ChartValue, b as ChartRect, c as ChartScene, d as ChartSpec, e as ChartLayoutOptions, f as ChartTheme, g as ChartWarning, h as ChartAxis, i as ChartLegend, j as ChartType, k as ChartStacking, l as ChartSeries, m as ChartIssue, n as ChartController, o as ChartValueScale, p as ChartSelection, q as ChartSpecPatch } from '../controller-BdKzaxs2.js';
2
+ export { r as CHART_AXIS_KINDS, s as CHART_CURVES, t as CHART_LABEL_POSITIONS, u as CHART_LEGEND_POSITIONS, v as CHART_MARKERS, w as CHART_NUMBER_STYLES, x as CHART_ORIENTATIONS, y as CHART_SERIES_TYPES, z as CHART_STACKINGS, A as CHART_TRENDLINE_TYPES, B as CHART_TYPES, D as CHART_TYPE_LABELS, E as CSS_VARIABLE_CHART_THEME, F as ChartActionResult, G as ChartCircleMark, H as ChartControllerOptions, I as ChartCurve, J as ChartDomSpec, K as ChartEditOptions, L as ChartFamily, M as ChartLabelPosition, N as ChartLegendPosition, O as ChartLineMark, P as ChartMark, Q as ChartMarkRole, R as ChartMarker, S as ChartOrientation, T as ChartPathMark, U as ChartRectMark, V as ChartSeriesInput, W as ChartSeriesPatch, X as ChartSeriesType, Y as ChartSparklineKind, Z as ChartSparklineOptions, _ as ChartState, $ as ChartSvgOptions, a0 as ChartTableData, a1 as ChartTableOptions, a2 as ChartTextMark, a3 as ChartTextMeasure, a4 as ChartTrendFit, a5 as ChartTrendline, a6 as ChartTrendlineType, a7 as DEFAULT_CHART_PALETTE, a8 as DEFAULT_CHART_THEME, a9 as chartColorInputValue, aa as chartColorsByCategory, ab as chartDataFromTable, ac as chartDataToTable, ad as chartFamily, ae as chartMovingAverage, af as chartPointColor, ag as chartSceneToDomSpec, ah as chartSceneToSvg, ai as chartSeriesColor, aj as chartSeriesType, ak as chartSliceColor, al as chartSupportsTrendlines, am as chartTextBaseline, an as chartTextTransform, ao as chartToSvg, ap as chartTrendlineName, aq as cloneChartSeries, ar as cloneChartSpec, as as contrastingTextColor, at as createChartController, au as createChartSpec, av as defaultChartAxis, aw as estimateChartTextWidth, ax as fitChartTrendline, ay as isCartesianChart, az as isXyChart, aA as layoutSparkline, aB as normalizeChartAxis, aC as normalizeChartSpec, aD as normalizeChartTrendline, aE as normalizeChartValues, aF as parseChartValue, aG as sameChartSelection, aH as sparklineToSvg, aI as trendNumberText, aJ as uniqueChartSeriesId } from '../controller-BdKzaxs2.js';
3
3
  import { C as CommandSpec } from '../registry-rVtFJjRM.js';
4
4
  import { A as AgentToolProvider } from '../registry-CSlH4iUn.js';
5
5
  import '../HistoryManager-DWSLd6Tf.js';
@@ -287,6 +287,86 @@ declare const MAX_CHART_LINE_POINTS = 2000;
287
287
  /** Markers beyond this many are thinned to one per 2px cell. */
288
288
  declare const MAX_CHART_MARKERS = 1000;
289
289
 
290
+ /** Longest side, in pixels, of a rasterized chart unless `maxSize` says otherwise. */
291
+ declare const CHART_RASTER_MAX_SIZE = 1024;
292
+ interface ChartPaintScope {
293
+ /**
294
+ * Element whose CSS variables, `color` and `font-family` stand in for `var(--x)`,
295
+ * `currentColor` and `inherit` (default: the document's root element). Pass the chart's
296
+ * container when its theme is scoped (e.g. a `.dark` wrapper).
297
+ */
298
+ scope?: Element | null;
299
+ /** Looks up a custom property (`--name`) instead of `getComputedStyle(scope)`. Return '' when unset. */
300
+ lookup?: (name: string) => string;
301
+ }
302
+ interface RasterizeChartOptions extends ChartPaintScope {
303
+ /** Size of the chart in CSS pixels (the SVG's own size). */
304
+ width: number;
305
+ height: number;
306
+ /** Pixels per CSS pixel (default 2), reduced so the longest side stays within `maxSize`. */
307
+ scale?: number;
308
+ /** Longest side of the image in pixels (default 1024). */
309
+ maxSize?: number;
310
+ /** Fill behind the chart (default white; `transparent` keeps the alpha channel). */
311
+ background?: string;
312
+ /** Document to create the canvas and image in (default: the global one). */
313
+ document?: Document;
314
+ }
315
+ interface ChartRasterImage {
316
+ /** Base64 PNG, without the `data:` prefix. */
317
+ data: string;
318
+ mimeType: 'image/png';
319
+ /** Size of the image in pixels. */
320
+ width: number;
321
+ height: number;
322
+ }
323
+ /** Pixel size of the image for a chart of `width` × `height` CSS pixels: `scale` × the size, longest side ≤ `maxSize`. */
324
+ declare function chartRasterSize(width: number, height: number, scale?: number, maxSize?: number): {
325
+ width: number;
326
+ height: number;
327
+ scale: number;
328
+ };
329
+ /**
330
+ * Makes a chart SVG drawable on its own (as an `<img>` or on a canvas, where the page's CSS
331
+ * does not apply): `var(--x, fallback)` becomes the variable's value on `scope` (or the
332
+ * fallback), `currentColor` the scope's colour and `font-family="inherit"` its font. An
333
+ * attribute left empty is dropped, so the renderer's default applies instead of an invalid
334
+ * paint. Text content is left alone.
335
+ */
336
+ declare function resolveChartSvgPaints(svg: string, options?: ChartPaintScope): string;
337
+ /**
338
+ * Turns a chart SVG (from `chartToSvg`, `chartSceneToSvg` or a live chart's `<svg>`) into a
339
+ * PNG in the browser: resolves CSS-variable paints first (see `resolveChartSvgPaints`, without
340
+ * which they draw black), draws it through an `Image` onto a canvas at `scale` (longest side
341
+ * ≤ `maxSize`, default 1024) over `background`, and returns base64 data. Throws a message
342
+ * saying what to do instead when there is no DOM or canvas.
343
+ */
344
+ declare function rasterizeChartSvg(svg: string, options: RasterizeChartOptions): Promise<ChartRasterImage>;
345
+ /**
346
+ * A `rasterize` function for `createChartToolProvider` (so `render_chart { format: "png" }`
347
+ * works), or `undefined` when there is no DOM to draw with. The React and Svelte
348
+ * `useChartToolProvider` pass one by default.
349
+ */
350
+ declare function createChartRasterizer(options?: Omit<RasterizeChartOptions, 'width' | 'height'>): ((svg: string, size: {
351
+ width: number;
352
+ height: number;
353
+ }) => Promise<ChartRasterImage>) | undefined;
354
+ interface DownloadChartPngOptions extends Omit<RasterizeChartOptions, 'width' | 'height'> {
355
+ /** Chart size in CSS pixels (default 800 × 450). */
356
+ width?: number;
357
+ height?: number;
358
+ /** File name (default: the chart title, else `chart`, plus `.png`). */
359
+ filename?: string;
360
+ /** Colours and type (default: the light default theme, with concrete colours). */
361
+ theme?: Partial<ChartTheme>;
362
+ }
363
+ /** A file name for a chart: its title in lower case with dashes, else `chart`, plus the extension. */
364
+ declare function chartFileName(spec: Pick<ChartSpec, 'title'>, extension: string): string;
365
+ /** Renders a chart to PNG (see `rasterizeChartSvg`) and saves it through a download link. Returns the image and the file name. */
366
+ declare function downloadChartPng(spec: ChartSpec, options?: DownloadChartPngOptions): Promise<ChartRasterImage & {
367
+ filename: string;
368
+ }>;
369
+
290
370
  interface ChartSummary {
291
371
  type: ChartSpec['type'];
292
372
  title: string;
@@ -822,6 +902,11 @@ interface ChartToolProviderOptions {
822
902
  mimeType: string;
823
903
  };
824
904
  }
905
+ /**
906
+ * When to look at the chart, for `render_chart`'s description (after vectorcraft's
907
+ * `render_preview` and Ursula's VIEW_DIAGRAM_INSTRUCTIONS).
908
+ */
909
+ declare const RENDER_CHART_INSTRUCTIONS = "Draws the chart without changing it so you can check how it looks: SVG text by default, or a PNG image with format \"png\" when the host can rasterize. Returns the layout warnings (hidden or thinned labels, dropped markers) alongside. An image costs tokens, so render after a batch of edits rather than after each one, and use it to check what text cannot tell you: overlapping or cut-off labels, a crowded legend, unreadable colours, whether the chart reads at the given size. For values, ids and warnings alone, get_chart is cheaper.";
825
910
  /**
826
911
  * Agent tools for a chart editor, for a `ToolRegistry`: one tool per operation with strict
827
912
  * schemas. Reads (`get_chart`, `render_chart`, `check_chart_colors`, `recommend_chart`,
@@ -877,4 +962,4 @@ declare function blendChartScenes(from: ChartScene | null, to: ChartScene, t: nu
877
962
  /** Ease-out cubic, for tweens. */
878
963
  declare const easeChartTween: (t: number) => number;
879
964
 
880
- export { CHART_COLOR_SCHEMES, CHART_DATE_STEPS, CHART_LAYOUT_PRESETS, CHART_MERMAID_META_PREFIX, CHART_OOXML_CONTENT_TYPE, CHART_OOXML_NS, CHART_OOXML_RELATIONSHIP, CHART_PALETTE_SHADES, CHART_PRESENCE_COLORS, type ChartAgentCommand, ChartAxis, type ChartBoxStats, type ChartClock, type ChartColorCheck, type ChartColorCheckOptions, type ChartColorPair, type ChartColorScheme, type ChartCommandOptions, ChartController, type ChartDateLabels, type ChartDateStep, ChartDirector, type ChartDirectorActor, type ChartDirectorOptions, type ChartDragMoveOptions, type ChartFormatCode, type ChartFromTable, type ChartHistogramBin, ChartIssue, type ChartKeyInput, ChartLayoutOptions, type ChartLayoutPreset, ChartLegend, type ChartMermaidFamily, type ChartMermaidOptions, type ChartMermaidParseOptions, type ChartMermaidResult, ChartNumberFormat, type ChartOoxmlReadOptions, type ChartOoxmlReadResult, type ChartOoxmlWriteResult, type ChartPerformanceResult, type ChartPerformanceStep, type ChartPointDrag, ChartPresence, type ChartPresenceActor, type ChartPresenceState, type ChartPresetPatch, type ChartRecommendation, ChartRect, type ChartRgb, ChartScene, ChartSelection, ChartSeries, type ChartSeriesSummary, type ChartSnapOptions, ChartSpec, ChartSpecPatch, ChartStacking, ChartStream, type ChartStreamFormat, type ChartStreamResult, type ChartSummary, type ChartTableShape, type ChartToolProviderOptions, ChartType, ChartValue, ChartValueScale, type ChartVision, ChartWarning, type FoundChartMermaid, MAX_CHART_DATA_LABELS, MAX_CHART_LINE_POINTS, MAX_CHART_MARKERS, type NiceScale, analyzeChartTable, blendChartScenes, canDragChartPoint, chartBoxStats, chartClientToScene, chartColorDistance, chartContrastRatio, chartDateLabels, chartDateToSerial, chartFormatToCode, chartFromMermaid, chartFromOoxml, chartFromTable, chartHistogram, chartHitTest, chartLuminance, chartMermaidFamily, chartPointAnchor, chartPresetPatch, chartQuantile, chartRgbToHex, chartRgbToOklab, chartSerialToDate, chartSquarify, chartTextOn, chartToMermaid, chartToOoxml, chartValueAtPoint, chartXAtPoint, checkChartColors, compileChartFormatCode, createChartCommands, createChartToolProvider, createInstantChartClock, cyclePaletteColor, decimateChartPoints, describeChart, describeChartSelection, easeChartTween, findMermaidCharts, formatChartDate, formatChartNumber, formatChartValueWithCode, handleChartKey, layoutChart, linearMap, monochromeChartPalette, niceScale, niceStep, parseChartColor, parseChartDate, parsePartialChartJson, planChartCommand, realChartClock, recommendChartTypes, recommendForShape, shadeChartColor, simulateChartVision, snapChartDragValue, snapChartValue, startChartPointDrag, stepDecimals, summarizeChart, summarizeChartSeries };
965
+ export { CHART_COLOR_SCHEMES, CHART_DATE_STEPS, CHART_LAYOUT_PRESETS, CHART_MERMAID_META_PREFIX, CHART_OOXML_CONTENT_TYPE, CHART_OOXML_NS, CHART_OOXML_RELATIONSHIP, CHART_PALETTE_SHADES, CHART_PRESENCE_COLORS, CHART_RASTER_MAX_SIZE, type ChartAgentCommand, ChartAxis, type ChartBoxStats, type ChartClock, type ChartColorCheck, type ChartColorCheckOptions, type ChartColorPair, type ChartColorScheme, type ChartCommandOptions, ChartController, type ChartDateLabels, type ChartDateStep, ChartDirector, type ChartDirectorActor, type ChartDirectorOptions, type ChartDragMoveOptions, type ChartFormatCode, type ChartFromTable, type ChartHistogramBin, ChartIssue, type ChartKeyInput, ChartLayoutOptions, type ChartLayoutPreset, ChartLegend, type ChartMermaidFamily, type ChartMermaidOptions, type ChartMermaidParseOptions, type ChartMermaidResult, ChartNumberFormat, type ChartOoxmlReadOptions, type ChartOoxmlReadResult, type ChartOoxmlWriteResult, type ChartPaintScope, type ChartPerformanceResult, type ChartPerformanceStep, type ChartPointDrag, ChartPresence, type ChartPresenceActor, type ChartPresenceState, type ChartPresetPatch, type ChartRasterImage, type ChartRecommendation, ChartRect, type ChartRgb, ChartScene, ChartSelection, ChartSeries, type ChartSeriesSummary, type ChartSnapOptions, ChartSpec, ChartSpecPatch, ChartStacking, ChartStream, type ChartStreamFormat, type ChartStreamResult, type ChartSummary, type ChartTableShape, ChartTheme, type ChartToolProviderOptions, ChartType, ChartValue, ChartValueScale, type ChartVision, ChartWarning, type DownloadChartPngOptions, type FoundChartMermaid, MAX_CHART_DATA_LABELS, MAX_CHART_LINE_POINTS, MAX_CHART_MARKERS, type NiceScale, RENDER_CHART_INSTRUCTIONS, type RasterizeChartOptions, analyzeChartTable, blendChartScenes, canDragChartPoint, chartBoxStats, chartClientToScene, chartColorDistance, chartContrastRatio, chartDateLabels, chartDateToSerial, chartFileName, chartFormatToCode, chartFromMermaid, chartFromOoxml, chartFromTable, chartHistogram, chartHitTest, chartLuminance, chartMermaidFamily, chartPointAnchor, chartPresetPatch, chartQuantile, chartRasterSize, chartRgbToHex, chartRgbToOklab, chartSerialToDate, chartSquarify, chartTextOn, chartToMermaid, chartToOoxml, chartValueAtPoint, chartXAtPoint, checkChartColors, compileChartFormatCode, createChartCommands, createChartRasterizer, createChartToolProvider, createInstantChartClock, cyclePaletteColor, decimateChartPoints, describeChart, describeChartSelection, downloadChartPng, easeChartTween, findMermaidCharts, formatChartDate, formatChartNumber, formatChartValueWithCode, handleChartKey, layoutChart, linearMap, monochromeChartPalette, niceScale, niceStep, parseChartColor, parseChartDate, parsePartialChartJson, planChartCommand, rasterizeChartSvg, realChartClock, recommendChartTypes, recommendForShape, resolveChartSvgPaints, shadeChartColor, simulateChartVision, snapChartDragValue, snapChartValue, startChartPointDrag, stepDecimals, summarizeChart, summarizeChartSeries };
@@ -128,6 +128,127 @@ import {
128
128
  } from "../chunk-664LQYFJ.js";
129
129
  import "../chunk-QVZZGT4X.js";
130
130
 
131
+ // src/chart/raster.ts
132
+ var CHART_RASTER_MAX_SIZE = 1024;
133
+ function chartRasterSize(width, height, scale = 2, maxSize = CHART_RASTER_MAX_SIZE) {
134
+ if (!(width > 0) || !(height > 0)) throw new Error(`A chart image needs a positive width and height; got ${width} \xD7 ${height}.`);
135
+ const factor = Math.min(scale > 0 ? scale : 1, maxSize / Math.max(width, height));
136
+ return { width: Math.max(1, Math.round(width * factor)), height: Math.max(1, Math.round(height * factor)), scale: factor };
137
+ }
138
+ function closingParen(text, open) {
139
+ let depth = 0;
140
+ for (let i = open; i < text.length; i++) {
141
+ if (text[i] === "(") depth++;
142
+ else if (text[i] === ")" && --depth === 0) return i + 1;
143
+ }
144
+ return -1;
145
+ }
146
+ function substituteVars(value, lookup, depth = 0) {
147
+ let out = "";
148
+ let i = 0;
149
+ for (let at = value.indexOf("var(", i); at !== -1; at = value.indexOf("var(", i)) {
150
+ const end = closingParen(value, at + 3);
151
+ if (end === -1) break;
152
+ const inner = value.slice(at + 4, end - 1);
153
+ let comma = -1;
154
+ for (let j = 0, d = 0; j < inner.length; j++) {
155
+ if (inner[j] === "(") d++;
156
+ else if (inner[j] === ")") d--;
157
+ else if (inner[j] === "," && d === 0) {
158
+ comma = j;
159
+ break;
160
+ }
161
+ }
162
+ const name = (comma === -1 ? inner : inner.slice(0, comma)).trim();
163
+ const fallback = comma === -1 ? "" : inner.slice(comma + 1).trim();
164
+ const found = lookup(name).trim();
165
+ const resolved = found || fallback;
166
+ out += value.slice(i, at) + (depth < 8 && resolved.includes("var(") ? substituteVars(resolved, lookup, depth + 1) : resolved);
167
+ i = end;
168
+ }
169
+ return out + value.slice(i);
170
+ }
171
+ var PAINT_ATTRIBUTE = /(\s)([\w:-]+)="([^"]*)"/g;
172
+ function resolveChartSvgPaints(svg, options = {}) {
173
+ const doc = globalThis.document;
174
+ const scope = options.scope ?? doc?.documentElement ?? null;
175
+ const view = scope?.ownerDocument?.defaultView ?? globalThis;
176
+ let computed;
177
+ const style = () => {
178
+ if (computed === void 0) computed = scope && typeof view?.getComputedStyle === "function" ? view.getComputedStyle(scope) : null;
179
+ return computed;
180
+ };
181
+ const lookup = options.lookup ?? ((name) => style()?.getPropertyValue(name) ?? "");
182
+ return svg.replace(PAINT_ATTRIBUTE, (match, space, name, raw) => {
183
+ let value = raw;
184
+ if (value.includes("var(")) value = substituteVars(value.replace(/&quot;/g, '"'), lookup).replace(/"/g, "&quot;");
185
+ if (/currentcolor/i.test(value)) value = value.replace(/currentcolor/gi, style()?.color || "#000000");
186
+ if (name === "font-family" && /^(inherit|unset|initial)$/i.test(value.trim())) value = (style()?.fontFamily || "sans-serif").replace(/"/g, "'");
187
+ if (value === raw) return match;
188
+ return value.trim() ? `${space}${name}="${value}"` : "";
189
+ });
190
+ }
191
+ var NO_DOM = 'Rasterizing a chart needs a browser DOM (document, Image and a 2D canvas). Outside a browser, render SVG with chartToSvg (or render_chart with format "svg") and convert it with an SVG renderer, or pass your own rasterize option to createChartToolProvider.';
192
+ async function svgToPngDataUrl(svg, options) {
193
+ const doc = options.document ?? globalThis.document;
194
+ const ImageCtor = doc?.defaultView?.Image ?? globalThis.Image;
195
+ if (!doc || typeof doc.createElement !== "function" || !ImageCtor) throw new Error(NO_DOM);
196
+ const size = chartRasterSize(options.width, options.height, options.scale, options.maxSize);
197
+ const canvas = doc.createElement("canvas");
198
+ canvas.width = size.width;
199
+ canvas.height = size.height;
200
+ let context = null;
201
+ try {
202
+ context = canvas.getContext("2d");
203
+ } catch {
204
+ context = null;
205
+ }
206
+ if (!context) throw new Error(NO_DOM);
207
+ const drawable = resolveChartSvgPaints(svg, options);
208
+ const image = new ImageCtor();
209
+ await new Promise((resolve2, reject) => {
210
+ image.onload = () => resolve2();
211
+ image.onerror = () => reject(new Error("The chart SVG could not be loaded as an image; check that it is a complete <svg> document with the SVG namespace."));
212
+ image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(drawable)}`;
213
+ });
214
+ const background = options.background ?? "#ffffff";
215
+ if (background !== "transparent") {
216
+ context.fillStyle = background;
217
+ context.fillRect(0, 0, size.width, size.height);
218
+ }
219
+ context.drawImage(image, 0, 0, size.width, size.height);
220
+ const url = canvas.toDataURL("image/png");
221
+ if (!url.startsWith("data:image/png")) throw new Error("This canvas cannot export PNG (toDataURL returned no image).");
222
+ return { url, width: size.width, height: size.height };
223
+ }
224
+ async function rasterizeChartSvg(svg, options) {
225
+ const { url, width, height } = await svgToPngDataUrl(svg, options);
226
+ return { data: url.slice(url.indexOf(",") + 1), mimeType: "image/png", width, height };
227
+ }
228
+ function createChartRasterizer(options = {}) {
229
+ const doc = options.document ?? globalThis.document;
230
+ if (!doc || typeof doc.createElement !== "function") return void 0;
231
+ return (svg, size) => rasterizeChartSvg(svg, { ...options, ...size });
232
+ }
233
+ function chartFileName(spec, extension) {
234
+ const base = (spec.title ?? "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "").slice(0, 60);
235
+ return `${base || "chart"}.${extension}`;
236
+ }
237
+ async function downloadChartPng(spec, options = {}) {
238
+ const { width = 800, height = 450, filename = chartFileName(spec, "png"), theme, ...raster } = options;
239
+ const svg = chartToSvg(spec, { width, height, theme });
240
+ const { url, width: w, height: h } = await svgToPngDataUrl(svg, { ...raster, width, height });
241
+ const doc = raster.document ?? globalThis.document;
242
+ const link = doc.createElement("a");
243
+ link.href = url;
244
+ link.download = filename;
245
+ link.style.display = "none";
246
+ doc.body?.appendChild(link);
247
+ link.click();
248
+ link.remove();
249
+ return { data: url.slice(url.indexOf(",") + 1), mimeType: "image/png", width: w, height: h, filename };
250
+ }
251
+
131
252
  // src/chart/recommend.ts
132
253
  var blank = (c) => c === null || c === void 0 || String(c).trim() === "";
133
254
  var isText = (c) => blank(c) || parseChartValue(c) === void 0;
@@ -763,6 +884,7 @@ function chartHitTest(scene, point, measure = (t, s, w = 400) => t.length * s *
763
884
  }
764
885
 
765
886
  // src/chart/tools.ts
887
+ var RENDER_CHART_INSTRUCTIONS = 'Draws the chart without changing it so you can check how it looks: SVG text by default, or a PNG image with format "png" when the host can rasterize. Returns the layout warnings (hidden or thinned labels, dropped markers) alongside. An image costs tokens, so render after a batch of edits rather than after each one, and use it to check what text cannot tell you: overlapping or cut-off labels, a crowded legend, unreadable colours, whether the chart reads at the given size. For values, ids and warnings alone, get_chart is cheaper.';
766
888
  var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
767
889
  var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
768
890
  var WRITE_IDEMPOTENT = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
@@ -817,21 +939,36 @@ function createChartToolProvider(controller, options = {}) {
817
939
  const renderChart = {
818
940
  name: "render_chart",
819
941
  title: "Render the chart",
820
- description: 'Draws the chart without changing it, to check it visually: SVG text by default, or a PNG image (format "png") when the host can rasterize. Look for overlapping or hidden labels; get_chart lists layout warnings without a render.',
942
+ description: RENDER_CHART_INSTRUCTIONS,
821
943
  inputSchema: {
822
944
  type: "object",
823
- properties: { width: WIDTH, height: HEIGHT, format: { type: "string", enum: ["svg", "png"], description: "svg (default) or png (only when the host supports it)." } },
945
+ properties: {
946
+ width: WIDTH,
947
+ height: HEIGHT,
948
+ format: { type: "string", enum: ["svg", "png"], description: "svg (default): the SVG document as text. png: an image to look at (only when the host can rasterize; costs image tokens)." }
949
+ },
824
950
  additionalProperties: false
825
951
  },
826
952
  annotations: { title: "Render the chart", ...READ },
827
953
  handler: async ({ width = size.width, height = size.height, format = "svg" }) => {
828
- const svg = chartToSvg(controller.toJSON(), { width, height });
954
+ const json = controller.toJSON();
955
+ const scene = layoutChart(json, { width, height, selection: null });
956
+ const svg = chartSceneToSvg(scene, { ariaLabel: json.title || void 0, description: describeChart(json) });
957
+ const warnings = scene.warnings;
829
958
  if (format === "png") {
830
- if (!options.rasterize) fail2('This host cannot rasterize charts; call render_chart with format "svg".');
959
+ if (!options.rasterize) fail2('This host cannot rasterize charts; call render_chart with format "svg", or get_chart for the layout warnings.');
831
960
  const image = await options.rasterize(svg, { width, height });
832
- return { content: [{ type: "image", data: image.data, mimeType: image.mimeType }], structuredContent: { width, height, mimeType: image.mimeType } };
961
+ const info = { width, height, mimeType: image.mimeType, warnings };
962
+ const note = warnings.length ? `Layout warnings: ${warnings.map((w) => w.message).join(" ")}` : "No layout warnings.";
963
+ return {
964
+ content: [
965
+ { type: "image", data: image.data, mimeType: image.mimeType },
966
+ { type: "text", text: `Chart at ${width} \xD7 ${height}. ${note}` }
967
+ ],
968
+ structuredContent: info
969
+ };
833
970
  }
834
- return { svg, width, height };
971
+ return { svg, width, height, warnings };
835
972
  }
836
973
  };
837
974
  const checkColors = {
@@ -1683,6 +1820,7 @@ export {
1683
1820
  CHART_ORIENTATIONS,
1684
1821
  CHART_PALETTE_SHADES,
1685
1822
  CHART_PRESENCE_COLORS,
1823
+ CHART_RASTER_MAX_SIZE,
1686
1824
  CHART_SERIES_TYPES,
1687
1825
  CHART_STACKINGS,
1688
1826
  CHART_TRENDLINE_TYPES,
@@ -1698,6 +1836,7 @@ export {
1698
1836
  MAX_CHART_DATA_LABELS,
1699
1837
  MAX_CHART_LINE_POINTS,
1700
1838
  MAX_CHART_MARKERS,
1839
+ RENDER_CHART_INSTRUCTIONS,
1701
1840
  analyzeChartTable,
1702
1841
  blendChartScenes,
1703
1842
  canDragChartPoint,
@@ -1712,6 +1851,7 @@ export {
1712
1851
  chartDateLabels,
1713
1852
  chartDateToSerial,
1714
1853
  chartFamily,
1854
+ chartFileName,
1715
1855
  chartFormatToCode,
1716
1856
  chartFromMermaid,
1717
1857
  chartFromOoxml,
@@ -1725,6 +1865,7 @@ export {
1725
1865
  chartPointColor,
1726
1866
  chartPresetPatch,
1727
1867
  chartQuantile,
1868
+ chartRasterSize,
1728
1869
  chartRgbToHex,
1729
1870
  chartRgbToOklab,
1730
1871
  chartSceneToDomSpec,
@@ -1751,6 +1892,7 @@ export {
1751
1892
  contrastingTextColor,
1752
1893
  createChartCommands,
1753
1894
  createChartController,
1895
+ createChartRasterizer,
1754
1896
  createChartSpec,
1755
1897
  createChartToolProvider,
1756
1898
  createInstantChartClock,
@@ -1759,6 +1901,7 @@ export {
1759
1901
  defaultChartAxis,
1760
1902
  describeChart,
1761
1903
  describeChartSelection,
1904
+ downloadChartPng,
1762
1905
  easeChartTween,
1763
1906
  estimateChartTextWidth,
1764
1907
  findMermaidCharts,
@@ -1784,9 +1927,11 @@ export {
1784
1927
  parseChartValue,
1785
1928
  parsePartialChartJson,
1786
1929
  planChartCommand,
1930
+ rasterizeChartSvg,
1787
1931
  realChartClock,
1788
1932
  recommendChartTypes,
1789
1933
  recommendForShape,
1934
+ resolveChartSvgPaints,
1790
1935
  sameChartSelection,
1791
1936
  shadeChartColor,
1792
1937
  simulateChartVision,