@arbidocs/react 0.4.55 → 0.4.57

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 (49) hide show
  1. package/dist/PdfViewer-bQH9yxFg.d.cts +55 -0
  2. package/dist/PdfViewer-bQH9yxFg.d.ts +55 -0
  3. package/dist/annotations/freeze/index.cjs +748 -0
  4. package/dist/annotations/freeze/index.cjs.map +1 -0
  5. package/dist/annotations/freeze/index.d.cts +199 -0
  6. package/dist/annotations/freeze/index.d.ts +199 -0
  7. package/dist/annotations/freeze/index.js +738 -0
  8. package/dist/annotations/freeze/index.js.map +1 -0
  9. package/dist/annotations/index.cjs +1756 -0
  10. package/dist/annotations/index.cjs.map +1 -0
  11. package/dist/annotations/index.d.cts +291 -0
  12. package/dist/annotations/index.d.ts +291 -0
  13. package/dist/annotations/index.js +1690 -0
  14. package/dist/annotations/index.js.map +1 -0
  15. package/dist/artifacts/index.cjs +16 -16
  16. package/dist/artifacts/index.js +5 -5
  17. package/dist/chunk-BGDE4DP5.cjs +192 -0
  18. package/dist/chunk-BGDE4DP5.cjs.map +1 -0
  19. package/dist/{chunk-MS7VH2BY.js → chunk-CVN7MAGQ.js} +6 -146
  20. package/dist/chunk-CVN7MAGQ.js.map +1 -0
  21. package/dist/chunk-JWXIRUWN.js +183 -0
  22. package/dist/chunk-JWXIRUWN.js.map +1 -0
  23. package/dist/chunk-QS3Q5542.js +151 -0
  24. package/dist/chunk-QS3Q5542.js.map +1 -0
  25. package/dist/{chunk-RI3BZQWD.cjs → chunk-R6V6YHPD.cjs} +3 -3
  26. package/dist/{chunk-RI3BZQWD.cjs.map → chunk-R6V6YHPD.cjs.map} +1 -1
  27. package/dist/{chunk-LOESXNVT.cjs → chunk-X3F5ABY2.cjs} +5 -158
  28. package/dist/chunk-X3F5ABY2.cjs.map +1 -0
  29. package/dist/chunk-XDCRWZF2.cjs +185 -0
  30. package/dist/chunk-XDCRWZF2.cjs.map +1 -0
  31. package/dist/{chunk-GT6KN3DV.js → chunk-XKGTZ3H6.js} +3 -3
  32. package/dist/{chunk-GT6KN3DV.js.map → chunk-XKGTZ3H6.js.map} +1 -1
  33. package/dist/index.cjs +475 -474
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.js +11 -9
  36. package/dist/index.js.map +1 -1
  37. package/dist/model-DzQxhMMz.d.cts +102 -0
  38. package/dist/model-DzQxhMMz.d.ts +102 -0
  39. package/dist/ui/index.cjs +186 -185
  40. package/dist/ui/index.js +3 -2
  41. package/dist/viewers/index.cjs +61 -52
  42. package/dist/viewers/index.cjs.map +1 -1
  43. package/dist/viewers/index.d.cts +3 -43
  44. package/dist/viewers/index.d.ts +3 -43
  45. package/dist/viewers/index.js +61 -52
  46. package/dist/viewers/index.js.map +1 -1
  47. package/package.json +31 -9
  48. package/dist/chunk-LOESXNVT.cjs.map +0 -1
  49. package/dist/chunk-MS7VH2BY.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/annotations/state.ts","../../src/annotations/store.ts","../../src/annotations/geometry.ts","../../src/annotations/controller.ts","../../src/annotations/useAnnotationLayer.ts","../../src/annotations/selection-marks.ts","../../src/annotations/useTextSelectionMarks.ts","../../src/annotations/overlay-geometry.ts","../../src/annotations/AnnotationPageOverlay.tsx","../../src/annotations/useAnnotationShortcuts.ts","../../src/annotations/AnnotationToolbar.tsx","../../src/annotations/FreezeDialog.tsx"],"names":["useRef","useEffect","useState","useCallback","jsx","MessageSquare","jsxs","Fragment"],"mappings":";;;;;;;;;AAqCO,IAAM,aAAA,GAAgB,GAAA;AAEtB,SAAS,cAAc,KAAA,EAAsC;AAClE,EAAA,OAAO,EAAE,SAAS,KAAA,EAAO,IAAA,EAAM,EAAC,EAAG,MAAA,EAAQ,EAAC,EAAE;AAChD;AAGO,SAAS,WAAA,CAAY,OAAwB,MAAA,EAA2C;AAC7F,EAAA,QAAQ,OAAO,IAAA;AAAM,IACnB,KAAK,YAAA;AACH,MAAA,OAA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E,SAAA,EAAU,4BAA2B,IAAA,EAAK,OAAA,EAAQ,aAAA,EAAY,cAAA,EAC9D,QAAA,EAAA,KAAA,EACH,CAAA;AAAA,oBAGFE,KAAC,YAAA,EAAA,EACC,QAAA,EAAA;AAAA,sBAAAF,GAAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,QAAA;AAAA,UACL,OAAA,EAAQ,SAAA;AAAA,UACR,QAAA,EAAU,IAAA;AAAA,UACV,OAAA,EAAS,MAAM,YAAA,CAAa,KAAK,CAAA;AAAA,UAClC,QAAA,EAAA;AAAA;AAAA,OAED;AAAA,sBACAA,GAAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,QAAA;AAAA,UACL,aAAA,EAAY,gBAAA;AAAA,UACZ,UAAU,IAAA,IAAQ,OAAA;AAAA,UAClB,OAAA,EAAS,MACP,SAAA,CAAU;AAAA,YACR,IAAA,EAAM,aAAA;AAAA,YACN,QAAA;AAAA,YACA,iBAAA,EAAmB,cAAc,MAAA,GAAS;AAAA,WAC3C,CAAA;AAAA,UAGF,iBAAO,gBAAA,GAAc;AAAA;AAAA;AACxB,KAAA,EACF;AAAA,GAAA,EACF,CAAA,EACF,CAAA;AAEJ","file":"index.js","sourcesContent":["/**\n * Pure state for an annotation layer: actions, a reducer and undo/redo history.\n *\n * No clock and no randomness in here. Callers pass ids and timestamps in, so the reducer is\n * deterministic, trivially testable, and an agent can replay the same actions a person makes.\n */\n\nimport {\n parseAnnotation,\n type Annotation,\n type AnnotationLayer,\n type CommentReply,\n type RedactionStatus,\n} from './model'\n\n/** Fields a caller may change on any mark. Identity (`id`, `kind`, `page`) is fixed. */\ntype PatchOf<A> = A extends Annotation\n ? Partial<Omit<A, 'id' | 'kind' | 'page' | 'createdAt'>>\n : never\nexport type AnnotationPatch = PatchOf<Annotation>\n\nexport type AnnotationAction =\n | { type: 'add'; annotation: Annotation }\n | { type: 'addMany'; annotations: Annotation[] }\n | { type: 'update'; id: string; patch: AnnotationPatch; now: string }\n | { type: 'remove'; id: string; now: string }\n | { type: 'setRedactionStatus'; ids: string[]; status: RedactionStatus; now: string }\n | { type: 'reply'; id: string; reply: CommentReply; now: string }\n | { type: 'resolve'; id: string; resolved: boolean; now: string }\n | { type: 'replaceAll'; layer: AnnotationLayer }\n\nexport interface LayerHistory {\n present: AnnotationLayer\n past: AnnotationLayer[]\n future: AnnotationLayer[]\n}\n\nexport const HISTORY_LIMIT = 200\n\nexport function createHistory(layer: AnnotationLayer): LayerHistory {\n return { present: layer, past: [], future: [] }\n}\n\n/** Apply one action to a layer. Returns the same object when nothing changed. */\nexport function reduceLayer(layer: AnnotationLayer, action: AnnotationAction): AnnotationLayer {\n switch (action.type) {\n case 'replaceAll':\n return action.layer\n case 'add': {\n // Validate on the way in: a bad mark must never reach storage or a frozen document.\n const annotation = parseAnnotation(action.annotation)\n if (layer.annotations.some((a) => a.id === annotation.id)) {\n throw new Error(`annotation ${annotation.id} already exists`)\n }\n return {\n ...layer,\n annotations: [...layer.annotations, annotation],\n updatedAt: annotation.updatedAt,\n }\n }\n case 'addMany': {\n // All or nothing: one bad mark rejects the batch, so history never holds half of it.\n let next = layer\n for (const annotation of action.annotations)\n next = reduceLayer(next, { type: 'add', annotation })\n return next\n }\n case 'update': {\n const found = layer.annotations.find((a) => a.id === action.id)\n if (!found) return layer\n // The patch type forbids identity fields, but patches also arrive from JSON (an agent, a\n // network message), so enforce it here rather than trusting the type.\n const next = parseAnnotation({\n ...found,\n ...action.patch,\n id: found.id,\n kind: found.kind,\n page: found.page,\n createdAt: found.createdAt,\n updatedAt: action.now,\n })\n return replace(layer, next, action.now)\n }\n case 'remove': {\n if (!layer.annotations.some((a) => a.id === action.id)) return layer\n return {\n ...layer,\n annotations: layer.annotations.filter((a) => a.id !== action.id),\n updatedAt: action.now,\n }\n }\n case 'setRedactionStatus': {\n const ids = new Set(action.ids)\n let changed = false\n const annotations = layer.annotations.map((a) => {\n if (a.kind !== 'redaction' || !ids.has(a.id) || a.status === action.status) return a\n changed = true\n return { ...a, status: action.status, updatedAt: action.now }\n })\n return changed ? { ...layer, annotations, updatedAt: action.now } : layer\n }\n case 'reply': {\n const found = layer.annotations.find((a) => a.id === action.id)\n if (!found || found.kind !== 'comment') return layer\n const next = parseAnnotation({\n ...found,\n replies: [...found.replies, action.reply],\n updatedAt: action.now,\n })\n return replace(layer, next, action.now)\n }\n case 'resolve': {\n const found = layer.annotations.find((a) => a.id === action.id)\n if (!found || found.kind !== 'comment' || found.resolved === action.resolved) return layer\n return replace(\n layer,\n { ...found, resolved: action.resolved, updatedAt: action.now },\n action.now\n )\n }\n }\n}\n\nfunction replace(layer: AnnotationLayer, next: Annotation, now: string): AnnotationLayer {\n return {\n ...layer,\n annotations: layer.annotations.map((a) => (a.id === next.id ? next : a)),\n updatedAt: now,\n }\n}\n\n/** Apply an action and record it for undo. A no-op action leaves history untouched. */\nexport function applyAction(history: LayerHistory, action: AnnotationAction): LayerHistory {\n const present = reduceLayer(history.present, action)\n if (present === history.present) return history\n const past = [...history.past, history.present]\n return {\n present,\n past: past.length > HISTORY_LIMIT ? past.slice(past.length - HISTORY_LIMIT) : past,\n future: [],\n }\n}\n\nexport function undo(history: LayerHistory): LayerHistory {\n const previous = history.past[history.past.length - 1]\n if (!previous) return history\n return {\n present: previous,\n past: history.past.slice(0, -1),\n future: [history.present, ...history.future],\n }\n}\n\nexport function redo(history: LayerHistory): LayerHistory {\n const [next, ...rest] = history.future\n if (!next) return history\n return { present: next, past: [...history.past, history.present], future: rest }\n}\n\nexport const canUndo = (h: LayerHistory) => h.past.length > 0\nexport const canRedo = (h: LayerHistory) => h.future.length > 0\n\nexport function annotationsOnPage(layer: AnnotationLayer, page: number): Annotation[] {\n return layer.annotations.filter((a) => a.page === page)\n}\n\nexport function pendingRedactions(layer: AnnotationLayer) {\n return layer.annotations.filter((a) => a.kind === 'redaction' && a.status === 'pending')\n}\n","/**\n * Where a layer is kept. The layer is data about a document, not part of it, so the host decides\n * (backend API, IndexedDB, a file). This package ships an in-memory store and a localStorage\n * store; both validate on load because stored JSON is untrusted.\n */\n\nimport { emptyLayer, parseLayer, type AnnotationLayer } from './model'\n\nexport interface AnnotationStore {\n /** The saved layer, or an empty one for a document that has none yet. */\n load(documentId: string): Promise<AnnotationLayer>\n save(layer: AnnotationLayer): Promise<void>\n}\n\nexport function createMemoryStore(\n now: () => string = () => new Date().toISOString()\n): AnnotationStore {\n const layers = new Map<string, string>()\n return {\n async load(documentId) {\n const raw = layers.get(documentId)\n return raw ? parseLayer(JSON.parse(raw)) : emptyLayer(documentId, now())\n },\n async save(layer) {\n layers.set(layer.documentId, JSON.stringify(parseLayer(layer)))\n },\n }\n}\n\nconst STORAGE_PREFIX = 'arbi:annotations:'\n\n/**\n * Per-browser store. Storage can be absent, full or blocked (private windows), so every access is\n * guarded. A saved layer that no longer validates is ignored rather than crashing the viewer.\n */\nexport function createLocalStorageStore(\n storage: Pick<Storage, 'getItem' | 'setItem'> | undefined = safeLocalStorage(),\n now: () => string = () => new Date().toISOString()\n): AnnotationStore {\n return {\n async load(documentId) {\n try {\n const raw = storage?.getItem(STORAGE_PREFIX + documentId)\n if (raw) return parseLayer(JSON.parse(raw))\n } catch {\n // unreadable or invalid: start from an empty layer\n }\n return emptyLayer(documentId, now())\n },\n async save(layer) {\n if (!storage) throw new Error('storage is not available')\n storage.setItem(STORAGE_PREFIX + layer.documentId, JSON.stringify(parseLayer(layer)))\n },\n }\n}\n\nfunction safeLocalStorage(): Storage | undefined {\n try {\n return typeof localStorage === 'undefined' ? undefined : localStorage\n } catch {\n return undefined\n }\n}\n","/**\n * Geometry helpers: pixels <-> fractions of the displayed page, and turning a text selection's\n * many client rects into tidy line boxes.\n */\n\nimport { clampRect, type NormRect } from './model'\n\nexport interface PixelRect {\n x: number\n y: number\n width: number\n height: number\n}\n\nexport interface PixelSize {\n width: number\n height: number\n}\n\n/** Rectangles smaller than this (as a fraction of the page) are treated as accidental clicks. */\nexport const MIN_MARK_FRACTION = 0.004\n\nexport function toNorm(r: PixelRect, page: PixelSize): NormRect {\n if (!(page.width > 0) || !(page.height > 0)) throw new RangeError('page size must be positive')\n const x1 = Math.min(r.x, r.x + r.width)\n const y1 = Math.min(r.y, r.y + r.height)\n const x2 = Math.max(r.x, r.x + r.width)\n const y2 = Math.max(r.y, r.y + r.height)\n const cx1 = Math.min(Math.max(x1, 0), page.width)\n const cy1 = Math.min(Math.max(y1, 0), page.height)\n const cx2 = Math.min(Math.max(x2, 0), page.width)\n const cy2 = Math.min(Math.max(y2, 0), page.height)\n return clampRect({\n x: cx1 / page.width,\n y: cy1 / page.height,\n w: (cx2 - cx1) / page.width,\n h: (cy2 - cy1) / page.height,\n })\n}\n\nexport function toPixels(r: NormRect, page: PixelSize): PixelRect {\n return {\n x: r.x * page.width,\n y: r.y * page.height,\n width: r.w * page.width,\n height: r.h * page.height,\n }\n}\n\n/** A drag from `a` to `b` (any direction), as a normalised rectangle. */\nexport function dragToNorm(\n a: { x: number; y: number },\n b: { x: number; y: number },\n page: PixelSize\n): NormRect {\n return toNorm({ x: a.x, y: a.y, width: b.x - a.x, height: b.y - a.y }, page)\n}\n\nexport function isTooSmall(r: NormRect): boolean {\n return r.w < MIN_MARK_FRACTION || r.h < MIN_MARK_FRACTION\n}\n\nexport function containsPoint(r: NormRect, x: number, y: number): boolean {\n return x >= r.x && x <= r.x + r.w && y >= r.y && y <= r.y + r.h\n}\n\n/** Rects that only share an edge do not intersect; `EPS` absorbs float noise at that edge. */\nconst EPS = 1e-9\n\nexport function intersects(a: NormRect, b: NormRect): boolean {\n return (\n 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\n )\n}\n\n/**\n * Collapse a selection's client rects into one box per text line. Browsers return a rect per\n * text node or span, often overlapping and with sub-pixel gaps; merging rects that share a line\n * and touch (or nearly touch) horizontally gives a clean, even highlight. Rects that sit on\n * different lines are left alone. Input is in the page's pixel space.\n */\nexport function mergeLineRects(input: PixelRect[], gap = 2): PixelRect[] {\n const rects = input\n .filter((r) => r.width > 0 && r.height > 0)\n .map((r) => ({ ...r }))\n .sort((a, b) => a.y - b.y || a.x - b.x)\n\n const lines: PixelRect[][] = []\n for (const r of rects) {\n const mid = r.y + r.height / 2\n const line = lines.find((l) => {\n const ref = l[0]\n return mid >= ref.y && mid <= ref.y + ref.height\n })\n if (line) line.push(r)\n else lines.push([r])\n }\n\n const out: PixelRect[] = []\n for (const line of lines) {\n line.sort((a, b) => a.x - b.x)\n let cur = { ...line[0] }\n for (const r of line.slice(1)) {\n if (r.x <= cur.x + cur.width + gap) {\n const right = Math.max(cur.x + cur.width, r.x + r.width)\n const top = Math.min(cur.y, r.y)\n const bottom = Math.max(cur.y + cur.height, r.y + r.height)\n cur = { x: cur.x, y: top, width: right - cur.x, height: bottom - top }\n } else {\n out.push(cur)\n cur = { ...r }\n }\n }\n out.push(cur)\n }\n return out.sort((a, b) => a.y - b.y || a.x - b.x)\n}\n","/**\n * The contract between the annotation state (`useAnnotationLayer`) and the UI that draws it\n * (`AnnotationPageOverlay`, `AnnotationToolbar`). Components take a controller as a prop and hold\n * no annotation state of their own beyond transient drags.\n */\n\nimport type { Annotation, AnnotationLayer, CommentReply, RedactionStatus } from './model'\nimport type { AnnotationPatch } from './state'\n\nexport type AnnotationTool =\n 'select' | 'highlight' | 'box' | 'comment' | 'stamp' | 'redact-area' | 'redact-text'\n\nexport const DRAW_TOOLS: readonly AnnotationTool[] = ['box', 'comment', 'stamp', 'redact-area']\nexport const TEXT_TOOLS: readonly AnnotationTool[] = ['highlight', 'redact-text']\n\n/** Tools that colour what they make. */\nexport type ColoredTool = 'highlight' | 'box' | 'stamp'\n\nexport interface ToolSettings {\n colors: Record<ColoredTool, string>\n stampLabel: string\n redactionReason: string\n /** Box outline width in points. */\n strokeWidth: number\n}\n\nexport const DEFAULT_SETTINGS: ToolSettings = {\n colors: { highlight: '#ffe066', box: '#e03131', stamp: '#c92a2a' },\n stampLabel: 'CONFIDENTIAL',\n redactionReason: 'Privileged',\n strokeWidth: 2,\n}\n\nexport const HIGHLIGHT_COLORS = ['#ffe066', '#8ce99a', '#74c0fc', '#ffa8a8', '#eebefa']\nexport const MARK_COLORS = ['#e03131', '#1c7ed6', '#2f9e44', '#f08c00', '#000000']\nexport const STAMP_PRESETS = ['CONFIDENTIAL', 'DRAFT', 'APPROVED', 'FILED', 'PRIVILEGED', 'COPY']\nexport const REDACTION_REASONS = [\n 'Privileged',\n 'Confidential',\n 'Personal data',\n 'Commercial',\n 'Irrelevant',\n]\n\n/** A mark as the UI describes it: identity, author and timestamps are added by the controller. */\nexport type NewMark = Annotation extends infer A\n ? A extends Annotation\n ? Omit<A, 'id' | 'author' | 'createdAt' | 'updatedAt'>\n : never\n : never\n\nexport type LayerStatus = 'loading' | 'ready' | 'error'\n\nexport interface AnnotationController {\n layer: AnnotationLayer\n status: LayerStatus\n /** The last load, save or validation failure, for the UI to show. */\n error: string | null\n saving: boolean\n /** True when edits have not reached the store yet. */\n dirty: boolean\n author: string\n\n tool: AnnotationTool\n setTool(tool: AnnotationTool): void\n settings: ToolSettings\n setSettings(patch: Partial<ToolSettings>): void\n selectedId: string | null\n select(id: string | null): void\n\n add(mark: NewMark): string | null\n /** Add several marks as ONE undo step (e.g. a selection spanning pages). */\n addMany(marks: NewMark[]): string[]\n update(id: string, patch: AnnotationPatch): void\n remove(id: string): void\n setRedactionStatus(ids: string[], status: RedactionStatus): void\n reply(id: string, body: string): void\n resolve(id: string, resolved: boolean): void\n\n undo(): void\n redo(): void\n canUndo: boolean\n canRedo: boolean\n /** Write to the store now (before leaving the page). */\n flush(): Promise<void>\n}\n\nexport type { CommentReply }\n","/**\n * Annotation state for one document: loads its layer from a store, applies edits through the pure\n * reducer (so undo/redo is exact), and saves back after a short pause.\n *\n * Edits are applied from a ref, not inside a React state updater, so a mark that fails validation\n * is reported through `error` instead of throwing during render.\n */\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n DEFAULT_SETTINGS,\n type AnnotationController,\n type AnnotationTool,\n type LayerStatus,\n type NewMark,\n type ToolSettings,\n} from './controller'\nimport { emptyLayer, type Annotation, type AnnotationLayer } from './model'\nimport {\n applyAction,\n canRedo as historyCanRedo,\n canUndo as historyCanUndo,\n createHistory,\n redo as historyRedo,\n undo as historyUndo,\n type AnnotationAction,\n type LayerHistory,\n} from './state'\nimport type { AnnotationStore } from './store'\n\nexport const AUTOSAVE_MS = 600\n\nexport interface UseAnnotationLayerOptions {\n documentId: string\n store: AnnotationStore\n /** Display name recorded as the author of new marks. */\n author: string\n autosaveMs?: number\n now?: () => string\n makeId?: () => string\n}\n\nconst defaultNow = () => new Date().toISOString()\nconst defaultId = () => globalThis.crypto.randomUUID()\n\nexport function useAnnotationLayer({\n documentId,\n store,\n author,\n autosaveMs = AUTOSAVE_MS,\n now = defaultNow,\n makeId = defaultId,\n}: UseAnnotationLayerOptions): AnnotationController {\n const [history, setHistory] = useState<LayerHistory>(() =>\n createHistory(emptyLayer(documentId, now()))\n )\n const [savedLayer, setSavedLayer] = useState<AnnotationLayer | null>(null)\n const [status, setStatus] = useState<LayerStatus>('loading')\n const [error, setError] = useState<string | null>(null)\n const [saving, setSaving] = useState(false)\n const [tool, setToolState] = useState<AnnotationTool>('select')\n const [settings, setSettingsState] = useState<ToolSettings>(DEFAULT_SETTINGS)\n const [selectedId, setSelectedId] = useState<string | null>(null)\n\n const historyRef = useRef(history)\n const savedRef = useRef<AnnotationLayer | null>(null)\n const timerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const docRef = useRef(documentId)\n const storeRef = useRef(store)\n storeRef.current = store\n const nowRef = useRef(now)\n nowRef.current = now\n const idRef = useRef(makeId)\n idRef.current = makeId\n\n const commit = useCallback((next: LayerHistory) => {\n historyRef.current = next\n setHistory(next)\n }, [])\n\n // Load when the document changes.\n useEffect(() => {\n docRef.current = documentId\n let cancelled = false\n setStatus('loading')\n setError(null)\n setSelectedId(null)\n setSavedLayer(null)\n savedRef.current = null\n commit(createHistory(emptyLayer(documentId, nowRef.current())))\n storeRef.current\n .load(documentId)\n .then((layer) => {\n if (cancelled) return\n savedRef.current = layer\n setSavedLayer(layer)\n commit(createHistory(layer))\n setStatus('ready')\n })\n .catch((e: unknown) => {\n if (cancelled) return\n setError(e instanceof Error ? e.message : 'The annotations could not be loaded')\n setStatus('error')\n })\n return () => {\n cancelled = true\n // Leaving this document (switching to another, or unmounting): write the edits still waiting\n // on the autosave timer. Without this they would be silently dropped.\n clearTimeout(timerRef.current)\n const layer = historyRef.current.present\n if (\n savedRef.current !== null &&\n layer !== savedRef.current &&\n layer.documentId === documentId\n ) {\n storeRef.current\n .save(layer)\n .catch((e: unknown) => console.error('Annotations could not be saved', e))\n }\n }\n }, [documentId, commit])\n\n const save = useCallback(async () => {\n clearTimeout(timerRef.current)\n const layer = historyRef.current.present\n if (layer === savedRef.current) return\n setSaving(true)\n try {\n await storeRef.current.save(layer)\n if (layer.documentId === docRef.current) {\n savedRef.current = layer\n setSavedLayer(layer)\n setError(null)\n }\n } catch (e) {\n setError(e instanceof Error ? e.message : 'The annotations could not be saved')\n } finally {\n setSaving(false)\n }\n }, [])\n\n const present = history.present\n const dirty = status === 'ready' && present !== savedLayer\n\n useEffect(() => {\n if (!dirty) return\n timerRef.current = setTimeout(() => void save(), autosaveMs)\n return () => clearTimeout(timerRef.current)\n }, [dirty, present, autosaveMs, save])\n\n // The tab can close or reload with edits still waiting on the autosave timer, and React's own\n // cleanup does not run then. Write when the page is being left or hidden (mobile browsers often\n // fire only the latter). `save` starts the store write synchronously, which is what unload needs.\n useEffect(() => {\n const flush = () => void save()\n const onVisibility = () => {\n if (document.visibilityState === 'hidden') flush()\n }\n window.addEventListener('pagehide', flush)\n document.addEventListener('visibilitychange', onVisibility)\n return () => {\n window.removeEventListener('pagehide', flush)\n document.removeEventListener('visibilitychange', onVisibility)\n }\n }, [save])\n\n const dispatch = useCallback(\n (action: AnnotationAction): boolean => {\n try {\n commit(applyAction(historyRef.current, action))\n setError(null)\n return true\n } catch (e) {\n setError(e instanceof Error ? e.message : 'The change was rejected')\n return false\n }\n },\n [commit]\n )\n\n const stamp = useCallback(\n (mark: NewMark): Annotation => {\n const t = nowRef.current()\n return { ...mark, id: idRef.current(), author, createdAt: t, updatedAt: t } as Annotation\n },\n [author]\n )\n\n const controller = useMemo<AnnotationController>(() => {\n const exists = (id: string | null) =>\n id !== null && present.annotations.some((a) => a.id === id) ? id : null\n return {\n layer: present,\n status,\n error,\n saving,\n dirty,\n author,\n tool,\n setTool: (next) => {\n setToolState(next)\n if (next !== 'select') setSelectedId(null)\n },\n settings,\n setSettings: (patch) =>\n setSettingsState((s) => ({ ...s, ...patch, colors: { ...s.colors, ...patch.colors } })),\n selectedId: exists(selectedId),\n select: setSelectedId,\n add: (mark) => {\n const annotation = stamp(mark)\n return dispatch({ type: 'add', annotation }) ? annotation.id : null\n },\n addMany: (marks) => {\n const annotations = marks.map(stamp)\n return dispatch({ type: 'addMany', annotations }) ? annotations.map((a) => a.id) : []\n },\n update: (id, patch) => void dispatch({ type: 'update', id, patch, now: nowRef.current() }),\n remove: (id) => void dispatch({ type: 'remove', id, now: nowRef.current() }),\n setRedactionStatus: (ids, next) =>\n void dispatch({ type: 'setRedactionStatus', ids, status: next, now: nowRef.current() }),\n reply: (id, body) => {\n const t = nowRef.current()\n void dispatch({\n type: 'reply',\n id,\n reply: { id: idRef.current(), author, createdAt: t, body },\n now: t,\n })\n },\n resolve: (id, resolved) =>\n void dispatch({ type: 'resolve', id, resolved, now: nowRef.current() }),\n undo: () => commit(historyUndo(historyRef.current)),\n redo: () => commit(historyRedo(historyRef.current)),\n canUndo: historyCanUndo(history),\n canRedo: historyCanRedo(history),\n flush: save,\n }\n }, [\n present,\n history,\n status,\n error,\n saving,\n dirty,\n author,\n tool,\n settings,\n selectedId,\n stamp,\n dispatch,\n commit,\n save,\n ])\n\n return controller\n}\n","/**\n * Turn a text selection into marks. The browser selects over pdf.js's text layer; each page's\n * share of the selection becomes one mark of normalised line boxes (page-relative, zoom-proof).\n *\n * `selectionToPageMarks` is pure so it can be tested without a layout engine; `readSelection`\n * is the thin DOM side that measures a real selection.\n */\n\nimport { mergeLineRects, toNorm, type PixelRect } from './geometry'\nimport type { NormRect } from './model'\n\n/** One page's slice of a selection, in client (viewport) coordinates. */\nexport interface PageSelection {\n page: number\n /** The page's box on screen. */\n box: PixelRect\n /** Client rects of the selected text on this page. */\n rects: PixelRect[]\n text: string\n}\n\nexport interface PageTextMark {\n page: number\n rects: NormRect[]\n text: string\n}\n\n/** Rects smaller than this many CSS pixels (either side) are layout noise, not selected text. */\nconst MIN_RECT_PX = 1\n\nexport function selectionToPageMarks(pages: PageSelection[]): PageTextMark[] {\n const out: PageTextMark[] = []\n for (const p of pages) {\n if (!(p.box.width > 0) || !(p.box.height > 0)) continue\n const local = p.rects\n .filter((r) => r.width >= MIN_RECT_PX && r.height >= MIN_RECT_PX)\n .map((r) => ({ x: r.x - p.box.x, y: r.y - p.box.y, width: r.width, height: r.height }))\n // keep only what overlaps the page area (a selection can brush a neighbouring page)\n .filter(\n (r) => r.x + r.width > 0 && r.y + r.height > 0 && r.x < p.box.width && r.y < p.box.height\n )\n const lines = mergeLineRects(local)\n if (lines.length === 0) continue\n out.push({\n page: p.page,\n rects: lines.map((r) => toNorm(r, { width: p.box.width, height: p.box.height })),\n text: p.text.replace(/\\s+/g, ' ').trim(),\n })\n }\n return out\n}\n\nexport const PAGE_ATTRIBUTE = 'data-annotation-page'\n\nconst toPixelRect = (r: DOMRect): PixelRect => ({\n x: r.left,\n y: r.top,\n width: r.width,\n height: r.height,\n})\n\n/** Narrow `range` to the part inside `container`, or null if it does not reach it. */\nexport function clipRange(range: Range, container: Node): Range | null {\n if (!range.intersectsNode(container)) return null\n const bounds = document.createRange()\n bounds.selectNodeContents(container)\n const clipped = range.cloneRange()\n if (clipped.compareBoundaryPoints(Range.START_TO_START, bounds) < 0) {\n clipped.setStart(bounds.startContainer, bounds.startOffset)\n }\n if (clipped.compareBoundaryPoints(Range.END_TO_END, bounds) > 0) {\n clipped.setEnd(bounds.endContainer, bounds.endOffset)\n }\n return clipped\n}\n\n/** Read the live selection as per-page slices, using the overlays in `root` to find the pages. */\nexport function readSelection(selection: Selection, root: ParentNode = document): PageSelection[] {\n if (selection.rangeCount === 0 || selection.isCollapsed) return []\n const range = selection.getRangeAt(0)\n const pages: PageSelection[] = []\n root.querySelectorAll<HTMLElement>(`[${PAGE_ATTRIBUTE}]`).forEach((overlay) => {\n const page = Number(overlay.getAttribute(PAGE_ATTRIBUTE))\n const container = overlay.parentElement\n if (!container || !Number.isInteger(page)) return\n const clipped = clipRange(range, container)\n if (!clipped) return\n pages.push({\n page,\n box: toPixelRect(overlay.getBoundingClientRect()),\n rects: Array.from(clipped.getClientRects(), toPixelRect),\n text: clipped.toString(),\n })\n })\n return pages\n}\n","/**\n * Turns a text selection made on the page into marks while the highlight or redact-text tool is\n * active. Only a selection that STARTED on a page counts: otherwise text left selected from an\n * earlier gesture would be marked the moment the user clicked a toolbar button.\n *\n * With a mouse the gesture is press, drag, release, so the release marks the selection. A touch\n * selection is different: the user long-presses a word, then drags the handles, and the browser\n * may cancel the pointer instead of releasing it. So for touch the selection is marked once it has\n * stopped changing for a moment. The marks are undoable, and redactions stay pending until reviewed.\n */\n\nimport { useEffect, useRef } from 'react'\nimport { TEXT_TOOLS, type AnnotationController, type NewMark } from './controller'\nimport { readSelection, selectionToPageMarks } from './selection-marks'\n\nconst PAGE_SELECTOR = '[data-page-number]'\n\n/** How long a touch selection must stay unchanged before it is turned into marks. */\nexport const TOUCH_SETTLE_MS = 700\n\n/**\n * After a mouse release the browser may still be extending the selection (WebKit does, under\n * load), so reading it at once can capture only part of what the user selected: a redaction that\n * under-covers. The release therefore waits until the selection has read the same on\n * STABLE_CHECKS consecutive checks, MOUSE_SETTLE_MS apart, and gives up waiting after\n * MAX_SETTLE_ROUNDS checks so a selection that never stops changing cannot hang the tool.\n */\nexport const MOUSE_SETTLE_MS = 60\nexport const STABLE_CHECKS = 2\nexport const MAX_SETTLE_ROUNDS = 10\n\nexport function useTextSelectionMarks(controller: AnnotationController) {\n const latest = useRef(controller)\n latest.current = controller\n\n useEffect(() => {\n let startedOnPage = false\n let touchSelecting = false\n let settleTimer: ReturnType<typeof setTimeout> | undefined\n const settleTimers = new Set<ReturnType<typeof setTimeout>>()\n\n /** Mark whatever is selected on the pages. Returns true when marks were made. */\n const markSelection = (): boolean => {\n const c = latest.current\n const selection = window.getSelection()\n if (!selection || !TEXT_TOOLS.includes(c.tool)) return false\n const pages = selectionToPageMarks(readSelection(selection))\n if (pages.length === 0) return false\n const marks: NewMark[] = pages.map((p) =>\n c.tool === 'highlight'\n ? {\n kind: 'highlight',\n page: p.page,\n rects: p.rects,\n color: c.settings.colors.highlight,\n text: p.text,\n }\n : {\n kind: 'redaction',\n page: p.page,\n rects: p.rects,\n reason: c.settings.redactionReason,\n text: p.text,\n status: 'pending',\n }\n )\n if (c.addMany(marks).length === 0) return false\n selection.removeAllRanges()\n return true\n }\n\n const onDown = (e: PointerEvent) => {\n startedOnPage = e.target instanceof Element && e.target.closest(PAGE_SELECTOR) !== null\n touchSelecting = startedOnPage && e.pointerType === 'touch'\n }\n\n const onUp = () => {\n if (!startedOnPage || !TEXT_TOOLS.includes(latest.current.tool)) return\n startedOnPage = false\n // Let the browser finish updating the selection for this gesture first.\n let last = window.getSelection()?.toString() ?? ''\n let stable = 0\n let rounds = 0\n const check = () => {\n const now = window.getSelection()?.toString() ?? ''\n if (now === last) stable++\n else {\n last = now\n stable = 0\n }\n if (stable >= STABLE_CHECKS || ++rounds >= MAX_SETTLE_ROUNDS) {\n if (markSelection()) touchSelecting = false\n return\n }\n settleTimers.add(setTimeout(check, MOUSE_SETTLE_MS))\n }\n settleTimers.add(setTimeout(check, MOUSE_SETTLE_MS))\n }\n\n const onSelectionChange = () => {\n if (!touchSelecting || !TEXT_TOOLS.includes(latest.current.tool)) return\n clearTimeout(settleTimer)\n settleTimer = setTimeout(() => {\n if (markSelection()) touchSelecting = false\n }, TOUCH_SETTLE_MS)\n }\n\n document.addEventListener('pointerdown', onDown, true)\n document.addEventListener('pointerup', onUp, true)\n document.addEventListener('selectionchange', onSelectionChange)\n return () => {\n clearTimeout(settleTimer)\n settleTimers.forEach(clearTimeout)\n document.removeEventListener('pointerdown', onDown, true)\n document.removeEventListener('pointerup', onUp, true)\n document.removeEventListener('selectionchange', onSelectionChange)\n }\n }, [])\n}\n","/**\n * Pure geometry for moving and resizing a single-rectangle mark. Kept out of the component file so\n * it can be tested and reused without a renderer.\n */\n\nimport { clampRect, type Annotation, type NormRect } from './model'\n\nconst MIN_MARK = 0.01\n\nexport type DragMode = 'move' | 'nw' | 'ne' | 'sw' | 'se'\n\n/** The single rectangle of a mark that can be moved and resized, or null for multi-rect marks. */\nexport function singleRect(a: Annotation): NormRect | null {\n if (a.kind === 'box' || a.kind === 'stamp' || a.kind === 'comment') return a.rect\n if (a.kind === 'redaction' && a.rects.length === 1) return a.rects[0]\n return null\n}\n\nexport const patchForRect = (a: Annotation, rect: NormRect) =>\n a.kind === 'redaction' ? { rects: [rect] } : { rect }\n\n/** Move or resize `origin` by a pointer delta given as fractions of the page. */\nexport function dragRect(origin: NormRect, mode: DragMode, dx: number, dy: number): NormRect {\n if (mode === 'move') {\n return {\n ...origin,\n x: Math.min(Math.max(origin.x + dx, 0), 1 - origin.w),\n y: Math.min(Math.max(origin.y + dy, 0), 1 - origin.h),\n }\n }\n let left = origin.x\n let right = origin.x + origin.w\n let top = origin.y\n let bottom = origin.y + origin.h\n if (mode.includes('w')) left += dx\n else right += dx\n if (mode.includes('n')) top += dy\n else bottom += dy\n const x1 = Math.min(Math.max(Math.min(left, right), 0), 1)\n const x2 = Math.min(Math.max(Math.max(left, right), 0), 1)\n const y1 = Math.min(Math.max(Math.min(top, bottom), 0), 1)\n const y2 = Math.min(Math.max(Math.max(top, bottom), 0), 1)\n return clampRect({\n x: x1,\n y: y1,\n w: Math.max(x2 - x1, MIN_MARK),\n h: Math.max(y2 - y1, MIN_MARK),\n })\n}\n","/**\n * The annotation layer for ONE page: draws its marks and handles the tools.\n *\n * It fills the page area (absolute, inset 0) and positions everything in percentages of it, so\n * marks follow zoom for free. Pointer maths uses the overlay's live box at event time.\n *\n * Event routing: in the text tools (highlight, redact text) the overlay lets pointer events fall\n * through to pdf.js's text layer so the browser can select text; `useTextSelectionMarks` turns\n * that selection into marks. In the draw tools the overlay captures the pointer. In select mode\n * only the marks themselves are interactive.\n */\n\nimport {\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n type PointerEvent as ReactPointerEvent,\n} from 'react'\nimport { Check, MessageSquare, RotateCcw, Send, Trash2, X } from 'lucide-react'\nimport { cn } from '../lib/utils'\nimport { DRAW_TOOLS, TEXT_TOOLS, type AnnotationController } from './controller'\nimport { dragToNorm, isTooSmall } from './geometry'\nimport {\n clampRect,\n type Annotation,\n type CommentAnnotation,\n type NormRect,\n type RedactionAnnotation,\n} from './model'\nimport { dragRect, patchForRect, singleRect, type DragMode } from './overlay-geometry'\nimport { PAGE_ATTRIBUTE } from './selection-marks'\n\nconst FALLBACK_PAGE_WIDTH_PT = 612\nconst COMMENT_ICON_PX = 24\nconst DEFAULT_STAMP = { w: 0.32, h: 0.06 }\nconst MOVE_THRESHOLD_PX = 3\n\ninterface DragState {\n id: string\n mode: DragMode\n startX: number\n startY: number\n origin: NormRect\n rect: NormRect\n moved: boolean\n}\ninterface Point {\n x: number\n y: number\n}\n\nfunction useElementSize(ref: React.RefObject<HTMLElement | null>) {\n const [size, setSize] = useState({ width: 0, height: 0 })\n useLayoutEffect(() => {\n const el = ref.current\n if (!el) return\n const measure = () => {\n const r = el.getBoundingClientRect()\n setSize((prev) =>\n prev.width === r.width && prev.height === r.height\n ? prev\n : { width: r.width, height: r.height }\n )\n }\n measure()\n const observer = new ResizeObserver(measure)\n observer.observe(el)\n return () => observer.disconnect()\n }, [ref])\n return size\n}\n\n/**\n * Whether the page this overlay sits on has selectable text. A scanned page has none (the parser\n * keeps OCR separately, not in the PDF), so the text tools cannot select anything there.\n */\nfunction useHasTextLayer(ref: React.RefObject<HTMLElement | null>) {\n const [hasText, setHasText] = useState(false)\n useLayoutEffect(() => {\n const container = ref.current?.parentElement\n if (!container) return\n const check = () => setHasText(container.querySelector('.textLayer span') !== null)\n check()\n const observer = new MutationObserver(check)\n observer.observe(container, { childList: true, subtree: true })\n return () => observer.disconnect()\n }, [ref])\n return hasText\n}\n\nconst pct = (n: number) => `${n * 100}%`\nconst rectStyle = (r: NormRect): CSSProperties => ({\n left: pct(r.x),\n top: pct(r.y),\n width: pct(r.w),\n height: pct(r.h),\n})\n\nexport interface AnnotationPageOverlayProps {\n controller: AnnotationController\n pageNumber: number\n /** Page width in PDF points, to size strokes like an export. Defaults to US Letter. */\n pageWidthPt?: number\n}\n\nexport function AnnotationPageOverlay({\n controller,\n pageNumber,\n pageWidthPt,\n}: AnnotationPageOverlayProps) {\n const rootRef = useRef<HTMLDivElement>(null)\n const size = useElementSize(rootRef)\n const pxPerPt = size.width / (pageWidthPt ?? FALLBACK_PAGE_WIDTH_PT)\n const { tool, selectedId, settings } = controller\n\n const [draft, setDraft] = useState<{ a: Point; b: Point } | null>(null)\n const [drag, setDrag] = useState<DragState | null>(null)\n const [openComment, setOpenComment] = useState<string | null>(null)\n\n const marks = controller.layer.annotations.filter((a) => a.page === pageNumber)\n const hasText = useHasTextLayer(rootRef)\n // On a page with no selectable text (a scan) the text tools draw an area instead.\n const drawing = DRAW_TOOLS.includes(tool) || (TEXT_TOOLS.includes(tool) && !hasText)\n\n // A comment opened by the tool or from elsewhere shows its popover only while it is selected.\n useEffect(() => {\n if (openComment && selectedId !== openComment) setOpenComment(null)\n }, [selectedId, openComment])\n\n const local = useCallback((e: { clientX: number; clientY: number }): Point => {\n const r = rootRef.current!.getBoundingClientRect()\n return { x: e.clientX - r.left, y: e.clientY - r.top }\n }, [])\n const pageSize = () => {\n const r = rootRef.current!.getBoundingClientRect()\n return { width: r.width, height: r.height }\n }\n\n const finishDraft = useCallback(\n (a: Point, b: Point) => {\n const page = pageSize()\n const rect = dragToNorm(a, b, page)\n if (tool === 'box') {\n if (isTooSmall(rect)) return\n controller.add({\n kind: 'box',\n page: pageNumber,\n rect,\n color: settings.colors.box,\n strokeWidth: settings.strokeWidth,\n })\n } else if (tool === 'highlight') {\n if (isTooSmall(rect)) return\n controller.add({\n kind: 'highlight',\n page: pageNumber,\n rects: [rect],\n color: settings.colors.highlight,\n })\n } else if (tool === 'redact-area' || tool === 'redact-text') {\n if (isTooSmall(rect)) return\n controller.add({\n kind: 'redaction',\n page: pageNumber,\n rects: [rect],\n reason: settings.redactionReason,\n status: 'pending',\n })\n } else if (tool === 'stamp') {\n const placed = isTooSmall(rect)\n ? clampRect({\n x: a.x / page.width - DEFAULT_STAMP.w / 2,\n y: a.y / page.height - DEFAULT_STAMP.h / 2,\n ...DEFAULT_STAMP,\n })\n : rect\n controller.add({\n kind: 'stamp',\n page: pageNumber,\n rect: placed,\n label: settings.stampLabel,\n color: settings.colors.stamp,\n })\n } else if (tool === 'comment') {\n const anchor = clampRect({\n x: a.x / page.width,\n y: a.y / page.height,\n w: COMMENT_ICON_PX / page.width,\n h: COMMENT_ICON_PX / page.height,\n })\n const id = controller.add({\n kind: 'comment',\n page: pageNumber,\n rect: anchor,\n body: '',\n replies: [],\n resolved: false,\n })\n if (id) {\n controller.setTool('select')\n controller.select(id)\n setOpenComment(id)\n }\n }\n },\n [controller, tool, settings, pageNumber]\n )\n\n const onRootPointerDown = (e: ReactPointerEvent<HTMLDivElement>) => {\n if (!drawing || e.button !== 0 || e.target !== e.currentTarget) return\n e.currentTarget.setPointerCapture(e.pointerId)\n const p = local(e)\n setDraft({ a: p, b: p })\n }\n const onRootPointerMove = (e: ReactPointerEvent<HTMLDivElement>) => {\n if (draft) setDraft({ a: draft.a, b: local(e) })\n }\n const onRootPointerUp = (e: ReactPointerEvent<HTMLDivElement>) => {\n if (!draft) return\n const b = local(e)\n const a = draft.a\n setDraft(null)\n finishDraft(a, b)\n }\n\n const beginDrag = (e: ReactPointerEvent<HTMLElement>, a: Annotation, mode: DragMode) => {\n const origin = singleRect(a)\n if (!origin || e.button !== 0) return\n e.stopPropagation()\n e.currentTarget.setPointerCapture(e.pointerId)\n setDrag({\n id: a.id,\n mode,\n startX: e.clientX,\n startY: e.clientY,\n origin,\n rect: origin,\n moved: false,\n })\n }\n const moveDrag = (e: ReactPointerEvent<HTMLElement>) => {\n if (!drag) return\n const page = pageSize()\n const dxPx = e.clientX - drag.startX\n const dyPx = e.clientY - drag.startY\n const moved = drag.moved || Math.hypot(dxPx, dyPx) > MOVE_THRESHOLD_PX\n if (!moved) return\n setDrag({\n ...drag,\n moved: true,\n rect: dragRect(drag.origin, drag.mode, dxPx / page.width, dyPx / page.height),\n })\n }\n const endDrag = (a: Annotation) => {\n if (!drag) return\n if (drag.moved) controller.update(a.id, patchForRect(a, drag.rect))\n setDrag(null)\n }\n\n const interactive = (a: Annotation) =>\n tool === 'select' || (tool === 'comment' && a.kind === 'comment')\n\n const selected = marks.find((a) => a.id === selectedId)\n\n return (\n <div\n ref={rootRef}\n {...{ [PAGE_ATTRIBUTE]: pageNumber }}\n data-testid={`annotation-overlay-${pageNumber}`}\n className={cn(\n 'absolute inset-0 z-10 select-none overflow-hidden',\n drawing && 'cursor-crosshair'\n )}\n style={{\n pointerEvents: drawing ? 'auto' : 'none',\n touchAction: drawing ? 'none' : undefined,\n }}\n onPointerDown={onRootPointerDown}\n onPointerMove={onRootPointerMove}\n onPointerUp={onRootPointerUp}\n onPointerCancel={() => setDraft(null)}\n >\n {marks.map((a) => (\n <MarkView\n key={a.id}\n annotation={a}\n rectOverride={drag?.id === a.id ? drag.rect : undefined}\n pxPerPt={pxPerPt}\n width={size.width}\n height={size.height}\n selected={a.id === selectedId}\n interactive={interactive(a)}\n onPointerDown={(e) => {\n if (!interactive(a)) return\n e.stopPropagation()\n controller.select(a.id)\n if (a.kind === 'comment') setOpenComment(a.id)\n beginDrag(e, a, 'move')\n }}\n onPointerMove={moveDrag}\n onPointerUp={() => endDrag(a)}\n onActivate={() => {\n controller.select(a.id)\n if (a.kind === 'comment') setOpenComment(a.id)\n }}\n onDelete={() => controller.remove(a.id)}\n />\n ))}\n\n {selected && tool === 'select' && singleRect(selected) && (\n <Handles\n rect={drag?.id === selected.id ? drag.rect : singleRect(selected)!}\n onPointerDown={(e, mode) => beginDrag(e, selected, mode)}\n onPointerMove={moveDrag}\n onPointerUp={() => endDrag(selected)}\n />\n )}\n\n {selected && tool === 'select' && (\n <ActionBar\n annotation={selected}\n controller={controller}\n rect={drag?.id === selected.id ? drag.rect : firstRect(selected)}\n />\n )}\n\n {draft && <Draft draft={draft} tool={tool} />}\n\n {openComment && selected?.kind === 'comment' && selected.id === openComment && (\n <CommentPopover\n annotation={selected}\n controller={controller}\n onClose={() => {\n setOpenComment(null)\n controller.select(null)\n }}\n />\n )}\n </div>\n )\n}\n\nconst firstRect = (a: Annotation): NormRect =>\n a.kind === 'highlight' || a.kind === 'redaction' ? a.rects[0] : a.rect\n\ninterface MarkViewProps {\n annotation: Annotation\n rectOverride?: NormRect\n pxPerPt: number\n width: number\n height: number\n selected: boolean\n interactive: boolean\n onPointerDown: (e: ReactPointerEvent<HTMLElement>) => void\n onPointerMove: (e: ReactPointerEvent<HTMLElement>) => void\n onPointerUp: () => void\n onActivate: () => void\n onDelete: () => void\n}\n\nfunction MarkView(props: MarkViewProps) {\n const { annotation: a, rectOverride, pxPerPt, width, height, selected, interactive } = props\n const handlers = {\n onPointerDown: props.onPointerDown,\n onPointerMove: props.onPointerMove,\n onPointerUp: props.onPointerUp,\n onPointerCancel: props.onPointerUp,\n onKeyDown: (e: KeyboardEvent<HTMLElement>) => {\n if (e.key === 'Enter') props.onActivate()\n if (e.key === 'Delete' || e.key === 'Backspace') {\n e.preventDefault()\n props.onDelete()\n }\n },\n }\n const base = (label: string): Record<string, unknown> => ({\n 'data-testid': `annotation-mark-${a.id}`,\n 'data-kind': a.kind,\n 'data-selected': selected ? 'true' : undefined,\n role: 'button',\n tabIndex: interactive ? 0 : -1,\n 'aria-label': label,\n ...handlers,\n })\n const ring = selected ? 'outline outline-2 outline-offset-2 outline-primary' : ''\n const events = interactive ? 'auto' : 'none'\n // A selected mark that can be moved must not be taken as a page pan by a finger.\n const dragsByTouch = selected && singleRect(a) !== null\n const cursor = interactive ? (singleRect(a) ? 'move' : 'pointer') : undefined\n\n if (a.kind === 'highlight') {\n return (\n <>\n {a.rects.map((r, i) => (\n <div\n key={i}\n {...(i === 0 ? base(`Highlight: ${a.text ?? ''}`) : {})}\n className={cn('absolute rounded-sm', i === 0 && ring)}\n style={{\n ...rectStyle(r),\n background: a.color,\n mixBlendMode: 'multiply',\n opacity: 0.7,\n pointerEvents: events,\n touchAction: dragsByTouch ? 'none' : undefined,\n cursor,\n }}\n />\n ))}\n </>\n )\n }\n\n if (a.kind === 'box') {\n const r = rectOverride ?? a.rect\n return (\n <div\n {...base('Box')}\n className={cn('absolute', ring)}\n style={{\n ...rectStyle(r),\n border: `${a.strokeWidth * pxPerPt}px solid ${a.color}`,\n pointerEvents: events,\n touchAction: dragsByTouch ? 'none' : undefined,\n cursor,\n boxSizing: 'border-box',\n }}\n />\n )\n }\n\n if (a.kind === 'stamp') {\n const r = rectOverride ?? a.rect\n const fontPx = Math.max(\n 6,\n Math.min(r.h * height * 0.6, (r.w * width * 0.9) / Math.max(1, a.label.length * 0.7))\n )\n return (\n <div\n {...base(`Stamp: ${a.label}`)}\n className={cn('absolute flex items-center justify-center font-bold uppercase', ring)}\n style={{\n ...rectStyle(r),\n border: `${2 * pxPerPt}px solid ${a.color}`,\n color: a.color,\n fontSize: fontPx,\n lineHeight: 1,\n pointerEvents: events,\n touchAction: dragsByTouch ? 'none' : undefined,\n cursor,\n boxSizing: 'border-box',\n fontFamily: 'Helvetica, Arial, sans-serif',\n }}\n >\n {a.label}\n </div>\n )\n }\n\n if (a.kind === 'comment') {\n const r = rectOverride ?? a.rect\n return (\n <button\n type=\"button\"\n {...base(`Comment: ${a.body || 'empty'}`)}\n className={cn(\n 'absolute flex items-center justify-center rounded-md border border-amber-700/60 bg-amber-300 text-amber-900 shadow-sm',\n a.resolved && 'opacity-50',\n ring\n )}\n style={{\n left: pct(r.x),\n top: pct(r.y),\n width: COMMENT_ICON_PX,\n height: COMMENT_ICON_PX,\n pointerEvents: events,\n touchAction: dragsByTouch ? 'none' : undefined,\n cursor,\n }}\n >\n <MessageSquare size={14} />\n {a.replies.length > 0 && (\n <span className=\"absolute -right-1 -top-1 rounded-full bg-amber-900 px-1 text-[9px] leading-3 text-white\">\n {a.replies.length}\n </span>\n )}\n </button>\n )\n }\n\n return <RedactionView {...props} annotation={a} ring={ring} cursor={cursor} base={base} />\n}\n\nfunction RedactionView({\n annotation: a,\n rectOverride,\n interactive,\n selected,\n ring,\n cursor,\n base,\n}: MarkViewProps & {\n annotation: RedactionAnnotation\n ring: string\n cursor: string | undefined\n base: (label: string) => Record<string, unknown>\n}) {\n const events = interactive ? 'auto' : 'none'\n const dragsByTouch = selected && singleRect(a) !== null\n const rects = rectOverride ? [rectOverride] : a.rects\n const approved = a.status === 'approved'\n const rejected = a.status === 'rejected'\n return (\n <>\n {rects.map((r, i) => (\n <div\n key={i}\n {...(i === 0 ? base(`Redaction (${a.status}): ${a.reason}`) : {})}\n data-status={i === 0 ? a.status : undefined}\n className={cn(\n 'absolute flex items-center justify-center overflow-hidden text-[10px] leading-none',\n i === 0 && ring\n )}\n style={{\n ...rectStyle(r),\n pointerEvents: events,\n touchAction: dragsByTouch ? 'none' : undefined,\n cursor,\n boxSizing: 'border-box',\n ...(approved\n ? { background: '#000', color: '#fff' }\n : rejected\n ? { border: '1px dotted #868e96', opacity: 0.6 }\n : {\n background: 'rgba(224,49,49,0.18)',\n border: '2px dashed #e03131',\n color: '#c92a2a',\n }),\n }}\n >\n {i === 0 && !rejected && <span className=\"truncate px-1\">{a.reason}</span>}\n </div>\n ))}\n </>\n )\n}\n\nfunction Draft({ draft, tool }: { draft: { a: Point; b: Point }; tool: string }) {\n const x = Math.min(draft.a.x, draft.b.x)\n const y = Math.min(draft.a.y, draft.b.y)\n const w = Math.abs(draft.b.x - draft.a.x)\n const h = Math.abs(draft.b.y - draft.a.y)\n const redact = tool === 'redact-area' || tool === 'redact-text'\n return (\n <div\n data-testid=\"annotation-draft\"\n className=\"pointer-events-none absolute\"\n style={{\n left: x,\n top: y,\n width: w,\n height: h,\n border: redact ? '2px dashed #e03131' : '2px solid #1c7ed6',\n background: redact ? 'rgba(224,49,49,0.18)' : 'rgba(28,126,214,0.08)',\n }}\n />\n )\n}\n\nconst HANDLES: Array<{ mode: DragMode; style: CSSProperties; cursor: string }> = [\n { mode: 'nw', style: { left: 0, top: 0 }, cursor: 'nwse-resize' },\n { mode: 'ne', style: { left: '100%', top: 0 }, cursor: 'nesw-resize' },\n { mode: 'sw', style: { left: 0, top: '100%' }, cursor: 'nesw-resize' },\n { mode: 'se', style: { left: '100%', top: '100%' }, cursor: 'nwse-resize' },\n]\n\nfunction Handles({\n rect,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n}: {\n rect: NormRect\n onPointerDown: (e: ReactPointerEvent<HTMLElement>, mode: DragMode) => void\n onPointerMove: (e: ReactPointerEvent<HTMLElement>) => void\n onPointerUp: () => void\n}) {\n return (\n <div className=\"pointer-events-none absolute\" style={rectStyle(rect)}>\n {HANDLES.map((h) => (\n // The visible dot is small; the element a finger or pointer hits is a larger transparent\n // square around it (44px on touch screens, the usual minimum target).\n <div\n key={h.mode}\n data-testid={`annotation-handle-${h.mode}`}\n 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\"\n style={{ ...h.style, cursor: h.cursor, touchAction: 'none' }}\n onPointerDown={(e) => onPointerDown(e, h.mode)}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n >\n <span className=\"pointer-events-none h-3 w-3 rounded-full border-2 border-primary bg-background\" />\n </div>\n ))}\n </div>\n )\n}\n\nconst ACTION =\n 'inline-flex h-7 w-7 items-center justify-center rounded text-foreground hover:bg-muted'\n\nfunction ActionBar({\n annotation: a,\n controller,\n rect,\n}: {\n annotation: Annotation\n controller: AnnotationController\n rect: NormRect\n}) {\n // Sit above the mark; flip below when it is too close to the top of the page.\n const above = rect.y > 0.05\n return (\n <div\n data-testid=\"annotation-actions\"\n className=\"pointer-events-auto absolute z-20 flex gap-0.5 rounded-md border border-border bg-background p-0.5 shadow-md\"\n style={{\n left: pct(rect.x),\n top: above ? `calc(${pct(rect.y)} - 36px)` : `calc(${pct(rect.y + rect.h)} + 6px)`,\n }}\n onPointerDown={(e) => e.stopPropagation()}\n >\n {a.kind === 'redaction' && a.status !== 'approved' && (\n <button\n type=\"button\"\n className={ACTION}\n title=\"Approve redaction\"\n aria-label=\"Approve redaction\"\n data-testid=\"annotation-action-approve\"\n onClick={() => controller.setRedactionStatus([a.id], 'approved')}\n >\n <Check size={15} />\n </button>\n )}\n {a.kind === 'redaction' && a.status !== 'rejected' && (\n <button\n type=\"button\"\n className={ACTION}\n title=\"Reject redaction (leave visible)\"\n aria-label=\"Reject redaction\"\n data-testid=\"annotation-action-reject\"\n onClick={() => controller.setRedactionStatus([a.id], 'rejected')}\n >\n <X size={15} />\n </button>\n )}\n {a.kind === 'redaction' && a.status !== 'pending' && (\n <button\n type=\"button\"\n className={ACTION}\n title=\"Back to pending\"\n aria-label=\"Mark pending\"\n data-testid=\"annotation-action-pending\"\n onClick={() => controller.setRedactionStatus([a.id], 'pending')}\n >\n <RotateCcw size={15} />\n </button>\n )}\n <button\n type=\"button\"\n className={ACTION}\n title=\"Delete\"\n aria-label=\"Delete annotation\"\n data-testid=\"annotation-action-delete\"\n onClick={() => controller.remove(a.id)}\n >\n <Trash2 size={15} />\n </button>\n </div>\n )\n}\n\nfunction CommentPopover({\n annotation: a,\n controller,\n onClose,\n}: {\n annotation: CommentAnnotation\n controller: AnnotationController\n onClose: () => void\n}) {\n const [body, setBody] = useState(a.body)\n const [reply, setReply] = useState('')\n const mine = a.author === controller.author\n useEffect(() => setBody(a.body), [a.body])\n\n const commitBody = () => {\n if (mine && body !== a.body) controller.update(a.id, { body })\n }\n const close = () => {\n commitBody()\n // an empty comment with no replies is a stray click, not a note worth keeping\n if (body.trim() === '' && a.replies.length === 0) controller.remove(a.id)\n onClose()\n }\n const sendReply = () => {\n const text = reply.trim()\n if (!text) return\n commitBody()\n controller.reply(a.id, text)\n setReply('')\n }\n const onRight = a.rect.x > 0.6\n\n return (\n <div\n data-testid=\"annotation-comment-popover\"\n className=\"pointer-events-auto absolute z-30 w-64 rounded-lg border border-border bg-background p-3 text-sm shadow-lg\"\n style={{\n top: pct(a.rect.y),\n ...(onRight\n ? { right: `calc(${pct(1 - a.rect.x)} + 8px)` }\n : { left: `calc(${pct(a.rect.x)} + ${COMMENT_ICON_PX + 8}px)` }),\n }}\n onPointerDown={(e) => e.stopPropagation()}\n >\n <div className=\"mb-2 flex items-center justify-between gap-2 text-xs text-muted-foreground\">\n <span className=\"truncate\">\n {a.author} · {new Date(a.createdAt).toLocaleString()}\n </span>\n <button\n type=\"button\"\n aria-label=\"Close comment\"\n data-testid=\"annotation-comment-close\"\n className={ACTION}\n onClick={close}\n >\n <X size={14} />\n </button>\n </div>\n <textarea\n autoFocus={a.body === ''}\n data-testid=\"annotation-comment-body\"\n className=\"min-h-16 w-full resize-y rounded-md border border-input bg-background p-2 text-sm\"\n placeholder=\"Add a comment\"\n value={body}\n readOnly={!mine}\n onChange={(e) => setBody(e.target.value)}\n onBlur={commitBody}\n onKeyDown={(e) => {\n if (e.key === 'Escape') close()\n if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {\n commitBody()\n onClose()\n }\n }}\n />\n {a.replies.length > 0 && (\n <ul\n className=\"mt-2 max-h-40 space-y-2 overflow-y-auto\"\n data-testid=\"annotation-comment-replies\"\n >\n {a.replies.map((r) => (\n <li key={r.id} className=\"rounded-md bg-muted p-2\">\n <div className=\"text-xs text-muted-foreground\">{r.author}</div>\n <div className=\"whitespace-pre-wrap break-words\">{r.body}</div>\n </li>\n ))}\n </ul>\n )}\n <div className=\"mt-2 flex gap-1\">\n <input\n data-testid=\"annotation-comment-reply\"\n className=\"h-8 min-w-0 flex-1 rounded-md border border-input bg-background px-2 text-sm\"\n placeholder=\"Reply\"\n value={reply}\n onChange={(e) => setReply(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault()\n sendReply()\n }\n }}\n />\n <button\n type=\"button\"\n aria-label=\"Send reply\"\n data-testid=\"annotation-comment-send\"\n className={ACTION}\n onClick={sendReply}\n >\n <Send size={14} />\n </button>\n </div>\n <div className=\"mt-2 flex items-center justify-between\">\n <button\n type=\"button\"\n data-testid=\"annotation-comment-resolve\"\n className=\"text-xs text-primary hover:underline\"\n onClick={() => controller.resolve(a.id, !a.resolved)}\n >\n {a.resolved ? 'Reopen' : 'Resolve'}\n </button>\n <button\n type=\"button\"\n data-testid=\"annotation-comment-delete\"\n className=\"text-xs text-destructive hover:underline\"\n onClick={() => {\n controller.remove(a.id)\n onClose()\n }}\n >\n Delete\n </button>\n </div>\n </div>\n )\n}\n","/** Delete, Escape, undo and redo for the annotation layer. */\n\nimport { useEffect } from 'react'\nimport type { AnnotationController } from './controller'\n\nconst isEditable = (el: EventTarget | null) =>\n el instanceof HTMLElement &&\n (el.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName))\n\n/** Delete, Escape, undo and redo, ignoring keystrokes meant for a text field. */\nexport function useAnnotationShortcuts(controller: AnnotationController, enabled = true) {\n useEffect(() => {\n if (!enabled) return\n const onKey = (e: KeyboardEvent) => {\n if (isEditable(e.target)) return\n const mod = e.metaKey || e.ctrlKey\n if (mod && e.key.toLowerCase() === 'z') {\n e.preventDefault()\n if (e.shiftKey) controller.redo()\n else controller.undo()\n } else if (mod && e.key.toLowerCase() === 'y') {\n e.preventDefault()\n controller.redo()\n } else if ((e.key === 'Delete' || e.key === 'Backspace') && controller.selectedId) {\n e.preventDefault()\n controller.remove(controller.selectedId)\n } else if (e.key === 'Escape') {\n controller.select(null)\n controller.setTool('select')\n }\n }\n document.addEventListener('keydown', onKey)\n return () => document.removeEventListener('keydown', onKey)\n }, [controller, enabled])\n}\n","/**\n * Toolbar for the annotation layer: pick a tool, set its options, review redactions, undo/redo,\n * and hand off to freezing. Holds no annotation state: everything goes through the controller.\n */\n\nimport type { ReactNode } from 'react'\nimport {\n EyeOff,\n Highlighter,\n MessageSquare,\n MousePointer2,\n Redo2,\n ScanText,\n Snowflake,\n Square,\n Stamp,\n Undo2,\n} from 'lucide-react'\nimport { cn } from '../lib/utils'\nimport { Button } from '../ui/button'\nimport {\n HIGHLIGHT_COLORS,\n MARK_COLORS,\n REDACTION_REASONS,\n STAMP_PRESETS,\n type AnnotationController,\n type AnnotationTool,\n type ColoredTool,\n} from './controller'\nimport { pendingRedactions } from './state'\nimport { useAnnotationShortcuts } from './useAnnotationShortcuts'\nimport { useTextSelectionMarks } from './useTextSelectionMarks'\n\nconst TOOLS: Array<{ tool: AnnotationTool; label: string; icon: ReactNode }> = [\n { tool: 'select', label: 'Select', icon: <MousePointer2 size={16} /> },\n { tool: 'highlight', label: 'Highlight', icon: <Highlighter size={16} /> },\n { tool: 'box', label: 'Box', icon: <Square size={16} /> },\n { tool: 'comment', label: 'Comment', icon: <MessageSquare size={16} /> },\n { tool: 'stamp', label: 'Stamp', icon: <Stamp size={16} /> },\n { tool: 'redact-text', label: 'Redact text', icon: <ScanText size={16} /> },\n { tool: 'redact-area', label: 'Redact area', icon: <EyeOff size={16} /> },\n]\n\nfunction Swatches({\n colors,\n value,\n onChange,\n label,\n}: {\n colors: string[]\n value: string\n onChange: (color: string) => void\n label: string\n}) {\n return (\n <div className=\"flex items-center gap-1\" role=\"group\" aria-label={label}>\n {colors.map((c) => (\n <button\n key={c}\n type=\"button\"\n aria-label={`${label} ${c}`}\n aria-pressed={c === value}\n data-testid={`annotation-color-${c.slice(1)}`}\n className={cn(\n 'h-5 w-5 rounded-full border border-border',\n c === value && 'ring-2 ring-primary ring-offset-1'\n )}\n style={{ background: c }}\n onClick={() => onChange(c)}\n />\n ))}\n </div>\n )\n}\n\nexport interface AnnotationToolbarProps {\n controller: AnnotationController\n /** Show a Freeze button; the host opens its freeze dialog. */\n onFreeze?: () => void\n className?: string\n}\n\nexport function AnnotationToolbar({ controller, onFreeze, className }: AnnotationToolbarProps) {\n useTextSelectionMarks(controller)\n useAnnotationShortcuts(controller)\n\n const { tool, settings } = controller\n const pending = pendingRedactions(controller.layer)\n const redactionCount = controller.layer.annotations.filter((a) => a.kind === 'redaction').length\n const colored = tool === 'highlight' || tool === 'box' || tool === 'stamp'\n const status = controller.error\n ? 'Not saved'\n : controller.saving\n ? 'Saving…'\n : controller.dirty\n ? 'Unsaved changes'\n : 'Saved'\n\n return (\n <div\n role=\"toolbar\"\n aria-label=\"Annotation tools\"\n data-testid=\"annotation-toolbar\"\n className={cn(\n 'flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border bg-background px-3 py-2',\n className\n )}\n >\n <div className=\"flex items-center gap-1\" role=\"group\" aria-label=\"Tool\">\n {TOOLS.map(({ tool: t, label, icon }) => (\n <Button\n key={t}\n type=\"button\"\n size=\"icon\"\n variant={tool === t ? 'default' : 'ghost'}\n title={label}\n aria-label={label}\n aria-pressed={tool === t}\n data-testid={`annotation-tool-${t}`}\n onClick={() => controller.setTool(t)}\n >\n {icon}\n </Button>\n ))}\n </div>\n\n <div className=\"flex items-center gap-1\" role=\"group\" aria-label=\"History\">\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n title=\"Undo\"\n aria-label=\"Undo\"\n data-testid=\"annotation-undo\"\n disabled={!controller.canUndo}\n onClick={controller.undo}\n >\n <Undo2 size={16} />\n </Button>\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n title=\"Redo\"\n aria-label=\"Redo\"\n data-testid=\"annotation-redo\"\n disabled={!controller.canRedo}\n onClick={controller.redo}\n >\n <Redo2 size={16} />\n </Button>\n </div>\n\n {colored && (\n <Swatches\n label=\"Colour\"\n colors={tool === 'highlight' ? HIGHLIGHT_COLORS : MARK_COLORS}\n value={settings.colors[tool as ColoredTool]}\n onChange={(c) => controller.setSettings({ colors: { ...settings.colors, [tool]: c } })}\n />\n )}\n\n {tool === 'stamp' && (\n <>\n <input\n list=\"annotation-stamp-presets\"\n aria-label=\"Stamp text\"\n data-testid=\"annotation-stamp-label\"\n className=\"h-8 w-40 rounded-md border border-input bg-background px-2 text-sm\"\n value={settings.stampLabel}\n maxLength={40}\n onChange={(e) => controller.setSettings({ stampLabel: e.target.value })}\n />\n <datalist id=\"annotation-stamp-presets\">\n {STAMP_PRESETS.map((s) => (\n <option key={s} value={s} />\n ))}\n </datalist>\n </>\n )}\n\n {(tool === 'redact-text' || tool === 'redact-area') && (\n <>\n <input\n list=\"annotation-redaction-reasons\"\n aria-label=\"Redaction reason\"\n data-testid=\"annotation-redaction-reason\"\n className=\"h-8 w-44 rounded-md border border-input bg-background px-2 text-sm\"\n value={settings.redactionReason}\n maxLength={80}\n onChange={(e) => controller.setSettings({ redactionReason: e.target.value })}\n />\n <datalist id=\"annotation-redaction-reasons\">\n {REDACTION_REASONS.map((r) => (\n <option key={r} value={r} />\n ))}\n </datalist>\n </>\n )}\n\n {redactionCount > 0 && (\n <div className=\"flex items-center gap-2 text-sm\" data-testid=\"annotation-review\">\n <span className=\"rounded-md bg-muted px-2 py-1\" data-testid=\"annotation-pending-count\">\n {pending.length} pending\n </span>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n disabled={pending.length === 0}\n data-testid=\"annotation-approve-all\"\n onClick={() =>\n controller.setRedactionStatus(\n pending.map((a) => a.id),\n 'approved'\n )\n }\n >\n Approve all\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n disabled={pending.length === 0}\n data-testid=\"annotation-reject-all\"\n onClick={() =>\n controller.setRedactionStatus(\n pending.map((a) => a.id),\n 'rejected'\n )\n }\n >\n Reject all\n </Button>\n </div>\n )}\n\n <div className=\"ml-auto flex items-center gap-3 text-xs text-muted-foreground\">\n <span\n data-testid=\"annotation-status\"\n role=\"status\"\n className={cn(controller.error && 'text-destructive')}\n title={controller.error ?? undefined}\n >\n {status}\n </span>\n {onFreeze && (\n <Button type=\"button\" size=\"sm\" data-testid=\"annotation-freeze\" onClick={onFreeze}>\n <Snowflake size={14} />\n Freeze copy\n </Button>\n )}\n </div>\n </div>\n )\n}\n","/**\n * Asks how to freeze the annotated document into a new copy. It only collects choices; the host\n * runs `freezePdf` (see `@arbidocs/react/annotations/freeze`) and reports progress back.\n *\n * The rules that keep a redacted copy safe are enforced here as well as in `freezePdf`: redactions\n * force an image-only copy, and unreviewed redaction marks must be resolved before freezing.\n */\n\nimport { useState } from 'react'\nimport { Button } from '../ui/button'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '../ui/dialog'\nimport type { AnnotationController } from './controller'\nimport { isEffectiveRedaction, type AnnotationKind } from './model'\nimport { pendingRedactions } from './state'\n\nexport interface FreezeChoices {\n mode: 'vector' | 'image'\n comments: 'omit' | 'markers' | 'appendix'\n pendingRedactions: 'error' | 'burn'\n}\n\nexport interface FreezeDialogProps {\n open: boolean\n onOpenChange: (open: boolean) => void\n controller: AnnotationController\n onConfirm: (choices: FreezeChoices) => void\n busy?: boolean\n progress?: { done: number; total: number } | null\n error?: string | null\n}\n\nconst KIND_LABELS: Record<AnnotationKind, string> = {\n highlight: 'highlights',\n box: 'boxes',\n comment: 'comments',\n stamp: 'stamps',\n redaction: 'redactions',\n}\n\nexport function FreezeDialog({\n open,\n onOpenChange,\n controller,\n onConfirm,\n busy,\n progress,\n error,\n}: FreezeDialogProps) {\n const [mode, setMode] = useState<FreezeChoices['mode']>('vector')\n const [comments, setComments] = useState<FreezeChoices['comments']>('omit')\n const [burnPending, setBurnPending] = useState(false)\n\n const marks = controller.layer.annotations\n const redactions = marks.filter(isEffectiveRedaction)\n const pending = pendingRedactions(controller.layer)\n const forced = redactions.length > 0\n const effectiveMode = forced ? 'image' : mode\n const blocked = pending.length > 0 && !burnPending\n const counts = (Object.keys(KIND_LABELS) as AnnotationKind[])\n .map(\n (k) =>\n [\n k,\n marks.filter((a) => a.kind === k && (k !== 'redaction' || isEffectiveRedaction(a)))\n .length,\n ] as const\n )\n .filter(([, n]) => n > 0)\n\n return (\n <Dialog open={open} onOpenChange={(next) => !busy && onOpenChange(next)}>\n <DialogContent data-testid=\"freeze-dialog\">\n <DialogHeader>\n <DialogTitle>Freeze a copy</DialogTitle>\n <DialogDescription>\n Creates a new document with your annotations built in. The original is never changed.\n </DialogDescription>\n </DialogHeader>\n\n <p className=\"text-sm text-muted-foreground\" data-testid=\"freeze-summary\">\n {counts.length === 0\n ? 'No annotations yet.'\n : counts.map(([k, n]) => `${n} ${KIND_LABELS[k]}`).join(', ')}\n </p>\n\n <fieldset className=\"space-y-2 text-sm\" disabled={busy}>\n <legend className=\"mb-1 font-medium\">Format</legend>\n <label className=\"flex items-start gap-2\">\n <input\n type=\"radio\"\n name=\"freeze-mode\"\n data-testid=\"freeze-mode-vector\"\n checked={effectiveMode === 'vector'}\n disabled={forced}\n onChange={() => setMode('vector')}\n />\n <span>\n Keep text\n <span className=\"block text-xs text-muted-foreground\">\n Searchable, smaller. Not available when there are redactions.\n </span>\n </span>\n </label>\n <label className=\"flex items-start gap-2\">\n <input\n type=\"radio\"\n name=\"freeze-mode\"\n data-testid=\"freeze-mode-image\"\n checked={effectiveMode === 'image'}\n onChange={() => setMode('image')}\n />\n <span>\n Image only\n <span className=\"block text-xs text-muted-foreground\">\n Every page becomes a picture. Nothing is left behind a redaction.\n </span>\n </span>\n </label>\n {forced && (\n <p className=\"text-xs text-muted-foreground\" data-testid=\"freeze-forced-note\">\n Image only is required because this document has redactions.\n </p>\n )}\n </fieldset>\n\n <label className=\"flex items-center gap-2 text-sm\">\n Comments\n <select\n data-testid=\"freeze-comments\"\n className=\"h-8 rounded-md border border-input bg-background px-2\"\n value={comments}\n disabled={busy}\n onChange={(e) => setComments(e.target.value as FreezeChoices['comments'])}\n >\n <option value=\"omit\">Leave out</option>\n <option value=\"markers\">Numbered markers</option>\n <option value=\"appendix\">Markers and a listing</option>\n </select>\n </label>\n {forced && comments !== 'omit' && marks.some((a) => a.kind === 'comment') && (\n <p className=\"text-xs text-destructive\" data-testid=\"freeze-comment-warning\">\n Comments are copied as written and may repeat text you have redacted.\n </p>\n )}\n\n {pending.length > 0 && (\n <label\n className=\"flex items-start gap-2 rounded-md border border-border p-2 text-sm\"\n data-testid=\"freeze-pending\"\n >\n <input\n type=\"checkbox\"\n data-testid=\"freeze-burn-pending\"\n checked={burnPending}\n disabled={busy}\n onChange={(e) => setBurnPending(e.target.checked)}\n />\n <span>\n {pending.length} redaction{pending.length === 1 ? ' has' : 's have'} not been reviewed\n <span className=\"block text-xs text-muted-foreground\">\n Tick to redact them as well, or approve or reject them first.\n </span>\n </span>\n </label>\n )}\n\n {busy && progress && (\n <p className=\"text-sm\" role=\"status\" data-testid=\"freeze-progress\">\n Page {progress.done} of {progress.total}…\n </p>\n )}\n {error && (\n <p className=\"text-sm text-destructive\" role=\"alert\" data-testid=\"freeze-error\">\n {error}\n </p>\n )}\n\n <DialogFooter>\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={busy}\n onClick={() => onOpenChange(false)}\n >\n Cancel\n </Button>\n <Button\n type=\"button\"\n data-testid=\"freeze-confirm\"\n disabled={busy || blocked}\n onClick={() =>\n onConfirm({\n mode: effectiveMode,\n comments,\n pendingRedactions: burnPending ? 'burn' : 'error',\n })\n }\n >\n {busy ? 'Freezing…' : 'Freeze'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkRI3BZQWD_cjs = require('../chunk-RI3BZQWD.cjs');
4
- var chunkZMTLGO3K_cjs = require('../chunk-ZMTLGO3K.cjs');
3
+ var chunkR6V6YHPD_cjs = require('../chunk-R6V6YHPD.cjs');
4
+ var chunkPATLJSAO_cjs = require('../chunk-PATLJSAO.cjs');
5
5
  var chunkNA3FOYSF_cjs = require('../chunk-NA3FOYSF.cjs');
6
6
  require('../chunk-S6A6FSG7.cjs');
7
- var chunkPATLJSAO_cjs = require('../chunk-PATLJSAO.cjs');
7
+ var chunkZMTLGO3K_cjs = require('../chunk-ZMTLGO3K.cjs');
8
8
  var react = require('react');
9
9
  var reactQuery = require('@tanstack/react-query');
10
10
  var jsxRuntime = require('react/jsx-runtime');
@@ -134,7 +134,7 @@ function flattenChunks(chunks, options) {
134
134
  const text = (chunks ?? []).map((c) => (c.content ?? "").trim()).join("\n\n");
135
135
  if (!options?.unescape) return text;
136
136
  return chunkPATLJSAO_cjs.normalizeMarkdown(
137
- chunkRI3BZQWD_cjs.repairParsedStructure(chunkRI3BZQWD_cjs.repairParsedTitle(chunkRI3BZQWD_cjs.unescapeMarkdown(text)))
137
+ chunkR6V6YHPD_cjs.repairParsedStructure(chunkR6V6YHPD_cjs.repairParsedTitle(chunkR6V6YHPD_cjs.unescapeMarkdown(text)))
138
138
  ).replace(/\n$/, "");
139
139
  }
140
140
  var DOC_ID = /^doc/;
@@ -342,7 +342,7 @@ function useArtifactText(docId, options) {
342
342
  const enabled = (options?.enabled ?? true) && isDocumentId(docId) && arbi.hasWorkspace;
343
343
  const query = reactQuery.useQuery({
344
344
  // Under the shared `parsedDoc` key, so a document's invalidation reaches it too.
345
- queryKey: [...chunkRI3BZQWD_cjs.arbiQueryKeys.parsedDoc(docId ?? "", "marker"), "artifact-text"],
345
+ queryKey: [...chunkR6V6YHPD_cjs.arbiQueryKeys.parsedDoc(docId ?? "", "marker"), "artifact-text"],
346
346
  queryFn: async () => {
347
347
  const parsed = await arbi.documents.getParsedContent(docId, "marker");
348
348
  if (!parsed.chunks?.some((c) => c.content?.trim())) throw new NotParsedYetError();
@@ -384,7 +384,7 @@ function useArtifactText(docId, options) {
384
384
 
385
385
  // src/artifacts/useArtifactSession.ts
386
386
  function useArtifactVersions(workspaceId, docId) {
387
- const { data: documents } = chunkRI3BZQWD_cjs.useDocuments(workspaceId);
387
+ const { data: documents } = chunkR6V6YHPD_cjs.useDocuments(workspaceId);
388
388
  return react.useMemo(
389
389
  () => toArtifactVersions(buildVersionChain(documents ?? [], docId)),
390
390
  [documents, docId]
@@ -406,7 +406,7 @@ function useSaveArtifactVersion() {
406
406
  }
407
407
  );
408
408
  if (workspaceId) {
409
- await queryClient.invalidateQueries({ queryKey: chunkRI3BZQWD_cjs.arbiQueryKeys.documents(workspaceId) });
409
+ await queryClient.invalidateQueries({ queryKey: chunkR6V6YHPD_cjs.arbiQueryKeys.documents(workspaceId) });
410
410
  }
411
411
  return { docId: result.doc_ext_ids?.[0] };
412
412
  }
@@ -554,7 +554,7 @@ function useStreamedArtifact({
554
554
  let stored;
555
555
  if (clean) stored = clean(content);
556
556
  else {
557
- const report = chunkRI3BZQWD_cjs.cleanDraftWithReport(content);
557
+ const report = chunkR6V6YHPD_cjs.cleanDraftWithReport(content);
558
558
  stored = report.text;
559
559
  setCleaned(report);
560
560
  onCleaned?.(report);
@@ -595,35 +595,35 @@ function useStreamedArtifact({
595
595
 
596
596
  Object.defineProperty(exports, "cleanDraftMarkdown", {
597
597
  enumerable: true,
598
- get: function () { return chunkRI3BZQWD_cjs.cleanDraftMarkdown; }
598
+ get: function () { return chunkR6V6YHPD_cjs.cleanDraftMarkdown; }
599
599
  });
600
600
  Object.defineProperty(exports, "cleanDraftWithReport", {
601
601
  enumerable: true,
602
- get: function () { return chunkRI3BZQWD_cjs.cleanDraftWithReport; }
602
+ get: function () { return chunkR6V6YHPD_cjs.cleanDraftWithReport; }
603
603
  });
604
604
  Object.defineProperty(exports, "promoteBoldTitle", {
605
605
  enumerable: true,
606
- get: function () { return chunkRI3BZQWD_cjs.promoteBoldTitle; }
606
+ get: function () { return chunkR6V6YHPD_cjs.promoteBoldTitle; }
607
607
  });
608
608
  Object.defineProperty(exports, "repairParsedStructure", {
609
609
  enumerable: true,
610
- get: function () { return chunkRI3BZQWD_cjs.repairParsedStructure; }
610
+ get: function () { return chunkR6V6YHPD_cjs.repairParsedStructure; }
611
611
  });
612
612
  Object.defineProperty(exports, "repairParsedTitle", {
613
613
  enumerable: true,
614
- get: function () { return chunkRI3BZQWD_cjs.repairParsedTitle; }
614
+ get: function () { return chunkR6V6YHPD_cjs.repairParsedTitle; }
615
615
  });
616
616
  Object.defineProperty(exports, "stripAgentPreamble", {
617
617
  enumerable: true,
618
- get: function () { return chunkRI3BZQWD_cjs.stripAgentPreamble; }
618
+ get: function () { return chunkR6V6YHPD_cjs.stripAgentPreamble; }
619
619
  });
620
620
  Object.defineProperty(exports, "unescapeMarkdown", {
621
621
  enumerable: true,
622
- get: function () { return chunkRI3BZQWD_cjs.unescapeMarkdown; }
622
+ get: function () { return chunkR6V6YHPD_cjs.unescapeMarkdown; }
623
623
  });
624
624
  Object.defineProperty(exports, "unwrapCitationLinks", {
625
625
  enumerable: true,
626
- get: function () { return chunkRI3BZQWD_cjs.unwrapCitationLinks; }
626
+ get: function () { return chunkR6V6YHPD_cjs.unwrapCitationLinks; }
627
627
  });
628
628
  Object.defineProperty(exports, "buildHybridRedlineMarkdown", {
629
629
  enumerable: true,
@@ -1,10 +1,10 @@
1
- import { repairParsedStructure, repairParsedTitle, unescapeMarkdown, arbiQueryKeys, useDocuments, cleanDraftWithReport } from '../chunk-GT6KN3DV.js';
2
- export { cleanDraftMarkdown, cleanDraftWithReport, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks } from '../chunk-GT6KN3DV.js';
3
- import { useArbi } from '../chunk-J4MX2W4H.js';
4
- import { MarkdownRenderer } from '../chunk-JPGV7NMY.js';
5
- import '../chunk-SN5YV6FF.js';
1
+ import { repairParsedStructure, repairParsedTitle, unescapeMarkdown, arbiQueryKeys, useDocuments, cleanDraftWithReport } from '../chunk-XKGTZ3H6.js';
2
+ export { cleanDraftMarkdown, cleanDraftWithReport, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks } from '../chunk-XKGTZ3H6.js';
6
3
  import { revertRedlineRegion, buildHybridRedlineWithRegions, buildHybridRedlineMarkdown, normalizeMarkdown } from '../chunk-43AKLNBC.js';
7
4
  export { buildHybridRedlineMarkdown, buildHybridRedlineWithRegions, normalizeMarkdown, revertRedlineRegion } from '../chunk-43AKLNBC.js';
5
+ import { MarkdownRenderer } from '../chunk-JPGV7NMY.js';
6
+ import '../chunk-SN5YV6FF.js';
7
+ import { useArbi } from '../chunk-J4MX2W4H.js';
8
8
  import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
9
9
  import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
10
10
  import { jsx } from 'react/jsx-runtime';