@nivaro/react 0.3.44 → 0.3.46

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 (51) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +75 -7
  4. package/dist/shared/components/BaseMap.js +149 -103
  5. package/dist/shared/components/CollectionBrowserView.js +1390 -1358
  6. package/dist/shared/components/DataTable.js +356 -334
  7. package/dist/shared/components/ProfileView.js +16 -21
  8. package/dist/shared/components/command-center/CommandCenterView.js +331 -352
  9. package/dist/shared/components/command-center/Customize.js +353 -0
  10. package/dist/shared/components/command-center/Header.js +296 -0
  11. package/dist/shared/components/command-center/KioskLinks.js +198 -0
  12. package/dist/shared/components/command-center/PeekPanel.js +146 -0
  13. package/dist/shared/components/command-center/announce.js +13 -0
  14. package/dist/shared/components/command-center/api.js +26 -0
  15. package/dist/shared/components/command-center/board-prefs.js +99 -0
  16. package/dist/shared/components/command-center/freshness.js +29 -0
  17. package/dist/shared/components/command-center/layout.js +56 -0
  18. package/dist/shared/components/command-center/panels/AttentionPanel.js +135 -0
  19. package/dist/shared/components/command-center/panels/Banner.js +75 -0
  20. package/dist/shared/components/command-center/panels/BoardSettings.js +223 -0
  21. package/dist/shared/components/command-center/panels/FeedPanel.js +149 -0
  22. package/dist/shared/components/command-center/panels/FlowPanel.js +159 -0
  23. package/dist/shared/components/command-center/panels/ForecastPanel.js +247 -0
  24. package/dist/shared/components/command-center/panels/MapLegend.js +266 -0
  25. package/dist/shared/components/command-center/panels/MapPanel.js +224 -0
  26. package/dist/shared/components/command-center/panels/PartnersPanel.js +52 -0
  27. package/dist/shared/components/command-center/panels/PeoplePanel.js +264 -0
  28. package/dist/shared/components/command-center/panels/RegionPicker.js +91 -0
  29. package/dist/shared/components/command-center/panels/SystemPanel.js +173 -0
  30. package/dist/shared/components/command-center/panels/ThroughputPanel.js +310 -0
  31. package/dist/shared/components/command-center/panels/TimeBar.js +231 -0
  32. package/dist/shared/components/command-center/panels/TrafficPanel.js +15 -0
  33. package/dist/shared/components/command-center/panels/WorkloadPanel.js +85 -0
  34. package/dist/shared/components/command-center/panels/attention-actions.js +267 -0
  35. package/dist/shared/components/command-center/panels/map-shared.js +95 -0
  36. package/dist/shared/components/command-center/panels/registry.js +96 -0
  37. package/dist/shared/components/command-center/shell-hooks.js +118 -0
  38. package/dist/shared/components/command-center/shortcuts.js +37 -0
  39. package/dist/shared/components/command-center/state.js +12 -0
  40. package/dist/shared/components/command-center/theme.js +84 -0
  41. package/dist/shared/components/command-center/time.js +52 -0
  42. package/dist/shared/components/command-center/url-state.js +54 -0
  43. package/dist/shared/components/command-center/work-links.js +32 -0
  44. package/dist/shared/components/imports/ImportConsole.js +48 -47
  45. package/dist/shared/components/monitoring/TrafficMiniMap.js +111 -70
  46. package/dist/shared/components/notifications/TestMyRules.js +39 -38
  47. package/dist/shared/components/profile/TeamsConnect.js +2 -2
  48. package/dist/shared/components/queue/QueueQuickFilters.js +81 -63
  49. package/dist/shared/components/queue/QueueWorklist.js +598 -586
  50. package/dist/shared/lib/quick-filter-cascade.js +29 -0
  51. package/package.json +1 -1
@@ -0,0 +1,135 @@
1
+ import { jsxs as o, jsx as a } from "react/jsx-runtime";
2
+ import { AlertOctagon as N, AlertTriangle as b, Info as I } from "lucide-react";
3
+ import { useState as w } from "react";
4
+ import { useCcQuery as $ } from "../api.js";
5
+ import { useCc as g } from "../state.js";
6
+ import { PANEL as _, PANEL_HEAD as A, TITLE as T, FAINT as u, FOCUS as h, MUTED as p, BUTTON as E } from "../theme.js";
7
+ import { sinceShort as C, stateListUrl as F } from "../work-links.js";
8
+ import { NudgeForm as L, TransitionForm as D, ApproveForm as S, ReassignForm as P } from "./attention-actions.js";
9
+ const O = {
10
+ critical: { Icon: N, word: "Critical", tone: "text-[var(--cc-bad-text)]" },
11
+ warning: { Icon: b, word: "Warning", tone: "text-[var(--cc-warn-text)]" },
12
+ info: { Icon: I, word: "Info", tone: "text-[var(--cc-muted)]" }
13
+ }, k = 8;
14
+ function Y() {
15
+ const r = g(), e = $("/attention", void 0, { refetchInterval: 6e4 }), n = e.data ?? [], [s, i] = w(!1), c = s ? n : n.slice(0, k), d = n.length - c.length;
16
+ return /* @__PURE__ */ o("section", { className: _, "data-cc-panel": "attention", "aria-busy": e.isLoading, children: [
17
+ /* @__PURE__ */ o("div", { className: A, children: [
18
+ /* @__PURE__ */ a("h2", { className: T, children: "Needs attention" }),
19
+ /* @__PURE__ */ a("span", { className: `text-[11px] tabular-nums ${u}`, children: r.at ? "Live — not rewound" : n.length > 0 ? n.length : "" })
20
+ ] }),
21
+ /* @__PURE__ */ a(R, {}),
22
+ /* @__PURE__ */ a("ul", { className: "divide-y divide-[var(--cc-border)]", children: c.map((l) => /* @__PURE__ */ a(H, { item: l }, l.id)) }),
23
+ (d > 0 || s) && n.length > k && /* @__PURE__ */ a("div", { className: "border-t border-[var(--cc-border)] px-3 py-2", children: r.kiosk || r.tv ? /* @__PURE__ */ o("span", { className: `text-[11.5px] ${u}`, children: [
24
+ "+",
25
+ d,
26
+ " more"
27
+ ] }) : /* @__PURE__ */ a(
28
+ "button",
29
+ {
30
+ type: "button",
31
+ onClick: () => i((l) => !l),
32
+ "aria-expanded": s,
33
+ className: `text-[11.5px] font-medium text-[var(--cc-text)] underline-offset-2 hover:underline ${h}`,
34
+ children: s ? "Show fewer" : `Show all ${n.length}`
35
+ }
36
+ ) }),
37
+ !e.isLoading && n.length === 0 && /* @__PURE__ */ a("p", { className: `px-3 py-3 text-[12px] ${u}`, children: e.isError ? "Could not load this list." : "Nothing needs attention right now." })
38
+ ] });
39
+ }
40
+ function R() {
41
+ var s;
42
+ const e = (s = g().snapshot) == null ? void 0 : s.risk;
43
+ if (!e) return null;
44
+ const n = [];
45
+ return e.sla_breached != null && n.push({
46
+ key: "b",
47
+ text: `${e.sla_breached} past deadline`,
48
+ tone: e.sla_breached > 0 ? "text-[var(--cc-bad-text)]" : p,
49
+ Icon: e.sla_breached > 0 ? N : void 0
50
+ }), e.sla_warning != null && n.push({
51
+ key: "w",
52
+ text: `${e.sla_warning} near deadline`,
53
+ tone: e.sla_warning > 0 ? "text-[var(--cc-warn-text)]" : p,
54
+ Icon: e.sla_warning > 0 ? b : void 0
55
+ }), e.tracked > 0 && n.push({ key: "r", text: `${e.at_risk} at risk of ${e.tracked} tracked`, tone: p }), (e.open_issues ?? 0) > 0 && n.push({ key: "i", text: `${e.open_issues} open issues`, tone: p }), n.length === 0 ? null : /* @__PURE__ */ o("p", { className: "flex flex-wrap gap-x-3 gap-y-1 border-b border-[var(--cc-border)] px-3 py-2 text-[11.5px]", children: [
56
+ /* @__PURE__ */ a("span", { className: "sr-only", children: "Risk summary:" }),
57
+ n.map((i) => /* @__PURE__ */ o("span", { className: `flex items-center gap-1 tabular-nums ${i.tone}`, children: [
58
+ i.Icon && /* @__PURE__ */ a(i.Icon, { className: "h-3 w-3", "aria-hidden": !0 }),
59
+ i.text
60
+ ] }, i.key))
61
+ ] });
62
+ }
63
+ function H({ item: r }) {
64
+ const e = g(), [n, s] = w(null), i = O[r.severity], c = C(r.since), d = r.list ? F(r.list.collection, {
65
+ state: r.list.state,
66
+ minAgeHours: r.list.min_age_hours
67
+ }) : null, l = () => {
68
+ r.record && !r.list ? e.setPeek(r.record) : d ? e.navigate(d) : r.href ? e.navigate(r.href) : r.record && e.setPeek(r.record);
69
+ }, m = !e.kiosk, y = (t) => {
70
+ var f, v;
71
+ if (t.kind === "open") {
72
+ t.href ? e.navigate(t.href) : t.target ? e.setPeek({ collection: t.target.collection, id: t.target.id }) : l();
73
+ return;
74
+ }
75
+ if (t.kind === "alert" && t.href) return e.navigate(t.href);
76
+ if (t.kind === "nudge" && t.target) return s({ kind: "nudge", target: t.target });
77
+ if (t.kind === "transition" && t.target)
78
+ return s({ kind: "transition", target: t.target });
79
+ if (t.kind === "approve" && ((f = t.target) == null ? void 0 : f.approval_id) != null)
80
+ return s({ kind: "approve", approvalId: t.target.approval_id });
81
+ if (t.kind === "reassign" && ((v = t.targets) != null && v.length))
82
+ return s({ kind: "reassign", targets: t.targets });
83
+ }, x = r.actions.filter(
84
+ (t) => t.kind === "open" || m && (t.kind !== "alert" || e.isAdmin)
85
+ );
86
+ return /* @__PURE__ */ o("li", { className: "px-3 py-2", children: [
87
+ /* @__PURE__ */ o("div", { className: "flex items-start gap-2", children: [
88
+ /* @__PURE__ */ o(
89
+ "span",
90
+ {
91
+ className: `mt-0.5 flex shrink-0 items-center gap-1 text-[10.5px] font-semibold ${i.tone}`,
92
+ children: [
93
+ /* @__PURE__ */ a(i.Icon, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
94
+ /* @__PURE__ */ a("span", { className: "w-[50px]", children: i.word })
95
+ ]
96
+ }
97
+ ),
98
+ /* @__PURE__ */ o("div", { className: "min-w-0 flex-1", children: [
99
+ /* @__PURE__ */ a(
100
+ "button",
101
+ {
102
+ type: "button",
103
+ onClick: l,
104
+ className: `block max-w-full truncate rounded text-left text-[12.5px] font-medium text-[var(--cc-strong)] hover:underline ${h}`,
105
+ children: r.title
106
+ }
107
+ ),
108
+ r.detail && /* @__PURE__ */ a("p", { className: `truncate text-[11.5px] ${p}`, children: r.detail })
109
+ ] }),
110
+ /* @__PURE__ */ o("div", { className: "shrink-0 text-right text-[11px] tabular-nums", children: [
111
+ r.count != null && r.count > 1 && /* @__PURE__ */ a("div", { className: "font-semibold text-[var(--cc-text)]", children: r.count }),
112
+ c && /* @__PURE__ */ a("div", { className: u, "data-tip": "How long it has been like this", children: c })
113
+ ] })
114
+ ] }),
115
+ x.length > 0 && !n && /* @__PURE__ */ a("div", { className: "mt-1.5 flex flex-wrap gap-1.5 pl-[70px]", children: x.map((t) => /* @__PURE__ */ a(
116
+ "button",
117
+ {
118
+ type: "button",
119
+ onClick: () => y(t),
120
+ className: `${E} py-0.5 ${h}`,
121
+ children: t.label
122
+ },
123
+ `${t.kind}:${t.label}`
124
+ )) }),
125
+ n && m && /* @__PURE__ */ o("div", { className: "mt-2 ml-[70px] rounded-md bg-[var(--cc-raised)] p-2", children: [
126
+ n.kind === "nudge" && /* @__PURE__ */ a(L, { target: n.target, onDone: () => s(null) }),
127
+ n.kind === "transition" && /* @__PURE__ */ a(D, { target: n.target, onDone: () => s(null) }),
128
+ n.kind === "approve" && /* @__PURE__ */ a(S, { approvalId: n.approvalId, onDone: () => s(null) }),
129
+ n.kind === "reassign" && /* @__PURE__ */ a(P, { targets: n.targets, onDone: () => s(null) })
130
+ ] })
131
+ ] });
132
+ }
133
+ export {
134
+ Y as AttentionPanel
135
+ };
@@ -0,0 +1,75 @@
1
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
2
+ import { useArmedFaults as s } from "../../chaos/DrillBanner.js";
3
+ import { useCcQuery as d } from "../api.js";
4
+ import { useCc as m } from "../state.js";
5
+ import { FOCUS as u } from "../theme.js";
6
+ import { whenLabel as l, clockLabel as f } from "../time.js";
7
+ function p(e, t) {
8
+ const i = [];
9
+ if (e != null && e.incident && i.push({
10
+ key: "incident",
11
+ tone: "critical",
12
+ text: `Incident open since ${l(new Date(e.incident.started_at).getTime())}: ${e.incident.title}`,
13
+ href: e.incident.href,
14
+ action: "Open the incident"
15
+ }), e != null && e.maintenance && i.push({
16
+ key: "maintenance",
17
+ tone: "warning",
18
+ text: `Maintenance in progress${e.maintenance.until ? ` until ${l(new Date(e.maintenance.until).getTime())}` : ""} — saving changes is paused.${e.maintenance.message ? ` ${e.maintenance.message}` : ""}`,
19
+ href: null,
20
+ action: null
21
+ }), t.length > 0) {
22
+ const r = t[0];
23
+ i.push({
24
+ key: "drill",
25
+ tone: "info",
26
+ text: `Practice drill running: ${r.label} on ${r.target}${t.length > 1 ? ` (+${t.length - 1} more)` : ""}, until ${f(r.ends_at)}. Some failures on this board are deliberate.`,
27
+ href: null,
28
+ action: null
29
+ });
30
+ }
31
+ return i;
32
+ }
33
+ const h = {
34
+ critical: { box: "bg-red-500/15 text-[var(--cc-bad-text)]", glyph: "■", word: "Incident" },
35
+ warning: { box: "bg-amber-500/15 text-[var(--cc-warn-text)]", glyph: "▲", word: "Maintenance" },
36
+ info: { box: "bg-nvr-cyan/10 text-[var(--cc-text)]", glyph: "◆", word: "Drill" }
37
+ };
38
+ function w() {
39
+ const e = m(), { data: t } = d("/banner", void 0, {
40
+ lenses: !1,
41
+ refetchInterval: 3e4,
42
+ staleTime: 15e3
43
+ }), { armed: i } = s(), r = p(t, i);
44
+ return r.length === 0 ? null : /* @__PURE__ */ a("div", { className: "flex shrink-0 flex-col gap-1.5", role: "status", "data-cc-banner": "", children: r.map((n) => {
45
+ const c = h[n.tone];
46
+ return /* @__PURE__ */ o(
47
+ "div",
48
+ {
49
+ className: `relative flex flex-wrap items-center gap-2 rounded-lg px-3 py-2 text-[12.5px] ${c.box}`,
50
+ children: [
51
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: "text-[10px]", children: c.glyph }),
52
+ /* @__PURE__ */ o("span", { className: "sr-only", children: [
53
+ c.word,
54
+ ": "
55
+ ] }),
56
+ /* @__PURE__ */ a("span", { className: "min-w-0 flex-1 font-medium", children: n.text }),
57
+ n.href && n.action && /* @__PURE__ */ a(
58
+ "button",
59
+ {
60
+ type: "button",
61
+ className: `rounded px-1.5 text-[12px] font-semibold underline-offset-2 hover:underline ${u}`,
62
+ onClick: () => e.navigate(n.href),
63
+ children: n.action
64
+ }
65
+ )
66
+ ]
67
+ },
68
+ n.key
69
+ );
70
+ }) });
71
+ }
72
+ export {
73
+ w as BoardBanner,
74
+ p as bannerLines
75
+ };
@@ -0,0 +1,223 @@
1
+ import { jsxs as o, jsx as n } from "react/jsx-runtime";
2
+ import { useQueryClient as P, useMutation as B } from "@tanstack/react-query";
3
+ import { useState as C, useEffect as D } from "react";
4
+ import { toast as S } from "sonner";
5
+ import { useNivaroClient as E } from "../../../context.js";
6
+ import { put as I } from "../../../lib/commands.js";
7
+ import { cn as a } from "../../../lib/utils.js";
8
+ import { useCcQuery as U } from "../api.js";
9
+ import { MUTED as $, FAINT as r, FOCUS as l, BUTTON as _ } from "../theme.js";
10
+ import { CcSidePanel as q } from "./map-shared.js";
11
+ const A = (d, u) => JSON.stringify(d) === JSON.stringify(u);
12
+ function V({ onClose: d }) {
13
+ const u = E(), O = P(), p = U("/config/candidates", void 0, {
14
+ lenses: !1,
15
+ staleTime: 0
16
+ }), c = p.data, [h, f] = C(null), [t, m] = C(null), [g, w] = C("");
17
+ D(() => {
18
+ c && (f((e) => e ?? c.config.geo_collections), w((e) => e || String(c.config.stuck_days)), m((e) => {
19
+ if (e) return e;
20
+ const s = c.config.region;
21
+ if (s === !1) return { mode: "none" };
22
+ if (!s) return { mode: "auto" };
23
+ const i = c.regions.findIndex((k) => A(k.source, s));
24
+ return i >= 0 ? { mode: "source", index: i } : { mode: "auto" };
25
+ }));
26
+ }, [c]);
27
+ const b = B({
28
+ mutationFn: () => {
29
+ var s;
30
+ const e = Math.round(Number(g));
31
+ return u.request(
32
+ I("/command-center/config", {
33
+ geo_collections: h ?? [],
34
+ region: (t == null ? void 0 : t.mode) === "none" ? !1 : (t == null ? void 0 : t.mode) === "source" && c ? ((s = c.regions[t.index]) == null ? void 0 : s.source) ?? null : null,
35
+ stuck_days: Number.isFinite(e) ? e : 7
36
+ })
37
+ );
38
+ },
39
+ onSuccess: () => {
40
+ S.success("Board settings saved"), O.invalidateQueries({ queryKey: ["command-center"] }), d();
41
+ },
42
+ onError: (e) => {
43
+ const s = e;
44
+ s.code === "MIGRATION_PENDING" || s.status === 409 ? S.error("These settings can be saved once this instance finishes its update.") : S.error(s.message || "Could not save the board settings");
45
+ }
46
+ }), N = c == null ? void 0 : c.regions.find((e) => e.suggested), T = (h ?? []).length === 0, F = (e) => f((s) => {
47
+ const i = s ?? [];
48
+ return i.includes(e) ? i.filter((k) => k !== e) : [...i, e];
49
+ }), M = (e) => f((s) => [e, ...(s ?? []).filter((i) => i !== e)]), x = Number(g), y = Number.isFinite(x) && x >= 1 && x <= 365, v = (e) => a(
50
+ "flex w-full cursor-pointer items-start gap-2 rounded-md border px-2.5 py-2 text-left",
51
+ e ? "border-nvr-cyan bg-nvr-cyan/10" : "border-[var(--cc-border)] hover:bg-[var(--cc-chip)]"
52
+ );
53
+ return /* @__PURE__ */ o(
54
+ q,
55
+ {
56
+ open: !0,
57
+ label: "Board settings",
58
+ title: "Board settings",
59
+ subtitle: "For everyone who opens the Command Center",
60
+ onClose: d,
61
+ width: 460,
62
+ footer: /* @__PURE__ */ o("div", { className: "flex items-center justify-end gap-2", children: [
63
+ /* @__PURE__ */ n("button", { type: "button", onClick: d, className: a(_, l), children: "Cancel" }),
64
+ /* @__PURE__ */ n(
65
+ "button",
66
+ {
67
+ type: "button",
68
+ disabled: !c || !y || b.isPending,
69
+ onClick: () => b.mutate(),
70
+ className: a(
71
+ "rounded-md bg-nvr-cyan px-3 py-1 text-[11.5px] font-medium text-white disabled:opacity-50",
72
+ l
73
+ ),
74
+ children: b.isPending ? "Saving…" : "Save"
75
+ }
76
+ )
77
+ ] }),
78
+ children: [
79
+ p.isLoading && /* @__PURE__ */ n("p", { className: `text-[12px] ${$}`, children: "Looking at the data model…" }),
80
+ p.isError && /* @__PURE__ */ n("p", { className: "text-[12px] text-[var(--cc-bad-text)]", children: "Could not load the choices." }),
81
+ c && /* @__PURE__ */ o("div", { className: "space-y-5 text-[12px]", children: [
82
+ /* @__PURE__ */ o("section", { "aria-labelledby": "cc-set-map", children: [
83
+ /* @__PURE__ */ n("h3", { id: "cc-set-map", className: "mb-1 font-semibold text-[var(--cc-strong)]", children: "Map collections" }),
84
+ /* @__PURE__ */ n("p", { className: `mb-2 ${r}`, children: "Collections with a latitude and longitude field. Pick the ones to offer on the map; the first is shown by default. Pick none to offer every one found." }),
85
+ c.geo.length === 0 && /* @__PURE__ */ n("p", { className: $, children: "No collection has latitude and longitude fields yet." }),
86
+ /* @__PURE__ */ n("ul", { className: "space-y-1", children: c.geo.map((e) => {
87
+ const s = (h ?? []).indexOf(e.key);
88
+ return /* @__PURE__ */ o("li", { className: "flex items-center gap-2", children: [
89
+ /* @__PURE__ */ o("label", { className: "flex flex-1 cursor-pointer items-center gap-2", children: [
90
+ /* @__PURE__ */ n(
91
+ "input",
92
+ {
93
+ type: "checkbox",
94
+ checked: s >= 0,
95
+ onChange: () => F(e.key),
96
+ className: a("h-3.5 w-3.5 accent-[#00a5cc]", l)
97
+ }
98
+ ),
99
+ /* @__PURE__ */ n("span", { children: e.label })
100
+ ] }),
101
+ s === 0 && /* @__PURE__ */ n("span", { className: `text-[11px] ${r}`, children: "Default" }),
102
+ s > 0 && /* @__PURE__ */ n(
103
+ "button",
104
+ {
105
+ type: "button",
106
+ onClick: () => M(e.key),
107
+ className: a(
108
+ "text-[11px] underline-offset-2 hover:underline",
109
+ $,
110
+ l
111
+ ),
112
+ children: "Make default"
113
+ }
114
+ )
115
+ ] }, e.key);
116
+ }) }),
117
+ T && c.geo.length > 0 && /* @__PURE__ */ o("p", { className: `mt-1.5 text-[11px] ${r}`, children: [
118
+ "Offering all ",
119
+ c.geo.length,
120
+ " found."
121
+ ] })
122
+ ] }),
123
+ /* @__PURE__ */ o("section", { "aria-labelledby": "cc-set-region", children: [
124
+ /* @__PURE__ */ n("h3", { id: "cc-set-region", className: "mb-1 font-semibold text-[var(--cc-strong)]", children: "Regions" }),
125
+ /* @__PURE__ */ n("p", { className: `mb-2 ${r}`, children: "Regions group the map and the people on it, and let the board focus on one place." }),
126
+ /* @__PURE__ */ o("div", { className: "space-y-1.5", role: "radiogroup", "aria-labelledby": "cc-set-region", children: [
127
+ /* @__PURE__ */ o("label", { className: v((t == null ? void 0 : t.mode) === "auto"), children: [
128
+ /* @__PURE__ */ n(
129
+ "input",
130
+ {
131
+ type: "radio",
132
+ name: "cc-region",
133
+ checked: (t == null ? void 0 : t.mode) === "auto",
134
+ onChange: () => m({ mode: "auto" }),
135
+ className: a("mt-0.5", l)
136
+ }
137
+ ),
138
+ /* @__PURE__ */ o("span", { children: [
139
+ /* @__PURE__ */ n("span", { className: "font-medium text-[var(--cc-strong)]", children: "Work it out for me" }),
140
+ /* @__PURE__ */ n("span", { className: `block ${r}`, children: N ? `Uses ${N.label}: ${N.description}` : "Nothing in the data model looks like a region yet." })
141
+ ] })
142
+ ] }),
143
+ c.regions.map((e, s) => /* @__PURE__ */ o(
144
+ "label",
145
+ {
146
+ className: v((t == null ? void 0 : t.mode) === "source" && t.index === s),
147
+ children: [
148
+ /* @__PURE__ */ n(
149
+ "input",
150
+ {
151
+ type: "radio",
152
+ name: "cc-region",
153
+ checked: (t == null ? void 0 : t.mode) === "source" && t.index === s,
154
+ onChange: () => m({ mode: "source", index: s }),
155
+ className: a("mt-0.5", l)
156
+ }
157
+ ),
158
+ /* @__PURE__ */ o("span", { children: [
159
+ /* @__PURE__ */ o("span", { className: "font-medium text-[var(--cc-strong)]", children: [
160
+ e.label,
161
+ e.suggested && /* @__PURE__ */ n("span", { className: `ml-1.5 font-normal ${r}`, children: "(suggested)" })
162
+ ] }),
163
+ /* @__PURE__ */ n("span", { className: `block ${r}`, children: e.description })
164
+ ] })
165
+ ]
166
+ },
167
+ JSON.stringify(e.source)
168
+ )),
169
+ /* @__PURE__ */ o("label", { className: v((t == null ? void 0 : t.mode) === "none"), children: [
170
+ /* @__PURE__ */ n(
171
+ "input",
172
+ {
173
+ type: "radio",
174
+ name: "cc-region",
175
+ checked: (t == null ? void 0 : t.mode) === "none",
176
+ onChange: () => m({ mode: "none" }),
177
+ className: a("mt-0.5", l)
178
+ }
179
+ ),
180
+ /* @__PURE__ */ o("span", { children: [
181
+ /* @__PURE__ */ n("span", { className: "font-medium text-[var(--cc-strong)]", children: "No regions" }),
182
+ /* @__PURE__ */ n("span", { className: `block ${r}`, children: "Show records and people without grouping them." })
183
+ ] })
184
+ ] })
185
+ ] })
186
+ ] }),
187
+ /* @__PURE__ */ o("section", { "aria-labelledby": "cc-set-stuck", children: [
188
+ /* @__PURE__ */ n("h3", { id: "cc-set-stuck", className: "mb-1 font-semibold text-[var(--cc-strong)]", children: "Stuck after" }),
189
+ /* @__PURE__ */ o("label", { className: "flex items-center gap-2", children: [
190
+ /* @__PURE__ */ n(
191
+ "input",
192
+ {
193
+ type: "number",
194
+ min: 1,
195
+ max: 365,
196
+ value: g,
197
+ onChange: (e) => w(e.target.value),
198
+ "aria-describedby": "cc-set-stuck-help",
199
+ className: a(
200
+ "w-20 rounded-md border border-[var(--cc-border)] bg-[var(--cc-panel)] px-2 py-1 text-[12px] text-[var(--cc-text)]",
201
+ l
202
+ )
203
+ }
204
+ ),
205
+ /* @__PURE__ */ n("span", { children: "days in one step" })
206
+ ] }),
207
+ /* @__PURE__ */ n(
208
+ "p",
209
+ {
210
+ id: "cc-set-stuck-help",
211
+ className: `mt-1 ${y ? r : "text-[var(--cc-bad-text)]"}`,
212
+ children: y ? "A record waiting this long in one step counts as stuck." : "Use a number from 1 to 365."
213
+ }
214
+ )
215
+ ] })
216
+ ] })
217
+ ]
218
+ }
219
+ );
220
+ }
221
+ export {
222
+ V as BoardSettings
223
+ };
@@ -0,0 +1,149 @@
1
+ import { jsxs as u, jsx as n, Fragment as P } from "react/jsx-runtime";
2
+ import { useQueryClient as S } from "@tanstack/react-query";
3
+ import { useState as d, useRef as m, useCallback as A, useEffect as D, useMemo as _ } from "react";
4
+ import { useCcQuery as I } from "../api.js";
5
+ import { useCc as R } from "../state.js";
6
+ import { PANEL as U, PANEL_HEAD as B, TITLE as M, FAINT as v, FOCUS as y, BUTTON as O, rel as Q, MUTED as q } from "../theme.js";
7
+ import { useCcPulse as j, clockLabel as $ } from "../time.js";
8
+ import { LiveOnlyBadge as H } from "./TimeBar.js";
9
+ const K = /* @__PURE__ */ new Set(["create", "update", "delete", "pipeline-transition", "transition"]), z = [
10
+ { key: "all", label: "Everything" },
11
+ { key: "records", label: "Records" },
12
+ { key: "transitions", label: "Pipeline moves" },
13
+ { key: "team", label: "My team" }
14
+ ];
15
+ function G(e, s) {
16
+ return !e.action || !K.has(e.action) || !e.collection || /^(nivaro|directus)_/.test(e.collection) ? !1 : s === "records" ? ["create", "update", "delete"].includes(e.action) : s === "transitions" ? /transition/.test(e.action) : !0;
17
+ }
18
+ function J(e, s) {
19
+ var c;
20
+ const r = new Set(e.map((a) => a.id)), i = ((c = e[0]) == null ? void 0 : c.id) ?? 0;
21
+ return s.filter((a) => !r.has(a.id) && a.id > i).length;
22
+ }
23
+ function ie() {
24
+ var k;
25
+ const e = R(), s = S(), [r, i] = d("all"), [c, a] = d(!1), [T, x] = d(!1), [L, b] = d(!1), o = e.at != null, p = c || T || L, E = W(
26
+ () => void s.invalidateQueries({ queryKey: ["command-center", "/activity"] }),
27
+ 1500
28
+ ), f = j(e.isAdmin && !o && !e.kiosk, (t) => {
29
+ G(t, r) && E();
30
+ }), w = I(
31
+ "/activity",
32
+ { filter: r, limit: 40 },
33
+ {
34
+ refetchInterval: o ? !1 : f ? 6e4 : 1e4,
35
+ placeholderData: (t) => t
36
+ }
37
+ ), h = w.data ?? ((k = e.snapshot) == null ? void 0 : k.activity) ?? [], l = m(null);
38
+ p && !l.current && (l.current = h), !p && l.current && (l.current = null);
39
+ const N = l.current ?? h, g = l.current ? J(l.current, h) : 0, F = A(
40
+ (t) => {
41
+ t.collection && t.item && e.setPeek({ collection: t.collection, id: t.item });
42
+ },
43
+ [e]
44
+ ), C = o ? `As of ${$(e.at)}` : p ? g > 0 ? `Paused · ${g} new` : "Paused" : f ? "Live" : "Updates every 10 s";
45
+ return /* @__PURE__ */ u(
46
+ "section",
47
+ {
48
+ className: `${U} flex min-h-0 shrink-0 flex-col`,
49
+ "data-cc-panel": "feed",
50
+ "aria-label": "Live feed",
51
+ children: [
52
+ /* @__PURE__ */ u("div", { className: `${B} flex-wrap`, children: [
53
+ /* @__PURE__ */ u("div", { className: "flex min-w-0 items-center gap-2", children: [
54
+ /* @__PURE__ */ n("h2", { className: M, children: "Live feed" }),
55
+ /* @__PURE__ */ n("span", { className: `text-[11.5px] ${v}`, "aria-live": "polite", children: C })
56
+ ] }),
57
+ /* @__PURE__ */ u("div", { className: "flex flex-wrap items-center gap-1.5", children: [
58
+ /* @__PURE__ */ n("fieldset", { className: "flex flex-wrap items-center gap-1", "aria-label": "Show", children: z.map((t) => /* @__PURE__ */ n(
59
+ "button",
60
+ {
61
+ type: "button",
62
+ "aria-pressed": r === t.key,
63
+ onClick: () => i(t.key),
64
+ className: `rounded-full px-2 py-0.5 text-[11.5px] ${y} ${r === t.key ? "bg-nvr-cyan/15 font-medium text-[var(--cc-strong)]" : "bg-[var(--cc-chip)] text-[var(--cc-text)] hover:bg-[var(--cc-chip-hover)]"}`,
65
+ children: t.label
66
+ },
67
+ t.key
68
+ )) }),
69
+ !o && /* @__PURE__ */ n(
70
+ "button",
71
+ {
72
+ type: "button",
73
+ className: `${O} ${y}`,
74
+ "aria-pressed": c,
75
+ onClick: () => a((t) => !t),
76
+ children: c ? "Resume" : "Pause"
77
+ }
78
+ )
79
+ ] })
80
+ ] }),
81
+ /* @__PURE__ */ n(
82
+ "div",
83
+ {
84
+ className: "max-h-[240px] min-h-[64px] overflow-y-auto",
85
+ onMouseEnter: () => x(!0),
86
+ onMouseLeave: () => x(!1),
87
+ onFocus: () => b(!0),
88
+ onBlur: (t) => {
89
+ t.currentTarget.contains(t.relatedTarget) || b(!1);
90
+ },
91
+ children: N.length === 0 ? /* @__PURE__ */ n("p", { className: `px-3 py-3 text-[12px] ${v}`, children: w.isLoading ? "Loading…" : o ? "Nothing you can see was written before then." : "Quiet — no recent activity you can see." }) : /* @__PURE__ */ n("ul", { className: "divide-y divide-[var(--cc-border)]", children: N.map((t) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(V, { entry: t, onOpen: F }) }, t.id)) })
92
+ }
93
+ ),
94
+ e.isAdmin && !o && !f && /* @__PURE__ */ n("div", { className: "border-t border-[var(--cc-border)] px-3 py-1.5", children: /* @__PURE__ */ n(H, { label: "Refreshes every 10 s" }) })
95
+ ]
96
+ }
97
+ );
98
+ }
99
+ function V({ entry: e, onOpen: s }) {
100
+ const r = e.sentence || `${e.user_name || "System"} ${e.action.replace(/-/g, " ")}${e.collection ? ` ${e.collection_label ?? e.collection.replace(/_/g, " ")}` : ""}`, i = new Date(e.timestamp).getTime(), c = /* @__PURE__ */ u(P, { children: [
101
+ /* @__PURE__ */ n(
102
+ "span",
103
+ {
104
+ className: `w-9 shrink-0 text-right tabular-nums text-[11px] ${v}`,
105
+ "data-tip": Number.isFinite(i) ? $(i) : void 0,
106
+ children: Q(e.timestamp)
107
+ }
108
+ ),
109
+ /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate", children: r }),
110
+ e.collection_label && /* @__PURE__ */ n("span", { className: `hidden shrink-0 text-[11px] sm:inline ${q}`, children: e.collection_label })
111
+ ] }), a = "flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-[12px] text-[var(--cc-text)]";
112
+ return !e.collection || !e.item ? /* @__PURE__ */ n("div", { className: a, "data-cc-feed-entry": e.id, children: c }) : /* @__PURE__ */ n(
113
+ "button",
114
+ {
115
+ type: "button",
116
+ onClick: () => s(e),
117
+ className: `${a} hover:bg-[var(--cc-chip)] ${y}`,
118
+ "aria-label": `${r} — open`,
119
+ "data-cc-feed-entry": e.id,
120
+ children: c
121
+ }
122
+ );
123
+ }
124
+ function W(e, s) {
125
+ const r = m(0), i = m(null), c = m(e);
126
+ return c.current = e, D(
127
+ () => () => {
128
+ i.current && clearTimeout(i.current);
129
+ },
130
+ []
131
+ ), _(
132
+ () => () => {
133
+ const a = r.current + s - Date.now();
134
+ if (a <= 0) {
135
+ r.current = Date.now(), c.current();
136
+ return;
137
+ }
138
+ i.current || (i.current = setTimeout(() => {
139
+ i.current = null, r.current = Date.now(), c.current();
140
+ }, a));
141
+ },
142
+ [s]
143
+ );
144
+ }
145
+ export {
146
+ ie as FeedPanel,
147
+ J as newSince,
148
+ G as pulseMatters
149
+ };