@nivaro/react 0.3.49 → 0.3.51

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 (46) hide show
  1. package/dist/components/InlineGridField.js +166 -105
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +38 -4
  5. package/dist/shared/components/ItemEditForm.js +5258 -5034
  6. package/dist/shared/components/QueryTable.js +489 -347
  7. package/dist/shared/components/ReportView.js +105 -99
  8. package/dist/shared/components/alerts/AlertManagerView.js +327 -301
  9. package/dist/shared/components/item-edit/CatalogPickerField.js +1230 -1175
  10. package/dist/shared/components/item-edit/CloneDialog.js +192 -142
  11. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +58 -53
  12. package/dist/shared/components/item-edit/FieldRenderer.js +249 -244
  13. package/dist/shared/components/item-edit/FieldRow.js +402 -370
  14. package/dist/shared/components/item-edit/FilePickerField.js +315 -307
  15. package/dist/shared/components/item-edit/InlineGridField.js +92 -90
  16. package/dist/shared/components/item-edit/InlineTableField.js +3119 -2951
  17. package/dist/shared/components/item-edit/MidairCollisionDialog.js +175 -0
  18. package/dist/shared/components/item-edit/PlanGrid.js +162 -162
  19. package/dist/shared/components/item-edit/PolishFields.js +169 -162
  20. package/dist/shared/components/item-edit/RecordHeaderActions.js +76 -75
  21. package/dist/shared/components/item-edit/RecordLiveSync.js +93 -91
  22. package/dist/shared/components/item-edit/RelationCombobox.js +198 -191
  23. package/dist/shared/components/item-edit/SummaryPanel.js +282 -259
  24. package/dist/shared/components/item-edit/UserChip.js +233 -200
  25. package/dist/shared/components/item-edit/ValidationSummary.js +64 -47
  26. package/dist/shared/components/item-edit/header-midair.js +51 -0
  27. package/dist/shared/components/item-edit/helpers.js +181 -155
  28. package/dist/shared/components/item-edit/line-midair.js +207 -0
  29. package/dist/shared/components/item-edit/soft-rules.js +27 -0
  30. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  31. package/dist/shared/components/panels/CommentPanel.js +290 -284
  32. package/dist/shared/components/panels/ItemLockBanner.js +414 -358
  33. package/dist/shared/components/panels/PipelinePanel.js +1241 -992
  34. package/dist/shared/components/panels/RecordIntegrityBanner.js +1 -1
  35. package/dist/shared/components/panels/TaskPanel.js +71 -61
  36. package/dist/shared/components/panels/TransitionRequirementsDialog.js +569 -439
  37. package/dist/shared/components/panels/requirement-side-effects.js +40 -0
  38. package/dist/shared/components/queue/QueueWorklist.js +925 -871
  39. package/dist/shared/components/queue/column-chooser.js +21 -0
  40. package/dist/shared/components/queue/live-state-aspect.js +6 -0
  41. package/dist/shared/components/ui/number-draft-input.js +93 -0
  42. package/dist/shared/components/widgets/ReviewListWidget.js +191 -166
  43. package/dist/shared/lib/draft-store.js +48 -34
  44. package/dist/shared/lib/error-hints.js +1 -0
  45. package/dist/shared/lib/query-stats.js +60 -60
  46. package/package.json +1 -1
@@ -1,11 +1,11 @@
1
- import { jsx as s, jsxs as p, Fragment as Re } from "react/jsx-runtime";
2
- import { ChevronsDownUp as Be, ChevronsUpDown as Qe } from "lucide-react";
3
- import { useState as Y, useEffect as Ve, useMemo as Pe } from "react";
4
- import { evaluateNumeric as Ye } from "../lib/expression.js";
5
- function Xe(i) {
6
- return `color-mix(in srgb, ${i} 55%, white)`;
1
+ import { jsx as o, jsxs as p, Fragment as Pe } from "react/jsx-runtime";
2
+ import { Search as dt, Download as it, ArrowUp as ut, ArrowDown as mt, ChevronsDownUp as bt, ChevronsUpDown as ct } from "lucide-react";
3
+ import { useState as W, useEffect as pt, useMemo as ht } from "react";
4
+ import { evaluateNumeric as xt } from "../lib/expression.js";
5
+ function ft(s) {
6
+ return `color-mix(in srgb, ${s} 55%, white)`;
7
7
  }
8
- const fe = {
8
+ const Se = {
9
9
  // Brand ink for TEXT: the raw brand (cyan on white ≈ 1.6:1) is a fill
10
10
  // colour, not a text colour — mix toward black in light mode, raw in dark.
11
11
  accent: ["color-mix(in srgb, rgb(var(--nvr-cyan-rgb)) 56%, black)", "rgb(var(--nvr-cyan-rgb))"],
@@ -19,12 +19,12 @@ const fe = {
19
19
  warning: ["var(--nvr-role-warning, #b45309)", "var(--nvr-role-warning-dark, #d4936a)"],
20
20
  info: ["var(--nvr-role-info, #4f46e5)", "var(--nvr-role-info-dark, #8fa6c9)"]
21
21
  };
22
- function xe(i, r) {
23
- var M, k;
24
- const x = fe[i.trim().toLowerCase()];
25
- return x ? [x[0], r ? ((M = fe[r]) == null ? void 0 : M[1]) ?? r : x[1]] : [i, r ? ((k = fe[r]) == null ? void 0 : k[1]) ?? r : Xe(i)];
22
+ function Ce(s, t) {
23
+ var c, u;
24
+ const m = Se[s.trim().toLowerCase()];
25
+ return m ? [m[0], t ? ((c = Se[t]) == null ? void 0 : c[1]) ?? t : m[1]] : [s, t ? ((u = Se[t]) == null ? void 0 : u[1]) ?? t : ft(s)];
26
26
  }
27
- const Ze = /^[-+−]?\$?0(?:\.0+)?%?$/, ke = (i) => i === "—" ? /* @__PURE__ */ s("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) : Ze.test(i) ? /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-slate-400", children: i }) : i, Te = [
27
+ const kt = /^[-+−]?\$?0(?:\.0+)?%?$/, qe = (s) => s === "—" ? /* @__PURE__ */ o("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) : kt.test(s) ? /* @__PURE__ */ o("span", { className: "text-slate-500 dark:text-slate-400", children: s }) : s, Ge = [
28
28
  "jan",
29
29
  "feb",
30
30
  "mar",
@@ -37,7 +37,7 @@ const Ze = /^[-+−]?\$?0(?:\.0+)?%?$/, ke = (i) => i === "—" ? /* @__PURE__ *
37
37
  "oct",
38
38
  "nov",
39
39
  "dec"
40
- ], je = [
40
+ ], yt = [
41
41
  "Jan",
42
42
  "Feb",
43
43
  "Mar",
@@ -50,169 +50,190 @@ const Ze = /^[-+−]?\$?0(?:\.0+)?%?$/, ke = (i) => i === "—" ? /* @__PURE__ *
50
50
  "Oct",
51
51
  "Nov",
52
52
  "Dec"
53
- ];
54
- function et(i, r, x, M = "month") {
55
- const k = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Set();
56
- for (const m of i) {
57
- const W = r.key_fields.map((_) => String(m[_] ?? "")).join("|");
58
- let u = k.get(W);
59
- if (!u) {
60
- u = {};
61
- for (const _ of r.key_fields) u[_] = m[_];
62
- k.set(W, u);
53
+ ], vt = "Undated";
54
+ function Nt(s, t, m, c = "month") {
55
+ const u = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set();
56
+ let y = !1;
57
+ for (const h of s) {
58
+ const A = t.key_fields.map((O) => String(h[O] ?? "")).join("|");
59
+ let w = u.get(A);
60
+ if (!w) {
61
+ w = {};
62
+ for (const O of t.key_fields) w[O] = h[O];
63
+ u.set(A, w);
63
64
  }
64
- const de = String(m[r.date_field] ?? ""), w = /^(\d{4})-(\d{2})/.exec(de);
65
- if (!w) continue;
66
- const A = Number(m[r.value_field]) || 0;
67
- if (Number(w[1]) === x) {
68
- const _ = Number(w[2]) - 1, C = M === "quarter" ? `q${Math.floor(_ / 3) + 1}` : Te[_];
69
- C && (u[C] = (Number(u[C]) || 0) + A);
65
+ const z = String(h[t.date_field] ?? ""), I = /^(\d{4})-(\d{2})/.exec(z);
66
+ if (!I) {
67
+ if (z !== vt) continue;
68
+ const O = Number(h[t.value_field]) || 0;
69
+ y = !0, w.undated = (Number(w.undated) || 0) + O, t.total !== !1 && (w.total = (Number(w.total) || 0) + O);
70
+ continue;
71
+ }
72
+ const V = Number(h[t.value_field]) || 0;
73
+ if (Number(I[1]) === m) {
74
+ const O = Number(I[2]) - 1, k = c === "quarter" ? `q${Math.floor(O / 3) + 1}` : Ge[O];
75
+ k && (w[k] = (Number(w[k]) || 0) + V);
70
76
  } else
71
- R.add(w[1]), u[`y${w[1]}`] = (Number(u[`y${w[1]}`]) || 0) + A;
72
- r.total !== !1 && (u.total = (Number(u.total) || 0) + A);
77
+ g.add(I[1]), w[`y${I[1]}`] = (Number(w[`y${I[1]}`]) || 0) + V;
78
+ t.total !== !1 && (w.total = (Number(w.total) || 0) + V);
73
79
  }
74
- const oe = [...R].filter((m) => Number(m) < x).sort(), E = [...R].filter((m) => Number(m) > x).sort(), G = M === "quarter" ? [1, 2, 3, 4].map((m) => ({
75
- field: `q${m}`,
76
- label: `Q${m}`,
80
+ const v = [...g].filter((h) => Number(h) < m).sort(), L = [...g].filter((h) => Number(h) > m).sort(), se = c === "quarter" ? [1, 2, 3, 4].map((h) => ({
81
+ field: `q${h}`,
82
+ label: `Q${h}`,
77
83
  format: "currency",
78
84
  sum: !0
79
- })) : Te.map((m, W) => ({
80
- field: m,
81
- label: je[W],
85
+ })) : Ge.map((h, A) => ({
86
+ field: h,
87
+ label: yt[A],
82
88
  format: "currency",
83
89
  sum: !0
84
- })), L = r.color ? { color: r.color, color_negative: r.color_negative } : {}, ne = [
85
- ...oe.map((m) => ({
86
- field: `y${m}`,
87
- label: m,
90
+ })), K = t.color ? { color: t.color, color_negative: t.color_negative } : {}, q = [
91
+ ...v.map((h) => ({
92
+ field: `y${h}`,
93
+ label: h,
88
94
  format: "currency",
89
95
  sum: !0,
90
- ...L
96
+ ...K
91
97
  })),
92
- ...G.map((m) => ({ ...m, ...L })),
93
- ...E.map((m) => ({
94
- field: `y${m}`,
95
- label: m,
98
+ ...se.map((h) => ({ ...h, ...K })),
99
+ ...L.map((h) => ({
100
+ field: `y${h}`,
101
+ label: h,
96
102
  format: "currency",
97
103
  sum: !0,
98
- ...L
104
+ ...K
99
105
  })),
100
- ...r.total !== !1 ? [
106
+ ...y ? [{ field: "undated", label: "Undated", format: "currency", sum: !0, ...K }] : [],
107
+ ...t.total !== !1 ? [
101
108
  {
102
109
  field: "total",
103
110
  label: "Total",
104
111
  format: "currency",
105
112
  sum: !0,
106
- ...r.total_color ? { color: r.total_color, color_negative: r.color_negative } : L
113
+ ...t.total_color ? { color: t.total_color, color_negative: t.color_negative } : K
107
114
  }
108
115
  ] : []
109
116
  ];
110
- return { rows: [...k.values()], columns: ne };
117
+ return { rows: [...u.values()], columns: q };
118
+ }
119
+ const gt = (s) => s != null && s !== "" && Number.isFinite(Number(s));
120
+ function wt(s, t) {
121
+ const m = {}, c = (u, g) => {
122
+ let y = !1, v = 0;
123
+ for (const L of s)
124
+ gt(L[u]) && (y = !0, v += Number(L[u]));
125
+ m[u] = y || !g || m[u] === 0 ? v : null;
126
+ };
127
+ for (const u of t) {
128
+ const g = u.null_when_empty ?? u.format === "currency";
129
+ u.field && c(u.field, g), u.stack && c(u.stack, g);
130
+ }
131
+ return m;
111
132
  }
112
- function I(i, r) {
113
- return Ye(i, r);
133
+ function j(s, t) {
134
+ return xt(s, t);
114
135
  }
115
- function se(i, r) {
116
- if (i == null || i === "") return "—";
117
- const x = Number(i);
118
- if (!Number.isFinite(x)) return String(i);
119
- switch (r) {
136
+ function ae(s, t) {
137
+ if (s == null || s === "") return "—";
138
+ const m = Number(s);
139
+ if (!Number.isFinite(m)) return String(s);
140
+ switch (t) {
120
141
  case "currency": {
121
- const M = Number.isInteger(x);
122
- return x.toLocaleString("en-US", {
142
+ const c = Number.isInteger(m);
143
+ return m.toLocaleString("en-US", {
123
144
  style: "currency",
124
145
  currency: "USD",
125
- minimumFractionDigits: M ? 0 : 2,
146
+ minimumFractionDigits: c ? 0 : 2,
126
147
  maximumFractionDigits: 2
127
148
  });
128
149
  }
129
150
  case "percent":
130
- return `${x.toLocaleString("en-US", { maximumFractionDigits: 1 })}%`;
151
+ return `${m.toLocaleString("en-US", { maximumFractionDigits: 1 })}%`;
131
152
  case "number":
132
- return x.toLocaleString("en-US", { maximumFractionDigits: 2 });
153
+ return m.toLocaleString("en-US", { maximumFractionDigits: 2 });
133
154
  default:
134
- return String(i);
155
+ return String(s);
135
156
  }
136
157
  }
137
- function ge(i) {
138
- return i.replace(/_/g, " ").replace(/\b\w/g, (r) => r.toUpperCase());
158
+ function le(s) {
159
+ return s.replace(/_/g, " ").replace(/\b\w/g, (t) => t.toUpperCase());
139
160
  }
140
- function st({
141
- rows: i,
142
- config: r,
143
- onRowClick: x,
144
- pivotYear: M,
145
- rowActions: k,
146
- emptyLabel: R,
147
- emptyText: oe
161
+ function Lt({
162
+ rows: s,
163
+ config: t,
164
+ onRowClick: m,
165
+ pivotYear: c,
166
+ rowActions: u,
167
+ emptyLabel: g,
168
+ emptyText: y
148
169
  }) {
149
- var Ce, qe, Fe, Me, Oe, Ee, ze;
150
- const [E, G] = Y(() => /* @__PURE__ */ new Set()), [L, ne] = Y("month"), [m, W] = Y(
151
- () => new Set(((r == null ? void 0 : r.toggles) ?? []).filter((e) => e.default_on === !1).map((e) => e.label))
152
- ), [u, de] = Y(null), [w, A] = Y({
170
+ var De, Re, ze, Ie, He, We, Ke, Ae, Je, je;
171
+ const [v, L] = W(() => /* @__PURE__ */ new Set()), [se, K] = W("month"), [q, h] = W(null), [A, w] = W(""), [z, I] = W(!!((De = t == null ? void 0 : t.hide_empty) != null && De.default_on)), [V, O] = W(
172
+ () => new Set(((t == null ? void 0 : t.toggles) ?? []).filter((e) => e.default_on === !1).map((e) => e.label))
173
+ ), [k, Ye] = W(null), [oe, Xe] = W({
153
174
  overflows: !1,
154
175
  canScrollRight: !1,
155
176
  cueInset: { right: 0, bottom: 0 }
156
177
  });
157
- if (Ve(() => {
158
- if (!u) return;
178
+ if (pt(() => {
179
+ if (!k) return;
159
180
  const e = () => {
160
- const a = u.scrollWidth > u.clientWidth + 1, n = u.scrollWidth > u.clientWidth + u.scrollLeft + 1, l = u.querySelector("[data-qt-actions-head]"), o = r != null && r.sticky && l ? l.offsetWidth : 0, b = u.offsetWidth - u.clientWidth + o, N = u.offsetHeight - u.clientHeight;
161
- A(
162
- (F) => F.overflows === a && F.canScrollRight === n && F.cueInset.right === b && F.cueInset.bottom === N ? F : { overflows: a, canScrollRight: n, cueInset: { right: b, bottom: N } }
181
+ const a = k.scrollWidth > k.clientWidth + 1, n = k.scrollWidth > k.clientWidth + k.scrollLeft + 1, l = k.querySelector("[data-qt-actions-head]"), d = t != null && t.sticky && l ? l.offsetWidth : 0, b = k.offsetWidth - k.clientWidth + d, F = k.offsetHeight - k.clientHeight;
182
+ Xe(
183
+ (D) => D.overflows === a && D.canScrollRight === n && D.cueInset.right === b && D.cueInset.bottom === F ? D : { overflows: a, canScrollRight: n, cueInset: { right: b, bottom: F } }
163
184
  );
164
185
  };
165
186
  e();
166
- const t = new ResizeObserver(e);
167
- return t.observe(u), u.firstElementChild && t.observe(u.firstElementChild), u.addEventListener("scroll", e, { passive: !0 }), () => {
168
- t.disconnect(), u.removeEventListener("scroll", e);
187
+ const r = new ResizeObserver(e);
188
+ return r.observe(k), k.firstElementChild && r.observe(k.firstElementChild), k.addEventListener("scroll", e, { passive: !0 }), () => {
189
+ r.disconnect(), k.removeEventListener("scroll", e);
169
190
  };
170
- }, [u, r == null ? void 0 : r.sticky]), !i || i.length === 0)
171
- return /* @__PURE__ */ s("p", { className: "px-1 py-2 text-[12px] italic text-slate-400", children: oe || (R ? `No ${R.toLowerCase()} yet` : "No data") });
172
- let _ = null;
173
- if (r != null && r.pivot) {
174
- const e = M ?? r.pivot.year ?? (/* @__PURE__ */ new Date()).getFullYear(), t = et(i, r.pivot, e, L);
175
- i = t.rows, _ = t.columns;
191
+ }, [k, t == null ? void 0 : t.sticky]), !s || s.length === 0)
192
+ return /* @__PURE__ */ o("p", { className: "px-1 py-2 text-[12px] italic text-slate-400", children: y || (g ? `No ${g.toLowerCase()} yet` : "No data") });
193
+ let xe = null;
194
+ if (t != null && t.pivot) {
195
+ const e = c ?? t.pivot.year ?? (/* @__PURE__ */ new Date()).getFullYear(), r = Nt(s, t.pivot, e, se);
196
+ s = r.rows, xe = r.columns;
176
197
  }
177
- let C = i;
178
- if (r != null && r.group_by) {
179
- const e = r.group_by, t = /* @__PURE__ */ new Map();
180
- for (const a of i) {
181
- const n = String(a[e] ?? "—"), l = t.get(n);
198
+ let S = s;
199
+ if (t != null && t.group_by) {
200
+ const e = t.group_by, r = /* @__PURE__ */ new Map();
201
+ for (const a of s) {
202
+ const n = String(a[e] ?? "—"), l = r.get(n);
182
203
  if (!l) {
183
- t.set(n, { ...a, [e]: n });
204
+ r.set(n, { ...a, [e]: n });
184
205
  continue;
185
206
  }
186
- for (const [o, b] of Object.entries(a)) {
187
- if (o === e) continue;
188
- const N = Number(b);
189
- Number.isFinite(N) && typeof b != "boolean" && (l[o] = (Number(l[o]) || 0) + N);
207
+ for (const [d, b] of Object.entries(a)) {
208
+ if (d === e) continue;
209
+ const F = Number(b);
210
+ Number.isFinite(F) && typeof b != "boolean" && (l[d] = (Number(l[d]) || 0) + F);
190
211
  }
191
212
  }
192
- C = [...t.entries()].sort(([a], [n]) => a.localeCompare(n)).map(([, a]) => a);
213
+ S = [...r.entries()].sort(([a], [n]) => a.localeCompare(n)).map(([, a]) => a);
193
214
  }
194
- const ye = _ ? [
215
+ const Fe = xe ? [
195
216
  // Key columns first (configured, else the pivot's key fields), then
196
217
  // the generated year/month/total columns.
197
- ...(Ce = r == null ? void 0 : r.columns) != null && Ce.length ? r.columns : (((qe = r == null ? void 0 : r.pivot) == null ? void 0 : qe.key_fields) ?? []).map((e) => ({ field: e })),
198
- ..._
199
- ] : r != null && r.columns && r.columns.length > 0 ? r.columns : Object.keys(C[0]).map((e) => ({ field: e })), B = /* @__PURE__ */ new Set();
218
+ ...(Re = t == null ? void 0 : t.columns) != null && Re.length ? t.columns : (((ze = t == null ? void 0 : t.pivot) == null ? void 0 : ze.key_fields) ?? []).map((e) => ({ field: e })),
219
+ ...xe
220
+ ] : t != null && t.columns && t.columns.length > 0 ? t.columns : Object.keys(S[0]).map((e) => ({ field: e })), Y = /* @__PURE__ */ new Set();
200
221
  {
201
222
  const e = [];
202
- for (const t of ye)
203
- t.field && e.push(t.field), t.stack && e.push(t.stack);
204
- for (const t of (r == null ? void 0 : r.toggles) ?? []) {
205
- const a = !m.has(t.label);
206
- if (t.hide_when_on ? a : !a)
223
+ for (const r of Fe)
224
+ r.field && e.push(r.field), r.stack && e.push(r.stack);
225
+ for (const r of (t == null ? void 0 : t.toggles) ?? []) {
226
+ const a = !V.has(r.label);
227
+ if (r.hide_when_on ? a : !a)
207
228
  for (const l of e)
208
- ((Fe = t.fields) != null && Fe.includes(l) || t.suffix && l.endsWith(t.suffix)) && B.add(l);
229
+ ((Ie = r.fields) != null && Ie.includes(l) || r.suffix && l.endsWith(r.suffix)) && Y.add(l);
209
230
  }
210
231
  }
211
- const h = ye.filter((e) => {
232
+ const f = Fe.filter((e) => {
212
233
  if (!e.field) return !0;
213
- const t = B.has(e.field), a = e.stack ? B.has(e.stack) : !0;
214
- return !(t && a);
215
- }), ve = (e) => !!e.field && !B.has(e.field), Ne = (e) => !!e.stack && !B.has(e.stack), We = [
234
+ const r = Y.has(e.field), a = e.stack ? Y.has(e.stack) : !0;
235
+ return !(r && a);
236
+ }), fe = (e) => !!e.field && !Y.has(e.field), Ee = (e) => !!e.stack && !Y.has(e.stack), Ze = [
216
237
  "Jan",
217
238
  "Feb",
218
239
  "Mar",
@@ -225,75 +246,88 @@ function st({
225
246
  "Oct",
226
247
  "Nov",
227
248
  "Dec"
228
- ], X = (r == null ? void 0 : r.highlight_group) === "$current_month" ? We[(/* @__PURE__ */ new Date()).getMonth()] : (r == null ? void 0 : r.highlight_group) ?? null, $e = (e) => !!X && (e.group === X || !e.group && e.label === X), Z = (e) => $e(e) ? "bg-[#6366f10f] dark:bg-[#a5b4fc12]" : "", Q = (e, t) => {
249
+ ], ne = (t == null ? void 0 : t.highlight_group) === "$current_month" ? Ze[(/* @__PURE__ */ new Date()).getMonth()] : (t == null ? void 0 : t.highlight_group) ?? null, Le = (e) => !!ne && (e.group === ne || !e.group && e.label === ne), de = (e) => Le(e) ? "bg-[#6366f10f] dark:bg-[#a5b4fc12]" : "", X = (e, r) => {
229
250
  if (!e.color) return;
230
- const a = e.color_negative && typeof t == "number" && t < 0, [n, l] = a ? xe(e.color_negative) : xe(e.color, e.color_dark);
251
+ const a = e.color_negative && typeof r == "number" && r < 0, [n, l] = a ? Ce(e.color_negative) : Ce(e.color, e.color_dark);
231
252
  return { "--qtc": n, "--qtcd": l };
232
- }, ie = (e, t) => e.color ? "text-[color:var(--qtc)] dark:text-[color:var(--qtcd)]" : t, ue = (e) => {
253
+ }, ke = (e, r) => e.color ? "text-[color:var(--qtc)] dark:text-[color:var(--qtcd)]" : r, ye = (e) => {
233
254
  if (!e.stack_color) return;
234
- const [t, a] = xe(e.stack_color, e.stack_color_dark);
235
- return { "--qts": t, "--qtsd": a };
236
- }, z = (e, t) => t.formula ? I(t.formula, e) : t.field ? e[t.field] : null, He = Pe(() => {
255
+ const [r, a] = Ce(e.stack_color, e.stack_color_dark);
256
+ return { "--qts": r, "--qtsd": a };
257
+ }, T = (e, r) => r.formula ? j(r.formula, e) : r.field ? e[r.field] : null, et = ht(() => {
237
258
  const e = /* @__PURE__ */ new Map();
238
- for (const t of (r == null ? void 0 : r.columns) ?? [])
239
- !t.percent_of_total || !t.field || e.set(
240
- t.field,
241
- i.reduce((a, n) => a + (Number(n[t.field]) || 0), 0)
259
+ for (const r of (t == null ? void 0 : t.columns) ?? [])
260
+ !r.percent_of_total || !r.field || e.set(
261
+ r.field,
262
+ s.reduce((a, n) => a + (Number(n[r.field]) || 0), 0)
242
263
  );
243
264
  return e;
244
- }, [i, r]), Ue = (e, t) => {
245
- const a = Number(z(e, t)), n = t.progress_max ? t.progress_max.includes("{{") ? I(t.progress_max, e) : Number(e[t.progress_max]) : null, l = n && Number.isFinite(n) && n > 0 && Number.isFinite(a) ? a / n * 100 : null;
265
+ }, [s, t]), tt = (e, r) => {
266
+ const a = Number(T(e, r)), n = r.progress_max ? r.progress_max.includes("{{") ? j(r.progress_max, e) : Number(e[r.progress_max]) : null, l = n && Number.isFinite(n) && n > 0 && Number.isFinite(a) ? a / n * 100 : null;
246
267
  return /* @__PURE__ */ p(
247
268
  "div",
248
269
  {
249
270
  className: "flex min-w-[130px] items-center justify-end gap-1.5",
250
- title: l === null ? void 0 : `${l.toLocaleString("en-US", { maximumFractionDigits: 1 })}% of ${se(n, t.format)}`,
271
+ title: l === null ? void 0 : `${l.toLocaleString("en-US", { maximumFractionDigits: 1 })}% of ${ae(n, r.format)}`,
251
272
  children: [
252
- /* @__PURE__ */ s("span", { children: se(z(e, t), t.format) }),
253
- /* @__PURE__ */ s("div", { className: "h-1 w-10 shrink-0 overflow-hidden rounded-full bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ s(
273
+ /* @__PURE__ */ o("span", { children: ae(T(e, r), r.format) }),
274
+ /* @__PURE__ */ o("div", { className: "h-1 w-10 shrink-0 overflow-hidden rounded-full bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ o(
254
275
  "div",
255
276
  {
256
277
  className: `h-full rounded-full ${l !== null && l > 100 ? "bg-red-500" : "bg-nvr-cyan"}`,
257
278
  style: { width: `${l === null ? 0 : Math.min(l, 100)}%` }
258
279
  }
259
280
  ) }),
260
- /* @__PURE__ */ s("span", { className: "w-9 shrink-0 text-right text-[10px] tabular-nums text-slate-400", children: l === null ? "—" : `${l.toLocaleString("en-US", { maximumFractionDigits: 0 })}%` })
281
+ /* @__PURE__ */ o("span", { className: "w-9 shrink-0 text-right text-[10px] tabular-nums text-slate-400", children: l === null ? "—" : `${l.toLocaleString("en-US", { maximumFractionDigits: 0 })}%` })
261
282
  ]
262
283
  }
263
284
  );
264
- };
265
- let H = null;
266
- if (r != null && r.totals) {
267
- const e = {}, t = (a) => {
268
- e[a] = C.reduce((n, l) => {
269
- const o = Number(l[a]);
270
- return Number.isFinite(o) ? n + o : n;
271
- }, 0);
272
- };
273
- for (const a of h)
274
- a.field && t(a.field), a.stack && t(a.stack);
275
- H = e;
285
+ }, Z = ((He = t == null ? void 0 : t.hide_empty) == null ? void 0 : He.fields) ?? [];
286
+ Z.length > 0 && z && (S = S.filter(
287
+ (e) => Z.some((r) => {
288
+ const a = e[r];
289
+ return a != null && a !== "" && Number(a) !== 0;
290
+ })
291
+ ));
292
+ const ie = t != null && t.search ? A.trim().toLowerCase() : "";
293
+ ie && (S = S.filter(
294
+ (e) => f.some((r) => {
295
+ const a = T(e, r);
296
+ return a == null || a === "" ? !1 : String(a).toLowerCase().includes(ie) || ae(a, r.format).toLowerCase().includes(ie);
297
+ })
298
+ ));
299
+ const ve = !!(t != null && t.sortable) && !(t != null && t.tree_group_by), ee = (e, r) => e.field ?? e.label ?? String(r);
300
+ if (ve && q) {
301
+ const e = f.findIndex((a, n) => ee(a, n) === q.key), r = e >= 0 ? f[e] : null;
302
+ r && (S = [...S].sort(
303
+ (a, n) => $t(T(a, r), T(n, r), q.dir)
304
+ ));
276
305
  }
277
- const q = (e) => e.format && e.format !== "text", be = (e, t) => {
278
- if (!(r != null && r.row_format_field) || !q(t)) return t.format;
279
- const a = e[r.row_format_field];
280
- return a === "currency" || a === "number" ? a : t.format;
281
- }, T = (e, t) => r != null && r.zero_dash && Number(e) === 0 ? "—" : se(e, t), j = (e, t) => {
306
+ const rt = (e) => h(
307
+ (r) => !r || r.key !== e ? { key: e, dir: 1 } : r.dir === 1 ? { key: e, dir: -1 } : null
308
+ );
309
+ let B = null;
310
+ t != null && t.totals && (B = wt(S, f));
311
+ const M = (e) => e.format && e.format !== "text", Ne = (e, r) => {
312
+ if (!(t != null && t.row_format_field) || !M(r)) return r.format;
313
+ const a = e[t.row_format_field];
314
+ return a === "currency" || a === "number" ? a : r.format;
315
+ }, J = (e, r) => t != null && t.zero_dash && Number(e) === 0 ? "—" : ae(e, r), ue = (e, r) => {
282
316
  var n;
283
- if ((n = t.sparkline_fields) != null && n.length) {
284
- const l = t.sparkline_fields.map((d) => Number(e[d]) || 0), o = Math.max(...l, 1), b = Math.min(...l, 0), N = Math.max(o - b, 1), F = l.map(
285
- (d, f) => `${f / Math.max(l.length - 1, 1) * 60},${17 - (d - b) / N * 15}`
317
+ if ((n = r.sparkline_fields) != null && n.length) {
318
+ const l = r.sparkline_fields.map((i) => Number(e[i]) || 0), d = Math.max(...l, 1), b = Math.min(...l, 0), F = Math.max(d - b, 1), D = l.map(
319
+ (i, N) => `${N / Math.max(l.length - 1, 1) * 60},${17 - (i - b) / F * 15}`
286
320
  ).join(" ");
287
- return /* @__PURE__ */ s(
321
+ return /* @__PURE__ */ o(
288
322
  "svg",
289
323
  {
290
324
  viewBox: "0 0 60 18",
291
325
  className: "inline-block h-[18px] w-[60px]",
292
- "data-tip": l.map((d) => se(d, t.format)).join(" · "),
293
- children: /* @__PURE__ */ s(
326
+ "data-tip": l.map((i) => ae(i, r.format)).join(" · "),
327
+ children: /* @__PURE__ */ o(
294
328
  "polyline",
295
329
  {
296
- points: F,
330
+ points: D,
297
331
  fill: "none",
298
332
  stroke: "#00a5cc",
299
333
  strokeWidth: "1.5",
@@ -303,202 +337,202 @@ function st({
303
337
  }
304
338
  );
305
339
  }
306
- if (t.percent_of_total && t.field) {
307
- const l = Number(z(e, t)), o = He.get(t.field) ?? 0, b = o > 0 && Number.isFinite(l) ? l / o * 100 : null;
340
+ if (r.percent_of_total && r.field) {
341
+ const l = Number(T(e, r)), d = et.get(r.field) ?? 0, b = d > 0 && Number.isFinite(l) ? l / d * 100 : null;
308
342
  return /* @__PURE__ */ p("span", { className: "inline-flex items-baseline gap-1", children: [
309
- T(z(e, t), t.format),
343
+ J(T(e, r), r.format),
310
344
  b != null && /* @__PURE__ */ p("span", { className: "text-[9.5px] text-slate-400", children: [
311
345
  b.toLocaleString("en-US", { maximumFractionDigits: 1 }),
312
346
  "%"
313
347
  ] })
314
348
  ] });
315
349
  }
316
- if (t.display === "progress") return Ue(e, t);
317
- if (t.stack)
318
- return /* @__PURE__ */ p("span", { className: "inline-flex flex-col items-end leading-[15px]", style: ue(t), children: [
319
- ve(t) && /* @__PURE__ */ s("span", { children: ke(T(z(e, t), be(e, t))) }),
320
- Ne(t) && /* @__PURE__ */ s(
350
+ if (r.display === "progress") return tt(e, r);
351
+ if (r.stack)
352
+ return /* @__PURE__ */ p("span", { className: "inline-flex flex-col items-end leading-[15px]", style: ye(r), children: [
353
+ fe(r) && /* @__PURE__ */ o("span", { children: qe(J(T(e, r), Ne(e, r))) }),
354
+ Ee(r) && /* @__PURE__ */ o(
321
355
  "span",
322
356
  {
323
- className: `text-[10.5px] ${t.stack_color ? "text-[color:var(--qts)] dark:text-[color:var(--qtsd)]" : "text-slate-400"}`,
324
- children: ke(T(e[t.stack], be(e, t)))
357
+ className: `text-[10.5px] ${r.stack_color ? "text-[color:var(--qts)] dark:text-[color:var(--qtsd)]" : "text-slate-400"}`,
358
+ children: qe(J(e[r.stack], Ne(e, r)))
325
359
  }
326
360
  )
327
361
  ] });
328
- const a = z(e, t);
329
- return t.empty_label !== void 0 && (a == null || a === "") ? t.empty_label ? /* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-slate-400", children: t.empty_label }) : null : ke(T(a, be(e, t)));
330
- }, we = h.some((e) => e.group), me = [];
362
+ const a = T(e, r);
363
+ return r.empty_label !== void 0 && (a == null || a === "") ? r.empty_label ? /* @__PURE__ */ o("span", { className: "text-slate-500 dark:text-slate-400", children: r.empty_label }) : null : qe(J(a, Ne(e, r)));
364
+ }, Oe = f.some((e) => e.group), ge = [];
331
365
  {
332
- let e = -1, t;
333
- for (const a of h)
334
- a.group && a.group !== t && e++, me.push(a.group ? e : -1), t = a.group;
366
+ let e = -1, r;
367
+ for (const a of f)
368
+ a.group && a.group !== r && e++, ge.push(a.group ? e : -1), r = a.group;
335
369
  }
336
- const ce = (e) => we && me[e] >= 0 && me[e] % 2 === 1 ? "bg-slate-50/70 dark:bg-muted/20" : "", g = !!(r != null && r.sticky), V = "border-r border-slate-200 dark:border-border", Je = (e, t) => g && e === 0 ? `sticky left-0 z-[1] ${V} ${t}` : "", _e = (e) => g ? e === 0 ? `sticky left-0 top-0 z-[3] ${V} bg-slate-50 dark:bg-muted` : "sticky top-0 z-[2] bg-white dark:bg-card" : "", U = (e) => g && (e === 0 || e === 1) ? "pl-3" : "", ee = w.overflows ? "border-l border-slate-200 dark:border-border" : "", pe = (e) => g ? `sticky right-0 z-[2] ${ee} ${e}` : "", P = (e, t, a = 0, n) => {
370
+ const we = (e) => Oe && ge[e] >= 0 && ge[e] % 2 === 1 ? "bg-slate-50/70 dark:bg-muted/20" : "", $ = !!(t != null && t.sticky), te = "border-r border-slate-200 dark:border-border", at = (e, r) => $ && e === 0 ? `sticky left-0 z-[1] ${te} ${r}` : "", Te = (e) => $ ? e === 0 ? `sticky left-0 top-0 z-[3] ${te} bg-slate-50 dark:bg-muted` : "sticky top-0 z-[2] bg-white dark:bg-card" : "", G = (e) => $ && (e === 0 || e === 1) ? "pl-3" : "", me = oe.overflows ? "border-l border-slate-200 dark:border-border" : "", $e = (e) => $ ? `sticky right-0 z-[2] ${me} ${e}` : "", re = (e, r, a = 0, n) => {
337
371
  const l = a === !0 ? 1 : a === !1 ? 0 : a;
338
372
  return /* @__PURE__ */ p(
339
373
  "tr",
340
374
  {
341
- onClick: x ? () => x(e) : void 0,
342
- className: `group/qtr border-b border-slate-100 dark:border-border/50 ${x ? "cursor-pointer" : ""} ${l >= 2 ? "bg-sky-50/70 hover:bg-sky-100/60 dark:bg-sky-500/10 dark:hover:bg-sky-500/15" : "hover:bg-slate-50 dark:hover:bg-muted/40"}`,
375
+ onClick: m ? () => m(e) : void 0,
376
+ className: `group/qtr border-b border-slate-100 dark:border-border/50 ${m ? "cursor-pointer" : ""} ${l >= 2 ? "bg-sky-50/70 hover:bg-sky-100/60 dark:bg-sky-500/10 dark:hover:bg-sky-500/15" : "hover:bg-slate-50 dark:hover:bg-muted/40"}`,
343
377
  children: [
344
- h.map((o, b) => /* @__PURE__ */ s(
378
+ f.map((d, b) => /* @__PURE__ */ o(
345
379
  "td",
346
380
  {
347
- className: `whitespace-nowrap py-1.5 pr-3 ${o.max_width ? "overflow-hidden text-ellipsis" : ""} ${U(b)} ${ie(o, "text-slate-700 dark:text-slate-200")} ${q(o) ? "text-right tabular-nums" : ""} ${o.group ? "min-w-[58px]" : ""} ${Z(o) || ce(b)} ${Je(b, "bg-slate-50 group-hover/qtr:bg-slate-100 dark:bg-muted dark:group-hover/qtr:bg-muted")}`,
381
+ className: `whitespace-nowrap py-1.5 pr-3 ${d.max_width ? "overflow-hidden text-ellipsis" : ""} ${G(b)} ${ke(d, "text-slate-700 dark:text-slate-200")} ${M(d) ? "text-right tabular-nums" : ""} ${d.group ? "min-w-[58px]" : ""} ${de(d) || we(b)} ${at(b, "bg-slate-50 group-hover/qtr:bg-slate-100 dark:bg-muted dark:group-hover/qtr:bg-muted")}`,
348
382
  style: {
349
383
  ...l > 0 && b === 0 ? { paddingLeft: 2 + l * 16 } : {},
350
- ...o.max_width ? { maxWidth: o.max_width } : {},
351
- ...Q(o, Number(z(e, o))) ?? {}
384
+ ...d.max_width ? { maxWidth: d.max_width } : {},
385
+ ...X(d, Number(T(e, d))) ?? {}
352
386
  },
353
- title: o.max_width ? String(z(e, o) ?? "") : void 0,
354
- children: b === 0 && n !== void 0 ? n : j(e, o)
387
+ title: d.max_width ? String(T(e, d) ?? "") : void 0,
388
+ children: b === 0 && n !== void 0 ? n : ue(e, d)
355
389
  },
356
- o.field ?? o.label ?? b
390
+ d.field ?? d.label ?? b
357
391
  )),
358
- k && /* @__PURE__ */ s(
392
+ u && /* @__PURE__ */ o(
359
393
  "td",
360
394
  {
361
- className: `py-1 pl-2 pr-3 text-right ${pe(
395
+ className: `py-1 pl-2 pr-3 text-right ${$e(
362
396
  l >= 2 ? "bg-[#f3f9fe] group-hover/qtr:bg-[#e7f3fd] dark:bg-card dark:group-hover/qtr:bg-muted" : "bg-white group-hover/qtr:bg-slate-50 dark:bg-card dark:group-hover/qtr:bg-muted"
363
397
  )}`,
364
- children: /* @__PURE__ */ s("span", { className: "inline-flex flex-nowrap gap-1", children: k.map((o) => /* @__PURE__ */ s(
398
+ children: /* @__PURE__ */ o("span", { className: "inline-flex flex-nowrap gap-1", children: u.map((d) => /* @__PURE__ */ o(
365
399
  "button",
366
400
  {
367
401
  type: "button",
368
402
  onClick: (b) => {
369
- b.stopPropagation(), o.onClick(e);
403
+ b.stopPropagation(), d.onClick(e);
370
404
  },
371
405
  className: "whitespace-nowrap rounded border border-nvr-cyan/40 bg-nvr-cyan/10 px-1.5 py-0.5 text-[11px] text-slate-700 hover:brightness-105 dark:text-slate-200",
372
- children: o.label
406
+ children: d.label
373
407
  },
374
- o.label
408
+ d.label
375
409
  )) })
376
410
  }
377
411
  )
378
412
  ]
379
413
  },
380
- t
414
+ r
381
415
  );
382
416
  };
383
- let he;
384
- const J = [];
385
- if (r != null && r.tree_group_by) {
386
- const e = r.tree_group_by, t = C.filter((l) => !String(l[e] ?? "").trim()), a = /* @__PURE__ */ new Map();
387
- for (const l of C) {
388
- const o = String(l[e] ?? "").trim();
389
- if (!o) continue;
390
- const b = a.get(o) ?? [];
391
- b.push(l), a.set(o, b);
417
+ let _e;
418
+ const Q = [];
419
+ if (t != null && t.tree_group_by) {
420
+ const e = t.tree_group_by, r = S.filter((l) => !String(l[e] ?? "").trim()), a = /* @__PURE__ */ new Map();
421
+ for (const l of S) {
422
+ const d = String(l[e] ?? "").trim();
423
+ if (!d) continue;
424
+ const b = a.get(d) ?? [];
425
+ b.push(l), a.set(d, b);
392
426
  }
393
- const n = [...a.entries()].sort(([l], [o]) => l.localeCompare(o)).map(([l, o]) => {
394
- const b = r.tree_collapsed ? !E.has(l) : E.has(l);
395
- J.push({ key: l, startsCollapsed: !!r.tree_collapsed });
396
- const N = { [e]: l }, F = (d) => {
397
- N[d] = o.reduce((f, re) => {
398
- const K = Number(re[d]);
399
- return Number.isFinite(K) ? f + K : f;
427
+ const n = [...a.entries()].sort(([l], [d]) => l.localeCompare(d)).map(([l, d]) => {
428
+ const b = t.tree_collapsed ? !v.has(l) : v.has(l);
429
+ Q.push({ key: l, startsCollapsed: !!t.tree_collapsed });
430
+ const F = { [e]: l }, D = (i) => {
431
+ F[i] = d.reduce((N, ce) => {
432
+ const P = Number(ce[i]);
433
+ return Number.isFinite(P) ? N + P : N;
400
434
  }, 0);
401
435
  };
402
- for (const d of h)
403
- d.field && d.field !== e && F(d.field), d.stack && F(d.stack);
404
- return /* @__PURE__ */ s(
405
- Ie,
436
+ for (const i of f)
437
+ i.field && i.field !== e && D(i.field), i.stack && D(i.stack);
438
+ return /* @__PURE__ */ o(
439
+ Qe,
406
440
  {
407
441
  header: /* @__PURE__ */ p(
408
442
  "tr",
409
443
  {
410
444
  className: "cursor-pointer border-b border-slate-200 bg-slate-100/80 dark:border-border dark:bg-muted",
411
- onClick: () => G((d) => {
412
- const f = new Set(d);
413
- return f.has(l) ? f.delete(l) : f.add(l), f;
445
+ onClick: () => L((i) => {
446
+ const N = new Set(i);
447
+ return N.has(l) ? N.delete(l) : N.add(l), N;
414
448
  }),
415
449
  children: [
416
- h.map((d, f) => /* @__PURE__ */ s(
450
+ f.map((i, N) => /* @__PURE__ */ o(
417
451
  "td",
418
452
  {
419
- className: `whitespace-nowrap py-1.5 pr-3 ${U(f)} text-[11.5px] font-semibold ${ie(d, "text-slate-600 dark:text-slate-300")} ${q(d) ? "text-right tabular-nums" : ""} ${Z(d)} ${g && f === 0 ? `sticky left-0 z-[1] ${V} bg-slate-100 dark:bg-muted` : ""}`,
420
- style: Q(
421
- d,
422
- Number(d.formula ? I(d.formula, N) : N[d.field ?? ""])
453
+ className: `whitespace-nowrap py-1.5 pr-3 ${G(N)} text-[11.5px] font-semibold ${ke(i, "text-slate-600 dark:text-slate-300")} ${M(i) ? "text-right tabular-nums" : ""} ${de(i)} ${$ && N === 0 ? `sticky left-0 z-[1] ${te} bg-slate-100 dark:bg-muted` : ""}`,
454
+ style: X(
455
+ i,
456
+ Number(i.formula ? j(i.formula, F) : F[i.field ?? ""])
423
457
  ),
424
- children: f === 0 ? `${b ? "▸" : "▾"} ${l}` : d.formula ? T(I(d.formula, N), d.format) : d.field && d.field !== e && q(d) ? j(N, d) : ""
458
+ children: N === 0 ? `${b ? "▸" : "▾"} ${l}` : i.formula ? J(j(i.formula, F), i.format) : i.field && i.field !== e && M(i) ? ue(F, i) : ""
425
459
  },
426
- d.field ?? d.label ?? f
460
+ i.field ?? i.label ?? N
427
461
  )),
428
- k && /* @__PURE__ */ s("td", { className: pe("bg-slate-100 dark:bg-muted") })
462
+ u && /* @__PURE__ */ o("td", { className: $e("bg-slate-100 dark:bg-muted") })
429
463
  ]
430
464
  }
431
465
  ),
432
466
  children: !b && (() => {
433
- const d = r.tree_sub_split;
434
- if (!d)
435
- return o.map(($, S) => {
436
- var D;
437
- let v;
438
- if (r.tree_strip_section_prefix && ((D = h[0]) != null && D.field)) {
439
- const O = String($[h[0].field] ?? "");
440
- O.startsWith(`${l} - `) && (v = O.slice(l.length + 3));
467
+ const i = t.tree_sub_split;
468
+ if (!i)
469
+ return d.map((E, U) => {
470
+ var H;
471
+ let C;
472
+ if (t.tree_strip_section_prefix && ((H = f[0]) != null && H.field)) {
473
+ const R = String(E[f[0].field] ?? "");
474
+ R.startsWith(`${l} - `) && (C = R.slice(l.length + 3));
441
475
  }
442
- return P($, `${l}-${S}`, 1, v);
476
+ return re(E, `${l}-${U}`, 1, C);
443
477
  });
444
- const f = d.separator ?? " - ", re = [], K = /* @__PURE__ */ new Map();
445
- for (const $ of o) {
446
- const S = String($[d.field] ?? ""), v = S.lastIndexOf(f);
447
- if (v <= 0) {
448
- re.push($);
478
+ const N = i.separator ?? " - ", ce = [], P = /* @__PURE__ */ new Map();
479
+ for (const E of d) {
480
+ const U = String(E[i.field] ?? ""), C = U.lastIndexOf(N);
481
+ if (C <= 0) {
482
+ ce.push(E);
449
483
  continue;
450
484
  }
451
- const D = S.slice(0, v), O = K.get(D) ?? [];
452
- O.push($), K.set(D, O);
485
+ const H = U.slice(0, C), R = P.get(H) ?? [];
486
+ R.push(E), P.set(H, R);
453
487
  }
454
488
  return [
455
- ...re.map(($, S) => P($, `${l}-flat-${S}`, 1)),
456
- ...[...K.entries()].sort(([$], [S]) => $.localeCompare(S)).map(([$, S]) => {
457
- const v = `s:${l}|${$}`;
458
- J.push({
459
- key: v,
460
- startsCollapsed: r.tree_sub_collapsed ?? !0
489
+ ...ce.map((E, U) => re(E, `${l}-flat-${U}`, 1)),
490
+ ...[...P.entries()].sort(([E], [U]) => E.localeCompare(U)).map(([E, U]) => {
491
+ const C = `s:${l}|${E}`;
492
+ Q.push({
493
+ key: C,
494
+ startsCollapsed: t.tree_sub_collapsed ?? !0
461
495
  });
462
- const D = r.tree_sub_collapsed ?? !0 ? !E.has(v) : E.has(v), O = {}, De = (c) => {
463
- O[c] = S.reduce((y, ae) => {
464
- const le = Number(ae[c]);
465
- return Number.isFinite(le) ? y + le : y;
496
+ const H = t.tree_sub_collapsed ?? !0 ? !v.has(C) : v.has(C), R = {}, Ve = (x) => {
497
+ R[x] = U.reduce((_, pe) => {
498
+ const he = Number(pe[x]);
499
+ return Number.isFinite(he) ? _ + he : _;
466
500
  }, 0);
467
501
  };
468
- for (const c of h)
469
- c.field && c.field !== e && De(c.field), c.stack && De(c.stack);
470
- return /* @__PURE__ */ s(
471
- Ie,
502
+ for (const x of f)
503
+ x.field && x.field !== e && Ve(x.field), x.stack && Ve(x.stack);
504
+ return /* @__PURE__ */ o(
505
+ Qe,
472
506
  {
473
507
  header: /* @__PURE__ */ p(
474
508
  "tr",
475
509
  {
476
510
  className: "cursor-pointer border-b border-slate-200/80 bg-slate-100/70 dark:border-border/60 dark:bg-muted/50",
477
- onClick: () => G((c) => {
478
- const y = new Set(c);
479
- return y.has(v) ? y.delete(v) : y.add(v), y;
511
+ onClick: () => L((x) => {
512
+ const _ = new Set(x);
513
+ return _.has(C) ? _.delete(C) : _.add(C), _;
480
514
  }),
481
515
  children: [
482
- h.map((c, y) => /* @__PURE__ */ s(
516
+ f.map((x, _) => /* @__PURE__ */ o(
483
517
  "td",
484
518
  {
485
- className: `whitespace-nowrap py-1.5 pr-3 ${U(y)} text-[11.5px] font-medium text-slate-600 dark:text-slate-300 ${q(c) ? "text-right tabular-nums" : ""} ${g && y === 0 ? `sticky left-0 z-[1] ${V} bg-slate-100/80 dark:bg-muted` : ""}`,
486
- style: y === 0 ? { paddingLeft: 18 } : void 0,
487
- children: y === 0 ? `${D ? "▸" : "▾"} ${$}` : c.formula ? T(I(c.formula, O), c.format) : c.field && c.field !== e && q(c) ? j(O, c) : ""
519
+ className: `whitespace-nowrap py-1.5 pr-3 ${G(_)} text-[11.5px] font-medium text-slate-600 dark:text-slate-300 ${M(x) ? "text-right tabular-nums" : ""} ${$ && _ === 0 ? `sticky left-0 z-[1] ${te} bg-slate-100/80 dark:bg-muted` : ""}`,
520
+ style: _ === 0 ? { paddingLeft: 18 } : void 0,
521
+ children: _ === 0 ? `${H ? "▸" : "▾"} ${E}` : x.formula ? J(j(x.formula, R), x.format) : x.field && x.field !== e && M(x) ? ue(R, x) : ""
488
522
  },
489
- c.field ?? c.label ?? y
523
+ x.field ?? x.label ?? _
490
524
  )),
491
- k && /* @__PURE__ */ s("td", { className: pe("bg-slate-100 dark:bg-muted") })
525
+ u && /* @__PURE__ */ o("td", { className: $e("bg-slate-100 dark:bg-muted") })
492
526
  ]
493
527
  }
494
528
  ),
495
- children: !D && S.map((c, y) => {
496
- var Le;
497
- const ae = String(c[d.field] ?? ""), le = ae.slice(ae.lastIndexOf(f) + f.length), Ae = ((Le = h[0]) == null ? void 0 : Le.field) === d.field ? le : void 0;
498
- return P(c, `${v}-${y}`, 2, Ae);
529
+ children: !H && U.map((x, _) => {
530
+ var Be;
531
+ const pe = String(x[i.field] ?? ""), he = pe.slice(pe.lastIndexOf(N) + N.length), nt = ((Be = f[0]) == null ? void 0 : Be.field) === i.field ? he : void 0;
532
+ return re(x, `${C}-${_}`, 2, nt);
499
533
  })
500
534
  },
501
- v
535
+ C
502
536
  );
503
537
  })
504
538
  ];
@@ -507,149 +541,230 @@ function st({
507
541
  l
508
542
  );
509
543
  });
510
- he = [...t.map((l, o) => P(l, `flat-${o}`)), ...n];
544
+ _e = [...r.map((l, d) => re(l, `flat-${d}`)), ...n];
511
545
  } else
512
- he = C.map((e, t) => P(e, String(t)));
513
- const Ke = (e) => e.startsCollapsed ? E.has(e.key) : !E.has(e.key), te = J.length > 0 && J.every(Ke), Ge = (e) => G(
546
+ _e = S.map((e, r) => re(e, String(r)));
547
+ const lt = (e) => e.startsCollapsed ? v.has(e.key) : !v.has(e.key), be = Q.length > 0 && Q.every(lt), st = (e) => L(
514
548
  new Set(
515
- J.filter((t) => e ? t.startsCollapsed : !t.startsCollapsed).map((t) => t.key)
549
+ Q.filter((r) => e ? r.startsCollapsed : !r.startsCollapsed).map((r) => r.key)
516
550
  )
517
- ), Se = J.length > 0 ? /* @__PURE__ */ p(
551
+ ), Me = Q.length > 0 ? /* @__PURE__ */ p(
518
552
  "button",
519
553
  {
520
554
  type: "button",
521
- "data-query-tree-toggle": te ? "collapse" : "expand",
522
- onClick: () => Ge(!te),
555
+ "data-query-tree-toggle": be ? "collapse" : "expand",
556
+ onClick: () => st(!be),
523
557
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 px-2 text-[11.5px] font-medium text-slate-600 transition-colors hover:bg-slate-50 hover:text-slate-800 dark:border-border dark:text-slate-300 dark:hover:bg-muted dark:hover:text-slate-100",
524
558
  children: [
525
- te ? /* @__PURE__ */ s(Be, { className: "h-3.5 w-3.5", "aria-hidden": !0 }) : /* @__PURE__ */ s(Qe, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
526
- te ? "Collapse all" : "Expand all"
559
+ be ? /* @__PURE__ */ o(bt, { className: "h-3.5 w-3.5", "aria-hidden": !0 }) : /* @__PURE__ */ o(ct, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
560
+ be ? "Collapse all" : "Expand all"
527
561
  ]
528
562
  }
529
- ) : null;
530
- return /* @__PURE__ */ p("div", { className: g ? "flex min-h-0 flex-1 flex-col" : void 0, children: [
531
- (((Me = r == null ? void 0 : r.pivot) == null ? void 0 : Me.quarter_toggle) || (((Oe = r == null ? void 0 : r.toggles) == null ? void 0 : Oe.length) ?? 0) > 0 || Se) && /* @__PURE__ */ p("div", { className: "flex shrink-0 flex-wrap items-center justify-between gap-2 pb-2", children: [
532
- (((Ee = r == null ? void 0 : r.toggles) == null ? void 0 : Ee.length) ?? 0) > 0 ? /* @__PURE__ */ s("div", { className: "inline-flex gap-0.5 rounded-md border border-slate-200 bg-slate-50 p-0.5 dark:border-border dark:bg-muted/40", children: r.toggles.map((e) => {
533
- const t = !m.has(e.label);
534
- return /* @__PURE__ */ s(
563
+ ) : null, ot = typeof (t == null ? void 0 : t.export_csv) == "object" && t.export_csv.filename ? t.export_csv.filename : "export.csv", Ue = t != null && t.search || t != null && t.export_csv || Z.length > 0 ? /* @__PURE__ */ p("div", { className: "flex flex-wrap items-center gap-2", children: [
564
+ (t == null ? void 0 : t.search) && /* @__PURE__ */ p("label", { className: "relative inline-flex items-center", children: [
565
+ /* @__PURE__ */ o(
566
+ dt,
567
+ {
568
+ className: "pointer-events-none absolute left-2 h-3.5 w-3.5 text-slate-400",
569
+ "aria-hidden": !0
570
+ }
571
+ ),
572
+ /* @__PURE__ */ o(
573
+ "input",
574
+ {
575
+ type: "search",
576
+ value: A,
577
+ onChange: (e) => w(e.target.value),
578
+ placeholder: "Search rows",
579
+ "aria-label": "Search rows",
580
+ "data-qt-search": "",
581
+ className: "h-7 w-48 rounded-md border border-slate-200 bg-white pl-7 pr-2 text-[12px] text-slate-700 outline-none placeholder:text-slate-400 focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-slate-200"
582
+ }
583
+ )
584
+ ] }),
585
+ Z.length > 0 && /* @__PURE__ */ o(
586
+ "button",
587
+ {
588
+ type: "button",
589
+ "aria-pressed": z,
590
+ "data-qt-hide-empty": z ? "on" : "off",
591
+ onClick: () => I((e) => !e),
592
+ className: `h-7 whitespace-nowrap rounded-md border px-2.5 text-[11.5px] font-medium transition-colors ${z ? "border-nvr-cyan bg-nvr-cyan text-white" : "border-slate-200 text-slate-600 hover:bg-slate-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted"}`,
593
+ children: ((We = t == null ? void 0 : t.hide_empty) == null ? void 0 : We.label) ?? "Hide empty rows"
594
+ }
595
+ ),
596
+ (ie || z && Z.length > 0) && /* @__PURE__ */ p(
597
+ "span",
598
+ {
599
+ className: "text-[11.5px] tabular-nums text-slate-500 dark:text-slate-400",
600
+ "data-qt-shown": "",
601
+ children: [
602
+ S.length.toLocaleString("en-US"),
603
+ " of ",
604
+ s.length.toLocaleString("en-US"),
605
+ " rows"
606
+ ]
607
+ }
608
+ ),
609
+ (t == null ? void 0 : t.export_csv) && /* @__PURE__ */ p(
610
+ "button",
611
+ {
612
+ type: "button",
613
+ "data-qt-csv": "",
614
+ onClick: () => St(
615
+ ot,
616
+ _t(
617
+ f.filter((e) => fe(e) || !e.field),
618
+ S,
619
+ T,
620
+ (e) => e.label ?? le(e.field ?? "")
621
+ )
622
+ ),
623
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 px-2 text-[11.5px] font-medium text-slate-600 transition-colors hover:bg-slate-50 hover:text-slate-800 dark:border-border dark:text-slate-300 dark:hover:bg-muted dark:hover:text-slate-100",
624
+ children: [
625
+ /* @__PURE__ */ o(it, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
626
+ "CSV"
627
+ ]
628
+ }
629
+ )
630
+ ] }) : null;
631
+ return /* @__PURE__ */ p("div", { className: $ ? "flex min-h-0 flex-1 flex-col" : void 0, children: [
632
+ Ue && /* @__PURE__ */ o("div", { className: "shrink-0 pb-2", children: Ue }),
633
+ (((Ke = t == null ? void 0 : t.pivot) == null ? void 0 : Ke.quarter_toggle) || (((Ae = t == null ? void 0 : t.toggles) == null ? void 0 : Ae.length) ?? 0) > 0 || Me) && /* @__PURE__ */ p("div", { className: "flex shrink-0 flex-wrap items-center justify-between gap-2 pb-2", children: [
634
+ (((Je = t == null ? void 0 : t.toggles) == null ? void 0 : Je.length) ?? 0) > 0 ? /* @__PURE__ */ o("div", { className: "inline-flex gap-0.5 rounded-md border border-slate-200 bg-slate-50 p-0.5 dark:border-border dark:bg-muted/40", children: t.toggles.map((e) => {
635
+ const r = !V.has(e.label);
636
+ return /* @__PURE__ */ o(
535
637
  "button",
536
638
  {
537
639
  type: "button",
538
- "aria-pressed": t,
539
- onClick: () => W((a) => {
640
+ "aria-pressed": r,
641
+ onClick: () => O((a) => {
540
642
  const n = new Set(a);
541
643
  return n.has(e.label) ? n.delete(e.label) : n.add(e.label), n;
542
644
  }),
543
- className: `whitespace-nowrap rounded px-2.5 py-1 text-[11.5px] font-medium transition-colors ${t ? "bg-nvr-cyan text-white shadow-sm" : "text-slate-500 hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200"}`,
645
+ className: `whitespace-nowrap rounded px-2.5 py-1 text-[11.5px] font-medium transition-colors ${r ? "bg-nvr-cyan text-white shadow-sm" : "text-slate-500 hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200"}`,
544
646
  children: e.label
545
647
  },
546
648
  e.label
547
649
  );
548
- }) }) : /* @__PURE__ */ s("span", {}),
650
+ }) }) : /* @__PURE__ */ o("span", {}),
549
651
  /* @__PURE__ */ p("div", { className: "ml-auto flex items-center gap-2", children: [
550
- Se,
551
- ((ze = r == null ? void 0 : r.pivot) == null ? void 0 : ze.quarter_toggle) && /* @__PURE__ */ s("div", { className: "inline-flex gap-0.5 rounded-md border border-slate-200 p-0.5 dark:border-border", children: ["month", "quarter"].map((e) => /* @__PURE__ */ s(
652
+ Me,
653
+ ((je = t == null ? void 0 : t.pivot) == null ? void 0 : je.quarter_toggle) && /* @__PURE__ */ o("div", { className: "inline-flex gap-0.5 rounded-md border border-slate-200 p-0.5 dark:border-border", children: ["month", "quarter"].map((e) => /* @__PURE__ */ o(
552
654
  "button",
553
655
  {
554
656
  type: "button",
555
- onClick: () => ne(e),
556
- className: `rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${L === e ? "bg-nvr-cyan/10 text-slate-800 dark:text-slate-100" : "text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,
657
+ onClick: () => K(e),
658
+ className: `rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${se === e ? "bg-nvr-cyan/10 text-slate-800 dark:text-slate-100" : "text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,
557
659
  children: e === "month" ? "Monthly" : "Quarterly"
558
660
  },
559
661
  e
560
662
  )) })
561
663
  ] })
562
664
  ] }),
563
- /* @__PURE__ */ p("div", { className: g ? "relative flex min-h-0 flex-1 flex-col" : "relative", children: [
564
- /* @__PURE__ */ s(
665
+ /* @__PURE__ */ p("div", { className: $ ? "relative flex min-h-0 flex-1 flex-col" : "relative", children: [
666
+ /* @__PURE__ */ o(
565
667
  "div",
566
668
  {
567
- ref: de,
568
- className: g ? "min-h-0 flex-1 overflow-auto" : "overflow-x-auto",
669
+ ref: Ye,
670
+ className: $ ? "min-h-0 flex-1 overflow-auto" : "overflow-x-auto",
569
671
  children: /* @__PURE__ */ p("table", { className: "w-full border-separate border-spacing-0 text-[12px] [&>tbody>tr.border-b>td]:border-b [&>tbody>tr.border-b>td]:[border-bottom-color:inherit] [&>tbody:has(+tfoot)>tr:last-child>td]:border-b-0 [&>tfoot>tr.border-t>td]:border-t [&>tfoot>tr.border-t>td]:[border-top-color:inherit]", children: [
570
- /* @__PURE__ */ s("thead", { children: we ? /* @__PURE__ */ p(Re, { children: [
672
+ /* @__PURE__ */ o("thead", { children: Oe ? /* @__PURE__ */ p(Pe, { children: [
571
673
  /* @__PURE__ */ p("tr", { children: [
572
674
  (() => {
573
675
  const e = [];
574
- let t = 0;
575
- for (; t < h.length; ) {
576
- const a = h[t];
676
+ let r = 0;
677
+ for (; r < f.length; ) {
678
+ const a = f[r];
577
679
  if (!a.group) {
578
680
  e.push(
579
- /* @__PURE__ */ s(
681
+ /* @__PURE__ */ o(
580
682
  "th",
581
683
  {
582
684
  rowSpan: 2,
583
- className: `whitespace-nowrap border-b border-slate-200 py-1.5 pr-3 align-bottom text-[10.5px] font-semibold uppercase tracking-wider text-slate-500 dark:border-border dark:text-slate-400 ${q(a) ? "text-right" : "text-left"} ${_e(t)}`,
584
- children: a.label ?? ge(a.field ?? "")
685
+ className: `whitespace-nowrap border-b border-slate-200 py-1.5 pr-3 align-bottom text-[10.5px] font-semibold uppercase tracking-wider text-slate-500 dark:border-border dark:text-slate-400 ${M(a) ? "text-right" : "text-left"} ${Te(r)}`,
686
+ children: a.label ?? le(a.field ?? "")
585
687
  },
586
- `u-${a.field ?? t}`
688
+ `u-${a.field ?? r}`
587
689
  )
588
- ), t++;
690
+ ), r++;
589
691
  continue;
590
692
  }
591
693
  let n = 1;
592
- for (; t + n < h.length && h[t + n].group === a.group; )
694
+ for (; r + n < f.length && f[r + n].group === a.group; )
593
695
  n++;
594
696
  e.push(
595
- /* @__PURE__ */ s(
697
+ /* @__PURE__ */ o(
596
698
  "th",
597
699
  {
598
700
  colSpan: n,
599
- className: `whitespace-nowrap border-b border-slate-100 py-1 pr-3 text-center text-[11px] font-semibold dark:border-border/60 ${a.group === X ? "border-t-2 border-t-[#6366f1] bg-[#6366f10f] text-[#4f46e5] dark:border-t-[#a5b4fc] dark:bg-[#a5b4fc12] dark:text-[#a5b4fc]" : `text-slate-600 dark:text-slate-300 ${ce(t)}`} ${g ? "sticky top-0 z-[2] bg-white dark:bg-card" : ""}`.trim(),
701
+ className: `whitespace-nowrap border-b border-slate-100 py-1 pr-3 text-center text-[11px] font-semibold dark:border-border/60 ${a.group === ne ? "border-t-2 border-t-[#6366f1] bg-[#6366f10f] text-[#4f46e5] dark:border-t-[#a5b4fc] dark:bg-[#a5b4fc12] dark:text-[#a5b4fc]" : `text-slate-600 dark:text-slate-300 ${we(r)}`} ${$ ? "sticky top-0 z-[2] bg-white dark:bg-card" : ""}`.trim(),
600
702
  children: a.group
601
703
  },
602
- `g-${a.group}-${t}`
704
+ `g-${a.group}-${r}`
603
705
  )
604
- ), t += n;
706
+ ), r += n;
605
707
  }
606
708
  return e;
607
709
  })(),
608
- k && /* @__PURE__ */ s(
710
+ u && /* @__PURE__ */ o(
609
711
  "th",
610
712
  {
611
713
  rowSpan: 2,
612
714
  "aria-label": "Actions",
613
715
  "data-qt-actions-head": "",
614
- className: `border-b border-slate-200 dark:border-border ${g ? `sticky right-0 top-0 z-[3] ${ee} bg-white dark:bg-card` : ""}`
716
+ className: `border-b border-slate-200 dark:border-border ${$ ? `sticky right-0 top-0 z-[3] ${me} bg-white dark:bg-card` : ""}`
615
717
  }
616
718
  )
617
719
  ] }),
618
- /* @__PURE__ */ s("tr", { children: h.map(
619
- (e, t) => e.group ? /* @__PURE__ */ s(
720
+ /* @__PURE__ */ o("tr", { children: f.map(
721
+ (e, r) => e.group ? /* @__PURE__ */ o(
620
722
  "th",
621
723
  {
622
- className: `min-w-[58px] whitespace-nowrap border-b border-slate-200 py-1 pr-3 ${U(t)} text-[11px] font-medium text-slate-500 dark:border-border dark:text-slate-400 ${q(e) ? "text-right" : "text-left"} ${Z(e) || ce(t)} ${g ? "sticky top-[26px] z-[2] bg-white dark:bg-card" : ""}`,
623
- children: e.label ?? ge(e.field ?? "")
724
+ className: `min-w-[58px] whitespace-nowrap border-b border-slate-200 py-1 pr-3 ${G(r)} text-[11px] font-medium text-slate-500 dark:border-border dark:text-slate-400 ${M(e) ? "text-right" : "text-left"} ${de(e) || we(r)} ${$ ? "sticky top-[26px] z-[2] bg-white dark:bg-card" : ""}`,
725
+ children: e.label ?? le(e.field ?? "")
624
726
  },
625
- e.field ?? e.label ?? t
727
+ e.field ?? e.label ?? r
626
728
  ) : null
627
729
  ) })
628
730
  ] }) : /* @__PURE__ */ p("tr", { className: "border-b border-slate-200 dark:border-border", children: [
629
- h.map((e, t) => /* @__PURE__ */ p(
731
+ f.map((e, r) => /* @__PURE__ */ p(
630
732
  "th",
631
733
  {
632
- className: `whitespace-nowrap border-b border-slate-200 py-1.5 pr-3 ${U(t)} text-[10.5px] font-semibold uppercase tracking-wider dark:border-border ${$e(e) ? "border-t-2 border-t-[#6366f1] bg-[#6366f10f] text-[#4f46e5] dark:border-t-[#a5b4fc] dark:bg-[#a5b4fc12] dark:text-[#a5b4fc]" : "text-slate-500 dark:text-slate-400"} ${e.stack ? "min-w-[64px]" : ""} ${q(e) ? "text-right" : "text-left"} ${_e(t)}`,
734
+ className: `whitespace-nowrap border-b border-slate-200 py-1.5 pr-3 ${G(r)} text-[10.5px] font-semibold uppercase tracking-wider dark:border-border ${Le(e) ? "border-t-2 border-t-[#6366f1] bg-[#6366f10f] text-[#4f46e5] dark:border-t-[#a5b4fc] dark:bg-[#a5b4fc12] dark:text-[#a5b4fc]" : "text-slate-500 dark:text-slate-400"} ${e.stack ? "min-w-[64px]" : ""} ${M(e) ? "text-right" : "text-left"} ${Te(r)}`,
735
+ "aria-sort": ve && (q == null ? void 0 : q.key) === ee(e, r) ? q.dir === 1 ? "ascending" : "descending" : void 0,
633
736
  children: [
634
- e.label ?? ge(e.field ?? ""),
635
- e.stack && (r == null ? void 0 : r.stack_legend) && /* @__PURE__ */ p(
737
+ ve ? /* @__PURE__ */ p(
738
+ "button",
739
+ {
740
+ type: "button",
741
+ "data-qt-sort": ee(e, r),
742
+ onClick: () => rt(ee(e, r)),
743
+ className: `inline-flex items-center gap-0.5 font-semibold uppercase tracking-wider hover:text-slate-800 dark:hover:text-slate-100 ${M(e) ? "flex-row-reverse" : ""}`,
744
+ children: [
745
+ e.label ?? le(e.field ?? ""),
746
+ (q == null ? void 0 : q.key) === ee(e, r) && (q.dir === 1 ? /* @__PURE__ */ o(ut, { className: "h-3 w-3", "aria-hidden": !0 }) : /* @__PURE__ */ o(mt, { className: "h-3 w-3", "aria-hidden": !0 }))
747
+ ]
748
+ }
749
+ ) : e.label ?? le(e.field ?? ""),
750
+ e.stack && (t == null ? void 0 : t.stack_legend) && /* @__PURE__ */ p(
636
751
  "span",
637
752
  {
638
753
  className: "flex justify-end gap-1.5 text-[9px] font-medium normal-case tracking-normal",
639
- style: ue(e) ? { ...ue(e), ...Q(e) ?? {} } : Q(e),
754
+ style: ye(e) ? { ...ye(e), ...X(e) ?? {} } : X(e),
640
755
  children: [
641
- ve(e) && /* @__PURE__ */ s(
756
+ fe(e) && /* @__PURE__ */ o(
642
757
  "span",
643
758
  {
644
759
  className: e.color ? "text-[color:var(--qtc)] dark:text-[color:var(--qtcd)]" : "",
645
- children: r.stack_legend[0]
760
+ children: t.stack_legend[0]
646
761
  }
647
762
  ),
648
- Ne(e) && /* @__PURE__ */ s(
763
+ Ee(e) && /* @__PURE__ */ o(
649
764
  "span",
650
765
  {
651
766
  className: e.stack_color ? "text-[color:var(--qts)] dark:text-[color:var(--qtsd)]" : "",
652
- children: r.stack_legend[1]
767
+ children: t.stack_legend[1]
653
768
  }
654
769
  )
655
770
  ]
@@ -657,38 +772,38 @@ function st({
657
772
  )
658
773
  ]
659
774
  },
660
- e.field ?? e.label ?? t
775
+ e.field ?? e.label ?? r
661
776
  )),
662
- k && /* @__PURE__ */ s(
777
+ u && /* @__PURE__ */ o(
663
778
  "th",
664
779
  {
665
780
  "aria-label": "Actions",
666
781
  "data-qt-actions-head": "",
667
- className: g ? `sticky right-0 top-0 z-[3] ${ee} bg-white dark:bg-card` : void 0
782
+ className: $ ? `sticky right-0 top-0 z-[3] ${me} bg-white dark:bg-card` : void 0
668
783
  }
669
784
  )
670
785
  ] }) }),
671
- /* @__PURE__ */ s("tbody", { children: he }),
672
- H && /* @__PURE__ */ s("tfoot", { children: /* @__PURE__ */ p("tr", { className: "border-t border-slate-300 font-semibold dark:border-border", children: [
673
- h.map((e, t) => /* @__PURE__ */ s(
786
+ /* @__PURE__ */ o("tbody", { children: _e }),
787
+ B && /* @__PURE__ */ o("tfoot", { children: /* @__PURE__ */ p("tr", { className: "border-t border-slate-300 font-semibold dark:border-border", children: [
788
+ f.map((e, r) => /* @__PURE__ */ o(
674
789
  "td",
675
790
  {
676
- className: `whitespace-nowrap py-1.5 pr-3 ${U(t)} ${ie(e, "")} ${q(e) ? "text-right tabular-nums" : ""} ${Z(e)} ${g ? `sticky bottom-0 border-t border-slate-300 dark:border-border ${t === 0 ? `left-0 z-[3] ${V} bg-slate-50 dark:bg-muted` : "z-[2] bg-white dark:bg-card"}` : ""}`,
677
- style: Q(
791
+ className: `whitespace-nowrap py-1.5 pr-3 ${G(r)} ${ke(e, "")} ${M(e) ? "text-right tabular-nums" : ""} ${de(e)} ${$ ? `sticky bottom-0 border-t border-slate-300 dark:border-border ${r === 0 ? `left-0 z-[3] ${te} bg-slate-50 dark:bg-muted` : "z-[2] bg-white dark:bg-card"}` : ""}`,
792
+ style: X(
678
793
  e,
679
794
  Number(
680
- e.formula ? I(e.formula, H) : H[e.field ?? ""]
795
+ e.formula ? j(e.formula, B) : B[e.field ?? ""]
681
796
  )
682
797
  ),
683
- children: t === 0 && !e.sum && !e.formula ? "Total" : e.sum || e.formula ? e.formula ? T(I(e.formula, H), e.format) : j(H, e) : ""
798
+ children: r === 0 && !e.sum && !e.formula ? "Total" : e.sum || e.formula ? e.formula ? J(j(e.formula, B), e.format) : ue(B, e) : ""
684
799
  },
685
- e.field ?? e.label ?? t
800
+ e.field ?? e.label ?? r
686
801
  )),
687
- k && /* @__PURE__ */ s(
802
+ u && /* @__PURE__ */ o(
688
803
  "td",
689
804
  {
690
- className: `py-1.5 pr-3 text-right ${g ? `sticky bottom-0 right-0 z-[3] border-t border-slate-300 ${ee} bg-white dark:border-border dark:bg-card` : ""}`,
691
- children: /* @__PURE__ */ s("span", { className: "inline-flex flex-nowrap gap-1.5", children: k.map((e) => /* @__PURE__ */ s(
805
+ className: `py-1.5 pr-3 text-right ${$ ? `sticky bottom-0 right-0 z-[3] border-t border-slate-300 ${me} bg-white dark:border-border dark:bg-card` : ""}`,
806
+ children: /* @__PURE__ */ o("span", { className: "inline-flex flex-nowrap gap-1.5", children: u.map((e) => /* @__PURE__ */ o(
692
807
  "button",
693
808
  {
694
809
  type: "button",
@@ -704,30 +819,57 @@ function st({
704
819
  ] })
705
820
  }
706
821
  ),
707
- w.canScrollRight && // More columns to the right: fade the edge so readers know the
822
+ oe.canScrollRight && // More columns to the right: fade the edge so readers know the
708
823
  // table scrolls sideways (the native scrollbar is often invisible).
709
- /* @__PURE__ */ s(
824
+ /* @__PURE__ */ o(
710
825
  "div",
711
826
  {
712
827
  "aria-hidden": !0,
713
828
  "data-qt-scroll-cue": "",
714
829
  className: "pointer-events-none absolute top-0 w-10 bg-gradient-to-r from-transparent to-white dark:to-card",
715
- style: { right: w.cueInset.right, bottom: w.cueInset.bottom }
830
+ style: { right: oe.cueInset.right, bottom: oe.cueInset.bottom }
716
831
  }
717
832
  )
718
833
  ] })
719
834
  ] });
720
835
  }
721
- function Ie({ header: i, children: r }) {
722
- return /* @__PURE__ */ p(Re, { children: [
723
- i,
724
- r
836
+ function $t(s, t, m = 1) {
837
+ const c = (y) => y == null || y === "";
838
+ if (c(s) && c(t)) return 0;
839
+ if (c(s)) return 1;
840
+ if (c(t)) return -1;
841
+ const u = typeof s == "number" ? s : Number(s), g = typeof t == "number" ? t : Number(t);
842
+ return Number.isFinite(u) && Number.isFinite(g) ? (u - g) * m : String(s).localeCompare(String(t), void 0, { numeric: !0, sensitivity: "base" }) * m;
843
+ }
844
+ function _t(s, t, m, c) {
845
+ const u = (y) => {
846
+ if (y == null) return "";
847
+ const v = typeof y == "object" ? JSON.stringify(y) : String(y), L = /^[=+\-@]/.test(v) && !/^-?\d/.test(v) ? `'${v}` : v;
848
+ return /[",\r\n]/.test(L) ? `"${L.replace(/"/g, '""')}"` : L;
849
+ }, g = [s.map((y) => u(c(y))).join(",")];
850
+ for (const y of t) g.push(s.map((v) => u(m(y, v))).join(","));
851
+ return `${g.join(`\r
852
+ `)}\r
853
+ `;
854
+ }
855
+ function St(s, t) {
856
+ const m = URL.createObjectURL(new Blob([`\uFEFF${t}`], { type: "text/csv;charset=utf-8" })), c = document.createElement("a");
857
+ c.href = m, c.download = s, document.body.appendChild(c), c.click(), c.remove(), setTimeout(() => URL.revokeObjectURL(m), 0);
858
+ }
859
+ function Qe({ header: s, children: t }) {
860
+ return /* @__PURE__ */ p(Pe, { children: [
861
+ s,
862
+ t
725
863
  ] });
726
864
  }
727
865
  export {
728
- fe as COLOR_ROLES,
729
- st as QueryTable,
730
- xe as colorPair,
731
- Xe as darkVariant,
732
- et as pivotQueryRows
866
+ Se as COLOR_ROLES,
867
+ Lt as QueryTable,
868
+ vt as UNDATED_KEY,
869
+ Ce as colorPair,
870
+ ft as darkVariant,
871
+ Nt as pivotQueryRows,
872
+ _t as queryTableCsv,
873
+ wt as queryTableTotals,
874
+ $t as sortCompare
733
875
  };