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