@nivaro/react 0.3.139 → 0.3.141

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