@nivaro/react 0.3.52 → 0.3.54

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