@embedpdf/plugin-annotation 2.14.0 → 2.14.2
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 +73 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/annotation-plugin.d.ts +25 -0
- package/dist/lib/helpers.d.ts +8 -0
- package/dist/lib/types.d.ts +21 -2
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +27 -18
- 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 +27 -18
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/annotation-container.d.ts +13 -1
- package/dist/shared/components/types.d.ts +12 -0
- package/dist/shared-preact/components/annotation-container.d.ts +13 -1
- package/dist/shared-preact/components/types.d.ts +12 -0
- package/dist/shared-react/components/annotation-container.d.ts +13 -1
- package/dist/shared-react/components/types.d.ts +12 -0
- package/dist/svelte/components/types.d.ts +12 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +31 -20
- package/dist/svelte/index.js.map +1 -1
- package/dist/svelte/types.d.ts +12 -0
- package/dist/vue/components/annotation-container.vue.d.ts +12 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +57 -41
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/types.d.ts +12 -0
- package/package.json +12 -12
|
@@ -253,6 +253,31 @@ export declare class AnnotationPlugin extends BasePlugin<AnnotationPluginConfig,
|
|
|
253
253
|
setLocked(mode: LockMode, documentId?: string): void;
|
|
254
254
|
getLocked(documentId?: string): LockMode;
|
|
255
255
|
isAnnotationLocked(annotation: PdfAnnotationObject, documentId?: string): boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Whether the annotation can be interacted with at all (selected, edited, menu shown).
|
|
258
|
+
* Returns false for `noView`, `hidden`, `readOnly`, or category-locked annotations.
|
|
259
|
+
* This is the spec-compliant "can the user do anything with this?" predicate.
|
|
260
|
+
*/
|
|
261
|
+
isAnnotationInteractive(annotation: PdfAnnotationObject, documentId?: string): boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Whether the annotation's structure (position, size, rotation, vertices) is locked.
|
|
264
|
+
* Non-interactive annotations are treated as structurally locked. PDF `locked` flag
|
|
265
|
+
* makes an otherwise-interactive annotation structurally locked while still selectable.
|
|
266
|
+
*/
|
|
267
|
+
isAnnotationStructurallyLocked(annotation: PdfAnnotationObject, documentId?: string): boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Whether the annotation's content (e.g. FreeText text) is locked.
|
|
270
|
+
* Non-interactive annotations are treated as content-locked. PDF `lockedContents`
|
|
271
|
+
* flag blocks content edits while still allowing move/resize.
|
|
272
|
+
*/
|
|
273
|
+
isAnnotationContentLocked(annotation: PdfAnnotationObject, documentId?: string): boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Whether a specific annotation is eligible to be added to the selection store.
|
|
276
|
+
* Differs from the subtype-based `isSelectableAnnotation` helper: that answers
|
|
277
|
+
* "is this subtype ever selectable?", while this answers "is this specific
|
|
278
|
+
* annotation selectable right now given its flags and document lock state?".
|
|
279
|
+
*/
|
|
280
|
+
private isAnnotationSelectable;
|
|
256
281
|
isCategoryLockedMethod(category: string, documentId?: string): boolean;
|
|
257
282
|
isToolLockedMethod(toolId: string, documentId?: string): boolean;
|
|
258
283
|
syncAnnotationObject(id: string, patch: Partial<PdfAnnotationObject>, documentId?: string): void;
|
package/dist/lib/helpers.d.ts
CHANGED
|
@@ -36,3 +36,11 @@ export declare function getAnnotationCategories(tool: AnnotationTool | null): st
|
|
|
36
36
|
export declare function isCategoryLocked(categories: string[], mode: LockMode): boolean;
|
|
37
37
|
/** Check if the annotation itself has the PDF 'locked' flag (bit 7). */
|
|
38
38
|
export declare function hasLockedFlag(annotation: PdfAnnotationObject): boolean;
|
|
39
|
+
/** Check if the annotation has the PDF 'noView' flag (bit 6). */
|
|
40
|
+
export declare function hasNoViewFlag(annotation: PdfAnnotationObject): boolean;
|
|
41
|
+
/** Check if the annotation has the PDF 'hidden' flag (bit 2): do not render, do not interact, do not print. */
|
|
42
|
+
export declare function hasHiddenFlag(annotation: PdfAnnotationObject): boolean;
|
|
43
|
+
/** Check if the annotation has the PDF 'readOnly' flag (bit 7): do not allow user interaction. Ignored for widgets per spec. */
|
|
44
|
+
export declare function hasReadOnlyFlag(annotation: PdfAnnotationObject): boolean;
|
|
45
|
+
/** Check if the annotation has the PDF 'lockedContents' flag (bit 10): content cannot be modified by the user. */
|
|
46
|
+
export declare function hasLockedContentsFlag(annotation: PdfAnnotationObject): boolean;
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -330,8 +330,19 @@ export interface AnnotationScope<TTools extends AnnotationToolMap = AnnotationTo
|
|
|
330
330
|
setLocked(mode: LockMode): void;
|
|
331
331
|
/** Get the current lock mode for this document */
|
|
332
332
|
getLocked(): LockMode;
|
|
333
|
-
/** Check if a specific annotation is locked (category-based or per-annotation flag)
|
|
333
|
+
/** Check if a specific annotation is locked (category-based or per-annotation flag).
|
|
334
|
+
* Legacy predicate kept for backward compatibility. Use `isAnnotationInteractive`,
|
|
335
|
+
* `isAnnotationStructurallyLocked`, or `isAnnotationContentLocked` for spec-aligned checks. */
|
|
334
336
|
isAnnotationLocked(annotation: PdfAnnotationObject): boolean;
|
|
337
|
+
/** Whether the annotation can be interacted with at all. False for `noView`, `hidden`,
|
|
338
|
+
* `readOnly`, or category-locked annotations. */
|
|
339
|
+
isAnnotationInteractive(annotation: PdfAnnotationObject): boolean;
|
|
340
|
+
/** Whether the annotation's structure (move/resize/rotate/vertex) is locked. True if
|
|
341
|
+
* non-interactive or the PDF `locked` flag is set. */
|
|
342
|
+
isAnnotationStructurallyLocked(annotation: PdfAnnotationObject): boolean;
|
|
343
|
+
/** Whether the annotation's content (e.g. FreeText text) is locked. True if
|
|
344
|
+
* non-interactive or the PDF `lockedContents` flag is set. */
|
|
345
|
+
isAnnotationContentLocked(annotation: PdfAnnotationObject): boolean;
|
|
335
346
|
/** Check if a single category is locked under the current mode */
|
|
336
347
|
isCategoryLocked(category: string): boolean;
|
|
337
348
|
/** Check if a tool (by ID) is locked under the current mode (resolves tool categories) */
|
|
@@ -415,8 +426,16 @@ export interface AnnotationCapability<TTools extends AnnotationToolMap = Annotat
|
|
|
415
426
|
setLocked: (mode: LockMode, documentId?: string) => void;
|
|
416
427
|
/** Get the current lock mode */
|
|
417
428
|
getLocked: (documentId?: string) => LockMode;
|
|
418
|
-
/** Check if a specific annotation is locked (category-based or per-annotation flag)
|
|
429
|
+
/** Check if a specific annotation is locked (category-based or per-annotation flag).
|
|
430
|
+
* Legacy predicate kept for backward compatibility. */
|
|
419
431
|
isAnnotationLocked: (annotation: PdfAnnotationObject, documentId?: string) => boolean;
|
|
432
|
+
/** Whether the annotation can be interacted with at all. False for `noView`, `hidden`,
|
|
433
|
+
* `readOnly`, or category-locked annotations. */
|
|
434
|
+
isAnnotationInteractive: (annotation: PdfAnnotationObject, documentId?: string) => boolean;
|
|
435
|
+
/** Whether the annotation's structure (move/resize/rotate/vertex) is locked. */
|
|
436
|
+
isAnnotationStructurallyLocked: (annotation: PdfAnnotationObject, documentId?: string) => boolean;
|
|
437
|
+
/** Whether the annotation's content (e.g. FreeText text) is locked. */
|
|
438
|
+
isAnnotationContentLocked: (annotation: PdfAnnotationObject, documentId?: string) => boolean;
|
|
420
439
|
/** Check if a single category is locked under the current mode */
|
|
421
440
|
isCategoryLocked: (category: string, documentId?: string) => boolean;
|
|
422
441
|
/** Check if a tool (by ID) is locked under the current mode (resolves tool categories) */
|
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 f(){return i.useContext(g)}const x=()=>s.usePlugin(t.AnnotationPlugin.id),y=()=>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 w({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:w=!0,lockAspectRatio:S=!1,style:C={},blendMode:A,vertexConfig:P,selectionMenu:I,outlineOffset:z=1,onDoubleClick:R,onSelect:E,appearance:D,zIndex:M=1,resizeUI:L,vertexUI:$,rotationUI:F,selectionOutlineColor:O,selectionOutline:W,customAnnotationRenderer:B,groupSelectionMenu:T,groupSelectionOutline:U,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}=y(),{plugin:ie}=x(),{canModifyAnnotations:re}=s.useDocumentPermissions(t),se=i.useRef(null),ae=re&&m&&!b,le=re&&k&&!b,ce=re&&w&&!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,xe=(null==L?void 0:L.color)??"#007ACC",ye=(null==$?void 0:$.color)??"#007ACC",be=(null==F?void 0:F.color)??"white",me=(null==F?void 0:F.connectorColor)??"#007ACC",ke=(null==L?void 0:L.size)??12,je=(null==$?void 0:$.size)??12,we=(null==F?void 0:F.size)??32,Se=null==F?void 0:F.margin,Ce=(null==F?void 0:F.iconColor)??"#007ACC",Ae=(null==F?void 0:F.showConnector)??!1,Pe=(null==(G=null==F?void 0:F.border)?void 0:G.color)??"#007ACC",Ie=(null==(q=null==F?void 0:F.border)?void 0:q.width)??1,ze=(null==(Y=null==F?void 0:F.border)?void 0:Y.style)??"solid",Re=(null==W?void 0:W.color)??O??"#007ACC",Ee=(null==W?void 0:W.style)??"solid",De=(null==W?void 0:W.width)??1,Me=(null==W?void 0:W.offset)??z??1,Le=K??ue.rotation??0,$e=K??ue.rotation??0,Fe=Number.isFinite($e)?Math.round(10*$e)/10:0,Oe=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&&P){const t=se.current??h.object,n=P.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,P,oe,de,Le]),Te=ue.unrotatedRect,Ue=Te??ue.rect,He=Te&&0!==Le?a.inferRotationCenterFromRects(Ue,ue.rect,Le):void 0,Ne=Ue,{dragProps:Ge,vertices:qe,resize:Ye,rotation:Ve}=d.useInteractionHandles({controller:{element:Ne,vertices:null==P?void 0:P.extractVertices(ue),constraints:{minWidth:10,minHeight:10,boundingBox:{width:c,height:p}},maintainAspectRatio:S,pageRotation:l,annotationRotation:Le,rotationCenter:He,rotationElement:ue.rect,scale:e,enabled:v&&!b,onUpdate:Be},resizeUI:{handleSize:ke,spacing:Me,offsetMode:"outside",includeSides:!S,zIndex:M+1},vertexUI:{vertexSize:je,zIndex:M+2},rotationUI:{handleSize:we,margin:Se,zIndex:M+3,showConnector:Ae},includeVertices:!!P,includeRotation:ce,currentRotation:Le}),Xe=i.useMemo(()=>{if(re&&R)return R},[re,R]),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=Ue.size.width*ve,et=Ue.size.height*ve,tt=Boolean(Te)&&0!==Le,nt=tt?(Ue.origin.x-ue.rect.origin.x)*ve:(Qe-Je)/2,ot=tt?(Ue.origin.y-ue.rect.origin.y)*ve:(_e-et)/2,it=tt&&He?`${(He.x-Ue.origin.x)*ve}px ${(He.y-Ue.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(()=>Te?{...ue,rect:Te}:ue,[ue,Te]),dt=!(!(null==D?void 0:D.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,...A&&{mixBlendMode:A},...C},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:E}))??t})(),(null==D?void 0:D.normal)&&n.jsx(j,{appearance:D.normal,style:{display:dt?"block":"none"}})]})}),n.jsxs("div",{style:ut,...N,children:[Oe&&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==F?void 0:F.component)?n.jsx("div",{onPointerEnter:()=>ee(!0),onPointerLeave:()=>{ee(!1),_(null)},onPointerMove:e=>{Oe||_({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:F.component({...Ve.handle,backgroundColor:be,iconColor:Ce,connectorStyle:{...Ve.connector.style,backgroundColor:me,opacity:Oe?0:1},showConnector:Ae,opacity:Oe?0:1,border:{color:Pe,width:Ie,style:ze}})}):n.jsxs("div",{onPointerEnter:()=>ee(!0),onPointerLeave:()=>{ee(!1),_(null)},onPointerMove:e=>{Oe||_({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[Ae&&n.jsx("div",{style:{...Ve.connector.style,backgroundColor:me,opacity:Oe?0:1}}),n.jsx("div",{...Ve.handle,style:{...Ve.handle.style,backgroundColor:be,border:`${Ie}px ${ze} ${Pe}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:Oe?0:1},children:n.jsxs("svg",{width:Math.round(.6*we),height:Math.round(.6*we),viewBox:"0 0 24 24",fill:"none",stroke:Ce,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?`${De}px ${Ee} ${Re}`:"none",outlineOffset:Ze?`${Me}px`:"0px",pointerEvents:!v||b||f?"none":"auto",touchAction:"none",cursor:v&&ae?"move":"default"},children:[v&&le&&!Oe&&Ye.map(({key:e,...t})=>(null==L?void 0:L.component)?L.component({key:e,...t,backgroundColor:xe}):n.jsx("div",{...t,style:{...t.style,backgroundColor:xe}},e)),v&&re&&!b&&!Oe&&qe.map(({key:e,...t})=>(null==$?void 0:$.component)?$.component({key:e,...t,backgroundColor:ye}):n.jsx("div",{...t,style:{...t.style,backgroundColor:ye}},e))]})]}),I&&!b&&!Oe&&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 I({...e,context:{type:"annotation",annotation:h,pageIndex:o},selected:v,placement:{suggestTop:ce&&t>90&&t<270}})}}),(Oe||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:[Fe.toFixed(0),"°"]}),document.body)]})}function S(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 C(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=[S(0,0,l,c,n),S(l,0,l,c,n),S(0,c,l,c,n),S(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 A({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:y,rotationUI:b,selectionOutlineColor:m,outlineOffset:k,selectionOutline:j,zIndex:w=2,groupSelectionMenu:S}){var A,P,I;const{plugin:z}=x(),{canModifyAnnotations:R}=s.useDocumentPermissions(e),E=i.useRef(null),D=i.useRef(!1),M=i.useRef(!1),[L,$]=i.useState(null),[F,O]=i.useState(null),[W,B]=i.useState(!1),T=R&&h,U=R&&g,H=R&&v,N=i.useMemo(()=>{const e=p.map(e=>e.object.rect);return a.boundingRectOrEmpty(e)},[p]),[G,q]=i.useState(N);i.useEffect(()=>{D.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&&!T)return;if("start"===t.state&&(E.current=N,d?(D.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&&O({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),O(null),z.commitRotation(e)))}const g=E.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&&(E.current=null,d&&D.current?(D.current=!1,z.commitDrag(e)):h&&M.current&&(M.current=!1,z.commitResize(e)))},[z,e,c,u,N,T,p,v]),V=L??0,X=null!==L,K=Number.isFinite(V)?Math.round(10*V)/10:0,Z=(null==y?void 0:y.color)??"#007ACC",Q=(null==y?void 0:y.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==(A=null==b?void 0:b.border)?void 0:A.color)??"#007ACC",re=(null==(P=null==b?void 0:b.border)?void 0:P.width)??1,se=(null==(I=null==b?void 0:b.border)?void 0:I.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:w+1},vertexUI:{vertexSize:0,zIndex:w},rotationUI:{handleSize:ee,margin:te,zIndex:w+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,xe=-1/0;for(const n of p){const e=C(n,o,l);ge=Math.min(ge,e.left),ve=Math.min(ve,e.top),fe=Math.max(fe,e.right),xe=Math.max(xe,e.bottom)}const ye=ge-N.origin.x*o,be=ve-N.origin.y*o,me=fe-(N.origin.x+N.size.width)*o,ke=xe-(N.origin.y+N.size.height)*o,je=G.origin.x*o+ye,we=G.origin.y*o+be,Se=G.size.width*o+(me-ye),Ce=G.size.height*o+(ke-be),Ae=Se/2,Pe=Ce/2,Ie=Math.max(300,Math.max(Se,Ce)+80);return n.jsxs("div",{"data-group-selection-box":!0,"data-no-interaction":!0,children:[n.jsxs("div",{style:{position:"absolute",left:je,top:we,width:Se,height:Ce,pointerEvents:"none",zIndex:w},children:[X&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:Ae-Ie/2,top:Pe,width:Ie,height:1,backgroundColor:Z,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:Ae,top:Pe-Ie/2,width:1,height:Ie,backgroundColor:Z,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:Ae-Ie/2,top:Pe,width:Ie,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),O(null)},onPointerMove:e=>{X||O({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),O(null)},onPointerMove:e=>{X||O({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",{...T?ue:{onPointerDown:e=>e.stopPropagation()},style:{position:"absolute",left:0,top:0,width:Se,height:Ce,outline:X?"none":`${ce}px ${le} ${ae}`,outlineOffset:de-1,cursor:T?"move":"default",touchAction:"none",pointerEvents:"auto"},children:U&&!X&&pe.map(({key:e,...t})=>(null==y?void 0:y.component)?y.component({key:e,...t,backgroundColor:Z}):n.jsx("div",{...t,style:{...t.style,backgroundColor:Z}},e))})]}),(X||W)&&F&&r.createPortal(n.jsxs("div",{style:{position:"fixed",left:F.x+16,top:F.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),S&&!X&&n.jsx(d.CounterRotate,{rect:{origin:{x:je,y:we},size:{width:Se,height:Ce}},rotation:l,children:e=>{const n=((V+90*l)%360+360)%360;return S({...e,context:{type:"group",annotations:p,pageIndex:t},selected:!0,placement:{suggestTop:H&&n>90&&n<270}})}})]})}function P(e){return{id:e.id,matches:e.matches?t=>e.matches(t):()=>!1,render:e.render?t=>e.render(t):()=>null,matchesPreview:e.matchesPreview,renderPreview:e.renderPreview?t=>e.renderPreview(t):void 0,previewContainerStyle:e.previewContainerStyle?t=>e.previewContainerStyle(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 I({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 z({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 x=(v??0)>0,{width:y,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(()=>x?t.generateCloudyRectanglePath({x:0,y:0,width:u.size.width,height:u.size.height},f,v,l):null,[x,u,f,v,l]),w=u.size.width*p,S=u.size.height*p,C=Math.max(l,20/p);return n.jsxs("svg",{style:{position:"absolute",width:w,height:S,pointerEvents:"none",zIndex:2},width:w,height:S,viewBox:`0 0 ${u.size.width} ${u.size.height}`,overflow:"visible",children:[x&&j?n.jsx("path",{d:j.path,fill:"transparent",stroke:"transparent",strokeWidth:C,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:y,height:b,fill:"transparent",stroke:"transparent",strokeWidth:C,onPointerDown:h,style:{cursor:e?"move":h?"pointer":"default",pointerEvents:h?e?"none":"transparent"===o?"visibleStroke":"visible":"none"}}),!g&&(x&&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:y,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 R({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 x=(v??0)>0,{width:y,height:b,cx:m,cy:k,rx:j,ry:w}=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]),S=i.useMemo(()=>x?t.generateCloudyEllipsePath({x:0,y:0,width:d.size.width,height:d.size.height},f,v,s):null,[x,d,f,v,s]),C=y*u,A=b*u,P=Math.max(s,20/u);return n.jsxs("svg",{style:{position:"absolute",width:C,height:A,pointerEvents:"none",zIndex:2},width:C,height:A,viewBox:`0 0 ${y} ${b}`,overflow:"visible",children:[x&&S?n.jsx("path",{d:S.path,fill:"transparent",stroke:"transparent",strokeWidth:P,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:w,fill:"transparent",stroke:"transparent",strokeWidth:P,onPointerDown:p,style:{cursor:h?"move":p?"pointer":"default",pointerEvents:p?h?"none":"transparent"===e?"visibleStroke":"visible":"none"}}),!g&&(x&&S?n.jsx("path",{d:S.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:w,fill:e,opacity:r,style:{pointerEvents:"none",stroke:o??e,strokeWidth:s,...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}))]})}function E({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:x,y1:y,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-y,b-x);return{start:t.patching.createEnding(null==p?void 0:p.start,r,e+Math.PI,x,y),end:t.patching.createEnding(null==p?void 0:p.end,r,e,b,m)}},[p,r,x,y,b,m]),j=d.size.width*h,w=d.size.height*h,S=Math.max(r,20/h);return n.jsxs("svg",{style:{position:"absolute",width:j,height:w,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:w,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[n.jsx("line",{x1:x,y1:y,x2:b,y2:m,stroke:"transparent",strokeWidth:S,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:S,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:S,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:x,y1:y,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 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,lineEndings:v,appearanceActive:f=!1}){const x=i.useMemo(()=>o.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[o,e]),y=i.useMemo(()=>{if(!x.length)return"";const[e,...t]=x;return`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y} `).join("").trim()},[x]),b=i.useMemo(()=>{if(x.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),n=e(x[0],x[1]),o=e(x[x.length-2],x[x.length-1]);return{start:t.patching.createEnding(null==v?void 0:v.start,c,n+Math.PI,x[0].x,x[0].y),end:t.patching.createEnding(null==v?void 0:v.end,c,o,x[x.length-1].x,x[x.length-1].y)}},[x,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:y,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:y,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:x=!1,cloudyBorderIntensity:y}){const b=(y??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]),w=i.useMemo(()=>!b||m.length<3?null:t.generateCloudyPolygonPath(m,e.origin,y,c),[b,m,e.origin,y,c]),S=v&&o.length>0,C=e.size.width*p,A=e.size.height*p,P=Math.max(c,20/p);return n.jsxs("svg",{style:{position:"absolute",width:C,height:A,pointerEvents:"none",zIndex:2,overflow:"visible"},width:C,height:A,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:b&&w?w.path:j,fill:"transparent",stroke:"transparent",strokeWidth:P,onPointerDown:g,style:{cursor:h?"move":g?"pointer":"default",pointerEvents:g?h?"none":"transparent"===r?"visibleStroke":"visible":"none",strokeLinecap:"butt",strokeLinejoin:"miter"}}),!x&&n.jsx(n.Fragment,{children:b&&w?n.jsx("path",{d:w.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(",")}}}),S&&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"}}),S&&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}=y(),v=(null==g?void 0:g.forDocument(e))??null,{adjustedFontPx:f,wrapperStyle:x}=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",...x},contentEditable:o,...p,children:r.object.contents})})}function F({documentId:e,isSelected:o,isEditing:r,annotation:s,pageIndex:l,scale:c,onClick:d,appearanceActive:u=!1}){const h=i.useRef(null),g=i.useRef(!1),{provides:v}=y(),f=(null==v?void 0:v.forDocument(e))??null,x=s.object,b=x.rect,m=x.rectangleDifferences,j=x.calloutLine,w=x.strokeWidth??1,S=x.strokeColor??"#000000",C=i.useMemo(()=>t.patching.computeTextBoxFromRD(b,m),[b,m]),A=i.useMemo(()=>({left:(C.origin.x-b.origin.x+w/2)*c,top:(C.origin.y-b.origin.y+w/2)*c,width:(C.size.width-w)*c,height:(C.size.height-w)*c}),[C,b,c,w]),P=i.useMemo(()=>!j||j.length<3?null:j.map(e=>({x:e.x-b.origin.x,y:e.y-b.origin.y})),[j,b]),I=i.useMemo(()=>{if(!P||P.length<2)return null;const e=Math.atan2(P[1].y-P[0].y,P[1].x-P[0].x);return t.patching.createEnding(x.lineEnding,w,e+Math.PI,P[0].x,P[0].y)},[P,x.lineEnding,w]),z=i.useMemo(()=>{if(!P||P.length<2)return P;const e=P.map(e=>({...e})),t=e.length-1,n=t-1,o=e[t].x-e[n].x,i=e[t].y-e[n].y,r=Math.sqrt(o*o+i*i);if(r>0){const n=w/2;e[t].x+=o/r*n,e[t].y+=i/r*n}return e},[P,w]),{adjustedFontPx:R,wrapperStyle:E}=k(x.fontSize*c,r);i.useEffect(()=>{var e;if(r&&h.current){g.current=!0;const t=h.current;t.focus();const n=null==f?void 0:f.findToolForAnnotation(x),o=null!=(null==(e=null==n?void 0:n.defaults)?void 0:e.contents)&&x.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)}}},[r]);const D=b.size.width*c,M=b.size.height*c,L=Math.max(w,20/c);return n.jsxs("div",{style:{position:"absolute",width:D,height:M,cursor:o&&!r?"move":"default",pointerEvents:"none",zIndex:2,opacity:u?0:1},children:[n.jsxs("svg",{style:{position:"absolute",width:D,height:M,pointerEvents:"none",overflow:"visible"},width:D,height:M,viewBox:`0 0 ${b.size.width} ${b.size.height}`,children:[P&&n.jsxs(n.Fragment,{children:[n.jsx("polyline",{points:P.map(e=>`${e.x},${e.y}`).join(" "),fill:"none",stroke:"transparent",strokeWidth:L,onPointerDown:d?e=>d(e):void 0,style:{cursor:o?"move":d?"pointer":"default",pointerEvents:d?o?"none":"visibleStroke":"none"}}),I&&n.jsx("path",{d:I.d,transform:I.transform,fill:"transparent",stroke:"transparent",strokeWidth:L,onPointerDown:d?e=>d(e):void 0,style:{cursor:o?"move":d?"pointer":"default",pointerEvents:d?o?"none":I.filled?"visible":"visibleStroke":"none"}})]}),!u&&n.jsxs(n.Fragment,{children:[z&&n.jsxs(n.Fragment,{children:[n.jsx("polyline",{points:z.map(e=>`${e.x},${e.y}`).join(" "),fill:"none",stroke:S,strokeWidth:w,opacity:x.opacity,style:{pointerEvents:"none"}}),I&&n.jsx("path",{d:I.d,transform:I.transform,stroke:S,fill:I.filled?x.color??"transparent":"none",strokeWidth:w,opacity:x.opacity,style:{pointerEvents:"none"}})]}),n.jsx("rect",{x:C.origin.x-b.origin.x+w/2,y:C.origin.y-b.origin.y+w/2,width:C.size.width-w,height:C.size.height-w,fill:x.color??x.backgroundColor??"transparent",stroke:S,strokeWidth:w,opacity:x.opacity,style:{pointerEvents:"none"}})]})]}),n.jsx("div",{onPointerDown:d?e=>d(e):void 0,style:{position:"absolute",left:(C.origin.x-b.origin.x)*c,top:(C.origin.y-b.origin.y)*c,width:C.size.width*c,height:C.size.height*c,cursor:o&&!r?"move":d?"pointer":"default",pointerEvents:d?o&&!r?"none":"auto":"none"}}),n.jsx("span",{ref:h,onBlur:()=>{g.current&&(g.current=!1,f&&h.current&&f.updateAnnotation(l,x.id,{contents:h.current.innerText.replace(/\u00A0/g," ")}))},tabIndex:0,style:{position:"absolute",left:A.left,top:A.top,width:A.width,height:A.height,color:x.fontColor,fontSize:R,...a.standardFontCssProperties(x.fontFamily),textAlign:a.textAlignmentToCss(x.textAlign),flexDirection:"column",justifyContent:x.verticalAlign===a.PdfVerticalAlignment.Top?"flex-start":x.verticalAlign===a.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",padding:w*c/2+2*c,opacity:x.opacity,lineHeight:"1.18",overflow:"hidden",cursor:r?"text":"default",outline:"none",pointerEvents:r?"auto":"none",...E},contentEditable:r,...p,children:x.contents})]})}function O({calloutLine:e,textBox:i,bounds:r,scale:s,strokeColor:a,strokeWidth:l,color:c,backgroundColor:d,opacity:u,lineEnding:p}){if(!e||e.length<2)return n.jsx(o.Fragment,{});const h=l??1,g=a??"#000000",v=u??1,f=r.size.width,x=r.size.height,y=r.origin.x,b=r.origin.y,m=e.map(e=>({x:e.x-y,y:e.y-b})),k=Math.atan2(m[1].y-m[0].y,m[1].x-m[0].x),j=t.patching.createEnding(p,h,k+Math.PI,m[0].x,m[0].y),w=h/2;return n.jsxs("svg",{style:{position:"absolute",width:f*s,height:x*s,pointerEvents:"none",overflow:"visible"},width:f*s,height:x*s,viewBox:`0 0 ${f} ${x}`,children:[n.jsx("polyline",{points:m.map(e=>`${e.x},${e.y}`).join(" "),fill:"none",stroke:g,strokeWidth:h,opacity:v}),j&&n.jsx("path",{d:j.d,transform:j.transform,stroke:g,fill:j.filled?c??"transparent":"none",strokeWidth:h,opacity:v}),i&&n.jsx("rect",{x:i.origin.x-y+w,y:i.origin.y-b+w,width:i.size.width-h,height:i.size.height-h,fill:c??d??"transparent",stroke:g,strokeWidth:h,opacity:v})]})}function W({documentId:e,pageIndex:t,annotation:r,scaleFactor:s=1,unrotated:l,style:c,...d}){const{provides:u}=y(),[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 B({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(W,{documentId:o,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:r,unrotated:a})})}function T({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]),x=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"}}),x?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 U({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 H({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 N({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 G({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 q({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 Y({annotation:e,documentId:t}){const{provides:o}=y(),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 V=[P({id:"ink",matches:e=>e.type===a.PdfAnnotationSubtype.INK,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.INK,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(I,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),renderPreview:({data:e,scale:t})=>n.jsx(I,{isSelected:!1,scale:t,...e}),previewContainerStyle:({data:e})=>({mixBlendMode:a.blendModeToCss(e.blendMode??a.PdfBlendMode.Normal)}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),P({id:"square",matches:e=>e.type===a.PdfAnnotationSubtype.SQUARE,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.SQUARE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(z,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),renderPreview:({data:e,scale:t})=>n.jsx(z,{isSelected:!1,scale:t,...e}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),P({id:"circle",matches:e=>e.type===a.PdfAnnotationSubtype.CIRCLE,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.CIRCLE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(R,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),renderPreview:({data:e,scale:t})=>n.jsx(R,{isSelected:!1,scale:t,...e}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),P({id:"line",matches:e=>e.type===a.PdfAnnotationSubtype.LINE,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.LINE,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})}),renderPreview:({data:e,scale:t})=>n.jsx(E,{isSelected:!1,scale:t,...e}),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}}),P({id:"polyline",matches:e=>e.type===a.PdfAnnotationSubtype.POLYLINE,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.POLYLINE,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})}),renderPreview:({data:e,scale:t})=>n.jsx(D,{isSelected:!1,scale:t,...e}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),P({id:"polygon",matches:e=>e.type===a.PdfAnnotationSubtype.POLYGON,matchesPreview: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})}),renderPreview:({data:e,scale:t})=>n.jsx(M,{isSelected:!1,scale:t,...e}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),P({id:"highlight",matches:e=>e.type===a.PdfAnnotationSubtype.HIGHLIGHT,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},defaultBlendMode:a.PdfBlendMode.Multiply}),P({id:"underline",matches:e=>e.type===a.PdfAnnotationSubtype.UNDERLINE,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}}),P({id:"strikeout",matches:e=>e.type===a.PdfAnnotationSubtype.STRIKEOUT,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(N,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),P({id:"squiggly",matches:e=>e.type===a.PdfAnnotationSubtype.SQUIGGLY,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(G,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),P({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}}),P({id:"caret",matches:e=>e.type===a.PdfAnnotationSubtype.CARET,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(q,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),P({id:"freeTextCallout",matches:e=>e.type===a.PdfAnnotationSubtype.FREETEXT&&"FreeTextCallout"===e.intent,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.FREETEXT&&!!e.data.calloutLine,render:({annotation:e,currentObject:t,isSelected:o,isEditing:i,scale:r,pageIndex:s,documentId:a,onClick:l,appearanceActive:c})=>n.jsx(F,{documentId:a,isSelected:o,isEditing:i,annotation:{...e,object:t},pageIndex:s,scale:r,onClick:l,appearanceActive:c}),renderPreview:({data:e,bounds:t,scale:o})=>n.jsx(O,{calloutLine:e.calloutLine,textBox:e.textBox,bounds:t,scale:o,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,color:e.color,backgroundColor:e.backgroundColor,opacity:e.opacity,lineEnding:e.lineEnding}),vertexConfig:t.patching.calloutVertexConfig,interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!1},isDraggable:(e,{isEditing:t})=>e&&!t,onDoubleClick:(e,t)=>t(e)}),P({id:"freeText",matches:e=>e.type===a.PdfAnnotationSubtype.FREETEXT&&"FreeTextCallout"!==e.intent,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.FREETEXT&&!e.data.calloutLine,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}),renderPreview:({data:e})=>n.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.fontColor||"#000000"}`,backgroundColor:"transparent"}}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0},isDraggable:(e,{isEditing:t})=>e&&!t,onDoubleClick:(e,t)=>t(e)}),P({id:"stamp",matches:e=>e.type===a.PdfAnnotationSubtype.STAMP,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.STAMP,render:({annotation:e,isSelected:t,documentId:o,pageIndex:i,scale:r,onClick:s})=>n.jsx(B,{isSelected:t,annotation:e,documentId:o,pageIndex:i,scale:r,onClick:s}),renderPreview:({data:e})=>{const t=(4-e.pageRotation)%4*90;return n.jsx("img",{src:e.ghostUrl,style:{width:"100%",height:"100%",opacity:.6,objectFit:"contain",pointerEvents:"none",transform:t?`rotate(${t}deg)`:void 0},alt:""})},useAppearanceStream:!1,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),P({id:"link",matches:e=>e.type===a.PdfAnnotationSubtype.LINK,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.LINK,render:({currentObject:e,isSelected:t,scale:o,onClick:i})=>n.jsx(T,{...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(Y,{...e})})];function X(e){const{documentId:o,pageIndex:r,scale:s,pageWidth:d,pageHeight:u,selectionMenu:p}=e,{provides:h}=y(),{provides:g}=c.useSelectionCapability(),[v,f]=i.useState([]),{register:x}=l.usePointerHandlers({documentId:o,pageIndex:r}),[b,m]=i.useState([]),[k,j]=i.useState(null),[S,C]=i.useState({}),[P,I]=i.useState({type:t.LockModeType.None}),z=i.useRef(s),R=i.useMemo(()=>h?h.forDocument(o):null,[h,o]),E=b.length>1;i.useEffect(()=>{if(R){const e=R.getState();return f(t.getAnnotationsByPageIndex(e,r)),m(t.getSelectedAnnotationIds(e)),I(e.locked),R.onStateChange(e=>{f(t.getAnnotationsByPageIndex(e,r)),m(t.getSelectedAnnotationIds(e)),I(e.locked)})}},[R,r]),i.useEffect(()=>{if(R)return R.onAnnotationEvent(e=>{"create"===e.type&&e.editAfterCreate&&j(e.annotation.id)})},[R]),i.useEffect(()=>{if(!R)return;z.current!==s&&(R.invalidatePageAppearances(r),z.current=s);R.getPageAppearances(r,{scaleFactor:s,dpr:"undefined"!=typeof window?window.devicePixelRatio:1}).wait(e=>C(e),()=>C({}))},[R,r,s]);const D=i.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&R&&(k&&v.some(e=>e.object.id===k)&&t.stopImmediatePropagation(),R.deselectAnnotation(),j(null))}}),[R,k,v]),M=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!==k&&j(null)}},[R,g,k,r]);i.useEffect(()=>x(D,{documentId:o}),[x,D]);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==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}),[L,R]),F=i.useMemo(()=>!(L.length<2)&&L.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}),[L,R]),O=i.useMemo(()=>!(L.length<2)&&L.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}),[L,R]),W=i.useMemo(()=>!(L.length<2)&&L.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}),[L,R]),B=i.useMemo(()=>{if(!R)return!1;const e=R.getSelectedAnnotations();return e.length>1&&e.every(e=>e.object.pageIndex===r)},[R,r,b]),T=i.useCallback(e=>{if(e.dictMode)return null;if(e.object.rotation&&e.object.unrotatedRect)return null;const t=S[e.object.id];return(null==t?void 0:t.normal)?t:null},[S]),U=i.useMemo(()=>{const t=e.annotationRenderers??[],n=new Set(t.map(e=>e.id));return[...t,...V.filter(e=>!n.has(e.id))]},[e.annotationRenderers]),H=i.useCallback(e=>U.find(t=>t.matches(e.object))??null,[U]),N=i.useMemo(()=>({defaultSelect:M,selectAnnotation:(e,t)=>null==R?void 0:R.selectAnnotation(e,t),clearSelection:()=>null==g?void 0:g.clear(),allAnnotations:v,pageIndex:r}),[M,R,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==R?void 0:R.findToolForAnnotation(i.object))??null,g=t.getAnnotationCategories(h),v=t.hasLockedFlag(i.object)||t.isCategoryLocked(g,P);if(v&&u.hiddenWhenLocked)return null;const f=v&&!!u.renderLocked,x=!v&&b.includes(i.object.id),y=!v&&k===i.object.id,m=u.interactionDefaults,S=t.resolveInteractionProp(null==h?void 0:h.interaction.isDraggable,i.object,(null==m?void 0:m.isDraggable)??!0),C=!v&&(u.isDraggable?u.isDraggable(S,{isEditing:y}):S),A=(null==(l=null==h?void 0:h.behavior)?void 0:l.useAppearanceStream)??u.useAppearanceStream??!0,I=f?void 0:A?T(i):void 0,z=v?e=>{e.stopPropagation()}:u.selectOverride?e=>u.selectOverride(e,i,N):e=>M(e,i);return n.jsx(w,{trackedAnnotation:i,isSelected:x,isEditing:y,isMultiSelected:!v&&E,isDraggable:C,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:z,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:I,...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:x,isEditing:y,scale:s,pageIndex:r,documentId:o,onClick:v?void 0:z,appearanceActive:t})},i.object.id)}),B&&L.length>=2&&n.jsx(A,{documentId:o,pageIndex:r,scale:s,rotation:e.rotation,pageWidth:d,pageHeight:u,selectedAnnotations:L,isDraggable:$,isResizable:F,isRotatable:O,lockAspectRatio:W,resizeUI:e.resizeUI,rotationUI:e.rotationUI,selectionOutlineColor:e.selectionOutlineColor,selectionOutline:e.groupSelectionOutline??e.selectionOutline,groupSelectionMenu:e.groupSelectionMenu})]})}function K({documentId:e,pageIndex:t,scale:o}){var r,s,l,d,u,p,h,g,v,f,x,b;const{provides:m}=c.useSelectionCapability(),{provides:k}=y(),[j,w]=i.useState([]),[S,C]=i.useState(null),[A,P]=i.useState(null);if(i.useEffect(()=>{if(m)return m.forDocument(e).onSelectionChange(()=>{w(m.forDocument(e).getHighlightRectsForPage(t)),C(m.forDocument(e).getBoundingRectForPage(t))})},[m,e,t]),i.useEffect(()=>{if(k)return P(k.forDocument(e).getActiveTool()),k.forDocument(e).onActiveToolChange(e=>P(e))},[k,e]),!S)return null;if(!A||!A.defaults)return null;switch(A.defaults.type){case a.PdfAnnotationSubtype.UNDERLINE:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(r=A.defaults)?void 0:r.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(H,{strokeColor:null==(s=A.defaults)?void 0:s.strokeColor,opacity:null==(l=A.defaults)?void 0:l.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.HIGHLIGHT:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(d=A.defaults)?void 0:d.blendMode)??a.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(U,{strokeColor:null==(u=A.defaults)?void 0:u.strokeColor,opacity:null==(p=A.defaults)?void 0:p.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.STRIKEOUT:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(h=A.defaults)?void 0:h.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(N,{strokeColor:null==(g=A.defaults)?void 0:g.strokeColor,opacity:null==(v=A.defaults)?void 0:v.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.SQUIGGLY:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(f=A.defaults)?void 0:f.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(G,{strokeColor:null==(x=A.defaults)?void 0:x.strokeColor,opacity:null==(b=A.defaults)?void 0:b.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.CARET:default:return null}}function Z({toolId:e,preview:t,scale:o}){var r;const{bounds:s}=t,a=f(),l=i.useMemo(()=>{const e=new Set(a.map(e=>e.id));return[...a,...V.filter(t=>!e.has(t.id))]},[a]),c={position:"absolute",left:s.origin.x*o,top:s.origin.y*o,width:s.size.width*o,height:s.size.height*o,pointerEvents:"none",zIndex:10},d=l.find(e=>{var n;return(null==(n=e.matchesPreview)?void 0:n.call(e,t))&&e.renderPreview})??l.find(t=>t.id===e&&t.renderPreview);if(null==d?void 0:d.renderPreview){const e=null==(r=d.previewContainerStyle)?void 0:r.call(d,{data:t.data,bounds:t.bounds,scale:o});return n.jsx("div",{style:{...c,...e},children:d.renderPreview({data:t.data,bounds:t.bounds,scale:o})})}return null}function Q({documentId:e,pageIndex:t,scale:o}){const{plugin:r}=x(),[s,a]=i.useState(new Map),l=i.useRef(null),c=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()}}),[]);return i.useEffect(()=>{if(r)return r.registerPageHandlers(e,t,o,{services:c,onPreview:(e,t)=>{a(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,o,r,c]),n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:l,type:"file",style:{display:"none"}}),Array.from(s.entries()).map(([e,t])=>n.jsx(Z,{toolId:e,preview:t,scale:o},e))]})}const _=e.createPluginPackage(t.AnnotationPluginPackage).addWrapper(v).addUtility(function(){const{plugin:e}=x(),{provides:t}=y();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:x,annotationRenderers:y,...b}){var m,k,j,w;const S=s.useDocumentState(t),C=null==(k=null==(m=null==S?void 0:S.document)?void 0:m.pages)?void 0:k[o],A=(null==(j=null==C?void 0:C.size)?void 0:j.width)??0,P=(null==(w=null==C?void 0:C.size)?void 0:w.height)??0,I=f(),z=i.useMemo(()=>{const e=[...I];for(const t of y??[]){const n=e.findIndex(e=>e.id===t.id);n>=0?e[n]=t:e.push(t)}return e},[I,y]),R=i.useMemo(()=>void 0!==r?r:(null==S?void 0:S.scale)??1,[r,null==S?void 0:S.scale]),E=i.useMemo(()=>{if(void 0!==a)return a;return(((null==C?void 0:C.rotation)??0)+((null==S?void 0:S.rotation)??0))%4},[a,null==C?void 0:C.rotation,null==S?void 0:S.rotation]);return n.jsxs("div",{style:{...e},...b,children:[n.jsx(X,{documentId:t,selectionMenu:l,groupSelectionMenu:c,pageIndex:o,scale:R,rotation:E,pageWidth:A,pageHeight:P,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:v,customAnnotationRenderer:x,annotationRenderers:z}),n.jsx(K,{documentId:t,pageIndex:o,scale:R}),n.jsx(Q,{documentId:t,pageIndex:o,scale:R})]})},exports.AnnotationPluginPackage=_,exports.AnnotationRendererProvider=v,exports.GroupSelectionBox=A,exports.createRenderer=P,exports.useAnnotation=e=>{var n;const{provides:o}=y(),[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=y,exports.useAnnotationPlugin=x,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]})});
|
|
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 w({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:w=!0,lockAspectRatio:S=!1,style:C={},blendMode:A,vertexConfig:P,selectionMenu:I,structurallyLocked:z=!1,contentLocked:R=!1,outlineOffset:E=1,onDoubleClick:D,onSelect:M,appearance:L,zIndex:$=1,resizeUI:F,vertexUI:O,rotationUI:W,selectionOutlineColor:B,selectionOutline:T,customAnnotationRenderer:U,groupSelectionMenu:H,groupSelectionOutline:N,annotationRenderers:G,...q}){var V,Y,X;const[K,Z]=i.useState(h.object),[Q,_]=i.useState(null),[J,ee]=i.useState(null),[te,ne]=i.useState(!1),[oe,ie]=i.useState(!1),{provides:re}=x(),{plugin:se}=y(),{canModifyAnnotations:ae}=s.useDocumentPermissions(t),le=i.useRef(null),ce=ae&&m&&!b,de=ae&&k&&!b,ue=ae&&w&&!b,pe=i.useMemo(()=>re?re.forDocument(t):null,[re,t]),he=K?{...h.object,...K}:h.object,ge=h.object.flags??[],ve=ge.includes("noZoom"),fe=ge.includes("noRotate"),ye=ve?1:e,xe=fe?0:l,be=(null==F?void 0:F.color)??"#007ACC",me=(null==O?void 0:O.color)??"#007ACC",ke=(null==W?void 0:W.color)??"white",je=(null==W?void 0:W.connectorColor)??"#007ACC",we=(null==F?void 0:F.size)??12,Se=(null==O?void 0:O.size)??12,Ce=(null==W?void 0:W.size)??32,Ae=null==W?void 0:W.margin,Pe=(null==W?void 0:W.iconColor)??"#007ACC",Ie=(null==W?void 0:W.showConnector)??!1,ze=(null==(V=null==W?void 0:W.border)?void 0:V.color)??"#007ACC",Re=(null==(Y=null==W?void 0:W.border)?void 0:Y.width)??1,Ee=(null==(X=null==W?void 0:W.border)?void 0:X.style)??"solid",De=(null==T?void 0:T.color)??B??"#007ACC",Me=(null==T?void 0:T.style)??"solid",Le=(null==T?void 0:T.width)??1,$e=(null==T?void 0:T.offset)??E??1,Fe=Q??he.rotation??0,Oe=Q??he.rotation??0,We=Number.isFinite(Oe)?Math.round(10*Oe)/10:0,Be=null!==Q,Te=i.useRef(null),Ue=i.useCallback(e=>{var n;if(!(null==(n=e.transformData)?void 0:n.type)||b||!se)return;const{type:i,changes:r,metadata:s}=e.transformData,a=h.object.id,l={width:c,height:p};if("start"===e.state&&(Te.current=h.object.unrotatedRect??h.object.rect,le.current=h.object,"resize"!==i&&"vertex-edit"!==i||ie(!0),"move"===i?se.startDrag(t,{annotationIds:[a],pageSize:l}):"resize"===i&&se.startResize(t,{annotationIds:[a],pageSize:l,resizeHandle:(null==s?void 0:s.handle)??"se"})),r.rect&&Te.current)if("move"===i){const e={x:r.rect.origin.x-Te.current.origin.x,y:r.rect.origin.y-Te.current.origin.y};se.updateDrag(t,e)}else"resize"===i&&se.updateResize(t,r.rect);if("vertex-edit"===i&&r.vertices&&P){const t=le.current??h.object,n=P.transformAnnotation(t,r.vertices),l=null==re?void 0:re.transformAnnotation(t,{type:i,changes:n,metadata:s});l&&(Z(e=>({...e,...l})),"end"===e.state&&(null==pe||pe.updateAnnotation(o,a,l)))}if("rotate"===i){const n=(null==s?void 0:s.rotationAngle)??Fe,o=null==s?void 0:s.cursorPosition;return o&&ee({x:o.clientX,y:o.clientY}),void("start"===e.state?(_(n),se.startRotation(t,{annotationIds:[a],cursorAngle:n,rotationCenter:null==s?void 0:s.rotationCenter})):"move"===e.state?(_(n),se.updateRotation(t,n,null==s?void 0:s.rotationDelta)):"end"===e.state&&(_(null),ee(null),se.commitRotation(t)))}"end"===e.state&&(Te.current=null,le.current=null,ie(!1),"move"===i?se.commitDrag(t):"resize"===i&&se.commitResize(t))},[se,t,h.object,c,p,o,b,P,re,pe,Fe]),He=he.unrotatedRect,Ne=He??he.rect,Ge=He&&0!==Fe?a.inferRotationCenterFromRects(Ne,he.rect,Fe):void 0,qe=Ne,{dragProps:Ve,vertices:Ye,resize:Xe,rotation:Ke}=d.useInteractionHandles({controller:{element:qe,vertices:null==P?void 0:P.extractVertices(he),constraints:{minWidth:10,minHeight:10,boundingBox:{width:c,height:p}},maintainAspectRatio:S,pageRotation:l,annotationRotation:Fe,rotationCenter:Ge,rotationElement:he.rect,scale:e,enabled:v&&!b,onUpdate:Ue},resizeUI:{handleSize:we,spacing:$e,offsetMode:"outside",includeSides:!S,zIndex:$+1},vertexUI:{vertexSize:Se,zIndex:$+2},rotationUI:{handleSize:Ce,margin:Ae,zIndex:$+3,showConnector:Ie},includeVertices:!!P,includeRotation:ue,currentRotation:Fe}),Ze=i.useMemo(()=>{if(ae&&D)return D},[ae,D]),Qe=d.useDoublePressProps(Ze);i.useEffect(()=>{Z(h.object)},[h.object]),i.useEffect(()=>{if(!se)return;const e=h.object.id,n=n=>{var o;if(n.documentId!==t)return;"end"!==n.type&&"cancel"!==n.type||_(null);const i=null==(o=n.previewPatches)?void 0:o[e];"update"===n.type&&i?Z(e=>({...e,...i})):"cancel"===n.type&&Z(h.object)},o=[se.onDragChange(n),se.onResizeChange(n),se.onRotateChange(n)];return()=>o.forEach(e=>e())},[se,t,h.object]);const _e=v&&!b,Je=he.rect.size.width*ye,et=he.rect.size.height*ye,tt=Ne.size.width*ye,nt=Ne.size.height*ye,ot=Boolean(He)&&0!==Fe,it=ot?(Ne.origin.x-he.rect.origin.x)*ye:(Je-tt)/2,rt=ot?(Ne.origin.y-he.rect.origin.y)*ye:(et-nt)/2,st=ot&&Ge?`${(Ge.x-Ne.origin.x)*ye}px ${(Ge.y-Ne.origin.y)*ye}px`:"center center",at=Ge?(Ge.x-he.rect.origin.x)*ye:Je/2,lt=Ge?(Ge.y-he.rect.origin.y)*ye:et/2,ct=Math.max(300,Math.max(Je,et)+80),dt=fe?u.getCounterRotation({origin:{x:0,y:0},size:{width:Je,height:et}},l):null,ut=i.useMemo(()=>He?{...he,rect:He}:he,[he,He]),pt=!(!(null==L?void 0:L.normal)||oe||f||h.dictMode),ht={position:"absolute",left:he.rect.origin.x*e,top:he.rect.origin.y*e,width:dt?dt.width:Je,height:dt?dt.height:et,pointerEvents:"none",zIndex:$,...dt&&{transform:dt.matrix,transformOrigin:"0 0"}},gt={position:"absolute",left:it,top:rt,width:tt,height:nt,transform:0!==Fe?`rotate(${Fe}deg)`:void 0,transformOrigin:st};return n.jsxs("div",{"data-no-interaction":!0,children:[n.jsx("div",{style:{...ht,...A&&{mixBlendMode:A},...C},children:n.jsxs("div",{style:{...gt,pointerEvents:f?"auto":"none"},children:[(()=>{const t="function"==typeof g?g(ut,{appearanceActive:pt}):g;return(null==U?void 0:U({annotation:ut,children:t,isSelected:v,scale:e,rotation:l,pageWidth:c,pageHeight:p,pageIndex:o,onSelect:M}))??t})(),(null==L?void 0:L.normal)&&n.jsx(j,{appearance:L.normal,style:{display:pt?"block":"none"}})]})}),n.jsxs("div",{style:ht,...q,children:[Be&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:at-ct/2,top:lt,width:ct,height:1,backgroundColor:je,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:at,top:lt-ct/2,width:1,height:ct,backgroundColor:je,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:at-ct/2,top:lt,width:ct,height:1,transformOrigin:"center center",transform:`rotate(${Fe}deg)`,backgroundColor:je,opacity:.8,pointerEvents:"none"}})]}),v&&ue&&Ke&&((null==W?void 0:W.component)?n.jsx("div",{onPointerEnter:()=>ne(!0),onPointerLeave:()=>{ne(!1),ee(null)},onPointerMove:e=>{Be||ee({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:W.component({...Ke.handle,backgroundColor:ke,iconColor:Pe,connectorStyle:{...Ke.connector.style,backgroundColor:je,opacity:Be?0:1},showConnector:Ie,opacity:Be?0:1,border:{color:ze,width:Re,style:Ee}})}):n.jsxs("div",{onPointerEnter:()=>ne(!0),onPointerLeave:()=>{ne(!1),ee(null)},onPointerMove:e=>{Be||ee({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[Ie&&n.jsx("div",{style:{...Ke.connector.style,backgroundColor:je,opacity:Be?0:1}}),n.jsx("div",{...Ke.handle,style:{...Ke.handle.style,backgroundColor:ke,border:`${Re}px ${Ee} ${ze}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:Be?0:1},children:n.jsxs("svg",{width:Math.round(.6*Ce),height:Math.round(.6*Ce),viewBox:"0 0 24 24",fill:"none",stroke:Pe,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",{...ce&&v?Ve:{},...Qe,style:{...gt,outline:_e?`${Le}px ${Me} ${De}`:"none",outlineOffset:_e?`${$e}px`:"0px",pointerEvents:!v||b||f?"none":"auto",touchAction:"none",cursor:v&&ce?"move":"default"},children:[v&&de&&!Be&&Xe.map(({key:e,...t})=>(null==F?void 0:F.component)?F.component({key:e,...t,backgroundColor:be}):n.jsx("div",{...t,style:{...t.style,backgroundColor:be}},e)),v&&ae&&!b&&!Be&&Ye.map(({key:e,...t})=>(null==O?void 0:O.component)?O.component({key:e,...t,backgroundColor:me}):n.jsx("div",{...t,style:{...t.style,backgroundColor:me}},e))]})]}),I&&!b&&!Be&&n.jsx(d.CounterRotate,{rect:{origin:{x:he.rect.origin.x*e,y:he.rect.origin.y*e},size:{width:he.rect.size.width*ye,height:he.rect.size.height*ye}},rotation:l,children:e=>{const t=((Fe+90*xe)%360+360)%360;return I({...e,context:{type:"annotation",annotation:h,pageIndex:o,structurallyLocked:z,contentLocked:R},selected:v,placement:{suggestTop:ue&&t>90&&t<270}})}}),(Be||te)&&J&&r.createPortal(n.jsxs("div",{style:{position:"fixed",left:J.x+16,top:J.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:[We.toFixed(0),"°"]}),document.body)]})}function S(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 C(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=[S(0,0,l,c,n),S(l,0,l,c,n),S(0,c,l,c,n),S(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 A({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:w=2,groupSelectionMenu:S}){var A,P,I;const{plugin:z}=y(),{canModifyAnnotations:R}=s.useDocumentPermissions(e),E=i.useRef(null),D=i.useRef(!1),M=i.useRef(!1),[L,$]=i.useState(null),[F,O]=i.useState(null),[W,B]=i.useState(!1),T=R&&h,U=R&&g,H=R&&v,N=i.useMemo(()=>{const e=p.map(e=>e.object.rect);return a.boundingRectOrEmpty(e)},[p]),[G,q]=i.useState(N);i.useEffect(()=>{D.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 V=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&&!T)return;if("start"===t.state&&(E.current=N,d?(D.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&&O({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),O(null),z.commitRotation(e)))}const g=E.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&&(E.current=null,d&&D.current?(D.current=!1,z.commitDrag(e)):h&&M.current&&(M.current=!1,z.commitResize(e)))},[z,e,c,u,N,T,p,v]),Y=L??0,X=null!==L,K=Number.isFinite(Y)?Math.round(10*Y)/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==(A=null==b?void 0:b.border)?void 0:A.color)??"#007ACC",re=(null==(P=null==b?void 0:b.border)?void 0:P.width)??1,se=(null==(I=null==b?void 0:b.border)?void 0:I.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:V},resizeUI:{handleSize:Q,spacing:de,offsetMode:"outside",includeSides:!f,zIndex:w+1},vertexUI:{vertexSize:0,zIndex:w},rotationUI:{handleSize:ee,margin:te,zIndex:w+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=C(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,we=G.origin.y*o+be,Se=G.size.width*o+(me-xe),Ce=G.size.height*o+(ke-be),Ae=Se/2,Pe=Ce/2,Ie=Math.max(300,Math.max(Se,Ce)+80);return n.jsxs("div",{"data-group-selection-box":!0,"data-no-interaction":!0,children:[n.jsxs("div",{style:{position:"absolute",left:je,top:we,width:Se,height:Ce,pointerEvents:"none",zIndex:w},children:[X&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:Ae-Ie/2,top:Pe,width:Ie,height:1,backgroundColor:Z,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:Ae,top:Pe-Ie/2,width:1,height:Ie,backgroundColor:Z,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:Ae-Ie/2,top:Pe,width:Ie,height:1,transformOrigin:"center center",transform:`rotate(${Y}deg)`,backgroundColor:Z,opacity:.8,pointerEvents:"none"}})]}),H&&he&&((null==b?void 0:b.component)?n.jsx("div",{onPointerEnter:()=>B(!0),onPointerLeave:()=>{B(!1),O(null)},onPointerMove:e=>{X||O({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),O(null)},onPointerMove:e=>{X||O({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",{...T?ue:{onPointerDown:e=>e.stopPropagation()},style:{position:"absolute",left:0,top:0,width:Se,height:Ce,outline:X?"none":`${ce}px ${le} ${ae}`,outlineOffset:de-1,cursor:T?"move":"default",touchAction:"none",pointerEvents:"auto"},children:U&&!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)&&F&&r.createPortal(n.jsxs("div",{style:{position:"fixed",left:F.x+16,top:F.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),S&&!X&&n.jsx(d.CounterRotate,{rect:{origin:{x:je,y:we},size:{width:Se,height:Ce}},rotation:l,children:e=>{const n=((Y+90*l)%360+360)%360;return S({...e,context:{type:"group",annotations:p,pageIndex:t},selected:!0,placement:{suggestTop:H&&n>90&&n<270}})}})]})}function P(e){return{id:e.id,matches:e.matches?t=>e.matches(t):()=>!1,render:e.render?t=>e.render(t):()=>null,matchesPreview:e.matchesPreview,renderPreview:e.renderPreview?t=>e.renderPreview(t):void 0,previewContainerStyle:e.previewContainerStyle?t=>e.previewContainerStyle(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 I({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 z({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]),w=u.size.width*p,S=u.size.height*p,C=Math.max(l,20/p);return n.jsxs("svg",{style:{position:"absolute",width:w,height:S,pointerEvents:"none",zIndex:2},width:w,height:S,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:C,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:C,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 R({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:w}=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]),S=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]),C=x*u,A=b*u,P=Math.max(s,20/u);return n.jsxs("svg",{style:{position:"absolute",width:C,height:A,pointerEvents:"none",zIndex:2},width:C,height:A,viewBox:`0 0 ${x} ${b}`,overflow:"visible",children:[y&&S?n.jsx("path",{d:S.path,fill:"transparent",stroke:"transparent",strokeWidth:P,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:w,fill:"transparent",stroke:"transparent",strokeWidth:P,onPointerDown:p,style:{cursor:h?"move":p?"pointer":"default",pointerEvents:p?h?"none":"transparent"===e?"visibleStroke":"visible":"none"}}),!g&&(y&&S?n.jsx("path",{d:S.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:w,fill:e,opacity:r,style:{pointerEvents:"none",stroke:o??e,strokeWidth:s,...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}))]})}function E({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,w=d.size.height*h,S=Math.max(r,20/h);return n.jsxs("svg",{style:{position:"absolute",width:j,height:w,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:w,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[n.jsx("line",{x1:y,y1:x,x2:b,y2:m,stroke:"transparent",strokeWidth:S,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:S,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:S,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 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,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]),w=i.useMemo(()=>!b||m.length<3?null:t.generateCloudyPolygonPath(m,e.origin,x,c),[b,m,e.origin,x,c]),S=v&&o.length>0,C=e.size.width*p,A=e.size.height*p,P=Math.max(c,20/p);return n.jsxs("svg",{style:{position:"absolute",width:C,height:A,pointerEvents:"none",zIndex:2,overflow:"visible"},width:C,height:A,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:b&&w?w.path:j,fill:"transparent",stroke:"transparent",strokeWidth:P,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&&w?n.jsx("path",{d:w.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(",")}}}),S&&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"}}),S&&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 F({documentId:e,isSelected:o,isEditing:r,annotation:s,pageIndex:l,scale:c,onClick:d,appearanceActive:u=!1}){const h=i.useRef(null),g=i.useRef(!1),{provides:v}=x(),f=(null==v?void 0:v.forDocument(e))??null,y=s.object,b=y.rect,m=y.rectangleDifferences,j=y.calloutLine,w=y.strokeWidth??1,S=y.strokeColor??"#000000",C=i.useMemo(()=>t.patching.computeTextBoxFromRD(b,m),[b,m]),A=i.useMemo(()=>({left:(C.origin.x-b.origin.x+w/2)*c,top:(C.origin.y-b.origin.y+w/2)*c,width:(C.size.width-w)*c,height:(C.size.height-w)*c}),[C,b,c,w]),P=i.useMemo(()=>!j||j.length<3?null:j.map(e=>({x:e.x-b.origin.x,y:e.y-b.origin.y})),[j,b]),I=i.useMemo(()=>{if(!P||P.length<2)return null;const e=Math.atan2(P[1].y-P[0].y,P[1].x-P[0].x);return t.patching.createEnding(y.lineEnding,w,e+Math.PI,P[0].x,P[0].y)},[P,y.lineEnding,w]),z=i.useMemo(()=>{if(!P||P.length<2)return P;const e=P.map(e=>({...e})),t=e.length-1,n=t-1,o=e[t].x-e[n].x,i=e[t].y-e[n].y,r=Math.sqrt(o*o+i*i);if(r>0){const n=w/2;e[t].x+=o/r*n,e[t].y+=i/r*n}return e},[P,w]),{adjustedFontPx:R,wrapperStyle:E}=k(y.fontSize*c,r);i.useEffect(()=>{var e;if(r&&h.current){g.current=!0;const t=h.current;t.focus();const n=null==f?void 0:f.findToolForAnnotation(y),o=null!=(null==(e=null==n?void 0:n.defaults)?void 0:e.contents)&&y.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)}}},[r]);const D=b.size.width*c,M=b.size.height*c,L=Math.max(w,20/c);return n.jsxs("div",{style:{position:"absolute",width:D,height:M,cursor:o&&!r?"move":"default",pointerEvents:"none",zIndex:2,opacity:u?0:1},children:[n.jsxs("svg",{style:{position:"absolute",width:D,height:M,pointerEvents:"none",overflow:"visible"},width:D,height:M,viewBox:`0 0 ${b.size.width} ${b.size.height}`,children:[P&&n.jsxs(n.Fragment,{children:[n.jsx("polyline",{points:P.map(e=>`${e.x},${e.y}`).join(" "),fill:"none",stroke:"transparent",strokeWidth:L,onPointerDown:d?e=>d(e):void 0,style:{cursor:o?"move":d?"pointer":"default",pointerEvents:d?o?"none":"visibleStroke":"none"}}),I&&n.jsx("path",{d:I.d,transform:I.transform,fill:"transparent",stroke:"transparent",strokeWidth:L,onPointerDown:d?e=>d(e):void 0,style:{cursor:o?"move":d?"pointer":"default",pointerEvents:d?o?"none":I.filled?"visible":"visibleStroke":"none"}})]}),!u&&n.jsxs(n.Fragment,{children:[z&&n.jsxs(n.Fragment,{children:[n.jsx("polyline",{points:z.map(e=>`${e.x},${e.y}`).join(" "),fill:"none",stroke:S,strokeWidth:w,opacity:y.opacity,style:{pointerEvents:"none"}}),I&&n.jsx("path",{d:I.d,transform:I.transform,stroke:S,fill:I.filled?y.color??"transparent":"none",strokeWidth:w,opacity:y.opacity,style:{pointerEvents:"none"}})]}),n.jsx("rect",{x:C.origin.x-b.origin.x+w/2,y:C.origin.y-b.origin.y+w/2,width:C.size.width-w,height:C.size.height-w,fill:y.color??y.backgroundColor??"transparent",stroke:S,strokeWidth:w,opacity:y.opacity,style:{pointerEvents:"none"}})]})]}),n.jsx("div",{onPointerDown:d?e=>d(e):void 0,style:{position:"absolute",left:(C.origin.x-b.origin.x)*c,top:(C.origin.y-b.origin.y)*c,width:C.size.width*c,height:C.size.height*c,cursor:o&&!r?"move":d?"pointer":"default",pointerEvents:d?o&&!r?"none":"auto":"none"}}),n.jsx("span",{ref:h,onBlur:()=>{g.current&&(g.current=!1,f&&h.current&&f.updateAnnotation(l,y.id,{contents:h.current.innerText.replace(/\u00A0/g," ")}))},tabIndex:0,style:{position:"absolute",left:A.left,top:A.top,width:A.width,height:A.height,color:y.fontColor,fontSize:R,...a.standardFontCssProperties(y.fontFamily),textAlign:a.textAlignmentToCss(y.textAlign),flexDirection:"column",justifyContent:y.verticalAlign===a.PdfVerticalAlignment.Top?"flex-start":y.verticalAlign===a.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",padding:w*c/2+2*c,opacity:y.opacity,lineHeight:"1.18",overflow:"hidden",cursor:r?"text":"default",outline:"none",pointerEvents:r?"auto":"none",...E},contentEditable:r,...p,children:y.contents})]})}function O({calloutLine:e,textBox:i,bounds:r,scale:s,strokeColor:a,strokeWidth:l,color:c,backgroundColor:d,opacity:u,lineEnding:p}){if(!e||e.length<2)return n.jsx(o.Fragment,{});const h=l??1,g=a??"#000000",v=u??1,f=r.size.width,y=r.size.height,x=r.origin.x,b=r.origin.y,m=e.map(e=>({x:e.x-x,y:e.y-b})),k=Math.atan2(m[1].y-m[0].y,m[1].x-m[0].x),j=t.patching.createEnding(p,h,k+Math.PI,m[0].x,m[0].y),w=h/2;return n.jsxs("svg",{style:{position:"absolute",width:f*s,height:y*s,pointerEvents:"none",overflow:"visible"},width:f*s,height:y*s,viewBox:`0 0 ${f} ${y}`,children:[n.jsx("polyline",{points:m.map(e=>`${e.x},${e.y}`).join(" "),fill:"none",stroke:g,strokeWidth:h,opacity:v}),j&&n.jsx("path",{d:j.d,transform:j.transform,stroke:g,fill:j.filled?c??"transparent":"none",strokeWidth:h,opacity:v}),i&&n.jsx("rect",{x:i.origin.x-x+w,y:i.origin.y-b+w,width:i.size.width-h,height:i.size.height-h,fill:c??d??"transparent",stroke:g,strokeWidth:h,opacity:v})]})}function W({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 B({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(W,{documentId:o,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:r,unrotated:a})})}function T({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 U({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 H({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 N({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 G({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 q({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 V({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 Y=[P({id:"ink",matches:e=>e.type===a.PdfAnnotationSubtype.INK,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.INK,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(I,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),renderPreview:({data:e,scale:t})=>n.jsx(I,{isSelected:!1,scale:t,...e}),previewContainerStyle:({data:e})=>({mixBlendMode:a.blendModeToCss(e.blendMode??a.PdfBlendMode.Normal)}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),P({id:"square",matches:e=>e.type===a.PdfAnnotationSubtype.SQUARE,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.SQUARE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(z,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),renderPreview:({data:e,scale:t})=>n.jsx(z,{isSelected:!1,scale:t,...e}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),P({id:"circle",matches:e=>e.type===a.PdfAnnotationSubtype.CIRCLE,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.CIRCLE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(R,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),renderPreview:({data:e,scale:t})=>n.jsx(R,{isSelected:!1,scale:t,...e}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),P({id:"line",matches:e=>e.type===a.PdfAnnotationSubtype.LINE,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.LINE,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})}),renderPreview:({data:e,scale:t})=>n.jsx(E,{isSelected:!1,scale:t,...e}),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}}),P({id:"polyline",matches:e=>e.type===a.PdfAnnotationSubtype.POLYLINE,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.POLYLINE,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})}),renderPreview:({data:e,scale:t})=>n.jsx(D,{isSelected:!1,scale:t,...e}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),P({id:"polygon",matches:e=>e.type===a.PdfAnnotationSubtype.POLYGON,matchesPreview: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})}),renderPreview:({data:e,scale:t})=>n.jsx(M,{isSelected:!1,scale:t,...e}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),P({id:"highlight",matches:e=>e.type===a.PdfAnnotationSubtype.HIGHLIGHT,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},defaultBlendMode:a.PdfBlendMode.Multiply}),P({id:"underline",matches:e=>e.type===a.PdfAnnotationSubtype.UNDERLINE,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}}),P({id:"strikeout",matches:e=>e.type===a.PdfAnnotationSubtype.STRIKEOUT,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(N,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),P({id:"squiggly",matches:e=>e.type===a.PdfAnnotationSubtype.SQUIGGLY,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(G,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),P({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}}),P({id:"caret",matches:e=>e.type===a.PdfAnnotationSubtype.CARET,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(q,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),P({id:"freeTextCallout",matches:e=>e.type===a.PdfAnnotationSubtype.FREETEXT&&"FreeTextCallout"===e.intent,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.FREETEXT&&!!e.data.calloutLine,render:({annotation:e,currentObject:t,isSelected:o,isEditing:i,scale:r,pageIndex:s,documentId:a,onClick:l,appearanceActive:c})=>n.jsx(F,{documentId:a,isSelected:o,isEditing:i,annotation:{...e,object:t},pageIndex:s,scale:r,onClick:l,appearanceActive:c}),renderPreview:({data:e,bounds:t,scale:o})=>n.jsx(O,{calloutLine:e.calloutLine,textBox:e.textBox,bounds:t,scale:o,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,color:e.color,backgroundColor:e.backgroundColor,opacity:e.opacity,lineEnding:e.lineEnding}),vertexConfig:t.patching.calloutVertexConfig,interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!1},isDraggable:(e,{isEditing:t})=>e&&!t,onDoubleClick:(e,t)=>t(e)}),P({id:"freeText",matches:e=>e.type===a.PdfAnnotationSubtype.FREETEXT&&"FreeTextCallout"!==e.intent,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.FREETEXT&&!e.data.calloutLine,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}),renderPreview:({data:e})=>n.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.fontColor||"#000000"}`,backgroundColor:"transparent"}}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0},isDraggable:(e,{isEditing:t})=>e&&!t,onDoubleClick:(e,t)=>t(e)}),P({id:"stamp",matches:e=>e.type===a.PdfAnnotationSubtype.STAMP,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.STAMP,render:({annotation:e,isSelected:t,documentId:o,pageIndex:i,scale:r,onClick:s})=>n.jsx(B,{isSelected:t,annotation:e,documentId:o,pageIndex:i,scale:r,onClick:s}),renderPreview:({data:e})=>{const t=(4-e.pageRotation)%4*90;return n.jsx("img",{src:e.ghostUrl,style:{width:"100%",height:"100%",opacity:.6,objectFit:"contain",pointerEvents:"none",transform:t?`rotate(${t}deg)`:void 0},alt:""})},useAppearanceStream:!1,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),P({id:"link",matches:e=>e.type===a.PdfAnnotationSubtype.LINK,matchesPreview:e=>e.type===a.PdfAnnotationSubtype.LINK,render:({currentObject:e,isSelected:t,scale:o,onClick:i})=>n.jsx(T,{...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(V,{...e})})];function X(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),[S,C]=i.useState({}),[,P]=i.useState({type:t.LockModeType.None}),I=i.useRef(s),z=i.useMemo(()=>h?h.forDocument(o):null,[h,o]),R=b.length>1;i.useEffect(()=>{if(z){const e=z.getState();return f(t.getAnnotationsByPageIndex(e,r)),m(t.getSelectedAnnotationIds(e)),P(e.locked),z.onStateChange(e=>{f(t.getAnnotationsByPageIndex(e,r)),m(t.getSelectedAnnotationIds(e)),P(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;I.current!==s&&(z.invalidatePageAppearances(r),I.current=s);z.getPageAppearances(r,{scaleFactor:s,dpr:"undefined"!=typeof window?window.devicePixelRatio:1}).wait(e=>C(e),()=>C({}))},[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]),D=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 M=i.useMemo(()=>v.filter(e=>b.includes(e.object.id)),[v,b]),L=i.useMemo(()=>!(M.length<2)&&M.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}),[M,z]),$=i.useMemo(()=>!(M.length<2)&&M.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}),[M,z]),F=i.useMemo(()=>!(M.length<2)&&M.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}),[M,z]),O=i.useMemo(()=>!(M.length<2)&&M.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}),[M,z]),W=i.useMemo(()=>{if(!z)return!1;const e=z.getSelectedAnnotations();return e.length>1&&e.every(e=>e.object.pageIndex===r)},[z,r,b]),B=i.useCallback(e=>{if(e.dictMode)return null;if(e.object.rotation&&e.object.unrotatedRect)return null;const t=S[e.object.id];return(null==t?void 0:t.normal)?t:null},[S]),T=i.useMemo(()=>{const t=e.annotationRenderers??[],n=new Set(t.map(e=>e.id));return[...t,...Y.filter(e=>!n.has(e.id))]},[e.annotationRenderers]),U=i.useCallback(e=>T.find(t=>t.matches(e.object))??null,[T]),H=i.useMemo(()=>({defaultSelect:D,selectAnnotation:(e,t)=>null==z?void 0:z.selectAnnotation(e,t),clearSelection:()=>null==g?void 0:g.clear(),allAnnotations:v,pageIndex:r}),[D,z,g,v,r]);return n.jsxs(n.Fragment,{children:[v.map(i=>{var l,c,d;const u=U(i);if(!u)return null;if(t.hasNoViewFlag(i.object))return null;if(t.hasHiddenFlag(i.object))return null;const h=(null==z?void 0:z.findToolForAnnotation(i.object))??null,g=!!z&&!z.isAnnotationInteractive(i.object),v=!!z&&z.isAnnotationStructurallyLocked(i.object),f=!!z&&z.isAnnotationContentLocked(i.object);if(g&&u.hiddenWhenLocked)return null;const y=g&&!!u.renderLocked,x=!g&&b.includes(i.object.id),m=!g&&k===i.object.id,S=u.interactionDefaults,C=t.resolveInteractionProp(null==h?void 0:h.interaction.isDraggable,i.object,(null==S?void 0:S.isDraggable)??!0),A=!v&&(u.isDraggable?u.isDraggable(C,{isEditing:m}):C),P=(null==(l=null==h?void 0:h.behavior)?void 0:l.useAppearanceStream)??u.useAppearanceStream??!0,I=y?void 0:P?B(i):void 0,E=g?e=>{e.stopPropagation()}:u.selectOverride?e=>u.selectOverride(e,i,H):e=>D(e,i);return n.jsx(w,{trackedAnnotation:i,isSelected:x,isEditing:m,isMultiSelected:!g&&R,isDraggable:A,isResizable:!v&&t.resolveInteractionProp(null==h?void 0:h.interaction.isResizable,i.object,(null==S?void 0:S.isResizable)??!1),lockAspectRatio:t.resolveInteractionProp(null==h?void 0:h.interaction.lockAspectRatio,i.object,(null==S?void 0:S.lockAspectRatio)??!1),isRotatable:!v&&t.resolveInteractionProp(null==h?void 0:h.interaction.isRotatable,i.object,(null==S?void 0:S.isRotatable)??!1),vertexConfig:v?void 0:u.vertexConfig,selectionMenu:g||(null==(c=u.hideSelectionMenu)?void 0:c.call(u,i.object))?void 0:p,structurallyLocked:v,contentLocked:f,onSelect:E,onDoubleClick:g||f?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:I,...e,children:(e,{appearanceActive:t})=>y?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:x,isEditing:m,scale:s,pageIndex:r,documentId:o,onClick:g?void 0:E,appearanceActive:t})},i.object.id)}),W&&M.length>=2&&n.jsx(A,{documentId:o,pageIndex:r,scale:s,rotation:e.rotation,pageWidth:d,pageHeight:u,selectedAnnotations:M,isDraggable:L,isResizable:$,isRotatable:F,lockAspectRatio:O,resizeUI:e.resizeUI,rotationUI:e.rotationUI,selectionOutlineColor:e.selectionOutlineColor,selectionOutline:e.groupSelectionOutline??e.selectionOutline,groupSelectionMenu:e.groupSelectionMenu})]})}function K({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,w]=i.useState([]),[S,C]=i.useState(null),[A,P]=i.useState(null);if(i.useEffect(()=>{if(m)return m.forDocument(e).onSelectionChange(()=>{w(m.forDocument(e).getHighlightRectsForPage(t)),C(m.forDocument(e).getBoundingRectForPage(t))})},[m,e,t]),i.useEffect(()=>{if(k)return P(k.forDocument(e).getActiveTool()),k.forDocument(e).onActiveToolChange(e=>P(e))},[k,e]),!S)return null;if(!A||!A.defaults)return null;switch(A.defaults.type){case a.PdfAnnotationSubtype.UNDERLINE:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(r=A.defaults)?void 0:r.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(H,{strokeColor:null==(s=A.defaults)?void 0:s.strokeColor,opacity:null==(l=A.defaults)?void 0:l.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.HIGHLIGHT:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(d=A.defaults)?void 0:d.blendMode)??a.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(U,{strokeColor:null==(u=A.defaults)?void 0:u.strokeColor,opacity:null==(p=A.defaults)?void 0:p.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.STRIKEOUT:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(h=A.defaults)?void 0:h.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(N,{strokeColor:null==(g=A.defaults)?void 0:g.strokeColor,opacity:null==(v=A.defaults)?void 0:v.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.SQUIGGLY:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(f=A.defaults)?void 0:f.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(G,{strokeColor:null==(y=A.defaults)?void 0:y.strokeColor,opacity:null==(b=A.defaults)?void 0:b.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.CARET:default:return null}}function Z({toolId:e,preview:t,scale:o}){var r;const{bounds:s}=t,a=f(),l=i.useMemo(()=>{const e=new Set(a.map(e=>e.id));return[...a,...Y.filter(t=>!e.has(t.id))]},[a]),c={position:"absolute",left:s.origin.x*o,top:s.origin.y*o,width:s.size.width*o,height:s.size.height*o,pointerEvents:"none",zIndex:10},d=l.find(e=>{var n;return(null==(n=e.matchesPreview)?void 0:n.call(e,t))&&e.renderPreview})??l.find(t=>t.id===e&&t.renderPreview);if(null==d?void 0:d.renderPreview){const e=null==(r=d.previewContainerStyle)?void 0:r.call(d,{data:t.data,bounds:t.bounds,scale:o});return n.jsx("div",{style:{...c,...e},children:d.renderPreview({data:t.data,bounds:t.bounds,scale:o})})}return null}function Q({documentId:e,pageIndex:t,scale:o}){const{plugin:r}=y(),[s,a]=i.useState(new Map),l=i.useRef(null),c=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()}}),[]);return i.useEffect(()=>{if(r)return r.registerPageHandlers(e,t,o,{services:c,onPreview:(e,t)=>{a(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,o,r,c]),n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:l,type:"file",style:{display:"none"}}),Array.from(s.entries()).map(([e,t])=>n.jsx(Z,{toolId:e,preview:t,scale:o},e))]})}const _=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,w;const S=s.useDocumentState(t),C=null==(k=null==(m=null==S?void 0:S.document)?void 0:m.pages)?void 0:k[o],A=(null==(j=null==C?void 0:C.size)?void 0:j.width)??0,P=(null==(w=null==C?void 0:C.size)?void 0:w.height)??0,I=f(),z=i.useMemo(()=>{const e=[...I];for(const t of x??[]){const n=e.findIndex(e=>e.id===t.id);n>=0?e[n]=t:e.push(t)}return e},[I,x]),R=i.useMemo(()=>void 0!==r?r:(null==S?void 0:S.scale)??1,[r,null==S?void 0:S.scale]),E=i.useMemo(()=>{if(void 0!==a)return a;return(((null==C?void 0:C.rotation)??0)+((null==S?void 0:S.rotation)??0))%4},[a,null==C?void 0:C.rotation,null==S?void 0:S.rotation]);return n.jsxs("div",{style:{...e},...b,children:[n.jsx(X,{documentId:t,selectionMenu:l,groupSelectionMenu:c,pageIndex:o,scale:R,rotation:E,pageWidth:A,pageHeight:P,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:v,customAnnotationRenderer:y,annotationRenderers:z}),n.jsx(K,{documentId:t,pageIndex:o,scale:R}),n.jsx(Q,{documentId:t,pageIndex:o,scale:R})]})},exports.AnnotationPluginPackage=_,exports.AnnotationRendererProvider=v,exports.GroupSelectionBox=A,exports.createRenderer=P,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
|