@nivaro/react 0.2.50 → 0.2.51
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.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/ItemEditForm.js +3156 -3099
- package/dist/shared/components/RecordReadView.js +148 -149
- package/dist/shared/components/chat/ChatPanel.js +1053 -993
- package/dist/shared/components/import/DocumentAutofillButton.js +141 -129
- package/dist/shared/components/item-edit/SummaryPanel.js +1 -0
- package/dist/shared/components/ui/dialog.js +11 -11
- package/dist/shared/lib/presence-state.js +43 -13
- package/package.json +1 -1
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { jsxs as l, Fragment as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Loader2 as Q, FileText as
|
|
4
|
-
import { useRef as q, useState as v, useEffect as H, useCallback as
|
|
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
|
|
7
|
-
import { askPickerNarrowing as
|
|
8
|
-
import { useAutofillRun as
|
|
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
|
|
10
|
+
import { RelationCombobox as Je } from "../item-edit/RelationCombobox.js";
|
|
11
11
|
import { Button as Y } from "../ui/button.js";
|
|
12
|
-
import { Dialog as
|
|
13
|
-
import { SimpleSelect as
|
|
14
|
-
const
|
|
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
|
|
22
|
-
var
|
|
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)), (
|
|
25
|
-
for (const
|
|
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(((
|
|
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
|
|
43
|
-
const { apiBase: d, authHeaders: b, credentials: g } =
|
|
44
|
-
return
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
148
|
-
b(
|
|
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
|
|
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
|
|
165
|
-
const h =
|
|
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 (!
|
|
167
|
+
if (!N) return;
|
|
168
168
|
ee(0);
|
|
169
|
-
const e = setInterval(() => ee((n) => Math.min(n + 1,
|
|
169
|
+
const e = setInterval(() => ee((n) => Math.min(n + 1, Oe.length - 1)), 9e3);
|
|
170
170
|
return () => clearInterval(e);
|
|
171
|
-
}, [
|
|
172
|
-
const de =
|
|
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()),
|
|
174
|
-
}, []),
|
|
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" &&
|
|
177
|
-
}, [x, j, de,
|
|
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
|
|
179
|
+
return ke(y, !j), () => ke(y, !1);
|
|
180
180
|
}, [y, j]), H(() => {
|
|
181
|
-
!p || ie.current === p || (ie.current = p,
|
|
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 =
|
|
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
|
-
),
|
|
186
|
+
), je = ye(() => {
|
|
187
187
|
const e = {};
|
|
188
188
|
if (!t) return e;
|
|
189
|
-
for (const n of t.fields)
|
|
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(
|
|
192
|
+
for (const [n, s] of Object.entries(C)) s != null && s !== "" && (e[n] = s);
|
|
193
193
|
return e;
|
|
194
|
-
}, [t,
|
|
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
|
|
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),
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
234
|
-
credentials:
|
|
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
|
|
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)
|
|
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: { ...
|
|
268
|
-
credentials:
|
|
267
|
+
headers: { ..._, "Content-Type": "application/json" },
|
|
268
|
+
credentials: F,
|
|
269
269
|
body: JSON.stringify({
|
|
270
|
-
kept_fields: [
|
|
270
|
+
kept_fields: [...$],
|
|
271
271
|
kept_lines: S,
|
|
272
|
-
resolved_asks: Object.keys(
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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
|
-
|
|
339
|
-
|
|
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
|
-
|
|
347
|
+
Ge,
|
|
345
348
|
{
|
|
346
|
-
open: !j && (!!
|
|
349
|
+
open: !j && (!!N || !!t),
|
|
347
350
|
onOpenChange: (e) => {
|
|
348
|
-
!e && !
|
|
351
|
+
!e && !N && !T && E();
|
|
349
352
|
},
|
|
350
|
-
children:
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
/* @__PURE__ */
|
|
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
|
-
(((
|
|
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(
|
|
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
|
-
|
|
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 =
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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 =
|
|
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
|
-
|
|
599
|
+
Ze,
|
|
588
600
|
{
|
|
589
601
|
ask: e,
|
|
590
|
-
value:
|
|
591
|
-
draft:
|
|
592
|
-
labelOf:
|
|
593
|
-
onChange: (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: () =>
|
|
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(
|
|
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
|
-
(((
|
|
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(
|
|
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:
|
|
687
|
-
disabled: T ||
|
|
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(
|
|
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
|
-
|
|
703
|
+
$.size,
|
|
692
704
|
" field",
|
|
693
|
-
|
|
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
|
-
|
|
709
|
-
|
|
710
|
-
|
|
720
|
+
ft as DocumentAutofillButton,
|
|
721
|
+
Ve as startDocumentExtraction,
|
|
722
|
+
Xe as useDocumentAutofillConfig
|
|
711
723
|
};
|
|
@@ -18,7 +18,7 @@ function m({
|
|
|
18
18
|
}
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function b({
|
|
22
22
|
className: t,
|
|
23
23
|
children: e,
|
|
24
24
|
hideClose: i = !1,
|
|
@@ -37,7 +37,7 @@ function D({
|
|
|
37
37
|
...r,
|
|
38
38
|
children: [
|
|
39
39
|
e,
|
|
40
|
-
!i && /* @__PURE__ */ n(o.Close, { className: "absolute right-4 top-2 rounded-lg p-1 text-slate-400 hover:text-slate-600 focus:outline-none focus:ring-2 focus:ring-nvr-cyan", children: [
|
|
40
|
+
!i && /* @__PURE__ */ n(o.Close, { className: "absolute right-4 top-2 rounded-lg p-1 text-slate-400 hover:text-slate-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan", children: [
|
|
41
41
|
/* @__PURE__ */ a(d, { className: "h-4 w-4" }),
|
|
42
42
|
/* @__PURE__ */ a("span", { className: "sr-only", children: "Close" })
|
|
43
43
|
] })
|
|
@@ -46,13 +46,13 @@ function D({
|
|
|
46
46
|
)
|
|
47
47
|
] });
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function D({ className: t, ...e }) {
|
|
50
50
|
return /* @__PURE__ */ a("div", { className: s("px-6 pt-6 pb-4", t), ...e });
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function v({ className: t, ...e }) {
|
|
53
53
|
return /* @__PURE__ */ a("div", { className: s("px-6 pb-6", t), ...e });
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function h({ className: t, ...e }) {
|
|
56
56
|
return /* @__PURE__ */ a(
|
|
57
57
|
"div",
|
|
58
58
|
{
|
|
@@ -61,7 +61,7 @@ function N({ className: t, ...e }) {
|
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function N({
|
|
65
65
|
className: t,
|
|
66
66
|
...e
|
|
67
67
|
}) {
|
|
@@ -87,11 +87,11 @@ function y({
|
|
|
87
87
|
}
|
|
88
88
|
export {
|
|
89
89
|
g as Dialog,
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
v as DialogBody,
|
|
91
|
+
b as DialogContent,
|
|
92
92
|
y as DialogDescription,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
h as DialogFooter,
|
|
94
|
+
D as DialogHeader,
|
|
95
|
+
N as DialogTitle,
|
|
96
96
|
x as DialogTrigger
|
|
97
97
|
};
|