@nice2dev/ui 1.0.10 → 1.0.12

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