@nivaro/react 0.3.58 → 0.3.59

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 (43) hide show
  1. package/dist/components/fields/RelationField.js +110 -80
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useRelationOptions.js +1 -0
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +32 -1
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2083 -2052
  8. package/dist/shared/components/DataTable.js +497 -465
  9. package/dist/shared/components/ItemEditForm.js +4430 -4282
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/QueryTable.js +74 -74
  12. package/dist/shared/components/WidgetSlot.js +543 -520
  13. package/dist/shared/components/alerts/AlertManagerView.js +269 -275
  14. package/dist/shared/components/alerts/types.js +37 -14
  15. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  16. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  17. package/dist/shared/components/item-edit/InlineTableField.js +2461 -2421
  18. package/dist/shared/components/item-edit/M2MCombobox.js +141 -137
  19. package/dist/shared/components/item-edit/PlanGrid.js +876 -820
  20. package/dist/shared/components/item-edit/QuickCreateButton.js +323 -130
  21. package/dist/shared/components/item-edit/RelationCombobox.js +408 -375
  22. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +255 -156
  23. package/dist/shared/components/item-edit/SummaryPanel.js +356 -343
  24. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  25. package/dist/shared/components/item-edit/line-midair.js +82 -75
  26. package/dist/shared/components/item-edit/save-outcome.js +6 -4
  27. package/dist/shared/components/panels/ItemLockBanner.js +212 -209
  28. package/dist/shared/components/panels/PipelinePanel.js +775 -737
  29. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  30. package/dist/shared/components/panels/RevisionsPanel.js +313 -299
  31. package/dist/shared/components/pipeline/PipelineEditorView.js +26 -16
  32. package/dist/shared/components/queue/QueueQuickFilters.js +13 -13
  33. package/dist/shared/components/queue/QueueWorklist.js +978 -953
  34. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  35. package/dist/shared/components/widgets/ReviewListWidget.js +152 -149
  36. package/dist/shared/lib/display-prefs.js +60 -52
  37. package/dist/shared/lib/draft-store.js +71 -48
  38. package/dist/shared/lib/expression.js +53 -53
  39. package/dist/shared/lib/list-page-memory.js +42 -20
  40. package/dist/shared/lib/money-input.js +45 -0
  41. package/dist/shared/lib/sanitize-html.js +10 -6
  42. package/dist/shared/lib/staged-row-labels.js +18 -0
  43. package/package.json +1 -1
@@ -1,29 +1,29 @@
1
- import { jsx as t, jsxs as x, Fragment as B } from "react/jsx-runtime";
2
- import { useQuery as z, useQueryClient as He } from "@tanstack/react-query";
3
- import { useState as q, useEffect as X, useRef as D, useMemo as Re, useCallback as Ye } from "react";
4
- import { createPortal as Xe } from "react-dom";
5
- import { useNivaroClient as K, useItemEditAuth as Ze, useDrilldown as Ae, useOverlayState as et, DrilldownContext as tt, useItemNavigation as rt } from "../context.js";
6
- import { useDebounced as nt } from "../hooks/useDebounced.js";
7
- import { get as Fe, post as Z } from "../lib/commands.js";
8
- import { describeError as at } from "../lib/error-message.js";
9
- import { visiblePageWidgets as lt } from "../lib/page-widget-access.js";
10
- import { explicitAllUrlParams as st, initialFilterSelection as it, filterSelectionToSearch as ot } from "../lib/query-filter-seed.js";
11
- import { userErrorMessage as Ee } from "../lib/safe-error.js";
12
- import { safeLinkKind as dt } from "../lib/safe-href.js";
13
- import { resolveSheetDef as ct } from "../lib/sheet-def.js";
14
- import { uniqueByValue as ut } from "../lib/unique-options.js";
15
- import { useMyScopes as mt, matchScopeDimension as Te, effectiveScopeSeedIds as pt, translateScopeValues as ht } from "../lib/use-my-scopes.js";
16
- import { titleCase as F, formatRelative as xt, formatNumber as ft } from "../lib/utils.js";
17
- import { CacheStamp as bt } from "./CacheStamp.js";
18
- import { RelationCombobox as gt } from "./item-edit/RelationCombobox.js";
19
- import { MatrixEditor as ce } from "./MatrixEditor.js";
20
- import { QueryStatStrip as yt } from "./QueryStatStrip.js";
21
- import { QueryTable as vt } from "./QueryTable.js";
22
- import { RecordDrilldownSheet as kt } from "./RecordDrilldownSheet.js";
23
- import { RecordGridEditor as We } from "./RecordGridEditor.js";
24
- import { SheetHeaderBody as wt } from "./SheetHeaderBody.js";
25
- const oe = 76;
26
- function ee() {
1
+ import { jsx as t, jsxs as p, Fragment as J } from "react/jsx-runtime";
2
+ import { useQuery as G, useQueryClient as He } from "@tanstack/react-query";
3
+ import { useState as j, useEffect as re, useRef as Y, useMemo as We, useCallback as Ye, useDeferredValue as Xe } from "react";
4
+ import { createPortal as Ze } from "react-dom";
5
+ import { useNivaroClient as X, useItemEditAuth as et, useDrilldown as Ee, useOverlayState as tt, DrilldownContext as rt, useItemNavigation as nt } from "../context.js";
6
+ import { useDebounced as at } from "../hooks/useDebounced.js";
7
+ import { get as me, post as ne } from "../lib/commands.js";
8
+ import { describeError as lt } from "../lib/error-message.js";
9
+ import { visiblePageWidgets as st } from "../lib/page-widget-access.js";
10
+ import { explicitAllUrlParams as ot, initialFilterSelection as it, filterSelectionToSearch as dt } from "../lib/query-filter-seed.js";
11
+ import { userErrorMessage as Le } from "../lib/safe-error.js";
12
+ import { safeLinkKind as ct } from "../lib/safe-href.js";
13
+ import { resolveSheetDef as ut } from "../lib/sheet-def.js";
14
+ import { uniqueByValue as mt } from "../lib/unique-options.js";
15
+ import { useMyScopes as ht, matchScopeDimension as Me, effectiveScopeSeedIds as pt, translateScopeValues as xt } from "../lib/use-my-scopes.js";
16
+ import { titleCase as K, formatRelative as ft, formatNumber as bt } from "../lib/utils.js";
17
+ import { CacheStamp as gt } from "./CacheStamp.js";
18
+ import { RelationCombobox as yt } from "./item-edit/RelationCombobox.js";
19
+ import { MatrixEditor as he } from "./MatrixEditor.js";
20
+ import { QueryStatStrip as vt } from "./QueryStatStrip.js";
21
+ import { QueryTable as kt } from "./QueryTable.js";
22
+ import { RecordDrilldownSheet as wt } from "./RecordDrilldownSheet.js";
23
+ import { RecordGridEditor as Oe } from "./RecordGridEditor.js";
24
+ import { SheetHeaderBody as Nt } from "./SheetHeaderBody.js";
25
+ const ce = 76;
26
+ function ae() {
27
27
  return /* @__PURE__ */ t("div", { className: "space-y-1.5 p-3", children: [1, 2, 3].map((e) => /* @__PURE__ */ t(
28
28
  "div",
29
29
  {
@@ -32,17 +32,17 @@ function ee() {
32
32
  e
33
33
  )) });
34
34
  }
35
- function te({ error: e, unresolved: r }) {
36
- const n = Mt(e, r) ?? Ee(e, "Failed to load widget data");
35
+ function le({ error: e, unresolved: r }) {
36
+ const n = Ot(e, r) ?? Le(e, "Failed to load widget data");
37
37
  return /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center p-3 text-[12px] text-amber-600 dark:text-amber-500", children: n });
38
38
  }
39
- function Nt(e) {
39
+ function St(e) {
40
40
  if (e == null) return "—";
41
41
  if (typeof e == "boolean") return e ? "true" : "false";
42
42
  const r = String(e);
43
43
  return r.length > 80 ? `${r.slice(0, 80)}…` : r;
44
44
  }
45
- function de(e, r) {
45
+ function ue(e, r) {
46
46
  const n = [], a = /(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g;
47
47
  return e.split(a).forEach((l, u) => {
48
48
  const c = `${r}-${u}`;
@@ -63,122 +63,122 @@ function de(e, r) {
63
63
  )
64
64
  );
65
65
  else {
66
- const i = l.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
67
- i && dt(i[2]) !== null ? n.push(
68
- /* @__PURE__ */ t("a", { href: i[2], className: "text-nvr-cyan underline-offset-2 hover:underline", children: i[1] }, c)
66
+ const o = l.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
67
+ o && ct(o[2]) !== null ? n.push(
68
+ /* @__PURE__ */ t("a", { href: o[2], className: "text-nvr-cyan underline-offset-2 hover:underline", children: o[1] }, c)
69
69
  ) : n.push(l);
70
70
  }
71
71
  }), n;
72
72
  }
73
- function St({ content: e }) {
73
+ function $t({ content: e }) {
74
74
  const r = [];
75
75
  let n = [], a = [], l = !1;
76
- const u = (i) => {
76
+ const u = (o) => {
77
77
  n.length && (r.push(
78
- /* @__PURE__ */ t("p", { className: "leading-relaxed", children: de(n.join(" "), i) }, i)
78
+ /* @__PURE__ */ t("p", { className: "leading-relaxed", children: ue(n.join(" "), o) }, o)
79
79
  ), n = []);
80
- }, c = (i) => {
80
+ }, c = (o) => {
81
81
  if (!a.length) return;
82
- const s = a.map((m, h) => /* @__PURE__ */ t("li", { children: de(m, `${i}-${h}`) }, `${i}-${h}`));
82
+ const s = a.map((m, x) => /* @__PURE__ */ t("li", { children: ue(m, `${o}-${x}`) }, `${o}-${x}`));
83
83
  r.push(
84
- l ? /* @__PURE__ */ t("ol", { className: "list-decimal space-y-0.5 pl-5", children: s }, i) : /* @__PURE__ */ t("ul", { className: "list-disc space-y-0.5 pl-5", children: s }, i)
84
+ l ? /* @__PURE__ */ t("ol", { className: "list-decimal space-y-0.5 pl-5", children: s }, o) : /* @__PURE__ */ t("ul", { className: "list-disc space-y-0.5 pl-5", children: s }, o)
85
85
  ), a = [];
86
86
  };
87
87
  return e.split(`
88
- `).forEach((i, s) => {
89
- const m = `md-${s}`, h = i.match(/^(#{1,3})\s+(.*)$/), v = i.match(/^[-*]\s+(.*)$/), $ = i.match(/^\d+\.\s+(.*)$/);
90
- if (h) {
88
+ `).forEach((o, s) => {
89
+ const m = `md-${s}`, x = o.match(/^(#{1,3})\s+(.*)$/), k = o.match(/^[-*]\s+(.*)$/), _ = o.match(/^\d+\.\s+(.*)$/);
90
+ if (x) {
91
91
  c(`${m}-fl`), u(`${m}-fp`);
92
- const N = h[1].length, j = N === 1 ? "text-[17px] font-semibold" : N === 2 ? "text-[15px] font-semibold" : "text-[13.5px] font-semibold";
92
+ const w = x[1].length, q = w === 1 ? "text-[17px] font-semibold" : w === 2 ? "text-[15px] font-semibold" : "text-[13.5px] font-semibold";
93
93
  r.push(
94
- /* @__PURE__ */ t("div", { className: `${j} text-slate-900 dark:text-slate-100`, children: de(h[2], `${m}-h`) }, m)
94
+ /* @__PURE__ */ t("div", { className: `${q} text-slate-900 dark:text-slate-100`, children: ue(x[2], `${m}-h`) }, m)
95
95
  );
96
- } else if (v || $) {
96
+ } else if (k || _) {
97
97
  u(`${m}-fp`);
98
- const N = !!$;
99
- a.length && l !== N && c(`${m}-fl`), l = N, a.push((v == null ? void 0 : v[1]) ?? ($ == null ? void 0 : $[1]));
100
- } else i.trim() === "" ? (c(`${m}-fl`), u(`${m}-fp`)) : (c(`${m}-fl`), n.push(i.trim()));
98
+ const w = !!_;
99
+ a.length && l !== w && c(`${m}-fl`), l = w, a.push((k == null ? void 0 : k[1]) ?? (_ == null ? void 0 : _[1]));
100
+ } else o.trim() === "" ? (c(`${m}-fl`), u(`${m}-fp`)) : (c(`${m}-fl`), n.push(o.trim()));
101
101
  }), c("md-end-l"), u("md-end-p"), /* @__PURE__ */ t("div", { className: "space-y-2 p-4 text-[13px] text-slate-700 dark:text-slate-300", children: r });
102
102
  }
103
- function ue(e, r, n) {
104
- const a = K();
105
- return z({
103
+ function pe(e, r, n) {
104
+ const a = X();
105
+ return G({
106
106
  queryKey: ["page-renderer-widget-data", e, r.id],
107
- queryFn: () => a.request(Z(`/pages/${e}/widget-data`, { widget_id: r.id })).then((l) => l.data),
107
+ queryFn: () => a.request(ne(`/pages/${e}/widget-data`, { widget_id: r.id })).then((l) => l.data),
108
108
  enabled: n,
109
109
  retry: !1,
110
110
  staleTime: 3e4
111
111
  });
112
112
  }
113
- function $t({ slug: e, widget: r }) {
113
+ function _t({ slug: e, widget: r }) {
114
114
  var m;
115
- const n = r.config ?? {}, { data: a, isLoading: l, error: u } = ue(e, r, !!n.collection), c = rt();
115
+ const n = r.config ?? {}, { data: a, isLoading: l, error: u } = pe(e, r, !!n.collection), c = nt();
116
116
  if (!n.collection)
117
117
  return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Select a collection" });
118
- if (l) return /* @__PURE__ */ t(ee, {});
119
- if (u) return /* @__PURE__ */ t(te, { error: u });
120
- const i = (a == null ? void 0 : a.rows) ?? [];
121
- if (!i.length) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No records" });
122
- const s = (m = n.columns) != null && m.length ? n.columns : Object.keys(i[0]).filter((h) => {
123
- const v = i[0][h];
124
- return v === null || ["string", "number", "boolean"].includes(typeof v);
118
+ if (l) return /* @__PURE__ */ t(ae, {});
119
+ if (u) return /* @__PURE__ */ t(le, { error: u });
120
+ const o = (a == null ? void 0 : a.rows) ?? [];
121
+ if (!o.length) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No records" });
122
+ const s = (m = n.columns) != null && m.length ? n.columns : Object.keys(o[0]).filter((x) => {
123
+ const k = o[0][x];
124
+ return k === null || ["string", "number", "boolean"].includes(typeof k);
125
125
  }).slice(0, 5);
126
- return /* @__PURE__ */ t("div", { className: "h-full overflow-auto", children: /* @__PURE__ */ x("table", { className: "w-full text-[12px]", children: [
127
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100 dark:border-border", children: s.map((h) => /* @__PURE__ */ t(
126
+ return /* @__PURE__ */ t("div", { className: "h-full overflow-auto", children: /* @__PURE__ */ p("table", { className: "w-full text-[12px]", children: [
127
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100 dark:border-border", children: s.map((x) => /* @__PURE__ */ t(
128
128
  "th",
129
129
  {
130
130
  className: "whitespace-nowrap px-3 py-1.5 text-left font-medium text-slate-400",
131
- children: F(h)
131
+ children: K(x)
132
132
  },
133
- h
133
+ x
134
134
  )) }) }),
135
- /* @__PURE__ */ t("tbody", { children: i.map((h, v) => /* @__PURE__ */ t(
135
+ /* @__PURE__ */ t("tbody", { children: o.map((x, k) => /* @__PURE__ */ t(
136
136
  "tr",
137
137
  {
138
- onClick: h.id != null ? () => c.open({ collection: n.collection, itemId: String(h.id) }) : void 0,
139
- className: `border-b border-slate-50 last:border-0 dark:border-border/50 ${h.id != null ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40" : ""}`,
140
- children: s.map(($) => /* @__PURE__ */ t(
138
+ onClick: x.id != null ? () => c.open({ collection: n.collection, itemId: String(x.id) }) : void 0,
139
+ className: `border-b border-slate-50 last:border-0 dark:border-border/50 ${x.id != null ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40" : ""}`,
140
+ children: s.map((_) => /* @__PURE__ */ t(
141
141
  "td",
142
142
  {
143
143
  className: "whitespace-nowrap px-3 py-1.5 text-slate-700 dark:text-slate-300",
144
- children: Nt(h[$])
144
+ children: St(x[_])
145
145
  },
146
- $
146
+ _
147
147
  ))
148
148
  },
149
- h.id != null ? `${h.id}-${v}` : v
149
+ x.id != null ? `${x.id}-${k}` : k
150
150
  )) })
151
151
  ] }) });
152
152
  }
153
- function _t({ slug: e, widget: r }) {
154
- const n = r.config ?? {}, { data: a, isLoading: l, error: u } = ue(e, r, !!n.collection);
155
- return n.collection ? u ? /* @__PURE__ */ t(te, { error: u }) : /* @__PURE__ */ x("div", { className: "flex h-full flex-col items-start justify-center px-4", children: [
156
- l ? /* @__PURE__ */ t("div", { className: "h-9 w-24 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("span", { className: "text-[32px] font-semibold leading-none tracking-tight text-slate-900 dark:text-slate-100", children: (a == null ? void 0 : a.value) != null ? ft(Number(a.value)) : "—" }),
153
+ function Ct({ slug: e, widget: r }) {
154
+ const n = r.config ?? {}, { data: a, isLoading: l, error: u } = pe(e, r, !!n.collection);
155
+ return n.collection ? u ? /* @__PURE__ */ t(le, { error: u }) : /* @__PURE__ */ p("div", { className: "flex h-full flex-col items-start justify-center px-4", children: [
156
+ l ? /* @__PURE__ */ t("div", { className: "h-9 w-24 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("span", { className: "text-[32px] font-semibold leading-none tracking-tight text-slate-900 dark:text-slate-100", children: (a == null ? void 0 : a.value) != null ? bt(Number(a.value)) : "—" }),
157
157
  /* @__PURE__ */ t("span", { className: "mt-1.5 text-[12px] text-slate-400", children: n.label || `${n.aggregate ?? "count"} of ${n.collection}` })
158
158
  ] }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Select a collection" });
159
159
  }
160
- function Ct({ slug: e, widget: r }) {
161
- const { data: n, isLoading: a, error: l } = ue(e, r, !0);
162
- if (a) return /* @__PURE__ */ t(ee, {});
163
- if (l) return /* @__PURE__ */ t(te, { error: l });
160
+ function qt({ slug: e, widget: r }) {
161
+ const { data: n, isLoading: a, error: l } = pe(e, r, !0);
162
+ if (a) return /* @__PURE__ */ t(ae, {});
163
+ if (l) return /* @__PURE__ */ t(le, { error: l });
164
164
  const u = (n == null ? void 0 : n.rows) ?? [];
165
- return u.length ? /* @__PURE__ */ t("div", { className: "h-full overflow-auto px-3 py-1.5", children: u.map((c) => /* @__PURE__ */ x(
165
+ return u.length ? /* @__PURE__ */ t("div", { className: "h-full overflow-auto px-3 py-1.5", children: u.map((c) => /* @__PURE__ */ p(
166
166
  "div",
167
167
  {
168
168
  className: "flex items-center gap-2 border-b border-slate-50 py-1.5 text-[12px] last:border-0 dark:border-border/50",
169
169
  children: [
170
170
  /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-slate-300", children: c.action }),
171
- c.collection && /* @__PURE__ */ x("span", { className: "truncate font-mono text-[11px] text-slate-400", children: [
171
+ c.collection && /* @__PURE__ */ p("span", { className: "truncate font-mono text-[11px] text-slate-400", children: [
172
172
  c.collection,
173
173
  c.item ? ` · ${c.item}` : ""
174
174
  ] }),
175
- /* @__PURE__ */ t("span", { className: "ml-auto shrink-0 text-[11px] text-slate-400", children: xt(c.timestamp) })
175
+ /* @__PURE__ */ t("span", { className: "ml-auto shrink-0 text-[11px] text-slate-400", children: ft(c.timestamp) })
176
176
  ]
177
177
  },
178
178
  c.id
179
179
  )) }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No activity" });
180
180
  }
181
- function qt({ widget: e }) {
181
+ function Tt({ widget: e }) {
182
182
  var n;
183
183
  const r = String(((n = e.config) == null ? void 0 : n.url) ?? "");
184
184
  return r ? /^https?:\/\//i.test(r) ? /* @__PURE__ */ t(
@@ -191,7 +191,7 @@ function qt({ widget: e }) {
191
191
  }
192
192
  ) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-amber-600", children: "URL must start with http(s)://" }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Set an iframe URL" });
193
193
  }
194
- function Le({
194
+ function Be({
195
195
  config: e,
196
196
  initialScope: r,
197
197
  width: n,
@@ -199,14 +199,14 @@ function Le({
199
199
  onClose: l
200
200
  }) {
201
201
  const u = typeof n == "number" ? `${n}px` : n ?? "85%";
202
- return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: l, children: /* @__PURE__ */ x(
202
+ return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: l, children: /* @__PURE__ */ p(
203
203
  "div",
204
204
  {
205
205
  className: "flex h-full flex-col border-l border-slate-200 bg-white shadow-2xl dark:border-border dark:bg-background",
206
206
  style: { width: u, maxWidth: "96%" },
207
207
  onClick: (c) => c.stopPropagation(),
208
208
  children: [
209
- /* @__PURE__ */ x("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
209
+ /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
210
210
  /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: a ?? e.title ?? "Manage" }),
211
211
  /* @__PURE__ */ t(
212
212
  "button",
@@ -218,14 +218,14 @@ function Le({
218
218
  }
219
219
  )
220
220
  ] }),
221
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(ce, { config: e, initialScope: r }) })
221
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(he, { config: e, initialScope: r }) })
222
222
  ]
223
223
  }
224
224
  ) });
225
225
  }
226
226
  function jt({ widget: e }) {
227
- const r = e.config ?? {}, [n, a] = q(!1);
228
- return !r.target_collection || !r.option_collection || !r.key_field || !r.value_field ? /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Matrix editor not configured" }) : r.display === "drawer" ? /* @__PURE__ */ x("div", { className: "flex h-full items-center", children: [
227
+ const r = e.config ?? {}, [n, a] = j(!1);
228
+ return !r.target_collection || !r.option_collection || !r.key_field || !r.value_field ? /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Matrix editor not configured" }) : r.display === "drawer" ? /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
229
229
  /* @__PURE__ */ t(
230
230
  "button",
231
231
  {
@@ -236,14 +236,14 @@ function jt({ widget: e }) {
236
236
  }
237
237
  ),
238
238
  n && /* @__PURE__ */ t(
239
- Le,
239
+ Be,
240
240
  {
241
241
  config: r,
242
242
  width: r.sheet_width,
243
243
  onClose: () => a(!1)
244
244
  }
245
245
  )
246
- ] }) : /* @__PURE__ */ t(ce, { config: r });
246
+ ] }) : /* @__PURE__ */ t(he, { config: r });
247
247
  }
248
248
  function Rt(e) {
249
249
  return it(
@@ -251,33 +251,33 @@ function Rt(e) {
251
251
  typeof window > "u" ? "" : window.location.search
252
252
  );
253
253
  }
254
- function Me(e, r) {
254
+ function Fe(e, r) {
255
255
  const n = [...new Set(e.map((a) => a[r]).filter((a) => a != null && a !== ""))];
256
256
  return n.length ? n.map(String).join(",") : void 0;
257
257
  }
258
- function Be(e, r, n, a, l, u, c) {
258
+ function De(e, r, n, a, l, u, c) {
259
259
  if (typeof e != "string") return e;
260
260
  if (e.startsWith("$row.")) {
261
- const i = e.slice(5);
262
- return !r && c ? Me(c, i) : r == null ? void 0 : r[i];
261
+ const o = e.slice(5);
262
+ return !r && c ? Fe(c, o) : r == null ? void 0 : r[o];
263
263
  }
264
- if (e.startsWith("$rows.")) return Me(n, e.slice(6));
264
+ if (e.startsWith("$rows.")) return Fe(n, e.slice(6));
265
265
  if (e.startsWith("$param.")) return a[e.slice(7)];
266
266
  if (e.startsWith("$filters.")) {
267
- const i = e.slice(9), s = u == null ? void 0 : u.find((h) => h.param === i), m = l[i] ?? [];
268
- return m.length ? m.map((h) => String(h[(s == null ? void 0 : s.value_field) ?? "id"] ?? "")).join(",") : void 0;
267
+ const o = e.slice(9), s = u == null ? void 0 : u.find((x) => x.param === o), m = l[o] ?? [];
268
+ return m.length ? m.map((x) => String(x[(s == null ? void 0 : s.value_field) ?? "id"] ?? "")).join(",") : void 0;
269
269
  }
270
270
  return e;
271
271
  }
272
- function Tt(e, r, n, a, l, u, c) {
273
- const i = {}, s = [];
274
- for (const [m, h] of Object.entries(e.params ?? {})) {
275
- const v = Be(h, r, n, a, l, u, c);
276
- v !== void 0 ? i[m] = v : typeof h == "string" && (h.startsWith("$row.") || h.startsWith("$rows.")) && s.push(m);
272
+ function Wt(e, r, n, a, l, u, c) {
273
+ const o = {}, s = [];
274
+ for (const [m, x] of Object.entries(e.params ?? {})) {
275
+ const k = De(x, r, n, a, l, u, c);
276
+ k !== void 0 ? o[m] = k : typeof x == "string" && (x.startsWith("$row.") || x.startsWith("$rows.")) && s.push(m);
277
277
  }
278
- return { ...e, params: i, ...s.length ? { unresolved_params: s } : {} };
278
+ return { ...e, params: o, ...s.length ? { unresolved_params: s } : {} };
279
279
  }
280
- function Wt(e, r) {
280
+ function Mt(e, r) {
281
281
  var l, u;
282
282
  let n = (l = e.row_noun) == null ? void 0 : l.trim();
283
283
  if (!n) {
@@ -287,22 +287,22 @@ function Wt(e, r) {
287
287
  const a = r === 1 && n.endsWith("s") ? n.slice(0, -1) : n;
288
288
  return `Total of ${r.toLocaleString("en-US")} ${a}`;
289
289
  }
290
- function Mt(e, r) {
291
- const n = at(e), a = [n.title, n.technical ?? ""].join(" "), l = /Missing required parameter:\s*([\w]+)/i.exec(a);
290
+ function Ot(e, r) {
291
+ const n = lt(e), a = [n.title, n.technical ?? ""].join(" "), l = /Missing required parameter:\s*([\w]+)/i.exec(a);
292
292
  if (!l) return null;
293
- const u = F(l[1]).toLowerCase();
293
+ const u = K(l[1]).toLowerCase();
294
294
  return r != null && r.includes(l[1]) ? `Nothing to show: the row you opened has no ${u}.` : `Choose ${u} to see this view.`;
295
295
  }
296
- function Ot({
296
+ function Ft({
297
297
  config: e,
298
298
  stats: r,
299
299
  asOf: n,
300
300
  note: a
301
301
  }) {
302
- const l = K(), u = e.params ?? {}, { data: c, isPending: i, isError: s } = z({
302
+ const l = X(), u = e.params ?? {}, { data: c, isPending: o, isError: s } = G({
303
303
  queryKey: ["page-renderer-query", e.query_slug, JSON.stringify(u)],
304
304
  queryFn: () => l.request(
305
- Z(`/custom-queries/${e.query_slug}/execute`, { params: u })
305
+ ne(`/custom-queries/${e.query_slug}/execute`, { params: u })
306
306
  ),
307
307
  enabled: !!e.query_slug,
308
308
  staleTime: 6e4
@@ -313,12 +313,12 @@ function Ot({
313
313
  className: "shrink-0 border-b border-slate-200 bg-white px-4 py-3 dark:border-border dark:bg-card",
314
314
  "data-sheet-header": !0,
315
315
  children: /* @__PURE__ */ t(
316
- wt,
316
+ Nt,
317
317
  {
318
318
  stats: r,
319
319
  rows: (c == null ? void 0 : c.data) ?? [],
320
320
  params: u,
321
- loading: i && !s,
321
+ loading: o && !s,
322
322
  error: s,
323
323
  asOf: n,
324
324
  note: a
@@ -333,26 +333,26 @@ function Pt({
333
333
  totalCount: n,
334
334
  onClose: a
335
335
  }) {
336
- const [l, u] = q(e.initialTab ?? 0), c = !r && n != null ? Wt(e, n) : e.title ? e.title.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (m, h) => {
337
- const v = r == null ? void 0 : r[h];
338
- return v == null ? "" : String(v);
339
- }) : "Details", i = typeof e.width == "number" ? `${e.width}px` : e.width ?? "90%", s = e.resolvedTabs[l];
340
- return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: a, children: /* @__PURE__ */ x(
336
+ const [l, u] = j(e.initialTab ?? 0), c = !r && n != null ? Mt(e, n) : e.title ? e.title.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (m, x) => {
337
+ const k = r == null ? void 0 : r[x];
338
+ return k == null ? "" : String(k);
339
+ }) : "Details", o = typeof e.width == "number" ? `${e.width}px` : e.width ?? "90%", s = e.resolvedTabs[l];
340
+ return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: a, children: /* @__PURE__ */ p(
341
341
  "div",
342
342
  {
343
343
  className: "flex h-full flex-col border-l border-slate-200 bg-slate-50 shadow-2xl dark:border-border dark:bg-background",
344
- style: { width: i, maxWidth: "96%" },
344
+ style: { width: o, maxWidth: "96%" },
345
345
  onClick: (m) => m.stopPropagation(),
346
346
  children: [
347
- /* @__PURE__ */ x("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-border dark:bg-card", children: [
348
- /* @__PURE__ */ x("div", { className: "flex items-center gap-3", children: [
347
+ /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-border dark:bg-card", children: [
348
+ /* @__PURE__ */ p("div", { className: "flex items-center gap-3", children: [
349
349
  /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: c }),
350
- e.resolvedTabs.length > 1 && /* @__PURE__ */ t("div", { className: "flex gap-1", children: e.resolvedTabs.map((m, h) => /* @__PURE__ */ t(
350
+ e.resolvedTabs.length > 1 && /* @__PURE__ */ t("div", { className: "flex gap-1", children: e.resolvedTabs.map((m, x) => /* @__PURE__ */ t(
351
351
  "button",
352
352
  {
353
353
  type: "button",
354
- onClick: () => u(h),
355
- className: `rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors ${h === l ? "bg-nvr-cyan/10 text-slate-800 dark:text-slate-100" : "text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,
354
+ onClick: () => u(x),
355
+ className: `rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors ${x === l ? "bg-nvr-cyan/10 text-slate-800 dark:text-slate-100" : "text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,
356
356
  children: m.label
357
357
  },
358
358
  m.label
@@ -369,7 +369,7 @@ function Pt({
369
369
  )
370
370
  ] }),
371
371
  e.header && /* @__PURE__ */ t(
372
- Ot,
372
+ Ft,
373
373
  {
374
374
  config: e.header.config,
375
375
  stats: e.header.stats,
@@ -378,14 +378,14 @@ function Pt({
378
378
  }
379
379
  ),
380
380
  /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: s != null && s.matrix ? /* @__PURE__ */ t(
381
- ce,
381
+ he,
382
382
  {
383
383
  config: s.matrix.config,
384
384
  initialScope: s.matrix.initialScope,
385
385
  lockScope: !0
386
386
  },
387
387
  l
388
- ) : s != null && s.config ? /* @__PURE__ */ x(B, { children: [
388
+ ) : s != null && s.config ? /* @__PURE__ */ p(J, { children: [
389
389
  s.note && /* @__PURE__ */ t(
390
390
  "p",
391
391
  {
@@ -405,20 +405,20 @@ function At(e, r, n, a) {
405
405
  const l = (s) => {
406
406
  const m = /^\$filters\.(\w+)(?:\.(\w+))?$/.exec(s);
407
407
  if (!m) return;
408
- const h = a == null ? void 0 : a.find((N) => N.param === m[1]), v = (n == null ? void 0 : n[m[1]]) ?? [];
409
- if (v.length === 0) return;
410
- const $ = m[2] ?? (h == null ? void 0 : h.value_field) ?? "id";
411
- return v.map((N) => N[$]);
408
+ const x = a == null ? void 0 : a.find((w) => w.param === m[1]), k = (n == null ? void 0 : n[m[1]]) ?? [];
409
+ if (k.length === 0) return;
410
+ const _ = m[2] ?? (x == null ? void 0 : x.value_field) ?? "id";
411
+ return k.map((w) => w[_]);
412
412
  }, u = (s) => typeof s == "string" && s.startsWith("$row.") ? r[s.slice(5)] : typeof s == "string" && s.startsWith("$filters.") ? l(s) : Array.isArray(s) ? s.map(u) : s && typeof s == "object" ? Object.fromEntries(
413
- Object.entries(s).map(([m, h]) => [m, u(h)])
414
- ) : s, c = (s) => s === void 0 ? !0 : Array.isArray(s) ? s.some(c) : s && typeof s == "object" ? Object.values(s).some(c) : !1, i = u(e);
415
- return Array.isArray(i._and) && (i._and = i._and.filter((s) => !c(s))), c(i) ? void 0 : i;
413
+ Object.entries(s).map(([m, x]) => [m, u(x)])
414
+ ) : s, c = (s) => s === void 0 ? !0 : Array.isArray(s) ? s.some(c) : s && typeof s == "object" ? Object.values(s).some(c) : !1, o = u(e);
415
+ return Array.isArray(o._and) && (o._and = o._and.filter((s) => !c(s))), c(o) ? void 0 : o;
416
416
  }
417
- const Ft = 400, Et = 2500;
418
- function Oe(e, r) {
417
+ const Et = 400, Lt = 2500;
418
+ function Pe(e, r) {
419
419
  return e.map((n) => String(n[r] ?? "")).sort().join("\0");
420
420
  }
421
- function Lt({
421
+ function Bt({
422
422
  filter: e,
423
423
  selected: r,
424
424
  onChange: n,
@@ -426,76 +426,99 @@ function Lt({
426
426
  scopeDefault: l,
427
427
  onOpenChange: u
428
428
  }) {
429
- const c = K(), [i, s] = q(!1), m = D(u);
430
- m.current = u, X(() => {
431
- var k;
432
- (k = m.current) == null || k.call(m, i);
433
- }, [i]);
434
- const [h, v] = q(""), $ = D(null), N = e.value_field ?? "id", j = e.label_field ?? N, { data: _ = [] } = z({
435
- queryKey: ["page-renderer-filter", e.collection, N, j, e.sort],
429
+ const c = X(), [o, s] = j(!1), m = Y(u);
430
+ m.current = u, re(() => {
431
+ var b;
432
+ (b = m.current) == null || b.call(m, o);
433
+ }, [o]);
434
+ const [x, k] = j(""), _ = Y(null), w = e.value_field ?? "id", q = e.label_field ?? w, S = e.secondary_field, O = [.../* @__PURE__ */ new Set(["id", w, q, S ?? ""])].filter(Boolean).join(","), { data: M } = G({
435
+ queryKey: [
436
+ "page-renderer-filter",
437
+ e.collection,
438
+ w,
439
+ q,
440
+ S ?? "",
441
+ e.sort
442
+ ],
436
443
  queryFn: () => c.request(
437
- Fe(`/items/${e.collection}`, {
438
- fields: [.../* @__PURE__ */ new Set(["id", N, j])].join(","),
444
+ me(`/items/${e.collection}`, {
445
+ fields: O,
439
446
  limit: e.limit ?? 500,
440
447
  ...e.sort ? { sort: e.sort } : {}
441
448
  })
442
- ).then((k) => k.data ?? []),
449
+ ).then((b) => {
450
+ const C = b.data ?? [], B = typeof b.total == "number" && b.total > C.length || C.length >= (e.limit ?? 500);
451
+ return { rows: C, more: B };
452
+ }),
453
+ staleTime: 6e4
454
+ }), F = (M == null ? void 0 : M.rows) ?? [], T = (M == null ? void 0 : M.more) === !0, R = x.trim(), P = Xe(R), { data: d = [] } = G({
455
+ queryKey: ["page-renderer-filter-search", e.collection, O, P],
456
+ enabled: T && P.length > 0,
457
+ queryFn: () => c.request(
458
+ me(`/items/${e.collection}`, {
459
+ fields: O,
460
+ limit: 100,
461
+ search: P,
462
+ search_fields: [.../* @__PURE__ */ new Set([w, q, S ?? ""])].filter(Boolean).join(","),
463
+ ...e.sort ? { sort: e.sort } : {}
464
+ })
465
+ ).then((b) => b.data ?? []),
443
466
  staleTime: 6e4
444
467
  });
445
- X(() => {
446
- if (!i) return;
447
- const k = (T) => {
448
- $.current && !$.current.contains(T.target) && s(!1);
468
+ re(() => {
469
+ if (!o) return;
470
+ const b = (C) => {
471
+ _.current && !_.current.contains(C.target) && s(!1);
449
472
  };
450
- return window.addEventListener("mousedown", k), () => window.removeEventListener("mousedown", k);
451
- }, [i]);
452
- const W = e.label ?? F(e.param), M = ut(
453
- a != null && a.length ? _.filter((k) => a.some((T) => String(T) === String(k.id))) : _,
454
- (k) => String(k[N] ?? "")
455
- ).filter(
456
- (k) => h ? String(k[j] ?? "").toLowerCase().includes(h.toLowerCase()) : !0
457
- ), C = a != null && a.length ? {
473
+ return window.addEventListener("mousedown", b), () => window.removeEventListener("mousedown", b);
474
+ }, [o]);
475
+ const y = e.label ?? K(e.param), L = T && R ? [...r, ...d] : F, Q = mt(
476
+ a != null && a.length ? L.filter((b) => a.some((C) => String(C) === String(b.id))) : L,
477
+ (b) => String(b[w] ?? "")
478
+ ), U = (b) => [b[w], b[q], S ? b[S] : null].filter((C) => C != null && C !== "").join(" ").toLowerCase(), I = Q.filter(
479
+ (b) => R ? U(b).includes(R.toLowerCase()) : !0
480
+ ), V = T && R.length > 0 && P !== R, D = a != null && a.length ? {
458
481
  label: "restricted",
459
482
  cls: "bg-amber-500/15 text-amber-700 dark:text-amber-300",
460
- title: `Options limited to your restricted ${W} scope${l ? "; selection seeded from your defaults" : ""}`
483
+ title: `Options limited to your restricted ${y} scope${l ? "; selection seeded from your defaults" : ""}`
461
484
  } : l && r.length > 0 ? {
462
485
  label: "your default",
463
486
  cls: "bg-nvr-cyan/[0.12] text-[#0284a8] dark:text-nvr-cyan",
464
- title: `Pre-selected from your default ${W} scope — adjust freely`
487
+ title: `Pre-selected from your default ${y} scope — adjust freely`
465
488
  } : null;
466
- return /* @__PURE__ */ x("div", { ref: $, className: "relative", children: [
467
- /* @__PURE__ */ x(
489
+ return /* @__PURE__ */ p("div", { ref: _, className: "relative", children: [
490
+ /* @__PURE__ */ p(
468
491
  "button",
469
492
  {
470
493
  type: "button",
471
- onClick: () => s((k) => !k),
494
+ onClick: () => s((b) => !b),
472
495
  className: `inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-[12px] transition-colors ${r.length > 0 ? "border-nvr-cyan bg-nvr-cyan/10 text-slate-700 dark:text-slate-200" : "border-slate-200 bg-white text-slate-600 hover:border-slate-400 dark:border-border dark:bg-card dark:text-slate-300"}`,
473
496
  children: [
474
- /* @__PURE__ */ t("span", { className: "font-medium", children: W }),
475
- C && /* @__PURE__ */ t(
497
+ /* @__PURE__ */ t("span", { className: "font-medium", children: y }),
498
+ D && /* @__PURE__ */ t(
476
499
  "span",
477
500
  {
478
- title: C.title,
479
- className: `rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide ${C.cls}`,
480
- children: C.label
501
+ title: D.title,
502
+ className: `rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide ${D.cls}`,
503
+ children: D.label
481
504
  }
482
505
  ),
483
- /* @__PURE__ */ t("span", { className: "text-slate-400", children: r.length === 0 ? "All" : r.length === 1 ? String(r[0][j] ?? r[0][N] ?? "") : `${r.length} selected` }),
506
+ /* @__PURE__ */ t("span", { className: "text-slate-400", children: r.length === 0 ? "All" : r.length === 1 ? String(r[0][q] ?? r[0][w] ?? "") : `${r.length} selected` }),
484
507
  /* @__PURE__ */ t("span", { className: "text-slate-400", children: "⌃" })
485
508
  ]
486
509
  }
487
510
  ),
488
- i && /* @__PURE__ */ x("div", { className: "absolute left-0 top-9 z-40 w-56 rounded-md border border-slate-200 bg-white p-1 shadow-md dark:border-border dark:bg-popover", children: [
511
+ o && /* @__PURE__ */ p("div", { className: "absolute left-0 top-9 z-40 w-56 rounded-md border border-slate-200 bg-white p-1 shadow-md dark:border-border dark:bg-popover", children: [
489
512
  /* @__PURE__ */ t(
490
513
  "input",
491
514
  {
492
- value: h,
493
- onChange: (k) => v(k.target.value),
515
+ value: x,
516
+ onChange: (b) => k(b.target.value),
494
517
  placeholder: "Search…",
495
518
  className: "mb-1 h-7 w-full rounded border border-slate-200 bg-white px-2 text-[12px] outline-none dark:border-border dark:bg-background"
496
519
  }
497
520
  ),
498
- /* @__PURE__ */ x("div", { className: "max-h-64 overflow-y-auto", children: [
521
+ /* @__PURE__ */ p("div", { className: "max-h-64 overflow-y-auto", children: [
499
522
  r.length > 0 && /* @__PURE__ */ t(
500
523
  "button",
501
524
  {
@@ -505,41 +528,47 @@ function Lt({
505
528
  children: "Clear selection"
506
529
  }
507
530
  ),
508
- M.map((k) => {
509
- const T = String(k[N] ?? ""), d = r.some((g) => String(g[N] ?? "") === T);
510
- return /* @__PURE__ */ x(
531
+ I.map((b) => {
532
+ const C = String(b[w] ?? ""), B = r.some((A) => String(A[w] ?? "") === C);
533
+ return /* @__PURE__ */ p(
511
534
  "button",
512
535
  {
513
536
  type: "button",
514
537
  onClick: () => {
515
538
  if (e.single) {
516
- n(d ? [] : [k]), s(!1);
539
+ n(B ? [] : [b]), s(!1);
517
540
  return;
518
541
  }
519
542
  n(
520
- d ? r.filter((g) => String(g[N] ?? "") !== T) : [...r, k]
543
+ B ? r.filter((A) => String(A[w] ?? "") !== C) : [...r, b]
521
544
  );
522
545
  },
523
546
  className: "flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px] text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-muted",
524
547
  children: [
525
- /* @__PURE__ */ t("span", { className: `w-3.5 shrink-0 text-nvr-cyan ${d ? "" : "invisible"}`, children: "✓" }),
526
- /* @__PURE__ */ t("span", { className: "truncate", children: String(k[j] ?? T) })
548
+ /* @__PURE__ */ t("span", { className: `w-3.5 shrink-0 text-nvr-cyan ${B ? "" : "invisible"}`, children: "✓" }),
549
+ /* @__PURE__ */ t("span", { className: "truncate", children: String(b[q] ?? C) }),
550
+ S && b[S] != null && b[S] !== "" && /* @__PURE__ */ t("span", { className: "min-w-0 truncate text-[11px] text-slate-400", children: String(b[S]) })
527
551
  ]
528
552
  },
529
- T
553
+ C
530
554
  );
531
555
  }),
532
- M.length === 0 && /* @__PURE__ */ t("p", { className: "px-2 py-1.5 text-[12px] text-slate-400", children: "No options" })
556
+ I.length === 0 && /* @__PURE__ */ t("p", { className: "px-2 py-1.5 text-[12px] text-slate-400", "aria-live": "polite", children: V ? "Searching…" : R ? `No matches for “${R}”` : "No options" }),
557
+ T && !R && /* @__PURE__ */ p("p", { className: "px-2 py-1.5 text-[11px] text-slate-400", children: [
558
+ "Showing the first ",
559
+ F.length.toLocaleString("en-US"),
560
+ " — type to search all"
561
+ ] })
533
562
  ] })
534
563
  ] })
535
564
  ] });
536
565
  }
537
- function Bt({ widget: e }) {
566
+ function Dt({ widget: e }) {
538
567
  return /* @__PURE__ */ t(Ie, { config: e.config ?? {} });
539
568
  }
540
569
  function It({ widget: e }) {
541
- const r = e.config ?? {}, [n, a] = q(!1);
542
- return r.collection ? r.display === "drawer" ? /* @__PURE__ */ x("div", { className: "flex h-full items-center", children: [
570
+ const r = e.config ?? {}, [n, a] = j(!1);
571
+ return r.collection ? r.display === "drawer" ? /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
543
572
  /* @__PURE__ */ t(
544
573
  "button",
545
574
  {
@@ -554,7 +583,7 @@ function It({ widget: e }) {
554
583
  {
555
584
  className: "fixed inset-0 z-50 flex justify-end bg-black/30",
556
585
  onClick: () => a(!1),
557
- children: /* @__PURE__ */ x(
586
+ children: /* @__PURE__ */ p(
558
587
  "div",
559
588
  {
560
589
  className: "flex h-full flex-col border-l border-slate-200 bg-white shadow-2xl dark:border-border dark:bg-background",
@@ -564,7 +593,7 @@ function It({ widget: e }) {
564
593
  },
565
594
  onClick: (l) => l.stopPropagation(),
566
595
  children: [
567
- /* @__PURE__ */ x("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
596
+ /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 px-4 py-2.5 dark:border-border", children: [
568
597
  /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: r.button_label ?? r.title ?? "Manage" }),
569
598
  /* @__PURE__ */ t(
570
599
  "button",
@@ -576,19 +605,19 @@ function It({ widget: e }) {
576
605
  }
577
606
  )
578
607
  ] }),
579
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(We, { config: r }) })
608
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(Oe, { config: r }) })
580
609
  ]
581
610
  }
582
611
  )
583
612
  }
584
613
  )
585
- ] }) : /* @__PURE__ */ t(We, { config: r }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Configure the record grid (collection)" });
614
+ ] }) : /* @__PURE__ */ t(Oe, { config: r }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Configure the record grid (collection)" });
586
615
  }
587
- function Dt({
616
+ function zt({
588
617
  cfg: e
589
618
  }) {
590
- const [r, n] = q(!1), a = { ...e };
591
- return delete a.display, /* @__PURE__ */ x("div", { className: "flex h-full items-center", children: [
619
+ const [r, n] = j(!1), a = { ...e };
620
+ return delete a.display, /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
592
621
  /* @__PURE__ */ t(
593
622
  "button",
594
623
  {
@@ -603,7 +632,7 @@ function Dt({
603
632
  {
604
633
  className: "fixed inset-0 z-50 flex justify-end bg-black/30",
605
634
  onClick: () => n(!1),
606
- children: /* @__PURE__ */ x(
635
+ children: /* @__PURE__ */ p(
607
636
  "div",
608
637
  {
609
638
  className: "flex h-full flex-col border-l border-slate-200 bg-slate-50 shadow-2xl dark:border-border dark:bg-background",
@@ -613,7 +642,7 @@ function Dt({
613
642
  },
614
643
  onClick: (l) => l.stopPropagation(),
615
644
  children: [
616
- /* @__PURE__ */ x("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-border dark:bg-card", children: [
645
+ /* @__PURE__ */ p("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-border dark:bg-card", children: [
617
646
  /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: e.button_label ?? e.label ?? "View" }),
618
647
  /* @__PURE__ */ t(
619
648
  "button",
@@ -625,7 +654,7 @@ function Dt({
625
654
  }
626
655
  )
627
656
  ] }),
628
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(De, { config: a }) })
657
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(ze, { config: a }) })
629
658
  ]
630
659
  }
631
660
  )
@@ -634,110 +663,110 @@ function Dt({
634
663
  ] });
635
664
  }
636
665
  function Ie({ config: e }) {
637
- return e.display === "drawer" ? /* @__PURE__ */ t(Dt, { cfg: e }) : /* @__PURE__ */ t(De, { config: e });
666
+ return e.display === "drawer" ? /* @__PURE__ */ t(zt, { cfg: e }) : /* @__PURE__ */ t(ze, { config: e });
638
667
  }
639
- function De({ config: e }) {
640
- var ke, we, Ne, Se, $e, _e, Ce, qe, je;
641
- const r = K(), n = Ae(), [a, l] = q(null), [u, c] = q(null), [i, s] = q(null), [m, h] = q(
668
+ function ze({ config: e }) {
669
+ var Ne, Se, $e, _e, Ce, qe, Te, je, Re;
670
+ const r = X(), n = Ee(), [a, l] = j(null), [u, c] = j(null), [o, s] = j(null), [m, x] = j(
642
671
  () => Rt(e.filters)
643
- ), [v] = q(
644
- () => st(e.filters, typeof window > "u" ? "" : window.location.search)
645
- ), $ = (o, p) => {
646
- const f = { ...m, [o]: p };
647
- if (h(f), typeof window > "u" || !(e.filters ?? []).some((y) => y.url_param)) return;
648
- const b = ot(e.filters, f, window.location.search);
649
- b !== window.location.search && window.history.replaceState(
672
+ ), [k] = j(
673
+ () => ot(e.filters, typeof window > "u" ? "" : window.location.search)
674
+ ), _ = (i, h) => {
675
+ const f = { ...m, [i]: h };
676
+ if (x(f), typeof window > "u" || !(e.filters ?? []).some((v) => v.url_param)) return;
677
+ const g = dt(e.filters, f, window.location.search);
678
+ g !== window.location.search && window.history.replaceState(
650
679
  window.history.state,
651
680
  "",
652
- `${window.location.pathname}${b}${window.location.hash}`
681
+ `${window.location.pathname}${g}${window.location.hash}`
653
682
  );
654
- }, [N, j] = q(null), [_, W] = q(null), P = (_ == null ? void 0 : _.phase) === "running", M = He();
655
- X(() => {
656
- if ((_ == null ? void 0 : _.phase) !== "running") return;
657
- const o = window.setInterval(() => {
658
- W(
659
- (p) => (p == null ? void 0 : p.phase) === "running" ? { ...p, elapsedMs: Date.now() - p.startedAt } : p
683
+ }, [w, q] = j(null), [S, O] = j(null), M = (S == null ? void 0 : S.phase) === "running", F = He();
684
+ re(() => {
685
+ if ((S == null ? void 0 : S.phase) !== "running") return;
686
+ const i = window.setInterval(() => {
687
+ O(
688
+ (h) => (h == null ? void 0 : h.phase) === "running" ? { ...h, elapsedMs: Date.now() - h.startedAt } : h
660
689
  );
661
690
  }, 250);
662
- return () => window.clearInterval(o);
663
- }, [_ == null ? void 0 : _.phase]);
664
- const { scopes: C, ready: k } = mt(), T = D(!1), [d, g] = q(!1), [E, Q] = q(/* @__PURE__ */ new Map());
665
- X(() => {
666
- if (T.current || !k) return;
667
- T.current = !0;
668
- const o = (e.filters ?? []).filter(
669
- (p) => !(m[p.param] ?? []).length && !v.has(p.param)
691
+ return () => window.clearInterval(i);
692
+ }, [S == null ? void 0 : S.phase]);
693
+ const { scopes: T, ready: R } = ht(), P = Y(!1), [d, y] = j(!1), [L, Q] = j(/* @__PURE__ */ new Map());
694
+ re(() => {
695
+ if (P.current || !R) return;
696
+ P.current = !0;
697
+ const i = (e.filters ?? []).filter(
698
+ (h) => !(m[h.param] ?? []).length && !k.has(h.param)
670
699
  );
671
- if (!C || !o.length) {
672
- g(!0);
700
+ if (!T || !i.length) {
701
+ y(!0);
673
702
  return;
674
703
  }
675
704
  (async () => {
676
705
  try {
677
- const p = {};
678
- for (const f of o) {
679
- const b = Te(C, { key: f.param, collection: f.collection });
680
- if (!b) continue;
681
- const y = pt(C, b.name);
682
- if (!y.length) continue;
683
- const S = f.value_field ?? "id", O = await ht(
706
+ const h = {};
707
+ for (const f of i) {
708
+ const g = Me(T, { key: f.param, collection: f.collection });
709
+ if (!g) continue;
710
+ const v = pt(T, g.name);
711
+ if (!v.length) continue;
712
+ const $ = f.value_field ?? "id", E = await xt(
684
713
  r,
685
- b,
686
- y,
687
- S
714
+ g,
715
+ v,
716
+ $
688
717
  );
689
- if (O.length) {
690
- const R = O.map((H, se) => ({ [S]: H, id: y[se] }));
691
- p[f.param] = f.single ? R.slice(0, 1) : R;
718
+ if (E.length) {
719
+ const W = E.map((ee, ie) => ({ [$]: ee, id: v[ie] }));
720
+ h[f.param] = f.single ? W.slice(0, 1) : W;
692
721
  }
693
722
  }
694
- Object.keys(p).length && (h((f) => {
695
- const b = { ...f };
696
- for (const [y, S] of Object.entries(p))
697
- (b[y] ?? []).length || (b[y] = S);
698
- return b;
723
+ Object.keys(h).length && (x((f) => {
724
+ const g = { ...f };
725
+ for (const [v, $] of Object.entries(h))
726
+ (g[v] ?? []).length || (g[v] = $);
727
+ return g;
699
728
  }), Q(
700
729
  new Map(
701
- Object.entries(p).map(([f, b]) => {
702
- var S;
703
- const y = ((S = (e.filters ?? []).find((O) => O.param === f)) == null ? void 0 : S.value_field) ?? "id";
704
- return [f, Oe(b, y)];
730
+ Object.entries(h).map(([f, g]) => {
731
+ var $;
732
+ const v = (($ = (e.filters ?? []).find((E) => E.param === f)) == null ? void 0 : $.value_field) ?? "id";
733
+ return [f, Pe(g, v)];
705
734
  })
706
735
  )
707
736
  ));
708
737
  } finally {
709
- g(!0);
738
+ y(!0);
710
739
  }
711
740
  })();
712
- }, [k, C, e.filters, m, r, v]);
713
- const J = Re(() => {
714
- const o = { ...e.params ?? {} };
715
- for (const p of e.filters ?? []) {
716
- const f = m[p.param] ?? [];
717
- f.length > 0 && (o[p.param] = f.map((b) => String(b[p.value_field ?? "id"] ?? "")).join(","));
741
+ }, [R, T, e.filters, m, r, k]);
742
+ const U = We(() => {
743
+ const i = { ...e.params ?? {} };
744
+ for (const h of e.filters ?? []) {
745
+ const f = m[h.param] ?? [];
746
+ f.length > 0 && (i[h.param] = f.map((g) => String(g[h.value_field ?? "id"] ?? "")).join(","));
718
747
  }
719
- return o;
720
- }, [e.params, e.filters, m]), [U, V] = q(/* @__PURE__ */ new Set()), re = D(!1), me = JSON.stringify(J), ze = nt(
721
- me,
722
- re.current ? U.size > 0 ? Et : Ft : 0
723
- ), ne = re.current ? ze : me, L = Re(
724
- () => JSON.parse(ne),
725
- [ne]
726
- ), ae = D(!1), {
727
- data: A,
728
- isPending: pe,
729
- error: he,
730
- refetch: xe,
731
- isFetching: fe,
748
+ return i;
749
+ }, [e.params, e.filters, m]), [I, V] = j(/* @__PURE__ */ new Set()), D = Y(!1), b = JSON.stringify(U), C = at(
750
+ b,
751
+ D.current ? I.size > 0 ? Lt : Et : 0
752
+ ), B = D.current ? C : b, A = We(
753
+ () => JSON.parse(B),
754
+ [B]
755
+ ), se = Y(!1), {
756
+ data: z,
757
+ isPending: xe,
758
+ error: fe,
759
+ refetch: be,
760
+ isFetching: ge,
732
761
  isPlaceholderData: Ke
733
- } = z({
734
- queryKey: ["page-renderer-query", e.query_slug, ne],
762
+ } = G({
763
+ queryKey: ["page-renderer-query", e.query_slug, B],
735
764
  queryFn: () => {
736
- const o = ae.current;
737
- return ae.current = !1, r.request(
738
- Z(`/custom-queries/${e.query_slug}/execute`, {
739
- params: L,
740
- ...o ? { refresh: !0 } : {}
765
+ const i = se.current;
766
+ return se.current = !1, r.request(
767
+ ne(`/custom-queries/${e.query_slug}/execute`, {
768
+ params: A,
769
+ ...i ? { refresh: !0 } : {}
741
770
  })
742
771
  );
743
772
  },
@@ -747,235 +776,235 @@ function De({ config: e }) {
747
776
  // new answer lands: swapping it for the loader unmounted QueryTable and
748
777
  // reset its view state — "Hide empty rows" switched itself off (L13).
749
778
  // Only the same query's answer stands in; another slug starts fresh.
750
- placeholderData: (o, p) => (p == null ? void 0 : p.queryKey[1]) === e.query_slug ? o : void 0
751
- }), I = A == null ? void 0 : A.data, G = Ke && fe, Qe = Ye(() => {
752
- ae.current = !0, xe();
753
- }, [xe]), be = pe;
779
+ placeholderData: (i, h) => (h == null ? void 0 : h.queryKey[1]) === e.query_slug ? i : void 0
780
+ }), H = z == null ? void 0 : z.data, Z = Ke && ge, Qe = Ye(() => {
781
+ se.current = !0, be();
782
+ }, [be]), ye = xe;
754
783
  if (!e.query_slug) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Set a query slug" });
755
- const Je = (o) => {
756
- var y;
757
- const p = {};
758
- for (const [S, O] of Object.entries(o.params ?? {})) {
759
- const R = Be(O, null, I ?? [], L, m, e.filters);
760
- if (R === void 0) {
761
- j(`Select a value for "${S}" first`);
784
+ const Ue = (i) => {
785
+ var v;
786
+ const h = {};
787
+ for (const [$, E] of Object.entries(i.params ?? {})) {
788
+ const W = De(E, null, H ?? [], A, m, e.filters);
789
+ if (W === void 0) {
790
+ q(`Select a value for "${$}" first`);
762
791
  return;
763
792
  }
764
- p[S] = R;
793
+ h[$] = W;
765
794
  }
766
- const f = (y = o.confirm) == null ? void 0 : y.replace(/\{(\w+)\}/g, (S, O) => String(p[O] ?? "")), b = {
767
- action: o,
768
- params: p,
795
+ const f = (v = i.confirm) == null ? void 0 : v.replace(/\{(\w+)\}/g, ($, E) => String(h[E] ?? "")), g = {
796
+ action: i,
797
+ params: h,
769
798
  phase: f ? "confirm" : "running",
770
799
  confirmText: f ?? null,
771
800
  startedAt: Date.now(),
772
801
  elapsedMs: 0
773
802
  };
774
- W(b), f || ge(b);
775
- }, ge = async (o) => {
776
- const p = Date.now();
777
- W({ ...o, phase: "running", startedAt: p, elapsedMs: 0 });
803
+ O(g), f || ve(g);
804
+ }, ve = async (i) => {
805
+ const h = Date.now();
806
+ O({ ...i, phase: "running", startedAt: h, elapsedMs: 0 });
778
807
  try {
779
808
  const f = await r.request(
780
- Z(`/custom-queries/${o.action.query_slug}/execute`, { params: o.params })
781
- ), b = Array.isArray(f == null ? void 0 : f.data) ? f.data : [];
782
- W(
783
- (y) => y && y.action === o.action ? {
784
- ...y,
809
+ ne(`/custom-queries/${i.action.query_slug}/execute`, { params: i.params })
810
+ ), g = Array.isArray(f == null ? void 0 : f.data) ? f.data : [];
811
+ O(
812
+ (v) => v && v.action === i.action ? {
813
+ ...v,
785
814
  phase: "done",
786
- elapsedMs: Date.now() - p,
787
- resultRows: b.length,
788
- resultSample: b[0] ?? null
789
- } : y
790
- ), j(
791
- `${o.action.success_message ?? `${o.action.label} completed`} · ${Y(Date.now() - p)}`
792
- ), M.invalidateQueries({ queryKey: ["page-renderer-query", e.query_slug] });
815
+ elapsedMs: Date.now() - h,
816
+ resultRows: g.length,
817
+ resultSample: g[0] ?? null
818
+ } : v
819
+ ), q(
820
+ `${i.action.success_message ?? `${i.action.label} completed`} · ${te(Date.now() - h)}`
821
+ ), F.invalidateQueries({ queryKey: ["page-renderer-query", e.query_slug] });
793
822
  } catch (f) {
794
- const b = Ee(f, "unknown error");
795
- W(
796
- (y) => y && y.action === o.action ? { ...y, phase: "error", elapsedMs: Date.now() - p, error: b } : y
797
- ), j(`${o.action.label} failed: ${b}`);
823
+ const g = Le(f, "unknown error");
824
+ O(
825
+ (v) => v && v.action === i.action ? { ...v, phase: "error", elapsedMs: Date.now() - h, error: g } : v
826
+ ), q(`${i.action.label} failed: ${g}`);
798
827
  }
799
- }, Ue = /* @__PURE__ */ t(
800
- bt,
828
+ }, Ve = /* @__PURE__ */ t(
829
+ gt,
801
830
  {
802
- envelope: A,
831
+ envelope: z,
803
832
  onRefresh: Qe,
804
- refreshing: fe && !pe,
833
+ refreshing: ge && !xe,
805
834
  className: "ml-auto"
806
835
  }
807
- ), le = e.filters && e.filters.length > 0 || (ke = e.actions) != null && ke.length || A != null && A.cache_ttl ? /* @__PURE__ */ x("div", { className: "flex flex-wrap items-center gap-2 pb-2", children: [
808
- (e.filters ?? []).map((o) => {
809
- const p = Te(C, { key: o.param, collection: o.collection }), f = p ? (C == null ? void 0 : C.restricted[p.name]) ?? [] : [];
836
+ ), oe = e.filters && e.filters.length > 0 || (Ne = e.actions) != null && Ne.length || z != null && z.cache_ttl ? /* @__PURE__ */ p("div", { className: "flex flex-wrap items-center gap-2 pb-2", children: [
837
+ (e.filters ?? []).map((i) => {
838
+ const h = Me(T, { key: i.param, collection: i.collection }), f = h ? (T == null ? void 0 : T.restricted[h.name]) ?? [] : [];
810
839
  return /* @__PURE__ */ t(
811
- Lt,
840
+ Bt,
812
841
  {
813
- filter: o,
814
- selected: m[o.param] ?? [],
842
+ filter: i,
843
+ selected: m[i.param] ?? [],
815
844
  allowedIds: f.length > 0 ? f : void 0,
816
- scopeDefault: E.has(o.param) && E.get(o.param) === Oe(m[o.param] ?? [], o.value_field ?? "id"),
817
- onChange: (b) => {
818
- re.current = !0, $(o.param, b);
845
+ scopeDefault: L.has(i.param) && L.get(i.param) === Pe(m[i.param] ?? [], i.value_field ?? "id"),
846
+ onChange: (g) => {
847
+ D.current = !0, _(i.param, g);
819
848
  },
820
- onOpenChange: (b) => V((y) => {
821
- if (y.has(o.param) === b) return y;
822
- const S = new Set(y);
823
- return b ? S.add(o.param) : S.delete(o.param), S;
849
+ onOpenChange: (g) => V((v) => {
850
+ if (v.has(i.param) === g) return v;
851
+ const $ = new Set(v);
852
+ return g ? $.add(i.param) : $.delete(i.param), $;
824
853
  })
825
854
  },
826
- o.param
855
+ i.param
827
856
  );
828
857
  }),
829
- (e.actions ?? []).map((o) => /* @__PURE__ */ t(
858
+ (e.actions ?? []).map((i) => /* @__PURE__ */ t(
830
859
  "button",
831
860
  {
832
861
  type: "button",
833
- disabled: P,
834
- onClick: () => void Je(o),
862
+ disabled: M,
863
+ onClick: () => void Ue(i),
835
864
  className: "ml-auto inline-flex h-8 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white hover:opacity-90 disabled:opacity-50",
836
- children: P ? "Running…" : o.label
865
+ children: M ? "Running…" : i.label
837
866
  },
838
- o.label
867
+ i.label
839
868
  )),
840
- N && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: N }),
841
- Ue
842
- ] }) : null, ye = (we = e.stats) != null && we.length ? /* @__PURE__ */ t(
843
- yt,
869
+ w && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: w }),
870
+ Ve
871
+ ] }) : null, ke = (Se = e.stats) != null && Se.length ? /* @__PURE__ */ t(
872
+ vt,
844
873
  {
845
874
  stats: e.stats,
846
- rows: I ?? [],
847
- effectiveParams: L,
848
- loading: be || G,
849
- zeroDash: !!((Ne = e.table) != null && Ne.zero_dash)
875
+ rows: H ?? [],
876
+ effectiveParams: A,
877
+ loading: ye || Z,
878
+ zeroDash: !!(($e = e.table) != null && $e.zero_dash)
850
879
  }
851
880
  ) : null;
852
- if (be)
853
- return /* @__PURE__ */ x("div", { className: "p-3", children: [
854
- le,
855
- ye,
856
- /* @__PURE__ */ t(ee, {})
881
+ if (ye)
882
+ return /* @__PURE__ */ p("div", { className: "p-3", children: [
883
+ oe,
884
+ ke,
885
+ /* @__PURE__ */ t(ae, {})
857
886
  ] });
858
- if (he)
859
- return /* @__PURE__ */ x("div", { className: "p-3", children: [
860
- le,
861
- /* @__PURE__ */ t(te, { error: he, unresolved: e.unresolved_params })
887
+ if (fe)
888
+ return /* @__PURE__ */ p("div", { className: "p-3", children: [
889
+ oe,
890
+ /* @__PURE__ */ t(le, { error: fe, unresolved: e.unresolved_params })
862
891
  ] });
863
- const w = e.row_click, ve = (o, p, f) => {
864
- const b = p ? null : f ?? I ?? [], S = ct(o, (R) => Tt(
865
- R,
866
- p,
867
- I ?? [],
868
- L,
892
+ const N = e.row_click, we = (i, h, f) => {
893
+ const g = h ? null : f ?? H ?? [], $ = ut(i, (W) => Wt(
894
+ W,
895
+ h,
896
+ H ?? [],
897
+ A,
869
898
  m,
870
899
  e.filters,
871
- b
872
- )), O = S.resolvedTabs.map((R) => {
873
- if ("matrix" in R) {
874
- const H = {};
875
- for (const [se, ie] of Object.entries(R.matrix.scope))
876
- H[se] = ie.startsWith("$row.") ? p == null ? void 0 : p[ie.slice(5)] : ie;
900
+ g
901
+ )), E = $.resolvedTabs.map((W) => {
902
+ if ("matrix" in W) {
903
+ const ee = {};
904
+ for (const [ie, de] of Object.entries(W.matrix.scope))
905
+ ee[ie] = de.startsWith("$row.") ? h == null ? void 0 : h[de.slice(5)] : de;
877
906
  return {
878
- label: R.label,
879
- matrix: { config: R.matrix.config, initialScope: H }
907
+ label: W.label,
908
+ matrix: { config: W.matrix.config, initialScope: ee }
880
909
  };
881
910
  }
882
- return { label: R.label, note: R.note, config: R.config };
911
+ return { label: W.label, note: W.note, config: W.config };
883
912
  });
884
913
  s({
885
914
  def: {
886
- ...o,
887
- resolvedTabs: O,
888
- header: S.header ? {
889
- config: S.header.config,
890
- stats: S.header.stats,
891
- asOf: S.header.asOf,
892
- note: S.header.note
915
+ ...i,
916
+ resolvedTabs: E,
917
+ header: $.header ? {
918
+ config: $.header.config,
919
+ stats: $.header.stats,
920
+ asOf: $.header.asOf,
921
+ note: $.header.note
893
922
  } : null,
894
- initialTab: S.initialTab
923
+ initialTab: $.initialTab
895
924
  },
896
- row: p,
897
- totalCount: b ? b.length : null
925
+ row: h,
926
+ totalCount: g ? g.length : null
898
927
  });
899
- }, Ve = w ? (o) => {
900
- w.picker ? l(o) : w.sheet ? ve(w.sheet, o) : w.matrix && o.id != null ? c(o.id) : w.drill && o.id != null && (n == null || n.open({
901
- collection: w.drill.collection ?? "",
902
- itemId: String(o.id),
903
- layoutId: w.drill.layout_id,
904
- width: w.drill.width
928
+ }, Je = N ? (i) => {
929
+ N.picker ? l(i) : N.sheet ? we(N.sheet, i) : N.matrix && i.id != null ? c(i.id) : N.drill && i.id != null && (n == null || n.open({
930
+ collection: N.drill.collection ?? "",
931
+ itemId: String(i.id),
932
+ layoutId: N.drill.layout_id,
933
+ width: N.drill.width
905
934
  }));
906
- } : void 0, Ge = (Se = e.row_actions) != null && Se.length ? e.row_actions.map((o) => ({
907
- label: o.label,
908
- onClick: (p, f) => ve(o.sheet, p, f)
935
+ } : void 0, Ge = (_e = e.row_actions) != null && _e.length ? e.row_actions.map((i) => ({
936
+ label: i.label,
937
+ onClick: (h, f) => we(i.sheet, h, f)
909
938
  })) : void 0;
910
- return /* @__PURE__ */ x(
939
+ return /* @__PURE__ */ p(
911
940
  "div",
912
941
  {
913
- className: ($e = e.table) != null && $e.sticky ? (
942
+ className: (Ce = e.table) != null && Ce.sticky ? (
914
943
  // Sticky grids own their scroll: filters/stats stay pinned above a
915
944
  // scrolling table region (header/first-column/totals pin inside it).
916
945
  "flex h-full min-h-0 flex-col overflow-hidden p-3"
917
946
  ) : "h-full overflow-auto p-3",
918
947
  children: [
919
- le,
920
- ye,
948
+ oe,
949
+ ke,
921
950
  /* @__PURE__ */ t(
922
951
  "div",
923
952
  {
924
- "data-qt-refetching": G ? "" : void 0,
925
- "aria-busy": G || void 0,
926
- className: `transition-opacity ${G ? "opacity-60" : ""} ${(_e = e.table) != null && _e.sticky ? "flex min-h-0 flex-1 flex-col" : ""}`.trim(),
953
+ "data-qt-refetching": Z ? "" : void 0,
954
+ "aria-busy": Z || void 0,
955
+ className: `transition-opacity ${Z ? "opacity-60" : ""} ${(qe = e.table) != null && qe.sticky ? "flex min-h-0 flex-1 flex-col" : ""}`.trim(),
927
956
  children: /* @__PURE__ */ t(
928
- vt,
957
+ kt,
929
958
  {
930
- rows: I ?? [],
959
+ rows: H ?? [],
931
960
  config: (
932
961
  // Current-month highlight only applies when the selected year param
933
962
  // IS the current year — otherwise strip it.
934
- (Ce = e.table) != null && Ce.highlight_group && e.table.highlight_year_param ? Number(
935
- String(L[e.table.highlight_year_param] ?? "").split(",")[0]
963
+ (Te = e.table) != null && Te.highlight_group && e.table.highlight_year_param ? Number(
964
+ String(A[e.table.highlight_year_param] ?? "").split(",")[0]
936
965
  ) === (/* @__PURE__ */ new Date()).getFullYear() ? e.table : { ...e.table, highlight_group: void 0 } : e.table
937
966
  ),
938
- onRowClick: Ve,
967
+ onRowClick: Je,
939
968
  rowActions: Ge,
940
969
  emptyText: e.empty_label,
941
- pivotYear: (je = (qe = e.table) == null ? void 0 : qe.pivot) != null && je.year_param && Number(String(L[e.table.pivot.year_param] ?? "").split(",")[0]) || void 0
970
+ pivotYear: (Re = (je = e.table) == null ? void 0 : je.pivot) != null && Re.year_param && Number(String(A[e.table.pivot.year_param] ?? "").split(",")[0]) || void 0
942
971
  }
943
972
  )
944
973
  }
945
974
  ),
946
- (w == null ? void 0 : w.picker) && a && /* @__PURE__ */ t(
975
+ (N == null ? void 0 : N.picker) && a && /* @__PURE__ */ t(
947
976
  "div",
948
977
  {
949
978
  className: "fixed inset-0 z-50 flex items-start justify-center bg-black/30 pt-32",
950
979
  onClick: () => l(null),
951
- children: /* @__PURE__ */ x(
980
+ children: /* @__PURE__ */ p(
952
981
  "div",
953
982
  {
954
983
  className: "w-[420px] rounded-lg border border-slate-200 bg-white p-4 shadow-xl dark:border-border dark:bg-background",
955
- onClick: (o) => o.stopPropagation(),
984
+ onClick: (i) => i.stopPropagation(),
956
985
  children: [
957
- /* @__PURE__ */ t("p", { className: "mb-2 text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: w.picker.title ?? "Choose a record" }),
986
+ /* @__PURE__ */ t("p", { className: "mb-2 text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: N.picker.title ?? "Choose a record" }),
958
987
  /* @__PURE__ */ t(
959
- gt,
988
+ yt,
960
989
  {
961
- collection: w.picker.collection,
990
+ collection: N.picker.collection,
962
991
  value: null,
963
- onChange: (o) => {
964
- var p, f, b, y;
965
- if (l(null), o != null) {
966
- if (w.matrix) {
967
- c(o);
992
+ onChange: (i) => {
993
+ var h, f, g, v;
994
+ if (l(null), i != null) {
995
+ if (N.matrix) {
996
+ c(i);
968
997
  return;
969
998
  }
970
999
  n == null || n.open({
971
- collection: ((p = w.drill) == null ? void 0 : p.collection) ?? ((f = w.picker) == null ? void 0 : f.collection) ?? "",
972
- itemId: String(o),
973
- layoutId: (b = w.drill) == null ? void 0 : b.layout_id,
974
- width: (y = w.drill) == null ? void 0 : y.width
1000
+ collection: ((h = N.drill) == null ? void 0 : h.collection) ?? ((f = N.picker) == null ? void 0 : f.collection) ?? "",
1001
+ itemId: String(i),
1002
+ layoutId: (g = N.drill) == null ? void 0 : g.layout_id,
1003
+ width: (v = N.drill) == null ? void 0 : v.width
975
1004
  });
976
1005
  }
977
1006
  },
978
- extraFilter: At(w.picker.filter, a, m, e.filters),
1007
+ extraFilter: At(N.picker.filter, a, m, e.filters),
979
1008
  placeholder: "Search…"
980
1009
  }
981
1010
  ),
@@ -993,32 +1022,32 @@ function De({ config: e }) {
993
1022
  )
994
1023
  }
995
1024
  ),
996
- (w == null ? void 0 : w.matrix) && u != null && /* @__PURE__ */ t(
997
- Le,
1025
+ (N == null ? void 0 : N.matrix) && u != null && /* @__PURE__ */ t(
1026
+ Be,
998
1027
  {
999
- config: w.matrix.config,
1000
- initialScope: { [w.matrix.scope_field]: u },
1001
- width: w.matrix.width,
1002
- title: w.matrix.title,
1028
+ config: N.matrix.config,
1029
+ initialScope: { [N.matrix.scope_field]: u },
1030
+ width: N.matrix.width,
1031
+ title: N.matrix.title,
1003
1032
  onClose: () => c(null)
1004
1033
  }
1005
1034
  ),
1006
- i && /* @__PURE__ */ t(
1035
+ o && /* @__PURE__ */ t(
1007
1036
  Pt,
1008
1037
  {
1009
- def: i.def,
1010
- row: i.row,
1011
- totalCount: i.totalCount,
1038
+ def: o.def,
1039
+ row: o.row,
1040
+ totalCount: o.totalCount,
1012
1041
  onClose: () => s(null)
1013
1042
  }
1014
1043
  ),
1015
- _ && /* @__PURE__ */ t(
1016
- zt,
1044
+ S && /* @__PURE__ */ t(
1045
+ Kt,
1017
1046
  {
1018
- run: _,
1019
- onConfirm: () => void ge(_),
1047
+ run: S,
1048
+ onConfirm: () => void ve(S),
1020
1049
  onClose: () => {
1021
- W(null);
1050
+ O(null);
1022
1051
  }
1023
1052
  }
1024
1053
  )
@@ -1026,15 +1055,15 @@ function De({ config: e }) {
1026
1055
  }
1027
1056
  );
1028
1057
  }
1029
- const Y = (e) => e < 6e4 ? `${(e / 1e3).toFixed(e < 1e4 ? 1 : 0)}s` : `${Math.floor(e / 6e4)}m ${Math.round(e % 6e4 / 1e3)}s`;
1030
- function zt({
1058
+ const te = (e) => e < 6e4 ? `${(e / 1e3).toFixed(e < 1e4 ? 1 : 0)}s` : `${Math.floor(e / 6e4)}m ${Math.round(e % 6e4 / 1e3)}s`;
1059
+ function Kt({
1031
1060
  run: e,
1032
1061
  onConfirm: r,
1033
1062
  onClose: n
1034
1063
  }) {
1035
1064
  const a = Object.entries(e.params);
1036
- return Xe(
1037
- /* @__PURE__ */ x(B, { children: [
1065
+ return Ze(
1066
+ /* @__PURE__ */ p(J, { children: [
1038
1067
  /* @__PURE__ */ t(
1039
1068
  "div",
1040
1069
  {
@@ -1043,7 +1072,7 @@ function zt({
1043
1072
  onClick: e.phase === "running" ? void 0 : n
1044
1073
  }
1045
1074
  ),
1046
- /* @__PURE__ */ x(
1075
+ /* @__PURE__ */ p(
1047
1076
  "div",
1048
1077
  {
1049
1078
  role: "dialog",
@@ -1052,13 +1081,13 @@ function zt({
1052
1081
  className: "fixed left-1/2 top-[24vh] z-50 w-[min(400px,92vw)] -translate-x-1/2 rounded-xl border border-slate-200 bg-white p-4 shadow-2xl dark:border-border dark:bg-card",
1053
1082
  children: [
1054
1083
  /* @__PURE__ */ t("p", { className: "text-[13.5px] font-semibold text-slate-900 dark:text-foreground", children: e.action.label }),
1055
- a.length > 0 && /* @__PURE__ */ t("dl", { className: "mt-2 space-y-0.5 rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: a.map(([l, u]) => /* @__PURE__ */ x("div", { className: "flex gap-2", children: [
1056
- /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: F(l) }),
1084
+ a.length > 0 && /* @__PURE__ */ t("dl", { className: "mt-2 space-y-0.5 rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: a.map(([l, u]) => /* @__PURE__ */ p("div", { className: "flex gap-2", children: [
1085
+ /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: K(l) }),
1057
1086
  /* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(u) })
1058
1087
  ] }, l)) }),
1059
- e.phase === "confirm" && /* @__PURE__ */ x(B, { children: [
1088
+ e.phase === "confirm" && /* @__PURE__ */ p(J, { children: [
1060
1089
  /* @__PURE__ */ t("p", { className: "mt-2 text-[12.5px] text-slate-600 dark:text-slate-300", children: e.confirmText }),
1061
- /* @__PURE__ */ x("div", { className: "mt-3 flex gap-2", children: [
1090
+ /* @__PURE__ */ p("div", { className: "mt-3 flex gap-2", children: [
1062
1091
  /* @__PURE__ */ t(
1063
1092
  "button",
1064
1093
  {
@@ -1079,23 +1108,23 @@ function zt({
1079
1108
  )
1080
1109
  ] })
1081
1110
  ] }),
1082
- e.phase === "running" && /* @__PURE__ */ x("div", { className: "mt-3 flex items-center gap-2.5 text-[12.5px] text-slate-600 dark:text-slate-300", children: [
1111
+ e.phase === "running" && /* @__PURE__ */ p("div", { className: "mt-3 flex items-center gap-2.5 text-[12.5px] text-slate-600 dark:text-slate-300", children: [
1083
1112
  /* @__PURE__ */ t("span", { className: "h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-nvr-cyan border-t-transparent" }),
1084
1113
  "Running… ",
1085
- /* @__PURE__ */ t("span", { className: "tabular-nums", children: Y(e.elapsedMs) })
1114
+ /* @__PURE__ */ t("span", { className: "tabular-nums", children: te(e.elapsedMs) })
1086
1115
  ] }),
1087
- e.phase === "done" && /* @__PURE__ */ x(B, { children: [
1088
- /* @__PURE__ */ x("p", { className: "mt-2 text-[12.5px] font-medium text-emerald-600 dark:text-emerald-400", children: [
1116
+ e.phase === "done" && /* @__PURE__ */ p(J, { children: [
1117
+ /* @__PURE__ */ p("p", { className: "mt-2 text-[12.5px] font-medium text-emerald-600 dark:text-emerald-400", children: [
1089
1118
  e.action.success_message ?? "Completed",
1090
1119
  " · ",
1091
- Y(e.elapsedMs)
1120
+ te(e.elapsedMs)
1092
1121
  ] }),
1093
- e.resultRows != null && e.resultRows > 0 && e.resultSample && /* @__PURE__ */ x("dl", { className: "mt-2 max-h-40 space-y-0.5 overflow-y-auto rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: [
1094
- Object.entries(e.resultSample).slice(0, 8).map(([l, u]) => /* @__PURE__ */ x("div", { className: "flex gap-2", children: [
1095
- /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: F(l) }),
1122
+ e.resultRows != null && e.resultRows > 0 && e.resultSample && /* @__PURE__ */ p("dl", { className: "mt-2 max-h-40 space-y-0.5 overflow-y-auto rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: [
1123
+ Object.entries(e.resultSample).slice(0, 8).map(([l, u]) => /* @__PURE__ */ p("div", { className: "flex gap-2", children: [
1124
+ /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: K(l) }),
1096
1125
  /* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(u ?? "—") })
1097
1126
  ] }, l)),
1098
- e.resultRows > 1 && /* @__PURE__ */ x("p", { className: "pt-0.5 text-slate-400", children: [
1127
+ e.resultRows > 1 && /* @__PURE__ */ p("p", { className: "pt-0.5 text-slate-400", children: [
1099
1128
  "…",
1100
1129
  e.resultRows,
1101
1130
  " result rows"
@@ -1111,14 +1140,14 @@ function zt({
1111
1140
  }
1112
1141
  )
1113
1142
  ] }),
1114
- e.phase === "error" && /* @__PURE__ */ x(B, { children: [
1115
- /* @__PURE__ */ x("p", { className: "mt-2 text-[12.5px] font-medium text-red-600 dark:text-red-400", children: [
1143
+ e.phase === "error" && /* @__PURE__ */ p(J, { children: [
1144
+ /* @__PURE__ */ p("p", { className: "mt-2 text-[12.5px] font-medium text-red-600 dark:text-red-400", children: [
1116
1145
  "Failed after ",
1117
- Y(e.elapsedMs),
1146
+ te(e.elapsedMs),
1118
1147
  ": ",
1119
1148
  e.error
1120
1149
  ] }),
1121
- /* @__PURE__ */ x("div", { className: "mt-3 flex gap-2", children: [
1150
+ /* @__PURE__ */ p("div", { className: "mt-3 flex gap-2", children: [
1122
1151
  /* @__PURE__ */ t(
1123
1152
  "button",
1124
1153
  {
@@ -1146,45 +1175,45 @@ function zt({
1146
1175
  document.body
1147
1176
  );
1148
1177
  }
1149
- function Pe({ slug: e, widget: r }) {
1178
+ function Ae({ slug: e, widget: r }) {
1150
1179
  var n;
1151
1180
  switch (r.type) {
1152
1181
  case "table":
1153
- return /* @__PURE__ */ t($t, { slug: e, widget: r });
1154
- case "kpi":
1155
1182
  return /* @__PURE__ */ t(_t, { slug: e, widget: r });
1183
+ case "kpi":
1184
+ return /* @__PURE__ */ t(Ct, { slug: e, widget: r });
1156
1185
  case "markdown":
1157
- return /* @__PURE__ */ t(St, { content: String(((n = r.config) == null ? void 0 : n.content) ?? "") });
1186
+ return /* @__PURE__ */ t($t, { content: String(((n = r.config) == null ? void 0 : n.content) ?? "") });
1158
1187
  case "iframe":
1159
- return /* @__PURE__ */ t(qt, { widget: r });
1188
+ return /* @__PURE__ */ t(Tt, { widget: r });
1160
1189
  case "query":
1161
- return /* @__PURE__ */ t(Bt, { widget: r });
1190
+ return /* @__PURE__ */ t(Dt, { widget: r });
1162
1191
  case "matrix":
1163
1192
  return /* @__PURE__ */ t(jt, { widget: r });
1164
1193
  case "record-grid":
1165
1194
  return /* @__PURE__ */ t(It, { widget: r });
1166
1195
  case "recent-activity":
1167
- return /* @__PURE__ */ t(Ct, { slug: e, widget: r });
1196
+ return /* @__PURE__ */ t(qt, { slug: e, widget: r });
1168
1197
  default:
1169
1198
  return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Unknown widget" });
1170
1199
  }
1171
1200
  }
1172
- function hr({ slug: e, hideHeader: r, className: n }) {
1173
- var k, T;
1174
- const a = K(), { isAdmin: l } = Ze(), u = Ae(), c = et("drill.page"), i = c.value, {
1201
+ function xr({ slug: e, hideHeader: r, className: n }) {
1202
+ var R, P;
1203
+ const a = X(), { isAdmin: l } = et(), u = Ee(), c = tt("drill.page"), o = c.value, {
1175
1204
  data: s,
1176
1205
  isLoading: m,
1177
- error: h
1178
- } = z({
1206
+ error: x
1207
+ } = G({
1179
1208
  queryKey: ["page-renderer", e],
1180
- queryFn: () => a.request(Fe(`/pages/${e}`)).then((d) => d.data),
1209
+ queryFn: () => a.request(me(`/pages/${e}`)).then((d) => d.data),
1181
1210
  enabled: !!e,
1182
1211
  retry: !1
1183
1212
  });
1184
1213
  if (m)
1185
- return /* @__PURE__ */ t("div", { className: n ?? "p-6", children: /* @__PURE__ */ t(ee, {}) });
1186
- if (h || !s)
1187
- return /* @__PURE__ */ x(
1214
+ return /* @__PURE__ */ t("div", { className: n ?? "p-6", children: /* @__PURE__ */ t(ae, {}) });
1215
+ if (x || !s)
1216
+ return /* @__PURE__ */ p(
1188
1217
  "div",
1189
1218
  {
1190
1219
  className: `flex flex-col items-center justify-center p-10 text-center ${n ?? ""}`,
@@ -1194,47 +1223,47 @@ function hr({ slug: e, hideHeader: r, className: n }) {
1194
1223
  ]
1195
1224
  }
1196
1225
  );
1197
- const v = ((k = s.layout) == null ? void 0 : k.columns) ?? 12, $ = lt(((T = s.layout) == null ? void 0 : T.widgets) ?? [], l), N = (d) => {
1198
- var g;
1199
- return (d.type === "matrix" || d.type === "query" || d.type === "record-grid") && ((g = d.config) == null ? void 0 : g.display) === "drawer";
1200
- }, j = [...new Set($.filter(N).map((d) => d.y))].filter((d) => $.every((g) => N(g) || d < g.y || d >= g.y + Math.max(g.h, 1))).sort((d, g) => d - g), _ = j.map((d) => ({
1226
+ const k = ((R = s.layout) == null ? void 0 : R.columns) ?? 12, _ = st(((P = s.layout) == null ? void 0 : P.widgets) ?? [], l), w = (d) => {
1227
+ var y;
1228
+ return (d.type === "matrix" || d.type === "query" || d.type === "record-grid") && ((y = d.config) == null ? void 0 : y.display) === "drawer";
1229
+ }, q = [...new Set(_.filter(w).map((d) => d.y))].filter((d) => _.every((y) => w(y) || d < y.y || d >= y.y + Math.max(y.h, 1))).sort((d, y) => d - y), S = q.map((d) => ({
1201
1230
  y: d,
1202
- items: $.filter((g) => g.y === d && N(g)).sort((g, E) => g.x - E.x)
1203
- })), W = $.filter((d) => !(N(d) && j.includes(d.y))), P = (d) => d - j.filter((g) => g < d).length, M = W.find((d) => {
1204
- var g;
1205
- return (g = d.config) == null ? void 0 : g.full_height;
1206
- }), C = /* @__PURE__ */ x("div", { className: `flex h-full min-h-0 flex-col ${n ?? ""}`, children: [
1231
+ items: _.filter((y) => y.y === d && w(y)).sort((y, L) => y.x - L.x)
1232
+ })), O = _.filter((d) => !(w(d) && q.includes(d.y))), M = (d) => d - q.filter((y) => y < d).length, F = O.find((d) => {
1233
+ var y;
1234
+ return (y = d.config) == null ? void 0 : y.full_height;
1235
+ }), T = /* @__PURE__ */ p("div", { className: `flex h-full min-h-0 flex-col ${n ?? ""}`, children: [
1207
1236
  !r && /* @__PURE__ */ t("div", { className: "shrink-0 pb-4", children: /* @__PURE__ */ t("h1", { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children: s.name }) }),
1208
- /* @__PURE__ */ t("div", { className: `min-h-0 flex-1 overflow-y-auto ${M ? "flex flex-col" : ""}`, children: $.length === 0 ? /* @__PURE__ */ t("p", { className: "p-6 text-center text-[13px] text-slate-400", children: "This page has no widgets yet." }) : /* @__PURE__ */ x(B, { children: [
1209
- _.map((d) => /* @__PURE__ */ t("div", { className: "mb-3 flex shrink-0 flex-wrap items-center gap-2", children: d.items.map((g) => /* @__PURE__ */ t(Pe, { slug: s.slug, widget: g }, g.id)) }, d.y)),
1237
+ /* @__PURE__ */ t("div", { className: `min-h-0 flex-1 overflow-y-auto ${F ? "flex flex-col" : ""}`, children: _.length === 0 ? /* @__PURE__ */ t("p", { className: "p-6 text-center text-[13px] text-slate-400", children: "This page has no widgets yet." }) : /* @__PURE__ */ p(J, { children: [
1238
+ S.map((d) => /* @__PURE__ */ t("div", { className: "mb-3 flex shrink-0 flex-wrap items-center gap-2", children: d.items.map((y) => /* @__PURE__ */ t(Ae, { slug: s.slug, widget: y }, y.id)) }, d.y)),
1210
1239
  /* @__PURE__ */ t(
1211
1240
  "div",
1212
1241
  {
1213
- className: M ? "grid min-h-0 flex-1 gap-4" : "grid gap-4",
1242
+ className: F ? "grid min-h-0 flex-1 gap-4" : "grid gap-4",
1214
1243
  style: {
1215
- gridTemplateColumns: `repeat(${v}, minmax(0, 1fr))`,
1244
+ gridTemplateColumns: `repeat(${k}, minmax(0, 1fr))`,
1216
1245
  // repeat(0, …) is INVALID CSS (count must be ≥1) and drops the
1217
1246
  // whole declaration — a fill widget in the first row band emits
1218
1247
  // just the stretching track.
1219
- ...M ? {
1220
- gridTemplateRows: `${P(M.y) > 0 ? `repeat(${P(M.y)}, ${oe}px) ` : ""}minmax(${oe * 3}px, 1fr)`
1248
+ ...F ? {
1249
+ gridTemplateRows: `${M(F.y) > 0 ? `repeat(${M(F.y)}, ${ce}px) ` : ""}minmax(${ce * 3}px, 1fr)`
1221
1250
  } : {},
1222
- gridAutoRows: `${oe}px`
1251
+ gridAutoRows: `${ce}px`
1223
1252
  },
1224
- children: W.map((d) => {
1225
- var Q, J, U, V;
1226
- const g = (d.type === "matrix" || d.type === "query" || d.type === "record-grid") && ((Q = d.config) == null ? void 0 : Q.display) === "drawer", E = d === M;
1227
- return /* @__PURE__ */ x(
1253
+ children: O.map((d) => {
1254
+ var Q, U, I, V;
1255
+ const y = (d.type === "matrix" || d.type === "query" || d.type === "record-grid") && ((Q = d.config) == null ? void 0 : Q.display) === "drawer", L = d === F;
1256
+ return /* @__PURE__ */ p(
1228
1257
  "div",
1229
1258
  {
1230
- className: g ? "flex min-h-0 flex-col" : "flex min-h-0 flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm dark:border-border dark:bg-card",
1259
+ className: y ? "flex min-h-0 flex-col" : "flex min-h-0 flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm dark:border-border dark:bg-card",
1231
1260
  style: {
1232
- gridColumn: `${Math.min(d.x, v - 1) + 1} / span ${Math.min(d.w, v)}`,
1233
- gridRow: E ? `${P(d.y) + 1} / -1` : `${P(d.y) + 1} / span ${Math.max(d.h, 1)}`
1261
+ gridColumn: `${Math.min(d.x, k - 1) + 1} / span ${Math.min(d.w, k)}`,
1262
+ gridRow: L ? `${M(d.y) + 1} / -1` : `${M(d.y) + 1} / span ${Math.max(d.h, 1)}`
1234
1263
  },
1235
1264
  children: [
1236
- !g && d.type !== "kpi" && d.type !== "markdown" && ((J = d.config) == null ? void 0 : J.hide_label) !== !0 && /* @__PURE__ */ t("div", { className: "shrink-0 border-b border-slate-100 px-3 py-1.5 text-[11px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: String(((U = d.config) == null ? void 0 : U.label) ?? "") || (typeof ((V = d.config) == null ? void 0 : V.collection) == "string" ? F(String(d.config.collection)) : F(d.type)) }),
1237
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ t(Pe, { slug: s.slug, widget: d }) })
1265
+ !y && d.type !== "kpi" && d.type !== "markdown" && ((U = d.config) == null ? void 0 : U.hide_label) !== !0 && /* @__PURE__ */ t("div", { className: "shrink-0 border-b border-slate-100 px-3 py-1.5 text-[11px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: String(((I = d.config) == null ? void 0 : I.label) ?? "") || (typeof ((V = d.config) == null ? void 0 : V.collection) == "string" ? K(String(d.config.collection)) : K(d.type)) }),
1266
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ t(Ae, { slug: s.slug, widget: d }) })
1238
1267
  ]
1239
1268
  },
1240
1269
  d.id
@@ -1244,31 +1273,31 @@ function hr({ slug: e, hideHeader: r, className: n }) {
1244
1273
  )
1245
1274
  ] }) })
1246
1275
  ] });
1247
- return u ? C : /* @__PURE__ */ x(tt.Provider, { value: { open: (d) => c.push([d]) }, children: [
1248
- i != null && i.length ? /* @__PURE__ */ t(
1249
- kt,
1276
+ return u ? T : /* @__PURE__ */ p(rt.Provider, { value: { open: (d) => c.push([d]) }, children: [
1277
+ o != null && o.length ? /* @__PURE__ */ t(
1278
+ wt,
1250
1279
  {
1251
- collection: i[0].collection,
1252
- itemId: i[0].itemId,
1253
- layoutId: i[0].layoutId,
1254
- width: i[0].width,
1255
- title: i[0].title,
1256
- stack: i,
1257
- onPush: (d) => c.push([...i, d]),
1280
+ collection: o[0].collection,
1281
+ itemId: o[0].itemId,
1282
+ layoutId: o[0].layoutId,
1283
+ width: o[0].width,
1284
+ title: o[0].title,
1285
+ stack: o,
1286
+ onPush: (d) => c.push([...o, d]),
1258
1287
  onPop: () => c.back(),
1259
- onClose: () => c.back(i.length)
1288
+ onClose: () => c.back(o.length)
1260
1289
  }
1261
1290
  ) : null,
1262
- C
1291
+ T
1263
1292
  ] });
1264
1293
  }
1265
1294
  export {
1266
- hr as PageRenderer,
1295
+ xr as PageRenderer,
1267
1296
  Ie as QueryWidgetView,
1268
1297
  It as RecordGridWidgetBody,
1269
- Mt as missingRowParamMessage,
1270
- Tt as resolveSheetConfig,
1271
- Be as resolveSheetValue,
1272
- Oe as selectionSignature,
1273
- Wt as totalSheetTitle
1298
+ Ot as missingRowParamMessage,
1299
+ Wt as resolveSheetConfig,
1300
+ De as resolveSheetValue,
1301
+ Pe as selectionSignature,
1302
+ Mt as totalSheetTitle
1274
1303
  };