@object-ui/plugin-charts 16.0.0 → 17.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,54 +1,211 @@
1
- import { ComponentRegistry as e, buildChartSeries as t, buildDimensionLabelMap as n, buildOptionColorMap as r, compareToTrendLabelKey as i, computeDrillFilter as a, extractRecords as o, isDrillEnabled as s, relabelDimensions as c, resolveDateMacros as l, resolveDrillTitle as u, shiftFilterByCompareTo as d } from "@object-ui/core";
2
- import * as f from "react";
3
- import p, { Suspense as m, useCallback as h, useContext as g, useEffect as ee, useMemo as _, useRef as te, useState as v } from "react";
4
- import { Button as ne, ChartSkeleton as re, Dialog as ie, DialogContent as ae, DialogHeader as oe, DialogTitle as se, RefreshIndicator as ce, Sheet as le, SheetContent as ue, SheetHeader as y, SheetTitle as b, Skeleton as x } from "@object-ui/components";
5
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
6
- import { Area as T, AreaChart as de, Bar as fe, BarChart as E, CartesianGrid as D, Cell as pe, Funnel as me, FunnelChart as O, LabelList as he, Legend as k, Line as A, LineChart as j, Pie as ge, PieChart as M, PolarAngleAxis as _e, PolarGrid as ve, PolarRadiusAxis as ye, Radar as be, RadarChart as N, ResponsiveContainer as P, Sankey as xe, Scatter as Se, ScatterChart as Ce, Tooltip as F, Treemap as we, XAxis as I, YAxis as L, ZAxis as R } from "recharts";
7
- import { SchemaRenderer as Te, SchemaRendererContext as Ee, useDataScope as z, useDrillNavigation as De } from "@object-ui/react";
8
- import { AlertCircle as Oe, ArrowUpRight as ke } from "lucide-react";
9
- import { useSafeFieldLabel as Ae, useSafeTranslate as je } from "@object-ui/i18n";
1
+ import { ComponentRegistry as e, buildCategoryRank as t, buildChartSeries as n, buildDimensionLabelMap as r, buildOptionColorMap as i, compareToTrendLabelKey as a, computeDrillFilter as o, extractRecords as s, isDrillEnabled as c, relabelDimensions as l, resolveContextTokens as u, resolveDrillTitle as d, resolveFilterPlaceholders as f, shiftFilterByCompareTo as p } from "@object-ui/core";
2
+ import * as m from "react";
3
+ import h, { Suspense as g, useCallback as ee, useContext as te, useEffect as ne, useMemo as _, useRef as re, useState as v } from "react";
4
+ import { Button as ie, ChartSkeleton as y, Dialog as ae, DialogContent as b, DialogHeader as x, DialogTitle as S, RefreshIndicator as C, Sheet as oe, SheetContent as se, SheetHeader as ce, SheetTitle as le, Skeleton as ue } from "@object-ui/components";
5
+ import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
6
+ import { Area as de, AreaChart as fe, Bar as pe, BarChart as D, Brush as me, CartesianGrid as he, Cell as O, ComposedChart as ge, Funnel as _e, FunnelChart as ve, LabelList as ye, Legend as k, Line as be, LineChart as xe, Pie as Se, PieChart as Ce, PolarAngleAxis as we, PolarGrid as Te, PolarRadiusAxis as Ee, Radar as De, RadarChart as Oe, ReferenceArea as ke, ReferenceLine as Ae, ResponsiveContainer as A, Sankey as je, Scatter as Me, ScatterChart as j, Tooltip as M, Treemap as Ne, XAxis as N, YAxis as P, ZAxis as Pe } from "recharts";
7
+ import { SchemaRenderer as Fe, SchemaRendererContext as Ie, useDataScope as Le, useDrillNavigation as Re, useFilterScope as ze } from "@object-ui/react";
8
+ import { AlertCircle as Be, ArrowUpRight as Ve } from "lucide-react";
9
+ import { useSafeFieldLabel as He, useSafeTranslate as F } from "@object-ui/i18n";
10
10
  //#region \0rolldown/runtime.js
11
- var B = Object.defineProperty, V = (e, t, n) => () => {
11
+ var I = Object.defineProperty, L = (e, t, n) => () => {
12
12
  if (n) throw n[0];
13
13
  try {
14
14
  return e && (t = e(e = 0)), t;
15
15
  } catch (e) {
16
16
  throw n = [e], e;
17
17
  }
18
- }, H = (e, t) => {
18
+ }, R = (e, t) => {
19
19
  let n = {};
20
- for (var r in e) B(n, r, {
20
+ for (var r in e) I(n, r, {
21
21
  get: e[r],
22
22
  enumerable: !0
23
23
  });
24
- return t || B(n, Symbol.toStringTag, { value: "Module" }), n;
25
- }, Me = /* @__PURE__ */ H({ default: () => Pe });
26
- function Ne(e, t = 14) {
24
+ return t || I(n, Symbol.toStringTag, { value: "Module" }), n;
25
+ };
26
+ //#endregion
27
+ //#region src/normalizeChartSchema.ts
28
+ function z(e) {
29
+ let t = W(e);
30
+ if (t) return t;
31
+ if (U(e)) return Object.values(e).find((e) => typeof e == "string" && e);
32
+ }
33
+ function B(e) {
34
+ if (!U(e)) return;
35
+ let t = {}, n = W(e.field);
36
+ n && (t.field = n);
37
+ let r = W(e.format);
38
+ r && (t.format = r);
39
+ let i = G(e.min);
40
+ i !== void 0 && (t.min = i);
41
+ let a = G(e.max);
42
+ a !== void 0 && (t.max = a);
43
+ let o = G(e.stepSize);
44
+ o !== void 0 && o > 0 && (t.stepSize = o), typeof e.showGridLines == "boolean" && (t.showGridLines = e.showGridLines), typeof e.logarithmic == "boolean" && (t.logarithmic = e.logarithmic);
45
+ let s = W(e.position);
46
+ (s === "left" || s === "right" || s === "top" || s === "bottom") && (t.position = s);
47
+ let c = z(e.title);
48
+ return c && (t.title = c), t;
49
+ }
50
+ function V(e) {
51
+ if (!U(e)) {
52
+ let t = W(e);
53
+ return t ? { dataKey: t } : void 0;
54
+ }
55
+ let t = W(e.dataKey) ?? W(e.name);
56
+ if (!t) return;
57
+ let n = { dataKey: t }, r = z(e.label);
58
+ r && (n.label = r);
59
+ let i = W(e.chartType) ?? W(e.type);
60
+ (i === "bar" || i === "line" || i === "area") && (n.chartType = i);
61
+ let a = W(e.variant);
62
+ (a === "comparison" || a === "current" || a === "primary") && (n.variant = a);
63
+ let o = G(e.opacity);
64
+ o !== void 0 && (n.opacity = o);
65
+ let s = W(e.dashArray);
66
+ s && (n.dashArray = s);
67
+ let c = W(e.stack);
68
+ c && (n.stack = c);
69
+ let l = W(e.yAxis);
70
+ (l === "left" || l === "right") && (n.yAxis = l);
71
+ let u = W(e.color);
72
+ return u && (n.color = u), n;
73
+ }
74
+ function Ue(e) {
75
+ if (!U(e)) return {};
76
+ let t = {}, n = W(e.type), r = W(e.chartType) ?? W(e.specType) ?? (n && Ze.has(n) ? n : void 0);
77
+ r && Je.has(r) && (t.chartType = r);
78
+ let i = e.xAxis, a = B(i);
79
+ a && (a.format || a.title || a.showGridLines !== void 0) && (t.xAxis = a);
80
+ let o = W(e.xAxisKey) ?? a?.field ?? W(i);
81
+ o && (t.xAxisKey = o);
82
+ let s = (Array.isArray(e.yAxis) ? e.yAxis : e.yAxis === void 0 ? [] : [e.yAxis]).map((e) => B(e) ?? (W(e) ? { field: W(e) } : void 0)).filter((e) => !!e);
83
+ s.length && (t.yAxes = s);
84
+ let c = (Array.isArray(e.series) ? e.series : Array.isArray(e.categories) ? e.categories : void 0)?.map(V).filter((e) => !!e);
85
+ if (!c?.length) {
86
+ let e = s.filter((e) => e.field).map((e, t) => ({
87
+ dataKey: e.field,
88
+ ...e.title ? { label: e.title } : {},
89
+ ...t > 0 || e.position === "right" ? { yAxis: "right" } : {}
90
+ }));
91
+ e.length && (c = e);
92
+ }
93
+ c?.length && (t.series = c), typeof e.showLegend == "boolean" && (t.showLegend = e.showLegend), typeof e.showDataLabels == "boolean" && (t.showDataLabels = e.showDataLabels);
94
+ let l = z(e.title);
95
+ l && (t.title = l);
96
+ let u = z(e.subtitle);
97
+ u && (t.subtitle = u);
98
+ let d = z(e.description);
99
+ d && (t.description = d);
100
+ let f = G(e.height);
101
+ return f !== void 0 && f > 0 && (t.height = f), Array.isArray(e.annotations) && e.annotations.length && (t.annotations = e.annotations.filter(U)), U(e.interaction) && (t.interaction = e.interaction), t;
102
+ }
103
+ function We(e) {
104
+ if (e === "bar" || e === "column") return "bar";
105
+ if (e === "line") return "line";
106
+ if (e === "area") return "area";
107
+ }
108
+ function Ge(e, t) {
109
+ if (e === "combo") return "combo";
110
+ let n = We(e);
111
+ if (!n || !t || t.length < 2) return e;
112
+ let r = t.map((e) => e.chartType ?? n);
113
+ return new Set(r).size > 1 ? "combo" : e;
114
+ }
115
+ function H(e) {
116
+ if (!e) return;
117
+ let t = e.includes("%"), n = /^([$£€¥₹])/.exec(e), r = e.includes(","), i = /\.(0+)/.exec(e)?.[1].length ?? 0, a = {
118
+ $: "USD",
119
+ "£": "GBP",
120
+ "€": "EUR",
121
+ "¥": "CNY",
122
+ "₹": "INR"
123
+ };
124
+ if (!t && !n && !r && i === 0) return;
125
+ let o = {
126
+ minimumFractionDigits: i,
127
+ maximumFractionDigits: i,
128
+ useGrouping: r
129
+ };
130
+ return t ? o.style = "percent" : n && (o.style = "currency", o.currency = a[n[1]] ?? "USD"), (e) => {
131
+ let t = typeof e == "number" ? e : Number(e);
132
+ if (!Number.isFinite(t)) return e == null ? "" : String(e);
133
+ try {
134
+ return new Intl.NumberFormat(void 0, o).format(t);
135
+ } catch {
136
+ return String(t);
137
+ }
138
+ };
139
+ }
140
+ function Ke(e, t) {
141
+ let n = e?.stepSize;
142
+ if (!n || n <= 0) return;
143
+ let r = t.filter((e) => Number.isFinite(e)), i = r.length ? Math.min(...r) : void 0, a = r.length ? Math.max(...r) : void 0, o = e.min ?? Math.min(0, i ?? 0), s = e.max ?? a;
144
+ if (s === void 0 || !Number.isFinite(o) || !Number.isFinite(s) || s < o) return;
145
+ let c = Math.floor(o / n) * n, l = e.max === void 0 ? Math.ceil(s / n) * n : e.max, u = Math.floor((l - c) / n + 1e-9) + 1;
146
+ if (u < 1 || u > Qe) return;
147
+ let d = [];
148
+ for (let e = 0; e < u; e++) d.push(Number((c + e * n).toPrecision(12)));
149
+ return e.max !== void 0 && d[d.length - 1] < e.max && d.push(e.max), d;
150
+ }
151
+ function qe(e) {
152
+ if (!e) return;
153
+ let { min: t, max: n } = e;
154
+ if (!(t === void 0 && n === void 0)) return [t ?? "auto", n ?? "auto"];
155
+ }
156
+ var Je, Ye, Xe, Ze, U, W, G, Qe, $e = L((() => {
157
+ Je = /* @__PURE__ */ new Set([
158
+ "bar",
159
+ "column",
160
+ "horizontal-bar",
161
+ "line",
162
+ "area",
163
+ "pie",
164
+ "donut",
165
+ "funnel",
166
+ "radar",
167
+ "scatter",
168
+ "treemap",
169
+ "sankey",
170
+ "combo"
171
+ ]), Ye = /* @__PURE__ */ new Set([
172
+ "gauge",
173
+ "solid-gauge",
174
+ "metric",
175
+ "kpi",
176
+ "bullet"
177
+ ]), Xe = /* @__PURE__ */ new Set(["table", "pivot"]), Ze = /* @__PURE__ */ new Set([
178
+ ...Je,
179
+ ...Ye,
180
+ ...Xe
181
+ ]), U = (e) => !!e && typeof e == "object" && !Array.isArray(e), W = (e) => typeof e == "string" && e ? e : void 0, G = (e) => typeof e == "number" && Number.isFinite(e) ? e : void 0, Qe = 200;
182
+ })), et = /* @__PURE__ */ R({ default: () => nt });
183
+ function tt(e, t = 14) {
27
184
  return e.length > t ? `${e.slice(0, t - 1)}…` : e;
28
185
  }
29
- function U({ x: e, y: t, payload: n }) {
30
- let r = String(n?.value ?? ""), i = Ne(r);
31
- return /* @__PURE__ */ C("g", {
186
+ function K({ x: e, y: t, payload: n }) {
187
+ let r = String(n?.value ?? ""), i = tt(r);
188
+ return /* @__PURE__ */ T("g", {
32
189
  transform: `translate(${e},${t})`,
33
- children: /* @__PURE__ */ w("text", {
190
+ children: /* @__PURE__ */ E("text", {
34
191
  dy: 10,
35
192
  textAnchor: "end",
36
193
  transform: "rotate(-32)",
37
194
  fill: "hsl(var(--muted-foreground))",
38
195
  fontSize: 11,
39
196
  fontFamily: "monospace",
40
- children: [r !== i && /* @__PURE__ */ C("title", { children: r }), i]
197
+ children: [r !== i && /* @__PURE__ */ T("title", { children: r }), i]
41
198
  })
42
199
  });
43
200
  }
44
- function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
201
+ function nt({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
45
202
  let o = e.map((e) => String(e?.[n] ?? "")), s = o.length > 4 || o.some((e) => e.length > 8);
46
- return /* @__PURE__ */ C("div", {
203
+ return /* @__PURE__ */ T("div", {
47
204
  className: `p-2 sm:p-3 md:p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${i}`,
48
- children: /* @__PURE__ */ C(P, {
205
+ children: /* @__PURE__ */ T(A, {
49
206
  width: "100%",
50
207
  height: r,
51
- children: /* @__PURE__ */ w(E, {
208
+ children: /* @__PURE__ */ E(D, {
52
209
  data: e,
53
210
  margin: {
54
211
  top: 10,
@@ -57,66 +214,66 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
57
214
  bottom: s ? 24 : 5
58
215
  },
59
216
  children: [
60
- /* @__PURE__ */ w("defs", { children: [/* @__PURE__ */ w("linearGradient", {
217
+ /* @__PURE__ */ E("defs", { children: [/* @__PURE__ */ E("linearGradient", {
61
218
  id: "barGradient",
62
219
  x1: "0",
63
220
  y1: "0",
64
221
  x2: "0",
65
222
  y2: "1",
66
223
  children: [
67
- /* @__PURE__ */ C("stop", {
224
+ /* @__PURE__ */ T("stop", {
68
225
  offset: "0%",
69
226
  stopColor: a,
70
227
  stopOpacity: 1
71
228
  }),
72
- /* @__PURE__ */ C("stop", {
229
+ /* @__PURE__ */ T("stop", {
73
230
  offset: "90%",
74
231
  stopColor: a,
75
232
  stopOpacity: .6
76
233
  }),
77
- /* @__PURE__ */ C("stop", {
234
+ /* @__PURE__ */ T("stop", {
78
235
  offset: "100%",
79
236
  stopColor: a,
80
237
  stopOpacity: .3
81
238
  })
82
239
  ]
83
- }), /* @__PURE__ */ w("filter", {
240
+ }), /* @__PURE__ */ E("filter", {
84
241
  id: "glow",
85
242
  height: "130%",
86
243
  children: [
87
- /* @__PURE__ */ C("feGaussianBlur", {
244
+ /* @__PURE__ */ T("feGaussianBlur", {
88
245
  in: "SourceAlpha",
89
246
  stdDeviation: "3",
90
247
  result: "blur"
91
248
  }),
92
- /* @__PURE__ */ C("feOffset", {
249
+ /* @__PURE__ */ T("feOffset", {
93
250
  in: "blur",
94
251
  dx: "0",
95
252
  dy: "0",
96
253
  result: "offsetBlur"
97
254
  }),
98
- /* @__PURE__ */ C("feFlood", {
255
+ /* @__PURE__ */ T("feFlood", {
99
256
  floodColor: a,
100
257
  floodOpacity: "0.5",
101
258
  result: "offsetColor"
102
259
  }),
103
- /* @__PURE__ */ C("feComposite", {
260
+ /* @__PURE__ */ T("feComposite", {
104
261
  in: "offsetColor",
105
262
  in2: "offsetBlur",
106
263
  operator: "in",
107
264
  result: "offsetBlur"
108
265
  }),
109
- /* @__PURE__ */ w("feMerge", { children: [/* @__PURE__ */ C("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ C("feMergeNode", { in: "SourceGraphic" })] })
266
+ /* @__PURE__ */ E("feMerge", { children: [/* @__PURE__ */ T("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ T("feMergeNode", { in: "SourceGraphic" })] })
110
267
  ]
111
268
  })] }),
112
- /* @__PURE__ */ C(D, {
269
+ /* @__PURE__ */ T(he, {
113
270
  strokeDasharray: "3 3",
114
271
  stroke: "hsl(var(--border))",
115
272
  vertical: !1
116
273
  }),
117
- /* @__PURE__ */ C(I, {
274
+ /* @__PURE__ */ T(N, {
118
275
  dataKey: n,
119
- tick: s ? /* @__PURE__ */ C(U, {}) : {
276
+ tick: s ? /* @__PURE__ */ T(K, {}) : {
120
277
  fill: "hsl(var(--muted-foreground))",
121
278
  fontSize: 12,
122
279
  fontFamily: "monospace"
@@ -127,7 +284,7 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
127
284
  height: s ? 56 : void 0,
128
285
  dy: s ? void 0 : 10
129
286
  }),
130
- /* @__PURE__ */ C(L, {
287
+ /* @__PURE__ */ T(P, {
131
288
  tick: {
132
289
  fill: "hsl(var(--muted-foreground))",
133
290
  fontSize: 12,
@@ -136,7 +293,7 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
136
293
  tickLine: !1,
137
294
  axisLine: !1
138
295
  }),
139
- /* @__PURE__ */ C(F, {
296
+ /* @__PURE__ */ T(M, {
140
297
  cursor: {
141
298
  fill: "hsl(var(--muted))",
142
299
  opacity: .2
@@ -151,11 +308,11 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
151
308
  },
152
309
  itemStyle: { color: "hsl(var(--primary))" }
153
310
  }),
154
- /* @__PURE__ */ C(k, { wrapperStyle: {
311
+ /* @__PURE__ */ T(k, { wrapperStyle: {
155
312
  paddingTop: "20px",
156
313
  fontFamily: "monospace"
157
314
  } }),
158
- /* @__PURE__ */ C(fe, {
315
+ /* @__PURE__ */ T(pe, {
159
316
  dataKey: t,
160
317
  fill: "url(#barGradient)",
161
318
  radius: [
@@ -172,48 +329,63 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
172
329
  })
173
330
  });
174
331
  }
175
- var Fe = V((() => {}));
332
+ var rt = L((() => {}));
176
333
  //#endregion
177
334
  //#region src/ChartContainerImpl.tsx
178
- function Ie() {
179
- let e = f.useContext(ze);
335
+ function it() {
336
+ let e = m.useContext(ct);
180
337
  if (!e) throw Error("useChart must be used within a <ChartContainer />");
181
338
  return e;
182
339
  }
183
- function W({ id: e, className: t, children: n, config: r, ...i }) {
184
- let a = f.useId(), o = `chart-${e || a.replace(/:/g, "")}`;
185
- return /* @__PURE__ */ C(ze.Provider, {
340
+ function q({ id: e, className: t, children: n, config: r, disableSettleRemount: i, ...a }) {
341
+ let o = m.useId(), s = `chart-${e || o.replace(/:/g, "")}`, c = m.useRef(null), [l, u] = m.useState(0);
342
+ return m.useEffect(() => {
343
+ if (i) return;
344
+ let e = c.current;
345
+ if (e == null || typeof ResizeObserver > "u") return;
346
+ let t = !1, n, r = new ResizeObserver((e) => {
347
+ if (t) return;
348
+ let i = e[0]?.contentRect;
349
+ i == null || i.width <= 0 || i.height <= 0 || (n != null && clearTimeout(n), n = setTimeout(() => {
350
+ t = !0, r.disconnect(), u((e) => e + 1);
351
+ }, 80));
352
+ });
353
+ return r.observe(e), () => {
354
+ t = !0, n != null && clearTimeout(n), r.disconnect();
355
+ };
356
+ }, [i]), /* @__PURE__ */ T(ct.Provider, {
186
357
  value: { config: r },
187
- children: /* @__PURE__ */ w("div", {
358
+ children: /* @__PURE__ */ E("div", {
359
+ ref: c,
188
360
  "data-slot": "chart",
189
- "data-chart": o,
190
- className: q("block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
361
+ "data-chart": s,
362
+ className: J("block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
191
363
  style: {
192
364
  minHeight: 280,
193
365
  minWidth: 0,
194
- ...i.style
366
+ ...a.style
195
367
  },
196
- ...i,
197
- children: [/* @__PURE__ */ C(Be, {
198
- id: o,
368
+ ...a,
369
+ children: [/* @__PURE__ */ T(lt, {
370
+ id: s,
199
371
  config: r
200
- }), /* @__PURE__ */ C(P, {
372
+ }), /* @__PURE__ */ T(A, {
201
373
  width: "100%",
202
374
  height: "100%",
203
375
  children: n
204
- })]
376
+ }, l)]
205
377
  })
206
378
  });
207
379
  }
208
- function G({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: o, labelFormatter: s, labelClassName: c, formatter: l, color: u, nameKey: d, labelKey: p }) {
209
- let { config: m } = Ie(), h = f.useMemo(() => {
380
+ function at({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: o, labelFormatter: s, labelClassName: c, formatter: l, color: u, nameKey: d, labelKey: f }) {
381
+ let { config: p } = it(), h = m.useMemo(() => {
210
382
  if (i || !t?.length) return null;
211
- let [e] = t, n = `${p || e?.dataKey || e?.name || "value"}`, r = Le(m, e, n), a = !p && typeof o == "string" ? m[o]?.label || o : r?.label;
212
- return s ? /* @__PURE__ */ C("div", {
213
- className: q("font-medium", c),
383
+ let [e] = t, n = `${f || e?.dataKey || e?.name || "value"}`, r = st(p, e, n), a = !f && typeof o == "string" ? p[o]?.label || o : r?.label;
384
+ return s ? /* @__PURE__ */ T("div", {
385
+ className: J("font-medium", c),
214
386
  children: s(a, t)
215
- }) : a ? /* @__PURE__ */ C("div", {
216
- className: q("font-medium", c),
387
+ }) : a ? /* @__PURE__ */ T("div", {
388
+ className: J("font-medium", c),
217
389
  children: a
218
390
  }) : null;
219
391
  }, [
@@ -222,34 +394,34 @@ function G({ active: e, payload: t, className: n, indicator: r = "dot", hideLabe
222
394
  t,
223
395
  i,
224
396
  c,
225
- m,
226
- p
397
+ p,
398
+ f
227
399
  ]);
228
400
  if (!e || !t?.length) return null;
229
401
  let g = t.length === 1 && r !== "dot";
230
- return /* @__PURE__ */ w("div", {
231
- className: q("border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl", n),
232
- children: [g ? null : h, /* @__PURE__ */ C("div", {
402
+ return /* @__PURE__ */ E("div", {
403
+ className: J("border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl", n),
404
+ children: [g ? null : h, /* @__PURE__ */ T("div", {
233
405
  className: "grid gap-1.5",
234
406
  children: t.filter((e) => e.type !== "none").map((e, t) => {
235
- let n = `${d || e.name || e.dataKey || "value"}`, i = Le(m, e, n), o = u || e.payload.fill || e.color;
236
- return /* @__PURE__ */ C("div", {
237
- className: q("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5", r === "dot" ? "items-center" : ""),
238
- children: l && e?.value !== void 0 && e.name ? l(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ w(S, { children: [i?.icon ? /* @__PURE__ */ C(i.icon, {}) : !a && /* @__PURE__ */ C("div", {
239
- className: q("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", r === "dot" ? "h-2.5 w-2.5" : "", r === "line" ? "w-1" : "", r === "dashed" ? "w-0 border-[1.5px] border-dashed bg-transparent" : "", g && r === "dashed" ? "my-0.5" : ""),
407
+ let n = `${d || e.name || e.dataKey || "value"}`, i = st(p, e, n), o = u || e.payload.fill || e.color;
408
+ return /* @__PURE__ */ T("div", {
409
+ className: J("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5", r === "dot" ? "items-center" : ""),
410
+ children: l && e?.value !== void 0 && e.name ? l(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ E(w, { children: [i?.icon ? /* @__PURE__ */ T(i.icon, {}) : !a && /* @__PURE__ */ T("div", {
411
+ className: J("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", r === "dot" ? "h-2.5 w-2.5" : "", r === "line" ? "w-1" : "", r === "dashed" ? "w-0 border-[1.5px] border-dashed bg-transparent" : "", g && r === "dashed" ? "my-0.5" : ""),
240
412
  style: {
241
413
  "--color-bg": o,
242
414
  "--color-border": o
243
415
  }
244
- }), /* @__PURE__ */ w("div", {
245
- className: q("flex flex-1 justify-between leading-none", g ? "items-end" : "items-center"),
246
- children: [/* @__PURE__ */ w("div", {
416
+ }), /* @__PURE__ */ E("div", {
417
+ className: J("flex flex-1 justify-between leading-none", g ? "items-end" : "items-center"),
418
+ children: [/* @__PURE__ */ E("div", {
247
419
  className: "grid gap-1.5",
248
- children: [g ? h : null, /* @__PURE__ */ C("span", {
420
+ children: [g ? h : null, /* @__PURE__ */ T("span", {
249
421
  className: "text-muted-foreground",
250
422
  children: i?.label || e.name
251
423
  })]
252
- }), e.value && /* @__PURE__ */ C("span", {
424
+ }), e.value && /* @__PURE__ */ T("span", {
253
425
  className: "text-foreground font-mono font-medium tabular-nums",
254
426
  children: e.value.toLocaleString()
255
427
  })]
@@ -259,15 +431,15 @@ function G({ active: e, payload: t, className: n, indicator: r = "dot", hideLabe
259
431
  })]
260
432
  });
261
433
  }
262
- function K({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bottom", nameKey: i }) {
263
- let { config: a } = Ie();
264
- return n?.length ? /* @__PURE__ */ C("div", {
265
- className: q("flex items-center justify-center gap-4", r === "top" ? "pb-3" : "pt-3", e),
434
+ function ot({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bottom", nameKey: i }) {
435
+ let { config: a } = it();
436
+ return n?.length ? /* @__PURE__ */ T("div", {
437
+ className: J("flex items-center justify-center gap-4", r === "top" ? "pb-3" : "pt-3", e),
266
438
  children: n.filter((e) => e.type !== "none").map((e) => {
267
- let n = `${i || e.dataKey || "value"}`, r = Le(a, e, n);
268
- return /* @__PURE__ */ w("div", {
269
- className: q("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
270
- children: [r?.icon && !t ? /* @__PURE__ */ C(r.icon, {}) : /* @__PURE__ */ C("div", {
439
+ let n = `${i || e.dataKey || "value"}`, r = st(a, e, n);
440
+ return /* @__PURE__ */ E("div", {
441
+ className: J("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
442
+ children: [r?.icon && !t ? /* @__PURE__ */ T(r.icon, {}) : /* @__PURE__ */ T("div", {
271
443
  className: "h-2 w-2 shrink-0 rounded-[2px]",
272
444
  style: { backgroundColor: e.color }
273
445
  }), r?.label]
@@ -275,18 +447,18 @@ function K({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bot
275
447
  })
276
448
  }) : null;
277
449
  }
278
- function Le(e, t, n) {
450
+ function st(e, t, n) {
279
451
  if (typeof t != "object" || !t) return;
280
452
  let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
281
453
  return n in t && typeof t[n] == "string" ? i = t[n] : r && n in r && typeof r[n] == "string" && (i = r[n]), i in e ? e[i] : e[n];
282
454
  }
283
- var q, Re, ze, Be, J, Y, Ve = V((() => {
284
- q = (...e) => e.filter(Boolean).join(" "), Re = {
455
+ var J, Y, ct, lt, X, Z, ut = L((() => {
456
+ J = (...e) => e.filter(Boolean).join(" "), Y = {
285
457
  light: "",
286
458
  dark: ".dark"
287
- }, ze = f.createContext(null), Be = ({ id: e, config: t }) => {
459
+ }, ct = m.createContext(null), lt = ({ id: e, config: t }) => {
288
460
  let n = Object.entries(t).filter(([, e]) => e.theme || e.color);
289
- return n.length ? /* @__PURE__ */ C("style", { dangerouslySetInnerHTML: { __html: Object.entries(Re).map(([t, r]) => `
461
+ return n.length ? /* @__PURE__ */ T("style", { dangerouslySetInnerHTML: { __html: Object.entries(Y).map(([t, r]) => `
290
462
  ${r} [data-chart=${e}] {
291
463
  ${n.map(([e, n]) => {
292
464
  let r = n.theme?.[t] || n.color;
@@ -294,124 +466,168 @@ ${n.map(([e, n]) => {
294
466
  }).join("\n")}
295
467
  }
296
468
  `).join("\n") } }) : null;
297
- }, J = F, Y = k;
469
+ }, X = M, Z = k;
298
470
  }));
299
471
  //#endregion
300
472
  //#region src/chartDrillEvents.ts
301
- function He(e) {
473
+ function dt(e) {
302
474
  return e?.[0]?.dataKey || "value";
303
475
  }
304
- function Ue(e, t, n) {
476
+ function ft(e, t, n) {
305
477
  if (!e) return null;
306
478
  let r = e.payload ?? e, i = r?.[t];
307
479
  if (i == null) return null;
308
- let a = He(n);
480
+ let a = dt(n);
309
481
  return {
310
482
  category: String(i),
311
483
  series: a,
312
484
  value: typeof r?.[a] == "number" ? r[a] : void 0
313
485
  };
314
486
  }
315
- function We(e, t) {
487
+ function pt(e, t) {
316
488
  if (!e) return null;
317
489
  let n = e.name ?? e.payload?.name ?? e.root?.name;
318
490
  if (n == null) return null;
319
491
  let r = e.value ?? e.size ?? e.payload?.size;
320
492
  return {
321
493
  category: String(n),
322
- series: He(t),
494
+ series: dt(t),
323
495
  value: typeof r == "number" ? r : void 0
324
496
  };
325
497
  }
326
- function Ge(e, t) {
498
+ function mt(e, t) {
327
499
  if (!e) return null;
328
500
  let n = e.payload ?? e, r = n?.name;
329
501
  return r == null || n?.depth === 0 ? null : {
330
502
  category: String(r),
331
- series: He(t),
503
+ series: dt(t),
332
504
  value: typeof n?.value == "number" ? n.value : void 0
333
505
  };
334
506
  }
335
- var Ke = V((() => {})), qe = /* @__PURE__ */ H({ default: () => Je });
336
- function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r = "name", series: i = [], className: a = "", colors: o, categoryColors: s, onChartClick: c, isAnimationActive: l }) {
337
- let u = e === "column" ? "bar" : e, d = Array.isArray(t) ? t : [], p = l === !1 ? { isAnimationActive: !1 } : {}, [m, h] = f.useState(!1), g = f.useCallback((e) => {
338
- if (!c || !e) return;
507
+ var ht = L((() => {})), gt = /* @__PURE__ */ R({ default: () => xt });
508
+ function _t(e) {
509
+ let { x: t, y: n, width: r, height: i, name: a, fill: o } = e;
510
+ return r <= 0 || i <= 0 ? null : /* @__PURE__ */ E("g", { children: [/* @__PURE__ */ T("rect", {
511
+ x: t,
512
+ y: n,
513
+ width: r,
514
+ height: i,
515
+ fill: o,
516
+ stroke: "hsl(var(--background))",
517
+ strokeWidth: 2
518
+ }), r > 48 && i > 18 ? /* @__PURE__ */ T("text", {
519
+ x: t + 6,
520
+ y: n + 18,
521
+ fill: "#fff",
522
+ fontSize: 12,
523
+ className: "pointer-events-none",
524
+ children: a
525
+ }) : null] });
526
+ }
527
+ function vt({ title: e, subtitle: t, children: n }) {
528
+ return !e && !t ? /* @__PURE__ */ T(w, { children: n }) : /* @__PURE__ */ E("div", {
529
+ className: "flex h-full w-full flex-col",
530
+ children: [/* @__PURE__ */ E("div", {
531
+ className: "mb-2 shrink-0",
532
+ children: [e ? /* @__PURE__ */ T("div", {
533
+ className: "text-sm font-medium leading-tight text-foreground",
534
+ children: e
535
+ }) : null, t ? /* @__PURE__ */ T("div", {
536
+ className: "text-xs leading-tight text-muted-foreground",
537
+ children: t
538
+ }) : null]
539
+ }), /* @__PURE__ */ T("div", {
540
+ className: "min-h-0 flex-1",
541
+ children: n
542
+ })]
543
+ });
544
+ }
545
+ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i = "name", series: a = [], className: o = "", colors: s, categoryColors: c, categoryOrder: l, onChartClick: u, isAnimationActive: d, xAxis: f, yAxes: p, showLegend: h, showDataLabels: g, title: ee, subtitle: te, description: ne, height: _, annotations: re, interaction: v }) {
546
+ let ie = e === "column" ? "bar" : e, y = Ge(ie, a), ae = We(ie), b = Array.isArray(n) ? n : [], x = d === !1 ? { isAnimationActive: !1 } : {}, S = {
547
+ ...d === !1 ? { disableSettleRemount: !0 } : {},
548
+ ..._ ? { style: { height: _ } } : {},
549
+ ...ne ? {
550
+ role: "img",
551
+ "aria-label": ne
552
+ } : {}
553
+ }, [C, oe] = m.useState(!1), se = m.useCallback((e) => {
554
+ if (!u || !e) return;
339
555
  let t = Array.isArray(e.activePayload) ? e.activePayload[0] : void 0;
340
- c({
556
+ u({
341
557
  category: e.activeLabel == null ? void 0 : String(e.activeLabel),
342
558
  series: t?.dataKey ? String(t.dataKey) : void 0,
343
559
  value: typeof t?.value == "number" ? t.value : void 0
344
560
  });
345
- }, [c]), ee = f.useCallback((e) => {
346
- if (!c || !e) return;
347
- let t = e.payload?.[r], n = i[0]?.dataKey || "value";
348
- c({
561
+ }, [u]), ce = m.useCallback((e) => {
562
+ if (!u || !e) return;
563
+ let t = e.payload?.[i], n = a[0]?.dataKey || "value";
564
+ u({
349
565
  category: t == null ? void 0 : String(t),
350
566
  series: n,
351
567
  value: typeof e.payload?.[n] == "number" ? e.payload[n] : void 0
352
568
  });
353
569
  }, [
354
- c,
355
- r,
356
- i
357
- ]), _ = c ? {
358
- onClick: g,
570
+ u,
571
+ i,
572
+ a
573
+ ]), le = u ? {
574
+ onClick: se,
359
575
  style: { cursor: "pointer" }
360
- } : {}, te = c ? {
361
- onClick: ee,
576
+ } : {}, ue = u ? {
577
+ onClick: ce,
362
578
  style: { cursor: "pointer" }
363
- } : {}, v = f.useCallback((e, t, n) => s && s[e == null ? "" : String(e)] || n[t % n.length], [s]), ne = f.useCallback((e) => {
364
- if (!c) return;
365
- let t = Ue(e, r, i);
366
- t && c(t);
579
+ } : {}, k = m.useCallback((e, t, n) => c && c[e == null ? "" : String(e)] || n[t % n.length], [c]), A = m.useCallback((e) => {
580
+ if (!u) return;
581
+ let t = ft(e, i, a);
582
+ t && u(t);
367
583
  }, [
368
- c,
369
- r,
370
- i
371
- ]), re = f.useCallback((e) => {
372
- if (!c) return;
373
- let t = We(e, i);
374
- t && c(t);
375
- }, [c, i]), ie = f.useCallback((e) => {
376
- if (!c) return;
377
- let t = Ge(e, i);
378
- t && c(t);
379
- }, [c, i]), ae = c ? {
380
- onClick: ne,
584
+ u,
585
+ i,
586
+ a
587
+ ]), Fe = m.useCallback((e) => {
588
+ if (!u) return;
589
+ let t = pt(e, a);
590
+ t && u(t);
591
+ }, [u, a]), Ie = m.useCallback((e) => {
592
+ if (!u) return;
593
+ let t = mt(e, a);
594
+ t && u(t);
595
+ }, [u, a]), Le = u ? {
596
+ onClick: A,
381
597
  cursor: "pointer"
382
- } : {}, oe = c ? {
383
- onClick: re,
598
+ } : {}, Re = u ? {
599
+ onClick: Fe,
384
600
  style: { cursor: "pointer" }
385
- } : {}, se = c ? {
386
- onClick: ie,
601
+ } : {}, ze = u ? {
602
+ onClick: Ie,
387
603
  style: { cursor: "pointer" }
388
604
  } : {};
389
- f.useEffect(() => {
390
- let e = () => h(window.innerWidth < 640);
605
+ m.useEffect(() => {
606
+ let e = () => oe(window.innerWidth < 640);
391
607
  return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
392
608
  }, []);
393
- let ce = {
394
- bar: E,
395
- "horizontal-bar": E,
396
- line: j,
397
- area: de,
398
- pie: M,
399
- donut: M,
400
- radar: N,
401
- scatter: Ce,
402
- funnel: O,
403
- combo: E,
404
- treemap: E,
405
- sankey: E
406
- }[u] || E, le = f.useCallback((e) => {
609
+ let Be = {
610
+ bar: D,
611
+ "horizontal-bar": D,
612
+ line: xe,
613
+ area: fe,
614
+ pie: Ce,
615
+ donut: Ce,
616
+ radar: Oe,
617
+ scatter: j,
618
+ funnel: ve,
619
+ combo: ge,
620
+ treemap: D,
621
+ sankey: D
622
+ }[y] || D, Ve = m.useCallback((e) => {
407
623
  if (e == null || e === "") return "";
408
- let t = n?.[String(e)]?.label;
624
+ let t = r?.[String(e)]?.label;
409
625
  if (t != null) return String(t);
410
- let i = typeof e == "string" ? e : String(e);
411
- if (/^\d{4}-\d{2}-\d{2}/.test(i)) {
412
- let e = new Date(i);
626
+ let n = typeof e == "string" ? e : String(e);
627
+ if (/^\d{4}-\d{2}-\d{2}/.test(n)) {
628
+ let e = new Date(n);
413
629
  if (!Number.isNaN(e.getTime())) {
414
- let t = (d.length > 1 ? Math.abs(new Date(String(d[d.length - 1][r] ?? "")).getTime() - new Date(String(d[0][r] ?? "")).getTime()) : 0) / (1e3 * 60 * 60 * 24);
630
+ let t = (b.length > 1 ? Math.abs(new Date(String(b[b.length - 1][i] ?? "")).getTime() - new Date(String(b[0][i] ?? "")).getTime()) : 0) / (1e3 * 60 * 60 * 24);
415
631
  try {
416
632
  return t <= 62 ? e.toLocaleDateString(void 0, {
417
633
  month: "short",
@@ -425,19 +641,19 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
425
641
  }
426
642
  }
427
643
  }
428
- return m && i.length > 8 ? i.slice(0, 8) + "…" : i;
644
+ return C && n.length > 8 ? n.slice(0, 8) + "…" : n;
429
645
  }, [
430
- d,
431
- r,
432
- m,
433
- n
434
- ]), ue = f.useMemo(() => d.some((e) => String(e[r] || "").length > 5), [d, r]), y = () => Array.isArray(o) && o.length > 0 ? o : [
646
+ b,
647
+ i,
648
+ C,
649
+ r
650
+ ]), He = m.useMemo(() => b.some((e) => String(e[i] || "").length > 5), [b, i]), F = () => Array.isArray(s) && s.length > 0 ? s : [
435
651
  "hsl(var(--chart-1))",
436
652
  "hsl(var(--chart-2))",
437
653
  "hsl(var(--chart-3))",
438
654
  "hsl(var(--chart-4))",
439
655
  "hsl(var(--chart-5))"
440
- ], b = f.useCallback((e) => {
656
+ ], I = m.useCallback((e) => {
441
657
  if (e == null || e === "") return "";
442
658
  let t = typeof e == "number" ? e : Number(e);
443
659
  if (!Number.isFinite(t)) return String(e);
@@ -449,149 +665,255 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
449
665
  } catch {
450
666
  return String(t);
451
667
  }
452
- }, []), x = f.useMemo(() => ({
668
+ }, []), L = p?.[0], R = p && p.length > 1 ? p[1] : L?.position === "right" ? L : void 0, z = !!p && p.length > 1, B = m.useMemo(() => H(f?.format) ?? Ve, [f?.format, Ve]), V = m.useMemo(() => H(L?.format) ?? I, [L?.format, I]), Ue = m.useMemo(() => H(R?.format) ?? I, [R?.format, I]), Ze = m.useCallback((e) => {
669
+ let t = a.filter((t) => z ? (t.yAxis === "right" ? "right" : "left") === e : e === "left").map((e) => e.dataKey), n = [];
670
+ for (let e of b) for (let r of t) {
671
+ let t = Number(e?.[r]);
672
+ Number.isFinite(t) && n.push(t);
673
+ }
674
+ return n;
675
+ }, [
676
+ b,
677
+ a,
678
+ z
679
+ ]), U = m.useCallback((e, t = "left") => {
680
+ if (!e) return {};
681
+ let n = qe(e), r = Ke(e, Ze(t));
682
+ return {
683
+ ...r ? { ticks: r } : {},
684
+ ...n ? { domain: n } : {},
685
+ ...n ? { allowDataOverflow: !0 } : {},
686
+ ...e.logarithmic ? {
687
+ scale: "log",
688
+ domain: n ?? [1, "auto"]
689
+ } : {},
690
+ ...e.title ? { label: {
691
+ value: e.title,
692
+ angle: -90,
693
+ position: "insideLeft"
694
+ } } : {}
695
+ };
696
+ }, [Ze]), W = L?.showGridLines !== !1, G = {
697
+ vertical: f?.showGridLines === !0,
698
+ horizontal: W
699
+ }, Qe = h !== !1, $e = m.useMemo(() => {
700
+ if (!Array.isArray(re) || re.length === 0) return null;
701
+ let e = {
702
+ solid: void 0,
703
+ dashed: "4 4",
704
+ dotted: "1 4"
705
+ };
706
+ return re.map((t, n) => {
707
+ let r = t?.axis === "x", i = Q(String(t?.color || "hsl(var(--muted-foreground))")), a = e[String(t?.style ?? "dashed")], o = typeof t?.label == "string" ? t.label : void 0, s = o ? { label: {
708
+ value: o,
709
+ position: "insideTopRight",
710
+ fill: i,
711
+ fontSize: 11
712
+ } } : {};
713
+ return t?.type === "region" ? /* @__PURE__ */ T(ke, {
714
+ ...r ? {
715
+ x1: t.value,
716
+ x2: t.endValue
717
+ } : {
718
+ y1: t.value,
719
+ y2: t.endValue
720
+ },
721
+ ...z && !r ? { yAxisId: "left" } : {},
722
+ fill: i,
723
+ fillOpacity: .12,
724
+ stroke: i,
725
+ strokeOpacity: .35,
726
+ ...s
727
+ }, `ann-${n}`) : /* @__PURE__ */ T(Ae, {
728
+ ...r ? { x: t?.value } : { y: t?.value },
729
+ ...z && !r ? { yAxisId: "left" } : {},
730
+ stroke: i,
731
+ strokeDasharray: a,
732
+ ...s
733
+ }, `ann-${n}`);
734
+ });
735
+ }, [re, z]), et = v?.tooltips !== !1, tt = v?.brush === !0 ? /* @__PURE__ */ T(me, {
736
+ dataKey: i,
737
+ height: 24,
738
+ travellerWidth: 8,
739
+ stroke: "hsl(var(--muted-foreground))"
740
+ }) : null, K = (e) => g ? /* @__PURE__ */ T(ye, {
741
+ position: "top",
742
+ className: "fill-foreground",
743
+ fontSize: 11,
744
+ ...e ? { formatter: e } : {}
745
+ }) : null, nt = m.useMemo(() => ({
453
746
  tickLine: !1,
454
747
  tickMargin: 10,
455
748
  axisLine: !1,
456
749
  interval: "preserveStartEnd",
457
- minTickGap: m ? 32 : 48,
458
- tickFormatter: le,
459
- ...!m && ue && {
750
+ minTickGap: C ? 32 : 48,
751
+ tickFormatter: B,
752
+ ...f?.title ? { label: {
753
+ value: f.title,
754
+ position: "insideBottom",
755
+ offset: -4
756
+ } } : {},
757
+ ...!C && He && {
460
758
  angle: -35,
461
759
  textAnchor: "end",
462
760
  height: 60
463
761
  }
464
762
  }), [
465
- m,
466
- ue,
467
- le
763
+ C,
764
+ He,
765
+ B,
766
+ f?.title
468
767
  ]);
469
- if (u === "pie" || u === "donut") {
470
- let e = u === "donut" ? "52%" : 0, t = y(), o = { ...n };
471
- return d.forEach((e, n) => {
472
- let i = e?.[r];
473
- if (i == null || i === "") return;
474
- let a = String(i);
475
- o[a] || (o[a] = {
476
- label: a,
477
- color: v(i, n, t)
768
+ if (y && Ye.has(y)) {
769
+ let e = a[0]?.dataKey || "value", t = b[0]?.[e], n = typeof t == "number" ? t : Number(t), i = a[0]?.label ?? r?.[e]?.label ?? e;
770
+ return /* @__PURE__ */ T("div", {
771
+ className: o,
772
+ "data-testid": "advanced-chart-single-value",
773
+ children: /* @__PURE__ */ E("div", {
774
+ className: "flex flex-col gap-1 py-4",
775
+ children: [/* @__PURE__ */ T("span", {
776
+ className: "text-3xl font-semibold tabular-nums",
777
+ children: Number.isFinite(n) ? new Intl.NumberFormat().format(n) : String(t ?? "—")
778
+ }), /* @__PURE__ */ T("span", {
779
+ className: "text-xs text-muted-foreground",
780
+ children: String(i)
781
+ })]
782
+ })
783
+ });
784
+ }
785
+ if (y && Xe.has(y)) return /* @__PURE__ */ E("div", {
786
+ className: `rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${o ?? ""}`,
787
+ "data-testid": "advanced-chart-tabular-notice",
788
+ role: "note",
789
+ children: [
790
+ "Chart type “",
791
+ y,
792
+ "” is tabular — render it with the data-table / pivot components; a chart block draws series charts."
793
+ ]
794
+ });
795
+ if (y && !Je.has(y)) return /* @__PURE__ */ E("div", {
796
+ className: `rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${o ?? ""}`,
797
+ "data-testid": "advanced-chart-unknown-type",
798
+ role: "note",
799
+ children: [
800
+ "Chart type “",
801
+ y,
802
+ "” is not a spec chart type — nothing was drawn."
803
+ ]
804
+ });
805
+ if (y === "pie" || y === "donut") {
806
+ let e = y === "donut" ? "52%" : 0, t = F(), n = { ...r };
807
+ return b.forEach((e, r) => {
808
+ let a = e?.[i];
809
+ if (a == null || a === "") return;
810
+ let o = String(a);
811
+ n[o] || (n[o] = {
812
+ label: o,
813
+ color: k(a, r, t)
478
814
  });
479
- }), /* @__PURE__ */ C(W, {
480
- config: o,
481
- className: a,
482
- children: /* @__PURE__ */ w(M, { children: [
483
- /* @__PURE__ */ C(J, {
815
+ }), /* @__PURE__ */ T(q, {
816
+ config: n,
817
+ className: o,
818
+ ...S,
819
+ children: /* @__PURE__ */ E(Ce, { children: [
820
+ /* @__PURE__ */ T(X, {
484
821
  cursor: !1,
485
- content: /* @__PURE__ */ C(G, { hideLabel: !0 })
822
+ content: /* @__PURE__ */ T(at, { hideLabel: !0 })
486
823
  }),
487
- /* @__PURE__ */ C(ge, {
488
- data: d,
489
- dataKey: i[0]?.dataKey || "value",
490
- nameKey: r || "name",
824
+ /* @__PURE__ */ T(Se, {
825
+ data: b,
826
+ dataKey: a[0]?.dataKey || "value",
827
+ nameKey: i || "name",
491
828
  innerRadius: e,
492
829
  strokeWidth: 5,
493
830
  paddingAngle: 2,
494
831
  outerRadius: "85%",
495
- ...p,
496
- ...te,
497
- children: d.map((e, n) => {
498
- let i = v(e?.[r], n, t);
499
- return /* @__PURE__ */ C(pe, { fill: Z(i) }, `cell-${n}`);
832
+ ...x,
833
+ ...ue,
834
+ children: b.map((e, n) => {
835
+ let r = k(e?.[i], n, t);
836
+ return /* @__PURE__ */ T(O, { fill: Q(r) }, `cell-${n}`);
500
837
  })
501
838
  }),
502
- /* @__PURE__ */ C(Y, {
839
+ /* @__PURE__ */ T(Z, {
503
840
  verticalAlign: "bottom",
504
841
  wrapperStyle: {
505
- fontSize: m ? "11px" : "12px",
842
+ fontSize: C ? "11px" : "12px",
506
843
  paddingTop: "8px"
507
844
  },
508
- content: /* @__PURE__ */ C(K, {
509
- nameKey: r,
845
+ content: /* @__PURE__ */ T(ot, {
846
+ nameKey: i,
510
847
  className: "flex-wrap"
511
848
  })
512
849
  })
513
850
  ] })
514
851
  });
515
852
  }
516
- if (u === "funnel") {
517
- let e = i[0]?.dataKey || "value", t = y(), o = c ? (t) => {
518
- t && c({
519
- category: t?.payload?.[r] ?? t?.[r],
853
+ if (y === "funnel") {
854
+ let e = a[0]?.dataKey || "value", n = F(), s = u ? (t) => {
855
+ t && u({
856
+ category: t?.payload?.[i] ?? t?.[i],
520
857
  value: t?.payload?.[e] ?? t?.[e]
521
858
  });
522
- } : void 0, s = o ? {
523
- onClick: o,
859
+ } : void 0, c = s ? {
860
+ onClick: s,
524
861
  style: { cursor: "pointer" }
525
- } : {}, l = [...d].sort((t, n) => {
862
+ } : {}, d = t(l), f = d ? [...b].sort((e, t) => (d.get(String(e?.[i] ?? "")) ?? 2 ** 53 - 1) - (d.get(String(t?.[i] ?? "")) ?? 2 ** 53 - 1)) : [...b].sort((t, n) => {
526
863
  let r = Number(t?.[e] ?? 0);
527
864
  return Number(n?.[e] ?? 0) - r;
528
865
  });
529
- return /* @__PURE__ */ C(W, {
530
- config: n,
531
- className: a,
532
- children: /* @__PURE__ */ w(O, { children: [/* @__PURE__ */ C(J, { content: /* @__PURE__ */ C(G, {}) }), /* @__PURE__ */ w(me, {
866
+ return /* @__PURE__ */ T(q, {
867
+ config: r,
868
+ className: o,
869
+ ...S,
870
+ children: /* @__PURE__ */ E(ve, { children: [/* @__PURE__ */ T(X, { content: /* @__PURE__ */ T(at, {}) }), /* @__PURE__ */ E(_e, {
533
871
  dataKey: e,
534
- data: l,
535
- nameKey: r,
536
- isAnimationActive: !0,
537
- ...s,
538
- children: [/* @__PURE__ */ C(he, {
872
+ data: f,
873
+ nameKey: i,
874
+ ...x,
875
+ ...c,
876
+ children: [/* @__PURE__ */ T(ye, {
539
877
  position: "right",
540
878
  fill: "hsl(var(--foreground))",
541
879
  stroke: "none",
542
- dataKey: r
543
- }), l.map((e, n) => /* @__PURE__ */ C(pe, { fill: Z(t[n % t.length]) }, `funnel-cell-${n}`))]
880
+ dataKey: i
881
+ }), f.map((e, t) => /* @__PURE__ */ T(O, { fill: Q(n[t % n.length]) }, `funnel-cell-${t}`))]
544
882
  })] })
545
883
  });
546
884
  }
547
- if (u === "treemap") {
548
- let e = i[0]?.dataKey || "value", t = y();
549
- return /* @__PURE__ */ C(W, {
550
- config: n,
551
- className: a,
552
- children: /* @__PURE__ */ C(we, {
553
- data: d.map((n, i) => ({
554
- name: String(n?.[r] ?? ""),
555
- size: Number(n?.[e]) || 0,
556
- fill: Z(t[i % t.length])
557
- })),
885
+ if (y === "treemap") {
886
+ let e = a[0]?.dataKey || "value", t = F(), n = b.map((n, r) => ({
887
+ name: String(n?.[i] ?? ""),
888
+ size: Number(n?.[e]) || 0,
889
+ fill: Q(t[r % t.length])
890
+ }));
891
+ return /* @__PURE__ */ T(q, {
892
+ config: r,
893
+ className: o,
894
+ ...S,
895
+ children: /* @__PURE__ */ T(Ne, {
896
+ data: n,
558
897
  dataKey: "size",
559
898
  nameKey: "name",
560
- isAnimationActive: !0,
561
- content: /* @__PURE__ */ C((e) => {
562
- let { x: t, y: n, width: r, height: i, name: a, fill: o } = e;
563
- return r <= 0 || i <= 0 ? null : /* @__PURE__ */ w("g", { children: [/* @__PURE__ */ C("rect", {
564
- x: t,
565
- y: n,
566
- width: r,
567
- height: i,
568
- fill: o,
569
- stroke: "hsl(var(--background))",
570
- strokeWidth: 2
571
- }), r > 48 && i > 18 ? /* @__PURE__ */ C("text", {
572
- x: t + 6,
573
- y: n + 18,
574
- fill: "#fff",
575
- fontSize: 12,
576
- className: "pointer-events-none",
577
- children: a
578
- }) : null] });
579
- }, {}),
580
- ...oe,
581
- children: /* @__PURE__ */ C(F, {})
899
+ ...x,
900
+ content: /* @__PURE__ */ T(_t, {}),
901
+ ...Re,
902
+ children: /* @__PURE__ */ T(M, {})
582
903
  })
583
904
  });
584
905
  }
585
- if (u === "sankey") {
586
- let e = i[0]?.dataKey || "value", t = i[0]?.label || e, o = d.filter((t) => (Number(t?.[e]) || 0) > 0), s = [{ name: t }, ...o.map((e) => ({ name: String(e?.[r] ?? "") }))], c = o.map((t, n) => ({
906
+ if (y === "sankey") {
907
+ let e = a[0]?.dataKey || "value", t = a[0]?.label || e, n = b.filter((t) => (Number(t?.[e]) || 0) > 0), s = [{ name: t }, ...n.map((e) => ({ name: String(e?.[i] ?? "") }))], c = n.map((t, n) => ({
587
908
  source: 0,
588
909
  target: n + 1,
589
910
  value: Number(t?.[e]) || 0
590
911
  }));
591
- return c.length === 0 ? /* @__PURE__ */ C("div", { className: a }) : /* @__PURE__ */ C(W, {
592
- config: n,
593
- className: a,
594
- children: /* @__PURE__ */ C(xe, {
912
+ return c.length === 0 ? /* @__PURE__ */ T("div", { className: o }) : /* @__PURE__ */ T(q, {
913
+ config: r,
914
+ className: o,
915
+ ...S,
916
+ children: /* @__PURE__ */ T(je, {
595
917
  data: {
596
918
  nodes: s,
597
919
  links: c
@@ -602,24 +924,25 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
602
924
  strokeOpacity: .25
603
925
  },
604
926
  node: { fill: "hsl(var(--chart-1))" },
605
- ...se,
606
- children: /* @__PURE__ */ C(F, {})
927
+ ...ze,
928
+ children: /* @__PURE__ */ T(M, {})
607
929
  })
608
930
  });
609
931
  }
610
- if (u === "radar") return /* @__PURE__ */ C(W, {
611
- config: n,
612
- className: a,
613
- children: /* @__PURE__ */ w(N, {
614
- data: d,
932
+ if (y === "radar") return /* @__PURE__ */ T(q, {
933
+ config: r,
934
+ className: o,
935
+ ...S,
936
+ children: /* @__PURE__ */ E(Oe, {
937
+ data: b,
615
938
  children: [
616
- /* @__PURE__ */ C(ve, {}),
617
- /* @__PURE__ */ C(_e, { dataKey: r }),
618
- /* @__PURE__ */ C(ye, {}),
619
- /* @__PURE__ */ C(J, { content: /* @__PURE__ */ C(G, {}) }),
620
- /* @__PURE__ */ C(Y, {
621
- content: /* @__PURE__ */ C(K, {}),
622
- ...m && {
939
+ /* @__PURE__ */ T(Te, {}),
940
+ /* @__PURE__ */ T(we, { dataKey: i }),
941
+ /* @__PURE__ */ T(Ee, {}),
942
+ /* @__PURE__ */ T(X, { content: /* @__PURE__ */ T(at, {}) }),
943
+ /* @__PURE__ */ T(Z, {
944
+ content: /* @__PURE__ */ T(ot, {}),
945
+ ...C && {
623
946
  verticalAlign: "bottom",
624
947
  wrapperStyle: {
625
948
  fontSize: "11px",
@@ -627,48 +950,50 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
627
950
  }
628
951
  }
629
952
  }),
630
- i.map((e) => {
631
- let t = Z(n[e.dataKey]?.color || X);
632
- return /* @__PURE__ */ C(be, {
953
+ a.map((e) => {
954
+ let t = Q(r[e.dataKey]?.color || St);
955
+ return /* @__PURE__ */ T(De, {
633
956
  dataKey: e.dataKey,
634
957
  stroke: t,
635
958
  fill: t,
636
- fillOpacity: .6
959
+ fillOpacity: .6,
960
+ ...x
637
961
  }, e.dataKey);
638
962
  })
639
963
  ]
640
964
  })
641
965
  });
642
- if (u === "scatter") return /* @__PURE__ */ C(W, {
643
- config: n,
644
- className: a,
645
- children: /* @__PURE__ */ w(Ce, { children: [
646
- /* @__PURE__ */ C(D, { vertical: !1 }),
647
- /* @__PURE__ */ C(I, {
966
+ if (y === "scatter") return /* @__PURE__ */ T(q, {
967
+ config: r,
968
+ className: o,
969
+ ...S,
970
+ children: /* @__PURE__ */ E(j, { children: [
971
+ /* @__PURE__ */ T(he, { vertical: !1 }),
972
+ /* @__PURE__ */ T(N, {
648
973
  type: "number",
649
- dataKey: r,
650
- name: String(n[r]?.label || r),
974
+ dataKey: i,
975
+ name: String(r[i]?.label || i),
651
976
  tickLine: !1,
652
977
  axisLine: !1,
653
- minTickGap: m ? 32 : 48
978
+ minTickGap: C ? 32 : 48
654
979
  }),
655
- /* @__PURE__ */ C(L, {
980
+ /* @__PURE__ */ T(P, {
656
981
  type: "number",
657
- dataKey: i[0]?.dataKey || "value",
658
- name: String(n[i[0]?.dataKey]?.label || i[0]?.dataKey),
982
+ dataKey: a[0]?.dataKey || "value",
983
+ name: String(r[a[0]?.dataKey]?.label || a[0]?.dataKey),
659
984
  tickLine: !1,
660
985
  axisLine: !1,
661
- tickFormatter: b,
986
+ tickFormatter: I,
662
987
  width: 48
663
988
  }),
664
- /* @__PURE__ */ C(R, {
989
+ /* @__PURE__ */ T(Pe, {
665
990
  type: "number",
666
991
  range: [60, 400]
667
992
  }),
668
- /* @__PURE__ */ C(J, { content: /* @__PURE__ */ C(G, {}) }),
669
- /* @__PURE__ */ C(Y, {
670
- content: /* @__PURE__ */ C(K, {}),
671
- ...m && {
993
+ /* @__PURE__ */ T(X, { content: /* @__PURE__ */ T(at, {}) }),
994
+ /* @__PURE__ */ T(Z, {
995
+ content: /* @__PURE__ */ T(ot, {}),
996
+ ...C && {
672
997
  verticalAlign: "bottom",
673
998
  wrapperStyle: {
674
999
  fontSize: "11px",
@@ -676,214 +1001,285 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
676
1001
  }
677
1002
  }
678
1003
  }),
679
- i.map((e, t) => {
680
- let r = y(), i = Z(n[e.dataKey]?.color || r[t % r.length]), a = Q(e, "scatter");
681
- return /* @__PURE__ */ C(Se, {
682
- name: n[e.dataKey]?.label || e.dataKey,
683
- data: d,
1004
+ a.map((e, t) => {
1005
+ let n = F(), i = Q(r[e.dataKey]?.color || n[t % n.length]), a = wt(e, "scatter");
1006
+ return /* @__PURE__ */ T(Me, {
1007
+ name: r[e.dataKey]?.label || e.dataKey,
1008
+ data: b,
684
1009
  fill: i,
685
1010
  fillOpacity: a?.fillOpacity,
686
- ...ae
1011
+ ...x,
1012
+ ...Le
687
1013
  }, e.dataKey);
688
1014
  })
689
1015
  ] })
690
1016
  });
691
- if (u === "combo") return /* @__PURE__ */ C(W, {
692
- config: n,
693
- className: a,
694
- children: /* @__PURE__ */ w(E, {
695
- data: d,
696
- children: [
697
- /* @__PURE__ */ C(D, { vertical: !1 }),
698
- /* @__PURE__ */ C(I, {
699
- dataKey: r,
700
- ...x
701
- }),
702
- /* @__PURE__ */ C(L, {
703
- yAxisId: "left",
704
- tickLine: !1,
705
- axisLine: !1,
706
- tickFormatter: b,
707
- width: 48
708
- }),
709
- /* @__PURE__ */ C(L, {
710
- yAxisId: "right",
711
- orientation: "right",
712
- tickLine: !1,
713
- axisLine: !1,
714
- tickFormatter: b,
715
- width: 48
716
- }),
717
- /* @__PURE__ */ C(J, { content: /* @__PURE__ */ C(G, {}) }),
718
- /* @__PURE__ */ C(Y, {
719
- content: /* @__PURE__ */ C(K, {}),
720
- ...m && {
721
- verticalAlign: "bottom",
722
- wrapperStyle: {
723
- fontSize: "11px",
724
- paddingTop: "8px"
725
- }
726
- }
727
- }),
728
- i.map((e, t) => {
729
- let r = Z(n[e.dataKey]?.color || X), i = e.chartType || (t === 0 ? "bar" : "line"), a = i === "bar" ? "left" : "right", o = Q(e, i);
730
- return i === "line" ? /* @__PURE__ */ C(A, {
731
- yAxisId: a,
732
- type: "monotone",
733
- dataKey: e.dataKey,
734
- stroke: r,
735
- strokeWidth: 2,
736
- dot: !1,
737
- strokeOpacity: o?.strokeOpacity,
738
- strokeDasharray: o?.strokeDasharray,
739
- ...p
740
- }, e.dataKey) : i === "area" ? /* @__PURE__ */ C(T, {
741
- yAxisId: a,
742
- type: "monotone",
743
- dataKey: e.dataKey,
744
- fill: r,
745
- stroke: r,
746
- fillOpacity: o?.fillOpacity ?? .4,
747
- strokeOpacity: o?.strokeOpacity,
748
- strokeDasharray: o?.strokeDasharray,
749
- ...p
750
- }, e.dataKey) : /* @__PURE__ */ C(fe, {
751
- yAxisId: a,
752
- dataKey: e.dataKey,
753
- fill: r,
754
- radius: 4,
755
- fillOpacity: o?.fillOpacity,
756
- ...p
757
- }, e.dataKey);
758
- })
759
- ]
760
- })
761
- });
762
- let k = u === "horizontal-bar", P = y(), Te = s ? Object.values(s).map((e) => Z(String(e))) : [], Ee = Array.from(/* @__PURE__ */ new Set([
763
- ...P,
764
- ...Te,
765
- ...i.map((e, t) => Z(n[e.dataKey]?.color || P[t % P.length] || X))
766
- ])), z = (e) => "g" + e.replace(/[^a-zA-Z0-9]/g, "");
767
- return /* @__PURE__ */ C(W, {
768
- config: n,
769
- className: a,
770
- children: /* @__PURE__ */ w(ce, {
771
- data: d,
772
- layout: k ? "vertical" : "horizontal",
773
- ..._,
774
- children: [
775
- /* @__PURE__ */ C("defs", { children: Ee.map((e) => /* @__PURE__ */ w(f.Fragment, { children: [/* @__PURE__ */ w("linearGradient", {
776
- id: `bg-${z(e)}`,
777
- x1: "0",
778
- y1: "0",
779
- x2: "0",
780
- y2: "1",
781
- children: [/* @__PURE__ */ C("stop", {
782
- offset: "0%",
783
- style: { stopColor: e },
784
- stopOpacity: .95
785
- }), /* @__PURE__ */ C("stop", {
786
- offset: "100%",
787
- style: { stopColor: e },
788
- stopOpacity: .5
789
- })]
790
- }), /* @__PURE__ */ w("linearGradient", {
791
- id: `ag-${z(e)}`,
792
- x1: "0",
793
- y1: "0",
794
- x2: "0",
795
- y2: "1",
796
- children: [/* @__PURE__ */ C("stop", {
797
- offset: "0%",
798
- style: { stopColor: e },
799
- stopOpacity: .5
800
- }), /* @__PURE__ */ C("stop", {
801
- offset: "95%",
802
- style: { stopColor: e },
803
- stopOpacity: .05
804
- })]
805
- })] }, z(e))) }),
806
- /* @__PURE__ */ C(D, { vertical: !1 }),
807
- k ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(I, {
808
- type: "number",
809
- tickLine: !1,
810
- axisLine: !1,
811
- tickFormatter: b
812
- }), /* @__PURE__ */ C(L, {
813
- type: "category",
814
- dataKey: r,
815
- tickLine: !1,
816
- axisLine: !1,
817
- width: Math.min(140, Math.max(60, Math.max(...d.map((e) => String(e[r] ?? "").length)) * 7)),
818
- tickFormatter: le
819
- })] }) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(I, {
820
- dataKey: r,
821
- ...x
822
- }), /* @__PURE__ */ C(L, {
823
- tickLine: !1,
824
- axisLine: !1,
825
- tickFormatter: b,
826
- width: 48
827
- })] }),
828
- /* @__PURE__ */ C(J, { content: /* @__PURE__ */ C(G, {}) }),
829
- /* @__PURE__ */ C(Y, {
830
- content: /* @__PURE__ */ C(K, {}),
831
- ...m && {
832
- verticalAlign: "bottom",
833
- wrapperStyle: {
834
- fontSize: "11px",
835
- paddingTop: "8px"
1017
+ if (y === "combo") return /* @__PURE__ */ T(vt, {
1018
+ title: ee,
1019
+ subtitle: te,
1020
+ children: /* @__PURE__ */ T(q, {
1021
+ config: r,
1022
+ className: o,
1023
+ ...S,
1024
+ children: /* @__PURE__ */ E(ge, {
1025
+ data: b,
1026
+ children: [
1027
+ /* @__PURE__ */ T(he, { ...G }),
1028
+ /* @__PURE__ */ T(N, {
1029
+ dataKey: i,
1030
+ ...nt
1031
+ }),
1032
+ /* @__PURE__ */ T(P, {
1033
+ yAxisId: "left",
1034
+ tickLine: !1,
1035
+ axisLine: !1,
1036
+ tickFormatter: V,
1037
+ width: 48,
1038
+ ...U(L)
1039
+ }),
1040
+ /* @__PURE__ */ T(P, {
1041
+ yAxisId: "right",
1042
+ orientation: "right",
1043
+ tickLine: !1,
1044
+ axisLine: !1,
1045
+ tickFormatter: Ue,
1046
+ width: 48,
1047
+ ...U(R, "right")
1048
+ }),
1049
+ et ? /* @__PURE__ */ T(X, { content: /* @__PURE__ */ T(at, {}) }) : null,
1050
+ Qe ? /* @__PURE__ */ T(Z, {
1051
+ content: /* @__PURE__ */ T(ot, {}),
1052
+ ...C && {
1053
+ verticalAlign: "bottom",
1054
+ wrapperStyle: {
1055
+ fontSize: "11px",
1056
+ paddingTop: "8px"
1057
+ }
836
1058
  }
837
- }
838
- }),
839
- i.map((e, t) => {
840
- let a = y(), o = e.variant === "comparison", s = o ? i.slice(0, t).find((e) => e.variant !== "comparison") || i[0] : e, c = o ? i.indexOf(s) : t, l = Z(n[s.dataKey]?.color || a[c % a.length] || X);
841
- if (u === "bar" || u === "horizontal-bar") {
842
- let t = i.filter((e) => e.variant !== "comparison").length === 1 && !o && i.length === 1 && d.length > 1, n = Q(e, "bar");
843
- return /* @__PURE__ */ C(fe, {
844
- dataKey: e.dataKey,
845
- fill: `url(#bg-${z(l)})`,
846
- radius: 4,
847
- fillOpacity: n?.fillOpacity,
848
- ...p,
849
- children: t && d.map((e, t) => /* @__PURE__ */ C(pe, { fill: `url(#bg-${z(Z(v(e?.[r], t, a)))})` }, `cell-${t}`))
850
- }, e.dataKey);
851
- }
852
- if (u === "line") {
853
- let t = Q(e, "line");
854
- return /* @__PURE__ */ C(A, {
1059
+ }) : null,
1060
+ $e,
1061
+ tt,
1062
+ a.map((e, t) => {
1063
+ let n = Q(r[e.dataKey]?.color || St), i = e.chartType || ae || (t === 0 ? "bar" : "line"), a = e.yAxis === "right" || e.yAxis === "left" ? e.yAxis : ae || i === "bar" ? "left" : "right", o = wt(e, i), s = e.stack ? { stackId: String(e.stack) } : {}, c = H((a === "right" ? R : L)?.format);
1064
+ return i === "line" ? /* @__PURE__ */ T(be, {
1065
+ yAxisId: a,
855
1066
  type: "monotone",
856
1067
  dataKey: e.dataKey,
857
- stroke: l,
1068
+ stroke: n,
858
1069
  strokeWidth: 2,
859
1070
  dot: !1,
860
- strokeOpacity: t?.strokeOpacity,
861
- strokeDasharray: t?.strokeDasharray,
862
- ...p
863
- }, e.dataKey);
864
- }
865
- if (u === "area") {
866
- let t = Q(e, "area");
867
- return /* @__PURE__ */ C(T, {
1071
+ strokeOpacity: o?.strokeOpacity,
1072
+ strokeDasharray: o?.strokeDasharray,
1073
+ ...x,
1074
+ children: K(c)
1075
+ }, e.dataKey) : i === "area" ? /* @__PURE__ */ T(de, {
1076
+ yAxisId: a,
868
1077
  type: "monotone",
869
1078
  dataKey: e.dataKey,
870
- fill: `url(#ag-${z(l)})`,
871
- stroke: l,
872
- strokeWidth: 2,
873
- fillOpacity: t?.fillOpacity ?? 1,
874
- strokeOpacity: t?.strokeOpacity,
875
- strokeDasharray: t?.strokeDasharray,
876
- ...p
1079
+ fill: n,
1080
+ stroke: n,
1081
+ fillOpacity: o?.fillOpacity ?? .4,
1082
+ strokeOpacity: o?.strokeOpacity,
1083
+ strokeDasharray: o?.strokeDasharray,
1084
+ ...s,
1085
+ ...x,
1086
+ children: K(c)
1087
+ }, e.dataKey) : /* @__PURE__ */ T(pe, {
1088
+ yAxisId: a,
1089
+ dataKey: e.dataKey,
1090
+ fill: n,
1091
+ radius: 4,
1092
+ fillOpacity: o?.fillOpacity,
1093
+ ...s,
1094
+ ...x,
1095
+ children: K(c)
877
1096
  }, e.dataKey);
878
- }
879
- return null;
880
- })
881
- ]
1097
+ })
1098
+ ]
1099
+ })
882
1100
  })
883
1101
  });
1102
+ let rt = y === "horizontal-bar", it = F(), st = c ? Object.values(c).map((e) => Q(String(e))) : [], J = Array.from(/* @__PURE__ */ new Set([
1103
+ ...it,
1104
+ ...st,
1105
+ ...a.map((e, t) => Q(r[e.dataKey]?.color || it[t % it.length] || St))
1106
+ ])), Y = (e) => "g" + e.replace(/[^a-zA-Z0-9]/g, "");
1107
+ return /* @__PURE__ */ T(vt, {
1108
+ title: ee,
1109
+ subtitle: te,
1110
+ children: /* @__PURE__ */ T(q, {
1111
+ config: r,
1112
+ className: o,
1113
+ ...S,
1114
+ children: /* @__PURE__ */ E(Be, {
1115
+ data: b,
1116
+ layout: rt ? "vertical" : "horizontal",
1117
+ ...le,
1118
+ children: [
1119
+ /* @__PURE__ */ T("defs", { children: J.map((e) => /* @__PURE__ */ E(m.Fragment, { children: [/* @__PURE__ */ E("linearGradient", {
1120
+ id: `bg-${Y(e)}`,
1121
+ x1: "0",
1122
+ y1: "0",
1123
+ x2: "0",
1124
+ y2: "1",
1125
+ children: [/* @__PURE__ */ T("stop", {
1126
+ offset: "0%",
1127
+ style: { stopColor: e },
1128
+ stopOpacity: .95
1129
+ }), /* @__PURE__ */ T("stop", {
1130
+ offset: "100%",
1131
+ style: { stopColor: e },
1132
+ stopOpacity: .5
1133
+ })]
1134
+ }), /* @__PURE__ */ E("linearGradient", {
1135
+ id: `ag-${Y(e)}`,
1136
+ x1: "0",
1137
+ y1: "0",
1138
+ x2: "0",
1139
+ y2: "1",
1140
+ children: [/* @__PURE__ */ T("stop", {
1141
+ offset: "0%",
1142
+ style: { stopColor: e },
1143
+ stopOpacity: .5
1144
+ }), /* @__PURE__ */ T("stop", {
1145
+ offset: "95%",
1146
+ style: { stopColor: e },
1147
+ stopOpacity: .05
1148
+ })]
1149
+ })] }, Y(e))) }),
1150
+ /* @__PURE__ */ T(he, { ...G }),
1151
+ rt ? /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ T(N, {
1152
+ type: "number",
1153
+ tickLine: !1,
1154
+ axisLine: !1,
1155
+ tickFormatter: V,
1156
+ ...U(L)
1157
+ }), /* @__PURE__ */ T(P, {
1158
+ type: "category",
1159
+ dataKey: i,
1160
+ tickLine: !1,
1161
+ axisLine: !1,
1162
+ width: Math.min(140, Math.max(60, Math.max(...b.map((e) => String(e[i] ?? "").length)) * 7)),
1163
+ tickFormatter: B
1164
+ })] }) : /* @__PURE__ */ E(w, { children: [
1165
+ /* @__PURE__ */ T(N, {
1166
+ dataKey: i,
1167
+ ...nt
1168
+ }),
1169
+ /* @__PURE__ */ T(P, {
1170
+ ...z ? { yAxisId: "left" } : {},
1171
+ tickLine: !1,
1172
+ axisLine: !1,
1173
+ tickFormatter: V,
1174
+ width: 48,
1175
+ ...U(L)
1176
+ }),
1177
+ z ? /* @__PURE__ */ T(P, {
1178
+ yAxisId: "right",
1179
+ orientation: "right",
1180
+ tickLine: !1,
1181
+ axisLine: !1,
1182
+ tickFormatter: Ue,
1183
+ width: 48,
1184
+ ...U(R, "right")
1185
+ }) : null
1186
+ ] }),
1187
+ et ? /* @__PURE__ */ T(X, { content: /* @__PURE__ */ T(at, {}) }) : null,
1188
+ Qe ? /* @__PURE__ */ T(Z, {
1189
+ content: /* @__PURE__ */ T(ot, {}),
1190
+ ...C && {
1191
+ verticalAlign: "bottom",
1192
+ wrapperStyle: {
1193
+ fontSize: "11px",
1194
+ paddingTop: "8px"
1195
+ }
1196
+ }
1197
+ }) : null,
1198
+ $e,
1199
+ tt,
1200
+ a.map((e, t) => {
1201
+ let n = F(), o = e.variant === "comparison", s = o ? a.slice(0, t).find((e) => e.variant !== "comparison") || a[0] : e, c = o ? a.indexOf(s) : t, l = Q(r[s.dataKey]?.color || n[c % n.length] || St), u = z ? { yAxisId: e.yAxis === "right" ? "right" : "left" } : {}, d = e.stack ? { stackId: String(e.stack) } : {}, f = H((e.yAxis === "right" ? R : L)?.format);
1202
+ if (y === "bar" || y === "horizontal-bar") {
1203
+ let t = a.filter((e) => e.variant !== "comparison").length === 1 && !o && a.length === 1 && b.length > 1, r = wt(e, "bar");
1204
+ return /* @__PURE__ */ E(pe, {
1205
+ dataKey: e.dataKey,
1206
+ fill: `url(#bg-${Y(l)})`,
1207
+ radius: 4,
1208
+ fillOpacity: r?.fillOpacity,
1209
+ ...d,
1210
+ ...u,
1211
+ ...x,
1212
+ children: [t && b.map((e, t) => /* @__PURE__ */ T(O, { fill: `url(#bg-${Y(Q(k(e?.[i], t, n)))})` }, `cell-${t}`)), K(f)]
1213
+ }, e.dataKey);
1214
+ }
1215
+ if (y === "line") {
1216
+ let t = wt(e, "line");
1217
+ return /* @__PURE__ */ T(be, {
1218
+ type: "monotone",
1219
+ dataKey: e.dataKey,
1220
+ stroke: l,
1221
+ strokeWidth: 2,
1222
+ dot: !1,
1223
+ strokeOpacity: t?.strokeOpacity,
1224
+ strokeDasharray: t?.strokeDasharray,
1225
+ ...u,
1226
+ ...x,
1227
+ children: K(f)
1228
+ }, e.dataKey);
1229
+ }
1230
+ if (y === "area") {
1231
+ let t = wt(e, "area");
1232
+ return /* @__PURE__ */ T(de, {
1233
+ type: "monotone",
1234
+ dataKey: e.dataKey,
1235
+ fill: `url(#ag-${Y(l)})`,
1236
+ stroke: l,
1237
+ strokeWidth: 2,
1238
+ fillOpacity: t?.fillOpacity ?? 1,
1239
+ strokeOpacity: t?.strokeOpacity,
1240
+ strokeDasharray: t?.strokeDasharray,
1241
+ ...d,
1242
+ ...u,
1243
+ ...x,
1244
+ children: K(f)
1245
+ }, e.dataKey);
1246
+ }
1247
+ return null;
1248
+ })
1249
+ ]
1250
+ })
1251
+ })
1252
+ });
1253
+ }
1254
+ function bt(e) {
1255
+ let t = e.chartType === "column" ? "bar" : e.chartType ?? "bar", n = Array.isArray(e.data) ? e.data : [], r = e.xAxisKey ?? "name";
1256
+ return Tt.has(t) && n.length > 0 && !n.some((e) => typeof e == "object" && !!e && r in e);
1257
+ }
1258
+ function xt(e) {
1259
+ let t = bt(e), n = e.xAxisKey ?? "name", r = m.useMemo(() => Object.keys((Array.isArray(e.data) ? e.data[0] : void 0) ?? {}), [e.data]);
1260
+ return m.useEffect(() => {
1261
+ t && console.warn(`[chart] no row has the category key "${n}" — rendering an explanatory placeholder instead of an empty axis. Row keys: ${JSON.stringify(r)}. A dataset query must PROJECT the dimension it groups by (framework#4033).`);
1262
+ }, [
1263
+ t,
1264
+ n,
1265
+ r
1266
+ ]), t ? /* @__PURE__ */ T("div", {
1267
+ className: `flex h-full min-h-[120px] w-full items-center justify-center p-4 text-center text-sm text-muted-foreground ${e.className ?? ""}`,
1268
+ role: "status",
1269
+ "data-chart-error": "missing-category-key",
1270
+ children: /* @__PURE__ */ E("span", { children: [
1271
+ "This chart cannot plot its category axis: no row has a",
1272
+ " ",
1273
+ /* @__PURE__ */ T("code", {
1274
+ className: "font-mono",
1275
+ children: n
1276
+ }),
1277
+ " field."
1278
+ ] })
1279
+ }) : /* @__PURE__ */ T(yt, { ...e });
884
1280
  }
885
- var X, Ye, Z, Q, Xe = V((() => {
886
- Ve(), Ke(), X = "hsl(var(--primary))", Ye = {
1281
+ var St, Ct, Q, wt, Tt, Et = L((() => {
1282
+ ut(), ht(), $e(), St = "hsl(var(--primary))", Ct = {
887
1283
  slate: "#64748b",
888
1284
  gray: "#6b7280",
889
1285
  zinc: "#71717a",
@@ -906,14 +1302,28 @@ var X, Ye, Z, Q, Xe = V((() => {
906
1302
  fuchsia: "#d946ef",
907
1303
  pink: "#ec4899",
908
1304
  rose: "#f43f5e"
909
- }, Z = (e) => Ye[e] || e, Q = (e, t) => e?.variant === "comparison" ? {
1305
+ }, Q = (e) => Ct[e] || e, wt = (e, t) => e?.variant === "comparison" ? {
910
1306
  strokeOpacity: typeof e.opacity == "number" ? e.opacity : t === "line" || t === "scatter" ? .5 : .6,
911
1307
  fillOpacity: typeof e.opacity == "number" ? e.opacity : t === "bar" ? .4 : t === "area" ? .2 : .5,
912
1308
  strokeDasharray: e.dashArray ?? (t === "line" || t === "area" ? "4 4" : void 0)
913
- } : null;
914
- })), Ze = p.lazy(() => Promise.resolve().then(() => (Fe(), Me))), Qe = p.lazy(() => Promise.resolve().then(() => (Xe(), qe))), $e = ({ schema: e }) => /* @__PURE__ */ C(m, {
915
- fallback: /* @__PURE__ */ C(x, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
916
- children: /* @__PURE__ */ C(Ze, {
1309
+ } : null, Tt = /* @__PURE__ */ new Set([
1310
+ "bar",
1311
+ "horizontal-bar",
1312
+ "line",
1313
+ "area",
1314
+ "pie",
1315
+ "donut",
1316
+ "radar",
1317
+ "funnel",
1318
+ "combo"
1319
+ ]);
1320
+ }));
1321
+ //#endregion
1322
+ //#region src/ChartRenderer.tsx
1323
+ $e();
1324
+ var Dt = h.lazy(() => Promise.resolve().then(() => (rt(), et))), Ot = h.lazy(() => Promise.resolve().then(() => (Et(), gt))), kt = ({ schema: e }) => /* @__PURE__ */ T(g, {
1325
+ fallback: /* @__PURE__ */ T(ue, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
1326
+ children: /* @__PURE__ */ T(Dt, {
917
1327
  data: e.data,
918
1328
  dataKey: e.dataKey,
919
1329
  xAxisKey: e.xAxisKey,
@@ -922,33 +1332,34 @@ var X, Ye, Z, Q, Xe = V((() => {
922
1332
  color: e.color
923
1333
  })
924
1334
  }), $ = ({ schema: e, onChartClick: t }) => {
925
- let n = p.useMemo(() => {
926
- let t = e.series, n = e.xAxisKey, r = e.config;
927
- if (n || (e.index ? n = e.index : e.category && (n = e.category)), t || (e.categories ? t = e.categories.map((e) => ({ dataKey: e })) : e.value && (t = [{ dataKey: e.value }])), !r && t) {
928
- let n = e.colors || [
1335
+ let n = h.useMemo(() => {
1336
+ let t = Ue(e), n = Array.isArray(e.series) ? e.series : void 0, r = (n?.length && n.every((e) => !!e && typeof e == "object" && "dataKey" in e) ? n : t.series) ?? n, i = e.xAxisKey ?? t.xAxisKey, a = e.config;
1337
+ if (i || (e.index ? i = e.index : e.category && (i = e.category)), r || (e.categories ? r = e.categories.map((e) => ({ dataKey: e })) : e.value && (r = [{ dataKey: e.value }])), !a && r) {
1338
+ let t = e.colors || [
929
1339
  "hsl(var(--chart-1))",
930
1340
  "hsl(var(--chart-2))",
931
1341
  "hsl(var(--chart-3))"
932
- ], i = {};
933
- t.forEach((e, t) => {
934
- i[e.dataKey] = {
1342
+ ], n = {};
1343
+ r.forEach((e, r) => {
1344
+ n[e.dataKey] = {
935
1345
  label: e.label || e.dataKey,
936
- color: n[t % n.length]
1346
+ color: e.color || t[r % t.length]
937
1347
  };
938
- }), r = i;
1348
+ }), a = n;
939
1349
  }
940
1350
  return {
941
- chartType: e.chartType,
1351
+ chartType: e.chartType ?? t.chartType,
942
1352
  data: Array.isArray(e.data) ? e.data : [],
943
- config: r,
944
- xAxisKey: n,
945
- series: t,
946
- className: e.className
1353
+ config: a,
1354
+ xAxisKey: i,
1355
+ series: r,
1356
+ className: e.className,
1357
+ spec: t
947
1358
  };
948
1359
  }, [e]);
949
- return /* @__PURE__ */ C(m, {
950
- fallback: /* @__PURE__ */ C(x, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
951
- children: /* @__PURE__ */ C(Qe, {
1360
+ return /* @__PURE__ */ T(g, {
1361
+ fallback: /* @__PURE__ */ T(ue, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
1362
+ children: /* @__PURE__ */ T(Ot, {
952
1363
  chartType: n.chartType,
953
1364
  data: n.data,
954
1365
  config: n.config,
@@ -957,58 +1368,73 @@ var X, Ye, Z, Q, Xe = V((() => {
957
1368
  className: n.className,
958
1369
  colors: Array.isArray(e.colors) ? e.colors : void 0,
959
1370
  categoryColors: e.categoryColors,
1371
+ categoryOrder: e.categoryOrder,
960
1372
  isAnimationActive: e.isAnimationActive,
961
- onChartClick: t
1373
+ onChartClick: t,
1374
+ xAxis: n.spec.xAxis,
1375
+ yAxes: n.spec.yAxes,
1376
+ showLegend: n.spec.showLegend,
1377
+ showDataLabels: n.spec.showDataLabels,
1378
+ title: n.spec.title,
1379
+ subtitle: n.spec.subtitle,
1380
+ description: n.spec.description,
1381
+ height: n.spec.height ?? e.height,
1382
+ annotations: n.spec.annotations,
1383
+ interaction: n.spec.interaction
962
1384
  })
963
1385
  });
964
1386
  };
965
1387
  //#endregion
966
1388
  //#region src/ObjectChart.tsx
967
- function et(e) {
1389
+ function At(e) {
968
1390
  return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
969
1391
  }
970
- function tt(e, t) {
971
- let { field: n, function: r, groupBy: i } = t, a = {};
1392
+ function jt(e) {
1393
+ return e.field || e.function || "count";
1394
+ }
1395
+ var Mt = "__comparison";
1396
+ function Nt(e, t) {
1397
+ let { field: n, function: r, groupBy: i } = t, a = jt(t), o = {};
972
1398
  for (let t of e) {
973
1399
  let e = String(t[i] ?? "Unknown");
974
- a[e] || (a[e] = []), a[e].push(t);
1400
+ o[e] || (o[e] = []), o[e].push(t);
975
1401
  }
976
- return Object.entries(a).map(([e, t]) => {
977
- let a = t.map((e) => Number(e[n]) || 0), o;
1402
+ return Object.entries(o).map(([e, t]) => {
1403
+ let o = n ? t.map((e) => Number(e[n]) || 0) : [], s;
978
1404
  switch (r) {
979
1405
  case "count":
980
- o = t.length;
1406
+ s = t.length;
981
1407
  break;
982
1408
  case "avg":
983
- o = a.length > 0 ? a.reduce((e, t) => e + t, 0) / a.length : 0;
1409
+ s = o.length > 0 ? o.reduce((e, t) => e + t, 0) / o.length : 0;
984
1410
  break;
985
1411
  case "min":
986
- o = a.length > 0 ? Math.min(...a) : 0;
1412
+ s = o.length > 0 ? Math.min(...o) : 0;
987
1413
  break;
988
1414
  case "max":
989
- o = a.length > 0 ? Math.max(...a) : 0;
1415
+ s = o.length > 0 ? Math.max(...o) : 0;
990
1416
  break;
991
1417
  default:
992
- o = a.reduce((e, t) => e + t, 0);
1418
+ s = o.reduce((e, t) => e + t, 0);
993
1419
  break;
994
1420
  }
995
1421
  return {
996
1422
  [i]: e,
997
- [n]: o
1423
+ [a]: s
998
1424
  };
999
1425
  });
1000
1426
  }
1001
- async function nt(e, t, n, r, i) {
1427
+ async function Pt(e, t, n, r, i) {
1002
1428
  if (!e.length || !t) return e;
1003
- let a = i || ((e, t) => t), s = `__raw_${t}`, c = n?.fields?.[t];
1429
+ let a = i || ((e, t) => t), o = `__raw_${t}`, c = n?.fields?.[t];
1004
1430
  if (!c) {
1005
1431
  let n = /^\d{4}-\d{2}-\d{2}/;
1006
1432
  return e.map((e) => {
1007
- let r = e[t], i = String(r ?? ""), o = n.test(i) ? i : et(i);
1433
+ let r = e[t], i = String(r ?? ""), s = n.test(i) ? i : At(i);
1008
1434
  return {
1009
1435
  ...e,
1010
- [t]: a(i, o),
1011
- [s]: r
1436
+ [t]: a(i, s),
1437
+ [o]: r
1012
1438
  };
1013
1439
  });
1014
1440
  }
@@ -1016,21 +1442,21 @@ async function nt(e, t, n, r, i) {
1016
1442
  if (l === "select" || l === "picklist" || l === "dropdown") {
1017
1443
  let n = c.options || [];
1018
1444
  if (n.length === 0) return e.map((e) => {
1019
- let n = e[t], r = String(n ?? ""), i = et(r);
1445
+ let n = e[t], r = String(n ?? ""), i = At(r);
1020
1446
  return {
1021
1447
  ...e,
1022
1448
  [t]: a(r, i),
1023
- [s]: n
1449
+ [o]: n
1024
1450
  };
1025
1451
  });
1026
1452
  let r = {};
1027
1453
  for (let e of n) typeof e == "string" ? r[e] = e : e && typeof e == "object" && (r[String(e.value)] = e.label || String(e.value));
1028
1454
  return e.map((e) => {
1029
- let n = e[t], i = String(n ?? ""), o = r[i] || et(i);
1455
+ let n = e[t], i = String(n ?? ""), s = r[i] || At(i);
1030
1456
  return {
1031
1457
  ...e,
1032
- [t]: a(i, o),
1033
- [s]: n
1458
+ [t]: a(i, s),
1459
+ [o]: n
1034
1460
  };
1035
1461
  });
1036
1462
  }
@@ -1038,16 +1464,16 @@ async function nt(e, t, n, r, i) {
1038
1464
  let n = c.reference_to || c.reference;
1039
1465
  if (!n || !r || typeof r.find != "function") return e.map((e) => ({
1040
1466
  ...e,
1041
- [s]: e[t]
1467
+ [o]: e[t]
1042
1468
  }));
1043
1469
  let i = [...new Set(e.map((e) => e[t]).filter((e) => e != null))];
1044
1470
  if (i.length === 0) return e.map((e) => ({
1045
1471
  ...e,
1046
- [s]: e[t]
1472
+ [o]: e[t]
1047
1473
  }));
1048
1474
  let a = c.id_field || "id";
1049
1475
  try {
1050
- let l = o(await r.find(n, {
1476
+ let l = s(await r.find(n, {
1051
1477
  $filter: { [a]: { $in: i } },
1052
1478
  $top: i.length
1053
1479
  })), u = c.reference_field || c.display_field || "name", d = {};
@@ -1060,316 +1486,322 @@ async function nt(e, t, n, r, i) {
1060
1486
  return {
1061
1487
  ...e,
1062
1488
  [t]: d[r] || r,
1063
- [s]: n
1489
+ [o]: n
1064
1490
  };
1065
1491
  });
1066
1492
  } catch (n) {
1067
1493
  return console.warn("[ObjectChart] Failed to resolve lookup labels:", n), e.map((e) => ({
1068
1494
  ...e,
1069
- [s]: e[t]
1495
+ [o]: e[t]
1070
1496
  }));
1071
1497
  }
1072
1498
  }
1073
1499
  if (l === "date" || l === "datetime" || l === "date_time" || l === "timestamp" || l === "time") return e.map((e) => ({
1074
1500
  ...e,
1075
- [s]: e[t]
1501
+ [o]: e[t]
1076
1502
  }));
1077
1503
  let u = /^\d{4}-\d{2}-\d{2}/;
1078
1504
  return e.map((e) => {
1079
1505
  let n = e[t], r = String(n ?? "");
1080
1506
  return {
1081
1507
  ...e,
1082
- [t]: u.test(r) ? r : et(r),
1083
- [s]: n
1508
+ [t]: u.test(r) ? r : At(r),
1509
+ [o]: n
1084
1510
  };
1085
1511
  });
1086
1512
  }
1087
- var rt = (e) => {
1088
- let { schema: f } = e, p = e.onSegmentClick, m = g(Ee), x = e.dataSource || m?.dataSource, S = z(f.bind), { fieldOptionLabel: T } = Ae(), de = te(T);
1089
- ee(() => {
1090
- de.current = T;
1091
- }, [T]);
1092
- let [fe, E] = v([]), [D, pe] = v(null), [me, O] = v(() => !(Array.isArray(f.data) && f.data.length > 0) && (!!f.objectName || !!f.dataset)), [he, k] = v(null), [A, j] = v(null), [ge, M] = v(null), [_e, ve] = v(null), { openRecordList: ye } = De(), be = je(), N = _(() => f.aggregate ? JSON.stringify(f.aggregate) : "", [f.aggregate]), P = _(() => f.filter ? JSON.stringify(f.filter) : "", [f.filter]), xe = _(() => f.compareTo ? JSON.stringify(f.compareTo) : "", [f.compareTo]), Se = _(() => f.dataset ? JSON.stringify({
1093
- d: f.dataset,
1094
- dim: f.dimensions ?? [],
1095
- val: f.values ?? []
1513
+ var Ft = (e) => {
1514
+ let { schema: t } = e, m = e.onSegmentClick, h = te(Ie), g = e.dataSource || h?.dataSource, ue = Le(t.bind), { fieldOptionLabel: w } = He(), de = re(w);
1515
+ ne(() => {
1516
+ de.current = w;
1517
+ }, [w]);
1518
+ let [fe, pe] = v([]), [D, me] = v(null), [he, O] = v(() => !(Array.isArray(t.data) && t.data.length > 0) && (!!t.objectName || !!t.dataset)), [ge, _e] = v(null), [ve, ye] = v(null), [k, be] = v(null), [xe, Se] = v(null), { openRecordList: Ce } = Re(), we = F(), Te = _(() => t.aggregate ? JSON.stringify(t.aggregate) : "", [t.aggregate]), Ee = _(() => t.filter ? JSON.stringify(t.filter) : "", [t.filter]), De = _(() => t.compareTo ? JSON.stringify(t.compareTo) : "", [t.compareTo]), Oe = _(() => t.dataset ? JSON.stringify({
1519
+ d: t.dataset,
1520
+ dim: t.dimensions ?? [],
1521
+ val: t.values ?? []
1096
1522
  }) : "", [
1097
- f.dataset,
1098
- f.dimensions,
1099
- f.values
1100
- ]), Ce = (e) => e !== "pie" && e !== "donut" && e !== "funnel";
1101
- ee(() => {
1523
+ t.dataset,
1524
+ t.dimensions,
1525
+ t.values
1526
+ ]), ke = (e) => e !== "pie" && e !== "donut" && e !== "funnel";
1527
+ ne(() => {
1102
1528
  let e = !1;
1103
1529
  return (async () => {
1104
1530
  try {
1105
- let t = {
1531
+ let n = {
1106
1532
  headers: { accept: "application/json" },
1107
1533
  credentials: "include"
1108
- }, i = f.objectName, a, o = null, s = f.aggregate?.groupBy;
1109
- if (i) a = s && typeof s == "object" && !Array.isArray(s) ? s.field : typeof s == "string" ? s : f.xAxisKey;
1110
- else if (f.dataset) {
1111
- let e = Array.isArray(f.dimensions) && f.dimensions.length ? f.dimensions[0] : void 0, n = await (await fetch(`/api/v1/meta/dataset/${encodeURIComponent(f.dataset)}`, t)).json().catch(() => null);
1112
- o = n?.item ?? n?.data ?? n, i = o?.object, a = ((o?.dimensions || []).find((t) => t?.name === e) ?? (o?.dimensions || [])[0])?.field ?? e;
1534
+ }, a = t.objectName, o, s = null, c = t.aggregate?.groupBy;
1535
+ if (a) o = c && typeof c == "object" && !Array.isArray(c) ? c.field : typeof c == "string" ? c : t.xAxisKey;
1536
+ else if (t.dataset) {
1537
+ let e = Array.isArray(t.dimensions) && t.dimensions.length ? t.dimensions[0] : void 0, r = await (await fetch(`/api/v1/meta/dataset/${encodeURIComponent(t.dataset)}`, n)).json().catch(() => null);
1538
+ s = r?.item ?? r?.data ?? r, a = s?.object, o = ((s?.dimensions || []).find((t) => t?.name === e) ?? (s?.dimensions || [])[0])?.field ?? e;
1113
1539
  }
1114
- if (!i || !a) {
1115
- e || (M(null), ve(null));
1540
+ if (!a || !o) {
1541
+ e || (be(null), Se(null));
1116
1542
  return;
1117
1543
  }
1118
- let c = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(i)}`, t)).json().catch(() => null), l = c?.item ?? c?.data ?? c, u = r(l?.fields?.[a]?.options), d = null;
1119
- if (f.dataset && Array.isArray(f.dimensions)) {
1544
+ let l = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(a)}`, n)).json().catch(() => null), u = l?.item ?? l?.data ?? l, d = i(u?.fields?.[o]?.options), f = null;
1545
+ if (t.dataset && Array.isArray(t.dimensions)) {
1120
1546
  let e = {};
1121
- for (let t of f.dimensions) {
1122
- let r = (o?.dimensions || []).find((e) => e?.name === t)?.field ?? t, i = n(l?.fields?.[r]?.options);
1123
- i && (e[t] = i);
1547
+ for (let n of t.dimensions) {
1548
+ let t = (s?.dimensions || []).find((e) => e?.name === n)?.field ?? n, i = r(u?.fields?.[t]?.options);
1549
+ i && (e[n] = i);
1124
1550
  }
1125
- Object.keys(e).length > 0 && (d = e);
1551
+ Object.keys(e).length > 0 && (f = e);
1126
1552
  }
1127
- e || (M(u), ve(d));
1553
+ e || (be(d), Se(f));
1128
1554
  } catch {
1129
- e || (M(null), ve(null));
1555
+ e || (be(null), Se(null));
1130
1556
  }
1131
1557
  })(), () => {
1132
1558
  e = !0;
1133
1559
  };
1134
1560
  }, [
1135
- f.objectName,
1136
- f.dataset,
1137
- Se,
1138
- N,
1139
- f.xAxisKey
1561
+ t.objectName,
1562
+ t.dataset,
1563
+ Oe,
1564
+ Te,
1565
+ t.xAxisKey
1140
1566
  ]);
1141
- let F = h(async (e, t) => {
1142
- if (f.aggregate && typeof e.aggregate == "function") {
1143
- let n = f.aggregate.groupBy;
1144
- if (n && typeof n == "object" && !Array.isArray(n)) {
1145
- let r = f.aggregate.field, i = f.aggregate.function, a = {
1146
- function: i,
1147
- alias: r || i
1567
+ let Ae = ee(async (e, n) => {
1568
+ if (t.aggregate && typeof e.aggregate == "function") {
1569
+ let r = t.aggregate.groupBy;
1570
+ if (r && typeof r == "object" && !Array.isArray(r)) {
1571
+ let i = t.aggregate.field, a = t.aggregate.function, o = {
1572
+ function: a,
1573
+ alias: jt(t.aggregate)
1148
1574
  };
1149
- i !== "count" && r && (a.field = r);
1150
- let o = await e.aggregate(f.objectName, {
1151
- groupBy: [n],
1152
- aggregations: [a],
1153
- where: t
1575
+ a !== "count" && i && (o.field = i);
1576
+ let s = await e.aggregate(t.objectName, {
1577
+ groupBy: [r],
1578
+ aggregations: [o],
1579
+ where: n
1154
1580
  });
1155
- return Array.isArray(o) ? o : [];
1581
+ return Array.isArray(s) ? s : [];
1156
1582
  }
1157
- let r = await e.aggregate(f.objectName, {
1158
- field: f.aggregate.field,
1159
- function: f.aggregate.function,
1160
- groupBy: n,
1161
- filter: t
1583
+ let i = await e.aggregate(t.objectName, {
1584
+ field: t.aggregate.field,
1585
+ function: t.aggregate.function,
1586
+ groupBy: r,
1587
+ filter: n
1162
1588
  });
1163
- return Array.isArray(r) ? r : [];
1589
+ return Array.isArray(i) ? i : [];
1164
1590
  }
1165
1591
  if (typeof e.find == "function") {
1166
- let n = o(await e.find(f.objectName, { $filter: t }));
1167
- return f.aggregate && n.length > 0 && (n = tt(n, f.aggregate)), n;
1592
+ let r = s(await e.find(t.objectName, { $filter: n }));
1593
+ return t.aggregate && r.length > 0 && (r = Nt(r, t.aggregate)), r;
1168
1594
  }
1169
1595
  return [];
1170
- }, [f.objectName, N]), we = h(async (e, t) => {
1171
- if (!e || !f.objectName && !f.dataset) {
1172
- t.current && O(!1);
1596
+ }, [t.objectName, Te]), A = ze(), je = ee(async (e, n) => {
1597
+ if (!e || !t.objectName && !t.dataset) {
1598
+ n.current && O(!1);
1173
1599
  return;
1174
1600
  }
1175
- t.current && (O(!0), k(null));
1601
+ n.current && (O(!0), _e(null));
1176
1602
  try {
1177
- if (f.dataset && typeof e.queryDataset == "function") {
1178
- let n = l(f.filter), r = await e.queryDataset(f.dataset, {
1179
- dimensions: Array.isArray(f.dimensions) ? f.dimensions : [],
1180
- measures: Array.isArray(f.values) ? f.values : [],
1181
- ...n ? { runtimeFilter: n } : {}
1603
+ if (t.dataset && typeof e.queryDataset == "function") {
1604
+ let r = f(t.filter, A), i = await e.queryDataset(t.dataset, {
1605
+ dimensions: Array.isArray(t.dimensions) ? t.dimensions : [],
1606
+ measures: Array.isArray(t.values) ? t.values : [],
1607
+ ...r ? { runtimeFilter: r } : {}
1182
1608
  });
1183
- t.current && (E(Array.isArray(r?.rows) ? r.rows : []), pe(Array.isArray(r?.fields) ? r.fields : null));
1609
+ n.current && (pe(Array.isArray(i?.rows) ? i.rows : []), me(Array.isArray(i?.fields) ? i.fields : null));
1184
1610
  return;
1185
1611
  }
1186
- let n = l(f.filter), r = f.compareTo, i = !!r && Ce(f.chartType), a = i ? d(f.filter, r) : null, [o, s] = await Promise.all([F(e, n), a ? F(e, a) : Promise.resolve([])]), c = o, u = f.aggregate?.groupBy, p = u && typeof u == "object" && !Array.isArray(u) ? u.alias || u.field : u || f.xAxisKey;
1187
- if (i && s.length > 0 && f.aggregate) {
1188
- let e = f.aggregate.field, t = f.aggregate.function, n = (n) => {
1189
- if (n == null) return null;
1190
- let r = `${e}_${t}`;
1191
- return r in n ? Number(n[r]) : t === "count" && `${e}_count` in n ? Number(n[`${e}_count`]) : e in n ? Number(n[e]) : "value" in n ? Number(n.value) : "count" in n ? Number(n.count) : null;
1192
- }, r = `${e}__comparison`, i = p;
1193
- if (i && c.some((e) => e[i] != null) && s.some((e) => e[i] != null)) {
1612
+ let r = f(t.filter, A), i = t.compareTo, a = !!i && ke(t.chartType), o = a ? u(p(t.filter, i), A) : null, [s, c] = await Promise.all([Ae(e, r), o ? Ae(e, o) : Promise.resolve([])]), l = s, d = t.aggregate?.groupBy, m = d && typeof d == "object" && !Array.isArray(d) ? d.alias || d.field : d || t.xAxisKey;
1613
+ if (a && c.length > 0 && t.aggregate) {
1614
+ let e = t.aggregate.field, n = t.aggregate.function, r = jt(t.aggregate), i = (t) => {
1615
+ if (t == null) return null;
1616
+ if (e) {
1617
+ let r = `${e}_${n}`;
1618
+ if (r in t) return Number(t[r]);
1619
+ if (n === "count" && `${e}_count` in t) return Number(t[`${e}_count`]);
1620
+ }
1621
+ return r in t ? Number(t[r]) : "value" in t ? Number(t.value) : "count" in t ? Number(t.count) : null;
1622
+ }, a = `${r}${Mt}`, o = m;
1623
+ if (o && l.some((e) => e[o] != null) && c.some((e) => e[o] != null)) {
1194
1624
  let e = /* @__PURE__ */ new Map();
1195
- for (let t of s) {
1196
- let r = String(t[i] ?? "");
1197
- e.set(r, n(t));
1625
+ for (let t of c) {
1626
+ let n = String(t[o] ?? "");
1627
+ e.set(n, i(t));
1198
1628
  }
1199
- c = c.map((t) => {
1200
- let n = String(t[i] ?? ""), a = e.get(n);
1201
- return a == null ? t : {
1629
+ l = l.map((t) => {
1630
+ let n = String(t[o] ?? ""), r = e.get(n);
1631
+ return r == null ? t : {
1202
1632
  ...t,
1203
- [r]: a
1633
+ [a]: r
1204
1634
  };
1205
1635
  });
1206
- let t = new Set(c.map((e) => String(e[i] ?? "")));
1207
- for (let e of s) {
1208
- let a = String(e[i] ?? "");
1209
- t.has(a) || c.push({
1210
- [i]: a,
1211
- [r]: n(e)
1636
+ let t = new Set(l.map((e) => String(e[o] ?? "")));
1637
+ for (let e of c) {
1638
+ let n = String(e[o] ?? "");
1639
+ t.has(n) || l.push({
1640
+ [o]: n,
1641
+ [a]: i(e)
1212
1642
  });
1213
1643
  }
1214
1644
  } else {
1215
- let e = Math.max(c.length, s.length), t = [];
1216
- for (let i = 0; i < e; i++) {
1217
- let e = c[i] || {}, a = s[i];
1218
- t.push(a ? {
1645
+ let e = Math.max(l.length, c.length), t = [];
1646
+ for (let n = 0; n < e; n++) {
1647
+ let e = l[n] || {}, r = c[n];
1648
+ t.push(r ? {
1219
1649
  ...e,
1220
- [r]: n(a)
1650
+ [a]: i(r)
1221
1651
  } : e);
1222
1652
  }
1223
- c = t;
1653
+ l = t;
1224
1654
  }
1225
1655
  }
1226
- if (p && typeof e.getObjectSchema == "function") try {
1227
- let t = await e.getObjectSchema(f.objectName);
1228
- c = await nt(c, p, t, e, (e, t) => de.current(f.objectName, p, e, t));
1656
+ if (m && typeof e.getObjectSchema == "function") try {
1657
+ let n = await e.getObjectSchema(t.objectName);
1658
+ l = await Pt(l, m, n, e, (e, n) => de.current(t.objectName, m, e, n));
1229
1659
  } catch {}
1230
- t.current && E(c);
1660
+ n.current && pe(l);
1231
1661
  } catch (e) {
1232
- console.error("[ObjectChart] Fetch error:", e), t.current && k(e instanceof Error ? e.message : "Failed to load chart data");
1662
+ console.error("[ObjectChart] Fetch error:", e), n.current && _e(e instanceof Error ? e.message : "Failed to load chart data");
1233
1663
  } finally {
1234
- t.current && O(!1);
1664
+ n.current && O(!1);
1235
1665
  }
1236
1666
  }, [
1237
- f.objectName,
1238
- Se,
1239
- N,
1240
- P,
1241
- xe,
1242
- f.xAxisKey,
1243
- f.chartType,
1244
- F
1667
+ t.objectName,
1668
+ Oe,
1669
+ Te,
1670
+ Ee,
1671
+ De,
1672
+ t.xAxisKey,
1673
+ t.chartType,
1674
+ Ae,
1675
+ A
1245
1676
  ]);
1246
- ee(() => {
1677
+ ne(() => {
1247
1678
  let e = { current: !0 };
1248
- return (f.objectName || f.dataset) && !S && !f.data ? we(x, e) : e.current && O(!1), () => {
1679
+ return (t.objectName || t.dataset) && !ue && !t.data ? je(g, e) : e.current && O(!1), () => {
1249
1680
  e.current = !1;
1250
1681
  };
1251
1682
  }, [
1252
- f.objectName,
1253
- Se,
1254
- x,
1255
- S,
1256
- f.data,
1257
- P,
1258
- N,
1259
- xe,
1260
- we
1683
+ t.objectName,
1684
+ Oe,
1685
+ g,
1686
+ ue,
1687
+ t.data,
1688
+ Ee,
1689
+ Te,
1690
+ De,
1691
+ je
1261
1692
  ]);
1262
- let I = S || f.data || fe, L = Array.isArray(I) ? I : [], R = f.drillDown, B = f.aggregate?.groupBy || f.xAxisKey, V = _(() => {
1263
- if (!B) return /* @__PURE__ */ new Map();
1264
- let e = /* @__PURE__ */ new Map(), t = `__raw_${B}`;
1265
- for (let n of L) {
1266
- let r = n?.[B];
1693
+ let Me = ue || t.data || fe, j = Array.isArray(Me) ? Me : [], M = t.drillDown, Ne = t.aggregate?.groupBy || t.xAxisKey, N = _(() => {
1694
+ if (!Ne) return /* @__PURE__ */ new Map();
1695
+ let e = /* @__PURE__ */ new Map(), t = `__raw_${Ne}`;
1696
+ for (let n of j) {
1697
+ let r = n?.[Ne];
1267
1698
  if (r == null) continue;
1268
1699
  let i = t in (n || {}) ? n[t] : r;
1269
1700
  e.set(String(r), i);
1270
1701
  }
1271
1702
  return e;
1272
- }, [L, B]), H = f.compareTo, Me = !!H && Ce(f.chartType) && !!f.aggregate && L.some((e) => e[`${f.aggregate.field}__comparison`] != null), Ne = _(() => {
1273
- let e = Array.isArray(f.series) ? f.series : null;
1274
- if (!Me) return e;
1275
- let t = e || [{ dataKey: f.aggregate.field }], n = {
1703
+ }, [j, Ne]), P = t.compareTo, Pe = t.aggregate ? jt(t.aggregate) : void 0, I = Pe ? `${Pe}${Mt}` : void 0, L = !!P && ke(t.chartType) && !!I && j.some((e) => e[I] != null), R = _(() => {
1704
+ let e = Array.isArray(t.series) ? t.series : null;
1705
+ if (!L) return e;
1706
+ let n = e || [{ dataKey: Pe }], r = {
1276
1707
  vsLastWeek: "Previous week",
1277
1708
  vsLastMonth: "Previous month",
1278
1709
  vsLastQuarter: "Previous quarter",
1279
1710
  vsLastYear: "Previous year",
1280
1711
  vsYesterday: "Yesterday",
1281
1712
  vsPreviousPeriod: "Previous period"
1282
- }[i(H, f.filter)] || "Previous period";
1283
- return [...t.map((e) => ({
1713
+ }[a(P, t.filter)] || "Previous period";
1714
+ return [...n.map((e) => ({
1284
1715
  ...e,
1285
1716
  variant: e.variant || "current"
1286
1717
  })), {
1287
- dataKey: `${f.aggregate.field}__comparison`,
1288
- label: n,
1718
+ dataKey: I,
1719
+ label: r,
1289
1720
  variant: "comparison"
1290
1721
  }];
1291
1722
  }, [
1292
- Me,
1293
- f.series,
1294
- f.aggregate,
1295
- f.filter,
1296
- H
1297
- ]), U = f.dataset ? t(c(L, _e), f.dimensions, f.values, D) : null, Pe = U ? {
1298
- ...f,
1299
- data: U.data,
1300
- xAxisKey: U.xAxisKey,
1301
- series: U.series
1723
+ L,
1724
+ t.series,
1725
+ Pe,
1726
+ I,
1727
+ t.filter,
1728
+ P
1729
+ ]), z = t.dataset ? n(l(j, xe), t.dimensions, t.values, D) : null, B = z ? {
1730
+ ...t,
1731
+ data: z.data,
1732
+ xAxisKey: z.xAxisKey,
1733
+ series: z.series
1302
1734
  } : {
1303
- ...f,
1304
- data: L,
1305
- ...Ne ? { series: Ne } : {}
1306
- }, Fe = f.colors && !Array.isArray(f.colors) && typeof f.colors == "object" ? f.colors : null, Ie = Array.isArray(f.colors) ? f.colors : void 0, W = ge || Fe ? {
1307
- ...ge || {},
1308
- ...Fe || {}
1309
- } : void 0, G = {
1310
- ...Pe,
1311
- colors: Ie,
1312
- ...W ? { categoryColors: W } : {}
1735
+ ...t,
1736
+ data: j,
1737
+ ...R ? { series: R } : {}
1738
+ }, V = t.colors && !Array.isArray(t.colors) && typeof t.colors == "object" ? t.colors : null, Ue = Array.isArray(t.colors) ? t.colors : void 0, We = k || V ? {
1739
+ ...k || {},
1740
+ ...V || {}
1741
+ } : void 0, Ge = {
1742
+ ...B,
1743
+ colors: Ue,
1744
+ ...We ? { categoryColors: We } : {}
1313
1745
  };
1314
- if (me && L.length === 0) return /* @__PURE__ */ w("div", {
1315
- className: "p-2 " + (f.className || ""),
1746
+ if (he && j.length === 0) return /* @__PURE__ */ E("div", {
1747
+ className: "p-2 " + (t.className || ""),
1316
1748
  "data-testid": "chart-loading",
1317
1749
  role: "status",
1318
1750
  "aria-busy": "true",
1319
1751
  "aria-live": "polite",
1320
- children: [/* @__PURE__ */ C("span", {
1752
+ children: [/* @__PURE__ */ T("span", {
1321
1753
  className: "sr-only",
1322
1754
  children: "Loading chart data…"
1323
- }), /* @__PURE__ */ C(re, { className: "h-full" })]
1755
+ }), /* @__PURE__ */ T(y, { className: "h-full" })]
1324
1756
  });
1325
- if (he) return /* @__PURE__ */ w("div", {
1326
- className: "flex flex-col items-center justify-center gap-2 p-4 " + (f.className || ""),
1757
+ if (ge) return /* @__PURE__ */ E("div", {
1758
+ className: "flex flex-col items-center justify-center gap-2 p-4 " + (t.className || ""),
1327
1759
  "data-testid": "chart-error",
1328
1760
  role: "alert",
1329
1761
  children: [
1330
- /* @__PURE__ */ C(Oe, { className: "h-6 w-6 text-destructive opacity-60" }),
1331
- /* @__PURE__ */ C("p", {
1762
+ /* @__PURE__ */ T(Be, { className: "h-6 w-6 text-destructive opacity-60" }),
1763
+ /* @__PURE__ */ T("p", {
1332
1764
  className: "text-xs text-destructive font-medium",
1333
1765
  children: "Failed to load chart data"
1334
1766
  }),
1335
- /* @__PURE__ */ C("p", {
1767
+ /* @__PURE__ */ T("p", {
1336
1768
  className: "text-xs text-muted-foreground max-w-xs text-center",
1337
- children: he
1769
+ children: ge
1338
1770
  })
1339
1771
  ]
1340
1772
  });
1341
- if (!x && f.objectName && L.length === 0) return /* @__PURE__ */ w("div", {
1342
- className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (f.className || ""),
1773
+ if (!g && t.objectName && j.length === 0) return /* @__PURE__ */ E("div", {
1774
+ className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (t.className || ""),
1343
1775
  "data-testid": "chart-no-datasource",
1344
1776
  children: [
1345
1777
  "No data source available for “",
1346
- f.objectName,
1778
+ t.objectName,
1347
1779
  "”"
1348
1780
  ]
1349
1781
  });
1350
- let K = s(R) ? (e) => {
1351
- let t = e.category, n = t != null && V.has(String(t)) ? V.get(String(t)) : t;
1352
- j({
1782
+ let H = c(M) ? (e) => {
1783
+ let t = e.category, n = t != null && N.has(String(t)) ? N.get(String(t)) : t;
1784
+ ye({
1353
1785
  ...e,
1354
1786
  category: n,
1355
1787
  categoryLabel: t,
1356
1788
  scope: "cell"
1357
1789
  });
1358
- } : void 0, Le = p ?? K, q = !p && A && f.objectName ? (() => {
1359
- let e = a(R, A, { groupByField: B }), t = {
1360
- ...f.filter || {},
1790
+ } : void 0, Ke = m ?? H, qe = !m && ve && t.objectName ? (() => {
1791
+ let e = o(M, ve, { groupByField: Ne }), n = {
1792
+ ...t.filter || {},
1361
1793
  ...e
1362
- }, n = u(R, A, f.title || "Details"), r = R?.target ?? "drawer", i = /* @__PURE__ */ C("div", {
1794
+ }, r = d(M, ve, t.title || "Details"), i = M?.target ?? "drawer", a = /* @__PURE__ */ T("div", {
1363
1795
  className: "overflow-auto",
1364
1796
  "data-testid": "chart-drill-body",
1365
- children: /* @__PURE__ */ C(Te, {
1797
+ children: /* @__PURE__ */ T(Fe, {
1366
1798
  schema: {
1367
1799
  type: "object-data-table",
1368
- objectName: f.objectName,
1369
- filter: t,
1800
+ objectName: t.objectName,
1801
+ filter: n,
1370
1802
  pagination: !0,
1371
- pageSize: R?.maxRows,
1372
- columns: R?.columns?.map((e) => ({
1803
+ pageSize: M?.maxRows,
1804
+ columns: M?.columns?.map((e) => ({
1373
1805
  accessorKey: e,
1374
1806
  header: e
1375
1807
  })),
@@ -1379,58 +1811,58 @@ var rt = (e) => {
1379
1811
  target: "dialog"
1380
1812
  }
1381
1813
  },
1382
- dataSource: x
1814
+ dataSource: g
1383
1815
  })
1384
- }), o = ye && f.objectName ? /* @__PURE__ */ w(ne, {
1816
+ }), s = Ce && t.objectName ? /* @__PURE__ */ E(ie, {
1385
1817
  type: "button",
1386
1818
  variant: "ghost",
1387
1819
  size: "sm",
1388
1820
  "data-testid": "drill-open-in-list",
1389
1821
  onClick: () => {
1390
- ye(f.objectName, t), j(null);
1822
+ Ce(t.objectName, n), ye(null);
1391
1823
  },
1392
- children: [be("dashboard.openInList", "Open in list"), /* @__PURE__ */ C(ke, { className: "ml-1 h-3.5 w-3.5" })]
1824
+ children: [we("dashboard.openInList", "Open in list"), /* @__PURE__ */ T(Ve, { className: "ml-1 h-3.5 w-3.5" })]
1393
1825
  }) : null;
1394
- return r === "dialog" ? /* @__PURE__ */ C(ie, {
1826
+ return i === "dialog" ? /* @__PURE__ */ T(ae, {
1395
1827
  open: !0,
1396
- onOpenChange: (e) => !e && j(null),
1397
- children: /* @__PURE__ */ w(ae, {
1828
+ onOpenChange: (e) => !e && ye(null),
1829
+ children: /* @__PURE__ */ E(b, {
1398
1830
  className: "max-w-4xl",
1399
- children: [/* @__PURE__ */ w(oe, {
1831
+ children: [/* @__PURE__ */ E(x, {
1400
1832
  className: "flex-row items-center justify-between gap-4 pr-8",
1401
- children: [/* @__PURE__ */ C(se, { children: n }), o]
1402
- }), i]
1833
+ children: [/* @__PURE__ */ T(S, { children: r }), s]
1834
+ }), a]
1403
1835
  })
1404
- }) : /* @__PURE__ */ C(le, {
1836
+ }) : /* @__PURE__ */ T(oe, {
1405
1837
  open: !0,
1406
- onOpenChange: (e) => !e && j(null),
1407
- children: /* @__PURE__ */ w(ue, {
1838
+ onOpenChange: (e) => !e && ye(null),
1839
+ children: /* @__PURE__ */ E(se, {
1408
1840
  side: "right",
1409
1841
  className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
1410
- children: [/* @__PURE__ */ w(y, {
1842
+ children: [/* @__PURE__ */ E(ce, {
1411
1843
  className: "flex-row items-center justify-between gap-4 pr-8",
1412
- children: [/* @__PURE__ */ C(b, { children: n }), o]
1413
- }), /* @__PURE__ */ C("div", {
1844
+ children: [/* @__PURE__ */ T(le, { children: r }), s]
1845
+ }), /* @__PURE__ */ T("div", {
1414
1846
  className: "flex-1 overflow-hidden mt-2",
1415
- children: i
1847
+ children: a
1416
1848
  })]
1417
1849
  })
1418
1850
  });
1419
1851
  })() : null;
1420
- return /* @__PURE__ */ w("div", {
1852
+ return /* @__PURE__ */ E("div", {
1421
1853
  className: "relative",
1422
1854
  children: [
1423
- /* @__PURE__ */ C(ce, { active: me && L.length > 0 }),
1424
- /* @__PURE__ */ C($, {
1855
+ /* @__PURE__ */ T(C, { active: he && j.length > 0 }),
1856
+ /* @__PURE__ */ T($, {
1425
1857
  ...e,
1426
- schema: G,
1427
- onChartClick: Le
1858
+ schema: Ge,
1859
+ onChartClick: Ke
1428
1860
  }),
1429
- q
1861
+ qe
1430
1862
  ]
1431
1863
  });
1432
1864
  };
1433
- e.register("object-chart", rt, {
1865
+ e.register("object-chart", Ft, {
1434
1866
  namespace: "plugin-charts",
1435
1867
  label: "Object Chart",
1436
1868
  category: "view",
@@ -1462,11 +1894,11 @@ e.register("object-chart", rt, {
1462
1894
  });
1463
1895
  //#endregion
1464
1896
  //#region src/index.tsx
1465
- var it = {
1466
- "bar-chart": $e,
1897
+ var It = {
1898
+ "bar-chart": kt,
1467
1899
  chart: $
1468
1900
  };
1469
- e.register("bar-chart", $e, {
1901
+ e.register("bar-chart", kt, {
1470
1902
  namespace: "plugin-charts",
1471
1903
  label: "Bar Chart",
1472
1904
  category: "plugin",
@@ -1530,7 +1962,7 @@ e.register("bar-chart", $e, {
1530
1962
  height: 400,
1531
1963
  color: "#8884d8"
1532
1964
  }
1533
- }), e.register("chart", rt, {
1965
+ }), e.register("chart", Ft, {
1534
1966
  namespace: "view",
1535
1967
  category: "view",
1536
1968
  label: "Chart",
@@ -1697,4 +2129,4 @@ e.register("bar-chart", $e, {
1697
2129
  defaultProps: { chartType: "scatter" }
1698
2130
  });
1699
2131
  //#endregion
1700
- export { $e as ChartBarRenderer, $ as ChartRenderer, rt as ObjectChart, it as chartComponents };
2132
+ export { kt as ChartBarRenderer, $ as ChartRenderer, Ft as ObjectChart, It as chartComponents };