@nivaro/react 0.3.13 → 0.3.15

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