@extend-ai/react-xlsx 0.18.1 → 0.20.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 (72) hide show
  1. package/README.md +154 -6
  2. package/dist/chart-renderer-AAVZ34BF.cjs +5048 -0
  3. package/dist/chart-renderer-AAVZ34BF.cjs.map +1 -0
  4. package/dist/{chart-renderer-HQSQHDCB.js → chart-renderer-KGLAI4DN.js} +25 -20
  5. package/dist/chart-renderer-KGLAI4DN.js.map +1 -0
  6. package/dist/{chart-renderer-ZUWRNNZT.cjs → chart-renderer-NM5UVCTO.cjs} +44 -39
  7. package/dist/chart-renderer-NM5UVCTO.cjs.map +1 -0
  8. package/dist/chart-renderer-RXO7WP4Q.js +5047 -0
  9. package/dist/chart-renderer-RXO7WP4Q.js.map +1 -0
  10. package/dist/chunk-2YBG7XQ3.cjs +26981 -0
  11. package/dist/chunk-2YBG7XQ3.cjs.map +1 -0
  12. package/dist/chunk-3JTCYAUX.js +50 -0
  13. package/dist/{chunk-OZLJPZUX.js.map → chunk-3JTCYAUX.js.map} +1 -1
  14. package/dist/chunk-6K3NSKDJ.cjs +50 -0
  15. package/dist/chunk-6K3NSKDJ.cjs.map +1 -0
  16. package/dist/chunk-CJBI5F6V.cjs +816 -0
  17. package/dist/chunk-CJBI5F6V.cjs.map +1 -0
  18. package/dist/{chunk-WFQGZI2Z.cjs → chunk-MCFUTO4J.cjs} +12 -8
  19. package/dist/chunk-MCFUTO4J.cjs.map +1 -0
  20. package/dist/chunk-NBH72POD.js +816 -0
  21. package/dist/chunk-NBH72POD.js.map +1 -0
  22. package/dist/{chunk-E2VSYCP2.cjs → chunk-O3V2MCOC.cjs} +18 -2
  23. package/dist/chunk-O3V2MCOC.cjs.map +1 -0
  24. package/dist/chunk-QN3D3JS2.js +26978 -0
  25. package/dist/chunk-QN3D3JS2.js.map +1 -0
  26. package/dist/{chunk-FO6MIHX4.cjs → chunk-T5WZHPIN.cjs} +2 -2
  27. package/dist/{chunk-FO6MIHX4.cjs.map → chunk-T5WZHPIN.cjs.map} +1 -1
  28. package/dist/{chunk-BAAMDEDS.js → chunk-VXBNYHW5.js} +18 -2
  29. package/dist/{chunk-BAAMDEDS.js.map → chunk-VXBNYHW5.js.map} +1 -1
  30. package/dist/{chunk-OZLJPZUX.js → chunk-WSQDFXDW.js} +10 -6
  31. package/dist/chunk-WSQDFXDW.js.map +1 -0
  32. package/dist/index.cjs +600 -11270
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +5 -14
  35. package/dist/index.d.ts +5 -14
  36. package/dist/index.js +479 -11149
  37. package/dist/index.js.map +1 -1
  38. package/dist/internal-DrXSHYJZ.d.cts +1498 -0
  39. package/dist/internal-DrXSHYJZ.d.ts +1498 -0
  40. package/dist/internal.cjs +24 -0
  41. package/dist/internal.cjs.map +1 -0
  42. package/dist/internal.d.cts +3 -0
  43. package/dist/internal.d.ts +3 -0
  44. package/dist/internal.js +23 -0
  45. package/dist/internal.js.map +1 -0
  46. package/dist/{region-map-geography-5E5SVPGS.cjs → region-map-geography-6TGXBY3V.cjs} +2 -2
  47. package/dist/{region-map-geography-5E5SVPGS.cjs.map → region-map-geography-6TGXBY3V.cjs.map} +1 -1
  48. package/dist/{spreadsheet-font-assets-7QMV43XD.cjs → spreadsheet-font-assets-4AHYDTAQ.cjs} +2 -2
  49. package/dist/{spreadsheet-font-assets-7QMV43XD.cjs.map → spreadsheet-font-assets-4AHYDTAQ.cjs.map} +1 -1
  50. package/dist/{surface-regl-WVLW3SEA.cjs → surface-regl-5Z6IVOID.cjs} +18 -15
  51. package/dist/surface-regl-5Z6IVOID.cjs.map +1 -0
  52. package/dist/{surface-regl-NWR5ZZ5D.js → surface-regl-7CDGGVDG.js} +10 -7
  53. package/dist/surface-regl-7CDGGVDG.js.map +1 -0
  54. package/dist/surface-regl-AY7JZVYY.cjs +727 -0
  55. package/dist/surface-regl-AY7JZVYY.cjs.map +1 -0
  56. package/dist/surface-regl-TJUWTLAZ.js +726 -0
  57. package/dist/surface-regl-TJUWTLAZ.js.map +1 -0
  58. package/dist/vanilla.cjs +20 -0
  59. package/dist/vanilla.cjs.map +1 -0
  60. package/dist/vanilla.d.cts +9 -0
  61. package/dist/vanilla.d.ts +9 -0
  62. package/dist/vanilla.js +19 -0
  63. package/dist/vanilla.js.map +1 -0
  64. package/dist/xlsx-worker.js +2888 -34
  65. package/dist/xlsx-worker.js.map +1 -1
  66. package/package.json +23 -3
  67. package/dist/chart-renderer-HQSQHDCB.js.map +0 -1
  68. package/dist/chart-renderer-ZUWRNNZT.cjs.map +0 -1
  69. package/dist/chunk-E2VSYCP2.cjs.map +0 -1
  70. package/dist/chunk-WFQGZI2Z.cjs.map +0 -1
  71. package/dist/surface-regl-NWR5ZZ5D.js.map +0 -1
  72. package/dist/surface-regl-WVLW3SEA.cjs.map +0 -1
@@ -0,0 +1,726 @@
1
+ import {
2
+ clipSurfaceBand,
3
+ groupSurfaceBandEdges,
4
+ normalizeSurfaceValue,
5
+ shadeSurfaceMatteColor,
6
+ surfaceDataRatios,
7
+ surfaceNormal,
8
+ transformSurfaceNormal,
9
+ triangulateSurfaceQuad
10
+ } from "./chunk-VXBNYHW5.js";
11
+ import {
12
+ A,
13
+ N,
14
+ d,
15
+ getBuiltinChartColor,
16
+ getBuiltinChartSurfaceLine,
17
+ h,
18
+ resolveBuiltinChartColor,
19
+ u
20
+ } from "./chunk-NBH72POD.js";
21
+
22
+ // src/surface-regl.tsx
23
+ import createREGL from "regl";
24
+ function clamp(value, min, max) {
25
+ return Math.max(min, Math.min(max, value));
26
+ }
27
+ function safeNumber(value) {
28
+ if (typeof value === "number" && Number.isFinite(value)) {
29
+ return value;
30
+ }
31
+ if (typeof value === "string") {
32
+ const normalized = value.trim().replace(/,/g, "");
33
+ if (!normalized) {
34
+ return null;
35
+ }
36
+ const parsed = Number(normalized);
37
+ return Number.isFinite(parsed) ? parsed : null;
38
+ }
39
+ return null;
40
+ }
41
+ function parseRgbColor(color) {
42
+ const match = /^#?([0-9a-f]{6})$/i.exec(color);
43
+ if (!match) {
44
+ return null;
45
+ }
46
+ return {
47
+ blue: Number.parseInt(match[1].slice(4, 6), 16),
48
+ green: Number.parseInt(match[1].slice(2, 4), 16),
49
+ red: Number.parseInt(match[1].slice(0, 2), 16)
50
+ };
51
+ }
52
+ function resolveSurfaceBaseColor(chart, palette) {
53
+ return chart.chartColorPalette?.[0] ?? chart.series[0]?.color ?? chart.series[0]?.lineColor ?? chart.axisLineColor ?? chart.textColor ?? palette.text;
54
+ }
55
+ function normalizeSurfaceRendererHexColor(value) {
56
+ if (typeof value !== "string") {
57
+ return null;
58
+ }
59
+ const trimmed = value.trim();
60
+ if (!trimmed) {
61
+ return null;
62
+ }
63
+ const normalized = trimmed.startsWith("#") ? trimmed.slice(1) : trimmed;
64
+ return /^[0-9a-f]{6}$/i.test(normalized) ? `#${normalized.toLowerCase()}` : null;
65
+ }
66
+ function resolveExplicitSurfaceSeriesColor(chart, kind) {
67
+ const shape = chart.series[0]?.shapeProperties;
68
+ if (kind === "fill" ? shape?.xmlFillHidden === true : shape?.xmlLineHidden === true) return "transparent";
69
+ const color = kind === "fill" ? shape?.xmlFillColor ?? shape?.solidFillHex : shape?.xmlLineColor ?? shape?.lineColorHex;
70
+ return normalizeSurfaceRendererHexColor(color);
71
+ }
72
+ function getSurfaceColorStops(chart, palette) {
73
+ const explicitFill = resolveExplicitSurfaceSeriesColor(chart, "fill");
74
+ if (explicitFill) return [explicitFill];
75
+ const colors = (chart.chartColorPalette ?? []).filter((value) => typeof value === "string" && value.length > 0);
76
+ return colors.length > 0 ? colors : [resolveSurfaceBaseColor(chart, palette)];
77
+ }
78
+ function getSurfaceDomain(chart) {
79
+ const numericValues = chart.series.flatMap((series) => series.values.map((value) => safeNumber(value)).filter((value) => value != null));
80
+ if (numericValues.length === 0) {
81
+ return null;
82
+ }
83
+ const explicitMin = typeof chart.valueAxis?.min === "number" && Number.isFinite(chart.valueAxis.min) ? chart.valueAxis.min : null;
84
+ const explicitMax = typeof chart.valueAxis?.max === "number" && Number.isFinite(chart.valueAxis.max) ? chart.valueAxis.max : null;
85
+ const rawMin = Math.min(...numericValues);
86
+ const rawMax = Math.max(...numericValues);
87
+ const spanBase = Math.max(1e-6, rawMax - Math.min(0, rawMin));
88
+ const roughStep = spanBase / 5;
89
+ const magnitude = Math.pow(10, Math.floor(Math.log10(Math.max(roughStep, 1e-6))));
90
+ const normalized = roughStep / magnitude;
91
+ const niceStep = normalized <= 1 ? 1 : normalized <= 2 ? 2 : normalized <= 5 ? 5 : 10;
92
+ const step = typeof chart.valueAxis?.majorUnit === "number" && chart.valueAxis.majorUnit > 0 ? chart.valueAxis.majorUnit : niceStep * magnitude;
93
+ const minValue = explicitMin ?? (rawMin >= 0 ? 0 : Math.floor(rawMin / step) * step);
94
+ const maxValue = explicitMax ?? Math.ceil(rawMax / step) * step;
95
+ const safeMax = maxValue <= minValue ? minValue + step : maxValue;
96
+ const ticks = [];
97
+ for (let current = minValue; current <= safeMax + step * 1e-3; current += step) {
98
+ ticks.push(Number(current.toFixed(8)));
99
+ }
100
+ const boundedTicks = [.../* @__PURE__ */ new Set([...ticks.filter((tick) => tick < safeMax), safeMax])];
101
+ return {
102
+ maxValue,
103
+ minValue,
104
+ safeMax,
105
+ ticks: boundedTicks.length >= 2 ? boundedTicks : [minValue, safeMax]
106
+ };
107
+ }
108
+ function resolveSurfaceBandPaletteColor(chart, palette, domain, value) {
109
+ const bandIndex = resolveSurfaceBandIndex(domain, value);
110
+ const explicitColor = resolveSurfaceBandFormatColor(chart, "bandFormatColors", bandIndex);
111
+ if (explicitColor) return explicitColor;
112
+ const explicitFill = resolveExplicitSurfaceSeriesColor(chart, "fill");
113
+ if (explicitFill) return explicitFill;
114
+ const themeColors = chart.raw?.builtinThemeColors;
115
+ const paletteCount = Math.trunc((domain.safeMax - domain.minValue) / (domain.ticks[1] - domain.ticks[0])) + 1;
116
+ const builtinColor = themeColors ? resolveBuiltinChartColor(getBuiltinChartColor(chart.chartStyleId, bandIndex % paletteCount, paletteCount), themeColors) : void 0;
117
+ if (builtinColor) return builtinColor;
118
+ const stops = getSurfaceColorStops(chart, palette);
119
+ if (stops.length === 0) {
120
+ return resolveSurfaceBaseColor(chart, palette);
121
+ }
122
+ return stops[Math.min(stops.length - 1, Math.max(0, bandIndex))] ?? stops[stops.length - 1] ?? resolveSurfaceBaseColor(chart, palette);
123
+ }
124
+ function resolveSurfaceBandIndex(domain, value) {
125
+ const ticks = domain.ticks;
126
+ for (let index = 0; index < ticks.length - 1; index += 1) {
127
+ const end = ticks[index + 1] ?? domain.safeMax;
128
+ if (value <= end || index === ticks.length - 2) {
129
+ return index;
130
+ }
131
+ }
132
+ return Math.max(0, ticks.length - 2);
133
+ }
134
+ function resolveSurfaceBandColor(chart, palette, domain, value) {
135
+ return resolveSurfaceBandPaletteColor(chart, palette, domain, value);
136
+ }
137
+ function resolveSurfaceBandFormatColor(chart, key, index) {
138
+ const colors = chart.raw?.[key];
139
+ if (!colors || typeof colors !== "object" || !Object.prototype.hasOwnProperty.call(colors, index)) return null;
140
+ const color = colors[index];
141
+ return typeof color === "string" && color.length > 0 ? color : null;
142
+ }
143
+ function resolveSurfaceWireframeColor(chart, palette, domain, value) {
144
+ const bandIndex = resolveSurfaceBandIndex(domain, value);
145
+ const themeColors = chart.raw?.builtinThemeColors;
146
+ const paletteCount = Math.trunc((domain.safeMax - domain.minValue) / (domain.ticks[1] - domain.ticks[0])) + 1;
147
+ const builtinLine = themeColors ? resolveBuiltinChartColor(getBuiltinChartSurfaceLine(chart.chartStyleId, bandIndex, paletteCount), themeColors) : void 0;
148
+ return resolveSurfaceBandFormatColor(chart, "bandFormatLineColors", bandIndex) ?? resolveExplicitSurfaceSeriesColor(chart, "line") ?? builtinLine ?? resolveSurfaceBandPaletteColor(chart, palette, domain, value);
149
+ }
150
+ function colorToRgba(color, alpha = 1) {
151
+ if (color === "transparent") return [0, 0, 0, 0];
152
+ const rgb = parseRgbColor(color);
153
+ if (!rgb) {
154
+ return [0.1, 0.1, 0.1, alpha];
155
+ }
156
+ return [rgb.red / 255, rgb.green / 255, rgb.blue / 255, alpha];
157
+ }
158
+ function normalizeSurfaceX(column, cols) {
159
+ return cols <= 1 ? 0 : (column / (cols - 1) - 0.5) * 2;
160
+ }
161
+ function normalizeSurfaceY(row, rows) {
162
+ return rows <= 1 ? 0 : (row / (rows - 1) - 0.5) * 2;
163
+ }
164
+ function normalizeSurfaceZ(value, domain, heightExtent, axis) {
165
+ return -(normalizeSurfaceValue(value, domain.minValue, domain.safeMax, axis) - 0.5) * heightExtent;
166
+ }
167
+ function projectCartesian3dPoint(x, y, z, rotXRad, rotYRad, usePerspective, perspectiveStrength, rightAngleAxes) {
168
+ if (rightAngleAxes) {
169
+ return { depth: z, x: x + z * Math.sin(rotYRad), y: y - z * Math.sin(rotXRad) };
170
+ }
171
+ const cosX = Math.cos(rotXRad);
172
+ const sinX = Math.sin(rotXRad);
173
+ const cosY = Math.cos(rotYRad);
174
+ const sinY = Math.sin(rotYRad);
175
+ const x1 = x * cosY + z * sinY;
176
+ const z1 = -x * sinY + z * cosY;
177
+ const y1 = y * cosX - z1 * sinX;
178
+ const z2 = y * sinX + z1 * cosX;
179
+ const perspective = usePerspective ? 1 / Math.max(0.18, 1 + z2 * (0.24 + perspectiveStrength * 0.5)) : 1;
180
+ return {
181
+ depth: z2,
182
+ x: x1 * perspective,
183
+ y: y1 * perspective
184
+ };
185
+ }
186
+ function withProjectedDepth(point, depth) {
187
+ return {
188
+ ...point,
189
+ depth
190
+ };
191
+ }
192
+ function nudgeProjectedDepth(point, delta) {
193
+ return {
194
+ ...point,
195
+ depth: point.depth + delta
196
+ };
197
+ }
198
+ function isContourSurfaceChart(chart) {
199
+ const rawChartType = chart.raw && typeof chart.raw === "object" && typeof chart.raw.xmlChartType === "string" ? chart.raw.xmlChartType : "";
200
+ if (rawChartType === "surfaceChart") {
201
+ return true;
202
+ }
203
+ if (rawChartType === "surface3DChart") {
204
+ return false;
205
+ }
206
+ return chart.chartType === "Surface" && chart.is3d !== true;
207
+ }
208
+ function buildSurfaceMesh(chart, palette, layout) {
209
+ const rows = chart.series.length;
210
+ const cols = chart.series.reduce((max, series) => Math.max(max, series.values.length), 0);
211
+ if (rows < 2 || cols < 2) {
212
+ return null;
213
+ }
214
+ const matrix = chart.series.map((series) => Array.from({ length: cols }, (_, columnIndex) => safeNumber(series.values[columnIndex])));
215
+ const domain = getSurfaceDomain(chart);
216
+ if (!domain) {
217
+ return null;
218
+ }
219
+ const isContour = isContourSurfaceChart(chart);
220
+ const isWireframe = chart.wireframe === true;
221
+ const fillVertices = [];
222
+ const wallTriangles = [];
223
+ const contourLines = [];
224
+ const meshLines = [];
225
+ const rotX = (chart.view3d?.rotX ?? 25) * (Math.PI / 180);
226
+ const rotY = (chart.view3d?.rotY ?? 30) * (Math.PI / 180);
227
+ const usePerspective = !isContour && chart.view3d?.rAngAx === false;
228
+ const perspectiveStrength = clamp((chart.view3d?.perspective ?? (usePerspective ? 30 : 0)) / 100, 0, 1);
229
+ const ratios = surfaceDataRatios(rows, cols, chart.valueAxis?.crossBetween !== "midCat", chart.view3d?.heightPercent, chart.view3d?.depthPercent, layout);
230
+ const depthScale = ratios.depth;
231
+ const heightExtent = 2 * ratios.height;
232
+ const usesFlatMaterial = chart.surfaceMaterial === "flat";
233
+ const wallLineColor = chart.valueAxis?.majorGridlineColor ?? chart.backWall?.lineColor ?? chart.sideWall?.lineColor ?? chart.floor?.lineColor ?? chart.axisLineColor ?? "#a6a6a6";
234
+ const backWallFill = chart.backWall?.fillColor ?? "#d9d9df";
235
+ const sideWallFill = chart.sideWall?.fillColor ?? "#d5d7dc";
236
+ const floorFill = chart.floor?.fillColor ?? "#d0d2d8";
237
+ const projectPoint = (column, row, value) => {
238
+ const worldX = normalizeSurfaceX(column, cols);
239
+ if (isContour) {
240
+ return {
241
+ depth: 0,
242
+ worldX,
243
+ worldY: normalizeSurfaceY(row, rows),
244
+ worldZ: 0,
245
+ x: worldX,
246
+ y: normalizeSurfaceY(row, rows)
247
+ };
248
+ }
249
+ const worldY = normalizeSurfaceZ(value, domain, heightExtent, chart.valueAxis);
250
+ const worldZ = normalizeSurfaceY(row, rows) * depthScale;
251
+ const projected = projectCartesian3dPoint(worldX, worldY, worldZ, rotX, rotY, usePerspective, perspectiveStrength, chart.view3d?.rAngAx !== false);
252
+ return {
253
+ depth: projected.depth,
254
+ worldX,
255
+ worldY,
256
+ worldZ,
257
+ x: projected.x,
258
+ y: projected.y
259
+ };
260
+ };
261
+ const addWallQuad = (a, b, c, d2, color) => {
262
+ wallTriangles.push(
263
+ { color, points: [a, b, c] },
264
+ { color, points: [a, c, d2] }
265
+ );
266
+ };
267
+ const addMeshLine = (from, to, color) => {
268
+ meshLines.push({ color, from, to });
269
+ };
270
+ for (let rowIndex = 0; rowIndex < rows - 1; rowIndex += 1) {
271
+ for (let columnIndex = 0; columnIndex < cols - 1; columnIndex += 1) {
272
+ const p00 = matrix[rowIndex]?.[columnIndex];
273
+ const p10 = matrix[rowIndex]?.[columnIndex + 1];
274
+ const p01 = matrix[rowIndex + 1]?.[columnIndex];
275
+ const p11 = matrix[rowIndex + 1]?.[columnIndex + 1];
276
+ if (p00 == null || p10 == null || p01 == null || p11 == null) {
277
+ continue;
278
+ }
279
+ const triangles = triangulateSurfaceQuad([
280
+ { value: p00, x: columnIndex, y: rowIndex },
281
+ { value: p10, x: columnIndex + 1, y: rowIndex },
282
+ { value: p11, x: columnIndex + 1, y: rowIndex + 1 },
283
+ { value: p01, x: columnIndex, y: rowIndex + 1 }
284
+ ], chart.valueAxis);
285
+ for (const triangle of triangles) {
286
+ for (let band = 0; band < domain.ticks.length - 1; band += 1) {
287
+ const lower = domain.ticks[band];
288
+ const upper = domain.ticks[band + 1];
289
+ const polygon = clipSurfaceBand(clipSurfaceBand(triangle, lower, true, chart.valueAxis, band === 0), upper, false, chart.valueAxis);
290
+ if (polygon.length < 3) continue;
291
+ const bandColor = resolveSurfaceBandColor(chart, palette, domain, (lower + upper) / 2);
292
+ if (!isWireframe && bandColor !== "transparent") {
293
+ for (let index = 1; index < polygon.length - 1; index += 1) {
294
+ for (const vertex of [polygon[0], polygon[index], polygon[index + 1]]) {
295
+ const point = projectPoint(vertex.x, vertex.y, vertex.value);
296
+ fillVertices.push({ bandColor, point: isContour ? withProjectedDepth(point, 0.08) : point, value: vertex.value });
297
+ }
298
+ }
299
+ }
300
+ for (const group of groupSurfaceBandEdges(polygon, triangle, band, lower, isWireframe)) {
301
+ const edgeMidpoint = (domain.ticks[group.band] + domain.ticks[group.band + 1]) / 2;
302
+ const color = resolveSurfaceWireframeColor(chart, palette, domain, edgeMidpoint);
303
+ if (color !== "transparent") {
304
+ for (const [from, to] of group.edges) {
305
+ contourLines.push({ color, from: projectPoint(from.x, from.y, from.value), to: projectPoint(to.x, to.y, to.value) });
306
+ }
307
+ }
308
+ }
309
+ }
310
+ }
311
+ }
312
+ }
313
+ const columnSkip = Math.max(1, chart.categoryAxis?.tickMarkSkip ?? 1);
314
+ const rowSkip = Math.max(1, chart.seriesAxis?.tickMarkSkip ?? 1);
315
+ if (isContour) {
316
+ const topLeft = withProjectedDepth(projectPoint(0, 0, domain.minValue), -0.12);
317
+ const topRight = withProjectedDepth(projectPoint(cols - 1, 0, domain.minValue), -0.12);
318
+ const bottomRight = withProjectedDepth(projectPoint(cols - 1, rows - 1, domain.minValue), -0.12);
319
+ const bottomLeft = withProjectedDepth(projectPoint(0, rows - 1, domain.minValue), -0.12);
320
+ if (chart.backWall?.hidden !== true && backWallFill !== "transparent") {
321
+ addWallQuad(topLeft, topRight, bottomRight, bottomLeft, backWallFill);
322
+ }
323
+ for (let columnIndex = 0; columnIndex < cols; columnIndex += columnSkip) {
324
+ addMeshLine(
325
+ withProjectedDepth(projectPoint(columnIndex, 0, domain.minValue), 0.04),
326
+ withProjectedDepth(projectPoint(columnIndex, rows - 1, domain.minValue), 0.04),
327
+ wallLineColor
328
+ );
329
+ }
330
+ for (let rowIndex = 0; rowIndex < rows; rowIndex += rowSkip) {
331
+ addMeshLine(
332
+ withProjectedDepth(projectPoint(0, rowIndex, domain.minValue), 0.04),
333
+ withProjectedDepth(projectPoint(cols - 1, rowIndex, domain.minValue), 0.04),
334
+ wallLineColor
335
+ );
336
+ }
337
+ } else {
338
+ const minPlaneValue = domain.minValue;
339
+ const wallDepthOffset = 0;
340
+ const backRow = chart.view3d?.rAngAx !== false || Math.cos(rotX) * Math.cos(rotY) >= 0 ? rows - 1 : 0;
341
+ const sideColumn = Math.sin(rotY) >= 0 ? 0 : cols - 1;
342
+ if (chart.floor?.hidden !== true && floorFill !== "transparent") {
343
+ addWallQuad(
344
+ nudgeProjectedDepth(projectPoint(0, 0, minPlaneValue), wallDepthOffset),
345
+ nudgeProjectedDepth(projectPoint(cols - 1, 0, minPlaneValue), wallDepthOffset),
346
+ nudgeProjectedDepth(projectPoint(cols - 1, rows - 1, minPlaneValue), wallDepthOffset),
347
+ nudgeProjectedDepth(projectPoint(0, rows - 1, minPlaneValue), wallDepthOffset),
348
+ floorFill
349
+ );
350
+ }
351
+ if (chart.backWall?.hidden !== true && backWallFill !== "transparent") {
352
+ addWallQuad(
353
+ nudgeProjectedDepth(projectPoint(0, backRow, domain.safeMax), wallDepthOffset),
354
+ nudgeProjectedDepth(projectPoint(cols - 1, backRow, domain.safeMax), wallDepthOffset),
355
+ nudgeProjectedDepth(projectPoint(cols - 1, backRow, minPlaneValue), wallDepthOffset),
356
+ nudgeProjectedDepth(projectPoint(0, backRow, minPlaneValue), wallDepthOffset),
357
+ backWallFill
358
+ );
359
+ }
360
+ if (chart.sideWall?.hidden !== true && sideWallFill !== "transparent") {
361
+ addWallQuad(
362
+ nudgeProjectedDepth(projectPoint(sideColumn, 0, domain.safeMax), wallDepthOffset),
363
+ nudgeProjectedDepth(projectPoint(sideColumn, rows - 1, domain.safeMax), wallDepthOffset),
364
+ nudgeProjectedDepth(projectPoint(sideColumn, rows - 1, minPlaneValue), wallDepthOffset),
365
+ nudgeProjectedDepth(projectPoint(sideColumn, 0, minPlaneValue), wallDepthOffset),
366
+ sideWallFill
367
+ );
368
+ }
369
+ for (const tick of chart.valueAxis?.majorGridlines ? domain.ticks : []) {
370
+ if (chart.backWall?.hidden !== true && wallLineColor !== "transparent") {
371
+ addMeshLine(nudgeProjectedDepth(projectPoint(0, backRow, tick), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(cols - 1, backRow, tick), wallDepthOffset * 0.75), wallLineColor);
372
+ }
373
+ if (chart.sideWall?.hidden !== true && wallLineColor !== "transparent") {
374
+ addMeshLine(nudgeProjectedDepth(projectPoint(sideColumn, 0, tick), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(sideColumn, rows - 1, tick), wallDepthOffset * 0.75), wallLineColor);
375
+ }
376
+ }
377
+ for (let columnIndex = 0; chart.categoryAxis?.majorGridlines && columnIndex < cols; columnIndex += columnSkip) {
378
+ if (chart.floor?.hidden !== true && wallLineColor !== "transparent") {
379
+ addMeshLine(nudgeProjectedDepth(projectPoint(columnIndex, 0, minPlaneValue), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(columnIndex, rows - 1, minPlaneValue), wallDepthOffset * 0.75), wallLineColor);
380
+ }
381
+ if (chart.backWall?.hidden !== true && wallLineColor !== "transparent") {
382
+ addMeshLine(nudgeProjectedDepth(projectPoint(columnIndex, backRow, minPlaneValue), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(columnIndex, backRow, domain.safeMax), wallDepthOffset * 0.75), wallLineColor);
383
+ }
384
+ }
385
+ for (let rowIndex = 0; chart.seriesAxis?.majorGridlines && rowIndex < rows; rowIndex += rowSkip) {
386
+ if (chart.floor?.hidden !== true && wallLineColor !== "transparent") {
387
+ addMeshLine(nudgeProjectedDepth(projectPoint(0, rowIndex, minPlaneValue), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(cols - 1, rowIndex, minPlaneValue), wallDepthOffset * 0.75), wallLineColor);
388
+ }
389
+ if (chart.sideWall?.hidden !== true && wallLineColor !== "transparent") {
390
+ addMeshLine(nudgeProjectedDepth(projectPoint(sideColumn, rowIndex, minPlaneValue), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(sideColumn, rowIndex, domain.safeMax), wallDepthOffset * 0.75), wallLineColor);
391
+ }
392
+ }
393
+ }
394
+ const allPoints = [
395
+ ...fillVertices.map((vertex) => vertex.point),
396
+ ...wallTriangles.flatMap((triangle) => triangle.points),
397
+ ...meshLines.flatMap((line) => [line.from, line.to]),
398
+ ...contourLines.flatMap((line) => [line.from, line.to])
399
+ ];
400
+ if (allPoints.length === 0) {
401
+ return null;
402
+ }
403
+ const minX = Math.min(...allPoints.map((point) => point.x));
404
+ const maxX = Math.max(...allPoints.map((point) => point.x));
405
+ const minY = Math.min(...allPoints.map((point) => point.y));
406
+ const maxY = Math.max(...allPoints.map((point) => point.y));
407
+ const minDepth = Math.min(...allPoints.map((point) => point.depth));
408
+ const maxDepth = Math.max(...allPoints.map((point) => point.depth));
409
+ const scale = Math.min(
410
+ layout.plot.width / Math.max(0.25, maxX - minX),
411
+ layout.plot.height / Math.max(0.25, maxY - minY)
412
+ );
413
+ const centerX = layout.plot.left + layout.plot.width / 2;
414
+ const centerY = layout.plot.top + layout.plot.height / 2;
415
+ const centerRawX = (minX + maxX) / 2;
416
+ const centerRawY = (minY + maxY) / 2;
417
+ const toScreenX = (x) => centerX + (x - centerRawX) * scale;
418
+ const toScreenY = (y) => centerY + (y - centerRawY) * scale;
419
+ const toClipPoint = (point) => {
420
+ const screenX = toScreenX(point.x);
421
+ const screenY = toScreenY(point.y);
422
+ return {
423
+ x: screenX / layout.width * 2 - 1,
424
+ y: 1 - screenY / layout.height * 2,
425
+ z: clamp((point.depth - minDepth) / Math.max(1e-6, maxDepth - minDepth) * 2 - 1, -1, 1)
426
+ };
427
+ };
428
+ const fillPositions = [];
429
+ const fillColors = [];
430
+ const wallPositions = [];
431
+ const wallColors = [];
432
+ for (const triangle of wallTriangles) {
433
+ const world = triangle.points.map((point) => ({ x: point.worldX, y: point.worldY, z: -point.worldZ }));
434
+ const normal = transformSurfaceNormal(surfaceNormal(world[0], world[1], world[2]), chart.view3d?.rotX ?? 25, chart.view3d?.rotY ?? 30, chart.view3d?.rAngAx !== false);
435
+ const rgba = colorToRgba(usesFlatMaterial ? triangle.color : shadeSurfaceMatteColor(triangle.color, normal), 1);
436
+ for (const point of triangle.points) {
437
+ const clip = toClipPoint(point);
438
+ wallPositions.push(clip.x, clip.y, clip.z);
439
+ wallColors.push(rgba[0], rgba[1], rgba[2], rgba[3]);
440
+ }
441
+ }
442
+ for (let index = 0; index < fillVertices.length; index += 3) {
443
+ const left = fillVertices[index];
444
+ const middle = fillVertices[index + 1];
445
+ const right = fillVertices[index + 2];
446
+ if (!left || !middle || !right) {
447
+ continue;
448
+ }
449
+ const world = [left, middle, right].map((vertex) => ({ x: vertex.point.worldX, y: vertex.point.worldY, z: -vertex.point.worldZ }));
450
+ const normal = transformSurfaceNormal(surfaceNormal(world[0], world[1], world[2]), chart.view3d?.rotX ?? 25, chart.view3d?.rotY ?? 30, chart.view3d?.rAngAx !== false);
451
+ const shaded = colorToRgba(usesFlatMaterial ? left.bandColor : shadeSurfaceMatteColor(left.bandColor, normal), 1);
452
+ [left, middle, right].forEach((vertex) => {
453
+ const clip = toClipPoint(vertex.point);
454
+ fillPositions.push(clip.x, clip.y, clip.z);
455
+ fillColors.push(shaded[0], shaded[1], shaded[2], shaded[3]);
456
+ });
457
+ }
458
+ const linePositions = [];
459
+ const lineColors = [];
460
+ meshLines.forEach((line) => {
461
+ const from = toClipPoint(line.from);
462
+ const to = toClipPoint(line.to);
463
+ const rgba = colorToRgba(line.color, 1);
464
+ linePositions.push(from.x, from.y, from.z - 1e-5, to.x, to.y, to.z - 1e-5);
465
+ lineColors.push(rgba[0], rgba[1], rgba[2], rgba[3], rgba[0], rgba[1], rgba[2], rgba[3]);
466
+ });
467
+ contourLines.forEach((line) => {
468
+ const from = toClipPoint(line.from);
469
+ const to = toClipPoint(line.to);
470
+ const rgba = colorToRgba(line.color, 1);
471
+ linePositions.push(from.x, from.y, from.z - 1e-5, to.x, to.y, to.z - 1e-5);
472
+ lineColors.push(rgba[0], rgba[1], rgba[2], rgba[3], rgba[0], rgba[1], rgba[2], rgba[3]);
473
+ });
474
+ return {
475
+ fillColors: new Float32Array(fillColors),
476
+ fillPositions: new Float32Array(fillPositions),
477
+ lineColors: new Float32Array(lineColors),
478
+ linePositions: new Float32Array(linePositions),
479
+ wallColors: new Float32Array(wallColors),
480
+ wallPositions: new Float32Array(wallPositions)
481
+ };
482
+ }
483
+ var MemoSurfaceChartComposite = N(function MemoSurfaceChartComposite2({
484
+ background,
485
+ borderColor,
486
+ chart,
487
+ fontFamily,
488
+ layout,
489
+ onDoubleClick,
490
+ onPointerDown,
491
+ overlay,
492
+ palette,
493
+ fallback
494
+ }) {
495
+ const canvasRef = A(null);
496
+ const [ready, setReady] = d(false);
497
+ const [failed, setFailed] = d(false);
498
+ const isContour = isContourSurfaceChart(chart);
499
+ h(() => {
500
+ if (isContour) {
501
+ setReady(false);
502
+ setFailed(false);
503
+ return;
504
+ }
505
+ const canvas = canvasRef.current;
506
+ if (!canvas) {
507
+ return;
508
+ }
509
+ let cancelled = false;
510
+ let reglInstance = null;
511
+ const drawSurface = () => {
512
+ try {
513
+ const scene = buildSurfaceMesh(chart, palette, layout);
514
+ if (!scene) {
515
+ if (!cancelled) {
516
+ setFailed(true);
517
+ setReady(false);
518
+ }
519
+ return;
520
+ }
521
+ const dpr = window.devicePixelRatio || 1;
522
+ canvas.width = Math.max(1, Math.round(layout.width * dpr));
523
+ canvas.height = Math.max(1, Math.round(layout.height * dpr));
524
+ reglInstance = createREGL({
525
+ attributes: {
526
+ alpha: true,
527
+ antialias: true,
528
+ depth: true,
529
+ premultipliedAlpha: true
530
+ },
531
+ canvas
532
+ });
533
+ const fillCommand = scene.fillPositions.length > 0 ? reglInstance({
534
+ attributes: {
535
+ color: scene.fillColors,
536
+ position: scene.fillPositions
537
+ },
538
+ blend: {
539
+ enable: true,
540
+ func: {
541
+ dstRGB: "one minus src alpha",
542
+ dstAlpha: "one minus src alpha",
543
+ srcRGB: "src alpha",
544
+ srcAlpha: "src alpha"
545
+ }
546
+ },
547
+ count: scene.fillPositions.length / 3,
548
+ depth: {
549
+ enable: true
550
+ },
551
+ frag: `
552
+ precision mediump float;
553
+ varying vec4 vColor;
554
+ void main() {
555
+ gl_FragColor = vColor;
556
+ }
557
+ `,
558
+ primitive: "triangles",
559
+ vert: `
560
+ precision mediump float;
561
+ attribute vec3 position;
562
+ attribute vec4 color;
563
+ varying vec4 vColor;
564
+ void main() {
565
+ gl_Position = vec4(position, 1.0);
566
+ vColor = color;
567
+ }
568
+ `
569
+ }) : null;
570
+ const wallCommand = scene.wallPositions.length > 0 ? reglInstance({
571
+ attributes: {
572
+ color: scene.wallColors,
573
+ position: scene.wallPositions
574
+ },
575
+ blend: {
576
+ enable: true,
577
+ func: {
578
+ dstRGB: "one minus src alpha",
579
+ dstAlpha: "one minus src alpha",
580
+ srcRGB: "src alpha",
581
+ srcAlpha: "src alpha"
582
+ }
583
+ },
584
+ count: scene.wallPositions.length / 3,
585
+ depth: {
586
+ enable: true,
587
+ func: "lequal"
588
+ },
589
+ frag: `
590
+ precision mediump float;
591
+ varying vec4 vColor;
592
+ void main() {
593
+ gl_FragColor = vColor;
594
+ }
595
+ `,
596
+ primitive: "triangles",
597
+ vert: `
598
+ precision mediump float;
599
+ attribute vec3 position;
600
+ attribute vec4 color;
601
+ varying vec4 vColor;
602
+ void main() {
603
+ gl_Position = vec4(position, 1.0);
604
+ vColor = color;
605
+ }
606
+ `
607
+ }) : null;
608
+ const lineCommand = scene.linePositions.length > 0 ? reglInstance({
609
+ attributes: {
610
+ color: scene.lineColors,
611
+ position: scene.linePositions
612
+ },
613
+ blend: {
614
+ enable: true,
615
+ func: {
616
+ dstRGB: "one minus src alpha",
617
+ dstAlpha: "one minus src alpha",
618
+ srcRGB: "src alpha",
619
+ srcAlpha: "src alpha"
620
+ }
621
+ },
622
+ count: scene.linePositions.length / 3,
623
+ depth: {
624
+ enable: true,
625
+ func: "lequal"
626
+ },
627
+ frag: `
628
+ precision mediump float;
629
+ varying vec4 vColor;
630
+ void main() {
631
+ gl_FragColor = vColor;
632
+ }
633
+ `,
634
+ lineWidth: 1,
635
+ primitive: "lines",
636
+ vert: `
637
+ precision mediump float;
638
+ attribute vec3 position;
639
+ attribute vec4 color;
640
+ varying vec4 vColor;
641
+ void main() {
642
+ gl_Position = vec4(position, 1.0);
643
+ vColor = color;
644
+ }
645
+ `
646
+ }) : null;
647
+ reglInstance.clear({ color: [0, 0, 0, 0], depth: 1 });
648
+ wallCommand?.();
649
+ fillCommand?.();
650
+ lineCommand?.();
651
+ if (!cancelled) {
652
+ setReady(true);
653
+ setFailed(false);
654
+ }
655
+ } catch {
656
+ if (!cancelled) {
657
+ setReady(false);
658
+ setFailed(true);
659
+ }
660
+ }
661
+ };
662
+ setReady(false);
663
+ setFailed(false);
664
+ drawSurface();
665
+ return () => {
666
+ cancelled = true;
667
+ reglInstance?.destroy();
668
+ };
669
+ }, [
670
+ chart,
671
+ isContour,
672
+ layout,
673
+ palette
674
+ ]);
675
+ const shouldRenderFallback = isContour || failed || !ready;
676
+ return /* @__PURE__ */ u(
677
+ "div",
678
+ {
679
+ "aria-label": chart.title ?? chart.name ?? "Chart",
680
+ role: "img",
681
+ style: {
682
+ background,
683
+ border: borderColor.trim().toLowerCase() === "transparent" ? "none" : `1px solid ${borderColor}`,
684
+ boxSizing: "border-box",
685
+ fontFamily,
686
+ height: "100%",
687
+ overflow: "hidden",
688
+ pointerEvents: "auto",
689
+ position: "relative",
690
+ width: "100%"
691
+ },
692
+ children: [
693
+ /* @__PURE__ */ u(
694
+ "canvas",
695
+ {
696
+ ref: canvasRef,
697
+ style: {
698
+ display: shouldRenderFallback ? "none" : "block",
699
+ height: "100%",
700
+ inset: 0,
701
+ position: "absolute",
702
+ width: "100%"
703
+ }
704
+ }
705
+ ),
706
+ /* @__PURE__ */ u(
707
+ "svg",
708
+ {
709
+ onDoubleClick,
710
+ onPointerDown,
711
+ style: { display: "block", height: "100%", inset: 0, position: "absolute", width: "100%" },
712
+ viewBox: `0 0 ${layout.width} ${layout.height}`,
713
+ children: [
714
+ shouldRenderFallback ? fallback : null,
715
+ overlay
716
+ ]
717
+ }
718
+ )
719
+ ]
720
+ }
721
+ );
722
+ }, (prev, next) => prev.chart === next.chart && prev.palette === next.palette && prev.background === next.background && prev.borderColor === next.borderColor && prev.fontFamily === next.fontFamily && prev.onDoubleClick === next.onDoubleClick && prev.onPointerDown === next.onPointerDown && prev.layout.width === next.layout.width && prev.layout.height === next.layout.height && prev.layout.plot.left === next.layout.plot.left && prev.layout.plot.top === next.layout.plot.top && prev.layout.plot.width === next.layout.plot.width && prev.layout.plot.height === next.layout.plot.height && prev.overlay === next.overlay && prev.fallback === next.fallback);
723
+ export {
724
+ MemoSurfaceChartComposite
725
+ };
726
+ //# sourceMappingURL=surface-regl-TJUWTLAZ.js.map