@nivaro/react 0.3.45 → 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 (40) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +42 -7
  4. package/dist/shared/components/BaseMap.js +149 -103
  5. package/dist/shared/components/command-center/CommandCenterView.js +313 -69
  6. package/dist/shared/components/command-center/Customize.js +353 -0
  7. package/dist/shared/components/command-center/Header.js +279 -53
  8. package/dist/shared/components/command-center/KioskLinks.js +198 -0
  9. package/dist/shared/components/command-center/PeekPanel.js +143 -3
  10. package/dist/shared/components/command-center/announce.js +13 -0
  11. package/dist/shared/components/command-center/board-prefs.js +99 -0
  12. package/dist/shared/components/command-center/freshness.js +29 -0
  13. package/dist/shared/components/command-center/layout.js +56 -0
  14. package/dist/shared/components/command-center/panels/AttentionPanel.js +132 -3
  15. package/dist/shared/components/command-center/panels/Banner.js +75 -0
  16. package/dist/shared/components/command-center/panels/BoardSettings.js +223 -0
  17. package/dist/shared/components/command-center/panels/FeedPanel.js +145 -29
  18. package/dist/shared/components/command-center/panels/FlowPanel.js +154 -56
  19. package/dist/shared/components/command-center/panels/ForecastPanel.js +244 -3
  20. package/dist/shared/components/command-center/panels/MapLegend.js +266 -0
  21. package/dist/shared/components/command-center/panels/MapPanel.js +216 -66
  22. package/dist/shared/components/command-center/panels/PartnersPanel.js +49 -3
  23. package/dist/shared/components/command-center/panels/PeoplePanel.js +257 -40
  24. package/dist/shared/components/command-center/panels/RegionPicker.js +88 -3
  25. package/dist/shared/components/command-center/panels/SystemPanel.js +158 -38
  26. package/dist/shared/components/command-center/panels/ThroughputPanel.js +307 -3
  27. package/dist/shared/components/command-center/panels/TimeBar.js +227 -6
  28. package/dist/shared/components/command-center/panels/TrafficPanel.js +12 -8
  29. package/dist/shared/components/command-center/panels/WorkloadPanel.js +82 -3
  30. package/dist/shared/components/command-center/panels/attention-actions.js +267 -0
  31. package/dist/shared/components/command-center/panels/map-shared.js +95 -0
  32. package/dist/shared/components/command-center/panels/registry.js +87 -19
  33. package/dist/shared/components/command-center/shell-hooks.js +118 -0
  34. package/dist/shared/components/command-center/shortcuts.js +37 -0
  35. package/dist/shared/components/command-center/theme.js +39 -21
  36. package/dist/shared/components/command-center/time.js +52 -0
  37. package/dist/shared/components/command-center/url-state.js +54 -0
  38. package/dist/shared/components/command-center/work-links.js +32 -0
  39. package/dist/shared/components/monitoring/TrafficMiniMap.js +111 -70
  40. package/package.json +1 -1
@@ -0,0 +1,95 @@
1
+ import { jsxs as c, jsx as n } from "react/jsx-runtime";
2
+ import { X as w } from "lucide-react";
3
+ import { useRef as m, useEffect as g } from "react";
4
+ import { createPortal as y } from "react-dom";
5
+ import { useCc as k } from "../state.js";
6
+ import { TITLE as N, FAINT as C, FOCUS as E, ccVars as L, useAppIsDark as A } from "../theme.js";
7
+ const o = {
8
+ breached: "#ef4444",
9
+ warning: "#f59e0b",
10
+ ok: "#00a5cc",
11
+ people: "#10b981",
12
+ out: "#8b5cf6",
13
+ activity: "#0ea5e9"
14
+ };
15
+ function j(e) {
16
+ return e === "breached" ? 2 : e === "warning" ? 1 : 0;
17
+ }
18
+ function F(e) {
19
+ return e.sla === "breached" ? o.breached : e.sla === "warning" ? o.warning : e.state_color ?? o.ok;
20
+ }
21
+ function M(e) {
22
+ return e === "breached" ? "SLA breached" : e === "warning" ? "SLA warning" : null;
23
+ }
24
+ function S() {
25
+ const { tv: e } = k();
26
+ return A() || e ? "dark" : "light";
27
+ }
28
+ function _({
29
+ open: e,
30
+ title: p,
31
+ subtitle: a,
32
+ onClose: t,
33
+ children: b,
34
+ footer: i,
35
+ width: h = 400,
36
+ label: v,
37
+ peek: x = !1
38
+ }) {
39
+ const d = S(), s = m(null), l = m(null);
40
+ return g(() => {
41
+ var f;
42
+ if (!e) return;
43
+ l.current = document.activeElement, (f = s.current) == null || f.focus();
44
+ const u = (r) => {
45
+ r.key === "Escape" && (r.stopPropagation(), t());
46
+ };
47
+ return window.addEventListener("keydown", u), () => {
48
+ window.removeEventListener("keydown", u);
49
+ const r = l.current;
50
+ r && typeof r.focus == "function" && document.contains(r) && r.focus();
51
+ };
52
+ }, [e, t]), !e || typeof document > "u" ? null : y(
53
+ /* @__PURE__ */ c(
54
+ "aside",
55
+ {
56
+ role: "dialog",
57
+ "aria-label": v,
58
+ "data-cc-peek": x ? "" : void 0,
59
+ "data-cc-mode": d,
60
+ style: { ...L(d), width: `min(${h}px, 100vw)` },
61
+ className: "fixed inset-y-0 right-0 z-[90] flex flex-col border-l border-[var(--cc-border)] bg-[var(--cc-panel)] text-[var(--cc-text)] shadow-2xl motion-safe:animate-in motion-safe:slide-in-from-right-4",
62
+ children: [
63
+ /* @__PURE__ */ c("div", { className: "flex items-start gap-2 border-b border-[var(--cc-border)] px-4 py-3", children: [
64
+ /* @__PURE__ */ c("div", { className: "min-w-0 flex-1", children: [
65
+ /* @__PURE__ */ n("h2", { className: `${N} text-[14px] leading-snug`, children: p }),
66
+ a && /* @__PURE__ */ n("div", { className: `mt-0.5 text-[11.5px] ${C}`, children: a })
67
+ ] }),
68
+ /* @__PURE__ */ n(
69
+ "button",
70
+ {
71
+ ref: s,
72
+ type: "button",
73
+ onClick: t,
74
+ "aria-label": "Close",
75
+ className: `rounded-md p-1 text-[var(--cc-muted)] hover:bg-[var(--cc-chip)] ${E}`,
76
+ children: /* @__PURE__ */ n(w, { className: "h-4 w-4" })
77
+ }
78
+ )
79
+ ] }),
80
+ /* @__PURE__ */ n("div", { className: "min-h-0 flex-1 overflow-y-auto px-4 py-3", children: b }),
81
+ i && /* @__PURE__ */ n("div", { className: "border-t border-[var(--cc-border)] px-4 py-3", children: i })
82
+ ]
83
+ }
84
+ ),
85
+ document.body
86
+ );
87
+ }
88
+ export {
89
+ _ as CcSidePanel,
90
+ o as MAP_COLORS,
91
+ F as pinColor,
92
+ j as slaRank,
93
+ M as slaWords,
94
+ S as useCcMode
95
+ };
@@ -1,26 +1,94 @@
1
1
  import { AttentionPanel as a } from "./AttentionPanel.js";
2
2
  import { FeedPanel as o } from "./FeedPanel.js";
3
3
  import { FlowPanel as r } from "./FlowPanel.js";
4
- import { ForecastPanel as l } from "./ForecastPanel.js";
5
- import { MapPanel as t } from "./MapPanel.js";
6
- import { PartnersPanel as n } from "./PartnersPanel.js";
7
- import { PeoplePanel as m } from "./PeoplePanel.js";
8
- import { SystemPanel as p } from "./SystemPanel.js";
9
- import { ThroughputPanel as i } from "./ThroughputPanel.js";
10
- import { TrafficPanel as f } from "./TrafficPanel.js";
11
- import { WorkloadPanel as y } from "./WorkloadPanel.js";
4
+ import { ForecastPanel as t } from "./ForecastPanel.js";
5
+ import { MapPanel as n } from "./MapPanel.js";
6
+ import { PartnersPanel as i } from "./PartnersPanel.js";
7
+ import { PeoplePanel as l } from "./PeoplePanel.js";
8
+ import { SystemPanel as m } from "./SystemPanel.js";
9
+ import { ThroughputPanel as s } from "./ThroughputPanel.js";
10
+ import { TrafficPanel as p } from "./TrafficPanel.js";
11
+ import { WorkloadPanel as h } from "./WorkloadPanel.js";
12
12
  const c = [
13
- { key: "map", label: "Live map", area: "main", component: t },
14
- { key: "attention", label: "Needs attention", area: "rail", component: a },
15
- { key: "flow", label: "Pipeline flow", area: "rail", component: r },
16
- { key: "throughput", label: "Throughput today", area: "rail", component: i },
17
- { key: "forecast", label: "Today’s forecast", area: "rail", component: l },
18
- { key: "workload", label: "Workload", area: "rail", component: y },
19
- { key: "people", label: "People on now", area: "rail", component: m },
20
- { key: "partners", label: "Partners", area: "rail", component: n },
21
- { key: "traffic", label: "Traffic", area: "rail", adminOnly: !0, component: f },
22
- { key: "system", label: "System", area: "rail", adminOnly: !0, component: p },
23
- { key: "feed", label: "Live feed", area: "bottom", component: o }
13
+ {
14
+ key: "map",
15
+ label: "Live map",
16
+ area: "main",
17
+ hint: "Where the work is, and who is on",
18
+ component: n
19
+ },
20
+ {
21
+ key: "attention",
22
+ label: "Needs attention",
23
+ area: "lead",
24
+ hint: "Breached and stuck work, failing partners, gaps",
25
+ component: a
26
+ },
27
+ {
28
+ key: "flow",
29
+ label: "Pipeline flow",
30
+ area: "rail",
31
+ hint: "Open records in each state",
32
+ component: r
33
+ },
34
+ {
35
+ key: "throughput",
36
+ label: "Throughput today",
37
+ area: "rail",
38
+ hint: "Moves per hour against yesterday",
39
+ component: s
40
+ },
41
+ {
42
+ key: "forecast",
43
+ label: "Today’s forecast",
44
+ area: "rail",
45
+ hint: "Arrivals and completions against the usual day",
46
+ component: t
47
+ },
48
+ {
49
+ key: "workload",
50
+ label: "Workload",
51
+ area: "lead",
52
+ hint: "Who is over their usual load",
53
+ component: h
54
+ },
55
+ {
56
+ key: "people",
57
+ label: "People on now",
58
+ area: "rail",
59
+ hint: "Who is signed in, by office or region",
60
+ component: l
61
+ },
62
+ {
63
+ key: "partners",
64
+ label: "Partners",
65
+ area: "rail",
66
+ hint: "Health of connected systems",
67
+ component: i
68
+ },
69
+ {
70
+ key: "traffic",
71
+ label: "Traffic",
72
+ area: "rail",
73
+ adminOnly: !0,
74
+ hint: "Live API traffic (administrators)",
75
+ component: p
76
+ },
77
+ {
78
+ key: "system",
79
+ label: "System",
80
+ area: "rail",
81
+ adminOnly: !0,
82
+ hint: "Database, jobs and errors (administrators)",
83
+ component: m
84
+ },
85
+ {
86
+ key: "feed",
87
+ label: "Live feed",
88
+ area: "bottom",
89
+ hint: "The latest changes you can see",
90
+ component: o
91
+ }
24
92
  ];
25
93
  c.map((e) => e.key);
26
94
  export {
@@ -0,0 +1,118 @@
1
+ import { useState as w, useRef as d, useEffect as f, useCallback as v } from "react";
2
+ function x(r = 1e3, t = !0) {
3
+ const [n, o] = w(() => Date.now());
4
+ return f(() => {
5
+ if (!t) return;
6
+ o(Date.now());
7
+ const c = setInterval(() => o(Date.now()), r);
8
+ return () => clearInterval(c);
9
+ }, [r, t]), n;
10
+ }
11
+ const h = () => typeof window > "u" ? 1440 : window.innerWidth;
12
+ function F() {
13
+ const [r, t] = w(h);
14
+ return f(() => {
15
+ const n = () => t(h());
16
+ return window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
17
+ }, []), r;
18
+ }
19
+ function L() {
20
+ const [r, t] = w(!1), n = d(!1);
21
+ f(() => {
22
+ const e = () => {
23
+ !document.fullscreenElement && n.current && (n.current = !1, t(!1));
24
+ };
25
+ return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
26
+ }, []);
27
+ const o = v(() => {
28
+ t(!0);
29
+ const e = document.documentElement;
30
+ document.fullscreenEnabled && e.requestFullscreen && !document.fullscreenElement && e.requestFullscreen().then(() => {
31
+ n.current = !0;
32
+ }).catch(() => {
33
+ n.current = !1;
34
+ });
35
+ }, []), c = v(() => {
36
+ t(!1), document.fullscreenElement && document.exitFullscreen && (n.current = !1, document.exitFullscreen().catch(() => {
37
+ }));
38
+ }, []), i = v(() => r ? c() : o(), [r, o, c]);
39
+ return { on: r, enter: o, exit: c, toggle: i };
40
+ }
41
+ const g = 6e4;
42
+ function y(r, t) {
43
+ const n = [null, ...r], o = n.indexOf(t);
44
+ return n[(o + 1) % n.length] ?? null;
45
+ }
46
+ function I(r) {
47
+ const { enabled: t, regionIds: n, current: o, setRegion: c, intervalMs: i } = r, e = d(0), u = d({ current: o, regionIds: n, setRegion: c });
48
+ u.current = { current: o, regionIds: n, setRegion: c }, f(() => {
49
+ if (!t) return;
50
+ const a = () => {
51
+ e.current = Date.now();
52
+ }, s = ["pointerdown", "keydown", "wheel", "touchstart"];
53
+ for (const m of s) window.addEventListener(m, a, { passive: !0 });
54
+ return () => {
55
+ for (const m of s) window.removeEventListener(m, a);
56
+ };
57
+ }, [t]);
58
+ const l = n.length;
59
+ f(() => {
60
+ if (!t || l === 0) return;
61
+ const a = setInterval(
62
+ () => {
63
+ if (Date.now() - e.current < g) return;
64
+ const s = u.current;
65
+ s.setRegion(y(s.regionIds, s.current));
66
+ },
67
+ Math.max(5e3, i)
68
+ );
69
+ return () => clearInterval(a);
70
+ }, [t, l, i]);
71
+ }
72
+ function k(r) {
73
+ const t = d(null);
74
+ f(() => {
75
+ if (!r) return;
76
+ t.current = document.activeElement ?? null;
77
+ let n = 0, o = 0;
78
+ const c = () => {
79
+ const e = document.querySelector("[data-cc-peek]");
80
+ if (!e) {
81
+ n++ < 20 && (o = requestAnimationFrame(c));
82
+ return;
83
+ }
84
+ if (e.contains(document.activeElement)) return;
85
+ (E(e)[0] ?? e).focus({ preventScroll: !0 });
86
+ };
87
+ o = requestAnimationFrame(c);
88
+ const i = (e) => {
89
+ if (e.key !== "Tab") return;
90
+ const u = document.querySelector("[data-cc-peek]");
91
+ if (!(u != null && u.contains(document.activeElement))) return;
92
+ const l = E(u);
93
+ if (l.length === 0) return;
94
+ const a = l[0], s = l[l.length - 1];
95
+ e.shiftKey && document.activeElement === a ? (e.preventDefault(), s.focus()) : !e.shiftKey && document.activeElement === s && (e.preventDefault(), a.focus());
96
+ };
97
+ return document.addEventListener("keydown", i), () => {
98
+ cancelAnimationFrame(o), document.removeEventListener("keydown", i);
99
+ const e = t.current;
100
+ t.current = null, e != null && e.isConnected && e.focus({ preventScroll: !0 });
101
+ };
102
+ }, [r]);
103
+ }
104
+ const p = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
105
+ function E(r) {
106
+ return Array.from(r.querySelectorAll(p)).filter(
107
+ (t) => !t.hasAttribute("aria-hidden") && t.offsetParent !== null
108
+ );
109
+ }
110
+ export {
111
+ g as TV_IDLE_MS,
112
+ y as nextRegion,
113
+ L as useFullscreen,
114
+ x as useNow,
115
+ k as usePeekFocus,
116
+ I as useRegionCycle,
117
+ F as useWindowWidth
118
+ };
@@ -0,0 +1,37 @@
1
+ const l = [
2
+ { keys: "F", label: "Full screen" },
3
+ { keys: "T", label: "TV mode (larger type, cycles regions)" },
4
+ { keys: "R", label: "Refresh now" },
5
+ { keys: "g", label: "Choose a region" },
6
+ { keys: "1–9", label: "Jump to region 1–9" },
7
+ { keys: "0", label: "Everywhere" },
8
+ { keys: "Esc", label: "Close the record panel, then leave TV mode" },
9
+ { keys: "?", label: "Show these shortcuts" }
10
+ ], i = "cc:focus-region", s = "data-cc-region-picker";
11
+ function o(r) {
12
+ const e = r;
13
+ if (!e || typeof e != "object" || !("tagName" in e)) return !1;
14
+ const t = String(e.tagName).toUpperCase();
15
+ if (t === "INPUT" || t === "TEXTAREA" || t === "SELECT" || e.isContentEditable) return !0;
16
+ const n = typeof e.getAttribute == "function" ? e.getAttribute("role") : null;
17
+ return n === "textbox" || n === "combobox" || n === "searchbox";
18
+ }
19
+ function u(r) {
20
+ if (r.defaultPrevented || r.isComposing || r.ctrlKey || r.metaKey || r.altKey) return null;
21
+ if (r.key === "Escape") return { kind: "escape" };
22
+ if (o(r.target)) return null;
23
+ const e = r.key;
24
+ return e === "f" || e === "F" ? { kind: "fullscreen" } : e === "t" || e === "T" ? { kind: "tv" } : e === "r" || e === "R" ? { kind: "refresh" } : e === "g" || e === "G" ? { kind: "focus-region" } : e === "?" ? { kind: "help" } : /^[0-9]$/.test(e) ? { kind: "region", index: Number(e) } : null;
25
+ }
26
+ function c(r, e) {
27
+ var t;
28
+ return e === 0 ? null : (t = r[e - 1]) == null ? void 0 : t.id;
29
+ }
30
+ export {
31
+ i as FOCUS_REGION_EVENT,
32
+ s as REGION_PICKER_ATTR,
33
+ l as SHORTCUTS,
34
+ o as isTypingTarget,
35
+ c as regionForIndex,
36
+ u as shortcutFor
37
+ };
@@ -8,14 +8,19 @@ const a = {
8
8
  "--cc-text": "#0f172a",
9
9
  "--cc-strong": "#020617",
10
10
  "--cc-muted": "#475569",
11
- "--cc-faint": "#64748b",
11
+ "--cc-faint": "#5d6a7d",
12
12
  "--cc-chip": "rgba(15, 23, 42, 0.05)",
13
13
  "--cc-chip-hover": "rgba(15, 23, 42, 0.09)",
14
14
  "--cc-people": "#059669",
15
15
  "--cc-people-text": "#047857",
16
- "--cc-warn-text": "#b45309",
16
+ "--cc-warn-text": "#92400e",
17
+ "--cc-warn-bg": "rgba(245, 158, 11, 0.14)",
17
18
  "--cc-bad-text": "#b91c1c",
19
+ "--cc-bad-bg": "rgba(239, 68, 68, 0.1)",
18
20
  "--cc-good-text": "#047857",
21
+ "--cc-accent-text": "#155e75",
22
+ "--cc-skeleton": "#e2e8f0",
23
+ "--cc-scrim": "rgba(15, 23, 42, 0.32)",
19
24
  "--cc-map-tint": "0"
20
25
  },
21
26
  dark: {
@@ -26,41 +31,54 @@ const a = {
26
31
  "--cc-text": "#e2e8f0",
27
32
  "--cc-strong": "#ffffff",
28
33
  "--cc-muted": "#94a3b8",
29
- "--cc-faint": "#8291a8",
34
+ "--cc-faint": "#8b9ab0",
30
35
  "--cc-chip": "rgba(255, 255, 255, 0.05)",
31
36
  "--cc-chip-hover": "rgba(255, 255, 255, 0.1)",
32
37
  "--cc-people": "#34d399",
33
38
  "--cc-people-text": "#6ee7b7",
34
39
  "--cc-warn-text": "#fbbf24",
40
+ "--cc-warn-bg": "rgba(251, 191, 36, 0.12)",
35
41
  "--cc-bad-text": "#f87171",
42
+ "--cc-bad-bg": "rgba(248, 113, 113, 0.12)",
36
43
  "--cc-good-text": "#34d399",
44
+ "--cc-accent-text": "#67e8f9",
45
+ "--cc-skeleton": "rgba(255, 255, 255, 0.08)",
46
+ "--cc-scrim": "rgba(0, 0, 0, 0.5)",
37
47
  "--cc-map-tint": "1"
38
48
  }
39
49
  };
40
- function d(e) {
41
- return a[e];
50
+ function i(c) {
51
+ return a[c];
52
+ }
53
+ function b(c) {
54
+ return c.tv || c.kiosk || c.theme === "dark" || c.appDark ? "dark" : "light";
42
55
  }
43
56
  const r = () => typeof document < "u" && document.documentElement.classList.contains("dark");
44
- function b() {
45
- const [e, c] = o(r);
57
+ function d() {
58
+ const [c, e] = o(r);
46
59
  return n(() => {
47
60
  if (typeof MutationObserver > "u") return;
48
- const t = new MutationObserver(() => c(r()));
61
+ const t = new MutationObserver(() => e(r()));
49
62
  return t.observe(document.documentElement, { attributes: !0, attributeFilter: ["class"] }), () => t.disconnect();
50
- }, []), e;
63
+ }, []), c;
51
64
  }
52
- const s = "rounded-lg border border-[var(--cc-border)] bg-[var(--cc-panel)]", i = "flex items-center justify-between gap-2 border-b border-[var(--cc-border)] px-3 py-2", p = "text-[12.5px] font-semibold text-[var(--cc-strong)]", u = "text-[var(--cc-faint)]", x = "rounded-md border border-[var(--cc-border)] px-2.5 py-1 text-[11.5px] text-[var(--cc-text)] hover:bg-[var(--cc-chip)] disabled:opacity-50";
53
- function l(e) {
54
- const c = Math.max(0, Math.floor((Date.now() - new Date(e).getTime()) / 1e3));
55
- return c < 60 ? `${c}s` : c < 3600 ? `${Math.floor(c / 60)}m` : c < 86400 ? `${Math.floor(c / 3600)}h` : `${Math.floor(c / 86400)}d`;
65
+ const f = "rounded-lg border border-[var(--cc-border)] bg-[var(--cc-panel)]", u = "flex items-center justify-between gap-2 border-b border-[var(--cc-border)] px-3 py-2", g = "text-[12.5px] font-semibold text-[var(--cc-strong)]", l = "text-[var(--cc-muted)]", p = "text-[var(--cc-faint)]", v = "rounded-md border border-[var(--cc-border)] px-2.5 py-1 text-[11.5px] text-[var(--cc-text)] hover:bg-[var(--cc-chip)] disabled:opacity-50", x = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan focus-visible:ring-offset-0", m = "inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--cc-muted)] hover:bg-[var(--cc-chip)] hover:text-[var(--cc-strong)] aria-pressed:bg-[var(--cc-chip-hover)] aria-pressed:text-[var(--cc-strong)] disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan", h = "rounded bg-[var(--cc-skeleton)] motion-safe:animate-pulse";
66
+ function k(c) {
67
+ const e = Math.max(0, Math.floor((Date.now() - new Date(c).getTime()) / 1e3));
68
+ return e < 60 ? `${e}s` : e < 3600 ? `${Math.floor(e / 60)}m` : e < 86400 ? `${Math.floor(e / 3600)}h` : `${Math.floor(e / 86400)}d`;
56
69
  }
57
70
  export {
58
- x as BUTTON,
59
- u as FAINT,
60
- s as PANEL,
61
- i as PANEL_HEAD,
62
- p as TITLE,
63
- d as ccVars,
64
- l as rel,
65
- b as useAppIsDark
71
+ v as BUTTON,
72
+ p as FAINT,
73
+ x as FOCUS,
74
+ m as ICON_BUTTON,
75
+ l as MUTED,
76
+ f as PANEL,
77
+ u as PANEL_HEAD,
78
+ h as SKELETON,
79
+ g as TITLE,
80
+ b as boardMode,
81
+ i as ccVars,
82
+ k as rel,
83
+ d as useAppIsDark
66
84
  };
@@ -0,0 +1,52 @@
1
+ import { useRef as m, useEffect as f } from "react";
2
+ import { useLiveEvent as p } from "../../lib/live.js";
3
+ import { useOptionalRealtime as d } from "../../lib/realtime.js";
4
+ import { useCc as v } from "./state.js";
5
+ import { useAppIsDark as D, ccVars as w } from "./theme.js";
6
+ function g(e) {
7
+ return new Date(e).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });
8
+ }
9
+ function b(e, n = Date.now()) {
10
+ const t = new Date(e);
11
+ return new Date(n).toDateString() === t.toDateString() ? g(e) : t.toLocaleString([], {
12
+ weekday: "short",
13
+ month: "short",
14
+ day: "numeric",
15
+ hour: "numeric",
16
+ minute: "2-digit"
17
+ });
18
+ }
19
+ function j(e) {
20
+ const n = new Date(e);
21
+ return n.setHours(0, 0, 0, 0), n.getTime();
22
+ }
23
+ function C(e, n) {
24
+ const t = d(), r = e && !!t, u = m(n);
25
+ return u.current = n, f(() => {
26
+ var s, a;
27
+ if (!r || !t) return;
28
+ t.emit("pulse:join");
29
+ let i = (((s = t.status) == null ? void 0 : s.call(t).state) ?? "live") === "live";
30
+ const o = (a = t.onStatus) == null ? void 0 : a.call(t, (l) => {
31
+ const c = l.state === "live";
32
+ c && !i && t.emit("pulse:join"), i = c;
33
+ });
34
+ return () => {
35
+ o == null || o(), t.emit("pulse:leave");
36
+ };
37
+ }, [r, t]), p("activity:pulse", (i) => u.current(i ?? {}), {
38
+ includeOwn: !0,
39
+ enabled: r
40
+ }), r;
41
+ }
42
+ function O() {
43
+ const { tv: e } = v(), n = D();
44
+ return w(n || e ? "dark" : "light");
45
+ }
46
+ export {
47
+ g as clockLabel,
48
+ j as localDayStart,
49
+ C as useCcPulse,
50
+ O as usePortalVars,
51
+ b as whenLabel
52
+ };
@@ -0,0 +1,54 @@
1
+ const m = {
2
+ region: null,
3
+ at: null,
4
+ map: null,
5
+ peek: null,
6
+ tv: !1
7
+ }, f = ["region", "at", "map", "peek", "tv"], u = /^[A-Za-z0-9_-]{1,64}$/, p = /^[A-Za-z0-9_]{1,64}$/, g = 31 * 864e5;
8
+ function h(n, e = Date.now()) {
9
+ const t = new URLSearchParams(n.startsWith("?") ? n.slice(1) : n), i = t.get("region"), r = t.get("map"), l = t.get("at");
10
+ let s = null;
11
+ if (l) {
12
+ const o = /^\d{10,14}$/.test(l) ? Number(l) : new Date(l).getTime();
13
+ Number.isFinite(o) && o < e && e - o <= g && (s = o);
14
+ }
15
+ let w = null;
16
+ const c = t.get("peek");
17
+ if (c) {
18
+ const o = c.indexOf(":"), d = o > 0 ? c.slice(0, o) : "", a = o > 0 ? c.slice(o + 1) : "";
19
+ p.test(d) && a.length > 0 && a.length <= 128 && (w = { collection: d, id: a });
20
+ }
21
+ return {
22
+ region: i && u.test(i) ? i : null,
23
+ at: s,
24
+ map: r && p.test(r) ? r : null,
25
+ peek: w,
26
+ tv: t.get("tv") === "1"
27
+ };
28
+ }
29
+ function k(n, e) {
30
+ const t = new URLSearchParams(n.startsWith("?") ? n.slice(1) : n);
31
+ for (const r of f) t.delete(r);
32
+ e.region && t.set("region", e.region), e.at && t.set("at", new Date(e.at).toISOString()), e.map && t.set("map", e.map), e.peek && t.set("peek", `${e.peek.collection}:${e.peek.id}`), e.tv && t.set("tv", "1");
33
+ const i = t.toString();
34
+ return i ? `?${i}` : "";
35
+ }
36
+ const S = {
37
+ read: () => typeof window > "u" ? "" : window.location.search,
38
+ replace: (n) => {
39
+ if (typeof window > "u" || n === window.location.search) return;
40
+ const e = `${window.location.pathname}${n}${window.location.hash}`;
41
+ window.history.replaceState(window.history.state, "", e);
42
+ }
43
+ };
44
+ function $() {
45
+ return typeof window > "u" ? "" : window.location.href;
46
+ }
47
+ export {
48
+ f as BOARD_URL_KEYS,
49
+ m as EMPTY_URL_STATE,
50
+ $ as currentViewUrl,
51
+ h as parseBoardUrl,
52
+ S as windowUrlAdapter,
53
+ k as writeBoardUrl
54
+ };
@@ -0,0 +1,32 @@
1
+ import { LIST_LINK_PARAM as u, encodeListLink as a } from "../../lib/list-link.js";
2
+ function c(r, t = {}) {
3
+ const n = {};
4
+ t.state && (n.__state__ = { kind: "state", value: [t.state] }), t.minAgeHours && t.minAgeHours > 0 && (n.__aging__ = { kind: "aging", value: `${Math.round(t.minAgeHours)}:` });
5
+ const e = `/collections/${encodeURIComponent(r)}`;
6
+ return Object.keys(n).length === 0 ? e : `${e}?${u}=${a(`cbv:${r}`, { cf: n })}`;
7
+ }
8
+ function f(r) {
9
+ if (r == null) return "–";
10
+ const t = Math.floor(r / 60);
11
+ if (t < 60) return `${t}m`;
12
+ const n = Math.floor(t / 60);
13
+ return n < 48 ? `${n}h` : `${Math.floor(n / 24)}d`;
14
+ }
15
+ function s(r) {
16
+ if (r == null) return "no records";
17
+ const t = Math.floor(r / 60), n = (o, i) => `${o} ${i}${o === 1 ? "" : "s"}`;
18
+ if (t < 60) return n(t, "minute");
19
+ const e = Math.floor(t / 60);
20
+ return e < 48 ? n(e, "hour") : n(Math.floor(e / 24), "day");
21
+ }
22
+ function h(r) {
23
+ if (!r) return null;
24
+ const t = new Date(r).getTime();
25
+ return Number.isFinite(t) ? f(Math.max(0, (Date.now() - t) / 1e3)) : null;
26
+ }
27
+ export {
28
+ f as ageShort,
29
+ s as ageWords,
30
+ h as sinceShort,
31
+ c as stateListUrl
32
+ };