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