@nice2dev/ui 1.2.2 → 1.3.1

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