@nivaro/react 0.3.0 → 0.3.2

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 (33) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +341 -0
  4. package/dist/index.js +764 -723
  5. package/dist/shared/components/ClientChaosToolbar.js +410 -0
  6. package/dist/shared/components/LoadErrorNote.js +49 -0
  7. package/dist/shared/components/PretendDown.js +258 -0
  8. package/dist/shared/components/ProfileView.js +54 -49
  9. package/dist/shared/components/QueryErrorState.js +16 -0
  10. package/dist/shared/components/ReportView.js +1351 -1338
  11. package/dist/shared/components/WidgetSlot.js +438 -418
  12. package/dist/shared/components/chaos/DeclareIncidentButton.js +72 -0
  13. package/dist/shared/components/chaos/DrillBanner.js +119 -0
  14. package/dist/shared/components/chaos/DrillTag.js +62 -0
  15. package/dist/shared/components/chaos/GameDayStrip.js +61 -0
  16. package/dist/shared/components/chat/huddle/HuddleAudioUi.js +95 -92
  17. package/dist/shared/components/chat/huddle/HuddleCallBar.js +69 -64
  18. package/dist/shared/components/chat/huddle/HuddlePeoplePicker.js +40 -39
  19. package/dist/shared/components/chat/huddle/HuddleStageTools.js +30 -27
  20. package/dist/shared/components/chat/huddle/huddle-dismiss.js +12 -0
  21. package/dist/shared/components/chat/huddle/huddle-store.js +25 -20
  22. package/dist/shared/components/client-chaos-gate.js +51 -0
  23. package/dist/shared/components/integrations/console/SignalCard.js +172 -167
  24. package/dist/shared/components/layout-editor/EditorTopBar.js +108 -105
  25. package/dist/shared/components/layout-editor/LayoutEditor.js +514 -508
  26. package/dist/shared/components/notifications/NotificationAnalyticsView.js +18 -10
  27. package/dist/shared/components/pipeline/PipelineEditorView.js +495 -479
  28. package/dist/shared/components/pipeline/TeamsView.js +184 -169
  29. package/dist/shared/lib/client-chaos.js +359 -0
  30. package/dist/shared/lib/load-error.js +26 -0
  31. package/dist/shared/lib/socket-realtime.js +31 -30
  32. package/dist/shared/lib/worker-socket.js +108 -89
  33. package/package.json +1 -1
@@ -0,0 +1,258 @@
1
+ import { jsxs as c, jsx as a } from "react/jsx-runtime";
2
+ import { useQueryClient as $ } from "@tanstack/react-query";
3
+ import { PlugZap as m, Radio as v, Bot as N, Handshake as y, LayoutGrid as D, Database as E } from "lucide-react";
4
+ import { useEffect as C, useCallback as I } from "react";
5
+ import { clearPretendDown as A, getPretendDown as f, setPretendDown as R, PRETEND_DOWN_EVENT as S } from "../lib/client-chaos.js";
6
+ import { cn as o, titleCase as T } from "../lib/utils.js";
7
+ import { useClientChaosGate as h, usePretendDownVersion as O } from "./client-chaos-gate.js";
8
+ import { Popover as q, PopoverTrigger as L, PopoverContent as j } from "./ui/popover.js";
9
+ const z = "layout-editor", W = {
10
+ query: /* @__PURE__ */ a(E, { className: "h-3.5 w-3.5" }),
11
+ data: /* @__PURE__ */ a(D, { className: "h-3.5 w-3.5" }),
12
+ partner: /* @__PURE__ */ a(y, { className: "h-3.5 w-3.5" }),
13
+ ai: /* @__PURE__ */ a(N, { className: "h-3.5 w-3.5" }),
14
+ realtime: /* @__PURE__ */ a(v, { className: "h-3.5 w-3.5" }),
15
+ panel: /* @__PURE__ */ a(m, { className: "h-3.5 w-3.5" })
16
+ };
17
+ function J(t) {
18
+ C(() => () => A(t), [t]);
19
+ }
20
+ function w(t) {
21
+ return O(), f(t).map((n) => n.id);
22
+ }
23
+ function G(t, n) {
24
+ const s = $();
25
+ return I(
26
+ (i) => {
27
+ const l = new Set(f(t).map((r) => r.id));
28
+ l.has(i) ? l.delete(i) : l.add(i), R(
29
+ t,
30
+ n.filter((r) => l.has(r.id))
31
+ ), s.invalidateQueries({ refetchType: "active" }), typeof window < "u" && window.dispatchEvent(new CustomEvent(S));
32
+ },
33
+ [t, n, s]
34
+ );
35
+ }
36
+ function b({
37
+ scope: t,
38
+ options: n,
39
+ className: s
40
+ }) {
41
+ const i = new Set(w(t)), l = G(t, n);
42
+ return /* @__PURE__ */ c("div", { className: s, children: [
43
+ /* @__PURE__ */ a("p", { className: "text-[12px] font-medium text-slate-700 dark:text-foreground", children: "Pretend down" }),
44
+ /* @__PURE__ */ a("p", { className: "mt-0.5 text-[11.5px] leading-snug text-slate-500 dark:text-muted-foreground", children: "See how this view copes when something it uses fails. Only you, only here, until you leave." }),
45
+ n.length === 0 ? /* @__PURE__ */ a("p", { className: "mt-2 text-[12px] text-slate-500 dark:text-muted-foreground", children: "This view uses nothing that can be pretended down yet." }) : /* @__PURE__ */ a("ul", { className: "-mx-1.5 mt-1.5 space-y-px", children: n.map((r) => {
46
+ const e = i.has(r.id);
47
+ return /* @__PURE__ */ a("li", { children: /* @__PURE__ */ c(
48
+ "button",
49
+ {
50
+ type: "button",
51
+ role: "switch",
52
+ "aria-checked": e,
53
+ onClick: () => l(r.id),
54
+ className: o(
55
+ "flex w-full items-center gap-2.5 rounded-md px-1.5 py-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50",
56
+ e ? "bg-amber-50 dark:bg-amber-400/10" : "hover:bg-muted"
57
+ ),
58
+ children: [
59
+ /* @__PURE__ */ a(
60
+ "span",
61
+ {
62
+ className: o(
63
+ "flex h-6 w-6 shrink-0 items-center justify-center rounded-md",
64
+ e ? "bg-amber-100 text-amber-700 dark:bg-amber-400/15 dark:text-amber-300" : "bg-slate-100 text-slate-500 dark:bg-white/[0.06] dark:text-muted-foreground"
65
+ ),
66
+ children: W[r.kind]
67
+ }
68
+ ),
69
+ /* @__PURE__ */ c("span", { className: "min-w-0 flex-1", children: [
70
+ /* @__PURE__ */ a("span", { className: "block truncate text-[12.5px] leading-tight", children: r.label }),
71
+ (e || r.hint) && /* @__PURE__ */ a("span", { className: "block truncate text-[11.5px] leading-snug text-slate-500 dark:text-muted-foreground", children: e ? "Pretending it is down" : r.hint })
72
+ ] }),
73
+ /* @__PURE__ */ a(
74
+ "span",
75
+ {
76
+ "aria-hidden": !0,
77
+ className: o(
78
+ "relative h-4 w-7 shrink-0 rounded-full transition-colors motion-reduce:transition-none",
79
+ e ? "bg-amber-500" : "bg-slate-200 dark:bg-white/[0.15]"
80
+ ),
81
+ children: /* @__PURE__ */ a(
82
+ "span",
83
+ {
84
+ className: o(
85
+ "absolute top-0.5 h-3 w-3 rounded-full bg-white shadow-sm transition-transform motion-reduce:transition-none",
86
+ e ? "translate-x-3.5" : "translate-x-0.5"
87
+ )
88
+ }
89
+ )
90
+ }
91
+ )
92
+ ]
93
+ }
94
+ ) }, r.id);
95
+ }) })
96
+ ] });
97
+ }
98
+ function X({
99
+ scope: t,
100
+ options: n,
101
+ user: s,
102
+ className: i
103
+ }) {
104
+ const l = h(s), r = w(t).length;
105
+ return l.allowed ? /* @__PURE__ */ c(q, { children: [
106
+ /* @__PURE__ */ a(L, { asChild: !0, children: /* @__PURE__ */ c(
107
+ "button",
108
+ {
109
+ type: "button",
110
+ "data-pretend-down": "",
111
+ "data-tip": "Pretend a dependency is down and see how this view copes (only you)",
112
+ className: o(
113
+ "inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border px-2.5 text-[12px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50",
114
+ r > 0 ? "border-amber-300 bg-amber-50 text-amber-800 hover:bg-amber-100 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-200 dark:hover:bg-amber-400/15" : "border-slate-200 text-slate-600 hover:bg-muted dark:border-border dark:text-muted-foreground",
115
+ i
116
+ ),
117
+ children: [
118
+ /* @__PURE__ */ a(m, { className: "h-3.5 w-3.5" }),
119
+ /* @__PURE__ */ a("span", { children: r > 0 ? `${r} down` : "Pretend down" })
120
+ ]
121
+ }
122
+ ) }),
123
+ /* @__PURE__ */ a(j, { align: "end", className: "w-[300px] p-3", children: /* @__PURE__ */ a(b, { scope: t, options: n }) })
124
+ ] }) : null;
125
+ }
126
+ const B = { is_admin: !0 };
127
+ function ee({
128
+ scope: t,
129
+ options: n
130
+ }) {
131
+ return h(B).allowed ? /* @__PURE__ */ a(
132
+ b,
133
+ {
134
+ scope: t,
135
+ options: n,
136
+ className: "mt-3 border-t border-slate-100 pt-3 dark:border-border"
137
+ }
138
+ ) : null;
139
+ }
140
+ const g = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
141
+ function x(t = {}) {
142
+ const n = [];
143
+ return t.ai !== !1 && n.push({
144
+ id: "ai",
145
+ kind: "ai",
146
+ label: "AI gateway",
147
+ hint: "Ask AI, AI fill and summaries",
148
+ patterns: [/^\/ai(\/|$)/, /^\/ask(\/|$)/]
149
+ }), t.partners !== !1 && n.push({
150
+ id: "partners",
151
+ kind: "partner",
152
+ label: "Partners and external APIs",
153
+ hint: "Calls out to other systems",
154
+ status: 502,
155
+ patterns: [/^\/external-apis(\/|$)/, /^\/integrations?(\/|$)/, /^\/erp-submissions(\/|$)/]
156
+ }), n.push({
157
+ id: "realtime",
158
+ kind: "realtime",
159
+ label: "Live updates",
160
+ hint: "The socket: presence, live figures",
161
+ patterns: [],
162
+ socket: !0
163
+ }), n;
164
+ }
165
+ const M = [
166
+ {
167
+ field: "__pipeline__",
168
+ id: "panel:pipeline",
169
+ label: "Pipeline panel",
170
+ patterns: [/^\/pipelines\/instance(\/|$)/, /^\/workflows\/instance(\/|$)/]
171
+ },
172
+ { field: "__owners__", id: "panel:owners", label: "Owners panel", patterns: [/\/owners(\/|$)/] },
173
+ {
174
+ field: "__comments__",
175
+ id: "panel:comments",
176
+ label: "Comments panel",
177
+ patterns: [/^\/comments(\/|$)/]
178
+ },
179
+ { field: "__tasks__", id: "panel:tasks", label: "Tasks panel", patterns: [/^\/tasks(\/|$)/] },
180
+ {
181
+ field: "__addendums__",
182
+ id: "panel:addendums",
183
+ label: "Addendums panel",
184
+ patterns: [/^\/addendums(\/|$)/]
185
+ },
186
+ {
187
+ field: "__related_records__",
188
+ id: "panel:related",
189
+ label: "Related records panel",
190
+ patterns: [/^\/items\/[^/]+\/[^/]+\/related(\/|$)/, /^\/related-records(\/|$)/]
191
+ },
192
+ { field: "__pdf__", id: "panel:pdf", label: "PDF panel", patterns: [/^\/pdf(-templates)?(\/|$)/] }
193
+ ];
194
+ function te(t) {
195
+ var r;
196
+ const n = (t == null ? void 0 : t.assignments) ?? [], s = [], i = /* @__PURE__ */ new Map();
197
+ for (const e of n) {
198
+ const d = e.field ?? "";
199
+ d.startsWith("__widget_") && d.endsWith("__") && e.widget_id != null && i.set(String(e.widget_id), ((r = e.label) == null ? void 0 : r.trim()) || null);
200
+ }
201
+ for (const [e, d] of i)
202
+ s.push({
203
+ id: `widget:${e}`,
204
+ kind: "query",
205
+ label: d ?? `Record widget ${e}`,
206
+ hint: "Its query or rollup",
207
+ status: 500,
208
+ patterns: [new RegExp(`^/widgets-internal/${g(e)}(/|$)`)]
209
+ });
210
+ const l = new Set(n.map((e) => e.field ?? ""));
211
+ for (const e of M)
212
+ l.has(e.field) && s.push({ id: e.id, kind: "panel", label: e.label, patterns: e.patterns });
213
+ return [...s, ...x()];
214
+ }
215
+ function ne(t, n = {}) {
216
+ var r;
217
+ const s = /* @__PURE__ */ new Map(), i = (e, d, p, _, k = []) => {
218
+ const u = s.get(e) ?? { label: d, kind: p, ids: [], extra: [] };
219
+ u.ids.push(_);
220
+ for (const P of k) u.extra.push(P);
221
+ s.set(e, u);
222
+ };
223
+ for (const e of t)
224
+ e.type === "ai_query" ? i("ai", "Ask AI charts", "ai", e.id) : e.type === "report_preset" ? i("preset", "Report presets", "query", e.id, [
225
+ /^\/report-studio\/widget-presets(\/|$)/,
226
+ /^\/custom-queries(\/|$)/
227
+ ]) : e.type === "cumulative_flow" ? i("flow", "Pipeline flow", "data", e.id) : e.collection && i(
228
+ `c:${e.collection}`,
229
+ ((r = n[e.collection]) == null ? void 0 : r.trim()) || T(e.collection),
230
+ "data",
231
+ e.id
232
+ );
233
+ const l = [];
234
+ for (const [e, d] of s) {
235
+ const p = d.ids.map(g).join("|");
236
+ l.push({
237
+ id: `dash:${e}`,
238
+ kind: d.kind,
239
+ label: d.kind === "data" && e.startsWith("c:") ? `${d.label} data` : d.label,
240
+ hint: `${d.ids.length} widget${d.ids.length === 1 ? "" : "s"}`,
241
+ status: 500,
242
+ patterns: [new RegExp(`^/dashboards/widgets/(${p})(/|$)`), ...d.extra]
243
+ });
244
+ }
245
+ return [...l, ...x({ partners: !1 })];
246
+ }
247
+ export {
248
+ z as LAYOUT_PRETEND_SCOPE,
249
+ X as PretendDownButton,
250
+ b as PretendDownList,
251
+ ee as PretendDownSection,
252
+ x as commonPretendDownOptions,
253
+ ne as dashboardPretendDownOptions,
254
+ te as layoutPretendDownOptions,
255
+ w as usePretendDownIds,
256
+ J as usePretendDownScope,
257
+ G as usePretendDownToggle
258
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsxs as t, jsx as e, Fragment as oe } from "react/jsx-runtime";
2
- import { readUser as fe, readUserCard as ye, updateUser as ue, readMyScopes as ve, saveMyScopeDefaults as ke, readItems as ne } from "@nivaro/sdk";
2
+ import { readUser as ye, readUserCard as fe, updateUser as ue, readMyScopes as ve, saveMyScopeDefaults as ke, readItems as ne } from "@nivaro/sdk";
3
3
  import { useQueryClient as E, useQuery as q, useMutation as _ } from "@tanstack/react-query";
4
4
  import { Loader2 as me, Camera as Ne, Building2 as we, Mail as Se, Phone as _e, Clock as qe, Undo2 as Ce, Check as Pe, UserRound as Ae, Filter as Te, LogOut as Fe, ShieldCheck as Oe } from "lucide-react";
5
5
  import { useState as C, useMemo as Le, useRef as De } from "react";
@@ -70,6 +70,11 @@ const Ze = (i) => [i.first_name, i.last_name].filter(Boolean).join(" ") || (i.em
70
70
  label: "Huddles & calls",
71
71
  help: "Someone calls you in a huddle or adds you to one, and reminders for huddles you were invited to. Push is what rings a closed tab."
72
72
  },
73
+ {
74
+ key: "chaos",
75
+ label: "Chaos drills",
76
+ help: "Chaos Monkey drills starting and ending, and pushes about drills you started or take part in (with a Stop button). Only administrators and chaos operators get these."
77
+ },
73
78
  {
74
79
  key: "system",
75
80
  label: "System & digests",
@@ -193,14 +198,14 @@ function tt() {
193
198
  escalation: r.escalation ?? s.escalation ?? {}
194
199
  };
195
200
  L.mutate(h), k.mutate(h);
196
- }, y = (a == null ? void 0 : a.notification_sounds) ?? {}, z = (r, h) => {
197
- const x = { ...y };
201
+ }, f = (a == null ? void 0 : a.notification_sounds) ?? {}, z = (r, h) => {
202
+ const x = { ...f };
198
203
  h === "default" ? delete x[r] : x[r] = h, h !== "default" && pe(h, { preview: !0 }), P.mutate({ notification_sounds: Object.keys(x).length ? x : null });
199
204
  }, { data: I } = q({
200
205
  queryKey: ["nvr-noise-suggestions"],
201
206
  queryFn: () => i.request(F("/notifications/noise-suggestions")).then((r) => r.data ?? []),
202
207
  staleTime: 6e5
203
- }), [f, K] = C({}), [j, U] = C(() => {
208
+ }), [y, K] = C({}), [j, U] = C(() => {
204
209
  try {
205
210
  const r = JSON.parse(localStorage.getItem("nvr-noise-dismissed") ?? "null");
206
211
  return r && Date.now() - r.at < 30 * 864e5 ? r.cats : [];
@@ -287,7 +292,7 @@ function tt() {
287
292
  r.message,
288
293
  " Mute them?"
289
294
  ] }),
290
- r.category in f ? /* @__PURE__ */ e(
295
+ r.category in y ? /* @__PURE__ */ e(
291
296
  "button",
292
297
  {
293
298
  type: "button",
@@ -296,7 +301,7 @@ function tt() {
296
301
  S({
297
302
  matrix: {
298
303
  ...s.matrix ?? {},
299
- [r.category]: f[r.category]
304
+ [r.category]: y[r.category]
300
305
  }
301
306
  }), K(({ [r.category]: h, ...x }) => x);
302
307
  },
@@ -477,7 +482,7 @@ function tt() {
477
482
  M,
478
483
  {
479
484
  ariaLabel: `Sound for ${r.label}`,
480
- value: y[r.key] ?? "default",
485
+ value: f[r.key] ?? "default",
481
486
  options: [
482
487
  { value: "default", label: "Default" },
483
488
  { value: "off", label: "None" },
@@ -817,25 +822,25 @@ function st({
817
822
  placeholderData: (d) => d
818
823
  }), S = new Map(p.map((d) => [String(d.id), d.label]));
819
824
  for (const d of O) S.set(String(d.id), d.label);
820
- const y = m.filter((d) => !S.has(String(d))), { data: z = [] } = q({
821
- queryKey: ["nvr-scope-selected-labels", i.name, y.map(String).sort().join(",")],
825
+ const f = m.filter((d) => !S.has(String(d))), { data: z = [] } = q({
826
+ queryKey: ["nvr-scope-selected-labels", i.name, f.map(String).sort().join(",")],
822
827
  queryFn: async () => ((await l.request(
823
828
  ne(i.target_collection, {
824
829
  fields: ["id", o],
825
- filter: { id: { _in: y } },
830
+ filter: { id: { _in: f } },
826
831
  limit: 100
827
832
  })
828
833
  )).data ?? []).map((N) => ({
829
834
  id: N.id,
830
835
  label: String(N[o] ?? N.id)
831
836
  })),
832
- enabled: y.length > 0
837
+ enabled: f.length > 0
833
838
  });
834
839
  for (const d of z) S.set(String(d.id), d.label);
835
840
  const I = (d) => {
836
841
  const N = P.has(String(d));
837
842
  s(N ? m.filter((A) => String(A) !== String(d)) : [...m, d]);
838
- }, f = c.trim().toLowerCase(), K = f ? k.filter((d) => d.label.toLowerCase().includes(f)) : k, j = f.length === 0 ? k.slice(0, 30) : L && O.length === 0 ? K.slice(0, 30) : O, U = v && (n || f.length > 0);
843
+ }, y = c.trim().toLowerCase(), K = y ? k.filter((d) => d.label.toLowerCase().includes(y)) : k, j = y.length === 0 ? k.slice(0, 30) : L && O.length === 0 ? K.slice(0, 30) : O, U = v && (n || y.length > 0);
839
844
  return /* @__PURE__ */ t("div", { children: [
840
845
  /* @__PURE__ */ t("p", { className: "mb-1 text-[11px] font-medium uppercase tracking-wide text-slate-400", children: [
841
846
  i.label,
@@ -910,8 +915,8 @@ function st({
910
915
  String(d.id)
911
916
  );
912
917
  }),
913
- j.length === 0 && /* @__PURE__ */ e("p", { className: "px-2.5 py-2 text-[11.5px] text-slate-400", children: L ? "Searching…" : f ? "No matches." : "No options." }),
914
- f.length === 0 && k.length > 30 && /* @__PURE__ */ e("p", { className: "border-t border-slate-100 px-2.5 py-1.5 text-[11px] text-slate-400 dark:border-border", children: "Showing first 30 — type to narrow." })
918
+ j.length === 0 && /* @__PURE__ */ e("p", { className: "px-2.5 py-2 text-[11.5px] text-slate-400", children: L ? "Searching…" : y ? "No matches." : "No options." }),
919
+ y.length === 0 && k.length > 30 && /* @__PURE__ */ e("p", { className: "border-t border-slate-100 px-2.5 py-1.5 text-[11px] text-slate-400 dark:border-border", children: "Showing first 30 — type to narrow." })
915
920
  ]
916
921
  }
917
922
  ),
@@ -940,35 +945,35 @@ function st({
940
945
  function lt() {
941
946
  const { data: i } = q({
942
947
  queryKey: ["nvr-settings-2fa"],
943
- queryFn: () => a.request({ _method: "GET", _path: "/settings/" }).then((y) => (y == null ? void 0 : y.data) ?? null).catch(() => null),
948
+ queryFn: () => a.request({ _method: "GET", _path: "/settings/" }).then((f) => (f == null ? void 0 : f.data) ?? null).catch(() => null),
944
949
  staleTime: 6e5
945
950
  }), m = (i == null ? void 0 : i.two_factor_enabled) !== !1, a = T(), s = E(), [l, o] = C(null), [c, u] = C(""), [n, b] = C(null), { data: p } = q({
946
951
  queryKey: ["nvr-profile-totp"],
947
- queryFn: () => a.request({ _method: "GET", _path: "/two-factor/status" }).then((y) => y.data)
952
+ queryFn: () => a.request({ _method: "GET", _path: "/two-factor/status" }).then((f) => f.data)
948
953
  }), w = () => void s.invalidateQueries({ queryKey: ["nvr-profile-totp"] }), k = _({
949
- mutationFn: () => a.request({ _method: "POST", _path: "/two-factor/setup" }).then((y) => y.data),
950
- onSuccess: (y) => o(y)
954
+ mutationFn: () => a.request({ _method: "POST", _path: "/two-factor/setup" }).then((f) => f.data),
955
+ onSuccess: (f) => o(f)
951
956
  }), P = _({
952
- mutationFn: (y) => a.request({
957
+ mutationFn: (f) => a.request({
953
958
  _method: "POST",
954
959
  _path: "/two-factor/verify",
955
- _body: { token: y }
960
+ _body: { token: f }
956
961
  }),
957
962
  onSuccess: () => {
958
963
  o(null), u(""), w();
959
964
  }
960
965
  }), v = _({
961
- mutationFn: (y) => a.request({
966
+ mutationFn: (f) => a.request({
962
967
  _method: "POST",
963
968
  _path: "/two-factor/disable",
964
- _body: { token: y }
969
+ _body: { token: f }
965
970
  }),
966
971
  onSuccess: () => {
967
972
  u(""), w();
968
973
  }
969
974
  }), O = _({
970
- mutationFn: () => a.request({ _method: "POST", _path: "/users/me/token" }).then((y) => y.data),
971
- onSuccess: (y) => b(y.token)
975
+ mutationFn: () => a.request({ _method: "POST", _path: "/users/me/token" }).then((f) => f.data),
976
+ onSuccess: (f) => b(f.token)
972
977
  }), L = _({
973
978
  mutationFn: () => a.request({ _method: "DELETE", _path: "/users/me/token" }),
974
979
  onSuccess: () => b(null)
@@ -1022,7 +1027,7 @@ function lt() {
1022
1027
  "input",
1023
1028
  {
1024
1029
  value: c,
1025
- onChange: (y) => u(y.target.value),
1030
+ onChange: (f) => u(f.target.value),
1026
1031
  placeholder: "123456",
1027
1032
  inputMode: "numeric",
1028
1033
  className: "h-8 w-[110px] rounded-md border border-slate-200 px-2.5 text-center text-[13px] tabular-nums tracking-widest dark:border-border dark:bg-background"
@@ -1046,7 +1051,7 @@ function lt() {
1046
1051
  "input",
1047
1052
  {
1048
1053
  value: c,
1049
- onChange: (y) => u(y.target.value),
1054
+ onChange: (f) => u(f.target.value),
1050
1055
  placeholder: "Code to disable",
1051
1056
  inputMode: "numeric",
1052
1057
  className: "h-8 w-[130px] rounded-md border border-slate-200 px-2.5 text-[12px] dark:border-border dark:bg-background"
@@ -1137,11 +1142,11 @@ function ot({
1137
1142
  var U;
1138
1143
  const s = T(), l = E(), o = xe(), c = !0, u = "me", { data: n } = q({
1139
1144
  queryKey: ["nvr-profile-user", u],
1140
- queryFn: () => s.request(fe(u)).then((d) => d.data),
1145
+ queryFn: () => s.request(ye(u)).then((d) => d.data),
1141
1146
  enabled: c
1142
1147
  }), b = (n == null ? void 0 : n.id) ?? null, { data: p } = q({
1143
1148
  queryKey: ["nvr-profile-card", b],
1144
- queryFn: () => s.request(ye(b)).then((d) => d.data),
1149
+ queryFn: () => s.request(fe(b)).then((d) => d.data),
1145
1150
  enabled: !!b
1146
1151
  }), [w, k] = C(null), P = Le(
1147
1152
  () => ({
@@ -1157,7 +1162,7 @@ function ot({
1157
1162
  onSuccess: () => {
1158
1163
  k(null), l.invalidateQueries({ queryKey: ["nvr-profile-user"] }), l.invalidateQueries({ queryKey: ["nvr-profile-card"] });
1159
1164
  }
1160
- }), [S, y] = C(it), z = De(null), I = _({
1165
+ }), [S, f] = C(it), z = De(null), I = _({
1161
1166
  mutationFn: async (d) => {
1162
1167
  const N = await new Promise((A, Z) => {
1163
1168
  const D = new Image(), W = URL.createObjectURL(d);
@@ -1178,8 +1183,8 @@ function ot({
1178
1183
  onSuccess: () => {
1179
1184
  l.invalidateQueries({ queryKey: ["nvr-profile-user"] }), l.invalidateQueries({ queryKey: ["nvr-profile-card"] }), l.invalidateQueries({ queryKey: ["user-card"] }), l.invalidateQueries({ queryKey: ["user-avatar"] });
1180
1185
  }
1181
- }), f = p ?? (n ? { ...n, role_name: null } : null);
1182
- if (!f)
1186
+ }), y = p ?? (n ? { ...n, role_name: null } : null);
1187
+ if (!y)
1183
1188
  return /* @__PURE__ */ t("div", { className: $("flex animate-pulse flex-col gap-4", i), "aria-busy": "true", children: [
1184
1189
  /* @__PURE__ */ t("div", { className: "flex items-center gap-5 rounded-lg border border-slate-200 bg-white p-5 dark:border-border dark:bg-card", children: [
1185
1190
  /* @__PURE__ */ e("div", { className: "h-[76px] w-[76px] rounded-full bg-slate-100 dark:bg-muted" }),
@@ -1194,7 +1199,7 @@ function ot({
1194
1199
  /* @__PURE__ */ e("div", { className: "h-64 rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card" })
1195
1200
  ] })
1196
1201
  ] });
1197
- const K = (n == null ? void 0 : n.avatar) ?? null, j = f.status === "active";
1202
+ const K = (n == null ? void 0 : n.avatar) ?? null, j = y.status === "active";
1198
1203
  return /* @__PURE__ */ t("div", { className: $("flex flex-col gap-4", i), "data-nvr-profile": !0, children: [
1199
1204
  /* @__PURE__ */ e("div", { className: "rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-x-5 gap-y-4 p-5", children: [
1200
1205
  /* @__PURE__ */ t("div", { className: "relative", children: [
@@ -1205,7 +1210,7 @@ function ot({
1205
1210
  alt: "",
1206
1211
  className: "h-[76px] w-[76px] rounded-full border border-slate-200 object-cover dark:border-border"
1207
1212
  }
1208
- ) : /* @__PURE__ */ e("span", { className: "flex h-[76px] w-[76px] items-center justify-center rounded-full bg-[#c7f0fb] text-[24px] font-semibold text-[#04516b] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: Xe(f) }),
1213
+ ) : /* @__PURE__ */ e("span", { className: "flex h-[76px] w-[76px] items-center justify-center rounded-full bg-[#c7f0fb] text-[24px] font-semibold text-[#04516b] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: Xe(y) }),
1209
1214
  /* @__PURE__ */ e(
1210
1215
  "span",
1211
1216
  {
@@ -1213,7 +1218,7 @@ function ot({
1213
1218
  "absolute bottom-0.5 right-0.5 h-3 w-3 rounded-full border-2 border-white dark:border-card",
1214
1219
  j ? "bg-emerald-500" : "bg-slate-300 dark:bg-slate-600"
1215
1220
  ),
1216
- title: j ? "Active" : f.status
1221
+ title: j ? "Active" : y.status
1217
1222
  }
1218
1223
  ),
1219
1224
  /* @__PURE__ */ t(oe, { children: [
@@ -1249,10 +1254,10 @@ function ot({
1249
1254
  ] }),
1250
1255
  /* @__PURE__ */ t("div", { className: "min-w-0 flex-1", children: [
1251
1256
  /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-2", children: [
1252
- /* @__PURE__ */ e("h1", { className: "text-[21px] font-semibold tracking-[-0.015em] text-slate-900 dark:text-white", children: Ze(f) }),
1253
- f.role_name && /* @__PURE__ */ e("span", { className: "rounded-full bg-nvr-cyan/10 px-2 py-px text-[10.5px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: f.role_name }),
1254
- f.is_out_of_office && /* @__PURE__ */ e("span", { className: "rounded-full bg-amber-50 px-2 py-px text-[10.5px] font-semibold text-amber-600 dark:bg-amber-500/10 dark:text-amber-400", children: "Out of office" }),
1255
- /* @__PURE__ */ e(He, { email: f.email, canClear: o.isAdmin })
1257
+ /* @__PURE__ */ e("h1", { className: "text-[21px] font-semibold tracking-[-0.015em] text-slate-900 dark:text-white", children: Ze(y) }),
1258
+ y.role_name && /* @__PURE__ */ e("span", { className: "rounded-full bg-nvr-cyan/10 px-2 py-px text-[10.5px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: y.role_name }),
1259
+ y.is_out_of_office && /* @__PURE__ */ e("span", { className: "rounded-full bg-amber-50 px-2 py-px text-[10.5px] font-semibold text-amber-600 dark:bg-amber-500/10 dark:text-amber-400", children: "Out of office" }),
1260
+ /* @__PURE__ */ e(He, { email: y.email, canClear: o.isAdmin })
1256
1261
  ] }),
1257
1262
  n && // The same status the chat panel's Online tab sets — one editor,
1258
1263
  // one preference, so the profile always agrees with the top bar.
@@ -1266,40 +1271,40 @@ function ot({
1266
1271
  className: "mt-1.5"
1267
1272
  }
1268
1273
  ),
1269
- (f.title || f.department) && /* @__PURE__ */ e("p", { className: "mt-0.5 truncate text-[13px] text-slate-500 dark:text-slate-400", children: [f.title, f.department].filter(Boolean).join(" · ") }),
1274
+ (y.title || y.department) && /* @__PURE__ */ e("p", { className: "mt-0.5 truncate text-[13px] text-slate-500 dark:text-slate-400", children: [y.title, y.department].filter(Boolean).join(" · ") }),
1270
1275
  /* @__PURE__ */ t("div", { className: "mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-[12.5px] text-slate-500 dark:text-slate-400", children: [
1271
- f.company && /* @__PURE__ */ t("span", { className: "inline-flex items-center gap-1.5", children: [
1276
+ y.company && /* @__PURE__ */ t("span", { className: "inline-flex items-center gap-1.5", children: [
1272
1277
  /* @__PURE__ */ e(we, { className: "h-3.5 w-3.5" }),
1273
1278
  " ",
1274
- f.company
1279
+ y.company
1275
1280
  ] }),
1276
1281
  /* @__PURE__ */ t(
1277
1282
  "a",
1278
1283
  {
1279
- href: `mailto:${f.email}`,
1284
+ href: `mailto:${y.email}`,
1280
1285
  className: "inline-flex items-center gap-1.5 transition-colors hover:text-nvr-navy dark:hover:text-nvr-cyan",
1281
1286
  children: [
1282
1287
  /* @__PURE__ */ e(Se, { className: "h-3.5 w-3.5" }),
1283
1288
  " ",
1284
- f.email
1289
+ y.email
1285
1290
  ]
1286
1291
  }
1287
1292
  ),
1288
- f.phone && /* @__PURE__ */ t(
1293
+ y.phone && /* @__PURE__ */ t(
1289
1294
  "a",
1290
1295
  {
1291
- href: `tel:${f.phone}`,
1296
+ href: `tel:${y.phone}`,
1292
1297
  className: "inline-flex items-center gap-1.5 transition-colors hover:text-nvr-navy dark:hover:text-nvr-cyan",
1293
1298
  children: [
1294
1299
  /* @__PURE__ */ e(_e, { className: "h-3.5 w-3.5" }),
1295
1300
  " ",
1296
- f.phone
1301
+ y.phone
1297
1302
  ]
1298
1303
  }
1299
1304
  ),
1300
- f.last_access && /* @__PURE__ */ t("span", { className: "inline-flex items-center gap-1.5", title: "Last active", children: [
1305
+ y.last_access && /* @__PURE__ */ t("span", { className: "inline-flex items-center gap-1.5", title: "Last active", children: [
1301
1306
  /* @__PURE__ */ e(qe, { className: "h-3.5 w-3.5" }),
1302
- new Date(f.last_access).toLocaleDateString(void 0, {
1307
+ new Date(y.last_access).toLocaleDateString(void 0, {
1303
1308
  month: "short",
1304
1309
  day: "numeric"
1305
1310
  })
@@ -1307,7 +1312,7 @@ function ot({
1307
1312
  ] })
1308
1313
  ] })
1309
1314
  ] }) }),
1310
- /* @__PURE__ */ e(dt, { tab: S, onChange: y }),
1315
+ /* @__PURE__ */ e(dt, { tab: S, onChange: f }),
1311
1316
  S === "agents" ? /* @__PURE__ */ e(Re, {}) : n ? (
1312
1317
  // One list in reading order — you, then notifications, then access
1313
1318
  // and security — flowing into two balanced columns. Two fixed stacks
@@ -0,0 +1,16 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { serverErrorText as c, loadErrorText as i } from "../lib/load-error.js";
3
+ import { cn as a } from "../lib/utils.js";
4
+ import { LoadErrorNote as x } from "./LoadErrorNote.js";
5
+ function u({
6
+ error: r,
7
+ what: e,
8
+ onRetry: m,
9
+ className: s
10
+ }) {
11
+ const o = c(r), n = o ? `Couldn’t load ${e}. ${o}` : i(r, e);
12
+ return /* @__PURE__ */ t("div", { className: a("flex min-h-[200px] flex-1 items-center justify-center p-8", s), children: /* @__PURE__ */ t(x, { centered: !0, message: n, onRetry: m, className: "max-w-[320px]" }) });
13
+ }
14
+ export {
15
+ u as QueryErrorState
16
+ };