@nice2dev/ui 1.0.30 → 1.0.31

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