@embedpdf/plugin-annotation 2.9.1 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3072 -2652
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +25 -6
- package/dist/lib/annotation-plugin.d.ts +15 -12
- package/dist/lib/handlers/index.d.ts +1 -0
- package/dist/lib/handlers/link.handler.d.ts +3 -0
- package/dist/lib/handlers/types.d.ts +9 -1
- package/dist/lib/helpers.d.ts +12 -5
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/reducer.d.ts +1 -1
- package/dist/lib/tools/default-tools.d.ts +147 -301
- package/dist/lib/tools/tools-utils.d.ts +448 -22
- package/dist/lib/tools/types.d.ts +35 -2
- package/dist/lib/types.d.ts +105 -24
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +192 -87
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +192 -87
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/annotation-navigation-handler.d.ts +1 -0
- package/dist/shared/components/annotations/link-locked.d.ts +3 -0
- package/dist/shared/components/annotations/stamp.d.ts +1 -1
- package/dist/shared/components/preview-renderer.d.ts +4 -3
- package/dist/shared/components/types.d.ts +21 -4
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/use-annotation.d.ts +2 -2
- package/dist/shared/hooks/use-ios-zoom-prevention.d.ts +16 -0
- package/dist/shared-preact/components/annotation-navigation-handler.d.ts +1 -0
- package/dist/shared-preact/components/annotations/link-locked.d.ts +3 -0
- package/dist/shared-preact/components/annotations/stamp.d.ts +1 -1
- package/dist/shared-preact/components/preview-renderer.d.ts +4 -3
- package/dist/shared-preact/components/types.d.ts +21 -4
- package/dist/shared-preact/hooks/index.d.ts +1 -0
- package/dist/shared-preact/hooks/use-annotation.d.ts +2 -2
- package/dist/shared-preact/hooks/use-ios-zoom-prevention.d.ts +15 -0
- package/dist/shared-react/components/annotation-navigation-handler.d.ts +1 -0
- package/dist/shared-react/components/annotations/link-locked.d.ts +3 -0
- package/dist/shared-react/components/annotations/stamp.d.ts +1 -1
- package/dist/shared-react/components/preview-renderer.d.ts +4 -3
- package/dist/shared-react/components/types.d.ts +21 -4
- package/dist/shared-react/hooks/index.d.ts +1 -0
- package/dist/shared-react/hooks/use-annotation.d.ts +2 -2
- package/dist/shared-react/hooks/use-ios-zoom-prevention.d.ts +16 -0
- package/dist/svelte/components/AnnotationNavigationHandler.svelte.d.ts +3 -0
- package/dist/svelte/components/PreviewRenderer.svelte.d.ts +3 -2
- package/dist/svelte/components/annotations/LinkLockedMode.svelte.d.ts +5 -0
- package/dist/svelte/components/annotations/LinkPreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/Stamp.svelte.d.ts +1 -1
- package/dist/svelte/context/renderer-registry.svelte.d.ts +1 -1
- package/dist/svelte/context/types.d.ts +20 -3
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-annotation.svelte.d.ts +1 -1
- package/dist/svelte/hooks/use-ios-zoom-prevention.svelte.d.ts +6 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +401 -228
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/annotation-navigation-handler.vue.d.ts +3 -0
- package/dist/vue/components/annotations/link-locked.vue.d.ts +5 -0
- package/dist/vue/components/annotations/link-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/stamp.vue.d.ts +2 -2
- package/dist/vue/components/preview-renderer.vue.d.ts +3 -2
- package/dist/vue/context/renderer-registry.d.ts +1 -1
- package/dist/vue/context/types.d.ts +20 -3
- package/dist/vue/hooks/index.d.ts +1 -0
- package/dist/vue/hooks/use-annotation.d.ts +24 -2
- package/dist/vue/hooks/use-ios-zoom-prevention.d.ts +7 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +402 -262
- package/dist/vue/index.js.map +1 -1
- package/package.json +12 -10
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BasePluginConfig, EventHook } from '@embedpdf/core';
|
|
2
|
-
import { AnnotationCreateContext, AnnotationAppearanceMap, PdfAnnotationObject,
|
|
3
|
-
import { AnnotationTool } from './tools/types';
|
|
2
|
+
import { AnnotationCreateContext, AnnotationAppearanceMap, PdfAnnotationObject, PdfDestinationObject, PdfErrorReason, PdfLinkTarget, PdfRenderPageAnnotationOptions, PdfTextAnnoObject, Position, Rect, Size, Task } from '@embedpdf/models';
|
|
3
|
+
import { AnnotationTool, AnnotationToolMap, ToolById, ToolId } from './tools/types';
|
|
4
4
|
/**
|
|
5
5
|
* Metadata attached to annotation history commands for filtering/purging.
|
|
6
6
|
* Used by the history plugin's purgeByMetadata method to identify commands
|
|
@@ -79,6 +79,32 @@ export interface RenderAnnotationOptions {
|
|
|
79
79
|
annotation: PdfAnnotationObject;
|
|
80
80
|
options?: PdfRenderPageAnnotationOptions;
|
|
81
81
|
}
|
|
82
|
+
export declare enum LockModeType {
|
|
83
|
+
None = "none",
|
|
84
|
+
All = "all",
|
|
85
|
+
Include = "include",
|
|
86
|
+
Exclude = "exclude"
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Controls which annotation categories are locked from UI interaction (selection, drag, resize).
|
|
90
|
+
* Locked annotations let clicks pass through to layers below (e.g. form-filling).
|
|
91
|
+
*
|
|
92
|
+
* - `{ type: LockModeType.None }` -- nothing locked (default, full interaction)
|
|
93
|
+
* - `{ type: LockModeType.All }` -- everything locked
|
|
94
|
+
* - `{ type: LockModeType.Include, categories: [...] }` -- only listed categories are locked
|
|
95
|
+
* - `{ type: LockModeType.Exclude, categories: [...] }` -- everything locked except listed categories
|
|
96
|
+
*/
|
|
97
|
+
export type LockMode = {
|
|
98
|
+
type: LockModeType.None;
|
|
99
|
+
} | {
|
|
100
|
+
type: LockModeType.All;
|
|
101
|
+
} | {
|
|
102
|
+
type: LockModeType.Include;
|
|
103
|
+
categories: string[];
|
|
104
|
+
} | {
|
|
105
|
+
type: LockModeType.Exclude;
|
|
106
|
+
categories: string[];
|
|
107
|
+
};
|
|
82
108
|
export interface AnnotationDocumentState {
|
|
83
109
|
pages: Record<number, string[]>;
|
|
84
110
|
byUid: Record<string, TrackedAnnotation>;
|
|
@@ -92,6 +118,7 @@ export interface AnnotationDocumentState {
|
|
|
92
118
|
selectedUid: string | null;
|
|
93
119
|
activeToolId: string | null;
|
|
94
120
|
hasPendingChanges: boolean;
|
|
121
|
+
locked: LockMode;
|
|
95
122
|
}
|
|
96
123
|
export interface AnnotationState {
|
|
97
124
|
documents: Record<string, AnnotationDocumentState>;
|
|
@@ -124,8 +151,12 @@ export interface AnnotationPluginConfig extends BasePluginConfig {
|
|
|
124
151
|
deactivateToolAfterCreate?: boolean;
|
|
125
152
|
/** When true (default false), select the annotation immediately after creation. */
|
|
126
153
|
selectAfterCreate?: boolean;
|
|
154
|
+
/** Initial lock mode for new documents. Defaults to `{ type: LockModeType.None }` (nothing locked). */
|
|
155
|
+
locked?: LockMode;
|
|
127
156
|
/** When true (default false), automatically enter edit mode after creating an annotation. */
|
|
128
157
|
editAfterCreate?: boolean;
|
|
158
|
+
/** When true (default), the LinkLockedMode component auto-opens URI links via window.open. Set to false to handle URI navigation yourself via onNavigate. */
|
|
159
|
+
autoOpenLinks?: boolean;
|
|
129
160
|
}
|
|
130
161
|
/**
|
|
131
162
|
* Options for transforming an annotation
|
|
@@ -154,10 +185,6 @@ export interface TransformOptions<T extends PdfAnnotationObject = PdfAnnotationO
|
|
|
154
185
|
[key: string]: any;
|
|
155
186
|
};
|
|
156
187
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Function type for custom patch functions
|
|
159
|
-
*/
|
|
160
|
-
export type PatchFunction<T extends PdfAnnotationObject> = (original: T, context: TransformOptions<T>) => Partial<T>;
|
|
161
188
|
export type ImportAnnotationItem<T extends PdfAnnotationObject = PdfAnnotationObject> = {
|
|
162
189
|
annotation: T;
|
|
163
190
|
ctx?: AnnotationCreateContext<T>;
|
|
@@ -177,7 +204,25 @@ export interface AnnotationActiveToolChangeEvent {
|
|
|
177
204
|
* - 'disabled': No valid grouping action (0-1 annotations selected)
|
|
178
205
|
*/
|
|
179
206
|
export type GroupingAction = 'group' | 'ungroup' | 'disabled';
|
|
180
|
-
|
|
207
|
+
type ToolUnion<TTools extends AnnotationToolMap> = TTools[ToolId<TTools>] & AnnotationTool;
|
|
208
|
+
type ToolEntry<TTools extends AnnotationToolMap, TId extends ToolId<TTools>> = ToolById<TTools, TId> & AnnotationTool;
|
|
209
|
+
export type NavigateTargetResult = {
|
|
210
|
+
outcome: 'navigated';
|
|
211
|
+
} | {
|
|
212
|
+
outcome: 'uri';
|
|
213
|
+
uri: string;
|
|
214
|
+
} | {
|
|
215
|
+
outcome: 'destination';
|
|
216
|
+
destination: PdfDestinationObject;
|
|
217
|
+
} | {
|
|
218
|
+
outcome: 'unsupported';
|
|
219
|
+
};
|
|
220
|
+
export interface NavigateEvent {
|
|
221
|
+
documentId: string;
|
|
222
|
+
result: NavigateTargetResult;
|
|
223
|
+
target: PdfLinkTarget;
|
|
224
|
+
}
|
|
225
|
+
export interface AnnotationScope<TTools extends AnnotationToolMap = AnnotationToolMap> {
|
|
181
226
|
getState(): AnnotationDocumentState;
|
|
182
227
|
getPageAnnotations(options: GetPageAnnotationsOptions): Task<PdfAnnotationObject[], PdfErrorReason>;
|
|
183
228
|
/** @deprecated Use getSelectedAnnotations() for multi-select support. Returns first selected or null. */
|
|
@@ -199,9 +244,10 @@ export interface AnnotationScope {
|
|
|
199
244
|
setSelection(ids: string[]): void;
|
|
200
245
|
/** Clear all selection */
|
|
201
246
|
deselectAnnotation(): void;
|
|
202
|
-
getActiveTool():
|
|
247
|
+
getActiveTool(): ToolUnion<TTools> | null;
|
|
248
|
+
setActiveTool<TId extends ToolId<TTools>>(toolId: TId | null): void;
|
|
203
249
|
setActiveTool(toolId: string | null): void;
|
|
204
|
-
findToolForAnnotation(annotation: PdfAnnotationObject):
|
|
250
|
+
findToolForAnnotation(annotation: PdfAnnotationObject): ToolUnion<TTools> | null;
|
|
205
251
|
importAnnotations(items: ImportAnnotationItem<PdfAnnotationObject>[]): void;
|
|
206
252
|
createAnnotation<A extends PdfAnnotationObject>(pageIndex: number, annotation: A, context?: AnnotationCreateContext<A>): void;
|
|
207
253
|
updateAnnotation(pageIndex: number, annotationId: string, patch: Partial<PdfAnnotationObject>): void;
|
|
@@ -243,11 +289,26 @@ export interface AnnotationScope {
|
|
|
243
289
|
isInGroup(annotationId: string): boolean;
|
|
244
290
|
/** Get the available grouping action for the current selection */
|
|
245
291
|
getGroupingAction(): GroupingAction;
|
|
292
|
+
/** Set which annotation categories are locked from UI interaction */
|
|
293
|
+
setLocked(mode: LockMode): void;
|
|
294
|
+
/** Get the current lock mode for this document */
|
|
295
|
+
getLocked(): LockMode;
|
|
296
|
+
/** Check if a specific annotation is locked (category-based or per-annotation flag) */
|
|
297
|
+
isAnnotationLocked(annotation: PdfAnnotationObject): boolean;
|
|
298
|
+
/** Check if a single category is locked under the current mode */
|
|
299
|
+
isCategoryLocked(category: string): boolean;
|
|
300
|
+
/** Check if a tool (by ID) is locked under the current mode (resolves tool categories) */
|
|
301
|
+
isToolLocked(toolId: string): boolean;
|
|
302
|
+
/** Update annotation object state without marking dirty or triggering commits. Used by the form plugin to sync PDFium state to the UI. */
|
|
303
|
+
syncAnnotationObject(id: string, patch: Partial<PdfAnnotationObject>): void;
|
|
304
|
+
/** Navigate to a link target. Returns a result indicating whether the plugin handled it or the caller should open a URI. */
|
|
305
|
+
navigateTarget(target: PdfLinkTarget): Task<NavigateTargetResult, PdfErrorReason>;
|
|
246
306
|
onStateChange: EventHook<AnnotationDocumentState>;
|
|
247
307
|
onAnnotationEvent: EventHook<AnnotationEvent>;
|
|
248
|
-
onActiveToolChange: EventHook<
|
|
308
|
+
onActiveToolChange: EventHook<ToolUnion<TTools> | null>;
|
|
309
|
+
onNavigate: EventHook<NavigateEvent>;
|
|
249
310
|
}
|
|
250
|
-
export interface AnnotationCapability {
|
|
311
|
+
export interface AnnotationCapability<TTools extends AnnotationToolMap = AnnotationToolMap> {
|
|
251
312
|
getState: () => AnnotationDocumentState;
|
|
252
313
|
getPageAnnotations: (options: GetPageAnnotationsOptions) => Task<PdfAnnotationObject[], PdfErrorReason>;
|
|
253
314
|
/** @deprecated Use getSelectedAnnotations() for multi-select support. Returns first selected or null. */
|
|
@@ -308,14 +369,37 @@ export interface AnnotationCapability {
|
|
|
308
369
|
getGroupMembers: (annotationId: string, documentId?: string) => TrackedAnnotation<PdfAnnotationObject>[];
|
|
309
370
|
/** Check if an annotation is part of a group */
|
|
310
371
|
isInGroup: (annotationId: string, documentId?: string) => boolean;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
372
|
+
/** Set which annotation categories are locked from UI interaction */
|
|
373
|
+
setLocked: (mode: LockMode, documentId?: string) => void;
|
|
374
|
+
/** Get the current lock mode */
|
|
375
|
+
getLocked: (documentId?: string) => LockMode;
|
|
376
|
+
/** Check if a specific annotation is locked (category-based or per-annotation flag) */
|
|
377
|
+
isAnnotationLocked: (annotation: PdfAnnotationObject, documentId?: string) => boolean;
|
|
378
|
+
/** Check if a single category is locked under the current mode */
|
|
379
|
+
isCategoryLocked: (category: string, documentId?: string) => boolean;
|
|
380
|
+
/** Check if a tool (by ID) is locked under the current mode (resolves tool categories) */
|
|
381
|
+
isToolLocked: (toolId: string, documentId?: string) => boolean;
|
|
382
|
+
/** Update annotation object state without marking dirty or triggering commits. Used by the form plugin to sync PDFium state to the UI. */
|
|
383
|
+
syncAnnotationObject: (id: string, patch: Partial<PdfAnnotationObject>, documentId?: string) => void;
|
|
384
|
+
/** Navigate to a link target. Returns a result indicating whether the plugin handled it or the caller should open a URI. */
|
|
385
|
+
navigateTarget: (target: PdfLinkTarget, documentId?: string) => Task<NavigateTargetResult, PdfErrorReason>;
|
|
386
|
+
forDocument: (documentId: string) => AnnotationScope<TTools>;
|
|
387
|
+
getActiveTool: () => ToolUnion<TTools> | null;
|
|
388
|
+
setActiveTool: {
|
|
389
|
+
<TId extends ToolId<TTools>>(toolId: TId | null): void;
|
|
390
|
+
(toolId: string | null): void;
|
|
391
|
+
};
|
|
392
|
+
getTools: () => Array<ToolUnion<TTools>>;
|
|
393
|
+
getTool: {
|
|
394
|
+
<TId extends ToolId<TTools>>(toolId: TId): ToolEntry<TTools, TId> | undefined;
|
|
395
|
+
(toolId: string): AnnotationTool | undefined;
|
|
396
|
+
};
|
|
397
|
+
addTool: <T extends AnnotationTool<any> = AnnotationTool<any>>(tool: T) => void;
|
|
398
|
+
findToolForAnnotation: (annotation: PdfAnnotationObject) => ToolUnion<TTools> | null;
|
|
399
|
+
setToolDefaults: {
|
|
400
|
+
<TId extends ToolId<TTools>>(toolId: TId, patch: Partial<ToolById<TTools, TId>['defaults']>): void;
|
|
401
|
+
(toolId: string, patch: Partial<PdfAnnotationObject> & Record<string, unknown>): void;
|
|
402
|
+
};
|
|
319
403
|
getColorPresets: () => string[];
|
|
320
404
|
addColorPreset: (color: string) => void;
|
|
321
405
|
/**
|
|
@@ -323,15 +407,11 @@ export interface AnnotationCapability {
|
|
|
323
407
|
* This applies annotation-specific logic to ensure consistency.
|
|
324
408
|
*/
|
|
325
409
|
transformAnnotation: <T extends PdfAnnotationObject>(annotation: T, options: TransformOptions<T>) => Partial<T>;
|
|
326
|
-
/**
|
|
327
|
-
* Register a custom patch function for a specific annotation type.
|
|
328
|
-
* This allows extending the transformation logic for custom annotations.
|
|
329
|
-
*/
|
|
330
|
-
registerPatchFunction: <T extends PdfAnnotationObject>(type: PdfAnnotationSubtype, patchFn: PatchFunction<T>) => void;
|
|
331
410
|
onStateChange: EventHook<AnnotationStateChangeEvent>;
|
|
332
411
|
onActiveToolChange: EventHook<AnnotationActiveToolChangeEvent>;
|
|
333
412
|
onAnnotationEvent: EventHook<AnnotationEvent>;
|
|
334
413
|
onToolsChange: EventHook<AnnotationToolsChangeEvent>;
|
|
414
|
+
onNavigate: EventHook<NavigateEvent>;
|
|
335
415
|
}
|
|
336
416
|
export interface GetPageAnnotationsOptions {
|
|
337
417
|
pageIndex: number;
|
|
@@ -523,3 +603,4 @@ export interface UnifiedRotateEvent {
|
|
|
523
603
|
state: UnifiedRotateState;
|
|
524
604
|
previewPatches: Record<string, Partial<PdfAnnotationObject>>;
|
|
525
605
|
}
|
|
606
|
+
export {};
|
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"),t=require("@embedpdf/plugin-annotation"),n=require("preact/jsx-runtime"),o=require("preact"),i=require("preact/hooks"),r=require("preact/compat"),s=require("@embedpdf/core/preact"),a=require("@embedpdf/models"),l=require("@embedpdf/plugin-interaction-manager/preact"),c=require("@embedpdf/plugin-selection/preact"),d=require("@embedpdf/utils/preact"),u=require("@embedpdf/utils"),p={},h=o.createContext(null),g=o.createContext([]);function v({children:e}){const[t,o]=i.useState([]),r=i.useCallback(e=>(o(t=>{const n=new Set(e.map(e=>e.id));return[...t.filter(e=>!n.has(e.id)),...e]}),()=>o(t=>t.filter(t=>!e.some(e=>e.id===t.id)))),[]);return n.jsx(h.Provider,{value:r,children:n.jsx(g.Provider,{value:t,children:e})})}function y(){return i.useContext(g)}const f=()=>s.usePlugin(t.AnnotationPlugin.id),x=()=>s.useCapability(t.AnnotationPlugin.id);function b({appearance:e,style:t}){const[o,r]=i.useState(null),s=i.useRef(null);i.useEffect(()=>{const t=URL.createObjectURL(e.data);return r(t),s.current=t,()=>{s.current&&(URL.revokeObjectURL(s.current),s.current=null)}},[e.data]);return o?n.jsx("img",{src:o,onLoad:()=>{s.current&&(URL.revokeObjectURL(s.current),s.current=null)},style:{position:"absolute",width:"100%",height:"100%",display:"block",pointerEvents:"none",userSelect:"none",...t}}):null}function m({scale:e,documentId:t,pageIndex:o,rotation:l,pageWidth:c,pageHeight:p,trackedAnnotation:h,children:g,isSelected:v,isEditing:y=!1,isMultiSelected:m=!1,isDraggable:k,isResizable:j,isRotatable:S=!0,lockAspectRatio:C=!1,style:A={},blendMode:w,vertexConfig:I,selectionMenu:R,outlineOffset:z=1,onDoubleClick:D,onSelect:P,appearance:E,zIndex:M=1,resizeUI:L,vertexUI:$,rotationUI:O,selectionOutlineColor:F,selectionOutline:B,customAnnotationRenderer:W,groupSelectionMenu:U,groupSelectionOutline:T,annotationRenderers:H,...N}){var G,q,Y;const[V,X]=i.useState(h.object),[K,Q]=i.useState(null),[Z,J]=i.useState(null),[_,ee]=i.useState(!1),[te,ne]=i.useState(!1),{provides:oe}=x(),{plugin:ie}=f(),{canModifyAnnotations:re}=s.useDocumentPermissions(t),se=i.useRef(null),ae=re&&k&&!m,le=re&&j&&!m,ce=re&&S&&!m,de=i.useMemo(()=>oe?oe.forDocument(t):null,[oe,t]),ue=V?{...h.object,...V}:h.object,pe=h.object.flags??[],he=pe.includes("noZoom"),ge=pe.includes("noRotate"),ve=he?1:e,ye=ge?0:l,fe=(null==L?void 0:L.color)??"#007ACC",xe=(null==$?void 0:$.color)??"#007ACC",be=(null==O?void 0:O.color)??"white",me=(null==O?void 0:O.connectorColor)??"#007ACC",ke=(null==L?void 0:L.size)??12,je=(null==$?void 0:$.size)??12,Se=(null==O?void 0:O.size)??32,Ce=null==O?void 0:O.margin,Ae=(null==O?void 0:O.iconColor)??"#007ACC",we=(null==O?void 0:O.showConnector)??!1,Ie=(null==(G=null==O?void 0:O.border)?void 0:G.color)??"#007ACC",Re=(null==(q=null==O?void 0:O.border)?void 0:q.width)??1,ze=(null==(Y=null==O?void 0:O.border)?void 0:Y.style)??"solid",De=(null==B?void 0:B.color)??F??"#007ACC",Pe=(null==B?void 0:B.style)??"solid",Ee=(null==B?void 0:B.width)??1,Me=(null==B?void 0:B.offset)??z??1,Le=K??ue.rotation??0,$e=K??ue.rotation??0,Oe=Number.isFinite($e)?Math.round(10*$e)/10:0,Fe=null!==K,Be=i.useRef(null),We=i.useCallback(e=>{var n;if(!(null==(n=e.transformData)?void 0:n.type)||m||!ie)return;const{type:i,changes:r,metadata:s}=e.transformData,a=h.object.id,l={width:c,height:p};if("start"===e.state&&(Be.current=h.object.unrotatedRect??h.object.rect,se.current=h.object,"resize"!==i&&"vertex-edit"!==i||ne(!0),"move"===i?ie.startDrag(t,{annotationIds:[a],pageSize:l}):"resize"===i&&ie.startResize(t,{annotationIds:[a],pageSize:l,resizeHandle:(null==s?void 0:s.handle)??"se"})),r.rect&&Be.current)if("move"===i){const e={x:r.rect.origin.x-Be.current.origin.x,y:r.rect.origin.y-Be.current.origin.y};ie.updateDrag(t,e)}else"resize"===i&&ie.updateResize(t,r.rect);if("vertex-edit"===i&&r.vertices&&I){const t=se.current??h.object,n=I.transformAnnotation(t,r.vertices),l=null==oe?void 0:oe.transformAnnotation(t,{type:i,changes:n,metadata:s});l&&(X(e=>({...e,...l})),"end"===e.state&&(null==de||de.updateAnnotation(o,a,l)))}if("rotate"===i){const n=(null==s?void 0:s.rotationAngle)??Le,o=null==s?void 0:s.cursorPosition;return o&&J({x:o.clientX,y:o.clientY}),void("start"===e.state?(Q(n),ie.startRotation(t,{annotationIds:[a],cursorAngle:n,rotationCenter:null==s?void 0:s.rotationCenter})):"move"===e.state?(Q(n),ie.updateRotation(t,n,null==s?void 0:s.rotationDelta)):"end"===e.state&&(Q(null),J(null),ie.commitRotation(t)))}"end"===e.state&&(Be.current=null,se.current=null,ne(!1),"move"===i?ie.commitDrag(t):"resize"===i&&ie.commitResize(t))},[ie,t,h.object,c,p,o,m,I,oe,de,Le]),Ue=ue.unrotatedRect,Te=Ue??ue.rect,He=Ue&&0!==Le?a.inferRotationCenterFromRects(Te,ue.rect,Le):void 0,Ne=Te,{dragProps:Ge,vertices:qe,resize:Ye,rotation:Ve}=d.useInteractionHandles({controller:{element:Ne,vertices:null==I?void 0:I.extractVertices(ue),constraints:{minWidth:10,minHeight:10,boundingBox:{width:c,height:p}},maintainAspectRatio:C,pageRotation:l,annotationRotation:Le,rotationCenter:He,rotationElement:ue.rect,scale:e,enabled:v&&!m,onUpdate:We},resizeUI:{handleSize:ke,spacing:Me,offsetMode:"outside",includeSides:!C,zIndex:M+1},vertexUI:{vertexSize:je,zIndex:M+2},rotationUI:{handleSize:Se,margin:Ce,zIndex:M+3,showConnector:we},includeVertices:!!I,includeRotation:ce,currentRotation:Le}),Xe=i.useMemo(()=>{if(re&&D)return D},[re,D]),Ke=d.useDoublePressProps(Xe);i.useEffect(()=>{X(h.object)},[h.object]),i.useEffect(()=>{if(!ie)return;const e=h.object.id,n=n=>{var o;if(n.documentId!==t)return;"end"!==n.type&&"cancel"!==n.type||Q(null);const i=null==(o=n.previewPatches)?void 0:o[e];"update"===n.type&&i?X(e=>({...e,...i})):"cancel"===n.type&&X(h.object)},o=[ie.onDragChange(n),ie.onResizeChange(n),ie.onRotateChange(n)];return()=>o.forEach(e=>e())},[ie,t,h.object]);const Qe=v&&!m,Ze=ue.rect.size.width*ve,Je=ue.rect.size.height*ve,_e=Te.size.width*ve,et=Te.size.height*ve,tt=Boolean(Ue)&&0!==Le,nt=tt?(Te.origin.x-ue.rect.origin.x)*ve:(Ze-_e)/2,ot=tt?(Te.origin.y-ue.rect.origin.y)*ve:(Je-et)/2,it=tt&&He?`${(He.x-Te.origin.x)*ve}px ${(He.y-Te.origin.y)*ve}px`:"center center",rt=He?(He.x-ue.rect.origin.x)*ve:Ze/2,st=He?(He.y-ue.rect.origin.y)*ve:Je/2,at=Math.max(300,Math.max(Ze,Je)+80),lt=ge?u.getCounterRotation({origin:{x:0,y:0},size:{width:Ze,height:Je}},l):null,ct=i.useMemo(()=>Ue?{...ue,rect:Ue}:ue,[ue,Ue]),dt=!(!(null==E?void 0:E.normal)||te||y||h.dictMode),ut={position:"absolute",left:ue.rect.origin.x*e,top:ue.rect.origin.y*e,width:lt?lt.width:Ze,height:lt?lt.height:Je,pointerEvents:"none",zIndex:M,...lt&&{transform:lt.matrix,transformOrigin:"0 0"}},pt={position:"absolute",left:nt,top:ot,width:_e,height:et,transform:0!==Le?`rotate(${Le}deg)`:void 0,transformOrigin:it};return n.jsxs("div",{"data-no-interaction":!0,children:[n.jsx("div",{style:{...ut,...w&&{mixBlendMode:w},...A},children:n.jsxs("div",{style:{...pt,pointerEvents:y?"auto":"none"},children:[(()=>{const t="function"==typeof g?g(ct,{appearanceActive:dt}):g;return(null==W?void 0:W({annotation:ct,children:t,isSelected:v,scale:e,rotation:l,pageWidth:c,pageHeight:p,pageIndex:o,onSelect:P}))??t})(),(null==E?void 0:E.normal)&&n.jsx(b,{appearance:E.normal,style:{display:dt?"block":"none"}})]})}),n.jsxs("div",{style:ut,...N,children:[Fe&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:rt-at/2,top:st,width:at,height:1,backgroundColor:me,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:rt,top:st-at/2,width:1,height:at,backgroundColor:me,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:rt-at/2,top:st,width:at,height:1,transformOrigin:"center center",transform:`rotate(${Le}deg)`,backgroundColor:me,opacity:.8,pointerEvents:"none"}})]}),v&&ce&&Ve&&((null==O?void 0:O.component)?n.jsx("div",{onPointerEnter:()=>ee(!0),onPointerLeave:()=>{ee(!1),J(null)},onPointerMove:e=>{Fe||J({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:O.component({...Ve.handle,backgroundColor:be,iconColor:Ae,connectorStyle:{...Ve.connector.style,backgroundColor:me,opacity:Fe?0:1},showConnector:we,opacity:Fe?0:1,border:{color:Ie,width:Re,style:ze}})}):n.jsxs("div",{onPointerEnter:()=>ee(!0),onPointerLeave:()=>{ee(!1),J(null)},onPointerMove:e=>{Fe||J({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[we&&n.jsx("div",{style:{...Ve.connector.style,backgroundColor:me,opacity:Fe?0:1}}),n.jsx("div",{...Ve.handle,style:{...Ve.handle.style,backgroundColor:be,border:`${Re}px ${ze} ${Ie}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:Fe?0:1},children:n.jsxs("svg",{width:Math.round(.6*Se),height:Math.round(.6*Se),viewBox:"0 0 24 24",fill:"none",stroke:Ae,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),n.jsx("path",{d:"M21 3v5h-5"})]})})]})),n.jsxs("div",{...ae&&v?Ge:{},...Ke,style:{...pt,outline:Qe?`${Ee}px ${Pe} ${De}`:"none",outlineOffset:Qe?`${Me}px`:"0px",pointerEvents:!v||m||y?"none":"auto",touchAction:"none",cursor:v&&ae?"move":"default"},children:[v&&le&&!Fe&&Ye.map(({key:e,...t})=>(null==L?void 0:L.component)?L.component({key:e,...t,backgroundColor:fe}):n.jsx("div",{...t,style:{...t.style,backgroundColor:fe}},e)),v&&re&&!m&&!Fe&&qe.map(({key:e,...t})=>(null==$?void 0:$.component)?$.component({key:e,...t,backgroundColor:xe}):n.jsx("div",{...t,style:{...t.style,backgroundColor:xe}},e))]})]}),R&&!m&&!Fe&&n.jsx(d.CounterRotate,{rect:{origin:{x:ue.rect.origin.x*e,y:ue.rect.origin.y*e},size:{width:ue.rect.size.width*ve,height:ue.rect.size.height*ve}},rotation:l,children:e=>{const t=((Le+90*ye)%360+360)%360;return R({...e,context:{type:"annotation",annotation:h,pageIndex:o},selected:v,placement:{suggestTop:ce&&t>90&&t<270}})}}),(Fe||_)&&Z&&r.createPortal(n.jsxs("div",{style:{position:"fixed",left:Z.x+16,top:Z.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[Oe.toFixed(0),"°"]}),document.body)]})}function k(e,t,n,o,i){switch(i){case 1:return{x:t,y:o-e};case 2:return{x:n-e,y:o-t};case 3:return{x:n-t,y:e};default:return{x:e,y:t}}}function j(e,t,n){const o=e.object.flags??[],i=o.includes("noZoom"),r=o.includes("noRotate"),s=e.object.rect.origin.x*t,a=e.object.rect.origin.y*t,l=e.object.rect.size.width*(i?1:t),c=e.object.rect.size.height*(i?1:t);if(!r||0===n)return{left:s,top:a,right:s+l,bottom:a+c};const d=[k(0,0,l,c,n),k(l,0,l,c,n),k(0,c,l,c,n),k(l,c,l,c,n)];let u=1/0,p=1/0,h=-1/0,g=-1/0;for(const v of d)v.x<u&&(u=v.x),v.y<p&&(p=v.y),v.x>h&&(h=v.x),v.y>g&&(g=v.y);return{left:s+u,top:a+p,right:s+h,bottom:a+g}}function S({documentId:e,pageIndex:t,scale:o,rotation:l,pageWidth:c,pageHeight:u,selectedAnnotations:p,isDraggable:h,isResizable:g,isRotatable:v=!0,lockAspectRatio:y=!1,resizeUI:x,rotationUI:b,selectionOutlineColor:m,outlineOffset:k,selectionOutline:S,zIndex:C=2,groupSelectionMenu:A}){var w,I,R;const{plugin:z}=f(),{canModifyAnnotations:D}=s.useDocumentPermissions(e),P=i.useRef(null),E=i.useRef(!1),M=i.useRef(!1),[L,$]=i.useState(null),[O,F]=i.useState(null),[B,W]=i.useState(!1),U=D&&h,T=D&&g,H=D&&v,N=i.useMemo(()=>{const e=p.map(e=>e.object.rect);return a.boundingRectOrEmpty(e)},[p]),[G,q]=i.useState(N);i.useEffect(()=>{E.current||M.current||q(N)},[N]),i.useEffect(()=>{if(!z)return;return z.onRotateChange(t=>{t.documentId===e&&("end"!==t.type&&"cancel"!==t.type||$(null))})},[z,e]);const Y=i.useCallback(t=>{var n,o,i,r,s,a;if(!(null==(n=t.transformData)?void 0:n.type))return;if(!z)return;const l=t.transformData.type,d="move"===l,h="resize"===l;if(d&&!U)return;if("start"===t.state&&(P.current=N,d?(E.current=!0,z.startDrag(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:c,height:u}})):h&&(M.current=!0,z.startResize(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:c,height:u},resizeHandle:(null==(o=t.transformData.metadata)?void 0:o.handle)??"se"}))),"rotate"===l){if(!v)return;const n=p.map(e=>e.object.id),o=(null==(i=t.transformData.metadata)?void 0:i.rotationAngle)??0,l=null==(r=t.transformData.metadata)?void 0:r.cursorPosition;return l&&F({x:l.clientX,y:l.clientY}),void("start"===t.state?($(o),z.startRotation(e,{annotationIds:n,cursorAngle:o,rotationCenter:null==(s=t.transformData.metadata)?void 0:s.rotationCenter})):"move"===t.state?($(o),z.updateRotation(e,o,null==(a=t.transformData.metadata)?void 0:a.rotationDelta)):"end"===t.state&&($(null),F(null),z.commitRotation(e)))}const g=P.current??N;if(d&&t.transformData.changes.rect){const n=t.transformData.changes.rect,o={x:n.origin.x-g.origin.x,y:n.origin.y-g.origin.y},i=z.updateDrag(e,o);q({...g,origin:{x:g.origin.x+i.x,y:g.origin.y+i.y}})}else if(h&&t.transformData.changes.rect){const n=t.transformData.changes.rect;z.updateResize(e,n),q(n)}"end"===t.state&&(P.current=null,d&&E.current?(E.current=!1,z.commitDrag(e)):h&&M.current&&(M.current=!1,z.commitResize(e)))},[z,e,c,u,N,U,p,v]),V=L??0,X=null!==L,K=Number.isFinite(V)?Math.round(10*V)/10:0,Q=(null==x?void 0:x.color)??"#007ACC",Z=(null==x?void 0:x.size)??12,J=(null==b?void 0:b.color)??"white",_=(null==b?void 0:b.connectorColor)??"#007ACC",ee=(null==b?void 0:b.size)??32,te=null==b?void 0:b.margin,ne=(null==b?void 0:b.iconColor)??"#007ACC",oe=(null==b?void 0:b.showConnector)??!1,ie=(null==(w=null==b?void 0:b.border)?void 0:w.color)??"#007ACC",re=(null==(I=null==b?void 0:b.border)?void 0:I.width)??1,se=(null==(R=null==b?void 0:b.border)?void 0:R.style)??"solid",ae=(null==S?void 0:S.color)??m??"#007ACC",le=(null==S?void 0:S.style)??"dashed",ce=(null==S?void 0:S.width)??2,de=(null==S?void 0:S.offset)??k??2,{dragProps:ue,resize:pe,rotation:he}=d.useInteractionHandles({controller:{element:G,constraints:{minWidth:20,minHeight:20,boundingBox:{width:c,height:u}},maintainAspectRatio:y,pageRotation:l,scale:o,enabled:!0,onUpdate:Y},resizeUI:{handleSize:Z,spacing:de,offsetMode:"outside",includeSides:!y,zIndex:C+1},vertexUI:{vertexSize:0,zIndex:C},rotationUI:{handleSize:ee,margin:te,zIndex:C+2,showConnector:oe},includeVertices:!1,includeRotation:H,currentRotation:L??0});if(p.length<2)return null;let ge=1/0,ve=1/0,ye=-1/0,fe=-1/0;for(const n of p){const e=j(n,o,l);ge=Math.min(ge,e.left),ve=Math.min(ve,e.top),ye=Math.max(ye,e.right),fe=Math.max(fe,e.bottom)}const xe=ge-N.origin.x*o,be=ve-N.origin.y*o,me=ye-(N.origin.x+N.size.width)*o,ke=fe-(N.origin.y+N.size.height)*o,je=G.origin.x*o+xe,Se=G.origin.y*o+be,Ce=G.size.width*o+(me-xe),Ae=G.size.height*o+(ke-be),we=Ce/2,Ie=Ae/2,Re=Math.max(300,Math.max(Ce,Ae)+80);return n.jsxs("div",{"data-group-selection-box":!0,"data-no-interaction":!0,children:[n.jsxs("div",{style:{position:"absolute",left:je,top:Se,width:Ce,height:Ae,pointerEvents:"none",zIndex:C},children:[X&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:we-Re/2,top:Ie,width:Re,height:1,backgroundColor:Q,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:we,top:Ie-Re/2,width:1,height:Re,backgroundColor:Q,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:we-Re/2,top:Ie,width:Re,height:1,transformOrigin:"center center",transform:`rotate(${V}deg)`,backgroundColor:Q,opacity:.8,pointerEvents:"none"}})]}),H&&he&&((null==b?void 0:b.component)?n.jsx("div",{onPointerEnter:()=>W(!0),onPointerLeave:()=>{W(!1),F(null)},onPointerMove:e=>{X||F({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:b.component({...he.handle,backgroundColor:J,iconColor:ne,connectorStyle:{...he.connector.style,backgroundColor:_,opacity:X?0:1},showConnector:oe,opacity:X?0:1,border:{color:ie,width:re,style:se}})}):n.jsxs("div",{onPointerEnter:()=>W(!0),onPointerLeave:()=>{W(!1),F(null)},onPointerMove:e=>{X||F({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[oe&&n.jsx("div",{style:{...he.connector.style,backgroundColor:_,opacity:X?0:1}}),n.jsx("div",{...he.handle,style:{...he.handle.style,backgroundColor:J,border:`${re}px ${se} ${ie}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:X?0:1},children:n.jsxs("svg",{width:Math.round(.6*ee),height:Math.round(.6*ee),viewBox:"0 0 24 24",fill:"none",stroke:ne,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),n.jsx("path",{d:"M21 3v5h-5"})]})})]})),n.jsx("div",{...U?ue:{onPointerDown:e=>e.stopPropagation()},style:{position:"absolute",left:0,top:0,width:Ce,height:Ae,outline:X?"none":`${ce}px ${le} ${ae}`,outlineOffset:de-1,cursor:U?"move":"default",touchAction:"none",pointerEvents:"auto"},children:T&&!X&&pe.map(({key:e,...t})=>(null==x?void 0:x.component)?x.component({key:e,...t,backgroundColor:Q}):n.jsx("div",{...t,style:{...t.style,backgroundColor:Q}},e))})]}),(X||B)&&O&&r.createPortal(n.jsxs("div",{style:{position:"fixed",left:O.x+16,top:O.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[K.toFixed(0),"°"]}),document.body),A&&!X&&n.jsx(d.CounterRotate,{rect:{origin:{x:je,y:Se},size:{width:Ce,height:Ae}},rotation:l,children:e=>{const n=((V+90*l)%360+360)%360;return A({...e,context:{type:"group",annotations:p,pageIndex:t},selected:!0,placement:{suggestTop:H&&n>90&&n<270}})}})]})}function C(e){return{id:e.id,matches:t=>e.matches(t),render:t=>e.render(t),vertexConfig:e.vertexConfig,zIndex:e.zIndex,defaultBlendMode:e.defaultBlendMode,containerStyle:e.containerStyle,interactionDefaults:e.interactionDefaults,useAppearanceStream:e.useAppearanceStream,isDraggable:e.isDraggable,onDoubleClick:e.onDoubleClick,selectOverride:e.selectOverride,hideSelectionMenu:e.hideSelectionMenu}}function A({isSelected:e,strokeColor:t,opacity:o=1,strokeWidth:r,inkList:s,rect:a,scale:l,onClick:c,appearanceActive:d=!1}){const u=t??"#000000",p=i.useMemo(()=>s.map(({points:e})=>{let t="";return e.forEach(({x:e,y:n},o)=>{const i=e-a.origin.x,r=n-a.origin.y;t+=(0===o?"M":"L")+i+" "+r+" "}),t.trim()}),[s,a]),h=a.size.width*l,g=a.size.height*l,v=Math.max(r,20/l);return n.jsxs("svg",{style:{position:"absolute",width:h,height:g,pointerEvents:"none",zIndex:2,overflow:"visible"},width:h,height:g,viewBox:`0 0 ${a.size.width} ${a.size.height}`,children:[p.map((t,o)=>n.jsx("path",{d:t,fill:"none",stroke:"transparent",strokeWidth:v,onPointerDown:c,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visibleStroke",strokeLinecap:"round",strokeLinejoin:"round"}},`hit-${o}`)),!d&&p.map((e,t)=>n.jsx("path",{d:e,fill:"none",opacity:o,style:{pointerEvents:"none",stroke:u,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}},`vis-${t}`))]})}function w({isSelected:e,color:o="#000000",strokeColor:r,opacity:s=1,strokeWidth:l,strokeStyle:c=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,rect:u,scale:p,onClick:h,appearanceActive:g=!1,cloudyBorderIntensity:v,rectangleDifferences:y}){const f=(v??0)>0,{width:x,height:b,x:m,y:k}=i.useMemo(()=>{const e=u.size.width,t=u.size.height;return{width:Math.max(e-l,0),height:Math.max(t-l,0),x:l/2,y:l/2}},[u,l]),j=i.useMemo(()=>f?t.generateCloudyRectanglePath({x:0,y:0,width:u.size.width,height:u.size.height},y,v,l):null,[f,u,y,v,l]),S=u.size.width*p,C=u.size.height*p,A=Math.max(l,20/p);return n.jsxs("svg",{style:{position:"absolute",width:S,height:C,pointerEvents:"none",zIndex:2},width:S,height:C,viewBox:`0 0 ${u.size.width} ${u.size.height}`,overflow:"visible",children:[f&&j?n.jsx("path",{d:j.path,fill:"transparent",stroke:"transparent",strokeWidth:A,onPointerDown:h,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"transparent"===o?"visibleStroke":"visible"}}):n.jsx("rect",{x:m,y:k,width:x,height:b,fill:"transparent",stroke:"transparent",strokeWidth:A,onPointerDown:h,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"transparent"===o?"visibleStroke":"visible"}}),!g&&(f&&j?n.jsx("path",{d:j.path,fill:o,opacity:s,style:{pointerEvents:"none",stroke:r??o,strokeWidth:l,strokeLinejoin:"round"}}):n.jsx("rect",{x:m,y:k,width:x,height:b,fill:o,opacity:s,style:{pointerEvents:"none",stroke:r??o,strokeWidth:l,...c===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}))]})}function I({color:e="#000000",strokeColor:o,opacity:r=1,strokeWidth:s,strokeStyle:l=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:p,isSelected:h,appearanceActive:g=!1,cloudyBorderIntensity:v,rectangleDifferences:y}){const f=(v??0)>0,{width:x,height:b,cx:m,cy:k,rx:j,ry:S}=i.useMemo(()=>{const e=d.size.width,t=d.size.height,n=Math.max(e-s,0),o=Math.max(t-s,0);return{width:e,height:t,cx:s/2+n/2,cy:s/2+o/2,rx:n/2,ry:o/2}},[d,s]),C=i.useMemo(()=>f?t.generateCloudyEllipsePath({x:0,y:0,width:d.size.width,height:d.size.height},y,v,s):null,[f,d,y,v,s]),A=x*u,w=b*u,I=Math.max(s,20/u);return n.jsxs("svg",{style:{position:"absolute",width:A,height:w,pointerEvents:"none",zIndex:2},width:A,height:w,viewBox:`0 0 ${x} ${b}`,overflow:"visible",children:[f&&C?n.jsx("path",{d:C.path,fill:"transparent",stroke:"transparent",strokeWidth:I,onPointerDown:p,style:{cursor:h?"move":"pointer",pointerEvents:h?"none":"transparent"===e?"visibleStroke":"visible"}}):n.jsx("ellipse",{cx:m,cy:k,rx:j,ry:S,fill:"transparent",stroke:"transparent",strokeWidth:I,onPointerDown:p,style:{cursor:h?"move":"pointer",pointerEvents:h?"none":"transparent"===e?"visibleStroke":"visible"}}),!g&&(f&&C?n.jsx("path",{d:C.path,fill:e,opacity:r,style:{pointerEvents:"none",stroke:o??e,strokeWidth:s,strokeLinejoin:"round"}}):n.jsx("ellipse",{cx:m,cy:k,rx:j,ry:S,fill:e,opacity:r,style:{pointerEvents:"none",stroke:o??e,strokeWidth:s,...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}))]})}function R({color:e="transparent",opacity:o=1,strokeWidth:r,strokeColor:s="#000000",strokeStyle:l=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,linePoints:u,lineEndings:p,scale:h,onClick:g,isSelected:v,appearanceActive:y=!1}){const{x1:f,y1:x,x2:b,y2:m}=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]),k=i.useMemo(()=>{const e=Math.atan2(m-x,b-f);return{start:t.patching.createEnding(null==p?void 0:p.start,r,e+Math.PI,f,x),end:t.patching.createEnding(null==p?void 0:p.end,r,e,b,m)}},[p,r,f,x,b,m]),j=d.size.width*h,S=d.size.height*h,C=Math.max(r,20/h);return n.jsxs("svg",{style:{position:"absolute",width:j,height:S,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:S,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[n.jsx("line",{x1:f,y1:x,x2:b,y2:m,stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":"pointer",pointerEvents:v?"none":"visibleStroke",strokeLinecap:"butt"}}),k.start&&n.jsx("path",{d:k.start.d,transform:k.start.transform,fill:"transparent",stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":"pointer",pointerEvents:v?"none":k.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),k.end&&n.jsx("path",{d:k.end.d,transform:k.end.transform,fill:"transparent",stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":"pointer",pointerEvents:v?"none":k.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),!y&&n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:f,y1:x,x2:b,y2:m,opacity:o,style:{pointerEvents:"none",stroke:s,strokeWidth:r,strokeLinecap:"butt",...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),k.start&&n.jsx("path",{d:k.start.d,transform:k.start.transform,stroke:s,fill:k.start.filled?e:"none",style:{pointerEvents:"none",strokeWidth:r,strokeLinecap:"butt",...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),k.end&&n.jsx("path",{d:k.end.d,transform:k.end.transform,stroke:s,fill:k.end.filled?e:"none",style:{pointerEvents:"none",strokeWidth:r,strokeLinecap:"butt",...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})]})]})}function z({rect:e,vertices:o,color:r="transparent",strokeColor:s="#000000",opacity:l=1,strokeWidth:c,strokeStyle:d=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:u,scale:p,isSelected:h,onClick:g,lineEndings:v,appearanceActive:y=!1}){const f=i.useMemo(()=>o.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[o,e]),x=i.useMemo(()=>{if(!f.length)return"";const[e,...t]=f;return`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y} `).join("").trim()},[f]),b=i.useMemo(()=>{if(f.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),n=e(f[0],f[1]),o=e(f[f.length-2],f[f.length-1]);return{start:t.patching.createEnding(null==v?void 0:v.start,c,n+Math.PI,f[0].x,f[0].y),end:t.patching.createEnding(null==v?void 0:v.end,c,o,f[f.length-1].x,f[f.length-1].y)}},[f,v,c]),m=e.size.width*p,k=e.size.height*p,j=Math.max(c,20/p);return n.jsxs("svg",{style:{position:"absolute",width:m,height:k,pointerEvents:"none",zIndex:2,overflow:"visible"},width:m,height:k,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:j,onPointerDown:g,style:{cursor:h?"move":"pointer",pointerEvents:h?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"}}),b.start&&n.jsx("path",{d:b.start.d,transform:b.start.transform,fill:"transparent",stroke:"transparent",strokeWidth:j,onPointerDown:g,style:{cursor:h?"move":"pointer",pointerEvents:h?"none":b.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),b.end&&n.jsx("path",{d:b.end.d,transform:b.end.transform,fill:"transparent",stroke:"transparent",strokeWidth:j,onPointerDown:g,style:{cursor:h?"move":"pointer",pointerEvents:h?"none":b.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),!y&&n.jsxs(n.Fragment,{children:[n.jsx("path",{d:x,opacity:l,style:{fill:"none",stroke:s??r,strokeWidth:c,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...d===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),b.start&&n.jsx("path",{d:b.start.d,transform:b.start.transform,stroke:s,fill:b.start.filled?r:"none",style:{pointerEvents:"none",strokeWidth:c,strokeLinecap:"butt",...d===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),b.end&&n.jsx("path",{d:b.end.d,transform:b.end.transform,stroke:s,fill:b.end.filled?r:"none",style:{pointerEvents:"none",strokeWidth:c,strokeLinecap:"butt",...d===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}})]})]})}function D({rect:e,vertices:o,color:r="transparent",strokeColor:s="#000000",opacity:l=1,strokeWidth:c,strokeStyle:d=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:u,scale:p,isSelected:h,onClick:g,currentVertex:v,handleSize:y=14,appearanceActive:f=!1,cloudyBorderIntensity:x}){const b=(x??0)>0,m=v?[...o,v]:o,k=i.useMemo(()=>m.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[m,e]),j=i.useMemo(()=>{if(!k.length)return"";const[e,...t]=k,n=!!v;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(n?"":" Z")).trim()},[k,v]),S=i.useMemo(()=>!b||m.length<3?null:t.generateCloudyPolygonPath(m,e.origin,x,c),[b,m,e.origin,x,c]),C=v&&o.length>0,A=e.size.width*p,w=e.size.height*p,I=Math.max(c,20/p);return n.jsxs("svg",{style:{position:"absolute",width:A,height:w,pointerEvents:"none",zIndex:2,overflow:"visible"},width:A,height:w,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:b&&S?S.path:j,fill:"transparent",stroke:"transparent",strokeWidth:I,onPointerDown:g,style:{cursor:h?"move":"pointer",pointerEvents:h?"none":"transparent"===r?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter"}}),!f&&n.jsx(n.Fragment,{children:b&&S?n.jsx("path",{d:S.path,opacity:l,style:{fill:r,stroke:s??r,strokeWidth:c,pointerEvents:"none",strokeLinejoin:"round"}}):n.jsxs(n.Fragment,{children:[n.jsx("path",{d:j,opacity:l,style:{fill:v?"none":r,stroke:s??r,strokeWidth:c,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...d===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),C&&o.length>1&&n.jsx("path",{d:`M ${k[k.length-1].x} ${k[k.length-1].y} L ${k[0].x} ${k[0].y}`,fill:"none",style:{stroke:s,strokeWidth:c,strokeDasharray:"4,4",opacity:.7,pointerEvents:"none"}}),C&&o.length>=2&&n.jsx("rect",{x:k[0].x-y/p/2,y:k[0].y-y/p/2,width:y/p,height:y/p,fill:s,opacity:.4,stroke:s,strokeWidth:c/2,style:{pointerEvents:"none"}})]})})]})}function P({isSelected:e,color:t="#facc15",opacity:o=1,onClick:i,appearanceActive:r=!1}){const s=a.getContrastStrokeColor(t);return n.jsx("div",{style:{position:"absolute",inset:0,zIndex:2,pointerEvents:e?"none":"auto",cursor:e?"move":"pointer"},onPointerDown:i,children:!r&&n.jsxs("svg",{style:{position:"absolute",inset:0,pointerEvents:"none"},viewBox:"0 0 20 20",width:"100%",height:"100%",children:[n.jsx("path",{d:"M 0.5 15.5 L 0.5 0.5 L 19.5 0.5 L 19.5 15.5 L 8.5 15.5 L 6.5 19.5 L 4.5 15.5 Z",fill:t,opacity:o,stroke:s,strokeWidth:"1",strokeLinejoin:"miter"}),n.jsx("line",{x1:"2.5",y1:"4.25",x2:"17.5",y2:"4.25",stroke:s,strokeWidth:"1"}),n.jsx("line",{x1:"2.5",y1:"8",x2:"17.5",y2:"8",stroke:s,strokeWidth:"1"}),n.jsx("line",{x1:"2.5",y1:"11.75",x2:"17.5",y2:"11.75",stroke:s,strokeWidth:"1"})]})})}function E({documentId:e,isSelected:t,isEditing:o,annotation:r,pageIndex:s,scale:l,onClick:c,appearanceActive:d=!1}){const u=i.useRef(null),h=i.useRef(!1),{provides:g}=x(),v=(null==g?void 0:g.forDocument(e))??null,[y,f]=i.useState(!1);i.useEffect(()=>{var e;if(o&&u.current){h.current=!0;const t=u.current;t.focus();const n=null==v?void 0:v.findToolForAnnotation(r.object),o=null!=(null==(e=null==n?void 0:n.defaults)?void 0:e.contents)&&r.object.contents===n.defaults.contents,i=window.getSelection();if(i){const e=document.createRange();e.selectNodeContents(t),o||e.collapse(!1),i.removeAllRanges(),i.addRange(e)}}},[o]),i.useLayoutEffect(()=>{try{const e=navigator,t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1;f(t)}catch{f(!1)}},[]);const b=r.object.fontSize*l,m=y&&o&&b>0&&b<16,k=m?16:b,j=m?b/16:1,S=m?100/j:100;return n.jsx("div",{style:{position:"absolute",width:r.object.rect.size.width*l,height:r.object.rect.size.height*l,cursor:t&&!o?"move":"default",pointerEvents:t&&!o?"none":"auto",zIndex:2,opacity:d?0:1},onPointerDown:c,children:n.jsx("span",{ref:u,onBlur:()=>{h.current&&(h.current=!1,v&&u.current&&v.updateAnnotation(s,r.object.id,{contents:u.current.innerText.replace(/\u00A0/g," ")}))},tabIndex:0,style:{color:r.object.fontColor,fontSize:k,...a.standardFontCssProperties(r.object.fontFamily),textAlign:a.textAlignmentToCss(r.object.textAlign),flexDirection:"column",justifyContent:r.object.verticalAlign===a.PdfVerticalAlignment.Top?"flex-start":r.object.verticalAlign===a.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:r.object.color??r.object.backgroundColor,opacity:r.object.opacity,width:m?`${S}%`:"100%",height:m?`${S}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:o?"text":"pointer",outline:"none",transform:m?`scale(${j})`:void 0,transformOrigin:"top left"},contentEditable:o,...p,children:r.object.contents})})}function M({documentId:e,pageIndex:t,annotation:r,scaleFactor:s=1,unrotated:l,style:c,...d}){const{provides:u}=x(),[p,h]=i.useState(null),g=i.useRef(null),{width:v,height:y}=r.rect.size;i.useEffect(()=>{if(u){const n=u.forDocument(e).renderAnnotation({pageIndex:t,annotation:r,options:{scaleFactor:s,dpr:window.devicePixelRatio,unrotated:l}});return n.wait(e=>{const t=URL.createObjectURL(e);h(t),g.current=t},a.ignore),()=>{g.current?(URL.revokeObjectURL(g.current),g.current=null):n.abort({code:a.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,s,l,u,e,r.id,v,y]);return n.jsx(o.Fragment,{children:p&&n.jsx("img",{src:p,onLoad:()=>{g.current&&(URL.revokeObjectURL(g.current),g.current=null)},...d,style:{width:"100%",height:"100%",display:"block",...c||{}}})})}function L({isSelected:e,annotation:t,documentId:o,pageIndex:i,scale:r,onClick:s}){const a=!!t.object.rotation&&!!t.object.unrotatedRect;return n.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:e?"none":"auto",cursor:"pointer"},onPointerDown:s,children:n.jsx(M,{documentId:o,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:r,unrotated:a})})}function $({isSelected:e,strokeColor:t="#0000FF",strokeWidth:o=2,strokeStyle:r=a.PdfAnnotationBorderStyle.UNDERLINE,strokeDashArray:s,rect:l,scale:c,onClick:d,hasIRT:u=!1}){const{width:p,height:h}=i.useMemo(()=>({width:l.size.width,height:l.size.height}),[l]),g=p*c,v=h*c,y=i.useMemo(()=>{if(r===a.PdfAnnotationBorderStyle.DASHED)return(null==s?void 0:s.join(","))??`${3*o},${o}`},[r,s,o]),f=r===a.PdfAnnotationBorderStyle.UNDERLINE;return n.jsxs("svg",{style:{position:"absolute",width:g,height:v,pointerEvents:"none",zIndex:2},width:g,height:v,viewBox:`0 0 ${p} ${h}`,children:[n.jsx("rect",{x:0,y:0,width:p,height:h,fill:"transparent",onPointerDown:u?void 0:d,style:{cursor:u?"default":e?"move":"pointer",pointerEvents:u||e?"none":"visible"}}),f?n.jsx("line",{x1:1,y1:h-1,x2:p-1,y2:h-1,stroke:t,strokeWidth:o,strokeDasharray:y,style:{pointerEvents:"none"}}):n.jsx("rect",{x:o/2,y:o/2,width:Math.max(p-o,0),height:Math.max(h-o,0),fill:"transparent",stroke:t,strokeWidth:o,strokeDasharray:y,style:{pointerEvents:"none"}})]})}function O({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00";return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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:l?"transparent":c,opacity:l?void 0:t,pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:void 0,...a}},o))})}function F({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00",d=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:d,background:c,opacity:t,pointerEvents:"none"}})},o))})}function B({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00",d=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:d,background:c,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},o))})}function W({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=2*r,d=6*r,u=`url("data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${2*c}" viewBox="0 0 ${d} ${2*c}">\n <path d="M0 ${c} Q ${d/4} 0 ${d/2} ${c} T ${d} ${c}"\n fill="none" stroke="${e??"#FFFF00"}" stroke-width="${c}" stroke-linecap="round"/>\n </svg>`)}")`;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:2*c,backgroundImage:u,backgroundRepeat:"repeat-x",backgroundSize:`${d}px ${2*c}px`,opacity:t,pointerEvents:"none"}})},o))})}function U({isSelected:e,strokeColor:t="#000000",opacity:o=1,rect:r,scale:s,onClick:a,appearanceActive:l=!1}){const{width:c,height:d,path:u}=i.useMemo(()=>{const e=r.size.width,t=r.size.height,n=e/2;return{width:e,height:t,path:[`M 0 ${t}`,`C ${.27*e} ${t} ${n} ${t-.44*t} ${n} 0`,`C ${n} ${t-.44*t} ${e-.27*e} ${t} ${e} ${t}`,"Z"].join(" ")}},[r]),p=c*s,h=d*s;return n.jsxs("svg",{style:{position:"absolute",width:p,height:h,pointerEvents:"none",zIndex:2},width:p,height:h,viewBox:`0 0 ${c} ${d}`,overflow:"visible",children:[n.jsx("path",{d:u,fill:"transparent",stroke:"transparent",strokeWidth:4,onPointerDown:a,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visible"}}),!l&&n.jsx("path",{d:u,fill:t,stroke:t,strokeWidth:.5,opacity:o,fillRule:"evenodd",style:{pointerEvents:"none"}})]})}const T=[C({id:"ink",matches:e=>e.type===a.PdfAnnotationSubtype.INK,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(A,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),C({id:"square",matches:e=>e.type===a.PdfAnnotationSubtype.SQUARE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(w,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),C({id:"circle",matches:e=>e.type===a.PdfAnnotationSubtype.CIRCLE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(I,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),C({id:"line",matches:e=>e.type===a.PdfAnnotationSubtype.LINE,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(R,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),C({id:"polyline",matches:e=>e.type===a.PdfAnnotationSubtype.POLYLINE,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(z,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),C({id:"polygon",matches:e=>e.type===a.PdfAnnotationSubtype.POLYGON,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(D,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),C({id:"highlight",matches:e=>e.type===a.PdfAnnotationSubtype.HIGHLIGHT,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(O,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},defaultBlendMode:a.PdfBlendMode.Multiply}),C({id:"underline",matches:e=>e.type===a.PdfAnnotationSubtype.UNDERLINE,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(F,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),C({id:"strikeout",matches:e=>e.type===a.PdfAnnotationSubtype.STRIKEOUT,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(B,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),C({id:"squiggly",matches:e=>e.type===a.PdfAnnotationSubtype.SQUIGGLY,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(W,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),C({id:"text",matches:e=>e.type===a.PdfAnnotationSubtype.TEXT&&!e.inReplyToId,render:({currentObject:e,isSelected:t,onClick:o,appearanceActive:i})=>n.jsx(P,{isSelected:t,color:e.strokeColor??e.color,opacity:e.opacity,onClick:o,appearanceActive:i}),interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!1}}),C({id:"caret",matches:e=>e.type===a.PdfAnnotationSubtype.CARET,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(U,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),C({id:"freeText",matches:e=>e.type===a.PdfAnnotationSubtype.FREETEXT,render:({annotation:e,currentObject:t,isSelected:o,isEditing:i,scale:r,pageIndex:s,documentId:a,onClick:l,appearanceActive:c})=>n.jsx(E,{documentId:a,isSelected:o,isEditing:i,annotation:{...e,object:t},pageIndex:s,scale:r,onClick:l,appearanceActive:c}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0},isDraggable:(e,{isEditing:t})=>e&&!t,onDoubleClick:(e,t)=>t(e)}),C({id:"stamp",matches:e=>e.type===a.PdfAnnotationSubtype.STAMP,render:({annotation:e,isSelected:t,documentId:o,pageIndex:i,scale:r,onClick:s})=>n.jsx(L,{isSelected:t,annotation:e,documentId:o,pageIndex:i,scale:r,onClick:s}),useAppearanceStream:!1,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),C({id:"link",matches:e=>e.type===a.PdfAnnotationSubtype.LINK,render:({currentObject:e,isSelected:t,scale:o,onClick:i})=>n.jsx($,{...e,isSelected:t,scale:o,onClick:i,hasIRT:!!e.inReplyToId}),interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},useAppearanceStream:!1,selectOverride:(e,t,n)=>{if(e.stopPropagation(),n.clearSelection(),t.object.inReplyToId){const e=n.allAnnotations.find(e=>e.object.id===t.object.inReplyToId);if(e)return void n.selectAnnotation(e.object.pageIndex,e.object.id)}n.selectAnnotation(n.pageIndex,t.object.id)},hideSelectionMenu:e=>!!e.inReplyToId})];function H(e){const{documentId:o,pageIndex:r,scale:s,pageWidth:d,pageHeight:u,selectionMenu:p}=e,{provides:h}=x(),{provides:g}=c.useSelectionCapability(),[v,y]=i.useState([]),{register:f}=l.usePointerHandlers({documentId:o,pageIndex:r}),[b,k]=i.useState([]),[j,C]=i.useState(null),[A,w]=i.useState({}),I=i.useRef(s),R=i.useMemo(()=>h?h.forDocument(o):null,[h,o]),z=b.length>1;i.useEffect(()=>{if(R){const e=R.getState();return y(t.getAnnotationsByPageIndex(e,r)),k(t.getSelectedAnnotationIds(e)),R.onStateChange(e=>{y(t.getAnnotationsByPageIndex(e,r)),k(t.getSelectedAnnotationIds(e))})}},[R,r]),i.useEffect(()=>{if(R)return R.onAnnotationEvent(e=>{"create"===e.type&&e.editAfterCreate&&C(e.annotation.id)})},[R]),i.useEffect(()=>{if(!R)return;I.current!==s&&(R.invalidatePageAppearances(r),I.current=s);R.getPageAppearances(r,{scaleFactor:s,dpr:"undefined"!=typeof window?window.devicePixelRatio:1}).wait(e=>w(e),()=>w({}))},[R,r,s]);const D=i.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&R&&(j&&v.some(e=>e.object.id===j)&&t.stopImmediatePropagation(),R.deselectAnnotation(),C(null))}}),[R,j,v]),P=i.useCallback((e,t)=>{if(e.stopPropagation(),R&&g){g.clear();"metaKey"in e&&(e.metaKey||e.ctrlKey)?R.toggleSelection(r,t.object.id):R.selectAnnotation(r,t.object.id),t.object.id!==j&&C(null)}},[R,g,j,r]);i.useEffect(()=>f(D,{documentId:o}),[f,D]);const E=i.useMemo(()=>v.filter(e=>b.includes(e.object.id)),[v,b]),M=i.useMemo(()=>!(E.length<2)&&E.every(e=>{const n=null==R?void 0:R.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupDraggable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isDraggable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupDraggable)?o:i}),[E,R]),L=i.useMemo(()=>!(E.length<2)&&E.every(e=>{const n=null==R?void 0:R.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupResizable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isResizable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupResizable)?o:i}),[E,R]),$=i.useMemo(()=>!(E.length<2)&&E.every(e=>{const n=null==R?void 0:R.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupRotatable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isRotatable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupRotatable)?o:i}),[E,R]),O=i.useMemo(()=>!(E.length<2)&&E.some(e=>{const n=null==R?void 0:R.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.lockGroupAspectRatio,e.object,!1),i=t.resolveInteractionProp(null==n?void 0:n.interaction.lockAspectRatio,e.object,!1);return void 0!==(null==n?void 0:n.interaction.lockGroupAspectRatio)?o:i}),[E,R]),F=i.useMemo(()=>{if(!R)return!1;const e=R.getSelectedAnnotations();return e.length>1&&e.every(e=>e.object.pageIndex===r)},[R,r,b]),B=i.useCallback(e=>{if(e.dictMode)return null;if(e.object.rotation&&e.object.unrotatedRect)return null;const t=A[e.object.id];return(null==t?void 0:t.normal)?t:null},[A]),W=i.useMemo(()=>{const t=e.annotationRenderers??[],n=new Set(t.map(e=>e.id));return[...t,...T.filter(e=>!n.has(e.id))]},[e.annotationRenderers]),U=i.useCallback(e=>W.find(t=>t.matches(e.object))??null,[W]),H=i.useMemo(()=>({defaultSelect:P,selectAnnotation:(e,t)=>null==R?void 0:R.selectAnnotation(e,t),clearSelection:()=>null==g?void 0:g.clear(),allAnnotations:v,pageIndex:r}),[P,R,g,v,r]);return n.jsxs(n.Fragment,{children:[v.map(i=>{var l,c,d;const u=U(i);if(!u)return null;const h=null==R?void 0:R.findToolForAnnotation(i.object),g=b.includes(i.object.id),v=j===i.object.id,y=u.interactionDefaults,f=t.resolveInteractionProp(null==h?void 0:h.interaction.isDraggable,i.object,(null==y?void 0:y.isDraggable)??!0),x=u.isDraggable?u.isDraggable(f,{isEditing:v}):f,k=(null==(l=null==h?void 0:h.behavior)?void 0:l.useAppearanceStream)??u.useAppearanceStream??!0,S=u.selectOverride?e=>u.selectOverride(e,i,H):e=>P(e,i);return n.jsx(m,{trackedAnnotation:i,isSelected:g,isEditing:v,isMultiSelected:z,isDraggable:x,isResizable:t.resolveInteractionProp(null==h?void 0:h.interaction.isResizable,i.object,(null==y?void 0:y.isResizable)??!1),lockAspectRatio:t.resolveInteractionProp(null==h?void 0:h.interaction.lockAspectRatio,i.object,(null==y?void 0:y.lockAspectRatio)??!1),isRotatable:t.resolveInteractionProp(null==h?void 0:h.interaction.isRotatable,i.object,(null==y?void 0:y.isRotatable)??!1),vertexConfig:u.vertexConfig,selectionMenu:(null==(c=u.hideSelectionMenu)?void 0:c.call(u,i.object))?void 0:p,onSelect:S,onDoubleClick:u.onDoubleClick?e=>{e.stopPropagation(),u.onDoubleClick(i.object.id,C)}:void 0,zIndex:u.zIndex,blendMode:a.blendModeToCss(i.object.blendMode??u.defaultBlendMode??a.PdfBlendMode.Normal),style:null==(d=u.containerStyle)?void 0:d.call(u,i.object),appearance:k?B(i):void 0,...e,children:(e,{appearanceActive:t})=>u.render({annotation:i,currentObject:e,isSelected:g,isEditing:v,scale:s,pageIndex:r,documentId:o,onClick:S,appearanceActive:t})},i.object.id)}),F&&E.length>=2&&n.jsx(S,{documentId:o,pageIndex:r,scale:s,rotation:e.rotation,pageWidth:d,pageHeight:u,selectedAnnotations:E,isDraggable:M,isResizable:L,isRotatable:$,lockAspectRatio:O,resizeUI:e.resizeUI,rotationUI:e.rotationUI,selectionOutlineColor:e.selectionOutlineColor,selectionOutline:e.groupSelectionOutline??e.selectionOutline,groupSelectionMenu:e.groupSelectionMenu})]})}function N({documentId:e,pageIndex:t,scale:o}){var r,s,l,d,u,p,h,g,v,y,f,b;const{provides:m}=c.useSelectionCapability(),{provides:k}=x(),[j,S]=i.useState([]),[C,A]=i.useState(null),[w,I]=i.useState(null);if(i.useEffect(()=>{if(m)return m.forDocument(e).onSelectionChange(()=>{S(m.forDocument(e).getHighlightRectsForPage(t)),A(m.forDocument(e).getBoundingRectForPage(t))})},[m,e,t]),i.useEffect(()=>{if(k)return I(k.forDocument(e).getActiveTool()),k.forDocument(e).onActiveToolChange(e=>I(e))},[k,e]),!C)return null;if(!w||!w.defaults)return null;switch(w.defaults.type){case a.PdfAnnotationSubtype.UNDERLINE:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(r=w.defaults)?void 0:r.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(F,{strokeColor:null==(s=w.defaults)?void 0:s.strokeColor,opacity:null==(l=w.defaults)?void 0:l.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.HIGHLIGHT:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(d=w.defaults)?void 0:d.blendMode)??a.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(O,{strokeColor:null==(u=w.defaults)?void 0:u.strokeColor,opacity:null==(p=w.defaults)?void 0:p.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.STRIKEOUT:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(h=w.defaults)?void 0:h.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(B,{strokeColor:null==(g=w.defaults)?void 0:g.strokeColor,opacity:null==(v=w.defaults)?void 0:v.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.SQUIGGLY:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(y=w.defaults)?void 0:y.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(W,{strokeColor:null==(f=w.defaults)?void 0:f.strokeColor,opacity:null==(b=w.defaults)?void 0:b.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.CARET:default:return null}}function G({preview:e,scale:t}){const{bounds:o}=e,i={position:"absolute",left:o.origin.x*t,top:o.origin.y*t,width:o.size.width*t,height:o.size.height*t,pointerEvents:"none",zIndex:10};return e.type===a.PdfAnnotationSubtype.CIRCLE?n.jsx("div",{style:i,children:n.jsx(I,{isSelected:!1,scale:t,...e.data})}):e.type===a.PdfAnnotationSubtype.SQUARE?n.jsx("div",{style:i,children:n.jsx(w,{isSelected:!1,scale:t,...e.data})}):e.type===a.PdfAnnotationSubtype.POLYGON?n.jsx("div",{style:i,children:n.jsx(D,{isSelected:!1,scale:t,...e.data})}):e.type===a.PdfAnnotationSubtype.POLYLINE?n.jsx("div",{style:i,children:n.jsx(z,{isSelected:!1,scale:t,...e.data})}):e.type===a.PdfAnnotationSubtype.LINE?n.jsx("div",{style:i,children:n.jsx(R,{isSelected:!1,scale:t,...e.data})}):e.type===a.PdfAnnotationSubtype.INK?n.jsx("div",{style:{...i,mixBlendMode:a.blendModeToCss(e.data.blendMode??a.PdfBlendMode.Normal)},children:n.jsx(A,{isSelected:!1,scale:t,...e.data})}):e.type===a.PdfAnnotationSubtype.FREETEXT?n.jsx("div",{style:i,children:n.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})}):null}function q({documentId:e,pageIndex:t,scale:o}){const{plugin:r}=f(),[s,a]=i.useState(new Map),l=i.useRef(null),c=i.useRef(null),d=i.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!l.current)return;const n=l.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 r=i.getContext("2d");if(!r)return;const s=new Image;s.crossOrigin="Anonymous",s.onload=()=>{let{naturalWidth:a,naturalHeight:l}=s;const c=t?t/a:1,d=n?n/l:1,u=Math.min(c,d,1),p=a*u,h=l*u;i.width=p,i.height=h,r.drawImage(s,0,0,p,h);const g=r.getImageData(0,0,p,h);"string"!=typeof e&&URL.revokeObjectURL(s.src),o({imageData:g,width:p,height:h})},s.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return i.useEffect(()=>{if(r)return r.registerPageHandlers(e,t,o,{services:d,onPreview:(e,t)=>{a(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,o,r,d]),n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:l,type:"file",style:{display:"none"}}),n.jsx("canvas",{ref:c,style:{display:"none"}}),Array.from(s.entries()).map(([e,t])=>n.jsx(G,{preview:t,scale:o},e))]})}const Y=e.createPluginPackage(t.AnnotationPluginPackage).addWrapper(v).build();exports.AnnotationLayer=function({style:e,documentId:t,pageIndex:o,scale:r,rotation:a,selectionMenu:l,groupSelectionMenu:c,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:v,customAnnotationRenderer:f,annotationRenderers:x,...b}){var m,k,j,S;const C=s.useDocumentState(t),A=null==(k=null==(m=null==C?void 0:C.document)?void 0:m.pages)?void 0:k[o],w=(null==(j=null==A?void 0:A.size)?void 0:j.width)??0,I=(null==(S=null==A?void 0:A.size)?void 0:S.height)??0,R=y(),z=i.useMemo(()=>{const e=[...R];for(const t of x??[]){const n=e.findIndex(e=>e.id===t.id);n>=0?e[n]=t:e.push(t)}return e},[R,x]),D=i.useMemo(()=>void 0!==r?r:(null==C?void 0:C.scale)??1,[r,null==C?void 0:C.scale]),P=i.useMemo(()=>{if(void 0!==a)return a;return(((null==A?void 0:A.rotation)??0)+((null==C?void 0:C.rotation)??0))%4},[a,null==A?void 0:A.rotation,null==C?void 0:C.rotation]);return n.jsxs("div",{style:{...e},...b,children:[n.jsx(H,{documentId:t,selectionMenu:l,groupSelectionMenu:c,pageIndex:o,scale:D,rotation:P,pageWidth:w,pageHeight:I,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:v,customAnnotationRenderer:f,annotationRenderers:z}),n.jsx(N,{documentId:t,pageIndex:o,scale:D}),n.jsx(q,{documentId:t,pageIndex:o,scale:D})]})},exports.AnnotationPluginPackage=Y,exports.AnnotationRendererProvider=v,exports.GroupSelectionBox=S,exports.createRenderer=C,exports.useAnnotation=e=>{var n;const{provides:o}=x(),[r,s]=i.useState((null==(n=null==o?void 0:o.forDocument(e))?void 0:n.getState())??t.initialDocumentState());return i.useEffect(()=>{if(!o)return;const t=o.forDocument(e);return s(t.getState()),t.onStateChange(e=>{s(e)})},[o,e]),{state:r,provides:(null==o?void 0:o.forDocument(e))??null}},exports.useAnnotationCapability=x,exports.useAnnotationPlugin=f,exports.useRegisterRenderers=function(e){const t=i.useContext(h),n=i.useRef(e);i.useEffect(()=>{if(t)return t(n.current)},[t])},exports.useRegisteredRenderers=y,exports.useRendererRegistry=function(){return i.useContext(h)},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"),n=require("preact/jsx-runtime"),o=require("preact"),i=require("preact/hooks"),r=require("preact/compat"),s=require("@embedpdf/core/preact"),a=require("@embedpdf/models"),l=require("@embedpdf/plugin-interaction-manager/preact"),c=require("@embedpdf/plugin-selection/preact"),d=require("@embedpdf/utils/preact"),u=require("@embedpdf/utils"),p={},h=o.createContext(null),g=o.createContext([]);function v({children:e}){const[t,o]=i.useState([]),r=i.useCallback(e=>(o(t=>{const n=new Set(e.map(e=>e.id));return[...t.filter(e=>!n.has(e.id)),...e]}),()=>o(t=>t.filter(t=>!e.some(e=>e.id===t.id)))),[]);return n.jsx(h.Provider,{value:r,children:n.jsx(g.Provider,{value:t,children:e})})}function f(){return i.useContext(g)}const y=()=>s.usePlugin(t.AnnotationPlugin.id),x=()=>s.useCapability(t.AnnotationPlugin.id);let b;function m(){return void 0===b&&(b=function(){try{const e=navigator;return/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1}catch{return!1}}()),b}function k(e,t){const n=m();return i.useMemo(()=>{const o=n&&t&&e>0&&e<16,i=o?e/16:1;return{needsComp:o,adjustedFontPx:o?16:e,scaleComp:i,wrapperStyle:o?{width:100/i+"%",height:100/i+"%",transform:`scale(${i})`,transformOrigin:"top left"}:void 0}},[n,t,e])}function j({appearance:e,style:t}){const[o,r]=i.useState(null),s=i.useRef(null);i.useEffect(()=>{const t=URL.createObjectURL(e.data);return r(t),s.current=t,()=>{s.current&&(URL.revokeObjectURL(s.current),s.current=null)}},[e.data]);return o?n.jsx("img",{src:o,onLoad:()=>{s.current&&(URL.revokeObjectURL(s.current),s.current=null)},style:{position:"absolute",width:"100%",height:"100%",display:"block",pointerEvents:"none",userSelect:"none",...t}}):null}function S({scale:e,documentId:t,pageIndex:o,rotation:l,pageWidth:c,pageHeight:p,trackedAnnotation:h,children:g,isSelected:v,isEditing:f=!1,isMultiSelected:b=!1,isDraggable:m,isResizable:k,isRotatable:S=!0,lockAspectRatio:C=!1,style:A={},blendMode:w,vertexConfig:I,selectionMenu:R,outlineOffset:P=1,onDoubleClick:z,onSelect:D,appearance:E,zIndex:M=1,resizeUI:L,vertexUI:$,rotationUI:O,selectionOutlineColor:F,selectionOutline:W,customAnnotationRenderer:B,groupSelectionMenu:U,groupSelectionOutline:T,annotationRenderers:H,...N}){var G,q,Y;const[V,X]=i.useState(h.object),[K,Z]=i.useState(null),[Q,_]=i.useState(null),[J,ee]=i.useState(!1),[te,ne]=i.useState(!1),{provides:oe}=x(),{plugin:ie}=y(),{canModifyAnnotations:re}=s.useDocumentPermissions(t),se=i.useRef(null),ae=re&&m&&!b,le=re&&k&&!b,ce=re&&S&&!b,de=i.useMemo(()=>oe?oe.forDocument(t):null,[oe,t]),ue=V?{...h.object,...V}:h.object,pe=h.object.flags??[],he=pe.includes("noZoom"),ge=pe.includes("noRotate"),ve=he?1:e,fe=ge?0:l,ye=(null==L?void 0:L.color)??"#007ACC",xe=(null==$?void 0:$.color)??"#007ACC",be=(null==O?void 0:O.color)??"white",me=(null==O?void 0:O.connectorColor)??"#007ACC",ke=(null==L?void 0:L.size)??12,je=(null==$?void 0:$.size)??12,Se=(null==O?void 0:O.size)??32,Ce=null==O?void 0:O.margin,Ae=(null==O?void 0:O.iconColor)??"#007ACC",we=(null==O?void 0:O.showConnector)??!1,Ie=(null==(G=null==O?void 0:O.border)?void 0:G.color)??"#007ACC",Re=(null==(q=null==O?void 0:O.border)?void 0:q.width)??1,Pe=(null==(Y=null==O?void 0:O.border)?void 0:Y.style)??"solid",ze=(null==W?void 0:W.color)??F??"#007ACC",De=(null==W?void 0:W.style)??"solid",Ee=(null==W?void 0:W.width)??1,Me=(null==W?void 0:W.offset)??P??1,Le=K??ue.rotation??0,$e=K??ue.rotation??0,Oe=Number.isFinite($e)?Math.round(10*$e)/10:0,Fe=null!==K,We=i.useRef(null),Be=i.useCallback(e=>{var n;if(!(null==(n=e.transformData)?void 0:n.type)||b||!ie)return;const{type:i,changes:r,metadata:s}=e.transformData,a=h.object.id,l={width:c,height:p};if("start"===e.state&&(We.current=h.object.unrotatedRect??h.object.rect,se.current=h.object,"resize"!==i&&"vertex-edit"!==i||ne(!0),"move"===i?ie.startDrag(t,{annotationIds:[a],pageSize:l}):"resize"===i&&ie.startResize(t,{annotationIds:[a],pageSize:l,resizeHandle:(null==s?void 0:s.handle)??"se"})),r.rect&&We.current)if("move"===i){const e={x:r.rect.origin.x-We.current.origin.x,y:r.rect.origin.y-We.current.origin.y};ie.updateDrag(t,e)}else"resize"===i&&ie.updateResize(t,r.rect);if("vertex-edit"===i&&r.vertices&&I){const t=se.current??h.object,n=I.transformAnnotation(t,r.vertices),l=null==oe?void 0:oe.transformAnnotation(t,{type:i,changes:n,metadata:s});l&&(X(e=>({...e,...l})),"end"===e.state&&(null==de||de.updateAnnotation(o,a,l)))}if("rotate"===i){const n=(null==s?void 0:s.rotationAngle)??Le,o=null==s?void 0:s.cursorPosition;return o&&_({x:o.clientX,y:o.clientY}),void("start"===e.state?(Z(n),ie.startRotation(t,{annotationIds:[a],cursorAngle:n,rotationCenter:null==s?void 0:s.rotationCenter})):"move"===e.state?(Z(n),ie.updateRotation(t,n,null==s?void 0:s.rotationDelta)):"end"===e.state&&(Z(null),_(null),ie.commitRotation(t)))}"end"===e.state&&(We.current=null,se.current=null,ne(!1),"move"===i?ie.commitDrag(t):"resize"===i&&ie.commitResize(t))},[ie,t,h.object,c,p,o,b,I,oe,de,Le]),Ue=ue.unrotatedRect,Te=Ue??ue.rect,He=Ue&&0!==Le?a.inferRotationCenterFromRects(Te,ue.rect,Le):void 0,Ne=Te,{dragProps:Ge,vertices:qe,resize:Ye,rotation:Ve}=d.useInteractionHandles({controller:{element:Ne,vertices:null==I?void 0:I.extractVertices(ue),constraints:{minWidth:10,minHeight:10,boundingBox:{width:c,height:p}},maintainAspectRatio:C,pageRotation:l,annotationRotation:Le,rotationCenter:He,rotationElement:ue.rect,scale:e,enabled:v&&!b,onUpdate:Be},resizeUI:{handleSize:ke,spacing:Me,offsetMode:"outside",includeSides:!C,zIndex:M+1},vertexUI:{vertexSize:je,zIndex:M+2},rotationUI:{handleSize:Se,margin:Ce,zIndex:M+3,showConnector:we},includeVertices:!!I,includeRotation:ce,currentRotation:Le}),Xe=i.useMemo(()=>{if(re&&z)return z},[re,z]),Ke=d.useDoublePressProps(Xe);i.useEffect(()=>{X(h.object)},[h.object]),i.useEffect(()=>{if(!ie)return;const e=h.object.id,n=n=>{var o;if(n.documentId!==t)return;"end"!==n.type&&"cancel"!==n.type||Z(null);const i=null==(o=n.previewPatches)?void 0:o[e];"update"===n.type&&i?X(e=>({...e,...i})):"cancel"===n.type&&X(h.object)},o=[ie.onDragChange(n),ie.onResizeChange(n),ie.onRotateChange(n)];return()=>o.forEach(e=>e())},[ie,t,h.object]);const Ze=v&&!b,Qe=ue.rect.size.width*ve,_e=ue.rect.size.height*ve,Je=Te.size.width*ve,et=Te.size.height*ve,tt=Boolean(Ue)&&0!==Le,nt=tt?(Te.origin.x-ue.rect.origin.x)*ve:(Qe-Je)/2,ot=tt?(Te.origin.y-ue.rect.origin.y)*ve:(_e-et)/2,it=tt&&He?`${(He.x-Te.origin.x)*ve}px ${(He.y-Te.origin.y)*ve}px`:"center center",rt=He?(He.x-ue.rect.origin.x)*ve:Qe/2,st=He?(He.y-ue.rect.origin.y)*ve:_e/2,at=Math.max(300,Math.max(Qe,_e)+80),lt=ge?u.getCounterRotation({origin:{x:0,y:0},size:{width:Qe,height:_e}},l):null,ct=i.useMemo(()=>Ue?{...ue,rect:Ue}:ue,[ue,Ue]),dt=!(!(null==E?void 0:E.normal)||te||f||h.dictMode),ut={position:"absolute",left:ue.rect.origin.x*e,top:ue.rect.origin.y*e,width:lt?lt.width:Qe,height:lt?lt.height:_e,pointerEvents:"none",zIndex:M,...lt&&{transform:lt.matrix,transformOrigin:"0 0"}},pt={position:"absolute",left:nt,top:ot,width:Je,height:et,transform:0!==Le?`rotate(${Le}deg)`:void 0,transformOrigin:it};return n.jsxs("div",{"data-no-interaction":!0,children:[n.jsx("div",{style:{...ut,...w&&{mixBlendMode:w},...A},children:n.jsxs("div",{style:{...pt,pointerEvents:f?"auto":"none"},children:[(()=>{const t="function"==typeof g?g(ct,{appearanceActive:dt}):g;return(null==B?void 0:B({annotation:ct,children:t,isSelected:v,scale:e,rotation:l,pageWidth:c,pageHeight:p,pageIndex:o,onSelect:D}))??t})(),(null==E?void 0:E.normal)&&n.jsx(j,{appearance:E.normal,style:{display:dt?"block":"none"}})]})}),n.jsxs("div",{style:ut,...N,children:[Fe&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:rt-at/2,top:st,width:at,height:1,backgroundColor:me,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:rt,top:st-at/2,width:1,height:at,backgroundColor:me,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:rt-at/2,top:st,width:at,height:1,transformOrigin:"center center",transform:`rotate(${Le}deg)`,backgroundColor:me,opacity:.8,pointerEvents:"none"}})]}),v&&ce&&Ve&&((null==O?void 0:O.component)?n.jsx("div",{onPointerEnter:()=>ee(!0),onPointerLeave:()=>{ee(!1),_(null)},onPointerMove:e=>{Fe||_({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:O.component({...Ve.handle,backgroundColor:be,iconColor:Ae,connectorStyle:{...Ve.connector.style,backgroundColor:me,opacity:Fe?0:1},showConnector:we,opacity:Fe?0:1,border:{color:Ie,width:Re,style:Pe}})}):n.jsxs("div",{onPointerEnter:()=>ee(!0),onPointerLeave:()=>{ee(!1),_(null)},onPointerMove:e=>{Fe||_({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[we&&n.jsx("div",{style:{...Ve.connector.style,backgroundColor:me,opacity:Fe?0:1}}),n.jsx("div",{...Ve.handle,style:{...Ve.handle.style,backgroundColor:be,border:`${Re}px ${Pe} ${Ie}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:Fe?0:1},children:n.jsxs("svg",{width:Math.round(.6*Se),height:Math.round(.6*Se),viewBox:"0 0 24 24",fill:"none",stroke:Ae,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),n.jsx("path",{d:"M21 3v5h-5"})]})})]})),n.jsxs("div",{...ae&&v?Ge:{},...Ke,style:{...pt,outline:Ze?`${Ee}px ${De} ${ze}`:"none",outlineOffset:Ze?`${Me}px`:"0px",pointerEvents:!v||b||f?"none":"auto",touchAction:"none",cursor:v&&ae?"move":"default"},children:[v&&le&&!Fe&&Ye.map(({key:e,...t})=>(null==L?void 0:L.component)?L.component({key:e,...t,backgroundColor:ye}):n.jsx("div",{...t,style:{...t.style,backgroundColor:ye}},e)),v&&re&&!b&&!Fe&&qe.map(({key:e,...t})=>(null==$?void 0:$.component)?$.component({key:e,...t,backgroundColor:xe}):n.jsx("div",{...t,style:{...t.style,backgroundColor:xe}},e))]})]}),R&&!b&&!Fe&&n.jsx(d.CounterRotate,{rect:{origin:{x:ue.rect.origin.x*e,y:ue.rect.origin.y*e},size:{width:ue.rect.size.width*ve,height:ue.rect.size.height*ve}},rotation:l,children:e=>{const t=((Le+90*fe)%360+360)%360;return R({...e,context:{type:"annotation",annotation:h,pageIndex:o},selected:v,placement:{suggestTop:ce&&t>90&&t<270}})}}),(Fe||J)&&Q&&r.createPortal(n.jsxs("div",{style:{position:"fixed",left:Q.x+16,top:Q.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[Oe.toFixed(0),"°"]}),document.body)]})}function C(e,t,n,o,i){switch(i){case 1:return{x:t,y:o-e};case 2:return{x:n-e,y:o-t};case 3:return{x:n-t,y:e};default:return{x:e,y:t}}}function A(e,t,n){const o=e.object.flags??[],i=o.includes("noZoom"),r=o.includes("noRotate"),s=e.object.rect.origin.x*t,a=e.object.rect.origin.y*t,l=e.object.rect.size.width*(i?1:t),c=e.object.rect.size.height*(i?1:t);if(!r||0===n)return{left:s,top:a,right:s+l,bottom:a+c};const d=[C(0,0,l,c,n),C(l,0,l,c,n),C(0,c,l,c,n),C(l,c,l,c,n)];let u=1/0,p=1/0,h=-1/0,g=-1/0;for(const v of d)v.x<u&&(u=v.x),v.y<p&&(p=v.y),v.x>h&&(h=v.x),v.y>g&&(g=v.y);return{left:s+u,top:a+p,right:s+h,bottom:a+g}}function w({documentId:e,pageIndex:t,scale:o,rotation:l,pageWidth:c,pageHeight:u,selectedAnnotations:p,isDraggable:h,isResizable:g,isRotatable:v=!0,lockAspectRatio:f=!1,resizeUI:x,rotationUI:b,selectionOutlineColor:m,outlineOffset:k,selectionOutline:j,zIndex:S=2,groupSelectionMenu:C}){var w,I,R;const{plugin:P}=y(),{canModifyAnnotations:z}=s.useDocumentPermissions(e),D=i.useRef(null),E=i.useRef(!1),M=i.useRef(!1),[L,$]=i.useState(null),[O,F]=i.useState(null),[W,B]=i.useState(!1),U=z&&h,T=z&&g,H=z&&v,N=i.useMemo(()=>{const e=p.map(e=>e.object.rect);return a.boundingRectOrEmpty(e)},[p]),[G,q]=i.useState(N);i.useEffect(()=>{E.current||M.current||q(N)},[N]),i.useEffect(()=>{if(!P)return;return P.onRotateChange(t=>{t.documentId===e&&("end"!==t.type&&"cancel"!==t.type||$(null))})},[P,e]);const Y=i.useCallback(t=>{var n,o,i,r,s,a;if(!(null==(n=t.transformData)?void 0:n.type))return;if(!P)return;const l=t.transformData.type,d="move"===l,h="resize"===l;if(d&&!U)return;if("start"===t.state&&(D.current=N,d?(E.current=!0,P.startDrag(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:c,height:u}})):h&&(M.current=!0,P.startResize(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:c,height:u},resizeHandle:(null==(o=t.transformData.metadata)?void 0:o.handle)??"se"}))),"rotate"===l){if(!v)return;const n=p.map(e=>e.object.id),o=(null==(i=t.transformData.metadata)?void 0:i.rotationAngle)??0,l=null==(r=t.transformData.metadata)?void 0:r.cursorPosition;return l&&F({x:l.clientX,y:l.clientY}),void("start"===t.state?($(o),P.startRotation(e,{annotationIds:n,cursorAngle:o,rotationCenter:null==(s=t.transformData.metadata)?void 0:s.rotationCenter})):"move"===t.state?($(o),P.updateRotation(e,o,null==(a=t.transformData.metadata)?void 0:a.rotationDelta)):"end"===t.state&&($(null),F(null),P.commitRotation(e)))}const g=D.current??N;if(d&&t.transformData.changes.rect){const n=t.transformData.changes.rect,o={x:n.origin.x-g.origin.x,y:n.origin.y-g.origin.y},i=P.updateDrag(e,o);q({...g,origin:{x:g.origin.x+i.x,y:g.origin.y+i.y}})}else if(h&&t.transformData.changes.rect){const n=t.transformData.changes.rect;P.updateResize(e,n),q(n)}"end"===t.state&&(D.current=null,d&&E.current?(E.current=!1,P.commitDrag(e)):h&&M.current&&(M.current=!1,P.commitResize(e)))},[P,e,c,u,N,U,p,v]),V=L??0,X=null!==L,K=Number.isFinite(V)?Math.round(10*V)/10:0,Z=(null==x?void 0:x.color)??"#007ACC",Q=(null==x?void 0:x.size)??12,_=(null==b?void 0:b.color)??"white",J=(null==b?void 0:b.connectorColor)??"#007ACC",ee=(null==b?void 0:b.size)??32,te=null==b?void 0:b.margin,ne=(null==b?void 0:b.iconColor)??"#007ACC",oe=(null==b?void 0:b.showConnector)??!1,ie=(null==(w=null==b?void 0:b.border)?void 0:w.color)??"#007ACC",re=(null==(I=null==b?void 0:b.border)?void 0:I.width)??1,se=(null==(R=null==b?void 0:b.border)?void 0:R.style)??"solid",ae=(null==j?void 0:j.color)??m??"#007ACC",le=(null==j?void 0:j.style)??"dashed",ce=(null==j?void 0:j.width)??2,de=(null==j?void 0:j.offset)??k??2,{dragProps:ue,resize:pe,rotation:he}=d.useInteractionHandles({controller:{element:G,constraints:{minWidth:20,minHeight:20,boundingBox:{width:c,height:u}},maintainAspectRatio:f,pageRotation:l,scale:o,enabled:!0,onUpdate:Y},resizeUI:{handleSize:Q,spacing:de,offsetMode:"outside",includeSides:!f,zIndex:S+1},vertexUI:{vertexSize:0,zIndex:S},rotationUI:{handleSize:ee,margin:te,zIndex:S+2,showConnector:oe},includeVertices:!1,includeRotation:H,currentRotation:L??0});if(p.length<2)return null;let ge=1/0,ve=1/0,fe=-1/0,ye=-1/0;for(const n of p){const e=A(n,o,l);ge=Math.min(ge,e.left),ve=Math.min(ve,e.top),fe=Math.max(fe,e.right),ye=Math.max(ye,e.bottom)}const xe=ge-N.origin.x*o,be=ve-N.origin.y*o,me=fe-(N.origin.x+N.size.width)*o,ke=ye-(N.origin.y+N.size.height)*o,je=G.origin.x*o+xe,Se=G.origin.y*o+be,Ce=G.size.width*o+(me-xe),Ae=G.size.height*o+(ke-be),we=Ce/2,Ie=Ae/2,Re=Math.max(300,Math.max(Ce,Ae)+80);return n.jsxs("div",{"data-group-selection-box":!0,"data-no-interaction":!0,children:[n.jsxs("div",{style:{position:"absolute",left:je,top:Se,width:Ce,height:Ae,pointerEvents:"none",zIndex:S},children:[X&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:we-Re/2,top:Ie,width:Re,height:1,backgroundColor:Z,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:we,top:Ie-Re/2,width:1,height:Re,backgroundColor:Z,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:we-Re/2,top:Ie,width:Re,height:1,transformOrigin:"center center",transform:`rotate(${V}deg)`,backgroundColor:Z,opacity:.8,pointerEvents:"none"}})]}),H&&he&&((null==b?void 0:b.component)?n.jsx("div",{onPointerEnter:()=>B(!0),onPointerLeave:()=>{B(!1),F(null)},onPointerMove:e=>{X||F({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:b.component({...he.handle,backgroundColor:_,iconColor:ne,connectorStyle:{...he.connector.style,backgroundColor:J,opacity:X?0:1},showConnector:oe,opacity:X?0:1,border:{color:ie,width:re,style:se}})}):n.jsxs("div",{onPointerEnter:()=>B(!0),onPointerLeave:()=>{B(!1),F(null)},onPointerMove:e=>{X||F({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[oe&&n.jsx("div",{style:{...he.connector.style,backgroundColor:J,opacity:X?0:1}}),n.jsx("div",{...he.handle,style:{...he.handle.style,backgroundColor:_,border:`${re}px ${se} ${ie}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:X?0:1},children:n.jsxs("svg",{width:Math.round(.6*ee),height:Math.round(.6*ee),viewBox:"0 0 24 24",fill:"none",stroke:ne,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),n.jsx("path",{d:"M21 3v5h-5"})]})})]})),n.jsx("div",{...U?ue:{onPointerDown:e=>e.stopPropagation()},style:{position:"absolute",left:0,top:0,width:Ce,height:Ae,outline:X?"none":`${ce}px ${le} ${ae}`,outlineOffset:de-1,cursor:U?"move":"default",touchAction:"none",pointerEvents:"auto"},children:T&&!X&&pe.map(({key:e,...t})=>(null==x?void 0:x.component)?x.component({key:e,...t,backgroundColor:Z}):n.jsx("div",{...t,style:{...t.style,backgroundColor:Z}},e))})]}),(X||W)&&O&&r.createPortal(n.jsxs("div",{style:{position:"fixed",left:O.x+16,top:O.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[K.toFixed(0),"°"]}),document.body),C&&!X&&n.jsx(d.CounterRotate,{rect:{origin:{x:je,y:Se},size:{width:Ce,height:Ae}},rotation:l,children:e=>{const n=((V+90*l)%360+360)%360;return C({...e,context:{type:"group",annotations:p,pageIndex:t},selected:!0,placement:{suggestTop:H&&n>90&&n<270}})}})]})}function I(e){return{id:e.id,matches:t=>e.matches(t),render:t=>e.render(t),renderPreview:e.renderPreview?t=>e.renderPreview(t):void 0,vertexConfig:e.vertexConfig,zIndex:e.zIndex,defaultBlendMode:e.defaultBlendMode,containerStyle:e.containerStyle,interactionDefaults:e.interactionDefaults,useAppearanceStream:e.useAppearanceStream,isDraggable:e.isDraggable,onDoubleClick:e.onDoubleClick,selectOverride:e.selectOverride,hideSelectionMenu:e.hideSelectionMenu,hiddenWhenLocked:e.hiddenWhenLocked,renderLocked:e.renderLocked?t=>e.renderLocked(t):void 0}}function R({isSelected:e,strokeColor:t,opacity:o=1,strokeWidth:r,inkList:s,rect:a,scale:l,onClick:c,appearanceActive:d=!1}){const u=t??"#000000",p=i.useMemo(()=>s.map(({points:e})=>{let t="";return e.forEach(({x:e,y:n},o)=>{const i=e-a.origin.x,r=n-a.origin.y;t+=(0===o?"M":"L")+i+" "+r+" "}),t.trim()}),[s,a]),h=a.size.width*l,g=a.size.height*l,v=Math.max(r,20/l);return n.jsxs("svg",{style:{position:"absolute",width:h,height:g,pointerEvents:"none",zIndex:2,overflow:"visible"},width:h,height:g,viewBox:`0 0 ${a.size.width} ${a.size.height}`,children:[p.map((t,o)=>n.jsx("path",{d:t,fill:"none",stroke:"transparent",strokeWidth:v,onPointerDown:c,style:{cursor:e?"move":c?"pointer":"default",pointerEvents:c?e?"none":"visibleStroke":"none",strokeLinecap:"round",strokeLinejoin:"round"}},`hit-${o}`)),!d&&p.map((e,t)=>n.jsx("path",{d:e,fill:"none",opacity:o,style:{pointerEvents:"none",stroke:u,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}},`vis-${t}`))]})}function P({isSelected:e,color:o="#000000",strokeColor:r,opacity:s=1,strokeWidth:l,strokeStyle:c=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,rect:u,scale:p,onClick:h,appearanceActive:g=!1,cloudyBorderIntensity:v,rectangleDifferences:f}){const y=(v??0)>0,{width:x,height:b,x:m,y:k}=i.useMemo(()=>{const e=u.size.width,t=u.size.height;return{width:Math.max(e-l,0),height:Math.max(t-l,0),x:l/2,y:l/2}},[u,l]),j=i.useMemo(()=>y?t.generateCloudyRectanglePath({x:0,y:0,width:u.size.width,height:u.size.height},f,v,l):null,[y,u,f,v,l]),S=u.size.width*p,C=u.size.height*p,A=Math.max(l,20/p);return n.jsxs("svg",{style:{position:"absolute",width:S,height:C,pointerEvents:"none",zIndex:2},width:S,height:C,viewBox:`0 0 ${u.size.width} ${u.size.height}`,overflow:"visible",children:[y&&j?n.jsx("path",{d:j.path,fill:"transparent",stroke:"transparent",strokeWidth:A,onPointerDown:h,style:{cursor:e?"move":h?"pointer":"default",pointerEvents:h?e?"none":"transparent"===o?"visibleStroke":"visible":"none"}}):n.jsx("rect",{x:m,y:k,width:x,height:b,fill:"transparent",stroke:"transparent",strokeWidth:A,onPointerDown:h,style:{cursor:e?"move":h?"pointer":"default",pointerEvents:h?e?"none":"transparent"===o?"visibleStroke":"visible":"none"}}),!g&&(y&&j?n.jsx("path",{d:j.path,fill:o,opacity:s,style:{pointerEvents:"none",stroke:r??o,strokeWidth:l,strokeLinejoin:"round"}}):n.jsx("rect",{x:m,y:k,width:x,height:b,fill:o,opacity:s,style:{pointerEvents:"none",stroke:r??o,strokeWidth:l,...c===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}))]})}function z({color:e="#000000",strokeColor:o,opacity:r=1,strokeWidth:s,strokeStyle:l=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:p,isSelected:h,appearanceActive:g=!1,cloudyBorderIntensity:v,rectangleDifferences:f}){const y=(v??0)>0,{width:x,height:b,cx:m,cy:k,rx:j,ry:S}=i.useMemo(()=>{const e=d.size.width,t=d.size.height,n=Math.max(e-s,0),o=Math.max(t-s,0);return{width:e,height:t,cx:s/2+n/2,cy:s/2+o/2,rx:n/2,ry:o/2}},[d,s]),C=i.useMemo(()=>y?t.generateCloudyEllipsePath({x:0,y:0,width:d.size.width,height:d.size.height},f,v,s):null,[y,d,f,v,s]),A=x*u,w=b*u,I=Math.max(s,20/u);return n.jsxs("svg",{style:{position:"absolute",width:A,height:w,pointerEvents:"none",zIndex:2},width:A,height:w,viewBox:`0 0 ${x} ${b}`,overflow:"visible",children:[y&&C?n.jsx("path",{d:C.path,fill:"transparent",stroke:"transparent",strokeWidth:I,onPointerDown:p,style:{cursor:h?"move":p?"pointer":"default",pointerEvents:p?h?"none":"transparent"===e?"visibleStroke":"visible":"none"}}):n.jsx("ellipse",{cx:m,cy:k,rx:j,ry:S,fill:"transparent",stroke:"transparent",strokeWidth:I,onPointerDown:p,style:{cursor:h?"move":p?"pointer":"default",pointerEvents:p?h?"none":"transparent"===e?"visibleStroke":"visible":"none"}}),!g&&(y&&C?n.jsx("path",{d:C.path,fill:e,opacity:r,style:{pointerEvents:"none",stroke:o??e,strokeWidth:s,strokeLinejoin:"round"}}):n.jsx("ellipse",{cx:m,cy:k,rx:j,ry:S,fill:e,opacity:r,style:{pointerEvents:"none",stroke:o??e,strokeWidth:s,...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}))]})}function D({color:e="transparent",opacity:o=1,strokeWidth:r,strokeColor:s="#000000",strokeStyle:l=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,linePoints:u,lineEndings:p,scale:h,onClick:g,isSelected:v,appearanceActive:f=!1}){const{x1:y,y1:x,x2:b,y2:m}=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]),k=i.useMemo(()=>{const e=Math.atan2(m-x,b-y);return{start:t.patching.createEnding(null==p?void 0:p.start,r,e+Math.PI,y,x),end:t.patching.createEnding(null==p?void 0:p.end,r,e,b,m)}},[p,r,y,x,b,m]),j=d.size.width*h,S=d.size.height*h,C=Math.max(r,20/h);return n.jsxs("svg",{style:{position:"absolute",width:j,height:S,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:S,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[n.jsx("line",{x1:y,y1:x,x2:b,y2:m,stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":g?"pointer":"default",pointerEvents:g?v?"none":"visibleStroke":"none",strokeLinecap:"butt"}}),k.start&&n.jsx("path",{d:k.start.d,transform:k.start.transform,fill:"transparent",stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":g?"pointer":"default",pointerEvents:g?v?"none":k.start.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"}}),k.end&&n.jsx("path",{d:k.end.d,transform:k.end.transform,fill:"transparent",stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":g?"pointer":"default",pointerEvents:g?v?"none":k.end.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"}}),!f&&n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:y,y1:x,x2:b,y2:m,opacity:o,style:{pointerEvents:"none",stroke:s,strokeWidth:r,strokeLinecap:"butt",...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),k.start&&n.jsx("path",{d:k.start.d,transform:k.start.transform,stroke:s,fill:k.start.filled?e:"none",style:{pointerEvents:"none",strokeWidth:r,strokeLinecap:"butt",...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),k.end&&n.jsx("path",{d:k.end.d,transform:k.end.transform,stroke:s,fill:k.end.filled?e:"none",style:{pointerEvents:"none",strokeWidth:r,strokeLinecap:"butt",...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})]})]})}function E({rect:e,vertices:o,color:r="transparent",strokeColor:s="#000000",opacity:l=1,strokeWidth:c,strokeStyle:d=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:u,scale:p,isSelected:h,onClick:g,lineEndings:v,appearanceActive:f=!1}){const y=i.useMemo(()=>o.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[o,e]),x=i.useMemo(()=>{if(!y.length)return"";const[e,...t]=y;return`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y} `).join("").trim()},[y]),b=i.useMemo(()=>{if(y.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),n=e(y[0],y[1]),o=e(y[y.length-2],y[y.length-1]);return{start:t.patching.createEnding(null==v?void 0:v.start,c,n+Math.PI,y[0].x,y[0].y),end:t.patching.createEnding(null==v?void 0:v.end,c,o,y[y.length-1].x,y[y.length-1].y)}},[y,v,c]),m=e.size.width*p,k=e.size.height*p,j=Math.max(c,20/p);return n.jsxs("svg",{style:{position:"absolute",width:m,height:k,pointerEvents:"none",zIndex:2,overflow:"visible"},width:m,height:k,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:j,onPointerDown:g,style:{cursor:h?"move":g?"pointer":"default",pointerEvents:g?h?"none":"visibleStroke":"none",strokeLinecap:"butt",strokeLinejoin:"miter"}}),b.start&&n.jsx("path",{d:b.start.d,transform:b.start.transform,fill:"transparent",stroke:"transparent",strokeWidth:j,onPointerDown:g,style:{cursor:h?"move":g?"pointer":"default",pointerEvents:g?h?"none":b.start.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"}}),b.end&&n.jsx("path",{d:b.end.d,transform:b.end.transform,fill:"transparent",stroke:"transparent",strokeWidth:j,onPointerDown:g,style:{cursor:h?"move":g?"pointer":"default",pointerEvents:g?h?"none":b.end.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"}}),!f&&n.jsxs(n.Fragment,{children:[n.jsx("path",{d:x,opacity:l,style:{fill:"none",stroke:s??r,strokeWidth:c,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...d===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),b.start&&n.jsx("path",{d:b.start.d,transform:b.start.transform,stroke:s,fill:b.start.filled?r:"none",style:{pointerEvents:"none",strokeWidth:c,strokeLinecap:"butt",...d===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),b.end&&n.jsx("path",{d:b.end.d,transform:b.end.transform,stroke:s,fill:b.end.filled?r:"none",style:{pointerEvents:"none",strokeWidth:c,strokeLinecap:"butt",...d===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}})]})]})}function M({rect:e,vertices:o,color:r="transparent",strokeColor:s="#000000",opacity:l=1,strokeWidth:c,strokeStyle:d=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:u,scale:p,isSelected:h,onClick:g,currentVertex:v,handleSize:f=14,appearanceActive:y=!1,cloudyBorderIntensity:x}){const b=(x??0)>0,m=v?[...o,v]:o,k=i.useMemo(()=>m.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[m,e]),j=i.useMemo(()=>{if(!k.length)return"";const[e,...t]=k,n=!!v;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(n?"":" Z")).trim()},[k,v]),S=i.useMemo(()=>!b||m.length<3?null:t.generateCloudyPolygonPath(m,e.origin,x,c),[b,m,e.origin,x,c]),C=v&&o.length>0,A=e.size.width*p,w=e.size.height*p,I=Math.max(c,20/p);return n.jsxs("svg",{style:{position:"absolute",width:A,height:w,pointerEvents:"none",zIndex:2,overflow:"visible"},width:A,height:w,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:b&&S?S.path:j,fill:"transparent",stroke:"transparent",strokeWidth:I,onPointerDown:g,style:{cursor:h?"move":g?"pointer":"default",pointerEvents:g?h?"none":"transparent"===r?"visibleStroke":"visible":"none",strokeLinecap:"butt",strokeLinejoin:"miter"}}),!y&&n.jsx(n.Fragment,{children:b&&S?n.jsx("path",{d:S.path,opacity:l,style:{fill:r,stroke:s??r,strokeWidth:c,pointerEvents:"none",strokeLinejoin:"round"}}):n.jsxs(n.Fragment,{children:[n.jsx("path",{d:j,opacity:l,style:{fill:v?"none":r,stroke:s??r,strokeWidth:c,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...d===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),C&&o.length>1&&n.jsx("path",{d:`M ${k[k.length-1].x} ${k[k.length-1].y} L ${k[0].x} ${k[0].y}`,fill:"none",style:{stroke:s,strokeWidth:c,strokeDasharray:"4,4",opacity:.7,pointerEvents:"none"}}),C&&o.length>=2&&n.jsx("rect",{x:k[0].x-f/p/2,y:k[0].y-f/p/2,width:f/p,height:f/p,fill:s,opacity:.4,stroke:s,strokeWidth:c/2,style:{pointerEvents:"none"}})]})})]})}function L({isSelected:e,color:t="#facc15",opacity:o=1,onClick:i,appearanceActive:r=!1}){const s=a.getContrastStrokeColor(t);return n.jsx("div",{style:{position:"absolute",inset:0,zIndex:2,pointerEvents:i?e?"none":"auto":"none",cursor:e?"move":i?"pointer":"default"},onPointerDown:i,children:!r&&n.jsxs("svg",{style:{position:"absolute",inset:0,pointerEvents:"none"},viewBox:"0 0 20 20",width:"100%",height:"100%",children:[n.jsx("path",{d:"M 0.5 15.5 L 0.5 0.5 L 19.5 0.5 L 19.5 15.5 L 8.5 15.5 L 6.5 19.5 L 4.5 15.5 Z",fill:t,opacity:o,stroke:s,strokeWidth:"1",strokeLinejoin:"miter"}),n.jsx("line",{x1:"2.5",y1:"4.25",x2:"17.5",y2:"4.25",stroke:s,strokeWidth:"1"}),n.jsx("line",{x1:"2.5",y1:"8",x2:"17.5",y2:"8",stroke:s,strokeWidth:"1"}),n.jsx("line",{x1:"2.5",y1:"11.75",x2:"17.5",y2:"11.75",stroke:s,strokeWidth:"1"})]})})}function $({documentId:e,isSelected:t,isEditing:o,annotation:r,pageIndex:s,scale:l,onClick:c,appearanceActive:d=!1}){const u=i.useRef(null),h=i.useRef(!1),{provides:g}=x(),v=(null==g?void 0:g.forDocument(e))??null,{adjustedFontPx:f,wrapperStyle:y}=k(r.object.fontSize*l,o);i.useEffect(()=>{var e;if(o&&u.current){h.current=!0;const t=u.current;t.focus();const n=null==v?void 0:v.findToolForAnnotation(r.object),o=null!=(null==(e=null==n?void 0:n.defaults)?void 0:e.contents)&&r.object.contents===n.defaults.contents,i=window.getSelection();if(i){const e=document.createRange();e.selectNodeContents(t),o||e.collapse(!1),i.removeAllRanges(),i.addRange(e)}}},[o]);return n.jsx("div",{style:{position:"absolute",width:r.object.rect.size.width*l,height:r.object.rect.size.height*l,cursor:t&&!o?"move":"default",pointerEvents:c?t&&!o?"none":"auto":"none",zIndex:2,opacity:d?0:1},onPointerDown:c,children:n.jsx("span",{ref:u,onBlur:()=>{h.current&&(h.current=!1,v&&u.current&&v.updateAnnotation(s,r.object.id,{contents:u.current.innerText.replace(/\u00A0/g," ")}))},tabIndex:0,style:{color:r.object.fontColor,fontSize:f,...a.standardFontCssProperties(r.object.fontFamily),textAlign:a.textAlignmentToCss(r.object.textAlign),flexDirection:"column",justifyContent:r.object.verticalAlign===a.PdfVerticalAlignment.Top?"flex-start":r.object.verticalAlign===a.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:r.object.color??r.object.backgroundColor,opacity:r.object.opacity,width:"100%",height:"100%",lineHeight:"1.18",overflow:"hidden",cursor:o?"text":c?"pointer":"default",outline:"none",...y},contentEditable:o,...p,children:r.object.contents})})}function O({documentId:e,pageIndex:t,annotation:r,scaleFactor:s=1,unrotated:l,style:c,...d}){const{provides:u}=x(),[p,h]=i.useState(null),g=i.useRef(null),{width:v,height:f}=r.rect.size;i.useEffect(()=>{if(u){const n=u.forDocument(e).renderAnnotation({pageIndex:t,annotation:r,options:{scaleFactor:s,dpr:window.devicePixelRatio,unrotated:l}});return n.wait(e=>{const t=URL.createObjectURL(e);h(t),g.current=t},a.ignore),()=>{g.current?(URL.revokeObjectURL(g.current),g.current=null):n.abort({code:a.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,s,l,u,e,r.id,v,f]);return n.jsx(o.Fragment,{children:p&&n.jsx("img",{src:p,onLoad:()=>{g.current&&(URL.revokeObjectURL(g.current),g.current=null)},...d,style:{width:"100%",height:"100%",display:"block",...c||{}}})})}function F({isSelected:e,annotation:t,documentId:o,pageIndex:i,scale:r,onClick:s}){const a=!!t.object.rotation&&!!t.object.unrotatedRect;return n.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:s?e?"none":"auto":"none",cursor:s?"pointer":"default"},onPointerDown:s,children:n.jsx(O,{documentId:o,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:r,unrotated:a})})}function W({isSelected:e,strokeColor:t="#0000FF",strokeWidth:o=2,strokeStyle:r=a.PdfAnnotationBorderStyle.UNDERLINE,strokeDashArray:s,rect:l,scale:c,onClick:d,hasIRT:u=!1}){const{width:p,height:h}=i.useMemo(()=>({width:l.size.width,height:l.size.height}),[l]),g=p*c,v=h*c,f=i.useMemo(()=>{if(r===a.PdfAnnotationBorderStyle.DASHED)return(null==s?void 0:s.join(","))??`${3*o},${o}`},[r,s,o]),y=r===a.PdfAnnotationBorderStyle.UNDERLINE;return n.jsxs("svg",{style:{position:"absolute",width:g,height:v,pointerEvents:"none",zIndex:2},width:g,height:v,viewBox:`0 0 ${p} ${h}`,children:[n.jsx("rect",{x:0,y:0,width:p,height:h,fill:"transparent",onPointerDown:u?void 0:d,style:{cursor:u||!d?"default":e?"move":"pointer",pointerEvents:u||!d||e?"none":"visible"}}),y?n.jsx("line",{x1:1,y1:h-1,x2:p-1,y2:h-1,stroke:t,strokeWidth:o,strokeDasharray:f,style:{pointerEvents:"none"}}):n.jsx("rect",{x:o/2,y:o/2,width:Math.max(p-o,0),height:Math.max(h-o,0),fill:"transparent",stroke:t,strokeWidth:o,strokeDasharray:f,style:{pointerEvents:"none"}})]})}function B({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00";return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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:l?"transparent":c,opacity:l?void 0:t,pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:void 0,...a}},o))})}function U({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00",d=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:d,background:c,opacity:t,pointerEvents:"none"}})},o))})}function T({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00",d=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:d,background:c,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},o))})}function H({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=2*r,d=6*r,u=`url("data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${2*c}" viewBox="0 0 ${d} ${2*c}">\n <path d="M0 ${c} Q ${d/4} 0 ${d/2} ${c} T ${d} ${c}"\n fill="none" stroke="${e??"#FFFF00"}" stroke-width="${c}" stroke-linecap="round"/>\n </svg>`)}")`;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:2*c,backgroundImage:u,backgroundRepeat:"repeat-x",backgroundSize:`${d}px ${2*c}px`,opacity:t,pointerEvents:"none"}})},o))})}function N({isSelected:e,strokeColor:t="#000000",opacity:o=1,rect:r,scale:s,onClick:a,appearanceActive:l=!1}){const{width:c,height:d,path:u}=i.useMemo(()=>{const e=r.size.width,t=r.size.height,n=e/2;return{width:e,height:t,path:[`M 0 ${t}`,`C ${.27*e} ${t} ${n} ${t-.44*t} ${n} 0`,`C ${n} ${t-.44*t} ${e-.27*e} ${t} ${e} ${t}`,"Z"].join(" ")}},[r]),p=c*s,h=d*s;return n.jsxs("svg",{style:{position:"absolute",width:p,height:h,pointerEvents:"none",zIndex:2},width:p,height:h,viewBox:`0 0 ${c} ${d}`,overflow:"visible",children:[n.jsx("path",{d:u,fill:"transparent",stroke:"transparent",strokeWidth:4,onPointerDown:a,style:{cursor:e?"move":a?"pointer":"default",pointerEvents:a?e?"none":"visible":"none"}}),!l&&n.jsx("path",{d:u,fill:t,stroke:t,strokeWidth:.5,opacity:o,fillRule:"evenodd",style:{pointerEvents:"none"}})]})}function G({annotation:e,documentId:t}){const{provides:o}=x(),r=i.useCallback(()=>{const n=e.object.target;n&&o&&o.forDocument(t).navigateTarget(n)},[e.object.target,o,t]);return n.jsx("div",{onClick:r,style:{width:"100%",height:"100%",cursor:"pointer",pointerEvents:"auto"}})}const q=[I({id:"ink",matches:e=>e.type===a.PdfAnnotationSubtype.INK,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(R,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),I({id:"square",matches:e=>e.type===a.PdfAnnotationSubtype.SQUARE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(P,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),I({id:"circle",matches:e=>e.type===a.PdfAnnotationSubtype.CIRCLE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(z,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),I({id:"line",matches:e=>e.type===a.PdfAnnotationSubtype.LINE,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(D,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),I({id:"polyline",matches:e=>e.type===a.PdfAnnotationSubtype.POLYLINE,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(E,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),I({id:"polygon",matches:e=>e.type===a.PdfAnnotationSubtype.POLYGON,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(M,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),I({id:"highlight",matches:e=>e.type===a.PdfAnnotationSubtype.HIGHLIGHT,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(B,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},defaultBlendMode:a.PdfBlendMode.Multiply}),I({id:"underline",matches:e=>e.type===a.PdfAnnotationSubtype.UNDERLINE,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(U,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),I({id:"strikeout",matches:e=>e.type===a.PdfAnnotationSubtype.STRIKEOUT,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(T,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),I({id:"squiggly",matches:e=>e.type===a.PdfAnnotationSubtype.SQUIGGLY,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(H,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),I({id:"text",matches:e=>e.type===a.PdfAnnotationSubtype.TEXT&&!e.inReplyToId,render:({currentObject:e,isSelected:t,onClick:o,appearanceActive:i})=>n.jsx(L,{isSelected:t,color:e.strokeColor??e.color,opacity:e.opacity,onClick:o,appearanceActive:i}),interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!1}}),I({id:"caret",matches:e=>e.type===a.PdfAnnotationSubtype.CARET,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(N,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),I({id:"freeText",matches:e=>e.type===a.PdfAnnotationSubtype.FREETEXT,render:({annotation:e,currentObject:t,isSelected:o,isEditing:i,scale:r,pageIndex:s,documentId:a,onClick:l,appearanceActive:c})=>n.jsx($,{documentId:a,isSelected:o,isEditing:i,annotation:{...e,object:t},pageIndex:s,scale:r,onClick:l,appearanceActive:c}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0},isDraggable:(e,{isEditing:t})=>e&&!t,onDoubleClick:(e,t)=>t(e)}),I({id:"stamp",matches:e=>e.type===a.PdfAnnotationSubtype.STAMP,render:({annotation:e,isSelected:t,documentId:o,pageIndex:i,scale:r,onClick:s})=>n.jsx(F,{isSelected:t,annotation:e,documentId:o,pageIndex:i,scale:r,onClick:s}),useAppearanceStream:!1,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),I({id:"link",matches:e=>e.type===a.PdfAnnotationSubtype.LINK,render:({currentObject:e,isSelected:t,scale:o,onClick:i})=>n.jsx(W,{...e,isSelected:t,scale:o,onClick:i,hasIRT:!!e.inReplyToId}),renderPreview:({data:e,bounds:t,scale:o})=>n.jsx("div",{style:{position:"absolute",left:0,top:0,width:t.size.width*o,height:t.size.height*o,borderBottom:`${e.strokeWidth*o}px solid ${e.strokeColor}`,backgroundColor:"rgba(0, 0, 255, 0.05)",boxSizing:"border-box"}}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!1},useAppearanceStream:!1,selectOverride:(e,t,n)=>{if(e.stopPropagation(),n.clearSelection(),t.object.inReplyToId){const e=n.allAnnotations.find(e=>e.object.id===t.object.inReplyToId);if(e)return void n.selectAnnotation(e.object.pageIndex,e.object.id)}n.selectAnnotation(n.pageIndex,t.object.id)},hideSelectionMenu:e=>!!e.inReplyToId,renderLocked:e=>n.jsx(G,{...e})})];function Y(e){const{documentId:o,pageIndex:r,scale:s,pageWidth:d,pageHeight:u,selectionMenu:p}=e,{provides:h}=x(),{provides:g}=c.useSelectionCapability(),[v,f]=i.useState([]),{register:y}=l.usePointerHandlers({documentId:o,pageIndex:r}),[b,m]=i.useState([]),[k,j]=i.useState(null),[C,A]=i.useState({}),[I,R]=i.useState({type:t.LockModeType.None}),P=i.useRef(s),z=i.useMemo(()=>h?h.forDocument(o):null,[h,o]),D=b.length>1;i.useEffect(()=>{if(z){const e=z.getState();return f(t.getAnnotationsByPageIndex(e,r)),m(t.getSelectedAnnotationIds(e)),R(e.locked),z.onStateChange(e=>{f(t.getAnnotationsByPageIndex(e,r)),m(t.getSelectedAnnotationIds(e)),R(e.locked)})}},[z,r]),i.useEffect(()=>{if(z)return z.onAnnotationEvent(e=>{"create"===e.type&&e.editAfterCreate&&j(e.annotation.id)})},[z]),i.useEffect(()=>{if(!z)return;P.current!==s&&(z.invalidatePageAppearances(r),P.current=s);z.getPageAppearances(r,{scaleFactor:s,dpr:"undefined"!=typeof window?window.devicePixelRatio:1}).wait(e=>A(e),()=>A({}))},[z,r,s]);const E=i.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&z&&(k&&v.some(e=>e.object.id===k)&&t.stopImmediatePropagation(),z.deselectAnnotation(),j(null))}}),[z,k,v]),M=i.useCallback((e,t)=>{if(e.stopPropagation(),z&&g){g.clear();"metaKey"in e&&(e.metaKey||e.ctrlKey)?z.toggleSelection(r,t.object.id):z.selectAnnotation(r,t.object.id),t.object.id!==k&&j(null)}},[z,g,k,r]);i.useEffect(()=>y(E,{documentId:o}),[y,E]);const L=i.useMemo(()=>v.filter(e=>b.includes(e.object.id)),[v,b]),$=i.useMemo(()=>!(L.length<2)&&L.every(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupDraggable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isDraggable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupDraggable)?o:i}),[L,z]),O=i.useMemo(()=>!(L.length<2)&&L.every(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupResizable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isResizable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupResizable)?o:i}),[L,z]),F=i.useMemo(()=>!(L.length<2)&&L.every(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupRotatable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isRotatable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupRotatable)?o:i}),[L,z]),W=i.useMemo(()=>!(L.length<2)&&L.some(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.lockGroupAspectRatio,e.object,!1),i=t.resolveInteractionProp(null==n?void 0:n.interaction.lockAspectRatio,e.object,!1);return void 0!==(null==n?void 0:n.interaction.lockGroupAspectRatio)?o:i}),[L,z]),B=i.useMemo(()=>{if(!z)return!1;const e=z.getSelectedAnnotations();return e.length>1&&e.every(e=>e.object.pageIndex===r)},[z,r,b]),U=i.useCallback(e=>{if(e.dictMode)return null;if(e.object.rotation&&e.object.unrotatedRect)return null;const t=C[e.object.id];return(null==t?void 0:t.normal)?t:null},[C]),T=i.useMemo(()=>{const t=e.annotationRenderers??[],n=new Set(t.map(e=>e.id));return[...t,...q.filter(e=>!n.has(e.id))]},[e.annotationRenderers]),H=i.useCallback(e=>T.find(t=>t.matches(e.object))??null,[T]),N=i.useMemo(()=>({defaultSelect:M,selectAnnotation:(e,t)=>null==z?void 0:z.selectAnnotation(e,t),clearSelection:()=>null==g?void 0:g.clear(),allAnnotations:v,pageIndex:r}),[M,z,g,v,r]);return n.jsxs(n.Fragment,{children:[v.map(i=>{var l,c,d;const u=H(i);if(!u)return null;const h=(null==z?void 0:z.findToolForAnnotation(i.object))??null,g=t.getAnnotationCategories(h),v=t.hasLockedFlag(i.object)||t.isCategoryLocked(g,I);if(v&&u.hiddenWhenLocked)return null;const f=v&&!!u.renderLocked,y=!v&&b.includes(i.object.id),x=!v&&k===i.object.id,m=u.interactionDefaults,C=t.resolveInteractionProp(null==h?void 0:h.interaction.isDraggable,i.object,(null==m?void 0:m.isDraggable)??!0),A=!v&&(u.isDraggable?u.isDraggable(C,{isEditing:x}):C),w=(null==(l=null==h?void 0:h.behavior)?void 0:l.useAppearanceStream)??u.useAppearanceStream??!0,R=f?void 0:w?U(i):void 0,P=v?e=>{e.stopPropagation()}:u.selectOverride?e=>u.selectOverride(e,i,N):e=>M(e,i);return n.jsx(S,{trackedAnnotation:i,isSelected:y,isEditing:x,isMultiSelected:!v&&D,isDraggable:A,isResizable:!v&&t.resolveInteractionProp(null==h?void 0:h.interaction.isResizable,i.object,(null==m?void 0:m.isResizable)??!1),lockAspectRatio:t.resolveInteractionProp(null==h?void 0:h.interaction.lockAspectRatio,i.object,(null==m?void 0:m.lockAspectRatio)??!1),isRotatable:!v&&t.resolveInteractionProp(null==h?void 0:h.interaction.isRotatable,i.object,(null==m?void 0:m.isRotatable)??!1),vertexConfig:v?void 0:u.vertexConfig,selectionMenu:v||(null==(c=u.hideSelectionMenu)?void 0:c.call(u,i.object))?void 0:p,onSelect:P,onDoubleClick:v?void 0:u.onDoubleClick?e=>{e.stopPropagation(),u.onDoubleClick(i.object.id,j)}:void 0,zIndex:u.zIndex,blendMode:a.blendModeToCss(i.object.blendMode??u.defaultBlendMode??a.PdfBlendMode.Normal),style:null==(d=u.containerStyle)?void 0:d.call(u,i.object),appearance:R,...e,children:(e,{appearanceActive:t})=>f?u.renderLocked({annotation:i,currentObject:e,isSelected:!1,isEditing:!1,scale:s,pageIndex:r,documentId:o,onClick:void 0,appearanceActive:t}):u.render({annotation:i,currentObject:e,isSelected:y,isEditing:x,scale:s,pageIndex:r,documentId:o,onClick:v?void 0:P,appearanceActive:t})},i.object.id)}),B&&L.length>=2&&n.jsx(w,{documentId:o,pageIndex:r,scale:s,rotation:e.rotation,pageWidth:d,pageHeight:u,selectedAnnotations:L,isDraggable:$,isResizable:O,isRotatable:F,lockAspectRatio:W,resizeUI:e.resizeUI,rotationUI:e.rotationUI,selectionOutlineColor:e.selectionOutlineColor,selectionOutline:e.groupSelectionOutline??e.selectionOutline,groupSelectionMenu:e.groupSelectionMenu})]})}function V({documentId:e,pageIndex:t,scale:o}){var r,s,l,d,u,p,h,g,v,f,y,b;const{provides:m}=c.useSelectionCapability(),{provides:k}=x(),[j,S]=i.useState([]),[C,A]=i.useState(null),[w,I]=i.useState(null);if(i.useEffect(()=>{if(m)return m.forDocument(e).onSelectionChange(()=>{S(m.forDocument(e).getHighlightRectsForPage(t)),A(m.forDocument(e).getBoundingRectForPage(t))})},[m,e,t]),i.useEffect(()=>{if(k)return I(k.forDocument(e).getActiveTool()),k.forDocument(e).onActiveToolChange(e=>I(e))},[k,e]),!C)return null;if(!w||!w.defaults)return null;switch(w.defaults.type){case a.PdfAnnotationSubtype.UNDERLINE:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(r=w.defaults)?void 0:r.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(U,{strokeColor:null==(s=w.defaults)?void 0:s.strokeColor,opacity:null==(l=w.defaults)?void 0:l.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.HIGHLIGHT:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(d=w.defaults)?void 0:d.blendMode)??a.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(B,{strokeColor:null==(u=w.defaults)?void 0:u.strokeColor,opacity:null==(p=w.defaults)?void 0:p.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.STRIKEOUT:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(h=w.defaults)?void 0:h.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(T,{strokeColor:null==(g=w.defaults)?void 0:g.strokeColor,opacity:null==(v=w.defaults)?void 0:v.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.SQUIGGLY:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(f=w.defaults)?void 0:f.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(H,{strokeColor:null==(y=w.defaults)?void 0:y.strokeColor,opacity:null==(b=w.defaults)?void 0:b.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.CARET:default:return null}}function X({toolId:e,preview:t,scale:o}){const{bounds:i}=t,r=f(),s={position:"absolute",left:i.origin.x*o,top:i.origin.y*o,width:i.size.width*o,height:i.size.height*o,pointerEvents:"none",zIndex:10};if(t.type===a.PdfAnnotationSubtype.CIRCLE)return n.jsx("div",{style:s,children:n.jsx(z,{isSelected:!1,scale:o,...t.data})});if(t.type===a.PdfAnnotationSubtype.SQUARE)return n.jsx("div",{style:s,children:n.jsx(P,{isSelected:!1,scale:o,...t.data})});if(t.type===a.PdfAnnotationSubtype.POLYGON)return n.jsx("div",{style:s,children:n.jsx(M,{isSelected:!1,scale:o,...t.data})});if(t.type===a.PdfAnnotationSubtype.POLYLINE)return n.jsx("div",{style:s,children:n.jsx(E,{isSelected:!1,scale:o,...t.data})});if(t.type===a.PdfAnnotationSubtype.LINE)return n.jsx("div",{style:s,children:n.jsx(D,{isSelected:!1,scale:o,...t.data})});if(t.type===a.PdfAnnotationSubtype.INK)return n.jsx("div",{style:{...s,mixBlendMode:a.blendModeToCss(t.data.blendMode??a.PdfBlendMode.Normal)},children:n.jsx(R,{isSelected:!1,scale:o,...t.data})});if(t.type===a.PdfAnnotationSubtype.FREETEXT)return n.jsx("div",{style:s,children:n.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${t.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})});const l=r.find(t=>t.id===e&&t.renderPreview);return(null==l?void 0:l.renderPreview)?n.jsx("div",{style:s,children:l.renderPreview({data:t.data,bounds:t.bounds,scale:o})}):null}function K({documentId:e,pageIndex:t,scale:o}){const{plugin:r}=y(),[s,a]=i.useState(new Map),l=i.useRef(null),c=i.useRef(null),d=i.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!l.current)return;const n=l.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 r=i.getContext("2d");if(!r)return;const s=new Image;s.crossOrigin="Anonymous",s.onload=()=>{let{naturalWidth:a,naturalHeight:l}=s;const c=t?t/a:1,d=n?n/l:1,u=Math.min(c,d,1),p=a*u,h=l*u;i.width=p,i.height=h,r.drawImage(s,0,0,p,h);const g=r.getImageData(0,0,p,h);"string"!=typeof e&&URL.revokeObjectURL(s.src),o({imageData:g,width:p,height:h})},s.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return i.useEffect(()=>{if(r)return r.registerPageHandlers(e,t,o,{services:d,onPreview:(e,t)=>{a(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,o,r,d]),n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:l,type:"file",style:{display:"none"}}),n.jsx("canvas",{ref:c,style:{display:"none"}}),Array.from(s.entries()).map(([e,t])=>n.jsx(X,{toolId:e,preview:t,scale:o},e))]})}const Z=e.createPluginPackage(t.AnnotationPluginPackage).addWrapper(v).addUtility(function(){const{plugin:e}=y(),{provides:t}=x();return i.useEffect(()=>{if(t&&e)return t.onNavigate(t=>{"uri"===t.result.outcome&&!1!==e.config.autoOpenLinks&&window.open(t.result.uri,"_blank","noopener,noreferrer")})},[t,e]),null}).build();exports.AnnotationLayer=function({style:e,documentId:t,pageIndex:o,scale:r,rotation:a,selectionMenu:l,groupSelectionMenu:c,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:v,customAnnotationRenderer:y,annotationRenderers:x,...b}){var m,k,j,S;const C=s.useDocumentState(t),A=null==(k=null==(m=null==C?void 0:C.document)?void 0:m.pages)?void 0:k[o],w=(null==(j=null==A?void 0:A.size)?void 0:j.width)??0,I=(null==(S=null==A?void 0:A.size)?void 0:S.height)??0,R=f(),P=i.useMemo(()=>{const e=[...R];for(const t of x??[]){const n=e.findIndex(e=>e.id===t.id);n>=0?e[n]=t:e.push(t)}return e},[R,x]),z=i.useMemo(()=>void 0!==r?r:(null==C?void 0:C.scale)??1,[r,null==C?void 0:C.scale]),D=i.useMemo(()=>{if(void 0!==a)return a;return(((null==A?void 0:A.rotation)??0)+((null==C?void 0:C.rotation)??0))%4},[a,null==A?void 0:A.rotation,null==C?void 0:C.rotation]);return n.jsxs("div",{style:{...e},...b,children:[n.jsx(Y,{documentId:t,selectionMenu:l,groupSelectionMenu:c,pageIndex:o,scale:z,rotation:D,pageWidth:w,pageHeight:I,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:v,customAnnotationRenderer:y,annotationRenderers:P}),n.jsx(V,{documentId:t,pageIndex:o,scale:z}),n.jsx(K,{documentId:t,pageIndex:o,scale:z})]})},exports.AnnotationPluginPackage=Z,exports.AnnotationRendererProvider=v,exports.GroupSelectionBox=w,exports.createRenderer=I,exports.useAnnotation=e=>{var n;const{provides:o}=x(),[r,s]=i.useState((null==(n=null==o?void 0:o.forDocument(e))?void 0:n.getState())??t.initialDocumentState());return i.useEffect(()=>{if(!o)return;const t=o.forDocument(e);return s(t.getState()),t.onStateChange(e=>{s(e)})},[o,e]),{state:r,provides:(null==o?void 0:o.forDocument(e))??null}},exports.useAnnotationCapability=x,exports.useAnnotationPlugin=y,exports.useIOSZoomPrevention=k,exports.useRegisterRenderers=function(e){const t=i.useContext(h),n=i.useRef(e);i.useEffect(()=>{if(t)return t(n.current)},[t])},exports.useRegisteredRenderers=f,exports.useRendererRegistry=function(){return i.useContext(h)},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
|