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