@embedpdf/plugin-annotation 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1232 -101
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +33 -3
- package/dist/lib/annotation-plugin.d.ts +178 -2
- package/dist/lib/handlers/types.d.ts +1 -1
- package/dist/lib/helpers.d.ts +8 -2
- package/dist/lib/selectors.d.ts +97 -8
- package/dist/lib/tools/default-tools.d.ts +39 -11
- package/dist/lib/tools/types.d.ts +22 -4
- package/dist/lib/types.d.ts +278 -1
- package/dist/preact/adapter.d.ts +3 -3
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +1133 -403
- package/dist/preact/index.js.map +1 -1
- package/dist/react/adapter.d.ts +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +1132 -402
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/annotation-container.d.ts +13 -2
- package/dist/shared/components/annotation-layer.d.ts +6 -2
- package/dist/shared/components/annotations/ink.d.ts +3 -3
- package/dist/shared/components/annotations/link.d.ts +28 -0
- package/dist/shared/components/annotations.d.ts +4 -1
- package/dist/shared/components/group-selection-box.d.ts +32 -0
- package/dist/shared/components/index.d.ts +1 -0
- package/dist/shared/components/text-markup/highlight.d.ts +3 -2
- package/dist/shared/components/text-markup/squiggly.d.ts +3 -2
- package/dist/shared/components/text-markup/strikeout.d.ts +3 -2
- package/dist/shared/components/text-markup/underline.d.ts +3 -2
- package/dist/shared/components/types.d.ts +50 -1
- package/dist/shared/context/index.d.ts +1 -0
- package/dist/shared/context/renderer-registry.d.ts +21 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared-preact/components/annotation-container.d.ts +13 -2
- package/dist/shared-preact/components/annotation-layer.d.ts +6 -2
- package/dist/shared-preact/components/annotations/ink.d.ts +3 -3
- package/dist/shared-preact/components/annotations/link.d.ts +28 -0
- package/dist/shared-preact/components/annotations.d.ts +4 -1
- package/dist/shared-preact/components/group-selection-box.d.ts +32 -0
- package/dist/shared-preact/components/index.d.ts +1 -0
- package/dist/shared-preact/components/text-markup/highlight.d.ts +3 -2
- package/dist/shared-preact/components/text-markup/squiggly.d.ts +3 -2
- package/dist/shared-preact/components/text-markup/strikeout.d.ts +3 -2
- package/dist/shared-preact/components/text-markup/underline.d.ts +3 -2
- package/dist/shared-preact/components/types.d.ts +50 -1
- package/dist/shared-preact/context/index.d.ts +1 -0
- package/dist/shared-preact/context/renderer-registry.d.ts +21 -0
- package/dist/shared-preact/index.d.ts +2 -0
- package/dist/shared-react/components/annotation-container.d.ts +13 -2
- package/dist/shared-react/components/annotation-layer.d.ts +6 -2
- package/dist/shared-react/components/annotations/ink.d.ts +3 -3
- package/dist/shared-react/components/annotations/link.d.ts +28 -0
- package/dist/shared-react/components/annotations.d.ts +4 -1
- package/dist/shared-react/components/group-selection-box.d.ts +32 -0
- package/dist/shared-react/components/index.d.ts +1 -0
- package/dist/shared-react/components/text-markup/highlight.d.ts +3 -2
- package/dist/shared-react/components/text-markup/squiggly.d.ts +3 -2
- package/dist/shared-react/components/text-markup/strikeout.d.ts +3 -2
- package/dist/shared-react/components/text-markup/underline.d.ts +3 -2
- package/dist/shared-react/components/types.d.ts +50 -1
- package/dist/shared-react/context/index.d.ts +1 -0
- package/dist/shared-react/context/renderer-registry.d.ts +21 -0
- package/dist/shared-react/index.d.ts +2 -0
- package/dist/svelte/components/AnnotationLayer.svelte.d.ts +8 -1
- package/dist/svelte/components/Annotations.svelte.d.ts +8 -1
- package/dist/svelte/components/GroupSelectionBox.svelte.d.ts +32 -0
- package/dist/svelte/components/RendererRegistryProvider.svelte.d.ts +7 -0
- package/dist/svelte/components/annotations/Ink.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Link.svelte.d.ts +24 -0
- package/dist/svelte/components/annotations/index.d.ts +1 -0
- package/dist/svelte/components/index.d.ts +2 -0
- package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +2 -1
- package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +2 -1
- package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +2 -1
- package/dist/svelte/components/text-markup/Underline.svelte.d.ts +2 -1
- package/dist/svelte/components/types.d.ts +2 -0
- package/dist/svelte/context/index.d.ts +2 -0
- package/dist/svelte/context/renderer-registry.svelte.d.ts +20 -0
- package/dist/svelte/context/types.d.ts +33 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.d.ts +2 -0
- package/dist/svelte/index.js +1215 -394
- package/dist/svelte/index.js.map +1 -1
- package/dist/svelte/types.d.ts +7 -0
- package/dist/vue/components/annotation-container.vue.d.ts +3 -1
- package/dist/vue/components/annotation-layer.vue.d.ts +31 -5
- package/dist/vue/components/annotations/free-text.vue.d.ts +1 -1
- package/dist/vue/components/annotations/index.d.ts +1 -0
- package/dist/vue/components/annotations/ink.vue.d.ts +2 -2
- package/dist/vue/components/annotations/line.vue.d.ts +1 -1
- package/dist/vue/components/annotations/link.vue.d.ts +29 -0
- package/dist/vue/components/annotations/polygon.vue.d.ts +1 -1
- package/dist/vue/components/annotations/polyline.vue.d.ts +1 -1
- package/dist/vue/components/annotations/stamp.vue.d.ts +1 -1
- package/dist/vue/components/annotations.vue.d.ts +151 -53
- package/dist/vue/components/group-selection-box.vue.d.ts +73 -0
- package/dist/vue/components/index.d.ts +2 -0
- package/dist/vue/components/preview-renderer.vue.d.ts +1 -1
- package/dist/vue/components/renderer-registry-provider.vue.d.ts +13 -0
- package/dist/vue/components/text-markup/highlight.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/squiggly.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/strikeout.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/underline.vue.d.ts +2 -2
- package/dist/vue/context/index.d.ts +2 -0
- package/dist/vue/context/renderer-registry.d.ts +26 -0
- package/dist/vue/context/types.d.ts +33 -0
- package/dist/vue/hooks/use-annotation.d.ts +7 -5
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.ts +3 -1
- package/dist/vue/index.js +1124 -459
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/types.d.ts +8 -1
- package/package.json +10 -10
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { PdfAnnotationObject, PdfAnnotationSubtype, Size } from '@embedpdf/models';
|
|
2
|
+
/**
|
|
3
|
+
* A dynamic boolean property that can be either a static boolean
|
|
4
|
+
* or a function that receives the annotation and returns a boolean.
|
|
5
|
+
*/
|
|
6
|
+
export type DynamicBooleanProp = boolean | ((annotation: PdfAnnotationObject) => boolean);
|
|
7
|
+
/**
|
|
8
|
+
* Resolves a dynamic boolean property to its actual value.
|
|
9
|
+
* @param prop The dynamic property (boolean or function)
|
|
10
|
+
* @param annotation The annotation to pass to the function if prop is a function
|
|
11
|
+
* @param defaultValue The default value if prop is undefined
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveInteractionProp(prop: DynamicBooleanProp | undefined, annotation: PdfAnnotationObject, defaultValue: boolean): boolean;
|
|
2
14
|
/**
|
|
3
15
|
* Specific configuration for Stamp tools.
|
|
4
16
|
*/
|
|
@@ -84,10 +96,16 @@ export type AnnotationTool<T extends PdfAnnotationObject = PdfAnnotationObject>
|
|
|
84
96
|
cursor?: string;
|
|
85
97
|
/** If true, this interaction mode is activated by selecting text. */
|
|
86
98
|
textSelection?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
isDraggable?:
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
/** Whether this annotation can be dragged when selected individually. Can be dynamic based on annotation. */
|
|
100
|
+
isDraggable?: DynamicBooleanProp;
|
|
101
|
+
/** Whether this annotation can be resized when selected individually. Can be dynamic based on annotation. */
|
|
102
|
+
isResizable?: DynamicBooleanProp;
|
|
103
|
+
/** Whether to maintain aspect ratio during resize. Can be dynamic based on annotation. */
|
|
104
|
+
lockAspectRatio?: DynamicBooleanProp;
|
|
105
|
+
/** Whether this annotation can be dragged when part of a group. Defaults to isDraggable. Can be dynamic based on annotation. */
|
|
106
|
+
isGroupDraggable?: DynamicBooleanProp;
|
|
107
|
+
/** Whether this annotation can be resized when part of a group. Defaults to isResizable. Can be dynamic based on annotation. */
|
|
108
|
+
isGroupResizable?: DynamicBooleanProp;
|
|
91
109
|
};
|
|
92
110
|
/** Tool-specific behavior settings that override plugin defaults */
|
|
93
111
|
behavior?: {
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { BasePluginConfig, EventHook } from '@embedpdf/core';
|
|
2
|
-
import { AnnotationCreateContext, PdfAnnotationObject, PdfAnnotationSubtype, PdfErrorReason, PdfRenderPageAnnotationOptions, PdfTextAnnoObject, Task } from '@embedpdf/models';
|
|
2
|
+
import { AnnotationCreateContext, PdfAnnotationObject, PdfAnnotationSubtype, PdfErrorReason, PdfRenderPageAnnotationOptions, PdfTextAnnoObject, Position, Rect, Size, Task } from '@embedpdf/models';
|
|
3
3
|
import { AnnotationTool } from './tools/types';
|
|
4
|
+
/**
|
|
5
|
+
* Metadata attached to annotation history commands for filtering/purging.
|
|
6
|
+
* Used by the history plugin's purgeByMetadata method to identify commands
|
|
7
|
+
* that should be removed (e.g., after a permanent redaction commit).
|
|
8
|
+
*/
|
|
9
|
+
export interface AnnotationCommandMetadata {
|
|
10
|
+
/** The annotation IDs affected by this command */
|
|
11
|
+
annotationIds: string[];
|
|
12
|
+
}
|
|
4
13
|
export type AnnotationEvent = {
|
|
5
14
|
type: 'create';
|
|
6
15
|
documentId: string;
|
|
@@ -34,6 +43,32 @@ export interface TrackedAnnotation<T extends PdfAnnotationObject = PdfAnnotation
|
|
|
34
43
|
commitState: CommitState;
|
|
35
44
|
object: T;
|
|
36
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Represents a batch of pending annotation changes to be committed.
|
|
48
|
+
* Separates the collection of changes from their execution.
|
|
49
|
+
*/
|
|
50
|
+
export interface CommitBatch {
|
|
51
|
+
/** Annotations that need to be created in the PDF */
|
|
52
|
+
creations: Array<{
|
|
53
|
+
uid: string;
|
|
54
|
+
ta: TrackedAnnotation;
|
|
55
|
+
ctx?: AnnotationCreateContext<PdfAnnotationObject>;
|
|
56
|
+
}>;
|
|
57
|
+
/** Annotations that need to be updated in the PDF */
|
|
58
|
+
updates: Array<{
|
|
59
|
+
uid: string;
|
|
60
|
+
ta: TrackedAnnotation;
|
|
61
|
+
}>;
|
|
62
|
+
/** Annotations that need to be deleted from the PDF */
|
|
63
|
+
deletions: Array<{
|
|
64
|
+
uid: string;
|
|
65
|
+
ta: TrackedAnnotation;
|
|
66
|
+
}>;
|
|
67
|
+
/** All UIDs that are part of this commit batch */
|
|
68
|
+
committedUids: string[];
|
|
69
|
+
/** Whether this batch has any changes */
|
|
70
|
+
isEmpty: boolean;
|
|
71
|
+
}
|
|
37
72
|
export interface RenderAnnotationOptions {
|
|
38
73
|
pageIndex: number;
|
|
39
74
|
annotation: PdfAnnotationObject;
|
|
@@ -42,6 +77,13 @@ export interface RenderAnnotationOptions {
|
|
|
42
77
|
export interface AnnotationDocumentState {
|
|
43
78
|
pages: Record<number, string[]>;
|
|
44
79
|
byUid: Record<string, TrackedAnnotation>;
|
|
80
|
+
/** Array of selected annotation UIDs (supports multi-selection) */
|
|
81
|
+
selectedUids: string[];
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated Use `selectedUids` array or `getSelectedAnnotation()` instead.
|
|
84
|
+
* Returns the UID only when exactly one annotation is selected, otherwise null.
|
|
85
|
+
* Will be removed in next major version.
|
|
86
|
+
*/
|
|
45
87
|
selectedUid: string | null;
|
|
46
88
|
activeToolId: string | null;
|
|
47
89
|
hasPendingChanges: boolean;
|
|
@@ -96,12 +138,34 @@ export interface AnnotationActiveToolChangeEvent {
|
|
|
96
138
|
documentId: string;
|
|
97
139
|
tool: AnnotationTool | null;
|
|
98
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Represents what grouping action is available for the current selection.
|
|
143
|
+
* - 'group': Selection can be grouped (2+ annotations, not all in same group)
|
|
144
|
+
* - 'ungroup': Selection is exactly one complete group that can be ungrouped
|
|
145
|
+
* - 'disabled': No valid grouping action (0-1 annotations selected)
|
|
146
|
+
*/
|
|
147
|
+
export type GroupingAction = 'group' | 'ungroup' | 'disabled';
|
|
99
148
|
export interface AnnotationScope {
|
|
100
149
|
getState(): AnnotationDocumentState;
|
|
101
150
|
getPageAnnotations(options: GetPageAnnotationsOptions): Task<PdfAnnotationObject[], PdfErrorReason>;
|
|
151
|
+
/** @deprecated Use getSelectedAnnotations() for multi-select support. Returns first selected or null. */
|
|
102
152
|
getSelectedAnnotation(): TrackedAnnotation | null;
|
|
153
|
+
/** Get all selected annotations */
|
|
154
|
+
getSelectedAnnotations(): TrackedAnnotation[];
|
|
155
|
+
/** Get the IDs of all selected annotations */
|
|
156
|
+
getSelectedAnnotationIds(): string[];
|
|
103
157
|
getAnnotationById(id: string): TrackedAnnotation | null;
|
|
158
|
+
/** Select a single annotation (clears previous selection) */
|
|
104
159
|
selectAnnotation(pageIndex: number, annotationId: string): void;
|
|
160
|
+
/** Toggle an annotation in/out of the current selection */
|
|
161
|
+
toggleSelection(pageIndex: number, annotationId: string): void;
|
|
162
|
+
/** Add an annotation to the current selection */
|
|
163
|
+
addToSelection(pageIndex: number, annotationId: string): void;
|
|
164
|
+
/** Remove an annotation from the current selection */
|
|
165
|
+
removeFromSelection(annotationId: string): void;
|
|
166
|
+
/** Set the selection to a specific set of annotation IDs (for marquee) */
|
|
167
|
+
setSelection(ids: string[]): void;
|
|
168
|
+
/** Clear all selection */
|
|
105
169
|
deselectAnnotation(): void;
|
|
106
170
|
getActiveTool(): AnnotationTool | null;
|
|
107
171
|
setActiveTool(toolId: string | null): void;
|
|
@@ -109,9 +173,38 @@ export interface AnnotationScope {
|
|
|
109
173
|
importAnnotations(items: ImportAnnotationItem<PdfAnnotationObject>[]): void;
|
|
110
174
|
createAnnotation<A extends PdfAnnotationObject>(pageIndex: number, annotation: A, context?: AnnotationCreateContext<A>): void;
|
|
111
175
|
updateAnnotation(pageIndex: number, annotationId: string, patch: Partial<PdfAnnotationObject>): void;
|
|
176
|
+
/** Batch update multiple annotations at once */
|
|
177
|
+
updateAnnotations(patches: Array<{
|
|
178
|
+
pageIndex: number;
|
|
179
|
+
id: string;
|
|
180
|
+
patch: Partial<PdfAnnotationObject>;
|
|
181
|
+
}>): void;
|
|
112
182
|
deleteAnnotation(pageIndex: number, annotationId: string): void;
|
|
183
|
+
/** Delete multiple annotations in batch */
|
|
184
|
+
deleteAnnotations(annotations: Array<{
|
|
185
|
+
pageIndex: number;
|
|
186
|
+
id: string;
|
|
187
|
+
}>): void;
|
|
188
|
+
/** Remove an annotation from state without calling the engine (no PDF modification) */
|
|
189
|
+
purgeAnnotation(pageIndex: number, annotationId: string): void;
|
|
113
190
|
renderAnnotation(options: RenderAnnotationOptions): Task<Blob, PdfErrorReason>;
|
|
114
191
|
commit(): Task<boolean, PdfErrorReason>;
|
|
192
|
+
/** Get link annotations attached to an annotation via IRT relationship */
|
|
193
|
+
getAttachedLinks(annotationId: string): TrackedAnnotation[];
|
|
194
|
+
/** Check if an annotation has attached link children */
|
|
195
|
+
hasAttachedLinks(annotationId: string): boolean;
|
|
196
|
+
/** Delete all link annotations attached to an annotation */
|
|
197
|
+
deleteAttachedLinks(annotationId: string): void;
|
|
198
|
+
/** Group the currently selected annotations (first selected becomes leader) */
|
|
199
|
+
groupAnnotations(): void;
|
|
200
|
+
/** Ungroup all annotations in the group containing the specified annotation */
|
|
201
|
+
ungroupAnnotations(annotationId: string): void;
|
|
202
|
+
/** Get all annotations in the same group as the specified annotation */
|
|
203
|
+
getGroupMembers(annotationId: string): TrackedAnnotation<PdfAnnotationObject>[];
|
|
204
|
+
/** Check if an annotation is part of a group */
|
|
205
|
+
isInGroup(annotationId: string): boolean;
|
|
206
|
+
/** Get the available grouping action for the current selection */
|
|
207
|
+
getGroupingAction(): GroupingAction;
|
|
115
208
|
onStateChange: EventHook<AnnotationDocumentState>;
|
|
116
209
|
onAnnotationEvent: EventHook<AnnotationEvent>;
|
|
117
210
|
onActiveToolChange: EventHook<AnnotationTool | null>;
|
|
@@ -119,16 +212,58 @@ export interface AnnotationScope {
|
|
|
119
212
|
export interface AnnotationCapability {
|
|
120
213
|
getState: () => AnnotationDocumentState;
|
|
121
214
|
getPageAnnotations: (options: GetPageAnnotationsOptions) => Task<PdfAnnotationObject[], PdfErrorReason>;
|
|
215
|
+
/** @deprecated Use getSelectedAnnotations() for multi-select support. Returns first selected or null. */
|
|
122
216
|
getSelectedAnnotation: () => TrackedAnnotation | null;
|
|
217
|
+
/** Get all selected annotations */
|
|
218
|
+
getSelectedAnnotations: () => TrackedAnnotation[];
|
|
219
|
+
/** Get the IDs of all selected annotations */
|
|
220
|
+
getSelectedAnnotationIds: () => string[];
|
|
123
221
|
getAnnotationById(id: string): TrackedAnnotation | null;
|
|
222
|
+
/** Select a single annotation (clears previous selection) */
|
|
124
223
|
selectAnnotation: (pageIndex: number, annotationId: string) => void;
|
|
224
|
+
/** Toggle an annotation in/out of the current selection */
|
|
225
|
+
toggleSelection: (pageIndex: number, annotationId: string) => void;
|
|
226
|
+
/** Add an annotation to the current selection */
|
|
227
|
+
addToSelection: (pageIndex: number, annotationId: string) => void;
|
|
228
|
+
/** Remove an annotation from the current selection */
|
|
229
|
+
removeFromSelection: (annotationId: string) => void;
|
|
230
|
+
/** Set the selection to a specific set of annotation IDs (for marquee) */
|
|
231
|
+
setSelection: (ids: string[]) => void;
|
|
232
|
+
/** Clear all selection */
|
|
125
233
|
deselectAnnotation: () => void;
|
|
126
234
|
importAnnotations: (items: ImportAnnotationItem<PdfAnnotationObject>[]) => void;
|
|
127
235
|
createAnnotation: <A extends PdfAnnotationObject>(pageIndex: number, annotation: A, context?: AnnotationCreateContext<A>) => void;
|
|
128
236
|
updateAnnotation: (pageIndex: number, annotationId: string, patch: Partial<PdfAnnotationObject>) => void;
|
|
237
|
+
/** Batch update multiple annotations at once */
|
|
238
|
+
updateAnnotations: (patches: Array<{
|
|
239
|
+
pageIndex: number;
|
|
240
|
+
id: string;
|
|
241
|
+
patch: Partial<PdfAnnotationObject>;
|
|
242
|
+
}>) => void;
|
|
129
243
|
deleteAnnotation: (pageIndex: number, annotationId: string) => void;
|
|
244
|
+
/** Delete multiple annotations in batch */
|
|
245
|
+
deleteAnnotations: (annotations: Array<{
|
|
246
|
+
pageIndex: number;
|
|
247
|
+
id: string;
|
|
248
|
+
}>, documentId?: string) => void;
|
|
249
|
+
/** Remove an annotation from state without calling the engine (no PDF modification) */
|
|
250
|
+
purgeAnnotation: (pageIndex: number, annotationId: string, documentId?: string) => void;
|
|
130
251
|
renderAnnotation: (options: RenderAnnotationOptions) => Task<Blob, PdfErrorReason>;
|
|
131
252
|
commit: () => Task<boolean, PdfErrorReason>;
|
|
253
|
+
/** Get link annotations attached to an annotation via IRT relationship */
|
|
254
|
+
getAttachedLinks: (annotationId: string, documentId?: string) => TrackedAnnotation[];
|
|
255
|
+
/** Check if an annotation has attached link children */
|
|
256
|
+
hasAttachedLinks: (annotationId: string, documentId?: string) => boolean;
|
|
257
|
+
/** Delete all link annotations attached to an annotation */
|
|
258
|
+
deleteAttachedLinks: (annotationId: string, documentId?: string) => void;
|
|
259
|
+
/** Group the currently selected annotations (first selected becomes leader) */
|
|
260
|
+
groupAnnotations: (documentId?: string) => void;
|
|
261
|
+
/** Ungroup all annotations in the group containing the specified annotation */
|
|
262
|
+
ungroupAnnotations: (annotationId: string, documentId?: string) => void;
|
|
263
|
+
/** Get all annotations in the same group as the specified annotation */
|
|
264
|
+
getGroupMembers: (annotationId: string, documentId?: string) => TrackedAnnotation<PdfAnnotationObject>[];
|
|
265
|
+
/** Check if an annotation is part of a group */
|
|
266
|
+
isInGroup: (annotationId: string, documentId?: string) => boolean;
|
|
132
267
|
forDocument: (documentId: string) => AnnotationScope;
|
|
133
268
|
getActiveTool: () => AnnotationTool | null;
|
|
134
269
|
setActiveTool: (toolId: string | null) => void;
|
|
@@ -162,3 +297,145 @@ export interface SidebarAnnotationEntry {
|
|
|
162
297
|
annotation: TrackedAnnotation;
|
|
163
298
|
replies: TrackedAnnotation<PdfTextAnnoObject>[];
|
|
164
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* Information about an annotation needed for constraint calculation.
|
|
302
|
+
*/
|
|
303
|
+
export interface AnnotationConstraintInfo {
|
|
304
|
+
id: string;
|
|
305
|
+
rect: Rect;
|
|
306
|
+
pageIndex: number;
|
|
307
|
+
pageSize: Size;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Combined constraints representing the intersection of all selected annotations' movement limits.
|
|
311
|
+
* These are the maximum distances the group can move in each direction without any annotation
|
|
312
|
+
* leaving its page bounds.
|
|
313
|
+
*/
|
|
314
|
+
export interface CombinedConstraints {
|
|
315
|
+
/** Maximum distance we can move up (positive = can move up) */
|
|
316
|
+
maxUp: number;
|
|
317
|
+
/** Maximum distance we can move down */
|
|
318
|
+
maxDown: number;
|
|
319
|
+
/** Maximum distance we can move left */
|
|
320
|
+
maxLeft: number;
|
|
321
|
+
/** Maximum distance we can move right */
|
|
322
|
+
maxRight: number;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Options for starting a unified drag operation.
|
|
326
|
+
* The plugin will automatically expand to include attached links.
|
|
327
|
+
*/
|
|
328
|
+
export interface UnifiedDragOptions {
|
|
329
|
+
/** The explicitly selected/dragged annotation IDs */
|
|
330
|
+
annotationIds: string[];
|
|
331
|
+
/** Page size for constraint calculation */
|
|
332
|
+
pageSize: Size;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* State of the unified drag operation.
|
|
336
|
+
* Managed entirely by the plugin - framework components just subscribe.
|
|
337
|
+
*/
|
|
338
|
+
export interface UnifiedDragState {
|
|
339
|
+
/** The document this drag belongs to */
|
|
340
|
+
documentId: string;
|
|
341
|
+
/** Whether a drag is currently in progress */
|
|
342
|
+
isDragging: boolean;
|
|
343
|
+
/** The explicitly selected annotation IDs (what the user selected) */
|
|
344
|
+
primaryIds: string[];
|
|
345
|
+
/** Auto-expanded attached link IDs */
|
|
346
|
+
attachedLinkIds: string[];
|
|
347
|
+
/** All participant IDs (primaryIds + attachedLinkIds) */
|
|
348
|
+
allParticipantIds: string[];
|
|
349
|
+
/** Original rects for all participants (for computing final patches) */
|
|
350
|
+
originalRects: Map<string, Rect>;
|
|
351
|
+
/** Current cumulative delta (already clamped to constraints) */
|
|
352
|
+
delta: Position;
|
|
353
|
+
/** Combined constraints computed at drag start */
|
|
354
|
+
combinedConstraints: CombinedConstraints;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Event emitted when unified drag state changes.
|
|
358
|
+
*/
|
|
359
|
+
export interface UnifiedDragEvent {
|
|
360
|
+
/** The document this event belongs to */
|
|
361
|
+
documentId: string;
|
|
362
|
+
/** The type of change */
|
|
363
|
+
type: 'start' | 'update' | 'end' | 'cancel';
|
|
364
|
+
/** Current state */
|
|
365
|
+
state: UnifiedDragState;
|
|
366
|
+
/** Pre-computed patches for ALL participants - components just apply directly! */
|
|
367
|
+
previewPatches: Record<string, Partial<PdfAnnotationObject>>;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Options for starting a unified resize operation.
|
|
371
|
+
* The plugin will automatically expand to include attached links.
|
|
372
|
+
*/
|
|
373
|
+
export interface UnifiedResizeOptions {
|
|
374
|
+
/** The explicitly selected annotation IDs */
|
|
375
|
+
annotationIds: string[];
|
|
376
|
+
/** Page size for constraint calculation */
|
|
377
|
+
pageSize: Size;
|
|
378
|
+
/** Which resize handle is being used */
|
|
379
|
+
resizeHandle: string;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Information about an annotation participating in unified resize.
|
|
383
|
+
*/
|
|
384
|
+
export interface UnifiedResizeAnnotationInfo {
|
|
385
|
+
id: string;
|
|
386
|
+
originalRect: Rect;
|
|
387
|
+
pageIndex: number;
|
|
388
|
+
/** Whether this is an attached link (auto-expanded) */
|
|
389
|
+
isAttachedLink: boolean;
|
|
390
|
+
/** The parent annotation ID (if this is an attached link) */
|
|
391
|
+
parentId?: string;
|
|
392
|
+
/** Relative X position within group (0-1) */
|
|
393
|
+
relativeX: number;
|
|
394
|
+
/** Relative Y position within group (0-1) */
|
|
395
|
+
relativeY: number;
|
|
396
|
+
/** Relative width within group (0-1) */
|
|
397
|
+
relativeWidth: number;
|
|
398
|
+
/** Relative height within group (0-1) */
|
|
399
|
+
relativeHeight: number;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* State of the unified resize operation.
|
|
403
|
+
* Managed entirely by the plugin - framework components just subscribe.
|
|
404
|
+
*/
|
|
405
|
+
export interface UnifiedResizeState {
|
|
406
|
+
/** The document this resize belongs to */
|
|
407
|
+
documentId: string;
|
|
408
|
+
/** Whether a resize is currently in progress */
|
|
409
|
+
isResizing: boolean;
|
|
410
|
+
/** The explicitly selected annotation IDs (what the user selected) */
|
|
411
|
+
primaryIds: string[];
|
|
412
|
+
/** Auto-expanded attached link IDs */
|
|
413
|
+
attachedLinkIds: string[];
|
|
414
|
+
/** All participant IDs (primaryIds + attachedLinkIds) */
|
|
415
|
+
allParticipantIds: string[];
|
|
416
|
+
/** The original group bounding box at resize start */
|
|
417
|
+
originalGroupBox: Rect;
|
|
418
|
+
/** The current (resized) group bounding box */
|
|
419
|
+
currentGroupBox: Rect;
|
|
420
|
+
/** All annotations participating with their relative positions */
|
|
421
|
+
participatingAnnotations: UnifiedResizeAnnotationInfo[];
|
|
422
|
+
/** Which resize handle is being used */
|
|
423
|
+
resizeHandle: string;
|
|
424
|
+
/** Current computed rects for all participants */
|
|
425
|
+
computedRects: Map<string, Rect>;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Event emitted when unified resize state changes.
|
|
429
|
+
*/
|
|
430
|
+
export interface UnifiedResizeEvent {
|
|
431
|
+
/** The document this event belongs to */
|
|
432
|
+
documentId: string;
|
|
433
|
+
/** The type of change */
|
|
434
|
+
type: 'start' | 'update' | 'end' | 'cancel';
|
|
435
|
+
/** Current state */
|
|
436
|
+
state: UnifiedResizeState;
|
|
437
|
+
/** Per-annotation computed rects for convenience (id -> new rect) */
|
|
438
|
+
computedRects: Record<string, Rect>;
|
|
439
|
+
/** Pre-computed patches for ALL participants - components just apply directly! */
|
|
440
|
+
previewPatches: Record<string, Partial<PdfAnnotationObject>>;
|
|
441
|
+
}
|
package/dist/preact/adapter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { JSX, Fragment } from 'preact';
|
|
2
|
-
export { useEffect, useRef, useState, useCallback, useMemo, useLayoutEffect } from 'preact/hooks';
|
|
1
|
+
import { JSX, Fragment, createContext } from 'preact';
|
|
2
|
+
export { useEffect, useRef, useState, useCallback, useMemo, useLayoutEffect, useContext, } from 'preact/hooks';
|
|
3
3
|
export type { ComponentChildren as ReactNode, JSX } from 'preact';
|
|
4
|
-
export { Fragment };
|
|
4
|
+
export { Fragment, createContext };
|
|
5
5
|
export type CSSProperties = import('preact').JSX.CSSProperties;
|
|
6
6
|
export type HTMLAttributes<T = any> = import('preact').JSX.HTMLAttributes<T extends EventTarget ? T : never>;
|
|
7
7
|
export type MouseEvent<T = Element> = JSX.TargetedMouseEvent<T extends EventTarget ? T : never>;
|
package/dist/preact/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),t=require("@embedpdf/plugin-annotation"),n=require("preact"),o=require("preact/hooks"),i=require("preact/jsx-runtime"),s=require("@embedpdf/models"),r=require("@embedpdf/plugin-interaction-manager/preact"),l=require("@embedpdf/plugin-selection/preact"),a=require("@embedpdf/utils/preact"),c={},d=()=>e.usePlugin(t.AnnotationPlugin.id),u=()=>e.useCapability(t.AnnotationPlugin.id);function g({scale:t,documentId:n,pageIndex:s,rotation:r,pageWidth:l,pageHeight:c,trackedAnnotation:d,children:g,isSelected:h,isDraggable:p,isResizable:x,lockAspectRatio:v=!1,style:b={},vertexConfig:y,selectionMenu:f,outlineOffset:m=1,onDoubleClick:j,onSelect:k,zIndex:S=1,resizeUI:M,vertexUI:A,selectionOutlineColor:w="#007ACC",customAnnotationRenderer:z,...D}){const[P,R]=o.useState(d.object),{provides:C}=u(),{canModifyAnnotations:I}=e.useDocumentPermissions(n),E=o.useRef(null),B=I&&p,T=I&&x,$=o.useMemo(()=>C?C.forDocument(n):null,[C,n]),L=P?{...d.object,...P}:d.object,F=(null==M?void 0:M.color)??"#007ACC",O=(null==A?void 0:A.color)??"#007ACC",U=(null==M?void 0:M.size)??12,W=(null==A?void 0:A.size)??12,{dragProps:H,vertices:N,resize:q}=a.useInteractionHandles({controller:{element:L.rect,vertices:null==y?void 0:y.extractVertices(L),constraints:{minWidth:10,minHeight:10,boundingBox:{width:l,height:c}},maintainAspectRatio:v,pageRotation:r,scale:t,enabled:h,onUpdate:e=>{var t;if(!(null==(t=e.transformData)?void 0:t.type))return;"start"===e.state&&(E.current=L);const n=e.transformData.type,o=E.current??L,i=e.transformData.changes.vertices?null==y?void 0:y.transformAnnotation(o,e.transformData.changes.vertices):{rect:e.transformData.changes.rect},r=null==C?void 0:C.transformAnnotation(o,{type:n,changes:i,metadata:e.transformData.metadata});r&&R(e=>({...e,...r})),"end"===e.state&&r&&(E.current=null,null==$||$.updateAnnotation(s,d.object.id,r))}},resizeUI:{handleSize:U,spacing:m,offsetMode:"outside",includeSides:!v,zIndex:S+1},vertexUI:{vertexSize:W,zIndex:S+2},includeVertices:!!y}),V=o.useMemo(()=>{if(I&&j)return j},[I,j]),G=a.useDoublePressProps(V);return o.useEffect(()=>{R(d.object)},[d.object]),i.jsxs("div",{"data-no-interaction":!0,children:[i.jsxs("div",{...B&&h?H:{},...G,style:{position:"absolute",left:L.rect.origin.x*t,top:L.rect.origin.y*t,width:L.rect.size.width*t,height:L.rect.size.height*t,outline:h?`1px solid ${w}`:"none",outlineOffset:h?`${m}px`:"0px",pointerEvents:h?"auto":"none",touchAction:"none",cursor:h&&B?"move":"default",zIndex:S,...b},...D,children:[(()=>{const e="function"==typeof g?g(L):g,n=null==z?void 0:z({annotation:L,children:e,isSelected:h,scale:t,rotation:r,pageWidth:l,pageHeight:c,pageIndex:s,onSelect:k});return null!=n?n:e})(),h&&T&&q.map(({key:e,...t})=>(null==M?void 0:M.component)?M.component({key:e,...t,backgroundColor:F}):i.jsx("div",{...t,style:{...t.style,backgroundColor:F}},e)),h&&I&&N.map(({key:e,...t})=>(null==A?void 0:A.component)?A.component({key:e,...t,backgroundColor:O}):i.jsx("div",{...t,style:{...t.style,backgroundColor:O}},e))]}),f&&i.jsx(a.CounterRotate,{rect:{origin:{x:L.rect.origin.x*t,y:L.rect.origin.y*t},size:{width:L.rect.size.width*t,height:L.rect.size.height*t}},rotation:r,children:e=>f({...e,context:{type:"annotation",annotation:d,pageIndex:s},selected:h,placement:{suggestTop:!1}})})]})}function h({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:o,scale:s,onClick:r,style:l}){return i.jsx(i.Fragment,{children:n.map((n,a)=>i.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(o?n.origin.x-o.origin.x:n.origin.x)*s,top:(o?n.origin.y-o.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:e,opacity:t,pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:void 0,...l}},a))})}function p({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:o,scale:s,onClick:r,style:l}){const a=2*s;return i.jsx(i.Fragment,{children:n.map((n,c)=>i.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(o?n.origin.x-o.origin.x:n.origin.x)*s,top:(o?n.origin.y-o.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:i.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:a,background:e,opacity:t,pointerEvents:"none"}})},c))})}function x({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:o,scale:s,onClick:r,style:l}){const a=2*s;return i.jsx(i.Fragment,{children:n.map((n,c)=>i.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(o?n.origin.x-o.origin.x:n.origin.x)*s,top:(o?n.origin.y-o.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:i.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:a,background:e,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},c))})}function v({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:o,scale:s,onClick:r,style:l}){const a=2*s,c=6*s,d=`url("data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${c}" height="${2*a}" viewBox="0 0 ${c} ${2*a}">\n <path d="M0 ${a} Q ${c/4} 0 ${c/2} ${a} T ${c} ${a}"\n fill="none" stroke="${e}" stroke-width="${a}" stroke-linecap="round"/>\n </svg>`)}")`;return i.jsx(i.Fragment,{children:n.map((e,n)=>i.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(o?e.origin.x-o.origin.x:e.origin.x)*s,top:(o?e.origin.y-o.origin.y:e.origin.y)*s,width:e.size.width*s,height:e.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:i.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:2*a,backgroundImage:d,backgroundRepeat:"repeat-x",backgroundSize:`${c}px ${2*a}px`,opacity:t,pointerEvents:"none"}})},n))})}function b({isSelected:e,color:t="#000000",opacity:n=1,strokeWidth:s,inkList:r,rect:l,scale:a,onClick:c}){const d=o.useMemo(()=>r.map(({points:e})=>{let t="";return e.forEach(({x:e,y:n},o)=>{const i=e-l.origin.x,s=n-l.origin.y;t+=(0===o?"M":"L")+i+" "+s+" "}),t.trim()}),[r,l]),u=l.size.width*a,g=l.size.height*a;return i.jsx("svg",{style:{position:"absolute",width:u,height:g,pointerEvents:"none",zIndex:2,overflow:"visible"},width:u,height:g,viewBox:`0 0 ${l.size.width} ${l.size.height}`,children:d.map((o,r)=>i.jsx("path",{d:o,fill:"none",opacity:n,onPointerDown:c,onTouchStart:c,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visibleStroke",stroke:t,strokeWidth:s,strokeLinecap:"round",strokeLinejoin:"round"}},r))})}function y({isSelected:e,color:t="#000000",strokeColor:n,opacity:r=1,strokeWidth:l,strokeStyle:a=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:g}){const{width:h,height:p,x:x,y:v}=o.useMemo(()=>{const e=d.size.width,t=d.size.height;return{width:Math.max(e-l,0),height:Math.max(t-l,0),x:l/2,y:l/2}},[d,l]),b=(h+l)*u,y=(p+l)*u;return i.jsx("svg",{style:{position:"absolute",width:b,height:y,pointerEvents:"none",zIndex:2},width:b,height:y,viewBox:`0 0 ${h+l} ${p+l}`,children:i.jsx("rect",{x:x,y:v,width:h,height:p,fill:t,opacity:r,onPointerDown:g,onTouchStart:g,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"transparent"===t?"visibleStroke":"visible",stroke:n??t,strokeWidth:l,...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})})}function f({color:e="#000000",strokeColor:t,opacity:n=1,strokeWidth:r,strokeStyle:l=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:a,rect:c,scale:d,onClick:u,isSelected:g}){const{width:h,height:p,cx:x,cy:v,rx:b,ry:y}=o.useMemo(()=>{const e=c.size.width,t=c.size.height,n=Math.max(e-r,0),o=Math.max(t-r,0);return{width:e,height:t,cx:r/2+n/2,cy:r/2+o/2,rx:n/2,ry:o/2}},[c,r]),f=h*d,m=p*d;return i.jsx("svg",{style:{position:"absolute",width:f,height:m,pointerEvents:"none",zIndex:2},width:f,height:m,viewBox:`0 0 ${h} ${p}`,children:i.jsx("ellipse",{cx:x,cy:v,rx:b,ry:y,fill:e,opacity:n,onPointerDown:u,onTouchStart:u,style:{cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===e?"visibleStroke":"visible",stroke:t??e,strokeWidth:r,...l===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==a?void 0:a.join(",")}}})})}function m({color:e="transparent",opacity:n=1,strokeWidth:r,strokeColor:l="#000000",strokeStyle:a=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,linePoints:u,lineEndings:g,scale:h,onClick:p,isSelected:x}){const{x1:v,y1:b,x2:y,y2:f}=o.useMemo(()=>({x1:u.start.x-d.origin.x,y1:u.start.y-d.origin.y,x2:u.end.x-d.origin.x,y2:u.end.y-d.origin.y}),[u,d]),m=o.useMemo(()=>{const e=Math.atan2(f-b,y-v);return{start:t.patching.createEnding(null==g?void 0:g.start,r,e+Math.PI,v,b),end:t.patching.createEnding(null==g?void 0:g.end,r,e,y,f)}},[g,r,v,b,y,f]),j=d.size.width*h,k=d.size.height*h;return i.jsxs("svg",{style:{position:"absolute",width:j,height:k,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:k,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[i.jsx("line",{x1:v,y1:b,x2:y,y2:f,opacity:n,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",pointerEvents:x?"none":"visibleStroke",stroke:l,strokeWidth:r,strokeLinecap:"butt",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),m.start&&i.jsx("path",{d:m.start.d,transform:m.start.transform,onPointerDown:p,onTouchStart:p,stroke:l,style:{cursor:x?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:x?"none":m.start.filled?"visible":"visibleStroke",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.start.filled?e:"none"}),m.end&&i.jsx("path",{d:m.end.d,transform:m.end.transform,stroke:l,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:x?"none":m.end.filled?"visible":"visibleStroke",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.end.filled?e:"none"})]})}function j({rect:e,vertices:n,color:s="transparent",strokeColor:r="#000000",opacity:l=1,strokeWidth:a,scale:c,isSelected:d,onClick:u,lineEndings:g}){const h=o.useMemo(()=>n.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[n,e]),p=o.useMemo(()=>{if(!h.length)return"";const[e,...t]=h;return`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y} `).join("").trim()},[h]),x=o.useMemo(()=>{if(h.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),n=e(h[0],h[1]),o=e(h[h.length-2],h[h.length-1]);return{start:t.patching.createEnding(null==g?void 0:g.start,a,n+Math.PI,h[0].x,h[0].y),end:t.patching.createEnding(null==g?void 0:g.end,a,o,h[h.length-1].x,h[h.length-1].y)}},[h,g,a]),v=e.size.width*c,b=e.size.height*c;return i.jsxs("svg",{style:{position:"absolute",width:v,height:b,pointerEvents:"none",zIndex:2,overflow:"visible"},width:v,height:b,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[i.jsx("path",{d:p,onPointerDown:u,onTouchStart:u,opacity:l,style:{fill:"none",stroke:r??s,strokeWidth:a,cursor:d?"move":"pointer",pointerEvents:d?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"}}),x.start&&i.jsx("path",{d:x.start.d,transform:x.start.transform,stroke:r,fill:x.start.filled?s:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":x.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),x.end&&i.jsx("path",{d:x.end.d,transform:x.end.transform,stroke:r,fill:x.end.filled?s:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":x.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}})]})}function k({rect:e,vertices:t,color:n="transparent",strokeColor:r="#000000",opacity:l=1,strokeWidth:a,strokeStyle:c=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,scale:u,isSelected:g,onClick:h,currentVertex:p,handleSize:x=14}){const v=p?[...t,p]:t,b=o.useMemo(()=>v.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[v,e]),y=o.useMemo(()=>{if(!b.length)return"";const[e,...t]=b,n=!!p;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(n?"":" Z")).trim()},[b,p]),f=p&&t.length>0,m=e.size.width*u,j=e.size.height*u;return i.jsxs("svg",{style:{position:"absolute",width:m,height:j,pointerEvents:"none",zIndex:2,overflow:"visible"},width:m,height:j,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[i.jsx("path",{d:y,onPointerDown:h,onTouchStart:h,opacity:l,style:{fill:p?"none":n,stroke:r??n,strokeWidth:a,cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===n?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter",...c===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}),f&&t.length>1&&i.jsx("path",{d:`M ${b[b.length-1].x} ${b[b.length-1].y} L ${b[0].x} ${b[0].y}`,fill:"none",style:{stroke:r,strokeWidth:a,strokeDasharray:"4,4",opacity:.7}}),f&&t.length>=2&&i.jsx("rect",{x:b[0].x-x/u/2,y:b[0].y-x/u/2,width:x/u,height:x/u,fill:r,opacity:.4,stroke:r,strokeWidth:a/2})]})}function S({isSelected:e,isEditing:t,annotation:n,pageIndex:r,scale:l,onClick:a}){const d=o.useRef(null),{provides:g}=u(),[h,p]=o.useState(!1);o.useEffect(()=>{if(t&&d.current){const e=d.current;e.focus();const t=window.getSelection();if(t){const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}}},[t]),o.useLayoutEffect(()=>{try{const e=navigator,t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1;p(t)}catch{p(!1)}},[]);const x=n.object.fontSize*l,v=h&&t&&x>0&&x<16,b=v?16:x,y=v?x/16:1,f=v?100/y:100;return i.jsx("div",{style:{position:"absolute",width:n.object.rect.size.width*l,height:n.object.rect.size.height*l,cursor:e&&!t?"move":"default",pointerEvents:e&&!t?"none":"auto",zIndex:2},onPointerDown:a,onTouchStart:a,children:i.jsx("span",{ref:d,onBlur:()=>{g&&d.current&&g.updateAnnotation(r,n.object.id,{contents:d.current.innerText})},tabIndex:0,style:{color:n.object.fontColor,fontSize:b,fontFamily:s.standardFontCss(n.object.fontFamily),textAlign:s.textAlignmentToCss(n.object.textAlign),flexDirection:"column",justifyContent:n.object.verticalAlign===s.PdfVerticalAlignment.Top?"flex-start":n.object.verticalAlign===s.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:n.object.backgroundColor,opacity:n.object.opacity,width:v?`${f}%`:"100%",height:v?`${f}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:t?"text":"pointer",outline:"none",transform:v?`scale(${y})`:void 0,transformOrigin:"top left"},contentEditable:t,...c,children:n.object.contents})})}function M({documentId:e,pageIndex:t,annotation:r,scaleFactor:l=1,style:a,...c}){const{provides:d}=u(),[g,h]=o.useState(null),p=o.useRef(null),{width:x,height:v}=r.rect.size;o.useEffect(()=>{if(d){const n=d.forDocument(e).renderAnnotation({pageIndex:t,annotation:r,options:{scaleFactor:l,dpr:window.devicePixelRatio}});return n.wait(e=>{const t=URL.createObjectURL(e);h(t),p.current=t},s.ignore),()=>{p.current?(URL.revokeObjectURL(p.current),p.current=null):n.abort({code:s.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,l,d,e,r.id,x,v]);return i.jsx(n.Fragment,{children:g&&i.jsx("img",{src:g,onLoad:()=>{p.current&&(URL.revokeObjectURL(p.current),p.current=null)},...c,style:{width:"100%",height:"100%",display:"block",...a||{}}})})}function A({isSelected:e,annotation:t,documentId:n,pageIndex:o,scale:s,onClick:r}){return i.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:e?"none":"auto",cursor:"pointer"},onPointerDown:r,onTouchStart:r,children:i.jsx(M,{documentId:n,pageIndex:o,annotation:{...t.object,id:t.object.id},scaleFactor:s})})}function w(e){const{documentId:a,pageIndex:c,scale:d,selectionMenu:M}=e,{provides:w}=u(),{provides:z}=l.useSelectionCapability(),[D,P]=o.useState([]),{register:R}=r.usePointerHandlers({documentId:a,pageIndex:c}),[C,I]=o.useState(null),[E,B]=o.useState(null),T=o.useMemo(()=>w?w.forDocument(a):null,[w,a]);o.useEffect(()=>{if(T){const e=T.getState();return P(t.getAnnotationsByPageIndex(e,c)),I(t.getSelectedAnnotationByPageIndex(e,c)),T.onStateChange(e=>{P(t.getAnnotationsByPageIndex(e,c)),I(t.getSelectedAnnotationByPageIndex(e,c))})}},[T,c]);const $=o.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&T&&(T.deselectAnnotation(),B(null))}}),[T]),L=o.useCallback((e,t)=>{e.stopPropagation(),T&&z&&(T.selectAnnotation(c,t.object.id),z.clear(),t.object.id!==E&&B(null))},[T,z,E,c]);return o.useEffect(()=>R($,{documentId:a}),[R,$]),i.jsx(i.Fragment,{children:D.map(o=>{const r=(null==C?void 0:C.object.id)===o.object.id,l=E===o.object.id,u=null==T?void 0:T.findToolForAnnotation(o.object);return t.isInk(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!0,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(b,{...e,isSelected:r,scale:d,onClick:e=>L(e,o)})},o.object.id):t.isSquare(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!0,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(y,{...e,isSelected:r,scale:d,onClick:e=>L(e,o)})},o.object.id):t.isCircle(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!0,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(f,{...e,isSelected:r,scale:d,onClick:e=>L(e,o)})},o.object.id):t.isUnderline(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!1,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),zIndex:0,style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(p,{...e,scale:d,onClick:e=>L(e,o)})},o.object.id):t.isStrikeout(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!1,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),zIndex:0,style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(x,{...e,scale:d,onClick:e=>L(e,o)})},o.object.id):t.isSquiggly(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!1,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),zIndex:0,style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(v,{...e,scale:d,onClick:e=>L(e,o)})},o.object.id):t.isHighlight(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!1,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),zIndex:0,style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Multiply)},...e,children:e=>i.jsx(h,{...e,scale:d,onClick:e=>L(e,o)})},o.object.id):t.isLine(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(n.Fragment,{children:i.jsx(m,{...e,isSelected:r,scale:d,onClick:e=>L(e,o)})})},o.object.id):t.isPolyline(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(n.Fragment,{children:i.jsx(j,{...e,isSelected:r,scale:d,onClick:e=>L(e,o)})})},o.object.id):t.isPolygon(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(n.Fragment,{children:i.jsx(k,{...e,isSelected:r,scale:d,onClick:e=>L(e,o)})})},o.object.id):t.isFreeText(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:((null==u?void 0:u.interaction.isDraggable)??!0)&&!l,isResizable:(null==u?void 0:u.interaction.isResizable)??!0,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},onDoubleClick:e=>{e.stopPropagation(),B(o.object.id)},...e,children:e=>i.jsx(S,{isSelected:r,isEditing:l,annotation:{...o,object:e},pageIndex:c,scale:d,onClick:e=>L(e,o)})},o.object.id):t.isStamp(o)?i.jsx(g,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!0,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:M,onSelect:e=>L(e,o),style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(A,{isSelected:r,annotation:o,documentId:a,pageIndex:c,scale:d,onClick:e=>L(e,o)})},o.object.id):null})})}function z({documentId:e,pageIndex:t,scale:n}){var r,a,c,d,g,b,y,f,m,j,k,S;const{provides:M}=l.useSelectionCapability(),{provides:A}=u(),[w,z]=o.useState([]),[D,P]=o.useState(null),[R,C]=o.useState(null);if(o.useEffect(()=>{if(M)return M.forDocument(e).onSelectionChange(()=>{z(M.forDocument(e).getHighlightRectsForPage(t)),P(M.forDocument(e).getBoundingRectForPage(t))})},[M,e,t]),o.useEffect(()=>{if(A)return C(A.forDocument(e).getActiveTool()),A.forDocument(e).onActiveToolChange(e=>C(e))},[A,e]),!D)return null;if(!R||!R.defaults)return null;switch(R.defaults.type){case s.PdfAnnotationSubtype.UNDERLINE:return i.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(r=R.defaults)?void 0:r.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:i.jsx(p,{color:null==(a=R.defaults)?void 0:a.color,opacity:null==(c=R.defaults)?void 0:c.opacity,segmentRects:w,scale:n})});case s.PdfAnnotationSubtype.HIGHLIGHT:return i.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(d=R.defaults)?void 0:d.blendMode)??s.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:i.jsx(h,{color:null==(g=R.defaults)?void 0:g.color,opacity:null==(b=R.defaults)?void 0:b.opacity,segmentRects:w,scale:n})});case s.PdfAnnotationSubtype.STRIKEOUT:return i.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(y=R.defaults)?void 0:y.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:i.jsx(x,{color:null==(f=R.defaults)?void 0:f.color,opacity:null==(m=R.defaults)?void 0:m.opacity,segmentRects:w,scale:n})});case s.PdfAnnotationSubtype.SQUIGGLY:return i.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(j=R.defaults)?void 0:j.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:i.jsx(v,{color:null==(k=R.defaults)?void 0:k.color,opacity:null==(S=R.defaults)?void 0:S.opacity,segmentRects:w,scale:n})});default:return null}}function D({preview:e,scale:t}){const{bounds:n}=e,o={position:"absolute",left:n.origin.x*t,top:n.origin.y*t,width:n.size.width*t,height:n.size.height*t,pointerEvents:"none",zIndex:10};return e.type===s.PdfAnnotationSubtype.CIRCLE?i.jsx("div",{style:o,children:i.jsx(f,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.SQUARE?i.jsx("div",{style:o,children:i.jsx(y,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.POLYGON?i.jsx("div",{style:o,children:i.jsx(k,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.POLYLINE?i.jsx("div",{style:o,children:i.jsx(j,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.LINE?i.jsx("div",{style:o,children:i.jsx(m,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.INK?i.jsx("div",{style:o,children:i.jsx(b,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.FREETEXT?i.jsx("div",{style:o,children:i.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})}):null}function P({documentId:e,pageIndex:t,scale:n}){const{plugin:s}=d(),[r,l]=o.useState(new Map),a=o.useRef(null),c=o.useRef(null),u=o.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!a.current)return;const n=a.current;n.accept=e,n.onchange=e=>{var o;const i=null==(o=e.target.files)?void 0:o[0];i&&(t(i),n.value="")},n.click()},processImage:({source:e,maxWidth:t,maxHeight:n,onComplete:o})=>{const i=c.current;if(!i||!i.getContext)return;const s=i.getContext("2d");if(!s)return;const r=new Image;r.crossOrigin="Anonymous",r.onload=()=>{let{naturalWidth:l,naturalHeight:a}=r;const c=t?t/l:1,d=n?n/a:1,u=Math.min(c,d,1),g=l*u,h=a*u;i.width=g,i.height=h,s.drawImage(r,0,0,g,h);const p=s.getImageData(0,0,g,h);"string"!=typeof e&&URL.revokeObjectURL(r.src),o({imageData:p,width:g,height:h})},r.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return o.useEffect(()=>{if(s)return s.registerPageHandlers(e,t,n,{services:u,onPreview:(e,t)=>{l(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,n,s,u]),i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:a,type:"file",style:{display:"none"}}),i.jsx("canvas",{ref:c,style:{display:"none"}}),Array.from(r.entries()).map(([e,t])=>i.jsx(D,{preview:t,scale:n},e))]})}exports.AnnotationLayer=function({style:t,documentId:n,pageIndex:r,scale:l,rotation:a,selectionMenu:c,resizeUI:d,vertexUI:u,selectionOutlineColor:g,customAnnotationRenderer:h,...p}){var x,v,b,y;const f=e.useDocumentState(n),m=null==(v=null==(x=null==f?void 0:f.document)?void 0:x.pages)?void 0:v[r],j=(null==(b=null==m?void 0:m.size)?void 0:b.width)??0,k=(null==(y=null==m?void 0:m.size)?void 0:y.height)??0,S=o.useMemo(()=>void 0!==l?l:(null==f?void 0:f.scale)??1,[l,null==f?void 0:f.scale]),M=o.useMemo(()=>void 0!==a?a:(null==f?void 0:f.rotation)??s.Rotation.Degree0,[a,null==f?void 0:f.rotation]);return i.jsxs("div",{style:{...t},...p,children:[i.jsx(w,{documentId:n,selectionMenu:c,pageIndex:r,scale:S,rotation:M,pageWidth:j,pageHeight:k,resizeUI:d,vertexUI:u,selectionOutlineColor:g,customAnnotationRenderer:h}),i.jsx(z,{documentId:n,pageIndex:r,scale:S}),i.jsx(P,{documentId:n,pageIndex:r,scale:S})]})},exports.useAnnotation=e=>{var n;const{provides:i}=u(),[s,r]=o.useState((null==(n=null==i?void 0:i.forDocument(e))?void 0:n.getState())??t.initialDocumentState());return o.useEffect(()=>{if(!i)return;const t=i.forDocument(e);return r(t.getState()),t.onStateChange(e=>{r(e)})},[i,e]),{state:s,provides:(null==i?void 0:i.forDocument(e))??null}},exports.useAnnotationCapability=u,exports.useAnnotationPlugin=d,Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-annotation"),o=require("preact/jsx-runtime"),n=require("preact"),i=require("preact/hooks"),r=require("@embedpdf/core/preact"),s=require("@embedpdf/models"),l=require("@embedpdf/plugin-interaction-manager/preact"),a=require("@embedpdf/plugin-selection/preact"),c=require("@embedpdf/utils/preact"),d={},u=n.createContext(null),g=n.createContext([]);function p({children:e}){const[t,n]=i.useState([]),r=i.useCallback(e=>(n(t=>{const o=new Set(e.map(e=>e.id));return[...t.filter(e=>!o.has(e.id)),...e]}),()=>n(t=>t.filter(t=>!e.some(e=>e.id===t.id)))),[]);return o.jsx(u.Provider,{value:r,children:o.jsx(g.Provider,{value:t,children:e})})}function h(){return i.useContext(g)}const v=()=>r.usePlugin(t.AnnotationPlugin.id),b=()=>r.useCapability(t.AnnotationPlugin.id);function x({scale:e,documentId:t,pageIndex:n,rotation:s,pageWidth:l,pageHeight:a,trackedAnnotation:d,children:u,isSelected:g,isMultiSelected:p=!1,isDraggable:h,isResizable:x,lockAspectRatio:f=!1,style:y={},vertexConfig:m,selectionMenu:j,outlineOffset:k=1,onDoubleClick:S,onSelect:I,zIndex:M=1,resizeUI:P,vertexUI:z,selectionOutlineColor:R="#007ACC",customAnnotationRenderer:A,groupSelectionMenu:C,annotationRenderers:w,...D}){const[E,B]=i.useState(d.object),{provides:T}=b(),{plugin:$}=v(),{canModifyAnnotations:L}=r.useDocumentPermissions(t),F=i.useRef(null),U=L&&h&&!p,W=L&&x&&!p,O=i.useMemo(()=>T?T.forDocument(t):null,[T,t]),H=E?{...d.object,...E}:d.object,N=(null==P?void 0:P.color)??"#007ACC",q=(null==z?void 0:z.color)??"#007ACC",G=(null==P?void 0:P.size)??12,V=(null==z?void 0:z.size)??12,K=i.useRef(null),Y=i.useCallback(e=>{var o;if(!(null==(o=e.transformData)?void 0:o.type)||p||!$)return;const{type:i,changes:r,metadata:s}=e.transformData,c=d.object.id,u={width:l,height:a};if("start"===e.state&&(K.current=d.object.rect,F.current=d.object,"move"===i?$.startDrag(t,{annotationIds:[c],pageSize:u}):"resize"===i&&$.startResize(t,{annotationIds:[c],pageSize:u,resizeHandle:(null==s?void 0:s.handle)??"se"})),r.rect&&K.current)if("move"===i){const e={x:r.rect.origin.x-K.current.origin.x,y:r.rect.origin.y-K.current.origin.y};$.updateDrag(t,e)}else"resize"===i&&$.updateResize(t,r.rect);if("vertex-edit"===i&&r.vertices&&m){const t=F.current??d.object,o=m.transformAnnotation(t,r.vertices),l=null==T?void 0:T.transformAnnotation(t,{type:i,changes:o,metadata:s});l&&(B(e=>({...e,...l})),"end"===e.state&&(null==O||O.updateAnnotation(n,c,l)))}"end"===e.state&&(K.current=null,F.current=null,"move"===i?$.commitDrag(t):"resize"===i&&$.commitResize(t))},[$,t,d.object,l,a,n,p,m,T,O]),{dragProps:Q,vertices:X,resize:Z}=c.useInteractionHandles({controller:{element:H.rect,vertices:null==m?void 0:m.extractVertices(H),constraints:{minWidth:10,minHeight:10,boundingBox:{width:l,height:a}},maintainAspectRatio:f,pageRotation:s,scale:e,enabled:g&&!p,onUpdate:Y},resizeUI:{handleSize:G,spacing:k,offsetMode:"outside",includeSides:!f,zIndex:M+1},vertexUI:{vertexSize:V,zIndex:M+2},includeVertices:!!m}),J=i.useMemo(()=>{if(L&&S)return S},[L,S]),_=c.useDoublePressProps(J);i.useEffect(()=>{B(d.object)},[d.object]),i.useEffect(()=>{if(!$)return;const e=d.object.id,o=o=>{var n;if(o.documentId!==t)return;const i=null==(n=o.previewPatches)?void 0:n[e];"update"===o.type&&i?B(e=>({...e,...i})):"cancel"===o.type&&B(d.object)},n=[$.onDragChange(o),$.onResizeChange(o)];return()=>n.forEach(e=>e())},[$,t,d.object]);const ee=g&&!p;return o.jsxs("div",{"data-no-interaction":!0,children:[o.jsxs("div",{...U&&g?Q:{},..._,style:{position:"absolute",left:H.rect.origin.x*e,top:H.rect.origin.y*e,width:H.rect.size.width*e,height:H.rect.size.height*e,outline:ee?`1px solid ${R}`:"none",outlineOffset:ee?`${k}px`:"0px",pointerEvents:g&&!p?"auto":"none",touchAction:"none",cursor:g&&U?"move":"default",zIndex:M,...y},...D,children:[(()=>{const t="function"==typeof u?u(H):u,o=null==A?void 0:A({annotation:H,children:t,isSelected:g,scale:e,rotation:s,pageWidth:l,pageHeight:a,pageIndex:n,onSelect:I});return null!=o?o:t})(),g&&W&&Z.map(({key:e,...t})=>(null==P?void 0:P.component)?P.component({key:e,...t,backgroundColor:N}):o.jsx("div",{...t,style:{...t.style,backgroundColor:N}},e)),g&&L&&!p&&X.map(({key:e,...t})=>(null==z?void 0:z.component)?z.component({key:e,...t,backgroundColor:q}):o.jsx("div",{...t,style:{...t.style,backgroundColor:q}},e))]}),j&&!p&&o.jsx(c.CounterRotate,{rect:{origin:{x:H.rect.origin.x*e,y:H.rect.origin.y*e},size:{width:H.rect.size.width*e,height:H.rect.size.height*e}},rotation:s,children:e=>j({...e,context:{type:"annotation",annotation:d,pageIndex:n},selected:g,placement:{suggestTop:!1}})})]})}function f({documentId:e,pageIndex:t,scale:n,rotation:l,pageWidth:a,pageHeight:d,selectedAnnotations:u,isDraggable:g,isResizable:p,resizeUI:h,selectionOutlineColor:b="#007ACC",outlineOffset:x=2,zIndex:f=100,groupSelectionMenu:y}){const{plugin:m}=v(),{canModifyAnnotations:j}=r.useDocumentPermissions(e),k=i.useRef(null),S=i.useRef(!1),I=i.useRef(!1),M=j&&g,P=j&&p,z=i.useMemo(()=>{const e=u.map(e=>e.object.rect);return s.boundingRectOrEmpty(e)},[u]),[R,A]=i.useState(z);i.useEffect(()=>{S.current||I.current||A(z)},[z]);const C=i.useCallback(t=>{var o,n;if(!(null==(o=t.transformData)?void 0:o.type))return;if(!m)return;const i=t.transformData.type,r="move"===i,s="resize"===i;if(r&&!M)return;"start"===t.state&&(k.current=z,r?(S.current=!0,m.startDrag(e,{annotationIds:u.map(e=>e.object.id),pageSize:{width:a,height:d}})):s&&(I.current=!0,m.startResize(e,{annotationIds:u.map(e=>e.object.id),pageSize:{width:a,height:d},resizeHandle:(null==(n=t.transformData.metadata)?void 0:n.handle)??"se"})));const l=k.current??z;if(r&&t.transformData.changes.rect){const o=t.transformData.changes.rect,n={x:o.origin.x-l.origin.x,y:o.origin.y-l.origin.y},i=m.updateDrag(e,n);A({...l,origin:{x:l.origin.x+i.x,y:l.origin.y+i.y}})}else if(s&&t.transformData.changes.rect){const o=t.transformData.changes.rect;m.updateResize(e,o),A(o)}"end"===t.state&&(k.current=null,r&&S.current?(S.current=!1,m.commitDrag(e)):s&&I.current&&(I.current=!1,m.commitResize(e)))},[m,e,a,d,z,M,u]),w=(null==h?void 0:h.color)??"#007ACC",D=(null==h?void 0:h.size)??12,{dragProps:E,resize:B}=c.useInteractionHandles({controller:{element:R,constraints:{minWidth:20,minHeight:20,boundingBox:{width:a,height:d}},maintainAspectRatio:!1,pageRotation:l,scale:n,enabled:!0,onUpdate:C},resizeUI:{handleSize:D,spacing:x,offsetMode:"outside",includeSides:!0,zIndex:f+1},vertexUI:{vertexSize:0,zIndex:f},includeVertices:!1});return u.length<2?null:o.jsxs("div",{"data-group-selection-box":!0,"data-no-interaction":!0,children:[o.jsx("div",{...M?E:{onPointerDown:e=>e.stopPropagation()},style:{position:"absolute",left:R.origin.x*n,top:R.origin.y*n,width:R.size.width*n,height:R.size.height*n,outline:`2px dashed ${b}`,outlineOffset:x-1,cursor:M?"move":"default",touchAction:"none",zIndex:f},children:P&&B.map(({key:e,...t})=>(null==h?void 0:h.component)?h.component({key:e,...t,backgroundColor:w}):o.jsx("div",{...t,style:{...t.style,backgroundColor:w}},e))}),y&&o.jsx(c.CounterRotate,{rect:{origin:{x:R.origin.x*n,y:R.origin.y*n},size:{width:R.size.width*n,height:R.size.height*n}},rotation:l,children:e=>y({...e,context:{type:"group",annotations:u,pageIndex:t},selected:!0,placement:{suggestTop:!1}})})]})}function y({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:s,style:l}){const a=e??"#FFFF00";return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:a,opacity:t,pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:void 0,...l}},n))})}function m({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:s,style:l}){const a=e??"#FFFF00",c=2*r;return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:c,background:a,opacity:t,pointerEvents:"none"}})},n))})}function j({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:s,style:l}){const a=e??"#FFFF00",c=2*r;return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:c,background:a,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},n))})}function k({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:s,style:l}){const a=2*r,c=6*r,d=`url("data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${c}" height="${2*a}" viewBox="0 0 ${c} ${2*a}">\n <path d="M0 ${a} Q ${c/4} 0 ${c/2} ${a} T ${c} ${a}"\n fill="none" stroke="${e??"#FFFF00"}" stroke-width="${a}" stroke-linecap="round"/>\n </svg>`)}")`;return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:2*a,backgroundImage:d,backgroundRepeat:"repeat-x",backgroundSize:`${c}px ${2*a}px`,opacity:t,pointerEvents:"none"}})},n))})}function S({isSelected:e,strokeColor:t,opacity:n=1,strokeWidth:r,inkList:s,rect:l,scale:a,onClick:c}){const d=t??"#000000",u=i.useMemo(()=>s.map(({points:e})=>{let t="";return e.forEach(({x:e,y:o},n)=>{const i=e-l.origin.x,r=o-l.origin.y;t+=(0===n?"M":"L")+i+" "+r+" "}),t.trim()}),[s,l]),g=l.size.width*a,p=l.size.height*a;return o.jsx("svg",{style:{position:"absolute",width:g,height:p,pointerEvents:"none",zIndex:2,overflow:"visible"},width:g,height:p,viewBox:`0 0 ${l.size.width} ${l.size.height}`,children:u.map((t,i)=>o.jsx("path",{d:t,fill:"none",opacity:n,onPointerDown:c,onTouchStart:c,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visibleStroke",stroke:d,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}},i))})}function I({isSelected:e,color:t="#000000",strokeColor:n,opacity:r=1,strokeWidth:l,strokeStyle:a=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:g}){const{width:p,height:h,x:v,y:b}=i.useMemo(()=>{const e=d.size.width,t=d.size.height;return{width:Math.max(e-l,0),height:Math.max(t-l,0),x:l/2,y:l/2}},[d,l]),x=(p+l)*u,f=(h+l)*u;return o.jsx("svg",{style:{position:"absolute",width:x,height:f,pointerEvents:"none",zIndex:2},width:x,height:f,viewBox:`0 0 ${p+l} ${h+l}`,children:o.jsx("rect",{x:v,y:b,width:p,height:h,fill:t,opacity:r,onPointerDown:g,onTouchStart:g,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"transparent"===t?"visibleStroke":"visible",stroke:n??t,strokeWidth:l,...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})})}function M({color:e="#000000",strokeColor:t,opacity:n=1,strokeWidth:r,strokeStyle:l=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:a,rect:c,scale:d,onClick:u,isSelected:g}){const{width:p,height:h,cx:v,cy:b,rx:x,ry:f}=i.useMemo(()=>{const e=c.size.width,t=c.size.height,o=Math.max(e-r,0),n=Math.max(t-r,0);return{width:e,height:t,cx:r/2+o/2,cy:r/2+n/2,rx:o/2,ry:n/2}},[c,r]),y=p*d,m=h*d;return o.jsx("svg",{style:{position:"absolute",width:y,height:m,pointerEvents:"none",zIndex:2},width:y,height:m,viewBox:`0 0 ${p} ${h}`,children:o.jsx("ellipse",{cx:v,cy:b,rx:x,ry:f,fill:e,opacity:n,onPointerDown:u,onTouchStart:u,style:{cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===e?"visibleStroke":"visible",stroke:t??e,strokeWidth:r,...l===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==a?void 0:a.join(",")}}})})}function P({color:e="transparent",opacity:n=1,strokeWidth:r,strokeColor:l="#000000",strokeStyle:a=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,linePoints:u,lineEndings:g,scale:p,onClick:h,isSelected:v}){const{x1:b,y1:x,x2:f,y2:y}=i.useMemo(()=>({x1:u.start.x-d.origin.x,y1:u.start.y-d.origin.y,x2:u.end.x-d.origin.x,y2:u.end.y-d.origin.y}),[u,d]),m=i.useMemo(()=>{const e=Math.atan2(y-x,f-b);return{start:t.patching.createEnding(null==g?void 0:g.start,r,e+Math.PI,b,x),end:t.patching.createEnding(null==g?void 0:g.end,r,e,f,y)}},[g,r,b,x,f,y]),j=d.size.width*p,k=d.size.height*p;return o.jsxs("svg",{style:{position:"absolute",width:j,height:k,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:k,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[o.jsx("line",{x1:b,y1:x,x2:f,y2:y,opacity:n,onPointerDown:h,onTouchStart:h,style:{cursor:v?"move":"pointer",pointerEvents:v?"none":"visibleStroke",stroke:l,strokeWidth:r,strokeLinecap:"butt",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),m.start&&o.jsx("path",{d:m.start.d,transform:m.start.transform,onPointerDown:h,onTouchStart:h,stroke:l,style:{cursor:v?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:v?"none":m.start.filled?"visible":"visibleStroke",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.start.filled?e:"none"}),m.end&&o.jsx("path",{d:m.end.d,transform:m.end.transform,stroke:l,onPointerDown:h,onTouchStart:h,style:{cursor:v?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:v?"none":m.end.filled?"visible":"visibleStroke",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.end.filled?e:"none"})]})}function z({rect:e,vertices:n,color:r="transparent",strokeColor:s="#000000",opacity:l=1,strokeWidth:a,scale:c,isSelected:d,onClick:u,lineEndings:g}){const p=i.useMemo(()=>n.map(({x:t,y:o})=>({x:t-e.origin.x,y:o-e.origin.y})),[n,e]),h=i.useMemo(()=>{if(!p.length)return"";const[e,...t]=p;return`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y} `).join("").trim()},[p]),v=i.useMemo(()=>{if(p.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),o=e(p[0],p[1]),n=e(p[p.length-2],p[p.length-1]);return{start:t.patching.createEnding(null==g?void 0:g.start,a,o+Math.PI,p[0].x,p[0].y),end:t.patching.createEnding(null==g?void 0:g.end,a,n,p[p.length-1].x,p[p.length-1].y)}},[p,g,a]),b=e.size.width*c,x=e.size.height*c;return o.jsxs("svg",{style:{position:"absolute",width:b,height:x,pointerEvents:"none",zIndex:2,overflow:"visible"},width:b,height:x,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[o.jsx("path",{d:h,onPointerDown:u,onTouchStart:u,opacity:l,style:{fill:"none",stroke:s??r,strokeWidth:a,cursor:d?"move":"pointer",pointerEvents:d?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"}}),v.start&&o.jsx("path",{d:v.start.d,transform:v.start.transform,stroke:s,fill:v.start.filled?r:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":v.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),v.end&&o.jsx("path",{d:v.end.d,transform:v.end.transform,stroke:s,fill:v.end.filled?r:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":v.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}})]})}function R({rect:e,vertices:t,color:n="transparent",strokeColor:r="#000000",opacity:l=1,strokeWidth:a,strokeStyle:c=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,scale:u,isSelected:g,onClick:p,currentVertex:h,handleSize:v=14}){const b=h?[...t,h]:t,x=i.useMemo(()=>b.map(({x:t,y:o})=>({x:t-e.origin.x,y:o-e.origin.y})),[b,e]),f=i.useMemo(()=>{if(!x.length)return"";const[e,...t]=x,o=!!h;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(o?"":" Z")).trim()},[x,h]),y=h&&t.length>0,m=e.size.width*u,j=e.size.height*u;return o.jsxs("svg",{style:{position:"absolute",width:m,height:j,pointerEvents:"none",zIndex:2,overflow:"visible"},width:m,height:j,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[o.jsx("path",{d:f,onPointerDown:p,onTouchStart:p,opacity:l,style:{fill:h?"none":n,stroke:r??n,strokeWidth:a,cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===n?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter",...c===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}),y&&t.length>1&&o.jsx("path",{d:`M ${x[x.length-1].x} ${x[x.length-1].y} L ${x[0].x} ${x[0].y}`,fill:"none",style:{stroke:r,strokeWidth:a,strokeDasharray:"4,4",opacity:.7}}),y&&t.length>=2&&o.jsx("rect",{x:x[0].x-v/u/2,y:x[0].y-v/u/2,width:v/u,height:v/u,fill:r,opacity:.4,stroke:r,strokeWidth:a/2})]})}function A({isSelected:e,isEditing:t,annotation:n,pageIndex:r,scale:l,onClick:a}){const c=i.useRef(null),{provides:u}=b(),[g,p]=i.useState(!1);i.useEffect(()=>{if(t&&c.current){const e=c.current;e.focus();const t=window.getSelection();if(t){const o=document.createRange();o.selectNodeContents(e),o.collapse(!1),t.removeAllRanges(),t.addRange(o)}}},[t]),i.useLayoutEffect(()=>{try{const e=navigator,t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1;p(t)}catch{p(!1)}},[]);const h=n.object.fontSize*l,v=g&&t&&h>0&&h<16,x=v?16:h,f=v?h/16:1,y=v?100/f:100;return o.jsx("div",{style:{position:"absolute",width:n.object.rect.size.width*l,height:n.object.rect.size.height*l,cursor:e&&!t?"move":"default",pointerEvents:e&&!t?"none":"auto",zIndex:2},onPointerDown:a,onTouchStart:a,children:o.jsx("span",{ref:c,onBlur:()=>{u&&c.current&&u.updateAnnotation(r,n.object.id,{contents:c.current.innerText})},tabIndex:0,style:{color:n.object.fontColor,fontSize:x,fontFamily:s.standardFontCss(n.object.fontFamily),textAlign:s.textAlignmentToCss(n.object.textAlign),flexDirection:"column",justifyContent:n.object.verticalAlign===s.PdfVerticalAlignment.Top?"flex-start":n.object.verticalAlign===s.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:n.object.color??n.object.backgroundColor,opacity:n.object.opacity,width:v?`${y}%`:"100%",height:v?`${y}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:t?"text":"pointer",outline:"none",transform:v?`scale(${f})`:void 0,transformOrigin:"top left"},contentEditable:t,...d,children:n.object.contents})})}function C({documentId:e,pageIndex:t,annotation:r,scaleFactor:l=1,style:a,...c}){const{provides:d}=b(),[u,g]=i.useState(null),p=i.useRef(null),{width:h,height:v}=r.rect.size;i.useEffect(()=>{if(d){const o=d.forDocument(e).renderAnnotation({pageIndex:t,annotation:r,options:{scaleFactor:l,dpr:window.devicePixelRatio}});return o.wait(e=>{const t=URL.createObjectURL(e);g(t),p.current=t},s.ignore),()=>{p.current?(URL.revokeObjectURL(p.current),p.current=null):o.abort({code:s.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,l,d,e,r.id,h,v]);return o.jsx(n.Fragment,{children:u&&o.jsx("img",{src:u,onLoad:()=>{p.current&&(URL.revokeObjectURL(p.current),p.current=null)},...c,style:{width:"100%",height:"100%",display:"block",...a||{}}})})}function w({isSelected:e,annotation:t,documentId:n,pageIndex:i,scale:r,onClick:s}){return o.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:e?"none":"auto",cursor:"pointer"},onPointerDown:s,onTouchStart:s,children:o.jsx(C,{documentId:n,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:r})})}function D({isSelected:e,strokeColor:t="#0000FF",strokeWidth:n=2,strokeStyle:r=s.PdfAnnotationBorderStyle.UNDERLINE,strokeDashArray:l,rect:a,scale:c,onClick:d,hasIRT:u=!1}){const{width:g,height:p}=i.useMemo(()=>({width:a.size.width,height:a.size.height}),[a]),h=g*c,v=p*c,b=i.useMemo(()=>{if(r===s.PdfAnnotationBorderStyle.DASHED)return(null==l?void 0:l.join(","))??`${3*n},${n}`},[r,l,n]),x=r===s.PdfAnnotationBorderStyle.UNDERLINE;return o.jsxs("svg",{style:{position:"absolute",width:h,height:v,pointerEvents:"none",zIndex:2},width:h,height:v,viewBox:`0 0 ${g} ${p}`,children:[o.jsx("rect",{x:0,y:0,width:g,height:p,fill:"transparent",onPointerDown:u?void 0:d,onTouchStart:u?void 0:d,style:{cursor:u?"default":e?"move":"pointer",pointerEvents:u||e?"none":"visible"}}),x?o.jsx("line",{x1:1,y1:p-1,x2:g-1,y2:p-1,stroke:t,strokeWidth:n,strokeDasharray:b,style:{pointerEvents:"none"}}):o.jsx("rect",{x:n/2,y:n/2,width:Math.max(g-n,0),height:Math.max(p-n,0),fill:"transparent",stroke:t,strokeWidth:n,strokeDasharray:b,style:{pointerEvents:"none"}})]})}function E(e){const{documentId:r,pageIndex:c,scale:d,pageWidth:u,pageHeight:g,selectionMenu:p}=e,{provides:h}=b(),{provides:v}=a.useSelectionCapability(),[C,E]=i.useState([]),{register:B}=l.usePointerHandlers({documentId:r,pageIndex:c}),[T,$]=i.useState([]),[L,F]=i.useState(null),U=i.useMemo(()=>h?h.forDocument(r):null,[h,r]),W=T.length>1;i.useEffect(()=>{if(U){const e=U.getState();return E(t.getAnnotationsByPageIndex(e,c)),$(t.getSelectedAnnotationIds(e)),U.onStateChange(e=>{E(t.getAnnotationsByPageIndex(e,c)),$(t.getSelectedAnnotationIds(e))})}},[U,c]);const O=i.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&U&&(U.deselectAnnotation(),F(null))}}),[U]),H=i.useCallback((e,t)=>{if(e.stopPropagation(),U&&v){v.clear();"metaKey"in e&&(e.metaKey||e.ctrlKey)?U.toggleSelection(c,t.object.id):U.selectAnnotation(c,t.object.id),t.object.id!==L&&F(null)}},[U,v,L,c]),N=i.useCallback((e,t)=>{if(e.stopPropagation(),U&&v){if(v.clear(),t.object.inReplyToId){const e=t.object.inReplyToId,o=C.find(t=>t.object.id===e);if(o)return void U.selectAnnotation(o.object.pageIndex,e)}U.selectAnnotation(c,t.object.id)}},[U,v,C,c]);i.useEffect(()=>B(O,{documentId:r}),[B,O]);const q=i.useMemo(()=>C.filter(e=>T.includes(e.object.id)),[C,T]),G=i.useMemo(()=>!(q.length<2)&&q.every(e=>{const o=null==U?void 0:U.findToolForAnnotation(e.object),n=t.resolveInteractionProp(null==o?void 0:o.interaction.isGroupDraggable,e.object,!0),i=t.resolveInteractionProp(null==o?void 0:o.interaction.isDraggable,e.object,!0);return void 0!==(null==o?void 0:o.interaction.isGroupDraggable)?n:i}),[q,U]),V=i.useMemo(()=>!(q.length<2)&&q.every(e=>{const o=null==U?void 0:U.findToolForAnnotation(e.object),n=t.resolveInteractionProp(null==o?void 0:o.interaction.isGroupResizable,e.object,!0),i=t.resolveInteractionProp(null==o?void 0:o.interaction.isResizable,e.object,!0);return void 0!==(null==o?void 0:o.interaction.isGroupResizable)?n:i}),[q,U]),K=i.useMemo(()=>{if(!U)return!1;const e=U.getSelectedAnnotations();return e.length>1&&e.every(e=>e.object.pageIndex===c)},[U,c,T]);return o.jsxs(o.Fragment,{children:[C.map(i=>{const l=T.includes(i.object.id),a=L===i.object.id,u=null==U?void 0:U.findToolForAnnotation(i.object);for(const n of e.annotationRenderers??[]){const r=n.tryRender(i,{isSelected:l,scale:d,pageIndex:c,onClick:e=>H(e,i)});if(r)return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:()=>r},i.object.id)}if(t.isInk(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(S,{...e,isSelected:l,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isSquare(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(I,{...e,isSelected:l,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isCircle(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(M,{...e,isSelected:l,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isUnderline(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),zIndex:0,style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(m,{...e,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isStrikeout(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),zIndex:0,style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(j,{...e,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isSquiggly(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),zIndex:0,style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(k,{...e,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isHighlight(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),zIndex:0,style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Multiply)},...e,children:e=>o.jsx(y,{...e,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isLine(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(P,{...e,isSelected:l,scale:d,onClick:e=>H(e,i)})})},i.object.id);if(t.isPolyline(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(z,{...e,isSelected:l,scale:d,onClick:e=>H(e,i)})})},i.object.id);if(t.isPolygon(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(R,{...e,isSelected:l,scale:d,onClick:e=>H(e,i)})})},i.object.id);if(t.isFreeText(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0)&&!a,isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},onDoubleClick:e=>{e.stopPropagation(),F(i.object.id)},...e,children:e=>o.jsx(A,{isSelected:l,isEditing:a,annotation:{...i,object:e},pageIndex:c,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isStamp(i))return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),selectionMenu:p,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(w,{isSelected:l,annotation:i,documentId:r,pageIndex:c,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isLink(i)){const t=!!i.object.inReplyToId;return o.jsx(x,{trackedAnnotation:i,isSelected:l,isMultiSelected:W,isDraggable:!1,isResizable:!1,lockAspectRatio:!1,selectionMenu:t?void 0:p,onSelect:e=>N(e,i),...e,children:e=>o.jsx(D,{...e,isSelected:l,scale:d,onClick:e=>N(e,i),hasIRT:t})},i.object.id)}return null}),K&&q.length>=2&&o.jsx(f,{documentId:r,pageIndex:c,scale:d,rotation:e.rotation,pageWidth:u,pageHeight:g,selectedAnnotations:q,isDraggable:G,isResizable:V,resizeUI:e.resizeUI,selectionOutlineColor:e.selectionOutlineColor,groupSelectionMenu:e.groupSelectionMenu})]})}function B({documentId:e,pageIndex:t,scale:n}){var r,l,c,d,u,g,p,h,v,x,f,S;const{provides:I}=a.useSelectionCapability(),{provides:M}=b(),[P,z]=i.useState([]),[R,A]=i.useState(null),[C,w]=i.useState(null);if(i.useEffect(()=>{if(I)return I.forDocument(e).onSelectionChange(()=>{z(I.forDocument(e).getHighlightRectsForPage(t)),A(I.forDocument(e).getBoundingRectForPage(t))})},[I,e,t]),i.useEffect(()=>{if(M)return w(M.forDocument(e).getActiveTool()),M.forDocument(e).onActiveToolChange(e=>w(e))},[M,e]),!R)return null;if(!C||!C.defaults)return null;switch(C.defaults.type){case s.PdfAnnotationSubtype.UNDERLINE:return o.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(r=C.defaults)?void 0:r.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(m,{strokeColor:null==(l=C.defaults)?void 0:l.strokeColor,opacity:null==(c=C.defaults)?void 0:c.opacity,segmentRects:P,scale:n})});case s.PdfAnnotationSubtype.HIGHLIGHT:return o.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(d=C.defaults)?void 0:d.blendMode)??s.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(y,{strokeColor:null==(u=C.defaults)?void 0:u.strokeColor,opacity:null==(g=C.defaults)?void 0:g.opacity,segmentRects:P,scale:n})});case s.PdfAnnotationSubtype.STRIKEOUT:return o.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(p=C.defaults)?void 0:p.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(j,{strokeColor:null==(h=C.defaults)?void 0:h.strokeColor,opacity:null==(v=C.defaults)?void 0:v.opacity,segmentRects:P,scale:n})});case s.PdfAnnotationSubtype.SQUIGGLY:return o.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(x=C.defaults)?void 0:x.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(k,{strokeColor:null==(f=C.defaults)?void 0:f.strokeColor,opacity:null==(S=C.defaults)?void 0:S.opacity,segmentRects:P,scale:n})});default:return null}}function T({preview:e,scale:t}){const{bounds:n}=e,i={position:"absolute",left:n.origin.x*t,top:n.origin.y*t,width:n.size.width*t,height:n.size.height*t,pointerEvents:"none",zIndex:10};return e.type===s.PdfAnnotationSubtype.CIRCLE?o.jsx("div",{style:i,children:o.jsx(M,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.SQUARE?o.jsx("div",{style:i,children:o.jsx(I,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.POLYGON?o.jsx("div",{style:i,children:o.jsx(R,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.POLYLINE?o.jsx("div",{style:i,children:o.jsx(z,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.LINE?o.jsx("div",{style:i,children:o.jsx(P,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.INK?o.jsx("div",{style:i,children:o.jsx(S,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.FREETEXT?o.jsx("div",{style:i,children:o.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})}):null}function $({documentId:e,pageIndex:t,scale:n}){const{plugin:r}=v(),[s,l]=i.useState(new Map),a=i.useRef(null),c=i.useRef(null),d=i.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!a.current)return;const o=a.current;o.accept=e,o.onchange=e=>{var n;const i=null==(n=e.target.files)?void 0:n[0];i&&(t(i),o.value="")},o.click()},processImage:({source:e,maxWidth:t,maxHeight:o,onComplete:n})=>{const i=c.current;if(!i||!i.getContext)return;const r=i.getContext("2d");if(!r)return;const s=new Image;s.crossOrigin="Anonymous",s.onload=()=>{let{naturalWidth:l,naturalHeight:a}=s;const c=t?t/l:1,d=o?o/a:1,u=Math.min(c,d,1),g=l*u,p=a*u;i.width=g,i.height=p,r.drawImage(s,0,0,g,p);const h=r.getImageData(0,0,g,p);"string"!=typeof e&&URL.revokeObjectURL(s.src),n({imageData:h,width:g,height:p})},s.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return i.useEffect(()=>{if(r)return r.registerPageHandlers(e,t,n,{services:d,onPreview:(e,t)=>{l(o=>{const n=new Map(o);return t?n.set(e,t):n.delete(e),n})}})},[e,t,n,r,d]),o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:a,type:"file",style:{display:"none"}}),o.jsx("canvas",{ref:c,style:{display:"none"}}),Array.from(s.entries()).map(([e,t])=>o.jsx(T,{preview:t,scale:n},e))]})}const L=e.createPluginPackage(t.AnnotationPluginPackage).addWrapper(p).build();exports.AnnotationLayer=function({style:e,documentId:t,pageIndex:n,scale:l,rotation:a,selectionMenu:c,groupSelectionMenu:d,resizeUI:u,vertexUI:g,selectionOutlineColor:p,customAnnotationRenderer:v,annotationRenderers:b,...x}){var f,y,m,j;const k=r.useDocumentState(t),S=null==(y=null==(f=null==k?void 0:k.document)?void 0:f.pages)?void 0:y[n],I=(null==(m=null==S?void 0:S.size)?void 0:m.width)??0,M=(null==(j=null==S?void 0:S.size)?void 0:j.height)??0,P=h(),z=i.useMemo(()=>{const e=[...P];for(const t of b??[]){const o=e.findIndex(e=>e.id===t.id);o>=0?e[o]=t:e.push(t)}return e},[P,b]),R=i.useMemo(()=>void 0!==l?l:(null==k?void 0:k.scale)??1,[l,null==k?void 0:k.scale]),A=i.useMemo(()=>void 0!==a?a:(null==k?void 0:k.rotation)??s.Rotation.Degree0,[a,null==k?void 0:k.rotation]);return o.jsxs("div",{style:{...e},...x,children:[o.jsx(E,{documentId:t,selectionMenu:c,groupSelectionMenu:d,pageIndex:n,scale:R,rotation:A,pageWidth:I,pageHeight:M,resizeUI:u,vertexUI:g,selectionOutlineColor:p,customAnnotationRenderer:v,annotationRenderers:z}),o.jsx(B,{documentId:t,pageIndex:n,scale:R}),o.jsx($,{documentId:t,pageIndex:n,scale:R})]})},exports.AnnotationPluginPackage=L,exports.AnnotationRendererProvider=p,exports.GroupSelectionBox=f,exports.createRenderer=function(e){return{id:e.id,tryRender:(t,o)=>e.matches(t.object)?e.render({...o,annotation:t}):null}},exports.useAnnotation=e=>{var o;const{provides:n}=b(),[r,s]=i.useState((null==(o=null==n?void 0:n.forDocument(e))?void 0:o.getState())??t.initialDocumentState());return i.useEffect(()=>{if(!n)return;const t=n.forDocument(e);return s(t.getState()),t.onStateChange(e=>{s(e)})},[n,e]),{state:r,provides:(null==n?void 0:n.forDocument(e))??null}},exports.useAnnotationCapability=b,exports.useAnnotationPlugin=v,exports.useRegisterRenderers=function(e){const t=i.useContext(u),o=i.useRef(e);i.useEffect(()=>{if(t)return t(o.current)},[t])},exports.useRegisteredRenderers=h,exports.useRendererRegistry=function(){return i.useContext(u)},Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|