@gravitee/graphene-charts 3.50.0 → 3.51.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.
@@ -21,45 +21,56 @@ function _(e) {
21
21
  }
22
22
  return String(e);
23
23
  }
24
+ function v(e, t) {
25
+ let n = typeof e == "number" ? e.toLocaleString() : e;
26
+ return t ? `${n} ${t}` : n;
27
+ }
28
+ function y(e) {
29
+ let t = Math.round(e);
30
+ return Math.abs(e - t) < 1e-9 ? `${t}%` : `${e.toFixed(1)}%`;
31
+ }
32
+ function b(e, t) {
33
+ return t > 0 ? e * 100 / t : 0;
34
+ }
24
35
  //#endregion
25
36
  //#region src/types/index.ts
26
- var v = {
37
+ var x = {
27
38
  light: "",
28
39
  dark: ".dark"
29
- }, y = {
40
+ }, S = {
30
41
  top: 20,
31
42
  right: 20,
32
43
  bottom: 30,
33
44
  left: 40
34
- }, b = /[^a-zA-Z0-9_-]/g;
35
- function x(e) {
36
- return e.replace(b, "");
45
+ }, C = /[^a-zA-Z0-9_-]/g;
46
+ function w(e) {
47
+ return e.replace(C, "");
37
48
  }
38
49
  //#endregion
39
50
  //#region src/base/ChartContainer/ChartContainer.tsx
40
- var S = a.createContext(null);
41
- function C() {
42
- let e = a.useContext(S);
51
+ var T = a.createContext(null);
52
+ function E() {
53
+ let e = a.useContext(T);
43
54
  if (!e) throw Error("useChartConfig must be used within a <ChartContainer>");
44
55
  return e;
45
56
  }
46
- function w(e, t) {
57
+ function D(e, t) {
47
58
  return t && (t.height !== void 0 || t.minHeight !== void 0 || t.maxHeight !== void 0) ? !0 : e ? /(?:^|\s)!?(?:min-|max-)?h-[^\s]+/.test(e) : !1;
48
59
  }
49
- var T = 10;
50
- function ee({ id: t, config: n, className: r, children: i, style: o, ...l }) {
60
+ var O = 10;
61
+ function k({ id: t, config: n, className: r, children: i, style: o, ...l }) {
51
62
  let u = a.useId(), d = `chart-${t ?? u.replace(/:/g, "")}`, f = a.useMemo(() => {
52
63
  let e = Object.entries(n), t = {};
53
64
  for (let n = 0; n < e.length; n++) {
54
65
  let [r, i] = e[n];
55
66
  i.color || i.theme ? t[r] = i : t[r] = {
56
67
  ...i,
57
- color: `var(--chart-${n % T + 1})`
68
+ color: `var(--chart-${n % O + 1})`
58
69
  };
59
70
  }
60
71
  return t;
61
- }, [n]), p = a.useMemo(() => Object.entries(f).filter(([, e]) => e.color || e.theme), [f]), m = w(r, o);
62
- return /* @__PURE__ */ s(S.Provider, {
72
+ }, [n]), p = a.useMemo(() => Object.entries(f).filter(([, e]) => e.color || e.theme), [f]), m = D(r, o);
73
+ return /* @__PURE__ */ s(T.Provider, {
63
74
  value: {
64
75
  config: f,
65
76
  id: d
@@ -70,23 +81,23 @@ function ee({ id: t, config: n, className: r, children: i, style: o, ...l }) {
70
81
  className: e("flex w-full justify-center text-xs", !m && "aspect-video", r),
71
82
  style: o,
72
83
  ...l,
73
- children: [p.length > 0 && /* @__PURE__ */ s(E, {
84
+ children: [p.length > 0 && /* @__PURE__ */ s(A, {
74
85
  id: d,
75
86
  config: f
76
87
  }), i]
77
88
  })
78
89
  });
79
90
  }
80
- function E({ id: e, config: t }) {
81
- let n = x(e);
82
- return /* @__PURE__ */ s("style", { dangerouslySetInnerHTML: { __html: Object.entries(v).map(([e, r]) => `${r} [data-chart=${n}] {\n${Object.entries(t).map(([t, n]) => {
83
- let r = n.theme?.[e] ?? n.color, i = x(t);
91
+ function A({ id: e, config: t }) {
92
+ let n = w(e);
93
+ return /* @__PURE__ */ s("style", { dangerouslySetInnerHTML: { __html: Object.entries(x).map(([e, r]) => `${r} [data-chart=${n}] {\n${Object.entries(t).map(([t, n]) => {
94
+ let r = n.theme?.[e] ?? n.color, i = w(t);
84
95
  return !r || !i ? null : ` --color-${i}: ${r};`;
85
96
  }).filter(Boolean).join("\n")}\n}`).join("\n") } });
86
97
  }
87
98
  //#endregion
88
99
  //#region src/primitives/useChartDimensions.ts
89
- function D(e) {
100
+ function ee(e) {
90
101
  let [t, n] = a.useState({
91
102
  width: 0,
92
103
  height: 0
@@ -106,19 +117,19 @@ function D(e) {
106
117
  }
107
118
  //#endregion
108
119
  //#region src/primitives/useTooltipState.ts
109
- var O = 12, k = -12;
110
- function A(e, t) {
120
+ var j = 12, te = -12;
121
+ function ne(e, t) {
111
122
  return {
112
- x: e.clientX - t.left + O,
113
- y: e.clientY - t.top + k
123
+ x: e.clientX - t.left + j,
124
+ y: e.clientY - t.top + te
114
125
  };
115
126
  }
116
- function te() {
127
+ function re() {
117
128
  let [e, t] = a.useState(null);
118
129
  return {
119
130
  state: e,
120
131
  show: a.useCallback((e, n, r, i) => {
121
- let { x: a, y: o } = A(r, i);
132
+ let { x: a, y: o } = ne(r, i);
122
133
  t({
123
134
  items: e,
124
135
  label: n,
@@ -129,7 +140,7 @@ function te() {
129
140
  move: a.useCallback((e, n) => {
130
141
  t((t) => {
131
142
  if (!t) return t;
132
- let { x: r, y: i } = A(e, n);
143
+ let { x: r, y: i } = ne(e, n);
133
144
  return {
134
145
  ...t,
135
146
  x: r,
@@ -142,16 +153,16 @@ function te() {
142
153
  }
143
154
  //#endregion
144
155
  //#region src/primitives/CartesianContext.tsx
145
- var j = a.createContext(null);
146
- function M() {
147
- let e = a.useContext(j);
156
+ var M = a.createContext(null);
157
+ function ie() {
158
+ let e = a.useContext(M);
148
159
  if (!e) throw Error("useCartesianContext must be used within a <CartesianChart>");
149
160
  return e;
150
161
  }
151
162
  //#endregion
152
163
  //#region src/primitives/Grid.tsx
153
164
  function N({ scale: e, length: t, orientation: n, tickCount: r = 5 }) {
154
- let i = a.useContext(j), o = e ?? i?.valueScale, c = i?.layout === "vertical", l = n ?? (c ? "horizontal" : "vertical"), u = t ?? (l === "horizontal" ? i?.innerWidth : i?.innerHeight) ?? 0;
165
+ let i = a.useContext(M), o = e ?? i?.valueScale, c = i?.layout === "vertical", l = n ?? (c ? "horizontal" : "vertical"), u = t ?? (l === "horizontal" ? i?.innerWidth : i?.innerHeight) ?? 0;
155
166
  if (!o) return null;
156
167
  let d = o.ticks(r), f = l === "horizontal";
157
168
  return /* @__PURE__ */ s("g", {
@@ -177,11 +188,11 @@ function N({ scale: e, length: t, orientation: n, tickCount: r = 5 }) {
177
188
  }
178
189
  //#endregion
179
190
  //#region src/primitives/chartBadge.ts
180
- var ne = 6.2, re = 12, ie = "inline-flex items-center rounded-md border px-1.5 py-0.5 text-[10px] leading-none font-medium";
181
- function P(e) {
182
- return e * ne + re;
191
+ var P = 6.2, F = 12, I = "inline-flex items-center rounded-md border px-1.5 py-0.5 text-[10px] leading-none font-medium";
192
+ function ae(e) {
193
+ return e * P + F;
183
194
  }
184
- function F(e) {
195
+ function L(e) {
185
196
  return {
186
197
  color: e,
187
198
  borderColor: e,
@@ -190,9 +201,9 @@ function F(e) {
190
201
  }
191
202
  //#endregion
192
203
  //#region src/primitives/ReferenceLine.tsx
193
- var I = 6, L = 20, R = "\n@keyframes graphene-refline-fadein {\n from { opacity: 0; }\n to { opacity: var(--_refline-opacity); }\n}\n@keyframes graphene-refline-pulse {\n 0%, 100% { stroke-opacity: 0.7; }\n 50% { stroke-opacity: 0.3; }\n}\n[data-graphene-refline] {\n animation: graphene-refline-fadein 300ms ease-out forwards;\n}\n[data-graphene-refline-pulse] {\n animation: graphene-refline-pulse 2s ease-in-out infinite;\n}\n@media (prefers-reduced-motion: reduce) {\n [data-graphene-refline] {\n animation: none;\n opacity: var(--_refline-opacity);\n }\n [data-graphene-refline-pulse] {\n animation: none;\n }\n}\n";
194
- function z({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray: i, strokeWidth: o = 1.5, label: l, labelPosition: u = "end", pulse: d = !1 }) {
195
- let f = a.useContext(j);
204
+ var R = 6, z = 20, oe = "\n@keyframes graphene-refline-fadein {\n from { opacity: 0; }\n to { opacity: var(--_refline-opacity); }\n}\n@keyframes graphene-refline-pulse {\n 0%, 100% { stroke-opacity: 0.7; }\n 50% { stroke-opacity: 0.3; }\n}\n[data-graphene-refline] {\n animation: graphene-refline-fadein 300ms ease-out forwards;\n}\n[data-graphene-refline-pulse] {\n animation: graphene-refline-pulse 2s ease-in-out infinite;\n}\n@media (prefers-reduced-motion: reduce) {\n [data-graphene-refline] {\n animation: none;\n opacity: var(--_refline-opacity);\n }\n [data-graphene-refline-pulse] {\n animation: none;\n }\n}\n";
205
+ function B({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray: i, strokeWidth: o = 1.5, label: l, labelPosition: u = "end", pulse: d = !1 }) {
206
+ let f = a.useContext(M);
196
207
  if (!f) return null;
197
208
  let { categoryScale: p, resolveValueScale: m, innerWidth: h, innerHeight: g, layout: _ } = f, v = m(n), y = _ === "vertical", b = e !== void 0, x = t !== void 0;
198
209
  if (!b && !x) return null;
@@ -208,13 +219,13 @@ function z({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray:
208
219
  let e = v(t);
209
220
  y ? (C = e, T = !0) : (S = e, w = !0);
210
221
  }
211
- let ee = w && S >= 0 && S <= h, E = T && C >= 0 && C <= g;
212
- if (!ee && !E) return null;
213
- let D = d ? .7 : .8, O = l ? ae(u, {
222
+ let E = w && S >= 0 && S <= h, D = T && C >= 0 && C <= g;
223
+ if (!E && !D) return null;
224
+ let O = d ? .7 : .8, k = l ? se(u, {
214
225
  xPos: S,
215
226
  yPos: C,
216
- xInBounds: ee,
217
- yInBounds: E,
227
+ xInBounds: E,
228
+ yInBounds: D,
218
229
  hasX: w,
219
230
  hasY: T,
220
231
  innerWidth: h,
@@ -224,13 +235,13 @@ function z({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray:
224
235
  return /* @__PURE__ */ c("g", {
225
236
  "aria-hidden": "true",
226
237
  "data-graphene-refline": !0,
227
- style: { "--_refline-opacity": D },
238
+ style: { "--_refline-opacity": O },
228
239
  children: [
229
240
  /* @__PURE__ */ s("style", {
230
241
  precedence: "graphene-charts",
231
- children: R
242
+ children: oe
232
243
  }),
233
- ee && /* @__PURE__ */ s("line", {
244
+ E && /* @__PURE__ */ s("line", {
234
245
  x1: S,
235
246
  x2: S,
236
247
  y1: 0,
@@ -239,10 +250,10 @@ function z({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray:
239
250
  strokeWidth: o,
240
251
  strokeDasharray: i,
241
252
  strokeLinecap: "round",
242
- strokeOpacity: D,
253
+ strokeOpacity: O,
243
254
  ...d ? { "data-graphene-refline-pulse": "" } : {}
244
255
  }),
245
- E && /* @__PURE__ */ s("line", {
256
+ D && /* @__PURE__ */ s("line", {
246
257
  x1: 0,
247
258
  x2: h,
248
259
  y1: C,
@@ -251,100 +262,100 @@ function z({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray:
251
262
  strokeWidth: o,
252
263
  strokeDasharray: i,
253
264
  strokeLinecap: "round",
254
- strokeOpacity: D,
265
+ strokeOpacity: O,
255
266
  ...d ? { "data-graphene-refline-pulse": "" } : {}
256
267
  }),
257
- l && O && /* @__PURE__ */ s("foreignObject", {
258
- x: O.x,
259
- y: O.y,
260
- width: O.width,
261
- height: L,
268
+ l && k && /* @__PURE__ */ s("foreignObject", {
269
+ x: k.x,
270
+ y: k.y,
271
+ width: k.width,
272
+ height: z,
262
273
  overflow: "visible",
263
274
  children: /* @__PURE__ */ s("span", {
264
275
  className: "inline-flex items-center rounded-md border px-1.5 py-0.5 text-[10px] leading-none font-medium",
265
- style: F(r),
276
+ style: L(r),
266
277
  children: l
267
278
  })
268
279
  })
269
280
  ]
270
281
  });
271
282
  }
272
- function ae(e, t) {
273
- let { xPos: n, yPos: r, xInBounds: i, yInBounds: a, hasX: o, hasY: s, innerWidth: c, innerHeight: l, labelLength: u } = t, d = P(u);
283
+ function se(e, t) {
284
+ let { xPos: n, yPos: r, xInBounds: i, yInBounds: a, hasX: o, hasY: s, innerWidth: c, innerHeight: l, labelLength: u } = t, d = ae(u);
274
285
  if (o && s && i && a) {
275
- let e = n + I + d > c, t = r + I + L > l;
286
+ let e = n + R + d > c, t = r + R + z > l;
276
287
  return {
277
- x: e ? n - I - d : n + I,
278
- y: t ? r - I - L : r + I,
288
+ x: e ? n - R - d : n + R,
289
+ y: t ? r - R - z : r + R,
279
290
  width: d
280
291
  };
281
292
  }
282
293
  if (s && a) {
283
- let t = r - I - L < 0;
294
+ let t = r - R - z < 0;
284
295
  return {
285
- x: se(e, c, d),
286
- y: t ? r + I : r - I - L,
296
+ x: le(e, c, d),
297
+ y: t ? r + R : r - R - z,
287
298
  width: d
288
299
  };
289
300
  }
290
301
  return o && i ? {
291
- x: n + I + d > c ? n - I - d : n + I,
292
- y: oe(e, l),
302
+ x: n + R + d > c ? n - R - d : n + R,
303
+ y: ce(e, l),
293
304
  width: d
294
305
  } : null;
295
306
  }
296
- function oe(e, t) {
297
- return e === "start" ? I : e === "center" ? t / 2 - L / 2 : t - L - I;
307
+ function ce(e, t) {
308
+ return e === "start" ? R : e === "center" ? t / 2 - z / 2 : t - z - R;
298
309
  }
299
- function se(e, t, n) {
300
- return e === "start" ? I : e === "center" ? t / 2 - n / 2 : t - n - I;
310
+ function le(e, t, n) {
311
+ return e === "start" ? R : e === "center" ? t / 2 - n / 2 : t - n - R;
301
312
  }
302
313
  //#endregion
303
314
  //#region src/primitives/Axis.tsx
304
- var B = 7, V = 8, ce = "…", H = 4;
305
- function U(e) {
315
+ var V = 7, H = 8, U = "…", W = 4;
316
+ function G(e) {
306
317
  return new Set(Array.from({ length: e }, (e, t) => t));
307
318
  }
308
- function le(e, t) {
319
+ function K(e, t) {
309
320
  let n = /* @__PURE__ */ new Set();
310
321
  for (let r = 0; r < e; r += t) n.add(r);
311
322
  let r = e - 1;
312
323
  return r - Math.floor((r - 1) / t) * t >= t && n.add(r), n;
313
324
  }
314
- function W(e, t) {
325
+ function q(e, t) {
315
326
  let n = e.domain();
316
327
  return n.length < 2 ? t : Math.abs((e(n[1]) ?? 0) - (e(n[0]) ?? 0));
317
328
  }
318
- function G(e, t, n, r) {
319
- let i = Math.max(0, t - V);
320
- if (r ? i >= H * B : n <= i) return {
321
- visible: U(e),
329
+ function J(e, t, n, r) {
330
+ let i = Math.max(0, t - H);
331
+ if (r ? i >= W * V : n <= i) return {
332
+ visible: G(e),
322
333
  maxWidth: i
323
334
  };
324
- let a = t > 0 ? Math.max(1, Math.ceil((n + V) / t)) : e;
335
+ let a = t > 0 ? Math.max(1, Math.ceil((n + H) / t)) : e;
325
336
  return {
326
- visible: le(e, a),
327
- maxWidth: Math.max(0, t * a - V)
337
+ visible: K(e, a),
338
+ maxWidth: Math.max(0, t * a - H)
328
339
  };
329
340
  }
330
- function K(e, t) {
331
- let n = Math.floor(t / B);
332
- return n <= 1 ? ce : e.length <= n ? e : e.slice(0, n - 1) + ce;
341
+ function ue(e, t) {
342
+ let n = Math.floor(t / V);
343
+ return n <= 1 ? U : e.length <= n ? e : e.slice(0, n - 1) + U;
333
344
  }
334
- function q(e, t, n, r) {
345
+ function de(e, t, n, r) {
335
346
  if (t) return Math.max(1, Math.floor(e / 24));
336
- let i = Math.max(...n.map((e) => r(e).length)) * B;
337
- return Math.max(1, Math.floor(e / (i + V)));
347
+ let i = Math.max(...n.map((e) => r(e).length)) * V;
348
+ return Math.max(1, Math.floor(e / (i + H)));
338
349
  }
339
- function ue({ scale: e, orientation: t, length: n }) {
340
- let r = a.useContext(j), i = e ?? r?.categoryScale, l = r?.layout !== "horizontal", u = t ?? (l ? "bottom" : "left"), d = n ?? (u === "bottom" ? r?.innerHeight : 0) ?? 0, f = r?.categoryTickFormatter ?? ((e) => e);
350
+ function Y({ scale: e, orientation: t, length: n }) {
351
+ let r = a.useContext(M), i = e ?? r?.categoryScale, l = r?.layout !== "horizontal", u = t ?? (l ? "bottom" : "left"), d = n ?? (u === "bottom" ? r?.innerHeight : 0) ?? 0, f = r?.categoryTickFormatter ?? ((e) => e);
341
352
  if (!i) return null;
342
- let p = i.domain(), m = p.map(f), h = W(i, u === "bottom" ? r?.innerWidth ?? 0 : r?.innerHeight ?? 0), g = (e, t) => {
343
- let n = m[e], r = K(n, t);
353
+ let p = i.domain(), m = p.map(f), h = q(i, u === "bottom" ? r?.innerWidth ?? 0 : r?.innerHeight ?? 0), g = (e, t) => {
354
+ let n = m[e], r = ue(n, t);
344
355
  return /* @__PURE__ */ c(o, { children: [r !== n && /* @__PURE__ */ s("title", { children: n }), r] });
345
356
  };
346
357
  if (u === "bottom") {
347
- let e = Math.max(...m.map((e) => e.length * B)), { visible: t, maxWidth: n } = G(p.length, h, e, i.bandwidth() > 0);
358
+ let e = Math.max(...m.map((e) => e.length * V)), { visible: t, maxWidth: n } = J(p.length, h, e, i.bandwidth() > 0);
348
359
  return /* @__PURE__ */ s("g", {
349
360
  transform: `translate(0,${d})`,
350
361
  "aria-hidden": "true",
@@ -357,7 +368,7 @@ function ue({ scale: e, orientation: t, length: n }) {
357
368
  }, e) : null)
358
369
  });
359
370
  }
360
- let _ = r?.marginLeft ?? 40, v = Math.max(0, _ - V), y = h > 0 ? Math.max(1, Math.ceil(24 / h)) : p.length, b = le(p.length, y);
371
+ let _ = r?.marginLeft ?? 40, v = Math.max(0, _ - H), y = h > 0 ? Math.max(1, Math.ceil(24 / h)) : p.length, b = K(p.length, y);
361
372
  return /* @__PURE__ */ s("g", {
362
373
  "aria-hidden": "true",
363
374
  children: p.map((e, t) => b.has(t) ? /* @__PURE__ */ s("text", {
@@ -370,10 +381,10 @@ function ue({ scale: e, orientation: t, length: n }) {
370
381
  }, e) : null)
371
382
  });
372
383
  }
373
- function de({ scale: e, orientation: t, axisId: n, unit: r, length: i, tickCount: o = 5, tickFormatter: c }) {
374
- let l = a.useContext(j), u = n && l?.resolveValueScale ? l.resolveValueScale(n) : l?.valueScale, d = e ?? u, f = l?.layout !== "horizontal", p = t ?? (f ? "left" : "bottom"), m = i ?? (p === "bottom" ? l?.innerHeight : 0) ?? 0, h = c ?? l?.valueTickFormatter ?? String, g = r ?? l?.axisUnits?.[n ?? "left"];
384
+ function X({ scale: e, orientation: t, axisId: n, unit: r, length: i, tickCount: o = 5, tickFormatter: c }) {
385
+ let l = a.useContext(M), u = n && l?.resolveValueScale ? l.resolveValueScale(n) : l?.valueScale, d = e ?? u, f = l?.layout !== "horizontal", p = t ?? (f ? "left" : "bottom"), m = i ?? (p === "bottom" ? l?.innerHeight : 0) ?? 0, h = c ?? l?.valueTickFormatter ?? String, g = r ?? l?.axisUnits?.[n ?? "left"];
375
386
  if (!d) return null;
376
- let _ = d.ticks(o), v = p === "left" || p === "right", y = q(v ? l?.innerHeight ?? 0 : l?.innerWidth ?? 0, v, _, h), b = y >= _.length ? _ : d.ticks(y), x = b.length > 0 ? Math.max(...b) : void 0, S = (e) => {
387
+ let _ = d.ticks(o), v = p === "left" || p === "right", y = de(v ? l?.innerHeight ?? 0 : l?.innerWidth ?? 0, v, _, h), b = y >= _.length ? _ : d.ticks(y), x = b.length > 0 ? Math.max(...b) : void 0, S = (e) => {
377
388
  let t = h(e);
378
389
  return g && e === x ? `${t} ${g}` : t;
379
390
  };
@@ -393,7 +404,7 @@ function de({ scale: e, orientation: t, axisId: n, unit: r, length: i, tickCount
393
404
  return /* @__PURE__ */ s("g", {
394
405
  "aria-hidden": "true",
395
406
  children: b.map((t) => /* @__PURE__ */ s("text", {
396
- x: e + V,
407
+ x: e + H,
397
408
  y: d(t),
398
409
  textAnchor: "start",
399
410
  dominantBaseline: "middle",
@@ -432,9 +443,9 @@ function fe(e, t, n, r, i) {
432
443
  }
433
444
  //#endregion
434
445
  //#region src/primitives/ChartSlots.tsx
435
- var J = a.createContext(null);
436
- function pe() {
437
- return a.useContext(J) || {
446
+ var pe = a.createContext(null);
447
+ function me() {
448
+ return a.useContext(pe) || {
438
449
  tooltip: null,
439
450
  legend: null,
440
451
  brush: null,
@@ -443,7 +454,7 @@ function pe() {
443
454
  setBrush: () => void 0
444
455
  };
445
456
  }
446
- function Y({ children: e }) {
457
+ function Z({ children: e }) {
447
458
  let [t, n] = a.useState(null), [r, i] = a.useState(null), [o, c] = a.useState(null), l = a.useMemo(() => ({
448
459
  tooltip: t,
449
460
  legend: r,
@@ -456,14 +467,48 @@ function Y({ children: e }) {
456
467
  r,
457
468
  o
458
469
  ]);
459
- return /* @__PURE__ */ s(J.Provider, {
470
+ return /* @__PURE__ */ s(pe.Provider, {
460
471
  value: l,
461
472
  children: e
462
473
  });
463
474
  }
464
475
  //#endregion
476
+ //#region src/primitives/ChartLegendFrame.tsx
477
+ function Q(e, t, n) {
478
+ return e ? e.position === "right" ? t === 0 || t >= n ? "right" : "bottom" : e.verticalAlign : null;
479
+ }
480
+ function he({ legend: t, legendProps: n, minWidthForRight: r, className: i, children: o, ref: l, ...u }) {
481
+ let d = a.useRef(null), f = a.useCallback((e) => {
482
+ d.current = e, typeof l == "function" ? l(e) : l && (l.current = e);
483
+ }, [l]), { width: p } = ee(d), [m, h] = a.useState(0);
484
+ a.useLayoutEffect(() => {
485
+ h(d.current?.getBoundingClientRect().width ?? 0);
486
+ }, []);
487
+ let g = Q(t, p || m, r), _ = t && g ? a.cloneElement(t.content, {
488
+ ...n,
489
+ placement: g,
490
+ verticalAlign: g === "top" ? "top" : "bottom"
491
+ }) : null;
492
+ return /* @__PURE__ */ c("div", {
493
+ ref: f,
494
+ "data-legend-placement": g ?? void 0,
495
+ className: e("flex h-full w-full", g === "right" ? "flex-row gap-4" : "flex-col", i),
496
+ ...u,
497
+ children: [
498
+ g === "top" && _,
499
+ o,
500
+ g === "right" && /* @__PURE__ */ s("div", {
501
+ "data-slot": "chart-legend-aside",
502
+ className: "flex max-h-full max-w-[50%] min-w-0 shrink-0 self-center overflow-y-auto",
503
+ children: _
504
+ }),
505
+ g === "bottom" && _
506
+ ]
507
+ });
508
+ }
509
+ //#endregion
465
510
  //#region src/primitives/useResolvedCssLength.tsx
466
- function me(e, t) {
511
+ function ge(e, t) {
467
512
  let n = a.useRef(null), [r, i] = a.useState(t), o = a.useCallback(() => {
468
513
  let e = n.current;
469
514
  if (!e) return;
@@ -488,17 +533,17 @@ function me(e, t) {
488
533
  }
489
534
  //#endregion
490
535
  //#region src/primitives/useDevWarning.ts
491
- function he(e) {
536
+ function _e(e) {
492
537
  a.useRef(null), a.useEffect(() => {}, [e]);
493
538
  }
494
539
  //#endregion
495
540
  //#region src/lib/resolveChartState.ts
496
- function ge(e, t) {
541
+ function ve(e, t) {
497
542
  return e ?? (t === 0 ? "empty" : "ready");
498
543
  }
499
544
  //#endregion
500
545
  //#region src/primitives/BarChartSkeleton.tsx
501
- var X = [
546
+ var ye = [
502
547
  {
503
548
  x: 55,
504
549
  height: 120
@@ -524,7 +569,7 @@ var X = [
524
569
  height: 85
525
570
  }
526
571
  ];
527
- function Z({ ariaLabel: t = "Loading chart", className: n, ...r }) {
572
+ function be({ ariaLabel: t = "Loading chart", className: n, ...r }) {
528
573
  return /* @__PURE__ */ s("div", {
529
574
  role: "img",
530
575
  "aria-label": t,
@@ -533,7 +578,7 @@ function Z({ ariaLabel: t = "Loading chart", className: n, ...r }) {
533
578
  ...r,
534
579
  children: /* @__PURE__ */ s("div", {
535
580
  className: "flex min-h-0 flex-1 items-end gap-2 px-8 py-4",
536
- children: X.map((e) => /* @__PURE__ */ s("div", {
581
+ children: ye.map((e) => /* @__PURE__ */ s("div", {
537
582
  className: "flex-1 animate-pulse rounded-t-sm bg-muted",
538
583
  style: { height: `${e.height / 200 * 100}%` }
539
584
  }, e.x))
@@ -542,7 +587,7 @@ function Z({ ariaLabel: t = "Loading chart", className: n, ...r }) {
542
587
  }
543
588
  //#endregion
544
589
  //#region src/primitives/LineChartSkeleton.tsx
545
- function _e({ ariaLabel: t = "Loading chart", className: n, ...r }) {
590
+ function xe({ ariaLabel: t = "Loading chart", className: n, ...r }) {
546
591
  return /* @__PURE__ */ s("div", {
547
592
  role: "img",
548
593
  "aria-label": t,
@@ -575,17 +620,17 @@ function _e({ ariaLabel: t = "Loading chart", className: n, ...r }) {
575
620
  }
576
621
  //#endregion
577
622
  //#region src/primitives/CartesianChartSkeleton.tsx
578
- function ve({ ariaLabel: t = "Loading chart", className: n, ...r }) {
623
+ function Se({ ariaLabel: t = "Loading chart", className: n, ...r }) {
579
624
  return /* @__PURE__ */ c("div", {
580
625
  role: "img",
581
626
  "aria-label": t,
582
627
  "aria-busy": "true",
583
628
  className: e("relative flex h-full w-full overflow-hidden", n),
584
629
  ...r,
585
- children: [/* @__PURE__ */ s(Z, {
630
+ children: [/* @__PURE__ */ s(be, {
586
631
  "aria-hidden": "true",
587
632
  className: "absolute inset-0"
588
- }), /* @__PURE__ */ s(_e, {
633
+ }), /* @__PURE__ */ s(xe, {
589
634
  "aria-hidden": "true",
590
635
  className: "absolute inset-0"
591
636
  })]
@@ -593,17 +638,17 @@ function ve({ ariaLabel: t = "Loading chart", className: n, ...r }) {
593
638
  }
594
639
  //#endregion
595
640
  //#region src/primitives/cartesianGeometry.ts
596
- function ye(e, t) {
641
+ function Ce(e, t) {
597
642
  let n = t.bandwidth() / 2;
598
643
  return e.map((e) => (t(e) ?? 0) + n);
599
644
  }
600
- function be(e, t, n, r) {
645
+ function we(e, t, n, r) {
601
646
  return r === "vertical" ? e.clientX - t.left - n.left : e.clientY - t.top - n.top;
602
647
  }
603
- function Q(e, t) {
648
+ function $(e, t) {
604
649
  return Math.min(Math.max(e, 0), t);
605
650
  }
606
- function xe(e, t) {
651
+ function Te(e, t) {
607
652
  if (t.length === 0) return -1;
608
653
  let n = 0, r = Infinity;
609
654
  for (let i = 0; i < t.length; i++) {
@@ -612,7 +657,7 @@ function xe(e, t) {
612
657
  }
613
658
  return n;
614
659
  }
615
- function Se(e, t) {
660
+ function Ee(e, t) {
616
661
  return e <= t ? {
617
662
  startIndex: e,
618
663
  endIndex: t
@@ -621,36 +666,36 @@ function Se(e, t) {
621
666
  endIndex: e
622
667
  };
623
668
  }
624
- function Ce(e, t) {
669
+ function De(e, t) {
625
670
  return e.startIndex === t.startIndex && e.endIndex === t.endIndex;
626
671
  }
627
- function we(e) {
672
+ function Oe(e) {
628
673
  return e.endIndex - e.startIndex + 1;
629
674
  }
630
- function $(e, t, n) {
675
+ function ke(e, t, n) {
631
676
  let r = e > 0 ? (t[e - 1] + t[e]) / 2 : 0, i = e < t.length - 1 ? (t[e] + t[e + 1]) / 2 : n;
632
677
  return {
633
- start: Q(r, n),
634
- end: Q(i, n)
678
+ start: $(r, n),
679
+ end: $(i, n)
635
680
  };
636
681
  }
637
- function Te(e, t, n) {
682
+ function Ae(e, t, n) {
638
683
  return {
639
- start: $(e.startIndex, t, n).start,
640
- end: $(e.endIndex, t, n).end
684
+ start: ke(e.startIndex, t, n).start,
685
+ end: ke(e.endIndex, t, n).end
641
686
  };
642
687
  }
643
- function Ee(e, t, n) {
688
+ function je(e, t, n) {
644
689
  return Math.abs(t - e) >= n;
645
690
  }
646
- function De(e, t) {
691
+ function Me(e, t) {
647
692
  return t < 2 ? !0 : e === "auto" ? t <= 4 : e;
648
693
  }
649
694
  //#endregion
650
695
  //#region src/primitives/ChartBrushOverlay.tsx
651
- var Oe = "var(--primary)", ke = "var(--muted-foreground)", Ae = "var(--background)", je = .1, Me = .45, Ne = 6;
652
- function Pe({ draft: e, centers: t, extent: n, crossExtent: r, layout: i, label: a }) {
653
- let { start: l, end: u } = Te(e.range, t, n), d = i === "vertical", f = (e, t) => d ? {
696
+ var Ne = "var(--primary)", Pe = "var(--muted-foreground)", Fe = "var(--background)", Ie = .1, Le = .45, Re = 6;
697
+ function ze({ draft: e, centers: t, extent: n, crossExtent: r, layout: i, label: a }) {
698
+ let { start: l, end: u } = Ae(e.range, t, n), d = i === "vertical", f = (e, t) => d ? {
654
699
  x: e,
655
700
  y: 0,
656
701
  width: Math.max(0, t - e),
@@ -670,12 +715,12 @@ function Pe({ draft: e, centers: t, extent: n, crossExtent: r, layout: i, label:
670
715
  x2: r,
671
716
  y1: e,
672
717
  y2: e
673
- }, m = e.tooNarrow ? ke : Oe, h = P(a.length), g = (l + u) / 2, _ = d ? {
674
- x: Q(g - h / 2, Math.max(0, n - h)),
675
- y: Ne
718
+ }, m = e.tooNarrow ? Pe : Ne, h = ae(a.length), g = (l + u) / 2, _ = d ? {
719
+ x: $(g - h / 2, Math.max(0, n - h)),
720
+ y: Re
676
721
  } : {
677
- x: Ne,
678
- y: Q(g - 20 / 2, Math.max(0, n - 20))
722
+ x: Re,
723
+ y: $(g - 20 / 2, Math.max(0, n - 20))
679
724
  };
680
725
  return /* @__PURE__ */ c("g", {
681
726
  "aria-hidden": "true",
@@ -686,19 +731,19 @@ function Pe({ draft: e, centers: t, extent: n, crossExtent: r, layout: i, label:
686
731
  !e.tooNarrow && /* @__PURE__ */ c(o, { children: [
687
732
  /* @__PURE__ */ s("rect", {
688
733
  ...f(0, l),
689
- fill: Ae,
690
- fillOpacity: Me
734
+ fill: Fe,
735
+ fillOpacity: Le
691
736
  }),
692
737
  /* @__PURE__ */ s("rect", {
693
738
  ...f(u, n),
694
- fill: Ae,
695
- fillOpacity: Me
739
+ fill: Fe,
740
+ fillOpacity: Le
696
741
  }),
697
742
  /* @__PURE__ */ s("rect", {
698
743
  ...f(l, u),
699
744
  "data-slot": "chart-brush-band",
700
- fill: Oe,
701
- fillOpacity: je
745
+ fill: Ne,
746
+ fillOpacity: Ie
702
747
  })
703
748
  ] }),
704
749
  /* @__PURE__ */ s("line", {
@@ -723,8 +768,8 @@ function Pe({ draft: e, centers: t, extent: n, crossExtent: r, layout: i, label:
723
768
  overflow: "visible",
724
769
  children: /* @__PURE__ */ s("span", {
725
770
  "data-slot": "chart-brush-label",
726
- className: ie,
727
- style: F(m),
771
+ className: I,
772
+ style: L(m),
728
773
  children: a
729
774
  })
730
775
  })
@@ -733,7 +778,7 @@ function Pe({ draft: e, centers: t, extent: n, crossExtent: r, layout: i, label:
733
778
  }
734
779
  //#endregion
735
780
  //#region src/primitives/ChartEmptyState.tsx
736
- function Fe({ ariaLabel: a, className: o, ...l }) {
781
+ function Be({ ariaLabel: a, className: o, ...l }) {
737
782
  return /* @__PURE__ */ s("div", {
738
783
  role: "img",
739
784
  "aria-label": a,
@@ -744,7 +789,7 @@ function Fe({ ariaLabel: a, className: o, ...l }) {
744
789
  }
745
790
  //#endregion
746
791
  //#region src/primitives/TooltipPortal.tsx
747
- function Ie({ state: e, containerRef: t, chartId: n, children: r }) {
792
+ function Ve({ state: e, containerRef: t, chartId: n, children: r }) {
748
793
  let i = a.useRef(null), [o, c] = a.useState({
749
794
  x: 0,
750
795
  y: 0,
@@ -787,38 +832,38 @@ function Ie({ state: e, containerRef: t, chartId: n, children: r }) {
787
832
  children: r
788
833
  }), document.body);
789
834
  }
790
- var Le = { status: "idle" };
791
- function Re(e, t, n) {
835
+ var He = { status: "idle" };
836
+ function Ue(e, t, n) {
792
837
  try {
793
838
  n === "set" ? e.setPointerCapture(t) : e.releasePointerCapture(t);
794
839
  } catch {}
795
840
  }
796
- function ze(e) {
841
+ function We(e) {
797
842
  return Math.max(1, Math.floor(e) || 1);
798
843
  }
799
- function Be(e) {
844
+ function Ge(e) {
800
845
  let { slot: t, extent: n, layout: r, categoryKey: i } = e, o = t !== null && !t.disabled, s = a.useRef(e), c = a.useRef(t);
801
846
  a.useLayoutEffect(() => {
802
847
  s.current = e, e.slot && (c.current = e.slot);
803
848
  });
804
- let l = a.useRef(Le), u = a.useRef(null), [d, f] = a.useState(null), p = a.useMemo(() => {
849
+ let l = a.useRef(He), u = a.useRef(null), [d, f] = a.useState(null), p = a.useMemo(() => {
805
850
  let e = (e) => {
806
851
  let { plotRef: t, margin: n, layout: r, extent: i } = s.current, a = t.current?.getBoundingClientRect();
807
- return a ? Q(be(e, a, n, r), i) : null;
852
+ return a ? $(we(e, a, n, r), i) : null;
808
853
  }, t = (e) => {
809
854
  let t = l.current;
810
- if (l.current = Le, u.current &&= (document.removeEventListener("keydown", u.current), null), t.status !== "dragging") return;
855
+ if (l.current = He, u.current &&= (document.removeEventListener("keydown", u.current), null), t.status !== "dragging") return;
811
856
  f(null);
812
857
  let n = s.current.slot ?? c.current;
813
- n && (e === "commit" && we(t.range) >= ze(n.minCategories) ? n.onBrushEnd(t.range) : n.onBrushCancel?.());
858
+ n && (e === "commit" && Oe(t.range) >= We(n.minCategories) ? n.onBrushEnd(t.range) : n.onBrushCancel?.());
814
859
  }, n = (n) => {
815
860
  let { slot: r, centers: i } = s.current;
816
861
  if (!r || r.disabled || n.button !== 0 || l.current.status !== "idle") return;
817
862
  let a = e(n);
818
863
  if (a === null) return;
819
- let o = xe(a, i);
864
+ let o = Te(a, i);
820
865
  if (o < 0) return;
821
- Re(n.currentTarget, n.pointerId, "set"), l.current = {
866
+ Ue(n.currentTarget, n.pointerId, "set"), l.current = {
822
867
  status: "pending",
823
868
  pointerId: n.pointerId,
824
869
  origin: a,
@@ -832,22 +877,22 @@ function Be(e) {
832
877
  let n = l.current;
833
878
  if (n.status === "idle" || t.pointerId !== n.pointerId) return;
834
879
  let r = e(t);
835
- if (r === null || n.status === "pending" && !Ee(n.origin, r, 4)) return;
836
- let { centers: i, slot: a, onDragStart: o } = s.current, c = xe(r, i);
880
+ if (r === null || n.status === "pending" && !je(n.origin, r, 4)) return;
881
+ let { centers: i, slot: a, onDragStart: o } = s.current, c = Te(r, i);
837
882
  if (c < 0) return;
838
- let u = Se(n.originIndex, c);
839
- n.status === "dragging" && Ce(n.range, u) || (n.status === "pending" && o(), l.current = {
883
+ let u = Ee(n.originIndex, c);
884
+ n.status === "dragging" && De(n.range, u) || (n.status === "pending" && o(), l.current = {
840
885
  status: "dragging",
841
886
  pointerId: n.pointerId,
842
887
  originIndex: n.originIndex,
843
888
  range: u
844
889
  }, f({
845
890
  range: u,
846
- tooNarrow: we(u) < ze(a?.minCategories ?? 1)
891
+ tooNarrow: Oe(u) < We(a?.minCategories ?? 1)
847
892
  }), a?.onBrushChange?.(u));
848
893
  }, i = (e) => {
849
894
  let n = l.current;
850
- n.status === "idle" || e.pointerId !== n.pointerId || (Re(e.currentTarget, e.pointerId, "release"), t("commit"));
895
+ n.status === "idle" || e.pointerId !== n.pointerId || (Ue(e.currentTarget, e.pointerId, "release"), t("commit"));
851
896
  }, a = (e) => {
852
897
  let n = l.current;
853
898
  n.status === "idle" || e.pointerId !== n.pointerId || t("cancel");
@@ -881,7 +926,8 @@ function Be(e) {
881
926
  }
882
927
  //#endregion
883
928
  //#region src/primitives/CartesianChart.tsx
884
- function Ve(e) {
929
+ var Ke = 560;
930
+ function qe(e) {
885
931
  let t = [], n = (e) => {
886
932
  a.Children.forEach(e, (e) => {
887
933
  if (!a.isValidElement(e)) return;
@@ -903,11 +949,11 @@ function Ve(e) {
903
949
  };
904
950
  return n(e), t;
905
951
  }
906
- function He(e, t, n) {
952
+ function Je(e, t, n) {
907
953
  let r = n(t[e.startIndex] ?? ""), i = n(t[e.endIndex] ?? "");
908
954
  return e.startIndex === e.endIndex ? r : `${r} – ${i}`;
909
955
  }
910
- function Ue(e) {
956
+ function Ye(e) {
911
957
  let t = !1, n = (e) => {
912
958
  a.Children.forEach(e, (e) => {
913
959
  if (t || !a.isValidElement(e)) return;
@@ -921,17 +967,17 @@ function Ue(e) {
921
967
  };
922
968
  return n(e), t;
923
969
  }
924
- function We({ state: e, className: t, data: n, margin: r, categoryPadding: i, categoryScaleType: a, layout: o, colorMode: c, animated: l, ariaLabel: u, valueTickFormatter: d, categoryTickFormatter: f, onPointHover: p, onPointLeave: m, children: h, ...g }) {
925
- let _ = ge(e, n.length);
926
- return _ === "loading" ? /* @__PURE__ */ s(ve, {
970
+ function Xe({ state: e, className: t, data: n, margin: r, categoryPadding: i, categoryScaleType: a, layout: o, colorMode: c, animated: l, ariaLabel: u, valueTickFormatter: d, categoryTickFormatter: f, onPointHover: p, onPointLeave: m, children: h, ...g }) {
971
+ let _ = ve(e, n.length);
972
+ return _ === "loading" ? /* @__PURE__ */ s(Se, {
927
973
  ariaLabel: u,
928
974
  className: t,
929
975
  ...g
930
- }) : _ === "empty" ? /* @__PURE__ */ s(Fe, {
976
+ }) : _ === "empty" ? /* @__PURE__ */ s(Be, {
931
977
  ariaLabel: u ?? "No data",
932
978
  className: t,
933
979
  ...g
934
- }) : /* @__PURE__ */ s(Y, { children: /* @__PURE__ */ s(Ge, {
980
+ }) : /* @__PURE__ */ s(Z, { children: /* @__PURE__ */ s(Ze, {
935
981
  data: n,
936
982
  margin: r,
937
983
  categoryPadding: i,
@@ -949,9 +995,9 @@ function We({ state: e, className: t, data: n, margin: r, categoryPadding: i, ca
949
995
  children: h
950
996
  }) });
951
997
  }
952
- function Ge({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i = "band", layout: o = "vertical", colorMode: h = "series", animated: g = !0, ariaLabel: v, valueTickFormatter: b = _, categoryTickFormatter: S = String, onPointHover: w, onPointLeave: T, className: ee, children: E, ...O }) {
953
- let { config: k, id: A } = C(), { tooltip: M, legend: N, brush: ne } = pe(), re = a.useMemo(() => Ue(E), [E]), ie = a.useMemo(() => {
954
- let e = Ve(E), n = {};
998
+ function Ze({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i = "band", layout: o = "vertical", colorMode: h = "series", animated: g = !0, ariaLabel: v, valueTickFormatter: y = _, categoryTickFormatter: b = String, onPointHover: x, onPointLeave: C, className: T, children: D, ...O }) {
999
+ let { config: k, id: A } = E(), { tooltip: j, legend: te, brush: ne } = me(), ie = a.useMemo(() => Ye(D), [D]), N = a.useMemo(() => {
1000
+ let e = qe(D), n = {};
955
1001
  for (let r of ["left", "right"]) {
956
1002
  let i = e.filter((e) => (e.axisId ?? "left") === r).map((e) => e.dataKey);
957
1003
  if (i.length === 0) continue;
@@ -962,7 +1008,7 @@ function Ge({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
962
1008
  let r = Number(n);
963
1009
  Number.isFinite(r) && Math.abs(r) > a && (a = Math.abs(r));
964
1010
  }
965
- let o = b(Math.ceil(a * 1.1)), s = "";
1011
+ let o = y(Math.ceil(a * 1.1)), s = "";
966
1012
  for (let t of e) if ((t.axisId ?? "left") === r) {
967
1013
  let e = k[t.dataKey]?.unit;
968
1014
  if (e) {
@@ -974,16 +1020,16 @@ function Ge({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
974
1020
  }
975
1021
  return n;
976
1022
  }, [
977
- E,
1023
+ D,
978
1024
  t,
979
1025
  k,
980
- b
1026
+ y
981
1027
  ]), P = {
982
- ...y,
1028
+ ...S,
983
1029
  ...n
984
1030
  };
985
- ie.left !== void 0 && n?.left === void 0 && (P.left = Math.max(P.left, ie.left)), re && n?.right === void 0 && (P.right = Math.max(P.right, ie.right ?? 40));
986
- let F = o === "vertical", I = a.useRef(null), L = a.useRef(null), R = D(L), z = te(), [ae, oe] = a.useState(null), [se, B] = a.useState(null), V = a.useCallback((e) => B(e), []), ce = a.useCallback(() => B(null), []), H = Math.max(0, R.width - P.left - P.right), U = Math.max(0, R.height - P.top - P.bottom), le = P.left, W = a.useMemo(() => t.map((e) => e.category), [t]), G = a.useMemo(() => Ve(E), [E]), K = a.useMemo(() => G.map((e) => e.dataKey), [G]), q = a.useMemo(() => {
1031
+ N.left !== void 0 && n?.left === void 0 && (P.left = Math.max(P.left, N.left)), ie && n?.right === void 0 && (P.right = Math.max(P.right, N.right ?? 40));
1032
+ let F = o === "vertical", I = a.useRef(null), ae = a.useRef(null), L = ee(ae), R = re(), [z, oe] = a.useState(null), [B, se] = a.useState(null), ce = a.useCallback((e) => se(e), []), le = a.useCallback(() => se(null), []), V = Math.max(0, L.width - P.left - P.right), H = Math.max(0, L.height - P.top - P.bottom), U = P.left, W = a.useMemo(() => t.map((e) => e.category), [t]), G = a.useMemo(() => qe(D), [D]), K = a.useMemo(() => G.map((e) => e.dataKey), [G]), q = a.useMemo(() => {
987
1033
  let e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
988
1034
  for (let e of G) {
989
1035
  if (!e.stackId) continue;
@@ -1000,16 +1046,16 @@ function Ge({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
1000
1046
  e.set(r, n(t));
1001
1047
  }
1002
1048
  return e;
1003
- }, [t, G]), ue = a.useMemo(() => G.filter((e) => e.seriesType === "BarSeries" && !e.stackId).map((e) => e.dataKey), [G]), de = a.useMemo(() => {
1049
+ }, [t, G]), J = a.useMemo(() => G.filter((e) => e.seriesType === "BarSeries" && !e.stackId).map((e) => e.dataKey), [G]), ue = a.useMemo(() => {
1004
1050
  let e = /* @__PURE__ */ new Map();
1005
1051
  for (let t of G) {
1006
1052
  let n = t.axisId ?? "left", r = e.get(n) ?? [];
1007
1053
  r.push(t.dataKey), e.set(n, r);
1008
1054
  }
1009
1055
  return e;
1010
- }, [G]), fe = a.useMemo(() => {
1056
+ }, [G]), de = a.useMemo(() => {
1011
1057
  let e = /* @__PURE__ */ new Map();
1012
- for (let [n, r] of de) {
1058
+ for (let [n, r] of ue) {
1013
1059
  let i = new Set(r), a = G.some((e) => e.stackId && i.has(e.dataKey)), o = r.filter((e) => !G.find((t) => t.dataKey === e && t.stackId));
1014
1060
  if (a) {
1015
1061
  let r = -Infinity;
@@ -1034,29 +1080,29 @@ function Ge({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
1034
1080
  }
1035
1081
  return e;
1036
1082
  }, [
1037
- de,
1083
+ ue,
1038
1084
  t,
1039
1085
  q,
1040
1086
  G
1041
- ]), J = a.useMemo(() => i === "point" ? Object.assign(d().domain(W).range([0, F ? H : U]).padding(0), { bandwidth: () => 0 }) : l().domain(W).range([0, F ? H : U]).padding(r), [
1087
+ ]), Y = a.useMemo(() => i === "point" ? Object.assign(d().domain(W).range([0, F ? V : H]).padding(0), { bandwidth: () => 0 }) : l().domain(W).range([0, F ? V : H]).padding(r), [
1042
1088
  W,
1043
1089
  i,
1044
1090
  r,
1045
1091
  F,
1046
- H,
1047
- U
1048
- ]), Y = a.useMemo(() => ye(W, J), [W, J]), me = F ? H : U, ge = a.useMemo(() => W.join(""), [W]);
1049
- he(a.useMemo(() => null, [W])), he(a.useMemo(() => null, [ne?.minCategories, t.length]));
1050
- let X = a.useMemo(() => {
1092
+ V,
1093
+ H
1094
+ ]), X = a.useMemo(() => Ce(W, Y), [W, Y]), fe = F ? V : H, pe = a.useMemo(() => W.join(""), [W]);
1095
+ _e(a.useMemo(() => null, [W])), _e(a.useMemo(() => null, [ne?.minCategories, t.length]));
1096
+ let Z = a.useMemo(() => {
1051
1097
  let e = {};
1052
- for (let [t, [n, r]] of fe) e[t] = u().domain([Math.min(0, n), r * 1.1 || 1]).nice().range(F ? [U, 0] : [0, H]);
1053
- return e.left ||= u().domain([0, 1]).nice().range(F ? [U, 0] : [0, H]), e;
1098
+ for (let [t, [n, r]] of de) e[t] = u().domain([Math.min(0, n), r * 1.1 || 1]).nice().range(F ? [H, 0] : [0, V]);
1099
+ return e.left ||= u().domain([0, 1]).nice().range(F ? [H, 0] : [0, V]), e;
1054
1100
  }, [
1055
- fe,
1101
+ de,
1056
1102
  F,
1057
- U,
1058
- H
1059
- ]), Z = X.left, _e = a.useCallback((e) => e ? X[e] ?? Z : Z, [Z, X]), ve = a.useMemo(() => {
1103
+ H,
1104
+ V
1105
+ ]), Q = Z.left, ge = a.useCallback((e) => e ? Z[e] ?? Q : Q, [Q, Z]), ve = a.useMemo(() => {
1060
1106
  let e = {};
1061
1107
  for (let t of G) {
1062
1108
  let n = t.axisId ?? "left";
@@ -1065,21 +1111,21 @@ function Ge({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
1065
1111
  r && (e[n] = r);
1066
1112
  }
1067
1113
  return e;
1068
- }, [G, k]), Q = a.useMemo(() => ue.length <= 1 ? null : l().domain(ue).range([0, J.bandwidth()]).padding(.05), [ue, J]), Se = h === "category" ? W.map((e) => ({
1114
+ }, [G, k]), ye = a.useMemo(() => J.length <= 1 ? null : l().domain(J).range([0, Y.bandwidth()]).padding(.05), [J, Y]), be = h === "category" ? W.map((e) => ({
1069
1115
  dataKey: e,
1070
1116
  value: e
1071
1117
  })) : K.map((e) => ({
1072
1118
  dataKey: e,
1073
1119
  value: e
1074
1120
  }));
1075
- function Ce(e) {
1121
+ function xe(e) {
1076
1122
  if (h === "category") {
1077
1123
  let t = K[0], n = t === void 0 ? 0 : Number(e[t]) || 0;
1078
1124
  return [{
1079
1125
  dataKey: e.category,
1080
1126
  name: e.category,
1081
1127
  value: n,
1082
- color: `var(--color-${x(e.category)})`
1128
+ color: `var(--color-${w(e.category)})`
1083
1129
  }];
1084
1130
  }
1085
1131
  return K.filter((t) => e[t] !== null && e[t] !== void 0).map((t) => ({
@@ -1088,37 +1134,37 @@ function Ge({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
1088
1134
  value: Number(e[t]) || 0
1089
1135
  }));
1090
1136
  }
1091
- function we() {
1092
- oe(null), z.hide(), T?.();
1137
+ function Se() {
1138
+ oe(null), R.hide(), C?.();
1093
1139
  }
1094
- let $ = Be({
1140
+ let $ = Ge({
1095
1141
  slot: ne,
1096
- centers: Y,
1097
- extent: me,
1142
+ centers: X,
1143
+ extent: fe,
1098
1144
  layout: o,
1099
1145
  margin: P,
1100
1146
  plotRef: I,
1101
- onDragStart: we,
1102
- categoryKey: ge
1103
- }), Te = $.draft ? He($.draft.range, W, S) : "";
1104
- function Ee(e) {
1147
+ onDragStart: Se,
1148
+ categoryKey: pe
1149
+ }), Ee = $.draft ? Je($.draft.range, W, b) : "";
1150
+ function De(e) {
1105
1151
  if ($.isDragging()) return;
1106
1152
  let n = I.current?.getBoundingClientRect();
1107
1153
  if (!n) return;
1108
- let r = xe(be(e, n, P, o), Y), i = t[r];
1154
+ let r = Te(we(e, n, P, o), X), i = t[r];
1109
1155
  if (!i) return;
1110
1156
  oe(i.category);
1111
- let a = Ce(i), s = Y[r], c = F ? {
1157
+ let a = xe(i), s = X[r], c = F ? {
1112
1158
  clientX: n.left + P.left + s,
1113
1159
  clientY: e.clientY
1114
1160
  } : {
1115
1161
  clientX: e.clientX,
1116
1162
  clientY: n.top + P.top + s
1117
1163
  };
1118
- M && z.show(a, i.category, c, n), w?.(a, i.category, e);
1164
+ j && R.show(a, i.category, c, n), x?.(a, i.category, e);
1119
1165
  }
1120
- let De = a.useCallback((e, n) => {
1121
- if (!M) return;
1166
+ let Oe = a.useCallback((e, n) => {
1167
+ if (!j) return;
1122
1168
  let r = I.current?.getBoundingClientRect();
1123
1169
  if (!r) return;
1124
1170
  let i = t.find((t) => t.category === e);
@@ -1127,7 +1173,7 @@ function Ge({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
1127
1173
  dataKey: e,
1128
1174
  name: e,
1129
1175
  value: K[0] === void 0 ? 0 : Number(i[K[0]]) || 0,
1130
- color: `var(--color-${x(e)})`
1176
+ color: `var(--color-${w(e)})`
1131
1177
  }] : K.filter((e) => i[e] !== null && i[e] !== void 0).map((e) => ({
1132
1178
  dataKey: e,
1133
1179
  name: e,
@@ -1136,148 +1182,140 @@ function Ge({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
1136
1182
  clientX: n.left + n.width / 2,
1137
1183
  clientY: n.top + n.height / 2
1138
1184
  };
1139
- z.show(a, e, o, r);
1185
+ R.show(a, e, o, r);
1140
1186
  }, [
1141
- M,
1187
+ j,
1142
1188
  t,
1143
1189
  K,
1144
1190
  h,
1145
- z
1146
- ]), Oe = a.useCallback(() => {
1147
- z.hide();
1148
- }, [z]), ke = N?.verticalAlign ?? "bottom", Ae = v ?? `Chart with ${t.length} categor${t.length === 1 ? "y" : "ies"} and ${K.length} series`, je = a.useMemo(() => ({
1191
+ R
1192
+ ]), ke = a.useCallback(() => {
1193
+ R.hide();
1194
+ }, [R]), Ae = v ?? `Chart with ${t.length} categor${t.length === 1 ? "y" : "ies"} and ${K.length} series`, je = a.useMemo(() => ({
1149
1195
  data: t,
1150
1196
  dataKeys: K,
1151
1197
  colorMode: h,
1152
- categoryScale: J,
1153
- valueScale: Z,
1154
- valueScales: X,
1155
- resolveValueScale: _e,
1198
+ categoryScale: Y,
1199
+ valueScale: Q,
1200
+ valueScales: Z,
1201
+ resolveValueScale: ge,
1156
1202
  axisUnits: ve,
1157
- innerWidth: H,
1158
- innerHeight: U,
1159
- marginLeft: le,
1203
+ innerWidth: V,
1204
+ innerHeight: H,
1205
+ marginLeft: U,
1160
1206
  layout: o,
1161
1207
  animated: g,
1162
- hoveredCategory: ae,
1163
- hoveredLegendKey: se,
1208
+ hoveredCategory: z,
1209
+ hoveredLegendKey: B,
1164
1210
  config: k,
1165
1211
  stackedLayers: q,
1166
- barGroupScale: Q,
1167
- valueTickFormatter: b,
1168
- categoryTickFormatter: S,
1212
+ barGroupScale: ye,
1213
+ valueTickFormatter: y,
1214
+ categoryTickFormatter: b,
1169
1215
  chartWrapperRef: I,
1170
1216
  chartId: A,
1171
- showTooltipAt: De,
1172
- hideTooltip: Oe
1217
+ showTooltipAt: Oe,
1218
+ hideTooltip: ke
1173
1219
  }), [
1174
1220
  t,
1175
1221
  K,
1176
1222
  h,
1177
- J,
1223
+ Y,
1224
+ Q,
1178
1225
  Z,
1179
- X,
1180
- _e,
1226
+ ge,
1181
1227
  ve,
1228
+ V,
1182
1229
  H,
1183
1230
  U,
1184
- le,
1185
1231
  o,
1186
1232
  g,
1187
- ae,
1188
- se,
1233
+ z,
1234
+ B,
1189
1235
  k,
1190
1236
  q,
1191
- Q,
1237
+ ye,
1238
+ y,
1192
1239
  b,
1193
- S,
1194
1240
  A,
1195
- De,
1196
- Oe
1241
+ Oe,
1242
+ ke
1197
1243
  ]);
1198
- return /* @__PURE__ */ s(j.Provider, {
1244
+ return /* @__PURE__ */ s(M.Provider, {
1199
1245
  value: je,
1200
- children: /* @__PURE__ */ c("div", {
1201
- className: e("flex h-full w-full flex-col", ee),
1246
+ children: /* @__PURE__ */ s(he, {
1247
+ legend: te,
1248
+ legendProps: {
1249
+ items: be,
1250
+ onItemHover: ce,
1251
+ onItemLeave: le,
1252
+ hoveredLegendKey: B
1253
+ },
1254
+ minWidthForRight: Ke,
1255
+ className: T,
1202
1256
  ...O,
1203
- children: [
1204
- N && ke === "top" && a.cloneElement(N.content, {
1205
- items: Se,
1206
- verticalAlign: "top",
1207
- onItemHover: V,
1208
- onItemLeave: ce,
1209
- hoveredLegendKey: se
1210
- }),
1211
- /* @__PURE__ */ c("div", {
1212
- ref: I,
1213
- "data-slot": "chart-plot",
1214
- "data-dashboard-grid-no-drag": $.active ? "" : void 0,
1215
- className: e("relative min-h-0 flex-1", $.active && "cursor-crosshair select-none", $.active && (F ? "touch-pan-y" : "touch-pan-x")),
1216
- onMouseMove: Ee,
1217
- onMouseLeave: we,
1218
- ...$.handlers,
1219
- children: [
1220
- /* @__PURE__ */ s("svg", {
1221
- ref: L,
1222
- role: "img",
1223
- "aria-label": Ae,
1224
- className: "h-full w-full",
1225
- overflow: "visible",
1226
- children: R.width > 0 && R.height > 0 && /* @__PURE__ */ c("g", {
1227
- transform: `translate(${P.left},${P.top})`,
1228
- children: [E, $.draft && /* @__PURE__ */ s(Pe, {
1229
- draft: $.draft,
1230
- centers: Y,
1231
- extent: me,
1232
- crossExtent: F ? U : H,
1233
- layout: o,
1234
- label: Te
1235
- })]
1236
- })
1237
- }),
1238
- /* @__PURE__ */ s("div", {
1239
- className: "sr-only",
1240
- children: /* @__PURE__ */ c("table", { children: [
1241
- /* @__PURE__ */ s("caption", { children: Ae }),
1242
- /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ c("tr", { children: [/* @__PURE__ */ s("th", {
1243
- scope: "col",
1244
- children: "Category"
1245
- }), K.map((e) => /* @__PURE__ */ s("th", {
1246
- scope: "col",
1247
- children: typeof k[e]?.label == "string" ? k[e]?.label : e
1248
- }, e))] }) }),
1249
- /* @__PURE__ */ s("tbody", { children: t.map((e) => /* @__PURE__ */ c("tr", { children: [/* @__PURE__ */ s("th", {
1250
- scope: "row",
1251
- children: e.category
1252
- }), K.map((t) => /* @__PURE__ */ s("td", { children: e[t] !== null && e[t] !== void 0 ? b(Number(e[t]) || 0) : "—" }, t))] }, e.category)) })
1253
- ] })
1254
- }),
1255
- M && z.state && /* @__PURE__ */ s(Ie, {
1256
- state: z.state,
1257
- containerRef: I,
1258
- chartId: A,
1259
- children: a.cloneElement(M.content, {
1260
- label: z.state.label,
1261
- items: z.state.items,
1262
- active: !0
1263
- })
1257
+ children: /* @__PURE__ */ c("div", {
1258
+ ref: I,
1259
+ "data-slot": "chart-plot",
1260
+ "data-dashboard-grid-no-drag": $.active ? "" : void 0,
1261
+ className: e("relative min-h-0 min-w-0 flex-1", $.active && "cursor-crosshair select-none", $.active && (F ? "touch-pan-y" : "touch-pan-x")),
1262
+ onMouseMove: De,
1263
+ onMouseLeave: Se,
1264
+ ...$.handlers,
1265
+ children: [
1266
+ /* @__PURE__ */ s("svg", {
1267
+ ref: ae,
1268
+ role: "img",
1269
+ "aria-label": Ae,
1270
+ className: "h-full w-full",
1271
+ overflow: "visible",
1272
+ children: L.width > 0 && L.height > 0 && /* @__PURE__ */ c("g", {
1273
+ transform: `translate(${P.left},${P.top})`,
1274
+ children: [D, $.draft && /* @__PURE__ */ s(ze, {
1275
+ draft: $.draft,
1276
+ centers: X,
1277
+ extent: fe,
1278
+ crossExtent: F ? H : V,
1279
+ layout: o,
1280
+ label: Ee
1281
+ })]
1264
1282
  })
1265
- ]
1266
- }),
1267
- N && ke === "bottom" && a.cloneElement(N.content, {
1268
- items: Se,
1269
- verticalAlign: "bottom",
1270
- onItemHover: V,
1271
- onItemLeave: ce,
1272
- hoveredLegendKey: se
1273
- })
1274
- ]
1283
+ }),
1284
+ /* @__PURE__ */ s("div", {
1285
+ className: "sr-only",
1286
+ children: /* @__PURE__ */ c("table", { children: [
1287
+ /* @__PURE__ */ s("caption", { children: Ae }),
1288
+ /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ c("tr", { children: [/* @__PURE__ */ s("th", {
1289
+ scope: "col",
1290
+ children: "Category"
1291
+ }), K.map((e) => /* @__PURE__ */ s("th", {
1292
+ scope: "col",
1293
+ children: typeof k[e]?.label == "string" ? k[e]?.label : e
1294
+ }, e))] }) }),
1295
+ /* @__PURE__ */ s("tbody", { children: t.map((e) => /* @__PURE__ */ c("tr", { children: [/* @__PURE__ */ s("th", {
1296
+ scope: "row",
1297
+ children: e.category
1298
+ }), K.map((t) => /* @__PURE__ */ s("td", { children: e[t] !== null && e[t] !== void 0 ? y(Number(e[t]) || 0) : "—" }, t))] }, e.category)) })
1299
+ ] })
1300
+ }),
1301
+ j && R.state && /* @__PURE__ */ s(Ve, {
1302
+ state: R.state,
1303
+ containerRef: I,
1304
+ chartId: A,
1305
+ children: a.cloneElement(j.content, {
1306
+ label: R.state.label,
1307
+ items: R.state.items,
1308
+ active: !0
1309
+ })
1310
+ })
1311
+ ]
1312
+ })
1275
1313
  })
1276
1314
  });
1277
1315
  }
1278
1316
  //#endregion
1279
1317
  //#region src/primitives/AreaChartSkeleton.tsx
1280
- function Ke({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1318
+ function Qe({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1281
1319
  return /* @__PURE__ */ s("div", {
1282
1320
  role: "img",
1283
1321
  "aria-label": t,
@@ -1323,7 +1361,7 @@ function Ke({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1323
1361
  }
1324
1362
  //#endregion
1325
1363
  //#region src/primitives/SkeletonBlock.tsx
1326
- function qe({ className: t, ...n }) {
1364
+ function $e({ className: t, ...n }) {
1327
1365
  return /* @__PURE__ */ s("div", {
1328
1366
  className: e("animate-pulse rounded-md bg-muted", t),
1329
1367
  ...n
@@ -1331,7 +1369,7 @@ function qe({ className: t, ...n }) {
1331
1369
  }
1332
1370
  //#endregion
1333
1371
  //#region src/primitives/DoughnutChartSkeleton.tsx
1334
- function Je({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1372
+ function et({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1335
1373
  return /* @__PURE__ */ s("div", {
1336
1374
  role: "img",
1337
1375
  "aria-label": t,
@@ -1355,4 +1393,4 @@ function Je({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1355
1393
  });
1356
1394
  }
1357
1395
  //#endregion
1358
- export { _ as A, D as C, x as D, C as E, v as O, te as S, E as T, de as _, Ie as a, j as b, _e as c, he as d, me as f, ue as g, fe as h, We as i, y as k, Z as l, pe as m, qe as n, Fe as o, Y as p, Ke as r, De as s, Je as t, ge as u, z as v, ee as w, M as x, N as y };
1396
+ export { S as A, re as C, E as D, A as E, v as M, y as N, w as O, b as P, ie as S, k as T, Y as _, Ve as a, N as b, xe as c, _e as d, ge as f, fe as g, me as h, Xe as i, _ as j, x as k, be as l, Z as m, $e as n, Be as o, he as p, Qe as r, Me as s, et as t, ve as u, X as v, ee as w, M as x, B as y };