drizzle-cube
Version:
Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.
1,237 lines • 95.1 kB
JavaScript
import { jsx as s, jsxs as b, Fragment as Ee } from "react/jsx-runtime";
import { useRef as bt, useState as H, useLayoutEffect as Nt, useMemo as wt } from "react";
import { ResponsiveContainer as He, Tooltip as lt, ComposedChart as ot, CartesianGrid as ve, XAxis as be, YAxis as Ne, Legend as Y, Bar as At, Cell as je, Line as W, LineChart as St, Area as kt, PieChart as Mt, Pie as $t, ScatterChart as Lt, Scatter as Ge, RadarChart as Tt, PolarGrid as Ft, PolarAngleAxis as Et, PolarRadiusAxis as jt, Radar as zt, RadialBarChart as Dt, RadialBar as Rt, Treemap as Vt } from "recharts";
import { u as X } from "./providers-DONuYrGH.js";
function B({ children: e, height: t = "100%" }) {
const n = bt(null), [r, i] = H(!1), [a, l] = H({ width: 0, height: 0 });
Nt(() => {
let o = !0, d = null;
const c = () => {
if (!o || !n.current) return;
const u = n.current.getBoundingClientRect(), f = Math.max(n.current.clientWidth, u.width), m = Math.max(n.current.clientHeight, u.height);
f > 0 && m > 0 && (l({ width: f, height: m }), i(!0));
};
return d = new ResizeObserver((u) => {
for (const f of u) {
const { width: m, height: p } = f.contentRect;
m > 0 && p > 0 && (l({ width: m, height: p }), r || i(!0));
}
}), n.current && (d.observe(n.current), c()), () => {
o = !1, d?.disconnect();
};
}, [r]);
try {
if (t === "100%")
return /* @__PURE__ */ s(
"div",
{
ref: n,
className: "w-full h-full flex-1 flex flex-col relative",
style: { minHeight: "250px", minWidth: "100px", overflow: "hidden" },
children: r && a.width > 0 && a.height > 0 ? /* @__PURE__ */ s(
He,
{
width: a.width,
height: a.height - 16,
debounce: 100,
style: { marginTop: "16px" },
children: e
}
) : /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ s("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-blue-500" }) })
}
);
const o = {
height: typeof t == "number" ? `${t}px` : t,
width: "100%",
minHeight: "200px",
minWidth: "100px"
};
return /* @__PURE__ */ s(
"div",
{
ref: n,
className: "w-full flex flex-col relative",
style: { ...o, overflow: "hidden" },
children: r && a.width > 0 && a.height > 0 ? /* @__PURE__ */ s(
He,
{
width: a.width,
height: a.height - 16,
debounce: 100,
style: { marginTop: "16px" },
children: e
}
) : /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ s("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-blue-500" }) })
}
);
} catch (o) {
return /* @__PURE__ */ b(
"div",
{
className: "flex flex-col items-center justify-center w-full h-full p-4 text-center border border-dashed rounded-lg",
style: { height: t, borderColor: "var(--dc-border)", backgroundColor: "var(--dc-surface)" },
children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1 text-dc-text-muted", children: "Unable to display chart" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: o instanceof Error ? o.message : "Failed to create responsive container" })
]
}
);
}
}
function ke(e) {
return e != null && !isNaN(Number(e));
}
function te(e) {
if (e == null) return null;
const t = typeof e == "string" ? parseFloat(e) : Number(e);
return isNaN(t) ? null : t;
}
function q(e) {
if (e == null) return "No data";
const t = typeof e == "number" ? e : parseFloat(e);
return isNaN(t) ? String(e) : Number.isInteger(t) ? t.toLocaleString() : parseFloat(t.toFixed(2)).toLocaleString();
}
function Me(e, t) {
return t[e] || e;
}
function R(e, t) {
if (!e) return String(e || "Unknown");
const n = String(e);
if (n.match(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}/)) {
let r = n;
n.includes(" ") && (r = n.replace(" ", "T").replace("+00", "Z").replace(/\+\d{2}:\d{2}$/, "Z")), !r.endsWith("Z") && !r.includes("+") && (r = r + "Z");
const i = new Date(r);
if (isNaN(i.getTime()))
return n;
const a = i.getUTCFullYear(), l = String(i.getUTCMonth() + 1).padStart(2, "0"), o = String(i.getUTCDate()).padStart(2, "0"), d = i.getUTCHours(), c = i.getUTCMinutes();
if (t)
switch (t.toLowerCase()) {
case "year":
return `${a}`;
case "quarter":
const m = Math.floor(i.getUTCMonth() / 3) + 1;
return `${a}-Q${m}`;
case "month":
return `${a}-${l}`;
case "week":
return `${a}-${l}-${o}`;
case "day":
return `${a}-${l}-${o}`;
case "hour":
return `${a}-${l}-${o} ${String(d).padStart(2, "0")}:00`;
case "minute":
return `${a}-${l}-${o} ${String(d).padStart(2, "0")}:${String(c).padStart(2, "0")}`;
}
const u = i.getUTCSeconds(), f = i.getUTCMilliseconds();
if (o === "01" && d === 0 && c === 0 && u === 0 && f === 0) {
if (l === "01" || l === "04" || l === "07" || l === "10") {
const m = Math.floor(i.getUTCMonth() / 3) + 1;
return `${a}-Q${m}`;
}
return `${a}-${l}`;
}
return d === 0 && c === 0 && u === 0 && f === 0 ? `${a}-${l}-${o}` : c === 0 && u === 0 && f === 0 ? `${a}-${l}-${o} ${String(d).padStart(2, "0")}:00` : `${a}-${l}-${o} ${String(d).padStart(2, "0")}:${String(c).padStart(2, "0")}`;
}
return n;
}
function O(e, t) {
try {
if (e?.timeDimensions) {
const r = e.timeDimensions.find((i) => t === i.dimension || t.startsWith(i.dimension.replace(".", "_")) || t === `${i.dimension}_${i.granularity}`);
if (r?.granularity)
return r.granularity;
}
const n = t.match(/_([a-z]+)$/);
if (n) {
const r = n[1];
if (["year", "quarter", "month", "week", "day", "hour", "minute", "second"].includes(r))
return r;
}
return;
} catch {
return;
}
}
function It(e, t, n, r, i = {}) {
if (!e || e.length === 0) return [];
const a = O(r, t);
return e.map((l) => {
const o = {
name: R(l[t], a) || l[t] || "Unknown"
};
return n.forEach((d) => {
const c = Me(d, i);
o[c] = te(l[d]);
}), o;
});
}
function se(e, t, n, r, i, a = {}) {
if (!e || e.length === 0)
return { data: [], seriesKeys: [], hasDimensions: !1 };
const l = r || {}, o = [
...l.dimensions || [],
...l.timeDimensions?.map((p) => p.dimension) || []
], d = l.measures || [], c = n.filter((p) => d.includes(p)), u = (i || []).filter((p) => o.includes(p));
if (u.length > 0) {
const p = {};
e.forEach((h) => {
const M = O(r, t), F = R(h[t], M) || h[t] || "Unknown";
p[F] || (p[F] = { name: String(F) }), c.forEach((v) => {
const A = Me(v, a), S = te(h[v]);
if (S !== null) {
const x = p[F][A];
p[F][A] = x == null ? S : x + S;
} else A in p[F] || (p[F][A] = null);
}), u.forEach((v) => {
const A = h[v];
if (A != null) {
const S = String(A), x = c[0] || d.find(
(y) => y.includes("totalCost") || y.includes("count") || y.includes("sum")
) || d[0];
if (x) {
const y = te(h[x]);
if (y !== null) {
const k = p[F][S];
p[F][S] = k == null ? y : k + y;
} else S in p[F] || (p[F][S] = null);
}
}
});
});
const N = Object.values(p), g = Array.from(new Set(
e.flatMap(
(h) => u.map((M) => {
const F = h[M];
return F != null ? String(F) : null;
}).filter((M) => M !== null)
)
));
return {
data: N,
seriesKeys: g,
hasDimensions: !0
};
}
const f = It(e, t, n, r, a), m = n.map((p) => Me(p, a));
return {
data: f,
seriesKeys: m,
hasDimensions: !1
};
}
const Ot = (e, t) => e == null ? ["No data", t] : [q(e), t];
function Q({ formatter: e, labelFormatter: t }) {
return /* @__PURE__ */ s(
lt,
{
formatter: e || Ot,
labelFormatter: t,
contentStyle: {
backgroundColor: "white",
border: "1px solid #e5e7eb",
borderRadius: "0.5rem",
fontSize: "0.875rem",
color: "#1f2937",
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
padding: "8px 12px"
}
}
);
}
const j = [
"#3b82f6",
// blue
"#10b981",
// green
"#f59e0b",
// yellow
"#ef4444",
// red
"#8b5cf6",
// purple
"#f97316",
// orange
"#06b6d4",
// cyan
"#84cc16"
// lime
], oe = [
"#440154",
// dark purple
"#414487",
// purple-blue
"#2a788e",
// teal
"#22a884",
// green-teal
"#7ad151",
// green
"#fde725"
// yellow
], Ue = "#10b981", _t = "#ef4444", we = {
top: 5,
right: 30,
left: 20,
bottom: 5
};
function ze(e) {
if (!e || typeof e != "string")
return [];
const t = e.trim();
if (!t)
return [];
try {
const n = t.split(",").map((r) => r.trim()).filter((r) => r !== "").map((r) => {
const i = parseFloat(r);
if (isNaN(i))
throw new Error(`Invalid numeric value: ${r}`);
return i;
});
return n.length > 0 ? n : [];
} catch (n) {
return console.warn("Failed to parse target values:", n), [];
}
}
function De(e, t) {
if (e.length === 0 || t <= 0)
return [];
if (e.length === 1)
return new Array(t).fill(e[0]);
const n = [], r = Math.floor(t / e.length), i = t % e.length;
let a = 0;
for (let l = 0; l < e.length; l++) {
const o = r + (l < i ? 1 : 0);
for (let d = 0; d < o; d++)
n[a++] = e[l];
}
return n;
}
function Qn(e, t) {
return t === 0 ? e === 0 ? 0 : e > 0 ? 100 : -100 : (e - t) / t * 100;
}
function Zn(e, t = 1) {
return `${e >= 0 ? "+" : ""}${e.toFixed(t)}%`;
}
function Jn({
data: e,
chartConfig: t,
displayConfig: n = {},
queryObject: r,
height: i = "100%",
colorPalette: a
}) {
const [l, o] = H(null), { labelMap: d, getFieldLabel: c } = X();
try {
const u = n?.stackType ?? (n?.stacked ? "normal" : "none"), f = u !== "none", m = u === "percent", p = {
showLegend: n?.showLegend ?? !0,
showGrid: n?.showGrid ?? !0,
showTooltip: n?.showTooltip ?? !0
};
if (!e || e.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in bar chart" })
] }) });
let N, g, h = [];
if (t?.xAxis && t?.yAxis)
N = Array.isArray(t.xAxis) ? t.xAxis[0] : t.xAxis, g = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], h = t.series || [];
else if (t?.x && t?.y)
N = t.x, g = Array.isArray(t.y) ? t.y : [t.y];
else
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
] }) });
if (!N || !g || g.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
] }) });
const { data: M, seriesKeys: F } = se(
e,
N,
g,
r,
h,
d
), { chartData: v, skippedCount: A } = wt(() => {
const L = M.filter((D) => F.some((V) => ke(D[V]))), E = M.length - L.length;
return { chartData: L, skippedCount: E };
}, [M, F]), S = m ? "expand" : void 0, x = F.length === 1 && v.some((L) => {
const E = L[F[0]];
return typeof E == "number" && E < 0;
}), y = p.showLegend, k = {
...we,
left: 40
// Increased from 20 to 40 for Y-axis label space
}, w = ze(n?.target || ""), T = De(w, v.length);
let $ = v;
return T.length > 0 && ($ = v.map((L, E) => ({
...L,
__target: T[E] || null
}))), !v || v.length === 0 ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for bar chart after transformation" })
] }) }) : /* @__PURE__ */ b("div", { className: "relative w-full", style: { height: i }, children: [
/* @__PURE__ */ s(B, { height: A > 0 ? "calc(100% - 20px)" : "100%", children: /* @__PURE__ */ b(ot, { data: $, margin: k, stackOffset: S, children: [
p.showGrid && /* @__PURE__ */ s(ve, { strokeDasharray: "3 3" }),
/* @__PURE__ */ s(
be,
{
dataKey: "name",
tick: { fontSize: 12 },
angle: -45,
textAnchor: "end",
height: 60
}
),
/* @__PURE__ */ s(
Ne,
{
tick: { fontSize: 12 },
tickFormatter: m ? (L) => `${(L * 100).toFixed(0)}%` : void 0,
domain: m ? [0, 1] : void 0,
label: m ? void 0 : { value: c(g[0]), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
}
),
p.showTooltip && /* @__PURE__ */ s(
Q,
{
formatter: (L, E) => L == null ? ["No data", E] : E === "Target" ? [q(L), "Target Value"] : m && typeof L == "number" ? [`${(L * 100).toFixed(1)}%`, E] : [q(L), E]
}
),
y && /* @__PURE__ */ s(
Y,
{
wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
iconType: "rect",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (L) => o(String(L.dataKey || "")),
onMouseLeave: () => o(null)
}
),
F.map((L, E) => /* @__PURE__ */ s(
At,
{
dataKey: L,
stackId: f ? "stack" : void 0,
fill: x ? Ue : a?.colors && a.colors[E % a.colors.length] || j[E % j.length],
fillOpacity: l ? l === L ? 1 : 0.3 : 1,
children: x && v.map((D, V) => {
const G = D[L], Z = typeof G == "number" && G < 0 ? _t : Ue;
return /* @__PURE__ */ s(
je,
{
fill: Z,
fillOpacity: l ? l === L ? 1 : 0.3 : 1
},
`cell-${V}`
);
})
},
L
)),
T.length > 0 && /* @__PURE__ */ b(Ee, { children: [
/* @__PURE__ */ s(
W,
{
type: "monotone",
dataKey: "__target",
stroke: "#ffffff",
strokeWidth: 2,
dot: !1,
activeDot: !1,
connectNulls: !1
}
),
/* @__PURE__ */ s(
W,
{
type: "monotone",
dataKey: "__target",
name: "Target",
stroke: "#8B5CF6",
strokeWidth: 2,
strokeDasharray: "2 3",
dot: !1,
activeDot: !1,
connectNulls: !1
}
)
] })
] }) }),
A > 0 && /* @__PURE__ */ b("div", { className: "text-xs text-dc-text-muted text-center mt-1", children: [
A,
" data point",
A !== 1 ? "s" : "",
" with no values hidden"
] })
] });
} catch (u) {
return /* @__PURE__ */ s("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Bar Chart Error" }),
/* @__PURE__ */ s("div", { className: "text-xs mb-2", children: u instanceof Error ? u.message : "Unknown rendering error" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}
function Pn({
data: e,
chartConfig: t,
displayConfig: n = {},
queryObject: r,
height: i = "100%",
colorPalette: a
}) {
const [l, o] = H(null), { labelMap: d, getFieldLabel: c } = X();
try {
const u = {
showLegend: n?.showLegend ?? !0,
showGrid: n?.showGrid ?? !0,
showTooltip: n?.showTooltip ?? !0,
connectNulls: n?.connectNulls ?? !1
};
if (!e || e.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in line chart" })
] }) });
let f, m, p = [];
if (t?.xAxis && t?.yAxis)
f = Array.isArray(t.xAxis) ? t.xAxis[0] : t.xAxis, m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], p = t.series || [];
else if (t?.x && t?.y)
f = t.x, m = Array.isArray(t.y) ? t.y : [t.y];
else
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
] }) });
if (!f || !m || m.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
] }) });
const { data: N, seriesKeys: g } = se(
e,
f,
m,
r,
p,
d
), h = u.showLegend, M = {
...we,
left: 40
// Increased from 20 to 40 for Y-axis label space
}, F = ze(n?.target || ""), v = De(F, N.length);
let A = N;
return v.length > 0 && (A = N.map((S, x) => ({
...S,
__target: v[x] || null
}))), !N || N.length === 0 ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for line chart after transformation" })
] }) }) : /* @__PURE__ */ s(B, { height: i, children: /* @__PURE__ */ b(St, { data: A, margin: M, children: [
u.showGrid && /* @__PURE__ */ s(ve, { strokeDasharray: "3 3" }),
/* @__PURE__ */ s(
be,
{
dataKey: "name",
tick: { fontSize: 12 },
angle: -45,
textAnchor: "end",
height: 60
}
),
/* @__PURE__ */ s(
Ne,
{
tick: { fontSize: 12 },
label: { value: c(m[0]), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
}
),
u.showTooltip && /* @__PURE__ */ s(
Q,
{
formatter: (S, x) => S == null ? ["No data", x] : x === "Target" ? [q(S), "Target Value"] : [q(S), x]
}
),
h && /* @__PURE__ */ s(
Y,
{
wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
iconType: "line",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (S) => o(String(S.dataKey || "")),
onMouseLeave: () => o(null)
}
),
g.map((S, x) => /* @__PURE__ */ s(
W,
{
type: "monotone",
dataKey: S,
stroke: a?.colors && a.colors[x % a.colors.length] || j[x % j.length],
strokeWidth: 2,
dot: { r: 3 },
activeDot: { r: 5 },
strokeOpacity: l ? l === S ? 1 : 0.3 : 1,
connectNulls: u.connectNulls
},
S
)),
v.length > 0 && /* @__PURE__ */ b(Ee, { children: [
/* @__PURE__ */ s(
W,
{
type: "monotone",
dataKey: "__target",
stroke: "#ffffff",
strokeWidth: 2,
dot: !1,
activeDot: !1,
connectNulls: !1
}
),
/* @__PURE__ */ s(
W,
{
type: "monotone",
dataKey: "__target",
name: "Target",
stroke: "#8B5CF6",
strokeWidth: 2,
strokeDasharray: "2 3",
dot: !1,
activeDot: !1,
connectNulls: !1
}
)
] })
] }) });
} catch (u) {
return /* @__PURE__ */ s("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Line Chart Error" }),
/* @__PURE__ */ s("div", { className: "text-xs mb-2", children: u instanceof Error ? u.message : "Unknown rendering error" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}
function er({
data: e,
chartConfig: t,
displayConfig: n = {},
queryObject: r,
height: i = "100%",
colorPalette: a
}) {
const [l, o] = H(null), { labelMap: d, getFieldLabel: c } = X();
try {
const u = n?.stackType ?? (n?.stacked ? "normal" : "none"), f = u !== "none", m = u === "percent", p = {
showLegend: n?.showLegend ?? !0,
showGrid: n?.showGrid ?? !0,
showTooltip: n?.showTooltip ?? !0,
connectNulls: n?.connectNulls ?? !1
};
if (!e || e.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in area chart" })
] }) });
let N, g, h = [];
if (t?.xAxis && t?.yAxis)
N = Array.isArray(t.xAxis) ? t.xAxis[0] : t.xAxis, g = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], h = t.series || [];
else if (t?.x && t?.y)
N = t.x, g = Array.isArray(t.y) ? t.y : [t.y];
else
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
] }) });
if (!N || !g || g.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
] }) });
const { data: M, seriesKeys: F } = se(
e,
N,
g,
r,
h,
d
), v = p.showLegend, A = {
...we,
left: 40
// Increased from 20 to 40 for Y-axis label space
}, S = ze(n?.target || ""), x = De(S, M.length);
let y = M;
return x.length > 0 && (y = M.map((w, T) => ({
...w,
__target: x[T] || null
}))), !M || M.length === 0 ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for area chart after transformation" })
] }) }) : /* @__PURE__ */ s(B, { height: i, children: /* @__PURE__ */ b(ot, { data: y, margin: A, stackOffset: m ? "expand" : void 0, children: [
p.showGrid && /* @__PURE__ */ s(ve, { strokeDasharray: "3 3" }),
/* @__PURE__ */ s(
be,
{
dataKey: "name",
tick: { fontSize: 12 },
angle: -45,
textAnchor: "end",
height: 60
}
),
/* @__PURE__ */ s(
Ne,
{
tick: { fontSize: 12 },
tickFormatter: m ? (w) => `${(w * 100).toFixed(0)}%` : void 0,
domain: m ? [0, 1] : void 0,
label: m ? void 0 : { value: c(g[0]), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
}
),
p.showTooltip && /* @__PURE__ */ s(
Q,
{
formatter: (w, T) => w == null ? ["No data", T] : T === "Target" ? [q(w), "Target Value"] : m && typeof w == "number" ? [`${(w * 100).toFixed(1)}%`, T] : [q(w), T]
}
),
v && /* @__PURE__ */ s(
Y,
{
wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
iconType: "rect",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (w) => o(String(w.dataKey || "")),
onMouseLeave: () => o(null)
}
),
F.map((w, T) => /* @__PURE__ */ s(
kt,
{
type: "monotone",
dataKey: w,
stackId: f ? "stack" : void 0,
stroke: a?.colors && a.colors[T % a.colors.length] || j[T % j.length],
fill: a?.colors && a.colors[T % a.colors.length] || j[T % j.length],
fillOpacity: l ? l === w ? 0.6 : 0.1 : 0.3,
strokeWidth: 2,
strokeOpacity: l ? l === w ? 1 : 0.3 : 1,
connectNulls: p.connectNulls
},
w
)),
x.length > 0 && /* @__PURE__ */ b(Ee, { children: [
/* @__PURE__ */ s(
W,
{
type: "monotone",
dataKey: "__target",
stroke: "#ffffff",
strokeWidth: 2,
dot: !1,
activeDot: !1,
connectNulls: !1
}
),
/* @__PURE__ */ s(
W,
{
type: "monotone",
dataKey: "__target",
name: "Target",
stroke: "#8B5CF6",
strokeWidth: 2,
strokeDasharray: "2 3",
dot: !1,
activeDot: !1,
connectNulls: !1
}
)
] })
] }) });
} catch (u) {
return /* @__PURE__ */ s("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Area Chart Error" }),
/* @__PURE__ */ s("div", { className: "text-xs mb-2", children: u instanceof Error ? u.message : "Unknown rendering error" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}
function tr({
data: e,
chartConfig: t,
displayConfig: n = {},
queryObject: r,
height: i = "100%",
colorPalette: a
}) {
const [l, o] = H(null), { labelMap: d } = X();
try {
const c = {
showLegend: n?.showLegend ?? !0,
showTooltip: n?.showTooltip ?? !0
};
if (!e || e.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in pie chart" })
] }) });
let u, f, m, p = [];
if (t?.xAxis && t?.yAxis)
f = Array.isArray(t.xAxis) ? t.xAxis[0] : t.xAxis, m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], p = t.series || [];
else if (t?.x && t?.y)
f = t.x, m = Array.isArray(t.y) ? t.y : [t.y];
else
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "chartConfig.x/y or chartConfig.xAxis/yAxis required for pie chart" })
] }) });
if (!f || !m || m.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
] }) });
if (p.length > 0) {
const { data: g } = se(
e,
f,
m,
r,
p,
d
);
if (u = [], g.length > 0) {
const h = g[0];
Object.keys(h).forEach((M) => {
M !== "name" && typeof h[M] == "number" && u.push({
name: String(M),
value: h[M]
});
});
}
} else {
const g = O(r, f);
u = e.map((h) => {
let M = R(h[f], g) || String(h[f]) || "Unknown";
return typeof h[f] == "boolean" ? M = h[f] ? "Active" : "Inactive" : (M === "true" || M === "false") && (M = M === "true" ? "Active" : "Inactive"), {
name: M,
value: typeof h[m[0]] == "string" ? parseFloat(h[m[0]]) : h[m[0]] || 0
};
});
}
const N = u.length;
return u = u.filter(
(g) => g.value != null && !isNaN(g.value) && g.value !== 0 && g.value > 0
), u.length === 0 ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: N > 0 ? `Filtered out ${N} data points (zero or invalid values)` : "No data points to display in pie chart" })
] }) }) : /* @__PURE__ */ s(B, { height: i, children: /* @__PURE__ */ b(Mt, { children: [
/* @__PURE__ */ s(
$t,
{
data: u,
cx: "50%",
cy: "50%",
outerRadius: "70%",
dataKey: "value",
label: c.showLegend ? void 0 : ({ name: g, percent: h }) => `${g} ${((h || 0) * 100).toFixed(0)}%`,
children: u.map((g, h) => /* @__PURE__ */ s(
je,
{
fill: a?.colors && a.colors[h % a.colors.length] || j[h % j.length],
fillOpacity: l ? l === u[h].name ? 1 : 0.3 : 1
},
`cell-${h}`
))
}
),
c.showTooltip && /* @__PURE__ */ s(Q, {}),
c.showLegend && /* @__PURE__ */ s(
Y,
{
wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
iconType: "circle",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (g) => o(String(g.value || "")),
onMouseLeave: () => o(null)
}
)
] }) });
} catch (c) {
return /* @__PURE__ */ s("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Pie Chart Error" }),
/* @__PURE__ */ s("div", { className: "text-xs mb-2", children: c instanceof Error ? c.message : "Unknown rendering error" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}
function nr({
data: e,
chartConfig: t,
displayConfig: n = {},
queryObject: r,
height: i = "100%",
colorPalette: a
}) {
const [l, o] = H(null), { getFieldLabel: d } = X();
try {
const c = {
showLegend: n?.showLegend ?? !0,
showGrid: n?.showGrid ?? !0,
showTooltip: n?.showTooltip ?? !0
};
if (!e || e.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in scatter chart" })
] }) });
let u, f, m = [];
if (t?.xAxis && t?.yAxis) {
u = Array.isArray(t.xAxis) ? t.xAxis[0] : t.xAxis, f = Array.isArray(t.yAxis) ? t.yAxis[0] : t.yAxis;
const x = t.series;
m = x ? Array.isArray(x) ? x : [x] : [];
} else if (t?.x && t?.y)
u = t.x, f = Array.isArray(t.y) ? t.y[0] : t.y;
else
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
] }) });
if (!u || !f)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
] }) });
const N = (r?.timeDimensions || []).map((x) => x.dimension);
let g, h = {};
if (m.length > 0) {
const x = m[0];
e.forEach((k) => {
const w = String(k[x] || "Default");
h[w] || (h[w] = []);
const T = O(r, u), $ = R(k[u], T) || k[u], L = te(k[f]), E = typeof $ == "string" ? parseFloat($) : $;
if (ke(E) && L !== null) {
const D = {};
N.forEach((V) => {
if (k[V]) {
const G = O(r, V);
D[V] = R(k[V], G);
}
}), h[w].push({
x: E,
y: L,
name: w,
timeValues: D,
originalItem: k
});
}
}), g = Object.keys(h).flatMap((k) => h[k]);
} else {
const x = O(r, u);
g = e.map((y) => {
const k = R(y[u], x) || y[u], w = te(y[f]), T = typeof k == "string" ? parseFloat(k) : k, $ = {};
return N.forEach((L) => {
if (y[L]) {
const E = O(r, L);
$[L] = R(y[L], E);
}
}), {
x: T,
y: w,
name: "Point",
timeValues: $,
originalItem: y,
isValid: ke(T) && w !== null
};
}).filter((y) => y.isValid);
}
if (!g || g.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for scatter chart after transformation" })
] }) });
const M = Object.keys(h), v = M.length > 1 && M.length <= 20, A = c.showLegend && v, S = {
...we,
left: 40
// Increased from 20 to 40 for Y-axis label space
};
return /* @__PURE__ */ s(B, { height: i, children: /* @__PURE__ */ b(Lt, { margin: S, children: [
c.showGrid && /* @__PURE__ */ s(ve, { strokeDasharray: "3 3" }),
/* @__PURE__ */ s(
be,
{
type: "number",
dataKey: "x",
name: d(u),
tick: { fontSize: 12 }
}
),
/* @__PURE__ */ s(
Ne,
{
type: "number",
dataKey: "y",
name: d(f),
tick: { fontSize: 12 },
label: { value: d(f), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
}
),
c.showTooltip && /* @__PURE__ */ s(
lt,
{
cursor: { strokeDasharray: "3 3" },
content: ({ active: x, payload: y }) => {
if (!x || !y || y.length === 0) return null;
const k = y[0]?.payload;
return k ? /* @__PURE__ */ b("div", { style: {
backgroundColor: "white",
border: "1px solid #e5e7eb",
borderRadius: "0.5rem",
fontSize: "0.875rem",
color: "#1f2937",
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1)",
padding: "8px 12px"
}, children: [
/* @__PURE__ */ s("div", { style: { fontWeight: 600, marginBottom: "4px" }, children: k.name }),
k.timeValues && Object.keys(k.timeValues).length > 0 && /* @__PURE__ */ s("div", { style: { marginBottom: "4px", color: "#6b7280" }, children: Object.entries(k.timeValues).map(([w, T]) => /* @__PURE__ */ b("div", { children: [
d(w),
": ",
T
] }, w)) }),
/* @__PURE__ */ b("div", { children: [
d(u),
": ",
q(k.x)
] }),
/* @__PURE__ */ b("div", { children: [
d(f),
": ",
q(k.y)
] })
] }) : null;
}
}
),
A && /* @__PURE__ */ s(
Y,
{
wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
iconType: "circle",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (x) => o(String(x.dataKey || "")),
onMouseLeave: () => o(null)
}
),
v ? (
// Multiple series
M.map((x, y) => /* @__PURE__ */ s(
Ge,
{
name: x,
data: h[x],
fill: a?.colors && a.colors[y % a.colors.length] || j[y % j.length],
fillOpacity: l ? l === x ? 1 : 0.3 : 1
},
x
))
) : (
// Single series
/* @__PURE__ */ s(
Ge,
{
name: "Data",
data: g,
fill: a?.colors && a.colors[0] || j[0]
}
)
)
] }) });
} catch (c) {
return /* @__PURE__ */ s("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Scatter Chart Error" }),
/* @__PURE__ */ s("div", { className: "text-xs mb-2", children: c instanceof Error ? c.message : "Unknown rendering error" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}
function rr({
data: e,
chartConfig: t,
displayConfig: n = {},
queryObject: r,
height: i = "100%",
colorPalette: a
}) {
const [l, o] = H(null);
try {
const d = {
showLegend: n?.showLegend ?? !0,
showTooltip: n?.showTooltip ?? !0,
showGrid: n?.showGrid ?? !0
};
if (!e || e.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in radar chart" })
] }) });
let c, u = [];
if (t?.xAxis && t?.yAxis) {
const f = Array.isArray(t.xAxis) ? t.xAxis[0] : t.xAxis, m = Array.isArray(t.yAxis) ? t.yAxis : [t.yAxis], p = t.series || [], { data: N, seriesKeys: g } = se(
e,
f,
m,
r,
p
);
c = N, u = g;
} else {
const f = e[0], m = Object.keys(f), p = m.find(
(g) => typeof f[g] == "string" || g.toLowerCase().includes("subject") || g.toLowerCase().includes("name") || g.toLowerCase().includes("category")
) || m[0], N = m.filter(
(g) => typeof f[g] == "number" && g !== p
);
if (N.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "No numeric fields found for radar chart values" })
] }) });
if (p) {
const g = O(r, p);
c = e.map((h) => {
const M = {
name: R(h[p], g) || String(h[p]) || "Unknown"
};
return N.forEach((F) => {
const v = F.split(".").pop() || F;
M[v] = typeof h[F] == "string" ? parseFloat(h[F]) : h[F] || 0;
}), M;
}), u = N.map((h) => h.split(".").pop() || h);
} else
c = e.map((g) => ({
name: String(g[m[0]] || "Unknown"),
value: typeof g[N[0]] == "string" ? parseFloat(g[N[0]]) : g[N[0]] || 0
})), u = ["value"];
}
return !c || c.length === 0 ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for radar chart after transformation" })
] }) }) : /* @__PURE__ */ s(B, { height: i, children: /* @__PURE__ */ b(Tt, { data: c, margin: { top: 20, right: 80, bottom: 20, left: 80 }, children: [
d.showGrid && /* @__PURE__ */ s(Ft, {}),
/* @__PURE__ */ s(
Et,
{
dataKey: "name",
tick: { fontSize: 12 },
className: "text-dc-text-muted"
}
),
/* @__PURE__ */ s(
jt,
{
tick: { fontSize: 10 },
className: "text-dc-text-muted"
}
),
d.showTooltip && /* @__PURE__ */ s(Q, {}),
d.showLegend && u.length > 1 && /* @__PURE__ */ s(
Y,
{
wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
iconType: "rect",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (f) => o(String(f.dataKey || "")),
onMouseLeave: () => o(null)
}
),
u.map((f, m) => /* @__PURE__ */ s(
zt,
{
name: f,
dataKey: f,
stroke: a?.colors && a.colors[m % a.colors.length] || j[m % j.length],
fill: a?.colors && a.colors[m % a.colors.length] || j[m % j.length],
fillOpacity: l ? l === f ? 0.6 : 0.1 : 0.3,
strokeOpacity: l ? l === f ? 1 : 0.3 : 1,
strokeWidth: 2
},
f
))
] }) });
} catch (d) {
return /* @__PURE__ */ s("div", { className: "flex flex-col items-center justify-center w-full text-red-500 p-4", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Radar Chart Error" }),
/* @__PURE__ */ s("div", { className: "text-xs mb-2", children: d instanceof Error ? d.message : "Unknown rendering error" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}
function ir({
data: e,
chartConfig: t,
displayConfig: n = {},
queryObject: r,
height: i = "100%",
colorPalette: a
}) {
const [l, o] = H(null);
try {
const d = {
showLegend: n?.showLegend ?? !0,
showTooltip: n?.showTooltip ?? !0
};
if (!e || e.length === 0)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ s("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in radial bar chart" })
] }) });
let c;
if (t?.xAxis && t?.yAxis) {
const u = Array.isArray(t.xAxis) ? t.xAxis[0] : t.xAxis, f = Array.isArray(t.yAxis) ? t.yAxis[0] : t.yAxis, m = O(r, u);
c = e.map((p, N) => ({
name: R(p[u], m) || String(p[u]) || "Unknown",
value: typeof p[f] == "string" ? parseFloat(p[f]) : p[f] || 0,
fill: a?.colors && a.colors[N % a.colors.length] || j[N % j.length]
}));
} else {
const u = e[0], f = Object.keys(u), m = f.find(
(N) => typeof u[N] == "string" || N.toLowerCase().includes("name") || N.toLowerCase().includes("label") || N.toLowerCase().includes("category")
) || f[0], p = f.find(
(N) => typeof u[N] == "number" && N !== m
) || f[1];
if (!p)
return /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ s("div", { className: "text-xs", children: "No numeric field found for radial bar chart values" })
] }) });
c = e.map((N, g) => {
let h = N[m];
return typeof h == "boolean" ? h = h ? "Active" : "Inactive" : h === "true" || h === "false" ? h = h === "true" ? "Active" : "Inactive" : h = String(h), {
name: h,
value: typeof N[p] == "string" ? parseFloat(N[p]) : N[p] || 0,
fill: a?.colors && a.colors[g % a.colors.length] || j[g % j.length]
};
});
}
return c = c.filter((u) => u.value != null && u.value !== 0), c.length === 0 ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ b("div", { className: "text-center", children: [
/* @__PURE__ */ s("div", { className: "text-sm font-semibold mb-1", children: "No valid data"