@nivaro/react 0.3.46 → 0.3.48

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 (57) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +248 -16
  4. package/dist/index.js +679 -659
  5. package/dist/shared/components/CollectionBrowserView.js +813 -826
  6. package/dist/shared/components/ErrorNotice.js +169 -0
  7. package/dist/shared/components/ErrorSurface.js +23 -17
  8. package/dist/shared/components/ListLoadError.js +8 -29
  9. package/dist/shared/components/LoadErrorNote.js +38 -21
  10. package/dist/shared/components/QueryErrorState.js +8 -11
  11. package/dist/shared/components/ReportView.js +1320 -1291
  12. package/dist/shared/components/chat/ChannelArchive.js +60 -60
  13. package/dist/shared/components/chat/ChannelExtras.js +74 -74
  14. package/dist/shared/components/chat/ChatPanel.js +368 -367
  15. package/dist/shared/components/command-center/PeekPanel.js +33 -32
  16. package/dist/shared/components/command-center/panels/BoardSettings.js +41 -40
  17. package/dist/shared/components/command-center/panels/PeoplePanel.js +32 -31
  18. package/dist/shared/components/help-videos/editor/ClipsPanel.js +49 -48
  19. package/dist/shared/components/help-videos/editor/PublishButton.js +37 -36
  20. package/dist/shared/components/help-videos/editor/StatsTab.js +45 -44
  21. package/dist/shared/components/help-videos/editor/VersionsTab.js +29 -28
  22. package/dist/shared/components/help-videos/library/AuthorRolesButton.js +19 -18
  23. package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +132 -129
  24. package/dist/shared/components/help-videos/library/LearningPathsPanel.js +42 -41
  25. package/dist/shared/components/help-videos/settings/HouseStyleButton.js +21 -20
  26. package/dist/shared/components/help-videos/settings/RenderSettingsButton.js +22 -21
  27. package/dist/shared/components/import/DocumentAutofillButton.js +24 -20
  28. package/dist/shared/components/import/ImportFromFileButton.js +61 -60
  29. package/dist/shared/components/imports/ImportStalenessControl.js +20 -21
  30. package/dist/shared/components/imports/NewImportDialog.js +29 -28
  31. package/dist/shared/components/imports/RunDetailSheet.js +63 -63
  32. package/dist/shared/components/item-edit/FieldRow.js +329 -329
  33. package/dist/shared/components/item-edit/InlineTableField.js +898 -898
  34. package/dist/shared/components/item-edit/PersonalDefaultControl.js +57 -56
  35. package/dist/shared/components/item-edit/PlanGrid.js +220 -221
  36. package/dist/shared/components/item-edit/RecordGrantTools.js +49 -48
  37. package/dist/shared/components/item-edit/placement-behaviour.js +68 -67
  38. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +24 -23
  39. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +17 -16
  40. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +41 -41
  41. package/dist/shared/components/layout-editor/outputs/output-api.js +33 -31
  42. package/dist/shared/components/layout-editor/overview/overview-api.js +84 -83
  43. package/dist/shared/components/layout-editor/useLayoutDraft.js +47 -42
  44. package/dist/shared/components/monitoring/InactiveUserLinksView.js +10 -9
  45. package/dist/shared/components/panels/SlaClock.js +35 -36
  46. package/dist/shared/components/pipeline/PipelineEditorView.js +311 -312
  47. package/dist/shared/components/pipeline/TeamSuggestions.js +31 -30
  48. package/dist/shared/components/profile/AgentsPanel.js +73 -72
  49. package/dist/shared/components/profile/MailSuppressedPill.js +22 -21
  50. package/dist/shared/components/support/SupportRequestDialog.js +85 -81
  51. package/dist/shared/components/support/SupportView.js +94 -87
  52. package/dist/shared/lib/autofill-poll.js +21 -18
  53. package/dist/shared/lib/error-actions.js +85 -0
  54. package/dist/shared/lib/error-message.js +223 -82
  55. package/dist/shared/lib/error-toast.js +71 -13
  56. package/dist/shared/lib/safe-error.js +136 -38
  57. package/package.json +1 -1
@@ -3,15 +3,15 @@ import { useQueryClient as Ue, useQuery as qe } from "@tanstack/react-query";
3
3
  import { Loader2 as W, FileText as be, AlertTriangle as He, Wand2 as Le, ChevronDown as Me, ChevronRight as Ee, HelpCircle as Ke, CheckCircle2 as Qe } from "lucide-react";
4
4
  import { useRef as I, useState as v, useEffect as U, useCallback as ge, useMemo as ye } from "react";
5
5
  import { toast as q } from "sonner";
6
- import { useApiFetchConfig as Oe, useOptionalNivaroClient as We } from "../../context.js";
6
+ import { useApiFetchConfig as Ae, useOptionalNivaroClient as We } from "../../context.js";
7
7
  import { askPickerNarrowing as Pe } from "../../lib/autofill-ask-filter.js";
8
8
  import { useAutofillRun as Ye, dismissAutofillRun as P, setAutofillRunPresented as ke, isAutofillProposalId as Je, startAutofillRun as we } from "../../lib/autofill-runs.js";
9
- import { cn as O } from "../../lib/utils.js";
9
+ import { cn as A } from "../../lib/utils.js";
10
10
  import { RelationCombobox as Ge } from "../item-edit/RelationCombobox.js";
11
11
  import { Button as Y } from "../ui/button.js";
12
12
  import { Dialog as Ve, DialogContent as ve, DialogHeader as Ne, DialogTitle as $e, DialogDescription as Ce, DialogFooter as Se } from "../ui/dialog.js";
13
13
  import { SimpleSelect as _e } from "../ui/SimpleSelect.js";
14
- const Ae = [
14
+ const Oe = [
15
15
  "Reading the document…",
16
16
  "Finding the parties, dates and amounts…",
17
17
  "Looking up vendors, people and categories…",
@@ -29,7 +29,11 @@ async function Xe(r, d, b, g = {}) {
29
29
  credentials: r.credentials,
30
30
  body: w
31
31
  }), h = await o.json().catch(() => ({}));
32
- if (!o.ok) throw new Error((h == null ? void 0 : h.error) || `Document autofill failed (${o.status})`);
32
+ if (!o.ok)
33
+ throw Object.assign(new Error((h == null ? void 0 : h.error) || "Document autofill failed"), {
34
+ status: o.status,
35
+ response: h
36
+ });
33
37
  const i = String(((R = h == null ? void 0 : h.data) == null ? void 0 : R.proposal_id) ?? "");
34
38
  if (!i) throw new Error("The server did not return a proposal id");
35
39
  return g.notify && await fetch(`${r.apiBase}/ai/extract-record/${encodeURIComponent(i)}/notify`, {
@@ -40,7 +44,7 @@ async function Xe(r, d, b, g = {}) {
40
44
  }), i;
41
45
  }
42
46
  function Ze(r) {
43
- const { apiBase: d, authHeaders: b, credentials: g } = Oe();
47
+ const { apiBase: d, authHeaders: b, credentials: g } = Ae();
44
48
  return qe({
45
49
  queryKey: ["ai-extract-config", r],
46
50
  enabled: !!r,
@@ -60,7 +64,7 @@ function J({ value: r }) {
60
64
  "span",
61
65
  {
62
66
  "data-autofill-confidence": d,
63
- className: O(
67
+ className: A(
64
68
  "inline-flex h-5 shrink-0 items-center rounded px-1.5 text-[11px] font-medium tabular-nums",
65
69
  b
66
70
  ),
@@ -141,7 +145,7 @@ function et({
141
145
  "input",
142
146
  {
143
147
  type: o.type === "number" ? "number" : o.type === "date" ? "date" : "text",
144
- className: O(h, "w-48"),
148
+ className: A(h, "w-48"),
145
149
  value: d == null ? "" : String(d),
146
150
  onChange: (i) => {
147
151
  const S = i.target.value;
@@ -162,11 +166,11 @@ function pt({
162
166
  onProposalConsumed: o
163
167
  }) {
164
168
  var me, fe, pe, he;
165
- const h = Oe(), { apiBase: i, authHeaders: S, credentials: R } = h, F = Ue(), V = I(null), X = I(null), [Re, Z] = v(null), [y, B] = v(null), x = Ye(y), [j, H] = v(!1), N = Re ?? ((x == null ? void 0 : x.status) === "reading" ? x.documentName : null), [Fe, ee] = v(0), [t, L] = v(null), [$, te] = v(/* @__PURE__ */ new Set()), [D, ae] = v(/* @__PURE__ */ new Set()), [A, ne] = v(/* @__PURE__ */ new Set()), [le, re] = v(/* @__PURE__ */ new Set()), [C, M] = v({}), [T, se] = v(!1), ie = I(null), { data: k } = Ze(r);
169
+ const h = Ae(), { apiBase: i, authHeaders: S, credentials: R } = h, F = Ue(), V = I(null), X = I(null), [Re, Z] = v(null), [y, B] = v(null), x = Ye(y), [j, H] = v(!1), N = Re ?? ((x == null ? void 0 : x.status) === "reading" ? x.documentName : null), [Fe, ee] = v(0), [t, L] = v(null), [$, te] = v(/* @__PURE__ */ new Set()), [D, ae] = v(/* @__PURE__ */ new Set()), [O, ne] = v(/* @__PURE__ */ new Set()), [le, re] = v(/* @__PURE__ */ new Set()), [C, M] = v({}), [T, se] = v(!1), ie = I(null), { data: k } = Ze(r);
166
170
  U(() => {
167
171
  if (!N) return;
168
172
  ee(0);
169
- const e = setInterval(() => ee((n) => Math.min(n + 1, Ae.length - 1)), 9e3);
173
+ const e = setInterval(() => ee((n) => Math.min(n + 1, Oe.length - 1)), 9e3);
170
174
  return () => clearInterval(e);
171
175
  }, [N]);
172
176
  const de = ge((e) => {
@@ -194,10 +198,10 @@ function pt({
194
198
  if (!t) return e;
195
199
  for (const n of t.fields) $.has(n.field) && (e[n.field] = n.value);
196
200
  for (const n of t.m2m)
197
- A.has(n.alias) && n.items.length && (e[n.alias] = n.items.map((s) => s.id));
201
+ O.has(n.alias) && n.items.length && (e[n.alias] = n.items.map((s) => s.id));
198
202
  for (const [n, s] of Object.entries(C)) s != null && s !== "" && (e[n] = s);
199
203
  return e;
200
- }, [t, $, A, C]), De = ge(
204
+ }, [t, $, O, C]), De = ge(
201
205
  (e) => {
202
206
  var n, s, c;
203
207
  return ((n = t == null ? void 0 : t.fields.find((m) => m.field === e)) == null ? void 0 : n.label) ?? ((s = t == null ? void 0 : t.m2m.find((m) => m.alias === e)) == null ? void 0 : s.label) ?? ((c = t == null ? void 0 : t.asks.find((m) => m.field === e)) == null ? void 0 : c.label) ?? e.replace(/_/g, " ");
@@ -264,7 +268,7 @@ function pt({
264
268
  for (const u of t.children)
265
269
  D.has(u.alias) && (s[u.alias] = u.lines.map((f) => ({ values: f.values })));
266
270
  const c = {};
267
- for (const u of t.m2m) A.has(u.alias) && (c[u.alias] = u.items.map((f) => f.id));
271
+ for (const u of t.m2m) O.has(u.alias) && (c[u.alias] = u.items.map((f) => f.id));
268
272
  t.prefill.attach_alias && t.prefill.file_id && (c[t.prefill.attach_alias] = [
269
273
  ...c[t.prefill.attach_alias] ?? [],
270
274
  t.prefill.file_id
@@ -339,7 +343,7 @@ function pt({
339
343
  return (e = V.current) == null ? void 0 : e.click();
340
344
  },
341
345
  title: N ? void 0 : "Fill this record from one or more documents — a statement of work and its quote, a spreadsheet",
342
- className: O(
346
+ className: A(
343
347
  "inline-flex h-9 items-center gap-1.5 rounded-md border border-input bg-background px-3 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-70",
344
348
  b
345
349
  ),
@@ -370,7 +374,7 @@ function pt({
370
374
  N
371
375
  ] }),
372
376
  /* @__PURE__ */ l(Ce, { children: [
373
- Ae[Fe],
377
+ Oe[Fe],
374
378
  " Usually under a minute."
375
379
  ] })
376
380
  ] }),
@@ -437,7 +441,7 @@ function pt({
437
441
  {
438
442
  "data-autofill-field": e.field,
439
443
  "data-autofill-derived": ((s = e.derived) == null ? void 0 : s.by) ?? void 0,
440
- className: O(
444
+ className: A(
441
445
  "flex items-start gap-3 px-3 py-2",
442
446
  !n && "opacity-55"
443
447
  ),
@@ -492,7 +496,7 @@ function pt({
492
496
  }, {})
493
497
  ).slice(0, 7);
494
498
  return /* @__PURE__ */ l("section", { className: "mb-5", "data-autofill-child": e.alias, children: [
495
- /* @__PURE__ */ l("div", { className: O("flex items-center gap-3", !n && "opacity-55"), children: [
499
+ /* @__PURE__ */ l("div", { className: A("flex items-center gap-3", !n && "opacity-55"), children: [
496
500
  /* @__PURE__ */ a(
497
501
  "input",
498
502
  {
@@ -546,11 +550,11 @@ function pt({
546
550
  t.m2m.length > 0 && /* @__PURE__ */ l("section", { className: "mb-5", "data-autofill-m2m": !0, children: [
547
551
  /* @__PURE__ */ a("h3", { className: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-slate-500", children: "Linked" }),
548
552
  /* @__PURE__ */ a("ul", { className: "space-y-1.5", children: t.m2m.map((e) => {
549
- const n = A.has(e.alias);
553
+ const n = O.has(e.alias);
550
554
  return /* @__PURE__ */ l(
551
555
  "li",
552
556
  {
553
- className: O(
557
+ className: A(
554
558
  "flex items-center gap-3 text-[12.5px]",
555
559
  !n && "opacity-55"
556
560
  ),
@@ -561,7 +565,7 @@ function pt({
561
565
  type: "checkbox",
562
566
  className: "h-3.5 w-3.5 accent-nvr-cyan",
563
567
  checked: n,
564
- onChange: () => z(A, e.alias, ne),
568
+ onChange: () => z(O, e.alias, ne),
565
569
  "aria-label": `Use ${e.label}`
566
570
  }
567
571
  ),
@@ -702,7 +706,7 @@ function pt({
702
706
  size: "sm",
703
707
  "data-autofill-apply": !0,
704
708
  onClick: Ie,
705
- disabled: T || $.size === 0 && _ === 0 && A.size === 0 && !Object.values(C).some((e) => e != null && e !== ""),
709
+ disabled: T || $.size === 0 && _ === 0 && O.size === 0 && !Object.values(C).some((e) => e != null && e !== ""),
706
710
  children: [
707
711
  T ? /* @__PURE__ */ a(W, { className: "mr-1.5 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(Qe, { className: "mr-1.5 h-3.5 w-3.5" }),
708
712
  "Fill ",
@@ -1,92 +1,93 @@
1
- import { jsxs as n, jsx as e, Fragment as S } from "react/jsx-runtime";
2
- import { listImportTemplates as K } from "@nivaro/sdk";
3
- import { useQuery as M } from "@tanstack/react-query";
4
- import { Loader2 as T, Upload as Q } from "lucide-react";
5
- import { useRef as q, useState as g } from "react";
6
- import { createPortal as E } from "react-dom";
7
- import { toast as U } from "sonner";
8
- import { useNivaroClient as $ } from "../../context.js";
9
- import { Button as y } from "../ui/button.js";
10
- import { Command as D, CommandInput as G, CommandList as H, CommandEmpty as J, CommandItem as V } from "../ui/command.js";
11
- import { Popover as W, PopoverTrigger as X, PopoverContent as Y } from "../ui/popover.js";
12
- import { ImportIssuesPanel as Z } from "./ImportIssuesPanel.js";
13
- function ee(d) {
1
+ import { jsxs as n, jsx as e, Fragment as L } from "react/jsx-runtime";
2
+ import { listImportTemplates as A } from "@nivaro/sdk";
3
+ import { useQuery as K } from "@tanstack/react-query";
4
+ import { Loader2 as O, Upload as Q } from "lucide-react";
5
+ import { useRef as S, useState as x } from "react";
6
+ import { createPortal as q } from "react-dom";
7
+ import { useNivaroClient as U } from "../../context.js";
8
+ import { toastError as $ } from "../../lib/error-toast.js";
9
+ import { userErrorMessage as D } from "../../lib/safe-error.js";
10
+ import { Button as g } from "../ui/button.js";
11
+ import { Command as G, CommandInput as H, CommandList as J, CommandEmpty as V, CommandItem as W } from "../ui/command.js";
12
+ import { Popover as X, PopoverTrigger as Y, PopoverContent as Z } from "../ui/popover.js";
13
+ import { ImportIssuesPanel as ee } from "./ImportIssuesPanel.js";
14
+ function te(d) {
14
15
  const c = new Set(d.flatMap((o) => o.file_types));
15
16
  return Array.from(c).map((o) => `.${o}`).join(",");
16
17
  }
17
- function ue({
18
+ function he({
18
19
  collection: d,
19
20
  templateFilter: c,
20
21
  getLabel: o,
21
22
  onParsed: R,
22
- compact: v = !1
23
+ compact: y = !1
23
24
  }) {
24
- var z;
25
- const N = $(), k = q(null), C = q(null), [B, w] = g(!1), [I, P] = g(null), l = I != null, [a, i] = g(null), { data: p } = M({
25
+ var j;
26
+ const v = U(), N = S(null), k = S(null), [B, C] = x(!1), [w, I] = x(null), l = w != null, [a, i] = x(null), { data: u } = K({
26
27
  queryKey: ["import-templates", d],
27
- queryFn: () => N.request(K(d))
28
- }), F = (p == null ? void 0 : p.data) ?? [], r = c ? F.filter(c) : F;
28
+ queryFn: () => v.request(A(d))
29
+ }), P = (u == null ? void 0 : u.data) ?? [], r = c ? P.filter(c) : P;
29
30
  if (r.length === 0) return null;
30
- function u(t) {
31
+ function f(t) {
31
32
  var s;
32
- C.current = t, i(null), w(!1), (s = k.current) == null || s.click();
33
+ k.current = t, i(null), C(!1), (s = N.current) == null || s.click();
33
34
  }
34
- async function _(t) {
35
- var L, O;
36
- const s = (L = t.target.files) == null ? void 0 : L[0], h = C.current;
37
- if (t.target.value = "", !(!s || !h)) {
38
- P(s.name), i(null);
35
+ async function M(t) {
36
+ var T, z;
37
+ const s = (T = t.target.files) == null ? void 0 : T[0], b = k.current;
38
+ if (t.target.value = "", !(!s || !b)) {
39
+ I(s.name), i(null);
39
40
  try {
40
- const b = await N.importParse(h.id, s);
41
- R(b, h);
42
- } catch (b) {
43
- const x = b;
44
- (O = x.issues) != null && O.length ? i(x) : U.error(x.message || "Import parse failed", { duration: 8e3 });
41
+ const p = await v.importParse(b.id, s);
42
+ R(p, b);
43
+ } catch (p) {
44
+ const E = p;
45
+ (z = E.issues) != null && z.length ? i(E) : $(p, "The file could not be read", { action: "Import from file" });
45
46
  } finally {
46
- P(null);
47
+ I(null);
47
48
  }
48
49
  }
49
50
  }
50
- const f = (t) => o ? o(t) : t.button_label, j = r[0] ? (z = f(r[0])) == null ? void 0 : z.trim() : void 0, A = j && r.every((t) => f(t) === f(r[0])) ? j : null, m = l ? /* @__PURE__ */ n(S, { children: [
51
- /* @__PURE__ */ e(T, { className: "h-3.5 w-3.5 animate-spin" }),
51
+ const h = (t) => o ? o(t) : t.button_label, F = r[0] ? (j = h(r[0])) == null ? void 0 : j.trim() : void 0, _ = F && r.every((t) => h(t) === h(r[0])) ? F : null, m = l ? /* @__PURE__ */ n(L, { children: [
52
+ /* @__PURE__ */ e(O, { className: "h-3.5 w-3.5 animate-spin" }),
52
53
  " Importing…"
53
- ] }) : /* @__PURE__ */ n(S, { children: [
54
+ ] }) : /* @__PURE__ */ n(L, { children: [
54
55
  /* @__PURE__ */ e(Q, { className: "h-3.5 w-3.5" }),
55
56
  " ",
56
- A ?? "Import from file"
57
+ _ ?? "Import from file"
57
58
  ] });
58
59
  return /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: [
59
60
  /* @__PURE__ */ e(
60
61
  "input",
61
62
  {
62
- ref: k,
63
+ ref: N,
63
64
  type: "file",
64
65
  className: "hidden",
65
- accept: ee(r),
66
- onChange: _
66
+ accept: te(r),
67
+ onChange: M
67
68
  }
68
69
  ),
69
- r.length === 1 ? v ? /* @__PURE__ */ e(
70
+ r.length === 1 ? y ? /* @__PURE__ */ e(
70
71
  "button",
71
72
  {
72
73
  type: "button",
73
74
  disabled: l,
74
- onClick: () => u(r[0]),
75
+ onClick: () => f(r[0]),
75
76
  className: "inline-flex h-6 items-center gap-1 rounded border border-slate-200 px-2.5 text-[11px] text-slate-600 transition-colors hover:border-slate-400 hover:text-slate-800 disabled:opacity-50 dark:border-border dark:text-slate-300",
76
77
  children: m
77
78
  }
78
79
  ) : /* @__PURE__ */ e(
79
- y,
80
+ g,
80
81
  {
81
82
  type: "button",
82
83
  variant: "outline",
83
84
  size: "sm",
84
85
  disabled: l,
85
- onClick: () => u(r[0]),
86
+ onClick: () => f(r[0]),
86
87
  children: m
87
88
  }
88
- ) : /* @__PURE__ */ n(W, { open: B, onOpenChange: w, children: [
89
- /* @__PURE__ */ e(X, { asChild: !0, children: v ? /* @__PURE__ */ e(
89
+ ) : /* @__PURE__ */ n(X, { open: B, onOpenChange: C, children: [
90
+ /* @__PURE__ */ e(Y, { asChild: !0, children: y ? /* @__PURE__ */ e(
90
91
  "button",
91
92
  {
92
93
  type: "button",
@@ -94,16 +95,16 @@ function ue({
94
95
  className: "inline-flex h-6 items-center gap-1 rounded border border-slate-200 px-2.5 text-[11px] text-slate-600 transition-colors hover:border-slate-400 hover:text-slate-800 disabled:opacity-50 dark:border-border dark:text-slate-300",
95
96
  children: m
96
97
  }
97
- ) : /* @__PURE__ */ e(y, { type: "button", variant: "outline", size: "sm", disabled: l, children: m }) }),
98
- /* @__PURE__ */ e(Y, { className: "w-[220px] p-0", align: "start", children: /* @__PURE__ */ n(D, { children: [
99
- /* @__PURE__ */ e(G, { placeholder: "Search templates…", className: "h-8 text-[12px]" }),
100
- /* @__PURE__ */ n(H, { children: [
101
- /* @__PURE__ */ e(J, { children: "No template found." }),
98
+ ) : /* @__PURE__ */ e(g, { type: "button", variant: "outline", size: "sm", disabled: l, children: m }) }),
99
+ /* @__PURE__ */ e(Z, { className: "w-[220px] p-0", align: "start", children: /* @__PURE__ */ n(G, { children: [
100
+ /* @__PURE__ */ e(H, { placeholder: "Search templates…", className: "h-8 text-[12px]" }),
101
+ /* @__PURE__ */ n(J, { children: [
102
+ /* @__PURE__ */ e(V, { children: "No template found." }),
102
103
  r.map((t) => /* @__PURE__ */ e(
103
- V,
104
+ W,
104
105
  {
105
106
  value: t.name,
106
- onSelect: () => u(t),
107
+ onSelect: () => f(t),
107
108
  children: t.name
108
109
  },
109
110
  t.id
@@ -111,7 +112,7 @@ function ue({
111
112
  ] })
112
113
  ] }) })
113
114
  ] }),
114
- (a == null ? void 0 : a.issues) && E(
115
+ (a == null ? void 0 : a.issues) && q(
115
116
  /* @__PURE__ */ e(
116
117
  "div",
117
118
  {
@@ -123,9 +124,9 @@ function ue({
123
124
  className: "max-h-[70vh] w-full max-w-[520px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-4 shadow-xl dark:border-border dark:bg-card",
124
125
  onClick: (t) => t.stopPropagation(),
125
126
  children: [
126
- /* @__PURE__ */ e("p", { className: "mb-2 text-[13px] font-semibold text-red-600 dark:text-red-400", children: a.message || "Import parse failed" }),
127
- /* @__PURE__ */ e(Z, { issues: a.issues }),
128
- /* @__PURE__ */ e("div", { className: "mt-3 flex justify-end", children: /* @__PURE__ */ e(y, { type: "button", variant: "outline", size: "sm", onClick: () => i(null), children: "Close" }) })
127
+ /* @__PURE__ */ e("p", { className: "mb-2 text-[13px] font-semibold text-red-600 dark:text-red-400", children: D(a, "The file could not be read") }),
128
+ /* @__PURE__ */ e(ee, { issues: a.issues }),
129
+ /* @__PURE__ */ e("div", { className: "mt-3 flex justify-end", children: /* @__PURE__ */ e(g, { type: "button", variant: "outline", size: "sm", onClick: () => i(null), children: "Close" }) })
129
130
  ]
130
131
  }
131
132
  )
@@ -133,12 +134,12 @@ function ue({
133
134
  ),
134
135
  document.body
135
136
  ),
136
- l && E(
137
+ l && q(
137
138
  /* @__PURE__ */ e("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/40", children: /* @__PURE__ */ n("div", { className: "flex items-center gap-3 rounded-lg border bg-background px-5 py-4 shadow-lg", children: [
138
- /* @__PURE__ */ e(T, { className: "h-5 w-5 animate-spin text-muted-foreground" }),
139
+ /* @__PURE__ */ e(O, { className: "h-5 w-5 animate-spin text-muted-foreground" }),
139
140
  /* @__PURE__ */ n("div", { className: "text-[13px]", children: [
140
141
  "Processing ",
141
- /* @__PURE__ */ e("span", { className: "font-medium", children: I }),
142
+ /* @__PURE__ */ e("span", { className: "font-medium", children: w }),
142
143
  "…"
143
144
  ] })
144
145
  ] }) }),
@@ -147,5 +148,5 @@ function ue({
147
148
  ] });
148
149
  }
149
150
  export {
150
- ue as ImportFromFileButton
151
+ he as ImportFromFileButton
151
152
  };
@@ -1,15 +1,16 @@
1
1
  import { jsxs as s, jsx as e } from "react/jsx-runtime";
2
2
  import { useQuery as z, useQueryClient as Q, useMutation as j } from "@tanstack/react-query";
3
- import { Pencil as M, Loader2 as k } from "lucide-react";
3
+ import { Pencil as D, Loader2 as k } from "lucide-react";
4
4
  import { useState as g, useId as y, useEffect as T } from "react";
5
5
  import { useNivaroClient as L } from "../../context.js";
6
6
  import { get as K, patch as B } from "../../lib/commands.js";
7
+ import { userErrorMessage as G } from "../../lib/safe-error.js";
7
8
  import { cn as f } from "../../lib/utils.js";
8
9
  import { Button as N } from "../ui/button.js";
9
10
  import { Input as q } from "../ui/input.js";
10
11
  import { Popover as F, PopoverTrigger as H, PopoverContent as O } from "../ui/popover.js";
11
- import { Switch as G } from "../ui/switch.js";
12
- const X = "core:import-stale", A = ["integration-partners", "imports"], I = 1, P = 2160;
12
+ import { Switch as X } from "../ui/switch.js";
13
+ const Y = "core:import-stale", A = ["integration-partners", "imports"], I = 1, P = 2160;
13
14
  function C() {
14
15
  const t = L();
15
16
  return z({
@@ -22,7 +23,7 @@ function C() {
22
23
  function S() {
23
24
  const t = L(), n = Q();
24
25
  return j({
25
- mutationFn: (a) => t.request(B(`/integration-signals/settings/${X}`, a)),
26
+ mutationFn: (a) => t.request(B(`/integration-signals/settings/${Y}`, a)),
26
27
  onSettled: () => {
27
28
  n.invalidateQueries({ queryKey: A }), n.invalidateQueries({ queryKey: ["integration-signals"] });
28
29
  }
@@ -32,9 +33,7 @@ function v(t) {
32
33
  return `${t.toLocaleString("en-US")} h`;
33
34
  }
34
35
  function w(t) {
35
- var a;
36
- const n = t;
37
- return ((a = n == null ? void 0 : n.response) == null ? void 0 : a.error) ?? (n == null ? void 0 : n.message) ?? "Could not save";
36
+ return G(t, "Could not save");
38
37
  }
39
38
  function E(t) {
40
39
  if (!t.trim()) return null;
@@ -45,11 +44,11 @@ function R(t) {
45
44
  const n = E(t);
46
45
  return n == null ? "Enter a number of hours." : n < I || n > P ? `Between ${I} and ${P} hours (90 days).` : null;
47
46
  }
48
- function Y(t) {
47
+ function J(t) {
49
48
  return t.last_run_at ? Math.max(0, Math.floor((Date.now() - new Date(t.last_run_at).getTime()) / 864e5)) : null;
50
49
  }
51
50
  function _(t) {
52
- return `No run in ${Y(t) ?? "many"} days — not watched. Run it or set a cadence to watch it again.`;
51
+ return `No run in ${J(t) ?? "many"} days — not watched. Run it or set a cadence to watch it again.`;
53
52
  }
54
53
  function $({
55
54
  row: t,
@@ -65,7 +64,7 @@ function $({
65
64
  /* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-3", children: [
66
65
  /* @__PURE__ */ e("label", { htmlFor: x, className: "text-[12.5px] font-medium text-foreground", children: "Monitor this import" }),
67
66
  /* @__PURE__ */ e(
68
- G,
67
+ X,
69
68
  {
70
69
  id: x,
71
70
  checked: l,
@@ -136,7 +135,7 @@ function $({
136
135
  ] })
137
136
  ] });
138
137
  }
139
- function D(t, n) {
138
+ function M(t, n) {
140
139
  return t.cadence_source === "dormant" ? n ? /* @__PURE__ */ e("span", { className: "text-muted-foreground", "data-tip": _(t), children: "Dormant" }) : /* @__PURE__ */ e(
141
140
  "span",
142
141
  {
@@ -150,7 +149,7 @@ function D(t, n) {
150
149
  t.cadence_source === "default" && /* @__PURE__ */ e("span", { className: "text-muted-foreground", children: " · default" })
151
150
  ] });
152
151
  }
153
- function ie({
152
+ function de({
154
153
  importKey: t,
155
154
  label: n,
156
155
  compact: a = !1,
@@ -182,8 +181,8 @@ function ie({
182
181
  o
183
182
  ),
184
183
  children: [
185
- D(r, !0),
186
- /* @__PURE__ */ e(M, { className: "h-3 w-3 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100" })
184
+ M(r, !0),
185
+ /* @__PURE__ */ e(D, { className: "h-3 w-3 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100" })
187
186
  ]
188
187
  }
189
188
  ) }),
@@ -199,7 +198,7 @@ function ie({
199
198
  onClick: () => u(!0),
200
199
  "data-cadence-source": r.cadence_source,
201
200
  className: "inline-flex items-center gap-1.5 rounded text-left hover:underline hover:decoration-muted-foreground hover:underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
202
- children: D(r, !1)
201
+ children: M(r, !1)
203
202
  }
204
203
  ),
205
204
  /* @__PURE__ */ e(
@@ -235,7 +234,7 @@ function ie({
235
234
  i.isError && /* @__PURE__ */ e("span", { className: "text-[12px] text-[color:var(--nvr-role-negative,#dc2626)] dark:text-[color:var(--nvr-role-negative-dark,#e08383)]", children: w(i.error) })
236
235
  ] }) }) : /* @__PURE__ */ e("p", { className: f("text-[12px] text-muted-foreground", o), children: c.isError ? "Could not load staleness." : "Available after the import is saved." }) : /* @__PURE__ */ e("p", { className: f("text-[12px] text-muted-foreground", o), children: "Available after the import is saved." });
237
236
  }
238
- function ce({ importKey: t }) {
237
+ function le({ importKey: t }) {
239
238
  var o;
240
239
  const a = (o = C().data) == null ? void 0 : o.rows.find((c) => c.key === t);
241
240
  return a ? a.cadence_source === "dormant" ? /* @__PURE__ */ e(
@@ -250,7 +249,7 @@ function ce({ importKey: t }) {
250
249
  v(a.cadence_hours)
251
250
  ] }) : null : null;
252
251
  }
253
- function de({ className: t }) {
252
+ function ue({ className: t }) {
254
253
  var x;
255
254
  const n = C(), a = S(), [o, c] = g(!1), i = ((x = n.data) == null ? void 0 : x.default_hours) ?? 48, [l, u] = g(String(i)), r = y(), m = R(l);
256
255
  T(() => {
@@ -274,7 +273,7 @@ function de({ className: t }) {
274
273
  "Default: stale after",
275
274
  " ",
276
275
  /* @__PURE__ */ e("span", { className: "font-medium text-foreground", children: v(i) }),
277
- /* @__PURE__ */ e(M, { className: "h-3 w-3 opacity-60 group-hover:opacity-100" })
276
+ /* @__PURE__ */ e(D, { className: "h-3 w-3 opacity-60 group-hover:opacity-100" })
278
277
  ]
279
278
  }
280
279
  ) }),
@@ -331,9 +330,9 @@ function de({ className: t }) {
331
330
  }
332
331
  export {
333
332
  A as IMPORT_HEALTH_KEY,
334
- de as ImportDefaultCadenceControl,
335
- ce as ImportStalenessChip,
336
- ie as ImportStalenessControl,
333
+ ue as ImportDefaultCadenceControl,
334
+ le as ImportStalenessChip,
335
+ de as ImportStalenessControl,
337
336
  w as errorText,
338
337
  v as hoursText,
339
338
  E as parseHours,