@nivaro/react 0.3.45 → 0.3.47

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 (90) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +290 -23
  4. package/dist/index.js +679 -659
  5. package/dist/shared/components/BaseMap.js +149 -103
  6. package/dist/shared/components/CollectionBrowserView.js +813 -826
  7. package/dist/shared/components/ErrorNotice.js +169 -0
  8. package/dist/shared/components/ErrorSurface.js +23 -17
  9. package/dist/shared/components/ListLoadError.js +8 -29
  10. package/dist/shared/components/LoadErrorNote.js +38 -21
  11. package/dist/shared/components/QueryErrorState.js +8 -11
  12. package/dist/shared/components/ReportView.js +1320 -1291
  13. package/dist/shared/components/chat/ChannelArchive.js +60 -60
  14. package/dist/shared/components/chat/ChannelExtras.js +74 -74
  15. package/dist/shared/components/chat/ChatPanel.js +368 -367
  16. package/dist/shared/components/command-center/CommandCenterView.js +313 -69
  17. package/dist/shared/components/command-center/Customize.js +353 -0
  18. package/dist/shared/components/command-center/Header.js +279 -53
  19. package/dist/shared/components/command-center/KioskLinks.js +198 -0
  20. package/dist/shared/components/command-center/PeekPanel.js +144 -3
  21. package/dist/shared/components/command-center/announce.js +13 -0
  22. package/dist/shared/components/command-center/board-prefs.js +99 -0
  23. package/dist/shared/components/command-center/freshness.js +29 -0
  24. package/dist/shared/components/command-center/layout.js +56 -0
  25. package/dist/shared/components/command-center/panels/AttentionPanel.js +132 -3
  26. package/dist/shared/components/command-center/panels/Banner.js +75 -0
  27. package/dist/shared/components/command-center/panels/BoardSettings.js +224 -0
  28. package/dist/shared/components/command-center/panels/FeedPanel.js +145 -29
  29. package/dist/shared/components/command-center/panels/FlowPanel.js +154 -56
  30. package/dist/shared/components/command-center/panels/ForecastPanel.js +244 -3
  31. package/dist/shared/components/command-center/panels/MapLegend.js +266 -0
  32. package/dist/shared/components/command-center/panels/MapPanel.js +216 -66
  33. package/dist/shared/components/command-center/panels/PartnersPanel.js +49 -3
  34. package/dist/shared/components/command-center/panels/PeoplePanel.js +258 -40
  35. package/dist/shared/components/command-center/panels/RegionPicker.js +88 -3
  36. package/dist/shared/components/command-center/panels/SystemPanel.js +158 -38
  37. package/dist/shared/components/command-center/panels/ThroughputPanel.js +307 -3
  38. package/dist/shared/components/command-center/panels/TimeBar.js +227 -6
  39. package/dist/shared/components/command-center/panels/TrafficPanel.js +12 -8
  40. package/dist/shared/components/command-center/panels/WorkloadPanel.js +82 -3
  41. package/dist/shared/components/command-center/panels/attention-actions.js +267 -0
  42. package/dist/shared/components/command-center/panels/map-shared.js +95 -0
  43. package/dist/shared/components/command-center/panels/registry.js +87 -19
  44. package/dist/shared/components/command-center/shell-hooks.js +118 -0
  45. package/dist/shared/components/command-center/shortcuts.js +37 -0
  46. package/dist/shared/components/command-center/theme.js +39 -21
  47. package/dist/shared/components/command-center/time.js +52 -0
  48. package/dist/shared/components/command-center/url-state.js +54 -0
  49. package/dist/shared/components/command-center/work-links.js +32 -0
  50. package/dist/shared/components/help-videos/editor/ClipsPanel.js +49 -48
  51. package/dist/shared/components/help-videos/editor/PublishButton.js +37 -36
  52. package/dist/shared/components/help-videos/editor/StatsTab.js +45 -44
  53. package/dist/shared/components/help-videos/editor/VersionsTab.js +29 -28
  54. package/dist/shared/components/help-videos/library/AuthorRolesButton.js +19 -18
  55. package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +132 -129
  56. package/dist/shared/components/help-videos/library/LearningPathsPanel.js +42 -41
  57. package/dist/shared/components/help-videos/settings/HouseStyleButton.js +21 -20
  58. package/dist/shared/components/help-videos/settings/RenderSettingsButton.js +22 -21
  59. package/dist/shared/components/import/DocumentAutofillButton.js +24 -20
  60. package/dist/shared/components/import/ImportFromFileButton.js +61 -60
  61. package/dist/shared/components/imports/ImportStalenessControl.js +20 -21
  62. package/dist/shared/components/imports/NewImportDialog.js +29 -28
  63. package/dist/shared/components/imports/RunDetailSheet.js +63 -63
  64. package/dist/shared/components/item-edit/FieldRow.js +329 -329
  65. package/dist/shared/components/item-edit/InlineTableField.js +898 -898
  66. package/dist/shared/components/item-edit/PersonalDefaultControl.js +57 -56
  67. package/dist/shared/components/item-edit/PlanGrid.js +220 -221
  68. package/dist/shared/components/item-edit/RecordGrantTools.js +49 -48
  69. package/dist/shared/components/item-edit/placement-behaviour.js +68 -67
  70. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +24 -23
  71. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +17 -16
  72. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +41 -41
  73. package/dist/shared/components/layout-editor/outputs/output-api.js +33 -31
  74. package/dist/shared/components/layout-editor/overview/overview-api.js +84 -83
  75. package/dist/shared/components/layout-editor/useLayoutDraft.js +47 -42
  76. package/dist/shared/components/monitoring/InactiveUserLinksView.js +10 -9
  77. package/dist/shared/components/monitoring/TrafficMiniMap.js +111 -70
  78. package/dist/shared/components/panels/SlaClock.js +35 -36
  79. package/dist/shared/components/pipeline/PipelineEditorView.js +311 -312
  80. package/dist/shared/components/pipeline/TeamSuggestions.js +31 -30
  81. package/dist/shared/components/profile/AgentsPanel.js +73 -72
  82. package/dist/shared/components/profile/MailSuppressedPill.js +22 -21
  83. package/dist/shared/components/support/SupportRequestDialog.js +85 -81
  84. package/dist/shared/components/support/SupportView.js +94 -87
  85. package/dist/shared/lib/autofill-poll.js +21 -18
  86. package/dist/shared/lib/error-actions.js +85 -0
  87. package/dist/shared/lib/error-message.js +223 -82
  88. package/dist/shared/lib/error-toast.js +71 -13
  89. package/dist/shared/lib/safe-error.js +136 -38
  90. package/package.json +1 -1
@@ -1,6 +1,147 @@
1
- function e() {
2
- return null;
1
+ import { jsxs as l, jsx as n } from "react/jsx-runtime";
2
+ import { useQueryClient as g, useMutation as y } from "@tanstack/react-query";
3
+ import { ExternalLink as k } from "lucide-react";
4
+ import { useState as C, useEffect as w } from "react";
5
+ import { toast as $ } from "sonner";
6
+ import { useNivaroClient as P } from "../../context.js";
7
+ import { post as T } from "../../lib/commands.js";
8
+ import { toastError as E } from "../../lib/error-toast.js";
9
+ import { cn as p } from "../../lib/utils.js";
10
+ import { useCcQuery as S } from "./api.js";
11
+ import { CcSidePanel as U, slaWords as A } from "./panels/map-shared.js";
12
+ import { useCc as M } from "./state.js";
13
+ import { MUTED as u, FOCUS as b, BUTTON as v, FAINT as d } from "./theme.js";
14
+ function H() {
15
+ var i;
16
+ const e = M(), s = e.peek, m = () => e.setPeek(null), r = S(
17
+ "/peek",
18
+ s ? { collection: s.collection, id: s.id } : {},
19
+ { enabled: !!s, lenses: !1, retry: !1, staleTime: 15e3 }
20
+ ), a = r.data, o = r.isError && ((i = r.error) == null ? void 0 : i.status) === 404;
21
+ return /* @__PURE__ */ l(
22
+ U,
23
+ {
24
+ peek: !0,
25
+ open: !!s,
26
+ label: "Record preview",
27
+ title: a ? a.title : o ? "Not available" : "Loading…",
28
+ subtitle: a == null ? void 0 : a.collection_label,
29
+ onClose: m,
30
+ footer: a && /* @__PURE__ */ l(
31
+ "button",
32
+ {
33
+ type: "button",
34
+ onClick: () => {
35
+ e.navigate(e.recordUrl(a.collection, a.id)), m();
36
+ },
37
+ className: p(v, b, "inline-flex items-center gap-1.5"),
38
+ children: [
39
+ /* @__PURE__ */ n(k, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
40
+ " Open full record"
41
+ ]
42
+ }
43
+ ),
44
+ children: [
45
+ r.isLoading && /* @__PURE__ */ n(q, {}),
46
+ o && /* @__PURE__ */ n("p", { className: `text-[12px] ${u}`, children: "This record is not there any more, or you do not have access to it." }),
47
+ r.isError && !o && /* @__PURE__ */ n("p", { className: "text-[12px] text-[var(--cc-bad-text)]", children: "Could not load this record." }),
48
+ a && /* @__PURE__ */ n(F, { rec: a, canAct: !e.kiosk })
49
+ ]
50
+ }
51
+ );
52
+ }
53
+ function q() {
54
+ return /* @__PURE__ */ n("div", { className: "space-y-2", "aria-hidden": "true", children: [70, 45, 90, 60].map((e) => /* @__PURE__ */ n(
55
+ "div",
56
+ {
57
+ className: "h-3 animate-pulse rounded bg-[var(--cc-chip-hover)]",
58
+ style: { width: `${e}%` }
59
+ },
60
+ e
61
+ )) });
62
+ }
63
+ function F({ rec: e, canAct: s }) {
64
+ const m = P(), r = g(), [a, o] = C(null);
65
+ w(() => {
66
+ if (!a) return;
67
+ const t = setTimeout(() => o(null), 6e3);
68
+ return () => clearTimeout(t);
69
+ }, [a]);
70
+ const i = y({
71
+ mutationFn: (t) => m.request(
72
+ T(
73
+ `/pipelines/instance/${encodeURIComponent(e.collection)}/${encodeURIComponent(e.id)}/transition`,
74
+ { transition_id: t }
75
+ )
76
+ ),
77
+ onSuccess: (t, c) => {
78
+ var f;
79
+ const x = ((f = e.transitions.find((N) => N.key === c)) == null ? void 0 : f.label) ?? "Moved";
80
+ $.success(`${x} — done`), o(null), r.invalidateQueries({ queryKey: ["command-center"] });
81
+ },
82
+ onError: (t) => {
83
+ o(null), E(t, "That move did not go through");
84
+ }
85
+ }), h = A(e.sla);
86
+ return /* @__PURE__ */ l("div", { className: "space-y-4 text-[12px]", children: [
87
+ /* @__PURE__ */ l("div", { className: "flex flex-wrap items-center gap-1.5", children: [
88
+ e.state && /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-[var(--cc-chip)] px-2 py-0.5", children: [
89
+ /* @__PURE__ */ n(
90
+ "span",
91
+ {
92
+ className: "h-2 w-2 rounded-full",
93
+ style: { background: e.state.color ?? "#00a5cc" },
94
+ "aria-hidden": "true"
95
+ }
96
+ ),
97
+ e.state.label
98
+ ] }),
99
+ h && /* @__PURE__ */ n(
100
+ "span",
101
+ {
102
+ className: p(
103
+ "rounded-full px-2 py-0.5 font-medium",
104
+ e.sla === "breached" ? "bg-red-500/15 text-[var(--cc-bad-text)]" : "bg-amber-500/15 text-[var(--cc-warn-text)]"
105
+ ),
106
+ children: h
107
+ }
108
+ ),
109
+ e.sla === "ok" && /* @__PURE__ */ n("span", { className: `rounded-full bg-[var(--cc-chip)] px-2 py-0.5 ${u}`, children: "SLA on time" }),
110
+ !e.state && /* @__PURE__ */ n("span", { className: d, children: "Not in a pipeline" })
111
+ ] }),
112
+ /* @__PURE__ */ l("div", { children: [
113
+ /* @__PURE__ */ n("p", { className: `mb-1 ${d}`, children: "Owners" }),
114
+ e.owners.length > 0 ? /* @__PURE__ */ n("p", { className: "text-[var(--cc-text)]", children: e.owners.map((t) => t.name).join(", ") }) : /* @__PURE__ */ n("p", { className: u, children: "Nobody owns this step" })
115
+ ] }),
116
+ e.facts.length > 0 && /* @__PURE__ */ n("dl", { className: "grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5", children: e.facts.map((t) => /* @__PURE__ */ l("div", { className: "contents", children: [
117
+ /* @__PURE__ */ n("dt", { className: d, children: t.label }),
118
+ /* @__PURE__ */ n("dd", { className: "min-w-0 break-words text-[var(--cc-text)]", children: t.value })
119
+ ] }, t.label)) }),
120
+ s && e.transitions.length > 0 && /* @__PURE__ */ l("div", { children: [
121
+ /* @__PURE__ */ n("p", { className: `mb-1.5 ${d}`, children: "Move it" }),
122
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap gap-1.5", children: e.transitions.map((t) => {
123
+ const c = a === t.key;
124
+ return /* @__PURE__ */ n(
125
+ "button",
126
+ {
127
+ type: "button",
128
+ disabled: i.isPending,
129
+ onClick: () => c ? i.mutate(t.key) : o(t.key),
130
+ "aria-label": c ? `Confirm: ${t.label}` : t.label,
131
+ className: p(
132
+ v,
133
+ b,
134
+ c && "border-nvr-cyan bg-nvr-cyan text-white hover:bg-nvr-cyan"
135
+ ),
136
+ children: i.isPending && c ? "Moving…" : c ? `Confirm ${t.label}` : t.label
137
+ },
138
+ t.key
139
+ );
140
+ }) }),
141
+ a && !i.isPending && /* @__PURE__ */ n("p", { className: `mt-1.5 ${d}`, role: "status", children: "Click again to confirm. Some moves ask for more on the full record." })
142
+ ] })
143
+ ] });
3
144
  }
4
145
  export {
5
- e as PeekPanel
146
+ H as PeekPanel
6
147
  };
@@ -0,0 +1,13 @@
1
+ function i(n) {
2
+ return Array.isArray(n) ? n.length : n && typeof n == "object" && Array.isArray(n.items) ? n.items.length : null;
3
+ }
4
+ function r(n, t) {
5
+ if (n === null || t === null || n === t) return "";
6
+ if (t === 0) return "Nothing needs attention now.";
7
+ const e = t === 1 ? "1 item needs attention" : `${t} items need attention`;
8
+ return t > n ? `${e} — ${t - n} new.` : `${e}.`;
9
+ }
10
+ export {
11
+ r as attentionAnnouncement,
12
+ i as attentionCount
13
+ };
@@ -0,0 +1,99 @@
1
+ import { useQuery as c, useQueryClient as a, useMutation as i } from "@tanstack/react-query";
2
+ import { useNivaroClient as o } from "../../context.js";
3
+ import { get as l, put as d, post as f, del as q } from "../../lib/commands.js";
4
+ const s = ["command-center", "prefs"], y = ["command-center", "role-defaults"], m = ["command-center", "kiosk-links"], k = {
5
+ layout: null,
6
+ theme: "app",
7
+ saved_views: [],
8
+ role_default: null,
9
+ tv_cycle_seconds: 30
10
+ };
11
+ function _(t) {
12
+ const n = o();
13
+ return c({
14
+ queryKey: s,
15
+ queryFn: () => n.request(l("/command-center/prefs")).then((e) => e.data),
16
+ enabled: t,
17
+ staleTime: 5 * 6e4,
18
+ retry: !1
19
+ });
20
+ }
21
+ function p() {
22
+ const t = o(), n = a();
23
+ return i({
24
+ mutationFn: (e) => t.request(d("/command-center/prefs", e)).then((r) => r.data),
25
+ onMutate: async (e) => {
26
+ await n.cancelQueries({ queryKey: s });
27
+ const r = n.getQueryData(s);
28
+ return n.setQueryData(s, { ...k, ...r ?? {}, ...e }), { before: r };
29
+ },
30
+ onError: (e, r, u) => {
31
+ u != null && u.before && n.setQueryData(s, u.before);
32
+ },
33
+ onSuccess: (e) => n.setQueryData(s, e)
34
+ });
35
+ }
36
+ function Q(t) {
37
+ const n = o();
38
+ return c({
39
+ queryKey: y,
40
+ queryFn: () => n.request(l("/command-center/role-defaults")).then((e) => e.data),
41
+ enabled: t
42
+ });
43
+ }
44
+ function S() {
45
+ const t = o(), n = a();
46
+ return i({
47
+ mutationFn: (e) => t.request(d("/command-center/role-defaults", e)).then((r) => r.data),
48
+ onSuccess: (e) => {
49
+ n.setQueryData(y, e), n.invalidateQueries({ queryKey: s });
50
+ }
51
+ });
52
+ }
53
+ function h(t) {
54
+ const n = o();
55
+ return c({
56
+ queryKey: m,
57
+ queryFn: () => n.request(l("/command-center/kiosk-links")).then((e) => e.data),
58
+ enabled: t
59
+ });
60
+ }
61
+ function D() {
62
+ const t = o(), n = a();
63
+ return i({
64
+ mutationFn: (e) => t.request(f("/command-center/kiosk-links", e)).then((r) => r.data),
65
+ onSuccess: () => void n.invalidateQueries({ queryKey: m })
66
+ });
67
+ }
68
+ function E() {
69
+ const t = o(), n = a();
70
+ return i({
71
+ mutationFn: (e) => t.request(q(`/command-center/kiosk-links/${e}`)),
72
+ onSuccess: () => void n.invalidateQueries({ queryKey: m })
73
+ });
74
+ }
75
+ function L(t) {
76
+ const n = o();
77
+ return c({
78
+ queryKey: ["command-center", "kiosk-info", t],
79
+ queryFn: () => n.request(l("/command-center/kiosk", { kiosk: t })).then((e) => e.data),
80
+ enabled: !!t,
81
+ // Re-checked every few minutes, so a revoked or expired link leaves the wall promptly.
82
+ refetchInterval: 5 * 6e4,
83
+ retry: 1
84
+ });
85
+ }
86
+ export {
87
+ k as DEFAULT_PREFS,
88
+ m as KIOSK_LINKS_KEY,
89
+ s as PREFS_KEY,
90
+ y as ROLE_DEFAULTS_KEY,
91
+ _ as useCcPrefs,
92
+ Q as useCcRoleDefaults,
93
+ D as useCreateKioskLink,
94
+ L as useKioskInfo,
95
+ h as useKioskLinks,
96
+ E as useRevokeKioskLink,
97
+ p as useSaveCcPrefs,
98
+ S as useSaveRoleDefault
99
+ };
@@ -0,0 +1,29 @@
1
+ const u = 2;
2
+ function i(n) {
3
+ const t = Math.max(0, Math.floor(n / 1e3));
4
+ if (t < 2) return "just now";
5
+ if (t < 60) return `${t}s ago`;
6
+ const r = Math.floor(t / 60);
7
+ if (r < 60) return `${r}m ago`;
8
+ const o = Math.floor(r / 60);
9
+ return o < 24 ? `${o}h ago` : `${Math.floor(o / 24)}d ago`;
10
+ }
11
+ function a(n) {
12
+ return new Date(n).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });
13
+ }
14
+ function f(n) {
15
+ const { updatedAt: t, failures: r, now: o } = n;
16
+ if (!t) return r >= 2 ? { kind: "failed" } : { kind: "loading" };
17
+ const e = `Updated ${i(o - t)}`;
18
+ return r >= 2 ? { kind: "stale", since: a(t), label: e } : { kind: "fresh", label: e };
19
+ }
20
+ function s(n, t) {
21
+ return Math.max(0, n - t);
22
+ }
23
+ export {
24
+ u as STALE_AFTER_FAILURES,
25
+ a as clockTime,
26
+ s as countFailures,
27
+ i as formatAge,
28
+ f as freshness
29
+ };
@@ -0,0 +1,56 @@
1
+ function s(n, r) {
2
+ return n ?? r ?? null;
3
+ }
4
+ function u(n, r) {
5
+ const o = new Set(n), i = new Set((r == null ? void 0 : r.hidden) ?? []), c = /* @__PURE__ */ new Set(), a = [];
6
+ for (const e of (r == null ? void 0 : r.order) ?? [])
7
+ o.has(e) && !c.has(e) && (c.add(e), a.push(e));
8
+ return n.forEach((e, t) => {
9
+ if (c.has(e)) return;
10
+ c.add(e);
11
+ const f = n.slice(0, t).reverse().find((l) => a.includes(l));
12
+ a.splice(f ? a.indexOf(f) + 1 : 0, 0, e);
13
+ }), a.map((e) => ({ key: e, visible: !i.has(e) }));
14
+ }
15
+ function d(n, r, o) {
16
+ const i = new Set(o), c = ((r == null ? void 0 : r.order) ?? []).filter((e) => !i.has(e)), a = ((r == null ? void 0 : r.hidden) ?? []).filter((e) => !i.has(e));
17
+ return {
18
+ order: [
19
+ ...n.map((e) => e.key),
20
+ ...c.filter((e) => !n.some((t) => t.key === e))
21
+ ],
22
+ hidden: [...n.filter((e) => !e.visible).map((e) => e.key), ...a]
23
+ };
24
+ }
25
+ function m(n, r, o) {
26
+ const i = n.findIndex((t) => t.key === r), c = i + o;
27
+ if (i < 0 || c < 0 || c >= n.length) return n;
28
+ const a = [...n], [e] = a.splice(i, 1);
29
+ return a.splice(c, 0, e), a;
30
+ }
31
+ function h(n, r, o) {
32
+ const i = n.findIndex((t) => t.key === r), c = n.findIndex((t) => t.key === o);
33
+ if (i < 0 || c < 0 || i === c) return n;
34
+ const a = [...n], [e] = a.splice(i, 1);
35
+ return a.splice(c, 0, e), a;
36
+ }
37
+ function p(n, r, o) {
38
+ return n.map((i) => i.key === r ? { ...i, visible: o } : i);
39
+ }
40
+ function w(n) {
41
+ return n < 768 ? "phone" : n < 1280 ? "medium" : n < 1800 ? "wide" : "xwide";
42
+ }
43
+ function x(n, r) {
44
+ const o = n.filter((t) => t.area === "main"), i = n.filter((t) => t.area === "bottom"), c = n.filter((t) => t.area === "lead"), a = n.filter((t) => t.area === "rail"), e = n.filter((t) => t.area === "lead" || t.area === "rail");
45
+ return r === "xwide" ? { columns: "three", lead: c, main: o, under: i, rail: a } : r === "wide" ? { columns: "two", lead: [], main: o, under: i, rail: e } : { columns: "one", lead: c, main: o, under: i, rail: a };
46
+ }
47
+ export {
48
+ x as arrangeBoard,
49
+ w as boardSizeFor,
50
+ s as effectiveLayout,
51
+ d as layoutToSave,
52
+ m as movePanel,
53
+ h as movePanelTo,
54
+ u as resolvePanels,
55
+ p as setPanelVisible
56
+ };
@@ -1,6 +1,135 @@
1
- function n() {
2
- return null;
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
+ ] });
3
132
  }
4
133
  export {
5
- n as AttentionPanel
134
+ Y as AttentionPanel
6
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
+ };