@nivaro/react 0.3.6 → 0.3.8

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.
@@ -1,92 +1,102 @@
1
- import { jsxs as a, jsx as e, Fragment as D } from "react/jsx-runtime";
2
- import { readUser as E } from "@nivaro/sdk";
3
- import { useQueryClient as P, useQuery as C, useMutation as I } from "@tanstack/react-query";
4
- import { Users as K, CalendarClock as T, UserRound as A, AlertTriangle as q, Check as L } from "lucide-react";
5
- import { useState as k } from "react";
6
- import { useNivaroClient as S, useItemEditAuth as Q, useNavigation as U } from "../../context.js";
7
- import { get as O, post as j } from "../../lib/commands.js";
8
- import { useLiveOps as z } from "../../lib/live-ops.js";
9
- import { cn as g } from "../../lib/utils.js";
10
- import { RelationCombobox as F } from "../item-edit/RelationCombobox.js";
11
- import { DelegationCard as R } from "../profile/DelegationCard.js";
12
- import { UserChip as f } from "../item-edit/UserChip.js";
13
- const y = (l) => l ? new Date(l).toLocaleDateString(void 0, { month: "short", day: "numeric" }) : "—", W = {
1
+ import { jsxs as a, jsx as e, Fragment as E } from "react/jsx-runtime";
2
+ import { readUser as P } from "@nivaro/sdk";
3
+ import { useQueryClient as I, useQuery as $, useMutation as K } from "@tanstack/react-query";
4
+ import { Users as T, CalendarClock as j, UserRound as A, AlertTriangle as O, Check as L } from "lucide-react";
5
+ import { useState as _ } from "react";
6
+ import { useNivaroClient as D, useItemEditAuth as Q, useNavigation as U } from "../../context.js";
7
+ import { get as S, post as z } from "../../lib/commands.js";
8
+ import { useLiveOps as F } from "../../lib/live-ops.js";
9
+ import { cn as m } from "../../lib/utils.js";
10
+ import { RelationCombobox as R } from "../item-edit/RelationCombobox.js";
11
+ import { UserChip as y } from "../item-edit/UserChip.js";
12
+ import { DelegationCard as W } from "../profile/DelegationCard.js";
13
+ const N = (n) => n ? new Date(n).toLocaleDateString(void 0, { month: "short", day: "numeric" }) : "—", M = {
14
14
  none: "no delegate",
15
15
  expired: "delegation expired",
16
16
  suspended: "delegate is suspended",
17
17
  out: "delegate is out too"
18
18
  };
19
- function b({ label: l, value: d, tone: o, hint: s }) {
19
+ function v({
20
+ label: n,
21
+ value: s,
22
+ tone: d,
23
+ hint: o
24
+ }) {
20
25
  return /* @__PURE__ */ a("div", { className: "rounded-lg border border-slate-200 bg-white px-4 py-3 dark:border-border dark:bg-card", children: [
21
- /* @__PURE__ */ e("p", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: l }),
26
+ /* @__PURE__ */ e("p", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: n }),
22
27
  /* @__PURE__ */ e(
23
28
  "p",
24
29
  {
25
- className: g(
30
+ className: m(
26
31
  "mt-1 text-[22px] font-semibold tabular-nums",
27
- o === "bad" ? "text-red-600 dark:text-red-400" : o === "warn" ? "text-amber-700 dark:text-amber-400" : "text-slate-900 dark:text-foreground"
32
+ d === "bad" ? "text-red-600 dark:text-red-400" : d === "warn" ? "text-amber-700 dark:text-amber-400" : "text-slate-900 dark:text-foreground"
28
33
  ),
29
- children: d
34
+ children: s
30
35
  }
31
36
  ),
32
- s && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: s })
37
+ o && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: o })
33
38
  ] });
34
39
  }
35
- function v({ title: l, hint: d, children: o, tone: s }) {
40
+ function f({
41
+ title: n,
42
+ hint: s,
43
+ children: d,
44
+ tone: o
45
+ }) {
36
46
  return /* @__PURE__ */ a(
37
47
  "div",
38
48
  {
39
- className: g(
49
+ className: m(
40
50
  "rounded-lg border bg-white dark:bg-card",
41
- s === "bad" ? "border-red-300 dark:border-red-500/40" : "border-slate-200 dark:border-border"
51
+ o === "bad" ? "border-red-300 dark:border-red-500/40" : "border-slate-200 dark:border-border"
42
52
  ),
43
53
  children: [
44
54
  /* @__PURE__ */ a("header", { className: "border-b border-slate-100 px-4 py-2.5 dark:border-border/60", children: [
45
- /* @__PURE__ */ e("h3", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: l }),
46
- d && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: d })
55
+ /* @__PURE__ */ e("h3", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: n }),
56
+ s && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: s })
47
57
  ] }),
48
- o
58
+ d
49
59
  ]
50
60
  }
51
61
  );
52
62
  }
53
- function M({ e: l }) {
54
- return l.delegate ? /* @__PURE__ */ a("span", { className: "inline-flex flex-wrap items-center gap-1.5", children: [
55
- /* @__PURE__ */ e(f, { userId: l.delegate.id, size: "compact" }),
56
- l.delegate_ok ? /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-0.5 text-[10.5px] text-emerald-700 dark:text-emerald-400", children: [
63
+ function B({ e: n }) {
64
+ return n.delegate ? /* @__PURE__ */ a("span", { className: "inline-flex flex-wrap items-center gap-1.5", children: [
65
+ /* @__PURE__ */ e(y, { userId: n.delegate.id, size: "compact" }),
66
+ n.delegate_ok ? /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-0.5 text-[10.5px] text-emerald-700 dark:text-emerald-400", children: [
57
67
  /* @__PURE__ */ e(L, { className: "h-3 w-3" }),
58
68
  " covering",
59
- l.delegate_expires_at ? ` until ${y(l.delegate_expires_at)}` : ""
69
+ n.delegate_expires_at ? ` until ${N(n.delegate_expires_at)}` : ""
60
70
  ] }) : /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-0.5 rounded-full bg-amber-500/10 px-1.5 py-px text-[10.5px] font-semibold text-amber-700 dark:text-amber-400", children: [
61
- /* @__PURE__ */ e(q, { className: "h-3 w-3" }),
71
+ /* @__PURE__ */ e(O, { className: "h-3 w-3" }),
62
72
  " ",
63
- W[l.delegate_problem ?? "none"]
73
+ M[n.delegate_problem ?? "none"]
64
74
  ] })
65
75
  ] }) : /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-1 rounded-full bg-red-500/10 px-2 py-0.5 text-[10.5px] font-semibold text-red-600 dark:text-red-400", children: [
66
- /* @__PURE__ */ e(q, { className: "h-3 w-3" }),
76
+ /* @__PURE__ */ e(O, { className: "h-3 w-3" }),
67
77
  " No delegate"
68
78
  ] });
69
79
  }
70
- function B({ entry: l, onDone: d }) {
71
- var w, N, c, u;
72
- const o = S(), [s, r] = k(!1), [x, m] = k(((w = l.delegate) == null ? void 0 : w.id) ?? null), [i, _] = k(((N = l.delegate_expires_at) == null ? void 0 : N.slice(0, 10)) ?? ""), n = I({
73
- mutationFn: () => o.request(
74
- j(`/delegation/${l.user.id}/delegate`, {
75
- delegate_id: x,
76
- delegate_expires_at: i ? (/* @__PURE__ */ new Date(`${i}T23:59:59`)).toISOString() : null
80
+ function G({ entry: n, onDone: s }) {
81
+ var l, k, w, i;
82
+ const d = D(), [o, r] = _(!1), [g, b] = _(((l = n.delegate) == null ? void 0 : l.id) ?? null), [c, p] = _(((k = n.delegate_expires_at) == null ? void 0 : k.slice(0, 10)) ?? ""), h = K({
83
+ mutationFn: () => d.request(
84
+ z(`/delegation/${n.user.id}/delegate`, {
85
+ delegate_id: g,
86
+ delegate_expires_at: c ? (/* @__PURE__ */ new Date(`${c}T23:59:59`)).toISOString() : null
77
87
  })
78
88
  ),
79
89
  onSuccess: () => {
80
- r(!1), d();
90
+ r(!1), s();
81
91
  }
82
92
  });
83
- return s ? /* @__PURE__ */ a("div", { className: "flex flex-wrap items-end gap-2", "data-nvr-assign-delegate": !0, children: [
93
+ return o ? /* @__PURE__ */ a("div", { className: "flex flex-wrap items-end gap-2", "data-nvr-assign-delegate": !0, children: [
84
94
  /* @__PURE__ */ e("div", { className: "w-[220px]", children: /* @__PURE__ */ e(
85
- F,
95
+ R,
86
96
  {
87
97
  collection: "nivaro_users",
88
- value: x,
89
- onChange: (p) => m(p == null ? null : String(p)),
98
+ value: g,
99
+ onChange: (x) => b(x == null ? null : String(x)),
90
100
  placeholder: "Pick a delegate…"
91
101
  }
92
102
  ) }),
@@ -94,8 +104,8 @@ function B({ entry: l, onDone: d }) {
94
104
  "input",
95
105
  {
96
106
  type: "date",
97
- value: i,
98
- onChange: (p) => _(p.target.value),
107
+ value: c,
108
+ onChange: (x) => p(x.target.value),
99
109
  "aria-label": "Delegation expires",
100
110
  className: "h-9 rounded-md border border-slate-200 bg-background px-2 text-[12px] dark:border-border"
101
111
  }
@@ -104,10 +114,10 @@ function B({ entry: l, onDone: d }) {
104
114
  "button",
105
115
  {
106
116
  type: "button",
107
- disabled: n.isPending,
108
- onClick: () => n.mutate(),
117
+ disabled: h.isPending,
118
+ onClick: () => h.mutate(),
109
119
  className: "h-9 rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white disabled:opacity-50",
110
- children: n.isPending ? "Saving…" : "Save"
120
+ children: h.isPending ? "Saving…" : "Save"
111
121
  }
112
122
  ),
113
123
  /* @__PURE__ */ e(
@@ -119,31 +129,36 @@ function B({ entry: l, onDone: d }) {
119
129
  children: "Cancel"
120
130
  }
121
131
  ),
122
- n.isError && /* @__PURE__ */ e("span", { className: "text-[11.5px] text-red-600", children: ((u = (c = n.error) == null ? void 0 : c.response) == null ? void 0 : u.error) ?? "Save failed" })
132
+ h.isError && /* @__PURE__ */ e("span", { className: "text-[11.5px] text-red-600", children: ((i = (w = h.error) == null ? void 0 : w.response) == null ? void 0 : i.error) ?? "Save failed" })
123
133
  ] }) : /* @__PURE__ */ e(
124
134
  "button",
125
135
  {
126
136
  type: "button",
127
137
  onClick: () => r(!0),
128
138
  className: "text-[11.5px] text-slate-500 underline decoration-dotted underline-offset-2 hover:text-slate-800 dark:hover:text-slate-200",
129
- children: l.delegate ? "Change" : "Assign delegate"
139
+ children: n.delegate ? "Change" : "Assign delegate"
130
140
  }
131
141
  );
132
142
  }
133
- function $({ rows: l, isAdmin: d, onChanged: o, showWindow: s }) {
134
- return l.length === 0 ? /* @__PURE__ */ e("p", { className: "px-4 py-4 text-[12px] text-slate-400", children: "Nobody." }) : /* @__PURE__ */ a("table", { className: "w-full text-[12px]", children: [
143
+ function q({
144
+ rows: n,
145
+ isAdmin: s,
146
+ onChanged: d,
147
+ showWindow: o
148
+ }) {
149
+ return n.length === 0 ? /* @__PURE__ */ e("p", { className: "px-4 py-4 text-[12px] text-slate-400", children: "Nobody." }) : /* @__PURE__ */ a("table", { className: "w-full text-[12px]", children: [
135
150
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ a("tr", { className: "text-left text-[10.5px] uppercase tracking-wide text-slate-400", children: [
136
151
  /* @__PURE__ */ e("th", { className: "px-4 py-1.5 font-semibold", children: "Person" }),
137
- s && /* @__PURE__ */ e("th", { className: "px-2 py-1.5 font-semibold", children: "Out" }),
152
+ o && /* @__PURE__ */ e("th", { className: "px-2 py-1.5 font-semibold", children: "Out" }),
138
153
  /* @__PURE__ */ e("th", { className: "px-2 py-1.5 font-semibold", children: "Delegate" }),
139
154
  /* @__PURE__ */ e("th", { className: "px-2 py-1.5 font-semibold", children: "Covers" }),
140
155
  /* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right font-semibold", children: "Pending" }),
141
- d && /* @__PURE__ */ e("th", { className: "px-2 py-1.5 font-semibold" })
156
+ s && /* @__PURE__ */ e("th", { className: "px-2 py-1.5 font-semibold" })
142
157
  ] }) }),
143
- /* @__PURE__ */ e("tbody", { children: l.map((r) => /* @__PURE__ */ a("tr", { className: "border-t border-slate-100 align-top dark:border-border", children: [
144
- /* @__PURE__ */ e("td", { className: "px-4 py-2", children: /* @__PURE__ */ e(f, { userId: r.user.id, size: "compact" }) }),
145
- s && /* @__PURE__ */ e("td", { className: "px-2 py-2 whitespace-nowrap text-slate-600 dark:text-muted-foreground", children: r.ooo_start || r.ooo_end ? `${y(r.ooo_start)} → ${r.ooo_end ? y(r.ooo_end) : "open"}` : r.currently_out ? "until switched off" : "—" }),
146
- /* @__PURE__ */ e("td", { className: "px-2 py-2", children: /* @__PURE__ */ e(M, { e: r }) }),
158
+ /* @__PURE__ */ e("tbody", { children: n.map((r) => /* @__PURE__ */ a("tr", { className: "border-t border-slate-100 align-top dark:border-border", children: [
159
+ /* @__PURE__ */ e("td", { className: "px-4 py-2", children: /* @__PURE__ */ e(y, { userId: r.user.id, size: "compact" }) }),
160
+ o && /* @__PURE__ */ e("td", { className: "px-2 py-2 whitespace-nowrap text-slate-600 dark:text-muted-foreground", children: r.ooo_start || r.ooo_end ? `${N(r.ooo_start)} → ${r.ooo_end ? N(r.ooo_end) : "open"}` : r.currently_out ? "until switched off" : "—" }),
161
+ /* @__PURE__ */ e("td", { className: "px-2 py-2", children: /* @__PURE__ */ e(B, { e: r }) }),
147
162
  /* @__PURE__ */ e("td", { className: "px-2 py-2 text-slate-500", children: r.group_seats > 0 ? /* @__PURE__ */ a("span", { title: r.states.join(", "), "data-tip": r.states.join(", "), children: [
148
163
  r.group_seats,
149
164
  " seat",
@@ -157,183 +172,295 @@ function $({ rows: l, isAdmin: d, onChanged: o, showWindow: s }) {
157
172
  /* @__PURE__ */ e(
158
173
  "td",
159
174
  {
160
- className: g(
175
+ className: m(
161
176
  "px-2 py-2 text-right tabular-nums",
162
177
  r.pending_estimate > 0 && !r.delegate_ok ? "font-semibold text-red-600 dark:text-red-400" : "text-slate-600 dark:text-muted-foreground"
163
178
  ),
164
179
  children: r.pending_estimate
165
180
  }
166
181
  ),
167
- d && /* @__PURE__ */ e("td", { className: "px-2 py-2", children: /* @__PURE__ */ e(B, { entry: r, onDone: o }) })
182
+ s && /* @__PURE__ */ e("td", { className: "px-2 py-2", children: /* @__PURE__ */ e(G, { entry: r, onDone: d }) })
168
183
  ] }, r.user.id)) })
169
184
  ] });
170
185
  }
171
- function le({ className: l, onNotice: d }) {
172
- const o = S(), s = P(), r = Q(), x = U(), m = !!(r != null && r.isAdmin), [i, _] = k(14), { data: n, isLoading: w } = C({
173
- queryKey: ["delegation-overview", i],
174
- queryFn: () => o.request(O("/delegation/overview", { days: i })).then((t) => t.data)
175
- }), { data: N } = C({
186
+ function se({
187
+ className: n,
188
+ onNotice: s,
189
+ compactHeader: d = !1
190
+ }) {
191
+ const o = D(), r = I(), g = Q(), b = U(), c = !!(g != null && g.isAdmin), [p, h] = _(14), { data: l, isLoading: k } = $({
192
+ queryKey: ["delegation-overview", p],
193
+ queryFn: () => o.request(S("/delegation/overview", { days: p })).then((t) => t.data)
194
+ }), { data: w } = $({
176
195
  queryKey: ["nvr-profile-user", "me"],
177
- queryFn: () => o.request(E("me")).then((t) => t.data)
178
- }), { data: c } = C({
196
+ queryFn: () => o.request(P("me")).then((t) => t.data)
197
+ }), { data: i } = $({
179
198
  queryKey: ["coverage-gaps"],
180
- queryFn: () => o.request(O("/coverage-gaps")).then((t) => t.data),
181
- enabled: m,
199
+ queryFn: () => o.request(S("/coverage-gaps")).then((t) => t.data),
200
+ enabled: c,
182
201
  staleTime: 6e4
183
- }), u = () => {
184
- s.invalidateQueries({ queryKey: ["delegation-overview"] }), s.invalidateQueries({ queryKey: ["nvr-profile-user"] }), s.invalidateQueries({ queryKey: ["coverage-gaps"] }), d == null || d("Saved");
202
+ }), x = () => {
203
+ r.invalidateQueries({ queryKey: ["delegation-overview"] }), r.invalidateQueries({ queryKey: ["nvr-profile-user"] }), r.invalidateQueries({ queryKey: ["coverage-gaps"] }), s == null || s("Saved");
185
204
  };
186
- z(
205
+ F(
187
206
  "delegation",
188
207
  () => {
189
- s.invalidateQueries({ queryKey: ["delegation-overview"] }), s.invalidateQueries({ queryKey: ["coverage-gaps"] });
208
+ r.invalidateQueries({ queryKey: ["delegation-overview"] }), r.invalidateQueries({ queryKey: ["coverage-gaps"] });
190
209
  },
191
210
  { debounceMs: 1e3 }
192
211
  );
193
- const p = x.consoleUrl ? x.consoleUrl("/coverage-gaps") : "/coverage-gaps";
194
- return /* @__PURE__ */ a("div", { className: g("flex flex-1 min-h-0 flex-col", l), "data-nvr-delegation-console": !0, children: [
195
- /* @__PURE__ */ e("header", { className: "shrink-0 border-b border-slate-200 bg-white px-6 py-4 dark:border-border dark:bg-card", children: /* @__PURE__ */ a("div", { className: "flex items-center gap-2.5", children: [
196
- /* @__PURE__ */ e(K, { className: "h-5 w-5 text-muted-foreground" }),
197
- /* @__PURE__ */ a("div", { children: [
198
- /* @__PURE__ */ e("h1", { className: "text-[17px] font-semibold text-slate-900 dark:text-foreground", children: "Delegation" }),
199
- /* @__PURE__ */ e("p", { className: "mt-0.5 text-[12.5px] text-slate-500 dark:text-muted-foreground", children: "Who is out, who covers them, what expires soon, and whose absence leaves approvals with nobody — plus your own delegate." })
200
- ] }),
201
- /* @__PURE__ */ e("span", { className: "flex-1" }),
202
- /* @__PURE__ */ e("div", { className: "inline-flex rounded-md border border-slate-200 p-0.5 dark:border-border", children: [7, 14, 30].map((t) => /* @__PURE__ */ a(
203
- "button",
204
- {
205
- type: "button",
206
- onClick: () => _(t),
207
- className: g(
208
- "rounded px-2.5 py-1 text-[12px] font-medium",
209
- i === t ? "bg-slate-900 text-white dark:bg-nvr-cyan dark:text-[#172940]" : "text-slate-600 hover:bg-slate-100 dark:text-muted-foreground dark:hover:bg-muted"
210
- ),
211
- children: [
212
- "next ",
213
- t,
214
- "d"
215
- ]
216
- },
217
- t
218
- )) })
219
- ] }) }),
220
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto bg-slate-50 p-6 dark:bg-background", children: w || !n ? /* @__PURE__ */ e("p", { className: "text-[13px] text-slate-400", children: "Loading…" }) : /* @__PURE__ */ a("div", { className: "space-y-5", children: [
212
+ const C = b.consoleUrl ? b.consoleUrl("/coverage-gaps") : "/coverage-gaps";
213
+ return /* @__PURE__ */ a("div", { className: m("flex flex-1 min-h-0 flex-col", n), "data-nvr-delegation-console": !0, children: [
214
+ /* @__PURE__ */ e(
215
+ "header",
216
+ {
217
+ className: m(
218
+ d ? "flex min-h-16 shrink-0 flex-col justify-center border-b border-slate-200 bg-white px-4 py-3 sm:px-6 dark:border-border dark:bg-card" : "shrink-0 border-b border-slate-200 bg-white px-6 py-4 dark:border-border dark:bg-card"
219
+ ),
220
+ children: /* @__PURE__ */ a("div", { className: "flex items-center gap-2.5", children: [
221
+ !d && /* @__PURE__ */ e(T, { className: "h-5 w-5 text-muted-foreground" }),
222
+ /* @__PURE__ */ a("div", { children: [
223
+ !d && /* @__PURE__ */ e("h1", { className: "text-[17px] font-semibold text-slate-900 dark:text-foreground", children: "Delegation" }),
224
+ /* @__PURE__ */ e(
225
+ "p",
226
+ {
227
+ className: m(
228
+ d ? "m-0 max-w-[72ch] text-[12px] leading-relaxed text-slate-600 dark:text-muted-foreground" : "mt-0.5 text-[12.5px] text-slate-500 dark:text-muted-foreground"
229
+ ),
230
+ children: "Who is out, who covers them, what expires soon, and whose absence leaves approvals with nobody — plus your own delegate."
231
+ }
232
+ )
233
+ ] }),
234
+ /* @__PURE__ */ e("span", { className: "flex-1" }),
235
+ /* @__PURE__ */ e("div", { className: "inline-flex rounded-md border border-slate-200 p-0.5 dark:border-border", children: [7, 14, 30].map((t) => /* @__PURE__ */ a(
236
+ "button",
237
+ {
238
+ type: "button",
239
+ onClick: () => h(t),
240
+ className: m(
241
+ "rounded px-2.5 py-1 text-[12px] font-medium",
242
+ p === t ? "bg-slate-900 text-white dark:bg-nvr-cyan dark:text-[#172940]" : "text-slate-600 hover:bg-slate-100 dark:text-muted-foreground dark:hover:bg-muted"
243
+ ),
244
+ children: [
245
+ "next ",
246
+ t,
247
+ "d"
248
+ ]
249
+ },
250
+ t
251
+ )) })
252
+ ] })
253
+ }
254
+ ),
255
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto bg-slate-50 p-6 dark:bg-background", children: k || !l ? /* @__PURE__ */ e("p", { className: "text-[13px] text-slate-400", children: "Loading…" }) : /* @__PURE__ */ a("div", { className: "space-y-5", children: [
221
256
  /* @__PURE__ */ a("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6", children: [
222
- /* @__PURE__ */ e(b, { label: "Out now", value: n.totals.out_now }),
223
- /* @__PURE__ */ e(b, { label: `Out in next ${i}d`, value: n.totals.upcoming }),
224
- /* @__PURE__ */ e(b, { label: "People covering", value: n.totals.covering }),
257
+ /* @__PURE__ */ e(v, { label: "Out now", value: l.totals.out_now }),
258
+ /* @__PURE__ */ e(v, { label: `Out in next ${p}d`, value: l.totals.upcoming }),
259
+ /* @__PURE__ */ e(v, { label: "People covering", value: l.totals.covering }),
225
260
  /* @__PURE__ */ e(
226
- b,
261
+ v,
227
262
  {
228
263
  label: "Expiring",
229
- value: n.totals.expiring,
230
- tone: n.expiring.some((t) => t.expired) ? "bad" : n.totals.expiring ? "warn" : void 0,
231
- hint: `delegations ending in ${i}d`
264
+ value: l.totals.expiring,
265
+ tone: l.expiring.some((t) => t.expired) ? "bad" : l.totals.expiring ? "warn" : void 0,
266
+ hint: `delegations ending in ${p}d`
232
267
  }
233
268
  ),
234
269
  /* @__PURE__ */ e(
235
- b,
270
+ v,
236
271
  {
237
272
  label: "Uncovered",
238
- value: n.totals.uncovered,
239
- tone: n.totals.uncovered ? "bad" : void 0,
273
+ value: l.totals.uncovered,
274
+ tone: l.totals.uncovered ? "bad" : void 0,
240
275
  hint: "out (or by tomorrow) with no working delegate"
241
276
  }
242
277
  ),
243
278
  /* @__PURE__ */ e(
244
- b,
279
+ v,
245
280
  {
246
281
  label: "Approvals at risk",
247
- value: n.totals.pending_uncovered,
248
- tone: n.totals.pending_uncovered ? "bad" : void 0,
282
+ value: l.totals.pending_uncovered,
283
+ tone: l.totals.pending_uncovered ? "bad" : void 0,
249
284
  hint: "open items in states they cover"
250
285
  }
251
286
  )
252
287
  ] }),
253
- n.uncovered.length > 0 && /* @__PURE__ */ e(
254
- v,
288
+ l.uncovered.length > 0 && /* @__PURE__ */ e(
289
+ f,
255
290
  {
256
291
  tone: "bad",
257
292
  title: "Would go unowned — no working delegate",
258
293
  hint: "Out now, or entering an OOO window within 24 hours, with nobody able to act for them. Pending = open items sitting in states they help cover.",
259
- children: /* @__PURE__ */ e($, { rows: n.uncovered, isAdmin: m, onChanged: u, showWindow: !0 })
294
+ children: /* @__PURE__ */ e(
295
+ q,
296
+ {
297
+ rows: l.uncovered,
298
+ isAdmin: c,
299
+ onChanged: x,
300
+ showWindow: !0
301
+ }
302
+ )
260
303
  }
261
304
  ),
262
305
  /* @__PURE__ */ a("div", { className: "grid grid-cols-1 gap-4 xl:grid-cols-2", children: [
263
306
  /* @__PURE__ */ a("div", { className: "space-y-4", children: [
264
- /* @__PURE__ */ e(v, { title: "Out now", hint: "Currently out of office.", children: /* @__PURE__ */ e($, { rows: n.out_now, isAdmin: m, onChanged: u, showWindow: !0 }) }),
265
- /* @__PURE__ */ e(v, { title: `Coming up (next ${i} days)`, hint: "Scheduled OOO windows — the flag flips on entry and clears on exit.", children: /* @__PURE__ */ e($, { rows: n.upcoming, isAdmin: m, onChanged: u, showWindow: !0 }) })
307
+ /* @__PURE__ */ e(f, { title: "Out now", hint: "Currently out of office.", children: /* @__PURE__ */ e(
308
+ q,
309
+ {
310
+ rows: l.out_now,
311
+ isAdmin: c,
312
+ onChanged: x,
313
+ showWindow: !0
314
+ }
315
+ ) }),
316
+ /* @__PURE__ */ e(
317
+ f,
318
+ {
319
+ title: `Coming up (next ${p} days)`,
320
+ hint: "Scheduled OOO windows — the flag flips on entry and clears on exit.",
321
+ children: /* @__PURE__ */ e(
322
+ q,
323
+ {
324
+ rows: l.upcoming,
325
+ isAdmin: c,
326
+ onChanged: x,
327
+ showWindow: !0
328
+ }
329
+ )
330
+ }
331
+ )
266
332
  ] }),
267
333
  /* @__PURE__ */ a("div", { className: "space-y-4", children: [
268
- N && /* @__PURE__ */ e(R, { user: N, onSaved: u }),
269
- /* @__PURE__ */ e(v, { title: "Who covers whom", hint: "Active delegations: the delegate and everyone routing to them right now.", children: n.covering.length === 0 ? /* @__PURE__ */ e("p", { className: "px-4 py-4 text-[12px] text-slate-400", children: "No active delegations." }) : /* @__PURE__ */ e("ul", { className: "divide-y divide-slate-100 dark:divide-border", children: n.covering.map((t) => /* @__PURE__ */ a("li", { className: "flex flex-wrap items-start gap-2 px-4 py-2 text-[12px]", children: [
270
- /* @__PURE__ */ e(f, { userId: t.delegate.id, size: "compact" }),
271
- /* @__PURE__ */ e("span", { className: "mt-1 text-slate-400", children: "covers" }),
272
- /* @__PURE__ */ e("span", { className: "flex flex-wrap gap-1", children: t.covers.map((h) => /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-1", children: [
273
- /* @__PURE__ */ e(f, { userId: h.id, size: "compact" }),
274
- h.expires_at && /* @__PURE__ */ a("span", { className: "text-[10.5px] text-slate-400", children: [
275
- "until ",
276
- y(h.expires_at)
277
- ] })
278
- ] }, h.id)) })
279
- ] }, t.delegate.id)) }) }),
280
- /* @__PURE__ */ e(v, { title: "Expiring delegations", hint: `Ending within ${i} days — an expired one while the person is still out means approvals are stalling.`, children: n.expiring.length === 0 ? /* @__PURE__ */ e("p", { className: "px-4 py-4 text-[12px] text-slate-400", children: "Nothing expiring." }) : /* @__PURE__ */ e("ul", { className: "divide-y divide-slate-100 dark:divide-border", children: n.expiring.map((t) => /* @__PURE__ */ a("li", { className: "flex flex-wrap items-center gap-2 px-4 py-2 text-[12px]", children: [
281
- /* @__PURE__ */ e(T, { className: g("h-3.5 w-3.5", t.expired ? "text-red-500" : "text-amber-500") }),
282
- /* @__PURE__ */ e(f, { userId: t.user.id, size: "compact" }),
283
- /* @__PURE__ */ e("span", { className: "text-slate-400", children: "→" }),
284
- /* @__PURE__ */ e(f, { userId: t.delegate.id, size: "compact" }),
285
- /* @__PURE__ */ e("span", { className: g("ml-auto text-[11.5px]", t.expired ? "font-semibold text-red-600 dark:text-red-400" : "text-slate-500"), children: t.expired ? `expired ${y(t.expires_at)}${t.currently_out ? " · still out" : ""}` : `ends ${y(t.expires_at)}` })
286
- ] }, t.user.id)) }) })
334
+ w && /* @__PURE__ */ e(W, { user: w, onSaved: x }),
335
+ /* @__PURE__ */ e(
336
+ f,
337
+ {
338
+ title: "Who covers whom",
339
+ hint: "Active delegations: the delegate and everyone routing to them right now.",
340
+ children: l.covering.length === 0 ? /* @__PURE__ */ e("p", { className: "px-4 py-4 text-[12px] text-slate-400", children: "No active delegations." }) : /* @__PURE__ */ e("ul", { className: "divide-y divide-slate-100 dark:divide-border", children: l.covering.map((t) => /* @__PURE__ */ a(
341
+ "li",
342
+ {
343
+ className: "flex flex-wrap items-start gap-2 px-4 py-2 text-[12px]",
344
+ children: [
345
+ /* @__PURE__ */ e(y, { userId: t.delegate.id, size: "compact" }),
346
+ /* @__PURE__ */ e("span", { className: "mt-1 text-slate-400", children: "covers" }),
347
+ /* @__PURE__ */ e("span", { className: "flex flex-wrap gap-1", children: t.covers.map((u) => /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-1", children: [
348
+ /* @__PURE__ */ e(y, { userId: u.id, size: "compact" }),
349
+ u.expires_at && /* @__PURE__ */ a("span", { className: "text-[10.5px] text-slate-400", children: [
350
+ "until ",
351
+ N(u.expires_at)
352
+ ] })
353
+ ] }, u.id)) })
354
+ ]
355
+ },
356
+ t.delegate.id
357
+ )) })
358
+ }
359
+ ),
360
+ /* @__PURE__ */ e(
361
+ f,
362
+ {
363
+ title: "Expiring delegations",
364
+ hint: `Ending within ${p} days — an expired one while the person is still out means approvals are stalling.`,
365
+ children: l.expiring.length === 0 ? /* @__PURE__ */ e("p", { className: "px-4 py-4 text-[12px] text-slate-400", children: "Nothing expiring." }) : /* @__PURE__ */ e("ul", { className: "divide-y divide-slate-100 dark:divide-border", children: l.expiring.map((t) => /* @__PURE__ */ a(
366
+ "li",
367
+ {
368
+ className: "flex flex-wrap items-center gap-2 px-4 py-2 text-[12px]",
369
+ children: [
370
+ /* @__PURE__ */ e(
371
+ j,
372
+ {
373
+ className: m(
374
+ "h-3.5 w-3.5",
375
+ t.expired ? "text-red-500" : "text-amber-500"
376
+ )
377
+ }
378
+ ),
379
+ /* @__PURE__ */ e(y, { userId: t.user.id, size: "compact" }),
380
+ /* @__PURE__ */ e("span", { className: "text-slate-400", children: "→" }),
381
+ /* @__PURE__ */ e(y, { userId: t.delegate.id, size: "compact" }),
382
+ /* @__PURE__ */ e(
383
+ "span",
384
+ {
385
+ className: m(
386
+ "ml-auto text-[11.5px]",
387
+ t.expired ? "font-semibold text-red-600 dark:text-red-400" : "text-slate-500"
388
+ ),
389
+ children: t.expired ? `expired ${N(t.expires_at)}${t.currently_out ? " · still out" : ""}` : `ends ${N(t.expires_at)}`
390
+ }
391
+ )
392
+ ]
393
+ },
394
+ t.user.id
395
+ )) })
396
+ }
397
+ )
287
398
  ] })
288
399
  ] }),
289
- m && /* @__PURE__ */ e(
290
- v,
400
+ c && /* @__PURE__ */ e(
401
+ f,
291
402
  {
292
403
  title: "Records blocked right now",
293
404
  hint: "Open records whose entire owner set cannot act (out with no working delegate, suspended, inactive). Live resolution over open instances.",
294
- children: c ? c.blocked.length === 0 ? /* @__PURE__ */ a("p", { className: "px-4 py-4 text-[12px] text-slate-400", children: [
405
+ children: i ? i.blocked.length === 0 ? /* @__PURE__ */ a("p", { className: "px-4 py-4 text-[12px] text-slate-400", children: [
295
406
  "Nothing blocked — every open record has at least one owner who can act.",
296
- c.no_owner_count > 0 && ` (${c.no_owner_count} resolve no owners at all — an owner-matrix coverage question, see Coverage Gaps.)`
297
- ] }) : /* @__PURE__ */ a(D, { children: [
407
+ i.no_owner_count > 0 && ` (${i.no_owner_count} resolve no owners at all — an owner-matrix coverage question, see Coverage Gaps.)`
408
+ ] }) : /* @__PURE__ */ a(E, { children: [
298
409
  /* @__PURE__ */ a("table", { className: "w-full text-[12px]", children: [
299
410
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ a("tr", { className: "text-left text-[10.5px] uppercase tracking-wide text-slate-400", children: [
300
411
  /* @__PURE__ */ e("th", { className: "px-4 py-1.5 font-semibold", children: "Record" }),
301
412
  /* @__PURE__ */ e("th", { className: "px-2 py-1.5 font-semibold", children: "State" }),
302
413
  /* @__PURE__ */ e("th", { className: "px-2 py-1.5 font-semibold", children: "Owners who cannot act" })
303
414
  ] }) }),
304
- /* @__PURE__ */ e("tbody", { children: c.blocked.slice(0, 40).map((t) => /* @__PURE__ */ a("tr", { className: "border-t border-slate-100 dark:border-border", children: [
305
- /* @__PURE__ */ a("td", { className: "px-4 py-1.5", children: [
306
- /* @__PURE__ */ e(
307
- "button",
308
- {
309
- type: "button",
310
- onClick: () => x.navigate(`/collections/${t.collection}/${t.item}`),
311
- className: "text-nvr-navy underline decoration-dotted underline-offset-2 dark:text-nvr-cyan",
312
- children: t.label
313
- }
314
- ),
315
- /* @__PURE__ */ e("span", { className: "ml-1 text-[10.5px] text-slate-400", children: t.collection.replace(/_/g, " ") })
316
- ] }),
317
- /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-slate-600 dark:text-muted-foreground", children: t.state ?? "—" }),
318
- /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-slate-600 dark:text-muted-foreground", children: t.owners.map((h) => `${h.name} (${h.reason.replace(/_/g, " ")})`).join(", ") })
319
- ] }, `${t.collection}:${t.item}`)) })
415
+ /* @__PURE__ */ e("tbody", { children: i.blocked.slice(0, 40).map((t) => /* @__PURE__ */ a(
416
+ "tr",
417
+ {
418
+ className: "border-t border-slate-100 dark:border-border",
419
+ children: [
420
+ /* @__PURE__ */ a("td", { className: "px-4 py-1.5", children: [
421
+ /* @__PURE__ */ e(
422
+ "button",
423
+ {
424
+ type: "button",
425
+ onClick: () => b.navigate(`/collections/${t.collection}/${t.item}`),
426
+ className: "text-nvr-navy underline decoration-dotted underline-offset-2 dark:text-nvr-cyan",
427
+ children: t.label
428
+ }
429
+ ),
430
+ /* @__PURE__ */ e("span", { className: "ml-1 text-[10.5px] text-slate-400", children: t.collection.replace(/_/g, " ") })
431
+ ] }),
432
+ /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-slate-600 dark:text-muted-foreground", children: t.state ?? "—" }),
433
+ /* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-slate-600 dark:text-muted-foreground", children: t.owners.map((u) => `${u.name} (${u.reason.replace(/_/g, " ")})`).join(", ") })
434
+ ]
435
+ },
436
+ `${t.collection}:${t.item}`
437
+ )) })
320
438
  ] }),
321
- (c.blocked.length > 40 || p) && /* @__PURE__ */ a("p", { className: "px-4 py-2 text-[11.5px] text-slate-400", children: [
322
- c.blocked.length > 40 ? `Showing 40 of ${c.blocked.length}. ` : "",
323
- p && /* @__PURE__ */ e("button", { type: "button", onClick: () => x.navigate(p), className: "underline decoration-dotted underline-offset-2", children: "Full coverage-gap report →" })
439
+ (i.blocked.length > 40 || C) && /* @__PURE__ */ a("p", { className: "px-4 py-2 text-[11.5px] text-slate-400", children: [
440
+ i.blocked.length > 40 ? `Showing 40 of ${i.blocked.length}. ` : "",
441
+ C && /* @__PURE__ */ e(
442
+ "button",
443
+ {
444
+ type: "button",
445
+ onClick: () => b.navigate(C),
446
+ className: "underline decoration-dotted underline-offset-2",
447
+ children: "Full coverage-gap report →"
448
+ }
449
+ )
324
450
  ] })
325
451
  ] }) : /* @__PURE__ */ e("p", { className: "px-4 py-4 text-[12px] text-slate-400", children: "Resolving owners…" })
326
452
  }
327
453
  ),
328
454
  /* @__PURE__ */ a("p", { className: "flex items-center gap-1 text-[11px] text-slate-400", children: [
329
455
  /* @__PURE__ */ e(A, { className: "h-3 w-3" }),
330
- " Computed live at ",
331
- new Date(n.generated_at).toLocaleTimeString(),
456
+ " Computed live at",
457
+ " ",
458
+ new Date(l.generated_at).toLocaleTimeString(),
332
459
  "."
333
460
  ] })
334
461
  ] }) })
335
462
  ] });
336
463
  }
337
464
  export {
338
- le as DelegationConsoleView
465
+ se as DelegationConsoleView
339
466
  };