@nivaro/react 0.3.33 → 0.3.34

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 (29) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +79 -5
  4. package/dist/index.js +338 -329
  5. package/dist/shared/components/ItemEditForm.js +5494 -5302
  6. package/dist/shared/components/ProfileView.js +46 -44
  7. package/dist/shared/components/ReportView.js +208 -205
  8. package/dist/shared/components/SearchHighlight.js +30 -0
  9. package/dist/shared/components/TipLayer.js +39 -37
  10. package/dist/shared/components/item-edit/CatalogPickerField.js +1484 -1232
  11. package/dist/shared/components/item-edit/FieldAffordances.js +370 -203
  12. package/dist/shared/components/item-edit/FieldRow.js +396 -354
  13. package/dist/shared/components/item-edit/PersonalDefaultPill.js +50 -0
  14. package/dist/shared/components/item-edit/RelationCombobox.js +42 -41
  15. package/dist/shared/components/item-edit/catalog-search.js +34 -0
  16. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +34 -34
  17. package/dist/shared/components/item-edit/personal-default-checks.js +134 -0
  18. package/dist/shared/components/item-edit/usePersonalDefaults.js +358 -0
  19. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +130 -111
  20. package/dist/shared/components/layout-editor/inspector/RulesTab.js +76 -75
  21. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  22. package/dist/shared/components/profile/MyDefaultsCard.js +667 -0
  23. package/dist/shared/components/profile/PersonProfile.js +42 -40
  24. package/dist/shared/components/profile/my-defaults-labels.js +76 -0
  25. package/dist/shared/components/profile/primitives.js +72 -67
  26. package/dist/shared/lib/personal-defaults.js +76 -0
  27. package/dist/shared/lib/request-gate.js +78 -76
  28. package/dist/shared/lib/search-text.js +111 -0
  29. package/package.json +1 -1
@@ -1,33 +1,33 @@
1
1
  import { jsxs as i, jsx as e, Fragment as Ge } from "react/jsx-runtime";
2
2
  import { saveReportFilterPreset as Ot, listReportFilterPresets as ma, deleteReportFilterPreset as ua, readReport as pa, executeCustomQuery as ha, readItems as fa, readReportFilterOptions as xa, aiReportFilters as ba, readReportWidgetData as yt, listReportAlerts as ga, createReportAlert as va, toggleReportAlert as ya, deleteReportAlert as ka, readReportAlertLog as Na, resolveReportAlert as wa } from "@nivaro/sdk";
3
- import { useQuery as ke, useQueryClient as Ct, useMutation as Me } from "@tanstack/react-query";
4
- import { X as Ae, Check as Qt, Plus as Ut, Camera as Nt, Bell as Yt, RefreshCw as Mt, ChevronsUpDown as Jt, Sparkles as Kt, Info as Sa, Table as _a, Sigma as Ca, StickyNote as $a, Download as qa, TrendingUp as Vt, TrendingDown as Gt, Trash2 as Ma } from "lucide-react";
5
- import { useState as C, useEffect as wt, useCallback as Ft, useRef as St, useMemo as dt, Suspense as $t, lazy as Rt, memo as Fa } from "react";
3
+ import { useQuery as ke, useQueryClient as Ct, useMutation as Me, isCancelledError as Sa } from "@tanstack/react-query";
4
+ import { X as Ae, Check as Qt, Plus as Ut, Camera as Nt, Bell as Yt, RefreshCw as Mt, ChevronsUpDown as Jt, Sparkles as Kt, Info as _a, Table as Ca, Sigma as $a, StickyNote as qa, Download as Ma, TrendingUp as Vt, TrendingDown as Gt, Trash2 as Fa } from "lucide-react";
5
+ import { useState as C, useEffect as wt, useCallback as Ft, useRef as St, useMemo as dt, Suspense as $t, lazy as Rt, memo as Aa } from "react";
6
6
  import { toast as Ht } from "sonner";
7
- import { useNivaroClient as Ke, useDrilldown as Xt, useOverlayState as Aa } from "../context.js";
8
- import { get as ot, post as ct, del as Ta, put as Ra } from "../lib/commands.js";
9
- import { useLiveWidget as La, liveWidgetInterval as Oa } from "../lib/live-widgets.js";
7
+ import { useNivaroClient as Ke, useDrilldown as Xt, useOverlayState as Ta } from "../context.js";
8
+ import { get as ot, post as ct, del as Ra, put as La } from "../lib/commands.js";
9
+ import { useLiveWidget as Oa, liveWidgetInterval as Ka } from "../lib/live-widgets.js";
10
10
  import { serverErrorText as Zt, loadErrorText as At } from "../lib/load-error.js";
11
- import { buildReportTree as Ka } from "../lib/report-tree.js";
12
- import { uniqueByValue as Da } from "../lib/unique-options.js";
13
- import { useMyScopes as Pa, matchScopeDimension as za, translateScopeValues as Dt, effectiveScopeSeedIds as ja } from "../lib/use-my-scopes.js";
11
+ import { buildReportTree as Da } from "../lib/report-tree.js";
12
+ import { uniqueByValue as Pa } from "../lib/unique-options.js";
13
+ import { useMyScopes as za, matchScopeDimension as ja, translateScopeValues as Dt, effectiveScopeSeedIds as Ea } from "../lib/use-my-scopes.js";
14
14
  import { cn as Q } from "../lib/utils.js";
15
15
  import { BackgroundRunOffer as It } from "./BackgroundRunOffer.js";
16
16
  import { RechartsGate as Le } from "./charts/RechartsGate.js";
17
17
  import { LoadErrorNote as ea } from "./LoadErrorNote.js";
18
- import { RecordDrilldownSheet as Ea } from "./RecordDrilldownSheet.js";
19
- import { TipLayer as Wa } from "./TipLayer.js";
20
- import { Command as Ba, CommandInput as Qa, CommandList as Ua, CommandEmpty as Ya, CommandItem as Ja } from "./ui/command.js";
18
+ import { RecordDrilldownSheet as Wa } from "./RecordDrilldownSheet.js";
19
+ import { TipLayer as Ba } from "./TipLayer.js";
20
+ import { Command as Qa, CommandInput as Ua, CommandList as Ya, CommandEmpty as Ja, CommandItem as Va } from "./ui/command.js";
21
21
  import { Popover as ta, PopoverTrigger as aa, PopoverContent as la } from "./ui/popover.js";
22
22
  import { SimpleSelect as kt } from "./ui/SimpleSelect.js";
23
23
  import { Skeleton as Oe } from "./ui/skeleton.js";
24
- async function Va(t, s) {
24
+ async function Ga(t, s) {
25
25
  const a = t == null ? void 0 : t.querySelector("svg");
26
26
  if (!(!a || typeof ClipboardItem > "u"))
27
27
  try {
28
- const o = a.getBoundingClientRect(), u = a.cloneNode(!0);
29
- u.setAttribute("width", String(o.width)), u.setAttribute("height", String(o.height));
30
- const m = new XMLSerializer().serializeToString(u), h = URL.createObjectURL(new Blob([m], { type: "image/svg+xml;charset=utf-8" })), f = new Image();
28
+ const o = a.getBoundingClientRect(), m = a.cloneNode(!0);
29
+ m.setAttribute("width", String(o.width)), m.setAttribute("height", String(o.height));
30
+ const u = new XMLSerializer().serializeToString(m), h = URL.createObjectURL(new Blob([u], { type: "image/svg+xml;charset=utf-8" })), f = new Image();
31
31
  await new Promise((P, c) => {
32
32
  f.onload = () => P(), f.onerror = () => c(new Error("svg load failed")), f.src = h;
33
33
  });
@@ -41,7 +41,7 @@ async function Va(t, s) {
41
41
  } catch {
42
42
  }
43
43
  }
44
- const Ce = (t) => Math.abs(t) >= 1e9 ? `${(t / 1e9).toFixed(1).replace(/\.0$/, "")}B` : Math.abs(t) >= 1e6 ? `${(t / 1e6).toFixed(1).replace(/\.0$/, "")}M` : Math.abs(t) >= 1e3 ? `${(t / 1e3).toFixed(1).replace(/\.0$/, "")}k` : String(t), Ga = [
44
+ const Ce = (t) => Math.abs(t) >= 1e9 ? `${(t / 1e9).toFixed(1).replace(/\.0$/, "")}B` : Math.abs(t) >= 1e6 ? `${(t / 1e6).toFixed(1).replace(/\.0$/, "")}M` : Math.abs(t) >= 1e3 ? `${(t / 1e3).toFixed(1).replace(/\.0$/, "")}k` : String(t), Ha = [
45
45
  "Jan",
46
46
  "Feb",
47
47
  "Mar",
@@ -54,18 +54,18 @@ const Ce = (t) => Math.abs(t) >= 1e9 ? `${(t / 1e9).toFixed(1).replace(/\.0$/, "
54
54
  "Oct",
55
55
  "Nov",
56
56
  "Dec"
57
- ], Ha = (t) => {
57
+ ], Xa = (t) => {
58
58
  const s = String(t ?? ""), a = /^(\d{4})-(\d{2})(?:-(\d{2}))?/.exec(s);
59
59
  if (a) {
60
- const o = Ga[Number(a[2]) - 1] ?? a[2];
60
+ const o = Ha[Number(a[2]) - 1] ?? a[2];
61
61
  return a[3] ? `${o} ${Number(a[3])}` : `${o} '${a[1].slice(2)}`;
62
62
  }
63
63
  return s.length > 16 ? `${s.slice(0, 15)}…` : s;
64
64
  }, _t = (t) => ({
65
65
  interval: t > 12 ? Math.ceil(t / 12) - 1 : 0,
66
- tickFormatter: Ha,
66
+ tickFormatter: Xa,
67
67
  minTickGap: 4
68
- }), Lt = () => import("./ReportEditMode.js"), Xa = Rt(() => Lt().then((t) => ({ default: t.AddWidgetBar }))), Za = Rt(() => Lt().then((t) => ({ default: t.WidgetConfigSheet }))), Ia = Rt(() => Lt().then((t) => ({ default: t.WidgetEditBar }))), Ve = "rgb(var(--nvr-cyan-rgb, 0 206 255))", ce = [Ve, "#172940", "#10b981", "#f59e0b", "#8b5cf6", "#ef4444", "#64748b"], el = [
68
+ }), Lt = () => import("./ReportEditMode.js"), Za = Rt(() => Lt().then((t) => ({ default: t.AddWidgetBar }))), Ia = Rt(() => Lt().then((t) => ({ default: t.WidgetConfigSheet }))), el = Rt(() => Lt().then((t) => ({ default: t.WidgetEditBar }))), Ve = "rgb(var(--nvr-cyan-rgb, 0 206 255))", ce = [Ve, "#172940", "#10b981", "#f59e0b", "#8b5cf6", "#ef4444", "#64748b"], tl = [
69
69
  { id: "", label: "All time" },
70
70
  { id: "this_month", label: "This month" },
71
71
  { id: "last_30_days", label: "Last 30 days" },
@@ -105,8 +105,8 @@ function ra({
105
105
  field: s,
106
106
  label: a,
107
107
  optionSource: o,
108
- selected: u,
109
- onChange: m,
108
+ selected: m,
109
+ onChange: u,
110
110
  allowedValues: h
111
111
  }) {
112
112
  const f = Ke(), [p, L] = C(!1), { data: $ = [] } = ke({
@@ -120,7 +120,7 @@ function ra({
120
120
  limit: 200
121
121
  })
122
122
  );
123
- return Da(
123
+ return Pa(
124
124
  (J.data ?? []).map((O) => ({
125
125
  value: String(O[c] ?? O.id),
126
126
  label: String(O[S] ?? O[c] ?? O.id)
@@ -132,7 +132,7 @@ function ra({
132
132
  },
133
133
  enabled: p,
134
134
  staleTime: 12e4
135
- }), w = h != null && h.length ? $.filter((c) => h.some((S) => String(S) === c.value)) : $, P = u.length > 0;
135
+ }), w = h != null && h.length ? $.filter((c) => h.some((S) => String(S) === c.value)) : $, P = m.length > 0;
136
136
  return /* @__PURE__ */ i(ta, { open: p, onOpenChange: L, children: [
137
137
  /* @__PURE__ */ e(aa, { asChild: !0, children: /* @__PURE__ */ i(
138
138
  "button",
@@ -144,27 +144,27 @@ function ra({
144
144
  ),
145
145
  children: [
146
146
  a,
147
- P && /* @__PURE__ */ e("span", { className: "rounded-full bg-white/60 px-1 text-[10px] dark:bg-black/20", children: u.length }),
147
+ P && /* @__PURE__ */ e("span", { className: "rounded-full bg-white/60 px-1 text-[10px] dark:bg-black/20", children: m.length }),
148
148
  /* @__PURE__ */ e(Jt, { className: "h-3 w-3 opacity-50" })
149
149
  ]
150
150
  }
151
151
  ) }),
152
- /* @__PURE__ */ e(la, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ i(Ba, { children: [
153
- /* @__PURE__ */ e(Qa, { placeholder: `Filter ${a}…`, className: "h-8 text-[12.5px]" }),
154
- /* @__PURE__ */ i(Ua, { className: "max-h-52", children: [
155
- /* @__PURE__ */ e(Ya, { children: "No values." }),
152
+ /* @__PURE__ */ e(la, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ i(Qa, { children: [
153
+ /* @__PURE__ */ e(Ua, { placeholder: `Filter ${a}…`, className: "h-8 text-[12.5px]" }),
154
+ /* @__PURE__ */ i(Ya, { className: "max-h-52", children: [
155
+ /* @__PURE__ */ e(Ja, { children: "No values." }),
156
156
  w.map((c) => {
157
- const S = u.some((J) => String(J) === c.value);
157
+ const S = m.some((J) => String(J) === c.value);
158
158
  return /* @__PURE__ */ i(
159
- Ja,
159
+ Va,
160
160
  {
161
161
  value: c.label,
162
162
  onSelect: () => {
163
- const J = S ? u.filter((G) => String(G) !== c.value) : [...u, c.value], O = (G) => {
163
+ const J = S ? m.filter((G) => String(G) !== c.value) : [...m, c.value], O = (G) => {
164
164
  var H;
165
165
  return ((H = $.find((me) => me.value === String(G))) == null ? void 0 : H.label) ?? String(G);
166
166
  };
167
- m(J, J.map(O));
167
+ u(J, J.map(O));
168
168
  },
169
169
  className: "text-[12.5px]",
170
170
  children: [
@@ -181,21 +181,21 @@ function ra({
181
181
  }
182
182
  function na(t) {
183
183
  if (!t) return null;
184
- const s = /* @__PURE__ */ new Date(), a = (m) => {
184
+ const s = /* @__PURE__ */ new Date(), a = (u) => {
185
185
  const h = (f) => String(f).padStart(2, "0");
186
- return `${m.getFullYear()}-${h(m.getMonth() + 1)}-${h(m.getDate())}`;
187
- }, o = (m, h) => new Date(m, h, 1), u = (m) => new Date(m.getFullYear(), m.getMonth() + 1, 0);
186
+ return `${u.getFullYear()}-${h(u.getMonth() + 1)}-${h(u.getDate())}`;
187
+ }, o = (u, h) => new Date(u, h, 1), m = (u) => new Date(u.getFullYear(), u.getMonth() + 1, 0);
188
188
  switch (t.preset) {
189
189
  case "this_month":
190
- return { start: a(o(s.getFullYear(), s.getMonth())), end: a(u(s)) };
190
+ return { start: a(o(s.getFullYear(), s.getMonth())), end: a(m(s)) };
191
191
  case "last_30_days":
192
192
  return { start: a(new Date(s.getTime() - 30 * 864e5)), end: a(s) };
193
193
  case "last_3_months":
194
- return { start: a(o(s.getFullYear(), s.getMonth() - 3)), end: a(u(s)) };
194
+ return { start: a(o(s.getFullYear(), s.getMonth() - 3)), end: a(m(s)) };
195
195
  case "last_6_months":
196
- return { start: a(o(s.getFullYear(), s.getMonth() - 6)), end: a(u(s)) };
196
+ return { start: a(o(s.getFullYear(), s.getMonth() - 6)), end: a(m(s)) };
197
197
  case "last_12_months":
198
- return { start: a(o(s.getFullYear(), s.getMonth() - 12)), end: a(u(s)) };
198
+ return { start: a(o(s.getFullYear(), s.getMonth() - 12)), end: a(m(s)) };
199
199
  case "ytd":
200
200
  return { start: `${s.getFullYear()}-01-01`, end: a(s) };
201
201
  case "custom":
@@ -207,18 +207,18 @@ function na(t) {
207
207
  function Ee(t, s, a) {
208
208
  if (t == null || t === "") return "—";
209
209
  if (s === "date" || s === "datetime") {
210
- const m = new Date(String(t));
211
- if (Number.isNaN(m.getTime())) return String(t);
212
- const h = m.toLocaleDateString();
213
- return s === "date" ? h : `${h} ${m.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}`;
210
+ const u = new Date(String(t));
211
+ if (Number.isNaN(u.getTime())) return String(t);
212
+ const h = u.toLocaleDateString();
213
+ return s === "date" ? h : `${h} ${u.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}`;
214
214
  }
215
215
  const o = Number(t);
216
216
  if (Number.isNaN(o)) return String(t);
217
- const u = (m, h) => o.toLocaleString(void 0, {
218
- minimumFractionDigits: a ?? m,
217
+ const m = (u, h) => o.toLocaleString(void 0, {
218
+ minimumFractionDigits: a ?? u,
219
219
  maximumFractionDigits: a ?? h
220
220
  });
221
- return s === "currency" ? `$${u(0, 0)}` : s === "percent" ? `${u(0, 1)}%` : s === "days" ? `${u(0, 1)}d` : s === "integer" ? Math.round(o).toLocaleString() : s === "number" ? u(0, 2) : String(t);
221
+ return s === "currency" ? `$${m(0, 0)}` : s === "percent" ? `${m(0, 1)}%` : s === "days" ? `${m(0, 1)}d` : s === "integer" ? Math.round(o).toLocaleString() : s === "number" ? m(0, 2) : String(t);
222
222
  }
223
223
  const je = /* @__PURE__ */ new Set([
224
224
  "currency",
@@ -228,57 +228,57 @@ const je = /* @__PURE__ */ new Set([
228
228
  "days"
229
229
  ]);
230
230
  function sa(t, s, a) {
231
- const o = {}, u = na(s);
232
- for (const [m, h] of Object.entries(t.params ?? {})) {
231
+ const o = {}, m = na(s);
232
+ for (const [u, h] of Object.entries(t.params ?? {})) {
233
233
  if (h === "$date.start") {
234
- u && (o[m] = u.start);
234
+ m && (o[u] = m.start);
235
235
  continue;
236
236
  }
237
237
  if (h === "$date.end") {
238
- u && (o[m] = u.end);
238
+ m && (o[u] = m.end);
239
239
  continue;
240
240
  }
241
241
  const f = /^\$filters\.([\w.]+?)(:values)?$/.exec(h);
242
242
  if (f) {
243
243
  const p = a.find(($) => $.field === f[1]), L = f[2] ? p == null ? void 0 : p.values : p != null && p.labels && p.labels.length > 0 ? p.labels : p == null ? void 0 : p.values;
244
- L && L.length > 0 && (o[m] = L.join(","));
244
+ L && L.length > 0 && (o[u] = L.join(","));
245
245
  continue;
246
246
  }
247
- o[m] = h;
247
+ o[u] = h;
248
248
  }
249
249
  return o;
250
250
  }
251
- const tl = (t) => `$${Ce(Math.round(t))}`, al = [
251
+ const al = (t) => `$${Ce(Math.round(t))}`, ll = [
252
252
  { gte: 90, color: "#ef4444" },
253
253
  { gte: 70, color: "#f59e0b" },
254
254
  { gte: -1 / 0, color: "#10b981" }
255
255
  ];
256
- function ll({
256
+ function rl({
257
257
  rows: t,
258
258
  cfg: s,
259
259
  onDrill: a
260
260
  }) {
261
- const o = s.tree, u = s.series && s.series.length > 0 ? s.series : Object.keys(t[0] ?? {}).filter((c) => {
261
+ const o = s.tree, m = s.series && s.series.length > 0 ? s.series : Object.keys(t[0] ?? {}).filter((c) => {
262
262
  var S;
263
263
  return typeof ((S = t[0]) == null ? void 0 : S[c]) == "number";
264
- }).slice(0, 3).map((c) => ({ field: c, label: c })), m = dt(
265
- () => o ? Ka(
264
+ }).slice(0, 3).map((c) => ({ field: c, label: c })), u = dt(
265
+ () => o ? Da(
266
266
  t,
267
267
  o,
268
- u.map((c) => c.field)
268
+ m.map((c) => c.field)
269
269
  ) : [],
270
270
  // eslint-disable-next-line react-hooks/exhaustive-deps
271
271
  [t, o]
272
272
  ), [h, f] = C(() => /* @__PURE__ */ new Set()), [p, L] = C(!1);
273
273
  wt(() => {
274
- if (p || m.length === 0) return;
274
+ if (p || u.length === 0) return;
275
275
  const c = /* @__PURE__ */ new Set(), S = (J) => {
276
276
  for (const O of J)
277
- (O.depth > 0 || m.length === 1) && c.add(O.key), S(O.children);
277
+ (O.depth > 0 || u.length === 1) && c.add(O.key), S(O.children);
278
278
  };
279
- S(m), f(c), L(!0);
280
- }, [m, p]);
281
- const $ = (o == null ? void 0 : o.thresholds) ?? al, w = (c) => {
279
+ S(u), f(c), L(!0);
280
+ }, [u, p]);
281
+ const $ = (o == null ? void 0 : o.thresholds) ?? ll, w = (c) => {
282
282
  var S;
283
283
  return c == null ? void 0 : ((S = $.find((J) => c >= J.gte)) == null ? void 0 : S.color) ?? "#10b981";
284
284
  }, P = (c) => {
@@ -359,10 +359,10 @@ function ll({
359
359
  )
360
360
  }
361
361
  ),
362
- /* @__PURE__ */ e("div", { className: "ml-[18px] mt-0.5 flex flex-wrap gap-x-3 text-[10px] tabular-nums text-slate-400", children: u.map((H) => /* @__PURE__ */ i("span", { children: [
362
+ /* @__PURE__ */ e("div", { className: "ml-[18px] mt-0.5 flex flex-wrap gap-x-3 text-[10px] tabular-nums text-slate-400", children: m.map((H) => /* @__PURE__ */ i("span", { children: [
363
363
  H.label ?? H.field,
364
364
  " ",
365
- /* @__PURE__ */ e("span", { className: "font-medium text-slate-500 dark:text-slate-300", children: c.sums[H.field] == null ? H.empty_label ?? "—" : s.value_format === "currency" ? tl(c.sums[H.field]) : c.sums[H.field].toLocaleString() })
365
+ /* @__PURE__ */ e("span", { className: "font-medium text-slate-500 dark:text-slate-300", children: c.sums[H.field] == null ? H.empty_label ?? "—" : s.value_format === "currency" ? al(c.sums[H.field]) : c.sums[H.field].toLocaleString() })
366
366
  ] }, H.field)) })
367
367
  ]
368
368
  }
@@ -370,16 +370,16 @@ function ll({
370
370
  J && c.children.map(P)
371
371
  ] }, c.key);
372
372
  };
373
- return !o || m.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 space-y-0.5 overflow-y-auto pr-1", children: m.map(P) });
373
+ return !o || u.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 space-y-0.5 overflow-y-auto pr-1", children: u.map(P) });
374
374
  }
375
- function rl(t) {
375
+ function nl(t) {
376
376
  const s = Ke(), a = St(!1);
377
377
  return async (o) => {
378
378
  if (!(!t || a.current)) {
379
379
  a.current = !0;
380
380
  try {
381
- const m = (await s.request(ct("/report-studio/drill-row", { values: o }))).data;
382
- m != null && m.collection && m.item_id && t({ collection: m.collection, itemId: m.item_id });
381
+ const u = (await s.request(ct("/report-studio/drill-row", { values: o }))).data;
382
+ u != null && u.collection && u.item_id && t({ collection: u.collection, itemId: u.item_id });
383
383
  } catch {
384
384
  } finally {
385
385
  a.current = !1;
@@ -390,49 +390,50 @@ function rl(t) {
390
390
  function ia(t, s) {
391
391
  let a = s;
392
392
  if (t.group_rows && t.x_field) {
393
- const o = /* @__PURE__ */ new Map(), u = new Set(
394
- (t.series ?? []).map((m) => m.field).length > 0 ? (t.series ?? []).map((m) => m.field) : Object.keys(a[0] ?? {}).filter((m) => {
393
+ const o = /* @__PURE__ */ new Map(), m = new Set(
394
+ (t.series ?? []).map((u) => u.field).length > 0 ? (t.series ?? []).map((u) => u.field) : Object.keys(a[0] ?? {}).filter((u) => {
395
395
  var h;
396
- return typeof ((h = a[0]) == null ? void 0 : h[m]) == "number";
396
+ return typeof ((h = a[0]) == null ? void 0 : h[u]) == "number";
397
397
  })
398
398
  );
399
- for (const m of a) {
400
- const h = String(m[t.x_field] ?? "Unknown"), f = o.get(h) ?? { [t.x_field]: h };
401
- for (const p of u) f[p] = (Number(f[p]) || 0) + (Number(m[p]) || 0);
399
+ for (const u of a) {
400
+ const h = String(u[t.x_field] ?? "Unknown"), f = o.get(h) ?? { [t.x_field]: h };
401
+ for (const p of m) f[p] = (Number(f[p]) || 0) + (Number(u[p]) || 0);
402
402
  o.set(h, f);
403
403
  }
404
404
  a = [...o.values()];
405
405
  }
406
406
  if (t.sort) {
407
- const o = t.sort.startsWith("-"), u = o ? t.sort.slice(1) : t.sort;
408
- a = [...a].sort((m, h) => {
409
- const f = m[u], p = h[u], L = typeof f == "number" && typeof p == "number" ? f - p : String(f ?? "").localeCompare(String(p ?? ""));
407
+ const o = t.sort.startsWith("-"), m = o ? t.sort.slice(1) : t.sort;
408
+ a = [...a].sort((u, h) => {
409
+ const f = u[m], p = h[m], L = typeof f == "number" && typeof p == "number" ? f - p : String(f ?? "").localeCompare(String(p ?? ""));
410
410
  return o ? -L : L;
411
411
  });
412
412
  }
413
413
  return t.limit && t.limit > 0 && (a = a.slice(0, t.limit)), a;
414
414
  }
415
- function oa(t, s, a) {
416
- return t.request(ha(s, a)).then((o) => o.data ?? []);
415
+ function oa(t, s, a, o) {
416
+ const m = ha(s, a);
417
+ return t.request(o ? { ...m, _signal: o } : m).then((u) => u.data ?? []);
417
418
  }
418
- function nl({
419
+ function sl({
419
420
  cfg: t,
420
421
  dateRange: s,
421
422
  entityFilters: a,
422
423
  refetchInterval: o,
423
- onStatus: u,
424
- onDrill: m
424
+ onStatus: m,
425
+ onDrill: u
425
426
  }) {
426
427
  var ue, le;
427
- const h = Ke(), f = rl(m), [p, L] = C(""), [$, w] = C(0), [P, c] = C(null), S = sa(t, s, a), { data: J, isLoading: O, error: G, isFetching: H, refetch: me } = ke({
428
+ const h = Ke(), f = nl(u), [p, L] = C(""), [$, w] = C(0), [P, c] = C(null), S = sa(t, s, a), { data: J, isLoading: O, error: G, isFetching: H, refetch: me } = ke({
428
429
  queryKey: ["nivaro-report-query", t.slug, S],
429
- queryFn: () => oa(h, t.slug, S),
430
+ queryFn: ({ signal: v }) => oa(h, t.slug, S, v),
430
431
  staleTime: 6e4,
431
432
  refetchInterval: o,
432
433
  retry: !1
433
434
  });
434
435
  if (wt(() => {
435
- u == null || u({ isFetching: H, refetch: () => void me() });
436
+ m == null || m({ isFetching: H, refetch: () => void me() });
436
437
  }, [H]), O)
437
438
  return /* @__PURE__ */ i("div", { className: "flex flex-col gap-2 px-1", children: [
438
439
  /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-300", children: "Loading…" }),
@@ -502,7 +503,7 @@ function nl({
502
503
  );
503
504
  }
504
505
  if (t.display === "tree")
505
- return /* @__PURE__ */ e(ll, { rows: Z, cfg: t, onDrill: (v) => m == null ? void 0 : m(v) });
506
+ return /* @__PURE__ */ e(rl, { rows: Z, cfg: t, onDrill: (v) => u == null ? void 0 : u(v) });
506
507
  if (t.display === "table") {
507
508
  const v = te.filter((M) => je.has(M.format ?? "")), A = p.trim().toLowerCase(), X = A ? Z.filter(
508
509
  (M) => Object.values(M).some(
@@ -563,9 +564,9 @@ function nl({
563
564
  /* @__PURE__ */ e("tbody", { children: pe.map((M, z) => /* @__PURE__ */ e(
564
565
  "tr",
565
566
  {
566
- className: m ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/60" : void 0,
567
+ className: u ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/60" : void 0,
567
568
  onClick: () => void f(M),
568
- title: m ? "Open the record behind this row" : void 0,
569
+ title: u ? "Open the record behind this row" : void 0,
569
570
  children: te.map((de) => /* @__PURE__ */ e(
570
571
  "td",
571
572
  {
@@ -606,7 +607,7 @@ function nl({
606
607
  for (const X of fe) A[X.field] = Number(v[X.field]) || 0;
607
608
  return A;
608
609
  }), Se = (v) => t.value_format === "currency" ? `$${Ce(v)}` : Ce(v), _e = (v) => Ee(v, t.value_format ?? "number"), x = t.display === "hbar" || t.display === "stacked_bar" && t.horizontal, I = (v) => {
609
- if (!m) return;
610
+ if (!u) return;
610
611
  const A = (J ?? []).filter((X) => String(X[se] ?? "") === v);
611
612
  A.length > 0 && c({ label: v, rows: A });
612
613
  }, ae = P ? /* @__PURE__ */ e(
@@ -684,7 +685,7 @@ function nl({
684
685
  outerRadius: "88%",
685
686
  paddingAngle: 2,
686
687
  strokeWidth: 0,
687
- className: m ? "cursor-pointer" : void 0,
688
+ className: u ? "cursor-pointer" : void 0,
688
689
  onClick: (z) => {
689
690
  var ge;
690
691
  const de = (ge = z == null ? void 0 : z.payload) == null ? void 0 : ge.dim;
@@ -834,7 +835,7 @@ function nl({
834
835
  fe.map((z, de) => /* @__PURE__ */ e(
835
836
  v,
836
837
  {
837
- className: m ? "cursor-pointer" : void 0,
838
+ className: u ? "cursor-pointer" : void 0,
838
839
  onClick: (ge) => {
839
840
  var Te;
840
841
  const ve = (Te = ge == null ? void 0 : ge.payload) == null ? void 0 : Te[se];
@@ -855,9 +856,9 @@ function nl({
855
856
  ae
856
857
  ] });
857
858
  }
858
- const sl = ["gt", "gte", "lt", "lte", "eq"], da = { gt: ">", gte: "≥", lt: "<", lte: "≤", eq: "=" }, il = ["sum", "avg", "max", "min"];
859
- function ol(t) {
860
- var o, u, m;
859
+ const il = ["gt", "gte", "lt", "lte", "eq"], da = { gt: ">", gte: "≥", lt: "<", lte: "≤", eq: "=" }, ol = ["sum", "avg", "max", "min"];
860
+ function dl(t) {
861
+ var o, m, u;
861
862
  const s = [
862
863
  { value: "value", label: "Value (widget metric)" },
863
864
  { value: "row_count", label: "Row count" }
@@ -873,34 +874,34 @@ function ol(t) {
873
874
  if (t.type === "kpi_group")
874
875
  return [
875
876
  ...s,
876
- ...(((u = t.config) == null ? void 0 : u.metrics) ?? []).map((h) => ({
877
+ ...(((m = t.config) == null ? void 0 : m.metrics) ?? []).map((h) => ({
877
878
  value: `tile:${h.label}`,
878
879
  label: `Tile: ${h.label}`
879
880
  }))
880
881
  ];
881
882
  if (t.type === "table") {
882
- const h = (((m = t.config) == null ? void 0 : m.columns) ?? []).map((f) => typeof f == "string" ? { field: f } : f).map((f) => ({ value: f.field, label: f.label ?? f.field, aggregatable: !0 }));
883
+ const h = (((u = t.config) == null ? void 0 : u.columns) ?? []).map((f) => typeof f == "string" ? { field: f } : f).map((f) => ({ value: f.field, label: f.label ?? f.field, aggregatable: !0 }));
883
884
  return [...s, ...h];
884
885
  }
885
886
  return s;
886
887
  }
887
888
  function zt(t, s) {
888
889
  var h;
889
- const a = /^(sum|avg|max|min|tile):(.+)$/.exec(t.field), o = a ? a[2] : t.field, u = ((h = s.find((f) => f.value === t.field || f.value === o)) == null ? void 0 : h.label) ?? o;
890
- return `${a && a[1] !== "sum" && a[1] !== "tile" ? `${a[1]} ` : ""}${u} ${da[t.op] ?? t.op} ${t.value.toLocaleString()}`;
890
+ const a = /^(sum|avg|max|min|tile):(.+)$/.exec(t.field), o = a ? a[2] : t.field, m = ((h = s.find((f) => f.value === t.field || f.value === o)) == null ? void 0 : h.label) ?? o;
891
+ return `${a && a[1] !== "sum" && a[1] !== "tile" ? `${a[1]} ` : ""}${m} ${da[t.op] ?? t.op} ${t.value.toLocaleString()}`;
891
892
  }
892
- function dl({ reportId: t, alert: s }) {
893
- const a = Ke(), o = Ct(), { data: u = [] } = ke({
893
+ function cl({ reportId: t, alert: s }) {
894
+ const a = Ke(), o = Ct(), { data: m = [] } = ke({
894
895
  queryKey: ["nivaro-report-alert-log", t, s.id],
895
896
  queryFn: () => a.request(Na(t, s.id)).then((h) => h.data),
896
897
  staleTime: 3e4
897
- }), m = Me({
898
+ }), u = Me({
898
899
  mutationFn: () => a.request(wa(t, s.id)),
899
900
  onSuccess: () => {
900
901
  o.invalidateQueries({ queryKey: ["nivaro-report-alert-log", t, s.id] }), o.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] });
901
902
  }
902
903
  });
903
- return u.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 py-1 text-[10.5px] text-slate-400", children: "Never fired." }) : /* @__PURE__ */ e("div", { className: "max-h-36 space-y-1 overflow-y-auto py-1", children: u.slice(0, 20).map((h) => /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
904
+ return m.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 py-1 text-[10.5px] text-slate-400", children: "Never fired." }) : /* @__PURE__ */ e("div", { className: "max-h-36 space-y-1 overflow-y-auto py-1", children: m.slice(0, 20).map((h) => /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
904
905
  /* @__PURE__ */ e(
905
906
  "span",
906
907
  {
@@ -920,25 +921,25 @@ function dl({ reportId: t, alert: s }) {
920
921
  {
921
922
  type: "button",
922
923
  className: "shrink-0 text-[10px] text-slate-400 underline hover:text-emerald-600",
923
- onClick: () => m.mutate(),
924
+ onClick: () => u.mutate(),
924
925
  children: "Mark resolved"
925
926
  }
926
927
  )
927
928
  ] }, h.id)) });
928
929
  }
929
- function cl({
930
+ function ml({
930
931
  reportId: t,
931
932
  widget: s,
932
933
  filterBar: a
933
934
  }) {
934
- const o = Ke(), u = Ct(), [m, h] = C(!1), [f, p] = C(""), [L, $] = C([
935
+ const o = Ke(), m = Ct(), [u, h] = C(!1), [f, p] = C(""), [L, $] = C([
935
936
  { field: "value", agg: "sum", op: "gt", value: "" }
936
- ]), [w, P] = C([]), [c, S] = C(!1), [J, O] = C(null), G = ol(s), { data: H = [] } = ke({
937
+ ]), [w, P] = C([]), [c, S] = C(!1), [J, O] = C(null), G = dl(s), { data: H = [] } = ke({
937
938
  queryKey: ["nivaro-report-alerts", t],
938
939
  queryFn: () => o.request(ga(t)).then((x) => x.data),
939
- enabled: m,
940
+ enabled: u,
940
941
  staleTime: 3e4
941
- }), me = H.filter((x) => x.widget === s.id), Z = () => void u.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] }), te = () => L.filter((x) => x.value.trim() !== "" && !Number.isNaN(Number(x.value))).map((x) => {
942
+ }), me = H.filter((x) => x.widget === s.id), Z = () => void m.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] }), te = () => L.filter((x) => x.value.trim() !== "" && !Number.isNaN(Number(x.value))).map((x) => {
942
943
  const I = G.find((Y) => Y.value === x.field);
943
944
  return { field: I != null && I.aggregatable && x.agg !== "sum" ? `${x.agg}:${x.field}` : x.field, op: x.op, value: Number(x.value) };
944
945
  }), se = Me({
@@ -965,7 +966,7 @@ function cl({
965
966
  mutationFn: (x) => o.request(ka(t, x.id)),
966
967
  onSuccess: Z
967
968
  }), Se = te().length > 0, _e = me.some((x) => x.firing);
968
- return /* @__PURE__ */ i(ta, { open: m, onOpenChange: h, children: [
969
+ return /* @__PURE__ */ i(ta, { open: u, onOpenChange: h, children: [
969
970
  /* @__PURE__ */ e(aa, { asChild: !0, children: /* @__PURE__ */ e(
970
971
  "button",
971
972
  {
@@ -1023,7 +1024,7 @@ function cl({
1023
1024
  type: "button",
1024
1025
  className: "text-slate-300 hover:text-red-500",
1025
1026
  onClick: () => be.mutate(x),
1026
- children: /* @__PURE__ */ e(Ma, { className: "h-3 w-3" })
1027
+ children: /* @__PURE__ */ e(Fa, { className: "h-3 w-3" })
1027
1028
  }
1028
1029
  )
1029
1030
  ] }),
@@ -1035,7 +1036,7 @@ function cl({
1035
1036
  " · Last fired: ",
1036
1037
  x.last_fired ? new Date(x.last_fired).toLocaleString() : "Never"
1037
1038
  ] }),
1038
- J === x.id && /* @__PURE__ */ e(dl, { reportId: t, alert: x })
1039
+ J === x.id && /* @__PURE__ */ e(cl, { reportId: t, alert: x })
1039
1040
  ]
1040
1041
  },
1041
1042
  x.id
@@ -1070,7 +1071,7 @@ function cl({
1070
1071
  onChange: (Y) => $(
1071
1072
  (ue) => ue.map((le, v) => v === I ? { ...le, agg: Y } : le)
1072
1073
  ),
1073
- options: il.map((Y) => ({ value: Y, label: Y })),
1074
+ options: ol.map((Y) => ({ value: Y, label: Y })),
1074
1075
  ariaLabel: "Aggregate",
1075
1076
  className: "h-7 w-[62px] rounded-md px-1.5 py-0 text-[11.5px] dark:border-border dark:bg-card"
1076
1077
  }
@@ -1082,7 +1083,7 @@ function cl({
1082
1083
  onChange: (Y) => $(
1083
1084
  (ue) => ue.map((le, v) => v === I ? { ...le, op: Y } : le)
1084
1085
  ),
1085
- options: sl.map((Y) => ({ value: Y, label: da[Y] })),
1086
+ options: il.map((Y) => ({ value: Y, label: da[Y] })),
1086
1087
  ariaLabel: "Operator",
1087
1088
  className: "h-7 w-[52px] rounded-md px-1.5 py-0 text-[11.5px] dark:border-border dark:bg-card"
1088
1089
  }
@@ -1172,7 +1173,7 @@ function cl({
1172
1173
  ] })
1173
1174
  ] });
1174
1175
  }
1175
- const ml = {
1176
+ const ul = {
1176
1177
  eq: "_eq",
1177
1178
  neq: "_neq",
1178
1179
  gt: "_gt",
@@ -1186,42 +1187,42 @@ const ml = {
1186
1187
  };
1187
1188
  function qt(t, s, a, o) {
1188
1189
  var L, $;
1189
- const u = t.config ?? {}, m = [];
1190
- for (const w of u.filters ?? []) {
1191
- const P = ml[w.op];
1190
+ const m = t.config ?? {}, u = [];
1191
+ for (const w of m.filters ?? []) {
1192
+ const P = ul[w.op];
1192
1193
  if (!P) continue;
1193
1194
  let c = w.value;
1194
- w.op === "in" && typeof c == "string" && (c = c.split(",").map((S) => S.trim())), m.push({ path: [w.field], op: P, value: c });
1195
+ w.op === "in" && typeof c == "string" && (c = c.split(",").map((S) => S.trim())), u.push({ path: [w.field], op: P, value: c });
1195
1196
  }
1196
1197
  for (const w of s)
1197
- (L = w.values) != null && L.length && m.push({ path: [w.field], op: "_in", value: w.values });
1198
- const h = u.date_field || (($ = u.dimension) != null && $.bucket ? u.dimension.field : null), f = na(a);
1199
- f && h && (m.push({ path: [h], op: "_gte", value: f.start }), m.push({ path: [h], op: "_lte", value: `${f.end}T23:59:59` }));
1200
- const p = u.dimension;
1198
+ (L = w.values) != null && L.length && u.push({ path: [w.field], op: "_in", value: w.values });
1199
+ const h = m.date_field || (($ = m.dimension) != null && $.bucket ? m.dimension.field : null), f = na(a);
1200
+ f && h && (u.push({ path: [h], op: "_gte", value: f.start }), u.push({ path: [h], op: "_lte", value: `${f.end}T23:59:59` }));
1201
+ const p = m.dimension;
1201
1202
  if (o !== void 0 && (p != null && p.field))
1202
1203
  if (p.bucket) {
1203
1204
  const w = String(o);
1204
1205
  if (/^\d{4}-\d{2}-\d{2}$/.test(w))
1205
- m.push({ path: [p.field], op: "_gte", value: w }), m.push({ path: [p.field], op: "_lte", value: `${w}T23:59:59` });
1206
+ u.push({ path: [p.field], op: "_gte", value: w }), u.push({ path: [p.field], op: "_lte", value: `${w}T23:59:59` });
1206
1207
  else if (/^\d{4}-\d{2}$/.test(w)) {
1207
1208
  const [P, c] = w.split("-").map(Number), S = new Date(P, c, 0).getDate();
1208
- m.push({ path: [p.field], op: "_gte", value: `${w}-01` }), m.push({
1209
+ u.push({ path: [p.field], op: "_gte", value: `${w}-01` }), u.push({
1209
1210
  path: [p.field],
1210
1211
  op: "_lte",
1211
1212
  value: `${w}-${String(S).padStart(2, "0")}T23:59:59`
1212
1213
  });
1213
1214
  }
1214
- } else o === null ? m.push({ path: [p.field], op: "_null", value: !0 }) : m.push({ path: [p.field], op: "_eq", value: o });
1215
- return m;
1215
+ } else o === null ? u.push({ path: [p.field], op: "_null", value: !0 }) : u.push({ path: [p.field], op: "_eq", value: o });
1216
+ return u;
1216
1217
  }
1217
1218
  function jt(t) {
1218
1219
  const s = t.config ?? {}, a = [], o = s.query;
1219
1220
  if (t.type === "query" && (o != null && o.slug))
1220
1221
  a.push(`Custom query: ${o.slug}`);
1221
1222
  else if (t.collection) {
1222
- const u = s.metric, m = (u == null ? void 0 : u.aggregate) ?? "count";
1223
+ const m = s.metric, u = (m == null ? void 0 : m.aggregate) ?? "count";
1223
1224
  a.push(
1224
- `${m === "count" ? "Count of" : `${m.toUpperCase()} of ${(u == null ? void 0 : u.field) ?? "?"} on`} ${t.collection.replace(/_/g, " ")}`
1225
+ `${u === "count" ? "Count of" : `${u.toUpperCase()} of ${(m == null ? void 0 : m.field) ?? "?"} on`} ${t.collection.replace(/_/g, " ")}`
1225
1226
  );
1226
1227
  const h = s.dimension;
1227
1228
  h != null && h.field && a.push(`by ${h.field}${h.bucket ? ` (${h.bucket})` : ""}`);
@@ -1231,9 +1232,9 @@ function jt(t) {
1231
1232
  }
1232
1233
  return a.length > 0 ? a.join(" · ") : "No configuration details";
1233
1234
  }
1234
- function ul(t) {
1235
+ function pl(t) {
1235
1236
  var s, a;
1236
- return t ? t.value != null ? Number(t.value) : t.series ? t.series.reduce((o, u) => o + (Number(u.value) || 0), 0) : (s = t.tiles) != null && s.length ? Number(((a = t.tiles[0]) == null ? void 0 : a.value) ?? 0) : t.row_count != null ? Number(t.row_count) : null : null;
1237
+ return t ? t.value != null ? Number(t.value) : t.series ? t.series.reduce((o, m) => o + (Number(m.value) || 0), 0) : (s = t.tiles) != null && s.length ? Number(((a = t.tiles[0]) == null ? void 0 : a.value) ?? 0) : t.row_count != null ? Number(t.row_count) : null : null;
1237
1238
  }
1238
1239
  function Et(t, s, a) {
1239
1240
  var $, w, P;
@@ -1254,10 +1255,10 @@ function Et(t, s, a) {
1254
1255
  });
1255
1256
  return;
1256
1257
  }
1257
- const u = [...new Set(o.flatMap((c) => Object.keys(c)))], m = (c) => {
1258
+ const m = [...new Set(o.flatMap((c) => Object.keys(c)))], u = (c) => {
1258
1259
  const S = String(c ?? "");
1259
1260
  return /[",\n]/.test(S) ? `"${S.replace(/"/g, '""')}"` : S;
1260
- }, h = [u.join(","), ...o.map((c) => u.map((S) => m(c[S])).join(","))].join(
1261
+ }, h = [m.join(","), ...o.map((c) => m.map((S) => u(c[S])).join(","))].join(
1261
1262
  `
1262
1263
  `
1263
1264
  ), f = new Blob([h], { type: "text/csv;charset=utf-8" }), p = document.createElement("a");
@@ -1265,13 +1266,13 @@ function Et(t, s, a) {
1265
1266
  const L = p.href;
1266
1267
  setTimeout(() => URL.revokeObjectURL(L), 1e4);
1267
1268
  }
1268
- function pl({
1269
+ function hl({
1269
1270
  collection: t,
1270
1271
  conditions: s,
1271
1272
  title: a,
1272
1273
  onClose: o,
1273
- onOpen: u,
1274
- crossFilter: m
1274
+ onOpen: m,
1275
+ crossFilter: u
1275
1276
  }) {
1276
1277
  const h = Ke(), { data: f, isLoading: p } = ke({
1277
1278
  queryKey: ["nvr-report-drill", t, JSON.stringify(s)],
@@ -1312,11 +1313,11 @@ function pl({
1312
1313
  /* @__PURE__ */ i("div", { className: "flex items-center gap-2 border-b border-slate-100 px-4 py-2.5 dark:border-border", children: [
1313
1314
  /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: a }),
1314
1315
  /* @__PURE__ */ e("span", { className: "text-[11.5px] tabular-nums text-slate-400", children: f ? `${L.length}${(f.total ?? 0) > L.length ? ` of ${f.total.toLocaleString()}` : ""} records` : "" }),
1315
- m && /* @__PURE__ */ e(
1316
+ u && /* @__PURE__ */ e(
1316
1317
  "button",
1317
1318
  {
1318
1319
  type: "button",
1319
- onClick: m,
1320
+ onClick: u,
1320
1321
  title: "Apply this value as a filter across the whole report",
1321
1322
  className: "shrink-0 rounded-md border border-nvr-cyan/40 bg-nvr-cyan/[0.08] px-2 py-0.5 text-[11px] font-medium text-[#007a99] hover:brightness-105 dark:text-nvr-cyan",
1322
1323
  children: "Filter report"
@@ -1339,7 +1340,7 @@ function pl({
1339
1340
  "button",
1340
1341
  {
1341
1342
  type: "button",
1342
- onClick: () => u({ collection: t, itemId: String(w.id) }),
1343
+ onClick: () => m({ collection: t, itemId: String(w.id) }),
1343
1344
  className: "block w-full truncate rounded-md px-2.5 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-slate-50 dark:text-slate-200 dark:hover:bg-muted",
1344
1345
  children: $(w)
1345
1346
  },
@@ -1374,12 +1375,12 @@ function Bt(t, s) {
1374
1375
  const a = Number(s);
1375
1376
  return Number.isFinite(a) ? t.op === "gt" ? a > t.value : t.op === "gte" ? a >= t.value : t.op === "lt" ? a < t.value : t.op === "lte" ? a <= t.value : a === t.value : !1;
1376
1377
  }
1377
- const Tt = Fa(function({
1378
+ const Tt = Aa(function({
1378
1379
  reportId: s,
1379
1380
  widget: a,
1380
1381
  dateRange: o,
1381
- entityFilters: u,
1382
- refetchInterval: m,
1382
+ entityFilters: m,
1383
+ refetchInterval: u,
1383
1384
  filterBar: h = [],
1384
1385
  onDrill: f,
1385
1386
  snapshot: p,
@@ -1398,28 +1399,28 @@ const Tt = Fa(function({
1398
1399
  const l = await O.request(
1399
1400
  yt(s, a.id, {
1400
1401
  date_range: o,
1401
- entity_filters: u,
1402
+ entity_filters: m,
1402
1403
  fresh: 1
1403
1404
  })
1404
1405
  );
1405
1406
  Te.setQueryData(
1406
- ["nivaro-report-widget", s, a.id, o, u],
1407
+ ["nivaro-report-widget", s, a.id, o, m],
1407
1408
  l.data
1408
1409
  );
1409
1410
  } catch {
1410
1411
  }
1411
1412
  mt(!1);
1412
1413
  }, Xe = dt(
1413
- () => ({ date_range: o ?? null, entity_filters: u }),
1414
- [o, u]
1415
- ), ye = La({
1414
+ () => ({ date_range: o ?? null, entity_filters: m }),
1415
+ [o, m]
1416
+ ), ye = Oa({
1416
1417
  kind: "report",
1417
1418
  widget: a.id,
1418
1419
  report: s,
1419
1420
  params: Xe,
1420
1421
  enabled: a.type !== "divider" && a.type !== "query",
1421
1422
  onData: (l) => Te.setQueryData(
1422
- ["nivaro-report-widget", s, a.id, o, u],
1423
+ ["nivaro-report-widget", s, a.id, o, m],
1423
1424
  l
1424
1425
  ),
1425
1426
  onStale: () => void De()
@@ -1430,11 +1431,11 @@ const Tt = Fa(function({
1430
1431
  refetch: De,
1431
1432
  isFetching: ut
1432
1433
  } = ke({
1433
- queryKey: ["nivaro-report-widget", s, a.id, o, u],
1434
+ queryKey: ["nivaro-report-widget", s, a.id, o, m],
1434
1435
  queryFn: () => O.request(
1435
1436
  yt(s, a.id, {
1436
1437
  date_range: o,
1437
- entity_filters: u
1438
+ entity_filters: m
1438
1439
  })
1439
1440
  ).then((l) => l.data),
1440
1441
  // Query widgets resolve client-side in QueryWidgetBody — but when a
@@ -1443,20 +1444,20 @@ const Tt = Fa(function({
1443
1444
  enabled: a.type !== "divider" && (a.type !== "query" || !!p),
1444
1445
  staleTime: 6e4,
1445
1446
  // Per-widget auto-refresh (#168) overrides the report-level interval.
1446
- refetchInterval: Oa(
1447
+ refetchInterval: Ka(
1447
1448
  ye,
1448
- Number((Qe = a.config) == null ? void 0 : Qe.refresh_secs) >= 10 ? Number(a.config.refresh_secs) * 1e3 : m
1449
+ Number((Qe = a.config) == null ? void 0 : Qe.refresh_secs) >= 10 ? Number(a.config.refresh_secs) * 1e3 : u
1449
1450
  ),
1450
1451
  retry: !1
1451
1452
  }), We = (((ft = a.config) == null ? void 0 : ft.drill_levels) ?? []).filter(
1452
1453
  (l) => typeof l == "string" && l
1453
1454
  ), { data: pt } = ke({
1454
- queryKey: ["nvr-report-drill", s, a.id, v, o, u],
1455
+ queryKey: ["nvr-report-drill", s, a.id, v, o, m],
1455
1456
  queryFn: () => O.request(
1456
1457
  yt(s, a.id, {
1457
1458
  date_range: o,
1458
1459
  entity_filters: [
1459
- ...u,
1460
+ ...m,
1460
1461
  ...v.map((l) => ({ field: l.field, values: [l.value] }))
1461
1462
  ],
1462
1463
  dimension_override: We[v.length - 1]
@@ -1478,12 +1479,12 @@ const Tt = Fa(function({
1478
1479
  let V = null;
1479
1480
  if ($e != null && $e.slug)
1480
1481
  V = /* @__PURE__ */ e(
1481
- nl,
1482
+ sl,
1482
1483
  {
1483
1484
  cfg: $e,
1484
1485
  dateRange: o,
1485
- entityFilters: u,
1486
- refetchInterval: m,
1486
+ entityFilters: m,
1487
+ refetchInterval: u,
1487
1488
  onDrill: f
1488
1489
  }
1489
1490
  );
@@ -1499,10 +1500,10 @@ const Tt = Fa(function({
1499
1500
  request: {
1500
1501
  method: "POST",
1501
1502
  url: `/report-studio/${s}/widgets/${a.id}/data`,
1502
- body: { date_range: o, entity_filters: u }
1503
+ body: { date_range: o, entity_filters: m }
1503
1504
  },
1504
1505
  label: a.title || "Report widget",
1505
- queryKey: ["nivaro-report-widget", s, a.id, o, u],
1506
+ queryKey: ["nivaro-report-widget", s, a.id, o, m],
1506
1507
  select: (l) => l == null ? void 0 : l.data
1507
1508
  }
1508
1509
  )
@@ -1558,7 +1559,7 @@ const Tt = Fa(function({
1558
1559
  title: a.collection ? "See the records behind this number" : void 0,
1559
1560
  onClick: () => {
1560
1561
  a.collection && se({
1561
- conditions: qt(a, u, o),
1562
+ conditions: qt(a, m, o),
1562
1563
  title: a.title || a.collection
1563
1564
  });
1564
1565
  },
@@ -2127,7 +2128,7 @@ const Tt = Fa(function({
2127
2128
  se({
2128
2129
  conditions: qt(
2129
2130
  a,
2130
- u,
2131
+ m,
2131
2132
  o,
2132
2133
  (d == null ? void 0 : d.raw) ?? (d == null ? void 0 : d.dim)
2133
2134
  ),
@@ -2431,7 +2432,7 @@ const Tt = Fa(function({
2431
2432
  se({
2432
2433
  conditions: qt(
2433
2434
  a,
2434
- u,
2435
+ m,
2435
2436
  o,
2436
2437
  (T == null ? void 0 : T.raw) ?? (T == null ? void 0 : T.dim)
2437
2438
  ),
@@ -2506,7 +2507,7 @@ const Tt = Fa(function({
2506
2507
  {
2507
2508
  "data-tip": jt(a),
2508
2509
  className: "shrink-0 cursor-help text-slate-300 hover:text-slate-500",
2509
- children: /* @__PURE__ */ e(Sa, { className: "h-3 w-3" })
2510
+ children: /* @__PURE__ */ e(_a, { className: "h-3 w-3" })
2510
2511
  }
2511
2512
  ),
2512
2513
  /* @__PURE__ */ i("span", { className: "ml-auto flex items-center gap-0.5", children: [
@@ -2520,7 +2521,7 @@ const Tt = Fa(function({
2520
2521
  ue ? "text-[#00a5cc]" : "text-slate-300 hover:text-[#00a5cc]"
2521
2522
  ),
2522
2523
  onClick: () => le((l) => !l),
2523
- children: /* @__PURE__ */ e(_a, { className: "h-3 w-3" })
2524
+ children: /* @__PURE__ */ e(Ca, { className: "h-3 w-3" })
2524
2525
  }
2525
2526
  ),
2526
2527
  ["bar", "line", "donut", "pareto", "scatter", "heatmap", "waterfall"].includes(
@@ -2531,7 +2532,7 @@ const Tt = Fa(function({
2531
2532
  type: "button",
2532
2533
  title: "Copy chart as image",
2533
2534
  className: "rounded p-0.5 text-slate-300 hover:text-[#00a5cc]",
2534
- onClick: () => void Va(X.current, a.title),
2535
+ onClick: () => void Ga(X.current, a.title),
2535
2536
  children: /* @__PURE__ */ e(Nt, { className: "h-3 w-3" })
2536
2537
  }
2537
2538
  ),
@@ -2552,7 +2553,7 @@ const Tt = Fa(function({
2552
2553
  O.request(
2553
2554
  ct(`/report-studio/${s}/widgets/${a.id}/explain-trend`, {
2554
2555
  date_range: o,
2555
- entity_filters: u
2556
+ entity_filters: m
2556
2557
  })
2557
2558
  ).then((n) => {
2558
2559
  pe(n.data.explanation || "No explanation available."), ge(n.data.movers ?? null);
@@ -2566,7 +2567,7 @@ const Tt = Fa(function({
2566
2567
  (j ? Promise.resolve(j) : O.request(
2567
2568
  yt(s, a.id, {
2568
2569
  date_range: o,
2569
- entity_filters: u
2570
+ entity_filters: m
2570
2571
  })
2571
2572
  ).then((n) => n.data).catch(() => {
2572
2573
  })).then((n) => {
@@ -2609,7 +2610,7 @@ const Tt = Fa(function({
2609
2610
  ae ? "text-[#00a5cc]" : "text-slate-300 hover:text-slate-500"
2610
2611
  ),
2611
2612
  onClick: () => Y((l) => !l),
2612
- children: /* @__PURE__ */ e(Ca, { className: "h-3 w-3" })
2613
+ children: /* @__PURE__ */ e($a, { className: "h-3 w-3" })
2613
2614
  }
2614
2615
  ),
2615
2616
  w && /* @__PURE__ */ e(
@@ -2622,7 +2623,7 @@ const Tt = Fa(function({
2622
2623
  (($ == null ? void 0 : $.length) ?? 0) > 0 ? "text-amber-500" : "text-slate-300 hover:text-slate-500"
2623
2624
  ),
2624
2625
  onClick: () => be((l) => !l),
2625
- children: /* @__PURE__ */ e($a, { className: "h-3 w-3" })
2626
+ children: /* @__PURE__ */ e(qa, { className: "h-3 w-3" })
2626
2627
  }
2627
2628
  ),
2628
2629
  /* @__PURE__ */ e(
@@ -2636,17 +2637,19 @@ const Tt = Fa(function({
2636
2637
  Et(a, j);
2637
2638
  return;
2638
2639
  }
2639
- const l = $e, n = sa(l, o, u);
2640
+ const l = $e, n = sa(l, o, m);
2640
2641
  Te.fetchQuery({
2641
2642
  queryKey: ["nivaro-report-query", l.slug, n],
2642
2643
  queryFn: () => oa(O, l.slug, n),
2643
2644
  staleTime: 6e4
2644
- }).then((g) => Et(a, void 0, ia(l, g))).catch((g) => Ht.error(At(g, "this widget")));
2645
+ }).then((g) => Et(a, void 0, ia(l, g))).catch((g) => {
2646
+ Sa(g) || Ht.error(At(g, "this widget"));
2647
+ });
2645
2648
  },
2646
- children: /* @__PURE__ */ e(qa, { className: "h-3 w-3" })
2649
+ children: /* @__PURE__ */ e(Ma, { className: "h-3 w-3" })
2647
2650
  }
2648
2651
  ),
2649
- /* @__PURE__ */ e(cl, { reportId: s, widget: a, filterBar: h }),
2652
+ /* @__PURE__ */ e(ml, { reportId: s, widget: a, filterBar: h }),
2650
2653
  /* @__PURE__ */ e(
2651
2654
  "button",
2652
2655
  {
@@ -2723,7 +2726,7 @@ const Tt = Fa(function({
2723
2726
  ] })
2724
2727
  ] }),
2725
2728
  p && (() => {
2726
- const l = ul(j), n = p.value;
2729
+ const l = pl(j), n = p.value;
2727
2730
  if (l == null || n == null) return null;
2728
2731
  const g = n === 0 ? null : (l - n) / Math.abs(n) * 100;
2729
2732
  return /* @__PURE__ */ i("p", { className: "mb-1 flex items-center gap-1 text-[10.5px] text-slate-400", children: [
@@ -2815,7 +2818,7 @@ const Tt = Fa(function({
2815
2818
  ] }) }) : V }),
2816
2819
  ((st = a.config) == null ? void 0 : st.footnote) && /* @__PURE__ */ e("p", { className: "mt-1 border-t border-slate-100 pt-1 text-[10.5px] leading-snug text-slate-400 dark:border-border/50", children: a.config.footnote }),
2817
2820
  te && /* @__PURE__ */ e(
2818
- pl,
2821
+ hl,
2819
2822
  {
2820
2823
  collection: a.collection ?? "",
2821
2824
  conditions: te.conditions,
@@ -2837,15 +2840,15 @@ const Tt = Fa(function({
2837
2840
  }
2838
2841
  );
2839
2842
  });
2840
- function Dl({
2843
+ function Pl({
2841
2844
  reportId: t,
2842
2845
  widget: s,
2843
2846
  dateRange: a = null,
2844
2847
  entityFilters: o = []
2845
2848
  }) {
2846
- const u = Xt(), m = Ft(
2847
- (f) => u == null ? void 0 : u.open(f),
2848
- [u]
2849
+ const m = Xt(), u = Ft(
2850
+ (f) => m == null ? void 0 : m.open(f),
2851
+ [m]
2849
2852
  ), h = dt(() => ({ ...s, x: 0 }), [s]);
2850
2853
  return /* @__PURE__ */ e(
2851
2854
  Tt,
@@ -2854,25 +2857,25 @@ function Dl({
2854
2857
  widget: h,
2855
2858
  dateRange: a,
2856
2859
  entityFilters: o,
2857
- onDrill: u ? m : void 0
2860
+ onDrill: m ? u : void 0
2858
2861
  }
2859
2862
  );
2860
2863
  }
2861
- function Pl({
2864
+ function zl({
2862
2865
  reportId: t,
2863
2866
  showFilterBar: s = !0,
2864
2867
  dateRange: a,
2865
2868
  initialEntityFilters: o = [],
2866
- refetchInterval: u,
2867
- className: m,
2869
+ refetchInterval: m,
2870
+ className: u,
2868
2871
  emptyState: h,
2869
2872
  reportUrl: f
2870
2873
  }) {
2871
2874
  var W, D;
2872
- const p = Ke(), L = Xt(), $ = Aa("drill.report"), w = $.value, P = Ft(
2875
+ const p = Ke(), L = Xt(), $ = Ta("drill.report"), w = $.value, P = Ft(
2873
2876
  (r) => L ? L.open(r) : $.push([r]),
2874
2877
  [L, $.push]
2875
- ), [c, S] = C(void 0), [J, O] = C(o), [G, H] = C(void 0), [me, Z] = C(o), { scopes: te, ready: se } = Pa(), [fe, be] = C(!1), [Se, _e] = C({}), x = Ct(), { data: I = [] } = ke({
2878
+ ), [c, S] = C(void 0), [J, O] = C(o), [G, H] = C(void 0), [me, Z] = C(o), { scopes: te, ready: se } = za(), [fe, be] = C(!1), [Se, _e] = C({}), x = Ct(), { data: I = [] } = ke({
2876
2879
  queryKey: ["nivaro-report-presets", t],
2877
2880
  queryFn: async () => {
2878
2881
  try {
@@ -2933,7 +2936,7 @@ function Pl({
2933
2936
  mutationFn: (r) => p.request(ct(`/report-studio/${t}/annotations`, r)),
2934
2937
  onSuccess: ve
2935
2938
  }), He = Me({
2936
- mutationFn: (r) => p.request(Ta(`/report-studio/${t}/annotations/${r}`)),
2939
+ mutationFn: (r) => p.request(Ra(`/report-studio/${t}/annotations/${r}`)),
2937
2940
  onSuccess: ve
2938
2941
  }), mt = Ft((r, b, y) => {
2939
2942
  const d = {
@@ -2944,7 +2947,7 @@ function Pl({
2944
2947
  O((k) => [...k.filter((N) => N.field !== r), d]), Z((k) => [...k.filter((N) => N.field !== r), d]);
2945
2948
  }, []), [Ne, Xe] = C(!1), [ye, Fe] = C(null), [Ze, Re] = C(null), De = Me({
2946
2949
  mutationFn: (r) => p.request(
2947
- Ra(`/report-studio/${t}/widgets`, {
2950
+ La(`/report-studio/${t}/widgets`, {
2948
2951
  widgets: r.map((b, y) => ({ ...b, sort: y }))
2949
2952
  })
2950
2953
  ),
@@ -3001,7 +3004,7 @@ function Pl({
3001
3004
  var y;
3002
3005
  const r = [], b = {};
3003
3006
  for (const d of n) {
3004
- const k = za(te, {
3007
+ const k = ja(te, {
3005
3008
  key: d.field,
3006
3009
  collection: (y = d.options) == null ? void 0 : y.collection
3007
3010
  });
@@ -3013,7 +3016,7 @@ function Pl({
3013
3016
  );
3014
3017
  T.length > 0 && (b[d.field] = T);
3015
3018
  }
3016
- const B = ja(te, k.name);
3019
+ const B = Ea(te, k.name);
3017
3020
  if (B.length > 0) {
3018
3021
  const T = await Dt(p, k, B, N).catch(
3019
3022
  () => []
@@ -3065,7 +3068,7 @@ function Pl({
3065
3068
  }
3066
3069
  }
3067
3070
  };
3068
- return vt || !fe ? /* @__PURE__ */ e("div", { className: Q("p-6 text-[13px] text-slate-400", m), children: "Loading report…" }) : re ? /* @__PURE__ */ i("div", { className: Q("flex flex-col gap-3", m), children: [
3071
+ return vt || !fe ? /* @__PURE__ */ e("div", { className: Q("p-6 text-[13px] text-slate-400", u), children: "Loading report…" }) : re ? /* @__PURE__ */ i("div", { className: Q("flex flex-col gap-3", u), children: [
3069
3072
  s && (g.length > 0 || n.length > 0) && /* @__PURE__ */ i("div", { className: "space-y-1.5", children: [
3070
3073
  /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-1.5", children: [
3071
3074
  /* @__PURE__ */ i("span", { className: "flex items-center gap-1.5 text-[11.5px] font-semibold text-slate-500 dark:text-slate-300", children: [
@@ -3080,7 +3083,7 @@ function Pl({
3080
3083
  {
3081
3084
  value: (q == null ? void 0 : q.preset) ?? "",
3082
3085
  onChange: (r) => H(r ? { preset: r } : null),
3083
- options: el.map((r) => ({ value: r.id, label: r.label })),
3086
+ options: tl.map((r) => ({ value: r.id, label: r.label })),
3084
3087
  ariaLabel: "Date range",
3085
3088
  className: "h-7 w-auto rounded-md px-1.5 py-0 text-[12px] text-slate-600 dark:border-border dark:bg-card dark:text-slate-300"
3086
3089
  }
@@ -3402,7 +3405,7 @@ function Pl({
3402
3405
  }
3403
3406
  ) }),
3404
3407
  Ne && ye && /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e($t, { fallback: null, children: /* @__PURE__ */ e(
3405
- Xa,
3408
+ Za,
3406
3409
  {
3407
3410
  maxY: Math.max(0, ...ye.map((r) => (r.y ?? 0) + (r.h ?? 1))),
3408
3411
  onAdd: (r) => Fe((b) => [...b ?? [], r])
@@ -3442,14 +3445,14 @@ function Pl({
3442
3445
  ...J.filter((k) => k.field !== he.field),
3443
3446
  { field: he.field, values: [y], labels: [y] }
3444
3447
  ],
3445
- refetchInterval: u,
3448
+ refetchInterval: m,
3446
3449
  filterBar: n,
3447
3450
  onDrill: P
3448
3451
  }
3449
3452
  )
3450
3453
  ] }, d)) }) : /* @__PURE__ */ i(Ge, { children: [
3451
3454
  Ne && /* @__PURE__ */ e($t, { fallback: null, children: /* @__PURE__ */ e(
3452
- Ia,
3455
+ el,
3453
3456
  {
3454
3457
  widget: r,
3455
3458
  onConfigure: () => Re(r.id),
@@ -3469,7 +3472,7 @@ function Pl({
3469
3472
  widget: r,
3470
3473
  dateRange: l,
3471
3474
  entityFilters: J,
3472
- refetchInterval: u,
3475
+ refetchInterval: m,
3473
3476
  filterBar: n,
3474
3477
  onDrill: P,
3475
3478
  snapshot: z && z.data[r.id] !== void 0 ? { name: z.name, value: ((b = z.data[r.id]) == null ? void 0 : b.value) ?? null } : null,
@@ -3490,7 +3493,7 @@ function Pl({
3490
3493
  }
3491
3494
  ),
3492
3495
  Ne && Ze && (ye == null ? void 0 : ye.some((r) => r.id === Ze)) && /* @__PURE__ */ e($t, { fallback: null, children: /* @__PURE__ */ e(
3493
- Za,
3496
+ Ia,
3494
3497
  {
3495
3498
  widget: ye.find((r) => r.id === Ze),
3496
3499
  allWidgets: ye,
@@ -3498,9 +3501,9 @@ function Pl({
3498
3501
  onClose: () => Re(null)
3499
3502
  }
3500
3503
  ) }),
3501
- /* @__PURE__ */ e(Wa, {}),
3504
+ /* @__PURE__ */ e(Ba, {}),
3502
3505
  !L && (w != null && w.length) ? /* @__PURE__ */ e(
3503
- Ea,
3506
+ Wa,
3504
3507
  {
3505
3508
  collection: w[0].collection,
3506
3509
  itemId: w[0].itemId,
@@ -3512,12 +3515,12 @@ function Pl({
3512
3515
  onClose: () => $.back(w.length)
3513
3516
  }
3514
3517
  ) : null
3515
- ] }) : /* @__PURE__ */ e("div", { className: Q("p-6 text-[13px] text-slate-400", m), children: "Report not found." });
3518
+ ] }) : /* @__PURE__ */ e("div", { className: Q("p-6 text-[13px] text-slate-400", u), children: "Report not found." });
3516
3519
  }
3517
3520
  export {
3518
- cl as AlertBell,
3519
- nl as QueryWidgetBody,
3520
- Pl as ReportView,
3521
- Dl as ReportWidgetCard,
3521
+ ml as AlertBell,
3522
+ sl as QueryWidgetBody,
3523
+ zl as ReportView,
3524
+ Pl as ReportWidgetCard,
3522
3525
  ia as shapeQueryRows
3523
3526
  };