@nice2dev/ui 1.1.9 → 1.1.10

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +17 -16
  3. package/dist/NiceCodeEditor-BfkH1bsZ.cjs +260 -0
  4. package/dist/NiceCodeEditor-CduGYggj.js +1179 -0
  5. package/dist/NiceColorPicker-CdUnhM-A.cjs +1 -0
  6. package/dist/NiceColorPicker-DpXwnDwL.js +598 -0
  7. package/dist/NiceConfirmDialog-B7aNRL2K.cjs +1 -0
  8. package/dist/NiceConfirmDialog-BdhWenrO.js +81 -0
  9. package/dist/NiceDataGrid-CVYEo_nv.cjs +10 -0
  10. package/dist/NiceDataGrid-D-rm4lu8.js +2217 -0
  11. package/dist/NiceDocumentViewer-BgcgLWJ3.cjs +180 -0
  12. package/dist/NiceDocumentViewer-sukmGhRx.js +672 -0
  13. package/dist/NiceForm-DVc0Xoly.js +4819 -0
  14. package/dist/NiceForm-qD_RKPYz.cjs +1 -0
  15. package/dist/NiceGantt-4UBd4uJ8.cjs +1 -0
  16. package/dist/NiceGantt-B_1lwEsp.js +328 -0
  17. package/dist/NiceHtmlEditor-Bce9Vwe1.cjs +10 -0
  18. package/dist/NiceHtmlEditor-CGRgcu2h.js +848 -0
  19. package/dist/NiceLoginForm-BTuQ0eKk.cjs +1 -0
  20. package/dist/NiceLoginForm-o1A-TBcp.js +736 -0
  21. package/dist/NiceMention-Dds9GQzk.cjs +430 -0
  22. package/dist/NiceMention-DlLXWddO.js +11268 -0
  23. package/dist/NiceModal-Dr1e3nQZ.cjs +1 -0
  24. package/dist/NiceModal-sihGCfDy.js +95 -0
  25. package/dist/NiceModuleLifecyclePanel-Du7G3-RG.js +7053 -0
  26. package/dist/NiceModuleLifecyclePanel-js1p7LIY.cjs +1 -0
  27. package/dist/NicePagination-D44waj9o.cjs +1 -0
  28. package/dist/NicePagination-DdxH8KMG.js +179 -0
  29. package/dist/NicePivotGrid-B2YHP3Z6.js +1183 -0
  30. package/dist/NicePivotGrid-BtVUWiud.cjs +152 -0
  31. package/dist/NiceSavedQueryPanel-C0A-eoYN.js +5142 -0
  32. package/dist/NiceSavedQueryPanel-ZrilZRtf.cjs +586 -0
  33. package/dist/NiceScheduler-KSzaUQxC.js +1693 -0
  34. package/dist/NiceScheduler-O3AwmdGG.cjs +5 -0
  35. package/dist/NiceSelect-BCbWtu1v.js +433 -0
  36. package/dist/NiceSelect-BqtiQbfD.cjs +1 -0
  37. package/dist/NiceWindow-BU1Ce7gS.js +1623 -0
  38. package/dist/NiceWindow-jjdE6vGy.cjs +1 -0
  39. package/dist/charts-C44vJber.cjs +768 -0
  40. package/dist/charts-XVlDwU0y.js +4732 -0
  41. package/dist/charts.cjs +1 -1
  42. package/dist/charts.mjs +8 -8
  43. package/dist/core-BxiH7vkV.cjs +1 -0
  44. package/dist/core-DMV6_SEE.js +795 -0
  45. package/dist/data-branching-oEH04O3i.js +6273 -0
  46. package/dist/data-branching-wmsbLNfa.cjs +1 -0
  47. package/dist/data-branching.cjs +1 -1
  48. package/dist/data-branching.mjs +1 -1
  49. package/dist/data.cjs +1 -1
  50. package/dist/data.d.ts +2 -2
  51. package/dist/data.mjs +3 -3
  52. package/dist/devops-Bt6EsfPa.cjs +17 -0
  53. package/dist/devops-CnZQ1rU5.js +8312 -0
  54. package/dist/devops.cjs +1 -1
  55. package/dist/devops.mjs +1 -1
  56. package/dist/editors.cjs +1 -1
  57. package/dist/editors.d.ts +2 -1
  58. package/dist/editors.mjs +7 -7
  59. package/dist/feedback.cjs +1 -1
  60. package/dist/feedback.mjs +3 -3
  61. package/dist/index.cjs +142 -142
  62. package/dist/index.d.ts +45 -26
  63. package/dist/index.mjs +7480 -7459
  64. package/dist/lazy.cjs +1 -1
  65. package/dist/lazy.mjs +24 -24
  66. package/dist/navigation.cjs +1 -1
  67. package/dist/navigation.d.ts +4 -4
  68. package/dist/navigation.mjs +69 -69
  69. package/dist/no-code-4GtIBr6f.js +7503 -0
  70. package/dist/no-code-Bdwh1vyS.cjs +332 -0
  71. package/dist/no-code.cjs +1 -1
  72. package/dist/no-code.mjs +1 -1
  73. package/dist/overlays.cjs +1 -1
  74. package/dist/overlays.mjs +102 -102
  75. package/dist/pickerCommons-31hyz1gs.js +1122 -0
  76. package/dist/pickerCommons-BifIkPdk.cjs +1 -0
  77. package/package.json +4 -4
@@ -0,0 +1,4732 @@
1
+ import { jsx as e, jsxs as b, Fragment as Ye } from "react/jsx-runtime";
2
+ import { resolveCssColor as Ze, NiceIcon as Me, useControlId as Le, useNiceAI as Ue, useChartSuggestion as Ge, useNiceTranslation as De } from "@nice2dev/ui-core";
3
+ import je, { useRef as ve, useState as he, useMemo as me, useCallback as ie, forwardRef as Se, useEffect as Ae, useImperativeHandle as ze } from "react";
4
+ import { useNiceTranslation as qe } from "@nice2dev/i18n";
5
+ const Ce = [
6
+ "var(--nice-color-primary, #3b82f6)",
7
+ "var(--nice-color-error, #ef4444)",
8
+ "var(--nice-color-success, #22c55e)",
9
+ "var(--nice-color-warning, #f59e0b)",
10
+ "var(--nice-color-accent, #8b5cf6)",
11
+ "var(--nice-color-accent-pink, #ec4899)",
12
+ "var(--nice-color-info, #06b6d4)",
13
+ "var(--nice-success, #84cc16)"
14
+ ], Pe = ({
15
+ series: t,
16
+ categories: c,
17
+ width: p = 600,
18
+ height: a = 400,
19
+ title: i,
20
+ showLegend: v = !0,
21
+ showGrid: _ = !0,
22
+ axisLabels: C = !0,
23
+ yAxisLabel: L,
24
+ xAxisLabel: k,
25
+ stacked: m,
26
+ animated: w,
27
+ zoomable: R,
28
+ crosshair: I,
29
+ annotations: $,
30
+ legendInteractive: l,
31
+ onDataPointClick: o,
32
+ exportable: h,
33
+ className: z,
34
+ style: g
35
+ }) => {
36
+ const S = ve(null), [y, D] = he(/* @__PURE__ */ new Set()), [r, B] = he(null), [d, M] = he(null), [x, O] = he(!1), Y = ve(null), V = me(
37
+ () => t.filter((N) => !y.has(N.name)),
38
+ [t, y]
39
+ ), X = ie(
40
+ (N) => {
41
+ l && D((G) => {
42
+ const ne = new Set(G);
43
+ return ne.has(N) ? ne.delete(N) : ne.add(N), ne;
44
+ });
45
+ },
46
+ [l]
47
+ ), E = {
48
+ top: i ? 40 : 20,
49
+ right: 20,
50
+ bottom: k ? 60 : 40,
51
+ left: L ? 60 : 50
52
+ }, Z = p - E.left - E.right, H = a - E.top - E.bottom, J = V[0]?.data.length ?? t[0]?.data.length ?? 0, f = d?.start ?? 0, re = d?.end ?? J, Q = re - f, ee = me(
53
+ () => V.map((N) => ({ ...N, data: N.data.slice(f, re) })),
54
+ [V, f, re]
55
+ ), U = me(
56
+ () => c?.slice(f, re),
57
+ [c, f, re]
58
+ ), { minY: oe, maxY: P, yTicks: u } = me(() => {
59
+ let N;
60
+ if (m) {
61
+ N = [];
62
+ for (let A = 0; A < Q; A++)
63
+ N.push(ee.reduce((K, ue) => K + (ue.data[A] || 0), 0));
64
+ } else
65
+ N = ee.flatMap((A) => A.data);
66
+ N.length === 0 && (N = [0]);
67
+ const G = Math.min(0, ...N), ne = Math.max(0, ...N), le = ne - G || 1, de = Math.pow(10, Math.floor(Math.log10(le))) || 1, n = Math.floor(G / de) * de;
68
+ let W = Math.ceil(ne / de) * de;
69
+ const F = [];
70
+ for (let A = n; A <= W; A += de)
71
+ F.push(Math.round(A * 1e6) / 1e6);
72
+ return F.length < 2 && (W = n + de, F.push(Math.round(W * 1e6) / 1e6)), { minY: n, maxY: W, yTicks: F };
73
+ }, [ee, Q, m]), s = (N) => H - (N - oe) / (P - oe || 1) * H, T = (N) => (N + 0.5) / Q * Z, te = Q > 0 ? Z / Q / (m ? 1.5 : Math.max(V.length, 1) * 1.5) : 20, ce = ie(
74
+ (N) => {
75
+ if (!R)
76
+ return;
77
+ N.preventDefault();
78
+ const G = d ?? { start: 0, end: J }, ne = G.end - G.start, le = (G.start + G.end) / 2, de = N.deltaY > 0 ? 1.2 : 0.8, n = Math.max(2, Math.min(J, Math.round(ne * de))), W = Math.max(0, Math.round(le - n / 2)), F = Math.min(J, W + n);
79
+ M({ start: W, end: F });
80
+ },
81
+ [R, d, J]
82
+ ), j = ie(
83
+ (N) => {
84
+ R && (O(!0), Y.current = { x: N.clientX, range: d ?? { start: 0, end: J } });
85
+ },
86
+ [R, d, J]
87
+ ), se = ie(
88
+ (N) => {
89
+ const G = S.current?.getBoundingClientRect();
90
+ if (G && B({ x: N.clientX - G.left - E.left, y: N.clientY - G.top - E.top }), x && Y.current && R) {
91
+ const ne = N.clientX - Y.current.x, le = Z / Q, de = -Math.round(ne / le), n = Y.current.range, W = n.end - n.start;
92
+ let F = n.start + de;
93
+ F < 0 && (F = 0), F + W > J && (F = J - W), M({ start: F, end: F + W });
94
+ }
95
+ },
96
+ [x, R, Z, Q, J, E.left, E.top]
97
+ ), fe = ie(() => {
98
+ O(!1), Y.current = null;
99
+ }, []), be = ie(() => {
100
+ B(null), O(!1), Y.current = null;
101
+ }, []), $e = ie(() => {
102
+ const N = S.current;
103
+ if (!N)
104
+ return;
105
+ const G = new XMLSerializer().serializeToString(N), ne = document.createElement("canvas");
106
+ ne.width = p, ne.height = a + (v ? 30 : 0);
107
+ const le = ne.getContext("2d");
108
+ if (!le)
109
+ return;
110
+ const de = new Image();
111
+ de.onload = () => {
112
+ le.fillStyle = Ze("var(--nice-bg-primary, #fff)", le.canvas), le.fillRect(0, 0, ne.width, ne.height), le.drawImage(de, 0, 0);
113
+ const n = document.createElement("a");
114
+ n.download = "chart.png", n.href = ne.toDataURL("image/png"), n.click();
115
+ }, de.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(G);
116
+ }, [p, a, v]), _e = a + (v ? 30 : 0), q = ee.length > 0 && ee.every((N) => N.type === "radar"), ae = me(() => {
117
+ if (!q)
118
+ return 1;
119
+ const N = ee.flatMap((G) => G.data);
120
+ return Math.max(1, ...N);
121
+ }, [q, ee]);
122
+ if (q) {
123
+ const N = p / 2, G = (a - E.top - E.bottom) / 2 + E.top, ne = Math.min(Z, a - E.top - E.bottom) / 2 - 10, le = U?.length ?? ee[0]?.data.length ?? 0, de = (F) => F / le * Math.PI * 2 - Math.PI / 2, n = (F, A) => {
124
+ const K = A / ae * ne;
125
+ return [N + Math.cos(de(F)) * K, G + Math.sin(de(F)) * K];
126
+ }, W = 4;
127
+ return /* @__PURE__ */ e("div", { className: `nice-chart nice-chart--radar ${z || ""}`, style: g, children: /* @__PURE__ */ b(
128
+ "svg",
129
+ {
130
+ ref: S,
131
+ viewBox: `0 0 ${p} ${_e}`,
132
+ preserveAspectRatio: "xMidYMid meet",
133
+ width: "100%",
134
+ height: "100%",
135
+ className: "nice-chart__svg",
136
+ style: { display: "block", maxWidth: "100%", maxHeight: "100%" },
137
+ children: [
138
+ i && /* @__PURE__ */ e("text", { x: p / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: i }),
139
+ _ && Array.from({ length: W }, (F, A) => {
140
+ const K = (A + 1) / W * ne, ue = [];
141
+ for (let pe = 0; pe < le; pe++)
142
+ ue.push(`${N + Math.cos(de(pe)) * K},${G + Math.sin(de(pe)) * K}`);
143
+ return /* @__PURE__ */ e(
144
+ "polygon",
145
+ {
146
+ points: ue.join(" "),
147
+ fill: "none",
148
+ className: "nice-chart__grid-line"
149
+ },
150
+ A
151
+ );
152
+ }),
153
+ Array.from({ length: le }, (F, A) => {
154
+ const [K, ue] = n(A, ae);
155
+ return /* @__PURE__ */ e("line", { x1: N, y1: G, x2: K, y2: ue, className: "nice-chart__grid-line" }, A);
156
+ }),
157
+ C && U?.map((F, A) => {
158
+ const [K, ue] = n(A, ae * 1.12);
159
+ return /* @__PURE__ */ e(
160
+ "text",
161
+ {
162
+ x: K,
163
+ y: ue,
164
+ textAnchor: "middle",
165
+ dominantBaseline: "middle",
166
+ className: "nice-chart__axis-label",
167
+ children: F
168
+ },
169
+ A
170
+ );
171
+ }),
172
+ ee.map((F, A) => {
173
+ const K = F.color || Ce[A % Ce.length], ue = F.data.map((pe, ge) => n(ge, pe).join(",")).join(" ");
174
+ return /* @__PURE__ */ b(
175
+ "g",
176
+ {
177
+ className: w ? "nice-chart__series nice-chart__series--radar nice-chart__series--anim" : "nice-chart__series nice-chart__series--radar",
178
+ children: [
179
+ /* @__PURE__ */ e(
180
+ "polygon",
181
+ {
182
+ points: ue,
183
+ fill: K,
184
+ fillOpacity: 0.2,
185
+ stroke: K,
186
+ strokeWidth: 2
187
+ }
188
+ ),
189
+ F.data.map((pe, ge) => {
190
+ const [Ne, ke] = n(ge, pe);
191
+ return /* @__PURE__ */ e("circle", { cx: Ne, cy: ke, r: 3, fill: K, children: /* @__PURE__ */ e("title", { children: `${F.name}: ${pe}` }) }, ge);
192
+ })
193
+ ]
194
+ },
195
+ F.name
196
+ );
197
+ }),
198
+ v && /* @__PURE__ */ e("g", { transform: `translate(${E.left}, ${a})`, children: t.map((F, A) => {
199
+ const K = A * 120, ue = y.has(F.name);
200
+ return /* @__PURE__ */ b(
201
+ "g",
202
+ {
203
+ transform: `translate(${K}, 10)`,
204
+ style: l ? { cursor: "pointer" } : void 0,
205
+ onClick: () => X(F.name),
206
+ opacity: ue ? 0.35 : 1,
207
+ children: [
208
+ /* @__PURE__ */ e(
209
+ "rect",
210
+ {
211
+ width: 12,
212
+ height: 12,
213
+ rx: 2,
214
+ fill: F.color || Ce[A % Ce.length]
215
+ }
216
+ ),
217
+ /* @__PURE__ */ e("text", { x: 16, y: 10, className: "nice-chart__legend-text", children: F.name })
218
+ ]
219
+ },
220
+ F.name
221
+ );
222
+ }) })
223
+ ]
224
+ }
225
+ ) });
226
+ }
227
+ return /* @__PURE__ */ b("div", { className: `nice-chart ${z || ""}`, style: g, children: [
228
+ h && /* @__PURE__ */ e(
229
+ "button",
230
+ {
231
+ type: "button",
232
+ className: "nice-chart__export-btn",
233
+ onClick: $e,
234
+ title: "Export PNG",
235
+ "aria-label": "Export PNG",
236
+ children: /* @__PURE__ */ e(Me, { name: "camera", size: 16 })
237
+ }
238
+ ),
239
+ /* @__PURE__ */ b(
240
+ "svg",
241
+ {
242
+ ref: S,
243
+ viewBox: `0 0 ${p} ${_e}`,
244
+ preserveAspectRatio: "xMidYMid meet",
245
+ width: "100%",
246
+ height: "100%",
247
+ style: { display: "block", maxWidth: "100%", maxHeight: "100%" },
248
+ className: "nice-chart__svg",
249
+ onWheel: ce,
250
+ onMouseDown: j,
251
+ onMouseMove: se,
252
+ onMouseUp: fe,
253
+ onMouseLeave: be,
254
+ children: [
255
+ /* @__PURE__ */ b("g", { transform: `translate(${E.left},${E.top})`, children: [
256
+ i && /* @__PURE__ */ e("text", { x: Z / 2, y: -10, textAnchor: "middle", className: "nice-chart__title", children: i }),
257
+ _ && u.map((N) => /* @__PURE__ */ e(
258
+ "line",
259
+ {
260
+ x1: 0,
261
+ y1: s(N),
262
+ x2: Z,
263
+ y2: s(N),
264
+ className: "nice-chart__grid-line"
265
+ },
266
+ `grid-${N}`
267
+ )),
268
+ C && u.map((N) => /* @__PURE__ */ e(
269
+ "text",
270
+ {
271
+ x: -8,
272
+ y: s(N) + 4,
273
+ textAnchor: "end",
274
+ className: "nice-chart__axis-label",
275
+ children: N
276
+ },
277
+ `ylabel-${N}`
278
+ )),
279
+ C && U && U.map((N, G) => /* @__PURE__ */ e(
280
+ "text",
281
+ {
282
+ x: T(G),
283
+ y: H + 20,
284
+ textAnchor: "middle",
285
+ className: "nice-chart__axis-label",
286
+ children: N
287
+ },
288
+ G
289
+ )),
290
+ L && /* @__PURE__ */ e(
291
+ "text",
292
+ {
293
+ x: -E.left + 14,
294
+ y: H / 2,
295
+ textAnchor: "middle",
296
+ transform: `rotate(-90, -${E.left - 14}, ${H / 2})`,
297
+ className: "nice-chart__axis-title",
298
+ children: L
299
+ }
300
+ ),
301
+ k && /* @__PURE__ */ e("text", { x: Z / 2, y: H + 45, textAnchor: "middle", className: "nice-chart__axis-title", children: k }),
302
+ /* @__PURE__ */ e("line", { x1: 0, y1: 0, x2: 0, y2: H, className: "nice-chart__axis" }),
303
+ /* @__PURE__ */ e("line", { x1: 0, y1: H, x2: Z, y2: H, className: "nice-chart__axis" }),
304
+ $?.map((N, G) => {
305
+ if (N.type === "line") {
306
+ const ne = s(N.value);
307
+ return /* @__PURE__ */ b("g", { children: [
308
+ /* @__PURE__ */ e(
309
+ "line",
310
+ {
311
+ x1: 0,
312
+ y1: ne,
313
+ x2: Z,
314
+ y2: ne,
315
+ stroke: N.color || "var(--nice-color-error, #ef4444)",
316
+ strokeWidth: 1.5,
317
+ strokeDasharray: N.dash || "6,3"
318
+ }
319
+ ),
320
+ N.label && /* @__PURE__ */ e(
321
+ "text",
322
+ {
323
+ x: Z + 4,
324
+ y: ne + 4,
325
+ className: "nice-chart__annotation-label",
326
+ fill: N.color || "var(--nice-color-error, #ef4444)",
327
+ children: N.label
328
+ }
329
+ )
330
+ ] }, G);
331
+ }
332
+ return /* @__PURE__ */ e(
333
+ "text",
334
+ {
335
+ x: T(N.value),
336
+ y: -4,
337
+ textAnchor: "middle",
338
+ className: "nice-chart__annotation-label",
339
+ fill: N.color || "var(--nice-text-muted, #6b7280)",
340
+ children: N.label
341
+ },
342
+ G
343
+ );
344
+ }),
345
+ I && r && r.x >= 0 && r.x <= Z && r.y >= 0 && r.y <= H && /* @__PURE__ */ b(Ye, { children: [
346
+ /* @__PURE__ */ e(
347
+ "line",
348
+ {
349
+ x1: r.x,
350
+ y1: 0,
351
+ x2: r.x,
352
+ y2: H,
353
+ stroke: "var(--nice-text-muted, #9ca3af)",
354
+ strokeWidth: 1,
355
+ strokeDasharray: "4,2"
356
+ }
357
+ ),
358
+ /* @__PURE__ */ e(
359
+ "line",
360
+ {
361
+ x1: 0,
362
+ y1: r.y,
363
+ x2: Z,
364
+ y2: r.y,
365
+ stroke: "var(--nice-text-muted, #9ca3af)",
366
+ strokeWidth: 1,
367
+ strokeDasharray: "4,2"
368
+ }
369
+ )
370
+ ] }),
371
+ ee.map((N, G) => {
372
+ const ne = N.color || Ce[G % Ce.length], le = N.type || "bar";
373
+ if (le === "bar")
374
+ return /* @__PURE__ */ e(
375
+ "g",
376
+ {
377
+ className: w ? "nice-chart__series nice-chart__series--bar nice-chart__series--anim" : "nice-chart__series nice-chart__series--bar",
378
+ children: N.data.map((n, W) => {
379
+ let F, A;
380
+ if (m) {
381
+ const ue = ee.slice(0, G).reduce((pe, ge) => pe + (ge.data[W] || 0), 0);
382
+ F = s(ue + n), A = s(ue) - F;
383
+ } else
384
+ F = s(Math.max(0, n)), A = Math.abs(s(n) - s(0));
385
+ const K = m ? T(W) - te / 2 : T(W) - ee.length * te / 2 + G * te;
386
+ return /* @__PURE__ */ e(
387
+ "rect",
388
+ {
389
+ x: K,
390
+ y: F,
391
+ width: te * 0.9,
392
+ height: Math.max(0, A),
393
+ fill: ne,
394
+ rx: 2,
395
+ style: {
396
+ transformOrigin: `${K + te * 0.9 / 2}px ${s(0)}px`,
397
+ ...o ? { cursor: "pointer" } : {}
398
+ },
399
+ onClick: o ? () => o(N.name, f + W, n) : void 0,
400
+ children: /* @__PURE__ */ e("title", { children: `${N.name}: ${n}` })
401
+ },
402
+ W
403
+ );
404
+ })
405
+ },
406
+ N.name
407
+ );
408
+ if (le === "scatter")
409
+ return /* @__PURE__ */ e(
410
+ "g",
411
+ {
412
+ className: w ? "nice-chart__series nice-chart__series--scatter nice-chart__series--anim" : "nice-chart__series nice-chart__series--scatter",
413
+ children: N.data.map((n, W) => /* @__PURE__ */ e(
414
+ "circle",
415
+ {
416
+ cx: T(W),
417
+ cy: s(n),
418
+ r: 5,
419
+ fill: ne,
420
+ fillOpacity: 0.7,
421
+ stroke: ne,
422
+ strokeWidth: 1.5,
423
+ style: o ? { cursor: "pointer" } : void 0,
424
+ onClick: o ? () => o(N.name, f + W, n) : void 0,
425
+ children: /* @__PURE__ */ e("title", { children: `${N.name}: ${n}` })
426
+ },
427
+ W
428
+ ))
429
+ },
430
+ N.name
431
+ );
432
+ const de = N.data.map((n, W) => `${T(W)},${s(n)}`);
433
+ return /* @__PURE__ */ b(
434
+ "g",
435
+ {
436
+ className: w ? `nice-chart__series nice-chart__series--${le} nice-chart__series--anim` : `nice-chart__series nice-chart__series--${le}`,
437
+ children: [
438
+ le === "area" && Q > 0 && /* @__PURE__ */ e(
439
+ "polygon",
440
+ {
441
+ points: `${T(0)},${s(0)} ${de.join(" ")} ${T(Q - 1)},${s(0)}`,
442
+ fill: ne,
443
+ opacity: 0.15
444
+ }
445
+ ),
446
+ /* @__PURE__ */ e(
447
+ "polyline",
448
+ {
449
+ points: de.join(" "),
450
+ fill: "none",
451
+ stroke: ne,
452
+ strokeWidth: 2,
453
+ className: w ? "nice-chart__line" : void 0
454
+ }
455
+ ),
456
+ N.data.map((n, W) => /* @__PURE__ */ e(
457
+ "circle",
458
+ {
459
+ cx: T(W),
460
+ cy: s(n),
461
+ r: 3,
462
+ fill: ne,
463
+ style: o ? { cursor: "pointer" } : void 0,
464
+ onClick: o ? () => o(N.name, f + W, n) : void 0,
465
+ children: /* @__PURE__ */ e("title", { children: `${N.name}: ${n}` })
466
+ },
467
+ W
468
+ ))
469
+ ]
470
+ },
471
+ N.name
472
+ );
473
+ })
474
+ ] }),
475
+ v && /* @__PURE__ */ e("g", { transform: `translate(${E.left}, ${a})`, children: t.map((N, G) => {
476
+ const ne = G * 120, le = y.has(N.name);
477
+ return /* @__PURE__ */ b(
478
+ "g",
479
+ {
480
+ transform: `translate(${ne}, 10)`,
481
+ style: l ? { cursor: "pointer" } : void 0,
482
+ onClick: () => X(N.name),
483
+ opacity: le ? 0.35 : 1,
484
+ children: [
485
+ /* @__PURE__ */ e("rect", { width: 12, height: 12, rx: 2, fill: N.color || Ce[G % Ce.length] }),
486
+ /* @__PURE__ */ e(
487
+ "text",
488
+ {
489
+ x: 16,
490
+ y: 10,
491
+ className: "nice-chart__legend-text",
492
+ style: le ? { textDecoration: "line-through" } : void 0,
493
+ children: N.name
494
+ }
495
+ )
496
+ ]
497
+ },
498
+ N.name
499
+ );
500
+ }) })
501
+ ]
502
+ }
503
+ )
504
+ ] });
505
+ }, yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
506
+ __proto__: null,
507
+ NiceChart: Pe
508
+ }, Symbol.toStringTag, { value: "Module" })), bt = ({
509
+ value: t,
510
+ min: c = 0,
511
+ max: p = 100,
512
+ width: a = 200,
513
+ height: i = 200,
514
+ startAngle: v = 225,
515
+ endAngle: _ = -45,
516
+ color: C = "var(--nice-color-primary, #3b82f6)",
517
+ trackColor: L,
518
+ label: k,
519
+ formatValue: m,
520
+ ranges: w,
521
+ className: R,
522
+ style: I
523
+ }) => {
524
+ const $ = a / 2, l = i / 2, o = Math.min($, l) - 20, h = Math.max(0, Math.min(1, (t - c) / (p - c || 1))), z = (d) => d * Math.PI / 180, g = (v - _ + 360) % 360 || 360, S = (d) => ({
525
+ x: $ + o * Math.cos(z(d)),
526
+ y: l - o * Math.sin(z(d))
527
+ }), y = (d, M) => {
528
+ const x = S(d), O = S(M), V = (d - M + 360) % 360 > 180 ? 1 : 0;
529
+ return `M${x.x},${x.y} A${o},${o} 0 ${V},1 ${O.x},${O.y}`;
530
+ }, D = v - h * g, r = S(D);
531
+ let B = C;
532
+ if (w) {
533
+ for (const d of w)
534
+ if (t >= d.start && t <= d.end) {
535
+ B = d.color;
536
+ break;
537
+ }
538
+ }
539
+ return /* @__PURE__ */ e("div", { className: `nice-gauge nice-gauge--circular ${R || ""}`, style: I, children: /* @__PURE__ */ b("svg", { width: a, height: i, children: [
540
+ /* @__PURE__ */ e(
541
+ "path",
542
+ {
543
+ d: y(v, _),
544
+ fill: "none",
545
+ stroke: L || "var(--nice-border-color, #e2e8f0)",
546
+ strokeWidth: 12,
547
+ strokeLinecap: "round"
548
+ }
549
+ ),
550
+ h > 0 && /* @__PURE__ */ e(
551
+ "path",
552
+ {
553
+ d: y(v, D),
554
+ fill: "none",
555
+ stroke: B,
556
+ strokeWidth: 12,
557
+ strokeLinecap: "round"
558
+ }
559
+ ),
560
+ /* @__PURE__ */ e(
561
+ "line",
562
+ {
563
+ x1: $,
564
+ y1: l,
565
+ x2: r.x,
566
+ y2: r.y,
567
+ stroke: "var(--nice-text-primary, #333)",
568
+ strokeWidth: 2,
569
+ strokeLinecap: "round"
570
+ }
571
+ ),
572
+ /* @__PURE__ */ e("circle", { cx: $, cy: l, r: 4, fill: "var(--nice-text-primary, #333)" }),
573
+ /* @__PURE__ */ e("text", { x: $, y: l + o * 0.6, textAnchor: "middle", className: "nice-gauge__value", children: m ? m(t) : t }),
574
+ k && /* @__PURE__ */ e("text", { x: $, y: l + o * 0.95, textAnchor: "middle", className: "nice-gauge__label", children: k })
575
+ ] }) });
576
+ }, _t = ({
577
+ value: t,
578
+ min: c = 0,
579
+ max: p = 100,
580
+ width: a = 300,
581
+ height: i = 60,
582
+ orientation: v = "horizontal",
583
+ color: _ = "var(--nice-color-primary, #3b82f6)",
584
+ label: C,
585
+ formatValue: L,
586
+ ranges: k,
587
+ showTicks: m = !0,
588
+ tickCount: w = 5,
589
+ className: R,
590
+ style: I
591
+ }) => {
592
+ const $ = v === "horizontal", l = $ ? a - 40 : i - 40, o = Math.max(0, Math.min(1, (t - c) / (p - c || 1))), h = 10;
593
+ let z = _;
594
+ if (k) {
595
+ for (const S of k)
596
+ if (t >= S.start && t <= S.end) {
597
+ z = S.color;
598
+ break;
599
+ }
600
+ }
601
+ const g = Array.from(
602
+ { length: w },
603
+ (S, y) => c + (p - c) * (y / (w - 1))
604
+ );
605
+ return $ ? /* @__PURE__ */ e("div", { className: `nice-gauge nice-gauge--linear ${R || ""}`, style: I, children: /* @__PURE__ */ b("svg", { width: a, height: i, children: [
606
+ /* @__PURE__ */ e(
607
+ "text",
608
+ {
609
+ x: 20 + l * o,
610
+ y: 14,
611
+ textAnchor: "middle",
612
+ className: "nice-gauge__value",
613
+ style: { fontSize: 12 },
614
+ children: L ? L(t) : t
615
+ }
616
+ ),
617
+ /* @__PURE__ */ e(
618
+ "rect",
619
+ {
620
+ x: 20,
621
+ y: i / 2 - h / 2,
622
+ width: l,
623
+ height: h,
624
+ rx: 5,
625
+ fill: "var(--nice-border-color, #e2e8f0)"
626
+ }
627
+ ),
628
+ /* @__PURE__ */ e(
629
+ "rect",
630
+ {
631
+ x: 20,
632
+ y: i / 2 - h / 2,
633
+ width: l * o,
634
+ height: h,
635
+ rx: 5,
636
+ fill: z
637
+ }
638
+ ),
639
+ /* @__PURE__ */ e(
640
+ "polygon",
641
+ {
642
+ points: `${20 + l * o},${i / 2 - h / 2 - 2} ${20 + l * o - 5},${i / 2 - h / 2 - 8} ${20 + l * o + 5},${i / 2 - h / 2 - 8}`,
643
+ fill: "var(--nice-text-primary, #333)"
644
+ }
645
+ ),
646
+ m && g.map((S, y) => {
647
+ const D = 20 + (S - c) / (p - c) * l;
648
+ return /* @__PURE__ */ e(
649
+ "text",
650
+ {
651
+ x: D,
652
+ y: i / 2 + h / 2 + 12,
653
+ textAnchor: "middle",
654
+ className: "nice-gauge__tick",
655
+ children: S
656
+ },
657
+ y
658
+ );
659
+ }),
660
+ C && /* @__PURE__ */ e("text", { x: a / 2, y: i - 2, textAnchor: "middle", className: "nice-gauge__label", children: C })
661
+ ] }) }) : /* @__PURE__ */ e(
662
+ "div",
663
+ {
664
+ className: `nice-gauge nice-gauge--linear nice-gauge--vertical ${R || ""}`,
665
+ style: I,
666
+ children: /* @__PURE__ */ b("svg", { width: a, height: i, children: [
667
+ /* @__PURE__ */ e(
668
+ "rect",
669
+ {
670
+ x: a / 2 - h / 2,
671
+ y: 20,
672
+ width: h,
673
+ height: l,
674
+ rx: 5,
675
+ fill: "var(--nice-border-color, #e2e8f0)"
676
+ }
677
+ ),
678
+ /* @__PURE__ */ e(
679
+ "rect",
680
+ {
681
+ x: a / 2 - h / 2,
682
+ y: 20 + l * (1 - o),
683
+ width: h,
684
+ height: l * o,
685
+ rx: 5,
686
+ fill: z
687
+ }
688
+ ),
689
+ /* @__PURE__ */ e("text", { x: a / 2, y: 14, textAnchor: "middle", className: "nice-gauge__value", children: L ? L(t) : t }),
690
+ C && /* @__PURE__ */ e("text", { x: a / 2, y: i - 4, textAnchor: "middle", className: "nice-gauge__label", children: C })
691
+ ] })
692
+ }
693
+ );
694
+ }, we = [
695
+ "#3b82f6",
696
+ "#ef4444",
697
+ "#22c55e",
698
+ "#f59e0b",
699
+ "#8b5cf6",
700
+ "#ec4899",
701
+ "#06b6d4",
702
+ "#84cc16"
703
+ ], wt = ({
704
+ items: t,
705
+ min: c = 0,
706
+ max: p = 100,
707
+ width: a = 300,
708
+ height: i = 300,
709
+ startAngle: v = 225,
710
+ endAngle: _ = -45,
711
+ formatValue: C,
712
+ title: L,
713
+ className: k,
714
+ style: m
715
+ }) => {
716
+ const w = a / 2, R = i / 2, I = Math.min(w, R) - 30, $ = Math.min(20, I / (t.length + 1)), l = 4, o = (g) => g * Math.PI / 180, h = (v - _ + 360) % 360 || 360, z = (g, S, y) => {
717
+ const D = w + g * Math.cos(o(S)), r = R - g * Math.sin(o(S)), B = w + g * Math.cos(o(y)), d = R - g * Math.sin(o(y)), M = (S - y + 360) % 360;
718
+ return `M${D},${r} A${g},${g} 0 ${M > 180 ? 1 : 0},1 ${B},${d}`;
719
+ };
720
+ return /* @__PURE__ */ e("div", { className: `nice-bargauge ${k || ""}`, style: m, children: /* @__PURE__ */ b("svg", { width: a, height: i, children: [
721
+ L && /* @__PURE__ */ e("text", { x: w, y: 20, textAnchor: "middle", className: "nice-chart__title", children: L }),
722
+ t.map((g, S) => {
723
+ const y = I - S * ($ + l), D = Math.max(0, Math.min(1, (g.value - c) / (p - c || 1))), r = v - D * h, B = g.color || we[S % we.length];
724
+ return /* @__PURE__ */ b("g", { children: [
725
+ /* @__PURE__ */ e(
726
+ "path",
727
+ {
728
+ d: z(y, v, _),
729
+ fill: "none",
730
+ stroke: "var(--nice-border-color, #e2e8f0)",
731
+ strokeWidth: $,
732
+ strokeLinecap: "round"
733
+ }
734
+ ),
735
+ D > 0 && /* @__PURE__ */ e(
736
+ "path",
737
+ {
738
+ d: z(y, v, r),
739
+ fill: "none",
740
+ stroke: B,
741
+ strokeWidth: $,
742
+ strokeLinecap: "round"
743
+ }
744
+ )
745
+ ] }, S);
746
+ }),
747
+ /* @__PURE__ */ e("g", { children: t.map((g, S) => /* @__PURE__ */ b(
748
+ "text",
749
+ {
750
+ x: w,
751
+ y: R - ((t.length - 1) / 2 - S) * 16,
752
+ textAnchor: "middle",
753
+ dominantBaseline: "middle",
754
+ className: "nice-gauge__value",
755
+ style: { fontSize: 12 },
756
+ children: [
757
+ g.label ? `${g.label}: ` : "",
758
+ C ? C(g.value) : g.value
759
+ ]
760
+ },
761
+ S
762
+ )) })
763
+ ] }) });
764
+ }, Je = {
765
+ sm: { width: 160, height: 22, fontSize: 11 },
766
+ md: { width: 220, height: 32, fontSize: 12 },
767
+ lg: { width: 320, height: 44, fontSize: 14 }
768
+ }, $t = ({
769
+ value: t,
770
+ target: c,
771
+ min: p = 0,
772
+ max: a = 100,
773
+ width: i,
774
+ height: v,
775
+ color: _ = "var(--nice-color-primary, #3b82f6)",
776
+ targetColor: C = "var(--nice-color-error, #ef4444)",
777
+ size: L = "md",
778
+ label: k,
779
+ labelPlacement: m = "top",
780
+ showValue: w = !1,
781
+ showTarget: R = !1,
782
+ formatValue: I = (z) => String(z),
783
+ state: $ = "normal",
784
+ errorMessage: l,
785
+ className: o,
786
+ style: h
787
+ }) => {
788
+ const z = Je[L], g = i ?? z.width, S = v ?? z.height, y = z.fontSize, D = 4, r = g - D * 2, B = R && c != null ? y + 4 : D, d = R && c != null ? S + (B - D) : S, M = d - B - D, x = Math.max(0, Math.min(1, (t - p) / (a - p || 1))), O = c != null ? Math.max(0, Math.min(1, (c - p) / (a - p || 1))) : null, Y = () => $ === "error" ? /* @__PURE__ */ e(
789
+ "div",
790
+ {
791
+ role: "alert",
792
+ style: {
793
+ width: g,
794
+ height: d,
795
+ display: "flex",
796
+ alignItems: "center",
797
+ justifyContent: "center",
798
+ border: "1px dashed var(--nice-color-error, #ef4444)",
799
+ borderRadius: 4,
800
+ color: "var(--nice-color-error, #ef4444)",
801
+ fontSize: y,
802
+ padding: "0 8px",
803
+ boxSizing: "border-box"
804
+ },
805
+ children: l ?? "Error"
806
+ }
807
+ ) : $ === "loading" ? /* @__PURE__ */ e(
808
+ "div",
809
+ {
810
+ role: "status",
811
+ "aria-label": "Loading",
812
+ className: "nice-bullet__skeleton",
813
+ style: {
814
+ width: g,
815
+ height: d,
816
+ borderRadius: 4,
817
+ background: "linear-gradient(90deg, var(--nice-bg-tertiary, #e5e7eb) 25%, var(--nice-bg-secondary, #f3f4f6) 50%, var(--nice-bg-tertiary, #e5e7eb) 75%)",
818
+ backgroundSize: "200% 100%",
819
+ animation: "nice-bullet-shimmer 1.4s linear infinite"
820
+ }
821
+ }
822
+ ) : /* @__PURE__ */ b(
823
+ "svg",
824
+ {
825
+ width: g,
826
+ height: d,
827
+ role: "img",
828
+ "aria-label": typeof k == "string" ? k : void 0,
829
+ children: [
830
+ /* @__PURE__ */ e(
831
+ "rect",
832
+ {
833
+ x: D,
834
+ y: B,
835
+ width: r,
836
+ height: M,
837
+ rx: 3,
838
+ fill: "var(--nice-border-color, #e2e8f0)"
839
+ }
840
+ ),
841
+ /* @__PURE__ */ e(
842
+ "rect",
843
+ {
844
+ x: D,
845
+ y: B + M * 0.2,
846
+ width: r * x,
847
+ height: M * 0.6,
848
+ rx: 2,
849
+ fill: _
850
+ }
851
+ ),
852
+ O != null && /* @__PURE__ */ e(
853
+ "line",
854
+ {
855
+ x1: D + r * O,
856
+ y1: B + 2,
857
+ x2: D + r * O,
858
+ y2: B + M - 2,
859
+ stroke: C,
860
+ strokeWidth: 2
861
+ }
862
+ ),
863
+ w && /* @__PURE__ */ e(
864
+ "text",
865
+ {
866
+ x: D + Math.max(r * x, 4),
867
+ y: B + M / 2,
868
+ dx: r * x > 24 ? -4 : 4,
869
+ textAnchor: r * x > 24 ? "end" : "start",
870
+ dominantBaseline: "middle",
871
+ fontSize: y,
872
+ fill: r * x > 24 ? "var(--nice-text-on-primary, #ffffff)" : "var(--nice-text-primary)",
873
+ fontWeight: 600,
874
+ children: I(t)
875
+ }
876
+ ),
877
+ R && O != null && /* @__PURE__ */ e(
878
+ "text",
879
+ {
880
+ x: D + r * O,
881
+ y: B - 2,
882
+ textAnchor: "middle",
883
+ fontSize: y - 1,
884
+ fill: C,
885
+ fontWeight: 600,
886
+ children: I(c)
887
+ }
888
+ )
889
+ ]
890
+ }
891
+ );
892
+ if (m === "none" || !k)
893
+ return /* @__PURE__ */ b("div", { className: `nice-bullet ${o || ""}`, style: h, children: [
894
+ Y(),
895
+ /* @__PURE__ */ e("style", { children: We })
896
+ ] });
897
+ const V = m === "top" || m === "bottom", X = /* @__PURE__ */ e(
898
+ "span",
899
+ {
900
+ className: "nice-bullet__label",
901
+ style: {
902
+ fontSize: y,
903
+ fontWeight: 600,
904
+ color: "var(--nice-text-primary)",
905
+ ...V ? {
906
+ marginBottom: m === "top" ? 4 : 0,
907
+ marginTop: m === "bottom" ? 4 : 0
908
+ } : {},
909
+ ...m === "left" ? { marginRight: 8 } : {},
910
+ ...m === "right" ? { marginLeft: 8 } : {}
911
+ },
912
+ children: k
913
+ }
914
+ );
915
+ return /* @__PURE__ */ b(
916
+ "div",
917
+ {
918
+ className: `nice-bullet nice-bullet--${m} ${o || ""}`,
919
+ style: {
920
+ display: "inline-flex",
921
+ flexDirection: V ? "column" : "row",
922
+ alignItems: V ? "flex-start" : "center",
923
+ ...h
924
+ },
925
+ children: [
926
+ (m === "top" || m === "left") && X,
927
+ Y(),
928
+ (m === "bottom" || m === "right") && X,
929
+ /* @__PURE__ */ e("style", { children: We })
930
+ ]
931
+ }
932
+ );
933
+ }, We = `
934
+ @keyframes nice-bullet-shimmer {
935
+ 0% { background-position: 200% 0; }
936
+ 100% { background-position: -200% 0; }
937
+ }
938
+ `, Mt = ({
939
+ data: t,
940
+ width: c = 400,
941
+ height: p = 400,
942
+ innerRadius: a = 0,
943
+ title: i,
944
+ showLegend: v = !0,
945
+ showLabels: _ = !0,
946
+ className: C,
947
+ style: L
948
+ }) => {
949
+ const k = c / 2, m = (p - (v ? 30 : 0)) / 2 + (i ? 10 : 0), w = Math.min(k, m) - 40, R = t.reduce((l, o) => l + o.value, 0);
950
+ let I = -Math.PI / 2;
951
+ const $ = t.map((l, o) => {
952
+ const h = l.value / (R || 1) * Math.PI * 2, z = I;
953
+ I += h;
954
+ const g = I, S = (z + g) / 2, y = k + w * Math.cos(z), D = m + w * Math.sin(z), r = k + w * Math.cos(g), B = m + w * Math.sin(g), d = h > Math.PI ? 1 : 0, M = l.color || we[o % we.length], x = h >= Math.PI * 2 - 1e-9;
955
+ let O;
956
+ if (x) {
957
+ const E = (Z, H) => `M${k - Z},${m} A${Z},${Z} 0 1,${H} ${k + Z},${m} A${Z},${Z} 0 1,${H} ${k - Z},${m} Z`;
958
+ O = a > 0 ? `${E(w, 1)} ${E(a, 0)}` : E(w, 1);
959
+ } else if (a > 0) {
960
+ const E = k + a * Math.cos(z), Z = m + a * Math.sin(z), H = k + a * Math.cos(g), J = m + a * Math.sin(g);
961
+ O = `M${y},${D} A${w},${w} 0 ${d},1 ${r},${B} L${H},${J} A${a},${a} 0 ${d},0 ${E},${Z} Z`;
962
+ } else
963
+ O = `M${k},${m} L${y},${D} A${w},${w} 0 ${d},1 ${r},${B} Z`;
964
+ const Y = x ? k : k + w * 0.7 * Math.cos(S), V = x ? m : m + w * 0.7 * Math.sin(S), X = R > 0 ? Math.round(l.value / R * 100) : 0;
965
+ return { ...l, path: O, labelX: Y, labelY: V, pct: X, color: M };
966
+ });
967
+ return /* @__PURE__ */ e("div", { className: `nice-piechart ${C || ""}`, style: L, children: /* @__PURE__ */ b(
968
+ "svg",
969
+ {
970
+ viewBox: `0 0 ${c} ${p}`,
971
+ preserveAspectRatio: "xMidYMid meet",
972
+ width: "100%",
973
+ height: "100%",
974
+ style: { display: "block", maxWidth: "100%", maxHeight: "100%" },
975
+ className: "nice-piechart__svg",
976
+ children: [
977
+ i && /* @__PURE__ */ e("text", { x: k, y: 20, textAnchor: "middle", className: "nice-chart__title", children: i }),
978
+ $.map((l, o) => /* @__PURE__ */ b("g", { children: [
979
+ /* @__PURE__ */ e("path", { d: l.path, fill: l.color, stroke: "var(--nice-bg-primary, #fff)", strokeWidth: 2, children: /* @__PURE__ */ e("title", { children: `${l.label}: ${l.value} (${l.pct}%)` }) }),
980
+ _ && l.pct >= 5 && /* @__PURE__ */ b(
981
+ "text",
982
+ {
983
+ x: l.labelX,
984
+ y: l.labelY,
985
+ textAnchor: "middle",
986
+ dominantBaseline: "middle",
987
+ className: "nice-piechart__label",
988
+ children: [
989
+ l.pct,
990
+ "%"
991
+ ]
992
+ }
993
+ )
994
+ ] }, o)),
995
+ v && /* @__PURE__ */ e("g", { transform: `translate(10, ${p - 25})`, children: t.map((l, o) => /* @__PURE__ */ b("g", { transform: `translate(${o * 100}, 0)`, children: [
996
+ /* @__PURE__ */ e("rect", { width: 10, height: 10, rx: 2, fill: l.color || we[o % we.length] }),
997
+ /* @__PURE__ */ e("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: l.label })
998
+ ] }, o)) })
999
+ ]
1000
+ }
1001
+ ) });
1002
+ }, Nt = ({
1003
+ data: t,
1004
+ width: c = 400,
1005
+ height: p = 300,
1006
+ inverted: a,
1007
+ showLabels: i = !0,
1008
+ showValues: v = !0,
1009
+ title: _,
1010
+ className: C,
1011
+ style: L
1012
+ }) => {
1013
+ const k = { top: _ ? 30 : 10, bottom: 10, x: 40 }, m = c - k.x * 2, w = p - k.top - k.bottom, R = a ? [...t].reverse() : t, I = Math.max(...R.map((l) => l.value), 1), $ = w / R.length;
1014
+ return /* @__PURE__ */ e("div", { className: `nice-funnel ${C || ""}`, style: L, children: /* @__PURE__ */ b("svg", { width: c, height: p, children: [
1015
+ _ && /* @__PURE__ */ e("text", { x: c / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: _ }),
1016
+ R.map((l, o) => {
1017
+ const h = l.value / I * m, z = o < R.length - 1 ? R[o + 1].value / I * m : h * 0.3, g = k.top + o * $, S = g + $, y = c / 2, D = `${y - h / 2},${g} ${y + h / 2},${g} ${y + z / 2},${S} ${y - z / 2},${S}`, r = l.color || we[o % we.length];
1018
+ return /* @__PURE__ */ b("g", { children: [
1019
+ /* @__PURE__ */ e(
1020
+ "polygon",
1021
+ {
1022
+ points: D,
1023
+ fill: r,
1024
+ stroke: "var(--nice-bg-primary, #fff)",
1025
+ strokeWidth: 1,
1026
+ children: /* @__PURE__ */ e("title", { children: `${l.label}: ${l.value}` })
1027
+ }
1028
+ ),
1029
+ i && /* @__PURE__ */ e(
1030
+ "text",
1031
+ {
1032
+ x: y,
1033
+ y: g + $ / 2 - (v ? 4 : 0),
1034
+ textAnchor: "middle",
1035
+ dominantBaseline: "middle",
1036
+ className: "nice-funnel__label",
1037
+ children: l.label
1038
+ }
1039
+ ),
1040
+ v && /* @__PURE__ */ e(
1041
+ "text",
1042
+ {
1043
+ x: y,
1044
+ y: g + $ / 2 + 10,
1045
+ textAnchor: "middle",
1046
+ dominantBaseline: "middle",
1047
+ className: "nice-funnel__value",
1048
+ children: l.value
1049
+ }
1050
+ )
1051
+ ] }, o);
1052
+ })
1053
+ ] }) });
1054
+ };
1055
+ function Ke(t, c, p) {
1056
+ const a = (I) => {
1057
+ const $ = I.replace("#", "");
1058
+ return [
1059
+ parseInt($.slice(0, 2), 16),
1060
+ parseInt($.slice(2, 4), 16),
1061
+ parseInt($.slice(4, 6), 16)
1062
+ ];
1063
+ }, [i, v, _] = a(t), [C, L, k] = a(c), m = Math.round(i + (C - i) * p), w = Math.round(v + (L - v) * p), R = Math.round(_ + (k - _) * p);
1064
+ return `rgb(${m},${w},${R})`;
1065
+ }
1066
+ const Qe = Se(
1067
+ ({
1068
+ data: t,
1069
+ xLabels: c,
1070
+ yLabels: p,
1071
+ colors: a = ["var(--nice-primary-bg, #e0f2fe)", "var(--nice-color-primary-active, #1d4ed8)"],
1072
+ onCellClick: i,
1073
+ cellSize: v = 40,
1074
+ showValues: _ = !0,
1075
+ className: C,
1076
+ style: L,
1077
+ id: k
1078
+ }, m) => {
1079
+ const w = Le(k), { minVal: R, maxVal: I } = me(() => {
1080
+ let l = 1 / 0, o = -1 / 0;
1081
+ for (const h of t)
1082
+ for (const z of h)
1083
+ z < l && (l = z), z > o && (o = z);
1084
+ return { minVal: l, maxVal: o };
1085
+ }, [t]), $ = ie(
1086
+ (l) => I === R ? 0.5 : (l - R) / (I - R),
1087
+ [R, I]
1088
+ );
1089
+ return /* @__PURE__ */ e("div", { ref: m, id: w, className: `nice-heatmap ${C || ""}`, style: L, children: /* @__PURE__ */ b("table", { className: "nice-heatmap__table", children: [
1090
+ c && /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ b("tr", { children: [
1091
+ p && /* @__PURE__ */ e("th", {}),
1092
+ c.map((l, o) => /* @__PURE__ */ e("th", { className: "nice-heatmap__header", children: l }, o))
1093
+ ] }) }),
1094
+ /* @__PURE__ */ e("tbody", { children: t.map((l, o) => /* @__PURE__ */ b("tr", { children: [
1095
+ p && /* @__PURE__ */ e("th", { className: "nice-heatmap__row-label", children: p[o] }),
1096
+ l.map((h, z) => /* @__PURE__ */ e(
1097
+ "td",
1098
+ {
1099
+ className: "nice-heatmap__cell",
1100
+ style: {
1101
+ background: Ke(a[0], a[1], $(h)),
1102
+ width: v,
1103
+ height: v,
1104
+ textAlign: "center",
1105
+ color: $(h) > 0.6 ? "var(--nice-text-on-primary, #fff)" : "var(--nice-text-primary, #333)",
1106
+ cursor: i ? "pointer" : void 0
1107
+ },
1108
+ onClick: () => i?.(o, z, h),
1109
+ title: String(h),
1110
+ children: _ ? h : ""
1111
+ },
1112
+ z
1113
+ ))
1114
+ ] }, o)) })
1115
+ ] }) });
1116
+ }
1117
+ );
1118
+ Qe.displayName = "NiceHeatMap";
1119
+ const et = ({
1120
+ nodes: t,
1121
+ links: c,
1122
+ width: p = 600,
1123
+ height: a = 400,
1124
+ nodeWidth: i = 20,
1125
+ nodePadding: v = 10,
1126
+ title: _,
1127
+ className: C,
1128
+ style: L
1129
+ }) => {
1130
+ const k = { top: _ ? 40 : 20, bottom: 20, left: 20, right: 20 }, m = p - k.left - k.right, w = a - k.top - k.bottom, R = new Set(c.map((d) => d.source)), I = new Set(c.map((d) => d.target)), $ = t.filter((d) => R.has(d.id) && !I.has(d.id)), l = t.filter((d) => I.has(d.id)), o = t.filter((d) => R.has(d.id) && I.has(d.id)), h = [$, ...o.length ? [o] : [], l].filter(
1131
+ (d) => d.length > 0
1132
+ ), z = h.length, g = /* @__PURE__ */ new Map();
1133
+ t.forEach((d) => {
1134
+ const M = c.filter((O) => O.source === d.id).reduce((O, Y) => O + Y.value, 0), x = c.filter((O) => O.target === d.id).reduce((O, Y) => O + Y.value, 0);
1135
+ g.set(d.id, Math.max(M, x));
1136
+ });
1137
+ const S = h.map(
1138
+ (d) => d.reduce((M, x) => M + (g.get(x.id) || 0), 0) + (d.length - 1) * v
1139
+ ), y = Math.max(...S, 1), D = /* @__PURE__ */ new Map();
1140
+ h.forEach((d, M) => {
1141
+ const x = k.left + M / (z - 1 || 1) * (m - i);
1142
+ let O = 0;
1143
+ d.forEach((Y) => {
1144
+ const V = (g.get(Y.id) || 0) / y * w;
1145
+ D.set(Y.id, { x, y: k.top + O, h: V }), O += V + v;
1146
+ });
1147
+ });
1148
+ const r = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
1149
+ return t.forEach((d) => {
1150
+ r.set(d.id, 0), B.set(d.id, 0);
1151
+ }), /* @__PURE__ */ e("div", { className: `nice-sankey ${C || ""}`, style: L, children: /* @__PURE__ */ b("svg", { width: p, height: a, children: [
1152
+ _ && /* @__PURE__ */ e("text", { x: p / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: _ }),
1153
+ c.map((d, M) => {
1154
+ const x = D.get(d.source), O = D.get(d.target);
1155
+ if (!x || !O)
1156
+ return null;
1157
+ const Y = r.get(d.source) || 0, V = B.get(d.target) || 0, X = d.value / y * w;
1158
+ r.set(d.source, Y + X), B.set(d.target, V + X);
1159
+ const E = x.x + i, Z = x.y + Y, H = O.x, J = O.y + V, f = (E + H) / 2, Q = t.find((ee) => ee.id === d.source)?.color || we[M % we.length];
1160
+ return /* @__PURE__ */ e(
1161
+ "path",
1162
+ {
1163
+ d: `M${E},${Z} C${f},${Z} ${f},${J} ${H},${J} L${H},${J + X} C${f},${J + X} ${f},${Z + X} ${E},${Z + X} Z`,
1164
+ fill: Q,
1165
+ fillOpacity: 0.3,
1166
+ stroke: Q,
1167
+ strokeOpacity: 0.5,
1168
+ strokeWidth: 0.5,
1169
+ children: /* @__PURE__ */ e("title", { children: `${d.source} → ${d.target}: ${d.value}` })
1170
+ },
1171
+ M
1172
+ );
1173
+ }),
1174
+ t.map((d, M) => {
1175
+ const x = D.get(d.id);
1176
+ if (!x)
1177
+ return null;
1178
+ const O = d.color || we[M % we.length];
1179
+ return /* @__PURE__ */ b("g", { children: [
1180
+ /* @__PURE__ */ e(
1181
+ "rect",
1182
+ {
1183
+ x: x.x,
1184
+ y: x.y,
1185
+ width: i,
1186
+ height: Math.max(x.h, 2),
1187
+ fill: O,
1188
+ rx: 2
1189
+ }
1190
+ ),
1191
+ /* @__PURE__ */ e(
1192
+ "text",
1193
+ {
1194
+ x: x.x < m / 2 ? x.x + i + 4 : x.x - 4,
1195
+ y: x.y + x.h / 2,
1196
+ textAnchor: x.x < m / 2 ? "start" : "end",
1197
+ dominantBaseline: "middle",
1198
+ className: "nice-chart__legend-text",
1199
+ children: d.label
1200
+ }
1201
+ )
1202
+ ] }, d.id);
1203
+ })
1204
+ ] }) });
1205
+ }, kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1206
+ __proto__: null,
1207
+ NiceSankey: et
1208
+ }, Symbol.toStringTag, { value: "Module" }));
1209
+ function tt(t, c) {
1210
+ const p = t.reduce((k, m) => k + m.value, 0);
1211
+ if (p === 0 || t.length === 0)
1212
+ return [];
1213
+ const a = [];
1214
+ let { x: i, y: v, w: _, h: C } = c;
1215
+ const L = [...t].sort((k, m) => m.value - k.value);
1216
+ for (const k of L) {
1217
+ const m = k.value / p;
1218
+ if (_ >= C) {
1219
+ const w = _ * m;
1220
+ a.push({ x: i, y: v, w, h: C, node: k }), i += w, _ -= w;
1221
+ } else {
1222
+ const w = C * m;
1223
+ a.push({ x: i, y: v, w: _, h: w, node: k }), v += w, C -= w;
1224
+ }
1225
+ }
1226
+ return a;
1227
+ }
1228
+ const nt = [
1229
+ "var(--nice-color-primary, #3b82f6)",
1230
+ "var(--nice-color-success, #10b981)",
1231
+ "var(--nice-color-warning, #f59e0b)",
1232
+ "var(--nice-color-error, #ef4444)",
1233
+ "var(--nice-color-accent, #8b5cf6)",
1234
+ "var(--nice-color-info, #06b6d4)",
1235
+ "var(--nice-color-accent-pink, #ec4899)",
1236
+ "var(--nice-success, #84cc16)"
1237
+ ], He = Se(
1238
+ ({ data: t, width: c = 600, height: p = 400, onNodeClick: a, colors: i = nt, className: v, style: _, id: C }, L) => {
1239
+ const k = Le(C), m = me(() => {
1240
+ const w = t.children ?? [t];
1241
+ return tt(w, { x: 0, y: 0, w: c, h: p });
1242
+ }, [t, c, p]);
1243
+ return /* @__PURE__ */ e("div", { ref: L, id: k, className: `nice-treemap ${v || ""}`, style: _, children: /* @__PURE__ */ e("svg", { width: c, height: p, className: "nice-treemap__svg", children: m.map((w, R) => /* @__PURE__ */ b(
1244
+ "g",
1245
+ {
1246
+ onClick: () => a?.(w.node),
1247
+ style: { cursor: a ? "pointer" : void 0 },
1248
+ children: [
1249
+ /* @__PURE__ */ e(
1250
+ "rect",
1251
+ {
1252
+ x: w.x,
1253
+ y: w.y,
1254
+ width: Math.max(w.w - 1, 0),
1255
+ height: Math.max(w.h - 1, 0),
1256
+ fill: w.node.color ?? i[R % i.length],
1257
+ rx: 2
1258
+ }
1259
+ ),
1260
+ w.w > 40 && w.h > 20 && /* @__PURE__ */ e(
1261
+ "text",
1262
+ {
1263
+ x: w.x + w.w / 2,
1264
+ y: w.y + w.h / 2,
1265
+ textAnchor: "middle",
1266
+ dominantBaseline: "central",
1267
+ fill: "var(--nice-text-on-primary, #fff)",
1268
+ fontSize: Math.min(12, w.w / 6),
1269
+ className: "nice-treemap__label",
1270
+ children: w.node.label
1271
+ }
1272
+ )
1273
+ ]
1274
+ },
1275
+ w.node.key
1276
+ )) }) });
1277
+ }
1278
+ );
1279
+ He.displayName = "NiceTreeMap";
1280
+ const St = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1281
+ __proto__: null,
1282
+ NiceTreeMap: He
1283
+ }, Symbol.toStringTag, { value: "Module" })), rt = ({
1284
+ regions: t,
1285
+ width: c = 600,
1286
+ height: p = 400,
1287
+ viewBox: a = "0 0 1000 600",
1288
+ // Literal hex: interpolateColor() parses these as #rrggbb. As var() tokens (a codemod
1289
+ // leftover) every region came out rgb(NaN,NaN,NaN).
1290
+ colorRange: i = ["#dbeafe", "#1d4ed8"],
1291
+ maxValue: v,
1292
+ onRegionClick: _,
1293
+ selectedRegionId: C,
1294
+ title: L,
1295
+ showTooltip: k = !0,
1296
+ className: m,
1297
+ style: w
1298
+ }) => {
1299
+ const R = v ?? Math.max(...t.map(($) => $.value ?? 0), 1), I = ($) => {
1300
+ const l = (d) => [
1301
+ parseInt(d.slice(1, 3), 16),
1302
+ parseInt(d.slice(3, 5), 16),
1303
+ parseInt(d.slice(5, 7), 16)
1304
+ ], [o, h, z] = l(i[0]), [g, S, y] = l(i[1]), D = Math.round(o + (g - o) * $), r = Math.round(h + (S - h) * $), B = Math.round(z + (y - z) * $);
1305
+ return `rgb(${D},${r},${B})`;
1306
+ };
1307
+ return /* @__PURE__ */ b("div", { className: `nice-vectormap ${m || ""}`, style: w, children: [
1308
+ L && /* @__PURE__ */ e("div", { className: "nice-vectormap__title", children: L }),
1309
+ /* @__PURE__ */ e("svg", { width: c, height: p, viewBox: a, children: t.map(($) => {
1310
+ const l = $.value != null ? Math.max(0, Math.min(1, $.value / R)) : 0, o = $.value != null ? I(l) : "var(--nice-bg-tertiary, #e5e7eb)", h = $.id === C;
1311
+ return /* @__PURE__ */ e(
1312
+ "path",
1313
+ {
1314
+ d: $.path,
1315
+ fill: o,
1316
+ stroke: h ? "var(--nice-color-primary, #3b82f6)" : "var(--nice-border-color, #d1d5db)",
1317
+ strokeWidth: h ? 2 : 0.5,
1318
+ cursor: _ ? "pointer" : void 0,
1319
+ onClick: () => _?.($),
1320
+ children: k && /* @__PURE__ */ e("title", { children: `${$.name}${$.value != null ? `: ${$.value}` : ""}` })
1321
+ },
1322
+ $.id
1323
+ );
1324
+ }) })
1325
+ ] });
1326
+ }, Ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1327
+ __proto__: null,
1328
+ NiceVectorMap: rt
1329
+ }, Symbol.toStringTag, { value: "Module" })), at = Se(
1330
+ ({
1331
+ data: t,
1332
+ renderNode: c,
1333
+ selectable: p,
1334
+ selectedKey: a,
1335
+ onSelect: i,
1336
+ direction: v = "top-down",
1337
+ collapsible: _ = !0,
1338
+ className: C,
1339
+ style: L,
1340
+ id: k
1341
+ }, m) => {
1342
+ const w = Le(k), [R, I] = he(/* @__PURE__ */ new Set()), $ = ie((h) => {
1343
+ I((z) => {
1344
+ const g = new Set(z);
1345
+ return g.has(h) ? g.delete(h) : g.add(h), g;
1346
+ });
1347
+ }, []), l = ie(
1348
+ (h) => {
1349
+ p && i?.(h);
1350
+ },
1351
+ [p, i]
1352
+ ), o = ie(
1353
+ (h) => {
1354
+ const z = R.has(h.key), g = h.children && h.children.length > 0;
1355
+ return /* @__PURE__ */ b("li", { className: "nice-org-chart__item", children: [
1356
+ /* @__PURE__ */ b(
1357
+ "div",
1358
+ {
1359
+ className: `nice-org-chart__node${a === h.key ? " nice-org-chart__node--selected" : ""}`,
1360
+ onClick: () => l(h.key),
1361
+ role: p ? "button" : void 0,
1362
+ children: [
1363
+ c ? c(h) : /* @__PURE__ */ e("span", { children: h.label }),
1364
+ _ && g && /* @__PURE__ */ e(
1365
+ "button",
1366
+ {
1367
+ type: "button",
1368
+ className: "nice-org-chart__toggle",
1369
+ onClick: (S) => {
1370
+ S.stopPropagation(), $(h.key);
1371
+ },
1372
+ "aria-label": z ? "Expand" : "Collapse",
1373
+ children: /* @__PURE__ */ e(Me, { name: z ? "plus" : "minus", size: 14 })
1374
+ }
1375
+ )
1376
+ ]
1377
+ }
1378
+ ),
1379
+ g && !z && /* @__PURE__ */ e("ul", { className: "nice-org-chart__children", children: h.children.map((S) => o(S)) })
1380
+ ] }, h.key);
1381
+ },
1382
+ [R, a, c, p, _, l, $]
1383
+ );
1384
+ return /* @__PURE__ */ e(
1385
+ "div",
1386
+ {
1387
+ ref: m,
1388
+ id: w,
1389
+ className: `nice-org-chart nice-org-chart--${v} ${C || ""}`,
1390
+ style: L,
1391
+ children: /* @__PURE__ */ e("ul", { className: "nice-org-chart__root", children: o(t) })
1392
+ }
1393
+ );
1394
+ }
1395
+ );
1396
+ at.displayName = "NiceOrganizationChart";
1397
+ const ct = Se(
1398
+ ({
1399
+ data: t,
1400
+ type: c = "candlestick",
1401
+ showVolume: p = !0,
1402
+ width: a = 800,
1403
+ height: i = 400,
1404
+ bullColor: v = "var(--nice-color-success, #22c55e)",
1405
+ bearColor: _ = "var(--nice-color-error, #ef4444)",
1406
+ className: C,
1407
+ style: L,
1408
+ id: k
1409
+ }, m) => {
1410
+ const w = Le(k), R = { top: 20, right: 20, bottom: p ? 80 : 30, left: 60 }, I = a - R.left - R.right, $ = p ? 50 : 0, l = i - R.top - R.bottom - $, { minP: o, maxP: h, maxVol: z } = me(() => {
1411
+ let r = 1 / 0, B = -1 / 0, d = 0;
1412
+ for (const M of t)
1413
+ M.low < r && (r = M.low), M.high > B && (B = M.high), M.volume && M.volume > d && (d = M.volume);
1414
+ return { minP: r, maxP: B, maxVol: d };
1415
+ }, [t]), g = Math.max(1, I / t.length * 0.7), S = (r) => R.left + (r + 0.5) * (I / t.length), y = (r) => R.top + l - (r - o) / (h - o || 1) * l, D = (r) => i - R.bottom - $ + $ * (1 - r / (z || 1));
1416
+ return /* @__PURE__ */ e("div", { ref: m, id: w, className: `nice-stock-chart ${C || ""}`, style: L, children: /* @__PURE__ */ b("svg", { width: a, height: i, className: "nice-stock-chart__svg", children: [
1417
+ [0, 0.25, 0.5, 0.75, 1].map((r) => {
1418
+ const B = o + r * (h - o);
1419
+ return /* @__PURE__ */ b("g", { children: [
1420
+ /* @__PURE__ */ e(
1421
+ "line",
1422
+ {
1423
+ x1: R.left,
1424
+ x2: a - R.right,
1425
+ y1: y(B),
1426
+ y2: y(B),
1427
+ stroke: "var(--nice-border, #e5e7eb)",
1428
+ strokeDasharray: "2,2"
1429
+ }
1430
+ ),
1431
+ /* @__PURE__ */ e(
1432
+ "text",
1433
+ {
1434
+ x: R.left - 4,
1435
+ y: y(B) + 4,
1436
+ textAnchor: "end",
1437
+ fontSize: 10,
1438
+ fill: "var(--nice-text-secondary, #888)",
1439
+ children: B.toFixed(2)
1440
+ }
1441
+ )
1442
+ ] }, r);
1443
+ }),
1444
+ c === "line" ? /* @__PURE__ */ e(
1445
+ "polyline",
1446
+ {
1447
+ points: t.map((r, B) => `${S(B)},${y(r.close)}`).join(" "),
1448
+ fill: "none",
1449
+ stroke: v,
1450
+ strokeWidth: 1.5
1451
+ }
1452
+ ) : t.map((r, B) => {
1453
+ const d = r.close >= r.open, M = d ? v : _, x = S(B);
1454
+ if (c === "ohlc")
1455
+ return /* @__PURE__ */ b("g", { children: [
1456
+ /* @__PURE__ */ e(
1457
+ "line",
1458
+ {
1459
+ x1: x,
1460
+ x2: x,
1461
+ y1: y(r.high),
1462
+ y2: y(r.low),
1463
+ stroke: M,
1464
+ strokeWidth: 1
1465
+ }
1466
+ ),
1467
+ /* @__PURE__ */ e(
1468
+ "line",
1469
+ {
1470
+ x1: x - g / 2,
1471
+ x2: x,
1472
+ y1: y(r.open),
1473
+ y2: y(r.open),
1474
+ stroke: M,
1475
+ strokeWidth: 1.5
1476
+ }
1477
+ ),
1478
+ /* @__PURE__ */ e(
1479
+ "line",
1480
+ {
1481
+ x1: x,
1482
+ x2: x + g / 2,
1483
+ y1: y(r.close),
1484
+ y2: y(r.close),
1485
+ stroke: M,
1486
+ strokeWidth: 1.5
1487
+ }
1488
+ )
1489
+ ] }, B);
1490
+ const O = y(Math.max(r.open, r.close)), Y = y(Math.min(r.open, r.close));
1491
+ return /* @__PURE__ */ b("g", { children: [
1492
+ /* @__PURE__ */ e(
1493
+ "line",
1494
+ {
1495
+ x1: x,
1496
+ x2: x,
1497
+ y1: y(r.high),
1498
+ y2: y(r.low),
1499
+ stroke: M,
1500
+ strokeWidth: 1
1501
+ }
1502
+ ),
1503
+ /* @__PURE__ */ e(
1504
+ "rect",
1505
+ {
1506
+ x: x - g / 2,
1507
+ y: O,
1508
+ width: g,
1509
+ height: Math.max(Y - O, 1),
1510
+ fill: d ? "transparent" : M,
1511
+ stroke: M,
1512
+ strokeWidth: 1
1513
+ }
1514
+ )
1515
+ ] }, B);
1516
+ }),
1517
+ p && t.map((r, B) => {
1518
+ if (!r.volume)
1519
+ return null;
1520
+ const d = r.close >= r.open;
1521
+ return /* @__PURE__ */ e(
1522
+ "rect",
1523
+ {
1524
+ x: S(B) - g / 2,
1525
+ y: D(r.volume),
1526
+ width: g,
1527
+ height: i - R.bottom - D(r.volume),
1528
+ fill: d ? v : _,
1529
+ opacity: 0.3
1530
+ },
1531
+ `v${B}`
1532
+ );
1533
+ }),
1534
+ t.map((r, B) => B % Math.max(1, Math.floor(t.length / 8)) !== 0 ? null : /* @__PURE__ */ e(
1535
+ "text",
1536
+ {
1537
+ x: S(B),
1538
+ y: i - R.bottom + $ + 14,
1539
+ textAnchor: "middle",
1540
+ fontSize: 9,
1541
+ fill: "var(--nice-text-secondary, #888)",
1542
+ children: r.date
1543
+ },
1544
+ `l${B}`
1545
+ ))
1546
+ ] }) });
1547
+ }
1548
+ );
1549
+ ct.displayName = "NiceStockChart";
1550
+ const At = ({
1551
+ data: t,
1552
+ width: c = 120,
1553
+ height: p = 30,
1554
+ type: a = "line",
1555
+ color: i = "var(--nice-color-primary, #3b82f6)",
1556
+ showMinMax: v,
1557
+ showLastPoint: _ = !0,
1558
+ className: C,
1559
+ style: L
1560
+ }) => {
1561
+ if (t.length === 0)
1562
+ return null;
1563
+ const k = 2, m = Math.min(...t), w = Math.max(...t), R = w - m || 1, I = c - k * 2, $ = p - k * 2, l = (y) => k + y / (t.length - 1 || 1) * I, o = (y) => k + $ - (y - m) / R * $;
1564
+ if (a === "bar") {
1565
+ const y = Math.max(1, I / t.length - 1);
1566
+ return /* @__PURE__ */ e(
1567
+ "svg",
1568
+ {
1569
+ width: c,
1570
+ height: p,
1571
+ className: `nice-sparkline ${C || ""}`,
1572
+ style: L,
1573
+ children: t.map((D, r) => /* @__PURE__ */ e(
1574
+ "rect",
1575
+ {
1576
+ x: k + r / t.length * I,
1577
+ y: o(D),
1578
+ width: y,
1579
+ height: $ - (o(D) - k),
1580
+ fill: i,
1581
+ rx: 1
1582
+ },
1583
+ r
1584
+ ))
1585
+ }
1586
+ );
1587
+ }
1588
+ const h = t.map((y, D) => `${l(D)},${o(y)}`).join(" "), z = t.indexOf(m), g = t.indexOf(w), S = t.length - 1;
1589
+ return /* @__PURE__ */ b(
1590
+ "svg",
1591
+ {
1592
+ width: c,
1593
+ height: p,
1594
+ className: `nice-sparkline ${C || ""}`,
1595
+ style: L,
1596
+ children: [
1597
+ a === "area" && /* @__PURE__ */ e(
1598
+ "polygon",
1599
+ {
1600
+ points: `${l(0)},${k + $} ${h} ${l(S)},${k + $}`,
1601
+ fill: i,
1602
+ opacity: 0.15
1603
+ }
1604
+ ),
1605
+ /* @__PURE__ */ e("polyline", { points: h, fill: "none", stroke: i, strokeWidth: 1.5 }),
1606
+ v && /* @__PURE__ */ e("circle", { cx: l(z), cy: o(m), r: 2, fill: "var(--nice-danger, #ef4444)" }),
1607
+ v && /* @__PURE__ */ e("circle", { cx: l(g), cy: o(w), r: 2, fill: "var(--nice-success, #22c55e)" }),
1608
+ _ && /* @__PURE__ */ e("circle", { cx: l(S), cy: o(t[S]), r: 2, fill: i })
1609
+ ]
1610
+ }
1611
+ );
1612
+ }, zt = ({
1613
+ series: t,
1614
+ categories: c,
1615
+ width: p = 400,
1616
+ height: a = 400,
1617
+ maxValue: i,
1618
+ title: v,
1619
+ showLegend: _ = !0,
1620
+ className: C,
1621
+ style: L
1622
+ }) => {
1623
+ const k = p / 2, m = (a - (_ ? 30 : 0)) / 2 + (v ? 10 : 0), w = Math.min(k, m) - 60, R = c.length, I = i ?? Math.max(...t.flatMap((h) => h.data), 1), $ = Math.PI * 2 / R, l = 5, o = (h, z) => {
1624
+ const g = h * $ - Math.PI / 2, S = z / I * w;
1625
+ return { x: k + S * Math.cos(g), y: m + S * Math.sin(g) };
1626
+ };
1627
+ return /* @__PURE__ */ e("div", { className: `nice-polarchart ${C || ""}`, style: L, children: /* @__PURE__ */ b("svg", { width: p, height: a, className: "nice-polarchart__svg", children: [
1628
+ v && /* @__PURE__ */ e("text", { x: k, y: 20, textAnchor: "middle", className: "nice-chart__title", children: v }),
1629
+ Array.from({ length: l }, (h, z) => {
1630
+ const g = w * ((z + 1) / l);
1631
+ return /* @__PURE__ */ e(
1632
+ "circle",
1633
+ {
1634
+ cx: k,
1635
+ cy: m,
1636
+ r: g,
1637
+ fill: "none",
1638
+ stroke: "var(--nice-border-color, #ddd)",
1639
+ strokeWidth: 0.5
1640
+ },
1641
+ z
1642
+ );
1643
+ }),
1644
+ c.map((h, z) => {
1645
+ const g = o(z, I), S = o(z, I * 1.22), y = z * $ - Math.PI / 2, D = Math.cos(y), r = Math.sin(y), B = D > 0.2 ? "start" : D < -0.2 ? "end" : "middle", d = r > 0.2 ? "hanging" : r < -0.2 ? "auto" : "middle";
1646
+ return /* @__PURE__ */ b("g", { children: [
1647
+ /* @__PURE__ */ e(
1648
+ "line",
1649
+ {
1650
+ x1: k,
1651
+ y1: m,
1652
+ x2: g.x,
1653
+ y2: g.y,
1654
+ stroke: "var(--nice-border-color, #ddd)",
1655
+ strokeWidth: 0.5
1656
+ }
1657
+ ),
1658
+ /* @__PURE__ */ e(
1659
+ "text",
1660
+ {
1661
+ x: S.x,
1662
+ y: S.y,
1663
+ textAnchor: B,
1664
+ dominantBaseline: d,
1665
+ className: "nice-chart__axis-label nice-chart__axis-label--polar",
1666
+ children: h
1667
+ }
1668
+ )
1669
+ ] }, z);
1670
+ }),
1671
+ t.map((h, z) => {
1672
+ const g = h.color || we[z % we.length], S = h.data.map((y, D) => {
1673
+ const r = o(D, y);
1674
+ return `${r.x},${r.y}`;
1675
+ }).join(" ");
1676
+ return /* @__PURE__ */ b("g", { children: [
1677
+ /* @__PURE__ */ e(
1678
+ "polygon",
1679
+ {
1680
+ points: S,
1681
+ fill: h.fill !== !1 ? g : "none",
1682
+ fillOpacity: 0.15,
1683
+ stroke: g,
1684
+ strokeWidth: 2
1685
+ }
1686
+ ),
1687
+ h.data.map((y, D) => {
1688
+ const r = o(D, y);
1689
+ return /* @__PURE__ */ e("circle", { cx: r.x, cy: r.y, r: 3, fill: g, children: /* @__PURE__ */ e("title", { children: `${h.name} - ${c[D]}: ${y}` }) }, D);
1690
+ })
1691
+ ] }, h.name);
1692
+ }),
1693
+ _ && /* @__PURE__ */ e("g", { transform: `translate(10, ${a - 25})`, children: t.map((h, z) => /* @__PURE__ */ b("g", { transform: `translate(${z * 100}, 0)`, children: [
1694
+ /* @__PURE__ */ e("rect", { width: 10, height: 10, rx: 2, fill: h.color || we[z % we.length] }),
1695
+ /* @__PURE__ */ e("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: h.name })
1696
+ ] }, z)) })
1697
+ ] }) });
1698
+ }, It = ({
1699
+ data: t,
1700
+ min: c,
1701
+ max: p,
1702
+ start: a,
1703
+ end: i,
1704
+ onChange: v,
1705
+ width: _ = 500,
1706
+ height: C = 100,
1707
+ step: L = 1,
1708
+ formatValue: k,
1709
+ chartColor: m = "var(--nice-color-primary, #3b82f6)",
1710
+ className: w,
1711
+ style: R
1712
+ }) => {
1713
+ const I = { top: 10, bottom: 30, left: 10, right: 10 }, $ = _ - I.left - I.right, l = C - I.top - I.bottom, o = (D) => I.left + (D - c) / (p - c || 1) * $, h = (D) => {
1714
+ const r = Math.max(0, Math.min(1, (D - I.left) / $)), B = c + r * (p - c);
1715
+ return Math.round(B / L) * L;
1716
+ }, z = (D, r) => {
1717
+ r.preventDefault();
1718
+ const B = r.target.closest("svg");
1719
+ if (!B)
1720
+ return;
1721
+ const d = (x) => {
1722
+ const O = B.getBoundingClientRect(), Y = h(x.clientX - O.left);
1723
+ D === "start" ? v(Math.min(Y, i), i) : v(a, Math.max(Y, a));
1724
+ }, M = () => {
1725
+ document.removeEventListener("pointermove", d), document.removeEventListener("pointerup", M);
1726
+ };
1727
+ document.addEventListener("pointermove", d), document.addEventListener("pointerup", M);
1728
+ }, g = t ? Math.min(...t) : 0, y = (t ? Math.max(...t) : 1) - g || 1;
1729
+ return /* @__PURE__ */ e("div", { className: `nice-rangeselector ${w || ""}`, style: R, children: /* @__PURE__ */ b("svg", { width: _, height: C, children: [
1730
+ t && t.length > 1 && /* @__PURE__ */ e(
1731
+ "polygon",
1732
+ {
1733
+ points: `${I.left},${I.top + l} ${t.map((D, r) => `${I.left + r / (t.length - 1) * $},${I.top + l - (D - g) / y * l}`).join(" ")} ${I.left + $},${I.top + l}`,
1734
+ fill: m,
1735
+ opacity: 0.15
1736
+ }
1737
+ ),
1738
+ /* @__PURE__ */ e(
1739
+ "rect",
1740
+ {
1741
+ x: o(a),
1742
+ y: I.top,
1743
+ width: o(i) - o(a),
1744
+ height: l,
1745
+ fill: m,
1746
+ opacity: 0.1
1747
+ }
1748
+ ),
1749
+ /* @__PURE__ */ e(
1750
+ "rect",
1751
+ {
1752
+ x: I.left,
1753
+ y: I.top,
1754
+ width: o(a) - I.left,
1755
+ height: l,
1756
+ fill: "var(--nice-bg-secondary, #f5f5f5)",
1757
+ opacity: 0.6
1758
+ }
1759
+ ),
1760
+ /* @__PURE__ */ e(
1761
+ "rect",
1762
+ {
1763
+ x: o(i),
1764
+ y: I.top,
1765
+ width: I.left + $ - o(i),
1766
+ height: l,
1767
+ fill: "var(--nice-bg-secondary, #f5f5f5)",
1768
+ opacity: 0.6
1769
+ }
1770
+ ),
1771
+ /* @__PURE__ */ e(
1772
+ "rect",
1773
+ {
1774
+ x: o(a) - 4,
1775
+ y: I.top,
1776
+ width: 8,
1777
+ height: l,
1778
+ fill: m,
1779
+ rx: 2,
1780
+ cursor: "ew-resize",
1781
+ onPointerDown: (D) => z("start", D)
1782
+ }
1783
+ ),
1784
+ /* @__PURE__ */ e(
1785
+ "rect",
1786
+ {
1787
+ x: o(i) - 4,
1788
+ y: I.top,
1789
+ width: 8,
1790
+ height: l,
1791
+ fill: m,
1792
+ rx: 2,
1793
+ cursor: "ew-resize",
1794
+ onPointerDown: (D) => z("end", D)
1795
+ }
1796
+ ),
1797
+ /* @__PURE__ */ e(
1798
+ "text",
1799
+ {
1800
+ x: o(a),
1801
+ y: I.top + l + 18,
1802
+ textAnchor: "middle",
1803
+ className: "nice-chart__axis-label",
1804
+ children: k ? k(a) : a
1805
+ }
1806
+ ),
1807
+ /* @__PURE__ */ e(
1808
+ "text",
1809
+ {
1810
+ x: o(i),
1811
+ y: I.top + l + 18,
1812
+ textAnchor: "middle",
1813
+ className: "nice-chart__axis-label",
1814
+ children: k ? k(i) : i
1815
+ }
1816
+ )
1817
+ ] }) });
1818
+ }, it = `
1819
+ .nice-forecast-chart {
1820
+ display: flex;
1821
+ flex-direction: column;
1822
+ background: var(--nice-bg-primary, #ffffff);
1823
+ border: 1px solid var(--nice-border-color, #e5e7eb);
1824
+ border-radius: var(--nice-radius-lg, 0.5rem);
1825
+ overflow: hidden;
1826
+ }
1827
+
1828
+ .nice-forecast-chart__header {
1829
+ display: flex;
1830
+ align-items: center;
1831
+ justify-content: space-between;
1832
+ padding: 0.75rem 1rem;
1833
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
1834
+ }
1835
+
1836
+ .nice-forecast-chart__title {
1837
+ font-size: 1rem;
1838
+ font-weight: 600;
1839
+ color: var(--nice-text-primary);
1840
+ margin: 0;
1841
+ }
1842
+
1843
+ .nice-forecast-chart__actions {
1844
+ display: flex;
1845
+ gap: 0.5rem;
1846
+ }
1847
+
1848
+ .nice-forecast-chart__btn {
1849
+ display: inline-flex;
1850
+ align-items: center;
1851
+ justify-content: center;
1852
+ width: 2rem;
1853
+ height: 2rem;
1854
+ font-size: 1rem;
1855
+ border-radius: var(--nice-radius-md, 0.375rem);
1856
+ cursor: pointer;
1857
+ transition: all 0.15s ease;
1858
+ border: 1px solid var(--nice-border-color, #d1d5db);
1859
+ background: var(--nice-bg-primary, #ffffff);
1860
+ color: var(--nice-text-secondary);
1861
+ }
1862
+
1863
+ .nice-forecast-chart__btn:hover {
1864
+ background: var(--nice-bg-hover, #f3f4f6);
1865
+ color: var(--nice-text-primary);
1866
+ }
1867
+
1868
+ .nice-forecast-chart__btn:disabled {
1869
+ opacity: 0.5;
1870
+ cursor: not-allowed;
1871
+ }
1872
+
1873
+ .nice-forecast-chart__container {
1874
+ position: relative;
1875
+ width: 100%;
1876
+ padding: 1rem;
1877
+ }
1878
+
1879
+ .nice-forecast-chart__svg {
1880
+ width: 100%;
1881
+ overflow: visible;
1882
+ }
1883
+
1884
+ .nice-forecast-chart__grid-line {
1885
+ stroke: var(--nice-border-divider, #f3f4f6);
1886
+ stroke-width: 1;
1887
+ }
1888
+
1889
+ .nice-forecast-chart__axis-line {
1890
+ stroke: var(--nice-border-color, #e5e7eb);
1891
+ stroke-width: 1;
1892
+ }
1893
+
1894
+ .nice-forecast-chart__axis-label {
1895
+ font-size: 0.6875rem;
1896
+ fill: var(--nice-text-secondary);
1897
+ }
1898
+
1899
+ .nice-forecast-chart__axis-title {
1900
+ font-size: 0.75rem;
1901
+ font-weight: 500;
1902
+ fill: var(--nice-text-primary);
1903
+ }
1904
+
1905
+ .nice-forecast-chart__historical-line {
1906
+ fill: none;
1907
+ stroke-width: 2;
1908
+ stroke-linecap: round;
1909
+ stroke-linejoin: round;
1910
+ }
1911
+
1912
+ .nice-forecast-chart__forecast-line {
1913
+ fill: none;
1914
+ stroke-width: 2;
1915
+ stroke-linecap: round;
1916
+ stroke-linejoin: round;
1917
+ stroke-dasharray: 6, 4;
1918
+ }
1919
+
1920
+ .nice-forecast-chart__confidence-band {
1921
+ opacity: 0.2;
1922
+ }
1923
+
1924
+ .nice-forecast-chart__forecast-region {
1925
+ fill: var(--nice-bg-secondary, #f9fafb);
1926
+ opacity: 0.5;
1927
+ }
1928
+
1929
+ .nice-forecast-chart__point {
1930
+ cursor: pointer;
1931
+ transition: r 0.15s ease;
1932
+ }
1933
+
1934
+ .nice-forecast-chart__point:hover {
1935
+ r: 6;
1936
+ }
1937
+
1938
+ .nice-forecast-chart__annotation-line {
1939
+ stroke-dasharray: 4, 2;
1940
+ stroke-width: 1;
1941
+ }
1942
+
1943
+ .nice-forecast-chart__annotation-marker {
1944
+ cursor: pointer;
1945
+ transition: transform 0.15s ease;
1946
+ }
1947
+
1948
+ .nice-forecast-chart__annotation-marker:hover {
1949
+ transform: scale(1.2);
1950
+ }
1951
+
1952
+ .nice-forecast-chart__reference-line {
1953
+ stroke-width: 1;
1954
+ }
1955
+
1956
+ .nice-forecast-chart__reference-label {
1957
+ font-size: 0.625rem;
1958
+ fill: var(--nice-text-secondary);
1959
+ }
1960
+
1961
+ .nice-forecast-chart__cash-runway {
1962
+ pointer-events: none;
1963
+ }
1964
+
1965
+ .nice-forecast-chart__cash-runway-line {
1966
+ stroke: var(--nice-danger, #ef4444);
1967
+ stroke-width: 2;
1968
+ stroke-dasharray: 8, 4;
1969
+ }
1970
+
1971
+ .nice-forecast-chart__cash-runway-label-bg {
1972
+ fill: var(--nice-danger, #ef4444);
1973
+ rx: 4;
1974
+ }
1975
+
1976
+ .nice-forecast-chart__cash-runway-label {
1977
+ font-size: 0.6875rem;
1978
+ font-weight: 600;
1979
+ fill: var(--nice-bg, #FFFFFF);
1980
+ }
1981
+
1982
+ .nice-forecast-chart__cash-runway-date {
1983
+ font-size: 0.625rem;
1984
+ fill: var(--nice-danger, #ef4444);
1985
+ font-weight: 500;
1986
+ }
1987
+
1988
+ .nice-forecast-chart__tooltip {
1989
+ position: absolute;
1990
+ pointer-events: none;
1991
+ z-index: 100;
1992
+ padding: 0.75rem;
1993
+ background: var(--nice-bg-primary, #ffffff);
1994
+ border: 1px solid var(--nice-border-color, #e5e7eb);
1995
+ border-radius: var(--nice-radius-lg, 0.5rem);
1996
+ box-shadow: 0 4px 12px var(--nice-overlay-10, rgba(0, 0, 0, 0.1));
1997
+ font-size: 0.8125rem;
1998
+ max-width: 250px;
1999
+ }
2000
+
2001
+ .nice-forecast-chart__tooltip-date {
2002
+ font-weight: 600;
2003
+ color: var(--nice-text-primary);
2004
+ margin-bottom: 0.5rem;
2005
+ padding-bottom: 0.5rem;
2006
+ border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
2007
+ }
2008
+
2009
+ .nice-forecast-chart__tooltip-item {
2010
+ display: flex;
2011
+ align-items: center;
2012
+ gap: 0.5rem;
2013
+ margin-bottom: 0.25rem;
2014
+ }
2015
+
2016
+ .nice-forecast-chart__tooltip-color {
2017
+ width: 10px;
2018
+ height: 10px;
2019
+ border-radius: var(--nice-radius-sm, 2px);
2020
+ flex-shrink: 0;
2021
+ }
2022
+
2023
+ .nice-forecast-chart__tooltip-label {
2024
+ color: var(--nice-text-secondary);
2025
+ flex: 1;
2026
+ }
2027
+
2028
+ .nice-forecast-chart__tooltip-value {
2029
+ font-weight: 600;
2030
+ color: var(--nice-text-primary);
2031
+ font-variant-numeric: tabular-nums;
2032
+ }
2033
+
2034
+ .nice-forecast-chart__tooltip-confidence {
2035
+ font-size: 0.75rem;
2036
+ color: var(--nice-text-tertiary);
2037
+ }
2038
+
2039
+ .nice-forecast-chart__legend {
2040
+ display: flex;
2041
+ flex-wrap: wrap;
2042
+ gap: 1rem;
2043
+ padding: 0.75rem 1rem;
2044
+ border-top: 1px solid var(--nice-border-color, #e5e7eb);
2045
+ }
2046
+
2047
+ .nice-forecast-chart__legend-item {
2048
+ display: flex;
2049
+ align-items: center;
2050
+ gap: 0.375rem;
2051
+ font-size: 0.8125rem;
2052
+ color: var(--nice-text-secondary);
2053
+ cursor: pointer;
2054
+ user-select: none;
2055
+ transition: opacity 0.15s ease;
2056
+ }
2057
+
2058
+ .nice-forecast-chart__legend-item:hover {
2059
+ color: var(--nice-text-primary);
2060
+ }
2061
+
2062
+ .nice-forecast-chart__legend-item--hidden {
2063
+ opacity: 0.4;
2064
+ }
2065
+
2066
+ .nice-forecast-chart__legend-color {
2067
+ width: 16px;
2068
+ height: 3px;
2069
+ border-radius: var(--nice-radius-xs, 1px);
2070
+ }
2071
+
2072
+ .nice-forecast-chart__legend-color--dashed {
2073
+ background: repeating-linear-gradient(
2074
+ 90deg,
2075
+ currentColor,
2076
+ currentColor 4px,
2077
+ transparent 4px,
2078
+ transparent 6px
2079
+ );
2080
+ }
2081
+
2082
+ .nice-forecast-chart__empty {
2083
+ display: flex;
2084
+ align-items: center;
2085
+ justify-content: center;
2086
+ height: 300px;
2087
+ color: var(--nice-text-secondary);
2088
+ }
2089
+
2090
+ /* Dark mode */
2091
+ .dark .nice-forecast-chart {
2092
+ background: var(--nice-bg-primary-dark, #111827);
2093
+ border-color: var(--nice-border-color-dark, #374151);
2094
+ }
2095
+
2096
+ .dark .nice-forecast-chart__tooltip {
2097
+ background: var(--nice-bg-secondary-dark, #1f2937);
2098
+ border-color: var(--nice-border-color-dark, #374151);
2099
+ }
2100
+
2101
+ .dark .nice-forecast-chart__forecast-region {
2102
+ fill: var(--nice-bg-secondary-dark, #1f2937);
2103
+ }
2104
+ `, Oe = [
2105
+ "var(--nice-color-primary, #3b82f6)",
2106
+ // blue
2107
+ "var(--nice-color-success, #10b981)",
2108
+ // green
2109
+ "var(--nice-color-warning, #f59e0b)",
2110
+ // amber
2111
+ "var(--nice-color-error, #ef4444)",
2112
+ // red
2113
+ "var(--nice-color-accent, #8b5cf6)",
2114
+ // purple
2115
+ "var(--nice-color-accent-pink, #ec4899)",
2116
+ // pink
2117
+ "var(--nice-color-info, #06b6d4)",
2118
+ // cyan
2119
+ "var(--nice-warning, #f97316)"
2120
+ // orange
2121
+ ];
2122
+ function ye(t) {
2123
+ return t instanceof Date ? t : new Date(t);
2124
+ }
2125
+ function Ee(t, c = "pl-PL") {
2126
+ return t.toLocaleDateString(c, {
2127
+ year: "numeric",
2128
+ month: "short",
2129
+ day: "numeric"
2130
+ });
2131
+ }
2132
+ function Ie(t, c = "pl-PL") {
2133
+ return new Intl.NumberFormat(c, {
2134
+ minimumFractionDigits: 0,
2135
+ maximumFractionDigits: 2
2136
+ }).format(t);
2137
+ }
2138
+ const Lt = Se(
2139
+ function(c, p) {
2140
+ const {
2141
+ scenarios: a,
2142
+ data: i,
2143
+ annotations: v = [],
2144
+ referenceLines: _ = [],
2145
+ forecastStartDate: C,
2146
+ cashRunway: L,
2147
+ xAxis: k,
2148
+ yAxis: m,
2149
+ confidenceBands: w = [
2150
+ { level: 95, color: "var(--nice-color-primary, #3b82f6)", opacity: 0.15 }
2151
+ ],
2152
+ tooltip: R,
2153
+ legend: I = { enabled: !0, position: "bottom", interactive: !0 },
2154
+ height: $ = 350,
2155
+ showForecastRegion: l = !0,
2156
+ lineWidth: o = 2,
2157
+ showPoints: h = !1,
2158
+ pointRadius: z = 4,
2159
+ enableZoom: g = !1,
2160
+ zoomEnabled: S,
2161
+ animationDuration: y = 300,
2162
+ showLegend: D,
2163
+ responsive: r = !0,
2164
+ onPointClick: B,
2165
+ onAnnotationClick: d,
2166
+ onScenarioToggle: M,
2167
+ onViewportChange: x,
2168
+ size: O = "medium",
2169
+ disabled: Y = !1,
2170
+ labels: V = {},
2171
+ locale: X = "pl-PL",
2172
+ className: E,
2173
+ style: Z
2174
+ } = c, H = a && a.length > 0 ? a : i ? [
2175
+ {
2176
+ id: "default",
2177
+ name: "Series",
2178
+ data: i
2179
+ }
2180
+ ] : [], J = {
2181
+ ...I,
2182
+ enabled: D ?? I.enabled
2183
+ }, [f, re] = he(
2184
+ () => H.map((n, W) => ({
2185
+ ...n,
2186
+ color: n.color ?? Oe[W % Oe.length],
2187
+ visible: n.visible !== !1
2188
+ }))
2189
+ ), [Q, ee] = he(null), [U, oe] = he({ x: 0, y: 0 }), P = ve(null), u = ve(null), s = { top: 20, right: 30, bottom: 40, left: 60 }, [T, te] = he({
2190
+ width: 600,
2191
+ height: typeof $ == "number" ? $ : 350
2192
+ });
2193
+ Ae(() => {
2194
+ if (!r || !P.current)
2195
+ return;
2196
+ const n = new ResizeObserver((W) => {
2197
+ for (const F of W)
2198
+ te((A) => ({
2199
+ width: F.contentRect.width,
2200
+ height: A.height
2201
+ }));
2202
+ });
2203
+ return n.observe(P.current), () => n.disconnect();
2204
+ }, [r]), Ae(() => {
2205
+ const n = "nice-forecast-chart-styles";
2206
+ if (!document.getElementById(n)) {
2207
+ const W = document.createElement("style");
2208
+ W.id = n, W.textContent = it, document.head.appendChild(W);
2209
+ }
2210
+ }, []);
2211
+ const { xScale: ce, yScale: j, allDates: se, minY: fe, maxY: be } = me(() => {
2212
+ const W = f.filter((xe) => xe.visible !== !1).flatMap((xe) => xe.data);
2213
+ if (W.length === 0)
2214
+ return { xScale: () => 0, yScale: () => 0, allDates: [], minY: 0, maxY: 100 };
2215
+ const F = W.map((xe) => ye(xe.date).getTime()), A = Math.min(...F), K = Math.max(...F), ue = W.flatMap((xe) => [xe.value, xe.forecast, xe.lowerBound, xe.upperBound]).filter((xe) => xe != null), pe = m?.min ?? Math.min(...ue) * 0.95, ge = m?.max ?? Math.max(...ue) * 1.05, Ne = T.width - s.left - s.right, ke = T.height - s.top - s.bottom, Te = (xe) => {
2216
+ const Be = typeof xe == "number" ? xe : xe.getTime();
2217
+ return s.left + (Be - A) / (K - A) * Ne;
2218
+ }, Re = (xe) => s.top + ke - (xe - pe) / (ge - pe) * ke, Xe = [...new Set(F)].sort((xe, Be) => xe - Be).map((xe) => new Date(xe));
2219
+ return {
2220
+ xScale: Te,
2221
+ yScale: Re,
2222
+ allDates: Xe,
2223
+ minY: pe,
2224
+ maxY: ge
2225
+ };
2226
+ }, [f, T, s, m]), $e = C ? ye(C) : null, _e = me(() => {
2227
+ if (!L?.enabled)
2228
+ return null;
2229
+ const n = L.threshold ?? 0, W = L.scenarioId ? f.find((A) => A.id === L.scenarioId && A.visible !== !1) : f.find((A) => A.visible !== !1);
2230
+ if (!W)
2231
+ return null;
2232
+ const F = W.data.sort(
2233
+ (A, K) => ye(A.date).getTime() - ye(K.date).getTime()
2234
+ );
2235
+ for (let A = 1; A < F.length; A++) {
2236
+ const K = F[A - 1], ue = F[A], pe = K.forecast ?? K.value, ge = ue.forecast ?? ue.value;
2237
+ if (pe != null && ge != null && pe > n && ge <= n) {
2238
+ const Ne = (pe - n) / (pe - ge), ke = ye(K.date).getTime(), Te = ye(ue.date).getTime(), Re = ke + Ne * (Te - ke);
2239
+ return new Date(Re);
2240
+ }
2241
+ }
2242
+ return null;
2243
+ }, [L, f]), q = ie(
2244
+ (n, W) => {
2245
+ const F = n.filter((A) => A[W] != null).map((A) => ({ x: ce(ye(A.date)), y: j(A[W]) }));
2246
+ return F.length === 0 ? "" : `M ${F.map((A) => `${A.x},${A.y}`).join(" L ")}`;
2247
+ },
2248
+ [ce, j]
2249
+ ), ae = ie(
2250
+ (n) => {
2251
+ const W = n.filter((K) => K.lowerBound != null && K.upperBound != null);
2252
+ if (W.length === 0)
2253
+ return "";
2254
+ const F = W.map((K) => ({
2255
+ x: ce(ye(K.date)),
2256
+ y: j(K.upperBound)
2257
+ })), A = W.map((K) => ({ x: ce(ye(K.date)), y: j(K.lowerBound) })).reverse();
2258
+ return `M ${F.map((K) => `${K.x},${K.y}`).join(" L ")} L ${A.map((K) => `${K.x},${K.y}`).join(" L ")} Z`;
2259
+ },
2260
+ [ce, j]
2261
+ ), N = ie(
2262
+ (n) => {
2263
+ if (!u.current || R?.enabled === !1)
2264
+ return;
2265
+ const W = u.current.getBoundingClientRect(), F = n.clientX - W.left;
2266
+ n.clientY - W.top;
2267
+ let A = null, K = 1 / 0;
2268
+ for (const ue of se) {
2269
+ const pe = ce(ue), ge = Math.abs(pe - F);
2270
+ ge < K && (K = ge, A = ue);
2271
+ }
2272
+ if (A && K < 50) {
2273
+ const ue = f.filter((ge) => ge.visible !== !1).map((ge) => {
2274
+ const Ne = ge.data.find((ke) => ye(ke.date).getTime() === A.getTime());
2275
+ return {
2276
+ scenario: ge,
2277
+ value: Ne?.value,
2278
+ forecast: Ne?.forecast,
2279
+ lowerBound: Ne?.lowerBound,
2280
+ upperBound: Ne?.upperBound
2281
+ };
2282
+ }), pe = v.filter(
2283
+ (ge) => Math.abs(ye(ge.date).getTime() - A.getTime()) < 864e5
2284
+ );
2285
+ ee({ date: A, values: ue, annotations: pe }), oe({ x: n.clientX - W.left + 10, y: n.clientY - W.top - 10 });
2286
+ } else
2287
+ ee(null);
2288
+ },
2289
+ [ce, se, f, v, R]
2290
+ ), G = ie(
2291
+ (n) => {
2292
+ if (!J.interactive)
2293
+ return;
2294
+ re((F) => F.map((A) => A.id === n ? { ...A, visible: !A.visible } : A));
2295
+ const W = f.find((F) => F.id === n);
2296
+ W && M?.(n, !W.visible);
2297
+ },
2298
+ [J.interactive, f, M]
2299
+ );
2300
+ ze(
2301
+ p,
2302
+ () => ({
2303
+ getScenarios: () => f,
2304
+ updateScenario: (n, W) => {
2305
+ re((F) => F.map((A) => A.id === n ? { ...A, data: W } : A));
2306
+ },
2307
+ toggleScenario: G,
2308
+ setZoomRange: () => {
2309
+ },
2310
+ // Would need pan/zoom implementation
2311
+ resetZoom: () => {
2312
+ },
2313
+ exportImage: (n) => {
2314
+ if (!u.current)
2315
+ return null;
2316
+ const W = u.current, A = new XMLSerializer().serializeToString(W);
2317
+ return `data:image/svg+xml;base64,${btoa(A)}`;
2318
+ },
2319
+ getDataAtDate: (n) => {
2320
+ const W = f.filter((F) => F.visible !== !1).map((F) => {
2321
+ const A = F.data.find((K) => ye(K.date).getTime() === n.getTime());
2322
+ return {
2323
+ scenario: F,
2324
+ value: A?.value,
2325
+ forecast: A?.forecast,
2326
+ lowerBound: A?.lowerBound,
2327
+ upperBound: A?.upperBound
2328
+ };
2329
+ });
2330
+ return {
2331
+ date: n,
2332
+ values: W,
2333
+ annotations: v.filter((F) => ye(F.date).getTime() === n.getTime())
2334
+ };
2335
+ }
2336
+ }),
2337
+ [f, v, G]
2338
+ ), T.width - s.left - s.right;
2339
+ const ne = T.height - s.top - s.bottom, le = me(() => {
2340
+ const n = m?.tickCount ?? 5, W = [], F = (be - fe) / (n - 1);
2341
+ for (let A = 0; A < n; A++)
2342
+ W.push(fe + F * A);
2343
+ return W;
2344
+ }, [fe, be, m?.tickCount]), de = me(() => {
2345
+ const n = k?.tickCount ?? 6;
2346
+ if (se.length === 0)
2347
+ return [];
2348
+ const W = Math.max(1, Math.floor(se.length / (n - 1)));
2349
+ return se.filter((F, A) => A % W === 0 || A === se.length - 1);
2350
+ }, [se, k?.tickCount]);
2351
+ return f.length === 0 || f.every((n) => n.data.length === 0) ? /* @__PURE__ */ e("div", { className: `nice-forecast-chart ${E ?? ""}`, style: Z, children: /* @__PURE__ */ e("div", { className: "nice-forecast-chart__empty", children: V.noData ?? "No data available" }) }) : /* @__PURE__ */ b("div", { className: `nice-forecast-chart ${E ?? ""}`, style: { ...Z, height: $ }, children: [
2352
+ /* @__PURE__ */ b("div", { ref: P, className: "nice-forecast-chart__container", children: [
2353
+ /* @__PURE__ */ b(
2354
+ "svg",
2355
+ {
2356
+ ref: u,
2357
+ className: "nice-forecast-chart__svg",
2358
+ width: T.width,
2359
+ height: T.height,
2360
+ onMouseMove: N,
2361
+ onMouseLeave: () => ee(null),
2362
+ children: [
2363
+ m?.showGrid !== !1 && le.map((n) => /* @__PURE__ */ e(
2364
+ "line",
2365
+ {
2366
+ className: "nice-forecast-chart__grid-line",
2367
+ x1: s.left,
2368
+ x2: T.width - s.right,
2369
+ y1: j(n),
2370
+ y2: j(n)
2371
+ },
2372
+ n
2373
+ )),
2374
+ l && $e && /* @__PURE__ */ e(
2375
+ "rect",
2376
+ {
2377
+ className: "nice-forecast-chart__forecast-region",
2378
+ x: ce($e),
2379
+ y: s.top,
2380
+ width: T.width - s.right - ce($e),
2381
+ height: ne
2382
+ }
2383
+ ),
2384
+ _.map((n) => /* @__PURE__ */ b("g", { children: [
2385
+ /* @__PURE__ */ e(
2386
+ "line",
2387
+ {
2388
+ className: "nice-forecast-chart__reference-line",
2389
+ x1: s.left,
2390
+ x2: T.width - s.right,
2391
+ y1: j(n.value),
2392
+ y2: j(n.value),
2393
+ stroke: n.color ?? "var(--nice-text-muted, #9ca3af)",
2394
+ strokeDasharray: n.dashArray ?? "4,2"
2395
+ }
2396
+ ),
2397
+ n.label && /* @__PURE__ */ e(
2398
+ "text",
2399
+ {
2400
+ className: "nice-forecast-chart__reference-label",
2401
+ x: T.width - s.right - 4,
2402
+ y: j(n.value) - 4,
2403
+ textAnchor: "end",
2404
+ children: n.label
2405
+ }
2406
+ )
2407
+ ] }, n.id)),
2408
+ _e && L?.enabled && /* @__PURE__ */ b("g", { className: "nice-forecast-chart__cash-runway", children: [
2409
+ /* @__PURE__ */ e(
2410
+ "line",
2411
+ {
2412
+ className: "nice-forecast-chart__cash-runway-line",
2413
+ x1: ce(_e),
2414
+ x2: ce(_e),
2415
+ y1: s.top,
2416
+ y2: T.height - s.bottom,
2417
+ stroke: L.color ?? "var(--nice-color-error, #ef4444)"
2418
+ }
2419
+ ),
2420
+ L.showLabel !== !1 && /* @__PURE__ */ b(Ye, { children: [
2421
+ /* @__PURE__ */ e(
2422
+ "rect",
2423
+ {
2424
+ className: "nice-forecast-chart__cash-runway-label-bg",
2425
+ x: ce(_e) - 60,
2426
+ y: s.top - 2,
2427
+ width: 120,
2428
+ height: L.showDate !== !1 ? 32 : 20,
2429
+ fill: L.color ?? "var(--nice-color-error, #ef4444)",
2430
+ rx: 4
2431
+ }
2432
+ ),
2433
+ /* @__PURE__ */ e(
2434
+ "text",
2435
+ {
2436
+ className: "nice-forecast-chart__cash-runway-label",
2437
+ x: ce(_e),
2438
+ y: s.top + 12,
2439
+ textAnchor: "middle",
2440
+ fill: "var(--nice-text-on-primary, #fff)",
2441
+ children: L.label ?? V.cashRunsOut ?? "Cash runs out"
2442
+ }
2443
+ ),
2444
+ L.showDate !== !1 && /* @__PURE__ */ e(
2445
+ "text",
2446
+ {
2447
+ className: "nice-forecast-chart__cash-runway-label",
2448
+ x: ce(_e),
2449
+ y: s.top + 26,
2450
+ textAnchor: "middle",
2451
+ fill: "var(--nice-text-on-primary, #fff)",
2452
+ style: { fontSize: "0.625rem", opacity: 0.9 },
2453
+ children: Ee(_e, X)
2454
+ }
2455
+ )
2456
+ ] })
2457
+ ] }),
2458
+ f.filter((n) => n.visible !== !1 && n.showConfidenceBand).map((n) => /* @__PURE__ */ e(
2459
+ "path",
2460
+ {
2461
+ className: "nice-forecast-chart__confidence-band",
2462
+ d: ae(n.data),
2463
+ fill: n.color
2464
+ },
2465
+ `band-${n.id}`
2466
+ )),
2467
+ f.filter((n) => n.visible !== !1).map((n) => {
2468
+ const W = $e ? n.data.filter((A) => ye(A.date) < $e) : n.data.filter((A) => A.value != null), F = $e ? n.data.filter((A) => ye(A.date) >= $e) : n.data.filter((A) => A.forecast != null);
2469
+ return /* @__PURE__ */ b("g", { children: [
2470
+ /* @__PURE__ */ e(
2471
+ "path",
2472
+ {
2473
+ className: "nice-forecast-chart__historical-line",
2474
+ d: q(W, "value"),
2475
+ stroke: n.color,
2476
+ strokeWidth: o
2477
+ }
2478
+ ),
2479
+ /* @__PURE__ */ e(
2480
+ "path",
2481
+ {
2482
+ className: "nice-forecast-chart__forecast-line",
2483
+ d: q(F, $e ? "value" : "forecast"),
2484
+ stroke: n.color,
2485
+ strokeWidth: o
2486
+ }
2487
+ ),
2488
+ F.length > 0 && n.data.some((A) => A.forecast != null) && /* @__PURE__ */ e(
2489
+ "path",
2490
+ {
2491
+ className: "nice-forecast-chart__forecast-line",
2492
+ d: q(n.data, "forecast"),
2493
+ stroke: n.color,
2494
+ strokeWidth: o
2495
+ }
2496
+ ),
2497
+ h && n.data.map((A, K) => {
2498
+ const ue = A.value ?? A.forecast;
2499
+ return ue == null ? null : /* @__PURE__ */ e(
2500
+ "circle",
2501
+ {
2502
+ className: "nice-forecast-chart__point",
2503
+ cx: ce(ye(A.date)),
2504
+ cy: j(ue),
2505
+ r: z,
2506
+ fill: n.color,
2507
+ onClick: () => B?.(A, n)
2508
+ },
2509
+ K
2510
+ );
2511
+ })
2512
+ ] }, n.id);
2513
+ }),
2514
+ v.map((n) => {
2515
+ const W = ce(ye(n.date));
2516
+ return /* @__PURE__ */ b(
2517
+ "g",
2518
+ {
2519
+ className: "nice-forecast-chart__annotation-marker",
2520
+ onClick: () => d?.(n),
2521
+ children: [
2522
+ n.showLine !== !1 && /* @__PURE__ */ e(
2523
+ "line",
2524
+ {
2525
+ className: "nice-forecast-chart__annotation-line",
2526
+ x1: W,
2527
+ x2: W,
2528
+ y1: s.top,
2529
+ y2: T.height - s.bottom,
2530
+ stroke: n.color ?? "var(--nice-text-muted, #9ca3af)"
2531
+ }
2532
+ ),
2533
+ /* @__PURE__ */ e(
2534
+ "circle",
2535
+ {
2536
+ cx: W,
2537
+ cy: s.top + 10,
2538
+ r: 8,
2539
+ fill: n.color ?? "var(--nice-text-muted, #9ca3af)"
2540
+ }
2541
+ ),
2542
+ /* @__PURE__ */ e("text", { x: W, y: s.top + 14, textAnchor: "middle", fill: "white", fontSize: "10", children: n.icon ?? "!" })
2543
+ ]
2544
+ },
2545
+ n.id
2546
+ );
2547
+ }),
2548
+ /* @__PURE__ */ e(
2549
+ "line",
2550
+ {
2551
+ className: "nice-forecast-chart__axis-line",
2552
+ x1: s.left,
2553
+ x2: s.left,
2554
+ y1: s.top,
2555
+ y2: T.height - s.bottom
2556
+ }
2557
+ ),
2558
+ /* @__PURE__ */ e(
2559
+ "line",
2560
+ {
2561
+ className: "nice-forecast-chart__axis-line",
2562
+ x1: s.left,
2563
+ x2: T.width - s.right,
2564
+ y1: T.height - s.bottom,
2565
+ y2: T.height - s.bottom
2566
+ }
2567
+ ),
2568
+ le.map((n) => /* @__PURE__ */ e(
2569
+ "text",
2570
+ {
2571
+ className: "nice-forecast-chart__axis-label",
2572
+ x: s.left - 8,
2573
+ y: j(n) + 4,
2574
+ textAnchor: "end",
2575
+ children: m?.format ? m.format(n) : Ie(n, X)
2576
+ },
2577
+ n
2578
+ )),
2579
+ de.map((n) => /* @__PURE__ */ e(
2580
+ "text",
2581
+ {
2582
+ className: "nice-forecast-chart__axis-label",
2583
+ x: ce(n),
2584
+ y: T.height - s.bottom + 16,
2585
+ textAnchor: "middle",
2586
+ children: k?.format ? k.format(n) : Ee(n, X)
2587
+ },
2588
+ n.getTime()
2589
+ )),
2590
+ m?.title && /* @__PURE__ */ e(
2591
+ "text",
2592
+ {
2593
+ className: "nice-forecast-chart__axis-title",
2594
+ x: 15,
2595
+ y: T.height / 2,
2596
+ textAnchor: "middle",
2597
+ transform: `rotate(-90, 15, ${T.height / 2})`,
2598
+ children: m.title
2599
+ }
2600
+ )
2601
+ ]
2602
+ }
2603
+ ),
2604
+ Q && /* @__PURE__ */ b(
2605
+ "div",
2606
+ {
2607
+ className: "nice-forecast-chart__tooltip",
2608
+ style: { left: U.x, top: U.y },
2609
+ children: [
2610
+ /* @__PURE__ */ e("div", { className: "nice-forecast-chart__tooltip-date", children: Ee(Q.date, X) }),
2611
+ Q.values.map((n) => {
2612
+ const W = n.value ?? n.forecast;
2613
+ return W == null ? null : /* @__PURE__ */ b("div", { className: "nice-forecast-chart__tooltip-item", children: [
2614
+ /* @__PURE__ */ e(
2615
+ "span",
2616
+ {
2617
+ className: "nice-forecast-chart__tooltip-color",
2618
+ style: { background: n.scenario.color }
2619
+ }
2620
+ ),
2621
+ /* @__PURE__ */ e("span", { className: "nice-forecast-chart__tooltip-label", children: n.scenario.name }),
2622
+ /* @__PURE__ */ e("span", { className: "nice-forecast-chart__tooltip-value", children: Ie(W, X) })
2623
+ ] }, n.scenario.id);
2624
+ }),
2625
+ Q.values.some((n) => n.lowerBound != null) && /* @__PURE__ */ b("div", { className: "nice-forecast-chart__tooltip-confidence", children: [
2626
+ V.confidence ?? "CI",
2627
+ ":",
2628
+ " ",
2629
+ Ie(Q.values[0]?.lowerBound ?? 0, X),
2630
+ " –",
2631
+ " ",
2632
+ Ie(Q.values[0]?.upperBound ?? 0, X)
2633
+ ] })
2634
+ ]
2635
+ }
2636
+ )
2637
+ ] }),
2638
+ J.enabled && /* @__PURE__ */ e("div", { className: "nice-forecast-chart__legend", children: f.map((n) => /* @__PURE__ */ b(
2639
+ "div",
2640
+ {
2641
+ className: `nice-forecast-chart__legend-item ${n.visible === !1 ? "nice-forecast-chart__legend-item--hidden" : ""}`,
2642
+ onClick: () => G(n.id),
2643
+ children: [
2644
+ /* @__PURE__ */ e(
2645
+ "span",
2646
+ {
2647
+ className: `nice-forecast-chart__legend-color ${n.isBase ? "" : "nice-forecast-chart__legend-color--dashed"}`,
2648
+ style: { background: n.color }
2649
+ }
2650
+ ),
2651
+ n.name
2652
+ ]
2653
+ },
2654
+ n.id
2655
+ )) })
2656
+ ] });
2657
+ }
2658
+ );
2659
+ function ot(t, c) {
2660
+ const p = t ? typeof t == "number" ? new Date(t) : new Date(t) : /* @__PURE__ */ new Date(), a = (L) => L.toString().padStart(2, "0"), i = a(p.getHours()), v = a(p.getMinutes()), _ = a(p.getSeconds()), C = p.getMilliseconds().toString().padStart(3, "0");
2661
+ switch (c) {
2662
+ case "HH:mm:ss":
2663
+ return `${i}:${v}:${_}`;
2664
+ case "HH:mm":
2665
+ return `${i}:${v}`;
2666
+ case "mm:ss":
2667
+ return `${v}:${_}`;
2668
+ case "ss.SSS":
2669
+ return `${_}.${C}`;
2670
+ case "ISO":
2671
+ return p.toISOString();
2672
+ default:
2673
+ return `${i}:${v}:${_}`;
2674
+ }
2675
+ }
2676
+ function Fe(t) {
2677
+ if (t.length === 0)
2678
+ return null;
2679
+ const c = Math.min(...t), p = Math.max(...t), a = t.reduce((v, _) => v + _, 0) / t.length, i = t[t.length - 1];
2680
+ return { min: c, max: p, avg: a, current: i, count: t.length };
2681
+ }
2682
+ const st = Se(
2683
+ ({
2684
+ series: t,
2685
+ maxPoints: c = 100,
2686
+ slidingWindow: p = !0,
2687
+ refreshRate: a = 16,
2688
+ dataSource: i,
2689
+ width: v = 600,
2690
+ height: _ = 400,
2691
+ title: C,
2692
+ showLegend: L = !0,
2693
+ showGrid: k = !0,
2694
+ yAxisLabel: m,
2695
+ xAxisLabel: w,
2696
+ stacked: R,
2697
+ zoomable: I,
2698
+ crosshair: $,
2699
+ annotations: l = [],
2700
+ legendInteractive: o,
2701
+ onDataPointClick: h,
2702
+ exportable: z,
2703
+ showControls: g = !0,
2704
+ showStatus: S = !0,
2705
+ initialPaused: y = !1,
2706
+ onDataReceived: D,
2707
+ onDataDropped: r,
2708
+ timeFormat: B = "HH:mm:ss",
2709
+ showStats: d,
2710
+ thresholds: M = [],
2711
+ className: x,
2712
+ style: O
2713
+ }, Y) => {
2714
+ const [V, X] = he(() => {
2715
+ const q = /* @__PURE__ */ new Map();
2716
+ for (const ae of t)
2717
+ q.set(ae.name, ae.initialData?.slice() ?? []);
2718
+ return q;
2719
+ }), [E, Z] = he([]), [H, J] = he(y), [f, re] = he(!1), Q = ve([]), ee = ve(Date.now()), U = ve(null), oe = ve(/* @__PURE__ */ new Map()), P = ve(0), u = JSON.stringify(t.map((q) => q.name)), s = me(
2720
+ () => new Set(JSON.parse(u)),
2721
+ [u]
2722
+ ), T = ve(H), te = ve(D), ce = ve(r);
2723
+ Ae(() => {
2724
+ T.current = H, te.current = D, ce.current = r;
2725
+ });
2726
+ const j = ie(() => {
2727
+ const q = Q.current;
2728
+ if (q.length === 0)
2729
+ return;
2730
+ Q.current = [], X((N) => {
2731
+ const G = new Map(N);
2732
+ for (const ne of q) {
2733
+ const le = G.get(ne.series);
2734
+ if (!le)
2735
+ continue;
2736
+ const de = [...le, ne.value];
2737
+ if (p && de.length > c) {
2738
+ const n = de.length - c;
2739
+ ce.current?.(n, ne.series), de.splice(0, n);
2740
+ }
2741
+ G.set(ne.series, de);
2742
+ }
2743
+ return G;
2744
+ });
2745
+ const ae = [];
2746
+ for (const N of q) {
2747
+ if (!s.has(N.series))
2748
+ continue;
2749
+ const G = (oe.current.get(N.series) ?? 0) + 1;
2750
+ oe.current.set(N.series, G), G > P.current && (P.current = G, ae.push(N.category ?? ot(N.timestamp, B)));
2751
+ }
2752
+ ae.length > 0 && Z((N) => {
2753
+ const G = [...N, ...ae];
2754
+ return p && G.length > c && G.splice(0, G.length - c), G;
2755
+ });
2756
+ }, [p, c, B, s]), se = ie(() => {
2757
+ const q = Date.now();
2758
+ q - ee.current >= a && (j(), ee.current = q), U.current = requestAnimationFrame(se);
2759
+ }, [a, j]);
2760
+ Ae(() => (H || (U.current = requestAnimationFrame(se)), () => {
2761
+ U.current !== null && (cancelAnimationFrame(U.current), U.current = null);
2762
+ }), [H, se]);
2763
+ const fe = ie(
2764
+ (q) => {
2765
+ if (T.current)
2766
+ return;
2767
+ const ae = "points" in q ? q.points : [q];
2768
+ for (const N of ae)
2769
+ s.has(N.series) && (Q.current.push(N), te.current?.(N));
2770
+ },
2771
+ [s]
2772
+ );
2773
+ Ae(() => {
2774
+ if (!i)
2775
+ return;
2776
+ const q = i.subscribe(fe);
2777
+ let ae;
2778
+ return i.onStatusChange ? ae = i.onStatusChange(re) : re(!0), i.fetchHistory && i.fetchHistory(c).then((N) => {
2779
+ for (const G of N)
2780
+ Q.current.push(G);
2781
+ j();
2782
+ }), () => {
2783
+ q(), ae?.();
2784
+ };
2785
+ }, [i, fe, c, j]);
2786
+ const be = me(() => t.map((q) => ({
2787
+ name: q.name,
2788
+ color: q.color,
2789
+ type: q.type,
2790
+ data: V.get(q.name) ?? []
2791
+ })), [t, V]), $e = me(() => {
2792
+ const q = [...l];
2793
+ for (const ae of M)
2794
+ q.push({
2795
+ type: "line",
2796
+ value: ae.value,
2797
+ color: ae.color,
2798
+ label: ae.label,
2799
+ dash: ae.style === "dashed" ? "5,5" : ae.style === "dotted" ? "2,2" : void 0
2800
+ });
2801
+ return q;
2802
+ }, [l, M]);
2803
+ ze(
2804
+ Y,
2805
+ () => ({
2806
+ pause() {
2807
+ J(!0);
2808
+ },
2809
+ resume() {
2810
+ J(!1);
2811
+ },
2812
+ isPaused() {
2813
+ return H;
2814
+ },
2815
+ clear() {
2816
+ X((q) => {
2817
+ const ae = new Map(q);
2818
+ for (const N of ae.keys())
2819
+ ae.set(N, []);
2820
+ return ae;
2821
+ }), Z([]), oe.current = /* @__PURE__ */ new Map(), P.current = 0, Q.current = [];
2822
+ },
2823
+ addPoint(q) {
2824
+ fe(q);
2825
+ },
2826
+ addPoints(q) {
2827
+ fe({ points: q });
2828
+ },
2829
+ getData(q) {
2830
+ return V.get(q) ?? [];
2831
+ },
2832
+ getCategories() {
2833
+ return E;
2834
+ },
2835
+ exportData() {
2836
+ return { series: be, categories: E };
2837
+ },
2838
+ getStats(q) {
2839
+ const ae = V.get(q);
2840
+ return ae ? Fe(ae) : null;
2841
+ }
2842
+ }),
2843
+ [H, V, E, be, fe]
2844
+ );
2845
+ const _e = me(() => {
2846
+ if (!d)
2847
+ return null;
2848
+ const q = {};
2849
+ for (const [ae, N] of V)
2850
+ q[ae] = Fe(N);
2851
+ return q;
2852
+ }, [d, V]);
2853
+ return /* @__PURE__ */ b("div", { className: x, style: { position: "relative", ...O }, children: [
2854
+ S && /* @__PURE__ */ b(
2855
+ "div",
2856
+ {
2857
+ style: {
2858
+ position: "absolute",
2859
+ top: 8,
2860
+ right: 8,
2861
+ display: "flex",
2862
+ alignItems: "center",
2863
+ gap: 4,
2864
+ fontSize: 12,
2865
+ color: f ? "var(--nice-color-success, #22c55e)" : "var(--nice-color-error, #ef4444)",
2866
+ zIndex: 10
2867
+ },
2868
+ children: [
2869
+ /* @__PURE__ */ e(
2870
+ "span",
2871
+ {
2872
+ style: {
2873
+ width: 8,
2874
+ height: 8,
2875
+ borderRadius: "50%",
2876
+ backgroundColor: f ? "var(--nice-color-success, #22c55e)" : "var(--nice-color-error, #ef4444)"
2877
+ }
2878
+ }
2879
+ ),
2880
+ f ? "Live" : "Disconnected"
2881
+ ]
2882
+ }
2883
+ ),
2884
+ g && /* @__PURE__ */ e(
2885
+ "div",
2886
+ {
2887
+ style: {
2888
+ position: "absolute",
2889
+ top: 8,
2890
+ left: 8,
2891
+ display: "flex",
2892
+ gap: 4,
2893
+ zIndex: 10
2894
+ },
2895
+ children: /* @__PURE__ */ e(
2896
+ "button",
2897
+ {
2898
+ onClick: () => J((q) => !q),
2899
+ style: {
2900
+ padding: "4px 8px",
2901
+ fontSize: 12,
2902
+ border: "1px solid var(--nice-border-color, #ddd)",
2903
+ borderRadius: 4,
2904
+ background: H ? "var(--nice-warning-bg, #fef3c7)" : "var(--nice-bg-primary, #fff)",
2905
+ color: "var(--nice-text-primary, #0f172a)",
2906
+ cursor: "pointer"
2907
+ },
2908
+ title: H ? "Resume" : "Pause",
2909
+ "aria-label": H ? "Resume" : "Pause",
2910
+ children: /* @__PURE__ */ e(Me, { name: H ? "play" : "pause", size: 14 })
2911
+ }
2912
+ )
2913
+ }
2914
+ ),
2915
+ d && _e && /* @__PURE__ */ e(
2916
+ "div",
2917
+ {
2918
+ style: {
2919
+ position: "absolute",
2920
+ bottom: 50,
2921
+ right: 8,
2922
+ // A panel over the plot: an elevated surface with its own text colour, so it
2923
+ // stays readable in dark themes (a fixed light overlay left light text on it).
2924
+ background: "color-mix(in srgb, var(--nice-bg-elevated, #fff) 92%, transparent)",
2925
+ color: "var(--nice-text-primary, #0f172a)",
2926
+ border: "1px solid var(--nice-border-color, #ddd)",
2927
+ borderRadius: 4,
2928
+ padding: 8,
2929
+ fontSize: 11,
2930
+ zIndex: 10
2931
+ },
2932
+ children: Object.entries(_e).map(
2933
+ ([q, ae]) => ae ? /* @__PURE__ */ b("div", { style: { marginBottom: 4 }, children: [
2934
+ /* @__PURE__ */ e("strong", { children: q }),
2935
+ /* @__PURE__ */ b("div", { children: [
2936
+ "Min: ",
2937
+ ae.min.toFixed(2),
2938
+ " | Max: ",
2939
+ ae.max.toFixed(2)
2940
+ ] }),
2941
+ /* @__PURE__ */ b("div", { children: [
2942
+ "Avg: ",
2943
+ ae.avg.toFixed(2),
2944
+ " | Now: ",
2945
+ ae.current.toFixed(2)
2946
+ ] })
2947
+ ] }, q) : null
2948
+ )
2949
+ }
2950
+ ),
2951
+ /* @__PURE__ */ e(
2952
+ Pe,
2953
+ {
2954
+ series: be,
2955
+ categories: E,
2956
+ width: v,
2957
+ height: _,
2958
+ title: C,
2959
+ showLegend: L,
2960
+ showGrid: k,
2961
+ yAxisLabel: m,
2962
+ xAxisLabel: w,
2963
+ stacked: R,
2964
+ zoomable: I,
2965
+ crosshair: $,
2966
+ annotations: $e,
2967
+ legendInteractive: o,
2968
+ onDataPointClick: h,
2969
+ exportable: z
2970
+ }
2971
+ )
2972
+ ] });
2973
+ }
2974
+ );
2975
+ st.displayName = "NiceLiveChart";
2976
+ function Dt(t) {
2977
+ const {
2978
+ hubConnection: c,
2979
+ eventName: p = "DataPoint",
2980
+ subscribeMethod: a = "SubscribeToMetrics",
2981
+ historyMethod: i = "GetMetricHistory",
2982
+ metricName: v
2983
+ } = t;
2984
+ return {
2985
+ subscribe(_) {
2986
+ const C = (L) => {
2987
+ _(L);
2988
+ };
2989
+ return c.on(p, C), c.state === "Connected" && c.invoke(a, v).catch(() => {
2990
+ }), () => {
2991
+ c.off(p, C);
2992
+ };
2993
+ },
2994
+ async fetchHistory(_) {
2995
+ try {
2996
+ return await c.invoke(i, v, _);
2997
+ } catch {
2998
+ return [];
2999
+ }
3000
+ },
3001
+ onStatusChange(_) {
3002
+ const C = () => _(c.state === "Connected");
3003
+ return c.onclose(() => _(!1)), c.onreconnected(() => _(!0)), C(), () => {
3004
+ };
3005
+ }
3006
+ };
3007
+ }
3008
+ function Tt(t) {
3009
+ const {
3010
+ url: c,
3011
+ autoReconnect: p = !0,
3012
+ reconnectDelay: a = 3e3,
3013
+ parseMessage: i = (m) => JSON.parse(m)
3014
+ } = t;
3015
+ let v = null, _ = null, C = null, L = null;
3016
+ const k = () => {
3017
+ v = new WebSocket(c), v.onopen = () => {
3018
+ _?.(!0);
3019
+ }, v.onclose = () => {
3020
+ _?.(!1), p && (L = setTimeout(k, a));
3021
+ }, v.onerror = () => {
3022
+ v?.close();
3023
+ }, v.onmessage = (m) => {
3024
+ try {
3025
+ const w = i(m.data);
3026
+ w && C && C(w);
3027
+ } catch {
3028
+ }
3029
+ };
3030
+ };
3031
+ return {
3032
+ subscribe(m) {
3033
+ return C = m, k(), () => {
3034
+ C = null, L && clearTimeout(L), v?.close(), v = null;
3035
+ };
3036
+ },
3037
+ onStatusChange(m) {
3038
+ return _ = m, () => {
3039
+ _ = null;
3040
+ };
3041
+ }
3042
+ };
3043
+ }
3044
+ function Rt(t) {
3045
+ const { seriesNames: c, interval: p = 1e3, generateValue: a = () => Math.random() * 100 } = t;
3046
+ let i = null, v = 0;
3047
+ return {
3048
+ subscribe(_) {
3049
+ return i = setInterval(() => {
3050
+ for (const C of c)
3051
+ _({
3052
+ series: C,
3053
+ value: a(C, v),
3054
+ timestamp: Date.now()
3055
+ });
3056
+ v++;
3057
+ }, p), () => {
3058
+ i && clearInterval(i);
3059
+ };
3060
+ },
3061
+ onStatusChange(_) {
3062
+ return _(!0), () => {
3063
+ };
3064
+ }
3065
+ };
3066
+ }
3067
+ function lt(t) {
3068
+ if (!t.length)
3069
+ return { categories: [], numericFields: [], sampleValues: {} };
3070
+ const c = t[0], p = [], a = {};
3071
+ let i = null;
3072
+ for (const [_, C] of Object.entries(c))
3073
+ typeof C == "number" ? (p.push(_), a[_] = t.map((L) => Number(L[_]) || 0)) : !i && (typeof C == "string" || C instanceof Date) && (i = _);
3074
+ return { categories: i ? t.map((_) => String(_[i] || "")) : t.map((_, C) => `Item ${C + 1}`), numericFields: p, sampleValues: a };
3075
+ }
3076
+ function dt(t, c) {
3077
+ const { categories: p, numericFields: a, sampleValues: i } = lt(t);
3078
+ return { series: a.map((_, C) => ({
3079
+ name: _.replace(/([A-Z])/g, " $1").replace(/^./, (L) => L.toUpperCase()).trim(),
3080
+ data: i[_],
3081
+ type: c === "area" ? "area" : c === "line" ? "line" : "bar"
3082
+ })), categories: p };
3083
+ }
3084
+ const Bt = Se(
3085
+ function(c, p) {
3086
+ const {
3087
+ rawData: a,
3088
+ enableAI: i = !0,
3089
+ aiModel: v,
3090
+ enableAutoType: _ = !0,
3091
+ enableInsights: C = !0,
3092
+ dataDescription: L,
3093
+ onChartSuggestion: k,
3094
+ onInsights: m,
3095
+ showAIToolbar: w = !0,
3096
+ showInsightsOnLoad: R = !1,
3097
+ series: I,
3098
+ categories: $,
3099
+ ...l
3100
+ } = c, [o, h] = he("bar"), [z, g] = he(null), [S, y] = he([]), [D, r] = he(R), [B, d] = he(null), { t: M } = qe(), x = Ue(), {
3101
+ suggestChartType: O,
3102
+ generateInsights: Y,
3103
+ isLoading: V
3104
+ } = Ge(), X = i && x.isConfigured, { series: E, categories: Z } = a ? dt(a, B || o) : { series: I || [], categories: $ }, H = ie(async () => {
3105
+ if (!X || !_)
3106
+ return { type: "bar", reason: "Default", config: {} };
3107
+ const ee = a || (I?.length ? I.flatMap((U) => U.data.map((oe, P) => ({ [U.name]: oe, index: P }))) : []);
3108
+ try {
3109
+ const U = await O(ee, L), oe = {
3110
+ type: U.type,
3111
+ reason: U.reason,
3112
+ config: U.config
3113
+ };
3114
+ return g(oe), h(oe.type), k?.(oe), oe;
3115
+ } catch {
3116
+ return { type: "bar", reason: "Default fallback", config: {} };
3117
+ }
3118
+ }, [
3119
+ X,
3120
+ _,
3121
+ a,
3122
+ I,
3123
+ L,
3124
+ O,
3125
+ k
3126
+ ]), J = ie(async () => {
3127
+ if (!X || !C)
3128
+ return [];
3129
+ const ee = a || (I?.length ? I.flatMap(
3130
+ (U) => U.data.map((oe, P) => ({ [U.name]: oe, category: $?.[P] || P }))
3131
+ ) : []);
3132
+ try {
3133
+ const U = await Y(ee, B || o);
3134
+ return y(U), m?.(U), U;
3135
+ } catch {
3136
+ return [];
3137
+ }
3138
+ }, [
3139
+ X,
3140
+ C,
3141
+ a,
3142
+ I,
3143
+ $,
3144
+ o,
3145
+ B,
3146
+ Y,
3147
+ m
3148
+ ]), f = ie(
3149
+ () => B || o,
3150
+ [B, o]
3151
+ );
3152
+ Ae(() => {
3153
+ X && _ && (a?.length || I?.length) && H();
3154
+ }, [X, _, a, I]), ze(p, () => ({
3155
+ getSuggestion: H,
3156
+ generateInsights: J,
3157
+ getCurrentType: f
3158
+ }));
3159
+ const re = [
3160
+ { type: "bar", icon: "bar-chart", label: "Bar" },
3161
+ { type: "line", icon: "line-chart", label: "Line" },
3162
+ { type: "area", icon: "area-chart", label: "Area" },
3163
+ { type: "pie", icon: "pie-chart", label: "Pie" },
3164
+ { type: "donut", icon: "donut-chart", label: "Donut" },
3165
+ { type: "scatter", icon: "scatter-chart", label: "Scatter" }
3166
+ ], Q = B || o;
3167
+ return /* @__PURE__ */ b("div", { className: "nice-chart-ai", "data-testid": c["data-testid"], children: [
3168
+ w && X && /* @__PURE__ */ b("div", { className: "nice-chart-ai__toolbar", children: [
3169
+ /* @__PURE__ */ b("div", { className: "nice-chart-ai__toolbar-left", children: [
3170
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__badge", children: "AI" }),
3171
+ z && /* @__PURE__ */ b("div", { className: "nice-chart-ai__suggestion", children: [
3172
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__suggestion-icon", children: /* @__PURE__ */ e(Me, { name: "lightbulb", size: 14 }) }),
3173
+ /* @__PURE__ */ b("span", { className: "nice-chart-ai__suggestion-text", children: [
3174
+ M("chartAI.suggestedType", "Suggested:"),
3175
+ " ",
3176
+ z.type
3177
+ ] }),
3178
+ /* @__PURE__ */ b("span", { className: "nice-chart-ai__suggestion-reason", title: z.reason, children: [
3179
+ "(",
3180
+ z.reason,
3181
+ ")"
3182
+ ] })
3183
+ ] }),
3184
+ V && /* @__PURE__ */ e("span", { className: "nice-chart-ai__loading", children: M("chartAI.analyzing", "Analyzing...") })
3185
+ ] }),
3186
+ /* @__PURE__ */ e("div", { className: "nice-chart-ai__toolbar-center", children: /* @__PURE__ */ e("div", { className: "nice-chart-ai__type-selector", children: re.filter((ee) => ["bar", "line", "area"].includes(ee.type)).map(({ type: ee, icon: U, label: oe }) => /* @__PURE__ */ e(
3187
+ "button",
3188
+ {
3189
+ type: "button",
3190
+ className: `nice-chart-ai__type-btn ${Q === ee ? "nice-chart-ai__type-btn--active" : ""}`,
3191
+ onClick: () => d(ee),
3192
+ title: oe,
3193
+ children: /* @__PURE__ */ e(Me, { name: U, size: 16 })
3194
+ },
3195
+ ee
3196
+ )) }) }),
3197
+ /* @__PURE__ */ b("div", { className: "nice-chart-ai__toolbar-right", children: [
3198
+ /* @__PURE__ */ b(
3199
+ "button",
3200
+ {
3201
+ type: "button",
3202
+ className: "nice-chart-ai__auto-btn",
3203
+ onClick: () => H(),
3204
+ disabled: V,
3205
+ title: M("chartAI.autoDetect", "Auto-detect best chart type"),
3206
+ children: [
3207
+ /* @__PURE__ */ e(Me, { name: "zap", size: 14 }),
3208
+ " ",
3209
+ M("chartAI.auto", "Auto")
3210
+ ]
3211
+ }
3212
+ ),
3213
+ C && /* @__PURE__ */ b(
3214
+ "button",
3215
+ {
3216
+ type: "button",
3217
+ className: "nice-chart-ai__insights-btn",
3218
+ onClick: () => {
3219
+ S.length || J(), r(!D);
3220
+ },
3221
+ disabled: V,
3222
+ title: M("chartAI.showInsights", "Show data insights"),
3223
+ children: [
3224
+ /* @__PURE__ */ e(Me, { name: "lightbulb", size: 14 }),
3225
+ " ",
3226
+ M("chartAI.insights", "Insights")
3227
+ ]
3228
+ }
3229
+ )
3230
+ ] })
3231
+ ] }),
3232
+ /* @__PURE__ */ e("div", { className: "nice-chart-ai__chart-wrapper", children: /* @__PURE__ */ e(Pe, { series: E, categories: Z, ...l }) }),
3233
+ D && S.length > 0 && /* @__PURE__ */ b("div", { className: "nice-chart-ai__insights", children: [
3234
+ /* @__PURE__ */ b("div", { className: "nice-chart-ai__insights-header", children: [
3235
+ /* @__PURE__ */ b("h4", { children: [
3236
+ /* @__PURE__ */ e(Me, { name: "lightbulb", size: 14 }),
3237
+ " ",
3238
+ M("chartAI.dataInsights", "Data Insights")
3239
+ ] }),
3240
+ /* @__PURE__ */ e(
3241
+ "button",
3242
+ {
3243
+ type: "button",
3244
+ className: "nice-chart-ai__insights-close",
3245
+ onClick: () => r(!1),
3246
+ "aria-label": M("chartAI.close", "Close"),
3247
+ children: /* @__PURE__ */ e(Me, { name: "close", size: 14 })
3248
+ }
3249
+ )
3250
+ ] }),
3251
+ /* @__PURE__ */ e("ul", { className: "nice-chart-ai__insights-list", children: S.map((ee, U) => /* @__PURE__ */ b("li", { className: "nice-chart-ai__insight", children: [
3252
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__insight-icon", children: "•" }),
3253
+ ee
3254
+ ] }, U)) }),
3255
+ /* @__PURE__ */ e("div", { className: "nice-chart-ai__insights-footer", children: /* @__PURE__ */ b(
3256
+ "button",
3257
+ {
3258
+ type: "button",
3259
+ className: "nice-chart-ai__refresh",
3260
+ onClick: () => J(),
3261
+ disabled: V,
3262
+ children: [
3263
+ /* @__PURE__ */ e(Me, { name: "refresh", size: 14 }),
3264
+ " ",
3265
+ M("chartAI.refresh", "Refresh")
3266
+ ]
3267
+ }
3268
+ ) })
3269
+ ] }),
3270
+ D && V && /* @__PURE__ */ e("div", { className: "nice-chart-ai__insights nice-chart-ai__insights--loading", children: /* @__PURE__ */ b("div", { className: "nice-chart-ai__loading-content", children: [
3271
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__spinner" }),
3272
+ M("chartAI.generatingInsights", "Generating insights...")
3273
+ ] }) })
3274
+ ] });
3275
+ }
3276
+ ), ht = [], Ve = [
3277
+ "var(--nice-color-primary, #3b82f6)",
3278
+ "var(--nice-color-error, #ef4444)",
3279
+ "var(--nice-color-success, #22c55e)",
3280
+ "var(--nice-color-warning, #f59e0b)",
3281
+ "var(--nice-color-accent, #8b5cf6)",
3282
+ "var(--nice-color-accent-pink, #ec4899)",
3283
+ "var(--nice-color-info, #06b6d4)",
3284
+ "var(--nice-color-success, #10b981)",
3285
+ "var(--nice-color-warning, #f59e0b)",
3286
+ "var(--nice-color-accent, #6366f1)"
3287
+ ], ut = Se(
3288
+ (t, c) => {
3289
+ const { t: p } = De(), {
3290
+ levels: a = ht,
3291
+ initialLevelId: i,
3292
+ levelId: v,
3293
+ chartType: _ = "bar",
3294
+ width: C = 600,
3295
+ height: L = 400,
3296
+ showBreadcrumbs: k = !0,
3297
+ showBackButton: m = !0,
3298
+ animationDuration: w = 300,
3299
+ onLevelChange: R,
3300
+ onItemClick: I,
3301
+ colors: $ = Ve,
3302
+ showValues: l = !0,
3303
+ showLegend: o = !0,
3304
+ className: h,
3305
+ style: z,
3306
+ ...g
3307
+ } = t, S = v !== void 0, [y, D] = he(i || a[0]?.id), [r, B] = he([i || a[0]?.id]), d = ie(
3308
+ (P) => {
3309
+ const u = [];
3310
+ let s = a.find((T) => T.id === P);
3311
+ for (; s && !u.includes(s.id); ) {
3312
+ u.unshift(s.id);
3313
+ const T = s.parentId;
3314
+ s = T ? a.find((te) => te.id === T) : void 0;
3315
+ }
3316
+ return u.length > 0 ? u : [P];
3317
+ },
3318
+ [a]
3319
+ ), M = v ?? y, x = me(
3320
+ () => v !== void 0 ? d(v) : r,
3321
+ [v, r, d]
3322
+ ), [O, Y] = he(!1), [V, X] = he("in"), E = me(
3323
+ () => a.find((P) => P.id === M),
3324
+ [a, M]
3325
+ ), Z = ie(
3326
+ (P) => {
3327
+ a.find((s) => s.id === P) && (X("in"), Y(!0), setTimeout(() => {
3328
+ S || (D(P), B((s) => [...s, P])), R?.(P, S ? d(P) : [...x, P]), Y(!1);
3329
+ }, w / 2));
3330
+ },
3331
+ [a, x, w, R, S, d]
3332
+ ), H = ie(() => {
3333
+ if (x.length <= 1)
3334
+ return;
3335
+ X("out"), Y(!0);
3336
+ const P = x.slice(0, -1), u = P[P.length - 1];
3337
+ setTimeout(() => {
3338
+ S || (D(u), B(P)), R?.(u, P), Y(!1);
3339
+ }, w / 2);
3340
+ }, [x, w, R, S]), J = ie(() => {
3341
+ const P = a[0]?.id;
3342
+ P && (X("out"), Y(!0), setTimeout(() => {
3343
+ S || (D(P), B([P])), R?.(P, [P]), Y(!1);
3344
+ }, w / 2));
3345
+ }, [a, w, R, S]);
3346
+ ze(
3347
+ c,
3348
+ () => ({
3349
+ drillDown: Z,
3350
+ drillUp: H,
3351
+ resetToRoot: J,
3352
+ getCurrentLevel: () => M,
3353
+ getPath: () => x
3354
+ }),
3355
+ [Z, H, J, M, x]
3356
+ );
3357
+ const f = ie(
3358
+ (P, u) => {
3359
+ I?.(P, M);
3360
+ const s = a.find(
3361
+ (T) => T.parentId === M && T.id === P.metadata?.childLevelId
3362
+ );
3363
+ s && Z(s.id);
3364
+ },
3365
+ [M, a, Z, I]
3366
+ ), re = me(
3367
+ () => E?.data.reduce((P, u) => P + u.value, 0) || 0,
3368
+ [E]
3369
+ ), Q = me(
3370
+ () => x.map((P) => a.find((u) => u.id === P)?.label || P),
3371
+ [x, a]
3372
+ ), ee = () => {
3373
+ if (!E)
3374
+ return null;
3375
+ const P = E.data, u = Math.max(...P.map((T) => T.value)), s = Math.min(40, (L - 100) / P.length - 8);
3376
+ return /* @__PURE__ */ e("div", { className: "nice-drilldown-bars", children: P.map((T, te) => {
3377
+ const ce = T.value / u * 100;
3378
+ return /* @__PURE__ */ b(
3379
+ "div",
3380
+ {
3381
+ className: "nice-drilldown-bar-row",
3382
+ onClick: () => f(T, te),
3383
+ children: [
3384
+ /* @__PURE__ */ e("span", { className: "nice-drilldown-bar-label", children: T.label || `Item ${te + 1}` }),
3385
+ /* @__PURE__ */ e("div", { className: "nice-drilldown-bar-track", children: /* @__PURE__ */ e(
3386
+ "div",
3387
+ {
3388
+ className: "nice-drilldown-bar-fill",
3389
+ style: {
3390
+ width: `${ce}%`,
3391
+ backgroundColor: T.color || $[te % $.length],
3392
+ height: s
3393
+ }
3394
+ }
3395
+ ) }),
3396
+ l && /* @__PURE__ */ e("span", { className: "nice-drilldown-bar-value", children: T.value.toLocaleString() })
3397
+ ]
3398
+ },
3399
+ te
3400
+ );
3401
+ }) });
3402
+ }, U = () => {
3403
+ if (!E)
3404
+ return null;
3405
+ const P = E.data, u = C / 2, s = (L - 60) / 2 + 30, T = Math.min(u, s) - 40;
3406
+ let te = -90;
3407
+ const ce = P.map((j, se) => {
3408
+ const fe = j.value / re * 360, be = te + fe, $e = fe > 180 ? 1 : 0, _e = te * Math.PI / 180, q = be * Math.PI / 180, ae = u + T * Math.cos(_e), N = s + T * Math.sin(_e), G = u + T * Math.cos(q), ne = s + T * Math.sin(q), le = (te + fe / 2) * Math.PI / 180, de = u + T * 0.7 * Math.cos(le), n = s + T * 0.7 * Math.sin(le), W = `M ${u} ${s} L ${ae} ${N} A ${T} ${T} 0 ${$e} 1 ${G} ${ne} Z`;
3409
+ return te = be, {
3410
+ path: W,
3411
+ color: j.color || $[se % $.length],
3412
+ label: j.label || `Item ${se + 1}`,
3413
+ value: j.value,
3414
+ percentage: (j.value / re * 100).toFixed(1),
3415
+ labelX: de,
3416
+ labelY: n,
3417
+ item: j,
3418
+ index: se
3419
+ };
3420
+ });
3421
+ return /* @__PURE__ */ e("svg", { width: C, height: L - 40, className: "nice-drilldown-pie", children: /* @__PURE__ */ e("g", { children: ce.map((j, se) => /* @__PURE__ */ b("g", { onClick: () => f(j.item, j.index), children: [
3422
+ /* @__PURE__ */ e(
3423
+ "path",
3424
+ {
3425
+ d: j.path,
3426
+ fill: j.color,
3427
+ stroke: "white",
3428
+ strokeWidth: 2,
3429
+ className: "nice-drilldown-pie-slice"
3430
+ }
3431
+ ),
3432
+ l && parseFloat(j.percentage) > 5 && /* @__PURE__ */ b(
3433
+ "text",
3434
+ {
3435
+ x: j.labelX,
3436
+ y: j.labelY,
3437
+ textAnchor: "middle",
3438
+ dominantBaseline: "middle",
3439
+ fill: "white",
3440
+ fontSize: "12",
3441
+ fontWeight: "600",
3442
+ children: [
3443
+ j.percentage,
3444
+ "%"
3445
+ ]
3446
+ }
3447
+ )
3448
+ ] }, se)) }) });
3449
+ }, oe = () => {
3450
+ if (!E)
3451
+ return null;
3452
+ const P = E.data, u = Math.max(...P.map((te) => te.value)), s = Math.min(60, (C - 100) / P.length - 8), T = L - 100;
3453
+ return /* @__PURE__ */ e("svg", { width: C, height: L - 40, className: "nice-drilldown-columns", children: /* @__PURE__ */ b("g", { transform: "translate(50, 20)", children: [
3454
+ [0, 0.25, 0.5, 0.75, 1].map((te, ce) => /* @__PURE__ */ b("g", { children: [
3455
+ /* @__PURE__ */ e(
3456
+ "line",
3457
+ {
3458
+ x1: 0,
3459
+ y1: T * (1 - te),
3460
+ x2: C - 80,
3461
+ y2: T * (1 - te),
3462
+ stroke: "var(--nice-border-color, #e5e7eb)",
3463
+ strokeDasharray: te === 0 ? void 0 : "4"
3464
+ }
3465
+ ),
3466
+ /* @__PURE__ */ e(
3467
+ "text",
3468
+ {
3469
+ x: -8,
3470
+ y: T * (1 - te),
3471
+ textAnchor: "end",
3472
+ dominantBaseline: "middle",
3473
+ fontSize: "11",
3474
+ fill: "var(--nice-text-secondary, #6b7280)",
3475
+ children: Math.round(u * te).toLocaleString()
3476
+ }
3477
+ )
3478
+ ] }, ce)),
3479
+ P.map((te, ce) => {
3480
+ const j = te.value / u * T, se = ce * ((C - 100) / P.length) + ((C - 100) / P.length - s) / 2;
3481
+ return /* @__PURE__ */ b("g", { onClick: () => f(te, ce), children: [
3482
+ /* @__PURE__ */ e(
3483
+ "rect",
3484
+ {
3485
+ x: se,
3486
+ y: T - j,
3487
+ width: s,
3488
+ height: j,
3489
+ fill: te.color || $[ce % $.length],
3490
+ rx: 4,
3491
+ className: "nice-drilldown-column-bar"
3492
+ }
3493
+ ),
3494
+ /* @__PURE__ */ e(
3495
+ "text",
3496
+ {
3497
+ x: se + s / 2,
3498
+ y: T + 16,
3499
+ textAnchor: "middle",
3500
+ fontSize: "11",
3501
+ fill: "var(--nice-text-primary, #374151)",
3502
+ children: (te.label || `${ce + 1}`).slice(0, 10)
3503
+ }
3504
+ ),
3505
+ l && /* @__PURE__ */ e(
3506
+ "text",
3507
+ {
3508
+ x: se + s / 2,
3509
+ y: T - j - 8,
3510
+ textAnchor: "middle",
3511
+ fontSize: "11",
3512
+ fill: "var(--nice-text-primary, #374151)",
3513
+ fontWeight: "500",
3514
+ children: te.value.toLocaleString()
3515
+ }
3516
+ )
3517
+ ] }, ce);
3518
+ })
3519
+ ] }) });
3520
+ };
3521
+ return /* @__PURE__ */ b(
3522
+ "div",
3523
+ {
3524
+ className: `nice-drilldown-chart ${O ? `animating ${V}` : ""} ${h || ""}`,
3525
+ style: { width: C, ...z },
3526
+ ...g,
3527
+ children: [
3528
+ /* @__PURE__ */ b("div", { className: "nice-drilldown-header", children: [
3529
+ m && x.length > 1 && /* @__PURE__ */ b("button", { className: "nice-drilldown-back", onClick: H, children: [
3530
+ /* @__PURE__ */ e(Me, { name: "arrow-left", size: 14 }),
3531
+ " ",
3532
+ p("charts.back", "Back")
3533
+ ] }),
3534
+ k && /* @__PURE__ */ e("div", { className: "nice-drilldown-breadcrumbs", children: Q.map((P, u) => /* @__PURE__ */ b(je.Fragment, { children: [
3535
+ u > 0 && /* @__PURE__ */ e("span", { className: "nice-drilldown-separator", children: "/" }),
3536
+ /* @__PURE__ */ e(
3537
+ "span",
3538
+ {
3539
+ className: `nice-drilldown-crumb ${u === Q.length - 1 ? "active" : ""}`,
3540
+ onClick: () => {
3541
+ if (u < Q.length - 1) {
3542
+ const s = x.slice(0, u + 1), T = s[s.length - 1];
3543
+ S || (B(s), D(T)), R?.(T, s);
3544
+ }
3545
+ },
3546
+ children: P
3547
+ }
3548
+ )
3549
+ ] }, u)) })
3550
+ ] }),
3551
+ /* @__PURE__ */ b("div", { className: "nice-drilldown-content", style: { height: L - 40 }, children: [
3552
+ _ === "bar" && ee(),
3553
+ _ === "pie" && U(),
3554
+ _ === "column" && oe()
3555
+ ] }),
3556
+ o && E && /* @__PURE__ */ e("div", { className: "nice-drilldown-legend", children: E.data.map((P, u) => /* @__PURE__ */ b("div", { className: "nice-drilldown-legend-item", children: [
3557
+ /* @__PURE__ */ e(
3558
+ "span",
3559
+ {
3560
+ className: "nice-drilldown-legend-color",
3561
+ style: { backgroundColor: P.color || $[u % $.length] }
3562
+ }
3563
+ ),
3564
+ /* @__PURE__ */ e("span", { className: "nice-drilldown-legend-label", children: P.label || `Item ${u + 1}` })
3565
+ ] }, u)) }),
3566
+ /* @__PURE__ */ e("style", { children: `
3567
+ .nice-drilldown-chart {
3568
+ font-family: inherit;
3569
+ color: var(--nice-text-primary, #111827);
3570
+ background: var(--nice-bg-elevated, #ffffff);
3571
+ border-radius: 8px;
3572
+ overflow: hidden;
3573
+ }
3574
+
3575
+ .nice-drilldown-header {
3576
+ display: flex;
3577
+ align-items: center;
3578
+ gap: 12px;
3579
+ padding: 12px 16px;
3580
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
3581
+ min-height: 40px;
3582
+ }
3583
+
3584
+ .nice-drilldown-back {
3585
+ background: var(--nice-bg-secondary, #f3f4f6);
3586
+ border: none;
3587
+ padding: 6px 12px;
3588
+ border-radius: 6px;
3589
+ cursor: pointer;
3590
+ font-size: 13px;
3591
+ font-family: inherit;
3592
+ color: var(--nice-text-primary, #374151);
3593
+ transition: background 0.2s;
3594
+ }
3595
+
3596
+ .nice-drilldown-back:hover {
3597
+ background: var(--nice-hover-bg, #e5e7eb);
3598
+ }
3599
+
3600
+ .nice-drilldown-breadcrumbs {
3601
+ display: flex;
3602
+ align-items: center;
3603
+ gap: 4px;
3604
+ font-size: 13px;
3605
+ font-family: inherit;
3606
+ }
3607
+
3608
+ .nice-drilldown-separator {
3609
+ color: var(--nice-text-muted, #9ca3af);
3610
+ }
3611
+
3612
+ .nice-drilldown-crumb {
3613
+ color: var(--nice-text-secondary, #6b7280);
3614
+ cursor: pointer;
3615
+ }
3616
+
3617
+ .nice-drilldown-crumb:hover:not(.active) {
3618
+ color: var(--nice-color-primary, #3b82f6);
3619
+ }
3620
+
3621
+ .nice-drilldown-crumb.active {
3622
+ color: var(--nice-text-primary, #111827);
3623
+ font-weight: 500;
3624
+ cursor: default;
3625
+ }
3626
+
3627
+ .nice-drilldown-content {
3628
+ padding: 16px;
3629
+ transition: opacity 0.15s, transform 0.15s;
3630
+ }
3631
+
3632
+ .nice-drilldown-chart.animating .nice-drilldown-content {
3633
+ opacity: 0;
3634
+ }
3635
+
3636
+ .nice-drilldown-chart.animating.in .nice-drilldown-content {
3637
+ transform: translateX(20px);
3638
+ }
3639
+
3640
+ .nice-drilldown-chart.animating.out .nice-drilldown-content {
3641
+ transform: translateX(-20px);
3642
+ }
3643
+
3644
+ .nice-drilldown-bars {
3645
+ display: flex;
3646
+ flex-direction: column;
3647
+ gap: 8px;
3648
+ }
3649
+
3650
+ .nice-drilldown-bar-row {
3651
+ display: flex;
3652
+ align-items: center;
3653
+ gap: 12px;
3654
+ cursor: pointer;
3655
+ padding: 4px 8px;
3656
+ margin: -4px -8px;
3657
+ border-radius: 6px;
3658
+ transition: background 0.2s;
3659
+ }
3660
+
3661
+ .nice-drilldown-bar-row:hover {
3662
+ background: var(--nice-hover-bg, #f9fafb);
3663
+ }
3664
+
3665
+ .nice-drilldown-bar-label {
3666
+ width: 120px;
3667
+ font-size: 13px;
3668
+ font-family: inherit;
3669
+ color: var(--nice-text-primary, #374151);
3670
+ overflow: hidden;
3671
+ text-overflow: ellipsis;
3672
+ white-space: nowrap;
3673
+ }
3674
+
3675
+ .nice-drilldown-bar-track {
3676
+ flex: 1;
3677
+ background: var(--nice-bg-tertiary, #f3f4f6);
3678
+ border-radius: 6px;
3679
+ overflow: hidden;
3680
+ }
3681
+
3682
+ .nice-drilldown-bar-fill {
3683
+ transition: width 0.3s ease;
3684
+ border-radius: 6px;
3685
+ }
3686
+
3687
+ .nice-drilldown-bar-value {
3688
+ width: 80px;
3689
+ text-align: right;
3690
+ font-size: 13px;
3691
+ font-family: inherit;
3692
+ font-weight: 500;
3693
+ color: var(--nice-text-primary, #111827);
3694
+ }
3695
+
3696
+ .nice-drilldown-pie-slice {
3697
+ cursor: pointer;
3698
+ transition: transform 0.2s, opacity 0.2s;
3699
+ transform-origin: center;
3700
+ }
3701
+
3702
+ .nice-drilldown-pie-slice:hover {
3703
+ opacity: 0.85;
3704
+ transform: scale(1.02);
3705
+ }
3706
+
3707
+ .nice-drilldown-column-bar {
3708
+ cursor: pointer;
3709
+ transition: opacity 0.2s;
3710
+ }
3711
+
3712
+ .nice-drilldown-column-bar:hover {
3713
+ opacity: 0.8;
3714
+ }
3715
+
3716
+ .nice-drilldown-legend {
3717
+ display: flex;
3718
+ flex-wrap: wrap;
3719
+ gap: 16px;
3720
+ padding: 12px 16px;
3721
+ border-top: 1px solid var(--nice-border-color, #e5e7eb);
3722
+ }
3723
+
3724
+ .nice-drilldown-legend-item {
3725
+ display: flex;
3726
+ align-items: center;
3727
+ gap: 6px;
3728
+ }
3729
+
3730
+ .nice-drilldown-legend-color {
3731
+ width: 12px;
3732
+ height: 12px;
3733
+ border-radius: 3px;
3734
+ }
3735
+
3736
+ .nice-drilldown-legend-label {
3737
+ font-size: 12px;
3738
+ font-family: inherit;
3739
+ color: var(--nice-text-secondary, #6b7280);
3740
+ }
3741
+ ` })
3742
+ ]
3743
+ }
3744
+ );
3745
+ }
3746
+ );
3747
+ ut.displayName = "NiceDrillDownChart";
3748
+ const ft = [
3749
+ "var(--nice-info-bg, #dbeafe)",
3750
+ "var(--nice-color-primary-light, #93c5fd)",
3751
+ "var(--nice-color-primary, #3b82f6)",
3752
+ "var(--nice-color-primary-active, #1d4ed8)",
3753
+ "var(--nice-color-primary, #6366f1)"
3754
+ ], Et = ({
3755
+ type: t = "choropleth",
3756
+ regions: c = [],
3757
+ bubbles: p = [],
3758
+ width: a = 800,
3759
+ height: i = 500,
3760
+ viewBox: v = "0 0 800 500",
3761
+ colorScale: _,
3762
+ // The documented alias of `colorScale`. It was never destructured, so it did nothing
3763
+ // and fell through `...rest` onto the root div (React warned about an unknown prop).
3764
+ colorRange: C,
3765
+ minValue: L,
3766
+ maxValue: k,
3767
+ showTooltip: m = !0,
3768
+ showLegend: w = !0,
3769
+ onRegionClick: R,
3770
+ onBubbleClick: I,
3771
+ onRegionHover: $,
3772
+ title: l,
3773
+ mapSvg: o,
3774
+ zoomable: h = !1,
3775
+ className: z,
3776
+ style: g,
3777
+ ...S
3778
+ }) => {
3779
+ const y = _ ?? C ?? ft, { t: D } = De(), [r, B] = he(null), [d, M] = he(1), [x, O] = he({ x: 0, y: 0 }), Y = ve(null), V = ve(!1), X = ve({ x: 0, y: 0 }), E = L ?? Math.min(...c.map((u) => u.value), ...p.map((u) => u.value)), Z = k ?? Math.max(...c.map((u) => u.value), ...p.map((u) => u.value)), H = ie(
3780
+ (u) => {
3781
+ const s = (u - E) / (Z - E), T = Math.min(Math.floor(s * y.length), y.length - 1);
3782
+ return y[Math.max(0, T)];
3783
+ },
3784
+ [E, Z, y]
3785
+ ), J = ie(
3786
+ (u) => {
3787
+ if (!m || !r)
3788
+ return;
3789
+ const s = Y.current?.getBoundingClientRect();
3790
+ s && B(
3791
+ (T) => T ? { ...T, x: u.clientX - s.left, y: u.clientY - s.top } : null
3792
+ );
3793
+ },
3794
+ [m, r]
3795
+ ), f = ie(
3796
+ (u, s) => {
3797
+ const T = Y.current?.getBoundingClientRect();
3798
+ T && m && B({
3799
+ x: s.clientX - T.left,
3800
+ y: s.clientY - T.top,
3801
+ content: `${u.name}: ${u.value.toLocaleString()}`
3802
+ }), $?.(u);
3803
+ },
3804
+ [m, $]
3805
+ ), re = ie(() => {
3806
+ B(null), $?.(null);
3807
+ }, [$]), Q = ie(
3808
+ (u) => {
3809
+ if (!h)
3810
+ return;
3811
+ u.preventDefault();
3812
+ const s = u.deltaY > 0 ? 0.9 : 1.1;
3813
+ M((T) => Math.min(Math.max(T * s, 0.5), 4));
3814
+ },
3815
+ [h]
3816
+ ), ee = ie(
3817
+ (u) => {
3818
+ h && (V.current = !0, X.current = { x: u.clientX - x.x, y: u.clientY - x.y });
3819
+ },
3820
+ [h, x]
3821
+ ), U = ie(() => {
3822
+ V.current = !1;
3823
+ }, []), oe = ie((u) => {
3824
+ V.current && O({
3825
+ x: u.clientX - X.current.x,
3826
+ y: u.clientY - X.current.y
3827
+ });
3828
+ }, []), P = me(() => c.length > 0 ? c : [
3829
+ {
3830
+ id: "mazowieckie",
3831
+ name: "Mazowieckie",
3832
+ value: 100,
3833
+ path: "M400,200 L450,200 L460,250 L420,280 L380,250 Z"
3834
+ },
3835
+ { id: "slaskie", name: "Śląskie", value: 80, path: "M350,280 L400,280 L390,330 L340,320 Z" },
3836
+ {
3837
+ id: "wielkopolskie",
3838
+ name: "Wielkopolskie",
3839
+ value: 70,
3840
+ path: "M300,200 L350,200 L360,260 L310,270 L280,230 Z"
3841
+ }
3842
+ ], [c]);
3843
+ return /* @__PURE__ */ b("div", { className: `nice-map-chart ${z || ""}`, style: { width: a, ...g }, ...S, children: [
3844
+ l && /* @__PURE__ */ e("div", { className: "nice-map-title", children: l }),
3845
+ /* @__PURE__ */ e(
3846
+ "svg",
3847
+ {
3848
+ ref: Y,
3849
+ width: a,
3850
+ height: i,
3851
+ viewBox: v,
3852
+ className: "nice-map-svg",
3853
+ onWheel: Q,
3854
+ onMouseDown: ee,
3855
+ onMouseUp: U,
3856
+ onMouseLeave: U,
3857
+ onMouseMove: (u) => {
3858
+ J(u), oe(u);
3859
+ },
3860
+ children: /* @__PURE__ */ b("g", { transform: `translate(${x.x}, ${x.y}) scale(${d})`, children: [
3861
+ o && /* @__PURE__ */ e("g", { dangerouslySetInnerHTML: { __html: o } }),
3862
+ t === "choropleth" && P.map((u) => /* @__PURE__ */ e(
3863
+ "path",
3864
+ {
3865
+ d: u.path,
3866
+ fill: u.color || H(u.value),
3867
+ stroke: "var(--nice-bg-primary, #ffffff)",
3868
+ strokeWidth: 1,
3869
+ className: "nice-map-region",
3870
+ onClick: () => R?.(u),
3871
+ onMouseEnter: (s) => f(u, s),
3872
+ onMouseLeave: re
3873
+ },
3874
+ u.id
3875
+ )),
3876
+ (t === "bubble" || p.length > 0) && p.map((u) => {
3877
+ const s = Math.sqrt((u.value - E) / (Z - E)) * 30 + 5;
3878
+ return /* @__PURE__ */ e(
3879
+ "circle",
3880
+ {
3881
+ cx: u.lng,
3882
+ cy: u.lat,
3883
+ r: s,
3884
+ fill: u.color || "var(--nice-color-primary, #3b82f6)",
3885
+ fillOpacity: 0.7,
3886
+ stroke: "var(--nice-bg-primary, #ffffff)",
3887
+ strokeWidth: 1,
3888
+ className: "nice-map-bubble",
3889
+ onClick: () => I?.(u),
3890
+ onMouseEnter: (T) => {
3891
+ const te = Y.current?.getBoundingClientRect();
3892
+ te && m && B({
3893
+ x: T.clientX - te.left,
3894
+ y: T.clientY - te.top,
3895
+ content: `${u.label || u.id}: ${u.value.toLocaleString()}`
3896
+ });
3897
+ },
3898
+ onMouseLeave: re,
3899
+ children: u.label && /* @__PURE__ */ b("title", { children: [
3900
+ u.label,
3901
+ ": ",
3902
+ u.value
3903
+ ] })
3904
+ },
3905
+ u.id
3906
+ );
3907
+ })
3908
+ ] })
3909
+ }
3910
+ ),
3911
+ r && /* @__PURE__ */ e("div", { className: "nice-map-tooltip", style: { left: r.x + 10, top: r.y - 30 }, children: r.content }),
3912
+ w && /* @__PURE__ */ b("div", { className: "nice-map-legend", children: [
3913
+ /* @__PURE__ */ e("span", { className: "nice-map-legend-title", children: D("charts.value", "Value") }),
3914
+ /* @__PURE__ */ e("div", { className: "nice-map-legend-scale", children: y.map((u, s) => /* @__PURE__ */ e("div", { className: "nice-map-legend-item", style: { backgroundColor: u } }, s)) }),
3915
+ /* @__PURE__ */ b("div", { className: "nice-map-legend-labels", children: [
3916
+ /* @__PURE__ */ e("span", { children: E.toLocaleString() }),
3917
+ /* @__PURE__ */ e("span", { children: Z.toLocaleString() })
3918
+ ] })
3919
+ ] }),
3920
+ /* @__PURE__ */ e("style", { children: `
3921
+ .nice-map-chart {
3922
+ font-family: system-ui, -apple-system, sans-serif;
3923
+ background: var(--nice-bg-primary, #ffffff);
3924
+ border-radius: var(--nice-radius-lg, 8px);
3925
+ overflow: hidden;
3926
+ position: relative;
3927
+ }
3928
+
3929
+ .nice-map-title {
3930
+ padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
3931
+ font-size: 16px;
3932
+ font-weight: 600;
3933
+ color: var(--nice-text-primary, #0f172a);
3934
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
3935
+ }
3936
+
3937
+ .nice-map-svg {
3938
+ display: block;
3939
+ cursor: grab;
3940
+ }
3941
+
3942
+ .nice-map-svg:active {
3943
+ cursor: grabbing;
3944
+ }
3945
+
3946
+ .nice-map-region {
3947
+ cursor: pointer;
3948
+ transition: opacity 0.2s, stroke-width 0.2s;
3949
+ }
3950
+
3951
+ .nice-map-region:hover {
3952
+ opacity: 0.8;
3953
+ stroke-width: 2;
3954
+ }
3955
+
3956
+ .nice-map-bubble {
3957
+ cursor: pointer;
3958
+ transition: transform 0.2s, opacity 0.2s;
3959
+ }
3960
+
3961
+ .nice-map-bubble:hover {
3962
+ opacity: 1;
3963
+ transform: scale(1.1);
3964
+ }
3965
+
3966
+ .nice-map-tooltip {
3967
+ position: absolute;
3968
+ /* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
3969
+ fill and the label uses --nice-text-inverse, so the pair flips together. */
3970
+ background: var(--nice-text-primary, #0f172a);
3971
+ color: var(--nice-text-inverse, #ffffff);
3972
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
3973
+ border-radius: var(--nice-radius-sm, 4px);
3974
+ font-size: 12px;
3975
+ pointer-events: none;
3976
+ z-index: 10;
3977
+ white-space: nowrap;
3978
+ }
3979
+
3980
+ .nice-map-legend {
3981
+ position: absolute;
3982
+ right: 16px;
3983
+ bottom: 16px;
3984
+ background: var(--nice-bg-elevated, #ffffff);
3985
+ padding: var(--nice-space-3, 12px);
3986
+ border-radius: var(--nice-radius-md, 6px);
3987
+ box-shadow: 0 2px 8px var(--nice-overlay-10, color-mix(in srgb, var(--nice-text-primary, #000) 10%, transparent));
3988
+ }
3989
+
3990
+ .nice-map-legend-title {
3991
+ display: block;
3992
+ font-size: 11px;
3993
+ color: var(--nice-text-secondary, #475569);
3994
+ margin-bottom: var(--nice-space-1-5, 6px);
3995
+ }
3996
+
3997
+ .nice-map-legend-scale {
3998
+ display: flex;
3999
+ height: 12px;
4000
+ border-radius: var(--nice-radius-sm, 2px);
4001
+ overflow: hidden;
4002
+ }
4003
+
4004
+ .nice-map-legend-item {
4005
+ flex: 1;
4006
+ min-width: 24px;
4007
+ }
4008
+
4009
+ .nice-map-legend-labels {
4010
+ display: flex;
4011
+ justify-content: space-between;
4012
+ font-size: 10px;
4013
+ color: var(--nice-text-secondary, #475569);
4014
+ margin-top: var(--nice-space-1, 4px);
4015
+ }
4016
+ ` })
4017
+ ] });
4018
+ }, Pt = ({
4019
+ nodes: t,
4020
+ links: c,
4021
+ width: p = 800,
4022
+ height: a = 500,
4023
+ nodeWidth: i = 20,
4024
+ nodePadding: v = 10,
4025
+ showValues: _ = !0,
4026
+ showTooltip: C = !0,
4027
+ onNodeClick: L,
4028
+ onLinkClick: k,
4029
+ title: m,
4030
+ className: w,
4031
+ style: R,
4032
+ ...I
4033
+ }) => {
4034
+ const [$, l] = he(null), o = ve(null), h = me(() => {
4035
+ const g = /* @__PURE__ */ new Map();
4036
+ t.forEach((f) => g.set(f.id, f));
4037
+ const S = new Set(c.map((f) => f.target)), y = new Set(c.map((f) => f.source)), D = [], r = /* @__PURE__ */ new Map(), B = t.filter((f) => y.has(f.id) && !S.has(f.id));
4038
+ B.length > 0 && (D.push(B.map((f) => f.id)), B.forEach((f) => r.set(f.id, 0)));
4039
+ const d = t.filter((f) => y.has(f.id) && S.has(f.id));
4040
+ d.length > 0 && (D.push(d.map((f) => f.id)), d.forEach((f) => r.set(f.id, 1)));
4041
+ const M = t.filter((f) => !y.has(f.id) && S.has(f.id));
4042
+ M.length > 0 && (D.push(M.map((f) => f.id)), M.forEach((f) => r.set(f.id, 2))), D.length === 0 && (D.push(t.map((f) => f.id)), t.forEach((f) => r.set(f.id, 0)));
4043
+ const x = /* @__PURE__ */ new Map();
4044
+ c.forEach((f) => {
4045
+ x.set(f.source, (x.get(f.source) || 0) + f.value), x.set(f.target, (x.get(f.target) || 0) + f.value);
4046
+ });
4047
+ const O = 40, Y = p - O * 2, V = a - O * 2, X = D.length > 1 ? Y / (D.length - 1) : Y, E = /* @__PURE__ */ new Map();
4048
+ Math.max(...Array.from(x.values())), D.forEach((f, re) => {
4049
+ const Q = f.reduce((oe, P) => oe + (x.get(P) || 0), 0), ee = (V - (f.length - 1) * v) / Q;
4050
+ let U = O;
4051
+ f.forEach((oe) => {
4052
+ const u = (x.get(oe) || 0) * ee, s = O + re * X;
4053
+ E.set(oe, { x: s, y: U, height: u }), U += u + v;
4054
+ });
4055
+ });
4056
+ const Z = [], H = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new Map();
4057
+ return c.forEach((f) => {
4058
+ const re = E.get(f.source), Q = E.get(f.target);
4059
+ if (!re || !Q)
4060
+ return;
4061
+ const ee = x.get(f.source) || 1;
4062
+ x.get(f.target);
4063
+ const U = f.value / ee * re.height, oe = re.y + (H.get(f.source) || 0), P = Q.y + (J.get(f.target) || 0);
4064
+ H.set(f.source, (H.get(f.source) || 0) + U), J.set(f.target, (J.get(f.target) || 0) + U);
4065
+ const u = re.x + i, s = Q.x, T = (s - u) * 0.5, te = `
4066
+ M ${u} ${oe}
4067
+ C ${u + T} ${oe},
4068
+ ${s - T} ${P},
4069
+ ${s} ${P}
4070
+ L ${s} ${P + U}
4071
+ C ${s - T} ${P + U},
4072
+ ${u + T} ${oe + U},
4073
+ ${u} ${oe + U}
4074
+ Z
4075
+ `;
4076
+ Z.push({
4077
+ path: te,
4078
+ link: f,
4079
+ sourcePos: re,
4080
+ targetPos: Q
4081
+ });
4082
+ }), { nodePositions: E, linkPaths: Z, nodeMap: g, nodeValues: x };
4083
+ }, [t, c, p, a, i, v]), z = ie(
4084
+ (g, S) => {
4085
+ const y = o.current?.getBoundingClientRect();
4086
+ y && C && l({
4087
+ x: S.clientX - y.left,
4088
+ y: S.clientY - y.top,
4089
+ content: g
4090
+ });
4091
+ },
4092
+ [C]
4093
+ );
4094
+ return /* @__PURE__ */ b("div", { className: `nice-sankey-chart ${w || ""}`, style: { width: p, ...R }, ...I, children: [
4095
+ m && /* @__PURE__ */ e("div", { className: "nice-sankey-title", children: m }),
4096
+ /* @__PURE__ */ b("svg", { ref: o, width: p, height: a, className: "nice-sankey-svg", children: [
4097
+ /* @__PURE__ */ e("defs", { children: h.linkPaths.map((g, S) => /* @__PURE__ */ b("linearGradient", { id: `sankey-gradient-${S}`, x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: [
4098
+ /* @__PURE__ */ e(
4099
+ "stop",
4100
+ {
4101
+ offset: "0%",
4102
+ stopColor: h.nodeMap.get(g.link.source)?.color || "var(--nice-color-primary, #3b82f6)"
4103
+ }
4104
+ ),
4105
+ /* @__PURE__ */ e(
4106
+ "stop",
4107
+ {
4108
+ offset: "100%",
4109
+ stopColor: h.nodeMap.get(g.link.target)?.color || "var(--nice-color-error, #ef4444)"
4110
+ }
4111
+ )
4112
+ ] }, S)) }),
4113
+ /* @__PURE__ */ e("g", { className: "nice-sankey-links", children: h.linkPaths.map((g, S) => /* @__PURE__ */ e(
4114
+ "path",
4115
+ {
4116
+ d: g.path,
4117
+ fill: g.link.color || `url(#sankey-gradient-${S})`,
4118
+ fillOpacity: 0.4,
4119
+ className: "nice-sankey-link",
4120
+ onClick: () => k?.(g.link),
4121
+ onMouseEnter: (y) => z(
4122
+ `${h.nodeMap.get(g.link.source)?.name} → ${h.nodeMap.get(g.link.target)?.name}: ${g.link.value.toLocaleString()}`,
4123
+ y
4124
+ ),
4125
+ onMouseLeave: () => l(null)
4126
+ },
4127
+ S
4128
+ )) }),
4129
+ /* @__PURE__ */ e("g", { className: "nice-sankey-nodes", children: Array.from(h.nodePositions.entries()).map(([g, S]) => {
4130
+ const y = h.nodeMap.get(g);
4131
+ return y ? /* @__PURE__ */ b("g", { children: [
4132
+ /* @__PURE__ */ e(
4133
+ "rect",
4134
+ {
4135
+ x: S.x,
4136
+ y: S.y,
4137
+ width: i,
4138
+ height: S.height,
4139
+ fill: y.color || "var(--nice-color-primary, #3b82f6)",
4140
+ rx: 2,
4141
+ className: "nice-sankey-node",
4142
+ onClick: () => L?.(y),
4143
+ onMouseEnter: (D) => z(
4144
+ `${y.label ?? y.name ?? y.id}: ${h.nodeValues.get(g)?.toLocaleString() || 0}`,
4145
+ D
4146
+ ),
4147
+ onMouseLeave: () => l(null)
4148
+ }
4149
+ ),
4150
+ /* @__PURE__ */ b(
4151
+ "text",
4152
+ {
4153
+ x: S.x + i + 6,
4154
+ y: S.y + S.height / 2,
4155
+ dominantBaseline: "middle",
4156
+ fontSize: "12",
4157
+ fill: "var(--nice-text-primary, #0f172a)",
4158
+ children: [
4159
+ y.label ?? y.name ?? y.id,
4160
+ _ && ` (${h.nodeValues.get(g)?.toLocaleString() || 0})`
4161
+ ]
4162
+ }
4163
+ )
4164
+ ] }, g) : null;
4165
+ }) })
4166
+ ] }),
4167
+ $ && /* @__PURE__ */ e("div", { className: "nice-sankey-tooltip", style: { left: $.x + 10, top: $.y - 30 }, children: $.content }),
4168
+ /* @__PURE__ */ e("style", { children: `
4169
+ .nice-sankey-chart {
4170
+ font-family: system-ui, -apple-system, sans-serif;
4171
+ background: var(--nice-bg-primary, #ffffff);
4172
+ border-radius: var(--nice-radius-lg, 8px);
4173
+ position: relative;
4174
+ }
4175
+
4176
+ .nice-sankey-title {
4177
+ padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
4178
+ font-size: 16px;
4179
+ font-weight: 600;
4180
+ color: var(--nice-text-primary, #0f172a);
4181
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
4182
+ }
4183
+
4184
+ .nice-sankey-link {
4185
+ cursor: pointer;
4186
+ transition: fill-opacity 0.2s;
4187
+ }
4188
+
4189
+ .nice-sankey-link:hover {
4190
+ fill-opacity: 0.7;
4191
+ }
4192
+
4193
+ .nice-sankey-node {
4194
+ cursor: pointer;
4195
+ transition: opacity 0.2s;
4196
+ }
4197
+
4198
+ .nice-sankey-node:hover {
4199
+ opacity: 0.8;
4200
+ }
4201
+
4202
+ .nice-sankey-tooltip {
4203
+ position: absolute;
4204
+ /* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
4205
+ fill and the label uses --nice-text-inverse, so the pair flips together. */
4206
+ background: var(--nice-text-primary, #0f172a);
4207
+ color: var(--nice-text-inverse, #ffffff);
4208
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
4209
+ border-radius: var(--nice-radius-sm, 4px);
4210
+ font-size: 12px;
4211
+ pointer-events: none;
4212
+ z-index: 10;
4213
+ white-space: nowrap;
4214
+ }
4215
+ ` })
4216
+ ] });
4217
+ }, pt = Se(
4218
+ (t, c) => {
4219
+ const { t: p } = De(), {
4220
+ initialData: a,
4221
+ data: i,
4222
+ maxPoints: v = 60,
4223
+ updateInterval: _ = 1e3,
4224
+ fetchData: C,
4225
+ width: L = 600,
4226
+ height: k = 200,
4227
+ chartType: m = "line",
4228
+ color: w = "var(--nice-color-primary, #3b82f6)",
4229
+ showGrid: R = !0,
4230
+ showTimeAxis: I = !0,
4231
+ showCurrentValue: $ = !0,
4232
+ title: l,
4233
+ valueFormatter: o = (j) => j.toFixed(2),
4234
+ timeFormatter: h = (j) => new Date(j).toLocaleTimeString(),
4235
+ onDataUpdate: z,
4236
+ paused: g,
4237
+ className: S,
4238
+ style: y,
4239
+ ...D
4240
+ } = t, [r, B] = he(a ?? i ?? []), [d, M] = he(g || !1), x = ve(void 0);
4241
+ Ae(() => {
4242
+ g !== void 0 && M(g);
4243
+ }, [g]), Ae(() => {
4244
+ if (d || !C)
4245
+ return;
4246
+ const j = async () => {
4247
+ try {
4248
+ const se = await C();
4249
+ B((fe) => {
4250
+ const be = [...fe, se].slice(-v);
4251
+ return z?.(be), be;
4252
+ });
4253
+ } catch (se) {
4254
+ console.error("Failed to fetch realtime data:", se);
4255
+ }
4256
+ };
4257
+ return x.current = setInterval(j, _), () => {
4258
+ x.current && clearInterval(x.current);
4259
+ };
4260
+ }, [d, C, _, v, z]);
4261
+ const O = ie(
4262
+ (j) => {
4263
+ B((se) => {
4264
+ const fe = [...se, j].slice(-v);
4265
+ return z?.(fe), fe;
4266
+ });
4267
+ },
4268
+ [v, z]
4269
+ ), Y = ie(() => {
4270
+ B([]), z?.([]);
4271
+ }, [z]), V = ie(() => M(!0), []), X = ie(() => M(!1), []);
4272
+ ze(
4273
+ c,
4274
+ () => ({
4275
+ addDataPoint: O,
4276
+ clearData: Y,
4277
+ pause: V,
4278
+ resume: X,
4279
+ getData: () => r
4280
+ }),
4281
+ [O, Y, r]
4282
+ );
4283
+ const E = { top: 20, right: 60, bottom: I ? 40 : 20, left: 50 }, Z = L - E.left - E.right, H = k - E.top - E.bottom, J = r.map((j) => j.value), f = J.length ? Math.min(...J) : 0, re = J.length ? Math.max(...J) : 100, ee = (re - f || 1) * 0.1, U = f - ee, P = re + ee - U, u = (j) => {
4284
+ const se = C ? v - 1 : Math.max(1, r.length - 1);
4285
+ return E.left + j / se * Z;
4286
+ }, s = (j) => E.top + H - (j - U) / P * H, T = r.map((j, se) => `${u(se)},${s(j.value)}`).join(" "), te = r.length > 0 ? `M ${u(0)},${E.top + H} L ${T} L ${u(r.length - 1)},${E.top + H} Z` : "", ce = r.length > 0 ? r[r.length - 1].value : null;
4287
+ return /* @__PURE__ */ b(
4288
+ "div",
4289
+ {
4290
+ className: `nice-realtime-chart ${S || ""}`,
4291
+ style: { width: L, ...y },
4292
+ ...D,
4293
+ children: [
4294
+ /* @__PURE__ */ b("div", { className: "nice-realtime-header", children: [
4295
+ /* @__PURE__ */ e("span", { className: "nice-realtime-title", children: l }),
4296
+ /* @__PURE__ */ b("div", { className: "nice-realtime-controls", children: [
4297
+ /* @__PURE__ */ b("span", { className: `nice-realtime-status ${d ? "paused" : "live"}`, children: [
4298
+ /* @__PURE__ */ e("span", { className: "nice-realtime-status-dot" }),
4299
+ /* @__PURE__ */ e("span", { children: d ? p("charts.paused", "Paused") : p("charts.live", "Live") })
4300
+ ] }),
4301
+ /* @__PURE__ */ e(
4302
+ "button",
4303
+ {
4304
+ className: `nice-realtime-btn ${d ? "paused" : ""}`,
4305
+ onClick: () => M(!d),
4306
+ "aria-label": d ? p("charts.resume", "Resume") : p("charts.pause", "Pause"),
4307
+ children: /* @__PURE__ */ e(Me, { name: d ? "play" : "pause", size: 14 })
4308
+ }
4309
+ ),
4310
+ $ && ce !== null && /* @__PURE__ */ e("span", { className: "nice-realtime-value", children: o(ce) })
4311
+ ] })
4312
+ ] }),
4313
+ /* @__PURE__ */ b("svg", { width: L, height: k, className: "nice-realtime-svg", children: [
4314
+ R && /* @__PURE__ */ e("g", { className: "nice-realtime-grid", children: [0, 0.25, 0.5, 0.75, 1].map((j, se) => {
4315
+ const fe = E.top + H * (1 - j), be = U + P * j;
4316
+ return /* @__PURE__ */ b("g", { children: [
4317
+ /* @__PURE__ */ e(
4318
+ "line",
4319
+ {
4320
+ x1: E.left,
4321
+ y1: fe,
4322
+ x2: L - E.right,
4323
+ y2: fe,
4324
+ stroke: "var(--nice-border-color, #e5e7eb)",
4325
+ strokeDasharray: j === 0 ? void 0 : "3"
4326
+ }
4327
+ ),
4328
+ /* @__PURE__ */ e(
4329
+ "text",
4330
+ {
4331
+ x: E.left - 8,
4332
+ y: fe,
4333
+ textAnchor: "end",
4334
+ dominantBaseline: "middle",
4335
+ fontSize: "10",
4336
+ fill: "var(--nice-text-secondary, #6b7280)",
4337
+ children: Math.round(be).toLocaleString()
4338
+ }
4339
+ )
4340
+ ] }, se);
4341
+ }) }),
4342
+ m === "area" && r.length > 0 && /* @__PURE__ */ e("path", { d: te, fill: w, fillOpacity: 0.2 }),
4343
+ r.length > 1 && /* @__PURE__ */ e(
4344
+ "polyline",
4345
+ {
4346
+ points: T,
4347
+ fill: "none",
4348
+ stroke: w,
4349
+ strokeWidth: 2,
4350
+ strokeLinecap: "round",
4351
+ strokeLinejoin: "round"
4352
+ }
4353
+ ),
4354
+ r.length > 0 && /* @__PURE__ */ e(
4355
+ "circle",
4356
+ {
4357
+ cx: u(r.length - 1),
4358
+ cy: s(r[r.length - 1].value),
4359
+ r: 3,
4360
+ fill: w,
4361
+ className: "nice-realtime-point"
4362
+ }
4363
+ ),
4364
+ I && r.length > 0 && /* @__PURE__ */ e("g", { className: "nice-realtime-time-axis", children: Array.from(
4365
+ new Set([0, Math.floor(r.length / 2), r.length - 1].filter((j) => r[j]))
4366
+ ).map((j) => /* @__PURE__ */ e(
4367
+ "text",
4368
+ {
4369
+ x: u(j),
4370
+ y: k - 8,
4371
+ textAnchor: "middle",
4372
+ fontSize: "10",
4373
+ fill: "var(--nice-text-secondary, #6b7280)",
4374
+ children: h(r[j].timestamp)
4375
+ },
4376
+ `tx-${j}`
4377
+ )) })
4378
+ ] }),
4379
+ /* @__PURE__ */ e("style", { children: `
4380
+ .nice-realtime-chart {
4381
+ font-family: inherit;
4382
+ color: var(--nice-text-primary, #111827);
4383
+ background: var(--nice-bg-elevated, #ffffff);
4384
+ border-radius: 8px;
4385
+ position: relative;
4386
+ }
4387
+
4388
+ .nice-realtime-header {
4389
+ display: flex;
4390
+ justify-content: space-between;
4391
+ align-items: center;
4392
+ padding: 12px 16px;
4393
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
4394
+ }
4395
+
4396
+ .nice-realtime-title {
4397
+ font-size: 14px;
4398
+ font-weight: 600;
4399
+ color: var(--nice-text-primary, #111827);
4400
+ }
4401
+
4402
+ .nice-realtime-controls {
4403
+ display: flex;
4404
+ align-items: center;
4405
+ gap: 12px;
4406
+ }
4407
+
4408
+ .nice-realtime-btn {
4409
+ background: none;
4410
+ border: none;
4411
+ cursor: pointer;
4412
+ font-size: 16px;
4413
+ padding: 4px;
4414
+ font-family: inherit;
4415
+ color: inherit;
4416
+ }
4417
+
4418
+ .nice-realtime-value {
4419
+ font-size: 18px;
4420
+ font-weight: 600;
4421
+ color: ${w};
4422
+ font-variant-numeric: tabular-nums;
4423
+ }
4424
+
4425
+ /* Static current-value dot — no pulsing animation (was distracting) */
4426
+
4427
+ .nice-realtime-status {
4428
+ display: inline-flex;
4429
+ align-items: center;
4430
+ gap: 6px;
4431
+ font-size: 11px;
4432
+ font-family: inherit;
4433
+ color: var(--nice-text-secondary, #6b7280);
4434
+ background: var(--nice-bg-secondary, #f3f4f6);
4435
+ padding: 2px 10px;
4436
+ border-radius: 999px;
4437
+ }
4438
+
4439
+ .nice-realtime-status-dot {
4440
+ width: 8px;
4441
+ height: 8px;
4442
+ border-radius: 50%;
4443
+ background: var(--nice-color-success, #22c55e);
4444
+ }
4445
+
4446
+ .nice-realtime-status.paused .nice-realtime-status-dot {
4447
+ background: var(--nice-color-warning, #f59e0b);
4448
+ }
4449
+
4450
+ .nice-realtime-status.live .nice-realtime-status-dot {
4451
+ animation: live-pulse 2s ease-in-out infinite;
4452
+ }
4453
+
4454
+ @keyframes live-pulse {
4455
+ 0%, 100% { opacity: 1; }
4456
+ 50% { opacity: 0.4; }
4457
+ }
4458
+ ` })
4459
+ ]
4460
+ }
4461
+ );
4462
+ }
4463
+ );
4464
+ pt.displayName = "NiceRealtimeChart";
4465
+ const Wt = ({
4466
+ data: t,
4467
+ width: c = 600,
4468
+ height: p = 400,
4469
+ showLabels: a = !0,
4470
+ showValues: i = !0,
4471
+ onNodeClick: v,
4472
+ drilldownEnabled: _ = !0,
4473
+ colors: C = Ve,
4474
+ tilePadding: L = 2,
4475
+ className: k,
4476
+ style: m,
4477
+ ...w
4478
+ }) => {
4479
+ const { t: R } = De(), I = me(() => Array.isArray(t) ? {
4480
+ id: "root",
4481
+ name: "Root",
4482
+ value: t.reduce((M, x) => M + (x.value || 0), 0),
4483
+ children: t.map((M, x) => ({
4484
+ id: `${x}`,
4485
+ name: M.label ?? M.name ?? `Item ${x + 1}`,
4486
+ value: M.value,
4487
+ color: M.color
4488
+ }))
4489
+ } : t, [t]), [$, l] = he(I), [o, h] = he([I.name]), [z, g] = he(null), S = ve(null), y = me(() => {
4490
+ const x = $.children || [];
4491
+ if (x.length === 0)
4492
+ return [];
4493
+ const O = x.reduce((f, re) => f + re.value, 0), Y = x.map((f) => ({
4494
+ node: f,
4495
+ area: f.value / O * c * p
4496
+ }));
4497
+ Y.sort((f, re) => re.area - f.area);
4498
+ const V = [];
4499
+ let X = 0, E = 0, Z = c, H = p, J = 0;
4500
+ for (; J < Y.length; ) {
4501
+ const f = Z < H;
4502
+ let re = 0, Q = [];
4503
+ const ee = f ? H : Z;
4504
+ for (let P = J; P < Y.length; P++) {
4505
+ const u = [...Q, Y[P]], s = u.reduce((te, ce) => te + ce.area, 0), T = D(u, s, ee);
4506
+ if (Q.length === 0)
4507
+ Q = u, re = s;
4508
+ else {
4509
+ const te = D(Q, re, ee);
4510
+ if (T <= te)
4511
+ Q = u, re = s;
4512
+ else
4513
+ break;
4514
+ }
4515
+ }
4516
+ const U = re / ee;
4517
+ let oe = 0;
4518
+ Q.forEach((P, u) => {
4519
+ const s = P.area / U;
4520
+ V.push({
4521
+ node: P.node,
4522
+ x: f ? X : X + oe,
4523
+ y: f ? E + oe : E,
4524
+ w: f ? U : s,
4525
+ h: f ? s : U,
4526
+ color: P.node.color || C[(J + u) % C.length]
4527
+ }), oe += s;
4528
+ }), f ? (X += U, Z -= U) : (E += U, H -= U), J += Q.length;
4529
+ }
4530
+ return V;
4531
+ }, [$, c, p, C]);
4532
+ function D(M, x, O) {
4533
+ const Y = x / O;
4534
+ let V = 0;
4535
+ for (const X of M) {
4536
+ const E = X.area / Y, Z = Math.max(Y / E, E / Y);
4537
+ V = Math.max(V, Z);
4538
+ }
4539
+ return V;
4540
+ }
4541
+ const r = (M) => {
4542
+ v?.(M, [...o, M.name]), _ && M.children && M.children.length > 0 && (l(M), h((x) => [...x, M.name]));
4543
+ }, B = () => {
4544
+ if (o.length <= 1)
4545
+ return;
4546
+ let M = I;
4547
+ const x = o.slice(0, -1);
4548
+ for (let O = 1; O < x.length; O++) {
4549
+ const Y = M.children?.find((V) => V.name === x[O]);
4550
+ Y && (M = Y);
4551
+ }
4552
+ l(M), h(x);
4553
+ }, d = (M, x) => {
4554
+ const O = S.current?.getBoundingClientRect();
4555
+ O && g({
4556
+ x: x.clientX - O.left,
4557
+ y: x.clientY - O.top,
4558
+ content: M
4559
+ });
4560
+ };
4561
+ return /* @__PURE__ */ b("div", { className: `nice-treemap-chart ${k || ""}`, style: { width: c, ...m }, ...w, children: [
4562
+ /* @__PURE__ */ b("div", { className: "nice-treemap-nav", children: [
4563
+ o.length > 1 && /* @__PURE__ */ b("button", { className: "nice-treemap-back", onClick: B, children: [
4564
+ /* @__PURE__ */ e(Me, { name: "arrow-left", size: 14 }),
4565
+ " ",
4566
+ R("charts.back", "Back")
4567
+ ] }),
4568
+ /* @__PURE__ */ e("div", { className: "nice-treemap-breadcrumbs", children: o.map((M, x) => /* @__PURE__ */ b(je.Fragment, { children: [
4569
+ x > 0 && /* @__PURE__ */ e("span", { className: "nice-treemap-sep", children: "/" }),
4570
+ /* @__PURE__ */ e("span", { className: x === o.length - 1 ? "current" : "", children: M })
4571
+ ] }, x)) })
4572
+ ] }),
4573
+ /* @__PURE__ */ e("svg", { ref: S, width: c, height: p, className: "nice-treemap-svg", children: y.map((M, x) => {
4574
+ const { node: O, x: Y, y: V, w: X, h: E, color: Z } = M, H = Math.min(14, Math.max(10, Math.min(X, E) / 6)), J = X > 40 && E > 30;
4575
+ return /* @__PURE__ */ b(
4576
+ "g",
4577
+ {
4578
+ onClick: () => r(O),
4579
+ onMouseEnter: (f) => d(`${O.name}: ${O.value.toLocaleString()}`, f),
4580
+ onMouseLeave: () => g(null),
4581
+ children: [
4582
+ /* @__PURE__ */ e(
4583
+ "rect",
4584
+ {
4585
+ x: Y + L / 2,
4586
+ y: V + L / 2,
4587
+ width: Math.max(0, X - L),
4588
+ height: Math.max(0, E - L),
4589
+ fill: Z,
4590
+ rx: 4,
4591
+ className: "nice-treemap-tile"
4592
+ }
4593
+ ),
4594
+ a && J && /* @__PURE__ */ e(
4595
+ "text",
4596
+ {
4597
+ x: Y + X / 2,
4598
+ y: V + E / 2 - (i ? 6 : 0),
4599
+ textAnchor: "middle",
4600
+ dominantBaseline: "middle",
4601
+ fontSize: H,
4602
+ fill: "white",
4603
+ fontWeight: "500",
4604
+ style: { pointerEvents: "none" },
4605
+ children: O.name.length > X / H + 2 ? O.name.slice(0, Math.floor(X / H)) + "..." : O.name
4606
+ }
4607
+ ),
4608
+ i && J && /* @__PURE__ */ e(
4609
+ "text",
4610
+ {
4611
+ x: Y + X / 2,
4612
+ y: V + E / 2 + 10,
4613
+ textAnchor: "middle",
4614
+ dominantBaseline: "middle",
4615
+ fontSize: H - 2,
4616
+ fill: "var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",
4617
+ style: { pointerEvents: "none" },
4618
+ children: O.value.toLocaleString()
4619
+ }
4620
+ )
4621
+ ]
4622
+ },
4623
+ x
4624
+ );
4625
+ }) }),
4626
+ z && /* @__PURE__ */ e("div", { className: "nice-treemap-tooltip", style: { left: z.x + 10, top: z.y - 30 }, children: z.content }),
4627
+ /* @__PURE__ */ e("style", { children: `
4628
+ .nice-treemap-chart {
4629
+ font-family: system-ui, -apple-system, sans-serif;
4630
+ background: var(--nice-bg-primary, #ffffff);
4631
+ border-radius: var(--nice-radius-lg, 8px);
4632
+ position: relative;
4633
+ }
4634
+
4635
+ .nice-treemap-nav {
4636
+ display: flex;
4637
+ align-items: center;
4638
+ gap: var(--nice-space-3, 12px);
4639
+ padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
4640
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
4641
+ }
4642
+
4643
+ .nice-treemap-back {
4644
+ background: var(--nice-bg-secondary, #f8fafc);
4645
+ color: var(--nice-text-primary, #0f172a);
4646
+ border: none;
4647
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-3, 12px);
4648
+ border-radius: var(--nice-radius-md, 6px);
4649
+ cursor: pointer;
4650
+ font-size: 13px;
4651
+ }
4652
+
4653
+ .nice-treemap-back:hover {
4654
+ background: var(--nice-border-color, #e5e7eb);
4655
+ }
4656
+
4657
+ .nice-treemap-breadcrumbs {
4658
+ display: flex;
4659
+ align-items: center;
4660
+ gap: var(--nice-space-1, 4px);
4661
+ font-size: 13px;
4662
+ color: var(--nice-text-secondary, #475569);
4663
+ }
4664
+
4665
+ .nice-treemap-breadcrumbs .current {
4666
+ color: var(--nice-text-primary, #0f172a);
4667
+ font-weight: 500;
4668
+ }
4669
+
4670
+ .nice-treemap-sep {
4671
+ color: var(--nice-text-muted, #94a3b8);
4672
+ }
4673
+
4674
+ .nice-treemap-tile {
4675
+ cursor: pointer;
4676
+ transition: opacity 0.2s, transform 0.1s;
4677
+ }
4678
+
4679
+ .nice-treemap-tile:hover {
4680
+ opacity: 0.85;
4681
+ }
4682
+
4683
+ .nice-treemap-tooltip {
4684
+ position: absolute;
4685
+ /* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
4686
+ fill and the label uses --nice-text-inverse, so the pair flips together. */
4687
+ background: var(--nice-text-primary, #0f172a);
4688
+ color: var(--nice-text-inverse, #ffffff);
4689
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
4690
+ border-radius: var(--nice-radius-sm, 4px);
4691
+ font-size: 12px;
4692
+ pointer-events: none;
4693
+ z-index: 10;
4694
+ white-space: nowrap;
4695
+ }
4696
+ ` })
4697
+ ] });
4698
+ };
4699
+ export {
4700
+ yt as A,
4701
+ kt as B,
4702
+ we as C,
4703
+ St as D,
4704
+ Ct as E,
4705
+ rt as N,
4706
+ It as a,
4707
+ at as b,
4708
+ ct as c,
4709
+ He as d,
4710
+ Qe as e,
4711
+ et as f,
4712
+ Nt as g,
4713
+ $t as h,
4714
+ At as i,
4715
+ wt as j,
4716
+ _t as k,
4717
+ bt as l,
4718
+ zt as m,
4719
+ Mt as n,
4720
+ Pe as o,
4721
+ Bt as p,
4722
+ ut as q,
4723
+ Lt as r,
4724
+ st as s,
4725
+ Et as t,
4726
+ pt as u,
4727
+ Pt as v,
4728
+ Wt as w,
4729
+ Rt as x,
4730
+ Dt as y,
4731
+ Tt as z
4732
+ };