serverside_pivot 0.0.91 → 0.0.96

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 (172) hide show
  1. package/README.md +182 -182
  2. package/dist/react/chunks/ContextMenu-DJuS4qTZ.mjs +198 -0
  3. package/dist/react/chunks/{DetailDrawer-Eb4EpVHG.mjs → DetailDrawer-DgKSC5Vu.mjs} +1 -1
  4. package/dist/react/chunks/{DetailSidePanel-BTcHOiKr.mjs → DetailSidePanel-CC5Dugyl.mjs} +1 -1
  5. package/dist/react/chunks/{DetailSurfaceContent-B3ZNKh7q.mjs → DetailSurfaceContent-CrQVHlcU.mjs} +85 -77
  6. package/dist/react/chunks/{ECharts2dRenderer-C3Qv0uAa.mjs → ECharts2dRenderer-46gLrUdf.mjs} +412 -410
  7. package/dist/react/chunks/{ECharts3dRenderer-BB_7-fOt.mjs → ECharts3dRenderer-Dg4ta5Bl.mjs} +2211 -3197
  8. package/dist/react/chunks/{EditSidePanel-C2cAvxlK.mjs → EditSidePanel-CkShaByb.mjs} +77 -65
  9. package/dist/react/chunks/{InlineDetailPanel-BXLAw1o3.mjs → InlineDetailPanel-mnwjoD0I.mjs} +1 -1
  10. package/dist/react/chunks/PivotCharts-MX-Z7DlR.mjs +5076 -0
  11. package/dist/react/chunks/{ReportEditor-D4V0ry2B.mjs → ReportEditor-U0E42xKL.mjs} +952 -631
  12. package/dist/react/chunks/SidebarPanel-BzRW1Kgq.mjs +3944 -0
  13. package/dist/react/chunks/{SparklineDetailGraph-Bu85X7OJ.mjs → SparklineDetailGraph-35Tim_8B.mjs} +88 -58
  14. package/dist/react/chunks/installCanvasRenderer-DRq0xpXO.mjs +21174 -0
  15. package/dist/react/chunks/react-CL4GbEOd.mjs +33206 -0
  16. package/dist/react/chunks/{xlsx.mini.min-vfxHk3Ry.mjs → xlsx.mini.min-kfIgXMVB.mjs} +5 -5
  17. package/dist/react/components/Charts/ChartRenderers.d.ts +5 -73
  18. package/dist/react/components/Charts/ChartWorkspace.d.ts +3 -34
  19. package/dist/react/components/Charts/ECharts2dRenderer.d.ts +2 -5
  20. package/dist/react/components/Charts/ECharts3dRenderer.d.ts +2 -6
  21. package/dist/react/components/Charts/PivotCharts.d.ts +2 -9
  22. package/dist/react/components/Charts/chartEnhancements.d.ts +17 -66
  23. package/dist/react/components/Charts/chartExportPresentation.d.ts +5 -19
  24. package/dist/react/components/Charts/chartMath.d.ts +4 -4
  25. package/dist/react/components/Charts/useChartExportMenu.d.ts +4 -12
  26. package/dist/react/components/DashTanstackPivot.react.d.ts +40 -0
  27. package/dist/react/components/Filters/ColumnFilter.d.ts +2 -12
  28. package/dist/react/components/Filters/DateRangeFilter.d.ts +2 -7
  29. package/dist/react/components/Filters/FilterPopover.d.ts +2 -13
  30. package/dist/react/components/Filters/MultiSelectFilter.d.ts +2 -11
  31. package/dist/react/components/Filters/NumericRangeFilter.d.ts +2 -7
  32. package/dist/react/components/Notification.d.ts +2 -6
  33. package/dist/react/components/PivotAppBar.d.ts +2 -2
  34. package/dist/react/components/PivotErrorBoundary.d.ts +11 -7
  35. package/dist/react/components/PivotSmallComponents.d.ts +2 -3
  36. package/dist/react/components/PivotWorkspaceCanvas.d.ts +2 -5
  37. package/dist/react/components/PivotWorkspaceControls.d.ts +4 -8
  38. package/dist/react/components/PivotWorkspaceShell.d.ts +4 -12
  39. package/dist/react/components/RuntimeDataError.d.ts +2 -7
  40. package/dist/react/components/ShimmerFallback.d.ts +11 -0
  41. package/dist/react/components/Sidebar/ColumnTreeItem.d.ts +2 -13
  42. package/dist/react/components/Sidebar/ReportEditor.d.ts +7 -20
  43. package/dist/react/components/Sidebar/SidebarFilterItem.d.ts +2 -13
  44. package/dist/react/components/Sidebar/SidebarPanel.d.ts +1 -2
  45. package/dist/react/components/Sidebar/ToolPanelSection.d.ts +2 -13
  46. package/dist/react/components/Sidebar/customCategoryUtils.d.ts +31 -62
  47. package/dist/react/components/Sidebar/formulaUtils.d.ts +16 -18
  48. package/dist/react/components/SkeletonRow.d.ts +2 -5
  49. package/dist/react/components/Table/ContextMenu.d.ts +2 -8
  50. package/dist/react/components/Table/DetailDrawer.d.ts +2 -11
  51. package/dist/react/components/Table/DetailSidePanel.d.ts +2 -11
  52. package/dist/react/components/Table/DetailSurfaceContent.d.ts +2 -11
  53. package/dist/react/components/Table/EditSidePanel.d.ts +2 -20
  54. package/dist/react/components/Table/EditableCell.d.ts +2 -28
  55. package/dist/react/components/Table/InlineDetailPanel.d.ts +2 -13
  56. package/dist/react/components/Table/PivotTableBody.d.ts +3 -3
  57. package/dist/react/components/Table/SparklineCell.d.ts +2 -17
  58. package/dist/react/components/Table/SparklineDetailGraph.d.ts +2 -5
  59. package/dist/react/components/Table/StatusBar.d.ts +2 -7
  60. package/dist/react/components/ThemedSelect.d.ts +8 -0
  61. package/dist/react/contexts/PivotConfigContext.d.ts +5 -33
  62. package/dist/react/contexts/PivotThemeContext.d.ts +8 -4
  63. package/dist/react/contexts/PivotValueDisplayContext.d.ts +5 -9
  64. package/dist/react/hooks/useChartState.d.ts +2 -71
  65. package/dist/react/hooks/useColumnDefs.d.ts +3 -68
  66. package/dist/react/hooks/useColumnVirtualizer.d.ts +1 -30
  67. package/dist/react/hooks/useDetailDrillThrough.d.ts +2 -36
  68. package/dist/react/hooks/useFilteredData.d.ts +4 -2
  69. package/dist/react/hooks/useFormatState.d.ts +2 -39
  70. package/dist/react/hooks/usePersistence.d.ts +4 -5
  71. package/dist/react/hooks/usePivotFieldInteractions.d.ts +2 -23
  72. package/dist/react/hooks/usePivotNormalization.d.ts +127 -461
  73. package/dist/react/hooks/usePivotRenderCounter.d.ts +2 -1
  74. package/dist/react/hooks/usePivotTransactions.d.ts +2 -23
  75. package/dist/react/hooks/useRenderHelpers.d.ts +3 -71
  76. package/dist/react/hooks/useReportMode.d.ts +2 -28
  77. package/dist/react/hooks/useRowCache.d.ts +16 -15
  78. package/dist/react/hooks/useRuntimeDataCommit.d.ts +2 -22
  79. package/dist/react/hooks/useRuntimeProfiling.d.ts +2 -13
  80. package/dist/react/hooks/useRuntimeTransport.d.ts +2 -18
  81. package/dist/react/hooks/useServerSideRowModel.d.ts +1 -50
  82. package/dist/react/hooks/useServerSideViewportController.d.ts +1 -64
  83. package/dist/react/hooks/useSidebarUI.d.ts +2 -32
  84. package/dist/react/hooks/useStickyStyles.d.ts +2 -23
  85. package/dist/react/index.mjs +15 -9
  86. package/dist/react/presentation/headerFormatting.d.ts +28 -11
  87. package/dist/react/presentation/safeCellContent.d.ts +22 -5
  88. package/dist/react/react.d.ts +4 -1
  89. package/dist/react/runtime/PivotRuntimeRoot.d.ts +1 -1
  90. package/dist/react/runtime/client/clientPivotTransport.d.ts +6 -1
  91. package/dist/react/runtime/client/clientResponsePostProcessor.d.ts +50 -0
  92. package/dist/react/runtime/client/duckdbWasmExecutor.d.ts +3 -0
  93. package/dist/react/runtime/client/types.d.ts +17 -0
  94. package/dist/react/runtime/createRuntimeCellPresentation.d.ts +2 -7
  95. package/dist/react/runtime/createRuntimeExportCommands.d.ts +2 -71
  96. package/dist/react/runtime/createRuntimeRowPinCommand.d.ts +2 -9
  97. package/dist/react/runtime/displayColumnOrder.d.ts +4 -4
  98. package/dist/react/runtime/httpTransport.d.ts +1 -0
  99. package/dist/react/runtime/runtime-contract.generated.d.ts +3 -0
  100. package/dist/react/runtime/runtimeContract.d.ts +3 -0
  101. package/dist/react/runtime/runtimeDomains.d.ts +110 -0
  102. package/dist/react/runtime/useChartWorkspacePresentation.d.ts +2 -45
  103. package/dist/react/runtime/useCoreRuntime.d.ts +4 -1
  104. package/dist/react/runtime/useCoreRuntimeStage.d.ts +1 -1
  105. package/dist/react/runtime/useRuntimeCellSelection.d.ts +2 -40
  106. package/dist/react/runtime/useRuntimeChartCanvasCommands.d.ts +7 -31
  107. package/dist/react/runtime/useRuntimeChartCanvasResize.d.ts +2 -13
  108. package/dist/react/runtime/useRuntimeChartCanvasVerticalResize.d.ts +2 -9
  109. package/dist/react/runtime/useRuntimeChartDefinitionCommands.d.ts +2 -14
  110. package/dist/react/runtime/useRuntimeChartFloatingInteractions.d.ts +2 -28
  111. package/dist/react/runtime/useRuntimeChartModels.d.ts +2 -62
  112. package/dist/react/runtime/useRuntimeChartPanelSizing.d.ts +2 -12
  113. package/dist/react/runtime/useRuntimeChartRequestDispatch.d.ts +2 -4
  114. package/dist/react/runtime/useRuntimeClipboardExportPresentation.d.ts +2 -152
  115. package/dist/react/runtime/useRuntimeClipboardPaste.d.ts +2 -7
  116. package/dist/react/runtime/useRuntimeColorScalePresentation.d.ts +2 -55
  117. package/dist/react/runtime/useRuntimeColumnAutoSizing.d.ts +2 -26
  118. package/dist/react/runtime/useRuntimeColumnCommands.d.ts +2 -22
  119. package/dist/react/runtime/useRuntimeColumnMeasurement.d.ts +2 -11
  120. package/dist/react/runtime/useRuntimeDataRetry.d.ts +2 -12
  121. package/dist/react/runtime/useRuntimeDisplayNavigation.d.ts +2 -11
  122. package/dist/react/runtime/useRuntimeEditCellIdentity.d.ts +2 -18
  123. package/dist/react/runtime/useRuntimeEditChangeTracking.d.ts +2 -28
  124. package/dist/react/runtime/useRuntimeEditComparisonState.d.ts +2 -35
  125. package/dist/react/runtime/useRuntimeEditDispatch.d.ts +2 -43
  126. package/dist/react/runtime/useRuntimeEditOwnership.d.ts +2 -28
  127. package/dist/react/runtime/useRuntimeEditPresentation.d.ts +2 -32
  128. package/dist/react/runtime/useRuntimeEditStatePersistence.d.ts +2 -24
  129. package/dist/react/runtime/useRuntimeExportState.d.ts +5 -5
  130. package/dist/react/runtime/useRuntimeFilterPopover.d.ts +2 -19
  131. package/dist/react/runtime/useRuntimeLayoutHistory.d.ts +2 -40
  132. package/dist/react/runtime/useRuntimeOptimisticCellState.d.ts +2 -27
  133. package/dist/react/runtime/useRuntimeRequestSession.d.ts +2 -76
  134. package/dist/react/runtime/useRuntimeResponseLifecycle.d.ts +2 -43
  135. package/dist/react/runtime/useRuntimeResponsePostCommit.d.ts +2 -15
  136. package/dist/react/runtime/useRuntimeRowEditSessions.d.ts +2 -28
  137. package/dist/react/runtime/useRuntimeRowEditing.d.ts +2 -18
  138. package/dist/react/runtime/useRuntimeRowSelection.d.ts +2 -14
  139. package/dist/react/runtime/useRuntimeSelectionFormatting.d.ts +2 -30
  140. package/dist/react/runtime/useRuntimeStructuralSync.d.ts +2 -61
  141. package/dist/react/runtime/useRuntimeViewRestoreScroll.d.ts +2 -5
  142. package/dist/react/runtime/useRuntimeViewSnapshot.d.ts +2 -196
  143. package/dist/react/runtime/useRuntimeViewportTableData.d.ts +2 -23
  144. package/dist/react/runtime/useWorkspaceStatusPresentation.d.ts +2 -109
  145. package/dist/react/utils/Icons.d.ts +2 -45
  146. package/dist/react/utils/chartModelBuilders.d.ts +76 -230
  147. package/dist/react/utils/columnOrder.d.ts +8 -12
  148. package/dist/react/utils/dataBars.d.ts +4 -7
  149. package/dist/react/utils/domEvents.d.ts +2 -1
  150. package/dist/react/utils/editing.d.ts +12 -47
  151. package/dist/react/utils/exportUtils.d.ts +30 -101
  152. package/dist/react/utils/fieldPanelLayout.d.ts +12 -61
  153. package/dist/react/utils/filterOptions.d.ts +4 -4
  154. package/dist/react/utils/helpers.d.ts +21 -18
  155. package/dist/react/utils/horizontalViewport.d.ts +1 -12
  156. package/dist/react/utils/layoutRows.d.ts +3 -3
  157. package/dist/react/utils/measureAxis.d.ts +6 -22
  158. package/dist/react/utils/pivotLayoutUtils.d.ts +7 -2
  159. package/dist/react/utils/pivotProfiler.d.ts +3 -3
  160. package/dist/react/utils/reportEditorSelection.d.ts +1 -23
  161. package/dist/react/utils/rowSpanning.d.ts +3 -6
  162. package/dist/react/utils/savedReports.d.ts +4 -7
  163. package/dist/react/utils/sorting.d.ts +8 -14
  164. package/dist/react/utils/sparklineDetail.d.ts +5 -8
  165. package/dist/react/utils/sparklines.d.ts +10 -78
  166. package/dist/react/utils/styles.d.ts +19 -308
  167. package/package.json +114 -114
  168. package/dist/react/chunks/ContextMenu-Bt5_3bmD.mjs +0 -192
  169. package/dist/react/chunks/PivotCharts-Bw6Swoa3.mjs +0 -4252
  170. package/dist/react/chunks/SidebarPanel-xO59p_2o.mjs +0 -3339
  171. package/dist/react/chunks/installCanvasRenderer-B7sfDGoL.mjs +0 -21281
  172. package/dist/react/chunks/react-CPZZxtSo.mjs +0 -26999
@@ -1,3339 +0,0 @@
1
- import e, { useState as be, useRef as mt, useEffect as er } from "react";
2
- import { y as z, Y as fe, Z as Wr, _ as Br, $ as xt, a0 as Je, a1 as Ir, a2 as Lr, a3 as Pr, a4 as Fe, a5 as Qe, a6 as et, E as Or, a7 as Hr, a8 as Ur, a9 as jr, aa as Pe, ab as tr, ac as Vr, ad as Ht, ae as Yr, af as Zr, ag as Kr, ah as Gr, ai as Nr, aj as Xr } from "./react-CPZZxtSo.mjs";
3
- const Jr = ({ column: t, theme: n, styles: s, onFilter: a, currentFilter: l, options: g, optionMeta: u, onSearchOptions: E, onLoadMoreOptions: d, onOpen: $ }) => {
4
- const [i, m] = be(!1), T = l && (l.conditions || l.value), L = () => m(!1), _ = () => {
5
- const D = !i;
6
- m(D), D && typeof $ == "function" && $(t.id);
7
- };
8
- return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column" } }, /* @__PURE__ */ e.createElement(
9
- "div",
10
- {
11
- style: {
12
- ...s.columnItem,
13
- cursor: "pointer",
14
- background: i ? n.select : "transparent",
15
- borderLeft: T ? `3px solid ${n.primary}` : "3px solid transparent"
16
- },
17
- onClick: _
18
- },
19
- /* @__PURE__ */ e.createElement("span", { style: { marginRight: "8px", opacity: 0.7, display: "flex" } }, i ? /* @__PURE__ */ e.createElement(z.ChevronDown, null) : /* @__PURE__ */ e.createElement(z.ChevronRight, null)),
20
- /* @__PURE__ */ e.createElement("span", { style: { flex: 1, fontWeight: 500, display: "flex", alignItems: "center", gap: "6px" } }, T && /* @__PURE__ */ e.createElement(z.Filter, { style: { fontSize: "12px", color: n.primary } }), fe(typeof t.header == "string" ? t.header : t.columnDef && typeof t.columnDef.header == "string" ? t.columnDef.header : t.id))
21
- ), i && /* @__PURE__ */ e.createElement("div", { style: { padding: "8px", borderBottom: `1px solid ${n.border}44` } }, /* @__PURE__ */ e.createElement(
22
- Wr,
23
- {
24
- column: t,
25
- onFilter: a,
26
- currentFilter: l,
27
- options: g,
28
- optionMeta: u,
29
- onSearchOptions: E,
30
- onLoadMoreOptions: d,
31
- theme: n,
32
- onClose: L
33
- }
34
- )));
35
- }, gt = ({ title: t, children: n, items: s, renderItem: a, theme: l, styles: g, initialExpanded: u = !0, count: E, onDrop: d, sectionId: $ }) => {
36
- const [i, m] = be(u), [T, L] = be(u ? 200 : 0), [_, D] = be(!1), y = mt(null);
37
- mt(null), er(() => {
38
- if (i && y.current) {
39
- const k = y.current.scrollHeight;
40
- L(Math.min(k, 300));
41
- } else
42
- L(0);
43
- }, [i, s, E]);
44
- const h = Br({
45
- count: s ? s.length : 0,
46
- getScrollElement: () => y.current,
47
- estimateSize: () => 32,
48
- overscan: 10,
49
- enabled: !!s && i
50
- }), w = (k) => {
51
- k.preventDefault(), D(!0);
52
- }, W = () => {
53
- D(!1);
54
- }, O = (k) => {
55
- k.preventDefault(), D(!1);
56
- const P = k.dataTransfer.getData("text/plain");
57
- d && P && d(P, $);
58
- };
59
- return /* @__PURE__ */ e.createElement(
60
- "div",
61
- {
62
- style: {
63
- ...g.toolPanelSection,
64
- flex: i ? "0 1 auto" : "0 0 auto",
65
- minHeight: i ? "40px" : "32px",
66
- overflow: "hidden"
67
- // Prevent overlap
68
- },
69
- onDragOver: w,
70
- onDragLeave: W,
71
- onDrop: O
72
- },
73
- /* @__PURE__ */ e.createElement("div", { style: g.toolPanelSectionHeader, onClick: () => m(!i) }, /* @__PURE__ */ e.createElement("span", { style: { marginRight: "8px", opacity: 0.7, display: "flex" } }, i ? /* @__PURE__ */ e.createElement(z.ChevronDown, null) : /* @__PURE__ */ e.createElement(z.ChevronRight, null)), /* @__PURE__ */ e.createElement("span", { style: { flex: 1 } }, t), E !== void 0 && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", opacity: 0.5, background: l.hover, padding: "2px 6px", borderRadius: "10px" } }, E)),
74
- /* @__PURE__ */ e.createElement(
75
- "div",
76
- {
77
- ref: y,
78
- style: {
79
- ...g.toolPanelList,
80
- height: `${T}px`,
81
- overflowY: i ? "auto" : "hidden",
82
- transition: "height 0.3s ease",
83
- opacity: i ? 1 : 0
84
- }
85
- },
86
- s ? /* @__PURE__ */ e.createElement("div", { style: {
87
- height: `${h.getTotalSize()}px`,
88
- width: "100%",
89
- position: "relative"
90
- } }, h.getVirtualItems().map((k) => /* @__PURE__ */ e.createElement(
91
- "div",
92
- {
93
- key: k.index,
94
- style: {
95
- position: "absolute",
96
- top: 0,
97
- left: 0,
98
- width: "100%",
99
- height: `${k.size}px`,
100
- transform: `translateY(${k.start}px)`
101
- }
102
- },
103
- a(s[k.index], k.index)
104
- ))) : n
105
- )
106
- );
107
- }, rr = ({ column: t, level: n, theme: s, styles: a, handlePinColumn: l, colSearch: g, selectedCols: u, setSelectedCols: E, onDrop: d, sectionId: $ }) => {
108
- const [i, m] = be(n < 1), [T, L] = be(!1), [_, D] = be(!1), y = mt(null), h = t.columns && t.columns.length > 0, w = t.columnDef.header;
109
- let W = typeof w == "string" ? w : t.id;
110
- typeof W == "string" && W.startsWith("group_") && (W = t.id.replace("group_", "").split("|||").pop() || W), t.headerVal && (W = t.headerVal), W = fe(W);
111
- const O = t.getIsPinned(), k = t.getIsVisible(), P = h ? xt(t) : [t.id], o = P.length > 0 && P.every((v) => u.has(v)), A = !o && P.some((v) => u.has(v));
112
- if (er(() => {
113
- y.current && (y.current.indeterminate = A);
114
- }, [A]), g && !W.toLowerCase().includes(g.toLowerCase()))
115
- if (h) {
116
- const v = (U) => {
117
- const Q = U.columnDef.header;
118
- return (typeof Q == "string" ? Q : U.id).toLowerCase().includes(g.toLowerCase()) ? !0 : U.columns ? U.columns.some(v) : !1;
119
- };
120
- if (!v(t)) return null;
121
- } else
122
- return null;
123
- const R = (v) => {
124
- v.stopPropagation();
125
- const U = new Set(u), Q = h ? xt(t) : [t.id];
126
- Q.every((ee) => U.has(ee)) ? Q.forEach((ee) => U.delete(ee)) : Q.forEach((ee) => U.add(ee)), E(U);
127
- }, B = (v) => {
128
- if (v.stopPropagation(), h) {
129
- const U = Ir(t), Q = U.some((V) => !V.getIsVisible());
130
- U.forEach((V) => V.toggleVisibility(Q));
131
- } else
132
- t.toggleVisibility();
133
- }, M = (v, U) => {
134
- v.stopPropagation(), l(t.id, U);
135
- }, H = (v) => {
136
- D(!0), v.dataTransfer.setData("text/plain", t.id), v.dataTransfer.effectAllowed = "move";
137
- }, K = () => {
138
- D(!1);
139
- }, x = (v) => {
140
- v.preventDefault(), v.stopPropagation();
141
- const U = v.dataTransfer.getData("text/plain");
142
- U && d && U !== t.id && d(U, $, t.id);
143
- }, F = (v) => {
144
- v.key === "Enter" ? B(v) : v.key === " " ? (v.preventDefault(), R(v)) : v.altKey && v.key === "ArrowLeft" ? (v.preventDefault(), l(t.id, "left")) : v.altKey && v.key === "ArrowRight" ? (v.preventDefault(), l(t.id, "right")) : v.altKey && v.key === "ArrowDown" && (v.preventDefault(), l(t.id, !1));
145
- };
146
- return /* @__PURE__ */ e.createElement(
147
- "div",
148
- {
149
- style: { display: "flex", flexDirection: "column", opacity: _ ? 0.5 : 1 },
150
- draggable: !h,
151
- onDragStart: H,
152
- onDragEnd: K,
153
- onDragOver: (v) => v.preventDefault(),
154
- onDrop: x,
155
- role: "treeitem",
156
- "aria-selected": o || A,
157
- "aria-expanded": i
158
- },
159
- /* @__PURE__ */ e.createElement(
160
- "div",
161
- {
162
- style: {
163
- ...a.columnItem,
164
- paddingLeft: `${n * 12 + 8}px`,
165
- // Reduced indentation step
166
- background: o || A ? s.select : T ? s.hover : "transparent",
167
- borderLeft: O ? `3px solid ${s.primary}` : "3px solid transparent"
168
- },
169
- onMouseEnter: (v) => !(o || A) && L(!0),
170
- onMouseLeave: (v) => !(o || A) && L(!1),
171
- tabIndex: 0,
172
- onKeyDown: F
173
- },
174
- /* @__PURE__ */ e.createElement(
175
- "input",
176
- {
177
- ref: y,
178
- type: "checkbox",
179
- checked: o,
180
- onChange: R,
181
- onClick: (v) => v.stopPropagation(),
182
- style: { margin: 0, cursor: "pointer", pointerEvents: "auto" },
183
- tabIndex: -1
184
- }
185
- ),
186
- !h && /* @__PURE__ */ e.createElement("span", { style: { cursor: "grab", display: "flex", opacity: 0.7, marginRight: "4px" } }, /* @__PURE__ */ e.createElement(z.DragIndicator, null)),
187
- h ? /* @__PURE__ */ e.createElement(
188
- "span",
189
- {
190
- role: "button",
191
- tabIndex: 0,
192
- "aria-expanded": i,
193
- "aria-label": i ? `Collapse ${W}` : `Expand ${W}`,
194
- onClick: () => m(!i),
195
- onKeyDown: (v) => {
196
- (v.key === "Enter" || v.key === " ") && (v.preventDefault(), m(!i));
197
- },
198
- style: { cursor: "pointer", display: "flex", opacity: 0.7, marginRight: "4px" }
199
- },
200
- i ? /* @__PURE__ */ e.createElement(z.ChevronDown, null) : /* @__PURE__ */ e.createElement(z.ChevronRight, null)
201
- ) : /* @__PURE__ */ e.createElement("span", { style: { width: "20px" } }),
202
- /* @__PURE__ */ e.createElement(
203
- "span",
204
- {
205
- onClick: B,
206
- style: {
207
- cursor: "pointer",
208
- display: "flex",
209
- color: k ? s.primary : s.textSec,
210
- opacity: k ? 1 : 0.5,
211
- marginRight: "4px"
212
- },
213
- title: k ? "Hide Column" : "Show Column",
214
- "aria-label": k ? "Hide Column" : "Show Column"
215
- },
216
- k ? /* @__PURE__ */ e.createElement(z.Visibility, null) : /* @__PURE__ */ e.createElement(z.VisibilityOff, null)
217
- ),
218
- /* @__PURE__ */ e.createElement(
219
- "span",
220
- {
221
- style: {
222
- flex: 1,
223
- overflow: "hidden",
224
- textOverflow: "ellipsis",
225
- whiteSpace: "nowrap",
226
- fontWeight: h ? 600 : 400,
227
- cursor: h ? "pointer" : "default",
228
- color: k ? s.text : s.textSec,
229
- opacity: k ? 1 : 0.6,
230
- display: "flex",
231
- alignItems: "center"
232
- },
233
- onClick: () => h && m(!i),
234
- title: W
235
- },
236
- h && /* @__PURE__ */ e.createElement(z.Group, { style: { marginRight: "6px", fontSize: "14px", opacity: 0.8 } }),
237
- W
238
- ),
239
- !h && /* @__PURE__ */ e.createElement("div", { className: "pin-controls" }, /* @__PURE__ */ e.createElement("button", { onClick: (v) => M(v, "left"), title: "Pin Column Left", "aria-label": "Pin Column Left" }, /* @__PURE__ */ e.createElement(z.PinLeft, null)), /* @__PURE__ */ e.createElement("button", { onClick: (v) => M(v, !1), title: "Unpin Column", "aria-label": "Unpin Column" }, /* @__PURE__ */ e.createElement(z.Unpin, null)), /* @__PURE__ */ e.createElement("button", { onClick: (v) => M(v, "right"), title: "Pin Column Right", "aria-label": "Pin Column Right" }, /* @__PURE__ */ e.createElement(z.PinRight, null)))
240
- ),
241
- h && i && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column" } }, t.columns.filter((v) => Je(v, $)).map((v) => /* @__PURE__ */ e.createElement(
242
- rr,
243
- {
244
- key: v.id,
245
- column: v,
246
- level: n + 1,
247
- theme: s,
248
- styles: a,
249
- handlePinColumn: l,
250
- colSearch: g,
251
- selectedCols: u,
252
- setSelectedCols: E,
253
- onDrop: d,
254
- sectionId: $
255
- }
256
- )))
257
- );
258
- }, nr = /\b[A-Za-z_][A-Za-z0-9_]*\b/g, lr = /^[A-Za-z_][A-Za-z0-9_]*$/, tt = /\[([^\]]+)\]/g, qr = /* @__PURE__ */ new Set(["abs", "round", "ceil", "floor", "max", "min", "int", "float"]), Qr = /* @__PURE__ */ new Set(["True", "False", "None", "and", "or", "not", "if", "else", "in", "is"]), Ee = {
259
- type: "line",
260
- metric: "last",
261
- showCurrentValue: !0,
262
- showDelta: !0,
263
- compact: !1,
264
- hideColumns: !1,
265
- placement: "before",
266
- source: "pivot",
267
- displayMode: "trend"
268
- };
269
- function ar(t) {
270
- return String(t || "").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
271
- }
272
- function ve(t, n = "formula") {
273
- const a = String(t || "").trim().toLowerCase().replace(/\s+/g, "").replace(/[^a-z0-9_]/g, "") || String(n || "formula").toLowerCase().replace(/[^a-z0-9_]/g, "") || "formula";
274
- return /^[a-z_]/.test(a) ? a : `f_${a}`;
275
- }
276
- function N(t) {
277
- return !t || typeof t != "object" ? "" : String(
278
- t.formulaRef || ve(t.label || "", t.field || "formula") || t.field || ""
279
- ).trim();
280
- }
281
- function ze(t) {
282
- const n = String(t || "").trim().toLowerCase();
283
- return ["columns", "display", "displayed", "displayed_columns", "rendered", "rendered_columns"].includes(n) ? "columns" : "measures";
284
- }
285
- function xe(t) {
286
- return ze(t) === "columns";
287
- }
288
- const en = [
289
- { value: "eq", label: "Equals" },
290
- { value: "ne", label: "Does not equal" },
291
- { value: "contains", label: "Contains" },
292
- { value: "starts_with", label: "Starts with" },
293
- { value: "ends_with", label: "Ends with" },
294
- { value: "gt", label: ">" },
295
- { value: "gte", label: ">=" },
296
- { value: "lt", label: "<" },
297
- { value: "lte", label: "<=" },
298
- { value: "in", label: "In list" },
299
- { value: "not_in", label: "Not in list" },
300
- { value: "is_null", label: "Is empty" },
301
- { value: "is_not_null", label: "Is not empty" }
302
- ], Ut = /* @__PURE__ */ new Set(["in", "not_in"]), tn = /* @__PURE__ */ new Set(["is_null", "is_not_null"]);
303
- function or(t) {
304
- return { field: t && t[0] || "", operator: "eq", value: "", values: [], caseSensitive: !1 };
305
- }
306
- function ir(t, n = 0) {
307
- return {
308
- id: `rule-${Date.now().toString(36)}-${n}`,
309
- label: n === 0 ? "Group A" : `Group ${n + 1}`,
310
- condition: { op: "AND", clauses: [or(t)] }
311
- };
312
- }
313
- function jt(t, n = null) {
314
- if (n) {
315
- const a = Fe([n])[0] || n;
316
- return { ...JSON.parse(JSON.stringify(a)), __editingField: a.field, __editingId: a.id };
317
- }
318
- const s = Qe(`category_${Date.now().toString(36)}`);
319
- return {
320
- id: s,
321
- field: et(s),
322
- name: "New Category",
323
- fallbackLabel: "Other",
324
- order: "creation",
325
- rules: [ir(t, 0)],
326
- __isNew: !0
327
- };
328
- }
329
- function rn(t, n) {
330
- if (!n) return "string";
331
- const s = Array.isArray(t) ? t.slice(0, 250) : [];
332
- for (let a = 0; a < s.length; a += 1) {
333
- const l = s[a];
334
- if (!l || typeof l != "object") continue;
335
- const g = l[n];
336
- if (!(g == null || g === "")) {
337
- if (typeof g == "number" && Number.isFinite(g)) return "number";
338
- if (g instanceof Date && !Number.isNaN(g.getTime())) return "date";
339
- if (typeof g == "string") {
340
- const u = g.trim();
341
- if (!u) continue;
342
- if (Number.isFinite(Number(u))) return "number";
343
- const E = Date.parse(u);
344
- return !Number.isNaN(E) && /[-/T:]/.test(u) ? "date" : "string";
345
- }
346
- }
347
- }
348
- return "string";
349
- }
350
- const qe = (t, n, s) => (Array.isArray(n) ? n : []).filter((a) => rn(t, a) === s);
351
- function nn(t, n) {
352
- const a = qe(n, t, "date")[0] || t[0] || "", l = Qe(`${a || "date"}_month`);
353
- return {
354
- id: l,
355
- field: et(l),
356
- kind: "date_group",
357
- name: a ? `${fe(a)} Month` : "Date Month",
358
- sourceField: a,
359
- granularity: "month",
360
- fiscalYearStartMonth: 1,
361
- fallbackLabel: "No date",
362
- __isNew: !0
363
- };
364
- }
365
- function ln(t, n) {
366
- const a = qe(n, t, "number")[0] || t[0] || "", l = Qe(`${a || "number"}_bins`);
367
- return {
368
- id: l,
369
- field: et(l),
370
- kind: "number_group",
371
- name: a ? `${fe(a)} Bins` : "Number Bins",
372
- sourceField: a,
373
- binSize: 10,
374
- minValue: "",
375
- maxValue: "",
376
- precision: 0,
377
- fallbackLabel: "No value",
378
- __isNew: !0
379
- };
380
- }
381
- const Vt = (t) => String(t || "").split(",").map((n) => n.trim()).filter(Boolean), Yt = (t) => String(t || "").trim().replace(/\s+/g, " ").toLowerCase(), sr = (t) => t && (t.__editingField || t.field) ? t.__editingField || t.field : "";
382
- function an(t, n) {
383
- const s = Array.isArray(t) ? t : [], a = sr(n);
384
- if (!a) return s;
385
- const l = s.findIndex((g) => g && g.field === a);
386
- return l >= 0 ? s.slice(0, l) : s;
387
- }
388
- function Zt(t) {
389
- const n = [];
390
- return (t && Array.isArray(t.rules) ? t.rules : []).forEach((s) => {
391
- (s && s.condition && Array.isArray(s.condition.clauses) ? s.condition.clauses : []).forEach((l) => {
392
- l && l.field && n.push(l.field);
393
- });
394
- }), Array.from(new Set(n));
395
- }
396
- function on(t, n) {
397
- const s = (Array.isArray(t) ? t : []).filter((a) => a && typeof a == "object").filter((a) => !a._isTotal && a._path !== "__grand_total__" && a._path !== "__color_scale_stats__");
398
- return Lr(s, n || []);
399
- }
400
- function sn(t, n) {
401
- return !Array.isArray(t) || t.length === 0 || !Array.isArray(n) || n.length === 0 ? !1 : n.every((s) => t.some((a) => a && Object.prototype.hasOwnProperty.call(a, s)));
402
- }
403
- const cn = (t, n) => (n && Array.isArray(n.rules) ? n.rules : []).map((s) => ({
404
- label: s && s.label ? s.label : "Rule",
405
- count: t.reduce((a, l) => Pr(l, s.condition) ? a + 1 : a, 0)
406
- })), un = e.lazy(() => import(
407
- /* webpackChunkName: "pivot-report-editor" */
408
- "./ReportEditor-D4V0ry2B.mjs"
409
- ).then((t) => ({
410
- default: t.ReportEditor
411
- }))), pn = (t) => /* @__PURE__ */ e.createElement(e.Suspense, { fallback: /* @__PURE__ */ e.createElement("div", { role: "status", style: { padding: "16px" } }, "Loading report builder…") }, /* @__PURE__ */ e.createElement(un, { ...t }));
412
- function Kt({
413
- availableFields: t,
414
- customDimensions: n,
415
- setCustomDimensions: s,
416
- data: a,
417
- theme: l,
418
- showNotification: g,
419
- getFieldLabel: u,
420
- onDeleteField: E
421
- }) {
422
- const d = e.useMemo(
423
- () => (t || []).filter((o) => o && !tr(o)),
424
- [t]
425
- ), $ = e.useMemo(
426
- () => Fe(n || []),
427
- [n]
428
- ), [i, m] = e.useState(null), T = e.useMemo(
429
- () => an($, i),
430
- [i, $]
431
- ), L = e.useMemo(() => {
432
- const o = /* @__PURE__ */ new Set(), A = [];
433
- return d.forEach((R) => {
434
- R && !o.has(R) && (o.add(R), A.push(R));
435
- }), T.forEach((R) => {
436
- R && R.field && !o.has(R.field) && (o.add(R.field), A.push(R.field));
437
- }), A;
438
- }, [T, d]), _ = e.useMemo(
439
- () => {
440
- const o = qe(a, d, "date");
441
- return o.length > 0 ? o : d;
442
- },
443
- [d, a]
444
- ), D = e.useMemo(
445
- () => {
446
- const o = qe(a, d, "number");
447
- return o.length > 0 ? o : d;
448
- },
449
- [d, a]
450
- ), y = e.useMemo(
451
- () => on(a, T),
452
- [T, a]
453
- ), h = e.useMemo(() => ({
454
- border: `1px solid ${l.border}`,
455
- background: l.background,
456
- color: l.text,
457
- borderRadius: "8px",
458
- fontSize: "12px",
459
- padding: "7px 8px",
460
- outline: "none",
461
- minWidth: 0
462
- }), [l.background, l.border, l.text]), w = e.useCallback((o = "default") => ({
463
- border: o === "primary" ? `1px solid ${l.primary}` : `1px solid ${l.border}`,
464
- background: o === "primary" ? l.primary || "#2563EB" : l.hover || "#F8FAFC",
465
- color: o === "primary" ? "#fff" : l.text,
466
- borderRadius: "8px",
467
- fontSize: "11px",
468
- fontWeight: 700,
469
- padding: "6px 9px",
470
- cursor: "pointer",
471
- display: "inline-flex",
472
- alignItems: "center",
473
- gap: "5px"
474
- }), [l.border, l.hover, l.primary, l.text]);
475
- e.useEffect(() => {
476
- if (!i) return;
477
- const o = (A) => {
478
- A.key === "Escape" && (A.preventDefault(), m(null));
479
- };
480
- return window.addEventListener("keydown", o), () => window.removeEventListener("keydown", o);
481
- }, [i]);
482
- const W = e.useCallback((o, A) => {
483
- m((R) => {
484
- if (!R) return R;
485
- const B = [...R.rules || []];
486
- return B[o] = typeof A == "function" ? A(B[o]) : A, { ...R, rules: B };
487
- });
488
- }, []), O = e.useCallback((o, A, R) => {
489
- W(o, (B) => {
490
- const M = B.condition || { op: "AND", clauses: [] }, H = [...M.clauses || []];
491
- return H[A] = { ...H[A], ...R }, { ...B, condition: { ...M, clauses: H } };
492
- });
493
- }, [W]), k = e.useCallback(() => {
494
- const o = Fe([i])[0];
495
- if (!o || !o.name) {
496
- g && g("A grouped field needs a name.", "warning");
497
- return;
498
- }
499
- if (o.kind === "category" && (!o.rules || o.rules.length === 0)) {
500
- g && g("A category needs at least one valid rule.", "warning");
501
- return;
502
- }
503
- if ((o.kind === "date_group" || o.kind === "number_group") && !o.sourceField) {
504
- g && g("Choose the source field to group.", "warning");
505
- return;
506
- }
507
- const A = sr(i), R = Yt(o.name);
508
- if ($.some((M) => M && M.field !== A && Yt(M.name) === R)) {
509
- g && g(`A category named "${o.name}" already exists.`, "warning");
510
- return;
511
- }
512
- if (o.kind === "category") {
513
- const M = new Set(L);
514
- if (Zt(o).find((x) => !M.has(x))) {
515
- g && g("A category can only use base fields or categories defined before it.", "warning");
516
- return;
517
- }
518
- const K = Zt(o);
519
- if (sn(y, K)) {
520
- const x = cn(y, o).find((F) => F.count === 0);
521
- if (x) {
522
- g && g(`"${x.label}" does not match any current row. Adjust the condition before applying.`, "warning");
523
- return;
524
- }
525
- }
526
- }
527
- if (o.kind === "date_group" && !_.includes(o.sourceField)) {
528
- g && g("Choose a date field for date grouping.", "warning");
529
- return;
530
- }
531
- if (o.kind === "number_group") {
532
- if (!D.includes(o.sourceField)) {
533
- g && g("Choose a numeric field for number grouping.", "warning");
534
- return;
535
- }
536
- if (!Number.isFinite(Number(o.binSize)) || Number(o.binSize) <= 0) {
537
- g && g("Number bins need a positive bin size.", "warning");
538
- return;
539
- }
540
- }
541
- s((M) => [...Fe(M || []).filter((x) => x.id !== o.id && x.field !== o.field && x.field !== A), o]), m(null), g && g(`Applied ${o.name}.`, "success");
542
- }, [L, _, i, $, D, s, g, y]), P = e.useCallback((o) => {
543
- const A = Fe([o])[0];
544
- A && (s((R) => Fe(R || []).filter((B) => B.field !== A.field)), typeof E == "function" && E(A.field), i && i.field === A.field && m(null), g && g(`Removed ${A.name}.`, "success"));
545
- }, [i, E, s, g]);
546
- return /* @__PURE__ */ e.createElement("div", { style: {
547
- border: `1px solid ${l.border}`,
548
- background: l.headerBg || l.surfaceInset || l.background,
549
- borderRadius: "12px",
550
- padding: "10px",
551
- marginBottom: "14px",
552
- display: "flex",
553
- flexDirection: "column",
554
- gap: "10px"
555
- } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "8px" } }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", fontWeight: 800 } }, "Custom Categories"), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: l.textSec, marginTop: "2px" } }, "Named filter rules that become fields.")), /* @__PURE__ */ e.createElement(
556
- "button",
557
- {
558
- type: "button",
559
- onClick: () => m(jt(L)),
560
- style: w("primary")
561
- },
562
- "+ Category"
563
- )), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
564
- "button",
565
- {
566
- type: "button",
567
- onClick: () => m(nn(d, a)),
568
- disabled: _.length === 0,
569
- style: { ...w(), opacity: _.length === 0 ? 0.5 : 1, cursor: _.length === 0 ? "not-allowed" : "pointer" },
570
- title: _.length === 0 ? "No date fields detected" : "Create date buckets"
571
- },
572
- /* @__PURE__ */ e.createElement(z.Group, null),
573
- " Date Group"
574
- ), /* @__PURE__ */ e.createElement(
575
- "button",
576
- {
577
- type: "button",
578
- onClick: () => m(ln(d, a)),
579
- disabled: D.length === 0,
580
- style: { ...w(), opacity: D.length === 0 ? 0.5 : 1, cursor: D.length === 0 ? "not-allowed" : "pointer" },
581
- title: D.length === 0 ? "No numeric fields detected" : "Create numeric bins"
582
- },
583
- /* @__PURE__ */ e.createElement(z.NumberFormat, null),
584
- " Number Bins"
585
- )), $.length > 0 && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } }, $.map((o) => {
586
- const A = o.kind || "category", R = A === "date_group" ? `${u(o.sourceField)} by ${o.granularity}` : A === "number_group" ? `${u(o.sourceField)} every ${o.binSize}` : `${o.rules.length} rule${o.rules.length === 1 ? "" : "s"} | fallback: ${o.fallbackLabel}`;
587
- return /* @__PURE__ */ e.createElement(
588
- "div",
589
- {
590
- key: o.field,
591
- style: {
592
- border: `1px solid ${l.border}`,
593
- background: l.background,
594
- borderRadius: "10px",
595
- padding: "8px",
596
- display: "flex",
597
- alignItems: "center",
598
- gap: "8px"
599
- }
600
- },
601
- A === "number_group" ? /* @__PURE__ */ e.createElement(z.NumberFormat, null) : /* @__PURE__ */ e.createElement(z.Branch, null),
602
- /* @__PURE__ */ e.createElement("div", { style: { minWidth: 0, flex: 1 } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "12px", fontWeight: 800, color: l.text, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, o.name), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec } }, R)),
603
- /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => m(jt(d, o)), style: w() }, /* @__PURE__ */ e.createElement(z.Edit, null), " Edit"),
604
- /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => P(o), style: { ...w(), color: "#B91C1C" } }, /* @__PURE__ */ e.createElement(z.Delete, null))
605
- );
606
- })), i && /* @__PURE__ */ e.createElement(
607
- "div",
608
- {
609
- role: "presentation",
610
- onMouseDown: (o) => {
611
- o.target === o.currentTarget && m(null);
612
- },
613
- style: {
614
- position: "fixed",
615
- inset: 0,
616
- zIndex: 1e4,
617
- background: "rgba(15, 23, 42, 0.38)",
618
- backdropFilter: "blur(4px)",
619
- display: "flex",
620
- alignItems: "center",
621
- justifyContent: "center",
622
- padding: "24px"
623
- }
624
- },
625
- /* @__PURE__ */ e.createElement(
626
- "div",
627
- {
628
- role: "dialog",
629
- "aria-modal": "true",
630
- "aria-label": i.kind === "date_group" || i.kind === "number_group" ? i.__editingField ? "Edit grouped field" : "Add grouped field" : i.__editingField ? "Edit custom category" : "Add custom category",
631
- style: {
632
- width: "min(780px, calc(100vw - 32px))",
633
- maxHeight: "calc(100vh - 48px)",
634
- border: `1px solid ${l.primary || "#2563EB"}55`,
635
- background: l.background,
636
- color: l.text,
637
- borderRadius: "16px",
638
- boxShadow: "0 24px 80px rgba(15, 23, 42, 0.28)",
639
- overflow: "hidden"
640
- }
641
- },
642
- /* @__PURE__ */ e.createElement("div", { style: {
643
- padding: "14px 16px",
644
- borderBottom: `1px solid ${l.border}`,
645
- background: l.headerBg || l.surfaceInset || l.background,
646
- display: "flex",
647
- alignItems: "center",
648
- justifyContent: "space-between",
649
- gap: "12px"
650
- } }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "13px", fontWeight: 900, color: l.text } }, i.kind === "date_group" || i.kind === "number_group" ? i.__editingField ? "Edit Grouped Field" : "Add Grouped Field" : i.__editingField ? "Edit Custom Category" : "Add Custom Category"), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: l.textSec, marginTop: "2px" } }, i.kind === "date_group" ? "Create calendar buckets from a date field." : i.kind === "number_group" ? "Create fixed-width numeric bins from a number field." : "Rules can use base fields and categories defined before this one.")), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => m(null), style: { ...w(), padding: "6px 8px" }, "aria-label": "Close category editor" }, /* @__PURE__ */ e.createElement(z.Close, null))),
651
- /* @__PURE__ */ e.createElement("div", { style: {
652
- padding: "14px",
653
- overflowY: "auto",
654
- maxHeight: "calc(100vh - 128px)",
655
- display: "flex",
656
- flexDirection: "column",
657
- gap: "10px"
658
- } }, /* @__PURE__ */ e.createElement("div", { style: { display: "grid", gridTemplateColumns: "1fr 120px 150px", gap: "8px" } }, /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Category Name", /* @__PURE__ */ e.createElement(
659
- "input",
660
- {
661
- value: i.name || "",
662
- onChange: (o) => {
663
- const A = o.target.value, R = i.id || Qe(A);
664
- m({ ...i, name: A, id: R, field: i.field || et(R) });
665
- },
666
- style: h,
667
- placeholder: "Example: Priority Segment"
668
- }
669
- )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Else", /* @__PURE__ */ e.createElement(
670
- "input",
671
- {
672
- value: i.fallbackLabel || "",
673
- onChange: (o) => m({ ...i, fallbackLabel: o.target.value }),
674
- style: h,
675
- placeholder: "Other"
676
- }
677
- )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Member Order", /* @__PURE__ */ e.createElement(
678
- "select",
679
- {
680
- value: i.order || "creation",
681
- onChange: (o) => m({ ...i, order: o.target.value }),
682
- style: h
683
- },
684
- /* @__PURE__ */ e.createElement("option", { value: "creation" }, "Creation Order"),
685
- /* @__PURE__ */ e.createElement("option", { value: "alpha" }, "Alphabetical (A→Z)"),
686
- /* @__PURE__ */ e.createElement("option", { value: "alpha_desc" }, "Alphabetical (Z→A)"),
687
- /* @__PURE__ */ e.createElement("option", { value: "numeric" }, "Numeric (0→9)"),
688
- /* @__PURE__ */ e.createElement("option", { value: "numeric_desc" }, "Numeric (9→0)")
689
- ))), i.kind === "date_group" && /* @__PURE__ */ e.createElement("div", { style: {
690
- border: `1px solid ${l.border}`,
691
- borderRadius: "10px",
692
- padding: "10px",
693
- background: l.hover || "#F8FAFC",
694
- display: "grid",
695
- gridTemplateColumns: "1.4fr 1fr 1fr",
696
- gap: "8px"
697
- } }, /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Date Field", /* @__PURE__ */ e.createElement(
698
- "select",
699
- {
700
- value: i.sourceField || "",
701
- onChange: (o) => m({
702
- ...i,
703
- sourceField: o.target.value,
704
- name: i.__isNew ? `${u(o.target.value)} ${fe(i.granularity || "month")}` : i.name
705
- }),
706
- style: h
707
- },
708
- _.map((o) => /* @__PURE__ */ e.createElement("option", { key: o, value: o }, u(o)))
709
- )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Date Part", /* @__PURE__ */ e.createElement(
710
- "select",
711
- {
712
- value: i.granularity || "month",
713
- onChange: (o) => m({ ...i, granularity: o.target.value }),
714
- style: h
715
- },
716
- Array.from(Zr).map((o) => /* @__PURE__ */ e.createElement("option", { key: o, value: o }, fe(o)))
717
- )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Fiscal Start", /* @__PURE__ */ e.createElement(
718
- "select",
719
- {
720
- value: i.fiscalYearStartMonth || 1,
721
- onChange: (o) => m({ ...i, fiscalYearStartMonth: Number(o.target.value) }),
722
- style: h
723
- },
724
- ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].map((o, A) => /* @__PURE__ */ e.createElement("option", { key: o, value: A + 1 }, o))
725
- ))), i.kind === "number_group" && /* @__PURE__ */ e.createElement("div", { style: {
726
- border: `1px solid ${l.border}`,
727
- borderRadius: "10px",
728
- padding: "10px",
729
- background: l.hover || "#F8FAFC",
730
- display: "grid",
731
- gridTemplateColumns: "1.4fr 0.8fr 0.8fr 0.8fr 0.7fr",
732
- gap: "8px"
733
- } }, /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Number Field", /* @__PURE__ */ e.createElement(
734
- "select",
735
- {
736
- value: i.sourceField || "",
737
- onChange: (o) => m({
738
- ...i,
739
- sourceField: o.target.value,
740
- name: i.__isNew ? `${u(o.target.value)} Bins` : i.name
741
- }),
742
- style: h
743
- },
744
- D.map((o) => /* @__PURE__ */ e.createElement("option", { key: o, value: o }, u(o)))
745
- )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Bin Size", /* @__PURE__ */ e.createElement(
746
- "input",
747
- {
748
- type: "number",
749
- value: i.binSize === void 0 ? "" : i.binSize,
750
- onChange: (o) => m({ ...i, binSize: o.target.value }),
751
- style: h
752
- }
753
- )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Min", /* @__PURE__ */ e.createElement(
754
- "input",
755
- {
756
- type: "number",
757
- value: i.minValue === null || i.minValue === void 0 ? "" : i.minValue,
758
- onChange: (o) => m({ ...i, minValue: o.target.value }),
759
- style: h
760
- }
761
- )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Max", /* @__PURE__ */ e.createElement(
762
- "input",
763
- {
764
- type: "number",
765
- value: i.maxValue === null || i.maxValue === void 0 ? "" : i.maxValue,
766
- onChange: (o) => m({ ...i, maxValue: o.target.value }),
767
- style: h
768
- }
769
- )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Decimals", /* @__PURE__ */ e.createElement(
770
- "input",
771
- {
772
- type: "number",
773
- min: "0",
774
- max: "8",
775
- value: i.precision === null || i.precision === void 0 ? "" : i.precision,
776
- onChange: (o) => m({ ...i, precision: o.target.value }),
777
- style: h
778
- }
779
- ))), (!i.kind || i.kind === "category") && (i.rules || []).map((o, A) => {
780
- const R = o.condition || { op: "AND", clauses: [] }, B = R.clauses || [];
781
- return /* @__PURE__ */ e.createElement("div", { key: o.id || A, style: {
782
- border: `1px solid ${l.border}`,
783
- borderRadius: "10px",
784
- padding: "8px",
785
- background: l.hover || "#F8FAFC",
786
- display: "flex",
787
- flexDirection: "column",
788
- gap: "8px"
789
- } }, /* @__PURE__ */ e.createElement("div", { style: { display: "grid", gridTemplateColumns: "1fr 78px 28px", gap: "8px", alignItems: "center" } }, /* @__PURE__ */ e.createElement(
790
- "input",
791
- {
792
- value: o.label || "",
793
- onChange: (M) => W(A, { ...o, label: M.target.value }),
794
- style: h,
795
- placeholder: "Category value"
796
- }
797
- ), /* @__PURE__ */ e.createElement(
798
- "select",
799
- {
800
- value: R.op || "AND",
801
- onChange: (M) => W(A, { ...o, condition: { ...R, op: M.target.value } }),
802
- style: h
803
- },
804
- /* @__PURE__ */ e.createElement("option", { value: "AND" }, "AND"),
805
- /* @__PURE__ */ e.createElement("option", { value: "OR" }, "OR")
806
- ), /* @__PURE__ */ e.createElement(
807
- "button",
808
- {
809
- type: "button",
810
- onClick: () => m({ ...i, rules: (i.rules || []).filter((M, H) => H !== A) }),
811
- style: { ...w(), padding: "6px", justifyContent: "center", color: "#B91C1C" },
812
- title: "Remove rule"
813
- },
814
- /* @__PURE__ */ e.createElement(z.Close, null)
815
- )), B.map((M, H) => {
816
- const K = tn.has(M.operator), x = Ut.has(M.operator);
817
- return /* @__PURE__ */ e.createElement("div", { key: `${o.id || A}:${H}`, style: { display: "grid", gridTemplateColumns: K ? "1fr 130px 28px" : "1fr 130px 1fr 28px", gap: "6px", alignItems: "center" } }, /* @__PURE__ */ e.createElement(
818
- "select",
819
- {
820
- value: M.field || "",
821
- onChange: (F) => O(A, H, { field: F.target.value }),
822
- style: h
823
- },
824
- L.map((F) => /* @__PURE__ */ e.createElement("option", { key: F, value: F }, u(F)))
825
- ), /* @__PURE__ */ e.createElement(
826
- "select",
827
- {
828
- value: M.operator || "eq",
829
- onChange: (F) => {
830
- const v = F.target.value;
831
- O(A, H, {
832
- operator: v,
833
- values: Ut.has(v) ? M.values && M.values.length ? M.values : Vt(M.value) : M.values
834
- });
835
- },
836
- style: h
837
- },
838
- en.map((F) => /* @__PURE__ */ e.createElement("option", { key: F.value, value: F.value }, F.label))
839
- ), !K && /* @__PURE__ */ e.createElement(
840
- "input",
841
- {
842
- value: x ? (M.values || []).join(", ") : M.value || "",
843
- onChange: (F) => O(A, H, x ? { values: Vt(F.target.value), value: F.target.value } : { value: F.target.value }),
844
- style: h,
845
- placeholder: x ? "A, B, C" : "Value"
846
- }
847
- ), /* @__PURE__ */ e.createElement(
848
- "button",
849
- {
850
- type: "button",
851
- onClick: () => W(A, {
852
- ...o,
853
- condition: {
854
- ...R,
855
- clauses: B.filter((F, v) => v !== H)
856
- }
857
- }),
858
- style: { ...w(), padding: "6px", justifyContent: "center", color: "#B91C1C" },
859
- title: "Remove condition"
860
- },
861
- /* @__PURE__ */ e.createElement(z.Close, null)
862
- ));
863
- }), /* @__PURE__ */ e.createElement(
864
- "button",
865
- {
866
- type: "button",
867
- onClick: () => W(A, {
868
- ...o,
869
- condition: {
870
- ...R,
871
- clauses: [...B, or(L)]
872
- }
873
- }),
874
- style: { ...w(), alignSelf: "flex-start" }
875
- },
876
- "+ Condition"
877
- ));
878
- }), (!i.kind || i.kind === "category") && /* @__PURE__ */ e.createElement(
879
- "button",
880
- {
881
- type: "button",
882
- onClick: () => m({
883
- ...i,
884
- rules: [...i.rules || [], ir(L, (i.rules || []).length)]
885
- }),
886
- style: { ...w(), alignSelf: "flex-start" }
887
- },
888
- "+ Rule"
889
- ), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", justifyContent: "flex-end", gap: "8px" } }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => m(null), style: w() }, "Cancel"), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: k, style: w("primary") }, i.kind === "date_group" || i.kind === "number_group" ? "Apply Group" : "Apply Category")))
890
- )
891
- ));
892
- }
893
- function cr(t) {
894
- const n = [], s = /* @__PURE__ */ new Set();
895
- return String(t || "").replace(tt, (a, l) => {
896
- const g = String(l || "").trim();
897
- return g && !s.has(g) && (n.push(g), s.add(g)), "";
898
- }), n;
899
- }
900
- function Gt(t, n = []) {
901
- const s = String(t || ""), a = [], l = /* @__PURE__ */ new Set(), g = (d) => {
902
- const $ = String(d || "").trim();
903
- !$ || l.has($) || (a.push($), l.add($));
904
- };
905
- cr(s).forEach(g);
906
- let u = s.replace(tt, " ");
907
- return (Array.isArray(n) ? n : Array.from(n || [])).map((d) => String(d || "").trim()).filter((d) => d && !lr.test(d)).sort((d, $) => $.length - d.length).forEach((d) => {
908
- const $ = new RegExp(`(^|[^A-Za-z0-9_])${ar(d)}(?=$|[^A-Za-z0-9_])`, "g");
909
- u = u.replace($, (i, m) => (g(d), `${m} `));
910
- }), u.replace(nr, (d, $) => {
911
- const i = u.slice($ + d.length).trimStart();
912
- return Qr.has(d) || qr.has(d) && i.startsWith("(") || g(d), d;
913
- }), a;
914
- }
915
- function le(t) {
916
- const n = String(t || "").trim();
917
- return n ? `[${n}]` : "";
918
- }
919
- function ye(t) {
920
- const n = String(t || "").trim();
921
- return n ? lr.test(n) ? n : `[${n}]` : "";
922
- }
923
- function dn(t, n, s = "formula") {
924
- const a = ve(t, s), l = new Set(
925
- (Array.isArray(n) ? n : []).map((E) => E ? E.agg === "formula" ? N(E) : E.field : null).filter(Boolean).map((E) => String(E).toLowerCase())
926
- );
927
- if (!l.has(a)) return a;
928
- let g = 2, u = `${a}${g}`;
929
- for (; l.has(u); )
930
- g += 1, u = `${a}${g}`;
931
- return u;
932
- }
933
- function fn(t, n, s) {
934
- if (!t || !n || n === s) return t;
935
- const a = ye(s), l = [];
936
- let u = String(t).replace(tt, (E, d) => String(d || "").trim() === n ? a : (l.push(E), `@@${l.length - 1}@@`)).replace(new RegExp(`\\b${ar(n)}\\b`, "g"), a);
937
- return l.forEach((E, d) => {
938
- u = u.replace(`@@${d}@@`, E);
939
- }), u;
940
- }
941
- function yt(t, n, s) {
942
- t((a) => {
943
- const l = [...a];
944
- return l[n] ? (l[n] = s(l[n]), l) : a;
945
- });
946
- }
947
- function Nt(t) {
948
- return !t || typeof t.closest != "function" ? !1 : !!t.closest('button, input, select, textarea, [contenteditable="true"]');
949
- }
950
- function gn(t) {
951
- if (!t || typeof t != "object") return "";
952
- const n = t.field === void 0 || t.field === null ? "" : String(t.field), s = t.agg === void 0 || t.agg === null ? "" : String(t.agg);
953
- return `${n}::${s}`;
954
- }
955
- function bt(t) {
956
- const n = Xr(t);
957
- return n ? {
958
- ...Ee,
959
- ...n,
960
- header: n.header || "",
961
- color: n.color || "",
962
- positiveColor: n.positiveColor || "",
963
- negativeColor: n.negativeColor || ""
964
- } : null;
965
- }
966
- function mn(t) {
967
- const n = {
968
- ...Ee,
969
- ...t || {}
970
- }, s = {
971
- type: n.type || Ee.type,
972
- metric: n.metric || Ee.metric,
973
- showCurrentValue: n.showCurrentValue !== !1,
974
- showDelta: n.showDelta !== !1,
975
- compact: !!n.compact,
976
- hideColumns: !!n.hideColumns,
977
- placement: "before",
978
- source: n.source === "field" ? "field" : "pivot",
979
- displayMode: n.displayMode === "value" ? "value" : "trend"
980
- };
981
- return ["header", "color", "positiveColor", "negativeColor"].forEach((a) => {
982
- const l = typeof n[a] == "string" ? n[a].trim() : "";
983
- l && (s[a] = l);
984
- }), Number.isFinite(Number(n.areaOpacity)) && (s.areaOpacity = Math.max(0.02, Math.min(0.45, Number(n.areaOpacity)))), s;
985
- }
986
- function ur(t, n = []) {
987
- const s = String(t && t.agg || "").trim().toLowerCase(), a = Array.isArray(n) && n.length > 0, l = s === "array_agg", g = s !== "array_agg" && a;
988
- return {
989
- canUseFieldSeries: l,
990
- canUsePivotSeries: g,
991
- canUseAny: l || g,
992
- defaultSource: l ? "field" : g ? "pivot" : null
993
- };
994
- }
995
- function vt(t, n) {
996
- return !n || !n.canUseAny ? !1 : t === "field" ? n.canUseFieldSeries : n.canUsePivotSeries;
997
- }
998
- function pr(t, n) {
999
- const s = mn(t);
1000
- return !n || !n.canUseAny ? null : vt(s.source, n) ? s : {
1001
- ...s,
1002
- source: n.defaultSource
1003
- };
1004
- }
1005
- function Et(t) {
1006
- if (!Array.isArray(t) || t.length === 0) return "";
1007
- const n = t.map((s) => s && ye(s.field)).filter(Boolean);
1008
- return n.length === 0 ? "" : n.length === 1 ? `${n[0]} * 100` : `${n[0]} - ${n[1]}`;
1009
- }
1010
- function Xt(t) {
1011
- const n = (Array.isArray(t) ? t : []).map((s) => s && s.id).filter(Boolean);
1012
- return n.length === 0 ? "" : n.length === 1 ? `${le(n[0])} * 100` : `${le(n[0])} - ${le(n[1])}`;
1013
- }
1014
- function xn(t) {
1015
- const n = new Set(
1016
- (Array.isArray(t) ? t : []).map((a) => a && a.field).filter(Boolean)
1017
- );
1018
- let s = 1;
1019
- for (; n.has(`formula_${s}`); ) s += 1;
1020
- return `formula_${s}`;
1021
- }
1022
- function yn(t, n, s = null, a = null, l = "measures", g = [], u = []) {
1023
- const E = String(t || "").trim(), d = xe(l);
1024
- if (!E)
1025
- return {
1026
- tone: "warning",
1027
- text: d ? "Enter a formula using bracketed rendered columns. Example: [Cash Equity_day_pnl_sum] - [ETF_day_pnl_sum]" : "Enter a formula using value fields. Example: sales - [day pnl]"
1028
- };
1029
- let $ = 0;
1030
- for (const k of E)
1031
- if (k === "(" && ($ += 1), k === ")" && ($ -= 1), $ < 0)
1032
- return { tone: "warning", text: "Parentheses are unbalanced." };
1033
- if ($ !== 0)
1034
- return { tone: "warning", text: "Parentheses are unbalanced." };
1035
- if (d) {
1036
- const k = Array.isArray(g) ? g : [], P = new Set(
1037
- k.map((B) => B && B.id).filter(Boolean)
1038
- ), o = cr(E);
1039
- if (o.length === 0)
1040
- return {
1041
- tone: "warning",
1042
- text: "Insert at least one rendered column reference like [column_id]."
1043
- };
1044
- const A = E.replace(tt, ""), R = Array.from(new Set(A.match(nr) || []));
1045
- if (R.length > 0)
1046
- return {
1047
- tone: "warning",
1048
- text: `Rendered columns must use brackets: ${R.join(", ")}`
1049
- };
1050
- if (P.size > 0) {
1051
- const B = o.filter((M) => !P.has(M));
1052
- if (B.length > 0)
1053
- return {
1054
- tone: "warning",
1055
- text: `Unknown rendered columns: ${B.join(", ")}`
1056
- };
1057
- }
1058
- return s && o.includes(s) ? {
1059
- tone: "warning",
1060
- text: "A displayed-column formula cannot reference its own output column."
1061
- } : {
1062
- tone: "success",
1063
- text: `Using rendered columns: ${o.join(", ")}`
1064
- };
1065
- }
1066
- const i = Array.isArray(n) ? n.filter((k) => k && k.field) : [];
1067
- if (i.length === 0)
1068
- return {
1069
- tone: "warning",
1070
- text: "Add at least one value or formula reference before creating formulas."
1071
- };
1072
- const m = i.filter((k) => k.agg === "formula"), T = /* @__PURE__ */ new Map();
1073
- m.forEach((k) => {
1074
- const P = k.field === s ? ve(a || N(k), k.field) : N(k);
1075
- P && (T.set(P, P), T.set(P.toLowerCase(), P));
1076
- });
1077
- const L = i.filter((k) => k.agg !== "formula").map((k) => k.field).filter(Boolean), _ = new Set(L), D = /* @__PURE__ */ new Set([...L, ...m.map((k) => k.field === s ? ve(a || N(k), k.field) : N(k)).filter(Boolean), ...Array.isArray(u) ? u : []]), y = Array.from(D), h = Gt(E, y), w = h.map((k) => T.get(k) || T.get(k.toLowerCase()) || k), W = w.filter((k) => !D.has(k) && !_.has(k));
1078
- if (W.length > 0)
1079
- return {
1080
- tone: "warning",
1081
- text: `Unknown fields: ${W.join(", ")}`
1082
- };
1083
- const O = s ? ve(a || s, s) : null;
1084
- if (s && O && i.some((P) => {
1085
- if (!P || P.field === s) return !1;
1086
- const o = P.agg === "formula" ? N(P) : P.field;
1087
- return String(o || "").toLowerCase() === O.toLowerCase();
1088
- }))
1089
- return {
1090
- tone: "warning",
1091
- text: `Reference key "${O}" is already in use.`
1092
- };
1093
- if (O && w.includes(O))
1094
- return {
1095
- tone: "warning",
1096
- text: "A formula cannot reference itself."
1097
- };
1098
- if (s && O) {
1099
- const k = {};
1100
- m.forEach((R) => {
1101
- const B = R.field === s ? O : N(R), M = R.field === s ? E : String(R.formula || ""), H = Gt(M, y).map((K) => T.get(K) || T.get(K.toLowerCase()) || K).filter((K) => K !== B && m.some((x) => N(x) === K || x.field === s && O === K));
1102
- k[B] = H;
1103
- });
1104
- const P = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), A = (R) => {
1105
- if (P.has(R)) return !0;
1106
- if (o.has(R)) return !1;
1107
- P.add(R);
1108
- const B = k[R] || [];
1109
- for (const M of B)
1110
- if (A(M)) return !0;
1111
- return P.delete(R), o.add(R), !1;
1112
- };
1113
- if (A(O))
1114
- return {
1115
- tone: "warning",
1116
- text: "Circular formula reference detected."
1117
- };
1118
- }
1119
- return h.length === 0 ? {
1120
- tone: "warning",
1121
- text: "Insert at least one measure or formula reference."
1122
- } : {
1123
- tone: "success",
1124
- text: `Using ${w.join(", ")}`
1125
- };
1126
- }
1127
- function bn(t) {
1128
- if (!Array.isArray(t) || t.length === 0) return [];
1129
- const n = t.map((s) => s && ye(s.field)).filter(Boolean);
1130
- return n.length === 0 ? [] : n.length === 1 ? [{ label: "Scale x100", value: `${n[0]} * 100` }] : [
1131
- { label: "Difference", value: `${n[0]} - ${n[1]}` },
1132
- { label: "Ratio %", value: `(${n[0]} / ${n[1]}) * 100` },
1133
- { label: "Margin %", value: `((${n[0]} - ${n[1]}) / ${n[0]}) * 100` }
1134
- ];
1135
- }
1136
- function En(t) {
1137
- const n = (Array.isArray(t) ? t : []).map((s) => s && s.id).filter(Boolean);
1138
- return n.length === 0 ? [] : n.length === 1 ? [{ label: "Scale x100", value: `${le(n[0])} * 100` }] : [
1139
- { label: "Difference", value: `${le(n[0])} - ${le(n[1])}` },
1140
- { label: "Ratio %", value: `(${le(n[0])} / ${le(n[1])}) * 100` },
1141
- { label: "Spread %", value: `((${le(n[0])} - ${le(n[1])}) / ${le(n[0])}) * 100` }
1142
- ];
1143
- }
1144
- function vn(t, n) {
1145
- const s = {
1146
- muted: {
1147
- text: t.textSec,
1148
- border: t.border,
1149
- background: t.headerSubtleBg || t.background
1150
- },
1151
- success: {
1152
- text: t.primary,
1153
- border: `${t.primary}33`,
1154
- background: `${t.primary}10`
1155
- },
1156
- warning: {
1157
- text: "#B45309",
1158
- border: "#F59E0B55",
1159
- background: "#F59E0B12"
1160
- }
1161
- };
1162
- return s[n] || s.muted;
1163
- }
1164
- function Sn({ item: t, idx: n, setValConfigs: s, theme: a, colFields: l = [], onClose: g }) {
1165
- const u = e.useMemo(
1166
- () => bt(t && t.sparkline) || { ...Ee },
1167
- // eslint-disable-next-line react-hooks/exhaustive-deps
1168
- [t && t.sparkline]
1169
- ), E = e.useMemo(
1170
- () => ur(t, l),
1171
- [l, t]
1172
- ), d = e.useMemo(() => {
1173
- const y = [];
1174
- return E.canUsePivotSeries && y.push({ value: "pivot", label: "Linked pivot" }), E.canUseFieldSeries && y.push({ value: "field", label: "Series field" }), y;
1175
- }, [E]), $ = vt(u.source || "pivot", E) ? u.source || "pivot" : E.defaultSource, i = e.useCallback((y) => {
1176
- yt(s, n, (h) => {
1177
- const w = bt(h.sparkline) || { ...Ee }, W = pr({ ...w, ...y }, E);
1178
- return W ? {
1179
- ...h,
1180
- sparkline: W
1181
- } : h;
1182
- });
1183
- }, [E, n, s]), m = e.useCallback((y) => y.stopPropagation(), []), T = [
1184
- { value: "line", label: "Line" },
1185
- { value: "area", label: "Area" },
1186
- { value: "column", label: "Column" },
1187
- { value: "bar", label: "Bar" }
1188
- ], L = {
1189
- background: a.background,
1190
- border: `1px solid ${a.border}`,
1191
- borderRadius: "5px",
1192
- color: a.text,
1193
- fontSize: "11px",
1194
- padding: "4px 7px",
1195
- outline: "none",
1196
- width: "100%",
1197
- boxSizing: "border-box"
1198
- }, _ = {
1199
- fontSize: "10px",
1200
- fontWeight: 700,
1201
- letterSpacing: "0.06em",
1202
- color: a.textSec,
1203
- textTransform: "uppercase",
1204
- marginBottom: "6px",
1205
- display: "block"
1206
- }, D = {
1207
- marginBottom: "14px"
1208
- };
1209
- return /* @__PURE__ */ e.createElement(
1210
- "div",
1211
- {
1212
- style: { position: "fixed", inset: 0, background: "rgba(0,0,0,0.45)", zIndex: 9999, display: "flex", alignItems: "center", justifyContent: "center" },
1213
- onMouseDown: m,
1214
- onClick: g
1215
- },
1216
- /* @__PURE__ */ e.createElement(
1217
- "div",
1218
- {
1219
- onClick: m,
1220
- style: {
1221
- background: a.background,
1222
- border: `1px solid ${a.border}`,
1223
- borderRadius: "12px",
1224
- boxShadow: "0 8px 32px rgba(0,0,0,0.22)",
1225
- width: "320px",
1226
- maxHeight: "80vh",
1227
- overflow: "auto",
1228
- padding: "18px 20px 16px",
1229
- fontFamily: "'Inter', ui-sans-serif, system-ui, sans-serif"
1230
- }
1231
- },
1232
- /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: "16px" } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "13px", fontWeight: 700, color: a.text } }, "Sparkline Column"), /* @__PURE__ */ e.createElement(
1233
- "button",
1234
- {
1235
- type: "button",
1236
- onClick: g,
1237
- style: { background: "none", border: "none", cursor: "pointer", color: a.textSec, fontSize: "18px", lineHeight: 1, padding: "2px 4px" }
1238
- },
1239
- "×"
1240
- )),
1241
- /* @__PURE__ */ e.createElement("div", { style: D }, /* @__PURE__ */ e.createElement("span", { style: _ }, "Data source"), d.length > 0 ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px" } }, d.map(({ value: y, label: h }) => /* @__PURE__ */ e.createElement(
1242
- "button",
1243
- {
1244
- key: y,
1245
- type: "button",
1246
- onClick: () => i({ source: y }),
1247
- style: {
1248
- flex: 1,
1249
- padding: "4px 0",
1250
- fontSize: "11px",
1251
- fontWeight: 600,
1252
- borderRadius: "6px",
1253
- cursor: "pointer",
1254
- border: `1px solid ${$ === y ? a.primary : a.border}`,
1255
- background: $ === y ? `${a.primary}18` : a.headerSubtleBg || a.background,
1256
- color: $ === y ? a.primary : a.textSec
1257
- }
1258
- },
1259
- h
1260
- ))), /* @__PURE__ */ e.createElement("div", { style: { marginTop: "5px", fontSize: "10px", color: a.textSec, lineHeight: 1.4 } }, $ === "pivot" ? "Trend values are collected across the pivot columns. Source value cells stay numeric unless hidden." : "Each cell already contains the full data series for its row.")) : /* @__PURE__ */ e.createElement(
1261
- "div",
1262
- {
1263
- "data-value-sparkline-unavailable": "true",
1264
- style: {
1265
- padding: "7px 8px",
1266
- borderRadius: "6px",
1267
- border: `1px solid ${a.warning || "#F59E0B"}55`,
1268
- background: `${a.warning || "#F59E0B"}12`,
1269
- color: a.text,
1270
- fontSize: "10px",
1271
- lineHeight: 1.45
1272
- }
1273
- },
1274
- "Add a column field for linked trends, or use the Series aggregation for field data."
1275
- )),
1276
- $ === "field" && /* @__PURE__ */ e.createElement("div", { style: D }, /* @__PURE__ */ e.createElement("span", { style: _ }, "Cell display"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px" } }, [
1277
- { value: "trend", label: "Trendline" },
1278
- { value: "value", label: "Value" }
1279
- ].map(({ value: y, label: h }) => /* @__PURE__ */ e.createElement(
1280
- "button",
1281
- {
1282
- key: y,
1283
- type: "button",
1284
- onClick: () => i({ displayMode: y }),
1285
- style: {
1286
- flex: 1,
1287
- padding: "4px 0",
1288
- fontSize: "11px",
1289
- fontWeight: 600,
1290
- borderRadius: "6px",
1291
- cursor: "pointer",
1292
- border: `1px solid ${(u.displayMode || "trend") === y ? a.primary : a.border}`,
1293
- background: (u.displayMode || "trend") === y ? `${a.primary}18` : a.headerSubtleBg || a.background,
1294
- color: (u.displayMode || "trend") === y ? a.primary : a.textSec
1295
- }
1296
- },
1297
- h
1298
- ))), /* @__PURE__ */ e.createElement("div", { style: { marginTop: "5px", fontSize: "10px", color: a.textSec, lineHeight: 1.4 } }, (u.displayMode || "trend") === "value" ? "Show the selected summary metric from the series." : "Draw the series in the cell.")),
1299
- /* @__PURE__ */ e.createElement("div", { style: D }, /* @__PURE__ */ e.createElement("span", { style: _ }, "Chart type"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px" } }, T.map(({ value: y, label: h }) => /* @__PURE__ */ e.createElement(
1300
- "button",
1301
- {
1302
- key: y,
1303
- type: "button",
1304
- onClick: () => i({ type: y }),
1305
- style: {
1306
- flex: 1,
1307
- padding: "4px 0",
1308
- fontSize: "11px",
1309
- fontWeight: 600,
1310
- borderRadius: "6px",
1311
- cursor: "pointer",
1312
- border: `1px solid ${u.type === y ? a.primary : a.border}`,
1313
- background: u.type === y ? `${a.primary}18` : a.headerSubtleBg || a.background,
1314
- color: u.type === y ? a.primary : a.textSec
1315
- }
1316
- },
1317
- h
1318
- )))),
1319
- /* @__PURE__ */ e.createElement("div", { style: D }, /* @__PURE__ */ e.createElement("span", { style: _ }, "Summary metric"), /* @__PURE__ */ e.createElement(
1320
- "select",
1321
- {
1322
- value: u.metric,
1323
- onChange: (y) => i({ metric: y.target.value }),
1324
- style: { ...L, cursor: "pointer" }
1325
- },
1326
- /* @__PURE__ */ e.createElement("option", { value: "last" }, "Last value"),
1327
- /* @__PURE__ */ e.createElement("option", { value: "first" }, "First value"),
1328
- /* @__PURE__ */ e.createElement("option", { value: "min" }, "Minimum"),
1329
- /* @__PURE__ */ e.createElement("option", { value: "max" }, "Maximum"),
1330
- /* @__PURE__ */ e.createElement("option", { value: "avg" }, "Average"),
1331
- /* @__PURE__ */ e.createElement("option", { value: "sum" }, "Sum"),
1332
- /* @__PURE__ */ e.createElement("option", { value: "delta" }, "Delta (last − first)")
1333
- )),
1334
- /* @__PURE__ */ e.createElement("div", { style: D }, /* @__PURE__ */ e.createElement("span", { style: _ }, "Display"), /* @__PURE__ */ e.createElement("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: "6px" } }, [
1335
- { key: "showCurrentValue", label: "Value label" },
1336
- { key: "showDelta", label: "Delta label" },
1337
- { key: "compact", label: "Compact cell" },
1338
- { key: "hideColumns", label: "Hide source values" }
1339
- ].map(({ key: y, label: h }) => /* @__PURE__ */ e.createElement("label", { key: y, style: { display: "flex", alignItems: "center", gap: "5px", fontSize: "11px", color: a.text, cursor: "pointer", userSelect: "none" } }, /* @__PURE__ */ e.createElement(
1340
- "input",
1341
- {
1342
- type: "checkbox",
1343
- checked: !!u[y],
1344
- onChange: (w) => i({ [y]: w.target.checked }),
1345
- style: { accentColor: a.primary, width: "13px", height: "13px", cursor: "pointer" }
1346
- }
1347
- ), h))), u.hideColumns && /* @__PURE__ */ e.createElement("div", { style: { marginTop: "6px", fontSize: "10px", color: a.textSec, background: `${a.primary}10`, border: `1px solid ${a.primary}30`, borderRadius: "6px", padding: "5px 8px", lineHeight: 1.4 } }, "Source value columns are hidden; the trend column remains."), !u.hideColumns && $ === "pivot" && /* @__PURE__ */ e.createElement("div", { style: { marginTop: "6px", fontSize: "10px", color: a.textSec, background: a.headerSubtleBg || a.background, border: `1px solid ${a.border}`, borderRadius: "6px", padding: "5px 8px", lineHeight: 1.4 } }, "Source value columns stay numeric; the trend column is added beside them.")),
1348
- $ === "pivot" && /* @__PURE__ */ e.createElement("div", { style: D }, /* @__PURE__ */ e.createElement("span", { style: _ }, "Position"), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: a.textSec, lineHeight: 1.4, background: a.headerSubtleBg || a.background, border: `1px solid ${a.border}`, borderRadius: "6px", padding: "6px 8px" } }, "Trend columns are placed before the matching value columns.")),
1349
- /* @__PURE__ */ e.createElement("div", { style: D }, /* @__PURE__ */ e.createElement("span", { style: _ }, "Colors"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } }, [
1350
- { key: "color", label: "Line / fill color", always: !0 },
1351
- { key: "positiveColor", label: "Positive bar color", always: !1 },
1352
- { key: "negativeColor", label: "Negative bar color", always: !1 }
1353
- ].filter(({ always: y }) => y || u.type === "column" || u.type === "bar").map(({ key: y, label: h }) => /* @__PURE__ */ e.createElement("div", { key: y }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: a.textSec, marginBottom: "3px", display: "block" } }, h), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "5px", alignItems: "center" } }, /* @__PURE__ */ e.createElement(
1354
- "input",
1355
- {
1356
- type: "color",
1357
- value: u[y] || (y === "negativeColor" ? "#B91C1C" : y === "positiveColor" ? "#2F855A" : "#2563EB"),
1358
- onChange: (w) => i({ [y]: w.target.value }),
1359
- style: { width: "28px", height: "26px", padding: "1px 2px", border: `1px solid ${a.border}`, borderRadius: "4px", cursor: "pointer", background: "none" }
1360
- }
1361
- ), /* @__PURE__ */ e.createElement(
1362
- "input",
1363
- {
1364
- type: "text",
1365
- value: u[y] || "",
1366
- onChange: (w) => i({ [y]: w.target.value }),
1367
- placeholder: "Auto",
1368
- style: { ...L, flex: 1 }
1369
- }
1370
- ), u[y] && /* @__PURE__ */ e.createElement(
1371
- "button",
1372
- {
1373
- type: "button",
1374
- onClick: () => i({ [y]: "" }),
1375
- style: { background: "none", border: "none", cursor: "pointer", color: a.textSec, fontSize: "14px", lineHeight: 1, padding: "2px" },
1376
- title: "Reset to auto"
1377
- },
1378
- "×"
1379
- )))))),
1380
- u.type === "area" && /* @__PURE__ */ e.createElement("div", { style: D }, /* @__PURE__ */ e.createElement("span", { style: _ }, "Area fill opacity"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px" } }, /* @__PURE__ */ e.createElement(
1381
- "input",
1382
- {
1383
- type: "range",
1384
- min: "0.02",
1385
- max: "0.45",
1386
- step: "0.01",
1387
- value: u.areaOpacity != null ? u.areaOpacity : 0.14,
1388
- onChange: (y) => i({ areaOpacity: Number(y.target.value) }),
1389
- style: { flex: 1, accentColor: a.primary }
1390
- }
1391
- ), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "11px", color: a.textSec, minWidth: "32px", textAlign: "right" } }, Math.round((u.areaOpacity != null ? u.areaOpacity : 0.14) * 100), "%"))),
1392
- /* @__PURE__ */ e.createElement("div", { style: D }, /* @__PURE__ */ e.createElement("span", { style: _ }, "Column header label"), /* @__PURE__ */ e.createElement(
1393
- "input",
1394
- {
1395
- type: "text",
1396
- value: u.header || "",
1397
- onChange: (y) => i({ header: y.target.value }),
1398
- placeholder: "Auto (e.g. Sales Trend)",
1399
- style: L
1400
- }
1401
- )),
1402
- /* @__PURE__ */ e.createElement("div", { style: { display: "flex", justifyContent: "flex-end" } }, /* @__PURE__ */ e.createElement(
1403
- "button",
1404
- {
1405
- type: "button",
1406
- onClick: g,
1407
- style: {
1408
- background: a.primary,
1409
- color: "#fff",
1410
- border: "none",
1411
- borderRadius: "7px",
1412
- padding: "6px 18px",
1413
- fontSize: "12px",
1414
- fontWeight: 700,
1415
- cursor: "pointer"
1416
- }
1417
- },
1418
- "Done"
1419
- ))
1420
- )
1421
- );
1422
- }
1423
- function dr({ item: t, idx: n, setValConfigs: s, theme: a, colFields: l = [], fixedSparklineValueKeySet: g = /* @__PURE__ */ new Set(), showNotification: u }) {
1424
- const [E, d] = e.useState(!1), $ = bt(t && t.sparkline), i = gn(t), m = !!(i && g && g.has(i)), T = e.useMemo(
1425
- () => ur(t, l),
1426
- [l, t]
1427
- ), L = !!$, _ = !!($ && vt($.source || "pivot", T)), D = e.useCallback((W) => W.stopPropagation(), []), y = e.useCallback(() => {
1428
- let W = !1;
1429
- return yt(s, n, (O) => {
1430
- const k = pr(
1431
- O.sparkline || Ee,
1432
- T
1433
- );
1434
- return k ? (W = !0, { ...O, sparkline: k }) : O;
1435
- }), W;
1436
- }, [T, n, s]), h = e.useCallback((W) => {
1437
- if (W.stopPropagation(), L) {
1438
- if (m) {
1439
- u && u("This trend is defined by the app. You can adjust its settings, but not remove it here.", "info");
1440
- return;
1441
- }
1442
- yt(s, n, (O) => ({ ...O, sparkline: !1 })), u && u("Removed trend column.", "info");
1443
- } else T.canUseAny && y() ? (d(!0), u && u("Trend column enabled.", "success")) : u && u("Trend needs a column field, or a Series aggregation for field data.", "warning");
1444
- }, [T.canUseAny, L, y, n, m, s, u]), w = e.useCallback((W) => {
1445
- if (W.stopPropagation(), !T.canUseAny) {
1446
- u && u("Trend settings are not available for this value selection.", "warning");
1447
- return;
1448
- }
1449
- y(), d(!0);
1450
- }, [T.canUseAny, y, u]);
1451
- return L ? /* @__PURE__ */ e.createElement(
1452
- "div",
1453
- {
1454
- "data-value-sparkline-controls": "true",
1455
- "data-value-sparkline-available": T.canUseAny ? "true" : "false",
1456
- "data-value-sparkline-enabled": _ ? "true" : "false",
1457
- onMouseDown: D,
1458
- onClick: D,
1459
- style: { marginTop: "6px", paddingTop: "6px", borderTop: `1px solid ${a.border}`, width: "100%", display: "flex", alignItems: "center", gap: "6px" }
1460
- },
1461
- /* @__PURE__ */ e.createElement(
1462
- "button",
1463
- {
1464
- type: "button",
1465
- "data-value-sparkline-settings": "true",
1466
- onClick: w,
1467
- style: {
1468
- border: `1px solid ${a.border}`,
1469
- background: a.headerSubtleBg || a.background,
1470
- color: a.textSec,
1471
- borderRadius: "6px",
1472
- cursor: "pointer",
1473
- padding: "3px 8px",
1474
- fontSize: "10px",
1475
- lineHeight: "16px",
1476
- fontWeight: 600,
1477
- flexShrink: 0
1478
- },
1479
- title: "Configure sparkline"
1480
- },
1481
- "Settings"
1482
- ),
1483
- m && /* @__PURE__ */ e.createElement(
1484
- "span",
1485
- {
1486
- "data-value-sparkline-fixed": "true",
1487
- style: { fontSize: "10px", color: a.textSec, flexShrink: 0 },
1488
- title: "This trend is defined by the app"
1489
- },
1490
- "App trend"
1491
- ),
1492
- !m && /* @__PURE__ */ e.createElement(
1493
- "button",
1494
- {
1495
- type: "button",
1496
- "data-value-sparkline-toggle": "true",
1497
- onClick: h,
1498
- style: {
1499
- border: `1px solid ${a.border}`,
1500
- background: a.background,
1501
- color: a.textSec,
1502
- borderRadius: "6px",
1503
- cursor: "pointer",
1504
- padding: "3px 8px",
1505
- fontSize: "10px",
1506
- lineHeight: "16px",
1507
- fontWeight: 600,
1508
- flexShrink: 0
1509
- },
1510
- title: "Remove trend"
1511
- },
1512
- "Remove Trend"
1513
- ),
1514
- _ && !E && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: a.primary, flex: 1, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, (t.sparkline && t.sparkline.source) === "field" ? `series ${(t.sparkline && t.sparkline.displayMode) === "value" ? "value" : "trend"}` : "linked pivot", " | ", ["line", "area", "column", "bar"].includes(t.sparkline && t.sparkline.type) ? t.sparkline.type : "line", " | ", t.sparkline && t.sparkline.metric || "last"),
1515
- E && /* @__PURE__ */ e.createElement(
1516
- Sn,
1517
- {
1518
- item: t,
1519
- idx: n,
1520
- setValConfigs: s,
1521
- theme: a,
1522
- colFields: l,
1523
- onClose: () => d(!1)
1524
- }
1525
- )
1526
- ) : null;
1527
- }
1528
- function Jt({ item: t, idx: n, selected: s, onSelect: a, onRemove: l, setValConfigs: g, theme: u, styles: E, dropLine: d, zoneId: $, valueSelectStyle: i, colFields: m = [], fixedSparklineValueKeySet: T = /* @__PURE__ */ new Set(), showNotification: L, serverError: _ = null }) {
1529
- const D = s ? `${u.primary}77` : _ ? "#F59E0B88" : u.border, y = s ? u.headerBg || `${u.primary}0f` : u.background || "transparent", h = String(t.formula || "").trim() || "Empty formula";
1530
- return /* @__PURE__ */ e.createElement(
1531
- "div",
1532
- {
1533
- onClick: () => a(t.field),
1534
- style: {
1535
- ...E.chip,
1536
- border: `1px solid ${D}`,
1537
- background: y,
1538
- borderLeft: s ? `3px solid ${u.primary}` : "3px solid transparent",
1539
- boxShadow: "none",
1540
- cursor: "pointer",
1541
- flexWrap: "wrap",
1542
- alignItems: "flex-start"
1543
- },
1544
- title: "Select formula"
1545
- },
1546
- d && d.zone === $ && d.idx === n && /* @__PURE__ */ e.createElement("div", { style: { ...E.dropLine, top: -2 } }),
1547
- /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", minWidth: 0, flex: 1 } }, /* @__PURE__ */ e.createElement(z.DragIndicator, null), /* @__PURE__ */ e.createElement("span", { style: {
1548
- fontSize: "10px",
1549
- fontWeight: 700,
1550
- color: u.primary,
1551
- background: `${u.primary}18`,
1552
- borderRadius: "999px",
1553
- padding: "3px 7px",
1554
- letterSpacing: "0.5px",
1555
- flexShrink: 0
1556
- } }, "fx"), /* @__PURE__ */ e.createElement("div", { style: { minWidth: 0, flex: 1 } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", minWidth: 0 } }, /* @__PURE__ */ e.createElement("b", { style: { fontWeight: 600, display: "block", minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, t.label || "Formula"), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: u.textSec, fontFamily: "monospace", flexShrink: 0 } }, N(t)), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "9px", color: u.textSec, border: `1px solid ${u.border}`, borderRadius: "999px", padding: "1px 6px", flexShrink: 0 } }, xe(t.formulaScope) ? "columns" : "values")), /* @__PURE__ */ e.createElement("div", { style: {
1557
- marginTop: "2px",
1558
- fontSize: "10px",
1559
- lineHeight: 1.35,
1560
- color: u.textSec,
1561
- fontFamily: "monospace",
1562
- whiteSpace: "nowrap",
1563
- overflow: "hidden",
1564
- textOverflow: "ellipsis"
1565
- } }, "=", h), _ && /* @__PURE__ */ e.createElement("div", { style: { marginTop: "2px", fontSize: "9px", color: "#B45309" } }, "⚠ ", hn[_] || _))),
1566
- /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", marginLeft: "8px", alignItems: "center", flexShrink: 0 } }, s && /* @__PURE__ */ e.createElement("span", { style: {
1567
- fontSize: "9px",
1568
- color: u.primary,
1569
- background: `${u.primary}14`,
1570
- borderRadius: "999px",
1571
- padding: "2px 6px",
1572
- flexShrink: 0
1573
- } }, "Active"), /* @__PURE__ */ e.createElement(
1574
- "span",
1575
- {
1576
- onClick: (w) => {
1577
- w.stopPropagation(), l(n);
1578
- },
1579
- style: { cursor: "pointer", color: "#9CA3AF", display: "flex", alignItems: "center" }
1580
- },
1581
- /* @__PURE__ */ e.createElement(z.Close, null)
1582
- )),
1583
- /* @__PURE__ */ e.createElement(
1584
- dr,
1585
- {
1586
- item: t,
1587
- idx: n,
1588
- setValConfigs: g,
1589
- theme: u,
1590
- valueSelectStyle: i,
1591
- colFields: m,
1592
- fixedSparklineValueKeySet: T,
1593
- showNotification: L
1594
- }
1595
- ),
1596
- d && d.zone === $ && d.idx === n + 1 && /* @__PURE__ */ e.createElement("div", { style: { ...E.dropLine, bottom: -2 } })
1597
- );
1598
- }
1599
- const hn = {
1600
- self_reference: "Formula references itself (server)",
1601
- circular_reference: "Circular dependency with another formula (server)",
1602
- expression_error: "Expression could not be evaluated (server)",
1603
- missing_reference: "Unknown field reference (server)"
1604
- };
1605
- function kn({ item: t, idx: n, valConfigs: s, setValConfigs: a, theme: l, onClose: g, onRemove: u, displayedColumnOptions: E = [], availableRawFields: d = [], serverError: $ = null }) {
1606
- const i = e.useRef(null), [m, T] = e.useState({
1607
- label: t.label || "",
1608
- formula: t.formula || "",
1609
- formulaRef: N(t),
1610
- formulaScope: ze(t.formulaScope)
1611
- }), L = e.useRef(t);
1612
- L.current = t, e.useEffect(() => {
1613
- const x = L.current;
1614
- T({
1615
- label: x.label || "",
1616
- formula: x.formula || "",
1617
- formulaRef: N(x),
1618
- formulaScope: ze(x.formulaScope)
1619
- });
1620
- }, [t.field]), e.useEffect(() => {
1621
- if (!i.current) return;
1622
- i.current.focus();
1623
- const x = i.current.value.length;
1624
- i.current.setSelectionRange(x, x);
1625
- }, [t.field]);
1626
- const _ = e.useMemo(
1627
- () => s.filter((x) => x && x.field),
1628
- [s]
1629
- ), D = e.useMemo(
1630
- () => _.filter((x) => x.agg !== "formula"),
1631
- [_]
1632
- ), y = e.useMemo(
1633
- () => _.filter((x) => x.agg === "formula" && x.field !== t.field),
1634
- [t.field, _]
1635
- ), h = e.useMemo(
1636
- () => (Array.isArray(E) ? E : []).filter((x) => x && x.id && x.id !== t.field),
1637
- [E, t.field]
1638
- ), w = e.useMemo(
1639
- () => {
1640
- const x = new Set(_.map((F) => F.field).filter(Boolean));
1641
- return (Array.isArray(d) ? d : []).filter((F) => !x.has(F));
1642
- },
1643
- [d, _]
1644
- ), W = e.useMemo(
1645
- () => yn(
1646
- m.formula,
1647
- _,
1648
- t.field,
1649
- m.formulaRef,
1650
- m.formulaScope,
1651
- h,
1652
- w
1653
- ),
1654
- [h, m.formula, m.formulaRef, m.formulaScope, t.field, _, w]
1655
- ), O = e.useMemo(
1656
- () => vn(l, W.tone),
1657
- [W.tone, l]
1658
- ), k = e.useMemo(
1659
- () => xe(m.formulaScope) ? En(h) : bn(D),
1660
- [h, m.formulaScope, D]
1661
- ), P = e.useMemo(
1662
- () => xe(m.formulaScope) ? Xt(h) || "[column_id] - [other_column_id]" : Et(D) || `${ye(m.formulaRef || t.field)} * 100`,
1663
- [h, m.formulaRef, m.formulaScope, t.field, D]
1664
- ), o = m.label !== (t.label || "") || m.formula !== (t.formula || "") || m.formulaRef !== N(t) || m.formulaScope !== ze(t.formulaScope), A = e.useCallback(() => {
1665
- const x = ve(m.formulaRef, t.field);
1666
- a((F) => {
1667
- const v = [...F], U = v[n];
1668
- if (!U) return F;
1669
- const Q = N(U);
1670
- let V = x;
1671
- const ee = new Set(
1672
- v.filter((Y, te) => Y && te !== n).map((Y) => Y.agg === "formula" ? N(Y) : Y.field).filter(Boolean).map((Y) => String(Y).toLowerCase())
1673
- );
1674
- if (ee.has(V.toLowerCase())) {
1675
- let Y = 2, te = `${V}${Y}`;
1676
- for (; ee.has(te.toLowerCase()); )
1677
- Y += 1, te = `${V}${Y}`;
1678
- V = te;
1679
- }
1680
- if (v[n] = {
1681
- ...U,
1682
- label: m.label,
1683
- formula: m.formula,
1684
- formulaRef: V,
1685
- formulaScope: m.formulaScope
1686
- }, Q && Q !== V)
1687
- for (let Y = 0; Y < v.length; Y += 1) {
1688
- if (Y === n) continue;
1689
- const te = v[Y];
1690
- !te || te.agg !== "formula" || !te.formula || (v[Y] = {
1691
- ...te,
1692
- formula: fn(te.formula, Q, V)
1693
- });
1694
- }
1695
- return v;
1696
- });
1697
- }, [m.formula, m.formulaRef, m.formulaScope, m.label, n, t.field, a]), R = e.useCallback(() => {
1698
- T({
1699
- label: t.label || "",
1700
- formula: t.formula || "",
1701
- formulaRef: N(t),
1702
- formulaScope: ze(t.formulaScope)
1703
- }), g();
1704
- }, [t.field, t.formula, t.formulaRef, t.formulaScope, t.label, g]), B = e.useCallback((x) => {
1705
- const F = i.current;
1706
- if (!F) return;
1707
- const v = m.formula || "", U = F.selectionStart ?? v.length, Q = F.selectionEnd ?? v.length, V = `${v.slice(0, U)}${x}${v.slice(Q)}`;
1708
- T((Y) => ({ ...Y, formula: V }));
1709
- const ee = U + x.length;
1710
- setTimeout(() => {
1711
- i.current && (i.current.focus(), i.current.setSelectionRange(ee, ee));
1712
- }, 0);
1713
- }, [m.formula]), M = e.useCallback(() => {
1714
- A(), g();
1715
- }, [A, g]), H = {
1716
- border: `1px solid ${l.border}`,
1717
- background: l.background,
1718
- color: l.text,
1719
- borderRadius: "999px",
1720
- cursor: "pointer",
1721
- padding: "3px 9px",
1722
- fontSize: "10px",
1723
- lineHeight: "16px"
1724
- }, K = {
1725
- border: `1px solid ${l.border}`,
1726
- background: l.headerSubtleBg || l.background,
1727
- color: l.text,
1728
- borderRadius: "6px",
1729
- cursor: "pointer",
1730
- padding: "3px 8px",
1731
- fontSize: "10px",
1732
- lineHeight: "16px",
1733
- fontFamily: "monospace"
1734
- };
1735
- return /* @__PURE__ */ e.createElement(
1736
- "div",
1737
- {
1738
- onClick: R,
1739
- style: {
1740
- position: "fixed",
1741
- inset: 0,
1742
- zIndex: 10006,
1743
- background: "rgba(2, 6, 23, 0.45)",
1744
- display: "flex",
1745
- alignItems: "center",
1746
- justifyContent: "center",
1747
- padding: "24px"
1748
- }
1749
- },
1750
- /* @__PURE__ */ e.createElement(
1751
- "div",
1752
- {
1753
- onClick: (x) => x.stopPropagation(),
1754
- onKeyDown: (x) => {
1755
- x.key === "Escape" && R(), (x.ctrlKey || x.metaKey) && x.key === "Enter" && M();
1756
- },
1757
- style: {
1758
- width: "min(760px, 92vw)",
1759
- maxHeight: "80vh",
1760
- overflowY: "auto",
1761
- background: l.surfaceBg || l.background || "#fff",
1762
- border: `1px solid ${l.border}`,
1763
- borderRadius: l.radius || "16px",
1764
- boxShadow: l.shadowMd || "0 18px 40px rgba(0,0,0,0.28)",
1765
- padding: "18px"
1766
- }
1767
- },
1768
- /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "12px", marginBottom: "14px" } }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "15px", fontWeight: 800, color: l.text } }, "Formula Editor"), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: l.textSec } }, "Use a stable reference key for formulas. Renaming the key updates dependent formulas.")), /* @__PURE__ */ e.createElement(
1769
- "button",
1770
- {
1771
- type: "button",
1772
- onClick: R,
1773
- style: {
1774
- border: `1px solid ${l.border}`,
1775
- background: l.headerSubtleBg || l.background,
1776
- color: l.text,
1777
- borderRadius: "8px",
1778
- padding: "7px 10px",
1779
- fontSize: "11px",
1780
- fontWeight: 700,
1781
- cursor: "pointer"
1782
- }
1783
- },
1784
- "Close"
1785
- )),
1786
- /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "12px", flexWrap: "wrap", marginBottom: "12px" } }, /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", flex: 1, minWidth: "180px" } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px" } }, "Label"), /* @__PURE__ */ e.createElement(
1787
- "input",
1788
- {
1789
- value: m.label,
1790
- onChange: (x) => T((F) => ({ ...F, label: x.target.value })),
1791
- placeholder: "Formula label",
1792
- style: {
1793
- border: `1px solid ${l.border}`,
1794
- background: l.background,
1795
- color: l.text,
1796
- borderRadius: "8px",
1797
- padding: "8px 10px",
1798
- fontSize: "12px",
1799
- fontWeight: 600,
1800
- outline: "none"
1801
- }
1802
- }
1803
- )), /* @__PURE__ */ e.createElement("label", { style: { minWidth: "180px", flex: "0 0 auto", display: "flex", flexDirection: "column", gap: "4px" } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px" } }, "Reference key"), /* @__PURE__ */ e.createElement(
1804
- "input",
1805
- {
1806
- value: m.formulaRef,
1807
- onChange: (x) => T((F) => ({ ...F, formulaRef: ve(x.target.value, t.field) })),
1808
- placeholder: "formula1",
1809
- style: {
1810
- border: `1px solid ${l.border}`,
1811
- background: l.headerSubtleBg || l.background,
1812
- color: l.text,
1813
- borderRadius: "8px",
1814
- padding: "8px 10px",
1815
- fontSize: "12px",
1816
- fontFamily: "monospace",
1817
- outline: "none"
1818
- }
1819
- }
1820
- )), /* @__PURE__ */ e.createElement("label", { style: { minWidth: "180px", flex: "0 0 auto", display: "flex", flexDirection: "column", gap: "4px" } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px" } }, "Formula type"), /* @__PURE__ */ e.createElement(
1821
- "select",
1822
- {
1823
- value: m.formulaScope,
1824
- onChange: (x) => {
1825
- const F = ze(x.target.value);
1826
- T((v) => ({
1827
- ...v,
1828
- formulaScope: F,
1829
- formula: v.formula || (F === "columns" ? Xt(h) : Et(D))
1830
- }));
1831
- },
1832
- style: {
1833
- border: `1px solid ${l.border}`,
1834
- background: l.headerSubtleBg || l.background,
1835
- color: l.text,
1836
- borderRadius: "8px",
1837
- padding: "8px 10px",
1838
- fontSize: "12px",
1839
- outline: "none"
1840
- }
1841
- },
1842
- /* @__PURE__ */ e.createElement("option", { value: "measures" }, "Value formula"),
1843
- /* @__PURE__ */ e.createElement("option", { value: "columns" }, "Displayed columns")
1844
- ))),
1845
- /* @__PURE__ */ e.createElement("div", { style: { marginBottom: "12px" } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "4px" } }, "Formula"), /* @__PURE__ */ e.createElement(
1846
- "textarea",
1847
- {
1848
- ref: i,
1849
- value: m.formula,
1850
- onChange: (x) => T((F) => ({ ...F, formula: x.target.value })),
1851
- placeholder: P,
1852
- rows: 4,
1853
- style: {
1854
- width: "100%",
1855
- boxSizing: "border-box",
1856
- resize: "vertical",
1857
- border: `1px solid ${l.border}`,
1858
- background: l.background,
1859
- color: l.text,
1860
- borderRadius: "10px",
1861
- fontFamily: "monospace",
1862
- fontSize: "12px",
1863
- lineHeight: 1.5,
1864
- padding: "10px 12px",
1865
- outline: "none"
1866
- }
1867
- }
1868
- )),
1869
- /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "8px", flexWrap: "wrap", marginBottom: "12px" } }, /* @__PURE__ */ e.createElement("div", { style: {
1870
- padding: "5px 9px",
1871
- borderRadius: "999px",
1872
- border: `1px solid ${O.border}`,
1873
- background: O.background,
1874
- color: O.text,
1875
- fontSize: "10px",
1876
- lineHeight: "14px"
1877
- } }, W.text), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec } }, "Ctrl/Cmd + Enter applies")),
1878
- /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap", marginBottom: "12px" } }, k.map((x) => /* @__PURE__ */ e.createElement(
1879
- "button",
1880
- {
1881
- key: x.label,
1882
- type: "button",
1883
- onClick: () => T((F) => ({ ...F, formula: x.value })),
1884
- style: H
1885
- },
1886
- x.label
1887
- )), ["+", "-", "*", "/", "(", ")", "* 100"].map((x) => /* @__PURE__ */ e.createElement(
1888
- "button",
1889
- {
1890
- key: x,
1891
- type: "button",
1892
- onMouseDown: (F) => F.preventDefault(),
1893
- onClick: () => B(x),
1894
- style: K
1895
- },
1896
- x
1897
- ))),
1898
- /* @__PURE__ */ e.createElement("div", { style: { display: "grid", gridTemplateColumns: "1fr", gap: "12px", marginBottom: "14px" } }, xe(m.formulaScope) ? /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Rendered Columns"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, h.map((x) => /* @__PURE__ */ e.createElement(
1899
- "button",
1900
- {
1901
- key: x.id,
1902
- type: "button",
1903
- onMouseDown: (F) => F.preventDefault(),
1904
- onClick: () => B(le(x.id)),
1905
- style: H,
1906
- title: `Insert ${x.id}`
1907
- },
1908
- x.label || x.id
1909
- )), h.length === 0 && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "11px", color: l.textSec } }, "Render the pivot once, or type a bracketed column id directly."))) : /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Measures"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, D.map((x) => /* @__PURE__ */ e.createElement(
1910
- "button",
1911
- {
1912
- key: x.field,
1913
- type: "button",
1914
- onMouseDown: (F) => F.preventDefault(),
1915
- onClick: () => B(ye(x.field)),
1916
- style: H,
1917
- title: `Insert ${x.field}`
1918
- },
1919
- x.field
1920
- )))), !xe(m.formulaScope) && y.length > 0 && /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Formula References"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, y.map((x) => /* @__PURE__ */ e.createElement(
1921
- "button",
1922
- {
1923
- key: x.field,
1924
- type: "button",
1925
- onMouseDown: (F) => F.preventDefault(),
1926
- onClick: () => B(ye(N(x))),
1927
- style: H,
1928
- title: `${N(x)}${x.label ? ` (${x.label})` : ""}`
1929
- },
1930
- N(x)
1931
- )))), !xe(m.formulaScope) && w.length > 0 && /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Data Fields (auto-aggregated as sum)"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, w.map((x) => /* @__PURE__ */ e.createElement(
1932
- "button",
1933
- {
1934
- key: x,
1935
- type: "button",
1936
- onMouseDown: (F) => F.preventDefault(),
1937
- onClick: () => B(ye(x)),
1938
- style: { ...H, borderColor: `${l.primary}66`, color: l.primary, background: `${l.primary}0d` },
1939
- title: `Insert: ${x}`
1940
- },
1941
- fe(x)
1942
- ))))),
1943
- /* @__PURE__ */ e.createElement("div", { style: { display: "flex", justifyContent: "space-between", gap: "8px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
1944
- "button",
1945
- {
1946
- type: "button",
1947
- onClick: () => {
1948
- u(n), g();
1949
- },
1950
- style: {
1951
- border: `1px solid ${l.border}`,
1952
- background: l.background,
1953
- color: l.textSec,
1954
- borderRadius: "8px",
1955
- padding: "8px 12px",
1956
- fontSize: "11px",
1957
- fontWeight: 700,
1958
- cursor: "pointer"
1959
- }
1960
- },
1961
- "Delete Formula"
1962
- ), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
1963
- "button",
1964
- {
1965
- type: "button",
1966
- onClick: R,
1967
- style: {
1968
- border: `1px solid ${l.border}`,
1969
- background: l.background,
1970
- color: l.textSec,
1971
- borderRadius: "8px",
1972
- padding: "8px 12px",
1973
- fontSize: "11px",
1974
- fontWeight: 700,
1975
- cursor: "pointer"
1976
- }
1977
- },
1978
- "Cancel"
1979
- ), /* @__PURE__ */ e.createElement(
1980
- "button",
1981
- {
1982
- type: "button",
1983
- onClick: M,
1984
- disabled: !o,
1985
- style: {
1986
- border: `1px solid ${o ? `${l.primary}66` : l.border}`,
1987
- background: o ? `${l.primary}14` : l.background,
1988
- color: o ? l.primary : l.textSec,
1989
- borderRadius: "8px",
1990
- padding: "8px 12px",
1991
- fontSize: "11px",
1992
- fontWeight: 700,
1993
- cursor: o ? "pointer" : "default",
1994
- opacity: o ? 1 : 0.7
1995
- }
1996
- },
1997
- "Apply"
1998
- )))
1999
- )
2000
- );
2001
- }
2002
- function qt({
2003
- panelId: t,
2004
- panelLabel: n,
2005
- size: s,
2006
- onSizeChange: a,
2007
- theme: l,
2008
- outerStyle: g = {},
2009
- contentStyle: u = {},
2010
- children: E
2011
- }) {
2012
- const d = e.useRef(null), $ = e.useRef(null), i = e.useMemo(() => Kr(t), [t]), m = e.useMemo(
2013
- () => Gr(t, s),
2014
- [t, s]
2015
- ), T = e.useCallback(() => {
2016
- if ($.current) {
2017
- const D = $.current;
2018
- $.current = null, D();
2019
- }
2020
- }, []);
2021
- e.useEffect(() => (() => T()), [T]);
2022
- const L = e.useCallback((D, y) => {
2023
- if (!d.current || typeof a != "function") return;
2024
- D.preventDefault(), D.stopPropagation(), T();
2025
- const h = d.current.getBoundingClientRect(), w = d.current.parentElement ? d.current.parentElement.getBoundingClientRect() : h, W = {
2026
- startX: D.clientX,
2027
- startY: D.clientY,
2028
- startWidth: h.width,
2029
- startHeight: h.height,
2030
- maxWidth: Math.max(i.minWidth, Math.min(i.maxWidth, Math.floor(w.width)))
2031
- }, O = document.body.style.cursor, k = document.body.style.userSelect;
2032
- document.body.style.cursor = y === "both" ? "nwse-resize" : y === "width" ? "ew-resize" : "ns-resize", document.body.style.userSelect = "none";
2033
- const P = (R) => {
2034
- const B = R.clientX - W.startX, M = R.clientY - W.startY, H = y === "height" ? m.width : Math.max(i.minWidth, Math.min(W.maxWidth, Math.round(W.startWidth + B))), K = y === "width" ? m.height : Math.max(i.minHeight, Math.min(i.maxHeight, Math.round(W.startHeight + M)));
2035
- a(t, { width: H, height: K });
2036
- }, o = () => {
2037
- document.body.style.cursor = O, document.body.style.userSelect = k, window.removeEventListener("mousemove", P), window.removeEventListener("mouseup", A);
2038
- }, A = () => T();
2039
- $.current = o, window.addEventListener("mousemove", P), window.addEventListener("mouseup", A);
2040
- }, [
2041
- i.maxHeight,
2042
- i.maxWidth,
2043
- i.minHeight,
2044
- i.minWidth,
2045
- a,
2046
- t,
2047
- m.height,
2048
- m.width,
2049
- T
2050
- ]), _ = `${l.primary}55`;
2051
- return /* @__PURE__ */ e.createElement(
2052
- "div",
2053
- {
2054
- ref: d,
2055
- style: {
2056
- position: "relative",
2057
- width: m.width === null ? "100%" : `${m.width}px`,
2058
- maxWidth: "100%",
2059
- height: `${m.height}px`,
2060
- minHeight: `${i.minHeight}px`,
2061
- maxHeight: `${i.maxHeight}px`,
2062
- boxSizing: "border-box",
2063
- overflow: "hidden",
2064
- ...g
2065
- }
2066
- },
2067
- /* @__PURE__ */ e.createElement(
2068
- "div",
2069
- {
2070
- style: {
2071
- width: "100%",
2072
- height: "100%",
2073
- overflow: "auto",
2074
- boxSizing: "border-box",
2075
- ...u
2076
- }
2077
- },
2078
- E
2079
- ),
2080
- /* @__PURE__ */ e.createElement(
2081
- "div",
2082
- {
2083
- onMouseDown: (D) => L(D, "width"),
2084
- style: {
2085
- position: "absolute",
2086
- top: 0,
2087
- right: 0,
2088
- bottom: "12px",
2089
- width: "12px",
2090
- cursor: "ew-resize",
2091
- zIndex: 4,
2092
- touchAction: "none"
2093
- },
2094
- title: `Resize ${n} width`
2095
- }
2096
- ),
2097
- /* @__PURE__ */ e.createElement(
2098
- "div",
2099
- {
2100
- onMouseDown: (D) => L(D, "height"),
2101
- style: {
2102
- position: "absolute",
2103
- left: 0,
2104
- right: "12px",
2105
- bottom: 0,
2106
- height: "12px",
2107
- cursor: "ns-resize",
2108
- zIndex: 4,
2109
- touchAction: "none"
2110
- },
2111
- title: `Resize ${n} height`
2112
- }
2113
- ),
2114
- /* @__PURE__ */ e.createElement(
2115
- "div",
2116
- {
2117
- onMouseDown: (D) => L(D, "both"),
2118
- style: {
2119
- position: "absolute",
2120
- right: 0,
2121
- bottom: 0,
2122
- width: "14px",
2123
- height: "14px",
2124
- cursor: "nwse-resize",
2125
- zIndex: 5,
2126
- touchAction: "none"
2127
- },
2128
- title: `Resize ${n}`
2129
- },
2130
- /* @__PURE__ */ e.createElement(
2131
- "div",
2132
- {
2133
- style: {
2134
- position: "absolute",
2135
- right: "4px",
2136
- bottom: "4px",
2137
- width: "3px",
2138
- height: "3px",
2139
- borderRadius: "999px",
2140
- background: _,
2141
- boxShadow: `-4px 0 0 ${_}, 0 -4px 0 ${_}, -4px -4px 0 ${_}`
2142
- }
2143
- }
2144
- )
2145
- )
2146
- );
2147
- }
2148
- function Qt({ measureAxis: t, setMeasureAxis: n, theme: s, valueSelectStyle: a, regularValueCount: l }) {
2149
- const g = e.useMemo(() => Pe(t), [t]), u = e.useCallback((d) => {
2150
- typeof n == "function" && n(($) => ({
2151
- ...Pe($),
2152
- ...typeof d == "function" ? d(Pe($)) : d
2153
- }));
2154
- }, [n]), E = {
2155
- ...a,
2156
- width: "112px",
2157
- padding: "3px 6px",
2158
- fontSize: "10px"
2159
- };
2160
- return /* @__PURE__ */ e.createElement("div", { style: {
2161
- display: "flex",
2162
- alignItems: "center",
2163
- gap: "6px",
2164
- flexWrap: "wrap",
2165
- padding: "6px",
2166
- border: `1px solid ${s.border}`,
2167
- borderRadius: s.radiusSm || "6px",
2168
- background: s.surfaceInset || s.headerSubtleBg || s.background
2169
- } }, /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: s.textSec, fontWeight: 700, textTransform: "uppercase" } }, "Values as"), /* @__PURE__ */ e.createElement(
2170
- "select",
2171
- {
2172
- value: g.placement,
2173
- onChange: (d) => u({ placement: d.target.value }),
2174
- style: { ...a, width: "98px" },
2175
- title: "Values placement"
2176
- },
2177
- /* @__PURE__ */ e.createElement("option", { value: "none" }, "Columns"),
2178
- /* @__PURE__ */ e.createElement("option", { value: "rows" }, "Rows"),
2179
- /* @__PURE__ */ e.createElement("option", { value: "columns" }, "Column Axis")
2180
- ), g.placement !== "none" && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
2181
- "input",
2182
- {
2183
- value: g.labelField,
2184
- onChange: (d) => u({ labelField: d.target.value }),
2185
- style: E,
2186
- title: "Measure label field"
2187
- }
2188
- ), /* @__PURE__ */ e.createElement(
2189
- "input",
2190
- {
2191
- value: g.valueField,
2192
- onChange: (d) => u({ valueField: d.target.value }),
2193
- style: { ...E, width: "82px" },
2194
- title: "Measure value field"
2195
- }
2196
- ), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", alignItems: "center", gap: "4px", fontSize: "10px", color: s.textSec } }, /* @__PURE__ */ e.createElement(
2197
- "input",
2198
- {
2199
- type: "checkbox",
2200
- checked: g.suppressEmptyMembers,
2201
- onChange: (d) => u({ suppressEmptyMembers: d.target.checked })
2202
- }
2203
- ), "Empty"), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", alignItems: "center", gap: "4px", fontSize: "10px", color: s.textSec } }, /* @__PURE__ */ e.createElement(
2204
- "input",
2205
- {
2206
- type: "checkbox",
2207
- checked: g.suppressZeroMembers,
2208
- onChange: (d) => u({ suppressZeroMembers: d.target.checked })
2209
- }
2210
- ), "Zero")), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: s.textSec } }, l, " selected"));
2211
- }
2212
- const Fn = e.memo(function({
2213
- sidebarTab: n,
2214
- setSidebarTab: s,
2215
- rowFields: a,
2216
- setRowFields: l,
2217
- colFields: g,
2218
- setColFields: u,
2219
- valConfigs: E,
2220
- setValConfigs: d,
2221
- measureAxis: $ = {},
2222
- setMeasureAxis: i = null,
2223
- columnVisibility: m,
2224
- setColumnVisibility: T,
2225
- columnPinning: L,
2226
- setColumnPinning: _,
2227
- availableFields: D,
2228
- table: y,
2229
- pinningPresets: h,
2230
- showNotification: w,
2231
- filterAnchorEl: W,
2232
- setFilterAnchorEl: O,
2233
- colSearch: k,
2234
- setColSearch: P,
2235
- colTypeFilter: o,
2236
- setColTypeFilter: A,
2237
- selectedCols: R,
2238
- setSelectedCols: B,
2239
- dropLine: M,
2240
- onDragStart: H,
2241
- onDragOver: K,
2242
- onDrop: x,
2243
- onDragEnd: F,
2244
- onKeyboardFieldDrop: v,
2245
- handleHeaderFilter: U,
2246
- handleFilterClick: Q,
2247
- requestFilterOptions: V,
2248
- handleExpandAllRows: ee,
2249
- handlePinColumn: Y,
2250
- toggleAllColumnsPinned: te,
2251
- activeFilterCol: Cn,
2252
- closeFilterPopover: wn,
2253
- filterOptions: Me,
2254
- filterOptionMeta: Oe = {},
2255
- clientFilterOptionMap: He = {},
2256
- data: Se,
2257
- sidebarWidth: rt,
2258
- setSidebarWidth: St,
2259
- fieldPanelSizes: Ue,
2260
- setFieldPanelSizes: nt,
2261
- fixedSparklineValueKeys: lt = [],
2262
- sparklineFields: Rn = null,
2263
- displayedColumnOptions: fr = [],
2264
- reportEditorSelection: gr = null,
2265
- showReportConfigColumn: mr = !0,
2266
- setShowReportConfigColumn: xr = null,
2267
- formulaErrors: he = {},
2268
- serverSide: je = !1
2269
- }) {
2270
- Or("SidebarPanel");
2271
- const { theme: c, styles: Z } = Hr(), {
2272
- filters: ae,
2273
- setFilters: at,
2274
- pivotMode: yr,
2275
- reportDef: br,
2276
- setReportDef: Er,
2277
- savedReports: vr,
2278
- setSavedReports: Sr,
2279
- activeReportId: hr,
2280
- setActiveReportId: kr,
2281
- customDimensions: _e,
2282
- setCustomDimensions: ht
2283
- } = Ur(), [Ve, kt] = e.useState({ columnId: null, anchorEl: null }), [ke, Ce] = e.useState(null), [se, ge] = e.useState(null), [we, Cr] = e.useState("report"), Ye = e.useRef(null), [wr, Ze] = e.useState(null), pe = e.useRef(null), Ct = e.useRef(0), Ke = e.useRef(null), ce = e.useRef(null), [G, ot] = e.useState(null), [it, wt] = e.useState(""), st = e.useMemo(
2284
- () => new Set(Array.isArray(lt) ? lt : []),
2285
- [lt]
2286
- ), X = e.useCallback(
2287
- (r) => jr(r, _e),
2288
- [_e]
2289
- ), Rt = e.useMemo(
2290
- () => Pe($),
2291
- [$]
2292
- ), de = Rt.labelField || "Measure Name", Re = e.useMemo(
2293
- () => (D || []).filter((r) => r),
2294
- [D]
2295
- ), J = e.useMemo(
2296
- () => Re.filter((r) => r && !tr(r)),
2297
- [Re]
2298
- ), Te = Array.isArray(E) && E.length > 0 && de && !Re.includes(de), De = e.useMemo(
2299
- () => Te ? [de, ...Re] : Re,
2300
- [Re, de, Te]
2301
- ), We = it.trim().toLowerCase(), Ge = e.useCallback((r) => {
2302
- if (!We) return !0;
2303
- const f = Te && r === de ? "measure name measure names metric metrics value values" : "";
2304
- return String(r || "").toLowerCase().includes(We) || String(X(r) || "").toLowerCase().includes(We) || f.includes(We);
2305
- }, [X, de, We, Te]), ct = e.useMemo(
2306
- () => De.length > 8 ? De.filter(Ge) : De,
2307
- [De, Ge]
2308
- ), ut = e.useMemo(
2309
- () => J.length > 8 ? J.filter(Ge) : J,
2310
- [J, Ge]
2311
- ), Dt = e.useCallback((r) => {
2312
- l((f) => (f || []).filter((p) => p !== r)), u((f) => (f || []).filter((p) => p !== r)), d((f) => (f || []).filter((p) => !(p && p.field === r))), at((f) => {
2313
- if (!f || !Object.prototype.hasOwnProperty.call(f, r)) return f;
2314
- const p = { ...f };
2315
- return delete p[r], p;
2316
- });
2317
- }, [u, at, l, d]), Rr = e.useCallback((r) => {
2318
- const f = pe.current;
2319
- if (!f) return;
2320
- const p = 60, b = 12, S = f.getBoundingClientRect(), I = r.clientY, q = I - S.top, C = S.bottom - I;
2321
- let j = 0;
2322
- if (q < p && q >= 0 ? j = -1 : C < p && C >= 0 && (j = 1), j === 0) {
2323
- ce.current && (cancelAnimationFrame(ce.current), ce.current = null);
2324
- return;
2325
- }
2326
- const ie = () => {
2327
- pe.current && (pe.current.scrollTop += j * b, ce.current = requestAnimationFrame(ie));
2328
- };
2329
- ce.current || (ce.current = requestAnimationFrame(ie));
2330
- }, []), At = e.useCallback(() => {
2331
- ce.current && (cancelAnimationFrame(ce.current), ce.current = null);
2332
- }, []), oe = e.useMemo(
2333
- () => E.filter((r) => r && r.agg === "formula"),
2334
- [E]
2335
- ), me = e.useMemo(
2336
- () => oe.length,
2337
- [oe]
2338
- ), Ae = e.useMemo(
2339
- () => E.filter((r) => r && r.agg !== "formula").length,
2340
- [E]
2341
- ), Dr = e.useMemo(() => [
2342
- { id: "rows", label: "Rows", icon: /* @__PURE__ */ e.createElement(z.List, null) },
2343
- { id: "cols", label: "Columns", icon: /* @__PURE__ */ e.createElement(z.Columns, null) },
2344
- { id: "vals", label: "Values", icon: /* @__PURE__ */ e.createElement(z.Sigma, null) },
2345
- { id: "filter", label: "Filters", icon: /* @__PURE__ */ e.createElement(z.Filter, null) }
2346
- ], []), Be = e.useMemo(() => ({
2347
- filter: Object.keys(ae || {}).filter((r) => r !== "global"),
2348
- rows: a || [],
2349
- cols: g || [],
2350
- vals: E || []
2351
- }), [g, ae, a, E]), Ne = e.useCallback(() => {
2352
- G && w && w("Keyboard move cancelled.", "info"), ot(null);
2353
- }, [G, w]), $t = e.useCallback((r, f, p, b) => {
2354
- if (typeof v != "function") return;
2355
- ot({ field: r, zone: f, idx: p, label: b }), w && w(`Picked up ${b}. Focus a target field or zone and press Enter.`, "info");
2356
- }, [v, w]), Xe = e.useCallback((r, f = null) => {
2357
- if (!G || typeof v != "function") return !1;
2358
- const p = Be[r] || [], b = Number(f), S = Number.isFinite(b) ? Math.max(0, Math.min(Math.floor(b), p.length)) : p.length, I = v({
2359
- field: G.field,
2360
- srcZone: G.zone,
2361
- srcIdx: G.idx,
2362
- targetZone: r,
2363
- targetIdx: S,
2364
- source: "layout:keyboard-drop"
2365
- });
2366
- return I !== !1 && (w && w(`Moved ${G.label}.`, "success"), ot(null)), I !== !1;
2367
- }, [G, v, w, Be]), Ft = e.useCallback((r, f, p, b, S) => {
2368
- if (!Nt(r.target)) {
2369
- if (r.key === "Escape") {
2370
- r.preventDefault(), r.stopPropagation(), Ne();
2371
- return;
2372
- }
2373
- r.key !== "Enter" && r.key !== " " || (r.preventDefault(), r.stopPropagation(), G ? Xe(p, b) : $t(f, p, b, S));
2374
- }
2375
- }, [Ne, Xe, G, $t]), Ar = e.useCallback((r, f) => {
2376
- if (!Nt(r.target)) {
2377
- if (r.key === "Escape") {
2378
- r.preventDefault(), r.stopPropagation(), Ne();
2379
- return;
2380
- }
2381
- !G || r.key !== "Enter" && r.key !== " " || (r.preventDefault(), r.stopPropagation(), Xe(f, (Be[f] || []).length));
2382
- }
2383
- }, [Ne, Xe, G, Be]), $r = e.useCallback((r) => {
2384
- r.preventDefault();
2385
- const f = r.clientX, p = rt || 288;
2386
- Ke.current = { startX: f, startWidth: p };
2387
- const b = (I) => {
2388
- const q = I.clientX - Ke.current.startX, C = Math.max(200, Math.min(520, Ke.current.startWidth + q));
2389
- St(C);
2390
- }, S = () => {
2391
- Ke.current = null, window.removeEventListener("mousemove", b), window.removeEventListener("mouseup", S);
2392
- };
2393
- window.addEventListener("mousemove", b), window.addEventListener("mouseup", S);
2394
- }, [rt, St]), zt = e.useCallback((r, f) => {
2395
- typeof nt == "function" && nt((p) => {
2396
- const b = Vr(p, r, f), S = p && p[r] ? p[r] : null, I = b[r];
2397
- return S && S.width === I.width && S.height === I.height ? p : b;
2398
- });
2399
- }, [nt]), Mt = Z.dropZone && Z.dropZone.padding || "8px", _t = e.useMemo(() => {
2400
- const r = { ...Z.dropZone || {} };
2401
- return delete r.minHeight, delete r.maxHeight, delete r.overflowY, delete r.padding, delete r.border, delete r.boxShadow, r;
2402
- }, [Z.dropZone]), Tt = e.useCallback((r) => {
2403
- if (Me && Me[r]) return Me[r];
2404
- if (He && He[r]) return He[r];
2405
- if (!y || !y.getColumn) return [];
2406
- if (!y.getColumn(r)) return [];
2407
- const p = /* @__PURE__ */ new Set();
2408
- return (y.getCoreRowModel ? y.getCoreRowModel().rows : []).forEach((S) => {
2409
- const I = S.getValue(r);
2410
- I != null && I !== "" && p.add(I);
2411
- }), Array.from(p).sort((S, I) => String(S).localeCompare(String(I), void 0, { numeric: !0, sensitivity: "base" }));
2412
- }, [He, Me, y]), ue = e.useMemo(() => ({
2413
- border: `1px solid ${c.border}`,
2414
- background: c.headerSubtleBg || c.surfaceInset || c.background,
2415
- color: c.text,
2416
- cursor: "pointer",
2417
- borderRadius: c.radiusSm || "8px",
2418
- fontSize: "9px",
2419
- lineHeight: 1.2,
2420
- padding: "1px 4px",
2421
- minHeight: "20px",
2422
- outline: "none"
2423
- }), [c.background, c.border, c.headerSubtleBg, c.radiusSm, c.surfaceInset, c.text]), Wt = e.useCallback((r, f) => {
2424
- d((p) => {
2425
- const b = [...p], S = b[r];
2426
- if (!S) return p;
2427
- if (Ht(f) && !S.weightField) {
2428
- const I = Array.isArray(J) && J.length > 0 ? J.find((j) => j !== S.field) || J[0] : "", q = typeof window < "u" ? window.prompt(
2429
- `Weight field for weighted average of ${fe(S.field)}`,
2430
- S.weightField || I || ""
2431
- ) : S.weightField || I || "", C = typeof q == "string" ? q.trim() : "";
2432
- return C ? Array.isArray(J) && J.length > 0 && !J.includes(C) ? (w && w(`Unknown weight field: ${C}`, "warning"), p) : (b[r] = { ...S, agg: f, weightField: C }, b) : (w && w("Weighted average requires a weight field.", "warning"), p);
2433
- }
2434
- return b[r] = { ...S, agg: f }, b;
2435
- });
2436
- }, [J, d, w]), Fr = e.useCallback((r, f) => {
2437
- if (!f) {
2438
- w && w("Weighted average requires a weight field.", "warning");
2439
- return;
2440
- }
2441
- d((p) => {
2442
- const b = [...p], S = b[r];
2443
- return S ? (b[r] = { ...S, weightField: f }, b) : p;
2444
- });
2445
- }, [d, w]), zr = e.useCallback((r, f) => {
2446
- d((p) => {
2447
- const b = [...p], S = b[r];
2448
- return S ? (b[r] = {
2449
- ...S,
2450
- windowFn: f === "none" ? null : f
2451
- }, b) : p;
2452
- });
2453
- }, [d]), Bt = e.useCallback(() => {
2454
- const r = xn(E), f = E.filter((I) => I && I.agg !== "formula"), p = `Formula ${me + 1}`, b = Et(f), S = dn(p, E, r);
2455
- Ce(r), ge(r), d((I) => [
2456
- ...I,
2457
- {
2458
- field: r,
2459
- agg: "formula",
2460
- label: p,
2461
- formula: b,
2462
- formulaRef: S,
2463
- formulaScope: "measures"
2464
- }
2465
- ]), w && (f.length === 0 ? w("Added a formula column. Add at least one regular value measure to reference in it.", "warning") : w(`Added ${p}.`, "success"));
2466
- }, [me, ge, d, Ce, w, E]), Mr = (r, f) => {
2467
- r.stopPropagation(), pe.current && (Ct.current = pe.current.scrollTop), kt((p) => p.columnId === f ? { columnId: null, anchorEl: null } : { columnId: f, anchorEl: r.currentTarget }), V && V(f);
2468
- }, _r = () => kt({ columnId: null, anchorEl: null });
2469
- e.useEffect(() => {
2470
- pe.current && Ve.columnId && (pe.current.scrollTop = Ct.current);
2471
- }, [Me, Ve.columnId]), e.useEffect(() => {
2472
- if (oe.length === 0) {
2473
- ke !== null && Ce(null), se !== null && ge(null);
2474
- return;
2475
- }
2476
- oe.some((f) => f.field === ke) || Ce(oe[oe.length - 1].field), se && !oe.some((f) => f.field === se) && ge(null);
2477
- }, [ke, oe, se]);
2478
- const pt = e.useMemo(
2479
- () => E.findIndex((r) => r && r.agg === "formula" && r.field === se),
2480
- [se, E]
2481
- ), dt = pt >= 0 ? E[pt] : null, It = e.useCallback((r) => {
2482
- Ce(r), ge(r);
2483
- }, []), Ie = e.useCallback((r) => {
2484
- const f = E[r] && E[r].agg === "formula" ? E[r].field : null;
2485
- if (d((p) => p.filter((b, S) => S !== r)), f && f === ke) {
2486
- const p = oe.find((b) => b.field !== f);
2487
- Ce(p ? p.field : null);
2488
- }
2489
- f && f === se && ge(null);
2490
- }, [ke, oe, se, d, E]), $e = yr === "report", Lt = Math.max(rt || 288, $e ? 380 : 0), Pt = (r, f) => {
2491
- if (r <= 8) return null;
2492
- const p = it.trim().length > 0;
2493
- return /* @__PURE__ */ e.createElement("div", { style: {
2494
- display: "flex",
2495
- alignItems: "center",
2496
- gap: "6px",
2497
- margin: "0 2px 8px",
2498
- padding: "5px 8px",
2499
- border: `1px solid ${c.border}`,
2500
- borderRadius: c.radiusSm || "8px",
2501
- background: c.headerSubtleBg || c.surfaceInset || c.background
2502
- } }, /* @__PURE__ */ e.createElement(z.Search, { style: { flexShrink: 0, color: c.textSec } }), /* @__PURE__ */ e.createElement(
2503
- "input",
2504
- {
2505
- type: "search",
2506
- "aria-label": "Search available fields",
2507
- placeholder: `Search ${r} fields...`,
2508
- value: it,
2509
- onChange: (b) => wt(b.target.value),
2510
- style: {
2511
- flex: 1,
2512
- minWidth: 0,
2513
- border: "none",
2514
- outline: "none",
2515
- background: "transparent",
2516
- color: c.text,
2517
- fontSize: "12px"
2518
- }
2519
- }
2520
- ), p && /* @__PURE__ */ e.createElement(
2521
- "button",
2522
- {
2523
- type: "button",
2524
- "aria-label": "Clear available field search",
2525
- title: "Clear search",
2526
- onClick: () => wt(""),
2527
- style: {
2528
- border: "none",
2529
- background: "transparent",
2530
- color: c.textSec,
2531
- cursor: "pointer",
2532
- padding: 0,
2533
- display: "flex",
2534
- alignItems: "center"
2535
- }
2536
- },
2537
- /* @__PURE__ */ e.createElement(z.Close, null)
2538
- ), p && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec, whiteSpace: "nowrap" } }, f, "/", r));
2539
- };
2540
- return /* @__PURE__ */ e.createElement("div", { style: { position: "relative", display: "flex", flexShrink: 0 } }, /* @__PURE__ */ e.createElement("div", { ref: pe, style: { ...Z.sidebar, width: `${Lt}px`, minWidth: `${Lt}px` }, role: "complementary", "aria-label": "Tool Panel", onDragOver: Rr, onDragLeave: At, onDrop: At }, /* @__PURE__ */ e.createElement(
2541
- "div",
2542
- {
2543
- id: "pivot-sidebar-keyboard-dnd-help",
2544
- style: { position: "absolute", width: 1, height: 1, padding: 0, margin: -1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap", border: 0 }
2545
- },
2546
- "Press Enter or Space on a field to pick it up. Focus a target field or zone and press Enter or Space to drop it. Press Escape to cancel."
2547
- ), $e ? /* @__PURE__ */ e.createElement("div", { style: { display: "flex", borderBottom: `1px solid ${c.border}`, marginBottom: "16px" } }, [
2548
- { id: "report", label: "Builder", icon: /* @__PURE__ */ e.createElement(z.Report, null) },
2549
- { id: "fields", label: "Fields", icon: /* @__PURE__ */ e.createElement(z.Sigma, null) },
2550
- { id: "columns", label: "Columns", icon: /* @__PURE__ */ e.createElement(z.Columns, null) }
2551
- ].map((r) => /* @__PURE__ */ e.createElement(
2552
- "div",
2553
- {
2554
- key: r.id,
2555
- onClick: () => Cr(r.id),
2556
- style: {
2557
- padding: "8px 14px",
2558
- cursor: "pointer",
2559
- borderBottom: we === r.id ? `2px solid ${c.primary}` : "2px solid transparent",
2560
- fontWeight: we === r.id ? 600 : 400,
2561
- color: we === r.id ? c.primary : c.textSec,
2562
- display: "flex",
2563
- alignItems: "center",
2564
- gap: "5px",
2565
- fontSize: "13px"
2566
- }
2567
- },
2568
- r.icon,
2569
- r.label
2570
- ))) : /* @__PURE__ */ e.createElement("div", { style: { display: "flex", borderBottom: `1px solid ${c.border}`, marginBottom: "16px" } }, /* @__PURE__ */ e.createElement(
2571
- "div",
2572
- {
2573
- onClick: () => s("fields"),
2574
- style: {
2575
- padding: "8px 16px",
2576
- cursor: "pointer",
2577
- borderBottom: n === "fields" ? `2px solid ${c.primary}` : "none",
2578
- fontWeight: n === "fields" ? 600 : 400,
2579
- color: n === "fields" ? c.primary : c.textSec
2580
- }
2581
- },
2582
- "Fields"
2583
- ), /* @__PURE__ */ e.createElement(
2584
- "div",
2585
- {
2586
- onClick: () => s("filters"),
2587
- style: {
2588
- padding: "8px 16px",
2589
- cursor: "pointer",
2590
- borderBottom: n === "filters" ? `2px solid ${c.primary}` : "none",
2591
- fontWeight: n === "filters" ? 600 : 400,
2592
- color: n === "filters" ? c.primary : c.textSec,
2593
- display: "flex",
2594
- alignItems: "center",
2595
- gap: "6px"
2596
- }
2597
- },
2598
- "Filters",
2599
- Object.keys(ae).length > 0 && /* @__PURE__ */ e.createElement("div", { style: { width: "6px", height: "6px", borderRadius: "50%", background: "#d32f2f" } })
2600
- ), /* @__PURE__ */ e.createElement(
2601
- "div",
2602
- {
2603
- onClick: () => s("columns"),
2604
- style: {
2605
- padding: "8px 16px",
2606
- cursor: "pointer",
2607
- borderBottom: n === "columns" ? `2px solid ${c.primary}` : "none",
2608
- fontWeight: n === "columns" ? 600 : 400,
2609
- color: n === "columns" ? c.primary : c.textSec
2610
- }
2611
- },
2612
- "Columns"
2613
- )), $e && we === "report" ? /* @__PURE__ */ e.createElement("div", { style: { flex: 1, overflowY: "auto", padding: "0 12px 12px" } }, /* @__PURE__ */ e.createElement(
2614
- pn,
2615
- {
2616
- reportDef: br,
2617
- setReportDef: Er,
2618
- availableFields: D,
2619
- customDimensions: _e,
2620
- theme: c,
2621
- styles: Z,
2622
- data: Se,
2623
- valConfigs: E,
2624
- colFields: g,
2625
- setColFields: u,
2626
- setValConfigs: d,
2627
- savedReports: vr,
2628
- setSavedReports: Sr,
2629
- activeReportId: hr,
2630
- setActiveReportId: kr,
2631
- showNotification: w,
2632
- requestedSelection: gr,
2633
- showReportConfigColumn: mr,
2634
- setShowReportConfigColumn: xr
2635
- }
2636
- )) : $e && we === "fields" ? /* @__PURE__ */ e.createElement("div", { style: { padding: "0 4px" } }, /* @__PURE__ */ e.createElement(
2637
- Kt,
2638
- {
2639
- availableFields: D,
2640
- customDimensions: _e,
2641
- setCustomDimensions: ht,
2642
- data: Se,
2643
- theme: c,
2644
- showNotification: w,
2645
- getFieldLabel: X,
2646
- onDeleteField: Dt
2647
- }
2648
- ), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: c.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px", padding: "0 2px" } }, /* @__PURE__ */ e.createElement(z.Database, { style: { verticalAlign: "middle", marginRight: "4px" } }), "Available Fields — click to add"), Pt(J.length, ut.length), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px", marginBottom: "14px" } }, ut.map((r) => {
2649
- const f = E.some((p) => p && p.field === r && p.agg !== "formula");
2650
- return /* @__PURE__ */ e.createElement(
2651
- "div",
2652
- {
2653
- key: r,
2654
- onClick: () => {
2655
- f || d((p) => [...p, { field: r, agg: "sum", label: X(r) }]);
2656
- },
2657
- style: {
2658
- padding: "3px 9px",
2659
- fontSize: "11px",
2660
- lineHeight: 1.4,
2661
- fontWeight: 500,
2662
- borderRadius: "999px",
2663
- border: `1px solid ${f || c.isDark ? c.border : "#D7DDEA"}`,
2664
- background: f ? c.select || c.headerBg : c.isDark ? c.background : "#ffffff",
2665
- color: f ? c.primary : c.text,
2666
- cursor: f ? "default" : "pointer",
2667
- opacity: f ? 0.6 : 1,
2668
- userSelect: "none"
2669
- },
2670
- title: f ? `${X(r)} already in values` : `Add ${X(r)} to values`
2671
- },
2672
- X(r),
2673
- f ? " ✓" : ""
2674
- );
2675
- }), J.length > 8 && ut.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { width: "100%", padding: "8px 2px", fontSize: "11px", color: c.textSec } }, "No fields match the current search.")), /* @__PURE__ */ e.createElement("div", { style: { borderTop: `1px solid ${c.border}`, paddingTop: "10px", marginBottom: "8px" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "0 2px 8px 2px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: Bt, style: { border: `1px solid ${c.primary}66`, background: `${c.primary}12`, color: c.primary, borderRadius: "999px", cursor: "pointer", padding: "4px 10px", fontSize: "11px", fontWeight: 700 } }, "+ Add Formula"), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec } }, Ae, " value", Ae === 1 ? "" : "s", " · ", me, " formula", me === 1 ? "" : "s")), /* @__PURE__ */ e.createElement(
2676
- Qt,
2677
- {
2678
- measureAxis: $,
2679
- setMeasureAxis: i,
2680
- theme: c,
2681
- valueSelectStyle: ue,
2682
- regularValueCount: Ae
2683
- }
2684
- )), E.map((r, f) => {
2685
- const p = r && r.agg === "formula";
2686
- if (!r) return null;
2687
- const b = wr === f;
2688
- return /* @__PURE__ */ e.createElement(
2689
- "div",
2690
- {
2691
- key: r.field || f,
2692
- draggable: !0,
2693
- onDragStart: () => {
2694
- Ye.current = f;
2695
- },
2696
- onDragOver: (S) => {
2697
- S.preventDefault(), Ze(f);
2698
- },
2699
- onDragLeave: () => Ze(null),
2700
- onDrop: (S) => {
2701
- S.preventDefault();
2702
- const I = Ye.current;
2703
- Ze(null), Ye.current = null, !(I === null || I === f) && d((q) => {
2704
- const C = [...q], [j] = C.splice(I, 1);
2705
- return C.splice(f, 0, j), C;
2706
- });
2707
- },
2708
- onDragEnd: () => {
2709
- Ye.current = null, Ze(null);
2710
- },
2711
- style: { marginBottom: "6px", borderTop: b ? `2px solid ${c.primary}` : "2px solid transparent", cursor: "grab" }
2712
- },
2713
- p ? /* @__PURE__ */ e.createElement(Jt, { item: r, idx: f, selected: r.field === se, onSelect: It, onRemove: Ie, setValConfigs: d, theme: c, styles: Z, dropLine: null, zoneId: "vals", valueSelectStyle: ue, colFields: g, fixedSparklineValueKeySet: st, showNotification: w, serverError: he && he[r.field] || null }) : /* @__PURE__ */ e.createElement("div", { style: { ...Z.chip, flexWrap: "wrap", alignItems: "flex-start" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", minWidth: 0, flex: 1 } }, /* @__PURE__ */ e.createElement(z.DragIndicator, { style: { flexShrink: 0, opacity: 0.4 } }), /* @__PURE__ */ e.createElement("b", { style: { fontWeight: 500, minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, X(r.field))), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "4px", marginLeft: "8px", flexWrap: "nowrap", flexShrink: 0 } }, /* @__PURE__ */ e.createElement("select", { value: r.agg, onChange: (S) => Wt(f, S.target.value), style: { ...ue, width: "74px" } }, /* @__PURE__ */ e.createElement("option", { value: "sum" }, "Sum"), /* @__PURE__ */ e.createElement("option", { value: "avg" }, "Avg"), /* @__PURE__ */ e.createElement("option", { value: "count" }, "Cnt"), /* @__PURE__ */ e.createElement("option", { value: "min" }, "Min"), /* @__PURE__ */ e.createElement("option", { value: "max" }, "Max"), /* @__PURE__ */ e.createElement("option", { value: "weighted_avg" }, "WAvg")), /* @__PURE__ */ e.createElement("span", { onClick: () => Ie(f), style: { cursor: "pointer", color: "#9CA3AF", display: "flex", alignItems: "center" } }, /* @__PURE__ */ e.createElement(z.Close, null))))
2714
- );
2715
- }), E.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { opacity: 0.5, fontSize: "11px", padding: "12px", textAlign: "center" } }, "No value fields. Click a field above or add a formula.")) : !$e && n === "filters" ? /* @__PURE__ */ e.createElement("div", { style: { flex: 1, overflowY: "auto", display: "flex", flexDirection: "column", padding: "8px" } }, /* @__PURE__ */ e.createElement("div", { style: { marginBottom: "10px", display: "flex", alignItems: "center", background: c.background, borderRadius: "6px", padding: "4px 8px", border: `1px solid ${c.border}` } }, /* @__PURE__ */ e.createElement(z.Search, null), /* @__PURE__ */ e.createElement(
2716
- "input",
2717
- {
2718
- placeholder: "Search columns...",
2719
- value: k,
2720
- onChange: (r) => P(r.target.value),
2721
- style: { border: "none", background: "transparent", marginLeft: "10px", outline: "none", width: "100%", color: c.text, fontSize: "13px" }
2722
- }
2723
- )), (() => {
2724
- const p = D.map((b) => {
2725
- const S = y.getColumn(b);
2726
- return S || { id: b, header: X(b), columnDef: { header: X(b) } };
2727
- }).filter((b) => {
2728
- const S = b.columnDef && typeof b.columnDef.header == "string" ? b.columnDef.header : typeof b.header == "string" ? b.header : b.id;
2729
- return String(S).toLowerCase().includes(k.toLowerCase()) || b.id.toLowerCase().includes(k.toLowerCase());
2730
- });
2731
- return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column" } }, p.map((b) => /* @__PURE__ */ e.createElement(
2732
- Jr,
2733
- {
2734
- key: b.id,
2735
- column: b,
2736
- theme: c,
2737
- styles: Z,
2738
- onFilter: (S) => U(b.id, S),
2739
- currentFilter: ae[b.id],
2740
- options: Tt(b.id),
2741
- optionMeta: Oe && Oe[b.id],
2742
- onSearchOptions: je ? (S) => V && V(b.id, { search: S, offset: 0 }) : void 0,
2743
- onLoadMoreOptions: je ? (S, I) => V && V(b.id, { search: S, offset: I }) : void 0,
2744
- onOpen: V
2745
- }
2746
- )));
2747
- })()) : ($e ? we !== "columns" : n !== "columns") ? /* @__PURE__ */ e.createElement(e.Fragment, null, n === "fields" && /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(
2748
- Kt,
2749
- {
2750
- availableFields: D,
2751
- customDimensions: _e,
2752
- setCustomDimensions: ht,
2753
- data: Se,
2754
- theme: c,
2755
- showNotification: w,
2756
- getFieldLabel: X,
2757
- onDeleteField: Dt
2758
- }
2759
- ), /* @__PURE__ */ e.createElement("div", { style: Z.sectionTitleSm }, /* @__PURE__ */ e.createElement(z.Database, null), " Available Fields"), Pt(De.length, ct.length), /* @__PURE__ */ e.createElement(
2760
- qt,
2761
- {
2762
- panelId: "availableFields",
2763
- panelLabel: "Available Fields",
2764
- size: Ue && Ue.availableFields,
2765
- onSizeChange: zt,
2766
- theme: c,
2767
- outerStyle: _t,
2768
- contentStyle: {
2769
- display: "flex",
2770
- flexWrap: "wrap",
2771
- gap: "4px",
2772
- alignContent: "flex-start",
2773
- padding: "2px 12px 12px 2px"
2774
- }
2775
- },
2776
- ct.map((r) => {
2777
- const f = Te && r === de, p = f ? "Measure Names" : X(r), b = f ? "measureAxis" : "pool";
2778
- return /* @__PURE__ */ e.createElement(
2779
- "div",
2780
- {
2781
- key: f ? `__measure_axis__${r}` : r,
2782
- draggable: !0,
2783
- "data-sidebar-field-chip": f ? "measure-axis-label" : "available",
2784
- role: "button",
2785
- tabIndex: 0,
2786
- "aria-describedby": "pivot-sidebar-keyboard-dnd-help",
2787
- "aria-grabbed": G && G.zone === b && G.field === r ? "true" : "false",
2788
- "aria-label": `Move ${p}`,
2789
- onDragStart: (S) => H(S, r, b),
2790
- onDragEnd: F,
2791
- onKeyDown: (S) => Ft(S, r, b, -1, p),
2792
- title: f ? "Drag to Rows or Columns to show measure names" : `Move ${X(r)}`,
2793
- style: {
2794
- padding: "4px 8px",
2795
- fontSize: "11px",
2796
- lineHeight: 1.2,
2797
- fontWeight: f ? 700 : 500,
2798
- fontFamily: "'Inter', ui-sans-serif, system-ui, sans-serif",
2799
- borderRadius: c.radiusSm || c.radius || "10px",
2800
- border: f ? `1px dashed ${c.primary}` : `1px solid ${c.isDark ? c.border : "#D7DDEA"}`,
2801
- background: f ? `${c.primary}12` : c.isDark ? c.background : c.surfaceInset || "#ffffff",
2802
- color: f ? c.primary : c.isDark ? c.text : "#334155",
2803
- display: "inline-flex",
2804
- alignItems: "center",
2805
- gap: "4px",
2806
- boxShadow: c.isDark ? "none" : c.shadowInset || "0 1px 2px rgba(0,0,0,0.04)",
2807
- cursor: "grab",
2808
- userSelect: "none",
2809
- minHeight: "24px"
2810
- }
2811
- },
2812
- f && /* @__PURE__ */ e.createElement(z.Sigma, null),
2813
- p
2814
- );
2815
- }),
2816
- De.length > 8 && ct.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { width: "100%", padding: "8px 2px", fontSize: "11px", color: c.textSec } }, "No fields match the current search.")
2817
- )), Dr.map((r) => {
2818
- const f = Be[r.id] || [];
2819
- return /* @__PURE__ */ e.createElement("div", { key: r.id, style: { marginBottom: "20px" } }, /* @__PURE__ */ e.createElement("div", { style: Z.sectionTitle }, r.icon, r.label), r.id === "vals" && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "0 4px 8px 4px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
2820
- "button",
2821
- {
2822
- type: "button",
2823
- onClick: Bt,
2824
- style: {
2825
- border: `1px solid ${c.primary}66`,
2826
- background: `${c.primary}12`,
2827
- color: c.primary,
2828
- borderRadius: "999px",
2829
- cursor: "pointer",
2830
- padding: "4px 10px",
2831
- fontSize: "11px",
2832
- fontWeight: 700
2833
- }
2834
- },
2835
- "+ Add Formula"
2836
- ), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec } }, Ae, " value measure", Ae === 1 ? "" : "s", " available"), me > 0 && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec } }, me, " formula", me === 1 ? "" : "s"), /* @__PURE__ */ e.createElement(
2837
- Qt,
2838
- {
2839
- measureAxis: $,
2840
- setMeasureAxis: i,
2841
- theme: c,
2842
- valueSelectStyle: ue,
2843
- regularValueCount: Ae
2844
- }
2845
- )), r.id === "rows" && a.length > 0 && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", padding: "0 4px 6px 4px" } }, /* @__PURE__ */ e.createElement(
2846
- "button",
2847
- {
2848
- title: "Expand all hierarchy levels",
2849
- onClick: () => ee(!0),
2850
- style: { flex: 1, border: `1px solid ${c.primary}`, background: c.select, cursor: "pointer", padding: "3px 6px", fontSize: "11px", color: c.primary, borderRadius: "4px", fontWeight: 600 }
2851
- },
2852
- "+ Expand All"
2853
- ), /* @__PURE__ */ e.createElement(
2854
- "button",
2855
- {
2856
- title: "Collapse all rows",
2857
- onClick: () => ee(!1),
2858
- style: { flex: 1, border: `1px solid ${c.border}`, background: c.background, cursor: "pointer", padding: "3px 6px", fontSize: "11px", color: c.textSec, borderRadius: "4px" }
2859
- },
2860
- "- Collapse All"
2861
- )), /* @__PURE__ */ e.createElement(
2862
- qt,
2863
- {
2864
- panelId: r.id,
2865
- panelLabel: r.label,
2866
- size: Ue && Ue[r.id],
2867
- onSizeChange: zt,
2868
- theme: c,
2869
- outerStyle: _t,
2870
- contentStyle: { padding: `${Mt} 12px 12px ${Mt}` }
2871
- },
2872
- /* @__PURE__ */ e.createElement(
2873
- "div",
2874
- {
2875
- "data-sidebar-drop-zone": r.id,
2876
- role: "group",
2877
- tabIndex: 0,
2878
- "aria-label": `${r.label} drop zone`,
2879
- "aria-describedby": "pivot-sidebar-keyboard-dnd-help",
2880
- onKeyDown: (p) => Ar(p, r.id),
2881
- onDragOver: (p) => {
2882
- p.target === p.currentTarget ? K(p, r.id, f.length) : (p.preventDefault(), p.dataTransfer && (p.dataTransfer.dropEffect = "move"));
2883
- },
2884
- onDrop: (p) => x(p, r.id)
2885
- },
2886
- f.map((p, b) => {
2887
- const S = r.id === "vals" ? p.field : p, I = r.id === "vals" ? p.agg === "formula" ? p.label || "Formula" : X(p.field) : X(p), q = (r.id === "rows" || r.id === "cols") && S === de && Rt.placement !== "none";
2888
- return /* @__PURE__ */ e.createElement(
2889
- "div",
2890
- {
2891
- key: b,
2892
- draggable: !0,
2893
- "data-sidebar-field-chip": "zone",
2894
- role: "button",
2895
- tabIndex: 0,
2896
- "aria-describedby": "pivot-sidebar-keyboard-dnd-help",
2897
- "aria-grabbed": G && G.zone === r.id && G.idx === b ? "true" : "false",
2898
- "aria-label": `Move ${I}`,
2899
- onKeyDown: (C) => Ft(C, p, r.id, b, I),
2900
- onDragStart: (C) => H(C, p, r.id, b),
2901
- onDragOver: (C) => K(C, r.id, b),
2902
- onDragEnd: F
2903
- },
2904
- r.id === "vals" && p.agg === "formula" ? /* @__PURE__ */ e.createElement(
2905
- Jt,
2906
- {
2907
- item: p,
2908
- idx: b,
2909
- selected: p.field === ke,
2910
- onSelect: It,
2911
- onRemove: Ie,
2912
- setValConfigs: d,
2913
- theme: c,
2914
- styles: Z,
2915
- dropLine: M,
2916
- zoneId: r.id,
2917
- valueSelectStyle: ue,
2918
- colFields: g,
2919
- fixedSparklineValueKeySet: st,
2920
- showNotification: w,
2921
- serverError: he && he[p.field] || null
2922
- }
2923
- ) : /* @__PURE__ */ e.createElement("div", { style: {
2924
- ...Z.chip,
2925
- ...r.id === "vals" ? { flexWrap: "wrap", alignItems: "flex-start" } : {}
2926
- } }, M && M.zone === r.id && M.idx === b && /* @__PURE__ */ e.createElement("div", { style: { ...Z.dropLine, top: -2 } }), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", minWidth: 0, flex: 1 } }, /* @__PURE__ */ e.createElement(z.DragIndicator, null), /* @__PURE__ */ e.createElement("b", { style: { fontWeight: 500, display: "block", minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, I)), r.id === "vals" && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "4px", marginLeft: "8px", flexWrap: "nowrap", flexShrink: 0 } }, /* @__PURE__ */ e.createElement("select", { value: p.agg, onChange: (C) => Wt(b, C.target.value), style: { ...ue, width: "74px" }, title: "Aggregation" }, /* @__PURE__ */ e.createElement("option", { value: "sum" }, "Sum"), /* @__PURE__ */ e.createElement("option", { value: "avg" }, "Avg"), /* @__PURE__ */ e.createElement("option", { value: "count" }, "Cnt"), /* @__PURE__ */ e.createElement("option", { value: "min" }, "Min"), /* @__PURE__ */ e.createElement("option", { value: "max" }, "Max"), /* @__PURE__ */ e.createElement("option", { value: "weighted_avg" }, "WAvg"), /* @__PURE__ */ e.createElement("option", { value: "array_agg" }, "Series")), Ht(p.agg) && /* @__PURE__ */ e.createElement("select", { value: p.weightField || "", onChange: (C) => Fr(b, C.target.value), style: { ...ue, width: "92px" }, title: "Weight field" }, /* @__PURE__ */ e.createElement("option", { value: "", disabled: !0 }, "Weight"), J.map((C) => /* @__PURE__ */ e.createElement("option", { key: C, value: C }, X(C)))), /* @__PURE__ */ e.createElement("select", { value: p.windowFn || "none", onChange: (C) => zr(b, C.target.value), style: { ...ue, width: "56px" } }, /* @__PURE__ */ e.createElement("option", { value: "none" }, "Norm"), /* @__PURE__ */ e.createElement("option", { value: "percent_of_row" }, "%Row"), /* @__PURE__ */ e.createElement("option", { value: "percent_of_col" }, "%Col"), /* @__PURE__ */ e.createElement("option", { value: "percent_of_grand_total" }, "%Tot"))), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", marginLeft: "auto", alignItems: "center" } }, r.id === "filter" && /* @__PURE__ */ e.createElement("div", { onClick: (C) => Mr(C, S), style: { cursor: "pointer", display: "flex", alignItems: "center", padding: "2px", borderRadius: "4px" } }, /* @__PURE__ */ e.createElement(z.Filter, null)), /* @__PURE__ */ e.createElement("span", { onClick: () => {
2927
- if (q && typeof i == "function") {
2928
- i((C) => ({
2929
- ...Pe(C),
2930
- placement: "none"
2931
- }));
2932
- return;
2933
- }
2934
- if (r.id === "filter") {
2935
- const C = { ...ae };
2936
- delete C[S], at(C);
2937
- }
2938
- r.id === "rows" && l((C) => C.filter((j) => j !== S)), r.id === "cols" && u((C) => C.filter((j) => j !== S)), r.id === "vals" && Ie(b);
2939
- }, style: { cursor: "pointer", color: "#9CA3AF", display: "flex", alignItems: "center" } }, /* @__PURE__ */ e.createElement(z.Close, null))), r.id === "filter" && Ve.columnId === S && /* @__PURE__ */ e.createElement(
2940
- Yr,
2941
- {
2942
- column: { header: I, id: S },
2943
- anchorEl: Ve.anchorEl,
2944
- onClose: _r,
2945
- onFilter: (C) => U(S, C),
2946
- currentFilter: ae[S],
2947
- options: Tt(S),
2948
- optionMeta: Oe && Oe[S],
2949
- onSearchOptions: je ? (C) => V && V(S, { search: C, offset: 0 }) : void 0,
2950
- onLoadMoreOptions: je ? (C, j) => V && V(S, { search: C, offset: j }) : void 0,
2951
- theme: c
2952
- }
2953
- ), r.id === "vals" && /* @__PURE__ */ e.createElement(
2954
- dr,
2955
- {
2956
- item: p,
2957
- idx: b,
2958
- setValConfigs: d,
2959
- theme: c,
2960
- valueSelectStyle: ue,
2961
- colFields: g,
2962
- fixedSparklineValueKeySet: st,
2963
- showNotification: w
2964
- }
2965
- ), M && M.zone === r.id && M.idx === b + 1 && /* @__PURE__ */ e.createElement("div", { style: { ...Z.dropLine, bottom: -2 } })),
2966
- r.id === "filter" && ae[S] && ae[S].conditions && /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: c.primary, padding: "0 8px 4px 8px", marginTop: "-4px" } }, ae[S].conditions.map((C) => `${C.type}: ${C.value}${C.caseSensitive ? " (Match Case)" : ""}`).join(` ${ae[S].operator} `))
2967
- );
2968
- }),
2969
- f.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { opacity: 0.5, fontSize: "11px", padding: "8px", textAlign: "center", pointerEvents: "none" } }, "Drag fields here"),
2970
- /* @__PURE__ */ e.createElement("div", { style: { height: 20 }, onDragOver: (p) => K(p, r.id, f.length), onDrop: (p) => x(p, r.id) })
2971
- )
2972
- ));
2973
- })) : /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "16px", height: "100%", overflow: "hidden" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px", padding: "8px", background: c.headerBg, borderRadius: "8px", boxShadow: "0 1px 3px rgba(0,0,0,0.08)" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", background: c.background, borderRadius: "6px", padding: "8px 12px", border: `2px solid ${c.border}`, transition: "border-color 0.2s" } }, /* @__PURE__ */ e.createElement(z.Search, null), /* @__PURE__ */ e.createElement(
2974
- "input",
2975
- {
2976
- placeholder: "Search columns...",
2977
- value: k,
2978
- onChange: (r) => P(r.target.value),
2979
- style: {
2980
- border: "none",
2981
- background: "transparent",
2982
- marginLeft: "10px",
2983
- outline: "none",
2984
- width: "100%",
2985
- color: c.text,
2986
- fontSize: "13px",
2987
- fontWeight: 500
2988
- }
2989
- }
2990
- ), k && /* @__PURE__ */ e.createElement(
2991
- "span",
2992
- {
2993
- onClick: () => P(""),
2994
- style: {
2995
- cursor: "pointer",
2996
- display: "flex",
2997
- padding: "4px",
2998
- borderRadius: "4px",
2999
- background: c.hover,
3000
- transition: "background 0.2s"
3001
- },
3002
- onMouseEnter: (r) => r.currentTarget.style.background = c.select,
3003
- onMouseLeave: (r) => r.currentTarget.style.background = c.hover
3004
- },
3005
- /* @__PURE__ */ e.createElement(z.Close, null)
3006
- )), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, [
3007
- { value: "all", label: "All", icon: "📊" },
3008
- { value: "number", label: "Numbers", icon: "🔢" },
3009
- { value: "string", label: "Text", icon: "📝" },
3010
- { value: "date", label: "Dates", icon: "📅" }
3011
- ].map((r) => /* @__PURE__ */ e.createElement(
3012
- "button",
3013
- {
3014
- key: r.value,
3015
- onClick: () => A(r.value),
3016
- style: {
3017
- padding: "6px 12px",
3018
- borderRadius: "6px",
3019
- border: "none",
3020
- background: o === r.value ? c.primary : c.background,
3021
- color: o === r.value ? "#fff" : c.text,
3022
- cursor: "pointer",
3023
- fontSize: "11px",
3024
- fontWeight: 600,
3025
- display: "flex",
3026
- alignItems: "center",
3027
- gap: "4px",
3028
- transition: "all 0.2s",
3029
- boxShadow: o === r.value ? "0 2px 4px rgba(0,0,0,0.1)" : "none"
3030
- },
3031
- onMouseEnter: (f) => {
3032
- o !== r.value && (f.currentTarget.style.background = c.hover);
3033
- },
3034
- onMouseLeave: (f) => {
3035
- o !== r.value && (f.currentTarget.style.background = c.background);
3036
- }
3037
- },
3038
- /* @__PURE__ */ e.createElement("span", null, r.icon),
3039
- /* @__PURE__ */ e.createElement("span", null, r.label)
3040
- )))), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", padding: "0 8px" } }, /* @__PURE__ */ e.createElement(
3041
- "button",
3042
- {
3043
- onClick: () => y.toggleAllColumnsVisible(!0),
3044
- style: {
3045
- ...Z.btn,
3046
- padding: "8px 12px",
3047
- fontSize: "11px",
3048
- flex: 1,
3049
- justifyContent: "center",
3050
- background: c.background,
3051
- fontWeight: 600,
3052
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3053
- transition: "all 0.2s"
3054
- },
3055
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3056
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3057
- },
3058
- /* @__PURE__ */ e.createElement(z.Visibility, { style: { fontSize: "14px" } }),
3059
- /* @__PURE__ */ e.createElement("span", null, "Show All")
3060
- ), /* @__PURE__ */ e.createElement(
3061
- "button",
3062
- {
3063
- onClick: () => y.toggleAllColumnsVisible(!1),
3064
- style: {
3065
- ...Z.btn,
3066
- padding: "8px 12px",
3067
- fontSize: "11px",
3068
- flex: 1,
3069
- justifyContent: "center",
3070
- background: c.background,
3071
- fontWeight: 600,
3072
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3073
- transition: "all 0.2s"
3074
- },
3075
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3076
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3077
- },
3078
- /* @__PURE__ */ e.createElement(z.VisibilityOff, { style: { fontSize: "14px" } }),
3079
- /* @__PURE__ */ e.createElement("span", null, "Hide All")
3080
- ), /* @__PURE__ */ e.createElement(
3081
- "button",
3082
- {
3083
- onClick: () => te(!1),
3084
- style: {
3085
- ...Z.btn,
3086
- padding: "8px 12px",
3087
- fontSize: "11px",
3088
- flex: 1,
3089
- justifyContent: "center",
3090
- background: c.background,
3091
- fontWeight: 600,
3092
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3093
- transition: "all 0.2s"
3094
- },
3095
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3096
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3097
- },
3098
- /* @__PURE__ */ e.createElement(z.Unpin, { style: { fontSize: "14px" } }),
3099
- /* @__PURE__ */ e.createElement("span", null, "Unpin All")
3100
- )), R.size > 0 && /* @__PURE__ */ e.createElement("div", { style: {
3101
- display: "flex",
3102
- flexDirection: "column",
3103
- gap: "8px",
3104
- background: `linear-gradient(135deg, ${c.select}ee, ${c.select}dd)`,
3105
- padding: "12px",
3106
- borderRadius: "8px",
3107
- border: `2px solid ${c.primary}66`,
3108
- boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3109
- margin: "0 8px"
3110
- } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, /* @__PURE__ */ e.createElement("span", { style: {
3111
- fontSize: "12px",
3112
- fontWeight: 700,
3113
- padding: "4px 10px",
3114
- color: c.primary,
3115
- background: c.background,
3116
- borderRadius: "6px",
3117
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)"
3118
- } }, R.size, " Column", R.size > 1 ? "s" : "", " Selected"), /* @__PURE__ */ e.createElement(
3119
- "button",
3120
- {
3121
- onClick: () => B(/* @__PURE__ */ new Set()),
3122
- style: {
3123
- border: "none",
3124
- background: c.background,
3125
- cursor: "pointer",
3126
- display: "flex",
3127
- color: c.textSec,
3128
- padding: "4px",
3129
- borderRadius: "4px",
3130
- transition: "all 0.2s"
3131
- },
3132
- onMouseEnter: (r) => r.currentTarget.style.background = c.hover,
3133
- onMouseLeave: (r) => r.currentTarget.style.background = c.background
3134
- },
3135
- /* @__PURE__ */ e.createElement(z.Close, null)
3136
- )), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
3137
- "button",
3138
- {
3139
- onClick: () => {
3140
- Array.from(R).forEach((r) => Y(r, "left")), B(/* @__PURE__ */ new Set());
3141
- },
3142
- style: {
3143
- ...Z.btn,
3144
- padding: "6px 12px",
3145
- fontSize: "11px",
3146
- background: c.background,
3147
- flex: 1,
3148
- justifyContent: "center",
3149
- fontWeight: 600,
3150
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3151
- transition: "all 0.2s"
3152
- },
3153
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3154
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3155
- },
3156
- /* @__PURE__ */ e.createElement(z.PinLeft, null),
3157
- /* @__PURE__ */ e.createElement("span", null, "Pin Left")
3158
- ), /* @__PURE__ */ e.createElement(
3159
- "button",
3160
- {
3161
- onClick: () => {
3162
- Array.from(R).forEach((r) => Y(r, !1)), B(/* @__PURE__ */ new Set());
3163
- },
3164
- style: {
3165
- ...Z.btn,
3166
- padding: "6px 12px",
3167
- fontSize: "11px",
3168
- background: c.background,
3169
- flex: 1,
3170
- justifyContent: "center",
3171
- fontWeight: 600,
3172
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3173
- transition: "all 0.2s"
3174
- },
3175
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3176
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3177
- },
3178
- /* @__PURE__ */ e.createElement(z.Unpin, null),
3179
- /* @__PURE__ */ e.createElement("span", null, "Unpin")
3180
- ), /* @__PURE__ */ e.createElement(
3181
- "button",
3182
- {
3183
- onClick: () => {
3184
- Array.from(R).forEach((r) => Y(r, "right")), B(/* @__PURE__ */ new Set());
3185
- },
3186
- style: {
3187
- ...Z.btn,
3188
- padding: "6px 12px",
3189
- fontSize: "11px",
3190
- background: c.background,
3191
- flex: 1,
3192
- justifyContent: "center",
3193
- fontWeight: 600,
3194
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3195
- transition: "all 0.2s"
3196
- },
3197
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3198
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3199
- },
3200
- /* @__PURE__ */ e.createElement(z.PinRight, null),
3201
- /* @__PURE__ */ e.createElement("span", null, "Pin Right")
3202
- ))), /* @__PURE__ */ e.createElement("div", { style: { flex: 1, overflowY: "auto", display: "flex", flexDirection: "column" } }, (() => {
3203
- const f = y.getAllColumns().filter((C) => !C.parent && C.id !== "no_data").filter((C) => {
3204
- if (o === "all") return !0;
3205
- let j = "string";
3206
- if (E.find((re) => C.id.includes(re.field)))
3207
- j = "number";
3208
- else if (Se && Se.length > 0) {
3209
- const re = Se[0];
3210
- let ne = re[C.id];
3211
- if (ne === void 0 && C.accessorFn)
3212
- try {
3213
- ne = C.accessorFn(re);
3214
- } catch {
3215
- }
3216
- typeof ne == "number" ? j = "number" : ne instanceof Date ? j = "date" : typeof ne == "string" && (!isNaN(Number(ne)) && ne.trim() !== "" ? j = "number" : !isNaN(Date.parse(ne)) && ne.includes("-") && (j = "date"));
3217
- }
3218
- return j === o;
3219
- }), p = f.filter((C) => Je(C, "left")), b = f.filter((C) => Je(C, "right")), S = f.filter((C) => Je(C, "unpinned")), I = (C, j) => C.map((ie) => /* @__PURE__ */ e.createElement(
3220
- rr,
3221
- {
3222
- key: ie.id,
3223
- column: ie,
3224
- level: 0,
3225
- theme: c,
3226
- styles: Z,
3227
- handlePinColumn: Y,
3228
- colSearch: k,
3229
- selectedCols: R,
3230
- setSelectedCols: B,
3231
- onDrop: q,
3232
- sectionId: j
3233
- }
3234
- )), q = (C, j, ie) => {
3235
- let re;
3236
- const ne = L || { left: [], right: [] };
3237
- if (ie) {
3238
- const Le = j === "left" ? ne.left : j === "right" ? ne.right : null;
3239
- if (Le) {
3240
- if (re = Le.indexOf(ie), re === -1) {
3241
- const ft = y.getColumn(ie);
3242
- if (ft && Nr(ft)) {
3243
- const Ot = xt(ft).find((Tr) => Le.includes(Tr));
3244
- Ot && (re = Le.indexOf(Ot));
3245
- }
3246
- }
3247
- re === -1 && (re = void 0);
3248
- }
3249
- }
3250
- j === "left" ? Y(C, "left", re) : j === "right" ? Y(C, "right", re) : Y(C, !1);
3251
- };
3252
- return /* @__PURE__ */ e.createElement(e.Fragment, null, p.length > 0 && /* @__PURE__ */ e.createElement(
3253
- gt,
3254
- {
3255
- title: "Pinned Left",
3256
- count: p.length,
3257
- theme: c,
3258
- styles: Z,
3259
- sectionId: "left",
3260
- onDrop: q
3261
- },
3262
- I(p, "left")
3263
- ), b.length > 0 && /* @__PURE__ */ e.createElement(
3264
- gt,
3265
- {
3266
- title: "Pinned Right",
3267
- count: b.length,
3268
- theme: c,
3269
- styles: Z,
3270
- sectionId: "right",
3271
- onDrop: q
3272
- },
3273
- I(b, "right")
3274
- ), /* @__PURE__ */ e.createElement(
3275
- gt,
3276
- {
3277
- title: "Columns",
3278
- count: S.length,
3279
- theme: c,
3280
- styles: Z,
3281
- sectionId: "unpinned",
3282
- onDrop: q
3283
- },
3284
- I(S, "unpinned")
3285
- ));
3286
- })()), h && h.length > 0 && /* @__PURE__ */ e.createElement("div", { style: { padding: "8px", borderTop: `1px solid ${c.border}` } }, /* @__PURE__ */ e.createElement("div", { style: Z.sectionTitle }, "Pinning Presets"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", flexWrap: "wrap" } }, h.map((r, f) => /* @__PURE__ */ e.createElement(
3287
- "button",
3288
- {
3289
- key: f,
3290
- onClick: () => {
3291
- _(r.config), w(`Applied preset: ${r.name}`);
3292
- },
3293
- style: { ...Z.btn, fontSize: "11px", background: c.headerBg }
3294
- },
3295
- r.name
3296
- )))), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: c.textSec, fontStyle: "italic", padding: "8px", background: c.headerBg, borderTop: `1px solid ${c.border}44` } }, /* @__PURE__ */ e.createElement(z.Lock, { style: { verticalAlign: "middle", marginRight: "4px", opacity: 0.5 } }), "Drag columns or use pin icons to freeze areas."))), dt && /* @__PURE__ */ e.createElement(
3297
- kn,
3298
- {
3299
- item: dt,
3300
- idx: pt,
3301
- valConfigs: E,
3302
- setValConfigs: d,
3303
- theme: c,
3304
- onClose: () => ge(null),
3305
- onRemove: Ie,
3306
- displayedColumnOptions: fr,
3307
- availableRawFields: J,
3308
- serverError: he && he[dt.field] || null
3309
- }
3310
- ), /* @__PURE__ */ e.createElement(
3311
- "div",
3312
- {
3313
- onMouseDown: $r,
3314
- style: {
3315
- position: "absolute",
3316
- right: 0,
3317
- top: 0,
3318
- bottom: 0,
3319
- width: "5px",
3320
- cursor: "col-resize",
3321
- zIndex: 10,
3322
- background: "transparent"
3323
- },
3324
- title: "Drag to resize panel"
3325
- },
3326
- /* @__PURE__ */ e.createElement("div", { style: {
3327
- position: "absolute",
3328
- right: 0,
3329
- top: 0,
3330
- bottom: 0,
3331
- width: "2px",
3332
- background: c.border,
3333
- transition: "background 0.15s"
3334
- } })
3335
- ));
3336
- });
3337
- export {
3338
- Fn as SidebarPanel
3339
- };