@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/index.cjs
CHANGED
|
@@ -221,7 +221,7 @@ async function readErrorEnvelope(error) {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
// src/version.ts
|
|
224
|
-
var VERSION = "0.
|
|
224
|
+
var VERSION = "0.10.0";
|
|
225
225
|
|
|
226
226
|
// src/chat.tsx
|
|
227
227
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -870,9 +870,181 @@ function GeminaChat(props) {
|
|
|
870
870
|
}
|
|
871
871
|
|
|
872
872
|
// src/verification/index.tsx
|
|
873
|
-
var
|
|
873
|
+
var import_react5 = require("react");
|
|
874
874
|
var import_sdk2 = require("@gemina/sdk");
|
|
875
875
|
|
|
876
|
+
// src/verification/field-types.ts
|
|
877
|
+
var ISO_4217_CODES = [
|
|
878
|
+
"AED",
|
|
879
|
+
"ARS",
|
|
880
|
+
"AUD",
|
|
881
|
+
"BGN",
|
|
882
|
+
"BRL",
|
|
883
|
+
"CAD",
|
|
884
|
+
"CHF",
|
|
885
|
+
"CLP",
|
|
886
|
+
"CNY",
|
|
887
|
+
"COP",
|
|
888
|
+
"CZK",
|
|
889
|
+
"DKK",
|
|
890
|
+
"EGP",
|
|
891
|
+
"EUR",
|
|
892
|
+
"GBP",
|
|
893
|
+
"HKD",
|
|
894
|
+
"HRK",
|
|
895
|
+
"HUF",
|
|
896
|
+
"IDR",
|
|
897
|
+
"ILS",
|
|
898
|
+
"INR",
|
|
899
|
+
"ISK",
|
|
900
|
+
"JPY",
|
|
901
|
+
"KRW",
|
|
902
|
+
"MAD",
|
|
903
|
+
"MXN",
|
|
904
|
+
"MYR",
|
|
905
|
+
"NGN",
|
|
906
|
+
"NOK",
|
|
907
|
+
"NZD",
|
|
908
|
+
"PEN",
|
|
909
|
+
"PHP",
|
|
910
|
+
"PLN",
|
|
911
|
+
"RON",
|
|
912
|
+
"RSD",
|
|
913
|
+
"RUB",
|
|
914
|
+
"SAR",
|
|
915
|
+
"SEK",
|
|
916
|
+
"SGD",
|
|
917
|
+
"THB",
|
|
918
|
+
"TRY",
|
|
919
|
+
"TWD",
|
|
920
|
+
"UAH",
|
|
921
|
+
"USD",
|
|
922
|
+
"VND",
|
|
923
|
+
"ZAR"
|
|
924
|
+
];
|
|
925
|
+
var ISO_4217_SHAPE = /^[A-Za-z]{3}$/;
|
|
926
|
+
var DATE_SHAPE = /^\d{4}-\d{2}-\d{2}$/;
|
|
927
|
+
var NUMERIC_SHAPE = /^[+-]?[\d,_]*\.?\d+$/;
|
|
928
|
+
function toNumber(value) {
|
|
929
|
+
if (!NUMERIC_SHAPE.test(value)) {
|
|
930
|
+
return null;
|
|
931
|
+
}
|
|
932
|
+
const parsed = Number(value.replace(/[,_]/g, ""));
|
|
933
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
934
|
+
}
|
|
935
|
+
function validateInput(value, field) {
|
|
936
|
+
const trimmed = value.trim();
|
|
937
|
+
if (trimmed === "" || !field) {
|
|
938
|
+
return null;
|
|
939
|
+
}
|
|
940
|
+
if (field.enum && field.enum.length > 0) {
|
|
941
|
+
return field.enum.includes(trimmed) ? null : `Choose one of: ${field.enum.join(", ")}`;
|
|
942
|
+
}
|
|
943
|
+
if (field.format === "iso4217") {
|
|
944
|
+
return ISO_4217_SHAPE.test(trimmed) ? null : "Use a 3-letter ISO 4217 code, e.g. USD";
|
|
945
|
+
}
|
|
946
|
+
switch (field.type) {
|
|
947
|
+
case "number":
|
|
948
|
+
return toNumber(trimmed) === null ? "Enter a number" : null;
|
|
949
|
+
case "integer": {
|
|
950
|
+
const parsed = toNumber(trimmed);
|
|
951
|
+
if (parsed === null || !Number.isInteger(parsed)) {
|
|
952
|
+
return "Enter a whole number";
|
|
953
|
+
}
|
|
954
|
+
return null;
|
|
955
|
+
}
|
|
956
|
+
case "date": {
|
|
957
|
+
if (!DATE_SHAPE.test(trimmed)) {
|
|
958
|
+
return "Enter a date as YYYY-MM-DD";
|
|
959
|
+
}
|
|
960
|
+
const [year, month, day] = trimmed.split("-").map(Number);
|
|
961
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
962
|
+
const survives = date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
963
|
+
return survives ? null : "Enter a date as YYYY-MM-DD";
|
|
964
|
+
}
|
|
965
|
+
default:
|
|
966
|
+
return null;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
function readRowMutableTables(raw) {
|
|
970
|
+
if (!Array.isArray(raw)) {
|
|
971
|
+
return [];
|
|
972
|
+
}
|
|
973
|
+
const out = [];
|
|
974
|
+
for (const item of raw) {
|
|
975
|
+
if (item === null || typeof item !== "object") {
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
const source = item;
|
|
979
|
+
if (typeof source.pointer !== "string" || typeof source.keyTemplate !== "string") {
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
out.push({
|
|
983
|
+
pointer: source.pointer,
|
|
984
|
+
keyTemplate: source.keyTemplate,
|
|
985
|
+
// Columns are descriptors keyed by `name` rather than `key`, so they get
|
|
986
|
+
// the same treatment with the name standing in as the identity.
|
|
987
|
+
columns: readDescriptors(
|
|
988
|
+
(Array.isArray(source.columns) ? source.columns : []).map((column) => {
|
|
989
|
+
const record = column ?? {};
|
|
990
|
+
return { ...record, key: record.name };
|
|
991
|
+
})
|
|
992
|
+
)
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
return out;
|
|
996
|
+
}
|
|
997
|
+
function cellSchemaKey(template, index, field) {
|
|
998
|
+
return template.replace(/\{index\}/g, String(index)).replace(/\{field\}/g, field);
|
|
999
|
+
}
|
|
1000
|
+
function coerceInput(value, field) {
|
|
1001
|
+
if (!field) {
|
|
1002
|
+
return value;
|
|
1003
|
+
}
|
|
1004
|
+
switch (field.type) {
|
|
1005
|
+
case "number":
|
|
1006
|
+
case "integer": {
|
|
1007
|
+
const parsed = toNumber(value);
|
|
1008
|
+
return parsed === null ? value : parsed;
|
|
1009
|
+
}
|
|
1010
|
+
case "boolean": {
|
|
1011
|
+
const lowered = value.trim().toLowerCase();
|
|
1012
|
+
if (lowered === "true") return true;
|
|
1013
|
+
if (lowered === "false") return false;
|
|
1014
|
+
return value;
|
|
1015
|
+
}
|
|
1016
|
+
// `date` stays a string: the wire format IS the ISO string, and a Date
|
|
1017
|
+
// object would serialise with a time component the extraction never had.
|
|
1018
|
+
default:
|
|
1019
|
+
return value;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
function readDescriptors(raw) {
|
|
1023
|
+
if (!Array.isArray(raw)) {
|
|
1024
|
+
return [];
|
|
1025
|
+
}
|
|
1026
|
+
const out = [];
|
|
1027
|
+
for (const item of raw) {
|
|
1028
|
+
if (item === null || typeof item !== "object") {
|
|
1029
|
+
continue;
|
|
1030
|
+
}
|
|
1031
|
+
const source = item;
|
|
1032
|
+
if (typeof source.key !== "string") {
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
const roster = source._enum ?? source.enum;
|
|
1036
|
+
out.push({
|
|
1037
|
+
key: source.key,
|
|
1038
|
+
label: typeof source.label === "string" ? source.label : void 0,
|
|
1039
|
+
type: typeof source.type === "string" ? source.type : void 0,
|
|
1040
|
+
enum: Array.isArray(roster) ? roster.map(String) : null,
|
|
1041
|
+
format: typeof source.format === "string" ? source.format : null,
|
|
1042
|
+
description: typeof source.description === "string" ? source.description : null
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
return out;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
876
1048
|
// src/verification/classify.ts
|
|
877
1049
|
var ACRONYMS = /* @__PURE__ */ new Set(["ID", "VAT", "OCR", "PDF", "URL", "API", "HTML", "CSS", "JSON", "XML", "UUID"]);
|
|
878
1050
|
function formatLabel(key) {
|
|
@@ -984,6 +1156,7 @@ function escapeSegment(segment) {
|
|
|
984
1156
|
var ROW_META_KEY = "_rowMeta";
|
|
985
1157
|
function classifyData(data) {
|
|
986
1158
|
const result = {
|
|
1159
|
+
overallConfidence: null,
|
|
987
1160
|
headers: [],
|
|
988
1161
|
simpleLists: [],
|
|
989
1162
|
entities: [],
|
|
@@ -994,6 +1167,7 @@ function classifyData(data) {
|
|
|
994
1167
|
return result;
|
|
995
1168
|
}
|
|
996
1169
|
let rootData = data;
|
|
1170
|
+
result.overallConfidence = readOverallConfidence(rootData);
|
|
997
1171
|
let basePointer = "";
|
|
998
1172
|
if ("data" in rootData && typeof rootData.data === "object" && rootData.data !== null && !Array.isArray(rootData.data)) {
|
|
999
1173
|
for (const [key, value] of Object.entries(rootData)) {
|
|
@@ -1001,6 +1175,7 @@ function classifyData(data) {
|
|
|
1001
1175
|
processField(key, value, result, rootData, "");
|
|
1002
1176
|
}
|
|
1003
1177
|
rootData = rootData.data;
|
|
1178
|
+
result.overallConfidence ?? (result.overallConfidence = readOverallConfidence(rootData));
|
|
1004
1179
|
basePointer = "/data";
|
|
1005
1180
|
}
|
|
1006
1181
|
for (const [key, value] of Object.entries(rootData)) {
|
|
@@ -1008,8 +1183,23 @@ function classifyData(data) {
|
|
|
1008
1183
|
}
|
|
1009
1184
|
return result;
|
|
1010
1185
|
}
|
|
1186
|
+
function readOverallConfidence(source) {
|
|
1187
|
+
const rawLevel = source.overall_confidence ?? source.overallConfidence;
|
|
1188
|
+
const value = extractValue(rawLevel);
|
|
1189
|
+
if (typeof value !== "string" || value.length === 0) return null;
|
|
1190
|
+
const rawReasons = source.confidence_reasons ?? source.confidenceReasons;
|
|
1191
|
+
const reasons = Array.isArray(rawReasons) ? rawReasons.filter((reason) => typeof reason === "string") : [];
|
|
1192
|
+
return { level: value, reasons };
|
|
1193
|
+
}
|
|
1011
1194
|
function processField(key, value, result, parentObj, basePointer) {
|
|
1012
|
-
if ([
|
|
1195
|
+
if ([
|
|
1196
|
+
"confidence",
|
|
1197
|
+
"confidence_reasons",
|
|
1198
|
+
"confidenceReasons",
|
|
1199
|
+
"coordinates",
|
|
1200
|
+
"overall_confidence",
|
|
1201
|
+
"overallConfidence"
|
|
1202
|
+
].includes(key)) {
|
|
1013
1203
|
return;
|
|
1014
1204
|
}
|
|
1015
1205
|
const pointer = `${basePointer}/${escapeSegment(key)}`;
|
|
@@ -1083,11 +1273,6 @@ function processField(key, value, result, parentObj, basePointer) {
|
|
|
1083
1273
|
level: parentObj[confidenceKey],
|
|
1084
1274
|
reasons: parentObj[reasonsKey] || []
|
|
1085
1275
|
};
|
|
1086
|
-
} else if (parentObj["overall_confidence"]) {
|
|
1087
|
-
overallConfidence = {
|
|
1088
|
-
level: parentObj["overall_confidence"],
|
|
1089
|
-
reasons: parentObj["confidence_reasons"] || []
|
|
1090
|
-
};
|
|
1091
1276
|
}
|
|
1092
1277
|
}
|
|
1093
1278
|
result.tables.push({
|
|
@@ -1194,6 +1379,9 @@ function parseSchemaKey(raw) {
|
|
|
1194
1379
|
return { raw, label: match[1], pointer: match[2] };
|
|
1195
1380
|
}
|
|
1196
1381
|
var NOT_FOUND = /* @__PURE__ */ Symbol("gemina-verification-not-found");
|
|
1382
|
+
function snakeToCamel(segment) {
|
|
1383
|
+
return segment.replace(/_([a-zA-Z0-9])/g, (_unused, ch) => ch.toUpperCase());
|
|
1384
|
+
}
|
|
1197
1385
|
|
|
1198
1386
|
// src/verification/bindings.ts
|
|
1199
1387
|
function unescapeSegment(raw) {
|
|
@@ -1202,9 +1390,6 @@ function unescapeSegment(raw) {
|
|
|
1202
1390
|
function escapeSegment2(segment) {
|
|
1203
1391
|
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
1204
1392
|
}
|
|
1205
|
-
function snakeToCamel(segment) {
|
|
1206
|
-
return segment.replace(/_([a-zA-Z0-9])/g, (_, ch) => ch.toUpperCase());
|
|
1207
|
-
}
|
|
1208
1393
|
function camelizePointer(pointer) {
|
|
1209
1394
|
if (!pointer.startsWith("/")) {
|
|
1210
1395
|
return pointer;
|
|
@@ -1255,7 +1440,13 @@ function resolveCasingAware(doc, pointer) {
|
|
|
1255
1440
|
function stripValueSuffix(pointer) {
|
|
1256
1441
|
return pointer.endsWith("/value") ? pointer.slice(0, -"/value".length) : pointer;
|
|
1257
1442
|
}
|
|
1258
|
-
function buildBindings(validationSchema, values) {
|
|
1443
|
+
function buildBindings(validationSchema, values, fields) {
|
|
1444
|
+
const descriptors = /* @__PURE__ */ new Map();
|
|
1445
|
+
for (const descriptor of fields ?? []) {
|
|
1446
|
+
if (typeof descriptor?.key === "string") {
|
|
1447
|
+
descriptors.set(descriptor.key, descriptor);
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1259
1450
|
const bindings = [];
|
|
1260
1451
|
for (const raw of validationSchema) {
|
|
1261
1452
|
const key = parseSchemaKey(raw);
|
|
@@ -1270,7 +1461,8 @@ function buildBindings(validationSchema, values) {
|
|
|
1270
1461
|
serverValue,
|
|
1271
1462
|
extracted,
|
|
1272
1463
|
fieldPointer: stripValueSuffix(resolvedPointer),
|
|
1273
|
-
editable
|
|
1464
|
+
editable,
|
|
1465
|
+
field: descriptors.get(key.raw)
|
|
1274
1466
|
});
|
|
1275
1467
|
}
|
|
1276
1468
|
return bindings;
|
|
@@ -1291,39 +1483,359 @@ function toInputString(extracted) {
|
|
|
1291
1483
|
}
|
|
1292
1484
|
return String(extracted);
|
|
1293
1485
|
}
|
|
1294
|
-
function composeSubmission(bindings, edits) {
|
|
1486
|
+
function composeSubmission(bindings, edits, options = {}) {
|
|
1487
|
+
const cells = options.cells ?? bindings.map((binding) => ({
|
|
1488
|
+
editKey: binding.key.raw,
|
|
1489
|
+
submitKey: binding.key.raw,
|
|
1490
|
+
column: binding.key.label,
|
|
1491
|
+
rowKey: binding.key.raw,
|
|
1492
|
+
binding,
|
|
1493
|
+
added: false
|
|
1494
|
+
}));
|
|
1295
1495
|
const data = {};
|
|
1296
1496
|
const byLabel = {};
|
|
1297
1497
|
let confirmed = 0;
|
|
1298
1498
|
let corrected = 0;
|
|
1299
|
-
for (const
|
|
1300
|
-
const
|
|
1499
|
+
for (const cell of cells) {
|
|
1500
|
+
const { binding } = cell;
|
|
1501
|
+
const label = parseSchemaKey(cell.submitKey)?.label ?? binding.key.label;
|
|
1502
|
+
const edit = edits.get(cell.editKey);
|
|
1301
1503
|
if (edit !== void 0) {
|
|
1302
1504
|
const trimmed = edit.trim();
|
|
1303
1505
|
if (trimmed === "" && binding.serverValue === NOT_FOUND) {
|
|
1304
1506
|
continue;
|
|
1305
1507
|
}
|
|
1306
|
-
const value = trimmed === "" ? null : trimmed;
|
|
1307
|
-
data[
|
|
1308
|
-
byLabel[
|
|
1508
|
+
const value = trimmed === "" ? null : coerceInput(trimmed, binding.field);
|
|
1509
|
+
data[cell.submitKey] = value;
|
|
1510
|
+
byLabel[label] = value;
|
|
1309
1511
|
corrected += 1;
|
|
1310
1512
|
} else {
|
|
1311
1513
|
if (binding.serverValue === NOT_FOUND) {
|
|
1312
1514
|
continue;
|
|
1313
1515
|
}
|
|
1314
|
-
data[
|
|
1315
|
-
byLabel[
|
|
1516
|
+
data[cell.submitKey] = binding.serverValue;
|
|
1517
|
+
byLabel[label] = binding.serverValue;
|
|
1316
1518
|
confirmed += 1;
|
|
1317
1519
|
}
|
|
1318
1520
|
}
|
|
1319
|
-
return { data, byLabel, confirmed, corrected };
|
|
1521
|
+
return { data, byLabel, confirmed, corrected, rowSources: options.rowSources ?? [] };
|
|
1522
|
+
}
|
|
1523
|
+
function countRowsAt(values, pointer) {
|
|
1524
|
+
const { node } = resolveCasingAware(values, pointer);
|
|
1525
|
+
return Array.isArray(node) ? node.length : 0;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
// src/verification/row-plan.ts
|
|
1529
|
+
var addedRowCounter = 0;
|
|
1530
|
+
function initialRowPlan(extractedCount, scope = "") {
|
|
1531
|
+
return Array.from({ length: Math.max(0, extractedCount) }, (_unused, index) => ({
|
|
1532
|
+
// Derived from the source index, so it is stable across re-renders without
|
|
1533
|
+
// any state to carry — an extracted row's identity never changes.
|
|
1534
|
+
id: `${scope}#row-${index}`,
|
|
1535
|
+
source: index
|
|
1536
|
+
}));
|
|
1537
|
+
}
|
|
1538
|
+
function nextAddedRowId(scope = "") {
|
|
1539
|
+
addedRowCounter += 1;
|
|
1540
|
+
return `${scope}#added-${addedRowCounter}`;
|
|
1541
|
+
}
|
|
1542
|
+
function removeRow(plan, position) {
|
|
1543
|
+
if (position < 0 || position >= plan.length) {
|
|
1544
|
+
return plan;
|
|
1545
|
+
}
|
|
1546
|
+
return plan.filter((_entry, index) => index !== position);
|
|
1547
|
+
}
|
|
1548
|
+
function insertRowAfter(plan, position, id) {
|
|
1549
|
+
const added = { id: id ?? nextAddedRowId(), source: null };
|
|
1550
|
+
const at = Math.min(Math.max(position + 1, 0), plan.length);
|
|
1551
|
+
return [...plan.slice(0, at), added, ...plan.slice(at)];
|
|
1552
|
+
}
|
|
1553
|
+
function cellEditKey(rowId, column) {
|
|
1554
|
+
return `cell:${rowId}|col:${column}`;
|
|
1555
|
+
}
|
|
1556
|
+
function rowSourcesOf(plan) {
|
|
1557
|
+
return plan.map((entry) => entry.source);
|
|
1558
|
+
}
|
|
1559
|
+
function isIdentityPlan(plan, extractedCount) {
|
|
1560
|
+
return plan.length === extractedCount && plan.every((entry, index) => entry.source === index);
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
// src/verification/row-cells.ts
|
|
1564
|
+
function syntheticBinding(submitKey, descriptor) {
|
|
1565
|
+
const key = parseSchemaKey(submitKey);
|
|
1566
|
+
if (key === null) {
|
|
1567
|
+
return null;
|
|
1568
|
+
}
|
|
1569
|
+
return {
|
|
1570
|
+
key,
|
|
1571
|
+
serverValue: NOT_FOUND,
|
|
1572
|
+
extracted: NOT_FOUND,
|
|
1573
|
+
// No extracted node, so nothing to point at on the document.
|
|
1574
|
+
fieldPointer: key.pointer,
|
|
1575
|
+
editable: true,
|
|
1576
|
+
field: descriptor
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
function planTableCells(table, plan, columns, bindingsByRawKey) {
|
|
1580
|
+
const descriptors = /* @__PURE__ */ new Map();
|
|
1581
|
+
for (const column of table.columns) {
|
|
1582
|
+
if (typeof column.key === "string") {
|
|
1583
|
+
descriptors.set(column.key, column);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
return plan.map((entry, submittedIndex) => {
|
|
1587
|
+
const cells = [];
|
|
1588
|
+
for (const column of columns) {
|
|
1589
|
+
const submitKey = cellSchemaKey(table.keyTemplate, submittedIndex, column);
|
|
1590
|
+
const editKey = cellEditKey(entry.id, column);
|
|
1591
|
+
const extractedKey = entry.source === null ? null : cellSchemaKey(table.keyTemplate, entry.source, column);
|
|
1592
|
+
const existing = extractedKey === null ? void 0 : bindingsByRawKey.get(extractedKey);
|
|
1593
|
+
const binding = existing ?? syntheticBinding(submitKey, descriptors.get(column));
|
|
1594
|
+
if (binding === null) {
|
|
1595
|
+
continue;
|
|
1596
|
+
}
|
|
1597
|
+
cells.push({ column, editKey, submitKey, binding, added: existing === void 0 });
|
|
1598
|
+
}
|
|
1599
|
+
return { entry, cells };
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
function displayColumns(table, classifiedColumns) {
|
|
1603
|
+
const declared = table.columns.map((column) => column.key).filter((name) => typeof name === "string");
|
|
1604
|
+
const declaredAliases = new Set(declared.map(snakeToCamel));
|
|
1605
|
+
return [
|
|
1606
|
+
...declared,
|
|
1607
|
+
...classifiedColumns.filter((name) => !declaredAliases.has(snakeToCamel(name)))
|
|
1608
|
+
];
|
|
1609
|
+
}
|
|
1610
|
+
function matchesTablePointer(serverPointer, classifiedPointer) {
|
|
1611
|
+
return serverPointer === classifiedPointer || snakeToCamel(serverPointer) === classifiedPointer;
|
|
1612
|
+
}
|
|
1613
|
+
function splitPointer(pointer) {
|
|
1614
|
+
const cut = pointer.lastIndexOf("/");
|
|
1615
|
+
return cut <= 0 ? null : { row: pointer.slice(0, cut), field: pointer.slice(cut + 1) };
|
|
1616
|
+
}
|
|
1617
|
+
function collectCellViews(bindings, plannedTables) {
|
|
1618
|
+
const views = [];
|
|
1619
|
+
const ownedPrefixes = [...plannedTables.keys()].map((pointer) => `${pointer}/`);
|
|
1620
|
+
for (const rows of plannedTables.values()) {
|
|
1621
|
+
for (const row of rows) {
|
|
1622
|
+
for (const cell of row.cells) {
|
|
1623
|
+
views.push({
|
|
1624
|
+
editKey: cell.editKey,
|
|
1625
|
+
submitKey: cell.submitKey,
|
|
1626
|
+
column: cell.column,
|
|
1627
|
+
rowKey: row.entry.id,
|
|
1628
|
+
binding: cell.binding,
|
|
1629
|
+
added: cell.added
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
for (const binding of bindings) {
|
|
1635
|
+
if (ownedPrefixes.some((prefix) => binding.key.pointer.startsWith(prefix))) {
|
|
1636
|
+
continue;
|
|
1637
|
+
}
|
|
1638
|
+
const split = splitPointer(binding.key.pointer);
|
|
1639
|
+
views.push({
|
|
1640
|
+
// Outside a plan all three identities coincide, which is why none of
|
|
1641
|
+
// this was needed before row editing.
|
|
1642
|
+
editKey: binding.key.raw,
|
|
1643
|
+
submitKey: binding.key.raw,
|
|
1644
|
+
column: split?.field ?? binding.key.label,
|
|
1645
|
+
rowKey: split?.row ?? binding.key.raw,
|
|
1646
|
+
binding,
|
|
1647
|
+
added: false
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
return views;
|
|
1651
|
+
}
|
|
1652
|
+
var UNIT_SIZE = "unit_size";
|
|
1653
|
+
var UNIT_SIZE_UOM = "unit_size_uom";
|
|
1654
|
+
var UNIT_PAIR_MESSAGE = "Enter both value and unit";
|
|
1655
|
+
function unitSizePairErrors(cells, edits) {
|
|
1656
|
+
const rows = /* @__PURE__ */ new Map();
|
|
1657
|
+
for (const cell of cells) {
|
|
1658
|
+
if (cell.column !== UNIT_SIZE && cell.column !== UNIT_SIZE_UOM) {
|
|
1659
|
+
continue;
|
|
1660
|
+
}
|
|
1661
|
+
const row = rows.get(cell.rowKey) ?? {};
|
|
1662
|
+
if (cell.column === UNIT_SIZE) {
|
|
1663
|
+
row.size = cell;
|
|
1664
|
+
} else {
|
|
1665
|
+
row.uom = cell;
|
|
1666
|
+
}
|
|
1667
|
+
rows.set(cell.rowKey, row);
|
|
1668
|
+
}
|
|
1669
|
+
const errors = /* @__PURE__ */ new Map();
|
|
1670
|
+
for (const { size, uom } of rows.values()) {
|
|
1671
|
+
if (!size || !uom) {
|
|
1672
|
+
continue;
|
|
1673
|
+
}
|
|
1674
|
+
const filled = (cell) => (edits.get(cell.editKey) ?? toInputString(cell.binding.extracted)).trim() !== "";
|
|
1675
|
+
if (filled(size) !== filled(uom)) {
|
|
1676
|
+
errors.set(size.editKey, UNIT_PAIR_MESSAGE);
|
|
1677
|
+
errors.set(uom.editKey, UNIT_PAIR_MESSAGE);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
return errors;
|
|
1681
|
+
}
|
|
1682
|
+
function pruneEmptyAddedRows(plannedTables, edits) {
|
|
1683
|
+
const out = /* @__PURE__ */ new Map();
|
|
1684
|
+
for (const [pointer, rows] of plannedTables) {
|
|
1685
|
+
out.set(pointer, rows.filter((row) => {
|
|
1686
|
+
if (row.entry.source !== null) {
|
|
1687
|
+
return true;
|
|
1688
|
+
}
|
|
1689
|
+
return row.cells.some((cell) => (edits.get(cell.editKey) ?? "").trim() !== "");
|
|
1690
|
+
}));
|
|
1691
|
+
}
|
|
1692
|
+
return out;
|
|
1320
1693
|
}
|
|
1321
1694
|
|
|
1322
1695
|
// src/verification/form.tsx
|
|
1323
|
-
var
|
|
1696
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
1324
1697
|
|
|
1325
|
-
// src/verification/
|
|
1698
|
+
// src/verification/tip.tsx
|
|
1326
1699
|
var import_react2 = require("react");
|
|
1700
|
+
var import_react_dom = require("react-dom");
|
|
1701
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1702
|
+
var GAP = 8;
|
|
1703
|
+
var MARGIN = 8;
|
|
1704
|
+
function isEmpty(content) {
|
|
1705
|
+
return content == null || content === "" || content === false;
|
|
1706
|
+
}
|
|
1707
|
+
function rootClassesOf(node) {
|
|
1708
|
+
const root = node?.closest(".gemina-verification");
|
|
1709
|
+
return root ? root.className : "gemina-verification";
|
|
1710
|
+
}
|
|
1711
|
+
function mergeRefs(ours, theirs) {
|
|
1712
|
+
return (value) => {
|
|
1713
|
+
ours(value);
|
|
1714
|
+
if (typeof theirs === "function") {
|
|
1715
|
+
theirs(value);
|
|
1716
|
+
} else if (theirs && typeof theirs === "object") {
|
|
1717
|
+
theirs.current = value;
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
function Tip({ content, children }) {
|
|
1722
|
+
const [open, setOpen] = (0, import_react2.useState)(false);
|
|
1723
|
+
const [position, setPosition] = (0, import_react2.useState)(null);
|
|
1724
|
+
const [rootClasses, setRootClasses] = (0, import_react2.useState)("gemina-verification");
|
|
1725
|
+
const triggerRef = (0, import_react2.useRef)(null);
|
|
1726
|
+
const tipRef = (0, import_react2.useRef)(null);
|
|
1727
|
+
const id = (0, import_react2.useId)();
|
|
1728
|
+
const empty = isEmpty(content);
|
|
1729
|
+
const show = (0, import_react2.useCallback)(() => {
|
|
1730
|
+
if (empty) {
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
setRootClasses(rootClassesOf(triggerRef.current));
|
|
1734
|
+
setPosition(null);
|
|
1735
|
+
setOpen(true);
|
|
1736
|
+
}, [empty]);
|
|
1737
|
+
const hide = (0, import_react2.useCallback)(() => setOpen(false), []);
|
|
1738
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
1739
|
+
if (!open) {
|
|
1740
|
+
return;
|
|
1741
|
+
}
|
|
1742
|
+
const trigger2 = triggerRef.current;
|
|
1743
|
+
const tip = tipRef.current;
|
|
1744
|
+
if (!trigger2 || !tip) {
|
|
1745
|
+
return;
|
|
1746
|
+
}
|
|
1747
|
+
const anchor = trigger2.getBoundingClientRect();
|
|
1748
|
+
const bubble = tip.getBoundingClientRect();
|
|
1749
|
+
const viewportWidth = window.innerWidth || 0;
|
|
1750
|
+
const viewportHeight = window.innerHeight || 0;
|
|
1751
|
+
const fitsAbove = anchor.top - bubble.height - GAP >= MARGIN;
|
|
1752
|
+
const fitsBelow = anchor.bottom + bubble.height + GAP <= viewportHeight - MARGIN;
|
|
1753
|
+
const top = fitsAbove || !fitsBelow ? anchor.top - bubble.height - GAP : anchor.bottom + GAP;
|
|
1754
|
+
const centred = anchor.left + anchor.width / 2 - bubble.width / 2;
|
|
1755
|
+
const rightLimit = Math.max(MARGIN, viewportWidth - bubble.width - MARGIN);
|
|
1756
|
+
const left = Math.min(Math.max(centred, MARGIN), rightLimit);
|
|
1757
|
+
setPosition({ top: Math.max(top, MARGIN), left });
|
|
1758
|
+
}, [open, content]);
|
|
1759
|
+
(0, import_react2.useEffect)(() => {
|
|
1760
|
+
if (!open) {
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
const onKeyDown = (event) => {
|
|
1764
|
+
if (event.key === "Escape") {
|
|
1765
|
+
hide();
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
const onScrollOrResize = () => hide();
|
|
1769
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1770
|
+
document.addEventListener("scroll", onScrollOrResize, true);
|
|
1771
|
+
window.addEventListener("resize", onScrollOrResize);
|
|
1772
|
+
return () => {
|
|
1773
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
1774
|
+
document.removeEventListener("scroll", onScrollOrResize, true);
|
|
1775
|
+
window.removeEventListener("resize", onScrollOrResize);
|
|
1776
|
+
};
|
|
1777
|
+
}, [open, hide]);
|
|
1778
|
+
if (!(0, import_react2.isValidElement)(children)) {
|
|
1779
|
+
return children;
|
|
1780
|
+
}
|
|
1781
|
+
const childProps = children.props;
|
|
1782
|
+
const call = (name, event) => {
|
|
1783
|
+
const handler = childProps[name];
|
|
1784
|
+
if (typeof handler === "function") {
|
|
1785
|
+
handler(event);
|
|
1786
|
+
}
|
|
1787
|
+
};
|
|
1788
|
+
const trigger = (0, import_react2.cloneElement)(children, {
|
|
1789
|
+
ref: mergeRefs((node) => {
|
|
1790
|
+
triggerRef.current = node;
|
|
1791
|
+
}, children.ref),
|
|
1792
|
+
// The tip is a DESCRIPTION. `aria-label` stays untouched — it already
|
|
1793
|
+
// carries the reason into the accessible NAME, and duplicating it here
|
|
1794
|
+
// would have a screen reader announce it twice.
|
|
1795
|
+
"aria-describedby": open && !empty ? id : void 0,
|
|
1796
|
+
onMouseEnter: (event) => {
|
|
1797
|
+
call("onMouseEnter", event);
|
|
1798
|
+
show();
|
|
1799
|
+
},
|
|
1800
|
+
onMouseLeave: (event) => {
|
|
1801
|
+
call("onMouseLeave", event);
|
|
1802
|
+
hide();
|
|
1803
|
+
},
|
|
1804
|
+
onFocus: (event) => {
|
|
1805
|
+
call("onFocus", event);
|
|
1806
|
+
show();
|
|
1807
|
+
},
|
|
1808
|
+
onBlur: (event) => {
|
|
1809
|
+
call("onBlur", event);
|
|
1810
|
+
hide();
|
|
1811
|
+
}
|
|
1812
|
+
});
|
|
1813
|
+
const canPortal = typeof document !== "undefined" && document.body;
|
|
1814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1815
|
+
trigger,
|
|
1816
|
+
open && !empty && canPortal ? (0, import_react_dom.createPortal)(
|
|
1817
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: rootClasses, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1818
|
+
"div",
|
|
1819
|
+
{
|
|
1820
|
+
ref: tipRef,
|
|
1821
|
+
id,
|
|
1822
|
+
role: "tooltip",
|
|
1823
|
+
className: "gemina-verification__tip",
|
|
1824
|
+
style: {
|
|
1825
|
+
top: position ? `${position.top}px` : "0px",
|
|
1826
|
+
left: position ? `${position.left}px` : "0px",
|
|
1827
|
+
visibility: position ? "visible" : "hidden"
|
|
1828
|
+
},
|
|
1829
|
+
children: content
|
|
1830
|
+
}
|
|
1831
|
+
) }),
|
|
1832
|
+
document.body
|
|
1833
|
+
) : null
|
|
1834
|
+
] });
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
// src/verification/viewer.tsx
|
|
1838
|
+
var import_react3 = require("react");
|
|
1327
1839
|
|
|
1328
1840
|
// src/verification/viewer-math.ts
|
|
1329
1841
|
function fitScaleFor(natural, container, rotationDeg) {
|
|
@@ -1405,9 +1917,9 @@ function flashZoomTarget(rects, natural, container, rotationDeg, fitScale) {
|
|
|
1405
1917
|
var easeOutCubic = (t) => 1 - Math.pow(1 - t, 3);
|
|
1406
1918
|
|
|
1407
1919
|
// src/verification/viewer.tsx
|
|
1408
|
-
var
|
|
1920
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1409
1921
|
function IconBase({ children }) {
|
|
1410
|
-
return /* @__PURE__ */ (0,
|
|
1922
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1411
1923
|
"svg",
|
|
1412
1924
|
{
|
|
1413
1925
|
width: "16",
|
|
@@ -1425,56 +1937,56 @@ function IconBase({ children }) {
|
|
|
1425
1937
|
);
|
|
1426
1938
|
}
|
|
1427
1939
|
function GlassBody() {
|
|
1428
|
-
return /* @__PURE__ */ (0,
|
|
1429
|
-
/* @__PURE__ */ (0,
|
|
1430
|
-
/* @__PURE__ */ (0,
|
|
1940
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1941
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "6.75", cy: "6.75", r: "4.25" }),
|
|
1942
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "9.9", y1: "9.9", x2: "13.5", y2: "13.5" })
|
|
1431
1943
|
] });
|
|
1432
1944
|
}
|
|
1433
1945
|
function IconZoomIn() {
|
|
1434
|
-
return /* @__PURE__ */ (0,
|
|
1435
|
-
/* @__PURE__ */ (0,
|
|
1436
|
-
/* @__PURE__ */ (0,
|
|
1437
|
-
/* @__PURE__ */ (0,
|
|
1946
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(IconBase, { children: [
|
|
1947
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GlassBody, {}),
|
|
1948
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "4.9", y1: "6.75", x2: "8.6", y2: "6.75" }),
|
|
1949
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "6.75", y1: "4.9", x2: "6.75", y2: "8.6" })
|
|
1438
1950
|
] });
|
|
1439
1951
|
}
|
|
1440
1952
|
function IconZoomOut() {
|
|
1441
|
-
return /* @__PURE__ */ (0,
|
|
1442
|
-
/* @__PURE__ */ (0,
|
|
1443
|
-
/* @__PURE__ */ (0,
|
|
1953
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(IconBase, { children: [
|
|
1954
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GlassBody, {}),
|
|
1955
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "4.9", y1: "6.75", x2: "8.6", y2: "6.75" })
|
|
1444
1956
|
] });
|
|
1445
1957
|
}
|
|
1446
1958
|
function IconMagnifier() {
|
|
1447
|
-
return /* @__PURE__ */ (0,
|
|
1959
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconBase, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GlassBody, {}) });
|
|
1448
1960
|
}
|
|
1449
1961
|
function IconActualSize() {
|
|
1450
|
-
return /* @__PURE__ */ (0,
|
|
1451
|
-
/* @__PURE__ */ (0,
|
|
1452
|
-
/* @__PURE__ */ (0,
|
|
1453
|
-
/* @__PURE__ */ (0,
|
|
1454
|
-
/* @__PURE__ */ (0,
|
|
1962
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(IconBase, { children: [
|
|
1963
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "2.8 6.2 4 5 4 11" }),
|
|
1964
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "10.8 6.2 12 5 12 11" }),
|
|
1965
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "8", cy: "6.75", r: "0.8", fill: "currentColor", stroke: "none" }),
|
|
1966
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "8", cy: "9.25", r: "0.8", fill: "currentColor", stroke: "none" })
|
|
1455
1967
|
] });
|
|
1456
1968
|
}
|
|
1457
1969
|
function IconFit() {
|
|
1458
|
-
return /* @__PURE__ */ (0,
|
|
1459
|
-
/* @__PURE__ */ (0,
|
|
1460
|
-
/* @__PURE__ */ (0,
|
|
1461
|
-
/* @__PURE__ */ (0,
|
|
1462
|
-
/* @__PURE__ */ (0,
|
|
1970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(IconBase, { children: [
|
|
1971
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "13.8", y1: "2.2", x2: "9.6", y2: "6.4" }),
|
|
1972
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "9.6 3.9 9.6 6.4 12.1 6.4" }),
|
|
1973
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "2.2", y1: "13.8", x2: "6.4", y2: "9.6" }),
|
|
1974
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "6.4 12.1 6.4 9.6 3.9 9.6" })
|
|
1463
1975
|
] });
|
|
1464
1976
|
}
|
|
1465
1977
|
function IconRotate() {
|
|
1466
|
-
return /* @__PURE__ */ (0,
|
|
1467
|
-
/* @__PURE__ */ (0,
|
|
1468
|
-
/* @__PURE__ */ (0,
|
|
1978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(IconBase, { children: [
|
|
1979
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M11.83 4.79A5 5 0 1 1 8 3" }),
|
|
1980
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "6 1.7 8 3 6 4.3" })
|
|
1469
1981
|
] });
|
|
1470
1982
|
}
|
|
1471
1983
|
function IconOverlay() {
|
|
1472
|
-
return /* @__PURE__ */ (0,
|
|
1984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconBase, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { x: "2.75", y: "2.75", width: "10.5", height: "10.5", rx: "1.5", strokeDasharray: "3 2.2" }) });
|
|
1473
1985
|
}
|
|
1474
1986
|
function IconEye() {
|
|
1475
|
-
return /* @__PURE__ */ (0,
|
|
1476
|
-
/* @__PURE__ */ (0,
|
|
1477
|
-
/* @__PURE__ */ (0,
|
|
1987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(IconBase, { children: [
|
|
1988
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.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" }),
|
|
1989
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "8", cy: "8", r: "2.1" })
|
|
1478
1990
|
] });
|
|
1479
1991
|
}
|
|
1480
1992
|
function ToolbarButton({
|
|
@@ -1486,12 +1998,11 @@ function ToolbarButton({
|
|
|
1486
1998
|
children
|
|
1487
1999
|
}) {
|
|
1488
2000
|
const active = (pressed ?? checked) === true;
|
|
1489
|
-
return /* @__PURE__ */ (0,
|
|
2001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Tip, { content: label, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1490
2002
|
"button",
|
|
1491
2003
|
{
|
|
1492
2004
|
type: "button",
|
|
1493
2005
|
className: active ? "gemina-verification__toolbar-btn gemina-verification__toolbar-btn--active" : "gemina-verification__toolbar-btn",
|
|
1494
|
-
title: label,
|
|
1495
2006
|
"aria-label": label,
|
|
1496
2007
|
role: checked === void 0 ? void 0 : "switch",
|
|
1497
2008
|
"aria-checked": checked,
|
|
@@ -1500,7 +2011,7 @@ function ToolbarButton({
|
|
|
1500
2011
|
onClick,
|
|
1501
2012
|
children
|
|
1502
2013
|
}
|
|
1503
|
-
);
|
|
2014
|
+
) });
|
|
1504
2015
|
}
|
|
1505
2016
|
var ZOOM_STEP = 1.2;
|
|
1506
2017
|
var IDENTITY = { scale: 1, tx: 0, ty: 0 };
|
|
@@ -1510,6 +2021,7 @@ var REDUCED_MOTION_FLASH_MS = 800;
|
|
|
1510
2021
|
var MIN_SIZE_RATIO = 8e-3;
|
|
1511
2022
|
var MAG_RADIUS = 150;
|
|
1512
2023
|
var MAG_ZOOM = 2.5;
|
|
2024
|
+
var MAG_BORDER = 2;
|
|
1513
2025
|
function rectGeometry(rect, natural) {
|
|
1514
2026
|
const xs = rect.points.map((point) => point[0]);
|
|
1515
2027
|
const ys = rect.points.map((point) => point[1]);
|
|
@@ -1527,29 +2039,30 @@ function rectGeometry(rect, natural) {
|
|
|
1527
2039
|
}
|
|
1528
2040
|
function VerificationViewer(props) {
|
|
1529
2041
|
const { src, alt, relativeRects, flashRects, onFlashComplete, onImageExpired } = props;
|
|
1530
|
-
const canvasRef = (0,
|
|
1531
|
-
const imgRef = (0,
|
|
1532
|
-
const [natural, setNatural] = (0,
|
|
1533
|
-
const [container, setContainer] = (0,
|
|
1534
|
-
const [transform, setTransform] = (0,
|
|
1535
|
-
const [rotation, setRotation] = (0,
|
|
1536
|
-
const [showRects, setShowRects] = (0,
|
|
1537
|
-
const [magnifierOn, setMagnifierOn] = (0,
|
|
1538
|
-
const [showMag, setShowMag] = (0,
|
|
1539
|
-
const [mousePos, setMousePos] = (0,
|
|
1540
|
-
const
|
|
1541
|
-
const
|
|
1542
|
-
const
|
|
1543
|
-
const [
|
|
1544
|
-
const
|
|
1545
|
-
const
|
|
1546
|
-
const
|
|
1547
|
-
const
|
|
2042
|
+
const canvasRef = (0, import_react3.useRef)(null);
|
|
2043
|
+
const imgRef = (0, import_react3.useRef)(null);
|
|
2044
|
+
const [natural, setNatural] = (0, import_react3.useState)(null);
|
|
2045
|
+
const [container, setContainer] = (0, import_react3.useState)({ w: 0, h: 0 });
|
|
2046
|
+
const [transform, setTransform] = (0, import_react3.useState)(IDENTITY);
|
|
2047
|
+
const [rotation, setRotation] = (0, import_react3.useState)(0);
|
|
2048
|
+
const [showRects, setShowRects] = (0, import_react3.useState)(false);
|
|
2049
|
+
const [magnifierOn, setMagnifierOn] = (0, import_react3.useState)(false);
|
|
2050
|
+
const [showMag, setShowMag] = (0, import_react3.useState)(false);
|
|
2051
|
+
const [mousePos, setMousePos] = (0, import_react3.useState)({ x: 0, y: 0 });
|
|
2052
|
+
const lastMouseClientRef = (0, import_react3.useRef)(null);
|
|
2053
|
+
const [isPanning, setIsPanning] = (0, import_react3.useState)(false);
|
|
2054
|
+
const panStart = (0, import_react3.useRef)(null);
|
|
2055
|
+
const [flashOpacity, setFlashOpacity] = (0, import_react3.useState)(0);
|
|
2056
|
+
const [activeFlashRects, setActiveFlashRects] = (0, import_react3.useState)(null);
|
|
2057
|
+
const travelRafRef = (0, import_react3.useRef)(null);
|
|
2058
|
+
const fadeRafRef = (0, import_react3.useRef)(null);
|
|
2059
|
+
const reducedFlashTimeoutRef = (0, import_react3.useRef)(null);
|
|
2060
|
+
const transformRef = (0, import_react3.useRef)(transform);
|
|
1548
2061
|
transformRef.current = transform;
|
|
1549
|
-
const onFlashCompleteRef = (0,
|
|
2062
|
+
const onFlashCompleteRef = (0, import_react3.useRef)(onFlashComplete);
|
|
1550
2063
|
onFlashCompleteRef.current = onFlashComplete;
|
|
1551
|
-
const hasLoadedRef = (0,
|
|
1552
|
-
(0,
|
|
2064
|
+
const hasLoadedRef = (0, import_react3.useRef)(false);
|
|
2065
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
1553
2066
|
const el = canvasRef.current;
|
|
1554
2067
|
if (!el) return;
|
|
1555
2068
|
if (typeof ResizeObserver === "undefined") {
|
|
@@ -1564,7 +2077,7 @@ function VerificationViewer(props) {
|
|
|
1564
2077
|
ro.observe(el);
|
|
1565
2078
|
return () => ro.disconnect();
|
|
1566
2079
|
}, []);
|
|
1567
|
-
const handleImgLoad = (0,
|
|
2080
|
+
const handleImgLoad = (0, import_react3.useCallback)(() => {
|
|
1568
2081
|
const img = imgRef.current;
|
|
1569
2082
|
if (!img) return;
|
|
1570
2083
|
hasLoadedRef.current = true;
|
|
@@ -1572,19 +2085,19 @@ function VerificationViewer(props) {
|
|
|
1572
2085
|
const h = img.naturalHeight;
|
|
1573
2086
|
setNatural((prev) => prev && prev.w === w && prev.h === h ? prev : { w, h });
|
|
1574
2087
|
}, []);
|
|
1575
|
-
(0,
|
|
2088
|
+
(0, import_react3.useEffect)(() => {
|
|
1576
2089
|
hasLoadedRef.current = false;
|
|
1577
2090
|
}, [src]);
|
|
1578
|
-
const handleImgError = (0,
|
|
2091
|
+
const handleImgError = (0, import_react3.useCallback)(() => {
|
|
1579
2092
|
if (!hasLoadedRef.current) return;
|
|
1580
2093
|
hasLoadedRef.current = false;
|
|
1581
2094
|
onImageExpired?.();
|
|
1582
2095
|
}, [onImageExpired]);
|
|
1583
|
-
const currentFitScale = (0,
|
|
2096
|
+
const currentFitScale = (0, import_react3.useCallback)(() => {
|
|
1584
2097
|
if (!natural || !container.w || !container.h) return 1;
|
|
1585
2098
|
return fitScaleFor(natural, container, rotation);
|
|
1586
2099
|
}, [natural, container, rotation]);
|
|
1587
|
-
(0,
|
|
2100
|
+
(0, import_react3.useEffect)(() => {
|
|
1588
2101
|
if (!natural || !container.w || !container.h) return;
|
|
1589
2102
|
const fit = fitScaleFor(natural, container, rotation);
|
|
1590
2103
|
const { tx, ty } = centeredTranslation(natural, container, fit, rotation);
|
|
@@ -1592,13 +2105,13 @@ function VerificationViewer(props) {
|
|
|
1592
2105
|
(prev) => Math.abs(prev.scale - fit) < 1e-4 && prev.tx === tx && prev.ty === ty ? prev : { scale: fit, tx, ty }
|
|
1593
2106
|
);
|
|
1594
2107
|
}, [natural, container, rotation]);
|
|
1595
|
-
const cancelFlashTravel = (0,
|
|
2108
|
+
const cancelFlashTravel = (0, import_react3.useCallback)(() => {
|
|
1596
2109
|
if (travelRafRef.current !== null) {
|
|
1597
2110
|
cancelAnimationFrame(travelRafRef.current);
|
|
1598
2111
|
travelRafRef.current = null;
|
|
1599
2112
|
}
|
|
1600
2113
|
}, []);
|
|
1601
|
-
const zoomBy = (0,
|
|
2114
|
+
const zoomBy = (0, import_react3.useCallback)(
|
|
1602
2115
|
(factor) => {
|
|
1603
2116
|
const node = canvasRef.current;
|
|
1604
2117
|
if (!node || !natural) return;
|
|
@@ -1611,9 +2124,9 @@ function VerificationViewer(props) {
|
|
|
1611
2124
|
},
|
|
1612
2125
|
[natural, rotation, currentFitScale, cancelFlashTravel]
|
|
1613
2126
|
);
|
|
1614
|
-
const handleZoomIn = (0,
|
|
1615
|
-
const handleZoomOut = (0,
|
|
1616
|
-
const zoomAtClientPoint = (0,
|
|
2127
|
+
const handleZoomIn = (0, import_react3.useCallback)(() => zoomBy(ZOOM_STEP), [zoomBy]);
|
|
2128
|
+
const handleZoomOut = (0, import_react3.useCallback)(() => zoomBy(1 / ZOOM_STEP), [zoomBy]);
|
|
2129
|
+
const zoomAtClientPoint = (0, import_react3.useCallback)(
|
|
1617
2130
|
(factor, clientX, clientY) => {
|
|
1618
2131
|
const node = canvasRef.current;
|
|
1619
2132
|
if (!node || !natural) return;
|
|
@@ -1625,7 +2138,7 @@ function VerificationViewer(props) {
|
|
|
1625
2138
|
},
|
|
1626
2139
|
[natural, rotation, currentFitScale]
|
|
1627
2140
|
);
|
|
1628
|
-
const handleWheel = (0,
|
|
2141
|
+
const handleWheel = (0, import_react3.useCallback)(
|
|
1629
2142
|
(event) => {
|
|
1630
2143
|
event.preventDefault();
|
|
1631
2144
|
event.stopPropagation();
|
|
@@ -1635,7 +2148,7 @@ function VerificationViewer(props) {
|
|
|
1635
2148
|
},
|
|
1636
2149
|
[zoomAtClientPoint, cancelFlashTravel]
|
|
1637
2150
|
);
|
|
1638
|
-
(0,
|
|
2151
|
+
(0, import_react3.useEffect)(() => {
|
|
1639
2152
|
const node = canvasRef.current;
|
|
1640
2153
|
if (!node) return;
|
|
1641
2154
|
const listener = (event) => handleWheel(event);
|
|
@@ -1643,7 +2156,7 @@ function VerificationViewer(props) {
|
|
|
1643
2156
|
return () => node.removeEventListener("wheel", listener);
|
|
1644
2157
|
}, [handleWheel]);
|
|
1645
2158
|
const atFitScale = transform.scale <= currentFitScale() + 1e-3;
|
|
1646
|
-
const handleMouseDown = (0,
|
|
2159
|
+
const handleMouseDown = (0, import_react3.useCallback)(
|
|
1647
2160
|
(e) => {
|
|
1648
2161
|
cancelFlashTravel();
|
|
1649
2162
|
if (e.button !== 0) return;
|
|
@@ -1654,7 +2167,7 @@ function VerificationViewer(props) {
|
|
|
1654
2167
|
},
|
|
1655
2168
|
[atFitScale, transform.tx, transform.ty, cancelFlashTravel]
|
|
1656
2169
|
);
|
|
1657
|
-
(0,
|
|
2170
|
+
(0, import_react3.useEffect)(() => {
|
|
1658
2171
|
if (!isPanning) return;
|
|
1659
2172
|
const onMove = (e) => {
|
|
1660
2173
|
const start = panStart.current;
|
|
@@ -1674,8 +2187,8 @@ function VerificationViewer(props) {
|
|
|
1674
2187
|
document.removeEventListener("mouseup", onUp);
|
|
1675
2188
|
};
|
|
1676
2189
|
}, [isPanning]);
|
|
1677
|
-
const touchState = (0,
|
|
1678
|
-
const handleTouchStart = (0,
|
|
2190
|
+
const touchState = (0, import_react3.useRef)(null);
|
|
2191
|
+
const handleTouchStart = (0, import_react3.useCallback)(
|
|
1679
2192
|
(e) => {
|
|
1680
2193
|
cancelFlashTravel();
|
|
1681
2194
|
const a = e.touches[0];
|
|
@@ -1693,7 +2206,7 @@ function VerificationViewer(props) {
|
|
|
1693
2206
|
},
|
|
1694
2207
|
[atFitScale, transform.tx, transform.ty, cancelFlashTravel]
|
|
1695
2208
|
);
|
|
1696
|
-
const handleTouchMove = (0,
|
|
2209
|
+
const handleTouchMove = (0, import_react3.useCallback)(
|
|
1697
2210
|
(e) => {
|
|
1698
2211
|
const state = touchState.current;
|
|
1699
2212
|
if (!state) return;
|
|
@@ -1718,19 +2231,42 @@ function VerificationViewer(props) {
|
|
|
1718
2231
|
},
|
|
1719
2232
|
[zoomAtClientPoint]
|
|
1720
2233
|
);
|
|
1721
|
-
const handleTouchEnd = (0,
|
|
2234
|
+
const handleTouchEnd = (0, import_react3.useCallback)((e) => {
|
|
1722
2235
|
if (e.touches.length === 0) touchState.current = null;
|
|
1723
2236
|
}, []);
|
|
1724
|
-
const
|
|
2237
|
+
const syncMagnifierToClientPoint = (0, import_react3.useCallback)((clientX, clientY, assumeInside = false) => {
|
|
1725
2238
|
const rect = canvasRef.current?.getBoundingClientRect();
|
|
1726
2239
|
if (!rect) return;
|
|
1727
|
-
|
|
1728
|
-
|
|
2240
|
+
const x = clientX - rect.left;
|
|
2241
|
+
const y = clientY - rect.top;
|
|
2242
|
+
const inside = assumeInside || x >= 0 && y >= 0 && x <= rect.width && y <= rect.height;
|
|
2243
|
+
setShowMag(inside);
|
|
2244
|
+
if (inside) {
|
|
2245
|
+
setMousePos({ x, y });
|
|
2246
|
+
}
|
|
1729
2247
|
}, []);
|
|
1730
|
-
const
|
|
2248
|
+
const handleCanvasMouseMove = (0, import_react3.useCallback)((e) => {
|
|
2249
|
+
lastMouseClientRef.current = { x: e.clientX, y: e.clientY };
|
|
2250
|
+
syncMagnifierToClientPoint(e.clientX, e.clientY, true);
|
|
2251
|
+
}, [syncMagnifierToClientPoint]);
|
|
2252
|
+
const handleCanvasMouseLeave = (0, import_react3.useCallback)(() => {
|
|
2253
|
+
lastMouseClientRef.current = null;
|
|
1731
2254
|
setShowMag(false);
|
|
1732
2255
|
}, []);
|
|
1733
|
-
|
|
2256
|
+
(0, import_react3.useEffect)(() => {
|
|
2257
|
+
if (!magnifierOn || !showMag) return;
|
|
2258
|
+
const sync = () => {
|
|
2259
|
+
const point = lastMouseClientRef.current;
|
|
2260
|
+
if (point) syncMagnifierToClientPoint(point.x, point.y);
|
|
2261
|
+
};
|
|
2262
|
+
document.addEventListener("scroll", sync, true);
|
|
2263
|
+
window.addEventListener("resize", sync);
|
|
2264
|
+
return () => {
|
|
2265
|
+
document.removeEventListener("scroll", sync, true);
|
|
2266
|
+
window.removeEventListener("resize", sync);
|
|
2267
|
+
};
|
|
2268
|
+
}, [magnifierOn, showMag, syncMagnifierToClientPoint]);
|
|
2269
|
+
const handleDoubleClick = (0, import_react3.useCallback)(
|
|
1734
2270
|
(e) => {
|
|
1735
2271
|
cancelFlashTravel();
|
|
1736
2272
|
if (!natural) return;
|
|
@@ -1745,26 +2281,26 @@ function VerificationViewer(props) {
|
|
|
1745
2281
|
},
|
|
1746
2282
|
[natural, container, rotation, transform.scale, currentFitScale, zoomAtClientPoint, cancelFlashTravel]
|
|
1747
2283
|
);
|
|
1748
|
-
const handleFit = (0,
|
|
2284
|
+
const handleFit = (0, import_react3.useCallback)(() => {
|
|
1749
2285
|
if (!natural) return;
|
|
1750
2286
|
cancelFlashTravel();
|
|
1751
2287
|
const fit = currentFitScale();
|
|
1752
2288
|
setTransform({ scale: fit, ...centeredTranslation(natural, container, fit, rotation) });
|
|
1753
2289
|
}, [natural, container, rotation, currentFitScale, cancelFlashTravel]);
|
|
1754
|
-
const handleActualSize = (0,
|
|
2290
|
+
const handleActualSize = (0, import_react3.useCallback)(() => {
|
|
1755
2291
|
if (!natural) return;
|
|
1756
2292
|
cancelFlashTravel();
|
|
1757
2293
|
const target = clampScale(1, currentFitScale());
|
|
1758
2294
|
setTransform({ scale: target, ...centeredTranslation(natural, container, target, rotation) });
|
|
1759
2295
|
}, [natural, container, rotation, currentFitScale, cancelFlashTravel]);
|
|
1760
|
-
const handleRotate = (0,
|
|
2296
|
+
const handleRotate = (0, import_react3.useCallback)(() => {
|
|
1761
2297
|
setRotation((r) => (r + 90) % 360);
|
|
1762
2298
|
}, []);
|
|
1763
2299
|
const hasRects = relativeRects !== void 0 && relativeRects.length > 0;
|
|
1764
|
-
(0,
|
|
2300
|
+
(0, import_react3.useEffect)(() => {
|
|
1765
2301
|
if (!hasRects) setShowRects(false);
|
|
1766
2302
|
}, [hasRects]);
|
|
1767
|
-
(0,
|
|
2303
|
+
(0, import_react3.useEffect)(() => {
|
|
1768
2304
|
if (!flashRects || flashRects.length === 0 || !natural || !container.w || !container.h) {
|
|
1769
2305
|
setActiveFlashRects((prev) => prev === null ? prev : null);
|
|
1770
2306
|
setFlashOpacity(0);
|
|
@@ -1835,71 +2371,72 @@ function VerificationViewer(props) {
|
|
|
1835
2371
|
const dy = mousePos.y - transform.ty;
|
|
1836
2372
|
const cxRaw = (cosA * dx + sinA * dy) / transform.scale;
|
|
1837
2373
|
const cyRaw = (-sinA * dx + cosA * dy) / transform.scale;
|
|
1838
|
-
const
|
|
1839
|
-
const clampedY = Math.max(0, Math.min(cyRaw, natural.h));
|
|
2374
|
+
const onImage = cxRaw >= 0 && cyRaw >= 0 && cxRaw <= natural.w && cyRaw <= natural.h;
|
|
1840
2375
|
const zoomScale = transform.scale * MAG_ZOOM;
|
|
1841
|
-
const px =
|
|
1842
|
-
const py =
|
|
2376
|
+
const px = cxRaw * zoomScale;
|
|
2377
|
+
const py = cyRaw * zoomScale;
|
|
1843
2378
|
const rotatedX = px * cosA - py * sinA;
|
|
1844
2379
|
const rotatedY = px * sinA + py * cosA;
|
|
1845
|
-
const translateX = MAG_RADIUS - rotatedX;
|
|
1846
|
-
const translateY = MAG_RADIUS - rotatedY;
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
2380
|
+
const translateX = MAG_RADIUS - MAG_BORDER - rotatedX;
|
|
2381
|
+
const translateY = MAG_RADIUS - MAG_BORDER - rotatedY;
|
|
2382
|
+
if (onImage) {
|
|
2383
|
+
magnifier = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2384
|
+
"div",
|
|
2385
|
+
{
|
|
2386
|
+
className: "gemina-verification__magnifier",
|
|
2387
|
+
style: {
|
|
2388
|
+
width: MAG_RADIUS * 2,
|
|
2389
|
+
height: MAG_RADIUS * 2,
|
|
2390
|
+
top: mousePos.y - MAG_RADIUS,
|
|
2391
|
+
left: mousePos.x - MAG_RADIUS
|
|
2392
|
+
},
|
|
2393
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2394
|
+
"img",
|
|
2395
|
+
{
|
|
2396
|
+
src,
|
|
2397
|
+
alt: "",
|
|
2398
|
+
draggable: false,
|
|
2399
|
+
style: {
|
|
2400
|
+
position: "absolute",
|
|
2401
|
+
width: natural.w,
|
|
2402
|
+
height: natural.h,
|
|
2403
|
+
transformOrigin: "0 0",
|
|
2404
|
+
transform: `translate(${translateX}px, ${translateY}px) rotate(${rotation}deg) scale(${zoomScale})`
|
|
2405
|
+
}
|
|
1869
2406
|
}
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
2407
|
+
)
|
|
2408
|
+
}
|
|
2409
|
+
);
|
|
2410
|
+
}
|
|
1874
2411
|
}
|
|
1875
|
-
return /* @__PURE__ */ (0,
|
|
1876
|
-
/* @__PURE__ */ (0,
|
|
1877
|
-
/* @__PURE__ */ (0,
|
|
1878
|
-
/* @__PURE__ */ (0,
|
|
1879
|
-
/* @__PURE__ */ (0,
|
|
1880
|
-
/* @__PURE__ */ (0,
|
|
1881
|
-
/* @__PURE__ */ (0,
|
|
1882
|
-
/* @__PURE__ */ (0,
|
|
2412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__viewer", children: [
|
|
2413
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__toolbar", children: [
|
|
2414
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ToolbarButton, { label: "Zoom out", onClick: handleZoomOut, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconZoomOut, {}) }),
|
|
2415
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ToolbarButton, { label: "Zoom in", onClick: handleZoomIn, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconZoomIn, {}) }),
|
|
2416
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ToolbarButton, { label: "Actual size (100%)", onClick: handleActualSize, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconActualSize, {}) }),
|
|
2417
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ToolbarButton, { label: "Fit to screen", onClick: handleFit, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconFit, {}) }),
|
|
2418
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ToolbarButton, { label: "Rotate 90 degrees", onClick: handleRotate, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconRotate, {}) }),
|
|
2419
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1883
2420
|
ToolbarButton,
|
|
1884
2421
|
{
|
|
1885
2422
|
label: "Toggle detection overlays",
|
|
1886
2423
|
pressed: showRects,
|
|
1887
2424
|
disabled: !hasRects,
|
|
1888
2425
|
onClick: () => setShowRects((prev) => !prev),
|
|
1889
|
-
children: /* @__PURE__ */ (0,
|
|
2426
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconOverlay, {})
|
|
1890
2427
|
}
|
|
1891
2428
|
),
|
|
1892
|
-
/* @__PURE__ */ (0,
|
|
2429
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1893
2430
|
ToolbarButton,
|
|
1894
2431
|
{
|
|
1895
2432
|
label: "Magnifier",
|
|
1896
2433
|
checked: magnifierOn,
|
|
1897
2434
|
onClick: () => setMagnifierOn((prev) => !prev),
|
|
1898
|
-
children: /* @__PURE__ */ (0,
|
|
2435
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconMagnifier, {})
|
|
1899
2436
|
}
|
|
1900
2437
|
)
|
|
1901
2438
|
] }),
|
|
1902
|
-
/* @__PURE__ */ (0,
|
|
2439
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1903
2440
|
"div",
|
|
1904
2441
|
{
|
|
1905
2442
|
ref: canvasRef,
|
|
@@ -1916,7 +2453,7 @@ function VerificationViewer(props) {
|
|
|
1916
2453
|
onTouchEnd: handleTouchEnd,
|
|
1917
2454
|
onTouchCancel: handleTouchEnd,
|
|
1918
2455
|
children: [
|
|
1919
|
-
/* @__PURE__ */ (0,
|
|
2456
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1920
2457
|
"div",
|
|
1921
2458
|
{
|
|
1922
2459
|
style: {
|
|
@@ -1928,7 +2465,7 @@ function VerificationViewer(props) {
|
|
|
1928
2465
|
willChange: "transform,left,top"
|
|
1929
2466
|
},
|
|
1930
2467
|
children: [
|
|
1931
|
-
/* @__PURE__ */ (0,
|
|
2468
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1932
2469
|
"img",
|
|
1933
2470
|
{
|
|
1934
2471
|
ref: imgRef,
|
|
@@ -1942,13 +2479,13 @@ function VerificationViewer(props) {
|
|
|
1942
2479
|
showRects && natural && relativeRects?.map((rect, idx) => {
|
|
1943
2480
|
const geometry = rectGeometry(rect, natural);
|
|
1944
2481
|
if (!geometry) return null;
|
|
1945
|
-
return /* @__PURE__ */ (0,
|
|
2482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1946
2483
|
"div",
|
|
1947
2484
|
{
|
|
1948
2485
|
className: "gemina-verification__rect",
|
|
1949
2486
|
style: geometry,
|
|
1950
2487
|
"aria-hidden": "true",
|
|
1951
|
-
children: /* @__PURE__ */ (0,
|
|
2488
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "gemina-verification__rect-badge", children: [
|
|
1952
2489
|
"#",
|
|
1953
2490
|
idx + 1
|
|
1954
2491
|
] })
|
|
@@ -1959,7 +2496,7 @@ function VerificationViewer(props) {
|
|
|
1959
2496
|
activeFlashRects && natural && activeFlashRects.map((rect, idx) => {
|
|
1960
2497
|
const geometry = rectGeometry(rect, natural);
|
|
1961
2498
|
if (!geometry) return null;
|
|
1962
|
-
return /* @__PURE__ */ (0,
|
|
2499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1963
2500
|
"div",
|
|
1964
2501
|
{
|
|
1965
2502
|
className: "gemina-verification__flash-rect",
|
|
@@ -1980,7 +2517,7 @@ function VerificationViewer(props) {
|
|
|
1980
2517
|
}
|
|
1981
2518
|
|
|
1982
2519
|
// src/verification/form.tsx
|
|
1983
|
-
var
|
|
2520
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1984
2521
|
function ConfidenceDot(props) {
|
|
1985
2522
|
const { confidence } = props;
|
|
1986
2523
|
if (!confidence?.level) {
|
|
@@ -2006,93 +2543,156 @@ function ConfidenceDot(props) {
|
|
|
2006
2543
|
label = `${confidence.level} confidence`;
|
|
2007
2544
|
}
|
|
2008
2545
|
const reasons = confidence.reasons.map(formatLabel);
|
|
2009
|
-
const title = [label, ...reasons].join("\n");
|
|
2010
2546
|
const ariaLabel = reasons.length > 0 ? `${label}: ${reasons.join(", ")}` : label;
|
|
2011
|
-
|
|
2547
|
+
const tip = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
2548
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { className: "gemina-verification__tip-title", children: label }),
|
|
2549
|
+
reasons.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "gemina-verification__tip-list", children: reasons.map((reason) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: reason }, reason)) }) : null
|
|
2550
|
+
] });
|
|
2551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tip, { content: tip, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2012
2552
|
"span",
|
|
2013
2553
|
{
|
|
2014
2554
|
className: `gemina-verification__dot gemina-verification__dot--${variant}`,
|
|
2015
2555
|
role: "img",
|
|
2016
|
-
"aria-label": ariaLabel
|
|
2017
|
-
title
|
|
2556
|
+
"aria-label": ariaLabel
|
|
2018
2557
|
}
|
|
2019
|
-
);
|
|
2558
|
+
) });
|
|
2020
2559
|
}
|
|
2021
2560
|
function EyeButton(props) {
|
|
2022
2561
|
const { coordinates, onFlash } = props;
|
|
2023
2562
|
if (!coordinates) {
|
|
2024
2563
|
return null;
|
|
2025
2564
|
}
|
|
2026
|
-
return /* @__PURE__ */ (0,
|
|
2565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tip, { content: "Show on document", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2027
2566
|
"button",
|
|
2028
2567
|
{
|
|
2029
2568
|
type: "button",
|
|
2030
2569
|
className: "gemina-verification__eye",
|
|
2031
|
-
title: "Show on document",
|
|
2032
2570
|
"aria-label": "Show on document",
|
|
2033
2571
|
onClick: (event) => {
|
|
2034
2572
|
event.stopPropagation();
|
|
2035
2573
|
onFlash();
|
|
2036
2574
|
},
|
|
2037
|
-
children: /* @__PURE__ */ (0,
|
|
2575
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconEye, {})
|
|
2038
2576
|
}
|
|
2039
|
-
);
|
|
2577
|
+
) });
|
|
2040
2578
|
}
|
|
2041
2579
|
function FieldInput(props) {
|
|
2042
|
-
const { binding, edit, onEdit, readOnly, ariaLabel } = props;
|
|
2043
|
-
const
|
|
2580
|
+
const { binding, edit, onEdit, readOnly, ariaLabel, pairError } = props;
|
|
2581
|
+
const editKey = props.editKey ?? binding.key.raw;
|
|
2582
|
+
const editedBadgeId = import_react4.default.useId();
|
|
2583
|
+
const errorId = import_react4.default.useId();
|
|
2584
|
+
const currencyListId = import_react4.default.useId();
|
|
2044
2585
|
if (readOnly || !binding.editable) {
|
|
2045
2586
|
const display = binding.extracted === NOT_FOUND ? null : binding.extracted;
|
|
2046
|
-
return /* @__PURE__ */ (0,
|
|
2587
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: formatValue(display, binding.key.label) });
|
|
2047
2588
|
}
|
|
2048
2589
|
const dirty = edit !== void 0;
|
|
2049
2590
|
const missed = binding.serverValue === NOT_FOUND;
|
|
2591
|
+
const field = binding.field;
|
|
2592
|
+
const value = dirty ? edit : toInputString(binding.extracted);
|
|
2593
|
+
const error = pairError ?? (dirty ? validateInput(value, field) : null);
|
|
2050
2594
|
const className = [
|
|
2051
2595
|
"gemina-verification__input",
|
|
2052
2596
|
dirty ? "gemina-verification__input--dirty" : "",
|
|
2053
|
-
missed ? "gemina-verification__input--missed" : ""
|
|
2597
|
+
missed ? "gemina-verification__input--missed" : "",
|
|
2598
|
+
error ? "gemina-verification__input--invalid" : ""
|
|
2054
2599
|
].filter(Boolean).join(" ");
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2600
|
+
const describedBy = [dirty ? editedBadgeId : "", error ? errorId : ""].filter(Boolean).join(" ");
|
|
2601
|
+
const shared = {
|
|
2602
|
+
className,
|
|
2603
|
+
"aria-label": ariaLabel,
|
|
2604
|
+
"aria-describedby": describedBy || void 0,
|
|
2605
|
+
"aria-invalid": error ? true : void 0,
|
|
2606
|
+
onChange: (event) => onEdit(editKey, event.target.value, binding)
|
|
2607
|
+
};
|
|
2608
|
+
const roster = field?.enum && field.enum.length > 0 ? field.enum : null;
|
|
2609
|
+
const offRoster = roster && value !== "" && !roster.includes(value) ? value : null;
|
|
2610
|
+
const control = roster ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { ...shared, value, dir: "auto", children: [
|
|
2611
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "", children: "\u2014" }),
|
|
2612
|
+
offRoster ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("option", { value: offRoster, children: [
|
|
2613
|
+
offRoster,
|
|
2614
|
+
" (as extracted)"
|
|
2615
|
+
] }) : null,
|
|
2616
|
+
roster.map((option) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: option, children: option }, option))
|
|
2617
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2618
|
+
"input",
|
|
2619
|
+
{
|
|
2620
|
+
...shared,
|
|
2621
|
+
type: field?.type === "date" ? "date" : "text",
|
|
2622
|
+
dir: "auto",
|
|
2623
|
+
value,
|
|
2624
|
+
inputMode: field?.type === "number" || field?.type === "integer" ? "decimal" : void 0,
|
|
2625
|
+
list: field?.format === "iso4217" ? currencyListId : void 0,
|
|
2626
|
+
placeholder: missed ? "Not detected \u2014 fill in if present" : void 0,
|
|
2627
|
+
autoComplete: "off"
|
|
2628
|
+
}
|
|
2629
|
+
);
|
|
2630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
2631
|
+
control,
|
|
2632
|
+
field?.format === "iso4217" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("datalist", { id: currencyListId, children: ISO_4217_CODES.map((code) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: code }, code)) }) : null,
|
|
2633
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "gemina-verification__field-error", id: errorId, role: "alert", children: error }) : null,
|
|
2634
|
+
dirty ? (
|
|
2635
|
+
// The badge is where the ORIGINAL belongs, now that the input holds
|
|
2636
|
+
// the edit — otherwise the extracted value is simply gone from the
|
|
2637
|
+
// screen the moment someone corrects it.
|
|
2638
|
+
//
|
|
2639
|
+
// Known limit: the badge is a non-focusable span, so this channel is
|
|
2640
|
+
// hover-only. AT is not worse off than before (nothing carried the
|
|
2641
|
+
// original previously), and the input's aria-describedby still names
|
|
2642
|
+
// the field as edited. Giving it a keyboard path needs a focusable
|
|
2643
|
+
// affordance, which belongs with the Phase 8 row work, not here.
|
|
2644
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2645
|
+
Tip,
|
|
2646
|
+
{
|
|
2647
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
2648
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "gemina-verification__tip-label", children: "Was: " }),
|
|
2649
|
+
formatValue(
|
|
2650
|
+
binding.extracted === NOT_FOUND ? null : binding.extracted,
|
|
2651
|
+
binding.key.label
|
|
2652
|
+
)
|
|
2653
|
+
] }),
|
|
2654
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "gemina-verification__edited", id: editedBadgeId, children: "edited" })
|
|
2655
|
+
}
|
|
2656
|
+
)
|
|
2657
|
+
) : null
|
|
2071
2658
|
] });
|
|
2072
2659
|
}
|
|
2660
|
+
var NO_PAIR_ERRORS = /* @__PURE__ */ new Map();
|
|
2661
|
+
var NO_TABLES = [];
|
|
2662
|
+
var NO_PLANNED = /* @__PURE__ */ new Map();
|
|
2663
|
+
var NOOP_ROW = () => {
|
|
2664
|
+
};
|
|
2073
2665
|
function isInteractiveTarget(target) {
|
|
2074
2666
|
return target instanceof Element && target.closest("input, button, a, select, textarea") !== null;
|
|
2075
2667
|
}
|
|
2668
|
+
function FieldLabel(props) {
|
|
2669
|
+
const { label, description } = props;
|
|
2670
|
+
if (!description) {
|
|
2671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: label });
|
|
2672
|
+
}
|
|
2673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tip, { content: description, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "gemina-verification__label-described", tabIndex: 0, children: label }) });
|
|
2674
|
+
}
|
|
2076
2675
|
function FieldPair(props) {
|
|
2077
2676
|
const { label, ariaLabel, cell, shared } = props;
|
|
2078
2677
|
const binding = shared.bindingIndex.get(cell.pointer);
|
|
2079
|
-
return /* @__PURE__ */ (0,
|
|
2080
|
-
/* @__PURE__ */ (0,
|
|
2081
|
-
/* @__PURE__ */ (0,
|
|
2082
|
-
/* @__PURE__ */ (0,
|
|
2678
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
2679
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dt", { className: "gemina-verification__dt", children: [
|
|
2680
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ConfidenceDot, { confidence: cell.confidence }),
|
|
2681
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldLabel, { label, description: binding?.field?.description })
|
|
2083
2682
|
] }),
|
|
2084
|
-
/* @__PURE__ */ (0,
|
|
2085
|
-
binding !== void 0 ? /* @__PURE__ */ (0,
|
|
2683
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dd", { className: "gemina-verification__dd", children: [
|
|
2684
|
+
binding !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2086
2685
|
FieldInput,
|
|
2087
2686
|
{
|
|
2088
2687
|
binding,
|
|
2688
|
+
pairError: shared.pairErrors.get(binding.key.raw),
|
|
2089
2689
|
edit: shared.edits.get(binding.key.raw),
|
|
2090
2690
|
onEdit: shared.onEdit,
|
|
2091
2691
|
readOnly: shared.readOnly,
|
|
2092
2692
|
ariaLabel
|
|
2093
2693
|
}
|
|
2094
|
-
) : /* @__PURE__ */ (0,
|
|
2095
|
-
/* @__PURE__ */ (0,
|
|
2694
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: formatValue(cell.value, label) }),
|
|
2695
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2096
2696
|
EyeButton,
|
|
2097
2697
|
{
|
|
2098
2698
|
coordinates: cell.coordinates,
|
|
@@ -2111,10 +2711,10 @@ function HeaderSection(props) {
|
|
|
2111
2711
|
if (headers.length === 0 && simpleLists.length === 0) {
|
|
2112
2712
|
return null;
|
|
2113
2713
|
}
|
|
2114
|
-
return /* @__PURE__ */ (0,
|
|
2115
|
-
/* @__PURE__ */ (0,
|
|
2116
|
-
/* @__PURE__ */ (0,
|
|
2117
|
-
headers.map((field) => /* @__PURE__ */ (0,
|
|
2714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Details", children: [
|
|
2715
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__section-header", children: "Details" }),
|
|
2716
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dl", { className: "gemina-verification__dl", children: [
|
|
2717
|
+
headers.map((field) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2118
2718
|
FieldPair,
|
|
2119
2719
|
{
|
|
2120
2720
|
label: formatLabel(field.key),
|
|
@@ -2124,23 +2724,24 @@ function HeaderSection(props) {
|
|
|
2124
2724
|
},
|
|
2125
2725
|
field.pointer
|
|
2126
2726
|
)),
|
|
2127
|
-
simpleLists.map((list) => /* @__PURE__ */ (0,
|
|
2128
|
-
/* @__PURE__ */ (0,
|
|
2129
|
-
/* @__PURE__ */ (0,
|
|
2727
|
+
simpleLists.map((list) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react4.default.Fragment, { children: [
|
|
2728
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { className: "gemina-verification__dt", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: formatLabel(list.key) }) }),
|
|
2729
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { className: "gemina-verification__dd", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "gemina-verification__list", children: list.items.map((item, index) => {
|
|
2130
2730
|
const binding = shared.bindingIndex.get(item.pointer);
|
|
2131
|
-
return /* @__PURE__ */ (0,
|
|
2132
|
-
binding !== void 0 ? /* @__PURE__ */ (0,
|
|
2731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { className: "gemina-verification__cell", children: [
|
|
2732
|
+
binding !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2133
2733
|
FieldInput,
|
|
2134
2734
|
{
|
|
2135
2735
|
binding,
|
|
2736
|
+
pairError: shared.pairErrors.get(binding.key.raw),
|
|
2136
2737
|
edit: shared.edits.get(binding.key.raw),
|
|
2137
2738
|
onEdit: shared.onEdit,
|
|
2138
2739
|
readOnly: shared.readOnly,
|
|
2139
2740
|
ariaLabel: `${formatLabel(list.key)} item ${index + 1}`
|
|
2140
2741
|
}
|
|
2141
|
-
) : /* @__PURE__ */ (0,
|
|
2142
|
-
/* @__PURE__ */ (0,
|
|
2143
|
-
/* @__PURE__ */ (0,
|
|
2742
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: formatValue(item.value) }),
|
|
2743
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ConfidenceDot, { confidence: item.confidence }),
|
|
2744
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2144
2745
|
EyeButton,
|
|
2145
2746
|
{
|
|
2146
2747
|
coordinates: item.coordinates,
|
|
@@ -2161,20 +2762,20 @@ function EntitySection(props) {
|
|
|
2161
2762
|
const { entity, shared } = props;
|
|
2162
2763
|
const label = formatLabel(entity.key);
|
|
2163
2764
|
const singular = label.replace(/s$/, "");
|
|
2164
|
-
return /* @__PURE__ */ (0,
|
|
2165
|
-
/* @__PURE__ */ (0,
|
|
2765
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
|
|
2766
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__section-header", children: [
|
|
2166
2767
|
label,
|
|
2167
2768
|
" (",
|
|
2168
2769
|
entity.items.length,
|
|
2169
2770
|
")"
|
|
2170
2771
|
] }),
|
|
2171
|
-
/* @__PURE__ */ (0,
|
|
2172
|
-
/* @__PURE__ */ (0,
|
|
2772
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__section-body", children: entity.items.map((item, itemIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__card", children: [
|
|
2773
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__card-header", children: [
|
|
2173
2774
|
singular,
|
|
2174
2775
|
" ",
|
|
2175
2776
|
itemIndex + 1
|
|
2176
2777
|
] }),
|
|
2177
|
-
/* @__PURE__ */ (0,
|
|
2778
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dl", { className: "gemina-verification__dl", children: Object.entries(item).map(([fieldKey, cell]) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2178
2779
|
FieldPair,
|
|
2179
2780
|
{
|
|
2180
2781
|
label: formatLabel(fieldKey),
|
|
@@ -2188,18 +2789,18 @@ function EntitySection(props) {
|
|
|
2188
2789
|
] });
|
|
2189
2790
|
}
|
|
2190
2791
|
function TableRowView(props) {
|
|
2191
|
-
const { row, rowIndex, columns, tableLabel, hasCoords, hasRowConfidence, shared } = props;
|
|
2792
|
+
const { row, rowIndex, columns, tableLabel, hasCoords, hasRowConfidence, shared, planned, tablePointer } = props;
|
|
2192
2793
|
const { bindingIndex, edits, onEdit, readOnly, onFlash } = shared;
|
|
2193
|
-
const rects =
|
|
2794
|
+
const rects = import_react4.default.useMemo(() => {
|
|
2194
2795
|
const collected = [];
|
|
2195
|
-
for (const [key, cell] of Object.entries(row)) {
|
|
2796
|
+
for (const [key, cell] of Object.entries(row ?? {})) {
|
|
2196
2797
|
if (key !== ROW_META_KEY && cell.coordinates) {
|
|
2197
2798
|
collected.push(cell.coordinates);
|
|
2198
2799
|
}
|
|
2199
2800
|
}
|
|
2200
2801
|
return collected;
|
|
2201
2802
|
}, [row]);
|
|
2202
|
-
const handleRowClick =
|
|
2803
|
+
const handleRowClick = import_react4.default.useCallback(
|
|
2203
2804
|
(event) => {
|
|
2204
2805
|
if (isInteractiveTarget(event.target)) {
|
|
2205
2806
|
return;
|
|
@@ -2210,81 +2811,205 @@ function TableRowView(props) {
|
|
|
2210
2811
|
},
|
|
2211
2812
|
[rects, onFlash]
|
|
2212
2813
|
);
|
|
2814
|
+
const cellFor = (column) => {
|
|
2815
|
+
const direct = row?.[column];
|
|
2816
|
+
const alias = direct === void 0 ? row?.[snakeToCamel(column)] : void 0;
|
|
2817
|
+
const fallbackKey = direct === void 0 && alias === void 0 && row !== void 0 ? Object.keys(row).find((key) => snakeToCamel(key) === snakeToCamel(column)) : void 0;
|
|
2818
|
+
const classified = direct ?? alias ?? (fallbackKey === void 0 ? void 0 : row?.[fallbackKey]);
|
|
2819
|
+
const fromPlan = planned?.cells.find((cell) => cell.column === column);
|
|
2820
|
+
if (fromPlan) {
|
|
2821
|
+
return { classified, binding: fromPlan.binding, editKey: fromPlan.editKey };
|
|
2822
|
+
}
|
|
2823
|
+
const binding = classified === void 0 ? void 0 : bindingIndex.get(classified.pointer);
|
|
2824
|
+
return { classified, binding, editKey: binding?.key.raw };
|
|
2825
|
+
};
|
|
2213
2826
|
const firstRect = rects.length > 0 ? rects[0] : null;
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2827
|
+
const showControls = planned !== void 0 && tablePointer !== void 0 && !readOnly;
|
|
2828
|
+
const rowLevel = (row?.[ROW_META_KEY]?.confidence?.level ?? "").toLowerCase();
|
|
2829
|
+
const rowClass = rowLevel === "low" || rowLevel === "medium" ? `gemina-verification__row--${rowLevel}` : void 0;
|
|
2830
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("tr", { onClick: handleRowClick, className: rowClass, children: [
|
|
2831
|
+
hasCoords ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EyeButton, { coordinates: firstRect, onFlash: () => onFlash(rects) }) }) : null,
|
|
2832
|
+
hasRowConfidence ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ConfidenceDot, { confidence: row?.[ROW_META_KEY]?.confidence ?? null }) }) : null,
|
|
2217
2833
|
columns.map((column) => {
|
|
2218
|
-
const
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
binding !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2834
|
+
const { classified, binding, editKey } = cellFor(column);
|
|
2835
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__cell", children: [
|
|
2836
|
+
binding !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2222
2837
|
FieldInput,
|
|
2223
2838
|
{
|
|
2224
2839
|
binding,
|
|
2225
|
-
|
|
2840
|
+
editKey,
|
|
2841
|
+
pairError: editKey === void 0 ? void 0 : shared.pairErrors.get(editKey),
|
|
2842
|
+
edit: editKey === void 0 ? void 0 : edits.get(editKey),
|
|
2226
2843
|
onEdit,
|
|
2227
2844
|
readOnly,
|
|
2228
2845
|
ariaLabel: `${tableLabel} row ${rowIndex + 1} \u2014 ${formatLabel(column)}`
|
|
2229
2846
|
}
|
|
2230
|
-
) : /* @__PURE__ */ (0,
|
|
2231
|
-
/* @__PURE__ */ (0,
|
|
2847
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: classified === void 0 ? "-" : formatValue(classified.value, column) }),
|
|
2848
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ConfidenceDot, { confidence: classified?.confidence ?? null })
|
|
2232
2849
|
] }) }, column);
|
|
2233
|
-
})
|
|
2850
|
+
}),
|
|
2851
|
+
showControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("td", { className: "gemina-verification__row-actions", children: [
|
|
2852
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tip, { content: "Insert a line below", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2853
|
+
"button",
|
|
2854
|
+
{
|
|
2855
|
+
type: "button",
|
|
2856
|
+
className: "gemina-verification__row-btn",
|
|
2857
|
+
"aria-label": `Insert line below line ${rowIndex + 1}`,
|
|
2858
|
+
onClick: () => shared.onAddRow(tablePointer, rowIndex),
|
|
2859
|
+
children: "+"
|
|
2860
|
+
}
|
|
2861
|
+
) }),
|
|
2862
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tip, { content: "Remove this line", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2863
|
+
"button",
|
|
2864
|
+
{
|
|
2865
|
+
type: "button",
|
|
2866
|
+
className: "gemina-verification__row-btn",
|
|
2867
|
+
"aria-label": `Remove line ${rowIndex + 1}`,
|
|
2868
|
+
onClick: () => shared.onRemoveRow(tablePointer, rowIndex),
|
|
2869
|
+
children: "\xD7"
|
|
2870
|
+
}
|
|
2871
|
+
) })
|
|
2872
|
+
] }) : null
|
|
2234
2873
|
] });
|
|
2235
2874
|
}
|
|
2236
2875
|
function areRowPropsEqual(prev, next) {
|
|
2237
|
-
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) {
|
|
2876
|
+
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) {
|
|
2238
2877
|
return false;
|
|
2239
2878
|
}
|
|
2240
2879
|
if (prev.shared.edits === next.shared.edits) {
|
|
2241
2880
|
return true;
|
|
2242
2881
|
}
|
|
2243
2882
|
for (const column of next.columns) {
|
|
2244
|
-
const
|
|
2245
|
-
const
|
|
2246
|
-
|
|
2883
|
+
const planned = next.planned?.cells.find((cell) => cell.column === column);
|
|
2884
|
+
const classified = next.row?.[column];
|
|
2885
|
+
const editKey = planned?.editKey ?? (classified === void 0 ? void 0 : next.shared.bindingIndex.get(classified.pointer)?.key.raw);
|
|
2886
|
+
if (editKey === void 0) {
|
|
2887
|
+
continue;
|
|
2888
|
+
}
|
|
2889
|
+
if (prev.shared.edits.get(editKey) !== next.shared.edits.get(editKey) || prev.shared.pairErrors.get(editKey) !== next.shared.pairErrors.get(editKey)) {
|
|
2247
2890
|
return false;
|
|
2248
2891
|
}
|
|
2249
2892
|
}
|
|
2250
2893
|
return true;
|
|
2251
2894
|
}
|
|
2252
|
-
var TableRow =
|
|
2895
|
+
var TableRow = import_react4.default.memo(TableRowView, areRowPropsEqual);
|
|
2896
|
+
function withEmptyMutableTables(classified, tables) {
|
|
2897
|
+
if (tables.length === 0) {
|
|
2898
|
+
return { tables: classified.tables, suppressed: EMPTY_SUPPRESSED };
|
|
2899
|
+
}
|
|
2900
|
+
const promoted = [...classified.tables];
|
|
2901
|
+
const suppressed = /* @__PURE__ */ new Set();
|
|
2902
|
+
for (const table of tables) {
|
|
2903
|
+
if (classified.tables.some((candidate) => matchesTablePointer(table.pointer, candidate.pointer))) {
|
|
2904
|
+
continue;
|
|
2905
|
+
}
|
|
2906
|
+
const header = classified.headers.find(
|
|
2907
|
+
(candidate) => matchesTablePointer(table.pointer, candidate.pointer)
|
|
2908
|
+
);
|
|
2909
|
+
const empty = header !== void 0 && (header.value === null || Array.isArray(header.value) && header.value.length === 0);
|
|
2910
|
+
if (!empty) {
|
|
2911
|
+
continue;
|
|
2912
|
+
}
|
|
2913
|
+
suppressed.add(header.pointer);
|
|
2914
|
+
promoted.push({
|
|
2915
|
+
key: header.key,
|
|
2916
|
+
pointer: header.pointer,
|
|
2917
|
+
columns: [],
|
|
2918
|
+
rows: [],
|
|
2919
|
+
overallConfidence: null
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2922
|
+
return { tables: promoted, suppressed };
|
|
2923
|
+
}
|
|
2924
|
+
var EMPTY_SUPPRESSED = /* @__PURE__ */ new Set();
|
|
2253
2925
|
function TableSection(props) {
|
|
2254
2926
|
const { table, shared } = props;
|
|
2255
2927
|
const label = formatLabel(table.key);
|
|
2256
|
-
const
|
|
2928
|
+
const mutable = import_react4.default.useMemo(
|
|
2929
|
+
() => shared.rowMutableTables.find((entry) => matchesTablePointer(entry.pointer, table.pointer)),
|
|
2930
|
+
[shared.rowMutableTables, table.pointer]
|
|
2931
|
+
);
|
|
2932
|
+
const columns = import_react4.default.useMemo(
|
|
2933
|
+
() => mutable ? displayColumns(mutable, table.columns) : table.columns,
|
|
2934
|
+
[mutable, table.columns]
|
|
2935
|
+
);
|
|
2936
|
+
const planned = mutable ? shared.plannedTables.get(mutable.pointer) : void 0;
|
|
2937
|
+
const hasCoords = import_react4.default.useMemo(
|
|
2257
2938
|
() => table.rows.some(
|
|
2258
2939
|
(row) => Object.entries(row).some(([key, cell]) => key !== ROW_META_KEY && cell.coordinates !== null)
|
|
2259
2940
|
),
|
|
2260
2941
|
[table]
|
|
2261
2942
|
);
|
|
2262
|
-
const hasRowConfidence =
|
|
2943
|
+
const hasRowConfidence = import_react4.default.useMemo(
|
|
2263
2944
|
() => table.rows.some((row) => Boolean(row[ROW_META_KEY]?.confidence?.level)),
|
|
2264
2945
|
[table]
|
|
2265
2946
|
);
|
|
2266
|
-
|
|
2267
|
-
/* @__PURE__ */ (
|
|
2268
|
-
|
|
2947
|
+
const columnDescriptions = import_react4.default.useMemo(() => {
|
|
2948
|
+
const map = /* @__PURE__ */ new Map();
|
|
2949
|
+
for (const column of mutable?.columns ?? []) {
|
|
2950
|
+
if (typeof column.key === "string" && column.description) {
|
|
2951
|
+
map.set(column.key, column.description);
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
return map;
|
|
2955
|
+
}, [mutable]);
|
|
2956
|
+
const rowCount = planned ? planned.length : table.rows.length;
|
|
2957
|
+
const needsReview = import_react4.default.useMemo(
|
|
2958
|
+
() => table.rows.filter((row) => {
|
|
2959
|
+
const level = (row[ROW_META_KEY]?.confidence?.level ?? "").toLowerCase();
|
|
2960
|
+
return level === "low" || level === "medium";
|
|
2961
|
+
}).length,
|
|
2962
|
+
[table.rows]
|
|
2963
|
+
);
|
|
2964
|
+
const showControls = planned !== void 0 && mutable !== void 0 && !shared.readOnly;
|
|
2965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
|
|
2966
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__section-header", children: [
|
|
2967
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
2269
2968
|
label,
|
|
2270
2969
|
" (",
|
|
2271
|
-
|
|
2272
|
-
" rows
|
|
2970
|
+
rowCount,
|
|
2971
|
+
" rows",
|
|
2972
|
+
needsReview > 0 ? ` \xB7 ${needsReview} need review` : "",
|
|
2973
|
+
")"
|
|
2273
2974
|
] }),
|
|
2274
|
-
/* @__PURE__ */ (0,
|
|
2975
|
+
table.overallConfidence ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "gemina-verification__overall-confidence", children: [
|
|
2976
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Overall confidence" }),
|
|
2977
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ConfidenceDot, { confidence: table.overallConfidence })
|
|
2978
|
+
] }) : null
|
|
2275
2979
|
] }),
|
|
2276
|
-
/* @__PURE__ */ (0,
|
|
2277
|
-
/* @__PURE__ */ (0,
|
|
2278
|
-
hasCoords ? /* @__PURE__ */ (0,
|
|
2279
|
-
hasRowConfidence ? /* @__PURE__ */ (0,
|
|
2280
|
-
|
|
2980
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__table-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("table", { className: "gemina-verification__table", children: [
|
|
2981
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("tr", { children: [
|
|
2982
|
+
hasCoords ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Show row on document" }) : null,
|
|
2983
|
+
hasRowConfidence ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Row confidence" }) : null,
|
|
2984
|
+
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2985
|
+
FieldLabel,
|
|
2986
|
+
{
|
|
2987
|
+
label: formatLabel(column),
|
|
2988
|
+
description: columnDescriptions.get(column)
|
|
2989
|
+
}
|
|
2990
|
+
) }, column)),
|
|
2991
|
+
showControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Row actions" }) : null
|
|
2281
2992
|
] }) }),
|
|
2282
|
-
/* @__PURE__ */ (0,
|
|
2993
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("tbody", { children: planned ? planned.map((plannedRow, position) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2994
|
+
TableRow,
|
|
2995
|
+
{
|
|
2996
|
+
row: plannedRow.entry.source === null ? void 0 : table.rows[plannedRow.entry.source],
|
|
2997
|
+
rowIndex: position,
|
|
2998
|
+
columns,
|
|
2999
|
+
tableLabel: label,
|
|
3000
|
+
hasCoords,
|
|
3001
|
+
hasRowConfidence,
|
|
3002
|
+
shared,
|
|
3003
|
+
planned: plannedRow,
|
|
3004
|
+
tablePointer: mutable.pointer
|
|
3005
|
+
},
|
|
3006
|
+
plannedRow.entry.id
|
|
3007
|
+
)) : table.rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2283
3008
|
TableRow,
|
|
2284
3009
|
{
|
|
2285
3010
|
row,
|
|
2286
3011
|
rowIndex,
|
|
2287
|
-
columns
|
|
3012
|
+
columns,
|
|
2288
3013
|
tableLabel: label,
|
|
2289
3014
|
hasCoords,
|
|
2290
3015
|
hasRowConfidence,
|
|
@@ -2292,19 +3017,28 @@ function TableSection(props) {
|
|
|
2292
3017
|
},
|
|
2293
3018
|
rowIndex
|
|
2294
3019
|
)) })
|
|
2295
|
-
] }) })
|
|
3020
|
+
] }) }),
|
|
3021
|
+
showControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__table-footer", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3022
|
+
"button",
|
|
3023
|
+
{
|
|
3024
|
+
type: "button",
|
|
3025
|
+
className: "gemina-verification__add-row",
|
|
3026
|
+
onClick: () => shared.onAddRow(mutable.pointer, rowCount - 1),
|
|
3027
|
+
children: "Add line"
|
|
3028
|
+
}
|
|
3029
|
+
) }) : null
|
|
2296
3030
|
] });
|
|
2297
3031
|
}
|
|
2298
|
-
var FallbackSection =
|
|
3032
|
+
var FallbackSection = import_react4.default.memo(function FallbackSection2(props) {
|
|
2299
3033
|
const { fallback } = props;
|
|
2300
3034
|
if (fallback.length === 0) {
|
|
2301
3035
|
return null;
|
|
2302
3036
|
}
|
|
2303
|
-
return /* @__PURE__ */ (0,
|
|
2304
|
-
/* @__PURE__ */ (0,
|
|
2305
|
-
/* @__PURE__ */ (0,
|
|
2306
|
-
/* @__PURE__ */ (0,
|
|
2307
|
-
/* @__PURE__ */ (0,
|
|
3037
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Additional Data", children: [
|
|
3038
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__section-header", children: "Additional Data" }),
|
|
3039
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__section-body", children: fallback.map((item) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { className: "gemina-verification__fallback", children: [
|
|
3040
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("summary", { children: formatLabel(item.key) }),
|
|
3041
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("pre", { children: JSON.stringify(item.data, null, 2) })
|
|
2308
3042
|
] }, item.key)) })
|
|
2309
3043
|
] });
|
|
2310
3044
|
});
|
|
@@ -2313,14 +3047,15 @@ function UnmatchedSection(props) {
|
|
|
2313
3047
|
if (unmatched.length === 0) {
|
|
2314
3048
|
return null;
|
|
2315
3049
|
}
|
|
2316
|
-
return /* @__PURE__ */ (0,
|
|
2317
|
-
/* @__PURE__ */ (0,
|
|
2318
|
-
/* @__PURE__ */ (0,
|
|
2319
|
-
/* @__PURE__ */ (0,
|
|
2320
|
-
/* @__PURE__ */ (0,
|
|
3050
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Not detected", children: [
|
|
3051
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__section-header", children: "Not detected" }),
|
|
3052
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dl", { className: "gemina-verification__dl", children: unmatched.map((binding) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react4.default.Fragment, { children: [
|
|
3053
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { className: "gemina-verification__dt", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: binding.key.label }) }),
|
|
3054
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { className: "gemina-verification__dd", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2321
3055
|
FieldInput,
|
|
2322
3056
|
{
|
|
2323
3057
|
binding,
|
|
3058
|
+
pairError: shared.pairErrors.get(binding.key.raw),
|
|
2324
3059
|
edit: shared.edits.get(binding.key.raw),
|
|
2325
3060
|
onEdit: shared.onEdit,
|
|
2326
3061
|
readOnly: shared.readOnly,
|
|
@@ -2331,26 +3066,65 @@ function UnmatchedSection(props) {
|
|
|
2331
3066
|
] });
|
|
2332
3067
|
}
|
|
2333
3068
|
function VerificationForm(props) {
|
|
2334
|
-
const {
|
|
2335
|
-
|
|
3069
|
+
const {
|
|
3070
|
+
classified,
|
|
3071
|
+
unmatched,
|
|
3072
|
+
bindingIndex,
|
|
3073
|
+
edits,
|
|
3074
|
+
onEdit,
|
|
3075
|
+
readOnly,
|
|
3076
|
+
onFlash,
|
|
3077
|
+
pairErrors,
|
|
3078
|
+
rowMutableTables,
|
|
3079
|
+
plannedTables,
|
|
3080
|
+
onAddRow,
|
|
3081
|
+
onRemoveRow
|
|
3082
|
+
} = props;
|
|
3083
|
+
const { tables: promotedTables, suppressed } = import_react4.default.useMemo(
|
|
3084
|
+
() => withEmptyMutableTables(classified, rowMutableTables ?? NO_TABLES),
|
|
3085
|
+
[classified, rowMutableTables]
|
|
3086
|
+
);
|
|
3087
|
+
const shared = {
|
|
3088
|
+
bindingIndex,
|
|
3089
|
+
edits,
|
|
3090
|
+
onEdit,
|
|
3091
|
+
readOnly,
|
|
3092
|
+
onFlash,
|
|
3093
|
+
pairErrors: pairErrors ?? NO_PAIR_ERRORS,
|
|
3094
|
+
rowMutableTables: rowMutableTables ?? NO_TABLES,
|
|
3095
|
+
plannedTables: plannedTables ?? NO_PLANNED,
|
|
3096
|
+
onAddRow: onAddRow ?? NOOP_ROW,
|
|
3097
|
+
onRemoveRow: onRemoveRow ?? NOOP_ROW
|
|
3098
|
+
};
|
|
2336
3099
|
return (
|
|
2337
3100
|
// A real, labeled <form> (role "form" landmark): AT users can jump
|
|
2338
3101
|
// straight to the editable fields. Submission is owned by the root's
|
|
2339
3102
|
// footer button, never by the form element itself — preventDefault stops
|
|
2340
3103
|
// implicit submission (Enter in a payload with exactly one input would
|
|
2341
3104
|
// otherwise navigate).
|
|
2342
|
-
/* @__PURE__ */ (0,
|
|
3105
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2343
3106
|
"form",
|
|
2344
3107
|
{
|
|
2345
3108
|
className: "gemina-verification__form",
|
|
2346
3109
|
"aria-label": "Extraction fields",
|
|
2347
3110
|
onSubmit: (event) => event.preventDefault(),
|
|
2348
3111
|
children: [
|
|
2349
|
-
/* @__PURE__ */ (0,
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
/* @__PURE__ */ (0,
|
|
3112
|
+
classified.overallConfidence ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__confidence-summary", children: [
|
|
3113
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Overall confidence" }),
|
|
3114
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ConfidenceDot, { confidence: classified.overallConfidence })
|
|
3115
|
+
] }) : null,
|
|
3116
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3117
|
+
HeaderSection,
|
|
3118
|
+
{
|
|
3119
|
+
headers: classified.headers.filter((header) => !suppressed.has(header.pointer)),
|
|
3120
|
+
simpleLists: classified.simpleLists,
|
|
3121
|
+
shared
|
|
3122
|
+
}
|
|
3123
|
+
),
|
|
3124
|
+
classified.entities.map((entity) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EntitySection, { entity, shared }, entity.pointer)),
|
|
3125
|
+
promotedTables.map((table) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TableSection, { table, shared }, table.pointer)),
|
|
3126
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FallbackSection, { fallback: classified.fallback }),
|
|
3127
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(UnmatchedSection, { unmatched, shared })
|
|
2354
3128
|
]
|
|
2355
3129
|
}
|
|
2356
3130
|
)
|
|
@@ -2457,9 +3231,15 @@ var VERIFICATION_CSS = `
|
|
|
2457
3231
|
background: var(--gemina-verification-bg);
|
|
2458
3232
|
border: 1px solid var(--gemina-verification-border);
|
|
2459
3233
|
border-radius: var(--gemina-verification-radius);
|
|
2460
|
-
overflow
|
|
3234
|
+
/* overflow hidden creates a scroll container and prevents the toolbar's sticky
|
|
3235
|
+
positioning from following the host modal's scrollport. Clip keeps the
|
|
3236
|
+
rounded frame without stealing sticky containment. */
|
|
3237
|
+
overflow: clip;
|
|
2461
3238
|
}
|
|
2462
3239
|
.gemina-verification__toolbar {
|
|
3240
|
+
position: sticky;
|
|
3241
|
+
top: 0;
|
|
3242
|
+
z-index: 5;
|
|
2463
3243
|
display: flex;
|
|
2464
3244
|
/* Narrow roots (~<330px) can't fit all 7 buttons on one line: wrap to a
|
|
2465
3245
|
second row instead of clipping past the canvas edge. The gap shorthand
|
|
@@ -2469,6 +3249,7 @@ var VERIFICATION_CSS = `
|
|
|
2469
3249
|
gap: 6px;
|
|
2470
3250
|
flex: 0 0 auto;
|
|
2471
3251
|
padding: 8px 10px;
|
|
3252
|
+
background: var(--gemina-verification-bg);
|
|
2472
3253
|
border-block-end: 1px solid var(--gemina-verification-border);
|
|
2473
3254
|
}
|
|
2474
3255
|
.gemina-verification__toolbar-btn {
|
|
@@ -2579,6 +3360,19 @@ var VERIFICATION_CSS = `
|
|
|
2579
3360
|
min-width: 0;
|
|
2580
3361
|
margin: 0;
|
|
2581
3362
|
}
|
|
3363
|
+
.gemina-verification__confidence-summary {
|
|
3364
|
+
display: flex;
|
|
3365
|
+
align-items: center;
|
|
3366
|
+
justify-content: space-between;
|
|
3367
|
+
gap: 12px;
|
|
3368
|
+
padding: 9px 12px;
|
|
3369
|
+
background: var(--gemina-verification-surface);
|
|
3370
|
+
border: 1px solid var(--gemina-verification-border);
|
|
3371
|
+
border-radius: var(--gemina-verification-radius);
|
|
3372
|
+
color: var(--gemina-verification-muted);
|
|
3373
|
+
font-size: 12px;
|
|
3374
|
+
font-weight: 600;
|
|
3375
|
+
}
|
|
2582
3376
|
.gemina-verification__section {
|
|
2583
3377
|
background: var(--gemina-verification-bg);
|
|
2584
3378
|
border: 1px solid var(--gemina-verification-border);
|
|
@@ -2595,6 +3389,16 @@ var VERIFICATION_CSS = `
|
|
|
2595
3389
|
font-size: 13px;
|
|
2596
3390
|
font-weight: 600;
|
|
2597
3391
|
}
|
|
3392
|
+
.gemina-verification__overall-confidence {
|
|
3393
|
+
display: inline-flex;
|
|
3394
|
+
align-items: center;
|
|
3395
|
+
gap: 6px;
|
|
3396
|
+
margin-inline-start: auto;
|
|
3397
|
+
color: var(--gemina-verification-muted);
|
|
3398
|
+
font-size: 11px;
|
|
3399
|
+
font-weight: 500;
|
|
3400
|
+
white-space: nowrap;
|
|
3401
|
+
}
|
|
2598
3402
|
.gemina-verification__dl {
|
|
2599
3403
|
display: grid;
|
|
2600
3404
|
grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
|
|
@@ -2614,6 +3418,10 @@ var VERIFICATION_CSS = `
|
|
|
2614
3418
|
}
|
|
2615
3419
|
.gemina-verification__dd {
|
|
2616
3420
|
display: flex;
|
|
3421
|
+
/* Wrap so a field error takes its OWN line (it sets flex-basis:100%).
|
|
3422
|
+
Without this it competes with the input for width, and at 390px the
|
|
3423
|
+
message wrapped to one word per line while the input shrank to ~55px. */
|
|
3424
|
+
flex-wrap: wrap;
|
|
2617
3425
|
align-items: center;
|
|
2618
3426
|
gap: 6px;
|
|
2619
3427
|
margin: 0; /* resets the UA's margin-inline-start on <dd> */
|
|
@@ -2633,6 +3441,15 @@ var VERIFICATION_CSS = `
|
|
|
2633
3441
|
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
2634
3442
|
padding: 5px 8px;
|
|
2635
3443
|
}
|
|
3444
|
+
/* FieldInput is a fragment. Let its control take the remaining row width
|
|
3445
|
+
instead of forcing width:100%, so a coordinate eye can sit beside it rather
|
|
3446
|
+
than wrapping onto a visually disconnected second line. */
|
|
3447
|
+
.gemina-verification__dd > .gemina-verification__input,
|
|
3448
|
+
.gemina-verification__cell > .gemina-verification__input {
|
|
3449
|
+
flex: 1 1 8ch;
|
|
3450
|
+
width: auto;
|
|
3451
|
+
min-width: 0;
|
|
3452
|
+
}
|
|
2636
3453
|
.gemina-verification__input--dirty { border-color: var(--gemina-verification-dirty); }
|
|
2637
3454
|
.gemina-verification__input--missed {
|
|
2638
3455
|
border-color: var(--gemina-verification-error);
|
|
@@ -2688,6 +3505,7 @@ var VERIFICATION_CSS = `
|
|
|
2688
3505
|
and list items \u2014 the fragment has no container of its own. */
|
|
2689
3506
|
.gemina-verification__cell {
|
|
2690
3507
|
display: flex;
|
|
3508
|
+
flex-wrap: wrap; /* same reason as __dd: the field error needs its own line */
|
|
2691
3509
|
align-items: center;
|
|
2692
3510
|
gap: 6px;
|
|
2693
3511
|
min-width: 0;
|
|
@@ -2948,6 +3766,157 @@ var VERIFICATION_CSS = `
|
|
|
2948
3766
|
transition: none;
|
|
2949
3767
|
}
|
|
2950
3768
|
}
|
|
3769
|
+
|
|
3770
|
+
/* A label that carries a description. Dotted underline is the long-standing
|
|
3771
|
+
convention for "there is more here", and tabIndex makes it reachable, so the
|
|
3772
|
+
tooltip is not mouse-only. */
|
|
3773
|
+
.gemina-verification__label-described {
|
|
3774
|
+
text-decoration: underline dotted;
|
|
3775
|
+
text-underline-offset: 3px;
|
|
3776
|
+
cursor: help;
|
|
3777
|
+
}
|
|
3778
|
+
.gemina-verification__label-described:focus-visible {
|
|
3779
|
+
outline: 2px solid var(--gemina-verification-accent);
|
|
3780
|
+
outline-offset: 2px;
|
|
3781
|
+
}
|
|
3782
|
+
|
|
3783
|
+
/* Rows worth a second look. Uses the EXISTING confidence tokens \u2014 no new
|
|
3784
|
+
colours \u2014 as a start-edge rule, which is the one edge a reviewer scans down
|
|
3785
|
+
a long table. Logical property, so it lands on the right side under RTL. */
|
|
3786
|
+
.gemina-verification__row--low > td:first-child,
|
|
3787
|
+
.gemina-verification__row--medium > td:first-child {
|
|
3788
|
+
border-inline-start: 3px solid transparent;
|
|
3789
|
+
}
|
|
3790
|
+
.gemina-verification__row--low > td:first-child {
|
|
3791
|
+
border-inline-start-color: var(--gemina-verification-confidence-low);
|
|
3792
|
+
}
|
|
3793
|
+
.gemina-verification__row--medium > td:first-child {
|
|
3794
|
+
border-inline-start-color: var(--gemina-verification-confidence-medium);
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
/* --- Row editing ----------------------------------------------------------
|
|
3798
|
+
Quiet by design: adding and removing lines is a correction, not the primary
|
|
3799
|
+
action, so the controls stay muted until hovered and the accent is left to
|
|
3800
|
+
Submit. */
|
|
3801
|
+
.gemina-verification__row-actions {
|
|
3802
|
+
white-space: nowrap;
|
|
3803
|
+
text-align: end; /* logical \u2014 RTL for free */
|
|
3804
|
+
}
|
|
3805
|
+
.gemina-verification__row-btn {
|
|
3806
|
+
font: inherit;
|
|
3807
|
+
line-height: 1;
|
|
3808
|
+
padding: 2px 7px;
|
|
3809
|
+
margin-inline-start: 4px;
|
|
3810
|
+
border-radius: calc(var(--gemina-verification-radius) - 5px);
|
|
3811
|
+
border: 1px solid var(--gemina-verification-border);
|
|
3812
|
+
background: transparent;
|
|
3813
|
+
color: var(--gemina-verification-muted);
|
|
3814
|
+
cursor: pointer;
|
|
3815
|
+
transition: border-color 120ms ease, color 120ms ease;
|
|
3816
|
+
}
|
|
3817
|
+
.gemina-verification__row-btn:hover {
|
|
3818
|
+
border-color: var(--gemina-verification-accent);
|
|
3819
|
+
color: var(--gemina-verification-fg);
|
|
3820
|
+
}
|
|
3821
|
+
.gemina-verification__table-footer {
|
|
3822
|
+
display: flex;
|
|
3823
|
+
padding: 8px 10px;
|
|
3824
|
+
}
|
|
3825
|
+
.gemina-verification__add-row {
|
|
3826
|
+
font: inherit;
|
|
3827
|
+
font-size: 12px;
|
|
3828
|
+
padding: 4px 10px;
|
|
3829
|
+
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
3830
|
+
border: 1px dashed var(--gemina-verification-border);
|
|
3831
|
+
background: transparent;
|
|
3832
|
+
color: var(--gemina-verification-muted);
|
|
3833
|
+
cursor: pointer;
|
|
3834
|
+
}
|
|
3835
|
+
.gemina-verification__add-row:hover {
|
|
3836
|
+
border-style: solid;
|
|
3837
|
+
border-color: var(--gemina-verification-accent);
|
|
3838
|
+
color: var(--gemina-verification-fg);
|
|
3839
|
+
}
|
|
3840
|
+
|
|
3841
|
+
/* --- Typed controls -------------------------------------------------------
|
|
3842
|
+
A <select> for a closed roster must sit on the same baseline as the text
|
|
3843
|
+
inputs beside it in a table row, so it inherits the input's box entirely and
|
|
3844
|
+
only overrides what a select needs. */
|
|
3845
|
+
.gemina-verification__input:is(select) {
|
|
3846
|
+
cursor: pointer;
|
|
3847
|
+
/* A select's intrinsic width follows its longest option \u2014 the 24-member unit
|
|
3848
|
+
roster would blow out the column. */
|
|
3849
|
+
max-width: 100%;
|
|
3850
|
+
}
|
|
3851
|
+
/* The error border must beat --dirty and --missed: an invalid value is the
|
|
3852
|
+
most urgent thing true about the field, and the reviewer cannot submit
|
|
3853
|
+
until it is fixed. Placed after both for cascade order. */
|
|
3854
|
+
.gemina-verification__input--invalid,
|
|
3855
|
+
.gemina-verification__input--invalid:focus-visible {
|
|
3856
|
+
border-color: var(--gemina-verification-error);
|
|
3857
|
+
}
|
|
3858
|
+
/* Sits under the control it describes. Basis 100% breaks it onto its own line
|
|
3859
|
+
inside the flex row FieldInput renders into, so it never squeezes the
|
|
3860
|
+
input. */
|
|
3861
|
+
.gemina-verification__field-error {
|
|
3862
|
+
flex-basis: 100%;
|
|
3863
|
+
margin-block-start: 4px;
|
|
3864
|
+
color: var(--gemina-verification-error);
|
|
3865
|
+
font-size: 12px;
|
|
3866
|
+
line-height: 1.35;
|
|
3867
|
+
}
|
|
3868
|
+
|
|
3869
|
+
/* Replaces __progress while anything is invalid \u2014 same slot, so the footer
|
|
3870
|
+
never grows a second status line competing for the same attention. */
|
|
3871
|
+
.gemina-verification__attention {
|
|
3872
|
+
color: var(--gemina-verification-error);
|
|
3873
|
+
font-size: 13px;
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
/* --- Tooltip -------------------------------------------------------------
|
|
3877
|
+
Renders in a portal on document.body, inside a div carrying the root's
|
|
3878
|
+
class list \u2014 so these rules and every --gemina-verification-* custom
|
|
3879
|
+
property resolve exactly as they do in the component.
|
|
3880
|
+
|
|
3881
|
+
Quieter than __confirm-dialog on purpose: an annotation, not a decision.
|
|
3882
|
+
Same border and shadow family, one step down in radius (the nested-element
|
|
3883
|
+
convention used by __chip et al), surface rather than bg so it separates
|
|
3884
|
+
from the panel it floats over, and a shorter shadow so it reads as sitting
|
|
3885
|
+
just above the page rather than over a scrim. */
|
|
3886
|
+
.gemina-verification__tip {
|
|
3887
|
+
position: fixed;
|
|
3888
|
+
z-index: 2147483000; /* above the host's own modal \u2014 this is the topmost layer */
|
|
3889
|
+
max-width: 260px; /* ~60 characters: past that a tooltip should be body copy */
|
|
3890
|
+
padding: 8px 10px;
|
|
3891
|
+
background: var(--gemina-verification-surface);
|
|
3892
|
+
color: var(--gemina-verification-fg);
|
|
3893
|
+
border: 1px solid var(--gemina-verification-border);
|
|
3894
|
+
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
3895
|
+
box-shadow: 0 6px 16px rgba(16, 20, 24, 0.18);
|
|
3896
|
+
font-family: var(--gemina-verification-font);
|
|
3897
|
+
font-size: 12px;
|
|
3898
|
+
line-height: 1.45;
|
|
3899
|
+
text-align: start; /* logical \u2014 RTL for free */
|
|
3900
|
+
pointer-events: none; /* never eat the hover that opened it */
|
|
3901
|
+
}
|
|
3902
|
+
/* Structured content: a level heading over a reasons list. The list is the
|
|
3903
|
+
reason this exists at all \u2014 title= could only ever have been one line. */
|
|
3904
|
+
.gemina-verification__tip-title {
|
|
3905
|
+
display: block;
|
|
3906
|
+
font-weight: 600;
|
|
3907
|
+
margin-block-end: 4px;
|
|
3908
|
+
}
|
|
3909
|
+
.gemina-verification__tip-list {
|
|
3910
|
+
margin: 0;
|
|
3911
|
+
padding-inline-start: 16px;
|
|
3912
|
+
}
|
|
3913
|
+
.gemina-verification__tip-list li + li {
|
|
3914
|
+
margin-block-start: 2px;
|
|
3915
|
+
}
|
|
3916
|
+
/* A muted lead-in for single-fact tips ("Was:"), so the VALUE reads first. */
|
|
3917
|
+
.gemina-verification__tip-label {
|
|
3918
|
+
color: var(--gemina-verification-muted);
|
|
3919
|
+
}
|
|
2951
3920
|
`;
|
|
2952
3921
|
var STYLE_ATTR2 = "data-gemina-verification";
|
|
2953
3922
|
function ensureVerificationStylesInjected() {
|
|
@@ -2964,7 +3933,7 @@ function ensureVerificationStylesInjected() {
|
|
|
2964
3933
|
}
|
|
2965
3934
|
|
|
2966
3935
|
// src/verification/index.tsx
|
|
2967
|
-
var
|
|
3936
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2968
3937
|
var HEBREW_RE2 = /[\u0590-\u05FF]/;
|
|
2969
3938
|
var STACKED_BREAKPOINT = 860;
|
|
2970
3939
|
var IMAGE_REFRESH_THROTTLE_MS = 6e4;
|
|
@@ -2977,11 +3946,23 @@ var PURGED_TEXT = "Document no longer available (retention policy).";
|
|
|
2977
3946
|
var NOT_COMPLETED_TEXT = "This extraction did not complete, so there is nothing to verify.";
|
|
2978
3947
|
var VERIFICATION_UNAVAILABLE_TEXT = "Verification isn't available for this extraction.";
|
|
2979
3948
|
var ALREADY_VALIDATED_TEXT = "Already verified \u2014 showing the original extraction.";
|
|
2980
|
-
var CONFIRM_TEXT = "Submit
|
|
3949
|
+
var CONFIRM_TEXT = "Submit these values? This is final \u2014 they can be submitted once and can't be changed.";
|
|
2981
3950
|
var SUBMITTING_TEXT = "Submitting\u2026";
|
|
2982
3951
|
var SUBMIT_FAILED_TEXT = "Submission failed \u2014 your corrections are still here.";
|
|
2983
|
-
var DONE_TITLE_TEXT = "
|
|
3952
|
+
var DONE_TITLE_TEXT = "Submitted";
|
|
2984
3953
|
var NO_EDITS = /* @__PURE__ */ new Map();
|
|
3954
|
+
var NO_ROW_PLANS = /* @__PURE__ */ new Map();
|
|
3955
|
+
var NO_PLANNED_TABLES = /* @__PURE__ */ new Map();
|
|
3956
|
+
function seedRowPlans(tables, values) {
|
|
3957
|
+
if (tables.length === 0) {
|
|
3958
|
+
return NO_ROW_PLANS;
|
|
3959
|
+
}
|
|
3960
|
+
const plans = /* @__PURE__ */ new Map();
|
|
3961
|
+
for (const table of tables) {
|
|
3962
|
+
plans.set(table.pointer, initialRowPlan(countRowsAt(values, table.pointer), table.pointer));
|
|
3963
|
+
}
|
|
3964
|
+
return plans;
|
|
3965
|
+
}
|
|
2985
3966
|
var ALERT_REASONS = /* @__PURE__ */ new Set([
|
|
2986
3967
|
"session-expired",
|
|
2987
3968
|
"not-available",
|
|
@@ -2998,43 +3979,44 @@ function GeminaVerification(props) {
|
|
|
2998
3979
|
onError,
|
|
2999
3980
|
className
|
|
3000
3981
|
} = props;
|
|
3001
|
-
const [phase, setPhase] = (0,
|
|
3002
|
-
const [alreadyValidated, setAlreadyValidated] = (0,
|
|
3003
|
-
const [loaded, setLoaded] = (0,
|
|
3004
|
-
const [
|
|
3005
|
-
const [
|
|
3006
|
-
const [
|
|
3007
|
-
const [
|
|
3008
|
-
const
|
|
3009
|
-
const
|
|
3010
|
-
const
|
|
3011
|
-
const
|
|
3012
|
-
const
|
|
3982
|
+
const [phase, setPhase] = (0, import_react5.useState)({ name: "loading" });
|
|
3983
|
+
const [alreadyValidated, setAlreadyValidated] = (0, import_react5.useState)(false);
|
|
3984
|
+
const [loaded, setLoaded] = (0, import_react5.useState)(null);
|
|
3985
|
+
const [rowPlans, setRowPlans] = (0, import_react5.useState)(NO_ROW_PLANS);
|
|
3986
|
+
const [edits, setEdits] = (0, import_react5.useState)(NO_EDITS);
|
|
3987
|
+
const [imageUrl, setImageUrl] = (0, import_react5.useState)(null);
|
|
3988
|
+
const [flashRects, setFlashRects] = (0, import_react5.useState)(null);
|
|
3989
|
+
const [stacked, setStacked] = (0, import_react5.useState)(false);
|
|
3990
|
+
const rootRef = (0, import_react5.useRef)(null);
|
|
3991
|
+
const mountedRef = (0, import_react5.useRef)(false);
|
|
3992
|
+
const loadSeqRef = (0, import_react5.useRef)(0);
|
|
3993
|
+
const lastImageRefreshRef = (0, import_react5.useRef)(0);
|
|
3994
|
+
const onErrorRef = (0, import_react5.useRef)(onError);
|
|
3013
3995
|
onErrorRef.current = onError;
|
|
3014
|
-
const onCompleteRef = (0,
|
|
3996
|
+
const onCompleteRef = (0, import_react5.useRef)(onComplete);
|
|
3015
3997
|
onCompleteRef.current = onComplete;
|
|
3016
|
-
const completedRef = (0,
|
|
3017
|
-
const submitInFlightRef = (0,
|
|
3018
|
-
const restoreFocusRef = (0,
|
|
3019
|
-
const submitButtonRef = (0,
|
|
3020
|
-
const confirmButtonRef = (0,
|
|
3021
|
-
const cancelButtonRef = (0,
|
|
3022
|
-
const retrySubmitButtonRef = (0,
|
|
3023
|
-
const doneStateRef = (0,
|
|
3024
|
-
const enterUnavailable = (0,
|
|
3998
|
+
const completedRef = (0, import_react5.useRef)(false);
|
|
3999
|
+
const submitInFlightRef = (0, import_react5.useRef)(false);
|
|
4000
|
+
const restoreFocusRef = (0, import_react5.useRef)(false);
|
|
4001
|
+
const submitButtonRef = (0, import_react5.useRef)(null);
|
|
4002
|
+
const confirmButtonRef = (0, import_react5.useRef)(null);
|
|
4003
|
+
const cancelButtonRef = (0, import_react5.useRef)(null);
|
|
4004
|
+
const retrySubmitButtonRef = (0, import_react5.useRef)(null);
|
|
4005
|
+
const doneStateRef = (0, import_react5.useRef)(null);
|
|
4006
|
+
const enterUnavailable = (0, import_react5.useCallback)(
|
|
3025
4007
|
(reason, message, canRetry, detail) => {
|
|
3026
4008
|
setPhase({ name: "unavailable", reason, message, canRetry });
|
|
3027
4009
|
onErrorRef.current?.(reason, detail);
|
|
3028
4010
|
},
|
|
3029
4011
|
[]
|
|
3030
4012
|
);
|
|
3031
|
-
const fetchOnce = (0,
|
|
4013
|
+
const fetchOnce = (0, import_react5.useCallback)(async () => {
|
|
3032
4014
|
const token = await tokenManager.getToken();
|
|
3033
4015
|
return import_sdk2.GeminaClient.withSessionToken(token, baseUrl).documents.getDocumentExtraction({
|
|
3034
4016
|
documentExtractionId: extractionId
|
|
3035
4017
|
});
|
|
3036
4018
|
}, [tokenManager, baseUrl, extractionId]);
|
|
3037
|
-
const fetchWithRetry = (0,
|
|
4019
|
+
const fetchWithRetry = (0, import_react5.useCallback)(async () => {
|
|
3038
4020
|
try {
|
|
3039
4021
|
return await fetchOnce();
|
|
3040
4022
|
} catch (error) {
|
|
@@ -3045,7 +4027,7 @@ function GeminaVerification(props) {
|
|
|
3045
4027
|
return await fetchOnce();
|
|
3046
4028
|
}
|
|
3047
4029
|
}, [fetchOnce, tokenManager]);
|
|
3048
|
-
const load = (0,
|
|
4030
|
+
const load = (0, import_react5.useCallback)(async () => {
|
|
3049
4031
|
const seq = ++loadSeqRef.current;
|
|
3050
4032
|
const live = () => mountedRef.current && loadSeqRef.current === seq;
|
|
3051
4033
|
setPhase({ name: "loading" });
|
|
@@ -3076,9 +4058,12 @@ function GeminaVerification(props) {
|
|
|
3076
4058
|
const schema = view.meta.validationFeedback?.validationSchema;
|
|
3077
4059
|
setLoaded({
|
|
3078
4060
|
values: view.values,
|
|
3079
|
-
schema: Array.isArray(schema) ? schema : []
|
|
4061
|
+
schema: Array.isArray(schema) ? schema : [],
|
|
4062
|
+
fields: readDescriptors(view.meta.validationFeedback?.validationFields),
|
|
4063
|
+
rowMutableTables: readRowMutableTables(view.meta.validationFeedback?.rowMutableTables)
|
|
3080
4064
|
});
|
|
3081
4065
|
setEdits(NO_EDITS);
|
|
4066
|
+
setRowPlans(seedRowPlans(readRowMutableTables(view.meta.validationFeedback?.rowMutableTables), view.values));
|
|
3082
4067
|
const url = view.document.imageUrl;
|
|
3083
4068
|
setImageUrl(typeof url === "string" && url.length > 0 ? url : null);
|
|
3084
4069
|
setAlreadyValidated(validated);
|
|
@@ -3096,7 +4081,7 @@ function GeminaVerification(props) {
|
|
|
3096
4081
|
enterReview(false);
|
|
3097
4082
|
}
|
|
3098
4083
|
}, [fetchWithRetry, enterUnavailable]);
|
|
3099
|
-
(0,
|
|
4084
|
+
(0, import_react5.useEffect)(() => {
|
|
3100
4085
|
mountedRef.current = true;
|
|
3101
4086
|
ensureVerificationStylesInjected();
|
|
3102
4087
|
void load();
|
|
@@ -3104,7 +4089,7 @@ function GeminaVerification(props) {
|
|
|
3104
4089
|
mountedRef.current = false;
|
|
3105
4090
|
};
|
|
3106
4091
|
}, [load]);
|
|
3107
|
-
(0,
|
|
4092
|
+
(0, import_react5.useEffect)(() => {
|
|
3108
4093
|
const el = rootRef.current;
|
|
3109
4094
|
if (el === null) {
|
|
3110
4095
|
return;
|
|
@@ -3125,10 +4110,20 @@ function GeminaVerification(props) {
|
|
|
3125
4110
|
observer.observe(el);
|
|
3126
4111
|
return () => observer.disconnect();
|
|
3127
4112
|
}, []);
|
|
3128
|
-
const classified = (0,
|
|
3129
|
-
const bindings = (0,
|
|
3130
|
-
|
|
3131
|
-
|
|
4113
|
+
const classified = (0, import_react5.useMemo)(() => classifyData(loaded?.values), [loaded]);
|
|
4114
|
+
const bindings = (0, import_react5.useMemo)(
|
|
4115
|
+
() => buildBindings(loaded?.schema ?? [], loaded?.values, loaded?.fields),
|
|
4116
|
+
[loaded]
|
|
4117
|
+
);
|
|
4118
|
+
const bindingIndex = (0, import_react5.useMemo)(() => indexBindingsByFieldPointer(bindings), [bindings]);
|
|
4119
|
+
const bindingsByRawKey = (0, import_react5.useMemo)(() => {
|
|
4120
|
+
const map = /* @__PURE__ */ new Map();
|
|
4121
|
+
for (const binding of bindings) {
|
|
4122
|
+
map.set(binding.key.raw, binding);
|
|
4123
|
+
}
|
|
4124
|
+
return map;
|
|
4125
|
+
}, [bindings]);
|
|
4126
|
+
const unmatched = (0, import_react5.useMemo)(() => {
|
|
3132
4127
|
const rendered = /* @__PURE__ */ new Set();
|
|
3133
4128
|
for (const field of classified.headers) {
|
|
3134
4129
|
rendered.add(field.pointer);
|
|
@@ -3156,7 +4151,7 @@ function GeminaVerification(props) {
|
|
|
3156
4151
|
}
|
|
3157
4152
|
return bindings.filter((binding) => !rendered.has(binding.fieldPointer));
|
|
3158
4153
|
}, [classified, bindings]);
|
|
3159
|
-
const overlayRects = (0,
|
|
4154
|
+
const overlayRects = (0, import_react5.useMemo)(() => {
|
|
3160
4155
|
const rects = [];
|
|
3161
4156
|
for (const field of classified.headers) {
|
|
3162
4157
|
if (field.coordinates) {
|
|
@@ -3190,48 +4185,87 @@ function GeminaVerification(props) {
|
|
|
3190
4185
|
}
|
|
3191
4186
|
return rects.length > 0 ? rects : void 0;
|
|
3192
4187
|
}, [classified]);
|
|
3193
|
-
const hasHebrewContent = (0,
|
|
4188
|
+
const hasHebrewContent = (0, import_react5.useMemo)(
|
|
3194
4189
|
() => bindings.some((binding) => HEBREW_RE2.test(toInputString(binding.extracted))),
|
|
3195
4190
|
[bindings]
|
|
3196
4191
|
);
|
|
3197
4192
|
const effectiveDir = dir === "auto" ? hasHebrewContent ? "rtl" : "ltr" : dir;
|
|
3198
|
-
const
|
|
3199
|
-
const
|
|
3200
|
-
for (const binding of bindings) {
|
|
3201
|
-
map.set(binding.key.raw, binding);
|
|
3202
|
-
}
|
|
3203
|
-
return map;
|
|
3204
|
-
}, [bindings]);
|
|
3205
|
-
const bindingsByRawKeyRef = (0, import_react4.useRef)(bindingsByRawKey);
|
|
3206
|
-
bindingsByRawKeyRef.current = bindingsByRawKey;
|
|
3207
|
-
const handleEdit = (0, import_react4.useCallback)((rawKey, value) => {
|
|
3208
|
-
const binding = bindingsByRawKeyRef.current.get(rawKey);
|
|
3209
|
-
const pristine = binding !== void 0 && value === toInputString(binding.extracted);
|
|
4193
|
+
const handleEdit = (0, import_react5.useCallback)((editKey, value, binding) => {
|
|
4194
|
+
const pristine = value === toInputString(binding.extracted);
|
|
3210
4195
|
setEdits((prev) => {
|
|
3211
4196
|
if (pristine) {
|
|
3212
|
-
if (!prev.has(
|
|
4197
|
+
if (!prev.has(editKey)) {
|
|
3213
4198
|
return prev;
|
|
3214
4199
|
}
|
|
3215
4200
|
const next2 = new Map(prev);
|
|
3216
|
-
next2.delete(
|
|
4201
|
+
next2.delete(editKey);
|
|
3217
4202
|
return next2;
|
|
3218
4203
|
}
|
|
3219
|
-
if (prev.get(
|
|
4204
|
+
if (prev.get(editKey) === value) {
|
|
3220
4205
|
return prev;
|
|
3221
4206
|
}
|
|
3222
4207
|
const next = new Map(prev);
|
|
3223
|
-
next.set(
|
|
4208
|
+
next.set(editKey, value);
|
|
3224
4209
|
return next;
|
|
3225
4210
|
});
|
|
3226
4211
|
}, []);
|
|
3227
|
-
const
|
|
3228
|
-
|
|
4212
|
+
const plannedTables = (0, import_react5.useMemo)(() => {
|
|
4213
|
+
const tables = loaded?.rowMutableTables ?? [];
|
|
4214
|
+
if (tables.length === 0) {
|
|
4215
|
+
return NO_PLANNED_TABLES;
|
|
4216
|
+
}
|
|
4217
|
+
const out = /* @__PURE__ */ new Map();
|
|
4218
|
+
for (const table of tables) {
|
|
4219
|
+
const plan = rowPlans.get(table.pointer);
|
|
4220
|
+
if (plan === void 0) {
|
|
4221
|
+
continue;
|
|
4222
|
+
}
|
|
4223
|
+
const classifiedTable = classified.tables.find(
|
|
4224
|
+
(candidate) => matchesTablePointer(table.pointer, candidate.pointer)
|
|
4225
|
+
);
|
|
4226
|
+
const columns = displayColumns(table, classifiedTable?.columns ?? []);
|
|
4227
|
+
out.set(table.pointer, planTableCells(table, plan, columns, bindingsByRawKey));
|
|
4228
|
+
}
|
|
4229
|
+
return out;
|
|
4230
|
+
}, [loaded, rowPlans, classified, bindingsByRawKey]);
|
|
4231
|
+
const cellViews = (0, import_react5.useMemo)(
|
|
4232
|
+
() => collectCellViews(bindings, plannedTables),
|
|
4233
|
+
[bindings, plannedTables]
|
|
4234
|
+
);
|
|
4235
|
+
const submissionTables = (0, import_react5.useMemo)(
|
|
4236
|
+
() => pruneEmptyAddedRows(plannedTables, edits),
|
|
4237
|
+
[plannedTables, edits]
|
|
4238
|
+
);
|
|
4239
|
+
const submissionCells = (0, import_react5.useMemo)(
|
|
4240
|
+
() => collectCellViews(bindings, submissionTables),
|
|
4241
|
+
[bindings, submissionTables]
|
|
4242
|
+
);
|
|
4243
|
+
const rowSources = (0, import_react5.useMemo)(() => {
|
|
4244
|
+
const entries = [];
|
|
4245
|
+
for (const table of loaded?.rowMutableTables ?? []) {
|
|
4246
|
+
const rows = submissionTables.get(table.pointer);
|
|
4247
|
+
if (rows === void 0) {
|
|
4248
|
+
continue;
|
|
4249
|
+
}
|
|
4250
|
+
const plan = rows.map((row) => row.entry);
|
|
4251
|
+
if (isIdentityPlan(plan, countRowsAt(loaded?.values, table.pointer))) {
|
|
4252
|
+
continue;
|
|
4253
|
+
}
|
|
4254
|
+
entries.push({ table: table.pointer, sources: rowSourcesOf(plan) });
|
|
4255
|
+
}
|
|
4256
|
+
return entries;
|
|
4257
|
+
}, [loaded, submissionTables]);
|
|
4258
|
+
const submission = (0, import_react5.useMemo)(
|
|
4259
|
+
() => composeSubmission(bindings, edits, { cells: submissionCells, rowSources }),
|
|
4260
|
+
[bindings, edits, submissionCells, rowSources]
|
|
4261
|
+
);
|
|
4262
|
+
const handleFlash = (0, import_react5.useCallback)((rects) => {
|
|
3229
4263
|
setFlashRects(rects.map((rect) => ({ points: rect.points })));
|
|
3230
4264
|
}, []);
|
|
3231
|
-
const handleFlashComplete = (0,
|
|
4265
|
+
const handleFlashComplete = (0, import_react5.useCallback)(() => {
|
|
3232
4266
|
setFlashRects(null);
|
|
3233
4267
|
}, []);
|
|
3234
|
-
const handleImageExpired = (0,
|
|
4268
|
+
const handleImageExpired = (0, import_react5.useCallback)(() => {
|
|
3235
4269
|
const now = Date.now();
|
|
3236
4270
|
if (now - lastImageRefreshRef.current < IMAGE_REFRESH_THROTTLE_MS) {
|
|
3237
4271
|
return;
|
|
@@ -3249,10 +4283,52 @@ function GeminaVerification(props) {
|
|
|
3249
4283
|
}).catch(() => {
|
|
3250
4284
|
});
|
|
3251
4285
|
}, [fetchWithRetry]);
|
|
3252
|
-
const handleRetry = (0,
|
|
4286
|
+
const handleRetry = (0, import_react5.useCallback)(() => {
|
|
3253
4287
|
void load();
|
|
3254
4288
|
}, [load]);
|
|
3255
|
-
const
|
|
4289
|
+
const handleAddRow = (0, import_react5.useCallback)((tablePointer, afterPosition) => {
|
|
4290
|
+
const id = nextAddedRowId(tablePointer);
|
|
4291
|
+
setRowPlans((prev) => {
|
|
4292
|
+
const plan = prev.get(tablePointer);
|
|
4293
|
+
if (plan === void 0) {
|
|
4294
|
+
return prev;
|
|
4295
|
+
}
|
|
4296
|
+
const next = new Map(prev);
|
|
4297
|
+
next.set(tablePointer, insertRowAfter(plan, afterPosition, id));
|
|
4298
|
+
return next;
|
|
4299
|
+
});
|
|
4300
|
+
}, []);
|
|
4301
|
+
const handleRemoveRow = (0, import_react5.useCallback)((tablePointer, position) => {
|
|
4302
|
+
setRowPlans((prev) => {
|
|
4303
|
+
const plan = prev.get(tablePointer);
|
|
4304
|
+
if (plan === void 0) {
|
|
4305
|
+
return prev;
|
|
4306
|
+
}
|
|
4307
|
+
const nextPlan = removeRow(plan, position);
|
|
4308
|
+
if (nextPlan === plan) {
|
|
4309
|
+
return prev;
|
|
4310
|
+
}
|
|
4311
|
+
const next = new Map(prev);
|
|
4312
|
+
next.set(tablePointer, nextPlan);
|
|
4313
|
+
return next;
|
|
4314
|
+
});
|
|
4315
|
+
}, []);
|
|
4316
|
+
const pairErrors = (0, import_react5.useMemo)(() => unitSizePairErrors(cellViews, edits), [cellViews, edits]);
|
|
4317
|
+
const invalidCount = (0, import_react5.useMemo)(() => {
|
|
4318
|
+
const rowLevel = pairErrors.size;
|
|
4319
|
+
if (edits.size === 0) {
|
|
4320
|
+
return rowLevel;
|
|
4321
|
+
}
|
|
4322
|
+
const byEditKey = new Map(cellViews.map((view) => [view.editKey, view.binding]));
|
|
4323
|
+
let count = 0;
|
|
4324
|
+
for (const [editKey, value] of edits) {
|
|
4325
|
+
if (!pairErrors.has(editKey) && validateInput(value, byEditKey.get(editKey)?.field) !== null) {
|
|
4326
|
+
count += 1;
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4329
|
+
return count + rowLevel;
|
|
4330
|
+
}, [edits, cellViews, pairErrors]);
|
|
4331
|
+
const doSubmit = (0, import_react5.useCallback)(async () => {
|
|
3256
4332
|
if (submitInFlightRef.current) {
|
|
3257
4333
|
return;
|
|
3258
4334
|
}
|
|
@@ -3265,7 +4341,13 @@ function GeminaVerification(props) {
|
|
|
3265
4341
|
const token = await tokenManager.getToken();
|
|
3266
4342
|
return import_sdk2.GeminaClient.withSessionToken(token, baseUrl).documents.validateDocumentExtraction({
|
|
3267
4343
|
targetDocumentExtractionId: extractionId,
|
|
3268
|
-
|
|
4344
|
+
// Conditional spread, matching the house pattern: without a row edit
|
|
4345
|
+
// the request body is byte-identical to what it was before this
|
|
4346
|
+
// feature, so nothing changes for the overwhelmingly common path.
|
|
4347
|
+
extractionValidationInDTO: {
|
|
4348
|
+
data: body.data,
|
|
4349
|
+
...body.rowSources.length > 0 ? { rowSources: body.rowSources } : {}
|
|
4350
|
+
}
|
|
3269
4351
|
});
|
|
3270
4352
|
};
|
|
3271
4353
|
try {
|
|
@@ -3313,20 +4395,20 @@ function GeminaVerification(props) {
|
|
|
3313
4395
|
submitInFlightRef.current = false;
|
|
3314
4396
|
}
|
|
3315
4397
|
}, [submission, tokenManager, baseUrl, extractionId, load]);
|
|
3316
|
-
const handleSubmitClick = (0,
|
|
4398
|
+
const handleSubmitClick = (0, import_react5.useCallback)(() => {
|
|
3317
4399
|
setPhase({ name: "confirming" });
|
|
3318
4400
|
}, []);
|
|
3319
|
-
const handleConfirm = (0,
|
|
4401
|
+
const handleConfirm = (0, import_react5.useCallback)(() => {
|
|
3320
4402
|
void doSubmit();
|
|
3321
4403
|
}, [doSubmit]);
|
|
3322
|
-
const handleCancelConfirm = (0,
|
|
4404
|
+
const handleCancelConfirm = (0, import_react5.useCallback)(() => {
|
|
3323
4405
|
restoreFocusRef.current = true;
|
|
3324
4406
|
setPhase({ name: "review" });
|
|
3325
4407
|
}, []);
|
|
3326
|
-
const handleRetrySubmit = (0,
|
|
4408
|
+
const handleRetrySubmit = (0, import_react5.useCallback)(() => {
|
|
3327
4409
|
void doSubmit();
|
|
3328
4410
|
}, [doSubmit]);
|
|
3329
|
-
const handleConfirmKeyDown = (0,
|
|
4411
|
+
const handleConfirmKeyDown = (0, import_react5.useCallback)(
|
|
3330
4412
|
(event) => {
|
|
3331
4413
|
if (phase.name !== "confirming") {
|
|
3332
4414
|
return;
|
|
@@ -3357,7 +4439,7 @@ function GeminaVerification(props) {
|
|
|
3357
4439
|
},
|
|
3358
4440
|
[phase.name, handleCancelConfirm]
|
|
3359
4441
|
);
|
|
3360
|
-
(0,
|
|
4442
|
+
(0, import_react5.useEffect)(() => {
|
|
3361
4443
|
if (phase.name === "confirming") {
|
|
3362
4444
|
confirmButtonRef.current?.focus();
|
|
3363
4445
|
} else if (phase.name === "review" && restoreFocusRef.current) {
|
|
@@ -3376,13 +4458,13 @@ function GeminaVerification(props) {
|
|
|
3376
4458
|
stacked ? "gemina-verification--stacked" : "",
|
|
3377
4459
|
className ?? ""
|
|
3378
4460
|
].filter((part) => part.length > 0).join(" ");
|
|
3379
|
-
const dialogTextId = (0,
|
|
4461
|
+
const dialogTextId = (0, import_react5.useId)();
|
|
3380
4462
|
const renderReview = (reviewPhase) => {
|
|
3381
4463
|
const overlayUp = reviewPhase.name === "confirming" || reviewPhase.name === "submitting";
|
|
3382
|
-
return /* @__PURE__ */ (0,
|
|
3383
|
-
alreadyValidated && /* @__PURE__ */ (0,
|
|
3384
|
-
/* @__PURE__ */ (0,
|
|
3385
|
-
imageUrl !== null && /* @__PURE__ */ (0,
|
|
4464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
4465
|
+
alreadyValidated && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "gemina-verification__banner", children: ALREADY_VALIDATED_TEXT }),
|
|
4466
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "gemina-verification__panes", children: [
|
|
4467
|
+
imageUrl !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3386
4468
|
VerificationViewer,
|
|
3387
4469
|
{
|
|
3388
4470
|
src: imageUrl,
|
|
@@ -3392,7 +4474,7 @@ function GeminaVerification(props) {
|
|
|
3392
4474
|
onImageExpired: handleImageExpired
|
|
3393
4475
|
}
|
|
3394
4476
|
),
|
|
3395
|
-
/* @__PURE__ */ (0,
|
|
4477
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3396
4478
|
VerificationForm,
|
|
3397
4479
|
{
|
|
3398
4480
|
classified,
|
|
@@ -3401,18 +4483,23 @@ function GeminaVerification(props) {
|
|
|
3401
4483
|
edits,
|
|
3402
4484
|
onEdit: handleEdit,
|
|
3403
4485
|
readOnly: alreadyValidated,
|
|
3404
|
-
onFlash: handleFlash
|
|
4486
|
+
onFlash: handleFlash,
|
|
4487
|
+
pairErrors,
|
|
4488
|
+
rowMutableTables: loaded?.rowMutableTables,
|
|
4489
|
+
plannedTables,
|
|
4490
|
+
onAddRow: handleAddRow,
|
|
4491
|
+
onRemoveRow: handleRemoveRow
|
|
3405
4492
|
}
|
|
3406
4493
|
)
|
|
3407
4494
|
] }),
|
|
3408
|
-
reviewPhase.name === "submit-error" && /* @__PURE__ */ (0,
|
|
4495
|
+
reviewPhase.name === "submit-error" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3409
4496
|
"div",
|
|
3410
4497
|
{
|
|
3411
4498
|
className: "gemina-verification__banner gemina-verification__banner--error gemina-verification__submit-error",
|
|
3412
4499
|
role: "alert",
|
|
3413
4500
|
children: [
|
|
3414
|
-
/* @__PURE__ */ (0,
|
|
3415
|
-
/* @__PURE__ */ (0,
|
|
4501
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: reviewPhase.message }),
|
|
4502
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3416
4503
|
"button",
|
|
3417
4504
|
{
|
|
3418
4505
|
type: "button",
|
|
@@ -3425,21 +4512,21 @@ function GeminaVerification(props) {
|
|
|
3425
4512
|
]
|
|
3426
4513
|
}
|
|
3427
4514
|
),
|
|
3428
|
-
/* @__PURE__ */ (0,
|
|
3429
|
-
!alreadyValidated && /* @__PURE__ */ (0,
|
|
3430
|
-
/* @__PURE__ */ (0,
|
|
4515
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "gemina-verification__footer", children: [
|
|
4516
|
+
!alreadyValidated && (invalidCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "gemina-verification__attention", "aria-live": "polite", children: invalidCount === 1 ? "1 field needs attention" : `${invalidCount} fields need attention` }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "gemina-verification__progress", "aria-live": "polite", children: `${submission.confirmed} confirmed \xB7 ${submission.corrected} corrected` })),
|
|
4517
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3431
4518
|
"button",
|
|
3432
4519
|
{
|
|
3433
4520
|
type: "button",
|
|
3434
4521
|
ref: submitButtonRef,
|
|
3435
4522
|
className: "gemina-verification__submit",
|
|
3436
|
-
disabled: alreadyValidated || reviewPhase.name !== "review",
|
|
4523
|
+
disabled: alreadyValidated || reviewPhase.name !== "review" || invalidCount > 0,
|
|
3437
4524
|
onClick: handleSubmitClick,
|
|
3438
|
-
children: "Submit
|
|
4525
|
+
children: "Submit"
|
|
3439
4526
|
}
|
|
3440
4527
|
)
|
|
3441
4528
|
] }),
|
|
3442
|
-
overlayUp && /* @__PURE__ */ (0,
|
|
4529
|
+
overlayUp && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3443
4530
|
"div",
|
|
3444
4531
|
{
|
|
3445
4532
|
className: "gemina-verification__confirm",
|
|
@@ -3449,7 +4536,7 @@ function GeminaVerification(props) {
|
|
|
3449
4536
|
event.preventDefault();
|
|
3450
4537
|
}
|
|
3451
4538
|
},
|
|
3452
|
-
children: /* @__PURE__ */ (0,
|
|
4539
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3453
4540
|
"div",
|
|
3454
4541
|
{
|
|
3455
4542
|
className: "gemina-verification__confirm-dialog",
|
|
@@ -3457,9 +4544,9 @@ function GeminaVerification(props) {
|
|
|
3457
4544
|
"aria-modal": "true",
|
|
3458
4545
|
"aria-labelledby": dialogTextId,
|
|
3459
4546
|
children: [
|
|
3460
|
-
/* @__PURE__ */ (0,
|
|
3461
|
-
/* @__PURE__ */ (0,
|
|
3462
|
-
/* @__PURE__ */ (0,
|
|
4547
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { id: dialogTextId, className: "gemina-verification__confirm-text", children: reviewPhase.name === "submitting" ? SUBMITTING_TEXT : CONFIRM_TEXT }),
|
|
4548
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "gemina-verification__confirm-actions", children: [
|
|
4549
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3463
4550
|
"button",
|
|
3464
4551
|
{
|
|
3465
4552
|
type: "button",
|
|
@@ -3470,7 +4557,7 @@ function GeminaVerification(props) {
|
|
|
3470
4557
|
children: "Cancel"
|
|
3471
4558
|
}
|
|
3472
4559
|
),
|
|
3473
|
-
/* @__PURE__ */ (0,
|
|
4560
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3474
4561
|
"button",
|
|
3475
4562
|
{
|
|
3476
4563
|
type: "button",
|
|
@@ -3492,16 +4579,16 @@ function GeminaVerification(props) {
|
|
|
3492
4579
|
const content = (() => {
|
|
3493
4580
|
switch (phase.name) {
|
|
3494
4581
|
case "loading":
|
|
3495
|
-
return /* @__PURE__ */ (0,
|
|
4582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "gemina-verification__state", role: "status", children: LOADING_TEXT });
|
|
3496
4583
|
case "unavailable":
|
|
3497
|
-
return /* @__PURE__ */ (0,
|
|
4584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3498
4585
|
"div",
|
|
3499
4586
|
{
|
|
3500
4587
|
className: "gemina-verification__state",
|
|
3501
4588
|
role: ALERT_REASONS.has(phase.reason) ? "alert" : "status",
|
|
3502
4589
|
children: [
|
|
3503
|
-
/* @__PURE__ */ (0,
|
|
3504
|
-
phase.canRetry && /* @__PURE__ */ (0,
|
|
4590
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: phase.message }),
|
|
4591
|
+
phase.canRetry && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "gemina-verification__retry", onClick: handleRetry, children: "Retry" })
|
|
3505
4592
|
]
|
|
3506
4593
|
}
|
|
3507
4594
|
);
|
|
@@ -3511,7 +4598,7 @@ function GeminaVerification(props) {
|
|
|
3511
4598
|
case "submit-error":
|
|
3512
4599
|
return renderReview(phase);
|
|
3513
4600
|
case "done":
|
|
3514
|
-
return /* @__PURE__ */ (0,
|
|
4601
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3515
4602
|
"div",
|
|
3516
4603
|
{
|
|
3517
4604
|
ref: doneStateRef,
|
|
@@ -3519,7 +4606,7 @@ function GeminaVerification(props) {
|
|
|
3519
4606
|
className: "gemina-verification__state gemina-verification__state--done",
|
|
3520
4607
|
role: "status",
|
|
3521
4608
|
children: [
|
|
3522
|
-
/* @__PURE__ */ (0,
|
|
4609
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "gemina-verification__done-check", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3523
4610
|
"path",
|
|
3524
4611
|
{
|
|
3525
4612
|
d: "M4 10.5l4 4 8-9",
|
|
@@ -3529,14 +4616,14 @@ function GeminaVerification(props) {
|
|
|
3529
4616
|
strokeLinejoin: "round"
|
|
3530
4617
|
}
|
|
3531
4618
|
) }) }),
|
|
3532
|
-
/* @__PURE__ */ (0,
|
|
3533
|
-
/* @__PURE__ */ (0,
|
|
4619
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "gemina-verification__done-title", children: DONE_TITLE_TEXT }),
|
|
4620
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "gemina-verification__progress", children: `${phase.confirmed} confirmed \xB7 ${phase.corrected} corrected` })
|
|
3534
4621
|
]
|
|
3535
4622
|
}
|
|
3536
4623
|
);
|
|
3537
4624
|
}
|
|
3538
4625
|
})();
|
|
3539
|
-
return /* @__PURE__ */ (0,
|
|
4626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: rootRef, className: rootClassName, dir: effectiveDir, children: content });
|
|
3540
4627
|
}
|
|
3541
4628
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3542
4629
|
0 && (module.exports = {
|