drizzle-cube 0.1.44 → 0.1.46

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.
@@ -1,2415 +0,0 @@
1
- import { jsx as i, jsxs as w, Fragment as $e } from "react/jsx-runtime";
2
- import { useState as H } from "react";
3
- import { ResponsiveContainer as _e, Tooltip as yt, ComposedChart as st, CartesianGrid as ye, XAxis as ge, YAxis as pe, Legend as K, Bar as gt, Cell as Le, Line as C, LineChart as pt, Area as vt, PieChart as bt, Pie as Nt, ScatterChart as wt, Scatter as Oe, RadarChart as At, PolarGrid as kt, PolarAngleAxis as St, PolarRadiusAxis as Mt, Radar as $t, RadialBarChart as Lt, RadialBar as Tt, Treemap as Ft } from "recharts";
4
- import { u as B } from "./providers-aaWIe5KD.js";
5
- function V({ children: e, height: t = "100%" }) {
6
- try {
7
- if (t === "100%")
8
- return /* @__PURE__ */ i("div", { className: "w-full h-full flex-1 flex flex-col relative", style: { minHeight: "250px", overflow: "hidden" }, children: /* @__PURE__ */ i(_e, { width: "100%", height: "100%", debounce: 50, style: { marginTop: "16px" }, children: e }) });
9
- const n = {
10
- height: typeof t == "number" ? `${t}px` : t,
11
- width: "100%",
12
- minHeight: "200px"
13
- };
14
- return /* @__PURE__ */ i("div", { className: "w-full flex flex-col relative", style: { ...n, overflow: "hidden" }, children: /* @__PURE__ */ i(_e, { width: "100%", height: "100%", debounce: 50, style: { marginTop: "16px" }, children: e }) });
15
- } catch (n) {
16
- return /* @__PURE__ */ w(
17
- "div",
18
- {
19
- className: "flex flex-col items-center justify-center w-full h-full p-4 text-center border border-dashed rounded-lg",
20
- style: { height: t, borderColor: "var(--dc-border)", backgroundColor: "var(--dc-surface)" },
21
- children: [
22
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1 text-dc-text-muted", children: "Unable to display chart" }),
23
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: n instanceof Error ? n.message : "Failed to create responsive container" })
24
- ]
25
- }
26
- );
27
- }
28
- }
29
- function G({ formatter: e, labelFormatter: t }) {
30
- return /* @__PURE__ */ i(
31
- yt,
32
- {
33
- formatter: e,
34
- labelFormatter: t,
35
- contentStyle: {
36
- backgroundColor: "white",
37
- border: "1px solid #e5e7eb",
38
- borderRadius: "0.5rem",
39
- fontSize: "0.875rem",
40
- color: "#1f2937",
41
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
42
- padding: "8px 12px"
43
- }
44
- }
45
- );
46
- }
47
- const T = [
48
- "#3b82f6",
49
- // blue
50
- "#10b981",
51
- // green
52
- "#f59e0b",
53
- // yellow
54
- "#ef4444",
55
- // red
56
- "#8b5cf6",
57
- // purple
58
- "#f97316",
59
- // orange
60
- "#06b6d4",
61
- // cyan
62
- "#84cc16"
63
- // lime
64
- ], ie = [
65
- "#440154",
66
- // dark purple
67
- "#414487",
68
- // purple-blue
69
- "#2a788e",
70
- // teal
71
- "#22a884",
72
- // green-teal
73
- "#7ad151",
74
- // green
75
- "#fde725"
76
- // yellow
77
- ], He = "#10b981", jt = "#ef4444", ve = {
78
- top: 5,
79
- right: 30,
80
- left: 20,
81
- bottom: 5
82
- };
83
- function we(e, t) {
84
- return t[e] || e;
85
- }
86
- function R(e, t) {
87
- if (!e) return String(e || "Unknown");
88
- const n = String(e);
89
- if (n.match(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}/)) {
90
- let r = n;
91
- n.includes(" ") && (r = n.replace(" ", "T").replace("+00", "Z").replace(/\+\d{2}:\d{2}$/, "Z")), !r.endsWith("Z") && !r.includes("+") && (r = r + "Z");
92
- const s = new Date(r);
93
- if (isNaN(s.getTime()))
94
- return n;
95
- const l = s.getUTCFullYear(), a = String(s.getUTCMonth() + 1).padStart(2, "0"), c = String(s.getUTCDate()).padStart(2, "0"), d = s.getUTCHours(), o = s.getUTCMinutes();
96
- if (t)
97
- switch (t.toLowerCase()) {
98
- case "year":
99
- return `${l}`;
100
- case "quarter":
101
- const m = Math.floor(s.getUTCMonth() / 3) + 1;
102
- return `${l}-Q${m}`;
103
- case "month":
104
- return `${l}-${a}`;
105
- case "week":
106
- return `${l}-${a}-${c}`;
107
- case "day":
108
- return `${l}-${a}-${c}`;
109
- case "hour":
110
- return `${l}-${a}-${c} ${String(d).padStart(2, "0")}:00`;
111
- case "minute":
112
- return `${l}-${a}-${c} ${String(d).padStart(2, "0")}:${String(o).padStart(2, "0")}`;
113
- }
114
- const f = s.getUTCSeconds(), u = s.getUTCMilliseconds();
115
- if (c === "01" && d === 0 && o === 0 && f === 0 && u === 0) {
116
- if (a === "01" || a === "04" || a === "07" || a === "10") {
117
- const m = Math.floor(s.getUTCMonth() / 3) + 1;
118
- return `${l}-Q${m}`;
119
- }
120
- return `${l}-${a}`;
121
- }
122
- return d === 0 && o === 0 && f === 0 && u === 0 ? `${l}-${a}-${c}` : o === 0 && f === 0 && u === 0 ? `${l}-${a}-${c} ${String(d).padStart(2, "0")}:00` : `${l}-${a}-${c} ${String(d).padStart(2, "0")}:${String(o).padStart(2, "0")}`;
123
- }
124
- return n;
125
- }
126
- function O(e, t) {
127
- try {
128
- if (e?.timeDimensions) {
129
- const r = e.timeDimensions.find((s) => t === s.dimension || t.startsWith(s.dimension.replace(".", "_")) || t === `${s.dimension}_${s.granularity}`);
130
- if (r?.granularity)
131
- return r.granularity;
132
- }
133
- const n = t.match(/_([a-z]+)$/);
134
- if (n) {
135
- const r = n[1];
136
- if (["year", "quarter", "month", "week", "day", "hour", "minute", "second"].includes(r))
137
- return r;
138
- }
139
- return;
140
- } catch {
141
- return;
142
- }
143
- }
144
- function zt(e, t, n, r, s = {}) {
145
- if (!e || e.length === 0) return [];
146
- const l = O(r, t);
147
- return e.map((a) => {
148
- const c = {
149
- name: R(a[t], l) || a[t] || "Unknown"
150
- };
151
- return n.forEach((d) => {
152
- const o = we(d, s);
153
- c[o] = typeof a[d] == "string" ? parseFloat(a[d]) : a[d] || 0;
154
- }), c;
155
- });
156
- }
157
- function ee(e, t, n, r, s, l = {}) {
158
- if (!e || e.length === 0)
159
- return { data: [], seriesKeys: [], hasDimensions: !1 };
160
- const a = r || {}, c = [
161
- ...a.dimensions || [],
162
- ...a.timeDimensions?.map((v) => v.dimension) || []
163
- ], d = a.measures || [], o = n.filter((v) => d.includes(v)), f = (s || []).filter((v) => c.includes(v));
164
- if (f.length > 0) {
165
- const v = {};
166
- e.forEach((x) => {
167
- const k = O(r, t), $ = R(x[t], k) || x[t] || "Unknown";
168
- v[$] || (v[$] = { name: String($) }), o.forEach((h) => {
169
- const N = we(h, l);
170
- v[$][N] = (v[$][N] || 0) + (typeof x[h] == "string" ? parseFloat(x[h]) : x[h] || 0);
171
- }), f.forEach((h) => {
172
- const N = x[h];
173
- if (N != null) {
174
- const y = String(N), g = o[0] || d.find(
175
- (b) => b.includes("totalCost") || b.includes("count") || b.includes("sum")
176
- ) || d[0];
177
- if (g) {
178
- const b = typeof x[g] == "string" ? parseFloat(x[g]) : x[g] || 0;
179
- v[$][y] = (v[$][y] || 0) + b;
180
- }
181
- }
182
- });
183
- });
184
- const p = Object.values(v), A = Array.from(new Set(
185
- e.flatMap(
186
- (x) => f.map((k) => {
187
- const $ = x[k];
188
- return $ != null ? String($) : null;
189
- }).filter((k) => k !== null)
190
- )
191
- ));
192
- return {
193
- data: p,
194
- seriesKeys: A,
195
- hasDimensions: !0
196
- };
197
- }
198
- const u = zt(e, t, n, r, l), m = n.map((v) => we(v, l));
199
- return {
200
- data: u,
201
- seriesKeys: m,
202
- hasDimensions: !1
203
- };
204
- }
205
- function Te(e) {
206
- if (!e || typeof e != "string")
207
- return [];
208
- const t = e.trim();
209
- if (!t)
210
- return [];
211
- try {
212
- const n = t.split(",").map((r) => r.trim()).filter((r) => r !== "").map((r) => {
213
- const s = parseFloat(r);
214
- if (isNaN(s))
215
- throw new Error(`Invalid numeric value: ${r}`);
216
- return s;
217
- });
218
- return n.length > 0 ? n : [];
219
- } catch (n) {
220
- return console.warn("Failed to parse target values:", n), [];
221
- }
222
- }
223
- function Fe(e, t) {
224
- if (e.length === 0 || t <= 0)
225
- return [];
226
- if (e.length === 1)
227
- return new Array(t).fill(e[0]);
228
- const n = [], r = Math.floor(t / e.length), s = t % e.length;
229
- let l = 0;
230
- for (let a = 0; a < e.length; a++) {
231
- const c = r + (a < s ? 1 : 0);
232
- for (let d = 0; d < c; d++)
233
- n[l++] = e[a];
234
- }
235
- return n;
236
- }
237
- function Cn(e, t) {
238
- return t === 0 ? e === 0 ? 0 : e > 0 ? 100 : -100 : (e - t) / t * 100;
239
- }
240
- function qn(e, t = 1) {
241
- return `${e >= 0 ? "+" : ""}${e.toFixed(t)}%`;
242
- }
243
- function Kn({
244
- data: e,
245
- chartConfig: t,
246
- displayConfig: n = {},
247
- queryObject: r,
248
- height: s = "100%",
249
- colorPalette: l
250
- }) {
251
- const [a, c] = H(null), { labelMap: d, getFieldLabel: o } = B();
252
- try {
253
- const f = {
254
- showLegend: n?.showLegend ?? !0,
255
- showGrid: n?.showGrid ?? !0,
256
- showTooltip: n?.showTooltip ?? !0,
257
- stacked: n?.stacked ?? !1
258
- };
259
- if (!e || e.length === 0)
260
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
261
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
262
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in bar chart" })
263
- ] }) });
264
- let u, m, v = [];
265
- if (t?.xAxis && t?.yAxis)
266
- u = t.xAxis[0], m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], v = t.series || [];
267
- else if (t?.x && t?.y)
268
- u = t.x, m = Array.isArray(t.y) ? t.y : [t.y];
269
- else
270
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
271
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
272
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
273
- ] }) });
274
- if (!u || !m || m.length === 0)
275
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
276
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
277
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
278
- ] }) });
279
- const { data: p, seriesKeys: A } = ee(
280
- e,
281
- u,
282
- m,
283
- r,
284
- v,
285
- d
286
- ), x = f.stacked === !0, k = A.length === 1 && p.some((b) => {
287
- const M = b[A[0]];
288
- return typeof M == "number" && M < 0;
289
- }), $ = f.showLegend, h = {
290
- ...ve,
291
- left: 40
292
- // Increased from 20 to 40 for Y-axis label space
293
- }, N = Te(n?.target || ""), y = Fe(N, p.length);
294
- let g = p;
295
- return y.length > 0 && (g = p.map((b, M) => ({
296
- ...b,
297
- __target: y[M] || null
298
- }))), !p || p.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
299
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
300
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for bar chart after transformation" })
301
- ] }) }) : /* @__PURE__ */ i(V, { height: s, children: /* @__PURE__ */ w(st, { data: g, margin: h, children: [
302
- f.showGrid && /* @__PURE__ */ i(ye, { strokeDasharray: "3 3" }),
303
- /* @__PURE__ */ i(
304
- ge,
305
- {
306
- dataKey: "name",
307
- tick: { fontSize: 12 },
308
- angle: -45,
309
- textAnchor: "end",
310
- height: 60
311
- }
312
- ),
313
- /* @__PURE__ */ i(
314
- pe,
315
- {
316
- tick: { fontSize: 12 },
317
- label: { value: o(m[0]), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
318
- }
319
- ),
320
- f.showTooltip && /* @__PURE__ */ i(
321
- G,
322
- {
323
- formatter: (b, M) => M === "Target" ? [`${b}`, "Target Value"] : [b, M]
324
- }
325
- ),
326
- $ && /* @__PURE__ */ i(
327
- K,
328
- {
329
- wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
330
- iconType: "rect",
331
- iconSize: 8,
332
- layout: "horizontal",
333
- align: "center",
334
- verticalAlign: "bottom",
335
- onMouseEnter: (b) => c(String(b.dataKey || "")),
336
- onMouseLeave: () => c(null)
337
- }
338
- ),
339
- A.map((b, M) => /* @__PURE__ */ i(
340
- gt,
341
- {
342
- dataKey: b,
343
- stackId: x ? "stack" : void 0,
344
- fill: k ? He : l?.colors && l.colors[M % l.colors.length] || T[M % T.length],
345
- fillOpacity: a ? a === b ? 1 : 0.3 : 1,
346
- children: k && p.map((L, F) => {
347
- const S = L[b], E = typeof S == "number" && S < 0 ? jt : He;
348
- return /* @__PURE__ */ i(
349
- Le,
350
- {
351
- fill: E,
352
- fillOpacity: a ? a === b ? 1 : 0.3 : 1
353
- },
354
- `cell-${F}`
355
- );
356
- })
357
- },
358
- b
359
- )),
360
- y.length > 0 && /* @__PURE__ */ w($e, { children: [
361
- /* @__PURE__ */ i(
362
- C,
363
- {
364
- type: "monotone",
365
- dataKey: "__target",
366
- stroke: "#ffffff",
367
- strokeWidth: 2,
368
- dot: !1,
369
- activeDot: !1,
370
- connectNulls: !1
371
- }
372
- ),
373
- /* @__PURE__ */ i(
374
- C,
375
- {
376
- type: "monotone",
377
- dataKey: "__target",
378
- name: "Target",
379
- stroke: "#8B5CF6",
380
- strokeWidth: 2,
381
- strokeDasharray: "2 3",
382
- dot: !1,
383
- activeDot: !1,
384
- connectNulls: !1
385
- }
386
- )
387
- ] })
388
- ] }) });
389
- } catch (f) {
390
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
391
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Bar Chart Error" }),
392
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: f instanceof Error ? f.message : "Unknown rendering error" }),
393
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
394
- ] }) });
395
- }
396
- }
397
- function Bn({
398
- data: e,
399
- chartConfig: t,
400
- displayConfig: n = {},
401
- queryObject: r,
402
- height: s = "100%",
403
- colorPalette: l
404
- }) {
405
- const [a, c] = H(null), { labelMap: d, getFieldLabel: o } = B();
406
- try {
407
- const f = {
408
- showLegend: n?.showLegend ?? !0,
409
- showGrid: n?.showGrid ?? !0,
410
- showTooltip: n?.showTooltip ?? !0
411
- };
412
- if (!e || e.length === 0)
413
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
414
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
415
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in line chart" })
416
- ] }) });
417
- let u, m, v = [];
418
- if (t?.xAxis && t?.yAxis)
419
- u = t.xAxis[0], m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], v = t.series || [];
420
- else if (t?.x && t?.y)
421
- u = t.x, m = Array.isArray(t.y) ? t.y : [t.y];
422
- else
423
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
424
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
425
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
426
- ] }) });
427
- if (!u || !m || m.length === 0)
428
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
429
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
430
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
431
- ] }) });
432
- const { data: p, seriesKeys: A } = ee(
433
- e,
434
- u,
435
- m,
436
- r,
437
- v,
438
- d
439
- ), x = f.showLegend, k = {
440
- ...ve,
441
- left: 40
442
- // Increased from 20 to 40 for Y-axis label space
443
- }, $ = Te(n?.target || ""), h = Fe($, p.length);
444
- let N = p;
445
- return h.length > 0 && (N = p.map((y, g) => ({
446
- ...y,
447
- __target: h[g] || null
448
- }))), !p || p.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
449
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
450
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for line chart after transformation" })
451
- ] }) }) : /* @__PURE__ */ i(V, { height: s, children: /* @__PURE__ */ w(pt, { data: N, margin: k, children: [
452
- f.showGrid && /* @__PURE__ */ i(ye, { strokeDasharray: "3 3" }),
453
- /* @__PURE__ */ i(
454
- ge,
455
- {
456
- dataKey: "name",
457
- tick: { fontSize: 12 },
458
- angle: -45,
459
- textAnchor: "end",
460
- height: 60
461
- }
462
- ),
463
- /* @__PURE__ */ i(
464
- pe,
465
- {
466
- tick: { fontSize: 12 },
467
- label: { value: o(m[0]), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
468
- }
469
- ),
470
- f.showTooltip && /* @__PURE__ */ i(
471
- G,
472
- {
473
- formatter: (y, g) => g === "Target" ? [`${y}`, "Target Value"] : [y, g]
474
- }
475
- ),
476
- x && /* @__PURE__ */ i(
477
- K,
478
- {
479
- wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
480
- iconType: "line",
481
- iconSize: 8,
482
- layout: "horizontal",
483
- align: "center",
484
- verticalAlign: "bottom",
485
- onMouseEnter: (y) => c(String(y.dataKey || "")),
486
- onMouseLeave: () => c(null)
487
- }
488
- ),
489
- A.map((y, g) => /* @__PURE__ */ i(
490
- C,
491
- {
492
- type: "monotone",
493
- dataKey: y,
494
- stroke: l?.colors && l.colors[g % l.colors.length] || T[g % T.length],
495
- strokeWidth: 2,
496
- dot: { r: 3 },
497
- activeDot: { r: 5 },
498
- strokeOpacity: a ? a === y ? 1 : 0.3 : 1
499
- },
500
- y
501
- )),
502
- h.length > 0 && /* @__PURE__ */ w($e, { children: [
503
- /* @__PURE__ */ i(
504
- C,
505
- {
506
- type: "monotone",
507
- dataKey: "__target",
508
- stroke: "#ffffff",
509
- strokeWidth: 2,
510
- dot: !1,
511
- activeDot: !1,
512
- connectNulls: !1
513
- }
514
- ),
515
- /* @__PURE__ */ i(
516
- C,
517
- {
518
- type: "monotone",
519
- dataKey: "__target",
520
- name: "Target",
521
- stroke: "#8B5CF6",
522
- strokeWidth: 2,
523
- strokeDasharray: "2 3",
524
- dot: !1,
525
- activeDot: !1,
526
- connectNulls: !1
527
- }
528
- )
529
- ] })
530
- ] }) });
531
- } catch (f) {
532
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
533
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Line Chart Error" }),
534
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: f instanceof Error ? f.message : "Unknown rendering error" }),
535
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
536
- ] }) });
537
- }
538
- }
539
- function Wn({
540
- data: e,
541
- chartConfig: t,
542
- displayConfig: n = {},
543
- queryObject: r,
544
- height: s = "100%",
545
- colorPalette: l
546
- }) {
547
- const [a, c] = H(null), { labelMap: d, getFieldLabel: o } = B();
548
- try {
549
- const f = {
550
- showLegend: n?.showLegend ?? !0,
551
- showGrid: n?.showGrid ?? !0,
552
- showTooltip: n?.showTooltip ?? !0,
553
- stacked: n?.stacked ?? !1
554
- };
555
- if (!e || e.length === 0)
556
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
557
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
558
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in area chart" })
559
- ] }) });
560
- let u, m, v = [];
561
- if (t?.xAxis && t?.yAxis)
562
- u = t.xAxis[0], m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], v = t.series || [];
563
- else if (t?.x && t?.y)
564
- u = t.x, m = Array.isArray(t.y) ? t.y : [t.y];
565
- else
566
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
567
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
568
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
569
- ] }) });
570
- if (!u || !m || m.length === 0)
571
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
572
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
573
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
574
- ] }) });
575
- const { data: p, seriesKeys: A } = ee(
576
- e,
577
- u,
578
- m,
579
- r,
580
- v,
581
- d
582
- ), x = f.showLegend, k = {
583
- ...ve,
584
- left: 40
585
- // Increased from 20 to 40 for Y-axis label space
586
- }, $ = Te(n?.target || ""), h = Fe($, p.length);
587
- let N = p;
588
- return h.length > 0 && (N = p.map((y, g) => ({
589
- ...y,
590
- __target: h[g] || null
591
- }))), !p || p.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
592
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
593
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for area chart after transformation" })
594
- ] }) }) : /* @__PURE__ */ i(V, { height: s, children: /* @__PURE__ */ w(st, { data: N, margin: k, children: [
595
- f.showGrid && /* @__PURE__ */ i(ye, { strokeDasharray: "3 3" }),
596
- /* @__PURE__ */ i(
597
- ge,
598
- {
599
- dataKey: "name",
600
- tick: { fontSize: 12 },
601
- angle: -45,
602
- textAnchor: "end",
603
- height: 60
604
- }
605
- ),
606
- /* @__PURE__ */ i(
607
- pe,
608
- {
609
- tick: { fontSize: 12 },
610
- label: { value: o(m[0]), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
611
- }
612
- ),
613
- f.showTooltip && /* @__PURE__ */ i(
614
- G,
615
- {
616
- formatter: (y, g) => g === "Target" ? [`${y}`, "Target Value"] : [y, g]
617
- }
618
- ),
619
- x && /* @__PURE__ */ i(
620
- K,
621
- {
622
- wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
623
- iconType: "rect",
624
- iconSize: 8,
625
- layout: "horizontal",
626
- align: "center",
627
- verticalAlign: "bottom",
628
- onMouseEnter: (y) => c(String(y.dataKey || "")),
629
- onMouseLeave: () => c(null)
630
- }
631
- ),
632
- A.map((y, g) => /* @__PURE__ */ i(
633
- vt,
634
- {
635
- type: "monotone",
636
- dataKey: y,
637
- stackId: f.stacked ? "stack" : void 0,
638
- stroke: l?.colors && l.colors[g % l.colors.length] || T[g % T.length],
639
- fill: l?.colors && l.colors[g % l.colors.length] || T[g % T.length],
640
- fillOpacity: a ? a === y ? 0.6 : 0.1 : 0.3,
641
- strokeWidth: 2,
642
- strokeOpacity: a ? a === y ? 1 : 0.3 : 1
643
- },
644
- y
645
- )),
646
- h.length > 0 && /* @__PURE__ */ w($e, { children: [
647
- /* @__PURE__ */ i(
648
- C,
649
- {
650
- type: "monotone",
651
- dataKey: "__target",
652
- stroke: "#ffffff",
653
- strokeWidth: 2,
654
- dot: !1,
655
- activeDot: !1,
656
- connectNulls: !1
657
- }
658
- ),
659
- /* @__PURE__ */ i(
660
- C,
661
- {
662
- type: "monotone",
663
- dataKey: "__target",
664
- name: "Target",
665
- stroke: "#8B5CF6",
666
- strokeWidth: 2,
667
- strokeDasharray: "2 3",
668
- dot: !1,
669
- activeDot: !1,
670
- connectNulls: !1
671
- }
672
- )
673
- ] })
674
- ] }) });
675
- } catch (f) {
676
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
677
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Area Chart Error" }),
678
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: f instanceof Error ? f.message : "Unknown rendering error" }),
679
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
680
- ] }) });
681
- }
682
- }
683
- function Yn({
684
- data: e,
685
- chartConfig: t,
686
- displayConfig: n = {},
687
- queryObject: r,
688
- height: s = "100%",
689
- colorPalette: l
690
- }) {
691
- const [a, c] = H(null), { labelMap: d } = B();
692
- try {
693
- const o = {
694
- showLegend: n?.showLegend ?? !0,
695
- showTooltip: n?.showTooltip ?? !0
696
- };
697
- if (!e || e.length === 0)
698
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
699
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
700
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in pie chart" })
701
- ] }) });
702
- let f, u, m, v = [];
703
- if (t?.xAxis && t?.yAxis)
704
- u = t.xAxis[0], m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], v = t.series || [];
705
- else if (t?.x && t?.y)
706
- u = t.x, m = Array.isArray(t.y) ? t.y : [t.y];
707
- else
708
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
709
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
710
- /* @__PURE__ */ i("div", { className: "text-xs", children: "chartConfig.x/y or chartConfig.xAxis/yAxis required for pie chart" })
711
- ] }) });
712
- if (!u || !m || m.length === 0)
713
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
714
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
715
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
716
- ] }) });
717
- if (v.length > 0) {
718
- const { data: A } = ee(
719
- e,
720
- u,
721
- m,
722
- r,
723
- v,
724
- d
725
- );
726
- if (f = [], A.length > 0) {
727
- const x = A[0];
728
- Object.keys(x).forEach((k) => {
729
- k !== "name" && typeof x[k] == "number" && f.push({
730
- name: String(k),
731
- value: x[k]
732
- });
733
- });
734
- }
735
- } else {
736
- const A = O(r, u);
737
- f = e.map((x) => {
738
- let k = R(x[u], A) || String(x[u]) || "Unknown";
739
- return typeof x[u] == "boolean" ? k = x[u] ? "Active" : "Inactive" : (k === "true" || k === "false") && (k = k === "true" ? "Active" : "Inactive"), {
740
- name: k,
741
- value: typeof x[m[0]] == "string" ? parseFloat(x[m[0]]) : x[m[0]] || 0
742
- };
743
- });
744
- }
745
- const p = f.length;
746
- return f = f.filter(
747
- (A) => A.value != null && !isNaN(A.value) && A.value !== 0 && A.value > 0
748
- ), f.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
749
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
750
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: p > 0 ? `Filtered out ${p} data points (zero or invalid values)` : "No data points to display in pie chart" })
751
- ] }) }) : /* @__PURE__ */ i(V, { height: s, children: /* @__PURE__ */ w(bt, { children: [
752
- /* @__PURE__ */ i(
753
- Nt,
754
- {
755
- data: f,
756
- cx: "50%",
757
- cy: "50%",
758
- outerRadius: "70%",
759
- dataKey: "value",
760
- label: o.showLegend ? void 0 : ({ name: A, percent: x }) => `${A} ${((x || 0) * 100).toFixed(0)}%`,
761
- children: f.map((A, x) => /* @__PURE__ */ i(
762
- Le,
763
- {
764
- fill: l?.colors && l.colors[x % l.colors.length] || T[x % T.length],
765
- fillOpacity: a ? a === f[x].name ? 1 : 0.3 : 1
766
- },
767
- `cell-${x}`
768
- ))
769
- }
770
- ),
771
- o.showTooltip && /* @__PURE__ */ i(G, {}),
772
- o.showLegend && /* @__PURE__ */ i(
773
- K,
774
- {
775
- wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
776
- iconType: "circle",
777
- iconSize: 8,
778
- layout: "horizontal",
779
- align: "center",
780
- verticalAlign: "bottom",
781
- onMouseEnter: (A) => c(String(A.value || "")),
782
- onMouseLeave: () => c(null)
783
- }
784
- )
785
- ] }) });
786
- } catch (o) {
787
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
788
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Pie Chart Error" }),
789
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: o instanceof Error ? o.message : "Unknown rendering error" }),
790
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
791
- ] }) });
792
- }
793
- }
794
- function Xn({
795
- data: e,
796
- chartConfig: t,
797
- displayConfig: n = {},
798
- queryObject: r,
799
- height: s = "100%",
800
- colorPalette: l
801
- }) {
802
- const [a, c] = H(null), { getFieldLabel: d } = B();
803
- try {
804
- const o = {
805
- showLegend: n?.showLegend ?? !0,
806
- showGrid: n?.showGrid ?? !0,
807
- showTooltip: n?.showTooltip ?? !0
808
- };
809
- if (!e || e.length === 0)
810
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
811
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
812
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in scatter chart" })
813
- ] }) });
814
- let f, u, m = [];
815
- if (t?.xAxis && t?.yAxis)
816
- f = t.xAxis[0], u = Array.isArray(t.yAxis) ? t.yAxis[0] : t.yAxis, m = t.series || [];
817
- else if (t?.x && t?.y)
818
- f = t.x, u = Array.isArray(t.y) ? t.y[0] : t.y;
819
- else
820
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
821
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
822
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
823
- ] }) });
824
- if (!f || !u)
825
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
826
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
827
- /* @__PURE__ */ i("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
828
- ] }) });
829
- let v, p = {};
830
- if (m.length > 0) {
831
- const h = m[0];
832
- e.forEach((y) => {
833
- const g = String(y[h] || "Default");
834
- p[g] || (p[g] = []);
835
- const b = O(r, f), M = R(y[f], b) || y[f], L = typeof y[u] == "string" ? parseFloat(y[u]) : y[u] || 0;
836
- p[g].push({
837
- x: typeof M == "string" ? parseFloat(M) || 0 : M,
838
- y: L,
839
- name: `${g} (${M}, ${L})`
840
- });
841
- });
842
- const N = Object.keys(p);
843
- v = p[N[0]] || [];
844
- } else {
845
- const h = O(r, f);
846
- v = e.map((N) => {
847
- const y = R(N[f], h) || N[f], g = typeof N[u] == "string" ? parseFloat(N[u]) : N[u] || 0;
848
- return {
849
- x: typeof y == "string" ? parseFloat(y) || 0 : y,
850
- y: g,
851
- name: `(${y}, ${g})`
852
- };
853
- });
854
- }
855
- if (!v || v.length === 0)
856
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
857
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
858
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for scatter chart after transformation" })
859
- ] }) });
860
- const A = Object.keys(p), x = A.length > 1, k = o.showLegend && x, $ = {
861
- ...ve,
862
- left: 40
863
- // Increased from 20 to 40 for Y-axis label space
864
- };
865
- return /* @__PURE__ */ i(V, { height: s, children: /* @__PURE__ */ w(wt, { data: v, margin: $, children: [
866
- o.showGrid && /* @__PURE__ */ i(ye, { strokeDasharray: "3 3" }),
867
- /* @__PURE__ */ i(
868
- ge,
869
- {
870
- type: "number",
871
- dataKey: "x",
872
- name: d(f),
873
- tick: { fontSize: 12 }
874
- }
875
- ),
876
- /* @__PURE__ */ i(
877
- pe,
878
- {
879
- type: "number",
880
- dataKey: "y",
881
- name: d(u),
882
- tick: { fontSize: 12 },
883
- label: { value: d(u), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
884
- }
885
- ),
886
- o.showTooltip && /* @__PURE__ */ i(G, {}),
887
- k && /* @__PURE__ */ i(
888
- K,
889
- {
890
- wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
891
- iconType: "circle",
892
- iconSize: 8,
893
- layout: "horizontal",
894
- align: "center",
895
- verticalAlign: "bottom",
896
- onMouseEnter: (h) => c(String(h.dataKey || "")),
897
- onMouseLeave: () => c(null)
898
- }
899
- ),
900
- x ? (
901
- // Multiple series
902
- A.map((h, N) => /* @__PURE__ */ i(
903
- Oe,
904
- {
905
- name: h,
906
- data: p[h],
907
- fill: l?.colors && l.colors[N % l.colors.length] || T[N % T.length],
908
- fillOpacity: a ? a === h ? 1 : 0.3 : 1
909
- },
910
- h
911
- ))
912
- ) : (
913
- // Single series
914
- /* @__PURE__ */ i(
915
- Oe,
916
- {
917
- name: "Data",
918
- data: v,
919
- fill: l?.colors && l.colors[0] || T[0]
920
- }
921
- )
922
- )
923
- ] }) });
924
- } catch (o) {
925
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
926
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Scatter Chart Error" }),
927
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: o instanceof Error ? o.message : "Unknown rendering error" }),
928
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
929
- ] }) });
930
- }
931
- }
932
- function Qn({
933
- data: e,
934
- chartConfig: t,
935
- displayConfig: n = {},
936
- queryObject: r,
937
- height: s = "100%",
938
- colorPalette: l
939
- }) {
940
- const [a, c] = H(null);
941
- try {
942
- const d = {
943
- showLegend: n?.showLegend ?? !0,
944
- showTooltip: n?.showTooltip ?? !0,
945
- showGrid: n?.showGrid ?? !0
946
- };
947
- if (!e || e.length === 0)
948
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
949
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
950
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in radar chart" })
951
- ] }) });
952
- let o, f = [];
953
- if (t?.xAxis && t?.yAxis) {
954
- const u = t.xAxis[0], m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], v = t.series || [], { data: p, seriesKeys: A } = ee(
955
- e,
956
- u,
957
- m,
958
- r,
959
- v
960
- );
961
- o = p, f = A;
962
- } else {
963
- const u = e[0], m = Object.keys(u), v = m.find(
964
- (A) => typeof u[A] == "string" || A.toLowerCase().includes("subject") || A.toLowerCase().includes("name") || A.toLowerCase().includes("category")
965
- ) || m[0], p = m.filter(
966
- (A) => typeof u[A] == "number" && A !== v
967
- );
968
- if (p.length === 0)
969
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
970
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
971
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No numeric fields found for radar chart values" })
972
- ] }) });
973
- if (v) {
974
- const A = O(r, v);
975
- o = e.map((x) => {
976
- const k = {
977
- name: R(x[v], A) || String(x[v]) || "Unknown"
978
- };
979
- return p.forEach(($) => {
980
- const h = $.split(".").pop() || $;
981
- k[h] = typeof x[$] == "string" ? parseFloat(x[$]) : x[$] || 0;
982
- }), k;
983
- }), f = p.map((x) => x.split(".").pop() || x);
984
- } else
985
- o = e.map((A) => ({
986
- name: String(A[m[0]] || "Unknown"),
987
- value: typeof A[p[0]] == "string" ? parseFloat(A[p[0]]) : A[p[0]] || 0
988
- })), f = ["value"];
989
- }
990
- return !o || o.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
991
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
992
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for radar chart after transformation" })
993
- ] }) }) : /* @__PURE__ */ i(V, { height: s, children: /* @__PURE__ */ w(At, { data: o, margin: { top: 20, right: 80, bottom: 20, left: 80 }, children: [
994
- d.showGrid && /* @__PURE__ */ i(kt, {}),
995
- /* @__PURE__ */ i(
996
- St,
997
- {
998
- dataKey: "name",
999
- tick: { fontSize: 12 },
1000
- className: "text-dc-text-muted"
1001
- }
1002
- ),
1003
- /* @__PURE__ */ i(
1004
- Mt,
1005
- {
1006
- tick: { fontSize: 10 },
1007
- className: "text-dc-text-muted"
1008
- }
1009
- ),
1010
- d.showTooltip && /* @__PURE__ */ i(G, {}),
1011
- d.showLegend && f.length > 1 && /* @__PURE__ */ i(
1012
- K,
1013
- {
1014
- wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
1015
- iconType: "rect",
1016
- iconSize: 8,
1017
- layout: "horizontal",
1018
- align: "center",
1019
- verticalAlign: "bottom",
1020
- onMouseEnter: (u) => c(String(u.dataKey || "")),
1021
- onMouseLeave: () => c(null)
1022
- }
1023
- ),
1024
- f.map((u, m) => /* @__PURE__ */ i(
1025
- $t,
1026
- {
1027
- name: u,
1028
- dataKey: u,
1029
- stroke: l?.colors && l.colors[m % l.colors.length] || T[m % T.length],
1030
- fill: l?.colors && l.colors[m % l.colors.length] || T[m % T.length],
1031
- fillOpacity: a ? a === u ? 0.6 : 0.1 : 0.3,
1032
- strokeOpacity: a ? a === u ? 1 : 0.3 : 1,
1033
- strokeWidth: 2
1034
- },
1035
- u
1036
- ))
1037
- ] }) });
1038
- } catch (d) {
1039
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
1040
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Radar Chart Error" }),
1041
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: d instanceof Error ? d.message : "Unknown rendering error" }),
1042
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
1043
- ] }) });
1044
- }
1045
- }
1046
- function Zn({
1047
- data: e,
1048
- chartConfig: t,
1049
- displayConfig: n = {},
1050
- queryObject: r,
1051
- height: s = "100%",
1052
- colorPalette: l
1053
- }) {
1054
- const [a, c] = H(null);
1055
- try {
1056
- const d = {
1057
- showLegend: n?.showLegend ?? !0,
1058
- showTooltip: n?.showTooltip ?? !0
1059
- };
1060
- if (!e || e.length === 0)
1061
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
1062
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
1063
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in radial bar chart" })
1064
- ] }) });
1065
- let o;
1066
- if (t?.xAxis && t?.yAxis) {
1067
- const f = t.xAxis[0], u = Array.isArray(t.yAxis) ? t.yAxis[0] : t.yAxis, m = O(r, f);
1068
- o = e.map((v, p) => ({
1069
- name: R(v[f], m) || String(v[f]) || "Unknown",
1070
- value: typeof v[u] == "string" ? parseFloat(v[u]) : v[u] || 0,
1071
- fill: l?.colors && l.colors[p % l.colors.length] || T[p % T.length]
1072
- }));
1073
- } else {
1074
- const f = e[0], u = Object.keys(f), m = u.find(
1075
- (p) => typeof f[p] == "string" || p.toLowerCase().includes("name") || p.toLowerCase().includes("label") || p.toLowerCase().includes("category")
1076
- ) || u[0], v = u.find(
1077
- (p) => typeof f[p] == "number" && p !== m
1078
- ) || u[1];
1079
- if (!v)
1080
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
1081
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
1082
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No numeric field found for radial bar chart values" })
1083
- ] }) });
1084
- o = e.map((p, A) => {
1085
- let x = p[m];
1086
- return typeof x == "boolean" ? x = x ? "Active" : "Inactive" : x === "true" || x === "false" ? x = x === "true" ? "Active" : "Inactive" : x = String(x), {
1087
- name: x,
1088
- value: typeof p[v] == "string" ? parseFloat(p[v]) : p[v] || 0,
1089
- fill: l?.colors && l.colors[A % l.colors.length] || T[A % T.length]
1090
- };
1091
- });
1092
- }
1093
- return o = o.filter((f) => f.value != null && f.value !== 0), o.length === 0 ? /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
1094
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
1095
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for radial bar chart after transformation" })
1096
- ] }) }) : /* @__PURE__ */ i(V, { height: s, children: /* @__PURE__ */ w(
1097
- Lt,
1098
- {
1099
- data: o,
1100
- innerRadius: "10%",
1101
- outerRadius: "80%",
1102
- margin: { top: 20, right: 30, bottom: 20, left: 30 },
1103
- children: [
1104
- d.showTooltip && /* @__PURE__ */ i(G, {}),
1105
- d.showLegend && /* @__PURE__ */ i(
1106
- K,
1107
- {
1108
- wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
1109
- iconType: "circle",
1110
- iconSize: 8,
1111
- layout: "horizontal",
1112
- align: "center",
1113
- verticalAlign: "bottom",
1114
- onMouseEnter: (f) => c(String(f.value || "")),
1115
- onMouseLeave: () => c(null)
1116
- }
1117
- ),
1118
- /* @__PURE__ */ i(
1119
- Tt,
1120
- {
1121
- dataKey: "value",
1122
- cornerRadius: 4,
1123
- label: { position: "insideStart", fill: "#fff", fontSize: 12 },
1124
- children: o.map((f, u) => /* @__PURE__ */ i(
1125
- Le,
1126
- {
1127
- fill: f.fill,
1128
- fillOpacity: a ? a === f.name ? 1 : 0.3 : 1
1129
- },
1130
- `cell-${u}`
1131
- ))
1132
- }
1133
- )
1134
- ]
1135
- }
1136
- ) });
1137
- } catch (d) {
1138
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
1139
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Radial Bar Chart Error" }),
1140
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: d instanceof Error ? d.message : "Unknown rendering error" }),
1141
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
1142
- ] }) });
1143
- }
1144
- }
1145
- function ce(e, t) {
1146
- return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
1147
- }
1148
- function Et(e, t) {
1149
- return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
1150
- }
1151
- function it(e) {
1152
- let t, n, r;
1153
- e.length !== 2 ? (t = ce, n = (c, d) => ce(e(c), d), r = (c, d) => e(c) - d) : (t = e === ce || e === Et ? e : Dt, n = e, r = e);
1154
- function s(c, d, o = 0, f = c.length) {
1155
- if (o < f) {
1156
- if (t(d, d) !== 0) return f;
1157
- do {
1158
- const u = o + f >>> 1;
1159
- n(c[u], d) < 0 ? o = u + 1 : f = u;
1160
- } while (o < f);
1161
- }
1162
- return o;
1163
- }
1164
- function l(c, d, o = 0, f = c.length) {
1165
- if (o < f) {
1166
- if (t(d, d) !== 0) return f;
1167
- do {
1168
- const u = o + f >>> 1;
1169
- n(c[u], d) <= 0 ? o = u + 1 : f = u;
1170
- } while (o < f);
1171
- }
1172
- return o;
1173
- }
1174
- function a(c, d, o = 0, f = c.length) {
1175
- const u = s(c, d, o, f - 1);
1176
- return u > o && r(c[u - 1], d) > -r(c[u], d) ? u - 1 : u;
1177
- }
1178
- return { left: s, center: a, right: l };
1179
- }
1180
- function Dt() {
1181
- return 0;
1182
- }
1183
- function Rt(e) {
1184
- return e === null ? NaN : +e;
1185
- }
1186
- const It = it(ce), at = It.right;
1187
- it(Rt).center;
1188
- class Ve extends Map {
1189
- constructor(t, n = Ht) {
1190
- if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null) for (const [r, s] of t) this.set(r, s);
1191
- }
1192
- get(t) {
1193
- return super.get(Ge(this, t));
1194
- }
1195
- has(t) {
1196
- return super.has(Ge(this, t));
1197
- }
1198
- set(t, n) {
1199
- return super.set(_t(this, t), n);
1200
- }
1201
- delete(t) {
1202
- return super.delete(Ot(this, t));
1203
- }
1204
- }
1205
- function Ge({ _intern: e, _key: t }, n) {
1206
- const r = t(n);
1207
- return e.has(r) ? e.get(r) : n;
1208
- }
1209
- function _t({ _intern: e, _key: t }, n) {
1210
- const r = t(n);
1211
- return e.has(r) ? e.get(r) : (e.set(r, n), n);
1212
- }
1213
- function Ot({ _intern: e, _key: t }, n) {
1214
- const r = t(n);
1215
- return e.has(r) && (n = e.get(r), e.delete(r)), n;
1216
- }
1217
- function Ht(e) {
1218
- return e !== null && typeof e == "object" ? e.valueOf() : e;
1219
- }
1220
- const Vt = Math.sqrt(50), Gt = Math.sqrt(10), Ut = Math.sqrt(2);
1221
- function de(e, t, n) {
1222
- const r = (t - e) / Math.max(0, n), s = Math.floor(Math.log10(r)), l = r / Math.pow(10, s), a = l >= Vt ? 10 : l >= Gt ? 5 : l >= Ut ? 2 : 1;
1223
- let c, d, o;
1224
- return s < 0 ? (o = Math.pow(10, -s) / a, c = Math.round(e * o), d = Math.round(t * o), c / o < e && ++c, d / o > t && --d, o = -o) : (o = Math.pow(10, s) * a, c = Math.round(e / o), d = Math.round(t / o), c * o < e && ++c, d * o > t && --d), d < c && 0.5 <= n && n < 2 ? de(e, t, n * 2) : [c, d, o];
1225
- }
1226
- function Ct(e, t, n) {
1227
- if (t = +t, e = +e, n = +n, !(n > 0)) return [];
1228
- if (e === t) return [e];
1229
- const r = t < e, [s, l, a] = r ? de(t, e, n) : de(e, t, n);
1230
- if (!(l >= s)) return [];
1231
- const c = l - s + 1, d = new Array(c);
1232
- if (r)
1233
- if (a < 0) for (let o = 0; o < c; ++o) d[o] = (l - o) / -a;
1234
- else for (let o = 0; o < c; ++o) d[o] = (l - o) * a;
1235
- else if (a < 0) for (let o = 0; o < c; ++o) d[o] = (s + o) / -a;
1236
- else for (let o = 0; o < c; ++o) d[o] = (s + o) * a;
1237
- return d;
1238
- }
1239
- function Ae(e, t, n) {
1240
- return t = +t, e = +e, n = +n, de(e, t, n)[2];
1241
- }
1242
- function qt(e, t, n) {
1243
- t = +t, e = +e, n = +n;
1244
- const r = t < e, s = r ? Ae(t, e, n) : Ae(e, t, n);
1245
- return (r ? -1 : 1) * (s < 0 ? 1 / -s : s);
1246
- }
1247
- function je(e, t, n) {
1248
- e.prototype = t.prototype = n, n.constructor = e;
1249
- }
1250
- function lt(e, t) {
1251
- var n = Object.create(e.prototype);
1252
- for (var r in t) n[r] = t[r];
1253
- return n;
1254
- }
1255
- function te() {
1256
- }
1257
- var Z = 0.7, fe = 1 / Z, X = "\\s*([+-]?\\d+)\\s*", J = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", I = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", Kt = /^#([0-9a-f]{3,8})$/, Bt = new RegExp(`^rgb\\(${X},${X},${X}\\)$`), Wt = new RegExp(`^rgb\\(${I},${I},${I}\\)$`), Yt = new RegExp(`^rgba\\(${X},${X},${X},${J}\\)$`), Xt = new RegExp(`^rgba\\(${I},${I},${I},${J}\\)$`), Qt = new RegExp(`^hsl\\(${J},${I},${I}\\)$`), Zt = new RegExp(`^hsla\\(${J},${I},${I},${J}\\)$`), Ue = {
1258
- aliceblue: 15792383,
1259
- antiquewhite: 16444375,
1260
- aqua: 65535,
1261
- aquamarine: 8388564,
1262
- azure: 15794175,
1263
- beige: 16119260,
1264
- bisque: 16770244,
1265
- black: 0,
1266
- blanchedalmond: 16772045,
1267
- blue: 255,
1268
- blueviolet: 9055202,
1269
- brown: 10824234,
1270
- burlywood: 14596231,
1271
- cadetblue: 6266528,
1272
- chartreuse: 8388352,
1273
- chocolate: 13789470,
1274
- coral: 16744272,
1275
- cornflowerblue: 6591981,
1276
- cornsilk: 16775388,
1277
- crimson: 14423100,
1278
- cyan: 65535,
1279
- darkblue: 139,
1280
- darkcyan: 35723,
1281
- darkgoldenrod: 12092939,
1282
- darkgray: 11119017,
1283
- darkgreen: 25600,
1284
- darkgrey: 11119017,
1285
- darkkhaki: 12433259,
1286
- darkmagenta: 9109643,
1287
- darkolivegreen: 5597999,
1288
- darkorange: 16747520,
1289
- darkorchid: 10040012,
1290
- darkred: 9109504,
1291
- darksalmon: 15308410,
1292
- darkseagreen: 9419919,
1293
- darkslateblue: 4734347,
1294
- darkslategray: 3100495,
1295
- darkslategrey: 3100495,
1296
- darkturquoise: 52945,
1297
- darkviolet: 9699539,
1298
- deeppink: 16716947,
1299
- deepskyblue: 49151,
1300
- dimgray: 6908265,
1301
- dimgrey: 6908265,
1302
- dodgerblue: 2003199,
1303
- firebrick: 11674146,
1304
- floralwhite: 16775920,
1305
- forestgreen: 2263842,
1306
- fuchsia: 16711935,
1307
- gainsboro: 14474460,
1308
- ghostwhite: 16316671,
1309
- gold: 16766720,
1310
- goldenrod: 14329120,
1311
- gray: 8421504,
1312
- green: 32768,
1313
- greenyellow: 11403055,
1314
- grey: 8421504,
1315
- honeydew: 15794160,
1316
- hotpink: 16738740,
1317
- indianred: 13458524,
1318
- indigo: 4915330,
1319
- ivory: 16777200,
1320
- khaki: 15787660,
1321
- lavender: 15132410,
1322
- lavenderblush: 16773365,
1323
- lawngreen: 8190976,
1324
- lemonchiffon: 16775885,
1325
- lightblue: 11393254,
1326
- lightcoral: 15761536,
1327
- lightcyan: 14745599,
1328
- lightgoldenrodyellow: 16448210,
1329
- lightgray: 13882323,
1330
- lightgreen: 9498256,
1331
- lightgrey: 13882323,
1332
- lightpink: 16758465,
1333
- lightsalmon: 16752762,
1334
- lightseagreen: 2142890,
1335
- lightskyblue: 8900346,
1336
- lightslategray: 7833753,
1337
- lightslategrey: 7833753,
1338
- lightsteelblue: 11584734,
1339
- lightyellow: 16777184,
1340
- lime: 65280,
1341
- limegreen: 3329330,
1342
- linen: 16445670,
1343
- magenta: 16711935,
1344
- maroon: 8388608,
1345
- mediumaquamarine: 6737322,
1346
- mediumblue: 205,
1347
- mediumorchid: 12211667,
1348
- mediumpurple: 9662683,
1349
- mediumseagreen: 3978097,
1350
- mediumslateblue: 8087790,
1351
- mediumspringgreen: 64154,
1352
- mediumturquoise: 4772300,
1353
- mediumvioletred: 13047173,
1354
- midnightblue: 1644912,
1355
- mintcream: 16121850,
1356
- mistyrose: 16770273,
1357
- moccasin: 16770229,
1358
- navajowhite: 16768685,
1359
- navy: 128,
1360
- oldlace: 16643558,
1361
- olive: 8421376,
1362
- olivedrab: 7048739,
1363
- orange: 16753920,
1364
- orangered: 16729344,
1365
- orchid: 14315734,
1366
- palegoldenrod: 15657130,
1367
- palegreen: 10025880,
1368
- paleturquoise: 11529966,
1369
- palevioletred: 14381203,
1370
- papayawhip: 16773077,
1371
- peachpuff: 16767673,
1372
- peru: 13468991,
1373
- pink: 16761035,
1374
- plum: 14524637,
1375
- powderblue: 11591910,
1376
- purple: 8388736,
1377
- rebeccapurple: 6697881,
1378
- red: 16711680,
1379
- rosybrown: 12357519,
1380
- royalblue: 4286945,
1381
- saddlebrown: 9127187,
1382
- salmon: 16416882,
1383
- sandybrown: 16032864,
1384
- seagreen: 3050327,
1385
- seashell: 16774638,
1386
- sienna: 10506797,
1387
- silver: 12632256,
1388
- skyblue: 8900331,
1389
- slateblue: 6970061,
1390
- slategray: 7372944,
1391
- slategrey: 7372944,
1392
- snow: 16775930,
1393
- springgreen: 65407,
1394
- steelblue: 4620980,
1395
- tan: 13808780,
1396
- teal: 32896,
1397
- thistle: 14204888,
1398
- tomato: 16737095,
1399
- turquoise: 4251856,
1400
- violet: 15631086,
1401
- wheat: 16113331,
1402
- white: 16777215,
1403
- whitesmoke: 16119285,
1404
- yellow: 16776960,
1405
- yellowgreen: 10145074
1406
- };
1407
- je(te, P, {
1408
- copy(e) {
1409
- return Object.assign(new this.constructor(), this, e);
1410
- },
1411
- displayable() {
1412
- return this.rgb().displayable();
1413
- },
1414
- hex: Ce,
1415
- // Deprecated! Use color.formatHex.
1416
- formatHex: Ce,
1417
- formatHex8: Jt,
1418
- formatHsl: Pt,
1419
- formatRgb: qe,
1420
- toString: qe
1421
- });
1422
- function Ce() {
1423
- return this.rgb().formatHex();
1424
- }
1425
- function Jt() {
1426
- return this.rgb().formatHex8();
1427
- }
1428
- function Pt() {
1429
- return ot(this).formatHsl();
1430
- }
1431
- function qe() {
1432
- return this.rgb().formatRgb();
1433
- }
1434
- function P(e) {
1435
- var t, n;
1436
- return e = (e + "").trim().toLowerCase(), (t = Kt.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? Ke(t) : n === 3 ? new j(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? ae(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? ae(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, ((t & 15) << 4 | t & 15) / 255) : null) : (t = Bt.exec(e)) ? new j(t[1], t[2], t[3], 1) : (t = Wt.exec(e)) ? new j(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = Yt.exec(e)) ? ae(t[1], t[2], t[3], t[4]) : (t = Xt.exec(e)) ? ae(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = Qt.exec(e)) ? Ye(t[1], t[2] / 100, t[3] / 100, 1) : (t = Zt.exec(e)) ? Ye(t[1], t[2] / 100, t[3] / 100, t[4]) : Ue.hasOwnProperty(e) ? Ke(Ue[e]) : e === "transparent" ? new j(NaN, NaN, NaN, 0) : null;
1437
- }
1438
- function Ke(e) {
1439
- return new j(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
1440
- }
1441
- function ae(e, t, n, r) {
1442
- return r <= 0 && (e = t = n = NaN), new j(e, t, n, r);
1443
- }
1444
- function en(e) {
1445
- return e instanceof te || (e = P(e)), e ? (e = e.rgb(), new j(e.r, e.g, e.b, e.opacity)) : new j();
1446
- }
1447
- function ke(e, t, n, r) {
1448
- return arguments.length === 1 ? en(e) : new j(e, t, n, r ?? 1);
1449
- }
1450
- function j(e, t, n, r) {
1451
- this.r = +e, this.g = +t, this.b = +n, this.opacity = +r;
1452
- }
1453
- je(j, ke, lt(te, {
1454
- brighter(e) {
1455
- return e = e == null ? fe : Math.pow(fe, e), new j(this.r * e, this.g * e, this.b * e, this.opacity);
1456
- },
1457
- darker(e) {
1458
- return e = e == null ? Z : Math.pow(Z, e), new j(this.r * e, this.g * e, this.b * e, this.opacity);
1459
- },
1460
- rgb() {
1461
- return this;
1462
- },
1463
- clamp() {
1464
- return new j(q(this.r), q(this.g), q(this.b), ue(this.opacity));
1465
- },
1466
- displayable() {
1467
- return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
1468
- },
1469
- hex: Be,
1470
- // Deprecated! Use color.formatHex.
1471
- formatHex: Be,
1472
- formatHex8: tn,
1473
- formatRgb: We,
1474
- toString: We
1475
- }));
1476
- function Be() {
1477
- return `#${U(this.r)}${U(this.g)}${U(this.b)}`;
1478
- }
1479
- function tn() {
1480
- return `#${U(this.r)}${U(this.g)}${U(this.b)}${U((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
1481
- }
1482
- function We() {
1483
- const e = ue(this.opacity);
1484
- return `${e === 1 ? "rgb(" : "rgba("}${q(this.r)}, ${q(this.g)}, ${q(this.b)}${e === 1 ? ")" : `, ${e})`}`;
1485
- }
1486
- function ue(e) {
1487
- return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
1488
- }
1489
- function q(e) {
1490
- return Math.max(0, Math.min(255, Math.round(e) || 0));
1491
- }
1492
- function U(e) {
1493
- return e = q(e), (e < 16 ? "0" : "") + e.toString(16);
1494
- }
1495
- function Ye(e, t, n, r) {
1496
- return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new D(e, t, n, r);
1497
- }
1498
- function ot(e) {
1499
- if (e instanceof D) return new D(e.h, e.s, e.l, e.opacity);
1500
- if (e instanceof te || (e = P(e)), !e) return new D();
1501
- if (e instanceof D) return e;
1502
- e = e.rgb();
1503
- var t = e.r / 255, n = e.g / 255, r = e.b / 255, s = Math.min(t, n, r), l = Math.max(t, n, r), a = NaN, c = l - s, d = (l + s) / 2;
1504
- return c ? (t === l ? a = (n - r) / c + (n < r) * 6 : n === l ? a = (r - t) / c + 2 : a = (t - n) / c + 4, c /= d < 0.5 ? l + s : 2 - l - s, a *= 60) : c = d > 0 && d < 1 ? 0 : a, new D(a, c, d, e.opacity);
1505
- }
1506
- function nn(e, t, n, r) {
1507
- return arguments.length === 1 ? ot(e) : new D(e, t, n, r ?? 1);
1508
- }
1509
- function D(e, t, n, r) {
1510
- this.h = +e, this.s = +t, this.l = +n, this.opacity = +r;
1511
- }
1512
- je(D, nn, lt(te, {
1513
- brighter(e) {
1514
- return e = e == null ? fe : Math.pow(fe, e), new D(this.h, this.s, this.l * e, this.opacity);
1515
- },
1516
- darker(e) {
1517
- return e = e == null ? Z : Math.pow(Z, e), new D(this.h, this.s, this.l * e, this.opacity);
1518
- },
1519
- rgb() {
1520
- var e = this.h % 360 + (this.h < 0) * 360, t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < 0.5 ? n : 1 - n) * t, s = 2 * n - r;
1521
- return new j(
1522
- be(e >= 240 ? e - 240 : e + 120, s, r),
1523
- be(e, s, r),
1524
- be(e < 120 ? e + 240 : e - 120, s, r),
1525
- this.opacity
1526
- );
1527
- },
1528
- clamp() {
1529
- return new D(Xe(this.h), le(this.s), le(this.l), ue(this.opacity));
1530
- },
1531
- displayable() {
1532
- return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
1533
- },
1534
- formatHsl() {
1535
- const e = ue(this.opacity);
1536
- return `${e === 1 ? "hsl(" : "hsla("}${Xe(this.h)}, ${le(this.s) * 100}%, ${le(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
1537
- }
1538
- }));
1539
- function Xe(e) {
1540
- return e = (e || 0) % 360, e < 0 ? e + 360 : e;
1541
- }
1542
- function le(e) {
1543
- return Math.max(0, Math.min(1, e || 0));
1544
- }
1545
- function be(e, t, n) {
1546
- return (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) * 255;
1547
- }
1548
- const ze = (e) => () => e;
1549
- function rn(e, t) {
1550
- return function(n) {
1551
- return e + n * t;
1552
- };
1553
- }
1554
- function sn(e, t, n) {
1555
- return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function(r) {
1556
- return Math.pow(e + r * t, n);
1557
- };
1558
- }
1559
- function an(e) {
1560
- return (e = +e) == 1 ? ct : function(t, n) {
1561
- return n - t ? sn(t, n, e) : ze(isNaN(t) ? n : t);
1562
- };
1563
- }
1564
- function ct(e, t) {
1565
- var n = t - e;
1566
- return n ? rn(e, n) : ze(isNaN(e) ? t : e);
1567
- }
1568
- const Qe = (function e(t) {
1569
- var n = an(t);
1570
- function r(s, l) {
1571
- var a = n((s = ke(s)).r, (l = ke(l)).r), c = n(s.g, l.g), d = n(s.b, l.b), o = ct(s.opacity, l.opacity);
1572
- return function(f) {
1573
- return s.r = a(f), s.g = c(f), s.b = d(f), s.opacity = o(f), s + "";
1574
- };
1575
- }
1576
- return r.gamma = e, r;
1577
- })(1);
1578
- function ln(e, t) {
1579
- t || (t = []);
1580
- var n = e ? Math.min(t.length, e.length) : 0, r = t.slice(), s;
1581
- return function(l) {
1582
- for (s = 0; s < n; ++s) r[s] = e[s] * (1 - l) + t[s] * l;
1583
- return r;
1584
- };
1585
- }
1586
- function on(e) {
1587
- return ArrayBuffer.isView(e) && !(e instanceof DataView);
1588
- }
1589
- function cn(e, t) {
1590
- var n = t ? t.length : 0, r = e ? Math.min(n, e.length) : 0, s = new Array(r), l = new Array(n), a;
1591
- for (a = 0; a < r; ++a) s[a] = Ee(e[a], t[a]);
1592
- for (; a < n; ++a) l[a] = t[a];
1593
- return function(c) {
1594
- for (a = 0; a < r; ++a) l[a] = s[a](c);
1595
- return l;
1596
- };
1597
- }
1598
- function dn(e, t) {
1599
- var n = /* @__PURE__ */ new Date();
1600
- return e = +e, t = +t, function(r) {
1601
- return n.setTime(e * (1 - r) + t * r), n;
1602
- };
1603
- }
1604
- function me(e, t) {
1605
- return e = +e, t = +t, function(n) {
1606
- return e * (1 - n) + t * n;
1607
- };
1608
- }
1609
- function fn(e, t) {
1610
- var n = {}, r = {}, s;
1611
- (e === null || typeof e != "object") && (e = {}), (t === null || typeof t != "object") && (t = {});
1612
- for (s in t)
1613
- s in e ? n[s] = Ee(e[s], t[s]) : r[s] = t[s];
1614
- return function(l) {
1615
- for (s in n) r[s] = n[s](l);
1616
- return r;
1617
- };
1618
- }
1619
- var Se = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, Ne = new RegExp(Se.source, "g");
1620
- function un(e) {
1621
- return function() {
1622
- return e;
1623
- };
1624
- }
1625
- function mn(e) {
1626
- return function(t) {
1627
- return e(t) + "";
1628
- };
1629
- }
1630
- function xn(e, t) {
1631
- var n = Se.lastIndex = Ne.lastIndex = 0, r, s, l, a = -1, c = [], d = [];
1632
- for (e = e + "", t = t + ""; (r = Se.exec(e)) && (s = Ne.exec(t)); )
1633
- (l = s.index) > n && (l = t.slice(n, l), c[a] ? c[a] += l : c[++a] = l), (r = r[0]) === (s = s[0]) ? c[a] ? c[a] += s : c[++a] = s : (c[++a] = null, d.push({ i: a, x: me(r, s) })), n = Ne.lastIndex;
1634
- return n < t.length && (l = t.slice(n), c[a] ? c[a] += l : c[++a] = l), c.length < 2 ? d[0] ? mn(d[0].x) : un(t) : (t = d.length, function(o) {
1635
- for (var f = 0, u; f < t; ++f) c[(u = d[f]).i] = u.x(o);
1636
- return c.join("");
1637
- });
1638
- }
1639
- function Ee(e, t) {
1640
- var n = typeof t, r;
1641
- return t == null || n === "boolean" ? ze(t) : (n === "number" ? me : n === "string" ? (r = P(t)) ? (t = r, Qe) : xn : t instanceof P ? Qe : t instanceof Date ? dn : on(t) ? ln : Array.isArray(t) ? cn : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? fn : me)(e, t);
1642
- }
1643
- function hn(e, t) {
1644
- return e = +e, t = +t, function(n) {
1645
- return Math.round(e * (1 - n) + t * n);
1646
- };
1647
- }
1648
- function yn(e) {
1649
- return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
1650
- }
1651
- function xe(e, t) {
1652
- if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0) return null;
1653
- var n, r = e.slice(0, n);
1654
- return [
1655
- r.length > 1 ? r[0] + r.slice(2) : r,
1656
- +e.slice(n + 1)
1657
- ];
1658
- }
1659
- function Q(e) {
1660
- return e = xe(Math.abs(e)), e ? e[1] : NaN;
1661
- }
1662
- function gn(e, t) {
1663
- return function(n, r) {
1664
- for (var s = n.length, l = [], a = 0, c = e[0], d = 0; s > 0 && c > 0 && (d + c + 1 > r && (c = Math.max(1, r - d)), l.push(n.substring(s -= c, s + c)), !((d += c + 1) > r)); )
1665
- c = e[a = (a + 1) % e.length];
1666
- return l.reverse().join(t);
1667
- };
1668
- }
1669
- function pn(e) {
1670
- return function(t) {
1671
- return t.replace(/[0-9]/g, function(n) {
1672
- return e[+n];
1673
- });
1674
- };
1675
- }
1676
- var vn = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
1677
- function he(e) {
1678
- if (!(t = vn.exec(e))) throw new Error("invalid format: " + e);
1679
- var t;
1680
- return new De({
1681
- fill: t[1],
1682
- align: t[2],
1683
- sign: t[3],
1684
- symbol: t[4],
1685
- zero: t[5],
1686
- width: t[6],
1687
- comma: t[7],
1688
- precision: t[8] && t[8].slice(1),
1689
- trim: t[9],
1690
- type: t[10]
1691
- });
1692
- }
1693
- he.prototype = De.prototype;
1694
- function De(e) {
1695
- this.fill = e.fill === void 0 ? " " : e.fill + "", this.align = e.align === void 0 ? ">" : e.align + "", this.sign = e.sign === void 0 ? "-" : e.sign + "", this.symbol = e.symbol === void 0 ? "" : e.symbol + "", this.zero = !!e.zero, this.width = e.width === void 0 ? void 0 : +e.width, this.comma = !!e.comma, this.precision = e.precision === void 0 ? void 0 : +e.precision, this.trim = !!e.trim, this.type = e.type === void 0 ? "" : e.type + "";
1696
- }
1697
- De.prototype.toString = function() {
1698
- return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
1699
- };
1700
- function bn(e) {
1701
- e: for (var t = e.length, n = 1, r = -1, s; n < t; ++n)
1702
- switch (e[n]) {
1703
- case ".":
1704
- r = s = n;
1705
- break;
1706
- case "0":
1707
- r === 0 && (r = n), s = n;
1708
- break;
1709
- default:
1710
- if (!+e[n]) break e;
1711
- r > 0 && (r = 0);
1712
- break;
1713
- }
1714
- return r > 0 ? e.slice(0, r) + e.slice(s + 1) : e;
1715
- }
1716
- var dt;
1717
- function Nn(e, t) {
1718
- var n = xe(e, t);
1719
- if (!n) return e + "";
1720
- var r = n[0], s = n[1], l = s - (dt = Math.max(-8, Math.min(8, Math.floor(s / 3))) * 3) + 1, a = r.length;
1721
- return l === a ? r : l > a ? r + new Array(l - a + 1).join("0") : l > 0 ? r.slice(0, l) + "." + r.slice(l) : "0." + new Array(1 - l).join("0") + xe(e, Math.max(0, t + l - 1))[0];
1722
- }
1723
- function Ze(e, t) {
1724
- var n = xe(e, t);
1725
- if (!n) return e + "";
1726
- var r = n[0], s = n[1];
1727
- return s < 0 ? "0." + new Array(-s).join("0") + r : r.length > s + 1 ? r.slice(0, s + 1) + "." + r.slice(s + 1) : r + new Array(s - r.length + 2).join("0");
1728
- }
1729
- const Je = {
1730
- "%": (e, t) => (e * 100).toFixed(t),
1731
- b: (e) => Math.round(e).toString(2),
1732
- c: (e) => e + "",
1733
- d: yn,
1734
- e: (e, t) => e.toExponential(t),
1735
- f: (e, t) => e.toFixed(t),
1736
- g: (e, t) => e.toPrecision(t),
1737
- o: (e) => Math.round(e).toString(8),
1738
- p: (e, t) => Ze(e * 100, t),
1739
- r: Ze,
1740
- s: Nn,
1741
- X: (e) => Math.round(e).toString(16).toUpperCase(),
1742
- x: (e) => Math.round(e).toString(16)
1743
- };
1744
- function Pe(e) {
1745
- return e;
1746
- }
1747
- var et = Array.prototype.map, tt = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
1748
- function wn(e) {
1749
- var t = e.grouping === void 0 || e.thousands === void 0 ? Pe : gn(et.call(e.grouping, Number), e.thousands + ""), n = e.currency === void 0 ? "" : e.currency[0] + "", r = e.currency === void 0 ? "" : e.currency[1] + "", s = e.decimal === void 0 ? "." : e.decimal + "", l = e.numerals === void 0 ? Pe : pn(et.call(e.numerals, String)), a = e.percent === void 0 ? "%" : e.percent + "", c = e.minus === void 0 ? "−" : e.minus + "", d = e.nan === void 0 ? "NaN" : e.nan + "";
1750
- function o(u) {
1751
- u = he(u);
1752
- var m = u.fill, v = u.align, p = u.sign, A = u.symbol, x = u.zero, k = u.width, $ = u.comma, h = u.precision, N = u.trim, y = u.type;
1753
- y === "n" ? ($ = !0, y = "g") : Je[y] || (h === void 0 && (h = 12), N = !0, y = "g"), (x || m === "0" && v === "=") && (x = !0, m = "0", v = "=");
1754
- var g = A === "$" ? n : A === "#" && /[boxX]/.test(y) ? "0" + y.toLowerCase() : "", b = A === "$" ? r : /[%p]/.test(y) ? a : "", M = Je[y], L = /[defgprs%]/.test(y);
1755
- h = h === void 0 ? 6 : /[gprs]/.test(y) ? Math.max(1, Math.min(21, h)) : Math.max(0, Math.min(20, h));
1756
- function F(S) {
1757
- var E = g, z = b, W, Ie, ne;
1758
- if (y === "c")
1759
- z = M(S) + z, S = "";
1760
- else {
1761
- S = +S;
1762
- var re = S < 0 || 1 / S < 0;
1763
- if (S = isNaN(S) ? d : M(Math.abs(S), h), N && (S = bn(S)), re && +S == 0 && p !== "+" && (re = !1), E = (re ? p === "(" ? p : c : p === "-" || p === "(" ? "" : p) + E, z = (y === "s" ? tt[8 + dt / 3] : "") + z + (re && p === "(" ? ")" : ""), L) {
1764
- for (W = -1, Ie = S.length; ++W < Ie; )
1765
- if (ne = S.charCodeAt(W), 48 > ne || ne > 57) {
1766
- z = (ne === 46 ? s + S.slice(W + 1) : S.slice(W)) + z, S = S.slice(0, W);
1767
- break;
1768
- }
1769
- }
1770
- }
1771
- $ && !x && (S = t(S, 1 / 0));
1772
- var se = E.length + S.length + z.length, _ = se < k ? new Array(k - se + 1).join(m) : "";
1773
- switch ($ && x && (S = t(_ + S, _.length ? k - z.length : 1 / 0), _ = ""), v) {
1774
- case "<":
1775
- S = E + S + z + _;
1776
- break;
1777
- case "=":
1778
- S = E + _ + S + z;
1779
- break;
1780
- case "^":
1781
- S = _.slice(0, se = _.length >> 1) + E + S + z + _.slice(se);
1782
- break;
1783
- default:
1784
- S = _ + E + S + z;
1785
- break;
1786
- }
1787
- return l(S);
1788
- }
1789
- return F.toString = function() {
1790
- return u + "";
1791
- }, F;
1792
- }
1793
- function f(u, m) {
1794
- var v = o((u = he(u), u.type = "f", u)), p = Math.max(-8, Math.min(8, Math.floor(Q(m) / 3))) * 3, A = Math.pow(10, -p), x = tt[8 + p / 3];
1795
- return function(k) {
1796
- return v(A * k) + x;
1797
- };
1798
- }
1799
- return {
1800
- format: o,
1801
- formatPrefix: f
1802
- };
1803
- }
1804
- var oe, ft, ut;
1805
- An({
1806
- thousands: ",",
1807
- grouping: [3],
1808
- currency: ["$", ""]
1809
- });
1810
- function An(e) {
1811
- return oe = wn(e), ft = oe.format, ut = oe.formatPrefix, oe;
1812
- }
1813
- function kn(e) {
1814
- return Math.max(0, -Q(Math.abs(e)));
1815
- }
1816
- function Sn(e, t) {
1817
- return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Q(t) / 3))) * 3 - Q(Math.abs(e)));
1818
- }
1819
- function Mn(e, t) {
1820
- return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Q(t) - Q(e)) + 1;
1821
- }
1822
- function Re(e, t) {
1823
- switch (arguments.length) {
1824
- case 0:
1825
- break;
1826
- case 1:
1827
- this.range(e);
1828
- break;
1829
- default:
1830
- this.range(t).domain(e);
1831
- break;
1832
- }
1833
- return this;
1834
- }
1835
- const nt = Symbol("implicit");
1836
- function mt() {
1837
- var e = new Ve(), t = [], n = [], r = nt;
1838
- function s(l) {
1839
- let a = e.get(l);
1840
- if (a === void 0) {
1841
- if (r !== nt) return r;
1842
- e.set(l, a = t.push(l) - 1);
1843
- }
1844
- return n[a % n.length];
1845
- }
1846
- return s.domain = function(l) {
1847
- if (!arguments.length) return t.slice();
1848
- t = [], e = new Ve();
1849
- for (const a of l)
1850
- e.has(a) || e.set(a, t.push(a) - 1);
1851
- return s;
1852
- }, s.range = function(l) {
1853
- return arguments.length ? (n = Array.from(l), s) : n.slice();
1854
- }, s.unknown = function(l) {
1855
- return arguments.length ? (r = l, s) : r;
1856
- }, s.copy = function() {
1857
- return mt(t, n).unknown(r);
1858
- }, Re.apply(s, arguments), s;
1859
- }
1860
- function $n(e) {
1861
- return function() {
1862
- return e;
1863
- };
1864
- }
1865
- function Ln(e) {
1866
- return +e;
1867
- }
1868
- var rt = [0, 1];
1869
- function Y(e) {
1870
- return e;
1871
- }
1872
- function Me(e, t) {
1873
- return (t -= e = +e) ? function(n) {
1874
- return (n - e) / t;
1875
- } : $n(isNaN(t) ? NaN : 0.5);
1876
- }
1877
- function Tn(e, t) {
1878
- var n;
1879
- return e > t && (n = e, e = t, t = n), function(r) {
1880
- return Math.max(e, Math.min(t, r));
1881
- };
1882
- }
1883
- function Fn(e, t, n) {
1884
- var r = e[0], s = e[1], l = t[0], a = t[1];
1885
- return s < r ? (r = Me(s, r), l = n(a, l)) : (r = Me(r, s), l = n(l, a)), function(c) {
1886
- return l(r(c));
1887
- };
1888
- }
1889
- function jn(e, t, n) {
1890
- var r = Math.min(e.length, t.length) - 1, s = new Array(r), l = new Array(r), a = -1;
1891
- for (e[r] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++a < r; )
1892
- s[a] = Me(e[a], e[a + 1]), l[a] = n(t[a], t[a + 1]);
1893
- return function(c) {
1894
- var d = at(e, c, 1, r) - 1;
1895
- return l[d](s[d](c));
1896
- };
1897
- }
1898
- function zn(e, t) {
1899
- return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
1900
- }
1901
- function En() {
1902
- var e = rt, t = rt, n = Ee, r, s, l, a = Y, c, d, o;
1903
- function f() {
1904
- var m = Math.min(e.length, t.length);
1905
- return a !== Y && (a = Tn(e[0], e[m - 1])), c = m > 2 ? jn : Fn, d = o = null, u;
1906
- }
1907
- function u(m) {
1908
- return m == null || isNaN(m = +m) ? l : (d || (d = c(e.map(r), t, n)))(r(a(m)));
1909
- }
1910
- return u.invert = function(m) {
1911
- return a(s((o || (o = c(t, e.map(r), me)))(m)));
1912
- }, u.domain = function(m) {
1913
- return arguments.length ? (e = Array.from(m, Ln), f()) : e.slice();
1914
- }, u.range = function(m) {
1915
- return arguments.length ? (t = Array.from(m), f()) : t.slice();
1916
- }, u.rangeRound = function(m) {
1917
- return t = Array.from(m), n = hn, f();
1918
- }, u.clamp = function(m) {
1919
- return arguments.length ? (a = m ? !0 : Y, f()) : a !== Y;
1920
- }, u.interpolate = function(m) {
1921
- return arguments.length ? (n = m, f()) : n;
1922
- }, u.unknown = function(m) {
1923
- return arguments.length ? (l = m, u) : l;
1924
- }, function(m, v) {
1925
- return r = m, s = v, f();
1926
- };
1927
- }
1928
- function Dn() {
1929
- return En()(Y, Y);
1930
- }
1931
- function Rn(e, t, n, r) {
1932
- var s = qt(e, t, n), l;
1933
- switch (r = he(r ?? ",f"), r.type) {
1934
- case "s": {
1935
- var a = Math.max(Math.abs(e), Math.abs(t));
1936
- return r.precision == null && !isNaN(l = Sn(s, a)) && (r.precision = l), ut(r, a);
1937
- }
1938
- case "":
1939
- case "e":
1940
- case "g":
1941
- case "p":
1942
- case "r": {
1943
- r.precision == null && !isNaN(l = Mn(s, Math.max(Math.abs(e), Math.abs(t)))) && (r.precision = l - (r.type === "e"));
1944
- break;
1945
- }
1946
- case "f":
1947
- case "%": {
1948
- r.precision == null && !isNaN(l = kn(s)) && (r.precision = l - (r.type === "%") * 2);
1949
- break;
1950
- }
1951
- }
1952
- return ft(r);
1953
- }
1954
- function xt(e) {
1955
- var t = e.domain;
1956
- return e.ticks = function(n) {
1957
- var r = t();
1958
- return Ct(r[0], r[r.length - 1], n ?? 10);
1959
- }, e.tickFormat = function(n, r) {
1960
- var s = t();
1961
- return Rn(s[0], s[s.length - 1], n ?? 10, r);
1962
- }, e.nice = function(n) {
1963
- n == null && (n = 10);
1964
- var r = t(), s = 0, l = r.length - 1, a = r[s], c = r[l], d, o, f = 10;
1965
- for (c < a && (o = a, a = c, c = o, o = s, s = l, l = o); f-- > 0; ) {
1966
- if (o = Ae(a, c, n), o === d)
1967
- return r[s] = a, r[l] = c, t(r);
1968
- if (o > 0)
1969
- a = Math.floor(a / o) * o, c = Math.ceil(c / o) * o;
1970
- else if (o < 0)
1971
- a = Math.ceil(a * o) / o, c = Math.floor(c * o) / o;
1972
- else
1973
- break;
1974
- d = o;
1975
- }
1976
- return e;
1977
- }, e;
1978
- }
1979
- function In() {
1980
- var e = Dn();
1981
- return e.copy = function() {
1982
- return zn(e, In());
1983
- }, Re.apply(e, arguments), xt(e);
1984
- }
1985
- function ht() {
1986
- var e = 0, t = 1, n = 1, r = [0.5], s = [0, 1], l;
1987
- function a(d) {
1988
- return d != null && d <= d ? s[at(r, d, 0, n)] : l;
1989
- }
1990
- function c() {
1991
- var d = -1;
1992
- for (r = new Array(n); ++d < n; ) r[d] = ((d + 1) * t - (d - n) * e) / (n + 1);
1993
- return a;
1994
- }
1995
- return a.domain = function(d) {
1996
- return arguments.length ? ([e, t] = d, e = +e, t = +t, c()) : [e, t];
1997
- }, a.range = function(d) {
1998
- return arguments.length ? (n = (s = Array.from(d)).length - 1, c()) : s.slice();
1999
- }, a.invertExtent = function(d) {
2000
- var o = s.indexOf(d);
2001
- return o < 0 ? [NaN, NaN] : o < 1 ? [e, r[0]] : o >= n ? [r[n - 1], t] : [r[o - 1], r[o]];
2002
- }, a.unknown = function(d) {
2003
- return arguments.length && (l = d), a;
2004
- }, a.thresholds = function() {
2005
- return r.slice();
2006
- }, a.copy = function() {
2007
- return ht().domain([e, t]).range(s).unknown(l);
2008
- }, Re.apply(xt(a), arguments);
2009
- }
2010
- function Jn({
2011
- data: e,
2012
- chartConfig: t,
2013
- displayConfig: n = {},
2014
- queryObject: r,
2015
- height: s = "100%",
2016
- colorPalette: l
2017
- }) {
2018
- const [a, c] = H(null), { getFieldLabel: d } = B();
2019
- try {
2020
- const o = {
2021
- showTooltip: n?.showTooltip ?? !0,
2022
- showLegend: n?.showLegend ?? !0
2023
- };
2024
- if (!e || e.length === 0)
2025
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
2026
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
2027
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in treemap chart" })
2028
- ] }) });
2029
- let f, u = !1, m;
2030
- if (t?.xAxis && t?.yAxis) {
2031
- const h = t.xAxis[0], N = Array.isArray(t.yAxis) ? t.yAxis[0] : t.yAxis;
2032
- m = Array.isArray(t.series) ? t.series[0] : t.series;
2033
- const y = O(r, h);
2034
- if (m) {
2035
- const g = e.map((b) => {
2036
- const M = b[m];
2037
- return typeof M == "string" ? parseFloat(M) : M;
2038
- }).filter((b) => !isNaN(b));
2039
- if (u = g.length === e.length && g.every((b) => typeof b == "number"), u) {
2040
- const b = Math.min(...g), M = Math.max(...g), L = ht().domain([b, M]).range(ie);
2041
- f = e.map((F) => {
2042
- const S = typeof F[m] == "string" ? parseFloat(F[m]) : F[m], E = L(S);
2043
- return {
2044
- name: R(F[h], y) || String(F[h]) || "Unknown",
2045
- size: typeof F[N] == "string" ? parseFloat(F[N]) : F[N] || 0,
2046
- fill: E,
2047
- series: String(F[m])
2048
- };
2049
- });
2050
- } else {
2051
- const b = [...new Set(e.map((L) => String(L[m])))], M = mt().domain(b).range(l?.colors || T);
2052
- f = e.map((L) => ({
2053
- name: R(L[h], y) || String(L[h]) || "Unknown",
2054
- size: typeof L[N] == "string" ? parseFloat(L[N]) : L[N] || 0,
2055
- fill: M(String(L[m])),
2056
- series: String(L[m])
2057
- }));
2058
- }
2059
- } else
2060
- f = e.map((g, b) => ({
2061
- name: R(g[h], y) || String(g[h]) || "Unknown",
2062
- size: typeof g[N] == "string" ? parseFloat(g[N]) : g[N] || 0,
2063
- fill: l?.colors && l.colors[b % l.colors.length] || T[b % T.length]
2064
- }));
2065
- } else {
2066
- const h = e[0], N = Object.keys(h), y = N.find(
2067
- (b) => typeof h[b] == "string" || b.toLowerCase().includes("name") || b.toLowerCase().includes("label") || b.toLowerCase().includes("category")
2068
- ) || N[0], g = N.find((b) => b.toLowerCase().includes("size")) || N.find(
2069
- (b) => typeof h[b] == "number" && b !== y
2070
- ) || N[1];
2071
- if (!g)
2072
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
2073
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
2074
- /* @__PURE__ */ i("div", { className: "text-xs", children: "No numeric field found for treemap chart size" })
2075
- ] }) });
2076
- f = e.map((b, M) => {
2077
- let L = b[y];
2078
- return typeof L == "boolean" ? L = L ? "Active" : "Inactive" : L === "true" || L === "false" ? L = L === "true" ? "Active" : "Inactive" : L = String(L), {
2079
- name: L,
2080
- size: typeof b[g] == "string" ? parseFloat(b[g]) : b[g] || 0,
2081
- fill: l?.colors && l.colors[M % l.colors.length] || T[M % T.length]
2082
- };
2083
- });
2084
- }
2085
- if (f = f.filter((h) => h.size != null && h.size > 0), f.length === 0)
2086
- return /* @__PURE__ */ i("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
2087
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
2088
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for treemap chart after transformation" })
2089
- ] }) });
2090
- const v = (h) => {
2091
- const { x: N, y, width: g, height: b, index: M, name: L, size: F } = h;
2092
- return g < 20 || b < 20 ? null : /* @__PURE__ */ w("g", { children: [
2093
- /* @__PURE__ */ i(
2094
- "rect",
2095
- {
2096
- x: N,
2097
- y,
2098
- width: g,
2099
- height: b,
2100
- style: {
2101
- fill: f[M]?.fill || l?.colors && l.colors[M % l.colors.length] || T[M % T.length],
2102
- fillOpacity: a !== null ? a === M ? 1 : 0.6 : 0.8,
2103
- stroke: "#fff",
2104
- strokeWidth: 2,
2105
- cursor: "pointer"
2106
- },
2107
- onMouseEnter: () => c(M),
2108
- onMouseLeave: () => c(null)
2109
- }
2110
- ),
2111
- /* @__PURE__ */ i(
2112
- "foreignObject",
2113
- {
2114
- x: N,
2115
- y,
2116
- width: g,
2117
- height: b,
2118
- style: { pointerEvents: "none", overflow: "visible" },
2119
- children: /* @__PURE__ */ w(
2120
- "div",
2121
- {
2122
- style: {
2123
- width: "100%",
2124
- height: "100%",
2125
- display: "flex",
2126
- flexDirection: "column",
2127
- alignItems: "center",
2128
- justifyContent: "center",
2129
- padding: "4px",
2130
- boxSizing: "border-box",
2131
- color: "#ffffff",
2132
- textShadow: "0 1px 2px rgba(0,0,0,0.8)",
2133
- fontFamily: "system-ui, -apple-system, sans-serif",
2134
- overflow: "hidden"
2135
- },
2136
- children: [
2137
- g > 40 && b > 30 && /* @__PURE__ */ i(
2138
- "div",
2139
- {
2140
- style: {
2141
- fontSize: `${Math.max(10, Math.min(g / 8, b / 8, 16))}px`,
2142
- fontWeight: "600",
2143
- textAlign: "center",
2144
- lineHeight: "1.2",
2145
- marginBottom: g > 60 && b > 45 ? "4px" : "0",
2146
- wordBreak: "break-word",
2147
- hyphens: "auto"
2148
- },
2149
- children: L
2150
- }
2151
- ),
2152
- g > 60 && b > 45 && /* @__PURE__ */ i(
2153
- "div",
2154
- {
2155
- style: {
2156
- fontSize: `${Math.max(8, Math.min(g / 10, b / 10, 14))}px`,
2157
- textAlign: "center",
2158
- opacity: 0.9
2159
- },
2160
- children: typeof F == "number" ? F.toLocaleString() : F
2161
- }
2162
- )
2163
- ]
2164
- }
2165
- )
2166
- }
2167
- )
2168
- ] });
2169
- }, A = f.some((h) => "series" in h) ? [...new Set(f.map((h) => h.series).filter(Boolean))] : [];
2170
- let x = [];
2171
- if (o.showLegend && m)
2172
- if (u) {
2173
- const h = Math.min(...e.map((y) => {
2174
- const g = y[m];
2175
- return typeof g == "string" ? parseFloat(g) : g;
2176
- })), N = Math.max(...e.map((y) => {
2177
- const g = y[m];
2178
- return typeof g == "string" ? parseFloat(g) : g;
2179
- }));
2180
- x = ie.map((y, g) => {
2181
- const b = g / (ie.length - 1);
2182
- return {
2183
- value: (h + (N - h) * b).toFixed(2),
2184
- type: "rect",
2185
- color: y
2186
- };
2187
- });
2188
- } else A.length > 1 && (x = A.map((h, N) => ({
2189
- value: h,
2190
- type: "rect",
2191
- color: T[N % T.length]
2192
- })));
2193
- const k = o.showLegend && x.length > 0, $ = k ? typeof s == "string" && s.includes("%") ? s : typeof s == "number" ? s + 60 : `calc(${s} + 60px)` : s;
2194
- return /* @__PURE__ */ w("div", { className: "w-full", style: { height: $ }, children: [
2195
- /* @__PURE__ */ i(V, { height: k ? "calc(100% - 50px)" : "100%", children: /* @__PURE__ */ i(
2196
- Ft,
2197
- {
2198
- data: f,
2199
- dataKey: "size",
2200
- aspectRatio: 4 / 3,
2201
- stroke: "#fff",
2202
- content: /* @__PURE__ */ i(v, {}),
2203
- children: o.showTooltip && /* @__PURE__ */ i(G, {})
2204
- }
2205
- ) }),
2206
- k && /* @__PURE__ */ i("div", { className: "flex justify-center items-center mt-4 pb-2", children: u ? (
2207
- // Gradient legend for numeric series
2208
- /* @__PURE__ */ w("div", { className: "flex flex-col items-center", children: [
2209
- /* @__PURE__ */ i("div", { className: "text-xs font-semibold text-dc-text-primary mb-2", children: m ? d(m) : "" }),
2210
- /* @__PURE__ */ w("div", { className: "flex items-center gap-2", children: [
2211
- /* @__PURE__ */ i("span", { className: "text-xs text-dc-text-muted", children: Math.min(...e.map((h) => {
2212
- const N = h[m];
2213
- return typeof N == "string" ? parseFloat(N) : N;
2214
- })).toFixed(2) }),
2215
- /* @__PURE__ */ i(
2216
- "div",
2217
- {
2218
- className: "h-4 rounded-sm",
2219
- style: {
2220
- width: "200px",
2221
- background: `linear-gradient(to right, ${ie.join(", ")})`
2222
- }
2223
- }
2224
- ),
2225
- /* @__PURE__ */ i("span", { className: "text-xs text-dc-text-muted", children: Math.max(...e.map((h) => {
2226
- const N = h[m];
2227
- return typeof N == "string" ? parseFloat(N) : N;
2228
- })).toFixed(2) })
2229
- ] })
2230
- ] })
2231
- ) : (
2232
- // Discrete legend for categorical series
2233
- /* @__PURE__ */ i("div", { className: "flex flex-wrap justify-center gap-4", children: x.map((h, N) => /* @__PURE__ */ w("div", { className: "flex items-center gap-2", children: [
2234
- /* @__PURE__ */ i(
2235
- "div",
2236
- {
2237
- className: "w-3 h-3 rounded-xs",
2238
- style: { backgroundColor: h.color }
2239
- }
2240
- ),
2241
- /* @__PURE__ */ i("span", { className: "text-xs text-dc-text-muted", children: h.value })
2242
- ] }, N)) })
2243
- ) })
2244
- ] });
2245
- } catch (o) {
2246
- return /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: s }, children: /* @__PURE__ */ w("div", { className: "text-center", children: [
2247
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "TreeMap Chart Error" }),
2248
- /* @__PURE__ */ i("div", { className: "text-xs mb-2", children: o instanceof Error ? o.message : "Unknown rendering error" }),
2249
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
2250
- ] }) });
2251
- }
2252
- }
2253
- function Pn({
2254
- data: e,
2255
- chartConfig: t,
2256
- height: n = 300
2257
- }) {
2258
- const { getFieldLabel: r } = B();
2259
- if (!e || e.length === 0)
2260
- return /* @__PURE__ */ i(
2261
- "div",
2262
- {
2263
- className: "flex items-center justify-center w-full",
2264
- style: { height: n },
2265
- children: /* @__PURE__ */ w("div", { className: "text-center text-dc-text-muted", children: [
2266
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
2267
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No data to display in table" })
2268
- ] })
2269
- }
2270
- );
2271
- const s = Object.keys(e[0] || {}), l = t?.xAxis && t.xAxis.length > 0 ? t.xAxis.filter((a) => s.includes(a)) : s;
2272
- return l.length === 0 ? /* @__PURE__ */ i(
2273
- "div",
2274
- {
2275
- className: "flex items-center justify-center w-full",
2276
- style: { height: n },
2277
- children: /* @__PURE__ */ w("div", { className: "text-center text-dc-text-muted", children: [
2278
- /* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No columns available" }),
2279
- /* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "Data structure is invalid" })
2280
- ] })
2281
- }
2282
- ) : /* @__PURE__ */ i("div", { className: "w-full overflow-auto", style: { height: n }, children: /* @__PURE__ */ w("table", { className: "min-w-full divide-y border-dc-border", children: [
2283
- /* @__PURE__ */ i("thead", { className: "bg-dc-surface-secondary sticky top-0", children: /* @__PURE__ */ i("tr", { children: l.map((a) => /* @__PURE__ */ i(
2284
- "th",
2285
- {
2286
- className: "px-3 py-2 text-left text-xs font-medium text-dc-text-muted uppercase tracking-wider",
2287
- children: r(a)
2288
- },
2289
- a
2290
- )) }) }),
2291
- /* @__PURE__ */ i("tbody", { className: "bg-dc-surface divide-y border-dc-border", children: e.map((a, c) => /* @__PURE__ */ i("tr", { className: "hover:bg-dc-surface-secondary", children: l.map((d) => /* @__PURE__ */ i(
2292
- "td",
2293
- {
2294
- className: "px-3 py-2 whitespace-nowrap text-sm text-dc-text",
2295
- children: _n(a[d])
2296
- },
2297
- d
2298
- )) }, c)) })
2299
- ] }) });
2300
- }
2301
- function _n(e) {
2302
- return e == null ? "" : typeof e == "number" ? e.toLocaleString() : typeof e == "boolean" ? e ? "Yes" : "No" : String(e);
2303
- }
2304
- function er(e) {
2305
- const t = On(e);
2306
- return {
2307
- portlets: e,
2308
- layouts: t
2309
- };
2310
- }
2311
- function On(e) {
2312
- const t = e.map((n) => ({
2313
- i: n.id,
2314
- x: n.x,
2315
- y: n.y,
2316
- w: n.w,
2317
- h: n.h,
2318
- minW: 3,
2319
- minH: 3
2320
- }));
2321
- return {
2322
- lg: t,
2323
- md: t.map((n) => ({ ...n, w: Math.min(n.w, 8) })),
2324
- sm: t.map((n) => ({ ...n, w: Math.min(n.w, 6) })),
2325
- xs: t.map((n) => ({ ...n, w: Math.min(n.w, 4) })),
2326
- xxs: t.map((n) => ({ ...n, w: 2 }))
2327
- };
2328
- }
2329
- function tr(e, t = {}) {
2330
- const { formatNumbers: n = !0, precision: r = 2 } = t;
2331
- return n ? e.map((s) => {
2332
- const l = {};
2333
- for (const [a, c] of Object.entries(s))
2334
- typeof c == "number" ? l[a] = Number(c.toFixed(r)) : l[a] = c;
2335
- return l;
2336
- }) : e;
2337
- }
2338
- function nr() {
2339
- return `portlet-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
2340
- }
2341
- function rr(e, t = 6, n = 4) {
2342
- return e.length === 0 ? { x: 0, y: 0 } : { x: 0, y: Math.max(...e.map((s) => s.y + s.h)) };
2343
- }
2344
- function sr(e) {
2345
- try {
2346
- const t = JSON.parse(e);
2347
- return typeof t != "object" || t === null ? { valid: !1, error: "Query must be a JSON object" } : !t.measures && !t.dimensions ? { valid: !1, error: "Query must have at least measures or dimensions" } : { valid: !0, query: t };
2348
- } catch {
2349
- return { valid: !1, error: "Invalid JSON format" };
2350
- }
2351
- }
2352
- function ir() {
2353
- return {
2354
- title: "Sample Chart",
2355
- query: JSON.stringify({
2356
- measures: ["count"],
2357
- dimensions: ["category"]
2358
- }, null, 2),
2359
- chartType: "bar",
2360
- chartConfig: {
2361
- x: "category",
2362
- y: ["count"]
2363
- },
2364
- displayConfig: {
2365
- showLegend: !0,
2366
- showGrid: !0,
2367
- showTooltip: !0
2368
- },
2369
- w: 6,
2370
- h: 4,
2371
- x: 0,
2372
- y: 0
2373
- };
2374
- }
2375
- export {
2376
- Wn as A,
2377
- Kn as B,
2378
- ve as C,
2379
- Pn as D,
2380
- ir as E,
2381
- He as F,
2382
- Bn as L,
2383
- jt as N,
2384
- Yn as P,
2385
- Qn as R,
2386
- Xn as S,
2387
- Jn as T,
2388
- Zn as a,
2389
- Qe as b,
2390
- er as c,
2391
- xn as d,
2392
- P as e,
2393
- tr as f,
2394
- zn as g,
2395
- Re as h,
2396
- me as i,
2397
- Y as j,
2398
- O as k,
2399
- xt as l,
2400
- R as m,
2401
- In as n,
2402
- ie as o,
2403
- mt as p,
2404
- ht as q,
2405
- T as r,
2406
- Te as s,
2407
- En as t,
2408
- qn as u,
2409
- Cn as v,
2410
- On as w,
2411
- nr as x,
2412
- rr as y,
2413
- sr as z
2414
- };
2415
- //# sourceMappingURL=charts-CfbqkXfS.js.map