@nivaro/react 0.3.117 → 0.3.118

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 (137) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +136 -14
  4. package/dist/index.js +488 -485
  5. package/dist/shared/components/ActivityEntry.js +130 -125
  6. package/dist/shared/components/AgentPresenceChip.js +36 -26
  7. package/dist/shared/components/CellCopyLayer.js +50 -45
  8. package/dist/shared/components/CollectionBrowserView.js +3757 -3695
  9. package/dist/shared/components/FilePreviewLightbox.js +96 -58
  10. package/dist/shared/components/InStep.js +18 -17
  11. package/dist/shared/components/ItemEditForm.js +4220 -4175
  12. package/dist/shared/components/JobsTray.js +8 -8
  13. package/dist/shared/components/LiveNewMatchesPill.js +21 -14
  14. package/dist/shared/components/LiveOffNote.js +3 -2
  15. package/dist/shared/components/LiveRowMark.js +53 -23
  16. package/dist/shared/components/LiveTraceView.js +162 -123
  17. package/dist/shared/components/MyWorkView.js +320 -299
  18. package/dist/shared/components/NotificationBell.js +14 -14
  19. package/dist/shared/components/OverflowRail.js +1 -1
  20. package/dist/shared/components/PageRenderer.js +120 -116
  21. package/dist/shared/components/ProfileView.js +203 -202
  22. package/dist/shared/components/RealtimeStatusBanner.js +31 -29
  23. package/dist/shared/components/RecordDrilldownSheet.js +7 -7
  24. package/dist/shared/components/RecordHoverCard.js +102 -84
  25. package/dist/shared/components/RecordReadView.js +146 -146
  26. package/dist/shared/components/ScreenRefreshButton.js +34 -32
  27. package/dist/shared/components/TipLayer.js +65 -58
  28. package/dist/shared/components/WidgetImageMenu.js +83 -43
  29. package/dist/shared/components/activity/RecordActivityStream.js +175 -173
  30. package/dist/shared/components/bulk/BulkSelectionNotices.js +142 -119
  31. package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +158 -143
  32. package/dist/shared/components/change-proposals/ProposeChangeButton.js +17 -11
  33. package/dist/shared/components/change-proposals/ProposeChangeDialog.js +201 -173
  34. package/dist/shared/components/chat/ChatAnalyticsView.js +27 -27
  35. package/dist/shared/components/chat/HuddleAnalyticsTab.js +17 -17
  36. package/dist/shared/components/collections-directory/CollectionsToolbar.js +39 -41
  37. package/dist/shared/components/collections-directory/page-model.js +72 -67
  38. package/dist/shared/components/integrations/RecordIntegrationPreview.js +48 -56
  39. package/dist/shared/components/integrations/SendStatus.js +65 -59
  40. package/dist/shared/components/integrations/console/ReadyToSendView.js +275 -209
  41. package/dist/shared/components/integrations/console/SignalCard.js +237 -230
  42. package/dist/shared/components/item-edit/CatalogPickerField.js +227 -205
  43. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +131 -92
  44. package/dist/shared/components/item-edit/CloneDialog.js +191 -161
  45. package/dist/shared/components/item-edit/DerivedCauseNote.js +44 -30
  46. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +153 -134
  47. package/dist/shared/components/item-edit/FieldComments.js +54 -53
  48. package/dist/shared/components/item-edit/FieldPointer.js +82 -67
  49. package/dist/shared/components/item-edit/FieldRow.js +106 -100
  50. package/dist/shared/components/item-edit/FieldSourceBadge.js +58 -56
  51. package/dist/shared/components/item-edit/FilePickerField.js +452 -387
  52. package/dist/shared/components/item-edit/HeaderSummaryChip.js +78 -56
  53. package/dist/shared/components/item-edit/HeaderTools.js +94 -85
  54. package/dist/shared/components/item-edit/InlineTableField.js +1242 -1218
  55. package/dist/shared/components/item-edit/ListNeighborNav.js +47 -50
  56. package/dist/shared/components/item-edit/LiveTraceSheet.js +15 -10
  57. package/dist/shared/components/item-edit/MembershipSetField.js +285 -254
  58. package/dist/shared/components/item-edit/OutboxReviewTray.js +155 -144
  59. package/dist/shared/components/item-edit/QueueReturnChip.js +15 -36
  60. package/dist/shared/components/item-edit/RecalcValue.js +57 -32
  61. package/dist/shared/components/item-edit/RecordHelpChip.js +21 -22
  62. package/dist/shared/components/item-edit/RecordLiveSync.js +283 -231
  63. package/dist/shared/components/item-edit/RelationCombobox.js +439 -393
  64. package/dist/shared/components/item-edit/RemoteChangeUi.js +292 -224
  65. package/dist/shared/components/item-edit/RemoteUploads.js +26 -20
  66. package/dist/shared/components/item-edit/RemovedLineNote.js +77 -67
  67. package/dist/shared/components/item-edit/RichTextEditorImpl.js +184 -179
  68. package/dist/shared/components/item-edit/ScheduledChangeChip.js +168 -134
  69. package/dist/shared/components/item-edit/SectionPresence.js +18 -10
  70. package/dist/shared/components/item-edit/SplitLinesButton.js +163 -139
  71. package/dist/shared/components/item-edit/UserChip.js +1 -1
  72. package/dist/shared/components/item-edit/file-live.js +69 -54
  73. package/dist/shared/components/item-edit/layout-switch.js +98 -89
  74. package/dist/shared/components/item-edit/partner-needs.js +12 -12
  75. package/dist/shared/components/item-edit/removed-line.js +31 -25
  76. package/dist/shared/components/layout-editor/pickers/field-picker.js +112 -104
  77. package/dist/shared/components/list/ListViewers.js +46 -35
  78. package/dist/shared/components/notifications/NotificationCenterView.js +479 -437
  79. package/dist/shared/components/panels/AccessDeniedPanel.js +176 -101
  80. package/dist/shared/components/panels/AlertBanners.js +82 -72
  81. package/dist/shared/components/panels/BranchLanes.js +22 -22
  82. package/dist/shared/components/panels/CommentImages.js +123 -102
  83. package/dist/shared/components/panels/CommentPanel.js +186 -185
  84. package/dist/shared/components/panels/ExternalRequestsChip.js +111 -119
  85. package/dist/shared/components/panels/OwnerOpenedLine.js +31 -24
  86. package/dist/shared/components/panels/PipelinePanel.js +2037 -1885
  87. package/dist/shared/components/panels/ResubmissionDiff.js +163 -142
  88. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +400 -288
  89. package/dist/shared/components/pipeline/PipelineEditorView.js +7 -2
  90. package/dist/shared/components/profile/AgentNameField.js +107 -81
  91. package/dist/shared/components/profile/AgentsPanel.js +184 -184
  92. package/dist/shared/components/profile/PersonAccess.js +599 -495
  93. package/dist/shared/components/profile/SignInTroubleshooter.js +160 -127
  94. package/dist/shared/components/profile/SignedInDevices.js +17 -17
  95. package/dist/shared/components/profile/primitives.js +1 -1
  96. package/dist/shared/components/queue/OwnerAvatars.js +91 -54
  97. package/dist/shared/components/queue/QueueTeamStrip.js +56 -46
  98. package/dist/shared/components/queue/QueueWorklist.js +1002 -983
  99. package/dist/shared/components/support/AssignRules.js +1733 -0
  100. package/dist/shared/components/support/PersonPick.js +88 -0
  101. package/dist/shared/components/support/RequestList.js +790 -0
  102. package/dist/shared/components/support/ScreenShare.js +158 -152
  103. package/dist/shared/components/support/SupportRequestDialog.js +50 -48
  104. package/dist/shared/components/support/SupportView.js +140 -246
  105. package/dist/shared/components/support/TicketDetailSheet.js +82 -75
  106. package/dist/shared/components/support/TicketSlowScreens.js +9 -9
  107. package/dist/shared/components/support/assign-rules-text.js +171 -0
  108. package/dist/shared/components/support/support-list.js +125 -0
  109. package/dist/shared/components/ui/SimpleSelect.js +28 -20
  110. package/dist/shared/components/ui/checkbox.js +6 -6
  111. package/dist/shared/components/ui/select.js +43 -39
  112. package/dist/shared/components/ui/sheet.js +9 -9
  113. package/dist/shared/components/ui/switch.js +12 -11
  114. package/dist/shared/components/watch-list/WatchDock.js +532 -459
  115. package/dist/shared/components/watch-list/WatchExtras.js +332 -286
  116. package/dist/shared/components/watch-list/WatchRows.js +164 -140
  117. package/dist/shared/lib/activity-sentence.js +103 -91
  118. package/dist/shared/lib/agent-presence.js +27 -21
  119. package/dist/shared/lib/approval-progress.js +2 -2
  120. package/dist/shared/lib/copy-rules.js +31 -24
  121. package/dist/shared/lib/derived-causes.js +113 -78
  122. package/dist/shared/lib/grid-cursors.js +26 -26
  123. package/dist/shared/lib/label-flash.js +27 -0
  124. package/dist/shared/lib/list-return.js +137 -125
  125. package/dist/shared/lib/live-deltas.js +40 -34
  126. package/dist/shared/lib/live-groups.js +56 -52
  127. package/dist/shared/lib/live-preference.js +64 -59
  128. package/dist/shared/lib/live-screen.js +223 -192
  129. package/dist/shared/lib/partner-failure.js +11 -11
  130. package/dist/shared/lib/rollup-recalc.js +68 -64
  131. package/dist/shared/lib/screen-refresh.js +74 -68
  132. package/dist/shared/lib/screen-share.js +108 -104
  133. package/dist/shared/lib/send-status.js +77 -61
  134. package/dist/shared/lib/text-diff-window.js +29 -0
  135. package/dist/shared/lib/watch-list.js +210 -209
  136. package/dist/shared/lib/widget-image-render.js +72 -49
  137. package/package.json +1 -1
@@ -1,20 +1,20 @@
1
- import { jsxs as a, jsx as t, Fragment as I } from "react/jsx-runtime";
2
- import { useQuery as K, useMutation as Q, useQueryClient as ae } from "@tanstack/react-query";
3
- import { Undo2 as Ce, Loader2 as ne, Check as ge, ShieldCheck as _e, ShieldAlert as xe, SlidersHorizontal as $e, RefreshCw as te, BookUser as qe, MonitorSmartphone as Re, EyeOff as Le, Eye as Te, Copy as Ae, Trash2 as De, KeyRound as Ee, Smartphone as Ke, Monitor as Pe, LogOut as Fe } from "lucide-react";
4
- import { useMemo as fe, useState as E, useRef as W, useEffect as de } from "react";
5
- import { toast as A } from "sonner";
6
- import { useNivaroClient as F } from "../../context.js";
7
- import { get as P, patch as Oe, put as Me, post as se, del as ye } from "../../lib/commands.js";
8
- import { toastError as ve } from "../../lib/error-toast.js";
9
- import { useLiveOps as Qe, useFreshIds as je } from "../../lib/live-ops.js";
10
- import { useLivePreference as Ue } from "../../lib/live-preference.js";
11
- import { formatRelative as Be, cn as T, formatDateTime as Ie, formatNumber as B } from "../../lib/utils.js";
12
- import { ErrorNotice as ze } from "../ErrorNotice.js";
13
- import { useOverflowTip as ce } from "../TipLayer.js";
14
- import { SimpleSelect as Z } from "../ui/SimpleSelect.js";
15
- import { Skeleton as me } from "../ui/skeleton.js";
16
- import { SectionCard as J, EmptyLine as ke, ConfirmButton as Y } from "./primitives.js";
17
- import { useInvalidatePerson as ie, errorText as z } from "./types.js";
1
+ import { jsxs as n, jsx as t, Fragment as z } from "react/jsx-runtime";
2
+ import { useQuery as E, useMutation as j, useQueryClient as oe } from "@tanstack/react-query";
3
+ import { Undo2 as _e, Loader2 as le, Check as ye, ShieldCheck as qe, ShieldAlert as ve, SlidersHorizontal as Re, RefreshCw as ae, BookUser as Ae, LogOut as ke, MonitorSmartphone as Le, EyeOff as Te, Eye as De, Copy as Fe, Trash2 as Ke, KeyRound as Pe, Smartphone as Ee, Monitor as Oe } from "lucide-react";
4
+ import { useMemo as de, useState as P, useRef as X, useEffect as pe } from "react";
5
+ import { toast as F } from "sonner";
6
+ import { useNivaroClient as Q } from "../../context.js";
7
+ import { get as O, patch as Qe, put as Me, post as H, del as Ne } from "../../lib/commands.js";
8
+ import { toastError as se } from "../../lib/error-toast.js";
9
+ import { useLiveOps as Ue, useFreshIds as je } from "../../lib/live-ops.js";
10
+ import { useLivePreference as Be } from "../../lib/live-preference.js";
11
+ import { formatRelative as ze, cn as T, formatNumber as M, formatDateTime as Ge } from "../../lib/utils.js";
12
+ import { ErrorNotice as He } from "../ErrorNotice.js";
13
+ import { useOverflowTip as Ie } from "../TipLayer.js";
14
+ import { SimpleSelect as re } from "../ui/SimpleSelect.js";
15
+ import { Skeleton as he } from "../ui/skeleton.js";
16
+ import { SectionCard as Y, EmptyLine as we, ConfirmButton as I } from "./primitives.js";
17
+ import { useInvalidatePerson as ce, errorText as J } from "./types.js";
18
18
  const Je = [
19
19
  { value: "", label: "Person" },
20
20
  { value: "integration", label: "Integration — an external system writes as it" },
@@ -22,97 +22,97 @@ const Je = [
22
22
  { value: "bot", label: "Bot" },
23
23
  { value: "placeholder", label: "Placeholder — kept so old references resolve" }
24
24
  ];
25
- function ft({ profile: e }) {
26
- const n = F(), d = ie(e.id), { data: i = [] } = K({
25
+ function wt({ profile: e }) {
26
+ const r = Q(), s = ce(e.id), { data: i = [] } = E({
27
27
  queryKey: ["nvr-roles"],
28
- queryFn: () => n.request(
29
- P("/roles")
30
- ).then((m) => m.data),
28
+ queryFn: () => r.request(
29
+ O("/roles")
30
+ ).then((u) => u.data),
31
31
  staleTime: 5 * 6e4
32
- }), o = fe(
32
+ }), l = de(
33
33
  () => {
34
- var m;
34
+ var u;
35
35
  return {
36
36
  role: e.role_id ?? "",
37
37
  status: e.status,
38
- account_kind: ((m = e.admin) == null ? void 0 : m.account_kind) ?? ""
38
+ account_kind: ((u = e.admin) == null ? void 0 : u.account_kind) ?? ""
39
39
  };
40
40
  },
41
41
  [e]
42
- ), [b, h] = E(null), p = b ?? o, k = JSON.stringify(p) !== JSON.stringify(o), l = Q({
43
- mutationFn: () => n.request(
44
- Oe(`/users/${e.id}`, {
45
- role: p.role || null,
46
- status: p.status,
47
- account_kind: p.account_kind || null
42
+ ), [h, b] = P(null), d = h ?? l, $ = JSON.stringify(d) !== JSON.stringify(l), c = j({
43
+ mutationFn: () => r.request(
44
+ Qe(`/users/${e.id}`, {
45
+ role: d.role || null,
46
+ status: d.status,
47
+ account_kind: d.account_kind || null
48
48
  })
49
49
  ),
50
50
  onSuccess: () => {
51
- h(null), d(), A.success("Access saved");
51
+ b(null), s(), F.success("Access saved");
52
52
  },
53
- onError: (m) => A.error(z(m, "Could not save access"))
54
- }), c = [
53
+ onError: (u) => F.error(J(u, "Could not save access"))
54
+ }), f = [
55
55
  { value: "", label: "No role" },
56
- ...i.map((m) => ({ value: m.id, label: m.admin_access ? `${m.name} · admin` : m.name }))
56
+ ...i.map((u) => ({ value: u.id, label: u.admin_access ? `${u.name} · admin` : u.name }))
57
57
  ];
58
58
  return /* @__PURE__ */ t(
59
- J,
59
+ Y,
60
60
  {
61
- icon: /* @__PURE__ */ t(_e, { className: "h-4 w-4" }),
61
+ icon: /* @__PURE__ */ t(qe, { className: "h-4 w-4" }),
62
62
  title: "Access",
63
63
  hint: "Role decides what they can do; status decides whether they can sign in",
64
64
  testId: "access",
65
- actions: k && /* @__PURE__ */ a("span", { className: "flex items-center gap-1.5", children: [
66
- /* @__PURE__ */ a(
65
+ actions: $ && /* @__PURE__ */ n("span", { className: "flex items-center gap-1.5", children: [
66
+ /* @__PURE__ */ n(
67
67
  "button",
68
68
  {
69
69
  type: "button",
70
- onClick: () => h(null),
70
+ onClick: () => b(null),
71
71
  className: "inline-flex h-7 items-center gap-1 rounded-md px-2 text-[11.5px] font-medium text-slate-400 transition-colors hover:text-slate-600 dark:hover:text-slate-200",
72
72
  children: [
73
- /* @__PURE__ */ t(Ce, { className: "h-3 w-3" }),
73
+ /* @__PURE__ */ t(_e, { className: "h-3 w-3" }),
74
74
  " Reset"
75
75
  ]
76
76
  }
77
77
  ),
78
- /* @__PURE__ */ a(
78
+ /* @__PURE__ */ n(
79
79
  "button",
80
80
  {
81
81
  type: "button",
82
- disabled: l.isPending,
83
- onClick: () => l.mutate(),
82
+ disabled: c.isPending,
83
+ onClick: () => c.mutate(),
84
84
  "data-person-access-save": !0,
85
85
  className: "inline-flex h-7 items-center gap-1 rounded-md bg-nvr-cyan px-2.5 text-[11.5px] font-semibold text-white transition-opacity disabled:opacity-50",
86
86
  children: [
87
- l.isPending ? /* @__PURE__ */ t(ne, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(ge, { className: "h-3 w-3" }),
87
+ c.isPending ? /* @__PURE__ */ t(le, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(ye, { className: "h-3 w-3" }),
88
88
  " ",
89
89
  "Save"
90
90
  ]
91
91
  }
92
92
  )
93
93
  ] }),
94
- children: /* @__PURE__ */ a("div", { className: "grid gap-3 sm:grid-cols-2", children: [
95
- /* @__PURE__ */ a("div", { className: "block", children: [
94
+ children: /* @__PURE__ */ n("div", { className: "grid gap-3 sm:grid-cols-2", children: [
95
+ /* @__PURE__ */ n("div", { className: "block", children: [
96
96
  /* @__PURE__ */ t("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Role" }),
97
97
  /* @__PURE__ */ t(
98
- Z,
98
+ re,
99
99
  {
100
100
  ariaLabel: "Role",
101
- value: p.role,
102
- onChange: (m) => h({ ...p, role: m }),
103
- options: c,
101
+ value: d.role,
102
+ onChange: (u) => b({ ...d, role: u }),
103
+ options: f,
104
104
  className: "h-8 text-[12.5px]"
105
105
  }
106
106
  )
107
107
  ] }),
108
- /* @__PURE__ */ a("div", { className: "block", children: [
108
+ /* @__PURE__ */ n("div", { className: "block", children: [
109
109
  /* @__PURE__ */ t("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Status" }),
110
110
  /* @__PURE__ */ t(
111
- Z,
111
+ re,
112
112
  {
113
113
  ariaLabel: "Status",
114
- value: p.status,
115
- onChange: (m) => h({ ...p, status: m }),
114
+ value: d.status,
115
+ onChange: (u) => b({ ...d, status: u }),
116
116
  options: [
117
117
  { value: "active", label: "Active" },
118
118
  { value: "inactive", label: "Inactive" },
@@ -122,14 +122,14 @@ function ft({ profile: e }) {
122
122
  }
123
123
  )
124
124
  ] }),
125
- /* @__PURE__ */ a("div", { className: "block sm:col-span-2", children: [
125
+ /* @__PURE__ */ n("div", { className: "block sm:col-span-2", children: [
126
126
  /* @__PURE__ */ t("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Account type" }),
127
127
  /* @__PURE__ */ t(
128
- Z,
128
+ re,
129
129
  {
130
130
  ariaLabel: "Account type",
131
- value: p.account_kind,
132
- onChange: (m) => h({ ...p, account_kind: m }),
131
+ value: d.account_kind,
132
+ onChange: (u) => b({ ...d, account_kind: u }),
133
133
  options: Je,
134
134
  className: "h-8 text-[12.5px]"
135
135
  }
@@ -140,7 +140,7 @@ function ft({ profile: e }) {
140
140
  }
141
141
  );
142
142
  }
143
- const Ge = {
143
+ const Ye = {
144
144
  directory: "Directory sync",
145
145
  retention: "Retention policy",
146
146
  offboarding: "Offboarding",
@@ -149,23 +149,23 @@ const Ge = {
149
149
  "legacy-redaction": "Legacy redaction job",
150
150
  unknown: "Unknown"
151
151
  };
152
- function yt({ profile: e }) {
153
- var o;
154
- const n = F(), d = e.status === "suspended" || !!((o = e.admin) != null && o.is_redacted), { data: i } = K({
152
+ function St({ profile: e }) {
153
+ var l;
154
+ const r = Q(), s = e.status === "suspended" || !!((l = e.admin) != null && l.is_redacted), { data: i } = E({
155
155
  queryKey: ["nvr-user-suspension", e.id],
156
- queryFn: () => n.request(P(`/users/${e.id}/suspension`)).then((b) => b.data).catch(() => null),
157
- enabled: d,
156
+ queryFn: () => r.request(O(`/users/${e.id}/suspension`)).then((h) => h.data).catch(() => null),
157
+ enabled: s,
158
158
  staleTime: 6e4
159
159
  });
160
- return !d || !i ? null : /* @__PURE__ */ a(
160
+ return !s || !i ? null : /* @__PURE__ */ n(
161
161
  "div",
162
162
  {
163
163
  className: "rounded-lg border border-[#e9c46a] bg-[#fbefd9] px-4 py-3 text-[12.5px] text-[#6b4300] dark:border-[#7a5a14] dark:bg-[#3a2a0d] dark:text-[#f1b95c]",
164
164
  "data-suspension-reason": i.source,
165
165
  children: [
166
- /* @__PURE__ */ a("p", { className: "font-medium", children: [
166
+ /* @__PURE__ */ n("p", { className: "font-medium", children: [
167
167
  "Cannot sign in — ",
168
- Ge[i.source] ?? i.source,
168
+ Ye[i.source] ?? i.source,
169
169
  i.at ? ` · ${new Date(i.at).toLocaleString()}` : "",
170
170
  i.by ? ` · by ${i.by.name}` : ""
171
171
  ] }),
@@ -175,79 +175,79 @@ function yt({ profile: e }) {
175
175
  }
176
176
  );
177
177
  }
178
- const oe = (e, n) => e.map((d) => ({ id: d.id, label: String(d[n] ?? d.id) }));
179
- function Ne(e) {
180
- const n = F(), d = e.display_field ?? "name", { data: i = [] } = K({
178
+ const me = (e, r) => e.map((s) => ({ id: s.id, label: String(s[r] ?? s.id) }));
179
+ function Se(e) {
180
+ const r = Q(), s = e.display_field ?? "name", { data: i = [] } = E({
181
181
  queryKey: ["nvr-scope-options", e.name],
182
- queryFn: () => n.request(
183
- P(`/items/${e.target_collection}`, {
184
- fields: `id,${d}`,
182
+ queryFn: () => r.request(
183
+ O(`/items/${e.target_collection}`, {
184
+ fields: `id,${s}`,
185
185
  limit: 200,
186
186
  ...e.options_sort ? { sort: e.options_sort } : {}
187
187
  })
188
- ).then((o) => oe(o.data ?? [], d))
188
+ ).then((l) => me(l.data ?? [], s))
189
189
  });
190
190
  return i;
191
191
  }
192
- function we(e, n, d = []) {
193
- const i = F(), o = e.display_field ?? "name", b = Ne(e), h = new Map(b.map((l) => [String(l.id), l.label]));
194
- for (const l of d) h.set(String(l.id), l.label);
195
- const p = n.filter((l) => !h.has(String(l))), { data: k = [] } = K({
196
- queryKey: ["nvr-scope-selected-labels", e.name, p.map(String).sort().join(",")],
192
+ function $e(e, r, s = []) {
193
+ const i = Q(), l = e.display_field ?? "name", h = Se(e), b = new Map(h.map((c) => [String(c.id), c.label]));
194
+ for (const c of s) b.set(String(c.id), c.label);
195
+ const d = r.filter((c) => !b.has(String(c))), { data: $ = [] } = E({
196
+ queryKey: ["nvr-scope-selected-labels", e.name, d.map(String).sort().join(",")],
197
197
  queryFn: () => i.request(
198
- P(`/items/${e.target_collection}`, {
199
- fields: `id,${o}`,
198
+ O(`/items/${e.target_collection}`, {
199
+ fields: `id,${l}`,
200
200
  limit: 100,
201
- filter: JSON.stringify({ id: { _in: p } })
201
+ filter: JSON.stringify({ id: { _in: d } })
202
202
  })
203
- ).then((l) => oe(l.data ?? [], o)),
204
- enabled: p.length > 0
203
+ ).then((c) => me(c.data ?? [], l)),
204
+ enabled: d.length > 0
205
205
  });
206
- for (const l of k) h.set(String(l.id), l.label);
207
- return h;
206
+ for (const c of $) b.set(String(c.id), c.label);
207
+ return b;
208
208
  }
209
- function ue({
209
+ function be({
210
210
  dimension: e,
211
- selected: n,
212
- accent: d,
211
+ selected: r,
212
+ accent: s,
213
213
  disabled: i,
214
- staged: o,
215
- removing: b,
216
- onToggle: h
214
+ staged: l,
215
+ removing: h,
216
+ onToggle: b
217
217
  }) {
218
- const p = F(), k = e.display_field ?? "name", [l, c] = E(""), m = new Set((o ?? []).map(String)), q = new Set((b ?? []).map(String)), $ = Ne(e), R = $.length > 24, { data: N = [], isFetching: y } = K({
219
- queryKey: ["nvr-scope-search", e.name, l],
220
- queryFn: () => p.request(
221
- P(`/items/${e.target_collection}`, {
222
- fields: `id,${k}`,
218
+ const d = Q(), $ = e.display_field ?? "name", [c, f] = P(""), u = new Set((l ?? []).map(String)), D = new Set((h ?? []).map(String)), _ = Se(e), R = _.length > 24, { data: y = [], isFetching: v } = E({
219
+ queryKey: ["nvr-scope-search", e.name, c],
220
+ queryFn: () => d.request(
221
+ O(`/items/${e.target_collection}`, {
222
+ fields: `id,${$}`,
223
223
  limit: 30,
224
- filter: JSON.stringify({ [k]: { _contains: l } }),
224
+ filter: JSON.stringify({ [$]: { _contains: c } }),
225
225
  ...e.options_sort ? { sort: e.options_sort } : {}
226
226
  })
227
- ).then((g) => oe(g.data ?? [], k)),
228
- enabled: R && l.trim().length > 0,
227
+ ).then((g) => me(g.data ?? [], $)),
228
+ enabled: R && c.trim().length > 0,
229
229
  placeholderData: (g) => g
230
- }), s = we(e, n, N), w = new Set(n.map(String)), S = (g) => h(
231
- w.has(String(g)) ? n.filter((L) => String(L) !== String(g)) : [...n, g]
232
- ), C = d === "amber" ? "border-amber-400 bg-amber-50 font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400" : "border-nvr-cyan bg-accent font-medium text-nvr-navy dark:text-nvr-cyan";
233
- return R ? /* @__PURE__ */ a("div", { className: "max-w-xl", children: [
234
- n.length > 0 && /* @__PURE__ */ t("div", { className: "mb-1.5 flex flex-wrap gap-1", children: n.map((g) => /* @__PURE__ */ a(
230
+ }), o = $e(e, r, y), N = new Set(r.map(String)), w = (g) => b(
231
+ N.has(String(g)) ? r.filter((L) => String(L) !== String(g)) : [...r, g]
232
+ ), C = s === "amber" ? "border-amber-400 bg-amber-50 font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400" : "border-nvr-cyan bg-accent font-medium text-nvr-navy dark:text-nvr-cyan";
233
+ return R ? /* @__PURE__ */ n("div", { className: "max-w-xl", children: [
234
+ r.length > 0 && /* @__PURE__ */ t("div", { className: "mb-1.5 flex flex-wrap gap-1", children: r.map((g) => /* @__PURE__ */ n(
235
235
  "span",
236
236
  {
237
237
  className: T(
238
238
  "inline-flex items-center gap-1 rounded-full border py-0.5 pl-2.5 pr-1 text-[11.5px]",
239
239
  C,
240
- m.has(String(g)) && "border-dashed"
240
+ u.has(String(g)) && "border-dashed"
241
241
  ),
242
242
  children: [
243
- s.get(String(g)) ?? String(g),
243
+ o.get(String(g)) ?? String(g),
244
244
  /* @__PURE__ */ t(
245
245
  "button",
246
246
  {
247
247
  type: "button",
248
248
  disabled: i,
249
- onClick: () => S(g),
250
- "aria-label": `Remove ${s.get(String(g)) ?? g}`,
249
+ onClick: () => w(g),
250
+ "aria-label": `Remove ${o.get(String(g)) ?? g}`,
251
251
  className: "rounded-full px-1 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",
252
252
  children: "×"
253
253
  }
@@ -259,22 +259,22 @@ function ue({
259
259
  /* @__PURE__ */ t(
260
260
  "input",
261
261
  {
262
- value: l,
263
- onChange: (g) => c(g.target.value),
262
+ value: c,
263
+ onChange: (g) => f(g.target.value),
264
264
  disabled: i,
265
265
  placeholder: `Search ${e.label.toLowerCase()} to add…`,
266
266
  className: "h-8 w-full rounded-md border border-slate-200 bg-white px-2.5 text-[12px] outline-none focus:border-nvr-cyan dark:border-border dark:bg-card"
267
267
  }
268
268
  ),
269
- l.trim().length > 0 && /* @__PURE__ */ a("div", { className: "mt-1 max-h-44 overflow-y-auto rounded-md border border-slate-200 dark:border-border", children: [
270
- N.map((g) => {
271
- const L = w.has(String(g.id));
272
- return /* @__PURE__ */ a(
269
+ c.trim().length > 0 && /* @__PURE__ */ n("div", { className: "mt-1 max-h-44 overflow-y-auto rounded-md border border-slate-200 dark:border-border", children: [
270
+ y.map((g) => {
271
+ const L = N.has(String(g.id));
272
+ return /* @__PURE__ */ n(
273
273
  "button",
274
274
  {
275
275
  type: "button",
276
276
  disabled: i,
277
- onClick: () => S(g.id),
277
+ onClick: () => w(g.id),
278
278
  className: T(
279
279
  "flex w-full items-center justify-between px-2.5 py-1.5 text-left text-[12px] hover:bg-muted",
280
280
  L ? "font-medium text-nvr-navy dark:text-nvr-cyan" : "text-slate-600 dark:text-slate-300"
@@ -287,22 +287,22 @@ function ue({
287
287
  String(g.id)
288
288
  );
289
289
  }),
290
- N.length === 0 && /* @__PURE__ */ t("p", { className: "px-2.5 py-2 text-[11.5px] text-slate-400", children: y ? "Searching…" : "No matches." })
290
+ y.length === 0 && /* @__PURE__ */ t("p", { className: "px-2.5 py-2 text-[11.5px] text-slate-400", children: v ? "Searching…" : "No matches." })
291
291
  ] })
292
- ] }) : /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: $.map((g) => {
293
- const L = w.has(String(g.id));
292
+ ] }) : /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: _.map((g) => {
293
+ const L = N.has(String(g.id));
294
294
  return /* @__PURE__ */ t(
295
295
  "button",
296
296
  {
297
297
  type: "button",
298
298
  "aria-pressed": L,
299
299
  disabled: i,
300
- onClick: () => S(g.id),
300
+ onClick: () => w(g.id),
301
301
  className: T(
302
302
  // No colour transition: a press shows its new state at once.
303
303
  "rounded-full border px-2.5 py-0.5 text-[11.5px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:cursor-wait",
304
- L ? C : q.has(String(g.id)) ? "border-dashed border-amber-400 text-amber-800 line-through decoration-amber-500/70 dark:border-amber-500/60 dark:text-amber-300" : "border-slate-200 text-slate-600 hover:border-slate-300 dark:border-border dark:text-slate-400 dark:hover:border-slate-500",
305
- L && m.has(String(g.id)) && "border-dashed"
304
+ L ? C : D.has(String(g.id)) ? "border-dashed border-amber-400 text-amber-800 line-through decoration-amber-500/70 dark:border-amber-500/60 dark:text-amber-300" : "border-slate-200 text-slate-600 hover:border-slate-300 dark:border-border dark:text-slate-400 dark:hover:border-slate-500",
305
+ L && u.has(String(g.id)) && "border-dashed"
306
306
  ),
307
307
  children: g.label
308
308
  },
@@ -310,222 +310,222 @@ function ue({
310
310
  );
311
311
  }) });
312
312
  }
313
- const X = (e, n) => {
314
- if (e.length !== n.length) return !1;
315
- const d = new Set(e.map(String));
316
- return n.every((i) => d.has(String(i)));
317
- }, He = (e, n) => `${e}:${n.map(String).sort().join(",")}`, re = (e) => e.replace(/_/g, " ").replace(/^\w/, (n) => n.toUpperCase()), pe = (e) => /s$/i.test(e) ? e : `${e}s`;
318
- function ee(e) {
313
+ const Z = (e, r) => {
314
+ if (e.length !== r.length) return !1;
315
+ const s = new Set(e.map(String));
316
+ return r.every((i) => s.has(String(i)));
317
+ }, Ve = (e, r) => `${e}:${r.map(String).sort().join(",")}`, ie = (e) => e.replace(/_/g, " ").replace(/^\w/, (r) => r.toUpperCase()), ge = (e) => /s$/i.test(e) ? e : `${e}s`;
318
+ function ne(e) {
319
319
  return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e.at(-1)}`;
320
320
  }
321
- function vt({
321
+ function $t({
322
322
  userId: e,
323
- previewDelayMs: n = 400
323
+ previewDelayMs: r = 400
324
324
  }) {
325
- const d = F(), i = ae(), o = fe(() => ["nvr-user-scopes", e], [e]), { data: b } = K({
326
- queryKey: o,
327
- queryFn: () => d.request(P(`/user-scopes/${e}`)).then((r) => r.data)
328
- }), [h, p] = E({}), [k, l] = E({}), c = W({}), m = W({}), q = W({});
329
- de(() => {
330
- const r = q.current;
325
+ const s = Q(), i = oe(), l = de(() => ["nvr-user-scopes", e], [e]), { data: h } = E({
326
+ queryKey: l,
327
+ queryFn: () => s.request(O(`/user-scopes/${e}`)).then((a) => a.data)
328
+ }), [b, d] = P({}), [$, c] = P({}), f = X({}), u = X({}), D = X({});
329
+ pe(() => {
330
+ const a = D.current;
331
331
  return () => {
332
- for (const u of Object.values(r)) clearTimeout(u);
332
+ for (const p of Object.values(a)) clearTimeout(p);
333
333
  };
334
334
  }, []);
335
- const $ = (r, u) => {
336
- clearTimeout(q.current[r]), l((v) => {
337
- const { [r]: f, ..._ } = v;
338
- return u ? { ..._, [r]: u } : _;
339
- }), u === "saved" && (q.current[r] = setTimeout(() => $(r, null), 2400));
340
- }, R = (r) => i.setQueryData(o, (u) => {
341
- if (!u) return u;
342
- const v = r.mode === "restrict" ? "restricted" : "defaults";
343
- return { ...u, [v]: { ...u[v], [r.dimension]: r.values } };
344
- }), N = Q({
335
+ const _ = (a, p) => {
336
+ clearTimeout(D.current[a]), c((S) => {
337
+ const { [a]: k, ...q } = S;
338
+ return p ? { ...q, [a]: p } : q;
339
+ }), p === "saved" && (D.current[a] = setTimeout(() => _(a, null), 2400));
340
+ }, R = (a) => i.setQueryData(l, (p) => {
341
+ if (!p) return p;
342
+ const S = a.mode === "restrict" ? "restricted" : "defaults";
343
+ return { ...p, [S]: { ...p[S], [a.dimension]: a.values } };
344
+ }), y = j({
345
345
  // One person's scope saves go out one after another, in click order.
346
346
  scope: { id: `nvr-user-scopes:${e}` },
347
- mutationFn: (r) => d.request(Me(`/user-scopes/${e}`, r)),
348
- onMutate: (r) => {
349
- var _, U;
350
- const u = `${r.dimension}:${r.mode}`, v = r.mode === "restrict" ? "restricted" : "defaults", f = ((U = (_ = i.getQueryData(o)) == null ? void 0 : _[v]) == null ? void 0 : U[r.dimension]) ?? [];
351
- return m.current[u] = (m.current[u] ?? 0) + 1, delete c.current[u], p((M) => ({ ...M, [u]: r.values })), $(u, "saving"), i.cancelQueries({ queryKey: o }), R(r), { before: f };
347
+ mutationFn: (a) => s.request(Me(`/user-scopes/${e}`, a)),
348
+ onMutate: (a) => {
349
+ var q, G;
350
+ const p = `${a.dimension}:${a.mode}`, S = a.mode === "restrict" ? "restricted" : "defaults", k = ((G = (q = i.getQueryData(l)) == null ? void 0 : q[S]) == null ? void 0 : G[a.dimension]) ?? [];
351
+ return u.current[p] = (u.current[p] ?? 0) + 1, delete f.current[p], d((B) => ({ ...B, [p]: a.values })), _(p, "saving"), i.cancelQueries({ queryKey: l }), R(a), { before: k };
352
352
  },
353
- onSuccess: (r, u) => R(u),
354
- onError: (r, u, v) => {
355
- var M, le;
356
- const f = `${u.dimension}:${u.mode}`, _ = u.mode === "restrict" ? "restricted" : "defaults", U = ((le = (M = i.getQueryData(o)) == null ? void 0 : M[_]) == null ? void 0 : le[u.dimension]) ?? [];
357
- v && X(U, u.values) && R({ ...u, values: v.before }), p((V) => {
358
- if (!V[f] || !X(V[f], u.values)) return V;
359
- const { [f]: et, ...Se } = V;
360
- return Se;
361
- }), c.current[f] = u, ve(
362
- r,
363
- u.mode === "restrict" ? "Could not apply the restriction" : "Could not save the default",
364
- { retry: () => N.mutate(u) }
353
+ onSuccess: (a, p) => R(p),
354
+ onError: (a, p, S) => {
355
+ var B, ue;
356
+ const k = `${p.dimension}:${p.mode}`, q = p.mode === "restrict" ? "restricted" : "defaults", G = ((ue = (B = i.getQueryData(l)) == null ? void 0 : B[q]) == null ? void 0 : ue[p.dimension]) ?? [];
357
+ S && Z(G, p.values) && R({ ...p, values: S.before }), d((W) => {
358
+ if (!W[k] || !Z(W[k], p.values)) return W;
359
+ const { [k]: st, ...Ce } = W;
360
+ return Ce;
361
+ }), f.current[k] = p, se(
362
+ a,
363
+ p.mode === "restrict" ? "Could not apply the restriction" : "Could not save the default",
364
+ { retry: () => y.mutate(p) }
365
365
  );
366
366
  },
367
- onSettled: (r, u, v) => {
368
- const f = `${v.dimension}:${v.mode}`;
369
- m.current[f] = Math.max(0, (m.current[f] ?? 1) - 1), u || p((_) => {
370
- if (!_[f] || !X(_[f], v.values)) return _;
371
- const { [f]: U, ...M } = _;
372
- return M;
373
- }), m.current[f] === 0 && $(f, u ? "failed" : "saved"), i.invalidateQueries({ queryKey: o }), i.invalidateQueries({ queryKey: ["nvr-person-profile", e] }), i.invalidateQueries({ queryKey: ["nvr-my-scopes"] }), i.invalidateQueries({ queryKey: ["nvr-profile-scopes"] });
367
+ onSettled: (a, p, S) => {
368
+ const k = `${S.dimension}:${S.mode}`;
369
+ u.current[k] = Math.max(0, (u.current[k] ?? 1) - 1), p || d((q) => {
370
+ if (!q[k] || !Z(q[k], S.values)) return q;
371
+ const { [k]: G, ...B } = q;
372
+ return B;
373
+ }), u.current[k] === 0 && _(k, p ? "failed" : "saved"), i.invalidateQueries({ queryKey: l }), i.invalidateQueries({ queryKey: ["nvr-person-profile", e] }), i.invalidateQueries({ queryKey: ["nvr-my-scopes"] }), i.invalidateQueries({ queryKey: ["nvr-profile-scopes"] });
374
374
  }
375
- }), y = (r, u) => h[`${r}:${u}`] ?? (u === "restrict" ? b == null ? void 0 : b.restricted[r] : b == null ? void 0 : b.defaults[r]) ?? [], [s, w] = E(null), [S, C] = E(null), [g, L] = E(0), O = W(0), D = s ? He(s.dimension, s.values) : null;
376
- de(() => {
377
- if (!s || !D) return;
378
- const r = ++O.current, u = setTimeout(() => {
379
- d.request(
380
- se(`/user-scopes/${e}/impact`, {
381
- dimension: s.dimension,
382
- values: s.values
375
+ }), v = (a, p) => b[`${a}:${p}`] ?? (p === "restrict" ? h == null ? void 0 : h.restricted[a] : h == null ? void 0 : h.defaults[a]) ?? [], [o, N] = P(null), [w, C] = P(null), [g, L] = P(0), m = X(0), A = o ? Ve(o.dimension, o.values) : null;
376
+ pe(() => {
377
+ if (!o || !A) return;
378
+ const a = ++m.current, p = setTimeout(() => {
379
+ s.request(
380
+ H(`/user-scopes/${e}/impact`, {
381
+ dimension: o.dimension,
382
+ values: o.values
383
383
  })
384
384
  ).then(
385
- (v) => {
386
- r === O.current && C({ key: D, answer: v.data, error: null });
385
+ (S) => {
386
+ a === m.current && C({ key: A, answer: S.data, error: null });
387
387
  },
388
- (v) => {
389
- r === O.current && C({ key: D, answer: null, error: v });
388
+ (S) => {
389
+ a === m.current && C({ key: A, answer: null, error: S });
390
390
  }
391
391
  );
392
- }, n);
393
- return () => clearTimeout(u);
394
- }, [D, g, d, e, n]);
395
- const G = (r, u) => {
396
- if (X(u, y(r, "restrict"))) {
397
- O.current++, w(null), C(null);
392
+ }, r);
393
+ return () => clearTimeout(p);
394
+ }, [A, g, s, e, r]);
395
+ const K = (a, p) => {
396
+ if (Z(p, v(a, "restrict"))) {
397
+ m.current++, N(null), C(null);
398
398
  return;
399
399
  }
400
- s && s.dimension !== r && C(null), w({ dimension: r, values: u });
401
- }, j = () => {
402
- O.current++, w(null), C(null);
403
- }, H = () => {
404
- s && (N.mutate({ dimension: s.dimension, mode: "restrict", values: s.values }), j());
405
- }, x = (r) => {
406
- const u = c.current[r];
407
- u && N.mutate(u);
400
+ o && o.dimension !== a && C(null), N({ dimension: a, values: p });
401
+ }, U = () => {
402
+ m.current++, N(null), C(null);
403
+ }, V = () => {
404
+ o && (y.mutate({ dimension: o.dimension, mode: "restrict", values: o.values }), U());
405
+ }, x = (a) => {
406
+ const p = f.current[a];
407
+ p && y.mutate(p);
408
408
  };
409
- return !b || b.dimensions.length === 0 ? null : /* @__PURE__ */ t(
410
- J,
409
+ return !h || h.dimensions.length === 0 ? null : /* @__PURE__ */ t(
410
+ Y,
411
411
  {
412
- icon: /* @__PURE__ */ t($e, { className: "h-4 w-4" }),
412
+ icon: /* @__PURE__ */ t(Re, { className: "h-4 w-4" }),
413
413
  title: "Scopes",
414
414
  hint: "Defaults pre-fill their filters; restrictions limit what they can see",
415
415
  testId: "scopes",
416
- children: /* @__PURE__ */ t("div", { className: "space-y-5", children: b.dimensions.map((r) => {
417
- const u = h[`${r.name}:restrict`] != null, v = (s == null ? void 0 : s.dimension) === r.name;
418
- return /* @__PURE__ */ a("div", { children: [
419
- /* @__PURE__ */ t("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: r.label }),
420
- /* @__PURE__ */ a("div", { className: "mt-1.5 space-y-2.5", children: [
421
- /* @__PURE__ */ a("div", { "data-scope-defaults": r.name, children: [
422
- /* @__PURE__ */ a("p", { className: "mb-1 flex min-h-4 items-center gap-1.5 text-[11px] font-medium text-slate-600 dark:text-slate-300", children: [
416
+ children: /* @__PURE__ */ t("div", { className: "space-y-5", children: h.dimensions.map((a) => {
417
+ const p = b[`${a.name}:restrict`] != null, S = (o == null ? void 0 : o.dimension) === a.name;
418
+ return /* @__PURE__ */ n("div", { children: [
419
+ /* @__PURE__ */ t("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: a.label }),
420
+ /* @__PURE__ */ n("div", { className: "mt-1.5 space-y-2.5", children: [
421
+ /* @__PURE__ */ n("div", { "data-scope-defaults": a.name, children: [
422
+ /* @__PURE__ */ n("p", { className: "mb-1 flex min-h-4 items-center gap-1.5 text-[11px] font-medium text-slate-600 dark:text-slate-300", children: [
423
423
  "Defaults",
424
424
  /* @__PURE__ */ t("span", { className: "font-normal text-slate-500 dark:text-slate-400", children: "pre-filled in their filters" }),
425
425
  /* @__PURE__ */ t(
426
- be,
426
+ fe,
427
427
  {
428
- slot: `${r.name}:default`,
429
- status: k[`${r.name}:default`],
428
+ slot: `${a.name}:default`,
429
+ status: $[`${a.name}:default`],
430
430
  onRetry: x
431
431
  }
432
432
  )
433
433
  ] }),
434
434
  /* @__PURE__ */ t(
435
- ue,
435
+ be,
436
436
  {
437
- dimension: r,
438
- selected: y(r.name, "default"),
437
+ dimension: a,
438
+ selected: v(a.name, "default"),
439
439
  accent: "cyan",
440
- onToggle: (f) => N.mutate({ dimension: r.name, mode: "default", values: f })
440
+ onToggle: (k) => y.mutate({ dimension: a.name, mode: "default", values: k })
441
441
  }
442
442
  )
443
443
  ] }),
444
- /* @__PURE__ */ a("div", { "data-scope-restrict": r.name, children: [
445
- /* @__PURE__ */ a("p", { className: "mb-1 flex min-h-4 items-center gap-1.5 text-[11px] font-medium text-slate-600 dark:text-slate-300", children: [
446
- /* @__PURE__ */ t(xe, { className: "h-3 w-3 text-amber-500", "aria-hidden": !0 }),
444
+ /* @__PURE__ */ n("div", { "data-scope-restrict": a.name, children: [
445
+ /* @__PURE__ */ n("p", { className: "mb-1 flex min-h-4 items-center gap-1.5 text-[11px] font-medium text-slate-600 dark:text-slate-300", children: [
446
+ /* @__PURE__ */ t(ve, { className: "h-3 w-3 text-amber-500", "aria-hidden": !0 }),
447
447
  "Restricted to",
448
- y(r.name, "restrict").length === 0 && !v ? /* @__PURE__ */ a("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: [
448
+ v(a.name, "restrict").length === 0 && !S ? /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: [
449
449
  "none — sees every ",
450
- r.label.toLowerCase()
450
+ a.label.toLowerCase()
451
451
  ] }) : /* @__PURE__ */ t("span", { className: "font-normal text-slate-500 dark:text-slate-400", children: "enforced on every read" }),
452
452
  /* @__PURE__ */ t(
453
- be,
453
+ fe,
454
454
  {
455
- slot: `${r.name}:restrict`,
456
- status: k[`${r.name}:restrict`],
455
+ slot: `${a.name}:restrict`,
456
+ status: $[`${a.name}:restrict`],
457
457
  onRetry: x
458
458
  }
459
459
  )
460
460
  ] }),
461
461
  /* @__PURE__ */ t(
462
- ue,
462
+ be,
463
463
  {
464
- dimension: r,
465
- selected: v && s ? s.values : y(r.name, "restrict"),
464
+ dimension: a,
465
+ selected: S && o ? o.values : v(a.name, "restrict"),
466
466
  accent: "amber",
467
- disabled: u,
468
- staged: v && s ? s.values.filter(
469
- (f) => !y(r.name, "restrict").some((_) => String(_) === String(f))
467
+ disabled: p,
468
+ staged: S && o ? o.values.filter(
469
+ (k) => !v(a.name, "restrict").some((q) => String(q) === String(k))
470
470
  ) : void 0,
471
- removing: v && s ? y(r.name, "restrict").filter(
472
- (f) => !s.values.some((_) => String(_) === String(f))
471
+ removing: S && o ? v(a.name, "restrict").filter(
472
+ (k) => !o.values.some((q) => String(q) === String(k))
473
473
  ) : void 0,
474
- onToggle: (f) => G(r.name, f)
474
+ onToggle: (k) => K(a.name, k)
475
475
  }
476
476
  ),
477
- v && s && /* @__PURE__ */ t(
478
- Ve,
477
+ S && o && /* @__PURE__ */ t(
478
+ We,
479
479
  {
480
- dimension: r,
481
- saved: y(r.name, "restrict"),
482
- values: s.values,
483
- result: (S == null ? void 0 : S.key) === D ? S : null,
484
- stale: S && S.key !== D ? S.answer : null,
485
- onApply: H,
486
- onCancel: j,
487
- onRetry: () => L((f) => f + 1)
480
+ dimension: a,
481
+ saved: v(a.name, "restrict"),
482
+ values: o.values,
483
+ result: (w == null ? void 0 : w.key) === A ? w : null,
484
+ stale: w && w.key !== A ? w.answer : null,
485
+ onApply: V,
486
+ onCancel: U,
487
+ onRetry: () => L((k) => k + 1)
488
488
  }
489
489
  )
490
490
  ] })
491
491
  ] })
492
- ] }, r.name);
492
+ ] }, a.name);
493
493
  }) })
494
494
  }
495
495
  );
496
496
  }
497
- function be({
497
+ function fe({
498
498
  slot: e,
499
- status: n,
500
- onRetry: d
499
+ status: r,
500
+ onRetry: s
501
501
  }) {
502
- return /* @__PURE__ */ a(
502
+ return /* @__PURE__ */ n(
503
503
  "span",
504
504
  {
505
505
  "data-scope-status": e,
506
506
  "aria-live": "polite",
507
507
  className: T(
508
508
  "inline-flex items-center gap-1 font-normal",
509
- n === "saved" && "text-emerald-700 dark:text-emerald-400",
510
- n === "failed" && "font-medium text-red-700 dark:text-red-400",
511
- n === "saving" && "text-slate-600 dark:text-slate-300"
509
+ r === "saved" && "text-emerald-700 dark:text-emerald-400",
510
+ r === "failed" && "font-medium text-red-700 dark:text-red-400",
511
+ r === "saving" && "text-slate-600 dark:text-slate-300"
512
512
  ),
513
513
  children: [
514
- n === "saving" && /* @__PURE__ */ a(I, { children: [
515
- /* @__PURE__ */ t(ne, { className: "h-3 w-3 animate-spin motion-reduce:animate-none", "aria-hidden": !0 }),
514
+ r === "saving" && /* @__PURE__ */ n(z, { children: [
515
+ /* @__PURE__ */ t(le, { className: "h-3 w-3 animate-spin motion-reduce:animate-none", "aria-hidden": !0 }),
516
516
  "Saving…"
517
517
  ] }),
518
- n === "saved" && /* @__PURE__ */ a(I, { children: [
519
- /* @__PURE__ */ t(ge, { className: "h-3 w-3", "aria-hidden": !0 }),
518
+ r === "saved" && /* @__PURE__ */ n(z, { children: [
519
+ /* @__PURE__ */ t(ye, { className: "h-3 w-3", "aria-hidden": !0 }),
520
520
  "Saved"
521
521
  ] }),
522
- n === "failed" && /* @__PURE__ */ a(I, { children: [
522
+ r === "failed" && /* @__PURE__ */ n(z, { children: [
523
523
  "Not saved",
524
524
  /* @__PURE__ */ t(
525
525
  "button",
526
526
  {
527
527
  type: "button",
528
- onClick: () => d(e),
528
+ onClick: () => s(e),
529
529
  className: "rounded font-medium underline decoration-dotted underline-offset-2 hover:decoration-solid focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-500/40",
530
530
  children: "Retry"
531
531
  }
@@ -535,84 +535,84 @@ function be({
535
535
  }
536
536
  );
537
537
  }
538
- function Ve({
538
+ function We({
539
539
  dimension: e,
540
- saved: n,
541
- values: d,
540
+ saved: r,
541
+ values: s,
542
542
  result: i,
543
- stale: o,
544
- onApply: b,
545
- onCancel: h,
546
- onRetry: p
543
+ stale: l,
544
+ onApply: h,
545
+ onCancel: b,
546
+ onRetry: d
547
547
  }) {
548
- var j, H;
549
- const k = we(e, [...n, ...d]), l = (x) => k.get(String(x)) ?? `#${x}`, c = e.label.toLowerCase(), m = new Set(n.map(String)), q = new Set(d.map(String)), $ = d.filter((x) => !m.has(String(x))).map(l), R = n.filter((x) => !q.has(String(x))).map(l), N = (i == null ? void 0 : i.answer) ?? o, y = i ? i.error ? "error" : "ready" : o ? "updating" : "loading", s = (N == null ? void 0 : N.impact) ?? [], w = s.filter((x) => x.proposed === 0 && x.total > 0), S = d.length === 0, C = (x, r = 5) => x.length <= r ? ee(x) : `${x.slice(0, r - 1).join(", ")} and ${x.length - (r - 1)} more`, g = S ? `Remove the ${c} restriction` : n.length === 0 ? `Limit them to ${C(d.map(l))}` : [
550
- $.length > 0 ? `Also let them see ${C($)}` : null,
551
- R.length > 0 ? `${$.length > 0 ? "stop" : "Stop"} them seeing ${C(R)}` : null
552
- ].filter(Boolean).join("; "), L = S ? `They will see records in every ${c}.` : `After this they only see records in ${C(d.map(l))}.`, O = y === "updating" ? "opacity-40" : "", D = w.map((x) => x.label ?? re(x.collection)), G = D.length <= 2 ? `they lose all ${ee(D)}` : `they lose ${D.length} record types`;
553
- return /* @__PURE__ */ a(
548
+ var U, V;
549
+ const $ = $e(e, [...r, ...s]), c = (x) => $.get(String(x)) ?? `#${x}`, f = e.label.toLowerCase(), u = new Set(r.map(String)), D = new Set(s.map(String)), _ = s.filter((x) => !u.has(String(x))).map(c), R = r.filter((x) => !D.has(String(x))).map(c), y = (i == null ? void 0 : i.answer) ?? l, v = i ? i.error ? "error" : "ready" : l ? "updating" : "loading", o = (y == null ? void 0 : y.impact) ?? [], N = o.filter((x) => x.proposed === 0 && x.total > 0), w = s.length === 0, C = (x, a = 5) => x.length <= a ? ne(x) : `${x.slice(0, a - 1).join(", ")} and ${x.length - (a - 1)} more`, g = w ? `Remove the ${f} restriction` : r.length === 0 ? `Limit them to ${C(s.map(c))}` : [
550
+ _.length > 0 ? `Also let them see ${C(_)}` : null,
551
+ R.length > 0 ? `${_.length > 0 ? "stop" : "Stop"} them seeing ${C(R)}` : null
552
+ ].filter(Boolean).join("; "), L = w ? `They will see records in every ${f}.` : `After this they only see records in ${C(s.map(c))}.`, m = v === "updating" ? "opacity-40" : "", A = N.map((x) => x.label ?? ie(x.collection)), K = A.length <= 2 ? `they lose all ${ne(A)}` : `they lose ${A.length} record types`;
553
+ return /* @__PURE__ */ n(
554
554
  "div",
555
555
  {
556
- "data-scope-preview": y,
556
+ "data-scope-preview": v,
557
557
  className: "mt-2 rounded-md border border-amber-300 bg-amber-50 text-[12px] text-amber-950 dark:border-amber-500/30 dark:bg-amber-400/[0.07] dark:text-amber-50",
558
558
  children: [
559
- /* @__PURE__ */ a("div", { className: "flex items-start gap-3 px-3 pt-2.5", children: [
560
- /* @__PURE__ */ a("div", { className: "min-w-0 flex-1", children: [
559
+ /* @__PURE__ */ n("div", { className: "flex items-start gap-3 px-3 pt-2.5", children: [
560
+ /* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
561
561
  /* @__PURE__ */ t("p", { className: "font-semibold", children: g }),
562
562
  /* @__PURE__ */ t("p", { className: "mt-0.5 text-amber-900 dark:text-amber-200", children: L })
563
563
  ] }),
564
- (y === "loading" || y === "updating") && /* @__PURE__ */ a("span", { className: "mt-0.5 inline-flex shrink-0 items-center gap-1 text-[11px] text-amber-900 dark:text-amber-200", children: [
565
- /* @__PURE__ */ t(ne, { className: "h-3 w-3 animate-spin motion-reduce:animate-none", "aria-hidden": !0 }),
566
- y === "loading" ? "Counting records…" : "Recounting — showing the last count"
564
+ (v === "loading" || v === "updating") && /* @__PURE__ */ n("span", { className: "mt-0.5 inline-flex shrink-0 items-center gap-1 text-[11px] text-amber-900 dark:text-amber-200", children: [
565
+ /* @__PURE__ */ t(le, { className: "h-3 w-3 animate-spin motion-reduce:animate-none", "aria-hidden": !0 }),
566
+ v === "loading" ? "Counting records…" : "Recounting — showing the last count"
567
567
  ] })
568
568
  ] }),
569
- w.length > 0 && /* @__PURE__ */ a(
569
+ N.length > 0 && /* @__PURE__ */ n(
570
570
  "p",
571
571
  {
572
572
  className: T(
573
573
  "mx-3 mt-2 flex items-start gap-1.5 font-semibold text-red-700 dark:text-red-300",
574
- O
574
+ m
575
575
  ),
576
576
  "data-scope-blind": !0,
577
577
  children: [
578
- /* @__PURE__ */ t(xe, { className: "mt-px h-3.5 w-3.5 shrink-0", "aria-hidden": !0 }),
578
+ /* @__PURE__ */ t(ve, { className: "mt-px h-3.5 w-3.5 shrink-0", "aria-hidden": !0 }),
579
579
  "They would see nothing in ",
580
- ee(w.map((x) => x.label ?? re(x.collection))),
580
+ ne(N.map((x) => x.label ?? ie(x.collection))),
581
581
  "."
582
582
  ]
583
583
  }
584
584
  ),
585
- y === "error" ? /* @__PURE__ */ t("div", { className: "mx-3 mt-2 text-amber-900 dark:text-amber-200", children: /* @__PURE__ */ a("p", { children: [
585
+ v === "error" ? /* @__PURE__ */ t("div", { className: "mx-3 mt-2 text-amber-900 dark:text-amber-200", children: /* @__PURE__ */ n("p", { children: [
586
586
  "Couldn’t count what changes. Count again, or check the ",
587
- pe(c),
587
+ ge(f),
588
588
  " above before applying."
589
- ] }) }) : s.length > 0 ? /* @__PURE__ */ t(
589
+ ] }) }) : o.length > 0 ? /* @__PURE__ */ t(
590
590
  "ul",
591
591
  {
592
592
  className: T(
593
593
  "mx-3 mt-2 w-fit max-w-[calc(100%-1.5rem)] border-t border-amber-200 dark:border-amber-500/20",
594
- O
594
+ m
595
595
  ),
596
- "aria-busy": y === "updating",
597
- children: s.map((x) => /* @__PURE__ */ t(We, { row: x }, x.collection))
596
+ "aria-busy": v === "updating",
597
+ children: o.map((x) => /* @__PURE__ */ t(Xe, { row: x }, x.collection))
598
598
  }
599
- ) : y === "loading" ? /* @__PURE__ */ t("div", { className: "mx-3 mt-2 space-y-1.5", "aria-hidden": !0, children: [0, 1, 2].map((x) => /* @__PURE__ */ t("div", { className: "h-4 max-w-md rounded bg-amber-200/60 dark:bg-amber-400/10" }, x)) }) : /* @__PURE__ */ a("p", { className: "mx-3 mt-2", children: [
599
+ ) : v === "loading" ? /* @__PURE__ */ t("div", { className: "mx-3 mt-2 space-y-1.5", "aria-hidden": !0, children: [0, 1, 2].map((x) => /* @__PURE__ */ t("div", { className: "h-4 max-w-md rounded bg-amber-200/60 dark:bg-amber-400/10" }, x)) }) : /* @__PURE__ */ n("p", { className: "mx-3 mt-2", children: [
600
600
  "No records route to ",
601
- pe(c),
601
+ ge(f),
602
602
  ", so nothing they see changes."
603
603
  ] }),
604
- (((j = N == null ? void 0 : N.partial) == null ? void 0 : j.length) ?? 0) > 0 && /* @__PURE__ */ a("p", { className: "mx-3 mt-1.5 text-[11px] text-amber-900 dark:text-amber-200", children: [
604
+ (((U = y == null ? void 0 : y.partial) == null ? void 0 : U.length) ?? 0) > 0 && /* @__PURE__ */ n("p", { className: "mx-3 mt-1.5 text-[11px] text-amber-900 dark:text-amber-200", children: [
605
605
  "Not counted in time: ",
606
- (H = N == null ? void 0 : N.partial) == null ? void 0 : H.map((x) => x.label).join(", "),
606
+ (V = y == null ? void 0 : y.partial) == null ? void 0 : V.map((x) => x.label).join(", "),
607
607
  "."
608
608
  ] }),
609
- /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2 px-3 pb-2.5 pt-2.5", children: [
610
- y === "error" ? /* @__PURE__ */ a(I, { children: [
609
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2 px-3 pb-2.5 pt-2.5", children: [
610
+ v === "error" ? /* @__PURE__ */ n(z, { children: [
611
611
  /* @__PURE__ */ t(
612
612
  "button",
613
613
  {
614
614
  type: "button",
615
- onClick: p,
615
+ onClick: d,
616
616
  className: "inline-flex h-7 items-center rounded-md bg-amber-700 px-3 text-[11.5px] font-medium text-[#fff] hover:bg-amber-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50 focus-visible:ring-offset-1 dark:bg-amber-400 dark:text-[#1c1003] dark:hover:bg-amber-300",
617
617
  children: "Count again"
618
618
  }
@@ -622,21 +622,21 @@ function Ve({
622
622
  {
623
623
  type: "button",
624
624
  "data-scope-apply": !0,
625
- onClick: b,
625
+ onClick: h,
626
626
  className: "inline-flex h-7 items-center rounded-md border border-amber-400 px-3 text-[11.5px] font-medium text-amber-900 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40 dark:border-amber-500/50 dark:text-amber-200 dark:hover:bg-amber-400/10",
627
627
  children: "Apply without counts"
628
628
  }
629
629
  )
630
- ] }) : w.length > 0 && y === "ready" ? /* @__PURE__ */ t("span", { "data-scope-apply-danger": !0, children: /* @__PURE__ */ a(
631
- Y,
630
+ ] }) : N.length > 0 && v === "ready" ? /* @__PURE__ */ t("span", { "data-scope-apply-danger": !0, children: /* @__PURE__ */ n(
631
+ I,
632
632
  {
633
- onConfirm: b,
634
- confirmLabel: `Press again — ${G}`,
633
+ onConfirm: h,
634
+ confirmLabel: `Press again — ${K}`,
635
635
  className: "inline-flex h-7 items-center rounded-md bg-red-600 px-3 text-[11.5px] font-medium text-white hover:bg-red-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-500/50 focus-visible:ring-offset-1 dark:bg-red-700 dark:hover:bg-red-600",
636
636
  armedClassName: "bg-red-700 dark:bg-red-800",
637
637
  children: [
638
638
  "Apply — ",
639
- G
639
+ K
640
640
  ]
641
641
  }
642
642
  ) }) : /* @__PURE__ */ t(
@@ -645,16 +645,16 @@ function Ve({
645
645
  type: "button",
646
646
  "data-scope-apply": !0,
647
647
  disabled: !i,
648
- onClick: b,
648
+ onClick: h,
649
649
  className: "inline-flex h-7 items-center rounded-md bg-amber-700 px-3 text-[11.5px] font-medium text-[#fff] hover:bg-amber-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:bg-amber-700/45 dark:bg-amber-400 dark:text-[#1c1003] dark:hover:bg-amber-300 dark:disabled:bg-amber-400/40",
650
- children: S ? "Remove restriction" : "Apply restriction"
650
+ children: w ? "Remove restriction" : "Apply restriction"
651
651
  }
652
652
  ),
653
653
  /* @__PURE__ */ t(
654
654
  "button",
655
655
  {
656
656
  type: "button",
657
- onClick: h,
657
+ onClick: b,
658
658
  className: "inline-flex h-7 items-center rounded-md px-2 text-[11.5px] text-amber-900 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40 dark:text-amber-200 dark:hover:bg-amber-400/10",
659
659
  children: "Cancel"
660
660
  }
@@ -665,30 +665,30 @@ function Ve({
665
665
  }
666
666
  );
667
667
  }
668
- function he({ items: e }) {
669
- return /* @__PURE__ */ t(I, { children: e.map((n, d) => /* @__PURE__ */ a("span", { children: [
670
- d > 0 && ", ",
671
- /^\d+$/.test(n.label) ? /* @__PURE__ */ a("span", { className: "font-mono text-[10.5px]", children: [
668
+ function xe({ items: e }) {
669
+ return /* @__PURE__ */ t(z, { children: e.map((r, s) => /* @__PURE__ */ n("span", { children: [
670
+ s > 0 && ", ",
671
+ /^\d+$/.test(r.label) ? /* @__PURE__ */ n("span", { className: "font-mono text-[10.5px]", children: [
672
672
  "#",
673
- n.label
674
- ] }) : n.label
675
- ] }, n.id)) });
673
+ r.label
674
+ ] }) : r.label
675
+ ] }, r.id)) });
676
676
  }
677
- function We({ row: e }) {
678
- var h, p, k, l;
679
- const n = e.label ?? re(e.collection), d = e.gained ?? 0, i = e.lost ?? 0, o = e.proposed - e.current, b = (c, m) => c > m ? ` and ${B(c - m)} more` : "";
680
- return /* @__PURE__ */ a(
677
+ function Xe({ row: e }) {
678
+ var b, d, $, c;
679
+ const r = e.label ?? ie(e.collection), s = e.gained ?? 0, i = e.lost ?? 0, l = e.proposed - e.current, h = (f, u) => f > u ? ` and ${M(f - u)} more` : "";
680
+ return /* @__PURE__ */ n(
681
681
  "li",
682
682
  {
683
683
  className: "grid grid-cols-[minmax(9rem,16rem)_9.5rem_5.5rem] items-baseline justify-start gap-x-4 border-b border-amber-200 py-1.5 dark:border-amber-500/20",
684
684
  "data-scope-impact-row": e.collection,
685
685
  children: [
686
- /* @__PURE__ */ t("span", { className: "min-w-0 truncate font-medium", children: n }),
687
- /* @__PURE__ */ a("span", { className: "text-right tabular-nums", children: [
688
- e.proposed === 0 && e.total > 0 ? /* @__PURE__ */ t("span", { className: "font-semibold text-red-700 dark:text-red-300", children: "none" }) : B(e.proposed),
689
- /* @__PURE__ */ a("span", { className: "text-amber-900 dark:text-amber-200", children: [
686
+ /* @__PURE__ */ t("span", { className: "min-w-0 truncate font-medium", children: r }),
687
+ /* @__PURE__ */ n("span", { className: "text-right tabular-nums", children: [
688
+ e.proposed === 0 && e.total > 0 ? /* @__PURE__ */ t("span", { className: "font-semibold text-red-700 dark:text-red-300", children: "none" }) : M(e.proposed),
689
+ /* @__PURE__ */ n("span", { className: "text-amber-900 dark:text-amber-200", children: [
690
690
  " of ",
691
- B(e.total)
691
+ M(e.total)
692
692
  ] })
693
693
  ] }),
694
694
  /* @__PURE__ */ t(
@@ -696,32 +696,32 @@ function We({ row: e }) {
696
696
  {
697
697
  className: T(
698
698
  "text-right text-[11.5px] tabular-nums",
699
- o > 0 ? "font-semibold text-emerald-700 dark:text-emerald-400" : o < 0 ? "font-semibold text-red-700 dark:text-red-400" : "text-amber-900 dark:text-amber-200"
699
+ l > 0 ? "font-semibold text-emerald-700 dark:text-emerald-400" : l < 0 ? "font-semibold text-red-700 dark:text-red-400" : "text-amber-900 dark:text-amber-200"
700
700
  ),
701
- children: o > 0 ? `+${B(o)}` : o < 0 ? `−${B(-o)}` : "no change"
701
+ children: l > 0 ? `+${M(l)}` : l < 0 ? `−${M(-l)}` : "no change"
702
702
  }
703
703
  ),
704
- d > 0 && (((h = e.gained_sample) == null ? void 0 : h.length) ?? 0) > 0 && /* @__PURE__ */ a(
704
+ s > 0 && (((b = e.gained_sample) == null ? void 0 : b.length) ?? 0) > 0 && /* @__PURE__ */ n(
705
705
  "p",
706
706
  {
707
707
  className: "col-span-3 mt-0.5 truncate text-[11px] text-amber-900 dark:text-amber-200",
708
- "data-scope-impact-gained": d,
708
+ "data-scope-impact-gained": s,
709
709
  children: [
710
710
  "Newly visible: ",
711
- /* @__PURE__ */ t(he, { items: e.gained_sample ?? [] }),
712
- b(d, ((p = e.gained_sample) == null ? void 0 : p.length) ?? 0)
711
+ /* @__PURE__ */ t(xe, { items: e.gained_sample ?? [] }),
712
+ h(s, ((d = e.gained_sample) == null ? void 0 : d.length) ?? 0)
713
713
  ]
714
714
  }
715
715
  ),
716
- i > 0 && (((k = e.lost_sample) == null ? void 0 : k.length) ?? 0) > 0 && /* @__PURE__ */ a(
716
+ i > 0 && ((($ = e.lost_sample) == null ? void 0 : $.length) ?? 0) > 0 && /* @__PURE__ */ n(
717
717
  "p",
718
718
  {
719
719
  className: "col-span-3 mt-0.5 truncate text-[11px] text-amber-900 dark:text-amber-200",
720
720
  "data-scope-impact-lost": i,
721
721
  children: [
722
722
  "No longer visible: ",
723
- /* @__PURE__ */ t(he, { items: e.lost_sample ?? [] }),
724
- b(i, ((l = e.lost_sample) == null ? void 0 : l.length) ?? 0)
723
+ /* @__PURE__ */ t(xe, { items: e.lost_sample ?? [] }),
724
+ h(i, ((c = e.lost_sample) == null ? void 0 : c.length) ?? 0)
725
725
  ]
726
726
  }
727
727
  )
@@ -729,7 +729,7 @@ function We({ row: e }) {
729
729
  }
730
730
  );
731
731
  }
732
- const Xe = [
732
+ const Ze = [
733
733
  { key: "first_name", label: "First name" },
734
734
  { key: "last_name", label: "Last name" },
735
735
  { key: "title", label: "Title" },
@@ -743,87 +743,87 @@ const Xe = [
743
743
  { key: "employee_id", label: "Employee id" },
744
744
  { key: "preferred_language", label: "Language" }
745
745
  ];
746
- function kt({ profile: e }) {
747
- var $, R, N, y;
748
- const n = F(), d = ae(), i = ie(e.id), o = K({
746
+ function Ct({ profile: e }) {
747
+ var _, R, y, v;
748
+ const r = Q(), s = oe(), i = ce(e.id), l = E({
749
749
  queryKey: ["nvr-directory-status"],
750
- queryFn: () => n.request(P("/directory/status")).then((s) => s.data),
750
+ queryFn: () => r.request(O("/directory/status")).then((o) => o.data),
751
751
  staleTime: 5 * 6e4
752
- }), b = K({
752
+ }), h = E({
753
753
  queryKey: ["nvr-directory-entry", e.email],
754
- queryFn: () => n.request(P(`/directory/users/${encodeURIComponent(e.email)}`)).then((s) => s.data).catch((s) => {
755
- if ((s == null ? void 0 : s.status) === 404) return null;
756
- throw s;
754
+ queryFn: () => r.request(O(`/directory/users/${encodeURIComponent(e.email)}`)).then((o) => o.data).catch((o) => {
755
+ if ((o == null ? void 0 : o.status) === 404) return null;
756
+ throw o;
757
757
  }),
758
- enabled: !!(($ = o.data) != null && $.granted && e.email),
758
+ enabled: !!((_ = l.data) != null && _.granted && e.email),
759
759
  staleTime: 6e4
760
- }), h = Q({
761
- mutationFn: () => n.request(se(`/directory/sync/${e.id}`)).then((s) => s.data),
762
- onSuccess: ({ summary: s }) => {
763
- i(), d.invalidateQueries({ queryKey: ["nvr-directory-entry", e.email] }), s.active > 0 ? A.success("Still with the company — profile synced from the directory") : A.warning(
764
- `${s.missing > 0 ? "Not in the directory" : "Disabled in Azure"}${s.suspended > 0 ? " — suspended" : ""}`
760
+ }), b = j({
761
+ mutationFn: () => r.request(H(`/directory/sync/${e.id}`)).then((o) => o.data),
762
+ onSuccess: ({ summary: o }) => {
763
+ i(), s.invalidateQueries({ queryKey: ["nvr-directory-entry", e.email] }), o.active > 0 ? F.success("Still with the company — profile synced from the directory") : F.warning(
764
+ `${o.missing > 0 ? "Not in the directory" : "Disabled in Azure"}${o.suspended > 0 ? " — suspended" : ""}`
765
765
  );
766
766
  },
767
- onError: (s) => A.error(z(s, "Directory sync failed"))
767
+ onError: (o) => F.error(J(o, "Directory sync failed"))
768
768
  });
769
- if (o.isLoading || !((R = o.data) != null && R.configured)) return null;
770
- const p = e, k = (s) => {
771
- var w;
772
- return p[s] ?? ((w = e.admin) == null ? void 0 : w[s]) ?? null;
773
- }, l = b.data, c = ((N = e.admin) == null ? void 0 : N.directory_status) ?? null, m = c === "active" ? "border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-400/30 dark:bg-emerald-400/10 dark:text-emerald-200" : c === "disabled" || c === "missing" ? "border-red-200 bg-red-50 text-red-800 dark:border-red-400/30 dark:bg-red-400/10 dark:text-red-200" : "border-slate-200 bg-slate-50 text-slate-600 dark:border-border dark:bg-muted dark:text-muted-foreground", q = c === "active" ? "Still with the company" : c === "disabled" ? "Account disabled in Azure — no longer with the company" : c === "missing" ? "Not in the Microsoft directory — no longer with the company" : "Not checked against the directory yet";
774
- return /* @__PURE__ */ a(
775
- J,
769
+ if (l.isLoading || !((R = l.data) != null && R.configured)) return null;
770
+ const d = e, $ = (o) => {
771
+ var N;
772
+ return d[o] ?? ((N = e.admin) == null ? void 0 : N[o]) ?? null;
773
+ }, c = h.data, f = ((y = e.admin) == null ? void 0 : y.directory_status) ?? null, u = f === "active" ? "border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-400/30 dark:bg-emerald-400/10 dark:text-emerald-200" : f === "disabled" || f === "missing" ? "border-red-200 bg-red-50 text-red-800 dark:border-red-400/30 dark:bg-red-400/10 dark:text-red-200" : "border-slate-200 bg-slate-50 text-slate-600 dark:border-border dark:bg-muted dark:text-muted-foreground", D = f === "active" ? "Still with the company" : f === "disabled" ? "Account disabled in Azure — no longer with the company" : f === "missing" ? "Not in the Microsoft directory — no longer with the company" : "Not checked against the directory yet";
774
+ return /* @__PURE__ */ n(
775
+ Y,
776
776
  {
777
- icon: /* @__PURE__ */ t(qe, { className: "h-4 w-4" }),
777
+ icon: /* @__PURE__ */ t(Ae, { className: "h-4 w-4" }),
778
778
  title: "Microsoft directory",
779
779
  hint: "Pulling writes every field the directory has a value for; blanks never clear",
780
780
  testId: "directory",
781
- actions: o.data.granted && /* @__PURE__ */ a(
781
+ actions: l.data.granted && /* @__PURE__ */ n(
782
782
  "button",
783
783
  {
784
784
  type: "button",
785
- onClick: () => h.mutate(),
786
- disabled: h.isPending,
785
+ onClick: () => b.mutate(),
786
+ disabled: b.isPending,
787
787
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
788
788
  children: [
789
- /* @__PURE__ */ t(te, { className: T("h-3 w-3", h.isPending && "animate-spin") }),
790
- h.isPending ? "Checking…" : "Sync from directory"
789
+ /* @__PURE__ */ t(ae, { className: T("h-3 w-3", b.isPending && "animate-spin") }),
790
+ b.isPending ? "Checking…" : "Sync from directory"
791
791
  ]
792
792
  }
793
793
  ),
794
794
  children: [
795
- /* @__PURE__ */ a(
795
+ /* @__PURE__ */ n(
796
796
  "div",
797
797
  {
798
- className: T("rounded-md border px-3 py-2 text-[12.5px]", m),
799
- "data-directory-verdict": c ?? "unchecked",
798
+ className: T("rounded-md border px-3 py-2 text-[12.5px]", u),
799
+ "data-directory-verdict": f ?? "unchecked",
800
800
  children: [
801
- /* @__PURE__ */ t("span", { className: "font-medium", children: q }),
802
- ((y = e.admin) == null ? void 0 : y.directory_checked_at) && /* @__PURE__ */ a("span", { className: "ml-2 text-[11px] opacity-70", children: [
801
+ /* @__PURE__ */ t("span", { className: "font-medium", children: D }),
802
+ ((v = e.admin) == null ? void 0 : v.directory_checked_at) && /* @__PURE__ */ n("span", { className: "ml-2 text-[11px] opacity-70", children: [
803
803
  "checked ",
804
- Be(e.admin.directory_checked_at)
804
+ ze(e.admin.directory_checked_at)
805
805
  ] }),
806
- (c === "disabled" || c === "missing") && /* @__PURE__ */ t("p", { className: "mt-0.5 text-[11.5px] opacity-80", children: "Hand off what they still own under Admin tools. Redaction stays a separate step." })
806
+ (f === "disabled" || f === "missing") && /* @__PURE__ */ t("p", { className: "mt-0.5 text-[11.5px] opacity-80", children: "Hand off what they still own under Admin tools. Redaction stays a separate step." })
807
807
  ]
808
808
  }
809
809
  ),
810
- o.data.granted ? b.isLoading ? /* @__PURE__ */ t("p", { className: "mt-3 text-[12px] text-slate-400", children: "Looking up the directory…" }) : b.isError ? /* @__PURE__ */ t("p", { className: "mt-3 text-[12px] text-red-600 dark:text-red-400", children: z(b.error, "The directory lookup failed.") }) : l ? /* @__PURE__ */ a("div", { className: "mt-3 space-y-3", children: [
811
- /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2 text-[12px]", children: [
812
- /* @__PURE__ */ t("span", { className: "font-medium text-slate-800 dark:text-foreground", children: l.display_name ?? `${l.first_name ?? ""} ${l.last_name ?? ""}`.trim() }),
813
- l.upn && l.upn.toLowerCase() !== e.email.toLowerCase() && /* @__PURE__ */ a("span", { className: "text-slate-400", children: [
810
+ l.data.granted ? h.isLoading ? /* @__PURE__ */ t("p", { className: "mt-3 text-[12px] text-slate-400", children: "Looking up the directory…" }) : h.isError ? /* @__PURE__ */ t("p", { className: "mt-3 text-[12px] text-red-600 dark:text-red-400", children: J(h.error, "The directory lookup failed.") }) : c ? /* @__PURE__ */ n("div", { className: "mt-3 space-y-3", children: [
811
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2 text-[12px]", children: [
812
+ /* @__PURE__ */ t("span", { className: "font-medium text-slate-800 dark:text-foreground", children: c.display_name ?? `${c.first_name ?? ""} ${c.last_name ?? ""}`.trim() }),
813
+ c.upn && c.upn.toLowerCase() !== e.email.toLowerCase() && /* @__PURE__ */ n("span", { className: "text-slate-400", children: [
814
814
  "UPN ",
815
- l.upn
815
+ c.upn
816
816
  ] }),
817
- l.account_enabled === !1 && /* @__PURE__ */ t("span", { className: "rounded-full bg-red-50 px-2 py-0.5 text-[11px] font-medium text-red-700 dark:bg-red-400/10 dark:text-red-300", children: "Disabled in Azure" }),
818
- l.manager && /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: [
817
+ c.account_enabled === !1 && /* @__PURE__ */ t("span", { className: "rounded-full bg-red-50 px-2 py-0.5 text-[11px] font-medium text-red-700 dark:bg-red-400/10 dark:text-red-300", children: "Disabled in Azure" }),
818
+ c.manager && /* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: [
819
819
  "Reports to",
820
820
  " ",
821
- /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-foreground", children: l.manager.display_name ?? l.manager.email })
821
+ /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-foreground", children: c.manager.display_name ?? c.manager.email })
822
822
  ] })
823
823
  ] }),
824
- /* @__PURE__ */ t("dl", { className: "grid gap-px overflow-hidden rounded-lg border border-slate-200 bg-slate-200 dark:border-border dark:bg-border sm:grid-cols-2 lg:grid-cols-3", children: Xe.filter((s) => s.key in l).map((s) => {
825
- const w = l[s.key] ?? null, S = k(s.key), C = !!w && w !== S;
826
- return /* @__PURE__ */ a(
824
+ /* @__PURE__ */ t("dl", { className: "grid gap-px overflow-hidden rounded-lg border border-slate-200 bg-slate-200 dark:border-border dark:bg-border sm:grid-cols-2 lg:grid-cols-3", children: Ze.filter((o) => o.key in c).map((o) => {
825
+ const N = c[o.key] ?? null, w = $(o.key), C = !!N && N !== w;
826
+ return /* @__PURE__ */ n(
827
827
  "div",
828
828
  {
829
829
  className: T(
@@ -831,62 +831,62 @@ function kt({ profile: e }) {
831
831
  C && "bg-amber-50/60 dark:bg-amber-400/10"
832
832
  ),
833
833
  children: [
834
- /* @__PURE__ */ t("dt", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: s.label }),
835
- /* @__PURE__ */ t("dd", { className: "mt-0.5 text-[12.5px] text-slate-800 dark:text-foreground", children: w ?? /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) }),
836
- C && /* @__PURE__ */ a("dd", { className: "text-[11px] text-slate-400", children: [
834
+ /* @__PURE__ */ t("dt", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: o.label }),
835
+ /* @__PURE__ */ t("dd", { className: "mt-0.5 text-[12.5px] text-slate-800 dark:text-foreground", children: N ?? /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) }),
836
+ C && /* @__PURE__ */ n("dd", { className: "text-[11px] text-slate-400", children: [
837
837
  "stored: ",
838
- S ?? /* @__PURE__ */ t("span", { className: "italic", children: "empty" })
838
+ w ?? /* @__PURE__ */ t("span", { className: "italic", children: "empty" })
839
839
  ] })
840
840
  ]
841
841
  },
842
- s.key
842
+ o.key
843
843
  );
844
844
  }) })
845
- ] }) : /* @__PURE__ */ a("p", { className: "mt-3 text-[12px] text-slate-500 dark:text-muted-foreground", children: [
845
+ ] }) : /* @__PURE__ */ n("p", { className: "mt-3 text-[12px] text-slate-500 dark:text-muted-foreground", children: [
846
846
  "No directory entry matches ",
847
847
  e.email,
848
848
  "."
849
- ] }) : /* @__PURE__ */ a("div", { className: "mt-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] text-amber-900 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-200", children: [
849
+ ] }) : /* @__PURE__ */ n("div", { className: "mt-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] text-amber-900 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-200", children: [
850
850
  /* @__PURE__ */ t("p", { className: "font-medium", children: "Directory access is not granted yet." }),
851
- /* @__PURE__ */ t("p", { className: "mt-0.5", children: o.data.reason ?? "The app token cannot read other users. Grant User.Read.All as an application permission with admin consent." })
851
+ /* @__PURE__ */ t("p", { className: "mt-0.5", children: l.data.reason ?? "The app token cannot read other users. Grant User.Read.All as an application permission with admin consent." })
852
852
  ] })
853
853
  ]
854
854
  }
855
855
  );
856
856
  }
857
- function Nt({ profile: e }) {
858
- var c;
859
- const n = F(), d = ie(e.id), [i, o] = E(null), [b, h] = E(!1), p = Q({
860
- mutationFn: () => n.request(se(`/users/${e.id}/token`)).then((m) => m.data.token),
861
- onSuccess: (m) => {
862
- o(m), h(!0), d(), A.success("Token generated — copy it now, it is shown once");
857
+ function _t({ profile: e }) {
858
+ var f;
859
+ const r = Q(), s = ce(e.id), [i, l] = P(null), [h, b] = P(!1), d = j({
860
+ mutationFn: () => r.request(H(`/users/${e.id}/token`)).then((u) => u.data.token),
861
+ onSuccess: (u) => {
862
+ l(u), b(!0), s(), F.success("Token generated — copy it now, it is shown once");
863
863
  },
864
- onError: (m) => A.error(z(m, "Could not generate a token"))
865
- }), k = Q({
866
- mutationFn: () => n.request(ye(`/users/${e.id}/token`)),
864
+ onError: (u) => F.error(J(u, "Could not generate a token"))
865
+ }), $ = j({
866
+ mutationFn: () => r.request(Ne(`/users/${e.id}/token`)),
867
867
  onSuccess: () => {
868
- o(null), h(!1), d(), A.success("Token revoked");
868
+ l(null), b(!1), s(), F.success("Token revoked");
869
869
  },
870
- onError: (m) => A.error(z(m, "Could not revoke the token"))
871
- }), l = !!((c = e.admin) != null && c.has_static_token) || !!i;
870
+ onError: (u) => F.error(J(u, "Could not revoke the token"))
871
+ }), c = !!((f = e.admin) != null && f.has_static_token) || !!i;
872
872
  return /* @__PURE__ */ t(
873
- J,
873
+ Y,
874
874
  {
875
- icon: /* @__PURE__ */ t(Ee, { className: "h-4 w-4" }),
875
+ icon: /* @__PURE__ */ t(Pe, { className: "h-4 w-4" }),
876
876
  title: "API token",
877
877
  hint: "Static bearer token for scripts and the SDK",
878
878
  testId: "api-token",
879
- children: l ? /* @__PURE__ */ a("div", { className: "space-y-3", children: [
880
- i ? /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
881
- /* @__PURE__ */ t("code", { className: "flex-1 break-all rounded-md border border-slate-200 bg-slate-50 px-3 py-2 font-mono text-[12px] text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-200", children: b ? i : "•".repeat(24) }),
879
+ children: c ? /* @__PURE__ */ n("div", { className: "space-y-3", children: [
880
+ i ? /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
881
+ /* @__PURE__ */ t("code", { className: "flex-1 break-all rounded-md border border-slate-200 bg-slate-50 px-3 py-2 font-mono text-[12px] text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-200", children: h ? i : "•".repeat(24) }),
882
882
  /* @__PURE__ */ t(
883
883
  "button",
884
884
  {
885
885
  type: "button",
886
- onClick: () => h((m) => !m),
887
- "aria-label": b ? "Hide token" : "Reveal token",
886
+ onClick: () => b((u) => !u),
887
+ "aria-label": h ? "Hide token" : "Reveal token",
888
888
  className: "rounded-md border border-slate-200 p-2 text-slate-500 hover:bg-slate-50 dark:border-border dark:hover:bg-muted",
889
- children: b ? /* @__PURE__ */ t(Le, { className: "h-4 w-4" }) : /* @__PURE__ */ t(Te, { className: "h-4 w-4" })
889
+ children: h ? /* @__PURE__ */ t(Te, { className: "h-4 w-4" }) : /* @__PURE__ */ t(De, { className: "h-4 w-4" })
890
890
  }
891
891
  ),
892
892
  /* @__PURE__ */ t(
@@ -894,56 +894,56 @@ function Nt({ profile: e }) {
894
894
  {
895
895
  type: "button",
896
896
  onClick: () => {
897
- navigator.clipboard.writeText(i), A.success("Copied");
897
+ navigator.clipboard.writeText(i), F.success("Copied");
898
898
  },
899
899
  "aria-label": "Copy token",
900
900
  className: "rounded-md border border-slate-200 p-2 text-slate-500 hover:bg-slate-50 dark:border-border dark:hover:bg-muted",
901
- children: /* @__PURE__ */ t(Ae, { className: "h-4 w-4" })
901
+ children: /* @__PURE__ */ t(Fe, { className: "h-4 w-4" })
902
902
  }
903
903
  )
904
904
  ] }) : /* @__PURE__ */ t("p", { className: "text-[12.5px] text-slate-600 dark:text-slate-300", children: "A token is set. The value is never shown again — regenerate to issue a new one." }),
905
- /* @__PURE__ */ a("div", { className: "flex gap-2", children: [
906
- /* @__PURE__ */ a(
907
- Y,
905
+ /* @__PURE__ */ n("div", { className: "flex gap-2", children: [
906
+ /* @__PURE__ */ n(
907
+ I,
908
908
  {
909
- onConfirm: () => p.mutate(),
910
- disabled: p.isPending,
909
+ onConfirm: () => d.mutate(),
910
+ disabled: d.isPending,
911
911
  confirmLabel: "Replace the current token?",
912
912
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
913
913
  armedClassName: "border-amber-300 text-amber-700 dark:text-amber-300",
914
914
  children: [
915
- /* @__PURE__ */ t(te, { className: "h-3 w-3" }),
915
+ /* @__PURE__ */ t(ae, { className: "h-3 w-3" }),
916
916
  " Regenerate"
917
917
  ]
918
918
  }
919
919
  ),
920
- /* @__PURE__ */ a(
921
- Y,
920
+ /* @__PURE__ */ n(
921
+ I,
922
922
  {
923
- onConfirm: () => k.mutate(),
924
- disabled: k.isPending,
923
+ onConfirm: () => $.mutate(),
924
+ disabled: $.isPending,
925
925
  confirmLabel: "Revoke — scripts using it stop working?",
926
926
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-red-600 transition-colors hover:bg-red-50 disabled:opacity-50 dark:border-border dark:text-red-400 dark:hover:bg-red-500/10",
927
927
  armedClassName: "border-red-300",
928
928
  children: [
929
- /* @__PURE__ */ t(De, { className: "h-3 w-3" }),
929
+ /* @__PURE__ */ t(Ke, { className: "h-3 w-3" }),
930
930
  " Revoke"
931
931
  ]
932
932
  }
933
933
  )
934
934
  ] })
935
- ] }) : /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-3", children: [
936
- /* @__PURE__ */ t(ke, { children: "No token issued." }),
937
- /* @__PURE__ */ a(
935
+ ] }) : /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-3", children: [
936
+ /* @__PURE__ */ t(we, { children: "No token issued." }),
937
+ /* @__PURE__ */ n(
938
938
  "button",
939
939
  {
940
940
  type: "button",
941
- onClick: () => p.mutate(),
942
- disabled: p.isPending,
941
+ onClick: () => d.mutate(),
942
+ disabled: d.isPending,
943
943
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
944
944
  children: [
945
- /* @__PURE__ */ t(te, { className: T("h-3 w-3", p.isPending && "animate-spin") }),
946
- p.isPending ? "Generating…" : "Generate token"
945
+ /* @__PURE__ */ t(ae, { className: T("h-3 w-3", d.isPending && "animate-spin") }),
946
+ d.isPending ? "Generating…" : "Generate token"
947
947
  ]
948
948
  }
949
949
  )
@@ -951,112 +951,214 @@ function Nt({ profile: e }) {
951
951
  }
952
952
  );
953
953
  }
954
- function Ye(e) {
954
+ function et(e, r, s) {
955
+ const i = `${M(r)} ${e ? "other " : ""}browser${r === 1 ? "" : "s"}`, l = s > 0 ? ` and ${M(s)} phone${s === 1 ? "" : "s"}` : "";
956
+ return `Sign out ${e ? "" : "all "}${i}${l}?`;
957
+ }
958
+ function tt(e) {
959
+ const r = new Date(e);
960
+ if (Number.isNaN(r.getTime())) return Ge(e);
961
+ const s = r.getFullYear() === (/* @__PURE__ */ new Date()).getFullYear();
962
+ return r.toLocaleString(void 0, {
963
+ month: "short",
964
+ day: "numeric",
965
+ ...s ? {} : { year: "numeric" },
966
+ hour: "numeric",
967
+ minute: "2-digit"
968
+ });
969
+ }
970
+ const ee = 6, te = (e) => !!(e.device || e.ip || e.signed_in_at);
971
+ function rt(e) {
972
+ const r = (s) => s.signed_in_at && Date.parse(s.signed_in_at) || 0;
973
+ return [...e].sort(
974
+ (s, i) => +!!i.current - +!!s.current || Number(te(i)) - Number(te(s)) || r(i) - r(s) || i.ttl_seconds - s.ttl_seconds
975
+ );
976
+ }
977
+ function nt(e) {
955
978
  if (!Number.isFinite(e) || e <= 0) return "Ending now";
956
979
  if (e < 3600) return `Ends in ${Math.max(1, Math.round(e / 60))} min`;
957
- const n = Math.round(e / 3600);
958
- return n >= 48 ? `Ends in ${Math.round(n / 24)} days` : `Ends in ${n}h`;
980
+ const r = Math.round(e / 3600);
981
+ return r >= 48 ? `Ends in ${Math.round(r / 24)} days` : `Ends in ${r}h`;
959
982
  }
960
- function wt({ userId: e }) {
961
- const n = F(), d = ae(), i = ["nvr-user-sessions", e], o = K({
983
+ function qt({ userId: e }) {
984
+ const r = Q(), s = oe(), i = ["nvr-user-sessions", e], l = E({
962
985
  queryKey: i,
963
- queryFn: () => n.request(P("/security/sessions", { user_id: e })).then((c) => c.data ?? []),
986
+ queryFn: () => r.request(O("/security/sessions", { user_id: e })).then((m) => m.data ?? []),
964
987
  staleTime: 3e4
965
- }), b = e.toUpperCase();
966
- Qe(
988
+ }), h = e.toUpperCase();
989
+ Ue(
967
990
  "sessions",
968
991
  () => {
969
- d.invalidateQueries({ queryKey: ["nvr-user-sessions", e] }), d.invalidateQueries({ queryKey: ["nvr-signed-in-devices", e] });
992
+ s.invalidateQueries({ queryKey: ["nvr-user-sessions", e] }), s.invalidateQueries({ queryKey: ["nvr-signed-in-devices", e] });
970
993
  },
971
994
  {
972
995
  debounceMs: 800,
973
- match: (c) => c.all === !0 || String(c.user_id ?? "").toUpperCase() === b
996
+ match: (m) => m.all === !0 || String(m.user_id ?? "").toUpperCase() === h
974
997
  }
975
998
  );
976
- const h = Q({
977
- mutationFn: (c) => n.request(ye(`/security/sessions/${c}`)),
978
- onSuccess: (c, m) => {
979
- d.setQueryData(i, (q) => q == null ? void 0 : q.filter(($) => $.sid_prefix !== m)), A.success("That browser is signed out");
999
+ const b = j({
1000
+ mutationFn: (m) => r.request(Ne(`/security/sessions/${m}`)),
1001
+ onSuccess: (m, A) => {
1002
+ s.setQueryData(i, (K) => K == null ? void 0 : K.filter((U) => U.sid_prefix !== A)), F.success("That browser is signed out");
1003
+ },
1004
+ onError: (m) => se(m, "Could not sign that browser out")
1005
+ }), d = de(() => rt(l.data ?? []), [l.data]), $ = je(d.map((m) => m.sid_prefix)), { quiet: c } = Be(), [f, u] = P(!1), D = d.filter((m) => !m.current && !te(m)), _ = D.length >= 3 ? d.filter((m) => m.current || te(m)) : d, R = f ? d : _.slice(0, ee), y = d.length - R.length, v = y > 0 && y === D.length && _.length <= ee, o = d.some((m) => m.current), N = d.filter((m) => !m.current), w = j({
1006
+ mutationFn: () => r.request(
1007
+ o ? H("/security/my/sessions/sign-out-others", {}) : H(`/security/users/${encodeURIComponent(e)}/sign-out`, {})
1008
+ ),
1009
+ onSuccess: (m) => {
1010
+ var K;
1011
+ s.invalidateQueries({ queryKey: i }), s.invalidateQueries({ queryKey: ["nvr-signed-in-devices", e] });
1012
+ const A = ((K = m == null ? void 0 : m.data) == null ? void 0 : K.revoked) ?? 0;
1013
+ F.success(A === 1 ? "1 sign-in ended" : `${M(A)} sign-ins ended`);
980
1014
  },
981
- onError: (c) => ve(c, "Could not sign that browser out")
982
- }), p = o.data ?? [], k = je(p.map((c) => c.sid_prefix)), { quiet: l } = Ue();
1015
+ onError: (m) => se(m, "Could not sign those out")
1016
+ }), C = o ? "Sign out everywhere else" : "Sign out everywhere", L = (E({
1017
+ queryKey: ["nvr-signed-in-devices", e],
1018
+ queryFn: () => r.request(O(`/users/${e}/devices`)).then((m) => m.data ?? []),
1019
+ staleTime: 3e4
1020
+ }).data ?? []).filter((m) => !(o && m.current)).length;
983
1021
  return /* @__PURE__ */ t(
984
- J,
1022
+ Y,
985
1023
  {
986
- icon: /* @__PURE__ */ t(Re, { className: "h-4 w-4" }),
987
- title: o.isSuccess ? `Signed-in browsers · ${p.length}` : "Signed-in browsers",
1024
+ icon: /* @__PURE__ */ t(Le, { className: "h-4 w-4" }),
1025
+ title: l.isSuccess ? `Signed-in browsers · ${d.length}` : "Signed-in browsers",
988
1026
  hint: "Signing a browser out ends it on its next request",
989
1027
  testId: "sessions",
990
- children: o.isLoading ? /* @__PURE__ */ a("div", { className: "space-y-3", "aria-hidden": !0, children: [
991
- /* @__PURE__ */ t(me, { className: "h-9 w-full" }),
992
- /* @__PURE__ */ t(me, { className: "h-9 w-2/3" })
993
- ] }) : o.isError ? /* @__PURE__ */ t(ze, { error: o.error, what: "signed-in browsers", onRetry: () => o.refetch() }) : p.length === 0 ? /* @__PURE__ */ t(ke, { children: "Not signed in on any browser." }) : /* @__PURE__ */ t("ul", { "data-sessions-list": !0, className: "-my-2 divide-y divide-slate-100 dark:divide-border/60", children: p.map((c) => /* @__PURE__ */ t(
994
- Ze,
995
- {
996
- session: c,
997
- fresh: !l && k.has(c.sid_prefix),
998
- pending: h.isPending && h.variables === c.sid_prefix,
999
- onRevoke: () => h.mutate(c.sid_prefix)
1000
- },
1001
- c.sid_prefix
1002
- )) })
1028
+ children: l.isLoading ? /* @__PURE__ */ n("div", { className: "space-y-3", "aria-hidden": !0, children: [
1029
+ /* @__PURE__ */ t(he, { className: "h-9 w-full" }),
1030
+ /* @__PURE__ */ t(he, { className: "h-9 w-2/3" })
1031
+ ] }) : l.isError ? /* @__PURE__ */ t(He, { error: l.error, what: "signed-in browsers", onRetry: () => l.refetch() }) : d.length === 0 ? /* @__PURE__ */ t(we, { children: "Not signed in on any browser." }) : /* @__PURE__ */ n(z, { children: [
1032
+ /* @__PURE__ */ t(
1033
+ "ul",
1034
+ {
1035
+ "data-sessions-list": !0,
1036
+ className: T(
1037
+ "-my-2 divide-y divide-slate-100 dark:divide-border/60",
1038
+ // A long list scrolls inside the card, so its count header stays in view.
1039
+ f && d.length > ee && "max-h-[26rem] overflow-y-auto pr-1"
1040
+ ),
1041
+ children: R.map((m) => /* @__PURE__ */ t(
1042
+ at,
1043
+ {
1044
+ session: m,
1045
+ fresh: !c && $.has(m.sid_prefix),
1046
+ pending: b.isPending && b.variables === m.sid_prefix || w.isPending && !m.current,
1047
+ onRevoke: () => b.mutate(m.sid_prefix)
1048
+ },
1049
+ m.sid_prefix
1050
+ ))
1051
+ }
1052
+ ),
1053
+ (y > 0 || f || N.length > 1) && /* @__PURE__ */ n(
1054
+ "div",
1055
+ {
1056
+ "data-sessions-foot": !0,
1057
+ className: "-mx-4 -mb-4 mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-slate-100 px-4 py-2.5 dark:border-border/60",
1058
+ children: [
1059
+ y > 0 ? /* @__PURE__ */ t(
1060
+ "button",
1061
+ {
1062
+ type: "button",
1063
+ "data-sessions-show-all": !0,
1064
+ onClick: () => u(!0),
1065
+ className: "min-w-0 rounded text-left text-[12px] font-medium text-slate-600 underline decoration-slate-300 underline-offset-2 hover:text-slate-900 hover:decoration-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:text-slate-300 dark:decoration-slate-600 dark:hover:text-slate-100",
1066
+ children: v ? `${y} older sign-in${y === 1 ? "" : "s"} with no browser details · Show` : `Show all ${d.length}`
1067
+ }
1068
+ ) : f && d.length > _.slice(0, ee).length ? /* @__PURE__ */ t(
1069
+ "button",
1070
+ {
1071
+ type: "button",
1072
+ onClick: () => u(!1),
1073
+ className: "rounded text-[12px] font-medium text-slate-600 underline decoration-slate-300 underline-offset-2 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:text-slate-300 dark:decoration-slate-600 dark:hover:text-slate-100",
1074
+ children: "Show fewer"
1075
+ }
1076
+ ) : null,
1077
+ N.length > 1 && /* @__PURE__ */ t("span", { className: "ml-auto", children: /* @__PURE__ */ n(
1078
+ I,
1079
+ {
1080
+ title: C,
1081
+ onConfirm: () => w.mutate(),
1082
+ confirmLabel: et(o, N.length, L),
1083
+ disabled: w.isPending,
1084
+ className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:border-red-300 hover:text-red-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:border-red-500/40 dark:hover:text-red-400",
1085
+ armedClassName: "border-red-300 font-semibold text-red-600 dark:border-red-500/40 dark:text-red-400",
1086
+ children: [
1087
+ /* @__PURE__ */ t(ke, { className: "h-3 w-3", "aria-hidden": !0 }),
1088
+ w.isPending ? "Signing out…" : C
1089
+ ]
1090
+ }
1091
+ ) })
1092
+ ]
1093
+ }
1094
+ )
1095
+ ] })
1003
1096
  }
1004
1097
  );
1005
1098
  }
1006
- function Ze({
1099
+ function at({
1007
1100
  session: e,
1008
- fresh: n,
1009
- pending: d,
1101
+ fresh: r,
1102
+ pending: s,
1010
1103
  onRevoke: i
1011
1104
  }) {
1012
- const o = e.device || "Browser", b = [
1105
+ const l = e.device || "Browser", h = [
1013
1106
  e.ip,
1014
- e.signed_in_at ? `Signed in ${Ie(e.signed_in_at)}` : "Signed in before this was recorded",
1015
- Ye(e.ttl_seconds)
1016
- ].filter(Boolean).join(" · "), h = ce(o), p = ce(b);
1017
- return /* @__PURE__ */ a(
1107
+ e.signed_in_at ? `Signed in ${tt(e.signed_in_at)}` : "Signed in before this was recorded",
1108
+ nt(e.ttl_seconds)
1109
+ ].filter((d) => !!d), b = Ie(l);
1110
+ return /* @__PURE__ */ n(
1018
1111
  "li",
1019
1112
  {
1020
1113
  "data-session-row": !0,
1021
- "data-fresh": n || void 0,
1114
+ "data-fresh": r || void 0,
1022
1115
  className: T(
1023
1116
  "-mx-2 flex items-center gap-3 rounded-md px-2 py-2.5 transition-colors duration-700 motion-reduce:transition-none",
1024
- n && "bg-nvr-cyan/10"
1117
+ r && "bg-nvr-cyan/10"
1025
1118
  ),
1026
1119
  children: [
1027
- /* @__PURE__ */ t("span", { className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-300", children: / on (iOS|Android)$/.test(o) ? /* @__PURE__ */ t(Ke, { className: "h-4 w-4", "aria-hidden": !0 }) : /* @__PURE__ */ t(Pe, { className: "h-4 w-4", "aria-hidden": !0 }) }),
1028
- /* @__PURE__ */ a("div", { className: "min-w-0 flex-1", children: [
1029
- /* @__PURE__ */ t(
1120
+ /* @__PURE__ */ t("span", { className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-300", children: / on (iOS|Android)$/.test(l) ? /* @__PURE__ */ t(Ee, { className: "h-4 w-4", "aria-hidden": !0 }) : /* @__PURE__ */ t(Oe, { className: "h-4 w-4", "aria-hidden": !0 }) }),
1121
+ /* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
1122
+ /* @__PURE__ */ n("p", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5", children: [
1123
+ /* @__PURE__ */ t(
1124
+ "span",
1125
+ {
1126
+ ref: b,
1127
+ "data-session-device": !0,
1128
+ className: "min-w-0 max-w-full truncate text-[12.5px] font-medium text-slate-800 dark:text-slate-100",
1129
+ children: l
1130
+ }
1131
+ ),
1132
+ e.current && /* @__PURE__ */ t(
1133
+ "span",
1134
+ {
1135
+ "data-session-current": !0,
1136
+ className: "shrink-0 rounded-full bg-nvr-cyan/10 px-1.5 py-px text-[10.5px] font-medium text-sky-700 dark:text-nvr-cyan",
1137
+ children: "This browser"
1138
+ }
1139
+ )
1140
+ ] }),
1141
+ /* @__PURE__ */ t("div", { "data-session-meta": !0, className: "mt-0.5 overflow-hidden", children: /* @__PURE__ */ t("p", { className: "-ml-3 flex flex-wrap text-[11.5px] leading-snug tabular-nums text-slate-500 dark:text-slate-400", children: h.map((d) => /* @__PURE__ */ t(
1030
1142
  "span",
1031
1143
  {
1032
- ref: h,
1033
- "data-session-device": !0,
1034
- className: "block truncate text-[12.5px] font-medium text-slate-800 dark:text-slate-100",
1035
- children: o
1036
- }
1037
- ),
1038
- /* @__PURE__ */ t(
1039
- "p",
1040
- {
1041
- ref: p,
1042
- "data-session-meta": !0,
1043
- className: "mt-0.5 truncate text-[11.5px] tabular-nums text-slate-500 dark:text-slate-400",
1044
- children: b
1045
- }
1046
- )
1144
+ className: "relative whitespace-nowrap pl-3 before:absolute before:left-[0.3rem] before:content-['·']",
1145
+ children: d
1146
+ },
1147
+ d
1148
+ )) }) })
1047
1149
  ] }),
1048
- /* @__PURE__ */ t("span", { "data-session-sign-out": !0, className: "contents", children: /* @__PURE__ */ a(
1049
- Y,
1150
+ /* @__PURE__ */ t("span", { "data-session-sign-out": !0, className: "contents", children: /* @__PURE__ */ n(
1151
+ I,
1050
1152
  {
1051
- title: `Sign out ${o}`,
1153
+ title: e.current ? "Sign out of this browser" : `Sign out ${l}`,
1052
1154
  onConfirm: i,
1053
- confirmLabel: "Sign it out?",
1054
- disabled: d,
1155
+ confirmLabel: e.current ? "Sign out here?" : "Sign it out?",
1156
+ disabled: s,
1055
1157
  className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:border-red-300 hover:text-red-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:border-red-500/40 dark:hover:text-red-400",
1056
1158
  armedClassName: "border-red-300 font-semibold text-red-600 dark:border-red-500/40 dark:text-red-400",
1057
1159
  children: [
1058
- /* @__PURE__ */ t(Fe, { className: "h-3 w-3", "aria-hidden": !0 }),
1059
- d ? "Signing out…" : "Sign out"
1160
+ /* @__PURE__ */ t(ke, { className: "h-3 w-3", "aria-hidden": !0 }),
1161
+ /* @__PURE__ */ t("span", { className: "sr-only sm:not-sr-only", children: s ? "Signing out…" : e.current ? "Sign out here" : "Sign out" })
1060
1162
  ]
1061
1163
  }
1062
1164
  ) })
@@ -1065,11 +1167,13 @@ function Ze({
1065
1167
  );
1066
1168
  }
1067
1169
  export {
1068
- ft as AccessCard,
1069
- Nt as ApiTokenCard,
1070
- wt as SessionsCard,
1071
- yt as SuspensionBanner,
1072
- kt as UserDirectoryCard,
1073
- vt as UserScopesCard,
1074
- Ye as sessionEndsIn
1170
+ wt as AccessCard,
1171
+ _t as ApiTokenCard,
1172
+ qt as SessionsCard,
1173
+ St as SuspensionBanner,
1174
+ Ct as UserDirectoryCard,
1175
+ $t as UserScopesCard,
1176
+ rt as orderSessions,
1177
+ nt as sessionEndsIn,
1178
+ et as signOutAllQuestion
1075
1179
  };