serverside_pivot 0.0.0-stage → 0.0.90

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 (178) hide show
  1. package/README.md +165 -3
  2. package/dist/react/chunks/ContextMenu-Bt5_3bmD.mjs +192 -0
  3. package/dist/react/chunks/DetailDrawer-DtsvdhO4.mjs +37 -0
  4. package/dist/react/chunks/DetailSidePanel-v_7iU73g.mjs +36 -0
  5. package/dist/react/chunks/DetailSurfaceContent-BOXVc58A.mjs +200 -0
  6. package/dist/react/chunks/ECharts2dRenderer-BGL_NVGU.mjs +3299 -0
  7. package/dist/react/chunks/ECharts3dRenderer-BF2YWlsP.mjs +21573 -0
  8. package/dist/react/chunks/EditSidePanel-CuvtsKTK.mjs +298 -0
  9. package/dist/react/chunks/InlineDetailPanel-Bmtlu3lc.mjs +41 -0
  10. package/dist/react/chunks/PivotCharts-CA3_0bB8.mjs +4252 -0
  11. package/dist/react/chunks/ReportEditor-DYBr0HDz.mjs +1726 -0
  12. package/dist/react/chunks/SidebarPanel-B64bhrUW.mjs +3339 -0
  13. package/dist/react/chunks/SparklineDetailGraph-90WjWkhg.mjs +200 -0
  14. package/dist/react/chunks/installCanvasRenderer-C8gE9ttC.mjs +21281 -0
  15. package/dist/react/chunks/react-52jgz-em.mjs +25301 -0
  16. package/dist/react/chunks/xlsx.mini.min-BwwnBtoK.mjs +7996 -0
  17. package/dist/react/components/Charts/ChartRenderers.d.ts +73 -0
  18. package/dist/react/components/Charts/ChartWorkspace.d.ts +38 -0
  19. package/dist/react/components/Charts/ECharts2dRenderer.d.ts +5 -0
  20. package/dist/react/components/Charts/ECharts3dRenderer.d.ts +6 -0
  21. package/dist/react/components/Charts/PivotCharts.d.ts +9 -0
  22. package/dist/react/components/Charts/chartEnhancements.d.ts +66 -0
  23. package/dist/react/components/Charts/chartExportPresentation.d.ts +19 -0
  24. package/dist/react/components/Charts/chartMath.d.ts +4 -0
  25. package/dist/react/components/Charts/useChartExportMenu.d.ts +12 -0
  26. package/dist/react/components/DashTanstackPivot.react.d.ts +365 -0
  27. package/dist/react/components/Filters/ColumnFilter.d.ts +13 -0
  28. package/dist/react/components/Filters/DateRangeFilter.d.ts +8 -0
  29. package/dist/react/components/Filters/FilterPopover.d.ts +14 -0
  30. package/dist/react/components/Filters/MultiSelectFilter.d.ts +12 -0
  31. package/dist/react/components/Filters/NumericRangeFilter.d.ts +8 -0
  32. package/dist/react/components/Notification.d.ts +7 -0
  33. package/dist/react/components/PivotAppBar.d.ts +2 -0
  34. package/dist/react/components/PivotErrorBoundary.d.ts +15 -0
  35. package/dist/react/components/PivotSmallComponents.d.ts +6 -0
  36. package/dist/react/components/PivotWorkspace.d.ts +19 -0
  37. package/dist/react/components/PivotWorkspaceCanvas.d.ts +5 -0
  38. package/dist/react/components/PivotWorkspaceControls.d.ts +12 -0
  39. package/dist/react/components/PivotWorkspaceShell.d.ts +12 -0
  40. package/dist/react/components/RuntimeDataError.d.ts +7 -0
  41. package/dist/react/components/Sidebar/ColumnTreeItem.d.ts +14 -0
  42. package/dist/react/components/Sidebar/ReportEditor.d.ts +21 -0
  43. package/dist/react/components/Sidebar/SidebarFilterItem.d.ts +14 -0
  44. package/dist/react/components/Sidebar/SidebarPanel.d.ts +2 -0
  45. package/dist/react/components/Sidebar/ToolPanelSection.d.ts +14 -0
  46. package/dist/react/components/Sidebar/customCategoryUtils.d.ts +62 -0
  47. package/dist/react/components/Sidebar/formulaUtils.d.ts +22 -0
  48. package/dist/react/components/SkeletonRow.d.ts +6 -0
  49. package/dist/react/components/Table/ContextMenu.d.ts +9 -0
  50. package/dist/react/components/Table/DetailDrawer.d.ts +12 -0
  51. package/dist/react/components/Table/DetailSidePanel.d.ts +12 -0
  52. package/dist/react/components/Table/DetailSurfaceContent.d.ts +12 -0
  53. package/dist/react/components/Table/EditSidePanel.d.ts +21 -0
  54. package/dist/react/components/Table/EditableCell.d.ts +29 -0
  55. package/dist/react/components/Table/InlineDetailPanel.d.ts +14 -0
  56. package/dist/react/components/Table/PivotTableBody.d.ts +9 -0
  57. package/dist/react/components/Table/SparklineCell.d.ts +17 -0
  58. package/dist/react/components/Table/SparklineDetailGraph.d.ts +5 -0
  59. package/dist/react/components/Table/StatusBar.d.ts +8 -0
  60. package/dist/react/contexts/PivotConfigContext.d.ts +34 -0
  61. package/dist/react/contexts/PivotThemeContext.d.ts +7 -0
  62. package/dist/react/contexts/PivotValueDisplayContext.d.ts +10 -0
  63. package/dist/react/hooks/useCellInteraction.d.ts +31 -0
  64. package/dist/react/hooks/useChartState.d.ts +76 -0
  65. package/dist/react/hooks/useColumnDefs.d.ts +82 -0
  66. package/dist/react/hooks/useColumnVirtualizer.d.ts +30 -0
  67. package/dist/react/hooks/useDetailDrillThrough.d.ts +38 -0
  68. package/dist/react/hooks/useFilteredData.d.ts +2 -0
  69. package/dist/react/hooks/useFormatState.d.ts +44 -0
  70. package/dist/react/hooks/usePersistence.d.ts +5 -0
  71. package/dist/react/hooks/usePivotFieldInteractions.d.ts +28 -0
  72. package/dist/react/hooks/usePivotNormalization.d.ts +473 -0
  73. package/dist/react/hooks/usePivotRenderCounter.d.ts +1 -0
  74. package/dist/react/hooks/usePivotTransactions.d.ts +29 -0
  75. package/dist/react/hooks/useRenderHelpers.d.ts +85 -0
  76. package/dist/react/hooks/useReportMode.d.ts +32 -0
  77. package/dist/react/hooks/useRowCache.d.ts +19 -0
  78. package/dist/react/hooks/useRuntimeDataCommit.d.ts +26 -0
  79. package/dist/react/hooks/useRuntimeProfiling.d.ts +19 -0
  80. package/dist/react/hooks/useRuntimeTransport.d.ts +24 -0
  81. package/dist/react/hooks/useServerSideRowModel.d.ts +50 -0
  82. package/dist/react/hooks/useServerSideViewportController.d.ts +64 -0
  83. package/dist/react/hooks/useSidebarUI.d.ts +37 -0
  84. package/dist/react/hooks/useStickyStyles.d.ts +24 -0
  85. package/dist/react/index.mjs +8 -0
  86. package/dist/react/presentation/headerFormatting.d.ts +13 -0
  87. package/dist/react/presentation/safeCellContent.d.ts +16 -0
  88. package/dist/react/react.d.ts +7 -0
  89. package/dist/react/runtime/PivotRuntimeRoot.d.ts +7 -0
  90. package/dist/react/runtime/cellSelectionAnchor.d.ts +45 -0
  91. package/dist/react/runtime/createRuntimeCellPresentation.d.ts +7 -0
  92. package/dist/react/runtime/createRuntimeExportCommands.d.ts +77 -0
  93. package/dist/react/runtime/createRuntimeRowPinCommand.d.ts +9 -0
  94. package/dist/react/runtime/createWorkspacePresentation.d.ts +7 -0
  95. package/dist/react/runtime/displayColumnOrder.d.ts +4 -0
  96. package/dist/react/runtime/httpTransport.d.ts +65 -0
  97. package/dist/react/runtime/runtime-contract.generated.d.ts +48 -0
  98. package/dist/react/runtime/runtime-response-contract.generated.d.ts +34 -0
  99. package/dist/react/runtime/runtimeContract.d.ts +115 -0
  100. package/dist/react/runtime/runtimeDomains.d.ts +642 -0
  101. package/dist/react/runtime/runtimeDomains.type-test.d.ts +1 -0
  102. package/dist/react/runtime/runtimeResponseDedup.d.ts +36 -0
  103. package/dist/react/runtime/useChartWorkspacePresentation.d.ts +50 -0
  104. package/dist/react/runtime/useCommandRuntime.d.ts +3 -0
  105. package/dist/react/runtime/useCommandRuntimeStage.d.ts +1 -0
  106. package/dist/react/runtime/useCoreRuntime.d.ts +3 -0
  107. package/dist/react/runtime/useCoreRuntimeStage.d.ts +3 -0
  108. package/dist/react/runtime/useRuntimeCellSelection.d.ts +44 -0
  109. package/dist/react/runtime/useRuntimeChartCanvasCommands.d.ts +36 -0
  110. package/dist/react/runtime/useRuntimeChartCanvasResize.d.ts +13 -0
  111. package/dist/react/runtime/useRuntimeChartCanvasVerticalResize.d.ts +9 -0
  112. package/dist/react/runtime/useRuntimeChartDefinitionCommands.d.ts +14 -0
  113. package/dist/react/runtime/useRuntimeChartFloatingInteractions.d.ts +28 -0
  114. package/dist/react/runtime/useRuntimeChartModels.d.ts +69 -0
  115. package/dist/react/runtime/useRuntimeChartPanelSizing.d.ts +12 -0
  116. package/dist/react/runtime/useRuntimeChartRequestDispatch.d.ts +7 -0
  117. package/dist/react/runtime/useRuntimeClipboardExportPresentation.d.ts +159 -0
  118. package/dist/react/runtime/useRuntimeClipboardPaste.d.ts +7 -0
  119. package/dist/react/runtime/useRuntimeColorScalePresentation.d.ts +55 -0
  120. package/dist/react/runtime/useRuntimeColumnAutoSizing.d.ts +26 -0
  121. package/dist/react/runtime/useRuntimeColumnCommands.d.ts +22 -0
  122. package/dist/react/runtime/useRuntimeColumnMeasurement.d.ts +16 -0
  123. package/dist/react/runtime/useRuntimeDataRetry.d.ts +12 -0
  124. package/dist/react/runtime/useRuntimeDisplayNavigation.d.ts +17 -0
  125. package/dist/react/runtime/useRuntimeEditCellIdentity.d.ts +22 -0
  126. package/dist/react/runtime/useRuntimeEditChangeTracking.d.ts +28 -0
  127. package/dist/react/runtime/useRuntimeEditComparisonState.d.ts +35 -0
  128. package/dist/react/runtime/useRuntimeEditDispatch.d.ts +47 -0
  129. package/dist/react/runtime/useRuntimeEditOwnership.d.ts +32 -0
  130. package/dist/react/runtime/useRuntimeEditPresentation.d.ts +32 -0
  131. package/dist/react/runtime/useRuntimeEditStatePersistence.d.ts +28 -0
  132. package/dist/react/runtime/useRuntimeExportState.d.ts +20 -0
  133. package/dist/react/runtime/useRuntimeFilterPopover.d.ts +23 -0
  134. package/dist/react/runtime/useRuntimeLayoutHistory.d.ts +44 -0
  135. package/dist/react/runtime/useRuntimeOptimisticCellState.d.ts +27 -0
  136. package/dist/react/runtime/useRuntimeRequestSession.d.ts +79 -0
  137. package/dist/react/runtime/useRuntimeResponseLifecycle.d.ts +47 -0
  138. package/dist/react/runtime/useRuntimeResponsePostCommit.d.ts +15 -0
  139. package/dist/react/runtime/useRuntimeRowEditSessions.d.ts +28 -0
  140. package/dist/react/runtime/useRuntimeRowEditing.d.ts +18 -0
  141. package/dist/react/runtime/useRuntimeRowSelection.d.ts +14 -0
  142. package/dist/react/runtime/useRuntimeSelectionFormatting.d.ts +36 -0
  143. package/dist/react/runtime/useRuntimeStructuralSync.d.ts +62 -0
  144. package/dist/react/runtime/useRuntimeViewRestoreScroll.d.ts +9 -0
  145. package/dist/react/runtime/useRuntimeViewSnapshot.d.ts +203 -0
  146. package/dist/react/runtime/useRuntimeViewportTableData.d.ts +23 -0
  147. package/dist/react/runtime/useTransportRuntime.d.ts +12 -0
  148. package/dist/react/runtime/useViewportRuntime.d.ts +3 -0
  149. package/dist/react/runtime/useViewportRuntimeStage.d.ts +1 -0
  150. package/dist/react/runtime/useWorkspaceRuntime.d.ts +3 -0
  151. package/dist/react/runtime/useWorkspaceRuntimeStage.d.ts +1 -0
  152. package/dist/react/runtime/useWorkspaceStatusPresentation.d.ts +115 -0
  153. package/dist/react/runtime/workspaceViewModel.d.ts +7 -0
  154. package/dist/react/utils/Icons.d.ts +46 -0
  155. package/dist/react/utils/chartModelBuilders.d.ts +236 -0
  156. package/dist/react/utils/columnOrder.d.ts +12 -0
  157. package/dist/react/utils/dataBars.d.ts +7 -0
  158. package/dist/react/utils/domEvents.d.ts +1 -0
  159. package/dist/react/utils/editing.d.ts +47 -0
  160. package/dist/react/utils/exportUtils.d.ts +121 -0
  161. package/dist/react/utils/fieldPanelLayout.d.ts +61 -0
  162. package/dist/react/utils/filterOptions.d.ts +4 -0
  163. package/dist/react/utils/formatting.d.ts +1 -0
  164. package/dist/react/utils/helpers.d.ts +20 -0
  165. package/dist/react/utils/horizontalViewport.d.ts +12 -0
  166. package/dist/react/utils/layoutRows.d.ts +3 -0
  167. package/dist/react/utils/measureAxis.d.ts +22 -0
  168. package/dist/react/utils/pivotLayoutUtils.d.ts +2 -0
  169. package/dist/react/utils/pivotProfiler.d.ts +4 -0
  170. package/dist/react/utils/rawTableTsv.d.ts +21 -0
  171. package/dist/react/utils/reportEditorSelection.d.ts +23 -0
  172. package/dist/react/utils/rowSpanning.d.ts +6 -0
  173. package/dist/react/utils/savedReports.d.ts +7 -0
  174. package/dist/react/utils/sorting.d.ts +14 -0
  175. package/dist/react/utils/sparklineDetail.d.ts +8 -0
  176. package/dist/react/utils/sparklines.d.ts +78 -0
  177. package/dist/react/utils/styles.d.ts +957 -0
  178. package/package.json +89 -6
@@ -0,0 +1,4252 @@
1
+ import e, { useRef as Fe, useState as _, useLayoutEffect as Hr, useMemo as ot, useEffect as He, useCallback as je } from "react";
2
+ import { createPortal as un } from "react-dom";
3
+ import { C as or, r as Kr, c as pn, a as Wr, n as Yt, e as Wt, t as ge, l as dn, g as Ce, b as xn, d as Fr, f as fn, p as ur, h as Or, i as Yr, j as gr, k as Vr, m as zt, M as _r, o as Xr, q as zr, s as gn, I as mn, u as yn, v as bn, w as Zr, x as qr, y as lr, z as hn, A as vn, V as En, B as Qr, D as Jr, E as kn, F as mr, G as wn, H as Sn, J as Mn, K as An, L as jr, N as Cn, O as $n, P as Wn, Q as Gr, R as zn } from "./react-52jgz-em.mjs";
4
+ function Bn(t, n, o) {
5
+ const f = Math.min(n.width, Math.max(0, o.width - 16)), h = Math.max(0, o.height - 8 - t.bottom - 6), S = Math.max(0, t.top - 6 - 8), $ = n.height > h && S > h, R = $ ? S : h, C = Math.min(n.height, R);
6
+ return {
7
+ left: Math.max(8, Math.min(t.right - f, o.width - 8 - f)),
8
+ top: $ ? t.top - 6 - C : t.bottom + 6,
9
+ maxWidth: Math.max(0, o.width - 16),
10
+ maxHeight: R
11
+ };
12
+ }
13
+ function Ln(t, n) {
14
+ var $;
15
+ const o = Fe(null), i = Fe(null), [r, f] = _(null), h = ($ = o.current) == null ? void 0 : $.ownerDocument, S = (h == null ? void 0 : h.fullscreenElement) || (h == null ? void 0 : h.body);
16
+ return Hr(() => {
17
+ if (!t || !o.current || !i.current) return;
18
+ const R = o.current, C = i.current, O = R.ownerDocument, J = O.defaultView, K = () => f(Bn(
19
+ R.getBoundingClientRect(),
20
+ { width: C.offsetWidth, height: C.scrollHeight + 2 },
21
+ { width: O.documentElement.clientWidth, height: O.documentElement.clientHeight }
22
+ )), a = () => Array.from(C.querySelectorAll('[role="menuitem"]:not(:disabled)')), X = (F = !1) => {
23
+ n(!1), f(null), F && R.focus();
24
+ }, T = (F) => {
25
+ var ue;
26
+ const U = ((ue = F.composedPath) == null ? void 0 : ue.call(F)) || [];
27
+ [R, C].some((ne) => U.includes(ne) || ne.contains(F.target)) || X();
28
+ }, V = (F) => {
29
+ var U, ue;
30
+ if (F.key === "Escape")
31
+ F.preventDefault(), F.stopPropagation(), X(!0);
32
+ else if (["ArrowDown", "ArrowUp", "Home", "End"].includes(F.key)) {
33
+ if (!C.contains(F.target) && !((U = F.composedPath) != null && U.call(F).includes(R))) return;
34
+ F.preventDefault();
35
+ const ne = a(), ie = ne.indexOf(O.activeElement), pe = F.key === "Home" ? 0 : F.key === "End" ? ne.length - 1 : (ie + (F.key === "ArrowUp" ? -1 : 1) + ne.length) % ne.length;
36
+ (ue = ne[pe]) == null || ue.focus();
37
+ } else F.key === "Tab" && X(!0);
38
+ };
39
+ K(), O.addEventListener("mousedown", T, !0), O.addEventListener("keydown", V, !0), O.addEventListener("scroll", K, !0), J.addEventListener("resize", K);
40
+ const Y = typeof J.ResizeObserver == "function" ? new J.ResizeObserver(K) : null;
41
+ return Y == null || Y.observe(R), Y == null || Y.observe(C), () => {
42
+ O.removeEventListener("mousedown", T, !0), O.removeEventListener("keydown", V, !0), O.removeEventListener("scroll", K, !0), J.removeEventListener("resize", K), Y == null || Y.disconnect();
43
+ };
44
+ }, [t, S, n]), Hr(() => {
45
+ var R, C;
46
+ t && r && ((C = (R = i.current) == null ? void 0 : R.querySelector('[role="menuitem"]:not(:disabled)')) == null || C.focus());
47
+ }, [t, !!r]), { anchorRef: o, menuRef: i, position: r, portalTarget: S };
48
+ }
49
+ const Lr = [
50
+ { value: "solid", label: "Solid", dash: "none" },
51
+ { value: "dashed", label: "Dashed", dash: "8 4" },
52
+ { value: "dotted", label: "Dotted", dash: "2 4" },
53
+ { value: "dot-dash", label: "Dot-Dash", dash: "8 4 2 4" }
54
+ ], yr = (t) => {
55
+ const n = Lr.find((o) => o.value === t);
56
+ return n && n.dash !== "none" ? n.dash : void 0;
57
+ }, Br = [
58
+ { value: "vertical", label: "Vertical", x1: "0", y1: "0", x2: "0", y2: "1" },
59
+ { value: "horizontal", label: "Horizontal", x1: "0", y1: "0", x2: "1", y2: "0" },
60
+ { value: "diagonal", label: "Diagonal", x1: "0", y1: "0", x2: "1", y2: "1" }
61
+ ], Rn = (t, n) => {
62
+ const o = (Number(n) || 70) / 100;
63
+ return [
64
+ { offset: "0%", stopOpacity: String(Math.min(1, o + 0.2)) },
65
+ { offset: "100%", stopOpacity: String(o) }
66
+ ];
67
+ }, Dn = ["bottom", "top", "none"], Nn = ({ legendPosition: t, onChange: n, theme: o }) => {
68
+ const i = (r, f) => ({
69
+ border: `1px solid ${r === t ? o.primary : o.border}`,
70
+ background: r === t ? o.select : o.headerSubtleBg || o.hover,
71
+ color: r === t ? o.primary : o.text,
72
+ borderRadius: o.radiusSm || "8px",
73
+ padding: "5px 10px",
74
+ fontSize: "11px",
75
+ fontWeight: 700,
76
+ cursor: "pointer"
77
+ });
78
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "5px" } }, Dn.map((r) => /* @__PURE__ */ e.createElement("button", { key: r, type: "button", onClick: () => n(r), style: i(r) }, r.charAt(0).toUpperCase() + r.slice(1))));
79
+ }, Pn = [
80
+ { value: "none", label: "Natural" },
81
+ { value: "value_desc", label: "Val ↓" },
82
+ { value: "value_asc", label: "Val ↑" },
83
+ { value: "alpha_asc", label: "A→Z" },
84
+ { value: "alpha_desc", label: "Z→A" }
85
+ ], In = (t, n) => {
86
+ if (!Array.isArray(t) || n === "none" || !n) return t;
87
+ const o = [...t];
88
+ if (n === "alpha_asc") return o.sort((r, f) => String(r.name || "").localeCompare(String(f.name || "")));
89
+ if (n === "alpha_desc") return o.sort((r, f) => String(f.name || "").localeCompare(String(r.name || "")));
90
+ const i = (r) => (r.values || []).reduce((f, h) => f + (Number.isFinite(Number(h)) ? Number(h) : 0), 0);
91
+ return n === "value_desc" ? o.sort((r, f) => i(f) - i(r)) : n === "value_asc" ? o.sort((r, f) => i(r) - i(f)) : o;
92
+ }, Hn = ({ model: t, maxCategories: n, maxSeries: o, theme: i }) => {
93
+ const r = Array.isArray(t && t.categories) ? t.categories.length : 0, f = Array.isArray(t && t.series) ? t.series.length : 0, h = r >= n * 0.9, S = f >= o * 0.9, $ = r >= n, R = f >= o;
94
+ if (!h && !S) return null;
95
+ const C = (O) => ({
96
+ display: "inline-flex",
97
+ alignItems: "center",
98
+ gap: "4px",
99
+ padding: "3px 8px",
100
+ borderRadius: i.radiusSm || "8px",
101
+ fontSize: "10px",
102
+ fontWeight: 700,
103
+ background: O ? (i.danger || "#ef4444") + "22" : (i.warning || "#f59e0b") + "22",
104
+ color: O ? i.danger || "#ef4444" : i.warning || "#ca8a04",
105
+ border: `1px solid ${O ? i.danger || "#ef4444" : i.warning || "#f59e0b"}44`
106
+ });
107
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "5px", flexWrap: "wrap" } }, h && /* @__PURE__ */ e.createElement("span", { style: C($) }, $ ? "⚠ " : "○ ", r, "/", n, " categories"), S && /* @__PURE__ */ e.createElement("span", { style: C(R) }, R ? "⚠ " : "○ ", f, "/", o, " series"));
108
+ }, Fn = ({ series: t, lineDashStyles: n, onChange: o, seriesColors: i, paletteColors: r, getColorForIndex: f, theme: h, compactInputStyle: S }) => !Array.isArray(t) || t.length === 0 ? null : /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "5px" } }, t.slice(0, 16).map(($, R) => {
109
+ const C = i && i[$.name] || f(R, h, r), O = n && n[$.name] || "solid";
110
+ return /* @__PURE__ */ e.createElement("div", { key: $.name || R, style: { display: "flex", alignItems: "center", gap: "6px" } }, /* @__PURE__ */ e.createElement("span", { style: { width: "10px", height: "10px", borderRadius: "50%", background: C, flexShrink: 0 } }), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "11px", color: h.text, flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, $.name || `Series ${R + 1}`), /* @__PURE__ */ e.createElement(
111
+ "select",
112
+ {
113
+ value: O,
114
+ onChange: (J) => o({ ...n, [$.name]: J.target.value }),
115
+ style: { ...S, width: "82px", flexShrink: 0 }
116
+ },
117
+ Lr.map((J) => /* @__PURE__ */ e.createElement("option", { key: J.value, value: J.value }, J.label))
118
+ ));
119
+ })), On = ({ customColors: t, onChange: n, theme: o, compactInputStyle: i }) => {
120
+ const r = Array.isArray(t) && t.length > 0 ? t : ["#2563EB", "#F97316", "#0F766E", "#7C3AED", "#DC2626", "#0891B2"], f = ($, R) => {
121
+ const C = [...r];
122
+ C[$] = R, n(C);
123
+ }, h = () => n([...r, "#888888"]), S = ($) => n(r.filter((R, C) => C !== $));
124
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "5px" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px", alignItems: "center" } }, r.map(($, R) => /* @__PURE__ */ e.createElement("div", { key: R, style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "2px" } }, /* @__PURE__ */ e.createElement(
125
+ "input",
126
+ {
127
+ type: "color",
128
+ value: $,
129
+ onChange: (C) => f(R, C.target.value),
130
+ style: { width: "28px", height: "28px", padding: 0, border: `1px solid ${o.border}`, borderRadius: "4px", cursor: "pointer", background: "none" },
131
+ title: `Color ${R + 1}`
132
+ }
133
+ ), r.length > 2 && /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => S(R), style: { border: "none", background: "none", color: o.textSec, cursor: "pointer", fontSize: "9px", padding: 0, lineHeight: 1 } }, "✕"))), r.length < 12 && /* @__PURE__ */ e.createElement("button", { type: "button", onClick: h, style: { ...i, padding: "5px 8px", flexShrink: 0 } }, "+")));
134
+ }, ze = 16, Yn = ({ color: t }) => /* @__PURE__ */ e.createElement("svg", { width: ze, height: ze, viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ e.createElement("rect", { x: "1", y: "9", width: "4", height: "6", fill: t, opacity: "0.85", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "6", y: "5", width: "4", height: "10", fill: t, opacity: "0.85", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "11", y: "7", width: "4", height: "8", fill: t, opacity: "0.85", rx: "0.5" })), Vn = ({ color: t }) => /* @__PURE__ */ e.createElement("svg", { width: ze, height: ze, viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ e.createElement("polyline", { points: "1,13 5,7 9,10 15,3", stroke: t, strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ e.createElement("circle", { cx: "1", cy: "13", r: "1.4", fill: t }), /* @__PURE__ */ e.createElement("circle", { cx: "5", cy: "7", r: "1.4", fill: t }), /* @__PURE__ */ e.createElement("circle", { cx: "9", cy: "10", r: "1.4", fill: t }), /* @__PURE__ */ e.createElement("circle", { cx: "15", cy: "3", r: "1.4", fill: t })), _n = ({ color: t }) => /* @__PURE__ */ e.createElement("svg", { width: ze, height: ze, viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ e.createElement("path", { d: "M8,8 L8,1 A7,7 0 0,1 15,8 Z", fill: t, opacity: "0.9" }), /* @__PURE__ */ e.createElement("path", { d: "M8,8 L15,8 A7,7 0 0,1 6,15 Z", fill: t, opacity: "0.55" }), /* @__PURE__ */ e.createElement("path", { d: "M8,8 L6,15 A7,7 1 1,1 8,1 Z", fill: t, opacity: "0.3" })), Xn = ({ color: t }) => /* @__PURE__ */ e.createElement("svg", { width: ze, height: ze, viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ e.createElement("circle", { cx: "3", cy: "12", r: "1.8", fill: t, opacity: "0.85" }), /* @__PURE__ */ e.createElement("circle", { cx: "7", cy: "5", r: "1.8", fill: t, opacity: "0.85" }), /* @__PURE__ */ e.createElement("circle", { cx: "12", cy: "9", r: "1.8", fill: t, opacity: "0.85" }), /* @__PURE__ */ e.createElement("circle", { cx: "13", cy: "3", r: "1.8", fill: t, opacity: "0.85" }), /* @__PURE__ */ e.createElement("circle", { cx: "5", cy: "11", r: "1.8", fill: t, opacity: "0.85" })), jn = ({ color: t }) => /* @__PURE__ */ e.createElement("svg", { width: ze, height: ze, viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ e.createElement("rect", { x: "1", y: "9", width: "4", height: "6", fill: t, opacity: "0.5", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "6", y: "5", width: "4", height: "10", fill: t, opacity: "0.5", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "11", y: "8", width: "4", height: "7", fill: t, opacity: "0.5", rx: "0.5" }), /* @__PURE__ */ e.createElement("polyline", { points: "1,9 5,4 9,7 15,2", stroke: t, strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" })), Gn = ({ color: t }) => /* @__PURE__ */ e.createElement("svg", { width: ze, height: ze, viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ e.createElement("rect", { x: "1", y: "4", width: "3", height: "7", fill: t, opacity: "0.85", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "5", y: "8", width: "3", height: "3", fill: t, opacity: "0.5", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "9", y: "5", width: "3", height: "6", fill: t, opacity: "0.85", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "13", y: "10", width: "3", height: "1", fill: t, opacity: "0.4", rx: "0.5" }), /* @__PURE__ */ e.createElement("line", { x1: "0", y1: "15", x2: "16", y2: "15", stroke: t, strokeWidth: "0.7", opacity: "0.35" })), Tn = ({ color: t }) => /* @__PURE__ */ e.createElement("svg", { width: ze, height: ze, viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ e.createElement("rect", { x: "2", y: "6", width: "12", height: "5", fill: "none", stroke: t, strokeWidth: "1.2", rx: "1", opacity: "0.85" }), /* @__PURE__ */ e.createElement("line", { x1: "8", y1: "6", x2: "8", y2: "11", stroke: t, strokeWidth: "1.2", opacity: "0.85" }), /* @__PURE__ */ e.createElement("line", { x1: "5", y1: "3", x2: "5", y2: "13", stroke: t, strokeWidth: "1.1", opacity: "0.55" }), /* @__PURE__ */ e.createElement("line", { x1: "11", y1: "3", x2: "11", y2: "13", stroke: t, strokeWidth: "1.1", opacity: "0.55" }), /* @__PURE__ */ e.createElement("line", { x1: "4", y1: "3", x2: "6", y2: "3", stroke: t, strokeWidth: "1.1", opacity: "0.55" }), /* @__PURE__ */ e.createElement("line", { x1: "10", y1: "3", x2: "12", y2: "3", stroke: t, strokeWidth: "1.1", opacity: "0.55" }), /* @__PURE__ */ e.createElement("line", { x1: "4", y1: "13", x2: "6", y2: "13", stroke: t, strokeWidth: "1.1", opacity: "0.55" }), /* @__PURE__ */ e.createElement("line", { x1: "10", y1: "13", x2: "12", y2: "13", stroke: t, strokeWidth: "1.1", opacity: "0.55" })), Un = ({ color: t }) => /* @__PURE__ */ e.createElement("svg", { width: ze, height: ze, viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ e.createElement("polygon", { points: "8,2 14,6 12,13 4,13 2,6", fill: "none", stroke: t, strokeWidth: "1", opacity: "0.35" }), /* @__PURE__ */ e.createElement("polygon", { points: "8,5 11,7.5 9.5,11 6.5,11 5,7.5", fill: t, opacity: "0.65" })), Kn = ({ color: t }) => /* @__PURE__ */ e.createElement("svg", { width: ze, height: ze, viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ e.createElement("rect", { x: "1", y: "1", width: "4", height: "4", fill: t, opacity: "0.9", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "6", y: "1", width: "4", height: "4", fill: t, opacity: "0.4", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "11", y: "1", width: "4", height: "4", fill: t, opacity: "0.7", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "1", y: "6", width: "4", height: "4", fill: t, opacity: "0.3", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "6", y: "6", width: "4", height: "4", fill: t, opacity: "0.85", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "11", y: "6", width: "4", height: "4", fill: t, opacity: "0.5", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "1", y: "11", width: "4", height: "4", fill: t, opacity: "0.6", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "6", y: "11", width: "4", height: "4", fill: t, opacity: "0.95", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "11", y: "11", width: "4", height: "4", fill: t, opacity: "0.35", rx: "0.5" })), Zn = ({ color: t }) => /* @__PURE__ */ e.createElement("svg", { width: ze, height: ze, viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ e.createElement("rect", { x: "1", y: "9", width: "5", height: "6", fill: t, opacity: "0.65", rx: "0.5" }), /* @__PURE__ */ e.createElement("rect", { x: "7", y: "4", width: "5", height: "11", fill: t, opacity: "0.85", rx: "0.5" }), /* @__PURE__ */ e.createElement("polygon", { points: "1,9 4,5 9,5 7,9", fill: t, opacity: "0.45" }), /* @__PURE__ */ e.createElement("polygon", { points: "7,4 12,4 12,9 7,9", fill: t, opacity: "0.55" })), qn = ({ color: t }) => /* @__PURE__ */ e.createElement("svg", { width: ze, height: ze, viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ e.createElement("rect", { x: "4", y: "1", width: "8", height: "5", fill: t, opacity: "0.85", rx: "1" }), /* @__PURE__ */ e.createElement("rect", { x: "1", y: "10", width: "6", height: "5", fill: t, opacity: "0.6", rx: "1" }), /* @__PURE__ */ e.createElement("rect", { x: "9", y: "10", width: "6", height: "5", fill: t, opacity: "0.6", rx: "1" }), /* @__PURE__ */ e.createElement("line", { x1: "8", y1: "6", x2: "4", y2: "10", stroke: t, strokeWidth: "1", opacity: "0.45" }), /* @__PURE__ */ e.createElement("line", { x1: "8", y1: "6", x2: "12", y2: "10", stroke: t, strokeWidth: "1", opacity: "0.45" })), Tr = [
135
+ { name: "Bar", Icon: Yn, types: [{ value: "bar", label: "Bar / Column" }] },
136
+ { name: "Line / Area", Icon: Vn, types: [{ value: "line", label: "Line" }, { value: "area", label: "Area" }, { value: "sparkline", label: "Sparkline" }] },
137
+ { name: "Pie / Donut", Icon: _n, types: [{ value: "pie", label: "Pie" }, { value: "donut", label: "Donut" }] },
138
+ { name: "Scatter", Icon: Xn, types: [{ value: "scatter", label: "Scatter" }, { value: "bubble", label: "Bubble" }] },
139
+ { name: "Combo", Icon: jn, types: [{ value: "combo", label: "Combo" }] },
140
+ { name: "Waterfall", Icon: Gn, types: [{ value: "waterfall", label: "Waterfall" }, { value: "range", label: "Range" }] },
141
+ { name: "Statistical", Icon: Tn, types: [{ value: "histogram", label: "Histogram" }, { value: "boxplot", label: "Box Plot" }, { value: "funnel", label: "Funnel" }] },
142
+ { name: "Radial", Icon: Un, types: [{ value: "radar", label: "Radar" }, { value: "nightingale", label: "Nightingale" }] },
143
+ { name: "Heatmap", Icon: Kn, types: [{ value: "heatmap", label: "Heatmap" }] },
144
+ { name: "3D", Icon: Zn, types: [{ value: "bar3d", label: "3D Bar" }, { value: "line3d", label: "3D Line" }, { value: "scatter3d", label: "3D Scatter" }] },
145
+ { name: "Hierarchical", Icon: qn, types: [{ value: "icicle", label: "Icicle" }, { value: "sunburst", label: "Sunburst" }, { value: "sankey", label: "Sankey" }], hierarchyOnly: !0 }
146
+ ], Qn = ({ chartType: t, onChange: n, theme: o, includeHierarchyCharts: i = !0 }) => {
147
+ const [r, f] = _(null), h = i ? Tr : Tr.filter((S) => !S.hierarchyOnly);
148
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "3px" } }, h.map(({ name: S, Icon: $, types: R }) => {
149
+ const C = R.some((X) => X.value === t), O = R.find((X) => X.value === t), J = R.length === 1, K = r === S || C, a = C ? o.primary : o.textSec || o.text;
150
+ return /* @__PURE__ */ e.createElement("div", { key: S }, /* @__PURE__ */ e.createElement(
151
+ "button",
152
+ {
153
+ type: "button",
154
+ "aria-expanded": J ? void 0 : K,
155
+ onClick: () => {
156
+ J ? n(R[0].value) : f(K && !C ? null : S);
157
+ },
158
+ style: {
159
+ width: "100%",
160
+ display: "flex",
161
+ alignItems: "center",
162
+ gap: "7px",
163
+ padding: "5px 8px",
164
+ border: `1px solid ${C ? o.primary : o.border}`,
165
+ background: C ? o.select : o.headerSubtleBg || o.hover,
166
+ color: C ? o.primary : o.text,
167
+ borderRadius: o.radiusSm || "8px",
168
+ fontSize: "11px",
169
+ fontWeight: C ? 700 : 600,
170
+ cursor: "pointer",
171
+ textAlign: "left"
172
+ }
173
+ },
174
+ /* @__PURE__ */ e.createElement($, { color: a }),
175
+ /* @__PURE__ */ e.createElement("span", { style: { flex: 1 } }, O ? O.label : S),
176
+ !J && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "8px", color: a, transform: K ? "rotate(0deg)" : "rotate(-90deg)", transition: "transform 0.12s", flexShrink: 0 } }, "▼")
177
+ ), !J && K && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexWrap: "wrap", gap: "3px", padding: "4px 0 2px 24px" } }, R.map((X) => /* @__PURE__ */ e.createElement(
178
+ "button",
179
+ {
180
+ key: X.value,
181
+ type: "button",
182
+ "aria-pressed": t === X.value,
183
+ onClick: () => {
184
+ n(X.value), f(null);
185
+ },
186
+ style: {
187
+ border: `1px solid ${t === X.value ? o.primary : o.border}`,
188
+ background: t === X.value ? o.select : o.headerSubtleBg || o.hover,
189
+ color: t === X.value ? o.primary : o.text,
190
+ borderRadius: o.radiusSm || "8px",
191
+ padding: "4px 9px",
192
+ fontSize: "10px",
193
+ fontWeight: t === X.value ? 700 : 600,
194
+ cursor: "pointer"
195
+ }
196
+ },
197
+ X.label
198
+ ))));
199
+ }));
200
+ }, Jn = ({ line: t, onUpdate: n, onRemove: o, exportButtonStyle: i, compactInputStyle: r, theme: f }) => /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", alignItems: "center", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
201
+ "button",
202
+ {
203
+ type: "button",
204
+ onClick: () => n({ ...t, orient: t.orient === "v" ? "h" : "v" }),
205
+ style: { ...i, padding: "4px 7px", flexShrink: 0, fontWeight: 800, color: t.orient === "v" ? f.primary : f.textSec },
206
+ title: t.orient === "v" ? "Vertical (click for horizontal)" : "Horizontal (click for vertical)"
207
+ },
208
+ t.orient === "v" ? "|" : "—"
209
+ ), /* @__PURE__ */ e.createElement(
210
+ "input",
211
+ {
212
+ type: "number",
213
+ value: t.value,
214
+ onChange: (h) => n({ ...t, value: h.target.value }),
215
+ placeholder: t.orient === "v" ? "Cat index" : "Value",
216
+ style: { ...r, width: "60px", flexShrink: 0 }
217
+ }
218
+ ), /* @__PURE__ */ e.createElement(
219
+ "input",
220
+ {
221
+ type: "text",
222
+ value: t.label,
223
+ onChange: (h) => n({ ...t, label: h.target.value }),
224
+ placeholder: "Label",
225
+ style: { ...r, flex: 1, minWidth: 0 }
226
+ }
227
+ ), /* @__PURE__ */ e.createElement(
228
+ "input",
229
+ {
230
+ type: "color",
231
+ value: t.color || f.primary || "#2563EB",
232
+ onChange: (h) => n({ ...t, color: h.target.value }),
233
+ style: { width: "28px", height: "28px", padding: 0, border: `1px solid ${f.border}`, borderRadius: "4px", cursor: "pointer", background: "none", flexShrink: 0 },
234
+ title: "Line color"
235
+ }
236
+ ), /* @__PURE__ */ e.createElement(
237
+ "select",
238
+ {
239
+ value: t.dash || "dashed",
240
+ onChange: (h) => n({ ...t, dash: h.target.value }),
241
+ style: { ...r, width: "74px", flexShrink: 0 },
242
+ title: "Line style"
243
+ },
244
+ Lr.map((h) => /* @__PURE__ */ e.createElement("option", { key: h.value, value: h.value }, h.label))
245
+ ), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: o, style: { ...i, padding: "4px 7px", color: f.danger || "#ef4444", flexShrink: 0 } }, "✕")), Ur = (t, n = 430, o, i) => {
246
+ const r = Number(t), f = Number(n), h = Number.isFinite(r) ? r : Number.isFinite(f) ? f : 430;
247
+ return Math.max(o, Math.min(i, Math.floor(h)));
248
+ }, ea = (t) => {
249
+ const n = t.map((C, O) => [O, Number(C)]).filter(([, C]) => Number.isFinite(C));
250
+ if (n.length < 2) return null;
251
+ const o = n.length, i = n.reduce((C, [O]) => C + O, 0), r = n.reduce((C, [, O]) => C + O, 0), f = n.reduce((C, [O, J]) => C + O * J, 0), h = n.reduce((C, [O]) => C + O * O, 0), S = o * h - i * i;
252
+ if (S === 0) return null;
253
+ const $ = (o * f - i * r) / S, R = (r - $ * i) / o;
254
+ return t.map((C, O) => $ * O + R);
255
+ }, ta = (t, n) => {
256
+ const o = Math.max(2, Math.floor(Number(n) || 3));
257
+ return t.map((i, r) => {
258
+ const f = t.slice(Math.max(0, r - o + 1), r + 1).map(Number).filter(Number.isFinite);
259
+ return f.length > 0 ? f.reduce((h, S) => h + S, 0) / f.length : null;
260
+ });
261
+ }, en = (t) => Array.isArray(t && t.series) && t.series.length > 1, hr = (t, n) => {
262
+ if (typeof window > "u" || !t) return;
263
+ const o = window.URL.createObjectURL(t), i = document.createElement("a");
264
+ i.href = o, i.download = n, document.body.appendChild(i), i.click(), document.body.removeChild(i), window.URL.revokeObjectURL(o);
265
+ }, vr = (t = {}) => ({
266
+ title: String(t.title || "").trim(),
267
+ legendPosition: t.legendPosition === "top" ? "top" : "bottom",
268
+ legendItems: Array.isArray(t.legendItems) ? t.legendItems.filter((n) => n && n.label) : [],
269
+ background: t.background || "#ffffff",
270
+ textColor: t.textColor || "#111827",
271
+ secondaryTextColor: t.secondaryTextColor || "#4b5563"
272
+ }), ra = (t, n, o, i) => {
273
+ const r = t ? Array.from(t.querySelectorAll('[data-chart-export-legend-item="true"]')).map((f) => ({
274
+ label: f.getAttribute("data-chart-export-label") || f.textContent || "",
275
+ color: f.getAttribute("data-chart-export-color") || i.primary || "#2563eb",
276
+ hidden: f.getAttribute("data-chart-export-hidden") === "true"
277
+ })).filter((f) => f.label) : [];
278
+ return vr({
279
+ title: n,
280
+ legendPosition: o,
281
+ legendItems: r,
282
+ background: i.chartBg || i.surfaceBg || i.background || "#ffffff",
283
+ textColor: i.text || "#111827",
284
+ secondaryTextColor: i.textSec || i.text || "#4b5563"
285
+ });
286
+ }, tn = (t, n, o) => {
287
+ const i = [];
288
+ let r = [], f = 0;
289
+ return t.forEach((h) => {
290
+ const S = Math.max(48, o(h.label) + 30);
291
+ r.length > 0 && f + S > Math.max(80, n - 24) && (i.push(r), r = [], f = 0), r.push({ ...h, width: S }), f += S;
292
+ }), r.length > 0 && i.push(r), i;
293
+ }, br = (t) => {
294
+ const n = String(t ?? ""), o = typeof t == "string" && /^[=+\-@]/.test(n) ? `'${n}` : n;
295
+ return o.includes(",") || o.includes('"') || o.includes(`
296
+ `) ? `"${o.replace(/"/g, '""')}"` : o;
297
+ }, na = (t, n, o) => {
298
+ if (!t) return;
299
+ const i = Array.isArray(t.categories) ? t.categories : [], r = Array.isArray(t.series) ? t.series : [];
300
+ if (i.length === 0 || r.length === 0) return;
301
+ const f = ["Category", ...r.map((C) => C.name)].map(br).join(","), h = i.map((C, O) => [C, ...r.map((J) => J.values[O] ?? "")].map(br).join(",")), S = vr(o), $ = S.legendItems.length > 0 ? S.legendItems.map((C) => C.label) : r.map((C) => C.name).filter(Boolean), R = [];
302
+ S.title && R.push(["Title", S.title].map(br).join(",")), $.length > 0 && R.push(["Legend", ...$].map(br).join(",")), R.length > 0 && R.push(""), hr(new Blob([`\uFEFF${[...R, f, ...h].join(`
303
+ `)}`], { type: "text/csv;charset=utf-8" }), `${n}.csv`);
304
+ }, aa = /* @__PURE__ */ new Set(["bar3d", "line3d", "scatter3d", "range", "boxplot", "nightingale"]), la = /* @__PURE__ */ new Set(["bar3d", "line3d", "scatter3d"]), oa = e.lazy(() => import(
305
+ /* webpackChunkName: "pivot-echarts-2d" */
306
+ "./ECharts2dRenderer-BGL_NVGU.mjs"
307
+ )), ia = e.lazy(() => import(
308
+ /* webpackChunkName: "pivot-echarts-3d" */
309
+ "./ECharts3dRenderer-BF2YWlsP.mjs"
310
+ )), nr = ({ chartType: t, echartsRef: n, option: o }) => {
311
+ const i = la.has(t) ? ia : oa;
312
+ return /* @__PURE__ */ e.createElement(e.Suspense, { fallback: /* @__PURE__ */ e.createElement("div", { "aria-label": "Loading chart", style: { width: "100%", height: "100%" } }) }, /* @__PURE__ */ e.createElement(i, { echartsRef: n, option: o }));
313
+ }, Se = ({ message: t, theme: n, chartHeight: o = or }) => /* @__PURE__ */ e.createElement("div", { style: {
314
+ minHeight: `${o}px`,
315
+ border: `1px dashed ${n.border}`,
316
+ borderRadius: n.radius || "14px",
317
+ background: n.headerSubtleBg || n.hover,
318
+ display: "flex",
319
+ alignItems: "center",
320
+ justifyContent: "center",
321
+ padding: "16px",
322
+ color: n.textSec,
323
+ fontSize: "12px",
324
+ textAlign: "center"
325
+ } }, t), sa = ({ model: t, theme: n }) => {
326
+ const o = ot(() => {
327
+ const r = [];
328
+ return (t && t.series ? t.series : []).forEach((f) => {
329
+ (f.values || []).forEach((h) => {
330
+ typeof h == "number" && Number.isFinite(h) && r.push(h);
331
+ });
332
+ }), r.length === 0 && t && Array.isArray(t.icicleNodes) && t.icicleNodes.forEach((f) => {
333
+ const h = Number(f && f.value);
334
+ Number.isFinite(h) && r.push(h);
335
+ }), r.length === 0 ? null : {
336
+ categories: Array.isArray(t.categories) ? t.categories.length : 0,
337
+ seriesCount: Array.isArray(t.series) ? t.series.length : 0,
338
+ hierarchyNodes: Array.isArray(t.icicleNodes) ? t.icicleNodes.length : 0,
339
+ min: Math.min(...r),
340
+ max: Math.max(...r)
341
+ };
342
+ }, [t]);
343
+ if (!o) return null;
344
+ const i = {
345
+ border: `1px solid ${n.border}`,
346
+ background: n.headerSubtleBg || n.hover,
347
+ color: n.textSec,
348
+ borderRadius: n.radiusSm || "8px",
349
+ padding: "5px 8px",
350
+ fontSize: "11px",
351
+ fontWeight: 700
352
+ };
353
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("span", { style: i }, o.categories, " categories"), /* @__PURE__ */ e.createElement("span", { style: i }, o.seriesCount, " series"), o.hierarchyNodes > 0 ? /* @__PURE__ */ e.createElement("span", { style: i }, o.hierarchyNodes, " nodes") : null, /* @__PURE__ */ e.createElement("span", { style: i }, "Min ", Vr(o.min)), /* @__PURE__ */ e.createElement("span", { style: i }, "Max ", Vr(o.max)));
354
+ }, St = ({ items: t, theme: n, hiddenSet: o, onToggle: i, position: r = "bottom", onElementSelect: f }) => {
355
+ if (r === "none" || !Array.isArray(t) || t.length === 0) return null;
356
+ const h = typeof i == "function" && o;
357
+ return /* @__PURE__ */ e.createElement("div", { "data-chart-export-legend": "true", style: {
358
+ display: "flex",
359
+ gap: "10px",
360
+ flexWrap: "wrap",
361
+ alignItems: "center",
362
+ justifyContent: "flex-start",
363
+ order: r === "top" ? -1 : 1,
364
+ padding: r === "top" ? "0 0 6px 0" : "6px 0 0 0"
365
+ } }, t.map((S) => {
366
+ const $ = h && o.has(S.label);
367
+ return /* @__PURE__ */ e.createElement(
368
+ "div",
369
+ {
370
+ key: S.label,
371
+ "data-chart-export-legend-item": "true",
372
+ "data-chart-export-label": S.label,
373
+ "data-chart-export-color": $ ? n.border : S.color,
374
+ "data-chart-export-hidden": $ ? "true" : "false",
375
+ onClick: () => {
376
+ h && i(S.label), typeof f == "function" && f("legend", S.label);
377
+ },
378
+ role: "button",
379
+ tabIndex: 0,
380
+ onKeyDown: (R) => {
381
+ (R.key === "Enter" || R.key === " ") && (R.preventDefault(), h && i(S.label), typeof f == "function" && f("legend", S.label));
382
+ },
383
+ "aria-pressed": h ? !$ : void 0,
384
+ style: {
385
+ display: "flex",
386
+ alignItems: "center",
387
+ gap: "6px",
388
+ fontSize: "11px",
389
+ color: n.textSec,
390
+ cursor: "pointer",
391
+ opacity: $ ? 0.35 : 1,
392
+ textDecoration: $ ? "line-through" : "none",
393
+ userSelect: "none"
394
+ }
395
+ },
396
+ /* @__PURE__ */ e.createElement("span", { style: { width: "10px", height: "10px", borderRadius: "999px", background: $ ? n.border : S.color, display: "inline-block" } }),
397
+ /* @__PURE__ */ e.createElement("span", null, S.label)
398
+ );
399
+ }));
400
+ }, ca = (t, n, o, i = 10) => {
401
+ const f = (Array.isArray(t) ? t.map((T) => Number.isFinite(Number(T)) ? Number(T) : null) : []).map((T, V) => T === null ? null : { value: T, index: V }).filter(Boolean);
402
+ if (f.length === 0)
403
+ return {
404
+ linePath: "",
405
+ areaPath: "",
406
+ currentPoint: null,
407
+ minPoint: null,
408
+ maxPoint: null,
409
+ minValue: null,
410
+ maxValue: null,
411
+ firstValue: null,
412
+ lastValue: null
413
+ };
414
+ const h = Math.min(...f.map((T) => T.value)), S = Math.max(...f.map((T) => T.value)), $ = Math.max(1, S - h), R = f.length > 1 ? (n - i * 2) / (f.length - 1) : 0, C = f.map((T, V) => {
415
+ const Y = i + V * R, F = (T.value - h) / $, U = o - i - F * Math.max(1, o - i * 2);
416
+ return {
417
+ ...T,
418
+ x: Y,
419
+ y: U
420
+ };
421
+ }), O = C.map((T, V) => `${V === 0 ? "M" : "L"} ${T.x.toFixed(2)} ${T.y.toFixed(2)}`).join(" "), J = C.length > 1 ? `${O} L ${C[C.length - 1].x.toFixed(2)} ${(o - i).toFixed(2)} L ${C[0].x.toFixed(2)} ${(o - i).toFixed(2)} Z` : "", K = C.find((T) => T.value === h) || C[0], a = C.find((T) => T.value === S) || C[0], X = C[C.length - 1];
422
+ return {
423
+ linePath: O,
424
+ areaPath: J,
425
+ currentPoint: X,
426
+ minPoint: K,
427
+ maxPoint: a,
428
+ minValue: h,
429
+ maxValue: S,
430
+ firstValue: C[0] ? C[0].value : null,
431
+ lastValue: X ? X.value : null
432
+ };
433
+ }, ua = ({
434
+ model: t,
435
+ theme: n,
436
+ chartHeight: o,
437
+ paletteColors: i,
438
+ valueFormat: r,
439
+ referenceLines: f = []
440
+ }) => {
441
+ const h = Array.isArray(t && t.series) ? t.series : [], S = Array.isArray(t && t.categories) ? t.categories : [];
442
+ if (h.length === 0)
443
+ return /* @__PURE__ */ e.createElement(Se, { message: t && t.emptyMessage ? t.emptyMessage : "No sparkline data available.", theme: n, chartHeight: o });
444
+ const $ = 110, R = 240, C = 64;
445
+ return /* @__PURE__ */ e.createElement(
446
+ "div",
447
+ {
448
+ "data-chart-sparkline-board": "true",
449
+ style: {
450
+ display: "grid",
451
+ gridTemplateColumns: "repeat(auto-fit, minmax(240px, 1fr))",
452
+ gap: "10px",
453
+ minHeight: 0,
454
+ maxHeight: `${o}px`,
455
+ overflowY: "auto",
456
+ paddingRight: "2px"
457
+ }
458
+ },
459
+ h.map((O, J) => {
460
+ const K = Ce(J, n, i), a = ca(O.values || [], R, C, 10), X = Array.isArray(O.values) && O.values.length > 1 ? Number(O.values[O.values.length - 2]) : null, T = a.lastValue, V = Number.isFinite(X) && Number.isFinite(T) ? T - X : null, Y = V === null ? n.textSec : V >= 0 ? n.isDark ? "#7DD3A7" : "#2E7D5B" : n.isDark ? "#F7A3A3" : "#B45353";
461
+ return /* @__PURE__ */ e.createElement(
462
+ "div",
463
+ {
464
+ key: O.id || O.name || `spark-${J}`,
465
+ "data-chart-sparkline-card": O.id || O.name || `spark-${J}`,
466
+ style: {
467
+ minHeight: `${$}px`,
468
+ border: `1px solid ${n.border}`,
469
+ borderRadius: n.radiusSm || "10px",
470
+ background: n.surfaceBg || n.background || "#fff",
471
+ boxShadow: n.shadowInset || "none",
472
+ padding: "10px 12px",
473
+ display: "flex",
474
+ flexDirection: "column",
475
+ gap: "8px"
476
+ }
477
+ },
478
+ /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { style: { minWidth: 0 } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "12px", fontWeight: 800, color: n.text, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, O.name || `Series ${J + 1}`), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: n.textSec } }, S.length > 0 ? `${S.length} points` : "Trend")), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-end", gap: "2px", flexShrink: 0 } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "12px", fontWeight: 800, color: n.text } }, T === null ? "—" : zt(T, r)), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 700, color: Y } }, V === null ? "No delta" : `${V >= 0 ? "+" : ""}${zt(V, r)}`))),
479
+ /* @__PURE__ */ e.createElement(
480
+ "svg",
481
+ {
482
+ viewBox: `0 0 ${R} ${C}`,
483
+ style: { width: "100%", height: "64px", display: "block" },
484
+ "aria-label": `${O.name || `Series ${J + 1}`} sparkline`
485
+ },
486
+ a.areaPath ? /* @__PURE__ */ e.createElement("path", { d: a.areaPath, fill: K, opacity: "0.12" }) : null,
487
+ a.linePath ? /* @__PURE__ */ e.createElement(
488
+ "path",
489
+ {
490
+ d: a.linePath,
491
+ fill: "none",
492
+ stroke: K,
493
+ strokeWidth: "2.5",
494
+ strokeLinecap: "round",
495
+ strokeLinejoin: "round"
496
+ }
497
+ ) : null,
498
+ a.minPoint ? /* @__PURE__ */ e.createElement("circle", { cx: a.minPoint.x, cy: a.minPoint.y, r: "2.6", fill: n.surfaceBg || n.background || "#fff", stroke: K, strokeWidth: "1.4", opacity: "0.7" }) : null,
499
+ a.maxPoint ? /* @__PURE__ */ e.createElement("circle", { cx: a.maxPoint.x, cy: a.maxPoint.y, r: "2.8", fill: n.surfaceBg || n.background || "#fff", stroke: K, strokeWidth: "1.6", opacity: "0.9" }) : null,
500
+ a.currentPoint ? /* @__PURE__ */ e.createElement("circle", { cx: a.currentPoint.x, cy: a.currentPoint.y, r: "3.2", fill: K }) : null,
501
+ f.map((F, U) => {
502
+ const ue = Number(F.value);
503
+ if (!Number.isFinite(ue) || F.orient === "v" || a.minValue === null || a.maxValue === null) return null;
504
+ const ne = a.maxValue - a.minValue || 1, ie = C - 10 - (ue - a.minValue) / ne * (C - 20);
505
+ if (ie < 0 || ie > C) return null;
506
+ const pe = F.color || n.primary;
507
+ return /* @__PURE__ */ e.createElement("g", { key: `spark-rl-${U}` }, /* @__PURE__ */ e.createElement("line", { x1: 10, y1: ie, x2: R - 10, y2: ie, stroke: pe, strokeWidth: "1", strokeDasharray: "4 2", style: { pointerEvents: "none" } }), F.label ? /* @__PURE__ */ e.createElement("text", { x: R - 11, y: ie - 2, textAnchor: "end", fontSize: "8", fontWeight: "700", fill: pe, style: { pointerEvents: "none" } }, F.label) : null);
508
+ })
509
+ ),
510
+ /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "8px", fontSize: "10px", color: n.textSec } }, /* @__PURE__ */ e.createElement("span", null, S[0] ? ge(String(S[0]), 14) : "Start"), /* @__PURE__ */ e.createElement("span", null, "Min ", a.minValue === null ? "—" : zt(a.minValue, r), " · ", "Max ", a.maxValue === null ? "—" : zt(a.maxValue, r)), /* @__PURE__ */ e.createElement("span", null, S.length > 0 ? ge(String(S[S.length - 1]), 14) : "End"))
511
+ );
512
+ })
513
+ );
514
+ }, pa = ({
515
+ model: t,
516
+ chartType: n,
517
+ barLayout: o,
518
+ axisMode: i,
519
+ theme: r,
520
+ chartHeight: f = or,
521
+ showLegend: h = !0,
522
+ showDataLabels: S = !1,
523
+ onCategoryActivate: $ = null,
524
+ svgRef: R = null,
525
+ echartsRef: C = null,
526
+ colorPalette: O = "default",
527
+ valueFormat: J = "auto",
528
+ yAxisTitle: K = "",
529
+ yAxisMin: a = "",
530
+ yAxisMax: X = "",
531
+ referenceLines: T = [],
532
+ labelAngle: V = 0,
533
+ chartTitle: Y = "",
534
+ onTitleChange: F = null,
535
+ tickCount: U = 5,
536
+ markerShape: ue = "circle",
537
+ markerSize: ne = 4,
538
+ showGradient: ie = !1,
539
+ seriesColors: pe = {},
540
+ showAnimations: it = !1,
541
+ showCalloutLabels: be = !1,
542
+ subtitle: st = "",
543
+ onReferenceLinesChange: Te = null,
544
+ showTrendline: Vt = !1,
545
+ trendlineMode: ct = "linear",
546
+ trendlinePeriod: et = 3,
547
+ // new props
548
+ legendPosition: _e = "bottom",
549
+ labelPosition: Me = "outside",
550
+ decimalPlaces: Gt = -1,
551
+ gradientDirection: ir = "vertical",
552
+ gradientOpacity: nt = 70,
553
+ trendlineColor: Tt = "",
554
+ trendlineWidth: Ut = 2,
555
+ seriesSort: tt = "none",
556
+ lineDashStyles: mt = {},
557
+ yAxisMinRight: Kt = "",
558
+ yAxisMaxRight: z = "",
559
+ customPaletteColors: Bt = [],
560
+ onElementSelect: de = null
561
+ }) => {
562
+ const Ee = O === "custom" && Bt.length >= 2 ? Bt : Kr(O), P = (l) => {
563
+ if (Gt >= 0 && typeof l == "number" && Number.isFinite(l)) {
564
+ const c = zt(l, J);
565
+ if (!/[KMB%$]/.test(c) || J === "number")
566
+ return l.toFixed(Gt);
567
+ }
568
+ return zt(l, J);
569
+ };
570
+ ot(() => !t || !Array.isArray(t.series) || tt === "none" ? t : { ...t, series: In(t.series, tt) }, [t, tt]);
571
+ const Oe = n === "bar" && o === "stacked" && Array.isArray(t.stackedGroups) && t.stackedGroups.length > 0, Lt = n === "bar" && o === "stacked" && !Oe && pn(t), yt = n === "area" && o === "stacked" && en(t), ut = n === "bar" && i === "horizontal", Pe = o === "stacked100", ke = Number.isFinite(Number(V)) ? Number(V) : 0, W = f, he = (l, c) => pe && pe[l] || Ce(c, r, Ee), Rt = (l, c, s, p, x = {}) => {
572
+ if (ue === "none") return null;
573
+ const g = ne || 4, E = r.surfaceBg || r.background || "#fff", m = { fill: s, stroke: E, strokeWidth: "1.5", opacity: "0.82", ...p, ...x };
574
+ switch (ue) {
575
+ case "square":
576
+ return /* @__PURE__ */ e.createElement("rect", { x: l - g, y: c - g, width: g * 2, height: g * 2, rx: "2", ...m });
577
+ case "diamond":
578
+ return /* @__PURE__ */ e.createElement("polygon", { points: `${l},${c - g} ${l + g},${c} ${l},${c + g} ${l - g},${c}`, ...m });
579
+ case "cross":
580
+ return /* @__PURE__ */ e.createElement("path", { d: `M${l - g},${c} L${l + g},${c} M${l},${c - g} L${l},${c + g}`, fill: "none", stroke: s, strokeWidth: "2.5", strokeLinecap: "round", ...p, ...x });
581
+ case "triangle":
582
+ return /* @__PURE__ */ e.createElement("polygon", { points: `${l},${c - g} ${l + g},${c + g * 0.85} ${l - g},${c + g * 0.85}`, ...m });
583
+ default:
584
+ return /* @__PURE__ */ e.createElement("circle", { cx: l, cy: c, r: g, ...m });
585
+ }
586
+ }, ve = ot(() => !Pe || !t || !Array.isArray(t.categories) ? null : t.categories.map((l, c) => {
587
+ let s = 0;
588
+ return (t.series || []).forEach((p) => {
589
+ const x = p.values && p.values[c];
590
+ typeof x == "number" && Number.isFinite(x) && (s += Math.abs(x));
591
+ }), s || 1;
592
+ }), [Pe, t]), bt = Array.isArray(t && t.icicleNodes) ? t.icicleNodes : [], pt = Math.max(1, Number(t && t.icicleDepth) || 1), Ye = Fe(null), [Mt, sr] = _(Wr), Z = Math.max(Wr, Number.isFinite(Mt) ? Math.floor(Mt) : Wr);
593
+ He(() => {
594
+ const l = Ye.current;
595
+ if (!l) return;
596
+ const c = () => {
597
+ const p = l.clientWidth;
598
+ p > 0 && sr(p);
599
+ };
600
+ if (c(), typeof ResizeObserver > "u") return;
601
+ const s = new ResizeObserver(c);
602
+ return s.observe(l), () => s.disconnect();
603
+ }, []);
604
+ const [ee, Dt] = _(/* @__PURE__ */ new Set()), Qe = je((l) => {
605
+ Dt((c) => {
606
+ const s = new Set(c);
607
+ return s.has(l) ? s.delete(l) : s.add(l), s;
608
+ });
609
+ }, []), [$e, Ue] = _(null), Ke = je((l) => {
610
+ const c = l.target, s = c.getAttribute("data-tip-cat");
611
+ if (!s) {
612
+ Ue((g) => g && null);
613
+ return;
614
+ }
615
+ const x = l.currentTarget.getBoundingClientRect();
616
+ Ue({
617
+ x: l.clientX - x.left,
618
+ y: l.clientY - x.top,
619
+ category: s,
620
+ series: c.getAttribute("data-tip-ser") || "",
621
+ value: c.getAttribute("data-tip-val") || "",
622
+ color: c.getAttribute("data-tip-color") || ""
623
+ });
624
+ }, []), ht = je(() => Ue(null), []), dt = je((l) => {
625
+ if (!de) return;
626
+ let c = l.target;
627
+ for (; c && c !== l.currentTarget; ) {
628
+ const s = c.getAttribute && c.getAttribute("data-chart-element-type");
629
+ if (s) {
630
+ de(s, c.getAttribute("data-chart-element-id") || "");
631
+ return;
632
+ }
633
+ c = c.parentElement;
634
+ }
635
+ }, [de]), Ie = $e ? /* @__PURE__ */ e.createElement("div", { style: {
636
+ position: "absolute",
637
+ left: $e.x + 14 + 160 > Z ? Math.max(0, $e.x - 174) : $e.x + 14,
638
+ top: $e.y - 10 < 0 ? $e.y + 14 : $e.y - 10,
639
+ pointerEvents: "none",
640
+ zIndex: 10,
641
+ background: r.surfaceBg || r.background || "#fff",
642
+ border: `1px solid ${r.border}`,
643
+ borderRadius: r.radiusSm || "8px",
644
+ padding: "6px 10px",
645
+ fontSize: "11px",
646
+ fontWeight: 600,
647
+ color: r.text,
648
+ boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
649
+ whiteSpace: "nowrap"
650
+ } }, /* @__PURE__ */ e.createElement("div", { style: { fontWeight: 800, marginBottom: $e.series ? "2px" : 0 } }, $e.category), $e.series ? /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "6px" } }, $e.color ? /* @__PURE__ */ e.createElement("span", { style: { width: "8px", height: "8px", borderRadius: "50%", background: $e.color, flexShrink: 0 } }) : null, /* @__PURE__ */ e.createElement("span", null, $e.series, ": ", $e.value)) : $e.value ? /* @__PURE__ */ e.createElement("div", null, $e.value) : null) : null, [Le, _t] = _(1), [at, Re] = _({ x: 0, y: 0 }), Je = Fe(null), [vt, Et] = _(null), lt = je((l) => {
651
+ l.preventDefault(), _t((c) => {
652
+ const s = l.deltaY < 0 ? c * 1.15 : c / 1.15, p = Math.min(10, Math.max(1, s));
653
+ return p === 1 && Re({ x: 0, y: 0 }), p;
654
+ });
655
+ }, []), Ze = je((l) => {
656
+ Le <= 1 || l.button !== 0 || (Je.current = { startX: l.clientX, startY: l.clientY, startPan: { ...at } });
657
+ }, [Le, at]), xt = je((l) => {
658
+ if (!Je.current) return;
659
+ const c = l.clientX - Je.current.startX, s = l.clientY - Je.current.startY;
660
+ Re({ x: Je.current.startPan.x + c, y: Je.current.startPan.y + s });
661
+ }, []), Ve = je(() => {
662
+ Je.current = null;
663
+ }, []), Nt = je(() => {
664
+ _t(1), Re({ x: 0, y: 0 });
665
+ }, []), ft = je((l) => {
666
+ Ke(l), xt(l);
667
+ const c = R && R.current;
668
+ if (c && typeof c.getScreenCTM == "function") {
669
+ const s = c.getScreenCTM();
670
+ if (s) {
671
+ const p = c.createSVGPoint();
672
+ p.x = l.clientX, p.y = l.clientY;
673
+ const x = p.matrixTransform(s.inverse());
674
+ Et({ x: x.x, y: x.y });
675
+ }
676
+ }
677
+ }, [Ke, xt]), At = je(() => {
678
+ ht(), Ve(), Et(null);
679
+ }, [ht, Ve]), We = {
680
+ onMouseMove: ft,
681
+ onMouseLeave: At,
682
+ onWheel: lt,
683
+ onMouseDown: Ze,
684
+ onMouseUp: Ve,
685
+ onDoubleClick: Nt
686
+ }, te = Le > 1 ? `scale(${Le}) translate(${at.x / Le}px, ${at.y / Le}px)` : void 0, Be = Le > 1 ? { overflow: "hidden", cursor: "grab" } : void 0, qe = Le > 1 ? { transform: te, transformOrigin: "center center" } : void 0, we = vt && n !== "icicle" && n !== "sunburst" && n !== "sankey" ? /* @__PURE__ */ e.createElement("svg", { style: { position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none", zIndex: 5 }, viewBox: `0 0 ${Z} ${W}`, preserveAspectRatio: "xMidYMid meet" }, /* @__PURE__ */ e.createElement("line", { x1: vt.x, y1: 0, x2: vt.x, y2: W, stroke: r.textSec, strokeOpacity: "0.3", strokeDasharray: "4 3" }), /* @__PURE__ */ e.createElement("line", { x1: 0, y1: vt.y, x2: Z, y2: vt.y, stroke: r.textSec, strokeOpacity: "0.3", strokeDasharray: "4 3" })) : null, Xe = Le > 1.05 ? /* @__PURE__ */ e.createElement("div", { style: { position: "absolute", top: 4, right: 4, zIndex: 12, background: r.surfaceBg || "#fff", border: `1px solid ${r.border}`, borderRadius: r.radiusSm || "8px", padding: "2px 7px", fontSize: "10px", fontWeight: 700, color: r.textSec, pointerEvents: "auto", cursor: "pointer" }, onClick: Nt, title: "Reset zoom (or double-click chart)" }, Math.round(Le * 100), "% ✕") : null, [rt, cr] = _(!1), [kt, pr] = _(""), Pt = Fe(null), [Zt, qt] = _(null), Qt = Fe(null);
687
+ He(() => {
688
+ const l = (s) => {
689
+ if (!Qt.current) return;
690
+ const { startX: p, startY: x, startPos: g, containerRect: E } = Qt.current, m = s.clientX - p, w = s.clientY - x, k = Math.max(0, Math.min(E.width - 40, g.x + m)), y = Math.max(0, Math.min(E.height - 20, g.y + w));
691
+ qt({ x: k, y });
692
+ }, c = () => {
693
+ Qt.current = null;
694
+ };
695
+ return window.addEventListener("mousemove", l), window.addEventListener("mouseup", c), () => {
696
+ window.removeEventListener("mousemove", l), window.removeEventListener("mouseup", c);
697
+ };
698
+ }, []);
699
+ const It = (l) => {
700
+ if (rt) return;
701
+ l.preventDefault();
702
+ const c = l.currentTarget.parentElement;
703
+ if (!c) return;
704
+ const s = c.getBoundingClientRect(), p = Zt || {
705
+ x: s.width / 2 - 40,
706
+ y: 6
707
+ };
708
+ Qt.current = {
709
+ startX: l.clientX,
710
+ startY: l.clientY,
711
+ startPos: p,
712
+ containerRect: s
713
+ };
714
+ }, Er = () => {
715
+ typeof F == "function" && (pr(Y || ""), cr(!0));
716
+ }, Ht = () => {
717
+ typeof F == "function" && F(kt), cr(!1);
718
+ };
719
+ He(() => {
720
+ rt && Pt.current && Pt.current.focus();
721
+ }, [rt]);
722
+ const kr = Zt ? { left: `${Zt.x}px`, top: `${Zt.y}px` } : { left: "50%", top: "6px", transform: "translateX(-50%)" }, De = Y || rt ? /* @__PURE__ */ e.createElement(
723
+ "div",
724
+ {
725
+ onMouseDown: It,
726
+ onDoubleClick: Er,
727
+ onClick: de && !rt ? () => de("title", "") : void 0,
728
+ "data-chart-element-type": "title",
729
+ style: {
730
+ position: "absolute",
731
+ ...kr,
732
+ zIndex: 6,
733
+ cursor: rt ? "text" : de ? "pointer" : "grab",
734
+ userSelect: rt ? "auto" : "none"
735
+ }
736
+ },
737
+ rt ? /* @__PURE__ */ e.createElement(
738
+ "input",
739
+ {
740
+ ref: Pt,
741
+ type: "text",
742
+ value: kt,
743
+ onChange: (l) => pr(l.target.value),
744
+ onBlur: Ht,
745
+ onKeyDown: (l) => {
746
+ l.key === "Enter" && Ht(), l.key === "Escape" && cr(!1);
747
+ },
748
+ onMouseDown: (l) => l.stopPropagation(),
749
+ style: {
750
+ fontSize: "13px",
751
+ fontWeight: 700,
752
+ color: r.text,
753
+ background: r.surfaceBg || r.background || "#fff",
754
+ border: `1.5px solid ${r.primary}`,
755
+ borderRadius: r.radiusSm || "6px",
756
+ padding: "2px 10px",
757
+ outline: "none",
758
+ minWidth: "80px"
759
+ }
760
+ }
761
+ ) : /* @__PURE__ */ e.createElement("span", { style: {
762
+ fontSize: "13px",
763
+ fontWeight: 700,
764
+ color: r.text,
765
+ background: `${r.surfaceBg || r.background || "#fff"}cc`,
766
+ padding: "2px 10px",
767
+ borderRadius: r.radiusSm || "6px",
768
+ whiteSpace: "nowrap",
769
+ display: "inline-block"
770
+ } }, Y)
771
+ ) : null, d = ot(() => {
772
+ if (n === "heatmap" || n === "icicle" || n === "sunburst" || n === "sankey" || n === "pie" || n === "donut" || n === "scatter" || n === "waterfall" || n === "combo" || n === "sparkline" || n === "bubble" || n === "radar" || n === "funnel" || n === "histogram" || aa.has(n)) return null;
773
+ const l = Oe ? (t.stackedGroups || []).reduce((L, ce) => {
774
+ let oe = 0, ae = 0;
775
+ return (ce.segments || []).forEach((N) => {
776
+ const re = N && typeof N.value == "number" && Number.isFinite(N.value) ? N.value : null;
777
+ re !== null && (re >= 0 ? oe += re : ae += re);
778
+ }), L.push(oe, ae), L;
779
+ }, []) : Lt ? (t.categories || []).reduce((L, ce, oe) => {
780
+ let ae = 0, N = 0;
781
+ return (t.series || []).forEach((re) => {
782
+ const fe = re && Array.isArray(re.values) ? re.values[oe] : null;
783
+ typeof fe != "number" || !Number.isFinite(fe) || (fe >= 0 ? ae += fe : N += fe);
784
+ }), L.push(ae, N), L;
785
+ }, []) : yt ? t.categories.reduce((L, ce, oe) => {
786
+ let ae = 0, N = 0;
787
+ return (t.series || []).forEach((re) => {
788
+ const fe = re && Array.isArray(re.values) ? re.values[oe] : null;
789
+ typeof fe != "number" || !Number.isFinite(fe) || (fe >= 0 ? ae += fe : N += fe);
790
+ }), L.push(ae, N), L;
791
+ }, []) : (t.series || []).reduce((L, ce) => ((ce.values || []).forEach((oe) => {
792
+ typeof oe == "number" && Number.isFinite(oe) && L.push(oe);
793
+ }), L), []);
794
+ if (l.length === 0) return null;
795
+ const c = !Oe && n === "bar" && Array.isArray(t.categoryBands) && t.categoryBands.length === t.categories.length && t.categoryBands.some((L) => L && L.outerLabel);
796
+ let s = Math.min(...l, 0), p = Math.max(...l, 0);
797
+ if (Pe)
798
+ s = 0, p = 100;
799
+ else {
800
+ if (s === p) {
801
+ const L = Math.abs(p || 1) * 0.15 || 1;
802
+ s -= L, p += L;
803
+ }
804
+ Number.isFinite(Number(a)) && a !== "" && (s = Number(a)), Number.isFinite(Number(X)) && X !== "" && (p = Number(X)), s >= p && (p = s + 1);
805
+ }
806
+ const g = Yt(s, p, 5).map((L) => Pe ? `${Math.round(L)}%` : P(L)).reduce((L, ce) => Math.max(L, Wt(ce)), 0), E = Oe ? (t.stackedGroups || []).map((L) => ge(L && L.label, 22)) : c ? (t.categoryBands || []).map((L) => ge(L && L.innerLabel, 18)) : (t.categories || []).map((L) => ge(L, 22)), m = c ? (t.categoryBands || []).map((L) => ge(L && L.outerLabel, 18)) : [], w = E.reduce((L, ce) => Math.max(L, Wt(ce)), 0), k = m.reduce((L, ce) => Math.max(L, Wt(ce, 11)), 0), y = ut ? Math.max(
807
+ c ? 176 : 132,
808
+ c ? k + w + 38 : w + 22
809
+ ) : Math.max(66, g + 18), I = ke === 0 ? 40 : ke <= 30 ? 62 : ke <= 45 ? 80 : ke <= 60 ? 98 : 118, j = ut ? { top: 24, right: 18, bottom: 42, left: y } : { top: 24, right: 18, bottom: c ? 118 : I, left: y }, M = Z - j.left - j.right, v = W - j.top - j.bottom, B = n === "bar" ? 0 : Math.min(Math.max(0, s), p), D = p - s || 1, H = ut ? null : ((L) => j.top + (p - L) / D * v), G = ut ? ((L) => j.left + (L - s) / D * M) : null, se = H ? H(B) : null, b = G ? G(B) : null, q = Math.max(t.categories.length, 1), le = (ut ? v : M) / q, A = Math.max(10, le * 0.72);
810
+ return {
811
+ margin: j,
812
+ plotWidth: M,
813
+ plotHeight: v,
814
+ baselineY: se,
815
+ baselineX: b,
816
+ scaleY: H,
817
+ scaleX: G,
818
+ step: le,
819
+ groupWidth: A,
820
+ minValue: s,
821
+ maxValue: p,
822
+ hasHierarchicalBands: c,
823
+ horizontalBarMode: ut
824
+ };
825
+ }, [i, t, n, yt, Oe, Lt, ut, W, Z, Pe, a, X, ke, P]), Ft = ot(() => {
826
+ if (!d || d.horizontalBarMode || d.hasHierarchicalBands)
827
+ return { visibleIndexes: null, maxChars: 20, stride: 1 };
828
+ const l = Array.isArray(t && t.categories) ? t.categories : [];
829
+ if (l.length <= 1) return { visibleIndexes: null, maxChars: 20, stride: 1 };
830
+ const c = d.step < 42 ? 12 : d.step < 70 ? 16 : 20, s = l.reduce((k, y) => Math.max(k, Wt(ge(y, c), 11)), 0), p = Math.abs(ke) * (Math.PI / 180), x = ke === 0 ? s : Math.abs(Math.cos(p)) * s + Math.abs(Math.sin(p)) * 12, g = Math.max(1, Math.ceil((x + 12) / Math.max(d.step, 1)));
831
+ if (g === 1) return { visibleIndexes: null, maxChars: c, stride: g };
832
+ const E = /* @__PURE__ */ new Set();
833
+ for (let k = 0; k < l.length; k += g) E.add(k);
834
+ const m = l.length - 1, w = Math.floor(m / g) * g;
835
+ return m - w >= Math.ceil(g * 0.6) && E.add(m), { visibleIndexes: E, maxChars: c, stride: g };
836
+ }, [ke, d, t]);
837
+ if (n === "sparkline")
838
+ return /* @__PURE__ */ e.createElement(
839
+ "div",
840
+ {
841
+ ref: Ye,
842
+ "data-chart-sparkline-surface": "true",
843
+ style: {
844
+ position: "relative",
845
+ minHeight: `${W}px`,
846
+ height: `${W}px`,
847
+ minWidth: 0
848
+ }
849
+ },
850
+ /* @__PURE__ */ e.createElement(
851
+ ua,
852
+ {
853
+ model: t,
854
+ theme: r,
855
+ chartHeight: W,
856
+ paletteColors: Ee,
857
+ valueFormat: J,
858
+ referenceLines: T
859
+ }
860
+ ),
861
+ De
862
+ );
863
+ if (n === "icicle") {
864
+ if (bt.length === 0)
865
+ return /* @__PURE__ */ e.createElement(Se, { message: "Icicle charts need hierarchical rows and a numeric measure.", theme: r, chartHeight: W });
866
+ const l = W / pt, c = dn(bt, 0, Z, 0, l, []);
867
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative" }, ...We }, /* @__PURE__ */ e.createElement(
868
+ "svg",
869
+ {
870
+ ref: R,
871
+ viewBox: `0 0 ${Z} ${W}`,
872
+ preserveAspectRatio: "xMidYMid meet",
873
+ style: {
874
+ width: "100%",
875
+ height: "auto",
876
+ display: "block",
877
+ maxWidth: "100%"
878
+ },
879
+ role: "img",
880
+ "aria-label": t.title || "Icicle chart"
881
+ },
882
+ c.map((s, p) => {
883
+ const x = Ce(Math.max(0, s.depth - 1), r, Ee), g = s.width >= 54;
884
+ return /* @__PURE__ */ e.createElement(
885
+ "g",
886
+ {
887
+ key: `icicle-node-${s.rowPath || p}`,
888
+ onClick: () => {
889
+ typeof $ == "function" && $(s);
890
+ },
891
+ style: typeof $ == "function" ? { cursor: "pointer" } : void 0
892
+ },
893
+ /* @__PURE__ */ e.createElement(
894
+ "rect",
895
+ {
896
+ x: s.x,
897
+ y: s.y,
898
+ width: Math.max(1, s.width - 1),
899
+ height: Math.max(20, s.height - 2),
900
+ rx: "4",
901
+ fill: x,
902
+ opacity: "0.86",
903
+ stroke: r.surfaceBg || r.background || "#fff",
904
+ strokeWidth: "1",
905
+ "data-tip-cat": s.label || "",
906
+ "data-tip-val": typeof s.value == "number" ? P(s.value) : "",
907
+ "data-tip-color": x
908
+ }
909
+ ),
910
+ g ? /* @__PURE__ */ e.createElement(
911
+ "text",
912
+ {
913
+ x: s.x + 8,
914
+ y: s.y + Math.min(s.height - 10, 22),
915
+ textAnchor: "start",
916
+ fontSize: "11",
917
+ fontWeight: "700",
918
+ fill: "#fff",
919
+ style: { pointerEvents: "none" }
920
+ },
921
+ ge(s.label, Math.max(6, Math.floor(s.width / 9)))
922
+ ) : null
923
+ );
924
+ })
925
+ ), De, we, Ie, Xe));
926
+ }
927
+ if (n === "sunburst") {
928
+ if (bt.length === 0)
929
+ return /* @__PURE__ */ e.createElement(Se, { message: "Sunburst charts need hierarchical rows and a numeric measure.", theme: r, chartHeight: W });
930
+ const l = Math.min(Z, W) / 2 - 18, c = Z / 2, s = W / 2, p = l / Math.max(pt, 1), x = xn(bt, -Math.PI / 2, Math.PI * 3 / 2, 1, p, []);
931
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative" }, ...We }, /* @__PURE__ */ e.createElement(
932
+ "svg",
933
+ {
934
+ ref: R,
935
+ viewBox: `0 0 ${Z} ${W}`,
936
+ preserveAspectRatio: "xMidYMid meet",
937
+ style: {
938
+ width: "100%",
939
+ height: "auto",
940
+ display: "block",
941
+ maxWidth: "100%"
942
+ },
943
+ role: "img",
944
+ "aria-label": t.title || "Sunburst chart"
945
+ },
946
+ x.map((g, E) => {
947
+ const m = Ce(Math.max(0, g.depth - 1), r, Ee), w = Fr(c, s, g.innerRadius, g.outerRadius, g.startAngle, g.endAngle), k = g.startAngle + (g.endAngle - g.startAngle) / 2, y = g.innerRadius + (g.outerRadius - g.innerRadius) / 2, I = ur(c, s, y, k), j = g.endAngle - g.startAngle, M = j > 0.2 && g.outerRadius - g.innerRadius >= 18;
948
+ return /* @__PURE__ */ e.createElement(
949
+ "g",
950
+ {
951
+ key: `sunburst-node-${g.rowPath || E}`,
952
+ onClick: () => {
953
+ typeof $ == "function" && $(g);
954
+ },
955
+ style: typeof $ == "function" ? { cursor: "pointer" } : void 0
956
+ },
957
+ /* @__PURE__ */ e.createElement(
958
+ "path",
959
+ {
960
+ d: w,
961
+ fill: m,
962
+ opacity: "0.88",
963
+ stroke: r.surfaceBg || r.background || "#fff",
964
+ strokeWidth: "1",
965
+ "data-tip-cat": g.label || "",
966
+ "data-tip-val": typeof g.value == "number" ? P(g.value) : "",
967
+ "data-tip-color": m
968
+ }
969
+ ),
970
+ M ? /* @__PURE__ */ e.createElement(
971
+ "text",
972
+ {
973
+ x: I.x,
974
+ y: I.y,
975
+ textAnchor: "middle",
976
+ fontSize: "10",
977
+ fontWeight: "700",
978
+ fill: "#fff",
979
+ style: { pointerEvents: "none" }
980
+ },
981
+ ge(g.label, Math.max(5, Math.floor(j * 24)))
982
+ ) : null
983
+ );
984
+ })
985
+ ), De, we, Ie, Xe));
986
+ }
987
+ if (n === "sankey") {
988
+ const l = Array.isArray(t && t.sankeyNodes) ? t.sankeyNodes : [], c = Array.isArray(t && t.sankeyLinks) ? t.sankeyLinks : [];
989
+ if (l.length === 0 || c.length === 0)
990
+ return /* @__PURE__ */ e.createElement(Se, { message: "Sankey charts need expanded hierarchical rows with child flows.", theme: r, chartHeight: W });
991
+ const s = fn(l, c, Z, W), p = s.nodes.length > 0 ? Math.max(...s.nodes.map((x) => x.x)) : 0;
992
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative" }, ...We }, /* @__PURE__ */ e.createElement(
993
+ "svg",
994
+ {
995
+ ref: R,
996
+ viewBox: `0 0 ${Z} ${W}`,
997
+ preserveAspectRatio: "xMidYMid meet",
998
+ style: {
999
+ width: "100%",
1000
+ height: "auto",
1001
+ display: "block",
1002
+ maxWidth: "100%",
1003
+ overflow: "visible"
1004
+ },
1005
+ role: "img",
1006
+ "aria-label": t.title || "Sankey chart"
1007
+ },
1008
+ s.links.map((x, g) => {
1009
+ const E = x.sourceNode.x + x.sourceNode.width, m = x.targetNode.x, w = E + (m - E) / 2, k = [
1010
+ `M ${E} ${x.sourceY}`,
1011
+ `C ${w} ${x.sourceY}, ${w} ${x.targetY}, ${m} ${x.targetY}`
1012
+ ].join(" ");
1013
+ return /* @__PURE__ */ e.createElement(
1014
+ "path",
1015
+ {
1016
+ key: `sankey-link-${x.source}-${x.target}-${g}`,
1017
+ d: k,
1018
+ fill: "none",
1019
+ stroke: r.primary,
1020
+ strokeOpacity: "0.22",
1021
+ strokeWidth: x.thickness,
1022
+ "data-tip-cat": `${x.sourceNode.label || ""} → ${x.targetNode.label || ""}`,
1023
+ "data-tip-val": typeof x.value == "number" ? P(x.value) : ""
1024
+ }
1025
+ );
1026
+ }),
1027
+ s.nodes.map((x, g) => {
1028
+ const E = Ce(Math.max(0, x.depth - 1), r, Ee);
1029
+ return /* @__PURE__ */ e.createElement(
1030
+ "g",
1031
+ {
1032
+ key: `sankey-node-${x.rowPath || g}`,
1033
+ onClick: () => {
1034
+ typeof $ == "function" && $(x);
1035
+ },
1036
+ style: typeof $ == "function" ? { cursor: "pointer" } : void 0
1037
+ },
1038
+ /* @__PURE__ */ e.createElement(
1039
+ "rect",
1040
+ {
1041
+ x: x.x,
1042
+ y: x.y,
1043
+ width: x.width,
1044
+ height: x.height,
1045
+ rx: "4",
1046
+ fill: E,
1047
+ opacity: "0.92",
1048
+ stroke: r.surfaceBg || r.background || "#fff",
1049
+ strokeWidth: "1",
1050
+ "data-tip-cat": x.label || "",
1051
+ "data-tip-val": typeof x.value == "number" ? P(x.value) : "",
1052
+ "data-tip-color": E
1053
+ }
1054
+ ),
1055
+ /* @__PURE__ */ e.createElement(
1056
+ "text",
1057
+ {
1058
+ x: x.x === p ? x.x - 6 : x.x + x.width + 6,
1059
+ y: x.y + Math.min(x.height / 2 + 4, x.height - 4),
1060
+ textAnchor: x.x === p ? "end" : "start",
1061
+ fontSize: "11",
1062
+ fill: r.text,
1063
+ fontWeight: "700",
1064
+ style: { pointerEvents: "none" }
1065
+ },
1066
+ ge(x.label, 24)
1067
+ )
1068
+ );
1069
+ })
1070
+ ), De, we, Ie, Xe));
1071
+ }
1072
+ if (n === "pie" || n === "donut") {
1073
+ const l = Array.isArray(t && t.series) && t.series.length > 0 ? t.series[0] : null, c = Array.isArray(t && t.categories) ? t.categories : [];
1074
+ if (!l || c.length === 0)
1075
+ return /* @__PURE__ */ e.createElement(Se, { message: "Pie charts need categories and at least one numeric measure.", theme: r, chartHeight: W });
1076
+ const s = c.map((M, v) => {
1077
+ const B = l.values[v], D = typeof B == "number" && Number.isFinite(B) ? B : 0;
1078
+ return { category: M, value: Math.abs(D), originalValue: D, index: v };
1079
+ }).filter((M) => M.value > 0 && !ee.has(M.category)), p = s.reduce((M, v) => M + v.value, 0);
1080
+ if (p === 0)
1081
+ return /* @__PURE__ */ e.createElement(Se, { message: "All values are zero — nothing to display.", theme: r, chartHeight: W });
1082
+ const x = n === "donut", g = Math.min(Z, W) / 2 - 24, E = x ? g * 0.52 : 0, m = Z / 2, w = W / 2, k = Array.isArray(t && t.categoryTargets) ? t.categoryTargets : [];
1083
+ let y = -Math.PI / 2;
1084
+ const I = s.map((M) => {
1085
+ const v = M.value / p, B = v * Math.PI * 2, D = y, H = y + B;
1086
+ return y = H, { ...M, startAngle: D, endAngle: H, fraction: v };
1087
+ }), j = I.map((M) => ({
1088
+ label: `${M.category} (${(M.fraction * 100).toFixed(1)}%)`,
1089
+ color: Ce(M.index, r, Ee)
1090
+ }));
1091
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative" }, ...We }, /* @__PURE__ */ e.createElement(
1092
+ "svg",
1093
+ {
1094
+ ref: R,
1095
+ viewBox: `0 0 ${Z} ${W}`,
1096
+ preserveAspectRatio: "xMidYMid meet",
1097
+ style: {
1098
+ width: "100%",
1099
+ height: "auto",
1100
+ display: "block",
1101
+ maxWidth: "100%"
1102
+ },
1103
+ role: "img",
1104
+ "aria-label": t.title || (x ? "Donut chart" : "Pie chart")
1105
+ },
1106
+ I.map((M) => {
1107
+ const v = Ce(M.index, r, Ee), B = Fr(m, w, E, g, M.startAngle, M.endAngle), D = M.startAngle + (M.endAngle - M.startAngle) / 2, H = x ? E + (g - E) / 2 : g * 0.62, G = ur(m, w, H, D), se = M.endAngle - M.startAngle > 0.3, b = ur(m, w, g + (be ? 26 : 14), D), q = M.endAngle - M.startAngle > 0.15, le = k[M.index] || null;
1108
+ return /* @__PURE__ */ e.createElement(
1109
+ "g",
1110
+ {
1111
+ key: `pie-slice-${M.index}`,
1112
+ onClick: () => {
1113
+ typeof $ == "function" && le && $(le);
1114
+ },
1115
+ style: typeof $ == "function" && le ? { cursor: "pointer" } : void 0
1116
+ },
1117
+ /* @__PURE__ */ e.createElement(
1118
+ "path",
1119
+ {
1120
+ d: B,
1121
+ fill: v,
1122
+ opacity: "0.9",
1123
+ stroke: r.surfaceBg || r.background || "#fff",
1124
+ strokeWidth: "2",
1125
+ "data-tip-cat": M.category,
1126
+ "data-tip-ser": l.name,
1127
+ "data-tip-val": `${P(M.originalValue)} (${(M.fraction * 100).toFixed(1)}%)`,
1128
+ "data-tip-color": v
1129
+ }
1130
+ ),
1131
+ se ? /* @__PURE__ */ e.createElement(
1132
+ "text",
1133
+ {
1134
+ x: G.x,
1135
+ y: G.y,
1136
+ textAnchor: "middle",
1137
+ dominantBaseline: "central",
1138
+ fontSize: "10",
1139
+ fontWeight: "700",
1140
+ fill: "#fff",
1141
+ style: { pointerEvents: "none" }
1142
+ },
1143
+ (M.fraction * 100).toFixed(1),
1144
+ "%"
1145
+ ) : null,
1146
+ (S || be) && q ? /* @__PURE__ */ e.createElement("g", null, be ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
1147
+ "line",
1148
+ {
1149
+ x1: ur(m, w, g * 0.97, D).x,
1150
+ y1: ur(m, w, g * 0.97, D).y,
1151
+ x2: b.x,
1152
+ y2: b.y,
1153
+ stroke: v,
1154
+ strokeWidth: "1",
1155
+ style: { pointerEvents: "none" }
1156
+ }
1157
+ ), /* @__PURE__ */ e.createElement(
1158
+ "text",
1159
+ {
1160
+ x: D > Math.PI / 2 && D < 3 * Math.PI / 2 ? b.x - 4 : b.x + 4,
1161
+ y: b.y + 4,
1162
+ textAnchor: D > Math.PI / 2 && D < 3 * Math.PI / 2 ? "end" : "start",
1163
+ fontSize: "9",
1164
+ fontWeight: "700",
1165
+ fill: r.textSec,
1166
+ style: { pointerEvents: "none" }
1167
+ },
1168
+ ge(M.category, 14)
1169
+ )) : null, S ? /* @__PURE__ */ e.createElement(
1170
+ "text",
1171
+ {
1172
+ x: b.x,
1173
+ y: be ? b.y + 14 : b.y,
1174
+ textAnchor: D > Math.PI / 2 && D < 3 * Math.PI / 2 ? "end" : "start",
1175
+ dominantBaseline: "central",
1176
+ fontSize: "9",
1177
+ fontWeight: "700",
1178
+ fill: r.textSec,
1179
+ style: { pointerEvents: "none" }
1180
+ },
1181
+ P(M.originalValue)
1182
+ ) : null) : null
1183
+ );
1184
+ }),
1185
+ x ? /* @__PURE__ */ e.createElement(
1186
+ "text",
1187
+ {
1188
+ x: m,
1189
+ y: w,
1190
+ textAnchor: "middle",
1191
+ dominantBaseline: "central",
1192
+ fontSize: "16",
1193
+ fontWeight: "800",
1194
+ fill: r.text,
1195
+ style: { pointerEvents: "none" }
1196
+ },
1197
+ P(p)
1198
+ ) : null
1199
+ ), De, we, Ie, Xe), h ? /* @__PURE__ */ e.createElement(St, { items: j, theme: r, hiddenSet: ee, onToggle: Qe, position: _e, onElementSelect: de }) : null);
1200
+ }
1201
+ if (n === "bubble") {
1202
+ const l = Array.isArray(t && t.series) ? t.series.filter((N) => !ee.has(N.name)) : [], c = Array.isArray(t && t.categories) ? t.categories : [], s = Array.isArray(t && t.categoryTargets) ? t.categoryTargets : [];
1203
+ if (l.length < 2)
1204
+ return /* @__PURE__ */ e.createElement(Se, { message: "Bubble charts need at least two measures (X and Y). A third measure sets bubble size.", theme: r, chartHeight: W });
1205
+ const p = l[0], x = l[1], g = l[2] || null, E = (p.values || []).filter((N) => typeof N == "number" && Number.isFinite(N)), m = (x.values || []).filter((N) => typeof N == "number" && Number.isFinite(N));
1206
+ if (E.length === 0 || m.length === 0)
1207
+ return /* @__PURE__ */ e.createElement(Se, { message: "Not enough numeric data for a bubble chart.", theme: r, chartHeight: W });
1208
+ let w = Math.min(...E), k = Math.max(...E), y = Math.min(...m), I = Math.max(...m);
1209
+ if (w === k) {
1210
+ const N = Math.abs(k || 1) * 0.15 || 1;
1211
+ w -= N, k += N;
1212
+ }
1213
+ if (y === I) {
1214
+ const N = Math.abs(I || 1) * 0.15 || 1;
1215
+ y -= N, I += N;
1216
+ }
1217
+ const j = (k - w) * 0.08, M = (I - y) * 0.08;
1218
+ w -= j, k += j, y -= M, I += M;
1219
+ const v = g ? (g.values || []).filter((N) => typeof N == "number" && Number.isFinite(N)) : [], B = v.length ? Math.min(...v) : 0, H = (v.length ? Math.max(...v) : 1) - B || 1, G = (N) => {
1220
+ if (!g) return 7;
1221
+ const re = g.values && g.values[N];
1222
+ return typeof re != "number" || !Number.isFinite(re) ? 7 : 4 + (re - B) / H * 20;
1223
+ }, b = { top: 24, right: 20, bottom: 64, left: Math.max(52, Wt(P(I), 11) + 16) }, q = Z - b.left - b.right, le = W - b.top - b.bottom, A = (N) => b.left + (N - w) / (k - w) * q, L = (N) => b.top + (I - N) / (I - y) * le, ce = Yt(w, k, 5), oe = Yt(y, I, 5), ae = he(x.name, 0);
1224
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative", ...Be }, ...We }, /* @__PURE__ */ e.createElement("svg", { ref: R, viewBox: `0 0 ${Z} ${W}`, width: "100%", preserveAspectRatio: "xMidYMid meet", style: { display: "block", overflow: "visible", ...qe } }, oe.map((N, re) => /* @__PURE__ */ e.createElement("g", { key: `y-${re}` }, /* @__PURE__ */ e.createElement("line", { x1: b.left, y1: L(N), x2: Z - b.right, y2: L(N), stroke: r.border, strokeDasharray: "3 4" }), /* @__PURE__ */ e.createElement("text", { x: b.left - 8, y: L(N) + 4, textAnchor: "end", fontSize: "11", fill: r.textSec }, P(N)))), ce.map((N, re) => /* @__PURE__ */ e.createElement("g", { key: `x-${re}` }, /* @__PURE__ */ e.createElement("line", { x1: A(N), y1: b.top, x2: A(N), y2: W - b.bottom, stroke: r.border, strokeDasharray: "3 4" }), /* @__PURE__ */ e.createElement("text", { x: A(N), y: W - b.bottom + 18, textAnchor: "middle", fontSize: "11", fill: r.textSec }, P(N)))), /* @__PURE__ */ e.createElement("line", { x1: b.left, y1: W - b.bottom, x2: Z - b.right, y2: W - b.bottom, stroke: r.border }), /* @__PURE__ */ e.createElement("line", { x1: b.left, y1: b.top, x2: b.left, y2: W - b.bottom, stroke: r.border }), /* @__PURE__ */ e.createElement("text", { x: Z / 2, y: W - 8, textAnchor: "middle", fontSize: "11", fontWeight: "700", fill: r.textSec }, p.name), K ? /* @__PURE__ */ e.createElement("text", { x: 14, y: (b.top + W - b.bottom) / 2, textAnchor: "middle", fontSize: "11", fontWeight: "700", fill: r.textSec, transform: `rotate(-90, 14, ${(b.top + W - b.bottom) / 2})` }, K) : null, (p.values || []).map((N, re) => {
1225
+ const fe = x.values[re];
1226
+ if (typeof N != "number" || !Number.isFinite(N) || typeof fe != "number" || !Number.isFinite(fe)) return null;
1227
+ const Ne = G(re), er = c[re] || `Point ${re + 1}`, wt = g ? ` | ${g.name}: ${P(g.values[re])}` : "", tr = { "data-tip-cat": er, "data-tip-ser": `${x.name} (X:${P(N)})${wt}`, "data-tip-val": P(fe), "data-tip-color": ae }, Ot = s[re];
1228
+ return /* @__PURE__ */ e.createElement(
1229
+ "circle",
1230
+ {
1231
+ key: `bubble-${re}`,
1232
+ cx: A(N),
1233
+ cy: L(fe),
1234
+ r: Ne,
1235
+ fill: ae,
1236
+ opacity: "0.72",
1237
+ stroke: r.surfaceBg || r.background || "#fff",
1238
+ strokeWidth: "1.5",
1239
+ style: typeof $ == "function" && Ot ? { cursor: "pointer" } : void 0,
1240
+ onClick: typeof $ == "function" && Ot ? () => $(Ot) : void 0,
1241
+ ...tr
1242
+ }
1243
+ );
1244
+ }), S && (p.values || []).map((N, re) => {
1245
+ const fe = x.values[re];
1246
+ if (typeof N != "number" || !Number.isFinite(N) || typeof fe != "number" || !Number.isFinite(fe)) return null;
1247
+ const Ne = G(re);
1248
+ return /* @__PURE__ */ e.createElement("text", { key: `bubble-lbl-${re}`, x: A(N), y: L(fe) - Ne - 4, textAnchor: "middle", fontSize: "9", fontWeight: "700", fill: r.textSec, style: { pointerEvents: "none" } }, c[re] || P(fe));
1249
+ })), De, we, Ie, Xe), h ? /* @__PURE__ */ e.createElement(St, { items: [{ label: `${p.name} vs ${x.name}${g ? ` (size: ${g.name})` : ""}`, color: ae }], theme: r, hiddenSet: ee, onToggle: Qe, position: _e }) : null);
1250
+ }
1251
+ if (n === "radar") {
1252
+ const l = Array.isArray(t && t.categories) ? t.categories : [], c = Array.isArray(t && t.series) ? t.series.filter((M) => !ee.has(M.name)) : [];
1253
+ if (l.length < 3)
1254
+ return /* @__PURE__ */ e.createElement(Se, { message: "Radar charts need at least 3 categories (spokes).", theme: r, chartHeight: W });
1255
+ if (c.length === 0)
1256
+ return /* @__PURE__ */ e.createElement(Se, { message: "Radar charts need at least one measure series.", theme: r, chartHeight: W });
1257
+ const s = c.flatMap((M) => (M.values || []).filter((v) => typeof v == "number" && Number.isFinite(v))), p = s.length ? Math.max(...s, 0) : 1, x = 60, g = Z / 2, E = W / 2, m = Math.min(g, E) - x, w = l.length, k = 2 * Math.PI / w, y = (M, v) => {
1258
+ const B = M * k - Math.PI / 2, D = m * (v / (p || 1));
1259
+ return { x: g + D * Math.cos(B), y: E + D * Math.sin(B) };
1260
+ }, I = (M) => {
1261
+ const v = M * k - Math.PI / 2, B = m + 18;
1262
+ return { x: g + B * Math.cos(v), y: E + B * Math.sin(v) };
1263
+ }, j = c.map((M, v) => ({ label: M.name, color: he(M.name, v) }));
1264
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative", ...Be }, ...We }, /* @__PURE__ */ e.createElement("svg", { ref: R, viewBox: `0 0 ${Z} ${W}`, width: "100%", preserveAspectRatio: "xMidYMid meet", style: { display: "block", ...qe } }, [0.25, 0.5, 0.75, 1].map((M) => {
1265
+ const v = l.map((B, D) => y(D, p * M));
1266
+ return /* @__PURE__ */ e.createElement("polygon", { key: `grid-${M}`, points: v.map((B) => `${B.x},${B.y}`).join(" "), fill: "none", stroke: r.border, strokeWidth: "1" });
1267
+ }), l.map((M, v) => {
1268
+ const B = y(v, p);
1269
+ return /* @__PURE__ */ e.createElement("line", { key: `spoke-${v}`, x1: g, y1: E, x2: B.x, y2: B.y, stroke: r.border, strokeWidth: "1" });
1270
+ }), l.map((M, v) => {
1271
+ const B = I(v), D = Math.abs(B.x - g) < 10 ? "middle" : B.x < g ? "end" : "start";
1272
+ return /* @__PURE__ */ e.createElement("text", { key: `spoke-lbl-${v}`, x: B.x, y: B.y + 4, textAnchor: D, fontSize: "10", fill: r.textSec }, ge(M, 14));
1273
+ }), c.map((M, v) => {
1274
+ const B = he(M.name, v), D = l.map((G, se) => {
1275
+ const b = M.values && M.values[se];
1276
+ return y(se, typeof b == "number" && Number.isFinite(b) ? b : 0);
1277
+ }), H = D.map((G) => `${G.x},${G.y}`).join(" ");
1278
+ return /* @__PURE__ */ e.createElement("g", { key: `radar-${v}` }, /* @__PURE__ */ e.createElement("polygon", { points: H, fill: B, fillOpacity: "0.18", stroke: B, strokeWidth: "2", style: { pointerEvents: "none" } }), D.map((G, se) => {
1279
+ const b = M.values && M.values[se], q = { "data-tip-cat": l[se], "data-tip-ser": M.name, "data-tip-val": P(b), "data-tip-color": B };
1280
+ return /* @__PURE__ */ e.createElement("circle", { key: `radar-dot-${v}-${se}`, cx: G.x, cy: G.y, r: "4", fill: B, stroke: r.surfaceBg || "#fff", strokeWidth: "1.5", ...q });
1281
+ }));
1282
+ }), [0.5, 1].map((M) => /* @__PURE__ */ e.createElement("text", { key: `scale-${M}`, x: g + 4, y: E - m * M + 4, fontSize: "9", fill: r.textSec }, P(p * M)))), De, we, Ie, Xe), h ? /* @__PURE__ */ e.createElement(St, { items: j, theme: r, hiddenSet: ee, onToggle: Qe, position: _e, onElementSelect: de }) : null);
1283
+ }
1284
+ if (n === "funnel") {
1285
+ const l = Array.isArray(t && t.categories) ? t.categories : [], c = Array.isArray(t && t.series) && t.series.length > 0 ? t.series[0] : null;
1286
+ if (!c || l.length === 0)
1287
+ return /* @__PURE__ */ e.createElement(Se, { message: "Funnel charts need categories and at least one measure.", theme: r, chartHeight: W });
1288
+ const s = l.map((k, y) => {
1289
+ const I = c.values && c.values[y];
1290
+ return typeof I == "number" && Number.isFinite(I) ? Math.abs(I) : 0;
1291
+ }), p = Math.max(...s, 1), x = { top: 24, right: 20, bottom: 24, left: 20 }, g = Z - x.left - x.right, m = (W - x.top - x.bottom) / l.length, w = l.map((k, y) => ({ label: k, color: he(k, y) }));
1292
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative", ...Be }, ...We }, /* @__PURE__ */ e.createElement("svg", { ref: R, viewBox: `0 0 ${Z} ${W}`, width: "100%", preserveAspectRatio: "xMidYMid meet", style: { display: "block", ...qe } }, l.map((k, y) => {
1293
+ const I = s[y] / p, j = y + 1 < l.length ? s[y + 1] / p : s[y] / p * 0.5, M = g * I, v = g * j, B = Z / 2, D = x.top + y * m, H = he(k, y), G = [
1294
+ `${B - M / 2},${D}`,
1295
+ `${B + M / 2},${D}`,
1296
+ `${B + v / 2},${D + m - 1}`,
1297
+ `${B - v / 2},${D + m - 1}`
1298
+ ].join(" ");
1299
+ return /* @__PURE__ */ e.createElement("g", { key: `funnel-${y}` }, /* @__PURE__ */ e.createElement(
1300
+ "polygon",
1301
+ {
1302
+ points: G,
1303
+ fill: H,
1304
+ opacity: "0.88",
1305
+ stroke: r.surfaceBg || "#fff",
1306
+ strokeWidth: "1.5",
1307
+ "data-tip-cat": k,
1308
+ "data-tip-ser": c.name,
1309
+ "data-tip-val": P(s[y]),
1310
+ "data-tip-color": H
1311
+ }
1312
+ ), /* @__PURE__ */ e.createElement("text", { x: B, y: D + m / 2 + 4, textAnchor: "middle", fontSize: "11", fontWeight: "700", fill: "#fff", style: { pointerEvents: "none" } }, ge(k, Math.max(4, Math.floor(M / 7))), " ", S ? `— ${P(s[y])}` : ""));
1313
+ })), De, we, Ie, Xe), h ? /* @__PURE__ */ e.createElement(St, { items: w, theme: r, hiddenSet: ee, onToggle: Qe, position: _e, onElementSelect: de }) : null);
1314
+ }
1315
+ if (n === "histogram") {
1316
+ const l = Array.isArray(t && t.series) && t.series.length > 0 ? t.series[0] : null;
1317
+ if (!l)
1318
+ return /* @__PURE__ */ e.createElement(Se, { message: "Histogram needs at least one numeric measure.", theme: r, chartHeight: W });
1319
+ const c = (l.values || []).filter((D) => typeof D == "number" && Number.isFinite(D));
1320
+ if (c.length === 0)
1321
+ return /* @__PURE__ */ e.createElement(Se, { message: "No numeric values for histogram.", theme: r, chartHeight: W });
1322
+ const s = Math.max(4, Math.min(20, Math.ceil(1 + Math.log2(c.length)))), p = Math.min(...c), g = (Math.max(...c) - p) / s || 1, E = Array.from({ length: s }, (D, H) => ({
1323
+ low: p + H * g,
1324
+ high: p + (H + 1) * g,
1325
+ count: 0
1326
+ }));
1327
+ c.forEach((D) => {
1328
+ const H = Math.min(Math.floor((D - p) / g), s - 1);
1329
+ E[H].count++;
1330
+ });
1331
+ const m = Math.max(...E.map((D) => D.count), 1), k = { top: 24, right: 16, bottom: 44, left: Math.max(46, Wt(String(m), 11) + 16) }, y = Z - k.left - k.right, I = W - k.top - k.bottom, j = y / s, M = (D) => k.top + (m - D) / m * I, v = he(l.name, 0), B = Yt(0, m, U || 5);
1332
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative", ...Be }, ...We }, /* @__PURE__ */ e.createElement("svg", { ref: R, viewBox: `0 0 ${Z} ${W}`, width: "100%", preserveAspectRatio: "xMidYMid meet", style: { display: "block", ...qe } }, B.map((D, H) => /* @__PURE__ */ e.createElement("g", { key: `htick-${H}` }, /* @__PURE__ */ e.createElement("line", { x1: k.left, y1: M(D), x2: Z - k.right, y2: M(D), stroke: r.border, strokeDasharray: "3 4" }), /* @__PURE__ */ e.createElement("text", { x: k.left - 8, y: M(D) + 4, textAnchor: "end", fontSize: "11", fill: r.textSec }, D))), /* @__PURE__ */ e.createElement("line", { x1: k.left, y1: k.top + I, x2: Z - k.right, y2: k.top + I, stroke: r.textSec, strokeWidth: "1" }), E.map((D, H) => {
1333
+ const G = k.left + H * j, se = M(D.count), b = Math.max(1, k.top + I - se);
1334
+ return /* @__PURE__ */ e.createElement("g", { key: `hbar-${H}` }, /* @__PURE__ */ e.createElement(
1335
+ "rect",
1336
+ {
1337
+ x: G,
1338
+ y: se,
1339
+ width: Math.max(1, j - 1),
1340
+ height: b,
1341
+ fill: v,
1342
+ opacity: "0.88",
1343
+ "data-tip-cat": `${P(D.low)}–${P(D.high)}`,
1344
+ "data-tip-ser": "Count",
1345
+ "data-tip-val": String(D.count),
1346
+ "data-tip-color": v
1347
+ }
1348
+ ), S && D.count > 0 ? /* @__PURE__ */ e.createElement("text", { x: G + j / 2, y: se - 4, textAnchor: "middle", fontSize: "9", fontWeight: "700", fill: r.textSec, style: { pointerEvents: "none" } }, D.count) : null);
1349
+ }), E.filter((D, H) => H % Math.max(1, Math.floor(s / 6)) === 0 || H === s - 1).map((D, H) => /* @__PURE__ */ e.createElement("text", { key: `hlbl-${H}`, x: k.left + E.indexOf(D) * j + j / 2, y: k.top + I + 18, textAnchor: "middle", fontSize: "10", fill: r.textSec }, P(D.low)))), De, we, Ie, Xe));
1350
+ }
1351
+ if (n === "boxplot") {
1352
+ const l = Array.isArray(t && t.categories) ? t.categories : [], c = Array.isArray(t && t.series) ? t.series.filter((k) => !ee.has(k.name)) : [], s = r.chartBg || r.surface || "#fff", p = r.text || "#333", x = r.border || "#ccc", g = r.gridLine || r.border || "#eee";
1353
+ if (c.length < 5)
1354
+ return /* @__PURE__ */ e.createElement(Se, { message: "Box Plot needs 5 measures: Min, Q1, Median, Q3, Max.", theme: r, chartHeight: W });
1355
+ const E = l.map((k, y) => [
1356
+ c[0].values[y] ?? 0,
1357
+ c[1].values[y] ?? 0,
1358
+ c[2].values[y] ?? 0,
1359
+ c[3].values[y] ?? 0,
1360
+ c[4].values[y] ?? 0
1361
+ ]), m = he(c[2].name, 0), w = {
1362
+ backgroundColor: s,
1363
+ tooltip: { trigger: "axis", formatter: (k) => {
1364
+ const y = k[0];
1365
+ return `${y.name}<br/>Min: ${P(y.data[1])}<br/>Q1: ${P(y.data[2])}<br/>Median: ${P(y.data[3])}<br/>Q3: ${P(y.data[4])}<br/>Max: ${P(y.data[5])}`;
1366
+ } },
1367
+ xAxis: { type: "category", data: l.map((k) => ge(String(k), 14)), axisLabel: { color: p, fontSize: 10 }, axisLine: { lineStyle: { color: x } } },
1368
+ yAxis: { type: "value", axisLabel: { color: p, fontSize: 10, formatter: P }, axisLine: { lineStyle: { color: x } }, splitLine: { lineStyle: { color: g } }, name: K || "", nameTextStyle: { color: p } },
1369
+ grid: { left: 60, right: 20, top: 20, bottom: 60 },
1370
+ series: [{ type: "boxplot", data: E, itemStyle: { color: m, borderColor: m } }]
1371
+ };
1372
+ return /* @__PURE__ */ e.createElement("div", { style: { width: "100%", height: f, background: s, borderRadius: r.radiusSm || "8px", overflow: "hidden" } }, /* @__PURE__ */ e.createElement(nr, { chartType: n, echartsRef: C, option: w }));
1373
+ }
1374
+ if (n === "nightingale") {
1375
+ const l = Array.isArray(t && t.categories) ? t.categories : [], c = Array.isArray(t && t.series) ? t.series.filter((E) => !ee.has(E.name)) : [], s = r.chartBg || r.surface || "#fff", p = r.text || "#333";
1376
+ if (l.length === 0 || c.length === 0)
1377
+ return /* @__PURE__ */ e.createElement(Se, { message: "Nightingale charts need categories and at least one measure.", theme: r, chartHeight: W });
1378
+ const x = l.map((E, m) => {
1379
+ const w = c[0] && c[0].values ? c[0].values[m] ?? 0 : 0;
1380
+ return { name: String(E), value: w, itemStyle: { color: he(String(E), m) } };
1381
+ }), g = {
1382
+ backgroundColor: s,
1383
+ tooltip: { trigger: "item", formatter: (E) => `${E.name}: ${P(E.value)}` },
1384
+ legend: { show: h, textStyle: { color: p }, type: "scroll" },
1385
+ series: [{
1386
+ type: "bar",
1387
+ coordinateSystem: "polar",
1388
+ data: x,
1389
+ label: { show: S, position: "outside", formatter: (E) => P(E.value), color: p, fontSize: 10 }
1390
+ }],
1391
+ polar: { radius: ["10%", "75%"] },
1392
+ angleAxis: { type: "category", data: l.map((E) => ge(String(E), 12)), axisLabel: { color: p, fontSize: 9 } },
1393
+ radiusAxis: { axisLabel: { color: p, fontSize: 9, formatter: P } }
1394
+ };
1395
+ return /* @__PURE__ */ e.createElement("div", { style: { width: "100%", height: f, background: s, borderRadius: r.radiusSm || "8px", overflow: "hidden" } }, /* @__PURE__ */ e.createElement(nr, { chartType: n, echartsRef: C, option: g }));
1396
+ }
1397
+ if (n === "heatmap") {
1398
+ const l = Array.isArray(t && t.categories) ? t.categories : [], c = Array.isArray(t && t.series) ? t.series.filter((H) => !ee.has(H.name)) : [];
1399
+ if (l.length === 0 || c.length === 0)
1400
+ return /* @__PURE__ */ e.createElement(Se, { message: "Heatmap needs categories and at least one measure.", theme: r, chartHeight: W });
1401
+ const s = c.flatMap((H) => (H.values || []).filter((G) => typeof G == "number" && Number.isFinite(G))), p = s.length ? Math.min(...s) : 0, g = (s.length ? Math.max(...s) : 1) - p || 1, E = (H) => {
1402
+ const G = Math.max(0, Math.min(1, (H - p) / g)), se = Math.round(59 + G * 180), b = Math.round(130 - G * 62), q = Math.round(246 - G * 178);
1403
+ return `rgb(${se},${b},${q})`;
1404
+ }, m = 2, w = Math.min(140, Math.max(60, c.reduce((H, G) => Math.max(H, Wt(G.name, 11)), 0) + 10)), k = 32, y = Z, I = W, j = y - w - 8, M = I - k - 8, v = Math.max(20, j / l.length), B = Math.max(20, M / c.length), D = c.map((H, G) => ({ label: H.name, color: Ce(G, r, Ee) }));
1405
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative", ...Be }, ...We }, /* @__PURE__ */ e.createElement(
1406
+ "svg",
1407
+ {
1408
+ ref: R,
1409
+ viewBox: `0 0 ${y} ${I}`,
1410
+ preserveAspectRatio: "xMidYMid meet",
1411
+ style: { width: "100%", height: "auto", display: "block", maxWidth: "100%", ...qe },
1412
+ role: "img",
1413
+ "aria-label": t.title || "Heatmap"
1414
+ },
1415
+ l.map((H, G) => /* @__PURE__ */ e.createElement(
1416
+ "text",
1417
+ {
1418
+ key: `hm-col-${G}`,
1419
+ x: w + G * v + v / 2,
1420
+ y: k - 6,
1421
+ textAnchor: "middle",
1422
+ fontSize: "10",
1423
+ fill: r.textSec,
1424
+ style: { pointerEvents: "none" }
1425
+ },
1426
+ ge(H, Math.max(4, Math.floor(v / 6.5)))
1427
+ )),
1428
+ c.map((H, G) => /* @__PURE__ */ e.createElement(
1429
+ "text",
1430
+ {
1431
+ key: `hm-row-${G}`,
1432
+ x: w - 6,
1433
+ y: k + G * B + B / 2 + 4,
1434
+ textAnchor: "end",
1435
+ fontSize: "11",
1436
+ fill: r.textSec,
1437
+ style: { pointerEvents: "none" }
1438
+ },
1439
+ ge(H.name, Math.max(6, Math.floor(w / 6.5)))
1440
+ )),
1441
+ c.map(
1442
+ (H, G) => l.map((se, b) => {
1443
+ const q = H.values && H.values[b];
1444
+ if (q == null) return null;
1445
+ const le = E(q), A = w + b * v, L = k + G * B;
1446
+ return /* @__PURE__ */ e.createElement(
1447
+ "rect",
1448
+ {
1449
+ key: `hm-cell-${G}-${b}`,
1450
+ x: A + m,
1451
+ y: L + m,
1452
+ width: Math.max(1, v - m * 2),
1453
+ height: Math.max(1, B - m * 2),
1454
+ rx: "3",
1455
+ fill: le,
1456
+ "data-tip-cat": se,
1457
+ "data-tip-ser": H.name,
1458
+ "data-tip-val": P(q),
1459
+ "data-tip-color": le
1460
+ }
1461
+ );
1462
+ })
1463
+ ),
1464
+ S && c.map(
1465
+ (H, G) => l.map((se, b) => {
1466
+ const q = H.values && H.values[b];
1467
+ if (q == null || v < 36 || B < 18) return null;
1468
+ const A = Math.max(0, Math.min(1, (q - p) / g)) > 0.5 ? "#fff" : r.text;
1469
+ return /* @__PURE__ */ e.createElement(
1470
+ "text",
1471
+ {
1472
+ key: `hm-label-${G}-${b}`,
1473
+ x: w + b * v + v / 2,
1474
+ y: k + G * B + B / 2 + 4,
1475
+ textAnchor: "middle",
1476
+ fontSize: "9",
1477
+ fontWeight: "700",
1478
+ fill: A,
1479
+ style: { pointerEvents: "none" }
1480
+ },
1481
+ P(q)
1482
+ );
1483
+ })
1484
+ )
1485
+ ), De, we, Ie, Xe), h ? /* @__PURE__ */ e.createElement(St, { items: D, theme: r, hiddenSet: ee, onToggle: Qe, position: _e, onElementSelect: de }) : null);
1486
+ }
1487
+ if (n === "bar3d") {
1488
+ const l = Array.isArray(t && t.categories) ? t.categories : [], c = Array.isArray(t && t.series) ? t.series.filter((m) => !ee.has(m.name)) : [], s = r.chartBg || r.surface || "#fff", p = r.text || "#333", x = r.border || "#ccc", g = [];
1489
+ c.forEach((m, w) => {
1490
+ l.forEach((k, y) => {
1491
+ const I = m.values[y];
1492
+ I != null && g.push([y, w, I]);
1493
+ });
1494
+ });
1495
+ const E = {
1496
+ backgroundColor: s,
1497
+ legend: {
1498
+ show: h,
1499
+ data: c.map((m) => m.name),
1500
+ textStyle: { color: p },
1501
+ type: "scroll"
1502
+ },
1503
+ tooltip: {
1504
+ formatter: (m) => {
1505
+ const w = l[m.value[0]] || "", k = c[m.value[1]] ? c[m.value[1]].name : "";
1506
+ return `${w} / ${k}: <b>${P(m.value[2])}</b>`;
1507
+ }
1508
+ },
1509
+ grid3D: {
1510
+ boxWidth: 200,
1511
+ boxDepth: 80,
1512
+ viewControl: { projection: "perspective", autoRotate: !1 },
1513
+ light: { main: { intensity: 1.2, shadow: !1 }, ambient: { intensity: 0.4 } }
1514
+ },
1515
+ xAxis3D: {
1516
+ type: "category",
1517
+ data: l.map((m) => ge(String(m), 12)),
1518
+ axisLabel: { color: p, fontSize: 10 },
1519
+ axisLine: { lineStyle: { color: x } },
1520
+ name: ""
1521
+ },
1522
+ yAxis3D: {
1523
+ type: "category",
1524
+ data: c.map((m) => ge(String(m.name), 12)),
1525
+ axisLabel: { color: p, fontSize: 10 },
1526
+ axisLine: { lineStyle: { color: x } }
1527
+ },
1528
+ zAxis3D: {
1529
+ type: "value",
1530
+ axisLabel: { color: p, fontSize: 10, formatter: P },
1531
+ axisLine: { lineStyle: { color: x } },
1532
+ name: K || "",
1533
+ nameTextStyle: { color: p }
1534
+ },
1535
+ series: [{
1536
+ type: "bar3D",
1537
+ data: g.map((m) => ({
1538
+ value: m,
1539
+ itemStyle: { color: Ce(m[1], r, Ee), opacity: 0.9 }
1540
+ })),
1541
+ shading: "lambert",
1542
+ label: {
1543
+ show: S,
1544
+ formatter: (m) => P(m.value[2]),
1545
+ textStyle: { color: p, fontSize: 10 }
1546
+ },
1547
+ emphasis: { label: { show: !0 }, itemStyle: { opacity: 1 } }
1548
+ }]
1549
+ };
1550
+ return /* @__PURE__ */ e.createElement("div", { style: { width: "100%", height: f, background: s, borderRadius: r.radiusSm || "8px", overflow: "hidden" } }, /* @__PURE__ */ e.createElement(nr, { chartType: n, echartsRef: C, option: E }));
1551
+ }
1552
+ if (n === "line3d") {
1553
+ const l = Array.isArray(t && t.categories) ? t.categories : [], c = Array.isArray(t && t.series) ? t.series.filter((m) => !ee.has(m.name)) : [], s = r.chartBg || r.surface || "#fff", p = r.text || "#333", x = r.border || "#ccc", g = c.map((m, w) => ({
1554
+ type: "line3D",
1555
+ data: l.map((k, y) => {
1556
+ const I = m.values[y];
1557
+ return [y, w, I ?? 0];
1558
+ }),
1559
+ lineStyle: { color: Ce(w, r, Ee), width: 3, opacity: 0.9 },
1560
+ name: m.name
1561
+ })), E = {
1562
+ backgroundColor: s,
1563
+ legend: { show: h, data: c.map((m) => m.name), textStyle: { color: p }, type: "scroll" },
1564
+ tooltip: {
1565
+ formatter: (m) => {
1566
+ const w = l[m.value[0]] || "", k = c[m.value[1]] ? c[m.value[1]].name : "";
1567
+ return `${w} / ${k}: <b>${P(m.value[2])}</b>`;
1568
+ }
1569
+ },
1570
+ grid3D: {
1571
+ boxWidth: 200,
1572
+ boxDepth: 80,
1573
+ viewControl: { projection: "perspective", autoRotate: !1 },
1574
+ light: { main: { intensity: 1.2, shadow: !1 }, ambient: { intensity: 0.4 } }
1575
+ },
1576
+ xAxis3D: {
1577
+ type: "category",
1578
+ data: l.map((m) => ge(String(m), 12)),
1579
+ axisLabel: { color: p, fontSize: 10 },
1580
+ axisLine: { lineStyle: { color: x } }
1581
+ },
1582
+ yAxis3D: {
1583
+ type: "category",
1584
+ data: c.map((m) => ge(String(m.name), 12)),
1585
+ axisLabel: { color: p, fontSize: 10 },
1586
+ axisLine: { lineStyle: { color: x } }
1587
+ },
1588
+ zAxis3D: {
1589
+ type: "value",
1590
+ axisLabel: { color: p, fontSize: 10, formatter: P },
1591
+ axisLine: { lineStyle: { color: x } },
1592
+ name: K || "",
1593
+ nameTextStyle: { color: p }
1594
+ },
1595
+ series: g
1596
+ };
1597
+ return /* @__PURE__ */ e.createElement("div", { style: { width: "100%", height: f, background: s, borderRadius: r.radiusSm || "8px", overflow: "hidden" } }, /* @__PURE__ */ e.createElement(nr, { chartType: n, echartsRef: C, option: E }));
1598
+ }
1599
+ if (n === "scatter3d") {
1600
+ const l = Array.isArray(t && t.categories) ? t.categories : [], c = Array.isArray(t && t.series) ? t.series.filter((y) => !ee.has(y.name)) : [], s = r.chartBg || r.surface || "#fff", p = r.text || "#333", x = r.border || "#ccc";
1601
+ if (c.length < 2)
1602
+ return /* @__PURE__ */ e.createElement(Se, { message: "3D Scatter needs at least two numeric measures (X and Y).", theme: r, chartHeight: W });
1603
+ const g = c[0], E = c[1], m = c[2] || null, w = l.map((y, I) => ({
1604
+ value: [g.values[I] ?? 0, E.values[I] ?? 0, m ? m.values[I] ?? 0 : I],
1605
+ name: String(y)
1606
+ })), k = {
1607
+ backgroundColor: s,
1608
+ tooltip: {
1609
+ formatter: (y) => `${l[y.dataIndex] || ""}<br/>X=${P(y.value[0])}, Y=${P(y.value[1])}, Z=${P(y.value[2])}`
1610
+ },
1611
+ grid3D: {
1612
+ boxWidth: 200,
1613
+ boxDepth: 80,
1614
+ viewControl: { projection: "perspective", autoRotate: !1 },
1615
+ light: { main: { intensity: 1.2, shadow: !1 }, ambient: { intensity: 0.4 } }
1616
+ },
1617
+ xAxis3D: {
1618
+ type: "value",
1619
+ name: g.name,
1620
+ axisLabel: { color: p, fontSize: 10, formatter: P },
1621
+ axisLine: { lineStyle: { color: x } },
1622
+ nameTextStyle: { color: p }
1623
+ },
1624
+ yAxis3D: {
1625
+ type: "value",
1626
+ name: E.name,
1627
+ axisLabel: { color: p, fontSize: 10, formatter: P },
1628
+ axisLine: { lineStyle: { color: x } },
1629
+ nameTextStyle: { color: p }
1630
+ },
1631
+ zAxis3D: {
1632
+ type: "value",
1633
+ name: m ? m.name : "Index",
1634
+ axisLabel: { color: p, fontSize: 10, formatter: P },
1635
+ axisLine: { lineStyle: { color: x } },
1636
+ nameTextStyle: { color: p }
1637
+ },
1638
+ series: [{
1639
+ type: "scatter3D",
1640
+ data: w,
1641
+ symbolSize: 8,
1642
+ itemStyle: { color: Ce(0, r, Ee), opacity: 0.85 },
1643
+ label: {
1644
+ show: S,
1645
+ formatter: (y) => String(l[y.dataIndex] || ""),
1646
+ textStyle: { color: p, fontSize: 10 }
1647
+ },
1648
+ emphasis: { itemStyle: { opacity: 1 } }
1649
+ }]
1650
+ };
1651
+ return /* @__PURE__ */ e.createElement("div", { style: { width: "100%", height: f, background: s, borderRadius: r.radiusSm || "8px", overflow: "hidden" } }, /* @__PURE__ */ e.createElement(nr, { chartType: n, echartsRef: C, option: k }));
1652
+ }
1653
+ if (n === "range") {
1654
+ const l = Array.isArray(t && t.categories) ? t.categories : [], c = Array.isArray(t && t.series) ? t.series.filter((y) => !ee.has(y.name)) : [], s = r.chartBg || r.surface || "#fff", p = r.text || "#333", x = r.border || "#ccc", g = r.gridLine || r.border || "#eee";
1655
+ if (c.length < 2)
1656
+ return /* @__PURE__ */ e.createElement(Se, { message: "Range chart needs at least two measures (low and high values).", theme: r, chartHeight: W });
1657
+ const E = [];
1658
+ for (let y = 0; y + 1 < c.length; y += 2)
1659
+ E.push({ low: c[y], high: c[y + 1] });
1660
+ const m = [];
1661
+ E.forEach((y, I) => {
1662
+ const j = Ce(I, r, Ee);
1663
+ m.push({
1664
+ type: "bar",
1665
+ name: `_base_${I}`,
1666
+ data: l.map((M, v) => Math.min(y.low.values[v] ?? 0, y.high.values[v] ?? 0)),
1667
+ stack: `range_${I}`,
1668
+ itemStyle: { opacity: 0 },
1669
+ emphasis: { disabled: !0 },
1670
+ silent: !0,
1671
+ legendHoverLink: !1
1672
+ }), m.push({
1673
+ type: "bar",
1674
+ name: `${y.low.name} – ${y.high.name}`,
1675
+ data: l.map((M, v) => Math.abs((y.high.values[v] ?? 0) - (y.low.values[v] ?? 0))),
1676
+ stack: `range_${I}`,
1677
+ itemStyle: { color: j, opacity: 0.9 },
1678
+ label: {
1679
+ show: S,
1680
+ position: "inside",
1681
+ formatter: (M) => {
1682
+ const v = M.dataIndex, B = y.low.values[v] ?? 0, D = y.high.values[v] ?? 0;
1683
+ return `${P(Math.min(B, D))}–${P(Math.max(B, D))}`;
1684
+ },
1685
+ color: p,
1686
+ fontSize: 10
1687
+ },
1688
+ tooltip: {
1689
+ formatter: (M) => {
1690
+ const v = M.dataIndex;
1691
+ return `${l[v]}<br/>${y.low.name}: ${P(y.low.values[v] ?? 0)}<br/>${y.high.name}: ${P(y.high.values[v] ?? 0)}`;
1692
+ }
1693
+ }
1694
+ });
1695
+ });
1696
+ const w = E.map((y, I) => ({ label: `${y.low.name} – ${y.high.name}`, color: Ce(I, r, Ee) })), k = {
1697
+ backgroundColor: s,
1698
+ tooltip: { trigger: "axis" },
1699
+ xAxis: {
1700
+ type: "category",
1701
+ data: l.map((y) => ge(String(y), 14)),
1702
+ axisLabel: { color: p, fontSize: 10 },
1703
+ axisLine: { lineStyle: { color: x } },
1704
+ splitLine: { show: !1 }
1705
+ },
1706
+ yAxis: {
1707
+ type: "value",
1708
+ name: K || "",
1709
+ axisLabel: { color: p, fontSize: 10, formatter: P },
1710
+ axisLine: { lineStyle: { color: x } },
1711
+ splitLine: { lineStyle: { color: g } },
1712
+ nameTextStyle: { color: p }
1713
+ },
1714
+ grid: { left: 60, right: 20, top: 20, bottom: 60 },
1715
+ series: m
1716
+ };
1717
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { style: { width: "100%", height: f, background: s, borderRadius: r.radiusSm || "8px", overflow: "hidden" } }, /* @__PURE__ */ e.createElement(nr, { chartType: n, echartsRef: C, option: k })), h ? /* @__PURE__ */ e.createElement(St, { items: w, theme: r, hiddenSet: ee, onToggle: Qe, position: _e, onElementSelect: de }) : null);
1718
+ }
1719
+ if (n === "scatter") {
1720
+ const l = Array.isArray(t && t.series) ? t.series.filter((A) => !ee.has(A.name)) : [], c = Array.isArray(t && t.categories) ? t.categories : [], s = Array.isArray(t && t.categoryTargets) ? t.categoryTargets : [];
1721
+ if (l.length < 2)
1722
+ return /* @__PURE__ */ e.createElement(Se, { message: "Scatter charts need at least two numeric measures (X and Y).", theme: r, chartHeight: W });
1723
+ const p = l[0], x = l.slice(1), g = (p.values || []).filter((A) => typeof A == "number" && Number.isFinite(A)), E = x.flatMap((A) => (A.values || []).filter((L) => typeof L == "number" && Number.isFinite(L)));
1724
+ if (g.length === 0 || E.length === 0)
1725
+ return /* @__PURE__ */ e.createElement(Se, { message: "Not enough numeric data for a scatter chart.", theme: r, chartHeight: W });
1726
+ let m = Math.min(...g), w = Math.max(...g), k = Math.min(...E), y = Math.max(...E);
1727
+ if (m === w) {
1728
+ const A = Math.abs(w || 1) * 0.15 || 1;
1729
+ m -= A, w += A;
1730
+ }
1731
+ if (k === y) {
1732
+ const A = Math.abs(y || 1) * 0.15 || 1;
1733
+ k -= A, y += A;
1734
+ }
1735
+ const I = (w - m) * 0.06, j = (y - k) * 0.06;
1736
+ m -= I, w += I, k -= j, y += j;
1737
+ const v = { top: 24, right: 20, bottom: 64, left: Math.max(52, Wt(P(y), 11) + 16) }, B = Z - v.left - v.right, D = W - v.top - v.bottom, H = (A) => v.left + (A - m) / (w - m) * B, G = (A) => v.top + (y - A) / (y - k) * D, se = Yt(m, w, 5), b = Yt(k, y, 5), q = x.map((A, L) => ({ label: A.name, color: he(A.name, L) })), le = typeof $ == "function";
1738
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { style: { position: "relative", width: "100%" }, ...We }, /* @__PURE__ */ e.createElement(
1739
+ "svg",
1740
+ {
1741
+ ref: R,
1742
+ viewBox: `0 0 ${Z} ${W}`,
1743
+ width: "100%",
1744
+ preserveAspectRatio: "xMidYMid meet",
1745
+ style: { display: "block", overflow: "visible" }
1746
+ },
1747
+ b.map((A, L) => /* @__PURE__ */ e.createElement("g", { key: `y-tick-${L}` }, /* @__PURE__ */ e.createElement("line", { x1: v.left, y1: G(A), x2: Z - v.right, y2: G(A), stroke: r.border, strokeDasharray: "3 4" }), /* @__PURE__ */ e.createElement("text", { x: v.left - 8, y: G(A) + 4, textAnchor: "end", fontSize: "11", fill: r.textSec, style: { pointerEvents: "none" } }, P(A)))),
1748
+ se.map((A, L) => /* @__PURE__ */ e.createElement("g", { key: `x-tick-${L}` }, /* @__PURE__ */ e.createElement("line", { x1: H(A), y1: v.top, x2: H(A), y2: W - v.bottom, stroke: r.border, strokeDasharray: "3 4" }), /* @__PURE__ */ e.createElement("text", { x: H(A), y: W - v.bottom + 18, textAnchor: "middle", fontSize: "11", fill: r.textSec, style: { pointerEvents: "none" } }, P(A)))),
1749
+ /* @__PURE__ */ e.createElement("line", { x1: v.left, y1: W - v.bottom, x2: Z - v.right, y2: W - v.bottom, stroke: r.border }),
1750
+ /* @__PURE__ */ e.createElement("line", { x1: v.left, y1: v.top, x2: v.left, y2: W - v.bottom, stroke: r.border }),
1751
+ /* @__PURE__ */ e.createElement("text", { x: Z / 2, y: W - 8, textAnchor: "middle", fontSize: "11", fontWeight: "700", fill: r.textSec, style: { pointerEvents: "none" } }, p.name),
1752
+ K ? /* @__PURE__ */ e.createElement("text", { x: 14, y: (v.top + W - v.bottom) / 2, textAnchor: "middle", fontSize: "11", fontWeight: "700", fill: r.textSec, transform: `rotate(-90, 14, ${(v.top + W - v.bottom) / 2})`, style: { pointerEvents: "none" } }, K) : null,
1753
+ x.map((A, L) => {
1754
+ const ce = he(A.name, L);
1755
+ return (A.values || []).map((oe, ae) => {
1756
+ const N = p.values[ae];
1757
+ if (typeof N != "number" || !Number.isFinite(N) || typeof oe != "number" || !Number.isFinite(oe)) return null;
1758
+ const re = H(N), fe = G(oe), Ne = c[ae] || `Point ${ae + 1}`, er = s[ae], wt = {
1759
+ "data-tip-cat": Ne,
1760
+ "data-tip-ser": `${A.name} (${p.name}=${P(N)})`,
1761
+ "data-tip-val": P(oe),
1762
+ "data-tip-color": ce
1763
+ };
1764
+ return e.cloneElement(Rt(re, fe, ce, wt, {
1765
+ style: le && er ? { cursor: "pointer" } : void 0,
1766
+ onClick: le && er ? () => $(er) : void 0
1767
+ }), { key: `scatter-${L}-${ae}` });
1768
+ });
1769
+ }),
1770
+ S ? x.map((A, L) => {
1771
+ const ce = he(A.name, L);
1772
+ return (A.values || []).map((oe, ae) => {
1773
+ const N = p.values[ae];
1774
+ return typeof N != "number" || !Number.isFinite(N) || typeof oe != "number" || !Number.isFinite(oe) ? null : /* @__PURE__ */ e.createElement(
1775
+ "text",
1776
+ {
1777
+ key: `scatter-label-${L}-${ae}`,
1778
+ x: H(N),
1779
+ y: G(oe) - 8,
1780
+ textAnchor: "middle",
1781
+ fontSize: "10",
1782
+ fontWeight: "700",
1783
+ fill: ce,
1784
+ style: { pointerEvents: "none" }
1785
+ },
1786
+ P(oe)
1787
+ );
1788
+ });
1789
+ }) : null
1790
+ ), De, we, Ie, Xe), h ? /* @__PURE__ */ e.createElement(St, { items: q, theme: r, hiddenSet: ee, onToggle: Qe, position: _e, onElementSelect: de }) : null);
1791
+ }
1792
+ if (n === "waterfall") {
1793
+ const l = Array.isArray(t && t.series) && t.series.length > 0 ? t.series[0] : null, c = Array.isArray(t && t.categories) ? t.categories : [], s = Array.isArray(t && t.categoryTargets) ? t.categoryTargets : [];
1794
+ if (!l || c.length === 0)
1795
+ return /* @__PURE__ */ e.createElement(Se, { message: "Waterfall charts need categories and at least one numeric measure.", theme: r, chartHeight: W });
1796
+ const p = c.map((A, L) => {
1797
+ const ce = l.values[L];
1798
+ return typeof ce == "number" && Number.isFinite(ce) ? ce : 0;
1799
+ }), x = [];
1800
+ let g = 0;
1801
+ for (let A = 0; A < p.length; A++) {
1802
+ const L = g;
1803
+ g += p[A], x.push({ label: c[A], start: L, end: g, increment: p[A], type: p[A] >= 0 ? "positive" : "negative" });
1804
+ }
1805
+ x.push({ label: "Total", start: 0, end: g, increment: g, type: "total" });
1806
+ const E = x.map((A) => A.start).concat(x.map((A) => A.end));
1807
+ let m = Math.min(...E, 0), w = Math.max(...E, 0);
1808
+ if (m === w) {
1809
+ const A = Math.abs(w || 1) * 0.15 || 1;
1810
+ m -= A, w += A;
1811
+ }
1812
+ const k = (w - m) * 0.08;
1813
+ m -= k, w += k;
1814
+ const y = Yt(m, w, 5), j = { top: 24, right: 20, bottom: 84, left: Math.max(52, Wt(P(w), 11) + 16) }, M = Z - j.left - j.right, v = W - j.top - j.bottom, B = (A) => j.top + (w - A) / (w - m) * v, D = M / x.length, H = Math.max(14, Math.min(60, D * 0.6)), G = "#059669", se = "#DC2626", b = Ce(0, r, Ee), q = typeof $ == "function", le = [
1815
+ { label: "Increase", color: G },
1816
+ { label: "Decrease", color: se },
1817
+ { label: "Total", color: b }
1818
+ ];
1819
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative" }, ...We }, /* @__PURE__ */ e.createElement(
1820
+ "svg",
1821
+ {
1822
+ ref: R,
1823
+ viewBox: `0 0 ${Z} ${W}`,
1824
+ width: "100%",
1825
+ preserveAspectRatio: "xMidYMid meet",
1826
+ style: { display: "block", overflow: "visible" }
1827
+ },
1828
+ y.map((A, L) => /* @__PURE__ */ e.createElement("g", { key: `wf-tick-${L}` }, /* @__PURE__ */ e.createElement("line", { x1: j.left, y1: B(A), x2: Z - j.right, y2: B(A), stroke: r.border, strokeDasharray: "3 4" }), /* @__PURE__ */ e.createElement("text", { x: j.left - 8, y: B(A) + 4, textAnchor: "end", fontSize: "11", fill: r.textSec, style: { pointerEvents: "none" } }, P(A)))),
1829
+ /* @__PURE__ */ e.createElement("line", { x1: j.left, y1: B(0), x2: Z - j.right, y2: B(0), stroke: r.textSec, strokeOpacity: "0.5" }),
1830
+ K ? /* @__PURE__ */ e.createElement("text", { x: 14, y: (j.top + W - j.bottom) / 2, textAnchor: "middle", fontSize: "11", fontWeight: "700", fill: r.textSec, transform: `rotate(-90, 14, ${(j.top + W - j.bottom) / 2})`, style: { pointerEvents: "none" } }, K) : null,
1831
+ x.map((A, L) => {
1832
+ const ce = j.left + L * D + D / 2, oe = ce - H / 2, ae = B(Math.max(A.start, A.end)), N = B(Math.min(A.start, A.end)), re = Math.max(1, N - ae), fe = A.type === "total" ? b : A.type === "positive" ? G : se, Ne = L < s.length ? s[L] : null;
1833
+ return /* @__PURE__ */ e.createElement("g", { key: `wf-bar-${L}` }, L > 0 ? /* @__PURE__ */ e.createElement(
1834
+ "line",
1835
+ {
1836
+ x1: j.left + (L - 1) * D + D / 2 + H / 2,
1837
+ y1: L === x.length - 1 ? B(A.end) : B(A.start),
1838
+ x2: oe,
1839
+ y2: L === x.length - 1 ? B(A.end) : B(A.start),
1840
+ stroke: r.textSec,
1841
+ strokeDasharray: "2 2",
1842
+ strokeOpacity: "0.5"
1843
+ }
1844
+ ) : null, /* @__PURE__ */ e.createElement(
1845
+ "rect",
1846
+ {
1847
+ x: oe,
1848
+ y: ae,
1849
+ width: H,
1850
+ height: re,
1851
+ rx: "3",
1852
+ fill: fe,
1853
+ opacity: "0.9",
1854
+ "data-tip-cat": A.label,
1855
+ "data-tip-ser": A.type === "total" ? "Total" : (A.increment >= 0 ? "+" : "") + P(A.increment),
1856
+ "data-tip-val": P(A.end),
1857
+ "data-tip-color": fe,
1858
+ style: q && Ne ? { cursor: "pointer" } : void 0,
1859
+ onClick: q && Ne ? () => $(Ne) : void 0
1860
+ }
1861
+ ), S ? /* @__PURE__ */ e.createElement(
1862
+ "text",
1863
+ {
1864
+ x: ce,
1865
+ y: ae - 5,
1866
+ textAnchor: "middle",
1867
+ fontSize: "9",
1868
+ fontWeight: "700",
1869
+ fill: r.textSec,
1870
+ style: { pointerEvents: "none" }
1871
+ },
1872
+ A.type === "total" ? P(A.end) : (A.increment >= 0 ? "+" : "") + P(A.increment)
1873
+ ) : null, /* @__PURE__ */ e.createElement(
1874
+ "text",
1875
+ {
1876
+ x: ce,
1877
+ y: W - j.bottom + 16,
1878
+ textAnchor: "middle",
1879
+ fontSize: "10",
1880
+ fontWeight: "600",
1881
+ fill: r.textSec,
1882
+ style: { pointerEvents: "none" }
1883
+ },
1884
+ ge(A.label, 12)
1885
+ ));
1886
+ })
1887
+ ), De, we, Ie, Xe), h ? /* @__PURE__ */ e.createElement(St, { items: le, theme: r, hiddenSet: ee, onToggle: Qe, position: _e, onElementSelect: de }) : null);
1888
+ }
1889
+ if (n === "combo") {
1890
+ const l = (Array.isArray(t && t.layers) ? t.layers : []).filter((b) => b && !b.hidden && !ee.has(b.name) && Array.isArray(b.values) && b.values.some((q) => q !== null));
1891
+ if (l.length === 0)
1892
+ return /* @__PURE__ */ e.createElement(Se, { message: t.emptyMessage || "No combo layers are configured.", theme: r, chartHeight: W });
1893
+ const c = l.some((b) => b.axis === "right"), s = { top: 24, right: c ? 76 : 20, bottom: 96, left: 72 }, p = Math.max(1, Array.isArray(t.categories) ? t.categories.length : 0), x = Math.max(1, (Z - s.left - s.right) / p), g = Math.max(22, Math.min(72, x * 0.72)), E = l.filter((b) => b.type === "bar"), m = l.filter((b) => b.type === "area"), w = l.filter((b) => b.type === "line"), k = Or(
1894
+ l.filter((b) => b.axis !== "right").flatMap((b) => b.values),
1895
+ W,
1896
+ s
1897
+ ), y = c ? Or(
1898
+ l.filter((b) => b.axis === "right").flatMap((b) => b.values),
1899
+ W,
1900
+ s
1901
+ ) : k, I = Array.isArray(t.categoryTargets) ? t.categoryTargets : [], j = l.map((b, q) => ({
1902
+ label: b.name,
1903
+ color: b.color || Ce(q, r, Ee)
1904
+ })), M = (b) => b.axis === "right" ? y.scaleY : k.scaleY, v = (b) => b.axis === "right" ? y.baselineY : k.baselineY, B = (b) => (q) => zt(q, b.valueFormat || J || "auto"), D = l.find((b) => b.axis === "right"), H = D ? B(D) : P, G = 4, se = Math.max(8, (g - (Math.max(E.length, 1) - 1) * G) / Math.max(E.length, 1));
1905
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative", ...Be }, ...We }, /* @__PURE__ */ e.createElement(
1906
+ "svg",
1907
+ {
1908
+ ref: R,
1909
+ viewBox: `0 0 ${Z} ${W}`,
1910
+ preserveAspectRatio: "xMidYMid meet",
1911
+ style: {
1912
+ width: "100%",
1913
+ height: "auto",
1914
+ display: "block",
1915
+ maxWidth: "100%",
1916
+ ...qe
1917
+ },
1918
+ role: "img",
1919
+ "aria-label": t.title || "Combo chart"
1920
+ },
1921
+ k.tickValues.map((b, q) => {
1922
+ const le = k.scaleY(b);
1923
+ return /* @__PURE__ */ e.createElement("g", { key: `combo-left-tick-${q}` }, /* @__PURE__ */ e.createElement(
1924
+ "line",
1925
+ {
1926
+ x1: s.left,
1927
+ x2: Z - s.right,
1928
+ y1: le,
1929
+ y2: le,
1930
+ stroke: r.border,
1931
+ strokeOpacity: "0.7",
1932
+ strokeDasharray: "4 4"
1933
+ }
1934
+ ), /* @__PURE__ */ e.createElement(
1935
+ "text",
1936
+ {
1937
+ x: s.left - 10,
1938
+ y: le + 4,
1939
+ textAnchor: "end",
1940
+ fontSize: "11",
1941
+ fill: r.textSec
1942
+ },
1943
+ P(b)
1944
+ ));
1945
+ }),
1946
+ c ? y.tickValues.map((b, q) => {
1947
+ const le = y.scaleY(b);
1948
+ return /* @__PURE__ */ e.createElement(
1949
+ "text",
1950
+ {
1951
+ key: `combo-right-tick-${q}`,
1952
+ x: Z - s.right + 10,
1953
+ y: le + 4,
1954
+ textAnchor: "start",
1955
+ fontSize: "11",
1956
+ fill: r.textSec
1957
+ },
1958
+ H(b)
1959
+ );
1960
+ }) : null,
1961
+ K ? /* @__PURE__ */ e.createElement("text", { x: 14, y: (s.top + W - s.bottom) / 2, textAnchor: "middle", fontSize: "11", fontWeight: "700", fill: r.textSec, transform: `rotate(-90, 14, ${(s.top + W - s.bottom) / 2})`, style: { pointerEvents: "none" } }, K) : null,
1962
+ /* @__PURE__ */ e.createElement(
1963
+ "line",
1964
+ {
1965
+ x1: s.left,
1966
+ x2: Z - s.right,
1967
+ y1: k.baselineY,
1968
+ y2: k.baselineY,
1969
+ stroke: r.textSec,
1970
+ strokeOpacity: "0.45"
1971
+ }
1972
+ ),
1973
+ E.map((b, q) => t.categories.map((le, A) => {
1974
+ const L = b.values[A];
1975
+ if (L == null) return null;
1976
+ const ce = s.left + A * x + (x - g) / 2, oe = M(b), ae = v(b), N = oe(L), re = b.color || Ce(q, r, Ee), fe = ce + q * (se + G), Ne = B(b);
1977
+ return /* @__PURE__ */ e.createElement(e.Fragment, { key: `${b.id}-${le}-${q}` }, /* @__PURE__ */ e.createElement(
1978
+ "rect",
1979
+ {
1980
+ x: fe,
1981
+ y: Math.min(N, ae),
1982
+ width: se,
1983
+ height: Math.max(1, Math.abs(ae - N)),
1984
+ rx: "3",
1985
+ fill: re,
1986
+ opacity: "0.9",
1987
+ "data-tip-cat": le,
1988
+ "data-tip-ser": b.name,
1989
+ "data-tip-val": Ne(L),
1990
+ "data-tip-color": re
1991
+ }
1992
+ ), S ? /* @__PURE__ */ e.createElement(
1993
+ "text",
1994
+ {
1995
+ x: fe + se / 2,
1996
+ y: L >= 0 ? Math.min(N, ae) - 4 : Math.max(N, ae) + 12,
1997
+ textAnchor: "middle",
1998
+ fontSize: "9",
1999
+ fontWeight: "700",
2000
+ fill: r.textSec,
2001
+ style: { pointerEvents: "none" }
2002
+ },
2003
+ Ne(L)
2004
+ ) : null);
2005
+ })),
2006
+ m.map((b, q) => {
2007
+ const le = t.categories.map((ae, N) => {
2008
+ const re = b.values[N];
2009
+ if (re == null) return null;
2010
+ const fe = s.left + N * x + x / 2, Ne = M(b);
2011
+ return {
2012
+ x: fe,
2013
+ y: Ne(re),
2014
+ baseY: v(b),
2015
+ rawValue: re
2016
+ };
2017
+ }), A = Yr(le), L = gr(le), ce = b.color || Ce(E.length + q, r, Ee), oe = B(b);
2018
+ return /* @__PURE__ */ e.createElement("g", { key: `combo-area-${b.id}` }, A ? /* @__PURE__ */ e.createElement("path", { d: A, fill: ce, opacity: "0.16", style: { pointerEvents: "none" } }) : null, L ? /* @__PURE__ */ e.createElement("path", { d: L, fill: "none", stroke: ce, strokeWidth: "2.5", strokeLinejoin: "round", strokeLinecap: "round", strokeDasharray: yr(mt[b.name]), style: { pointerEvents: "none" } }) : null, le.map((ae, N) => ae ? /* @__PURE__ */ e.createElement(e.Fragment, { key: `${b.id}-area-pt-${N}` }, /* @__PURE__ */ e.createElement(
2019
+ "circle",
2020
+ {
2021
+ cx: ae.x,
2022
+ cy: ae.y,
2023
+ r: "4",
2024
+ fill: ce,
2025
+ stroke: r.surfaceBg || r.background || "#fff",
2026
+ strokeWidth: "2",
2027
+ "data-tip-cat": t.categories[N],
2028
+ "data-tip-ser": b.name,
2029
+ "data-tip-val": oe(ae.rawValue),
2030
+ "data-tip-color": ce
2031
+ }
2032
+ ), S ? /* @__PURE__ */ e.createElement("text", { x: ae.x, y: ae.y - 8, textAnchor: "middle", fontSize: "9", fontWeight: "700", fill: r.textSec, style: { pointerEvents: "none" } }, oe(ae.rawValue)) : null) : null));
2033
+ }),
2034
+ w.map((b, q) => {
2035
+ const le = t.categories.map((oe, ae) => {
2036
+ const N = b.values[ae];
2037
+ return N == null ? null : {
2038
+ x: s.left + ae * x + x / 2,
2039
+ y: M(b)(N),
2040
+ rawValue: N
2041
+ };
2042
+ }), A = gr(le), L = b.color || Ce(E.length + m.length + q, r, Ee), ce = B(b);
2043
+ return /* @__PURE__ */ e.createElement("g", { key: `combo-line-${b.id}` }, A ? /* @__PURE__ */ e.createElement("path", { d: A, fill: "none", stroke: L, strokeWidth: "3", strokeLinejoin: "round", strokeLinecap: "round", strokeDasharray: yr(mt[b.name]), style: { pointerEvents: "none" } }) : null, le.map((oe, ae) => oe ? /* @__PURE__ */ e.createElement(e.Fragment, { key: `${b.id}-point-${ae}` }, /* @__PURE__ */ e.createElement(
2044
+ "circle",
2045
+ {
2046
+ cx: oe.x,
2047
+ cy: oe.y,
2048
+ r: "4",
2049
+ fill: L,
2050
+ stroke: r.surfaceBg || r.background || "#fff",
2051
+ strokeWidth: "2",
2052
+ "data-tip-cat": t.categories[ae],
2053
+ "data-tip-ser": b.name,
2054
+ "data-tip-val": ce(oe.rawValue),
2055
+ "data-tip-color": L
2056
+ }
2057
+ ), S ? /* @__PURE__ */ e.createElement("text", { x: oe.x, y: oe.y - 8, textAnchor: "middle", fontSize: "9", fontWeight: "700", fill: r.textSec, style: { pointerEvents: "none" } }, ce(oe.rawValue)) : null) : null));
2058
+ }),
2059
+ t.categories.map((b, q) => {
2060
+ const le = s.left + q * x + x / 2;
2061
+ return /* @__PURE__ */ e.createElement(
2062
+ "text",
2063
+ {
2064
+ key: `combo-label-${q}`,
2065
+ x: le,
2066
+ y: W - s.bottom + 28,
2067
+ textAnchor: "middle",
2068
+ fontSize: "11",
2069
+ fill: r.textSec
2070
+ },
2071
+ ge(b, 18)
2072
+ );
2073
+ }),
2074
+ typeof $ == "function" ? t.categories.map((b, q) => {
2075
+ const le = I[q];
2076
+ return le ? /* @__PURE__ */ e.createElement(
2077
+ "rect",
2078
+ {
2079
+ key: `combo-hit-${q}`,
2080
+ x: s.left + q * x,
2081
+ y: s.top,
2082
+ width: x,
2083
+ height: W - s.top - s.bottom,
2084
+ fill: "transparent",
2085
+ style: { cursor: "pointer" },
2086
+ onClick: () => $(le)
2087
+ }
2088
+ ) : null;
2089
+ }) : null
2090
+ ), De, we, Ie, Xe), h ? /* @__PURE__ */ e.createElement(St, { items: j, theme: r, hiddenSet: ee, onToggle: Qe, position: _e, onElementSelect: de }) : null);
2091
+ }
2092
+ if (!d)
2093
+ return /* @__PURE__ */ e.createElement(Se, { message: "No numeric data available for this chart.", theme: r, chartHeight: W });
2094
+ const wr = Yt(d.minValue, d.maxValue, U || 5), Ct = Oe ? Array.from(new Set(
2095
+ (t.stackedGroups || []).reduce((l, c) => ((c.segments || []).forEach((s) => {
2096
+ s && s.label && l.push(s.label);
2097
+ }), l), [])
2098
+ )) : [], dr = Ct.reduce((l, c, s) => (l[c] = Ce(s, r, Ee), l), {}), $t = Oe ? Ct.map((l) => ({ label: l, color: dr[l] || Ce(0, r, Ee) })) : (t.series || []).map((l, c) => ({
2099
+ label: l.name,
2100
+ color: he(l.name, c)
2101
+ })), Jt = d.hasHierarchicalBands ? t.categoryBands.reduce((l, c, s) => {
2102
+ const p = l[l.length - 1];
2103
+ return p && p.groupKey === c.groupKey ? (p.endIndex = s, l) : (l.push({
2104
+ groupKey: c.groupKey,
2105
+ outerLabel: c.outerLabel,
2106
+ startIndex: s,
2107
+ endIndex: s
2108
+ }), l);
2109
+ }, []) : [], Xt = Array.isArray(t && t.categoryTargets) ? t.categoryTargets : [], Sr = typeof $ == "function" && Xt.length === t.categories.length;
2110
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px" } }, /* @__PURE__ */ e.createElement("div", { ref: Ye, style: { width: "100%", minWidth: 0, position: "relative", ...Be }, ...We }, /* @__PURE__ */ e.createElement(
2111
+ "svg",
2112
+ {
2113
+ ref: R,
2114
+ viewBox: `0 0 ${Z} ${W}`,
2115
+ preserveAspectRatio: "xMidYMid meet",
2116
+ style: {
2117
+ width: "100%",
2118
+ height: "auto",
2119
+ display: "block",
2120
+ maxWidth: "100%",
2121
+ ...qe
2122
+ },
2123
+ role: "img",
2124
+ "aria-label": t.title,
2125
+ onClick: de ? dt : void 0
2126
+ },
2127
+ ie ? /* @__PURE__ */ e.createElement("defs", null, (t.series || []).map((l, c) => {
2128
+ const s = he(l.name, c), p = Br.find((g) => g.value === ir) || Br[0], x = Rn(s, nt);
2129
+ return /* @__PURE__ */ e.createElement("linearGradient", { key: `grad-${c}`, id: `pg-grad-${c}`, x1: p.x1, y1: p.y1, x2: p.x2, y2: p.y2 }, /* @__PURE__ */ e.createElement("stop", { offset: x[0].offset, stopColor: s, stopOpacity: x[0].stopOpacity }), /* @__PURE__ */ e.createElement("stop", { offset: x[1].offset, stopColor: s, stopOpacity: x[1].stopOpacity }));
2130
+ })) : null,
2131
+ wr.map((l, c) => {
2132
+ const s = d.scaleY ? d.scaleY(l) : null, p = d.scaleX ? d.scaleX(l) : null, x = Pe ? `${Math.round(l)}%` : P(l);
2133
+ return /* @__PURE__ */ e.createElement("g", { key: `tick-${c}` }, d.horizontalBarMode ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("line", { x1: p, y1: d.margin.top, x2: p, y2: W - d.margin.bottom, stroke: r.border, strokeDasharray: "3 4" }), /* @__PURE__ */ e.createElement("text", { x: p, y: W - d.margin.bottom + 18, textAnchor: "middle", fontSize: "11", fill: r.textSec, "data-chart-element-type": "axis", "data-chart-element-id": "x", style: de ? { cursor: "pointer" } : void 0 }, x)) : /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("line", { x1: d.margin.left, y1: s, x2: Z - d.margin.right, y2: s, stroke: r.border, strokeDasharray: "3 4" }), /* @__PURE__ */ e.createElement("text", { x: d.margin.left - 8, y: s + 4, textAnchor: "end", fontSize: "11", fill: r.textSec, "data-chart-element-type": "axis", "data-chart-element-id": "y", style: de ? { cursor: "pointer" } : void 0 }, x)));
2134
+ }),
2135
+ /* @__PURE__ */ e.createElement(
2136
+ "line",
2137
+ {
2138
+ x1: d.horizontalBarMode ? d.baselineX : d.margin.left,
2139
+ y1: d.horizontalBarMode ? d.margin.top : d.baselineY,
2140
+ x2: d.horizontalBarMode ? d.baselineX : Z - d.margin.right,
2141
+ y2: d.horizontalBarMode ? W - d.margin.bottom : d.baselineY,
2142
+ stroke: r.textSec,
2143
+ strokeWidth: "1"
2144
+ }
2145
+ ),
2146
+ K ? /* @__PURE__ */ e.createElement("text", { x: 14, y: (d.margin.top + W - d.margin.bottom) / 2, textAnchor: "middle", fontSize: "11", fontWeight: "700", fill: r.textSec, transform: `rotate(-90, 14, ${(d.margin.top + W - d.margin.bottom) / 2})`, style: { pointerEvents: "none" } }, K) : null,
2147
+ Array.isArray(T) && T.length > 0 && T.map((l, c) => {
2148
+ const s = Number(l.value);
2149
+ if (!Number.isFinite(s)) return null;
2150
+ const p = l.color || r.primary, x = l.orient === "v", g = yr(l.dash || "dashed") || "6 3";
2151
+ if (x) {
2152
+ const m = d.margin.left + s * d.step;
2153
+ return m < d.margin.left - 2 || m > Z - d.margin.right + 2 ? null : /* @__PURE__ */ e.createElement("g", { key: `ref-line-${c}` }, /* @__PURE__ */ e.createElement("line", { x1: m, y1: d.margin.top, x2: m, y2: W - d.margin.bottom, stroke: p, strokeWidth: "1.5", strokeDasharray: g, style: { pointerEvents: "none" } }), l.label ? /* @__PURE__ */ e.createElement("text", { x: m + 4, y: d.margin.top + 12, textAnchor: "start", fontSize: "10", fontWeight: "700", fill: p, style: { pointerEvents: "none" } }, l.label) : null);
2154
+ }
2155
+ if (!d.scaleY) return null;
2156
+ const E = d.scaleY(s);
2157
+ return E < d.margin.top - 2 || E > W - d.margin.bottom + 2 ? null : /* @__PURE__ */ e.createElement("g", { key: `ref-line-${c}` }, /* @__PURE__ */ e.createElement("line", { x1: d.margin.left, y1: E, x2: Z - d.margin.right, y2: E, stroke: p, strokeWidth: "1.5", strokeDasharray: g, style: { pointerEvents: "none" } }), l.label ? /* @__PURE__ */ e.createElement("text", { x: Z - d.margin.right - 4, y: E - 4, textAnchor: "end", fontSize: "10", fontWeight: "700", fill: p, style: { pointerEvents: "none" } }, l.label) : null, typeof Te == "function" ? /* @__PURE__ */ e.createElement(
2158
+ "circle",
2159
+ {
2160
+ cx: d.margin.left + 22,
2161
+ cy: E,
2162
+ r: 6,
2163
+ fill: p,
2164
+ stroke: "white",
2165
+ strokeWidth: "1.5",
2166
+ style: { cursor: "ns-resize" },
2167
+ onMouseDown: (m) => {
2168
+ m.preventDefault(), m.stopPropagation();
2169
+ const w = m.clientY, k = s, { plotHeight: y, maxValue: I, minValue: j } = d, M = I - j;
2170
+ if (M <= 0) return;
2171
+ const v = (D) => {
2172
+ const H = k - (D.clientY - w) / y * M;
2173
+ Te((G) => G.map(
2174
+ (se, b) => b === c ? { ...se, value: String(Math.round(H * 1e3) / 1e3) } : se
2175
+ ));
2176
+ }, B = () => {
2177
+ window.removeEventListener("mousemove", v), window.removeEventListener("mouseup", B);
2178
+ };
2179
+ window.addEventListener("mousemove", v), window.addEventListener("mouseup", B);
2180
+ }
2181
+ }
2182
+ ) : null);
2183
+ }),
2184
+ Vt && !d.horizontalBarMode && (n === "bar" || n === "line" || n === "area" || n === "scatter") && Array.isArray(t.series) && t.series.length > 0 && d.scaleY ? t.series.filter((c) => !ee.has(c.name)).map((c, s) => {
2185
+ const p = c.values || [], x = ct === "moving_avg" ? ta(p, et) : ea(p);
2186
+ if (!x) return null;
2187
+ const g = x.map((k, y) => Number.isFinite(k) ? { x: d.margin.left + y * d.step + d.step / 2, y: d.scaleY(k) } : null), E = gr(g);
2188
+ if (!E) return null;
2189
+ const m = he(c.name, s), w = Tt || m;
2190
+ return /* @__PURE__ */ e.createElement(
2191
+ "path",
2192
+ {
2193
+ key: `trendline-${s}`,
2194
+ d: E,
2195
+ fill: "none",
2196
+ stroke: w,
2197
+ strokeWidth: String(Ut || 2),
2198
+ strokeDasharray: "8 4",
2199
+ strokeLinecap: "round",
2200
+ opacity: "0.78",
2201
+ style: { pointerEvents: "none" }
2202
+ }
2203
+ );
2204
+ }) : null,
2205
+ d.hasHierarchicalBands && Jt.map((l, c) => {
2206
+ if (c === Jt.length - 1) return null;
2207
+ const s = d.horizontalBarMode ? d.margin.top + (l.endIndex + 1) * d.step : d.margin.left + (l.endIndex + 1) * d.step;
2208
+ return /* @__PURE__ */ e.createElement(
2209
+ "line",
2210
+ {
2211
+ key: `group-divider-${l.groupKey}-${c}`,
2212
+ x1: d.horizontalBarMode ? d.margin.left : s,
2213
+ y1: d.horizontalBarMode ? s : d.margin.top,
2214
+ x2: d.horizontalBarMode ? Z - d.margin.right : s,
2215
+ y2: d.horizontalBarMode ? s : W - d.margin.bottom + 58,
2216
+ stroke: r.border,
2217
+ strokeDasharray: "4 4"
2218
+ }
2219
+ );
2220
+ }),
2221
+ Oe && (t.stackedGroups || []).map((l, c) => {
2222
+ const s = d.horizontalBarMode ? d.margin.top + c * d.step + (d.step - d.groupWidth) / 2 : d.margin.left + c * d.step + (d.step - d.groupWidth) / 2, p = Math.max(14, d.groupWidth * 0.64);
2223
+ let x = 0, g = 0;
2224
+ return /* @__PURE__ */ e.createElement("g", { key: `stacked-group-${l.key}` }, (l.segments || []).map((E) => {
2225
+ const m = E && typeof E.value == "number" && Number.isFinite(E.value) ? E.value : null;
2226
+ if (m === null) return null;
2227
+ const w = m >= 0 ? x : g, k = w + m;
2228
+ m >= 0 ? x = k : g = k;
2229
+ const y = dr[E.label] || Ce(0, r, Ee);
2230
+ if (d.horizontalBarMode) {
2231
+ const B = d.scaleX(w), D = d.scaleX(k);
2232
+ return /* @__PURE__ */ e.createElement(
2233
+ "rect",
2234
+ {
2235
+ key: `${l.key}-${E.path || E.label}`,
2236
+ x: Math.min(B, D),
2237
+ y: s,
2238
+ width: Math.max(1, Math.abs(D - B)),
2239
+ height: p,
2240
+ rx: "3",
2241
+ fill: y,
2242
+ opacity: "0.94",
2243
+ "data-tip-cat": l.label,
2244
+ "data-tip-ser": E.label,
2245
+ "data-tip-val": P(m),
2246
+ "data-tip-color": y
2247
+ }
2248
+ );
2249
+ }
2250
+ const I = d.scaleY(w), j = d.scaleY(k), M = Math.min(I, j), v = Math.max(1, Math.abs(j - I));
2251
+ return /* @__PURE__ */ e.createElement(
2252
+ "rect",
2253
+ {
2254
+ key: `${l.key}-${E.path || E.label}`,
2255
+ x: s,
2256
+ y: M,
2257
+ width: p,
2258
+ height: v,
2259
+ rx: "3",
2260
+ fill: y,
2261
+ opacity: "0.94",
2262
+ "data-tip-cat": l.label,
2263
+ "data-tip-ser": E.label,
2264
+ "data-tip-val": P(m),
2265
+ "data-tip-color": y
2266
+ }
2267
+ );
2268
+ }), d.horizontalBarMode ? /* @__PURE__ */ e.createElement(
2269
+ "text",
2270
+ {
2271
+ x: d.margin.left - 10,
2272
+ y: s + p / 2 + 4,
2273
+ textAnchor: "end",
2274
+ fontSize: "11",
2275
+ fill: r.textSec
2276
+ },
2277
+ ge(l.label, 22)
2278
+ ) : /* @__PURE__ */ e.createElement(
2279
+ "text",
2280
+ {
2281
+ x: s + p / 2,
2282
+ y: W - d.margin.bottom + 30,
2283
+ textAnchor: "middle",
2284
+ fontSize: "11",
2285
+ fill: r.textSec
2286
+ },
2287
+ ge(l.label, 20)
2288
+ ));
2289
+ }),
2290
+ !Oe && n === "bar" && t.categories.map((l, c) => {
2291
+ const s = d.horizontalBarMode ? d.margin.top + c * d.step + (d.step - d.groupWidth) / 2 : d.margin.left + c * d.step + (d.step - d.groupWidth) / 2, p = Lt || Pe ? Math.max(14, d.groupWidth * 0.64) : Math.max(6, d.groupWidth / Math.max(t.series.length, 1) - 4);
2292
+ let x = 0, g = 0;
2293
+ return /* @__PURE__ */ e.createElement("g", { key: `bar-group-${l}` }, t.series.map((E, m) => {
2294
+ if (ee.has(E.name)) return null;
2295
+ const w = E.values[c];
2296
+ if (w == null) return null;
2297
+ const k = he(E.name, m), y = ie ? `url(#pg-grad-${m})` : k;
2298
+ if (Lt || Pe) {
2299
+ const v = Pe && ve ? ve[c] : null, B = Pe && v ? w / v * 100 : w, D = B >= 0 ? x : g, H = D + B;
2300
+ B >= 0 ? x = H : g = H;
2301
+ const G = Pe ? `${(Math.abs(w / v) * 100).toFixed(1)}% (${P(w)})` : P(w), se = { "data-tip-cat": l, "data-tip-ser": E.name, "data-tip-val": G, "data-tip-color": k };
2302
+ if (d.horizontalBarMode) {
2303
+ const le = d.scaleX(D), A = d.scaleX(H);
2304
+ return /* @__PURE__ */ e.createElement(
2305
+ "rect",
2306
+ {
2307
+ key: `${E.name}-${l}`,
2308
+ x: Math.min(le, A),
2309
+ y: s,
2310
+ width: Math.max(1, Math.abs(A - le)),
2311
+ height: p,
2312
+ rx: "3",
2313
+ fill: y,
2314
+ opacity: "0.92",
2315
+ style: { transition: it ? "width 0.35s ease, x 0.35s ease" : void 0 },
2316
+ ...se
2317
+ }
2318
+ );
2319
+ }
2320
+ const b = d.scaleY(D), q = d.scaleY(H);
2321
+ return /* @__PURE__ */ e.createElement(
2322
+ "rect",
2323
+ {
2324
+ key: `${E.name}-${l}`,
2325
+ x: s,
2326
+ y: Math.min(b, q),
2327
+ width: p,
2328
+ height: Math.max(1, Math.abs(q - b)),
2329
+ rx: "3",
2330
+ fill: y,
2331
+ opacity: "0.92",
2332
+ style: { transition: it ? "height 0.35s ease, y 0.35s ease" : void 0 },
2333
+ ...se
2334
+ }
2335
+ );
2336
+ }
2337
+ if (d.horizontalBarMode) {
2338
+ const v = d.scaleX(w), B = s + m * (p + 4);
2339
+ return /* @__PURE__ */ e.createElement(e.Fragment, { key: `${E.name}-${l}` }, /* @__PURE__ */ e.createElement(
2340
+ "rect",
2341
+ {
2342
+ x: Math.min(v, d.baselineX),
2343
+ y: B,
2344
+ width: Math.max(1, Math.abs(d.baselineX - v)),
2345
+ height: p,
2346
+ rx: "3",
2347
+ fill: y,
2348
+ opacity: "0.9",
2349
+ style: { transition: it ? "width 0.35s ease, x 0.35s ease" : void 0 },
2350
+ "data-tip-cat": l,
2351
+ "data-tip-ser": E.name,
2352
+ "data-tip-val": P(w),
2353
+ "data-tip-color": k
2354
+ }
2355
+ ), S ? /* @__PURE__ */ e.createElement(
2356
+ "text",
2357
+ {
2358
+ x: w >= 0 ? Math.max(v, d.baselineX) + 4 : Math.min(v, d.baselineX) - 4,
2359
+ y: B + p / 2 + 3,
2360
+ textAnchor: w >= 0 ? "start" : "end",
2361
+ fontSize: "9",
2362
+ fontWeight: "700",
2363
+ fill: r.textSec,
2364
+ style: { pointerEvents: "none" }
2365
+ },
2366
+ P(w)
2367
+ ) : null);
2368
+ }
2369
+ const I = d.scaleY(w), j = Math.max(1, Math.abs(d.baselineY - I)), M = s + m * (p + 4);
2370
+ return /* @__PURE__ */ e.createElement(e.Fragment, { key: `${E.name}-${l}` }, /* @__PURE__ */ e.createElement(
2371
+ "rect",
2372
+ {
2373
+ x: M,
2374
+ y: Math.min(I, d.baselineY),
2375
+ width: p,
2376
+ height: j,
2377
+ rx: "3",
2378
+ fill: y,
2379
+ opacity: "0.9",
2380
+ style: { transition: it ? "height 0.35s ease, y 0.35s ease" : void 0, cursor: de ? "pointer" : void 0 },
2381
+ "data-tip-cat": l,
2382
+ "data-tip-ser": E.name,
2383
+ "data-tip-val": P(w),
2384
+ "data-tip-color": k,
2385
+ "data-chart-element-type": "series",
2386
+ "data-chart-element-id": E.name
2387
+ }
2388
+ ), S ? /* @__PURE__ */ e.createElement(
2389
+ "text",
2390
+ {
2391
+ x: M + p / 2,
2392
+ y: w >= 0 ? Math.min(I, d.baselineY) - 4 : Math.max(I, d.baselineY) + 12,
2393
+ textAnchor: "middle",
2394
+ fontSize: "9",
2395
+ fontWeight: "700",
2396
+ fill: r.textSec,
2397
+ style: { pointerEvents: "none" }
2398
+ },
2399
+ P(w)
2400
+ ) : null);
2401
+ }));
2402
+ }),
2403
+ (n === "line" || n === "area") && (() => {
2404
+ const l = t.categories.map(() => 0), c = t.categories.map(() => 0);
2405
+ return t.series.map((s, p) => {
2406
+ if (ee.has(s.name)) return null;
2407
+ const x = he(s.name, p), g = t.categories.map((w, k) => {
2408
+ const y = s.values[k];
2409
+ if (y == null) return null;
2410
+ const I = d.margin.left + k * d.step + d.step / 2;
2411
+ if (yt || Pe) {
2412
+ const j = Pe && ve ? ve[k] : null, M = Pe && j ? y / j * 100 : y, v = M >= 0 ? l[k] : c[k], B = v + M;
2413
+ return M >= 0 ? l[k] = B : c[k] = B, {
2414
+ x: I,
2415
+ y: d.scaleY(B),
2416
+ baseY: d.scaleY(v),
2417
+ rawValue: y
2418
+ };
2419
+ }
2420
+ return {
2421
+ x: I,
2422
+ y: d.scaleY(y),
2423
+ baseY: d.baselineY,
2424
+ rawValue: y
2425
+ };
2426
+ }), E = gr(g), m = n === "area" ? Yr(g) : "";
2427
+ return /* @__PURE__ */ e.createElement("g", { key: `${s.name}-${n}` }, n === "area" && m && /* @__PURE__ */ e.createElement("path", { d: m, fill: ie ? `url(#pg-grad-${p})` : x, opacity: yt || Pe ? "0.46" : "0.16", style: { pointerEvents: "none" } }), E && /* @__PURE__ */ e.createElement("path", { d: E, fill: "none", stroke: x, strokeWidth: "3", strokeLinejoin: "round", strokeLinecap: "round", strokeDasharray: yr(mt[s.name]), style: { pointerEvents: "none" } }), g.map((w, k) => w ? /* @__PURE__ */ e.createElement(e.Fragment, { key: `${s.name}-${k}` }, e.cloneElement(Rt(w.x, w.y, x, {
2428
+ "data-tip-cat": t.categories[k],
2429
+ "data-tip-ser": s.name,
2430
+ "data-tip-val": P(w.rawValue),
2431
+ "data-tip-color": x
2432
+ }), { key: `marker-${p}-${k}` }), S ? /* @__PURE__ */ e.createElement(
2433
+ "text",
2434
+ {
2435
+ x: w.x,
2436
+ y: w.y - 8,
2437
+ textAnchor: "middle",
2438
+ fontSize: "9",
2439
+ fontWeight: "700",
2440
+ fill: r.textSec,
2441
+ style: { pointerEvents: "none" }
2442
+ },
2443
+ P(w.rawValue)
2444
+ ) : null) : null));
2445
+ });
2446
+ })(),
2447
+ Sr && t.categories.map((l, c) => {
2448
+ const s = Xt[c];
2449
+ return s ? d.horizontalBarMode ? /* @__PURE__ */ e.createElement(
2450
+ "rect",
2451
+ {
2452
+ key: `category-hit-horizontal-${c}`,
2453
+ x: d.margin.left,
2454
+ y: d.margin.top + c * d.step,
2455
+ width: Z - d.margin.left - d.margin.right,
2456
+ height: d.step,
2457
+ fill: "transparent",
2458
+ style: { cursor: "pointer" },
2459
+ onClick: () => $(s)
2460
+ }
2461
+ ) : /* @__PURE__ */ e.createElement(
2462
+ "rect",
2463
+ {
2464
+ key: `category-hit-vertical-${c}`,
2465
+ x: d.margin.left + c * d.step,
2466
+ y: d.margin.top,
2467
+ width: d.step,
2468
+ height: W - d.margin.top - d.margin.bottom,
2469
+ fill: "transparent",
2470
+ style: { cursor: "pointer" },
2471
+ onClick: () => $(s)
2472
+ }
2473
+ ) : null;
2474
+ }),
2475
+ Oe ? null : d.horizontalBarMode ? d.hasHierarchicalBands ? /* @__PURE__ */ e.createElement(e.Fragment, null, Jt.map((l) => {
2476
+ const c = d.margin.top + l.startIndex * d.step, s = d.margin.top + (l.endIndex + 1) * d.step, p = (c + s) / 2;
2477
+ return /* @__PURE__ */ e.createElement("g", { key: `outer-label-horizontal-${l.groupKey}` }, /* @__PURE__ */ e.createElement(
2478
+ "text",
2479
+ {
2480
+ x: 10,
2481
+ y: p + 4,
2482
+ textAnchor: "start",
2483
+ fontSize: "11",
2484
+ fontWeight: "700",
2485
+ fill: r.text
2486
+ },
2487
+ ge(l.outerLabel, 18)
2488
+ ));
2489
+ }), t.categoryBands.map((l, c) => {
2490
+ const s = d.margin.top + c * d.step + d.step / 2, p = l && l.innerLabel ? String(l.innerLabel) : "";
2491
+ return p ? /* @__PURE__ */ e.createElement(
2492
+ "text",
2493
+ {
2494
+ key: `inner-label-horizontal-${c}`,
2495
+ x: d.margin.left - 10,
2496
+ y: s + 4,
2497
+ textAnchor: "end",
2498
+ fontSize: "11",
2499
+ fill: r.textSec
2500
+ },
2501
+ ge(p, 18)
2502
+ ) : null;
2503
+ })) : t.categories.map((l, c) => {
2504
+ const s = d.margin.top + c * d.step + d.step / 2;
2505
+ return /* @__PURE__ */ e.createElement(
2506
+ "text",
2507
+ {
2508
+ key: `label-horizontal-${c}`,
2509
+ x: d.margin.left - 10,
2510
+ y: s + 4,
2511
+ textAnchor: "end",
2512
+ fontSize: "11",
2513
+ fill: r.textSec
2514
+ },
2515
+ ge(l, 22)
2516
+ );
2517
+ }) : d.hasHierarchicalBands ? /* @__PURE__ */ e.createElement(e.Fragment, null, Jt.map((l) => {
2518
+ const c = d.margin.left + l.startIndex * d.step, s = d.margin.left + (l.endIndex + 1) * d.step, p = (c + s) / 2;
2519
+ return /* @__PURE__ */ e.createElement("g", { key: `outer-label-${l.groupKey}` }, /* @__PURE__ */ e.createElement(
2520
+ "text",
2521
+ {
2522
+ x: p,
2523
+ y: W - d.margin.bottom + 68,
2524
+ textAnchor: "middle",
2525
+ fontSize: "11",
2526
+ fontWeight: "700",
2527
+ fill: r.text
2528
+ },
2529
+ ge(l.outerLabel, 22)
2530
+ ));
2531
+ }), t.categoryBands.map((l, c) => {
2532
+ const s = d.margin.left + c * d.step + d.step / 2, p = l && l.innerLabel ? String(l.innerLabel) : "";
2533
+ return /* @__PURE__ */ e.createElement("g", { key: `inner-label-${c}` }, p ? /* @__PURE__ */ e.createElement(
2534
+ "text",
2535
+ {
2536
+ x: s,
2537
+ y: W - d.margin.bottom + 30,
2538
+ textAnchor: "middle",
2539
+ fontSize: "11",
2540
+ fill: r.textSec
2541
+ },
2542
+ ge(p, 18)
2543
+ ) : null);
2544
+ })) : t.categories.map((l, c) => {
2545
+ if (Ft.visibleIndexes && !Ft.visibleIndexes.has(c)) return null;
2546
+ const s = d.margin.left + c * d.step + d.step / 2;
2547
+ return /* @__PURE__ */ e.createElement("g", { key: `label-${c}`, transform: `translate(${s}, ${W - d.margin.bottom + 18}) rotate(${ke})` }, /* @__PURE__ */ e.createElement("text", { textAnchor: ke === 0 ? "middle" : "start", fontSize: "11", fill: r.textSec, "data-chart-element-type": "axis", "data-chart-element-id": "x", style: de ? { cursor: "pointer" } : void 0 }, /* @__PURE__ */ e.createElement("title", null, String(l)), ge(l, Ft.maxChars)));
2548
+ })
2549
+ ), De, Ie), h ? /* @__PURE__ */ e.createElement(St, { items: $t, theme: r, hiddenSet: ee, onToggle: Qe, position: _e, onElementSelect: de }) : null);
2550
+ }, da = ({ chartType: t, barLayout: n, onChange: o, canStack: i, theme: r }) => {
2551
+ const f = (h, S = !1) => ({
2552
+ border: `1px solid ${h === n ? r.primary : r.border}`,
2553
+ background: h === n ? r.select : r.headerSubtleBg || r.hover,
2554
+ color: h === n ? r.primary : r.text,
2555
+ borderRadius: r.radiusSm || "8px",
2556
+ padding: "6px 8px",
2557
+ fontSize: "11px",
2558
+ fontWeight: 700,
2559
+ cursor: S ? "not-allowed" : "pointer",
2560
+ opacity: S ? 0.45 : 1
2561
+ });
2562
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("button", { onClick: () => o("grouped"), style: f("grouped") }, t === "area" ? "Normal" : "Grouped"), /* @__PURE__ */ e.createElement(
2563
+ "button",
2564
+ {
2565
+ onClick: () => {
2566
+ i && o("stacked");
2567
+ },
2568
+ style: f("stacked", !i),
2569
+ title: i ? t === "area" ? "Stack area series" : "Stack series or visible child rows" : t === "area" ? "Stacked area needs at least two visible series" : "Stacked bars need multiple visible series or visible child groups"
2570
+ },
2571
+ "Stacked"
2572
+ ), /* @__PURE__ */ e.createElement(
2573
+ "button",
2574
+ {
2575
+ onClick: () => {
2576
+ i && o("stacked100");
2577
+ },
2578
+ style: f("stacked100", !i),
2579
+ title: i ? "Normalize each category to 100%" : "Needs multiple series"
2580
+ },
2581
+ "100%"
2582
+ ));
2583
+ }, xa = ({ orientation: t, onChange: n, theme: o }) => {
2584
+ const i = (r) => ({
2585
+ border: `1px solid ${r === t ? o.primary : o.border}`,
2586
+ background: r === t ? o.select : o.headerSubtleBg || o.hover,
2587
+ color: r === t ? o.primary : o.text,
2588
+ borderRadius: o.radiusSm || "8px",
2589
+ padding: "6px 8px",
2590
+ fontSize: "11px",
2591
+ fontWeight: 700,
2592
+ cursor: "pointer"
2593
+ });
2594
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("button", { onClick: () => n("rows"), style: i("rows") }, "By Rows"), /* @__PURE__ */ e.createElement("button", { onClick: () => n("columns"), style: i("columns") }, "By Columns"));
2595
+ }, fa = ({ axisMode: t, onChange: n, theme: o }) => {
2596
+ const i = (r) => ({
2597
+ border: `1px solid ${r === t ? o.primary : o.border}`,
2598
+ background: r === t ? o.select : o.headerSubtleBg || o.hover,
2599
+ color: r === t ? o.primary : o.text,
2600
+ borderRadius: o.radiusSm || "8px",
2601
+ padding: "6px 8px",
2602
+ fontSize: "11px",
2603
+ fontWeight: 700,
2604
+ cursor: "pointer"
2605
+ });
2606
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("button", { onClick: () => n("vertical"), style: i("vertical") }, "Vertical"), /* @__PURE__ */ e.createElement("button", { onClick: () => n("horizontal"), style: i("horizontal") }, "Horizontal"));
2607
+ }, ga = ({ level: t, onChange: n, maxLevel: o, theme: i }) => {
2608
+ if (!o || o <= 1) return null;
2609
+ const r = (f) => ({
2610
+ border: `1px solid ${f === t ? i.primary : i.border}`,
2611
+ background: f === t ? i.select : i.headerSubtleBg || i.hover,
2612
+ color: f === t ? i.primary : i.text,
2613
+ borderRadius: i.radiusSm || "8px",
2614
+ padding: "6px 8px",
2615
+ fontSize: "11px",
2616
+ fontWeight: 700,
2617
+ cursor: "pointer",
2618
+ minWidth: "34px"
2619
+ });
2620
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("button", { onClick: () => n("all"), style: r("all") }, "All"), Array.from({ length: o }, (f, h) => h + 1).map((f) => /* @__PURE__ */ e.createElement("button", { key: f, onClick: () => n(f), style: r(f) }, f)));
2621
+ }, ma = ({ title: t, subtitle: n, note: o, theme: i }) => !t && !n && !o ? null : /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "4px" } }, t ? /* @__PURE__ */ e.createElement("div", { style: { fontSize: "14px", fontWeight: 800, color: i.text } }, t) : null, n ? /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: i.textSec } }, n) : null, o ? /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: i.textSec } }, o) : null), xe = ({ label: t, theme: n, children: o, controlMinWidth: i = "180px" }) => /* @__PURE__ */ e.createElement("div", { style: {
2622
+ display: "flex",
2623
+ alignItems: "flex-start",
2624
+ justifyContent: "space-between",
2625
+ gap: "10px",
2626
+ flexWrap: "wrap"
2627
+ } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "3px", flex: "1 1 180px", minWidth: "132px" } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", fontWeight: 700, color: n.text } }, t)), /* @__PURE__ */ e.createElement("div", { style: {
2628
+ display: "flex",
2629
+ justifyContent: "flex-end",
2630
+ alignItems: "flex-start",
2631
+ flex: "1 1 210px",
2632
+ minWidth: i
2633
+ } }, o)), ya = ({
2634
+ rowLimit: t,
2635
+ onRowLimitChange: n,
2636
+ columnLimit: o,
2637
+ onColumnLimitChange: i,
2638
+ theme: r
2639
+ }) => {
2640
+ const f = {
2641
+ width: "58px",
2642
+ border: `1px solid ${r.border}`,
2643
+ background: r.surfaceBg || r.background || "#fff",
2644
+ color: r.text,
2645
+ borderRadius: r.radiusSm || "8px",
2646
+ padding: "6px 8px",
2647
+ fontSize: "11px",
2648
+ fontWeight: 700
2649
+ }, h = {
2650
+ display: "flex",
2651
+ alignItems: "center",
2652
+ gap: "6px",
2653
+ color: r.textSec,
2654
+ fontSize: "11px",
2655
+ fontWeight: 700
2656
+ }, S = ($, R) => (C) => {
2657
+ $ && $(zn(C.target.value, R));
2658
+ };
2659
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("label", { style: h }, "Rows", /* @__PURE__ */ e.createElement(
2660
+ "input",
2661
+ {
2662
+ type: "number",
2663
+ min: "1",
2664
+ step: "1",
2665
+ value: t,
2666
+ onChange: S(n, Jr),
2667
+ style: f
2668
+ }
2669
+ )), /* @__PURE__ */ e.createElement("label", { style: h }, "Cols", /* @__PURE__ */ e.createElement(
2670
+ "input",
2671
+ {
2672
+ type: "number",
2673
+ min: "1",
2674
+ step: "1",
2675
+ value: o,
2676
+ onChange: S(i, Qr),
2677
+ style: f
2678
+ }
2679
+ )));
2680
+ }, ba = ({
2681
+ layers: t,
2682
+ onChange: n,
2683
+ availableColumns: o,
2684
+ theme: i
2685
+ }) => {
2686
+ const r = zr(o), f = Mn(t, r), [h, S] = _(""), $ = ot(
2687
+ () => An(r),
2688
+ [r]
2689
+ ), R = ot(
2690
+ () => new Map($.map((Y) => [Y.id, Y])),
2691
+ [$]
2692
+ ), C = h.trim().toLowerCase(), O = ot(
2693
+ () => C ? $.filter((Y) => Y.searchText.includes(C)) : $,
2694
+ [$, C]
2695
+ ), J = ot(() => {
2696
+ const Y = /* @__PURE__ */ new Map();
2697
+ return O.forEach((F) => {
2698
+ Y.has(F.groupLabel) || Y.set(F.groupLabel, []), Y.get(F.groupLabel).push(F);
2699
+ }), Array.from(Y.entries()).map(([F, U]) => ({ label: F, options: U }));
2700
+ }, [O]), K = {
2701
+ border: `1px solid ${i.border}`,
2702
+ background: i.surfaceBg || i.background || "#fff",
2703
+ color: i.text,
2704
+ borderRadius: i.radiusSm || "8px",
2705
+ padding: "6px 8px",
2706
+ fontSize: "11px",
2707
+ fontWeight: 700
2708
+ }, a = (Y, F) => {
2709
+ typeof n == "function" && n(f.map((U) => U.id === Y ? { ...U, ...F || {} } : U));
2710
+ }, X = (Y, F) => {
2711
+ if (typeof n != "function") return;
2712
+ const U = f.findIndex((pe) => pe.id === Y), ue = U + F;
2713
+ if (U < 0 || ue < 0 || ue >= f.length) return;
2714
+ const ne = [...f], [ie] = ne.splice(U, 1);
2715
+ ne.splice(ue, 0, ie), n(ne);
2716
+ }, T = (Y) => {
2717
+ if (typeof n != "function") return;
2718
+ const F = f.filter((U) => U.id !== Y);
2719
+ n(F.length > 0 ? F : Cn(r, 1));
2720
+ }, V = () => {
2721
+ if (typeof n != "function") return;
2722
+ const Y = new Set(f.map((ue) => ue.columnId)), F = r.find((ue) => !Y.has(ue.id)) || r[0];
2723
+ if (!F) return;
2724
+ const U = $n({
2725
+ id: `layer-${f.length + 1}`,
2726
+ type: Gr[f.length % Gr.length],
2727
+ columnId: F.id,
2728
+ axis: f.length === 1 ? "right" : "left",
2729
+ name: Wn(F)
2730
+ }, r, f.length);
2731
+ n([...f, U]);
2732
+ };
2733
+ return r.length === 0 ? /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: i.textSec } }, "No visible numeric/value columns are available for combo layers.") : /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "8px", width: "100%" } }, /* @__PURE__ */ e.createElement("div", { style: {
2734
+ display: "flex",
2735
+ flexWrap: "wrap",
2736
+ alignItems: "center",
2737
+ justifyContent: "space-between",
2738
+ gap: "8px",
2739
+ padding: "10px",
2740
+ border: `1px solid ${i.border}`,
2741
+ borderRadius: i.radiusSm || "8px",
2742
+ background: i.headerSubtleBg || i.hover
2743
+ } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "3px", flex: "1 1 240px", minWidth: "220px" } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", fontWeight: 800, color: i.text } }, "Measure Search"), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: i.textSec } }, "Search across all available chart measures and grouped pivot columns.")), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", flex: "1 1 320px", minWidth: "240px", justifyContent: "flex-end" } }, /* @__PURE__ */ e.createElement(
2744
+ "input",
2745
+ {
2746
+ type: "search",
2747
+ value: h,
2748
+ onChange: (Y) => S(Y.target.value),
2749
+ placeholder: "Search measures, groups, or column ids",
2750
+ style: { ...K, width: "100%", maxWidth: "360px" }
2751
+ }
2752
+ ), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 700, color: i.textSec, whiteSpace: "nowrap" } }, O.length, " / ", $.length))), O.length === 0 ? /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: i.textSec, padding: "2px 2px 0 2px" } }, "No measures match the current search. Clear the search to see the full catalog.") : null, f.map((Y, F) => {
2753
+ const U = R.get(Y.columnId) || null, ue = J.some((ne) => ne.options.some((ie) => ie.id === Y.columnId));
2754
+ return /* @__PURE__ */ e.createElement(
2755
+ "div",
2756
+ {
2757
+ key: Y.id,
2758
+ style: {
2759
+ display: "flex",
2760
+ flexDirection: "column",
2761
+ gap: "10px",
2762
+ width: "100%",
2763
+ padding: "12px",
2764
+ border: `1px solid ${i.border}`,
2765
+ borderRadius: i.radiusSm || "8px",
2766
+ background: i.surfaceBg || i.background || "#fff",
2767
+ boxShadow: i.shadowInset || "none"
2768
+ }
2769
+ },
2770
+ /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: "10px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "4px", minWidth: "180px" } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", fontWeight: 800, color: i.text } }, `Layer ${F + 1}`), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: i.textSec } }, U ? U.fullLabel : Y.name || "Select a measure"), U ? /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: i.textSec } }, `${U.groupLabel} | ${U.id}`) : null), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
2771
+ "button",
2772
+ {
2773
+ type: "button",
2774
+ onClick: () => X(Y.id, -1),
2775
+ disabled: F === 0,
2776
+ style: {
2777
+ border: `1px solid ${i.border}`,
2778
+ background: i.headerSubtleBg || i.hover,
2779
+ color: i.textSec,
2780
+ borderRadius: i.radiusSm || "8px",
2781
+ padding: "6px 8px",
2782
+ fontSize: "11px",
2783
+ fontWeight: 700,
2784
+ cursor: F === 0 ? "not-allowed" : "pointer",
2785
+ opacity: F === 0 ? 0.45 : 1
2786
+ }
2787
+ },
2788
+ "Up"
2789
+ ), /* @__PURE__ */ e.createElement(
2790
+ "button",
2791
+ {
2792
+ type: "button",
2793
+ onClick: () => X(Y.id, 1),
2794
+ disabled: F === f.length - 1,
2795
+ style: {
2796
+ border: `1px solid ${i.border}`,
2797
+ background: i.headerSubtleBg || i.hover,
2798
+ color: i.textSec,
2799
+ borderRadius: i.radiusSm || "8px",
2800
+ padding: "6px 8px",
2801
+ fontSize: "11px",
2802
+ fontWeight: 700,
2803
+ cursor: F === f.length - 1 ? "not-allowed" : "pointer",
2804
+ opacity: F === f.length - 1 ? 0.45 : 1
2805
+ }
2806
+ },
2807
+ "Down"
2808
+ ), /* @__PURE__ */ e.createElement(
2809
+ "button",
2810
+ {
2811
+ type: "button",
2812
+ onClick: () => T(Y.id),
2813
+ style: {
2814
+ border: `1px solid ${i.border}`,
2815
+ background: i.headerSubtleBg || i.hover,
2816
+ color: i.textSec,
2817
+ borderRadius: i.radiusSm || "8px",
2818
+ padding: "6px 8px",
2819
+ fontSize: "11px",
2820
+ fontWeight: 700,
2821
+ cursor: "pointer"
2822
+ }
2823
+ },
2824
+ "Remove"
2825
+ ))),
2826
+ /* @__PURE__ */ e.createElement("div", { style: {
2827
+ display: "grid",
2828
+ gridTemplateColumns: "repeat(auto-fit, minmax(180px, 1fr))",
2829
+ gap: "8px",
2830
+ alignItems: "start",
2831
+ width: "100%"
2832
+ } }, /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "5px", minWidth: 0 } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.06em", textTransform: "uppercase", color: i.textSec } }, "Measure"), /* @__PURE__ */ e.createElement(
2833
+ "select",
2834
+ {
2835
+ value: Y.columnId || "",
2836
+ onChange: (ne) => {
2837
+ const ie = R.get(ne.target.value) || null;
2838
+ a(Y.id, {
2839
+ columnId: ne.target.value,
2840
+ name: ie ? ie.fullLabel : Y.name
2841
+ });
2842
+ },
2843
+ style: K
2844
+ },
2845
+ !ue && U ? /* @__PURE__ */ e.createElement("optgroup", { label: "Current Layer Measure" }, /* @__PURE__ */ e.createElement("option", { value: U.id }, U.fullLabel)) : null,
2846
+ J.map((ne) => /* @__PURE__ */ e.createElement("optgroup", { key: ne.label, label: `${ne.label} (${ne.options.length})` }, ne.options.map((ie) => /* @__PURE__ */ e.createElement("option", { key: ie.id, value: ie.id }, ie.leafLabel))))
2847
+ )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "5px" } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.06em", textTransform: "uppercase", color: i.textSec } }, "Layer Type"), /* @__PURE__ */ e.createElement(
2848
+ "select",
2849
+ {
2850
+ value: Y.type,
2851
+ onChange: (ne) => a(Y.id, { type: ne.target.value }),
2852
+ style: K
2853
+ },
2854
+ /* @__PURE__ */ e.createElement("option", { value: "bar" }, "Bar"),
2855
+ /* @__PURE__ */ e.createElement("option", { value: "line" }, "Line"),
2856
+ /* @__PURE__ */ e.createElement("option", { value: "area" }, "Area")
2857
+ )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "5px" } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.06em", textTransform: "uppercase", color: i.textSec } }, "Axis"), /* @__PURE__ */ e.createElement(
2858
+ "select",
2859
+ {
2860
+ value: Y.axis,
2861
+ onChange: (ne) => a(Y.id, { axis: ne.target.value }),
2862
+ style: K
2863
+ },
2864
+ /* @__PURE__ */ e.createElement("option", { value: "left" }, "Left Axis"),
2865
+ /* @__PURE__ */ e.createElement("option", { value: "right" }, "Right Axis")
2866
+ )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "5px" } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.06em", textTransform: "uppercase", color: i.textSec } }, "Format"), /* @__PURE__ */ e.createElement(
2867
+ "select",
2868
+ {
2869
+ value: Y.valueFormat || "auto",
2870
+ onChange: (ne) => a(Y.id, { valueFormat: ne.target.value }),
2871
+ style: K
2872
+ },
2873
+ /* @__PURE__ */ e.createElement("option", { value: "auto" }, "Auto"),
2874
+ /* @__PURE__ */ e.createElement("option", { value: "number" }, "Number"),
2875
+ /* @__PURE__ */ e.createElement("option", { value: "compact" }, "Compact (K/M)"),
2876
+ /* @__PURE__ */ e.createElement("option", { value: "percent" }, "Percent"),
2877
+ /* @__PURE__ */ e.createElement("option", { value: "currency" }, "Currency ($)")
2878
+ )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "5px" } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.06em", textTransform: "uppercase", color: i.textSec } }, "Color"), /* @__PURE__ */ e.createElement(
2879
+ "input",
2880
+ {
2881
+ type: "color",
2882
+ value: Y.color || "#6366f1",
2883
+ onChange: (ne) => a(Y.id, { color: ne.target.value }),
2884
+ style: { width: "100%", height: "34px", padding: "2px 4px", border: `1px solid ${i.border}`, borderRadius: i.radiusSm || "8px", cursor: "pointer", background: "none" },
2885
+ title: "Override color for this layer"
2886
+ }
2887
+ )))
2888
+ );
2889
+ }), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(
2890
+ "button",
2891
+ {
2892
+ type: "button",
2893
+ onClick: V,
2894
+ style: {
2895
+ border: `1px solid ${i.primary}`,
2896
+ background: i.select,
2897
+ color: i.primary,
2898
+ borderRadius: i.radiusSm || "8px",
2899
+ padding: "6px 10px",
2900
+ fontSize: "11px",
2901
+ fontWeight: 700,
2902
+ cursor: "pointer"
2903
+ }
2904
+ },
2905
+ "Add Layer"
2906
+ )));
2907
+ }, ha = ({ sortMode: t, onChange: n, theme: o }) => {
2908
+ const i = [
2909
+ { value: "natural", label: "Natural" },
2910
+ { value: "value_desc", label: "Value Desc" },
2911
+ { value: "value_asc", label: "Value Asc" },
2912
+ { value: "label_asc", label: "Label A-Z" },
2913
+ { value: "label_desc", label: "Label Z-A" }
2914
+ ];
2915
+ return /* @__PURE__ */ e.createElement(
2916
+ "select",
2917
+ {
2918
+ value: t,
2919
+ onChange: (r) => n(r.target.value),
2920
+ style: {
2921
+ border: `1px solid ${o.border}`,
2922
+ background: o.surfaceBg || o.background || "#fff",
2923
+ color: o.text,
2924
+ borderRadius: o.radiusSm || "8px",
2925
+ padding: "6px 8px",
2926
+ fontSize: "11px",
2927
+ fontWeight: 700,
2928
+ minWidth: "132px"
2929
+ },
2930
+ title: "Chart ordering"
2931
+ },
2932
+ i.map((r) => /* @__PURE__ */ e.createElement("option", { key: r.value, value: r.value }, r.label))
2933
+ );
2934
+ }, va = ({ interactionMode: t, onChange: n, theme: o }) => {
2935
+ const i = (r) => ({
2936
+ border: `1px solid ${r === t ? o.primary : o.border}`,
2937
+ background: r === t ? o.select : o.headerSubtleBg || o.hover,
2938
+ color: r === t ? o.primary : o.text,
2939
+ borderRadius: o.radiusSm || "8px",
2940
+ padding: "6px 8px",
2941
+ fontSize: "11px",
2942
+ fontWeight: 700,
2943
+ cursor: "pointer"
2944
+ });
2945
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("button", { onClick: () => n("focus"), style: i("focus"), title: "Jump the grid to the matching row or column" }, "Jump to Grid"), /* @__PURE__ */ e.createElement("button", { onClick: () => n("filter"), style: i("filter"), title: "Apply the clicked chart item as a pivot filter" }, "Filter Grid"), /* @__PURE__ */ e.createElement("button", { onClick: () => n("event"), style: i("event"), title: "Send the chart click to Dash only and leave the grid unchanged" }, "No Grid Change"));
2946
+ }, Ea = ({ scope: t, onChange: n, theme: o }) => {
2947
+ const i = (r) => ({
2948
+ border: `1px solid ${r === t ? o.primary : o.border}`,
2949
+ background: r === t ? o.select : o.headerSubtleBg || o.hover,
2950
+ color: r === t ? o.primary : o.text,
2951
+ borderRadius: o.radiusSm || "8px",
2952
+ padding: "6px 8px",
2953
+ fontSize: "11px",
2954
+ fontWeight: 700,
2955
+ cursor: "pointer"
2956
+ });
2957
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("button", { onClick: () => n("viewport"), style: i("viewport") }, "Viewport"), /* @__PURE__ */ e.createElement("button", { onClick: () => n("root"), style: i("root") }, "From Start"));
2958
+ }, ar = "http://www.w3.org/2000/svg", Rr = (t, n) => {
2959
+ if (!t || typeof document > "u") return null;
2960
+ const o = vr(n), i = t.cloneNode(!0), r = (i.getAttribute("viewBox") || "").split(/[\s,]+/).map(Number), f = r.length === 4 && r[2] > 0 ? r[2] : t.clientWidth || 800, h = r.length === 4 && r[3] > 0 ? r[3] : t.clientHeight || 400, S = o.title ? 42 : 0, $ = tn(
2961
+ o.legendItems,
2962
+ f,
2963
+ (T) => String(T || "").length * 6.4
2964
+ ), R = $.length > 0 ? $.length * 22 + 14 : 0, C = o.legendPosition === "top" ? R : 0, O = S + C, J = S + h + R, K = Array.from(i.childNodes), a = document.createElementNS(ar, "g");
2965
+ a.setAttribute("transform", `translate(0 ${O})`), K.forEach((T) => a.appendChild(T)), i.appendChild(a), i.setAttribute("viewBox", `0 0 ${f} ${J}`), i.setAttribute("width", String(f)), i.setAttribute("height", String(J)), i.setAttribute("xmlns", ar);
2966
+ const X = document.createElementNS(ar, "rect");
2967
+ if (X.setAttribute("x", "0"), X.setAttribute("y", "0"), X.setAttribute("width", String(f)), X.setAttribute("height", String(J)), X.setAttribute("fill", o.background), i.insertBefore(X, a), o.title) {
2968
+ const T = document.createElementNS(ar, "text");
2969
+ T.setAttribute("x", "16"), T.setAttribute("y", "27"), T.setAttribute("fill", o.textColor), T.setAttribute("font-size", "16"), T.setAttribute("font-weight", "700"), T.setAttribute("font-family", "Inter, Arial, sans-serif"), T.textContent = o.title, i.appendChild(T);
2970
+ }
2971
+ if ($.length > 0) {
2972
+ const T = o.legendPosition === "top" ? S + 16 : S + h + 18;
2973
+ $.forEach((V, Y) => {
2974
+ let F = 16;
2975
+ V.forEach((U) => {
2976
+ const ue = T + Y * 22, ne = document.createElementNS(ar, "circle");
2977
+ ne.setAttribute("cx", String(F + 5)), ne.setAttribute("cy", String(ue - 4)), ne.setAttribute("r", "5"), ne.setAttribute("fill", U.hidden ? o.secondaryTextColor : U.color || "#2563eb"), ne.setAttribute("opacity", U.hidden ? "0.35" : "1"), i.appendChild(ne);
2978
+ const ie = document.createElementNS(ar, "text");
2979
+ ie.setAttribute("x", String(F + 16)), ie.setAttribute("y", String(ue)), ie.setAttribute("fill", o.secondaryTextColor), ie.setAttribute("font-size", "11"), ie.setAttribute("font-family", "Inter, Arial, sans-serif"), ie.setAttribute("opacity", U.hidden ? "0.45" : "1"), ie.textContent = U.label, i.appendChild(ie), F += U.width;
2980
+ });
2981
+ });
2982
+ }
2983
+ return i;
2984
+ }, ka = async (t, n, o) => {
2985
+ if (!t || typeof window > "u") return;
2986
+ const i = Rr(t, o);
2987
+ if (!i) return;
2988
+ const f = new XMLSerializer().serializeToString(i), h = new Blob([f], { type: "image/svg+xml;charset=utf-8" });
2989
+ hr(h, `${n}.svg`);
2990
+ }, rn = (t, n = 2) => new Promise((o) => {
2991
+ if (!t) {
2992
+ o(null);
2993
+ return;
2994
+ }
2995
+ const r = new XMLSerializer().serializeToString(t), f = t.getAttribute("viewBox");
2996
+ let h = t.clientWidth || 800, S = t.clientHeight || 400;
2997
+ if (f) {
2998
+ const K = f.split(/[\s,]+/).map(Number);
2999
+ K.length === 4 && K[2] > 0 && K[3] > 0 && (h = K[2], S = K[3]);
3000
+ }
3001
+ const $ = document.createElement("canvas");
3002
+ $.width = h * n, $.height = S * n;
3003
+ const R = $.getContext("2d");
3004
+ R.fillStyle = "#ffffff", R.fillRect(0, 0, $.width, $.height);
3005
+ const C = new Image(), O = new Blob([r], { type: "image/svg+xml;charset=utf-8" }), J = URL.createObjectURL(O);
3006
+ C.onload = () => {
3007
+ R.drawImage(C, 0, 0, $.width, $.height), URL.revokeObjectURL(J), o($);
3008
+ }, C.onerror = () => {
3009
+ URL.revokeObjectURL(J), o(null);
3010
+ }, C.src = J;
3011
+ }), wa = async (t, n, o) => {
3012
+ const i = await rn(Rr(t, o));
3013
+ i && i.toBlob((r) => {
3014
+ r && hr(r, `${n}.png`);
3015
+ }, "image/png");
3016
+ }, Sa = async (t, n) => {
3017
+ if (typeof navigator > "u" || !navigator.clipboard || !navigator.clipboard.write) return !1;
3018
+ const o = await rn(Rr(t, n));
3019
+ if (!o) return !1;
3020
+ try {
3021
+ const i = await new Promise((r) => o.toBlob(r, "image/png"));
3022
+ return i ? (await navigator.clipboard.write([new ClipboardItem({ "image/png": i })]), !0) : !1;
3023
+ } catch {
3024
+ return !1;
3025
+ }
3026
+ }, gt = /* @__PURE__ */ new Set(["bar3d", "line3d", "scatter3d", "range", "boxplot", "nightingale"]), Ma = (t) => new Promise((n) => {
3027
+ const o = new Image();
3028
+ o.onload = () => n(o), o.onerror = () => n(null), o.src = t;
3029
+ }), nn = async (t, n) => {
3030
+ const o = t && t.current && t.current.getEchartsInstance();
3031
+ if (!o) return null;
3032
+ const i = vr(n), r = o.getDataURL({ type: "png", pixelRatio: 2 }), f = await Ma(r);
3033
+ if (!f) return null;
3034
+ const h = Math.max(1, f.naturalWidth / Math.max(1, o.getWidth())), S = i.title ? Math.round(42 * h) : 0, R = document.createElement("canvas").getContext("2d");
3035
+ R.font = "11px Inter, Arial, sans-serif";
3036
+ const C = tn(
3037
+ i.legendItems,
3038
+ o.getWidth(),
3039
+ (T) => R.measureText(String(T || "")).width
3040
+ ), O = C.length > 0 ? Math.round((C.length * 22 + 14) * h) : 0, J = i.legendPosition === "top" ? O : 0, K = S + J, a = document.createElement("canvas");
3041
+ a.width = f.naturalWidth, a.height = S + f.naturalHeight + O;
3042
+ const X = a.getContext("2d");
3043
+ if (X.fillStyle = i.background, X.fillRect(0, 0, a.width, a.height), X.drawImage(f, 0, K), i.title && (X.fillStyle = i.textColor, X.font = `700 ${Math.round(16 * h)}px Inter, Arial, sans-serif`, X.textBaseline = "alphabetic", X.fillText(i.title, Math.round(16 * h), Math.round(27 * h))), C.length > 0) {
3044
+ const T = i.legendPosition === "top" ? S + Math.round(16 * h) : S + f.naturalHeight + Math.round(18 * h);
3045
+ X.font = `${Math.round(11 * h)}px Inter, Arial, sans-serif`, C.forEach((V, Y) => {
3046
+ let F = Math.round(16 * h);
3047
+ V.forEach((U) => {
3048
+ const ue = T + Math.round(Y * 22 * h);
3049
+ X.globalAlpha = U.hidden ? 0.35 : 1, X.fillStyle = U.hidden ? i.secondaryTextColor : U.color || "#2563eb", X.beginPath(), X.arc(F + Math.round(5 * h), ue - Math.round(4 * h), Math.round(5 * h), 0, Math.PI * 2), X.fill(), X.globalAlpha = U.hidden ? 0.45 : 1, X.fillStyle = i.secondaryTextColor, X.fillText(U.label, F + Math.round(16 * h), ue), X.globalAlpha = 1, F += Math.round(U.width * h);
3050
+ });
3051
+ });
3052
+ }
3053
+ return a;
3054
+ }, Aa = async (t, n, o) => {
3055
+ const i = await nn(t, o);
3056
+ i && i.toBlob((r) => {
3057
+ r && hr(r, `${n}.png`);
3058
+ }, "image/png");
3059
+ }, Ca = async (t, n) => {
3060
+ if (!(t && t.current && t.current.getEchartsInstance()) || typeof navigator > "u" || !navigator.clipboard || !navigator.clipboard.write) return !1;
3061
+ try {
3062
+ const i = await nn(t, n);
3063
+ if (!i) return !1;
3064
+ const r = await new Promise((f) => i.toBlob(f, "image/png"));
3065
+ return r ? (await navigator.clipboard.write([new ClipboardItem({ "image/png": r })]), !0) : !1;
3066
+ } catch {
3067
+ return !1;
3068
+ }
3069
+ }, an = ({
3070
+ model: t,
3071
+ chartType: n,
3072
+ chartLayers: o,
3073
+ onChartLayersChange: i,
3074
+ availableColumns: r,
3075
+ barLayout: f,
3076
+ axisMode: h,
3077
+ onChartTypeChange: S,
3078
+ onBarLayoutChange: $,
3079
+ onAxisModeChange: R,
3080
+ orientation: C,
3081
+ onOrientationChange: O,
3082
+ hierarchyLevel: J,
3083
+ onHierarchyLevelChange: K,
3084
+ theme: a,
3085
+ title: X,
3086
+ onTitleChange: T,
3087
+ subtitle: V,
3088
+ note: Y,
3089
+ chartHeight: F,
3090
+ onChartHeightChange: U,
3091
+ rowLimit: ue,
3092
+ onRowLimitChange: ne,
3093
+ columnLimit: ie,
3094
+ onColumnLimitChange: pe,
3095
+ sortMode: it,
3096
+ onSortModeChange: be,
3097
+ interactionMode: st,
3098
+ onInteractionModeChange: Te,
3099
+ serverScope: Vt,
3100
+ onServerScopeChange: ct,
3101
+ showServerScope: et = !1,
3102
+ floating: _e = !1,
3103
+ immersiveMode: Me = !1,
3104
+ onCategoryActivate: Gt,
3105
+ allowHierarchyCharts: ir = !0,
3106
+ locked: nt = !1,
3107
+ onToggleLock: Tt,
3108
+ configOpen: Ut,
3109
+ onConfigChange: tt,
3110
+ settingsPanelWidth: mt,
3111
+ onSettingsPanelWidthChange: Kt,
3112
+ initialSettings: z = {},
3113
+ onSettingsChange: Bt
3114
+ }) => {
3115
+ const de = n === "combo", Ee = n === "sparkline", P = de ? !1 : n === "area" ? en(t) : Zr(t), Oe = X !== void 0 ? X : t && t.title, Lt = V !== void 0 ? V : t && t.subtitle, yt = Y !== void 0 ? Y : nt ? _e ? "Locked to the current chart request and floating frame" : "Locked to the current chart request" : t && t.note, [ut, Pe] = _(!1), ke = typeof Ut == "boolean" ? Ut : ut, W = typeof tt == "function" ? tt : Pe, [he, Rt] = _(() => (z == null ? void 0 : z.showDataLabels) ?? !1), [ve, bt] = _(() => (z == null ? void 0 : z.colorPalette) ?? "default"), [pt, Ye] = _(() => (z == null ? void 0 : z.valueFormat) ?? "auto"), [Mt, sr] = _(() => (z == null ? void 0 : z.yAxisTitle) ?? ""), [Z, ee] = _(() => (z == null ? void 0 : z.yAxisMin) ?? ""), [Dt, Qe] = _(() => (z == null ? void 0 : z.yAxisMax) ?? ""), [$e, Ue] = _(() => (z == null ? void 0 : z.referenceLines) ?? []), [Ke, ht] = _({ value: "", label: "", orient: "h" }), [dt, Ie] = _(() => (z == null ? void 0 : z.labelAngle) ?? 0), [Le, _t] = _(() => (z == null ? void 0 : z.chartSubtitle) ?? ""), [at, Re] = _(() => (z == null ? void 0 : z.tickCount) ?? 5), [Je, vt] = _(() => (z == null ? void 0 : z.markerShape) ?? "circle"), [Et, lt] = _(() => (z == null ? void 0 : z.markerSize) ?? 4), [Ze, xt] = _(() => (z == null ? void 0 : z.showGradient) ?? !1), [Ve, Nt] = _(() => (z == null ? void 0 : z.seriesColors) ?? {}), [ft, At] = _(() => (z == null ? void 0 : z.showAnimations) ?? !0), [We, te] = _(() => (z == null ? void 0 : z.showCalloutLabels) ?? !1), [Be, qe] = _(() => (z == null ? void 0 : z.showTrendline) ?? !1), [we, Xe] = _(() => (z == null ? void 0 : z.trendlineMode) ?? "linear"), [rt, cr] = _(() => (z == null ? void 0 : z.trendlinePeriod) ?? 3), [kt, pr] = _(() => (z == null ? void 0 : z.legendPosition) ?? "bottom"), [Pt, Zt] = _(() => (z == null ? void 0 : z.labelPosition) ?? "outside"), [qt, Qt] = _(() => (z == null ? void 0 : z.decimalPlaces) ?? -1), [It, Er] = _(() => (z == null ? void 0 : z.gradientDirection) ?? "vertical"), [Ht, kr] = _(() => (z == null ? void 0 : z.gradientOpacity) ?? 70), [De, d] = _(() => (z == null ? void 0 : z.trendlineColor) ?? ""), [Ft, wr] = _(() => (z == null ? void 0 : z.trendlineWidth) ?? 2), [Ct, dr] = _(() => (z == null ? void 0 : z.seriesSort) ?? "none"), [$t, Jt] = _(() => (z == null ? void 0 : z.customPaletteColors) ?? []), [Xt, Sr] = _(() => (z == null ? void 0 : z.lineDashStyles) ?? {}), [l, c] = _(() => (z == null ? void 0 : z.yAxisMinRight) ?? ""), [s, p] = _(() => (z == null ? void 0 : z.yAxisMaxRight) ?? ""), [x, g] = _("chart"), [E, m] = _(!0), [w, k] = _(!0), y = je((u) => {
3116
+ const me = { series: "style", axis: "axes", legend: "labels", title: "data" }[u];
3117
+ me && (W(!0), g(me));
3118
+ }, [W]), I = Kr(ve), [j, M] = _(String(F || or)), v = Fe(null), B = Fe(null), D = Fe(null), [H, G] = _(null), [se, b] = _(!1), { anchorRef: q, menuRef: le, position: A, portalTarget: L } = Ln(se, b), [ce, oe] = _(null), [ae, N] = _(348), re = Number.isFinite(Number(mt)) ? Math.max(300, Math.min(680, Math.floor(Number(mt)))) : ae, fe = typeof Kt == "function" ? Kt : N, Ne = !Me, wt = Me && ce ? Math.max(180, ce - (Me && !Ee && kt !== "none" ? 44 : 0) - 44) : Math.max(180, Number.isFinite(Number(F)) ? Number(F) : or), tr = Fe(null), Ot = Fe(null), Mr = Fe(null), Dr = t && t.maxHierarchyLevel || 1, xr = typeof K == "function" && Dr > 1, Nr = {
3119
+ width: "32px",
3120
+ height: "32px",
3121
+ display: "inline-flex",
3122
+ alignItems: "center",
3123
+ justifyContent: "center",
3124
+ border: `1px solid ${ke ? a.primary : a.border}`,
3125
+ background: ke ? a.select : a.headerSubtleBg || a.hover,
3126
+ color: ke ? a.primary : a.textSec,
3127
+ borderRadius: a.radiusSm || "8px",
3128
+ cursor: "pointer",
3129
+ flexShrink: 0
3130
+ }, ln = {
3131
+ ...Nr,
3132
+ border: `1px solid ${nt ? a.primary : a.border}`,
3133
+ background: nt ? a.select : a.headerSubtleBg || a.hover,
3134
+ color: nt ? a.primary : a.textSec
3135
+ }, jt = {
3136
+ border: `1px solid ${a.border}`,
3137
+ background: a.headerSubtleBg || a.hover,
3138
+ color: a.textSec,
3139
+ borderRadius: a.radiusSm || "8px",
3140
+ padding: "6px 8px",
3141
+ fontSize: "11px",
3142
+ fontWeight: 700,
3143
+ cursor: "pointer"
3144
+ }, Ae = {
3145
+ border: `1px solid ${a.border}`,
3146
+ background: a.surfaceBg || a.background || "#fff",
3147
+ color: a.text,
3148
+ borderRadius: a.radiusSm || "8px",
3149
+ padding: "6px 8px",
3150
+ fontSize: "11px",
3151
+ fontWeight: 600,
3152
+ minWidth: "68px"
3153
+ }, on = je((u) => {
3154
+ if (u === "trend") {
3155
+ S("line"), typeof O == "function" && O("rows"), typeof be == "function" && be("natural");
3156
+ return;
3157
+ }
3158
+ if (u === "compare") {
3159
+ S("bar"), typeof $ == "function" && $("grouped"), typeof R == "function" && R("vertical");
3160
+ return;
3161
+ }
3162
+ if (u === "composition") {
3163
+ S(xr ? "sunburst" : "donut");
3164
+ return;
3165
+ }
3166
+ if (u === "flow") {
3167
+ S("waterfall");
3168
+ return;
3169
+ }
3170
+ u === "sparkline" && S("sparkline");
3171
+ }, [
3172
+ R,
3173
+ $,
3174
+ S,
3175
+ O,
3176
+ be,
3177
+ xr
3178
+ ]);
3179
+ He(() => {
3180
+ !Me || !ke || W(!1);
3181
+ }, [Me, ke]), He(() => {
3182
+ if (!H) return;
3183
+ const u = setTimeout(() => G(null), 2500);
3184
+ return () => clearTimeout(u);
3185
+ }, [H]);
3186
+ const fr = je(() => ra(
3187
+ Mr.current,
3188
+ Oe,
3189
+ kt,
3190
+ a
3191
+ ), [kt, Oe, a]), sn = je(async (u) => {
3192
+ b(!1);
3193
+ const Q = fr();
3194
+ if (u === "svg") {
3195
+ gt.has(n) || await ka(tr.current, "pivot-chart", Q);
3196
+ return;
3197
+ }
3198
+ if (u === "png") {
3199
+ gt.has(n) ? await Aa(Ot, "pivot-chart", Q) : await wa(tr.current, "pivot-chart", Q);
3200
+ return;
3201
+ }
3202
+ u === "csv" && na(t, "pivot-chart", Q);
3203
+ }, [n, fr, t]), cn = je(async () => {
3204
+ const u = fr(), Q = gt.has(n) ? await Ca(Ot, u) : await Sa(tr.current, u);
3205
+ G(Q ? { tone: "success", text: "Copied chart" } : { tone: "error", text: "Copy failed" });
3206
+ }, [n, fr]);
3207
+ He(() => {
3208
+ if (!Me) {
3209
+ oe(null);
3210
+ return;
3211
+ }
3212
+ const u = D.current;
3213
+ if (!u) return;
3214
+ const Q = () => {
3215
+ const ye = u.clientHeight;
3216
+ ye > 0 && oe(ye);
3217
+ };
3218
+ if (Q(), typeof ResizeObserver > "u") return;
3219
+ const me = new ResizeObserver(Q);
3220
+ return me.observe(u), () => me.disconnect();
3221
+ }, [Me]);
3222
+ const Ar = Fe(U);
3223
+ He(() => {
3224
+ Ar.current = U;
3225
+ }), He(() => {
3226
+ const u = (me) => {
3227
+ if (!v.current || typeof Ar.current != "function") return;
3228
+ const ye = v.current, Ge = Math.max(180, ye.startHeight + (me.clientY - ye.startY));
3229
+ Ar.current(Ge);
3230
+ }, Q = () => {
3231
+ v.current = null;
3232
+ };
3233
+ return window.addEventListener("mousemove", u), window.addEventListener("mouseup", Q), window.addEventListener("blur", Q), () => {
3234
+ window.removeEventListener("mousemove", u), window.removeEventListener("mouseup", Q), window.removeEventListener("blur", Q);
3235
+ };
3236
+ }, []), He(() => {
3237
+ const u = (me) => {
3238
+ if (!B.current) return;
3239
+ const ye = B.current, Ge = ye.direction === "left" ? ye.startX - me.clientX : me.clientX - ye.startX, rr = Math.max(300, Math.min(680, ye.startWidth + Ge));
3240
+ fe(rr);
3241
+ }, Q = () => {
3242
+ B.current = null;
3243
+ };
3244
+ return window.addEventListener("mousemove", u), window.addEventListener("mouseup", Q), window.addEventListener("blur", Q), () => {
3245
+ window.removeEventListener("mousemove", u), window.removeEventListener("mouseup", Q), window.removeEventListener("blur", Q);
3246
+ };
3247
+ }, []), He(() => {
3248
+ const u = Mr.current;
3249
+ if (!u || typeof ResizeObserver > "u") return;
3250
+ let Q = u.clientWidth;
3251
+ const me = new ResizeObserver(() => {
3252
+ var Ge, rr;
3253
+ const ye = u.clientWidth;
3254
+ if (ye !== Q) {
3255
+ Q = ye;
3256
+ const Ir = (rr = (Ge = Ot.current) == null ? void 0 : Ge.getEchartsInstance) == null ? void 0 : rr.call(Ge);
3257
+ Ir && Ir.resize();
3258
+ }
3259
+ });
3260
+ return me.observe(u), () => me.disconnect();
3261
+ }, []), He(() => {
3262
+ M(String(wt));
3263
+ }, [wt]);
3264
+ const Cr = Fe(Bt);
3265
+ He(() => {
3266
+ Cr.current = Bt;
3267
+ });
3268
+ const Pr = Fe(!0);
3269
+ He(() => {
3270
+ if (Pr.current) {
3271
+ Pr.current = !1;
3272
+ return;
3273
+ }
3274
+ typeof Cr.current == "function" && Cr.current({
3275
+ showDataLabels: he,
3276
+ colorPalette: ve,
3277
+ valueFormat: pt,
3278
+ yAxisTitle: Mt,
3279
+ yAxisMin: Z,
3280
+ yAxisMax: Dt,
3281
+ referenceLines: $e,
3282
+ labelAngle: dt,
3283
+ chartSubtitle: Le,
3284
+ tickCount: at,
3285
+ markerShape: Je,
3286
+ markerSize: Et,
3287
+ showGradient: Ze,
3288
+ seriesColors: Ve,
3289
+ showAnimations: ft,
3290
+ showCalloutLabels: We,
3291
+ showTrendline: Be,
3292
+ trendlineMode: we,
3293
+ trendlinePeriod: rt,
3294
+ legendPosition: kt,
3295
+ labelPosition: Pt,
3296
+ decimalPlaces: qt,
3297
+ gradientDirection: It,
3298
+ gradientOpacity: Ht,
3299
+ trendlineColor: De,
3300
+ trendlineWidth: Ft,
3301
+ seriesSort: Ct,
3302
+ customPaletteColors: $t,
3303
+ lineDashStyles: Xt,
3304
+ yAxisMinRight: l,
3305
+ yAxisMaxRight: s
3306
+ });
3307
+ }, [
3308
+ he,
3309
+ ve,
3310
+ pt,
3311
+ Mt,
3312
+ Z,
3313
+ Dt,
3314
+ $e,
3315
+ dt,
3316
+ Le,
3317
+ at,
3318
+ Je,
3319
+ Et,
3320
+ Ze,
3321
+ Ve,
3322
+ ft,
3323
+ We,
3324
+ Be,
3325
+ we,
3326
+ rt,
3327
+ kt,
3328
+ Pt,
3329
+ qt,
3330
+ It,
3331
+ Ht,
3332
+ De,
3333
+ Ft,
3334
+ Ct,
3335
+ $t,
3336
+ Xt,
3337
+ l,
3338
+ s
3339
+ ]);
3340
+ const $r = ot(() => {
3341
+ if (!t || !Array.isArray(t.series)) return null;
3342
+ let u = 1 / 0, Q = -1 / 0;
3343
+ return t.series.forEach((me) => {
3344
+ (me.values || []).forEach((ye) => {
3345
+ typeof ye == "number" && Number.isFinite(ye) && (u = Math.min(u, ye), Q = Math.max(Q, ye));
3346
+ });
3347
+ }), Number.isFinite(u) && u !== Q ? { min: u, max: Q } : null;
3348
+ }, [t]);
3349
+ return /* @__PURE__ */ e.createElement(
3350
+ "div",
3351
+ {
3352
+ ref: D,
3353
+ style: {
3354
+ display: "flex",
3355
+ flexDirection: "column",
3356
+ gap: Ne ? "14px" : "10px",
3357
+ flex: "1 1 auto",
3358
+ minHeight: 0,
3359
+ overflow: "hidden"
3360
+ }
3361
+ },
3362
+ Ne || Me ? /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: "12px" } }, /* @__PURE__ */ e.createElement(
3363
+ ma,
3364
+ {
3365
+ title: Me ? Oe : null,
3366
+ subtitle: Lt,
3367
+ note: yt,
3368
+ theme: a
3369
+ }
3370
+ ), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "6px", flexWrap: "wrap", justifyContent: "flex-end" } }, /* @__PURE__ */ e.createElement("div", { style: { position: "relative" } }, /* @__PURE__ */ e.createElement(
3371
+ "button",
3372
+ {
3373
+ type: "button",
3374
+ ref: q,
3375
+ onClick: () => b((u) => !u),
3376
+ onKeyDown: (u) => {
3377
+ (u.key === "ArrowDown" || u.key === "ArrowUp") && (u.preventDefault(), b(!0));
3378
+ },
3379
+ style: jt,
3380
+ title: "Export chart",
3381
+ "aria-haspopup": "menu",
3382
+ "aria-expanded": se
3383
+ },
3384
+ /* @__PURE__ */ e.createElement("span", { style: { display: "inline-flex", alignItems: "center", gap: "5px" } }, "Export ", /* @__PURE__ */ e.createElement(lr.ChevronDown, null))
3385
+ ), se && L ? un(
3386
+ /* @__PURE__ */ e.createElement(
3387
+ "div",
3388
+ {
3389
+ ref: le,
3390
+ role: "menu",
3391
+ "aria-label": "Chart export formats",
3392
+ style: {
3393
+ position: "fixed",
3394
+ ...A,
3395
+ visibility: A ? "visible" : "hidden",
3396
+ zIndex: 10060,
3397
+ width: "190px",
3398
+ boxSizing: "border-box",
3399
+ overflowY: "auto",
3400
+ fontFamily: "inherit",
3401
+ padding: "6px",
3402
+ border: `1px solid ${a.border}`,
3403
+ borderRadius: a.radiusSm || "8px",
3404
+ background: a.surfaceBg || a.background || "#fff",
3405
+ boxShadow: a.shadowMd || "0 12px 28px rgba(15,23,42,0.18)"
3406
+ }
3407
+ },
3408
+ [
3409
+ { format: "svg", label: "SVG image", hint: "Title + legend included", disabled: gt.has(n) },
3410
+ { format: "png", label: "PNG image", hint: "Title + legend included", disabled: !1 },
3411
+ { format: "csv", label: "CSV data", hint: "Title + legend metadata", disabled: !1 }
3412
+ ].map((u) => /* @__PURE__ */ e.createElement(
3413
+ "button",
3414
+ {
3415
+ key: u.format,
3416
+ type: "button",
3417
+ role: "menuitem",
3418
+ disabled: u.disabled,
3419
+ onClick: () => {
3420
+ var Q;
3421
+ (Q = q.current) == null || Q.focus(), sn(u.format);
3422
+ },
3423
+ title: u.disabled ? "SVG export is unavailable for this chart type" : void 0,
3424
+ style: {
3425
+ width: "100%",
3426
+ display: "flex",
3427
+ flexDirection: "column",
3428
+ alignItems: "flex-start",
3429
+ gap: "2px",
3430
+ border: "none",
3431
+ borderRadius: a.radiusSm || "7px",
3432
+ background: "transparent",
3433
+ color: u.disabled ? a.textSec : a.text,
3434
+ opacity: u.disabled ? 0.45 : 1,
3435
+ padding: "8px 9px",
3436
+ cursor: u.disabled ? "not-allowed" : "pointer",
3437
+ textAlign: "left"
3438
+ },
3439
+ onMouseEnter: (Q) => {
3440
+ u.disabled || (Q.currentTarget.style.background = a.hover);
3441
+ },
3442
+ onMouseLeave: (Q) => {
3443
+ Q.currentTarget.style.background = "transparent";
3444
+ }
3445
+ },
3446
+ /* @__PURE__ */ e.createElement("span", { style: { fontSize: "11px", fontWeight: 800 } }, u.label),
3447
+ /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: a.textSec } }, u.hint)
3448
+ ))
3449
+ ),
3450
+ L
3451
+ ) : null), /* @__PURE__ */ e.createElement(
3452
+ "button",
3453
+ {
3454
+ type: "button",
3455
+ onClick: cn,
3456
+ style: jt,
3457
+ title: "Copy chart with title and legend"
3458
+ },
3459
+ "Copy"
3460
+ ), H ? /* @__PURE__ */ e.createElement(
3461
+ "span",
3462
+ {
3463
+ role: "status",
3464
+ style: {
3465
+ fontSize: "10px",
3466
+ fontWeight: 800,
3467
+ color: H.tone === "success" ? a.primary || "#047857" : "#B91C1C",
3468
+ border: `1px solid ${H.tone === "success" ? `${a.primary || "#047857"}55` : "#FCA5A5"}`,
3469
+ borderRadius: "999px",
3470
+ padding: "3px 7px",
3471
+ background: H.tone === "success" ? `${a.primary || "#047857"}10` : "#FEF2F2"
3472
+ }
3473
+ },
3474
+ H.text
3475
+ ) : null, typeof Tt == "function" ? /* @__PURE__ */ e.createElement(
3476
+ "button",
3477
+ {
3478
+ type: "button",
3479
+ onClick: Tt,
3480
+ style: { ...ln, width: "auto", padding: "0 10px", gap: "6px", fontSize: "11px", fontWeight: 800 },
3481
+ title: nt ? "Data is fixed to the saved selection. Click to resume live pivot updates." : "Keep this chart fixed to the current data selection while the pivot changes.",
3482
+ "aria-label": nt ? "Unlock chart data and resume live updates" : "Lock chart to the current data selection",
3483
+ "aria-pressed": nt
3484
+ },
3485
+ /* @__PURE__ */ e.createElement(lr.Lock, null),
3486
+ /* @__PURE__ */ e.createElement("span", null, nt ? "Data locked" : "Lock data")
3487
+ ) : null, Ne ? /* @__PURE__ */ e.createElement(
3488
+ "button",
3489
+ {
3490
+ type: "button",
3491
+ onMouseDown: (u) => u.stopPropagation(),
3492
+ onClick: (u) => {
3493
+ u.stopPropagation(), W((Q) => !Q);
3494
+ },
3495
+ "data-chart-settings-toggle": "true",
3496
+ style: Nr,
3497
+ title: ke ? "Hide chart settings" : "Show chart settings",
3498
+ "aria-label": ke ? "Hide chart settings" : "Show chart settings"
3499
+ },
3500
+ /* @__PURE__ */ e.createElement(lr.Settings, null)
3501
+ ) : null)) : null,
3502
+ /* @__PURE__ */ e.createElement("div", { style: { display: "flex", minHeight: 0, gap: 0, overflow: "hidden", flex: "1 1 auto" } }, /* @__PURE__ */ e.createElement(
3503
+ "div",
3504
+ {
3505
+ ref: Mr,
3506
+ "data-chart-surface-main": "true",
3507
+ "data-chart-surface-scroll": "true",
3508
+ style: {
3509
+ display: "flex",
3510
+ flexDirection: "column",
3511
+ minHeight: 0,
3512
+ minWidth: 0,
3513
+ flex: "1 1 auto",
3514
+ overflowY: "auto",
3515
+ overflowX: "hidden",
3516
+ overscrollBehavior: "contain",
3517
+ paddingRight: ke ? "4px" : "0"
3518
+ }
3519
+ },
3520
+ t ? (!Array.isArray(t.series) || t.series.length === 0) && n !== "icicle" && n !== "sunburst" && n !== "sankey" ? /* @__PURE__ */ e.createElement(Se, { message: t.emptyMessage || "No chart data available.", theme: a, chartHeight: wt }) : /* @__PURE__ */ e.createElement(pa, { model: t, chartType: n, barLayout: f, axisMode: h, theme: a, chartHeight: wt, showLegend: !Ee, showDataLabels: he, onCategoryActivate: Gt, svgRef: tr, echartsRef: Ot, colorPalette: ve, valueFormat: pt, yAxisTitle: Mt, yAxisMin: Z, yAxisMax: Dt, referenceLines: $e, onReferenceLinesChange: Ue, labelAngle: dt, chartTitle: Me ? "" : Oe, onTitleChange: T, subtitle: Le, tickCount: at, markerShape: Je, markerSize: Et, showGradient: Ze, seriesColors: Ve, showAnimations: ft, showCalloutLabels: We, showTrendline: Be, trendlineMode: we, trendlinePeriod: rt, legendPosition: kt, labelPosition: Pt, decimalPlaces: qt, gradientDirection: It, gradientOpacity: Ht, trendlineColor: De, trendlineWidth: Ft, seriesSort: Ct, lineDashStyles: Xt, yAxisMinRight: l, yAxisMaxRight: s, customPaletteColors: $t, onElementSelect: y }) : /* @__PURE__ */ e.createElement(Se, { message: "No chart data available.", theme: a, chartHeight: wt }),
3521
+ Le ? /* @__PURE__ */ e.createElement("div", { style: { textAlign: "center", fontSize: "11px", color: a.textSec, padding: "4px 8px 0", fontStyle: "italic" } }, Le) : null,
3522
+ !Me && typeof U == "function" ? /* @__PURE__ */ e.createElement(
3523
+ "div",
3524
+ {
3525
+ onMouseDown: (u) => {
3526
+ u.preventDefault(), v.current = {
3527
+ startY: u.clientY,
3528
+ startHeight: wt
3529
+ };
3530
+ },
3531
+ style: {
3532
+ height: "22px",
3533
+ cursor: "ns-resize",
3534
+ display: "flex",
3535
+ alignItems: "center",
3536
+ justifyContent: "center",
3537
+ gap: "8px",
3538
+ marginTop: "6px",
3539
+ color: a.textSec,
3540
+ fontSize: "11px",
3541
+ fontWeight: 700
3542
+ },
3543
+ title: "Drag to resize the graph height"
3544
+ },
3545
+ /* @__PURE__ */ e.createElement("span", null, "Graph Height"),
3546
+ /* @__PURE__ */ e.createElement("div", { style: { width: "72px", height: "5px", borderRadius: "999px", background: a.border, opacity: 0.95 } })
3547
+ ) : null
3548
+ ), Ne && ke ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
3549
+ "div",
3550
+ {
3551
+ "data-chart-settings-resizer": "true",
3552
+ onMouseDown: (u) => {
3553
+ u.preventDefault(), B.current = {
3554
+ startX: u.clientX,
3555
+ startWidth: re,
3556
+ direction: "left"
3557
+ };
3558
+ },
3559
+ style: {
3560
+ width: "8px",
3561
+ cursor: "col-resize",
3562
+ background: "transparent",
3563
+ position: "relative",
3564
+ flexShrink: 0
3565
+ },
3566
+ title: "Resize chart settings"
3567
+ },
3568
+ /* @__PURE__ */ e.createElement("div", { style: {
3569
+ position: "absolute",
3570
+ top: "50%",
3571
+ left: "50%",
3572
+ transform: "translate(-50%, -50%)",
3573
+ width: "3px",
3574
+ height: "78px",
3575
+ borderRadius: "999px",
3576
+ background: a.border,
3577
+ opacity: 0.92
3578
+ } })
3579
+ ), /* @__PURE__ */ e.createElement(
3580
+ "aside",
3581
+ {
3582
+ "data-chart-settings-pane": "true",
3583
+ style: {
3584
+ width: `${re}px`,
3585
+ minWidth: "300px",
3586
+ maxWidth: "680px",
3587
+ flexShrink: 0,
3588
+ minHeight: 0,
3589
+ overflow: "hidden",
3590
+ borderLeft: `1px solid ${a.border}`,
3591
+ background: a.sidebarBg || a.surfaceBg || a.background,
3592
+ display: "flex",
3593
+ flexDirection: "column"
3594
+ }
3595
+ },
3596
+ /* @__PURE__ */ e.createElement("div", { style: {
3597
+ display: "flex",
3598
+ alignItems: "stretch",
3599
+ borderBottom: `1px solid ${a.border}`,
3600
+ background: a.sidebarBg || a.surfaceBg || a.background,
3601
+ flexShrink: 0
3602
+ } }, [
3603
+ { id: "chart", label: "Chart" },
3604
+ { id: "data", label: "Data" },
3605
+ { id: "axes", label: "Axes" },
3606
+ { id: "style", label: "Style" },
3607
+ { id: "labels", label: "Labels" }
3608
+ ].map((u) => /* @__PURE__ */ e.createElement(
3609
+ "button",
3610
+ {
3611
+ key: u.id,
3612
+ type: "button",
3613
+ "data-chart-settings-tab": u.id,
3614
+ onClick: () => g(u.id),
3615
+ style: {
3616
+ flex: 1,
3617
+ padding: "9px 4px 7px",
3618
+ fontSize: "11px",
3619
+ fontWeight: x === u.id ? 800 : 600,
3620
+ color: x === u.id ? a.primary : a.textSec,
3621
+ background: "none",
3622
+ border: "none",
3623
+ borderBottom: `2px solid ${x === u.id ? a.primary : "transparent"}`,
3624
+ cursor: "pointer",
3625
+ letterSpacing: "0.03em"
3626
+ }
3627
+ },
3628
+ u.label
3629
+ )), /* @__PURE__ */ e.createElement(
3630
+ "button",
3631
+ {
3632
+ type: "button",
3633
+ onClick: () => W(!1),
3634
+ style: {
3635
+ padding: "9px 12px",
3636
+ background: "none",
3637
+ border: "none",
3638
+ borderBottom: "2px solid transparent",
3639
+ color: a.textSec,
3640
+ cursor: "pointer",
3641
+ fontSize: "14px",
3642
+ lineHeight: 1
3643
+ },
3644
+ title: "Close settings"
3645
+ },
3646
+ "✕"
3647
+ )),
3648
+ /* @__PURE__ */ e.createElement(
3649
+ "div",
3650
+ {
3651
+ "data-chart-settings-scroll": "true",
3652
+ style: {
3653
+ overflowY: "auto",
3654
+ overflowX: "hidden",
3655
+ overscrollBehavior: "contain",
3656
+ padding: "12px",
3657
+ display: "flex",
3658
+ flexDirection: "column",
3659
+ gap: "8px",
3660
+ flex: 1,
3661
+ minHeight: 0,
3662
+ background: a.sidebarBg || a.surfaceBg || a.background
3663
+ }
3664
+ },
3665
+ x === "chart" && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => m((u) => !u), style: { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%", background: "none", border: "none", borderBottom: `1px solid ${a.border}`, padding: "4px 0", cursor: "pointer", marginBottom: E ? "6px" : 0 } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec } }, "Chart Type"), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: a.textSec, transform: E ? "rotate(0deg)" : "rotate(-90deg)", transition: "transform 0.15s" } }, "▾")), E && /* @__PURE__ */ e.createElement(Qn, { chartType: n, onChange: S, theme: a, includeHierarchyCharts: ir }), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => k((u) => !u), style: { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%", background: "none", border: "none", borderBottom: `1px solid ${a.border}`, padding: "4px 0", cursor: "pointer", marginTop: "8px", marginBottom: w ? "6px" : 0 } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec } }, "Parameters"), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: a.textSec, transform: w ? "rotate(0deg)" : "rotate(-90deg)", transition: "transform 0.15s" } }, "▾")), w && /* @__PURE__ */ e.createElement(e.Fragment, null, n !== "heatmap" && n !== "icicle" && n !== "sunburst" && n !== "sankey" && n !== "pie" && n !== "donut" && n !== "scatter" && n !== "waterfall" && !gt.has(n) && !de ? /* @__PURE__ */ e.createElement(xe, { label: "Source", theme: a }, /* @__PURE__ */ e.createElement(xa, { orientation: C, onChange: O, theme: a })) : null, n === "bar" ? /* @__PURE__ */ e.createElement(xe, { label: "Direction", theme: a }, /* @__PURE__ */ e.createElement(fa, { axisMode: h, onChange: R, theme: a })) : null, (n === "bar" || n === "area") && !de && /* @__PURE__ */ e.createElement(xe, { label: "Layout", theme: a }, /* @__PURE__ */ e.createElement(da, { chartType: n, barLayout: f, onChange: $, canStack: P, theme: a })), xr ? /* @__PURE__ */ e.createElement(xe, { label: "Level", theme: a }, /* @__PURE__ */ e.createElement(ga, { level: J, onChange: K, maxLevel: Dr, theme: a })) : null, de ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec, paddingBottom: "4px", borderBottom: `1px solid ${a.border}`, marginTop: "4px" } }, "Layers"), /* @__PURE__ */ e.createElement(ba, { layers: o, onChange: i, availableColumns: r, theme: a })) : null, !(n !== "heatmap" && n !== "icicle" && n !== "sunburst" && n !== "sankey" && n !== "pie" && n !== "donut" && n !== "scatter" && n !== "waterfall" && !gt.has(n) && !de) && n !== "bar" && !((n === "bar" || n === "area") && !de) && !xr && !de ? /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: a.textSec, padding: "4px 0" } }, "No parameters for this chart type.") : null)),
3666
+ x === "data" && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec, paddingBottom: "4px", borderBottom: `1px solid ${a.border}`, marginTop: "4px" } }, "General"), typeof T == "function" ? /* @__PURE__ */ e.createElement(xe, { label: "Title", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("input", { type: "text", value: Oe || "", onChange: (u) => T(u.target.value), placeholder: "Chart title", style: { ...Ae, width: "100%" } })) : null, /* @__PURE__ */ e.createElement(xe, { label: "Subtitle", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("input", { type: "text", value: Le, onChange: (u) => _t(u.target.value), placeholder: "Chart subtitle", style: { ...Ae, width: "100%" } })), typeof U == "function" ? /* @__PURE__ */ e.createElement(xe, { label: "Height", theme: a, controlMinWidth: "96px" }, /* @__PURE__ */ e.createElement("input", { type: "number", min: "180", step: "20", value: j, onChange: (u) => M(u.target.value), onBlur: () => {
3667
+ typeof U == "function" && U(j);
3668
+ }, onKeyDown: (u) => {
3669
+ u.key === "Enter" && typeof U == "function" && U(j);
3670
+ }, style: Ae })) : null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec, paddingBottom: "4px", borderBottom: `1px solid ${a.border}`, marginTop: "4px" } }, "Data & Actions"), /* @__PURE__ */ e.createElement(xe, { label: "Limits", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement(ya, { rowLimit: ue, onRowLimitChange: ne, columnLimit: ie, onColumnLimitChange: pe, theme: a })), typeof be == "function" ? /* @__PURE__ */ e.createElement(xe, { label: "Sort", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement(ha, { sortMode: it, onChange: be, theme: a })) : null, typeof be == "function" ? /* @__PURE__ */ e.createElement(xe, { label: "Series Sort", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "5px", flexWrap: "wrap" } }, Pn.map((u) => /* @__PURE__ */ e.createElement("button", { key: u.value, type: "button", onClick: () => dr(u.value), style: { border: `1px solid ${Ct === u.value ? a.primary : a.border}`, background: Ct === u.value ? a.select : a.headerSubtleBg || a.hover, color: Ct === u.value ? a.primary : a.text, borderRadius: a.radiusSm || "8px", padding: "5px 8px", fontSize: "11px", fontWeight: 700, cursor: "pointer" } }, u.label)))) : null, typeof Te == "function" ? /* @__PURE__ */ e.createElement(xe, { label: "Click", theme: a }, /* @__PURE__ */ e.createElement(va, { interactionMode: st, onChange: Te, theme: a })) : null, et && typeof ct == "function" ? /* @__PURE__ */ e.createElement(xe, { label: "Scope", theme: a }, /* @__PURE__ */ e.createElement(Ea, { scope: Vt, onChange: ct, theme: a })) : null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec, paddingBottom: "4px", borderBottom: `1px solid ${a.border}`, marginTop: "4px" } }, "Presets"), /* @__PURE__ */ e.createElement("div", { style: { display: "grid", gridTemplateColumns: "repeat(2, minmax(0, 1fr))", gap: "6px" } }, [
3671
+ { key: "trend", label: "Trend" },
3672
+ { key: "compare", label: "Compare" },
3673
+ { key: "composition", label: "Composition" },
3674
+ { key: "flow", label: "Flow" },
3675
+ { key: "sparkline", label: "Sparkline" }
3676
+ ].map((u) => /* @__PURE__ */ e.createElement("button", { key: u.key, type: "button", "data-chart-preset": u.key, onClick: () => on(u.key), style: { ...jt, textAlign: "left" } }, u.label)))),
3677
+ x === "axes" && /* @__PURE__ */ e.createElement(e.Fragment, null, n !== "heatmap" && n !== "icicle" && n !== "sunburst" && n !== "sankey" && n !== "pie" && n !== "donut" && n !== "sparkline" ? /* @__PURE__ */ e.createElement(xe, { label: "Y-Axis Title", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("input", { type: "text", value: Mt, onChange: (u) => sr(u.target.value), placeholder: "Y-axis title", style: { ...Ae, width: "100%" } })) : null, n !== "heatmap" && n !== "icicle" && n !== "sunburst" && n !== "sankey" && n !== "pie" && n !== "donut" && n !== "sparkline" && !gt.has(n) ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(xe, { label: "Y Range", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px" } }, /* @__PURE__ */ e.createElement("input", { type: "number", value: Z, onChange: (u) => ee(u.target.value), placeholder: "Min", style: { ...Ae, width: "50%" } }), /* @__PURE__ */ e.createElement("input", { type: "number", value: Dt, onChange: (u) => Qe(u.target.value), placeholder: "Max", style: { ...Ae, width: "50%" } }))), /* @__PURE__ */ e.createElement(xe, { label: "Y Ticks", theme: a, controlMinWidth: "80px" }, /* @__PURE__ */ e.createElement("input", { type: "number", min: "2", max: "20", value: at, onChange: (u) => Re(Math.max(2, Math.min(20, Number(u.target.value) || 5))), style: { ...Ae, width: "80px" } })), /* @__PURE__ */ e.createElement(xe, { label: "X Angle", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", alignItems: "center", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("input", { type: "number", min: "0", max: "90", value: dt, onChange: (u) => Ie(Math.max(0, Math.min(90, Number(u.target.value) || 0))), style: { ...Ae, width: "58px" }, title: "X-axis label angle (0–90°)" }), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "11px", color: a.textSec } }, "°"), [0, 30, 45, 90].map((u) => /* @__PURE__ */ e.createElement("button", { key: u, type: "button", onClick: () => Ie(u), style: { ...Ae, padding: "4px 6px", background: dt === u ? a.select : a.headerSubtleBg || a.hover, color: dt === u ? a.primary : a.text, border: `1px solid ${dt === u ? a.primary : a.border}` } }, u, "°"))))) : null, de ? /* @__PURE__ */ e.createElement(xe, { label: "Right Axis Range", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px" } }, /* @__PURE__ */ e.createElement("input", { type: "number", value: l, onChange: (u) => c(u.target.value), placeholder: "Min", style: { ...Ae, width: "50%" } }), /* @__PURE__ */ e.createElement("input", { type: "number", value: s, onChange: (u) => p(u.target.value), placeholder: "Max", style: { ...Ae, width: "50%" } }))) : null, n !== "heatmap" && n !== "icicle" && n !== "sunburst" && n !== "sankey" && n !== "pie" && n !== "donut" && !gt.has(n) ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec, paddingBottom: "4px", borderBottom: `1px solid ${a.border}`, marginTop: "4px" } }, "Reference Lines"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } }, $e.map((u, Q) => /* @__PURE__ */ e.createElement(Jn, { key: u.id, line: u, onUpdate: (me) => Ue((ye) => ye.map((Ge, rr) => rr === Q ? me : Ge)), onRemove: () => Ue((me) => me.filter((ye, Ge) => Ge !== Q)), exportButtonStyle: jt, compactInputStyle: Ae, theme: a })), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", alignItems: "center" } }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => ht((u) => ({ ...u, orient: u.orient === "v" ? "h" : "v" })), style: { ...jt, padding: "4px 7px", flexShrink: 0, fontWeight: 800, color: Ke.orient === "v" ? a.primary : a.textSec } }, Ke.orient === "v" ? "|" : "—"), /* @__PURE__ */ e.createElement("input", { type: "number", value: Ke.value, onChange: (u) => ht((Q) => ({ ...Q, value: u.target.value })), placeholder: Ke.orient === "v" ? "Cat index" : "Value", style: { ...Ae, width: "60px", flexShrink: 0 } }), /* @__PURE__ */ e.createElement("input", { type: "text", value: Ke.label, onChange: (u) => ht((Q) => ({ ...Q, label: u.target.value })), placeholder: "Label", style: { ...Ae, flex: 1, minWidth: 0 } }), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => {
3678
+ Ke.value !== "" && (Ue((u) => [...u, { id: Date.now(), value: Ke.value, label: Ke.label, orient: Ke.orient, color: "", dash: "dashed" }]), ht({ value: "", label: "", orient: Ke.orient }));
3679
+ }, style: { ...jt, padding: "4px 10px", flexShrink: 0 } }, "+")), $r ? /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: a.textSec } }, "Data range: ", zt($r.min, pt), " — ", zt($r.max, pt)) : null)) : null),
3680
+ x === "style" && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec, paddingBottom: "4px", borderBottom: `1px solid ${a.border}` } }, "Colors"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexWrap: "wrap", gap: "6px" } }, [...hn, ...$t.length >= 2 ? ["custom"] : []].map((u) => {
3681
+ const Q = ve === u, me = u === "custom" ? $t : vn[u];
3682
+ return /* @__PURE__ */ e.createElement(
3683
+ "button",
3684
+ {
3685
+ key: u,
3686
+ type: "button",
3687
+ onClick: () => bt(u),
3688
+ title: u.charAt(0).toUpperCase() + u.slice(1),
3689
+ style: { display: "flex", alignItems: "center", gap: "3px", padding: "3px 6px", border: `1.5px solid ${Q ? a.primary : a.border}`, background: Q ? a.select : a.headerSubtleBg || a.hover, borderRadius: a.radiusSm || "8px", cursor: "pointer" }
3690
+ },
3691
+ (me || []).slice(0, 4).map((ye, Ge) => /* @__PURE__ */ e.createElement("span", { key: Ge, style: { width: "8px", height: "8px", borderRadius: "50%", background: ye, flexShrink: 0 } })),
3692
+ /* @__PURE__ */ e.createElement("span", { style: { fontSize: "9px", fontWeight: Q ? 700 : 600, color: Q ? a.primary : a.textSec, marginLeft: "1px", textTransform: "capitalize" } }, u === "a11y" ? "A11y" : u)
3693
+ );
3694
+ })), Array.isArray(t && t.series) && t.series.length > 0 ? /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "4px" } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 700, color: a.textSec, textTransform: "uppercase", letterSpacing: "0.05em", marginBottom: "2px" } }, "Override per series"), t.series.slice(0, 20).map((u, Q) => /* @__PURE__ */ e.createElement("div", { key: u.name || Q, style: { display: "flex", alignItems: "center", gap: "5px" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "2px", flexShrink: 0 } }, I.slice(0, 6).map((me, ye) => /* @__PURE__ */ e.createElement("button", { key: ye, type: "button", onClick: () => Nt((Ge) => ({ ...Ge, [u.name]: me })), style: { width: "14px", height: "14px", borderRadius: "50%", background: me, border: `2px solid ${(Ve[u.name] || Ce(Q, a, I)) === me ? a.text : "transparent"}`, cursor: "pointer", padding: 0, flexShrink: 0 }, title: me }))), /* @__PURE__ */ e.createElement("input", { type: "color", value: Ve[u.name] || Ce(Q, a, I), onChange: (me) => Nt((ye) => ({ ...ye, [u.name]: me.target.value })), style: { width: "24px", height: "24px", padding: 0, border: `1px solid ${a.border}`, borderRadius: "4px", cursor: "pointer", background: "none", flexShrink: 0 }, title: `Custom color for ${u.name}` }), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "11px", color: a.text, flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, u.name || `Series ${Q + 1}`), Ve[u.name] ? /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => Nt((me) => {
3695
+ const ye = { ...me };
3696
+ return delete ye[u.name], ye;
3697
+ }), style: { border: "none", background: "none", color: a.textSec, cursor: "pointer", fontSize: "10px", padding: "0 2px" }, title: "Reset to palette" }, "↺") : null)), t.series.length > 20 ? /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: a.textSec } }, `…${t.series.length - 20} more`) : null) : null, /* @__PURE__ */ e.createElement("div", { style: { borderTop: `1px solid ${a.border}`, paddingTop: "8px" } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 700, color: a.textSec, textTransform: "uppercase", letterSpacing: "0.05em", marginBottom: "6px" } }, "Custom Palette"), /* @__PURE__ */ e.createElement(On, { customColors: $t, onChange: Jt, theme: a, compactInputStyle: Ae }), $t.length >= 2 ? /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => bt("custom"), style: { ...jt, marginTop: "6px", background: ve === "custom" ? a.select : void 0, color: ve === "custom" ? a.primary : void 0, border: `1px solid ${ve === "custom" ? a.primary : a.border}` } }, ve === "custom" ? "Custom active" : "Use custom palette") : null), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec, paddingBottom: "4px", borderBottom: `1px solid ${a.border}`, marginTop: "4px" } }, "Effects"), /* @__PURE__ */ e.createElement(xe, { label: "Animate", theme: a }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => At((u) => !u), style: { border: `1px solid ${ft ? a.primary : a.border}`, background: ft ? a.select : a.headerSubtleBg || a.hover, color: ft ? a.primary : a.text, borderRadius: a.radiusSm || "8px", padding: "6px 8px", fontSize: "11px", fontWeight: 700, cursor: "pointer" } }, ft ? "On" : "Off")), n !== "heatmap" && n !== "icicle" && n !== "sunburst" && n !== "sankey" && n !== "pie" && n !== "donut" && n !== "sparkline" && !gt.has(n) ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(xe, { label: "Gradient", theme: a }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => xt((u) => !u), style: { border: `1px solid ${Ze ? a.primary : a.border}`, background: Ze ? a.select : a.headerSubtleBg || a.hover, color: Ze ? a.primary : a.text, borderRadius: a.radiusSm || "8px", padding: "6px 8px", fontSize: "11px", fontWeight: 700, cursor: "pointer" } }, Ze ? "On" : "Off")), Ze ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(xe, { label: "Grad Dir", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "5px" } }, Br.map((u) => /* @__PURE__ */ e.createElement("button", { key: u.value, type: "button", onClick: () => Er(u.value), style: { border: `1px solid ${It === u.value ? a.primary : a.border}`, background: It === u.value ? a.select : a.headerSubtleBg || a.hover, color: It === u.value ? a.primary : a.text, borderRadius: a.radiusSm || "8px", padding: "5px 8px", fontSize: "11px", fontWeight: 700, cursor: "pointer" } }, u.label)))), /* @__PURE__ */ e.createElement(xe, { label: "Grad Opacity", theme: a, controlMinWidth: "80px" }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", alignItems: "center" } }, /* @__PURE__ */ e.createElement("input", { type: "range", min: "10", max: "100", step: "5", value: Ht, onChange: (u) => kr(Number(u.target.value)), style: { flex: 1 } }), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "11px", color: a.textSec, minWidth: "30px" } }, Ht, "%")))) : null) : null, n === "line" || n === "scatter" || n === "bubble" || n === "area" || n === "radar" || de ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec, paddingBottom: "4px", borderBottom: `1px solid ${a.border}`, marginTop: "4px" } }, "Markers"), /* @__PURE__ */ e.createElement(xe, { label: "Shape", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("select", { value: Je, onChange: (u) => vt(u.target.value), style: { ...Ae, width: "100%" } }, /* @__PURE__ */ e.createElement("option", { value: "none" }, "None (line only)"), /* @__PURE__ */ e.createElement("option", { value: "circle" }, "Circle"), /* @__PURE__ */ e.createElement("option", { value: "square" }, "Square"), /* @__PURE__ */ e.createElement("option", { value: "diamond" }, "Diamond"), /* @__PURE__ */ e.createElement("option", { value: "triangle" }, "Triangle"), /* @__PURE__ */ e.createElement("option", { value: "cross" }, "Cross"))), /* @__PURE__ */ e.createElement(xe, { label: "Size", theme: a, controlMinWidth: "80px" }, /* @__PURE__ */ e.createElement("select", { value: Et, onChange: (u) => lt(Number(u.target.value)), style: { ...Ae, width: "80px" } }, /* @__PURE__ */ e.createElement("option", { value: 3 }, "Small"), /* @__PURE__ */ e.createElement("option", { value: 5 }, "Medium"), /* @__PURE__ */ e.createElement("option", { value: 7 }, "Large"), /* @__PURE__ */ e.createElement("option", { value: 10 }, "XLarge")))) : null, (n === "line" || n === "area" || de) && Array.isArray(t && t.series) && t.series.length > 0 ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec, paddingBottom: "4px", borderBottom: `1px solid ${a.border}`, marginTop: "4px" } }, "Line Style"), /* @__PURE__ */ e.createElement(Fn, { series: t.series, lineDashStyles: Xt, onChange: Sr, seriesColors: Ve, paletteColors: I, getColorForIndex: Ce, theme: a, compactInputStyle: Ae })) : null, n === "bar" || n === "line" || n === "area" || n === "scatter" || de ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", fontWeight: 800, letterSpacing: "0.08em", textTransform: "uppercase", color: a.textSec, paddingBottom: "4px", borderBottom: `1px solid ${a.border}`, marginTop: "4px" } }, "Trendline"), /* @__PURE__ */ e.createElement(xe, { label: "Show", theme: a }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => qe((u) => !u), style: { border: `1px solid ${Be ? a.primary : a.border}`, background: Be ? a.select : a.headerSubtleBg || a.hover, color: Be ? a.primary : a.text, borderRadius: a.radiusSm || "8px", padding: "6px 8px", fontSize: "11px", fontWeight: 700, cursor: "pointer" } }, Be ? "On" : "Off")), Be ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(xe, { label: "Type", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("select", { value: we, onChange: (u) => Xe(u.target.value), style: { ...Ae, width: "100%" } }, /* @__PURE__ */ e.createElement("option", { value: "linear" }, "Linear Regression"), /* @__PURE__ */ e.createElement("option", { value: "moving_avg" }, "Moving Average"), /* @__PURE__ */ e.createElement("option", { value: "exponential" }, "Exponential Smoothing"))), we === "moving_avg" ? /* @__PURE__ */ e.createElement(xe, { label: "Period", theme: a, controlMinWidth: "80px" }, /* @__PURE__ */ e.createElement("input", { type: "number", min: "2", max: "50", value: rt, onChange: (u) => cr(Math.max(2, Math.min(50, Number(u.target.value) || 3))), style: { ...Ae, width: "80px" } })) : null, /* @__PURE__ */ e.createElement(xe, { label: "Color", theme: a }, /* @__PURE__ */ e.createElement("input", { type: "color", value: De || "#888888", onChange: (u) => d(u.target.value), style: { width: "32px", height: "28px", padding: 0, border: `1px solid ${a.border}`, borderRadius: "4px", cursor: "pointer", background: "none" }, title: "Trendline color" }), De ? /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => d(""), style: { border: "none", background: "none", color: a.textSec, cursor: "pointer", fontSize: "10px", padding: "0 4px" }, title: "Reset to auto" }, "↺") : null), /* @__PURE__ */ e.createElement(xe, { label: "Width", theme: a, controlMinWidth: "80px" }, /* @__PURE__ */ e.createElement("input", { type: "number", min: "1", max: "8", value: Ft, onChange: (u) => wr(Math.max(1, Math.min(8, Number(u.target.value) || 2))), style: { ...Ae, width: "80px" } }))) : null) : null),
3698
+ x === "labels" && /* @__PURE__ */ e.createElement(e.Fragment, null, n !== "icicle" && n !== "sunburst" && n !== "sankey" && n !== "sparkline" ? /* @__PURE__ */ e.createElement(xe, { label: "Data Labels", theme: a }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => Rt((u) => !u), style: { border: `1px solid ${he ? a.primary : a.border}`, background: he ? a.select : a.headerSubtleBg || a.hover, color: he ? a.primary : a.text, borderRadius: a.radiusSm || "8px", padding: "6px 8px", fontSize: "11px", fontWeight: 700, cursor: "pointer" } }, he ? "On" : "Off")) : null, n !== "heatmap" && n !== "icicle" && n !== "sunburst" && n !== "sankey" && n !== "pie" && n !== "donut" ? /* @__PURE__ */ e.createElement(xe, { label: "Format", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("select", { value: pt, onChange: (u) => Ye(u.target.value), style: { ...Ae, width: "100%" }, title: "Value format for axis labels" }, En.map((u) => /* @__PURE__ */ e.createElement("option", { key: u.value, value: u.value }, u.label)))) : null, n !== "heatmap" && n !== "icicle" && n !== "sunburst" && n !== "sankey" && n !== "sparkline" && !gt.has(n) ? /* @__PURE__ */ e.createElement(xe, { label: "Decimals", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("select", { value: qt, onChange: (u) => Qt(Number(u.target.value)), style: { ...Ae, width: "100%" } }, /* @__PURE__ */ e.createElement("option", { value: -1 }, "Auto"), /* @__PURE__ */ e.createElement("option", { value: 0 }, "0 (e.g. 1,234)"), /* @__PURE__ */ e.createElement("option", { value: 1 }, "1 (e.g. 1.2)"), /* @__PURE__ */ e.createElement("option", { value: 2 }, "2 (e.g. 1.23)"), /* @__PURE__ */ e.createElement("option", { value: 3 }, "3 (e.g. 1.234)"))) : null, he && n === "bar" ? /* @__PURE__ */ e.createElement(xe, { label: "Position", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement("select", { value: Pt, onChange: (u) => Zt(u.target.value), style: { ...Ae, width: "100%" } }, /* @__PURE__ */ e.createElement("option", { value: "outside" }, "Outside"), /* @__PURE__ */ e.createElement("option", { value: "inside" }, "Inside top"), /* @__PURE__ */ e.createElement("option", { value: "center" }, "Center"))) : null, n === "pie" || n === "donut" ? /* @__PURE__ */ e.createElement(xe, { label: "Callouts", theme: a }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => te((u) => !u), style: { border: `1px solid ${We ? a.primary : a.border}`, background: We ? a.select : a.headerSubtleBg || a.hover, color: We ? a.primary : a.text, borderRadius: a.radiusSm || "8px", padding: "6px 8px", fontSize: "11px", fontWeight: 700, cursor: "pointer" } }, We ? "On" : "Off")) : null, n !== "sparkline" && !gt.has(n) ? /* @__PURE__ */ e.createElement(xe, { label: "Legend", theme: a, controlMinWidth: "100%" }, /* @__PURE__ */ e.createElement(Nn, { legendPosition: kt, onChange: pr, theme: a })) : null)
3699
+ )
3700
+ )) : null),
3701
+ Ne ? /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap", alignItems: "center" } }, /* @__PURE__ */ e.createElement(sa, { model: t, theme: a }), /* @__PURE__ */ e.createElement(Hn, { model: t, maxCategories: Jr, maxSeries: Qr, theme: a })) : null
3702
+ );
3703
+ }, $a = ({
3704
+ onClose: t,
3705
+ source: n,
3706
+ onSourceChange: o,
3707
+ chartType: i,
3708
+ onChartTypeChange: r,
3709
+ chartLayers: f = [],
3710
+ onChartLayersChange: h,
3711
+ availableColumns: S = [],
3712
+ barLayout: $,
3713
+ onBarLayoutChange: R,
3714
+ axisMode: C,
3715
+ onAxisModeChange: O,
3716
+ orientation: J,
3717
+ onOrientationChange: K,
3718
+ hierarchyLevel: a,
3719
+ onHierarchyLevelChange: X,
3720
+ model: T,
3721
+ theme: V,
3722
+ width: Y,
3723
+ chartTitle: F,
3724
+ onChartTitleChange: U,
3725
+ chartHeight: ue,
3726
+ onChartHeightChange: ne,
3727
+ onResizeStart: ie,
3728
+ floating: pe = !1,
3729
+ onToggleFloating: it,
3730
+ floatingRect: be = null,
3731
+ onFloatingDragStart: st,
3732
+ onFloatingResizeStart: Te,
3733
+ rowLimit: Vt,
3734
+ onRowLimitChange: ct,
3735
+ columnLimit: et,
3736
+ onColumnLimitChange: _e,
3737
+ sortMode: Me,
3738
+ onSortModeChange: Gt,
3739
+ interactionMode: ir,
3740
+ onInteractionModeChange: nt,
3741
+ serverScope: Tt,
3742
+ onServerScopeChange: Ut,
3743
+ chartDefinitions: tt = [],
3744
+ activeChartId: mt = null,
3745
+ onActiveChartChange: Kt,
3746
+ onCreateChart: z,
3747
+ onDuplicateChart: Bt,
3748
+ onDeleteChart: de,
3749
+ onRenameChart: Ee,
3750
+ onCategoryActivate: P,
3751
+ allowHierarchyCharts: Oe = !0,
3752
+ showServerScope: Lt = !1,
3753
+ locked: yt = !1,
3754
+ onToggleLock: ut,
3755
+ dockPosition: Pe = "right",
3756
+ onDockPositionChange: ke,
3757
+ immersiveMode: W,
3758
+ onImmersiveModeChange: he,
3759
+ onSettingsWidthBudgetChange: Rt,
3760
+ standalone: ve = !1,
3761
+ showResizeHandle: bt = !0,
3762
+ title: pt = "Chart Panel",
3763
+ showDefinitionManager: Ye = !0,
3764
+ initialSettings: Mt = {},
3765
+ onSettingsChange: sr,
3766
+ initialSettingsPaneOpen: Z = !1
3767
+ }) => {
3768
+ kn("PivotChartPanel", mt);
3769
+ const [ee, Dt] = _(!1), [Qe, $e] = _(!1), [Ue, Ke] = _(Z), [ht, dt] = _(348), Ie = Fe(null), Le = Fe(Ur(
3770
+ Y,
3771
+ 430,
3772
+ mr,
3773
+ jr
3774
+ )), _t = Fe(Rt), at = Fe(null), Re = typeof W == "boolean" ? W : Qe, Je = () => {
3775
+ const te = !Re;
3776
+ if (typeof he == "function") {
3777
+ he(te);
3778
+ return;
3779
+ }
3780
+ $e(te);
3781
+ }, vt = pe && yt, Et = (te) => ({
3782
+ border: `1px solid ${te === n ? V.primary : V.border}`,
3783
+ background: te === n ? V.select : V.headerSubtleBg || V.hover,
3784
+ color: te === n ? V.primary : V.text,
3785
+ borderRadius: V.radiusSm || "8px",
3786
+ padding: "6px 8px",
3787
+ fontSize: "11px",
3788
+ fontWeight: 700,
3789
+ cursor: "pointer"
3790
+ }), lt = (te = !1) => ({
3791
+ border: `1px solid ${te ? V.primary : V.border}`,
3792
+ background: te ? V.select : V.headerSubtleBg || V.hover,
3793
+ color: te ? V.primary : V.text,
3794
+ borderRadius: V.radiusSm || "8px",
3795
+ padding: "6px 8px",
3796
+ fontSize: "11px",
3797
+ fontWeight: 700,
3798
+ cursor: "pointer",
3799
+ display: "inline-flex",
3800
+ alignItems: "center",
3801
+ justifyContent: "center",
3802
+ gap: "6px",
3803
+ minWidth: "32px"
3804
+ }), Ze = (te) => ({
3805
+ ...lt(Pe === te),
3806
+ minWidth: "56px",
3807
+ padding: "6px 10px"
3808
+ }), xt = !Re && Ue ? ht + 9 : 0, Ve = Ur(
3809
+ Y,
3810
+ 430,
3811
+ mr,
3812
+ jr
3813
+ ), Nt = be && Number.isFinite(Number(be.width)) ? Math.max(mr, Math.floor(Number(be.width))) : Ve, ft = be && Number.isFinite(Number(be.height)) ? Math.max(wn, Math.floor(Number(be.height))) : Math.max(Sn, (Number(ue) || or) + qr);
3814
+ He(() => {
3815
+ _t.current = Rt;
3816
+ }, [Rt]);
3817
+ const At = je((te, Be = {}) => {
3818
+ const qe = Number(te), we = Number.isFinite(qe) ? Math.max(320, Math.ceil(qe)) : null;
3819
+ if (!Be.force && at.current === we) return;
3820
+ at.current = we;
3821
+ const Xe = _t.current;
3822
+ typeof Xe == "function" && Xe(we);
3823
+ }, []), We = ee ? {
3824
+ position: "fixed",
3825
+ inset: "16px",
3826
+ zIndex: 10040,
3827
+ display: "flex",
3828
+ minWidth: 0,
3829
+ minHeight: 0
3830
+ } : pe ? {
3831
+ position: "absolute",
3832
+ left: `${be && be.left || 24}px`,
3833
+ top: `${be && be.top || 24}px`,
3834
+ width: `${Nt + xt}px`,
3835
+ height: `${ft}px`,
3836
+ zIndex: 240,
3837
+ display: "flex",
3838
+ minWidth: 0,
3839
+ minHeight: 0
3840
+ } : ve ? {
3841
+ display: "flex",
3842
+ flexGrow: 1,
3843
+ flexShrink: 1,
3844
+ flexBasis: "auto",
3845
+ width: "100%",
3846
+ height: "100%",
3847
+ minWidth: 0,
3848
+ minHeight: 0,
3849
+ overflow: "hidden"
3850
+ } : {
3851
+ display: "flex",
3852
+ width: `${Ve + xt}px`,
3853
+ minWidth: `${Ve + xt}px`,
3854
+ maxWidth: `${Ve + xt}px`,
3855
+ flexShrink: 0
3856
+ };
3857
+ return He(() => {
3858
+ if (!ve || pe || ee) return;
3859
+ const te = Ie.current;
3860
+ if (!te) return;
3861
+ const Be = () => {
3862
+ const we = te.clientWidth;
3863
+ we > 0 && !Ue && (Le.current = Math.max(mr, we));
3864
+ };
3865
+ if (Be(), typeof ResizeObserver > "u") return;
3866
+ const qe = new ResizeObserver(Be);
3867
+ return qe.observe(te), () => qe.disconnect();
3868
+ }, [pe, ee, Ue, ve]), He(() => {
3869
+ if (!ve || pe || ee || Re || !Ue) {
3870
+ At(null);
3871
+ return;
3872
+ }
3873
+ const te = Le.current || Ve;
3874
+ At(te + xt);
3875
+ }, [
3876
+ Ve,
3877
+ At,
3878
+ Re,
3879
+ pe,
3880
+ ee,
3881
+ Ue,
3882
+ ve,
3883
+ xt
3884
+ ]), He(() => () => {
3885
+ At(null, { force: !0 });
3886
+ }, [At]), /* @__PURE__ */ e.createElement("div", { style: We }, !ee && !pe && !ve && bt ? /* @__PURE__ */ e.createElement(
3887
+ "div",
3888
+ {
3889
+ onMouseDown: (te) => {
3890
+ te.preventDefault(), ie && ie();
3891
+ },
3892
+ style: {
3893
+ width: "8px",
3894
+ cursor: "col-resize",
3895
+ background: "transparent",
3896
+ position: "relative",
3897
+ flexShrink: 0
3898
+ },
3899
+ title: "Resize chart panel"
3900
+ },
3901
+ /* @__PURE__ */ e.createElement("div", { style: {
3902
+ position: "absolute",
3903
+ top: "50%",
3904
+ left: "50%",
3905
+ transform: "translate(-50%, -50%)",
3906
+ width: "3px",
3907
+ height: "72px",
3908
+ borderRadius: "999px",
3909
+ background: V.border,
3910
+ opacity: 0.9
3911
+ } })
3912
+ ) : null, /* @__PURE__ */ e.createElement("aside", { ref: Ie, style: {
3913
+ width: ee || pe || ve ? "100%" : `calc(100% - ${bt ? 8 : 0}px)`,
3914
+ height: ee || pe || ve ? "100%" : "auto",
3915
+ minWidth: 0,
3916
+ minHeight: 0,
3917
+ borderLeft: ve || pe || ee ? "none" : `1px solid ${V.border}`,
3918
+ border: pe || ee ? `1px solid ${V.border}` : "none",
3919
+ borderRadius: pe || ee ? V.radius || "16px" : 0,
3920
+ background: V.sidebarBg || V.surfaceBg || V.background,
3921
+ padding: ee ? "12px" : "14px",
3922
+ overflow: "hidden",
3923
+ boxShadow: pe || ee ? V.shadowMd || "0 18px 40px rgba(15,23,42,0.24)" : ve ? "none" : `-10px 0 24px ${V.pinnedBoundaryShadow || "rgba(15,23,42,0.12)"}`,
3924
+ display: "flex",
3925
+ flexDirection: "column",
3926
+ gap: Re ? "8px" : "0",
3927
+ position: "relative"
3928
+ } }, /* @__PURE__ */ e.createElement(
3929
+ "div",
3930
+ {
3931
+ onMouseDown: (te) => {
3932
+ pe && !ee && !vt && typeof st == "function" && st(te);
3933
+ },
3934
+ style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "12px", marginBottom: Re ? "0" : "12px", cursor: pe && !ee && !vt ? "move" : "default" }
3935
+ },
3936
+ Re ? /* @__PURE__ */ e.createElement("div", null) : /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "4px", minWidth: 0 } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "15px", fontWeight: 800, color: V.text } }, pt)),
3937
+ /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "6px" }, onMouseDown: (te) => te.stopPropagation() }, typeof it == "function" ? /* @__PURE__ */ e.createElement(
3938
+ "button",
3939
+ {
3940
+ type: "button",
3941
+ onClick: it,
3942
+ style: lt(pe),
3943
+ title: pe ? "Dock chart panel" : "Float chart over table",
3944
+ "aria-label": pe ? "Dock chart panel" : "Float chart over table"
3945
+ },
3946
+ pe ? "Dock" : "Float"
3947
+ ) : null, /* @__PURE__ */ e.createElement(
3948
+ "button",
3949
+ {
3950
+ type: "button",
3951
+ onClick: Je,
3952
+ style: lt(Re),
3953
+ title: Re ? "Exit immersive mode" : "Enter immersive mode",
3954
+ "aria-label": Re ? "Exit immersive mode" : "Enter immersive mode"
3955
+ },
3956
+ "Immersive"
3957
+ ), /* @__PURE__ */ e.createElement(
3958
+ "button",
3959
+ {
3960
+ type: "button",
3961
+ onClick: () => Dt((te) => !te),
3962
+ style: lt(ee),
3963
+ title: ee ? "Exit full screen" : "Open chart full screen",
3964
+ "aria-label": ee ? "Exit full screen" : "Open chart full screen"
3965
+ },
3966
+ ee ? /* @__PURE__ */ e.createElement(lr.FullscreenExit, null) : /* @__PURE__ */ e.createElement(lr.Fullscreen, null)
3967
+ ), /* @__PURE__ */ e.createElement(
3968
+ "button",
3969
+ {
3970
+ onClick: t,
3971
+ style: lt(!1),
3972
+ title: ve ? "Close chart pane" : "Close chart panel",
3973
+ "aria-label": ve ? "Close chart pane" : "Close chart panel"
3974
+ },
3975
+ ee ? /* @__PURE__ */ e.createElement(lr.Close, null) : "Close"
3976
+ ))
3977
+ ), !Re && Ye ? /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "8px", marginBottom: "10px", flexWrap: "wrap", alignItems: "center" } }, Array.isArray(tt) && tt.length > 0 ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
3978
+ "select",
3979
+ {
3980
+ value: mt || "",
3981
+ onChange: (te) => {
3982
+ typeof Kt == "function" && Kt(te.target.value);
3983
+ },
3984
+ style: {
3985
+ border: `1px solid ${V.border}`,
3986
+ background: V.surfaceBg || V.background || "#fff",
3987
+ color: V.text,
3988
+ borderRadius: V.radiusSm || "8px",
3989
+ padding: "6px 8px",
3990
+ fontSize: "11px",
3991
+ fontWeight: 700,
3992
+ minWidth: "160px"
3993
+ }
3994
+ },
3995
+ tt.map((te) => /* @__PURE__ */ e.createElement("option", { key: te.id, value: te.id }, te.name || te.id))
3996
+ ), /* @__PURE__ */ e.createElement(
3997
+ "input",
3998
+ {
3999
+ type: "text",
4000
+ value: (tt.find((te) => te.id === mt) || {}).name || "",
4001
+ onChange: (te) => {
4002
+ typeof Ee == "function" && Ee(te.target.value);
4003
+ },
4004
+ placeholder: "Chart name",
4005
+ style: {
4006
+ border: `1px solid ${V.border}`,
4007
+ background: V.surfaceBg || V.background || "#fff",
4008
+ color: V.text,
4009
+ borderRadius: V.radiusSm || "8px",
4010
+ padding: "6px 8px",
4011
+ fontSize: "11px",
4012
+ fontWeight: 700,
4013
+ minWidth: "180px"
4014
+ }
4015
+ }
4016
+ )) : null, typeof z == "function" ? /* @__PURE__ */ e.createElement("button", { type: "button", style: lt(!1), onClick: z }, "New") : null, typeof Bt == "function" ? /* @__PURE__ */ e.createElement("button", { type: "button", style: lt(!1), onClick: Bt }, "Duplicate") : null, typeof de == "function" ? /* @__PURE__ */ e.createElement(
4017
+ "button",
4018
+ {
4019
+ type: "button",
4020
+ style: lt(!1),
4021
+ onClick: de,
4022
+ disabled: !Array.isArray(tt) || tt.length <= 1
4023
+ },
4024
+ "Delete"
4025
+ ) : null) : null, !Re && ve && !pe && typeof ke == "function" ? /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", marginBottom: "10px", flexWrap: "wrap", alignItems: "center" } }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => ke("left"), style: Ze("left"), title: "Dock chart pane to the left" }, "Left"), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => ke("right"), style: Ze("right"), title: "Dock chart pane to the right" }, "Right"), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => ke("top"), style: Ze("top"), title: "Dock chart pane to the top" }, "Top"), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => ke("bottom"), style: Ze("bottom"), title: "Dock chart pane to the bottom" }, "Bottom")) : null, Re ? null : /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", marginBottom: "12px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("button", { style: Et("pivot"), onClick: () => o("pivot") }, "Pivot View"), /* @__PURE__ */ e.createElement("button", { style: Et("selection"), onClick: () => o("selection") }, "Selection")), /* @__PURE__ */ e.createElement(
4026
+ an,
4027
+ {
4028
+ model: T,
4029
+ chartType: i,
4030
+ chartLayers: f,
4031
+ onChartLayersChange: h,
4032
+ availableColumns: S,
4033
+ barLayout: $,
4034
+ axisMode: C,
4035
+ onChartTypeChange: r,
4036
+ onBarLayoutChange: R,
4037
+ onAxisModeChange: O,
4038
+ orientation: J,
4039
+ onOrientationChange: K,
4040
+ hierarchyLevel: a,
4041
+ onHierarchyLevelChange: X,
4042
+ rowLimit: Vt,
4043
+ onRowLimitChange: ct,
4044
+ columnLimit: et,
4045
+ onColumnLimitChange: _e,
4046
+ title: F,
4047
+ onTitleChange: U,
4048
+ chartHeight: ue,
4049
+ onChartHeightChange: ne,
4050
+ sortMode: Me,
4051
+ onSortModeChange: Gt,
4052
+ interactionMode: ir,
4053
+ onInteractionModeChange: nt,
4054
+ serverScope: Tt,
4055
+ onServerScopeChange: Ut,
4056
+ showServerScope: Lt,
4057
+ theme: V,
4058
+ immersiveMode: Re,
4059
+ onCategoryActivate: P,
4060
+ allowHierarchyCharts: Oe,
4061
+ floating: pe,
4062
+ locked: yt,
4063
+ onToggleLock: ut,
4064
+ configOpen: Ue,
4065
+ onConfigChange: Ke,
4066
+ settingsPanelWidth: ht,
4067
+ onSettingsPanelWidthChange: dt,
4068
+ initialSettings: Mt,
4069
+ onSettingsChange: sr
4070
+ }
4071
+ ), pe && !ee && !yt ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
4072
+ "div",
4073
+ {
4074
+ onMouseDown: (te) => typeof Te == "function" && Te("right", te),
4075
+ style: { position: "absolute", top: 0, right: 0, width: "10px", height: "100%", cursor: "ew-resize" }
4076
+ }
4077
+ ), /* @__PURE__ */ e.createElement(
4078
+ "div",
4079
+ {
4080
+ onMouseDown: (te) => typeof Te == "function" && Te("bottom", te),
4081
+ style: { position: "absolute", left: 0, bottom: 0, width: "100%", height: "10px", cursor: "ns-resize" }
4082
+ }
4083
+ ), /* @__PURE__ */ e.createElement(
4084
+ "div",
4085
+ {
4086
+ onMouseDown: (te) => typeof Te == "function" && Te("corner", te),
4087
+ style: { position: "absolute", right: 0, bottom: 0, width: "18px", height: "18px", cursor: "nwse-resize" }
4088
+ }
4089
+ )) : null));
4090
+ }, La = (t) => t.open ? /* @__PURE__ */ e.createElement($a, { ...t }) : null, Ra = ({ chartState: t, onClose: n, theme: o, position: i = "right", onPositionChange: r }) => {
4091
+ const [f, h] = _(t && t.chartType ? t.chartType : "bar"), [S, $] = _(t && t.barLayout ? t.barLayout : "grouped"), [R, C] = _(t && t.axisMode ? t.axisMode : "vertical"), [O, J] = _(t && t.defaultOrientation ? t.defaultOrientation : "rows"), [K, a] = _(t && t.defaultHierarchyLevel !== void 0 ? t.defaultHierarchyLevel : "all"), [X, T] = _(t && t.rowLimit ? t.rowLimit : _r), [V, Y] = _(t && t.columnLimit ? t.columnLimit : Xr), [F, U] = _(t && t.sortMode ? t.sortMode : "natural"), [ue, ne] = _(t && Array.isArray(t.chartLayers) ? t.chartLayers : []), [ie, pe] = _(null);
4092
+ He(() => {
4093
+ h(t && t.chartType ? t.chartType : "bar"), $(t && t.barLayout ? t.barLayout : "grouped"), C(t && t.axisMode ? t.axisMode : "vertical"), J(t && t.defaultOrientation ? t.defaultOrientation : "rows"), a(t && t.defaultHierarchyLevel !== void 0 ? t.defaultHierarchyLevel : "all"), T(t && t.rowLimit ? t.rowLimit : _r), Y(t && t.columnLimit ? t.columnLimit : Xr), U(t && t.sortMode ? t.sortMode : "natural"), ne(t && Array.isArray(t.chartLayers) ? t.chartLayers : []);
4094
+ }, [t]);
4095
+ const it = ot(() => {
4096
+ if (!t || !Array.isArray(t.visibleCols)) return [];
4097
+ if (!(t.selectionMap && t.visibleRows))
4098
+ return zr(t.visibleCols);
4099
+ const et = gn(t.selectionMap, t.visibleRows, t.visibleCols);
4100
+ if (!et) return [];
4101
+ const _e = new Set(
4102
+ (et.colIndexes || []).map((Me) => t.visibleCols[Me]).filter((Me) => Me && Me.id && !mn.has(Me.id)).map((Me) => Me.id)
4103
+ );
4104
+ return zr(t.visibleCols).filter((Me) => _e.has(Me.id));
4105
+ }, [t]), be = ot(() => t ? t.selectionMap && t.visibleRows && t.visibleCols ? f === "combo" ? yn(t.selectionMap, t.visibleRows, t.visibleCols, {
4106
+ hierarchyLevel: K,
4107
+ maxHierarchyLevel: t.maxHierarchyLevel || 1,
4108
+ maxRows: X,
4109
+ rowFields: t.rowFields || [],
4110
+ colFields: t.colFields || [],
4111
+ sortMode: F,
4112
+ layers: ue
4113
+ }) : bn(t.selectionMap, t.visibleRows, t.visibleCols, {
4114
+ orientation: O,
4115
+ hierarchyLevel: K,
4116
+ maxHierarchyLevel: t.maxHierarchyLevel || 1,
4117
+ maxRows: X,
4118
+ maxColumns: V,
4119
+ rowFields: t.rowFields || [],
4120
+ colFields: t.colFields || [],
4121
+ sortMode: F
4122
+ }) : t.model : null, [ue, t, f, K, O, X, V, F]);
4123
+ if (He(() => {
4124
+ if (S !== "stacked") return;
4125
+ if (f === "combo") {
4126
+ $("grouped");
4127
+ return;
4128
+ }
4129
+ (f === "area" ? be && Array.isArray(be.series) && be.series.length > 1 : Zr(be)) || $("grouped");
4130
+ }, [be, S, f]), !t) return null;
4131
+ const st = i === "top" || i === "bottom", Te = Math.max(420, Number.isFinite(Number(ie)) ? Math.floor(Number(ie)) : 420), Vt = Math.max(360, Number(t.chartHeight || or) + qr), ct = (et, _e) => ({
4132
+ border: `1px solid ${et === i ? o.primary : o.border}`,
4133
+ background: et === i ? o.select : o.headerSubtleBg || o.hover,
4134
+ color: et === i ? o.primary : o.text,
4135
+ borderRadius: o.radiusSm || "8px",
4136
+ padding: "5px 8px",
4137
+ fontSize: "11px",
4138
+ fontWeight: 700,
4139
+ cursor: "pointer"
4140
+ });
4141
+ return /* @__PURE__ */ e.createElement(
4142
+ "aside",
4143
+ {
4144
+ "data-chart-modal-position": i,
4145
+ style: {
4146
+ display: "flex",
4147
+ flexDirection: "column",
4148
+ width: st ? "100%" : `${Te}px`,
4149
+ minWidth: st ? 0 : `${Math.max(320, Te)}px`,
4150
+ maxWidth: st ? "100%" : "70%",
4151
+ height: st ? `${Vt}px` : void 0,
4152
+ minHeight: st ? "320px" : 0,
4153
+ flexShrink: 0,
4154
+ overflow: "hidden",
4155
+ borderLeft: i === "right" ? `1px solid ${o.border}` : "none",
4156
+ borderRight: i === "left" ? `1px solid ${o.border}` : "none",
4157
+ borderTop: i === "bottom" ? `1px solid ${o.border}` : "none",
4158
+ borderBottom: i === "top" ? `1px solid ${o.border}` : "none",
4159
+ background: o.sidebarBg || o.surfaceBg || o.background
4160
+ }
4161
+ },
4162
+ /* @__PURE__ */ e.createElement("div", { style: { padding: "12px 14px", overflow: "hidden", flex: 1, minHeight: 0, display: "flex", flexDirection: "column", gap: "12px" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "8px" } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "14px", fontWeight: 800, color: o.text } }, t.title || "Range Chart"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "4px" } }, typeof r == "function" ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
4163
+ "button",
4164
+ {
4165
+ type: "button",
4166
+ onClick: () => r("left"),
4167
+ style: ct("left"),
4168
+ title: "Dock chart pane to the left",
4169
+ "aria-label": "Dock left"
4170
+ },
4171
+ "Left"
4172
+ ), /* @__PURE__ */ e.createElement(
4173
+ "button",
4174
+ {
4175
+ type: "button",
4176
+ onClick: () => r("right"),
4177
+ style: ct("right"),
4178
+ title: "Dock chart pane to the right",
4179
+ "aria-label": "Dock right"
4180
+ },
4181
+ "Right"
4182
+ ), /* @__PURE__ */ e.createElement(
4183
+ "button",
4184
+ {
4185
+ type: "button",
4186
+ onClick: () => r("top"),
4187
+ style: ct("top"),
4188
+ title: "Dock chart pane to the top",
4189
+ "aria-label": "Dock top"
4190
+ },
4191
+ "Top"
4192
+ ), /* @__PURE__ */ e.createElement(
4193
+ "button",
4194
+ {
4195
+ type: "button",
4196
+ onClick: () => r("bottom"),
4197
+ style: ct("bottom"),
4198
+ title: "Dock chart pane to the bottom",
4199
+ "aria-label": "Dock bottom"
4200
+ },
4201
+ "Bottom"
4202
+ )) : null, /* @__PURE__ */ e.createElement(
4203
+ "button",
4204
+ {
4205
+ onClick: n,
4206
+ style: {
4207
+ border: `1px solid ${o.border}`,
4208
+ background: o.headerSubtleBg || o.hover,
4209
+ color: o.text,
4210
+ borderRadius: o.radiusSm || "8px",
4211
+ padding: "5px 10px",
4212
+ fontSize: "11px",
4213
+ fontWeight: 700,
4214
+ cursor: "pointer"
4215
+ }
4216
+ },
4217
+ "Close"
4218
+ ))), /* @__PURE__ */ e.createElement(
4219
+ an,
4220
+ {
4221
+ model: be,
4222
+ chartType: f,
4223
+ chartLayers: ue,
4224
+ onChartLayersChange: ne,
4225
+ availableColumns: it,
4226
+ barLayout: S,
4227
+ axisMode: R,
4228
+ onChartTypeChange: h,
4229
+ onBarLayoutChange: $,
4230
+ onAxisModeChange: C,
4231
+ orientation: O,
4232
+ onOrientationChange: J,
4233
+ hierarchyLevel: K,
4234
+ onHierarchyLevelChange: a,
4235
+ title: t.title || "Range Chart",
4236
+ rowLimit: X,
4237
+ onRowLimitChange: T,
4238
+ columnLimit: V,
4239
+ onColumnLimitChange: Y,
4240
+ sortMode: F,
4241
+ onSortModeChange: U,
4242
+ theme: o,
4243
+ allowHierarchyCharts: !(t.selectionMap && t.visibleRows && t.visibleCols),
4244
+ onSettingsWidthBudgetChange: pe
4245
+ }
4246
+ ))
4247
+ );
4248
+ };
4249
+ export {
4250
+ Ra as PivotChartModal,
4251
+ La as PivotChartPanel
4252
+ };