@nivaro/react 0.3.0 → 0.3.1

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