@object-ui/plugin-charts 7.0.0 → 7.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,47 +1,47 @@
1
- import { ComponentRegistry as e, buildChartSeries as t, compareToTrendLabelKey as n, computeDrillFilter as r, extractRecords as i, isDrillEnabled as a, resolveDateMacros as o, resolveDrillTitle as s, shiftFilterByCompareTo as c } from "@object-ui/core";
2
- import * as l from "react";
3
- import u, { Suspense as d, useCallback as f, useContext as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
4
- import { Button as ee, Dialog as te, DialogContent as ne, DialogHeader as re, DialogTitle as ie, RefreshIndicator as ae, Sheet as oe, SheetContent as v, SheetHeader as y, SheetTitle as se, Skeleton as b } from "@object-ui/components";
5
- import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
6
- import { Area as w, AreaChart as ce, Bar as T, BarChart as E, CartesianGrid as D, Cell as O, Funnel as le, FunnelChart as ue, LabelList as de, Legend as k, Line as fe, LineChart as pe, Pie as A, PieChart as j, PolarAngleAxis as me, PolarGrid as he, PolarRadiusAxis as ge, Radar as M, RadarChart as N, ResponsiveContainer as P, Sankey as F, Scatter as I, ScatterChart as L, Tooltip as R, Treemap as z, XAxis as B, YAxis as V, ZAxis as H } from "recharts";
7
- import { SchemaRenderer as _e, SchemaRendererContext as ve, useDataScope as ye, useDrillNavigation as be } from "@object-ui/react";
8
- import { AlertCircle as xe, ArrowUpRight as Se } from "lucide-react";
9
- import { useSafeFieldLabel as Ce, useSafeTranslate as we } from "@object-ui/i18n";
1
+ import { ComponentRegistry as e, buildChartSeries as t, buildOptionColorMap as n, compareToTrendLabelKey as r, computeDrillFilter as i, extractRecords as a, isDrillEnabled as o, resolveDateMacros as s, resolveDrillTitle as c, shiftFilterByCompareTo as l } from "@object-ui/core";
2
+ import * as u from "react";
3
+ import d, { Suspense as f, useCallback as p, useContext as m, useEffect as h, useMemo as g, useRef as ee, useState as _ } from "react";
4
+ import { Button as te, Dialog as ne, DialogContent as re, DialogHeader as ie, DialogTitle as ae, RefreshIndicator as oe, Sheet as se, SheetContent as ce, SheetHeader as le, SheetTitle as v, Skeleton as y } from "@object-ui/components";
5
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
6
+ import { Area as C, AreaChart as ue, Bar as de, BarChart as w, CartesianGrid as T, Cell as E, Funnel as fe, FunnelChart as pe, LabelList as me, Legend as D, Line as O, LineChart as k, Pie as he, PieChart as A, PolarAngleAxis as j, PolarGrid as ge, PolarRadiusAxis as _e, Radar as M, RadarChart as ve, ResponsiveContainer as N, Sankey as ye, Scatter as be, ScatterChart as P, Tooltip as F, Treemap as I, XAxis as L, YAxis as R, ZAxis as xe } from "recharts";
7
+ import { SchemaRenderer as Se, SchemaRendererContext as Ce, useDataScope as z, useDrillNavigation as we } from "@object-ui/react";
8
+ import { AlertCircle as Te, ArrowUpRight as B } from "lucide-react";
9
+ import { useSafeFieldLabel as Ee, useSafeTranslate as De } from "@object-ui/i18n";
10
10
  //#region \0rolldown/runtime.js
11
- var Te = Object.defineProperty, U = (e, t) => () => (e && (t = e(e = 0)), t), Ee = (e, t) => {
11
+ var V = Object.defineProperty, H = (e, t) => () => (e && (t = e(e = 0)), t), Oe = (e, t) => {
12
12
  let n = {};
13
- for (var r in e) Te(n, r, {
13
+ for (var r in e) V(n, r, {
14
14
  get: e[r],
15
15
  enumerable: !0
16
16
  });
17
- return t || Te(n, Symbol.toStringTag, { value: "Module" }), n;
18
- }, De = /* @__PURE__ */ Ee({ default: () => Ae });
19
- function Oe(e, t = 14) {
17
+ return t || V(n, Symbol.toStringTag, { value: "Module" }), n;
18
+ }, ke = /* @__PURE__ */ Oe({ default: () => Me });
19
+ function Ae(e, t = 14) {
20
20
  return e.length > t ? `${e.slice(0, t - 1)}…` : e;
21
21
  }
22
- function ke({ x: e, y: t, payload: n }) {
23
- let r = String(n?.value ?? ""), i = Oe(r);
24
- return /* @__PURE__ */ S("g", {
22
+ function je({ x: e, y: t, payload: n }) {
23
+ let r = String(n?.value ?? ""), i = Ae(r);
24
+ return /* @__PURE__ */ x("g", {
25
25
  transform: `translate(${e},${t})`,
26
- children: /* @__PURE__ */ C("text", {
26
+ children: /* @__PURE__ */ S("text", {
27
27
  dy: 10,
28
28
  textAnchor: "end",
29
29
  transform: "rotate(-32)",
30
30
  fill: "hsl(var(--muted-foreground))",
31
31
  fontSize: 11,
32
32
  fontFamily: "monospace",
33
- children: [r !== i && /* @__PURE__ */ S("title", { children: r }), i]
33
+ children: [r !== i && /* @__PURE__ */ x("title", { children: r }), i]
34
34
  })
35
35
  });
36
36
  }
37
- function Ae({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
37
+ function Me({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
38
38
  let o = e.map((e) => String(e?.[n] ?? "")), s = o.length > 4 || o.some((e) => e.length > 8);
39
- return /* @__PURE__ */ S("div", {
39
+ return /* @__PURE__ */ x("div", {
40
40
  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}`,
41
- children: /* @__PURE__ */ S(P, {
41
+ children: /* @__PURE__ */ x(N, {
42
42
  width: "100%",
43
43
  height: r,
44
- children: /* @__PURE__ */ C(E, {
44
+ children: /* @__PURE__ */ S(w, {
45
45
  data: e,
46
46
  margin: {
47
47
  top: 10,
@@ -50,66 +50,66 @@ function Ae({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
50
50
  bottom: s ? 24 : 5
51
51
  },
52
52
  children: [
53
- /* @__PURE__ */ C("defs", { children: [/* @__PURE__ */ C("linearGradient", {
53
+ /* @__PURE__ */ S("defs", { children: [/* @__PURE__ */ S("linearGradient", {
54
54
  id: "barGradient",
55
55
  x1: "0",
56
56
  y1: "0",
57
57
  x2: "0",
58
58
  y2: "1",
59
59
  children: [
60
- /* @__PURE__ */ S("stop", {
60
+ /* @__PURE__ */ x("stop", {
61
61
  offset: "0%",
62
62
  stopColor: a,
63
63
  stopOpacity: 1
64
64
  }),
65
- /* @__PURE__ */ S("stop", {
65
+ /* @__PURE__ */ x("stop", {
66
66
  offset: "90%",
67
67
  stopColor: a,
68
68
  stopOpacity: .6
69
69
  }),
70
- /* @__PURE__ */ S("stop", {
70
+ /* @__PURE__ */ x("stop", {
71
71
  offset: "100%",
72
72
  stopColor: a,
73
73
  stopOpacity: .3
74
74
  })
75
75
  ]
76
- }), /* @__PURE__ */ C("filter", {
76
+ }), /* @__PURE__ */ S("filter", {
77
77
  id: "glow",
78
78
  height: "130%",
79
79
  children: [
80
- /* @__PURE__ */ S("feGaussianBlur", {
80
+ /* @__PURE__ */ x("feGaussianBlur", {
81
81
  in: "SourceAlpha",
82
82
  stdDeviation: "3",
83
83
  result: "blur"
84
84
  }),
85
- /* @__PURE__ */ S("feOffset", {
85
+ /* @__PURE__ */ x("feOffset", {
86
86
  in: "blur",
87
87
  dx: "0",
88
88
  dy: "0",
89
89
  result: "offsetBlur"
90
90
  }),
91
- /* @__PURE__ */ S("feFlood", {
91
+ /* @__PURE__ */ x("feFlood", {
92
92
  floodColor: a,
93
93
  floodOpacity: "0.5",
94
94
  result: "offsetColor"
95
95
  }),
96
- /* @__PURE__ */ S("feComposite", {
96
+ /* @__PURE__ */ x("feComposite", {
97
97
  in: "offsetColor",
98
98
  in2: "offsetBlur",
99
99
  operator: "in",
100
100
  result: "offsetBlur"
101
101
  }),
102
- /* @__PURE__ */ C("feMerge", { children: [/* @__PURE__ */ S("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ S("feMergeNode", { in: "SourceGraphic" })] })
102
+ /* @__PURE__ */ S("feMerge", { children: [/* @__PURE__ */ x("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ x("feMergeNode", { in: "SourceGraphic" })] })
103
103
  ]
104
104
  })] }),
105
- /* @__PURE__ */ S(D, {
105
+ /* @__PURE__ */ x(T, {
106
106
  strokeDasharray: "3 3",
107
107
  stroke: "hsl(var(--border))",
108
108
  vertical: !1
109
109
  }),
110
- /* @__PURE__ */ S(B, {
110
+ /* @__PURE__ */ x(L, {
111
111
  dataKey: n,
112
- tick: s ? /* @__PURE__ */ S(ke, {}) : {
112
+ tick: s ? /* @__PURE__ */ x(je, {}) : {
113
113
  fill: "hsl(var(--muted-foreground))",
114
114
  fontSize: 12,
115
115
  fontFamily: "monospace"
@@ -120,7 +120,7 @@ function Ae({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
120
120
  height: s ? 56 : void 0,
121
121
  dy: s ? void 0 : 10
122
122
  }),
123
- /* @__PURE__ */ S(V, {
123
+ /* @__PURE__ */ x(R, {
124
124
  tick: {
125
125
  fill: "hsl(var(--muted-foreground))",
126
126
  fontSize: 12,
@@ -129,7 +129,7 @@ function Ae({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
129
129
  tickLine: !1,
130
130
  axisLine: !1
131
131
  }),
132
- /* @__PURE__ */ S(R, {
132
+ /* @__PURE__ */ x(F, {
133
133
  cursor: {
134
134
  fill: "hsl(var(--muted))",
135
135
  opacity: .2
@@ -144,11 +144,11 @@ function Ae({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
144
144
  },
145
145
  itemStyle: { color: "hsl(var(--primary))" }
146
146
  }),
147
- /* @__PURE__ */ S(k, { wrapperStyle: {
147
+ /* @__PURE__ */ x(D, { wrapperStyle: {
148
148
  paddingTop: "20px",
149
149
  fontFamily: "monospace"
150
150
  } }),
151
- /* @__PURE__ */ S(T, {
151
+ /* @__PURE__ */ x(de, {
152
152
  dataKey: t,
153
153
  fill: "url(#barGradient)",
154
154
  radius: [
@@ -165,32 +165,32 @@ function Ae({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
165
165
  })
166
166
  });
167
167
  }
168
- var je = U((() => {}));
168
+ var Ne = H((() => {}));
169
169
  //#endregion
170
170
  //#region src/ChartContainerImpl.tsx
171
- function Me() {
172
- let e = l.useContext(Fe);
171
+ function Pe() {
172
+ let e = u.useContext(Le);
173
173
  if (!e) throw Error("useChart must be used within a <ChartContainer />");
174
174
  return e;
175
175
  }
176
- function W({ id: e, className: t, children: n, config: r, ...i }) {
177
- let a = l.useId(), o = `chart-${e || a.replace(/:/g, "")}`;
178
- return /* @__PURE__ */ S(Fe.Provider, {
176
+ function U({ id: e, className: t, children: n, config: r, ...i }) {
177
+ let a = u.useId(), o = `chart-${e || a.replace(/:/g, "")}`;
178
+ return /* @__PURE__ */ x(Le.Provider, {
179
179
  value: { config: r },
180
- children: /* @__PURE__ */ C("div", {
180
+ children: /* @__PURE__ */ S("div", {
181
181
  "data-slot": "chart",
182
182
  "data-chart": o,
183
- className: q("block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
183
+ className: K("block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
184
184
  style: {
185
185
  minHeight: 280,
186
186
  minWidth: 0,
187
187
  ...i.style
188
188
  },
189
189
  ...i,
190
- children: [/* @__PURE__ */ S(Ie, {
190
+ children: [/* @__PURE__ */ x(Re, {
191
191
  id: o,
192
192
  config: r
193
- }), /* @__PURE__ */ S(P, {
193
+ }), /* @__PURE__ */ x(N, {
194
194
  width: "100%",
195
195
  height: "100%",
196
196
  children: n
@@ -198,15 +198,15 @@ function W({ id: e, className: t, children: n, config: r, ...i }) {
198
198
  })
199
199
  });
200
200
  }
201
- function G({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: o, labelFormatter: s, labelClassName: c, formatter: u, color: d, nameKey: f, labelKey: p }) {
202
- let { config: m } = Me(), h = l.useMemo(() => {
201
+ function W({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: o, labelFormatter: s, labelClassName: c, formatter: l, color: d, nameKey: f, labelKey: p }) {
202
+ let { config: m } = Pe(), h = u.useMemo(() => {
203
203
  if (i || !t?.length) return null;
204
- let [e] = t, n = Ne(m, e, `${p || e?.dataKey || e?.name || "value"}`), r = !p && typeof o == "string" ? m[o]?.label || o : n?.label;
205
- return s ? /* @__PURE__ */ S("div", {
206
- className: q("font-medium", c),
204
+ let [e] = t, n = Fe(m, e, `${p || e?.dataKey || e?.name || "value"}`), r = !p && typeof o == "string" ? m[o]?.label || o : n?.label;
205
+ return s ? /* @__PURE__ */ x("div", {
206
+ className: K("font-medium", c),
207
207
  children: s(r, t)
208
- }) : r ? /* @__PURE__ */ S("div", {
209
- className: q("font-medium", c),
208
+ }) : r ? /* @__PURE__ */ x("div", {
209
+ className: K("font-medium", c),
210
210
  children: r
211
211
  }) : null;
212
212
  }, [
@@ -220,29 +220,29 @@ function G({ active: e, payload: t, className: n, indicator: r = "dot", hideLabe
220
220
  ]);
221
221
  if (!e || !t?.length) return null;
222
222
  let g = t.length === 1 && r !== "dot";
223
- return /* @__PURE__ */ C("div", {
224
- 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),
225
- children: [g ? null : h, /* @__PURE__ */ S("div", {
223
+ return /* @__PURE__ */ S("div", {
224
+ className: K("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),
225
+ children: [g ? null : h, /* @__PURE__ */ x("div", {
226
226
  className: "grid gap-1.5",
227
227
  children: t.filter((e) => e.type !== "none").map((e, t) => {
228
- let n = Ne(m, e, `${f || e.name || e.dataKey || "value"}`), i = d || e.payload.fill || e.color;
229
- return /* @__PURE__ */ S("div", {
230
- 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" : ""),
231
- children: u && e?.value !== void 0 && e.name ? u(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ C(x, { children: [n?.icon ? /* @__PURE__ */ S(n.icon, {}) : !a && /* @__PURE__ */ S("div", {
232
- 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" : ""),
228
+ let n = Fe(m, e, `${f || e.name || e.dataKey || "value"}`), i = d || e.payload.fill || e.color;
229
+ return /* @__PURE__ */ x("div", {
230
+ className: K("[&>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" : ""),
231
+ children: l && e?.value !== void 0 && e.name ? l(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ S(b, { children: [n?.icon ? /* @__PURE__ */ x(n.icon, {}) : !a && /* @__PURE__ */ x("div", {
232
+ className: K("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" : ""),
233
233
  style: {
234
234
  "--color-bg": i,
235
235
  "--color-border": i
236
236
  }
237
- }), /* @__PURE__ */ C("div", {
238
- className: q("flex flex-1 justify-between leading-none", g ? "items-end" : "items-center"),
239
- children: [/* @__PURE__ */ C("div", {
237
+ }), /* @__PURE__ */ S("div", {
238
+ className: K("flex flex-1 justify-between leading-none", g ? "items-end" : "items-center"),
239
+ children: [/* @__PURE__ */ S("div", {
240
240
  className: "grid gap-1.5",
241
- children: [g ? h : null, /* @__PURE__ */ S("span", {
241
+ children: [g ? h : null, /* @__PURE__ */ x("span", {
242
242
  className: "text-muted-foreground",
243
243
  children: n?.label || e.name
244
244
  })]
245
- }), e.value && /* @__PURE__ */ S("span", {
245
+ }), e.value && /* @__PURE__ */ x("span", {
246
246
  className: "text-foreground font-mono font-medium tabular-nums",
247
247
  children: e.value.toLocaleString()
248
248
  })]
@@ -252,15 +252,15 @@ function G({ active: e, payload: t, className: n, indicator: r = "dot", hideLabe
252
252
  })]
253
253
  });
254
254
  }
255
- function K({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bottom", nameKey: i }) {
256
- let { config: a } = Me();
257
- return n?.length ? /* @__PURE__ */ S("div", {
258
- className: q("flex items-center justify-center gap-4", r === "top" ? "pb-3" : "pt-3", e),
255
+ function G({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bottom", nameKey: i }) {
256
+ let { config: a } = Pe();
257
+ return n?.length ? /* @__PURE__ */ x("div", {
258
+ className: K("flex items-center justify-center gap-4", r === "top" ? "pb-3" : "pt-3", e),
259
259
  children: n.filter((e) => e.type !== "none").map((e) => {
260
- let n = Ne(a, e, `${i || e.dataKey || "value"}`);
261
- return /* @__PURE__ */ C("div", {
262
- className: q("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
263
- children: [n?.icon && !t ? /* @__PURE__ */ S(n.icon, {}) : /* @__PURE__ */ S("div", {
260
+ let n = Fe(a, e, `${i || e.dataKey || "value"}`);
261
+ return /* @__PURE__ */ S("div", {
262
+ className: K("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
263
+ children: [n?.icon && !t ? /* @__PURE__ */ x(n.icon, {}) : /* @__PURE__ */ x("div", {
264
264
  className: "h-2 w-2 shrink-0 rounded-[2px]",
265
265
  style: { backgroundColor: e.color }
266
266
  }), n?.label]
@@ -268,18 +268,18 @@ function K({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bot
268
268
  })
269
269
  }) : null;
270
270
  }
271
- function Ne(e, t, n) {
271
+ function Fe(e, t, n) {
272
272
  if (typeof t != "object" || !t) return;
273
273
  let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
274
274
  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];
275
275
  }
276
- var q, Pe, Fe, Ie, J, Y, Le = U((() => {
277
- q = (...e) => e.filter(Boolean).join(" "), Pe = {
276
+ var K, Ie, Le, Re, q, J, ze = H((() => {
277
+ K = (...e) => e.filter(Boolean).join(" "), Ie = {
278
278
  light: "",
279
279
  dark: ".dark"
280
- }, Fe = l.createContext(null), Ie = ({ id: e, config: t }) => {
280
+ }, Le = u.createContext(null), Re = ({ id: e, config: t }) => {
281
281
  let n = Object.entries(t).filter(([, e]) => e.theme || e.color);
282
- return n.length ? /* @__PURE__ */ S("style", { dangerouslySetInnerHTML: { __html: Object.entries(Pe).map(([t, r]) => `
282
+ return n.length ? /* @__PURE__ */ x("style", { dangerouslySetInnerHTML: { __html: Object.entries(Ie).map(([t, r]) => `
283
283
  ${r} [data-chart=${e}] {
284
284
  ${n.map(([e, n]) => {
285
285
  let r = n.theme?.[t] || n.color;
@@ -287,122 +287,122 @@ ${n.map(([e, n]) => {
287
287
  }).join("\n")}
288
288
  }
289
289
  `).join("\n") } }) : null;
290
- }, J = R, Y = k;
290
+ }, q = F, J = D;
291
291
  }));
292
292
  //#endregion
293
293
  //#region src/chartDrillEvents.ts
294
- function Re(e) {
294
+ function Be(e) {
295
295
  return e?.[0]?.dataKey || "value";
296
296
  }
297
- function ze(e, t, n) {
297
+ function Ve(e, t, n) {
298
298
  if (!e) return null;
299
299
  let r = e.payload ?? e, i = r?.[t];
300
300
  if (i == null) return null;
301
- let a = Re(n);
301
+ let a = Be(n);
302
302
  return {
303
303
  category: String(i),
304
304
  series: a,
305
305
  value: typeof r?.[a] == "number" ? r[a] : void 0
306
306
  };
307
307
  }
308
- function Be(e, t) {
308
+ function He(e, t) {
309
309
  if (!e) return null;
310
310
  let n = e.name ?? e.payload?.name ?? e.root?.name;
311
311
  if (n == null) return null;
312
312
  let r = e.value ?? e.size ?? e.payload?.size;
313
313
  return {
314
314
  category: String(n),
315
- series: Re(t),
315
+ series: Be(t),
316
316
  value: typeof r == "number" ? r : void 0
317
317
  };
318
318
  }
319
- function Ve(e, t) {
319
+ function Ue(e, t) {
320
320
  if (!e) return null;
321
321
  let n = e.payload ?? e, r = n?.name;
322
322
  return r == null || n?.depth === 0 ? null : {
323
323
  category: String(r),
324
- series: Re(t),
324
+ series: Be(t),
325
325
  value: typeof n?.value == "number" ? n.value : void 0
326
326
  };
327
327
  }
328
- var He = U((() => {})), Ue = /* @__PURE__ */ Ee({ default: () => We });
329
- function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r = "name", series: i = [], className: a = "", onChartClick: o }) {
330
- let s = e === "column" ? "bar" : e, c = Array.isArray(t) ? t : [], [u, d] = l.useState(!1), f = l.useCallback((e) => {
331
- if (!o || !e) return;
328
+ var We = H((() => {})), Ge = /* @__PURE__ */ Oe({ default: () => Ke });
329
+ function Ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r = "name", series: i = [], className: a = "", colors: o, categoryColors: s, onChartClick: c, isAnimationActive: l }) {
330
+ let d = e === "column" ? "bar" : e, f = Array.isArray(t) ? t : [], p = l === !1 ? { isAnimationActive: !1 } : {}, [m, h] = u.useState(!1), g = u.useCallback((e) => {
331
+ if (!c || !e) return;
332
332
  let t = Array.isArray(e.activePayload) ? e.activePayload[0] : void 0;
333
- o({
333
+ c({
334
334
  category: e.activeLabel == null ? void 0 : String(e.activeLabel),
335
335
  series: t?.dataKey ? String(t.dataKey) : void 0,
336
336
  value: typeof t?.value == "number" ? t.value : void 0
337
337
  });
338
- }, [o]), p = l.useCallback((e) => {
339
- if (!o || !e) return;
338
+ }, [c]), ee = u.useCallback((e) => {
339
+ if (!c || !e) return;
340
340
  let t = e.payload?.[r], n = i[0]?.dataKey || "value";
341
- o({
341
+ c({
342
342
  category: t == null ? void 0 : String(t),
343
343
  series: n,
344
344
  value: typeof e.payload?.[n] == "number" ? e.payload[n] : void 0
345
345
  });
346
346
  }, [
347
- o,
347
+ c,
348
348
  r,
349
349
  i
350
- ]), m = o ? {
351
- onClick: f,
350
+ ]), _ = c ? {
351
+ onClick: g,
352
352
  style: { cursor: "pointer" }
353
- } : {}, h = o ? {
354
- onClick: p,
353
+ } : {}, te = c ? {
354
+ onClick: ee,
355
355
  style: { cursor: "pointer" }
356
- } : {}, g = l.useCallback((e) => {
357
- if (!o) return;
358
- let t = ze(e, r, i);
359
- t && o(t);
356
+ } : {}, ne = u.useCallback((e, t, n) => s && s[e == null ? "" : String(e)] || n[t % n.length], [s]), re = u.useCallback((e) => {
357
+ if (!c) return;
358
+ let t = Ve(e, r, i);
359
+ t && c(t);
360
360
  }, [
361
- o,
361
+ c,
362
362
  r,
363
363
  i
364
- ]), _ = l.useCallback((e) => {
365
- if (!o) return;
366
- let t = Be(e, i);
367
- t && o(t);
368
- }, [o, i]), ee = l.useCallback((e) => {
369
- if (!o) return;
370
- let t = Ve(e, i);
371
- t && o(t);
372
- }, [o, i]), te = o ? {
373
- onClick: g,
364
+ ]), ie = u.useCallback((e) => {
365
+ if (!c) return;
366
+ let t = He(e, i);
367
+ t && c(t);
368
+ }, [c, i]), ae = u.useCallback((e) => {
369
+ if (!c) return;
370
+ let t = Ue(e, i);
371
+ t && c(t);
372
+ }, [c, i]), oe = c ? {
373
+ onClick: re,
374
374
  cursor: "pointer"
375
- } : {}, ne = o ? {
376
- onClick: _,
375
+ } : {}, se = c ? {
376
+ onClick: ie,
377
377
  style: { cursor: "pointer" }
378
- } : {}, re = o ? {
379
- onClick: ee,
378
+ } : {}, ce = c ? {
379
+ onClick: ae,
380
380
  style: { cursor: "pointer" }
381
381
  } : {};
382
- l.useEffect(() => {
383
- let e = () => d(window.innerWidth < 640);
382
+ u.useEffect(() => {
383
+ let e = () => h(window.innerWidth < 640);
384
384
  return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
385
385
  }, []);
386
- let ie = {
387
- bar: E,
388
- "horizontal-bar": E,
389
- line: pe,
390
- area: ce,
391
- pie: j,
392
- donut: j,
393
- radar: N,
394
- scatter: L,
395
- funnel: ue,
396
- combo: E,
397
- treemap: E,
398
- sankey: E
399
- }[s] || E, ae = l.useCallback((e) => {
386
+ let le = {
387
+ bar: w,
388
+ "horizontal-bar": w,
389
+ line: k,
390
+ area: ue,
391
+ pie: A,
392
+ donut: A,
393
+ radar: ve,
394
+ scatter: P,
395
+ funnel: pe,
396
+ combo: w,
397
+ treemap: w,
398
+ sankey: w
399
+ }[d] || w, v = u.useCallback((e) => {
400
400
  if (e == null || e === "") return "";
401
401
  let t = typeof e == "string" ? e : String(e);
402
402
  if (/^\d{4}-\d{2}-\d{2}/.test(t)) {
403
403
  let e = new Date(t);
404
404
  if (!Number.isNaN(e.getTime())) {
405
- let t = (c.length > 1 ? Math.abs(new Date(String(c[c.length - 1][r] ?? "")).getTime() - new Date(String(c[0][r] ?? "")).getTime()) : 0) / (1e3 * 60 * 60 * 24);
405
+ let t = (f.length > 1 ? Math.abs(new Date(String(f[f.length - 1][r] ?? "")).getTime() - new Date(String(f[0][r] ?? "")).getTime()) : 0) / (1e3 * 60 * 60 * 24);
406
406
  try {
407
407
  return t <= 62 ? e.toLocaleDateString(void 0, {
408
408
  month: "short",
@@ -416,18 +416,18 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
416
416
  }
417
417
  }
418
418
  }
419
- return u && t.length > 8 ? t.slice(0, 8) + "…" : t;
419
+ return m && t.length > 8 ? t.slice(0, 8) + "…" : t;
420
420
  }, [
421
- c,
421
+ f,
422
422
  r,
423
- u
424
- ]), oe = l.useMemo(() => c.some((e) => String(e[r] || "").length > 5), [c, r]), v = () => [
423
+ m
424
+ ]), y = u.useMemo(() => f.some((e) => String(e[r] || "").length > 5), [f, r]), D = () => Array.isArray(o) && o.length > 0 ? o : [
425
425
  "hsl(var(--chart-1))",
426
426
  "hsl(var(--chart-2))",
427
427
  "hsl(var(--chart-3))",
428
428
  "hsl(var(--chart-4))",
429
429
  "hsl(var(--chart-5))"
430
- ], y = l.useCallback((e) => {
430
+ ], N = u.useCallback((e) => {
431
431
  if (e == null || e === "") return "";
432
432
  let t = typeof e == "number" ? e : Number(e);
433
433
  if (!Number.isFinite(t)) return String(e);
@@ -439,62 +439,60 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
439
439
  } catch {
440
440
  return String(t);
441
441
  }
442
- }, []), se = l.useMemo(() => ({
442
+ }, []), Se = u.useMemo(() => ({
443
443
  tickLine: !1,
444
444
  tickMargin: 10,
445
445
  axisLine: !1,
446
446
  interval: "preserveStartEnd",
447
- minTickGap: u ? 32 : 48,
448
- tickFormatter: ae,
449
- ...!u && oe && {
447
+ minTickGap: m ? 32 : 48,
448
+ tickFormatter: v,
449
+ ...!m && y && {
450
450
  angle: -35,
451
451
  textAnchor: "end",
452
452
  height: 60
453
453
  }
454
454
  }), [
455
- u,
456
- oe,
457
- ae
455
+ m,
456
+ y,
457
+ v
458
458
  ]);
459
- if (s === "pie" || s === "donut") {
460
- let e = s === "donut" ? 60 : 0, t = v(), o = { ...n };
461
- return c.forEach((e, n) => {
459
+ if (d === "pie" || d === "donut") {
460
+ let e = d === "donut" ? "52%" : 0, t = D(), o = { ...n };
461
+ return f.forEach((e, n) => {
462
462
  let i = e?.[r];
463
463
  if (i == null || i === "") return;
464
464
  let a = String(i);
465
465
  o[a] || (o[a] = {
466
466
  label: a,
467
- color: t[n % t.length]
467
+ color: ne(i, n, t)
468
468
  });
469
- }), /* @__PURE__ */ S(W, {
469
+ }), /* @__PURE__ */ x(U, {
470
470
  config: o,
471
471
  className: a,
472
- children: /* @__PURE__ */ C(j, { children: [
473
- /* @__PURE__ */ S(J, {
472
+ children: /* @__PURE__ */ S(A, { children: [
473
+ /* @__PURE__ */ x(q, {
474
474
  cursor: !1,
475
- content: /* @__PURE__ */ S(G, { hideLabel: !0 })
475
+ content: /* @__PURE__ */ x(W, { hideLabel: !0 })
476
476
  }),
477
- /* @__PURE__ */ S(A, {
478
- data: c,
477
+ /* @__PURE__ */ x(he, {
478
+ data: f,
479
479
  dataKey: i[0]?.dataKey || "value",
480
480
  nameKey: r || "name",
481
481
  innerRadius: e,
482
482
  strokeWidth: 5,
483
483
  paddingAngle: 2,
484
- outerRadius: 80,
485
- ...h,
486
- children: c.map((e, n) => {
487
- let i = o[String(e[r])]?.color;
488
- return i ||= t[n % t.length], /* @__PURE__ */ S(O, { fill: X(i) }, `cell-${n}`);
489
- })
484
+ outerRadius: "85%",
485
+ ...p,
486
+ ...te,
487
+ children: f.map((e, n) => /* @__PURE__ */ x(E, { fill: X(ne(e?.[r], n, t)) }, `cell-${n}`))
490
488
  }),
491
- /* @__PURE__ */ S(Y, {
489
+ /* @__PURE__ */ x(J, {
492
490
  verticalAlign: "bottom",
493
491
  wrapperStyle: {
494
- fontSize: u ? "11px" : "12px",
492
+ fontSize: m ? "11px" : "12px",
495
493
  paddingTop: "8px"
496
494
  },
497
- content: /* @__PURE__ */ S(K, {
495
+ content: /* @__PURE__ */ x(G, {
498
496
  nameKey: r,
499
497
  className: "flex-wrap"
500
498
  })
@@ -502,44 +500,44 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
502
500
  ] })
503
501
  });
504
502
  }
505
- if (s === "funnel") {
506
- let e = i[0]?.dataKey || "value", t = v(), s = o ? (t) => {
507
- t && o({
503
+ if (d === "funnel") {
504
+ let e = i[0]?.dataKey || "value", t = D(), o = c ? (t) => {
505
+ t && c({
508
506
  category: t?.payload?.[r] ?? t?.[r],
509
507
  value: t?.payload?.[e] ?? t?.[e]
510
508
  });
511
- } : void 0, l = s ? {
512
- onClick: s,
509
+ } : void 0, s = o ? {
510
+ onClick: o,
513
511
  style: { cursor: "pointer" }
514
- } : {}, u = [...c].sort((t, n) => {
512
+ } : {}, l = [...f].sort((t, n) => {
515
513
  let r = Number(t?.[e] ?? 0);
516
514
  return Number(n?.[e] ?? 0) - r;
517
515
  });
518
- return /* @__PURE__ */ S(W, {
516
+ return /* @__PURE__ */ x(U, {
519
517
  config: n,
520
518
  className: a,
521
- children: /* @__PURE__ */ C(ue, { children: [/* @__PURE__ */ S(J, { content: /* @__PURE__ */ S(G, {}) }), /* @__PURE__ */ C(le, {
519
+ children: /* @__PURE__ */ S(pe, { children: [/* @__PURE__ */ x(q, { content: /* @__PURE__ */ x(W, {}) }), /* @__PURE__ */ S(fe, {
522
520
  dataKey: e,
523
- data: u,
521
+ data: l,
524
522
  nameKey: r,
525
523
  isAnimationActive: !0,
526
- ...l,
527
- children: [/* @__PURE__ */ S(de, {
524
+ ...s,
525
+ children: [/* @__PURE__ */ x(me, {
528
526
  position: "right",
529
527
  fill: "hsl(var(--foreground))",
530
528
  stroke: "none",
531
529
  dataKey: r
532
- }), u.map((e, n) => /* @__PURE__ */ S(O, { fill: X(t[n % t.length]) }, `funnel-cell-${n}`))]
530
+ }), l.map((e, n) => /* @__PURE__ */ x(E, { fill: X(t[n % t.length]) }, `funnel-cell-${n}`))]
533
531
  })] })
534
532
  });
535
533
  }
536
- if (s === "treemap") {
537
- let e = i[0]?.dataKey || "value", t = v();
538
- return /* @__PURE__ */ S(W, {
534
+ if (d === "treemap") {
535
+ let e = i[0]?.dataKey || "value", t = D();
536
+ return /* @__PURE__ */ x(U, {
539
537
  config: n,
540
538
  className: a,
541
- children: /* @__PURE__ */ S(z, {
542
- data: c.map((n, i) => ({
539
+ children: /* @__PURE__ */ x(I, {
540
+ data: f.map((n, i) => ({
543
541
  name: String(n?.[r] ?? ""),
544
542
  size: Number(n?.[e]) || 0,
545
543
  fill: X(t[i % t.length])
@@ -547,9 +545,9 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
547
545
  dataKey: "size",
548
546
  nameKey: "name",
549
547
  isAnimationActive: !0,
550
- content: /* @__PURE__ */ S((e) => {
548
+ content: /* @__PURE__ */ x((e) => {
551
549
  let { x: t, y: n, width: r, height: i, name: a, fill: o } = e;
552
- return r <= 0 || i <= 0 ? null : /* @__PURE__ */ C("g", { children: [/* @__PURE__ */ S("rect", {
550
+ return r <= 0 || i <= 0 ? null : /* @__PURE__ */ S("g", { children: [/* @__PURE__ */ x("rect", {
553
551
  x: t,
554
552
  y: n,
555
553
  width: r,
@@ -557,7 +555,7 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
557
555
  fill: o,
558
556
  stroke: "hsl(var(--background))",
559
557
  strokeWidth: 2
560
- }), r > 48 && i > 18 ? /* @__PURE__ */ S("text", {
558
+ }), r > 48 && i > 18 ? /* @__PURE__ */ x("text", {
561
559
  x: t + 6,
562
560
  y: n + 18,
563
561
  fill: "#fff",
@@ -566,24 +564,24 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
566
564
  children: a
567
565
  }) : null] });
568
566
  }, {}),
569
- ...ne,
570
- children: /* @__PURE__ */ S(R, {})
567
+ ...se,
568
+ children: /* @__PURE__ */ x(F, {})
571
569
  })
572
570
  });
573
571
  }
574
- if (s === "sankey") {
575
- let e = i[0]?.dataKey || "value", t = i[0]?.label || e, o = c.filter((t) => (Number(t?.[e]) || 0) > 0), s = [{ name: t }, ...o.map((e) => ({ name: String(e?.[r] ?? "") }))], l = o.map((t, n) => ({
572
+ if (d === "sankey") {
573
+ let e = i[0]?.dataKey || "value", t = i[0]?.label || e, o = f.filter((t) => (Number(t?.[e]) || 0) > 0), s = [{ name: t }, ...o.map((e) => ({ name: String(e?.[r] ?? "") }))], c = o.map((t, n) => ({
576
574
  source: 0,
577
575
  target: n + 1,
578
576
  value: Number(t?.[e]) || 0
579
577
  }));
580
- return l.length === 0 ? /* @__PURE__ */ S("div", { className: a }) : /* @__PURE__ */ S(W, {
578
+ return c.length === 0 ? /* @__PURE__ */ x("div", { className: a }) : /* @__PURE__ */ x(U, {
581
579
  config: n,
582
580
  className: a,
583
- children: /* @__PURE__ */ S(F, {
581
+ children: /* @__PURE__ */ x(ye, {
584
582
  data: {
585
583
  nodes: s,
586
- links: l
584
+ links: c
587
585
  },
588
586
  nodePadding: 24,
589
587
  link: {
@@ -591,24 +589,24 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
591
589
  strokeOpacity: .25
592
590
  },
593
591
  node: { fill: "hsl(var(--chart-1))" },
594
- ...re,
595
- children: /* @__PURE__ */ S(R, {})
592
+ ...ce,
593
+ children: /* @__PURE__ */ x(F, {})
596
594
  })
597
595
  });
598
596
  }
599
- if (s === "radar") return /* @__PURE__ */ S(W, {
597
+ if (d === "radar") return /* @__PURE__ */ x(U, {
600
598
  config: n,
601
599
  className: a,
602
- children: /* @__PURE__ */ C(N, {
603
- data: c,
600
+ children: /* @__PURE__ */ S(ve, {
601
+ data: f,
604
602
  children: [
605
- /* @__PURE__ */ S(he, {}),
606
- /* @__PURE__ */ S(me, { dataKey: r }),
607
- /* @__PURE__ */ S(ge, {}),
608
- /* @__PURE__ */ S(J, { content: /* @__PURE__ */ S(G, {}) }),
609
- /* @__PURE__ */ S(Y, {
610
- content: /* @__PURE__ */ S(K, {}),
611
- ...u && {
603
+ /* @__PURE__ */ x(ge, {}),
604
+ /* @__PURE__ */ x(j, { dataKey: r }),
605
+ /* @__PURE__ */ x(_e, {}),
606
+ /* @__PURE__ */ x(q, { content: /* @__PURE__ */ x(W, {}) }),
607
+ /* @__PURE__ */ x(J, {
608
+ content: /* @__PURE__ */ x(G, {}),
609
+ ...m && {
612
610
  verticalAlign: "bottom",
613
611
  wrapperStyle: {
614
612
  fontSize: "11px",
@@ -617,8 +615,8 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
617
615
  }
618
616
  }),
619
617
  i.map((e) => {
620
- let t = X(n[e.dataKey]?.color || Ge);
621
- return /* @__PURE__ */ S(M, {
618
+ let t = X(n[e.dataKey]?.color || Y);
619
+ return /* @__PURE__ */ x(M, {
622
620
  dataKey: e.dataKey,
623
621
  stroke: t,
624
622
  fill: t,
@@ -628,36 +626,36 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
628
626
  ]
629
627
  })
630
628
  });
631
- if (s === "scatter") return /* @__PURE__ */ S(W, {
629
+ if (d === "scatter") return /* @__PURE__ */ x(U, {
632
630
  config: n,
633
631
  className: a,
634
- children: /* @__PURE__ */ C(L, { children: [
635
- /* @__PURE__ */ S(D, { vertical: !1 }),
636
- /* @__PURE__ */ S(B, {
632
+ children: /* @__PURE__ */ S(P, { children: [
633
+ /* @__PURE__ */ x(T, { vertical: !1 }),
634
+ /* @__PURE__ */ x(L, {
637
635
  type: "number",
638
636
  dataKey: r,
639
637
  name: String(n[r]?.label || r),
640
638
  tickLine: !1,
641
639
  axisLine: !1,
642
- minTickGap: u ? 32 : 48
640
+ minTickGap: m ? 32 : 48
643
641
  }),
644
- /* @__PURE__ */ S(V, {
642
+ /* @__PURE__ */ x(R, {
645
643
  type: "number",
646
644
  dataKey: i[0]?.dataKey || "value",
647
645
  name: String(n[i[0]?.dataKey]?.label || i[0]?.dataKey),
648
646
  tickLine: !1,
649
647
  axisLine: !1,
650
- tickFormatter: y,
648
+ tickFormatter: N,
651
649
  width: 48
652
650
  }),
653
- /* @__PURE__ */ S(H, {
651
+ /* @__PURE__ */ x(xe, {
654
652
  type: "number",
655
653
  range: [60, 400]
656
654
  }),
657
- /* @__PURE__ */ S(J, { content: /* @__PURE__ */ S(G, {}) }),
658
- /* @__PURE__ */ S(Y, {
659
- content: /* @__PURE__ */ S(K, {}),
660
- ...u && {
655
+ /* @__PURE__ */ x(q, { content: /* @__PURE__ */ x(W, {}) }),
656
+ /* @__PURE__ */ x(J, {
657
+ content: /* @__PURE__ */ x(G, {}),
658
+ ...m && {
661
659
  verticalAlign: "bottom",
662
660
  wrapperStyle: {
663
661
  fontSize: "11px",
@@ -666,47 +664,47 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
666
664
  }
667
665
  }),
668
666
  i.map((e, t) => {
669
- let r = v(), i = X(n[e.dataKey]?.color || r[t % r.length]), a = Z(e, "scatter");
670
- return /* @__PURE__ */ S(I, {
667
+ let r = D(), i = X(n[e.dataKey]?.color || r[t % r.length]), a = Z(e, "scatter");
668
+ return /* @__PURE__ */ x(be, {
671
669
  name: n[e.dataKey]?.label || e.dataKey,
672
- data: c,
670
+ data: f,
673
671
  fill: i,
674
672
  fillOpacity: a?.fillOpacity,
675
- ...te
673
+ ...oe
676
674
  }, e.dataKey);
677
675
  })
678
676
  ] })
679
677
  });
680
- if (s === "combo") return /* @__PURE__ */ S(W, {
678
+ if (d === "combo") return /* @__PURE__ */ x(U, {
681
679
  config: n,
682
680
  className: a,
683
- children: /* @__PURE__ */ C(E, {
684
- data: c,
681
+ children: /* @__PURE__ */ S(w, {
682
+ data: f,
685
683
  children: [
686
- /* @__PURE__ */ S(D, { vertical: !1 }),
687
- /* @__PURE__ */ S(B, {
684
+ /* @__PURE__ */ x(T, { vertical: !1 }),
685
+ /* @__PURE__ */ x(L, {
688
686
  dataKey: r,
689
- ...se
687
+ ...Se
690
688
  }),
691
- /* @__PURE__ */ S(V, {
689
+ /* @__PURE__ */ x(R, {
692
690
  yAxisId: "left",
693
691
  tickLine: !1,
694
692
  axisLine: !1,
695
- tickFormatter: y,
693
+ tickFormatter: N,
696
694
  width: 48
697
695
  }),
698
- /* @__PURE__ */ S(V, {
696
+ /* @__PURE__ */ x(R, {
699
697
  yAxisId: "right",
700
698
  orientation: "right",
701
699
  tickLine: !1,
702
700
  axisLine: !1,
703
- tickFormatter: y,
701
+ tickFormatter: N,
704
702
  width: 48
705
703
  }),
706
- /* @__PURE__ */ S(J, { content: /* @__PURE__ */ S(G, {}) }),
707
- /* @__PURE__ */ S(Y, {
708
- content: /* @__PURE__ */ S(K, {}),
709
- ...u && {
704
+ /* @__PURE__ */ x(q, { content: /* @__PURE__ */ x(W, {}) }),
705
+ /* @__PURE__ */ x(J, {
706
+ content: /* @__PURE__ */ x(G, {}),
707
+ ...m && {
710
708
  verticalAlign: "bottom",
711
709
  wrapperStyle: {
712
710
  fontSize: "11px",
@@ -715,8 +713,8 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
715
713
  }
716
714
  }),
717
715
  i.map((e, t) => {
718
- let r = X(n[e.dataKey]?.color || Ge), i = e.chartType || (t === 0 ? "bar" : "line"), a = i === "bar" ? "left" : "right", o = Z(e, i);
719
- return i === "line" ? /* @__PURE__ */ S(fe, {
716
+ let r = X(n[e.dataKey]?.color || Y), i = e.chartType || (t === 0 ? "bar" : "line"), a = i === "bar" ? "left" : "right", o = Z(e, i);
717
+ return i === "line" ? /* @__PURE__ */ x(O, {
720
718
  yAxisId: a,
721
719
  type: "monotone",
722
720
  dataKey: e.dataKey,
@@ -724,8 +722,9 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
724
722
  strokeWidth: 2,
725
723
  dot: !1,
726
724
  strokeOpacity: o?.strokeOpacity,
727
- strokeDasharray: o?.strokeDasharray
728
- }, e.dataKey) : i === "area" ? /* @__PURE__ */ S(w, {
725
+ strokeDasharray: o?.strokeDasharray,
726
+ ...p
727
+ }, e.dataKey) : i === "area" ? /* @__PURE__ */ x(C, {
729
728
  yAxisId: a,
730
729
  type: "monotone",
731
730
  dataKey: e.dataKey,
@@ -733,53 +732,90 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
733
732
  stroke: r,
734
733
  fillOpacity: o?.fillOpacity ?? .4,
735
734
  strokeOpacity: o?.strokeOpacity,
736
- strokeDasharray: o?.strokeDasharray
737
- }, e.dataKey) : /* @__PURE__ */ S(T, {
735
+ strokeDasharray: o?.strokeDasharray,
736
+ ...p
737
+ }, e.dataKey) : /* @__PURE__ */ x(de, {
738
738
  yAxisId: a,
739
739
  dataKey: e.dataKey,
740
740
  fill: r,
741
741
  radius: 4,
742
- fillOpacity: o?.fillOpacity
742
+ fillOpacity: o?.fillOpacity,
743
+ ...p
743
744
  }, e.dataKey);
744
745
  })
745
746
  ]
746
747
  })
747
748
  });
748
- let b = s === "horizontal-bar";
749
- return /* @__PURE__ */ S(W, {
749
+ let Ce = d === "horizontal-bar", z = D(), we = s ? Object.values(s).map((e) => X(String(e))) : [], Te = Array.from(new Set([
750
+ ...z,
751
+ ...we,
752
+ ...i.map((e, t) => X(n[e.dataKey]?.color || z[t % z.length] || Y))
753
+ ])), B = (e) => "g" + e.replace(/[^a-zA-Z0-9]/g, "");
754
+ return /* @__PURE__ */ x(U, {
750
755
  config: n,
751
756
  className: a,
752
- children: /* @__PURE__ */ C(ie, {
753
- data: c,
754
- layout: b ? "vertical" : "horizontal",
755
- ...m,
757
+ children: /* @__PURE__ */ S(le, {
758
+ data: f,
759
+ layout: Ce ? "vertical" : "horizontal",
760
+ ..._,
756
761
  children: [
757
- /* @__PURE__ */ S(D, { vertical: !1 }),
758
- b ? /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(B, {
762
+ /* @__PURE__ */ x("defs", { children: Te.map((e) => /* @__PURE__ */ S(u.Fragment, { children: [/* @__PURE__ */ S("linearGradient", {
763
+ id: `bg-${B(e)}`,
764
+ x1: "0",
765
+ y1: "0",
766
+ x2: "0",
767
+ y2: "1",
768
+ children: [/* @__PURE__ */ x("stop", {
769
+ offset: "0%",
770
+ style: { stopColor: e },
771
+ stopOpacity: .95
772
+ }), /* @__PURE__ */ x("stop", {
773
+ offset: "100%",
774
+ style: { stopColor: e },
775
+ stopOpacity: .5
776
+ })]
777
+ }), /* @__PURE__ */ S("linearGradient", {
778
+ id: `ag-${B(e)}`,
779
+ x1: "0",
780
+ y1: "0",
781
+ x2: "0",
782
+ y2: "1",
783
+ children: [/* @__PURE__ */ x("stop", {
784
+ offset: "0%",
785
+ style: { stopColor: e },
786
+ stopOpacity: .5
787
+ }), /* @__PURE__ */ x("stop", {
788
+ offset: "95%",
789
+ style: { stopColor: e },
790
+ stopOpacity: .05
791
+ })]
792
+ })] }, B(e))) }),
793
+ /* @__PURE__ */ x(T, { vertical: !1 }),
794
+ Ce ? /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(L, {
759
795
  type: "number",
760
796
  tickLine: !1,
761
797
  axisLine: !1,
762
- tickFormatter: y
763
- }), /* @__PURE__ */ S(V, {
798
+ tickFormatter: N
799
+ }), /* @__PURE__ */ x(R, {
764
800
  type: "category",
765
801
  dataKey: r,
766
802
  tickLine: !1,
767
803
  axisLine: !1,
768
- width: Math.min(140, Math.max(60, Math.max(...c.map((e) => String(e[r] ?? "").length)) * 7)),
769
- tickFormatter: ae
770
- })] }) : /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(B, {
804
+ width: Math.min(140, Math.max(60, Math.max(...f.map((e) => String(e[r] ?? "").length)) * 7)),
805
+ tickFormatter: v
806
+ })] }) : /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(L, {
771
807
  dataKey: r,
772
- ...se
773
- }), /* @__PURE__ */ S(V, {
808
+ ...Se
809
+ }), /* @__PURE__ */ x(R, {
774
810
  tickLine: !1,
775
811
  axisLine: !1,
776
- tickFormatter: y,
812
+ tickFormatter: N,
777
813
  width: 48
778
814
  })] }),
779
- /* @__PURE__ */ S(J, { content: /* @__PURE__ */ S(G, {}) }),
780
- /* @__PURE__ */ S(Y, {
781
- content: /* @__PURE__ */ S(K, {}),
782
- ...u && {
815
+ /* @__PURE__ */ x(q, { content: /* @__PURE__ */ x(W, {}) }),
816
+ /* @__PURE__ */ x(J, {
817
+ content: /* @__PURE__ */ x(G, {}),
818
+ ...m && {
783
819
  verticalAlign: "bottom",
784
820
  wrapperStyle: {
785
821
  fontSize: "11px",
@@ -788,39 +824,43 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
788
824
  }
789
825
  }),
790
826
  i.map((e, t) => {
791
- let r = v(), a = e.variant === "comparison", o = a ? i.slice(0, t).find((e) => e.variant !== "comparison") || i[0] : e, l = a ? i.indexOf(o) : t, u = X(n[o.dataKey]?.color || r[l % r.length] || Ge);
792
- if (s === "bar" || s === "horizontal-bar") {
793
- let t = i.filter((e) => e.variant !== "comparison").length === 1 && !a && i.length === 1 && c.length > 1, n = Z(e, "bar");
794
- return /* @__PURE__ */ S(T, {
827
+ let a = D(), 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 = X(n[s.dataKey]?.color || a[c % a.length] || Y);
828
+ if (d === "bar" || d === "horizontal-bar") {
829
+ let t = i.filter((e) => e.variant !== "comparison").length === 1 && !o && i.length === 1 && f.length > 1, n = Z(e, "bar");
830
+ return /* @__PURE__ */ x(de, {
795
831
  dataKey: e.dataKey,
796
- fill: u,
832
+ fill: `url(#bg-${B(l)})`,
797
833
  radius: 4,
798
834
  fillOpacity: n?.fillOpacity,
799
- children: t && c.map((e, t) => /* @__PURE__ */ S(O, { fill: X(r[t % r.length]) }, `cell-${t}`))
835
+ ...p,
836
+ children: t && f.map((e, t) => /* @__PURE__ */ x(E, { fill: `url(#bg-${B(X(ne(e?.[r], t, a)))})` }, `cell-${t}`))
800
837
  }, e.dataKey);
801
838
  }
802
- if (s === "line") {
839
+ if (d === "line") {
803
840
  let t = Z(e, "line");
804
- return /* @__PURE__ */ S(fe, {
841
+ return /* @__PURE__ */ x(O, {
805
842
  type: "monotone",
806
843
  dataKey: e.dataKey,
807
- stroke: u,
844
+ stroke: l,
808
845
  strokeWidth: 2,
809
846
  dot: !1,
810
847
  strokeOpacity: t?.strokeOpacity,
811
- strokeDasharray: t?.strokeDasharray
848
+ strokeDasharray: t?.strokeDasharray,
849
+ ...p
812
850
  }, e.dataKey);
813
851
  }
814
- if (s === "area") {
852
+ if (d === "area") {
815
853
  let t = Z(e, "area");
816
- return /* @__PURE__ */ S(w, {
854
+ return /* @__PURE__ */ x(C, {
817
855
  type: "monotone",
818
856
  dataKey: e.dataKey,
819
- fill: u,
820
- stroke: u,
821
- fillOpacity: t?.fillOpacity ?? .4,
857
+ fill: `url(#ag-${B(l)})`,
858
+ stroke: l,
859
+ strokeWidth: 2,
860
+ fillOpacity: t?.fillOpacity ?? 1,
822
861
  strokeOpacity: t?.strokeOpacity,
823
- strokeDasharray: t?.strokeDasharray
862
+ strokeDasharray: t?.strokeDasharray,
863
+ ...p
824
864
  }, e.dataKey);
825
865
  }
826
866
  return null;
@@ -829,8 +869,8 @@ function We({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
829
869
  })
830
870
  });
831
871
  }
832
- var Ge, Ke, X, Z, qe = U((() => {
833
- Le(), He(), Ge = "hsl(var(--primary))", Ke = {
872
+ var Y, qe, X, Z, Je = H((() => {
873
+ ze(), We(), Y = "hsl(var(--primary))", qe = {
834
874
  slate: "#64748b",
835
875
  gray: "#6b7280",
836
876
  zinc: "#71717a",
@@ -853,14 +893,14 @@ var Ge, Ke, X, Z, qe = U((() => {
853
893
  fuchsia: "#d946ef",
854
894
  pink: "#ec4899",
855
895
  rose: "#f43f5e"
856
- }, X = (e) => Ke[e] || e, Z = (e, t) => e?.variant === "comparison" ? {
896
+ }, X = (e) => qe[e] || e, Z = (e, t) => e?.variant === "comparison" ? {
857
897
  strokeOpacity: typeof e.opacity == "number" ? e.opacity : t === "line" || t === "scatter" ? .5 : .6,
858
898
  fillOpacity: typeof e.opacity == "number" ? e.opacity : t === "bar" ? .4 : t === "area" ? .2 : .5,
859
899
  strokeDasharray: e.dashArray ?? (t === "line" || t === "area" ? "4 4" : void 0)
860
900
  } : null;
861
- })), Je = u.lazy(() => Promise.resolve().then(() => (je(), De))), Ye = u.lazy(() => Promise.resolve().then(() => (qe(), Ue))), Xe = ({ schema: e }) => /* @__PURE__ */ S(d, {
862
- fallback: /* @__PURE__ */ S(b, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
863
- children: /* @__PURE__ */ S(Je, {
901
+ })), Ye = d.lazy(() => Promise.resolve().then(() => (Ne(), ke))), Xe = d.lazy(() => Promise.resolve().then(() => (Je(), Ge))), Ze = ({ schema: e }) => /* @__PURE__ */ x(f, {
902
+ fallback: /* @__PURE__ */ x(y, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
903
+ children: /* @__PURE__ */ x(Ye, {
864
904
  data: e.data,
865
905
  dataKey: e.dataKey,
866
906
  xAxisKey: e.xAxisKey,
@@ -869,7 +909,7 @@ var Ge, Ke, X, Z, qe = U((() => {
869
909
  color: e.color
870
910
  })
871
911
  }), Q = ({ schema: e, onChartClick: t }) => {
872
- let n = u.useMemo(() => {
912
+ let n = d.useMemo(() => {
873
913
  let t = e.series, n = e.xAxisKey, r = e.config;
874
914
  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) {
875
915
  let n = e.colors || [
@@ -893,15 +933,18 @@ var Ge, Ke, X, Z, qe = U((() => {
893
933
  className: e.className
894
934
  };
895
935
  }, [e]);
896
- return /* @__PURE__ */ S(d, {
897
- fallback: /* @__PURE__ */ S(b, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
898
- children: /* @__PURE__ */ S(Ye, {
936
+ return /* @__PURE__ */ x(f, {
937
+ fallback: /* @__PURE__ */ x(y, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
938
+ children: /* @__PURE__ */ x(Xe, {
899
939
  chartType: n.chartType,
900
940
  data: n.data,
901
941
  config: n.config,
902
942
  xAxisKey: n.xAxisKey,
903
943
  series: n.series,
904
944
  className: n.className,
945
+ colors: Array.isArray(e.colors) ? e.colors : void 0,
946
+ categoryColors: e.categoryColors,
947
+ isAnimationActive: e.isAnimationActive,
905
948
  onChartClick: t
906
949
  })
907
950
  });
@@ -911,7 +954,7 @@ var Ge, Ke, X, Z, qe = U((() => {
911
954
  function $(e) {
912
955
  return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
913
956
  }
914
- function Ze(e, t) {
957
+ function Qe(e, t) {
915
958
  let { field: n, function: r, groupBy: i } = t, a = {};
916
959
  for (let t of e) {
917
960
  let e = String(t[i] ?? "Unknown");
@@ -942,9 +985,9 @@ function Ze(e, t) {
942
985
  };
943
986
  });
944
987
  }
945
- async function Qe(e, t, n, r, a) {
988
+ async function $e(e, t, n, r, i) {
946
989
  if (!e.length || !t) return e;
947
- let o = a || ((e, t) => t), s = `__raw_${t}`, c = n?.fields?.[t];
990
+ let o = i || ((e, t) => t), s = `__raw_${t}`, c = n?.fields?.[t];
948
991
  if (!c) {
949
992
  let n = /^\d{4}-\d{2}-\d{2}/;
950
993
  return e.map((e) => {
@@ -984,16 +1027,16 @@ async function Qe(e, t, n, r, a) {
984
1027
  ...e,
985
1028
  [s]: e[t]
986
1029
  }));
987
- let a = [...new Set(e.map((e) => e[t]).filter((e) => e != null))];
988
- if (a.length === 0) return e.map((e) => ({
1030
+ let i = [...new Set(e.map((e) => e[t]).filter((e) => e != null))];
1031
+ if (i.length === 0) return e.map((e) => ({
989
1032
  ...e,
990
1033
  [s]: e[t]
991
1034
  }));
992
1035
  let o = c.id_field || "id";
993
1036
  try {
994
- let l = i(await r.find(n, {
995
- $filter: { [o]: { $in: a } },
996
- $top: a.length
1037
+ let l = a(await r.find(n, {
1038
+ $filter: { [o]: { $in: i } },
1039
+ $top: i.length
997
1040
  })), u = c.reference_field || c.display_field || "name", d = {};
998
1041
  for (let e of l) {
999
1042
  let t = String(e[o] ?? e.id ?? e._id ?? ""), n = e[u] || e.name || e.label || e.title || t;
@@ -1028,74 +1071,107 @@ async function Qe(e, t, n, r, a) {
1028
1071
  };
1029
1072
  });
1030
1073
  }
1031
- var $e = (e) => {
1032
- let { schema: l } = e, u = e.onSegmentClick, d = p(ve), b = e.dataSource || d?.dataSource, x = ye(l.bind), { fieldOptionLabel: w } = Ce(), ce = g(w);
1033
- m(() => {
1034
- ce.current = w;
1035
- }, [w]);
1036
- let [T, E] = _([]), [D, O] = _(() => !(Array.isArray(l.data) && l.data.length > 0) && (!!l.objectName || !!l.dataset)), [le, ue] = _(null), [de, k] = _(null), { openRecordList: fe } = be(), pe = we(), A = h(() => l.aggregate ? JSON.stringify(l.aggregate) : "", [l.aggregate]), j = h(() => l.filter ? JSON.stringify(l.filter) : "", [l.filter]), me = h(() => l.compareTo ? JSON.stringify(l.compareTo) : "", [l.compareTo]), he = h(() => l.dataset ? JSON.stringify({
1037
- d: l.dataset,
1038
- dim: l.dimensions ?? [],
1039
- val: l.values ?? []
1074
+ var et = (e) => {
1075
+ let { schema: u } = e, d = e.onSegmentClick, f = m(Ce), y = e.dataSource || f?.dataSource, b = z(u.bind), { fieldOptionLabel: C } = Ee(), ue = ee(C);
1076
+ h(() => {
1077
+ ue.current = C;
1078
+ }, [C]);
1079
+ let [de, w] = _([]), [T, E] = _(() => !(Array.isArray(u.data) && u.data.length > 0) && (!!u.objectName || !!u.dataset)), [fe, pe] = _(null), [me, D] = _(null), [O, k] = _(null), { openRecordList: he } = we(), A = De(), j = g(() => u.aggregate ? JSON.stringify(u.aggregate) : "", [u.aggregate]), ge = g(() => u.filter ? JSON.stringify(u.filter) : "", [u.filter]), _e = g(() => u.compareTo ? JSON.stringify(u.compareTo) : "", [u.compareTo]), M = g(() => u.dataset ? JSON.stringify({
1080
+ d: u.dataset,
1081
+ dim: u.dimensions ?? [],
1082
+ val: u.values ?? []
1040
1083
  }) : "", [
1041
- l.dataset,
1042
- l.dimensions,
1043
- l.values
1044
- ]), ge = (e) => e !== "pie" && e !== "donut" && e !== "funnel", M = f(async (e, t) => {
1045
- if (l.aggregate && typeof e.aggregate == "function") {
1046
- let n = l.aggregate.groupBy;
1084
+ u.dataset,
1085
+ u.dimensions,
1086
+ u.values
1087
+ ]), ve = (e) => e !== "pie" && e !== "donut" && e !== "funnel";
1088
+ h(() => {
1089
+ let e = !1;
1090
+ return (async () => {
1091
+ try {
1092
+ let t = {
1093
+ headers: { accept: "application/json" },
1094
+ credentials: "include"
1095
+ }, r = u.objectName, i, a = u.aggregate?.groupBy;
1096
+ if (r) i = a && typeof a == "object" && !Array.isArray(a) ? a.field : typeof a == "string" ? a : u.xAxisKey;
1097
+ else if (u.dataset) {
1098
+ let e = Array.isArray(u.dimensions) && u.dimensions.length ? u.dimensions[0] : void 0, n = await (await fetch(`/api/v1/meta/dataset/${encodeURIComponent(u.dataset)}`, t)).json().catch(() => null), a = n?.item ?? n?.data ?? n;
1099
+ r = a?.object, i = ((a?.dimensions || []).find((t) => t?.name === e) ?? (a?.dimensions || [])[0])?.field ?? e;
1100
+ }
1101
+ if (!r || !i) {
1102
+ e || k(null);
1103
+ return;
1104
+ }
1105
+ let o = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(r)}`, t)).json().catch(() => null), s = n((o?.item ?? o?.data ?? o)?.fields?.[i]?.options);
1106
+ e || k(s);
1107
+ } catch {
1108
+ e || k(null);
1109
+ }
1110
+ })(), () => {
1111
+ e = !0;
1112
+ };
1113
+ }, [
1114
+ u.objectName,
1115
+ u.dataset,
1116
+ M,
1117
+ j,
1118
+ u.xAxisKey
1119
+ ]);
1120
+ let N = p(async (e, t) => {
1121
+ if (u.aggregate && typeof e.aggregate == "function") {
1122
+ let n = u.aggregate.groupBy;
1047
1123
  if (n && typeof n == "object" && !Array.isArray(n)) {
1048
- let r = l.aggregate.field, i = l.aggregate.function, a = {
1124
+ let r = u.aggregate.field, i = u.aggregate.function, a = {
1049
1125
  function: i,
1050
1126
  alias: r || i
1051
1127
  };
1052
1128
  i !== "count" && r && (a.field = r);
1053
- let o = await e.aggregate(l.objectName, {
1129
+ let o = await e.aggregate(u.objectName, {
1054
1130
  groupBy: [n],
1055
1131
  aggregations: [a],
1056
1132
  where: t
1057
1133
  });
1058
1134
  return Array.isArray(o) ? o : [];
1059
1135
  }
1060
- let r = await e.aggregate(l.objectName, {
1061
- field: l.aggregate.field,
1062
- function: l.aggregate.function,
1136
+ let r = await e.aggregate(u.objectName, {
1137
+ field: u.aggregate.field,
1138
+ function: u.aggregate.function,
1063
1139
  groupBy: n,
1064
1140
  filter: t
1065
1141
  });
1066
1142
  return Array.isArray(r) ? r : [];
1067
1143
  }
1068
1144
  if (typeof e.find == "function") {
1069
- let n = i(await e.find(l.objectName, { $filter: t }));
1070
- return l.aggregate && n.length > 0 && (n = Ze(n, l.aggregate)), n;
1145
+ let n = a(await e.find(u.objectName, { $filter: t }));
1146
+ return u.aggregate && n.length > 0 && (n = Qe(n, u.aggregate)), n;
1071
1147
  }
1072
1148
  return [];
1073
- }, [l.objectName, A]), N = f(async (e, t) => {
1074
- if (!e || !l.objectName && !l.dataset) {
1075
- t.current && O(!1);
1149
+ }, [u.objectName, j]), ye = p(async (e, t) => {
1150
+ if (!e || !u.objectName && !u.dataset) {
1151
+ t.current && E(!1);
1076
1152
  return;
1077
1153
  }
1078
- t.current && (O(!0), ue(null));
1154
+ t.current && (E(!0), pe(null));
1079
1155
  try {
1080
- if (l.dataset && typeof e.queryDataset == "function") {
1081
- let n = o(l.filter), r = await e.queryDataset(l.dataset, {
1082
- dimensions: Array.isArray(l.dimensions) ? l.dimensions : [],
1083
- measures: Array.isArray(l.values) ? l.values : [],
1156
+ if (u.dataset && typeof e.queryDataset == "function") {
1157
+ let n = s(u.filter), r = await e.queryDataset(u.dataset, {
1158
+ dimensions: Array.isArray(u.dimensions) ? u.dimensions : [],
1159
+ measures: Array.isArray(u.values) ? u.values : [],
1084
1160
  ...n ? { runtimeFilter: n } : {}
1085
1161
  });
1086
- t.current && E(Array.isArray(r?.rows) ? r.rows : []);
1162
+ t.current && w(Array.isArray(r?.rows) ? r.rows : []);
1087
1163
  return;
1088
1164
  }
1089
- let n = o(l.filter), r = l.compareTo, i = !!r && ge(l.chartType), a = i ? c(l.filter, r) : null, [s, u] = await Promise.all([M(e, n), a ? M(e, a) : Promise.resolve([])]), d = s, f = l.aggregate?.groupBy, p = f && typeof f == "object" && !Array.isArray(f) ? f.alias || f.field : f || l.xAxisKey;
1090
- if (i && u.length > 0 && l.aggregate) {
1091
- let e = l.aggregate.field, t = l.aggregate.function, n = (n) => {
1165
+ let n = s(u.filter), r = u.compareTo, i = !!r && ve(u.chartType), a = i ? l(u.filter, r) : null, [o, c] = await Promise.all([N(e, n), a ? N(e, a) : Promise.resolve([])]), d = o, f = u.aggregate?.groupBy, p = f && typeof f == "object" && !Array.isArray(f) ? f.alias || f.field : f || u.xAxisKey;
1166
+ if (i && c.length > 0 && u.aggregate) {
1167
+ let e = u.aggregate.field, t = u.aggregate.function, n = (n) => {
1092
1168
  if (n == null) return null;
1093
1169
  let r = `${e}_${t}`;
1094
1170
  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;
1095
1171
  }, r = `${e}__comparison`, i = p;
1096
- if (i && d.some((e) => e[i] != null) && u.some((e) => e[i] != null)) {
1172
+ if (i && d.some((e) => e[i] != null) && c.some((e) => e[i] != null)) {
1097
1173
  let e = /* @__PURE__ */ new Map();
1098
- for (let t of u) {
1174
+ for (let t of c) {
1099
1175
  let r = String(t[i] ?? "");
1100
1176
  e.set(r, n(t));
1101
1177
  }
@@ -1107,7 +1183,7 @@ var $e = (e) => {
1107
1183
  };
1108
1184
  });
1109
1185
  let t = new Set(d.map((e) => String(e[i] ?? "")));
1110
- for (let e of u) {
1186
+ for (let e of c) {
1111
1187
  let a = String(e[i] ?? "");
1112
1188
  t.has(a) || d.push({
1113
1189
  [i]: a,
@@ -1115,9 +1191,9 @@ var $e = (e) => {
1115
1191
  });
1116
1192
  }
1117
1193
  } else {
1118
- let e = Math.max(d.length, u.length), t = [];
1194
+ let e = Math.max(d.length, c.length), t = [];
1119
1195
  for (let i = 0; i < e; i++) {
1120
- let e = d[i] || {}, a = u[i];
1196
+ let e = d[i] || {}, a = c[i];
1121
1197
  t.push(a ? {
1122
1198
  ...e,
1123
1199
  [r]: n(a)
@@ -1127,139 +1203,146 @@ var $e = (e) => {
1127
1203
  }
1128
1204
  }
1129
1205
  if (p && typeof e.getObjectSchema == "function") try {
1130
- let t = await e.getObjectSchema(l.objectName);
1131
- d = await Qe(d, p, t, e, (e, t) => ce.current(l.objectName, p, e, t));
1206
+ let t = await e.getObjectSchema(u.objectName);
1207
+ d = await $e(d, p, t, e, (e, t) => ue.current(u.objectName, p, e, t));
1132
1208
  } catch {}
1133
- t.current && E(d);
1209
+ t.current && w(d);
1134
1210
  } catch (e) {
1135
- console.error("[ObjectChart] Fetch error:", e), t.current && ue(e instanceof Error ? e.message : "Failed to load chart data");
1211
+ console.error("[ObjectChart] Fetch error:", e), t.current && pe(e instanceof Error ? e.message : "Failed to load chart data");
1136
1212
  } finally {
1137
- t.current && O(!1);
1213
+ t.current && E(!1);
1138
1214
  }
1139
1215
  }, [
1140
- l.objectName,
1141
- he,
1142
- A,
1216
+ u.objectName,
1217
+ M,
1143
1218
  j,
1144
- me,
1145
- l.xAxisKey,
1146
- l.chartType,
1147
- M
1219
+ ge,
1220
+ _e,
1221
+ u.xAxisKey,
1222
+ u.chartType,
1223
+ N
1148
1224
  ]);
1149
- m(() => {
1225
+ h(() => {
1150
1226
  let e = { current: !0 };
1151
- return (l.objectName || l.dataset) && !x && !l.data ? N(b, e) : e.current && O(!1), () => {
1227
+ return (u.objectName || u.dataset) && !b && !u.data ? ye(y, e) : e.current && E(!1), () => {
1152
1228
  e.current = !1;
1153
1229
  };
1154
1230
  }, [
1155
- l.objectName,
1156
- he,
1231
+ u.objectName,
1232
+ M,
1233
+ y,
1157
1234
  b,
1158
- x,
1159
- l.data,
1235
+ u.data,
1236
+ ge,
1160
1237
  j,
1161
- A,
1162
- me,
1163
- N
1238
+ _e,
1239
+ ye
1164
1240
  ]);
1165
- let P = x || l.data || T, F = Array.isArray(P) ? P : [], I = l.drillDown, L = l.aggregate?.groupBy || l.xAxisKey, R = h(() => {
1166
- if (!L) return /* @__PURE__ */ new Map();
1167
- let e = /* @__PURE__ */ new Map(), t = `__raw_${L}`;
1168
- for (let n of F) {
1169
- let r = n?.[L];
1241
+ let be = b || u.data || de, P = Array.isArray(be) ? be : [], F = u.drillDown, I = u.aggregate?.groupBy || u.xAxisKey, L = g(() => {
1242
+ if (!I) return /* @__PURE__ */ new Map();
1243
+ let e = /* @__PURE__ */ new Map(), t = `__raw_${I}`;
1244
+ for (let n of P) {
1245
+ let r = n?.[I];
1170
1246
  if (r == null) continue;
1171
1247
  let i = t in (n || {}) ? n[t] : r;
1172
1248
  e.set(String(r), i);
1173
1249
  }
1174
1250
  return e;
1175
- }, [F, L]), z = l.compareTo, B = !!z && ge(l.chartType) && !!l.aggregate && F.some((e) => e[`${l.aggregate.field}__comparison`] != null), V = h(() => {
1176
- let e = Array.isArray(l.series) ? l.series : null;
1177
- if (!B) return e;
1178
- let t = e || [{ dataKey: l.aggregate.field }], r = {
1251
+ }, [P, I]), R = u.compareTo, xe = !!R && ve(u.chartType) && !!u.aggregate && P.some((e) => e[`${u.aggregate.field}__comparison`] != null), V = g(() => {
1252
+ let e = Array.isArray(u.series) ? u.series : null;
1253
+ if (!xe) return e;
1254
+ let t = e || [{ dataKey: u.aggregate.field }], n = {
1179
1255
  vsLastWeek: "Previous week",
1180
1256
  vsLastMonth: "Previous month",
1181
1257
  vsLastQuarter: "Previous quarter",
1182
1258
  vsLastYear: "Previous year",
1183
1259
  vsYesterday: "Yesterday",
1184
1260
  vsPreviousPeriod: "Previous period"
1185
- }[n(z, l.filter)] || "Previous period";
1261
+ }[r(R, u.filter)] || "Previous period";
1186
1262
  return [...t.map((e) => ({
1187
1263
  ...e,
1188
1264
  variant: e.variant || "current"
1189
1265
  })), {
1190
- dataKey: `${l.aggregate.field}__comparison`,
1191
- label: r,
1266
+ dataKey: `${u.aggregate.field}__comparison`,
1267
+ label: n,
1192
1268
  variant: "comparison"
1193
1269
  }];
1194
1270
  }, [
1195
- B,
1196
- l.series,
1197
- l.aggregate,
1198
- l.filter,
1199
- z
1200
- ]), H = l.dataset ? t(F, l.dimensions, l.values) : null, Te = H ? {
1201
- ...l,
1271
+ xe,
1272
+ u.series,
1273
+ u.aggregate,
1274
+ u.filter,
1275
+ R
1276
+ ]), H = u.dataset ? t(P, u.dimensions, u.values) : null, Oe = H ? {
1277
+ ...u,
1202
1278
  data: H.data,
1203
1279
  xAxisKey: H.xAxisKey,
1204
1280
  series: H.series
1205
1281
  } : {
1206
- ...l,
1207
- data: F,
1282
+ ...u,
1283
+ data: P,
1208
1284
  ...V ? { series: V } : {}
1285
+ }, ke = u.colors && !Array.isArray(u.colors) && typeof u.colors == "object" ? u.colors : null, Ae = Array.isArray(u.colors) ? u.colors : void 0, je = O || ke ? {
1286
+ ...O || {},
1287
+ ...ke || {}
1288
+ } : void 0, Me = {
1289
+ ...Oe,
1290
+ colors: Ae,
1291
+ ...je ? { categoryColors: je } : {}
1209
1292
  };
1210
- if (D && F.length === 0) return /* @__PURE__ */ S("div", {
1211
- className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (l.className || ""),
1293
+ if (T && P.length === 0) return /* @__PURE__ */ x("div", {
1294
+ className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (u.className || ""),
1212
1295
  "data-testid": "chart-loading",
1213
1296
  children: "Loading chart data…"
1214
1297
  });
1215
- if (le) return /* @__PURE__ */ C("div", {
1216
- className: "flex flex-col items-center justify-center gap-2 p-4 " + (l.className || ""),
1298
+ if (fe) return /* @__PURE__ */ S("div", {
1299
+ className: "flex flex-col items-center justify-center gap-2 p-4 " + (u.className || ""),
1217
1300
  "data-testid": "chart-error",
1218
1301
  role: "alert",
1219
1302
  children: [
1220
- /* @__PURE__ */ S(xe, { className: "h-6 w-6 text-destructive opacity-60" }),
1221
- /* @__PURE__ */ S("p", {
1303
+ /* @__PURE__ */ x(Te, { className: "h-6 w-6 text-destructive opacity-60" }),
1304
+ /* @__PURE__ */ x("p", {
1222
1305
  className: "text-xs text-destructive font-medium",
1223
1306
  children: "Failed to load chart data"
1224
1307
  }),
1225
- /* @__PURE__ */ S("p", {
1308
+ /* @__PURE__ */ x("p", {
1226
1309
  className: "text-xs text-muted-foreground max-w-xs text-center",
1227
- children: le
1310
+ children: fe
1228
1311
  })
1229
1312
  ]
1230
1313
  });
1231
- if (!b && l.objectName && F.length === 0) return /* @__PURE__ */ C("div", {
1232
- className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (l.className || ""),
1314
+ if (!y && u.objectName && P.length === 0) return /* @__PURE__ */ S("div", {
1315
+ className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (u.className || ""),
1233
1316
  "data-testid": "chart-no-datasource",
1234
1317
  children: [
1235
1318
  "No data source available for “",
1236
- l.objectName,
1319
+ u.objectName,
1237
1320
  "”"
1238
1321
  ]
1239
1322
  });
1240
- let U = a(I) ? (e) => {
1241
- let t = e.category, n = t != null && R.has(String(t)) ? R.get(String(t)) : t;
1242
- k({
1323
+ let Ne = o(F) ? (e) => {
1324
+ let t = e.category, n = t != null && L.has(String(t)) ? L.get(String(t)) : t;
1325
+ D({
1243
1326
  ...e,
1244
1327
  category: n,
1245
1328
  categoryLabel: t,
1246
1329
  scope: "cell"
1247
1330
  });
1248
- } : void 0, Ee = u ?? U, De = !u && de && l.objectName ? (() => {
1249
- let e = r(I, de, { groupByField: L }), t = {
1250
- ...l.filter || {},
1331
+ } : void 0, Pe = d ?? Ne, U = !d && me && u.objectName ? (() => {
1332
+ let e = i(F, me, { groupByField: I }), t = {
1333
+ ...u.filter || {},
1251
1334
  ...e
1252
- }, n = s(I, de, l.title || "Details"), i = I?.target ?? "drawer", a = /* @__PURE__ */ S("div", {
1335
+ }, n = c(F, me, u.title || "Details"), r = F?.target ?? "drawer", a = /* @__PURE__ */ x("div", {
1253
1336
  className: "overflow-auto",
1254
1337
  "data-testid": "chart-drill-body",
1255
- children: /* @__PURE__ */ S(_e, {
1338
+ children: /* @__PURE__ */ x(Se, {
1256
1339
  schema: {
1257
1340
  type: "object-data-table",
1258
- objectName: l.objectName,
1341
+ objectName: u.objectName,
1259
1342
  filter: t,
1260
1343
  pagination: !0,
1261
- pageSize: I?.maxRows,
1262
- columns: I?.columns?.map((e) => ({
1344
+ pageSize: F?.maxRows,
1345
+ columns: F?.columns?.map((e) => ({
1263
1346
  accessorKey: e,
1264
1347
  header: e
1265
1348
  })),
@@ -1269,58 +1352,58 @@ var $e = (e) => {
1269
1352
  target: "dialog"
1270
1353
  }
1271
1354
  },
1272
- dataSource: b
1355
+ dataSource: y
1273
1356
  })
1274
- }), o = fe && l.objectName ? /* @__PURE__ */ C(ee, {
1357
+ }), o = he && u.objectName ? /* @__PURE__ */ S(te, {
1275
1358
  type: "button",
1276
1359
  variant: "ghost",
1277
1360
  size: "sm",
1278
1361
  "data-testid": "drill-open-in-list",
1279
1362
  onClick: () => {
1280
- fe(l.objectName, t), k(null);
1363
+ he(u.objectName, t), D(null);
1281
1364
  },
1282
- children: [pe("dashboard.openInList", "Open in list"), /* @__PURE__ */ S(Se, { className: "ml-1 h-3.5 w-3.5" })]
1365
+ children: [A("dashboard.openInList", "Open in list"), /* @__PURE__ */ x(B, { className: "ml-1 h-3.5 w-3.5" })]
1283
1366
  }) : null;
1284
- return i === "dialog" ? /* @__PURE__ */ S(te, {
1367
+ return r === "dialog" ? /* @__PURE__ */ x(ne, {
1285
1368
  open: !0,
1286
- onOpenChange: (e) => !e && k(null),
1287
- children: /* @__PURE__ */ C(ne, {
1369
+ onOpenChange: (e) => !e && D(null),
1370
+ children: /* @__PURE__ */ S(re, {
1288
1371
  className: "max-w-4xl",
1289
- children: [/* @__PURE__ */ C(re, {
1372
+ children: [/* @__PURE__ */ S(ie, {
1290
1373
  className: "flex-row items-center justify-between gap-4 pr-8",
1291
- children: [/* @__PURE__ */ S(ie, { children: n }), o]
1374
+ children: [/* @__PURE__ */ x(ae, { children: n }), o]
1292
1375
  }), a]
1293
1376
  })
1294
- }) : /* @__PURE__ */ S(oe, {
1377
+ }) : /* @__PURE__ */ x(se, {
1295
1378
  open: !0,
1296
- onOpenChange: (e) => !e && k(null),
1297
- children: /* @__PURE__ */ C(v, {
1379
+ onOpenChange: (e) => !e && D(null),
1380
+ children: /* @__PURE__ */ S(ce, {
1298
1381
  side: "right",
1299
1382
  className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
1300
- children: [/* @__PURE__ */ C(y, {
1383
+ children: [/* @__PURE__ */ S(le, {
1301
1384
  className: "flex-row items-center justify-between gap-4 pr-8",
1302
- children: [/* @__PURE__ */ S(se, { children: n }), o]
1303
- }), /* @__PURE__ */ S("div", {
1385
+ children: [/* @__PURE__ */ x(v, { children: n }), o]
1386
+ }), /* @__PURE__ */ x("div", {
1304
1387
  className: "flex-1 overflow-hidden mt-2",
1305
1388
  children: a
1306
1389
  })]
1307
1390
  })
1308
1391
  });
1309
1392
  })() : null;
1310
- return /* @__PURE__ */ C("div", {
1393
+ return /* @__PURE__ */ S("div", {
1311
1394
  className: "relative",
1312
1395
  children: [
1313
- /* @__PURE__ */ S(ae, { active: D && F.length > 0 }),
1314
- /* @__PURE__ */ S(Q, {
1396
+ /* @__PURE__ */ x(oe, { active: T && P.length > 0 }),
1397
+ /* @__PURE__ */ x(Q, {
1315
1398
  ...e,
1316
- schema: Te,
1317
- onChartClick: Ee
1399
+ schema: Me,
1400
+ onChartClick: Pe
1318
1401
  }),
1319
- De
1402
+ U
1320
1403
  ]
1321
1404
  });
1322
1405
  };
1323
- e.register("object-chart", $e, {
1406
+ e.register("object-chart", et, {
1324
1407
  namespace: "plugin-charts",
1325
1408
  label: "Object Chart",
1326
1409
  category: "view",
@@ -1352,11 +1435,11 @@ e.register("object-chart", $e, {
1352
1435
  });
1353
1436
  //#endregion
1354
1437
  //#region src/index.tsx
1355
- var et = {
1356
- "bar-chart": Xe,
1438
+ var tt = {
1439
+ "bar-chart": Ze,
1357
1440
  chart: Q
1358
1441
  };
1359
- e.register("bar-chart", Xe, {
1442
+ e.register("bar-chart", Ze, {
1360
1443
  namespace: "plugin-charts",
1361
1444
  label: "Bar Chart",
1362
1445
  category: "plugin",
@@ -1420,7 +1503,7 @@ e.register("bar-chart", Xe, {
1420
1503
  height: 400,
1421
1504
  color: "#8884d8"
1422
1505
  }
1423
- }), e.register("chart", $e, {
1506
+ }), e.register("chart", et, {
1424
1507
  namespace: "view",
1425
1508
  category: "view",
1426
1509
  label: "Chart",
@@ -1586,4 +1669,4 @@ e.register("bar-chart", Xe, {
1586
1669
  defaultProps: { chartType: "scatter" }
1587
1670
  });
1588
1671
  //#endregion
1589
- export { Xe as ChartBarRenderer, Q as ChartRenderer, $e as ObjectChart, et as chartComponents };
1672
+ export { Ze as ChartBarRenderer, Q as ChartRenderer, et as ObjectChart, tt as chartComponents };