@gemina/elements 0.8.0 → 0.10.0
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/chat.cjs +1 -1
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/{chunk-5T2M557X.js → chunk-ILX5CY6H.js} +1446 -350
- package/dist/chunk-ILX5CY6H.js.map +1 -0
- package/dist/{chunk-724KJLIY.js → chunk-TSOUHYYB.js} +2 -2
- package/dist/{chunk-724KJLIY.js.map → chunk-TSOUHYYB.js.map} +1 -1
- package/dist/{chunk-3SZSUO7E.js → chunk-YVJI4TFI.js} +2 -2
- package/dist/index.cjs +1449 -362
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/verification.cjs +1449 -362
- package/dist/verification.cjs.map +1 -1
- package/dist/verification.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-5T2M557X.js.map +0 -1
- /package/dist/{chunk-3SZSUO7E.js.map → chunk-YVJI4TFI.js.map} +0 -0
package/dist/verification.cjs
CHANGED
|
@@ -33,7 +33,7 @@ __export(verification_exports, {
|
|
|
33
33
|
GeminaVerification: () => GeminaVerification
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(verification_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_react4 = require("react");
|
|
37
37
|
var import_sdk = require("@gemina/sdk");
|
|
38
38
|
|
|
39
39
|
// src/internal/response-like.ts
|
|
@@ -82,6 +82,178 @@ async function readErrorEnvelope(error) {
|
|
|
82
82
|
return info;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
// src/verification/field-types.ts
|
|
86
|
+
var ISO_4217_CODES = [
|
|
87
|
+
"AED",
|
|
88
|
+
"ARS",
|
|
89
|
+
"AUD",
|
|
90
|
+
"BGN",
|
|
91
|
+
"BRL",
|
|
92
|
+
"CAD",
|
|
93
|
+
"CHF",
|
|
94
|
+
"CLP",
|
|
95
|
+
"CNY",
|
|
96
|
+
"COP",
|
|
97
|
+
"CZK",
|
|
98
|
+
"DKK",
|
|
99
|
+
"EGP",
|
|
100
|
+
"EUR",
|
|
101
|
+
"GBP",
|
|
102
|
+
"HKD",
|
|
103
|
+
"HRK",
|
|
104
|
+
"HUF",
|
|
105
|
+
"IDR",
|
|
106
|
+
"ILS",
|
|
107
|
+
"INR",
|
|
108
|
+
"ISK",
|
|
109
|
+
"JPY",
|
|
110
|
+
"KRW",
|
|
111
|
+
"MAD",
|
|
112
|
+
"MXN",
|
|
113
|
+
"MYR",
|
|
114
|
+
"NGN",
|
|
115
|
+
"NOK",
|
|
116
|
+
"NZD",
|
|
117
|
+
"PEN",
|
|
118
|
+
"PHP",
|
|
119
|
+
"PLN",
|
|
120
|
+
"RON",
|
|
121
|
+
"RSD",
|
|
122
|
+
"RUB",
|
|
123
|
+
"SAR",
|
|
124
|
+
"SEK",
|
|
125
|
+
"SGD",
|
|
126
|
+
"THB",
|
|
127
|
+
"TRY",
|
|
128
|
+
"TWD",
|
|
129
|
+
"UAH",
|
|
130
|
+
"USD",
|
|
131
|
+
"VND",
|
|
132
|
+
"ZAR"
|
|
133
|
+
];
|
|
134
|
+
var ISO_4217_SHAPE = /^[A-Za-z]{3}$/;
|
|
135
|
+
var DATE_SHAPE = /^\d{4}-\d{2}-\d{2}$/;
|
|
136
|
+
var NUMERIC_SHAPE = /^[+-]?[\d,_]*\.?\d+$/;
|
|
137
|
+
function toNumber(value) {
|
|
138
|
+
if (!NUMERIC_SHAPE.test(value)) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const parsed = Number(value.replace(/[,_]/g, ""));
|
|
142
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
143
|
+
}
|
|
144
|
+
function validateInput(value, field) {
|
|
145
|
+
const trimmed = value.trim();
|
|
146
|
+
if (trimmed === "" || !field) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
if (field.enum && field.enum.length > 0) {
|
|
150
|
+
return field.enum.includes(trimmed) ? null : `Choose one of: ${field.enum.join(", ")}`;
|
|
151
|
+
}
|
|
152
|
+
if (field.format === "iso4217") {
|
|
153
|
+
return ISO_4217_SHAPE.test(trimmed) ? null : "Use a 3-letter ISO 4217 code, e.g. USD";
|
|
154
|
+
}
|
|
155
|
+
switch (field.type) {
|
|
156
|
+
case "number":
|
|
157
|
+
return toNumber(trimmed) === null ? "Enter a number" : null;
|
|
158
|
+
case "integer": {
|
|
159
|
+
const parsed = toNumber(trimmed);
|
|
160
|
+
if (parsed === null || !Number.isInteger(parsed)) {
|
|
161
|
+
return "Enter a whole number";
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
case "date": {
|
|
166
|
+
if (!DATE_SHAPE.test(trimmed)) {
|
|
167
|
+
return "Enter a date as YYYY-MM-DD";
|
|
168
|
+
}
|
|
169
|
+
const [year, month, day] = trimmed.split("-").map(Number);
|
|
170
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
171
|
+
const survives = date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
172
|
+
return survives ? null : "Enter a date as YYYY-MM-DD";
|
|
173
|
+
}
|
|
174
|
+
default:
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function readRowMutableTables(raw) {
|
|
179
|
+
if (!Array.isArray(raw)) {
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
const out = [];
|
|
183
|
+
for (const item of raw) {
|
|
184
|
+
if (item === null || typeof item !== "object") {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const source = item;
|
|
188
|
+
if (typeof source.pointer !== "string" || typeof source.keyTemplate !== "string") {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
out.push({
|
|
192
|
+
pointer: source.pointer,
|
|
193
|
+
keyTemplate: source.keyTemplate,
|
|
194
|
+
// Columns are descriptors keyed by `name` rather than `key`, so they get
|
|
195
|
+
// the same treatment with the name standing in as the identity.
|
|
196
|
+
columns: readDescriptors(
|
|
197
|
+
(Array.isArray(source.columns) ? source.columns : []).map((column) => {
|
|
198
|
+
const record = column ?? {};
|
|
199
|
+
return { ...record, key: record.name };
|
|
200
|
+
})
|
|
201
|
+
)
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return out;
|
|
205
|
+
}
|
|
206
|
+
function cellSchemaKey(template, index, field) {
|
|
207
|
+
return template.replace(/\{index\}/g, String(index)).replace(/\{field\}/g, field);
|
|
208
|
+
}
|
|
209
|
+
function coerceInput(value, field) {
|
|
210
|
+
if (!field) {
|
|
211
|
+
return value;
|
|
212
|
+
}
|
|
213
|
+
switch (field.type) {
|
|
214
|
+
case "number":
|
|
215
|
+
case "integer": {
|
|
216
|
+
const parsed = toNumber(value);
|
|
217
|
+
return parsed === null ? value : parsed;
|
|
218
|
+
}
|
|
219
|
+
case "boolean": {
|
|
220
|
+
const lowered = value.trim().toLowerCase();
|
|
221
|
+
if (lowered === "true") return true;
|
|
222
|
+
if (lowered === "false") return false;
|
|
223
|
+
return value;
|
|
224
|
+
}
|
|
225
|
+
// `date` stays a string: the wire format IS the ISO string, and a Date
|
|
226
|
+
// object would serialise with a time component the extraction never had.
|
|
227
|
+
default:
|
|
228
|
+
return value;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function readDescriptors(raw) {
|
|
232
|
+
if (!Array.isArray(raw)) {
|
|
233
|
+
return [];
|
|
234
|
+
}
|
|
235
|
+
const out = [];
|
|
236
|
+
for (const item of raw) {
|
|
237
|
+
if (item === null || typeof item !== "object") {
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
const source = item;
|
|
241
|
+
if (typeof source.key !== "string") {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const roster = source._enum ?? source.enum;
|
|
245
|
+
out.push({
|
|
246
|
+
key: source.key,
|
|
247
|
+
label: typeof source.label === "string" ? source.label : void 0,
|
|
248
|
+
type: typeof source.type === "string" ? source.type : void 0,
|
|
249
|
+
enum: Array.isArray(roster) ? roster.map(String) : null,
|
|
250
|
+
format: typeof source.format === "string" ? source.format : null,
|
|
251
|
+
description: typeof source.description === "string" ? source.description : null
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return out;
|
|
255
|
+
}
|
|
256
|
+
|
|
85
257
|
// src/verification/classify.ts
|
|
86
258
|
var ACRONYMS = /* @__PURE__ */ new Set(["ID", "VAT", "OCR", "PDF", "URL", "API", "HTML", "CSS", "JSON", "XML", "UUID"]);
|
|
87
259
|
function formatLabel(key) {
|
|
@@ -193,6 +365,7 @@ function escapeSegment(segment) {
|
|
|
193
365
|
var ROW_META_KEY = "_rowMeta";
|
|
194
366
|
function classifyData(data) {
|
|
195
367
|
const result = {
|
|
368
|
+
overallConfidence: null,
|
|
196
369
|
headers: [],
|
|
197
370
|
simpleLists: [],
|
|
198
371
|
entities: [],
|
|
@@ -203,6 +376,7 @@ function classifyData(data) {
|
|
|
203
376
|
return result;
|
|
204
377
|
}
|
|
205
378
|
let rootData = data;
|
|
379
|
+
result.overallConfidence = readOverallConfidence(rootData);
|
|
206
380
|
let basePointer = "";
|
|
207
381
|
if ("data" in rootData && typeof rootData.data === "object" && rootData.data !== null && !Array.isArray(rootData.data)) {
|
|
208
382
|
for (const [key, value] of Object.entries(rootData)) {
|
|
@@ -210,6 +384,7 @@ function classifyData(data) {
|
|
|
210
384
|
processField(key, value, result, rootData, "");
|
|
211
385
|
}
|
|
212
386
|
rootData = rootData.data;
|
|
387
|
+
result.overallConfidence ?? (result.overallConfidence = readOverallConfidence(rootData));
|
|
213
388
|
basePointer = "/data";
|
|
214
389
|
}
|
|
215
390
|
for (const [key, value] of Object.entries(rootData)) {
|
|
@@ -217,8 +392,23 @@ function classifyData(data) {
|
|
|
217
392
|
}
|
|
218
393
|
return result;
|
|
219
394
|
}
|
|
395
|
+
function readOverallConfidence(source) {
|
|
396
|
+
const rawLevel = source.overall_confidence ?? source.overallConfidence;
|
|
397
|
+
const value = extractValue(rawLevel);
|
|
398
|
+
if (typeof value !== "string" || value.length === 0) return null;
|
|
399
|
+
const rawReasons = source.confidence_reasons ?? source.confidenceReasons;
|
|
400
|
+
const reasons = Array.isArray(rawReasons) ? rawReasons.filter((reason) => typeof reason === "string") : [];
|
|
401
|
+
return { level: value, reasons };
|
|
402
|
+
}
|
|
220
403
|
function processField(key, value, result, parentObj, basePointer) {
|
|
221
|
-
if ([
|
|
404
|
+
if ([
|
|
405
|
+
"confidence",
|
|
406
|
+
"confidence_reasons",
|
|
407
|
+
"confidenceReasons",
|
|
408
|
+
"coordinates",
|
|
409
|
+
"overall_confidence",
|
|
410
|
+
"overallConfidence"
|
|
411
|
+
].includes(key)) {
|
|
222
412
|
return;
|
|
223
413
|
}
|
|
224
414
|
const pointer = `${basePointer}/${escapeSegment(key)}`;
|
|
@@ -292,11 +482,6 @@ function processField(key, value, result, parentObj, basePointer) {
|
|
|
292
482
|
level: parentObj[confidenceKey],
|
|
293
483
|
reasons: parentObj[reasonsKey] || []
|
|
294
484
|
};
|
|
295
|
-
} else if (parentObj["overall_confidence"]) {
|
|
296
|
-
overallConfidence = {
|
|
297
|
-
level: parentObj["overall_confidence"],
|
|
298
|
-
reasons: parentObj["confidence_reasons"] || []
|
|
299
|
-
};
|
|
300
485
|
}
|
|
301
486
|
}
|
|
302
487
|
result.tables.push({
|
|
@@ -403,6 +588,9 @@ function parseSchemaKey(raw) {
|
|
|
403
588
|
return { raw, label: match[1], pointer: match[2] };
|
|
404
589
|
}
|
|
405
590
|
var NOT_FOUND = /* @__PURE__ */ Symbol("gemina-verification-not-found");
|
|
591
|
+
function snakeToCamel(segment) {
|
|
592
|
+
return segment.replace(/_([a-zA-Z0-9])/g, (_unused, ch) => ch.toUpperCase());
|
|
593
|
+
}
|
|
406
594
|
|
|
407
595
|
// src/verification/bindings.ts
|
|
408
596
|
function unescapeSegment(raw) {
|
|
@@ -411,9 +599,6 @@ function unescapeSegment(raw) {
|
|
|
411
599
|
function escapeSegment2(segment) {
|
|
412
600
|
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
413
601
|
}
|
|
414
|
-
function snakeToCamel(segment) {
|
|
415
|
-
return segment.replace(/_([a-zA-Z0-9])/g, (_, ch) => ch.toUpperCase());
|
|
416
|
-
}
|
|
417
602
|
function camelizePointer(pointer) {
|
|
418
603
|
if (!pointer.startsWith("/")) {
|
|
419
604
|
return pointer;
|
|
@@ -464,7 +649,13 @@ function resolveCasingAware(doc, pointer) {
|
|
|
464
649
|
function stripValueSuffix(pointer) {
|
|
465
650
|
return pointer.endsWith("/value") ? pointer.slice(0, -"/value".length) : pointer;
|
|
466
651
|
}
|
|
467
|
-
function buildBindings(validationSchema, values) {
|
|
652
|
+
function buildBindings(validationSchema, values, fields) {
|
|
653
|
+
const descriptors = /* @__PURE__ */ new Map();
|
|
654
|
+
for (const descriptor of fields ?? []) {
|
|
655
|
+
if (typeof descriptor?.key === "string") {
|
|
656
|
+
descriptors.set(descriptor.key, descriptor);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
468
659
|
const bindings = [];
|
|
469
660
|
for (const raw of validationSchema) {
|
|
470
661
|
const key = parseSchemaKey(raw);
|
|
@@ -479,7 +670,8 @@ function buildBindings(validationSchema, values) {
|
|
|
479
670
|
serverValue,
|
|
480
671
|
extracted,
|
|
481
672
|
fieldPointer: stripValueSuffix(resolvedPointer),
|
|
482
|
-
editable
|
|
673
|
+
editable,
|
|
674
|
+
field: descriptors.get(key.raw)
|
|
483
675
|
});
|
|
484
676
|
}
|
|
485
677
|
return bindings;
|
|
@@ -500,39 +692,359 @@ function toInputString(extracted) {
|
|
|
500
692
|
}
|
|
501
693
|
return String(extracted);
|
|
502
694
|
}
|
|
503
|
-
function composeSubmission(bindings, edits) {
|
|
695
|
+
function composeSubmission(bindings, edits, options = {}) {
|
|
696
|
+
const cells = options.cells ?? bindings.map((binding) => ({
|
|
697
|
+
editKey: binding.key.raw,
|
|
698
|
+
submitKey: binding.key.raw,
|
|
699
|
+
column: binding.key.label,
|
|
700
|
+
rowKey: binding.key.raw,
|
|
701
|
+
binding,
|
|
702
|
+
added: false
|
|
703
|
+
}));
|
|
504
704
|
const data = {};
|
|
505
705
|
const byLabel = {};
|
|
506
706
|
let confirmed = 0;
|
|
507
707
|
let corrected = 0;
|
|
508
|
-
for (const
|
|
509
|
-
const
|
|
708
|
+
for (const cell of cells) {
|
|
709
|
+
const { binding } = cell;
|
|
710
|
+
const label = parseSchemaKey(cell.submitKey)?.label ?? binding.key.label;
|
|
711
|
+
const edit = edits.get(cell.editKey);
|
|
510
712
|
if (edit !== void 0) {
|
|
511
713
|
const trimmed = edit.trim();
|
|
512
714
|
if (trimmed === "" && binding.serverValue === NOT_FOUND) {
|
|
513
715
|
continue;
|
|
514
716
|
}
|
|
515
|
-
const value = trimmed === "" ? null : trimmed;
|
|
516
|
-
data[
|
|
517
|
-
byLabel[
|
|
717
|
+
const value = trimmed === "" ? null : coerceInput(trimmed, binding.field);
|
|
718
|
+
data[cell.submitKey] = value;
|
|
719
|
+
byLabel[label] = value;
|
|
518
720
|
corrected += 1;
|
|
519
721
|
} else {
|
|
520
722
|
if (binding.serverValue === NOT_FOUND) {
|
|
521
723
|
continue;
|
|
522
724
|
}
|
|
523
|
-
data[
|
|
524
|
-
byLabel[
|
|
725
|
+
data[cell.submitKey] = binding.serverValue;
|
|
726
|
+
byLabel[label] = binding.serverValue;
|
|
525
727
|
confirmed += 1;
|
|
526
728
|
}
|
|
527
729
|
}
|
|
528
|
-
return { data, byLabel, confirmed, corrected };
|
|
730
|
+
return { data, byLabel, confirmed, corrected, rowSources: options.rowSources ?? [] };
|
|
731
|
+
}
|
|
732
|
+
function countRowsAt(values, pointer) {
|
|
733
|
+
const { node } = resolveCasingAware(values, pointer);
|
|
734
|
+
return Array.isArray(node) ? node.length : 0;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// src/verification/row-plan.ts
|
|
738
|
+
var addedRowCounter = 0;
|
|
739
|
+
function initialRowPlan(extractedCount, scope = "") {
|
|
740
|
+
return Array.from({ length: Math.max(0, extractedCount) }, (_unused, index) => ({
|
|
741
|
+
// Derived from the source index, so it is stable across re-renders without
|
|
742
|
+
// any state to carry — an extracted row's identity never changes.
|
|
743
|
+
id: `${scope}#row-${index}`,
|
|
744
|
+
source: index
|
|
745
|
+
}));
|
|
746
|
+
}
|
|
747
|
+
function nextAddedRowId(scope = "") {
|
|
748
|
+
addedRowCounter += 1;
|
|
749
|
+
return `${scope}#added-${addedRowCounter}`;
|
|
750
|
+
}
|
|
751
|
+
function removeRow(plan, position) {
|
|
752
|
+
if (position < 0 || position >= plan.length) {
|
|
753
|
+
return plan;
|
|
754
|
+
}
|
|
755
|
+
return plan.filter((_entry, index) => index !== position);
|
|
756
|
+
}
|
|
757
|
+
function insertRowAfter(plan, position, id) {
|
|
758
|
+
const added = { id: id ?? nextAddedRowId(), source: null };
|
|
759
|
+
const at = Math.min(Math.max(position + 1, 0), plan.length);
|
|
760
|
+
return [...plan.slice(0, at), added, ...plan.slice(at)];
|
|
761
|
+
}
|
|
762
|
+
function cellEditKey(rowId, column) {
|
|
763
|
+
return `cell:${rowId}|col:${column}`;
|
|
764
|
+
}
|
|
765
|
+
function rowSourcesOf(plan) {
|
|
766
|
+
return plan.map((entry) => entry.source);
|
|
767
|
+
}
|
|
768
|
+
function isIdentityPlan(plan, extractedCount) {
|
|
769
|
+
return plan.length === extractedCount && plan.every((entry, index) => entry.source === index);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
// src/verification/row-cells.ts
|
|
773
|
+
function syntheticBinding(submitKey, descriptor) {
|
|
774
|
+
const key = parseSchemaKey(submitKey);
|
|
775
|
+
if (key === null) {
|
|
776
|
+
return null;
|
|
777
|
+
}
|
|
778
|
+
return {
|
|
779
|
+
key,
|
|
780
|
+
serverValue: NOT_FOUND,
|
|
781
|
+
extracted: NOT_FOUND,
|
|
782
|
+
// No extracted node, so nothing to point at on the document.
|
|
783
|
+
fieldPointer: key.pointer,
|
|
784
|
+
editable: true,
|
|
785
|
+
field: descriptor
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function planTableCells(table, plan, columns, bindingsByRawKey) {
|
|
789
|
+
const descriptors = /* @__PURE__ */ new Map();
|
|
790
|
+
for (const column of table.columns) {
|
|
791
|
+
if (typeof column.key === "string") {
|
|
792
|
+
descriptors.set(column.key, column);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
return plan.map((entry, submittedIndex) => {
|
|
796
|
+
const cells = [];
|
|
797
|
+
for (const column of columns) {
|
|
798
|
+
const submitKey = cellSchemaKey(table.keyTemplate, submittedIndex, column);
|
|
799
|
+
const editKey = cellEditKey(entry.id, column);
|
|
800
|
+
const extractedKey = entry.source === null ? null : cellSchemaKey(table.keyTemplate, entry.source, column);
|
|
801
|
+
const existing = extractedKey === null ? void 0 : bindingsByRawKey.get(extractedKey);
|
|
802
|
+
const binding = existing ?? syntheticBinding(submitKey, descriptors.get(column));
|
|
803
|
+
if (binding === null) {
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
cells.push({ column, editKey, submitKey, binding, added: existing === void 0 });
|
|
807
|
+
}
|
|
808
|
+
return { entry, cells };
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
function displayColumns(table, classifiedColumns) {
|
|
812
|
+
const declared = table.columns.map((column) => column.key).filter((name) => typeof name === "string");
|
|
813
|
+
const declaredAliases = new Set(declared.map(snakeToCamel));
|
|
814
|
+
return [
|
|
815
|
+
...declared,
|
|
816
|
+
...classifiedColumns.filter((name) => !declaredAliases.has(snakeToCamel(name)))
|
|
817
|
+
];
|
|
818
|
+
}
|
|
819
|
+
function matchesTablePointer(serverPointer, classifiedPointer) {
|
|
820
|
+
return serverPointer === classifiedPointer || snakeToCamel(serverPointer) === classifiedPointer;
|
|
821
|
+
}
|
|
822
|
+
function splitPointer(pointer) {
|
|
823
|
+
const cut = pointer.lastIndexOf("/");
|
|
824
|
+
return cut <= 0 ? null : { row: pointer.slice(0, cut), field: pointer.slice(cut + 1) };
|
|
825
|
+
}
|
|
826
|
+
function collectCellViews(bindings, plannedTables) {
|
|
827
|
+
const views = [];
|
|
828
|
+
const ownedPrefixes = [...plannedTables.keys()].map((pointer) => `${pointer}/`);
|
|
829
|
+
for (const rows of plannedTables.values()) {
|
|
830
|
+
for (const row of rows) {
|
|
831
|
+
for (const cell of row.cells) {
|
|
832
|
+
views.push({
|
|
833
|
+
editKey: cell.editKey,
|
|
834
|
+
submitKey: cell.submitKey,
|
|
835
|
+
column: cell.column,
|
|
836
|
+
rowKey: row.entry.id,
|
|
837
|
+
binding: cell.binding,
|
|
838
|
+
added: cell.added
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
for (const binding of bindings) {
|
|
844
|
+
if (ownedPrefixes.some((prefix) => binding.key.pointer.startsWith(prefix))) {
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
const split = splitPointer(binding.key.pointer);
|
|
848
|
+
views.push({
|
|
849
|
+
// Outside a plan all three identities coincide, which is why none of
|
|
850
|
+
// this was needed before row editing.
|
|
851
|
+
editKey: binding.key.raw,
|
|
852
|
+
submitKey: binding.key.raw,
|
|
853
|
+
column: split?.field ?? binding.key.label,
|
|
854
|
+
rowKey: split?.row ?? binding.key.raw,
|
|
855
|
+
binding,
|
|
856
|
+
added: false
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
return views;
|
|
860
|
+
}
|
|
861
|
+
var UNIT_SIZE = "unit_size";
|
|
862
|
+
var UNIT_SIZE_UOM = "unit_size_uom";
|
|
863
|
+
var UNIT_PAIR_MESSAGE = "Enter both value and unit";
|
|
864
|
+
function unitSizePairErrors(cells, edits) {
|
|
865
|
+
const rows = /* @__PURE__ */ new Map();
|
|
866
|
+
for (const cell of cells) {
|
|
867
|
+
if (cell.column !== UNIT_SIZE && cell.column !== UNIT_SIZE_UOM) {
|
|
868
|
+
continue;
|
|
869
|
+
}
|
|
870
|
+
const row = rows.get(cell.rowKey) ?? {};
|
|
871
|
+
if (cell.column === UNIT_SIZE) {
|
|
872
|
+
row.size = cell;
|
|
873
|
+
} else {
|
|
874
|
+
row.uom = cell;
|
|
875
|
+
}
|
|
876
|
+
rows.set(cell.rowKey, row);
|
|
877
|
+
}
|
|
878
|
+
const errors = /* @__PURE__ */ new Map();
|
|
879
|
+
for (const { size, uom } of rows.values()) {
|
|
880
|
+
if (!size || !uom) {
|
|
881
|
+
continue;
|
|
882
|
+
}
|
|
883
|
+
const filled = (cell) => (edits.get(cell.editKey) ?? toInputString(cell.binding.extracted)).trim() !== "";
|
|
884
|
+
if (filled(size) !== filled(uom)) {
|
|
885
|
+
errors.set(size.editKey, UNIT_PAIR_MESSAGE);
|
|
886
|
+
errors.set(uom.editKey, UNIT_PAIR_MESSAGE);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return errors;
|
|
890
|
+
}
|
|
891
|
+
function pruneEmptyAddedRows(plannedTables, edits) {
|
|
892
|
+
const out = /* @__PURE__ */ new Map();
|
|
893
|
+
for (const [pointer, rows] of plannedTables) {
|
|
894
|
+
out.set(pointer, rows.filter((row) => {
|
|
895
|
+
if (row.entry.source !== null) {
|
|
896
|
+
return true;
|
|
897
|
+
}
|
|
898
|
+
return row.cells.some((cell) => (edits.get(cell.editKey) ?? "").trim() !== "");
|
|
899
|
+
}));
|
|
900
|
+
}
|
|
901
|
+
return out;
|
|
529
902
|
}
|
|
530
903
|
|
|
531
904
|
// src/verification/form.tsx
|
|
532
|
-
var
|
|
905
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
533
906
|
|
|
534
|
-
// src/verification/
|
|
907
|
+
// src/verification/tip.tsx
|
|
535
908
|
var import_react = require("react");
|
|
909
|
+
var import_react_dom = require("react-dom");
|
|
910
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
911
|
+
var GAP = 8;
|
|
912
|
+
var MARGIN = 8;
|
|
913
|
+
function isEmpty(content) {
|
|
914
|
+
return content == null || content === "" || content === false;
|
|
915
|
+
}
|
|
916
|
+
function rootClassesOf(node) {
|
|
917
|
+
const root = node?.closest(".gemina-verification");
|
|
918
|
+
return root ? root.className : "gemina-verification";
|
|
919
|
+
}
|
|
920
|
+
function mergeRefs(ours, theirs) {
|
|
921
|
+
return (value) => {
|
|
922
|
+
ours(value);
|
|
923
|
+
if (typeof theirs === "function") {
|
|
924
|
+
theirs(value);
|
|
925
|
+
} else if (theirs && typeof theirs === "object") {
|
|
926
|
+
theirs.current = value;
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
function Tip({ content, children }) {
|
|
931
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
932
|
+
const [position, setPosition] = (0, import_react.useState)(null);
|
|
933
|
+
const [rootClasses, setRootClasses] = (0, import_react.useState)("gemina-verification");
|
|
934
|
+
const triggerRef = (0, import_react.useRef)(null);
|
|
935
|
+
const tipRef = (0, import_react.useRef)(null);
|
|
936
|
+
const id = (0, import_react.useId)();
|
|
937
|
+
const empty = isEmpty(content);
|
|
938
|
+
const show = (0, import_react.useCallback)(() => {
|
|
939
|
+
if (empty) {
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
setRootClasses(rootClassesOf(triggerRef.current));
|
|
943
|
+
setPosition(null);
|
|
944
|
+
setOpen(true);
|
|
945
|
+
}, [empty]);
|
|
946
|
+
const hide = (0, import_react.useCallback)(() => setOpen(false), []);
|
|
947
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
948
|
+
if (!open) {
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
const trigger2 = triggerRef.current;
|
|
952
|
+
const tip = tipRef.current;
|
|
953
|
+
if (!trigger2 || !tip) {
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
const anchor = trigger2.getBoundingClientRect();
|
|
957
|
+
const bubble = tip.getBoundingClientRect();
|
|
958
|
+
const viewportWidth = window.innerWidth || 0;
|
|
959
|
+
const viewportHeight = window.innerHeight || 0;
|
|
960
|
+
const fitsAbove = anchor.top - bubble.height - GAP >= MARGIN;
|
|
961
|
+
const fitsBelow = anchor.bottom + bubble.height + GAP <= viewportHeight - MARGIN;
|
|
962
|
+
const top = fitsAbove || !fitsBelow ? anchor.top - bubble.height - GAP : anchor.bottom + GAP;
|
|
963
|
+
const centred = anchor.left + anchor.width / 2 - bubble.width / 2;
|
|
964
|
+
const rightLimit = Math.max(MARGIN, viewportWidth - bubble.width - MARGIN);
|
|
965
|
+
const left = Math.min(Math.max(centred, MARGIN), rightLimit);
|
|
966
|
+
setPosition({ top: Math.max(top, MARGIN), left });
|
|
967
|
+
}, [open, content]);
|
|
968
|
+
(0, import_react.useEffect)(() => {
|
|
969
|
+
if (!open) {
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
const onKeyDown = (event) => {
|
|
973
|
+
if (event.key === "Escape") {
|
|
974
|
+
hide();
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
const onScrollOrResize = () => hide();
|
|
978
|
+
document.addEventListener("keydown", onKeyDown);
|
|
979
|
+
document.addEventListener("scroll", onScrollOrResize, true);
|
|
980
|
+
window.addEventListener("resize", onScrollOrResize);
|
|
981
|
+
return () => {
|
|
982
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
983
|
+
document.removeEventListener("scroll", onScrollOrResize, true);
|
|
984
|
+
window.removeEventListener("resize", onScrollOrResize);
|
|
985
|
+
};
|
|
986
|
+
}, [open, hide]);
|
|
987
|
+
if (!(0, import_react.isValidElement)(children)) {
|
|
988
|
+
return children;
|
|
989
|
+
}
|
|
990
|
+
const childProps = children.props;
|
|
991
|
+
const call = (name, event) => {
|
|
992
|
+
const handler = childProps[name];
|
|
993
|
+
if (typeof handler === "function") {
|
|
994
|
+
handler(event);
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
const trigger = (0, import_react.cloneElement)(children, {
|
|
998
|
+
ref: mergeRefs((node) => {
|
|
999
|
+
triggerRef.current = node;
|
|
1000
|
+
}, children.ref),
|
|
1001
|
+
// The tip is a DESCRIPTION. `aria-label` stays untouched — it already
|
|
1002
|
+
// carries the reason into the accessible NAME, and duplicating it here
|
|
1003
|
+
// would have a screen reader announce it twice.
|
|
1004
|
+
"aria-describedby": open && !empty ? id : void 0,
|
|
1005
|
+
onMouseEnter: (event) => {
|
|
1006
|
+
call("onMouseEnter", event);
|
|
1007
|
+
show();
|
|
1008
|
+
},
|
|
1009
|
+
onMouseLeave: (event) => {
|
|
1010
|
+
call("onMouseLeave", event);
|
|
1011
|
+
hide();
|
|
1012
|
+
},
|
|
1013
|
+
onFocus: (event) => {
|
|
1014
|
+
call("onFocus", event);
|
|
1015
|
+
show();
|
|
1016
|
+
},
|
|
1017
|
+
onBlur: (event) => {
|
|
1018
|
+
call("onBlur", event);
|
|
1019
|
+
hide();
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
1022
|
+
const canPortal = typeof document !== "undefined" && document.body;
|
|
1023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1024
|
+
trigger,
|
|
1025
|
+
open && !empty && canPortal ? (0, import_react_dom.createPortal)(
|
|
1026
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: rootClasses, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1027
|
+
"div",
|
|
1028
|
+
{
|
|
1029
|
+
ref: tipRef,
|
|
1030
|
+
id,
|
|
1031
|
+
role: "tooltip",
|
|
1032
|
+
className: "gemina-verification__tip",
|
|
1033
|
+
style: {
|
|
1034
|
+
top: position ? `${position.top}px` : "0px",
|
|
1035
|
+
left: position ? `${position.left}px` : "0px",
|
|
1036
|
+
visibility: position ? "visible" : "hidden"
|
|
1037
|
+
},
|
|
1038
|
+
children: content
|
|
1039
|
+
}
|
|
1040
|
+
) }),
|
|
1041
|
+
document.body
|
|
1042
|
+
) : null
|
|
1043
|
+
] });
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
// src/verification/viewer.tsx
|
|
1047
|
+
var import_react2 = require("react");
|
|
536
1048
|
|
|
537
1049
|
// src/verification/viewer-math.ts
|
|
538
1050
|
function fitScaleFor(natural, container, rotationDeg) {
|
|
@@ -614,9 +1126,9 @@ function flashZoomTarget(rects, natural, container, rotationDeg, fitScale) {
|
|
|
614
1126
|
var easeOutCubic = (t) => 1 - Math.pow(1 - t, 3);
|
|
615
1127
|
|
|
616
1128
|
// src/verification/viewer.tsx
|
|
617
|
-
var
|
|
1129
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
618
1130
|
function IconBase({ children }) {
|
|
619
|
-
return /* @__PURE__ */ (0,
|
|
1131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
620
1132
|
"svg",
|
|
621
1133
|
{
|
|
622
1134
|
width: "16",
|
|
@@ -634,56 +1146,56 @@ function IconBase({ children }) {
|
|
|
634
1146
|
);
|
|
635
1147
|
}
|
|
636
1148
|
function GlassBody() {
|
|
637
|
-
return /* @__PURE__ */ (0,
|
|
638
|
-
/* @__PURE__ */ (0,
|
|
639
|
-
/* @__PURE__ */ (0,
|
|
1149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1150
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "6.75", cy: "6.75", r: "4.25" }),
|
|
1151
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "9.9", y1: "9.9", x2: "13.5", y2: "13.5" })
|
|
640
1152
|
] });
|
|
641
1153
|
}
|
|
642
1154
|
function IconZoomIn() {
|
|
643
|
-
return /* @__PURE__ */ (0,
|
|
644
|
-
/* @__PURE__ */ (0,
|
|
645
|
-
/* @__PURE__ */ (0,
|
|
646
|
-
/* @__PURE__ */ (0,
|
|
1155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(IconBase, { children: [
|
|
1156
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GlassBody, {}),
|
|
1157
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "4.9", y1: "6.75", x2: "8.6", y2: "6.75" }),
|
|
1158
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "6.75", y1: "4.9", x2: "6.75", y2: "8.6" })
|
|
647
1159
|
] });
|
|
648
1160
|
}
|
|
649
1161
|
function IconZoomOut() {
|
|
650
|
-
return /* @__PURE__ */ (0,
|
|
651
|
-
/* @__PURE__ */ (0,
|
|
652
|
-
/* @__PURE__ */ (0,
|
|
1162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(IconBase, { children: [
|
|
1163
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GlassBody, {}),
|
|
1164
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "4.9", y1: "6.75", x2: "8.6", y2: "6.75" })
|
|
653
1165
|
] });
|
|
654
1166
|
}
|
|
655
1167
|
function IconMagnifier() {
|
|
656
|
-
return /* @__PURE__ */ (0,
|
|
1168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconBase, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GlassBody, {}) });
|
|
657
1169
|
}
|
|
658
1170
|
function IconActualSize() {
|
|
659
|
-
return /* @__PURE__ */ (0,
|
|
660
|
-
/* @__PURE__ */ (0,
|
|
661
|
-
/* @__PURE__ */ (0,
|
|
662
|
-
/* @__PURE__ */ (0,
|
|
663
|
-
/* @__PURE__ */ (0,
|
|
1171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(IconBase, { children: [
|
|
1172
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "2.8 6.2 4 5 4 11" }),
|
|
1173
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "10.8 6.2 12 5 12 11" }),
|
|
1174
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "8", cy: "6.75", r: "0.8", fill: "currentColor", stroke: "none" }),
|
|
1175
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "8", cy: "9.25", r: "0.8", fill: "currentColor", stroke: "none" })
|
|
664
1176
|
] });
|
|
665
1177
|
}
|
|
666
1178
|
function IconFit() {
|
|
667
|
-
return /* @__PURE__ */ (0,
|
|
668
|
-
/* @__PURE__ */ (0,
|
|
669
|
-
/* @__PURE__ */ (0,
|
|
670
|
-
/* @__PURE__ */ (0,
|
|
671
|
-
/* @__PURE__ */ (0,
|
|
1179
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(IconBase, { children: [
|
|
1180
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "13.8", y1: "2.2", x2: "9.6", y2: "6.4" }),
|
|
1181
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "9.6 3.9 9.6 6.4 12.1 6.4" }),
|
|
1182
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "2.2", y1: "13.8", x2: "6.4", y2: "9.6" }),
|
|
1183
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "6.4 12.1 6.4 9.6 3.9 9.6" })
|
|
672
1184
|
] });
|
|
673
1185
|
}
|
|
674
1186
|
function IconRotate() {
|
|
675
|
-
return /* @__PURE__ */ (0,
|
|
676
|
-
/* @__PURE__ */ (0,
|
|
677
|
-
/* @__PURE__ */ (0,
|
|
1187
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(IconBase, { children: [
|
|
1188
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M11.83 4.79A5 5 0 1 1 8 3" }),
|
|
1189
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "6 1.7 8 3 6 4.3" })
|
|
678
1190
|
] });
|
|
679
1191
|
}
|
|
680
1192
|
function IconOverlay() {
|
|
681
|
-
return /* @__PURE__ */ (0,
|
|
1193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconBase, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "2.75", y: "2.75", width: "10.5", height: "10.5", rx: "1.5", strokeDasharray: "3 2.2" }) });
|
|
682
1194
|
}
|
|
683
1195
|
function IconEye() {
|
|
684
|
-
return /* @__PURE__ */ (0,
|
|
685
|
-
/* @__PURE__ */ (0,
|
|
686
|
-
/* @__PURE__ */ (0,
|
|
1196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(IconBase, { children: [
|
|
1197
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8s-2.4 4.5-6.5 4.5S1.5 8 1.5 8z" }),
|
|
1198
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "8", cy: "8", r: "2.1" })
|
|
687
1199
|
] });
|
|
688
1200
|
}
|
|
689
1201
|
function ToolbarButton({
|
|
@@ -695,12 +1207,11 @@ function ToolbarButton({
|
|
|
695
1207
|
children
|
|
696
1208
|
}) {
|
|
697
1209
|
const active = (pressed ?? checked) === true;
|
|
698
|
-
return /* @__PURE__ */ (0,
|
|
1210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Tip, { content: label, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
699
1211
|
"button",
|
|
700
1212
|
{
|
|
701
1213
|
type: "button",
|
|
702
1214
|
className: active ? "gemina-verification__toolbar-btn gemina-verification__toolbar-btn--active" : "gemina-verification__toolbar-btn",
|
|
703
|
-
title: label,
|
|
704
1215
|
"aria-label": label,
|
|
705
1216
|
role: checked === void 0 ? void 0 : "switch",
|
|
706
1217
|
"aria-checked": checked,
|
|
@@ -709,7 +1220,7 @@ function ToolbarButton({
|
|
|
709
1220
|
onClick,
|
|
710
1221
|
children
|
|
711
1222
|
}
|
|
712
|
-
);
|
|
1223
|
+
) });
|
|
713
1224
|
}
|
|
714
1225
|
var ZOOM_STEP = 1.2;
|
|
715
1226
|
var IDENTITY = { scale: 1, tx: 0, ty: 0 };
|
|
@@ -719,6 +1230,7 @@ var REDUCED_MOTION_FLASH_MS = 800;
|
|
|
719
1230
|
var MIN_SIZE_RATIO = 8e-3;
|
|
720
1231
|
var MAG_RADIUS = 150;
|
|
721
1232
|
var MAG_ZOOM = 2.5;
|
|
1233
|
+
var MAG_BORDER = 2;
|
|
722
1234
|
function rectGeometry(rect, natural) {
|
|
723
1235
|
const xs = rect.points.map((point) => point[0]);
|
|
724
1236
|
const ys = rect.points.map((point) => point[1]);
|
|
@@ -736,29 +1248,30 @@ function rectGeometry(rect, natural) {
|
|
|
736
1248
|
}
|
|
737
1249
|
function VerificationViewer(props) {
|
|
738
1250
|
const { src, alt, relativeRects, flashRects, onFlashComplete, onImageExpired } = props;
|
|
739
|
-
const canvasRef = (0,
|
|
740
|
-
const imgRef = (0,
|
|
741
|
-
const [natural, setNatural] = (0,
|
|
742
|
-
const [container, setContainer] = (0,
|
|
743
|
-
const [transform, setTransform] = (0,
|
|
744
|
-
const [rotation, setRotation] = (0,
|
|
745
|
-
const [showRects, setShowRects] = (0,
|
|
746
|
-
const [magnifierOn, setMagnifierOn] = (0,
|
|
747
|
-
const [showMag, setShowMag] = (0,
|
|
748
|
-
const [mousePos, setMousePos] = (0,
|
|
749
|
-
const
|
|
750
|
-
const
|
|
751
|
-
const
|
|
752
|
-
const [
|
|
753
|
-
const
|
|
754
|
-
const
|
|
755
|
-
const
|
|
756
|
-
const
|
|
1251
|
+
const canvasRef = (0, import_react2.useRef)(null);
|
|
1252
|
+
const imgRef = (0, import_react2.useRef)(null);
|
|
1253
|
+
const [natural, setNatural] = (0, import_react2.useState)(null);
|
|
1254
|
+
const [container, setContainer] = (0, import_react2.useState)({ w: 0, h: 0 });
|
|
1255
|
+
const [transform, setTransform] = (0, import_react2.useState)(IDENTITY);
|
|
1256
|
+
const [rotation, setRotation] = (0, import_react2.useState)(0);
|
|
1257
|
+
const [showRects, setShowRects] = (0, import_react2.useState)(false);
|
|
1258
|
+
const [magnifierOn, setMagnifierOn] = (0, import_react2.useState)(false);
|
|
1259
|
+
const [showMag, setShowMag] = (0, import_react2.useState)(false);
|
|
1260
|
+
const [mousePos, setMousePos] = (0, import_react2.useState)({ x: 0, y: 0 });
|
|
1261
|
+
const lastMouseClientRef = (0, import_react2.useRef)(null);
|
|
1262
|
+
const [isPanning, setIsPanning] = (0, import_react2.useState)(false);
|
|
1263
|
+
const panStart = (0, import_react2.useRef)(null);
|
|
1264
|
+
const [flashOpacity, setFlashOpacity] = (0, import_react2.useState)(0);
|
|
1265
|
+
const [activeFlashRects, setActiveFlashRects] = (0, import_react2.useState)(null);
|
|
1266
|
+
const travelRafRef = (0, import_react2.useRef)(null);
|
|
1267
|
+
const fadeRafRef = (0, import_react2.useRef)(null);
|
|
1268
|
+
const reducedFlashTimeoutRef = (0, import_react2.useRef)(null);
|
|
1269
|
+
const transformRef = (0, import_react2.useRef)(transform);
|
|
757
1270
|
transformRef.current = transform;
|
|
758
|
-
const onFlashCompleteRef = (0,
|
|
1271
|
+
const onFlashCompleteRef = (0, import_react2.useRef)(onFlashComplete);
|
|
759
1272
|
onFlashCompleteRef.current = onFlashComplete;
|
|
760
|
-
const hasLoadedRef = (0,
|
|
761
|
-
(0,
|
|
1273
|
+
const hasLoadedRef = (0, import_react2.useRef)(false);
|
|
1274
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
762
1275
|
const el = canvasRef.current;
|
|
763
1276
|
if (!el) return;
|
|
764
1277
|
if (typeof ResizeObserver === "undefined") {
|
|
@@ -773,7 +1286,7 @@ function VerificationViewer(props) {
|
|
|
773
1286
|
ro.observe(el);
|
|
774
1287
|
return () => ro.disconnect();
|
|
775
1288
|
}, []);
|
|
776
|
-
const handleImgLoad = (0,
|
|
1289
|
+
const handleImgLoad = (0, import_react2.useCallback)(() => {
|
|
777
1290
|
const img = imgRef.current;
|
|
778
1291
|
if (!img) return;
|
|
779
1292
|
hasLoadedRef.current = true;
|
|
@@ -781,19 +1294,19 @@ function VerificationViewer(props) {
|
|
|
781
1294
|
const h = img.naturalHeight;
|
|
782
1295
|
setNatural((prev) => prev && prev.w === w && prev.h === h ? prev : { w, h });
|
|
783
1296
|
}, []);
|
|
784
|
-
(0,
|
|
1297
|
+
(0, import_react2.useEffect)(() => {
|
|
785
1298
|
hasLoadedRef.current = false;
|
|
786
1299
|
}, [src]);
|
|
787
|
-
const handleImgError = (0,
|
|
1300
|
+
const handleImgError = (0, import_react2.useCallback)(() => {
|
|
788
1301
|
if (!hasLoadedRef.current) return;
|
|
789
1302
|
hasLoadedRef.current = false;
|
|
790
1303
|
onImageExpired?.();
|
|
791
1304
|
}, [onImageExpired]);
|
|
792
|
-
const currentFitScale = (0,
|
|
1305
|
+
const currentFitScale = (0, import_react2.useCallback)(() => {
|
|
793
1306
|
if (!natural || !container.w || !container.h) return 1;
|
|
794
1307
|
return fitScaleFor(natural, container, rotation);
|
|
795
1308
|
}, [natural, container, rotation]);
|
|
796
|
-
(0,
|
|
1309
|
+
(0, import_react2.useEffect)(() => {
|
|
797
1310
|
if (!natural || !container.w || !container.h) return;
|
|
798
1311
|
const fit = fitScaleFor(natural, container, rotation);
|
|
799
1312
|
const { tx, ty } = centeredTranslation(natural, container, fit, rotation);
|
|
@@ -801,13 +1314,13 @@ function VerificationViewer(props) {
|
|
|
801
1314
|
(prev) => Math.abs(prev.scale - fit) < 1e-4 && prev.tx === tx && prev.ty === ty ? prev : { scale: fit, tx, ty }
|
|
802
1315
|
);
|
|
803
1316
|
}, [natural, container, rotation]);
|
|
804
|
-
const cancelFlashTravel = (0,
|
|
1317
|
+
const cancelFlashTravel = (0, import_react2.useCallback)(() => {
|
|
805
1318
|
if (travelRafRef.current !== null) {
|
|
806
1319
|
cancelAnimationFrame(travelRafRef.current);
|
|
807
1320
|
travelRafRef.current = null;
|
|
808
1321
|
}
|
|
809
1322
|
}, []);
|
|
810
|
-
const zoomBy = (0,
|
|
1323
|
+
const zoomBy = (0, import_react2.useCallback)(
|
|
811
1324
|
(factor) => {
|
|
812
1325
|
const node = canvasRef.current;
|
|
813
1326
|
if (!node || !natural) return;
|
|
@@ -820,9 +1333,9 @@ function VerificationViewer(props) {
|
|
|
820
1333
|
},
|
|
821
1334
|
[natural, rotation, currentFitScale, cancelFlashTravel]
|
|
822
1335
|
);
|
|
823
|
-
const handleZoomIn = (0,
|
|
824
|
-
const handleZoomOut = (0,
|
|
825
|
-
const zoomAtClientPoint = (0,
|
|
1336
|
+
const handleZoomIn = (0, import_react2.useCallback)(() => zoomBy(ZOOM_STEP), [zoomBy]);
|
|
1337
|
+
const handleZoomOut = (0, import_react2.useCallback)(() => zoomBy(1 / ZOOM_STEP), [zoomBy]);
|
|
1338
|
+
const zoomAtClientPoint = (0, import_react2.useCallback)(
|
|
826
1339
|
(factor, clientX, clientY) => {
|
|
827
1340
|
const node = canvasRef.current;
|
|
828
1341
|
if (!node || !natural) return;
|
|
@@ -834,7 +1347,7 @@ function VerificationViewer(props) {
|
|
|
834
1347
|
},
|
|
835
1348
|
[natural, rotation, currentFitScale]
|
|
836
1349
|
);
|
|
837
|
-
const handleWheel = (0,
|
|
1350
|
+
const handleWheel = (0, import_react2.useCallback)(
|
|
838
1351
|
(event) => {
|
|
839
1352
|
event.preventDefault();
|
|
840
1353
|
event.stopPropagation();
|
|
@@ -844,7 +1357,7 @@ function VerificationViewer(props) {
|
|
|
844
1357
|
},
|
|
845
1358
|
[zoomAtClientPoint, cancelFlashTravel]
|
|
846
1359
|
);
|
|
847
|
-
(0,
|
|
1360
|
+
(0, import_react2.useEffect)(() => {
|
|
848
1361
|
const node = canvasRef.current;
|
|
849
1362
|
if (!node) return;
|
|
850
1363
|
const listener = (event) => handleWheel(event);
|
|
@@ -852,7 +1365,7 @@ function VerificationViewer(props) {
|
|
|
852
1365
|
return () => node.removeEventListener("wheel", listener);
|
|
853
1366
|
}, [handleWheel]);
|
|
854
1367
|
const atFitScale = transform.scale <= currentFitScale() + 1e-3;
|
|
855
|
-
const handleMouseDown = (0,
|
|
1368
|
+
const handleMouseDown = (0, import_react2.useCallback)(
|
|
856
1369
|
(e) => {
|
|
857
1370
|
cancelFlashTravel();
|
|
858
1371
|
if (e.button !== 0) return;
|
|
@@ -863,7 +1376,7 @@ function VerificationViewer(props) {
|
|
|
863
1376
|
},
|
|
864
1377
|
[atFitScale, transform.tx, transform.ty, cancelFlashTravel]
|
|
865
1378
|
);
|
|
866
|
-
(0,
|
|
1379
|
+
(0, import_react2.useEffect)(() => {
|
|
867
1380
|
if (!isPanning) return;
|
|
868
1381
|
const onMove = (e) => {
|
|
869
1382
|
const start = panStart.current;
|
|
@@ -883,8 +1396,8 @@ function VerificationViewer(props) {
|
|
|
883
1396
|
document.removeEventListener("mouseup", onUp);
|
|
884
1397
|
};
|
|
885
1398
|
}, [isPanning]);
|
|
886
|
-
const touchState = (0,
|
|
887
|
-
const handleTouchStart = (0,
|
|
1399
|
+
const touchState = (0, import_react2.useRef)(null);
|
|
1400
|
+
const handleTouchStart = (0, import_react2.useCallback)(
|
|
888
1401
|
(e) => {
|
|
889
1402
|
cancelFlashTravel();
|
|
890
1403
|
const a = e.touches[0];
|
|
@@ -902,7 +1415,7 @@ function VerificationViewer(props) {
|
|
|
902
1415
|
},
|
|
903
1416
|
[atFitScale, transform.tx, transform.ty, cancelFlashTravel]
|
|
904
1417
|
);
|
|
905
|
-
const handleTouchMove = (0,
|
|
1418
|
+
const handleTouchMove = (0, import_react2.useCallback)(
|
|
906
1419
|
(e) => {
|
|
907
1420
|
const state = touchState.current;
|
|
908
1421
|
if (!state) return;
|
|
@@ -927,19 +1440,42 @@ function VerificationViewer(props) {
|
|
|
927
1440
|
},
|
|
928
1441
|
[zoomAtClientPoint]
|
|
929
1442
|
);
|
|
930
|
-
const handleTouchEnd = (0,
|
|
1443
|
+
const handleTouchEnd = (0, import_react2.useCallback)((e) => {
|
|
931
1444
|
if (e.touches.length === 0) touchState.current = null;
|
|
932
1445
|
}, []);
|
|
933
|
-
const
|
|
1446
|
+
const syncMagnifierToClientPoint = (0, import_react2.useCallback)((clientX, clientY, assumeInside = false) => {
|
|
934
1447
|
const rect = canvasRef.current?.getBoundingClientRect();
|
|
935
1448
|
if (!rect) return;
|
|
936
|
-
|
|
937
|
-
|
|
1449
|
+
const x = clientX - rect.left;
|
|
1450
|
+
const y = clientY - rect.top;
|
|
1451
|
+
const inside = assumeInside || x >= 0 && y >= 0 && x <= rect.width && y <= rect.height;
|
|
1452
|
+
setShowMag(inside);
|
|
1453
|
+
if (inside) {
|
|
1454
|
+
setMousePos({ x, y });
|
|
1455
|
+
}
|
|
938
1456
|
}, []);
|
|
939
|
-
const
|
|
1457
|
+
const handleCanvasMouseMove = (0, import_react2.useCallback)((e) => {
|
|
1458
|
+
lastMouseClientRef.current = { x: e.clientX, y: e.clientY };
|
|
1459
|
+
syncMagnifierToClientPoint(e.clientX, e.clientY, true);
|
|
1460
|
+
}, [syncMagnifierToClientPoint]);
|
|
1461
|
+
const handleCanvasMouseLeave = (0, import_react2.useCallback)(() => {
|
|
1462
|
+
lastMouseClientRef.current = null;
|
|
940
1463
|
setShowMag(false);
|
|
941
1464
|
}, []);
|
|
942
|
-
|
|
1465
|
+
(0, import_react2.useEffect)(() => {
|
|
1466
|
+
if (!magnifierOn || !showMag) return;
|
|
1467
|
+
const sync = () => {
|
|
1468
|
+
const point = lastMouseClientRef.current;
|
|
1469
|
+
if (point) syncMagnifierToClientPoint(point.x, point.y);
|
|
1470
|
+
};
|
|
1471
|
+
document.addEventListener("scroll", sync, true);
|
|
1472
|
+
window.addEventListener("resize", sync);
|
|
1473
|
+
return () => {
|
|
1474
|
+
document.removeEventListener("scroll", sync, true);
|
|
1475
|
+
window.removeEventListener("resize", sync);
|
|
1476
|
+
};
|
|
1477
|
+
}, [magnifierOn, showMag, syncMagnifierToClientPoint]);
|
|
1478
|
+
const handleDoubleClick = (0, import_react2.useCallback)(
|
|
943
1479
|
(e) => {
|
|
944
1480
|
cancelFlashTravel();
|
|
945
1481
|
if (!natural) return;
|
|
@@ -954,26 +1490,26 @@ function VerificationViewer(props) {
|
|
|
954
1490
|
},
|
|
955
1491
|
[natural, container, rotation, transform.scale, currentFitScale, zoomAtClientPoint, cancelFlashTravel]
|
|
956
1492
|
);
|
|
957
|
-
const handleFit = (0,
|
|
1493
|
+
const handleFit = (0, import_react2.useCallback)(() => {
|
|
958
1494
|
if (!natural) return;
|
|
959
1495
|
cancelFlashTravel();
|
|
960
1496
|
const fit = currentFitScale();
|
|
961
1497
|
setTransform({ scale: fit, ...centeredTranslation(natural, container, fit, rotation) });
|
|
962
1498
|
}, [natural, container, rotation, currentFitScale, cancelFlashTravel]);
|
|
963
|
-
const handleActualSize = (0,
|
|
1499
|
+
const handleActualSize = (0, import_react2.useCallback)(() => {
|
|
964
1500
|
if (!natural) return;
|
|
965
1501
|
cancelFlashTravel();
|
|
966
1502
|
const target = clampScale(1, currentFitScale());
|
|
967
1503
|
setTransform({ scale: target, ...centeredTranslation(natural, container, target, rotation) });
|
|
968
1504
|
}, [natural, container, rotation, currentFitScale, cancelFlashTravel]);
|
|
969
|
-
const handleRotate = (0,
|
|
1505
|
+
const handleRotate = (0, import_react2.useCallback)(() => {
|
|
970
1506
|
setRotation((r) => (r + 90) % 360);
|
|
971
1507
|
}, []);
|
|
972
1508
|
const hasRects = relativeRects !== void 0 && relativeRects.length > 0;
|
|
973
|
-
(0,
|
|
1509
|
+
(0, import_react2.useEffect)(() => {
|
|
974
1510
|
if (!hasRects) setShowRects(false);
|
|
975
1511
|
}, [hasRects]);
|
|
976
|
-
(0,
|
|
1512
|
+
(0, import_react2.useEffect)(() => {
|
|
977
1513
|
if (!flashRects || flashRects.length === 0 || !natural || !container.w || !container.h) {
|
|
978
1514
|
setActiveFlashRects((prev) => prev === null ? prev : null);
|
|
979
1515
|
setFlashOpacity(0);
|
|
@@ -1044,71 +1580,72 @@ function VerificationViewer(props) {
|
|
|
1044
1580
|
const dy = mousePos.y - transform.ty;
|
|
1045
1581
|
const cxRaw = (cosA * dx + sinA * dy) / transform.scale;
|
|
1046
1582
|
const cyRaw = (-sinA * dx + cosA * dy) / transform.scale;
|
|
1047
|
-
const
|
|
1048
|
-
const clampedY = Math.max(0, Math.min(cyRaw, natural.h));
|
|
1583
|
+
const onImage = cxRaw >= 0 && cyRaw >= 0 && cxRaw <= natural.w && cyRaw <= natural.h;
|
|
1049
1584
|
const zoomScale = transform.scale * MAG_ZOOM;
|
|
1050
|
-
const px =
|
|
1051
|
-
const py =
|
|
1585
|
+
const px = cxRaw * zoomScale;
|
|
1586
|
+
const py = cyRaw * zoomScale;
|
|
1052
1587
|
const rotatedX = px * cosA - py * sinA;
|
|
1053
1588
|
const rotatedY = px * sinA + py * cosA;
|
|
1054
|
-
const translateX = MAG_RADIUS - rotatedX;
|
|
1055
|
-
const translateY = MAG_RADIUS - rotatedY;
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1589
|
+
const translateX = MAG_RADIUS - MAG_BORDER - rotatedX;
|
|
1590
|
+
const translateY = MAG_RADIUS - MAG_BORDER - rotatedY;
|
|
1591
|
+
if (onImage) {
|
|
1592
|
+
magnifier = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1593
|
+
"div",
|
|
1594
|
+
{
|
|
1595
|
+
className: "gemina-verification__magnifier",
|
|
1596
|
+
style: {
|
|
1597
|
+
width: MAG_RADIUS * 2,
|
|
1598
|
+
height: MAG_RADIUS * 2,
|
|
1599
|
+
top: mousePos.y - MAG_RADIUS,
|
|
1600
|
+
left: mousePos.x - MAG_RADIUS
|
|
1601
|
+
},
|
|
1602
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1603
|
+
"img",
|
|
1604
|
+
{
|
|
1605
|
+
src,
|
|
1606
|
+
alt: "",
|
|
1607
|
+
draggable: false,
|
|
1608
|
+
style: {
|
|
1609
|
+
position: "absolute",
|
|
1610
|
+
width: natural.w,
|
|
1611
|
+
height: natural.h,
|
|
1612
|
+
transformOrigin: "0 0",
|
|
1613
|
+
transform: `translate(${translateX}px, ${translateY}px) rotate(${rotation}deg) scale(${zoomScale})`
|
|
1614
|
+
}
|
|
1078
1615
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1616
|
+
)
|
|
1617
|
+
}
|
|
1618
|
+
);
|
|
1619
|
+
}
|
|
1083
1620
|
}
|
|
1084
|
-
return /* @__PURE__ */ (0,
|
|
1085
|
-
/* @__PURE__ */ (0,
|
|
1086
|
-
/* @__PURE__ */ (0,
|
|
1087
|
-
/* @__PURE__ */ (0,
|
|
1088
|
-
/* @__PURE__ */ (0,
|
|
1089
|
-
/* @__PURE__ */ (0,
|
|
1090
|
-
/* @__PURE__ */ (0,
|
|
1091
|
-
/* @__PURE__ */ (0,
|
|
1621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gemina-verification__viewer", children: [
|
|
1622
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gemina-verification__toolbar", children: [
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ToolbarButton, { label: "Zoom out", onClick: handleZoomOut, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconZoomOut, {}) }),
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ToolbarButton, { label: "Zoom in", onClick: handleZoomIn, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconZoomIn, {}) }),
|
|
1625
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ToolbarButton, { label: "Actual size (100%)", onClick: handleActualSize, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconActualSize, {}) }),
|
|
1626
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ToolbarButton, { label: "Fit to screen", onClick: handleFit, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconFit, {}) }),
|
|
1627
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ToolbarButton, { label: "Rotate 90 degrees", onClick: handleRotate, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconRotate, {}) }),
|
|
1628
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1092
1629
|
ToolbarButton,
|
|
1093
1630
|
{
|
|
1094
1631
|
label: "Toggle detection overlays",
|
|
1095
1632
|
pressed: showRects,
|
|
1096
1633
|
disabled: !hasRects,
|
|
1097
1634
|
onClick: () => setShowRects((prev) => !prev),
|
|
1098
|
-
children: /* @__PURE__ */ (0,
|
|
1635
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconOverlay, {})
|
|
1099
1636
|
}
|
|
1100
1637
|
),
|
|
1101
|
-
/* @__PURE__ */ (0,
|
|
1638
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1102
1639
|
ToolbarButton,
|
|
1103
1640
|
{
|
|
1104
1641
|
label: "Magnifier",
|
|
1105
1642
|
checked: magnifierOn,
|
|
1106
1643
|
onClick: () => setMagnifierOn((prev) => !prev),
|
|
1107
|
-
children: /* @__PURE__ */ (0,
|
|
1644
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconMagnifier, {})
|
|
1108
1645
|
}
|
|
1109
1646
|
)
|
|
1110
1647
|
] }),
|
|
1111
|
-
/* @__PURE__ */ (0,
|
|
1648
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1112
1649
|
"div",
|
|
1113
1650
|
{
|
|
1114
1651
|
ref: canvasRef,
|
|
@@ -1125,7 +1662,7 @@ function VerificationViewer(props) {
|
|
|
1125
1662
|
onTouchEnd: handleTouchEnd,
|
|
1126
1663
|
onTouchCancel: handleTouchEnd,
|
|
1127
1664
|
children: [
|
|
1128
|
-
/* @__PURE__ */ (0,
|
|
1665
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1129
1666
|
"div",
|
|
1130
1667
|
{
|
|
1131
1668
|
style: {
|
|
@@ -1137,7 +1674,7 @@ function VerificationViewer(props) {
|
|
|
1137
1674
|
willChange: "transform,left,top"
|
|
1138
1675
|
},
|
|
1139
1676
|
children: [
|
|
1140
|
-
/* @__PURE__ */ (0,
|
|
1677
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1141
1678
|
"img",
|
|
1142
1679
|
{
|
|
1143
1680
|
ref: imgRef,
|
|
@@ -1151,13 +1688,13 @@ function VerificationViewer(props) {
|
|
|
1151
1688
|
showRects && natural && relativeRects?.map((rect, idx) => {
|
|
1152
1689
|
const geometry = rectGeometry(rect, natural);
|
|
1153
1690
|
if (!geometry) return null;
|
|
1154
|
-
return /* @__PURE__ */ (0,
|
|
1691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1155
1692
|
"div",
|
|
1156
1693
|
{
|
|
1157
1694
|
className: "gemina-verification__rect",
|
|
1158
1695
|
style: geometry,
|
|
1159
1696
|
"aria-hidden": "true",
|
|
1160
|
-
children: /* @__PURE__ */ (0,
|
|
1697
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "gemina-verification__rect-badge", children: [
|
|
1161
1698
|
"#",
|
|
1162
1699
|
idx + 1
|
|
1163
1700
|
] })
|
|
@@ -1168,7 +1705,7 @@ function VerificationViewer(props) {
|
|
|
1168
1705
|
activeFlashRects && natural && activeFlashRects.map((rect, idx) => {
|
|
1169
1706
|
const geometry = rectGeometry(rect, natural);
|
|
1170
1707
|
if (!geometry) return null;
|
|
1171
|
-
return /* @__PURE__ */ (0,
|
|
1708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1172
1709
|
"div",
|
|
1173
1710
|
{
|
|
1174
1711
|
className: "gemina-verification__flash-rect",
|
|
@@ -1189,7 +1726,7 @@ function VerificationViewer(props) {
|
|
|
1189
1726
|
}
|
|
1190
1727
|
|
|
1191
1728
|
// src/verification/form.tsx
|
|
1192
|
-
var
|
|
1729
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1193
1730
|
function ConfidenceDot(props) {
|
|
1194
1731
|
const { confidence } = props;
|
|
1195
1732
|
if (!confidence?.level) {
|
|
@@ -1215,93 +1752,156 @@ function ConfidenceDot(props) {
|
|
|
1215
1752
|
label = `${confidence.level} confidence`;
|
|
1216
1753
|
}
|
|
1217
1754
|
const reasons = confidence.reasons.map(formatLabel);
|
|
1218
|
-
const title = [label, ...reasons].join("\n");
|
|
1219
1755
|
const ariaLabel = reasons.length > 0 ? `${label}: ${reasons.join(", ")}` : label;
|
|
1220
|
-
|
|
1756
|
+
const tip = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1757
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { className: "gemina-verification__tip-title", children: label }),
|
|
1758
|
+
reasons.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ul", { className: "gemina-verification__tip-list", children: reasons.map((reason) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("li", { children: reason }, reason)) }) : null
|
|
1759
|
+
] });
|
|
1760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Tip, { content: tip, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1221
1761
|
"span",
|
|
1222
1762
|
{
|
|
1223
1763
|
className: `gemina-verification__dot gemina-verification__dot--${variant}`,
|
|
1224
1764
|
role: "img",
|
|
1225
|
-
"aria-label": ariaLabel
|
|
1226
|
-
title
|
|
1765
|
+
"aria-label": ariaLabel
|
|
1227
1766
|
}
|
|
1228
|
-
);
|
|
1767
|
+
) });
|
|
1229
1768
|
}
|
|
1230
1769
|
function EyeButton(props) {
|
|
1231
1770
|
const { coordinates, onFlash } = props;
|
|
1232
1771
|
if (!coordinates) {
|
|
1233
1772
|
return null;
|
|
1234
1773
|
}
|
|
1235
|
-
return /* @__PURE__ */ (0,
|
|
1774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Tip, { content: "Show on document", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1236
1775
|
"button",
|
|
1237
1776
|
{
|
|
1238
1777
|
type: "button",
|
|
1239
1778
|
className: "gemina-verification__eye",
|
|
1240
|
-
title: "Show on document",
|
|
1241
1779
|
"aria-label": "Show on document",
|
|
1242
1780
|
onClick: (event) => {
|
|
1243
1781
|
event.stopPropagation();
|
|
1244
1782
|
onFlash();
|
|
1245
1783
|
},
|
|
1246
|
-
children: /* @__PURE__ */ (0,
|
|
1784
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconEye, {})
|
|
1247
1785
|
}
|
|
1248
|
-
);
|
|
1786
|
+
) });
|
|
1249
1787
|
}
|
|
1250
1788
|
function FieldInput(props) {
|
|
1251
|
-
const { binding, edit, onEdit, readOnly, ariaLabel } = props;
|
|
1252
|
-
const
|
|
1789
|
+
const { binding, edit, onEdit, readOnly, ariaLabel, pairError } = props;
|
|
1790
|
+
const editKey = props.editKey ?? binding.key.raw;
|
|
1791
|
+
const editedBadgeId = import_react3.default.useId();
|
|
1792
|
+
const errorId = import_react3.default.useId();
|
|
1793
|
+
const currencyListId = import_react3.default.useId();
|
|
1253
1794
|
if (readOnly || !binding.editable) {
|
|
1254
1795
|
const display = binding.extracted === NOT_FOUND ? null : binding.extracted;
|
|
1255
|
-
return /* @__PURE__ */ (0,
|
|
1796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: formatValue(display, binding.key.label) });
|
|
1256
1797
|
}
|
|
1257
1798
|
const dirty = edit !== void 0;
|
|
1258
1799
|
const missed = binding.serverValue === NOT_FOUND;
|
|
1800
|
+
const field = binding.field;
|
|
1801
|
+
const value = dirty ? edit : toInputString(binding.extracted);
|
|
1802
|
+
const error = pairError ?? (dirty ? validateInput(value, field) : null);
|
|
1259
1803
|
const className = [
|
|
1260
1804
|
"gemina-verification__input",
|
|
1261
1805
|
dirty ? "gemina-verification__input--dirty" : "",
|
|
1262
|
-
missed ? "gemina-verification__input--missed" : ""
|
|
1806
|
+
missed ? "gemina-verification__input--missed" : "",
|
|
1807
|
+
error ? "gemina-verification__input--invalid" : ""
|
|
1263
1808
|
].filter(Boolean).join(" ");
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1809
|
+
const describedBy = [dirty ? editedBadgeId : "", error ? errorId : ""].filter(Boolean).join(" ");
|
|
1810
|
+
const shared = {
|
|
1811
|
+
className,
|
|
1812
|
+
"aria-label": ariaLabel,
|
|
1813
|
+
"aria-describedby": describedBy || void 0,
|
|
1814
|
+
"aria-invalid": error ? true : void 0,
|
|
1815
|
+
onChange: (event) => onEdit(editKey, event.target.value, binding)
|
|
1816
|
+
};
|
|
1817
|
+
const roster = field?.enum && field.enum.length > 0 ? field.enum : null;
|
|
1818
|
+
const offRoster = roster && value !== "" && !roster.includes(value) ? value : null;
|
|
1819
|
+
const control = roster ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("select", { ...shared, value, dir: "auto", children: [
|
|
1820
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "", children: "\u2014" }),
|
|
1821
|
+
offRoster ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("option", { value: offRoster, children: [
|
|
1822
|
+
offRoster,
|
|
1823
|
+
" (as extracted)"
|
|
1824
|
+
] }) : null,
|
|
1825
|
+
roster.map((option) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: option, children: option }, option))
|
|
1826
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1827
|
+
"input",
|
|
1828
|
+
{
|
|
1829
|
+
...shared,
|
|
1830
|
+
type: field?.type === "date" ? "date" : "text",
|
|
1831
|
+
dir: "auto",
|
|
1832
|
+
value,
|
|
1833
|
+
inputMode: field?.type === "number" || field?.type === "integer" ? "decimal" : void 0,
|
|
1834
|
+
list: field?.format === "iso4217" ? currencyListId : void 0,
|
|
1835
|
+
placeholder: missed ? "Not detected \u2014 fill in if present" : void 0,
|
|
1836
|
+
autoComplete: "off"
|
|
1837
|
+
}
|
|
1838
|
+
);
|
|
1839
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1840
|
+
control,
|
|
1841
|
+
field?.format === "iso4217" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("datalist", { id: currencyListId, children: ISO_4217_CODES.map((code) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: code }, code)) }) : null,
|
|
1842
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "gemina-verification__field-error", id: errorId, role: "alert", children: error }) : null,
|
|
1843
|
+
dirty ? (
|
|
1844
|
+
// The badge is where the ORIGINAL belongs, now that the input holds
|
|
1845
|
+
// the edit — otherwise the extracted value is simply gone from the
|
|
1846
|
+
// screen the moment someone corrects it.
|
|
1847
|
+
//
|
|
1848
|
+
// Known limit: the badge is a non-focusable span, so this channel is
|
|
1849
|
+
// hover-only. AT is not worse off than before (nothing carried the
|
|
1850
|
+
// original previously), and the input's aria-describedby still names
|
|
1851
|
+
// the field as edited. Giving it a keyboard path needs a focusable
|
|
1852
|
+
// affordance, which belongs with the Phase 8 row work, not here.
|
|
1853
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1854
|
+
Tip,
|
|
1855
|
+
{
|
|
1856
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1857
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "gemina-verification__tip-label", children: "Was: " }),
|
|
1858
|
+
formatValue(
|
|
1859
|
+
binding.extracted === NOT_FOUND ? null : binding.extracted,
|
|
1860
|
+
binding.key.label
|
|
1861
|
+
)
|
|
1862
|
+
] }),
|
|
1863
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "gemina-verification__edited", id: editedBadgeId, children: "edited" })
|
|
1864
|
+
}
|
|
1865
|
+
)
|
|
1866
|
+
) : null
|
|
1280
1867
|
] });
|
|
1281
1868
|
}
|
|
1869
|
+
var NO_PAIR_ERRORS = /* @__PURE__ */ new Map();
|
|
1870
|
+
var NO_TABLES = [];
|
|
1871
|
+
var NO_PLANNED = /* @__PURE__ */ new Map();
|
|
1872
|
+
var NOOP_ROW = () => {
|
|
1873
|
+
};
|
|
1282
1874
|
function isInteractiveTarget(target) {
|
|
1283
1875
|
return target instanceof Element && target.closest("input, button, a, select, textarea") !== null;
|
|
1284
1876
|
}
|
|
1877
|
+
function FieldLabel(props) {
|
|
1878
|
+
const { label, description } = props;
|
|
1879
|
+
if (!description) {
|
|
1880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: label });
|
|
1881
|
+
}
|
|
1882
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Tip, { content: description, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "gemina-verification__label-described", tabIndex: 0, children: label }) });
|
|
1883
|
+
}
|
|
1285
1884
|
function FieldPair(props) {
|
|
1286
1885
|
const { label, ariaLabel, cell, shared } = props;
|
|
1287
1886
|
const binding = shared.bindingIndex.get(cell.pointer);
|
|
1288
|
-
return /* @__PURE__ */ (0,
|
|
1289
|
-
/* @__PURE__ */ (0,
|
|
1290
|
-
/* @__PURE__ */ (0,
|
|
1291
|
-
/* @__PURE__ */ (0,
|
|
1887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1888
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("dt", { className: "gemina-verification__dt", children: [
|
|
1889
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfidenceDot, { confidence: cell.confidence }),
|
|
1890
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FieldLabel, { label, description: binding?.field?.description })
|
|
1292
1891
|
] }),
|
|
1293
|
-
/* @__PURE__ */ (0,
|
|
1294
|
-
binding !== void 0 ? /* @__PURE__ */ (0,
|
|
1892
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("dd", { className: "gemina-verification__dd", children: [
|
|
1893
|
+
binding !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1295
1894
|
FieldInput,
|
|
1296
1895
|
{
|
|
1297
1896
|
binding,
|
|
1897
|
+
pairError: shared.pairErrors.get(binding.key.raw),
|
|
1298
1898
|
edit: shared.edits.get(binding.key.raw),
|
|
1299
1899
|
onEdit: shared.onEdit,
|
|
1300
1900
|
readOnly: shared.readOnly,
|
|
1301
1901
|
ariaLabel
|
|
1302
1902
|
}
|
|
1303
|
-
) : /* @__PURE__ */ (0,
|
|
1304
|
-
/* @__PURE__ */ (0,
|
|
1903
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: formatValue(cell.value, label) }),
|
|
1904
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1305
1905
|
EyeButton,
|
|
1306
1906
|
{
|
|
1307
1907
|
coordinates: cell.coordinates,
|
|
@@ -1320,10 +1920,10 @@ function HeaderSection(props) {
|
|
|
1320
1920
|
if (headers.length === 0 && simpleLists.length === 0) {
|
|
1321
1921
|
return null;
|
|
1322
1922
|
}
|
|
1323
|
-
return /* @__PURE__ */ (0,
|
|
1324
|
-
/* @__PURE__ */ (0,
|
|
1325
|
-
/* @__PURE__ */ (0,
|
|
1326
|
-
headers.map((field) => /* @__PURE__ */ (0,
|
|
1923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Details", children: [
|
|
1924
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__section-header", children: "Details" }),
|
|
1925
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("dl", { className: "gemina-verification__dl", children: [
|
|
1926
|
+
headers.map((field) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1327
1927
|
FieldPair,
|
|
1328
1928
|
{
|
|
1329
1929
|
label: formatLabel(field.key),
|
|
@@ -1333,23 +1933,24 @@ function HeaderSection(props) {
|
|
|
1333
1933
|
},
|
|
1334
1934
|
field.pointer
|
|
1335
1935
|
)),
|
|
1336
|
-
simpleLists.map((list) => /* @__PURE__ */ (0,
|
|
1337
|
-
/* @__PURE__ */ (0,
|
|
1338
|
-
/* @__PURE__ */ (0,
|
|
1936
|
+
simpleLists.map((list) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react3.default.Fragment, { children: [
|
|
1937
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dt", { className: "gemina-verification__dt", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: formatLabel(list.key) }) }),
|
|
1938
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { className: "gemina-verification__dd", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ul", { className: "gemina-verification__list", children: list.items.map((item, index) => {
|
|
1339
1939
|
const binding = shared.bindingIndex.get(item.pointer);
|
|
1340
|
-
return /* @__PURE__ */ (0,
|
|
1341
|
-
binding !== void 0 ? /* @__PURE__ */ (0,
|
|
1940
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { className: "gemina-verification__cell", children: [
|
|
1941
|
+
binding !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1342
1942
|
FieldInput,
|
|
1343
1943
|
{
|
|
1344
1944
|
binding,
|
|
1945
|
+
pairError: shared.pairErrors.get(binding.key.raw),
|
|
1345
1946
|
edit: shared.edits.get(binding.key.raw),
|
|
1346
1947
|
onEdit: shared.onEdit,
|
|
1347
1948
|
readOnly: shared.readOnly,
|
|
1348
1949
|
ariaLabel: `${formatLabel(list.key)} item ${index + 1}`
|
|
1349
1950
|
}
|
|
1350
|
-
) : /* @__PURE__ */ (0,
|
|
1351
|
-
/* @__PURE__ */ (0,
|
|
1352
|
-
/* @__PURE__ */ (0,
|
|
1951
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: formatValue(item.value) }),
|
|
1952
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfidenceDot, { confidence: item.confidence }),
|
|
1953
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1353
1954
|
EyeButton,
|
|
1354
1955
|
{
|
|
1355
1956
|
coordinates: item.coordinates,
|
|
@@ -1370,20 +1971,20 @@ function EntitySection(props) {
|
|
|
1370
1971
|
const { entity, shared } = props;
|
|
1371
1972
|
const label = formatLabel(entity.key);
|
|
1372
1973
|
const singular = label.replace(/s$/, "");
|
|
1373
|
-
return /* @__PURE__ */ (0,
|
|
1374
|
-
/* @__PURE__ */ (0,
|
|
1974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
|
|
1975
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__section-header", children: [
|
|
1375
1976
|
label,
|
|
1376
1977
|
" (",
|
|
1377
1978
|
entity.items.length,
|
|
1378
1979
|
")"
|
|
1379
1980
|
] }),
|
|
1380
|
-
/* @__PURE__ */ (0,
|
|
1381
|
-
/* @__PURE__ */ (0,
|
|
1981
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__section-body", children: entity.items.map((item, itemIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__card", children: [
|
|
1982
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__card-header", children: [
|
|
1382
1983
|
singular,
|
|
1383
1984
|
" ",
|
|
1384
1985
|
itemIndex + 1
|
|
1385
1986
|
] }),
|
|
1386
|
-
/* @__PURE__ */ (0,
|
|
1987
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dl", { className: "gemina-verification__dl", children: Object.entries(item).map(([fieldKey, cell]) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1387
1988
|
FieldPair,
|
|
1388
1989
|
{
|
|
1389
1990
|
label: formatLabel(fieldKey),
|
|
@@ -1397,18 +1998,18 @@ function EntitySection(props) {
|
|
|
1397
1998
|
] });
|
|
1398
1999
|
}
|
|
1399
2000
|
function TableRowView(props) {
|
|
1400
|
-
const { row, rowIndex, columns, tableLabel, hasCoords, hasRowConfidence, shared } = props;
|
|
2001
|
+
const { row, rowIndex, columns, tableLabel, hasCoords, hasRowConfidence, shared, planned, tablePointer } = props;
|
|
1401
2002
|
const { bindingIndex, edits, onEdit, readOnly, onFlash } = shared;
|
|
1402
|
-
const rects =
|
|
2003
|
+
const rects = import_react3.default.useMemo(() => {
|
|
1403
2004
|
const collected = [];
|
|
1404
|
-
for (const [key, cell] of Object.entries(row)) {
|
|
2005
|
+
for (const [key, cell] of Object.entries(row ?? {})) {
|
|
1405
2006
|
if (key !== ROW_META_KEY && cell.coordinates) {
|
|
1406
2007
|
collected.push(cell.coordinates);
|
|
1407
2008
|
}
|
|
1408
2009
|
}
|
|
1409
2010
|
return collected;
|
|
1410
2011
|
}, [row]);
|
|
1411
|
-
const handleRowClick =
|
|
2012
|
+
const handleRowClick = import_react3.default.useCallback(
|
|
1412
2013
|
(event) => {
|
|
1413
2014
|
if (isInteractiveTarget(event.target)) {
|
|
1414
2015
|
return;
|
|
@@ -1419,81 +2020,205 @@ function TableRowView(props) {
|
|
|
1419
2020
|
},
|
|
1420
2021
|
[rects, onFlash]
|
|
1421
2022
|
);
|
|
2023
|
+
const cellFor = (column) => {
|
|
2024
|
+
const direct = row?.[column];
|
|
2025
|
+
const alias = direct === void 0 ? row?.[snakeToCamel(column)] : void 0;
|
|
2026
|
+
const fallbackKey = direct === void 0 && alias === void 0 && row !== void 0 ? Object.keys(row).find((key) => snakeToCamel(key) === snakeToCamel(column)) : void 0;
|
|
2027
|
+
const classified = direct ?? alias ?? (fallbackKey === void 0 ? void 0 : row?.[fallbackKey]);
|
|
2028
|
+
const fromPlan = planned?.cells.find((cell) => cell.column === column);
|
|
2029
|
+
if (fromPlan) {
|
|
2030
|
+
return { classified, binding: fromPlan.binding, editKey: fromPlan.editKey };
|
|
2031
|
+
}
|
|
2032
|
+
const binding = classified === void 0 ? void 0 : bindingIndex.get(classified.pointer);
|
|
2033
|
+
return { classified, binding, editKey: binding?.key.raw };
|
|
2034
|
+
};
|
|
1422
2035
|
const firstRect = rects.length > 0 ? rects[0] : null;
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
2036
|
+
const showControls = planned !== void 0 && tablePointer !== void 0 && !readOnly;
|
|
2037
|
+
const rowLevel = (row?.[ROW_META_KEY]?.confidence?.level ?? "").toLowerCase();
|
|
2038
|
+
const rowClass = rowLevel === "low" || rowLevel === "medium" ? `gemina-verification__row--${rowLevel}` : void 0;
|
|
2039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { onClick: handleRowClick, className: rowClass, children: [
|
|
2040
|
+
hasCoords ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(EyeButton, { coordinates: firstRect, onFlash: () => onFlash(rects) }) }) : null,
|
|
2041
|
+
hasRowConfidence ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfidenceDot, { confidence: row?.[ROW_META_KEY]?.confidence ?? null }) }) : null,
|
|
1426
2042
|
columns.map((column) => {
|
|
1427
|
-
const
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
binding !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2043
|
+
const { classified, binding, editKey } = cellFor(column);
|
|
2044
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__cell", children: [
|
|
2045
|
+
binding !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1431
2046
|
FieldInput,
|
|
1432
2047
|
{
|
|
1433
2048
|
binding,
|
|
1434
|
-
|
|
2049
|
+
editKey,
|
|
2050
|
+
pairError: editKey === void 0 ? void 0 : shared.pairErrors.get(editKey),
|
|
2051
|
+
edit: editKey === void 0 ? void 0 : edits.get(editKey),
|
|
1435
2052
|
onEdit,
|
|
1436
2053
|
readOnly,
|
|
1437
2054
|
ariaLabel: `${tableLabel} row ${rowIndex + 1} \u2014 ${formatLabel(column)}`
|
|
1438
2055
|
}
|
|
1439
|
-
) : /* @__PURE__ */ (0,
|
|
1440
|
-
/* @__PURE__ */ (0,
|
|
2056
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: classified === void 0 ? "-" : formatValue(classified.value, column) }),
|
|
2057
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfidenceDot, { confidence: classified?.confidence ?? null })
|
|
1441
2058
|
] }) }, column);
|
|
1442
|
-
})
|
|
2059
|
+
}),
|
|
2060
|
+
showControls ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("td", { className: "gemina-verification__row-actions", children: [
|
|
2061
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Tip, { content: "Insert a line below", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2062
|
+
"button",
|
|
2063
|
+
{
|
|
2064
|
+
type: "button",
|
|
2065
|
+
className: "gemina-verification__row-btn",
|
|
2066
|
+
"aria-label": `Insert line below line ${rowIndex + 1}`,
|
|
2067
|
+
onClick: () => shared.onAddRow(tablePointer, rowIndex),
|
|
2068
|
+
children: "+"
|
|
2069
|
+
}
|
|
2070
|
+
) }),
|
|
2071
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Tip, { content: "Remove this line", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2072
|
+
"button",
|
|
2073
|
+
{
|
|
2074
|
+
type: "button",
|
|
2075
|
+
className: "gemina-verification__row-btn",
|
|
2076
|
+
"aria-label": `Remove line ${rowIndex + 1}`,
|
|
2077
|
+
onClick: () => shared.onRemoveRow(tablePointer, rowIndex),
|
|
2078
|
+
children: "\xD7"
|
|
2079
|
+
}
|
|
2080
|
+
) })
|
|
2081
|
+
] }) : null
|
|
1443
2082
|
] });
|
|
1444
2083
|
}
|
|
1445
2084
|
function areRowPropsEqual(prev, next) {
|
|
1446
|
-
if (prev.row !== next.row || prev.rowIndex !== next.rowIndex || prev.columns !== next.columns || prev.tableLabel !== next.tableLabel || prev.hasCoords !== next.hasCoords || prev.hasRowConfidence !== next.hasRowConfidence || prev.shared.bindingIndex !== next.shared.bindingIndex || prev.shared.onEdit !== next.shared.onEdit || prev.shared.onFlash !== next.shared.onFlash || prev.shared.readOnly !== next.shared.readOnly) {
|
|
2085
|
+
if (prev.row !== next.row || prev.rowIndex !== next.rowIndex || prev.columns !== next.columns || prev.tableLabel !== next.tableLabel || prev.hasCoords !== next.hasCoords || prev.hasRowConfidence !== next.hasRowConfidence || prev.planned !== next.planned || prev.tablePointer !== next.tablePointer || prev.shared.bindingIndex !== next.shared.bindingIndex || prev.shared.onEdit !== next.shared.onEdit || prev.shared.onFlash !== next.shared.onFlash || prev.shared.readOnly !== next.shared.readOnly) {
|
|
1447
2086
|
return false;
|
|
1448
2087
|
}
|
|
1449
2088
|
if (prev.shared.edits === next.shared.edits) {
|
|
1450
2089
|
return true;
|
|
1451
2090
|
}
|
|
1452
2091
|
for (const column of next.columns) {
|
|
1453
|
-
const
|
|
1454
|
-
const
|
|
1455
|
-
|
|
2092
|
+
const planned = next.planned?.cells.find((cell) => cell.column === column);
|
|
2093
|
+
const classified = next.row?.[column];
|
|
2094
|
+
const editKey = planned?.editKey ?? (classified === void 0 ? void 0 : next.shared.bindingIndex.get(classified.pointer)?.key.raw);
|
|
2095
|
+
if (editKey === void 0) {
|
|
2096
|
+
continue;
|
|
2097
|
+
}
|
|
2098
|
+
if (prev.shared.edits.get(editKey) !== next.shared.edits.get(editKey) || prev.shared.pairErrors.get(editKey) !== next.shared.pairErrors.get(editKey)) {
|
|
1456
2099
|
return false;
|
|
1457
2100
|
}
|
|
1458
2101
|
}
|
|
1459
2102
|
return true;
|
|
1460
2103
|
}
|
|
1461
|
-
var TableRow =
|
|
2104
|
+
var TableRow = import_react3.default.memo(TableRowView, areRowPropsEqual);
|
|
2105
|
+
function withEmptyMutableTables(classified, tables) {
|
|
2106
|
+
if (tables.length === 0) {
|
|
2107
|
+
return { tables: classified.tables, suppressed: EMPTY_SUPPRESSED };
|
|
2108
|
+
}
|
|
2109
|
+
const promoted = [...classified.tables];
|
|
2110
|
+
const suppressed = /* @__PURE__ */ new Set();
|
|
2111
|
+
for (const table of tables) {
|
|
2112
|
+
if (classified.tables.some((candidate) => matchesTablePointer(table.pointer, candidate.pointer))) {
|
|
2113
|
+
continue;
|
|
2114
|
+
}
|
|
2115
|
+
const header = classified.headers.find(
|
|
2116
|
+
(candidate) => matchesTablePointer(table.pointer, candidate.pointer)
|
|
2117
|
+
);
|
|
2118
|
+
const empty = header !== void 0 && (header.value === null || Array.isArray(header.value) && header.value.length === 0);
|
|
2119
|
+
if (!empty) {
|
|
2120
|
+
continue;
|
|
2121
|
+
}
|
|
2122
|
+
suppressed.add(header.pointer);
|
|
2123
|
+
promoted.push({
|
|
2124
|
+
key: header.key,
|
|
2125
|
+
pointer: header.pointer,
|
|
2126
|
+
columns: [],
|
|
2127
|
+
rows: [],
|
|
2128
|
+
overallConfidence: null
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
return { tables: promoted, suppressed };
|
|
2132
|
+
}
|
|
2133
|
+
var EMPTY_SUPPRESSED = /* @__PURE__ */ new Set();
|
|
1462
2134
|
function TableSection(props) {
|
|
1463
2135
|
const { table, shared } = props;
|
|
1464
2136
|
const label = formatLabel(table.key);
|
|
1465
|
-
const
|
|
2137
|
+
const mutable = import_react3.default.useMemo(
|
|
2138
|
+
() => shared.rowMutableTables.find((entry) => matchesTablePointer(entry.pointer, table.pointer)),
|
|
2139
|
+
[shared.rowMutableTables, table.pointer]
|
|
2140
|
+
);
|
|
2141
|
+
const columns = import_react3.default.useMemo(
|
|
2142
|
+
() => mutable ? displayColumns(mutable, table.columns) : table.columns,
|
|
2143
|
+
[mutable, table.columns]
|
|
2144
|
+
);
|
|
2145
|
+
const planned = mutable ? shared.plannedTables.get(mutable.pointer) : void 0;
|
|
2146
|
+
const hasCoords = import_react3.default.useMemo(
|
|
1466
2147
|
() => table.rows.some(
|
|
1467
2148
|
(row) => Object.entries(row).some(([key, cell]) => key !== ROW_META_KEY && cell.coordinates !== null)
|
|
1468
2149
|
),
|
|
1469
2150
|
[table]
|
|
1470
2151
|
);
|
|
1471
|
-
const hasRowConfidence =
|
|
2152
|
+
const hasRowConfidence = import_react3.default.useMemo(
|
|
1472
2153
|
() => table.rows.some((row) => Boolean(row[ROW_META_KEY]?.confidence?.level)),
|
|
1473
2154
|
[table]
|
|
1474
2155
|
);
|
|
1475
|
-
|
|
1476
|
-
/* @__PURE__ */ (
|
|
1477
|
-
|
|
2156
|
+
const columnDescriptions = import_react3.default.useMemo(() => {
|
|
2157
|
+
const map = /* @__PURE__ */ new Map();
|
|
2158
|
+
for (const column of mutable?.columns ?? []) {
|
|
2159
|
+
if (typeof column.key === "string" && column.description) {
|
|
2160
|
+
map.set(column.key, column.description);
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
return map;
|
|
2164
|
+
}, [mutable]);
|
|
2165
|
+
const rowCount = planned ? planned.length : table.rows.length;
|
|
2166
|
+
const needsReview = import_react3.default.useMemo(
|
|
2167
|
+
() => table.rows.filter((row) => {
|
|
2168
|
+
const level = (row[ROW_META_KEY]?.confidence?.level ?? "").toLowerCase();
|
|
2169
|
+
return level === "low" || level === "medium";
|
|
2170
|
+
}).length,
|
|
2171
|
+
[table.rows]
|
|
2172
|
+
);
|
|
2173
|
+
const showControls = planned !== void 0 && mutable !== void 0 && !shared.readOnly;
|
|
2174
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
|
|
2175
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__section-header", children: [
|
|
2176
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
|
|
1478
2177
|
label,
|
|
1479
2178
|
" (",
|
|
1480
|
-
|
|
1481
|
-
" rows
|
|
2179
|
+
rowCount,
|
|
2180
|
+
" rows",
|
|
2181
|
+
needsReview > 0 ? ` \xB7 ${needsReview} need review` : "",
|
|
2182
|
+
")"
|
|
1482
2183
|
] }),
|
|
1483
|
-
/* @__PURE__ */ (0,
|
|
2184
|
+
table.overallConfidence ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "gemina-verification__overall-confidence", children: [
|
|
2185
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Overall confidence" }),
|
|
2186
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfidenceDot, { confidence: table.overallConfidence })
|
|
2187
|
+
] }) : null
|
|
1484
2188
|
] }),
|
|
1485
|
-
/* @__PURE__ */ (0,
|
|
1486
|
-
/* @__PURE__ */ (0,
|
|
1487
|
-
hasCoords ? /* @__PURE__ */ (0,
|
|
1488
|
-
hasRowConfidence ? /* @__PURE__ */ (0,
|
|
1489
|
-
|
|
2189
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__table-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("table", { className: "gemina-verification__table", children: [
|
|
2190
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { children: [
|
|
2191
|
+
hasCoords ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { "aria-label": "Show row on document" }) : null,
|
|
2192
|
+
hasRowConfidence ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { "aria-label": "Row confidence" }) : null,
|
|
2193
|
+
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2194
|
+
FieldLabel,
|
|
2195
|
+
{
|
|
2196
|
+
label: formatLabel(column),
|
|
2197
|
+
description: columnDescriptions.get(column)
|
|
2198
|
+
}
|
|
2199
|
+
) }, column)),
|
|
2200
|
+
showControls ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { "aria-label": "Row actions" }) : null
|
|
1490
2201
|
] }) }),
|
|
1491
|
-
/* @__PURE__ */ (0,
|
|
2202
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children: planned ? planned.map((plannedRow, position) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2203
|
+
TableRow,
|
|
2204
|
+
{
|
|
2205
|
+
row: plannedRow.entry.source === null ? void 0 : table.rows[plannedRow.entry.source],
|
|
2206
|
+
rowIndex: position,
|
|
2207
|
+
columns,
|
|
2208
|
+
tableLabel: label,
|
|
2209
|
+
hasCoords,
|
|
2210
|
+
hasRowConfidence,
|
|
2211
|
+
shared,
|
|
2212
|
+
planned: plannedRow,
|
|
2213
|
+
tablePointer: mutable.pointer
|
|
2214
|
+
},
|
|
2215
|
+
plannedRow.entry.id
|
|
2216
|
+
)) : table.rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1492
2217
|
TableRow,
|
|
1493
2218
|
{
|
|
1494
2219
|
row,
|
|
1495
2220
|
rowIndex,
|
|
1496
|
-
columns
|
|
2221
|
+
columns,
|
|
1497
2222
|
tableLabel: label,
|
|
1498
2223
|
hasCoords,
|
|
1499
2224
|
hasRowConfidence,
|
|
@@ -1501,19 +2226,28 @@ function TableSection(props) {
|
|
|
1501
2226
|
},
|
|
1502
2227
|
rowIndex
|
|
1503
2228
|
)) })
|
|
1504
|
-
] }) })
|
|
2229
|
+
] }) }),
|
|
2230
|
+
showControls ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__table-footer", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2231
|
+
"button",
|
|
2232
|
+
{
|
|
2233
|
+
type: "button",
|
|
2234
|
+
className: "gemina-verification__add-row",
|
|
2235
|
+
onClick: () => shared.onAddRow(mutable.pointer, rowCount - 1),
|
|
2236
|
+
children: "Add line"
|
|
2237
|
+
}
|
|
2238
|
+
) }) : null
|
|
1505
2239
|
] });
|
|
1506
2240
|
}
|
|
1507
|
-
var FallbackSection =
|
|
2241
|
+
var FallbackSection = import_react3.default.memo(function FallbackSection2(props) {
|
|
1508
2242
|
const { fallback } = props;
|
|
1509
2243
|
if (fallback.length === 0) {
|
|
1510
2244
|
return null;
|
|
1511
2245
|
}
|
|
1512
|
-
return /* @__PURE__ */ (0,
|
|
1513
|
-
/* @__PURE__ */ (0,
|
|
1514
|
-
/* @__PURE__ */ (0,
|
|
1515
|
-
/* @__PURE__ */ (0,
|
|
1516
|
-
/* @__PURE__ */ (0,
|
|
2246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Additional Data", children: [
|
|
2247
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__section-header", children: "Additional Data" }),
|
|
2248
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__section-body", children: fallback.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("details", { className: "gemina-verification__fallback", children: [
|
|
2249
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("summary", { children: formatLabel(item.key) }),
|
|
2250
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { children: JSON.stringify(item.data, null, 2) })
|
|
1517
2251
|
] }, item.key)) })
|
|
1518
2252
|
] });
|
|
1519
2253
|
});
|
|
@@ -1522,14 +2256,15 @@ function UnmatchedSection(props) {
|
|
|
1522
2256
|
if (unmatched.length === 0) {
|
|
1523
2257
|
return null;
|
|
1524
2258
|
}
|
|
1525
|
-
return /* @__PURE__ */ (0,
|
|
1526
|
-
/* @__PURE__ */ (0,
|
|
1527
|
-
/* @__PURE__ */ (0,
|
|
1528
|
-
/* @__PURE__ */ (0,
|
|
1529
|
-
/* @__PURE__ */ (0,
|
|
2259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Not detected", children: [
|
|
2260
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__section-header", children: "Not detected" }),
|
|
2261
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dl", { className: "gemina-verification__dl", children: unmatched.map((binding) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react3.default.Fragment, { children: [
|
|
2262
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dt", { className: "gemina-verification__dt", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: binding.key.label }) }),
|
|
2263
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { className: "gemina-verification__dd", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1530
2264
|
FieldInput,
|
|
1531
2265
|
{
|
|
1532
2266
|
binding,
|
|
2267
|
+
pairError: shared.pairErrors.get(binding.key.raw),
|
|
1533
2268
|
edit: shared.edits.get(binding.key.raw),
|
|
1534
2269
|
onEdit: shared.onEdit,
|
|
1535
2270
|
readOnly: shared.readOnly,
|
|
@@ -1540,26 +2275,65 @@ function UnmatchedSection(props) {
|
|
|
1540
2275
|
] });
|
|
1541
2276
|
}
|
|
1542
2277
|
function VerificationForm(props) {
|
|
1543
|
-
const {
|
|
1544
|
-
|
|
2278
|
+
const {
|
|
2279
|
+
classified,
|
|
2280
|
+
unmatched,
|
|
2281
|
+
bindingIndex,
|
|
2282
|
+
edits,
|
|
2283
|
+
onEdit,
|
|
2284
|
+
readOnly,
|
|
2285
|
+
onFlash,
|
|
2286
|
+
pairErrors,
|
|
2287
|
+
rowMutableTables,
|
|
2288
|
+
plannedTables,
|
|
2289
|
+
onAddRow,
|
|
2290
|
+
onRemoveRow
|
|
2291
|
+
} = props;
|
|
2292
|
+
const { tables: promotedTables, suppressed } = import_react3.default.useMemo(
|
|
2293
|
+
() => withEmptyMutableTables(classified, rowMutableTables ?? NO_TABLES),
|
|
2294
|
+
[classified, rowMutableTables]
|
|
2295
|
+
);
|
|
2296
|
+
const shared = {
|
|
2297
|
+
bindingIndex,
|
|
2298
|
+
edits,
|
|
2299
|
+
onEdit,
|
|
2300
|
+
readOnly,
|
|
2301
|
+
onFlash,
|
|
2302
|
+
pairErrors: pairErrors ?? NO_PAIR_ERRORS,
|
|
2303
|
+
rowMutableTables: rowMutableTables ?? NO_TABLES,
|
|
2304
|
+
plannedTables: plannedTables ?? NO_PLANNED,
|
|
2305
|
+
onAddRow: onAddRow ?? NOOP_ROW,
|
|
2306
|
+
onRemoveRow: onRemoveRow ?? NOOP_ROW
|
|
2307
|
+
};
|
|
1545
2308
|
return (
|
|
1546
2309
|
// A real, labeled <form> (role "form" landmark): AT users can jump
|
|
1547
2310
|
// straight to the editable fields. Submission is owned by the root's
|
|
1548
2311
|
// footer button, never by the form element itself — preventDefault stops
|
|
1549
2312
|
// implicit submission (Enter in a payload with exactly one input would
|
|
1550
2313
|
// otherwise navigate).
|
|
1551
|
-
/* @__PURE__ */ (0,
|
|
2314
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1552
2315
|
"form",
|
|
1553
2316
|
{
|
|
1554
2317
|
className: "gemina-verification__form",
|
|
1555
2318
|
"aria-label": "Extraction fields",
|
|
1556
2319
|
onSubmit: (event) => event.preventDefault(),
|
|
1557
2320
|
children: [
|
|
1558
|
-
/* @__PURE__ */ (0,
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
/* @__PURE__ */ (0,
|
|
2321
|
+
classified.overallConfidence ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__confidence-summary", children: [
|
|
2322
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Overall confidence" }),
|
|
2323
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfidenceDot, { confidence: classified.overallConfidence })
|
|
2324
|
+
] }) : null,
|
|
2325
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2326
|
+
HeaderSection,
|
|
2327
|
+
{
|
|
2328
|
+
headers: classified.headers.filter((header) => !suppressed.has(header.pointer)),
|
|
2329
|
+
simpleLists: classified.simpleLists,
|
|
2330
|
+
shared
|
|
2331
|
+
}
|
|
2332
|
+
),
|
|
2333
|
+
classified.entities.map((entity) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(EntitySection, { entity, shared }, entity.pointer)),
|
|
2334
|
+
promotedTables.map((table) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TableSection, { table, shared }, table.pointer)),
|
|
2335
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FallbackSection, { fallback: classified.fallback }),
|
|
2336
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(UnmatchedSection, { unmatched, shared })
|
|
1563
2337
|
]
|
|
1564
2338
|
}
|
|
1565
2339
|
)
|
|
@@ -1567,7 +2341,7 @@ function VerificationForm(props) {
|
|
|
1567
2341
|
}
|
|
1568
2342
|
|
|
1569
2343
|
// src/version.ts
|
|
1570
|
-
var VERSION = "0.
|
|
2344
|
+
var VERSION = "0.10.0";
|
|
1571
2345
|
|
|
1572
2346
|
// src/verification/styles.ts
|
|
1573
2347
|
var DARK_VARS = `
|
|
@@ -1669,9 +2443,15 @@ var VERIFICATION_CSS = `
|
|
|
1669
2443
|
background: var(--gemina-verification-bg);
|
|
1670
2444
|
border: 1px solid var(--gemina-verification-border);
|
|
1671
2445
|
border-radius: var(--gemina-verification-radius);
|
|
1672
|
-
overflow
|
|
2446
|
+
/* overflow hidden creates a scroll container and prevents the toolbar's sticky
|
|
2447
|
+
positioning from following the host modal's scrollport. Clip keeps the
|
|
2448
|
+
rounded frame without stealing sticky containment. */
|
|
2449
|
+
overflow: clip;
|
|
1673
2450
|
}
|
|
1674
2451
|
.gemina-verification__toolbar {
|
|
2452
|
+
position: sticky;
|
|
2453
|
+
top: 0;
|
|
2454
|
+
z-index: 5;
|
|
1675
2455
|
display: flex;
|
|
1676
2456
|
/* Narrow roots (~<330px) can't fit all 7 buttons on one line: wrap to a
|
|
1677
2457
|
second row instead of clipping past the canvas edge. The gap shorthand
|
|
@@ -1681,6 +2461,7 @@ var VERIFICATION_CSS = `
|
|
|
1681
2461
|
gap: 6px;
|
|
1682
2462
|
flex: 0 0 auto;
|
|
1683
2463
|
padding: 8px 10px;
|
|
2464
|
+
background: var(--gemina-verification-bg);
|
|
1684
2465
|
border-block-end: 1px solid var(--gemina-verification-border);
|
|
1685
2466
|
}
|
|
1686
2467
|
.gemina-verification__toolbar-btn {
|
|
@@ -1791,6 +2572,19 @@ var VERIFICATION_CSS = `
|
|
|
1791
2572
|
min-width: 0;
|
|
1792
2573
|
margin: 0;
|
|
1793
2574
|
}
|
|
2575
|
+
.gemina-verification__confidence-summary {
|
|
2576
|
+
display: flex;
|
|
2577
|
+
align-items: center;
|
|
2578
|
+
justify-content: space-between;
|
|
2579
|
+
gap: 12px;
|
|
2580
|
+
padding: 9px 12px;
|
|
2581
|
+
background: var(--gemina-verification-surface);
|
|
2582
|
+
border: 1px solid var(--gemina-verification-border);
|
|
2583
|
+
border-radius: var(--gemina-verification-radius);
|
|
2584
|
+
color: var(--gemina-verification-muted);
|
|
2585
|
+
font-size: 12px;
|
|
2586
|
+
font-weight: 600;
|
|
2587
|
+
}
|
|
1794
2588
|
.gemina-verification__section {
|
|
1795
2589
|
background: var(--gemina-verification-bg);
|
|
1796
2590
|
border: 1px solid var(--gemina-verification-border);
|
|
@@ -1807,6 +2601,16 @@ var VERIFICATION_CSS = `
|
|
|
1807
2601
|
font-size: 13px;
|
|
1808
2602
|
font-weight: 600;
|
|
1809
2603
|
}
|
|
2604
|
+
.gemina-verification__overall-confidence {
|
|
2605
|
+
display: inline-flex;
|
|
2606
|
+
align-items: center;
|
|
2607
|
+
gap: 6px;
|
|
2608
|
+
margin-inline-start: auto;
|
|
2609
|
+
color: var(--gemina-verification-muted);
|
|
2610
|
+
font-size: 11px;
|
|
2611
|
+
font-weight: 500;
|
|
2612
|
+
white-space: nowrap;
|
|
2613
|
+
}
|
|
1810
2614
|
.gemina-verification__dl {
|
|
1811
2615
|
display: grid;
|
|
1812
2616
|
grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
|
|
@@ -1826,6 +2630,10 @@ var VERIFICATION_CSS = `
|
|
|
1826
2630
|
}
|
|
1827
2631
|
.gemina-verification__dd {
|
|
1828
2632
|
display: flex;
|
|
2633
|
+
/* Wrap so a field error takes its OWN line (it sets flex-basis:100%).
|
|
2634
|
+
Without this it competes with the input for width, and at 390px the
|
|
2635
|
+
message wrapped to one word per line while the input shrank to ~55px. */
|
|
2636
|
+
flex-wrap: wrap;
|
|
1829
2637
|
align-items: center;
|
|
1830
2638
|
gap: 6px;
|
|
1831
2639
|
margin: 0; /* resets the UA's margin-inline-start on <dd> */
|
|
@@ -1845,6 +2653,15 @@ var VERIFICATION_CSS = `
|
|
|
1845
2653
|
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
1846
2654
|
padding: 5px 8px;
|
|
1847
2655
|
}
|
|
2656
|
+
/* FieldInput is a fragment. Let its control take the remaining row width
|
|
2657
|
+
instead of forcing width:100%, so a coordinate eye can sit beside it rather
|
|
2658
|
+
than wrapping onto a visually disconnected second line. */
|
|
2659
|
+
.gemina-verification__dd > .gemina-verification__input,
|
|
2660
|
+
.gemina-verification__cell > .gemina-verification__input {
|
|
2661
|
+
flex: 1 1 8ch;
|
|
2662
|
+
width: auto;
|
|
2663
|
+
min-width: 0;
|
|
2664
|
+
}
|
|
1848
2665
|
.gemina-verification__input--dirty { border-color: var(--gemina-verification-dirty); }
|
|
1849
2666
|
.gemina-verification__input--missed {
|
|
1850
2667
|
border-color: var(--gemina-verification-error);
|
|
@@ -1900,6 +2717,7 @@ var VERIFICATION_CSS = `
|
|
|
1900
2717
|
and list items \u2014 the fragment has no container of its own. */
|
|
1901
2718
|
.gemina-verification__cell {
|
|
1902
2719
|
display: flex;
|
|
2720
|
+
flex-wrap: wrap; /* same reason as __dd: the field error needs its own line */
|
|
1903
2721
|
align-items: center;
|
|
1904
2722
|
gap: 6px;
|
|
1905
2723
|
min-width: 0;
|
|
@@ -2160,6 +2978,157 @@ var VERIFICATION_CSS = `
|
|
|
2160
2978
|
transition: none;
|
|
2161
2979
|
}
|
|
2162
2980
|
}
|
|
2981
|
+
|
|
2982
|
+
/* A label that carries a description. Dotted underline is the long-standing
|
|
2983
|
+
convention for "there is more here", and tabIndex makes it reachable, so the
|
|
2984
|
+
tooltip is not mouse-only. */
|
|
2985
|
+
.gemina-verification__label-described {
|
|
2986
|
+
text-decoration: underline dotted;
|
|
2987
|
+
text-underline-offset: 3px;
|
|
2988
|
+
cursor: help;
|
|
2989
|
+
}
|
|
2990
|
+
.gemina-verification__label-described:focus-visible {
|
|
2991
|
+
outline: 2px solid var(--gemina-verification-accent);
|
|
2992
|
+
outline-offset: 2px;
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
/* Rows worth a second look. Uses the EXISTING confidence tokens \u2014 no new
|
|
2996
|
+
colours \u2014 as a start-edge rule, which is the one edge a reviewer scans down
|
|
2997
|
+
a long table. Logical property, so it lands on the right side under RTL. */
|
|
2998
|
+
.gemina-verification__row--low > td:first-child,
|
|
2999
|
+
.gemina-verification__row--medium > td:first-child {
|
|
3000
|
+
border-inline-start: 3px solid transparent;
|
|
3001
|
+
}
|
|
3002
|
+
.gemina-verification__row--low > td:first-child {
|
|
3003
|
+
border-inline-start-color: var(--gemina-verification-confidence-low);
|
|
3004
|
+
}
|
|
3005
|
+
.gemina-verification__row--medium > td:first-child {
|
|
3006
|
+
border-inline-start-color: var(--gemina-verification-confidence-medium);
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
/* --- Row editing ----------------------------------------------------------
|
|
3010
|
+
Quiet by design: adding and removing lines is a correction, not the primary
|
|
3011
|
+
action, so the controls stay muted until hovered and the accent is left to
|
|
3012
|
+
Submit. */
|
|
3013
|
+
.gemina-verification__row-actions {
|
|
3014
|
+
white-space: nowrap;
|
|
3015
|
+
text-align: end; /* logical \u2014 RTL for free */
|
|
3016
|
+
}
|
|
3017
|
+
.gemina-verification__row-btn {
|
|
3018
|
+
font: inherit;
|
|
3019
|
+
line-height: 1;
|
|
3020
|
+
padding: 2px 7px;
|
|
3021
|
+
margin-inline-start: 4px;
|
|
3022
|
+
border-radius: calc(var(--gemina-verification-radius) - 5px);
|
|
3023
|
+
border: 1px solid var(--gemina-verification-border);
|
|
3024
|
+
background: transparent;
|
|
3025
|
+
color: var(--gemina-verification-muted);
|
|
3026
|
+
cursor: pointer;
|
|
3027
|
+
transition: border-color 120ms ease, color 120ms ease;
|
|
3028
|
+
}
|
|
3029
|
+
.gemina-verification__row-btn:hover {
|
|
3030
|
+
border-color: var(--gemina-verification-accent);
|
|
3031
|
+
color: var(--gemina-verification-fg);
|
|
3032
|
+
}
|
|
3033
|
+
.gemina-verification__table-footer {
|
|
3034
|
+
display: flex;
|
|
3035
|
+
padding: 8px 10px;
|
|
3036
|
+
}
|
|
3037
|
+
.gemina-verification__add-row {
|
|
3038
|
+
font: inherit;
|
|
3039
|
+
font-size: 12px;
|
|
3040
|
+
padding: 4px 10px;
|
|
3041
|
+
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
3042
|
+
border: 1px dashed var(--gemina-verification-border);
|
|
3043
|
+
background: transparent;
|
|
3044
|
+
color: var(--gemina-verification-muted);
|
|
3045
|
+
cursor: pointer;
|
|
3046
|
+
}
|
|
3047
|
+
.gemina-verification__add-row:hover {
|
|
3048
|
+
border-style: solid;
|
|
3049
|
+
border-color: var(--gemina-verification-accent);
|
|
3050
|
+
color: var(--gemina-verification-fg);
|
|
3051
|
+
}
|
|
3052
|
+
|
|
3053
|
+
/* --- Typed controls -------------------------------------------------------
|
|
3054
|
+
A <select> for a closed roster must sit on the same baseline as the text
|
|
3055
|
+
inputs beside it in a table row, so it inherits the input's box entirely and
|
|
3056
|
+
only overrides what a select needs. */
|
|
3057
|
+
.gemina-verification__input:is(select) {
|
|
3058
|
+
cursor: pointer;
|
|
3059
|
+
/* A select's intrinsic width follows its longest option \u2014 the 24-member unit
|
|
3060
|
+
roster would blow out the column. */
|
|
3061
|
+
max-width: 100%;
|
|
3062
|
+
}
|
|
3063
|
+
/* The error border must beat --dirty and --missed: an invalid value is the
|
|
3064
|
+
most urgent thing true about the field, and the reviewer cannot submit
|
|
3065
|
+
until it is fixed. Placed after both for cascade order. */
|
|
3066
|
+
.gemina-verification__input--invalid,
|
|
3067
|
+
.gemina-verification__input--invalid:focus-visible {
|
|
3068
|
+
border-color: var(--gemina-verification-error);
|
|
3069
|
+
}
|
|
3070
|
+
/* Sits under the control it describes. Basis 100% breaks it onto its own line
|
|
3071
|
+
inside the flex row FieldInput renders into, so it never squeezes the
|
|
3072
|
+
input. */
|
|
3073
|
+
.gemina-verification__field-error {
|
|
3074
|
+
flex-basis: 100%;
|
|
3075
|
+
margin-block-start: 4px;
|
|
3076
|
+
color: var(--gemina-verification-error);
|
|
3077
|
+
font-size: 12px;
|
|
3078
|
+
line-height: 1.35;
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
/* Replaces __progress while anything is invalid \u2014 same slot, so the footer
|
|
3082
|
+
never grows a second status line competing for the same attention. */
|
|
3083
|
+
.gemina-verification__attention {
|
|
3084
|
+
color: var(--gemina-verification-error);
|
|
3085
|
+
font-size: 13px;
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3088
|
+
/* --- Tooltip -------------------------------------------------------------
|
|
3089
|
+
Renders in a portal on document.body, inside a div carrying the root's
|
|
3090
|
+
class list \u2014 so these rules and every --gemina-verification-* custom
|
|
3091
|
+
property resolve exactly as they do in the component.
|
|
3092
|
+
|
|
3093
|
+
Quieter than __confirm-dialog on purpose: an annotation, not a decision.
|
|
3094
|
+
Same border and shadow family, one step down in radius (the nested-element
|
|
3095
|
+
convention used by __chip et al), surface rather than bg so it separates
|
|
3096
|
+
from the panel it floats over, and a shorter shadow so it reads as sitting
|
|
3097
|
+
just above the page rather than over a scrim. */
|
|
3098
|
+
.gemina-verification__tip {
|
|
3099
|
+
position: fixed;
|
|
3100
|
+
z-index: 2147483000; /* above the host's own modal \u2014 this is the topmost layer */
|
|
3101
|
+
max-width: 260px; /* ~60 characters: past that a tooltip should be body copy */
|
|
3102
|
+
padding: 8px 10px;
|
|
3103
|
+
background: var(--gemina-verification-surface);
|
|
3104
|
+
color: var(--gemina-verification-fg);
|
|
3105
|
+
border: 1px solid var(--gemina-verification-border);
|
|
3106
|
+
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
3107
|
+
box-shadow: 0 6px 16px rgba(16, 20, 24, 0.18);
|
|
3108
|
+
font-family: var(--gemina-verification-font);
|
|
3109
|
+
font-size: 12px;
|
|
3110
|
+
line-height: 1.45;
|
|
3111
|
+
text-align: start; /* logical \u2014 RTL for free */
|
|
3112
|
+
pointer-events: none; /* never eat the hover that opened it */
|
|
3113
|
+
}
|
|
3114
|
+
/* Structured content: a level heading over a reasons list. The list is the
|
|
3115
|
+
reason this exists at all \u2014 title= could only ever have been one line. */
|
|
3116
|
+
.gemina-verification__tip-title {
|
|
3117
|
+
display: block;
|
|
3118
|
+
font-weight: 600;
|
|
3119
|
+
margin-block-end: 4px;
|
|
3120
|
+
}
|
|
3121
|
+
.gemina-verification__tip-list {
|
|
3122
|
+
margin: 0;
|
|
3123
|
+
padding-inline-start: 16px;
|
|
3124
|
+
}
|
|
3125
|
+
.gemina-verification__tip-list li + li {
|
|
3126
|
+
margin-block-start: 2px;
|
|
3127
|
+
}
|
|
3128
|
+
/* A muted lead-in for single-fact tips ("Was:"), so the VALUE reads first. */
|
|
3129
|
+
.gemina-verification__tip-label {
|
|
3130
|
+
color: var(--gemina-verification-muted);
|
|
3131
|
+
}
|
|
2163
3132
|
`;
|
|
2164
3133
|
var STYLE_ATTR = "data-gemina-verification";
|
|
2165
3134
|
function ensureVerificationStylesInjected() {
|
|
@@ -2176,7 +3145,7 @@ function ensureVerificationStylesInjected() {
|
|
|
2176
3145
|
}
|
|
2177
3146
|
|
|
2178
3147
|
// src/verification/index.tsx
|
|
2179
|
-
var
|
|
3148
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2180
3149
|
var HEBREW_RE = /[\u0590-\u05FF]/;
|
|
2181
3150
|
var STACKED_BREAKPOINT = 860;
|
|
2182
3151
|
var IMAGE_REFRESH_THROTTLE_MS = 6e4;
|
|
@@ -2189,11 +3158,23 @@ var PURGED_TEXT = "Document no longer available (retention policy).";
|
|
|
2189
3158
|
var NOT_COMPLETED_TEXT = "This extraction did not complete, so there is nothing to verify.";
|
|
2190
3159
|
var VERIFICATION_UNAVAILABLE_TEXT = "Verification isn't available for this extraction.";
|
|
2191
3160
|
var ALREADY_VALIDATED_TEXT = "Already verified \u2014 showing the original extraction.";
|
|
2192
|
-
var CONFIRM_TEXT = "Submit
|
|
3161
|
+
var CONFIRM_TEXT = "Submit these values? This is final \u2014 they can be submitted once and can't be changed.";
|
|
2193
3162
|
var SUBMITTING_TEXT = "Submitting\u2026";
|
|
2194
3163
|
var SUBMIT_FAILED_TEXT = "Submission failed \u2014 your corrections are still here.";
|
|
2195
|
-
var DONE_TITLE_TEXT = "
|
|
3164
|
+
var DONE_TITLE_TEXT = "Submitted";
|
|
2196
3165
|
var NO_EDITS = /* @__PURE__ */ new Map();
|
|
3166
|
+
var NO_ROW_PLANS = /* @__PURE__ */ new Map();
|
|
3167
|
+
var NO_PLANNED_TABLES = /* @__PURE__ */ new Map();
|
|
3168
|
+
function seedRowPlans(tables, values) {
|
|
3169
|
+
if (tables.length === 0) {
|
|
3170
|
+
return NO_ROW_PLANS;
|
|
3171
|
+
}
|
|
3172
|
+
const plans = /* @__PURE__ */ new Map();
|
|
3173
|
+
for (const table of tables) {
|
|
3174
|
+
plans.set(table.pointer, initialRowPlan(countRowsAt(values, table.pointer), table.pointer));
|
|
3175
|
+
}
|
|
3176
|
+
return plans;
|
|
3177
|
+
}
|
|
2197
3178
|
var ALERT_REASONS = /* @__PURE__ */ new Set([
|
|
2198
3179
|
"session-expired",
|
|
2199
3180
|
"not-available",
|
|
@@ -2210,43 +3191,44 @@ function GeminaVerification(props) {
|
|
|
2210
3191
|
onError,
|
|
2211
3192
|
className
|
|
2212
3193
|
} = props;
|
|
2213
|
-
const [phase, setPhase] = (0,
|
|
2214
|
-
const [alreadyValidated, setAlreadyValidated] = (0,
|
|
2215
|
-
const [loaded, setLoaded] = (0,
|
|
2216
|
-
const [
|
|
2217
|
-
const [
|
|
2218
|
-
const [
|
|
2219
|
-
const [
|
|
2220
|
-
const
|
|
2221
|
-
const
|
|
2222
|
-
const
|
|
2223
|
-
const
|
|
2224
|
-
const
|
|
3194
|
+
const [phase, setPhase] = (0, import_react4.useState)({ name: "loading" });
|
|
3195
|
+
const [alreadyValidated, setAlreadyValidated] = (0, import_react4.useState)(false);
|
|
3196
|
+
const [loaded, setLoaded] = (0, import_react4.useState)(null);
|
|
3197
|
+
const [rowPlans, setRowPlans] = (0, import_react4.useState)(NO_ROW_PLANS);
|
|
3198
|
+
const [edits, setEdits] = (0, import_react4.useState)(NO_EDITS);
|
|
3199
|
+
const [imageUrl, setImageUrl] = (0, import_react4.useState)(null);
|
|
3200
|
+
const [flashRects, setFlashRects] = (0, import_react4.useState)(null);
|
|
3201
|
+
const [stacked, setStacked] = (0, import_react4.useState)(false);
|
|
3202
|
+
const rootRef = (0, import_react4.useRef)(null);
|
|
3203
|
+
const mountedRef = (0, import_react4.useRef)(false);
|
|
3204
|
+
const loadSeqRef = (0, import_react4.useRef)(0);
|
|
3205
|
+
const lastImageRefreshRef = (0, import_react4.useRef)(0);
|
|
3206
|
+
const onErrorRef = (0, import_react4.useRef)(onError);
|
|
2225
3207
|
onErrorRef.current = onError;
|
|
2226
|
-
const onCompleteRef = (0,
|
|
3208
|
+
const onCompleteRef = (0, import_react4.useRef)(onComplete);
|
|
2227
3209
|
onCompleteRef.current = onComplete;
|
|
2228
|
-
const completedRef = (0,
|
|
2229
|
-
const submitInFlightRef = (0,
|
|
2230
|
-
const restoreFocusRef = (0,
|
|
2231
|
-
const submitButtonRef = (0,
|
|
2232
|
-
const confirmButtonRef = (0,
|
|
2233
|
-
const cancelButtonRef = (0,
|
|
2234
|
-
const retrySubmitButtonRef = (0,
|
|
2235
|
-
const doneStateRef = (0,
|
|
2236
|
-
const enterUnavailable = (0,
|
|
3210
|
+
const completedRef = (0, import_react4.useRef)(false);
|
|
3211
|
+
const submitInFlightRef = (0, import_react4.useRef)(false);
|
|
3212
|
+
const restoreFocusRef = (0, import_react4.useRef)(false);
|
|
3213
|
+
const submitButtonRef = (0, import_react4.useRef)(null);
|
|
3214
|
+
const confirmButtonRef = (0, import_react4.useRef)(null);
|
|
3215
|
+
const cancelButtonRef = (0, import_react4.useRef)(null);
|
|
3216
|
+
const retrySubmitButtonRef = (0, import_react4.useRef)(null);
|
|
3217
|
+
const doneStateRef = (0, import_react4.useRef)(null);
|
|
3218
|
+
const enterUnavailable = (0, import_react4.useCallback)(
|
|
2237
3219
|
(reason, message, canRetry, detail) => {
|
|
2238
3220
|
setPhase({ name: "unavailable", reason, message, canRetry });
|
|
2239
3221
|
onErrorRef.current?.(reason, detail);
|
|
2240
3222
|
},
|
|
2241
3223
|
[]
|
|
2242
3224
|
);
|
|
2243
|
-
const fetchOnce = (0,
|
|
3225
|
+
const fetchOnce = (0, import_react4.useCallback)(async () => {
|
|
2244
3226
|
const token = await tokenManager.getToken();
|
|
2245
3227
|
return import_sdk.GeminaClient.withSessionToken(token, baseUrl).documents.getDocumentExtraction({
|
|
2246
3228
|
documentExtractionId: extractionId
|
|
2247
3229
|
});
|
|
2248
3230
|
}, [tokenManager, baseUrl, extractionId]);
|
|
2249
|
-
const fetchWithRetry = (0,
|
|
3231
|
+
const fetchWithRetry = (0, import_react4.useCallback)(async () => {
|
|
2250
3232
|
try {
|
|
2251
3233
|
return await fetchOnce();
|
|
2252
3234
|
} catch (error) {
|
|
@@ -2257,7 +3239,7 @@ function GeminaVerification(props) {
|
|
|
2257
3239
|
return await fetchOnce();
|
|
2258
3240
|
}
|
|
2259
3241
|
}, [fetchOnce, tokenManager]);
|
|
2260
|
-
const load = (0,
|
|
3242
|
+
const load = (0, import_react4.useCallback)(async () => {
|
|
2261
3243
|
const seq = ++loadSeqRef.current;
|
|
2262
3244
|
const live = () => mountedRef.current && loadSeqRef.current === seq;
|
|
2263
3245
|
setPhase({ name: "loading" });
|
|
@@ -2288,9 +3270,12 @@ function GeminaVerification(props) {
|
|
|
2288
3270
|
const schema = view.meta.validationFeedback?.validationSchema;
|
|
2289
3271
|
setLoaded({
|
|
2290
3272
|
values: view.values,
|
|
2291
|
-
schema: Array.isArray(schema) ? schema : []
|
|
3273
|
+
schema: Array.isArray(schema) ? schema : [],
|
|
3274
|
+
fields: readDescriptors(view.meta.validationFeedback?.validationFields),
|
|
3275
|
+
rowMutableTables: readRowMutableTables(view.meta.validationFeedback?.rowMutableTables)
|
|
2292
3276
|
});
|
|
2293
3277
|
setEdits(NO_EDITS);
|
|
3278
|
+
setRowPlans(seedRowPlans(readRowMutableTables(view.meta.validationFeedback?.rowMutableTables), view.values));
|
|
2294
3279
|
const url = view.document.imageUrl;
|
|
2295
3280
|
setImageUrl(typeof url === "string" && url.length > 0 ? url : null);
|
|
2296
3281
|
setAlreadyValidated(validated);
|
|
@@ -2308,7 +3293,7 @@ function GeminaVerification(props) {
|
|
|
2308
3293
|
enterReview(false);
|
|
2309
3294
|
}
|
|
2310
3295
|
}, [fetchWithRetry, enterUnavailable]);
|
|
2311
|
-
(0,
|
|
3296
|
+
(0, import_react4.useEffect)(() => {
|
|
2312
3297
|
mountedRef.current = true;
|
|
2313
3298
|
ensureVerificationStylesInjected();
|
|
2314
3299
|
void load();
|
|
@@ -2316,7 +3301,7 @@ function GeminaVerification(props) {
|
|
|
2316
3301
|
mountedRef.current = false;
|
|
2317
3302
|
};
|
|
2318
3303
|
}, [load]);
|
|
2319
|
-
(0,
|
|
3304
|
+
(0, import_react4.useEffect)(() => {
|
|
2320
3305
|
const el = rootRef.current;
|
|
2321
3306
|
if (el === null) {
|
|
2322
3307
|
return;
|
|
@@ -2337,10 +3322,20 @@ function GeminaVerification(props) {
|
|
|
2337
3322
|
observer.observe(el);
|
|
2338
3323
|
return () => observer.disconnect();
|
|
2339
3324
|
}, []);
|
|
2340
|
-
const classified = (0,
|
|
2341
|
-
const bindings = (0,
|
|
2342
|
-
|
|
2343
|
-
|
|
3325
|
+
const classified = (0, import_react4.useMemo)(() => classifyData(loaded?.values), [loaded]);
|
|
3326
|
+
const bindings = (0, import_react4.useMemo)(
|
|
3327
|
+
() => buildBindings(loaded?.schema ?? [], loaded?.values, loaded?.fields),
|
|
3328
|
+
[loaded]
|
|
3329
|
+
);
|
|
3330
|
+
const bindingIndex = (0, import_react4.useMemo)(() => indexBindingsByFieldPointer(bindings), [bindings]);
|
|
3331
|
+
const bindingsByRawKey = (0, import_react4.useMemo)(() => {
|
|
3332
|
+
const map = /* @__PURE__ */ new Map();
|
|
3333
|
+
for (const binding of bindings) {
|
|
3334
|
+
map.set(binding.key.raw, binding);
|
|
3335
|
+
}
|
|
3336
|
+
return map;
|
|
3337
|
+
}, [bindings]);
|
|
3338
|
+
const unmatched = (0, import_react4.useMemo)(() => {
|
|
2344
3339
|
const rendered = /* @__PURE__ */ new Set();
|
|
2345
3340
|
for (const field of classified.headers) {
|
|
2346
3341
|
rendered.add(field.pointer);
|
|
@@ -2368,7 +3363,7 @@ function GeminaVerification(props) {
|
|
|
2368
3363
|
}
|
|
2369
3364
|
return bindings.filter((binding) => !rendered.has(binding.fieldPointer));
|
|
2370
3365
|
}, [classified, bindings]);
|
|
2371
|
-
const overlayRects = (0,
|
|
3366
|
+
const overlayRects = (0, import_react4.useMemo)(() => {
|
|
2372
3367
|
const rects = [];
|
|
2373
3368
|
for (const field of classified.headers) {
|
|
2374
3369
|
if (field.coordinates) {
|
|
@@ -2402,48 +3397,87 @@ function GeminaVerification(props) {
|
|
|
2402
3397
|
}
|
|
2403
3398
|
return rects.length > 0 ? rects : void 0;
|
|
2404
3399
|
}, [classified]);
|
|
2405
|
-
const hasHebrewContent = (0,
|
|
3400
|
+
const hasHebrewContent = (0, import_react4.useMemo)(
|
|
2406
3401
|
() => bindings.some((binding) => HEBREW_RE.test(toInputString(binding.extracted))),
|
|
2407
3402
|
[bindings]
|
|
2408
3403
|
);
|
|
2409
3404
|
const effectiveDir = dir === "auto" ? hasHebrewContent ? "rtl" : "ltr" : dir;
|
|
2410
|
-
const
|
|
2411
|
-
const
|
|
2412
|
-
for (const binding of bindings) {
|
|
2413
|
-
map.set(binding.key.raw, binding);
|
|
2414
|
-
}
|
|
2415
|
-
return map;
|
|
2416
|
-
}, [bindings]);
|
|
2417
|
-
const bindingsByRawKeyRef = (0, import_react3.useRef)(bindingsByRawKey);
|
|
2418
|
-
bindingsByRawKeyRef.current = bindingsByRawKey;
|
|
2419
|
-
const handleEdit = (0, import_react3.useCallback)((rawKey, value) => {
|
|
2420
|
-
const binding = bindingsByRawKeyRef.current.get(rawKey);
|
|
2421
|
-
const pristine = binding !== void 0 && value === toInputString(binding.extracted);
|
|
3405
|
+
const handleEdit = (0, import_react4.useCallback)((editKey, value, binding) => {
|
|
3406
|
+
const pristine = value === toInputString(binding.extracted);
|
|
2422
3407
|
setEdits((prev) => {
|
|
2423
3408
|
if (pristine) {
|
|
2424
|
-
if (!prev.has(
|
|
3409
|
+
if (!prev.has(editKey)) {
|
|
2425
3410
|
return prev;
|
|
2426
3411
|
}
|
|
2427
3412
|
const next2 = new Map(prev);
|
|
2428
|
-
next2.delete(
|
|
3413
|
+
next2.delete(editKey);
|
|
2429
3414
|
return next2;
|
|
2430
3415
|
}
|
|
2431
|
-
if (prev.get(
|
|
3416
|
+
if (prev.get(editKey) === value) {
|
|
2432
3417
|
return prev;
|
|
2433
3418
|
}
|
|
2434
3419
|
const next = new Map(prev);
|
|
2435
|
-
next.set(
|
|
3420
|
+
next.set(editKey, value);
|
|
2436
3421
|
return next;
|
|
2437
3422
|
});
|
|
2438
3423
|
}, []);
|
|
2439
|
-
const
|
|
2440
|
-
|
|
3424
|
+
const plannedTables = (0, import_react4.useMemo)(() => {
|
|
3425
|
+
const tables = loaded?.rowMutableTables ?? [];
|
|
3426
|
+
if (tables.length === 0) {
|
|
3427
|
+
return NO_PLANNED_TABLES;
|
|
3428
|
+
}
|
|
3429
|
+
const out = /* @__PURE__ */ new Map();
|
|
3430
|
+
for (const table of tables) {
|
|
3431
|
+
const plan = rowPlans.get(table.pointer);
|
|
3432
|
+
if (plan === void 0) {
|
|
3433
|
+
continue;
|
|
3434
|
+
}
|
|
3435
|
+
const classifiedTable = classified.tables.find(
|
|
3436
|
+
(candidate) => matchesTablePointer(table.pointer, candidate.pointer)
|
|
3437
|
+
);
|
|
3438
|
+
const columns = displayColumns(table, classifiedTable?.columns ?? []);
|
|
3439
|
+
out.set(table.pointer, planTableCells(table, plan, columns, bindingsByRawKey));
|
|
3440
|
+
}
|
|
3441
|
+
return out;
|
|
3442
|
+
}, [loaded, rowPlans, classified, bindingsByRawKey]);
|
|
3443
|
+
const cellViews = (0, import_react4.useMemo)(
|
|
3444
|
+
() => collectCellViews(bindings, plannedTables),
|
|
3445
|
+
[bindings, plannedTables]
|
|
3446
|
+
);
|
|
3447
|
+
const submissionTables = (0, import_react4.useMemo)(
|
|
3448
|
+
() => pruneEmptyAddedRows(plannedTables, edits),
|
|
3449
|
+
[plannedTables, edits]
|
|
3450
|
+
);
|
|
3451
|
+
const submissionCells = (0, import_react4.useMemo)(
|
|
3452
|
+
() => collectCellViews(bindings, submissionTables),
|
|
3453
|
+
[bindings, submissionTables]
|
|
3454
|
+
);
|
|
3455
|
+
const rowSources = (0, import_react4.useMemo)(() => {
|
|
3456
|
+
const entries = [];
|
|
3457
|
+
for (const table of loaded?.rowMutableTables ?? []) {
|
|
3458
|
+
const rows = submissionTables.get(table.pointer);
|
|
3459
|
+
if (rows === void 0) {
|
|
3460
|
+
continue;
|
|
3461
|
+
}
|
|
3462
|
+
const plan = rows.map((row) => row.entry);
|
|
3463
|
+
if (isIdentityPlan(plan, countRowsAt(loaded?.values, table.pointer))) {
|
|
3464
|
+
continue;
|
|
3465
|
+
}
|
|
3466
|
+
entries.push({ table: table.pointer, sources: rowSourcesOf(plan) });
|
|
3467
|
+
}
|
|
3468
|
+
return entries;
|
|
3469
|
+
}, [loaded, submissionTables]);
|
|
3470
|
+
const submission = (0, import_react4.useMemo)(
|
|
3471
|
+
() => composeSubmission(bindings, edits, { cells: submissionCells, rowSources }),
|
|
3472
|
+
[bindings, edits, submissionCells, rowSources]
|
|
3473
|
+
);
|
|
3474
|
+
const handleFlash = (0, import_react4.useCallback)((rects) => {
|
|
2441
3475
|
setFlashRects(rects.map((rect) => ({ points: rect.points })));
|
|
2442
3476
|
}, []);
|
|
2443
|
-
const handleFlashComplete = (0,
|
|
3477
|
+
const handleFlashComplete = (0, import_react4.useCallback)(() => {
|
|
2444
3478
|
setFlashRects(null);
|
|
2445
3479
|
}, []);
|
|
2446
|
-
const handleImageExpired = (0,
|
|
3480
|
+
const handleImageExpired = (0, import_react4.useCallback)(() => {
|
|
2447
3481
|
const now = Date.now();
|
|
2448
3482
|
if (now - lastImageRefreshRef.current < IMAGE_REFRESH_THROTTLE_MS) {
|
|
2449
3483
|
return;
|
|
@@ -2461,10 +3495,52 @@ function GeminaVerification(props) {
|
|
|
2461
3495
|
}).catch(() => {
|
|
2462
3496
|
});
|
|
2463
3497
|
}, [fetchWithRetry]);
|
|
2464
|
-
const handleRetry = (0,
|
|
3498
|
+
const handleRetry = (0, import_react4.useCallback)(() => {
|
|
2465
3499
|
void load();
|
|
2466
3500
|
}, [load]);
|
|
2467
|
-
const
|
|
3501
|
+
const handleAddRow = (0, import_react4.useCallback)((tablePointer, afterPosition) => {
|
|
3502
|
+
const id = nextAddedRowId(tablePointer);
|
|
3503
|
+
setRowPlans((prev) => {
|
|
3504
|
+
const plan = prev.get(tablePointer);
|
|
3505
|
+
if (plan === void 0) {
|
|
3506
|
+
return prev;
|
|
3507
|
+
}
|
|
3508
|
+
const next = new Map(prev);
|
|
3509
|
+
next.set(tablePointer, insertRowAfter(plan, afterPosition, id));
|
|
3510
|
+
return next;
|
|
3511
|
+
});
|
|
3512
|
+
}, []);
|
|
3513
|
+
const handleRemoveRow = (0, import_react4.useCallback)((tablePointer, position) => {
|
|
3514
|
+
setRowPlans((prev) => {
|
|
3515
|
+
const plan = prev.get(tablePointer);
|
|
3516
|
+
if (plan === void 0) {
|
|
3517
|
+
return prev;
|
|
3518
|
+
}
|
|
3519
|
+
const nextPlan = removeRow(plan, position);
|
|
3520
|
+
if (nextPlan === plan) {
|
|
3521
|
+
return prev;
|
|
3522
|
+
}
|
|
3523
|
+
const next = new Map(prev);
|
|
3524
|
+
next.set(tablePointer, nextPlan);
|
|
3525
|
+
return next;
|
|
3526
|
+
});
|
|
3527
|
+
}, []);
|
|
3528
|
+
const pairErrors = (0, import_react4.useMemo)(() => unitSizePairErrors(cellViews, edits), [cellViews, edits]);
|
|
3529
|
+
const invalidCount = (0, import_react4.useMemo)(() => {
|
|
3530
|
+
const rowLevel = pairErrors.size;
|
|
3531
|
+
if (edits.size === 0) {
|
|
3532
|
+
return rowLevel;
|
|
3533
|
+
}
|
|
3534
|
+
const byEditKey = new Map(cellViews.map((view) => [view.editKey, view.binding]));
|
|
3535
|
+
let count = 0;
|
|
3536
|
+
for (const [editKey, value] of edits) {
|
|
3537
|
+
if (!pairErrors.has(editKey) && validateInput(value, byEditKey.get(editKey)?.field) !== null) {
|
|
3538
|
+
count += 1;
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
return count + rowLevel;
|
|
3542
|
+
}, [edits, cellViews, pairErrors]);
|
|
3543
|
+
const doSubmit = (0, import_react4.useCallback)(async () => {
|
|
2468
3544
|
if (submitInFlightRef.current) {
|
|
2469
3545
|
return;
|
|
2470
3546
|
}
|
|
@@ -2477,7 +3553,13 @@ function GeminaVerification(props) {
|
|
|
2477
3553
|
const token = await tokenManager.getToken();
|
|
2478
3554
|
return import_sdk.GeminaClient.withSessionToken(token, baseUrl).documents.validateDocumentExtraction({
|
|
2479
3555
|
targetDocumentExtractionId: extractionId,
|
|
2480
|
-
|
|
3556
|
+
// Conditional spread, matching the house pattern: without a row edit
|
|
3557
|
+
// the request body is byte-identical to what it was before this
|
|
3558
|
+
// feature, so nothing changes for the overwhelmingly common path.
|
|
3559
|
+
extractionValidationInDTO: {
|
|
3560
|
+
data: body.data,
|
|
3561
|
+
...body.rowSources.length > 0 ? { rowSources: body.rowSources } : {}
|
|
3562
|
+
}
|
|
2481
3563
|
});
|
|
2482
3564
|
};
|
|
2483
3565
|
try {
|
|
@@ -2525,20 +3607,20 @@ function GeminaVerification(props) {
|
|
|
2525
3607
|
submitInFlightRef.current = false;
|
|
2526
3608
|
}
|
|
2527
3609
|
}, [submission, tokenManager, baseUrl, extractionId, load]);
|
|
2528
|
-
const handleSubmitClick = (0,
|
|
3610
|
+
const handleSubmitClick = (0, import_react4.useCallback)(() => {
|
|
2529
3611
|
setPhase({ name: "confirming" });
|
|
2530
3612
|
}, []);
|
|
2531
|
-
const handleConfirm = (0,
|
|
3613
|
+
const handleConfirm = (0, import_react4.useCallback)(() => {
|
|
2532
3614
|
void doSubmit();
|
|
2533
3615
|
}, [doSubmit]);
|
|
2534
|
-
const handleCancelConfirm = (0,
|
|
3616
|
+
const handleCancelConfirm = (0, import_react4.useCallback)(() => {
|
|
2535
3617
|
restoreFocusRef.current = true;
|
|
2536
3618
|
setPhase({ name: "review" });
|
|
2537
3619
|
}, []);
|
|
2538
|
-
const handleRetrySubmit = (0,
|
|
3620
|
+
const handleRetrySubmit = (0, import_react4.useCallback)(() => {
|
|
2539
3621
|
void doSubmit();
|
|
2540
3622
|
}, [doSubmit]);
|
|
2541
|
-
const handleConfirmKeyDown = (0,
|
|
3623
|
+
const handleConfirmKeyDown = (0, import_react4.useCallback)(
|
|
2542
3624
|
(event) => {
|
|
2543
3625
|
if (phase.name !== "confirming") {
|
|
2544
3626
|
return;
|
|
@@ -2569,7 +3651,7 @@ function GeminaVerification(props) {
|
|
|
2569
3651
|
},
|
|
2570
3652
|
[phase.name, handleCancelConfirm]
|
|
2571
3653
|
);
|
|
2572
|
-
(0,
|
|
3654
|
+
(0, import_react4.useEffect)(() => {
|
|
2573
3655
|
if (phase.name === "confirming") {
|
|
2574
3656
|
confirmButtonRef.current?.focus();
|
|
2575
3657
|
} else if (phase.name === "review" && restoreFocusRef.current) {
|
|
@@ -2588,13 +3670,13 @@ function GeminaVerification(props) {
|
|
|
2588
3670
|
stacked ? "gemina-verification--stacked" : "",
|
|
2589
3671
|
className ?? ""
|
|
2590
3672
|
].filter((part) => part.length > 0).join(" ");
|
|
2591
|
-
const dialogTextId = (0,
|
|
3673
|
+
const dialogTextId = (0, import_react4.useId)();
|
|
2592
3674
|
const renderReview = (reviewPhase) => {
|
|
2593
3675
|
const overlayUp = reviewPhase.name === "confirming" || reviewPhase.name === "submitting";
|
|
2594
|
-
return /* @__PURE__ */ (0,
|
|
2595
|
-
alreadyValidated && /* @__PURE__ */ (0,
|
|
2596
|
-
/* @__PURE__ */ (0,
|
|
2597
|
-
imageUrl !== null && /* @__PURE__ */ (0,
|
|
3676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
3677
|
+
alreadyValidated && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__banner", children: ALREADY_VALIDATED_TEXT }),
|
|
3678
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__panes", children: [
|
|
3679
|
+
imageUrl !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2598
3680
|
VerificationViewer,
|
|
2599
3681
|
{
|
|
2600
3682
|
src: imageUrl,
|
|
@@ -2604,7 +3686,7 @@ function GeminaVerification(props) {
|
|
|
2604
3686
|
onImageExpired: handleImageExpired
|
|
2605
3687
|
}
|
|
2606
3688
|
),
|
|
2607
|
-
/* @__PURE__ */ (0,
|
|
3689
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2608
3690
|
VerificationForm,
|
|
2609
3691
|
{
|
|
2610
3692
|
classified,
|
|
@@ -2613,18 +3695,23 @@ function GeminaVerification(props) {
|
|
|
2613
3695
|
edits,
|
|
2614
3696
|
onEdit: handleEdit,
|
|
2615
3697
|
readOnly: alreadyValidated,
|
|
2616
|
-
onFlash: handleFlash
|
|
3698
|
+
onFlash: handleFlash,
|
|
3699
|
+
pairErrors,
|
|
3700
|
+
rowMutableTables: loaded?.rowMutableTables,
|
|
3701
|
+
plannedTables,
|
|
3702
|
+
onAddRow: handleAddRow,
|
|
3703
|
+
onRemoveRow: handleRemoveRow
|
|
2617
3704
|
}
|
|
2618
3705
|
)
|
|
2619
3706
|
] }),
|
|
2620
|
-
reviewPhase.name === "submit-error" && /* @__PURE__ */ (0,
|
|
3707
|
+
reviewPhase.name === "submit-error" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2621
3708
|
"div",
|
|
2622
3709
|
{
|
|
2623
3710
|
className: "gemina-verification__banner gemina-verification__banner--error gemina-verification__submit-error",
|
|
2624
3711
|
role: "alert",
|
|
2625
3712
|
children: [
|
|
2626
|
-
/* @__PURE__ */ (0,
|
|
2627
|
-
/* @__PURE__ */ (0,
|
|
3713
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: reviewPhase.message }),
|
|
3714
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2628
3715
|
"button",
|
|
2629
3716
|
{
|
|
2630
3717
|
type: "button",
|
|
@@ -2637,21 +3724,21 @@ function GeminaVerification(props) {
|
|
|
2637
3724
|
]
|
|
2638
3725
|
}
|
|
2639
3726
|
),
|
|
2640
|
-
/* @__PURE__ */ (0,
|
|
2641
|
-
!alreadyValidated && /* @__PURE__ */ (0,
|
|
2642
|
-
/* @__PURE__ */ (0,
|
|
3727
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__footer", children: [
|
|
3728
|
+
!alreadyValidated && (invalidCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__attention", "aria-live": "polite", children: invalidCount === 1 ? "1 field needs attention" : `${invalidCount} fields need attention` }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__progress", "aria-live": "polite", children: `${submission.confirmed} confirmed \xB7 ${submission.corrected} corrected` })),
|
|
3729
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2643
3730
|
"button",
|
|
2644
3731
|
{
|
|
2645
3732
|
type: "button",
|
|
2646
3733
|
ref: submitButtonRef,
|
|
2647
3734
|
className: "gemina-verification__submit",
|
|
2648
|
-
disabled: alreadyValidated || reviewPhase.name !== "review",
|
|
3735
|
+
disabled: alreadyValidated || reviewPhase.name !== "review" || invalidCount > 0,
|
|
2649
3736
|
onClick: handleSubmitClick,
|
|
2650
|
-
children: "Submit
|
|
3737
|
+
children: "Submit"
|
|
2651
3738
|
}
|
|
2652
3739
|
)
|
|
2653
3740
|
] }),
|
|
2654
|
-
overlayUp && /* @__PURE__ */ (0,
|
|
3741
|
+
overlayUp && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2655
3742
|
"div",
|
|
2656
3743
|
{
|
|
2657
3744
|
className: "gemina-verification__confirm",
|
|
@@ -2661,7 +3748,7 @@ function GeminaVerification(props) {
|
|
|
2661
3748
|
event.preventDefault();
|
|
2662
3749
|
}
|
|
2663
3750
|
},
|
|
2664
|
-
children: /* @__PURE__ */ (0,
|
|
3751
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2665
3752
|
"div",
|
|
2666
3753
|
{
|
|
2667
3754
|
className: "gemina-verification__confirm-dialog",
|
|
@@ -2669,9 +3756,9 @@ function GeminaVerification(props) {
|
|
|
2669
3756
|
"aria-modal": "true",
|
|
2670
3757
|
"aria-labelledby": dialogTextId,
|
|
2671
3758
|
children: [
|
|
2672
|
-
/* @__PURE__ */ (0,
|
|
2673
|
-
/* @__PURE__ */ (0,
|
|
2674
|
-
/* @__PURE__ */ (0,
|
|
3759
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { id: dialogTextId, className: "gemina-verification__confirm-text", children: reviewPhase.name === "submitting" ? SUBMITTING_TEXT : CONFIRM_TEXT }),
|
|
3760
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__confirm-actions", children: [
|
|
3761
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2675
3762
|
"button",
|
|
2676
3763
|
{
|
|
2677
3764
|
type: "button",
|
|
@@ -2682,7 +3769,7 @@ function GeminaVerification(props) {
|
|
|
2682
3769
|
children: "Cancel"
|
|
2683
3770
|
}
|
|
2684
3771
|
),
|
|
2685
|
-
/* @__PURE__ */ (0,
|
|
3772
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2686
3773
|
"button",
|
|
2687
3774
|
{
|
|
2688
3775
|
type: "button",
|
|
@@ -2704,16 +3791,16 @@ function GeminaVerification(props) {
|
|
|
2704
3791
|
const content = (() => {
|
|
2705
3792
|
switch (phase.name) {
|
|
2706
3793
|
case "loading":
|
|
2707
|
-
return /* @__PURE__ */ (0,
|
|
3794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__state", role: "status", children: LOADING_TEXT });
|
|
2708
3795
|
case "unavailable":
|
|
2709
|
-
return /* @__PURE__ */ (0,
|
|
3796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2710
3797
|
"div",
|
|
2711
3798
|
{
|
|
2712
3799
|
className: "gemina-verification__state",
|
|
2713
3800
|
role: ALERT_REASONS.has(phase.reason) ? "alert" : "status",
|
|
2714
3801
|
children: [
|
|
2715
|
-
/* @__PURE__ */ (0,
|
|
2716
|
-
phase.canRetry && /* @__PURE__ */ (0,
|
|
3802
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: phase.message }),
|
|
3803
|
+
phase.canRetry && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "gemina-verification__retry", onClick: handleRetry, children: "Retry" })
|
|
2717
3804
|
]
|
|
2718
3805
|
}
|
|
2719
3806
|
);
|
|
@@ -2723,7 +3810,7 @@ function GeminaVerification(props) {
|
|
|
2723
3810
|
case "submit-error":
|
|
2724
3811
|
return renderReview(phase);
|
|
2725
3812
|
case "done":
|
|
2726
|
-
return /* @__PURE__ */ (0,
|
|
3813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2727
3814
|
"div",
|
|
2728
3815
|
{
|
|
2729
3816
|
ref: doneStateRef,
|
|
@@ -2731,7 +3818,7 @@ function GeminaVerification(props) {
|
|
|
2731
3818
|
className: "gemina-verification__state gemina-verification__state--done",
|
|
2732
3819
|
role: "status",
|
|
2733
3820
|
children: [
|
|
2734
|
-
/* @__PURE__ */ (0,
|
|
3821
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "gemina-verification__done-check", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2735
3822
|
"path",
|
|
2736
3823
|
{
|
|
2737
3824
|
d: "M4 10.5l4 4 8-9",
|
|
@@ -2741,14 +3828,14 @@ function GeminaVerification(props) {
|
|
|
2741
3828
|
strokeLinejoin: "round"
|
|
2742
3829
|
}
|
|
2743
3830
|
) }) }),
|
|
2744
|
-
/* @__PURE__ */ (0,
|
|
2745
|
-
/* @__PURE__ */ (0,
|
|
3831
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__done-title", children: DONE_TITLE_TEXT }),
|
|
3832
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__progress", children: `${phase.confirmed} confirmed \xB7 ${phase.corrected} corrected` })
|
|
2746
3833
|
]
|
|
2747
3834
|
}
|
|
2748
3835
|
);
|
|
2749
3836
|
}
|
|
2750
3837
|
})();
|
|
2751
|
-
return /* @__PURE__ */ (0,
|
|
3838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { ref: rootRef, className: rootClassName, dir: effectiveDir, children: content });
|
|
2752
3839
|
}
|
|
2753
3840
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2754
3841
|
0 && (module.exports = {
|