@arbidocs/react 0.4.68 → 0.4.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +8 -0
  2. package/dist/annotations/index.cjs +186 -2450
  3. package/dist/annotations/index.cjs.map +1 -1
  4. package/dist/annotations/index.d.cts +3 -33
  5. package/dist/annotations/index.d.ts +3 -33
  6. package/dist/annotations/index.js +4 -2411
  7. package/dist/annotations/index.js.map +1 -1
  8. package/dist/artifacts/index.cjs +88 -112
  9. package/dist/artifacts/index.cjs.map +1 -1
  10. package/dist/artifacts/index.js +12 -61
  11. package/dist/artifacts/index.js.map +1 -1
  12. package/dist/artifacts/redline-core.cjs +8 -7
  13. package/dist/artifacts/redline-core.js +2 -1
  14. package/dist/{chunk-PATLJSAO.cjs → chunk-3AADNIOK.cjs} +9 -52
  15. package/dist/chunk-3AADNIOK.cjs.map +1 -0
  16. package/dist/chunk-3QF5DNAP.js +2413 -0
  17. package/dist/chunk-3QF5DNAP.js.map +1 -0
  18. package/dist/chunk-5DCRIWCA.cjs +243 -0
  19. package/dist/chunk-5DCRIWCA.cjs.map +1 -0
  20. package/dist/{chunk-NA3FOYSF.cjs → chunk-5SZ2J2WT.cjs} +5 -177
  21. package/dist/chunk-5SZ2J2WT.cjs.map +1 -0
  22. package/dist/{chunk-43AKLNBC.js → chunk-74N436VK.js} +4 -40
  23. package/dist/chunk-74N436VK.js.map +1 -0
  24. package/dist/{chunk-Z3RRZ3KV.cjs → chunk-7CL7QHT6.cjs} +2 -240
  25. package/dist/chunk-7CL7QHT6.cjs.map +1 -0
  26. package/dist/{chunk-BWVIAATD.cjs → chunk-BTRIS3HY.cjs} +4 -4
  27. package/dist/{chunk-BWVIAATD.cjs.map → chunk-BTRIS3HY.cjs.map} +1 -1
  28. package/dist/chunk-G6FHNURH.js +234 -0
  29. package/dist/chunk-G6FHNURH.js.map +1 -0
  30. package/dist/chunk-HKUD2NZN.js +61 -0
  31. package/dist/chunk-HKUD2NZN.js.map +1 -0
  32. package/dist/chunk-QRCMKEE6.js +173 -0
  33. package/dist/chunk-QRCMKEE6.js.map +1 -0
  34. package/dist/{chunk-PFKLOVGQ.js → chunk-SYPUFZGA.js} +3 -233
  35. package/dist/chunk-SYPUFZGA.js.map +1 -0
  36. package/dist/chunk-T4IJHRRD.cjs +71 -0
  37. package/dist/chunk-T4IJHRRD.cjs.map +1 -0
  38. package/dist/chunk-ULU5LEWF.cjs +2460 -0
  39. package/dist/chunk-ULU5LEWF.cjs.map +1 -0
  40. package/dist/{chunk-TQ6FRVAH.js → chunk-V4CXOPLB.js} +3 -3
  41. package/dist/{chunk-TQ6FRVAH.js.map → chunk-V4CXOPLB.js.map} +1 -1
  42. package/dist/chunk-VOFNX4P6.cjs +50 -0
  43. package/dist/chunk-VOFNX4P6.cjs.map +1 -0
  44. package/dist/chunk-WUTL62MC.js +42 -0
  45. package/dist/chunk-WUTL62MC.js.map +1 -0
  46. package/dist/{chunk-JPGV7NMY.js → chunk-YXSXGTYQ.js} +4 -173
  47. package/dist/chunk-YXSXGTYQ.js.map +1 -0
  48. package/dist/chunk-Z3LLUO32.cjs +177 -0
  49. package/dist/chunk-Z3LLUO32.cjs.map +1 -0
  50. package/dist/document-tools/index.cjs +683 -0
  51. package/dist/document-tools/index.cjs.map +1 -0
  52. package/dist/document-tools/index.d.cts +392 -0
  53. package/dist/document-tools/index.d.ts +392 -0
  54. package/dist/document-tools/index.js +639 -0
  55. package/dist/document-tools/index.js.map +1 -0
  56. package/dist/index.cjs +320 -318
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.js +9 -6
  59. package/dist/index.js.map +1 -1
  60. package/dist/store-CqkkD7Ho.d.cts +35 -0
  61. package/dist/store-D1nhbkgk.d.ts +35 -0
  62. package/dist/ui/index.cjs +138 -137
  63. package/dist/ui/index.js +3 -2
  64. package/package.json +11 -3
  65. package/dist/chunk-43AKLNBC.js.map +0 -1
  66. package/dist/chunk-JPGV7NMY.js.map +0 -1
  67. package/dist/chunk-NA3FOYSF.cjs.map +0 -1
  68. package/dist/chunk-PATLJSAO.cjs.map +0 -1
  69. package/dist/chunk-PFKLOVGQ.js.map +0 -1
  70. package/dist/chunk-Z3RRZ3KV.cjs.map +0 -1
@@ -1,2415 +1,197 @@
1
1
  'use strict';
2
2
 
3
- var chunkLQ5YHB7W_cjs = require('../chunk-LQ5YHB7W.cjs');
4
- var chunkHJDR5HEO_cjs = require('../chunk-HJDR5HEO.cjs');
5
- var chunkS6A6FSG7_cjs = require('../chunk-S6A6FSG7.cjs');
3
+ var chunkULU5LEWF_cjs = require('../chunk-ULU5LEWF.cjs');
6
4
  var chunkSSOPIPEX_cjs = require('../chunk-SSOPIPEX.cjs');
7
- var react = require('react');
8
- var lucideReact = require('lucide-react');
9
- var jsxRuntime = require('react/jsx-runtime');
5
+ require('../chunk-LQ5YHB7W.cjs');
6
+ require('../chunk-HJDR5HEO.cjs');
7
+ require('../chunk-S6A6FSG7.cjs');
10
8
 
11
- // src/annotations/state.ts
12
- var HISTORY_LIMIT = 200;
13
- function createHistory(layer) {
14
- return { present: layer, past: [], future: [] };
15
- }
16
- function reduceLayer(layer, action) {
17
- switch (action.type) {
18
- case "replaceAll":
19
- return action.layer;
20
- case "add": {
21
- const annotation = chunkSSOPIPEX_cjs.parseAnnotation(action.annotation);
22
- if (layer.annotations.some((a) => a.id === annotation.id)) {
23
- throw new Error(`annotation ${annotation.id} already exists`);
24
- }
25
- return {
26
- ...layer,
27
- annotations: [...layer.annotations, annotation],
28
- updatedAt: annotation.updatedAt
29
- };
30
- }
31
- case "addMany": {
32
- let next = layer;
33
- for (const annotation of action.annotations)
34
- next = reduceLayer(next, { type: "add", annotation });
35
- return next;
36
- }
37
- case "update": {
38
- const found = layer.annotations.find((a) => a.id === action.id);
39
- if (!found) return layer;
40
- const next = chunkSSOPIPEX_cjs.parseAnnotation({
41
- ...found,
42
- ...action.patch,
43
- id: found.id,
44
- kind: found.kind,
45
- page: found.page,
46
- createdAt: found.createdAt,
47
- updatedAt: action.now
48
- });
49
- return replace(layer, next, action.now);
50
- }
51
- case "remove": {
52
- if (!layer.annotations.some((a) => a.id === action.id)) return layer;
53
- return {
54
- ...layer,
55
- annotations: layer.annotations.filter((a) => a.id !== action.id),
56
- updatedAt: action.now
57
- };
58
- }
59
- case "setRedactionStatus": {
60
- const ids = new Set(action.ids);
61
- let changed = false;
62
- const annotations = layer.annotations.map((a) => {
63
- if (a.kind !== "redaction" || !ids.has(a.id) || a.status === action.status) return a;
64
- changed = true;
65
- const next = { ...a, status: action.status, updatedAt: action.now };
66
- delete next.reviewedBy;
67
- delete next.reviewedAt;
68
- if (action.status !== "pending" && action.by) {
69
- next.reviewedBy = action.by;
70
- next.reviewedAt = action.now;
71
- }
72
- return next;
73
- });
74
- return changed ? { ...layer, annotations, updatedAt: action.now } : layer;
75
- }
76
- case "reply": {
77
- const found = layer.annotations.find((a) => a.id === action.id);
78
- if (!found || found.kind !== "comment") return layer;
79
- const next = chunkSSOPIPEX_cjs.parseAnnotation({
80
- ...found,
81
- replies: [...found.replies, action.reply],
82
- updatedAt: action.now
83
- });
84
- return replace(layer, next, action.now);
85
- }
86
- case "resolve": {
87
- const found = layer.annotations.find((a) => a.id === action.id);
88
- if (!found || found.kind !== "comment" || found.resolved === action.resolved) return layer;
89
- return replace(
90
- layer,
91
- { ...found, resolved: action.resolved, updatedAt: action.now },
92
- action.now
93
- );
94
- }
95
- }
96
- }
97
- function replace(layer, next, now) {
98
- return {
99
- ...layer,
100
- annotations: layer.annotations.map((a) => a.id === next.id ? next : a),
101
- updatedAt: now
102
- };
103
- }
104
- function applyAction(history, action) {
105
- const present = reduceLayer(history.present, action);
106
- if (present === history.present) return history;
107
- const past = [...history.past, history.present];
108
- return {
109
- present,
110
- past: past.length > HISTORY_LIMIT ? past.slice(past.length - HISTORY_LIMIT) : past,
111
- future: []
112
- };
113
- }
114
- function undo(history) {
115
- const previous = history.past[history.past.length - 1];
116
- if (!previous) return history;
117
- return {
118
- present: previous,
119
- past: history.past.slice(0, -1),
120
- future: [history.present, ...history.future]
121
- };
122
- }
123
- function redo(history) {
124
- const [next, ...rest] = history.future;
125
- if (!next) return history;
126
- return { present: next, past: [...history.past, history.present], future: rest };
127
- }
128
- var canUndo = (h) => h.past.length > 0;
129
- var canRedo = (h) => h.future.length > 0;
130
- function annotationsOnPage(layer, page) {
131
- return layer.annotations.filter((a) => a.page === page);
132
- }
133
- function pendingRedactions(layer) {
134
- return layer.annotations.filter((a) => a.kind === "redaction" && a.status === "pending");
135
- }
136
9
 
137
- // src/annotations/store.ts
138
- var AnnotationStoreOfflineError = class extends Error {
139
- constructor(message = "You are offline") {
140
- super(message);
141
- this.name = "AnnotationStoreOfflineError";
142
- }
143
- };
144
- function createMemoryStore(now = () => (/* @__PURE__ */ new Date()).toISOString()) {
145
- const layers = /* @__PURE__ */ new Map();
146
- return {
147
- async load(documentId) {
148
- const raw = layers.get(documentId);
149
- return raw ? chunkSSOPIPEX_cjs.parseLayer(JSON.parse(raw)) : chunkSSOPIPEX_cjs.emptyLayer(documentId, now());
150
- },
151
- async save(layer) {
152
- layers.set(layer.documentId, JSON.stringify(chunkSSOPIPEX_cjs.parseLayer(layer)));
153
- }
154
- };
155
- }
156
- var STORAGE_PREFIX = "arbi:annotations:";
157
- function createLocalStorageStore(storage = safeLocalStorage(), now = () => (/* @__PURE__ */ new Date()).toISOString()) {
158
- return {
159
- async load(documentId) {
160
- try {
161
- const raw = storage?.getItem(STORAGE_PREFIX + documentId);
162
- if (raw) return chunkSSOPIPEX_cjs.parseLayer(JSON.parse(raw));
163
- } catch {
164
- }
165
- return chunkSSOPIPEX_cjs.emptyLayer(documentId, now());
166
- },
167
- async save(layer) {
168
- if (!storage) throw new Error("storage is not available");
169
- storage.setItem(STORAGE_PREFIX + layer.documentId, JSON.stringify(chunkSSOPIPEX_cjs.parseLayer(layer)));
170
- }
171
- };
172
- }
173
- function safeLocalStorage() {
174
- try {
175
- return typeof localStorage === "undefined" ? void 0 : localStorage;
176
- } catch {
177
- return void 0;
178
- }
179
- }
180
10
 
181
- // src/annotations/merge.ts
182
- var time = (iso) => {
183
- const t = Date.parse(iso);
184
- return Number.isNaN(t) ? 0 : t;
185
- };
186
- function mergeReplies(a, b) {
187
- const byId = /* @__PURE__ */ new Map();
188
- for (const r of [...a, ...b]) if (!byId.has(r.id)) byId.set(r.id, r);
189
- return [...byId.values()].sort((x, y) => time(x.createdAt) - time(y.createdAt));
190
- }
191
- function newer(mine, theirs) {
192
- const winner = time(theirs.updatedAt) > time(mine.updatedAt) ? theirs : mine;
193
- if (mine.kind === "comment" && theirs.kind === "comment" && winner.kind === "comment") {
194
- const replies = mergeReplies(mine.replies, theirs.replies);
195
- if (replies.length !== winner.replies.length) return { ...winner, replies };
196
- }
197
- return winner;
198
- }
199
- function mergeLayers({ base, mine, theirs, deleted }) {
200
- const baseById = new Map((base?.annotations ?? []).map((a) => [a.id, a]));
201
- const theirsById = new Map(theirs.annotations.map((a) => [a.id, a]));
202
- const mineIds = new Set(mine.annotations.map((a) => a.id));
203
- const out = [];
204
- for (const m of mine.annotations) {
205
- if (deleted?.has(m.id)) continue;
206
- const t = theirsById.get(m.id);
207
- if (t) {
208
- out.push(newer(m, t));
209
- continue;
210
- }
211
- const b = baseById.get(m.id);
212
- if (b && time(m.updatedAt) <= time(b.updatedAt)) continue;
213
- out.push(m);
214
- }
215
- for (const t of theirs.annotations) {
216
- if (mineIds.has(t.id) || deleted?.has(t.id)) continue;
217
- if (baseById.has(t.id)) continue;
218
- out.push(t);
219
- }
220
- const updatedAt = time(theirs.updatedAt) > time(mine.updatedAt) ? theirs.updatedAt : mine.updatedAt;
221
- return { ...mine, annotations: out, updatedAt };
222
- }
223
- function sameMarks(a, b) {
224
- if (a.annotations.length !== b.annotations.length) return false;
225
- const byId = new Map(a.annotations.map((m) => [m.id, m.updatedAt]));
226
- return b.annotations.every(
227
- (m) => byId.get(m.id) === m.updatedAt && (m.kind !== "comment" || a.annotations.find((x) => x.id === m.id).replies.length === m.replies.length)
228
- );
229
- }
230
-
231
- // src/annotations/redaction-log.ts
232
- var REDACTION_LOG_COLUMNS = ["page", "reason", "status", "approved_by", "time"];
233
- var STATUS = {
234
- approved: "redacted (approved)",
235
- pending: "redacted (not reviewed)",
236
- rejected: "not redacted (rejected)"
237
- };
238
- var top = (a) => Math.min(...a.rects.map((r) => r.y));
239
- var left = (a) => Math.min(...a.rects.map((r) => r.x));
240
- function redactionLogRows(layer) {
241
- return layer.annotations.filter((a) => a.kind === "redaction").sort((a, b) => a.page - b.page || top(a) - top(b) || left(a) - left(b)).map((a) => ({
242
- page: a.page,
243
- reason: a.reason,
244
- status: STATUS[a.status],
245
- approvedBy: a.status === "approved" ? a.reviewedBy ?? "" : "",
246
- time: a.reviewedAt ?? a.createdAt
247
- }));
248
- }
249
- var cell = (value) => {
250
- const text = String(value);
251
- return `"${(/^[=+\-@]/.test(text) ? `'${text}` : text).replace(/"/g, '""')}"`;
252
- };
253
- function redactionLogCsv(layer) {
254
- const rows = redactionLogRows(layer).map(
255
- (r) => [r.page, r.reason, r.status, r.approvedBy, r.time].map(cell).join(",")
256
- );
257
- return [REDACTION_LOG_COLUMNS.join(","), ...rows].join("\r\n") + "\r\n";
258
- }
259
-
260
- // src/annotations/geometry.ts
261
- var MIN_MARK_FRACTION = 4e-3;
262
- function toNorm(r, page) {
263
- if (!(page.width > 0) || !(page.height > 0)) throw new RangeError("page size must be positive");
264
- const x1 = Math.min(r.x, r.x + r.width);
265
- const y1 = Math.min(r.y, r.y + r.height);
266
- const x2 = Math.max(r.x, r.x + r.width);
267
- const y2 = Math.max(r.y, r.y + r.height);
268
- const cx1 = Math.min(Math.max(x1, 0), page.width);
269
- const cy1 = Math.min(Math.max(y1, 0), page.height);
270
- const cx2 = Math.min(Math.max(x2, 0), page.width);
271
- const cy2 = Math.min(Math.max(y2, 0), page.height);
272
- return chunkSSOPIPEX_cjs.clampRect({
273
- x: cx1 / page.width,
274
- y: cy1 / page.height,
275
- w: (cx2 - cx1) / page.width,
276
- h: (cy2 - cy1) / page.height
277
- });
278
- }
279
- function toPixels(r, page) {
280
- return {
281
- x: r.x * page.width,
282
- y: r.y * page.height,
283
- width: r.w * page.width,
284
- height: r.h * page.height
285
- };
286
- }
287
- function dragToNorm(a, b, page) {
288
- return toNorm({ x: a.x, y: a.y, width: b.x - a.x, height: b.y - a.y }, page);
289
- }
290
- function isTooSmall(r) {
291
- return r.w < MIN_MARK_FRACTION || r.h < MIN_MARK_FRACTION;
292
- }
293
- function containsPoint(r, x, y) {
294
- return x >= r.x && x <= r.x + r.w && y >= r.y && y <= r.y + r.h;
295
- }
296
- var EPS = 1e-9;
297
- function intersects(a, b) {
298
- return a.x + EPS < b.x + b.w && b.x + EPS < a.x + a.w && a.y + EPS < b.y + b.h && b.y + EPS < a.y + a.h;
299
- }
300
- function mergeLineRects(input, gap = 2) {
301
- const rects = input.filter((r) => r.width > 0 && r.height > 0).map((r) => ({ ...r })).sort((a, b) => a.y - b.y || a.x - b.x);
302
- const lines = [];
303
- for (const r of rects) {
304
- const mid = r.y + r.height / 2;
305
- const line = lines.find((l) => {
306
- const ref = l[0];
307
- return mid >= ref.y && mid <= ref.y + ref.height;
308
- });
309
- if (line) line.push(r);
310
- else lines.push([r]);
311
- }
312
- const out = [];
313
- for (const line of lines) {
314
- line.sort((a, b) => a.x - b.x);
315
- let cur = { ...line[0] };
316
- for (const r of line.slice(1)) {
317
- if (r.x <= cur.x + cur.width + gap) {
318
- const right = Math.max(cur.x + cur.width, r.x + r.width);
319
- const top2 = Math.min(cur.y, r.y);
320
- const bottom = Math.max(cur.y + cur.height, r.y + r.height);
321
- cur = { x: cur.x, y: top2, width: right - cur.x, height: bottom - top2 };
322
- } else {
323
- out.push(cur);
324
- cur = { ...r };
325
- }
326
- }
327
- out.push(cur);
328
- }
329
- return out.sort((a, b) => a.y - b.y || a.x - b.x);
330
- }
331
-
332
- // src/annotations/controller.ts
333
- var DRAW_TOOLS = ["box", "comment", "stamp", "redact-area"];
334
- var TEXT_TOOLS = ["highlight", "redact-text"];
335
- var DEFAULT_SETTINGS = {
336
- colors: { highlight: "#ffe066", box: "#e03131", stamp: "#c92a2a" },
337
- stampLabel: "CONFIDENTIAL",
338
- redactionReason: "Privileged",
339
- strokeWidth: 2
340
- };
341
- var HIGHLIGHT_COLORS = ["#ffe066", "#8ce99a", "#74c0fc", "#ffa8a8", "#eebefa"];
342
- var MARK_COLORS = ["#e03131", "#1c7ed6", "#2f9e44", "#f08c00", "#000000"];
343
- var STAMP_PRESETS = ["CONFIDENTIAL", "DRAFT", "APPROVED", "FILED", "PRIVILEGED", "COPY"];
344
- var REDACTION_REASONS = [
345
- "Privileged",
346
- "Confidential",
347
- "Personal data",
348
- "Commercial",
349
- "Irrelevant"
350
- ];
351
- function layerStatusText(controller) {
352
- if (controller.status === "error") return "Could not be loaded";
353
- if (controller.readOnly) return "View only";
354
- if (controller.offline) {
355
- return controller.dirty ? "Offline \u2014 will save when back online" : "Offline";
356
- }
357
- if (controller.error) return "Not saved \u2014 retrying";
358
- if (controller.saving) return "Saving\u2026";
359
- if (controller.dirty) return "Unsaved changes";
360
- return "Saved";
361
- }
362
- var AUTOSAVE_MS = 600;
363
- var RETRY_MS = 1e4;
364
- var defaultNow = () => (/* @__PURE__ */ new Date()).toISOString();
365
- var defaultId = () => globalThis.crypto.randomUUID();
366
- function rebaseHistory(history, sent, remote) {
367
- const onto = (layer) => layer === sent ? remote : mergeLayers({ base: sent, mine: layer, theirs: remote });
368
- return {
369
- present: onto(history.present),
370
- past: history.past.map(onto),
371
- future: history.future.map(onto)
372
- };
373
- }
374
- function useAnnotationLayer({
375
- documentId,
376
- store,
377
- author,
378
- autosaveMs = AUTOSAVE_MS,
379
- readOnly: readOnlyProp = false,
380
- online = true,
381
- pullMs = 0,
382
- now = defaultNow,
383
- makeId = defaultId
384
- }) {
385
- const [history, setHistory] = react.useState(
386
- () => createHistory(chunkSSOPIPEX_cjs.emptyLayer(documentId, now()))
387
- );
388
- const [savedLayer, setSavedLayer] = react.useState(null);
389
- const [status, setStatus] = react.useState("loading");
390
- const [error, setError] = react.useState(null);
391
- const [saving, setSaving] = react.useState(false);
392
- const [offlineFailure, setOfflineFailure] = react.useState(false);
393
- const [storeReadOnly, setStoreReadOnly] = react.useState(false);
394
- const [tool, setToolState] = react.useState("select");
395
- const [settings, setSettingsState] = react.useState(DEFAULT_SETTINGS);
396
- const [selectedId, setSelectedId] = react.useState(null);
397
- const readOnly = readOnlyProp || storeReadOnly;
398
- const historyRef = react.useRef(history);
399
- const savedRef = react.useRef(null);
400
- const timerRef = react.useRef(void 0);
401
- const retryRef = react.useRef(void 0);
402
- const savingRef = react.useRef(false);
403
- const docRef = react.useRef(documentId);
404
- const storeRef = react.useRef(store);
405
- storeRef.current = store;
406
- const nowRef = react.useRef(now);
407
- nowRef.current = now;
408
- const idRef = react.useRef(makeId);
409
- idRef.current = makeId;
410
- const readOnlyRef = react.useRef(readOnly);
411
- readOnlyRef.current = readOnly;
412
- const onlineRef = react.useRef(online);
413
- onlineRef.current = online;
414
- const autosaveMsRef = react.useRef(autosaveMs);
415
- autosaveMsRef.current = autosaveMs;
416
- const commit = react.useCallback((next) => {
417
- historyRef.current = next;
418
- setHistory(next);
419
- }, []);
420
- const adoptRemote = react.useCallback(
421
- (sent, remote) => {
422
- commit(rebaseHistory(historyRef.current, sent, remote));
423
- savedRef.current = remote;
424
- setSavedLayer(remote);
425
- },
426
- [commit]
427
- );
428
- react.useEffect(() => {
429
- docRef.current = documentId;
430
- let cancelled = false;
431
- setStatus("loading");
432
- setError(null);
433
- setSelectedId(null);
434
- setSavedLayer(null);
435
- setStoreReadOnly(false);
436
- savedRef.current = null;
437
- commit(createHistory(chunkSSOPIPEX_cjs.emptyLayer(documentId, nowRef.current())));
438
- storeRef.current.load(documentId).then((layer) => {
439
- if (cancelled) return;
440
- savedRef.current = layer;
441
- setSavedLayer(layer);
442
- setStoreReadOnly(storeRef.current.canEdit?.(documentId) === false);
443
- commit(createHistory(layer));
444
- setStatus("ready");
445
- }).catch((e) => {
446
- if (cancelled) return;
447
- setError(e instanceof Error ? e.message : "The annotations could not be loaded");
448
- setStatus("error");
449
- });
450
- return () => {
451
- cancelled = true;
452
- clearTimeout(timerRef.current);
453
- clearTimeout(retryRef.current);
454
- const layer = historyRef.current.present;
455
- if (savedRef.current !== null && layer !== savedRef.current && layer.documentId === documentId && !readOnlyRef.current) {
456
- storeRef.current.save(layer).catch((e) => console.error("Annotations could not be saved", e));
457
- }
458
- };
459
- }, [documentId, commit]);
460
- const save = react.useCallback(async () => {
461
- clearTimeout(timerRef.current);
462
- clearTimeout(retryRef.current);
463
- const layer = historyRef.current.present;
464
- if (layer === savedRef.current || savedRef.current === null) return;
465
- if (readOnlyRef.current || savingRef.current) return;
466
- if (!onlineRef.current) return;
467
- savingRef.current = true;
468
- setSaving(true);
469
- let failed = false;
470
- try {
471
- const stored = await storeRef.current.save(layer);
472
- if (layer.documentId === docRef.current) {
473
- setError(null);
474
- setOfflineFailure(false);
475
- if (stored && stored !== layer) {
476
- adoptRemote(layer, stored);
477
- } else {
478
- savedRef.current = layer;
479
- setSavedLayer(layer);
480
- }
481
- }
482
- } catch (e) {
483
- failed = true;
484
- if (e instanceof AnnotationStoreOfflineError) {
485
- setOfflineFailure(true);
486
- } else {
487
- setError(e instanceof Error ? e.message : "The annotations could not be saved");
488
- }
489
- retryRef.current = setTimeout(() => void saveRef.current(), RETRY_MS);
490
- } finally {
491
- savingRef.current = false;
492
- setSaving(false);
493
- if (!failed && historyRef.current.present !== savedRef.current) {
494
- timerRef.current = setTimeout(() => void saveRef.current(), autosaveMsRef.current);
495
- }
496
- }
497
- }, [adoptRemote]);
498
- const saveRef = react.useRef(save);
499
- saveRef.current = save;
500
- const present = history.present;
501
- const dirty = status === "ready" && present !== savedLayer;
502
- react.useEffect(() => {
503
- if (!dirty || !online || readOnly) return;
504
- timerRef.current = setTimeout(() => void save(), autosaveMs);
505
- return () => clearTimeout(timerRef.current);
506
- }, [dirty, present, autosaveMs, save, online, readOnly]);
507
- react.useEffect(() => {
508
- if (online) setOfflineFailure(false);
509
- if (online && savedRef.current !== null && historyRef.current.present !== savedRef.current) {
510
- void save();
511
- }
512
- }, [online, save]);
513
- const pull = react.useCallback(async () => {
514
- const s = storeRef.current;
515
- const base = savedRef.current;
516
- if (!s.pull || !base || savingRef.current || !onlineRef.current) return;
517
- if (historyRef.current.present !== base) return;
518
- try {
519
- const remote = await s.pull(docRef.current);
520
- if (!remote || remote.documentId !== docRef.current || savedRef.current !== base) return;
521
- adoptRemote(base, remote);
522
- } catch {
523
- }
524
- }, [adoptRemote]);
525
- react.useEffect(() => {
526
- if (!pullMs || status !== "ready") return;
527
- const timer = setInterval(() => void pull(), pullMs);
528
- const onFocus = () => void pull();
529
- window.addEventListener("focus", onFocus);
530
- return () => {
531
- clearInterval(timer);
532
- window.removeEventListener("focus", onFocus);
533
- };
534
- }, [pullMs, status, pull]);
535
- react.useEffect(() => {
536
- const flush = () => void save();
537
- const onVisibility = () => {
538
- if (document.visibilityState === "hidden") flush();
539
- };
540
- window.addEventListener("pagehide", flush);
541
- document.addEventListener("visibilitychange", onVisibility);
542
- return () => {
543
- window.removeEventListener("pagehide", flush);
544
- document.removeEventListener("visibilitychange", onVisibility);
545
- };
546
- }, [save]);
547
- const dispatch = react.useCallback(
548
- (action) => {
549
- if (readOnlyRef.current) return false;
550
- try {
551
- commit(applyAction(historyRef.current, action));
552
- setError(null);
553
- return true;
554
- } catch (e) {
555
- setError(e instanceof Error ? e.message : "The change was rejected");
556
- return false;
557
- }
558
- },
559
- [commit]
560
- );
561
- const stamp = react.useCallback(
562
- (mark) => {
563
- const t = nowRef.current();
564
- return { ...mark, id: idRef.current(), author, createdAt: t, updatedAt: t };
565
- },
566
- [author]
567
- );
568
- const offline = !online || offlineFailure;
569
- const controller = react.useMemo(() => {
570
- const exists = (id) => id !== null && present.annotations.some((a) => a.id === id) ? id : null;
571
- return {
572
- layer: present,
573
- status,
574
- error,
575
- saving,
576
- dirty,
577
- offline,
578
- readOnly,
579
- author,
580
- tool: readOnly ? "select" : tool,
581
- setTool: (next) => {
582
- if (readOnly && next !== "select") return;
583
- setToolState(next);
584
- if (next !== "select") setSelectedId(null);
585
- },
586
- settings,
587
- setSettings: (patch) => setSettingsState((s) => ({ ...s, ...patch, colors: { ...s.colors, ...patch.colors } })),
588
- selectedId: exists(selectedId),
589
- select: setSelectedId,
590
- add: (mark) => {
591
- const annotation = stamp(mark);
592
- return dispatch({ type: "add", annotation }) ? annotation.id : null;
593
- },
594
- addMany: (marks) => {
595
- const annotations = marks.map(stamp);
596
- return dispatch({ type: "addMany", annotations }) ? annotations.map((a) => a.id) : [];
597
- },
598
- update: (id, patch) => void dispatch({ type: "update", id, patch, now: nowRef.current() }),
599
- remove: (id) => void dispatch({ type: "remove", id, now: nowRef.current() }),
600
- setRedactionStatus: (ids, next) => void dispatch({
601
- type: "setRedactionStatus",
602
- ids,
603
- status: next,
604
- now: nowRef.current(),
605
- by: author
606
- }),
607
- reply: (id, body) => {
608
- const t = nowRef.current();
609
- void dispatch({
610
- type: "reply",
611
- id,
612
- reply: { id: idRef.current(), author, createdAt: t, body },
613
- now: t
614
- });
615
- },
616
- resolve: (id, resolved) => void dispatch({ type: "resolve", id, resolved, now: nowRef.current() }),
617
- undo: () => {
618
- if (!readOnly) commit(undo(historyRef.current));
619
- },
620
- redo: () => {
621
- if (!readOnly) commit(redo(historyRef.current));
622
- },
623
- canUndo: !readOnly && canUndo(history),
624
- canRedo: !readOnly && canRedo(history),
625
- flush: save
626
- };
627
- }, [
628
- present,
629
- history,
630
- status,
631
- error,
632
- saving,
633
- dirty,
634
- offline,
635
- readOnly,
636
- author,
637
- tool,
638
- settings,
639
- selectedId,
640
- stamp,
641
- dispatch,
642
- commit,
643
- save
644
- ]);
645
- return controller;
646
- }
647
-
648
- // src/annotations/selection-marks.ts
649
- var MIN_RECT_PX = 1;
650
- function selectionToPageMarks(pages) {
651
- const out = [];
652
- for (const p of pages) {
653
- if (!(p.box.width > 0) || !(p.box.height > 0)) continue;
654
- const local = p.rects.filter((r) => r.width >= MIN_RECT_PX && r.height >= MIN_RECT_PX).map((r) => ({ x: r.x - p.box.x, y: r.y - p.box.y, width: r.width, height: r.height })).filter(
655
- (r) => r.x + r.width > 0 && r.y + r.height > 0 && r.x < p.box.width && r.y < p.box.height
656
- );
657
- const lines = mergeLineRects(local);
658
- if (lines.length === 0) continue;
659
- out.push({
660
- page: p.page,
661
- rects: lines.map((r) => toNorm(r, { width: p.box.width, height: p.box.height })),
662
- text: p.text.replace(/\s+/g, " ").trim()
663
- });
664
- }
665
- return out;
666
- }
667
- var PAGE_ATTRIBUTE = "data-annotation-page";
668
- var ownerDocument = (node) => node.ownerDocument ?? document;
669
- var toPixelRect = (r) => ({
670
- x: r.left,
671
- y: r.top,
672
- width: r.width,
673
- height: r.height
11
+ Object.defineProperty(exports, "AUTOSAVE_MS", {
12
+ enumerable: true,
13
+ get: function () { return chunkULU5LEWF_cjs.AUTOSAVE_MS; }
674
14
  });
675
- function clipRange(range, container) {
676
- if (!range.intersectsNode(container)) return null;
677
- const bounds = ownerDocument(container).createRange();
678
- bounds.selectNodeContents(container);
679
- const clipped = range.cloneRange();
680
- if (clipped.compareBoundaryPoints(Range.START_TO_START, bounds) < 0) {
681
- clipped.setStart(bounds.startContainer, bounds.startOffset);
682
- }
683
- if (clipped.compareBoundaryPoints(Range.END_TO_END, bounds) > 0) {
684
- clipped.setEnd(bounds.endContainer, bounds.endOffset);
685
- }
686
- return clipped;
687
- }
688
- function textClientRects(range, container) {
689
- const doc = ownerDocument(container);
690
- const walker = doc.createTreeWalker(container, NodeFilter.SHOW_TEXT);
691
- const rects = [];
692
- for (let node = walker.nextNode(); node; node = walker.nextNode()) {
693
- if (!node.textContent?.trim() || !range.intersectsNode(node)) continue;
694
- const part = doc.createRange();
695
- part.selectNodeContents(node);
696
- if (node === range.startContainer) part.setStart(node, range.startOffset);
697
- if (node === range.endContainer) part.setEnd(node, range.endOffset);
698
- rects.push(...Array.from(part.getClientRects()));
699
- }
700
- return rects;
701
- }
702
- function firstTextAt(container, offset) {
703
- if (container.nodeType === Node.TEXT_NODE) return { node: container, offset };
704
- const child = container.childNodes[offset];
705
- if (!child) return null;
706
- if (child.nodeType === Node.TEXT_NODE) return { node: child, offset: 0 };
707
- const first = ownerDocument(child).createTreeWalker(child, NodeFilter.SHOW_TEXT).nextNode();
708
- return first ? { node: first, offset: 0 } : null;
709
- }
710
- function extendFocusToPointer(selection, point) {
711
- if (selection.rangeCount === 0 || selection.isCollapsed) return;
712
- const range = selection.getRangeAt(0);
713
- if (selection.focusNode !== range.endContainer || selection.focusOffset !== range.endOffset)
714
- return;
715
- const start = firstTextAt(range.endContainer, range.endOffset);
716
- if (!start) return;
717
- const doc = ownerDocument(start.node);
718
- const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_TEXT);
719
- walker.currentNode = start.node;
720
- const glyph = doc.createRange();
721
- let end = null;
722
- let node = start.node;
723
- let offset = start.offset;
724
- let passed = false;
725
- while (node && !passed) {
726
- const text = node.textContent ?? "";
727
- for (let i = offset; i < text.length && !passed; i++) {
728
- glyph.setStart(node, i);
729
- glyph.setEnd(node, i + 1);
730
- const r = glyph.getBoundingClientRect();
731
- if (r.height === 0) continue;
732
- const mid = r.top + r.height / 2;
733
- if (mid > point.y + r.height / 2) passed = true;
734
- else if (Math.abs(mid - point.y) > r.height / 2) continue;
735
- else if (r.right > point.x + 0.5) passed = true;
736
- else end = { node, offset: i + 1 };
737
- }
738
- node = walker.nextNode();
739
- offset = 0;
740
- }
741
- if (end) selection.extend(end.node, end.offset);
742
- }
743
- function readSelection(selection, root = document) {
744
- if (selection.rangeCount === 0 || selection.isCollapsed) return [];
745
- const range = selection.getRangeAt(0);
746
- const pages = [];
747
- root.querySelectorAll(`[${PAGE_ATTRIBUTE}]`).forEach((overlay) => {
748
- const page = Number(overlay.getAttribute(PAGE_ATTRIBUTE));
749
- const container = overlay.parentElement;
750
- if (!container || !Number.isInteger(page)) return;
751
- const clipped = clipRange(range, container);
752
- if (!clipped) return;
753
- pages.push({
754
- page,
755
- box: toPixelRect(overlay.getBoundingClientRect()),
756
- rects: textClientRects(clipped, container).map(toPixelRect),
757
- text: clipped.toString()
758
- });
759
- });
760
- return pages;
761
- }
762
-
763
- // src/annotations/useTextSelectionMarks.ts
764
- var PAGE_SELECTOR = "[data-page-number]";
765
- var TOUCH_SETTLE_MS = 700;
766
- var MOUSE_SETTLE_MS = 80;
767
- var STABLE_CHECKS = 3;
768
- var MAX_SETTLE_ROUNDS = 12;
769
- function useTextSelectionMarks(controller) {
770
- const latest = react.useRef(controller);
771
- latest.current = controller;
772
- const pagesDoc = chunkHJDR5HEO_cjs.usePortalContainer()?.ownerDocument ?? document;
773
- react.useEffect(() => {
774
- let startedOnPage = false;
775
- let touchSelecting = false;
776
- let settleTimer;
777
- const settleTimers = /* @__PURE__ */ new Set();
778
- const markSelection = () => {
779
- const c = latest.current;
780
- const selection = pagesDoc.getSelection();
781
- if (!selection || !TEXT_TOOLS.includes(c.tool)) return false;
782
- const pages = selectionToPageMarks(readSelection(selection, pagesDoc));
783
- if (pages.length === 0) return false;
784
- const marks = pages.map(
785
- (p) => c.tool === "highlight" ? {
786
- kind: "highlight",
787
- page: p.page,
788
- rects: p.rects,
789
- color: c.settings.colors.highlight,
790
- text: p.text
791
- } : {
792
- kind: "redaction",
793
- page: p.page,
794
- rects: p.rects,
795
- reason: c.settings.redactionReason,
796
- text: p.text,
797
- status: "pending"
798
- }
799
- );
800
- if (c.addMany(marks).length === 0) return false;
801
- selection.removeAllRanges();
802
- return true;
803
- };
804
- const onDown = (e) => {
805
- startedOnPage = e.target instanceof Element && e.target.closest(PAGE_SELECTOR) !== null;
806
- touchSelecting = startedOnPage && e.pointerType === "touch";
807
- };
808
- const onUp = (e) => {
809
- if (!startedOnPage || !TEXT_TOOLS.includes(latest.current.tool)) return;
810
- startedOnPage = false;
811
- const selection = pagesDoc.getSelection();
812
- if (selection && e.pointerType === "mouse") {
813
- extendFocusToPointer(selection, { x: e.clientX, y: e.clientY });
814
- }
815
- let last = selection?.toString() ?? "";
816
- let stable = 0;
817
- let rounds = 0;
818
- const check = () => {
819
- const now = pagesDoc.getSelection()?.toString() ?? "";
820
- if (now === last) stable++;
821
- else {
822
- last = now;
823
- stable = 0;
824
- }
825
- if (stable >= STABLE_CHECKS || ++rounds >= MAX_SETTLE_ROUNDS) {
826
- if (markSelection()) touchSelecting = false;
827
- return;
828
- }
829
- settleTimers.add(setTimeout(check, MOUSE_SETTLE_MS));
830
- };
831
- settleTimers.add(setTimeout(check, MOUSE_SETTLE_MS));
832
- };
833
- const onSelectionChange = () => {
834
- if (!touchSelecting || !TEXT_TOOLS.includes(latest.current.tool)) return;
835
- clearTimeout(settleTimer);
836
- settleTimer = setTimeout(() => {
837
- if (markSelection()) touchSelecting = false;
838
- }, TOUCH_SETTLE_MS);
839
- };
840
- pagesDoc.addEventListener("pointerdown", onDown, true);
841
- pagesDoc.addEventListener("pointerup", onUp, true);
842
- pagesDoc.addEventListener("selectionchange", onSelectionChange);
843
- return () => {
844
- clearTimeout(settleTimer);
845
- settleTimers.forEach(clearTimeout);
846
- pagesDoc.removeEventListener("pointerdown", onDown, true);
847
- pagesDoc.removeEventListener("pointerup", onUp, true);
848
- pagesDoc.removeEventListener("selectionchange", onSelectionChange);
849
- };
850
- }, [pagesDoc]);
851
- }
852
-
853
- // src/annotations/overlay-geometry.ts
854
- var MIN_MARK = 0.01;
855
- function singleRect(a) {
856
- if (a.kind === "box" || a.kind === "stamp" || a.kind === "comment") return a.rect;
857
- if (a.kind === "redaction" && a.rects.length === 1) return a.rects[0];
858
- return null;
859
- }
860
- var patchForRect = (a, rect) => a.kind === "redaction" ? { rects: [rect] } : { rect };
861
- function dragRect(origin, mode, dx, dy) {
862
- if (mode === "move") {
863
- return {
864
- ...origin,
865
- x: Math.min(Math.max(origin.x + dx, 0), 1 - origin.w),
866
- y: Math.min(Math.max(origin.y + dy, 0), 1 - origin.h)
867
- };
868
- }
869
- let left2 = origin.x;
870
- let right = origin.x + origin.w;
871
- let top2 = origin.y;
872
- let bottom = origin.y + origin.h;
873
- if (mode.includes("w")) left2 += dx;
874
- else right += dx;
875
- if (mode.includes("n")) top2 += dy;
876
- else bottom += dy;
877
- const x1 = Math.min(Math.max(Math.min(left2, right), 0), 1);
878
- const x2 = Math.min(Math.max(Math.max(left2, right), 0), 1);
879
- const y1 = Math.min(Math.max(Math.min(top2, bottom), 0), 1);
880
- const y2 = Math.min(Math.max(Math.max(top2, bottom), 0), 1);
881
- return chunkSSOPIPEX_cjs.clampRect({
882
- x: x1,
883
- y: y1,
884
- w: Math.max(x2 - x1, MIN_MARK),
885
- h: Math.max(y2 - y1, MIN_MARK)
886
- });
887
- }
888
- var FALLBACK_PAGE_WIDTH_PT = 612;
889
- var COMMENT_ICON_PX = 24;
890
- var DEFAULT_STAMP = { w: 0.32, h: 0.06 };
891
- var MOVE_THRESHOLD_PX = 3;
892
- function useElementSize(ref) {
893
- const [size, setSize] = react.useState({ width: 0, height: 0 });
894
- react.useLayoutEffect(() => {
895
- const el = ref.current;
896
- if (!el) return;
897
- const measure = () => {
898
- const r = el.getBoundingClientRect();
899
- setSize(
900
- (prev) => prev.width === r.width && prev.height === r.height ? prev : { width: r.width, height: r.height }
901
- );
902
- };
903
- measure();
904
- const observer = new ResizeObserver(measure);
905
- observer.observe(el);
906
- return () => observer.disconnect();
907
- }, [ref]);
908
- return size;
909
- }
910
- function useHasTextLayer(ref) {
911
- const [hasText, setHasText] = react.useState(false);
912
- react.useLayoutEffect(() => {
913
- const container = ref.current?.parentElement;
914
- if (!container) return;
915
- const check = () => setHasText(container.querySelector(".textLayer span") !== null);
916
- check();
917
- const observer = new MutationObserver(check);
918
- observer.observe(container, { childList: true, subtree: true });
919
- return () => observer.disconnect();
920
- }, [ref]);
921
- return hasText;
922
- }
923
- var pct = (n) => `${n * 100}%`;
924
- var rectStyle = (r) => ({
925
- left: pct(r.x),
926
- top: pct(r.y),
927
- width: pct(r.w),
928
- height: pct(r.h)
15
+ Object.defineProperty(exports, "AnnotationPageOverlay", {
16
+ enumerable: true,
17
+ get: function () { return chunkULU5LEWF_cjs.AnnotationPageOverlay; }
18
+ });
19
+ Object.defineProperty(exports, "AnnotationStoreOfflineError", {
20
+ enumerable: true,
21
+ get: function () { return chunkULU5LEWF_cjs.AnnotationStoreOfflineError; }
22
+ });
23
+ Object.defineProperty(exports, "AnnotationToolbar", {
24
+ enumerable: true,
25
+ get: function () { return chunkULU5LEWF_cjs.AnnotationToolbar; }
26
+ });
27
+ Object.defineProperty(exports, "DEFAULT_SETTINGS", {
28
+ enumerable: true,
29
+ get: function () { return chunkULU5LEWF_cjs.DEFAULT_SETTINGS; }
30
+ });
31
+ Object.defineProperty(exports, "FreezeDialog", {
32
+ enumerable: true,
33
+ get: function () { return chunkULU5LEWF_cjs.FreezeDialog; }
34
+ });
35
+ Object.defineProperty(exports, "HIGHLIGHT_COLORS", {
36
+ enumerable: true,
37
+ get: function () { return chunkULU5LEWF_cjs.HIGHLIGHT_COLORS; }
38
+ });
39
+ Object.defineProperty(exports, "MARK_COLORS", {
40
+ enumerable: true,
41
+ get: function () { return chunkULU5LEWF_cjs.MARK_COLORS; }
42
+ });
43
+ Object.defineProperty(exports, "ProductionDialog", {
44
+ enumerable: true,
45
+ get: function () { return chunkULU5LEWF_cjs.ProductionDialog; }
46
+ });
47
+ Object.defineProperty(exports, "REDACTION_LOG_COLUMNS", {
48
+ enumerable: true,
49
+ get: function () { return chunkULU5LEWF_cjs.REDACTION_LOG_COLUMNS; }
50
+ });
51
+ Object.defineProperty(exports, "REDACTION_REASONS", {
52
+ enumerable: true,
53
+ get: function () { return chunkULU5LEWF_cjs.REDACTION_REASONS; }
54
+ });
55
+ Object.defineProperty(exports, "RETRY_MS", {
56
+ enumerable: true,
57
+ get: function () { return chunkULU5LEWF_cjs.RETRY_MS; }
58
+ });
59
+ Object.defineProperty(exports, "STAMP_PRESETS", {
60
+ enumerable: true,
61
+ get: function () { return chunkULU5LEWF_cjs.STAMP_PRESETS; }
62
+ });
63
+ Object.defineProperty(exports, "annotationsOnPage", {
64
+ enumerable: true,
65
+ get: function () { return chunkULU5LEWF_cjs.annotationsOnPage; }
66
+ });
67
+ Object.defineProperty(exports, "applyAction", {
68
+ enumerable: true,
69
+ get: function () { return chunkULU5LEWF_cjs.applyAction; }
70
+ });
71
+ Object.defineProperty(exports, "canRedo", {
72
+ enumerable: true,
73
+ get: function () { return chunkULU5LEWF_cjs.canRedo; }
74
+ });
75
+ Object.defineProperty(exports, "canUndo", {
76
+ enumerable: true,
77
+ get: function () { return chunkULU5LEWF_cjs.canUndo; }
78
+ });
79
+ Object.defineProperty(exports, "containsPoint", {
80
+ enumerable: true,
81
+ get: function () { return chunkULU5LEWF_cjs.containsPoint; }
82
+ });
83
+ Object.defineProperty(exports, "createHistory", {
84
+ enumerable: true,
85
+ get: function () { return chunkULU5LEWF_cjs.createHistory; }
86
+ });
87
+ Object.defineProperty(exports, "createLocalStorageStore", {
88
+ enumerable: true,
89
+ get: function () { return chunkULU5LEWF_cjs.createLocalStorageStore; }
90
+ });
91
+ Object.defineProperty(exports, "createMemoryStore", {
92
+ enumerable: true,
93
+ get: function () { return chunkULU5LEWF_cjs.createMemoryStore; }
94
+ });
95
+ Object.defineProperty(exports, "dragRect", {
96
+ enumerable: true,
97
+ get: function () { return chunkULU5LEWF_cjs.dragRect; }
98
+ });
99
+ Object.defineProperty(exports, "dragToNorm", {
100
+ enumerable: true,
101
+ get: function () { return chunkULU5LEWF_cjs.dragToNorm; }
102
+ });
103
+ Object.defineProperty(exports, "intersects", {
104
+ enumerable: true,
105
+ get: function () { return chunkULU5LEWF_cjs.intersects; }
106
+ });
107
+ Object.defineProperty(exports, "isTooSmall", {
108
+ enumerable: true,
109
+ get: function () { return chunkULU5LEWF_cjs.isTooSmall; }
110
+ });
111
+ Object.defineProperty(exports, "layerStatusText", {
112
+ enumerable: true,
113
+ get: function () { return chunkULU5LEWF_cjs.layerStatusText; }
114
+ });
115
+ Object.defineProperty(exports, "mergeLayers", {
116
+ enumerable: true,
117
+ get: function () { return chunkULU5LEWF_cjs.mergeLayers; }
118
+ });
119
+ Object.defineProperty(exports, "mergeLineRects", {
120
+ enumerable: true,
121
+ get: function () { return chunkULU5LEWF_cjs.mergeLineRects; }
122
+ });
123
+ Object.defineProperty(exports, "moveItem", {
124
+ enumerable: true,
125
+ get: function () { return chunkULU5LEWF_cjs.moveItem; }
126
+ });
127
+ Object.defineProperty(exports, "patchForRect", {
128
+ enumerable: true,
129
+ get: function () { return chunkULU5LEWF_cjs.patchForRect; }
130
+ });
131
+ Object.defineProperty(exports, "pendingRedactions", {
132
+ enumerable: true,
133
+ get: function () { return chunkULU5LEWF_cjs.pendingRedactions; }
134
+ });
135
+ Object.defineProperty(exports, "qrCornerFor", {
136
+ enumerable: true,
137
+ get: function () { return chunkULU5LEWF_cjs.qrCornerFor; }
138
+ });
139
+ Object.defineProperty(exports, "readSelection", {
140
+ enumerable: true,
141
+ get: function () { return chunkULU5LEWF_cjs.readSelection; }
142
+ });
143
+ Object.defineProperty(exports, "redactionLogCsv", {
144
+ enumerable: true,
145
+ get: function () { return chunkULU5LEWF_cjs.redactionLogCsv; }
146
+ });
147
+ Object.defineProperty(exports, "redactionLogRows", {
148
+ enumerable: true,
149
+ get: function () { return chunkULU5LEWF_cjs.redactionLogRows; }
150
+ });
151
+ Object.defineProperty(exports, "redo", {
152
+ enumerable: true,
153
+ get: function () { return chunkULU5LEWF_cjs.redo; }
154
+ });
155
+ Object.defineProperty(exports, "reduceLayer", {
156
+ enumerable: true,
157
+ get: function () { return chunkULU5LEWF_cjs.reduceLayer; }
158
+ });
159
+ Object.defineProperty(exports, "sameMarks", {
160
+ enumerable: true,
161
+ get: function () { return chunkULU5LEWF_cjs.sameMarks; }
162
+ });
163
+ Object.defineProperty(exports, "selectionToPageMarks", {
164
+ enumerable: true,
165
+ get: function () { return chunkULU5LEWF_cjs.selectionToPageMarks; }
166
+ });
167
+ Object.defineProperty(exports, "singleRect", {
168
+ enumerable: true,
169
+ get: function () { return chunkULU5LEWF_cjs.singleRect; }
170
+ });
171
+ Object.defineProperty(exports, "toNorm", {
172
+ enumerable: true,
173
+ get: function () { return chunkULU5LEWF_cjs.toNorm; }
174
+ });
175
+ Object.defineProperty(exports, "toPixels", {
176
+ enumerable: true,
177
+ get: function () { return chunkULU5LEWF_cjs.toPixels; }
178
+ });
179
+ Object.defineProperty(exports, "undo", {
180
+ enumerable: true,
181
+ get: function () { return chunkULU5LEWF_cjs.undo; }
182
+ });
183
+ Object.defineProperty(exports, "useAnnotationLayer", {
184
+ enumerable: true,
185
+ get: function () { return chunkULU5LEWF_cjs.useAnnotationLayer; }
186
+ });
187
+ Object.defineProperty(exports, "useAnnotationShortcuts", {
188
+ enumerable: true,
189
+ get: function () { return chunkULU5LEWF_cjs.useAnnotationShortcuts; }
190
+ });
191
+ Object.defineProperty(exports, "useTextSelectionMarks", {
192
+ enumerable: true,
193
+ get: function () { return chunkULU5LEWF_cjs.useTextSelectionMarks; }
929
194
  });
930
- function AnnotationPageOverlay({
931
- controller,
932
- pageNumber,
933
- pageWidthPt
934
- }) {
935
- const rootRef = react.useRef(null);
936
- const size = useElementSize(rootRef);
937
- const pxPerPt = size.width / (pageWidthPt ?? FALLBACK_PAGE_WIDTH_PT);
938
- const { tool, selectedId, settings } = controller;
939
- const [draft, setDraft] = react.useState(null);
940
- const [drag, setDrag] = react.useState(null);
941
- const [openComment, setOpenComment] = react.useState(null);
942
- const marks = controller.layer.annotations.filter((a) => a.page === pageNumber);
943
- const hasText = useHasTextLayer(rootRef);
944
- const readOnly = controller.readOnly;
945
- const drawing = !readOnly && (DRAW_TOOLS.includes(tool) || TEXT_TOOLS.includes(tool) && !hasText);
946
- react.useEffect(() => {
947
- if (openComment && selectedId !== openComment) setOpenComment(null);
948
- }, [selectedId, openComment]);
949
- const local = react.useCallback((e) => {
950
- const r = rootRef.current.getBoundingClientRect();
951
- return { x: e.clientX - r.left, y: e.clientY - r.top };
952
- }, []);
953
- const pageSize = () => {
954
- const r = rootRef.current.getBoundingClientRect();
955
- return { width: r.width, height: r.height };
956
- };
957
- const finishDraft = react.useCallback(
958
- (a, b) => {
959
- const page = pageSize();
960
- const rect = dragToNorm(a, b, page);
961
- if (tool === "box") {
962
- if (isTooSmall(rect)) return;
963
- controller.add({
964
- kind: "box",
965
- page: pageNumber,
966
- rect,
967
- color: settings.colors.box,
968
- strokeWidth: settings.strokeWidth
969
- });
970
- } else if (tool === "highlight") {
971
- if (isTooSmall(rect)) return;
972
- controller.add({
973
- kind: "highlight",
974
- page: pageNumber,
975
- rects: [rect],
976
- color: settings.colors.highlight
977
- });
978
- } else if (tool === "redact-area" || tool === "redact-text") {
979
- if (isTooSmall(rect)) return;
980
- controller.add({
981
- kind: "redaction",
982
- page: pageNumber,
983
- rects: [rect],
984
- reason: settings.redactionReason,
985
- status: "pending"
986
- });
987
- } else if (tool === "stamp") {
988
- const placed = isTooSmall(rect) ? chunkSSOPIPEX_cjs.clampRect({
989
- x: a.x / page.width - DEFAULT_STAMP.w / 2,
990
- y: a.y / page.height - DEFAULT_STAMP.h / 2,
991
- ...DEFAULT_STAMP
992
- }) : rect;
993
- controller.add({
994
- kind: "stamp",
995
- page: pageNumber,
996
- rect: placed,
997
- label: settings.stampLabel,
998
- color: settings.colors.stamp
999
- });
1000
- } else if (tool === "comment") {
1001
- const anchor = chunkSSOPIPEX_cjs.clampRect({
1002
- x: a.x / page.width,
1003
- y: a.y / page.height,
1004
- w: COMMENT_ICON_PX / page.width,
1005
- h: COMMENT_ICON_PX / page.height
1006
- });
1007
- const id = controller.add({
1008
- kind: "comment",
1009
- page: pageNumber,
1010
- rect: anchor,
1011
- body: "",
1012
- replies: [],
1013
- resolved: false
1014
- });
1015
- if (id) {
1016
- controller.setTool("select");
1017
- controller.select(id);
1018
- setOpenComment(id);
1019
- }
1020
- }
1021
- },
1022
- [controller, tool, settings, pageNumber]
1023
- );
1024
- const onRootPointerDown = (e) => {
1025
- if (!drawing || e.button !== 0 || e.target !== e.currentTarget) return;
1026
- e.currentTarget.setPointerCapture(e.pointerId);
1027
- const p = local(e);
1028
- setDraft({ a: p, b: p });
1029
- };
1030
- const onRootPointerMove = (e) => {
1031
- if (draft) setDraft({ a: draft.a, b: local(e) });
1032
- };
1033
- const onRootPointerUp = (e) => {
1034
- if (!draft) return;
1035
- const b = local(e);
1036
- const a = draft.a;
1037
- setDraft(null);
1038
- finishDraft(a, b);
1039
- };
1040
- const beginDrag = (e, a, mode) => {
1041
- const origin = singleRect(a);
1042
- if (!origin || e.button !== 0 || readOnly) return;
1043
- e.stopPropagation();
1044
- e.currentTarget.setPointerCapture(e.pointerId);
1045
- setDrag({
1046
- id: a.id,
1047
- mode,
1048
- startX: e.clientX,
1049
- startY: e.clientY,
1050
- origin,
1051
- rect: origin,
1052
- moved: false
1053
- });
1054
- };
1055
- const moveDrag = (e) => {
1056
- if (!drag) return;
1057
- const page = pageSize();
1058
- const dxPx = e.clientX - drag.startX;
1059
- const dyPx = e.clientY - drag.startY;
1060
- const moved = drag.moved || Math.hypot(dxPx, dyPx) > MOVE_THRESHOLD_PX;
1061
- if (!moved) return;
1062
- setDrag({
1063
- ...drag,
1064
- moved: true,
1065
- rect: dragRect(drag.origin, drag.mode, dxPx / page.width, dyPx / page.height)
1066
- });
1067
- };
1068
- const endDrag = (a) => {
1069
- if (!drag) return;
1070
- if (drag.moved) controller.update(a.id, patchForRect(a, drag.rect));
1071
- setDrag(null);
1072
- };
1073
- const interactive = (a) => readOnly ? a.kind === "comment" : tool === "select" || tool === "comment" && a.kind === "comment";
1074
- const selected = marks.find((a) => a.id === selectedId);
1075
- return /* @__PURE__ */ jsxRuntime.jsxs(
1076
- "div",
1077
- {
1078
- ref: rootRef,
1079
- ...{ [PAGE_ATTRIBUTE]: pageNumber },
1080
- "data-testid": `annotation-overlay-${pageNumber}`,
1081
- className: chunkS6A6FSG7_cjs.cn(
1082
- "absolute inset-0 z-10 select-none overflow-hidden",
1083
- drawing && "cursor-crosshair"
1084
- ),
1085
- style: {
1086
- pointerEvents: drawing ? "auto" : "none",
1087
- touchAction: drawing ? "none" : void 0
1088
- },
1089
- onPointerDown: onRootPointerDown,
1090
- onPointerMove: onRootPointerMove,
1091
- onPointerUp: onRootPointerUp,
1092
- onPointerCancel: () => setDraft(null),
1093
- children: [
1094
- marks.map((a) => /* @__PURE__ */ jsxRuntime.jsx(
1095
- MarkView,
1096
- {
1097
- annotation: a,
1098
- rectOverride: drag?.id === a.id ? drag.rect : void 0,
1099
- pxPerPt,
1100
- width: size.width,
1101
- height: size.height,
1102
- selected: a.id === selectedId,
1103
- interactive: interactive(a),
1104
- onPointerDown: (e) => {
1105
- if (!interactive(a)) return;
1106
- e.stopPropagation();
1107
- controller.select(a.id);
1108
- if (a.kind === "comment") setOpenComment(a.id);
1109
- beginDrag(e, a, "move");
1110
- },
1111
- onPointerMove: moveDrag,
1112
- onPointerUp: () => endDrag(a),
1113
- onActivate: () => {
1114
- controller.select(a.id);
1115
- if (a.kind === "comment") setOpenComment(a.id);
1116
- },
1117
- onDelete: () => controller.remove(a.id)
1118
- },
1119
- a.id
1120
- )),
1121
- selected && tool === "select" && !readOnly && singleRect(selected) && /* @__PURE__ */ jsxRuntime.jsx(
1122
- Handles,
1123
- {
1124
- rect: drag?.id === selected.id ? drag.rect : singleRect(selected),
1125
- onPointerDown: (e, mode) => beginDrag(e, selected, mode),
1126
- onPointerMove: moveDrag,
1127
- onPointerUp: () => endDrag(selected)
1128
- }
1129
- ),
1130
- selected && tool === "select" && !readOnly && /* @__PURE__ */ jsxRuntime.jsx(
1131
- ActionBar,
1132
- {
1133
- annotation: selected,
1134
- controller,
1135
- rect: drag?.id === selected.id ? drag.rect : firstRect(selected)
1136
- }
1137
- ),
1138
- draft && /* @__PURE__ */ jsxRuntime.jsx(Draft, { draft, tool }),
1139
- openComment && selected?.kind === "comment" && selected.id === openComment && /* @__PURE__ */ jsxRuntime.jsx(
1140
- CommentPopover,
1141
- {
1142
- annotation: selected,
1143
- controller,
1144
- pageHeight: size.height,
1145
- onClose: () => {
1146
- setOpenComment(null);
1147
- controller.select(null);
1148
- }
1149
- },
1150
- selected.id
1151
- )
1152
- ]
1153
- }
1154
- );
1155
- }
1156
- var firstRect = (a) => a.kind === "highlight" || a.kind === "redaction" ? a.rects[0] : a.rect;
1157
- function MarkView(props) {
1158
- const { annotation: a, rectOverride, pxPerPt, width, height, selected, interactive } = props;
1159
- const handlers = {
1160
- onPointerDown: props.onPointerDown,
1161
- onPointerMove: props.onPointerMove,
1162
- onPointerUp: props.onPointerUp,
1163
- onPointerCancel: props.onPointerUp,
1164
- onKeyDown: (e) => {
1165
- if (e.key === "Enter") props.onActivate();
1166
- if (e.key === "Delete" || e.key === "Backspace") {
1167
- e.preventDefault();
1168
- props.onDelete();
1169
- }
1170
- }
1171
- };
1172
- const base = (label) => ({
1173
- "data-testid": `annotation-mark-${a.id}`,
1174
- "data-kind": a.kind,
1175
- "data-selected": selected ? "true" : void 0,
1176
- role: "button",
1177
- tabIndex: interactive ? 0 : -1,
1178
- "aria-label": label,
1179
- ...handlers
1180
- });
1181
- const ring = selected ? "outline outline-2 outline-offset-2 outline-primary" : "";
1182
- const events = interactive ? "auto" : "none";
1183
- const dragsByTouch = selected && singleRect(a) !== null;
1184
- const cursor = interactive ? singleRect(a) ? "move" : "pointer" : void 0;
1185
- if (a.kind === "highlight") {
1186
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: a.rects.map((r, i) => /* @__PURE__ */ jsxRuntime.jsx(
1187
- "div",
1188
- {
1189
- ...i === 0 ? base(`Highlight: ${a.text ?? ""}`) : {},
1190
- className: chunkS6A6FSG7_cjs.cn("absolute rounded-sm", i === 0 && ring),
1191
- style: {
1192
- ...rectStyle(r),
1193
- background: a.color,
1194
- mixBlendMode: "multiply",
1195
- opacity: 0.7,
1196
- pointerEvents: events,
1197
- touchAction: dragsByTouch ? "none" : void 0,
1198
- cursor
1199
- }
1200
- },
1201
- i
1202
- )) });
1203
- }
1204
- if (a.kind === "box") {
1205
- const r = rectOverride ?? a.rect;
1206
- return /* @__PURE__ */ jsxRuntime.jsx(
1207
- "div",
1208
- {
1209
- ...base("Box"),
1210
- className: chunkS6A6FSG7_cjs.cn("absolute", ring),
1211
- style: {
1212
- ...rectStyle(r),
1213
- border: `${a.strokeWidth * pxPerPt}px solid ${a.color}`,
1214
- pointerEvents: events,
1215
- touchAction: dragsByTouch ? "none" : void 0,
1216
- cursor,
1217
- boxSizing: "border-box"
1218
- }
1219
- }
1220
- );
1221
- }
1222
- if (a.kind === "stamp") {
1223
- const r = rectOverride ?? a.rect;
1224
- const fontPx = Math.max(
1225
- 6,
1226
- Math.min(r.h * height * 0.6, r.w * width * 0.9 / Math.max(1, a.label.length * 0.7))
1227
- );
1228
- return /* @__PURE__ */ jsxRuntime.jsx(
1229
- "div",
1230
- {
1231
- ...base(`Stamp: ${a.label}`),
1232
- className: chunkS6A6FSG7_cjs.cn("absolute flex items-center justify-center font-bold uppercase", ring),
1233
- style: {
1234
- ...rectStyle(r),
1235
- border: `${2 * pxPerPt}px solid ${a.color}`,
1236
- color: a.color,
1237
- fontSize: fontPx,
1238
- lineHeight: 1,
1239
- pointerEvents: events,
1240
- touchAction: dragsByTouch ? "none" : void 0,
1241
- cursor,
1242
- boxSizing: "border-box",
1243
- fontFamily: "Helvetica, Arial, sans-serif"
1244
- },
1245
- children: a.label
1246
- }
1247
- );
1248
- }
1249
- if (a.kind === "comment") {
1250
- const r = rectOverride ?? a.rect;
1251
- return /* @__PURE__ */ jsxRuntime.jsxs(
1252
- "button",
1253
- {
1254
- type: "button",
1255
- ...base(`Comment: ${a.body || "empty"}`),
1256
- onMouseDown: (e) => e.preventDefault(),
1257
- className: chunkS6A6FSG7_cjs.cn(
1258
- "absolute flex items-center justify-center rounded-md border border-amber-700/60 bg-amber-300 text-amber-900 shadow-sm",
1259
- a.resolved && "opacity-50",
1260
- ring
1261
- ),
1262
- style: {
1263
- left: pct(r.x),
1264
- top: pct(r.y),
1265
- width: COMMENT_ICON_PX,
1266
- height: COMMENT_ICON_PX,
1267
- pointerEvents: events,
1268
- touchAction: dragsByTouch ? "none" : void 0,
1269
- cursor
1270
- },
1271
- children: [
1272
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { size: 14 }),
1273
- a.replies.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -right-1 -top-1 rounded-full bg-amber-900 px-1 text-[9px] leading-3 text-white", children: a.replies.length })
1274
- ]
1275
- }
1276
- );
1277
- }
1278
- return /* @__PURE__ */ jsxRuntime.jsx(RedactionView, { ...props, annotation: a, ring, cursor, base });
1279
- }
1280
- function RedactionView({
1281
- annotation: a,
1282
- rectOverride,
1283
- interactive,
1284
- selected,
1285
- ring,
1286
- cursor,
1287
- base
1288
- }) {
1289
- const events = interactive ? "auto" : "none";
1290
- const dragsByTouch = selected && singleRect(a) !== null;
1291
- const rects = rectOverride ? [rectOverride] : a.rects;
1292
- const approved = a.status === "approved";
1293
- const rejected = a.status === "rejected";
1294
- const label = `Redaction (${a.status}): ${a.reason}`;
1295
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: rects.map((r, i) => /* @__PURE__ */ jsxRuntime.jsx(
1296
- "div",
1297
- {
1298
- ...i === 0 ? { ...base(label), title: label } : {},
1299
- "data-status": i === 0 ? a.status : void 0,
1300
- className: chunkS6A6FSG7_cjs.cn(
1301
- "absolute flex items-center justify-center overflow-hidden text-[10px] leading-none",
1302
- i === 0 && ring
1303
- ),
1304
- style: {
1305
- ...rectStyle(r),
1306
- pointerEvents: events,
1307
- touchAction: dragsByTouch ? "none" : void 0,
1308
- cursor,
1309
- boxSizing: "border-box",
1310
- ...approved ? { background: "#000", color: "#fff" } : rejected ? { border: "1px dotted #868e96", opacity: 0.6 } : {
1311
- background: "rgba(224,49,49,0.18)",
1312
- border: "2px dashed #e03131",
1313
- color: "#c92a2a"
1314
- }
1315
- },
1316
- children: i === 0 && !rejected && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate px-1", children: a.reason })
1317
- },
1318
- i
1319
- )) });
1320
- }
1321
- function Draft({ draft, tool }) {
1322
- const x = Math.min(draft.a.x, draft.b.x);
1323
- const y = Math.min(draft.a.y, draft.b.y);
1324
- const w = Math.abs(draft.b.x - draft.a.x);
1325
- const h = Math.abs(draft.b.y - draft.a.y);
1326
- const redact = tool === "redact-area" || tool === "redact-text";
1327
- return /* @__PURE__ */ jsxRuntime.jsx(
1328
- "div",
1329
- {
1330
- "data-testid": "annotation-draft",
1331
- className: "pointer-events-none absolute",
1332
- style: {
1333
- left: x,
1334
- top: y,
1335
- width: w,
1336
- height: h,
1337
- border: redact ? "2px dashed #e03131" : "2px solid #1c7ed6",
1338
- background: redact ? "rgba(224,49,49,0.18)" : "rgba(28,126,214,0.08)"
1339
- }
1340
- }
1341
- );
1342
- }
1343
- var HANDLES = [
1344
- { mode: "nw", style: { left: 0, top: 0 }, cursor: "nwse-resize" },
1345
- { mode: "ne", style: { left: "100%", top: 0 }, cursor: "nesw-resize" },
1346
- { mode: "sw", style: { left: 0, top: "100%" }, cursor: "nesw-resize" },
1347
- { mode: "se", style: { left: "100%", top: "100%" }, cursor: "nwse-resize" }
1348
- ];
1349
- function Handles({
1350
- rect,
1351
- onPointerDown,
1352
- onPointerMove,
1353
- onPointerUp
1354
- }) {
1355
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-none absolute", style: rectStyle(rect), children: HANDLES.map((h) => (
1356
- // The visible dot is small; the element a finger or pointer hits is a larger transparent
1357
- // square around it (44px on touch screens, the usual minimum target).
1358
- /* @__PURE__ */ jsxRuntime.jsx(
1359
- "div",
1360
- {
1361
- "data-testid": `annotation-handle-${h.mode}`,
1362
- className: "pointer-events-auto absolute flex h-6 w-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center pointer-coarse:h-11 pointer-coarse:w-11",
1363
- style: { ...h.style, cursor: h.cursor, touchAction: "none" },
1364
- onPointerDown: (e) => onPointerDown(e, h.mode),
1365
- onPointerMove,
1366
- onPointerUp,
1367
- onPointerCancel: onPointerUp,
1368
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none h-3 w-3 rounded-full border-2 border-primary bg-background" })
1369
- },
1370
- h.mode
1371
- )
1372
- )) });
1373
- }
1374
- var ACTION = "inline-flex h-7 w-7 items-center justify-center rounded text-foreground hover:bg-muted";
1375
- function ActionBar({
1376
- annotation: a,
1377
- controller,
1378
- rect
1379
- }) {
1380
- const above = rect.y > 0.05;
1381
- return /* @__PURE__ */ jsxRuntime.jsxs(
1382
- "div",
1383
- {
1384
- "data-testid": "annotation-actions",
1385
- className: "pointer-events-auto absolute z-20 flex gap-0.5 rounded-md border border-border bg-background p-0.5 shadow-md",
1386
- style: {
1387
- left: pct(rect.x),
1388
- top: above ? `calc(${pct(rect.y)} - 36px)` : `calc(${pct(rect.y + rect.h)} + 6px)`
1389
- },
1390
- onPointerDown: (e) => e.stopPropagation(),
1391
- children: [
1392
- a.kind === "redaction" && /* @__PURE__ */ jsxRuntime.jsx(
1393
- "span",
1394
- {
1395
- className: "max-w-44 truncate self-center px-1.5 text-xs text-muted-foreground",
1396
- title: a.reason,
1397
- "data-testid": "annotation-action-reason",
1398
- children: a.reason
1399
- }
1400
- ),
1401
- a.kind === "redaction" && a.status !== "approved" && /* @__PURE__ */ jsxRuntime.jsx(
1402
- "button",
1403
- {
1404
- type: "button",
1405
- className: ACTION,
1406
- title: "Approve redaction",
1407
- "aria-label": "Approve redaction",
1408
- "data-testid": "annotation-action-approve",
1409
- onClick: () => controller.setRedactionStatus([a.id], "approved"),
1410
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { size: 15 })
1411
- }
1412
- ),
1413
- a.kind === "redaction" && a.status !== "rejected" && /* @__PURE__ */ jsxRuntime.jsx(
1414
- "button",
1415
- {
1416
- type: "button",
1417
- className: ACTION,
1418
- title: "Reject redaction (leave visible)",
1419
- "aria-label": "Reject redaction",
1420
- "data-testid": "annotation-action-reject",
1421
- onClick: () => controller.setRedactionStatus([a.id], "rejected"),
1422
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 15 })
1423
- }
1424
- ),
1425
- a.kind === "redaction" && a.status !== "pending" && /* @__PURE__ */ jsxRuntime.jsx(
1426
- "button",
1427
- {
1428
- type: "button",
1429
- className: ACTION,
1430
- title: "Back to pending",
1431
- "aria-label": "Mark pending",
1432
- "data-testid": "annotation-action-pending",
1433
- onClick: () => controller.setRedactionStatus([a.id], "pending"),
1434
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RotateCcw, { size: 15 })
1435
- }
1436
- ),
1437
- /* @__PURE__ */ jsxRuntime.jsx(
1438
- "button",
1439
- {
1440
- type: "button",
1441
- className: ACTION,
1442
- title: "Delete",
1443
- "aria-label": "Delete annotation",
1444
- "data-testid": "annotation-action-delete",
1445
- onClick: () => controller.remove(a.id),
1446
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 15 })
1447
- }
1448
- )
1449
- ]
1450
- }
1451
- );
1452
- }
1453
- function CommentPopover({
1454
- annotation: a,
1455
- controller,
1456
- pageHeight,
1457
- onClose
1458
- }) {
1459
- const [body, setBody] = react.useState(a.body);
1460
- const [reply, setReply] = react.useState("");
1461
- const [lift, setLift] = react.useState(0);
1462
- const popRef = react.useRef(null);
1463
- const unsaved = react.useRef(null);
1464
- const readOnly = controller.readOnly;
1465
- const mine = a.author === controller.author && !readOnly;
1466
- react.useEffect(() => setBody(a.body), [a.body]);
1467
- react.useLayoutEffect(() => {
1468
- const el = popRef.current;
1469
- if (!el) return;
1470
- const top2 = a.rect.y * pageHeight;
1471
- const fit = () => setLift(Math.min(top2, Math.max(0, top2 + el.offsetHeight - pageHeight)));
1472
- fit();
1473
- const observer = new ResizeObserver(fit);
1474
- observer.observe(el);
1475
- return () => observer.disconnect();
1476
- }, [a.rect.y, pageHeight]);
1477
- const commitBody = () => {
1478
- if (mine && body !== a.body) controller.update(a.id, { body });
1479
- unsaved.current = null;
1480
- };
1481
- react.useEffect(
1482
- () => () => {
1483
- if (unsaved.current !== null) controller.update(a.id, { body: unsaved.current });
1484
- unsaved.current = null;
1485
- },
1486
- // eslint-disable-next-line react-hooks/exhaustive-deps -- runs once, when this comment's box unmounts
1487
- [a.id]
1488
- );
1489
- const close = () => {
1490
- commitBody();
1491
- if (!readOnly && body.trim() === "" && a.replies.length === 0) controller.remove(a.id);
1492
- onClose();
1493
- };
1494
- const sendReply = () => {
1495
- const text = reply.trim();
1496
- if (!text) return;
1497
- commitBody();
1498
- controller.reply(a.id, text);
1499
- setReply("");
1500
- };
1501
- const onRight = a.rect.x > 0.6;
1502
- return /* @__PURE__ */ jsxRuntime.jsxs(
1503
- "div",
1504
- {
1505
- ref: popRef,
1506
- "data-testid": "annotation-comment-popover",
1507
- className: "pointer-events-auto absolute z-30 w-64 rounded-lg border border-border bg-background p-3 text-sm shadow-lg",
1508
- style: {
1509
- top: pct(a.rect.y),
1510
- marginTop: -lift,
1511
- ...onRight ? { right: `calc(${pct(1 - a.rect.x)} + 8px)` } : { left: `calc(${pct(a.rect.x)} + ${COMMENT_ICON_PX + 8}px)` }
1512
- },
1513
- onPointerDown: (e) => e.stopPropagation(),
1514
- children: [
1515
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-2 flex items-center justify-between gap-2 text-xs text-muted-foreground", children: [
1516
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "truncate", children: [
1517
- a.author,
1518
- " \xB7 ",
1519
- new Date(a.createdAt).toLocaleString()
1520
- ] }),
1521
- /* @__PURE__ */ jsxRuntime.jsx(
1522
- "button",
1523
- {
1524
- type: "button",
1525
- "aria-label": "Close comment",
1526
- "data-testid": "annotation-comment-close",
1527
- className: ACTION,
1528
- onClick: close,
1529
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 14 })
1530
- }
1531
- )
1532
- ] }),
1533
- /* @__PURE__ */ jsxRuntime.jsx(
1534
- "textarea",
1535
- {
1536
- autoFocus: a.body === "",
1537
- "data-testid": "annotation-comment-body",
1538
- className: "field-sizing-content max-h-60 min-h-24 w-full resize-y rounded-md border border-input bg-background p-2 text-sm",
1539
- placeholder: "Add a comment",
1540
- value: body,
1541
- readOnly: !mine,
1542
- onChange: (e) => {
1543
- setBody(e.target.value);
1544
- unsaved.current = e.target.value;
1545
- },
1546
- onBlur: commitBody,
1547
- onKeyDown: (e) => {
1548
- if (e.key === "Escape") close();
1549
- if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
1550
- commitBody();
1551
- onClose();
1552
- }
1553
- }
1554
- }
1555
- ),
1556
- a.replies.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1557
- "ul",
1558
- {
1559
- className: "mt-2 max-h-40 space-y-2 overflow-y-auto",
1560
- "data-testid": "annotation-comment-replies",
1561
- children: a.replies.map((r) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "rounded-md bg-muted p-2", children: [
1562
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-muted-foreground", children: r.author }),
1563
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap break-words", children: r.body })
1564
- ] }, r.id))
1565
- }
1566
- ),
1567
- !readOnly && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex gap-1", children: [
1568
- /* @__PURE__ */ jsxRuntime.jsx(
1569
- "input",
1570
- {
1571
- "data-testid": "annotation-comment-reply",
1572
- className: "h-8 min-w-0 flex-1 rounded-md border border-input bg-background px-2 text-sm",
1573
- placeholder: "Reply",
1574
- value: reply,
1575
- onChange: (e) => setReply(e.target.value),
1576
- onKeyDown: (e) => {
1577
- if (e.key === "Enter") {
1578
- e.preventDefault();
1579
- sendReply();
1580
- }
1581
- }
1582
- }
1583
- ),
1584
- /* @__PURE__ */ jsxRuntime.jsx(
1585
- "button",
1586
- {
1587
- type: "button",
1588
- "aria-label": "Send reply",
1589
- "data-testid": "annotation-comment-send",
1590
- className: ACTION,
1591
- onClick: sendReply,
1592
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Send, { size: 14 })
1593
- }
1594
- )
1595
- ] }),
1596
- readOnly ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 text-xs text-muted-foreground", "data-testid": "annotation-comment-status", children: a.resolved ? "Resolved" : "Open" }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex items-center justify-between", children: [
1597
- /* @__PURE__ */ jsxRuntime.jsx(
1598
- "button",
1599
- {
1600
- type: "button",
1601
- "data-testid": "annotation-comment-resolve",
1602
- className: "text-xs text-primary hover:underline",
1603
- onClick: () => controller.resolve(a.id, !a.resolved),
1604
- children: a.resolved ? "Reopen" : "Resolve"
1605
- }
1606
- ),
1607
- /* @__PURE__ */ jsxRuntime.jsx(
1608
- "button",
1609
- {
1610
- type: "button",
1611
- "data-testid": "annotation-comment-delete",
1612
- className: "text-xs text-destructive hover:underline",
1613
- onClick: () => {
1614
- controller.remove(a.id);
1615
- onClose();
1616
- },
1617
- children: "Delete"
1618
- }
1619
- )
1620
- ] })
1621
- ]
1622
- }
1623
- );
1624
- }
1625
- var isEditable = (el) => el instanceof HTMLElement && (el.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName));
1626
- function useAnnotationShortcuts(controller, enabled = true) {
1627
- react.useEffect(() => {
1628
- if (!enabled) return;
1629
- const onKey = (e) => {
1630
- if (isEditable(e.target)) return;
1631
- const mod = e.metaKey || e.ctrlKey;
1632
- if (mod && e.key.toLowerCase() === "z") {
1633
- e.preventDefault();
1634
- if (e.shiftKey) controller.redo();
1635
- else controller.undo();
1636
- } else if (mod && e.key.toLowerCase() === "y") {
1637
- e.preventDefault();
1638
- controller.redo();
1639
- } else if ((e.key === "Delete" || e.key === "Backspace") && controller.selectedId) {
1640
- e.preventDefault();
1641
- controller.remove(controller.selectedId);
1642
- } else if (e.key === "Escape") {
1643
- controller.select(null);
1644
- controller.setTool("select");
1645
- }
1646
- };
1647
- document.addEventListener("keydown", onKey);
1648
- return () => document.removeEventListener("keydown", onKey);
1649
- }, [controller, enabled]);
1650
- }
1651
- var TOOLS = [
1652
- { tool: "select", label: "Select", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MousePointer2, { size: 16 }) },
1653
- { tool: "highlight", label: "Highlight", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Highlighter, { size: 16 }) },
1654
- { tool: "box", label: "Box", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Square, { size: 16 }) },
1655
- { tool: "comment", label: "Comment", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { size: 16 }) },
1656
- { tool: "stamp", label: "Stamp", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Stamp, { size: 16 }) },
1657
- { tool: "redact-text", label: "Redact text", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ScanText, { size: 16 }) },
1658
- { tool: "redact-area", label: "Redact area", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { size: 16 }) }
1659
- ];
1660
- function Swatches({
1661
- colors,
1662
- value,
1663
- onChange,
1664
- label
1665
- }) {
1666
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1", role: "group", "aria-label": label, children: colors.map((c) => /* @__PURE__ */ jsxRuntime.jsx(
1667
- "button",
1668
- {
1669
- type: "button",
1670
- "aria-label": `${label} ${c}`,
1671
- "aria-pressed": c === value,
1672
- "data-testid": `annotation-color-${c.slice(1)}`,
1673
- className: chunkS6A6FSG7_cjs.cn(
1674
- "h-5 w-5 rounded-full border border-border",
1675
- c === value && "ring-2 ring-primary ring-offset-1"
1676
- ),
1677
- style: { background: c },
1678
- onClick: () => onChange(c)
1679
- },
1680
- c
1681
- )) });
1682
- }
1683
- function PresetField({
1684
- label,
1685
- testId,
1686
- value,
1687
- presets,
1688
- maxLength,
1689
- className,
1690
- onChange
1691
- }) {
1692
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
1693
- /* @__PURE__ */ jsxRuntime.jsx(
1694
- "input",
1695
- {
1696
- "aria-label": label,
1697
- "data-testid": testId,
1698
- className: chunkS6A6FSG7_cjs.cn("h-8 rounded-l-md border border-input bg-background px-2 text-sm", className),
1699
- value,
1700
- maxLength,
1701
- onFocus: (e) => e.currentTarget.select(),
1702
- onChange: (e) => onChange(e.target.value)
1703
- }
1704
- ),
1705
- /* @__PURE__ */ jsxRuntime.jsxs(chunkHJDR5HEO_cjs.DropdownMenu, { children: [
1706
- /* @__PURE__ */ jsxRuntime.jsx(chunkHJDR5HEO_cjs.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1707
- "button",
1708
- {
1709
- type: "button",
1710
- "aria-label": `Choose ${label.toLowerCase()}`,
1711
- title: `Choose ${label.toLowerCase()}`,
1712
- "data-testid": `${testId}-presets`,
1713
- className: "flex h-8 items-center rounded-r-md border border-l-0 border-input bg-background px-1.5 text-muted-foreground hover:bg-accent",
1714
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: 14 })
1715
- }
1716
- ) }),
1717
- /* @__PURE__ */ jsxRuntime.jsx(chunkHJDR5HEO_cjs.DropdownMenuContent, { align: "end", children: presets.map((p) => /* @__PURE__ */ jsxRuntime.jsx(chunkHJDR5HEO_cjs.DropdownMenuItem, { onSelect: () => onChange(p), children: p }, p)) })
1718
- ] })
1719
- ] });
1720
- }
1721
- function AnnotationToolbar({
1722
- controller,
1723
- onFreeze,
1724
- actions,
1725
- className
1726
- }) {
1727
- useTextSelectionMarks(controller);
1728
- useAnnotationShortcuts(controller);
1729
- const { tool, settings } = controller;
1730
- const pending = pendingRedactions(controller.layer);
1731
- const redactionCount = controller.layer.annotations.filter((a) => a.kind === "redaction").length;
1732
- const colored = tool === "highlight" || tool === "box" || tool === "stamp";
1733
- const redacting = tool === "redact-text" || tool === "redact-area";
1734
- const status = layerStatusText(controller);
1735
- const editable = !controller.readOnly;
1736
- const redactionControls = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1737
- editable && redacting && /* @__PURE__ */ jsxRuntime.jsx(
1738
- PresetField,
1739
- {
1740
- label: "Redaction reason",
1741
- testId: "annotation-redaction-reason",
1742
- className: "w-44",
1743
- value: settings.redactionReason,
1744
- presets: REDACTION_REASONS,
1745
- maxLength: 80,
1746
- onChange: (redactionReason) => controller.setSettings({ redactionReason })
1747
- }
1748
- ),
1749
- redactionCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm", "data-testid": "annotation-review", children: [
1750
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rounded-md bg-muted px-2 py-1", "data-testid": "annotation-pending-count", children: [
1751
- pending.length,
1752
- " pending"
1753
- ] }),
1754
- editable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1755
- /* @__PURE__ */ jsxRuntime.jsx(
1756
- chunkLQ5YHB7W_cjs.Button,
1757
- {
1758
- type: "button",
1759
- size: "sm",
1760
- variant: "outline",
1761
- disabled: pending.length === 0,
1762
- "data-testid": "annotation-approve-all",
1763
- onClick: () => controller.setRedactionStatus(
1764
- pending.map((a) => a.id),
1765
- "approved"
1766
- ),
1767
- children: "Approve all"
1768
- }
1769
- ),
1770
- /* @__PURE__ */ jsxRuntime.jsx(
1771
- chunkLQ5YHB7W_cjs.Button,
1772
- {
1773
- type: "button",
1774
- size: "sm",
1775
- variant: "outline",
1776
- disabled: pending.length === 0,
1777
- "data-testid": "annotation-reject-all",
1778
- onClick: () => controller.setRedactionStatus(
1779
- pending.map((a) => a.id),
1780
- "rejected"
1781
- ),
1782
- children: "Reject all"
1783
- }
1784
- )
1785
- ] })
1786
- ] })
1787
- ] });
1788
- return /* @__PURE__ */ jsxRuntime.jsxs(
1789
- "div",
1790
- {
1791
- role: "toolbar",
1792
- "aria-label": "Annotation tools",
1793
- "data-testid": "annotation-toolbar",
1794
- className: chunkS6A6FSG7_cjs.cn(
1795
- "flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border bg-background px-3 py-2",
1796
- className
1797
- ),
1798
- children: [
1799
- editable && /* @__PURE__ */ jsxRuntime.jsxs(
1800
- "div",
1801
- {
1802
- className: "flex items-center gap-1 border-r border-border pr-3",
1803
- role: "group",
1804
- "aria-label": "History",
1805
- children: [
1806
- /* @__PURE__ */ jsxRuntime.jsx(
1807
- chunkLQ5YHB7W_cjs.Button,
1808
- {
1809
- type: "button",
1810
- size: "icon",
1811
- variant: "ghost",
1812
- title: "Undo",
1813
- "aria-label": "Undo",
1814
- "data-testid": "annotation-undo",
1815
- disabled: !controller.canUndo,
1816
- onClick: controller.undo,
1817
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { size: 16 })
1818
- }
1819
- ),
1820
- /* @__PURE__ */ jsxRuntime.jsx(
1821
- chunkLQ5YHB7W_cjs.Button,
1822
- {
1823
- type: "button",
1824
- size: "icon",
1825
- variant: "ghost",
1826
- title: "Redo",
1827
- "aria-label": "Redo",
1828
- "data-testid": "annotation-redo",
1829
- disabled: !controller.canRedo,
1830
- onClick: controller.redo,
1831
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { size: 16 })
1832
- }
1833
- )
1834
- ]
1835
- }
1836
- ),
1837
- editable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1", role: "group", "aria-label": "Tool", children: TOOLS.map(({ tool: t, label, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
1838
- chunkLQ5YHB7W_cjs.Button,
1839
- {
1840
- type: "button",
1841
- size: "icon",
1842
- variant: tool === t ? "default" : "ghost",
1843
- title: label,
1844
- "aria-label": label,
1845
- "aria-pressed": tool === t,
1846
- "data-testid": `annotation-tool-${t}`,
1847
- onClick: () => controller.setTool(t),
1848
- children: icon
1849
- },
1850
- t
1851
- )) }),
1852
- editable && colored && /* @__PURE__ */ jsxRuntime.jsx(
1853
- Swatches,
1854
- {
1855
- label: "Colour",
1856
- colors: tool === "highlight" ? HIGHLIGHT_COLORS : MARK_COLORS,
1857
- value: settings.colors[tool],
1858
- onChange: (c) => controller.setSettings({ colors: { ...settings.colors, [tool]: c } })
1859
- }
1860
- ),
1861
- editable && tool === "stamp" && /* @__PURE__ */ jsxRuntime.jsx(
1862
- PresetField,
1863
- {
1864
- label: "Stamp text",
1865
- testId: "annotation-stamp-label",
1866
- className: "w-40",
1867
- value: settings.stampLabel,
1868
- presets: STAMP_PRESETS,
1869
- maxLength: 40,
1870
- onChange: (stampLabel) => controller.setSettings({ stampLabel })
1871
- }
1872
- ),
1873
- (redacting || redactionCount > 0) && /* @__PURE__ */ jsxRuntime.jsx(
1874
- "div",
1875
- {
1876
- className: "flex w-full flex-wrap items-center gap-x-3 gap-y-2",
1877
- "data-testid": "annotation-redaction-row",
1878
- children: redactionControls
1879
- }
1880
- ),
1881
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center justify-end gap-3 text-xs text-muted-foreground", children: [
1882
- /* @__PURE__ */ jsxRuntime.jsx(
1883
- "span",
1884
- {
1885
- "data-testid": "annotation-status",
1886
- role: "status",
1887
- "data-state": controller.readOnly ? "readonly" : controller.offline ? "offline" : controller.error ? "error" : controller.saving ? "saving" : controller.dirty ? "dirty" : "saved",
1888
- className: chunkS6A6FSG7_cjs.cn(controller.error && !controller.offline && "text-destructive"),
1889
- title: controller.error ?? void 0,
1890
- children: status
1891
- }
1892
- ),
1893
- actions,
1894
- onFreeze && /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.Button, { type: "button", size: "sm", "data-testid": "annotation-freeze", onClick: onFreeze, children: [
1895
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Snowflake, { size: 14 }),
1896
- "Freeze copy"
1897
- ] })
1898
- ] })
1899
- ]
1900
- }
1901
- );
1902
- }
1903
- var KIND_LABELS = {
1904
- highlight: "highlights",
1905
- box: "boxes",
1906
- comment: "comments",
1907
- stamp: "stamps",
1908
- redaction: "redactions"
1909
- };
1910
- function FreezeDialog({
1911
- open,
1912
- onOpenChange,
1913
- controller,
1914
- onConfirm,
1915
- busy,
1916
- progress,
1917
- error
1918
- }) {
1919
- const [mode, setMode] = react.useState("vector");
1920
- const [comments, setComments] = react.useState("omit");
1921
- const [burnPending, setBurnPending] = react.useState(false);
1922
- const [redactionLog, setRedactionLog] = react.useState(true);
1923
- const marks = controller.layer.annotations;
1924
- const redactions = marks.filter(chunkSSOPIPEX_cjs.isEffectiveRedaction);
1925
- const pending = pendingRedactions(controller.layer);
1926
- const hasRedactionMarks = marks.some((a) => a.kind === "redaction");
1927
- const forced = redactions.length > 0;
1928
- const effectiveMode = forced ? "image" : mode;
1929
- const blocked = pending.length > 0 && !burnPending;
1930
- const counts = Object.keys(KIND_LABELS).map(
1931
- (k) => [
1932
- k,
1933
- marks.filter((a) => a.kind === k && (k !== "redaction" || chunkSSOPIPEX_cjs.isEffectiveRedaction(a))).length
1934
- ]
1935
- ).filter(([, n]) => n > 0);
1936
- return /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.Dialog, { open, onOpenChange: (next) => !busy && onOpenChange(next), children: /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogContent, { "data-testid": "freeze-dialog", children: [
1937
- /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogHeader, { children: [
1938
- /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.DialogTitle, { children: "Freeze a copy" }),
1939
- /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.DialogDescription, { children: "Saves a separate document with your annotations built in, next to the original. The original stays as it is." })
1940
- ] }),
1941
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", "data-testid": "freeze-summary", children: counts.length === 0 ? "No annotations yet." : counts.map(([k, n]) => `${n} ${KIND_LABELS[k]}`).join(", ") }),
1942
- /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { className: "space-y-2 text-sm", disabled: busy, children: [
1943
- /* @__PURE__ */ jsxRuntime.jsx("legend", { className: "mb-1 font-medium", children: "Format" }),
1944
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-start gap-2", children: [
1945
- /* @__PURE__ */ jsxRuntime.jsx(
1946
- "input",
1947
- {
1948
- type: "radio",
1949
- name: "freeze-mode",
1950
- "data-testid": "freeze-mode-vector",
1951
- checked: effectiveMode === "vector",
1952
- disabled: forced,
1953
- onChange: () => setMode("vector")
1954
- }
1955
- ),
1956
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1957
- "Keep text",
1958
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-xs text-muted-foreground", children: "Searchable, smaller. Not available when there are redactions." })
1959
- ] })
1960
- ] }),
1961
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-start gap-2", children: [
1962
- /* @__PURE__ */ jsxRuntime.jsx(
1963
- "input",
1964
- {
1965
- type: "radio",
1966
- name: "freeze-mode",
1967
- "data-testid": "freeze-mode-image",
1968
- checked: effectiveMode === "image",
1969
- onChange: () => setMode("image")
1970
- }
1971
- ),
1972
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1973
- "Image only",
1974
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-xs text-muted-foreground", children: "Every page becomes a picture. Nothing is left behind a redaction." })
1975
- ] })
1976
- ] }),
1977
- forced && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", "data-testid": "freeze-forced-note", children: "Image only is required because this document has redactions." })
1978
- ] }),
1979
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
1980
- "Comments",
1981
- /* @__PURE__ */ jsxRuntime.jsxs(
1982
- "select",
1983
- {
1984
- "data-testid": "freeze-comments",
1985
- className: "h-8 rounded-md border border-input bg-background px-2",
1986
- value: comments,
1987
- disabled: busy,
1988
- onChange: (e) => setComments(e.target.value),
1989
- children: [
1990
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "omit", children: "Leave out" }),
1991
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "markers", children: "Numbered markers" }),
1992
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "appendix", children: "Markers and a listing" })
1993
- ]
1994
- }
1995
- )
1996
- ] }),
1997
- forced && comments !== "omit" && marks.some((a) => a.kind === "comment") && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-destructive", "data-testid": "freeze-comment-warning", children: "Comments are copied as written and may repeat text you have redacted." }),
1998
- pending.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
1999
- "label",
2000
- {
2001
- className: "flex items-start gap-2 rounded-md border border-border p-2 text-sm",
2002
- "data-testid": "freeze-pending",
2003
- children: [
2004
- /* @__PURE__ */ jsxRuntime.jsx(
2005
- "input",
2006
- {
2007
- type: "checkbox",
2008
- "data-testid": "freeze-burn-pending",
2009
- checked: burnPending,
2010
- disabled: busy,
2011
- onChange: (e) => setBurnPending(e.target.checked)
2012
- }
2013
- ),
2014
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2015
- pending.length,
2016
- " redaction",
2017
- pending.length === 1 ? " has" : "s have",
2018
- " not been reviewed",
2019
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-xs text-muted-foreground", children: "Tick to redact them as well, or approve or reject them first." })
2020
- ] })
2021
- ]
2022
- }
2023
- ),
2024
- hasRedactionMarks && /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-start gap-2 text-sm", children: [
2025
- /* @__PURE__ */ jsxRuntime.jsx(
2026
- "input",
2027
- {
2028
- type: "checkbox",
2029
- "data-testid": "freeze-redaction-log",
2030
- checked: redactionLog,
2031
- disabled: busy,
2032
- onChange: (e) => setRedactionLog(e.target.checked)
2033
- }
2034
- ),
2035
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2036
- "Download a redaction log (CSV)",
2037
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-xs text-muted-foreground", children: "Page, reason, status, who approved it and when. Never the redacted text." })
2038
- ] })
2039
- ] }),
2040
- busy && progress && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm", role: "status", "data-testid": "freeze-progress", children: [
2041
- "Page ",
2042
- progress.done,
2043
- " of ",
2044
- progress.total,
2045
- "\u2026"
2046
- ] }),
2047
- error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", role: "alert", "data-testid": "freeze-error", children: error }),
2048
- /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogFooter, { children: [
2049
- /* @__PURE__ */ jsxRuntime.jsx(
2050
- chunkLQ5YHB7W_cjs.Button,
2051
- {
2052
- type: "button",
2053
- variant: "outline",
2054
- disabled: busy,
2055
- onClick: () => onOpenChange(false),
2056
- children: "Cancel"
2057
- }
2058
- ),
2059
- /* @__PURE__ */ jsxRuntime.jsx(
2060
- chunkLQ5YHB7W_cjs.Button,
2061
- {
2062
- type: "button",
2063
- "data-testid": "freeze-confirm",
2064
- disabled: busy || blocked,
2065
- onClick: () => onConfirm({
2066
- mode: effectiveMode,
2067
- comments,
2068
- pendingRedactions: burnPending ? "burn" : "error",
2069
- redactionLog: hasRedactionMarks && redactionLog
2070
- }),
2071
- children: busy ? "Freezing\u2026" : "Freeze"
2072
- }
2073
- )
2074
- ] })
2075
- ] }) });
2076
- }
2077
- var MAX_PREFIX = 24;
2078
- function previewLabel(choices) {
2079
- return `${choices.prefix}${String(choices.start).padStart(choices.digits, "0")}`;
2080
- }
2081
- function qrCornerFor(corner) {
2082
- return corner.endsWith("left") ? "bottom-right" : "bottom-left";
2083
- }
2084
- function moveItem(items, from, to) {
2085
- if (from === to || from < 0 || to < 0 || from >= items.length || to >= items.length)
2086
- return [...items];
2087
- const next = [...items];
2088
- const [moved] = next.splice(from, 1);
2089
- next.splice(to, 0, moved);
2090
- return next;
2091
- }
2092
- function ProductionDialog({
2093
- open,
2094
- onOpenChange,
2095
- documents,
2096
- leftOut = [],
2097
- onConfirm,
2098
- busy,
2099
- progress,
2100
- error
2101
- }) {
2102
- const [layout, setLayout] = react.useState("merged");
2103
- const [prefix, setPrefix] = react.useState("");
2104
- const [start, setStart] = react.useState(1);
2105
- const [digits, setDigits] = react.useState(6);
2106
- const [corner, setCorner] = react.useState("bottom-right");
2107
- const [qr, setQr] = react.useState(false);
2108
- const [indexPage, setIndexPage] = react.useState(false);
2109
- const [saveToWorkspace, setSaveToWorkspace] = react.useState(true);
2110
- const documentKey = documents.map((d) => d.id).join("|");
2111
- const [ordered, setOrdered] = react.useState(documents);
2112
- react.useEffect(() => setOrdered(documents), [documentKey]);
2113
- const listRef = react.useRef(null);
2114
- const [dragFrom, setDragFrom] = react.useState(null);
2115
- const focusAfterMove = react.useRef(null);
2116
- react.useEffect(() => {
2117
- const pending = focusAfterMove.current;
2118
- focusAfterMove.current = null;
2119
- if (!pending || !listRef.current) return;
2120
- const button = (arrow) => listRef.current?.querySelector(
2121
- `[data-testid="production-move-${arrow}-${pending.index}"]:not(:disabled)`
2122
- );
2123
- (button(pending.arrow) ?? button(pending.arrow === "up" ? "down" : "up"))?.focus();
2124
- }, [ordered]);
2125
- const move = (from, to, arrow) => {
2126
- if (arrow) focusAfterMove.current = { index: to, arrow };
2127
- setOrdered((items) => moveItem(items, from, to));
2128
- };
2129
- const onDrop = (to) => (e) => {
2130
- e.preventDefault();
2131
- if (dragFrom !== null) move(dragFrom, to);
2132
- setDragFrom(null);
2133
- };
2134
- const valid = Number.isInteger(start) && start >= 0 && Number.isInteger(digits) && digits >= 1 && digits <= 12;
2135
- return /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.Dialog, { open, onOpenChange: (next) => !busy && onOpenChange(next), children: /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogContent, { "data-testid": "production-dialog", className: "max-h-[90dvh] overflow-y-auto", children: [
2136
- /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogHeader, { children: [
2137
- /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.DialogTitle, { children: "Production set" }),
2138
- /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.DialogDescription, { children: "Numbers every page with a Bates label, in the order shown. The originals are never changed; the result is downloaded and, if you choose, saved to the workspace." })
2139
- ] }),
2140
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", "data-testid": "production-summary", children: [
2141
- documents.length,
2142
- " document",
2143
- documents.length === 1 ? "" : "s",
2144
- ", numbered in this order.",
2145
- ordered.length > 1 ? " Drag a row or use its arrows to reorder." : ""
2146
- ] }),
2147
- /* @__PURE__ */ jsxRuntime.jsx(
2148
- "ol",
2149
- {
2150
- ref: listRef,
2151
- className: "max-h-48 space-y-1 overflow-y-auto text-sm",
2152
- "data-testid": "production-order",
2153
- "aria-label": "Numbering order",
2154
- children: ordered.map((doc, i) => /* @__PURE__ */ jsxRuntime.jsxs(
2155
- "li",
2156
- {
2157
- draggable: !busy,
2158
- onDragStart: () => setDragFrom(i),
2159
- onDragOver: (e) => e.preventDefault(),
2160
- onDrop: onDrop(i),
2161
- onDragEnd: () => setDragFrom(null),
2162
- className: `flex items-center gap-1 rounded-md border border-border px-2 py-1 ${dragFrom === i ? "opacity-50" : ""}`,
2163
- "data-testid": `production-order-item-${i}`,
2164
- "data-document-id": doc.id,
2165
- children: [
2166
- /* @__PURE__ */ jsxRuntime.jsx(
2167
- lucideReact.GripVertical,
2168
- {
2169
- className: "size-4 shrink-0 cursor-grab text-muted-foreground",
2170
- "aria-hidden": true
2171
- }
2172
- ),
2173
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "w-6 shrink-0 text-right tabular-nums text-muted-foreground", children: [
2174
- i + 1,
2175
- "."
2176
- ] }),
2177
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", title: doc.name, children: doc.name }),
2178
- /* @__PURE__ */ jsxRuntime.jsx(
2179
- chunkLQ5YHB7W_cjs.Button,
2180
- {
2181
- type: "button",
2182
- variant: "ghost",
2183
- size: "icon",
2184
- className: "size-7 pointer-coarse:size-11",
2185
- "aria-label": `Move ${doc.name} up`,
2186
- "data-testid": `production-move-up-${i}`,
2187
- disabled: busy || i === 0,
2188
- onClick: () => move(i, i - 1, "up"),
2189
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "size-4" })
2190
- }
2191
- ),
2192
- /* @__PURE__ */ jsxRuntime.jsx(
2193
- chunkLQ5YHB7W_cjs.Button,
2194
- {
2195
- type: "button",
2196
- variant: "ghost",
2197
- size: "icon",
2198
- className: "size-7 pointer-coarse:size-11",
2199
- "aria-label": `Move ${doc.name} down`,
2200
- "data-testid": `production-move-down-${i}`,
2201
- disabled: busy || i === ordered.length - 1,
2202
- onClick: () => move(i, i + 1, "down"),
2203
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "size-4" })
2204
- }
2205
- )
2206
- ]
2207
- },
2208
- doc.id
2209
- ))
2210
- }
2211
- ),
2212
- leftOut.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", "data-testid": "production-left-out", children: [
2213
- "Left out, with no PDF version to number: ",
2214
- leftOut.join(", ")
2215
- ] }),
2216
- /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { className: "space-y-2 text-sm", disabled: busy, children: [
2217
- /* @__PURE__ */ jsxRuntime.jsx("legend", { className: "mb-1 font-medium", children: "Files" }),
2218
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-start gap-2", children: [
2219
- /* @__PURE__ */ jsxRuntime.jsx(
2220
- "input",
2221
- {
2222
- type: "radio",
2223
- name: "production-layout",
2224
- "data-testid": "production-layout-merged",
2225
- checked: layout === "merged",
2226
- onChange: () => setLayout("merged")
2227
- }
2228
- ),
2229
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2230
- "One merged file",
2231
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-xs text-muted-foreground", children: "All documents joined, numbered consecutively." })
2232
- ] })
2233
- ] }),
2234
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-start gap-2", children: [
2235
- /* @__PURE__ */ jsxRuntime.jsx(
2236
- "input",
2237
- {
2238
- type: "radio",
2239
- name: "production-layout",
2240
- "data-testid": "production-layout-per-document",
2241
- checked: layout === "per-document",
2242
- onChange: () => setLayout("per-document")
2243
- }
2244
- ),
2245
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2246
- "One file per document",
2247
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-xs text-muted-foreground", children: "Numbering carries on from one file to the next." })
2248
- ] })
2249
- ] })
2250
- ] }),
2251
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-3 gap-2 text-sm", children: [
2252
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
2253
- "Prefix",
2254
- /* @__PURE__ */ jsxRuntime.jsx(
2255
- "input",
2256
- {
2257
- "data-testid": "production-prefix",
2258
- className: "h-8 w-full rounded-md border border-input bg-background px-2",
2259
- value: prefix,
2260
- maxLength: MAX_PREFIX,
2261
- disabled: busy,
2262
- onChange: (e) => setPrefix(e.target.value)
2263
- }
2264
- )
2265
- ] }),
2266
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
2267
- "Start at",
2268
- /* @__PURE__ */ jsxRuntime.jsx(
2269
- "input",
2270
- {
2271
- "data-testid": "production-start",
2272
- type: "number",
2273
- min: 0,
2274
- className: "h-8 w-full rounded-md border border-input bg-background px-2",
2275
- value: start,
2276
- disabled: busy,
2277
- onChange: (e) => setStart(e.target.valueAsNumber)
2278
- }
2279
- )
2280
- ] }),
2281
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
2282
- "Digits",
2283
- /* @__PURE__ */ jsxRuntime.jsx(
2284
- "input",
2285
- {
2286
- "data-testid": "production-digits",
2287
- type: "number",
2288
- min: 1,
2289
- max: 12,
2290
- className: "h-8 w-full rounded-md border border-input bg-background px-2",
2291
- value: digits,
2292
- disabled: busy,
2293
- onChange: (e) => setDigits(e.target.valueAsNumber)
2294
- }
2295
- )
2296
- ] })
2297
- ] }),
2298
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
2299
- "Label position",
2300
- /* @__PURE__ */ jsxRuntime.jsxs(
2301
- "select",
2302
- {
2303
- "data-testid": "production-corner",
2304
- className: "h-8 rounded-md border border-input bg-background px-2",
2305
- value: corner,
2306
- disabled: busy,
2307
- onChange: (e) => setCorner(e.target.value),
2308
- children: [
2309
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "bottom-right", children: "Bottom right" }),
2310
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "bottom-left", children: "Bottom left" }),
2311
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "top-right", children: "Top right" }),
2312
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "top-left", children: "Top left" })
2313
- ]
2314
- }
2315
- )
2316
- ] }),
2317
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-start gap-2 text-sm", children: [
2318
- /* @__PURE__ */ jsxRuntime.jsx(
2319
- "input",
2320
- {
2321
- type: "checkbox",
2322
- "data-testid": "production-qr",
2323
- checked: qr,
2324
- disabled: busy,
2325
- onChange: (e) => setQr(e.target.checked)
2326
- }
2327
- ),
2328
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2329
- "QR code on every page",
2330
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-xs text-muted-foreground", children: "Opens the document in ARBI for anyone with access." })
2331
- ] })
2332
- ] }),
2333
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-start gap-2 text-sm", children: [
2334
- /* @__PURE__ */ jsxRuntime.jsx(
2335
- "input",
2336
- {
2337
- type: "checkbox",
2338
- "data-testid": "production-index",
2339
- checked: indexPage,
2340
- disabled: busy,
2341
- onChange: (e) => setIndexPage(e.target.checked)
2342
- }
2343
- ),
2344
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2345
- "Index page at the start",
2346
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-xs text-muted-foreground", children: "Lists every document with its Bates range. The index itself is not numbered." })
2347
- ] })
2348
- ] }),
2349
- /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-start gap-2 text-sm", children: [
2350
- /* @__PURE__ */ jsxRuntime.jsx(
2351
- "input",
2352
- {
2353
- type: "checkbox",
2354
- "data-testid": "production-save",
2355
- checked: saveToWorkspace,
2356
- disabled: busy,
2357
- onChange: (e) => setSaveToWorkspace(e.target.checked)
2358
- }
2359
- ),
2360
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2361
- "Save to workspace",
2362
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-xs text-muted-foreground", children: layout === "merged" ? "Adds the merged PDF to the Productions folder, so it can be shared or emailed." : "Adds each numbered file to a folder under Productions, so they can be shared or emailed." })
2363
- ] })
2364
- ] }),
2365
- valid && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm", "data-testid": "production-preview", children: [
2366
- "First label:",
2367
- " ",
2368
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: previewLabel({ prefix, start, digits }) })
2369
- ] }),
2370
- busy && progress && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm", role: "status", "data-testid": "production-progress", children: [
2371
- "Document ",
2372
- progress.done,
2373
- " of ",
2374
- progress.total,
2375
- "\u2026"
2376
- ] }),
2377
- error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", role: "alert", "data-testid": "production-error", children: error }),
2378
- /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogFooter, { children: [
2379
- /* @__PURE__ */ jsxRuntime.jsx(
2380
- chunkLQ5YHB7W_cjs.Button,
2381
- {
2382
- type: "button",
2383
- variant: "outline",
2384
- disabled: busy,
2385
- onClick: () => onOpenChange(false),
2386
- children: "Cancel"
2387
- }
2388
- ),
2389
- /* @__PURE__ */ jsxRuntime.jsx(
2390
- chunkLQ5YHB7W_cjs.Button,
2391
- {
2392
- type: "button",
2393
- "data-testid": "production-confirm",
2394
- disabled: busy || !valid || ordered.length === 0,
2395
- onClick: () => onConfirm({
2396
- layout,
2397
- prefix,
2398
- start,
2399
- digits,
2400
- corner,
2401
- qr,
2402
- indexPage,
2403
- saveToWorkspace,
2404
- order: ordered.map((d) => d.id)
2405
- }),
2406
- children: busy ? "Working\u2026" : "Create production"
2407
- }
2408
- )
2409
- ] })
2410
- ] }) });
2411
- }
2412
-
2413
195
  Object.defineProperty(exports, "AnnotationLayerError", {
2414
196
  enumerable: true,
2415
197
  get: function () { return chunkSSOPIPEX_cjs.AnnotationLayerError; }
@@ -2442,51 +224,5 @@ Object.defineProperty(exports, "parseLayer", {
2442
224
  enumerable: true,
2443
225
  get: function () { return chunkSSOPIPEX_cjs.parseLayer; }
2444
226
  });
2445
- exports.AUTOSAVE_MS = AUTOSAVE_MS;
2446
- exports.AnnotationPageOverlay = AnnotationPageOverlay;
2447
- exports.AnnotationStoreOfflineError = AnnotationStoreOfflineError;
2448
- exports.AnnotationToolbar = AnnotationToolbar;
2449
- exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
2450
- exports.FreezeDialog = FreezeDialog;
2451
- exports.HIGHLIGHT_COLORS = HIGHLIGHT_COLORS;
2452
- exports.MARK_COLORS = MARK_COLORS;
2453
- exports.ProductionDialog = ProductionDialog;
2454
- exports.REDACTION_LOG_COLUMNS = REDACTION_LOG_COLUMNS;
2455
- exports.REDACTION_REASONS = REDACTION_REASONS;
2456
- exports.RETRY_MS = RETRY_MS;
2457
- exports.STAMP_PRESETS = STAMP_PRESETS;
2458
- exports.annotationsOnPage = annotationsOnPage;
2459
- exports.applyAction = applyAction;
2460
- exports.canRedo = canRedo;
2461
- exports.canUndo = canUndo;
2462
- exports.containsPoint = containsPoint;
2463
- exports.createHistory = createHistory;
2464
- exports.createLocalStorageStore = createLocalStorageStore;
2465
- exports.createMemoryStore = createMemoryStore;
2466
- exports.dragRect = dragRect;
2467
- exports.dragToNorm = dragToNorm;
2468
- exports.intersects = intersects;
2469
- exports.isTooSmall = isTooSmall;
2470
- exports.layerStatusText = layerStatusText;
2471
- exports.mergeLayers = mergeLayers;
2472
- exports.mergeLineRects = mergeLineRects;
2473
- exports.moveItem = moveItem;
2474
- exports.patchForRect = patchForRect;
2475
- exports.pendingRedactions = pendingRedactions;
2476
- exports.qrCornerFor = qrCornerFor;
2477
- exports.readSelection = readSelection;
2478
- exports.redactionLogCsv = redactionLogCsv;
2479
- exports.redactionLogRows = redactionLogRows;
2480
- exports.redo = redo;
2481
- exports.reduceLayer = reduceLayer;
2482
- exports.sameMarks = sameMarks;
2483
- exports.selectionToPageMarks = selectionToPageMarks;
2484
- exports.singleRect = singleRect;
2485
- exports.toNorm = toNorm;
2486
- exports.toPixels = toPixels;
2487
- exports.undo = undo;
2488
- exports.useAnnotationLayer = useAnnotationLayer;
2489
- exports.useAnnotationShortcuts = useAnnotationShortcuts;
2490
- exports.useTextSelectionMarks = useTextSelectionMarks;
2491
227
  //# sourceMappingURL=index.cjs.map
2492
228
  //# sourceMappingURL=index.cjs.map