@pixerate/editor 0.256.0 → 0.258.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 (124) hide show
  1. package/dist/agent/index.cjs +40 -38
  2. package/dist/agent/index.js +9 -7
  3. package/dist/animation/index.cjs +4 -2
  4. package/dist/animation/index.js +4 -2
  5. package/dist/animation-editor/index.cjs +63 -61
  6. package/dist/animation-editor/index.js +7 -5
  7. package/dist/brushes/colour.d.cts +11 -0
  8. package/dist/brushes/colour.d.ts +11 -0
  9. package/dist/brushes/index.cjs +51 -30
  10. package/dist/brushes/index.d.cts +1 -0
  11. package/dist/brushes/index.d.ts +1 -0
  12. package/dist/brushes/index.js +25 -4
  13. package/dist/brushes/resolve.d.cts +2 -0
  14. package/dist/brushes/resolve.d.ts +2 -0
  15. package/dist/brushes/schema.d.cts +1 -0
  16. package/dist/brushes/schema.d.ts +1 -0
  17. package/dist/brushes/tools.d.cts +7 -0
  18. package/dist/brushes/tools.d.ts +7 -0
  19. package/dist/brushes/types.d.cts +10 -2
  20. package/dist/brushes/types.d.ts +10 -2
  21. package/dist/brushes/ui.d.cts +14 -3
  22. package/dist/brushes/ui.d.ts +14 -3
  23. package/dist/{brushstrokeRender-HCOQUSWW.js → brushstrokeRender-JI4W6F2G.js} +2 -2
  24. package/dist/{brushstrokeRender-ZZOXI5O5.cjs → brushstrokeRender-MQ6PSDM5.cjs} +11 -11
  25. package/dist/canvas/index.cjs +20 -18
  26. package/dist/canvas/index.js +7 -5
  27. package/dist/chart/index.cjs +159 -157
  28. package/dist/chart/index.js +9 -7
  29. package/dist/{chunk-7272D3K2.js → chunk-2EUW2XZX.js} +27 -276
  30. package/dist/{chunk-L6Y7TSQ4.js → chunk-2VJ6OVJV.js} +1 -1
  31. package/dist/{chunk-6ZZKRH7R.js → chunk-47V3WXDG.js} +2 -2
  32. package/dist/{chunk-H7ET2ISK.cjs → chunk-4IMD2TLY.cjs} +52 -52
  33. package/dist/{chunk-VUKUTT2W.js → chunk-4M4E3N6X.js} +1 -1
  34. package/dist/{chunk-TBAVCLEQ.cjs → chunk-5Q5MLXAD.cjs} +23 -23
  35. package/dist/{chunk-MONXNVZK.js → chunk-6I23ZCGK.js} +5 -3
  36. package/dist/{chunk-GOBOCZZI.js → chunk-6NQPKNUZ.js} +1 -1
  37. package/dist/{chunk-WYGSR3IJ.js → chunk-AORZ5M5C.js} +1 -1
  38. package/dist/chunk-AVTPZO4Z.cjs +142 -0
  39. package/dist/{chunk-WKMUBATU.js → chunk-C2WEIEUB.js} +1 -1
  40. package/dist/{chunk-P3K2JCJA.js → chunk-D5BXSOSU.js} +3 -3
  41. package/dist/chunk-E2V5DA3W.js +36 -0
  42. package/dist/{chunk-WZOGDKCQ.js → chunk-F7CPSRLN.js} +0 -133
  43. package/dist/chunk-FJBQTZS4.js +17 -0
  44. package/dist/{chunk-SOSBOS5T.cjs → chunk-G23BTQA5.cjs} +22 -22
  45. package/dist/{chunk-EUIDTZNQ.cjs → chunk-I3Y2Q3PM.cjs} +59 -308
  46. package/dist/{chunk-YHUMGBZD.js → chunk-ICTPLVSR.js} +22 -4
  47. package/dist/{chunk-LRNUZKWV.cjs → chunk-IPUTIUGQ.cjs} +1 -1
  48. package/dist/{chunk-6GRUVGKU.js → chunk-ITURMC2M.js} +3 -3
  49. package/dist/{chunk-HYWRU5VX.js → chunk-IXQZHCOF.js} +1 -1
  50. package/dist/chunk-J5UQHWVL.js +142 -0
  51. package/dist/{chunk-YBAPT7NL.js → chunk-JC2SHA4A.js} +1 -23
  52. package/dist/chunk-LRTR4ASZ.cjs +17 -0
  53. package/dist/{chunk-HUAISCUX.cjs → chunk-M2HG5DJ2.cjs} +18 -18
  54. package/dist/{chunk-N76AMOKE.cjs → chunk-MDLEGVEN.cjs} +42 -42
  55. package/dist/chunk-MEGSQUQO.cjs +36 -0
  56. package/dist/chunk-MLLTWAXH.cjs +276 -0
  57. package/dist/{chunk-RHPSE2YR.js → chunk-MQ6MGIQM.js} +2 -2
  58. package/dist/{chunk-PGPFWC35.cjs → chunk-MQGQTKVW.cjs} +51 -33
  59. package/dist/{chunk-5YWWQ36H.cjs → chunk-O3ZVZSNJ.cjs} +9 -9
  60. package/dist/{chunk-GCTUOTCW.cjs → chunk-P3PZ63M3.cjs} +35 -35
  61. package/dist/{chunk-WRZ6C4TU.cjs → chunk-P6WYDBTH.cjs} +4 -4
  62. package/dist/{chunk-CJ6TBL2N.cjs → chunk-RHEMMGCN.cjs} +16 -16
  63. package/dist/{chunk-HIMGBZAM.cjs → chunk-RSIKDWOP.cjs} +201 -38
  64. package/dist/{chunk-SABJMH6M.cjs → chunk-RVGP2XLF.cjs} +2 -135
  65. package/dist/{chunk-JVRLGV3C.js → chunk-SMTUQWGY.js} +184 -21
  66. package/dist/{chunk-DMTEQ6SH.js → chunk-SSFMWJDK.js} +4 -4
  67. package/dist/{chunk-TFF2GTGN.cjs → chunk-SXQHWXEL.cjs} +2 -24
  68. package/dist/{chunk-IWEVV63O.cjs → chunk-UEYLANO3.cjs} +18 -16
  69. package/dist/chunk-VR6OGHU5.js +276 -0
  70. package/dist/{chunk-AF23QK5F.js → chunk-YQ4PQTBB.js} +1 -1
  71. package/dist/{chunk-B7V34GIH.cjs → chunk-YSGW7VV4.cjs} +88 -88
  72. package/dist/{chunk-3NS5C7FB.cjs → chunk-YYBW6DF2.cjs} +76 -76
  73. package/dist/{chunk-UFEDHACQ.js → chunk-Z7BX4TWO.js} +2 -2
  74. package/dist/{chunk-RUONPPMC.cjs → chunk-ZSE25IZA.cjs} +8 -8
  75. package/dist/color/index.cjs +7 -3
  76. package/dist/color/index.js +18 -14
  77. package/dist/export/index.cjs +8 -6
  78. package/dist/export/index.js +7 -5
  79. package/dist/extensions/index.cjs +11 -9
  80. package/dist/extensions/index.js +10 -8
  81. package/dist/gradient/index.cjs +33 -31
  82. package/dist/gradient/index.js +5 -3
  83. package/dist/image-editor/brush-presets.d.cts +4 -1
  84. package/dist/image-editor/brush-presets.d.ts +4 -1
  85. package/dist/image-editor/controller.d.cts +10 -5
  86. package/dist/image-editor/controller.d.ts +10 -5
  87. package/dist/image-editor/index.cjs +1090 -1073
  88. package/dist/image-editor/index.js +37 -20
  89. package/dist/index.cjs +17 -15
  90. package/dist/index.js +11 -9
  91. package/dist/paint-editor/brushes.d.cts +18 -1
  92. package/dist/paint-editor/brushes.d.ts +18 -1
  93. package/dist/paint-editor/collaboration.d.cts +38 -0
  94. package/dist/paint-editor/collaboration.d.ts +38 -0
  95. package/dist/paint-editor/controller.d.cts +60 -0
  96. package/dist/paint-editor/controller.d.ts +60 -0
  97. package/dist/paint-editor/engine.d.cts +7 -0
  98. package/dist/paint-editor/engine.d.ts +7 -0
  99. package/dist/paint-editor/index.cjs +1564 -1324
  100. package/dist/paint-editor/index.js +1198 -958
  101. package/dist/paint-editor/mark-settings.d.cts +1 -1
  102. package/dist/paint-editor/mark-settings.d.ts +1 -1
  103. package/dist/paint-editor/procedural.d.cts +4 -2
  104. package/dist/paint-editor/procedural.d.ts +4 -2
  105. package/dist/paint-editor/stamp-tip.d.cts +45 -0
  106. package/dist/paint-editor/stamp-tip.d.ts +45 -0
  107. package/dist/paint-editor/stroke.d.cts +4 -0
  108. package/dist/paint-editor/stroke.d.ts +4 -0
  109. package/dist/stickers/index.cjs +4 -2
  110. package/dist/stickers/index.js +6 -4
  111. package/dist/typography/index.cjs +3 -2
  112. package/dist/typography/index.js +2 -1
  113. package/dist/vector/index.cjs +971 -969
  114. package/dist/vector/index.js +8 -6
  115. package/dist/video-editor/index.cjs +4 -2
  116. package/dist/video-editor/index.js +4 -2
  117. package/package.json +1 -1
  118. package/skills/pixerate-brushes/SKILL.md +21 -11
  119. package/skills/pixerate-brushes-design/SKILL.md +6 -2
  120. package/skills/pixerate-brushes-design/evals/canvas-chalk.json +8 -8
  121. package/skills/pixerate-canvas/SKILL.md +3 -2
  122. package/skills/pixerate-image-editor/SKILL.md +1 -1
  123. package/skills/pixerate-paint-editor/SKILL.md +5 -1
  124. package/skills/pixerate-vector/SKILL.md +1 -1
@@ -12,7 +12,7 @@
12
12
 
13
13
 
14
14
 
15
- var _chunkWRZ6C4TUcjs = require('./chunk-WRZ6C4TU.cjs');
15
+ var _chunkP6WYDBTHcjs = require('./chunk-P6WYDBTH.cjs');
16
16
 
17
17
 
18
18
  var _chunk55AKPTLMcjs = require('./chunk-55AKPTLM.cjs');
@@ -1239,7 +1239,7 @@ function layoutCartesian(ctx, area, visible) {
1239
1239
  const { spec, theme, marks, measure, fs } = ctx;
1240
1240
  const horizontal = spec.orientation === "horizontal";
1241
1241
  const n = spec.categories.length;
1242
- const types = new Map(visible.map((s) => [s.id, _chunkWRZ6C4TUcjs.chartSeriesType.call(void 0, spec, s)]));
1242
+ const types = new Map(visible.map((s) => [s.id, _chunkP6WYDBTHcjs.chartSeriesType.call(void 0, spec, s)]));
1243
1243
  const stacked = spec.stacking !== "none";
1244
1244
  const percent = spec.stacking === "percent";
1245
1245
  const onSecondary = (s) => s.axis === "secondary";
@@ -1276,7 +1276,7 @@ function layoutCartesian(ctx, area, visible) {
1276
1276
  const stack = stacks.get(s.id);
1277
1277
  errors.set(
1278
1278
  s.id,
1279
- _chunkWRZ6C4TUcjs.chartErrorAmounts.call(void 0, s.errorBars, s.values).map((e, i) => {
1279
+ _chunkP6WYDBTHcjs.chartErrorAmounts.call(void 0, s.errorBars, s.values).map((e, i) => {
1280
1280
  const raw = s.values[i];
1281
1281
  const seg = _optionalChain([stack, 'optionalAccess', _11 => _11.segments, 'access', _12 => _12[i]]);
1282
1282
  if (!e || raw === null || stack && !seg) return null;
@@ -1346,7 +1346,7 @@ function layoutCartesian(ctx, area, visible) {
1346
1346
  const drawOrder = [...visible].sort((a, b) => order(types.get(a.id)) - order(types.get(b.id)));
1347
1347
  for (const s of drawOrder) {
1348
1348
  const si = spec.series.indexOf(s);
1349
- const color = _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, si);
1349
+ const color = _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, si);
1350
1350
  const type = types.get(s.id);
1351
1351
  const stack = stacks.get(s.id);
1352
1352
  const selSeries = ctx.seriesSelected(s.id);
@@ -1372,7 +1372,7 @@ function layoutCartesian(ctx, area, visible) {
1372
1372
  const selected = ctx.isSelected(target);
1373
1373
  const [x, y] = map({ c: c0, v: Math.min(a, b) });
1374
1374
  const rect = horizontal ? { x: Math.min(a, b), y: c0, width: Math.abs(b - a), height: cw } : { x, y, width: cw, height: Math.abs(b - a) };
1375
- const fill = _chunkWRZ6C4TUcjs.chartPointColor.call(void 0, spec, si, i);
1375
+ const fill = _chunkP6WYDBTHcjs.chartPointColor.call(void 0, spec, si, i);
1376
1376
  marks.push({
1377
1377
  kind: "rect",
1378
1378
  key: `bar-${s.id}-${i}`,
@@ -1451,7 +1451,7 @@ function layoutCartesian(ctx, area, visible) {
1451
1451
  const target = { kind: "point", seriesId: s.id, index: i };
1452
1452
  const selected = ctx.isSelected(target);
1453
1453
  const r = type === "scatter" ? 4.5 : 3.5;
1454
- const pointColor = _chunkWRZ6C4TUcjs.chartPointColor.call(void 0, spec, si, i);
1454
+ const pointColor = _chunkP6WYDBTHcjs.chartPointColor.call(void 0, spec, si, i);
1455
1455
  const fill = showDots ? type === "scatter" ? pointColor : theme.surface : "transparent";
1456
1456
  marks.push(
1457
1457
  pointMark({ key: `point-${s.id}-${i}`, target, selected: selected || selSeries, opacity: type === "scatter" ? 0.85 : void 0 }, showDots ? marker : "hit", cx, cy, showDots ? r : 6, fill, showDots ? pointColor : void 0, 2)
@@ -1525,8 +1525,8 @@ function layoutXy(ctx, area, visible) {
1525
1525
  const yErrors = /* @__PURE__ */ new Map();
1526
1526
  const xErrors = /* @__PURE__ */ new Map();
1527
1527
  for (const { s } of all) {
1528
- if (s.errorBars) yErrors.set(s.id, _chunkWRZ6C4TUcjs.chartErrorAmounts.call(void 0, s.errorBars, s.values));
1529
- if (s.xErrorBars) xErrors.set(s.id, _chunkWRZ6C4TUcjs.chartErrorAmounts.call(void 0, s.xErrorBars, s.values.map((_, i) => _nullishCoalesce(_optionalChain([s, 'access', _29 => _29.x, 'optionalAccess', _30 => _30[i]]), () => ( (bubble || !s.x ? i + 1 : null))))));
1528
+ if (s.errorBars) yErrors.set(s.id, _chunkP6WYDBTHcjs.chartErrorAmounts.call(void 0, s.errorBars, s.values));
1529
+ if (s.xErrorBars) xErrors.set(s.id, _chunkP6WYDBTHcjs.chartErrorAmounts.call(void 0, s.xErrorBars, s.values.map((_, i) => _nullishCoalesce(_optionalChain([s, 'access', _29 => _29.x, 'optionalAccess', _30 => _30[i]]), () => ( (bubble || !s.x ? i + 1 : null))))));
1530
1530
  }
1531
1531
  let xlo = Infinity;
1532
1532
  let xhi = -Infinity;
@@ -1609,8 +1609,8 @@ function layoutXy(ctx, area, visible) {
1609
1609
  const trendLabels = [];
1610
1610
  for (const { s, pts } of all) {
1611
1611
  const si = spec.series.indexOf(s);
1612
- const color = _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, si);
1613
- const type = _chunkWRZ6C4TUcjs.chartSeriesType.call(void 0, spec, s);
1612
+ const color = _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, si);
1613
+ const type = _chunkP6WYDBTHcjs.chartSeriesType.call(void 0, spec, s);
1614
1614
  const selSeries = ctx.seriesSelected(s.id);
1615
1615
  const seriesTarget = { kind: "series", seriesId: s.id };
1616
1616
  if (type === "line" || type === "area") {
@@ -1635,7 +1635,7 @@ function layoutXy(ctx, area, visible) {
1635
1635
  }
1636
1636
  const target = { kind: "point", seriesId: s.id, index: p.i };
1637
1637
  const selected = ctx.isSelected(target);
1638
- const pointColor = _chunkWRZ6C4TUcjs.chartPointColor.call(void 0, spec, si, p.i);
1638
+ const pointColor = _chunkP6WYDBTHcjs.chartPointColor.call(void 0, spec, si, p.i);
1639
1639
  const r = bubble ? maxSize > 0 && p.size !== null && p.size > 0 ? Math.max(2, Math.sqrt(p.size / maxSize) * maxR) : 2 : 4.5;
1640
1640
  if (bubble) marks.push({ kind: "circle", key: `point-${s.id}-${p.i}`, role: "point", cx, cy, r, fill: pointColor, stroke: pointColor, strokeWidth: 1, opacity: 0.6, target, selected: selected || selSeries });
1641
1641
  else marks.push(pointMark({ key: `point-${s.id}-${p.i}`, target, selected: selected || selSeries, opacity: 0.85 }, marker === "none" ? "hit" : marker, cx, cy, marker === "none" ? 6 : r, marker === "none" ? "transparent" : pointColor, marker === "none" ? void 0 : pointColor, 2));
@@ -1749,7 +1749,7 @@ function layoutStreamgraph(ctx, area, visible) {
1749
1749
  const layers = [];
1750
1750
  for (let sIdx = 0; sIdx < visible.length; sIdx++) {
1751
1751
  const s = visible[sIdx];
1752
- const color = _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
1752
+ const color = _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
1753
1753
  const selSeries = ctx.seriesSelected(s.id);
1754
1754
  const bottomPts = [];
1755
1755
  const topPts = [];
@@ -1899,7 +1899,7 @@ function chartMapBreaks(values, steps, thresholds) {
1899
1899
  var chartMapClass = (value, breaks) => breaks.filter((b) => value >= b).length;
1900
1900
  function chartMapRamp(base, count) {
1901
1901
  if (count <= 1) return [base];
1902
- return Array.from({ length: count }, (_, k) => _chunkWRZ6C4TUcjs.shadeChartColor.call(void 0, base, 0.82 - 1.17 * k / (count - 1)));
1902
+ return Array.from({ length: count }, (_, k) => _chunkP6WYDBTHcjs.shadeChartColor.call(void 0, base, 0.82 - 1.17 * k / (count - 1)));
1903
1903
  }
1904
1904
 
1905
1905
  // src/chart/race.ts
@@ -1935,7 +1935,7 @@ function chartRaceRanking(spec, frame) {
1935
1935
  }
1936
1936
 
1937
1937
  // src/chart/layout-families.ts
1938
- var sliceColor = (ctx, series, i) => _optionalChain([series, 'access', _45 => _45.pointColors, 'optionalAccess', _46 => _46[i]]) || _chunkWRZ6C4TUcjs.chartSliceColor.call(void 0, ctx.spec, i);
1938
+ var sliceColor = (ctx, series, i) => _optionalChain([series, 'access', _45 => _45.pointColors, 'optionalAccess', _46 => _46[i]]) || _chunkP6WYDBTHcjs.chartSliceColor.call(void 0, ctx.spec, i);
1939
1939
  function layoutPie(ctx, area, series) {
1940
1940
  const { spec, theme, marks, fs, selection } = ctx;
1941
1941
  const values = spec.categories.map((_, i) => {
@@ -2051,7 +2051,7 @@ function layoutRadar(ctx, area, visible) {
2051
2051
  });
2052
2052
  for (const s of visible) {
2053
2053
  const si = spec.series.indexOf(s);
2054
- const color = _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, si);
2054
+ const color = _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, si);
2055
2055
  const selSeries = ctx.seriesSelected(s.id);
2056
2056
  const pts = s.values.map((v, i) => v !== null && Number.isFinite(v) ? at(i, rOf(v)) : null);
2057
2057
  const present = pts.filter((p) => p !== null);
@@ -2101,7 +2101,7 @@ function layoutWaterfall(ctx, area, series) {
2101
2101
  });
2102
2102
  const { band, catCenter, map, value } = frame;
2103
2103
  const w = band * (1 - spec.gapWidth);
2104
- const color = _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(series));
2104
+ const color = _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(series));
2105
2105
  const format = _nullishCoalesce(series.format, () => ( spec.yAxis.format));
2106
2106
  const labelsOn = _nullishCoalesce(series.dataLabels, () => ( spec.dataLabels));
2107
2107
  let prevEnd = null;
@@ -2160,7 +2160,7 @@ function layoutHistogram(ctx, area, visible) {
2160
2160
  const gap = k > 1 ? band * spec.gapWidth * 0.5 : 0;
2161
2161
  const w = (band - gap) / k;
2162
2162
  visible.forEach((s, si) => {
2163
- const color = _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
2163
+ const color = _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
2164
2164
  const target = { kind: "series", seriesId: s.id };
2165
2165
  const selected = ctx.seriesSelected(s.id);
2166
2166
  counts[si].forEach((c, b) => {
@@ -2191,7 +2191,7 @@ function layoutBox(ctx, area, visible) {
2191
2191
  visible.forEach((s, i) => {
2192
2192
  const st = stats[i];
2193
2193
  if (!st) return;
2194
- const color = _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
2194
+ const color = _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
2195
2195
  const target = { kind: "series", seriesId: s.id };
2196
2196
  const selected = ctx.seriesSelected(s.id);
2197
2197
  const c = catCenter(i);
@@ -2410,7 +2410,7 @@ function layoutLikert(ctx, area, visible) {
2410
2410
  if (x1 - x0 <= 0) return;
2411
2411
  const target = { kind: "point", seriesId: s.id, index: i };
2412
2412
  const selected = ctx.isSelected(target);
2413
- const fill = _optionalChain([s, 'access', _48 => _48.pointColors, 'optionalAccess', _49 => _49[i]]) || _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
2413
+ const fill = _optionalChain([s, 'access', _48 => _48.pointColors, 'optionalAccess', _49 => _49[i]]) || _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
2414
2414
  const rect = { x: x0, y, width: x1 - x0, height: barH };
2415
2415
  marks.push({ kind: "rect", key, role: "bar", ...rect, fill, target, selected: selected || ctx.seriesSelected(s.id) || catSelected });
2416
2416
  if (selected) ctx.outline(`${key}-selection`, { x: rect.x - 2, y: rect.y - 2, width: rect.width + 4, height: rect.height + 4 });
@@ -2509,8 +2509,8 @@ function layoutParliament(ctx, area, series) {
2509
2509
  }
2510
2510
  function treeColor(ctx, series, node, group, base, shade) {
2511
2511
  if (node.color) return node.color;
2512
- if (base === null) return _optionalChain([series, 'optionalAccess', _50 => _50.pointColors, 'optionalAccess', _51 => _51[group]]) || _chunkWRZ6C4TUcjs.chartSliceColor.call(void 0, ctx.spec, group);
2513
- return _chunkWRZ6C4TUcjs.shadeChartColor.call(void 0, base, shade);
2512
+ if (base === null) return _optionalChain([series, 'optionalAccess', _50 => _50.pointColors, 'optionalAccess', _51 => _51[group]]) || _chunkP6WYDBTHcjs.chartSliceColor.call(void 0, ctx.spec, group);
2513
+ return _chunkP6WYDBTHcjs.shadeChartColor.call(void 0, base, shade);
2514
2514
  }
2515
2515
  function layoutTreemapTree(ctx, area, series) {
2516
2516
  const { spec, marks, theme, fs, measure } = ctx;
@@ -2518,7 +2518,7 @@ function layoutTreemapTree(ctx, area, series) {
2518
2518
  const labelsOn = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _53 => _53.dataLabels]), () => ( true));
2519
2519
  let unlabelled = 0;
2520
2520
  const draw = (nodes, rect, key, group, base) => {
2521
- const rects = chartSquarify(nodes.map(_chunkWRZ6C4TUcjs.chartTreeTotal), rect);
2521
+ const rects = chartSquarify(nodes.map(_chunkP6WYDBTHcjs.chartTreeTotal), rect);
2522
2522
  nodes.forEach((node, k) => {
2523
2523
  const r = rects[k];
2524
2524
  if (r.width <= 0.5 || r.height <= 0.5) return;
@@ -2553,10 +2553,10 @@ function layoutTreemapTree(ctx, area, series) {
2553
2553
  }
2554
2554
  function layoutSunburst(ctx, area, series) {
2555
2555
  const { spec, marks, theme, fs, measure } = ctx;
2556
- const tree = spec.tree.length ? spec.tree : _chunkWRZ6C4TUcjs.chartTreeFromSeries.call(void 0, spec.categories, _nullishCoalesce(_optionalChain([series, 'optionalAccess', _55 => _55.values]), () => ( [])));
2556
+ const tree = spec.tree.length ? spec.tree : _chunkP6WYDBTHcjs.chartTreeFromSeries.call(void 0, spec.categories, _nullishCoalesce(_optionalChain([series, 'optionalAccess', _55 => _55.values]), () => ( [])));
2557
2557
  const indexOf = new Map(spec.categories.map((c, i) => [c.trim() || `${i + 1}`, i]));
2558
- const depth = _chunkWRZ6C4TUcjs.chartTreeDepth.call(void 0, tree);
2559
- const total = tree.reduce((t, n) => t + _chunkWRZ6C4TUcjs.chartTreeTotal.call(void 0, n), 0);
2558
+ const depth = _chunkP6WYDBTHcjs.chartTreeDepth.call(void 0, tree);
2559
+ const total = tree.reduce((t, n) => t + _chunkP6WYDBTHcjs.chartTreeTotal.call(void 0, n), 0);
2560
2560
  const cx = area.x + area.width / 2;
2561
2561
  const cy = area.y + area.height / 2;
2562
2562
  const outer = Math.max(8, Math.min(area.width, area.height) / 2 - 4);
@@ -2570,10 +2570,10 @@ function layoutSunburst(ctx, area, series) {
2570
2570
  const format = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _56 => _56.format]), () => ( spec.yAxis.format));
2571
2571
  let unlabelled = 0;
2572
2572
  const walk = (nodes, start, sweep, level, key, group, base) => {
2573
- const sum = nodes.reduce((t, n) => t + _chunkWRZ6C4TUcjs.chartTreeTotal.call(void 0, n), 0);
2573
+ const sum = nodes.reduce((t, n) => t + _chunkP6WYDBTHcjs.chartTreeTotal.call(void 0, n), 0);
2574
2574
  let at = start;
2575
2575
  nodes.forEach((node, k) => {
2576
- const value = _chunkWRZ6C4TUcjs.chartTreeTotal.call(void 0, node);
2576
+ const value = _chunkP6WYDBTHcjs.chartTreeTotal.call(void 0, node);
2577
2577
  if (!(value > 0) || !sum) return;
2578
2578
  const a0 = at;
2579
2579
  const a1 = at + sweep * value / sum;
@@ -2645,7 +2645,7 @@ function layoutSankey(ctx, area, series) {
2645
2645
  y += value[i] * ky + pad;
2646
2646
  }
2647
2647
  }
2648
- const color = (i) => _optionalChain([series, 'optionalAccess', _61 => _61.pointColors, 'optionalAccess', _62 => _62[i]]) || _chunkWRZ6C4TUcjs.chartSliceColor.call(void 0, spec, i);
2648
+ const color = (i) => _optionalChain([series, 'optionalAccess', _61 => _61.pointColors, 'optionalAccess', _62 => _62[i]]) || _chunkP6WYDBTHcjs.chartSliceColor.call(void 0, spec, i);
2649
2649
  const named = new Set(spec.highlight);
2650
2650
  const lit = nodes.map((n) => named.has(n));
2651
2651
  const dimLinks = lit.some(Boolean);
@@ -2730,7 +2730,7 @@ function layoutBarRace(ctx, area, frame) {
2730
2730
  const target = { kind: "point", seriesId: e.seriesId, index };
2731
2731
  const selected = ctx.isSelected(target) || ctx.seriesSelected(e.seriesId);
2732
2732
  const width = Math.max(0, xOf(e.value) - plot.x);
2733
- marks.push({ kind: "rect", key: `bar-${e.seriesId}`, role: "bar", x: plot.x, y, width, height: barH, fill: _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, si), radius: Math.min(3, barH / 4), target, selected, ...selected ? { stroke: theme.selection, strokeWidth: 1.5 } : {} });
2733
+ marks.push({ kind: "rect", key: `bar-${e.seriesId}`, role: "bar", x: plot.x, y, width, height: barH, fill: _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, si), radius: Math.min(3, barH / 4), target, selected, ...selected ? { stroke: theme.selection, strokeWidth: 1.5 } : {} });
2734
2734
  marks.push({ kind: "text", key: `label-name-${e.seriesId}`, role: "tick-label", x: plot.x - 6, y: y + barH / 2, text: truncate(e.name, labelW - 8, fs, measure), anchor: "end", baseline: "middle", size: fs, fill: selected ? theme.selection : theme.text, target: { kind: "series", seriesId: e.seriesId } });
2735
2735
  if (_nullishCoalesce(s.dataLabels, () => ( true))) marks.push({ kind: "text", key: `label-${e.seriesId}`, role: "data-label", x: plot.x + width + 5, y: y + barH / 2, text: formatChartNumber(e.value, _nullishCoalesce(s.format, () => ( format)), _nullishCoalesce((_nullishCoalesce(s.format, () => ( format))).decimals, () => ( (Math.abs(e.value) >= 100 ? 0 : void 0)))), anchor: "start", baseline: "middle", size: fs - 1, fill: theme.text, target });
2736
2736
  }
@@ -2755,7 +2755,7 @@ function layoutChoropleth(ctx, area, series) {
2755
2755
  };
2756
2756
  const present = [...indexOf.values()].map(valueAt).filter((v) => v !== null);
2757
2757
  const breaks = chartMapBreaks(present, spec.mapSteps, spec.mapThresholds);
2758
- const ramp = chartMapRamp(_nullishCoalesce(series.color, () => ( _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(series)))), breaks.length + 1);
2758
+ const ramp = chartMapRamp(_nullishCoalesce(series.color, () => ( _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(series)))), breaks.length + 1);
2759
2759
  const format = _nullishCoalesce(series.format, () => ( spec.yAxis.format));
2760
2760
  const legendH = fs * 2.2;
2761
2761
  const s = Math.max(1e-6, Math.min(area.width / map.width, (area.height - legendH) / map.height));
@@ -2800,14 +2800,14 @@ function layoutChoropleth(ctx, area, series) {
2800
2800
 
2801
2801
  // src/chart/layout.ts
2802
2802
  function legendItems(spec, ctx) {
2803
- const family = _chunkWRZ6C4TUcjs.chartFamily.call(void 0, spec);
2803
+ const family = _chunkP6WYDBTHcjs.chartFamily.call(void 0, spec);
2804
2804
  if (spec.type === "funnel" || spec.type === "slope" || spec.type === "sankey" || spec.type === "barrace" || spec.type === "choropleth") return [];
2805
- if (_chunkWRZ6C4TUcjs.chartSpecColorsByCategory.call(void 0, spec)) {
2805
+ if (_chunkP6WYDBTHcjs.chartSpecColorsByCategory.call(void 0, spec)) {
2806
2806
  const first = spec.series.find((s) => !s.hidden);
2807
2807
  const seats = (i) => Math.max(0, Math.round(_nullishCoalesce(_optionalChain([first, 'optionalAccess', _68 => _68.values, 'access', _69 => _69[i]]), () => ( 0))));
2808
2808
  return spec.categories.map((c, i) => ({
2809
2809
  label: spec.type === "parliament" ? `${c} ${seats(i)}` : c,
2810
- color: _optionalChain([first, 'optionalAccess', _70 => _70.pointColors, 'optionalAccess', _71 => _71[i]]) || _chunkWRZ6C4TUcjs.chartSliceColor.call(void 0, spec, i),
2810
+ color: _optionalChain([first, 'optionalAccess', _70 => _70.pointColors, 'optionalAccess', _71 => _71[i]]) || _chunkP6WYDBTHcjs.chartSliceColor.call(void 0, spec, i),
2811
2811
  target: { kind: "category", index: i },
2812
2812
  faded: false,
2813
2813
  selected: ctx.isSelected({ kind: "category", index: i }),
@@ -2821,17 +2821,17 @@ function legendItems(spec, ctx) {
2821
2821
  return [
2822
2822
  { label: "Increase", color: ctx.theme.positive, target, faded: false, selected: false, shape: "square" },
2823
2823
  { label: "Decrease", color: ctx.theme.negative, target, faded: false, selected: false, shape: "square" },
2824
- { label: "Total", color: _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(first)), target, faded: false, selected: false, shape: "square" }
2824
+ { label: "Total", color: _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(first)), target, faded: false, selected: false, shape: "square" }
2825
2825
  ];
2826
2826
  }
2827
2827
  if (family === "box") return [];
2828
- const trends = trendlineLegendItems(spec, (i) => _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, i));
2828
+ const trends = trendlineLegendItems(spec, (i) => _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, i));
2829
2829
  const items = [];
2830
2830
  spec.series.forEach((s, i) => {
2831
- const type = _chunkWRZ6C4TUcjs.chartSeriesType.call(void 0, spec, s);
2831
+ const type = _chunkP6WYDBTHcjs.chartSeriesType.call(void 0, spec, s);
2832
2832
  items.push({
2833
2833
  label: s.name,
2834
- color: _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, i),
2834
+ color: _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, i),
2835
2835
  target: { kind: "series", seriesId: s.id },
2836
2836
  faded: !!s.hidden,
2837
2837
  selected: ctx.seriesSelected(s.id),
@@ -2844,7 +2844,7 @@ function legendItems(spec, ctx) {
2844
2844
  function layoutChart(spec, options) {
2845
2845
  const width = Math.max(1, Number.isFinite(options.width) ? options.width : 1);
2846
2846
  const height = Math.max(1, Number.isFinite(options.height) ? options.height : 1);
2847
- const theme = { ..._chunkWRZ6C4TUcjs.DEFAULT_CHART_THEME, ...options.theme };
2847
+ const theme = { ..._chunkP6WYDBTHcjs.DEFAULT_CHART_THEME, ...options.theme };
2848
2848
  const selection = _nullishCoalesce(options.selection, () => ( null));
2849
2849
  const marks = [];
2850
2850
  const warnings = [];
@@ -2883,17 +2883,17 @@ function layoutChart(spec, options) {
2883
2883
  if (spec.title) titleMark("title", spec.title, theme.titleSize, 600, theme.text);
2884
2884
  if (spec.subtitle) titleMark("subtitle", spec.subtitle, fs + 1, 400, theme.mutedText);
2885
2885
  if (spec.title || spec.subtitle) top += 6;
2886
- const family = _chunkWRZ6C4TUcjs.chartFamily.call(void 0, spec);
2886
+ const family = _chunkP6WYDBTHcjs.chartFamily.call(void 0, spec);
2887
2887
  const visible = spec.series.filter((s) => !s.hidden);
2888
2888
  const items = legendItems(spec, ctx);
2889
2889
  let area = { x: pad, y: top, width: width - pad * 2, height: height - top - pad - noteHeight(spec, fs) };
2890
2890
  const seriesLegend = family === "cartesian" || family === "xy" || family === "radar" || family === "histogram";
2891
2891
  const hasTrend = items.some((i) => i.shape === "dash");
2892
- const showLegend = spec.legend.show && items.length > 0 && (!seriesLegend || _chunkWRZ6C4TUcjs.chartVariesColors.call(void 0, spec) || spec.series.length > 1 || spec.series.some((s) => s.hidden) || hasTrend);
2892
+ const showLegend = spec.legend.show && items.length > 0 && (!seriesLegend || _chunkP6WYDBTHcjs.chartVariesColors.call(void 0, spec) || spec.series.length > 1 || spec.series.some((s) => s.hidden) || hasTrend);
2893
2893
  if (showLegend) area = layoutLegend(items, spec.legend.position, area, ctx, ctx.isSelected({ kind: "legend" }));
2894
2894
  const finish = (result) => {
2895
2895
  if (result.plot.width > 0) {
2896
- if (chartAnnotationFamily(_chunkWRZ6C4TUcjs.chartFamily.call(void 0, spec))) drawCallouts(ctx, result.plot);
2896
+ if (chartAnnotationFamily(_chunkP6WYDBTHcjs.chartFamily.call(void 0, spec))) drawCallouts(ctx, result.plot);
2897
2897
  else if (spec.referenceLines.length || spec.referenceBands.length || spec.series.some((s) => s.callouts))
2898
2898
  ctx.warn("annotations-skipped", `Reference lines, bands and callouts are drawn on bar, line, area, scatter and bubble charts; this ${spec.type} chart leaves them out.`);
2899
2899
  }
@@ -3074,7 +3074,7 @@ function addReadout(ctx, readout, plot) {
3074
3074
  } else return;
3075
3075
  const axis = series.axis === "secondary" ? spec.yAxis2 : spec.yAxis;
3076
3076
  const x = _optionalChain([series, 'access', _77 => _77.x, 'optionalAccess', _78 => _78[readout.index]]);
3077
- const text = x !== null && x !== void 0 && _chunkWRZ6C4TUcjs.chartFamily.call(void 0, spec) === "xy" ? `${formatChartNumber(x, spec.xAxis.format)}, ${formatChartNumber(value, axis.format)}` : `${_nullishCoalesce(spec.categories[readout.index], () => ( ""))}: ${formatChartNumber(value, _nullishCoalesce(series.format, () => ( axis.format)))}`;
3077
+ const text = x !== null && x !== void 0 && _chunkP6WYDBTHcjs.chartFamily.call(void 0, spec) === "xy" ? `${formatChartNumber(x, spec.xAxis.format)}, ${formatChartNumber(value, axis.format)}` : `${_nullishCoalesce(spec.categories[readout.index], () => ( ""))}: ${formatChartNumber(value, _nullishCoalesce(series.format, () => ( axis.format)))}`;
3078
3078
  const w = measure(text, fs, 600) + 10;
3079
3079
  const h = fs + 8;
3080
3080
  const bx = Math.max(plot.x, Math.min(plot.x + plot.width - w, ax - w / 2));
@@ -0,0 +1,36 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+
4
+ var _chunkSXQHWXELcjs = require('./chunk-SXQHWXEL.cjs');
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+ var _chunk5UEFBM2Mcjs = require('./chunk-5UEFBM2M.cjs');
14
+
15
+ // src/color/suggest.ts
16
+ function suggestAccessibleForeground(foreground, background, options = {}) {
17
+ const large = _nullishCoalesce(options.large, () => ( false));
18
+ const lch = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, foreground));
19
+ const asHex = (l) => _chunk5UEFBM2Mcjs.parseColor.call(void 0, _chunkSXQHWXELcjs.formatHex.call(void 0, _chunkSXQHWXELcjs.toSrgbGamut.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { ...lch, l })))));
20
+ for (let d = 0.01; d <= 1; d += 0.01) {
21
+ const downCand = asHex(Math.max(0, lch.l - d));
22
+ const upCand = asHex(Math.min(1, lch.l + d));
23
+ const downRatio = _chunk5UEFBM2Mcjs.contrastRatio.call(void 0, downCand, background);
24
+ const upRatio = _chunk5UEFBM2Mcjs.contrastRatio.call(void 0, upCand, background);
25
+ const downPass = _chunk5UEFBM2Mcjs.contrastLevel.call(void 0, downRatio, { large }) !== "fail";
26
+ const upPass = _chunk5UEFBM2Mcjs.contrastLevel.call(void 0, upRatio, { large }) !== "fail";
27
+ if (downPass && upPass) return _chunkSXQHWXELcjs.formatHex.call(void 0, downRatio >= upRatio ? downCand : upCand);
28
+ if (downPass) return _chunkSXQHWXELcjs.formatHex.call(void 0, downCand);
29
+ if (upPass) return _chunkSXQHWXELcjs.formatHex.call(void 0, upCand);
30
+ }
31
+ return void 0;
32
+ }
33
+
34
+
35
+
36
+ exports.suggestAccessibleForeground = suggestAccessibleForeground;
@@ -0,0 +1,276 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+ var _chunkSXQHWXELcjs = require('./chunk-SXQHWXEL.cjs');
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ var _chunk5UEFBM2Mcjs = require('./chunk-5UEFBM2M.cjs');
15
+
16
+ // src/color/dual.ts
17
+ var DEFAULT_SCHEME_SURFACES = {
18
+ light: "#ffffff",
19
+ dark: "#0b0b0f"
20
+ };
21
+ var clamp = (v, min, max) => Math.min(max, Math.max(min, v));
22
+ function isDualColor(value) {
23
+ return typeof value === "object" && value !== null && typeof value.light === "string" && typeof value.dark === "string";
24
+ }
25
+ function parseDualColor(input) {
26
+ if (input === null || input === void 0) return null;
27
+ if (isDualColor(input)) {
28
+ if (_chunk5UEFBM2Mcjs.parseColor.call(void 0, input.light) === null || _chunk5UEFBM2Mcjs.parseColor.call(void 0, input.dark) === null) {
29
+ return null;
30
+ }
31
+ return { light: input.light, dark: input.dark };
32
+ }
33
+ if (typeof input === "string") {
34
+ const trimmed = input.trim();
35
+ if (trimmed.toLowerCase().startsWith("light-dark(") && trimmed.endsWith(")")) {
36
+ const inner = trimmed.slice("light-dark(".length, -1).trim();
37
+ if (inner.toLowerCase().includes("light-dark(")) {
38
+ return null;
39
+ }
40
+ let depth = 0;
41
+ let commaIndex = -1;
42
+ for (let i = 0; i < inner.length; i++) {
43
+ const char = inner[i];
44
+ if (char === "(") {
45
+ depth++;
46
+ } else if (char === ")") {
47
+ depth--;
48
+ if (depth < 0) return null;
49
+ } else if (char === "," && depth === 0) {
50
+ if (commaIndex !== -1) {
51
+ return null;
52
+ }
53
+ commaIndex = i;
54
+ }
55
+ }
56
+ if (depth !== 0 || commaIndex === -1) {
57
+ return null;
58
+ }
59
+ const lightPart = inner.slice(0, commaIndex).trim();
60
+ const darkPart = inner.slice(commaIndex + 1).trim();
61
+ if (!lightPart || !darkPart) return null;
62
+ if (_chunk5UEFBM2Mcjs.parseColor.call(void 0, lightPart) === null || _chunk5UEFBM2Mcjs.parseColor.call(void 0, darkPart) === null) {
63
+ return null;
64
+ }
65
+ return { light: lightPart, dark: darkPart };
66
+ }
67
+ if (_chunk5UEFBM2Mcjs.parseColor.call(void 0, trimmed) !== null) {
68
+ return { light: trimmed, dark: trimmed };
69
+ }
70
+ }
71
+ return null;
72
+ }
73
+ function normalizeDualColor(input) {
74
+ const parsed = parseDualColor(input);
75
+ if (!parsed) return null;
76
+ const light = _chunkSXQHWXELcjs.normalizeColor.call(void 0, parsed.light);
77
+ const dark = _chunkSXQHWXELcjs.normalizeColor.call(void 0, parsed.dark);
78
+ if (!light || !dark) return null;
79
+ return { light, dark };
80
+ }
81
+ function resolveColor(value, scheme) {
82
+ const normalized = normalizeDualColor(value);
83
+ if (!normalized) return null;
84
+ return scheme === "dark" ? normalized.dark : normalized.light;
85
+ }
86
+ function formatDualColor(value) {
87
+ const light = _nullishCoalesce(_chunkSXQHWXELcjs.normalizeColor.call(void 0, value.light), () => ( value.light));
88
+ const dark = _nullishCoalesce(_chunkSXQHWXELcjs.normalizeColor.call(void 0, value.dark), () => ( value.dark));
89
+ if (light === dark) {
90
+ return light;
91
+ }
92
+ return `light-dark(${light}, ${dark})`;
93
+ }
94
+ function isSameInBothSchemes(value) {
95
+ const light = _chunkSXQHWXELcjs.normalizeColor.call(void 0, value.light);
96
+ const dark = _chunkSXQHWXELcjs.normalizeColor.call(void 0, value.dark);
97
+ if (!light || !dark) return value.light === value.dark;
98
+ return light === dark;
99
+ }
100
+ function setDualColorSide(value, scheme, color) {
101
+ const base = _nullishCoalesce(normalizeDualColor(value), () => ( { light: "#000000", dark: "#000000" }));
102
+ const normColor = _nullishCoalesce(_chunkSXQHWXELcjs.normalizeColor.call(void 0, color), () => ( color));
103
+ return {
104
+ light: scheme === "light" ? normColor : base.light,
105
+ dark: scheme === "dark" ? normColor : base.dark
106
+ };
107
+ }
108
+ function deriveDualColor(color, options) {
109
+ const fromScheme = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.from]), () => ( "light"));
110
+ const baseRgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, color);
111
+ if (!baseRgba) {
112
+ throw new Error(`"${String(color)}" is not a colour; pass hex, rgb(), hsl(), oklch() or a CSS colour name.`);
113
+ }
114
+ if (_optionalChain([options, 'optionalAccess', _2 => _2.surfaces]) && !normalizeDualColor(options.surfaces)) {
115
+ throw new Error('The surfaces need a readable light and dark colour, e.g. { light: "#ffffff", dark: "#0b0b0f" }.');
116
+ }
117
+ const baseHex = _chunkSXQHWXELcjs.formatHex.call(void 0, baseRgba);
118
+ const lab = _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, baseRgba);
119
+ const lch = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, lab);
120
+ const startL = clamp(1.05 - lch.l, 0.12, 0.95);
121
+ const targetC = lch.c * 0.9;
122
+ const targetH = lch.h;
123
+ let derivedHex;
124
+ if (_optionalChain([options, 'optionalAccess', _3 => _3.surfaces])) {
125
+ const surfaces = options.surfaces;
126
+ const fromSurfaceRgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, surfaces[fromScheme]);
127
+ const targetScheme = fromScheme === "light" ? "dark" : "light";
128
+ const targetSurfaceRgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, surfaces[targetScheme]);
129
+ const targetRatio = _chunk5UEFBM2Mcjs.contrastRatio.call(void 0, baseRgba, fromSurfaceRgba);
130
+ const targetSurfaceL = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, targetSurfaceRgba)).l;
131
+ const preferHigherL = targetSurfaceL < 0.5;
132
+ let bestDiff = Infinity;
133
+ let bestL = startL;
134
+ for (let candL = 0.05; candL <= 0.98; candL += 5e-3) {
135
+ const candRgb = _chunkSXQHWXELcjs.toSrgbGamut.call(void 0,
136
+ _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: candL, c: targetC, h: targetH, alpha: baseRgba.a }))
137
+ );
138
+ const ratio = _chunk5UEFBM2Mcjs.contrastRatio.call(void 0, candRgb, targetSurfaceRgba);
139
+ const diff = Math.abs(ratio - targetRatio);
140
+ const isBetter = diff < bestDiff - 1e-4 || Math.abs(diff - bestDiff) <= 1e-4 && (preferHigherL ? candL > bestL : candL < bestL);
141
+ if (isBetter) {
142
+ bestDiff = diff;
143
+ bestL = candL;
144
+ }
145
+ }
146
+ const finalRgba = _chunkSXQHWXELcjs.toSrgbGamut.call(void 0,
147
+ _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: bestL, c: targetC, h: targetH, alpha: baseRgba.a }))
148
+ );
149
+ derivedHex = _chunkSXQHWXELcjs.formatHex.call(void 0, finalRgba);
150
+ } else {
151
+ const finalRgba = _chunkSXQHWXELcjs.toSrgbGamut.call(void 0,
152
+ _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: startL, c: targetC, h: targetH, alpha: baseRgba.a }))
153
+ );
154
+ derivedHex = _chunkSXQHWXELcjs.formatHex.call(void 0, finalRgba);
155
+ }
156
+ return fromScheme === "light" ? { light: baseHex, dark: derivedHex } : { light: derivedHex, dark: baseHex };
157
+ }
158
+ function checkDualColorContrast(foreground, background, options) {
159
+ const large = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _4 => _4.large]), () => ( false));
160
+ const requiredRatio = large ? 3 : 4.5;
161
+ const fg = normalizeDualColor(foreground);
162
+ const bg = normalizeDualColor(background);
163
+ if (!fg) throw new Error(`The foreground "${describeValue(foreground)}" is not a colour, light-dark() or { light, dark }.`);
164
+ if (!bg) throw new Error(`The background "${describeValue(background)}" is not a colour, light-dark() or { light, dark }.`);
165
+ const lightFgHex = fg.light;
166
+ const lightBgHex = bg.light;
167
+ const darkFgHex = fg.dark;
168
+ const darkBgHex = bg.dark;
169
+ const lightFg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, lightFgHex);
170
+ const lightBg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, lightBgHex);
171
+ const darkFg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, darkFgHex);
172
+ const darkBg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, darkBgHex);
173
+ const lightRatio = Math.round(_chunk5UEFBM2Mcjs.contrastRatio.call(void 0, lightFg, lightBg) * 100) / 100;
174
+ const darkRatio = Math.round(_chunk5UEFBM2Mcjs.contrastRatio.call(void 0, darkFg, darkBg) * 100) / 100;
175
+ const lightLevel = _chunk5UEFBM2Mcjs.contrastLevel.call(void 0, lightRatio, { large });
176
+ const darkLevel = _chunk5UEFBM2Mcjs.contrastLevel.call(void 0, darkRatio, { large });
177
+ const issues = [];
178
+ if (lightLevel === "fail") {
179
+ issues.push(
180
+ `In light mode, ${lightFgHex} on ${lightBgHex} has a contrast of ${lightRatio.toFixed(1)} (needs ${requiredRatio} for AA).`
181
+ );
182
+ }
183
+ if (darkLevel === "fail") {
184
+ issues.push(
185
+ `In dark mode, ${darkFgHex} on ${darkBgHex} has a contrast of ${darkRatio.toFixed(1)} (needs ${requiredRatio} for AA).`
186
+ );
187
+ }
188
+ return {
189
+ light: { ratio: lightRatio, level: lightLevel },
190
+ dark: { ratio: darkRatio, level: darkLevel },
191
+ issues
192
+ };
193
+ }
194
+ var CSS_VARIABLE_NAME = /^[A-Za-z_][A-Za-z0-9_-]*$/;
195
+ function describeValue(value) {
196
+ return typeof value === "string" ? value : _nullishCoalesce(JSON.stringify(value), () => ( String(value)));
197
+ }
198
+ function dualColorsToCss(colors, options) {
199
+ const selector = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _5 => _5.selector]), () => ( ":root"));
200
+ const strategy = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _6 => _6.strategy]), () => ( "light-dark"));
201
+ const darkSelector = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.darkSelector]), () => ( ".dark"));
202
+ for (const [label, sel] of [["selector", selector], ["darkSelector", darkSelector]]) {
203
+ if (!sel.trim() || /[{};]/.test(sel)) {
204
+ throw new Error(`The ${label} "${sel}" is not a CSS selector (it can't be empty or contain "{", "}" or ";").`);
205
+ }
206
+ }
207
+ const normalized = {};
208
+ for (const [key, value] of Object.entries(colors)) {
209
+ if (!CSS_VARIABLE_NAME.test(key)) {
210
+ throw new Error(`"${key}" is not a CSS variable name; use letters, digits, "-" and "_" without the leading "--" (e.g. "brand-color").`);
211
+ }
212
+ const dual = normalizeDualColor(value);
213
+ if (!dual) throw new Error(`"${key}" has "${describeValue(value)}", which is not a colour, light-dark() or { light, dark }.`);
214
+ normalized[key] = dual;
215
+ }
216
+ const sortedKeys = Object.keys(normalized).sort();
217
+ switch (strategy) {
218
+ case "light-dark": {
219
+ const lines = [
220
+ `${selector} {`,
221
+ ...selector === ":root" ? [" color-scheme: light dark;"] : [],
222
+ ...sortedKeys.map((k) => {
223
+ return ` --${k}: ${formatDualColor(normalized[k])};`;
224
+ }),
225
+ "}"
226
+ ];
227
+ return lines.join("\n");
228
+ }
229
+ case "media": {
230
+ const lightLines = [
231
+ `${selector} {`,
232
+ ...sortedKeys.map((k) => ` --${k}: ${normalized[k].light};`),
233
+ "}"
234
+ ];
235
+ const darkLines = [
236
+ `@media (prefers-color-scheme: dark) {`,
237
+ ` ${selector} {`,
238
+ ...sortedKeys.map((k) => ` --${k}: ${normalized[k].dark};`),
239
+ ` }`,
240
+ `}`
241
+ ];
242
+ return `${lightLines.join("\n")}
243
+
244
+ ${darkLines.join("\n")}`;
245
+ }
246
+ case "class": {
247
+ const lightLines = [
248
+ `${selector} {`,
249
+ ...sortedKeys.map((k) => ` --${k}: ${normalized[k].light};`),
250
+ "}"
251
+ ];
252
+ const darkLines = [
253
+ `${darkSelector} {`,
254
+ ...sortedKeys.map((k) => ` --${k}: ${normalized[k].dark};`),
255
+ "}"
256
+ ];
257
+ return `${lightLines.join("\n")}
258
+
259
+ ${darkLines.join("\n")}`;
260
+ }
261
+ }
262
+ }
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+ exports.DEFAULT_SCHEME_SURFACES = DEFAULT_SCHEME_SURFACES; exports.isDualColor = isDualColor; exports.parseDualColor = parseDualColor; exports.normalizeDualColor = normalizeDualColor; exports.resolveColor = resolveColor; exports.formatDualColor = formatDualColor; exports.isSameInBothSchemes = isSameInBothSchemes; exports.setDualColorSide = setDualColorSide; exports.deriveDualColor = deriveDualColor; exports.checkDualColorContrast = checkDualColorContrast; exports.dualColorsToCss = dualColorsToCss;
@@ -14,7 +14,7 @@ import {
14
14
  r2,
15
15
  sameChartSelection,
16
16
  summarizeChartSeries
17
- } from "./chunk-WKMUBATU.js";
17
+ } from "./chunk-C2WEIEUB.js";
18
18
  import {
19
19
  CHART_TYPE_LABELS,
20
20
  DEFAULT_CHART_PALETTE,
@@ -47,7 +47,7 @@ import {
47
47
  parseChartValue,
48
48
  shadeChartColor,
49
49
  uniqueChartSeriesId
50
- } from "./chunk-6ZZKRH7R.js";
50
+ } from "./chunk-47V3WXDG.js";
51
51
  import {
52
52
  parseCsv,
53
53
  parseTsv