@opendata-ai/openchart-engine 9.7.0 → 9.8.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.
package/dist/index.js CHANGED
@@ -6963,7 +6963,7 @@ function buildArcPath(geom) {
6963
6963
  }) ?? "";
6964
6964
  }
6965
6965
  var DEFAULT_PALETTE = CATEGORICAL_FILL_PALETTE;
6966
- function groupSmallSlices(slices, threshold) {
6966
+ function groupSmallSlices(slices, threshold, fields) {
6967
6967
  const total = slices.reduce((sum, s) => sum + s.value, 0);
6968
6968
  if (total === 0) return slices;
6969
6969
  const big = [];
@@ -6979,7 +6979,7 @@ function groupSmallSlices(slices, threshold) {
6979
6979
  big.push({
6980
6980
  label: "Other",
6981
6981
  value: otherValue,
6982
- originalRow: { label: "Other", value: otherValue }
6982
+ originalRow: { [fields.category ?? "label"]: "Other", [fields.value]: otherValue }
6983
6983
  });
6984
6984
  }
6985
6985
  return big;
@@ -7026,18 +7026,16 @@ function computePieMarks(spec, scales, chartArea, _strategy, innerRadiusSpec = 0
7026
7026
  const val = finiteNumber(row[valueChannel.field]);
7027
7027
  if (val === void 0 || val < 0) continue;
7028
7028
  categoryTotals.set(cat, (categoryTotals.get(cat) ?? 0) + val);
7029
- if (!categoryRows.has(cat)) {
7030
- categoryRows.set(cat, row);
7031
- }
7029
+ const rows = categoryRows.get(cat);
7030
+ if (rows) rows.push(row);
7031
+ else categoryRows.set(cat, [row]);
7032
7032
  }
7033
7033
  for (const [label, value] of categoryTotals) {
7034
+ const rows = categoryRows.get(label) ?? [];
7034
7035
  slices.push({
7035
7036
  label,
7036
7037
  value,
7037
- originalRow: categoryRows.get(label) ?? {
7038
- [categoryField]: label,
7039
- [valueChannel.field]: value
7040
- }
7038
+ originalRow: rows.length === 1 ? rows[0] : { [categoryField]: rows[0]?.[categoryField] ?? label, [valueChannel.field]: value }
7041
7039
  });
7042
7040
  }
7043
7041
  } else {
@@ -7051,7 +7049,10 @@ function computePieMarks(spec, scales, chartArea, _strategy, innerRadiusSpec = 0
7051
7049
  }
7052
7050
  if (slices.length === 0) return [];
7053
7051
  slices.sort((a, b) => b.value - a.value);
7054
- slices = groupSmallSlices(slices, SMALL_SLICE_THRESHOLD);
7052
+ slices = groupSmallSlices(slices, SMALL_SLICE_THRESHOLD, {
7053
+ category: categoryField,
7054
+ value: valueChannel.field
7055
+ });
7055
7056
  const pieGenerator = d3Pie().value((d) => d.value).sort(null).padAngle(PIE_PAD_ANGLE).startAngle(startAngle).endAngle(endAngle);
7056
7057
  const arcs = pieGenerator(slices);
7057
7058
  const sweepBounds = computeSweepBounds(startAngle, endAngle);
@@ -8609,7 +8610,7 @@ function describeRefusal(markType, display, faceted, layered) {
8609
8610
  }
8610
8611
 
8611
8612
  // src/compiler/validation/locale.ts
8612
- import { matchLocale, SUPPORTED_LOCALES } from "@opendata-ai/openchart-core";
8613
+ import { jsonPointer, matchLocale, SUPPORTED_LOCALES } from "@opendata-ai/openchart-core";
8613
8614
  var INVALID_LOCALE_TYPE = "[INVALID_LOCALE_TYPE]";
8614
8615
  var LOCALE_WARNING_PREFIX = 'locale "';
8615
8616
  function isLocaleWarning(message) {
@@ -8625,10 +8626,21 @@ function validateLocale(spec, errors) {
8625
8626
  suggestion: 'Use a string such as "de-DE".'
8626
8627
  });
8627
8628
  };
8628
- validate(spec.locale, "/locale");
8629
- const theme = spec.theme;
8630
- if (theme && typeof theme === "object" && "locale" in theme)
8631
- validate(theme.locale, "/theme/locale");
8629
+ const validateSpecLocales = (current, prefix) => {
8630
+ validate(current.locale, `${prefix}/locale`);
8631
+ const theme = current.theme;
8632
+ if (theme && typeof theme === "object" && "locale" in theme)
8633
+ validate(theme.locale, `${prefix}/theme/locale`);
8634
+ if (Array.isArray(current.layer)) {
8635
+ for (const [index, child] of current.layer.entries())
8636
+ if (child && typeof child === "object" && !Array.isArray(child))
8637
+ validateSpecLocales(
8638
+ child,
8639
+ `${prefix}${jsonPointer("layer", index)}`
8640
+ );
8641
+ }
8642
+ };
8643
+ validateSpecLocales(spec, "");
8632
8644
  }
8633
8645
  function localeWarnings(locale) {
8634
8646
  if (locale === void 0) return [];
@@ -8733,7 +8745,7 @@ import {
8733
8745
  } from "@opendata-ai/openchart-core";
8734
8746
 
8735
8747
  // src/compiler/mark-options.ts
8736
- import { jsonPointer } from "@opendata-ai/openchart-core";
8748
+ import { jsonPointer as jsonPointer2 } from "@opendata-ai/openchart-core";
8737
8749
  var APPLIES_TO = {
8738
8750
  ticks: ["errorbar"],
8739
8751
  point: ["line", "area", "density"],
@@ -8792,7 +8804,7 @@ function collectMarkOptionErrors(input, path = "") {
8792
8804
  if (mark[key] !== void 0 && !allowed.includes(mark.type)) {
8793
8805
  errors.push({
8794
8806
  code: "INVALID_VALUE",
8795
- path: `${path}${jsonPointer("mark", key)}`,
8807
+ path: `${path}${jsonPointer2("mark", key)}`,
8796
8808
  message: `Option "${key}" is not supported by mark "${mark.type}".`,
8797
8809
  suggestion: `Remove ${key}, or use a supported mark: ${allowed.join(", ")}.`
8798
8810
  });
@@ -8802,7 +8814,7 @@ function collectMarkOptionErrors(input, path = "") {
8802
8814
  if (key !== "render" && !SHARED_OPTIONS.has(key) && !(key in APPLIES_TO)) {
8803
8815
  errors.push({
8804
8816
  code: "INVALID_VALUE",
8805
- path: `${path}${jsonPointer("mark", key)}`,
8817
+ path: `${path}${jsonPointer2("mark", key)}`,
8806
8818
  message: `Unknown mark option "${key}".`,
8807
8819
  suggestion: `Remove ${key}.`
8808
8820
  });
@@ -9700,7 +9712,7 @@ function resolveRampColors(channel, theme) {
9700
9712
  const scheme = resolveThemeScheme(channel.scale.scheme, theme);
9701
9713
  if (scheme) return channel.scale.reverse ? [...scheme].reverse() : scheme;
9702
9714
  }
9703
- return Object.values(theme.colors.sequential)[0] ?? theme.colors.categorical;
9715
+ return theme.colors.sequential[theme.colors.defaultSequential] ?? theme.colors.categorical;
9704
9716
  }
9705
9717
  function resolveBarWidth(availableWidth) {
9706
9718
  const preferred = Math.min(
@@ -10956,13 +10968,13 @@ function applyColorScaleRange(scales, encoding, theme, highlight, markType) {
10956
10968
  return [];
10957
10969
  }
10958
10970
  if (scales.color.type === "sequential") {
10959
- const seqStops = Object.values(theme.colors.sequential)[0] ?? theme.colors.categorical;
10971
+ const seqStops = theme.colors.sequential[theme.colors.defaultSequential] ?? theme.colors.categorical;
10960
10972
  scales.color.scale.range([
10961
10973
  seqStops[0],
10962
10974
  seqStops[seqStops.length - 1]
10963
10975
  ]);
10964
10976
  } else if (scales.color.type === "quantile" || scales.color.type === "quantize" || scales.color.type === "threshold") {
10965
- const seqStops = Object.values(theme.colors.sequential)[0] ?? theme.colors.categorical;
10977
+ const seqStops = theme.colors.sequential[theme.colors.defaultSequential] ?? theme.colors.categorical;
10966
10978
  const scale = scales.color.scale;
10967
10979
  scale.range(sampleRampColors(seqStops, scale.range().length));
10968
10980
  } else {
@@ -16828,15 +16840,15 @@ function flattenLayers(spec, parentData, parentEncoding, parentTransforms, paren
16828
16840
  }
16829
16841
 
16830
16842
  // src/compiler/validate.ts
16831
- import { isRaceSpec as isRaceSpec2, jsonPointer as jsonPointer20, MARK_TYPES as MARK_TYPES2 } from "@opendata-ai/openchart-core";
16843
+ import { isRaceSpec as isRaceSpec2, jsonPointer as jsonPointer22, MARK_TYPES as MARK_TYPES2 } from "@opendata-ai/openchart-core";
16832
16844
 
16833
16845
  // src/compiler/validation/barlist.ts
16834
- import { jsonPointer as jsonPointer3 } from "@opendata-ai/openchart-core";
16846
+ import { jsonPointer as jsonPointer4 } from "@opendata-ai/openchart-core";
16835
16847
 
16836
16848
  // src/compiler/validation/helpers.ts
16837
16849
  import {
16838
16850
  DIVERGING_PALETTES as DIVERGING_PALETTES2,
16839
- jsonPointer as jsonPointer2,
16851
+ jsonPointer as jsonPointer3,
16840
16852
  resolveSchemeName as resolveSchemeName3,
16841
16853
  SEQUENTIAL_PALETTES as SEQUENTIAL_PALETTES2,
16842
16854
  SUPPORTED_SCHEME_NAMES
@@ -16906,7 +16918,7 @@ function checkSchemeName(channelObj, channelPath, errors) {
16906
16918
  if (scale && typeof scale.scheme === "string" && !resolveSchemeName3(scale.scheme)) {
16907
16919
  errors.push({
16908
16920
  message: `Spec error: ${channelPath.join(".")}.scale.scheme "${scale.scheme}" is not a supported scheme name`,
16909
- path: jsonPointer2(...channelPath, "scale", "scheme"),
16921
+ path: jsonPointer3(...channelPath, "scale", "scheme"),
16910
16922
  code: "INVALID_VALUE",
16911
16923
  suggestion: `Use one of the supported scheme names: ${[...SUPPORTED_SCHEME_NAMES].join(", ")}. Or provide explicit colors via scale.range.`
16912
16924
  });
@@ -16919,7 +16931,7 @@ function checkSchemeUnused(encoding, errors, familyNote, suggestion) {
16919
16931
  if (scale && typeof scale.scheme === "string") {
16920
16932
  errors.push({
16921
16933
  message: `Spec error: encoding.${channel}.scale.scheme has no effect \u2014 ${familyNote}`,
16922
- path: jsonPointer2("encoding", channel, "scale", "scheme"),
16934
+ path: jsonPointer3("encoding", channel, "scale", "scheme"),
16923
16935
  code: "INVALID_VALUE",
16924
16936
  suggestion
16925
16937
  });
@@ -16933,7 +16945,7 @@ function checkMapSchemeName(channelObj, channelPath, errors) {
16933
16945
  if (channelObj.type === "nominal" || channelObj.type === "ordinal") {
16934
16946
  errors.push({
16935
16947
  message: `Spec error: ${channelPath.join(".")}.scale.scheme has no effect \u2014 categorical map colors come from scale.range and scale.domain`,
16936
- path: jsonPointer2(...channelPath, "scale", "scheme"),
16948
+ path: jsonPointer3(...channelPath, "scale", "scheme"),
16937
16949
  code: "INVALID_VALUE",
16938
16950
  suggestion: "Remove scale.scheme. To customize categorical map colors, provide explicit colors via scale.range (with scale.domain for category order)."
16939
16951
  });
@@ -16942,9 +16954,9 @@ function checkMapSchemeName(channelObj, channelPath, errors) {
16942
16954
  if (!(scale.scheme in SEQUENTIAL_PALETTES2) && !(scale.scheme in DIVERGING_PALETTES2)) {
16943
16955
  errors.push({
16944
16956
  message: `Spec error: ${channelPath.join(".")}.scale.scheme "${scale.scheme}" is not a supported map palette`,
16945
- path: jsonPointer2(...channelPath, "scale", "scheme"),
16957
+ path: jsonPointer3(...channelPath, "scale", "scheme"),
16946
16958
  code: "INVALID_VALUE",
16947
- suggestion: `Maps support sequential and diverging palettes: ${MAP_PALETTE_NAMES}. The default is "blue".`
16959
+ suggestion: `Maps support sequential and diverging palettes: ${MAP_PALETTE_NAMES}. The default is the theme's default sequential ramp ("blue" unless colors.defaultSequential is set).`
16948
16960
  });
16949
16961
  }
16950
16962
  }
@@ -16997,7 +17009,7 @@ function validateBarListSpec(spec, errors) {
16997
17009
  if (!ch || typeof ch !== "object") {
16998
17010
  errors.push({
16999
17011
  message: `Spec error: barlist encoding requires "${channel}" channel`,
17000
- path: jsonPointer3("encoding", channel),
17012
+ path: jsonPointer4("encoding", channel),
17001
17013
  code: "MISSING_FIELD",
17002
17014
  suggestion: `Add encoding.${channel} with a field from your data (${availableColumns}). Example: ${channel}: { field: "${columnList[0] ?? "myField"}", type: "${channel === "value" ? "quantitative" : "nominal"}" }`
17003
17015
  });
@@ -17006,7 +17018,7 @@ function validateBarListSpec(spec, errors) {
17006
17018
  if (!ch.field || typeof ch.field !== "string") {
17007
17019
  errors.push({
17008
17020
  message: `Spec error: encoding.${channel} must have a "field" string`,
17009
- path: jsonPointer3("encoding", channel, "field"),
17021
+ path: jsonPointer4("encoding", channel, "field"),
17010
17022
  code: "MISSING_FIELD",
17011
17023
  suggestion: `Add a field name from your data columns: ${availableColumns}`
17012
17024
  });
@@ -17015,7 +17027,7 @@ function validateBarListSpec(spec, errors) {
17015
17027
  if (!dataColumns.has(ch.field)) {
17016
17028
  errors.push({
17017
17029
  message: `Spec error: encoding.${channel}.field "${ch.field}" does not exist in data. Available columns: ${availableColumns}`,
17018
- path: jsonPointer3("encoding", channel, "field"),
17030
+ path: jsonPointer4("encoding", channel, "field"),
17019
17031
  code: "DATA_FIELD_MISSING",
17020
17032
  suggestion: `Use one of the available data columns: ${availableColumns}.${didYouMean(ch.field, columnList)}`
17021
17033
  });
@@ -17028,7 +17040,7 @@ function validateBarListSpec(spec, errors) {
17028
17040
  if (field && typeof field === "string" && !dataColumns.has(field)) {
17029
17041
  errors.push({
17030
17042
  message: `Spec error: encoding.${channel}.field "${field}" does not exist in data. Available columns: ${availableColumns}`,
17031
- path: jsonPointer3("encoding", channel, "field"),
17043
+ path: jsonPointer4("encoding", channel, "field"),
17032
17044
  code: "DATA_FIELD_MISSING",
17033
17045
  suggestion: `Use one of the available data columns: ${availableColumns}.${didYouMean(field, columnList)}`
17034
17046
  });
@@ -17095,7 +17107,7 @@ function validateBarListSpec(spec, errors) {
17095
17107
  // src/compiler/validation/chart.ts
17096
17108
  import {
17097
17109
  inferFieldType as inferFieldType6,
17098
- jsonPointer as jsonPointer7,
17110
+ jsonPointer as jsonPointer8,
17099
17111
  MARK_ENCODING_RULES
17100
17112
  } from "@opendata-ai/openchart-core";
17101
17113
 
@@ -17328,7 +17340,7 @@ function validatePreparedLabelPlacement(spec) {
17328
17340
  }
17329
17341
 
17330
17342
  // src/compiler/validation/mark-rules.ts
17331
- import { inferFieldType as inferFieldType5, jsonPointer as jsonPointer4 } from "@opendata-ai/openchart-core";
17343
+ import { inferFieldType as inferFieldType5, jsonPointer as jsonPointer5 } from "@opendata-ai/openchart-core";
17332
17344
  var VALID_RANGE_STYLES = /* @__PURE__ */ new Set(["dumbbell", "arrow", "bar"]);
17333
17345
  function validateRangeSpec(spec, errors) {
17334
17346
  const encoding = spec.encoding;
@@ -17507,7 +17519,7 @@ function validateCalendarSpec(spec, errors) {
17507
17519
  if (value != null && !isParseableDate(value)) {
17508
17520
  errors.push({
17509
17521
  message: `Spec error: encoding.x.field "${x.field}" contains an unparseable date at data[${i}]: ${JSON.stringify(value)}`,
17510
- path: jsonPointer4("data", i, x.field),
17522
+ path: jsonPointer5("data", i, x.field),
17511
17523
  code: "INVALID_VALUE",
17512
17524
  suggestion: `Fix data[${i}].${x.field} to a parseable date (ISO 8601 strings like "2024-01-15" or Date objects)`
17513
17525
  });
@@ -17525,7 +17537,7 @@ function validateCalendarSpec(spec, errors) {
17525
17537
  if (firstIndex !== void 0) {
17526
17538
  errors.push({
17527
17539
  message: `Spec error: calendar chart requires daily granularity, but data[${firstIndex}] and data[${i}] fall on the same day (${JSON.stringify(value)})`,
17528
- path: jsonPointer4("data", i, x.field),
17540
+ path: jsonPointer5("data", i, x.field),
17529
17541
  code: "ENCODING_MISMATCH",
17530
17542
  suggestion: `Aggregate to one row per day first, e.g. transform: [{ timeUnit: "yearmonthdate", field: "${x.field}", as: "day" }] plus an aggregate over the value field, or pre-aggregate the data.`
17531
17543
  });
@@ -17539,7 +17551,7 @@ function pointSizeError(tokens, value) {
17539
17551
  const radius = Math.max(1, Math.round(Math.sqrt(value / Math.PI)));
17540
17552
  return {
17541
17553
  message: `Spec error: ${tokens.join(".")} is a radius in pixels, and ${value} would draw a ${Math.round(value * 2)}px-wide circle. This usually means the value was written in Vega-Lite's units, where point size is an area in px^2.`,
17542
- path: jsonPointer4(...tokens),
17554
+ path: jsonPointer5(...tokens),
17543
17555
  code: "INVALID_VALUE",
17544
17556
  suggestion: `Point sizes are radii in px (default 5, typical 2-12). For the dot a Vega-Lite size of ${value} draws, use ${radius} (r = sqrt(area / pi)).`
17545
17557
  };
@@ -17672,7 +17684,7 @@ function checkStack(x, errors) {
17672
17684
  }
17673
17685
 
17674
17686
  // src/compiler/validation/time.ts
17675
- import { jsonPointer as jsonPointer6 } from "@opendata-ai/openchart-core";
17687
+ import { jsonPointer as jsonPointer7 } from "@opendata-ai/openchart-core";
17676
17688
 
17677
17689
  // src/playback/periods.ts
17678
17690
  var ISO_TIME_WITHOUT_OFFSET = /T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/i;
@@ -17737,7 +17749,7 @@ function firstDuplicateCell(rows, identityOf, time) {
17737
17749
  }
17738
17750
 
17739
17751
  // src/compiler/validation/playback.ts
17740
- import { jsonPointer as jsonPointer5 } from "@opendata-ai/openchart-core";
17752
+ import { jsonPointer as jsonPointer6 } from "@opendata-ai/openchart-core";
17741
17753
  var PLAYBACK_OPTIONS = [
17742
17754
  "duration",
17743
17755
  "step",
@@ -17770,7 +17782,7 @@ function checkUnknownPlaybackKeys(block, errors) {
17770
17782
  const hint = didYouMean(option, PLAYBACK_OPTIONS);
17771
17783
  errors.push(
17772
17784
  invalid2(
17773
- jsonPointer5("playback", option),
17785
+ jsonPointer6("playback", option),
17774
17786
  `Unknown playback option "${option}"`,
17775
17787
  hint ? `Check the option name and keep its value.${hint}` : `Remove "${option}". Supported playback options are ${PLAYBACK_OPTIONS.join(", ")}.`
17776
17788
  )
@@ -17794,7 +17806,7 @@ function checkTiming(name, block, errors) {
17794
17806
  if (isFiniteNumber(value) && value >= 0 && (value > 0 || allowZero)) continue;
17795
17807
  errors.push(
17796
17808
  invalid2(
17797
- jsonPointer5(name, option),
17809
+ jsonPointer6(name, option),
17798
17810
  `${name}.${option} must be a finite number ${allowZero ? "of zero or more" : "greater than zero"}`,
17799
17811
  `Use ${option}: ${example} or omit the option. Times are in milliseconds.`
17800
17812
  )
@@ -17816,7 +17828,7 @@ function checkSwitches(name, block, errors) {
17816
17828
  if (block[option] === void 0 || typeof block[option] === "boolean") continue;
17817
17829
  errors.push(
17818
17830
  invalid2(
17819
- jsonPointer5(name, option),
17831
+ jsonPointer6(name, option),
17820
17832
  `${name}.${option} must be true or false`,
17821
17833
  `Use ${option}: false to disable it or ${option}: true to enable it.`
17822
17834
  )
@@ -17946,7 +17958,7 @@ function checkUnsupportedFeatures(spec, encoding, context, errors) {
17946
17958
  if (encoding[channel] === void 0) continue;
17947
17959
  errors.push(
17948
17960
  mismatch(
17949
- jsonPointer6("encoding", channel),
17961
+ jsonPointer7("encoding", channel),
17950
17962
  `encoding.time cannot be combined with encoding.${channel}, which facets the chart`,
17951
17963
  `Remove encoding.${channel}, or remove encoding.time.`
17952
17964
  )
@@ -17988,7 +18000,7 @@ function checkPointOnlyOptions(spec, errors) {
17988
18000
  if (value === void 0 || value === false) continue;
17989
18001
  errors.push(
17990
18002
  mismatch(
17991
- jsonPointer6("playback", option),
18003
+ jsonPointer7("playback", option),
17992
18004
  `playback.${option} is only supported on point marks, not ${mark}`,
17993
18005
  `Remove playback.${option}, or change the mark to point.`
17994
18006
  )
@@ -18005,7 +18017,7 @@ function checkTrailAxes(spec, encoding, errors) {
18005
18017
  if (type === void 0 || type === "quantitative") continue;
18006
18018
  errors.push(
18007
18019
  mismatch(
18008
- jsonPointer6("playback", "trails"),
18020
+ jsonPointer7("playback", "trails"),
18009
18021
  `playback.trails needs quantitative x and y, but ${channel} is not quantitative (${JSON.stringify(type)})`,
18010
18022
  `Make encoding.${channel} quantitative, or remove playback.trails.`
18011
18023
  )
@@ -18021,7 +18033,7 @@ function checkAggregateKeepsTime(spec, timeField, errors) {
18021
18033
  if (groupby.includes(timeField)) return;
18022
18034
  errors.push(
18023
18035
  mismatch(
18024
- jsonPointer6("transform", index, "groupby"),
18036
+ jsonPointer7("transform", index, "groupby"),
18025
18037
  `this aggregate drops the time field '${timeField}', so there is nothing to play over`,
18026
18038
  `Add '${timeField}' to the aggregate's groupby.`
18027
18039
  )
@@ -18109,7 +18121,7 @@ function validateChartSpec(spec, errors, context = {}) {
18109
18121
  markType !== "bar" || !["x", "y", "x2", "y2"].includes(name) || channel.type !== "temporal")
18110
18122
  errors.push({
18111
18123
  code: "INVALID_VALUE",
18112
- path: jsonPointer7("encoding", name, "interval"),
18124
+ path: jsonPointer8("encoding", name, "interval"),
18113
18125
  message: "interval requires a temporal position channel of a bar mark and a calendar unit or finite positive milliseconds.",
18114
18126
  suggestion: "Use day, week, month, quarter, year, or a positive millisecond interval on a temporal position channel of a bar mark."
18115
18127
  });
@@ -18178,7 +18190,7 @@ function validateChartSpec(spec, errors, context = {}) {
18178
18190
  const suggestedChannel = channel === "y" && isThetaMark ? "theta" : channel;
18179
18191
  errors.push({
18180
18192
  message: `Spec error: ${markType} chart requires encoding.${suggestedChannel} but none was provided`,
18181
- path: jsonPointer7("encoding", suggestedChannel),
18193
+ path: jsonPointer8("encoding", suggestedChannel),
18182
18194
  code: "MISSING_FIELD",
18183
18195
  suggestion: `Add encoding.${suggestedChannel} with a field from your data (${availableColumns}) and type (${allowedTypes}). Example: ${suggestedChannel}: { field: "${[...dataColumns][0] ?? "myField"}", type: "${rule.allowedTypes[0]}" }`
18184
18196
  });
@@ -18230,7 +18242,7 @@ function validateChartSpec(spec, errors, context = {}) {
18230
18242
  if (t && typeof t === "object" && typeof t.calculate === "string") {
18231
18243
  errors.push({
18232
18244
  message: `Spec error: transform[${i}].calculate must be a structured expression object, not a string`,
18233
- path: jsonPointer7("transform", i, "calculate"),
18245
+ path: jsonPointer8("transform", i, "calculate"),
18234
18246
  code: "INVALID_TYPE",
18235
18247
  suggestion: 'Use the structured form for single operations, e.g. calculate: { op: "/", field: "a", field2: "b" } with as: "ratio". For running or grouped computations use the window or aggregate transforms.'
18236
18248
  });
@@ -18272,7 +18284,7 @@ function validateChartSpec(spec, errors, context = {}) {
18272
18284
  if (!elem.field || typeof elem.field !== "string") {
18273
18285
  errors.push({
18274
18286
  message: `Spec error: encoding.tooltip[${i}] must have a "field" string`,
18275
- path: jsonPointer7("encoding", "tooltip", i, "field"),
18287
+ path: jsonPointer8("encoding", "tooltip", i, "field"),
18276
18288
  code: "MISSING_FIELD",
18277
18289
  suggestion: `Add a field name from your data columns: ${availableColumns}`
18278
18290
  });
@@ -18281,7 +18293,7 @@ function validateChartSpec(spec, errors, context = {}) {
18281
18293
  if (!dataColumns.has(elem.field) && !transformFields.has(elem.field)) {
18282
18294
  errors.push({
18283
18295
  message: `Spec error: encoding.tooltip[${i}].field "${elem.field}" does not exist in data. Available columns: ${availableColumns}`,
18284
- path: jsonPointer7("encoding", "tooltip", i, "field"),
18296
+ path: jsonPointer8("encoding", "tooltip", i, "field"),
18285
18297
  code: "DATA_FIELD_MISSING",
18286
18298
  suggestion: `Use one of the available data columns: ${availableColumns}.${didYouMean(elem.field, columnList)}`
18287
18299
  });
@@ -18289,7 +18301,7 @@ function validateChartSpec(spec, errors, context = {}) {
18289
18301
  if (elem.type && !VALID_FIELD_TYPES.has(elem.type)) {
18290
18302
  errors.push({
18291
18303
  message: `Spec error: encoding.tooltip[${i}].type "${elem.type}" is not valid. Must be one of: ${[...VALID_FIELD_TYPES].join(", ")}`,
18292
- path: jsonPointer7("encoding", "tooltip", i, "type"),
18304
+ path: jsonPointer8("encoding", "tooltip", i, "type"),
18293
18305
  code: "INVALID_VALUE",
18294
18306
  suggestion: `Use one of: ${[...VALID_FIELD_TYPES].join(", ")}`
18295
18307
  });
@@ -18323,7 +18335,7 @@ function validateChartSpec(spec, errors, context = {}) {
18323
18335
  if (!channelObj.field || typeof channelObj.field !== "string") {
18324
18336
  errors.push({
18325
18337
  message: `Spec error: encoding.${channel} must have a "field" string`,
18326
- path: jsonPointer7("encoding", channel, "field"),
18338
+ path: jsonPointer8("encoding", channel, "field"),
18327
18339
  code: "MISSING_FIELD",
18328
18340
  suggestion: `For constant colors, use mark.fill (e.g., mark: { type: "bar", fill: "#1b7fa3" }) instead of encoding.${channel}. Encoding channels require a data field: ${availableColumns}`
18329
18341
  });
@@ -18332,7 +18344,7 @@ function validateChartSpec(spec, errors, context = {}) {
18332
18344
  if (!dataColumns.has(channelObj.field) && !transformFields.has(channelObj.field)) {
18333
18345
  errors.push({
18334
18346
  message: `Spec error: encoding.${channel}.field "${channelObj.field}" does not exist in data. Available columns: ${availableColumns}`,
18335
- path: jsonPointer7("encoding", channel, "field"),
18347
+ path: jsonPointer8("encoding", channel, "field"),
18336
18348
  code: "DATA_FIELD_MISSING",
18337
18349
  suggestion: `Use one of the available data columns: ${availableColumns}.${didYouMean(channelObj.field, columnList)}`
18338
18350
  });
@@ -18340,7 +18352,7 @@ function validateChartSpec(spec, errors, context = {}) {
18340
18352
  if (channelObj.type && !VALID_FIELD_TYPES.has(channelObj.type)) {
18341
18353
  errors.push({
18342
18354
  message: `Spec error: encoding.${channel}.type "${channelObj.type}" is not valid. Must be one of: ${[...VALID_FIELD_TYPES].join(", ")}`,
18343
- path: jsonPointer7("encoding", channel, "type"),
18355
+ path: jsonPointer8("encoding", channel, "type"),
18344
18356
  code: "INVALID_VALUE",
18345
18357
  suggestion: `Use one of: ${[...VALID_FIELD_TYPES].join(", ")}`
18346
18358
  });
@@ -18350,7 +18362,7 @@ function validateChartSpec(spec, errors, context = {}) {
18350
18362
  if (!channelRule.allowedTypes.includes(channelObj.type)) {
18351
18363
  errors.push({
18352
18364
  message: `Spec error: encoding.${channel} for ${markType} chart does not accept type "${channelObj.type}". Allowed types: ${channelRule.allowedTypes.join(", ")}`,
18353
- path: jsonPointer7("encoding", channel, "type"),
18365
+ path: jsonPointer8("encoding", channel, "type"),
18354
18366
  code: "ENCODING_MISMATCH",
18355
18367
  suggestion: `Change encoding.${channel}.type to one of: ${channelRule.allowedTypes.join(", ")}`
18356
18368
  });
@@ -18372,7 +18384,7 @@ function validateChartSpec(spec, errors, context = {}) {
18372
18384
  if (nonDateCount > 0) {
18373
18385
  errors.push({
18374
18386
  message: `Spec error: encoding.${channel}.field "${fieldName}" is declared as temporal but contains non-date values`,
18375
- path: jsonPointer7("encoding", channel),
18387
+ path: jsonPointer8("encoding", channel),
18376
18388
  code: "ENCODING_MISMATCH",
18377
18389
  suggestion: `Either change the type to "nominal" or ensure "${fieldName}" values are parseable dates (ISO 8601 strings like "2024-01-15" or Date objects)`
18378
18390
  });
@@ -18389,7 +18401,7 @@ function validateChartSpec(spec, errors, context = {}) {
18389
18401
  if (nonNumericCount > 0) {
18390
18402
  errors.push({
18391
18403
  message: `Spec error: encoding.${channel}.field "${fieldName}" is declared as quantitative but contains non-numeric values`,
18392
- path: jsonPointer7("encoding", channel),
18404
+ path: jsonPointer8("encoding", channel),
18393
18405
  code: "ENCODING_MISMATCH",
18394
18406
  suggestion: `Either change the type to "nominal" or ensure "${fieldName}" values are numbers`
18395
18407
  });
@@ -18466,14 +18478,14 @@ function validateChartSpec(spec, errors, context = {}) {
18466
18478
  if (!facetCh.field || typeof facetCh.field !== "string") {
18467
18479
  errors.push({
18468
18480
  message: `Spec error: encoding.${channel}.field is required and must be a non-empty string`,
18469
- path: jsonPointer7("encoding", channel, "field"),
18481
+ path: jsonPointer8("encoding", channel, "field"),
18470
18482
  code: "MISSING_FIELD",
18471
18483
  suggestion: `Add a field property to encoding.${channel} (e.g. { field: "category", type: "nominal" })`
18472
18484
  });
18473
18485
  } else if (!dataColumns.has(facetCh.field) && !transformFields.has(facetCh.field)) {
18474
18486
  errors.push({
18475
18487
  message: `Spec error: encoding.${channel}.field "${facetCh.field}" does not exist in data. Available columns: ${availableColumns}`,
18476
- path: jsonPointer7("encoding", channel, "field"),
18488
+ path: jsonPointer8("encoding", channel, "field"),
18477
18489
  code: "DATA_FIELD_MISSING",
18478
18490
  suggestion: `Use one of the available data columns: ${availableColumns}.${didYouMean(facetCh.field, columnList)}`
18479
18491
  });
@@ -18481,7 +18493,7 @@ function validateChartSpec(spec, errors, context = {}) {
18481
18493
  if (!facetCh.type || facetCh.type !== "nominal" && facetCh.type !== "ordinal") {
18482
18494
  errors.push({
18483
18495
  message: `Spec error: encoding.${channel}.type must be "nominal" or "ordinal"${facetCh.type ? `, got "${facetCh.type}"` : ""}`,
18484
- path: jsonPointer7("encoding", channel, "type"),
18496
+ path: jsonPointer8("encoding", channel, "type"),
18485
18497
  code: facetCh.type ? "INVALID_VALUE" : "MISSING_FIELD",
18486
18498
  suggestion: `Set encoding.${channel}.type to "nominal" or "ordinal"`
18487
18499
  });
@@ -18489,7 +18501,7 @@ function validateChartSpec(spec, errors, context = {}) {
18489
18501
  if (encoding.facet && typeof encoding.facet === "object") {
18490
18502
  errors.push({
18491
18503
  message: `Spec error: encoding.${channel} and encoding.facet cannot be used together`,
18492
- path: jsonPointer7("encoding", channel),
18504
+ path: jsonPointer8("encoding", channel),
18493
18505
  code: "INVALID_VALUE",
18494
18506
  suggestion: `Use either encoding.${channel} or encoding.facet, not both`
18495
18507
  });
@@ -18498,7 +18510,7 @@ function validateChartSpec(spec, errors, context = {}) {
18498
18510
  if (encoding[otherChannel]) {
18499
18511
  errors.push({
18500
18512
  message: "Spec error: encoding.row and encoding.column cannot be used together (cross-product faceting is not yet supported)",
18501
- path: jsonPointer7("encoding", channel),
18513
+ path: jsonPointer8("encoding", channel),
18502
18514
  code: "INVALID_VALUE",
18503
18515
  suggestion: "Use encoding.facet with columns for grid layout, or use only row or column"
18504
18516
  });
@@ -18551,7 +18563,7 @@ function validateChartSpec(spec, errors, context = {}) {
18551
18563
  }
18552
18564
 
18553
18565
  // src/compiler/validation/chrome-links.ts
18554
- import { isSafeLink, jsonPointer as jsonPointer8 } from "@opendata-ai/openchart-core";
18566
+ import { isSafeLink, jsonPointer as jsonPointer9 } from "@opendata-ai/openchart-core";
18555
18567
  function validateChromeLinks(spec, errors, prefix = "") {
18556
18568
  const chrome = spec.chrome;
18557
18569
  if (chrome && typeof chrome === "object" && !Array.isArray(chrome)) {
@@ -18561,7 +18573,7 @@ function validateChromeLinks(spec, errors, prefix = "") {
18561
18573
  if (typeof value.href === "string" && isSafeLink(value.href)) continue;
18562
18574
  errors.push({
18563
18575
  code: "INVALID_VALUE",
18564
- path: `${prefix}${jsonPointer8("chrome", key, "href")}`,
18576
+ path: `${prefix}${jsonPointer9("chrome", key, "href")}`,
18565
18577
  message: `chrome.${key}.href must be an http, https or mailto link.`,
18566
18578
  suggestion: "Use an absolute http, https or mailto URL, or omit href."
18567
18579
  });
@@ -18570,13 +18582,13 @@ function validateChromeLinks(spec, errors, prefix = "") {
18570
18582
  if (Array.isArray(spec.layer)) {
18571
18583
  for (const [index, child] of spec.layer.entries()) {
18572
18584
  if (child && typeof child === "object" && !Array.isArray(child))
18573
- validateChromeLinks(child, errors, `${prefix}${jsonPointer8("layer", index)}`);
18585
+ validateChromeLinks(child, errors, `${prefix}${jsonPointer9("layer", index)}`);
18574
18586
  }
18575
18587
  }
18576
18588
  }
18577
18589
 
18578
18590
  // src/compiler/validation/common-fields.ts
18579
- import { encodePointerToken as encodePointerToken2, jsonPointer as jsonPointer9 } from "@opendata-ai/openchart-core";
18591
+ import { encodePointerToken as encodePointerToken2, jsonPointer as jsonPointer10 } from "@opendata-ai/openchart-core";
18580
18592
  function validateAnimation(spec, errors) {
18581
18593
  const animation = spec.animation;
18582
18594
  if (typeof animation === "string" && !["fluid", "subtle"].includes(animation)) {
@@ -18635,7 +18647,7 @@ function validatePhaseTiming(settings, path, errors) {
18635
18647
  errors.push({
18636
18648
  code: "INVALID_VALUE",
18637
18649
  suggestion: TIMING_SUGGESTION,
18638
- path: jsonPointer9(...path),
18650
+ path: jsonPointer10(...path),
18639
18651
  message: "A phase cannot combine spring with duration or ease."
18640
18652
  });
18641
18653
  }
@@ -18643,7 +18655,7 @@ function validatePhaseTiming(settings, path, errors) {
18643
18655
  errors.push({
18644
18656
  code: "INVALID_VALUE",
18645
18657
  suggestion: TIMING_SUGGESTION,
18646
- path: jsonPointer9(...path, "spring"),
18658
+ path: jsonPointer10(...path, "spring"),
18647
18659
  message: "Spring must be a configuration object."
18648
18660
  });
18649
18661
  } else {
@@ -18654,7 +18666,7 @@ function validatePhaseTiming(settings, path, errors) {
18654
18666
  errors.push({
18655
18667
  code: "INVALID_VALUE",
18656
18668
  suggestion: TIMING_SUGGESTION,
18657
- path: jsonPointer9(...path, "spring", key),
18669
+ path: jsonPointer10(...path, "spring", key),
18658
18670
  message: "Spring parameters must be finite positive stiffness, damping, or mass."
18659
18671
  });
18660
18672
  }
@@ -18669,7 +18681,7 @@ function validateDuration(duration, path, errors) {
18669
18681
  errors.push({
18670
18682
  code: "INVALID_VALUE",
18671
18683
  suggestion: TIMING_SUGGESTION,
18672
- path: jsonPointer9(...path, "duration"),
18684
+ path: jsonPointer10(...path, "duration"),
18673
18685
  message: "Animation duration must be finite and nonnegative."
18674
18686
  });
18675
18687
  }
@@ -18679,7 +18691,7 @@ function validateEase(ease, path, errors) {
18679
18691
  errors.push({
18680
18692
  code: "INVALID_VALUE",
18681
18693
  suggestion: "Use ease: 'smooth', 'snappy', or 'gentle'.",
18682
- path: jsonPointer9(...path, "ease"),
18694
+ path: jsonPointer10(...path, "ease"),
18683
18695
  message: `Animation ease must be 'smooth', 'snappy', or 'gentle', got ${JSON.stringify(ease)}.`
18684
18696
  });
18685
18697
  }
@@ -18745,7 +18757,7 @@ function validateFieldMetadata(obj, errors) {
18745
18757
  return;
18746
18758
  }
18747
18759
  for (const [field, value] of Object.entries(obj.fields)) {
18748
- const path = jsonPointer9("fields", field);
18760
+ const path = jsonPointer10("fields", field);
18749
18761
  if (!value || typeof value !== "object" || Array.isArray(value)) {
18750
18762
  fail2(path, "Field metadata must be an object.");
18751
18763
  continue;
@@ -18788,7 +18800,7 @@ function validateFieldMetadata(obj, errors) {
18788
18800
  }
18789
18801
 
18790
18802
  // src/compiler/validation/geo-map.ts
18791
- import { jsonPointer as jsonPointer11 } from "@opendata-ai/openchart-core";
18803
+ import { jsonPointer as jsonPointer12 } from "@opendata-ai/openchart-core";
18792
18804
 
18793
18805
  // src/geo/projections.ts
18794
18806
  import { geoAlbersUsa, geoBounds, geoEqualEarth, geoIdentity, geoMercator } from "d3-geo";
@@ -18892,7 +18904,7 @@ function topologyBBox(topology) {
18892
18904
  }
18893
18905
 
18894
18906
  // src/compiler/validation/geo-time.ts
18895
- import { jsonPointer as jsonPointer10 } from "@opendata-ai/openchart-core";
18907
+ import { jsonPointer as jsonPointer11 } from "@opendata-ai/openchart-core";
18896
18908
  var TIME_TYPES = ["temporal", "ordinal", "quantitative"];
18897
18909
  var POINT_ONLY_OPTIONS = ["labels", "trails"];
18898
18910
  function isRecord4(value) {
@@ -18950,7 +18962,7 @@ function checkPlaybackBlock(spec, errors) {
18950
18962
  if (value === void 0 || value === false) continue;
18951
18963
  errors.push(
18952
18964
  invalid3(
18953
- jsonPointer10("playback", option),
18965
+ jsonPointer11("playback", option),
18954
18966
  `playback.${option} is only supported on point charts, not maps`,
18955
18967
  `Remove playback.${option}.`
18956
18968
  )
@@ -19112,7 +19124,7 @@ function validateGeoMapSpec(spec, errors) {
19112
19124
  if (!["activeValue", "distribution"].includes(name) || typeof value !== "boolean")
19113
19125
  errors.push({
19114
19126
  code: "INVALID_VALUE",
19115
- path: jsonPointer11("colorKey", name),
19127
+ path: jsonPointer12("colorKey", name),
19116
19128
  message: "colorKey accepts only boolean activeValue and distribution.",
19117
19129
  suggestion: "Omit either option or set it to true or false."
19118
19130
  });
@@ -19163,7 +19175,7 @@ function validateGeoMapSpec(spec, errors) {
19163
19175
  if (typeof focus[i] !== "string" && typeof focus[i] !== "number") {
19164
19176
  errors.push({
19165
19177
  message: `Spec error: geo.focus array element [${i}] must be a string or number`,
19166
- path: jsonPointer11("geo", "focus", i),
19178
+ path: jsonPointer12("geo", "focus", i),
19167
19179
  code: "INVALID_TYPE",
19168
19180
  suggestion: "Each element in the focus array should be a feature id (string or number)"
19169
19181
  });
@@ -19211,7 +19223,7 @@ function validateGeoMapSpec(spec, errors) {
19211
19223
  if (typeof feats[i] !== "string" && typeof feats[i] !== "number") {
19212
19224
  errors.push({
19213
19225
  message: `Spec error: geo.focus.features[${i}] must be a string or number`,
19214
- path: jsonPointer11("geo", "focus", "features", i),
19226
+ path: jsonPointer12("geo", "focus", "features", i),
19215
19227
  code: "INVALID_TYPE",
19216
19228
  suggestion: "Each element should be a feature id (string or number)"
19217
19229
  });
@@ -19299,14 +19311,14 @@ function validateGeoMapSpec(spec, errors) {
19299
19311
  if (!enc || typeof enc !== "object") {
19300
19312
  errors.push({
19301
19313
  message: `Spec error: points requires "${ch}" encoding channel`,
19302
- path: jsonPointer11("points", ch),
19314
+ path: jsonPointer12("points", ch),
19303
19315
  code: "MISSING_FIELD",
19304
19316
  suggestion: `Add points.${ch}, e.g. ${ch}: { field: "${ch === "longitude" ? "lon" : "lat"}", type: "quantitative" }`
19305
19317
  });
19306
19318
  } else if (!enc.field || typeof enc.field !== "string") {
19307
19319
  errors.push({
19308
19320
  message: `Spec error: points.${ch} must have a "field" string`,
19309
- path: jsonPointer11("points", ch, "field"),
19321
+ path: jsonPointer12("points", ch, "field"),
19310
19322
  code: "MISSING_FIELD",
19311
19323
  suggestion: `Add a field name, e.g. ${ch}: { field: "${ch === "longitude" ? "lon" : "lat"}" }`
19312
19324
  });
@@ -19317,7 +19329,7 @@ function validateGeoMapSpec(spec, errors) {
19317
19329
  if (enc && typeof enc === "object" && (!enc.field || typeof enc.field !== "string")) {
19318
19330
  errors.push({
19319
19331
  message: `Spec error: points.${ch} must have a "field" string when provided`,
19320
- path: jsonPointer11("points", ch, "field"),
19332
+ path: jsonPointer12("points", ch, "field"),
19321
19333
  code: "MISSING_FIELD",
19322
19334
  suggestion: `Add a field name, e.g. ${ch}: { field: "myField" }`
19323
19335
  });
@@ -19573,7 +19585,7 @@ function validateGeoMapViews(spec, errors) {
19573
19585
  }
19574
19586
 
19575
19587
  // src/compiler/validation/graph.ts
19576
- import { jsonPointer as jsonPointer12 } from "@opendata-ai/openchart-core";
19588
+ import { jsonPointer as jsonPointer13 } from "@opendata-ai/openchart-core";
19577
19589
  function validateGraphSpec(spec, errors) {
19578
19590
  if (!Array.isArray(spec.nodes)) {
19579
19591
  errors.push({
@@ -19600,7 +19612,7 @@ function validateGraphSpec(spec, errors) {
19600
19612
  if (!node3 || typeof node3 !== "object") {
19601
19613
  errors.push({
19602
19614
  message: `Spec error: nodes[${i}] must be an object`,
19603
- path: jsonPointer12("nodes", i),
19615
+ path: jsonPointer13("nodes", i),
19604
19616
  code: "INVALID_TYPE",
19605
19617
  suggestion: 'Each node must be an object with at least an "id" field, e.g. { id: "a" }'
19606
19618
  });
@@ -19609,7 +19621,7 @@ function validateGraphSpec(spec, errors) {
19609
19621
  if (typeof node3.id !== "string" || node3.id === "") {
19610
19622
  errors.push({
19611
19623
  message: `Spec error: nodes[${i}] must have a non-empty string "id" field`,
19612
- path: jsonPointer12("nodes", i, "id"),
19624
+ path: jsonPointer13("nodes", i, "id"),
19613
19625
  code: "MISSING_FIELD",
19614
19626
  suggestion: 'Add a string id to the node, e.g. { id: "node1" }'
19615
19627
  });
@@ -19661,7 +19673,7 @@ function validateGraphSpec(spec, errors) {
19661
19673
  if (!edge || typeof edge !== "object") {
19662
19674
  errors.push({
19663
19675
  message: `Spec error: edges[${i}] must be an object`,
19664
- path: jsonPointer12("edges", i),
19676
+ path: jsonPointer13("edges", i),
19665
19677
  code: "INVALID_TYPE",
19666
19678
  suggestion: 'Each edge must be an object with "source" and "target" fields, e.g. { source: "a", target: "b" }'
19667
19679
  });
@@ -19670,14 +19682,14 @@ function validateGraphSpec(spec, errors) {
19670
19682
  if (typeof edge.source !== "string" || edge.source === "") {
19671
19683
  errors.push({
19672
19684
  message: `Spec error: edges[${i}] must have a non-empty string "source" field`,
19673
- path: jsonPointer12("edges", i, "source"),
19685
+ path: jsonPointer13("edges", i, "source"),
19674
19686
  code: "MISSING_FIELD",
19675
19687
  suggestion: 'Add a source node id, e.g. { source: "a", target: "b" }'
19676
19688
  });
19677
19689
  } else if (nodeIds.size > 0 && !nodeIds.has(edge.source)) {
19678
19690
  errors.push({
19679
19691
  message: `Spec error: edges[${i}].source "${edge.source}" does not reference an existing node id`,
19680
- path: jsonPointer12("edges", i, "source"),
19692
+ path: jsonPointer13("edges", i, "source"),
19681
19693
  code: "DATA_FIELD_MISSING",
19682
19694
  suggestion: `Use one of the existing node ids: ${[...nodeIds].slice(0, 5).join(", ")}${nodeIds.size > 5 ? "..." : ""}.${didYouMean(edge.source, [...nodeIds])}`
19683
19695
  });
@@ -19685,14 +19697,14 @@ function validateGraphSpec(spec, errors) {
19685
19697
  if (typeof edge.target !== "string" || edge.target === "") {
19686
19698
  errors.push({
19687
19699
  message: `Spec error: edges[${i}] must have a non-empty string "target" field`,
19688
- path: jsonPointer12("edges", i, "target"),
19700
+ path: jsonPointer13("edges", i, "target"),
19689
19701
  code: "MISSING_FIELD",
19690
19702
  suggestion: 'Add a target node id, e.g. { source: "a", target: "b" }'
19691
19703
  });
19692
19704
  } else if (nodeIds.size > 0 && !nodeIds.has(edge.target)) {
19693
19705
  errors.push({
19694
19706
  message: `Spec error: edges[${i}].target "${edge.target}" does not reference an existing node id`,
19695
- path: jsonPointer12("edges", i, "target"),
19707
+ path: jsonPointer13("edges", i, "target"),
19696
19708
  code: "DATA_FIELD_MISSING",
19697
19709
  suggestion: `Use one of the existing node ids: ${[...nodeIds].slice(0, 5).join(", ")}${nodeIds.size > 5 ? "..." : ""}.${didYouMean(edge.target, [...nodeIds])}`
19698
19710
  });
@@ -19724,7 +19736,7 @@ function validateGraphSpec(spec, errors) {
19724
19736
  if (ch?.field && typeof ch.field === "string" && nodes.length > 0 && !nodeFields.has(ch.field)) {
19725
19737
  errors.push({
19726
19738
  message: `Spec error: encoding.${channel}.field "${ch.field}" does not exist on nodes. Available fields: ${[...nodeFields].join(", ")}`,
19727
- path: jsonPointer12("encoding", channel, "field"),
19739
+ path: jsonPointer13("encoding", channel, "field"),
19728
19740
  code: "DATA_FIELD_MISSING",
19729
19741
  suggestion: `Use one of the node fields: ${[...nodeFields].join(", ")}.${didYouMean(ch.field, [...nodeFields])}`
19730
19742
  });
@@ -19736,7 +19748,7 @@ function validateGraphSpec(spec, errors) {
19736
19748
  if (ch?.field && typeof ch.field === "string" && edges.length > 0 && !edgeFields.has(ch.field)) {
19737
19749
  errors.push({
19738
19750
  message: `Spec error: encoding.${channel}.field "${ch.field}" does not exist on edges. Available fields: ${[...edgeFields].join(", ")}`,
19739
- path: jsonPointer12("encoding", channel, "field"),
19751
+ path: jsonPointer13("encoding", channel, "field"),
19740
19752
  code: "DATA_FIELD_MISSING",
19741
19753
  suggestion: `Use one of the edge fields: ${[...edgeFields].join(", ")}.${didYouMean(ch.field, [...edgeFields])}`
19742
19754
  });
@@ -19763,7 +19775,7 @@ function validateGraphSpec(spec, errors) {
19763
19775
  }
19764
19776
 
19765
19777
  // src/compiler/validation/layer.ts
19766
- import { jsonPointer as jsonPointer13, MARK_TYPES } from "@opendata-ai/openchart-core";
19778
+ import { jsonPointer as jsonPointer14, MARK_TYPES } from "@opendata-ai/openchart-core";
19767
19779
  function rootLeafPath(path, parentPrefix, leafPrefix, leaf, inheritsData) {
19768
19780
  const [, first, second] = path.split("/");
19769
19781
  const leafEncoding = leaf.encoding;
@@ -19787,7 +19799,7 @@ function validateLayerSpec(spec, errors, prefix = "") {
19787
19799
  if (!child || typeof child !== "object" || Array.isArray(child)) {
19788
19800
  errors.push({
19789
19801
  message: `Spec error: layer[${i}] must be an object`,
19790
- path: `${prefix}${jsonPointer13("layer", i)}`,
19802
+ path: `${prefix}${jsonPointer14("layer", i)}`,
19791
19803
  code: "INVALID_TYPE",
19792
19804
  suggestion: "Each layer must be a chart spec (with mark) or a nested layer spec (with layer)"
19793
19805
  });
@@ -19797,7 +19809,7 @@ function validateLayerSpec(spec, errors, prefix = "") {
19797
19809
  if (childObj.type === "race") {
19798
19810
  errors.push({
19799
19811
  code: "INVALID_VALUE",
19800
- path: `${prefix}${jsonPointer13("layer", i, "type")}`,
19812
+ path: `${prefix}${jsonPointer14("layer", i, "type")}`,
19801
19813
  message: "Race specs cannot be layered.",
19802
19814
  suggestion: "Render the race in its own container."
19803
19815
  });
@@ -19808,14 +19820,14 @@ function validateLayerSpec(spec, errors, prefix = "") {
19808
19820
  if (!isNestedLayer && !isChildChart) {
19809
19821
  errors.push({
19810
19822
  message: `Spec error: layer[${i}] must have a "mark" field or a "layer" array`,
19811
- path: `${prefix}${jsonPointer13("layer", i)}`,
19823
+ path: `${prefix}${jsonPointer14("layer", i)}`,
19812
19824
  code: "MISSING_FIELD",
19813
19825
  suggestion: "Each layer must be a chart spec (with mark + encoding) or a nested layer spec (with layer array)"
19814
19826
  });
19815
19827
  continue;
19816
19828
  }
19817
19829
  if (isNestedLayer) {
19818
- validateLayerSpec(childObj, errors, `${prefix}${jsonPointer13("layer", i)}`);
19830
+ validateLayerSpec(childObj, errors, `${prefix}${jsonPointer14("layer", i)}`);
19819
19831
  } else if (isChildChart) {
19820
19832
  const mark = childObj.mark;
19821
19833
  let markValue;
@@ -19827,7 +19839,7 @@ function validateLayerSpec(spec, errors, prefix = "") {
19827
19839
  if (!markValue || !MARK_TYPES.has(markValue)) {
19828
19840
  errors.push({
19829
19841
  message: `Spec error: layer[${i}].mark "${markValue ?? String(mark)}" is not a valid mark type`,
19830
- path: `${prefix}${jsonPointer13("layer", i, "mark")}`,
19842
+ path: `${prefix}${jsonPointer14("layer", i, "mark")}`,
19831
19843
  code: "INVALID_VALUE",
19832
19844
  suggestion: `Change mark to one of: ${[...MARK_TYPES].join(", ")}`
19833
19845
  });
@@ -19849,7 +19861,7 @@ function validateLayerSpec(spec, errors, prefix = "") {
19849
19861
  if (mergedForValidation.data && mergedForValidation.encoding) {
19850
19862
  const leafErrors = [];
19851
19863
  validateChartSpec(mergedForValidation, leafErrors, { inLayer: true });
19852
- const leafPrefix = `${prefix}${jsonPointer13("layer", i)}`;
19864
+ const leafPrefix = `${prefix}${jsonPointer14("layer", i)}`;
19853
19865
  for (const error of leafErrors)
19854
19866
  errors.push({
19855
19867
  ...error,
@@ -19862,10 +19874,10 @@ function validateLayerSpec(spec, errors, prefix = "") {
19862
19874
  }
19863
19875
 
19864
19876
  // src/compiler/validation/race.ts
19865
- import { jsonPointer as jsonPointer15 } from "@opendata-ai/openchart-core";
19877
+ import { jsonPointer as jsonPointer16 } from "@opendata-ai/openchart-core";
19866
19878
 
19867
19879
  // src/compiler/validation/race-options.ts
19868
- import { jsonPointer as jsonPointer14 } from "@opendata-ai/openchart-core";
19880
+ import { jsonPointer as jsonPointer15 } from "@opendata-ai/openchart-core";
19869
19881
  var RACE_OPTIONS = [
19870
19882
  "top",
19871
19883
  "duration",
@@ -19908,7 +19920,7 @@ function checkUnknownRaceKeys(race, errors) {
19908
19920
  const hint = didYouMean(option, RACE_OPTIONS);
19909
19921
  errors.push({
19910
19922
  code: "INVALID_VALUE",
19911
- path: jsonPointer14("race", option),
19923
+ path: jsonPointer15("race", option),
19912
19924
  message: `Spec error: Unknown race option "${option}"`,
19913
19925
  suggestion: hint ? `Check the option name and keep its value.${hint}` : `Remove "${option}". Supported race options are ${RACE_OPTIONS.join(", ")}.`
19914
19926
  });
@@ -19971,7 +19983,7 @@ function checkTimingAcrossBlocks(race, playback, errors) {
19971
19983
  if (race[raceField2] === void 0 || playback[playbackField] === void 0) continue;
19972
19984
  errors.push({
19973
19985
  code: "INVALID_VALUE",
19974
- path: jsonPointer14("playback", playbackField),
19986
+ path: jsonPointer15("playback", playbackField),
19975
19987
  message: `Spec error: duration and step are mutually exclusive across race and playback (race.${raceField2}, playback.${playbackField})`,
19976
19988
  suggestion: "Keep duration for the whole race or step for each period, in one block. Remove the other option."
19977
19989
  });
@@ -19983,14 +19995,14 @@ function checkPlaybackAgainstRace(race, playback, errors) {
19983
19995
  if (CHART_ONLY_PLAYBACK_OPTIONS.includes(field)) {
19984
19996
  errors.push({
19985
19997
  code: "INVALID_VALUE",
19986
- path: jsonPointer14("playback", field),
19998
+ path: jsonPointer15("playback", field),
19987
19999
  message: `Spec error: playback.${field} applies to point and circle charts only`,
19988
20000
  suggestion: `Remove playback.${field} from the race spec.`
19989
20001
  });
19990
20002
  } else if (isRecord5(race) && race[field] !== void 0 && playback[field] !== void 0) {
19991
20003
  errors.push({
19992
20004
  code: "INVALID_VALUE",
19993
- path: jsonPointer14("playback", field),
20005
+ path: jsonPointer15("playback", field),
19994
20006
  message: `Spec error: ${field} is set in both race and playback`,
19995
20007
  suggestion: `Keep ${field} in one block. Remove it from race or from playback.`
19996
20008
  });
@@ -20068,7 +20080,7 @@ function validateEncoding(encoding, errors) {
20068
20080
  if (!isRecord6(definition)) {
20069
20081
  errors.push({
20070
20082
  code: definition === void 0 ? "MISSING_FIELD" : "INVALID_TYPE",
20071
- path: jsonPointer15("encoding", channel),
20083
+ path: jsonPointer16("encoding", channel),
20072
20084
  message: definition === void 0 ? `Spec error: race encoding requires a "${channel}" channel` : `Spec error: encoding.${channel} must be an object`,
20073
20085
  suggestion: `Add encoding.${channel} with a field from your data, e.g. { field: "${example}" }.`
20074
20086
  });
@@ -20078,7 +20090,7 @@ function validateEncoding(encoding, errors) {
20078
20090
  if (typeof field !== "string" || field.trim() === "") {
20079
20091
  errors.push({
20080
20092
  code: field === void 0 ? "MISSING_FIELD" : "INVALID_TYPE",
20081
- path: jsonPointer15("encoding", channel, "field"),
20093
+ path: jsonPointer16("encoding", channel, "field"),
20082
20094
  message: `Spec error: encoding.${channel} requires a non-empty "field" string`,
20083
20095
  suggestion: `Set encoding.${channel}.field to the name of a column in your data, e.g. "${example}".`
20084
20096
  });
@@ -20090,7 +20102,7 @@ function validateEncoding(encoding, errors) {
20090
20102
  if (definition === void 0 || isRecord6(definition)) continue;
20091
20103
  errors.push({
20092
20104
  code: "INVALID_TYPE",
20093
- path: jsonPointer15("encoding", channel),
20105
+ path: jsonPointer16("encoding", channel),
20094
20106
  message: `Spec error: encoding.${channel} must be an object`,
20095
20107
  suggestion: `Use a channel definition or omit encoding.${channel}.`
20096
20108
  });
@@ -20111,7 +20123,7 @@ function validateEncodingFields(encoding, data, errors) {
20111
20123
  if (typeof field !== "string" || field.trim() === "" || dataColumns.has(field)) continue;
20112
20124
  errors.push({
20113
20125
  message: `Spec error: encoding.${channel}.field "${field}" does not exist in data. Available columns: ${availableColumns}`,
20114
- path: jsonPointer15("encoding", channel, "field"),
20126
+ path: jsonPointer16("encoding", channel, "field"),
20115
20127
  code: "DATA_FIELD_MISSING",
20116
20128
  suggestion: `Use one of the available data columns: ${availableColumns}.${didYouMean(field, columnList)}`
20117
20129
  });
@@ -20166,7 +20178,7 @@ function validateMark(mark, errors) {
20166
20178
  if (option === "type" || option === supported) continue;
20167
20179
  errors.push({
20168
20180
  code: "INVALID_VALUE",
20169
- path: jsonPointer15("mark", option),
20181
+ path: jsonPointer16("mark", option),
20170
20182
  message: `Spec error: unknown option "${option}" on the race "${type}" mark`,
20171
20183
  suggestion: `Remove "${option}". The "${type}" mark supports "${supported}".${didYouMean(option, [supported])}`
20172
20184
  });
@@ -20195,7 +20207,7 @@ function validateData(data, errors) {
20195
20207
  const otherRows = invalidCount > 1 ? " and the other non-object rows" : "";
20196
20208
  errors.push({
20197
20209
  code: "INVALID_TYPE",
20198
- path: jsonPointer15("data", firstInvalidRow),
20210
+ path: jsonPointer16("data", firstInvalidRow),
20199
20211
  message: `Spec error: each race data row must be an object. ${invalidCount} of ${data.length} rows ${invalidRows}.`,
20200
20212
  suggestion: `Replace or remove row ${firstInvalidRow + 1}${otherRows}. Each row should name the fields used by time, key, and value.`
20201
20213
  });
@@ -20220,7 +20232,7 @@ function validateRaceSpec(spec, errors) {
20220
20232
  }
20221
20233
 
20222
20234
  // src/compiler/validation/sankey.ts
20223
- import { jsonPointer as jsonPointer16 } from "@opendata-ai/openchart-core";
20235
+ import { jsonPointer as jsonPointer17 } from "@opendata-ai/openchart-core";
20224
20236
 
20225
20237
  // src/sankey/overrides.ts
20226
20238
  import { getBreakpoint } from "@opendata-ai/openchart-core";
@@ -20295,7 +20307,7 @@ function validateSankeySpec(spec, errors) {
20295
20307
  if (!ch || typeof ch !== "object") {
20296
20308
  errors.push({
20297
20309
  message: `Spec error: sankey encoding requires "${channel}" channel`,
20298
- path: jsonPointer16("encoding", channel),
20310
+ path: jsonPointer17("encoding", channel),
20299
20311
  code: "MISSING_FIELD",
20300
20312
  suggestion: `Add encoding.${channel} with a field from your data (${availableColumns}). Example: ${channel}: { field: "${columnList[0] ?? "myField"}", type: "${channel === "value" ? "quantitative" : "nominal"}" }`
20301
20313
  });
@@ -20304,7 +20316,7 @@ function validateSankeySpec(spec, errors) {
20304
20316
  if (!ch.field || typeof ch.field !== "string") {
20305
20317
  errors.push({
20306
20318
  message: `Spec error: encoding.${channel} must have a "field" string`,
20307
- path: jsonPointer16("encoding", channel, "field"),
20319
+ path: jsonPointer17("encoding", channel, "field"),
20308
20320
  code: "MISSING_FIELD",
20309
20321
  suggestion: `Add a field name from your data columns: ${availableColumns}`
20310
20322
  });
@@ -20313,7 +20325,7 @@ function validateSankeySpec(spec, errors) {
20313
20325
  if (!dataColumns.has(ch.field)) {
20314
20326
  errors.push({
20315
20327
  message: `Spec error: encoding.${channel}.field "${ch.field}" does not exist in data. Available columns: ${availableColumns}`,
20316
- path: jsonPointer16("encoding", channel, "field"),
20328
+ path: jsonPointer17("encoding", channel, "field"),
20317
20329
  code: "DATA_FIELD_MISSING",
20318
20330
  suggestion: `Use one of the available data columns: ${availableColumns}.${didYouMean(ch.field, columnList)}`
20319
20331
  });
@@ -20343,7 +20355,7 @@ function validateSankeyOverrides(overrides, errors) {
20343
20355
  if (!breakpoints.includes(breakpoint)) {
20344
20356
  errors.push({
20345
20357
  message: `Spec error: sankey overrides has unknown breakpoint "${breakpoint}"`,
20346
- path: jsonPointer16("overrides", breakpoint),
20358
+ path: jsonPointer17("overrides", breakpoint),
20347
20359
  code: "INVALID_VALUE",
20348
20360
  suggestion: `Valid breakpoints: compact (under 400px), medium (400 to 700px).${didYouMean(breakpoint, [...breakpoints])}`
20349
20361
  });
@@ -20352,7 +20364,7 @@ function validateSankeyOverrides(overrides, errors) {
20352
20364
  if (!isPlainObject2(block)) {
20353
20365
  errors.push({
20354
20366
  message: `Spec error: overrides.${breakpoint} must be an object`,
20355
- path: jsonPointer16("overrides", breakpoint),
20367
+ path: jsonPointer17("overrides", breakpoint),
20356
20368
  code: "INVALID_TYPE",
20357
20369
  suggestion: `Use overrides.${breakpoint}: { other: 0.05 }`
20358
20370
  });
@@ -20382,7 +20394,7 @@ var OVERRIDE_FIELD_CHECKS = {
20382
20394
  function validateOverrideBlock(breakpoint, block, errors) {
20383
20395
  const fields = SANKEY_OVERRIDE_FIELDS;
20384
20396
  for (const [field, value] of Object.entries(block)) {
20385
- const path = jsonPointer16("overrides", breakpoint, field);
20397
+ const path = jsonPointer17("overrides", breakpoint, field);
20386
20398
  if (!fields.includes(field)) {
20387
20399
  errors.push({
20388
20400
  message: `Spec error: overrides.${breakpoint} cannot set "${field}"`,
@@ -20405,7 +20417,7 @@ function validateOverrideBlock(breakpoint, block, errors) {
20405
20417
  }
20406
20418
 
20407
20419
  // src/compiler/validation/table.ts
20408
- import { jsonPointer as jsonPointer17 } from "@opendata-ai/openchart-core";
20420
+ import { jsonPointer as jsonPointer18 } from "@opendata-ai/openchart-core";
20409
20421
  function validateTableSpec(spec, errors) {
20410
20422
  if (!Array.isArray(spec.data)) {
20411
20423
  errors.push({
@@ -20454,7 +20466,7 @@ function validateTableSpec(spec, errors) {
20454
20466
  if (!col || typeof col !== "object") {
20455
20467
  errors.push({
20456
20468
  message: `Spec error: columns[${i}] must be an object`,
20457
- path: jsonPointer17("columns", i),
20469
+ path: jsonPointer18("columns", i),
20458
20470
  code: "INVALID_TYPE",
20459
20471
  suggestion: 'Each column entry should be an object, e.g. { key: "fieldName" }'
20460
20472
  });
@@ -20463,7 +20475,7 @@ function validateTableSpec(spec, errors) {
20463
20475
  if (!col.key || typeof col.key !== "string") {
20464
20476
  errors.push({
20465
20477
  message: `Spec error: columns[${i}] must have a "key" string`,
20466
- path: jsonPointer17("columns", i, "key"),
20478
+ path: jsonPointer18("columns", i, "key"),
20467
20479
  code: "MISSING_FIELD",
20468
20480
  suggestion: `Add a key referencing a data field. Available columns: ${availableColumns}`
20469
20481
  });
@@ -20472,7 +20484,7 @@ function validateTableSpec(spec, errors) {
20472
20484
  if (!dataColumns.has(col.key)) {
20473
20485
  errors.push({
20474
20486
  message: `Spec error: columns[${i}].key "${col.key}" does not exist in data. Available columns: ${availableColumns}`,
20475
- path: jsonPointer17("columns", i, "key"),
20487
+ path: jsonPointer18("columns", i, "key"),
20476
20488
  code: "DATA_FIELD_MISSING",
20477
20489
  suggestion: `Use one of the available data columns: ${availableColumns}.${didYouMean(col.key, columnList)}`
20478
20490
  });
@@ -20483,7 +20495,7 @@ function validateTableSpec(spec, errors) {
20483
20495
  if (visuals.length > 1) {
20484
20496
  errors.push({
20485
20497
  message: `Spec error: columns[${i}] has multiple visual features (${visuals.join(", ")}). Only one is allowed per column.`,
20486
- path: jsonPointer17("columns", i),
20498
+ path: jsonPointer18("columns", i),
20487
20499
  code: "INVALID_VALUE",
20488
20500
  suggestion: `Keep only one visual feature per column. Remove all but one of: ${visuals.join(", ")}`
20489
20501
  });
@@ -20492,13 +20504,70 @@ function validateTableSpec(spec, errors) {
20492
20504
  }
20493
20505
 
20494
20506
  // src/compiler/validation/theme-chrome.ts
20495
- import { isSafeLogoSource, jsonPointer as jsonPointer18 } from "@opendata-ai/openchart-core";
20507
+ import { isSafeLogoSource, jsonPointer as jsonPointer20 } from "@opendata-ai/openchart-core";
20508
+
20509
+ // src/compiler/validation/theme-ramps.ts
20510
+ import { jsonPointer as jsonPointer19 } from "@opendata-ai/openchart-core";
20496
20511
  function isObject(value) {
20497
20512
  return !!value && typeof value === "object" && !Array.isArray(value);
20498
20513
  }
20514
+ function isStop(stop) {
20515
+ return typeof stop === "string" || isObject(stop) && typeof stop.light === "string" && typeof stop.dark === "string";
20516
+ }
20517
+ function validateThemeRamps(theme, themePath, errors) {
20518
+ if (!isObject(theme.colors)) return;
20519
+ if (theme.colors.defaultSequential !== void 0 && typeof theme.colors.defaultSequential !== "string") {
20520
+ errors.push({
20521
+ code: "INVALID_TYPE",
20522
+ path: `${themePath}${jsonPointer19("colors", "defaultSequential")}`,
20523
+ message: "theme.colors.defaultSequential must be a string naming a sequential ramp.",
20524
+ suggestion: 'Use a ramp key such as "blue", or omit defaultSequential to use the first merged sequential ramp.'
20525
+ });
20526
+ }
20527
+ for (const kind of ["sequential", "diverging"]) {
20528
+ const ramps = theme.colors[kind];
20529
+ if (ramps === void 0) continue;
20530
+ const kindPath = `${themePath}${jsonPointer19("colors", kind)}`;
20531
+ if (!isObject(ramps)) {
20532
+ errors.push({
20533
+ code: "INVALID_TYPE",
20534
+ path: kindPath,
20535
+ message: `theme.colors.${kind} must be an object mapping ramp names to arrays of stops.`,
20536
+ suggestion: 'Use { name: ["#fff", { light: "#eef", dark: "#113" }] }, or omit it.'
20537
+ });
20538
+ continue;
20539
+ }
20540
+ for (const [name, stops] of Object.entries(ramps)) {
20541
+ const rampPath = `${kindPath}${jsonPointer19(name)}`;
20542
+ if (!Array.isArray(stops)) {
20543
+ errors.push({
20544
+ code: "INVALID_TYPE",
20545
+ path: rampPath,
20546
+ message: `theme.colors.${kind}.${name} must be an array of stops.`,
20547
+ suggestion: "Use an array of color strings or { light, dark } pairs."
20548
+ });
20549
+ continue;
20550
+ }
20551
+ for (const [index, stop] of stops.entries()) {
20552
+ if (isStop(stop)) continue;
20553
+ errors.push({
20554
+ code: "INVALID_VALUE",
20555
+ path: `${rampPath}${jsonPointer19(index)}`,
20556
+ message: `theme.colors.${kind}.${name}[${index}] must be a color string or a { light, dark } pair of strings.`,
20557
+ suggestion: 'Use a color string such as "#336699" or { light: "#eef", dark: "#113" }.'
20558
+ });
20559
+ }
20560
+ }
20561
+ }
20562
+ }
20563
+
20564
+ // src/compiler/validation/theme-chrome.ts
20565
+ function isObject2(value) {
20566
+ return !!value && typeof value === "object" && !Array.isArray(value);
20567
+ }
20499
20568
  function validateThemeChrome(spec, errors) {
20500
20569
  function validate(current, prefix) {
20501
- if (isObject(current.chrome) && current.chrome.logo !== void 0 && typeof current.chrome.logo !== "boolean")
20570
+ if (isObject2(current.chrome) && current.chrome.logo !== void 0 && typeof current.chrome.logo !== "boolean")
20502
20571
  errors.push({
20503
20572
  code: "INVALID_VALUE",
20504
20573
  path: `${prefix}/chrome/logo`,
@@ -20506,15 +20575,16 @@ function validateThemeChrome(spec, errors) {
20506
20575
  suggestion: "Use true or false, or omit chrome.logo."
20507
20576
  });
20508
20577
  const theme = current.theme;
20509
- if (isObject(theme)) {
20510
- if (theme.logo !== void 0 && theme.logo !== null && !isObject(theme.logo))
20578
+ if (isObject2(theme)) {
20579
+ validateThemeRamps(theme, `${prefix}/theme`, errors);
20580
+ if (theme.logo !== void 0 && theme.logo !== null && !isObject2(theme.logo))
20511
20581
  errors.push({
20512
20582
  code: "INVALID_VALUE",
20513
20583
  path: `${prefix}/theme/logo`,
20514
20584
  message: "theme.logo must be an object or null.",
20515
20585
  suggestion: "Use a logo object, null, or omit theme.logo."
20516
20586
  });
20517
- if (isObject(theme.logo)) {
20587
+ if (isObject2(theme.logo)) {
20518
20588
  if (typeof theme.logo.src !== "string" || !isSafeLogoSource(theme.logo.src))
20519
20589
  errors.push({
20520
20590
  code: "INVALID_VALUE",
@@ -20554,39 +20624,39 @@ function validateThemeChrome(spec, errors) {
20554
20624
  suggestion: "Use a string for alt, or omit it."
20555
20625
  });
20556
20626
  }
20557
- if (isObject(theme.chrome))
20627
+ if (isObject2(theme.chrome))
20558
20628
  for (const [key, value] of Object.entries(theme.chrome)) {
20559
- if (!isObject(value)) continue;
20629
+ if (!isObject2(value)) continue;
20560
20630
  for (const field of ["prefix", "fontFamily"]) {
20561
20631
  if (value[field] !== void 0 && typeof value[field] !== "string")
20562
20632
  errors.push({
20563
20633
  code: "INVALID_VALUE",
20564
- path: `${prefix}${jsonPointer18("theme", "chrome", key, field)}`,
20634
+ path: `${prefix}${jsonPointer20("theme", "chrome", key, field)}`,
20565
20635
  message: `theme.chrome.${key}.${field} must be a string.`,
20566
20636
  suggestion: `Use a string for ${field}, or omit it.`
20567
20637
  });
20568
20638
  }
20569
- if (value.textAlign === void 0) continue;
20570
- if (value.textAlign === "left" || value.textAlign === "center" || value.textAlign === "right")
20639
+ if (value.align === void 0) continue;
20640
+ if (value.align === "left" || value.align === "center" || value.align === "right")
20571
20641
  continue;
20572
20642
  errors.push({
20573
20643
  code: "INVALID_VALUE",
20574
- path: `${prefix}${jsonPointer18("theme", "chrome", key, "textAlign")}`,
20575
- suggestion: "Use left, center or right, or omit textAlign.",
20576
- message: `theme.chrome.${key}.textAlign must be left, center or right.`
20644
+ path: `${prefix}${jsonPointer20("theme", "chrome", key, "align")}`,
20645
+ suggestion: "Use left, center or right, or omit align.",
20646
+ message: `theme.chrome.${key}.align must be left, center or right.`
20577
20647
  });
20578
20648
  }
20579
20649
  }
20580
20650
  if (Array.isArray(current.layer))
20581
20651
  for (const [index, child] of current.layer.entries()) {
20582
- if (isObject(child)) validate(child, `${prefix}${jsonPointer18("layer", index)}`);
20652
+ if (isObject2(child)) validate(child, `${prefix}${jsonPointer20("layer", index)}`);
20583
20653
  }
20584
20654
  }
20585
20655
  validate(spec, "");
20586
20656
  }
20587
20657
 
20588
20658
  // src/compiler/validation/tilemap.ts
20589
- import { jsonPointer as jsonPointer19 } from "@opendata-ai/openchart-core";
20659
+ import { jsonPointer as jsonPointer21 } from "@opendata-ai/openchart-core";
20590
20660
  function validateTileMapSpec(spec, errors) {
20591
20661
  validateTileMapTime(spec, errors);
20592
20662
  if (!spec.data || typeof spec.data !== "object") {
@@ -20645,7 +20715,7 @@ function validateTileMapSpec(spec, errors) {
20645
20715
  if (!ch || typeof ch !== "object") {
20646
20716
  errors.push({
20647
20717
  message: `Spec error: tilemap encoding requires "${channel}" channel`,
20648
- path: jsonPointer19("encoding", channel),
20718
+ path: jsonPointer21("encoding", channel),
20649
20719
  code: "MISSING_FIELD",
20650
20720
  suggestion: `Add encoding.${channel} with a field from your data (${availableColumns}). Example: ${channel}: { field: "${columnList[0] ?? "myField"}", type: "${channel === "value" ? "quantitative" : "nominal"}" }`
20651
20721
  });
@@ -20654,7 +20724,7 @@ function validateTileMapSpec(spec, errors) {
20654
20724
  if (!ch.field || typeof ch.field !== "string") {
20655
20725
  errors.push({
20656
20726
  message: `Spec error: encoding.${channel} must have a "field" string`,
20657
- path: jsonPointer19("encoding", channel, "field"),
20727
+ path: jsonPointer21("encoding", channel, "field"),
20658
20728
  code: "MISSING_FIELD",
20659
20729
  suggestion: `Add a field name from your data columns: ${availableColumns}`
20660
20730
  });
@@ -20663,7 +20733,7 @@ function validateTileMapSpec(spec, errors) {
20663
20733
  if (!dataColumns.has(ch.field)) {
20664
20734
  errors.push({
20665
20735
  message: `Spec error: encoding.${channel}.field "${ch.field}" does not exist in data. Available columns: ${availableColumns}`,
20666
- path: jsonPointer19("encoding", channel, "field"),
20736
+ path: jsonPointer21("encoding", channel, "field"),
20667
20737
  code: "DATA_FIELD_MISSING",
20668
20738
  suggestion: `Use one of the available data columns: ${availableColumns}.${didYouMean(ch.field, columnList)}`
20669
20739
  });
@@ -20700,7 +20770,7 @@ function validateAnnotationLayout(spec, errors, prefix = "") {
20700
20770
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0)
20701
20771
  errors.push({
20702
20772
  code: "INVALID_VALUE",
20703
- path: `${prefix}${jsonPointer20("annotations", index, field)}`,
20773
+ path: `${prefix}${jsonPointer22("annotations", index, field)}`,
20704
20774
  message: `${field} must be a positive finite number`,
20705
20775
  suggestion: field === "maxWidth" ? "Use null for unlimited width." : "Omit subtitleFontSize to use the default ratio."
20706
20776
  });
@@ -20708,7 +20778,7 @@ function validateAnnotationLayout(spec, errors, prefix = "") {
20708
20778
  if (annotation?.labelPlacement !== void 0 && !["auto", "start", "end", "outside"].includes(annotation.labelPlacement))
20709
20779
  errors.push({
20710
20780
  code: "INVALID_VALUE",
20711
- path: `${prefix}${jsonPointer20("annotations", index, "labelPlacement")}`,
20781
+ path: `${prefix}${jsonPointer22("annotations", index, "labelPlacement")}`,
20712
20782
  message: "Unknown reference label placement",
20713
20783
  suggestion: "Use auto, start, end or outside."
20714
20784
  });
@@ -20716,7 +20786,7 @@ function validateAnnotationLayout(spec, errors, prefix = "") {
20716
20786
  if (bend !== void 0 && (typeof bend !== "number" || !Number.isFinite(bend) || bend < -1 || bend > 1)) {
20717
20787
  errors.push({
20718
20788
  code: "INVALID_VALUE",
20719
- path: `${prefix}${jsonPointer20("annotations", index, "connector", "bend")}`,
20789
+ path: `${prefix}${jsonPointer22("annotations", index, "connector", "bend")}`,
20720
20790
  message: "Connector bend must be a finite number between -1 and 1",
20721
20791
  suggestion: "Omit bend for the automatic curve, or use a number in [-1, 1]."
20722
20792
  });
@@ -20767,7 +20837,7 @@ function validateCommonSpecFields(obj, errors) {
20767
20837
  if (value === void 0) continue;
20768
20838
  if (typeof value !== "string" && (!value || typeof value !== "object" || Array.isArray(value) || typeof value.text !== "string")) {
20769
20839
  errors.push({
20770
- path: jsonPointer20("chrome", key),
20840
+ path: jsonPointer22("chrome", key),
20771
20841
  code: "INVALID_TYPE",
20772
20842
  message: `${key} must be text or an object with a string text property.`,
20773
20843
  suggestion: "Preserve authored styling in the object and provide text as a string."
@@ -20810,7 +20880,7 @@ function validateSpecShape(spec) {
20810
20880
  errors: [
20811
20881
  {
20812
20882
  message: `Spec error: "${key}" composition is not supported`,
20813
- path: jsonPointer20(key),
20883
+ path: jsonPointer22(key),
20814
20884
  code: "INVALID_VALUE",
20815
20885
  suggestion: "Render each chart in its own container instead. For small multiples of the same chart, use the facet encoding channel: encoding.facet = { field, type }"
20816
20886
  }
@@ -25382,10 +25452,11 @@ function compileTileMapFrame(spec, options, scope) {
25382
25452
  isDarkMode,
25383
25453
  watermark,
25384
25454
  chromeLayout,
25455
+ (spec.palette === void 0 ? theme.colors.sequential[theme.colors.defaultSequential] : resolveThemeScheme(tilemapSpec.palette, theme)) ?? SEQUENTIAL_PALETTES3.blue,
25385
25456
  scope
25386
25457
  );
25387
25458
  }
25388
- function compileQuantitative(tilemapSpec, options, theme, chrome, fullArea, isDarkMode, watermark, chromeLayout, scope) {
25459
+ function compileQuantitative(tilemapSpec, options, theme, chrome, fullArea, isDarkMode, watermark, chromeLayout, paletteStops, scope) {
25389
25460
  const stateField = tilemapSpec.encoding.state.field;
25390
25461
  const valueField = tilemapSpec.encoding.value.field;
25391
25462
  const stateValueMap = /* @__PURE__ */ new Map();
@@ -25399,7 +25470,6 @@ function compileQuantitative(tilemapSpec, options, theme, chrome, fullArea, isDa
25399
25470
  const values = scope?.valueRows ? scope.valueRows.flatMap((row) => finiteNumber(row[valueField]) ?? []) : Array.from(stateValueMap.values());
25400
25471
  const min4 = values.length > 0 ? Math.min(...values) : 0;
25401
25472
  const max4 = values.length > 0 ? Math.max(...values) : 100;
25402
- const paletteStops = resolveThemeScheme(tilemapSpec.palette, theme) ?? SEQUENTIAL_PALETTES3.blue;
25403
25473
  const baseColor = isDarkMode ? paletteStops[0] : paletteStops[paletteStops.length - 1];
25404
25474
  const opacityRange = isDarkMode ? [0.3, 1] : [0.25, 1];
25405
25475
  const opacityScale = scaleLinear6().domain([min4, max4]).range(opacityRange).clamp(true);
@@ -30876,8 +30946,7 @@ function resolveNodeVisuals(nodes, encoding, edges, theme, nodeOverrides) {
30876
30946
  const values = nodes.map((n) => Number(n[field])).filter((v) => Number.isFinite(v));
30877
30947
  const colorMin = min3(values) ?? 0;
30878
30948
  const colorMax = max3(values) ?? 1;
30879
- const seqPalettes = Object.values(theme.colors.sequential);
30880
- const palette = seqPalettes.length > 0 ? seqPalettes[0] : ["#ccc", "#333"];
30949
+ const palette = theme.colors.sequential[theme.colors.defaultSequential] ?? ["#ccc", "#333"];
30881
30950
  const domain = scaleConfig?.domain && scaleConfig.domain.length === 2 ? scaleConfig.domain : [colorMin, colorMax];
30882
30951
  const range = scaleConfig?.range && scaleConfig.range.length >= 2 ? scaleConfig.range : [palette[0], palette[palette.length - 1]];
30883
30952
  const colorScale = scaleLinear7().domain(domain).range(range);
@@ -30992,8 +31061,7 @@ function resolveEdgeVisuals(edges, encoding, theme, nodeFills) {
30992
31061
  const values = edges.map((e) => Number(e[field])).filter((v) => Number.isFinite(v));
30993
31062
  const colorMin = min3(values) ?? 0;
30994
31063
  const colorMax = max3(values) ?? 1;
30995
- const seqPalettes = Object.values(theme.colors.sequential);
30996
- const palette = seqPalettes.length > 0 ? seqPalettes[0] : ["#ccc", "#333"];
31064
+ const palette = theme.colors.sequential[theme.colors.defaultSequential] ?? ["#ccc", "#333"];
30997
31065
  const domain = scaleConfig?.domain && scaleConfig.domain.length === 2 ? scaleConfig.domain : [colorMin, colorMax];
30998
31066
  const range = scaleConfig?.range && scaleConfig.range.length >= 2 ? scaleConfig.range : [palette[0], palette[palette.length - 1]];
30999
31067
  const colorScale = scaleLinear7().domain(domain).range(range);
@@ -32636,8 +32704,7 @@ function resolvePalette(palette, theme) {
32636
32704
  if (seqPalettes[palette]) return seqPalettes[palette];
32637
32705
  if (divPalettes[palette]) return divPalettes[palette];
32638
32706
  }
32639
- const firstSeqKey = Object.keys(seqPalettes)[0];
32640
- return firstSeqKey ? seqPalettes[firstSeqKey] : ["#deebf7", "#08519c"];
32707
+ return seqPalettes[theme.colors.defaultSequential] ?? ["#deebf7", "#08519c"];
32641
32708
  }
32642
32709
  function computeHeatmapColors(data, column, theme, darkMode) {
32643
32710
  const result = /* @__PURE__ */ new Map();
@@ -32779,7 +32846,7 @@ function sortData(data, sort) {
32779
32846
  }
32780
32847
 
32781
32848
  // src/tables/sparkline.ts
32782
- import { formatRawNumber as formatRawNumber20 } from "@opendata-ai/openchart-core";
32849
+ import { buildD3Formatter as buildD3Formatter6, formatRawNumber as formatRawNumber20 } from "@opendata-ai/openchart-core";
32783
32850
  function extractSparklineValues(row, columnKey, config) {
32784
32851
  const field = config.valuesField ?? columnKey;
32785
32852
  const raw = row[field];
@@ -32820,7 +32887,8 @@ function computeSparkline(values, config, theme, _darkMode, domain) {
32820
32887
  const normalize = (v) => range === 0 ? 0.5 : Math.max(0, Math.min(1, (v - min4) / range));
32821
32888
  const startValue = values[0];
32822
32889
  const endValue = values[values.length - 1];
32823
- const formatEndValue = (value) => Math.abs(value) >= 1e3 ? value.toLocaleString(theme.locale, { maximumFractionDigits: 0 }) : formatRawNumber20(value.toFixed(Math.abs(value) >= 100 ? 0 : 1), theme.locale);
32890
+ const formatThousands = buildD3Formatter6(",.0f", theme.locale) ?? String;
32891
+ const formatEndValue = (value) => Math.abs(value) >= 1e3 ? formatThousands(value) : formatRawNumber20(value.toFixed(Math.abs(value) >= 100 ? 0 : 1), theme.locale);
32824
32892
  const formattedStartValue = formatEndValue(startValue);
32825
32893
  const formattedEndValue = formatEndValue(endValue);
32826
32894
  if (type === "line") {
@@ -34195,7 +34263,7 @@ var lineGeometry = (model, layout, frame) => {
34195
34263
  };
34196
34264
 
34197
34265
  // src/race/layout-table.ts
34198
- import { buildD3Formatter as buildD3Formatter6 } from "@opendata-ai/openchart-core";
34266
+ import { buildD3Formatter as buildD3Formatter7 } from "@opendata-ai/openchart-core";
34199
34267
  var DEFAULT_COLUMNS2 = ["rank", "change", "name", "bar", "value", "share"];
34200
34268
  var LABELS = {
34201
34269
  rank: "Rank",
@@ -34209,7 +34277,7 @@ var COMPACT_WIDTH4 = 520;
34209
34277
  var COMPACT_CHANGE = "\u2195";
34210
34278
  var CHIP_WIDTH_AND_GAP = 14;
34211
34279
  var EMPTY = "\u2014";
34212
- var formatShare = (locale) => buildD3Formatter6(".1%", locale) ?? String;
34280
+ var formatShare = (locale) => buildD3Formatter7(".1%", locale) ?? String;
34213
34281
  var VALUE_WIDTH_SAMPLES = [0.25, 0.5, 0.75, Math.SQRT1_2];
34214
34282
  function frameShareBase(values, period, fraction) {
34215
34283
  let total = 0;
@@ -35814,7 +35882,7 @@ function recommendCompositions(data, question, roles) {
35814
35882
 
35815
35883
  // src/geo/reader-index.ts
35816
35884
  import {
35817
- buildD3Formatter as buildD3Formatter7,
35885
+ buildD3Formatter as buildD3Formatter8,
35818
35886
  computeFieldFormatContext as computeFieldFormatContext12,
35819
35887
  formatRawNumber as formatRawNumber21
35820
35888
  } from "@opendata-ai/openchart-core";
@@ -35932,7 +36000,7 @@ function buildGeoReaderIndex(spec, layout) {
35932
36000
  (field) => {
35933
36001
  const raw = datum?.[field.field];
35934
36002
  const numeric = finiteNumber(raw);
35935
- const format = field.format ? buildD3Formatter7(field.format, layout.theme.locale) : void 0;
36003
+ const format = field.format ? buildD3Formatter8(field.format, layout.theme.locale) : void 0;
35936
36004
  return {
35937
36005
  label: field.title ?? spec.fields?.[field.field]?.label ?? field.field,
35938
36006
  value: raw == null ? "No data" : field.type === "quantitative" ? numeric === void 0 ? "No data" : format ? format(numeric) : formatRawNumber21(numeric, layout.theme.locale) : String(raw)