@nivaro/react 0.3.64 → 0.3.66

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 (74) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +62 -8
  4. package/dist/shared/components/CollectionBrowserView.js +3127 -3204
  5. package/dist/shared/components/ConformanceView.js +235 -221
  6. package/dist/shared/components/DataTable.js +478 -459
  7. package/dist/shared/components/ItemEditForm.js +4842 -4500
  8. package/dist/shared/components/MyWorkView.js +124 -113
  9. package/dist/shared/components/PageRenderer.js +146 -138
  10. package/dist/shared/components/ProfileView.js +483 -472
  11. package/dist/shared/components/RecordDrilldownSheet.js +73 -65
  12. package/dist/shared/components/ReportView.js +1100 -1094
  13. package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
  14. package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
  15. package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
  16. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
  17. package/dist/shared/components/bulk/MessageStakeholders.js +235 -0
  18. package/dist/shared/components/bulk/bulk-field-options.js +29 -23
  19. package/dist/shared/components/integrations/IntegrationObligationsView.js +191 -173
  20. package/dist/shared/components/integrations/IntegrationStatusLines.js +101 -85
  21. package/dist/shared/components/integrations/RecordIntegrationPreview.js +11 -9
  22. package/dist/shared/components/integrations/SendCurrentData.js +126 -0
  23. package/dist/shared/components/item-edit/CatalogPickerField.js +1535 -1440
  24. package/dist/shared/components/item-edit/FieldRenderer.js +49 -45
  25. package/dist/shared/components/item-edit/FieldRow.js +413 -403
  26. package/dist/shared/components/item-edit/GroupSection.js +555 -538
  27. package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
  28. package/dist/shared/components/item-edit/M2MCombobox.js +407 -338
  29. package/dist/shared/components/item-edit/MidairCollisionDialog.js +367 -116
  30. package/dist/shared/components/item-edit/NestedRelationEditor.js +171 -163
  31. package/dist/shared/components/item-edit/PlanGrid.js +783 -724
  32. package/dist/shared/components/item-edit/QuickCreateButton.js +291 -224
  33. package/dist/shared/components/item-edit/RecordInsights.js +113 -111
  34. package/dist/shared/components/item-edit/RecordLiveSync.js +4 -1
  35. package/dist/shared/components/item-edit/RelationCombobox.js +398 -364
  36. package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
  37. package/dist/shared/components/item-edit/UserChip.js +264 -229
  38. package/dist/shared/components/item-edit/cascade-clear-notice.js +56 -0
  39. package/dist/shared/components/item-edit/collision-format.js +37 -0
  40. package/dist/shared/components/item-edit/field-a11y.js +25 -0
  41. package/dist/shared/components/item-edit/header-path-preview.js +52 -0
  42. package/dist/shared/components/item-edit/line-merge.js +84 -0
  43. package/dist/shared/components/item-edit/line-midair.js +94 -87
  44. package/dist/shared/components/item-edit/move-guard.js +17 -0
  45. package/dist/shared/components/item-edit/picker-search.js +27 -16
  46. package/dist/shared/components/item-edit/rail-width.js +8 -0
  47. package/dist/shared/components/monitoring/InactiveUserLinksView.js +126 -124
  48. package/dist/shared/components/panels/AccessDeniedPanel.js +96 -55
  49. package/dist/shared/components/panels/CommentPanel.js +142 -136
  50. package/dist/shared/components/panels/ItemLockBanner.js +246 -240
  51. package/dist/shared/components/panels/PipelinePanel.js +1366 -1194
  52. package/dist/shared/components/panels/RevisionsPanel.js +106 -102
  53. package/dist/shared/components/panels/SlaBreachBanner.js +16 -20
  54. package/dist/shared/components/panels/SlaClock.js +90 -68
  55. package/dist/shared/components/queue/QueueItemSheet.js +94 -87
  56. package/dist/shared/components/queue/QueueWorklist.js +1522 -1347
  57. package/dist/shared/components/queue/worklist-csv.js +75 -0
  58. package/dist/shared/components/queue/worklist-helpers.js +20 -0
  59. package/dist/shared/components/widgets/ReviewListWidget.js +226 -207
  60. package/dist/shared/lib/bulk-copy.js +17 -0
  61. package/dist/shared/lib/cbv-export.js +122 -0
  62. package/dist/shared/lib/delete-offer.js +13 -0
  63. package/dist/shared/lib/error-hints.js +1 -0
  64. package/dist/shared/lib/leave-guard.js +41 -26
  65. package/dist/shared/lib/list-link.js +72 -56
  66. package/dist/shared/lib/live-queries.js +32 -30
  67. package/dist/shared/lib/moved-notice.js +25 -0
  68. package/dist/shared/lib/notification-target.js +56 -54
  69. package/dist/shared/lib/obligation-banner.js +11 -8
  70. package/dist/shared/lib/obligation-reason-text.js +6 -6
  71. package/dist/shared/lib/quick-filter-cascade.js +29 -19
  72. package/dist/shared/lib/sort-cycle.js +6 -0
  73. package/dist/shared/lib/summary-mode.js +59 -41
  74. package/package.json +1 -1
@@ -1,47 +1,48 @@
1
- import { jsx as e, jsxs as i, Fragment as He } from "react/jsx-runtime";
2
- import { saveReportFilterPreset as Kt, listReportFilterPresets as ua, deleteReportFilterPreset as pa, readReport as ha, executeCustomQuery as fa, readItems as xa, readReportFilterOptions as ba, aiReportFilters as ga, readReportWidgetData as kt, listReportAlerts as va, createReportAlert as ya, toggleReportAlert as ka, deleteReportAlert as Na, readReportAlertLog as wa, resolveReportAlert as Sa } from "@nivaro/sdk";
3
- import { useQuery as Ne, useQueryClient as Ct, useMutation as Me, isCancelledError as _a } from "@tanstack/react-query";
4
- import { X as Ae, Check as Ut, Plus as Yt, Camera as wt, Bell as Vt, RefreshCw as Ft, ChevronsUpDown as Jt, Sparkles as Dt, Info as Ca, Table as $a, Sigma as qa, StickyNote as Ma, Download as Fa, TrendingUp as Gt, TrendingDown as Ht, Trash2 as Aa } from "lucide-react";
5
- import { useState as C, useEffect as mt, useCallback as At, useRef as St, useMemo as ut, Suspense as qt, lazy as Rt, memo as Ta } from "react";
1
+ import { jsx as e, jsxs as o, Fragment as He } from "react/jsx-runtime";
2
+ import { saveReportFilterPreset as Kt, listReportFilterPresets as pa, deleteReportFilterPreset as ha, readReport as fa, executeCustomQuery as xa, readItems as ba, readReportFilterOptions as ga, aiReportFilters as va, readReportWidgetData as Nt, listReportAlerts as ya, createReportAlert as ka, toggleReportAlert as Na, deleteReportAlert as wa, readReportAlertLog as Sa, resolveReportAlert as _a } from "@nivaro/sdk";
3
+ import { useQuery as Ne, useQueryClient as ht, useMutation as Me, isCancelledError as Ca } from "@tanstack/react-query";
4
+ import { X as Ae, Check as Ut, Plus as Yt, Camera as St, Bell as Vt, RefreshCw as Ft, ChevronsUpDown as Jt, Sparkles as Dt, Info as $a, Table as qa, Sigma as Ma, StickyNote as Fa, Download as Aa, TrendingUp as Gt, TrendingDown as Ht, Trash2 as Ta } from "lucide-react";
5
+ import { useState as C, useEffect as mt, useCallback as At, useRef as _t, useMemo as ut, Suspense as qt, lazy as Lt, memo as Ra } from "react";
6
6
  import { toast as Xt } from "sonner";
7
7
  import { useNivaroClient as Ke, useDrilldown as Zt, useOverlayState as La } from "../context.js";
8
- import { get as ct, post as pt, del as Ra, put as Oa } from "../lib/commands.js";
9
- import { useLiveWidget as Ka, liveWidgetInterval as Da } from "../lib/live-widgets.js";
8
+ import { get as ct, post as pt, del as Oa, put as Ka } from "../lib/commands.js";
9
+ import { useLiveWidget as Da, liveWidgetInterval as Pa } from "../lib/live-widgets.js";
10
10
  import { serverErrorText as It, loadErrorText as Tt } from "../lib/load-error.js";
11
- import { buildReportTree as Pa } from "../lib/report-tree.js";
12
- import { uniqueByValue as za } from "../lib/unique-options.js";
13
- import { useMyScopes as ja, matchScopeDimension as Ea, translateScopeValues as Pt, effectiveScopeSeedIds as Wa } from "../lib/use-my-scopes.js";
14
- import { cn as Q } from "../lib/utils.js";
15
- import { BackgroundRunOffer as ea } from "./BackgroundRunOffer.js";
16
- import { RechartsGate as Re } from "./charts/RechartsGate.js";
17
- import { LoadErrorNote as ta } from "./LoadErrorNote.js";
18
- import { RecordDrilldownSheet as Ba } from "./RecordDrilldownSheet.js";
19
- import { TipLayer as Qa } from "./TipLayer.js";
20
- import { Command as Ua, CommandInput as Ya, CommandList as Va, CommandEmpty as Ja, CommandItem as Ga } from "./ui/command.js";
21
- import { Popover as aa, PopoverTrigger as la, PopoverContent as ra } from "./ui/popover.js";
22
- import { SimpleSelect as Nt } from "./ui/SimpleSelect.js";
11
+ import { restrictedScopeSelections as za, cascadeFilter as ja, fetchCascadeRelations as Ea } from "../lib/quick-filter-cascade.js";
12
+ import { buildReportTree as Wa } from "../lib/report-tree.js";
13
+ import { uniqueByValue as Ba } from "../lib/unique-options.js";
14
+ import { useMyScopes as ea, matchScopeDimension as Qa, translateScopeValues as Pt, effectiveScopeSeedIds as Ua } from "../lib/use-my-scopes.js";
15
+ import { cn as V } from "../lib/utils.js";
16
+ import { BackgroundRunOffer as ta } from "./BackgroundRunOffer.js";
17
+ import { RechartsGate as Le } from "./charts/RechartsGate.js";
18
+ import { LoadErrorNote as aa } from "./LoadErrorNote.js";
19
+ import { RecordDrilldownSheet as Ya } from "./RecordDrilldownSheet.js";
20
+ import { TipLayer as Va } from "./TipLayer.js";
21
+ import { Command as Ja, CommandInput as Ga, CommandList as Ha, CommandEmpty as Xa, CommandItem as Za } from "./ui/command.js";
22
+ import { Popover as la, PopoverTrigger as ra, PopoverContent as na } from "./ui/popover.js";
23
+ import { SimpleSelect as wt } from "./ui/SimpleSelect.js";
23
24
  import { Skeleton as Oe } from "./ui/skeleton.js";
24
- async function Ha(t, n) {
25
+ async function Ia(t, n) {
25
26
  const a = t == null ? void 0 : t.querySelector("svg");
26
27
  if (!(!a || typeof ClipboardItem > "u"))
27
28
  try {
28
- const o = a.getBoundingClientRect(), c = a.cloneNode(!0);
29
- c.setAttribute("width", String(o.width)), c.setAttribute("height", String(o.height));
29
+ const s = a.getBoundingClientRect(), c = a.cloneNode(!0);
30
+ c.setAttribute("width", String(s.width)), c.setAttribute("height", String(s.height));
30
31
  const m = new XMLSerializer().serializeToString(c), h = URL.createObjectURL(new Blob([m], { type: "image/svg+xml;charset=utf-8" })), f = new Image();
31
- await new Promise((U, u) => {
32
- f.onload = () => U(), f.onerror = () => u(new Error("svg load failed")), f.src = h;
32
+ await new Promise((W, p) => {
33
+ f.onload = () => W(), f.onerror = () => p(new Error("svg load failed")), f.src = h;
33
34
  });
34
- const p = 2, L = document.createElement("canvas");
35
- L.width = Math.max(1, Math.round(o.width * p)), L.height = Math.max(1, Math.round(o.height * p) + 28 * p);
36
- const q = L.getContext("2d");
37
- if (!q) return;
38
- q.fillStyle = "#ffffff", q.fillRect(0, 0, L.width, L.height), q.fillStyle = "#172940", q.font = `${12 * p}px system-ui, sans-serif`, q.fillText(n || "Chart", 8 * p, 18 * p), q.drawImage(f, 0, 28 * p, o.width * p, o.height * p), URL.revokeObjectURL(h);
39
- const w = await new Promise((U) => L.toBlob(U, "image/png"));
40
- w && await navigator.clipboard.write([new ClipboardItem({ "image/png": w })]);
35
+ const u = 2, R = document.createElement("canvas");
36
+ R.width = Math.max(1, Math.round(s.width * u)), R.height = Math.max(1, Math.round(s.height * u) + 28 * u);
37
+ const M = R.getContext("2d");
38
+ if (!M) return;
39
+ M.fillStyle = "#ffffff", M.fillRect(0, 0, R.width, R.height), M.fillStyle = "#172940", M.font = `${12 * u}px system-ui, sans-serif`, M.fillText(n || "Chart", 8 * u, 18 * u), M.drawImage(f, 0, 28 * u, s.width * u, s.height * u), URL.revokeObjectURL(h);
40
+ const N = await new Promise((W) => R.toBlob(W, "image/png"));
41
+ N && await navigator.clipboard.write([new ClipboardItem({ "image/png": N })]);
41
42
  } catch {
42
43
  }
43
44
  }
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), Xa = [
45
+ 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), el = [
45
46
  "Jan",
46
47
  "Feb",
47
48
  "Mar",
@@ -54,22 +55,22 @@ const Ce = (t) => Math.abs(t) >= 1e9 ? `${(t / 1e9).toFixed(1).replace(/\.0$/, "
54
55
  "Oct",
55
56
  "Nov",
56
57
  "Dec"
57
- ], Za = (t) => {
58
+ ], tl = (t) => {
58
59
  const n = String(t ?? ""), a = /^(\d{4})-(\d{2})(?:-(\d{2}))?/.exec(n);
59
60
  if (a) {
60
- const o = Xa[Number(a[2]) - 1] ?? a[2];
61
- return a[3] ? `${o} ${Number(a[3])}` : `${o} '${a[1].slice(2)}`;
61
+ const s = el[Number(a[2]) - 1] ?? a[2];
62
+ return a[3] ? `${s} ${Number(a[3])}` : `${s} '${a[1].slice(2)}`;
62
63
  }
63
64
  return n.length > 16 ? `${n.slice(0, 15)}…` : n;
64
- }, _t = (t) => ({
65
+ }, Ct = (t) => ({
65
66
  interval: t > 12 ? Math.ceil(t / 12) - 1 : 0,
66
- tickFormatter: Za,
67
+ tickFormatter: tl,
67
68
  minTickGap: 4,
68
69
  ...t > 5 && t <= 12 ? { angle: -35, textAnchor: "end", height: 56 } : {}
69
- }), Ia = (t) => {
70
+ }), al = (t) => {
70
71
  const n = String(t ?? "");
71
72
  return n.length > 22 ? `${n.slice(0, 21)}…` : n;
72
- }, Ot = () => import("./ReportEditMode.js"), el = Rt(() => Ot().then((t) => ({ default: t.AddWidgetBar }))), tl = Rt(() => Ot().then((t) => ({ default: t.WidgetConfigSheet }))), al = Rt(() => Ot().then((t) => ({ default: t.WidgetEditBar }))), Ge = "rgb(var(--nvr-cyan-rgb, 0 206 255))", oe = [
73
+ }, Ot = () => import("./ReportEditMode.js"), ll = Lt(() => Ot().then((t) => ({ default: t.AddWidgetBar }))), rl = Lt(() => Ot().then((t) => ({ default: t.WidgetConfigSheet }))), nl = Lt(() => Ot().then((t) => ({ default: t.WidgetEditBar }))), Ge = "rgb(var(--nvr-cyan-rgb, 0 206 255))", ce = [
73
74
  Ge,
74
75
  "#4f7cac",
75
76
  // steel blue
@@ -89,7 +90,7 @@ const Ce = (t) => Math.abs(t) >= 1e9 ? `${(t / 1e9).toFixed(1).replace(/\.0$/, "
89
90
  // olive
90
91
  "#9c7b56"
91
92
  // tan
92
- ], ll = [
93
+ ], sl = [
93
94
  { id: "", label: "All time" },
94
95
  { id: "this_month", label: "This month" },
95
96
  { id: "last_30_days", label: "Last 30 days" },
@@ -109,10 +110,10 @@ function qe(t, n) {
109
110
  function zt({ pct: t }) {
110
111
  if (t == null) return null;
111
112
  const n = t >= 0;
112
- return /* @__PURE__ */ i(
113
+ return /* @__PURE__ */ o(
113
114
  "span",
114
115
  {
115
- className: Q(
116
+ className: V(
116
117
  "inline-flex items-center gap-0.5 rounded px-1 py-px text-[10.5px] font-medium",
117
118
  n ? "bg-emerald-50 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400" : "bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400"
118
119
  ),
@@ -124,102 +125,107 @@ function zt({ pct: t }) {
124
125
  }
125
126
  );
126
127
  }
127
- function na({
128
+ function sa({
128
129
  reportId: t,
129
130
  field: n,
130
131
  label: a,
131
- optionSource: o,
132
+ optionSource: s,
132
133
  selected: c,
133
134
  onChange: m,
134
135
  allowedValues: h
135
136
  }) {
136
- const f = Ke(), [p, L] = C(!1), { data: q = [] } = Ne({
137
- queryKey: ["nivaro-report-filter-opts", t, n, o ?? null],
137
+ const f = Ke(), u = ht(), [R, M] = C(!1), { scopes: N } = ea(), W = s ? za(s.collection, N) : [], { data: p = [] } = Ne({
138
+ queryKey: ["nivaro-report-filter-opts", t, n, s ?? null, W],
138
139
  queryFn: async () => {
139
- if (o) {
140
- const u = o.value_field ?? "id", N = o.label_field ?? u, Y = await f.request(
141
- xa(o.collection, {
142
- fields: [.../* @__PURE__ */ new Set(["id", u, N])],
143
- sort: o.sort ? [o.sort] : void 0,
140
+ if (s) {
141
+ const F = s.value_field ?? "id", Z = s.label_field ?? F, P = W.length ? ja(
142
+ s.collection,
143
+ await Ea(f, u, s.collection),
144
+ W
145
+ ) : null, me = await f.request(
146
+ ba(s.collection, {
147
+ fields: [.../* @__PURE__ */ new Set(["id", F, Z])],
148
+ ...P ? { filter: P } : {},
149
+ sort: s.sort ? [s.sort] : void 0,
144
150
  limit: 200
145
151
  })
146
152
  );
147
- return za(
148
- (Y.data ?? []).map((O) => ({
149
- value: String(O[u] ?? O.id),
150
- label: String(O[N] ?? O[u] ?? O.id)
153
+ return Ba(
154
+ (me.data ?? []).map((J) => ({
155
+ value: String(J[F] ?? J.id),
156
+ label: String(J[Z] ?? J[F] ?? J.id)
151
157
  })),
152
- (O) => O.value
158
+ (J) => J.value
153
159
  );
154
160
  }
155
- return f.request(ba(t, n)).then((u) => u.data);
161
+ return f.request(ga(t, n)).then((F) => F.data);
156
162
  },
157
- enabled: p,
163
+ enabled: R,
158
164
  staleTime: 12e4
159
- }), w = h != null && h.length ? q.filter((u) => h.some((N) => String(N) === u.value)) : q, U = c.length > 0;
160
- return /* @__PURE__ */ i(aa, { open: p, onOpenChange: L, children: [
161
- /* @__PURE__ */ e(la, { asChild: !0, children: /* @__PURE__ */ i(
165
+ }), S = h != null && h.length ? p.filter((F) => h.some((Z) => String(Z) === F.value)) : p, ee = c.length > 0;
166
+ return /* @__PURE__ */ o(la, { open: R, onOpenChange: M, children: [
167
+ /* @__PURE__ */ e(ra, { asChild: !0, children: /* @__PURE__ */ o(
162
168
  "button",
163
169
  {
164
170
  type: "button",
165
- className: Q(
171
+ className: V(
166
172
  "flex h-7 items-center gap-1.5 rounded-md border px-2 text-[12px]",
167
- U ? "border-nvr-cyan bg-accent font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:border-slate-300 dark:border-border"
173
+ ee ? "border-nvr-cyan bg-accent font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:border-slate-300 dark:border-border"
168
174
  ),
169
175
  children: [
170
176
  a,
171
- U && /* @__PURE__ */ e("span", { className: "rounded-full bg-white/60 px-1 text-[10px] dark:bg-black/20", children: c.length }),
177
+ ee && /* @__PURE__ */ e("span", { className: "rounded-full bg-white/60 px-1 text-[10px] dark:bg-black/20", children: c.length }),
172
178
  /* @__PURE__ */ e(Jt, { className: "h-3 w-3 opacity-50" })
173
179
  ]
174
180
  }
175
181
  ) }),
176
- /* @__PURE__ */ e(ra, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ i(Ua, { children: [
177
- /* @__PURE__ */ e(Ya, { placeholder: `Filter ${a}…`, className: "h-8 text-[12.5px]" }),
178
- /* @__PURE__ */ i(Va, { className: "max-h-52", children: [
179
- /* @__PURE__ */ e(Ja, { children: "No values." }),
180
- w.map((u) => {
181
- const N = c.some((Y) => String(Y) === u.value);
182
- return /* @__PURE__ */ i(
183
- Ga,
182
+ /* @__PURE__ */ e(na, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ o(Ja, { children: [
183
+ /* @__PURE__ */ e(Ga, { placeholder: `Filter ${a}…`, className: "h-8 text-[12.5px]" }),
184
+ /* @__PURE__ */ o(Ha, { className: "max-h-52", children: [
185
+ /* @__PURE__ */ e(Xa, { children: "No values." }),
186
+ S.map((F) => {
187
+ const Z = c.some((P) => String(P) === F.value);
188
+ return /* @__PURE__ */ o(
189
+ Za,
184
190
  {
185
- value: u.label,
191
+ value: F.label,
186
192
  onSelect: () => {
187
- const Y = N ? c.filter((ee) => String(ee) !== u.value) : [...c, u.value], O = (ee) => {
188
- var X;
189
- return ((X = q.find((ue) => ue.value === String(ee))) == null ? void 0 : X.label) ?? String(ee);
193
+ const P = Z ? c.filter((J) => String(J) !== F.value) : [...c, F.value], me = (J) => {
194
+ var B;
195
+ return ((B = p.find((se) => se.value === String(J))) == null ? void 0 : B.label) ?? String(J);
190
196
  };
191
- m(Y, Y.map(O));
197
+ m(P, P.map(me));
192
198
  },
193
199
  className: "text-[12.5px]",
194
200
  children: [
195
- /* @__PURE__ */ e(Ut, { className: Q("mr-1.5 h-3 w-3", N ? "opacity-100" : "opacity-0") }),
196
- u.label
201
+ /* @__PURE__ */ e(Ut, { className: V("mr-1.5 h-3 w-3", Z ? "opacity-100" : "opacity-0") }),
202
+ F.label
197
203
  ]
198
204
  },
199
- u.value
205
+ F.value
200
206
  );
201
207
  })
202
208
  ] })
203
209
  ] }) })
204
210
  ] });
205
211
  }
206
- function sa(t) {
212
+ function ia(t) {
207
213
  if (!t) return null;
208
214
  const n = /* @__PURE__ */ new Date(), a = (m) => {
209
215
  const h = (f) => String(f).padStart(2, "0");
210
216
  return `${m.getFullYear()}-${h(m.getMonth() + 1)}-${h(m.getDate())}`;
211
- }, o = (m, h) => new Date(m, h, 1), c = (m) => new Date(m.getFullYear(), m.getMonth() + 1, 0);
217
+ }, s = (m, h) => new Date(m, h, 1), c = (m) => new Date(m.getFullYear(), m.getMonth() + 1, 0);
212
218
  switch (t.preset) {
213
219
  case "this_month":
214
- return { start: a(o(n.getFullYear(), n.getMonth())), end: a(c(n)) };
220
+ return { start: a(s(n.getFullYear(), n.getMonth())), end: a(c(n)) };
215
221
  case "last_30_days":
216
222
  return { start: a(new Date(n.getTime() - 30 * 864e5)), end: a(n) };
217
223
  case "last_3_months":
218
- return { start: a(o(n.getFullYear(), n.getMonth() - 3)), end: a(c(n)) };
224
+ return { start: a(s(n.getFullYear(), n.getMonth() - 3)), end: a(c(n)) };
219
225
  case "last_6_months":
220
- return { start: a(o(n.getFullYear(), n.getMonth() - 6)), end: a(c(n)) };
226
+ return { start: a(s(n.getFullYear(), n.getMonth() - 6)), end: a(c(n)) };
221
227
  case "last_12_months":
222
- return { start: a(o(n.getFullYear(), n.getMonth() - 12)), end: a(c(n)) };
228
+ return { start: a(s(n.getFullYear(), n.getMonth() - 12)), end: a(c(n)) };
223
229
  case "ytd":
224
230
  return { start: `${n.getFullYear()}-01-01`, end: a(n) };
225
231
  case "custom":
@@ -228,23 +234,23 @@ function sa(t) {
228
234
  return null;
229
235
  }
230
236
  }
231
- const rl = "No workflow number", nl = /^undefined-\d+$/;
237
+ const il = "No workflow number", ol = /^undefined-\d+$/;
232
238
  function je(t, n, a) {
233
239
  if (t == null || t === "") return "—";
234
- if (typeof t == "string" && nl.test(t)) return rl;
240
+ if (typeof t == "string" && ol.test(t)) return il;
235
241
  if (n === "date" || n === "datetime") {
236
242
  const m = new Date(String(t));
237
243
  if (Number.isNaN(m.getTime())) return String(t);
238
244
  const h = m.toLocaleDateString();
239
245
  return n === "date" ? h : `${h} ${m.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}`;
240
246
  }
241
- const o = Number(t);
242
- if (Number.isNaN(o)) return String(t);
243
- const c = (m, h) => o.toLocaleString(void 0, {
247
+ const s = Number(t);
248
+ if (Number.isNaN(s)) return String(t);
249
+ const c = (m, h) => s.toLocaleString(void 0, {
244
250
  minimumFractionDigits: a ?? m,
245
251
  maximumFractionDigits: a ?? h
246
252
  });
247
- return n === "currency" ? `$${c(0, 0)}` : n === "percent" ? `${c(0, 1)}%` : n === "days" ? `${c(0, 1)}d` : n === "integer" ? Math.round(o).toLocaleString() : n === "number" ? c(0, 2) : String(t);
253
+ return n === "currency" ? `$${c(0, 0)}` : n === "percent" ? `${c(0, 1)}%` : n === "days" ? `${c(0, 1)}d` : n === "integer" ? Math.round(s).toLocaleString() : n === "number" ? c(0, 2) : String(t);
248
254
  }
249
255
  const ze = /* @__PURE__ */ new Set([
250
256
  "currency",
@@ -253,157 +259,157 @@ const ze = /* @__PURE__ */ new Set([
253
259
  "percent",
254
260
  "days"
255
261
  ]);
256
- function ia(t, n, a) {
257
- const o = {}, c = sa(n);
262
+ function oa(t, n, a) {
263
+ const s = {}, c = ia(n);
258
264
  for (const [m, h] of Object.entries(t.params ?? {})) {
259
265
  if (h === "$date.start") {
260
- c && (o[m] = c.start);
266
+ c && (s[m] = c.start);
261
267
  continue;
262
268
  }
263
269
  if (h === "$date.end") {
264
- c && (o[m] = c.end);
270
+ c && (s[m] = c.end);
265
271
  continue;
266
272
  }
267
273
  const f = /^\$filters\.([\w.]+?)(:values)?$/.exec(h);
268
274
  if (f) {
269
- const p = a.find((q) => q.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;
270
- L && L.length > 0 && (o[m] = L.join(","));
275
+ const u = a.find((M) => M.field === f[1]), R = f[2] ? u == null ? void 0 : u.values : u != null && u.labels && u.labels.length > 0 ? u.labels : u == null ? void 0 : u.values;
276
+ R && R.length > 0 && (s[m] = R.join(","));
271
277
  continue;
272
278
  }
273
- o[m] = h;
279
+ s[m] = h;
274
280
  }
275
- return o;
281
+ return s;
276
282
  }
277
- const sl = (t) => `$${Ce(Math.round(t))}`, il = [
283
+ const dl = (t) => `$${Ce(Math.round(t))}`, cl = [
278
284
  { gte: 90, color: "#ef4444" },
279
285
  { gte: 70, color: "#f59e0b" },
280
286
  { gte: -1 / 0, color: "#10b981" }
281
287
  ];
282
- function ol({
288
+ function ml({
283
289
  rows: t,
284
290
  cfg: n,
285
291
  onDrill: a
286
292
  }) {
287
- const o = n.tree, c = n.series && n.series.length > 0 ? n.series : Object.keys(t[0] ?? {}).filter((u) => {
288
- var N;
289
- return typeof ((N = t[0]) == null ? void 0 : N[u]) == "number";
290
- }).slice(0, 3).map((u) => ({ field: u, label: u })), m = ut(
291
- () => o ? Pa(
293
+ const s = n.tree, c = n.series && n.series.length > 0 ? n.series : Object.keys(t[0] ?? {}).filter((p) => {
294
+ var S;
295
+ return typeof ((S = t[0]) == null ? void 0 : S[p]) == "number";
296
+ }).slice(0, 3).map((p) => ({ field: p, label: p })), m = ut(
297
+ () => s ? Wa(
292
298
  t,
293
- o,
294
- c.map((u) => u.field)
299
+ s,
300
+ c.map((p) => p.field)
295
301
  ) : [],
296
302
  // eslint-disable-next-line react-hooks/exhaustive-deps
297
- [t, o]
298
- ), [h, f] = C(() => /* @__PURE__ */ new Set()), [p, L] = C(!1);
303
+ [t, s]
304
+ ), [h, f] = C(() => /* @__PURE__ */ new Set()), [u, R] = C(!1);
299
305
  mt(() => {
300
- if (p || m.length === 0) return;
301
- const u = /* @__PURE__ */ new Set(), N = (Y) => {
302
- for (const O of Y)
303
- (O.depth > 0 || m.length === 1) && u.add(O.key), N(O.children);
306
+ if (u || m.length === 0) return;
307
+ const p = /* @__PURE__ */ new Set(), S = (ee) => {
308
+ for (const F of ee)
309
+ (F.depth > 0 || m.length === 1) && p.add(F.key), S(F.children);
304
310
  };
305
- N(m), f(u), L(!0);
306
- }, [m, p]);
307
- const q = (o == null ? void 0 : o.thresholds) ?? il, w = (u) => {
308
- var N;
309
- return u == null ? void 0 : ((N = q.find((Y) => u >= Y.gte)) == null ? void 0 : N.color) ?? "#10b981";
310
- }, U = (u) => {
311
- const N = u.children.length === 0, Y = h.has(u.key), O = w(u.pct), ee = N && (o == null ? void 0 : o.drill) && u.drillId != null;
312
- return /* @__PURE__ */ i("div", { style: { paddingLeft: u.depth === 0 ? 0 : 14 }, children: [
313
- /* @__PURE__ */ i(
311
+ S(m), f(p), R(!0);
312
+ }, [m, u]);
313
+ const M = (s == null ? void 0 : s.thresholds) ?? cl, N = (p) => {
314
+ var S;
315
+ return p == null ? void 0 : ((S = M.find((ee) => p >= ee.gte)) == null ? void 0 : S.color) ?? "#10b981";
316
+ }, W = (p) => {
317
+ const S = p.children.length === 0, ee = h.has(p.key), F = N(p.pct), Z = S && (s == null ? void 0 : s.drill) && p.drillId != null;
318
+ return /* @__PURE__ */ o("div", { style: { paddingLeft: p.depth === 0 ? 0 : 14 }, children: [
319
+ /* @__PURE__ */ o(
314
320
  "div",
315
321
  {
316
- role: ee || !N ? "button" : void 0,
317
- tabIndex: ee || !N ? 0 : void 0,
318
- className: Q(
322
+ role: Z || !S ? "button" : void 0,
323
+ tabIndex: Z || !S ? 0 : void 0,
324
+ className: V(
319
325
  "group/tn rounded-md px-1.5 py-1",
320
- (ee || !N) && "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40"
326
+ (Z || !S) && "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40"
321
327
  ),
322
328
  onClick: () => {
323
- N ? ee && (o != null && o.drill) && a({
324
- collection: o.drill.collection,
325
- itemId: String(u.drillId),
326
- title: u.label
327
- }) : f((X) => {
328
- const ue = new Set(X);
329
- return ue.has(u.key) ? ue.delete(u.key) : ue.add(u.key), ue;
329
+ S ? Z && (s != null && s.drill) && a({
330
+ collection: s.drill.collection,
331
+ itemId: String(p.drillId),
332
+ title: p.label
333
+ }) : f((P) => {
334
+ const me = new Set(P);
335
+ return me.has(p.key) ? me.delete(p.key) : me.add(p.key), me;
330
336
  });
331
337
  },
332
- onKeyDown: (X) => {
333
- (X.key === "Enter" || X.key === " ") && X.currentTarget.click();
338
+ onKeyDown: (P) => {
339
+ (P.key === "Enter" || P.key === " ") && P.currentTarget.click();
334
340
  },
335
341
  children: [
336
- /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
337
- N ? /* @__PURE__ */ e("span", { className: "w-3 shrink-0" }) : /* @__PURE__ */ e(
342
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5", children: [
343
+ S ? /* @__PURE__ */ e("span", { className: "w-3 shrink-0" }) : /* @__PURE__ */ e(
338
344
  Jt,
339
345
  {
340
- className: Q(
346
+ className: V(
341
347
  "h-3 w-3 shrink-0 text-slate-400 transition-transform",
342
- Y && "rotate-180"
348
+ ee && "rotate-180"
343
349
  )
344
350
  }
345
351
  ),
346
- N && u.badge && /* @__PURE__ */ e("span", { className: "shrink-0 rounded bg-slate-100 px-1 py-px text-[9.5px] tabular-nums text-slate-500 dark:bg-muted dark:text-slate-400", children: u.badge }),
352
+ S && p.badge && /* @__PURE__ */ e("span", { className: "shrink-0 rounded bg-slate-100 px-1 py-px text-[9.5px] tabular-nums text-slate-500 dark:bg-muted dark:text-slate-400", children: p.badge }),
347
353
  /* @__PURE__ */ e(
348
354
  "span",
349
355
  {
350
- className: Q(
356
+ className: V(
351
357
  "min-w-0 flex-1 truncate",
352
- u.depth === 0 ? "text-[12px] font-semibold text-slate-800 dark:text-slate-100" : u.depth === 1 ? "text-[11.5px] font-medium text-slate-700 dark:text-slate-200" : Q(
358
+ p.depth === 0 ? "text-[12px] font-semibold text-slate-800 dark:text-slate-100" : p.depth === 1 ? "text-[11.5px] font-medium text-slate-700 dark:text-slate-200" : V(
353
359
  "text-[11px] text-slate-600 dark:text-slate-300",
354
- ee && "group-hover/tn:underline"
360
+ Z && "group-hover/tn:underline"
355
361
  )
356
362
  ),
357
- children: u.label
363
+ children: p.label
358
364
  }
359
365
  ),
360
- (o == null ? void 0 : o.pct) && (u.pct == null ? /* @__PURE__ */ e("span", { className: "shrink-0 text-[10.5px] font-semibold tabular-nums text-slate-400", children: "—" }) : /* @__PURE__ */ i(
366
+ (s == null ? void 0 : s.pct) && (p.pct == null ? /* @__PURE__ */ e("span", { className: "shrink-0 text-[10.5px] font-semibold tabular-nums text-slate-400", children: "—" }) : /* @__PURE__ */ o(
361
367
  "span",
362
368
  {
363
369
  className: "shrink-0 text-[10.5px] font-semibold tabular-nums",
364
- style: { color: O },
370
+ style: { color: F },
365
371
  children: [
366
- u.pct.toFixed(1),
372
+ p.pct.toFixed(1),
367
373
  "%"
368
374
  ]
369
375
  }
370
376
  ))
371
377
  ] }),
372
- (o == null ? void 0 : o.pct) && u.pct != null && /* @__PURE__ */ e(
378
+ (s == null ? void 0 : s.pct) && p.pct != null && /* @__PURE__ */ e(
373
379
  "div",
374
380
  {
375
- className: Q(
381
+ className: V(
376
382
  "ml-[18px] mt-0.5 overflow-hidden rounded-full bg-slate-100 dark:bg-muted",
377
- u.depth === 0 ? "h-[5px]" : u.depth === 1 ? "h-[3px]" : "h-[2px]"
383
+ p.depth === 0 ? "h-[5px]" : p.depth === 1 ? "h-[3px]" : "h-[2px]"
378
384
  ),
379
385
  children: /* @__PURE__ */ e(
380
386
  "div",
381
387
  {
382
388
  className: "h-full rounded-full transition-[width] duration-300",
383
- style: { width: `${Math.min(Math.max(u.pct, 0), 100)}%`, background: O }
389
+ style: { width: `${Math.min(Math.max(p.pct, 0), 100)}%`, background: F }
384
390
  }
385
391
  )
386
392
  }
387
393
  ),
388
- /* @__PURE__ */ e("div", { className: "ml-[18px] mt-0.5 flex flex-wrap gap-x-3 text-[10px] tabular-nums text-slate-400", children: c.map((X) => /* @__PURE__ */ i("span", { children: [
389
- X.label ?? X.field,
394
+ /* @__PURE__ */ e("div", { className: "ml-[18px] mt-0.5 flex flex-wrap gap-x-3 text-[10px] tabular-nums text-slate-400", children: c.map((P) => /* @__PURE__ */ o("span", { children: [
395
+ P.label ?? P.field,
390
396
  " ",
391
- /* @__PURE__ */ e("span", { className: "font-medium text-slate-500 dark:text-slate-300", children: u.sums[X.field] == null ? X.empty_label ?? "—" : n.value_format === "currency" ? sl(u.sums[X.field]) : u.sums[X.field].toLocaleString() })
392
- ] }, X.field)) })
397
+ /* @__PURE__ */ e("span", { className: "font-medium text-slate-500 dark:text-slate-300", children: p.sums[P.field] == null ? P.empty_label ?? "—" : n.value_format === "currency" ? dl(p.sums[P.field]) : p.sums[P.field].toLocaleString() })
398
+ ] }, P.field)) })
393
399
  ]
394
400
  }
395
401
  ),
396
- Y && u.children.map(U)
397
- ] }, u.key);
402
+ ee && p.children.map(W)
403
+ ] }, p.key);
398
404
  };
399
- 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(U) });
405
+ return !s || 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(W) });
400
406
  }
401
- function dl(t) {
407
+ function ul(t) {
402
408
  const [n, a] = C(() => typeof IntersectionObserver > "u");
403
409
  return mt(() => {
404
410
  if (n) return;
405
- const o = t.current;
406
- if (!o) {
411
+ const s = t.current;
412
+ if (!s) {
407
413
  a(!0);
408
414
  return;
409
415
  }
@@ -413,20 +419,20 @@ function dl(t) {
413
419
  },
414
420
  { rootMargin: "600px 0px" }
415
421
  );
416
- c.observe(o);
422
+ c.observe(s);
417
423
  const m = () => a(!0);
418
424
  return window.addEventListener("beforeprint", m), () => {
419
425
  c.disconnect(), window.removeEventListener("beforeprint", m);
420
426
  };
421
427
  }, [n, t]), n;
422
428
  }
423
- function cl(t) {
424
- const n = Ke(), a = St(!1);
425
- return async (o) => {
429
+ function pl(t) {
430
+ const n = Ke(), a = _t(!1);
431
+ return async (s) => {
426
432
  if (!(!t || a.current)) {
427
433
  a.current = !0;
428
434
  try {
429
- const m = (await n.request(pt("/report-studio/drill-row", { values: o }))).data;
435
+ const m = (await n.request(pt("/report-studio/drill-row", { values: s }))).data;
430
436
  m != null && m.collection && m.item_id && t({ collection: m.collection, itemId: m.item_id });
431
437
  } catch {
432
438
  } finally {
@@ -435,177 +441,177 @@ function cl(t) {
435
441
  }
436
442
  };
437
443
  }
438
- function oa(t, n) {
444
+ function da(t, n) {
439
445
  let a = n;
440
446
  if (t.group_rows && t.x_field) {
441
- const o = /* @__PURE__ */ new Map(), c = new Set(
447
+ const s = /* @__PURE__ */ new Map(), c = new Set(
442
448
  (t.series ?? []).map((m) => m.field).length > 0 ? (t.series ?? []).map((m) => m.field) : Object.keys(a[0] ?? {}).filter((m) => {
443
449
  var h;
444
450
  return typeof ((h = a[0]) == null ? void 0 : h[m]) == "number";
445
451
  })
446
452
  );
447
453
  for (const m of a) {
448
- const h = String(m[t.x_field] ?? "Unknown"), f = o.get(h) ?? { [t.x_field]: h };
449
- for (const p of c) f[p] = (Number(f[p]) || 0) + (Number(m[p]) || 0);
450
- o.set(h, f);
454
+ const h = String(m[t.x_field] ?? "Unknown"), f = s.get(h) ?? { [t.x_field]: h };
455
+ for (const u of c) f[u] = (Number(f[u]) || 0) + (Number(m[u]) || 0);
456
+ s.set(h, f);
451
457
  }
452
- a = [...o.values()];
458
+ a = [...s.values()];
453
459
  }
454
460
  if (t.sort) {
455
- const o = t.sort.startsWith("-"), c = o ? t.sort.slice(1) : t.sort;
461
+ const s = t.sort.startsWith("-"), c = s ? t.sort.slice(1) : t.sort;
456
462
  a = [...a].sort((m, h) => {
457
- const f = m[c], p = h[c], L = typeof f == "number" && typeof p == "number" ? f - p : String(f ?? "").localeCompare(String(p ?? ""));
458
- return o ? -L : L;
463
+ const f = m[c], u = h[c], R = typeof f == "number" && typeof u == "number" ? f - u : String(f ?? "").localeCompare(String(u ?? ""));
464
+ return s ? -R : R;
459
465
  });
460
466
  }
461
467
  return t.limit && t.limit > 0 && (a = a.slice(0, t.limit)), a;
462
468
  }
463
- function da(t, n, a, o) {
464
- const c = fa(n, a);
465
- return t.request(o ? { ...c, _signal: o } : c).then((m) => m.data ?? []);
469
+ function ca(t, n, a, s) {
470
+ const c = xa(n, a);
471
+ return t.request(s ? { ...c, _signal: s } : c).then((m) => m.data ?? []);
466
472
  }
467
- function ml({
473
+ function hl({
468
474
  cfg: t,
469
475
  dateRange: n,
470
476
  entityFilters: a,
471
- refetchInterval: o,
477
+ refetchInterval: s,
472
478
  onStatus: c,
473
479
  onDrill: m,
474
480
  deferred: h = !1
475
481
  }) {
476
- var le, ae;
477
- const f = Ke(), p = cl(m), [L, q] = C(""), [w, U] = C(0), [u, N] = C(null), Y = ia(t, n, a), { data: O, isLoading: ee, error: X, isFetching: ue, refetch: pe } = Ne({
478
- queryKey: ["nivaro-report-query", t.slug, Y],
479
- queryFn: ({ signal: S }) => da(f, t.slug, Y, S),
482
+ var re, le;
483
+ const f = Ke(), u = pl(m), [R, M] = C(""), [N, W] = C(0), [p, S] = C(null), ee = oa(t, n, a), { data: F, isLoading: Z, error: P, isFetching: me, refetch: J } = Ne({
484
+ queryKey: ["nivaro-report-query", t.slug, ee],
485
+ queryFn: ({ signal: w }) => ca(f, t.slug, ee, w),
480
486
  enabled: !h,
481
487
  staleTime: 6e4,
482
- refetchInterval: o,
488
+ refetchInterval: s,
483
489
  retry: !1
484
490
  });
485
491
  if (mt(() => {
486
- c == null || c({ isFetching: ue, refetch: () => void pe() });
487
- }, [ue]), h && O === void 0)
492
+ c == null || c({ isFetching: me, refetch: () => void J() });
493
+ }, [me]), h && F === void 0)
488
494
  return /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-300", children: "Loading…" });
489
- if (ee)
490
- return /* @__PURE__ */ i("div", { className: "flex flex-col gap-2 px-1", children: [
495
+ if (Z)
496
+ return /* @__PURE__ */ o("div", { className: "flex flex-col gap-2 px-1", children: [
491
497
  /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-300", children: "Loading…" }),
492
498
  /* @__PURE__ */ e(
493
- ea,
499
+ ta,
494
500
  {
495
501
  pending: !0,
496
502
  request: {
497
503
  method: "POST",
498
504
  url: `/custom-queries/${t.slug}/execute`,
499
- body: { params: Y }
505
+ body: { params: ee }
500
506
  },
501
507
  label: `Query ${t.slug}`,
502
- queryKey: ["nivaro-report-query", t.slug, Y],
503
- select: (S) => (S == null ? void 0 : S.data) ?? []
508
+ queryKey: ["nivaro-report-query", t.slug, ee],
509
+ select: (w) => (w == null ? void 0 : w.data) ?? []
504
510
  }
505
511
  )
506
512
  ] });
507
- if (X)
513
+ if (P)
508
514
  return /* @__PURE__ */ e(
509
- ta,
515
+ aa,
510
516
  {
511
517
  className: "px-1",
512
- message: It(X) ?? Tt(X, "this query"),
513
- onRetry: () => void pe()
518
+ message: It(P) ?? Tt(P, "this query"),
519
+ onRetry: () => void J()
514
520
  }
515
521
  );
516
- const H = oa(t, O ?? []);
517
- if (H.length === 0) return /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." });
518
- const de = t.columns && t.columns.length > 0 ? t.columns : Object.keys(H[0] ?? {}).map((S) => ({ field: S }));
522
+ const B = da(t, F ?? []);
523
+ if (B.length === 0) return /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." });
524
+ const se = t.columns && t.columns.length > 0 ? t.columns : Object.keys(B[0] ?? {}).map((w) => ({ field: w }));
519
525
  if (t.display === "kpis") {
520
- const S = t.x_field ? H.map((A, E) => {
521
- var J, ne, ce, fe, _;
526
+ const w = t.x_field ? B.map((T, Q) => {
527
+ var H, ie, ue, fe, _;
522
528
  return {
523
- label: String(A[t.x_field] ?? ""),
524
- value: A[((ne = (J = t.series) == null ? void 0 : J[0]) == null ? void 0 : ne.field) ?? ((ce = de.find((P) => P.field !== t.x_field)) == null ? void 0 : ce.field) ?? ""],
525
- color: ((_ = (fe = t.series) == null ? void 0 : fe[0]) == null ? void 0 : _.color) ?? oe[E % oe.length],
529
+ label: String(T[t.x_field] ?? ""),
530
+ value: T[((ie = (H = t.series) == null ? void 0 : H[0]) == null ? void 0 : ie.field) ?? ((ue = se.find((z) => z.field !== t.x_field)) == null ? void 0 : ue.field) ?? ""],
531
+ color: ((_ = (fe = t.series) == null ? void 0 : fe[0]) == null ? void 0 : _.color) ?? ce[Q % ce.length],
526
532
  format: t.value_format
527
533
  };
528
- }) : de.map((A, E) => {
529
- var J;
534
+ }) : se.map((T, Q) => {
535
+ var H;
530
536
  return {
531
- label: A.label ?? A.field,
532
- value: (J = H[0]) == null ? void 0 : J[A.field],
533
- color: oe[E % oe.length],
534
- format: A.format ?? t.value_format
537
+ label: T.label ?? T.field,
538
+ value: (H = B[0]) == null ? void 0 : H[T.field],
539
+ color: ce[Q % ce.length],
540
+ format: T.format ?? t.value_format
535
541
  };
536
542
  });
537
543
  return /* @__PURE__ */ e(
538
544
  "div",
539
545
  {
540
546
  className: "grid gap-2",
541
- style: { gridTemplateColumns: `repeat(${Math.min(6, Math.max(1, S.length))}, 1fr)` },
542
- children: S.map((A) => /* @__PURE__ */ i(
547
+ style: { gridTemplateColumns: `repeat(${Math.min(6, Math.max(1, w.length))}, 1fr)` },
548
+ children: w.map((T) => /* @__PURE__ */ o(
543
549
  "div",
544
550
  {
545
551
  className: "flex flex-col justify-center rounded-md border border-slate-100 px-3 py-2 dark:border-border/60",
546
- style: { borderTopColor: A.color, borderTopWidth: 2 },
552
+ style: { borderTopColor: T.color, borderTopWidth: 2 },
547
553
  children: [
548
- /* @__PURE__ */ e("p", { className: "truncate text-[10.5px] uppercase tracking-wide text-slate-400", children: A.label }),
549
- /* @__PURE__ */ e("p", { className: "text-[19px] font-semibold leading-tight text-slate-900 dark:text-foreground", children: je(A.value, A.format ?? "integer") })
554
+ /* @__PURE__ */ e("p", { className: "truncate text-[10.5px] uppercase tracking-wide text-slate-400", children: T.label }),
555
+ /* @__PURE__ */ e("p", { className: "text-[19px] font-semibold leading-tight text-slate-900 dark:text-foreground", children: je(T.value, T.format ?? "integer") })
550
556
  ]
551
557
  },
552
- A.label
558
+ T.label
553
559
  ))
554
560
  }
555
561
  );
556
562
  }
557
563
  if (t.display === "tree")
558
- return /* @__PURE__ */ e(ol, { rows: H, cfg: t, onDrill: (S) => m == null ? void 0 : m(S) });
564
+ return /* @__PURE__ */ e(ml, { rows: B, cfg: t, onDrill: (w) => m == null ? void 0 : m(w) });
559
565
  if (t.display === "table") {
560
- const S = de.filter((_) => ze.has(_.format ?? "")), A = L.trim().toLowerCase(), E = A ? H.filter(
566
+ const w = se.filter((_) => ze.has(_.format ?? "")), T = R.trim().toLowerCase(), Q = T ? B.filter(
561
567
  (_) => Object.values(_).some(
562
- (P) => String(P ?? "").toLowerCase().includes(A)
568
+ (z) => String(z ?? "").toLowerCase().includes(T)
563
569
  )
564
- ) : H, J = 12, ne = Math.max(1, Math.ceil(E.length / J)), ce = Math.min(w, ne - 1), fe = E.length > J ? E.slice(ce * J, ce * J + J) : E;
565
- return /* @__PURE__ */ i("div", { className: "flex min-h-0 flex-1 flex-col", children: [
566
- H.length > J && /* @__PURE__ */ i("div", { className: "mb-1 flex items-center gap-2", children: [
570
+ ) : B, H = 12, ie = Math.max(1, Math.ceil(Q.length / H)), ue = Math.min(N, ie - 1), fe = Q.length > H ? Q.slice(ue * H, ue * H + H) : Q;
571
+ return /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
572
+ B.length > H && /* @__PURE__ */ o("div", { className: "mb-1 flex items-center gap-2", children: [
567
573
  /* @__PURE__ */ e(
568
574
  "input",
569
575
  {
570
- value: L,
576
+ value: R,
571
577
  onChange: (_) => {
572
- q(_.target.value), U(0);
578
+ M(_.target.value), W(0);
573
579
  },
574
580
  placeholder: "Search rows…",
575
581
  className: "h-6 w-40 rounded border border-slate-200 bg-white px-1.5 text-[11px] dark:border-border dark:bg-card dark:text-slate-200"
576
582
  }
577
583
  ),
578
- ne > 1 && /* @__PURE__ */ i("span", { className: "ml-auto flex items-center gap-1 text-[10.5px] text-slate-400", children: [
584
+ ie > 1 && /* @__PURE__ */ o("span", { className: "ml-auto flex items-center gap-1 text-[10.5px] text-slate-400", children: [
579
585
  /* @__PURE__ */ e(
580
586
  "button",
581
587
  {
582
588
  type: "button",
583
- disabled: ce <= 0,
584
- onClick: () => U(ce - 1),
589
+ disabled: ue <= 0,
590
+ onClick: () => W(ue - 1),
585
591
  className: "rounded px-1 disabled:opacity-30",
586
592
  children: "←"
587
593
  }
588
594
  ),
589
- ce + 1,
595
+ ue + 1,
590
596
  "/",
591
- ne,
597
+ ie,
592
598
  /* @__PURE__ */ e(
593
599
  "button",
594
600
  {
595
601
  type: "button",
596
- disabled: ce >= ne - 1,
597
- onClick: () => U(ce + 1),
602
+ disabled: ue >= ie - 1,
603
+ onClick: () => W(ue + 1),
598
604
  className: "rounded px-1 disabled:opacity-30",
599
605
  children: "→"
600
606
  }
601
607
  )
602
608
  ] })
603
609
  ] }),
604
- /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ i("table", { className: "w-full text-[11.5px]", children: [
605
- /* @__PURE__ */ e("thead", { className: "sticky top-0 z-[1] bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: de.map((_) => /* @__PURE__ */ e(
610
+ /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ o("table", { className: "w-full text-[11.5px]", children: [
611
+ /* @__PURE__ */ e("thead", { className: "sticky top-0 z-[1] bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: se.map((_) => /* @__PURE__ */ e(
606
612
  "th",
607
613
  {
608
- className: Q(
614
+ className: V(
609
615
  "whitespace-nowrap border-b border-slate-100 px-1.5 py-1 text-left font-medium text-slate-400 dark:border-border",
610
616
  ze.has(_.format ?? "") && "text-right"
611
617
  ),
@@ -613,35 +619,35 @@ function ml({
613
619
  },
614
620
  _.field
615
621
  )) }) }),
616
- /* @__PURE__ */ e("tbody", { children: fe.map((_, P) => /* @__PURE__ */ e(
622
+ /* @__PURE__ */ e("tbody", { children: fe.map((_, z) => /* @__PURE__ */ e(
617
623
  "tr",
618
624
  {
619
625
  className: m ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/60" : void 0,
620
- onClick: () => void p(_),
626
+ onClick: () => void u(_),
621
627
  title: m ? "Open the record behind this row" : void 0,
622
- children: de.map((me) => /* @__PURE__ */ e(
628
+ children: se.map((pe) => /* @__PURE__ */ e(
623
629
  "td",
624
630
  {
625
- className: Q(
631
+ className: V(
626
632
  "max-w-[220px] truncate border-b border-slate-50 px-1.5 py-1 text-slate-700 dark:border-border/40 dark:text-slate-300",
627
- ze.has(me.format ?? "") && "text-right tabular-nums"
633
+ ze.has(pe.format ?? "") && "text-right tabular-nums"
628
634
  ),
629
- children: je(_[me.field], me.format, me.decimals)
635
+ children: je(_[pe.field], pe.format, pe.decimals)
630
636
  },
631
- me.field
637
+ pe.field
632
638
  ))
633
639
  },
634
- P
640
+ z
635
641
  )) }),
636
- t.totals && S.length > 0 && /* @__PURE__ */ e("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: de.map((_, P) => /* @__PURE__ */ e(
642
+ t.totals && w.length > 0 && /* @__PURE__ */ e("tfoot", { className: "sticky bottom-0 bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: se.map((_, z) => /* @__PURE__ */ e(
637
643
  "td",
638
644
  {
639
- className: Q(
645
+ className: V(
640
646
  "border-t border-slate-200 px-1.5 py-1 font-semibold text-slate-800 dark:border-border dark:text-slate-200",
641
647
  ze.has(_.format ?? "") && "text-right tabular-nums"
642
648
  ),
643
- children: P === 0 && !ze.has(_.format ?? "") ? "Total" : ze.has(_.format ?? "") ? je(
644
- H.reduce((me, ve) => me + (Number(ve[_.field]) || 0), 0),
649
+ children: z === 0 && !ze.has(_.format ?? "") ? "Total" : ze.has(_.format ?? "") ? je(
650
+ B.reduce((pe, ve) => pe + (Number(ve[_.field]) || 0), 0),
645
651
  _.format,
646
652
  _.decimals
647
653
  ) : ""
@@ -651,70 +657,70 @@ function ml({
651
657
  ] }) })
652
658
  ] });
653
659
  }
654
- const xe = t.x_field ?? ((le = de[0]) == null ? void 0 : le.field) ?? "", be = t.series && t.series.length > 0 ? t.series : de.filter((S) => {
655
- var A;
656
- return S.field !== xe && typeof ((A = H[0]) == null ? void 0 : A[S.field]) == "number";
657
- }).slice(0, 3).map((S) => ({ field: S.field, label: S.label ?? S.field })), ge = H.map((S) => {
658
- const A = { [xe]: S[xe] };
659
- for (const E of be) A[E.field] = Number(S[E.field]) || 0;
660
- return A;
661
- }), $e = (S) => t.value_format === "currency" ? `$${Ce(S)}` : Ce(S), x = (S) => je(S, t.value_format ?? "number"), Z = t.display === "hbar" || t.display === "stacked_bar" && t.horizontal, te = (S) => {
660
+ const xe = t.x_field ?? ((re = se[0]) == null ? void 0 : re.field) ?? "", be = t.series && t.series.length > 0 ? t.series : se.filter((w) => {
661
+ var T;
662
+ return w.field !== xe && typeof ((T = B[0]) == null ? void 0 : T[w.field]) == "number";
663
+ }).slice(0, 3).map((w) => ({ field: w.field, label: w.label ?? w.field })), ge = B.map((w) => {
664
+ const T = { [xe]: w[xe] };
665
+ for (const Q of be) T[Q.field] = Number(w[Q.field]) || 0;
666
+ return T;
667
+ }), $e = (w) => t.value_format === "currency" ? `$${Ce(w)}` : Ce(w), x = (w) => je(w, t.value_format ?? "number"), I = t.display === "hbar" || t.display === "stacked_bar" && t.horizontal, ae = (w) => {
662
668
  if (!m) return;
663
- const A = (O ?? []).filter((E) => String(E[xe] ?? "") === S);
664
- A.length > 0 && N({ label: S, rows: A });
665
- }, V = u ? /* @__PURE__ */ e(
669
+ const T = (F ?? []).filter((Q) => String(Q[xe] ?? "") === w);
670
+ T.length > 0 && S({ label: w, rows: T });
671
+ }, G = p ? /* @__PURE__ */ e(
666
672
  "div",
667
673
  {
668
674
  className: "fixed inset-0 z-[126] flex items-center justify-center bg-black/30 p-6",
669
- onClick: () => N(null),
670
- children: /* @__PURE__ */ i(
675
+ onClick: () => S(null),
676
+ children: /* @__PURE__ */ o(
671
677
  "div",
672
678
  {
673
679
  className: "flex max-h-[70vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-2xl dark:border-border dark:bg-card",
674
- onClick: (S) => S.stopPropagation(),
680
+ onClick: (w) => w.stopPropagation(),
675
681
  children: [
676
- /* @__PURE__ */ i("div", { className: "flex items-center gap-2 border-b border-slate-100 px-4 py-2.5 dark:border-border", children: [
677
- /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: u.label }),
678
- /* @__PURE__ */ i("span", { className: "text-[11.5px] text-slate-400", children: [
679
- u.rows.length,
682
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-2 border-b border-slate-100 px-4 py-2.5 dark:border-border", children: [
683
+ /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: p.label }),
684
+ /* @__PURE__ */ o("span", { className: "text-[11.5px] text-slate-400", children: [
685
+ p.rows.length,
680
686
  " rows — click one to open its record"
681
687
  ] }),
682
688
  /* @__PURE__ */ e(
683
689
  "button",
684
690
  {
685
691
  type: "button",
686
- onClick: () => N(null),
692
+ onClick: () => S(null),
687
693
  className: "rounded p-1 text-slate-400 hover:text-slate-600",
688
694
  children: /* @__PURE__ */ e(Ae, { className: "h-4 w-4" })
689
695
  }
690
696
  )
691
697
  ] }),
692
- /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto p-2", children: /* @__PURE__ */ i("table", { className: "w-full text-[11px]", children: [
693
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: Object.keys(u.rows[0] ?? {}).slice(0, 7).map((S) => /* @__PURE__ */ e(
698
+ /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto p-2", children: /* @__PURE__ */ o("table", { className: "w-full text-[11px]", children: [
699
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: Object.keys(p.rows[0] ?? {}).slice(0, 7).map((w) => /* @__PURE__ */ e(
694
700
  "th",
695
701
  {
696
702
  className: "border-b border-slate-100 px-1.5 py-1 text-left font-medium text-slate-400 dark:border-border",
697
- children: S
703
+ children: w
698
704
  },
699
- S
705
+ w
700
706
  )) }) }),
701
- /* @__PURE__ */ e("tbody", { children: u.rows.slice(0, 100).map((S, A) => /* @__PURE__ */ e(
707
+ /* @__PURE__ */ e("tbody", { children: p.rows.slice(0, 100).map((w, T) => /* @__PURE__ */ e(
702
708
  "tr",
703
709
  {
704
710
  className: "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/60",
705
711
  onClick: () => {
706
- N(null), p(S);
712
+ S(null), u(w);
707
713
  },
708
- children: Object.keys(u.rows[0] ?? {}).slice(0, 7).map((E) => /* @__PURE__ */ e(
714
+ children: Object.keys(p.rows[0] ?? {}).slice(0, 7).map((Q) => /* @__PURE__ */ e(
709
715
  "td",
710
716
  {
711
717
  className: "max-w-[160px] truncate border-b border-slate-50 px-1.5 py-1 text-slate-600 dark:border-border/40 dark:text-slate-300",
712
- children: String(S[E] ?? "")
718
+ children: String(w[Q] ?? "")
713
719
  },
714
- E
720
+ Q
715
721
  ))
716
722
  },
717
- A
723
+ T
718
724
  )) })
719
725
  ] }) })
720
726
  ]
@@ -723,14 +729,14 @@ function ml({
723
729
  }
724
730
  ) : null;
725
731
  if (t.display === "donut") {
726
- const S = ((ae = be[0]) == null ? void 0 : ae.field) ?? "", A = ge.map((J) => ({ dim: String(J[xe]), value: Number(J[S]) || 0 })), E = A.reduce((J, ne) => J + ne.value, 0);
727
- return /* @__PURE__ */ i("div", { className: "flex min-h-0 flex-1 items-stretch gap-3", children: [
728
- /* @__PURE__ */ i("div", { className: "relative min-h-[110px] min-w-0 flex-1", children: [
729
- /* @__PURE__ */ e(Re, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Cell: J, Pie: ne, PieChart: ce, ResponsiveContainer: fe, Tooltip: _ }) => /* @__PURE__ */ e(fe, { width: "100%", height: "100%", children: /* @__PURE__ */ i(ce, { children: [
732
+ const w = ((le = be[0]) == null ? void 0 : le.field) ?? "", T = ge.map((H) => ({ dim: String(H[xe]), value: Number(H[w]) || 0 })), Q = T.reduce((H, ie) => H + ie.value, 0);
733
+ return /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 items-stretch gap-3", children: [
734
+ /* @__PURE__ */ o("div", { className: "relative min-h-[110px] min-w-0 flex-1", children: [
735
+ /* @__PURE__ */ e(Le, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Cell: H, Pie: ie, PieChart: ue, ResponsiveContainer: fe, Tooltip: _ }) => /* @__PURE__ */ e(fe, { width: "100%", height: "100%", children: /* @__PURE__ */ o(ue, { children: [
730
736
  /* @__PURE__ */ e(
731
- ne,
737
+ ie,
732
738
  {
733
- data: A,
739
+ data: T,
734
740
  dataKey: "value",
735
741
  nameKey: "dim",
736
742
  innerRadius: "58%",
@@ -738,12 +744,12 @@ function ml({
738
744
  paddingAngle: 2,
739
745
  strokeWidth: 0,
740
746
  className: m ? "cursor-pointer" : void 0,
741
- onClick: (P) => {
747
+ onClick: (z) => {
742
748
  var ve;
743
- const me = (ve = P == null ? void 0 : P.payload) == null ? void 0 : ve.dim;
744
- me && te(String(me));
749
+ const pe = (ve = z == null ? void 0 : z.payload) == null ? void 0 : ve.dim;
750
+ pe && ae(String(pe));
745
751
  },
746
- children: A.map((P, me) => /* @__PURE__ */ e(J, { fill: oe[me % oe.length] }, P.dim))
752
+ children: T.map((z, pe) => /* @__PURE__ */ e(H, { fill: ce[pe % ce.length] }, z.dim))
747
753
  }
748
754
  ),
749
755
  /* @__PURE__ */ e(
@@ -758,44 +764,44 @@ function ml({
758
764
  },
759
765
  labelStyle: { color: "#f1f5f9" },
760
766
  itemStyle: { color: "#e2e8f0" },
761
- formatter: (P) => x(P)
767
+ formatter: (z) => x(z)
762
768
  }
763
769
  )
764
770
  ] }) }) }),
765
- /* @__PURE__ */ i("div", { className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center", children: [
766
- /* @__PURE__ */ e("span", { className: "text-[17px] font-semibold leading-none text-slate-900 dark:text-foreground", children: je(E, t.value_format ?? "integer") }),
771
+ /* @__PURE__ */ o("div", { className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center", children: [
772
+ /* @__PURE__ */ e("span", { className: "text-[17px] font-semibold leading-none text-slate-900 dark:text-foreground", children: je(Q, t.value_format ?? "integer") }),
767
773
  /* @__PURE__ */ e("span", { className: "text-[9.5px] text-slate-400", children: "total" })
768
774
  ] })
769
775
  ] }),
770
- /* @__PURE__ */ e("div", { className: "max-h-full w-[40%] shrink-0 space-y-0.5 self-center overflow-y-auto pr-1", children: A.slice(0, 12).map((J, ne) => /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
776
+ /* @__PURE__ */ e("div", { className: "max-h-full w-[40%] shrink-0 space-y-0.5 self-center overflow-y-auto pr-1", children: T.slice(0, 12).map((H, ie) => /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
771
777
  /* @__PURE__ */ e(
772
778
  "span",
773
779
  {
774
780
  className: "h-2 w-2 shrink-0 rounded-sm",
775
- style: { background: oe[ne % oe.length] }
781
+ style: { background: ce[ie % ce.length] }
776
782
  }
777
783
  ),
778
- /* @__PURE__ */ e("span", { className: "truncate text-slate-600 dark:text-slate-300", children: J.dim }),
779
- /* @__PURE__ */ e("span", { className: "ml-auto tabular-nums text-slate-400", children: x(J.value) })
780
- ] }, J.dim)) }),
781
- V
784
+ /* @__PURE__ */ e("span", { className: "truncate text-slate-600 dark:text-slate-300", children: H.dim }),
785
+ /* @__PURE__ */ e("span", { className: "ml-auto tabular-nums text-slate-400", children: x(H.value) })
786
+ ] }, H.dim)) }),
787
+ G
782
788
  ] });
783
789
  }
784
790
  if (t.display === "line" || t.display === "area")
785
- return /* @__PURE__ */ i("div", { className: "min-h-[110px] min-w-0 flex-1", children: [
786
- /* @__PURE__ */ e(Re, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Area: S, AreaChart: A, Legend: E, ResponsiveContainer: J, Tooltip: ne, XAxis: ce, YAxis: fe }) => /* @__PURE__ */ e(J, { width: "100%", height: "100%", children: /* @__PURE__ */ i(A, { data: ge, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
791
+ return /* @__PURE__ */ o("div", { className: "min-h-[110px] min-w-0 flex-1", children: [
792
+ /* @__PURE__ */ e(Le, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Area: w, AreaChart: T, Legend: Q, ResponsiveContainer: H, Tooltip: ie, XAxis: ue, YAxis: fe }) => /* @__PURE__ */ e(H, { width: "100%", height: "100%", children: /* @__PURE__ */ o(T, { data: ge, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
787
793
  /* @__PURE__ */ e(
788
- ce,
794
+ ue,
789
795
  {
790
796
  dataKey: xe,
791
797
  tick: { fontSize: 10 },
792
798
  stroke: "#94a3b8",
793
- ..._t(ge.length)
799
+ ...Ct(ge.length)
794
800
  }
795
801
  ),
796
802
  /* @__PURE__ */ e(fe, { tick: { fontSize: 10 }, stroke: "#94a3b8", tickFormatter: $e, width: 48 }),
797
803
  /* @__PURE__ */ e(
798
- ne,
804
+ ie,
799
805
  {
800
806
  contentStyle: {
801
807
  fontSize: 12,
@@ -809,34 +815,34 @@ function ml({
809
815
  formatter: (_) => x(_)
810
816
  }
811
817
  ),
812
- be.length > 1 && /* @__PURE__ */ e(E, { wrapperStyle: { fontSize: 11 } }),
813
- be.map((_, P) => /* @__PURE__ */ e(
814
- S,
818
+ be.length > 1 && /* @__PURE__ */ e(Q, { wrapperStyle: { fontSize: 11 } }),
819
+ be.map((_, z) => /* @__PURE__ */ e(
820
+ w,
815
821
  {
816
822
  type: "monotone",
817
823
  dataKey: _.field,
818
824
  name: _.label ?? _.field,
819
- stroke: _.color ?? oe[P % oe.length],
825
+ stroke: _.color ?? ce[z % ce.length],
820
826
  strokeWidth: 2,
821
827
  strokeDasharray: _.dash ? "4 3" : void 0,
822
- fill: _.color ?? oe[P % oe.length],
828
+ fill: _.color ?? ce[z % ce.length],
823
829
  fillOpacity: t.display === "area" && !_.dash ? 0.12 : 0
824
830
  },
825
831
  _.field
826
832
  ))
827
833
  ] }) }) }),
828
- V
834
+ G
829
835
  ] });
830
836
  const he = t.display === "stacked_bar";
831
- return /* @__PURE__ */ i("div", { className: "min-h-[110px] min-w-0 flex-1", children: [
832
- /* @__PURE__ */ e(Re, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Bar: S, BarChart: A, Cell: E, Legend: J, ResponsiveContainer: ne, Tooltip: ce, XAxis: fe, YAxis: _ }) => /* @__PURE__ */ e(ne, { width: "100%", height: "100%", children: /* @__PURE__ */ i(
833
- A,
837
+ return /* @__PURE__ */ o("div", { className: "min-h-[110px] min-w-0 flex-1", children: [
838
+ /* @__PURE__ */ e(Le, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Bar: w, BarChart: T, Cell: Q, Legend: H, ResponsiveContainer: ie, Tooltip: ue, XAxis: fe, YAxis: _ }) => /* @__PURE__ */ e(ie, { width: "100%", height: "100%", children: /* @__PURE__ */ o(
839
+ T,
834
840
  {
835
841
  data: ge,
836
- layout: Z ? "vertical" : "horizontal",
837
- margin: { top: 6, right: 8, left: Z ? 30 : -6, bottom: 0 },
842
+ layout: I ? "vertical" : "horizontal",
843
+ margin: { top: 6, right: 8, left: I ? 30 : -6, bottom: 0 },
838
844
  children: [
839
- Z ? /* @__PURE__ */ i(He, { children: [
845
+ I ? /* @__PURE__ */ o(He, { children: [
840
846
  /* @__PURE__ */ e(
841
847
  fe,
842
848
  {
@@ -855,23 +861,23 @@ function ml({
855
861
  stroke: "#94a3b8",
856
862
  width: 140,
857
863
  interval: 0,
858
- tickFormatter: yl
864
+ tickFormatter: wl
859
865
  }
860
866
  )
861
- ] }) : /* @__PURE__ */ i(He, { children: [
867
+ ] }) : /* @__PURE__ */ o(He, { children: [
862
868
  /* @__PURE__ */ e(
863
869
  fe,
864
870
  {
865
871
  dataKey: xe,
866
872
  tick: { fontSize: 10 },
867
873
  stroke: "#94a3b8",
868
- ..._t(ge.length)
874
+ ...Ct(ge.length)
869
875
  }
870
876
  ),
871
877
  /* @__PURE__ */ e(_, { tick: { fontSize: 10 }, stroke: "#94a3b8", tickFormatter: $e, width: 48 })
872
878
  ] }),
873
879
  /* @__PURE__ */ e(
874
- ce,
880
+ ue,
875
881
  {
876
882
  contentStyle: {
877
883
  fontSize: 12,
@@ -882,41 +888,41 @@ function ml({
882
888
  },
883
889
  labelStyle: { color: "#f1f5f9" },
884
890
  itemStyle: { color: "#e2e8f0" },
885
- formatter: (P) => x(P)
891
+ formatter: (z) => x(z)
886
892
  }
887
893
  ),
888
- be.length > 1 && /* @__PURE__ */ e(J, { wrapperStyle: { fontSize: 11 } }),
889
- be.map((P, me) => /* @__PURE__ */ e(
890
- S,
894
+ be.length > 1 && /* @__PURE__ */ e(H, { wrapperStyle: { fontSize: 11 } }),
895
+ be.map((z, pe) => /* @__PURE__ */ e(
896
+ w,
891
897
  {
892
898
  className: m ? "cursor-pointer" : void 0,
893
899
  onClick: (ve) => {
894
900
  var Te;
895
901
  const we = (Te = ve == null ? void 0 : ve.payload) == null ? void 0 : Te[xe];
896
- we != null && te(String(we));
902
+ we != null && ae(String(we));
897
903
  },
898
- dataKey: P.field,
899
- name: P.label ?? P.field,
904
+ dataKey: z.field,
905
+ name: z.label ?? z.field,
900
906
  stackId: he ? "stack" : void 0,
901
- fill: P.color ?? oe[me % oe.length],
902
- radius: he ? 0 : Z ? [0, 3, 3, 0] : [3, 3, 0, 0],
903
- children: be.length === 1 && !P.color && ge.map((ve, we) => /* @__PURE__ */ e(E, { fill: oe[we % oe.length] }, we))
907
+ fill: z.color ?? ce[pe % ce.length],
908
+ radius: he ? 0 : I ? [0, 3, 3, 0] : [3, 3, 0, 0],
909
+ children: be.length === 1 && !z.color && ge.map((ve, we) => /* @__PURE__ */ e(Q, { fill: ce[we % ce.length] }, we))
904
910
  },
905
- P.field
911
+ z.field
906
912
  ))
907
913
  ]
908
914
  }
909
915
  ) }) }),
910
- V
916
+ G
911
917
  ] });
912
918
  }
913
- const ul = ["gt", "gte", "lt", "lte", "eq"], ca = { gt: ">", gte: "≥", lt: "<", lte: "≤", eq: "=" }, pl = ["sum", "avg", "max", "min"];
914
- function hl(t) {
915
- var o, c, m;
919
+ const fl = ["gt", "gte", "lt", "lte", "eq"], ma = { gt: ">", gte: "≥", lt: "<", lte: "≤", eq: "=" }, xl = ["sum", "avg", "max", "min"];
920
+ function bl(t) {
921
+ var s, c, m;
916
922
  const n = [
917
923
  { value: "value", label: "Value (widget metric)" },
918
924
  { value: "row_count", label: "Row count" }
919
- ], a = (o = t.config) == null ? void 0 : o.query;
925
+ ], a = (s = t.config) == null ? void 0 : s.query;
920
926
  if (t.type === "query" && a) {
921
927
  const h = a.columns && a.columns.length > 0 ? a.columns.map((f) => ({ value: f.field, label: f.label ?? f.field, aggregatable: !0 })) : (a.series ?? []).map((f) => ({
922
928
  value: f.field,
@@ -941,32 +947,32 @@ function hl(t) {
941
947
  }
942
948
  function jt(t, n) {
943
949
  var h;
944
- const a = /^(sum|avg|max|min|tile):(.+)$/.exec(t.field), o = a ? a[2] : t.field, c = ((h = n.find((f) => f.value === t.field || f.value === o)) == null ? void 0 : h.label) ?? o;
945
- return `${a && a[1] !== "sum" && a[1] !== "tile" ? `${a[1]} ` : ""}${c} ${ca[t.op] ?? t.op} ${t.value.toLocaleString()}`;
950
+ const a = /^(sum|avg|max|min|tile):(.+)$/.exec(t.field), s = a ? a[2] : t.field, c = ((h = n.find((f) => f.value === t.field || f.value === s)) == null ? void 0 : h.label) ?? s;
951
+ return `${a && a[1] !== "sum" && a[1] !== "tile" ? `${a[1]} ` : ""}${c} ${ma[t.op] ?? t.op} ${t.value.toLocaleString()}`;
946
952
  }
947
- function fl({ reportId: t, alert: n }) {
948
- const a = Ke(), o = Ct(), { data: c = [] } = Ne({
953
+ function gl({ reportId: t, alert: n }) {
954
+ const a = Ke(), s = ht(), { data: c = [] } = Ne({
949
955
  queryKey: ["nivaro-report-alert-log", t, n.id],
950
- queryFn: () => a.request(wa(t, n.id)).then((h) => h.data),
956
+ queryFn: () => a.request(Sa(t, n.id)).then((h) => h.data),
951
957
  staleTime: 3e4
952
958
  }), m = Me({
953
- mutationFn: () => a.request(Sa(t, n.id)),
959
+ mutationFn: () => a.request(_a(t, n.id)),
954
960
  onSuccess: () => {
955
- o.invalidateQueries({ queryKey: ["nivaro-report-alert-log", t, n.id] }), o.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] });
961
+ s.invalidateQueries({ queryKey: ["nivaro-report-alert-log", t, n.id] }), s.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] });
956
962
  }
957
963
  });
958
- return c.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: c.slice(0, 20).map((h) => /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
964
+ return c.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: c.slice(0, 20).map((h) => /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
959
965
  /* @__PURE__ */ e(
960
966
  "span",
961
967
  {
962
- className: Q(
968
+ className: V(
963
969
  "h-1.5 w-1.5 shrink-0 rounded-full",
964
970
  h.status === "firing" ? "bg-amber-500" : "bg-emerald-500"
965
971
  )
966
972
  }
967
973
  ),
968
- /* @__PURE__ */ e("span", { className: Q(h.status === "firing" ? "text-amber-600" : "text-slate-500"), children: h.status === "firing" ? "Firing" : "Resolved" }),
969
- /* @__PURE__ */ i("span", { className: "min-w-0 flex-1 truncate text-slate-400", children: [
974
+ /* @__PURE__ */ e("span", { className: V(h.status === "firing" ? "text-amber-600" : "text-slate-500"), children: h.status === "firing" ? "Firing" : "Resolved" }),
975
+ /* @__PURE__ */ o("span", { className: "min-w-0 flex-1 truncate text-slate-400", children: [
970
976
  new Date(h.fired_at).toLocaleString(),
971
977
  h.resolved_at ? ` → ${new Date(h.resolved_at).toLocaleString()}` : ""
972
978
  ] }),
@@ -981,73 +987,73 @@ function fl({ reportId: t, alert: n }) {
981
987
  )
982
988
  ] }, h.id)) });
983
989
  }
984
- function xl({
990
+ function vl({
985
991
  reportId: t,
986
992
  widget: n,
987
993
  filterBar: a
988
994
  }) {
989
- const o = Ke(), c = Ct(), [m, h] = C(!1), [f, p] = C(""), [L, q] = C([
995
+ const s = Ke(), c = ht(), [m, h] = C(!1), [f, u] = C(""), [R, M] = C([
990
996
  { field: "value", agg: "sum", op: "gt", value: "" }
991
- ]), [w, U] = C([]), [u, N] = C(!1), [Y, O] = C(null), ee = hl(n), { data: X = [] } = Ne({
997
+ ]), [N, W] = C([]), [p, S] = C(!1), [ee, F] = C(null), Z = bl(n), { data: P = [] } = Ne({
992
998
  queryKey: ["nivaro-report-alerts", t],
993
- queryFn: () => o.request(va(t)).then((x) => x.data),
999
+ queryFn: () => s.request(ya(t)).then((x) => x.data),
994
1000
  enabled: m,
995
1001
  staleTime: 3e4
996
- }), ue = X.filter((x) => x.widget === n.id), pe = () => void c.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] }), H = () => L.filter((x) => x.value.trim() !== "" && !Number.isNaN(Number(x.value))).map((x) => {
997
- const Z = ee.find((V) => V.value === x.field);
998
- return { field: Z != null && Z.aggregatable && x.agg !== "sum" ? `${x.agg}:${x.field}` : x.field, op: x.op, value: Number(x.value) };
999
- }), de = Me({
1002
+ }), me = P.filter((x) => x.widget === n.id), J = () => void c.invalidateQueries({ queryKey: ["nivaro-report-alerts", t] }), B = () => R.filter((x) => x.value.trim() !== "" && !Number.isNaN(Number(x.value))).map((x) => {
1003
+ const I = Z.find((G) => G.value === x.field);
1004
+ return { field: I != null && I.aggregatable && x.agg !== "sum" ? `${x.agg}:${x.field}` : x.field, op: x.op, value: Number(x.value) };
1005
+ }), se = Me({
1000
1006
  mutationFn: () => {
1001
- const x = H(), Z = x.map((te) => jt(te, ee)).join(" & ");
1002
- return o.request(
1003
- ya(t, {
1007
+ const x = B(), I = x.map((ae) => jt(ae, Z)).join(" & ");
1008
+ return s.request(
1009
+ ka(t, {
1004
1010
  widget: n.id,
1005
- name: f.trim() || Z.slice(0, 120),
1011
+ name: f.trim() || I.slice(0, 120),
1006
1012
  conditions: x,
1007
- filters: w.filter((te) => te.values.length > 0),
1008
- delivery_email: u,
1013
+ filters: N.filter((ae) => ae.values.length > 0),
1014
+ delivery_email: p,
1009
1015
  delivery_inapp: !0
1010
1016
  })
1011
1017
  );
1012
1018
  },
1013
1019
  onSuccess: () => {
1014
- p(""), q([{ field: "value", agg: "sum", op: "gt", value: "" }]), U([]), pe();
1020
+ u(""), M([{ field: "value", agg: "sum", op: "gt", value: "" }]), W([]), J();
1015
1021
  }
1016
1022
  }), xe = Me({
1017
- mutationFn: (x) => o.request(ka(t, x.id, !x.is_active)),
1018
- onSuccess: pe
1023
+ mutationFn: (x) => s.request(Na(t, x.id, !x.is_active)),
1024
+ onSuccess: J
1019
1025
  }), be = Me({
1020
- mutationFn: (x) => o.request(Na(t, x.id)),
1021
- onSuccess: pe
1022
- }), ge = H().length > 0, $e = ue.some((x) => x.firing);
1023
- return /* @__PURE__ */ i(aa, { open: m, onOpenChange: h, children: [
1024
- /* @__PURE__ */ e(la, { asChild: !0, children: /* @__PURE__ */ e(
1026
+ mutationFn: (x) => s.request(wa(t, x.id)),
1027
+ onSuccess: J
1028
+ }), ge = B().length > 0, $e = me.some((x) => x.firing);
1029
+ return /* @__PURE__ */ o(la, { open: m, onOpenChange: h, children: [
1030
+ /* @__PURE__ */ e(ra, { asChild: !0, children: /* @__PURE__ */ e(
1025
1031
  "button",
1026
1032
  {
1027
1033
  type: "button",
1028
1034
  title: "Alerts on this widget",
1029
- className: Q(
1035
+ className: V(
1030
1036
  "rounded p-0.5",
1031
1037
  $e ? "text-amber-500" : "text-slate-300 hover:text-amber-500 dark:text-slate-600"
1032
1038
  ),
1033
1039
  children: /* @__PURE__ */ e(Vt, { className: "h-3 w-3" })
1034
1040
  }
1035
1041
  ) }),
1036
- /* @__PURE__ */ i(ra, { className: "w-[380px] p-3", align: "end", children: [
1037
- /* @__PURE__ */ i("p", { className: "mb-2 text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: [
1042
+ /* @__PURE__ */ o(na, { className: "w-[380px] p-3", align: "end", children: [
1043
+ /* @__PURE__ */ o("p", { className: "mb-2 text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: [
1038
1044
  "Alerts · ",
1039
1045
  n.title
1040
1046
  ] }),
1041
- ue.length > 0 && /* @__PURE__ */ e("div", { className: "mb-2 space-y-1.5", children: ue.map((x) => /* @__PURE__ */ i(
1047
+ me.length > 0 && /* @__PURE__ */ e("div", { className: "mb-2 space-y-1.5", children: me.map((x) => /* @__PURE__ */ o(
1042
1048
  "div",
1043
1049
  {
1044
1050
  className: "rounded-md border border-slate-100 px-2 py-1.5 dark:border-border/60",
1045
1051
  children: [
1046
- /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 text-[11.5px]", children: [
1052
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5 text-[11.5px]", children: [
1047
1053
  /* @__PURE__ */ e(
1048
1054
  "span",
1049
1055
  {
1050
- className: Q(
1056
+ className: V(
1051
1057
  "h-1.5 w-1.5 shrink-0 rounded-full",
1052
1058
  x.firing ? "bg-amber-500" : x.is_active ? "bg-emerald-500" : "bg-slate-300"
1053
1059
  )
@@ -1059,7 +1065,7 @@ function xl({
1059
1065
  {
1060
1066
  type: "button",
1061
1067
  className: "text-[10.5px] text-slate-400 hover:text-slate-600",
1062
- onClick: () => O(Y === x.id ? null : x.id),
1068
+ onClick: () => F(ee === x.id ? null : x.id),
1063
1069
  children: "History"
1064
1070
  }
1065
1071
  ),
@@ -1078,66 +1084,66 @@ function xl({
1078
1084
  type: "button",
1079
1085
  className: "text-slate-300 hover:text-red-500",
1080
1086
  onClick: () => be.mutate(x),
1081
- children: /* @__PURE__ */ e(Aa, { className: "h-3 w-3" })
1087
+ children: /* @__PURE__ */ e(Ta, { className: "h-3 w-3" })
1082
1088
  }
1083
1089
  )
1084
1090
  ] }),
1085
- /* @__PURE__ */ i("p", { className: "mt-0.5 truncate pl-3 text-[10.5px] text-slate-400", children: [
1086
- (x.conditions ?? []).map((Z) => jt(Z, ee)).join(" & "),
1087
- x.filters && x.filters.length > 0 && ` · scoped: ${x.filters.map((Z) => (Z.labels ?? Z.values).join("/")).join(", ")}`,
1091
+ /* @__PURE__ */ o("p", { className: "mt-0.5 truncate pl-3 text-[10.5px] text-slate-400", children: [
1092
+ (x.conditions ?? []).map((I) => jt(I, Z)).join(" & "),
1093
+ x.filters && x.filters.length > 0 && ` · scoped: ${x.filters.map((I) => (I.labels ?? I.values).join("/")).join(", ")}`,
1088
1094
  " · ",
1089
1095
  x.delivery_email ? "In-app + Email" : "In-app",
1090
1096
  " · Last fired: ",
1091
1097
  x.last_fired ? new Date(x.last_fired).toLocaleString() : "Never"
1092
1098
  ] }),
1093
- Y === x.id && /* @__PURE__ */ e(fl, { reportId: t, alert: x })
1099
+ ee === x.id && /* @__PURE__ */ e(gl, { reportId: t, alert: x })
1094
1100
  ]
1095
1101
  },
1096
1102
  x.id
1097
1103
  )) }),
1098
- /* @__PURE__ */ i("div", { className: "space-y-1.5 border-t border-slate-100 pt-2 dark:border-border", children: [
1104
+ /* @__PURE__ */ o("div", { className: "space-y-1.5 border-t border-slate-100 pt-2 dark:border-border", children: [
1099
1105
  /* @__PURE__ */ e(
1100
1106
  "input",
1101
1107
  {
1102
1108
  value: f,
1103
- onChange: (x) => p(x.target.value),
1109
+ onChange: (x) => u(x.target.value),
1104
1110
  placeholder: "Alert name (optional)",
1105
1111
  className: "h-7 w-full rounded-md border border-slate-200 bg-white px-2 text-[11.5px] dark:border-border dark:bg-card"
1106
1112
  }
1107
1113
  ),
1108
- L.map((x, Z) => {
1109
- const te = ee.find((V) => V.value === x.field);
1110
- return /* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
1114
+ R.map((x, I) => {
1115
+ const ae = Z.find((G) => G.value === x.field);
1116
+ return /* @__PURE__ */ o("div", { className: "flex items-center gap-1", children: [
1111
1117
  /* @__PURE__ */ e(
1112
- Nt,
1118
+ wt,
1113
1119
  {
1114
1120
  value: x.field,
1115
- onChange: (V) => q((he) => he.map((le, ae) => ae === Z ? { ...le, field: V } : le)),
1116
- options: ee.map((V) => ({ value: V.value, label: V.label })),
1121
+ onChange: (G) => M((he) => he.map((re, le) => le === I ? { ...re, field: G } : re)),
1122
+ options: Z.map((G) => ({ value: G.value, label: G.label })),
1117
1123
  ariaLabel: "Alert metric field",
1118
1124
  className: "h-7 min-w-0 flex-1 rounded-md px-1.5 py-0 text-[11.5px] dark:border-border dark:bg-card"
1119
1125
  }
1120
1126
  ),
1121
- (te == null ? void 0 : te.aggregatable) && /* @__PURE__ */ e(
1122
- Nt,
1127
+ (ae == null ? void 0 : ae.aggregatable) && /* @__PURE__ */ e(
1128
+ wt,
1123
1129
  {
1124
1130
  value: x.agg,
1125
- onChange: (V) => q(
1126
- (he) => he.map((le, ae) => ae === Z ? { ...le, agg: V } : le)
1131
+ onChange: (G) => M(
1132
+ (he) => he.map((re, le) => le === I ? { ...re, agg: G } : re)
1127
1133
  ),
1128
- options: pl.map((V) => ({ value: V, label: V })),
1134
+ options: xl.map((G) => ({ value: G, label: G })),
1129
1135
  ariaLabel: "Aggregate",
1130
1136
  className: "h-7 w-[62px] rounded-md px-1.5 py-0 text-[11.5px] dark:border-border dark:bg-card"
1131
1137
  }
1132
1138
  ),
1133
1139
  /* @__PURE__ */ e(
1134
- Nt,
1140
+ wt,
1135
1141
  {
1136
1142
  value: x.op,
1137
- onChange: (V) => q(
1138
- (he) => he.map((le, ae) => ae === Z ? { ...le, op: V } : le)
1143
+ onChange: (G) => M(
1144
+ (he) => he.map((re, le) => le === I ? { ...re, op: G } : re)
1139
1145
  ),
1140
- options: ul.map((V) => ({ value: V, label: ca[V] })),
1146
+ options: fl.map((G) => ({ value: G, label: ma[G] })),
1141
1147
  ariaLabel: "Operator",
1142
1148
  className: "h-7 w-[52px] rounded-md px-1.5 py-0 text-[11.5px] dark:border-border dark:bg-card"
1143
1149
  }
@@ -1146,74 +1152,74 @@ function xl({
1146
1152
  "input",
1147
1153
  {
1148
1154
  value: x.value,
1149
- onChange: (V) => q(
1150
- (he) => he.map((le, ae) => ae === Z ? { ...le, value: V.target.value } : le)
1155
+ onChange: (G) => M(
1156
+ (he) => he.map((re, le) => le === I ? { ...re, value: G.target.value } : re)
1151
1157
  ),
1152
1158
  placeholder: "0",
1153
1159
  inputMode: "decimal",
1154
1160
  className: "h-7 w-[64px] rounded-md border border-slate-200 bg-white px-2 text-right text-[11.5px] tabular-nums dark:border-border dark:bg-card"
1155
1161
  }
1156
1162
  ),
1157
- L.length > 1 && /* @__PURE__ */ e(
1163
+ R.length > 1 && /* @__PURE__ */ e(
1158
1164
  "button",
1159
1165
  {
1160
1166
  type: "button",
1161
1167
  className: "text-slate-300 hover:text-red-500",
1162
- onClick: () => q((V) => V.filter((he, le) => le !== Z)),
1168
+ onClick: () => M((G) => G.filter((he, re) => re !== I)),
1163
1169
  children: /* @__PURE__ */ e(Ae, { className: "h-3 w-3" })
1164
1170
  }
1165
1171
  )
1166
- ] }, Z);
1172
+ ] }, I);
1167
1173
  }),
1168
1174
  /* @__PURE__ */ e(
1169
1175
  "button",
1170
1176
  {
1171
1177
  type: "button",
1172
1178
  className: "text-[10.5px] text-slate-400 hover:text-nvr-navy dark:hover:text-nvr-cyan",
1173
- onClick: () => q((x) => [...x, { field: "value", agg: "sum", op: "gt", value: "" }]),
1179
+ onClick: () => M((x) => [...x, { field: "value", agg: "sum", op: "gt", value: "" }]),
1174
1180
  children: "+ condition (all must match)"
1175
1181
  }
1176
1182
  ),
1177
- a.length > 0 && /* @__PURE__ */ i("div", { children: [
1183
+ a.length > 0 && /* @__PURE__ */ o("div", { children: [
1178
1184
  /* @__PURE__ */ e("p", { className: "mb-1 text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: "Alert scope (optional)" }),
1179
1185
  /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1", children: a.map((x) => {
1180
- var Z;
1186
+ var I;
1181
1187
  return /* @__PURE__ */ e(
1182
- na,
1188
+ sa,
1183
1189
  {
1184
1190
  reportId: t,
1185
1191
  field: x.field,
1186
1192
  label: x.label,
1187
1193
  optionSource: x.options,
1188
- selected: ((Z = w.find((te) => te.field === x.field)) == null ? void 0 : Z.values) ?? [],
1189
- onChange: (te, V) => U((he) => [
1190
- ...he.filter((le) => le.field !== x.field),
1191
- ...te.length > 0 ? [{ field: x.field, values: te, labels: V }] : []
1194
+ selected: ((I = N.find((ae) => ae.field === x.field)) == null ? void 0 : I.values) ?? [],
1195
+ onChange: (ae, G) => W((he) => [
1196
+ ...he.filter((re) => re.field !== x.field),
1197
+ ...ae.length > 0 ? [{ field: x.field, values: ae, labels: G }] : []
1192
1198
  ])
1193
1199
  },
1194
1200
  x.field
1195
1201
  );
1196
1202
  }) })
1197
1203
  ] }),
1198
- /* @__PURE__ */ i("div", { className: "flex items-center justify-between", children: [
1199
- /* @__PURE__ */ i("label", { className: "flex items-center gap-1.5 text-[11px] text-slate-500", children: [
1204
+ /* @__PURE__ */ o("div", { className: "flex items-center justify-between", children: [
1205
+ /* @__PURE__ */ o("label", { className: "flex items-center gap-1.5 text-[11px] text-slate-500", children: [
1200
1206
  /* @__PURE__ */ e(
1201
1207
  "input",
1202
1208
  {
1203
1209
  type: "checkbox",
1204
- checked: u,
1205
- onChange: (x) => N(x.target.checked),
1210
+ checked: p,
1211
+ onChange: (x) => S(x.target.checked),
1206
1212
  className: "h-3 w-3 accent-nvr-cyan"
1207
1213
  }
1208
1214
  ),
1209
1215
  "Also email me"
1210
1216
  ] }),
1211
- /* @__PURE__ */ i(
1217
+ /* @__PURE__ */ o(
1212
1218
  "button",
1213
1219
  {
1214
1220
  type: "button",
1215
- disabled: !ge || de.isPending,
1216
- onClick: () => de.mutate(),
1221
+ disabled: !ge || se.isPending,
1222
+ onClick: () => se.mutate(),
1217
1223
  className: "inline-flex h-7 items-center gap-1 rounded-md bg-nvr-cyan px-2 text-[11.5px] font-semibold text-white disabled:opacity-50",
1218
1224
  children: [
1219
1225
  /* @__PURE__ */ e(Yt, { className: "h-3 w-3" }),
@@ -1227,7 +1233,7 @@ function xl({
1227
1233
  ] })
1228
1234
  ] });
1229
1235
  }
1230
- const bl = {
1236
+ const yl = {
1231
1237
  eq: "_eq",
1232
1238
  neq: "_neq",
1233
1239
  gt: "_gt",
@@ -1239,40 +1245,40 @@ const bl = {
1239
1245
  null: "_null",
1240
1246
  nnull: "_nnull"
1241
1247
  };
1242
- function Mt(t, n, a, o) {
1243
- var L, q;
1248
+ function Mt(t, n, a, s) {
1249
+ var R, M;
1244
1250
  const c = t.config ?? {}, m = [];
1245
- for (const w of c.filters ?? []) {
1246
- const U = bl[w.op];
1247
- if (!U) continue;
1248
- let u = w.value;
1249
- w.op === "in" && typeof u == "string" && (u = u.split(",").map((N) => N.trim())), m.push({ path: [w.field], op: U, value: u });
1251
+ for (const N of c.filters ?? []) {
1252
+ const W = yl[N.op];
1253
+ if (!W) continue;
1254
+ let p = N.value;
1255
+ N.op === "in" && typeof p == "string" && (p = p.split(",").map((S) => S.trim())), m.push({ path: [N.field], op: W, value: p });
1250
1256
  }
1251
- for (const w of n)
1252
- (L = w.values) != null && L.length && m.push({ path: [w.field], op: "_in", value: w.values });
1253
- const h = c.date_field || ((q = c.dimension) != null && q.bucket ? c.dimension.field : null), f = sa(a);
1257
+ for (const N of n)
1258
+ (R = N.values) != null && R.length && m.push({ path: [N.field], op: "_in", value: N.values });
1259
+ const h = c.date_field || ((M = c.dimension) != null && M.bucket ? c.dimension.field : null), f = ia(a);
1254
1260
  f && h && (m.push({ path: [h], op: "_gte", value: f.start }), m.push({ path: [h], op: "_lte", value: `${f.end}T23:59:59` }));
1255
- const p = c.dimension;
1256
- if (o !== void 0 && (p != null && p.field))
1257
- if (p.bucket) {
1258
- const w = String(o);
1259
- if (/^\d{4}-\d{2}-\d{2}$/.test(w))
1260
- m.push({ path: [p.field], op: "_gte", value: w }), m.push({ path: [p.field], op: "_lte", value: `${w}T23:59:59` });
1261
- else if (/^\d{4}-\d{2}$/.test(w)) {
1262
- const [U, u] = w.split("-").map(Number), N = new Date(U, u, 0).getDate();
1263
- m.push({ path: [p.field], op: "_gte", value: `${w}-01` }), m.push({
1264
- path: [p.field],
1261
+ const u = c.dimension;
1262
+ if (s !== void 0 && (u != null && u.field))
1263
+ if (u.bucket) {
1264
+ const N = String(s);
1265
+ if (/^\d{4}-\d{2}-\d{2}$/.test(N))
1266
+ m.push({ path: [u.field], op: "_gte", value: N }), m.push({ path: [u.field], op: "_lte", value: `${N}T23:59:59` });
1267
+ else if (/^\d{4}-\d{2}$/.test(N)) {
1268
+ const [W, p] = N.split("-").map(Number), S = new Date(W, p, 0).getDate();
1269
+ m.push({ path: [u.field], op: "_gte", value: `${N}-01` }), m.push({
1270
+ path: [u.field],
1265
1271
  op: "_lte",
1266
- value: `${w}-${String(N).padStart(2, "0")}T23:59:59`
1272
+ value: `${N}-${String(S).padStart(2, "0")}T23:59:59`
1267
1273
  });
1268
1274
  }
1269
- } else o === null ? m.push({ path: [p.field], op: "_null", value: !0 }) : m.push({ path: [p.field], op: "_eq", value: o });
1275
+ } else s === null ? m.push({ path: [u.field], op: "_null", value: !0 }) : m.push({ path: [u.field], op: "_eq", value: s });
1270
1276
  return m;
1271
1277
  }
1272
1278
  function Et(t) {
1273
- const n = t.config ?? {}, a = [], o = n.query;
1274
- if (t.type === "query" && (o != null && o.slug))
1275
- a.push(`Custom query: ${o.slug}`);
1279
+ const n = t.config ?? {}, a = [], s = n.query;
1280
+ if (t.type === "query" && (s != null && s.slug))
1281
+ a.push(`Custom query: ${s.slug}`);
1276
1282
  else if (t.collection) {
1277
1283
  const c = n.metric, m = (c == null ? void 0 : c.aggregate) ?? "count";
1278
1284
  a.push(
@@ -1281,62 +1287,62 @@ function Et(t) {
1281
1287
  const h = n.dimension;
1282
1288
  h != null && h.field && a.push(`by ${h.field}${h.bucket ? ` (${h.bucket})` : ""}`);
1283
1289
  const f = n.filters ?? [];
1284
- for (const p of f) a.push(`${p.field} ${p.op} ${String(p.value ?? "")}`);
1290
+ for (const u of f) a.push(`${u.field} ${u.op} ${String(u.value ?? "")}`);
1285
1291
  n.date_field && a.push(`dated by ${n.date_field}`), n.compare && a.push(`compared to ${String(n.compare).replace(/_/g, " ")}`);
1286
1292
  }
1287
1293
  return a.length > 0 ? a.join(" · ") : "No configuration details";
1288
1294
  }
1289
- function gl(t) {
1295
+ function kl(t) {
1290
1296
  var n, a;
1291
- return t ? t.value != null ? Number(t.value) : t.series ? t.series.reduce((o, c) => o + (Number(c.value) || 0), 0) : (n = t.tiles) != null && n.length ? Number(((a = t.tiles[0]) == null ? void 0 : a.value) ?? 0) : t.row_count != null ? Number(t.row_count) : null : null;
1297
+ return t ? t.value != null ? Number(t.value) : t.series ? t.series.reduce((s, c) => s + (Number(c.value) || 0), 0) : (n = t.tiles) != null && n.length ? Number(((a = t.tiles[0]) == null ? void 0 : a.value) ?? 0) : t.row_count != null ? Number(t.row_count) : null : null;
1292
1298
  }
1293
1299
  function Wt(t, n, a) {
1294
- var q, w, U;
1295
- const o = a ? [...a] : [];
1296
- if (o.length === 0 && ((q = n == null ? void 0 : n.rows) != null && q.length) && o.push(...n.rows), o.length === 0 && ((w = n == null ? void 0 : n.series) != null && w.length))
1297
- for (const u of n.series)
1298
- o.push({
1299
- dim: u.dim,
1300
- value: u.value,
1301
- ...u.prev != null ? { previous: u.prev } : {},
1302
- ...u.value2 != null ? { value2: u.value2 } : {}
1300
+ var M, N, W;
1301
+ const s = a ? [...a] : [];
1302
+ if (s.length === 0 && ((M = n == null ? void 0 : n.rows) != null && M.length) && s.push(...n.rows), s.length === 0 && ((N = n == null ? void 0 : n.series) != null && N.length))
1303
+ for (const p of n.series)
1304
+ s.push({
1305
+ dim: p.dim,
1306
+ value: p.value,
1307
+ ...p.prev != null ? { previous: p.prev } : {},
1308
+ ...p.value2 != null ? { value2: p.value2 } : {}
1303
1309
  });
1304
- if (o.length === 0 && ((U = n == null ? void 0 : n.tiles) != null && U.length))
1305
- for (const u of n.tiles) o.push({ label: u.label, value: u.value });
1306
- if (o.length === 0 && (n == null ? void 0 : n.value) != null && o.push({ value: n.value }), o.length === 0) {
1310
+ if (s.length === 0 && ((W = n == null ? void 0 : n.tiles) != null && W.length))
1311
+ for (const p of n.tiles) s.push({ label: p.label, value: p.value });
1312
+ if (s.length === 0 && (n == null ? void 0 : n.value) != null && s.push({ value: n.value }), s.length === 0) {
1307
1313
  Xt.info("Nothing to download yet", {
1308
1314
  description: "This widget has no rows for these filters."
1309
1315
  });
1310
1316
  return;
1311
1317
  }
1312
- const c = [...new Set(o.flatMap((u) => Object.keys(u)))], m = (u) => {
1313
- const N = String(u ?? "");
1314
- return /[",\n]/.test(N) ? `"${N.replace(/"/g, '""')}"` : N;
1315
- }, h = [c.join(","), ...o.map((u) => c.map((N) => m(u[N])).join(","))].join(
1318
+ const c = [...new Set(s.flatMap((p) => Object.keys(p)))], m = (p) => {
1319
+ const S = String(p ?? "");
1320
+ return /[",\n]/.test(S) ? `"${S.replace(/"/g, '""')}"` : S;
1321
+ }, h = [c.join(","), ...s.map((p) => c.map((S) => m(p[S])).join(","))].join(
1316
1322
  `
1317
1323
  `
1318
- ), f = new Blob([h], { type: "text/csv;charset=utf-8" }), p = document.createElement("a");
1319
- p.href = URL.createObjectURL(f), p.download = `${(t.title || "widget").replace(/[^\w-]+/g, "_")}.csv`, p.click();
1320
- const L = p.href;
1321
- setTimeout(() => URL.revokeObjectURL(L), 1e4);
1324
+ ), f = new Blob([h], { type: "text/csv;charset=utf-8" }), u = document.createElement("a");
1325
+ u.href = URL.createObjectURL(f), u.download = `${(t.title || "widget").replace(/[^\w-]+/g, "_")}.csv`, u.click();
1326
+ const R = u.href;
1327
+ setTimeout(() => URL.revokeObjectURL(R), 1e4);
1322
1328
  }
1323
- function vl({
1329
+ function Nl({
1324
1330
  collection: t,
1325
1331
  conditions: n,
1326
1332
  title: a,
1327
- onClose: o,
1333
+ onClose: s,
1328
1334
  onOpen: c,
1329
1335
  crossFilter: m
1330
1336
  }) {
1331
- const h = Ke(), { data: f, isLoading: p } = Ne({
1337
+ const h = Ke(), { data: f, isLoading: u } = Ne({
1332
1338
  queryKey: ["nvr-report-drill", t, JSON.stringify(n)],
1333
1339
  queryFn: () => h.request(
1334
1340
  ct(`/items/${t}`, { limit: 50, conditions: JSON.stringify(n) })
1335
1341
  ),
1336
1342
  staleTime: 3e4,
1337
1343
  retry: !1
1338
- }), L = (f == null ? void 0 : f.data) ?? [], q = (w) => {
1339
- for (const u of [
1344
+ }), R = (f == null ? void 0 : f.data) ?? [], M = (N) => {
1345
+ for (const p of [
1340
1346
  "title",
1341
1347
  "name",
1342
1348
  "label",
@@ -1345,28 +1351,28 @@ function vl({
1345
1351
  "project_id",
1346
1352
  "description"
1347
1353
  ]) {
1348
- const N = w[u];
1349
- if (typeof N == "string" && N.trim()) return N.slice(0, 90);
1354
+ const S = N[p];
1355
+ if (typeof S == "string" && S.trim()) return S.slice(0, 90);
1350
1356
  }
1351
- const U = Object.entries(w).find(
1352
- ([u, N]) => u !== "id" && typeof N == "string" && N.trim()
1357
+ const W = Object.entries(N).find(
1358
+ ([p, S]) => p !== "id" && typeof S == "string" && S.trim()
1353
1359
  );
1354
- return U ? String(U[1]).slice(0, 90) : `#${w.id}`;
1360
+ return W ? String(W[1]).slice(0, 90) : `#${N.id}`;
1355
1361
  };
1356
1362
  return /* @__PURE__ */ e(
1357
1363
  "div",
1358
1364
  {
1359
1365
  className: "fixed inset-0 z-[126] flex items-center justify-center bg-black/30 p-6",
1360
- onClick: o,
1361
- children: /* @__PURE__ */ i(
1366
+ onClick: s,
1367
+ children: /* @__PURE__ */ o(
1362
1368
  "div",
1363
1369
  {
1364
1370
  className: "flex max-h-[70vh] w-full max-w-xl flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-2xl dark:border-border dark:bg-card",
1365
- onClick: (w) => w.stopPropagation(),
1371
+ onClick: (N) => N.stopPropagation(),
1366
1372
  children: [
1367
- /* @__PURE__ */ i("div", { className: "flex items-center gap-2 border-b border-slate-100 px-4 py-2.5 dark:border-border", children: [
1373
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-2 border-b border-slate-100 px-4 py-2.5 dark:border-border", children: [
1368
1374
  /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: a }),
1369
- /* @__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` : "" }),
1375
+ /* @__PURE__ */ e("span", { className: "text-[11.5px] tabular-nums text-slate-400", children: f ? `${R.length}${(f.total ?? 0) > R.length ? ` of ${f.total.toLocaleString()}` : ""} records` : "" }),
1370
1376
  m && /* @__PURE__ */ e(
1371
1377
  "button",
1372
1378
  {
@@ -1381,24 +1387,24 @@ function vl({
1381
1387
  "button",
1382
1388
  {
1383
1389
  type: "button",
1384
- onClick: o,
1390
+ onClick: s,
1385
1391
  className: "rounded p-1 text-slate-400 hover:text-slate-600",
1386
1392
  children: /* @__PURE__ */ e(Ae, { className: "h-4 w-4" })
1387
1393
  }
1388
1394
  )
1389
1395
  ] }),
1390
- /* @__PURE__ */ i("div", { className: "min-h-0 flex-1 overflow-y-auto p-1.5", children: [
1391
- p && /* @__PURE__ */ e("p", { className: "px-2.5 py-3 text-[12px] text-slate-400", children: "Loading…" }),
1392
- !p && L.length === 0 && /* @__PURE__ */ e("p", { className: "px-2.5 py-3 text-[12px] text-slate-400", children: "No records match." }),
1393
- L.map((w) => /* @__PURE__ */ e(
1396
+ /* @__PURE__ */ o("div", { className: "min-h-0 flex-1 overflow-y-auto p-1.5", children: [
1397
+ u && /* @__PURE__ */ e("p", { className: "px-2.5 py-3 text-[12px] text-slate-400", children: "Loading…" }),
1398
+ !u && R.length === 0 && /* @__PURE__ */ e("p", { className: "px-2.5 py-3 text-[12px] text-slate-400", children: "No records match." }),
1399
+ R.map((N) => /* @__PURE__ */ e(
1394
1400
  "button",
1395
1401
  {
1396
1402
  type: "button",
1397
- onClick: () => c({ collection: t, itemId: String(w.id) }),
1403
+ onClick: () => c({ collection: t, itemId: String(N.id) }),
1398
1404
  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",
1399
- children: q(w)
1405
+ children: M(N)
1400
1406
  },
1401
- String(w.id)
1407
+ String(N.id)
1402
1408
  ))
1403
1409
  ] })
1404
1410
  ]
@@ -1429,52 +1435,52 @@ function Qt(t, n) {
1429
1435
  const a = Number(n);
1430
1436
  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;
1431
1437
  }
1432
- const Lt = Ta(function({
1438
+ const Rt = Ra(function({
1433
1439
  reportId: n,
1434
1440
  widget: a,
1435
- dateRange: o,
1441
+ dateRange: s,
1436
1442
  entityFilters: c,
1437
1443
  refetchInterval: m,
1438
1444
  filterBar: h = [],
1439
1445
  onDrill: f,
1440
- snapshot: p,
1441
- asOf: L,
1442
- annotations: q,
1443
- onAddAnnotation: w,
1444
- onDeleteAnnotation: U,
1445
- onCrossFilter: u,
1446
- reportUrl: N,
1447
- currentFilters: Y
1446
+ snapshot: u,
1447
+ asOf: R,
1448
+ annotations: M,
1449
+ onAddAnnotation: N,
1450
+ onDeleteAnnotation: W,
1451
+ onCrossFilter: p,
1452
+ reportUrl: S,
1453
+ currentFilters: ee
1448
1454
  }) {
1449
- var ft, Ue, xt, Ye, bt, gt, tt, vt, Ve, at, Je, lt, rt, nt, re, yt, st, it, ot, Le;
1450
- const O = Ke(), [ee, X] = C(""), [ue, pe] = C(0), [H, de] = C(null), [xe, be] = C(!1), [ge, $e] = C(""), [x, Z] = C(""), [te, V] = C(!1), [he, le] = C(!1), [ae, S] = C([]), A = St(null), E = dl(A), [J, ne] = C(!1), [ce, fe] = C(null), [_, P] = C(!1), [me, ve] = C(null), we = ["bar", "line", "donut", "pareto", "area"].includes(a.type) || a.type === "kpi" && !!((ft = a.config) != null && ft.compare || (Ue = a.config) != null && Ue.sparkline), Te = Ct(), [Xe, ye] = C(!1), Ze = async () => {
1455
+ var xt, Ue, bt, Ye, gt, vt, tt, yt, Ve, at, Je, lt, rt, nt, ne, kt, st, it, ot, Re;
1456
+ const F = Ke(), [Z, P] = C(""), [me, J] = C(0), [B, se] = C(null), [xe, be] = C(!1), [ge, $e] = C(""), [x, I] = C(""), [ae, G] = C(!1), [he, re] = C(!1), [le, w] = C([]), T = _t(null), Q = ul(T), [H, ie] = C(!1), [ue, fe] = C(null), [_, z] = C(!1), [pe, ve] = C(null), we = ["bar", "line", "donut", "pareto", "area"].includes(a.type) || a.type === "kpi" && !!((xt = a.config) != null && xt.compare || (Ue = a.config) != null && Ue.sparkline), Te = ht(), [Xe, ye] = C(!1), Ze = async () => {
1451
1457
  ye(!0);
1452
1458
  try {
1453
- const l = await O.request(
1454
- kt(n, a.id, {
1455
- date_range: o,
1459
+ const l = await F.request(
1460
+ Nt(n, a.id, {
1461
+ date_range: s,
1456
1462
  entity_filters: c,
1457
1463
  fresh: 1
1458
1464
  })
1459
1465
  );
1460
1466
  Te.setQueryData(
1461
- ["nivaro-report-widget", n, a.id, o, c],
1467
+ ["nivaro-report-widget", n, a.id, s, c],
1462
1468
  l.data
1463
1469
  );
1464
1470
  } catch {
1465
1471
  }
1466
1472
  ye(!1);
1467
1473
  }, ke = ut(
1468
- () => ({ date_range: o ?? null, entity_filters: c }),
1469
- [o, c]
1470
- ), Fe = Ka({
1474
+ () => ({ date_range: s ?? null, entity_filters: c }),
1475
+ [s, c]
1476
+ ), Fe = Da({
1471
1477
  kind: "report",
1472
1478
  widget: a.id,
1473
1479
  report: n,
1474
1480
  params: ke,
1475
- enabled: E && a.type !== "divider" && a.type !== "query",
1481
+ enabled: Q && a.type !== "divider" && a.type !== "query",
1476
1482
  onData: (l) => Te.setQueryData(
1477
- ["nivaro-report-widget", n, a.id, o, c],
1483
+ ["nivaro-report-widget", n, a.id, s, c],
1478
1484
  l
1479
1485
  ),
1480
1486
  onStale: () => void We()
@@ -1485,102 +1491,102 @@ const Lt = Ta(function({
1485
1491
  refetch: We,
1486
1492
  isFetching: $t
1487
1493
  } = Ne({
1488
- queryKey: ["nivaro-report-widget", n, a.id, o, c],
1489
- queryFn: () => O.request(
1490
- kt(n, a.id, {
1491
- date_range: o,
1494
+ queryKey: ["nivaro-report-widget", n, a.id, s, c],
1495
+ queryFn: () => F.request(
1496
+ Nt(n, a.id, {
1497
+ date_range: s,
1492
1498
  entity_filters: c
1493
1499
  })
1494
1500
  ).then((l) => l.data),
1495
1501
  // Query widgets resolve client-side in QueryWidgetBody — but when a
1496
1502
  // snapshot comparison is active, the server-resolved value (the same
1497
1503
  // number the snapshot stored) is fetched so the delta badge can render.
1498
- enabled: E && a.type !== "divider" && (a.type !== "query" || !!p),
1504
+ enabled: Q && a.type !== "divider" && (a.type !== "query" || !!u),
1499
1505
  staleTime: 6e4,
1500
1506
  // Per-widget auto-refresh (#168) overrides the report-level interval.
1501
- refetchInterval: Da(
1507
+ refetchInterval: Pa(
1502
1508
  Fe,
1503
- Number((xt = a.config) == null ? void 0 : xt.refresh_secs) >= 10 ? Number(a.config.refresh_secs) * 1e3 : m
1509
+ Number((bt = a.config) == null ? void 0 : bt.refresh_secs) >= 10 ? Number(a.config.refresh_secs) * 1e3 : m
1504
1510
  ),
1505
1511
  retry: !1
1506
1512
  }), Be = (((Ye = a.config) == null ? void 0 : Ye.drill_levels) ?? []).filter(
1507
1513
  (l) => typeof l == "string" && l
1508
- ), { data: ht } = Ne({
1509
- queryKey: ["nvr-report-drill", n, a.id, ae, o, c],
1510
- queryFn: () => O.request(
1511
- kt(n, a.id, {
1512
- date_range: o,
1514
+ ), { data: ft } = Ne({
1515
+ queryKey: ["nvr-report-drill", n, a.id, le, s, c],
1516
+ queryFn: () => F.request(
1517
+ Nt(n, a.id, {
1518
+ date_range: s,
1513
1519
  entity_filters: [
1514
1520
  ...c,
1515
- ...ae.map((l) => ({ field: l.field, values: [l.value] }))
1521
+ ...le.map((l) => ({ field: l.field, values: [l.value] }))
1516
1522
  ],
1517
- dimension_override: Be[ae.length - 1]
1523
+ dimension_override: Be[le.length - 1]
1518
1524
  })
1519
1525
  ).then((l) => l.data),
1520
- enabled: ae.length > 0 && Be.length > 0,
1526
+ enabled: le.length > 0 && Be.length > 0,
1521
1527
  staleTime: 6e4,
1522
1528
  retry: !1
1523
- }), R = ae.length > 0 && ht ? ht : Ie, se = (bt = a.config) == null ? void 0 : bt.format, et = {
1529
+ }), O = le.length > 0 && ft ? ft : Ie, oe = (gt = a.config) == null ? void 0 : gt.format, et = {
1524
1530
  gridColumn: `${Math.max(1, (a.x ?? 0) + 1)} / span ${Math.min(12, Math.max(2, a.w || 4))}`,
1525
1531
  gridRow: `span ${Math.max(1, a.h || 3)}`
1526
1532
  };
1527
1533
  if (a.type === "divider")
1528
1534
  return /* @__PURE__ */ e("div", { style: et, className: "self-end border-b border-slate-200 pb-1 dark:border-border", children: /* @__PURE__ */ e("h3", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: a.title }) });
1529
- const Qe = a.type === "query" ? (gt = a.config) == null ? void 0 : gt.query : null, _e = Qe ? {
1535
+ const Qe = a.type === "query" ? (vt = a.config) == null ? void 0 : vt.query : null, _e = Qe ? {
1530
1536
  ...Qe,
1531
1537
  slug: Qe.slug || Qe.query_slug || ""
1532
1538
  } : null;
1533
- let G = null;
1539
+ let X = null;
1534
1540
  if (_e != null && _e.slug)
1535
- G = /* @__PURE__ */ e(
1536
- ml,
1541
+ X = /* @__PURE__ */ e(
1542
+ hl,
1537
1543
  {
1538
1544
  cfg: _e,
1539
- dateRange: o,
1545
+ dateRange: s,
1540
1546
  entityFilters: c,
1541
1547
  refetchInterval: m,
1542
1548
  onDrill: f,
1543
- deferred: !E
1549
+ deferred: !Q
1544
1550
  }
1545
1551
  );
1546
1552
  else if (a.type === "query")
1547
- G = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No query configured." });
1548
- else if (!E && R === void 0)
1549
- G = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-300", children: "Loading…" });
1553
+ X = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No query configured." });
1554
+ else if (!Q && O === void 0)
1555
+ X = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-300", children: "Loading…" });
1550
1556
  else if (Ee)
1551
- G = /* @__PURE__ */ i("div", { className: "flex flex-col gap-2 px-1", children: [
1557
+ X = /* @__PURE__ */ o("div", { className: "flex flex-col gap-2 px-1", children: [
1552
1558
  /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-300", children: "Loading…" }),
1553
1559
  /* @__PURE__ */ e(
1554
- ea,
1560
+ ta,
1555
1561
  {
1556
1562
  pending: !0,
1557
1563
  request: {
1558
1564
  method: "POST",
1559
1565
  url: `/report-studio/${n}/widgets/${a.id}/data`,
1560
- body: { date_range: o, entity_filters: c }
1566
+ body: { date_range: s, entity_filters: c }
1561
1567
  },
1562
1568
  label: a.title || "Report widget",
1563
- queryKey: ["nivaro-report-widget", n, a.id, o, c],
1569
+ queryKey: ["nivaro-report-widget", n, a.id, s, c],
1564
1570
  select: (l) => l == null ? void 0 : l.data
1565
1571
  }
1566
1572
  )
1567
1573
  ] });
1568
1574
  else if (De)
1569
- G = /* @__PURE__ */ e(
1570
- ta,
1575
+ X = /* @__PURE__ */ e(
1576
+ aa,
1571
1577
  {
1572
1578
  className: "px-1",
1573
1579
  message: It(De) ?? Tt(De, "this widget"),
1574
1580
  onRetry: () => void We()
1575
1581
  }
1576
1582
  );
1577
- else if (R)
1583
+ else if (O)
1578
1584
  if (a.type === "queue") {
1579
- const l = R.series ?? [], s = Math.max(...l.map((K) => K.value), 1), g = Math.min(...l.map((K) => K.value), 0), M = Math.max(s - g, 1), $ = l.map(
1580
- (K, ie) => `${ie / Math.max(1, l.length - 1) * 100},${28 - (K.value - g) / M * 26}`
1585
+ const l = O.series ?? [], i = Math.max(...l.map((K) => K.value), 1), g = Math.min(...l.map((K) => K.value), 0), q = Math.max(i - g, 1), $ = l.map(
1586
+ (K, de) => `${de / Math.max(1, l.length - 1) * 100},${28 - (K.value - g) / q * 26}`
1581
1587
  ).join(" ");
1582
- G = /* @__PURE__ */ i("div", { className: "flex min-h-0 flex-1 flex-col justify-center", children: [
1583
- /* @__PURE__ */ e("p", { className: "text-[28px] font-semibold leading-none tracking-tight tabular-nums text-slate-900 dark:text-foreground", children: R.value == null ? "—" : Number(R.value).toLocaleString() }),
1588
+ X = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center", children: [
1589
+ /* @__PURE__ */ e("p", { className: "text-[28px] font-semibold leading-none tracking-tight tabular-nums text-slate-900 dark:text-foreground", children: O.value == null ? "—" : Number(O.value).toLocaleString() }),
1584
1590
  l.length >= 3 && /* @__PURE__ */ e("svg", { viewBox: "0 0 100 30", preserveAspectRatio: "none", className: "mt-1.5 h-7 w-full", children: /* @__PURE__ */ e(
1585
1591
  "polyline",
1586
1592
  {
@@ -1591,43 +1597,43 @@ const Lt = Ta(function({
1591
1597
  vectorEffect: "non-scaling-stroke"
1592
1598
  }
1593
1599
  ) }),
1594
- /* @__PURE__ */ i("p", { className: "mt-0.5 text-[10.5px] text-slate-400", children: [
1600
+ /* @__PURE__ */ o("p", { className: "mt-0.5 text-[10.5px] text-slate-400", children: [
1595
1601
  ((tt = a.config) == null ? void 0 : tt.metric) ?? "total",
1596
1602
  " · daily snapshots"
1597
1603
  ] })
1598
1604
  ] });
1599
1605
  } else if (a.type === "kpi" || a.type === "calc") {
1600
- if (G = /* @__PURE__ */ i("div", { className: "flex items-baseline gap-2", children: [
1606
+ if (X = /* @__PURE__ */ o("div", { className: "flex items-baseline gap-2", children: [
1601
1607
  /* @__PURE__ */ e(
1602
1608
  "p",
1603
1609
  {
1604
- className: Q(
1610
+ className: V(
1605
1611
  "text-[28px] font-semibold leading-none tracking-tight text-slate-900 dark:text-foreground",
1606
1612
  a.collection && "cursor-pointer decoration-dotted underline-offset-4 hover:underline",
1607
1613
  // KPI threshold colors (#211): first matching gte-descending rule wins.
1608
1614
  (() => {
1609
1615
  var g;
1610
1616
  const l = (g = a.config) == null ? void 0 : g.thresholds;
1611
- if (!(l != null && l.length) || R.value == null) return null;
1612
- const s = [...l].filter((M) => Number.isFinite(M.gte)).sort((M, $) => $.gte - M.gte).find((M) => R.value >= M.gte);
1613
- return (s == null ? void 0 : s.color) === "red" ? "!text-red-600 dark:!text-red-400" : (s == null ? void 0 : s.color) === "amber" ? "!text-amber-600 dark:!text-amber-400" : (s == null ? void 0 : s.color) === "green" ? "!text-emerald-600 dark:!text-emerald-400" : null;
1617
+ if (!(l != null && l.length) || O.value == null) return null;
1618
+ const i = [...l].filter((q) => Number.isFinite(q.gte)).sort((q, $) => $.gte - q.gte).find((q) => O.value >= q.gte);
1619
+ return (i == null ? void 0 : i.color) === "red" ? "!text-red-600 dark:!text-red-400" : (i == null ? void 0 : i.color) === "amber" ? "!text-amber-600 dark:!text-amber-400" : (i == null ? void 0 : i.color) === "green" ? "!text-emerald-600 dark:!text-emerald-400" : null;
1614
1620
  })()
1615
1621
  ),
1616
1622
  title: a.collection ? "See the records behind this number" : void 0,
1617
1623
  onClick: () => {
1618
- a.collection && de({
1619
- conditions: Mt(a, c, o),
1624
+ a.collection && se({
1625
+ conditions: Mt(a, c, s),
1620
1626
  title: a.title || a.collection
1621
1627
  });
1622
1628
  },
1623
- children: qe(R.value, se)
1629
+ children: qe(O.value, oe)
1624
1630
  }
1625
1631
  ),
1626
- /* @__PURE__ */ e(zt, { pct: R.change_pct })
1627
- ] }), R.spark && R.spark.length >= 3) {
1628
- const l = R.spark, s = Math.max(...l.map((K) => K.value), 1), g = Math.min(...l.map((K) => K.value), 0), M = Math.max(s - g, 1), $ = l.map((K, ie) => `${ie / (l.length - 1) * 100},${28 - (K.value - g) / M * 26}`).join(" ");
1629
- G = /* @__PURE__ */ i("div", { className: "flex min-h-0 flex-1 flex-col justify-center", children: [
1630
- G,
1632
+ /* @__PURE__ */ e(zt, { pct: O.change_pct })
1633
+ ] }), O.spark && O.spark.length >= 3) {
1634
+ const l = O.spark, i = Math.max(...l.map((K) => K.value), 1), g = Math.min(...l.map((K) => K.value), 0), q = Math.max(i - g, 1), $ = l.map((K, de) => `${de / (l.length - 1) * 100},${28 - (K.value - g) / q * 26}`).join(" ");
1635
+ X = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center", children: [
1636
+ X,
1631
1637
  /* @__PURE__ */ e("svg", { viewBox: "0 0 100 30", preserveAspectRatio: "none", className: "mt-1.5 h-7 w-full", children: /* @__PURE__ */ e(
1632
1638
  "polyline",
1633
1639
  {
@@ -1641,40 +1647,40 @@ const Lt = Ta(function({
1641
1647
  ] });
1642
1648
  }
1643
1649
  } else if (a.type === "kpi_group") {
1644
- const l = R.tiles ?? [];
1645
- G = /* @__PURE__ */ e(
1650
+ const l = O.tiles ?? [];
1651
+ X = /* @__PURE__ */ e(
1646
1652
  "div",
1647
1653
  {
1648
1654
  className: "grid gap-2",
1649
1655
  style: { gridTemplateColumns: `repeat(${Math.max(1, l.length)}, 1fr)` },
1650
- children: l.map((s, g) => /* @__PURE__ */ i(
1656
+ children: l.map((i, g) => /* @__PURE__ */ o(
1651
1657
  "div",
1652
1658
  {
1653
1659
  className: "flex flex-col justify-center rounded-md border border-slate-100 px-3 py-2 dark:border-border/60",
1654
1660
  style: {
1655
- borderTopColor: s.color ?? oe[g % oe.length],
1661
+ borderTopColor: i.color ?? ce[g % ce.length],
1656
1662
  borderTopWidth: 2
1657
1663
  },
1658
1664
  children: [
1659
- /* @__PURE__ */ e("p", { className: "truncate text-[10.5px] uppercase tracking-wide text-slate-400", children: s.label }),
1660
- /* @__PURE__ */ i("div", { className: "flex items-baseline gap-1.5", children: [
1661
- /* @__PURE__ */ e("p", { className: "text-[19px] font-semibold leading-tight text-slate-900 dark:text-foreground", children: qe(s.value, s.format) }),
1662
- /* @__PURE__ */ e(zt, { pct: s.change_pct })
1665
+ /* @__PURE__ */ e("p", { className: "truncate text-[10.5px] uppercase tracking-wide text-slate-400", children: i.label }),
1666
+ /* @__PURE__ */ o("div", { className: "flex items-baseline gap-1.5", children: [
1667
+ /* @__PURE__ */ e("p", { className: "text-[19px] font-semibold leading-tight text-slate-900 dark:text-foreground", children: qe(i.value, i.format) }),
1668
+ /* @__PURE__ */ e(zt, { pct: i.change_pct })
1663
1669
  ] })
1664
1670
  ]
1665
1671
  },
1666
- s.label
1672
+ i.label
1667
1673
  ))
1668
1674
  }
1669
1675
  );
1670
1676
  } else if (a.type === "narrative")
1671
- G = /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap text-[12.5px] leading-relaxed text-slate-700 dark:text-slate-300", children: (R.narrative ?? "").split(/(\*\*[^*]+\*\*)/g).map(
1672
- (l, s) => l.startsWith("**") && l.endsWith("**") ? /* @__PURE__ */ e("strong", { className: "font-semibold text-slate-900 dark:text-foreground", children: l.slice(2, -2) }, s) : /* @__PURE__ */ e("span", { children: l }, s)
1677
+ X = /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap text-[12.5px] leading-relaxed text-slate-700 dark:text-slate-300", children: (O.narrative ?? "").split(/(\*\*[^*]+\*\*)/g).map(
1678
+ (l, i) => l.startsWith("**") && l.endsWith("**") ? /* @__PURE__ */ e("strong", { className: "font-semibold text-slate-900 dark:text-foreground", children: l.slice(2, -2) }, i) : /* @__PURE__ */ e("span", { children: l }, i)
1673
1679
  ) });
1674
1680
  else if (a.type === "heatmap") {
1675
- const l = R.cells ?? [], s = [...new Set(l.map((K) => K.dim))], g = [...new Set(l.map((K) => K.dim2))], M = Math.max(1, ...l.map((K) => K.value)), $ = (K, ie) => l.find((I) => I.dim === K && I.dim2 === ie);
1676
- G = l.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 overflow-auto", children: /* @__PURE__ */ i("table", { className: "w-full text-[10.5px]", children: [
1677
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ i("tr", { children: [
1681
+ const l = O.cells ?? [], i = [...new Set(l.map((K) => K.dim))], g = [...new Set(l.map((K) => K.dim2))], q = Math.max(1, ...l.map((K) => K.value)), $ = (K, de) => l.find((te) => te.dim === K && te.dim2 === de);
1682
+ X = l.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 overflow-auto", children: /* @__PURE__ */ o("table", { className: "w-full text-[10.5px]", children: [
1683
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ o("tr", { children: [
1678
1684
  /* @__PURE__ */ e("th", {}),
1679
1685
  g.map((K) => /* @__PURE__ */ e(
1680
1686
  "th",
@@ -1685,30 +1691,30 @@ const Lt = Ta(function({
1685
1691
  K
1686
1692
  ))
1687
1693
  ] }) }),
1688
- /* @__PURE__ */ e("tbody", { children: s.map((K) => /* @__PURE__ */ i("tr", { children: [
1694
+ /* @__PURE__ */ e("tbody", { children: i.map((K) => /* @__PURE__ */ o("tr", { children: [
1689
1695
  /* @__PURE__ */ e("td", { className: "max-w-[110px] truncate pr-1.5 text-slate-500 dark:text-slate-400", children: K }),
1690
- g.map((ie) => {
1691
- const I = $(K, ie), F = I ? I.value / M : 0;
1696
+ g.map((de) => {
1697
+ const te = $(K, de), A = te ? te.value / q : 0;
1692
1698
  return /* @__PURE__ */ e("td", { className: "p-0.5", children: /* @__PURE__ */ e(
1693
1699
  "div",
1694
1700
  {
1695
- "data-tip": I ? `${K} × ${ie}: ${I.value.toLocaleString()}` : void 0,
1701
+ "data-tip": te ? `${K} × ${de}: ${te.value.toLocaleString()}` : void 0,
1696
1702
  className: "flex h-6 items-center justify-center rounded text-[9.5px] tabular-nums",
1697
1703
  style: {
1698
- backgroundColor: I ? `rgba(0, 165, 204, ${0.08 + F * 0.85})` : "transparent",
1699
- color: F > 0.55 ? "#fff" : void 0,
1700
- border: I ? void 0 : "1px dashed rgba(148,163,184,0.25)"
1704
+ backgroundColor: te ? `rgba(0, 165, 204, ${0.08 + A * 0.85})` : "transparent",
1705
+ color: A > 0.55 ? "#fff" : void 0,
1706
+ border: te ? void 0 : "1px dashed rgba(148,163,184,0.25)"
1701
1707
  },
1702
- children: I ? Ce(Math.round(I.value)) : ""
1708
+ children: te ? Ce(Math.round(te.value)) : ""
1703
1709
  }
1704
- ) }, ie);
1710
+ ) }, de);
1705
1711
  })
1706
1712
  ] }, K)) })
1707
1713
  ] }) });
1708
1714
  } else if (a.type === "ai_insight") {
1709
- const l = R.narrative ?? "";
1710
- G = /* @__PURE__ */ i("div", { className: "flex min-h-0 flex-1 flex-col", children: [
1711
- /* @__PURE__ */ i("div", { className: "mb-1 flex items-center gap-1.5", children: [
1715
+ const l = O.narrative ?? "";
1716
+ X = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
1717
+ /* @__PURE__ */ o("div", { className: "mb-1 flex items-center gap-1.5", children: [
1712
1718
  /* @__PURE__ */ e(Dt, { className: "h-3.5 w-3.5 text-[#00a5cc]" }),
1713
1719
  /* @__PURE__ */ e("span", { className: "text-[10px] uppercase tracking-wide text-slate-400", children: "AI-generated" }),
1714
1720
  /* @__PURE__ */ e(
@@ -1719,58 +1725,58 @@ const Lt = Ta(function({
1719
1725
  disabled: Xe,
1720
1726
  onClick: () => void Ze(),
1721
1727
  className: "ml-auto rounded p-0.5 text-slate-300 hover:text-[#00a5cc] disabled:opacity-50",
1722
- children: /* @__PURE__ */ e(Ft, { className: Q("h-3 w-3", Xe && "animate-spin") })
1728
+ children: /* @__PURE__ */ e(Ft, { className: V("h-3 w-3", Xe && "animate-spin") })
1723
1729
  }
1724
1730
  )
1725
1731
  ] }),
1726
1732
  /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap text-[12.5px] leading-relaxed text-slate-700 dark:text-slate-300", children: Xe ? "Regenerating…" : l })
1727
1733
  ] });
1728
1734
  } else if (a.type === "pivot") {
1729
- const l = R.pivot;
1730
- G = !l || l.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ i("div", { className: "flex min-h-0 flex-1 flex-col", children: [
1731
- /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ i("table", { className: "w-full border-collapse text-[10.5px]", children: [
1732
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ i("tr", { children: [
1735
+ const l = O.pivot;
1736
+ X = !l || l.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
1737
+ /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ o("table", { className: "w-full border-collapse text-[10.5px]", children: [
1738
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ o("tr", { children: [
1733
1739
  /* @__PURE__ */ e("th", { className: "sticky left-0 top-0 z-[2] bg-white dark:bg-card" }),
1734
- l.cols.map((s) => /* @__PURE__ */ e(
1740
+ l.cols.map((i) => /* @__PURE__ */ e(
1735
1741
  "th",
1736
1742
  {
1737
1743
  className: "sticky top-0 z-[1] whitespace-nowrap bg-white px-1.5 pb-1 text-right font-medium text-slate-400 dark:bg-card",
1738
- children: s
1744
+ children: i
1739
1745
  },
1740
- s
1746
+ i
1741
1747
  )),
1742
1748
  /* @__PURE__ */ e("th", { className: "sticky top-0 z-[1] bg-white px-1.5 pb-1 text-right font-semibold text-slate-500 dark:bg-card dark:text-slate-300", children: "Total" })
1743
1749
  ] }) }),
1744
- /* @__PURE__ */ e("tbody", { children: l.rows.map((s) => /* @__PURE__ */ i("tr", { className: "hover:bg-muted", children: [
1745
- /* @__PURE__ */ e("td", { className: "sticky left-0 z-[1] max-w-[150px] truncate bg-white pr-1.5 text-slate-500 dark:bg-card dark:text-slate-400", children: s }),
1750
+ /* @__PURE__ */ e("tbody", { children: l.rows.map((i) => /* @__PURE__ */ o("tr", { className: "hover:bg-muted", children: [
1751
+ /* @__PURE__ */ e("td", { className: "sticky left-0 z-[1] max-w-[150px] truncate bg-white pr-1.5 text-slate-500 dark:bg-card dark:text-slate-400", children: i }),
1746
1752
  l.cols.map((g) => {
1747
1753
  var $;
1748
- const M = ($ = l.cells[s]) == null ? void 0 : $[g];
1754
+ const q = ($ = l.cells[i]) == null ? void 0 : $[g];
1749
1755
  return /* @__PURE__ */ e(
1750
1756
  "td",
1751
1757
  {
1752
1758
  className: "px-1.5 py-0.5 text-right tabular-nums text-slate-700 dark:text-slate-300",
1753
- children: M == null ? "" : qe(M, se)
1759
+ children: q == null ? "" : qe(q, oe)
1754
1760
  },
1755
1761
  g
1756
1762
  );
1757
1763
  }),
1758
- /* @__PURE__ */ e("td", { className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-800 dark:text-slate-200", children: qe(l.row_totals[s] ?? 0, se) })
1759
- ] }, s)) }),
1760
- /* @__PURE__ */ e("tfoot", { children: /* @__PURE__ */ i("tr", { className: "border-t border-slate-200 dark:border-border", children: [
1764
+ /* @__PURE__ */ e("td", { className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-800 dark:text-slate-200", children: qe(l.row_totals[i] ?? 0, oe) })
1765
+ ] }, i)) }),
1766
+ /* @__PURE__ */ e("tfoot", { children: /* @__PURE__ */ o("tr", { className: "border-t border-slate-200 dark:border-border", children: [
1761
1767
  /* @__PURE__ */ e("td", { className: "sticky left-0 z-[1] bg-white pr-1.5 font-semibold text-slate-600 dark:bg-card dark:text-slate-300", children: "Total" }),
1762
- l.cols.map((s) => /* @__PURE__ */ e(
1768
+ l.cols.map((i) => /* @__PURE__ */ e(
1763
1769
  "td",
1764
1770
  {
1765
1771
  className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-800 dark:text-slate-200",
1766
- children: qe(l.col_totals[s] ?? 0, se)
1772
+ children: qe(l.col_totals[i] ?? 0, oe)
1767
1773
  },
1768
- s
1774
+ i
1769
1775
  )),
1770
- /* @__PURE__ */ e("td", { className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-900 dark:text-foreground", children: qe(l.grand_total, se) })
1776
+ /* @__PURE__ */ e("td", { className: "px-1.5 py-0.5 text-right font-semibold tabular-nums text-slate-900 dark:text-foreground", children: qe(l.grand_total, oe) })
1771
1777
  ] }) })
1772
1778
  ] }) }),
1773
- (l.truncated_rows > 0 || l.truncated_cols > 0) && /* @__PURE__ */ i("p", { className: "mt-1 shrink-0 px-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
1779
+ (l.truncated_rows > 0 || l.truncated_cols > 0) && /* @__PURE__ */ o("p", { className: "mt-1 shrink-0 px-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
1774
1780
  "Showing the ",
1775
1781
  l.rows.length,
1776
1782
  "×",
@@ -1786,34 +1792,34 @@ const Lt = Ta(function({
1786
1792
  ] })
1787
1793
  ] });
1788
1794
  } else if (a.type === "waterfall") {
1789
- const l = R.waterfall;
1790
- G = l ? (() => {
1791
- const s = [];
1792
- s.push({ label: "Previous", from: 0, to: l.start, kind: "total" });
1795
+ const l = O.waterfall;
1796
+ X = l ? (() => {
1797
+ const i = [];
1798
+ i.push({ label: "Previous", from: 0, to: l.start, kind: "total" });
1793
1799
  let g = l.start;
1794
1800
  for (const $ of l.steps)
1795
- s.push({
1801
+ i.push({
1796
1802
  label: $.dim,
1797
1803
  from: g,
1798
1804
  to: g + $.delta,
1799
1805
  kind: $.delta >= 0 ? "up" : "down"
1800
1806
  }), g += $.delta;
1801
- s.push({ label: "Current", from: 0, to: l.end, kind: "total" });
1802
- const M = Math.max(1, ...s.map(($) => Math.max($.from, $.to)));
1803
- return /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 items-end gap-1 overflow-x-auto px-1 pb-4", children: s.map(($, K) => {
1804
- const ie = Math.max($.from, $.to) / M * 100, I = Math.abs($.to - $.from) / M * 100;
1805
- return /* @__PURE__ */ i(
1807
+ i.push({ label: "Current", from: 0, to: l.end, kind: "total" });
1808
+ const q = Math.max(1, ...i.map(($) => Math.max($.from, $.to)));
1809
+ return /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 items-end gap-1 overflow-x-auto px-1 pb-4", children: i.map(($, K) => {
1810
+ const de = Math.max($.from, $.to) / q * 100, te = Math.abs($.to - $.from) / q * 100;
1811
+ return /* @__PURE__ */ o(
1806
1812
  "div",
1807
1813
  {
1808
1814
  className: "relative flex h-full min-w-[46px] flex-1 flex-col justify-end",
1809
1815
  children: [
1810
- /* @__PURE__ */ e("div", { style: { height: `${Math.max(ie, 0.5)}%` }, className: "relative w-full", children: /* @__PURE__ */ e(
1816
+ /* @__PURE__ */ e("div", { style: { height: `${Math.max(de, 0.5)}%` }, className: "relative w-full", children: /* @__PURE__ */ e(
1811
1817
  "div",
1812
1818
  {
1813
1819
  "data-tip": `${$.label}: ${($.to - $.from).toLocaleString()}`,
1814
1820
  className: "absolute inset-x-0 top-0 rounded-sm",
1815
1821
  style: {
1816
- height: `${Math.max(I / Math.max(ie, 1e-3) * 100, 2)}%`,
1822
+ height: `${Math.max(te / Math.max(de, 1e-3) * 100, 2)}%`,
1817
1823
  backgroundColor: $.kind === "total" ? "#172940" : $.kind === "up" ? "#10b981" : "#ef4444"
1818
1824
  }
1819
1825
  }
@@ -1826,21 +1832,21 @@ const Lt = Ta(function({
1826
1832
  }) });
1827
1833
  })() : /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." });
1828
1834
  } else if (a.type === "stats") {
1829
- const l = R.rows ?? [];
1830
- G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ e("div", { className: "grid min-h-0 flex-1 grid-cols-2 content-start gap-x-4 gap-y-1.5 overflow-auto px-1", children: l.map((s) => /* @__PURE__ */ i(
1835
+ const l = O.rows ?? [];
1836
+ X = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : /* @__PURE__ */ e("div", { className: "grid min-h-0 flex-1 grid-cols-2 content-start gap-x-4 gap-y-1.5 overflow-auto px-1", children: l.map((i) => /* @__PURE__ */ o(
1831
1837
  "div",
1832
1838
  {
1833
1839
  className: "flex items-baseline justify-between border-b border-slate-100 pb-1 dark:border-border/50",
1834
1840
  children: [
1835
- /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-500", children: s.stat }),
1836
- /* @__PURE__ */ e("span", { className: "text-[13px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: s.value == null ? "—" : qe(s.value, se) })
1841
+ /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-500", children: i.stat }),
1842
+ /* @__PURE__ */ e("span", { className: "text-[13px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: i.value == null ? "—" : qe(i.value, oe) })
1837
1843
  ]
1838
1844
  },
1839
- s.stat
1845
+ i.stat
1840
1846
  )) });
1841
1847
  } else if (a.type === "hot_records") {
1842
- const l = R.rows ?? [], s = Math.max(1, ...l.map((g) => g.views));
1843
- G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No views recorded in the window." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 space-y-1 overflow-auto px-1", children: l.map((g) => /* @__PURE__ */ i(
1848
+ const l = O.rows ?? [], i = Math.max(1, ...l.map((g) => g.views));
1849
+ X = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No views recorded in the window." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 space-y-1 overflow-auto px-1", children: l.map((g) => /* @__PURE__ */ o(
1844
1850
  "button",
1845
1851
  {
1846
1852
  type: "button",
@@ -1852,7 +1858,7 @@ const Lt = Ta(function({
1852
1858
  "span",
1853
1859
  {
1854
1860
  className: "absolute inset-y-0 left-0 rounded-full bg-[#00a5cc]",
1855
- style: { width: `${g.views / s * 100}%` }
1861
+ style: { width: `${g.views / i * 100}%` }
1856
1862
  }
1857
1863
  ) }),
1858
1864
  /* @__PURE__ */ e("span", { className: "w-8 text-right text-[11px] tabular-nums text-slate-400", children: g.views })
@@ -1861,23 +1867,23 @@ const Lt = Ta(function({
1861
1867
  g.id
1862
1868
  )) });
1863
1869
  } else if (a.type === "scatter") {
1864
- const l = R.rows ?? [];
1865
- G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : (() => {
1866
- const s = l.length, g = l.reduce((b, v) => b + v.x, 0), M = l.reduce((b, v) => b + v.y, 0), $ = l.reduce((b, v) => b + v.x * v.x, 0), K = l.reduce((b, v) => b + v.x * v.y, 0), ie = s * $ - g * g, I = ie !== 0 ? (s * K - g * M) / ie : 0, F = s > 0 ? (M - I * g) / s : 0, z = l.map((b) => b.x), W = Math.min(...z), D = Math.max(...z), r = [
1867
- { x: W, y: F + I * W },
1868
- { x: D, y: F + I * D }
1870
+ const l = O.rows ?? [];
1871
+ X = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." }) : (() => {
1872
+ const i = l.length, g = l.reduce((b, v) => b + v.x, 0), q = l.reduce((b, v) => b + v.y, 0), $ = l.reduce((b, v) => b + v.x * v.x, 0), K = l.reduce((b, v) => b + v.x * v.y, 0), de = i * $ - g * g, te = de !== 0 ? (i * K - g * q) / de : 0, A = i > 0 ? (q - te * g) / i : 0, j = l.map((b) => b.x), U = Math.min(...j), D = Math.max(...j), r = [
1873
+ { x: U, y: A + te * U },
1874
+ { x: D, y: A + te * D }
1869
1875
  ];
1870
- return /* @__PURE__ */ e("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ e(Re, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({
1876
+ return /* @__PURE__ */ e("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ e(Le, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({
1871
1877
  ComposedChart: b,
1872
1878
  Line: v,
1873
1879
  ResponsiveContainer: d,
1874
1880
  Scatter: y,
1875
1881
  Tooltip: k,
1876
- XAxis: j,
1877
- YAxis: B
1878
- }) => /* @__PURE__ */ e(d, { width: "100%", height: "100%", children: /* @__PURE__ */ i(b, { data: l, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
1882
+ XAxis: E,
1883
+ YAxis: Y
1884
+ }) => /* @__PURE__ */ e(d, { width: "100%", height: "100%", children: /* @__PURE__ */ o(b, { data: l, margin: { top: 6, right: 8, left: -6, bottom: 0 }, children: [
1879
1885
  /* @__PURE__ */ e(
1880
- j,
1886
+ E,
1881
1887
  {
1882
1888
  dataKey: "x",
1883
1889
  type: "number",
@@ -1886,7 +1892,7 @@ const Lt = Ta(function({
1886
1892
  domain: ["dataMin", "dataMax"]
1887
1893
  }
1888
1894
  ),
1889
- /* @__PURE__ */ e(B, { tick: { fontSize: 10 }, tickFormatter: Ce }),
1895
+ /* @__PURE__ */ e(Y, { tick: { fontSize: 10 }, tickFormatter: Ce }),
1890
1896
  /* @__PURE__ */ e(
1891
1897
  k,
1892
1898
  {
@@ -1914,10 +1920,10 @@ const Lt = Ta(function({
1914
1920
  ] }) }) }) });
1915
1921
  })();
1916
1922
  } else if (a.type === "pareto") {
1917
- const l = R.series ?? [];
1918
- G = l.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", children: /* @__PURE__ */ e(Re, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Bar: s, ComposedChart: g, Line: M, ResponsiveContainer: $, Tooltip: K, XAxis: ie, YAxis: I }) => /* @__PURE__ */ e($, { width: "100%", height: "100%", children: /* @__PURE__ */ i(g, { data: l, margin: { top: 6, right: 4, left: -10, bottom: 0 }, children: [
1923
+ const l = O.series ?? [];
1924
+ X = l.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", children: /* @__PURE__ */ e(Le, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Bar: i, ComposedChart: g, Line: q, ResponsiveContainer: $, Tooltip: K, XAxis: de, YAxis: te }) => /* @__PURE__ */ e($, { width: "100%", height: "100%", children: /* @__PURE__ */ o(g, { data: l, margin: { top: 6, right: 4, left: -10, bottom: 0 }, children: [
1919
1925
  /* @__PURE__ */ e(
1920
- ie,
1926
+ de,
1921
1927
  {
1922
1928
  dataKey: "dim",
1923
1929
  tick: { fontSize: 10 },
@@ -1927,15 +1933,15 @@ const Lt = Ta(function({
1927
1933
  height: 42
1928
1934
  }
1929
1935
  ),
1930
- /* @__PURE__ */ e(I, { yAxisId: "v", tick: { fontSize: 10 }, tickFormatter: Ce }),
1936
+ /* @__PURE__ */ e(te, { yAxisId: "v", tick: { fontSize: 10 }, tickFormatter: Ce }),
1931
1937
  /* @__PURE__ */ e(
1932
- I,
1938
+ te,
1933
1939
  {
1934
1940
  yAxisId: "pct",
1935
1941
  orientation: "right",
1936
1942
  domain: [0, 100],
1937
1943
  tick: { fontSize: 10 },
1938
- tickFormatter: (F) => `${F}%`
1944
+ tickFormatter: (A) => `${A}%`
1939
1945
  }
1940
1946
  ),
1941
1947
  /* @__PURE__ */ e(
@@ -1951,7 +1957,7 @@ const Lt = Ta(function({
1951
1957
  }
1952
1958
  ),
1953
1959
  /* @__PURE__ */ e(
1954
- s,
1960
+ i,
1955
1961
  {
1956
1962
  yAxisId: "v",
1957
1963
  dataKey: "value",
@@ -1961,7 +1967,7 @@ const Lt = Ta(function({
1961
1967
  }
1962
1968
  ),
1963
1969
  /* @__PURE__ */ e(
1964
- M,
1970
+ q,
1965
1971
  {
1966
1972
  yAxisId: "pct",
1967
1973
  dataKey: "cum_pct",
@@ -1973,81 +1979,81 @@ const Lt = Ta(function({
1973
1979
  )
1974
1980
  ] }) }) }) });
1975
1981
  } else if (a.type === "metric")
1976
- G = /* @__PURE__ */ i("div", { className: "flex min-h-0 flex-1 flex-col justify-center px-1", children: [
1977
- /* @__PURE__ */ e("p", { className: "text-[26px] font-bold tabular-nums text-slate-900 dark:text-slate-50", children: R.value == null ? "—" : qe(R.value, se) }),
1978
- /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: String(((vt = a.config) == null ? void 0 : vt.metric_key) ?? "") })
1982
+ X = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center px-1", children: [
1983
+ /* @__PURE__ */ e("p", { className: "text-[26px] font-bold tabular-nums text-slate-900 dark:text-slate-50", children: O.value == null ? "—" : qe(O.value, oe) }),
1984
+ /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: String(((yt = a.config) == null ? void 0 : yt.metric_key) ?? "") })
1979
1985
  ] });
1980
1986
  else if (a.type === "movers") {
1981
- const l = R.rows ?? [];
1982
- G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No movement in this window." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 space-y-0.5 overflow-y-auto", children: l.map((s) => /* @__PURE__ */ i("div", { className: "flex items-center gap-2 text-[11.5px]", children: [
1983
- /* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: s.dim }),
1984
- /* @__PURE__ */ i("span", { className: "tabular-nums text-slate-400", children: [
1985
- s.previous.toLocaleString(),
1987
+ const l = O.rows ?? [];
1988
+ X = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No movement in this window." }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 space-y-0.5 overflow-y-auto", children: l.map((i) => /* @__PURE__ */ o("div", { className: "flex items-center gap-2 text-[11.5px]", children: [
1989
+ /* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: i.dim }),
1990
+ /* @__PURE__ */ o("span", { className: "tabular-nums text-slate-400", children: [
1991
+ i.previous.toLocaleString(),
1986
1992
  " → ",
1987
- s.current.toLocaleString()
1993
+ i.current.toLocaleString()
1988
1994
  ] }),
1989
- /* @__PURE__ */ i(
1995
+ /* @__PURE__ */ o(
1990
1996
  "span",
1991
1997
  {
1992
- className: Q(
1998
+ className: V(
1993
1999
  "w-[74px] shrink-0 text-right font-semibold tabular-nums",
1994
- s.delta > 0 ? "text-emerald-600 dark:text-emerald-400" : "text-red-500"
2000
+ i.delta > 0 ? "text-emerald-600 dark:text-emerald-400" : "text-red-500"
1995
2001
  ),
1996
2002
  children: [
1997
- s.delta > 0 ? "+" : "",
1998
- s.delta.toLocaleString(),
1999
- s.delta_pct != null && /* @__PURE__ */ i("span", { className: "ml-1 text-[10px] font-normal text-slate-400", children: [
2000
- s.delta_pct > 0 ? "+" : "",
2001
- s.delta_pct.toFixed(0),
2003
+ i.delta > 0 ? "+" : "",
2004
+ i.delta.toLocaleString(),
2005
+ i.delta_pct != null && /* @__PURE__ */ o("span", { className: "ml-1 text-[10px] font-normal text-slate-400", children: [
2006
+ i.delta_pct > 0 ? "+" : "",
2007
+ i.delta_pct.toFixed(0),
2002
2008
  "%"
2003
2009
  ] })
2004
2010
  ]
2005
2011
  }
2006
2012
  )
2007
- ] }, s.dim)) });
2013
+ ] }, i.dim)) });
2008
2014
  } else if (a.type === "table") {
2009
- const l = R.rows ?? [], s = (Ve = a.config) != null && Ve.columns && a.config.columns.length > 0 ? a.config.columns.map((d) => typeof d == "string" ? { field: d } : d) : l[0] ? Object.keys(l[0]).filter((d) => d !== "id").map((d) => ({ field: d })) : [], g = s.map((d) => d.field), M = (d) => s.find((y) => y.field === d), $ = ((at = a.config) == null ? void 0 : at.format_rules) ?? [], K = (d) => {
2015
+ const l = O.rows ?? [], i = (Ve = a.config) != null && Ve.columns && a.config.columns.length > 0 ? a.config.columns.map((d) => typeof d == "string" ? { field: d } : d) : l[0] ? Object.keys(l[0]).filter((d) => d !== "id").map((d) => ({ field: d })) : [], g = i.map((d) => d.field), q = (d) => i.find((y) => y.field === d), $ = ((at = a.config) == null ? void 0 : at.format_rules) ?? [], K = (d) => {
2010
2016
  var y;
2011
2017
  for (const k of $)
2012
2018
  if ((k.scope ?? "cell") === "row" && Qt(k, d[k.field]))
2013
2019
  return ((y = Bt[k.color]) == null ? void 0 : y.row) ?? null;
2014
2020
  return null;
2015
- }, ie = (d, y) => {
2021
+ }, de = (d, y) => {
2016
2022
  var k;
2017
- for (const j of $)
2018
- if ((j.scope ?? "cell") === "cell" && j.field === y && Qt(j, d[y]))
2019
- return ((k = Bt[j.color]) == null ? void 0 : k.cell) ?? null;
2023
+ for (const E of $)
2024
+ if ((E.scope ?? "cell") === "cell" && E.field === y && Qt(E, d[y]))
2025
+ return ((k = Bt[E.color]) == null ? void 0 : k.cell) ?? null;
2020
2026
  return null;
2021
- }, I = ee.trim().toLowerCase(), F = a.config, z = F != null && F.suppress_zero ? l.filter(
2027
+ }, te = Z.trim().toLowerCase(), A = a.config, j = A != null && A.suppress_zero ? l.filter(
2022
2028
  (d) => g.some((y) => {
2023
2029
  const k = Number(d[y]);
2024
2030
  return Number.isFinite(k) && k !== 0;
2025
2031
  })
2026
- ) : l, W = I ? z.filter(
2032
+ ) : l, U = te ? j.filter(
2027
2033
  (d) => Object.values(d).some(
2028
- (y) => String(y ?? "").toLowerCase().includes(I)
2034
+ (y) => String(y ?? "").toLowerCase().includes(te)
2029
2035
  )
2030
- ) : z, D = 12, r = Math.max(1, Math.ceil(W.length / D)), b = Math.min(ue, r - 1), v = W.length > D ? W.slice(b * D, b * D + D) : W;
2031
- G = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No rows." }) : /* @__PURE__ */ i("div", { className: "flex min-h-0 flex-1 flex-col", children: [
2032
- l.length > D && /* @__PURE__ */ i("div", { className: "mb-1 flex items-center gap-2", children: [
2036
+ ) : j, D = 12, r = Math.max(1, Math.ceil(U.length / D)), b = Math.min(me, r - 1), v = U.length > D ? U.slice(b * D, b * D + D) : U;
2037
+ X = l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No rows." }) : /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col", children: [
2038
+ l.length > D && /* @__PURE__ */ o("div", { className: "mb-1 flex items-center gap-2", children: [
2033
2039
  /* @__PURE__ */ e(
2034
2040
  "input",
2035
2041
  {
2036
- value: ee,
2042
+ value: Z,
2037
2043
  onChange: (d) => {
2038
- X(d.target.value), pe(0);
2044
+ P(d.target.value), J(0);
2039
2045
  },
2040
2046
  placeholder: "Search rows…",
2041
2047
  className: "h-6 w-40 rounded border border-slate-200 bg-white px-1.5 text-[11px] dark:border-border dark:bg-card dark:text-slate-200"
2042
2048
  }
2043
2049
  ),
2044
- r > 1 && /* @__PURE__ */ i("span", { className: "ml-auto flex items-center gap-1 text-[10.5px] text-slate-400", children: [
2050
+ r > 1 && /* @__PURE__ */ o("span", { className: "ml-auto flex items-center gap-1 text-[10.5px] text-slate-400", children: [
2045
2051
  /* @__PURE__ */ e(
2046
2052
  "button",
2047
2053
  {
2048
2054
  type: "button",
2049
2055
  disabled: b <= 0,
2050
- onClick: () => pe(b - 1),
2056
+ onClick: () => J(b - 1),
2051
2057
  className: "rounded px-1 disabled:opacity-30",
2052
2058
  children: "←"
2053
2059
  }
@@ -2060,21 +2066,21 @@ const Lt = Ta(function({
2060
2066
  {
2061
2067
  type: "button",
2062
2068
  disabled: b >= r - 1,
2063
- onClick: () => pe(b + 1),
2069
+ onClick: () => J(b + 1),
2064
2070
  className: "rounded px-1 disabled:opacity-30",
2065
2071
  children: "→"
2066
2072
  }
2067
2073
  )
2068
2074
  ] })
2069
2075
  ] }),
2070
- /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ i("table", { className: "w-full text-[11.5px]", children: [
2076
+ /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ o("table", { className: "w-full text-[11.5px]", children: [
2071
2077
  /* @__PURE__ */ e("thead", { className: "sticky top-0 bg-white dark:bg-card", children: /* @__PURE__ */ e("tr", { children: g.map((d) => {
2072
2078
  var y;
2073
2079
  return /* @__PURE__ */ e(
2074
2080
  "th",
2075
2081
  {
2076
2082
  className: "border-b border-slate-100 px-1.5 py-1 text-left font-medium text-slate-400 dark:border-border",
2077
- children: ((y = M(d)) == null ? void 0 : y.label) ?? d
2083
+ children: ((y = q(d)) == null ? void 0 : y.label) ?? d
2078
2084
  },
2079
2085
  d
2080
2086
  );
@@ -2082,7 +2088,7 @@ const Lt = Ta(function({
2082
2088
  /* @__PURE__ */ e("tbody", { children: v.map((d) => /* @__PURE__ */ e(
2083
2089
  "tr",
2084
2090
  {
2085
- className: Q(
2091
+ className: V(
2086
2092
  K(d),
2087
2093
  a.collection && d.id != null && "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/60"
2088
2094
  ),
@@ -2090,16 +2096,16 @@ const Lt = Ta(function({
2090
2096
  a.collection && d.id != null && (f == null || f({ collection: a.collection, itemId: String(d.id) }));
2091
2097
  },
2092
2098
  children: g.map((y) => {
2093
- var k, j, B, T;
2099
+ var k, E, Y, L;
2094
2100
  return /* @__PURE__ */ e(
2095
2101
  "td",
2096
2102
  {
2097
- className: Q(
2103
+ className: V(
2098
2104
  "max-w-[180px] truncate border-b border-slate-50 px-1.5 py-1 text-slate-700 dark:border-border/40 dark:text-slate-300",
2099
- (typeof d[y] == "number" || ze.has(((k = M(y)) == null ? void 0 : k.format) ?? "")) && "text-right tabular-nums",
2100
- ie(d, y)
2105
+ (typeof d[y] == "number" || ze.has(((k = q(y)) == null ? void 0 : k.format) ?? "")) && "text-right tabular-nums",
2106
+ de(d, y)
2101
2107
  ),
2102
- children: (j = M(y)) != null && j.format ? je(d[y], (B = M(y)) == null ? void 0 : B.format, (T = M(y)) == null ? void 0 : T.decimals) : String(d[y] ?? "")
2108
+ children: (E = q(y)) != null && E.format ? je(d[y], (Y = q(y)) == null ? void 0 : Y.format, (L = q(y)) == null ? void 0 : L.decimals) : String(d[y] ?? "")
2103
2109
  },
2104
2110
  y
2105
2111
  );
@@ -2107,17 +2113,17 @@ const Lt = Ta(function({
2107
2113
  },
2108
2114
  String(d.id)
2109
2115
  )) }),
2110
- (F == null ? void 0 : F.grand_total) && W.length > 1 && /* @__PURE__ */ e("tfoot", { children: /* @__PURE__ */ e("tr", { className: "border-t border-slate-200 font-semibold dark:border-border", children: g.map((d, y) => {
2111
- var T, Se, Pe;
2112
- const k = W.map((dt) => Number(dt[d])).filter((dt) => Number.isFinite(dt)), j = k.length > W.length / 2, B = k.reduce((dt, ma) => dt + ma, 0);
2116
+ (A == null ? void 0 : A.grand_total) && U.length > 1 && /* @__PURE__ */ e("tfoot", { children: /* @__PURE__ */ e("tr", { className: "border-t border-slate-200 font-semibold dark:border-border", children: g.map((d, y) => {
2117
+ var L, Se, Pe;
2118
+ const k = U.map((dt) => Number(dt[d])).filter((dt) => Number.isFinite(dt)), E = k.length > U.length / 2, Y = k.reduce((dt, ua) => dt + ua, 0);
2113
2119
  return /* @__PURE__ */ e(
2114
2120
  "td",
2115
2121
  {
2116
- className: Q(
2122
+ className: V(
2117
2123
  "px-1.5 py-1 text-slate-800 dark:text-slate-100",
2118
- j && "text-right tabular-nums"
2124
+ E && "text-right tabular-nums"
2119
2125
  ),
2120
- children: y === 0 && !j ? "Total" : j ? (T = M(d)) != null && T.format ? je(B, (Se = M(d)) == null ? void 0 : Se.format, (Pe = M(d)) == null ? void 0 : Pe.decimals) : B.toLocaleString() : ""
2126
+ children: y === 0 && !E ? "Total" : E ? (L = q(d)) != null && L.format ? je(Y, (Se = q(d)) == null ? void 0 : Se.format, (Pe = q(d)) == null ? void 0 : Pe.decimals) : Y.toLocaleString() : ""
2121
2127
  },
2122
2128
  d
2123
2129
  );
@@ -2125,38 +2131,38 @@ const Lt = Ta(function({
2125
2131
  ] }) })
2126
2132
  ] });
2127
2133
  } else {
2128
- let l = R.series ?? [];
2129
- const s = !!((lt = (Je = a.config) == null ? void 0 : Je.dimension) != null && lt.bucket), g = Number((rt = a.config) == null ? void 0 : rt.rolling_avg) || 0;
2130
- if (g >= 2 && s && !te && l.length >= g && (l = l.map((F, z) => {
2131
- if (z < g - 1) return F;
2132
- const W = l.slice(z - g + 1, z + 1);
2133
- return { ...F, ma: W.reduce((D, r) => D + r.value, 0) / g };
2134
- })), te && s) {
2135
- let F = 0, z = 0, W = 0;
2136
- l = l.map((D) => (F += D.value, z += D.prev ?? 0, W += D.value2 ?? 0, {
2134
+ let l = O.series ?? [];
2135
+ const i = !!((lt = (Je = a.config) == null ? void 0 : Je.dimension) != null && lt.bucket), g = Number((rt = a.config) == null ? void 0 : rt.rolling_avg) || 0;
2136
+ if (g >= 2 && i && !ae && l.length >= g && (l = l.map((A, j) => {
2137
+ if (j < g - 1) return A;
2138
+ const U = l.slice(j - g + 1, j + 1);
2139
+ return { ...A, ma: U.reduce((D, r) => D + r.value, 0) / g };
2140
+ })), ae && i) {
2141
+ let A = 0, j = 0, U = 0;
2142
+ l = l.map((D) => (A += D.value, j += D.prev ?? 0, U += D.value2 ?? 0, {
2137
2143
  ...D,
2138
- value: F,
2139
- ...D.prev != null ? { prev: z } : {},
2140
- ...D.value2 != null ? { value2: W } : {}
2144
+ value: A,
2145
+ ...D.prev != null ? { prev: j } : {},
2146
+ ...D.value2 != null ? { value2: U } : {}
2141
2147
  }));
2142
2148
  }
2143
- const M = l.some((F) => F.value2 != null), $ = ((re = (nt = a.config) == null ? void 0 : nt.metric2) == null ? void 0 : re.label) ?? "secondary", K = l.some((F) => F.band != null), ie = (() => {
2144
- if (!s || te || l.length < 8) return /* @__PURE__ */ new Set();
2145
- const F = l.map((D) => D.value), z = F.reduce((D, r) => D + r, 0) / F.length, W = Math.sqrt(F.reduce((D, r) => D + (r - z) ** 2, 0) / F.length);
2146
- return W === 0 ? /* @__PURE__ */ new Set() : new Set(
2147
- l.filter((D) => Math.abs(D.value - z) > 2 * W).map((D) => D.dim)
2149
+ const q = l.some((A) => A.value2 != null), $ = ((ne = (nt = a.config) == null ? void 0 : nt.metric2) == null ? void 0 : ne.label) ?? "secondary", K = l.some((A) => A.band != null), de = (() => {
2150
+ if (!i || ae || l.length < 8) return /* @__PURE__ */ new Set();
2151
+ const A = l.map((D) => D.value), j = A.reduce((D, r) => D + r, 0) / A.length, U = Math.sqrt(A.reduce((D, r) => D + (r - j) ** 2, 0) / A.length);
2152
+ return U === 0 ? /* @__PURE__ */ new Set() : new Set(
2153
+ l.filter((D) => Math.abs(D.value - j) > 2 * U).map((D) => D.dim)
2148
2154
  );
2149
- })(), I = (q ?? []).filter(
2150
- (F) => F.anchor_date && l.some((z) => z.dim === F.anchor_date)
2155
+ })(), te = (M ?? []).filter(
2156
+ (A) => A.anchor_date && l.some((j) => j.dim === A.anchor_date)
2151
2157
  );
2152
- if (l.length === 0) G = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." });
2158
+ if (l.length === 0) X = /* @__PURE__ */ e("p", { className: "px-1 text-[12px] text-slate-400", children: "No data." });
2153
2159
  else if (a.type === "donut") {
2154
- const F = l.reduce((z, W) => z + W.value, 0);
2155
- G = /* @__PURE__ */ i("div", { className: "flex min-h-0 flex-1 items-stretch gap-3", children: [
2156
- /* @__PURE__ */ i("div", { className: "relative min-h-[110px] min-w-0 flex-1", children: [
2157
- /* @__PURE__ */ e(Re, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Cell: z, Pie: W, PieChart: D, ResponsiveContainer: r, Tooltip: b }) => /* @__PURE__ */ e(r, { width: "100%", height: "100%", children: /* @__PURE__ */ i(D, { children: [
2160
+ const A = l.reduce((j, U) => j + U.value, 0);
2161
+ X = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 items-stretch gap-3", children: [
2162
+ /* @__PURE__ */ o("div", { className: "relative min-h-[110px] min-w-0 flex-1", children: [
2163
+ /* @__PURE__ */ e(Le, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({ Cell: j, Pie: U, PieChart: D, ResponsiveContainer: r, Tooltip: b }) => /* @__PURE__ */ e(r, { width: "100%", height: "100%", children: /* @__PURE__ */ o(D, { children: [
2158
2164
  /* @__PURE__ */ e(
2159
- W,
2165
+ U,
2160
2166
  {
2161
2167
  data: l,
2162
2168
  dataKey: "value",
@@ -2167,26 +2173,26 @@ const Lt = Ta(function({
2167
2173
  strokeWidth: 0,
2168
2174
  className: a.collection ? "cursor-pointer" : void 0,
2169
2175
  onClick: (v) => {
2170
- var k, j, B, T;
2176
+ var k, E, Y, L;
2171
2177
  if (!a.collection) return;
2172
2178
  const d = v == null ? void 0 : v.payload;
2173
2179
  if (d != null && d.other) return;
2174
- if (Be.length > ae.length) {
2175
- const Se = ae.length === 0 ? (j = (k = a.config) == null ? void 0 : k.dimension) == null ? void 0 : j.field : Be[ae.length - 1];
2180
+ if (Be.length > le.length) {
2181
+ const Se = le.length === 0 ? (E = (k = a.config) == null ? void 0 : k.dimension) == null ? void 0 : E.field : Be[le.length - 1];
2176
2182
  if (Se) {
2177
- S((Pe) => [
2183
+ w((Pe) => [
2178
2184
  ...Pe,
2179
2185
  { field: Se, value: String((d == null ? void 0 : d.raw) ?? (d == null ? void 0 : d.dim) ?? "") }
2180
2186
  ]);
2181
2187
  return;
2182
2188
  }
2183
2189
  }
2184
- const y = (T = (B = a.config) == null ? void 0 : B.dimension) == null ? void 0 : T.field;
2185
- de({
2190
+ const y = (L = (Y = a.config) == null ? void 0 : Y.dimension) == null ? void 0 : L.field;
2191
+ se({
2186
2192
  conditions: Mt(
2187
2193
  a,
2188
2194
  c,
2189
- o,
2195
+ s,
2190
2196
  (d == null ? void 0 : d.raw) ?? (d == null ? void 0 : d.dim)
2191
2197
  ),
2192
2198
  title: `${a.title || a.collection} — ${(d == null ? void 0 : d.dim) ?? ""}`,
@@ -2196,9 +2202,9 @@ const Lt = Ta(function({
2196
2202
  });
2197
2203
  },
2198
2204
  children: l.map((v, d) => /* @__PURE__ */ e(
2199
- z,
2205
+ j,
2200
2206
  {
2201
- fill: v.other ? "#94a3b8" : oe[d % oe.length]
2207
+ fill: v.other ? "#94a3b8" : ce[d % ce.length]
2202
2208
  },
2203
2209
  v.dim
2204
2210
  ))
@@ -2219,28 +2225,28 @@ const Lt = Ta(function({
2219
2225
  }
2220
2226
  )
2221
2227
  ] }) }) }),
2222
- /* @__PURE__ */ i("div", { className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center", children: [
2223
- /* @__PURE__ */ e("span", { className: "text-[17px] font-semibold leading-none text-slate-900 dark:text-foreground", children: F.toLocaleString() }),
2228
+ /* @__PURE__ */ o("div", { className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center", children: [
2229
+ /* @__PURE__ */ e("span", { className: "text-[17px] font-semibold leading-none text-slate-900 dark:text-foreground", children: A.toLocaleString() }),
2224
2230
  /* @__PURE__ */ e("span", { className: "text-[9.5px] text-slate-400", children: "total" })
2225
2231
  ] })
2226
2232
  ] }),
2227
- /* @__PURE__ */ e("div", { className: "max-h-full w-[40%] shrink-0 space-y-0.5 self-center overflow-y-auto pr-1", children: l.slice(0, 10).map((z, W) => /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
2233
+ /* @__PURE__ */ e("div", { className: "max-h-full w-[40%] shrink-0 space-y-0.5 self-center overflow-y-auto pr-1", children: l.slice(0, 10).map((j, U) => /* @__PURE__ */ o("div", { className: "flex items-center gap-1.5 text-[10.5px]", children: [
2228
2234
  /* @__PURE__ */ e(
2229
2235
  "span",
2230
2236
  {
2231
2237
  className: "h-2 w-2 shrink-0 rounded-sm",
2232
- style: { background: oe[W % oe.length] }
2238
+ style: { background: ce[U % ce.length] }
2233
2239
  }
2234
2240
  ),
2235
- /* @__PURE__ */ e("span", { className: "truncate text-slate-600 dark:text-slate-300", children: z.dim }),
2236
- /* @__PURE__ */ e("span", { className: "ml-auto tabular-nums text-slate-400", children: z.value.toLocaleString() })
2237
- ] }, z.dim)) })
2241
+ /* @__PURE__ */ e("span", { className: "truncate text-slate-600 dark:text-slate-300", children: j.dim }),
2242
+ /* @__PURE__ */ e("span", { className: "ml-auto tabular-nums text-slate-400", children: j.value.toLocaleString() })
2243
+ ] }, j.dim)) })
2238
2244
  ] });
2239
2245
  } else if (a.type === "line")
2240
- G = /* @__PURE__ */ e("div", { className: "min-h-[110px] flex-1", children: /* @__PURE__ */ e(Re, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({
2241
- Area: F,
2242
- ComposedChart: z,
2243
- Line: W,
2246
+ X = /* @__PURE__ */ e("div", { className: "min-h-[110px] flex-1", children: /* @__PURE__ */ e(Le, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({
2247
+ Area: A,
2248
+ ComposedChart: j,
2249
+ Line: U,
2244
2250
  ReferenceLine: D,
2245
2251
  ResponsiveContainer: r,
2246
2252
  Tooltip: b,
@@ -2248,11 +2254,11 @@ const Lt = Ta(function({
2248
2254
  YAxis: d
2249
2255
  }) => {
2250
2256
  var y;
2251
- return /* @__PURE__ */ e(r, { width: "100%", height: "100%", children: /* @__PURE__ */ i(
2252
- z,
2257
+ return /* @__PURE__ */ e(r, { width: "100%", height: "100%", children: /* @__PURE__ */ o(
2258
+ j,
2253
2259
  {
2254
2260
  data: l,
2255
- margin: { top: 6, right: M ? 4 : 8, left: -10, bottom: 0 },
2261
+ margin: { top: 6, right: q ? 4 : 8, left: -10, bottom: 0 },
2256
2262
  children: [
2257
2263
  /* @__PURE__ */ e(
2258
2264
  v,
@@ -2260,7 +2266,7 @@ const Lt = Ta(function({
2260
2266
  dataKey: "dim",
2261
2267
  tick: { fontSize: 10 },
2262
2268
  stroke: "#94a3b8",
2263
- ..._t(l.length)
2269
+ ...Ct(l.length)
2264
2270
  }
2265
2271
  ),
2266
2272
  /* @__PURE__ */ e(
@@ -2272,7 +2278,7 @@ const Lt = Ta(function({
2272
2278
  width: 44
2273
2279
  }
2274
2280
  ),
2275
- M && /* @__PURE__ */ e(
2281
+ q && /* @__PURE__ */ e(
2276
2282
  d,
2277
2283
  {
2278
2284
  yAxisId: "right",
@@ -2283,7 +2289,7 @@ const Lt = Ta(function({
2283
2289
  width: 44
2284
2290
  }
2285
2291
  ),
2286
- I.map((k) => /* @__PURE__ */ e(
2292
+ te.map((k) => /* @__PURE__ */ e(
2287
2293
  D,
2288
2294
  {
2289
2295
  x: k.anchor_date,
@@ -2308,7 +2314,7 @@ const Lt = Ta(function({
2308
2314
  }
2309
2315
  ),
2310
2316
  K && /* @__PURE__ */ e(
2311
- F,
2317
+ A,
2312
2318
  {
2313
2319
  type: "monotone",
2314
2320
  dataKey: "band",
@@ -2320,7 +2326,7 @@ const Lt = Ta(function({
2320
2326
  }
2321
2327
  ),
2322
2328
  ((y = a.config) == null ? void 0 : y.compare) && /* @__PURE__ */ e(
2323
- W,
2329
+ U,
2324
2330
  {
2325
2331
  type: "monotone",
2326
2332
  dataKey: "prev",
@@ -2332,15 +2338,15 @@ const Lt = Ta(function({
2332
2338
  }
2333
2339
  ),
2334
2340
  /* @__PURE__ */ e(
2335
- W,
2341
+ U,
2336
2342
  {
2337
2343
  type: "monotone",
2338
2344
  dataKey: "value",
2339
2345
  stroke: Ge,
2340
2346
  strokeWidth: 2,
2341
2347
  dot: (k) => {
2342
- var j, B, T;
2343
- return ie.has(((j = k.payload) == null ? void 0 : j.dim) ?? "") ? /* @__PURE__ */ e(
2348
+ var E, Y, L;
2349
+ return de.has(((E = k.payload) == null ? void 0 : E.dim) ?? "") ? /* @__PURE__ */ e(
2344
2350
  "circle",
2345
2351
  {
2346
2352
  cx: k.cx,
@@ -2350,13 +2356,13 @@ const Lt = Ta(function({
2350
2356
  stroke: "#fff",
2351
2357
  strokeWidth: 1
2352
2358
  },
2353
- (B = k.payload) == null ? void 0 : B.dim
2354
- ) : /* @__PURE__ */ e("g", {}, (T = k.payload) == null ? void 0 : T.dim);
2359
+ (Y = k.payload) == null ? void 0 : Y.dim
2360
+ ) : /* @__PURE__ */ e("g", {}, (L = k.payload) == null ? void 0 : L.dim);
2355
2361
  }
2356
2362
  }
2357
2363
  ),
2358
- M && /* @__PURE__ */ e(
2359
- W,
2364
+ q && /* @__PURE__ */ e(
2365
+ U,
2360
2366
  {
2361
2367
  yAxisId: "right",
2362
2368
  type: "monotone",
@@ -2368,7 +2374,7 @@ const Lt = Ta(function({
2368
2374
  }
2369
2375
  ),
2370
2376
  g >= 2 && /* @__PURE__ */ e(
2371
- W,
2377
+ U,
2372
2378
  {
2373
2379
  type: "monotone",
2374
2380
  dataKey: "ma",
@@ -2385,10 +2391,10 @@ const Lt = Ta(function({
2385
2391
  ) });
2386
2392
  } }) });
2387
2393
  else {
2388
- const F = ((yt = a.config) == null ? void 0 : yt.orientation) === "horizontal";
2389
- G = /* @__PURE__ */ e("div", { className: "min-h-[110px] flex-1", children: /* @__PURE__ */ e(Re, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({
2390
- Bar: z,
2391
- Cell: W,
2394
+ const A = ((kt = a.config) == null ? void 0 : kt.orientation) === "horizontal";
2395
+ X = /* @__PURE__ */ e("div", { className: "min-h-[110px] flex-1", children: /* @__PURE__ */ e(Le, { fallback: /* @__PURE__ */ e(Oe, { className: "h-full w-full", "aria-busy": "true" }), children: ({
2396
+ Bar: j,
2397
+ Cell: U,
2392
2398
  ComposedChart: D,
2393
2399
  Line: r,
2394
2400
  ReferenceLine: b,
@@ -2397,15 +2403,15 @@ const Lt = Ta(function({
2397
2403
  XAxis: y,
2398
2404
  YAxis: k
2399
2405
  }) => {
2400
- var j;
2401
- return /* @__PURE__ */ e(v, { width: "100%", height: "100%", children: /* @__PURE__ */ i(
2406
+ var E;
2407
+ return /* @__PURE__ */ e(v, { width: "100%", height: "100%", children: /* @__PURE__ */ o(
2402
2408
  D,
2403
2409
  {
2404
2410
  data: l,
2405
- layout: F ? "vertical" : "horizontal",
2406
- margin: { top: 6, right: 8, left: F ? 10 : -10, bottom: 0 },
2411
+ layout: A ? "vertical" : "horizontal",
2412
+ margin: { top: 6, right: 8, left: A ? 10 : -10, bottom: 0 },
2407
2413
  children: [
2408
- F ? /* @__PURE__ */ i(He, { children: [
2414
+ A ? /* @__PURE__ */ o(He, { children: [
2409
2415
  /* @__PURE__ */ e(y, { type: "number", tick: { fontSize: 10 }, stroke: "#94a3b8" }),
2410
2416
  /* @__PURE__ */ e(
2411
2417
  k,
@@ -2414,19 +2420,19 @@ const Lt = Ta(function({
2414
2420
  dataKey: "dim",
2415
2421
  tick: { fontSize: 10 },
2416
2422
  stroke: "#94a3b8",
2417
- tickFormatter: Ia,
2423
+ tickFormatter: al,
2418
2424
  interval: 0,
2419
2425
  width: 140
2420
2426
  }
2421
2427
  )
2422
- ] }) : /* @__PURE__ */ i(He, { children: [
2428
+ ] }) : /* @__PURE__ */ o(He, { children: [
2423
2429
  /* @__PURE__ */ e(
2424
2430
  y,
2425
2431
  {
2426
2432
  dataKey: "dim",
2427
2433
  tick: { fontSize: 10 },
2428
2434
  stroke: "#94a3b8",
2429
- ..._t(l.length)
2435
+ ...Ct(l.length)
2430
2436
  }
2431
2437
  ),
2432
2438
  /* @__PURE__ */ e(
@@ -2438,7 +2444,7 @@ const Lt = Ta(function({
2438
2444
  width: 44
2439
2445
  }
2440
2446
  ),
2441
- M && /* @__PURE__ */ e(
2447
+ q && /* @__PURE__ */ e(
2442
2448
  k,
2443
2449
  {
2444
2450
  yAxisId: "right",
@@ -2450,15 +2456,15 @@ const Lt = Ta(function({
2450
2456
  }
2451
2457
  )
2452
2458
  ] }),
2453
- !F && I.map((B) => /* @__PURE__ */ e(
2459
+ !A && te.map((Y) => /* @__PURE__ */ e(
2454
2460
  b,
2455
2461
  {
2456
- x: B.anchor_date,
2462
+ x: Y.anchor_date,
2457
2463
  stroke: "#f59e0b",
2458
2464
  strokeDasharray: "4 3",
2459
2465
  label: { value: "✎", position: "top", fontSize: 11, fill: "#f59e0b" }
2460
2466
  },
2461
- B.id
2467
+ Y.id
2462
2468
  )),
2463
2469
  /* @__PURE__ */ e(
2464
2470
  d,
@@ -2474,40 +2480,40 @@ const Lt = Ta(function({
2474
2480
  itemStyle: { color: "#e2e8f0" }
2475
2481
  }
2476
2482
  ),
2477
- ((j = a.config) == null ? void 0 : j.compare) && /* @__PURE__ */ e(z, { dataKey: "prev", fill: "#cbd5e1", radius: [3, 3, 0, 0], name: "previous" }),
2483
+ ((E = a.config) == null ? void 0 : E.compare) && /* @__PURE__ */ e(j, { dataKey: "prev", fill: "#cbd5e1", radius: [3, 3, 0, 0], name: "previous" }),
2478
2484
  /* @__PURE__ */ e(
2479
- z,
2485
+ j,
2480
2486
  {
2481
2487
  dataKey: "value",
2482
2488
  fill: Ge,
2483
2489
  radius: [3, 3, 0, 0],
2484
2490
  className: a.collection ? "cursor-pointer" : void 0,
2485
- onClick: (B) => {
2491
+ onClick: (Y) => {
2486
2492
  var Pe;
2487
2493
  if (!a.collection) return;
2488
- const T = B == null ? void 0 : B.payload;
2489
- if (T != null && T.other) return;
2494
+ const L = Y == null ? void 0 : Y.payload;
2495
+ if (L != null && L.other) return;
2490
2496
  const Se = (Pe = a.config) == null ? void 0 : Pe.dimension;
2491
- de({
2497
+ se({
2492
2498
  conditions: Mt(
2493
2499
  a,
2494
2500
  c,
2495
- o,
2496
- (T == null ? void 0 : T.raw) ?? (T == null ? void 0 : T.dim)
2501
+ s,
2502
+ (L == null ? void 0 : L.raw) ?? (L == null ? void 0 : L.dim)
2497
2503
  ),
2498
- title: `${a.title || a.collection} — ${(T == null ? void 0 : T.dim) ?? ""}`,
2504
+ title: `${a.title || a.collection} — ${(L == null ? void 0 : L.dim) ?? ""}`,
2499
2505
  dimField: Se != null && Se.bucket || Se == null ? void 0 : Se.field,
2500
- dimRaw: (T == null ? void 0 : T.raw) ?? (T == null ? void 0 : T.dim),
2501
- dimLabel: T == null ? void 0 : T.dim
2506
+ dimRaw: (L == null ? void 0 : L.raw) ?? (L == null ? void 0 : L.dim),
2507
+ dimLabel: L == null ? void 0 : L.dim
2502
2508
  });
2503
2509
  },
2504
- children: l.map((B) => /* @__PURE__ */ e(W, { fill: B.other ? "#94a3b8" : Ge }, B.dim))
2510
+ children: l.map((Y) => /* @__PURE__ */ e(U, { fill: Y.other ? "#94a3b8" : Ge }, Y.dim))
2505
2511
  }
2506
2512
  ),
2507
- M && /* @__PURE__ */ e(
2513
+ q && /* @__PURE__ */ e(
2508
2514
  r,
2509
2515
  {
2510
- yAxisId: F ? void 0 : "right",
2516
+ yAxisId: A ? void 0 : "right",
2511
2517
  type: "monotone",
2512
2518
  dataKey: "value2",
2513
2519
  stroke: "#8b5cf6",
@@ -2522,32 +2528,32 @@ const Lt = Ta(function({
2522
2528
  } }) });
2523
2529
  }
2524
2530
  }
2525
- return L && p && (G = /* @__PURE__ */ i("div", { className: "flex min-h-0 flex-1 flex-col justify-center px-1", children: [
2526
- /* @__PURE__ */ e("p", { className: "text-[26px] font-bold tabular-nums text-amber-700 dark:text-amber-400", children: p.value == null ? "—" : qe(p.value, se) }),
2527
- /* @__PURE__ */ i("p", { className: "text-[10.5px] text-slate-400", children: [
2531
+ return R && u && (X = /* @__PURE__ */ o("div", { className: "flex min-h-0 flex-1 flex-col justify-center px-1", children: [
2532
+ /* @__PURE__ */ e("p", { className: "text-[26px] font-bold tabular-nums text-amber-700 dark:text-amber-400", children: u.value == null ? "—" : qe(u.value, oe) }),
2533
+ /* @__PURE__ */ o("p", { className: "text-[10.5px] text-slate-400", children: [
2528
2534
  "As of ",
2529
- p.name,
2530
- p.value == null ? " — no metric stored for this widget" : ""
2535
+ u.name,
2536
+ u.value == null ? " — no metric stored for this widget" : ""
2531
2537
  ] })
2532
- ] })), /* @__PURE__ */ i(
2538
+ ] })), /* @__PURE__ */ o(
2533
2539
  "div",
2534
2540
  {
2535
2541
  className: "flex min-h-0 flex-col overflow-hidden rounded-lg border border-slate-200 bg-white p-3 dark:border-border dark:bg-card",
2536
2542
  style: et,
2537
2543
  children: [
2538
- /* @__PURE__ */ i("div", { className: "mb-1.5 flex items-center gap-1.5", children: [
2544
+ /* @__PURE__ */ o("div", { className: "mb-1.5 flex items-center gap-1.5", children: [
2539
2545
  (() => {
2540
- var s;
2541
- const l = (s = a.config) == null ? void 0 : s.link_report;
2542
- return l != null && l.report_id && N ? /* @__PURE__ */ i(
2546
+ var i;
2547
+ const l = (i = a.config) == null ? void 0 : i.link_report;
2548
+ return l != null && l.report_id && S ? /* @__PURE__ */ o(
2543
2549
  "a",
2544
2550
  {
2545
- href: N(l.report_id),
2551
+ href: S(l.report_id),
2546
2552
  onClick: () => {
2547
2553
  try {
2548
2554
  sessionStorage.setItem(
2549
2555
  `nvr-report-xf:${l.report_id}`,
2550
- JSON.stringify(Y ?? [])
2556
+ JSON.stringify(ee ?? [])
2551
2557
  );
2552
2558
  } catch {
2553
2559
  }
@@ -2566,21 +2572,21 @@ const Lt = Ta(function({
2566
2572
  {
2567
2573
  "data-tip": Et(a),
2568
2574
  className: "shrink-0 cursor-help text-slate-300 hover:text-slate-500",
2569
- children: /* @__PURE__ */ e(Ca, { className: "h-3 w-3" })
2575
+ children: /* @__PURE__ */ e($a, { className: "h-3 w-3" })
2570
2576
  }
2571
2577
  ),
2572
- /* @__PURE__ */ i("span", { className: "ml-auto flex items-center gap-0.5", children: [
2578
+ /* @__PURE__ */ o("span", { className: "ml-auto flex items-center gap-0.5", children: [
2573
2579
  ["bar", "line", "donut", "pareto"].includes(a.type) && /* @__PURE__ */ e(
2574
2580
  "button",
2575
2581
  {
2576
2582
  type: "button",
2577
2583
  title: he ? "Back to the chart" : "View as table (#383)",
2578
- className: Q(
2584
+ className: V(
2579
2585
  "rounded p-0.5",
2580
2586
  he ? "text-[#00a5cc]" : "text-slate-300 hover:text-[#00a5cc]"
2581
2587
  ),
2582
- onClick: () => le((l) => !l),
2583
- children: /* @__PURE__ */ e($a, { className: "h-3 w-3" })
2588
+ onClick: () => re((l) => !l),
2589
+ children: /* @__PURE__ */ e(qa, { className: "h-3 w-3" })
2584
2590
  }
2585
2591
  ),
2586
2592
  ["bar", "line", "donut", "pareto", "scatter", "heatmap", "waterfall"].includes(
@@ -2591,8 +2597,8 @@ const Lt = Ta(function({
2591
2597
  type: "button",
2592
2598
  title: "Copy chart as image",
2593
2599
  className: "rounded p-0.5 text-slate-300 hover:text-[#00a5cc]",
2594
- onClick: () => void Ha(A.current, a.title),
2595
- children: /* @__PURE__ */ e(wt, { className: "h-3 w-3" })
2600
+ onClick: () => void Ia(T.current, a.title),
2601
+ children: /* @__PURE__ */ e(St, { className: "h-3 w-3" })
2596
2602
  }
2597
2603
  ),
2598
2604
  /* @__PURE__ */ e(
@@ -2603,58 +2609,58 @@ const Lt = Ta(function({
2603
2609
  "data-explain-trend": we ? "1" : void 0,
2604
2610
  className: "rounded p-0.5 text-slate-300 hover:text-[#00a5cc]",
2605
2611
  onClick: () => {
2606
- if (J) {
2607
- ne(!1);
2612
+ if (H) {
2613
+ ie(!1);
2608
2614
  return;
2609
2615
  }
2610
- if (ne(!0), ce || _) return;
2611
- if (P(!0), we) {
2612
- O.request(
2616
+ if (ie(!0), ue || _) return;
2617
+ if (z(!0), we) {
2618
+ F.request(
2613
2619
  pt(`/report-studio/${n}/widgets/${a.id}/explain-trend`, {
2614
- date_range: o,
2620
+ date_range: s,
2615
2621
  entity_filters: c
2616
2622
  })
2617
- ).then((s) => {
2618
- fe(s.data.explanation || "No explanation available."), ve(s.data.movers ?? null);
2623
+ ).then((i) => {
2624
+ fe(i.data.explanation || "No explanation available."), ve(i.data.movers ?? null);
2619
2625
  }).catch(
2620
- (s) => fe(
2621
- (s == null ? void 0 : s.status) === 503 ? "AI is not configured on this instance." : (s == null ? void 0 : s.status) === 400 ? s.message ?? "Not enough data to describe a trend." : "AI is not configured or unavailable."
2626
+ (i) => fe(
2627
+ (i == null ? void 0 : i.status) === 503 ? "AI is not configured on this instance." : (i == null ? void 0 : i.status) === 400 ? i.message ?? "Not enough data to describe a trend." : "AI is not configured or unavailable."
2622
2628
  )
2623
- ).finally(() => P(!1));
2629
+ ).finally(() => z(!1));
2624
2630
  return;
2625
2631
  }
2626
- (R ? Promise.resolve(R) : O.request(
2627
- kt(n, a.id, {
2628
- date_range: o,
2632
+ (O ? Promise.resolve(O) : F.request(
2633
+ Nt(n, a.id, {
2634
+ date_range: s,
2629
2635
  entity_filters: c
2630
2636
  })
2631
- ).then((s) => s.data).catch(() => {
2632
- })).then((s) => {
2637
+ ).then((i) => i.data).catch(() => {
2638
+ })).then((i) => {
2633
2639
  const g = {
2634
2640
  widget: a.title,
2635
2641
  how_computed: Et(a),
2636
- value: (s == null ? void 0 : s.value) ?? null,
2637
- previous_value: (s == null ? void 0 : s.prev_value) ?? null,
2638
- change_pct: (s == null ? void 0 : s.change_pct) ?? null,
2639
- row_count: (s == null ? void 0 : s.row_count) ?? null,
2640
- series: ((s == null ? void 0 : s.series) ?? []).slice(0, 15),
2641
- rows: ((s == null ? void 0 : s.rows) ?? []).slice(0, 10),
2642
- tiles: (s == null ? void 0 : s.tiles) ?? null
2643
- }, M = (s == null ? void 0 : s.prev_value) != null || ((s == null ? void 0 : s.series) ?? []).some(($) => $.prev != null);
2644
- return O.request(
2642
+ value: (i == null ? void 0 : i.value) ?? null,
2643
+ previous_value: (i == null ? void 0 : i.prev_value) ?? null,
2644
+ change_pct: (i == null ? void 0 : i.change_pct) ?? null,
2645
+ row_count: (i == null ? void 0 : i.row_count) ?? null,
2646
+ series: ((i == null ? void 0 : i.series) ?? []).slice(0, 15),
2647
+ rows: ((i == null ? void 0 : i.rows) ?? []).slice(0, 10),
2648
+ tiles: (i == null ? void 0 : i.tiles) ?? null
2649
+ }, q = (i == null ? void 0 : i.prev_value) != null || ((i == null ? void 0 : i.series) ?? []).some(($) => $.prev != null);
2650
+ return F.request(
2645
2651
  pt("/ai/brief", {
2646
2652
  context: JSON.stringify(g),
2647
2653
  // `template` picks the server's prompt; `instructions` (the same
2648
2654
  // text) keeps an older API answering the same way.
2649
- template: M ? "report-compare" : "report-explain",
2650
- instructions: M ? "Compare the current period against the previous one in 2-4 plain sentences: overall direction, the biggest movers up and down, and anything anomalous. No preamble." : "In 2-3 plain sentences, explain what this report metric shows and what stands out (biggest contributor, direction of change). No preamble."
2655
+ template: q ? "report-compare" : "report-explain",
2656
+ instructions: q ? "Compare the current period against the previous one in 2-4 plain sentences: overall direction, the biggest movers up and down, and anything anomalous. No preamble." : "In 2-3 plain sentences, explain what this report metric shows and what stands out (biggest contributor, direction of change). No preamble."
2651
2657
  })
2652
2658
  );
2653
- }).then((s) => {
2654
- var M, $;
2655
- const g = ((M = s.data) == null ? void 0 : M.brief) ?? (($ = s.data) == null ? void 0 : $.text) ?? null;
2659
+ }).then((i) => {
2660
+ var q, $;
2661
+ const g = ((q = i.data) == null ? void 0 : q.brief) ?? (($ = i.data) == null ? void 0 : $.text) ?? null;
2656
2662
  fe(g || "No explanation available.");
2657
- }).catch(() => fe("AI is not configured or unavailable.")).finally(() => P(!1));
2663
+ }).catch(() => fe("AI is not configured or unavailable.")).finally(() => z(!1));
2658
2664
  },
2659
2665
  children: /* @__PURE__ */ e(Dt, { className: "h-3 w-3" })
2660
2666
  }
@@ -2663,26 +2669,26 @@ const Lt = Ta(function({
2663
2669
  "button",
2664
2670
  {
2665
2671
  type: "button",
2666
- title: te ? "Show per-period values" : "Show running total",
2667
- className: Q(
2672
+ title: ae ? "Show per-period values" : "Show running total",
2673
+ className: V(
2668
2674
  "rounded p-0.5",
2669
- te ? "text-[#00a5cc]" : "text-slate-300 hover:text-slate-500"
2675
+ ae ? "text-[#00a5cc]" : "text-slate-300 hover:text-slate-500"
2670
2676
  ),
2671
- onClick: () => V((l) => !l),
2672
- children: /* @__PURE__ */ e(qa, { className: "h-3 w-3" })
2677
+ onClick: () => G((l) => !l),
2678
+ children: /* @__PURE__ */ e(Ma, { className: "h-3 w-3" })
2673
2679
  }
2674
2680
  ),
2675
- w && /* @__PURE__ */ e(
2681
+ N && /* @__PURE__ */ e(
2676
2682
  "button",
2677
2683
  {
2678
2684
  type: "button",
2679
2685
  title: "Notes on this widget",
2680
- className: Q(
2686
+ className: V(
2681
2687
  "relative rounded p-0.5",
2682
- ((q == null ? void 0 : q.length) ?? 0) > 0 ? "text-amber-500" : "text-slate-300 hover:text-slate-500"
2688
+ ((M == null ? void 0 : M.length) ?? 0) > 0 ? "text-amber-500" : "text-slate-300 hover:text-slate-500"
2683
2689
  ),
2684
2690
  onClick: () => be((l) => !l),
2685
- children: /* @__PURE__ */ e(Ma, { className: "h-3 w-3" })
2691
+ children: /* @__PURE__ */ e(Fa, { className: "h-3 w-3" })
2686
2692
  }
2687
2693
  ),
2688
2694
  /* @__PURE__ */ e(
@@ -2693,22 +2699,22 @@ const Lt = Ta(function({
2693
2699
  className: "rounded p-0.5 text-slate-300 hover:text-slate-500",
2694
2700
  onClick: () => {
2695
2701
  if (!(_e != null && _e.slug)) {
2696
- Wt(a, R);
2702
+ Wt(a, O);
2697
2703
  return;
2698
2704
  }
2699
- const l = _e, s = ia(l, o, c);
2705
+ const l = _e, i = oa(l, s, c);
2700
2706
  Te.fetchQuery({
2701
- queryKey: ["nivaro-report-query", l.slug, s],
2702
- queryFn: () => da(O, l.slug, s),
2707
+ queryKey: ["nivaro-report-query", l.slug, i],
2708
+ queryFn: () => ca(F, l.slug, i),
2703
2709
  staleTime: 6e4
2704
- }).then((g) => Wt(a, void 0, oa(l, g))).catch((g) => {
2705
- _a(g) || Xt.error(Tt(g, "this widget"));
2710
+ }).then((g) => Wt(a, void 0, da(l, g))).catch((g) => {
2711
+ Ca(g) || Xt.error(Tt(g, "this widget"));
2706
2712
  });
2707
2713
  },
2708
- children: /* @__PURE__ */ e(Fa, { className: "h-3 w-3" })
2714
+ children: /* @__PURE__ */ e(Aa, { className: "h-3 w-3" })
2709
2715
  }
2710
2716
  ),
2711
- /* @__PURE__ */ e(xl, { reportId: n, widget: a, filterBar: h }),
2717
+ /* @__PURE__ */ e(vl, { reportId: n, widget: a, filterBar: h }),
2712
2718
  /* @__PURE__ */ e(
2713
2719
  "button",
2714
2720
  {
@@ -2716,19 +2722,19 @@ const Lt = Ta(function({
2716
2722
  title: "Refresh",
2717
2723
  className: "rounded p-0.5 text-slate-300 hover:text-slate-500",
2718
2724
  onClick: () => We(),
2719
- children: /* @__PURE__ */ e(Ft, { className: Q("h-3 w-3", $t && "animate-spin") })
2725
+ children: /* @__PURE__ */ e(Ft, { className: V("h-3 w-3", $t && "animate-spin") })
2720
2726
  }
2721
2727
  )
2722
2728
  ] })
2723
2729
  ] }),
2724
- xe && /* @__PURE__ */ i("div", { className: "mb-1.5 space-y-1 rounded-md border border-amber-200 bg-amber-50/60 p-2 dark:border-amber-500/30 dark:bg-amber-500/10", children: [
2725
- (q ?? []).map((l) => /* @__PURE__ */ i(
2730
+ xe && /* @__PURE__ */ o("div", { className: "mb-1.5 space-y-1 rounded-md border border-amber-200 bg-amber-50/60 p-2 dark:border-amber-500/30 dark:bg-amber-500/10", children: [
2731
+ (M ?? []).map((l) => /* @__PURE__ */ o(
2726
2732
  "div",
2727
2733
  {
2728
2734
  className: "group/note flex items-start gap-1.5 text-[11px] text-slate-600 dark:text-slate-300",
2729
2735
  children: [
2730
- /* @__PURE__ */ i("span", { className: "min-w-0 flex-1", children: [
2731
- l.anchor_date && /* @__PURE__ */ i("span", { className: "font-semibold text-amber-600 dark:text-amber-400", children: [
2736
+ /* @__PURE__ */ o("span", { className: "min-w-0 flex-1", children: [
2737
+ l.anchor_date && /* @__PURE__ */ o("span", { className: "font-semibold text-amber-600 dark:text-amber-400", children: [
2732
2738
  l.anchor_date,
2733
2739
  " —",
2734
2740
  " "
@@ -2736,11 +2742,11 @@ const Lt = Ta(function({
2736
2742
  l.note,
2737
2743
  /* @__PURE__ */ e("span", { className: "ml-1 text-[10px] text-slate-400", children: l.created_by_name ?? "" })
2738
2744
  ] }),
2739
- U && /* @__PURE__ */ e(
2745
+ W && /* @__PURE__ */ e(
2740
2746
  "button",
2741
2747
  {
2742
2748
  type: "button",
2743
- onClick: () => U(l.id),
2749
+ onClick: () => W(l.id),
2744
2750
  className: "shrink-0 rounded p-0.5 text-slate-300 opacity-0 hover:text-red-500 group-hover/note:opacity-100",
2745
2751
  children: /* @__PURE__ */ e(Ae, { className: "h-2.5 w-2.5" })
2746
2752
  }
@@ -2749,8 +2755,8 @@ const Lt = Ta(function({
2749
2755
  },
2750
2756
  l.id
2751
2757
  )),
2752
- (q ?? []).length === 0 && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: "No notes yet — record why a number moved." }),
2753
- w && /* @__PURE__ */ i("div", { className: "flex items-center gap-1 pt-0.5", children: [
2758
+ (M ?? []).length === 0 && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: "No notes yet — record why a number moved." }),
2759
+ N && /* @__PURE__ */ o("div", { className: "flex items-center gap-1 pt-0.5", children: [
2754
2760
  /* @__PURE__ */ e(
2755
2761
  "input",
2756
2762
  {
@@ -2764,7 +2770,7 @@ const Lt = Ta(function({
2764
2770
  "input",
2765
2771
  {
2766
2772
  value: x,
2767
- onChange: (l) => Z(l.target.value),
2773
+ onChange: (l) => I(l.target.value),
2768
2774
  placeholder: "2026-03",
2769
2775
  title: "Optional chart anchor (YYYY-MM or YYYY-MM-DD bucket key)",
2770
2776
  className: "h-6 w-[76px] rounded border border-amber-200 bg-white px-1.5 text-[10.5px] dark:border-amber-500/30 dark:bg-card dark:text-slate-200"
@@ -2776,7 +2782,7 @@ const Lt = Ta(function({
2776
2782
  type: "button",
2777
2783
  disabled: !ge.trim(),
2778
2784
  onClick: () => {
2779
- w(a.id, ge.trim(), x.trim() || null), $e(""), Z("");
2785
+ N(a.id, ge.trim(), x.trim() || null), $e(""), I("");
2780
2786
  },
2781
2787
  className: "h-6 rounded bg-amber-500 px-2 text-[11px] font-medium text-white hover:brightness-105 disabled:opacity-40",
2782
2788
  children: "Add"
@@ -2784,22 +2790,22 @@ const Lt = Ta(function({
2784
2790
  )
2785
2791
  ] })
2786
2792
  ] }),
2787
- p && (() => {
2788
- const l = gl(R), s = p.value;
2789
- if (l == null || s == null) return null;
2790
- const g = s === 0 ? null : (l - s) / Math.abs(s) * 100;
2791
- return /* @__PURE__ */ i("p", { className: "mb-1 flex items-center gap-1 text-[10.5px] text-slate-400", children: [
2792
- /* @__PURE__ */ e(wt, { className: "h-2.5 w-2.5" }),
2793
+ u && (() => {
2794
+ const l = kl(O), i = u.value;
2795
+ if (l == null || i == null) return null;
2796
+ const g = i === 0 ? null : (l - i) / Math.abs(i) * 100;
2797
+ return /* @__PURE__ */ o("p", { className: "mb-1 flex items-center gap-1 text-[10.5px] text-slate-400", children: [
2798
+ /* @__PURE__ */ e(St, { className: "h-2.5 w-2.5" }),
2793
2799
  "vs ",
2794
- p.name,
2800
+ u.name,
2795
2801
  ": ",
2796
- s.toLocaleString(),
2802
+ i.toLocaleString(),
2797
2803
  " →",
2798
2804
  " ",
2799
2805
  /* @__PURE__ */ e(
2800
2806
  "span",
2801
2807
  {
2802
- className: Q(
2808
+ className: V(
2803
2809
  "font-semibold",
2804
2810
  g != null && g > 0 && "text-emerald-600 dark:text-emerald-400",
2805
2811
  g != null && g < 0 && "text-red-500"
@@ -2809,17 +2815,17 @@ const Lt = Ta(function({
2809
2815
  )
2810
2816
  ] });
2811
2817
  })(),
2812
- J && /* @__PURE__ */ i(
2818
+ H && /* @__PURE__ */ o(
2813
2819
  "div",
2814
2820
  {
2815
2821
  className: "mb-1.5 rounded-md border border-nvr-cyan/25 bg-nvr-cyan/5 px-2.5 py-1.5 text-[11.5px] leading-snug text-slate-600 dark:text-slate-300",
2816
2822
  "data-explain-panel": we ? "trend" : "number",
2817
2823
  children: [
2818
- _ ? "Thinking…" : ce,
2819
- !_ && me && me.length > 0 && /* @__PURE__ */ e("div", { className: "mt-1.5 flex flex-wrap gap-1", "data-explain-movers": !0, children: me.slice(0, 4).map((l) => /* @__PURE__ */ i(
2824
+ _ ? "Thinking…" : ue,
2825
+ !_ && pe && pe.length > 0 && /* @__PURE__ */ e("div", { className: "mt-1.5 flex flex-wrap gap-1", "data-explain-movers": !0, children: pe.slice(0, 4).map((l) => /* @__PURE__ */ o(
2820
2826
  "span",
2821
2827
  {
2822
- className: Q(
2828
+ className: V(
2823
2829
  "inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10.5px] tabular-nums",
2824
2830
  l.delta == null ? "border-slate-200 text-slate-500 dark:border-border dark:text-slate-400" : l.delta >= 0 ? "border-emerald-200 text-emerald-700 dark:border-emerald-500/30 dark:text-emerald-300" : "border-red-200 text-red-700 dark:border-red-500/30 dark:text-red-300"
2825
2831
  ),
@@ -2827,11 +2833,11 @@ const Lt = Ta(function({
2827
2833
  children: [
2828
2834
  l.delta != null && (l.delta >= 0 ? /* @__PURE__ */ e(Gt, { className: "h-3 w-3" }) : /* @__PURE__ */ e(Ht, { className: "h-3 w-3" })),
2829
2835
  /* @__PURE__ */ e("span", { className: "font-medium", children: l.label }),
2830
- l.delta != null ? /* @__PURE__ */ i("span", { children: [
2836
+ l.delta != null ? /* @__PURE__ */ o("span", { children: [
2831
2837
  l.delta >= 0 ? "+" : "",
2832
2838
  Number(l.delta).toLocaleString(void 0, { maximumFractionDigits: 1 }),
2833
2839
  l.pct != null ? ` (${l.pct >= 0 ? "+" : ""}${l.pct}%)` : ""
2834
- ] }) : l.to != null ? /* @__PURE__ */ i("span", { children: [
2840
+ ] }) : l.to != null ? /* @__PURE__ */ o("span", { children: [
2835
2841
  Number(l.to).toLocaleString(void 0, { maximumFractionDigits: 1 }),
2836
2842
  l.pct != null ? ` · ${l.pct}%` : ""
2837
2843
  ] }) : null
@@ -2842,56 +2848,56 @@ const Lt = Ta(function({
2842
2848
  ]
2843
2849
  }
2844
2850
  ),
2845
- ae.length > 0 && /* @__PURE__ */ i("div", { className: "mb-1 flex flex-wrap items-center gap-1 text-[10.5px] text-slate-500", children: [
2851
+ le.length > 0 && /* @__PURE__ */ o("div", { className: "mb-1 flex flex-wrap items-center gap-1 text-[10.5px] text-slate-500", children: [
2846
2852
  /* @__PURE__ */ e(
2847
2853
  "button",
2848
2854
  {
2849
2855
  type: "button",
2850
- onClick: () => S([]),
2856
+ onClick: () => w([]),
2851
2857
  className: "rounded px-1 hover:bg-muted",
2852
2858
  children: "⌂ All"
2853
2859
  }
2854
2860
  ),
2855
- ae.map((l, s) => /* @__PURE__ */ i("span", { className: "flex items-center gap-1", children: [
2861
+ le.map((l, i) => /* @__PURE__ */ o("span", { className: "flex items-center gap-1", children: [
2856
2862
  /* @__PURE__ */ e("span", { className: "text-slate-300", children: "›" }),
2857
2863
  /* @__PURE__ */ e(
2858
2864
  "button",
2859
2865
  {
2860
2866
  type: "button",
2861
- onClick: () => S(ae.slice(0, s + 1)),
2867
+ onClick: () => w(le.slice(0, i + 1)),
2862
2868
  className: "rounded bg-nvr-cyan/[0.08] px-1.5 py-0.5 font-medium text-[#007a99] dark:text-nvr-cyan",
2863
2869
  children: l.value
2864
2870
  }
2865
2871
  )
2866
- ] }, `${l.field}-${s}`))
2872
+ ] }, `${l.field}-${i}`))
2867
2873
  ] }),
2868
- /* @__PURE__ */ e("div", { ref: A, className: "flex min-h-0 flex-1 flex-col", children: he && ((ot = R == null ? void 0 : R.series) != null && ot.length) ? /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ i("table", { className: "w-full text-[11.5px]", children: [
2869
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ i("tr", { className: "text-left text-[10px] uppercase tracking-wide text-slate-400", children: [
2874
+ /* @__PURE__ */ e("div", { ref: T, className: "flex min-h-0 flex-1 flex-col", children: he && ((ot = O == null ? void 0 : O.series) != null && ot.length) ? /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ o("table", { className: "w-full text-[11.5px]", children: [
2875
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ o("tr", { className: "text-left text-[10px] uppercase tracking-wide text-slate-400", children: [
2870
2876
  /* @__PURE__ */ e("th", { className: "px-1.5 pb-1", children: "Dimension" }),
2871
2877
  /* @__PURE__ */ e("th", { className: "px-1.5 pb-1 text-right", children: "Value" })
2872
2878
  ] }) }),
2873
- /* @__PURE__ */ e("tbody", { children: (R.series ?? []).map((l) => /* @__PURE__ */ i("tr", { className: "border-b border-slate-50 dark:border-border/40", children: [
2879
+ /* @__PURE__ */ e("tbody", { children: (O.series ?? []).map((l) => /* @__PURE__ */ o("tr", { className: "border-b border-slate-50 dark:border-border/40", children: [
2874
2880
  /* @__PURE__ */ e("td", { className: "max-w-[220px] truncate px-1.5 py-1 text-slate-700 dark:text-slate-300", children: l.dim }),
2875
- /* @__PURE__ */ e("td", { className: "px-1.5 py-1 text-right tabular-nums text-slate-800 dark:text-slate-100", children: qe(l.value, se) })
2881
+ /* @__PURE__ */ e("td", { className: "px-1.5 py-1 text-right tabular-nums text-slate-800 dark:text-slate-100", children: qe(l.value, oe) })
2876
2882
  ] }, l.dim)) })
2877
- ] }) }) : G }),
2878
- ((Le = a.config) == null ? void 0 : Le.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 }),
2879
- H && /* @__PURE__ */ e(
2880
- vl,
2883
+ ] }) }) : X }),
2884
+ ((Re = a.config) == null ? void 0 : Re.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 }),
2885
+ B && /* @__PURE__ */ e(
2886
+ Nl,
2881
2887
  {
2882
2888
  collection: a.collection ?? "",
2883
- conditions: H.conditions,
2884
- title: H.title,
2885
- onClose: () => de(null),
2889
+ conditions: B.conditions,
2890
+ title: B.title,
2891
+ onClose: () => se(null),
2886
2892
  onOpen: (l) => {
2887
- de(null), f == null || f(l);
2893
+ se(null), f == null || f(l);
2888
2894
  },
2889
- crossFilter: u && H.dimField && H.dimRaw != null ? () => {
2890
- u(
2891
- H.dimField,
2892
- H.dimRaw,
2893
- H.dimLabel ?? String(H.dimRaw)
2894
- ), de(null);
2895
+ crossFilter: p && B.dimField && B.dimRaw != null ? () => {
2896
+ p(
2897
+ B.dimField,
2898
+ B.dimRaw,
2899
+ B.dimLabel ?? String(B.dimRaw)
2900
+ ), se(null);
2895
2901
  } : void 0
2896
2902
  }
2897
2903
  )
@@ -2899,57 +2905,57 @@ const Lt = Ta(function({
2899
2905
  }
2900
2906
  );
2901
2907
  });
2902
- function Ul({
2908
+ function Gl({
2903
2909
  reportId: t,
2904
2910
  widget: n,
2905
2911
  dateRange: a = null,
2906
- entityFilters: o = []
2912
+ entityFilters: s = []
2907
2913
  }) {
2908
2914
  const c = Zt(), m = At(
2909
2915
  (f) => c == null ? void 0 : c.open(f),
2910
2916
  [c]
2911
2917
  ), h = ut(() => ({ ...n, x: 0 }), [n]);
2912
2918
  return /* @__PURE__ */ e(
2913
- Lt,
2919
+ Rt,
2914
2920
  {
2915
2921
  reportId: t,
2916
2922
  widget: h,
2917
2923
  dateRange: a,
2918
- entityFilters: o,
2924
+ entityFilters: s,
2919
2925
  onDrill: c ? m : void 0
2920
2926
  }
2921
2927
  );
2922
2928
  }
2923
- function yl(t) {
2929
+ function wl(t) {
2924
2930
  const n = t == null ? "" : String(t);
2925
2931
  return n.length > 24 ? `${n.slice(0, 23)}…` : n;
2926
2932
  }
2927
- function kl(t) {
2933
+ function Sl(t) {
2928
2934
  const n = t;
2929
2935
  return !(n != null && n.admin) || !n.access_scope_label ? null : `(your access scope: ${n.access_scope_label})`;
2930
2936
  }
2931
- function Yl({
2937
+ function Hl({
2932
2938
  reportId: t,
2933
2939
  showFilterBar: n = !0,
2934
2940
  dateRange: a,
2935
- initialEntityFilters: o = [],
2941
+ initialEntityFilters: s = [],
2936
2942
  refetchInterval: c,
2937
2943
  className: m,
2938
2944
  emptyState: h,
2939
2945
  reportUrl: f
2940
2946
  }) {
2941
- var W, D;
2942
- const p = Ke(), L = Zt(), q = La("drill.report"), w = q.value, U = At(
2943
- (r) => L ? L.open(r) : q.push([r]),
2944
- [L, q.push]
2945
- ), [u, N] = C(void 0), [Y, O] = C(o), [ee, X] = C(void 0), [ue, pe] = C(o), { scopes: H, ready: de } = ja(), [xe, be] = C(!1), [ge, $e] = C({}), x = Ct(), { data: Z = [] } = Ne({
2947
+ var U, D;
2948
+ const u = Ke(), R = Zt(), M = La("drill.report"), N = M.value, W = At(
2949
+ (r) => R ? R.open(r) : M.push([r]),
2950
+ [R, M.push]
2951
+ ), [p, S] = C(void 0), [ee, F] = C(s), [Z, P] = C(void 0), [me, J] = C(s), { scopes: B, ready: se } = ea(), [xe, be] = C(!1), [ge, $e] = C({}), x = ht(), { data: I = [] } = Ne({
2946
2952
  queryKey: ["nivaro-report-presets", t],
2947
2953
  queryFn: async () => {
2948
2954
  try {
2949
2955
  const r = JSON.parse(localStorage.getItem(`nvr-report-presets:${t}`) ?? "[]");
2950
2956
  if (Array.isArray(r) && r.length > 0) {
2951
2957
  for (const b of r)
2952
- b != null && b.name && await p.request(
2958
+ b != null && b.name && await u.request(
2953
2959
  Kt(t, {
2954
2960
  name: String(b.name),
2955
2961
  date_range: b.date_range ?? null,
@@ -2961,49 +2967,49 @@ function Yl({
2961
2967
  }
2962
2968
  } catch {
2963
2969
  }
2964
- return p.request(ua(t)).then((r) => r.data);
2970
+ return u.request(pa(t)).then((r) => r.data);
2965
2971
  },
2966
2972
  staleTime: 6e4
2967
- }), te = () => void x.invalidateQueries({ queryKey: ["nivaro-report-presets", t] }), V = Me({
2968
- mutationFn: (r) => p.request(
2973
+ }), ae = () => void x.invalidateQueries({ queryKey: ["nivaro-report-presets", t] }), G = Me({
2974
+ mutationFn: (r) => u.request(
2969
2975
  Kt(t, {
2970
2976
  name: r,
2971
2977
  date_range: st.current ?? null,
2972
2978
  entity_filters: it.current
2973
2979
  })
2974
2980
  ),
2975
- onSuccess: te
2981
+ onSuccess: ae
2976
2982
  }), he = Me({
2977
- mutationFn: (r) => p.request(pa(t, r)),
2978
- onSuccess: te
2979
- }), [le, ae] = C(""), [S, A] = C(!1), [E, J] = C(null), [ne, ce] = C(!1), { data: fe = [] } = Ne({
2983
+ mutationFn: (r) => u.request(ha(t, r)),
2984
+ onSuccess: ae
2985
+ }), [re, le] = C(""), [w, T] = C(!1), [Q, H] = C(null), [ie, ue] = C(!1), { data: fe = [] } = Ne({
2980
2986
  queryKey: ["nvr-report-snaps", t],
2981
- queryFn: () => p.request(
2987
+ queryFn: () => u.request(
2982
2988
  ct(`/report-studio/${t}/snapshots`)
2983
2989
  ).then((r) => r.data ?? []),
2984
2990
  staleTime: 6e4,
2985
2991
  retry: !1
2986
2992
  }), { data: _ } = Ne({
2987
- queryKey: ["nvr-report-snap", t, E],
2988
- queryFn: () => p.request(
2989
- ct(`/report-studio/${t}/snapshots/${E}`)
2993
+ queryKey: ["nvr-report-snap", t, Q],
2994
+ queryFn: () => u.request(
2995
+ ct(`/report-studio/${t}/snapshots/${Q}`)
2990
2996
  ).then((r) => r.data),
2991
- enabled: E != null,
2997
+ enabled: Q != null,
2992
2998
  staleTime: 5 * 6e4,
2993
2999
  retry: !1
2994
- }), P = Me({
2995
- mutationFn: () => p.request(pt(`/report-studio/${t}/snapshots`, {})),
3000
+ }), z = Me({
3001
+ mutationFn: () => u.request(pt(`/report-studio/${t}/snapshots`, {})),
2996
3002
  onSuccess: () => void x.invalidateQueries({ queryKey: ["nvr-report-snaps", t] })
2997
- }), { data: me = [] } = Ne({
3003
+ }), { data: pe = [] } = Ne({
2998
3004
  queryKey: ["nvr-report-notes", t],
2999
- queryFn: () => p.request(ct(`/report-studio/${t}/annotations`)).then((r) => r.data ?? []),
3005
+ queryFn: () => u.request(ct(`/report-studio/${t}/annotations`)).then((r) => r.data ?? []),
3000
3006
  staleTime: 6e4,
3001
3007
  retry: !1
3002
3008
  }), ve = () => void x.invalidateQueries({ queryKey: ["nvr-report-notes", t] }), we = Me({
3003
- mutationFn: (r) => p.request(pt(`/report-studio/${t}/annotations`, r)),
3009
+ mutationFn: (r) => u.request(pt(`/report-studio/${t}/annotations`, r)),
3004
3010
  onSuccess: ve
3005
3011
  }), Te = Me({
3006
- mutationFn: (r) => p.request(Ra(`/report-studio/${t}/annotations/${r}`)),
3012
+ mutationFn: (r) => u.request(Oa(`/report-studio/${t}/annotations/${r}`)),
3007
3013
  onSuccess: ve
3008
3014
  }), Xe = At((r, b, v) => {
3009
3015
  const d = {
@@ -3011,59 +3017,59 @@ function Yl({
3011
3017
  values: [b],
3012
3018
  labels: [v]
3013
3019
  };
3014
- O((y) => [...y.filter((k) => k.field !== r), d]), pe((y) => [...y.filter((k) => k.field !== r), d]);
3020
+ F((y) => [...y.filter((k) => k.field !== r), d]), J((y) => [...y.filter((k) => k.field !== r), d]);
3015
3021
  }, []), [ye, Ze] = C(!1), [ke, Fe] = C(null), [Ie, Ee] = C(null), De = Me({
3016
- mutationFn: (r) => p.request(
3017
- Oa(`/report-studio/${t}/widgets`, {
3022
+ mutationFn: (r) => u.request(
3023
+ Ka(`/report-studio/${t}/widgets`, {
3018
3024
  widgets: r.map((b, v) => ({ ...b, sort: v }))
3019
3025
  })
3020
3026
  ),
3021
3027
  onSuccess: () => {
3022
3028
  Ze(!1), Fe(null), Ee(null), x.invalidateQueries({ queryKey: ["nivaro-report", t] }), x.invalidateQueries({ queryKey: ["nivaro-report-widget"] });
3023
3029
  }
3024
- }), We = (r) => [...r].sort((b, v) => (b.y ?? 0) - (v.y ?? 0) || (b.x ?? 0) - (v.x ?? 0)), [$t, Be] = C(() => /* @__PURE__ */ new Date()), ht = () => {
3030
+ }), We = (r) => [...r].sort((b, v) => (b.y ?? 0) - (v.y ?? 0) || (b.x ?? 0) - (v.x ?? 0)), [$t, Be] = C(() => /* @__PURE__ */ new Date()), ft = () => {
3025
3031
  x.invalidateQueries({ queryKey: ["nivaro-report-widget", t] }), x.invalidateQueries({ queryKey: ["nivaro-report-query"] }), Be(/* @__PURE__ */ new Date());
3026
- }, { data: R = [] } = Ne({
3032
+ }, { data: O = [] } = Ne({
3027
3033
  queryKey: ["nvr-report-firing", t],
3028
- queryFn: () => p.request(ct(`/report-studio/${t}/firing`)).then((r) => r.data ?? []).catch(() => []),
3034
+ queryFn: () => u.request(ct(`/report-studio/${t}/firing`)).then((r) => r.data ?? []).catch(() => []),
3029
3035
  staleTime: 6e4,
3030
3036
  refetchInterval: 5 * 6e4,
3031
3037
  retry: !1
3032
- }), [se, et] = C(null), [Qe, _e] = C(!1), [G, ft] = C(""), [Ue, xt] = C(""), [Ye, bt] = C("");
3038
+ }), [oe, et] = C(null), [Qe, _e] = C(!1), [X, xt] = C(""), [Ue, bt] = C(""), [Ye, gt] = C("");
3033
3039
  mt(() => {
3034
3040
  try {
3035
3041
  const r = sessionStorage.getItem(`nvr-report-xf:${t}`);
3036
3042
  if (r) {
3037
3043
  sessionStorage.removeItem(`nvr-report-xf:${t}`);
3038
3044
  const b = JSON.parse(r);
3039
- Array.isArray(b) && b.length > 0 && (O(b), pe(b));
3045
+ Array.isArray(b) && b.length > 0 && (F(b), J(b));
3040
3046
  }
3041
3047
  } catch {
3042
3048
  }
3043
3049
  }, [t]);
3044
- const gt = () => {
3045
- Fe(We((re == null ? void 0 : re.widgets) ?? [])), Ze(!0), window.__nvrReportId = t;
3046
- }, tt = (r) => Fe((b) => (b ?? []).map((v) => v.id === r.id ? r : v)), vt = (r, b) => Fe((v) => {
3047
- const d = [...v ?? []], y = d.findIndex((T) => T.id === r), k = y + b;
3050
+ const vt = () => {
3051
+ Fe(We((ne == null ? void 0 : ne.widgets) ?? [])), Ze(!0), window.__nvrReportId = t;
3052
+ }, tt = (r) => Fe((b) => (b ?? []).map((v) => v.id === r.id ? r : v)), yt = (r, b) => Fe((v) => {
3053
+ const d = [...v ?? []], y = d.findIndex((L) => L.id === r), k = y + b;
3048
3054
  if (y < 0 || k < 0 || k >= d.length) return d;
3049
- const j = d[y], B = d[k];
3050
- return d[y] = { ...B, x: j.x, y: j.y }, d[k] = { ...j, x: B.x, y: B.y }, d;
3051
- }), [Ve, at] = C(""), [Je, lt] = C(!1), [rt, nt] = C(null), { data: re, isLoading: yt } = Ne({
3055
+ const E = d[y], Y = d[k];
3056
+ return d[y] = { ...Y, x: E.x, y: E.y }, d[k] = { ...E, x: Y.x, y: Y.y }, d;
3057
+ }), [Ve, at] = C(""), [Je, lt] = C(!1), [rt, nt] = C(null), { data: ne, isLoading: kt } = Ne({
3052
3058
  queryKey: ["nivaro-report", t],
3053
- queryFn: () => p.request(ha(t)).then((r) => r.data),
3059
+ queryFn: () => u.request(fa(t)).then((r) => r.data),
3054
3060
  staleTime: 3e4
3055
- }), st = St(null), it = St([]), ot = ((W = re == null ? void 0 : re.global_filters) == null ? void 0 : W.date_range) ?? null, Le = ut(() => u !== void 0 ? u : a !== void 0 ? a : ot, [u, a, ot]);
3056
- st.current = Le ?? null, it.current = Y;
3061
+ }), st = _t(null), it = _t([]), ot = ((U = ne == null ? void 0 : ne.global_filters) == null ? void 0 : U.date_range) ?? null, Re = ut(() => p !== void 0 ? p : a !== void 0 ? a : ot, [p, a, ot]);
3062
+ st.current = Re ?? null, it.current = ee;
3057
3063
  const l = ut(
3058
3064
  () => {
3059
3065
  var r;
3060
- return ((r = re == null ? void 0 : re.global_filters) == null ? void 0 : r.filter_bar) ?? [];
3066
+ return ((r = ne == null ? void 0 : ne.global_filters) == null ? void 0 : r.filter_bar) ?? [];
3061
3067
  },
3062
- [(D = re == null ? void 0 : re.global_filters) == null ? void 0 : D.filter_bar]
3068
+ [(D = ne == null ? void 0 : ne.global_filters) == null ? void 0 : D.filter_bar]
3063
3069
  );
3064
3070
  mt(() => {
3065
- if (!xe && !(!de || !re)) {
3066
- if (!H || l.length === 0) {
3071
+ if (!xe && !(!se || !ne)) {
3072
+ if (!B || l.length === 0) {
3067
3073
  be(!0);
3068
3074
  return;
3069
3075
  }
@@ -3071,61 +3077,61 @@ function Yl({
3071
3077
  var v;
3072
3078
  const r = [], b = {};
3073
3079
  for (const d of l) {
3074
- const y = Ea(H, {
3080
+ const y = Qa(B, {
3075
3081
  key: d.field,
3076
3082
  collection: (v = d.options) == null ? void 0 : v.collection
3077
3083
  });
3078
3084
  if (!y) continue;
3079
- const k = d.options ? d.options.value_field ?? "id" : "id", j = H.restricted[y.name] ?? [];
3080
- if (j.length > 0) {
3081
- const T = await Pt(p, y, j, k).catch(
3085
+ const k = d.options ? d.options.value_field ?? "id" : "id", E = B.restricted[y.name] ?? [];
3086
+ if (E.length > 0) {
3087
+ const L = await Pt(u, y, E, k).catch(
3082
3088
  () => []
3083
3089
  );
3084
- T.length > 0 && (b[d.field] = T);
3090
+ L.length > 0 && (b[d.field] = L);
3085
3091
  }
3086
- const B = Wa(H, y.name);
3087
- if (B.length > 0) {
3088
- const T = await Pt(p, y, B, k).catch(
3092
+ const Y = Ua(B, y.name);
3093
+ if (Y.length > 0) {
3094
+ const L = await Pt(u, y, Y, k).catch(
3089
3095
  () => []
3090
3096
  );
3091
- T.length > 0 && r.push({ field: d.field, values: T, labels: T.map(String) });
3097
+ L.length > 0 && r.push({ field: d.field, values: L, labels: L.map(String) });
3092
3098
  }
3093
3099
  }
3094
3100
  if (Object.keys(b).length > 0 && $e(b), r.length > 0) {
3095
3101
  const d = (y) => {
3096
3102
  const k = [...y];
3097
- for (const j of r) k.some((B) => B.field === j.field) || k.push(j);
3103
+ for (const E of r) k.some((Y) => Y.field === E.field) || k.push(E);
3098
3104
  return k;
3099
3105
  };
3100
- pe(d), O(d);
3106
+ J(d), F(d);
3101
3107
  }
3102
3108
  be(!0);
3103
3109
  })();
3104
3110
  }
3105
- }, [xe, de, re, H, l]);
3106
- const s = (re == null ? void 0 : re.widgets) ?? [], g = ee !== void 0 ? ee : Le, M = Y.filter((r) => r.values.length > 0).length + (Le ? 1 : 0), $ = JSON.stringify(ue) !== JSON.stringify(Y) || ee !== void 0, K = () => {
3107
- O(ue), ee !== void 0 && (N(ee), X(void 0));
3108
- }, ie = () => {
3109
- pe([]), O([]), N(null), X(void 0);
3110
- }, I = (r) => {
3111
- pe(r.entity_filters), O(r.entity_filters), N(r.date_range), X(void 0);
3112
- }, F = async () => {
3111
+ }, [xe, se, ne, B, l]);
3112
+ const i = (ne == null ? void 0 : ne.widgets) ?? [], g = Z !== void 0 ? Z : Re, q = ee.filter((r) => r.values.length > 0).length + (Re ? 1 : 0), $ = JSON.stringify(me) !== JSON.stringify(ee) || Z !== void 0, K = () => {
3113
+ F(me), Z !== void 0 && (S(Z), P(void 0));
3114
+ }, de = () => {
3115
+ J([]), F([]), S(null), P(void 0);
3116
+ }, te = (r) => {
3117
+ J(r.entity_filters), F(r.entity_filters), S(r.date_range), P(void 0);
3118
+ }, A = async () => {
3113
3119
  var b, v;
3114
3120
  const r = Ve.trim();
3115
3121
  if (!(!r || Je)) {
3116
3122
  lt(!0), nt(null);
3117
3123
  try {
3118
- const d = await p.request(
3119
- ga(
3124
+ const d = await u.request(
3125
+ va(
3120
3126
  t,
3121
3127
  r,
3122
3128
  l.map((k) => ({ field: k.field, label: k.label }))
3123
3129
  )
3124
3130
  ), y = (d.data.entity_filters ?? []).filter((k) => {
3125
- var j;
3126
- return l.some((B) => B.field === k.field) && ((j = k.values) == null ? void 0 : j.length) > 0;
3131
+ var E;
3132
+ return l.some((Y) => Y.field === k.field) && ((E = k.values) == null ? void 0 : E.length) > 0;
3127
3133
  }).map((k) => ({ field: k.field, values: k.values, labels: k.values.map(String) }));
3128
- pe(y), O(y), N(d.data.date_range ?? null), X(void 0), at("");
3134
+ J(y), F(y), S(d.data.date_range ?? null), P(void 0), at("");
3129
3135
  } catch (d) {
3130
3136
  nt(
3131
3137
  ((v = (b = d.response) == null ? void 0 : b.data) == null ? void 0 : v.error) ?? "Could not parse that"
@@ -3135,29 +3141,29 @@ function Yl({
3135
3141
  }
3136
3142
  }
3137
3143
  };
3138
- if (yt || !xe)
3139
- return /* @__PURE__ */ e("div", { className: Q("p-6 text-[13px] text-slate-400", m), children: "Loading report…" });
3140
- if (!re)
3141
- return /* @__PURE__ */ e("div", { className: Q("p-6 text-[13px] text-slate-400", m), children: "Report not found." });
3142
- const z = kl(H);
3143
- return /* @__PURE__ */ i("div", { className: Q("flex flex-col gap-3", m), children: [
3144
- z && (!n || s.length === 0 && l.length === 0) && /* @__PURE__ */ e("p", { className: "text-[11.5px] text-amber-700 dark:text-amber-300", children: z }),
3145
- n && (s.length > 0 || l.length > 0) && /* @__PURE__ */ i("div", { className: "space-y-1.5", children: [
3146
- /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-1.5", children: [
3147
- /* @__PURE__ */ i("span", { className: "flex items-center gap-1.5 text-[11.5px] font-semibold text-slate-500 dark:text-slate-300", children: [
3144
+ if (kt || !xe)
3145
+ return /* @__PURE__ */ e("div", { className: V("p-6 text-[13px] text-slate-400", m), children: "Loading report…" });
3146
+ if (!ne)
3147
+ return /* @__PURE__ */ e("div", { className: V("p-6 text-[13px] text-slate-400", m), children: "Report not found." });
3148
+ const j = Sl(B);
3149
+ return /* @__PURE__ */ o("div", { className: V("flex flex-col gap-3", m), children: [
3150
+ j && (!n || i.length === 0 && l.length === 0) && /* @__PURE__ */ e("p", { className: "text-[11.5px] text-amber-700 dark:text-amber-300", children: j }),
3151
+ n && (i.length > 0 || l.length > 0) && /* @__PURE__ */ o("div", { className: "space-y-1.5", children: [
3152
+ /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-1.5", children: [
3153
+ /* @__PURE__ */ o("span", { className: "flex items-center gap-1.5 text-[11.5px] font-semibold text-slate-500 dark:text-slate-300", children: [
3148
3154
  "Filters",
3149
- z && /* @__PURE__ */ e("span", { className: "font-normal text-amber-700 dark:text-amber-300", children: z }),
3150
- M > 0 && /* @__PURE__ */ i("span", { className: "rounded-full bg-emerald-50 px-1.5 py-px text-[10px] font-semibold text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400", children: [
3155
+ j && /* @__PURE__ */ e("span", { className: "font-normal text-amber-700 dark:text-amber-300", children: j }),
3156
+ q > 0 && /* @__PURE__ */ o("span", { className: "rounded-full bg-emerald-50 px-1.5 py-px text-[10px] font-semibold text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400", children: [
3151
3157
  "Active · ",
3152
- M
3158
+ q
3153
3159
  ] })
3154
3160
  ] }),
3155
3161
  /* @__PURE__ */ e(
3156
- Nt,
3162
+ wt,
3157
3163
  {
3158
3164
  value: (g == null ? void 0 : g.preset) ?? "",
3159
- onChange: (r) => X(r ? { preset: r } : null),
3160
- options: ll.map((r) => ({ value: r.id, label: r.label })),
3165
+ onChange: (r) => P(r ? { preset: r } : null),
3166
+ options: sl.map((r) => ({ value: r.id, label: r.label })),
3161
3167
  ariaLabel: "Date range",
3162
3168
  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"
3163
3169
  }
@@ -3165,15 +3171,15 @@ function Yl({
3165
3171
  l.map((r) => {
3166
3172
  var b;
3167
3173
  return /* @__PURE__ */ e(
3168
- na,
3174
+ sa,
3169
3175
  {
3170
3176
  reportId: t,
3171
3177
  field: r.field,
3172
3178
  label: r.label,
3173
3179
  optionSource: r.options,
3174
3180
  allowedValues: ge[r.field],
3175
- selected: ((b = ue.find((v) => v.field === r.field)) == null ? void 0 : b.values) ?? [],
3176
- onChange: (v, d) => pe((y) => [
3181
+ selected: ((b = me.find((v) => v.field === r.field)) == null ? void 0 : b.values) ?? [],
3182
+ onChange: (v, d) => J((y) => [
3177
3183
  ...y.filter((k) => k.field !== r.field),
3178
3184
  ...v.length > 0 ? [{ field: r.field, values: v, labels: d }] : []
3179
3185
  ])
@@ -3181,13 +3187,13 @@ function Yl({
3181
3187
  r.field
3182
3188
  );
3183
3189
  }),
3184
- /* @__PURE__ */ i(
3190
+ /* @__PURE__ */ o(
3185
3191
  "button",
3186
3192
  {
3187
3193
  type: "button",
3188
3194
  disabled: !$,
3189
3195
  onClick: K,
3190
- className: Q(
3196
+ className: V(
3191
3197
  "inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[11.5px] font-semibold",
3192
3198
  $ ? "bg-nvr-cyan text-white" : "bg-slate-100 text-slate-400 dark:bg-muted dark:text-slate-500"
3193
3199
  ),
@@ -3197,12 +3203,12 @@ function Yl({
3197
3203
  ]
3198
3204
  }
3199
3205
  ),
3200
- (M > 0 || $) && /* @__PURE__ */ i(
3206
+ (q > 0 || $) && /* @__PURE__ */ o(
3201
3207
  "button",
3202
3208
  {
3203
3209
  type: "button",
3204
3210
  className: "flex items-center gap-1 text-[11.5px] text-slate-400 hover:text-red-500",
3205
- onClick: ie,
3211
+ onClick: de,
3206
3212
  children: [
3207
3213
  /* @__PURE__ */ e(Ae, { className: "h-3 w-3" }),
3208
3214
  " Clear"
@@ -3210,13 +3216,13 @@ function Yl({
3210
3216
  }
3211
3217
  )
3212
3218
  ] }),
3213
- /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-1.5", children: [
3214
- Z.map((r) => /* @__PURE__ */ i(
3219
+ /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-1.5", children: [
3220
+ I.map((r) => /* @__PURE__ */ o(
3215
3221
  "span",
3216
3222
  {
3217
3223
  className: "group/preset inline-flex h-6 items-center gap-1 rounded-full border border-slate-200 pl-2 pr-1 text-[11px] text-slate-500 hover:border-nvr-cyan hover:text-nvr-navy dark:border-border dark:hover:text-nvr-cyan",
3218
3224
  children: [
3219
- /* @__PURE__ */ e("button", { type: "button", onClick: () => I(r), children: r.name }),
3225
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => te(r), children: r.name }),
3220
3226
  /* @__PURE__ */ e(
3221
3227
  "button",
3222
3228
  {
@@ -3231,24 +3237,24 @@ function Yl({
3231
3237
  },
3232
3238
  r.name
3233
3239
  )),
3234
- S ? /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1", children: /* @__PURE__ */ e(
3240
+ w ? /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1", children: /* @__PURE__ */ e(
3235
3241
  "input",
3236
3242
  {
3237
- value: le,
3238
- onChange: (r) => ae(r.target.value),
3243
+ value: re,
3244
+ onChange: (r) => le(r.target.value),
3239
3245
  placeholder: "Preset name",
3240
3246
  autoFocus: !0,
3241
3247
  onKeyDown: (r) => {
3242
- r.key === "Enter" && le.trim() && (V.mutate(le.trim()), ae(""), A(!1)), r.key === "Escape" && A(!1);
3248
+ r.key === "Enter" && re.trim() && (G.mutate(re.trim()), le(""), T(!1)), r.key === "Escape" && T(!1);
3243
3249
  },
3244
3250
  className: "h-6 w-[130px] rounded-md border border-slate-200 bg-white px-2 text-[11px] dark:border-border dark:bg-card"
3245
3251
  }
3246
- ) }) : /* @__PURE__ */ i(
3252
+ ) }) : /* @__PURE__ */ o(
3247
3253
  "button",
3248
3254
  {
3249
3255
  type: "button",
3250
3256
  className: "inline-flex h-6 items-center gap-1 rounded-full border border-dashed border-slate-200 px-2 text-[11px] text-slate-400 hover:border-slate-300 hover:text-slate-600 dark:border-border",
3251
- onClick: () => A(!0),
3257
+ onClick: () => T(!0),
3252
3258
  children: [
3253
3259
  /* @__PURE__ */ e(Yt, { className: "h-2.5 w-2.5" }),
3254
3260
  " Save preset"
@@ -3256,55 +3262,55 @@ function Yl({
3256
3262
  }
3257
3263
  ),
3258
3264
  /* @__PURE__ */ e("span", { className: "mx-1 h-4 w-px bg-slate-200 dark:bg-border" }),
3259
- /* @__PURE__ */ i(
3265
+ /* @__PURE__ */ o(
3260
3266
  "button",
3261
3267
  {
3262
3268
  type: "button",
3263
3269
  title: "Save the current numbers as a snapshot to compare against later",
3264
- disabled: P.isPending,
3265
- onClick: () => P.mutate(),
3270
+ disabled: z.isPending,
3271
+ onClick: () => z.mutate(),
3266
3272
  className: "inline-flex h-6 items-center gap-1 rounded-full border border-dashed border-slate-200 px-2 text-[11px] text-slate-400 hover:border-slate-300 hover:text-slate-600 disabled:opacity-40 dark:border-border",
3267
3273
  children: [
3268
- /* @__PURE__ */ e(wt, { className: "h-2.5 w-2.5" }),
3274
+ /* @__PURE__ */ e(St, { className: "h-2.5 w-2.5" }),
3269
3275
  " ",
3270
- P.isPending ? "Saving…" : "Snapshot"
3276
+ z.isPending ? "Saving…" : "Snapshot"
3271
3277
  ]
3272
3278
  }
3273
3279
  ),
3274
- fe.map((r) => /* @__PURE__ */ i(
3280
+ fe.map((r) => /* @__PURE__ */ o(
3275
3281
  "button",
3276
3282
  {
3277
3283
  type: "button",
3278
3284
  title: `Compare against ${r.name} (${new Date(r.taken_at).toLocaleDateString()})`,
3279
- onClick: () => J((b) => b === r.id ? null : r.id),
3280
- className: Q(
3285
+ onClick: () => H((b) => b === r.id ? null : r.id),
3286
+ className: V(
3281
3287
  "inline-flex h-6 items-center gap-1 rounded-full border px-2 text-[11px]",
3282
- E === r.id ? "border-nvr-cyan/40 bg-nvr-cyan/[0.08] font-medium text-[#007a99] dark:text-nvr-cyan" : "border-slate-200 text-slate-400 hover:text-slate-600 dark:border-border"
3288
+ Q === r.id ? "border-nvr-cyan/40 bg-nvr-cyan/[0.08] font-medium text-[#007a99] dark:text-nvr-cyan" : "border-slate-200 text-slate-400 hover:text-slate-600 dark:border-border"
3283
3289
  ),
3284
3290
  children: [
3285
- /* @__PURE__ */ e(wt, { className: "h-2.5 w-2.5" }),
3291
+ /* @__PURE__ */ e(St, { className: "h-2.5 w-2.5" }),
3286
3292
  " ",
3287
3293
  r.name,
3288
- E === r.id && /* @__PURE__ */ e(Ae, { className: "h-2.5 w-2.5" })
3294
+ Q === r.id && /* @__PURE__ */ e(Ae, { className: "h-2.5 w-2.5" })
3289
3295
  ]
3290
3296
  },
3291
3297
  r.id
3292
3298
  )),
3293
- E != null && /* @__PURE__ */ e(
3299
+ Q != null && /* @__PURE__ */ e(
3294
3300
  "button",
3295
3301
  {
3296
3302
  type: "button",
3297
3303
  title: "Time machine (#404): show the snapshot values AS the numbers, not as delta badges",
3298
- onClick: () => ce((r) => !r),
3299
- className: Q(
3304
+ onClick: () => ue((r) => !r),
3305
+ className: V(
3300
3306
  "inline-flex h-6 items-center gap-1 rounded-full border px-2 text-[11px]",
3301
- ne ? "border-amber-400 bg-amber-50 font-medium text-amber-700 dark:bg-amber-400/10 dark:text-amber-400" : "border-dashed border-slate-200 text-slate-400 hover:text-slate-600 dark:border-border"
3307
+ ie ? "border-amber-400 bg-amber-50 font-medium text-amber-700 dark:bg-amber-400/10 dark:text-amber-400" : "border-dashed border-slate-200 text-slate-400 hover:text-slate-600 dark:border-border"
3302
3308
  ),
3303
3309
  children: "As of"
3304
3310
  }
3305
3311
  ),
3306
3312
  /* @__PURE__ */ e("span", { className: "mx-1 h-4 w-px bg-slate-200 dark:bg-border" }),
3307
- /* @__PURE__ */ i("span", { className: "inline-flex h-7 min-w-[240px] flex-1 items-center gap-1.5 rounded-md border border-slate-200 bg-white px-2 dark:border-border dark:bg-card sm:max-w-[420px]", children: [
3313
+ /* @__PURE__ */ o("span", { className: "inline-flex h-7 min-w-[240px] flex-1 items-center gap-1.5 rounded-md border border-slate-200 bg-white px-2 dark:border-border dark:bg-card sm:max-w-[420px]", children: [
3308
3314
  /* @__PURE__ */ e("span", { className: "text-[11px] text-nvr-navy dark:text-nvr-cyan", children: "✦" }),
3309
3315
  /* @__PURE__ */ e(
3310
3316
  "input",
@@ -3312,7 +3318,7 @@ function Yl({
3312
3318
  value: Ve,
3313
3319
  onChange: (r) => at(r.target.value),
3314
3320
  onKeyDown: (r) => {
3315
- r.key === "Enter" && F();
3321
+ r.key === "Enter" && A();
3316
3322
  },
3317
3323
  placeholder: 'Describe filters… e.g. "Zone 1 CRAN this year"',
3318
3324
  className: "h-full min-w-0 flex-1 bg-transparent text-[11.5px] outline-none placeholder:text-slate-300 dark:text-slate-200"
@@ -3323,7 +3329,7 @@ function Yl({
3323
3329
  {
3324
3330
  type: "button",
3325
3331
  disabled: Je || !Ve.trim(),
3326
- onClick: () => void F(),
3332
+ onClick: () => void A(),
3327
3333
  className: "text-[11px] font-semibold text-nvr-navy disabled:opacity-40 dark:text-nvr-cyan",
3328
3334
  children: Je ? "…" : "Set"
3329
3335
  }
@@ -3332,20 +3338,20 @@ function Yl({
3332
3338
  rt && /* @__PURE__ */ e("span", { className: "text-[10.5px] text-red-400", children: rt })
3333
3339
  ] })
3334
3340
  ] }),
3335
- R.length > 0 && /* @__PURE__ */ i("div", { className: "mb-2 flex items-center gap-2 rounded-lg border border-red-300 bg-red-50 px-3 py-2 dark:border-red-500/40 dark:bg-red-500/10", children: [
3341
+ O.length > 0 && /* @__PURE__ */ o("div", { className: "mb-2 flex items-center gap-2 rounded-lg border border-red-300 bg-red-50 px-3 py-2 dark:border-red-500/40 dark:bg-red-500/10", children: [
3336
3342
  /* @__PURE__ */ e(Vt, { className: "h-3.5 w-3.5 shrink-0 text-red-500" }),
3337
- /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[12px] text-red-700 dark:text-red-300", children: R.length === 1 ? `Alert firing: ${R[0].name}` : `${R.length} alerts firing: ${R.map((r) => r.name).join(" · ")}` })
3343
+ /* @__PURE__ */ e("p", { className: "min-w-0 flex-1 truncate text-[12px] text-red-700 dark:text-red-300", children: O.length === 1 ? `Alert firing: ${O[0].name}` : `${O.length} alerts firing: ${O.map((r) => r.name).join(" · ")}` })
3338
3344
  ] }),
3339
- /* @__PURE__ */ i("div", { className: "mb-2 flex flex-wrap items-center gap-2", children: [
3340
- /* @__PURE__ */ i("span", { className: "text-[10.5px] text-slate-400", children: [
3345
+ /* @__PURE__ */ o("div", { className: "mb-2 flex flex-wrap items-center gap-2", children: [
3346
+ /* @__PURE__ */ o("span", { className: "text-[10.5px] text-slate-400", children: [
3341
3347
  "Data as of ",
3342
3348
  $t.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })
3343
3349
  ] }),
3344
- /* @__PURE__ */ i(
3350
+ /* @__PURE__ */ o(
3345
3351
  "button",
3346
3352
  {
3347
3353
  type: "button",
3348
- onClick: ht,
3354
+ onClick: ft,
3349
3355
  className: "inline-flex items-center gap-1 rounded-md border border-slate-200 px-2 py-0.5 text-[11px] text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400",
3350
3356
  children: [
3351
3357
  /* @__PURE__ */ e(Ft, { className: "h-2.5 w-2.5" }),
@@ -3353,19 +3359,19 @@ function Yl({
3353
3359
  ]
3354
3360
  }
3355
3361
  ),
3356
- /* @__PURE__ */ i("span", { className: "relative", children: [
3357
- /* @__PURE__ */ i(
3362
+ /* @__PURE__ */ o("span", { className: "relative", children: [
3363
+ /* @__PURE__ */ o(
3358
3364
  "button",
3359
3365
  {
3360
3366
  type: "button",
3361
3367
  onClick: () => _e((r) => !r),
3362
- className: Q(
3368
+ className: V(
3363
3369
  "inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-[11px]",
3364
- se ? "border-nvr-cyan/40 bg-nvr-cyan/[0.08] font-medium text-[#007a99] dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400"
3370
+ oe ? "border-nvr-cyan/40 bg-nvr-cyan/[0.08] font-medium text-[#007a99] dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400"
3365
3371
  ),
3366
3372
  children: [
3367
- se ? `Comparing ${se.a} vs ${se.b}` : "Compare A/B",
3368
- se && /* @__PURE__ */ e(
3373
+ oe ? `Comparing ${oe.a} vs ${oe.b}` : "Compare A/B",
3374
+ oe && /* @__PURE__ */ e(
3369
3375
  Ae,
3370
3376
  {
3371
3377
  className: "h-2.5 w-2.5",
@@ -3377,22 +3383,22 @@ function Yl({
3377
3383
  ]
3378
3384
  }
3379
3385
  ),
3380
- Qe && /* @__PURE__ */ i("span", { className: "absolute left-0 top-full z-50 mt-1 flex w-72 flex-col gap-1.5 rounded-xl border border-slate-200 bg-white p-2.5 shadow-lg dark:border-border dark:bg-card", children: [
3386
+ Qe && /* @__PURE__ */ o("span", { className: "absolute left-0 top-full z-50 mt-1 flex w-72 flex-col gap-1.5 rounded-xl border border-slate-200 bg-white p-2.5 shadow-lg dark:border-border dark:bg-card", children: [
3381
3387
  /* @__PURE__ */ e(
3382
3388
  "input",
3383
3389
  {
3384
- value: G,
3385
- onChange: (r) => ft(r.target.value),
3390
+ value: X,
3391
+ onChange: (r) => xt(r.target.value),
3386
3392
  placeholder: "Filter field (e.g. division)",
3387
3393
  className: "h-7 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-card dark:text-slate-200"
3388
3394
  }
3389
3395
  ),
3390
- /* @__PURE__ */ i("span", { className: "flex gap-1.5", children: [
3396
+ /* @__PURE__ */ o("span", { className: "flex gap-1.5", children: [
3391
3397
  /* @__PURE__ */ e(
3392
3398
  "input",
3393
3399
  {
3394
3400
  value: Ue,
3395
- onChange: (r) => xt(r.target.value),
3401
+ onChange: (r) => bt(r.target.value),
3396
3402
  placeholder: "Value A",
3397
3403
  className: "h-7 min-w-0 flex-1 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-card dark:text-slate-200"
3398
3404
  }
@@ -3401,7 +3407,7 @@ function Yl({
3401
3407
  "input",
3402
3408
  {
3403
3409
  value: Ye,
3404
- onChange: (r) => bt(r.target.value),
3410
+ onChange: (r) => gt(r.target.value),
3405
3411
  placeholder: "Value B",
3406
3412
  className: "h-7 min-w-0 flex-1 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-card dark:text-slate-200"
3407
3413
  }
@@ -3411,9 +3417,9 @@ function Yl({
3411
3417
  "button",
3412
3418
  {
3413
3419
  type: "button",
3414
- disabled: !G.trim() || !Ue.trim() || !Ye.trim(),
3420
+ disabled: !X.trim() || !Ue.trim() || !Ye.trim(),
3415
3421
  onClick: () => {
3416
- et({ field: G.trim(), a: Ue.trim(), b: Ye.trim() }), _e(!1);
3422
+ et({ field: X.trim(), a: Ue.trim(), b: Ye.trim() }), _e(!1);
3417
3423
  },
3418
3424
  className: "h-7 rounded-md bg-nvr-cyan text-[11.5px] font-semibold text-white hover:brightness-110 disabled:opacity-40",
3419
3425
  children: "Compare"
@@ -3422,7 +3428,7 @@ function Yl({
3422
3428
  ] })
3423
3429
  ] })
3424
3430
  ] }),
3425
- Y.filter((r) => !l.some((b) => b.field === r.field)).length > 0 && /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-1.5 px-1 pb-2", children: Y.filter((r) => !l.some((b) => b.field === r.field)).map((r) => /* @__PURE__ */ i(
3431
+ ee.filter((r) => !l.some((b) => b.field === r.field)).length > 0 && /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-1.5 px-1 pb-2", children: ee.filter((r) => !l.some((b) => b.field === r.field)).map((r) => /* @__PURE__ */ o(
3426
3432
  "span",
3427
3433
  {
3428
3434
  className: "inline-flex items-center gap-1.5 rounded-full border border-nvr-cyan/40 bg-nvr-cyan/[0.08] py-0.5 pl-2.5 pr-1 text-[11.5px] text-[#007a99] dark:text-nvr-cyan",
@@ -3436,7 +3442,7 @@ function Yl({
3436
3442
  type: "button",
3437
3443
  "aria-label": "Remove filter",
3438
3444
  onClick: () => {
3439
- O((b) => b.filter((v) => v.field !== r.field)), pe((b) => b.filter((v) => v.field !== r.field));
3445
+ F((b) => b.filter((v) => v.field !== r.field)), J((b) => b.filter((v) => v.field !== r.field));
3440
3446
  },
3441
3447
  className: "rounded-full p-0.5 hover:bg-nvr-cyan/[0.16]",
3442
3448
  children: /* @__PURE__ */ e(Ae, { className: "h-2.5 w-2.5" })
@@ -3446,7 +3452,7 @@ function Yl({
3446
3452
  },
3447
3453
  r.field
3448
3454
  )) }),
3449
- (re == null ? void 0 : re.editable) && /* @__PURE__ */ e("div", { className: "mb-2 flex items-center gap-1.5", children: ye ? /* @__PURE__ */ i(He, { children: [
3455
+ (ne == null ? void 0 : ne.editable) && /* @__PURE__ */ e("div", { className: "mb-2 flex items-center gap-1.5", children: ye ? /* @__PURE__ */ o(He, { children: [
3450
3456
  /* @__PURE__ */ e(
3451
3457
  "button",
3452
3458
  {
@@ -3473,19 +3479,19 @@ function Yl({
3473
3479
  "button",
3474
3480
  {
3475
3481
  type: "button",
3476
- onClick: gt,
3482
+ onClick: vt,
3477
3483
  className: "rounded-md border border-slate-200 px-3 py-1 text-[12px] font-medium text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400",
3478
3484
  children: "Edit report"
3479
3485
  }
3480
3486
  ) }),
3481
3487
  ye && ke && /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(qt, { fallback: null, children: /* @__PURE__ */ e(
3482
- el,
3488
+ ll,
3483
3489
  {
3484
3490
  maxY: Math.max(0, ...ke.map((r) => (r.y ?? 0) + (r.h ?? 1))),
3485
3491
  onAdd: (r) => Fe((b) => [...b ?? [], r])
3486
3492
  }
3487
3493
  ) }) }),
3488
- s.length === 0 && !ye ? /* @__PURE__ */ e("div", { className: "p-6 text-[13px] text-slate-400", children: h ?? "This report has no widgets yet." }) : /* @__PURE__ */ e(
3494
+ i.length === 0 && !ye ? /* @__PURE__ */ e("div", { className: "p-6 text-[13px] text-slate-400", children: h ?? "This report has no widgets yet." }) : /* @__PURE__ */ e(
3489
3495
  "div",
3490
3496
  {
3491
3497
  className: "grid gap-3",
@@ -3493,40 +3499,40 @@ function Yl({
3493
3499
  gridTemplateColumns: "repeat(12, minmax(0, 1fr))",
3494
3500
  gridAutoRows: ye ? void 0 : "72px"
3495
3501
  },
3496
- children: We(ye && ke ? ke : s).map((r) => {
3502
+ children: We(ye && ke ? ke : i).map((r) => {
3497
3503
  var b;
3498
3504
  return /* @__PURE__ */ e(
3499
3505
  "div",
3500
3506
  {
3501
3507
  style: {
3502
- gridColumn: se ? "1 / -1" : `${Math.max(1, (r.x ?? 0) + 1)} / span ${Math.min(12, Math.max(2, r.w || 4))}`,
3508
+ gridColumn: oe ? "1 / -1" : `${Math.max(1, (r.x ?? 0) + 1)} / span ${Math.min(12, Math.max(2, r.w || 4))}`,
3503
3509
  gridRow: void 0
3504
3510
  },
3505
- className: ye || se ? "" : "contents",
3506
- children: se && !ye && r.type !== "divider" ? /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: [se.a, se.b].map((v, d) => /* @__PURE__ */ i("div", { className: "flex min-h-[160px] flex-col", children: [
3507
- /* @__PURE__ */ i("p", { className: "mb-1 text-[10.5px] font-semibold uppercase tracking-wide text-[#007a99] dark:text-nvr-cyan", children: [
3508
- se.field.replace(/_/g, " "),
3511
+ className: ye || oe ? "" : "contents",
3512
+ children: oe && !ye && r.type !== "divider" ? /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: [oe.a, oe.b].map((v, d) => /* @__PURE__ */ o("div", { className: "flex min-h-[160px] flex-col", children: [
3513
+ /* @__PURE__ */ o("p", { className: "mb-1 text-[10.5px] font-semibold uppercase tracking-wide text-[#007a99] dark:text-nvr-cyan", children: [
3514
+ oe.field.replace(/_/g, " "),
3509
3515
  ": ",
3510
3516
  v
3511
3517
  ] }),
3512
3518
  /* @__PURE__ */ e(
3513
- Lt,
3519
+ Rt,
3514
3520
  {
3515
3521
  reportId: t,
3516
3522
  widget: r,
3517
- dateRange: Le,
3523
+ dateRange: Re,
3518
3524
  entityFilters: [
3519
- ...Y.filter((y) => y.field !== se.field),
3520
- { field: se.field, values: [v], labels: [v] }
3525
+ ...ee.filter((y) => y.field !== oe.field),
3526
+ { field: oe.field, values: [v], labels: [v] }
3521
3527
  ],
3522
3528
  refetchInterval: c,
3523
3529
  filterBar: l,
3524
- onDrill: U
3530
+ onDrill: W
3525
3531
  }
3526
3532
  )
3527
- ] }, d)) }) : /* @__PURE__ */ i(He, { children: [
3533
+ ] }, d)) }) : /* @__PURE__ */ o(He, { children: [
3528
3534
  ye && /* @__PURE__ */ e(qt, { fallback: null, children: /* @__PURE__ */ e(
3529
- al,
3535
+ nl,
3530
3536
  {
3531
3537
  widget: r,
3532
3538
  onConfigure: () => Ee(r.id),
@@ -3536,27 +3542,27 @@ function Yl({
3536
3542
  w: Math.min(12, Math.max(2, (r.w || 4) + v)),
3537
3543
  h: Math.min(8, Math.max(1, (r.h || 2) + d))
3538
3544
  }),
3539
- onMove: (v) => vt(r.id, v)
3545
+ onMove: (v) => yt(r.id, v)
3540
3546
  }
3541
3547
  ) }),
3542
3548
  /* @__PURE__ */ e(
3543
- Lt,
3549
+ Rt,
3544
3550
  {
3545
3551
  reportId: t,
3546
3552
  widget: r,
3547
- dateRange: Le,
3548
- entityFilters: Y,
3553
+ dateRange: Re,
3554
+ entityFilters: ee,
3549
3555
  refetchInterval: c,
3550
3556
  filterBar: l,
3551
- onDrill: U,
3557
+ onDrill: W,
3552
3558
  snapshot: _ && _.data[r.id] !== void 0 ? { name: _.name, value: ((b = _.data[r.id]) == null ? void 0 : b.value) ?? null } : null,
3553
- asOf: ne,
3554
- annotations: me.filter((v) => v.widget === r.id),
3559
+ asOf: ie,
3560
+ annotations: pe.filter((v) => v.widget === r.id),
3555
3561
  onAddAnnotation: (v, d, y) => we.mutate({ widget: v, note: d, anchor_date: y }),
3556
3562
  onDeleteAnnotation: (v) => Te.mutate(v),
3557
3563
  onCrossFilter: Xe,
3558
3564
  reportUrl: f,
3559
- currentFilters: Y
3565
+ currentFilters: ee
3560
3566
  }
3561
3567
  )
3562
3568
  ] })
@@ -3567,7 +3573,7 @@ function Yl({
3567
3573
  }
3568
3574
  ),
3569
3575
  ye && Ie && (ke == null ? void 0 : ke.some((r) => r.id === Ie)) && /* @__PURE__ */ e(qt, { fallback: null, children: /* @__PURE__ */ e(
3570
- tl,
3576
+ rl,
3571
3577
  {
3572
3578
  widget: ke.find((r) => r.id === Ie),
3573
3579
  allWidgets: ke,
@@ -3575,31 +3581,31 @@ function Yl({
3575
3581
  onClose: () => Ee(null)
3576
3582
  }
3577
3583
  ) }),
3578
- /* @__PURE__ */ e(Qa, {}),
3579
- !L && (w != null && w.length) ? /* @__PURE__ */ e(
3580
- Ba,
3584
+ /* @__PURE__ */ e(Va, {}),
3585
+ !R && (N != null && N.length) ? /* @__PURE__ */ e(
3586
+ Ya,
3581
3587
  {
3582
- collection: w[0].collection,
3583
- itemId: w[0].itemId,
3584
- title: w[0].title,
3588
+ collection: N[0].collection,
3589
+ itemId: N[0].itemId,
3590
+ title: N[0].title,
3585
3591
  width: "72%",
3586
- stack: w,
3587
- onPush: (r) => q.push([...w, r]),
3588
- onPop: () => q.back(),
3589
- onClose: () => q.back(w.length)
3592
+ stack: N,
3593
+ onPush: (r) => M.push([...N, r]),
3594
+ onPop: () => M.back(),
3595
+ onClose: () => M.back(N.length)
3590
3596
  }
3591
3597
  ) : null
3592
3598
  ] });
3593
3599
  }
3594
3600
  export {
3595
- xl as AlertBell,
3596
- oe as CHART_COLORS,
3597
- rl as NO_WORKFLOW_NUMBER,
3598
- ml as QueryWidgetBody,
3599
- Yl as ReportView,
3600
- Ul as ReportWidgetCard,
3601
- kl as adminAccessScopeNote,
3601
+ vl as AlertBell,
3602
+ ce as CHART_COLORS,
3603
+ il as NO_WORKFLOW_NUMBER,
3604
+ hl as QueryWidgetBody,
3605
+ Hl as ReportView,
3606
+ Gl as ReportWidgetCard,
3607
+ Sl as adminAccessScopeNote,
3602
3608
  je as fmtCell,
3603
- oa as shapeQueryRows,
3604
- yl as shortCategoryLabel
3609
+ da as shapeQueryRows,
3610
+ wl as shortCategoryLabel
3605
3611
  };