@gemina/elements 0.5.4 → 0.7.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/README.md +137 -11
- package/dist/chat.cjs +27 -21
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.js +2 -1
- package/dist/chunk-CDGDP2C3.js +2680 -0
- package/dist/chunk-CDGDP2C3.js.map +1 -0
- package/dist/chunk-MQMT7SEJ.js +56 -0
- package/dist/chunk-MQMT7SEJ.js.map +1 -0
- package/dist/{chunk-I6CB46UZ.js → chunk-PB3PXDYZ.js} +11 -50
- package/dist/chunk-PB3PXDYZ.js.map +1 -0
- package/dist/index.cjs +2709 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +8 -2
- package/dist/verification.cjs +2757 -0
- package/dist/verification.cjs.map +1 -0
- package/dist/verification.d.cts +68 -0
- package/dist/verification.d.ts +68 -0
- package/dist/verification.js +8 -0
- package/dist/verification.js.map +1 -0
- package/package.json +8 -3
- package/dist/chunk-I6CB46UZ.js.map +0 -1
|
@@ -0,0 +1,2757 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/verification/index.tsx
|
|
31
|
+
var verification_exports = {};
|
|
32
|
+
__export(verification_exports, {
|
|
33
|
+
GeminaVerification: () => GeminaVerification
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(verification_exports);
|
|
36
|
+
var import_react3 = require("react");
|
|
37
|
+
var import_sdk = require("@gemina/sdk");
|
|
38
|
+
|
|
39
|
+
// src/internal/response-like.ts
|
|
40
|
+
function getResponseLike(error) {
|
|
41
|
+
if (error !== null && typeof error === "object" && "response" in error) {
|
|
42
|
+
const response = error.response;
|
|
43
|
+
if (response !== null && typeof response === "object") {
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
function httpStatus(error) {
|
|
50
|
+
const status = getResponseLike(error)?.status;
|
|
51
|
+
return typeof status === "number" ? status : void 0;
|
|
52
|
+
}
|
|
53
|
+
async function readErrorEnvelope(error) {
|
|
54
|
+
const response = getResponseLike(error);
|
|
55
|
+
const info = {
|
|
56
|
+
status: typeof response?.status === "number" ? response.status : void 0,
|
|
57
|
+
errorCode: void 0,
|
|
58
|
+
description: void 0
|
|
59
|
+
};
|
|
60
|
+
if (response === void 0) {
|
|
61
|
+
return info;
|
|
62
|
+
}
|
|
63
|
+
let body;
|
|
64
|
+
try {
|
|
65
|
+
const source = typeof response.clone === "function" ? response.clone() : response;
|
|
66
|
+
body = typeof source.json === "function" ? await source.json() : void 0;
|
|
67
|
+
} catch {
|
|
68
|
+
body = void 0;
|
|
69
|
+
}
|
|
70
|
+
if (body !== null && typeof body === "object") {
|
|
71
|
+
const errors = body.errors;
|
|
72
|
+
if (Array.isArray(errors) && errors.length > 0 && errors[0] !== null && typeof errors[0] === "object") {
|
|
73
|
+
const first = errors[0];
|
|
74
|
+
if (typeof first.error_code === "string") {
|
|
75
|
+
info.errorCode = first.error_code;
|
|
76
|
+
}
|
|
77
|
+
if (typeof first.description === "string") {
|
|
78
|
+
info.description = first.description;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return info;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/verification/classify.ts
|
|
86
|
+
var ACRONYMS = /* @__PURE__ */ new Set(["ID", "VAT", "OCR", "PDF", "URL", "API", "HTML", "CSS", "JSON", "XML", "UUID"]);
|
|
87
|
+
function formatLabel(key) {
|
|
88
|
+
const words = key.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/_/g, " ").split(" ").filter(Boolean);
|
|
89
|
+
return words.map((word) => {
|
|
90
|
+
const upper = word.toUpperCase();
|
|
91
|
+
if (ACRONYMS.has(upper)) {
|
|
92
|
+
return upper;
|
|
93
|
+
}
|
|
94
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
95
|
+
}).join(" ");
|
|
96
|
+
}
|
|
97
|
+
function formatValue(value, fieldName) {
|
|
98
|
+
if (value === null || value === void 0) {
|
|
99
|
+
return "-";
|
|
100
|
+
}
|
|
101
|
+
if (typeof value === "boolean") {
|
|
102
|
+
return value ? "Yes" : "No";
|
|
103
|
+
}
|
|
104
|
+
if (typeof value === "number") {
|
|
105
|
+
if (fieldName && /rate|percent/i.test(fieldName)) {
|
|
106
|
+
return `${value}%`;
|
|
107
|
+
}
|
|
108
|
+
if (fieldName && /number|num|id|code|phone|fax|postal|zip/i.test(fieldName)) {
|
|
109
|
+
return String(value);
|
|
110
|
+
}
|
|
111
|
+
return value.toLocaleString();
|
|
112
|
+
}
|
|
113
|
+
if (typeof value === "string") {
|
|
114
|
+
if (/^\d{4}-\d{2}-\d{2}(T|$)/.test(value)) {
|
|
115
|
+
try {
|
|
116
|
+
const date = new Date(value);
|
|
117
|
+
if (!isNaN(date.getTime())) {
|
|
118
|
+
return date.toLocaleDateString();
|
|
119
|
+
}
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
return String(value);
|
|
126
|
+
}
|
|
127
|
+
function isValueObject(obj) {
|
|
128
|
+
if (!obj || typeof obj !== "object" || Array.isArray(obj)) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return "value" in obj;
|
|
132
|
+
}
|
|
133
|
+
function isPrimitiveArray(arr) {
|
|
134
|
+
if (arr.length === 0) return false;
|
|
135
|
+
return arr.every((item) => item === null || typeof item !== "object");
|
|
136
|
+
}
|
|
137
|
+
function isSimpleValueArray(arr) {
|
|
138
|
+
if (arr.length === 0) return false;
|
|
139
|
+
return arr.every((item) => isValueObject(item) && Object.keys(item).every((k) => ["value", "coordinates", "confidence", "confidence_reasons"].includes(k)));
|
|
140
|
+
}
|
|
141
|
+
function isTableArray(arr) {
|
|
142
|
+
if (arr.length === 0) return false;
|
|
143
|
+
const first = arr[0];
|
|
144
|
+
if (!first || typeof first !== "object" || Array.isArray(first)) return false;
|
|
145
|
+
const metaFields = /* @__PURE__ */ new Set(["confidence", "confidence_reasons", "coordinates"]);
|
|
146
|
+
const keys = Object.keys(first).filter((k) => !metaFields.has(k));
|
|
147
|
+
if (keys.length > 3) {
|
|
148
|
+
const firstObj = first;
|
|
149
|
+
const nonMetaValues = keys.map((k) => firstObj[k]);
|
|
150
|
+
const allSimple = nonMetaValues.every(
|
|
151
|
+
(v) => v === null || typeof v !== "object" || isValueObject(v)
|
|
152
|
+
);
|
|
153
|
+
return allSimple;
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
function isEntityArray(arr) {
|
|
158
|
+
if (arr.length === 0) return false;
|
|
159
|
+
if (isPrimitiveArray(arr)) return false;
|
|
160
|
+
if (isSimpleValueArray(arr)) return false;
|
|
161
|
+
if (isTableArray(arr)) return false;
|
|
162
|
+
const first = arr[0];
|
|
163
|
+
if (!first || typeof first !== "object" || Array.isArray(first)) return false;
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
function extractValue(field) {
|
|
167
|
+
if (isValueObject(field)) {
|
|
168
|
+
return field.value;
|
|
169
|
+
}
|
|
170
|
+
return field;
|
|
171
|
+
}
|
|
172
|
+
function extractCoordinates(field) {
|
|
173
|
+
if (isValueObject(field) && field.coordinates) {
|
|
174
|
+
const coords = field.coordinates;
|
|
175
|
+
if (coords.relative) {
|
|
176
|
+
return { points: coords.relative };
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
function extractConfidence(field) {
|
|
182
|
+
if (isValueObject(field) && field.confidence) {
|
|
183
|
+
return {
|
|
184
|
+
level: field.confidence,
|
|
185
|
+
reasons: field.confidence_reasons || []
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
function escapeSegment(segment) {
|
|
191
|
+
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
192
|
+
}
|
|
193
|
+
var ROW_META_KEY = "_rowMeta";
|
|
194
|
+
function classifyData(data) {
|
|
195
|
+
const result = {
|
|
196
|
+
headers: [],
|
|
197
|
+
simpleLists: [],
|
|
198
|
+
entities: [],
|
|
199
|
+
tables: [],
|
|
200
|
+
fallback: []
|
|
201
|
+
};
|
|
202
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
let rootData = data;
|
|
206
|
+
let basePointer = "";
|
|
207
|
+
if ("data" in rootData && typeof rootData.data === "object" && rootData.data !== null && !Array.isArray(rootData.data)) {
|
|
208
|
+
for (const [key, value] of Object.entries(rootData)) {
|
|
209
|
+
if (key === "data") continue;
|
|
210
|
+
processField(key, value, result, rootData, "");
|
|
211
|
+
}
|
|
212
|
+
rootData = rootData.data;
|
|
213
|
+
basePointer = "/data";
|
|
214
|
+
}
|
|
215
|
+
for (const [key, value] of Object.entries(rootData)) {
|
|
216
|
+
processField(key, value, result, rootData, basePointer);
|
|
217
|
+
}
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
function processField(key, value, result, parentObj, basePointer) {
|
|
221
|
+
if (["confidence", "confidence_reasons", "coordinates", "overall_confidence"].includes(key)) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const pointer = `${basePointer}/${escapeSegment(key)}`;
|
|
225
|
+
if (value === null || typeof value !== "object") {
|
|
226
|
+
result.headers.push({
|
|
227
|
+
key,
|
|
228
|
+
pointer,
|
|
229
|
+
value,
|
|
230
|
+
coordinates: null,
|
|
231
|
+
confidence: null
|
|
232
|
+
});
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (isValueObject(value)) {
|
|
236
|
+
result.headers.push({
|
|
237
|
+
key,
|
|
238
|
+
pointer,
|
|
239
|
+
value: extractValue(value),
|
|
240
|
+
coordinates: extractCoordinates(value),
|
|
241
|
+
confidence: extractConfidence(value)
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (Array.isArray(value)) {
|
|
246
|
+
if (value.length === 0) {
|
|
247
|
+
result.headers.push({
|
|
248
|
+
key,
|
|
249
|
+
pointer,
|
|
250
|
+
value: null,
|
|
251
|
+
coordinates: null,
|
|
252
|
+
confidence: null
|
|
253
|
+
});
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (isPrimitiveArray(value)) {
|
|
257
|
+
result.simpleLists.push({
|
|
258
|
+
key,
|
|
259
|
+
pointer,
|
|
260
|
+
items: value.map((item, index) => ({
|
|
261
|
+
pointer: `${pointer}/${index}`,
|
|
262
|
+
value: item,
|
|
263
|
+
coordinates: null,
|
|
264
|
+
confidence: null
|
|
265
|
+
}))
|
|
266
|
+
});
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (isSimpleValueArray(value)) {
|
|
270
|
+
result.simpleLists.push({
|
|
271
|
+
key,
|
|
272
|
+
pointer,
|
|
273
|
+
items: value.map((item, index) => ({
|
|
274
|
+
pointer: `${pointer}/${index}`,
|
|
275
|
+
value: extractValue(item),
|
|
276
|
+
coordinates: extractCoordinates(item),
|
|
277
|
+
confidence: extractConfidence(item)
|
|
278
|
+
}))
|
|
279
|
+
});
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (isTableArray(value)) {
|
|
283
|
+
const first = value[0];
|
|
284
|
+
const metaFields = /* @__PURE__ */ new Set(["confidence", "confidence_reasons", "coordinates"]);
|
|
285
|
+
const columns = Object.keys(first).filter((k) => !metaFields.has(k));
|
|
286
|
+
let overallConfidence = null;
|
|
287
|
+
if (parentObj) {
|
|
288
|
+
const confidenceKey = `${key}_confidence`;
|
|
289
|
+
const reasonsKey = `${key}_confidence_reasons`;
|
|
290
|
+
if (parentObj[confidenceKey]) {
|
|
291
|
+
overallConfidence = {
|
|
292
|
+
level: parentObj[confidenceKey],
|
|
293
|
+
reasons: parentObj[reasonsKey] || []
|
|
294
|
+
};
|
|
295
|
+
} else if (parentObj["overall_confidence"]) {
|
|
296
|
+
overallConfidence = {
|
|
297
|
+
level: parentObj["overall_confidence"],
|
|
298
|
+
reasons: parentObj["confidence_reasons"] || []
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
result.tables.push({
|
|
303
|
+
key,
|
|
304
|
+
pointer,
|
|
305
|
+
columns,
|
|
306
|
+
overallConfidence,
|
|
307
|
+
rows: value.map((row, rowIndex) => {
|
|
308
|
+
const rowPointer = `${pointer}/${rowIndex}`;
|
|
309
|
+
const rowData = {};
|
|
310
|
+
const rowObj = row ?? {};
|
|
311
|
+
for (const col of columns) {
|
|
312
|
+
const cell = rowObj[col];
|
|
313
|
+
rowData[col] = {
|
|
314
|
+
pointer: `${rowPointer}/${escapeSegment(col)}`,
|
|
315
|
+
value: extractValue(cell),
|
|
316
|
+
coordinates: extractCoordinates(cell),
|
|
317
|
+
confidence: extractConfidence(cell)
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
if (rowObj.confidence || rowObj.confidence_reasons) {
|
|
321
|
+
rowData[ROW_META_KEY] = {
|
|
322
|
+
pointer: rowPointer,
|
|
323
|
+
value: null,
|
|
324
|
+
coordinates: null,
|
|
325
|
+
confidence: {
|
|
326
|
+
level: rowObj.confidence || "",
|
|
327
|
+
reasons: rowObj.confidence_reasons || []
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
return rowData;
|
|
332
|
+
})
|
|
333
|
+
});
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (isEntityArray(value)) {
|
|
337
|
+
result.entities.push({
|
|
338
|
+
key,
|
|
339
|
+
pointer,
|
|
340
|
+
items: value.map((item, index) => {
|
|
341
|
+
const entity = {};
|
|
342
|
+
if (item === null || typeof item !== "object" || Array.isArray(item)) {
|
|
343
|
+
return entity;
|
|
344
|
+
}
|
|
345
|
+
for (const [fieldKey, fieldValue] of Object.entries(item)) {
|
|
346
|
+
if (["confidence", "confidence_reasons", "coordinates"].includes(fieldKey)) {
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
entity[fieldKey] = {
|
|
350
|
+
pointer: `${pointer}/${index}/${escapeSegment(fieldKey)}`,
|
|
351
|
+
value: extractValue(fieldValue),
|
|
352
|
+
coordinates: extractCoordinates(fieldValue),
|
|
353
|
+
confidence: extractConfidence(fieldValue)
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
return entity;
|
|
357
|
+
})
|
|
358
|
+
});
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
result.fallback.push({ key, data: value });
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const nestedObj = value;
|
|
365
|
+
const nestedKeys = Object.keys(nestedObj).filter((k) => !["confidence", "confidence_reasons", "coordinates"].includes(k));
|
|
366
|
+
if (nestedKeys.length > 0 && nestedKeys.length <= 10) {
|
|
367
|
+
for (const nestedKey of nestedKeys) {
|
|
368
|
+
const nestedValue = nestedObj[nestedKey];
|
|
369
|
+
const combinedKey = `${key}.${nestedKey}`;
|
|
370
|
+
const nestedPointer = `${pointer}/${escapeSegment(nestedKey)}`;
|
|
371
|
+
if (nestedValue === null || typeof nestedValue !== "object") {
|
|
372
|
+
result.headers.push({
|
|
373
|
+
key: combinedKey,
|
|
374
|
+
pointer: nestedPointer,
|
|
375
|
+
value: nestedValue,
|
|
376
|
+
coordinates: null,
|
|
377
|
+
confidence: null
|
|
378
|
+
});
|
|
379
|
+
} else if (isValueObject(nestedValue)) {
|
|
380
|
+
result.headers.push({
|
|
381
|
+
key: combinedKey,
|
|
382
|
+
pointer: nestedPointer,
|
|
383
|
+
value: extractValue(nestedValue),
|
|
384
|
+
coordinates: extractCoordinates(nestedValue),
|
|
385
|
+
confidence: extractConfidence(nestedValue)
|
|
386
|
+
});
|
|
387
|
+
} else {
|
|
388
|
+
result.fallback.push({ key: combinedKey, data: nestedValue });
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
result.fallback.push({ key, data: value });
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// src/verification/pointer.ts
|
|
397
|
+
var KEY_RE = /^label:([^|]+)\|ptr:(\/.*)$/;
|
|
398
|
+
function parseSchemaKey(raw) {
|
|
399
|
+
const match = KEY_RE.exec(raw);
|
|
400
|
+
if (match === null) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
return { raw, label: match[1], pointer: match[2] };
|
|
404
|
+
}
|
|
405
|
+
var NOT_FOUND = /* @__PURE__ */ Symbol("gemina-verification-not-found");
|
|
406
|
+
|
|
407
|
+
// src/verification/bindings.ts
|
|
408
|
+
function unescapeSegment(raw) {
|
|
409
|
+
return raw.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
410
|
+
}
|
|
411
|
+
function escapeSegment2(segment) {
|
|
412
|
+
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
413
|
+
}
|
|
414
|
+
function snakeToCamel(segment) {
|
|
415
|
+
return segment.replace(/_([a-zA-Z0-9])/g, (_, ch) => ch.toUpperCase());
|
|
416
|
+
}
|
|
417
|
+
function camelizePointer(pointer) {
|
|
418
|
+
if (!pointer.startsWith("/")) {
|
|
419
|
+
return pointer;
|
|
420
|
+
}
|
|
421
|
+
return "/" + pointer.slice(1).split("/").map((raw) => escapeSegment2(snakeToCamel(unescapeSegment(raw)))).join("/");
|
|
422
|
+
}
|
|
423
|
+
function resolveCasingAware(doc, pointer) {
|
|
424
|
+
const missing = { node: NOT_FOUND, resolvedPointer: camelizePointer(pointer) };
|
|
425
|
+
if (pointer === "") {
|
|
426
|
+
return { node: doc, resolvedPointer: "" };
|
|
427
|
+
}
|
|
428
|
+
if (!pointer.startsWith("/")) {
|
|
429
|
+
return missing;
|
|
430
|
+
}
|
|
431
|
+
let current = doc;
|
|
432
|
+
const matched = [];
|
|
433
|
+
for (const rawSegment of pointer.slice(1).split("/")) {
|
|
434
|
+
const segment = unescapeSegment(rawSegment);
|
|
435
|
+
if (Array.isArray(current)) {
|
|
436
|
+
if (!/^\d+$/.test(segment)) {
|
|
437
|
+
return missing;
|
|
438
|
+
}
|
|
439
|
+
const index = Number(segment);
|
|
440
|
+
if (index >= current.length) {
|
|
441
|
+
return missing;
|
|
442
|
+
}
|
|
443
|
+
current = current[index];
|
|
444
|
+
matched.push(rawSegment);
|
|
445
|
+
} else if (current !== null && typeof current === "object") {
|
|
446
|
+
let key;
|
|
447
|
+
if (Object.prototype.hasOwnProperty.call(current, segment)) {
|
|
448
|
+
key = segment;
|
|
449
|
+
} else {
|
|
450
|
+
const camel = snakeToCamel(segment);
|
|
451
|
+
if (camel === segment || !Object.prototype.hasOwnProperty.call(current, camel)) {
|
|
452
|
+
return missing;
|
|
453
|
+
}
|
|
454
|
+
key = camel;
|
|
455
|
+
}
|
|
456
|
+
current = current[key];
|
|
457
|
+
matched.push(escapeSegment2(key));
|
|
458
|
+
} else {
|
|
459
|
+
return missing;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return { node: current, resolvedPointer: "/" + matched.join("/") };
|
|
463
|
+
}
|
|
464
|
+
function stripValueSuffix(pointer) {
|
|
465
|
+
return pointer.endsWith("/value") ? pointer.slice(0, -"/value".length) : pointer;
|
|
466
|
+
}
|
|
467
|
+
function buildBindings(validationSchema, values) {
|
|
468
|
+
const bindings = [];
|
|
469
|
+
for (const raw of validationSchema) {
|
|
470
|
+
const key = parseSchemaKey(raw);
|
|
471
|
+
if (key === null) {
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
const { node: serverValue, resolvedPointer } = resolveCasingAware(values, key.pointer);
|
|
475
|
+
const extracted = serverValue !== NOT_FOUND && isValueObject(serverValue) ? serverValue.value : serverValue;
|
|
476
|
+
const editable = serverValue === NOT_FOUND || serverValue === null || typeof serverValue !== "object";
|
|
477
|
+
bindings.push({
|
|
478
|
+
key,
|
|
479
|
+
serverValue,
|
|
480
|
+
extracted,
|
|
481
|
+
fieldPointer: stripValueSuffix(resolvedPointer),
|
|
482
|
+
editable
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
return bindings;
|
|
486
|
+
}
|
|
487
|
+
function indexBindingsByFieldPointer(bindings) {
|
|
488
|
+
const map = /* @__PURE__ */ new Map();
|
|
489
|
+
for (const binding of bindings) {
|
|
490
|
+
map.set(binding.fieldPointer, binding);
|
|
491
|
+
}
|
|
492
|
+
return map;
|
|
493
|
+
}
|
|
494
|
+
function toInputString(extracted) {
|
|
495
|
+
if (extracted === NOT_FOUND || extracted === null || extracted === void 0) {
|
|
496
|
+
return "";
|
|
497
|
+
}
|
|
498
|
+
if (typeof extracted === "object") {
|
|
499
|
+
return JSON.stringify(extracted);
|
|
500
|
+
}
|
|
501
|
+
return String(extracted);
|
|
502
|
+
}
|
|
503
|
+
function composeSubmission(bindings, edits) {
|
|
504
|
+
const data = {};
|
|
505
|
+
const byLabel = {};
|
|
506
|
+
let confirmed = 0;
|
|
507
|
+
let corrected = 0;
|
|
508
|
+
for (const binding of bindings) {
|
|
509
|
+
const edit = edits.get(binding.key.raw);
|
|
510
|
+
if (edit !== void 0) {
|
|
511
|
+
const trimmed = edit.trim();
|
|
512
|
+
if (trimmed === "" && binding.serverValue === NOT_FOUND) {
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
const value = trimmed === "" ? null : trimmed;
|
|
516
|
+
data[binding.key.raw] = value;
|
|
517
|
+
byLabel[binding.key.label] = value;
|
|
518
|
+
corrected += 1;
|
|
519
|
+
} else {
|
|
520
|
+
if (binding.serverValue === NOT_FOUND) {
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
data[binding.key.raw] = binding.serverValue;
|
|
524
|
+
byLabel[binding.key.label] = binding.serverValue;
|
|
525
|
+
confirmed += 1;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return { data, byLabel, confirmed, corrected };
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// src/verification/form.tsx
|
|
532
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
533
|
+
|
|
534
|
+
// src/verification/viewer.tsx
|
|
535
|
+
var import_react = require("react");
|
|
536
|
+
|
|
537
|
+
// src/verification/viewer-math.ts
|
|
538
|
+
function fitScaleFor(natural, container, rotationDeg) {
|
|
539
|
+
const rot = (rotationDeg % 180 + 180) % 180;
|
|
540
|
+
const w = rot === 90 ? natural.h : natural.w;
|
|
541
|
+
const h = rot === 90 ? natural.w : natural.h;
|
|
542
|
+
const s = Math.min(container.w / w, container.h / h);
|
|
543
|
+
return isFinite(s) && s > 0 ? s : 1;
|
|
544
|
+
}
|
|
545
|
+
function rotatedBox(natural, scale, rotationDeg) {
|
|
546
|
+
const w0 = natural.w;
|
|
547
|
+
const h0 = natural.h;
|
|
548
|
+
const s = scale;
|
|
549
|
+
const rot = (rotationDeg % 360 + 360) % 360;
|
|
550
|
+
switch (rot) {
|
|
551
|
+
case 0:
|
|
552
|
+
return { W: w0 * s, H: h0 * s, minX: 0, minY: 0 };
|
|
553
|
+
case 90:
|
|
554
|
+
return { W: h0 * s, H: w0 * s, minX: -h0 * s, minY: 0 };
|
|
555
|
+
case 180:
|
|
556
|
+
return { W: w0 * s, H: h0 * s, minX: -w0 * s, minY: -h0 * s };
|
|
557
|
+
case 270:
|
|
558
|
+
return { W: h0 * s, H: w0 * s, minX: 0, minY: -w0 * s };
|
|
559
|
+
default:
|
|
560
|
+
return { W: w0 * s, H: h0 * s, minX: 0, minY: 0 };
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function centeredTranslation(natural, container, scale, rotationDeg) {
|
|
564
|
+
const { W, H, minX, minY } = rotatedBox(natural, scale, rotationDeg);
|
|
565
|
+
const nx = (container.w - W) / 2 - minX;
|
|
566
|
+
const ny = (container.h - H) / 2 - minY;
|
|
567
|
+
return { tx: nx, ty: ny };
|
|
568
|
+
}
|
|
569
|
+
function clampScale(s, fitScale, max = 8) {
|
|
570
|
+
return Math.max(fitScale, Math.min(max, s));
|
|
571
|
+
}
|
|
572
|
+
function zoomAtPoint(current, factor, px, py, rotationDeg, fitScale) {
|
|
573
|
+
const { scale, tx, ty } = current;
|
|
574
|
+
const newScale = clampScale(scale * factor, fitScale);
|
|
575
|
+
if (newScale === scale) return current;
|
|
576
|
+
const rad = rotationDeg * Math.PI / 180;
|
|
577
|
+
const cosA = Math.cos(rad);
|
|
578
|
+
const sinA = Math.sin(rad);
|
|
579
|
+
const dx = px - tx;
|
|
580
|
+
const dy = py - ty;
|
|
581
|
+
const cx = (cosA * dx + sinA * dy) / scale;
|
|
582
|
+
const cy = (-sinA * dx + cosA * dy) / scale;
|
|
583
|
+
const ntx = px - (cosA * (newScale * cx) - sinA * (newScale * cy));
|
|
584
|
+
const nty = py - (sinA * (newScale * cx) + cosA * (newScale * cy));
|
|
585
|
+
return { scale: newScale, tx: ntx, ty: nty };
|
|
586
|
+
}
|
|
587
|
+
function flashZoomTarget(rects, natural, container, rotationDeg, fitScale) {
|
|
588
|
+
let minX = 1, minY = 1, maxX = 0, maxY = 0;
|
|
589
|
+
for (const rect of rects) {
|
|
590
|
+
for (const [px, py] of rect.points) {
|
|
591
|
+
minX = Math.min(minX, px);
|
|
592
|
+
minY = Math.min(minY, py);
|
|
593
|
+
maxX = Math.max(maxX, px);
|
|
594
|
+
maxY = Math.max(maxY, py);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
const centerX = (minX + maxX) / 2 * natural.w;
|
|
598
|
+
const centerY = (minY + maxY) / 2 * natural.h;
|
|
599
|
+
const bboxWidth = (maxX - minX) * natural.w;
|
|
600
|
+
const bboxHeight = (maxY - minY) * natural.h;
|
|
601
|
+
const rad = rotationDeg * Math.PI / 180;
|
|
602
|
+
const cosA = Math.cos(rad);
|
|
603
|
+
const sinA = Math.sin(rad);
|
|
604
|
+
const TARGET_RENDERED_SIZE = 100;
|
|
605
|
+
const largerDimension = Math.max(bboxWidth, bboxHeight);
|
|
606
|
+
const scaleForTargetSize = largerDimension > 0 ? TARGET_RENDERED_SIZE / largerDimension : 1;
|
|
607
|
+
const targetScale = Math.max(fitScale, Math.min(scaleForTargetSize, 1.8));
|
|
608
|
+
const newScreenX = cosA * centerX * targetScale - sinA * centerY * targetScale;
|
|
609
|
+
const newScreenY = sinA * centerX * targetScale + cosA * centerY * targetScale;
|
|
610
|
+
const targetTx = container.w / 2 - newScreenX;
|
|
611
|
+
const targetTy = container.h / 2 - newScreenY;
|
|
612
|
+
return { scale: targetScale, tx: targetTx, ty: targetTy };
|
|
613
|
+
}
|
|
614
|
+
var easeOutCubic = (t) => 1 - Math.pow(1 - t, 3);
|
|
615
|
+
|
|
616
|
+
// src/verification/viewer.tsx
|
|
617
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
618
|
+
function IconBase({ children }) {
|
|
619
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
620
|
+
"svg",
|
|
621
|
+
{
|
|
622
|
+
width: "16",
|
|
623
|
+
height: "16",
|
|
624
|
+
viewBox: "0 0 16 16",
|
|
625
|
+
fill: "none",
|
|
626
|
+
stroke: "currentColor",
|
|
627
|
+
strokeWidth: "1.5",
|
|
628
|
+
strokeLinecap: "round",
|
|
629
|
+
strokeLinejoin: "round",
|
|
630
|
+
"aria-hidden": "true",
|
|
631
|
+
focusable: "false",
|
|
632
|
+
children
|
|
633
|
+
}
|
|
634
|
+
);
|
|
635
|
+
}
|
|
636
|
+
function GlassBody() {
|
|
637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
638
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "6.75", cy: "6.75", r: "4.25" }),
|
|
639
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "9.9", y1: "9.9", x2: "13.5", y2: "13.5" })
|
|
640
|
+
] });
|
|
641
|
+
}
|
|
642
|
+
function IconZoomIn() {
|
|
643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(IconBase, { children: [
|
|
644
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlassBody, {}),
|
|
645
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "4.9", y1: "6.75", x2: "8.6", y2: "6.75" }),
|
|
646
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "6.75", y1: "4.9", x2: "6.75", y2: "8.6" })
|
|
647
|
+
] });
|
|
648
|
+
}
|
|
649
|
+
function IconZoomOut() {
|
|
650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(IconBase, { children: [
|
|
651
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlassBody, {}),
|
|
652
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "4.9", y1: "6.75", x2: "8.6", y2: "6.75" })
|
|
653
|
+
] });
|
|
654
|
+
}
|
|
655
|
+
function IconMagnifier() {
|
|
656
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconBase, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlassBody, {}) });
|
|
657
|
+
}
|
|
658
|
+
function IconActualSize() {
|
|
659
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(IconBase, { children: [
|
|
660
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "2.8 6.2 4 5 4 11" }),
|
|
661
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "10.8 6.2 12 5 12 11" }),
|
|
662
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "8", cy: "6.75", r: "0.8", fill: "currentColor", stroke: "none" }),
|
|
663
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "8", cy: "9.25", r: "0.8", fill: "currentColor", stroke: "none" })
|
|
664
|
+
] });
|
|
665
|
+
}
|
|
666
|
+
function IconFit() {
|
|
667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(IconBase, { children: [
|
|
668
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "13.8", y1: "2.2", x2: "9.6", y2: "6.4" }),
|
|
669
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "9.6 3.9 9.6 6.4 12.1 6.4" }),
|
|
670
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "2.2", y1: "13.8", x2: "6.4", y2: "9.6" }),
|
|
671
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "6.4 12.1 6.4 9.6 3.9 9.6" })
|
|
672
|
+
] });
|
|
673
|
+
}
|
|
674
|
+
function IconRotate() {
|
|
675
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(IconBase, { children: [
|
|
676
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M11.83 4.79A5 5 0 1 1 8 3" }),
|
|
677
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "6 1.7 8 3 6 4.3" })
|
|
678
|
+
] });
|
|
679
|
+
}
|
|
680
|
+
function IconOverlay() {
|
|
681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconBase, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "2.75", y: "2.75", width: "10.5", height: "10.5", rx: "1.5", strokeDasharray: "3 2.2" }) });
|
|
682
|
+
}
|
|
683
|
+
function IconEye() {
|
|
684
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(IconBase, { children: [
|
|
685
|
+
/* @__PURE__ */ (0, import_jsx_runtime.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" }),
|
|
686
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "8", cy: "8", r: "2.1" })
|
|
687
|
+
] });
|
|
688
|
+
}
|
|
689
|
+
function ToolbarButton({
|
|
690
|
+
label,
|
|
691
|
+
onClick,
|
|
692
|
+
disabled,
|
|
693
|
+
pressed,
|
|
694
|
+
checked,
|
|
695
|
+
children
|
|
696
|
+
}) {
|
|
697
|
+
const active = (pressed ?? checked) === true;
|
|
698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
699
|
+
"button",
|
|
700
|
+
{
|
|
701
|
+
type: "button",
|
|
702
|
+
className: active ? "gemina-verification__toolbar-btn gemina-verification__toolbar-btn--active" : "gemina-verification__toolbar-btn",
|
|
703
|
+
title: label,
|
|
704
|
+
"aria-label": label,
|
|
705
|
+
role: checked === void 0 ? void 0 : "switch",
|
|
706
|
+
"aria-checked": checked,
|
|
707
|
+
"aria-pressed": pressed,
|
|
708
|
+
disabled,
|
|
709
|
+
onClick,
|
|
710
|
+
children
|
|
711
|
+
}
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
var ZOOM_STEP = 1.2;
|
|
715
|
+
var IDENTITY = { scale: 1, tx: 0, ty: 0 };
|
|
716
|
+
var FLASH_DURATION = 1500;
|
|
717
|
+
var ZOOM_ANIMATION_DURATION = 350;
|
|
718
|
+
var REDUCED_MOTION_FLASH_MS = 800;
|
|
719
|
+
var MIN_SIZE_RATIO = 8e-3;
|
|
720
|
+
var MAG_RADIUS = 150;
|
|
721
|
+
var MAG_ZOOM = 2.5;
|
|
722
|
+
function rectGeometry(rect, natural) {
|
|
723
|
+
const xs = rect.points.map((point) => point[0]);
|
|
724
|
+
const ys = rect.points.map((point) => point[1]);
|
|
725
|
+
const minX = Math.min(...xs);
|
|
726
|
+
const minY = Math.min(...ys);
|
|
727
|
+
const rawWidthRatio = Math.max(0, Math.max(...xs) - minX);
|
|
728
|
+
const rawHeightRatio = Math.max(0, Math.max(...ys) - minY);
|
|
729
|
+
if (rawWidthRatio <= 0 && rawHeightRatio <= 0) return null;
|
|
730
|
+
return {
|
|
731
|
+
left: minX * natural.w,
|
|
732
|
+
top: minY * natural.h,
|
|
733
|
+
width: Math.max(rawWidthRatio, MIN_SIZE_RATIO) * natural.w,
|
|
734
|
+
height: Math.max(rawHeightRatio, MIN_SIZE_RATIO) * natural.h
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
function VerificationViewer(props) {
|
|
738
|
+
const { src, alt, relativeRects, flashRects, onFlashComplete, onImageExpired } = props;
|
|
739
|
+
const canvasRef = (0, import_react.useRef)(null);
|
|
740
|
+
const imgRef = (0, import_react.useRef)(null);
|
|
741
|
+
const [natural, setNatural] = (0, import_react.useState)(null);
|
|
742
|
+
const [container, setContainer] = (0, import_react.useState)({ w: 0, h: 0 });
|
|
743
|
+
const [transform, setTransform] = (0, import_react.useState)(IDENTITY);
|
|
744
|
+
const [rotation, setRotation] = (0, import_react.useState)(0);
|
|
745
|
+
const [showRects, setShowRects] = (0, import_react.useState)(false);
|
|
746
|
+
const [magnifierOn, setMagnifierOn] = (0, import_react.useState)(false);
|
|
747
|
+
const [showMag, setShowMag] = (0, import_react.useState)(false);
|
|
748
|
+
const [mousePos, setMousePos] = (0, import_react.useState)({ x: 0, y: 0 });
|
|
749
|
+
const [isPanning, setIsPanning] = (0, import_react.useState)(false);
|
|
750
|
+
const panStart = (0, import_react.useRef)(null);
|
|
751
|
+
const [flashOpacity, setFlashOpacity] = (0, import_react.useState)(0);
|
|
752
|
+
const [activeFlashRects, setActiveFlashRects] = (0, import_react.useState)(null);
|
|
753
|
+
const travelRafRef = (0, import_react.useRef)(null);
|
|
754
|
+
const fadeRafRef = (0, import_react.useRef)(null);
|
|
755
|
+
const reducedFlashTimeoutRef = (0, import_react.useRef)(null);
|
|
756
|
+
const transformRef = (0, import_react.useRef)(transform);
|
|
757
|
+
transformRef.current = transform;
|
|
758
|
+
const onFlashCompleteRef = (0, import_react.useRef)(onFlashComplete);
|
|
759
|
+
onFlashCompleteRef.current = onFlashComplete;
|
|
760
|
+
const hasLoadedRef = (0, import_react.useRef)(false);
|
|
761
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
762
|
+
const el = canvasRef.current;
|
|
763
|
+
if (!el) return;
|
|
764
|
+
if (typeof ResizeObserver === "undefined") {
|
|
765
|
+
const rect = el.getBoundingClientRect();
|
|
766
|
+
setContainer({ w: rect.width, h: rect.height });
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
const ro = new ResizeObserver((entries) => {
|
|
770
|
+
const cr = entries[0]?.contentRect;
|
|
771
|
+
if (cr) setContainer({ w: cr.width, h: cr.height });
|
|
772
|
+
});
|
|
773
|
+
ro.observe(el);
|
|
774
|
+
return () => ro.disconnect();
|
|
775
|
+
}, []);
|
|
776
|
+
const handleImgLoad = (0, import_react.useCallback)(() => {
|
|
777
|
+
const img = imgRef.current;
|
|
778
|
+
if (!img) return;
|
|
779
|
+
hasLoadedRef.current = true;
|
|
780
|
+
const w = img.naturalWidth;
|
|
781
|
+
const h = img.naturalHeight;
|
|
782
|
+
setNatural((prev) => prev && prev.w === w && prev.h === h ? prev : { w, h });
|
|
783
|
+
}, []);
|
|
784
|
+
(0, import_react.useEffect)(() => {
|
|
785
|
+
hasLoadedRef.current = false;
|
|
786
|
+
}, [src]);
|
|
787
|
+
const handleImgError = (0, import_react.useCallback)(() => {
|
|
788
|
+
if (!hasLoadedRef.current) return;
|
|
789
|
+
hasLoadedRef.current = false;
|
|
790
|
+
onImageExpired?.();
|
|
791
|
+
}, [onImageExpired]);
|
|
792
|
+
const currentFitScale = (0, import_react.useCallback)(() => {
|
|
793
|
+
if (!natural || !container.w || !container.h) return 1;
|
|
794
|
+
return fitScaleFor(natural, container, rotation);
|
|
795
|
+
}, [natural, container, rotation]);
|
|
796
|
+
(0, import_react.useEffect)(() => {
|
|
797
|
+
if (!natural || !container.w || !container.h) return;
|
|
798
|
+
const fit = fitScaleFor(natural, container, rotation);
|
|
799
|
+
const { tx, ty } = centeredTranslation(natural, container, fit, rotation);
|
|
800
|
+
setTransform(
|
|
801
|
+
(prev) => Math.abs(prev.scale - fit) < 1e-4 && prev.tx === tx && prev.ty === ty ? prev : { scale: fit, tx, ty }
|
|
802
|
+
);
|
|
803
|
+
}, [natural, container, rotation]);
|
|
804
|
+
const cancelFlashTravel = (0, import_react.useCallback)(() => {
|
|
805
|
+
if (travelRafRef.current !== null) {
|
|
806
|
+
cancelAnimationFrame(travelRafRef.current);
|
|
807
|
+
travelRafRef.current = null;
|
|
808
|
+
}
|
|
809
|
+
}, []);
|
|
810
|
+
const zoomBy = (0, import_react.useCallback)(
|
|
811
|
+
(factor) => {
|
|
812
|
+
const node = canvasRef.current;
|
|
813
|
+
if (!node || !natural) return;
|
|
814
|
+
cancelFlashTravel();
|
|
815
|
+
const rect = node.getBoundingClientRect();
|
|
816
|
+
const fit = currentFitScale();
|
|
817
|
+
setTransform(
|
|
818
|
+
(prev) => zoomAtPoint(prev, factor, rect.width / 2, rect.height / 2, rotation, fit)
|
|
819
|
+
);
|
|
820
|
+
},
|
|
821
|
+
[natural, rotation, currentFitScale, cancelFlashTravel]
|
|
822
|
+
);
|
|
823
|
+
const handleZoomIn = (0, import_react.useCallback)(() => zoomBy(ZOOM_STEP), [zoomBy]);
|
|
824
|
+
const handleZoomOut = (0, import_react.useCallback)(() => zoomBy(1 / ZOOM_STEP), [zoomBy]);
|
|
825
|
+
const zoomAtClientPoint = (0, import_react.useCallback)(
|
|
826
|
+
(factor, clientX, clientY) => {
|
|
827
|
+
const node = canvasRef.current;
|
|
828
|
+
if (!node || !natural) return;
|
|
829
|
+
const rect = node.getBoundingClientRect();
|
|
830
|
+
const fit = currentFitScale();
|
|
831
|
+
setTransform(
|
|
832
|
+
(prev) => zoomAtPoint(prev, factor, clientX - rect.left, clientY - rect.top, rotation, fit)
|
|
833
|
+
);
|
|
834
|
+
},
|
|
835
|
+
[natural, rotation, currentFitScale]
|
|
836
|
+
);
|
|
837
|
+
const handleWheel = (0, import_react.useCallback)(
|
|
838
|
+
(event) => {
|
|
839
|
+
event.preventDefault();
|
|
840
|
+
event.stopPropagation();
|
|
841
|
+
cancelFlashTravel();
|
|
842
|
+
const factor = event.deltaY > 0 ? 0.92 : 1.08;
|
|
843
|
+
zoomAtClientPoint(factor, event.clientX, event.clientY);
|
|
844
|
+
},
|
|
845
|
+
[zoomAtClientPoint, cancelFlashTravel]
|
|
846
|
+
);
|
|
847
|
+
(0, import_react.useEffect)(() => {
|
|
848
|
+
const node = canvasRef.current;
|
|
849
|
+
if (!node) return;
|
|
850
|
+
const listener = (event) => handleWheel(event);
|
|
851
|
+
node.addEventListener("wheel", listener, { passive: false });
|
|
852
|
+
return () => node.removeEventListener("wheel", listener);
|
|
853
|
+
}, [handleWheel]);
|
|
854
|
+
const atFitScale = transform.scale <= currentFitScale() + 1e-3;
|
|
855
|
+
const handleMouseDown = (0, import_react.useCallback)(
|
|
856
|
+
(e) => {
|
|
857
|
+
cancelFlashTravel();
|
|
858
|
+
if (e.button !== 0) return;
|
|
859
|
+
if (atFitScale) return;
|
|
860
|
+
e.preventDefault();
|
|
861
|
+
panStart.current = { x: e.clientX, y: e.clientY, tx: transform.tx, ty: transform.ty };
|
|
862
|
+
setIsPanning(true);
|
|
863
|
+
},
|
|
864
|
+
[atFitScale, transform.tx, transform.ty, cancelFlashTravel]
|
|
865
|
+
);
|
|
866
|
+
(0, import_react.useEffect)(() => {
|
|
867
|
+
if (!isPanning) return;
|
|
868
|
+
const onMove = (e) => {
|
|
869
|
+
const start = panStart.current;
|
|
870
|
+
if (!start) return;
|
|
871
|
+
const dx = e.clientX - start.x;
|
|
872
|
+
const dy = e.clientY - start.y;
|
|
873
|
+
setTransform((prev) => ({ scale: prev.scale, tx: start.tx + dx, ty: start.ty + dy }));
|
|
874
|
+
};
|
|
875
|
+
const onUp = () => {
|
|
876
|
+
panStart.current = null;
|
|
877
|
+
setIsPanning(false);
|
|
878
|
+
};
|
|
879
|
+
document.addEventListener("mousemove", onMove);
|
|
880
|
+
document.addEventListener("mouseup", onUp);
|
|
881
|
+
return () => {
|
|
882
|
+
document.removeEventListener("mousemove", onMove);
|
|
883
|
+
document.removeEventListener("mouseup", onUp);
|
|
884
|
+
};
|
|
885
|
+
}, [isPanning]);
|
|
886
|
+
const touchState = (0, import_react.useRef)(null);
|
|
887
|
+
const handleTouchStart = (0, import_react.useCallback)(
|
|
888
|
+
(e) => {
|
|
889
|
+
cancelFlashTravel();
|
|
890
|
+
const a = e.touches[0];
|
|
891
|
+
const b = e.touches[1];
|
|
892
|
+
if (e.touches.length === 2 && a && b) {
|
|
893
|
+
touchState.current = {
|
|
894
|
+
mode: "pinch",
|
|
895
|
+
dist: Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY)
|
|
896
|
+
};
|
|
897
|
+
} else if (e.touches.length === 1 && a && !atFitScale) {
|
|
898
|
+
touchState.current = { mode: "pan", x: a.clientX, y: a.clientY, tx: transform.tx, ty: transform.ty };
|
|
899
|
+
} else {
|
|
900
|
+
touchState.current = null;
|
|
901
|
+
}
|
|
902
|
+
},
|
|
903
|
+
[atFitScale, transform.tx, transform.ty, cancelFlashTravel]
|
|
904
|
+
);
|
|
905
|
+
const handleTouchMove = (0, import_react.useCallback)(
|
|
906
|
+
(e) => {
|
|
907
|
+
const state = touchState.current;
|
|
908
|
+
if (!state) return;
|
|
909
|
+
if (state.mode === "pinch" && e.touches.length === 2) {
|
|
910
|
+
const a = e.touches[0];
|
|
911
|
+
const b = e.touches[1];
|
|
912
|
+
if (!a || !b) return;
|
|
913
|
+
const dist = Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY);
|
|
914
|
+
if (state.dist > 0) {
|
|
915
|
+
zoomAtClientPoint(dist / state.dist, (a.clientX + b.clientX) / 2, (a.clientY + b.clientY) / 2);
|
|
916
|
+
}
|
|
917
|
+
state.dist = dist;
|
|
918
|
+
} else if (state.mode === "pan" && e.touches.length === 1) {
|
|
919
|
+
const t = e.touches[0];
|
|
920
|
+
if (!t) return;
|
|
921
|
+
setTransform((prev) => ({
|
|
922
|
+
scale: prev.scale,
|
|
923
|
+
tx: state.tx + (t.clientX - state.x),
|
|
924
|
+
ty: state.ty + (t.clientY - state.y)
|
|
925
|
+
}));
|
|
926
|
+
}
|
|
927
|
+
},
|
|
928
|
+
[zoomAtClientPoint]
|
|
929
|
+
);
|
|
930
|
+
const handleTouchEnd = (0, import_react.useCallback)((e) => {
|
|
931
|
+
if (e.touches.length === 0) touchState.current = null;
|
|
932
|
+
}, []);
|
|
933
|
+
const handleCanvasMouseMove = (0, import_react.useCallback)((e) => {
|
|
934
|
+
const rect = canvasRef.current?.getBoundingClientRect();
|
|
935
|
+
if (!rect) return;
|
|
936
|
+
setShowMag(true);
|
|
937
|
+
setMousePos({ x: e.clientX - rect.left, y: e.clientY - rect.top });
|
|
938
|
+
}, []);
|
|
939
|
+
const handleCanvasMouseLeave = (0, import_react.useCallback)(() => {
|
|
940
|
+
setShowMag(false);
|
|
941
|
+
}, []);
|
|
942
|
+
const handleDoubleClick = (0, import_react.useCallback)(
|
|
943
|
+
(e) => {
|
|
944
|
+
cancelFlashTravel();
|
|
945
|
+
if (!natural) return;
|
|
946
|
+
const fit = currentFitScale();
|
|
947
|
+
const nearFit = Math.abs(transform.scale - fit) < 1e-3;
|
|
948
|
+
if (nearFit) {
|
|
949
|
+
const target = clampScale(1, fit);
|
|
950
|
+
zoomAtClientPoint(target / transform.scale, e.clientX, e.clientY);
|
|
951
|
+
} else {
|
|
952
|
+
setTransform({ scale: fit, ...centeredTranslation(natural, container, fit, rotation) });
|
|
953
|
+
}
|
|
954
|
+
},
|
|
955
|
+
[natural, container, rotation, transform.scale, currentFitScale, zoomAtClientPoint, cancelFlashTravel]
|
|
956
|
+
);
|
|
957
|
+
const handleFit = (0, import_react.useCallback)(() => {
|
|
958
|
+
if (!natural) return;
|
|
959
|
+
cancelFlashTravel();
|
|
960
|
+
const fit = currentFitScale();
|
|
961
|
+
setTransform({ scale: fit, ...centeredTranslation(natural, container, fit, rotation) });
|
|
962
|
+
}, [natural, container, rotation, currentFitScale, cancelFlashTravel]);
|
|
963
|
+
const handleActualSize = (0, import_react.useCallback)(() => {
|
|
964
|
+
if (!natural) return;
|
|
965
|
+
cancelFlashTravel();
|
|
966
|
+
const target = clampScale(1, currentFitScale());
|
|
967
|
+
setTransform({ scale: target, ...centeredTranslation(natural, container, target, rotation) });
|
|
968
|
+
}, [natural, container, rotation, currentFitScale, cancelFlashTravel]);
|
|
969
|
+
const handleRotate = (0, import_react.useCallback)(() => {
|
|
970
|
+
setRotation((r) => (r + 90) % 360);
|
|
971
|
+
}, []);
|
|
972
|
+
const hasRects = relativeRects !== void 0 && relativeRects.length > 0;
|
|
973
|
+
(0, import_react.useEffect)(() => {
|
|
974
|
+
if (!hasRects) setShowRects(false);
|
|
975
|
+
}, [hasRects]);
|
|
976
|
+
(0, import_react.useEffect)(() => {
|
|
977
|
+
if (!flashRects || flashRects.length === 0 || !natural || !container.w || !container.h) {
|
|
978
|
+
setActiveFlashRects((prev) => prev === null ? prev : null);
|
|
979
|
+
setFlashOpacity(0);
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
const fit = fitScaleFor(natural, container, rotation);
|
|
983
|
+
const target = flashZoomTarget(flashRects, natural, container, rotation, fit);
|
|
984
|
+
setActiveFlashRects(flashRects);
|
|
985
|
+
setFlashOpacity(1);
|
|
986
|
+
const prefersReduced = typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
987
|
+
if (prefersReduced) {
|
|
988
|
+
setTransform(target);
|
|
989
|
+
reducedFlashTimeoutRef.current = setTimeout(() => {
|
|
990
|
+
reducedFlashTimeoutRef.current = null;
|
|
991
|
+
setActiveFlashRects(null);
|
|
992
|
+
setFlashOpacity(0);
|
|
993
|
+
onFlashCompleteRef.current?.();
|
|
994
|
+
}, REDUCED_MOTION_FLASH_MS);
|
|
995
|
+
return () => {
|
|
996
|
+
if (reducedFlashTimeoutRef.current !== null) {
|
|
997
|
+
clearTimeout(reducedFlashTimeoutRef.current);
|
|
998
|
+
reducedFlashTimeoutRef.current = null;
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
const from = transformRef.current;
|
|
1003
|
+
const zoomStartTime = Date.now();
|
|
1004
|
+
const animateZoom = () => {
|
|
1005
|
+
const progress = Math.min((Date.now() - zoomStartTime) / ZOOM_ANIMATION_DURATION, 1);
|
|
1006
|
+
const eased = easeOutCubic(progress);
|
|
1007
|
+
setTransform({
|
|
1008
|
+
scale: from.scale + (target.scale - from.scale) * eased,
|
|
1009
|
+
tx: from.tx + (target.tx - from.tx) * eased,
|
|
1010
|
+
ty: from.ty + (target.ty - from.ty) * eased
|
|
1011
|
+
});
|
|
1012
|
+
travelRafRef.current = progress < 1 ? requestAnimationFrame(animateZoom) : null;
|
|
1013
|
+
};
|
|
1014
|
+
travelRafRef.current = requestAnimationFrame(animateZoom);
|
|
1015
|
+
const flashStartTime = Date.now();
|
|
1016
|
+
const animateFlash = () => {
|
|
1017
|
+
const progress = Math.min((Date.now() - flashStartTime) / FLASH_DURATION, 1);
|
|
1018
|
+
setFlashOpacity(1 - progress * progress);
|
|
1019
|
+
if (progress < 1) {
|
|
1020
|
+
fadeRafRef.current = requestAnimationFrame(animateFlash);
|
|
1021
|
+
} else {
|
|
1022
|
+
fadeRafRef.current = null;
|
|
1023
|
+
setActiveFlashRects(null);
|
|
1024
|
+
setFlashOpacity(0);
|
|
1025
|
+
onFlashCompleteRef.current?.();
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
fadeRafRef.current = requestAnimationFrame(animateFlash);
|
|
1029
|
+
return () => {
|
|
1030
|
+
cancelFlashTravel();
|
|
1031
|
+
if (fadeRafRef.current !== null) {
|
|
1032
|
+
cancelAnimationFrame(fadeRafRef.current);
|
|
1033
|
+
fadeRafRef.current = null;
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
}, [flashRects, natural, container.w, container.h, rotation, cancelFlashTravel]);
|
|
1037
|
+
const cursorMode = atFitScale ? "zoom-in" : isPanning ? "grabbing" : "grab";
|
|
1038
|
+
let magnifier = null;
|
|
1039
|
+
if (magnifierOn && showMag && natural && transform.scale > 0) {
|
|
1040
|
+
const rad = rotation * Math.PI / 180;
|
|
1041
|
+
const cosA = Math.cos(rad);
|
|
1042
|
+
const sinA = Math.sin(rad);
|
|
1043
|
+
const dx = mousePos.x - transform.tx;
|
|
1044
|
+
const dy = mousePos.y - transform.ty;
|
|
1045
|
+
const cxRaw = (cosA * dx + sinA * dy) / transform.scale;
|
|
1046
|
+
const cyRaw = (-sinA * dx + cosA * dy) / transform.scale;
|
|
1047
|
+
const clampedX = Math.max(0, Math.min(cxRaw, natural.w));
|
|
1048
|
+
const clampedY = Math.max(0, Math.min(cyRaw, natural.h));
|
|
1049
|
+
const zoomScale = transform.scale * MAG_ZOOM;
|
|
1050
|
+
const px = clampedX * zoomScale;
|
|
1051
|
+
const py = clampedY * zoomScale;
|
|
1052
|
+
const rotatedX = px * cosA - py * sinA;
|
|
1053
|
+
const rotatedY = px * sinA + py * cosA;
|
|
1054
|
+
const translateX = MAG_RADIUS - rotatedX;
|
|
1055
|
+
const translateY = MAG_RADIUS - rotatedY;
|
|
1056
|
+
magnifier = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1057
|
+
"div",
|
|
1058
|
+
{
|
|
1059
|
+
className: "gemina-verification__magnifier",
|
|
1060
|
+
style: {
|
|
1061
|
+
width: MAG_RADIUS * 2,
|
|
1062
|
+
height: MAG_RADIUS * 2,
|
|
1063
|
+
top: mousePos.y - MAG_RADIUS,
|
|
1064
|
+
left: mousePos.x - MAG_RADIUS
|
|
1065
|
+
},
|
|
1066
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1067
|
+
"img",
|
|
1068
|
+
{
|
|
1069
|
+
src,
|
|
1070
|
+
alt: "",
|
|
1071
|
+
draggable: false,
|
|
1072
|
+
style: {
|
|
1073
|
+
position: "absolute",
|
|
1074
|
+
width: natural.w,
|
|
1075
|
+
height: natural.h,
|
|
1076
|
+
transformOrigin: "0 0",
|
|
1077
|
+
transform: `translate(${translateX}px, ${translateY}px) rotate(${rotation}deg) scale(${zoomScale})`
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
)
|
|
1081
|
+
}
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "gemina-verification__viewer", children: [
|
|
1085
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "gemina-verification__toolbar", children: [
|
|
1086
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolbarButton, { label: "Zoom out", onClick: handleZoomOut, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconZoomOut, {}) }),
|
|
1087
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolbarButton, { label: "Zoom in", onClick: handleZoomIn, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconZoomIn, {}) }),
|
|
1088
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolbarButton, { label: "Actual size (100%)", onClick: handleActualSize, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconActualSize, {}) }),
|
|
1089
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolbarButton, { label: "Fit to screen", onClick: handleFit, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconFit, {}) }),
|
|
1090
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolbarButton, { label: "Rotate 90 degrees", onClick: handleRotate, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconRotate, {}) }),
|
|
1091
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1092
|
+
ToolbarButton,
|
|
1093
|
+
{
|
|
1094
|
+
label: "Toggle detection overlays",
|
|
1095
|
+
pressed: showRects,
|
|
1096
|
+
disabled: !hasRects,
|
|
1097
|
+
onClick: () => setShowRects((prev) => !prev),
|
|
1098
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconOverlay, {})
|
|
1099
|
+
}
|
|
1100
|
+
),
|
|
1101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1102
|
+
ToolbarButton,
|
|
1103
|
+
{
|
|
1104
|
+
label: "Magnifier",
|
|
1105
|
+
checked: magnifierOn,
|
|
1106
|
+
onClick: () => setMagnifierOn((prev) => !prev),
|
|
1107
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconMagnifier, {})
|
|
1108
|
+
}
|
|
1109
|
+
)
|
|
1110
|
+
] }),
|
|
1111
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1112
|
+
"div",
|
|
1113
|
+
{
|
|
1114
|
+
ref: canvasRef,
|
|
1115
|
+
className: "gemina-verification__canvas",
|
|
1116
|
+
"data-cursor": cursorMode,
|
|
1117
|
+
role: "img",
|
|
1118
|
+
"aria-label": alt ?? "Document image",
|
|
1119
|
+
onDoubleClick: handleDoubleClick,
|
|
1120
|
+
onMouseDown: handleMouseDown,
|
|
1121
|
+
onMouseMove: handleCanvasMouseMove,
|
|
1122
|
+
onMouseLeave: handleCanvasMouseLeave,
|
|
1123
|
+
onTouchStart: handleTouchStart,
|
|
1124
|
+
onTouchMove: handleTouchMove,
|
|
1125
|
+
onTouchEnd: handleTouchEnd,
|
|
1126
|
+
onTouchCancel: handleTouchEnd,
|
|
1127
|
+
children: [
|
|
1128
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1129
|
+
"div",
|
|
1130
|
+
{
|
|
1131
|
+
style: {
|
|
1132
|
+
position: "absolute",
|
|
1133
|
+
left: transform.tx,
|
|
1134
|
+
top: transform.ty,
|
|
1135
|
+
transform: `rotate(${rotation}deg) scale(${transform.scale})`,
|
|
1136
|
+
transformOrigin: "top left",
|
|
1137
|
+
willChange: "transform,left,top"
|
|
1138
|
+
},
|
|
1139
|
+
children: [
|
|
1140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1141
|
+
"img",
|
|
1142
|
+
{
|
|
1143
|
+
ref: imgRef,
|
|
1144
|
+
src,
|
|
1145
|
+
alt: alt ?? "Document",
|
|
1146
|
+
draggable: false,
|
|
1147
|
+
onLoad: handleImgLoad,
|
|
1148
|
+
onError: handleImgError
|
|
1149
|
+
}
|
|
1150
|
+
),
|
|
1151
|
+
showRects && natural && relativeRects?.map((rect, idx) => {
|
|
1152
|
+
const geometry = rectGeometry(rect, natural);
|
|
1153
|
+
if (!geometry) return null;
|
|
1154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1155
|
+
"div",
|
|
1156
|
+
{
|
|
1157
|
+
className: "gemina-verification__rect",
|
|
1158
|
+
style: geometry,
|
|
1159
|
+
"aria-hidden": "true",
|
|
1160
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "gemina-verification__rect-badge", children: [
|
|
1161
|
+
"#",
|
|
1162
|
+
idx + 1
|
|
1163
|
+
] })
|
|
1164
|
+
},
|
|
1165
|
+
`rect-${idx}`
|
|
1166
|
+
);
|
|
1167
|
+
}),
|
|
1168
|
+
activeFlashRects && natural && activeFlashRects.map((rect, idx) => {
|
|
1169
|
+
const geometry = rectGeometry(rect, natural);
|
|
1170
|
+
if (!geometry) return null;
|
|
1171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1172
|
+
"div",
|
|
1173
|
+
{
|
|
1174
|
+
className: "gemina-verification__flash-rect",
|
|
1175
|
+
style: { ...geometry, opacity: flashOpacity },
|
|
1176
|
+
"aria-hidden": "true"
|
|
1177
|
+
},
|
|
1178
|
+
`flash-rect-${idx}`
|
|
1179
|
+
);
|
|
1180
|
+
})
|
|
1181
|
+
]
|
|
1182
|
+
}
|
|
1183
|
+
),
|
|
1184
|
+
magnifier
|
|
1185
|
+
]
|
|
1186
|
+
}
|
|
1187
|
+
)
|
|
1188
|
+
] });
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
// src/verification/form.tsx
|
|
1192
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1193
|
+
function ConfidenceDot(props) {
|
|
1194
|
+
const { confidence } = props;
|
|
1195
|
+
if (!confidence?.level) {
|
|
1196
|
+
return null;
|
|
1197
|
+
}
|
|
1198
|
+
let variant;
|
|
1199
|
+
let label;
|
|
1200
|
+
switch (confidence.level.toLowerCase()) {
|
|
1201
|
+
case "high":
|
|
1202
|
+
variant = "high";
|
|
1203
|
+
label = "High confidence";
|
|
1204
|
+
break;
|
|
1205
|
+
case "medium":
|
|
1206
|
+
variant = "medium";
|
|
1207
|
+
label = "Medium confidence";
|
|
1208
|
+
break;
|
|
1209
|
+
case "low":
|
|
1210
|
+
variant = "low";
|
|
1211
|
+
label = "Low confidence";
|
|
1212
|
+
break;
|
|
1213
|
+
default:
|
|
1214
|
+
variant = "unknown";
|
|
1215
|
+
label = `${confidence.level} confidence`;
|
|
1216
|
+
}
|
|
1217
|
+
const reasons = confidence.reasons.map(formatLabel);
|
|
1218
|
+
const title = [label, ...reasons].join("\n");
|
|
1219
|
+
const ariaLabel = reasons.length > 0 ? `${label}: ${reasons.join(", ")}` : label;
|
|
1220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1221
|
+
"span",
|
|
1222
|
+
{
|
|
1223
|
+
className: `gemina-verification__dot gemina-verification__dot--${variant}`,
|
|
1224
|
+
role: "img",
|
|
1225
|
+
"aria-label": ariaLabel,
|
|
1226
|
+
title
|
|
1227
|
+
}
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
function EyeButton(props) {
|
|
1231
|
+
const { coordinates, onFlash } = props;
|
|
1232
|
+
if (!coordinates) {
|
|
1233
|
+
return null;
|
|
1234
|
+
}
|
|
1235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1236
|
+
"button",
|
|
1237
|
+
{
|
|
1238
|
+
type: "button",
|
|
1239
|
+
className: "gemina-verification__eye",
|
|
1240
|
+
title: "Show on document",
|
|
1241
|
+
"aria-label": "Show on document",
|
|
1242
|
+
onClick: (event) => {
|
|
1243
|
+
event.stopPropagation();
|
|
1244
|
+
onFlash();
|
|
1245
|
+
},
|
|
1246
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconEye, {})
|
|
1247
|
+
}
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
1250
|
+
function FieldInput(props) {
|
|
1251
|
+
const { binding, edit, onEdit, readOnly, ariaLabel } = props;
|
|
1252
|
+
const editedBadgeId = import_react2.default.useId();
|
|
1253
|
+
if (readOnly || !binding.editable) {
|
|
1254
|
+
const display = binding.extracted === NOT_FOUND ? null : binding.extracted;
|
|
1255
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: formatValue(display, binding.key.label) });
|
|
1256
|
+
}
|
|
1257
|
+
const dirty = edit !== void 0;
|
|
1258
|
+
const missed = binding.serverValue === NOT_FOUND;
|
|
1259
|
+
const className = [
|
|
1260
|
+
"gemina-verification__input",
|
|
1261
|
+
dirty ? "gemina-verification__input--dirty" : "",
|
|
1262
|
+
missed ? "gemina-verification__input--missed" : ""
|
|
1263
|
+
].filter(Boolean).join(" ");
|
|
1264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1265
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1266
|
+
"input",
|
|
1267
|
+
{
|
|
1268
|
+
type: "text",
|
|
1269
|
+
className,
|
|
1270
|
+
dir: "auto",
|
|
1271
|
+
value: dirty ? edit : toInputString(binding.extracted),
|
|
1272
|
+
onChange: (event) => onEdit(binding.key.raw, event.target.value),
|
|
1273
|
+
placeholder: missed ? "Not detected \u2014 fill in if present" : void 0,
|
|
1274
|
+
"aria-label": ariaLabel,
|
|
1275
|
+
"aria-describedby": dirty ? editedBadgeId : void 0,
|
|
1276
|
+
autoComplete: "off"
|
|
1277
|
+
}
|
|
1278
|
+
),
|
|
1279
|
+
dirty ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gemina-verification__edited", id: editedBadgeId, children: "edited" }) : null
|
|
1280
|
+
] });
|
|
1281
|
+
}
|
|
1282
|
+
function isInteractiveTarget(target) {
|
|
1283
|
+
return target instanceof Element && target.closest("input, button, a, select, textarea") !== null;
|
|
1284
|
+
}
|
|
1285
|
+
function FieldPair(props) {
|
|
1286
|
+
const { label, ariaLabel, cell, shared } = props;
|
|
1287
|
+
const binding = shared.bindingIndex.get(cell.pointer);
|
|
1288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1289
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("dt", { className: "gemina-verification__dt", children: [
|
|
1290
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ConfidenceDot, { confidence: cell.confidence }),
|
|
1291
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: label })
|
|
1292
|
+
] }),
|
|
1293
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("dd", { className: "gemina-verification__dd", children: [
|
|
1294
|
+
binding !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1295
|
+
FieldInput,
|
|
1296
|
+
{
|
|
1297
|
+
binding,
|
|
1298
|
+
edit: shared.edits.get(binding.key.raw),
|
|
1299
|
+
onEdit: shared.onEdit,
|
|
1300
|
+
readOnly: shared.readOnly,
|
|
1301
|
+
ariaLabel
|
|
1302
|
+
}
|
|
1303
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: formatValue(cell.value, label) }),
|
|
1304
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1305
|
+
EyeButton,
|
|
1306
|
+
{
|
|
1307
|
+
coordinates: cell.coordinates,
|
|
1308
|
+
onFlash: () => {
|
|
1309
|
+
if (cell.coordinates) {
|
|
1310
|
+
shared.onFlash([cell.coordinates]);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
)
|
|
1315
|
+
] })
|
|
1316
|
+
] });
|
|
1317
|
+
}
|
|
1318
|
+
function HeaderSection(props) {
|
|
1319
|
+
const { headers, simpleLists, shared } = props;
|
|
1320
|
+
if (headers.length === 0 && simpleLists.length === 0) {
|
|
1321
|
+
return null;
|
|
1322
|
+
}
|
|
1323
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Details", children: [
|
|
1324
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gemina-verification__section-header", children: "Details" }),
|
|
1325
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("dl", { className: "gemina-verification__dl", children: [
|
|
1326
|
+
headers.map((field) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1327
|
+
FieldPair,
|
|
1328
|
+
{
|
|
1329
|
+
label: formatLabel(field.key),
|
|
1330
|
+
ariaLabel: formatLabel(field.key),
|
|
1331
|
+
cell: field,
|
|
1332
|
+
shared
|
|
1333
|
+
},
|
|
1334
|
+
field.pointer
|
|
1335
|
+
)),
|
|
1336
|
+
simpleLists.map((list) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.default.Fragment, { children: [
|
|
1337
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dt", { className: "gemina-verification__dt", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: formatLabel(list.key) }) }),
|
|
1338
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dd", { className: "gemina-verification__dd", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { className: "gemina-verification__list", children: list.items.map((item, index) => {
|
|
1339
|
+
const binding = shared.bindingIndex.get(item.pointer);
|
|
1340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("li", { className: "gemina-verification__cell", children: [
|
|
1341
|
+
binding !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1342
|
+
FieldInput,
|
|
1343
|
+
{
|
|
1344
|
+
binding,
|
|
1345
|
+
edit: shared.edits.get(binding.key.raw),
|
|
1346
|
+
onEdit: shared.onEdit,
|
|
1347
|
+
readOnly: shared.readOnly,
|
|
1348
|
+
ariaLabel: `${formatLabel(list.key)} item ${index + 1}`
|
|
1349
|
+
}
|
|
1350
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: formatValue(item.value) }),
|
|
1351
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ConfidenceDot, { confidence: item.confidence }),
|
|
1352
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1353
|
+
EyeButton,
|
|
1354
|
+
{
|
|
1355
|
+
coordinates: item.coordinates,
|
|
1356
|
+
onFlash: () => {
|
|
1357
|
+
if (item.coordinates) {
|
|
1358
|
+
shared.onFlash([item.coordinates]);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
)
|
|
1363
|
+
] }, item.pointer);
|
|
1364
|
+
}) }) })
|
|
1365
|
+
] }, list.pointer))
|
|
1366
|
+
] })
|
|
1367
|
+
] });
|
|
1368
|
+
}
|
|
1369
|
+
function EntitySection(props) {
|
|
1370
|
+
const { entity, shared } = props;
|
|
1371
|
+
const label = formatLabel(entity.key);
|
|
1372
|
+
const singular = label.replace(/s$/, "");
|
|
1373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
|
|
1374
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gemina-verification__section-header", children: [
|
|
1375
|
+
label,
|
|
1376
|
+
" (",
|
|
1377
|
+
entity.items.length,
|
|
1378
|
+
")"
|
|
1379
|
+
] }),
|
|
1380
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gemina-verification__section-body", children: entity.items.map((item, itemIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gemina-verification__card", children: [
|
|
1381
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gemina-verification__card-header", children: [
|
|
1382
|
+
singular,
|
|
1383
|
+
" ",
|
|
1384
|
+
itemIndex + 1
|
|
1385
|
+
] }),
|
|
1386
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dl", { className: "gemina-verification__dl", children: Object.entries(item).map(([fieldKey, cell]) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1387
|
+
FieldPair,
|
|
1388
|
+
{
|
|
1389
|
+
label: formatLabel(fieldKey),
|
|
1390
|
+
ariaLabel: `${singular} ${itemIndex + 1} \u2014 ${formatLabel(fieldKey)}`,
|
|
1391
|
+
cell,
|
|
1392
|
+
shared
|
|
1393
|
+
},
|
|
1394
|
+
fieldKey
|
|
1395
|
+
)) })
|
|
1396
|
+
] }, itemIndex)) })
|
|
1397
|
+
] });
|
|
1398
|
+
}
|
|
1399
|
+
function TableRowView(props) {
|
|
1400
|
+
const { row, rowIndex, columns, tableLabel, hasCoords, hasRowConfidence, shared } = props;
|
|
1401
|
+
const { bindingIndex, edits, onEdit, readOnly, onFlash } = shared;
|
|
1402
|
+
const rects = import_react2.default.useMemo(() => {
|
|
1403
|
+
const collected = [];
|
|
1404
|
+
for (const [key, cell] of Object.entries(row)) {
|
|
1405
|
+
if (key !== ROW_META_KEY && cell.coordinates) {
|
|
1406
|
+
collected.push(cell.coordinates);
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
return collected;
|
|
1410
|
+
}, [row]);
|
|
1411
|
+
const handleRowClick = import_react2.default.useCallback(
|
|
1412
|
+
(event) => {
|
|
1413
|
+
if (isInteractiveTarget(event.target)) {
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
if (rects.length > 0) {
|
|
1417
|
+
onFlash(rects);
|
|
1418
|
+
}
|
|
1419
|
+
},
|
|
1420
|
+
[rects, onFlash]
|
|
1421
|
+
);
|
|
1422
|
+
const firstRect = rects.length > 0 ? rects[0] : null;
|
|
1423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { onClick: handleRowClick, children: [
|
|
1424
|
+
hasCoords ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(EyeButton, { coordinates: firstRect, onFlash: () => onFlash(rects) }) }) : null,
|
|
1425
|
+
hasRowConfidence ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ConfidenceDot, { confidence: row[ROW_META_KEY]?.confidence ?? null }) }) : null,
|
|
1426
|
+
columns.map((column) => {
|
|
1427
|
+
const cell = row[column];
|
|
1428
|
+
const binding = cell === void 0 ? void 0 : bindingIndex.get(cell.pointer);
|
|
1429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gemina-verification__cell", children: [
|
|
1430
|
+
binding !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1431
|
+
FieldInput,
|
|
1432
|
+
{
|
|
1433
|
+
binding,
|
|
1434
|
+
edit: edits.get(binding.key.raw),
|
|
1435
|
+
onEdit,
|
|
1436
|
+
readOnly,
|
|
1437
|
+
ariaLabel: `${tableLabel} row ${rowIndex + 1} \u2014 ${formatLabel(column)}`
|
|
1438
|
+
}
|
|
1439
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: cell === void 0 ? "-" : formatValue(cell.value, column) }),
|
|
1440
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ConfidenceDot, { confidence: cell?.confidence ?? null })
|
|
1441
|
+
] }) }, column);
|
|
1442
|
+
})
|
|
1443
|
+
] });
|
|
1444
|
+
}
|
|
1445
|
+
function areRowPropsEqual(prev, next) {
|
|
1446
|
+
if (prev.row !== next.row || prev.rowIndex !== next.rowIndex || prev.columns !== next.columns || prev.tableLabel !== next.tableLabel || prev.hasCoords !== next.hasCoords || prev.hasRowConfidence !== next.hasRowConfidence || prev.shared.bindingIndex !== next.shared.bindingIndex || prev.shared.onEdit !== next.shared.onEdit || prev.shared.onFlash !== next.shared.onFlash || prev.shared.readOnly !== next.shared.readOnly) {
|
|
1447
|
+
return false;
|
|
1448
|
+
}
|
|
1449
|
+
if (prev.shared.edits === next.shared.edits) {
|
|
1450
|
+
return true;
|
|
1451
|
+
}
|
|
1452
|
+
for (const column of next.columns) {
|
|
1453
|
+
const cell = next.row[column];
|
|
1454
|
+
const binding = cell === void 0 ? void 0 : next.shared.bindingIndex.get(cell.pointer);
|
|
1455
|
+
if (binding !== void 0 && prev.shared.edits.get(binding.key.raw) !== next.shared.edits.get(binding.key.raw)) {
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
return true;
|
|
1460
|
+
}
|
|
1461
|
+
var TableRow = import_react2.default.memo(TableRowView, areRowPropsEqual);
|
|
1462
|
+
function TableSection(props) {
|
|
1463
|
+
const { table, shared } = props;
|
|
1464
|
+
const label = formatLabel(table.key);
|
|
1465
|
+
const hasCoords = import_react2.default.useMemo(
|
|
1466
|
+
() => table.rows.some(
|
|
1467
|
+
(row) => Object.entries(row).some(([key, cell]) => key !== ROW_META_KEY && cell.coordinates !== null)
|
|
1468
|
+
),
|
|
1469
|
+
[table]
|
|
1470
|
+
);
|
|
1471
|
+
const hasRowConfidence = import_react2.default.useMemo(
|
|
1472
|
+
() => table.rows.some((row) => Boolean(row[ROW_META_KEY]?.confidence?.level)),
|
|
1473
|
+
[table]
|
|
1474
|
+
);
|
|
1475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
|
|
1476
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gemina-verification__section-header", children: [
|
|
1477
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
1478
|
+
label,
|
|
1479
|
+
" (",
|
|
1480
|
+
table.rows.length,
|
|
1481
|
+
" rows)"
|
|
1482
|
+
] }),
|
|
1483
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ConfidenceDot, { confidence: table.overallConfidence })
|
|
1484
|
+
] }),
|
|
1485
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gemina-verification__table-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("table", { className: "gemina-verification__table", children: [
|
|
1486
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
|
1487
|
+
hasCoords ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { "aria-label": "Show row on document" }) : null,
|
|
1488
|
+
hasRowConfidence ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { "aria-label": "Row confidence" }) : null,
|
|
1489
|
+
table.columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { children: formatLabel(column) }, column))
|
|
1490
|
+
] }) }),
|
|
1491
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tbody", { children: table.rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1492
|
+
TableRow,
|
|
1493
|
+
{
|
|
1494
|
+
row,
|
|
1495
|
+
rowIndex,
|
|
1496
|
+
columns: table.columns,
|
|
1497
|
+
tableLabel: label,
|
|
1498
|
+
hasCoords,
|
|
1499
|
+
hasRowConfidence,
|
|
1500
|
+
shared
|
|
1501
|
+
},
|
|
1502
|
+
rowIndex
|
|
1503
|
+
)) })
|
|
1504
|
+
] }) })
|
|
1505
|
+
] });
|
|
1506
|
+
}
|
|
1507
|
+
var FallbackSection = import_react2.default.memo(function FallbackSection2(props) {
|
|
1508
|
+
const { fallback } = props;
|
|
1509
|
+
if (fallback.length === 0) {
|
|
1510
|
+
return null;
|
|
1511
|
+
}
|
|
1512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Additional Data", children: [
|
|
1513
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gemina-verification__section-header", children: "Additional Data" }),
|
|
1514
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gemina-verification__section-body", children: fallback.map((item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("details", { className: "gemina-verification__fallback", children: [
|
|
1515
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("summary", { children: formatLabel(item.key) }),
|
|
1516
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { children: JSON.stringify(item.data, null, 2) })
|
|
1517
|
+
] }, item.key)) })
|
|
1518
|
+
] });
|
|
1519
|
+
});
|
|
1520
|
+
function UnmatchedSection(props) {
|
|
1521
|
+
const { unmatched, shared } = props;
|
|
1522
|
+
if (unmatched.length === 0) {
|
|
1523
|
+
return null;
|
|
1524
|
+
}
|
|
1525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Not detected", children: [
|
|
1526
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gemina-verification__section-header", children: "Not detected" }),
|
|
1527
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dl", { className: "gemina-verification__dl", children: unmatched.map((binding) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.default.Fragment, { children: [
|
|
1528
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dt", { className: "gemina-verification__dt", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: binding.key.label }) }),
|
|
1529
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dd", { className: "gemina-verification__dd", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1530
|
+
FieldInput,
|
|
1531
|
+
{
|
|
1532
|
+
binding,
|
|
1533
|
+
edit: shared.edits.get(binding.key.raw),
|
|
1534
|
+
onEdit: shared.onEdit,
|
|
1535
|
+
readOnly: shared.readOnly,
|
|
1536
|
+
ariaLabel: binding.key.label
|
|
1537
|
+
}
|
|
1538
|
+
) })
|
|
1539
|
+
] }, binding.key.raw)) })
|
|
1540
|
+
] });
|
|
1541
|
+
}
|
|
1542
|
+
function VerificationForm(props) {
|
|
1543
|
+
const { classified, unmatched, bindingIndex, edits, onEdit, readOnly, onFlash } = props;
|
|
1544
|
+
const shared = { bindingIndex, edits, onEdit, readOnly, onFlash };
|
|
1545
|
+
return (
|
|
1546
|
+
// A real, labeled <form> (role "form" landmark): AT users can jump
|
|
1547
|
+
// straight to the editable fields. Submission is owned by the root's
|
|
1548
|
+
// footer button, never by the form element itself — preventDefault stops
|
|
1549
|
+
// implicit submission (Enter in a payload with exactly one input would
|
|
1550
|
+
// otherwise navigate).
|
|
1551
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1552
|
+
"form",
|
|
1553
|
+
{
|
|
1554
|
+
className: "gemina-verification__form",
|
|
1555
|
+
"aria-label": "Extraction fields",
|
|
1556
|
+
onSubmit: (event) => event.preventDefault(),
|
|
1557
|
+
children: [
|
|
1558
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(HeaderSection, { headers: classified.headers, simpleLists: classified.simpleLists, shared }),
|
|
1559
|
+
classified.entities.map((entity) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(EntitySection, { entity, shared }, entity.pointer)),
|
|
1560
|
+
classified.tables.map((table) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableSection, { table, shared }, table.pointer)),
|
|
1561
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FallbackSection, { fallback: classified.fallback }),
|
|
1562
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(UnmatchedSection, { unmatched, shared })
|
|
1563
|
+
]
|
|
1564
|
+
}
|
|
1565
|
+
)
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
// src/version.ts
|
|
1570
|
+
var VERSION = "0.7.0";
|
|
1571
|
+
|
|
1572
|
+
// src/verification/styles.ts
|
|
1573
|
+
var DARK_VARS = `
|
|
1574
|
+
--gemina-verification-bg: #101418;
|
|
1575
|
+
--gemina-verification-fg: #e6e9ee;
|
|
1576
|
+
--gemina-verification-border: #2a323c;
|
|
1577
|
+
--gemina-verification-accent: #4c8dff;
|
|
1578
|
+
--gemina-verification-accent-fg: #ffffff;
|
|
1579
|
+
--gemina-verification-surface: #1c232b;
|
|
1580
|
+
--gemina-verification-muted: #98a2b3;
|
|
1581
|
+
--gemina-verification-error: #f97066;
|
|
1582
|
+
--gemina-verification-input-bg: #12171d;
|
|
1583
|
+
--gemina-verification-input-border: #2a323c;
|
|
1584
|
+
--gemina-verification-dirty: #f7b27a;
|
|
1585
|
+
`;
|
|
1586
|
+
var VERIFICATION_CSS = `
|
|
1587
|
+
.gemina-verification {
|
|
1588
|
+
--gemina-verification-bg: #ffffff;
|
|
1589
|
+
--gemina-verification-fg: #1a1d21;
|
|
1590
|
+
--gemina-verification-border: #d9dce1;
|
|
1591
|
+
--gemina-verification-accent: #2f6fed;
|
|
1592
|
+
--gemina-verification-accent-fg: #ffffff;
|
|
1593
|
+
--gemina-verification-surface: #f2f4f7;
|
|
1594
|
+
--gemina-verification-muted: #667085;
|
|
1595
|
+
--gemina-verification-error: #b42318;
|
|
1596
|
+
--gemina-verification-input-bg: #ffffff;
|
|
1597
|
+
--gemina-verification-input-border: #d0d5e2;
|
|
1598
|
+
--gemina-verification-dirty: #b54708;
|
|
1599
|
+
--gemina-verification-confidence-high: #52c41a;
|
|
1600
|
+
--gemina-verification-confidence-medium: #faad14;
|
|
1601
|
+
--gemina-verification-confidence-low: #ff4d4f;
|
|
1602
|
+
--gemina-verification-confidence-unknown: #d9d9d9;
|
|
1603
|
+
--gemina-verification-overlay-rgb: 24, 144, 255;
|
|
1604
|
+
--gemina-verification-radius: 10px;
|
|
1605
|
+
--gemina-verification-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
1606
|
+
|
|
1607
|
+
box-sizing: border-box;
|
|
1608
|
+
position: relative; /* anchors __confirm; never overflow:hidden here \u2014 it would break the stacked sticky viewer */
|
|
1609
|
+
display: flex;
|
|
1610
|
+
flex-direction: column;
|
|
1611
|
+
gap: 16px;
|
|
1612
|
+
padding: 16px;
|
|
1613
|
+
background: var(--gemina-verification-bg);
|
|
1614
|
+
color: var(--gemina-verification-fg);
|
|
1615
|
+
border: 1px solid var(--gemina-verification-border);
|
|
1616
|
+
border-radius: var(--gemina-verification-radius);
|
|
1617
|
+
font-family: var(--gemina-verification-font);
|
|
1618
|
+
font-size: 14px;
|
|
1619
|
+
line-height: 1.5;
|
|
1620
|
+
}
|
|
1621
|
+
.gemina-verification *, .gemina-verification *::before, .gemina-verification *::after { box-sizing: border-box; }
|
|
1622
|
+
.gemina-verification--dark { ${DARK_VARS} }
|
|
1623
|
+
@media (prefers-color-scheme: dark) {
|
|
1624
|
+
.gemina-verification--auto { ${DARK_VARS} }
|
|
1625
|
+
}
|
|
1626
|
+
.gemina-verification--rtl { direction: rtl; }
|
|
1627
|
+
|
|
1628
|
+
/* --- Two-pane layout ------------------------------------------------------ */
|
|
1629
|
+
.gemina-verification__panes {
|
|
1630
|
+
display: grid;
|
|
1631
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
1632
|
+
gap: 16px;
|
|
1633
|
+
}
|
|
1634
|
+
.gemina-verification--stacked .gemina-verification__panes {
|
|
1635
|
+
/* Flex column, NOT a one-column grid: a sticky GRID item is confined to its
|
|
1636
|
+
own grid area \u2014 whose auto row is exactly its own height, leaving zero
|
|
1637
|
+
travel \u2014 while a sticky FLEX child's containing block is the whole panes
|
|
1638
|
+
box, so the viewer genuinely floats over the form as it scrolls. The gap
|
|
1639
|
+
carries over from the base rule. */
|
|
1640
|
+
display: flex;
|
|
1641
|
+
flex-direction: column;
|
|
1642
|
+
}
|
|
1643
|
+
.gemina-verification--stacked .gemina-verification__viewer {
|
|
1644
|
+
position: sticky;
|
|
1645
|
+
top: 0; /* block axis, not inline \u2014 RTL-safe */
|
|
1646
|
+
z-index: 2;
|
|
1647
|
+
/* Cap AND height in one declaration: the canvas is absolutely-positioned
|
|
1648
|
+
geometry with no intrinsic height (it contributes only its min-height),
|
|
1649
|
+
so a max-block-size alone would never bind \u2014 the explicit block-size is
|
|
1650
|
+
what the canvas fills. 48vh keeps the majority of a short viewport for
|
|
1651
|
+
the form the reviewer is working through; 420px stops a tall narrow
|
|
1652
|
+
window from devoting a huge sticky band to the document. The dvh line
|
|
1653
|
+
wins where supported (mobile browser chrome shrinks the visual viewport). */
|
|
1654
|
+
flex: 0 0 auto;
|
|
1655
|
+
block-size: min(48vh, 420px);
|
|
1656
|
+
block-size: min(48dvh, 420px);
|
|
1657
|
+
}
|
|
1658
|
+
.gemina-verification--stacked .gemina-verification__canvas {
|
|
1659
|
+
/* The stacked cap owns the height; the side-by-side 280px floor would
|
|
1660
|
+
overflow it on short viewports (48vh of a 568px screen is ~273px). */
|
|
1661
|
+
min-height: 120px;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
/* --- Document viewer ------------------------------------------------------ */
|
|
1665
|
+
.gemina-verification__viewer {
|
|
1666
|
+
display: flex;
|
|
1667
|
+
flex-direction: column;
|
|
1668
|
+
min-width: 0;
|
|
1669
|
+
background: var(--gemina-verification-bg);
|
|
1670
|
+
border: 1px solid var(--gemina-verification-border);
|
|
1671
|
+
border-radius: var(--gemina-verification-radius);
|
|
1672
|
+
overflow: hidden;
|
|
1673
|
+
}
|
|
1674
|
+
.gemina-verification__toolbar {
|
|
1675
|
+
display: flex;
|
|
1676
|
+
/* Narrow roots (~<330px) can't fit all 7 buttons on one line: wrap to a
|
|
1677
|
+
second row instead of clipping past the canvas edge. The gap shorthand
|
|
1678
|
+
below already provides the 6px row-gap between wrapped rows. */
|
|
1679
|
+
flex-wrap: wrap;
|
|
1680
|
+
align-items: center;
|
|
1681
|
+
gap: 6px;
|
|
1682
|
+
flex: 0 0 auto;
|
|
1683
|
+
padding: 8px 10px;
|
|
1684
|
+
border-block-end: 1px solid var(--gemina-verification-border);
|
|
1685
|
+
}
|
|
1686
|
+
.gemina-verification__toolbar-btn {
|
|
1687
|
+
font: inherit;
|
|
1688
|
+
font-size: 12px;
|
|
1689
|
+
padding: 4px 10px;
|
|
1690
|
+
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
1691
|
+
border: 1px solid var(--gemina-verification-border);
|
|
1692
|
+
background: transparent;
|
|
1693
|
+
color: var(--gemina-verification-fg);
|
|
1694
|
+
cursor: pointer;
|
|
1695
|
+
transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
|
|
1696
|
+
}
|
|
1697
|
+
.gemina-verification__toolbar-btn svg { display: block; } /* no inline-baseline slack under the icons */
|
|
1698
|
+
.gemina-verification__toolbar-btn:hover:not(:disabled) { border-color: var(--gemina-verification-accent); }
|
|
1699
|
+
.gemina-verification__toolbar-btn:disabled { opacity: 0.5; cursor: default; }
|
|
1700
|
+
.gemina-verification__toolbar-btn--active {
|
|
1701
|
+
background: var(--gemina-verification-accent);
|
|
1702
|
+
border-color: var(--gemina-verification-accent);
|
|
1703
|
+
color: var(--gemina-verification-accent-fg);
|
|
1704
|
+
}
|
|
1705
|
+
.gemina-verification__canvas {
|
|
1706
|
+
position: relative;
|
|
1707
|
+
flex: 1;
|
|
1708
|
+
min-height: 280px;
|
|
1709
|
+
overflow: hidden;
|
|
1710
|
+
background: var(--gemina-verification-surface);
|
|
1711
|
+
touch-action: none;
|
|
1712
|
+
cursor: zoom-in; /* initial truth: at fit a drag is inert, wheel/dblclick zooms */
|
|
1713
|
+
user-select: none;
|
|
1714
|
+
-webkit-user-select: none;
|
|
1715
|
+
}
|
|
1716
|
+
/* Cursor is the promise of what a drag will do, so it follows viewer state
|
|
1717
|
+
(data-cursor), never :active \u2014 a bare :active rule would claim "grabbing"
|
|
1718
|
+
at fit scale where pan never engages. */
|
|
1719
|
+
.gemina-verification__canvas[data-cursor='zoom-in'] { cursor: zoom-in; }
|
|
1720
|
+
.gemina-verification__canvas[data-cursor='grab'] { cursor: grab; }
|
|
1721
|
+
.gemina-verification__canvas[data-cursor='grabbing'] { cursor: grabbing; }
|
|
1722
|
+
/* The document image is geometry, not layout: a block box at natural size,
|
|
1723
|
+
positioned purely by the JS transform layer above it. */
|
|
1724
|
+
.gemina-verification__canvas img {
|
|
1725
|
+
display: block;
|
|
1726
|
+
max-width: unset;
|
|
1727
|
+
max-height: unset;
|
|
1728
|
+
}
|
|
1729
|
+
/* Overlay geometry (left/top/width/height) is set inline by the viewer from
|
|
1730
|
+
transform math; CSS owns only the appearance. */
|
|
1731
|
+
.gemina-verification__rect {
|
|
1732
|
+
position: absolute;
|
|
1733
|
+
z-index: 2;
|
|
1734
|
+
pointer-events: none;
|
|
1735
|
+
border: 2px solid rgba(var(--gemina-verification-overlay-rgb), 0.85);
|
|
1736
|
+
background: rgba(var(--gemina-verification-overlay-rgb), 0.16);
|
|
1737
|
+
border-radius: 2px;
|
|
1738
|
+
}
|
|
1739
|
+
/* Numbered "#1" chip on each overlay rect. Physical left/top: the badge lives
|
|
1740
|
+
in image coordinate space inside the transform layer (geometry, not layout),
|
|
1741
|
+
so it scales and rotates with the document exactly like the console's.
|
|
1742
|
+
Explicit line-height pins the chip height across host font stacks. */
|
|
1743
|
+
.gemina-verification__rect-badge {
|
|
1744
|
+
position: absolute;
|
|
1745
|
+
top: -18px;
|
|
1746
|
+
left: 0;
|
|
1747
|
+
font-size: 11px;
|
|
1748
|
+
font-weight: 600;
|
|
1749
|
+
line-height: 16px;
|
|
1750
|
+
color: rgb(var(--gemina-verification-overlay-rgb));
|
|
1751
|
+
background: rgba(255, 255, 255, 0.92); /* floats over the document, not the theme surface */
|
|
1752
|
+
padding: 0 6px;
|
|
1753
|
+
border-radius: 12px;
|
|
1754
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
|
|
1755
|
+
pointer-events: none;
|
|
1756
|
+
}
|
|
1757
|
+
.gemina-verification__flash-rect {
|
|
1758
|
+
/* Fade is driven by JS via element-level opacity (rAF travel animation);
|
|
1759
|
+
no CSS animation here so the two never fight. Element-level opacity is
|
|
1760
|
+
equivalent to the console's per-channel fade \u2014 border (1\xB7o), background
|
|
1761
|
+
(0.25\xB7o), glow (0.6\xB7o / 0.3\xB7o) \u2014 modulo overlapping-layer compositing:
|
|
1762
|
+
per-channel alphas blend border-over-background where they overlap,
|
|
1763
|
+
element opacity flattens the group first. Indistinguishable in practice. */
|
|
1764
|
+
position: absolute;
|
|
1765
|
+
z-index: 3;
|
|
1766
|
+
pointer-events: none;
|
|
1767
|
+
border: 5px solid rgba(var(--gemina-verification-overlay-rgb), 1);
|
|
1768
|
+
background: rgba(var(--gemina-verification-overlay-rgb), 0.25);
|
|
1769
|
+
box-shadow: 0 0 20px rgba(var(--gemina-verification-overlay-rgb), 0.6),
|
|
1770
|
+
inset 0 0 10px rgba(var(--gemina-verification-overlay-rgb), 0.3);
|
|
1771
|
+
border-radius: 2px;
|
|
1772
|
+
}
|
|
1773
|
+
.gemina-verification__magnifier {
|
|
1774
|
+
position: absolute;
|
|
1775
|
+
z-index: 4;
|
|
1776
|
+
pointer-events: none;
|
|
1777
|
+
overflow: hidden;
|
|
1778
|
+
border-radius: 50%;
|
|
1779
|
+
border: 2px solid rgba(255, 255, 255, 0.85);
|
|
1780
|
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
|
|
1781
|
+
background: var(--gemina-verification-surface);
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
/* --- Form pane ------------------------------------------------------------ */
|
|
1785
|
+
/* A real <form> element (labeled AT landmark) \u2014 margin reset guards against
|
|
1786
|
+
host/UA form margins. */
|
|
1787
|
+
.gemina-verification__form {
|
|
1788
|
+
display: flex;
|
|
1789
|
+
flex-direction: column;
|
|
1790
|
+
gap: 12px;
|
|
1791
|
+
min-width: 0;
|
|
1792
|
+
margin: 0;
|
|
1793
|
+
}
|
|
1794
|
+
.gemina-verification__section {
|
|
1795
|
+
background: var(--gemina-verification-bg);
|
|
1796
|
+
border: 1px solid var(--gemina-verification-border);
|
|
1797
|
+
border-radius: var(--gemina-verification-radius);
|
|
1798
|
+
overflow: hidden;
|
|
1799
|
+
}
|
|
1800
|
+
.gemina-verification__section-header {
|
|
1801
|
+
display: flex;
|
|
1802
|
+
align-items: center;
|
|
1803
|
+
gap: 8px;
|
|
1804
|
+
padding: 8px 12px;
|
|
1805
|
+
background: var(--gemina-verification-surface);
|
|
1806
|
+
border-block-end: 1px solid var(--gemina-verification-border);
|
|
1807
|
+
font-size: 13px;
|
|
1808
|
+
font-weight: 600;
|
|
1809
|
+
}
|
|
1810
|
+
.gemina-verification__dl {
|
|
1811
|
+
display: grid;
|
|
1812
|
+
grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
|
|
1813
|
+
column-gap: 12px;
|
|
1814
|
+
margin: 0;
|
|
1815
|
+
padding: 8px 12px;
|
|
1816
|
+
}
|
|
1817
|
+
.gemina-verification__dt {
|
|
1818
|
+
display: flex;
|
|
1819
|
+
align-items: center;
|
|
1820
|
+
gap: 6px;
|
|
1821
|
+
padding-block: 5px;
|
|
1822
|
+
min-width: 0;
|
|
1823
|
+
font-size: 12px;
|
|
1824
|
+
color: var(--gemina-verification-muted);
|
|
1825
|
+
overflow-wrap: break-word;
|
|
1826
|
+
}
|
|
1827
|
+
.gemina-verification__dd {
|
|
1828
|
+
display: flex;
|
|
1829
|
+
align-items: center;
|
|
1830
|
+
gap: 6px;
|
|
1831
|
+
margin: 0; /* resets the UA's margin-inline-start on <dd> */
|
|
1832
|
+
padding-block: 5px;
|
|
1833
|
+
min-width: 0;
|
|
1834
|
+
font-size: 13px;
|
|
1835
|
+
font-variant-numeric: tabular-nums;
|
|
1836
|
+
overflow-wrap: break-word;
|
|
1837
|
+
}
|
|
1838
|
+
.gemina-verification__input {
|
|
1839
|
+
width: 100%;
|
|
1840
|
+
font: inherit;
|
|
1841
|
+
font-size: 13px;
|
|
1842
|
+
color: var(--gemina-verification-fg);
|
|
1843
|
+
background: var(--gemina-verification-input-bg);
|
|
1844
|
+
border: 1px solid var(--gemina-verification-input-border);
|
|
1845
|
+
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
1846
|
+
padding: 5px 8px;
|
|
1847
|
+
}
|
|
1848
|
+
.gemina-verification__input--dirty { border-color: var(--gemina-verification-dirty); }
|
|
1849
|
+
.gemina-verification__input--missed {
|
|
1850
|
+
border-color: var(--gemina-verification-error);
|
|
1851
|
+
box-shadow: 0 0 0 1px var(--gemina-verification-error);
|
|
1852
|
+
}
|
|
1853
|
+
/* Non-color dirty channel: the word itself is the signal (WCAG 1.4.1) \u2014 it
|
|
1854
|
+
stays legible when --missed's error border overrides the dirty border. */
|
|
1855
|
+
.gemina-verification__edited {
|
|
1856
|
+
flex: 0 0 auto;
|
|
1857
|
+
font-size: 10px;
|
|
1858
|
+
font-weight: 600;
|
|
1859
|
+
letter-spacing: 0.06em;
|
|
1860
|
+
text-transform: uppercase;
|
|
1861
|
+
color: var(--gemina-verification-dirty);
|
|
1862
|
+
}
|
|
1863
|
+
.gemina-verification__dot {
|
|
1864
|
+
display: inline-block;
|
|
1865
|
+
flex: 0 0 auto;
|
|
1866
|
+
width: 8px;
|
|
1867
|
+
height: 8px;
|
|
1868
|
+
border-radius: 50%;
|
|
1869
|
+
background: var(--gemina-verification-confidence-unknown);
|
|
1870
|
+
}
|
|
1871
|
+
.gemina-verification__dot--high { background: var(--gemina-verification-confidence-high); }
|
|
1872
|
+
.gemina-verification__dot--medium { background: var(--gemina-verification-confidence-medium); }
|
|
1873
|
+
.gemina-verification__dot--low { background: var(--gemina-verification-confidence-low); }
|
|
1874
|
+
.gemina-verification__dot--unknown { background: var(--gemina-verification-confidence-unknown); }
|
|
1875
|
+
.gemina-verification__eye {
|
|
1876
|
+
display: inline-flex;
|
|
1877
|
+
align-items: center;
|
|
1878
|
+
justify-content: center;
|
|
1879
|
+
flex: 0 0 auto;
|
|
1880
|
+
width: 24px;
|
|
1881
|
+
height: 24px;
|
|
1882
|
+
padding: 0;
|
|
1883
|
+
border: 0;
|
|
1884
|
+
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
1885
|
+
background: transparent;
|
|
1886
|
+
color: var(--gemina-verification-muted);
|
|
1887
|
+
cursor: pointer;
|
|
1888
|
+
transition: background-color 120ms ease, color 120ms ease;
|
|
1889
|
+
}
|
|
1890
|
+
.gemina-verification__eye:hover {
|
|
1891
|
+
color: var(--gemina-verification-accent);
|
|
1892
|
+
background: var(--gemina-verification-surface);
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
/* --- Tables and cards ----------------------------------------------------- */
|
|
1896
|
+
/* Section content that is not flush with the section frame (cards, fallback
|
|
1897
|
+
details) sits inside this padded body. */
|
|
1898
|
+
.gemina-verification__section-body { padding: 8px 12px; }
|
|
1899
|
+
/* Flex row for FieldInput's fragment (input + "edited" badge) inside <td>s
|
|
1900
|
+
and list items \u2014 the fragment has no container of its own. */
|
|
1901
|
+
.gemina-verification__cell {
|
|
1902
|
+
display: flex;
|
|
1903
|
+
align-items: center;
|
|
1904
|
+
gap: 6px;
|
|
1905
|
+
min-width: 0;
|
|
1906
|
+
}
|
|
1907
|
+
/* Simple-list items stack inside a __dd; each item row is a __cell. */
|
|
1908
|
+
.gemina-verification__list {
|
|
1909
|
+
display: flex;
|
|
1910
|
+
flex-direction: column;
|
|
1911
|
+
gap: 4px;
|
|
1912
|
+
flex: 1 1 auto;
|
|
1913
|
+
min-width: 0;
|
|
1914
|
+
margin: 0;
|
|
1915
|
+
padding: 0;
|
|
1916
|
+
list-style: none;
|
|
1917
|
+
}
|
|
1918
|
+
.gemina-verification__table-wrap { overflow-x: auto; }
|
|
1919
|
+
.gemina-verification__table {
|
|
1920
|
+
width: 100%;
|
|
1921
|
+
border-collapse: collapse;
|
|
1922
|
+
font-size: 13px;
|
|
1923
|
+
font-variant-numeric: tabular-nums;
|
|
1924
|
+
}
|
|
1925
|
+
.gemina-verification__table th {
|
|
1926
|
+
text-align: start;
|
|
1927
|
+
padding: 6px 10px;
|
|
1928
|
+
font-size: 12px;
|
|
1929
|
+
font-weight: 600;
|
|
1930
|
+
color: var(--gemina-verification-muted);
|
|
1931
|
+
background: var(--gemina-verification-surface);
|
|
1932
|
+
border-block-end: 1px solid var(--gemina-verification-border);
|
|
1933
|
+
}
|
|
1934
|
+
.gemina-verification__table td {
|
|
1935
|
+
padding: 6px 10px;
|
|
1936
|
+
vertical-align: top;
|
|
1937
|
+
border-block-end: 1px solid var(--gemina-verification-border);
|
|
1938
|
+
}
|
|
1939
|
+
.gemina-verification__table tr:last-child td { border-block-end: 0; }
|
|
1940
|
+
/* Wide tables lean on __table-wrap's scroll; the clamp keeps a cell input
|
|
1941
|
+
usable instead of letting the table squeeze it to nothing. */
|
|
1942
|
+
.gemina-verification__table .gemina-verification__input { min-width: 6ch; }
|
|
1943
|
+
.gemina-verification__card {
|
|
1944
|
+
display: flex;
|
|
1945
|
+
flex-direction: column;
|
|
1946
|
+
gap: 6px;
|
|
1947
|
+
padding: 10px 12px;
|
|
1948
|
+
background: var(--gemina-verification-bg);
|
|
1949
|
+
border: 1px solid var(--gemina-verification-border);
|
|
1950
|
+
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
1951
|
+
}
|
|
1952
|
+
.gemina-verification__card + .gemina-verification__card { margin-block-start: 8px; }
|
|
1953
|
+
.gemina-verification__card-header {
|
|
1954
|
+
font-size: 12px;
|
|
1955
|
+
font-weight: 600;
|
|
1956
|
+
color: var(--gemina-verification-muted);
|
|
1957
|
+
}
|
|
1958
|
+
/* The card already pads; its inner description list must not double it. */
|
|
1959
|
+
.gemina-verification__card .gemina-verification__dl { padding: 0; }
|
|
1960
|
+
/* Fallback blobs are a native <details>: summary is the toggle, the JSON
|
|
1961
|
+
lives in a <pre> so only the code is monospace/pre-wrapped. */
|
|
1962
|
+
.gemina-verification__fallback {
|
|
1963
|
+
margin: 0;
|
|
1964
|
+
padding: 8px 12px;
|
|
1965
|
+
font-size: 12px;
|
|
1966
|
+
background: var(--gemina-verification-surface);
|
|
1967
|
+
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
1968
|
+
}
|
|
1969
|
+
.gemina-verification__fallback + .gemina-verification__fallback { margin-block-start: 8px; }
|
|
1970
|
+
.gemina-verification__fallback summary {
|
|
1971
|
+
cursor: pointer;
|
|
1972
|
+
font-weight: 600;
|
|
1973
|
+
user-select: none;
|
|
1974
|
+
}
|
|
1975
|
+
.gemina-verification__fallback pre {
|
|
1976
|
+
margin: 0;
|
|
1977
|
+
margin-block-start: 8px;
|
|
1978
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
1979
|
+
white-space: pre-wrap;
|
|
1980
|
+
overflow-wrap: break-word;
|
|
1981
|
+
overflow-x: auto;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
/* --- Messaging, progress, actions ----------------------------------------- */
|
|
1985
|
+
.gemina-verification__banner {
|
|
1986
|
+
padding: 10px 12px;
|
|
1987
|
+
font-size: 13px;
|
|
1988
|
+
background: var(--gemina-verification-surface);
|
|
1989
|
+
border: 1px solid var(--gemina-verification-border);
|
|
1990
|
+
border-radius: var(--gemina-verification-radius);
|
|
1991
|
+
}
|
|
1992
|
+
.gemina-verification__banner--error {
|
|
1993
|
+
background: transparent;
|
|
1994
|
+
border-color: var(--gemina-verification-error);
|
|
1995
|
+
color: var(--gemina-verification-error);
|
|
1996
|
+
}
|
|
1997
|
+
.gemina-verification__progress {
|
|
1998
|
+
font-size: 12px;
|
|
1999
|
+
color: var(--gemina-verification-muted);
|
|
2000
|
+
font-variant-numeric: tabular-nums;
|
|
2001
|
+
/* The counts copy ("N confirmed \xB7 M corrected") is untranslated English
|
|
2002
|
+
chrome; under dir="rtl" the RTL paragraph direction reorders its
|
|
2003
|
+
leading-number run ("confirmed \xB7 0 corrected 7"). plaintext makes the
|
|
2004
|
+
line take its base direction from its own first strong character, so
|
|
2005
|
+
the English copy lays out LTR inside the RTL widget. The done-state
|
|
2006
|
+
recap reuses this same class, so it is covered too. */
|
|
2007
|
+
unicode-bidi: plaintext;
|
|
2008
|
+
}
|
|
2009
|
+
.gemina-verification__footer {
|
|
2010
|
+
display: flex;
|
|
2011
|
+
align-items: center;
|
|
2012
|
+
gap: 10px;
|
|
2013
|
+
padding-block-start: 12px;
|
|
2014
|
+
border-block-start: 1px solid var(--gemina-verification-border);
|
|
2015
|
+
}
|
|
2016
|
+
.gemina-verification__footer .gemina-verification__submit { margin-inline-start: auto; }
|
|
2017
|
+
.gemina-verification__submit {
|
|
2018
|
+
font: inherit;
|
|
2019
|
+
border: none;
|
|
2020
|
+
border-radius: var(--gemina-verification-radius);
|
|
2021
|
+
background: var(--gemina-verification-accent);
|
|
2022
|
+
color: var(--gemina-verification-accent-fg);
|
|
2023
|
+
padding: 8px 16px;
|
|
2024
|
+
cursor: pointer;
|
|
2025
|
+
}
|
|
2026
|
+
.gemina-verification__submit:disabled { opacity: 0.5; cursor: default; }
|
|
2027
|
+
.gemina-verification__retry {
|
|
2028
|
+
font: inherit;
|
|
2029
|
+
font-size: 12px;
|
|
2030
|
+
padding: 2px 10px;
|
|
2031
|
+
border-radius: var(--gemina-verification-radius);
|
|
2032
|
+
border: 1px solid var(--gemina-verification-error);
|
|
2033
|
+
background: transparent;
|
|
2034
|
+
color: var(--gemina-verification-error);
|
|
2035
|
+
cursor: pointer;
|
|
2036
|
+
}
|
|
2037
|
+
.gemina-verification__state {
|
|
2038
|
+
display: flex;
|
|
2039
|
+
flex-direction: column;
|
|
2040
|
+
align-items: center;
|
|
2041
|
+
justify-content: center;
|
|
2042
|
+
gap: 8px;
|
|
2043
|
+
min-height: 220px;
|
|
2044
|
+
padding: 24px;
|
|
2045
|
+
text-align: center;
|
|
2046
|
+
font-size: 13px;
|
|
2047
|
+
color: var(--gemina-verification-muted);
|
|
2048
|
+
}
|
|
2049
|
+
/* Submit-error banner: message + inline Retry on one line. */
|
|
2050
|
+
.gemina-verification__submit-error {
|
|
2051
|
+
display: flex;
|
|
2052
|
+
align-items: center;
|
|
2053
|
+
justify-content: space-between;
|
|
2054
|
+
gap: 10px;
|
|
2055
|
+
}
|
|
2056
|
+
/* Done: the one saturated moment outside the form \u2014 a single accent check. */
|
|
2057
|
+
.gemina-verification__state--done { color: var(--gemina-verification-fg); }
|
|
2058
|
+
/* Programmatic focus landing (tabIndex -1), not an interactive control: no
|
|
2059
|
+
ring \u2014 the accent check IS the visual landing; focus moves here purely so
|
|
2060
|
+
keyboard/AT users don't drop to <body> when the dialog unmounts. */
|
|
2061
|
+
.gemina-verification__state--done:focus,
|
|
2062
|
+
.gemina-verification__state--done:focus-visible { outline: none; }
|
|
2063
|
+
.gemina-verification__done-check {
|
|
2064
|
+
display: flex;
|
|
2065
|
+
align-items: center;
|
|
2066
|
+
justify-content: center;
|
|
2067
|
+
width: 40px;
|
|
2068
|
+
height: 40px;
|
|
2069
|
+
border-radius: 50%;
|
|
2070
|
+
background: var(--gemina-verification-accent);
|
|
2071
|
+
color: var(--gemina-verification-accent-fg);
|
|
2072
|
+
}
|
|
2073
|
+
.gemina-verification__done-title {
|
|
2074
|
+
font-size: 14px;
|
|
2075
|
+
font-weight: 600;
|
|
2076
|
+
}
|
|
2077
|
+
.gemina-verification__state--done .gemina-verification__progress { font-size: 13px; }
|
|
2078
|
+
|
|
2079
|
+
/* --- Confirm dialog ------------------------------------------------------- */
|
|
2080
|
+
.gemina-verification__confirm {
|
|
2081
|
+
position: absolute;
|
|
2082
|
+
inset: 0;
|
|
2083
|
+
z-index: 10;
|
|
2084
|
+
display: flex;
|
|
2085
|
+
/* flex-start + a sticky dialog: the scrim spans the whole component, but the
|
|
2086
|
+
dialog slides with the page so it is in view even when the user is
|
|
2087
|
+
scrolled deep into a long stacked form. Sticky (not fixed) so it survives
|
|
2088
|
+
transformed-ancestor hosts where fixed re-anchors. */
|
|
2089
|
+
align-items: flex-start;
|
|
2090
|
+
justify-content: center;
|
|
2091
|
+
padding: 16px;
|
|
2092
|
+
background: rgba(16, 20, 24, 0.45);
|
|
2093
|
+
border-radius: var(--gemina-verification-radius);
|
|
2094
|
+
}
|
|
2095
|
+
.gemina-verification__confirm-dialog {
|
|
2096
|
+
position: sticky;
|
|
2097
|
+
top: 20vh; /* block axis \u2014 RTL-safe */
|
|
2098
|
+
display: flex;
|
|
2099
|
+
flex-direction: column;
|
|
2100
|
+
gap: 12px;
|
|
2101
|
+
width: 100%;
|
|
2102
|
+
max-width: 380px;
|
|
2103
|
+
padding: 16px;
|
|
2104
|
+
background: var(--gemina-verification-bg);
|
|
2105
|
+
color: var(--gemina-verification-fg);
|
|
2106
|
+
border: 1px solid var(--gemina-verification-border);
|
|
2107
|
+
border-radius: var(--gemina-verification-radius);
|
|
2108
|
+
box-shadow: 0 12px 32px rgba(16, 20, 24, 0.24);
|
|
2109
|
+
}
|
|
2110
|
+
.gemina-verification__confirm-text {
|
|
2111
|
+
margin: 0;
|
|
2112
|
+
font-size: 13px;
|
|
2113
|
+
}
|
|
2114
|
+
.gemina-verification__confirm-actions {
|
|
2115
|
+
display: flex;
|
|
2116
|
+
justify-content: flex-end;
|
|
2117
|
+
gap: 8px;
|
|
2118
|
+
}
|
|
2119
|
+
/* Quiet counterpart to __submit: same geometry, bordered, no fill \u2014 the
|
|
2120
|
+
accent stays on the final action. */
|
|
2121
|
+
.gemina-verification__confirm-cancel {
|
|
2122
|
+
font: inherit;
|
|
2123
|
+
padding: 8px 16px;
|
|
2124
|
+
border: 1px solid var(--gemina-verification-border);
|
|
2125
|
+
border-radius: var(--gemina-verification-radius);
|
|
2126
|
+
background: transparent;
|
|
2127
|
+
color: var(--gemina-verification-fg);
|
|
2128
|
+
cursor: pointer;
|
|
2129
|
+
transition: border-color 120ms ease;
|
|
2130
|
+
}
|
|
2131
|
+
.gemina-verification__confirm-cancel:hover:not(:disabled) {
|
|
2132
|
+
border-color: var(--gemina-verification-accent);
|
|
2133
|
+
}
|
|
2134
|
+
.gemina-verification__confirm-cancel:disabled { opacity: 0.5; cursor: default; }
|
|
2135
|
+
|
|
2136
|
+
/* --- Focus ---------------------------------------------------------------- */
|
|
2137
|
+
.gemina-verification__input:focus-visible {
|
|
2138
|
+
outline: 2px solid var(--gemina-verification-accent);
|
|
2139
|
+
outline-offset: -1px;
|
|
2140
|
+
}
|
|
2141
|
+
.gemina-verification__toolbar-btn:focus-visible,
|
|
2142
|
+
.gemina-verification__eye:focus-visible,
|
|
2143
|
+
.gemina-verification__submit:focus-visible,
|
|
2144
|
+
.gemina-verification__retry:focus-visible,
|
|
2145
|
+
.gemina-verification__confirm-cancel:focus-visible,
|
|
2146
|
+
.gemina-verification__fallback summary:focus-visible {
|
|
2147
|
+
outline: 2px solid var(--gemina-verification-accent);
|
|
2148
|
+
outline-offset: 1px;
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
/* --- Reduced motion -------------------------------------------------------- */
|
|
2152
|
+
/* The viewer also checks this in JS before animating; the CSS block is the
|
|
2153
|
+
backstop that stills the canvas (flash, travel, micro-transitions). */
|
|
2154
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2155
|
+
.gemina-verification__flash-rect,
|
|
2156
|
+
.gemina-verification__rect,
|
|
2157
|
+
.gemina-verification__canvas,
|
|
2158
|
+
.gemina-verification__canvas * {
|
|
2159
|
+
animation: none;
|
|
2160
|
+
transition: none;
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
`;
|
|
2164
|
+
var STYLE_ATTR = "data-gemina-verification";
|
|
2165
|
+
function ensureVerificationStylesInjected() {
|
|
2166
|
+
if (typeof document === "undefined") {
|
|
2167
|
+
return;
|
|
2168
|
+
}
|
|
2169
|
+
if (document.head.querySelector(`style[${STYLE_ATTR}]`) !== null) {
|
|
2170
|
+
return;
|
|
2171
|
+
}
|
|
2172
|
+
const style = document.createElement("style");
|
|
2173
|
+
style.setAttribute(STYLE_ATTR, VERSION);
|
|
2174
|
+
style.textContent = VERIFICATION_CSS;
|
|
2175
|
+
document.head.appendChild(style);
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
// src/verification/index.tsx
|
|
2179
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2180
|
+
var HEBREW_RE = /[\u0590-\u05FF]/;
|
|
2181
|
+
var STACKED_BREAKPOINT = 860;
|
|
2182
|
+
var IMAGE_REFRESH_THROTTLE_MS = 6e4;
|
|
2183
|
+
var LOADING_TEXT = "Loading extraction\u2026";
|
|
2184
|
+
var SESSION_EXPIRED_TEXT = "Session expired \u2014 please reload the page or sign in again.";
|
|
2185
|
+
var SUBMIT_SESSION_EXPIRED_TEXT = "Session expired \u2014 sign in again in another tab, then press Retry. Your corrections are still here.";
|
|
2186
|
+
var NOT_AVAILABLE_TEXT = "This extraction is not available.";
|
|
2187
|
+
var LOAD_FAILED_TEXT = "Couldn't load the extraction.";
|
|
2188
|
+
var PURGED_TEXT = "Document no longer available (retention policy).";
|
|
2189
|
+
var NOT_COMPLETED_TEXT = "This extraction did not complete, so there is nothing to verify.";
|
|
2190
|
+
var VERIFICATION_UNAVAILABLE_TEXT = "Verification isn't available for this extraction.";
|
|
2191
|
+
var ALREADY_VALIDATED_TEXT = "Already verified \u2014 showing the original extraction.";
|
|
2192
|
+
var CONFIRM_TEXT = "Submit verification? This is final \u2014 feedback can be submitted only once and cannot be changed.";
|
|
2193
|
+
var SUBMITTING_TEXT = "Submitting\u2026";
|
|
2194
|
+
var SUBMIT_FAILED_TEXT = "Submission failed \u2014 your corrections are still here.";
|
|
2195
|
+
var DONE_TITLE_TEXT = "Feedback submitted";
|
|
2196
|
+
var NO_EDITS = /* @__PURE__ */ new Map();
|
|
2197
|
+
var ALERT_REASONS = /* @__PURE__ */ new Set([
|
|
2198
|
+
"session-expired",
|
|
2199
|
+
"not-available",
|
|
2200
|
+
"load-failed"
|
|
2201
|
+
]);
|
|
2202
|
+
function GeminaVerification(props) {
|
|
2203
|
+
const {
|
|
2204
|
+
extractionId,
|
|
2205
|
+
tokenManager,
|
|
2206
|
+
baseUrl,
|
|
2207
|
+
theme = "auto",
|
|
2208
|
+
dir = "auto",
|
|
2209
|
+
onComplete,
|
|
2210
|
+
onError,
|
|
2211
|
+
className
|
|
2212
|
+
} = props;
|
|
2213
|
+
const [phase, setPhase] = (0, import_react3.useState)({ name: "loading" });
|
|
2214
|
+
const [alreadyValidated, setAlreadyValidated] = (0, import_react3.useState)(false);
|
|
2215
|
+
const [loaded, setLoaded] = (0, import_react3.useState)(null);
|
|
2216
|
+
const [edits, setEdits] = (0, import_react3.useState)(NO_EDITS);
|
|
2217
|
+
const [imageUrl, setImageUrl] = (0, import_react3.useState)(null);
|
|
2218
|
+
const [flashRects, setFlashRects] = (0, import_react3.useState)(null);
|
|
2219
|
+
const [stacked, setStacked] = (0, import_react3.useState)(false);
|
|
2220
|
+
const rootRef = (0, import_react3.useRef)(null);
|
|
2221
|
+
const mountedRef = (0, import_react3.useRef)(false);
|
|
2222
|
+
const loadSeqRef = (0, import_react3.useRef)(0);
|
|
2223
|
+
const lastImageRefreshRef = (0, import_react3.useRef)(0);
|
|
2224
|
+
const onErrorRef = (0, import_react3.useRef)(onError);
|
|
2225
|
+
onErrorRef.current = onError;
|
|
2226
|
+
const onCompleteRef = (0, import_react3.useRef)(onComplete);
|
|
2227
|
+
onCompleteRef.current = onComplete;
|
|
2228
|
+
const completedRef = (0, import_react3.useRef)(false);
|
|
2229
|
+
const submitInFlightRef = (0, import_react3.useRef)(false);
|
|
2230
|
+
const restoreFocusRef = (0, import_react3.useRef)(false);
|
|
2231
|
+
const submitButtonRef = (0, import_react3.useRef)(null);
|
|
2232
|
+
const confirmButtonRef = (0, import_react3.useRef)(null);
|
|
2233
|
+
const cancelButtonRef = (0, import_react3.useRef)(null);
|
|
2234
|
+
const retrySubmitButtonRef = (0, import_react3.useRef)(null);
|
|
2235
|
+
const doneStateRef = (0, import_react3.useRef)(null);
|
|
2236
|
+
const enterUnavailable = (0, import_react3.useCallback)(
|
|
2237
|
+
(reason, message, canRetry, detail) => {
|
|
2238
|
+
setPhase({ name: "unavailable", reason, message, canRetry });
|
|
2239
|
+
onErrorRef.current?.(reason, detail);
|
|
2240
|
+
},
|
|
2241
|
+
[]
|
|
2242
|
+
);
|
|
2243
|
+
const fetchOnce = (0, import_react3.useCallback)(async () => {
|
|
2244
|
+
const token = await tokenManager.getToken();
|
|
2245
|
+
return import_sdk.GeminaClient.withSessionToken(token, baseUrl).documents.getDocumentExtraction({
|
|
2246
|
+
documentExtractionId: extractionId
|
|
2247
|
+
});
|
|
2248
|
+
}, [tokenManager, baseUrl, extractionId]);
|
|
2249
|
+
const fetchWithRetry = (0, import_react3.useCallback)(async () => {
|
|
2250
|
+
try {
|
|
2251
|
+
return await fetchOnce();
|
|
2252
|
+
} catch (error) {
|
|
2253
|
+
if (httpStatus(error) !== 401) {
|
|
2254
|
+
throw error;
|
|
2255
|
+
}
|
|
2256
|
+
tokenManager.invalidate();
|
|
2257
|
+
return await fetchOnce();
|
|
2258
|
+
}
|
|
2259
|
+
}, [fetchOnce, tokenManager]);
|
|
2260
|
+
const load = (0, import_react3.useCallback)(async () => {
|
|
2261
|
+
const seq = ++loadSeqRef.current;
|
|
2262
|
+
const live = () => mountedRef.current && loadSeqRef.current === seq;
|
|
2263
|
+
setPhase({ name: "loading" });
|
|
2264
|
+
completedRef.current = false;
|
|
2265
|
+
setFlashRects(null);
|
|
2266
|
+
lastImageRefreshRef.current = 0;
|
|
2267
|
+
let view;
|
|
2268
|
+
try {
|
|
2269
|
+
view = await fetchWithRetry();
|
|
2270
|
+
} catch (error) {
|
|
2271
|
+
const detail = await readErrorEnvelope(error);
|
|
2272
|
+
if (!live()) {
|
|
2273
|
+
return;
|
|
2274
|
+
}
|
|
2275
|
+
if (detail.status === 401) {
|
|
2276
|
+
enterUnavailable("session-expired", SESSION_EXPIRED_TEXT, false, detail);
|
|
2277
|
+
} else if (detail.status === 404) {
|
|
2278
|
+
enterUnavailable("not-available", NOT_AVAILABLE_TEXT, false, detail);
|
|
2279
|
+
} else {
|
|
2280
|
+
enterUnavailable("load-failed", LOAD_FAILED_TEXT, true, detail);
|
|
2281
|
+
}
|
|
2282
|
+
return;
|
|
2283
|
+
}
|
|
2284
|
+
if (!live()) {
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
const enterReview = (validated) => {
|
|
2288
|
+
const schema = view.meta.validationFeedback?.validationSchema;
|
|
2289
|
+
setLoaded({
|
|
2290
|
+
values: view.values,
|
|
2291
|
+
schema: Array.isArray(schema) ? schema : []
|
|
2292
|
+
});
|
|
2293
|
+
setEdits(NO_EDITS);
|
|
2294
|
+
const url = view.document.imageUrl;
|
|
2295
|
+
setImageUrl(typeof url === "string" && url.length > 0 ? url : null);
|
|
2296
|
+
setAlreadyValidated(validated);
|
|
2297
|
+
setPhase({ name: "review" });
|
|
2298
|
+
};
|
|
2299
|
+
if (view.meta.purgedAt != null) {
|
|
2300
|
+
enterUnavailable("purged", PURGED_TEXT, false);
|
|
2301
|
+
} else if (view.meta.processingStatus !== "success") {
|
|
2302
|
+
enterUnavailable("not-completed", NOT_COMPLETED_TEXT, false);
|
|
2303
|
+
} else if (view.meta.validated === true) {
|
|
2304
|
+
enterReview(true);
|
|
2305
|
+
} else if (!Array.isArray(view.meta.validationFeedback?.validationSchema) || view.meta.validationFeedback.validationSchema.length === 0) {
|
|
2306
|
+
enterUnavailable("verification-unavailable", VERIFICATION_UNAVAILABLE_TEXT, false);
|
|
2307
|
+
} else {
|
|
2308
|
+
enterReview(false);
|
|
2309
|
+
}
|
|
2310
|
+
}, [fetchWithRetry, enterUnavailable]);
|
|
2311
|
+
(0, import_react3.useEffect)(() => {
|
|
2312
|
+
mountedRef.current = true;
|
|
2313
|
+
ensureVerificationStylesInjected();
|
|
2314
|
+
void load();
|
|
2315
|
+
return () => {
|
|
2316
|
+
mountedRef.current = false;
|
|
2317
|
+
};
|
|
2318
|
+
}, [load]);
|
|
2319
|
+
(0, import_react3.useEffect)(() => {
|
|
2320
|
+
const el = rootRef.current;
|
|
2321
|
+
if (el === null) {
|
|
2322
|
+
return;
|
|
2323
|
+
}
|
|
2324
|
+
const apply = (width) => setStacked(width > 0 && width < STACKED_BREAKPOINT);
|
|
2325
|
+
if (typeof ResizeObserver === "undefined") {
|
|
2326
|
+
apply(el.getBoundingClientRect().width);
|
|
2327
|
+
return;
|
|
2328
|
+
}
|
|
2329
|
+
const observer = new ResizeObserver((entries) => {
|
|
2330
|
+
const entry = entries[0];
|
|
2331
|
+
if (!entry) {
|
|
2332
|
+
return;
|
|
2333
|
+
}
|
|
2334
|
+
const width = entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width;
|
|
2335
|
+
apply(width);
|
|
2336
|
+
});
|
|
2337
|
+
observer.observe(el);
|
|
2338
|
+
return () => observer.disconnect();
|
|
2339
|
+
}, []);
|
|
2340
|
+
const classified = (0, import_react3.useMemo)(() => classifyData(loaded?.values), [loaded]);
|
|
2341
|
+
const bindings = (0, import_react3.useMemo)(() => buildBindings(loaded?.schema ?? [], loaded?.values), [loaded]);
|
|
2342
|
+
const bindingIndex = (0, import_react3.useMemo)(() => indexBindingsByFieldPointer(bindings), [bindings]);
|
|
2343
|
+
const unmatched = (0, import_react3.useMemo)(() => {
|
|
2344
|
+
const rendered = /* @__PURE__ */ new Set();
|
|
2345
|
+
for (const field of classified.headers) {
|
|
2346
|
+
rendered.add(field.pointer);
|
|
2347
|
+
}
|
|
2348
|
+
for (const list of classified.simpleLists) {
|
|
2349
|
+
for (const item of list.items) {
|
|
2350
|
+
rendered.add(item.pointer);
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
for (const entity of classified.entities) {
|
|
2354
|
+
for (const item of entity.items) {
|
|
2355
|
+
for (const cell of Object.values(item)) {
|
|
2356
|
+
rendered.add(cell.pointer);
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
for (const table of classified.tables) {
|
|
2361
|
+
for (const row of table.rows) {
|
|
2362
|
+
for (const [key, cell] of Object.entries(row)) {
|
|
2363
|
+
if (key !== ROW_META_KEY) {
|
|
2364
|
+
rendered.add(cell.pointer);
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
return bindings.filter((binding) => !rendered.has(binding.fieldPointer));
|
|
2370
|
+
}, [classified, bindings]);
|
|
2371
|
+
const overlayRects = (0, import_react3.useMemo)(() => {
|
|
2372
|
+
const rects = [];
|
|
2373
|
+
for (const field of classified.headers) {
|
|
2374
|
+
if (field.coordinates) {
|
|
2375
|
+
rects.push(field.coordinates);
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
for (const list of classified.simpleLists) {
|
|
2379
|
+
for (const item of list.items) {
|
|
2380
|
+
if (item.coordinates) {
|
|
2381
|
+
rects.push(item.coordinates);
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
for (const entity of classified.entities) {
|
|
2386
|
+
for (const item of entity.items) {
|
|
2387
|
+
for (const cell of Object.values(item)) {
|
|
2388
|
+
if (cell.coordinates) {
|
|
2389
|
+
rects.push(cell.coordinates);
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
for (const table of classified.tables) {
|
|
2395
|
+
for (const row of table.rows) {
|
|
2396
|
+
for (const [key, cell] of Object.entries(row)) {
|
|
2397
|
+
if (key !== ROW_META_KEY && cell.coordinates) {
|
|
2398
|
+
rects.push(cell.coordinates);
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
return rects.length > 0 ? rects : void 0;
|
|
2404
|
+
}, [classified]);
|
|
2405
|
+
const hasHebrewContent = (0, import_react3.useMemo)(
|
|
2406
|
+
() => bindings.some((binding) => HEBREW_RE.test(toInputString(binding.extracted))),
|
|
2407
|
+
[bindings]
|
|
2408
|
+
);
|
|
2409
|
+
const effectiveDir = dir === "auto" ? hasHebrewContent ? "rtl" : "ltr" : dir;
|
|
2410
|
+
const bindingsByRawKey = (0, import_react3.useMemo)(() => {
|
|
2411
|
+
const map = /* @__PURE__ */ new Map();
|
|
2412
|
+
for (const binding of bindings) {
|
|
2413
|
+
map.set(binding.key.raw, binding);
|
|
2414
|
+
}
|
|
2415
|
+
return map;
|
|
2416
|
+
}, [bindings]);
|
|
2417
|
+
const bindingsByRawKeyRef = (0, import_react3.useRef)(bindingsByRawKey);
|
|
2418
|
+
bindingsByRawKeyRef.current = bindingsByRawKey;
|
|
2419
|
+
const handleEdit = (0, import_react3.useCallback)((rawKey, value) => {
|
|
2420
|
+
const binding = bindingsByRawKeyRef.current.get(rawKey);
|
|
2421
|
+
const pristine = binding !== void 0 && value === toInputString(binding.extracted);
|
|
2422
|
+
setEdits((prev) => {
|
|
2423
|
+
if (pristine) {
|
|
2424
|
+
if (!prev.has(rawKey)) {
|
|
2425
|
+
return prev;
|
|
2426
|
+
}
|
|
2427
|
+
const next2 = new Map(prev);
|
|
2428
|
+
next2.delete(rawKey);
|
|
2429
|
+
return next2;
|
|
2430
|
+
}
|
|
2431
|
+
if (prev.get(rawKey) === value) {
|
|
2432
|
+
return prev;
|
|
2433
|
+
}
|
|
2434
|
+
const next = new Map(prev);
|
|
2435
|
+
next.set(rawKey, value);
|
|
2436
|
+
return next;
|
|
2437
|
+
});
|
|
2438
|
+
}, []);
|
|
2439
|
+
const submission = (0, import_react3.useMemo)(() => composeSubmission(bindings, edits), [bindings, edits]);
|
|
2440
|
+
const handleFlash = (0, import_react3.useCallback)((rects) => {
|
|
2441
|
+
setFlashRects(rects.map((rect) => ({ points: rect.points })));
|
|
2442
|
+
}, []);
|
|
2443
|
+
const handleFlashComplete = (0, import_react3.useCallback)(() => {
|
|
2444
|
+
setFlashRects(null);
|
|
2445
|
+
}, []);
|
|
2446
|
+
const handleImageExpired = (0, import_react3.useCallback)(() => {
|
|
2447
|
+
const now = Date.now();
|
|
2448
|
+
if (now - lastImageRefreshRef.current < IMAGE_REFRESH_THROTTLE_MS) {
|
|
2449
|
+
return;
|
|
2450
|
+
}
|
|
2451
|
+
lastImageRefreshRef.current = now;
|
|
2452
|
+
const seq = loadSeqRef.current;
|
|
2453
|
+
fetchWithRetry().then((view) => {
|
|
2454
|
+
if (!mountedRef.current || loadSeqRef.current !== seq) {
|
|
2455
|
+
return;
|
|
2456
|
+
}
|
|
2457
|
+
const url = view.document.imageUrl;
|
|
2458
|
+
if (typeof url === "string" && url.length > 0) {
|
|
2459
|
+
setImageUrl(url);
|
|
2460
|
+
}
|
|
2461
|
+
}).catch(() => {
|
|
2462
|
+
});
|
|
2463
|
+
}, [fetchWithRetry]);
|
|
2464
|
+
const handleRetry = (0, import_react3.useCallback)(() => {
|
|
2465
|
+
void load();
|
|
2466
|
+
}, [load]);
|
|
2467
|
+
const doSubmit = (0, import_react3.useCallback)(async () => {
|
|
2468
|
+
if (submitInFlightRef.current) {
|
|
2469
|
+
return;
|
|
2470
|
+
}
|
|
2471
|
+
submitInFlightRef.current = true;
|
|
2472
|
+
const seq = loadSeqRef.current;
|
|
2473
|
+
const live = () => mountedRef.current && loadSeqRef.current === seq;
|
|
2474
|
+
setPhase({ name: "submitting" });
|
|
2475
|
+
const body = submission;
|
|
2476
|
+
const submitOnce = async () => {
|
|
2477
|
+
const token = await tokenManager.getToken();
|
|
2478
|
+
return import_sdk.GeminaClient.withSessionToken(token, baseUrl).documents.validateDocumentExtraction({
|
|
2479
|
+
targetDocumentExtractionId: extractionId,
|
|
2480
|
+
extractionValidationInDTO: { data: body.data }
|
|
2481
|
+
});
|
|
2482
|
+
};
|
|
2483
|
+
try {
|
|
2484
|
+
let result;
|
|
2485
|
+
try {
|
|
2486
|
+
try {
|
|
2487
|
+
result = await submitOnce();
|
|
2488
|
+
} catch (error) {
|
|
2489
|
+
if (httpStatus(error) !== 401) {
|
|
2490
|
+
throw error;
|
|
2491
|
+
}
|
|
2492
|
+
tokenManager.invalidate();
|
|
2493
|
+
result = await submitOnce();
|
|
2494
|
+
}
|
|
2495
|
+
} catch (error) {
|
|
2496
|
+
const detail = await readErrorEnvelope(error);
|
|
2497
|
+
if (!live()) {
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
if (detail.status === 409) {
|
|
2501
|
+
void load();
|
|
2502
|
+
return;
|
|
2503
|
+
}
|
|
2504
|
+
if (detail.status === 401) {
|
|
2505
|
+
setPhase({ name: "submit-error", message: SUBMIT_SESSION_EXPIRED_TEXT });
|
|
2506
|
+
onErrorRef.current?.("session-expired", detail);
|
|
2507
|
+
return;
|
|
2508
|
+
}
|
|
2509
|
+
setPhase({
|
|
2510
|
+
name: "submit-error",
|
|
2511
|
+
message: detail.description ?? SUBMIT_FAILED_TEXT
|
|
2512
|
+
});
|
|
2513
|
+
onErrorRef.current?.("submit-failed", detail);
|
|
2514
|
+
return;
|
|
2515
|
+
}
|
|
2516
|
+
if (!live()) {
|
|
2517
|
+
return;
|
|
2518
|
+
}
|
|
2519
|
+
setPhase({ name: "done", confirmed: body.confirmed, corrected: body.corrected });
|
|
2520
|
+
if (!completedRef.current) {
|
|
2521
|
+
completedRef.current = true;
|
|
2522
|
+
onCompleteRef.current?.({ correctedValues: body.byLabel, summary: result.data });
|
|
2523
|
+
}
|
|
2524
|
+
} finally {
|
|
2525
|
+
submitInFlightRef.current = false;
|
|
2526
|
+
}
|
|
2527
|
+
}, [submission, tokenManager, baseUrl, extractionId, load]);
|
|
2528
|
+
const handleSubmitClick = (0, import_react3.useCallback)(() => {
|
|
2529
|
+
setPhase({ name: "confirming" });
|
|
2530
|
+
}, []);
|
|
2531
|
+
const handleConfirm = (0, import_react3.useCallback)(() => {
|
|
2532
|
+
void doSubmit();
|
|
2533
|
+
}, [doSubmit]);
|
|
2534
|
+
const handleCancelConfirm = (0, import_react3.useCallback)(() => {
|
|
2535
|
+
restoreFocusRef.current = true;
|
|
2536
|
+
setPhase({ name: "review" });
|
|
2537
|
+
}, []);
|
|
2538
|
+
const handleRetrySubmit = (0, import_react3.useCallback)(() => {
|
|
2539
|
+
void doSubmit();
|
|
2540
|
+
}, [doSubmit]);
|
|
2541
|
+
const handleConfirmKeyDown = (0, import_react3.useCallback)(
|
|
2542
|
+
(event) => {
|
|
2543
|
+
if (phase.name !== "confirming") {
|
|
2544
|
+
return;
|
|
2545
|
+
}
|
|
2546
|
+
if (event.key === "Escape") {
|
|
2547
|
+
event.stopPropagation();
|
|
2548
|
+
handleCancelConfirm();
|
|
2549
|
+
return;
|
|
2550
|
+
}
|
|
2551
|
+
if (event.key === "Tab") {
|
|
2552
|
+
const cancel = cancelButtonRef.current;
|
|
2553
|
+
const confirm = confirmButtonRef.current;
|
|
2554
|
+
if (cancel === null || confirm === null) {
|
|
2555
|
+
return;
|
|
2556
|
+
}
|
|
2557
|
+
const active = document.activeElement;
|
|
2558
|
+
if (event.shiftKey && active === cancel) {
|
|
2559
|
+
event.preventDefault();
|
|
2560
|
+
confirm.focus();
|
|
2561
|
+
} else if (!event.shiftKey && active === confirm) {
|
|
2562
|
+
event.preventDefault();
|
|
2563
|
+
cancel.focus();
|
|
2564
|
+
} else if (active !== cancel && active !== confirm) {
|
|
2565
|
+
event.preventDefault();
|
|
2566
|
+
confirm.focus();
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
},
|
|
2570
|
+
[phase.name, handleCancelConfirm]
|
|
2571
|
+
);
|
|
2572
|
+
(0, import_react3.useEffect)(() => {
|
|
2573
|
+
if (phase.name === "confirming") {
|
|
2574
|
+
confirmButtonRef.current?.focus();
|
|
2575
|
+
} else if (phase.name === "review" && restoreFocusRef.current) {
|
|
2576
|
+
restoreFocusRef.current = false;
|
|
2577
|
+
submitButtonRef.current?.focus();
|
|
2578
|
+
} else if (phase.name === "submit-error") {
|
|
2579
|
+
retrySubmitButtonRef.current?.focus();
|
|
2580
|
+
} else if (phase.name === "done") {
|
|
2581
|
+
doneStateRef.current?.focus();
|
|
2582
|
+
}
|
|
2583
|
+
}, [phase.name]);
|
|
2584
|
+
const rootClassName = [
|
|
2585
|
+
"gemina-verification",
|
|
2586
|
+
`gemina-verification--${theme}`,
|
|
2587
|
+
effectiveDir === "rtl" ? "gemina-verification--rtl" : "",
|
|
2588
|
+
stacked ? "gemina-verification--stacked" : "",
|
|
2589
|
+
className ?? ""
|
|
2590
|
+
].filter((part) => part.length > 0).join(" ");
|
|
2591
|
+
const dialogTextId = (0, import_react3.useId)();
|
|
2592
|
+
const renderReview = (reviewPhase) => {
|
|
2593
|
+
const overlayUp = reviewPhase.name === "confirming" || reviewPhase.name === "submitting";
|
|
2594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2595
|
+
alreadyValidated && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__banner", children: ALREADY_VALIDATED_TEXT }),
|
|
2596
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__panes", children: [
|
|
2597
|
+
imageUrl !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2598
|
+
VerificationViewer,
|
|
2599
|
+
{
|
|
2600
|
+
src: imageUrl,
|
|
2601
|
+
relativeRects: overlayRects,
|
|
2602
|
+
flashRects,
|
|
2603
|
+
onFlashComplete: handleFlashComplete,
|
|
2604
|
+
onImageExpired: handleImageExpired
|
|
2605
|
+
}
|
|
2606
|
+
),
|
|
2607
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2608
|
+
VerificationForm,
|
|
2609
|
+
{
|
|
2610
|
+
classified,
|
|
2611
|
+
unmatched,
|
|
2612
|
+
bindingIndex,
|
|
2613
|
+
edits,
|
|
2614
|
+
onEdit: handleEdit,
|
|
2615
|
+
readOnly: alreadyValidated,
|
|
2616
|
+
onFlash: handleFlash
|
|
2617
|
+
}
|
|
2618
|
+
)
|
|
2619
|
+
] }),
|
|
2620
|
+
reviewPhase.name === "submit-error" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2621
|
+
"div",
|
|
2622
|
+
{
|
|
2623
|
+
className: "gemina-verification__banner gemina-verification__banner--error gemina-verification__submit-error",
|
|
2624
|
+
role: "alert",
|
|
2625
|
+
children: [
|
|
2626
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: reviewPhase.message }),
|
|
2627
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2628
|
+
"button",
|
|
2629
|
+
{
|
|
2630
|
+
type: "button",
|
|
2631
|
+
ref: retrySubmitButtonRef,
|
|
2632
|
+
className: "gemina-verification__retry",
|
|
2633
|
+
onClick: handleRetrySubmit,
|
|
2634
|
+
children: "Retry"
|
|
2635
|
+
}
|
|
2636
|
+
)
|
|
2637
|
+
]
|
|
2638
|
+
}
|
|
2639
|
+
),
|
|
2640
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__footer", children: [
|
|
2641
|
+
!alreadyValidated && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__progress", "aria-live": "polite", children: `${submission.confirmed} confirmed \xB7 ${submission.corrected} corrected` }),
|
|
2642
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2643
|
+
"button",
|
|
2644
|
+
{
|
|
2645
|
+
type: "button",
|
|
2646
|
+
ref: submitButtonRef,
|
|
2647
|
+
className: "gemina-verification__submit",
|
|
2648
|
+
disabled: alreadyValidated || reviewPhase.name !== "review",
|
|
2649
|
+
onClick: handleSubmitClick,
|
|
2650
|
+
children: "Submit feedback"
|
|
2651
|
+
}
|
|
2652
|
+
)
|
|
2653
|
+
] }),
|
|
2654
|
+
overlayUp && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2655
|
+
"div",
|
|
2656
|
+
{
|
|
2657
|
+
className: "gemina-verification__confirm",
|
|
2658
|
+
onKeyDown: handleConfirmKeyDown,
|
|
2659
|
+
onMouseDown: (event) => {
|
|
2660
|
+
if (!event.target.closest("button")) {
|
|
2661
|
+
event.preventDefault();
|
|
2662
|
+
}
|
|
2663
|
+
},
|
|
2664
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2665
|
+
"div",
|
|
2666
|
+
{
|
|
2667
|
+
className: "gemina-verification__confirm-dialog",
|
|
2668
|
+
role: "dialog",
|
|
2669
|
+
"aria-modal": "true",
|
|
2670
|
+
"aria-labelledby": dialogTextId,
|
|
2671
|
+
children: [
|
|
2672
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: dialogTextId, className: "gemina-verification__confirm-text", children: reviewPhase.name === "submitting" ? SUBMITTING_TEXT : CONFIRM_TEXT }),
|
|
2673
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__confirm-actions", children: [
|
|
2674
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2675
|
+
"button",
|
|
2676
|
+
{
|
|
2677
|
+
type: "button",
|
|
2678
|
+
ref: cancelButtonRef,
|
|
2679
|
+
className: "gemina-verification__confirm-cancel",
|
|
2680
|
+
onClick: handleCancelConfirm,
|
|
2681
|
+
disabled: reviewPhase.name === "submitting",
|
|
2682
|
+
children: "Cancel"
|
|
2683
|
+
}
|
|
2684
|
+
),
|
|
2685
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2686
|
+
"button",
|
|
2687
|
+
{
|
|
2688
|
+
type: "button",
|
|
2689
|
+
ref: confirmButtonRef,
|
|
2690
|
+
className: "gemina-verification__submit",
|
|
2691
|
+
onClick: handleConfirm,
|
|
2692
|
+
disabled: reviewPhase.name === "submitting",
|
|
2693
|
+
children: "Confirm submission"
|
|
2694
|
+
}
|
|
2695
|
+
)
|
|
2696
|
+
] })
|
|
2697
|
+
]
|
|
2698
|
+
}
|
|
2699
|
+
)
|
|
2700
|
+
}
|
|
2701
|
+
)
|
|
2702
|
+
] });
|
|
2703
|
+
};
|
|
2704
|
+
const content = (() => {
|
|
2705
|
+
switch (phase.name) {
|
|
2706
|
+
case "loading":
|
|
2707
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__state", role: "status", children: LOADING_TEXT });
|
|
2708
|
+
case "unavailable":
|
|
2709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2710
|
+
"div",
|
|
2711
|
+
{
|
|
2712
|
+
className: "gemina-verification__state",
|
|
2713
|
+
role: ALERT_REASONS.has(phase.reason) ? "alert" : "status",
|
|
2714
|
+
children: [
|
|
2715
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: phase.message }),
|
|
2716
|
+
phase.canRetry && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "gemina-verification__retry", onClick: handleRetry, children: "Retry" })
|
|
2717
|
+
]
|
|
2718
|
+
}
|
|
2719
|
+
);
|
|
2720
|
+
case "review":
|
|
2721
|
+
case "confirming":
|
|
2722
|
+
case "submitting":
|
|
2723
|
+
case "submit-error":
|
|
2724
|
+
return renderReview(phase);
|
|
2725
|
+
case "done":
|
|
2726
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2727
|
+
"div",
|
|
2728
|
+
{
|
|
2729
|
+
ref: doneStateRef,
|
|
2730
|
+
tabIndex: -1,
|
|
2731
|
+
className: "gemina-verification__state gemina-verification__state--done",
|
|
2732
|
+
role: "status",
|
|
2733
|
+
children: [
|
|
2734
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "gemina-verification__done-check", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2735
|
+
"path",
|
|
2736
|
+
{
|
|
2737
|
+
d: "M4 10.5l4 4 8-9",
|
|
2738
|
+
stroke: "currentColor",
|
|
2739
|
+
strokeWidth: "2.4",
|
|
2740
|
+
strokeLinecap: "round",
|
|
2741
|
+
strokeLinejoin: "round"
|
|
2742
|
+
}
|
|
2743
|
+
) }) }),
|
|
2744
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__done-title", children: DONE_TITLE_TEXT }),
|
|
2745
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__progress", children: `${phase.confirmed} confirmed \xB7 ${phase.corrected} corrected` })
|
|
2746
|
+
]
|
|
2747
|
+
}
|
|
2748
|
+
);
|
|
2749
|
+
}
|
|
2750
|
+
})();
|
|
2751
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: rootRef, className: rootClassName, dir: effectiveDir, children: content });
|
|
2752
|
+
}
|
|
2753
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2754
|
+
0 && (module.exports = {
|
|
2755
|
+
GeminaVerification
|
|
2756
|
+
});
|
|
2757
|
+
//# sourceMappingURL=verification.cjs.map
|