@nice2dev/ui-3d 1.0.5 → 1.0.6

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 (95) hide show
  1. package/dist/cjs/core/i18n.js +3 -3
  2. package/dist/cjs/dance/DanceBridge.js +13 -13
  3. package/dist/cjs/dance/DanceScoreEngine.js +8 -8
  4. package/dist/cjs/dance/PoseDetector.js +20 -20
  5. package/dist/cjs/material/NiceMaterialEditor.js +19 -19
  6. package/dist/cjs/model/ModelEditorLeftPanel.js +5 -5
  7. package/dist/cjs/model/ModelEditorLeftPanel.js.map +1 -1
  8. package/dist/cjs/model/ModelEditorMenuBar.js +6 -5
  9. package/dist/cjs/model/ModelEditorMenuBar.js.map +1 -1
  10. package/dist/cjs/model/ModelEditorRightPanel.js +19 -17
  11. package/dist/cjs/model/ModelEditorRightPanel.js.map +1 -1
  12. package/dist/cjs/model/ModelEditorSubComponents.js +10 -9
  13. package/dist/cjs/model/ModelEditorSubComponents.js.map +1 -1
  14. package/dist/cjs/model/ModelEditorTimeline.js +6 -5
  15. package/dist/cjs/model/ModelEditorTimeline.js.map +1 -1
  16. package/dist/cjs/model/ModelEditorToolbar.js +4 -4
  17. package/dist/cjs/model/ModelEditorToolbar.js.map +1 -1
  18. package/dist/cjs/model/ModelEditorViewport.js +2 -2
  19. package/dist/cjs/model/ModelViewer.js +14 -13
  20. package/dist/cjs/model/ModelViewer.js.map +1 -1
  21. package/dist/cjs/model/NiceArmatureEditor.js +18 -18
  22. package/dist/cjs/model/NiceMorphTargetEditor.js +18 -18
  23. package/dist/cjs/model/NiceOctree.js +16 -16
  24. package/dist/cjs/model/NicePhysicsSimulation.js +24 -24
  25. package/dist/cjs/model/NiceProceduralGeometry.js +8 -8
  26. package/dist/cjs/model/NiceTerrainEditor.js +19 -19
  27. package/dist/cjs/model/NiceWeightPainter.js +14 -14
  28. package/dist/cjs/model/NiceXRPreview.js +18 -18
  29. package/dist/cjs/model/useModelEditor.js +127 -127
  30. package/dist/cjs/model/useModelViewer.js +61 -61
  31. package/dist/cjs/particle/NiceParticleEditor.js +11 -11
  32. package/dist/cjs/rendering/NiceCascadedShadows.js +12 -12
  33. package/dist/cjs/rendering/NiceRenderExport.js +5 -5
  34. package/dist/cjs/rendering/NiceSSAO.js +18 -18
  35. package/dist/cjs/rendering/NiceSSR.js +14 -14
  36. package/dist/cjs/rendering/NiceWebGPURenderer.js +21 -21
  37. package/dist/cjs/ui/dist/NiceButton-DmTHNHet.js +453 -0
  38. package/dist/cjs/ui/dist/NiceButton-DmTHNHet.js.map +1 -0
  39. package/dist/cjs/ui/dist/NiceErrorBoundary-D1hh5GGe.js +543 -0
  40. package/dist/cjs/ui/dist/NiceErrorBoundary-D1hh5GGe.js.map +1 -0
  41. package/dist/cjs/ui/dist/NiceModuleLifecyclePanel-BapdidD6.js +4772 -0
  42. package/dist/cjs/ui/dist/NiceModuleLifecyclePanel-BapdidD6.js.map +1 -0
  43. package/dist/cjs/ui/dist/NicePinCodeInput-4q8yULuo.js +11329 -0
  44. package/dist/cjs/ui/dist/NicePinCodeInput-4q8yULuo.js.map +1 -0
  45. package/dist/cjs/ui/dist/NiceSavedQueryPanel-DUw8plYP.js +5544 -0
  46. package/dist/cjs/ui/dist/NiceSavedQueryPanel-DUw8plYP.js.map +1 -0
  47. package/dist/cjs/ui/dist/NiceStockChart-Cpmv9_Cc.js +2244 -0
  48. package/dist/cjs/ui/dist/NiceStockChart-Cpmv9_Cc.js.map +1 -0
  49. package/dist/cjs/ui/dist/NiceToggle-C1UKGXmJ.js +212 -0
  50. package/dist/cjs/ui/dist/NiceToggle-C1UKGXmJ.js.map +1 -0
  51. package/dist/cjs/ui/dist/NiceWindow-D1awkyFl.js +697 -0
  52. package/dist/cjs/ui/dist/NiceWindow-D1awkyFl.js.map +1 -0
  53. package/dist/cjs/ui/dist/core-CfXsl755.js +9597 -0
  54. package/dist/cjs/ui/dist/core-CfXsl755.js.map +1 -0
  55. package/dist/cjs/ui/dist/index-CNwVELPJ.js +31214 -0
  56. package/dist/cjs/ui/dist/index-CNwVELPJ.js.map +1 -0
  57. package/dist/cjs/ui/dist/index-x8mRM4Jc.js +20 -0
  58. package/dist/cjs/ui/dist/index-x8mRM4Jc.js.map +1 -0
  59. package/dist/cjs/uv/NiceUVEditor.js +24 -24
  60. package/dist/esm/model/ModelEditorLeftPanel.js +5 -5
  61. package/dist/esm/model/ModelEditorMenuBar.js +6 -5
  62. package/dist/esm/model/ModelEditorMenuBar.js.map +1 -1
  63. package/dist/esm/model/ModelEditorRightPanel.js +19 -17
  64. package/dist/esm/model/ModelEditorRightPanel.js.map +1 -1
  65. package/dist/esm/model/ModelEditorSubComponents.js +7 -6
  66. package/dist/esm/model/ModelEditorSubComponents.js.map +1 -1
  67. package/dist/esm/model/ModelEditorTimeline.js +6 -5
  68. package/dist/esm/model/ModelEditorTimeline.js.map +1 -1
  69. package/dist/esm/model/ModelEditorToolbar.js +4 -4
  70. package/dist/esm/model/ModelEditorViewport.js +2 -2
  71. package/dist/esm/model/ModelViewer.js +6 -5
  72. package/dist/esm/model/ModelViewer.js.map +1 -1
  73. package/dist/esm/ui/dist/NiceButton-DmTHNHet.js +448 -0
  74. package/dist/esm/ui/dist/NiceButton-DmTHNHet.js.map +1 -0
  75. package/dist/esm/ui/dist/NiceErrorBoundary-D1hh5GGe.js +533 -0
  76. package/dist/esm/ui/dist/NiceErrorBoundary-D1hh5GGe.js.map +1 -0
  77. package/dist/esm/ui/dist/NiceModuleLifecyclePanel-BapdidD6.js +4731 -0
  78. package/dist/esm/ui/dist/NiceModuleLifecyclePanel-BapdidD6.js.map +1 -0
  79. package/dist/esm/ui/dist/NicePinCodeInput-4q8yULuo.js +11259 -0
  80. package/dist/esm/ui/dist/NicePinCodeInput-4q8yULuo.js.map +1 -0
  81. package/dist/esm/ui/dist/NiceSavedQueryPanel-DUw8plYP.js +5527 -0
  82. package/dist/esm/ui/dist/NiceSavedQueryPanel-DUw8plYP.js.map +1 -0
  83. package/dist/esm/ui/dist/NiceStockChart-Cpmv9_Cc.js +2222 -0
  84. package/dist/esm/ui/dist/NiceStockChart-Cpmv9_Cc.js.map +1 -0
  85. package/dist/esm/ui/dist/NiceToggle-C1UKGXmJ.js +208 -0
  86. package/dist/esm/ui/dist/NiceToggle-C1UKGXmJ.js.map +1 -0
  87. package/dist/esm/ui/dist/NiceWindow-D1awkyFl.js +686 -0
  88. package/dist/esm/ui/dist/NiceWindow-D1awkyFl.js.map +1 -0
  89. package/dist/esm/ui/dist/core-CfXsl755.js +9419 -0
  90. package/dist/esm/ui/dist/core-CfXsl755.js.map +1 -0
  91. package/dist/esm/ui/dist/index-CNwVELPJ.js +31110 -0
  92. package/dist/esm/ui/dist/index-CNwVELPJ.js.map +1 -0
  93. package/dist/esm/ui/dist/index-x8mRM4Jc.js +18 -0
  94. package/dist/esm/ui/dist/index-x8mRM4Jc.js.map +1 -0
  95. package/package.json +1 -1
@@ -0,0 +1,2222 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useRef, useState, useMemo, useCallback, forwardRef, useEffect, useImperativeHandle } from 'react';
3
+ import { k as ue, n as fi, u as ys } from './core-CfXsl755.js';
4
+ import { N as a } from './index-x8mRM4Jc.js';
5
+
6
+ const Ne = ["#3b82f6", "#ef4444", "#22c55e", "#f59e0b", "#8b5cf6", "#ec4899", "#06b6d4", "#84cc16"], De = ({
7
+ series: t,
8
+ categories: a,
9
+ width: d = 600,
10
+ height: c = 400,
11
+ title: r,
12
+ showLegend: u = true,
13
+ showGrid: i = true,
14
+ yAxisLabel: m,
15
+ xAxisLabel: C,
16
+ stacked: l,
17
+ zoomable: v,
18
+ crosshair: f,
19
+ annotations: S,
20
+ legendInteractive: y,
21
+ onDataPointClick: p,
22
+ exportable: o,
23
+ className: s,
24
+ style: h
25
+ }) => {
26
+ const w = useRef(null), [b, A] = useState(/* @__PURE__ */ new Set()), [N, I] = useState(null), [g, T] = useState(null), [x, O] = useState(false), B = useRef(null), R = useMemo(
27
+ () => t.filter(($) => !b.has($.name)),
28
+ [t, b]
29
+ ), G = useCallback(($) => {
30
+ y && A((E) => {
31
+ const Y = new Set(E);
32
+ return Y.has($) ? Y.delete($) : Y.add($), Y;
33
+ });
34
+ }, [y]), j = { top: r ? 40 : 20, right: 20, bottom: C ? 60 : 40, left: m ? 60 : 50 }, W = d - j.left - j.right, U = c - j.top - j.bottom, Z = R[0]?.data.length ?? t[0]?.data.length ?? 0, X = g?.start ?? 0, K = g?.end ?? Z, ee = K - X, he = useMemo(
35
+ () => R.map(($) => ({ ...$, data: $.data.slice(X, K) })),
36
+ [R, X, K]
37
+ ), ne = useMemo(
38
+ () => a?.slice(X, K),
39
+ [a, X, K]
40
+ ), { minY: D, maxY: P, yTicks: re } = useMemo(() => {
41
+ let $;
42
+ if (l) {
43
+ $ = [];
44
+ for (let _ = 0; _ < ee; _++)
45
+ $.push(he.reduce((V, ae) => V + (ae.data[_] || 0), 0));
46
+ } else
47
+ $ = he.flatMap((_) => _.data);
48
+ $.length === 0 && ($ = [0]);
49
+ const E = Math.min(0, ...$), Y = Math.max(0, ...$), ce = Y - E || 1, oe = Math.pow(10, Math.floor(Math.log10(ce))) || 1, n = Math.floor(E / oe) * oe, M = Math.ceil(Y / oe) * oe, z = [];
50
+ for (let _ = n; _ <= M; _ += oe) z.push(Math.round(_ * 1e6) / 1e6);
51
+ return z.length < 2 && z.push(M), { minY: n, maxY: M, yTicks: z };
52
+ }, [he, ee, l]), F = ($) => U - ($ - D) / (P - D || 1) * U, q = ($) => ($ + 0.5) / ee * W, de = ee > 0 ? W / ee / (l ? 1.5 : Math.max(R.length, 1) * 1.5) : 20, xe = useCallback(($) => {
53
+ if (!v) return;
54
+ $.preventDefault();
55
+ const E = g ?? { start: 0, end: Z }, Y = E.end - E.start, ce = (E.start + E.end) / 2, oe = $.deltaY > 0 ? 1.2 : 0.8, n = Math.max(2, Math.min(Z, Math.round(Y * oe))), M = Math.max(0, Math.round(ce - n / 2)), z = Math.min(Z, M + n);
56
+ T({ start: M, end: z });
57
+ }, [v, g, Z]), ye = useCallback(($) => {
58
+ v && (O(true), B.current = { x: $.clientX, range: g ?? { start: 0, end: Z } });
59
+ }, [v, g, Z]), L = useCallback(($) => {
60
+ const E = w.current?.getBoundingClientRect();
61
+ if (E && I({ x: $.clientX - E.left - j.left, y: $.clientY - E.top - j.top }), x && B.current && v) {
62
+ const Y = $.clientX - B.current.x, ce = W / ee, oe = -Math.round(Y / ce), n = B.current.range, M = n.end - n.start;
63
+ let z = n.start + oe;
64
+ z < 0 && (z = 0), z + M > Z && (z = Z - M), T({ start: z, end: z + M });
65
+ }
66
+ }, [x, v, W, ee, Z, j.left, j.top]), H = useCallback(() => {
67
+ O(false), B.current = null;
68
+ }, []), J = useCallback(() => {
69
+ I(null), O(false), B.current = null;
70
+ }, []), pe = useCallback(() => {
71
+ const $ = w.current;
72
+ if (!$) return;
73
+ const E = new XMLSerializer().serializeToString($), Y = document.createElement("canvas");
74
+ Y.width = d, Y.height = c + (u ? 30 : 0);
75
+ const ce = Y.getContext("2d");
76
+ if (!ce) return;
77
+ const oe = new Image();
78
+ oe.onload = () => {
79
+ ce.fillStyle = "#fff", ce.fillRect(0, 0, Y.width, Y.height), ce.drawImage(oe, 0, 0);
80
+ const n = document.createElement("a");
81
+ n.download = "chart.png", n.href = Y.toDataURL("image/png"), n.click();
82
+ }, oe.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(E);
83
+ }, [d, c, u]);
84
+ return /* @__PURE__ */ jsxs("div", { className: `nice-chart ${s || ""}`, style: h, children: [
85
+ o && /* @__PURE__ */ jsx("button", { type: "button", className: "nice-chart__export-btn", onClick: pe, title: "Export PNG", children: "📷" }),
86
+ /* @__PURE__ */ jsxs(
87
+ "svg",
88
+ {
89
+ ref: w,
90
+ width: d,
91
+ height: c + (u ? 30 : 0),
92
+ className: "nice-chart__svg",
93
+ onWheel: xe,
94
+ onMouseDown: ye,
95
+ onMouseMove: L,
96
+ onMouseUp: H,
97
+ onMouseLeave: J,
98
+ children: [
99
+ /* @__PURE__ */ jsxs("g", { transform: `translate(${j.left},${j.top})`, children: [
100
+ r && /* @__PURE__ */ jsx("text", { x: W / 2, y: -10, textAnchor: "middle", className: "nice-chart__title", children: r }),
101
+ i && re.map(($) => /* @__PURE__ */ jsxs("g", { children: [
102
+ /* @__PURE__ */ jsx("line", { x1: 0, y1: F($), x2: W, y2: F($), className: "nice-chart__grid-line" }),
103
+ /* @__PURE__ */ jsx("text", { x: -8, y: F($) + 4, textAnchor: "end", className: "nice-chart__axis-label", children: $ })
104
+ ] }, $)),
105
+ ne && ne.map(($, E) => /* @__PURE__ */ jsx("text", { x: q(E), y: U + 20, textAnchor: "middle", className: "nice-chart__axis-label", children: $ }, E)),
106
+ m && /* @__PURE__ */ jsx("text", { x: -j.left + 14, y: U / 2, textAnchor: "middle", transform: `rotate(-90, -${j.left - 14}, ${U / 2})`, className: "nice-chart__axis-title", children: m }),
107
+ C && /* @__PURE__ */ jsx("text", { x: W / 2, y: U + 45, textAnchor: "middle", className: "nice-chart__axis-title", children: C }),
108
+ /* @__PURE__ */ jsx("line", { x1: 0, y1: 0, x2: 0, y2: U, className: "nice-chart__axis" }),
109
+ /* @__PURE__ */ jsx("line", { x1: 0, y1: U, x2: W, y2: U, className: "nice-chart__axis" }),
110
+ S?.map(($, E) => {
111
+ if ($.type === "line") {
112
+ const Y = F($.value);
113
+ return /* @__PURE__ */ jsxs("g", { children: [
114
+ /* @__PURE__ */ jsx("line", { x1: 0, y1: Y, x2: W, y2: Y, stroke: $.color || "#ef4444", strokeWidth: 1.5, strokeDasharray: $.dash || "6,3" }),
115
+ $.label && /* @__PURE__ */ jsx("text", { x: W + 4, y: Y + 4, className: "nice-chart__annotation-label", fill: $.color || "#ef4444", children: $.label })
116
+ ] }, E);
117
+ }
118
+ return /* @__PURE__ */ jsx("text", { x: q($.value), y: -4, textAnchor: "middle", className: "nice-chart__annotation-label", fill: $.color || "#6b7280", children: $.label }, E);
119
+ }),
120
+ f && N && N.x >= 0 && N.x <= W && N.y >= 0 && N.y <= U && /* @__PURE__ */ jsxs(Fragment, { children: [
121
+ /* @__PURE__ */ jsx("line", { x1: N.x, y1: 0, x2: N.x, y2: U, stroke: "#9ca3af", strokeWidth: 1, strokeDasharray: "4,2" }),
122
+ /* @__PURE__ */ jsx("line", { x1: 0, y1: N.y, x2: W, y2: N.y, stroke: "#9ca3af", strokeWidth: 1, strokeDasharray: "4,2" })
123
+ ] }),
124
+ he.map(($, E) => {
125
+ const Y = $.color || Ne[E % Ne.length], ce = $.type || "bar";
126
+ if (ce === "bar")
127
+ return /* @__PURE__ */ jsx("g", { children: $.data.map((n, M) => {
128
+ let z, _;
129
+ if (l) {
130
+ const ae = he.slice(0, E).reduce((ue, se) => ue + (se.data[M] || 0), 0);
131
+ z = F(ae + n), _ = F(ae) - z;
132
+ } else
133
+ z = F(Math.max(0, n)), _ = Math.abs(F(n) - F(0));
134
+ const V = l ? q(M) - de / 2 : q(M) - he.length * de / 2 + E * de;
135
+ return /* @__PURE__ */ jsx(
136
+ "rect",
137
+ {
138
+ x: V,
139
+ y: z,
140
+ width: de * 0.9,
141
+ height: Math.max(0, _),
142
+ fill: Y,
143
+ rx: 2,
144
+ style: p ? { cursor: "pointer" } : void 0,
145
+ onClick: p ? () => p($.name, X + M, n) : void 0,
146
+ children: /* @__PURE__ */ jsx("title", { children: `${$.name}: ${n}` })
147
+ },
148
+ M
149
+ );
150
+ }) }, $.name);
151
+ const oe = $.data.map((n, M) => `${q(M)},${F(n)}`);
152
+ return /* @__PURE__ */ jsxs("g", { children: [
153
+ ce === "area" && /* @__PURE__ */ jsx(
154
+ "polygon",
155
+ {
156
+ points: `${q(0)},${F(0)} ${oe.join(" ")} ${q(ee - 1)},${F(0)}`,
157
+ fill: Y,
158
+ opacity: 0.15
159
+ }
160
+ ),
161
+ /* @__PURE__ */ jsx("polyline", { points: oe.join(" "), fill: "none", stroke: Y, strokeWidth: 2 }),
162
+ $.data.map((n, M) => /* @__PURE__ */ jsx(
163
+ "circle",
164
+ {
165
+ cx: q(M),
166
+ cy: F(n),
167
+ r: 3,
168
+ fill: Y,
169
+ style: p ? { cursor: "pointer" } : void 0,
170
+ onClick: p ? () => p($.name, X + M, n) : void 0,
171
+ children: /* @__PURE__ */ jsx("title", { children: `${$.name}: ${n}` })
172
+ },
173
+ M
174
+ ))
175
+ ] }, $.name);
176
+ })
177
+ ] }),
178
+ u && /* @__PURE__ */ jsx("g", { transform: `translate(${j.left}, ${c})`, children: t.map(($, E) => {
179
+ const Y = E * 120, ce = b.has($.name);
180
+ return /* @__PURE__ */ jsxs(
181
+ "g",
182
+ {
183
+ transform: `translate(${Y}, 10)`,
184
+ style: y ? { cursor: "pointer" } : void 0,
185
+ onClick: () => G($.name),
186
+ opacity: ce ? 0.35 : 1,
187
+ children: [
188
+ /* @__PURE__ */ jsx("rect", { width: 12, height: 12, rx: 2, fill: $.color || Ne[E % Ne.length] }),
189
+ /* @__PURE__ */ jsx(
190
+ "text",
191
+ {
192
+ x: 16,
193
+ y: 10,
194
+ className: "nice-chart__legend-text",
195
+ style: ce ? { textDecoration: "line-through" } : void 0,
196
+ children: $.name
197
+ }
198
+ )
199
+ ]
200
+ },
201
+ $.name
202
+ );
203
+ }) })
204
+ ]
205
+ }
206
+ )
207
+ ] });
208
+ }, rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
209
+ __proto__: null,
210
+ NiceChart: De
211
+ }, Symbol.toStringTag, { value: "Module" }));
212
+ function Re(t) {
213
+ if (!t.length)
214
+ return { categories: [], numericFields: [], sampleValues: {} };
215
+ const a = t[0], d = [], c = {};
216
+ let r = null;
217
+ for (const [i, m] of Object.entries(a))
218
+ typeof m == "number" ? (d.push(i), c[i] = t.map((C) => Number(C[i]) || 0)) : !r && (typeof m == "string" || m instanceof Date) && (r = i);
219
+ return { categories: r ? t.map((i) => String(i[r] || "")) : t.map((i, m) => `Item ${m + 1}`), numericFields: d, sampleValues: c };
220
+ }
221
+ function je(t, a) {
222
+ const { categories: d, numericFields: c, sampleValues: r } = Re(t);
223
+ return { series: c.map((i, m) => ({
224
+ name: i.replace(/([A-Z])/g, " $1").replace(/^./, (C) => C.toUpperCase()).trim(),
225
+ data: r[i],
226
+ type: a === "area" ? "area" : a === "line" ? "line" : "bar"
227
+ })), categories: d };
228
+ }
229
+ forwardRef(function(a$1, d) {
230
+ const {
231
+ rawData: c,
232
+ enableAI: r = true,
233
+ aiModel: u,
234
+ enableAutoType: i = true,
235
+ enableInsights: m = true,
236
+ dataDescription: C,
237
+ onChartSuggestion: l,
238
+ onInsights: v,
239
+ showAIToolbar: f = true,
240
+ showInsightsOnLoad: S = false,
241
+ series: y,
242
+ categories: p,
243
+ ...o
244
+ } = a$1, [s, h] = useState("bar"), [w, b] = useState(null), [A, N] = useState([]), [I, g] = useState(S), [T, x] = useState(null), { t: O } = a(), B = ue(), { suggestChartType: R, generateInsights: G, isLoading: j } = fi(), W = r && B.isConfigured, { series: U, categories: Z } = c ? je(c, T || s) : { series: y || [], categories: p }, X = useCallback(async () => {
245
+ if (!W || !i)
246
+ return { type: "bar", reason: "Default", config: {} };
247
+ const D = c || (y?.length ? y.flatMap((P) => P.data.map((re, F) => ({ [P.name]: re, index: F }))) : []);
248
+ try {
249
+ const P = await R(D, C), re = {
250
+ type: P.type,
251
+ reason: P.reason,
252
+ config: P.config
253
+ };
254
+ return b(re), h(re.type), l?.(re), re;
255
+ } catch {
256
+ return { type: "bar", reason: "Default fallback", config: {} };
257
+ }
258
+ }, [W, i, c, y, C, R, l]), K = useCallback(async () => {
259
+ if (!W || !m) return [];
260
+ const D = c || (y?.length ? y.flatMap((P) => P.data.map((re, F) => ({ [P.name]: re, category: p?.[F] || F }))) : []);
261
+ try {
262
+ const P = await G(D, T || s);
263
+ return N(P), v?.(P), P;
264
+ } catch {
265
+ return [];
266
+ }
267
+ }, [W, m, c, y, p, s, T, G, v]), ee = useCallback(() => T || s, [T, s]);
268
+ useEffect(() => {
269
+ W && i && (c?.length || y?.length) && X();
270
+ }, [W, i, c, y]), useImperativeHandle(d, () => ({
271
+ getSuggestion: X,
272
+ generateInsights: K,
273
+ getCurrentType: ee
274
+ }));
275
+ const he = [
276
+ { type: "bar", icon: "📊", label: "Bar" },
277
+ { type: "line", icon: "📈", label: "Line" },
278
+ { type: "area", icon: "🏔️", label: "Area" },
279
+ { type: "pie", icon: "🥧", label: "Pie" },
280
+ { type: "donut", icon: "🍩", label: "Donut" },
281
+ { type: "scatter", icon: "⭐", label: "Scatter" }
282
+ ], ne = T || s;
283
+ return /* @__PURE__ */ jsxs("div", { className: "nice-chart-ai", "data-testid": a$1["data-testid"], children: [
284
+ f && W && /* @__PURE__ */ jsxs("div", { className: "nice-chart-ai__toolbar", children: [
285
+ /* @__PURE__ */ jsxs("div", { className: "nice-chart-ai__toolbar-left", children: [
286
+ /* @__PURE__ */ jsx("span", { className: "nice-chart-ai__badge", children: "AI" }),
287
+ w && /* @__PURE__ */ jsxs("div", { className: "nice-chart-ai__suggestion", children: [
288
+ /* @__PURE__ */ jsx("span", { className: "nice-chart-ai__suggestion-icon", children: "💡" }),
289
+ /* @__PURE__ */ jsxs("span", { className: "nice-chart-ai__suggestion-text", children: [
290
+ O("chartAI.suggestedType", "Suggested:"),
291
+ " ",
292
+ w.type
293
+ ] }),
294
+ /* @__PURE__ */ jsxs("span", { className: "nice-chart-ai__suggestion-reason", title: w.reason, children: [
295
+ "(",
296
+ w.reason,
297
+ ")"
298
+ ] })
299
+ ] }),
300
+ j && /* @__PURE__ */ jsx("span", { className: "nice-chart-ai__loading", children: O("chartAI.analyzing", "Analyzing...") })
301
+ ] }),
302
+ /* @__PURE__ */ jsx("div", { className: "nice-chart-ai__toolbar-center", children: /* @__PURE__ */ jsx("div", { className: "nice-chart-ai__type-selector", children: he.filter((D) => ["bar", "line", "area"].includes(D.type)).map(({ type: D, icon: P, label: re }) => /* @__PURE__ */ jsx(
303
+ "button",
304
+ {
305
+ type: "button",
306
+ className: `nice-chart-ai__type-btn ${ne === D ? "nice-chart-ai__type-btn--active" : ""}`,
307
+ onClick: () => x(D),
308
+ title: re,
309
+ children: P
310
+ },
311
+ D
312
+ )) }) }),
313
+ /* @__PURE__ */ jsxs("div", { className: "nice-chart-ai__toolbar-right", children: [
314
+ /* @__PURE__ */ jsxs(
315
+ "button",
316
+ {
317
+ type: "button",
318
+ className: "nice-chart-ai__auto-btn",
319
+ onClick: () => X(),
320
+ disabled: j,
321
+ title: O("chartAI.autoDetect", "Auto-detect best chart type"),
322
+ children: [
323
+ "🔮 ",
324
+ O("chartAI.auto", "Auto")
325
+ ]
326
+ }
327
+ ),
328
+ m && /* @__PURE__ */ jsxs(
329
+ "button",
330
+ {
331
+ type: "button",
332
+ className: "nice-chart-ai__insights-btn",
333
+ onClick: () => {
334
+ A.length || K(), g(!I);
335
+ },
336
+ disabled: j,
337
+ title: O("chartAI.showInsights", "Show data insights"),
338
+ children: [
339
+ "💡 ",
340
+ O("chartAI.insights", "Insights")
341
+ ]
342
+ }
343
+ )
344
+ ] })
345
+ ] }),
346
+ /* @__PURE__ */ jsx("div", { className: "nice-chart-ai__chart-wrapper", children: /* @__PURE__ */ jsx(
347
+ De,
348
+ {
349
+ series: U,
350
+ categories: Z,
351
+ ...o
352
+ }
353
+ ) }),
354
+ I && A.length > 0 && /* @__PURE__ */ jsxs("div", { className: "nice-chart-ai__insights", children: [
355
+ /* @__PURE__ */ jsxs("div", { className: "nice-chart-ai__insights-header", children: [
356
+ /* @__PURE__ */ jsxs("h4", { children: [
357
+ "💡 ",
358
+ O("chartAI.dataInsights", "Data Insights")
359
+ ] }),
360
+ /* @__PURE__ */ jsx(
361
+ "button",
362
+ {
363
+ type: "button",
364
+ className: "nice-chart-ai__insights-close",
365
+ onClick: () => g(false),
366
+ children: "✕"
367
+ }
368
+ )
369
+ ] }),
370
+ /* @__PURE__ */ jsx("ul", { className: "nice-chart-ai__insights-list", children: A.map((D, P) => /* @__PURE__ */ jsxs("li", { className: "nice-chart-ai__insight", children: [
371
+ /* @__PURE__ */ jsx("span", { className: "nice-chart-ai__insight-icon", children: "•" }),
372
+ D
373
+ ] }, P)) }),
374
+ /* @__PURE__ */ jsx("div", { className: "nice-chart-ai__insights-footer", children: /* @__PURE__ */ jsxs(
375
+ "button",
376
+ {
377
+ type: "button",
378
+ className: "nice-chart-ai__refresh",
379
+ onClick: () => K(),
380
+ disabled: j,
381
+ children: [
382
+ "🔄 ",
383
+ O("chartAI.refresh", "Refresh")
384
+ ]
385
+ }
386
+ ) })
387
+ ] }),
388
+ I && j && /* @__PURE__ */ jsx("div", { className: "nice-chart-ai__insights nice-chart-ai__insights--loading", children: /* @__PURE__ */ jsxs("div", { className: "nice-chart-ai__loading-content", children: [
389
+ /* @__PURE__ */ jsx("span", { className: "nice-chart-ai__spinner" }),
390
+ O("chartAI.generatingInsights", "Generating insights...")
391
+ ] }) })
392
+ ] });
393
+ });
394
+ function He(t, a) {
395
+ const d = t ? typeof t == "number" ? new Date(t) : new Date(t) : /* @__PURE__ */ new Date(), c = (C) => C.toString().padStart(2, "0"), r = c(d.getHours()), u = c(d.getMinutes()), i = c(d.getSeconds()), m = d.getMilliseconds().toString().padStart(3, "0");
396
+ switch (a) {
397
+ case "HH:mm:ss":
398
+ return `${r}:${u}:${i}`;
399
+ case "HH:mm":
400
+ return `${r}:${u}`;
401
+ case "mm:ss":
402
+ return `${u}:${i}`;
403
+ case "ss.SSS":
404
+ return `${i}.${m}`;
405
+ case "ISO":
406
+ return d.toISOString();
407
+ default:
408
+ return `${r}:${u}:${i}`;
409
+ }
410
+ }
411
+ function Te(t) {
412
+ if (t.length === 0) return null;
413
+ const a = Math.min(...t), d = Math.max(...t), c = t.reduce((u, i) => u + i, 0) / t.length, r = t[t.length - 1];
414
+ return { min: a, max: d, avg: c, current: r, count: t.length };
415
+ }
416
+ const Fe = forwardRef(
417
+ ({
418
+ series: t,
419
+ maxPoints: a = 100,
420
+ slidingWindow: d = true,
421
+ refreshRate: c = 16,
422
+ dataSource: r,
423
+ width: u = 600,
424
+ height: i = 400,
425
+ title: m,
426
+ showLegend: C = true,
427
+ showGrid: l = true,
428
+ yAxisLabel: v,
429
+ xAxisLabel: f,
430
+ stacked: S,
431
+ zoomable: y,
432
+ crosshair: p,
433
+ annotations: o = [],
434
+ legendInteractive: s,
435
+ onDataPointClick: h,
436
+ exportable: w,
437
+ showControls: b = true,
438
+ showStatus: A = true,
439
+ initialPaused: N = false,
440
+ onDataReceived: I,
441
+ onDataDropped: g,
442
+ timeFormat: T = "HH:mm:ss",
443
+ showStats: x,
444
+ thresholds: O = [],
445
+ className: B,
446
+ style: R
447
+ }, G) => {
448
+ const [j, W] = useState(() => {
449
+ const L = /* @__PURE__ */ new Map();
450
+ for (const H of t)
451
+ L.set(H.name, H.initialData?.slice() ?? []);
452
+ return L;
453
+ }), [U, Z] = useState([]), [X, K] = useState(N), [ee, he] = useState(false), ne = useRef([]), D = useRef(Date.now()), P = useRef(null), re = useCallback(() => {
454
+ const L = ne.current;
455
+ L.length !== 0 && (ne.current = [], W((H) => {
456
+ const J = new Map(H);
457
+ for (const pe of L) {
458
+ const $ = J.get(pe.series);
459
+ if (!$) continue;
460
+ const E = [...$, pe.value];
461
+ if (d && E.length > a) {
462
+ const Y = E.length - a;
463
+ g?.(Y, pe.series), E.splice(0, Y);
464
+ }
465
+ J.set(pe.series, E);
466
+ }
467
+ return J;
468
+ }), L.length > 0 && Z((H) => {
469
+ const J = [...H];
470
+ for (const pe of L) {
471
+ const $ = pe.category ?? He(pe.timestamp, T);
472
+ J.push($);
473
+ }
474
+ return d && J.length > a && J.splice(0, J.length - a), J;
475
+ }));
476
+ }, [d, a, T, g]), F = useCallback(() => {
477
+ const L = Date.now();
478
+ L - D.current >= c && (re(), D.current = L), P.current = requestAnimationFrame(F);
479
+ }, [c, re]);
480
+ useEffect(() => (X || (P.current = requestAnimationFrame(F)), () => {
481
+ P.current !== null && (cancelAnimationFrame(P.current), P.current = null);
482
+ }), [X, F]);
483
+ const q = useCallback(
484
+ (L) => {
485
+ if (X) return;
486
+ const H = "points" in L ? L.points : [L];
487
+ for (const J of H)
488
+ j.has(J.series) && (ne.current.push(J), I?.(J));
489
+ },
490
+ [X, j, I]
491
+ );
492
+ useEffect(() => {
493
+ if (!r) return;
494
+ const L = r.subscribe(q);
495
+ let H;
496
+ return r.onStatusChange ? H = r.onStatusChange(he) : he(true), r.fetchHistory && r.fetchHistory(a).then((J) => {
497
+ for (const pe of J)
498
+ ne.current.push(pe);
499
+ re();
500
+ }), () => {
501
+ L(), H?.();
502
+ };
503
+ }, [r, q, a, re]);
504
+ const de = useMemo(() => t.map((L) => ({
505
+ name: L.name,
506
+ color: L.color,
507
+ type: L.type,
508
+ data: j.get(L.name) ?? []
509
+ })), [t, j]), xe = useMemo(() => {
510
+ const L = [...o];
511
+ for (const H of O)
512
+ L.push({
513
+ type: "line",
514
+ value: H.value,
515
+ color: H.color,
516
+ label: H.label,
517
+ dash: H.style === "dashed" ? "5,5" : H.style === "dotted" ? "2,2" : void 0
518
+ });
519
+ return L;
520
+ }, [o, O]);
521
+ useImperativeHandle(
522
+ G,
523
+ () => ({
524
+ pause() {
525
+ K(true);
526
+ },
527
+ resume() {
528
+ K(false);
529
+ },
530
+ isPaused() {
531
+ return X;
532
+ },
533
+ clear() {
534
+ W((L) => {
535
+ const H = new Map(L);
536
+ for (const J of H.keys())
537
+ H.set(J, []);
538
+ return H;
539
+ }), Z([]), ne.current = [];
540
+ },
541
+ addPoint(L) {
542
+ q(L);
543
+ },
544
+ addPoints(L) {
545
+ q({ points: L });
546
+ },
547
+ getData(L) {
548
+ return j.get(L) ?? [];
549
+ },
550
+ getCategories() {
551
+ return U;
552
+ },
553
+ exportData() {
554
+ return { series: de, categories: U };
555
+ },
556
+ getStats(L) {
557
+ const H = j.get(L);
558
+ return H ? Te(H) : null;
559
+ }
560
+ }),
561
+ [X, j, U, de, q]
562
+ );
563
+ const ye = useMemo(() => {
564
+ if (!x) return null;
565
+ const L = {};
566
+ for (const [H, J] of j)
567
+ L[H] = Te(J);
568
+ return L;
569
+ }, [x, j]);
570
+ return /* @__PURE__ */ jsxs("div", { className: B, style: { position: "relative", ...R }, children: [
571
+ A && /* @__PURE__ */ jsxs(
572
+ "div",
573
+ {
574
+ style: {
575
+ position: "absolute",
576
+ top: 8,
577
+ right: 8,
578
+ display: "flex",
579
+ alignItems: "center",
580
+ gap: 4,
581
+ fontSize: 12,
582
+ color: ee ? "#22c55e" : "#ef4444",
583
+ zIndex: 10
584
+ },
585
+ children: [
586
+ /* @__PURE__ */ jsx(
587
+ "span",
588
+ {
589
+ style: {
590
+ width: 8,
591
+ height: 8,
592
+ borderRadius: "50%",
593
+ backgroundColor: ee ? "#22c55e" : "#ef4444"
594
+ }
595
+ }
596
+ ),
597
+ ee ? "Live" : "Disconnected"
598
+ ]
599
+ }
600
+ ),
601
+ b && /* @__PURE__ */ jsx(
602
+ "div",
603
+ {
604
+ style: {
605
+ position: "absolute",
606
+ top: 8,
607
+ left: 8,
608
+ display: "flex",
609
+ gap: 4,
610
+ zIndex: 10
611
+ },
612
+ children: /* @__PURE__ */ jsx(
613
+ "button",
614
+ {
615
+ onClick: () => K((L) => !L),
616
+ style: {
617
+ padding: "4px 8px",
618
+ fontSize: 12,
619
+ border: "1px solid #ddd",
620
+ borderRadius: 4,
621
+ background: X ? "#fef3c7" : "#fff",
622
+ cursor: "pointer"
623
+ },
624
+ title: X ? "Resume" : "Pause",
625
+ children: X ? "▶" : "⏸"
626
+ }
627
+ )
628
+ }
629
+ ),
630
+ x && ye && /* @__PURE__ */ jsx(
631
+ "div",
632
+ {
633
+ style: {
634
+ position: "absolute",
635
+ bottom: 50,
636
+ right: 8,
637
+ background: "rgba(255,255,255,0.9)",
638
+ border: "1px solid #ddd",
639
+ borderRadius: 4,
640
+ padding: 8,
641
+ fontSize: 11,
642
+ zIndex: 10
643
+ },
644
+ children: Object.entries(ye).map(
645
+ ([L, H]) => H ? /* @__PURE__ */ jsxs("div", { style: { marginBottom: 4 }, children: [
646
+ /* @__PURE__ */ jsx("strong", { children: L }),
647
+ /* @__PURE__ */ jsxs("div", { children: [
648
+ "Min: ",
649
+ H.min.toFixed(2),
650
+ " | Max: ",
651
+ H.max.toFixed(2)
652
+ ] }),
653
+ /* @__PURE__ */ jsxs("div", { children: [
654
+ "Avg: ",
655
+ H.avg.toFixed(2),
656
+ " | Now: ",
657
+ H.current.toFixed(2)
658
+ ] })
659
+ ] }, L) : null
660
+ )
661
+ }
662
+ ),
663
+ /* @__PURE__ */ jsx(
664
+ De,
665
+ {
666
+ series: de,
667
+ categories: U,
668
+ width: u,
669
+ height: i,
670
+ title: m,
671
+ showLegend: C,
672
+ showGrid: l,
673
+ yAxisLabel: v,
674
+ xAxisLabel: f,
675
+ stacked: S,
676
+ zoomable: y,
677
+ crosshair: p,
678
+ annotations: xe,
679
+ legendInteractive: s,
680
+ onDataPointClick: h,
681
+ exportable: w
682
+ }
683
+ )
684
+ ] });
685
+ }
686
+ );
687
+ Fe.displayName = "NiceLiveChart";
688
+ const fe = ["#3b82f6", "#ef4444", "#22c55e", "#f59e0b", "#8b5cf6", "#ec4899", "#06b6d4", "#84cc16"], it = ({
689
+ data: t,
690
+ width: a = 400,
691
+ height: d = 400,
692
+ innerRadius: c = 0,
693
+ title: r,
694
+ showLegend: u = true,
695
+ showLabels: i = true,
696
+ className: m,
697
+ style: C
698
+ }) => {
699
+ const l = a / 2, v = (d - (u ? 30 : 0)) / 2 + (r ? 10 : 0), f = Math.min(l, v) - 40, S = t.reduce((o, s) => o + s.value, 0);
700
+ let y = -Math.PI / 2;
701
+ const p = t.map((o, s) => {
702
+ const h = o.value / (S || 1) * Math.PI * 2, w = y;
703
+ y += h;
704
+ const b = y, A = (w + b) / 2, N = l + f * Math.cos(w), I = v + f * Math.sin(w), g = l + f * Math.cos(b), T = v + f * Math.sin(b), x = h > Math.PI ? 1 : 0, O = o.color || fe[s % fe.length];
705
+ let B;
706
+ if (c > 0) {
707
+ const W = l + c * Math.cos(w), U = v + c * Math.sin(w), Z = l + c * Math.cos(b), X = v + c * Math.sin(b);
708
+ B = `M${N},${I} A${f},${f} 0 ${x},1 ${g},${T} L${Z},${X} A${c},${c} 0 ${x},0 ${W},${U} Z`;
709
+ } else
710
+ B = `M${l},${v} L${N},${I} A${f},${f} 0 ${x},1 ${g},${T} Z`;
711
+ const R = l + f * 0.7 * Math.cos(A), G = v + f * 0.7 * Math.sin(A), j = S > 0 ? Math.round(o.value / S * 100) : 0;
712
+ return { ...o, path: B, labelX: R, labelY: G, pct: j, color: O };
713
+ });
714
+ return /* @__PURE__ */ jsx("div", { className: `nice-piechart ${m || ""}`, style: C, children: /* @__PURE__ */ jsxs("svg", { width: a, height: d, className: "nice-piechart__svg", children: [
715
+ r && /* @__PURE__ */ jsx("text", { x: l, y: 20, textAnchor: "middle", className: "nice-chart__title", children: r }),
716
+ p.map((o, s) => /* @__PURE__ */ jsxs("g", { children: [
717
+ /* @__PURE__ */ jsx("path", { d: o.path, fill: o.color, stroke: "var(--bg-primary, #fff)", strokeWidth: 2, children: /* @__PURE__ */ jsx("title", { children: `${o.label}: ${o.value} (${o.pct}%)` }) }),
718
+ i && o.pct >= 5 && /* @__PURE__ */ jsxs("text", { x: o.labelX, y: o.labelY, textAnchor: "middle", dominantBaseline: "middle", className: "nice-piechart__label", children: [
719
+ o.pct,
720
+ "%"
721
+ ] })
722
+ ] }, s)),
723
+ u && /* @__PURE__ */ jsx("g", { transform: `translate(10, ${d - 25})`, children: t.map((o, s) => /* @__PURE__ */ jsxs("g", { transform: `translate(${s * 100}, 0)`, children: [
724
+ /* @__PURE__ */ jsx("rect", { width: 10, height: 10, rx: 2, fill: o.color || fe[s % fe.length] }),
725
+ /* @__PURE__ */ jsx("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: o.label })
726
+ ] }, s)) })
727
+ ] }) });
728
+ }, lt = ({
729
+ series: t,
730
+ categories: a,
731
+ width: d = 400,
732
+ height: c = 400,
733
+ maxValue: r,
734
+ title: u,
735
+ showLegend: i = true,
736
+ className: m,
737
+ style: C
738
+ }) => {
739
+ const l = d / 2, v = (c - (i ? 30 : 0)) / 2 + (u ? 10 : 0), f = Math.min(l, v) - 40, S = a.length, y = r ?? Math.max(...t.flatMap((h) => h.data), 1), p = Math.PI * 2 / S, o = 5, s = (h, w) => {
740
+ const b = h * p - Math.PI / 2, A = w / y * f;
741
+ return { x: l + A * Math.cos(b), y: v + A * Math.sin(b) };
742
+ };
743
+ return /* @__PURE__ */ jsx("div", { className: `nice-polarchart ${m || ""}`, style: C, children: /* @__PURE__ */ jsxs("svg", { width: d, height: c, className: "nice-polarchart__svg", children: [
744
+ u && /* @__PURE__ */ jsx("text", { x: l, y: 20, textAnchor: "middle", className: "nice-chart__title", children: u }),
745
+ Array.from({ length: o }, (h, w) => {
746
+ const b = f * ((w + 1) / o);
747
+ return /* @__PURE__ */ jsx("circle", { cx: l, cy: v, r: b, fill: "none", stroke: "var(--border-color, #ddd)", strokeWidth: 0.5 }, w);
748
+ }),
749
+ a.map((h, w) => {
750
+ const b = s(w, y), A = s(w, y * 1.12);
751
+ return /* @__PURE__ */ jsxs("g", { children: [
752
+ /* @__PURE__ */ jsx("line", { x1: l, y1: v, x2: b.x, y2: b.y, stroke: "var(--border-color, #ddd)", strokeWidth: 0.5 }),
753
+ /* @__PURE__ */ jsx("text", { x: A.x, y: A.y, textAnchor: "middle", dominantBaseline: "middle", className: "nice-chart__axis-label", children: h })
754
+ ] }, w);
755
+ }),
756
+ t.map((h, w) => {
757
+ const b = h.color || fe[w % fe.length], A = h.data.map((N, I) => {
758
+ const g = s(I, N);
759
+ return `${g.x},${g.y}`;
760
+ }).join(" ");
761
+ return /* @__PURE__ */ jsxs("g", { children: [
762
+ /* @__PURE__ */ jsx("polygon", { points: A, fill: h.fill !== false ? b : "none", fillOpacity: 0.15, stroke: b, strokeWidth: 2 }),
763
+ h.data.map((N, I) => {
764
+ const g = s(I, N);
765
+ return /* @__PURE__ */ jsx("circle", { cx: g.x, cy: g.y, r: 3, fill: b, children: /* @__PURE__ */ jsx("title", { children: `${h.name} - ${a[I]}: ${N}` }) }, I);
766
+ })
767
+ ] }, h.name);
768
+ }),
769
+ i && /* @__PURE__ */ jsx("g", { transform: `translate(10, ${c - 25})`, children: t.map((h, w) => /* @__PURE__ */ jsxs("g", { transform: `translate(${w * 100}, 0)`, children: [
770
+ /* @__PURE__ */ jsx("rect", { width: 10, height: 10, rx: 2, fill: h.color || fe[w % fe.length] }),
771
+ /* @__PURE__ */ jsx("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: h.name })
772
+ ] }, w)) })
773
+ ] }) });
774
+ }, ht = ({
775
+ value: t,
776
+ min: a = 0,
777
+ max: d = 100,
778
+ width: c = 200,
779
+ height: r = 200,
780
+ startAngle: u = 225,
781
+ endAngle: i = -45,
782
+ color: m = "#3b82f6",
783
+ trackColor: C,
784
+ label: l,
785
+ formatValue: v,
786
+ ranges: f,
787
+ className: S,
788
+ style: y
789
+ }) => {
790
+ const p = c / 2, o = r / 2, s = Math.min(p, o) - 20, h = Math.max(0, Math.min(1, (t - a) / (d - a || 1))), w = (x) => x * Math.PI / 180, b = (u - i + 360) % 360 || 360, A = (x) => ({
791
+ x: p + s * Math.cos(w(x)),
792
+ y: o - s * Math.sin(w(x))
793
+ }), N = (x, O) => {
794
+ const B = A(x), R = A(O), j = (x - O + 360) % 360 > 180 ? 1 : 0;
795
+ return `M${B.x},${B.y} A${s},${s} 0 ${j},1 ${R.x},${R.y}`;
796
+ }, I = u - h * b, g = A(I);
797
+ let T = m;
798
+ if (f) {
799
+ for (const x of f)
800
+ if (t >= x.start && t <= x.end) {
801
+ T = x.color;
802
+ break;
803
+ }
804
+ }
805
+ return /* @__PURE__ */ jsx("div", { className: `nice-gauge nice-gauge--circular ${S || ""}`, style: y, children: /* @__PURE__ */ jsxs("svg", { width: c, height: r, children: [
806
+ /* @__PURE__ */ jsx("path", { d: N(u, i), fill: "none", stroke: C || "var(--border-color, #e2e8f0)", strokeWidth: 12, strokeLinecap: "round" }),
807
+ h > 0 && /* @__PURE__ */ jsx("path", { d: N(u, I), fill: "none", stroke: T, strokeWidth: 12, strokeLinecap: "round" }),
808
+ /* @__PURE__ */ jsx("line", { x1: p, y1: o, x2: g.x, y2: g.y, stroke: "var(--text-primary, #333)", strokeWidth: 2, strokeLinecap: "round" }),
809
+ /* @__PURE__ */ jsx("circle", { cx: p, cy: o, r: 4, fill: "var(--text-primary, #333)" }),
810
+ /* @__PURE__ */ jsx("text", { x: p, y: o + s * 0.35, textAnchor: "middle", className: "nice-gauge__value", children: v ? v(t) : t }),
811
+ l && /* @__PURE__ */ jsx("text", { x: p, y: o + s * 0.55, textAnchor: "middle", className: "nice-gauge__label", children: l })
812
+ ] }) });
813
+ }, dt = ({
814
+ value: t,
815
+ min: a = 0,
816
+ max: d = 100,
817
+ width: c = 300,
818
+ height: r = 60,
819
+ orientation: u = "horizontal",
820
+ color: i = "#3b82f6",
821
+ label: m,
822
+ formatValue: C,
823
+ ranges: l,
824
+ showTicks: v = true,
825
+ tickCount: f = 5,
826
+ className: S,
827
+ style: y
828
+ }) => {
829
+ const p = u === "horizontal", o = p ? c - 40 : r - 40, s = Math.max(0, Math.min(1, (t - a) / (d - a || 1))), h = 10;
830
+ let w = i;
831
+ if (l) {
832
+ for (const A of l)
833
+ if (t >= A.start && t <= A.end) {
834
+ w = A.color;
835
+ break;
836
+ }
837
+ }
838
+ const b = Array.from({ length: f }, (A, N) => a + (d - a) * (N / (f - 1)));
839
+ return p ? /* @__PURE__ */ jsx("div", { className: `nice-gauge nice-gauge--linear ${S || ""}`, style: y, children: /* @__PURE__ */ jsxs("svg", { width: c, height: r, children: [
840
+ m && /* @__PURE__ */ jsx("text", { x: c / 2, y: 14, textAnchor: "middle", className: "nice-gauge__label", children: m }),
841
+ /* @__PURE__ */ jsx("rect", { x: 20, y: r / 2 - h / 2, width: o, height: h, rx: 5, fill: "var(--border-color, #e2e8f0)" }),
842
+ /* @__PURE__ */ jsx("rect", { x: 20, y: r / 2 - h / 2, width: o * s, height: h, rx: 5, fill: w }),
843
+ /* @__PURE__ */ jsx("polygon", { points: `${20 + o * s},${r / 2 - h / 2 - 2} ${20 + o * s - 5},${r / 2 - h / 2 - 10} ${20 + o * s + 5},${r / 2 - h / 2 - 10}`, fill: "var(--text-primary, #333)" }),
844
+ /* @__PURE__ */ jsx("text", { x: 20 + o * s, y: r / 2 - h / 2 - 12, textAnchor: "middle", className: "nice-gauge__value", style: { fontSize: 11 }, children: C ? C(t) : t }),
845
+ v && b.map((A, N) => {
846
+ const I = 20 + (A - a) / (d - a) * o;
847
+ return /* @__PURE__ */ jsx("text", { x: I, y: r / 2 + h / 2 + 14, textAnchor: "middle", className: "nice-gauge__tick", children: A }, N);
848
+ })
849
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: `nice-gauge nice-gauge--linear nice-gauge--vertical ${S || ""}`, style: y, children: /* @__PURE__ */ jsxs("svg", { width: c, height: r, children: [
850
+ /* @__PURE__ */ jsx("rect", { x: c / 2 - h / 2, y: 20, width: h, height: o, rx: 5, fill: "var(--border-color, #e2e8f0)" }),
851
+ /* @__PURE__ */ jsx("rect", { x: c / 2 - h / 2, y: 20 + o * (1 - s), width: h, height: o * s, rx: 5, fill: w }),
852
+ /* @__PURE__ */ jsx("text", { x: c / 2, y: 14, textAnchor: "middle", className: "nice-gauge__value", children: C ? C(t) : t }),
853
+ m && /* @__PURE__ */ jsx("text", { x: c / 2, y: r - 4, textAnchor: "middle", className: "nice-gauge__label", children: m })
854
+ ] }) });
855
+ }, ft = ({
856
+ items: t,
857
+ min: a = 0,
858
+ max: d = 100,
859
+ width: c = 300,
860
+ height: r = 300,
861
+ startAngle: u = 225,
862
+ endAngle: i = -45,
863
+ formatValue: m,
864
+ title: C,
865
+ className: l,
866
+ style: v
867
+ }) => {
868
+ const f = c / 2, S = r / 2, y = Math.min(f, S) - 30, p = Math.min(20, y / (t.length + 1)), o = 4, s = (b) => b * Math.PI / 180, h = (u - i + 360) % 360 || 360, w = (b, A, N) => {
869
+ const I = f + b * Math.cos(s(A)), g = S - b * Math.sin(s(A)), T = f + b * Math.cos(s(N)), x = S - b * Math.sin(s(N)), O = (A - N + 360) % 360;
870
+ return `M${I},${g} A${b},${b} 0 ${O > 180 ? 1 : 0},1 ${T},${x}`;
871
+ };
872
+ return /* @__PURE__ */ jsx("div", { className: `nice-bargauge ${l || ""}`, style: v, children: /* @__PURE__ */ jsxs("svg", { width: c, height: r, children: [
873
+ C && /* @__PURE__ */ jsx("text", { x: f, y: 20, textAnchor: "middle", className: "nice-chart__title", children: C }),
874
+ t.map((b, A) => {
875
+ const N = y - A * (p + o), I = Math.max(0, Math.min(1, (b.value - a) / (d - a || 1))), g = u - I * h, T = b.color || fe[A % fe.length];
876
+ return /* @__PURE__ */ jsxs("g", { children: [
877
+ /* @__PURE__ */ jsx("path", { d: w(N, u, i), fill: "none", stroke: "var(--border-color, #e2e8f0)", strokeWidth: p, strokeLinecap: "round" }),
878
+ I > 0 && /* @__PURE__ */ jsx("path", { d: w(N, u, g), fill: "none", stroke: T, strokeWidth: p, strokeLinecap: "round" })
879
+ ] }, A);
880
+ }),
881
+ /* @__PURE__ */ jsx("g", { children: t.map((b, A) => /* @__PURE__ */ jsxs("text", { x: f, y: S - ((t.length - 1) / 2 - A) * 16, textAnchor: "middle", dominantBaseline: "middle", className: "nice-gauge__value", style: { fontSize: 12 }, children: [
882
+ b.label ? `${b.label}: ` : "",
883
+ m ? m(b.value) : b.value
884
+ ] }, A)) })
885
+ ] }) });
886
+ }, ut = ({
887
+ data: t,
888
+ width: a = 120,
889
+ height: d = 30,
890
+ type: c = "line",
891
+ color: r = "#3b82f6",
892
+ showMinMax: u,
893
+ showLastPoint: i = true,
894
+ className: m,
895
+ style: C
896
+ }) => {
897
+ if (t.length === 0) return null;
898
+ const l = 2, v = Math.min(...t), f = Math.max(...t), S = f - v || 1, y = a - l * 2, p = d - l * 2, o = (N) => l + N / (t.length - 1 || 1) * y, s = (N) => l + p - (N - v) / S * p;
899
+ if (c === "bar") {
900
+ const N = Math.max(1, y / t.length - 1);
901
+ return /* @__PURE__ */ jsx("svg", { width: a, height: d, className: `nice-sparkline ${m || ""}`, style: C, children: t.map((I, g) => /* @__PURE__ */ jsx("rect", { x: l + g / t.length * y, y: s(I), width: N, height: p - (s(I) - l), fill: r, rx: 1 }, g)) });
902
+ }
903
+ const h = t.map((N, I) => `${o(I)},${s(N)}`).join(" "), w = t.indexOf(v), b = t.indexOf(f), A = t.length - 1;
904
+ return /* @__PURE__ */ jsxs("svg", { width: a, height: d, className: `nice-sparkline ${m || ""}`, style: C, children: [
905
+ c === "area" && /* @__PURE__ */ jsx("polygon", { points: `${o(0)},${l + p} ${h} ${o(A)},${l + p}`, fill: r, opacity: 0.15 }),
906
+ /* @__PURE__ */ jsx("polyline", { points: h, fill: "none", stroke: r, strokeWidth: 1.5 }),
907
+ u && /* @__PURE__ */ jsx("circle", { cx: o(w), cy: s(v), r: 2, fill: "#ef4444" }),
908
+ u && /* @__PURE__ */ jsx("circle", { cx: o(b), cy: s(f), r: 2, fill: "#22c55e" }),
909
+ i && /* @__PURE__ */ jsx("circle", { cx: o(A), cy: s(t[A]), r: 2, fill: r })
910
+ ] });
911
+ }, mt = ({
912
+ value: t,
913
+ target: a,
914
+ min: d = 0,
915
+ max: c = 100,
916
+ width: r = 200,
917
+ height: u = 30,
918
+ color: i = "#3b82f6",
919
+ targetColor: m = "#ef4444",
920
+ className: C,
921
+ style: l
922
+ }) => {
923
+ const f = r - 8, S = u - 8, y = Math.max(0, Math.min(1, (t - d) / (c - d || 1))), p = a != null ? Math.max(0, Math.min(1, (a - d) / (c - d || 1))) : null;
924
+ return /* @__PURE__ */ jsxs("svg", { width: r, height: u, className: `nice-bullet ${C || ""}`, style: l, children: [
925
+ /* @__PURE__ */ jsx("rect", { x: 4, y: 4, width: f, height: S, rx: 3, fill: "var(--border-color, #e2e8f0)" }),
926
+ /* @__PURE__ */ jsx("rect", { x: 4, y: 4 + S * 0.2, width: f * y, height: S * 0.6, rx: 2, fill: i }),
927
+ p != null && /* @__PURE__ */ jsx("line", { x1: 4 + f * p, y1: 6, x2: 4 + f * p, y2: 4 + S - 2, stroke: m, strokeWidth: 2 })
928
+ ] });
929
+ }, pt = ({
930
+ data: t,
931
+ width: a = 400,
932
+ height: d = 300,
933
+ inverted: c,
934
+ showLabels: r = true,
935
+ showValues: u = true,
936
+ title: i,
937
+ className: m,
938
+ style: C
939
+ }) => {
940
+ const l = { top: i ? 30 : 10, bottom: 10, x: 40 }, v = a - l.x * 2, f = d - l.top - l.bottom, S = c ? [...t].reverse() : t, y = Math.max(...S.map((o) => o.value), 1), p = f / S.length;
941
+ return /* @__PURE__ */ jsx("div", { className: `nice-funnel ${m || ""}`, style: C, children: /* @__PURE__ */ jsxs("svg", { width: a, height: d, children: [
942
+ i && /* @__PURE__ */ jsx("text", { x: a / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: i }),
943
+ S.map((o, s) => {
944
+ const h = o.value / y * v, w = s < S.length - 1 ? S[s + 1].value / y * v : h * 0.3, b = l.top + s * p, A = b + p, N = a / 2, I = `${N - h / 2},${b} ${N + h / 2},${b} ${N + w / 2},${A} ${N - w / 2},${A}`, g = o.color || fe[s % fe.length];
945
+ return /* @__PURE__ */ jsxs("g", { children: [
946
+ /* @__PURE__ */ jsx("polygon", { points: I, fill: g, stroke: "var(--bg-primary, #fff)", strokeWidth: 1, children: /* @__PURE__ */ jsx("title", { children: `${o.label}: ${o.value}` }) }),
947
+ r && /* @__PURE__ */ jsx("text", { x: N, y: b + p / 2 - (u ? 4 : 0), textAnchor: "middle", dominantBaseline: "middle", className: "nice-funnel__label", children: o.label }),
948
+ u && /* @__PURE__ */ jsx("text", { x: N, y: b + p / 2 + 10, textAnchor: "middle", dominantBaseline: "middle", className: "nice-funnel__value", children: o.value })
949
+ ] }, s);
950
+ })
951
+ ] }) });
952
+ }, Ee = ({
953
+ nodes: t,
954
+ links: a,
955
+ width: d = 600,
956
+ height: c = 400,
957
+ nodeWidth: r = 20,
958
+ nodePadding: u = 10,
959
+ title: i,
960
+ className: m,
961
+ style: C
962
+ }) => {
963
+ const l = { top: i ? 40 : 20, bottom: 20, left: 20, right: 20 }, v = d - l.left - l.right, f = c - l.top - l.bottom, S = new Set(a.map((x) => x.source)), y = new Set(a.map((x) => x.target)), p = t.filter((x) => S.has(x.id) && !y.has(x.id)), o = t.filter((x) => y.has(x.id)), s = t.filter((x) => S.has(x.id) && y.has(x.id)), h = [p, ...s.length ? [s] : [], o].filter((x) => x.length > 0), w = h.length, b = /* @__PURE__ */ new Map();
964
+ t.forEach((x) => {
965
+ const O = a.filter((R) => R.source === x.id).reduce((R, G) => R + G.value, 0), B = a.filter((R) => R.target === x.id).reduce((R, G) => R + G.value, 0);
966
+ b.set(x.id, Math.max(O, B));
967
+ });
968
+ const A = h.map((x) => x.reduce((O, B) => O + (b.get(B.id) || 0), 0) + (x.length - 1) * u), N = Math.max(...A, 1), I = /* @__PURE__ */ new Map();
969
+ h.forEach((x, O) => {
970
+ const B = l.left + O / (w - 1 || 1) * (v - r);
971
+ let R = 0;
972
+ x.forEach((G) => {
973
+ const j = (b.get(G.id) || 0) / N * f;
974
+ I.set(G.id, { x: B, y: l.top + R, h: j }), R += j + u;
975
+ });
976
+ });
977
+ const g = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map();
978
+ return t.forEach((x) => {
979
+ g.set(x.id, 0), T.set(x.id, 0);
980
+ }), /* @__PURE__ */ jsx("div", { className: `nice-sankey ${m || ""}`, style: C, children: /* @__PURE__ */ jsxs("svg", { width: d, height: c, children: [
981
+ i && /* @__PURE__ */ jsx("text", { x: d / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: i }),
982
+ a.map((x, O) => {
983
+ const B = I.get(x.source), R = I.get(x.target);
984
+ if (!B || !R) return null;
985
+ const G = g.get(x.source) || 0, j = T.get(x.target) || 0, W = x.value / N * f;
986
+ g.set(x.source, G + W), T.set(x.target, j + W);
987
+ const U = B.x + r, Z = B.y + G, X = R.x, K = R.y + j, ee = (U + X) / 2, ne = t.find((D) => D.id === x.source)?.color || fe[O % fe.length];
988
+ return /* @__PURE__ */ jsx(
989
+ "path",
990
+ {
991
+ d: `M${U},${Z} C${ee},${Z} ${ee},${K} ${X},${K} L${X},${K + W} C${ee},${K + W} ${ee},${Z + W} ${U},${Z + W} Z`,
992
+ fill: ne,
993
+ fillOpacity: 0.3,
994
+ stroke: ne,
995
+ strokeOpacity: 0.5,
996
+ strokeWidth: 0.5,
997
+ children: /* @__PURE__ */ jsx("title", { children: `${x.source} → ${x.target}: ${x.value}` })
998
+ },
999
+ O
1000
+ );
1001
+ }),
1002
+ t.map((x, O) => {
1003
+ const B = I.get(x.id);
1004
+ if (!B) return null;
1005
+ const R = x.color || fe[O % fe.length];
1006
+ return /* @__PURE__ */ jsxs("g", { children: [
1007
+ /* @__PURE__ */ jsx("rect", { x: B.x, y: B.y, width: r, height: Math.max(B.h, 2), fill: R, rx: 2 }),
1008
+ /* @__PURE__ */ jsx(
1009
+ "text",
1010
+ {
1011
+ x: B.x < v / 2 ? B.x + r + 4 : B.x - 4,
1012
+ y: B.y + B.h / 2,
1013
+ textAnchor: B.x < v / 2 ? "start" : "end",
1014
+ dominantBaseline: "middle",
1015
+ className: "nice-chart__legend-text",
1016
+ children: x.label
1017
+ }
1018
+ )
1019
+ ] }, x.id);
1020
+ })
1021
+ ] }) });
1022
+ }, gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1023
+ __proto__: null,
1024
+ NiceSankey: Ee
1025
+ }, Symbol.toStringTag, { value: "Module" })), xt = ({
1026
+ data: t,
1027
+ min: a,
1028
+ max: d,
1029
+ start: c,
1030
+ end: r,
1031
+ onChange: u,
1032
+ width: i = 500,
1033
+ height: m = 100,
1034
+ step: C = 1,
1035
+ formatValue: l,
1036
+ chartColor: v = "#3b82f6",
1037
+ className: f,
1038
+ style: S
1039
+ }) => {
1040
+ const y = { top: 10, bottom: 30, left: 10, right: 10 }, p = i - y.left - y.right, o = m - y.top - y.bottom, s = (I) => y.left + (I - a) / (d - a || 1) * p, h = (I) => {
1041
+ const g = Math.max(0, Math.min(1, (I - y.left) / p)), T = a + g * (d - a);
1042
+ return Math.round(T / C) * C;
1043
+ }, w = (I, g) => {
1044
+ g.preventDefault();
1045
+ const T = g.target.closest("svg");
1046
+ if (!T) return;
1047
+ const x = (B) => {
1048
+ const R = T.getBoundingClientRect(), G = h(B.clientX - R.left);
1049
+ I === "start" ? u(Math.min(G, r), r) : u(c, Math.max(G, c));
1050
+ }, O = () => {
1051
+ document.removeEventListener("pointermove", x), document.removeEventListener("pointerup", O);
1052
+ };
1053
+ document.addEventListener("pointermove", x), document.addEventListener("pointerup", O);
1054
+ }, b = t ? Math.min(...t) : 0, N = (t ? Math.max(...t) : 1) - b || 1;
1055
+ return /* @__PURE__ */ jsx("div", { className: `nice-rangeselector ${f || ""}`, style: S, children: /* @__PURE__ */ jsxs("svg", { width: i, height: m, children: [
1056
+ t && t.length > 1 && /* @__PURE__ */ jsx(
1057
+ "polygon",
1058
+ {
1059
+ points: `${y.left},${y.top + o} ${t.map((I, g) => `${y.left + g / (t.length - 1) * p},${y.top + o - (I - b) / N * o}`).join(" ")} ${y.left + p},${y.top + o}`,
1060
+ fill: v,
1061
+ opacity: 0.15
1062
+ }
1063
+ ),
1064
+ /* @__PURE__ */ jsx("rect", { x: s(c), y: y.top, width: s(r) - s(c), height: o, fill: v, opacity: 0.1 }),
1065
+ /* @__PURE__ */ jsx("rect", { x: y.left, y: y.top, width: s(c) - y.left, height: o, fill: "var(--bg-secondary, #f5f5f5)", opacity: 0.6 }),
1066
+ /* @__PURE__ */ jsx("rect", { x: s(r), y: y.top, width: y.left + p - s(r), height: o, fill: "var(--bg-secondary, #f5f5f5)", opacity: 0.6 }),
1067
+ /* @__PURE__ */ jsx(
1068
+ "rect",
1069
+ {
1070
+ x: s(c) - 4,
1071
+ y: y.top,
1072
+ width: 8,
1073
+ height: o,
1074
+ fill: v,
1075
+ rx: 2,
1076
+ cursor: "ew-resize",
1077
+ onPointerDown: (I) => w("start", I)
1078
+ }
1079
+ ),
1080
+ /* @__PURE__ */ jsx(
1081
+ "rect",
1082
+ {
1083
+ x: s(r) - 4,
1084
+ y: y.top,
1085
+ width: 8,
1086
+ height: o,
1087
+ fill: v,
1088
+ rx: 2,
1089
+ cursor: "ew-resize",
1090
+ onPointerDown: (I) => w("end", I)
1091
+ }
1092
+ ),
1093
+ /* @__PURE__ */ jsx("text", { x: s(c), y: y.top + o + 18, textAnchor: "middle", className: "nice-chart__axis-label", children: l ? l(c) : c }),
1094
+ /* @__PURE__ */ jsx("text", { x: s(r), y: y.top + o + 18, textAnchor: "middle", className: "nice-chart__axis-label", children: l ? l(r) : r })
1095
+ ] }) });
1096
+ }, Ye = ({
1097
+ regions: t,
1098
+ width: a = 600,
1099
+ height: d = 400,
1100
+ viewBox: c = "0 0 1000 600",
1101
+ colorRange: r = ["#dbeafe", "#1d4ed8"],
1102
+ maxValue: u,
1103
+ onRegionClick: i,
1104
+ selectedRegionId: m,
1105
+ title: C,
1106
+ showTooltip: l = true,
1107
+ className: v,
1108
+ style: f
1109
+ }) => {
1110
+ const S = u ?? Math.max(...t.map((p) => p.value ?? 0), 1), y = (p) => {
1111
+ const o = (x) => [parseInt(x.slice(1, 3), 16), parseInt(x.slice(3, 5), 16), parseInt(x.slice(5, 7), 16)], [s, h, w] = o(r[0]), [b, A, N] = o(r[1]), I = Math.round(s + (b - s) * p), g = Math.round(h + (A - h) * p), T = Math.round(w + (N - w) * p);
1112
+ return `rgb(${I},${g},${T})`;
1113
+ };
1114
+ return /* @__PURE__ */ jsxs("div", { className: `nice-vectormap ${v || ""}`, style: f, children: [
1115
+ C && /* @__PURE__ */ jsx("div", { className: "nice-vectormap__title", children: C }),
1116
+ /* @__PURE__ */ jsx("svg", { width: a, height: d, viewBox: c, children: t.map((p) => {
1117
+ const o = p.value != null ? Math.max(0, Math.min(1, p.value / S)) : 0, s = p.value != null ? y(o) : "var(--bg-tertiary, #e5e7eb)", h = p.id === m;
1118
+ return /* @__PURE__ */ jsx(
1119
+ "path",
1120
+ {
1121
+ d: p.path,
1122
+ fill: s,
1123
+ stroke: h ? "var(--color-primary, #3b82f6)" : "var(--border-color, #d1d5db)",
1124
+ strokeWidth: h ? 2 : 0.5,
1125
+ cursor: i ? "pointer" : void 0,
1126
+ onClick: () => i?.(p),
1127
+ children: l && /* @__PURE__ */ jsx("title", { children: `${p.name}${p.value != null ? `: ${p.value}` : ""}` })
1128
+ },
1129
+ p.id
1130
+ );
1131
+ }) })
1132
+ ] });
1133
+ }, yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1134
+ __proto__: null,
1135
+ NiceVectorMap: Ye
1136
+ }, Symbol.toStringTag, { value: "Module" })), Ve = `
1137
+ .nice-forecast-chart {
1138
+ display: flex;
1139
+ flex-direction: column;
1140
+ background: var(--nice-bg-primary, #ffffff);
1141
+ border: 1px solid var(--nice-border-color, #e5e7eb);
1142
+ border-radius: 0.5rem;
1143
+ overflow: hidden;
1144
+ }
1145
+
1146
+ .nice-forecast-chart__header {
1147
+ display: flex;
1148
+ align-items: center;
1149
+ justify-content: space-between;
1150
+ padding: 0.75rem 1rem;
1151
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
1152
+ }
1153
+
1154
+ .nice-forecast-chart__title {
1155
+ font-size: 1rem;
1156
+ font-weight: 600;
1157
+ color: var(--nice-text-primary);
1158
+ margin: 0;
1159
+ }
1160
+
1161
+ .nice-forecast-chart__actions {
1162
+ display: flex;
1163
+ gap: 0.5rem;
1164
+ }
1165
+
1166
+ .nice-forecast-chart__btn {
1167
+ display: inline-flex;
1168
+ align-items: center;
1169
+ justify-content: center;
1170
+ width: 2rem;
1171
+ height: 2rem;
1172
+ font-size: 1rem;
1173
+ border-radius: 0.375rem;
1174
+ cursor: pointer;
1175
+ transition: all 0.15s ease;
1176
+ border: 1px solid var(--nice-border-color, #d1d5db);
1177
+ background: var(--nice-bg-primary, #ffffff);
1178
+ color: var(--nice-text-secondary);
1179
+ }
1180
+
1181
+ .nice-forecast-chart__btn:hover {
1182
+ background: var(--nice-bg-hover, #f3f4f6);
1183
+ color: var(--nice-text-primary);
1184
+ }
1185
+
1186
+ .nice-forecast-chart__btn:disabled {
1187
+ opacity: 0.5;
1188
+ cursor: not-allowed;
1189
+ }
1190
+
1191
+ .nice-forecast-chart__container {
1192
+ position: relative;
1193
+ width: 100%;
1194
+ padding: 1rem;
1195
+ }
1196
+
1197
+ .nice-forecast-chart__svg {
1198
+ width: 100%;
1199
+ overflow: visible;
1200
+ }
1201
+
1202
+ .nice-forecast-chart__grid-line {
1203
+ stroke: var(--nice-border-divider, #f3f4f6);
1204
+ stroke-width: 1;
1205
+ }
1206
+
1207
+ .nice-forecast-chart__axis-line {
1208
+ stroke: var(--nice-border-color, #e5e7eb);
1209
+ stroke-width: 1;
1210
+ }
1211
+
1212
+ .nice-forecast-chart__axis-label {
1213
+ font-size: 0.6875rem;
1214
+ fill: var(--nice-text-secondary);
1215
+ }
1216
+
1217
+ .nice-forecast-chart__axis-title {
1218
+ font-size: 0.75rem;
1219
+ font-weight: 500;
1220
+ fill: var(--nice-text-primary);
1221
+ }
1222
+
1223
+ .nice-forecast-chart__historical-line {
1224
+ fill: none;
1225
+ stroke-width: 2;
1226
+ stroke-linecap: round;
1227
+ stroke-linejoin: round;
1228
+ }
1229
+
1230
+ .nice-forecast-chart__forecast-line {
1231
+ fill: none;
1232
+ stroke-width: 2;
1233
+ stroke-linecap: round;
1234
+ stroke-linejoin: round;
1235
+ stroke-dasharray: 6, 4;
1236
+ }
1237
+
1238
+ .nice-forecast-chart__confidence-band {
1239
+ opacity: 0.2;
1240
+ }
1241
+
1242
+ .nice-forecast-chart__forecast-region {
1243
+ fill: var(--nice-bg-secondary, #f9fafb);
1244
+ opacity: 0.5;
1245
+ }
1246
+
1247
+ .nice-forecast-chart__point {
1248
+ cursor: pointer;
1249
+ transition: r 0.15s ease;
1250
+ }
1251
+
1252
+ .nice-forecast-chart__point:hover {
1253
+ r: 6;
1254
+ }
1255
+
1256
+ .nice-forecast-chart__annotation-line {
1257
+ stroke-dasharray: 4, 2;
1258
+ stroke-width: 1;
1259
+ }
1260
+
1261
+ .nice-forecast-chart__annotation-marker {
1262
+ cursor: pointer;
1263
+ transition: transform 0.15s ease;
1264
+ }
1265
+
1266
+ .nice-forecast-chart__annotation-marker:hover {
1267
+ transform: scale(1.2);
1268
+ }
1269
+
1270
+ .nice-forecast-chart__reference-line {
1271
+ stroke-width: 1;
1272
+ }
1273
+
1274
+ .nice-forecast-chart__reference-label {
1275
+ font-size: 0.625rem;
1276
+ fill: var(--nice-text-secondary);
1277
+ }
1278
+
1279
+ .nice-forecast-chart__cash-runway {
1280
+ pointer-events: none;
1281
+ }
1282
+
1283
+ .nice-forecast-chart__cash-runway-line {
1284
+ stroke: #ef4444;
1285
+ stroke-width: 2;
1286
+ stroke-dasharray: 8, 4;
1287
+ }
1288
+
1289
+ .nice-forecast-chart__cash-runway-label-bg {
1290
+ fill: #ef4444;
1291
+ rx: 4;
1292
+ }
1293
+
1294
+ .nice-forecast-chart__cash-runway-label {
1295
+ font-size: 0.6875rem;
1296
+ font-weight: 600;
1297
+ fill: #ffffff;
1298
+ }
1299
+
1300
+ .nice-forecast-chart__cash-runway-date {
1301
+ font-size: 0.625rem;
1302
+ fill: #ef4444;
1303
+ font-weight: 500;
1304
+ }
1305
+
1306
+ .nice-forecast-chart__tooltip {
1307
+ position: absolute;
1308
+ pointer-events: none;
1309
+ z-index: 100;
1310
+ padding: 0.75rem;
1311
+ background: var(--nice-bg-primary, #ffffff);
1312
+ border: 1px solid var(--nice-border-color, #e5e7eb);
1313
+ border-radius: 0.5rem;
1314
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
1315
+ font-size: 0.8125rem;
1316
+ max-width: 250px;
1317
+ }
1318
+
1319
+ .nice-forecast-chart__tooltip-date {
1320
+ font-weight: 600;
1321
+ color: var(--nice-text-primary);
1322
+ margin-bottom: 0.5rem;
1323
+ padding-bottom: 0.5rem;
1324
+ border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
1325
+ }
1326
+
1327
+ .nice-forecast-chart__tooltip-item {
1328
+ display: flex;
1329
+ align-items: center;
1330
+ gap: 0.5rem;
1331
+ margin-bottom: 0.25rem;
1332
+ }
1333
+
1334
+ .nice-forecast-chart__tooltip-color {
1335
+ width: 10px;
1336
+ height: 10px;
1337
+ border-radius: 2px;
1338
+ flex-shrink: 0;
1339
+ }
1340
+
1341
+ .nice-forecast-chart__tooltip-label {
1342
+ color: var(--nice-text-secondary);
1343
+ flex: 1;
1344
+ }
1345
+
1346
+ .nice-forecast-chart__tooltip-value {
1347
+ font-weight: 600;
1348
+ color: var(--nice-text-primary);
1349
+ font-variant-numeric: tabular-nums;
1350
+ }
1351
+
1352
+ .nice-forecast-chart__tooltip-confidence {
1353
+ font-size: 0.75rem;
1354
+ color: var(--nice-text-tertiary);
1355
+ }
1356
+
1357
+ .nice-forecast-chart__legend {
1358
+ display: flex;
1359
+ flex-wrap: wrap;
1360
+ gap: 1rem;
1361
+ padding: 0.75rem 1rem;
1362
+ border-top: 1px solid var(--nice-border-color, #e5e7eb);
1363
+ }
1364
+
1365
+ .nice-forecast-chart__legend-item {
1366
+ display: flex;
1367
+ align-items: center;
1368
+ gap: 0.375rem;
1369
+ font-size: 0.8125rem;
1370
+ color: var(--nice-text-secondary);
1371
+ cursor: pointer;
1372
+ user-select: none;
1373
+ transition: opacity 0.15s ease;
1374
+ }
1375
+
1376
+ .nice-forecast-chart__legend-item:hover {
1377
+ color: var(--nice-text-primary);
1378
+ }
1379
+
1380
+ .nice-forecast-chart__legend-item--hidden {
1381
+ opacity: 0.4;
1382
+ }
1383
+
1384
+ .nice-forecast-chart__legend-color {
1385
+ width: 16px;
1386
+ height: 3px;
1387
+ border-radius: 1px;
1388
+ }
1389
+
1390
+ .nice-forecast-chart__legend-color--dashed {
1391
+ background: repeating-linear-gradient(
1392
+ 90deg,
1393
+ currentColor,
1394
+ currentColor 4px,
1395
+ transparent 4px,
1396
+ transparent 6px
1397
+ );
1398
+ }
1399
+
1400
+ .nice-forecast-chart__empty {
1401
+ display: flex;
1402
+ align-items: center;
1403
+ justify-content: center;
1404
+ height: 300px;
1405
+ color: var(--nice-text-secondary);
1406
+ }
1407
+
1408
+ /* Dark mode */
1409
+ .dark .nice-forecast-chart {
1410
+ background: var(--nice-bg-primary-dark, #111827);
1411
+ border-color: var(--nice-border-color-dark, #374151);
1412
+ }
1413
+
1414
+ .dark .nice-forecast-chart__tooltip {
1415
+ background: var(--nice-bg-secondary-dark, #1f2937);
1416
+ border-color: var(--nice-border-color-dark, #374151);
1417
+ }
1418
+
1419
+ .dark .nice-forecast-chart__forecast-region {
1420
+ fill: var(--nice-bg-secondary-dark, #1f2937);
1421
+ }
1422
+ `, ze = [
1423
+ "#3b82f6",
1424
+ // blue
1425
+ "#10b981",
1426
+ // green
1427
+ "#f59e0b",
1428
+ // amber
1429
+ "#ef4444",
1430
+ // red
1431
+ "#8b5cf6",
1432
+ // purple
1433
+ "#ec4899",
1434
+ // pink
1435
+ "#06b6d4",
1436
+ // cyan
1437
+ "#f97316"
1438
+ // orange
1439
+ ];
1440
+ function le(t) {
1441
+ return t instanceof Date ? t : new Date(t);
1442
+ }
1443
+ function Ae(t, a = "pl-PL") {
1444
+ return t.toLocaleDateString(a, {
1445
+ year: "numeric",
1446
+ month: "short",
1447
+ day: "numeric"
1448
+ });
1449
+ }
1450
+ function Me(t, a = "pl-PL") {
1451
+ return new Intl.NumberFormat(a, {
1452
+ minimumFractionDigits: 0,
1453
+ maximumFractionDigits: 2
1454
+ }).format(t);
1455
+ }
1456
+ forwardRef(
1457
+ function(a, d) {
1458
+ const {
1459
+ scenarios: c,
1460
+ annotations: r = [],
1461
+ referenceLines: u = [],
1462
+ forecastStartDate: i,
1463
+ cashRunway: m,
1464
+ xAxis: C,
1465
+ yAxis: l,
1466
+ confidenceBands: v = [{ level: 95, color: "#3b82f6", opacity: 0.15 }],
1467
+ tooltip: f,
1468
+ legend: S = { enabled: true, position: "bottom", interactive: true },
1469
+ height: y = 350,
1470
+ showForecastRegion: p = true,
1471
+ lineWidth: o = 2,
1472
+ showPoints: s = false,
1473
+ pointRadius: h = 4,
1474
+ enableZoom: w = false,
1475
+ animationDuration: b = 300,
1476
+ responsive: A = true,
1477
+ onPointClick: N,
1478
+ onAnnotationClick: I,
1479
+ onScenarioToggle: g,
1480
+ onViewportChange: T,
1481
+ size: x = "medium",
1482
+ disabled: O = false,
1483
+ labels: B = {},
1484
+ locale: R = "pl-PL",
1485
+ className: G,
1486
+ style: j
1487
+ } = a, [W, U] = useState(
1488
+ () => c.map((n, M) => ({
1489
+ ...n,
1490
+ color: n.color ?? ze[M % ze.length],
1491
+ visible: n.visible !== false
1492
+ }))
1493
+ ), [Z, X] = useState(null), [K, ee] = useState({ x: 0, y: 0 }), he = useRef(null), ne = useRef(null), D = { top: 20, right: 30, bottom: 40, left: 60 }, [P, re] = useState({
1494
+ width: 600,
1495
+ height: typeof y == "number" ? y : 350
1496
+ });
1497
+ useEffect(() => {
1498
+ if (!A || !he.current) return;
1499
+ const n = new ResizeObserver((M) => {
1500
+ for (const z of M)
1501
+ re((_) => ({
1502
+ width: z.contentRect.width,
1503
+ height: _.height
1504
+ }));
1505
+ });
1506
+ return n.observe(he.current), () => n.disconnect();
1507
+ }, [A]), useEffect(() => {
1508
+ const n = "nice-forecast-chart-styles";
1509
+ if (!document.getElementById(n)) {
1510
+ const M = document.createElement("style");
1511
+ M.id = n, M.textContent = Ve, document.head.appendChild(M);
1512
+ }
1513
+ }, []);
1514
+ const { xScale: F, yScale: q, allDates: de, minY: xe, maxY: ye } = useMemo(() => {
1515
+ const M = W.filter((Q) => Q.visible !== false).flatMap((Q) => Q.data);
1516
+ if (M.length === 0)
1517
+ return { xScale: () => 0, yScale: () => 0, allDates: [], minY: 0, maxY: 100 };
1518
+ const z = M.map((Q) => le(Q.date).getTime()), _ = Math.min(...z), V = Math.max(...z), ae = M.flatMap((Q) => [Q.value, Q.forecast, Q.lowerBound, Q.upperBound]).filter((Q) => Q != null), ue = l?.min ?? Math.min(...ae) * 0.95, se = l?.max ?? Math.max(...ae) * 1.05, ge = P.width - D.left - D.right, _e = P.height - D.top - D.bottom, we = (Q) => {
1519
+ const Ce = typeof Q == "number" ? Q : Q.getTime();
1520
+ return D.left + (Ce - _) / (V - _) * ge;
1521
+ }, Se = (Q) => D.top + _e - (Q - ue) / (se - ue) * _e, Oe = [...new Set(z)].sort((Q, Ce) => Q - Ce).map((Q) => new Date(Q));
1522
+ return {
1523
+ xScale: we,
1524
+ yScale: Se,
1525
+ allDates: Oe,
1526
+ minY: ue,
1527
+ maxY: se
1528
+ };
1529
+ }, [W, P, D, l]), L = i ? le(i) : null, H = useMemo(() => {
1530
+ if (!m?.enabled) return null;
1531
+ const n = m.threshold ?? 0, M = m.scenarioId ? W.find((_) => _.id === m.scenarioId && _.visible !== false) : W.find((_) => _.visible !== false);
1532
+ if (!M) return null;
1533
+ const z = M.data.sort(
1534
+ (_, V) => le(_.date).getTime() - le(V.date).getTime()
1535
+ );
1536
+ for (let _ = 1; _ < z.length; _++) {
1537
+ const V = z[_ - 1], ae = z[_], ue = V.forecast ?? V.value, se = ae.forecast ?? ae.value;
1538
+ if (ue != null && se != null && ue > n && se <= n) {
1539
+ const ge = (ue - n) / (ue - se), _e = le(V.date).getTime(), we = le(ae.date).getTime(), Se = _e + ge * (we - _e);
1540
+ return new Date(Se);
1541
+ }
1542
+ }
1543
+ return null;
1544
+ }, [m, W]), J = useCallback(
1545
+ (n, M) => {
1546
+ const z = n.filter((_) => _[M] != null).map((_) => ({ x: F(le(_.date)), y: q(_[M]) }));
1547
+ return z.length === 0 ? "" : `M ${z.map((_) => `${_.x},${_.y}`).join(" L ")}`;
1548
+ },
1549
+ [F, q]
1550
+ ), pe = useCallback(
1551
+ (n) => {
1552
+ const M = n.filter((V) => V.lowerBound != null && V.upperBound != null);
1553
+ if (M.length === 0) return "";
1554
+ const z = M.map((V) => ({
1555
+ x: F(le(V.date)),
1556
+ y: q(V.upperBound)
1557
+ })), _ = M.map((V) => ({ x: F(le(V.date)), y: q(V.lowerBound) })).reverse();
1558
+ return `M ${z.map((V) => `${V.x},${V.y}`).join(" L ")} L ${_.map((V) => `${V.x},${V.y}`).join(" L ")} Z`;
1559
+ },
1560
+ [F, q]
1561
+ ), $ = useCallback(
1562
+ (n) => {
1563
+ if (!ne.current || f?.enabled === false) return;
1564
+ const M = ne.current.getBoundingClientRect(), z = n.clientX - M.left;
1565
+ n.clientY - M.top;
1566
+ let _ = null, V = 1 / 0;
1567
+ for (const ae of de) {
1568
+ const ue = F(ae), se = Math.abs(ue - z);
1569
+ se < V && (V = se, _ = ae);
1570
+ }
1571
+ if (_ && V < 50) {
1572
+ const ae = W.filter((se) => se.visible !== false).map((se) => {
1573
+ const ge = se.data.find((_e) => le(_e.date).getTime() === _.getTime());
1574
+ return {
1575
+ scenario: se,
1576
+ value: ge?.value,
1577
+ forecast: ge?.forecast,
1578
+ lowerBound: ge?.lowerBound,
1579
+ upperBound: ge?.upperBound
1580
+ };
1581
+ }), ue = r.filter(
1582
+ (se) => Math.abs(le(se.date).getTime() - _.getTime()) < 864e5
1583
+ );
1584
+ X({ date: _, values: ae, annotations: ue }), ee({ x: n.clientX - M.left + 10, y: n.clientY - M.top - 10 });
1585
+ } else
1586
+ X(null);
1587
+ },
1588
+ [F, de, W, r, f]
1589
+ ), E = useCallback(
1590
+ (n) => {
1591
+ if (!S.interactive) return;
1592
+ U((z) => z.map((_) => _.id === n ? { ..._, visible: !_.visible } : _));
1593
+ const M = W.find((z) => z.id === n);
1594
+ M && g?.(n, !M.visible);
1595
+ },
1596
+ [S.interactive, W, g]
1597
+ );
1598
+ useImperativeHandle(
1599
+ d,
1600
+ () => ({
1601
+ getScenarios: () => W,
1602
+ updateScenario: (n, M) => {
1603
+ U((z) => z.map((_) => _.id === n ? { ..._, data: M } : _));
1604
+ },
1605
+ toggleScenario: E,
1606
+ setZoomRange: () => {
1607
+ },
1608
+ // Would need pan/zoom implementation
1609
+ resetZoom: () => {
1610
+ },
1611
+ exportImage: (n) => {
1612
+ if (!ne.current) return null;
1613
+ const M = ne.current, _ = new XMLSerializer().serializeToString(M);
1614
+ return `data:image/svg+xml;base64,${btoa(_)}`;
1615
+ },
1616
+ getDataAtDate: (n) => {
1617
+ const M = W.filter((z) => z.visible !== false).map((z) => {
1618
+ const _ = z.data.find((V) => le(V.date).getTime() === n.getTime());
1619
+ return {
1620
+ scenario: z,
1621
+ value: _?.value,
1622
+ forecast: _?.forecast,
1623
+ lowerBound: _?.lowerBound,
1624
+ upperBound: _?.upperBound
1625
+ };
1626
+ });
1627
+ return {
1628
+ date: n,
1629
+ values: M,
1630
+ annotations: r.filter((z) => le(z.date).getTime() === n.getTime())
1631
+ };
1632
+ }
1633
+ }),
1634
+ [W, r, E]
1635
+ ), P.width - D.left - D.right;
1636
+ const Y = P.height - D.top - D.bottom, ce = useMemo(() => {
1637
+ const n = l?.tickCount ?? 5, M = [], z = (ye - xe) / (n - 1);
1638
+ for (let _ = 0; _ < n; _++)
1639
+ M.push(xe + z * _);
1640
+ return M;
1641
+ }, [xe, ye, l?.tickCount]), oe = useMemo(() => {
1642
+ const n = C?.tickCount ?? 6;
1643
+ if (de.length === 0) return [];
1644
+ const M = Math.max(1, Math.floor(de.length / (n - 1)));
1645
+ return de.filter((z, _) => _ % M === 0 || _ === de.length - 1);
1646
+ }, [de, C?.tickCount]);
1647
+ return W.length === 0 || W.every((n) => n.data.length === 0) ? /* @__PURE__ */ jsx("div", { className: `nice-forecast-chart ${G ?? ""}`, style: j, children: /* @__PURE__ */ jsx("div", { className: "nice-forecast-chart__empty", children: B.noData ?? "No data available" }) }) : /* @__PURE__ */ jsxs("div", { className: `nice-forecast-chart ${G ?? ""}`, style: { ...j, height: y }, children: [
1648
+ /* @__PURE__ */ jsxs("div", { ref: he, className: "nice-forecast-chart__container", children: [
1649
+ /* @__PURE__ */ jsxs(
1650
+ "svg",
1651
+ {
1652
+ ref: ne,
1653
+ className: "nice-forecast-chart__svg",
1654
+ width: P.width,
1655
+ height: P.height,
1656
+ onMouseMove: $,
1657
+ onMouseLeave: () => X(null),
1658
+ children: [
1659
+ l?.showGrid !== false && ce.map((n) => /* @__PURE__ */ jsx(
1660
+ "line",
1661
+ {
1662
+ className: "nice-forecast-chart__grid-line",
1663
+ x1: D.left,
1664
+ x2: P.width - D.right,
1665
+ y1: q(n),
1666
+ y2: q(n)
1667
+ },
1668
+ n
1669
+ )),
1670
+ p && L && /* @__PURE__ */ jsx(
1671
+ "rect",
1672
+ {
1673
+ className: "nice-forecast-chart__forecast-region",
1674
+ x: F(L),
1675
+ y: D.top,
1676
+ width: P.width - D.right - F(L),
1677
+ height: Y
1678
+ }
1679
+ ),
1680
+ u.map((n) => /* @__PURE__ */ jsxs("g", { children: [
1681
+ /* @__PURE__ */ jsx(
1682
+ "line",
1683
+ {
1684
+ className: "nice-forecast-chart__reference-line",
1685
+ x1: D.left,
1686
+ x2: P.width - D.right,
1687
+ y1: q(n.value),
1688
+ y2: q(n.value),
1689
+ stroke: n.color ?? "#9ca3af",
1690
+ strokeDasharray: n.dashArray ?? "4,2"
1691
+ }
1692
+ ),
1693
+ n.label && /* @__PURE__ */ jsx(
1694
+ "text",
1695
+ {
1696
+ className: "nice-forecast-chart__reference-label",
1697
+ x: P.width - D.right - 4,
1698
+ y: q(n.value) - 4,
1699
+ textAnchor: "end",
1700
+ children: n.label
1701
+ }
1702
+ )
1703
+ ] }, n.id)),
1704
+ H && m?.enabled && /* @__PURE__ */ jsxs("g", { className: "nice-forecast-chart__cash-runway", children: [
1705
+ /* @__PURE__ */ jsx(
1706
+ "line",
1707
+ {
1708
+ className: "nice-forecast-chart__cash-runway-line",
1709
+ x1: F(H),
1710
+ x2: F(H),
1711
+ y1: D.top,
1712
+ y2: P.height - D.bottom,
1713
+ stroke: m.color ?? "#ef4444"
1714
+ }
1715
+ ),
1716
+ m.showLabel !== false && /* @__PURE__ */ jsxs(Fragment, { children: [
1717
+ /* @__PURE__ */ jsx(
1718
+ "rect",
1719
+ {
1720
+ className: "nice-forecast-chart__cash-runway-label-bg",
1721
+ x: F(H) - 60,
1722
+ y: D.top - 2,
1723
+ width: 120,
1724
+ height: m.showDate !== false ? 32 : 20,
1725
+ fill: m.color ?? "#ef4444",
1726
+ rx: 4
1727
+ }
1728
+ ),
1729
+ /* @__PURE__ */ jsx(
1730
+ "text",
1731
+ {
1732
+ className: "nice-forecast-chart__cash-runway-label",
1733
+ x: F(H),
1734
+ y: D.top + 12,
1735
+ textAnchor: "middle",
1736
+ fill: "#ffffff",
1737
+ children: m.label ?? B.cashRunsOut ?? "💰 Cash runs out"
1738
+ }
1739
+ ),
1740
+ m.showDate !== false && /* @__PURE__ */ jsx(
1741
+ "text",
1742
+ {
1743
+ className: "nice-forecast-chart__cash-runway-label",
1744
+ x: F(H),
1745
+ y: D.top + 26,
1746
+ textAnchor: "middle",
1747
+ fill: "#ffffff",
1748
+ style: { fontSize: "0.625rem", opacity: 0.9 },
1749
+ children: Ae(H, R)
1750
+ }
1751
+ )
1752
+ ] })
1753
+ ] }),
1754
+ W.filter((n) => n.visible !== false && n.showConfidenceBand).map((n) => /* @__PURE__ */ jsx(
1755
+ "path",
1756
+ {
1757
+ className: "nice-forecast-chart__confidence-band",
1758
+ d: pe(n.data),
1759
+ fill: n.color
1760
+ },
1761
+ `band-${n.id}`
1762
+ )),
1763
+ W.filter((n) => n.visible !== false).map((n) => {
1764
+ const M = L ? n.data.filter((_) => le(_.date) < L) : n.data.filter((_) => _.value != null), z = L ? n.data.filter((_) => le(_.date) >= L) : n.data.filter((_) => _.forecast != null);
1765
+ return /* @__PURE__ */ jsxs("g", { children: [
1766
+ /* @__PURE__ */ jsx(
1767
+ "path",
1768
+ {
1769
+ className: "nice-forecast-chart__historical-line",
1770
+ d: J(M, "value"),
1771
+ stroke: n.color,
1772
+ strokeWidth: o
1773
+ }
1774
+ ),
1775
+ /* @__PURE__ */ jsx(
1776
+ "path",
1777
+ {
1778
+ className: "nice-forecast-chart__forecast-line",
1779
+ d: J(z, L ? "value" : "forecast"),
1780
+ stroke: n.color,
1781
+ strokeWidth: o
1782
+ }
1783
+ ),
1784
+ z.length > 0 && n.data.some((_) => _.forecast != null) && /* @__PURE__ */ jsx(
1785
+ "path",
1786
+ {
1787
+ className: "nice-forecast-chart__forecast-line",
1788
+ d: J(n.data, "forecast"),
1789
+ stroke: n.color,
1790
+ strokeWidth: o
1791
+ }
1792
+ ),
1793
+ s && n.data.map((_, V) => {
1794
+ const ae = _.value ?? _.forecast;
1795
+ return ae == null ? null : /* @__PURE__ */ jsx(
1796
+ "circle",
1797
+ {
1798
+ className: "nice-forecast-chart__point",
1799
+ cx: F(le(_.date)),
1800
+ cy: q(ae),
1801
+ r: h,
1802
+ fill: n.color,
1803
+ onClick: () => N?.(_, n)
1804
+ },
1805
+ V
1806
+ );
1807
+ })
1808
+ ] }, n.id);
1809
+ }),
1810
+ r.map((n) => {
1811
+ const M = F(le(n.date));
1812
+ return /* @__PURE__ */ jsxs(
1813
+ "g",
1814
+ {
1815
+ className: "nice-forecast-chart__annotation-marker",
1816
+ onClick: () => I?.(n),
1817
+ children: [
1818
+ n.showLine !== false && /* @__PURE__ */ jsx(
1819
+ "line",
1820
+ {
1821
+ className: "nice-forecast-chart__annotation-line",
1822
+ x1: M,
1823
+ x2: M,
1824
+ y1: D.top,
1825
+ y2: P.height - D.bottom,
1826
+ stroke: n.color ?? "#9ca3af"
1827
+ }
1828
+ ),
1829
+ /* @__PURE__ */ jsx("circle", { cx: M, cy: D.top + 10, r: 8, fill: n.color ?? "#9ca3af" }),
1830
+ /* @__PURE__ */ jsx("text", { x: M, y: D.top + 14, textAnchor: "middle", fill: "white", fontSize: "10", children: n.icon ?? "!" })
1831
+ ]
1832
+ },
1833
+ n.id
1834
+ );
1835
+ }),
1836
+ /* @__PURE__ */ jsx(
1837
+ "line",
1838
+ {
1839
+ className: "nice-forecast-chart__axis-line",
1840
+ x1: D.left,
1841
+ x2: D.left,
1842
+ y1: D.top,
1843
+ y2: P.height - D.bottom
1844
+ }
1845
+ ),
1846
+ /* @__PURE__ */ jsx(
1847
+ "line",
1848
+ {
1849
+ className: "nice-forecast-chart__axis-line",
1850
+ x1: D.left,
1851
+ x2: P.width - D.right,
1852
+ y1: P.height - D.bottom,
1853
+ y2: P.height - D.bottom
1854
+ }
1855
+ ),
1856
+ ce.map((n) => /* @__PURE__ */ jsx(
1857
+ "text",
1858
+ {
1859
+ className: "nice-forecast-chart__axis-label",
1860
+ x: D.left - 8,
1861
+ y: q(n) + 4,
1862
+ textAnchor: "end",
1863
+ children: l?.format ? l.format(n) : Me(n, R)
1864
+ },
1865
+ n
1866
+ )),
1867
+ oe.map((n) => /* @__PURE__ */ jsx(
1868
+ "text",
1869
+ {
1870
+ className: "nice-forecast-chart__axis-label",
1871
+ x: F(n),
1872
+ y: P.height - D.bottom + 16,
1873
+ textAnchor: "middle",
1874
+ children: C?.format ? C.format(n) : Ae(n, R)
1875
+ },
1876
+ n.getTime()
1877
+ )),
1878
+ l?.title && /* @__PURE__ */ jsx(
1879
+ "text",
1880
+ {
1881
+ className: "nice-forecast-chart__axis-title",
1882
+ x: 15,
1883
+ y: P.height / 2,
1884
+ textAnchor: "middle",
1885
+ transform: `rotate(-90, 15, ${P.height / 2})`,
1886
+ children: l.title
1887
+ }
1888
+ )
1889
+ ]
1890
+ }
1891
+ ),
1892
+ Z && /* @__PURE__ */ jsxs(
1893
+ "div",
1894
+ {
1895
+ className: "nice-forecast-chart__tooltip",
1896
+ style: { left: K.x, top: K.y },
1897
+ children: [
1898
+ /* @__PURE__ */ jsx("div", { className: "nice-forecast-chart__tooltip-date", children: Ae(Z.date, R) }),
1899
+ Z.values.map((n) => {
1900
+ const M = n.value ?? n.forecast;
1901
+ return M == null ? null : /* @__PURE__ */ jsxs("div", { className: "nice-forecast-chart__tooltip-item", children: [
1902
+ /* @__PURE__ */ jsx(
1903
+ "span",
1904
+ {
1905
+ className: "nice-forecast-chart__tooltip-color",
1906
+ style: { background: n.scenario.color }
1907
+ }
1908
+ ),
1909
+ /* @__PURE__ */ jsx("span", { className: "nice-forecast-chart__tooltip-label", children: n.scenario.name }),
1910
+ /* @__PURE__ */ jsx("span", { className: "nice-forecast-chart__tooltip-value", children: Me(M, R) })
1911
+ ] }, n.scenario.id);
1912
+ }),
1913
+ Z.values.some((n) => n.lowerBound != null) && /* @__PURE__ */ jsxs("div", { className: "nice-forecast-chart__tooltip-confidence", children: [
1914
+ B.confidence ?? "CI",
1915
+ ":",
1916
+ " ",
1917
+ Me(Z.values[0]?.lowerBound ?? 0, R),
1918
+ " –",
1919
+ " ",
1920
+ Me(Z.values[0]?.upperBound ?? 0, R)
1921
+ ] })
1922
+ ]
1923
+ }
1924
+ )
1925
+ ] }),
1926
+ S.enabled && /* @__PURE__ */ jsx("div", { className: "nice-forecast-chart__legend", children: W.map((n) => /* @__PURE__ */ jsxs(
1927
+ "div",
1928
+ {
1929
+ className: `nice-forecast-chart__legend-item ${n.visible === false ? "nice-forecast-chart__legend-item--hidden" : ""}`,
1930
+ onClick: () => E(n.id),
1931
+ children: [
1932
+ /* @__PURE__ */ jsx(
1933
+ "span",
1934
+ {
1935
+ className: `nice-forecast-chart__legend-color ${n.isBase ? "" : "nice-forecast-chart__legend-color--dashed"}`,
1936
+ style: { background: n.color }
1937
+ }
1938
+ ),
1939
+ n.name
1940
+ ]
1941
+ },
1942
+ n.id
1943
+ )) })
1944
+ ] });
1945
+ }
1946
+ ); const Xe = forwardRef(({
1947
+ data: t,
1948
+ renderNode: a,
1949
+ selectable: d,
1950
+ selectedKey: c,
1951
+ onSelect: r,
1952
+ direction: u = "top-down",
1953
+ collapsible: i = true,
1954
+ className: m,
1955
+ style: C,
1956
+ id: l
1957
+ }, v) => {
1958
+ const f = ys(l), [S, y] = useState(/* @__PURE__ */ new Set()), p = useCallback((h) => {
1959
+ y((w) => {
1960
+ const b = new Set(w);
1961
+ return b.has(h) ? b.delete(h) : b.add(h), b;
1962
+ });
1963
+ }, []), o = useCallback((h) => {
1964
+ d && r?.(h);
1965
+ }, [d, r]), s = useCallback((h) => {
1966
+ const w = S.has(h.key), b = h.children && h.children.length > 0;
1967
+ return /* @__PURE__ */ jsxs("li", { className: "nice-org-chart__item", children: [
1968
+ /* @__PURE__ */ jsxs(
1969
+ "div",
1970
+ {
1971
+ className: `nice-org-chart__node${c === h.key ? " nice-org-chart__node--selected" : ""}`,
1972
+ onClick: () => o(h.key),
1973
+ role: d ? "button" : void 0,
1974
+ children: [
1975
+ a ? a(h) : /* @__PURE__ */ jsx("span", { children: h.label }),
1976
+ i && b && /* @__PURE__ */ jsx(
1977
+ "button",
1978
+ {
1979
+ type: "button",
1980
+ className: "nice-org-chart__toggle",
1981
+ onClick: (A) => {
1982
+ A.stopPropagation(), p(h.key);
1983
+ },
1984
+ "aria-label": w ? "Expand" : "Collapse",
1985
+ children: w ? "+" : "−"
1986
+ }
1987
+ )
1988
+ ]
1989
+ }
1990
+ ),
1991
+ b && !w && /* @__PURE__ */ jsx("ul", { className: "nice-org-chart__children", children: h.children.map((A) => s(A)) })
1992
+ ] }, h.key);
1993
+ }, [S, c, a, d, i, o, p]);
1994
+ return /* @__PURE__ */ jsx(
1995
+ "div",
1996
+ {
1997
+ ref: v,
1998
+ id: f,
1999
+ className: `nice-org-chart nice-org-chart--${u} ${m || ""}`,
2000
+ style: C,
2001
+ children: /* @__PURE__ */ jsx("ul", { className: "nice-org-chart__root", children: s(t) })
2002
+ }
2003
+ );
2004
+ });
2005
+ Xe.displayName = "NiceOrganizationChart";
2006
+ function Ze(t, a, d) {
2007
+ const c = (y) => {
2008
+ const p = y.replace("#", "");
2009
+ return [parseInt(p.slice(0, 2), 16), parseInt(p.slice(2, 4), 16), parseInt(p.slice(4, 6), 16)];
2010
+ }, [r, u, i] = c(t), [m, C, l] = c(a), v = Math.round(r + (m - r) * d), f = Math.round(u + (C - u) * d), S = Math.round(i + (l - i) * d);
2011
+ return `rgb(${v},${f},${S})`;
2012
+ }
2013
+ const Ge = forwardRef(({
2014
+ data: t,
2015
+ xLabels: a,
2016
+ yLabels: d,
2017
+ colors: c = ["#e0f2fe", "#1d4ed8"],
2018
+ onCellClick: r,
2019
+ cellSize: u = 40,
2020
+ showValues: i = true,
2021
+ className: m,
2022
+ style: C,
2023
+ id: l
2024
+ }, v) => {
2025
+ const f = ys(l), { minVal: S, maxVal: y } = useMemo(() => {
2026
+ let o = 1 / 0, s = -1 / 0;
2027
+ for (const h of t) for (const w of h)
2028
+ w < o && (o = w), w > s && (s = w);
2029
+ return { minVal: o, maxVal: s };
2030
+ }, [t]), p = useCallback((o) => y === S ? 0.5 : (o - S) / (y - S), [S, y]);
2031
+ return /* @__PURE__ */ jsx("div", { ref: v, id: f, className: `nice-heatmap ${m || ""}`, style: C, children: /* @__PURE__ */ jsxs("table", { className: "nice-heatmap__table", children: [
2032
+ a && /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
2033
+ d && /* @__PURE__ */ jsx("th", {}),
2034
+ a.map((o, s) => /* @__PURE__ */ jsx("th", { className: "nice-heatmap__header", children: o }, s))
2035
+ ] }) }),
2036
+ /* @__PURE__ */ jsx("tbody", { children: t.map((o, s) => /* @__PURE__ */ jsxs("tr", { children: [
2037
+ d && /* @__PURE__ */ jsx("th", { className: "nice-heatmap__row-label", children: d[s] }),
2038
+ o.map((h, w) => /* @__PURE__ */ jsx(
2039
+ "td",
2040
+ {
2041
+ className: "nice-heatmap__cell",
2042
+ style: {
2043
+ background: Ze(c[0], c[1], p(h)),
2044
+ width: u,
2045
+ height: u,
2046
+ textAlign: "center",
2047
+ color: p(h) > 0.6 ? "#fff" : "#333",
2048
+ cursor: r ? "pointer" : void 0
2049
+ },
2050
+ onClick: () => r?.(s, w, h),
2051
+ title: String(h),
2052
+ children: i ? h : ""
2053
+ },
2054
+ w
2055
+ ))
2056
+ ] }, s)) })
2057
+ ] }) });
2058
+ });
2059
+ Ge.displayName = "NiceHeatMap";
2060
+ function Ue(t, a) {
2061
+ const d = t.reduce((l, v) => l + v.value, 0);
2062
+ if (d === 0 || t.length === 0) return [];
2063
+ const c = [];
2064
+ let { x: r, y: u, w: i, h: m } = a;
2065
+ const C = [...t].sort((l, v) => v.value - l.value);
2066
+ for (const l of C) {
2067
+ const v = l.value / d;
2068
+ if (i >= m) {
2069
+ const f = i * v;
2070
+ c.push({ x: r, y: u, w: f, h: m, node: l }), r += f, i -= f;
2071
+ } else {
2072
+ const f = m * v;
2073
+ c.push({ x: r, y: u, w: i, h: f, node: l }), u += f, m -= f;
2074
+ }
2075
+ }
2076
+ return c;
2077
+ }
2078
+ const qe = ["#3b82f6", "#10b981", "#f59e0b", "#ef4444", "#8b5cf6", "#06b6d4", "#ec4899", "#84cc16"], Je = forwardRef(({
2079
+ data: t,
2080
+ width: a = 600,
2081
+ height: d = 400,
2082
+ onNodeClick: c,
2083
+ colors: r = qe,
2084
+ className: u,
2085
+ style: i,
2086
+ id: m
2087
+ }, C) => {
2088
+ const l = ys(m), v = useMemo(() => {
2089
+ const f = t.children ?? [t];
2090
+ return Ue(f, { x: 0, y: 0, w: a, h: d });
2091
+ }, [t, a, d]);
2092
+ return /* @__PURE__ */ jsx("div", { ref: C, id: l, className: `nice-treemap ${u || ""}`, style: i, children: /* @__PURE__ */ jsx("svg", { width: a, height: d, className: "nice-treemap__svg", children: v.map((f, S) => /* @__PURE__ */ jsxs("g", { onClick: () => c?.(f.node), style: { cursor: c ? "pointer" : void 0 }, children: [
2093
+ /* @__PURE__ */ jsx(
2094
+ "rect",
2095
+ {
2096
+ x: f.x,
2097
+ y: f.y,
2098
+ width: Math.max(f.w - 1, 0),
2099
+ height: Math.max(f.h - 1, 0),
2100
+ fill: f.node.color ?? r[S % r.length],
2101
+ rx: 2
2102
+ }
2103
+ ),
2104
+ f.w > 40 && f.h > 20 && /* @__PURE__ */ jsx(
2105
+ "text",
2106
+ {
2107
+ x: f.x + f.w / 2,
2108
+ y: f.y + f.h / 2,
2109
+ textAnchor: "middle",
2110
+ dominantBaseline: "central",
2111
+ fill: "#fff",
2112
+ fontSize: Math.min(12, f.w / 6),
2113
+ className: "nice-treemap__label",
2114
+ children: f.node.label
2115
+ }
2116
+ )
2117
+ ] }, f.node.key)) }) });
2118
+ });
2119
+ Je.displayName = "NiceTreeMap";
2120
+ const Qe = forwardRef(({
2121
+ data: t,
2122
+ type: a = "candlestick",
2123
+ showVolume: d = true,
2124
+ width: c = 800,
2125
+ height: r = 400,
2126
+ bullColor: u = "#22c55e",
2127
+ bearColor: i = "#ef4444",
2128
+ className: m,
2129
+ style: C,
2130
+ id: l
2131
+ }, v) => {
2132
+ const f = ys(l), S = { top: 20, right: 20, bottom: d ? 80 : 30, left: 60 }, y = c - S.left - S.right, p = d ? 50 : 0, o = r - S.top - S.bottom - p, { minP: s, maxP: h, maxVol: w } = useMemo(() => {
2133
+ let g = 1 / 0, T = -1 / 0, x = 0;
2134
+ for (const O of t)
2135
+ O.low < g && (g = O.low), O.high > T && (T = O.high), O.volume && O.volume > x && (x = O.volume);
2136
+ return { minP: g, maxP: T, maxVol: x };
2137
+ }, [t]), b = Math.max(1, y / t.length * 0.7), A = (g) => S.left + (g + 0.5) * (y / t.length), N = (g) => S.top + o - (g - s) / (h - s || 1) * o, I = (g) => r - S.bottom - p + p * (1 - g / (w || 1));
2138
+ return /* @__PURE__ */ jsx("div", { ref: v, id: f, className: `nice-stock-chart ${m || ""}`, style: C, children: /* @__PURE__ */ jsxs("svg", { width: c, height: r, className: "nice-stock-chart__svg", children: [
2139
+ [0, 0.25, 0.5, 0.75, 1].map((g) => {
2140
+ const T = s + g * (h - s);
2141
+ return /* @__PURE__ */ jsxs("g", { children: [
2142
+ /* @__PURE__ */ jsx(
2143
+ "line",
2144
+ {
2145
+ x1: S.left,
2146
+ x2: c - S.right,
2147
+ y1: N(T),
2148
+ y2: N(T),
2149
+ stroke: "#e5e7eb",
2150
+ strokeDasharray: "2,2"
2151
+ }
2152
+ ),
2153
+ /* @__PURE__ */ jsx("text", { x: S.left - 4, y: N(T) + 4, textAnchor: "end", fontSize: 10, fill: "#888", children: T.toFixed(2) })
2154
+ ] }, g);
2155
+ }),
2156
+ a === "line" ? /* @__PURE__ */ jsx(
2157
+ "polyline",
2158
+ {
2159
+ points: t.map((g, T) => `${A(T)},${N(g.close)}`).join(" "),
2160
+ fill: "none",
2161
+ stroke: u,
2162
+ strokeWidth: 1.5
2163
+ }
2164
+ ) : t.map((g, T) => {
2165
+ const x = g.close >= g.open, O = x ? u : i, B = A(T);
2166
+ if (a === "ohlc")
2167
+ return /* @__PURE__ */ jsxs("g", { children: [
2168
+ /* @__PURE__ */ jsx("line", { x1: B, x2: B, y1: N(g.high), y2: N(g.low), stroke: O, strokeWidth: 1 }),
2169
+ /* @__PURE__ */ jsx("line", { x1: B - b / 2, x2: B, y1: N(g.open), y2: N(g.open), stroke: O, strokeWidth: 1.5 }),
2170
+ /* @__PURE__ */ jsx("line", { x1: B, x2: B + b / 2, y1: N(g.close), y2: N(g.close), stroke: O, strokeWidth: 1.5 })
2171
+ ] }, T);
2172
+ const R = N(Math.max(g.open, g.close)), G = N(Math.min(g.open, g.close));
2173
+ return /* @__PURE__ */ jsxs("g", { children: [
2174
+ /* @__PURE__ */ jsx("line", { x1: B, x2: B, y1: N(g.high), y2: N(g.low), stroke: O, strokeWidth: 1 }),
2175
+ /* @__PURE__ */ jsx(
2176
+ "rect",
2177
+ {
2178
+ x: B - b / 2,
2179
+ y: R,
2180
+ width: b,
2181
+ height: Math.max(G - R, 1),
2182
+ fill: x ? "transparent" : O,
2183
+ stroke: O,
2184
+ strokeWidth: 1
2185
+ }
2186
+ )
2187
+ ] }, T);
2188
+ }),
2189
+ d && t.map((g, T) => {
2190
+ if (!g.volume) return null;
2191
+ const x = g.close >= g.open;
2192
+ return /* @__PURE__ */ jsx(
2193
+ "rect",
2194
+ {
2195
+ x: A(T) - b / 2,
2196
+ y: I(g.volume),
2197
+ width: b,
2198
+ height: r - S.bottom - I(g.volume),
2199
+ fill: x ? u : i,
2200
+ opacity: 0.3
2201
+ },
2202
+ `v${T}`
2203
+ );
2204
+ }),
2205
+ t.map((g, T) => T % Math.max(1, Math.floor(t.length / 8)) !== 0 ? null : /* @__PURE__ */ jsx(
2206
+ "text",
2207
+ {
2208
+ x: A(T),
2209
+ y: r - S.bottom + p + 14,
2210
+ textAnchor: "middle",
2211
+ fontSize: 9,
2212
+ fill: "#888",
2213
+ children: g.date
2214
+ },
2215
+ `l${T}`
2216
+ ))
2217
+ ] }) });
2218
+ });
2219
+ Qe.displayName = "NiceStockChart";
2220
+
2221
+ export { fe as C, ft as N, mt as a, De as b, ht as d, pt as f, Ge as g, dt as h, Fe as i, Xe as j, it as k, lt as l, xt as m, Ee as n, ut as o, Qe as p, Je as q, Ye as r, rt as v, gt as w, yt as x };
2222
+ //# sourceMappingURL=NiceStockChart-Cpmv9_Cc.js.map