@nivaro/react 0.3.136 → 0.3.138

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 (50) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +95 -4
  4. package/dist/index.js +748 -743
  5. package/dist/shared/components/CollectionBrowserView.js +392 -389
  6. package/dist/shared/components/DelegateCoverLine.js +80 -87
  7. package/dist/shared/components/ItemEditForm.js +589 -588
  8. package/dist/shared/components/MyWorkView.js +284 -286
  9. package/dist/shared/components/NotificationBell.js +251 -205
  10. package/dist/shared/components/ai/AiAnalyticsView.js +878 -417
  11. package/dist/shared/components/ai/AiPlanCard.js +164 -122
  12. package/dist/shared/components/ai/AiPlanUndo.js +291 -0
  13. package/dist/shared/components/ai/call-log/CallDrawer.js +357 -0
  14. package/dist/shared/components/ai/call-log/RawJson.js +126 -0
  15. package/dist/shared/components/ai/call-log/ThreadView.js +223 -0
  16. package/dist/shared/components/ai/call-log/TranscriptView.js +227 -0
  17. package/dist/shared/components/ai/call-log/controls.js +364 -0
  18. package/dist/shared/components/ai/call-log/format.js +46 -0
  19. package/dist/shared/components/ai/call-log/url.js +105 -0
  20. package/dist/shared/components/chat/ChatPanel.js +86 -86
  21. package/dist/shared/components/chat/chat-core.js +422 -346
  22. package/dist/shared/components/integrations/IntegrationObligationsView.js +98 -98
  23. package/dist/shared/components/integrations/RecordIntegrationPreview.js +102 -93
  24. package/dist/shared/components/integrations/console/api.js +11 -1
  25. package/dist/shared/components/item-edit/HeaderRollupExplainer.js +5 -1
  26. package/dist/shared/components/item-edit/RecordLiveSync.js +241 -229
  27. package/dist/shared/components/item-edit/RecordRecapChanges.js +166 -0
  28. package/dist/shared/components/item-edit/RecordRecapStrip.js +254 -84
  29. package/dist/shared/components/item-edit/live-related.js +34 -18
  30. package/dist/shared/components/panels/RevisionsPanel.js +735 -683
  31. package/dist/shared/components/queue/QueueWorklist.js +323 -316
  32. package/dist/shared/components/support/SupportRequestDialog.js +198 -181
  33. package/dist/shared/components/trackers/use-tracker-link.js +74 -65
  34. package/dist/shared/lib/config-update-refresh.js +34 -0
  35. package/dist/shared/lib/config-watch.js +17 -17
  36. package/dist/shared/lib/gap-refresh.js +49 -0
  37. package/dist/shared/lib/integration-dots.js +8 -8
  38. package/dist/shared/lib/live-ops.js +26 -23
  39. package/dist/shared/lib/live-pickers.js +1 -1
  40. package/dist/shared/lib/live-queries.js +223 -195
  41. package/dist/shared/lib/live.js +56 -51
  42. package/dist/shared/lib/obligation-banner.js +11 -10
  43. package/dist/shared/lib/obligation-filters.js +22 -18
  44. package/dist/shared/lib/obligation-reason-text.js +18 -8
  45. package/dist/shared/lib/presence-hooks.js +133 -132
  46. package/dist/shared/lib/reconnect-resync.js +90 -0
  47. package/dist/shared/lib/record-room-holds.js +43 -0
  48. package/dist/shared/lib/socket-realtime.js +116 -105
  49. package/dist/shared/lib/user-sync.js +1 -6
  50. package/package.json +1 -1
@@ -1,437 +1,898 @@
1
- import { jsxs as r, jsx as e, Fragment as E } from "react/jsx-runtime";
2
- import { useQuery as _ } from "@tanstack/react-query";
3
- import { RotateCw as O, ChevronDown as j, ChevronRight as Q } from "lucide-react";
4
- import { useState as g } from "react";
5
- import { useNivaroClient as C } from "../../context.js";
6
- import { get as w } from "../../lib/commands.js";
7
- import { cn as y, formatRelative as T, formatDateTime as P } from "../../lib/utils.js";
8
- const H = [
9
- { label: "24h", hours: 24 },
10
- { label: "7d", hours: 168 },
11
- { label: "30d", hours: 720 }
12
- ], m = (d, s = 2) => d == null ? "—" : `$${d.toFixed(d < 0.1 && d > 0 ? 4 : s)}`, c = (d) => d == null ? "—" : d.toLocaleString(), u = (d) => d == null ? "—" : d >= 1e6 ? `${(d / 1e6).toFixed(2)}M` : d >= 1e4 ? `${(d / 1e3).toFixed(1)}k` : d.toLocaleString();
13
- function p({ label: d, value: s, sub: n }) {
14
- return /* @__PURE__ */ r("div", { className: "rounded-lg border border-border bg-card px-3 py-2.5", "data-ai-tile": d, children: [
15
- /* @__PURE__ */ e("div", { className: "text-[10.5px] uppercase tracking-wide text-muted-foreground", children: d }),
16
- /* @__PURE__ */ e("div", { className: "mt-0.5 text-lg font-semibold tabular-nums", children: s }),
17
- n ? /* @__PURE__ */ e("div", { className: "text-[11px] text-muted-foreground", children: n }) : null
18
- ] });
19
- }
20
- function G({ series: d }) {
21
- const s = Math.max(1, ...d.map((n) => n.calls));
22
- return d.length === 0 ? /* @__PURE__ */ e("p", { className: "py-6 text-center text-[12px] text-muted-foreground", children: "No AI calls in this window." }) : /* @__PURE__ */ e("div", { className: "flex h-28 items-end gap-[3px] overflow-x-auto", "data-ai-series": !0, children: d.map((n) => /* @__PURE__ */ e(
23
- "div",
1
+ import { jsxs as o, jsx as t, Fragment as M } from "react/jsx-runtime";
2
+ import { useQuery as j } from "@tanstack/react-query";
3
+ import { Search as ge, Download as ve, RotateCw as ye, X as ke, ArrowUp as we, ArrowDown as Ne, ArrowUpDown as _e, MessagesSquare as $e, ThumbsUp as Ce, ThumbsDown as Se } from "lucide-react";
4
+ import { useMemo as re, useState as K, useEffect as se } from "react";
5
+ import { useNivaroClient as me, useApiFetchConfig as qe } from "../../context.js";
6
+ import { get as Q } from "../../lib/commands.js";
7
+ import { cn as g } from "../../lib/utils.js";
8
+ import { Segmented as oe, Panel as he, ShareBar as Te, OutcomeChip as De } from "../delivery-analytics/ui.js";
9
+ import { useParamState as Me } from "../delivery-analytics/url.js";
10
+ import { QueryErrorState as ne } from "../QueryErrorState.js";
11
+ import { Skeleton as B } from "../ui/skeleton.js";
12
+ import { CallDrawer as Oe } from "./call-log/CallDrawer.js";
13
+ import { SavedViews as Pe, MultiPicker as q, MoreFilters as Re } from "./call-log/controls.js";
14
+ import { whenShort as L, featureLabel as F, resultLabel as W, num as u, usd as v, tok as w, secs as T, pctOf as ie, bucketLabel as Le, bucketRange as Ae, resultOf as Fe } from "./call-log/format.js";
15
+ import { apiFilter as Ie, activeChips as Ee, WINDOWS as Ke, clearFilters as de, listOf as N, toggleIn as Be } from "./call-log/url.js";
16
+ const U = 50, Ue = {
17
+ error: "failed",
18
+ max_tokens: "dropped",
19
+ stopped: "suppressed",
20
+ end_turn: "delivered",
21
+ tool_use: "deferred"
22
+ }, je = ["ok", "error", "end_turn", "tool_use", "max_tokens", "stopped"], ce = [
23
+ { key: "when", label: "When" },
24
+ { key: "feature", label: "Question / feature" },
25
+ { key: "person", label: "Person" },
26
+ { key: "model", label: "Model" },
27
+ { key: "in", label: "In", right: !0, tip: "Input tokens (cached ones included)" },
28
+ { key: "cached", label: "Cached", right: !0, tip: "Input tokens read from the prompt cache" },
29
+ { key: "out", label: "Out", right: !0, tip: "Output tokens" },
30
+ { key: "cost", label: "Cost", right: !0, tip: "At list price" },
31
+ { key: "time", label: "Time", right: !0 },
32
+ { key: "result", label: "Result" }
33
+ ];
34
+ function k({
35
+ label: s,
36
+ value: d,
37
+ sub: h,
38
+ onClick: i,
39
+ active: r,
40
+ tip: a,
41
+ className: f
42
+ }) {
43
+ const c = /* @__PURE__ */ o(M, { children: [
44
+ /* @__PURE__ */ t("div", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children: s }),
45
+ /* @__PURE__ */ t("div", { className: "mt-0.5 text-[17px] font-semibold tabular-nums tracking-[-0.01em] text-slate-900 dark:text-foreground", children: d }),
46
+ h ? /* @__PURE__ */ t("div", { className: "truncate text-[11px] text-slate-500 dark:text-muted-foreground", children: h }) : null
47
+ ] }), p = g(
48
+ "min-w-0 bg-white px-3 py-2.5 text-left dark:bg-card",
49
+ f,
50
+ r && "bg-nvr-cyan/10 dark:bg-nvr-cyan/10"
51
+ );
52
+ return i ? /* @__PURE__ */ t(
53
+ "button",
24
54
  {
25
- className: "group relative flex min-w-[6px] flex-1 flex-col justify-end",
26
- "data-tip": `${n.bucket} · ${n.calls} calls · ${n.errors} errors · ${m(n.cost_usd)}`,
27
- children: /* @__PURE__ */ e(
28
- "div",
29
- {
30
- className: y("rounded-t-sm", n.errors > 0 ? "bg-amber-500/80" : "bg-nvr-cyan/70"),
31
- style: { height: `${Math.max(2, n.calls / s * 100)}%` }
32
- }
33
- )
34
- },
35
- n.bucket
36
- )) });
55
+ type: "button",
56
+ onClick: i,
57
+ "aria-pressed": r,
58
+ "data-tip": a,
59
+ className: g(
60
+ p,
61
+ "transition-colors hover:bg-slate-50 focus-visible:relative focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-nvr-cyan/50 dark:hover:bg-muted/50"
62
+ ),
63
+ children: c
64
+ }
65
+ ) : /* @__PURE__ */ t("div", { className: p, "data-tip": a, children: c });
37
66
  }
38
- function K({ value: d }) {
39
- const s = typeof d == "string" ? d : JSON.stringify(d, null, 2);
40
- return /* @__PURE__ */ e("pre", { className: "max-h-[420px] overflow-auto whitespace-pre-wrap break-words rounded-md bg-black/[0.04] p-2 font-mono text-[11px] leading-snug dark:bg-white/[0.06]", children: s });
67
+ function Qe(s) {
68
+ const d = s.bucket === "hour" ? 36e5 : 864e5, h = (p) => {
69
+ const b = new Date(p).toISOString();
70
+ return s.bucket === "hour" ? b.slice(0, 13) : b.slice(0, 10);
71
+ }, i = new Date(s.from).getTime(), r = new Date(s.to).getTime(), a = Math.floor(i / d) * d;
72
+ if (!Number.isFinite(a) || (r - a) / d > 2200) return s.series;
73
+ const f = new Map(s.series.map((p) => [p.bucket, p])), c = [];
74
+ for (let p = a; p < r; p += d) {
75
+ const b = h(p);
76
+ c.push(f.get(b) ?? { bucket: b, calls: 0, errors: 0, cost_usd: 0 });
77
+ }
78
+ return c;
41
79
  }
42
- function J({ id: d }) {
43
- const s = C(), { data: n, isLoading: o } = _({
44
- queryKey: ["nvr-ai-call", d],
45
- queryFn: () => s.request(w(`/ai/calls/${d}`))
46
- });
47
- if (o) return /* @__PURE__ */ e("p", { className: "text-[12px] text-muted-foreground", children: "Loading…" });
48
- const i = n == null ? void 0 : n.data;
49
- return i ? /* @__PURE__ */ r("div", { className: "grid gap-3 lg:grid-cols-2", "data-ai-call-detail": !0, children: [
50
- /* @__PURE__ */ r("div", { children: [
51
- /* @__PURE__ */ e("div", { className: "mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: "Request" }),
52
- /* @__PURE__ */ e(K, { value: i.request ?? "(not stored)" })
53
- ] }),
54
- /* @__PURE__ */ r("div", { children: [
55
- /* @__PURE__ */ e("div", { className: "mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: i.status === "error" ? "Error" : "Response" }),
56
- /* @__PURE__ */ e(K, { value: i.status === "error" ? i.error : i.response ?? "(not stored)" })
57
- ] })
58
- ] }) : null;
80
+ function We({ s, onPick: d }) {
81
+ const h = Qe(s), i = Math.max(1, ...h.map((r) => r.calls));
82
+ return s.series.length ? /* @__PURE__ */ t("div", { className: "flex h-28 items-end gap-px overflow-x-auto px-4 pb-3 pt-2", "data-ai-series": !0, children: h.map((r) => {
83
+ const a = Le(r.bucket, s.bucket), f = r.calls / i * 100;
84
+ return /* @__PURE__ */ t(
85
+ "button",
86
+ {
87
+ type: "button",
88
+ disabled: r.calls === 0,
89
+ onClick: () => d(r.bucket),
90
+ "aria-label": `${a}: ${u(r.calls)} calls, ${u(r.errors)} errors, ${v(r.cost_usd)}. Show only these calls`,
91
+ "data-tip": `${a} · ${u(r.calls)} calls${r.errors ? ` · ${u(r.errors)} errors` : ""} · ${v(r.cost_usd)}`,
92
+ className: "group flex h-full min-w-[3px] flex-1 flex-col justify-end rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:cursor-default",
93
+ children: r.calls > 0 && /* @__PURE__ */ o(
94
+ "span",
95
+ {
96
+ className: "flex flex-col overflow-hidden rounded-t-sm",
97
+ style: { height: `${Math.max(3, f)}%` },
98
+ children: [
99
+ r.errors > 0 && /* @__PURE__ */ t(
100
+ "span",
101
+ {
102
+ className: "block bg-amber-500/90",
103
+ style: { height: `${Math.max(8, r.errors / r.calls * 100)}%` }
104
+ }
105
+ ),
106
+ /* @__PURE__ */ t("span", { className: "block flex-1 bg-nvr-cyan/60 transition-colors group-hover:bg-nvr-cyan" })
107
+ ]
108
+ }
109
+ )
110
+ },
111
+ r.bucket
112
+ );
113
+ }) }) : /* @__PURE__ */ t("p", { className: "px-4 py-8 text-center text-[12px] text-slate-500", children: "No calls in this window." });
59
114
  }
60
- function te() {
61
- var L, R, B;
62
- const d = C(), [s, n] = g(168), [o, i] = g(""), [l, $] = g(""), [x, S] = g(""), [h, b] = g(1), [v, D] = g(null), F = _({
63
- queryKey: ["nvr-ai-analytics", s],
64
- queryFn: () => d.request(w("/ai/analytics", { hours: s })),
65
- refetchInterval: 6e4
66
- }), k = _({
67
- queryKey: ["nvr-ai-calls", s, o, l, x, h],
68
- queryFn: () => d.request(
69
- w("/ai/calls", {
70
- hours: s,
71
- ...o ? { feature: o } : {},
72
- ...l ? { status: l } : {},
73
- ...x ? { request_id: x } : {},
74
- page: h,
75
- limit: 50
76
- })
77
- ),
78
- placeholderData: (t) => t
79
- }), a = (L = F.data) == null ? void 0 : L.data, M = ((R = k.data) == null ? void 0 : R.data) ?? [], A = ((B = k.data) == null ? void 0 : B.total) ?? 0, I = Math.max(1, Math.ceil(A / 50));
80
- return /* @__PURE__ */ r("div", { className: "flex flex-col gap-4", "data-ai-analytics": !0, children: [
81
- /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", children: [
82
- /* @__PURE__ */ e("div", { className: "inline-flex rounded-md border border-border p-0.5", children: H.map((t) => /* @__PURE__ */ e(
115
+ function A({
116
+ title: s,
117
+ rows: d,
118
+ label: h,
119
+ activeKeys: i,
120
+ onPick: r,
121
+ extra: a
122
+ }) {
123
+ const f = Math.max(1, ...d.map((c) => c.calls));
124
+ return /* @__PURE__ */ t(he, { title: s, id: s, children: d.length === 0 ? /* @__PURE__ */ t("p", { className: "px-4 py-6 text-center text-[12px] text-slate-500", children: "Nothing in this filter." }) : /* @__PURE__ */ t("ul", { className: "max-h-[300px] divide-y divide-slate-100 overflow-y-auto dark:divide-border/60", children: d.map((c) => {
125
+ const p = c.key ?? "system", b = i.includes(p);
126
+ return /* @__PURE__ */ t("li", { children: /* @__PURE__ */ o(
127
+ "button",
128
+ {
129
+ type: "button",
130
+ onClick: () => r(p),
131
+ "aria-pressed": b,
132
+ className: g(
133
+ "grid w-full grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 px-4 py-2 text-left text-[12px] transition-colors hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-nvr-cyan/50 dark:hover:bg-muted/40",
134
+ b && "bg-nvr-cyan/10 hover:bg-nvr-cyan/15 dark:bg-nvr-cyan/10"
135
+ ),
136
+ children: [
137
+ /* @__PURE__ */ t("span", { className: "min-w-0 truncate font-medium text-slate-800 dark:text-slate-100", children: h(c) }),
138
+ /* @__PURE__ */ o("span", { className: "tabular-nums text-slate-600 dark:text-muted-foreground", children: [
139
+ u(c.calls),
140
+ " · ",
141
+ v(c.cost_usd),
142
+ c.errors ? /* @__PURE__ */ o("span", { className: "ml-1 text-red-700 dark:text-[#eaa3a3]", children: [
143
+ "· ",
144
+ u(c.errors),
145
+ " err"
146
+ ] }) : null
147
+ ] }),
148
+ /* @__PURE__ */ t("span", { className: "col-span-2", children: /* @__PURE__ */ t(Te, { value: c.calls, max: f }) }),
149
+ a && /* @__PURE__ */ t("span", { className: "col-span-2 text-[11px] text-slate-500", children: a(c) })
150
+ ]
151
+ }
152
+ ) }, p);
153
+ }) }) });
154
+ }
155
+ function He({
156
+ col: s,
157
+ sort: d,
158
+ onSort: h
159
+ }) {
160
+ const i = d.key === s.key, r = i ? d.dir === "asc" ? we : Ne : _e;
161
+ return /* @__PURE__ */ t(
162
+ "th",
163
+ {
164
+ scope: "col",
165
+ "aria-sort": i ? d.dir === "asc" ? "ascending" : "descending" : "none",
166
+ className: g("whitespace-nowrap px-2 py-2 font-semibold", s.right && "text-right"),
167
+ children: /* @__PURE__ */ o(
83
168
  "button",
84
169
  {
85
170
  type: "button",
86
- onClick: () => {
87
- n(t.hours), b(1);
88
- },
89
- className: y(
90
- "rounded px-2.5 py-1 text-[12px]",
91
- s === t.hours ? "bg-nvr-cyan/15 font-medium" : "text-muted-foreground hover:bg-muted"
171
+ onClick: () => h(s.key),
172
+ "data-tip": s.tip,
173
+ className: g(
174
+ "inline-flex items-center gap-1 rounded hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:hover:text-foreground",
175
+ i && "text-slate-900 dark:text-foreground",
176
+ s.right && "flex-row-reverse"
92
177
  ),
93
- children: t.label
94
- },
95
- t.hours
96
- )) }),
97
- /* @__PURE__ */ r(
178
+ children: [
179
+ s.label,
180
+ /* @__PURE__ */ t(r, { className: g("h-3 w-3", i ? "opacity-90" : "opacity-30"), "aria-hidden": !0 })
181
+ ]
182
+ }
183
+ )
184
+ }
185
+ );
186
+ }
187
+ function Ve({ fb: s }) {
188
+ return !s || !s.up && !s.down ? null : /* @__PURE__ */ o("span", { className: "ml-1 inline-flex items-center gap-1 align-middle", children: [
189
+ s.up > 0 && /* @__PURE__ */ t(
190
+ Ce,
191
+ {
192
+ className: "h-3 w-3 text-green-700 dark:text-[#b9d3a6]",
193
+ "aria-label": `${s.up} thumbs up`
194
+ }
195
+ ),
196
+ s.down > 0 && /* @__PURE__ */ t(
197
+ Se,
198
+ {
199
+ className: "h-3 w-3 text-red-700 dark:text-[#eaa3a3]",
200
+ "aria-label": `${s.down} thumbs down`
201
+ }
202
+ )
203
+ ] });
204
+ }
205
+ function ue({ r: s }) {
206
+ const d = Fe(s);
207
+ return /* @__PURE__ */ o("span", { className: "inline-flex items-center gap-1 whitespace-nowrap", children: [
208
+ /* @__PURE__ */ t(De, { outcome: Ue[d] ?? "neutral", children: W(d) }),
209
+ s.tool_calls ? /* @__PURE__ */ o("span", { className: "text-[11px] text-slate-500", "data-tip": s.tools.join(", ") || void 0, children: [
210
+ s.tool_calls,
211
+ " tool",
212
+ s.tool_calls === 1 ? "" : "s"
213
+ ] }) : null,
214
+ /* @__PURE__ */ t(Ve, { fb: s.feedback })
215
+ ] });
216
+ }
217
+ function ze({ r: s, onRequest: d }) {
218
+ return /* @__PURE__ */ o("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
219
+ s.question ? /* @__PURE__ */ t(
220
+ "span",
221
+ {
222
+ className: "line-clamp-1 text-slate-900 dark:text-foreground",
223
+ "data-tip": s.question.length > 80 ? s.question : void 0,
224
+ children: s.question
225
+ }
226
+ ) : null,
227
+ /* @__PURE__ */ o("span", { className: "flex min-w-0 items-center gap-1.5 text-[11px] text-slate-500 dark:text-muted-foreground", children: [
228
+ /* @__PURE__ */ t("span", { className: "rounded bg-slate-100 px-1.5 py-px text-slate-700 dark:bg-muted dark:text-slate-300", children: F(s.feature) }),
229
+ s.request_id ? /* @__PURE__ */ o(
98
230
  "button",
99
231
  {
100
232
  type: "button",
101
- onClick: () => {
102
- F.refetch(), k.refetch();
233
+ className: "rounded underline-offset-2 hover:text-slate-900 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:hover:text-foreground",
234
+ "data-tip": "Show every call of this question",
235
+ onClick: (h) => {
236
+ h.stopPropagation(), d(s.request_id);
103
237
  },
104
- className: "inline-flex h-7 items-center gap-1 rounded-md border border-border px-2 text-[12px] text-muted-foreground hover:bg-muted",
105
238
  children: [
106
- /* @__PURE__ */ e(O, { className: "h-3.5 w-3.5" }),
107
- " Refresh"
239
+ "#",
240
+ s.request_id.slice(0, 6)
108
241
  ]
109
242
  }
243
+ ) : null,
244
+ s.conversation_id ? /* @__PURE__ */ t($e, { className: "h-3 w-3", "aria-label": "Part of a saved conversation" }) : null
245
+ ] })
246
+ ] });
247
+ }
248
+ function ut({
249
+ search: s,
250
+ onSearchChange: d
251
+ } = {}) {
252
+ var te, ae, le;
253
+ const h = me(), i = qe(), [r, a] = Me(s, d), f = re(() => Ie(r).toString(), [r]), c = r.get("sort") ?? "-when", p = {
254
+ key: c.replace(/^[+-]/, "") || "when",
255
+ dir: c.startsWith("+") ? "asc" : "desc"
256
+ }, b = Math.max(1, Number(r.get("page")) || 1), H = Number(r.get("call")) || null, I = r.get("window") ?? "7d", y = j({
257
+ queryKey: ["nvr-ai-call-log-summary", f],
258
+ queryFn: () => h.request(
259
+ Q("/ai/call-log/summary", Object.fromEntries(new URLSearchParams(f)))
260
+ ),
261
+ placeholderData: (e) => e,
262
+ refetchInterval: 12e4
263
+ }), x = j({
264
+ queryKey: ["nvr-ai-call-log", f, c, b],
265
+ queryFn: () => h.request(
266
+ Q("/ai/call-log", {
267
+ ...Object.fromEntries(new URLSearchParams(f)),
268
+ sort: c,
269
+ page: b,
270
+ limit: U
271
+ })
272
+ ),
273
+ placeholderData: (e) => e
274
+ }), l = (te = y.data) == null ? void 0 : te.data, O = ((ae = x.data) == null ? void 0 : ae.data) ?? [], _ = ((le = x.data) == null ? void 0 : le.total) ?? 0, P = Math.max(1, Math.ceil(_ / U)), V = y.isPlaceholderData || x.isPlaceholderData, [$, z] = K(r.get("q") ?? "");
275
+ se(() => z(r.get("q") ?? ""), [r]), se(() => {
276
+ const e = r.get("q") ?? "";
277
+ if ($.trim() === e) return;
278
+ const n = setTimeout(
279
+ () => a(
280
+ (m) => {
281
+ $.trim() ? m.set("q", $.trim()) : m.delete("q"), m.delete("page");
282
+ },
283
+ { replace: !0 }
110
284
  ),
111
- /* @__PURE__ */ e("span", { className: "text-[11.5px] text-muted-foreground", children: "Every model call through the AI provider, with tokens and list-price cost. Bodies are kept 30 days." })
112
- ] }),
113
- /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-2 md:grid-cols-4 xl:grid-cols-8", children: [
114
- /* @__PURE__ */ e(p, { label: "Questions", value: c(a == null ? void 0 : a.requests), sub: "requests to the API" }),
115
- /* @__PURE__ */ e(
116
- p,
117
- {
118
- label: "Model calls",
119
- value: c(a == null ? void 0 : a.calls),
120
- sub: a ? `${(a.calls / Math.max(1, a.requests)).toFixed(1)} per question` : void 0
121
- }
122
- ),
123
- /* @__PURE__ */ e(p, { label: "Spend", value: m(a == null ? void 0 : a.cost_usd), sub: "list price" }),
124
- /* @__PURE__ */ e(
125
- p,
126
- {
127
- label: "Errors",
128
- value: c(a == null ? void 0 : a.errors),
129
- sub: a && a.calls ? `${(a.errors / a.calls * 100).toFixed(1)}%` : void 0
130
- }
131
- ),
132
- /* @__PURE__ */ e(
133
- p,
134
- {
135
- label: "Input tokens",
136
- value: u(a == null ? void 0 : a.input_tokens),
137
- sub: a ? `${u(a.cache_read_tokens)} from cache` : void 0
138
- }
139
- ),
140
- /* @__PURE__ */ e(p, { label: "Output tokens", value: u(a == null ? void 0 : a.output_tokens) }),
141
- /* @__PURE__ */ e(
142
- p,
143
- {
144
- label: "Latency p50",
145
- value: a ? `${(a.p50 / 1e3).toFixed(1)}s` : "—",
146
- sub: a ? `avg ${(a.avg_latency / 1e3).toFixed(1)}s` : void 0
147
- }
148
- ),
149
- /* @__PURE__ */ e(
150
- p,
151
- {
152
- label: "Latency p95",
153
- value: a ? `${(a.p95 / 1e3).toFixed(1)}s` : "—",
154
- sub: a ? `${c(a.tool_calls)} tool calls` : void 0
155
- }
156
- ),
157
- /* @__PURE__ */ e(
158
- p,
159
- {
160
- label: "Helpful",
161
- value: a != null && a.feedback && a.feedback.up + a.feedback.down > 0 ? `${Math.round(a.feedback.up / (a.feedback.up + a.feedback.down) * 100)}%` : "—",
162
- sub: a != null && a.feedback ? `${c(a.feedback.up)} up · ${c(a.feedback.down)} down` : void 0
163
- }
164
- )
165
- ] }),
166
- /* @__PURE__ */ r("div", { className: "rounded-lg border border-border bg-card p-3", children: [
167
- /* @__PURE__ */ r("div", { className: "mb-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: [
168
- "Calls ",
169
- s <= 48 ? "per hour" : "per day"
285
+ 350
286
+ );
287
+ return () => clearTimeout(n);
288
+ }, [$, r, a]);
289
+ const be = re(
290
+ () => new Map(((l == null ? void 0 : l.facets.people) ?? []).map((e) => [e.value, e.label])),
291
+ [l == null ? void 0 : l.facets.people]
292
+ ), E = Ee(r, { people: be }), C = (e, n) => a((m) => Be(m, e, n)), G = (e) => a(
293
+ (n) => {
294
+ const m = p.key === e ? p.dir === "desc" ? `+${e}` : `-${e}` : `-${e}`;
295
+ m === "-when" ? n.delete("sort") : n.set("sort", m), n.delete("page");
296
+ },
297
+ { replace: !0 }
298
+ ), R = (e) => a((n) => {
299
+ n.set("call", String(e)), n.delete("thread");
300
+ }), fe = (e) => {
301
+ if (!l) return;
302
+ const n = Ae(e, l.bucket);
303
+ n && a((m) => {
304
+ m.set("window", "custom"), m.set("from", n.from), m.set("to", n.to), m.delete("page");
305
+ });
306
+ }, [X, J] = K(!1), [Y, Z] = K(!1), xe = async () => {
307
+ J(!0), Z(!1);
308
+ try {
309
+ const e = await fetch(`${i.apiBase}/ai/call-log/export?${f}`, {
310
+ headers: i.authHeaders,
311
+ credentials: i.credentials
312
+ });
313
+ if (!e.ok) throw new Error(String(e.status));
314
+ const n = await e.blob(), m = URL.createObjectURL(n), S = document.createElement("a");
315
+ S.href = m, S.download = `ai-calls-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.csv`, document.body.appendChild(S), S.click(), S.remove(), setTimeout(() => URL.revokeObjectURL(m), 3e4);
316
+ } catch {
317
+ Z(!0);
318
+ } finally {
319
+ J(!1);
320
+ }
321
+ }, ee = I === "custom" && r.get("from") ? `${L(r.get("from"))} – ${r.get("to") ? L(r.get("to")) : "now"}` : null;
322
+ return /* @__PURE__ */ o("div", { className: "flex flex-col gap-4", "data-ai-analytics": !0, children: [
323
+ /* @__PURE__ */ o("div", { className: "flex flex-col gap-2", children: [
324
+ /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-2", children: [
325
+ /* @__PURE__ */ t(
326
+ oe,
327
+ {
328
+ ariaLabel: "Window",
329
+ value: I === "custom" ? "custom" : I,
330
+ onChange: (e) => a((n) => {
331
+ e !== "custom" && (n.set("window", e), n.delete("from"), n.delete("to"), n.delete("page"));
332
+ }),
333
+ options: [
334
+ ...Ke.map((e) => ({ value: e.value, label: e.label })),
335
+ ...ee ? [{ value: "custom", label: ee }] : []
336
+ ]
337
+ }
338
+ ),
339
+ /* @__PURE__ */ o("label", { className: "relative flex min-w-[200px] flex-1 items-center sm:max-w-[360px]", children: [
340
+ /* @__PURE__ */ t("span", { className: "sr-only", children: "Search the questions people asked" }),
341
+ /* @__PURE__ */ t(
342
+ ge,
343
+ {
344
+ className: "pointer-events-none absolute left-2.5 h-3.5 w-3.5 text-slate-400",
345
+ "aria-hidden": !0
346
+ }
347
+ ),
348
+ /* @__PURE__ */ t(
349
+ "input",
350
+ {
351
+ type: "search",
352
+ value: $,
353
+ onChange: (e) => z(e.target.value),
354
+ placeholder: l && !l.search_ready ? "Search needs migration 539" : "Search the questions people asked",
355
+ disabled: !!l && !l.search_ready,
356
+ "data-ai-search": !0,
357
+ className: "h-8 w-full rounded-md border border-slate-200 bg-white pl-8 pr-2 text-[12.5px] text-slate-900 placeholder:text-slate-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:opacity-60 dark:border-border dark:bg-card dark:text-foreground"
358
+ }
359
+ )
360
+ ] }),
361
+ /* @__PURE__ */ o("div", { className: "ml-auto flex items-center gap-2", children: [
362
+ /* @__PURE__ */ t(Pe, { params: r, setParams: a }),
363
+ /* @__PURE__ */ o(
364
+ "button",
365
+ {
366
+ type: "button",
367
+ onClick: () => void xe(),
368
+ disabled: X || _ === 0,
369
+ "data-tip": Y ? "The download failed. Try again." : "Every call in this filter, newest first",
370
+ className: g(
371
+ "inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-[12px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:opacity-50",
372
+ Y ? "border-red-300 text-red-700 dark:border-[#e08383]/40 dark:text-[#eaa3a3]" : "border-slate-200 bg-white text-slate-600 hover:bg-slate-50 dark:border-border dark:bg-card dark:text-muted-foreground dark:hover:bg-muted"
373
+ ),
374
+ children: [
375
+ /* @__PURE__ */ t(ve, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
376
+ X ? "Preparing…" : "CSV"
377
+ ]
378
+ }
379
+ ),
380
+ /* @__PURE__ */ t(
381
+ "button",
382
+ {
383
+ type: "button",
384
+ "aria-label": "Refresh",
385
+ "data-tip": "Refresh",
386
+ onClick: () => {
387
+ y.refetch(), x.refetch();
388
+ },
389
+ className: "inline-flex h-8 w-8 items-center justify-center rounded-md border border-slate-200 bg-white text-slate-500 hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:border-border dark:bg-card dark:hover:bg-muted",
390
+ children: /* @__PURE__ */ t(
391
+ ye,
392
+ {
393
+ className: g(
394
+ "h-3.5 w-3.5",
395
+ (y.isFetching || x.isFetching) && "animate-spin motion-reduce:animate-none"
396
+ ),
397
+ "aria-hidden": !0
398
+ }
399
+ )
400
+ }
401
+ )
402
+ ] })
170
403
  ] }),
171
- /* @__PURE__ */ e(G, { series: (a == null ? void 0 : a.series) ?? [] })
172
- ] }),
173
- /* @__PURE__ */ r("div", { className: "grid gap-3 lg:grid-cols-3", children: [
174
- /* @__PURE__ */ e(
175
- N,
176
- {
177
- title: "By feature",
178
- rows: ((a == null ? void 0 : a.by_feature) ?? []).map((t) => ({
179
- key: t.feature,
180
- label: t.feature,
181
- cells: [
182
- c(t.requests),
183
- c(t.calls),
184
- m(t.cost_usd),
185
- `${(t.avg_latency / 1e3).toFixed(1)}s`,
186
- c(t.errors)
404
+ /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-2", children: [
405
+ /* @__PURE__ */ t(
406
+ q,
407
+ {
408
+ label: "Feature",
409
+ paramKey: "feature",
410
+ params: r,
411
+ setParams: a,
412
+ options: (l == null ? void 0 : l.facets.features) ?? [],
413
+ render: (e) => F(e.value)
414
+ }
415
+ ),
416
+ /* @__PURE__ */ t(
417
+ q,
418
+ {
419
+ label: "Model",
420
+ paramKey: "model",
421
+ params: r,
422
+ setParams: a,
423
+ options: (l == null ? void 0 : l.facets.models) ?? []
424
+ }
425
+ ),
426
+ /* @__PURE__ */ t(
427
+ q,
428
+ {
429
+ label: "Person",
430
+ paramKey: "user",
431
+ params: r,
432
+ setParams: a,
433
+ options: (l == null ? void 0 : l.facets.people) ?? []
434
+ }
435
+ ),
436
+ /* @__PURE__ */ t(
437
+ q,
438
+ {
439
+ label: "Tool",
440
+ paramKey: "tool",
441
+ params: r,
442
+ setParams: a,
443
+ options: (l == null ? void 0 : l.facets.tools) ?? []
444
+ }
445
+ ),
446
+ /* @__PURE__ */ t(
447
+ q,
448
+ {
449
+ label: "Result",
450
+ paramKey: "result",
451
+ params: r,
452
+ setParams: a,
453
+ options: je.map((e) => {
454
+ var n;
455
+ return {
456
+ value: e,
457
+ label: W(e),
458
+ count: ((n = ((l == null ? void 0 : l.by_result) ?? []).find((m) => m.key === e)) == null ? void 0 : n.calls) ?? (e === "ok" ? ((l == null ? void 0 : l.calls) ?? 0) - ((l == null ? void 0 : l.errors) ?? 0) : 0)
459
+ };
460
+ })
461
+ }
462
+ ),
463
+ /* @__PURE__ */ t(Re, { params: r, setParams: a })
464
+ ] }),
465
+ E.length > 0 && /* @__PURE__ */ o("ul", { className: "flex flex-wrap items-center gap-1.5", "aria-label": "Filters that are on", children: [
466
+ E.map((e) => /* @__PURE__ */ o(
467
+ "li",
468
+ {
469
+ className: "inline-flex h-6 items-center gap-1 rounded-full border border-nvr-cyan/50 bg-nvr-cyan/10 pl-2.5 pr-1 text-[11.5px] text-slate-800 animate-in fade-in-0 zoom-in-95 duration-150 motion-reduce:animate-none dark:text-foreground",
470
+ children: [
471
+ e.label,
472
+ /* @__PURE__ */ t(
473
+ "button",
474
+ {
475
+ type: "button",
476
+ "aria-label": `Remove the filter ${e.label}`,
477
+ onClick: () => a((n) => e.clear(n), { replace: !0 }),
478
+ className: "inline-flex h-4 w-4 items-center justify-center rounded-full text-slate-500 hover:bg-nvr-cyan/20 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:hover:text-foreground",
479
+ children: /* @__PURE__ */ t(ke, { className: "h-3 w-3", "aria-hidden": !0 })
480
+ }
481
+ )
187
482
  ]
188
- })),
189
- heads: ["Questions", "Calls", "Spend", "Avg", "Err"],
190
- onPick: (t) => {
191
- i(t === o ? "" : t), b(1);
192
483
  },
193
- active: o
194
- }
195
- ),
196
- /* @__PURE__ */ e(
197
- N,
484
+ e.key
485
+ )),
486
+ /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
487
+ "button",
488
+ {
489
+ type: "button",
490
+ onClick: () => a((e) => de(e), { replace: !0 }),
491
+ className: "rounded px-1.5 text-[11.5px] text-slate-500 underline-offset-2 hover:text-slate-900 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:hover:text-foreground",
492
+ children: "Clear all"
493
+ }
494
+ ) })
495
+ ] })
496
+ ] }),
497
+ y.isError && !l ? /* @__PURE__ */ t(
498
+ ne,
499
+ {
500
+ error: y.error,
501
+ what: "the AI figures",
502
+ onRetry: () => void y.refetch()
503
+ }
504
+ ) : /* @__PURE__ */ o(M, { children: [
505
+ /* @__PURE__ */ t(
506
+ "div",
198
507
  {
199
- title: "By model",
200
- rows: ((a == null ? void 0 : a.by_model) ?? []).map((t) => ({
201
- key: t.model,
202
- label: `${t.model} · ${t.provider}`,
203
- cells: [
204
- c(t.calls),
205
- m(t.cost_usd),
206
- u(t.input_tokens),
207
- u(t.cache_read_tokens),
208
- u(t.output_tokens)
209
- ]
210
- })),
211
- heads: ["Calls", "Spend", "In", "Cached", "Out"]
508
+ className: g(
509
+ "grid grid-cols-2 gap-px overflow-hidden rounded-lg border border-slate-200 bg-slate-200 transition-opacity sm:grid-cols-4 xl:grid-cols-7 dark:border-border dark:bg-border",
510
+ V && "opacity-60"
511
+ ),
512
+ "data-ai-stat-strip": !0,
513
+ "aria-busy": V,
514
+ children: l ? /* @__PURE__ */ o(M, { children: [
515
+ /* @__PURE__ */ t(
516
+ k,
517
+ {
518
+ label: "Questions",
519
+ value: u(l.questions),
520
+ sub: `${(l.calls / Math.max(1, l.questions)).toFixed(1)} calls each`
521
+ }
522
+ ),
523
+ /* @__PURE__ */ t(
524
+ k,
525
+ {
526
+ label: "Model calls",
527
+ value: u(l.calls),
528
+ sub: `${u(l.tool_calls)} tool calls`
529
+ }
530
+ ),
531
+ /* @__PURE__ */ t(k, { label: "Spend", value: v(l.cost_usd), sub: "at list price" }),
532
+ /* @__PURE__ */ t(
533
+ k,
534
+ {
535
+ label: "Tokens",
536
+ value: w(l.input_tokens + l.output_tokens),
537
+ sub: `${w(l.cache_read_tokens)} cached · ${w(l.output_tokens)} out`
538
+ }
539
+ ),
540
+ /* @__PURE__ */ t(
541
+ k,
542
+ {
543
+ label: "Time p50 / p95",
544
+ value: `${T(l.p50)} / ${T(l.p95)}`,
545
+ sub: `avg ${T(l.avg_latency)}`
546
+ }
547
+ ),
548
+ /* @__PURE__ */ t(
549
+ k,
550
+ {
551
+ label: "Error rate",
552
+ value: ie(l.errors, l.calls),
553
+ sub: `${u(l.errors)} failed`,
554
+ active: N(r, "result").includes("error"),
555
+ onClick: l.errors || N(r, "result").includes("error") ? () => C("result", "error") : void 0,
556
+ tip: "Show only the calls that failed"
557
+ }
558
+ ),
559
+ /* @__PURE__ */ t(
560
+ k,
561
+ {
562
+ className: "col-span-2 xl:col-span-1",
563
+ label: "Helpful",
564
+ value: l.feedback.up + l.feedback.down ? ie(l.feedback.up, l.feedback.up + l.feedback.down) : "–",
565
+ sub: `${u(l.feedback.up)} up · ${u(l.feedback.down)} down`,
566
+ active: r.get("feedback") === "any",
567
+ onClick: () => a((e) => {
568
+ e.get("feedback") === "any" ? e.delete("feedback") : e.set("feedback", "any"), e.delete("page");
569
+ }),
570
+ tip: "Show only the questions people rated"
571
+ }
572
+ )
573
+ ] }) : Array.from({ length: 7 }, (e, n) => (
574
+ // biome-ignore lint/suspicious/noArrayIndexKey: skeleton cells
575
+ /* @__PURE__ */ o("div", { className: "bg-white px-3 py-2.5 dark:bg-card", children: [
576
+ /* @__PURE__ */ t(B, { className: "h-3 w-16" }),
577
+ /* @__PURE__ */ t(B, { className: "mt-2 h-5 w-20" })
578
+ ] }, n)
579
+ ))
212
580
  }
213
581
  ),
214
- /* @__PURE__ */ e(
215
- N,
582
+ l && /* @__PURE__ */ t(
583
+ he,
216
584
  {
217
- title: "By person",
218
- rows: ((a == null ? void 0 : a.by_user) ?? []).map((t) => ({
219
- key: t.user ?? "system",
220
- label: t.name,
221
- cells: [c(t.requests), c(t.calls), m(t.cost_usd)]
222
- })),
223
- heads: ["Questions", "Calls", "Spend"]
585
+ title: l.bucket === "hour" ? "Calls per hour" : "Calls per day",
586
+ hint: "The amber part of a bar is calls that failed. Click a bar to see only its calls.",
587
+ children: /* @__PURE__ */ t(We, { s: l, onPick: fe })
224
588
  }
225
- )
226
- ] }),
227
- /* @__PURE__ */ e(V, { days: Math.max(1, Math.round(s / 24)) }),
228
- /* @__PURE__ */ r("div", { className: "rounded-lg border border-border bg-card", "data-ai-call-log": !0, children: [
229
- /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2 border-b border-border px-3 py-2", children: [
230
- /* @__PURE__ */ e("span", { className: "text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: "Call log" }),
231
- o ? /* @__PURE__ */ r(
232
- "button",
589
+ ),
590
+ l && /* @__PURE__ */ o("div", { className: "grid gap-3 md:grid-cols-2 xl:grid-cols-4", children: [
591
+ /* @__PURE__ */ t(
592
+ A,
233
593
  {
234
- type: "button",
235
- onClick: () => i(""),
236
- className: "rounded bg-nvr-cyan/15 px-1.5 py-0.5 text-[11px]",
237
- children: [
238
- "feature: ",
239
- o,
240
- " ×"
241
- ]
594
+ title: "By feature",
595
+ rows: l.by_feature,
596
+ label: (e) => F(e.key ?? ""),
597
+ activeKeys: N(r, "feature"),
598
+ onPick: (e) => C("feature", e)
242
599
  }
243
- ) : null,
244
- /* @__PURE__ */ e("div", { className: "inline-flex rounded-md border border-border p-0.5 text-[11px]", children: [
245
- ["", "All"],
246
- ["ok", "OK"],
247
- ["error", "Errors"]
248
- ].map(([t, q]) => /* @__PURE__ */ e(
249
- "button",
600
+ ),
601
+ /* @__PURE__ */ t(
602
+ A,
250
603
  {
251
- type: "button",
252
- onClick: () => {
253
- $(t), b(1);
254
- },
255
- className: y(
256
- "rounded px-2 py-0.5",
257
- l === t ? "bg-nvr-cyan/15 font-medium" : "text-muted-foreground"
258
- ),
259
- children: q
260
- },
261
- t
262
- )) }),
263
- x ? /* @__PURE__ */ r(
264
- "button",
604
+ title: "By model",
605
+ rows: l.by_model,
606
+ label: (e) => e.key ?? "",
607
+ activeKeys: N(r, "model"),
608
+ onPick: (e) => C("model", e)
609
+ }
610
+ ),
611
+ /* @__PURE__ */ t(
612
+ A,
265
613
  {
266
- type: "button",
267
- onClick: () => S(""),
268
- className: "rounded bg-nvr-cyan/15 px-1.5 py-0.5 text-[11px]",
269
- children: [
270
- "question ",
271
- x.slice(0, 8),
272
- " ×"
273
- ]
614
+ title: "By person",
615
+ rows: l.by_person,
616
+ label: (e) => e.name ?? "",
617
+ activeKeys: N(r, "user"),
618
+ onPick: (e) => C("user", e)
274
619
  }
275
- ) : null,
276
- /* @__PURE__ */ r("span", { className: "ml-auto text-[11px] text-muted-foreground", children: [
277
- A.toLocaleString(),
278
- " calls · page ",
279
- h,
280
- " of ",
281
- I
282
- ] })
283
- ] }),
284
- /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "w-full text-left text-[12px]", children: [
285
- /* @__PURE__ */ e("thead", { className: "text-[10.5px] uppercase tracking-wide text-muted-foreground", children: /* @__PURE__ */ r("tr", { className: "border-b border-border", children: [
286
- /* @__PURE__ */ e("th", { className: "w-6 px-2 py-1.5" }),
287
- /* @__PURE__ */ e("th", { className: "px-2 py-1.5", children: "When" }),
288
- /* @__PURE__ */ e("th", { className: "px-2 py-1.5", children: "Feature" }),
289
- /* @__PURE__ */ e("th", { className: "px-2 py-1.5", children: "Person" }),
290
- /* @__PURE__ */ e("th", { className: "px-2 py-1.5", children: "Model" }),
291
- /* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right", children: "In" }),
292
- /* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right", children: "Cached" }),
293
- /* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right", children: "Out" }),
294
- /* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right", children: "Cost" }),
295
- /* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right", children: "Time" }),
296
- /* @__PURE__ */ e("th", { className: "px-2 py-1.5", children: "Result" })
297
- ] }) }),
298
- /* @__PURE__ */ r("tbody", { className: "divide-y divide-border tabular-nums", children: [
299
- M.map((t) => /* @__PURE__ */ r(E, { children: [
300
- /* @__PURE__ */ r(
301
- "tr",
620
+ ),
621
+ /* @__PURE__ */ t(
622
+ A,
623
+ {
624
+ title: "By result",
625
+ rows: l.by_result,
626
+ label: (e) => W(e.key),
627
+ activeKeys: N(r, "result"),
628
+ onPick: (e) => C("result", e)
629
+ }
630
+ )
631
+ ] })
632
+ ] }),
633
+ /* @__PURE__ */ o(
634
+ "section",
635
+ {
636
+ className: "min-w-0 rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card",
637
+ "data-ai-call-log": !0,
638
+ "aria-label": "Call log",
639
+ children: [
640
+ /* @__PURE__ */ o("header", { className: "flex flex-wrap items-center gap-2 border-b border-slate-100 px-4 py-2.5 dark:border-border/60", children: [
641
+ /* @__PURE__ */ t("h3", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: "Call log" }),
642
+ /* @__PURE__ */ o("span", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
643
+ u(_),
644
+ " ",
645
+ _ === 1 ? "call" : "calls",
646
+ _ > U ? ` · page ${b} of ${u(P)}` : ""
647
+ ] }),
648
+ /* @__PURE__ */ t("span", { className: "ml-auto hidden text-[11.5px] text-slate-500 sm:inline dark:text-muted-foreground", children: "Click a call to read it. Bodies are kept 30 days." })
649
+ ] }),
650
+ x.isError && !x.data ? /* @__PURE__ */ t(
651
+ ne,
652
+ {
653
+ error: x.error,
654
+ what: "the call log",
655
+ onRetry: () => void x.refetch()
656
+ }
657
+ ) : /* @__PURE__ */ o(M, { children: [
658
+ /* @__PURE__ */ t(
659
+ "div",
302
660
  {
303
- "data-ai-call": t.id,
304
- className: y(
305
- "cursor-pointer hover:bg-muted/50",
306
- v === t.id && "bg-muted/40"
661
+ className: g(
662
+ "hidden overflow-x-auto md:block",
663
+ x.isPlaceholderData && "opacity-60"
664
+ ),
665
+ children: /* @__PURE__ */ o("table", { className: "w-full text-left text-[12px]", children: [
666
+ /* @__PURE__ */ t("thead", { className: "border-b border-slate-100 text-[11px] text-slate-500 dark:border-border/60 dark:text-muted-foreground", children: /* @__PURE__ */ t("tr", { children: ce.map((e) => /* @__PURE__ */ t(He, { col: e, sort: p, onSort: G }, e.key)) }) }),
667
+ /* @__PURE__ */ t("tbody", { className: "divide-y divide-slate-100 tabular-nums dark:divide-border/60", children: x.isLoading && !O.length ? Array.from({ length: 8 }, (e, n) => (
668
+ // biome-ignore lint/suspicious/noArrayIndexKey: skeleton rows
669
+ /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { colSpan: ce.length, className: "px-2 py-2", children: /* @__PURE__ */ t(B, { className: "h-4 w-full" }) }) }, n)
670
+ )) : O.map((e) => /* @__PURE__ */ o(
671
+ "tr",
672
+ {
673
+ "data-ai-call": e.id,
674
+ tabIndex: 0,
675
+ onClick: () => R(e.id),
676
+ onKeyDown: (n) => {
677
+ (n.key === "Enter" || n.key === " ") && (n.preventDefault(), R(e.id));
678
+ },
679
+ "aria-label": `Open call ${e.id}`,
680
+ className: g(
681
+ "cursor-pointer transition-colors hover:bg-slate-50 focus-visible:bg-slate-50 focus-visible:outline-none dark:hover:bg-muted/40 dark:focus-visible:bg-muted/40",
682
+ H === e.id && "bg-nvr-cyan/10 hover:bg-nvr-cyan/10"
683
+ ),
684
+ children: [
685
+ /* @__PURE__ */ t(
686
+ "td",
687
+ {
688
+ className: "whitespace-nowrap px-2 py-2 text-slate-600 dark:text-muted-foreground",
689
+ "data-tip": new Date(e.created_at).toLocaleString(),
690
+ children: L(e.created_at)
691
+ }
692
+ ),
693
+ /* @__PURE__ */ t("td", { className: "max-w-[380px] px-2 py-2", children: /* @__PURE__ */ t(
694
+ ze,
695
+ {
696
+ r: e,
697
+ onRequest: (n) => a((m) => {
698
+ m.set("request_id", n), m.delete("page");
699
+ })
700
+ }
701
+ ) }),
702
+ /* @__PURE__ */ t("td", { className: "max-w-[160px] truncate px-2 py-2", children: e.user_name ?? "System" }),
703
+ /* @__PURE__ */ o("td", { className: "whitespace-nowrap px-2 py-2 font-mono text-[11px]", children: [
704
+ e.model,
705
+ e.tier && /* @__PURE__ */ t(
706
+ "span",
707
+ {
708
+ className: "ml-1.5 rounded bg-slate-100 px-1 py-px font-sans text-[10px] text-slate-500 dark:bg-muted",
709
+ "data-tip": e.tier === "cheap" ? "Started cheap: the small model" : `Moved up to the main model${e.tier_reason ? ` (${e.tier_reason.replace(/_/g, " ")})` : ""}`,
710
+ children: e.tier === "cheap" ? "quick" : "moved up"
711
+ }
712
+ )
713
+ ] }),
714
+ /* @__PURE__ */ t("td", { className: "px-2 py-2 text-right", children: w(e.input_tokens) }),
715
+ /* @__PURE__ */ t("td", { className: "px-2 py-2 text-right text-slate-500 dark:text-muted-foreground", children: w(e.cache_read_tokens) }),
716
+ /* @__PURE__ */ t("td", { className: "px-2 py-2 text-right", children: w(e.output_tokens) }),
717
+ /* @__PURE__ */ t("td", { className: "px-2 py-2 text-right", children: v(e.cost_usd, 3) }),
718
+ /* @__PURE__ */ t("td", { className: "px-2 py-2 text-right", children: T(e.latency_ms) }),
719
+ /* @__PURE__ */ t("td", { className: "px-2 py-2", children: /* @__PURE__ */ t(ue, { r: e }) })
720
+ ]
721
+ },
722
+ e.id
723
+ )) })
724
+ ] })
725
+ }
726
+ ),
727
+ /* @__PURE__ */ o("div", { className: "md:hidden", children: [
728
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-2 border-b border-slate-100 px-3 py-2 text-[12px] dark:border-border/60", children: [
729
+ /* @__PURE__ */ t("span", { className: "text-slate-500", children: "Sort" }),
730
+ /* @__PURE__ */ t(
731
+ oe,
732
+ {
733
+ ariaLabel: "Sort",
734
+ value: p.key,
735
+ onChange: (e) => G(e),
736
+ options: [
737
+ { value: "when", label: "When" },
738
+ { value: "cost", label: "Cost" },
739
+ { value: "time", label: "Time" }
740
+ ]
741
+ }
307
742
  ),
308
- onClick: () => D(v === t.id ? null : t.id),
743
+ /* @__PURE__ */ t("span", { className: "text-slate-400", children: p.dir === "asc" ? "↑" : "↓" })
744
+ ] }),
745
+ /* @__PURE__ */ t(
746
+ "ul",
747
+ {
748
+ className: g(
749
+ "divide-y divide-slate-100 dark:divide-border/60",
750
+ x.isPlaceholderData && "opacity-60"
751
+ ),
752
+ children: O.map((e) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ o(
753
+ "button",
754
+ {
755
+ type: "button",
756
+ onClick: () => R(e.id),
757
+ className: "flex w-full flex-col gap-1 px-3 py-2.5 text-left text-[12px] hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-nvr-cyan/50 dark:hover:bg-muted/40",
758
+ children: [
759
+ /* @__PURE__ */ t("span", { className: "line-clamp-2 font-medium text-slate-900 dark:text-foreground", children: e.question || `${F(e.feature)} call` }),
760
+ /* @__PURE__ */ o("span", { className: "flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-slate-500 dark:text-muted-foreground", children: [
761
+ /* @__PURE__ */ t("span", { children: L(e.created_at) }),
762
+ /* @__PURE__ */ t("span", { children: e.user_name ?? "System" }),
763
+ /* @__PURE__ */ o("span", { className: "tabular-nums", children: [
764
+ v(e.cost_usd, 3),
765
+ " · ",
766
+ T(e.latency_ms)
767
+ ] }),
768
+ /* @__PURE__ */ t(ue, { r: e })
769
+ ] })
770
+ ]
771
+ }
772
+ ) }, e.id))
773
+ }
774
+ )
775
+ ] }),
776
+ O.length === 0 && !x.isLoading && /* @__PURE__ */ t("div", { className: "px-4 py-10 text-center text-[12.5px] text-slate-500 dark:text-muted-foreground", children: E.length ? /* @__PURE__ */ o(M, { children: [
777
+ "No calls match these filters.",
778
+ " ",
779
+ /* @__PURE__ */ t(
780
+ "button",
781
+ {
782
+ type: "button",
783
+ className: "text-nvr-cyan underline-offset-2 hover:underline",
784
+ onClick: () => a((e) => de(e)),
785
+ children: "Clear the filters"
786
+ }
787
+ )
788
+ ] }) : "No AI calls in this window. Calls appear here as people use Ask AI and the other AI features." }),
789
+ P > 1 && /* @__PURE__ */ o(
790
+ "nav",
791
+ {
792
+ "aria-label": "Pages",
793
+ className: "flex items-center justify-end gap-2 border-t border-slate-100 px-4 py-2 text-[12px] dark:border-border/60",
309
794
  children: [
310
- /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-muted-foreground", children: v === t.id ? /* @__PURE__ */ e(j, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(Q, { className: "h-3.5 w-3.5" }) }),
311
- /* @__PURE__ */ e(
312
- "td",
795
+ /* @__PURE__ */ t(
796
+ "button",
313
797
  {
314
- className: "whitespace-nowrap px-2 py-1.5",
315
- "data-tip": P(t.created_at),
316
- children: T(t.created_at)
798
+ type: "button",
799
+ disabled: b <= 1,
800
+ onClick: () => a((e) => {
801
+ b - 1 <= 1 ? e.delete("page") : e.set("page", String(b - 1));
802
+ }),
803
+ className: "rounded-md border border-slate-200 px-2.5 py-1 hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:hover:bg-muted",
804
+ children: "Previous"
317
805
  }
318
806
  ),
319
- /* @__PURE__ */ r("td", { className: "px-2 py-1.5", children: [
320
- /* @__PURE__ */ e("span", { className: "rounded bg-muted px-1.5 py-0.5 text-[11px]", children: t.feature }),
321
- t.request_id ? /* @__PURE__ */ r(
322
- "button",
323
- {
324
- type: "button",
325
- className: "ml-1 text-[10.5px] text-muted-foreground underline-offset-2 hover:underline",
326
- "data-tip": "Show every call of this question",
327
- onClick: (q) => {
328
- q.stopPropagation(), S(t.request_id ?? ""), b(1);
329
- },
330
- children: [
331
- "#",
332
- t.request_id.slice(0, 6)
333
- ]
334
- }
335
- ) : null
336
- ] }),
337
- /* @__PURE__ */ e("td", { className: "max-w-[160px] truncate px-2 py-1.5", children: t.user_name ?? (t.user ? "…" : "System") }),
338
- /* @__PURE__ */ r("td", { className: "px-2 py-1.5 font-mono text-[11px]", children: [
339
- t.model,
340
- t.tier && /* @__PURE__ */ e(
341
- "span",
342
- {
343
- className: "ml-1.5 rounded bg-muted px-1 py-px font-sans text-[10px] text-muted-foreground",
344
- "data-tip": t.tier === "cheap" ? "Started cheap: the small model" : `Moved up to the main model${t.tier_reason ? ` (${t.tier_reason.replace(/_/g, " ")})` : ""}`,
345
- children: t.tier === "cheap" ? "quick" : "moved up"
346
- }
347
- )
348
- ] }),
349
- /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right", children: u(t.input_tokens) }),
350
- /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right text-muted-foreground", children: u(t.cache_read_tokens) }),
351
- /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right", children: u(t.output_tokens) }),
352
- /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right", children: m(t.cost_usd, 3) }),
353
- /* @__PURE__ */ r("td", { className: "px-2 py-1.5 text-right", children: [
354
- (t.latency_ms / 1e3).toFixed(1),
355
- "s"
807
+ /* @__PURE__ */ o("span", { className: "tabular-nums text-slate-500", children: [
808
+ b,
809
+ " / ",
810
+ u(P)
356
811
  ] }),
357
- /* @__PURE__ */ e("td", { className: "px-2 py-1.5", children: t.status === "error" ? /* @__PURE__ */ e("span", { className: "text-red-700 dark:text-red-400", "data-tip": t.error ?? "", children: "error" }) : /* @__PURE__ */ r("span", { className: "text-muted-foreground", children: [
358
- t.stop_reason ?? "ok",
359
- t.tool_calls ? ` · ${t.tool_calls} tool` : ""
360
- ] }) })
812
+ /* @__PURE__ */ t(
813
+ "button",
814
+ {
815
+ type: "button",
816
+ disabled: b >= P,
817
+ onClick: () => a((e) => e.set("page", String(b + 1))),
818
+ className: "rounded-md border border-slate-200 px-2.5 py-1 hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:hover:bg-muted",
819
+ children: "Next"
820
+ }
821
+ )
361
822
  ]
362
- },
363
- t.id
364
- ),
365
- v === t.id ? /* @__PURE__ */ e("tr", { className: "bg-muted/20", children: /* @__PURE__ */ e("td", { colSpan: 11, className: "px-3 py-3", children: /* @__PURE__ */ e(J, { id: t.id }) }) }, `${t.id}-d`) : null
366
- ] })),
367
- M.length === 0 && !k.isLoading ? /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: 11, className: "px-3 py-6 text-center text-muted-foreground", children: "No calls match." }) }) : null
368
- ] })
369
- ] }) }),
370
- /* @__PURE__ */ r("div", { className: "flex items-center justify-end gap-2 border-t border-border px-3 py-2 text-[12px]", children: [
371
- /* @__PURE__ */ e(
372
- "button",
373
- {
374
- type: "button",
375
- disabled: h <= 1,
376
- onClick: () => b(h - 1),
377
- className: "rounded border border-border px-2 py-0.5 disabled:opacity-40",
378
- children: "Prev"
379
- }
380
- ),
381
- /* @__PURE__ */ e(
382
- "button",
383
- {
384
- type: "button",
385
- disabled: h >= I,
386
- onClick: () => b(h + 1),
387
- className: "rounded border border-border px-2 py-0.5 disabled:opacity-40",
388
- children: "Next"
389
- }
823
+ }
824
+ )
825
+ ] })
826
+ ]
827
+ }
828
+ ),
829
+ /* @__PURE__ */ t(
830
+ Ge,
831
+ {
832
+ days: Math.max(
833
+ 1,
834
+ Math.round(
835
+ (l ? new Date(l.to).getTime() - new Date(l.from).getTime() : 7 * 864e5) / 864e5
836
+ )
390
837
  )
391
- ] })
392
- ] })
838
+ }
839
+ ),
840
+ /* @__PURE__ */ t(
841
+ Oe,
842
+ {
843
+ callId: H,
844
+ threadOpen: r.get("thread") === "1",
845
+ onClose: () => a((e) => {
846
+ e.delete("call"), e.delete("thread");
847
+ }),
848
+ onOpenCall: R,
849
+ onThread: (e) => a((n) => {
850
+ e ? n.set("thread", "1") : n.delete("thread");
851
+ })
852
+ }
853
+ )
393
854
  ] });
394
855
  }
395
- function N({
396
- title: d,
397
- heads: s,
398
- rows: n,
399
- onPick: o,
400
- active: i
856
+ function pe({
857
+ title: s,
858
+ heads: d,
859
+ rows: h,
860
+ onPick: i,
861
+ active: r
401
862
  }) {
402
- return /* @__PURE__ */ e(
863
+ return /* @__PURE__ */ t(
403
864
  "div",
404
865
  {
405
866
  className: "overflow-x-auto rounded-lg border border-border bg-card",
406
- "data-ai-breakdown": d,
407
- children: /* @__PURE__ */ r("table", { className: "w-full text-left text-[12px]", children: [
408
- /* @__PURE__ */ e("thead", { className: "text-[10.5px] uppercase tracking-wide text-muted-foreground", children: /* @__PURE__ */ r("tr", { className: "border-b border-border", children: [
409
- /* @__PURE__ */ e("th", { className: "px-3 py-1.5", children: d }),
410
- s.map((l) => /* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right", children: l }, l))
867
+ "data-ai-breakdown": s,
868
+ children: /* @__PURE__ */ o("table", { className: "w-full text-left text-[12px]", children: [
869
+ /* @__PURE__ */ t("thead", { className: "text-[10.5px] uppercase tracking-wide text-muted-foreground", children: /* @__PURE__ */ o("tr", { className: "border-b border-border", children: [
870
+ /* @__PURE__ */ t("th", { className: "px-3 py-1.5", children: s }),
871
+ d.map((a) => /* @__PURE__ */ t("th", { className: "px-2 py-1.5 text-right", children: a }, a))
411
872
  ] }) }),
412
- /* @__PURE__ */ r("tbody", { className: "divide-y divide-border tabular-nums", children: [
413
- n.map((l) => /* @__PURE__ */ r(
873
+ /* @__PURE__ */ o("tbody", { className: "divide-y divide-border tabular-nums", children: [
874
+ h.map((a) => /* @__PURE__ */ o(
414
875
  "tr",
415
876
  {
416
- className: y(
417
- o && "cursor-pointer hover:bg-muted/50",
418
- i === l.key && "bg-nvr-cyan/10"
877
+ className: g(
878
+ i && "cursor-pointer hover:bg-muted/50",
879
+ r === a.key && "bg-nvr-cyan/10"
419
880
  ),
420
- onClick: () => o == null ? void 0 : o(l.key),
881
+ onClick: () => i == null ? void 0 : i(a.key),
421
882
  children: [
422
- /* @__PURE__ */ e("td", { className: "max-w-[220px] truncate px-3 py-1.5", children: l.label }),
423
- l.cells.map(($, x) => (
883
+ /* @__PURE__ */ t("td", { className: "max-w-[220px] truncate px-3 py-1.5", children: a.label }),
884
+ a.cells.map((f, c) => (
424
885
  // biome-ignore lint/suspicious/noArrayIndexKey: fixed column order
425
- /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right", children: $ }, x)
886
+ /* @__PURE__ */ t("td", { className: "px-2 py-1.5 text-right", children: f }, c)
426
887
  ))
427
888
  ]
428
889
  },
429
- l.key
890
+ a.key
430
891
  )),
431
- n.length === 0 ? /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e(
892
+ h.length === 0 ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t(
432
893
  "td",
433
894
  {
434
- colSpan: s.length + 1,
895
+ colSpan: d.length + 1,
435
896
  className: "px-3 py-4 text-center text-muted-foreground",
436
897
  children: "Nothing yet"
437
898
  }
@@ -441,65 +902,65 @@ function N({
441
902
  }
442
903
  );
443
904
  }
444
- function f(d, s) {
445
- return s ? `${Math.round(d / s * 100)}%` : "—";
905
+ function D(s, d) {
906
+ return d ? `${Math.round(s / d * 100)}%` : "—";
446
907
  }
447
- function V({ days: d }) {
448
- var i;
449
- const s = C(), o = (i = _({
450
- queryKey: ["nvr-ai-autofill-analytics", d],
451
- queryFn: () => s.request(w("/ai/extract-record/analytics", { days: d })),
908
+ function Ge({ days: s }) {
909
+ var r;
910
+ const d = me(), i = (r = j({
911
+ queryKey: ["nvr-ai-autofill-analytics", s],
912
+ queryFn: () => d.request(Q("/ai/extract-record/analytics", { days: s })),
452
913
  refetchInterval: 6e4
453
- }).data) == null ? void 0 : i.data;
454
- return !o || o.documents === 0 ? null : /* @__PURE__ */ r("div", { className: "flex flex-col gap-3", "data-ai-autofill-scorecard": !0, children: [
455
- /* @__PURE__ */ r("div", { className: "flex items-baseline gap-2", children: [
456
- /* @__PURE__ */ r("span", { className: "text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: [
914
+ }).data) == null ? void 0 : r.data;
915
+ return !i || i.documents === 0 ? null : /* @__PURE__ */ o("div", { className: "flex flex-col gap-3", "data-ai-autofill-scorecard": !0, children: [
916
+ /* @__PURE__ */ o("div", { className: "flex items-baseline gap-2", children: [
917
+ /* @__PURE__ */ o("span", { className: "text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: [
457
918
  "Document autofill · last ",
458
- o.days,
919
+ i.days,
459
920
  " days"
460
921
  ] }),
461
- /* @__PURE__ */ r("span", { className: "text-[11.5px] text-muted-foreground", children: [
462
- c(o.documents),
922
+ /* @__PURE__ */ o("span", { className: "text-[11.5px] text-muted-foreground", children: [
923
+ u(i.documents),
463
924
  " document",
464
- o.documents === 1 ? "" : "s",
925
+ i.documents === 1 ? "" : "s",
465
926
  " · ",
466
- m(o.cost_usd),
467
- o.avg_latency_ms ? ` · ${(o.avg_latency_ms / 1e3).toFixed(0)}s per document` : ""
927
+ v(i.cost_usd),
928
+ i.avg_latency_ms ? ` · ${(i.avg_latency_ms / 1e3).toFixed(0)}s per document` : ""
468
929
  ] })
469
930
  ] }),
470
- /* @__PURE__ */ r("div", { className: "grid gap-3 lg:grid-cols-2", children: [
471
- /* @__PURE__ */ e(
472
- N,
931
+ /* @__PURE__ */ o("div", { className: "grid gap-3 lg:grid-cols-2", children: [
932
+ /* @__PURE__ */ t(
933
+ pe,
473
934
  {
474
935
  title: "By collection",
475
936
  heads: ["Docs", "Kept", "Changed", "Lines kept", "Asked", "Spend"],
476
- rows: o.by_collection.map((l) => ({
477
- key: l.collection,
478
- label: l.collection,
937
+ rows: i.by_collection.map((a) => ({
938
+ key: a.collection,
939
+ label: a.collection,
479
940
  cells: [
480
- c(l.documents),
481
- `${f(l.fields_kept, l.fields_proposed)} of ${c(l.fields_proposed)}`,
482
- f(l.fields_overridden, l.fields_kept),
483
- `${f(l.lines_kept, l.lines_proposed)} of ${c(l.lines_proposed)}`,
484
- `${c(l.asks_resolved)}/${c(l.asks)}`,
485
- m(l.cost_usd)
941
+ u(a.documents),
942
+ `${D(a.fields_kept, a.fields_proposed)} of ${u(a.fields_proposed)}`,
943
+ D(a.fields_overridden, a.fields_kept),
944
+ `${D(a.lines_kept, a.lines_proposed)} of ${u(a.lines_proposed)}`,
945
+ `${u(a.asks_resolved)}/${u(a.asks)}`,
946
+ v(a.cost_usd)
486
947
  ]
487
948
  }))
488
949
  }
489
950
  ),
490
- /* @__PURE__ */ e(
491
- N,
951
+ /* @__PURE__ */ t(
952
+ pe,
492
953
  {
493
954
  title: "By field",
494
955
  heads: ["Proposed", "Kept", "Changed", "Conf."],
495
- rows: o.by_field.slice(0, 25).map((l) => ({
496
- key: `${l.collection}:${l.field}`,
497
- label: `${l.collection} · ${l.field}`,
956
+ rows: i.by_field.slice(0, 25).map((a) => ({
957
+ key: `${a.collection}:${a.field}`,
958
+ label: `${a.collection} · ${a.field}`,
498
959
  cells: [
499
- c(l.proposed),
500
- f(l.kept, l.proposed),
501
- f(l.overridden, l.proposed),
502
- l.avg_confidence == null ? "—" : `${Math.round(l.avg_confidence * 100)}%`
960
+ u(a.proposed),
961
+ D(a.kept, a.proposed),
962
+ D(a.overridden, a.proposed),
963
+ a.avg_confidence == null ? "—" : `${Math.round(a.avg_confidence * 100)}%`
503
964
  ]
504
965
  }))
505
966
  }
@@ -508,5 +969,5 @@ function V({ days: d }) {
508
969
  ] });
509
970
  }
510
971
  export {
511
- te as AiAnalyticsView
972
+ ut as AiAnalyticsView
512
973
  };