@nice2dev/ui-presentations 1.0.5 → 1.0.8

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