@nivaro/react 0.2.50 → 0.2.52

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 (121) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +204 -6
  4. package/dist/index.js +442 -439
  5. package/dist/layout-editor.d.ts +80 -0
  6. package/dist/layout-editor.js +11 -0
  7. package/dist/shared/components/ItemEditForm.js +4117 -3882
  8. package/dist/shared/components/RecordDrilldownSheet.js +114 -97
  9. package/dist/shared/components/RecordReadView.js +662 -596
  10. package/dist/shared/components/ai/ExplainButton.js +1 -1
  11. package/dist/shared/components/chat/ChatPanel.js +1053 -993
  12. package/dist/shared/components/import/DocumentAutofillButton.js +141 -129
  13. package/dist/shared/components/item-edit/GroupSection.js +489 -466
  14. package/dist/shared/components/item-edit/HeaderBand.js +47 -44
  15. package/dist/shared/components/item-edit/M2MStagingContext.js +3 -3
  16. package/dist/shared/components/item-edit/O2MStagingContext.js +1 -1
  17. package/dist/shared/components/item-edit/RecordGrantTools.js +206 -0
  18. package/dist/shared/components/item-edit/StepsBar.js +49 -43
  19. package/dist/shared/components/item-edit/SummaryPanel.js +2 -1
  20. package/dist/shared/components/item-edit/config-update.js +6 -0
  21. package/dist/shared/components/item-edit/layout-editing-quiet.js +25 -0
  22. package/dist/shared/components/layout-editor/AddPanel.js +301 -0
  23. package/dist/shared/components/layout-editor/DesignNode.js +173 -0
  24. package/dist/shared/components/layout-editor/EditorCanvas.js +52 -0
  25. package/dist/shared/components/layout-editor/EditorTopBar.js +241 -0
  26. package/dist/shared/components/layout-editor/HistoryPanel.js +179 -0
  27. package/dist/shared/components/layout-editor/LayoutEditor.js +393 -0
  28. package/dist/shared/components/layout-editor/LayoutsRail.js +89 -0
  29. package/dist/shared/components/layout-editor/add-target.js +103 -0
  30. package/dist/shared/components/layout-editor/bundle-to-active.js +86 -0
  31. package/dist/shared/components/layout-editor/canvases/PdfCanvas.js +90 -0
  32. package/dist/shared/components/layout-editor/canvases/TableColumnsCanvas.js +246 -0
  33. package/dist/shared/components/layout-editor/collection-meta.js +22 -0
  34. package/dist/shared/components/layout-editor/design-canvas.js +81 -0
  35. package/dist/shared/components/layout-editor/design-context.js +21 -0
  36. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +225 -0
  37. package/dist/shared/components/layout-editor/dnd/collision.js +107 -0
  38. package/dist/shared/components/layout-editor/dnd/node.js +164 -0
  39. package/dist/shared/components/layout-editor/dnd/order.js +122 -0
  40. package/dist/shared/components/layout-editor/editors/DefaultValuesEditor.js +223 -0
  41. package/dist/shared/components/layout-editor/editors/QuickPickerStepsEditor.js +129 -0
  42. package/dist/shared/components/layout-editor/editors/ReadPresentationEditor.js +134 -0
  43. package/dist/shared/components/layout-editor/editors/RecordConditionsEditor.js +249 -0
  44. package/dist/shared/components/layout-editor/editors/RolesPicker.js +77 -0
  45. package/dist/shared/components/layout-editor/editors/cascade-filters.js +556 -0
  46. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +150 -0
  47. package/dist/shared/components/layout-editor/editors/controls.js +73 -0
  48. package/dist/shared/components/layout-editor/editors/editor-api.js +21 -0
  49. package/dist/shared/components/layout-editor/editors/editor-queries.js +25 -0
  50. package/dist/shared/components/layout-editor/editors/field-default-value.js +131 -0
  51. package/dist/shared/components/layout-editor/editors/grid-presets.js +310 -0
  52. package/dist/shared/components/layout-editor/editors/inline-display.js +157 -0
  53. package/dist/shared/components/layout-editor/editors/layout-picker.js +80 -0
  54. package/dist/shared/components/layout-editor/editors/layout-rows.js +55 -0
  55. package/dist/shared/components/layout-editor/editors/lock-conditions.js +109 -0
  56. package/dist/shared/components/layout-editor/editors/o2m-agg-field.js +25 -0
  57. package/dist/shared/components/layout-editor/editors/pdf-field-config.js +107 -0
  58. package/dist/shared/components/layout-editor/editors/report-widget-config.js +94 -0
  59. package/dist/shared/components/layout-editor/editors/row-rule-check.js +225 -0
  60. package/dist/shared/components/layout-editor/editors/row-rule-row.js +1353 -0
  61. package/dist/shared/components/layout-editor/editors/swap-config.js +245 -0
  62. package/dist/shared/components/layout-editor/focus-buffer.js +32 -0
  63. package/dist/shared/components/layout-editor/host.js +15 -0
  64. package/dist/shared/components/layout-editor/inspector/AdvancedTab.js +296 -0
  65. package/dist/shared/components/layout-editor/inspector/GridTab.js +767 -0
  66. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +456 -0
  67. package/dist/shared/components/layout-editor/inspector/HeaderItemInspector.js +268 -0
  68. package/dist/shared/components/layout-editor/inspector/Inspector.js +332 -0
  69. package/dist/shared/components/layout-editor/inspector/LookTab.js +310 -0
  70. package/dist/shared/components/layout-editor/inspector/PickerTab.js +333 -0
  71. package/dist/shared/components/layout-editor/inspector/RulesTab.js +323 -0
  72. package/dist/shared/components/layout-editor/inspector/SlotInspector.js +179 -0
  73. package/dist/shared/components/layout-editor/inspector/SubtitleInspector.js +154 -0
  74. package/dist/shared/components/layout-editor/inspector/WidgetInspector.js +262 -0
  75. package/dist/shared/components/layout-editor/inspector/applies.js +27 -0
  76. package/dist/shared/components/layout-editor/inspector/field-context.js +134 -0
  77. package/dist/shared/components/layout-editor/inspector/interfaces.js +126 -0
  78. package/dist/shared/components/layout-editor/inspector/kit.js +595 -0
  79. package/dist/shared/components/layout-editor/inspector/model.js +307 -0
  80. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -0
  81. package/dist/shared/components/layout-editor/overview/describe-conditions.js +121 -0
  82. package/dist/shared/components/layout-editor/overview/overview-api.js +141 -0
  83. package/dist/shared/components/layout-editor/overview/purpose.js +62 -0
  84. package/dist/shared/components/layout-editor/overview/record-count.js +65 -0
  85. package/dist/shared/components/layout-editor/panel-frame.js +99 -0
  86. package/dist/shared/components/layout-editor/panel-style.js +19 -0
  87. package/dist/shared/components/layout-editor/pickers/field-picker.js +230 -0
  88. package/dist/shared/components/layout-editor/pickers/icon-picker.js +233 -0
  89. package/dist/shared/components/layout-editor/pickers/relation-label.js +34 -0
  90. package/dist/shared/components/layout-editor/pickers/relation-picker.js +136 -0
  91. package/dist/shared/components/layout-editor/record-queries.js +15 -0
  92. package/dist/shared/components/layout-editor/settings/AddendumSection.js +52 -0
  93. package/dist/shared/components/layout-editor/settings/ButtonsSection.js +45 -0
  94. package/dist/shared/components/layout-editor/settings/DefaultsSection.js +67 -0
  95. package/dist/shared/components/layout-editor/settings/FormSettings.js +146 -0
  96. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +37 -0
  97. package/dist/shared/components/layout-editor/settings/LayoutSection.js +70 -0
  98. package/dist/shared/components/layout-editor/settings/PdfSection.js +176 -0
  99. package/dist/shared/components/layout-editor/settings/ReadSection.js +79 -0
  100. package/dist/shared/components/layout-editor/settings/TextSetting.js +55 -0
  101. package/dist/shared/components/layout-editor/settings/ToggleSetting.js +33 -0
  102. package/dist/shared/components/layout-editor/settings/ToolsSection.js +179 -0
  103. package/dist/shared/components/layout-editor/settings/WhoSection.js +213 -0
  104. package/dist/shared/components/layout-editor/settings/controls.js +214 -0
  105. package/dist/shared/components/layout-editor/settings/section-props.js +17 -0
  106. package/dist/shared/components/layout-editor/settings/settings-api.js +151 -0
  107. package/dist/shared/components/layout-editor/settings/settings-registry.js +445 -0
  108. package/dist/shared/components/layout-editor/slot-names.js +20 -0
  109. package/dist/shared/components/layout-editor/summary-pref.js +21 -0
  110. package/dist/shared/components/layout-editor/useLayoutDraft.js +474 -0
  111. package/dist/shared/components/pipeline/relations.js +28 -23
  112. package/dist/shared/components/ui/dialog.js +11 -11
  113. package/dist/shared/components/ui/popover.js +17 -17
  114. package/dist/shared/components/ui/scroll-area.js +38 -0
  115. package/dist/shared/hooks/useRelationOptions.js +60 -0
  116. package/dist/shared/lib/layout-grants.js +9 -0
  117. package/dist/shared/lib/layout-ops.js +348 -0
  118. package/dist/shared/lib/layout-slots.js +11 -7
  119. package/dist/shared/lib/presence-state.js +43 -13
  120. package/dist/shared/lib/request-gate.js +1 -1
  121. package/package.json +5 -1
@@ -1,28 +1,28 @@
1
- import { jsxs as l, Fragment as he, jsx as a } from "react/jsx-runtime";
2
- import { useQueryClient as qe, useQuery as He } from "@tanstack/react-query";
3
- import { Loader2 as Q, FileText as xe, AlertTriangle as Ie, Wand2 as Le, ChevronDown as Me, ChevronRight as Ue, HelpCircle as Pe, CheckCircle2 as Ee } from "lucide-react";
4
- import { useRef as q, useState as v, useEffect as H, useCallback as be, useMemo as ge } from "react";
1
+ import { jsxs as l, Fragment as xe, jsx as a } from "react/jsx-runtime";
2
+ import { useQueryClient as He, useQuery as Ie } from "@tanstack/react-query";
3
+ import { Loader2 as Q, FileText as be, AlertTriangle as Le, Wand2 as Me, ChevronDown as Pe, ChevronRight as Ue, HelpCircle as Ee, CheckCircle2 as Ke } from "lucide-react";
4
+ import { useRef as q, useState as v, useEffect as H, useCallback as ge, useMemo as ye } from "react";
5
5
  import { toast as I } from "sonner";
6
- import { useApiFetchConfig as Oe, useOptionalNivaroClient as Ke } from "../../context.js";
7
- import { askPickerNarrowing as Qe } from "../../lib/autofill-ask-filter.js";
8
- import { useAutofillRun as We, dismissAutofillRun as W, setAutofillRunPresented as ye, startAutofillRun as ke } from "../../lib/autofill-runs.js";
6
+ import { useApiFetchConfig as Ae, useOptionalNivaroClient as Qe } from "../../context.js";
7
+ import { askPickerNarrowing as We } from "../../lib/autofill-ask-filter.js";
8
+ import { useAutofillRun as Ye, dismissAutofillRun as W, setAutofillRunPresented as ke, startAutofillRun as we } from "../../lib/autofill-runs.js";
9
9
  import { cn as A } from "../../lib/utils.js";
10
- import { RelationCombobox as Ye } from "../item-edit/RelationCombobox.js";
10
+ import { RelationCombobox as Je } from "../item-edit/RelationCombobox.js";
11
11
  import { Button as Y } from "../ui/button.js";
12
- import { Dialog as Je, DialogContent as we, DialogHeader as ve, DialogTitle as Ne, DialogDescription as $e, DialogFooter as Ce } from "../ui/dialog.js";
13
- import { SimpleSelect as _e } from "../ui/SimpleSelect.js";
14
- const Se = [
12
+ import { Dialog as Ge, DialogContent as ve, DialogHeader as Ne, DialogTitle as $e, DialogDescription as Ce, DialogFooter as _e } from "../ui/dialog.js";
13
+ import { SimpleSelect as Se } from "../ui/SimpleSelect.js";
14
+ const Oe = [
15
15
  "Reading the document…",
16
16
  "Finding the parties, dates and amounts…",
17
17
  "Looking up vendors, people and categories…",
18
18
  "Building the lines…",
19
19
  "Checking the numbers…"
20
20
  ];
21
- async function Ge(r, d, b, g = {}) {
22
- var C, R;
21
+ async function Ve(r, d, b, g = {}) {
22
+ var _, F;
23
23
  const p = Array.isArray(d) ? d : [d], w = new FormData();
24
- w.append("collection", b), w.append("background", "1"), g.layoutId != null && w.append("layout_id", String(g.layoutId)), (C = g.fileIds) != null && C.length && w.append("file_ids", g.fileIds.join(","));
25
- for (const F of p) w.append("file", F, F.name);
24
+ w.append("collection", b), w.append("background", "1"), g.layoutId != null && w.append("layout_id", String(g.layoutId)), (_ = g.fileIds) != null && _.length && w.append("file_ids", g.fileIds.join(","));
25
+ for (const R of p) w.append("file", R, R.name);
26
26
  const f = await fetch(`${r.apiBase}/ai/extract-record`, {
27
27
  method: "POST",
28
28
  headers: r.authHeaders,
@@ -30,7 +30,7 @@ async function Ge(r, d, b, g = {}) {
30
30
  body: w
31
31
  }), h = await f.json().catch(() => ({}));
32
32
  if (!f.ok) throw new Error((h == null ? void 0 : h.error) || `Document autofill failed (${f.status})`);
33
- const i = String(((R = h == null ? void 0 : h.data) == null ? void 0 : R.proposal_id) ?? "");
33
+ const i = String(((F = h == null ? void 0 : h.data) == null ? void 0 : F.proposal_id) ?? "");
34
34
  if (!i) throw new Error("The server did not return a proposal id");
35
35
  return g.notify && await fetch(`${r.apiBase}/ai/extract-record/${i}/notify`, {
36
36
  method: "POST",
@@ -39,9 +39,9 @@ async function Ge(r, d, b, g = {}) {
39
39
  }).catch(() => {
40
40
  }), i;
41
41
  }
42
- function Ve(r) {
43
- const { apiBase: d, authHeaders: b, credentials: g } = Oe();
44
- return He({
42
+ function Xe(r) {
43
+ const { apiBase: d, authHeaders: b, credentials: g } = Ae();
44
+ return Ie({
45
45
  queryKey: ["ai-extract-config", r],
46
46
  enabled: !!r,
47
47
  queryFn: async () => {
@@ -79,18 +79,18 @@ function G(r) {
79
79
  const d = String(r);
80
80
  return d.length > 240 ? `${d.slice(0, 240)}…` : d;
81
81
  }
82
- function Xe({
82
+ function Ze({
83
83
  ask: r,
84
84
  value: d,
85
85
  onChange: b,
86
86
  draft: g,
87
87
  labelOf: p
88
88
  }) {
89
- const w = Ke(), f = r.input, h = "h-7 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-background";
89
+ const w = Qe(), f = r.input, h = "h-7 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-background";
90
90
  if (!f) return null;
91
91
  if (f.type === "relation") {
92
92
  if (!w) return null;
93
- const i = Qe(f, g, p);
93
+ const i = We(f, g, p);
94
94
  return /* @__PURE__ */ a(
95
95
  "div",
96
96
  {
@@ -98,7 +98,7 @@ function Xe({
98
98
  "data-autofill-ask-input": "relation",
99
99
  "data-autofill-ask-narrowed": i.narrowedBy.keys.join(",") || void 0,
100
100
  children: /* @__PURE__ */ a(
101
- Ye,
101
+ Je,
102
102
  {
103
103
  collection: f.collection,
104
104
  value: d ?? null,
@@ -113,7 +113,7 @@ function Xe({
113
113
  );
114
114
  }
115
115
  return f.type === "choices" ? /* @__PURE__ */ a(
116
- _e,
116
+ Se,
117
117
  {
118
118
  className: `${h} w-auto`,
119
119
  value: d == null ? "" : String(d),
@@ -125,7 +125,7 @@ function Xe({
125
125
  ]
126
126
  }
127
127
  ) : f.type === "boolean" ? /* @__PURE__ */ a(
128
- _e,
128
+ Se,
129
129
  {
130
130
  className: `${h} w-auto`,
131
131
  value: d == null ? "" : d ? "true" : "false",
@@ -144,15 +144,15 @@ function Xe({
144
144
  className: A(h, "w-48"),
145
145
  value: d == null ? "" : String(d),
146
146
  onChange: (i) => {
147
- const C = i.target.value;
148
- b(C === "" ? null : f.type === "number" ? Number(C) : C);
147
+ const _ = i.target.value;
148
+ b(_ === "" ? null : f.type === "number" ? Number(_) : _);
149
149
  },
150
150
  placeholder: r.label,
151
151
  "data-autofill-ask-input": f.type
152
152
  }
153
153
  );
154
154
  }
155
- function mt({
155
+ function ft({
156
156
  collection: r,
157
157
  onApply: d,
158
158
  className: b,
@@ -161,37 +161,37 @@ function mt({
161
161
  label: w,
162
162
  onProposalConsumed: f
163
163
  }) {
164
- var ue, me, fe, pe;
165
- const h = Oe(), { apiBase: i, authHeaders: C, credentials: R } = h, F = qe(), V = q(null), X = q(null), [Ae, Z] = v(null), [y, B] = v(null), x = We(y), [j, L] = v(!1), _ = Ae ?? ((x == null ? void 0 : x.status) === "reading" ? x.documentName : null), [Re, ee] = v(0), [t, M] = v(null), [N, te] = v(/* @__PURE__ */ new Set()), [D, ae] = v(/* @__PURE__ */ new Set()), [O, ne] = v(/* @__PURE__ */ new Set()), [le, re] = v(/* @__PURE__ */ new Set()), [$, U] = v({}), [T, se] = v(!1), ie = q(null), { data: k } = Ve(r);
164
+ var me, fe, pe, he;
165
+ const h = Ae(), { apiBase: i, authHeaders: _, credentials: F } = h, R = He(), V = q(null), X = q(null), [Fe, Z] = v(null), [y, B] = v(null), x = Ye(y), [j, L] = v(!1), N = Fe ?? ((x == null ? void 0 : x.status) === "reading" ? x.documentName : null), [Re, ee] = v(0), [t, M] = 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, P] = v({}), [T, se] = v(!1), ie = q(null), { data: k } = Xe(r);
166
166
  H(() => {
167
- if (!_) return;
167
+ if (!N) return;
168
168
  ee(0);
169
- const e = setInterval(() => ee((n) => Math.min(n + 1, Se.length - 1)), 9e3);
169
+ const e = setInterval(() => ee((n) => Math.min(n + 1, Oe.length - 1)), 9e3);
170
170
  return () => clearInterval(e);
171
- }, [_]);
172
- const de = be((e) => {
173
- M(e), te(new Set(e.fields.map((n) => n.field))), ae(new Set(e.children.map((n) => n.alias))), ne(new Set(e.m2m.map((n) => n.alias))), re(/* @__PURE__ */ new Set()), U({});
174
- }, []), P = q(null);
171
+ }, [N]);
172
+ const de = ge((e) => {
173
+ M(e), te(new Set(e.fields.map((n) => n.field))), ae(new Set(e.children.map((n) => n.alias))), ne(new Set(e.m2m.map((n) => n.alias))), re(/* @__PURE__ */ new Set()), P({});
174
+ }, []), U = q(null);
175
175
  H(() => {
176
- !x || j || (x.status === "ready" && P.current !== x.id ? (P.current = x.id, de(x.proposal), F.invalidateQueries({ queryKey: ["nvr-ai-autofill-analytics"] })) : x.status === "failed" && (I.error(x.error ?? "Document autofill failed"), W(x.id), B(null)));
177
- }, [x, j, de, F]), H(() => {
176
+ !x || j || (x.status === "ready" && U.current !== x.id ? (U.current = x.id, de(x.proposal), R.invalidateQueries({ queryKey: ["nvr-ai-autofill-analytics"] })) : x.status === "failed" && (I.error(x.error ?? "Document autofill failed"), W(x.id), B(null)));
177
+ }, [x, j, de, R]), H(() => {
178
178
  if (y)
179
- return ye(y, !j), () => ye(y, !1);
179
+ return ke(y, !j), () => ke(y, !1);
180
180
  }, [y, j]), H(() => {
181
- !p || ie.current === p || (ie.current = p, ke(h, { id: p, collection: r }), B(p), L(!1), f == null || f());
181
+ !p || ie.current === p || (ie.current = p, we(h, { id: p, collection: r }), B(p), L(!1), f == null || f());
182
182
  }, [p, f]);
183
- const S = ge(
183
+ const S = ye(
184
184
  () => (t == null ? void 0 : t.children.reduce((e, n) => D.has(n.alias) ? e + n.lines.length : e, 0)) ?? 0,
185
185
  [t, D]
186
- ), Fe = ge(() => {
186
+ ), je = ye(() => {
187
187
  const e = {};
188
188
  if (!t) return e;
189
- for (const n of t.fields) N.has(n.field) && (e[n.field] = n.value);
189
+ for (const n of t.fields) $.has(n.field) && (e[n.field] = n.value);
190
190
  for (const n of t.m2m)
191
191
  O.has(n.alias) && n.items.length && (e[n.alias] = n.items.map((s) => s.id));
192
- for (const [n, s] of Object.entries($)) s != null && s !== "" && (e[n] = s);
192
+ for (const [n, s] of Object.entries(C)) s != null && s !== "" && (e[n] = s);
193
193
  return e;
194
- }, [t, N, O, $]), je = be(
194
+ }, [t, $, O, C]), De = ge(
195
195
  (e) => {
196
196
  var n, s, o;
197
197
  return ((n = t == null ? void 0 : t.fields.find((u) => u.field === e)) == null ? void 0 : n.label) ?? ((s = t == null ? void 0 : t.m2m.find((u) => u.alias === e)) == null ? void 0 : s.label) ?? ((o = t == null ? void 0 : t.asks.find((u) => u.field === e)) == null ? void 0 : o.label) ?? e.replace(/_/g, " ");
@@ -205,33 +205,33 @@ function mt({
205
205
  const s = n && t ? ((c = t.document.documents) == null ? void 0 : c.map((m) => m.file_id).filter((m) => !!m)) ?? (t.prefill.file_id ? [t.prefill.file_id] : []) : [], o = s.length + e.length, u = o === 1 ? e[0].name : `${o} documents`;
206
206
  Z(u), L(!1);
207
207
  try {
208
- const m = await Ge(h, e, r, {
208
+ const m = await Ve(h, e, r, {
209
209
  layoutId: g,
210
210
  fileIds: s
211
211
  });
212
- n && y && W(y), M(null), P.current = null, ke(h, { id: m, collection: r, documentName: u, layoutId: g }), B(m);
212
+ n && y && W(y), M(null), U.current = null, we(h, { id: m, collection: r, documentName: u, layoutId: g }), B(m);
213
213
  } catch (m) {
214
214
  I.error(m.message);
215
215
  } finally {
216
216
  Z(null);
217
217
  }
218
218
  }
219
- async function De(e) {
219
+ async function Te(e) {
220
220
  const n = Array.from(e.target.files ?? []);
221
221
  e.target.value = "", await oe(n, !1);
222
222
  }
223
- async function Te(e) {
223
+ async function Be(e) {
224
224
  const n = Array.from(e.target.files ?? []);
225
225
  e.target.value = "", await oe(n, !0);
226
226
  }
227
- async function Be() {
227
+ async function ze() {
228
228
  if (y) {
229
229
  L(!0);
230
230
  try {
231
231
  await fetch(`${i}/ai/extract-record/${y}/notify`, {
232
232
  method: "POST",
233
- headers: C,
234
- credentials: R
233
+ headers: _,
234
+ credentials: F
235
235
  });
236
236
  } catch {
237
237
  I.error("Could not arrange the notification");
@@ -245,14 +245,14 @@ function mt({
245
245
  const o = new Set(e);
246
246
  o.has(n) ? o.delete(n) : o.add(n), s(o);
247
247
  }
248
- async function ze() {
248
+ async function qe() {
249
249
  if (t) {
250
250
  se(!0);
251
251
  try {
252
252
  const e = {};
253
- for (const c of t.fields) N.has(c.field) && (e[c.field] = c.value);
253
+ for (const c of t.fields) $.has(c.field) && (e[c.field] = c.value);
254
254
  let n = 0;
255
- for (const [c, m] of Object.entries($))
255
+ for (const [c, m] of Object.entries(C))
256
256
  m == null || m === "" || (e[c] = m, n++);
257
257
  const s = {};
258
258
  for (const c of t.children)
@@ -264,12 +264,12 @@ function mt({
264
264
  t.prefill.file_id
265
265
  ]), fetch(`${i}/ai/extract-record/${t.id}/apply`, {
266
266
  method: "POST",
267
- headers: { ...C, "Content-Type": "application/json" },
268
- credentials: R,
267
+ headers: { ..._, "Content-Type": "application/json" },
268
+ credentials: F,
269
269
  body: JSON.stringify({
270
- kept_fields: [...N],
270
+ kept_fields: [...$],
271
271
  kept_lines: S,
272
- resolved_asks: Object.keys($).filter((c) => $[c] != null && $[c] !== "")
272
+ resolved_asks: Object.keys(C).filter((c) => C[c] != null && C[c] !== "")
273
273
  })
274
274
  }).catch(() => {
275
275
  }), await d(
@@ -293,8 +293,11 @@ function mt({
293
293
  }
294
294
  }
295
295
  }
296
- const ce = ((k == null ? void 0 : k.accept) ?? []).join(","), K = (t == null ? void 0 : t.asks) ?? [];
297
- return /* @__PURE__ */ l(he, { children: [
296
+ const ce = ((k == null ? void 0 : k.accept) ?? []).join(","), K = (t == null ? void 0 : t.asks) ?? [], ue = (e) => {
297
+ var n;
298
+ e.preventDefault(), (n = e.currentTarget) == null || n.focus();
299
+ };
300
+ return /* @__PURE__ */ l(xe, { children: [
298
301
  /* @__PURE__ */ a(
299
302
  "input",
300
303
  {
@@ -303,7 +306,7 @@ function mt({
303
306
  accept: ce,
304
307
  multiple: !0,
305
308
  className: "hidden",
306
- onChange: De,
309
+ onChange: Te,
307
310
  "data-autofill-file-input": !0
308
311
  }
309
312
  ),
@@ -315,7 +318,7 @@ function mt({
315
318
  accept: ce,
316
319
  multiple: !0,
317
320
  className: "hidden",
318
- onChange: Te,
321
+ onChange: Be,
319
322
  "data-autofill-add-input": !0
320
323
  }
321
324
  ),
@@ -324,68 +327,77 @@ function mt({
324
327
  {
325
328
  type: "button",
326
329
  "data-autofill-button": !0,
327
- disabled: !!_,
330
+ disabled: !!N,
328
331
  onClick: () => {
329
332
  var e;
330
333
  return (e = V.current) == null ? void 0 : e.click();
331
334
  },
332
- title: "Fill this record from one or more documents — a statement of work and its quote, a spreadsheet",
335
+ title: N ? void 0 : "Fill this record from one or more documents — a statement of work and its quote, a spreadsheet",
333
336
  className: A(
334
337
  "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",
335
338
  b
336
339
  ),
337
340
  children: [
338
- _ ? /* @__PURE__ */ a(Q, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(xe, { className: "h-3.5 w-3.5" }),
339
- _ ? "Reading…" : w ?? "Fill from document"
341
+ N ? /* @__PURE__ */ a(Q, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(be, { className: "h-3.5 w-3.5" }),
342
+ N ? "Reading…" : w ?? "Fill from document"
340
343
  ]
341
344
  }
342
345
  ),
343
346
  /* @__PURE__ */ a(
344
- Je,
347
+ Ge,
345
348
  {
346
- open: !j && (!!_ || !!t),
349
+ open: !j && (!!N || !!t),
347
350
  onOpenChange: (e) => {
348
- !e && !_ && !T && E();
351
+ !e && !N && !T && E();
349
352
  },
350
- children: _ && !t ? /* @__PURE__ */ l(we, { className: "max-w-md", "data-autofill-waiting": !0, children: [
351
- /* @__PURE__ */ l(ve, { children: [
352
- /* @__PURE__ */ l(Ne, { className: "flex items-center gap-2 text-[15px]", children: [
353
- /* @__PURE__ */ a(Q, { className: "h-4 w-4 animate-spin text-nvr-navy dark:text-nvr-cyan" }),
354
- "Reading ",
355
- _
356
- ] }),
357
- /* @__PURE__ */ l($e, { children: [
358
- Se[Re],
359
- " Usually under a minute."
360
- ] })
361
- ] }),
362
- y && /* @__PURE__ */ l(Ce, { className: "sm:justify-start", children: [
363
- /* @__PURE__ */ a(
364
- Y,
365
- {
366
- type: "button",
367
- variant: "outline",
368
- size: "sm",
369
- onClick: Be,
370
- "data-autofill-background": !0,
371
- children: "Tell me when it's ready"
372
- }
373
- ),
374
- /* @__PURE__ */ a("span", { className: "text-[11.5px] text-slate-500", children: "Keep working — a notification opens the proposal here." })
375
- ] })
376
- ] }) : /* @__PURE__ */ a(
377
- we,
353
+ children: N && !t ? /* @__PURE__ */ l(
354
+ ve,
355
+ {
356
+ className: "max-w-md outline-none",
357
+ "data-autofill-waiting": !0,
358
+ onOpenAutoFocus: ue,
359
+ children: [
360
+ /* @__PURE__ */ l(Ne, { children: [
361
+ /* @__PURE__ */ l($e, { className: "flex items-center gap-2 text-[15px]", children: [
362
+ /* @__PURE__ */ a(Q, { className: "h-4 w-4 animate-spin text-nvr-navy dark:text-nvr-cyan" }),
363
+ "Reading ",
364
+ N
365
+ ] }),
366
+ /* @__PURE__ */ l(Ce, { children: [
367
+ Oe[Re],
368
+ " Usually under a minute."
369
+ ] })
370
+ ] }),
371
+ y && /* @__PURE__ */ l(_e, { className: "sm:justify-start", children: [
372
+ /* @__PURE__ */ a(
373
+ Y,
374
+ {
375
+ type: "button",
376
+ variant: "outline",
377
+ size: "sm",
378
+ onClick: ze,
379
+ "data-autofill-background": !0,
380
+ children: "Tell me when it's ready"
381
+ }
382
+ ),
383
+ /* @__PURE__ */ a("span", { className: "text-[11.5px] text-slate-500", children: "Keep working — a notification opens the proposal here." })
384
+ ] })
385
+ ]
386
+ }
387
+ ) : /* @__PURE__ */ a(
388
+ ve,
378
389
  {
379
- className: "flex max-h-[88vh] w-[880px] max-w-[96vw] flex-col gap-0 p-0",
390
+ className: "flex max-h-[88vh] w-[880px] max-w-[96vw] flex-col gap-0 p-0 outline-none",
380
391
  "data-autofill-review": !0,
381
- children: t && /* @__PURE__ */ l(he, { children: [
382
- /* @__PURE__ */ l(ve, { className: "border-b border-slate-200 px-5 py-4 dark:border-border", children: [
383
- /* @__PURE__ */ a(Ne, { className: "text-[15px]", children: "What the document says" }),
384
- /* @__PURE__ */ l($e, { className: "text-[12.5px]", children: [
392
+ onOpenAutoFocus: ue,
393
+ children: t && /* @__PURE__ */ l(xe, { children: [
394
+ /* @__PURE__ */ l(Ne, { className: "border-b border-slate-200 px-5 py-4 dark:border-border", children: [
395
+ /* @__PURE__ */ a($e, { className: "text-[15px]", children: "What the document says" }),
396
+ /* @__PURE__ */ l(Ce, { className: "text-[12.5px]", children: [
385
397
  t.summary || `Read from ${t.document.name}.`,
386
398
  " ",
387
399
  /* @__PURE__ */ l("span", { className: "text-slate-400", children: [
388
- (((ue = t.document.documents) == null ? void 0 : ue.length) ?? 0) > 1 ? `${(me = t.document.documents) == null ? void 0 : me.length} documents` : t.document.name,
400
+ (((me = t.document.documents) == null ? void 0 : me.length) ?? 0) > 1 ? `${(fe = t.document.documents) == null ? void 0 : fe.length} documents` : t.document.name,
389
401
  t.document.pages ? ` · ${t.document.pages} pages` : "",
390
402
  t.condensed ? ` · long document, ${t.condensed.chunks} later part${t.condensed.chunks === 1 ? "" : "s"} read for excerpts` : t.document.truncated ? " · only the first part was read" : ""
391
403
  ] })
@@ -397,7 +409,7 @@ function mt({
397
409
  {
398
410
  className: "flex items-start gap-2 rounded-md bg-amber-50 px-3 py-2 text-[12.5px] text-amber-900 dark:bg-amber-900/25 dark:text-amber-100",
399
411
  children: [
400
- /* @__PURE__ */ a(Ie, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
412
+ /* @__PURE__ */ a(Le, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
401
413
  e
402
414
  ]
403
415
  },
@@ -406,14 +418,14 @@ function mt({
406
418
  t.fields.length > 0 && /* @__PURE__ */ l("section", { className: "mb-5", children: [
407
419
  /* @__PURE__ */ l("h3", { className: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-slate-500", children: [
408
420
  "Fields · ",
409
- N.size,
421
+ $.size,
410
422
  " of ",
411
423
  t.fields.length,
412
424
  " selected"
413
425
  ] }),
414
426
  /* @__PURE__ */ a("ul", { className: "divide-y divide-slate-100 rounded-lg border border-slate-200 dark:divide-border dark:border-border", children: t.fields.map((e) => {
415
427
  var s;
416
- const n = N.has(e.field);
428
+ const n = $.has(e.field);
417
429
  return /* @__PURE__ */ l(
418
430
  "li",
419
431
  {
@@ -430,7 +442,7 @@ function mt({
430
442
  type: "checkbox",
431
443
  className: "mt-1 h-3.5 w-3.5 accent-nvr-cyan",
432
444
  checked: n,
433
- onChange: () => z(N, e.field, te),
445
+ onChange: () => z($, e.field, te),
434
446
  "aria-label": `Use ${e.label}`
435
447
  }
436
448
  ),
@@ -444,7 +456,7 @@ function mt({
444
456
  className: "inline-flex h-5 items-center gap-1 rounded bg-sky-50 px-1.5 text-[10.5px] font-medium text-sky-800 dark:bg-sky-900/30 dark:text-sky-200",
445
457
  title: e.source ?? void 0,
446
458
  children: [
447
- /* @__PURE__ */ a(Le, { className: "h-3 w-3" }),
459
+ /* @__PURE__ */ a(Me, { className: "h-3 w-3" }),
448
460
  e.derived.by === "field_rule" ? "rule" : "default"
449
461
  ]
450
462
  }
@@ -493,7 +505,7 @@ function mt({
493
505
  onClick: () => z(le, e.alias, re),
494
506
  "aria-expanded": s,
495
507
  children: [
496
- s ? /* @__PURE__ */ a(Me, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ a(Ue, { className: "h-3.5 w-3.5" }),
508
+ s ? /* @__PURE__ */ a(Pe, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ a(Ue, { className: "h-3.5 w-3.5" }),
497
509
  e.label,
498
510
  " · ",
499
511
  e.lines.length,
@@ -564,12 +576,12 @@ function mt({
564
576
  ] }),
565
577
  K.length > 0 && /* @__PURE__ */ l("section", { "data-autofill-asks": !0, children: [
566
578
  /* @__PURE__ */ l("h3", { className: "mb-2 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-slate-500", children: [
567
- /* @__PURE__ */ a(Pe, { className: "h-3.5 w-3.5" }),
579
+ /* @__PURE__ */ a(Ee, { className: "h-3.5 w-3.5" }),
568
580
  " Still needs you · ",
569
581
  K.length
570
582
  ] }),
571
583
  /* @__PURE__ */ a("ul", { className: "space-y-2", children: K.map((e) => {
572
- const n = $[e.field] != null && $[e.field] !== "";
584
+ const n = C[e.field] != null && C[e.field] !== "";
573
585
  return /* @__PURE__ */ l(
574
586
  "li",
575
587
  {
@@ -584,13 +596,13 @@ function mt({
584
596
  ] }),
585
597
  /* @__PURE__ */ l("div", { className: "mt-1.5 flex flex-wrap items-center gap-2", children: [
586
598
  /* @__PURE__ */ a(
587
- Xe,
599
+ Ze,
588
600
  {
589
601
  ask: e,
590
- value: $[e.field],
591
- draft: Fe,
592
- labelOf: je,
593
- onChange: (s) => U((o) => ({ ...o, [e.field]: s }))
602
+ value: C[e.field],
603
+ draft: je,
604
+ labelOf: De,
605
+ onChange: (s) => P((o) => ({ ...o, [e.field]: s }))
594
606
  }
595
607
  ),
596
608
  e.candidate && /* @__PURE__ */ l(
@@ -598,7 +610,7 @@ function mt({
598
610
  {
599
611
  type: "button",
600
612
  "data-autofill-use-candidate": e.field,
601
- onClick: () => U((s) => {
613
+ onClick: () => P((s) => {
602
614
  var o;
603
615
  return {
604
616
  ...s,
@@ -624,7 +636,7 @@ function mt({
624
636
  ] }),
625
637
  t.fields.length === 0 && t.children.length === 0 && /* @__PURE__ */ a("p", { className: "text-[13px] text-slate-600 dark:text-slate-300", children: "Nothing in this document maps onto a field here. Try a document that names the record's parties, dates or amounts." })
626
638
  ] }),
627
- /* @__PURE__ */ l(Ce, { className: "items-center justify-between gap-3 border-t border-slate-200 px-5 py-3 dark:border-border sm:justify-between", children: [
639
+ /* @__PURE__ */ l(_e, { className: "items-center justify-between gap-3 border-t border-slate-200 px-5 py-3 dark:border-border sm:justify-between", children: [
628
640
  /* @__PURE__ */ l("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [
629
641
  /* @__PURE__ */ l("span", { className: "text-[11.5px] text-slate-400", children: [
630
642
  "Nothing is saved until you press Create. Model ",
@@ -637,13 +649,13 @@ function mt({
637
649
  t.latency_ms ? ` · ${Math.round(t.latency_ms / 1e3)}s` : "",
638
650
  "."
639
651
  ] }),
640
- (((fe = t.document.documents) == null ? void 0 : fe.length) ?? 0) > 1 && /* @__PURE__ */ a("span", { className: "flex flex-wrap gap-1", "data-autofill-documents": !0, children: (pe = t.document.documents) == null ? void 0 : pe.map((e) => /* @__PURE__ */ l(
652
+ (((pe = t.document.documents) == null ? void 0 : pe.length) ?? 0) > 1 && /* @__PURE__ */ a("span", { className: "flex flex-wrap gap-1", "data-autofill-documents": !0, children: (he = t.document.documents) == null ? void 0 : he.map((e) => /* @__PURE__ */ l(
641
653
  "span",
642
654
  {
643
655
  className: "inline-flex items-center gap-1 rounded-full border border-slate-200 px-2 py-0.5 text-[11px] text-slate-600 dark:border-border dark:text-slate-300",
644
656
  title: `${e.method}${e.pages ? ` · ${e.pages} pages` : ""}${e.truncated ? " · truncated" : ""}`,
645
657
  children: [
646
- /* @__PURE__ */ a(xe, { className: "h-3 w-3" }),
658
+ /* @__PURE__ */ a(be, { className: "h-3 w-3" }),
647
659
  e.name
648
660
  ]
649
661
  },
@@ -683,14 +695,14 @@ function mt({
683
695
  type: "button",
684
696
  size: "sm",
685
697
  "data-autofill-apply": !0,
686
- onClick: ze,
687
- disabled: T || N.size === 0 && S === 0 && O.size === 0 && !Object.values($).some((e) => e != null && e !== ""),
698
+ onClick: qe,
699
+ disabled: T || $.size === 0 && S === 0 && O.size === 0 && !Object.values(C).some((e) => e != null && e !== ""),
688
700
  children: [
689
- T ? /* @__PURE__ */ a(Q, { className: "mr-1.5 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(Ee, { className: "mr-1.5 h-3.5 w-3.5" }),
701
+ T ? /* @__PURE__ */ a(Q, { className: "mr-1.5 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(Ke, { className: "mr-1.5 h-3.5 w-3.5" }),
690
702
  "Fill ",
691
- N.size,
703
+ $.size,
692
704
  " field",
693
- N.size === 1 ? "" : "s",
705
+ $.size === 1 ? "" : "s",
694
706
  S ? ` + ${S} line${S === 1 ? "" : "s"}` : ""
695
707
  ]
696
708
  }
@@ -705,7 +717,7 @@ function mt({
705
717
  ] });
706
718
  }
707
719
  export {
708
- mt as DocumentAutofillButton,
709
- Ge as startDocumentExtraction,
710
- Ve as useDocumentAutofillConfig
720
+ ft as DocumentAutofillButton,
721
+ Ve as startDocumentExtraction,
722
+ Xe as useDocumentAutofillConfig
711
723
  };