@nivaro/react 0.3.48 → 0.3.50

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