@nice2dev/ui-3d 1.1.0 → 1.1.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.
Files changed (206) hide show
  1. package/dist/cjs/collaborative/collaborativeScene.js +16 -8
  2. package/dist/cjs/collaborative/collaborativeScene.js.map +1 -1
  3. package/dist/cjs/core/i18n.js +3 -3
  4. package/dist/cjs/dance/DanceBridge.js +65 -30
  5. package/dist/cjs/dance/DanceBridge.js.map +1 -1
  6. package/dist/cjs/dance/DanceScoreEngine.js +37 -23
  7. package/dist/cjs/dance/DanceScoreEngine.js.map +1 -1
  8. package/dist/cjs/dance/PoseDetector.js +92 -49
  9. package/dist/cjs/dance/PoseDetector.js.map +1 -1
  10. package/dist/cjs/material/NiceMaterialEditor.js +134 -91
  11. package/dist/cjs/material/NiceMaterialEditor.js.map +1 -1
  12. package/dist/cjs/material/materialEditorUtils.js +86 -55
  13. package/dist/cjs/material/materialEditorUtils.js.map +1 -1
  14. package/dist/cjs/model/ModelEditor.js +16 -14
  15. package/dist/cjs/model/ModelEditor.js.map +1 -1
  16. package/dist/cjs/model/ModelEditorLeftPanel.js +21 -15
  17. package/dist/cjs/model/ModelEditorLeftPanel.js.map +1 -1
  18. package/dist/cjs/model/ModelEditorMenuBar.js +23 -10
  19. package/dist/cjs/model/ModelEditorMenuBar.js.map +1 -1
  20. package/dist/cjs/model/ModelEditorRightPanel.js +32 -27
  21. package/dist/cjs/model/ModelEditorRightPanel.js.map +1 -1
  22. package/dist/cjs/model/ModelEditorSubComponents.js +20 -20
  23. package/dist/cjs/model/ModelEditorSubComponents.js.map +1 -1
  24. package/dist/cjs/model/ModelEditorTimeline.js +12 -11
  25. package/dist/cjs/model/ModelEditorTimeline.js.map +1 -1
  26. package/dist/cjs/model/ModelEditorToolbar.js +5 -5
  27. package/dist/cjs/model/ModelEditorToolbar.js.map +1 -1
  28. package/dist/cjs/model/ModelEditorViewport.js +12 -8
  29. package/dist/cjs/model/ModelEditorViewport.js.map +1 -1
  30. package/dist/cjs/model/ModelViewer.js +16 -15
  31. package/dist/cjs/model/ModelViewer.js.map +1 -1
  32. package/dist/cjs/model/NiceArmatureEditor.js +53 -30
  33. package/dist/cjs/model/NiceArmatureEditor.js.map +1 -1
  34. package/dist/cjs/model/NiceMorphTargetEditor.js +51 -30
  35. package/dist/cjs/model/NiceMorphTargetEditor.js.map +1 -1
  36. package/dist/cjs/model/NiceOctree.js +62 -37
  37. package/dist/cjs/model/NiceOctree.js.map +1 -1
  38. package/dist/cjs/model/NicePhysicsSimulation.js +74 -36
  39. package/dist/cjs/model/NicePhysicsSimulation.js.map +1 -1
  40. package/dist/cjs/model/NiceProceduralGeometry.js +101 -31
  41. package/dist/cjs/model/NiceProceduralGeometry.js.map +1 -1
  42. package/dist/cjs/model/NiceTerrainEditor.js +88 -38
  43. package/dist/cjs/model/NiceTerrainEditor.js.map +1 -1
  44. package/dist/cjs/model/NiceWeightPainter.js +46 -24
  45. package/dist/cjs/model/NiceWeightPainter.js.map +1 -1
  46. package/dist/cjs/model/NiceXRPreview.js +89 -43
  47. package/dist/cjs/model/NiceXRPreview.js.map +1 -1
  48. package/dist/cjs/model/cadModeUtils.js +2 -2
  49. package/dist/cjs/model/cadModeUtils.js.map +1 -1
  50. package/dist/cjs/model/editorShortcuts.js +69 -35
  51. package/dist/cjs/model/editorShortcuts.js.map +1 -1
  52. package/dist/cjs/model/modelEditorTypes.js +56 -52
  53. package/dist/cjs/model/modelEditorTypes.js.map +1 -1
  54. package/dist/cjs/model/modelEditorUtils.js +356 -131
  55. package/dist/cjs/model/modelEditorUtils.js.map +1 -1
  56. package/dist/cjs/model/simsModeUtils.js +819 -74
  57. package/dist/cjs/model/simsModeUtils.js.map +1 -1
  58. package/dist/cjs/model/useModelEditor.js +501 -394
  59. package/dist/cjs/model/useModelEditor.js.map +1 -1
  60. package/dist/cjs/model/useModelViewer.js +117 -86
  61. package/dist/cjs/model/useModelViewer.js.map +1 -1
  62. package/dist/cjs/particle/NiceParticleEditor.js +126 -69
  63. package/dist/cjs/particle/NiceParticleEditor.js.map +1 -1
  64. package/dist/cjs/particle/particleEditorUtils.js +64 -27
  65. package/dist/cjs/particle/particleEditorUtils.js.map +1 -1
  66. package/dist/cjs/rendering/NiceCascadedShadows.js +35 -23
  67. package/dist/cjs/rendering/NiceCascadedShadows.js.map +1 -1
  68. package/dist/cjs/rendering/NiceRenderExport.js +26 -12
  69. package/dist/cjs/rendering/NiceRenderExport.js.map +1 -1
  70. package/dist/cjs/rendering/NiceSSAO.js +28 -23
  71. package/dist/cjs/rendering/NiceSSAO.js.map +1 -1
  72. package/dist/cjs/rendering/NiceSSR.js +22 -18
  73. package/dist/cjs/rendering/NiceSSR.js.map +1 -1
  74. package/dist/cjs/rendering/NiceWebGPURenderer.js +60 -37
  75. package/dist/cjs/rendering/NiceWebGPURenderer.js.map +1 -1
  76. package/dist/cjs/ui/dist/NiceErrorBoundary-D75yr_WE.js +572 -0
  77. package/dist/cjs/ui/dist/NiceErrorBoundary-D75yr_WE.js.map +1 -0
  78. package/dist/cjs/ui/dist/NiceForm-CKoJA6NG.js +4979 -0
  79. package/dist/cjs/ui/dist/NiceForm-CKoJA6NG.js.map +1 -0
  80. package/dist/cjs/ui/dist/NiceModal-1QX7NhyH.js +98 -0
  81. package/dist/cjs/ui/dist/NiceModal-1QX7NhyH.js.map +1 -0
  82. package/dist/cjs/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js +5244 -0
  83. package/dist/cjs/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js.map +1 -0
  84. package/dist/cjs/ui/dist/NicePagination-DbE-uOkl.js +174 -0
  85. package/dist/cjs/ui/dist/NicePagination-DbE-uOkl.js.map +1 -0
  86. package/dist/cjs/ui/dist/NicePinCodeInput-B8cI8zu8.js +10459 -0
  87. package/dist/cjs/ui/dist/NicePinCodeInput-B8cI8zu8.js.map +1 -0
  88. package/dist/cjs/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js +6313 -0
  89. package/dist/cjs/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js.map +1 -0
  90. package/dist/cjs/ui/dist/NiceTabs-DzLHzwuA.js +1639 -0
  91. package/dist/cjs/ui/dist/NiceTabs-DzLHzwuA.js.map +1 -0
  92. package/dist/cjs/ui/dist/NiceWindow-DeC83yfE.js +807 -0
  93. package/dist/cjs/ui/dist/NiceWindow-DeC83yfE.js.map +1 -0
  94. package/dist/cjs/ui/dist/charts-BAS21jkC.js +3833 -0
  95. package/dist/cjs/ui/dist/charts-BAS21jkC.js.map +1 -0
  96. package/dist/cjs/ui/dist/core-Da43q-pO.js +11683 -0
  97. package/dist/cjs/ui/dist/core-Da43q-pO.js.map +1 -0
  98. package/dist/cjs/ui/dist/index-pAuGTbuB.js +28876 -0
  99. package/dist/cjs/ui/dist/index-pAuGTbuB.js.map +1 -0
  100. package/dist/cjs/uv/NiceUVEditor.js +115 -86
  101. package/dist/cjs/uv/NiceUVEditor.js.map +1 -1
  102. package/dist/cjs/uv/uvEditorUtils.js +41 -23
  103. package/dist/cjs/uv/uvEditorUtils.js.map +1 -1
  104. package/dist/esm/collaborative/collaborativeScene.js +16 -8
  105. package/dist/esm/collaborative/collaborativeScene.js.map +1 -1
  106. package/dist/esm/dance/DanceBridge.js +55 -20
  107. package/dist/esm/dance/DanceBridge.js.map +1 -1
  108. package/dist/esm/dance/DanceScoreEngine.js +29 -15
  109. package/dist/esm/dance/DanceScoreEngine.js.map +1 -1
  110. package/dist/esm/dance/PoseDetector.js +73 -30
  111. package/dist/esm/dance/PoseDetector.js.map +1 -1
  112. package/dist/esm/material/NiceMaterialEditor.js +115 -72
  113. package/dist/esm/material/NiceMaterialEditor.js.map +1 -1
  114. package/dist/esm/material/materialEditorUtils.js +86 -55
  115. package/dist/esm/material/materialEditorUtils.js.map +1 -1
  116. package/dist/esm/model/ModelEditor.js +16 -14
  117. package/dist/esm/model/ModelEditor.js.map +1 -1
  118. package/dist/esm/model/ModelEditorLeftPanel.js +21 -15
  119. package/dist/esm/model/ModelEditorLeftPanel.js.map +1 -1
  120. package/dist/esm/model/ModelEditorMenuBar.js +23 -10
  121. package/dist/esm/model/ModelEditorMenuBar.js.map +1 -1
  122. package/dist/esm/model/ModelEditorRightPanel.js +32 -27
  123. package/dist/esm/model/ModelEditorRightPanel.js.map +1 -1
  124. package/dist/esm/model/ModelEditorSubComponents.js +17 -17
  125. package/dist/esm/model/ModelEditorSubComponents.js.map +1 -1
  126. package/dist/esm/model/ModelEditorTimeline.js +12 -11
  127. package/dist/esm/model/ModelEditorTimeline.js.map +1 -1
  128. package/dist/esm/model/ModelEditorToolbar.js +5 -5
  129. package/dist/esm/model/ModelEditorToolbar.js.map +1 -1
  130. package/dist/esm/model/ModelEditorViewport.js +12 -8
  131. package/dist/esm/model/ModelEditorViewport.js.map +1 -1
  132. package/dist/esm/model/ModelViewer.js +8 -7
  133. package/dist/esm/model/ModelViewer.js.map +1 -1
  134. package/dist/esm/model/NiceArmatureEditor.js +36 -13
  135. package/dist/esm/model/NiceArmatureEditor.js.map +1 -1
  136. package/dist/esm/model/NiceMorphTargetEditor.js +34 -13
  137. package/dist/esm/model/NiceMorphTargetEditor.js.map +1 -1
  138. package/dist/esm/model/NiceOctree.js +47 -22
  139. package/dist/esm/model/NiceOctree.js.map +1 -1
  140. package/dist/esm/model/NicePhysicsSimulation.js +51 -13
  141. package/dist/esm/model/NicePhysicsSimulation.js.map +1 -1
  142. package/dist/esm/model/NiceProceduralGeometry.js +94 -24
  143. package/dist/esm/model/NiceProceduralGeometry.js.map +1 -1
  144. package/dist/esm/model/NiceTerrainEditor.js +70 -20
  145. package/dist/esm/model/NiceTerrainEditor.js.map +1 -1
  146. package/dist/esm/model/NiceWeightPainter.js +33 -11
  147. package/dist/esm/model/NiceWeightPainter.js.map +1 -1
  148. package/dist/esm/model/NiceXRPreview.js +72 -26
  149. package/dist/esm/model/NiceXRPreview.js.map +1 -1
  150. package/dist/esm/model/cadModeUtils.js +2 -2
  151. package/dist/esm/model/cadModeUtils.js.map +1 -1
  152. package/dist/esm/model/editorShortcuts.js +69 -35
  153. package/dist/esm/model/editorShortcuts.js.map +1 -1
  154. package/dist/esm/model/modelEditorTypes.js +56 -52
  155. package/dist/esm/model/modelEditorTypes.js.map +1 -1
  156. package/dist/esm/model/modelEditorUtils.js +356 -131
  157. package/dist/esm/model/modelEditorUtils.js.map +1 -1
  158. package/dist/esm/model/simsModeUtils.js +819 -74
  159. package/dist/esm/model/simsModeUtils.js.map +1 -1
  160. package/dist/esm/model/useModelEditor.js +384 -277
  161. package/dist/esm/model/useModelEditor.js.map +1 -1
  162. package/dist/esm/model/useModelViewer.js +56 -25
  163. package/dist/esm/model/useModelViewer.js.map +1 -1
  164. package/dist/esm/particle/NiceParticleEditor.js +116 -59
  165. package/dist/esm/particle/NiceParticleEditor.js.map +1 -1
  166. package/dist/esm/particle/particleEditorUtils.js +64 -27
  167. package/dist/esm/particle/particleEditorUtils.js.map +1 -1
  168. package/dist/esm/rendering/NiceCascadedShadows.js +24 -12
  169. package/dist/esm/rendering/NiceCascadedShadows.js.map +1 -1
  170. package/dist/esm/rendering/NiceRenderExport.js +22 -8
  171. package/dist/esm/rendering/NiceRenderExport.js.map +1 -1
  172. package/dist/esm/rendering/NiceSSAO.js +11 -6
  173. package/dist/esm/rendering/NiceSSAO.js.map +1 -1
  174. package/dist/esm/rendering/NiceSSR.js +9 -5
  175. package/dist/esm/rendering/NiceSSR.js.map +1 -1
  176. package/dist/esm/rendering/NiceWebGPURenderer.js +40 -17
  177. package/dist/esm/rendering/NiceWebGPURenderer.js.map +1 -1
  178. package/dist/esm/ui/dist/NiceErrorBoundary-D75yr_WE.js +563 -0
  179. package/dist/esm/ui/dist/NiceErrorBoundary-D75yr_WE.js.map +1 -0
  180. package/dist/esm/ui/dist/NiceForm-CKoJA6NG.js +4960 -0
  181. package/dist/esm/ui/dist/NiceForm-CKoJA6NG.js.map +1 -0
  182. package/dist/esm/ui/dist/NiceModal-1QX7NhyH.js +96 -0
  183. package/dist/esm/ui/dist/NiceModal-1QX7NhyH.js.map +1 -0
  184. package/dist/esm/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js +5201 -0
  185. package/dist/esm/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js.map +1 -0
  186. package/dist/esm/ui/dist/NicePagination-DbE-uOkl.js +172 -0
  187. package/dist/esm/ui/dist/NicePagination-DbE-uOkl.js.map +1 -0
  188. package/dist/esm/ui/dist/NicePinCodeInput-B8cI8zu8.js +10408 -0
  189. package/dist/esm/ui/dist/NicePinCodeInput-B8cI8zu8.js.map +1 -0
  190. package/dist/esm/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js +6296 -0
  191. package/dist/esm/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js.map +1 -0
  192. package/dist/esm/ui/dist/NiceTabs-DzLHzwuA.js +1630 -0
  193. package/dist/esm/ui/dist/NiceTabs-DzLHzwuA.js.map +1 -0
  194. package/dist/esm/ui/dist/NiceWindow-DeC83yfE.js +796 -0
  195. package/dist/esm/ui/dist/NiceWindow-DeC83yfE.js.map +1 -0
  196. package/dist/esm/ui/dist/charts-BAS21jkC.js +3809 -0
  197. package/dist/esm/ui/dist/charts-BAS21jkC.js.map +1 -0
  198. package/dist/esm/ui/dist/core-Da43q-pO.js +11502 -0
  199. package/dist/esm/ui/dist/core-Da43q-pO.js.map +1 -0
  200. package/dist/esm/ui/dist/index-pAuGTbuB.js +28792 -0
  201. package/dist/esm/ui/dist/index-pAuGTbuB.js.map +1 -0
  202. package/dist/esm/uv/NiceUVEditor.js +91 -62
  203. package/dist/esm/uv/NiceUVEditor.js.map +1 -1
  204. package/dist/esm/uv/uvEditorUtils.js +41 -23
  205. package/dist/esm/uv/uvEditorUtils.js.map +1 -1
  206. package/package.json +2 -2
@@ -0,0 +1,3833 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var _e = require('react');
5
+ var coreDa43qPO = require('./core-Da43q-pO.js');
6
+
7
+ const ke = [
8
+ "var(--color-primary, #3b82f6)",
9
+ "var(--color-error, #ef4444)",
10
+ "var(--color-success, #22c55e)",
11
+ "var(--color-warning, #f59e0b)",
12
+ "var(--color-accent, #8b5cf6)",
13
+ "var(--color-accent-pink, #ec4899)",
14
+ "var(--color-info, #06b6d4)",
15
+ "#84cc16"
16
+ ], Re = ({
17
+ series: t,
18
+ categories: o,
19
+ width: s = 600,
20
+ height: l = 400,
21
+ title: c,
22
+ showLegend: v = true,
23
+ showGrid: m = true,
24
+ axisLabels: A = true,
25
+ yAxisLabel: D,
26
+ xAxisLabel: w,
27
+ stacked: p,
28
+ animated: k,
29
+ zoomable: z,
30
+ crosshair: C,
31
+ annotations: M,
32
+ legendInteractive: i,
33
+ onDataPointClick: d,
34
+ exportable: u,
35
+ className: S,
36
+ style: g
37
+ }) => {
38
+ const x = _e.useRef(null), [b, y] = _e.useState(/* @__PURE__ */ new Set()), [h, B] = _e.useState(null), [a, _] = _e.useState(null), [I, P] = _e.useState(false), Z = _e.useRef(null), U = _e.useMemo(
39
+ () => t.filter((T) => !b.has(T.name)),
40
+ [t, b]
41
+ ), V = _e.useCallback(
42
+ (T) => {
43
+ i && y((re) => {
44
+ const ce = new Set(re);
45
+ return ce.has(T) ? ce.delete(T) : ce.add(T), ce;
46
+ });
47
+ },
48
+ [i]
49
+ ), G = {
50
+ top: c ? 40 : 20,
51
+ right: 20,
52
+ bottom: w ? 60 : 40,
53
+ left: D ? 60 : 50
54
+ }, Q = s - G.left - G.right, q = l - G.top - G.bottom, J = U[0]?.data.length ?? t[0]?.data.length ?? 0, n = a?.start ?? 0, H = a?.end ?? J, F = H - n, W = _e.useMemo(
55
+ () => U.map((T) => ({ ...T, data: T.data.slice(n, H) })),
56
+ [U, n, H]
57
+ ), f = _e.useMemo(
58
+ () => o?.slice(n, H),
59
+ [o, n, H]
60
+ ), { minY: Y, maxY: j, yTicks: ee } = _e.useMemo(() => {
61
+ let T;
62
+ if (p) {
63
+ T = [];
64
+ for (let N = 0; N < F; N++)
65
+ T.push(W.reduce((K, ie) => K + (ie.data[N] || 0), 0));
66
+ } else
67
+ T = W.flatMap((N) => N.data);
68
+ T.length === 0 && (T = [0]);
69
+ const re = Math.min(0, ...T), ce = Math.max(0, ...T), se = ce - re || 1, de = Math.pow(10, Math.floor(Math.log10(se))) || 1, r = Math.floor(re / de) * de, R = Math.ceil(ce / de) * de, E = [];
70
+ for (let N = r; N <= R; N += de)
71
+ E.push(Math.round(N * 1e6) / 1e6);
72
+ return E.length < 2 && E.push(R), { minY: r, maxY: R, yTicks: E };
73
+ }, [W, F, p]), O = (T) => q - (T - Y) / (j - Y || 1) * q, te = (T) => (T + 0.5) / F * Q, pe = F > 0 ? Q / F / (p ? 1.5 : Math.max(U.length, 1) * 1.5) : 20, L = _e.useCallback(
74
+ (T) => {
75
+ if (!z)
76
+ return;
77
+ T.preventDefault();
78
+ const re = a ?? { start: 0, end: J }, ce = re.end - re.start, se = (re.start + re.end) / 2, de = T.deltaY > 0 ? 1.2 : 0.8, r = Math.max(2, Math.min(J, Math.round(ce * de))), R = Math.max(0, Math.round(se - r / 2)), E = Math.min(J, R + r);
79
+ _({ start: R, end: E });
80
+ },
81
+ [z, a, J]
82
+ ), X = _e.useCallback(
83
+ (T) => {
84
+ z && (P(true), Z.current = { x: T.clientX, range: a ?? { start: 0, end: J } });
85
+ },
86
+ [z, a, J]
87
+ ), ne = _e.useCallback(
88
+ (T) => {
89
+ const re = x.current?.getBoundingClientRect();
90
+ if (re && B({ x: T.clientX - re.left - G.left, y: T.clientY - re.top - G.top }), I && Z.current && z) {
91
+ const ce = T.clientX - Z.current.x, se = Q / F, de = -Math.round(ce / se), r = Z.current.range, R = r.end - r.start;
92
+ let E = r.start + de;
93
+ E < 0 && (E = 0), E + R > J && (E = J - R), _({ start: E, end: E + R });
94
+ }
95
+ },
96
+ [I, z, Q, F, J, G.left, G.top]
97
+ ), ue = _e.useCallback(() => {
98
+ P(false), Z.current = null;
99
+ }, []), _e$1 = _e.useCallback(() => {
100
+ B(null), P(false), Z.current = null;
101
+ }, []), ge = _e.useCallback(() => {
102
+ const T = x.current;
103
+ if (!T)
104
+ return;
105
+ const re = new XMLSerializer().serializeToString(T), ce = document.createElement("canvas");
106
+ ce.width = s, ce.height = l + (v ? 30 : 0);
107
+ const se = ce.getContext("2d");
108
+ if (!se)
109
+ return;
110
+ const de = new Image();
111
+ de.onload = () => {
112
+ se.fillStyle = "var(--bg-primary, #fff)", se.fillRect(0, 0, ce.width, ce.height), se.drawImage(de, 0, 0);
113
+ const r = document.createElement("a");
114
+ r.download = "chart.png", r.href = ce.toDataURL("image/png"), r.click();
115
+ }, de.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(re);
116
+ }, [s, l, v]), ye = l + (v ? 30 : 0), $e = W.length > 0 && W.every((T) => T.type === "radar"), Se = _e.useMemo(() => {
117
+ if (!$e)
118
+ return 1;
119
+ const T = W.flatMap((re) => re.data);
120
+ return Math.max(1, ...T);
121
+ }, [$e, W]);
122
+ if ($e) {
123
+ const T = s / 2, re = (l - G.top - G.bottom) / 2 + G.top, ce = Math.min(Q, l - G.top - G.bottom) / 2 - 10, se = f?.length ?? W[0]?.data.length ?? 0, de = (E) => E / se * Math.PI * 2 - Math.PI / 2, r = (E, N) => {
124
+ const K = N / Se * ce;
125
+ return [T + Math.cos(de(E)) * K, re + Math.sin(de(E)) * K];
126
+ }, R = 4;
127
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-chart nice-chart--radar ${S || ""}`, style: g, children: /* @__PURE__ */ jsxRuntime.jsxs(
128
+ "svg",
129
+ {
130
+ ref: x,
131
+ viewBox: `0 0 ${s} ${ye}`,
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
+ c && /* @__PURE__ */ jsxRuntime.jsx("text", { x: s / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: c }),
139
+ m && Array.from({ length: R }, (E, N) => {
140
+ const K = (N + 1) / R * ce, ie = [];
141
+ for (let le = 0; le < se; le++)
142
+ ie.push(`${T + Math.cos(de(le)) * K},${re + Math.sin(de(le)) * K}`);
143
+ return /* @__PURE__ */ jsxRuntime.jsx(
144
+ "polygon",
145
+ {
146
+ points: ie.join(" "),
147
+ fill: "none",
148
+ className: "nice-chart__grid-line"
149
+ },
150
+ N
151
+ );
152
+ }),
153
+ Array.from({ length: se }, (E, N) => {
154
+ const [K, ie] = r(N, Se);
155
+ return /* @__PURE__ */ jsxRuntime.jsx("line", { x1: T, y1: re, x2: K, y2: ie, className: "nice-chart__grid-line" }, N);
156
+ }),
157
+ A && f?.map((E, N) => {
158
+ const [K, ie] = r(N, Se * 1.12);
159
+ return /* @__PURE__ */ jsxRuntime.jsx(
160
+ "text",
161
+ {
162
+ x: K,
163
+ y: ie,
164
+ textAnchor: "middle",
165
+ dominantBaseline: "middle",
166
+ className: "nice-chart__axis-label",
167
+ children: E
168
+ },
169
+ N
170
+ );
171
+ }),
172
+ W.map((E, N) => {
173
+ const K = E.color || ke[N % ke.length], ie = E.data.map((le, he) => r(he, le).join(",")).join(" ");
174
+ return /* @__PURE__ */ jsxRuntime.jsxs(
175
+ "g",
176
+ {
177
+ className: k ? "nice-chart__series nice-chart__series--radar nice-chart__series--anim" : "nice-chart__series nice-chart__series--radar",
178
+ children: [
179
+ /* @__PURE__ */ jsxRuntime.jsx(
180
+ "polygon",
181
+ {
182
+ points: ie,
183
+ fill: K,
184
+ fillOpacity: 0.2,
185
+ stroke: K,
186
+ strokeWidth: 2
187
+ }
188
+ ),
189
+ E.data.map((le, he) => {
190
+ const [we, Me] = r(he, le);
191
+ return /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: we, cy: Me, r: 3, fill: K, children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${E.name}: ${le}` }) }, he);
192
+ })
193
+ ]
194
+ },
195
+ E.name
196
+ );
197
+ }),
198
+ v && /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(${G.left}, ${l})`, children: t.map((E, N) => {
199
+ const K = N * 120, ie = b.has(E.name);
200
+ return /* @__PURE__ */ jsxRuntime.jsxs(
201
+ "g",
202
+ {
203
+ transform: `translate(${K}, 10)`,
204
+ style: i ? { cursor: "pointer" } : void 0,
205
+ onClick: () => V(E.name),
206
+ opacity: ie ? 0.35 : 1,
207
+ children: [
208
+ /* @__PURE__ */ jsxRuntime.jsx(
209
+ "rect",
210
+ {
211
+ width: 12,
212
+ height: 12,
213
+ rx: 2,
214
+ fill: E.color || ke[N % ke.length]
215
+ }
216
+ ),
217
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: 16, y: 10, className: "nice-chart__legend-text", children: E.name })
218
+ ]
219
+ },
220
+ E.name
221
+ );
222
+ }) })
223
+ ]
224
+ }
225
+ ) });
226
+ }
227
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `nice-chart ${S || ""}`, style: g, children: [
228
+ u && /* @__PURE__ */ jsxRuntime.jsx(
229
+ "button",
230
+ {
231
+ type: "button",
232
+ className: "nice-chart__export-btn",
233
+ onClick: ge,
234
+ title: "Export PNG",
235
+ children: "📷"
236
+ }
237
+ ),
238
+ /* @__PURE__ */ jsxRuntime.jsxs(
239
+ "svg",
240
+ {
241
+ ref: x,
242
+ viewBox: `0 0 ${s} ${ye}`,
243
+ preserveAspectRatio: "xMidYMid meet",
244
+ width: "100%",
245
+ height: "100%",
246
+ style: { display: "block", maxWidth: "100%", maxHeight: "100%" },
247
+ className: "nice-chart__svg",
248
+ onWheel: L,
249
+ onMouseDown: X,
250
+ onMouseMove: ne,
251
+ onMouseUp: ue,
252
+ onMouseLeave: _e$1,
253
+ children: [
254
+ /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${G.left},${G.top})`, children: [
255
+ c && /* @__PURE__ */ jsxRuntime.jsx("text", { x: Q / 2, y: -10, textAnchor: "middle", className: "nice-chart__title", children: c }),
256
+ m && ee.map((T) => /* @__PURE__ */ jsxRuntime.jsx(
257
+ "line",
258
+ {
259
+ x1: 0,
260
+ y1: O(T),
261
+ x2: Q,
262
+ y2: O(T),
263
+ className: "nice-chart__grid-line"
264
+ },
265
+ `grid-${T}`
266
+ )),
267
+ A && ee.map((T) => /* @__PURE__ */ jsxRuntime.jsx(
268
+ "text",
269
+ {
270
+ x: -8,
271
+ y: O(T) + 4,
272
+ textAnchor: "end",
273
+ className: "nice-chart__axis-label",
274
+ children: T
275
+ },
276
+ `ylabel-${T}`
277
+ )),
278
+ A && f && f.map((T, re) => /* @__PURE__ */ jsxRuntime.jsx(
279
+ "text",
280
+ {
281
+ x: te(re),
282
+ y: q + 20,
283
+ textAnchor: "middle",
284
+ className: "nice-chart__axis-label",
285
+ children: T
286
+ },
287
+ re
288
+ )),
289
+ D && /* @__PURE__ */ jsxRuntime.jsx(
290
+ "text",
291
+ {
292
+ x: -G.left + 14,
293
+ y: q / 2,
294
+ textAnchor: "middle",
295
+ transform: `rotate(-90, -${G.left - 14}, ${q / 2})`,
296
+ className: "nice-chart__axis-title",
297
+ children: D
298
+ }
299
+ ),
300
+ w && /* @__PURE__ */ jsxRuntime.jsx("text", { x: Q / 2, y: q + 45, textAnchor: "middle", className: "nice-chart__axis-title", children: w }),
301
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: 0, y1: 0, x2: 0, y2: q, className: "nice-chart__axis" }),
302
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: 0, y1: q, x2: Q, y2: q, className: "nice-chart__axis" }),
303
+ M?.map((T, re) => {
304
+ if (T.type === "line") {
305
+ const ce = O(T.value);
306
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
307
+ /* @__PURE__ */ jsxRuntime.jsx(
308
+ "line",
309
+ {
310
+ x1: 0,
311
+ y1: ce,
312
+ x2: Q,
313
+ y2: ce,
314
+ stroke: T.color || "var(--color-error, #ef4444)",
315
+ strokeWidth: 1.5,
316
+ strokeDasharray: T.dash || "6,3"
317
+ }
318
+ ),
319
+ T.label && /* @__PURE__ */ jsxRuntime.jsx(
320
+ "text",
321
+ {
322
+ x: Q + 4,
323
+ y: ce + 4,
324
+ className: "nice-chart__annotation-label",
325
+ fill: T.color || "var(--color-error, #ef4444)",
326
+ children: T.label
327
+ }
328
+ )
329
+ ] }, re);
330
+ }
331
+ return /* @__PURE__ */ jsxRuntime.jsx(
332
+ "text",
333
+ {
334
+ x: te(T.value),
335
+ y: -4,
336
+ textAnchor: "middle",
337
+ className: "nice-chart__annotation-label",
338
+ fill: T.color || "var(--text-muted, #6b7280)",
339
+ children: T.label
340
+ },
341
+ re
342
+ );
343
+ }),
344
+ C && h && h.x >= 0 && h.x <= Q && h.y >= 0 && h.y <= q && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
345
+ /* @__PURE__ */ jsxRuntime.jsx(
346
+ "line",
347
+ {
348
+ x1: h.x,
349
+ y1: 0,
350
+ x2: h.x,
351
+ y2: q,
352
+ stroke: "#9ca3af",
353
+ strokeWidth: 1,
354
+ strokeDasharray: "4,2"
355
+ }
356
+ ),
357
+ /* @__PURE__ */ jsxRuntime.jsx(
358
+ "line",
359
+ {
360
+ x1: 0,
361
+ y1: h.y,
362
+ x2: Q,
363
+ y2: h.y,
364
+ stroke: "#9ca3af",
365
+ strokeWidth: 1,
366
+ strokeDasharray: "4,2"
367
+ }
368
+ )
369
+ ] }),
370
+ W.map((T, re) => {
371
+ const ce = T.color || ke[re % ke.length], se = T.type || "bar";
372
+ if (se === "bar")
373
+ return /* @__PURE__ */ jsxRuntime.jsx(
374
+ "g",
375
+ {
376
+ className: k ? "nice-chart__series nice-chart__series--bar nice-chart__series--anim" : "nice-chart__series nice-chart__series--bar",
377
+ children: T.data.map((r, R) => {
378
+ let E, N;
379
+ if (p) {
380
+ const ie = W.slice(0, re).reduce((le, he) => le + (he.data[R] || 0), 0);
381
+ E = O(ie + r), N = O(ie) - E;
382
+ } else
383
+ E = O(Math.max(0, r)), N = Math.abs(O(r) - O(0));
384
+ const K = p ? te(R) - pe / 2 : te(R) - W.length * pe / 2 + re * pe;
385
+ return /* @__PURE__ */ jsxRuntime.jsx(
386
+ "rect",
387
+ {
388
+ x: K,
389
+ y: E,
390
+ width: pe * 0.9,
391
+ height: Math.max(0, N),
392
+ fill: ce,
393
+ rx: 2,
394
+ style: {
395
+ transformOrigin: `${K + pe * 0.9 / 2}px ${O(0)}px`,
396
+ ...d ? { cursor: "pointer" } : {}
397
+ },
398
+ onClick: d ? () => d(T.name, n + R, r) : void 0,
399
+ children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${T.name}: ${r}` })
400
+ },
401
+ R
402
+ );
403
+ })
404
+ },
405
+ T.name
406
+ );
407
+ if (se === "scatter")
408
+ return /* @__PURE__ */ jsxRuntime.jsx(
409
+ "g",
410
+ {
411
+ className: k ? "nice-chart__series nice-chart__series--scatter nice-chart__series--anim" : "nice-chart__series nice-chart__series--scatter",
412
+ children: T.data.map((r, R) => /* @__PURE__ */ jsxRuntime.jsx(
413
+ "circle",
414
+ {
415
+ cx: te(R),
416
+ cy: O(r),
417
+ r: 5,
418
+ fill: ce,
419
+ fillOpacity: 0.7,
420
+ stroke: ce,
421
+ strokeWidth: 1.5,
422
+ style: d ? { cursor: "pointer" } : void 0,
423
+ onClick: d ? () => d(T.name, n + R, r) : void 0,
424
+ children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${T.name}: ${r}` })
425
+ },
426
+ R
427
+ ))
428
+ },
429
+ T.name
430
+ );
431
+ const de = T.data.map((r, R) => `${te(R)},${O(r)}`);
432
+ return /* @__PURE__ */ jsxRuntime.jsxs(
433
+ "g",
434
+ {
435
+ className: k ? `nice-chart__series nice-chart__series--${se} nice-chart__series--anim` : `nice-chart__series nice-chart__series--${se}`,
436
+ children: [
437
+ se === "area" && /* @__PURE__ */ jsxRuntime.jsx(
438
+ "polygon",
439
+ {
440
+ points: `${te(0)},${O(0)} ${de.join(" ")} ${te(F - 1)},${O(0)}`,
441
+ fill: ce,
442
+ opacity: 0.15
443
+ }
444
+ ),
445
+ /* @__PURE__ */ jsxRuntime.jsx(
446
+ "polyline",
447
+ {
448
+ points: de.join(" "),
449
+ fill: "none",
450
+ stroke: ce,
451
+ strokeWidth: 2,
452
+ className: k ? "nice-chart__line" : void 0
453
+ }
454
+ ),
455
+ T.data.map((r, R) => /* @__PURE__ */ jsxRuntime.jsx(
456
+ "circle",
457
+ {
458
+ cx: te(R),
459
+ cy: O(r),
460
+ r: 3,
461
+ fill: ce,
462
+ style: d ? { cursor: "pointer" } : void 0,
463
+ onClick: d ? () => d(T.name, n + R, r) : void 0,
464
+ children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${T.name}: ${r}` })
465
+ },
466
+ R
467
+ ))
468
+ ]
469
+ },
470
+ T.name
471
+ );
472
+ })
473
+ ] }),
474
+ v && /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(${G.left}, ${l})`, children: t.map((T, re) => {
475
+ const ce = re * 120, se = b.has(T.name);
476
+ return /* @__PURE__ */ jsxRuntime.jsxs(
477
+ "g",
478
+ {
479
+ transform: `translate(${ce}, 10)`,
480
+ style: i ? { cursor: "pointer" } : void 0,
481
+ onClick: () => V(T.name),
482
+ opacity: se ? 0.35 : 1,
483
+ children: [
484
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: 12, height: 12, rx: 2, fill: T.color || ke[re % ke.length] }),
485
+ /* @__PURE__ */ jsxRuntime.jsx(
486
+ "text",
487
+ {
488
+ x: 16,
489
+ y: 10,
490
+ className: "nice-chart__legend-text",
491
+ style: se ? { textDecoration: "line-through" } : void 0,
492
+ children: T.name
493
+ }
494
+ )
495
+ ]
496
+ },
497
+ T.name
498
+ );
499
+ }) })
500
+ ]
501
+ }
502
+ )
503
+ ] });
504
+ }, ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
505
+ __proto__: null,
506
+ NiceChart: Re
507
+ }, Symbol.toStringTag, { value: "Module" }));
508
+ function Ue(t) {
509
+ if (!t.length)
510
+ return { categories: [], numericFields: [], sampleValues: {} };
511
+ const o = t[0], s = [], l = {};
512
+ let c = null;
513
+ for (const [m, A] of Object.entries(o))
514
+ typeof A == "number" ? (s.push(m), l[m] = t.map((D) => Number(D[m]) || 0)) : !c && (typeof A == "string" || A instanceof Date) && (c = m);
515
+ return { categories: c ? t.map((m) => String(m[c] || "")) : t.map((m, A) => `Item ${A + 1}`), numericFields: s, sampleValues: l };
516
+ }
517
+ function Ge(t, o) {
518
+ const { categories: s, numericFields: l, sampleValues: c } = Ue(t);
519
+ return { series: l.map((m, A) => ({
520
+ name: m.replace(/([A-Z])/g, " $1").replace(/^./, (D) => D.toUpperCase()).trim(),
521
+ data: c[m],
522
+ type: o === "area" ? "area" : o === "line" ? "line" : "bar"
523
+ })), categories: s };
524
+ }
525
+ _e.forwardRef(
526
+ function(o, s) {
527
+ const {
528
+ rawData: l,
529
+ enableAI: c = true,
530
+ aiModel: v,
531
+ enableAutoType: m = true,
532
+ enableInsights: A = true,
533
+ dataDescription: D,
534
+ onChartSuggestion: w,
535
+ onInsights: p,
536
+ showAIToolbar: k = true,
537
+ showInsightsOnLoad: z = false,
538
+ series: C,
539
+ categories: M,
540
+ ...i
541
+ } = o, [d, u] = _e.useState("bar"), [S, g] = _e.useState(null), [x, b] = _e.useState([]), [y, h] = _e.useState(z), [B, a] = _e.useState(null), { t: _ } = coreDa43qPO.W(), I = coreDa43qPO.u(), {
542
+ suggestChartType: P,
543
+ generateInsights: Z,
544
+ isLoading: U
545
+ } = coreDa43qPO.a(), V = c && I.isConfigured, { series: G, categories: Q } = l ? Ge(l, B || d) : { series: C || [], categories: M }, q = _e.useCallback(async () => {
546
+ if (!V || !m)
547
+ return { type: "bar", reason: "Default", config: {} };
548
+ const W = l || (C?.length ? C.flatMap((f) => f.data.map((Y, j) => ({ [f.name]: Y, index: j }))) : []);
549
+ try {
550
+ const f = await P(W, D), Y = {
551
+ type: f.type,
552
+ reason: f.reason,
553
+ config: f.config
554
+ };
555
+ return g(Y), u(Y.type), w?.(Y), Y;
556
+ } catch {
557
+ return { type: "bar", reason: "Default fallback", config: {} };
558
+ }
559
+ }, [
560
+ V,
561
+ m,
562
+ l,
563
+ C,
564
+ D,
565
+ P,
566
+ w
567
+ ]), J = _e.useCallback(async () => {
568
+ if (!V || !A)
569
+ return [];
570
+ const W = l || (C?.length ? C.flatMap(
571
+ (f) => f.data.map((Y, j) => ({ [f.name]: Y, category: M?.[j] || j }))
572
+ ) : []);
573
+ try {
574
+ const f = await Z(W, B || d);
575
+ return b(f), p?.(f), f;
576
+ } catch {
577
+ return [];
578
+ }
579
+ }, [
580
+ V,
581
+ A,
582
+ l,
583
+ C,
584
+ M,
585
+ d,
586
+ B,
587
+ Z,
588
+ p
589
+ ]), n = _e.useCallback(
590
+ () => B || d,
591
+ [B, d]
592
+ );
593
+ _e.useEffect(() => {
594
+ V && m && (l?.length || C?.length) && q();
595
+ }, [V, m, l, C]), _e.useImperativeHandle(s, () => ({
596
+ getSuggestion: q,
597
+ generateInsights: J,
598
+ getCurrentType: n
599
+ }));
600
+ const H = [
601
+ { type: "bar", icon: "📊", label: "Bar" },
602
+ { type: "line", icon: "📈", label: "Line" },
603
+ { type: "area", icon: "🏔️", label: "Area" },
604
+ { type: "pie", icon: "🥧", label: "Pie" },
605
+ { type: "donut", icon: "🍩", label: "Donut" },
606
+ { type: "scatter", icon: "⭐", label: "Scatter" }
607
+ ], F = B || d;
608
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai", "data-testid": o["data-testid"], children: [
609
+ k && V && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__toolbar", children: [
610
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__toolbar-left", children: [
611
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-chart-ai__badge", children: "AI" }),
612
+ S && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__suggestion", children: [
613
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-chart-ai__suggestion-icon", children: "💡" }),
614
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "nice-chart-ai__suggestion-text", children: [
615
+ _("chartAI.suggestedType", "Suggested:"),
616
+ " ",
617
+ S.type
618
+ ] }),
619
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "nice-chart-ai__suggestion-reason", title: S.reason, children: [
620
+ "(",
621
+ S.reason,
622
+ ")"
623
+ ] })
624
+ ] }),
625
+ U && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-chart-ai__loading", children: _("chartAI.analyzing", "Analyzing...") })
626
+ ] }),
627
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-chart-ai__toolbar-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-chart-ai__type-selector", children: H.filter((W) => ["bar", "line", "area"].includes(W.type)).map(({ type: W, icon: f, label: Y }) => /* @__PURE__ */ jsxRuntime.jsx(
628
+ "button",
629
+ {
630
+ type: "button",
631
+ className: `nice-chart-ai__type-btn ${F === W ? "nice-chart-ai__type-btn--active" : ""}`,
632
+ onClick: () => a(W),
633
+ title: Y,
634
+ children: f
635
+ },
636
+ W
637
+ )) }) }),
638
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__toolbar-right", children: [
639
+ /* @__PURE__ */ jsxRuntime.jsxs(
640
+ "button",
641
+ {
642
+ type: "button",
643
+ className: "nice-chart-ai__auto-btn",
644
+ onClick: () => q(),
645
+ disabled: U,
646
+ title: _("chartAI.autoDetect", "Auto-detect best chart type"),
647
+ children: [
648
+ "🔮 ",
649
+ _("chartAI.auto", "Auto")
650
+ ]
651
+ }
652
+ ),
653
+ A && /* @__PURE__ */ jsxRuntime.jsxs(
654
+ "button",
655
+ {
656
+ type: "button",
657
+ className: "nice-chart-ai__insights-btn",
658
+ onClick: () => {
659
+ x.length || J(), h(!y);
660
+ },
661
+ disabled: U,
662
+ title: _("chartAI.showInsights", "Show data insights"),
663
+ children: [
664
+ "💡 ",
665
+ _("chartAI.insights", "Insights")
666
+ ]
667
+ }
668
+ )
669
+ ] })
670
+ ] }),
671
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-chart-ai__chart-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(Re, { series: G, categories: Q, ...i }) }),
672
+ y && x.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__insights", children: [
673
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__insights-header", children: [
674
+ /* @__PURE__ */ jsxRuntime.jsxs("h4", { children: [
675
+ "💡 ",
676
+ _("chartAI.dataInsights", "Data Insights")
677
+ ] }),
678
+ /* @__PURE__ */ jsxRuntime.jsx(
679
+ "button",
680
+ {
681
+ type: "button",
682
+ className: "nice-chart-ai__insights-close",
683
+ onClick: () => h(false),
684
+ children: "✕"
685
+ }
686
+ )
687
+ ] }),
688
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "nice-chart-ai__insights-list", children: x.map((W, f) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "nice-chart-ai__insight", children: [
689
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-chart-ai__insight-icon", children: "•" }),
690
+ W
691
+ ] }, f)) }),
692
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-chart-ai__insights-footer", children: /* @__PURE__ */ jsxRuntime.jsxs(
693
+ "button",
694
+ {
695
+ type: "button",
696
+ className: "nice-chart-ai__refresh",
697
+ onClick: () => J(),
698
+ disabled: U,
699
+ children: [
700
+ "🔄 ",
701
+ _("chartAI.refresh", "Refresh")
702
+ ]
703
+ }
704
+ ) })
705
+ ] }),
706
+ y && U && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-chart-ai__insights nice-chart-ai__insights--loading", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__loading-content", children: [
707
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-chart-ai__spinner" }),
708
+ _("chartAI.generatingInsights", "Generating insights...")
709
+ ] }) })
710
+ ] });
711
+ }
712
+ );
713
+ function qe(t, o) {
714
+ const s = t ? typeof t == "number" ? new Date(t) : new Date(t) : /* @__PURE__ */ new Date(), l = (D) => D.toString().padStart(2, "0"), c = l(s.getHours()), v = l(s.getMinutes()), m = l(s.getSeconds()), A = s.getMilliseconds().toString().padStart(3, "0");
715
+ switch (o) {
716
+ case "HH:mm:ss":
717
+ return `${c}:${v}:${m}`;
718
+ case "HH:mm":
719
+ return `${c}:${v}`;
720
+ case "mm:ss":
721
+ return `${v}:${m}`;
722
+ case "ss.SSS":
723
+ return `${m}.${A}`;
724
+ case "ISO":
725
+ return s.toISOString();
726
+ default:
727
+ return `${c}:${v}:${m}`;
728
+ }
729
+ }
730
+ function We(t) {
731
+ if (t.length === 0)
732
+ return null;
733
+ const o = Math.min(...t), s = Math.max(...t), l = t.reduce((v, m) => v + m, 0) / t.length, c = t[t.length - 1];
734
+ return { min: o, max: s, avg: l, current: c, count: t.length };
735
+ }
736
+ const Je = _e.forwardRef(
737
+ ({
738
+ series: t,
739
+ maxPoints: o = 100,
740
+ slidingWindow: s = true,
741
+ refreshRate: l = 16,
742
+ dataSource: c,
743
+ width: v = 600,
744
+ height: m = 400,
745
+ title: A,
746
+ showLegend: D = true,
747
+ showGrid: w = true,
748
+ yAxisLabel: p,
749
+ xAxisLabel: k,
750
+ stacked: z,
751
+ zoomable: C,
752
+ crosshair: M,
753
+ annotations: i = [],
754
+ legendInteractive: d,
755
+ onDataPointClick: u,
756
+ exportable: S,
757
+ showControls: g = true,
758
+ showStatus: x = true,
759
+ initialPaused: b = false,
760
+ onDataReceived: y,
761
+ onDataDropped: h,
762
+ timeFormat: B = "HH:mm:ss",
763
+ showStats: a,
764
+ thresholds: _ = [],
765
+ className: I,
766
+ style: P
767
+ }, Z) => {
768
+ const [U, V] = _e.useState(() => {
769
+ const L = /* @__PURE__ */ new Map();
770
+ for (const X of t)
771
+ L.set(X.name, X.initialData?.slice() ?? []);
772
+ return L;
773
+ }), [G, Q] = _e.useState([]), [q, J] = _e.useState(b), [n, H] = _e.useState(false), F = _e.useRef([]), W = _e.useRef(Date.now()), f = _e.useRef(null), Y = _e.useCallback(() => {
774
+ const L = F.current;
775
+ L.length !== 0 && (F.current = [], V((X) => {
776
+ const ne = new Map(X);
777
+ for (const ue of L) {
778
+ const _e = ne.get(ue.series);
779
+ if (!_e)
780
+ continue;
781
+ const ge = [..._e, ue.value];
782
+ if (s && ge.length > o) {
783
+ const ye = ge.length - o;
784
+ h?.(ye, ue.series), ge.splice(0, ye);
785
+ }
786
+ ne.set(ue.series, ge);
787
+ }
788
+ return ne;
789
+ }), L.length > 0 && Q((X) => {
790
+ const ne = [...X];
791
+ for (const ue of L) {
792
+ const _e = ue.category ?? qe(ue.timestamp, B);
793
+ ne.push(_e);
794
+ }
795
+ return s && ne.length > o && ne.splice(0, ne.length - o), ne;
796
+ }));
797
+ }, [s, o, B, h]), j = _e.useCallback(() => {
798
+ const L = Date.now();
799
+ L - W.current >= l && (Y(), W.current = L), f.current = requestAnimationFrame(j);
800
+ }, [l, Y]);
801
+ _e.useEffect(() => (q || (f.current = requestAnimationFrame(j)), () => {
802
+ f.current !== null && (cancelAnimationFrame(f.current), f.current = null);
803
+ }), [q, j]);
804
+ const ee = _e.useCallback(
805
+ (L) => {
806
+ if (q)
807
+ return;
808
+ const X = "points" in L ? L.points : [L];
809
+ for (const ne of X)
810
+ U.has(ne.series) && (F.current.push(ne), y?.(ne));
811
+ },
812
+ [q, U, y]
813
+ );
814
+ _e.useEffect(() => {
815
+ if (!c)
816
+ return;
817
+ const L = c.subscribe(ee);
818
+ let X;
819
+ return c.onStatusChange ? X = c.onStatusChange(H) : H(true), c.fetchHistory && c.fetchHistory(o).then((ne) => {
820
+ for (const ue of ne)
821
+ F.current.push(ue);
822
+ Y();
823
+ }), () => {
824
+ L(), X?.();
825
+ };
826
+ }, [c, ee, o, Y]);
827
+ const O = _e.useMemo(() => t.map((L) => ({
828
+ name: L.name,
829
+ color: L.color,
830
+ type: L.type,
831
+ data: U.get(L.name) ?? []
832
+ })), [t, U]), te = _e.useMemo(() => {
833
+ const L = [...i];
834
+ for (const X of _)
835
+ L.push({
836
+ type: "line",
837
+ value: X.value,
838
+ color: X.color,
839
+ label: X.label,
840
+ dash: X.style === "dashed" ? "5,5" : X.style === "dotted" ? "2,2" : void 0
841
+ });
842
+ return L;
843
+ }, [i, _]);
844
+ _e.useImperativeHandle(
845
+ Z,
846
+ () => ({
847
+ pause() {
848
+ J(true);
849
+ },
850
+ resume() {
851
+ J(false);
852
+ },
853
+ isPaused() {
854
+ return q;
855
+ },
856
+ clear() {
857
+ V((L) => {
858
+ const X = new Map(L);
859
+ for (const ne of X.keys())
860
+ X.set(ne, []);
861
+ return X;
862
+ }), Q([]), F.current = [];
863
+ },
864
+ addPoint(L) {
865
+ ee(L);
866
+ },
867
+ addPoints(L) {
868
+ ee({ points: L });
869
+ },
870
+ getData(L) {
871
+ return U.get(L) ?? [];
872
+ },
873
+ getCategories() {
874
+ return G;
875
+ },
876
+ exportData() {
877
+ return { series: O, categories: G };
878
+ },
879
+ getStats(L) {
880
+ const X = U.get(L);
881
+ return X ? We(X) : null;
882
+ }
883
+ }),
884
+ [q, U, G, O, ee]
885
+ );
886
+ const pe = _e.useMemo(() => {
887
+ if (!a)
888
+ return null;
889
+ const L = {};
890
+ for (const [X, ne] of U)
891
+ L[X] = We(ne);
892
+ return L;
893
+ }, [a, U]);
894
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: I, style: { position: "relative", ...P }, children: [
895
+ x && /* @__PURE__ */ jsxRuntime.jsxs(
896
+ "div",
897
+ {
898
+ style: {
899
+ position: "absolute",
900
+ top: 8,
901
+ right: 8,
902
+ display: "flex",
903
+ alignItems: "center",
904
+ gap: 4,
905
+ fontSize: 12,
906
+ color: n ? "var(--color-success, #22c55e)" : "var(--color-error, #ef4444)",
907
+ zIndex: 10
908
+ },
909
+ children: [
910
+ /* @__PURE__ */ jsxRuntime.jsx(
911
+ "span",
912
+ {
913
+ style: {
914
+ width: 8,
915
+ height: 8,
916
+ borderRadius: "50%",
917
+ backgroundColor: n ? "var(--color-success, #22c55e)" : "var(--color-error, #ef4444)"
918
+ }
919
+ }
920
+ ),
921
+ n ? "Live" : "Disconnected"
922
+ ]
923
+ }
924
+ ),
925
+ g && /* @__PURE__ */ jsxRuntime.jsx(
926
+ "div",
927
+ {
928
+ style: {
929
+ position: "absolute",
930
+ top: 8,
931
+ left: 8,
932
+ display: "flex",
933
+ gap: 4,
934
+ zIndex: 10
935
+ },
936
+ children: /* @__PURE__ */ jsxRuntime.jsx(
937
+ "button",
938
+ {
939
+ onClick: () => J((L) => !L),
940
+ style: {
941
+ padding: "4px 8px",
942
+ fontSize: 12,
943
+ border: "1px solid var(--border-color, #ddd)",
944
+ borderRadius: 4,
945
+ background: q ? "var(--warning-bg, #fef3c7)" : "var(--bg-primary, #fff)",
946
+ cursor: "pointer"
947
+ },
948
+ title: q ? "Resume" : "Pause",
949
+ children: q ? "▶" : "⏸"
950
+ }
951
+ )
952
+ }
953
+ ),
954
+ a && pe && /* @__PURE__ */ jsxRuntime.jsx(
955
+ "div",
956
+ {
957
+ style: {
958
+ position: "absolute",
959
+ bottom: 50,
960
+ right: 8,
961
+ background: "rgba(255,255,255,0.9)",
962
+ border: "1px solid var(--border-color, #ddd)",
963
+ borderRadius: 4,
964
+ padding: 8,
965
+ fontSize: 11,
966
+ zIndex: 10
967
+ },
968
+ children: Object.entries(pe).map(
969
+ ([L, X]) => X ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: 4 }, children: [
970
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: L }),
971
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
972
+ "Min: ",
973
+ X.min.toFixed(2),
974
+ " | Max: ",
975
+ X.max.toFixed(2)
976
+ ] }),
977
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
978
+ "Avg: ",
979
+ X.avg.toFixed(2),
980
+ " | Now: ",
981
+ X.current.toFixed(2)
982
+ ] })
983
+ ] }, L) : null
984
+ )
985
+ }
986
+ ),
987
+ /* @__PURE__ */ jsxRuntime.jsx(
988
+ Re,
989
+ {
990
+ series: O,
991
+ categories: G,
992
+ width: v,
993
+ height: m,
994
+ title: A,
995
+ showLegend: D,
996
+ showGrid: w,
997
+ yAxisLabel: p,
998
+ xAxisLabel: k,
999
+ stacked: z,
1000
+ zoomable: C,
1001
+ crosshair: M,
1002
+ annotations: te,
1003
+ legendInteractive: d,
1004
+ onDataPointClick: u,
1005
+ exportable: S
1006
+ }
1007
+ )
1008
+ ] });
1009
+ }
1010
+ );
1011
+ Je.displayName = "NiceLiveChart";
1012
+ const ve = ["#3b82f6", "#ef4444", "#22c55e", "#f59e0b", "#8b5cf6", "#ec4899", "#06b6d4", "#84cc16"], yt = ({
1013
+ data: t,
1014
+ width: o = 400,
1015
+ height: s = 400,
1016
+ innerRadius: l = 0,
1017
+ title: c,
1018
+ showLegend: v = true,
1019
+ showLabels: m = true,
1020
+ className: A,
1021
+ style: D
1022
+ }) => {
1023
+ const w = o / 2, p = (s - (v ? 30 : 0)) / 2 + (c ? 10 : 0), k = Math.min(w, p) - 40, z = t.reduce((i, d) => i + d.value, 0);
1024
+ let C = -Math.PI / 2;
1025
+ const M = t.map((i, d) => {
1026
+ const u = i.value / (z || 1) * Math.PI * 2, S = C;
1027
+ C += u;
1028
+ const g = C, x = (S + g) / 2, b = w + k * Math.cos(S), y = p + k * Math.sin(S), h = w + k * Math.cos(g), B = p + k * Math.sin(g), a = u > Math.PI ? 1 : 0, _ = i.color || ve[d % ve.length];
1029
+ let I;
1030
+ if (l > 0) {
1031
+ const V = w + l * Math.cos(S), G = p + l * Math.sin(S), Q = w + l * Math.cos(g), q = p + l * Math.sin(g);
1032
+ I = `M${b},${y} A${k},${k} 0 ${a},1 ${h},${B} L${Q},${q} A${l},${l} 0 ${a},0 ${V},${G} Z`;
1033
+ } else
1034
+ I = `M${w},${p} L${b},${y} A${k},${k} 0 ${a},1 ${h},${B} Z`;
1035
+ const P = w + k * 0.7 * Math.cos(x), Z = p + k * 0.7 * Math.sin(x), U = z > 0 ? Math.round(i.value / z * 100) : 0;
1036
+ return { ...i, path: I, labelX: P, labelY: Z, pct: U, color: _ };
1037
+ });
1038
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-piechart ${A || ""}`, style: D, children: /* @__PURE__ */ jsxRuntime.jsxs(
1039
+ "svg",
1040
+ {
1041
+ viewBox: `0 0 ${o} ${s}`,
1042
+ preserveAspectRatio: "xMidYMid meet",
1043
+ width: "100%",
1044
+ height: "100%",
1045
+ style: { display: "block", maxWidth: "100%", maxHeight: "100%" },
1046
+ className: "nice-piechart__svg",
1047
+ children: [
1048
+ c && /* @__PURE__ */ jsxRuntime.jsx("text", { x: w, y: 20, textAnchor: "middle", className: "nice-chart__title", children: c }),
1049
+ M.map((i, d) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
1050
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: i.path, fill: i.color, stroke: "var(--bg-primary, #fff)", strokeWidth: 2, children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${i.label}: ${i.value} (${i.pct}%)` }) }),
1051
+ m && i.pct >= 5 && /* @__PURE__ */ jsxRuntime.jsxs(
1052
+ "text",
1053
+ {
1054
+ x: i.labelX,
1055
+ y: i.labelY,
1056
+ textAnchor: "middle",
1057
+ dominantBaseline: "middle",
1058
+ className: "nice-piechart__label",
1059
+ children: [
1060
+ i.pct,
1061
+ "%"
1062
+ ]
1063
+ }
1064
+ )
1065
+ ] }, d)),
1066
+ v && /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(10, ${s - 25})`, children: t.map((i, d) => /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${d * 100}, 0)`, children: [
1067
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: 10, height: 10, rx: 2, fill: i.color || ve[d % ve.length] }),
1068
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: i.label })
1069
+ ] }, d)) })
1070
+ ]
1071
+ }
1072
+ ) });
1073
+ }, vt = ({
1074
+ series: t,
1075
+ categories: o,
1076
+ width: s = 400,
1077
+ height: l = 400,
1078
+ maxValue: c,
1079
+ title: v,
1080
+ showLegend: m = true,
1081
+ className: A,
1082
+ style: D
1083
+ }) => {
1084
+ const w = s / 2, p = (l - (m ? 30 : 0)) / 2 + (v ? 10 : 0), k = Math.min(w, p) - 60, z = o.length, C = c ?? Math.max(...t.flatMap((u) => u.data), 1), M = Math.PI * 2 / z, i = 5, d = (u, S) => {
1085
+ const g = u * M - Math.PI / 2, x = S / C * k;
1086
+ return { x: w + x * Math.cos(g), y: p + x * Math.sin(g) };
1087
+ };
1088
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-polarchart ${A || ""}`, style: D, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: s, height: l, className: "nice-polarchart__svg", children: [
1089
+ v && /* @__PURE__ */ jsxRuntime.jsx("text", { x: w, y: 20, textAnchor: "middle", className: "nice-chart__title", children: v }),
1090
+ Array.from({ length: i }, (u, S) => {
1091
+ const g = k * ((S + 1) / i);
1092
+ return /* @__PURE__ */ jsxRuntime.jsx(
1093
+ "circle",
1094
+ {
1095
+ cx: w,
1096
+ cy: p,
1097
+ r: g,
1098
+ fill: "none",
1099
+ stroke: "var(--border-color, #ddd)",
1100
+ strokeWidth: 0.5
1101
+ },
1102
+ S
1103
+ );
1104
+ }),
1105
+ o.map((u, S) => {
1106
+ const g = d(S, C), x = d(S, C * 1.22), b = S * M - Math.PI / 2, y = Math.cos(b), h = Math.sin(b), B = y > 0.2 ? "start" : y < -0.2 ? "end" : "middle", a = h > 0.2 ? "hanging" : h < -0.2 ? "auto" : "middle";
1107
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
1108
+ /* @__PURE__ */ jsxRuntime.jsx(
1109
+ "line",
1110
+ {
1111
+ x1: w,
1112
+ y1: p,
1113
+ x2: g.x,
1114
+ y2: g.y,
1115
+ stroke: "var(--border-color, #ddd)",
1116
+ strokeWidth: 0.5
1117
+ }
1118
+ ),
1119
+ /* @__PURE__ */ jsxRuntime.jsx(
1120
+ "text",
1121
+ {
1122
+ x: x.x,
1123
+ y: x.y,
1124
+ textAnchor: B,
1125
+ dominantBaseline: a,
1126
+ className: "nice-chart__axis-label nice-chart__axis-label--polar",
1127
+ children: u
1128
+ }
1129
+ )
1130
+ ] }, S);
1131
+ }),
1132
+ t.map((u, S) => {
1133
+ const g = u.color || ve[S % ve.length], x = u.data.map((b, y) => {
1134
+ const h = d(y, b);
1135
+ return `${h.x},${h.y}`;
1136
+ }).join(" ");
1137
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
1138
+ /* @__PURE__ */ jsxRuntime.jsx(
1139
+ "polygon",
1140
+ {
1141
+ points: x,
1142
+ fill: u.fill !== false ? g : "none",
1143
+ fillOpacity: 0.15,
1144
+ stroke: g,
1145
+ strokeWidth: 2
1146
+ }
1147
+ ),
1148
+ u.data.map((b, y) => {
1149
+ const h = d(y, b);
1150
+ return /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: h.x, cy: h.y, r: 3, fill: g, children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${u.name} - ${o[y]}: ${b}` }) }, y);
1151
+ })
1152
+ ] }, u.name);
1153
+ }),
1154
+ m && /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(10, ${l - 25})`, children: t.map((u, S) => /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${S * 100}, 0)`, children: [
1155
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: 10, height: 10, rx: 2, fill: u.color || ve[S % ve.length] }),
1156
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: u.name })
1157
+ ] }, S)) })
1158
+ ] }) });
1159
+ }, bt = ({
1160
+ value: t,
1161
+ min: o = 0,
1162
+ max: s = 100,
1163
+ width: l = 200,
1164
+ height: c = 200,
1165
+ startAngle: v = 225,
1166
+ endAngle: m = -45,
1167
+ color: A = "var(--color-primary, #3b82f6)",
1168
+ trackColor: D,
1169
+ label: w,
1170
+ formatValue: p,
1171
+ ranges: k,
1172
+ className: z,
1173
+ style: C
1174
+ }) => {
1175
+ const M = l / 2, i = c / 2, d = Math.min(M, i) - 20, u = Math.max(0, Math.min(1, (t - o) / (s - o || 1))), S = (a) => a * Math.PI / 180, g = (v - m + 360) % 360 || 360, x = (a) => ({
1176
+ x: M + d * Math.cos(S(a)),
1177
+ y: i - d * Math.sin(S(a))
1178
+ }), b = (a, _) => {
1179
+ const I = x(a), P = x(_), U = (a - _ + 360) % 360 > 180 ? 1 : 0;
1180
+ return `M${I.x},${I.y} A${d},${d} 0 ${U},1 ${P.x},${P.y}`;
1181
+ }, y = v - u * g, h = x(y);
1182
+ let B = A;
1183
+ if (k) {
1184
+ for (const a of k)
1185
+ if (t >= a.start && t <= a.end) {
1186
+ B = a.color;
1187
+ break;
1188
+ }
1189
+ }
1190
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-gauge nice-gauge--circular ${z || ""}`, style: C, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: l, height: c, children: [
1191
+ /* @__PURE__ */ jsxRuntime.jsx(
1192
+ "path",
1193
+ {
1194
+ d: b(v, m),
1195
+ fill: "none",
1196
+ stroke: D || "var(--border-color, #e2e8f0)",
1197
+ strokeWidth: 12,
1198
+ strokeLinecap: "round"
1199
+ }
1200
+ ),
1201
+ u > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1202
+ "path",
1203
+ {
1204
+ d: b(v, y),
1205
+ fill: "none",
1206
+ stroke: B,
1207
+ strokeWidth: 12,
1208
+ strokeLinecap: "round"
1209
+ }
1210
+ ),
1211
+ /* @__PURE__ */ jsxRuntime.jsx(
1212
+ "line",
1213
+ {
1214
+ x1: M,
1215
+ y1: i,
1216
+ x2: h.x,
1217
+ y2: h.y,
1218
+ stroke: "var(--text-primary, #333)",
1219
+ strokeWidth: 2,
1220
+ strokeLinecap: "round"
1221
+ }
1222
+ ),
1223
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: M, cy: i, r: 4, fill: "var(--text-primary, #333)" }),
1224
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: M, y: i + d * 0.6, textAnchor: "middle", className: "nice-gauge__value", children: p ? p(t) : t }),
1225
+ w && /* @__PURE__ */ jsxRuntime.jsx("text", { x: M, y: i + d * 0.95, textAnchor: "middle", className: "nice-gauge__label", children: w })
1226
+ ] }) });
1227
+ }, _t = ({
1228
+ value: t,
1229
+ min: o = 0,
1230
+ max: s = 100,
1231
+ width: l = 300,
1232
+ height: c = 60,
1233
+ orientation: v = "horizontal",
1234
+ color: m = "var(--color-primary, #3b82f6)",
1235
+ label: A,
1236
+ formatValue: D,
1237
+ ranges: w,
1238
+ showTicks: p = true,
1239
+ tickCount: k = 5,
1240
+ className: z,
1241
+ style: C
1242
+ }) => {
1243
+ const M = v === "horizontal", i = M ? l - 40 : c - 40, d = Math.max(0, Math.min(1, (t - o) / (s - o || 1))), u = 10;
1244
+ let S = m;
1245
+ if (w) {
1246
+ for (const x of w)
1247
+ if (t >= x.start && t <= x.end) {
1248
+ S = x.color;
1249
+ break;
1250
+ }
1251
+ }
1252
+ const g = Array.from(
1253
+ { length: k },
1254
+ (x, b) => o + (s - o) * (b / (k - 1))
1255
+ );
1256
+ return M ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-gauge nice-gauge--linear ${z || ""}`, style: C, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: l, height: c, children: [
1257
+ /* @__PURE__ */ jsxRuntime.jsx(
1258
+ "text",
1259
+ {
1260
+ x: 20 + i * d,
1261
+ y: 14,
1262
+ textAnchor: "middle",
1263
+ className: "nice-gauge__value",
1264
+ style: { fontSize: 12 },
1265
+ children: D ? D(t) : t
1266
+ }
1267
+ ),
1268
+ /* @__PURE__ */ jsxRuntime.jsx(
1269
+ "rect",
1270
+ {
1271
+ x: 20,
1272
+ y: c / 2 - u / 2,
1273
+ width: i,
1274
+ height: u,
1275
+ rx: 5,
1276
+ fill: "var(--border-color, #e2e8f0)"
1277
+ }
1278
+ ),
1279
+ /* @__PURE__ */ jsxRuntime.jsx(
1280
+ "rect",
1281
+ {
1282
+ x: 20,
1283
+ y: c / 2 - u / 2,
1284
+ width: i * d,
1285
+ height: u,
1286
+ rx: 5,
1287
+ fill: S
1288
+ }
1289
+ ),
1290
+ /* @__PURE__ */ jsxRuntime.jsx(
1291
+ "polygon",
1292
+ {
1293
+ points: `${20 + i * d},${c / 2 - u / 2 - 2} ${20 + i * d - 5},${c / 2 - u / 2 - 8} ${20 + i * d + 5},${c / 2 - u / 2 - 8}`,
1294
+ fill: "var(--text-primary, #333)"
1295
+ }
1296
+ ),
1297
+ p && g.map((x, b) => {
1298
+ const y = 20 + (x - o) / (s - o) * i;
1299
+ return /* @__PURE__ */ jsxRuntime.jsx(
1300
+ "text",
1301
+ {
1302
+ x: y,
1303
+ y: c / 2 + u / 2 + 12,
1304
+ textAnchor: "middle",
1305
+ className: "nice-gauge__tick",
1306
+ children: x
1307
+ },
1308
+ b
1309
+ );
1310
+ }),
1311
+ A && /* @__PURE__ */ jsxRuntime.jsx("text", { x: l / 2, y: c - 2, textAnchor: "middle", className: "nice-gauge__label", children: A })
1312
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(
1313
+ "div",
1314
+ {
1315
+ className: `nice-gauge nice-gauge--linear nice-gauge--vertical ${z || ""}`,
1316
+ style: C,
1317
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: l, height: c, children: [
1318
+ /* @__PURE__ */ jsxRuntime.jsx(
1319
+ "rect",
1320
+ {
1321
+ x: l / 2 - u / 2,
1322
+ y: 20,
1323
+ width: u,
1324
+ height: i,
1325
+ rx: 5,
1326
+ fill: "var(--border-color, #e2e8f0)"
1327
+ }
1328
+ ),
1329
+ /* @__PURE__ */ jsxRuntime.jsx(
1330
+ "rect",
1331
+ {
1332
+ x: l / 2 - u / 2,
1333
+ y: 20 + i * (1 - d),
1334
+ width: u,
1335
+ height: i * d,
1336
+ rx: 5,
1337
+ fill: S
1338
+ }
1339
+ ),
1340
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: l / 2, y: 14, textAnchor: "middle", className: "nice-gauge__value", children: D ? D(t) : t }),
1341
+ A && /* @__PURE__ */ jsxRuntime.jsx("text", { x: l / 2, y: c - 4, textAnchor: "middle", className: "nice-gauge__label", children: A })
1342
+ ] })
1343
+ }
1344
+ );
1345
+ }, wt = ({
1346
+ items: t,
1347
+ min: o = 0,
1348
+ max: s = 100,
1349
+ width: l = 300,
1350
+ height: c = 300,
1351
+ startAngle: v = 225,
1352
+ endAngle: m = -45,
1353
+ formatValue: A,
1354
+ title: D,
1355
+ className: w,
1356
+ style: p
1357
+ }) => {
1358
+ const k = l / 2, z = c / 2, C = Math.min(k, z) - 30, M = Math.min(20, C / (t.length + 1)), i = 4, d = (g) => g * Math.PI / 180, u = (v - m + 360) % 360 || 360, S = (g, x, b) => {
1359
+ const y = k + g * Math.cos(d(x)), h = z - g * Math.sin(d(x)), B = k + g * Math.cos(d(b)), a = z - g * Math.sin(d(b)), _ = (x - b + 360) % 360;
1360
+ return `M${y},${h} A${g},${g} 0 ${_ > 180 ? 1 : 0},1 ${B},${a}`;
1361
+ };
1362
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-bargauge ${w || ""}`, style: p, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: l, height: c, children: [
1363
+ D && /* @__PURE__ */ jsxRuntime.jsx("text", { x: k, y: 20, textAnchor: "middle", className: "nice-chart__title", children: D }),
1364
+ t.map((g, x) => {
1365
+ const b = C - x * (M + i), y = Math.max(0, Math.min(1, (g.value - o) / (s - o || 1))), h = v - y * u, B = g.color || ve[x % ve.length];
1366
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
1367
+ /* @__PURE__ */ jsxRuntime.jsx(
1368
+ "path",
1369
+ {
1370
+ d: S(b, v, m),
1371
+ fill: "none",
1372
+ stroke: "var(--border-color, #e2e8f0)",
1373
+ strokeWidth: M,
1374
+ strokeLinecap: "round"
1375
+ }
1376
+ ),
1377
+ y > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1378
+ "path",
1379
+ {
1380
+ d: S(b, v, h),
1381
+ fill: "none",
1382
+ stroke: B,
1383
+ strokeWidth: M,
1384
+ strokeLinecap: "round"
1385
+ }
1386
+ )
1387
+ ] }, x);
1388
+ }),
1389
+ /* @__PURE__ */ jsxRuntime.jsx("g", { children: t.map((g, x) => /* @__PURE__ */ jsxRuntime.jsxs(
1390
+ "text",
1391
+ {
1392
+ x: k,
1393
+ y: z - ((t.length - 1) / 2 - x) * 16,
1394
+ textAnchor: "middle",
1395
+ dominantBaseline: "middle",
1396
+ className: "nice-gauge__value",
1397
+ style: { fontSize: 12 },
1398
+ children: [
1399
+ g.label ? `${g.label}: ` : "",
1400
+ A ? A(g.value) : g.value
1401
+ ]
1402
+ },
1403
+ x
1404
+ )) })
1405
+ ] }) });
1406
+ }, $t = ({
1407
+ data: t,
1408
+ width: o = 120,
1409
+ height: s = 30,
1410
+ type: l = "line",
1411
+ color: c = "var(--color-primary, #3b82f6)",
1412
+ showMinMax: v,
1413
+ showLastPoint: m = true,
1414
+ className: A,
1415
+ style: D
1416
+ }) => {
1417
+ if (t.length === 0)
1418
+ return null;
1419
+ const w = 2, p = Math.min(...t), k = Math.max(...t), z = k - p || 1, C = o - w * 2, M = s - w * 2, i = (b) => w + b / (t.length - 1 || 1) * C, d = (b) => w + M - (b - p) / z * M;
1420
+ if (l === "bar") {
1421
+ const b = Math.max(1, C / t.length - 1);
1422
+ return /* @__PURE__ */ jsxRuntime.jsx(
1423
+ "svg",
1424
+ {
1425
+ width: o,
1426
+ height: s,
1427
+ className: `nice-sparkline ${A || ""}`,
1428
+ style: D,
1429
+ children: t.map((y, h) => /* @__PURE__ */ jsxRuntime.jsx(
1430
+ "rect",
1431
+ {
1432
+ x: w + h / t.length * C,
1433
+ y: d(y),
1434
+ width: b,
1435
+ height: M - (d(y) - w),
1436
+ fill: c,
1437
+ rx: 1
1438
+ },
1439
+ h
1440
+ ))
1441
+ }
1442
+ );
1443
+ }
1444
+ const u = t.map((b, y) => `${i(y)},${d(b)}`).join(" "), S = t.indexOf(p), g = t.indexOf(k), x = t.length - 1;
1445
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1446
+ "svg",
1447
+ {
1448
+ width: o,
1449
+ height: s,
1450
+ className: `nice-sparkline ${A || ""}`,
1451
+ style: D,
1452
+ children: [
1453
+ l === "area" && /* @__PURE__ */ jsxRuntime.jsx(
1454
+ "polygon",
1455
+ {
1456
+ points: `${i(0)},${w + M} ${u} ${i(x)},${w + M}`,
1457
+ fill: c,
1458
+ opacity: 0.15
1459
+ }
1460
+ ),
1461
+ /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: u, fill: "none", stroke: c, strokeWidth: 1.5 }),
1462
+ v && /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: i(S), cy: d(p), r: 2, fill: "#ef4444" }),
1463
+ v && /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: i(g), cy: d(k), r: 2, fill: "#22c55e" }),
1464
+ m && /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: i(x), cy: d(t[x]), r: 2, fill: c })
1465
+ ]
1466
+ }
1467
+ );
1468
+ }, Ke = {
1469
+ sm: { width: 160, height: 22, fontSize: 11 },
1470
+ md: { width: 220, height: 32, fontSize: 12 },
1471
+ lg: { width: 320, height: 44, fontSize: 14 }
1472
+ }, Mt = ({
1473
+ value: t,
1474
+ target: o,
1475
+ min: s = 0,
1476
+ max: l = 100,
1477
+ width: c,
1478
+ height: v,
1479
+ color: m = "var(--color-primary, #3b82f6)",
1480
+ targetColor: A = "var(--color-error, #ef4444)",
1481
+ size: D = "md",
1482
+ label: w,
1483
+ labelPlacement: p = "top",
1484
+ showValue: k = false,
1485
+ showTarget: z = false,
1486
+ formatValue: C = (S) => String(S),
1487
+ state: M = "normal",
1488
+ errorMessage: i,
1489
+ className: d,
1490
+ style: u
1491
+ }) => {
1492
+ const S = Ke[D], g = c ?? S.width, x = v ?? S.height, b = S.fontSize, y = 4, h = g - y * 2, B = x - y * 2, a = Math.max(0, Math.min(1, (t - s) / (l - s || 1))), _ = o != null ? Math.max(0, Math.min(1, (o - s) / (l - s || 1))) : null, I = () => M === "error" ? /* @__PURE__ */ jsxRuntime.jsx(
1493
+ "div",
1494
+ {
1495
+ role: "alert",
1496
+ style: {
1497
+ width: g,
1498
+ height: x,
1499
+ display: "flex",
1500
+ alignItems: "center",
1501
+ justifyContent: "center",
1502
+ border: "1px dashed var(--color-error, #ef4444)",
1503
+ borderRadius: 4,
1504
+ color: "var(--color-error, #ef4444)",
1505
+ fontSize: b,
1506
+ padding: "0 8px",
1507
+ boxSizing: "border-box"
1508
+ },
1509
+ children: i ?? "Error"
1510
+ }
1511
+ ) : M === "loading" ? /* @__PURE__ */ jsxRuntime.jsx(
1512
+ "div",
1513
+ {
1514
+ role: "status",
1515
+ "aria-label": "Loading",
1516
+ className: "nice-bullet__skeleton",
1517
+ style: {
1518
+ width: g,
1519
+ height: x,
1520
+ borderRadius: 4,
1521
+ background: "linear-gradient(90deg, var(--bg-tertiary, #e5e7eb) 25%, var(--bg-secondary, #f3f4f6) 50%, var(--bg-tertiary, #e5e7eb) 75%)",
1522
+ backgroundSize: "200% 100%",
1523
+ animation: "nice-bullet-shimmer 1.4s linear infinite"
1524
+ }
1525
+ }
1526
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(
1527
+ "svg",
1528
+ {
1529
+ width: g,
1530
+ height: x,
1531
+ role: "img",
1532
+ "aria-label": typeof w == "string" ? w : void 0,
1533
+ children: [
1534
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: y, y, width: h, height: B, rx: 3, fill: "var(--border-color, #e2e8f0)" }),
1535
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: y, y: y + B * 0.2, width: h * a, height: B * 0.6, rx: 2, fill: m }),
1536
+ _ != null && /* @__PURE__ */ jsxRuntime.jsx(
1537
+ "line",
1538
+ {
1539
+ x1: y + h * _,
1540
+ y1: y + 2,
1541
+ x2: y + h * _,
1542
+ y2: y + B - 2,
1543
+ stroke: A,
1544
+ strokeWidth: 2
1545
+ }
1546
+ ),
1547
+ k && /* @__PURE__ */ jsxRuntime.jsx(
1548
+ "text",
1549
+ {
1550
+ x: y + Math.max(h * a, 4),
1551
+ y: x / 2,
1552
+ dx: h * a > 24 ? -4 : 4,
1553
+ textAnchor: h * a > 24 ? "end" : "start",
1554
+ dominantBaseline: "middle",
1555
+ fontSize: b,
1556
+ fill: h * a > 24 ? "#fff" : "var(--text-primary)",
1557
+ fontWeight: 600,
1558
+ children: C(t)
1559
+ }
1560
+ ),
1561
+ z && _ != null && /* @__PURE__ */ jsxRuntime.jsxs(
1562
+ "text",
1563
+ {
1564
+ x: y + h * _,
1565
+ y: y - 1,
1566
+ textAnchor: "middle",
1567
+ fontSize: b - 1,
1568
+ fill: A,
1569
+ fontWeight: 600,
1570
+ children: [
1571
+ "▼",
1572
+ C(o)
1573
+ ]
1574
+ }
1575
+ )
1576
+ ]
1577
+ }
1578
+ );
1579
+ if (p === "none" || !w)
1580
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `nice-bullet ${d || ""}`, style: u, children: [
1581
+ I(),
1582
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: Ee })
1583
+ ] });
1584
+ const P = p === "top" || p === "bottom", Z = /* @__PURE__ */ jsxRuntime.jsx(
1585
+ "span",
1586
+ {
1587
+ className: "nice-bullet__label",
1588
+ style: {
1589
+ fontSize: b,
1590
+ fontWeight: 600,
1591
+ color: "var(--text-primary)",
1592
+ ...P ? {
1593
+ marginBottom: p === "top" ? 4 : 0,
1594
+ marginTop: p === "bottom" ? 4 : 0
1595
+ } : {},
1596
+ ...p === "left" ? { marginRight: 8 } : {},
1597
+ ...p === "right" ? { marginLeft: 8 } : {}
1598
+ },
1599
+ children: w
1600
+ }
1601
+ );
1602
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1603
+ "div",
1604
+ {
1605
+ className: `nice-bullet nice-bullet--${p} ${d || ""}`,
1606
+ style: {
1607
+ display: "inline-flex",
1608
+ flexDirection: P ? "column" : "row",
1609
+ alignItems: P ? "flex-start" : "center",
1610
+ ...u
1611
+ },
1612
+ children: [
1613
+ (p === "top" || p === "left") && Z,
1614
+ I(),
1615
+ (p === "bottom" || p === "right") && Z,
1616
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: Ee })
1617
+ ]
1618
+ }
1619
+ );
1620
+ }, Ee = `
1621
+ @keyframes nice-bullet-shimmer {
1622
+ 0% { background-position: 200% 0; }
1623
+ 100% { background-position: -200% 0; }
1624
+ }
1625
+ `, Nt = ({
1626
+ data: t,
1627
+ width: o = 400,
1628
+ height: s = 300,
1629
+ inverted: l,
1630
+ showLabels: c = true,
1631
+ showValues: v = true,
1632
+ title: m,
1633
+ className: A,
1634
+ style: D
1635
+ }) => {
1636
+ const w = { top: m ? 30 : 10, bottom: 10, x: 40 }, p = o - w.x * 2, k = s - w.top - w.bottom, z = l ? [...t].reverse() : t, C = Math.max(...z.map((i) => i.value), 1), M = k / z.length;
1637
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-funnel ${A || ""}`, style: D, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: o, height: s, children: [
1638
+ m && /* @__PURE__ */ jsxRuntime.jsx("text", { x: o / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: m }),
1639
+ z.map((i, d) => {
1640
+ const u = i.value / C * p, S = d < z.length - 1 ? z[d + 1].value / C * p : u * 0.3, g = w.top + d * M, x = g + M, b = o / 2, y = `${b - u / 2},${g} ${b + u / 2},${g} ${b + S / 2},${x} ${b - S / 2},${x}`, h = i.color || ve[d % ve.length];
1641
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
1642
+ /* @__PURE__ */ jsxRuntime.jsx(
1643
+ "polygon",
1644
+ {
1645
+ points: y,
1646
+ fill: h,
1647
+ stroke: "var(--bg-primary, #fff)",
1648
+ strokeWidth: 1,
1649
+ children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${i.label}: ${i.value}` })
1650
+ }
1651
+ ),
1652
+ c && /* @__PURE__ */ jsxRuntime.jsx(
1653
+ "text",
1654
+ {
1655
+ x: b,
1656
+ y: g + M / 2 - (v ? 4 : 0),
1657
+ textAnchor: "middle",
1658
+ dominantBaseline: "middle",
1659
+ className: "nice-funnel__label",
1660
+ children: i.label
1661
+ }
1662
+ ),
1663
+ v && /* @__PURE__ */ jsxRuntime.jsx(
1664
+ "text",
1665
+ {
1666
+ x: b,
1667
+ y: g + M / 2 + 10,
1668
+ textAnchor: "middle",
1669
+ dominantBaseline: "middle",
1670
+ className: "nice-funnel__value",
1671
+ children: i.value
1672
+ }
1673
+ )
1674
+ ] }, d);
1675
+ })
1676
+ ] }) });
1677
+ }, Qe = ({
1678
+ nodes: t,
1679
+ links: o,
1680
+ width: s = 600,
1681
+ height: l = 400,
1682
+ nodeWidth: c = 20,
1683
+ nodePadding: v = 10,
1684
+ title: m,
1685
+ className: A,
1686
+ style: D
1687
+ }) => {
1688
+ const w = { top: m ? 40 : 20, bottom: 20, left: 20, right: 20 }, p = s - w.left - w.right, k = l - w.top - w.bottom, z = new Set(o.map((a) => a.source)), C = new Set(o.map((a) => a.target)), M = t.filter((a) => z.has(a.id) && !C.has(a.id)), i = t.filter((a) => C.has(a.id)), d = t.filter((a) => z.has(a.id) && C.has(a.id)), u = [M, ...d.length ? [d] : [], i].filter(
1689
+ (a) => a.length > 0
1690
+ ), S = u.length, g = /* @__PURE__ */ new Map();
1691
+ t.forEach((a) => {
1692
+ const _ = o.filter((P) => P.source === a.id).reduce((P, Z) => P + Z.value, 0), I = o.filter((P) => P.target === a.id).reduce((P, Z) => P + Z.value, 0);
1693
+ g.set(a.id, Math.max(_, I));
1694
+ });
1695
+ const x = u.map(
1696
+ (a) => a.reduce((_, I) => _ + (g.get(I.id) || 0), 0) + (a.length - 1) * v
1697
+ ), b = Math.max(...x, 1), y = /* @__PURE__ */ new Map();
1698
+ u.forEach((a, _) => {
1699
+ const I = w.left + _ / (S - 1 || 1) * (p - c);
1700
+ let P = 0;
1701
+ a.forEach((Z) => {
1702
+ const U = (g.get(Z.id) || 0) / b * k;
1703
+ y.set(Z.id, { x: I, y: w.top + P, h: U }), P += U + v;
1704
+ });
1705
+ });
1706
+ const h = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
1707
+ return t.forEach((a) => {
1708
+ h.set(a.id, 0), B.set(a.id, 0);
1709
+ }), /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-sankey ${A || ""}`, style: D, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: s, height: l, children: [
1710
+ m && /* @__PURE__ */ jsxRuntime.jsx("text", { x: s / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: m }),
1711
+ o.map((a, _) => {
1712
+ const I = y.get(a.source), P = y.get(a.target);
1713
+ if (!I || !P)
1714
+ return null;
1715
+ const Z = h.get(a.source) || 0, U = B.get(a.target) || 0, V = a.value / b * k;
1716
+ h.set(a.source, Z + V), B.set(a.target, U + V);
1717
+ const G = I.x + c, Q = I.y + Z, q = P.x, J = P.y + U, n = (G + q) / 2, F = t.find((W) => W.id === a.source)?.color || ve[_ % ve.length];
1718
+ return /* @__PURE__ */ jsxRuntime.jsx(
1719
+ "path",
1720
+ {
1721
+ d: `M${G},${Q} C${n},${Q} ${n},${J} ${q},${J} L${q},${J + V} C${n},${J + V} ${n},${Q + V} ${G},${Q + V} Z`,
1722
+ fill: F,
1723
+ fillOpacity: 0.3,
1724
+ stroke: F,
1725
+ strokeOpacity: 0.5,
1726
+ strokeWidth: 0.5,
1727
+ children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${a.source} → ${a.target}: ${a.value}` })
1728
+ },
1729
+ _
1730
+ );
1731
+ }),
1732
+ t.map((a, _) => {
1733
+ const I = y.get(a.id);
1734
+ if (!I)
1735
+ return null;
1736
+ const P = a.color || ve[_ % ve.length];
1737
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
1738
+ /* @__PURE__ */ jsxRuntime.jsx(
1739
+ "rect",
1740
+ {
1741
+ x: I.x,
1742
+ y: I.y,
1743
+ width: c,
1744
+ height: Math.max(I.h, 2),
1745
+ fill: P,
1746
+ rx: 2
1747
+ }
1748
+ ),
1749
+ /* @__PURE__ */ jsxRuntime.jsx(
1750
+ "text",
1751
+ {
1752
+ x: I.x < p / 2 ? I.x + c + 4 : I.x - 4,
1753
+ y: I.y + I.h / 2,
1754
+ textAnchor: I.x < p / 2 ? "start" : "end",
1755
+ dominantBaseline: "middle",
1756
+ className: "nice-chart__legend-text",
1757
+ children: a.label
1758
+ }
1759
+ )
1760
+ ] }, a.id);
1761
+ })
1762
+ ] }) });
1763
+ }, kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1764
+ __proto__: null,
1765
+ NiceSankey: Qe
1766
+ }, Symbol.toStringTag, { value: "Module" })), St = ({
1767
+ data: t,
1768
+ min: o,
1769
+ max: s,
1770
+ start: l,
1771
+ end: c,
1772
+ onChange: v,
1773
+ width: m = 500,
1774
+ height: A = 100,
1775
+ step: D = 1,
1776
+ formatValue: w,
1777
+ chartColor: p = "var(--color-primary, #3b82f6)",
1778
+ className: k,
1779
+ style: z
1780
+ }) => {
1781
+ const C = { top: 10, bottom: 30, left: 10, right: 10 }, M = m - C.left - C.right, i = A - C.top - C.bottom, d = (y) => C.left + (y - o) / (s - o || 1) * M, u = (y) => {
1782
+ const h = Math.max(0, Math.min(1, (y - C.left) / M)), B = o + h * (s - o);
1783
+ return Math.round(B / D) * D;
1784
+ }, S = (y, h) => {
1785
+ h.preventDefault();
1786
+ const B = h.target.closest("svg");
1787
+ if (!B)
1788
+ return;
1789
+ const a = (I) => {
1790
+ const P = B.getBoundingClientRect(), Z = u(I.clientX - P.left);
1791
+ y === "start" ? v(Math.min(Z, c), c) : v(l, Math.max(Z, l));
1792
+ }, _ = () => {
1793
+ document.removeEventListener("pointermove", a), document.removeEventListener("pointerup", _);
1794
+ };
1795
+ document.addEventListener("pointermove", a), document.addEventListener("pointerup", _);
1796
+ }, g = t ? Math.min(...t) : 0, b = (t ? Math.max(...t) : 1) - g || 1;
1797
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-rangeselector ${k || ""}`, style: z, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: m, height: A, children: [
1798
+ t && t.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(
1799
+ "polygon",
1800
+ {
1801
+ points: `${C.left},${C.top + i} ${t.map((y, h) => `${C.left + h / (t.length - 1) * M},${C.top + i - (y - g) / b * i}`).join(" ")} ${C.left + M},${C.top + i}`,
1802
+ fill: p,
1803
+ opacity: 0.15
1804
+ }
1805
+ ),
1806
+ /* @__PURE__ */ jsxRuntime.jsx(
1807
+ "rect",
1808
+ {
1809
+ x: d(l),
1810
+ y: C.top,
1811
+ width: d(c) - d(l),
1812
+ height: i,
1813
+ fill: p,
1814
+ opacity: 0.1
1815
+ }
1816
+ ),
1817
+ /* @__PURE__ */ jsxRuntime.jsx(
1818
+ "rect",
1819
+ {
1820
+ x: C.left,
1821
+ y: C.top,
1822
+ width: d(l) - C.left,
1823
+ height: i,
1824
+ fill: "var(--bg-secondary, #f5f5f5)",
1825
+ opacity: 0.6
1826
+ }
1827
+ ),
1828
+ /* @__PURE__ */ jsxRuntime.jsx(
1829
+ "rect",
1830
+ {
1831
+ x: d(c),
1832
+ y: C.top,
1833
+ width: C.left + M - d(c),
1834
+ height: i,
1835
+ fill: "var(--bg-secondary, #f5f5f5)",
1836
+ opacity: 0.6
1837
+ }
1838
+ ),
1839
+ /* @__PURE__ */ jsxRuntime.jsx(
1840
+ "rect",
1841
+ {
1842
+ x: d(l) - 4,
1843
+ y: C.top,
1844
+ width: 8,
1845
+ height: i,
1846
+ fill: p,
1847
+ rx: 2,
1848
+ cursor: "ew-resize",
1849
+ onPointerDown: (y) => S("start", y)
1850
+ }
1851
+ ),
1852
+ /* @__PURE__ */ jsxRuntime.jsx(
1853
+ "rect",
1854
+ {
1855
+ x: d(c) - 4,
1856
+ y: C.top,
1857
+ width: 8,
1858
+ height: i,
1859
+ fill: p,
1860
+ rx: 2,
1861
+ cursor: "ew-resize",
1862
+ onPointerDown: (y) => S("end", y)
1863
+ }
1864
+ ),
1865
+ /* @__PURE__ */ jsxRuntime.jsx(
1866
+ "text",
1867
+ {
1868
+ x: d(l),
1869
+ y: C.top + i + 18,
1870
+ textAnchor: "middle",
1871
+ className: "nice-chart__axis-label",
1872
+ children: w ? w(l) : l
1873
+ }
1874
+ ),
1875
+ /* @__PURE__ */ jsxRuntime.jsx(
1876
+ "text",
1877
+ {
1878
+ x: d(c),
1879
+ y: C.top + i + 18,
1880
+ textAnchor: "middle",
1881
+ className: "nice-chart__axis-label",
1882
+ children: w ? w(c) : c
1883
+ }
1884
+ )
1885
+ ] }) });
1886
+ }, et = ({
1887
+ regions: t,
1888
+ width: o = 600,
1889
+ height: s = 400,
1890
+ viewBox: l = "0 0 1000 600",
1891
+ colorRange: c = ["var(--info-bg, #dbeafe)", "var(--color-primary-active, #1d4ed8)"],
1892
+ maxValue: v,
1893
+ onRegionClick: m,
1894
+ selectedRegionId: A,
1895
+ title: D,
1896
+ showTooltip: w = true,
1897
+ className: p,
1898
+ style: k
1899
+ }) => {
1900
+ const z = v ?? Math.max(...t.map((M) => M.value ?? 0), 1), C = (M) => {
1901
+ const i = (a) => [
1902
+ parseInt(a.slice(1, 3), 16),
1903
+ parseInt(a.slice(3, 5), 16),
1904
+ parseInt(a.slice(5, 7), 16)
1905
+ ], [d, u, S] = i(c[0]), [g, x, b] = i(c[1]), y = Math.round(d + (g - d) * M), h = Math.round(u + (x - u) * M), B = Math.round(S + (b - S) * M);
1906
+ return `rgb(${y},${h},${B})`;
1907
+ };
1908
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `nice-vectormap ${p || ""}`, style: k, children: [
1909
+ D && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-vectormap__title", children: D }),
1910
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { width: o, height: s, viewBox: l, children: t.map((M) => {
1911
+ const i = M.value != null ? Math.max(0, Math.min(1, M.value / z)) : 0, d = M.value != null ? C(i) : "var(--bg-tertiary, #e5e7eb)", u = M.id === A;
1912
+ return /* @__PURE__ */ jsxRuntime.jsx(
1913
+ "path",
1914
+ {
1915
+ d: M.path,
1916
+ fill: d,
1917
+ stroke: u ? "var(--color-primary, #3b82f6)" : "var(--border-color, #d1d5db)",
1918
+ strokeWidth: u ? 2 : 0.5,
1919
+ cursor: m ? "pointer" : void 0,
1920
+ onClick: () => m?.(M),
1921
+ children: w && /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${M.name}${M.value != null ? `: ${M.value}` : ""}` })
1922
+ },
1923
+ M.id
1924
+ );
1925
+ }) })
1926
+ ] });
1927
+ }, Ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1928
+ __proto__: null,
1929
+ NiceVectorMap: et
1930
+ }, Symbol.toStringTag, { value: "Module" })), tt = `
1931
+ .nice-forecast-chart {
1932
+ display: flex;
1933
+ flex-direction: column;
1934
+ background: var(--nice-bg-primary, #ffffff);
1935
+ border: 1px solid var(--nice-border-color, #e5e7eb);
1936
+ border-radius: 0.5rem;
1937
+ overflow: hidden;
1938
+ }
1939
+
1940
+ .nice-forecast-chart__header {
1941
+ display: flex;
1942
+ align-items: center;
1943
+ justify-content: space-between;
1944
+ padding: 0.75rem 1rem;
1945
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
1946
+ }
1947
+
1948
+ .nice-forecast-chart__title {
1949
+ font-size: 1rem;
1950
+ font-weight: 600;
1951
+ color: var(--nice-text-primary);
1952
+ margin: 0;
1953
+ }
1954
+
1955
+ .nice-forecast-chart__actions {
1956
+ display: flex;
1957
+ gap: 0.5rem;
1958
+ }
1959
+
1960
+ .nice-forecast-chart__btn {
1961
+ display: inline-flex;
1962
+ align-items: center;
1963
+ justify-content: center;
1964
+ width: 2rem;
1965
+ height: 2rem;
1966
+ font-size: 1rem;
1967
+ border-radius: 0.375rem;
1968
+ cursor: pointer;
1969
+ transition: all 0.15s ease;
1970
+ border: 1px solid var(--nice-border-color, #d1d5db);
1971
+ background: var(--nice-bg-primary, #ffffff);
1972
+ color: var(--nice-text-secondary);
1973
+ }
1974
+
1975
+ .nice-forecast-chart__btn:hover {
1976
+ background: var(--nice-bg-hover, #f3f4f6);
1977
+ color: var(--nice-text-primary);
1978
+ }
1979
+
1980
+ .nice-forecast-chart__btn:disabled {
1981
+ opacity: 0.5;
1982
+ cursor: not-allowed;
1983
+ }
1984
+
1985
+ .nice-forecast-chart__container {
1986
+ position: relative;
1987
+ width: 100%;
1988
+ padding: 1rem;
1989
+ }
1990
+
1991
+ .nice-forecast-chart__svg {
1992
+ width: 100%;
1993
+ overflow: visible;
1994
+ }
1995
+
1996
+ .nice-forecast-chart__grid-line {
1997
+ stroke: var(--nice-border-divider, #f3f4f6);
1998
+ stroke-width: 1;
1999
+ }
2000
+
2001
+ .nice-forecast-chart__axis-line {
2002
+ stroke: var(--nice-border-color, #e5e7eb);
2003
+ stroke-width: 1;
2004
+ }
2005
+
2006
+ .nice-forecast-chart__axis-label {
2007
+ font-size: 0.6875rem;
2008
+ fill: var(--nice-text-secondary);
2009
+ }
2010
+
2011
+ .nice-forecast-chart__axis-title {
2012
+ font-size: 0.75rem;
2013
+ font-weight: 500;
2014
+ fill: var(--nice-text-primary);
2015
+ }
2016
+
2017
+ .nice-forecast-chart__historical-line {
2018
+ fill: none;
2019
+ stroke-width: 2;
2020
+ stroke-linecap: round;
2021
+ stroke-linejoin: round;
2022
+ }
2023
+
2024
+ .nice-forecast-chart__forecast-line {
2025
+ fill: none;
2026
+ stroke-width: 2;
2027
+ stroke-linecap: round;
2028
+ stroke-linejoin: round;
2029
+ stroke-dasharray: 6, 4;
2030
+ }
2031
+
2032
+ .nice-forecast-chart__confidence-band {
2033
+ opacity: 0.2;
2034
+ }
2035
+
2036
+ .nice-forecast-chart__forecast-region {
2037
+ fill: var(--nice-bg-secondary, #f9fafb);
2038
+ opacity: 0.5;
2039
+ }
2040
+
2041
+ .nice-forecast-chart__point {
2042
+ cursor: pointer;
2043
+ transition: r 0.15s ease;
2044
+ }
2045
+
2046
+ .nice-forecast-chart__point:hover {
2047
+ r: 6;
2048
+ }
2049
+
2050
+ .nice-forecast-chart__annotation-line {
2051
+ stroke-dasharray: 4, 2;
2052
+ stroke-width: 1;
2053
+ }
2054
+
2055
+ .nice-forecast-chart__annotation-marker {
2056
+ cursor: pointer;
2057
+ transition: transform 0.15s ease;
2058
+ }
2059
+
2060
+ .nice-forecast-chart__annotation-marker:hover {
2061
+ transform: scale(1.2);
2062
+ }
2063
+
2064
+ .nice-forecast-chart__reference-line {
2065
+ stroke-width: 1;
2066
+ }
2067
+
2068
+ .nice-forecast-chart__reference-label {
2069
+ font-size: 0.625rem;
2070
+ fill: var(--nice-text-secondary);
2071
+ }
2072
+
2073
+ .nice-forecast-chart__cash-runway {
2074
+ pointer-events: none;
2075
+ }
2076
+
2077
+ .nice-forecast-chart__cash-runway-line {
2078
+ stroke: #ef4444;
2079
+ stroke-width: 2;
2080
+ stroke-dasharray: 8, 4;
2081
+ }
2082
+
2083
+ .nice-forecast-chart__cash-runway-label-bg {
2084
+ fill: #ef4444;
2085
+ rx: 4;
2086
+ }
2087
+
2088
+ .nice-forecast-chart__cash-runway-label {
2089
+ font-size: 0.6875rem;
2090
+ font-weight: 600;
2091
+ fill: #ffffff;
2092
+ }
2093
+
2094
+ .nice-forecast-chart__cash-runway-date {
2095
+ font-size: 0.625rem;
2096
+ fill: #ef4444;
2097
+ font-weight: 500;
2098
+ }
2099
+
2100
+ .nice-forecast-chart__tooltip {
2101
+ position: absolute;
2102
+ pointer-events: none;
2103
+ z-index: 100;
2104
+ padding: 0.75rem;
2105
+ background: var(--nice-bg-primary, #ffffff);
2106
+ border: 1px solid var(--nice-border-color, #e5e7eb);
2107
+ border-radius: 0.5rem;
2108
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
2109
+ font-size: 0.8125rem;
2110
+ max-width: 250px;
2111
+ }
2112
+
2113
+ .nice-forecast-chart__tooltip-date {
2114
+ font-weight: 600;
2115
+ color: var(--nice-text-primary);
2116
+ margin-bottom: 0.5rem;
2117
+ padding-bottom: 0.5rem;
2118
+ border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
2119
+ }
2120
+
2121
+ .nice-forecast-chart__tooltip-item {
2122
+ display: flex;
2123
+ align-items: center;
2124
+ gap: 0.5rem;
2125
+ margin-bottom: 0.25rem;
2126
+ }
2127
+
2128
+ .nice-forecast-chart__tooltip-color {
2129
+ width: 10px;
2130
+ height: 10px;
2131
+ border-radius: 2px;
2132
+ flex-shrink: 0;
2133
+ }
2134
+
2135
+ .nice-forecast-chart__tooltip-label {
2136
+ color: var(--nice-text-secondary);
2137
+ flex: 1;
2138
+ }
2139
+
2140
+ .nice-forecast-chart__tooltip-value {
2141
+ font-weight: 600;
2142
+ color: var(--nice-text-primary);
2143
+ font-variant-numeric: tabular-nums;
2144
+ }
2145
+
2146
+ .nice-forecast-chart__tooltip-confidence {
2147
+ font-size: 0.75rem;
2148
+ color: var(--nice-text-tertiary);
2149
+ }
2150
+
2151
+ .nice-forecast-chart__legend {
2152
+ display: flex;
2153
+ flex-wrap: wrap;
2154
+ gap: 1rem;
2155
+ padding: 0.75rem 1rem;
2156
+ border-top: 1px solid var(--nice-border-color, #e5e7eb);
2157
+ }
2158
+
2159
+ .nice-forecast-chart__legend-item {
2160
+ display: flex;
2161
+ align-items: center;
2162
+ gap: 0.375rem;
2163
+ font-size: 0.8125rem;
2164
+ color: var(--nice-text-secondary);
2165
+ cursor: pointer;
2166
+ user-select: none;
2167
+ transition: opacity 0.15s ease;
2168
+ }
2169
+
2170
+ .nice-forecast-chart__legend-item:hover {
2171
+ color: var(--nice-text-primary);
2172
+ }
2173
+
2174
+ .nice-forecast-chart__legend-item--hidden {
2175
+ opacity: 0.4;
2176
+ }
2177
+
2178
+ .nice-forecast-chart__legend-color {
2179
+ width: 16px;
2180
+ height: 3px;
2181
+ border-radius: 1px;
2182
+ }
2183
+
2184
+ .nice-forecast-chart__legend-color--dashed {
2185
+ background: repeating-linear-gradient(
2186
+ 90deg,
2187
+ currentColor,
2188
+ currentColor 4px,
2189
+ transparent 4px,
2190
+ transparent 6px
2191
+ );
2192
+ }
2193
+
2194
+ .nice-forecast-chart__empty {
2195
+ display: flex;
2196
+ align-items: center;
2197
+ justify-content: center;
2198
+ height: 300px;
2199
+ color: var(--nice-text-secondary);
2200
+ }
2201
+
2202
+ /* Dark mode */
2203
+ .dark .nice-forecast-chart {
2204
+ background: var(--nice-bg-primary-dark, #111827);
2205
+ border-color: var(--nice-border-color-dark, #374151);
2206
+ }
2207
+
2208
+ .dark .nice-forecast-chart__tooltip {
2209
+ background: var(--nice-bg-secondary-dark, #1f2937);
2210
+ border-color: var(--nice-border-color-dark, #374151);
2211
+ }
2212
+
2213
+ .dark .nice-forecast-chart__forecast-region {
2214
+ fill: var(--nice-bg-secondary-dark, #1f2937);
2215
+ }
2216
+ `, Oe = [
2217
+ "var(--color-primary, #3b82f6)",
2218
+ // blue
2219
+ "var(--color-success, #10b981)",
2220
+ // green
2221
+ "var(--color-warning, #f59e0b)",
2222
+ // amber
2223
+ "var(--color-error, #ef4444)",
2224
+ // red
2225
+ "var(--color-accent, #8b5cf6)",
2226
+ // purple
2227
+ "var(--color-accent-pink, #ec4899)",
2228
+ // pink
2229
+ "var(--color-info, #06b6d4)",
2230
+ // cyan
2231
+ "#f97316"
2232
+ // orange
2233
+ ];
2234
+ function xe(t) {
2235
+ return t instanceof Date ? t : new Date(t);
2236
+ }
2237
+ function Be(t, o = "pl-PL") {
2238
+ return t.toLocaleDateString(o, {
2239
+ year: "numeric",
2240
+ month: "short",
2241
+ day: "numeric"
2242
+ });
2243
+ }
2244
+ function Ie(t, o = "pl-PL") {
2245
+ return new Intl.NumberFormat(o, {
2246
+ minimumFractionDigits: 0,
2247
+ maximumFractionDigits: 2
2248
+ }).format(t);
2249
+ }
2250
+ _e.forwardRef(
2251
+ function(o, s) {
2252
+ const {
2253
+ scenarios: l,
2254
+ data: c,
2255
+ annotations: v = [],
2256
+ referenceLines: m = [],
2257
+ forecastStartDate: A,
2258
+ cashRunway: D,
2259
+ xAxis: w,
2260
+ yAxis: p,
2261
+ confidenceBands: k = [{ level: 95, color: "var(--color-primary, #3b82f6)", opacity: 0.15 }],
2262
+ tooltip: z,
2263
+ legend: C = { enabled: true, position: "bottom", interactive: true },
2264
+ height: M = 350,
2265
+ showForecastRegion: i = true,
2266
+ lineWidth: d = 2,
2267
+ showPoints: u = false,
2268
+ pointRadius: S = 4,
2269
+ enableZoom: g = false,
2270
+ zoomEnabled: x,
2271
+ animationDuration: b = 300,
2272
+ showLegend: y,
2273
+ responsive: h = true,
2274
+ onPointClick: B,
2275
+ onAnnotationClick: a,
2276
+ onScenarioToggle: _,
2277
+ onViewportChange: I,
2278
+ size: P = "medium",
2279
+ disabled: Z = false,
2280
+ labels: U = {},
2281
+ locale: V = "pl-PL",
2282
+ className: G,
2283
+ style: Q
2284
+ } = o, q = l && l.length > 0 ? l : c ? [
2285
+ {
2286
+ id: "default",
2287
+ name: "Series",
2288
+ data: c
2289
+ }
2290
+ ] : [], J = {
2291
+ ...C,
2292
+ enabled: y ?? C.enabled
2293
+ }, [n, H] = _e.useState(
2294
+ () => q.map((r, R) => ({
2295
+ ...r,
2296
+ color: r.color ?? Oe[R % Oe.length],
2297
+ visible: r.visible !== false
2298
+ }))
2299
+ ), [F, W] = _e.useState(null), [f, Y] = _e.useState({ x: 0, y: 0 }), j = _e.useRef(null), ee = _e.useRef(null), O = { top: 20, right: 30, bottom: 40, left: 60 }, [te, pe] = _e.useState({
2300
+ width: 600,
2301
+ height: typeof M == "number" ? M : 350
2302
+ });
2303
+ _e.useEffect(() => {
2304
+ if (!h || !j.current)
2305
+ return;
2306
+ const r = new ResizeObserver((R) => {
2307
+ for (const E of R)
2308
+ pe((N) => ({
2309
+ width: E.contentRect.width,
2310
+ height: N.height
2311
+ }));
2312
+ });
2313
+ return r.observe(j.current), () => r.disconnect();
2314
+ }, [h]), _e.useEffect(() => {
2315
+ const r = "nice-forecast-chart-styles";
2316
+ if (!document.getElementById(r)) {
2317
+ const R = document.createElement("style");
2318
+ R.id = r, R.textContent = tt, document.head.appendChild(R);
2319
+ }
2320
+ }, []);
2321
+ const { xScale: L, yScale: X, allDates: ne, minY: ue, maxY: _e$1 } = _e.useMemo(() => {
2322
+ const R = n.filter((fe) => fe.visible !== false).flatMap((fe) => fe.data);
2323
+ if (R.length === 0)
2324
+ return { xScale: () => 0, yScale: () => 0, allDates: [], minY: 0, maxY: 100 };
2325
+ const E = R.map((fe) => xe(fe.date).getTime()), N = Math.min(...E), K = Math.max(...E), ie = R.flatMap((fe) => [fe.value, fe.forecast, fe.lowerBound, fe.upperBound]).filter((fe) => fe != null), le = p?.min ?? Math.min(...ie) * 0.95, he = p?.max ?? Math.max(...ie) * 1.05, we = te.width - O.left - O.right, Me = te.height - O.top - O.bottom, Le = (fe) => {
2326
+ const Te = typeof fe == "number" ? fe : fe.getTime();
2327
+ return O.left + (Te - N) / (K - N) * we;
2328
+ }, De = (fe) => O.top + Me - (fe - le) / (he - le) * Me, He = [...new Set(E)].sort((fe, Te) => fe - Te).map((fe) => new Date(fe));
2329
+ return {
2330
+ xScale: Le,
2331
+ yScale: De,
2332
+ allDates: He,
2333
+ minY: le,
2334
+ maxY: he
2335
+ };
2336
+ }, [n, te, O, p]), ge = A ? xe(A) : null, ye = _e.useMemo(() => {
2337
+ if (!D?.enabled)
2338
+ return null;
2339
+ const r = D.threshold ?? 0, R = D.scenarioId ? n.find((N) => N.id === D.scenarioId && N.visible !== false) : n.find((N) => N.visible !== false);
2340
+ if (!R)
2341
+ return null;
2342
+ const E = R.data.sort(
2343
+ (N, K) => xe(N.date).getTime() - xe(K.date).getTime()
2344
+ );
2345
+ for (let N = 1; N < E.length; N++) {
2346
+ const K = E[N - 1], ie = E[N], le = K.forecast ?? K.value, he = ie.forecast ?? ie.value;
2347
+ if (le != null && he != null && le > r && he <= r) {
2348
+ const we = (le - r) / (le - he), Me = xe(K.date).getTime(), Le = xe(ie.date).getTime(), De = Me + we * (Le - Me);
2349
+ return new Date(De);
2350
+ }
2351
+ }
2352
+ return null;
2353
+ }, [D, n]), $e = _e.useCallback(
2354
+ (r, R) => {
2355
+ const E = r.filter((N) => N[R] != null).map((N) => ({ x: L(xe(N.date)), y: X(N[R]) }));
2356
+ return E.length === 0 ? "" : `M ${E.map((N) => `${N.x},${N.y}`).join(" L ")}`;
2357
+ },
2358
+ [L, X]
2359
+ ), Se = _e.useCallback(
2360
+ (r) => {
2361
+ const R = r.filter((K) => K.lowerBound != null && K.upperBound != null);
2362
+ if (R.length === 0)
2363
+ return "";
2364
+ const E = R.map((K) => ({
2365
+ x: L(xe(K.date)),
2366
+ y: X(K.upperBound)
2367
+ })), N = R.map((K) => ({ x: L(xe(K.date)), y: X(K.lowerBound) })).reverse();
2368
+ return `M ${E.map((K) => `${K.x},${K.y}`).join(" L ")} L ${N.map((K) => `${K.x},${K.y}`).join(" L ")} Z`;
2369
+ },
2370
+ [L, X]
2371
+ ), T = _e.useCallback(
2372
+ (r) => {
2373
+ if (!ee.current || z?.enabled === false)
2374
+ return;
2375
+ const R = ee.current.getBoundingClientRect(), E = r.clientX - R.left;
2376
+ r.clientY - R.top;
2377
+ let N = null, K = 1 / 0;
2378
+ for (const ie of ne) {
2379
+ const le = L(ie), he = Math.abs(le - E);
2380
+ he < K && (K = he, N = ie);
2381
+ }
2382
+ if (N && K < 50) {
2383
+ const ie = n.filter((he) => he.visible !== false).map((he) => {
2384
+ const we = he.data.find((Me) => xe(Me.date).getTime() === N.getTime());
2385
+ return {
2386
+ scenario: he,
2387
+ value: we?.value,
2388
+ forecast: we?.forecast,
2389
+ lowerBound: we?.lowerBound,
2390
+ upperBound: we?.upperBound
2391
+ };
2392
+ }), le = v.filter(
2393
+ (he) => Math.abs(xe(he.date).getTime() - N.getTime()) < 864e5
2394
+ );
2395
+ W({ date: N, values: ie, annotations: le }), Y({ x: r.clientX - R.left + 10, y: r.clientY - R.top - 10 });
2396
+ } else
2397
+ W(null);
2398
+ },
2399
+ [L, ne, n, v, z]
2400
+ ), re = _e.useCallback(
2401
+ (r) => {
2402
+ if (!J.interactive)
2403
+ return;
2404
+ H((E) => E.map((N) => N.id === r ? { ...N, visible: !N.visible } : N));
2405
+ const R = n.find((E) => E.id === r);
2406
+ R && _?.(r, !R.visible);
2407
+ },
2408
+ [J.interactive, n, _]
2409
+ );
2410
+ _e.useImperativeHandle(
2411
+ s,
2412
+ () => ({
2413
+ getScenarios: () => n,
2414
+ updateScenario: (r, R) => {
2415
+ H((E) => E.map((N) => N.id === r ? { ...N, data: R } : N));
2416
+ },
2417
+ toggleScenario: re,
2418
+ setZoomRange: () => {
2419
+ },
2420
+ // Would need pan/zoom implementation
2421
+ resetZoom: () => {
2422
+ },
2423
+ exportImage: (r) => {
2424
+ if (!ee.current)
2425
+ return null;
2426
+ const R = ee.current, N = new XMLSerializer().serializeToString(R);
2427
+ return `data:image/svg+xml;base64,${btoa(N)}`;
2428
+ },
2429
+ getDataAtDate: (r) => {
2430
+ const R = n.filter((E) => E.visible !== false).map((E) => {
2431
+ const N = E.data.find((K) => xe(K.date).getTime() === r.getTime());
2432
+ return {
2433
+ scenario: E,
2434
+ value: N?.value,
2435
+ forecast: N?.forecast,
2436
+ lowerBound: N?.lowerBound,
2437
+ upperBound: N?.upperBound
2438
+ };
2439
+ });
2440
+ return {
2441
+ date: r,
2442
+ values: R,
2443
+ annotations: v.filter((E) => xe(E.date).getTime() === r.getTime())
2444
+ };
2445
+ }
2446
+ }),
2447
+ [n, v, re]
2448
+ ), te.width - O.left - O.right;
2449
+ const ce = te.height - O.top - O.bottom, se = _e.useMemo(() => {
2450
+ const r = p?.tickCount ?? 5, R = [], E = (_e$1 - ue) / (r - 1);
2451
+ for (let N = 0; N < r; N++)
2452
+ R.push(ue + E * N);
2453
+ return R;
2454
+ }, [ue, _e$1, p?.tickCount]), de = _e.useMemo(() => {
2455
+ const r = w?.tickCount ?? 6;
2456
+ if (ne.length === 0)
2457
+ return [];
2458
+ const R = Math.max(1, Math.floor(ne.length / (r - 1)));
2459
+ return ne.filter((E, N) => N % R === 0 || N === ne.length - 1);
2460
+ }, [ne, w?.tickCount]);
2461
+ return n.length === 0 || n.every((r) => r.data.length === 0) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-forecast-chart ${G ?? ""}`, style: Q, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-forecast-chart__empty", children: U.noData ?? "No data available" }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `nice-forecast-chart ${G ?? ""}`, style: { ...Q, height: M }, children: [
2462
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: j, className: "nice-forecast-chart__container", children: [
2463
+ /* @__PURE__ */ jsxRuntime.jsxs(
2464
+ "svg",
2465
+ {
2466
+ ref: ee,
2467
+ className: "nice-forecast-chart__svg",
2468
+ width: te.width,
2469
+ height: te.height,
2470
+ onMouseMove: T,
2471
+ onMouseLeave: () => W(null),
2472
+ children: [
2473
+ p?.showGrid !== false && se.map((r) => /* @__PURE__ */ jsxRuntime.jsx(
2474
+ "line",
2475
+ {
2476
+ className: "nice-forecast-chart__grid-line",
2477
+ x1: O.left,
2478
+ x2: te.width - O.right,
2479
+ y1: X(r),
2480
+ y2: X(r)
2481
+ },
2482
+ r
2483
+ )),
2484
+ i && ge && /* @__PURE__ */ jsxRuntime.jsx(
2485
+ "rect",
2486
+ {
2487
+ className: "nice-forecast-chart__forecast-region",
2488
+ x: L(ge),
2489
+ y: O.top,
2490
+ width: te.width - O.right - L(ge),
2491
+ height: ce
2492
+ }
2493
+ ),
2494
+ m.map((r) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
2495
+ /* @__PURE__ */ jsxRuntime.jsx(
2496
+ "line",
2497
+ {
2498
+ className: "nice-forecast-chart__reference-line",
2499
+ x1: O.left,
2500
+ x2: te.width - O.right,
2501
+ y1: X(r.value),
2502
+ y2: X(r.value),
2503
+ stroke: r.color ?? "var(--text-muted, #9ca3af)",
2504
+ strokeDasharray: r.dashArray ?? "4,2"
2505
+ }
2506
+ ),
2507
+ r.label && /* @__PURE__ */ jsxRuntime.jsx(
2508
+ "text",
2509
+ {
2510
+ className: "nice-forecast-chart__reference-label",
2511
+ x: te.width - O.right - 4,
2512
+ y: X(r.value) - 4,
2513
+ textAnchor: "end",
2514
+ children: r.label
2515
+ }
2516
+ )
2517
+ ] }, r.id)),
2518
+ ye && D?.enabled && /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "nice-forecast-chart__cash-runway", children: [
2519
+ /* @__PURE__ */ jsxRuntime.jsx(
2520
+ "line",
2521
+ {
2522
+ className: "nice-forecast-chart__cash-runway-line",
2523
+ x1: L(ye),
2524
+ x2: L(ye),
2525
+ y1: O.top,
2526
+ y2: te.height - O.bottom,
2527
+ stroke: D.color ?? "var(--color-error, #ef4444)"
2528
+ }
2529
+ ),
2530
+ D.showLabel !== false && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2531
+ /* @__PURE__ */ jsxRuntime.jsx(
2532
+ "rect",
2533
+ {
2534
+ className: "nice-forecast-chart__cash-runway-label-bg",
2535
+ x: L(ye) - 60,
2536
+ y: O.top - 2,
2537
+ width: 120,
2538
+ height: D.showDate !== false ? 32 : 20,
2539
+ fill: D.color ?? "var(--color-error, #ef4444)",
2540
+ rx: 4
2541
+ }
2542
+ ),
2543
+ /* @__PURE__ */ jsxRuntime.jsx(
2544
+ "text",
2545
+ {
2546
+ className: "nice-forecast-chart__cash-runway-label",
2547
+ x: L(ye),
2548
+ y: O.top + 12,
2549
+ textAnchor: "middle",
2550
+ fill: "#ffffff",
2551
+ children: D.label ?? U.cashRunsOut ?? "💰 Cash runs out"
2552
+ }
2553
+ ),
2554
+ D.showDate !== false && /* @__PURE__ */ jsxRuntime.jsx(
2555
+ "text",
2556
+ {
2557
+ className: "nice-forecast-chart__cash-runway-label",
2558
+ x: L(ye),
2559
+ y: O.top + 26,
2560
+ textAnchor: "middle",
2561
+ fill: "#ffffff",
2562
+ style: { fontSize: "0.625rem", opacity: 0.9 },
2563
+ children: Be(ye, V)
2564
+ }
2565
+ )
2566
+ ] })
2567
+ ] }),
2568
+ n.filter((r) => r.visible !== false && r.showConfidenceBand).map((r) => /* @__PURE__ */ jsxRuntime.jsx(
2569
+ "path",
2570
+ {
2571
+ className: "nice-forecast-chart__confidence-band",
2572
+ d: Se(r.data),
2573
+ fill: r.color
2574
+ },
2575
+ `band-${r.id}`
2576
+ )),
2577
+ n.filter((r) => r.visible !== false).map((r) => {
2578
+ const R = ge ? r.data.filter((N) => xe(N.date) < ge) : r.data.filter((N) => N.value != null), E = ge ? r.data.filter((N) => xe(N.date) >= ge) : r.data.filter((N) => N.forecast != null);
2579
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
2580
+ /* @__PURE__ */ jsxRuntime.jsx(
2581
+ "path",
2582
+ {
2583
+ className: "nice-forecast-chart__historical-line",
2584
+ d: $e(R, "value"),
2585
+ stroke: r.color,
2586
+ strokeWidth: d
2587
+ }
2588
+ ),
2589
+ /* @__PURE__ */ jsxRuntime.jsx(
2590
+ "path",
2591
+ {
2592
+ className: "nice-forecast-chart__forecast-line",
2593
+ d: $e(E, ge ? "value" : "forecast"),
2594
+ stroke: r.color,
2595
+ strokeWidth: d
2596
+ }
2597
+ ),
2598
+ E.length > 0 && r.data.some((N) => N.forecast != null) && /* @__PURE__ */ jsxRuntime.jsx(
2599
+ "path",
2600
+ {
2601
+ className: "nice-forecast-chart__forecast-line",
2602
+ d: $e(r.data, "forecast"),
2603
+ stroke: r.color,
2604
+ strokeWidth: d
2605
+ }
2606
+ ),
2607
+ u && r.data.map((N, K) => {
2608
+ const ie = N.value ?? N.forecast;
2609
+ return ie == null ? null : /* @__PURE__ */ jsxRuntime.jsx(
2610
+ "circle",
2611
+ {
2612
+ className: "nice-forecast-chart__point",
2613
+ cx: L(xe(N.date)),
2614
+ cy: X(ie),
2615
+ r: S,
2616
+ fill: r.color,
2617
+ onClick: () => B?.(N, r)
2618
+ },
2619
+ K
2620
+ );
2621
+ })
2622
+ ] }, r.id);
2623
+ }),
2624
+ v.map((r) => {
2625
+ const R = L(xe(r.date));
2626
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2627
+ "g",
2628
+ {
2629
+ className: "nice-forecast-chart__annotation-marker",
2630
+ onClick: () => a?.(r),
2631
+ children: [
2632
+ r.showLine !== false && /* @__PURE__ */ jsxRuntime.jsx(
2633
+ "line",
2634
+ {
2635
+ className: "nice-forecast-chart__annotation-line",
2636
+ x1: R,
2637
+ x2: R,
2638
+ y1: O.top,
2639
+ y2: te.height - O.bottom,
2640
+ stroke: r.color ?? "var(--text-muted, #9ca3af)"
2641
+ }
2642
+ ),
2643
+ /* @__PURE__ */ jsxRuntime.jsx(
2644
+ "circle",
2645
+ {
2646
+ cx: R,
2647
+ cy: O.top + 10,
2648
+ r: 8,
2649
+ fill: r.color ?? "var(--text-muted, #9ca3af)"
2650
+ }
2651
+ ),
2652
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: R, y: O.top + 14, textAnchor: "middle", fill: "white", fontSize: "10", children: r.icon ?? "!" })
2653
+ ]
2654
+ },
2655
+ r.id
2656
+ );
2657
+ }),
2658
+ /* @__PURE__ */ jsxRuntime.jsx(
2659
+ "line",
2660
+ {
2661
+ className: "nice-forecast-chart__axis-line",
2662
+ x1: O.left,
2663
+ x2: O.left,
2664
+ y1: O.top,
2665
+ y2: te.height - O.bottom
2666
+ }
2667
+ ),
2668
+ /* @__PURE__ */ jsxRuntime.jsx(
2669
+ "line",
2670
+ {
2671
+ className: "nice-forecast-chart__axis-line",
2672
+ x1: O.left,
2673
+ x2: te.width - O.right,
2674
+ y1: te.height - O.bottom,
2675
+ y2: te.height - O.bottom
2676
+ }
2677
+ ),
2678
+ se.map((r) => /* @__PURE__ */ jsxRuntime.jsx(
2679
+ "text",
2680
+ {
2681
+ className: "nice-forecast-chart__axis-label",
2682
+ x: O.left - 8,
2683
+ y: X(r) + 4,
2684
+ textAnchor: "end",
2685
+ children: p?.format ? p.format(r) : Ie(r, V)
2686
+ },
2687
+ r
2688
+ )),
2689
+ de.map((r) => /* @__PURE__ */ jsxRuntime.jsx(
2690
+ "text",
2691
+ {
2692
+ className: "nice-forecast-chart__axis-label",
2693
+ x: L(r),
2694
+ y: te.height - O.bottom + 16,
2695
+ textAnchor: "middle",
2696
+ children: w?.format ? w.format(r) : Be(r, V)
2697
+ },
2698
+ r.getTime()
2699
+ )),
2700
+ p?.title && /* @__PURE__ */ jsxRuntime.jsx(
2701
+ "text",
2702
+ {
2703
+ className: "nice-forecast-chart__axis-title",
2704
+ x: 15,
2705
+ y: te.height / 2,
2706
+ textAnchor: "middle",
2707
+ transform: `rotate(-90, 15, ${te.height / 2})`,
2708
+ children: p.title
2709
+ }
2710
+ )
2711
+ ]
2712
+ }
2713
+ ),
2714
+ F && /* @__PURE__ */ jsxRuntime.jsxs(
2715
+ "div",
2716
+ {
2717
+ className: "nice-forecast-chart__tooltip",
2718
+ style: { left: f.x, top: f.y },
2719
+ children: [
2720
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-forecast-chart__tooltip-date", children: Be(F.date, V) }),
2721
+ F.values.map((r) => {
2722
+ const R = r.value ?? r.forecast;
2723
+ return R == null ? null : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-forecast-chart__tooltip-item", children: [
2724
+ /* @__PURE__ */ jsxRuntime.jsx(
2725
+ "span",
2726
+ {
2727
+ className: "nice-forecast-chart__tooltip-color",
2728
+ style: { background: r.scenario.color }
2729
+ }
2730
+ ),
2731
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-forecast-chart__tooltip-label", children: r.scenario.name }),
2732
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-forecast-chart__tooltip-value", children: Ie(R, V) })
2733
+ ] }, r.scenario.id);
2734
+ }),
2735
+ F.values.some((r) => r.lowerBound != null) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-forecast-chart__tooltip-confidence", children: [
2736
+ U.confidence ?? "CI",
2737
+ ":",
2738
+ " ",
2739
+ Ie(F.values[0]?.lowerBound ?? 0, V),
2740
+ " –",
2741
+ " ",
2742
+ Ie(F.values[0]?.upperBound ?? 0, V)
2743
+ ] })
2744
+ ]
2745
+ }
2746
+ )
2747
+ ] }),
2748
+ J.enabled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-forecast-chart__legend", children: n.map((r) => /* @__PURE__ */ jsxRuntime.jsxs(
2749
+ "div",
2750
+ {
2751
+ className: `nice-forecast-chart__legend-item ${r.visible === false ? "nice-forecast-chart__legend-item--hidden" : ""}`,
2752
+ onClick: () => re(r.id),
2753
+ children: [
2754
+ /* @__PURE__ */ jsxRuntime.jsx(
2755
+ "span",
2756
+ {
2757
+ className: `nice-forecast-chart__legend-color ${r.isBase ? "" : "nice-forecast-chart__legend-color--dashed"}`,
2758
+ style: { background: r.color }
2759
+ }
2760
+ ),
2761
+ r.name
2762
+ ]
2763
+ },
2764
+ r.id
2765
+ )) })
2766
+ ] });
2767
+ }
2768
+ ); const je = [
2769
+ "var(--color-primary, #3b82f6)",
2770
+ "var(--color-error, #ef4444)",
2771
+ "var(--color-success, #22c55e)",
2772
+ "var(--color-warning, #f59e0b)",
2773
+ "var(--color-accent, #8b5cf6)",
2774
+ "var(--color-accent-pink, #ec4899)",
2775
+ "var(--color-info, #06b6d4)",
2776
+ "#84cc16",
2777
+ "#f97316",
2778
+ "var(--color-accent, #6366f1)"
2779
+ ], nt = _e.forwardRef(
2780
+ (t, o) => {
2781
+ const {
2782
+ levels: s,
2783
+ initialLevelId: l,
2784
+ chartType: c = "bar",
2785
+ width: v = 600,
2786
+ height: m = 400,
2787
+ showBreadcrumbs: A = true,
2788
+ showBackButton: D = true,
2789
+ animationDuration: w = 300,
2790
+ onLevelChange: p,
2791
+ onItemClick: k,
2792
+ colors: z = je,
2793
+ showValues: C = true,
2794
+ showLegend: M = true,
2795
+ className: i,
2796
+ style: d,
2797
+ ...u
2798
+ } = t, [S, g] = _e.useState(l || s[0]?.id), [x, b] = _e.useState([l || s[0]?.id]), [y, h] = _e.useState(false), [B, a] = _e.useState("in"), _ = _e.useMemo(
2799
+ () => s.find((n) => n.id === S),
2800
+ [s, S]
2801
+ ), I = _e.useCallback(
2802
+ (n) => {
2803
+ s.find((F) => F.id === n) && (a("in"), h(true), setTimeout(() => {
2804
+ g(n), b((F) => [...F, n]), p?.(n, [...x, n]), h(false);
2805
+ }, w / 2));
2806
+ },
2807
+ [s, x, w, p]
2808
+ ), P = _e.useCallback(() => {
2809
+ if (x.length <= 1)
2810
+ return;
2811
+ a("out"), h(true);
2812
+ const n = x.slice(0, -1), H = n[n.length - 1];
2813
+ setTimeout(() => {
2814
+ g(H), b(n), p?.(H, n), h(false);
2815
+ }, w / 2);
2816
+ }, [x, w, p]), Z = _e.useCallback(() => {
2817
+ const n = s[0]?.id;
2818
+ n && (a("out"), h(true), setTimeout(() => {
2819
+ g(n), b([n]), p?.(n, [n]), h(false);
2820
+ }, w / 2));
2821
+ }, [s, w, p]);
2822
+ _e.useImperativeHandle(
2823
+ o,
2824
+ () => ({
2825
+ drillDown: I,
2826
+ drillUp: P,
2827
+ resetToRoot: Z,
2828
+ getCurrentLevel: () => S,
2829
+ getPath: () => x
2830
+ }),
2831
+ [I, P, Z, S, x]
2832
+ );
2833
+ const U = _e.useCallback(
2834
+ (n, H) => {
2835
+ k?.(n, S);
2836
+ const F = s.find(
2837
+ (W) => W.parentId === S && W.id === n.metadata?.childLevelId
2838
+ );
2839
+ F && I(F.id);
2840
+ },
2841
+ [S, s, I, k]
2842
+ ), V = _e.useMemo(
2843
+ () => _?.data.reduce((n, H) => n + H.value, 0) || 0,
2844
+ [_]
2845
+ ), G = _e.useMemo(
2846
+ () => x.map((n) => s.find((H) => H.id === n)?.label || n),
2847
+ [x, s]
2848
+ ), Q = () => {
2849
+ if (!_)
2850
+ return null;
2851
+ const n = _.data, H = Math.max(...n.map((W) => W.value)), F = Math.min(40, (m - 100) / n.length - 8);
2852
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-drilldown-bars", children: n.map((W, f) => {
2853
+ const Y = W.value / H * 100;
2854
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2855
+ "div",
2856
+ {
2857
+ className: "nice-drilldown-bar-row",
2858
+ onClick: () => U(W, f),
2859
+ children: [
2860
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-drilldown-bar-label", children: W.label || `Item ${f + 1}` }),
2861
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-drilldown-bar-track", children: /* @__PURE__ */ jsxRuntime.jsx(
2862
+ "div",
2863
+ {
2864
+ className: "nice-drilldown-bar-fill",
2865
+ style: {
2866
+ width: `${Y}%`,
2867
+ backgroundColor: W.color || z[f % z.length],
2868
+ height: F
2869
+ }
2870
+ }
2871
+ ) }),
2872
+ C && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-drilldown-bar-value", children: W.value.toLocaleString() })
2873
+ ]
2874
+ },
2875
+ f
2876
+ );
2877
+ }) });
2878
+ }, q = () => {
2879
+ if (!_)
2880
+ return null;
2881
+ const n = _.data, H = v / 2, F = (m - 60) / 2 + 30, W = Math.min(H, F) - 40;
2882
+ let f = -90;
2883
+ const Y = n.map((j, ee) => {
2884
+ const O = j.value / V * 360, te = f + O, pe = O > 180 ? 1 : 0, L = f * Math.PI / 180, X = te * Math.PI / 180, ne = H + W * Math.cos(L), ue = F + W * Math.sin(L), _e = H + W * Math.cos(X), ge = F + W * Math.sin(X), ye = (f + O / 2) * Math.PI / 180, $e = H + W * 0.7 * Math.cos(ye), Se = F + W * 0.7 * Math.sin(ye), T = `M ${H} ${F} L ${ne} ${ue} A ${W} ${W} 0 ${pe} 1 ${_e} ${ge} Z`;
2885
+ return f = te, {
2886
+ path: T,
2887
+ color: j.color || z[ee % z.length],
2888
+ label: j.label || `Item ${ee + 1}`,
2889
+ value: j.value,
2890
+ percentage: (j.value / V * 100).toFixed(1),
2891
+ labelX: $e,
2892
+ labelY: Se,
2893
+ item: j,
2894
+ index: ee
2895
+ };
2896
+ });
2897
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: v, height: m - 40, className: "nice-drilldown-pie", children: /* @__PURE__ */ jsxRuntime.jsx("g", { children: Y.map((j, ee) => /* @__PURE__ */ jsxRuntime.jsxs("g", { onClick: () => U(j.item, j.index), children: [
2898
+ /* @__PURE__ */ jsxRuntime.jsx(
2899
+ "path",
2900
+ {
2901
+ d: j.path,
2902
+ fill: j.color,
2903
+ stroke: "white",
2904
+ strokeWidth: 2,
2905
+ className: "nice-drilldown-pie-slice"
2906
+ }
2907
+ ),
2908
+ C && parseFloat(j.percentage) > 5 && /* @__PURE__ */ jsxRuntime.jsxs(
2909
+ "text",
2910
+ {
2911
+ x: j.labelX,
2912
+ y: j.labelY,
2913
+ textAnchor: "middle",
2914
+ dominantBaseline: "middle",
2915
+ fill: "white",
2916
+ fontSize: "12",
2917
+ fontWeight: "600",
2918
+ children: [
2919
+ j.percentage,
2920
+ "%"
2921
+ ]
2922
+ }
2923
+ )
2924
+ ] }, ee)) }) });
2925
+ }, J = () => {
2926
+ if (!_)
2927
+ return null;
2928
+ const n = _.data, H = Math.max(...n.map((f) => f.value)), F = Math.min(60, (v - 100) / n.length - 8), W = m - 100;
2929
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: v, height: m - 40, className: "nice-drilldown-columns", children: /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: "translate(50, 20)", children: [
2930
+ [0, 0.25, 0.5, 0.75, 1].map((f, Y) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
2931
+ /* @__PURE__ */ jsxRuntime.jsx(
2932
+ "line",
2933
+ {
2934
+ x1: 0,
2935
+ y1: W * (1 - f),
2936
+ x2: v - 80,
2937
+ y2: W * (1 - f),
2938
+ stroke: "#e5e7eb",
2939
+ strokeDasharray: f === 0 ? void 0 : "4"
2940
+ }
2941
+ ),
2942
+ /* @__PURE__ */ jsxRuntime.jsx(
2943
+ "text",
2944
+ {
2945
+ x: -8,
2946
+ y: W * (1 - f),
2947
+ textAnchor: "end",
2948
+ dominantBaseline: "middle",
2949
+ fontSize: "11",
2950
+ fill: "#6b7280",
2951
+ children: Math.round(H * f).toLocaleString()
2952
+ }
2953
+ )
2954
+ ] }, Y)),
2955
+ n.map((f, Y) => {
2956
+ const j = f.value / H * W, ee = Y * ((v - 100) / n.length) + ((v - 100) / n.length - F) / 2;
2957
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { onClick: () => U(f, Y), children: [
2958
+ /* @__PURE__ */ jsxRuntime.jsx(
2959
+ "rect",
2960
+ {
2961
+ x: ee,
2962
+ y: W - j,
2963
+ width: F,
2964
+ height: j,
2965
+ fill: f.color || z[Y % z.length],
2966
+ rx: 4,
2967
+ className: "nice-drilldown-column-bar"
2968
+ }
2969
+ ),
2970
+ /* @__PURE__ */ jsxRuntime.jsx(
2971
+ "text",
2972
+ {
2973
+ x: ee + F / 2,
2974
+ y: W + 16,
2975
+ textAnchor: "middle",
2976
+ fontSize: "11",
2977
+ fill: "#374151",
2978
+ children: (f.label || `${Y + 1}`).slice(0, 10)
2979
+ }
2980
+ ),
2981
+ C && /* @__PURE__ */ jsxRuntime.jsx(
2982
+ "text",
2983
+ {
2984
+ x: ee + F / 2,
2985
+ y: W - j - 8,
2986
+ textAnchor: "middle",
2987
+ fontSize: "11",
2988
+ fill: "#374151",
2989
+ fontWeight: "500",
2990
+ children: f.value.toLocaleString()
2991
+ }
2992
+ )
2993
+ ] }, Y);
2994
+ })
2995
+ ] }) });
2996
+ };
2997
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2998
+ "div",
2999
+ {
3000
+ className: `nice-drilldown-chart ${y ? `animating ${B}` : ""} ${i || ""}`,
3001
+ style: { width: v, ...d },
3002
+ ...u,
3003
+ children: [
3004
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-drilldown-header", children: [
3005
+ D && x.length > 1 && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "nice-drilldown-back", onClick: P, children: "← Wstecz" }),
3006
+ A && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-drilldown-breadcrumbs", children: G.map((n, H) => /* @__PURE__ */ jsxRuntime.jsxs(_e.Fragment, { children: [
3007
+ H > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-drilldown-separator", children: "/" }),
3008
+ /* @__PURE__ */ jsxRuntime.jsx(
3009
+ "span",
3010
+ {
3011
+ className: `nice-drilldown-crumb ${H === G.length - 1 ? "active" : ""}`,
3012
+ onClick: () => {
3013
+ if (H < G.length - 1) {
3014
+ const F = x.slice(0, H + 1);
3015
+ b(F), g(F[F.length - 1]);
3016
+ }
3017
+ },
3018
+ children: n
3019
+ }
3020
+ )
3021
+ ] }, H)) })
3022
+ ] }),
3023
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-drilldown-content", style: { height: m - 40 }, children: [
3024
+ c === "bar" && Q(),
3025
+ c === "pie" && q(),
3026
+ c === "column" && J()
3027
+ ] }),
3028
+ M && _ && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-drilldown-legend", children: _.data.map((n, H) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-drilldown-legend-item", children: [
3029
+ /* @__PURE__ */ jsxRuntime.jsx(
3030
+ "span",
3031
+ {
3032
+ className: "nice-drilldown-legend-color",
3033
+ style: { backgroundColor: n.color || z[H % z.length] }
3034
+ }
3035
+ ),
3036
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-drilldown-legend-label", children: n.label || `Item ${H + 1}` })
3037
+ ] }, H)) }),
3038
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
3039
+ .nice-drilldown-chart {
3040
+ font-family: system-ui, -apple-system, sans-serif;
3041
+ background: white;
3042
+ border-radius: 8px;
3043
+ overflow: hidden;
3044
+ }
3045
+
3046
+ .nice-drilldown-header {
3047
+ display: flex;
3048
+ align-items: center;
3049
+ gap: 12px;
3050
+ padding: 12px 16px;
3051
+ border-bottom: 1px solid var(--border-color, #e5e7eb);
3052
+ min-height: 40px;
3053
+ }
3054
+
3055
+ .nice-drilldown-back {
3056
+ background: #f3f4f6;
3057
+ border: none;
3058
+ padding: 6px 12px;
3059
+ border-radius: 6px;
3060
+ cursor: pointer;
3061
+ font-size: 13px;
3062
+ color: #374151;
3063
+ transition: background 0.2s;
3064
+ }
3065
+
3066
+ .nice-drilldown-back:hover {
3067
+ background: #e5e7eb;
3068
+ }
3069
+
3070
+ .nice-drilldown-breadcrumbs {
3071
+ display: flex;
3072
+ align-items: center;
3073
+ gap: 4px;
3074
+ font-size: 13px;
3075
+ }
3076
+
3077
+ .nice-drilldown-separator {
3078
+ color: #9ca3af;
3079
+ }
3080
+
3081
+ .nice-drilldown-crumb {
3082
+ color: #6b7280;
3083
+ cursor: pointer;
3084
+ }
3085
+
3086
+ .nice-drilldown-crumb:hover:not(.active) {
3087
+ color: #3b82f6;
3088
+ }
3089
+
3090
+ .nice-drilldown-crumb.active {
3091
+ color: #111827;
3092
+ font-weight: 500;
3093
+ cursor: default;
3094
+ }
3095
+
3096
+ .nice-drilldown-content {
3097
+ padding: 16px;
3098
+ transition: opacity 0.15s, transform 0.15s;
3099
+ }
3100
+
3101
+ .nice-drilldown-chart.animating .nice-drilldown-content {
3102
+ opacity: 0;
3103
+ }
3104
+
3105
+ .nice-drilldown-chart.animating.in .nice-drilldown-content {
3106
+ transform: translateX(20px);
3107
+ }
3108
+
3109
+ .nice-drilldown-chart.animating.out .nice-drilldown-content {
3110
+ transform: translateX(-20px);
3111
+ }
3112
+
3113
+ .nice-drilldown-bars {
3114
+ display: flex;
3115
+ flex-direction: column;
3116
+ gap: 8px;
3117
+ }
3118
+
3119
+ .nice-drilldown-bar-row {
3120
+ display: flex;
3121
+ align-items: center;
3122
+ gap: 12px;
3123
+ cursor: pointer;
3124
+ padding: 4px 8px;
3125
+ margin: -4px -8px;
3126
+ border-radius: 6px;
3127
+ transition: background 0.2s;
3128
+ }
3129
+
3130
+ .nice-drilldown-bar-row:hover {
3131
+ background: #f9fafb;
3132
+ }
3133
+
3134
+ .nice-drilldown-bar-label {
3135
+ width: 120px;
3136
+ font-size: 13px;
3137
+ color: #374151;
3138
+ overflow: hidden;
3139
+ text-overflow: ellipsis;
3140
+ white-space: nowrap;
3141
+ }
3142
+
3143
+ .nice-drilldown-bar-track {
3144
+ flex: 1;
3145
+ background: #f3f4f6;
3146
+ border-radius: 6px;
3147
+ overflow: hidden;
3148
+ }
3149
+
3150
+ .nice-drilldown-bar-fill {
3151
+ transition: width 0.3s ease;
3152
+ border-radius: 6px;
3153
+ }
3154
+
3155
+ .nice-drilldown-bar-value {
3156
+ width: 80px;
3157
+ text-align: right;
3158
+ font-size: 13px;
3159
+ font-weight: 500;
3160
+ color: #111827;
3161
+ }
3162
+
3163
+ .nice-drilldown-pie-slice {
3164
+ cursor: pointer;
3165
+ transition: transform 0.2s, opacity 0.2s;
3166
+ transform-origin: center;
3167
+ }
3168
+
3169
+ .nice-drilldown-pie-slice:hover {
3170
+ opacity: 0.85;
3171
+ transform: scale(1.02);
3172
+ }
3173
+
3174
+ .nice-drilldown-column-bar {
3175
+ cursor: pointer;
3176
+ transition: opacity 0.2s;
3177
+ }
3178
+
3179
+ .nice-drilldown-column-bar:hover {
3180
+ opacity: 0.8;
3181
+ }
3182
+
3183
+ .nice-drilldown-legend {
3184
+ display: flex;
3185
+ flex-wrap: wrap;
3186
+ gap: 16px;
3187
+ padding: 12px 16px;
3188
+ border-top: 1px solid var(--border-color, #e5e7eb);
3189
+ }
3190
+
3191
+ .nice-drilldown-legend-item {
3192
+ display: flex;
3193
+ align-items: center;
3194
+ gap: 6px;
3195
+ }
3196
+
3197
+ .nice-drilldown-legend-color {
3198
+ width: 12px;
3199
+ height: 12px;
3200
+ border-radius: 3px;
3201
+ }
3202
+
3203
+ .nice-drilldown-legend-label {
3204
+ font-size: 12px;
3205
+ color: #6b7280;
3206
+ }
3207
+ ` })
3208
+ ]
3209
+ }
3210
+ );
3211
+ }
3212
+ );
3213
+ nt.displayName = "NiceDrillDownChart";
3214
+ const rt = _e.forwardRef(
3215
+ (t, o) => {
3216
+ const {
3217
+ initialData: s,
3218
+ data: l,
3219
+ maxPoints: c = 60,
3220
+ updateInterval: v = 1e3,
3221
+ fetchData: m,
3222
+ width: A = 600,
3223
+ height: D = 200,
3224
+ chartType: w = "line",
3225
+ color: p = "var(--color-primary, #3b82f6)",
3226
+ showGrid: k = true,
3227
+ showTimeAxis: z = true,
3228
+ showCurrentValue: C = true,
3229
+ title: M,
3230
+ valueFormatter: i = (L) => L.toFixed(2),
3231
+ timeFormatter: d = (L) => new Date(L).toLocaleTimeString(),
3232
+ onDataUpdate: u,
3233
+ paused: S,
3234
+ className: g,
3235
+ style: x,
3236
+ ...b
3237
+ } = t, [y, h] = _e.useState(s ?? l ?? []), [B, a] = _e.useState(S || false), _ = _e.useRef();
3238
+ _e.useEffect(() => {
3239
+ S !== void 0 && a(S);
3240
+ }, [S]), _e.useEffect(() => {
3241
+ if (B || !m)
3242
+ return;
3243
+ const L = async () => {
3244
+ try {
3245
+ const X = await m();
3246
+ h((ne) => {
3247
+ const ue = [...ne, X].slice(-c);
3248
+ return u?.(ue), ue;
3249
+ });
3250
+ } catch (X) {
3251
+ console.error("Failed to fetch realtime data:", X);
3252
+ }
3253
+ };
3254
+ return _.current = setInterval(L, v), () => {
3255
+ _.current && clearInterval(_.current);
3256
+ };
3257
+ }, [B, m, v, c, u]);
3258
+ const I = _e.useCallback(
3259
+ (L) => {
3260
+ h((X) => {
3261
+ const ne = [...X, L].slice(-c);
3262
+ return u?.(ne), ne;
3263
+ });
3264
+ },
3265
+ [c, u]
3266
+ ), P = _e.useCallback(() => {
3267
+ h([]), u?.([]);
3268
+ }, [u]), Z = _e.useCallback(() => a(true), []), U = _e.useCallback(() => a(false), []);
3269
+ _e.useImperativeHandle(
3270
+ o,
3271
+ () => ({
3272
+ addDataPoint: I,
3273
+ clearData: P,
3274
+ pause: Z,
3275
+ resume: U,
3276
+ getData: () => y
3277
+ }),
3278
+ [I, P, y]
3279
+ );
3280
+ const V = { top: 20, right: 60, bottom: z ? 40 : 20, left: 50 }, G = A - V.left - V.right, Q = D - V.top - V.bottom, q = y.map((L) => L.value), J = q.length ? Math.min(...q) : 0, n = q.length ? Math.max(...q) : 100, F = (n - J || 1) * 0.1, W = J - F, Y = n + F - W, j = (L) => {
3281
+ const X = m ? c - 1 : Math.max(1, y.length - 1);
3282
+ return V.left + L / X * G;
3283
+ }, ee = (L) => V.top + Q - (L - W) / Y * Q, O = y.map((L, X) => `${j(X)},${ee(L.value)}`).join(" "), te = y.length > 0 ? `M ${j(0)},${V.top + Q} L ${O} L ${j(y.length - 1)},${V.top + Q} Z` : "", pe = y.length > 0 ? y[y.length - 1].value : null;
3284
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3285
+ "div",
3286
+ {
3287
+ className: `nice-realtime-chart ${g || ""}`,
3288
+ style: { width: A, ...x },
3289
+ ...b,
3290
+ children: [
3291
+ M && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-realtime-header", children: [
3292
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-realtime-title", children: M }),
3293
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-realtime-controls", children: [
3294
+ /* @__PURE__ */ jsxRuntime.jsx(
3295
+ "button",
3296
+ {
3297
+ className: `nice-realtime-btn ${B ? "paused" : ""}`,
3298
+ onClick: () => a(!B),
3299
+ children: B ? "▶️" : "⏸️"
3300
+ }
3301
+ ),
3302
+ C && pe !== null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-realtime-value", children: i(pe) })
3303
+ ] })
3304
+ ] }),
3305
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: A, height: D, className: "nice-realtime-svg", children: [
3306
+ k && /* @__PURE__ */ jsxRuntime.jsx("g", { className: "nice-realtime-grid", children: [0, 0.25, 0.5, 0.75, 1].map((L, X) => {
3307
+ const ne = V.top + Q * (1 - L), ue = W + Y * L;
3308
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
3309
+ /* @__PURE__ */ jsxRuntime.jsx(
3310
+ "line",
3311
+ {
3312
+ x1: V.left,
3313
+ y1: ne,
3314
+ x2: A - V.right,
3315
+ y2: ne,
3316
+ stroke: "#e5e7eb",
3317
+ strokeDasharray: L === 0 ? void 0 : "3"
3318
+ }
3319
+ ),
3320
+ /* @__PURE__ */ jsxRuntime.jsx(
3321
+ "text",
3322
+ {
3323
+ x: V.left - 8,
3324
+ y: ne,
3325
+ textAnchor: "end",
3326
+ dominantBaseline: "middle",
3327
+ fontSize: "10",
3328
+ fill: "#6b7280",
3329
+ children: i(ue)
3330
+ }
3331
+ )
3332
+ ] }, X);
3333
+ }) }),
3334
+ w === "area" && y.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("path", { d: te, fill: p, fillOpacity: 0.2 }),
3335
+ y.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(
3336
+ "polyline",
3337
+ {
3338
+ points: O,
3339
+ fill: "none",
3340
+ stroke: p,
3341
+ strokeWidth: 2,
3342
+ strokeLinecap: "round",
3343
+ strokeLinejoin: "round"
3344
+ }
3345
+ ),
3346
+ y.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
3347
+ "circle",
3348
+ {
3349
+ cx: j(y.length - 1),
3350
+ cy: ee(y[y.length - 1].value),
3351
+ r: 4,
3352
+ fill: p,
3353
+ className: "nice-realtime-point"
3354
+ }
3355
+ ),
3356
+ z && y.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("g", { className: "nice-realtime-time-axis", children: [0, Math.floor(y.length / 2), y.length - 1].filter((L) => y[L]).map((L) => /* @__PURE__ */ jsxRuntime.jsx(
3357
+ "text",
3358
+ {
3359
+ x: j(L),
3360
+ y: D - 8,
3361
+ textAnchor: "middle",
3362
+ fontSize: "10",
3363
+ fill: "#6b7280",
3364
+ children: d(y[L].timestamp)
3365
+ },
3366
+ L
3367
+ )) })
3368
+ ] }),
3369
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `nice-realtime-status ${B ? "paused" : "live"}`, children: [
3370
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-realtime-status-dot" }),
3371
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: B ? "Wstrzymano" : "Na żywo" })
3372
+ ] }),
3373
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
3374
+ .nice-realtime-chart {
3375
+ font-family: system-ui, -apple-system, sans-serif;
3376
+ background: white;
3377
+ border-radius: 8px;
3378
+ position: relative;
3379
+ }
3380
+
3381
+ .nice-realtime-header {
3382
+ display: flex;
3383
+ justify-content: space-between;
3384
+ align-items: center;
3385
+ padding: 12px 16px;
3386
+ border-bottom: 1px solid var(--border-color, #e5e7eb);
3387
+ }
3388
+
3389
+ .nice-realtime-title {
3390
+ font-size: 14px;
3391
+ font-weight: 600;
3392
+ color: #111827;
3393
+ }
3394
+
3395
+ .nice-realtime-controls {
3396
+ display: flex;
3397
+ align-items: center;
3398
+ gap: 12px;
3399
+ }
3400
+
3401
+ .nice-realtime-btn {
3402
+ background: none;
3403
+ border: none;
3404
+ cursor: pointer;
3405
+ font-size: 16px;
3406
+ padding: 4px;
3407
+ }
3408
+
3409
+ .nice-realtime-value {
3410
+ font-size: 18px;
3411
+ font-weight: 600;
3412
+ color: ${p};
3413
+ font-variant-numeric: tabular-nums;
3414
+ }
3415
+
3416
+ .nice-realtime-point {
3417
+ animation: realtime-pulse 1s ease-out infinite;
3418
+ }
3419
+
3420
+ @keyframes realtime-pulse {
3421
+ 0% { opacity: 1; transform: scale(1); }
3422
+ 50% { opacity: 0.5; transform: scale(1.5); }
3423
+ 100% { opacity: 1; transform: scale(1); }
3424
+ }
3425
+
3426
+ .nice-realtime-status {
3427
+ position: absolute;
3428
+ bottom: 8px;
3429
+ right: 8px;
3430
+ display: flex;
3431
+ align-items: center;
3432
+ gap: 6px;
3433
+ font-size: 11px;
3434
+ color: #6b7280;
3435
+ }
3436
+
3437
+ .nice-realtime-status-dot {
3438
+ width: 8px;
3439
+ height: 8px;
3440
+ border-radius: 50%;
3441
+ background: #22c55e;
3442
+ }
3443
+
3444
+ .nice-realtime-status.paused .nice-realtime-status-dot {
3445
+ background: #f59e0b;
3446
+ }
3447
+
3448
+ .nice-realtime-status.live .nice-realtime-status-dot {
3449
+ animation: live-pulse 2s ease-in-out infinite;
3450
+ }
3451
+
3452
+ @keyframes live-pulse {
3453
+ 0%, 100% { opacity: 1; }
3454
+ 50% { opacity: 0.4; }
3455
+ }
3456
+ ` })
3457
+ ]
3458
+ }
3459
+ );
3460
+ }
3461
+ );
3462
+ rt.displayName = "NiceRealtimeChart";
3463
+ const at = _e.forwardRef(
3464
+ ({
3465
+ data: t,
3466
+ renderNode: o,
3467
+ selectable: s,
3468
+ selectedKey: l,
3469
+ onSelect: c,
3470
+ direction: v = "top-down",
3471
+ collapsible: m = true,
3472
+ className: A,
3473
+ style: D,
3474
+ id: w
3475
+ }, p) => {
3476
+ const k = coreDa43qPO.b(w), [z, C] = _e.useState(/* @__PURE__ */ new Set()), M = _e.useCallback((u) => {
3477
+ C((S) => {
3478
+ const g = new Set(S);
3479
+ return g.has(u) ? g.delete(u) : g.add(u), g;
3480
+ });
3481
+ }, []), i = _e.useCallback(
3482
+ (u) => {
3483
+ s && c?.(u);
3484
+ },
3485
+ [s, c]
3486
+ ), d = _e.useCallback(
3487
+ (u) => {
3488
+ const S = z.has(u.key), g = u.children && u.children.length > 0;
3489
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "nice-org-chart__item", children: [
3490
+ /* @__PURE__ */ jsxRuntime.jsxs(
3491
+ "div",
3492
+ {
3493
+ className: `nice-org-chart__node${l === u.key ? " nice-org-chart__node--selected" : ""}`,
3494
+ onClick: () => i(u.key),
3495
+ role: s ? "button" : void 0,
3496
+ children: [
3497
+ o ? o(u) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: u.label }),
3498
+ m && g && /* @__PURE__ */ jsxRuntime.jsx(
3499
+ "button",
3500
+ {
3501
+ type: "button",
3502
+ className: "nice-org-chart__toggle",
3503
+ onClick: (x) => {
3504
+ x.stopPropagation(), M(u.key);
3505
+ },
3506
+ "aria-label": S ? "Expand" : "Collapse",
3507
+ children: S ? "+" : "−"
3508
+ }
3509
+ )
3510
+ ]
3511
+ }
3512
+ ),
3513
+ g && !S && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "nice-org-chart__children", children: u.children.map((x) => d(x)) })
3514
+ ] }, u.key);
3515
+ },
3516
+ [z, l, o, s, m, i, M]
3517
+ );
3518
+ return /* @__PURE__ */ jsxRuntime.jsx(
3519
+ "div",
3520
+ {
3521
+ ref: p,
3522
+ id: k,
3523
+ className: `nice-org-chart nice-org-chart--${v} ${A || ""}`,
3524
+ style: D,
3525
+ children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "nice-org-chart__root", children: d(t) })
3526
+ }
3527
+ );
3528
+ }
3529
+ );
3530
+ at.displayName = "NiceOrganizationChart";
3531
+ function ct(t, o, s) {
3532
+ const l = (C) => {
3533
+ const M = C.replace("#", "");
3534
+ return [
3535
+ parseInt(M.slice(0, 2), 16),
3536
+ parseInt(M.slice(2, 4), 16),
3537
+ parseInt(M.slice(4, 6), 16)
3538
+ ];
3539
+ }, [c, v, m] = l(t), [A, D, w] = l(o), p = Math.round(c + (A - c) * s), k = Math.round(v + (D - v) * s), z = Math.round(m + (w - m) * s);
3540
+ return `rgb(${p},${k},${z})`;
3541
+ }
3542
+ const ot = _e.forwardRef(
3543
+ ({
3544
+ data: t,
3545
+ xLabels: o,
3546
+ yLabels: s,
3547
+ colors: l = ["#e0f2fe", "var(--color-primary-active, #1d4ed8)"],
3548
+ onCellClick: c,
3549
+ cellSize: v = 40,
3550
+ showValues: m = true,
3551
+ className: A,
3552
+ style: D,
3553
+ id: w
3554
+ }, p) => {
3555
+ const k = coreDa43qPO.b(w), { minVal: z, maxVal: C } = _e.useMemo(() => {
3556
+ let i = 1 / 0, d = -1 / 0;
3557
+ for (const u of t)
3558
+ for (const S of u)
3559
+ S < i && (i = S), S > d && (d = S);
3560
+ return { minVal: i, maxVal: d };
3561
+ }, [t]), M = _e.useCallback(
3562
+ (i) => C === z ? 0.5 : (i - z) / (C - z),
3563
+ [z, C]
3564
+ );
3565
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: p, id: k, className: `nice-heatmap ${A || ""}`, style: D, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "nice-heatmap__table", children: [
3566
+ o && /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
3567
+ s && /* @__PURE__ */ jsxRuntime.jsx("th", {}),
3568
+ o.map((i, d) => /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-heatmap__header", children: i }, d))
3569
+ ] }) }),
3570
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: t.map((i, d) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
3571
+ s && /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-heatmap__row-label", children: s[d] }),
3572
+ i.map((u, S) => /* @__PURE__ */ jsxRuntime.jsx(
3573
+ "td",
3574
+ {
3575
+ className: "nice-heatmap__cell",
3576
+ style: {
3577
+ background: ct(l[0], l[1], M(u)),
3578
+ width: v,
3579
+ height: v,
3580
+ textAlign: "center",
3581
+ color: M(u) > 0.6 ? "var(--bg-primary, #fff)" : "var(--bg-tertiary, #333)",
3582
+ cursor: c ? "pointer" : void 0
3583
+ },
3584
+ onClick: () => c?.(d, S, u),
3585
+ title: String(u),
3586
+ children: m ? u : ""
3587
+ },
3588
+ S
3589
+ ))
3590
+ ] }, d)) })
3591
+ ] }) });
3592
+ }
3593
+ );
3594
+ ot.displayName = "NiceHeatMap";
3595
+ function it(t, o) {
3596
+ const s = t.reduce((w, p) => w + p.value, 0);
3597
+ if (s === 0 || t.length === 0)
3598
+ return [];
3599
+ const l = [];
3600
+ let { x: c, y: v, w: m, h: A } = o;
3601
+ const D = [...t].sort((w, p) => p.value - w.value);
3602
+ for (const w of D) {
3603
+ const p = w.value / s;
3604
+ if (m >= A) {
3605
+ const k = m * p;
3606
+ l.push({ x: c, y: v, w: k, h: A, node: w }), c += k, m -= k;
3607
+ } else {
3608
+ const k = A * p;
3609
+ l.push({ x: c, y: v, w: m, h: k, node: w }), v += k, A -= k;
3610
+ }
3611
+ }
3612
+ return l;
3613
+ }
3614
+ const st = [
3615
+ "var(--color-primary, #3b82f6)",
3616
+ "var(--color-success, #10b981)",
3617
+ "var(--color-warning, #f59e0b)",
3618
+ "var(--color-error, #ef4444)",
3619
+ "var(--color-accent, #8b5cf6)",
3620
+ "var(--color-info, #06b6d4)",
3621
+ "var(--color-accent-pink, #ec4899)",
3622
+ "#84cc16"
3623
+ ], Fe = _e.forwardRef(
3624
+ ({ data: t, width: o = 600, height: s = 400, onNodeClick: l, colors: c = st, className: v, style: m, id: A }, D) => {
3625
+ const w = coreDa43qPO.b(A), p = _e.useMemo(() => {
3626
+ const k = t.children ?? [t];
3627
+ return it(k, { x: 0, y: 0, w: o, h: s });
3628
+ }, [t, o, s]);
3629
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: D, id: w, className: `nice-treemap ${v || ""}`, style: m, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: o, height: s, className: "nice-treemap__svg", children: p.map((k, z) => /* @__PURE__ */ jsxRuntime.jsxs(
3630
+ "g",
3631
+ {
3632
+ onClick: () => l?.(k.node),
3633
+ style: { cursor: l ? "pointer" : void 0 },
3634
+ children: [
3635
+ /* @__PURE__ */ jsxRuntime.jsx(
3636
+ "rect",
3637
+ {
3638
+ x: k.x,
3639
+ y: k.y,
3640
+ width: Math.max(k.w - 1, 0),
3641
+ height: Math.max(k.h - 1, 0),
3642
+ fill: k.node.color ?? c[z % c.length],
3643
+ rx: 2
3644
+ }
3645
+ ),
3646
+ k.w > 40 && k.h > 20 && /* @__PURE__ */ jsxRuntime.jsx(
3647
+ "text",
3648
+ {
3649
+ x: k.x + k.w / 2,
3650
+ y: k.y + k.h / 2,
3651
+ textAnchor: "middle",
3652
+ dominantBaseline: "central",
3653
+ fill: "#fff",
3654
+ fontSize: Math.min(12, k.w / 6),
3655
+ className: "nice-treemap__label",
3656
+ children: k.node.label
3657
+ }
3658
+ )
3659
+ ]
3660
+ },
3661
+ k.node.key
3662
+ )) }) });
3663
+ }
3664
+ );
3665
+ Fe.displayName = "NiceTreeMap";
3666
+ const lt = _e.forwardRef(
3667
+ ({
3668
+ data: t,
3669
+ type: o = "candlestick",
3670
+ showVolume: s = true,
3671
+ width: l = 800,
3672
+ height: c = 400,
3673
+ bullColor: v = "var(--color-success, #22c55e)",
3674
+ bearColor: m = "var(--color-error, #ef4444)",
3675
+ className: A,
3676
+ style: D,
3677
+ id: w
3678
+ }, p) => {
3679
+ const k = coreDa43qPO.b(w), z = { top: 20, right: 20, bottom: s ? 80 : 30, left: 60 }, C = l - z.left - z.right, M = s ? 50 : 0, i = c - z.top - z.bottom - M, { minP: d, maxP: u, maxVol: S } = _e.useMemo(() => {
3680
+ let h = 1 / 0, B = -1 / 0, a = 0;
3681
+ for (const _ of t)
3682
+ _.low < h && (h = _.low), _.high > B && (B = _.high), _.volume && _.volume > a && (a = _.volume);
3683
+ return { minP: h, maxP: B, maxVol: a };
3684
+ }, [t]), g = Math.max(1, C / t.length * 0.7), x = (h) => z.left + (h + 0.5) * (C / t.length), b = (h) => z.top + i - (h - d) / (u - d || 1) * i, y = (h) => c - z.bottom - M + M * (1 - h / (S || 1));
3685
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: p, id: k, className: `nice-stock-chart ${A || ""}`, style: D, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: l, height: c, className: "nice-stock-chart__svg", children: [
3686
+ [0, 0.25, 0.5, 0.75, 1].map((h) => {
3687
+ const B = d + h * (u - d);
3688
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
3689
+ /* @__PURE__ */ jsxRuntime.jsx(
3690
+ "line",
3691
+ {
3692
+ x1: z.left,
3693
+ x2: l - z.right,
3694
+ y1: b(B),
3695
+ y2: b(B),
3696
+ stroke: "#e5e7eb",
3697
+ strokeDasharray: "2,2"
3698
+ }
3699
+ ),
3700
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: z.left - 4, y: b(B) + 4, textAnchor: "end", fontSize: 10, fill: "#888", children: B.toFixed(2) })
3701
+ ] }, h);
3702
+ }),
3703
+ o === "line" ? /* @__PURE__ */ jsxRuntime.jsx(
3704
+ "polyline",
3705
+ {
3706
+ points: t.map((h, B) => `${x(B)},${b(h.close)}`).join(" "),
3707
+ fill: "none",
3708
+ stroke: v,
3709
+ strokeWidth: 1.5
3710
+ }
3711
+ ) : t.map((h, B) => {
3712
+ const a = h.close >= h.open, _ = a ? v : m, I = x(B);
3713
+ if (o === "ohlc")
3714
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
3715
+ /* @__PURE__ */ jsxRuntime.jsx(
3716
+ "line",
3717
+ {
3718
+ x1: I,
3719
+ x2: I,
3720
+ y1: b(h.high),
3721
+ y2: b(h.low),
3722
+ stroke: _,
3723
+ strokeWidth: 1
3724
+ }
3725
+ ),
3726
+ /* @__PURE__ */ jsxRuntime.jsx(
3727
+ "line",
3728
+ {
3729
+ x1: I - g / 2,
3730
+ x2: I,
3731
+ y1: b(h.open),
3732
+ y2: b(h.open),
3733
+ stroke: _,
3734
+ strokeWidth: 1.5
3735
+ }
3736
+ ),
3737
+ /* @__PURE__ */ jsxRuntime.jsx(
3738
+ "line",
3739
+ {
3740
+ x1: I,
3741
+ x2: I + g / 2,
3742
+ y1: b(h.close),
3743
+ y2: b(h.close),
3744
+ stroke: _,
3745
+ strokeWidth: 1.5
3746
+ }
3747
+ )
3748
+ ] }, B);
3749
+ const P = b(Math.max(h.open, h.close)), Z = b(Math.min(h.open, h.close));
3750
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
3751
+ /* @__PURE__ */ jsxRuntime.jsx(
3752
+ "line",
3753
+ {
3754
+ x1: I,
3755
+ x2: I,
3756
+ y1: b(h.high),
3757
+ y2: b(h.low),
3758
+ stroke: _,
3759
+ strokeWidth: 1
3760
+ }
3761
+ ),
3762
+ /* @__PURE__ */ jsxRuntime.jsx(
3763
+ "rect",
3764
+ {
3765
+ x: I - g / 2,
3766
+ y: P,
3767
+ width: g,
3768
+ height: Math.max(Z - P, 1),
3769
+ fill: a ? "transparent" : _,
3770
+ stroke: _,
3771
+ strokeWidth: 1
3772
+ }
3773
+ )
3774
+ ] }, B);
3775
+ }),
3776
+ s && t.map((h, B) => {
3777
+ if (!h.volume)
3778
+ return null;
3779
+ const a = h.close >= h.open;
3780
+ return /* @__PURE__ */ jsxRuntime.jsx(
3781
+ "rect",
3782
+ {
3783
+ x: x(B) - g / 2,
3784
+ y: y(h.volume),
3785
+ width: g,
3786
+ height: c - z.bottom - y(h.volume),
3787
+ fill: a ? v : m,
3788
+ opacity: 0.3
3789
+ },
3790
+ `v${B}`
3791
+ );
3792
+ }),
3793
+ t.map((h, B) => B % Math.max(1, Math.floor(t.length / 8)) !== 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(
3794
+ "text",
3795
+ {
3796
+ x: x(B),
3797
+ y: c - z.bottom + M + 14,
3798
+ textAnchor: "middle",
3799
+ fontSize: 9,
3800
+ fill: "#888",
3801
+ children: h.date
3802
+ },
3803
+ `l${B}`
3804
+ ))
3805
+ ] }) });
3806
+ }
3807
+ );
3808
+ lt.displayName = "NiceStockChart";
3809
+
3810
+ exports.A = ft;
3811
+ exports.B = kt;
3812
+ exports.C = ve;
3813
+ exports.D = Ct;
3814
+ exports.N = et;
3815
+ exports.a = St;
3816
+ exports.b = at;
3817
+ exports.c = lt;
3818
+ exports.d = Fe;
3819
+ exports.e = ot;
3820
+ exports.f = Qe;
3821
+ exports.g = Nt;
3822
+ exports.h = Mt;
3823
+ exports.i = $t;
3824
+ exports.j = wt;
3825
+ exports.k = _t;
3826
+ exports.l = bt;
3827
+ exports.m = vt;
3828
+ exports.n = yt;
3829
+ exports.o = Re;
3830
+ exports.q = nt;
3831
+ exports.s = Je;
3832
+ exports.u = rt;
3833
+ //# sourceMappingURL=charts-BAS21jkC.js.map