@embedpdf/plugin-annotation 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1196 -92
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +31 -2
- package/dist/lib/annotation-plugin.d.ts +177 -2
- package/dist/lib/handlers/types.d.ts +1 -1
- package/dist/lib/helpers.d.ts +6 -1
- package/dist/lib/selectors.d.ts +97 -8
- package/dist/lib/tools/default-tools.d.ts +39 -11
- package/dist/lib/tools/types.d.ts +7 -1
- package/dist/lib/types.d.ts +265 -1
- package/dist/preact/adapter.d.ts +3 -3
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +857 -403
- package/dist/preact/index.js.map +1 -1
- package/dist/react/adapter.d.ts +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +857 -403
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/annotation-container.d.ts +8 -1
- package/dist/shared/components/annotation-layer.d.ts +4 -2
- package/dist/shared/components/annotations/ink.d.ts +3 -3
- package/dist/shared/components/annotations/link.d.ts +28 -0
- package/dist/shared/components/annotations.d.ts +2 -1
- package/dist/shared/components/group-selection-box.d.ts +32 -0
- package/dist/shared/components/index.d.ts +1 -0
- package/dist/shared/components/text-markup/highlight.d.ts +3 -2
- package/dist/shared/components/text-markup/squiggly.d.ts +3 -2
- package/dist/shared/components/text-markup/strikeout.d.ts +3 -2
- package/dist/shared/components/text-markup/underline.d.ts +3 -2
- package/dist/shared/components/types.d.ts +7 -0
- package/dist/shared-preact/components/annotation-container.d.ts +8 -1
- package/dist/shared-preact/components/annotation-layer.d.ts +4 -2
- package/dist/shared-preact/components/annotations/ink.d.ts +3 -3
- package/dist/shared-preact/components/annotations/link.d.ts +28 -0
- package/dist/shared-preact/components/annotations.d.ts +2 -1
- package/dist/shared-preact/components/group-selection-box.d.ts +32 -0
- package/dist/shared-preact/components/index.d.ts +1 -0
- package/dist/shared-preact/components/text-markup/highlight.d.ts +3 -2
- package/dist/shared-preact/components/text-markup/squiggly.d.ts +3 -2
- package/dist/shared-preact/components/text-markup/strikeout.d.ts +3 -2
- package/dist/shared-preact/components/text-markup/underline.d.ts +3 -2
- package/dist/shared-preact/components/types.d.ts +7 -0
- package/dist/shared-react/components/annotation-container.d.ts +8 -1
- package/dist/shared-react/components/annotation-layer.d.ts +4 -2
- package/dist/shared-react/components/annotations/ink.d.ts +3 -3
- package/dist/shared-react/components/annotations/link.d.ts +28 -0
- package/dist/shared-react/components/annotations.d.ts +2 -1
- package/dist/shared-react/components/group-selection-box.d.ts +32 -0
- package/dist/shared-react/components/index.d.ts +1 -0
- package/dist/shared-react/components/text-markup/highlight.d.ts +3 -2
- package/dist/shared-react/components/text-markup/squiggly.d.ts +3 -2
- package/dist/shared-react/components/text-markup/strikeout.d.ts +3 -2
- package/dist/shared-react/components/text-markup/underline.d.ts +3 -2
- package/dist/shared-react/components/types.d.ts +7 -0
- package/dist/svelte/components/AnnotationLayer.svelte.d.ts +5 -1
- package/dist/svelte/components/Annotations.svelte.d.ts +5 -1
- package/dist/svelte/components/GroupSelectionBox.svelte.d.ts +32 -0
- package/dist/svelte/components/annotations/Ink.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Link.svelte.d.ts +24 -0
- package/dist/svelte/components/annotations/index.d.ts +1 -0
- package/dist/svelte/components/index.d.ts +1 -0
- package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +2 -1
- package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +2 -1
- package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +2 -1
- package/dist/svelte/components/text-markup/Underline.svelte.d.ts +2 -1
- package/dist/svelte/components/types.d.ts +2 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +905 -255
- package/dist/svelte/index.js.map +1 -1
- package/dist/svelte/types.d.ts +7 -0
- package/dist/vue/components/annotation-container.vue.d.ts +2 -0
- package/dist/vue/components/annotation-layer.vue.d.ts +28 -5
- package/dist/vue/components/annotations/index.d.ts +1 -0
- package/dist/vue/components/annotations/ink.vue.d.ts +2 -2
- package/dist/vue/components/annotations/line.vue.d.ts +1 -1
- package/dist/vue/components/annotations/link.vue.d.ts +29 -0
- package/dist/vue/components/annotations/polygon.vue.d.ts +1 -1
- package/dist/vue/components/annotations/polyline.vue.d.ts +1 -1
- package/dist/vue/components/annotations.vue.d.ts +65 -1
- package/dist/vue/components/group-selection-box.vue.d.ts +73 -0
- package/dist/vue/components/index.d.ts +1 -0
- package/dist/vue/components/text-markup/highlight.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/squiggly.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/strikeout.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/underline.vue.d.ts +2 -2
- package/dist/vue/hooks/use-annotation.d.ts +2 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +946 -406
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/types.d.ts +7 -0
- package/package.json +10 -10
package/dist/react/adapter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Fragment, useEffect, useRef, useState, useCallback, useMemo, useLayoutEffect, JSX, ChangeEvent, } from 'react';
|
|
1
|
+
export { Fragment, useEffect, useRef, useState, useCallback, useMemo, useLayoutEffect, createContext, useContext, JSX, ChangeEvent, } from 'react';
|
|
2
2
|
export type { ReactNode, HTMLAttributes, CSSProperties, MouseEvent, PointerEvent, TouchEvent, } from 'react';
|
|
3
3
|
export declare const suppressContentEditableWarningProps: {
|
|
4
4
|
suppressContentEditableWarning: boolean;
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-annotation"),n=require("react"),o=require("react/jsx-runtime"),i=require("@embedpdf/models"),s=require("@embedpdf/plugin-interaction-manager/react"),r=require("@embedpdf/plugin-selection/react"),l=require("@embedpdf/utils/react"),a={suppressContentEditableWarning:!0},d=()=>e.usePlugin(t.AnnotationPlugin.id),c=()=>e.useCapability(t.AnnotationPlugin.id);function u({scale:t,documentId:i,pageIndex:s,rotation:r,pageWidth:a,pageHeight:d,trackedAnnotation:u,children:g,isSelected:h,isDraggable:p,isResizable:x,lockAspectRatio:v=!1,style:b={},vertexConfig:y,selectionMenu:f,outlineOffset:m=1,onDoubleClick:j,onSelect:k,zIndex:S=1,resizeUI:M,vertexUI:A,selectionOutlineColor:w="#007ACC",customAnnotationRenderer:z,...D}){const[P,C]=n.useState(u.object),{provides:R}=c(),{canModifyAnnotations:I}=e.useDocumentPermissions(i),E=n.useRef(null),B=I&&p,T=I&&x,$=n.useMemo(()=>R?R.forDocument(i):null,[R,i]),L=P?{...u.object,...P}:u.object,F=(null==M?void 0:M.color)??"#007ACC",O=(null==A?void 0:A.color)??"#007ACC",U=(null==M?void 0:M.size)??12,W=(null==A?void 0:A.size)??12,{dragProps:H,vertices:N,resize:q}=l.useInteractionHandles({controller:{element:L.rect,vertices:null==y?void 0:y.extractVertices(L),constraints:{minWidth:10,minHeight:10,boundingBox:{width:a,height:d}},maintainAspectRatio:v,pageRotation:r,scale:t,enabled:h,onUpdate:e=>{var t;if(!(null==(t=e.transformData)?void 0:t.type))return;"start"===e.state&&(E.current=L);const n=e.transformData.type,o=E.current??L,i=e.transformData.changes.vertices?null==y?void 0:y.transformAnnotation(o,e.transformData.changes.vertices):{rect:e.transformData.changes.rect},r=null==R?void 0:R.transformAnnotation(o,{type:n,changes:i,metadata:e.transformData.metadata});r&&C(e=>({...e,...r})),"end"===e.state&&r&&(E.current=null,null==$||$.updateAnnotation(s,u.object.id,r))}},resizeUI:{handleSize:U,spacing:m,offsetMode:"outside",includeSides:!v,zIndex:S+1},vertexUI:{vertexSize:W,zIndex:S+2},includeVertices:!!y}),V=n.useMemo(()=>{if(I&&j)return j},[I,j]),G=l.useDoublePressProps(V);return n.useEffect(()=>{C(u.object)},[u.object]),o.jsxs("div",{"data-no-interaction":!0,children:[o.jsxs("div",{...B&&h?H:{},...G,style:{position:"absolute",left:L.rect.origin.x*t,top:L.rect.origin.y*t,width:L.rect.size.width*t,height:L.rect.size.height*t,outline:h?`1px solid ${w}`:"none",outlineOffset:h?`${m}px`:"0px",pointerEvents:h?"auto":"none",touchAction:"none",cursor:h&&B?"move":"default",zIndex:S,...b},...D,children:[(()=>{const e="function"==typeof g?g(L):g,n=null==z?void 0:z({annotation:L,children:e,isSelected:h,scale:t,rotation:r,pageWidth:a,pageHeight:d,pageIndex:s,onSelect:k});return null!=n?n:e})(),h&&T&&q.map(({key:e,...t})=>(null==M?void 0:M.component)?M.component({key:e,...t,backgroundColor:F}):o.jsx("div",{...t,style:{...t.style,backgroundColor:F}},e)),h&&I&&N.map(({key:e,...t})=>(null==A?void 0:A.component)?A.component({key:e,...t,backgroundColor:O}):o.jsx("div",{...t,style:{...t.style,backgroundColor:O}},e))]}),f&&o.jsx(l.CounterRotate,{rect:{origin:{x:L.rect.origin.x*t,y:L.rect.origin.y*t},size:{width:L.rect.size.width*t,height:L.rect.size.height*t}},rotation:r,children:e=>f({...e,context:{type:"annotation",annotation:u,pageIndex:s},selected:h,placement:{suggestTop:!1}})})]})}function g({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:i,scale:s,onClick:r,style:l}){return o.jsx(o.Fragment,{children:n.map((n,a)=>o.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?n.origin.x-i.origin.x:n.origin.x)*s,top:(i?n.origin.y-i.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:e,opacity:t,pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:void 0,...l}},a))})}function h({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:i,scale:s,onClick:r,style:l}){const a=2*s;return o.jsx(o.Fragment,{children:n.map((n,d)=>o.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?n.origin.x-i.origin.x:n.origin.x)*s,top:(i?n.origin.y-i.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:a,background:e,opacity:t,pointerEvents:"none"}})},d))})}function p({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:i,scale:s,onClick:r,style:l}){const a=2*s;return o.jsx(o.Fragment,{children:n.map((n,d)=>o.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?n.origin.x-i.origin.x:n.origin.x)*s,top:(i?n.origin.y-i.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:a,background:e,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},d))})}function x({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:i,scale:s,onClick:r,style:l}){const a=2*s,d=6*s,c=`url("data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${2*a}" viewBox="0 0 ${d} ${2*a}">\n <path d="M0 ${a} Q ${d/4} 0 ${d/2} ${a} T ${d} ${a}"\n fill="none" stroke="${e}" stroke-width="${a}" stroke-linecap="round"/>\n </svg>`)}")`;return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*s,top:(i?e.origin.y-i.origin.y:e.origin.y)*s,width:e.size.width*s,height:e.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:2*a,backgroundImage:c,backgroundRepeat:"repeat-x",backgroundSize:`${d}px ${2*a}px`,opacity:t,pointerEvents:"none"}})},n))})}function v({isSelected:e,color:t="#000000",opacity:i=1,strokeWidth:s,inkList:r,rect:l,scale:a,onClick:d}){const c=n.useMemo(()=>r.map(({points:e})=>{let t="";return e.forEach(({x:e,y:n},o)=>{const i=e-l.origin.x,s=n-l.origin.y;t+=(0===o?"M":"L")+i+" "+s+" "}),t.trim()}),[r,l]),u=l.size.width*a,g=l.size.height*a;return o.jsx("svg",{style:{position:"absolute",width:u,height:g,pointerEvents:"none",zIndex:2,overflow:"visible"},width:u,height:g,viewBox:`0 0 ${l.size.width} ${l.size.height}`,children:c.map((n,r)=>o.jsx("path",{d:n,fill:"none",opacity:i,onPointerDown:d,onTouchStart:d,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visibleStroke",stroke:t,strokeWidth:s,strokeLinecap:"round",strokeLinejoin:"round"}},r))})}function b({isSelected:e,color:t="#000000",strokeColor:s,opacity:r=1,strokeWidth:l,strokeStyle:a=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,rect:c,scale:u,onClick:g}){const{width:h,height:p,x:x,y:v}=n.useMemo(()=>{const e=c.size.width,t=c.size.height;return{width:Math.max(e-l,0),height:Math.max(t-l,0),x:l/2,y:l/2}},[c,l]),b=(h+l)*u,y=(p+l)*u;return o.jsx("svg",{style:{position:"absolute",width:b,height:y,pointerEvents:"none",zIndex:2},width:b,height:y,viewBox:`0 0 ${h+l} ${p+l}`,children:o.jsx("rect",{x:x,y:v,width:h,height:p,fill:t,opacity:r,onPointerDown:g,onTouchStart:g,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"transparent"===t?"visibleStroke":"visible",stroke:s??t,strokeWidth:l,...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}})})}function y({color:e="#000000",strokeColor:t,opacity:s=1,strokeWidth:r,strokeStyle:l=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:a,rect:d,scale:c,onClick:u,isSelected:g}){const{width:h,height:p,cx:x,cy:v,rx:b,ry:y}=n.useMemo(()=>{const e=d.size.width,t=d.size.height,n=Math.max(e-r,0),o=Math.max(t-r,0);return{width:e,height:t,cx:r/2+n/2,cy:r/2+o/2,rx:n/2,ry:o/2}},[d,r]),f=h*c,m=p*c;return o.jsx("svg",{style:{position:"absolute",width:f,height:m,pointerEvents:"none",zIndex:2},width:f,height:m,viewBox:`0 0 ${h} ${p}`,children:o.jsx("ellipse",{cx:x,cy:v,rx:b,ry:y,fill:e,opacity:s,onPointerDown:u,onTouchStart:u,style:{cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===e?"visibleStroke":"visible",stroke:t??e,strokeWidth:r,...l===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==a?void 0:a.join(",")}}})})}function f({color:e="transparent",opacity:s=1,strokeWidth:r,strokeColor:l="#000000",strokeStyle:a=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,rect:c,linePoints:u,lineEndings:g,scale:h,onClick:p,isSelected:x}){const{x1:v,y1:b,x2:y,y2:f}=n.useMemo(()=>({x1:u.start.x-c.origin.x,y1:u.start.y-c.origin.y,x2:u.end.x-c.origin.x,y2:u.end.y-c.origin.y}),[u,c]),m=n.useMemo(()=>{const e=Math.atan2(f-b,y-v);return{start:t.patching.createEnding(null==g?void 0:g.start,r,e+Math.PI,v,b),end:t.patching.createEnding(null==g?void 0:g.end,r,e,y,f)}},[g,r,v,b,y,f]),j=c.size.width*h,k=c.size.height*h;return o.jsxs("svg",{style:{position:"absolute",width:j,height:k,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:k,viewBox:`0 0 ${c.size.width} ${c.size.height}`,children:[o.jsx("line",{x1:v,y1:b,x2:y,y2:f,opacity:s,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",pointerEvents:x?"none":"visibleStroke",stroke:l,strokeWidth:r,strokeLinecap:"butt",...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}),m.start&&o.jsx("path",{d:m.start.d,transform:m.start.transform,onPointerDown:p,onTouchStart:p,stroke:l,style:{cursor:x?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:x?"none":m.start.filled?"visible":"visibleStroke",...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}},fill:m.start.filled?e:"none"}),m.end&&o.jsx("path",{d:m.end.d,transform:m.end.transform,stroke:l,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:x?"none":m.end.filled?"visible":"visibleStroke",...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}},fill:m.end.filled?e:"none"})]})}function m({rect:e,vertices:i,color:s="transparent",strokeColor:r="#000000",opacity:l=1,strokeWidth:a,scale:d,isSelected:c,onClick:u,lineEndings:g}){const h=n.useMemo(()=>i.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[i,e]),p=n.useMemo(()=>{if(!h.length)return"";const[e,...t]=h;return`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y} `).join("").trim()},[h]),x=n.useMemo(()=>{if(h.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),n=e(h[0],h[1]),o=e(h[h.length-2],h[h.length-1]);return{start:t.patching.createEnding(null==g?void 0:g.start,a,n+Math.PI,h[0].x,h[0].y),end:t.patching.createEnding(null==g?void 0:g.end,a,o,h[h.length-1].x,h[h.length-1].y)}},[h,g,a]),v=e.size.width*d,b=e.size.height*d;return o.jsxs("svg",{style:{position:"absolute",width:v,height:b,pointerEvents:"none",zIndex:2,overflow:"visible"},width:v,height:b,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[o.jsx("path",{d:p,onPointerDown:u,onTouchStart:u,opacity:l,style:{fill:"none",stroke:r??s,strokeWidth:a,cursor:c?"move":"pointer",pointerEvents:c?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"}}),x.start&&o.jsx("path",{d:x.start.d,transform:x.start.transform,stroke:r,fill:x.start.filled?s:"none",onPointerDown:u,onTouchStart:u,style:{cursor:c?"move":"pointer",strokeWidth:a,pointerEvents:c?"none":x.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),x.end&&o.jsx("path",{d:x.end.d,transform:x.end.transform,stroke:r,fill:x.end.filled?s:"none",onPointerDown:u,onTouchStart:u,style:{cursor:c?"move":"pointer",strokeWidth:a,pointerEvents:c?"none":x.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}})]})}function j({rect:e,vertices:t,color:s="transparent",strokeColor:r="#000000",opacity:l=1,strokeWidth:a,strokeStyle:d=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,scale:u,isSelected:g,onClick:h,currentVertex:p,handleSize:x=14}){const v=p?[...t,p]:t,b=n.useMemo(()=>v.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[v,e]),y=n.useMemo(()=>{if(!b.length)return"";const[e,...t]=b,n=!!p;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(n?"":" Z")).trim()},[b,p]),f=p&&t.length>0,m=e.size.width*u,j=e.size.height*u;return o.jsxs("svg",{style:{position:"absolute",width:m,height:j,pointerEvents:"none",zIndex:2,overflow:"visible"},width:m,height:j,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[o.jsx("path",{d:y,onPointerDown:h,onTouchStart:h,opacity:l,style:{fill:p?"none":s,stroke:r??s,strokeWidth:a,cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===s?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter",...d===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),f&&t.length>1&&o.jsx("path",{d:`M ${b[b.length-1].x} ${b[b.length-1].y} L ${b[0].x} ${b[0].y}`,fill:"none",style:{stroke:r,strokeWidth:a,strokeDasharray:"4,4",opacity:.7}}),f&&t.length>=2&&o.jsx("rect",{x:b[0].x-x/u/2,y:b[0].y-x/u/2,width:x/u,height:x/u,fill:r,opacity:.4,stroke:r,strokeWidth:a/2})]})}function k({isSelected:e,isEditing:t,annotation:s,pageIndex:r,scale:l,onClick:d}){const u=n.useRef(null),{provides:g}=c(),[h,p]=n.useState(!1);n.useEffect(()=>{if(t&&u.current){const e=u.current;e.focus();const t=window.getSelection();if(t){const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}}},[t]),n.useLayoutEffect(()=>{try{const e=navigator,t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1;p(t)}catch{p(!1)}},[]);const x=s.object.fontSize*l,v=h&&t&&x>0&&x<16,b=v?16:x,y=v?x/16:1,f=v?100/y:100;return o.jsx("div",{style:{position:"absolute",width:s.object.rect.size.width*l,height:s.object.rect.size.height*l,cursor:e&&!t?"move":"default",pointerEvents:e&&!t?"none":"auto",zIndex:2},onPointerDown:d,onTouchStart:d,children:o.jsx("span",{ref:u,onBlur:()=>{g&&u.current&&g.updateAnnotation(r,s.object.id,{contents:u.current.innerText})},tabIndex:0,style:{color:s.object.fontColor,fontSize:b,fontFamily:i.standardFontCss(s.object.fontFamily),textAlign:i.textAlignmentToCss(s.object.textAlign),flexDirection:"column",justifyContent:s.object.verticalAlign===i.PdfVerticalAlignment.Top?"flex-start":s.object.verticalAlign===i.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:s.object.backgroundColor,opacity:s.object.opacity,width:v?`${f}%`:"100%",height:v?`${f}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:t?"text":"pointer",outline:"none",transform:v?`scale(${y})`:void 0,transformOrigin:"top left"},contentEditable:t,...a,children:s.object.contents})})}function S({documentId:e,pageIndex:t,annotation:s,scaleFactor:r=1,style:l,...a}){const{provides:d}=c(),[u,g]=n.useState(null),h=n.useRef(null),{width:p,height:x}=s.rect.size;n.useEffect(()=>{if(d){const n=d.forDocument(e).renderAnnotation({pageIndex:t,annotation:s,options:{scaleFactor:r,dpr:window.devicePixelRatio}});return n.wait(e=>{const t=URL.createObjectURL(e);g(t),h.current=t},i.ignore),()=>{h.current?(URL.revokeObjectURL(h.current),h.current=null):n.abort({code:i.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,r,d,e,s.id,p,x]);return o.jsx(n.Fragment,{children:u&&o.jsx("img",{src:u,onLoad:()=>{h.current&&(URL.revokeObjectURL(h.current),h.current=null)},...a,style:{width:"100%",height:"100%",display:"block",...l||{}}})})}function M({isSelected:e,annotation:t,documentId:n,pageIndex:i,scale:s,onClick:r}){return o.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:e?"none":"auto",cursor:"pointer"},onPointerDown:r,onTouchStart:r,children:o.jsx(S,{documentId:n,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:s})})}function A(e){const{documentId:l,pageIndex:a,scale:d,selectionMenu:S}=e,{provides:A}=c(),{provides:w}=r.useSelectionCapability(),[z,D]=n.useState([]),{register:P}=s.usePointerHandlers({documentId:l,pageIndex:a}),[C,R]=n.useState(null),[I,E]=n.useState(null),B=n.useMemo(()=>A?A.forDocument(l):null,[A,l]);n.useEffect(()=>{if(B){const e=B.getState();return D(t.getAnnotationsByPageIndex(e,a)),R(t.getSelectedAnnotationByPageIndex(e,a)),B.onStateChange(e=>{D(t.getAnnotationsByPageIndex(e,a)),R(t.getSelectedAnnotationByPageIndex(e,a))})}},[B,a]);const T=n.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&B&&(B.deselectAnnotation(),E(null))}}),[B]),$=n.useCallback((e,t)=>{e.stopPropagation(),B&&w&&(B.selectAnnotation(a,t.object.id),w.clear(),t.object.id!==I&&E(null))},[B,w,I,a]);return n.useEffect(()=>P(T,{documentId:l}),[P,T]),o.jsx(o.Fragment,{children:z.map(s=>{const r=(null==C?void 0:C.object.id)===s.object.id,c=I===s.object.id,A=null==B?void 0:B.findToolForAnnotation(s.object);return t.isInk(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!0,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(v,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isSquare(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!0,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(b,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isCircle(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!0,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(y,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isUnderline(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!1,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),zIndex:0,style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(h,{...e,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isStrikeout(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!1,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),zIndex:0,style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(p,{...e,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isSquiggly(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!1,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),zIndex:0,style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(x,{...e,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isHighlight(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!1,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),zIndex:0,style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Multiply)},...e,children:e=>o.jsx(g,{...e,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isLine(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(f,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})})},s.object.id):t.isPolyline(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(m,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})})},s.object.id):t.isPolygon(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(j,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})})},s.object.id):t.isFreeText(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:((null==A?void 0:A.interaction.isDraggable)??!0)&&!c,isResizable:(null==A?void 0:A.interaction.isResizable)??!0,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},onDoubleClick:e=>{e.stopPropagation(),E(s.object.id)},...e,children:e=>o.jsx(k,{isSelected:r,isEditing:c,annotation:{...s,object:e},pageIndex:a,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isStamp(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!0,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(M,{isSelected:r,annotation:s,documentId:l,pageIndex:a,scale:d,onClick:e=>$(e,s)})},s.object.id):null})})}function w({documentId:e,pageIndex:t,scale:s}){var l,a,d,u,v,b,y,f,m,j,k,S;const{provides:M}=r.useSelectionCapability(),{provides:A}=c(),[w,z]=n.useState([]),[D,P]=n.useState(null),[C,R]=n.useState(null);if(n.useEffect(()=>{if(M)return M.forDocument(e).onSelectionChange(()=>{z(M.forDocument(e).getHighlightRectsForPage(t)),P(M.forDocument(e).getBoundingRectForPage(t))})},[M,e,t]),n.useEffect(()=>{if(A)return R(A.forDocument(e).getActiveTool()),A.forDocument(e).onActiveToolChange(e=>R(e))},[A,e]),!D)return null;if(!C||!C.defaults)return null;switch(C.defaults.type){case i.PdfAnnotationSubtype.UNDERLINE:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(l=C.defaults)?void 0:l.blendMode)??i.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(h,{color:null==(a=C.defaults)?void 0:a.color,opacity:null==(d=C.defaults)?void 0:d.opacity,segmentRects:w,scale:s})});case i.PdfAnnotationSubtype.HIGHLIGHT:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(u=C.defaults)?void 0:u.blendMode)??i.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(g,{color:null==(v=C.defaults)?void 0:v.color,opacity:null==(b=C.defaults)?void 0:b.opacity,segmentRects:w,scale:s})});case i.PdfAnnotationSubtype.STRIKEOUT:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(y=C.defaults)?void 0:y.blendMode)??i.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(p,{color:null==(f=C.defaults)?void 0:f.color,opacity:null==(m=C.defaults)?void 0:m.opacity,segmentRects:w,scale:s})});case i.PdfAnnotationSubtype.SQUIGGLY:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(j=C.defaults)?void 0:j.blendMode)??i.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(x,{color:null==(k=C.defaults)?void 0:k.color,opacity:null==(S=C.defaults)?void 0:S.opacity,segmentRects:w,scale:s})});default:return null}}function z({preview:e,scale:t}){const{bounds:n}=e,s={position:"absolute",left:n.origin.x*t,top:n.origin.y*t,width:n.size.width*t,height:n.size.height*t,pointerEvents:"none",zIndex:10};return e.type===i.PdfAnnotationSubtype.CIRCLE?o.jsx("div",{style:s,children:o.jsx(y,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.SQUARE?o.jsx("div",{style:s,children:o.jsx(b,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.POLYGON?o.jsx("div",{style:s,children:o.jsx(j,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.POLYLINE?o.jsx("div",{style:s,children:o.jsx(m,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.LINE?o.jsx("div",{style:s,children:o.jsx(f,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.INK?o.jsx("div",{style:s,children:o.jsx(v,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.FREETEXT?o.jsx("div",{style:s,children:o.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})}):null}function D({documentId:e,pageIndex:t,scale:i}){const{plugin:s}=d(),[r,l]=n.useState(new Map),a=n.useRef(null),c=n.useRef(null),u=n.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!a.current)return;const n=a.current;n.accept=e,n.onchange=e=>{var o;const i=null==(o=e.target.files)?void 0:o[0];i&&(t(i),n.value="")},n.click()},processImage:({source:e,maxWidth:t,maxHeight:n,onComplete:o})=>{const i=c.current;if(!i||!i.getContext)return;const s=i.getContext("2d");if(!s)return;const r=new Image;r.crossOrigin="Anonymous",r.onload=()=>{let{naturalWidth:l,naturalHeight:a}=r;const d=t?t/l:1,c=n?n/a:1,u=Math.min(d,c,1),g=l*u,h=a*u;i.width=g,i.height=h,s.drawImage(r,0,0,g,h);const p=s.getImageData(0,0,g,h);"string"!=typeof e&&URL.revokeObjectURL(r.src),o({imageData:p,width:g,height:h})},r.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return n.useEffect(()=>{if(s)return s.registerPageHandlers(e,t,i,{services:u,onPreview:(e,t)=>{l(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,i,s,u]),o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:a,type:"file",style:{display:"none"}}),o.jsx("canvas",{ref:c,style:{display:"none"}}),Array.from(r.entries()).map(([e,t])=>o.jsx(z,{preview:t,scale:i},e))]})}exports.AnnotationLayer=function({style:t,documentId:s,pageIndex:r,scale:l,rotation:a,selectionMenu:d,resizeUI:c,vertexUI:u,selectionOutlineColor:g,customAnnotationRenderer:h,...p}){var x,v,b,y;const f=e.useDocumentState(s),m=null==(v=null==(x=null==f?void 0:f.document)?void 0:x.pages)?void 0:v[r],j=(null==(b=null==m?void 0:m.size)?void 0:b.width)??0,k=(null==(y=null==m?void 0:m.size)?void 0:y.height)??0,S=n.useMemo(()=>void 0!==l?l:(null==f?void 0:f.scale)??1,[l,null==f?void 0:f.scale]),M=n.useMemo(()=>void 0!==a?a:(null==f?void 0:f.rotation)??i.Rotation.Degree0,[a,null==f?void 0:f.rotation]);return o.jsxs("div",{style:{...t},...p,children:[o.jsx(A,{documentId:s,selectionMenu:d,pageIndex:r,scale:S,rotation:M,pageWidth:j,pageHeight:k,resizeUI:c,vertexUI:u,selectionOutlineColor:g,customAnnotationRenderer:h}),o.jsx(w,{documentId:s,pageIndex:r,scale:S}),o.jsx(D,{documentId:s,pageIndex:r,scale:S})]})},exports.useAnnotation=e=>{var o;const{provides:i}=c(),[s,r]=n.useState((null==(o=null==i?void 0:i.forDocument(e))?void 0:o.getState())??t.initialDocumentState());return n.useEffect(()=>{if(!i)return;const t=i.forDocument(e);return r(t.getState()),t.onStateChange(e=>{r(e)})},[i,e]),{state:s,provides:(null==i?void 0:i.forDocument(e))??null}},exports.useAnnotationCapability=c,exports.useAnnotationPlugin=d,Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-annotation"),n=require("react"),o=require("react/jsx-runtime"),i=require("@embedpdf/models"),r=require("@embedpdf/plugin-interaction-manager/react"),s=require("@embedpdf/plugin-selection/react"),l=require("@embedpdf/utils/react"),a={suppressContentEditableWarning:!0},c=()=>e.usePlugin(t.AnnotationPlugin.id),d=()=>e.useCapability(t.AnnotationPlugin.id);function u({scale:t,documentId:i,pageIndex:r,rotation:s,pageWidth:a,pageHeight:u,trackedAnnotation:g,children:h,isSelected:p,isMultiSelected:x=!1,isDraggable:f,isResizable:v,lockAspectRatio:b=!1,style:y={},vertexConfig:m,selectionMenu:j,outlineOffset:k=1,onDoubleClick:S,onSelect:M,zIndex:z=1,resizeUI:A,vertexUI:w,selectionOutlineColor:C="#007ACC",customAnnotationRenderer:D,...R}){const[I,P]=n.useState(g.object),{provides:E}=d(),{plugin:B}=c(),{canModifyAnnotations:T}=e.useDocumentPermissions(i),$=n.useRef(null),L=T&&f&&!x,F=T&&v&&!x,U=n.useMemo(()=>E?E.forDocument(i):null,[E,i]),W=I?{...g.object,...I}:g.object,O=(null==A?void 0:A.color)??"#007ACC",H=(null==w?void 0:w.color)??"#007ACC",N=(null==A?void 0:A.size)??12,q=(null==w?void 0:w.size)??12,V=n.useRef(null),G=n.useCallback(e=>{var t;if(!(null==(t=e.transformData)?void 0:t.type)||x||!B)return;const{type:n,changes:o,metadata:s}=e.transformData,l=g.object.id,c={width:a,height:u};if("start"===e.state&&(V.current=g.object.rect,$.current=g.object,"move"===n?B.startDrag(i,{annotationIds:[l],pageSize:c}):"resize"===n&&B.startResize(i,{annotationIds:[l],pageSize:c,resizeHandle:(null==s?void 0:s.handle)??"se"})),o.rect&&V.current)if("move"===n){const e={x:o.rect.origin.x-V.current.origin.x,y:o.rect.origin.y-V.current.origin.y};B.updateDrag(i,e)}else"resize"===n&&B.updateResize(i,o.rect);if("vertex-edit"===n&&o.vertices&&m){const t=$.current??g.object,i=m.transformAnnotation(t,o.vertices),a=null==E?void 0:E.transformAnnotation(t,{type:n,changes:i,metadata:s});a&&(P(e=>({...e,...a})),"end"===e.state&&(null==U||U.updateAnnotation(r,l,a)))}"end"===e.state&&(V.current=null,$.current=null,"move"===n?B.commitDrag(i):"resize"===n&&B.commitResize(i))},[B,i,g.object,a,u,r,x,m,E,U]),{dragProps:K,vertices:Y,resize:Q}=l.useInteractionHandles({controller:{element:W.rect,vertices:null==m?void 0:m.extractVertices(W),constraints:{minWidth:10,minHeight:10,boundingBox:{width:a,height:u}},maintainAspectRatio:b,pageRotation:s,scale:t,enabled:p&&!x,onUpdate:G},resizeUI:{handleSize:N,spacing:k,offsetMode:"outside",includeSides:!b,zIndex:z+1},vertexUI:{vertexSize:q,zIndex:z+2},includeVertices:!!m}),X=n.useMemo(()=>{if(T&&S)return S},[T,S]),Z=l.useDoublePressProps(X);n.useEffect(()=>{P(g.object)},[g.object]),n.useEffect(()=>{if(!B)return;const e=g.object.id,t=t=>{var n;if(t.documentId!==i)return;const o=null==(n=t.previewPatches)?void 0:n[e];"update"===t.type&&o?P(e=>({...e,...o})):"cancel"===t.type&&P(g.object)},n=[B.onDragChange(t),B.onResizeChange(t)];return()=>n.forEach(e=>e())},[B,i,g.object]);const J=p&&!x;return o.jsxs("div",{"data-no-interaction":!0,children:[o.jsxs("div",{...L&&p?K:{},...Z,style:{position:"absolute",left:W.rect.origin.x*t,top:W.rect.origin.y*t,width:W.rect.size.width*t,height:W.rect.size.height*t,outline:J?`1px solid ${C}`:"none",outlineOffset:J?`${k}px`:"0px",pointerEvents:p&&!x?"auto":"none",touchAction:"none",cursor:p&&L?"move":"default",zIndex:z,...y},...R,children:[(()=>{const e="function"==typeof h?h(W):h,n=null==D?void 0:D({annotation:W,children:e,isSelected:p,scale:t,rotation:s,pageWidth:a,pageHeight:u,pageIndex:r,onSelect:M});return null!=n?n:e})(),p&&F&&Q.map(({key:e,...t})=>(null==A?void 0:A.component)?A.component({key:e,...t,backgroundColor:O}):o.jsx("div",{...t,style:{...t.style,backgroundColor:O}},e)),p&&T&&!x&&Y.map(({key:e,...t})=>(null==w?void 0:w.component)?w.component({key:e,...t,backgroundColor:H}):o.jsx("div",{...t,style:{...t.style,backgroundColor:H}},e))]}),j&&!x&&o.jsx(l.CounterRotate,{rect:{origin:{x:W.rect.origin.x*t,y:W.rect.origin.y*t},size:{width:W.rect.size.width*t,height:W.rect.size.height*t}},rotation:s,children:e=>j({...e,context:{type:"annotation",annotation:g,pageIndex:r},selected:p,placement:{suggestTop:!1}})})]})}function g({documentId:e,pageIndex:t,scale:r,rotation:s,pageWidth:a,pageHeight:d,selectedAnnotations:u,isDraggable:g,isResizable:h,resizeUI:p,selectionOutlineColor:x="#007ACC",outlineOffset:f=2,zIndex:v=100,groupSelectionMenu:b}){const{plugin:y}=c(),m=n.useRef(null),j=n.useRef(!1),k=n.useRef(!1),S=n.useMemo(()=>{const e=u.map(e=>e.object.rect);return i.boundingRectOrEmpty(e)},[u]),[M,z]=n.useState(S);n.useEffect(()=>{j.current||k.current||z(S)},[S]);const A=n.useCallback(t=>{var n,o;if(!(null==(n=t.transformData)?void 0:n.type))return;if(!y)return;const i=t.transformData.type,r="move"===i,s="resize"===i;if(r&&!g)return;"start"===t.state&&(m.current=S,r?(j.current=!0,y.startDrag(e,{annotationIds:u.map(e=>e.object.id),pageSize:{width:a,height:d}})):s&&(k.current=!0,y.startResize(e,{annotationIds:u.map(e=>e.object.id),pageSize:{width:a,height:d},resizeHandle:(null==(o=t.transformData.metadata)?void 0:o.handle)??"se"})));const l=m.current??S;if(r&&t.transformData.changes.rect){const n=t.transformData.changes.rect,o={x:n.origin.x-l.origin.x,y:n.origin.y-l.origin.y},i=y.updateDrag(e,o);z({...l,origin:{x:l.origin.x+i.x,y:l.origin.y+i.y}})}else if(s&&t.transformData.changes.rect){const n=t.transformData.changes.rect;y.updateResize(e,n),z(n)}"end"===t.state&&(m.current=null,r&&j.current?(j.current=!1,y.commitDrag(e)):s&&k.current&&(k.current=!1,y.commitResize(e)))},[y,e,a,d,S,g,u]),w=(null==p?void 0:p.color)??"#007ACC",C=(null==p?void 0:p.size)??12,{dragProps:D,resize:R}=l.useInteractionHandles({controller:{element:M,constraints:{minWidth:20,minHeight:20,boundingBox:{width:a,height:d}},maintainAspectRatio:!1,pageRotation:s,scale:r,enabled:!0,onUpdate:A},resizeUI:{handleSize:C,spacing:f,offsetMode:"outside",includeSides:!0,zIndex:v+1},vertexUI:{vertexSize:0,zIndex:v},includeVertices:!1});return u.length<2?null:o.jsxs("div",{"data-group-selection-box":!0,"data-no-interaction":!0,children:[o.jsx("div",{...g?D:{onPointerDown:e=>e.stopPropagation()},style:{position:"absolute",left:M.origin.x*r,top:M.origin.y*r,width:M.size.width*r,height:M.size.height*r,outline:`2px dashed ${x}`,outlineOffset:f-1,cursor:g?"move":"default",touchAction:"none",zIndex:v},children:h&&R.map(({key:e,...t})=>(null==p?void 0:p.component)?p.component({key:e,...t,backgroundColor:w}):o.jsx("div",{...t,style:{...t.style,backgroundColor:w}},e))}),b&&o.jsx(l.CounterRotate,{rect:{origin:{x:M.origin.x*r,y:M.origin.y*r},size:{width:M.size.width*r,height:M.size.height*r}},rotation:s,children:e=>b({...e,context:{type:"group",annotations:u,pageIndex:t},selected:!0,placement:{suggestTop:!1}})})]})}function h({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:s,style:l}){const a=e??"#FFFF00";return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:a,opacity:t,pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:void 0,...l}},n))})}function p({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:s,style:l}){const a=e??"#FFFF00",c=2*r;return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:c,background:a,opacity:t,pointerEvents:"none"}})},n))})}function x({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:s,style:l}){const a=e??"#FFFF00",c=2*r;return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:c,background:a,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},n))})}function f({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:s,style:l}){const a=2*r,c=6*r,d=`url("data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${c}" height="${2*a}" viewBox="0 0 ${c} ${2*a}">\n <path d="M0 ${a} Q ${c/4} 0 ${c/2} ${a} T ${c} ${a}"\n fill="none" stroke="${e??"#FFFF00"}" stroke-width="${a}" stroke-linecap="round"/>\n </svg>`)}")`;return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:2*a,backgroundImage:d,backgroundRepeat:"repeat-x",backgroundSize:`${c}px ${2*a}px`,opacity:t,pointerEvents:"none"}})},n))})}function v({isSelected:e,strokeColor:t,opacity:i=1,strokeWidth:r,inkList:s,rect:l,scale:a,onClick:c}){const d=t??"#000000",u=n.useMemo(()=>s.map(({points:e})=>{let t="";return e.forEach(({x:e,y:n},o)=>{const i=e-l.origin.x,r=n-l.origin.y;t+=(0===o?"M":"L")+i+" "+r+" "}),t.trim()}),[s,l]),g=l.size.width*a,h=l.size.height*a;return o.jsx("svg",{style:{position:"absolute",width:g,height:h,pointerEvents:"none",zIndex:2,overflow:"visible"},width:g,height:h,viewBox:`0 0 ${l.size.width} ${l.size.height}`,children:u.map((t,n)=>o.jsx("path",{d:t,fill:"none",opacity:i,onPointerDown:c,onTouchStart:c,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visibleStroke",stroke:d,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}},n))})}function b({isSelected:e,color:t="#000000",strokeColor:r,opacity:s=1,strokeWidth:l,strokeStyle:a=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:g}){const{width:h,height:p,x:x,y:f}=n.useMemo(()=>{const e=d.size.width,t=d.size.height;return{width:Math.max(e-l,0),height:Math.max(t-l,0),x:l/2,y:l/2}},[d,l]),v=(h+l)*u,b=(p+l)*u;return o.jsx("svg",{style:{position:"absolute",width:v,height:b,pointerEvents:"none",zIndex:2},width:v,height:b,viewBox:`0 0 ${h+l} ${p+l}`,children:o.jsx("rect",{x:x,y:f,width:h,height:p,fill:t,opacity:s,onPointerDown:g,onTouchStart:g,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"transparent"===t?"visibleStroke":"visible",stroke:r??t,strokeWidth:l,...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})})}function y({color:e="#000000",strokeColor:t,opacity:r=1,strokeWidth:s,strokeStyle:l=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:a,rect:c,scale:d,onClick:u,isSelected:g}){const{width:h,height:p,cx:x,cy:f,rx:v,ry:b}=n.useMemo(()=>{const e=c.size.width,t=c.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}},[c,s]),y=h*d,m=p*d;return o.jsx("svg",{style:{position:"absolute",width:y,height:m,pointerEvents:"none",zIndex:2},width:y,height:m,viewBox:`0 0 ${h} ${p}`,children:o.jsx("ellipse",{cx:x,cy:f,rx:v,ry:b,fill:e,opacity:r,onPointerDown:u,onTouchStart:u,style:{cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===e?"visibleStroke":"visible",stroke:t??e,strokeWidth:s,...l===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==a?void 0:a.join(",")}}})})}function m({color:e="transparent",opacity:r=1,strokeWidth:s,strokeColor:l="#000000",strokeStyle:a=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,linePoints:u,lineEndings:g,scale:h,onClick:p,isSelected:x}){const{x1:f,y1:v,x2:b,y2:y}=n.useMemo(()=>({x1:u.start.x-d.origin.x,y1:u.start.y-d.origin.y,x2:u.end.x-d.origin.x,y2:u.end.y-d.origin.y}),[u,d]),m=n.useMemo(()=>{const e=Math.atan2(y-v,b-f);return{start:t.patching.createEnding(null==g?void 0:g.start,s,e+Math.PI,f,v),end:t.patching.createEnding(null==g?void 0:g.end,s,e,b,y)}},[g,s,f,v,b,y]),j=d.size.width*h,k=d.size.height*h;return o.jsxs("svg",{style:{position:"absolute",width:j,height:k,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:k,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[o.jsx("line",{x1:f,y1:v,x2:b,y2:y,opacity:r,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",pointerEvents:x?"none":"visibleStroke",stroke:l,strokeWidth:s,strokeLinecap:"butt",...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),m.start&&o.jsx("path",{d:m.start.d,transform:m.start.transform,onPointerDown:p,onTouchStart:p,stroke:l,style:{cursor:x?"move":"pointer",strokeWidth:s,strokeLinecap:"butt",pointerEvents:x?"none":m.start.filled?"visible":"visibleStroke",...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.start.filled?e:"none"}),m.end&&o.jsx("path",{d:m.end.d,transform:m.end.transform,stroke:l,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",strokeWidth:s,strokeLinecap:"butt",pointerEvents:x?"none":m.end.filled?"visible":"visibleStroke",...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.end.filled?e:"none"})]})}function j({rect:e,vertices:i,color:r="transparent",strokeColor:s="#000000",opacity:l=1,strokeWidth:a,scale:c,isSelected:d,onClick:u,lineEndings:g}){const h=n.useMemo(()=>i.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[i,e]),p=n.useMemo(()=>{if(!h.length)return"";const[e,...t]=h;return`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y} `).join("").trim()},[h]),x=n.useMemo(()=>{if(h.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),n=e(h[0],h[1]),o=e(h[h.length-2],h[h.length-1]);return{start:t.patching.createEnding(null==g?void 0:g.start,a,n+Math.PI,h[0].x,h[0].y),end:t.patching.createEnding(null==g?void 0:g.end,a,o,h[h.length-1].x,h[h.length-1].y)}},[h,g,a]),f=e.size.width*c,v=e.size.height*c;return o.jsxs("svg",{style:{position:"absolute",width:f,height:v,pointerEvents:"none",zIndex:2,overflow:"visible"},width:f,height:v,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[o.jsx("path",{d:p,onPointerDown:u,onTouchStart:u,opacity:l,style:{fill:"none",stroke:s??r,strokeWidth:a,cursor:d?"move":"pointer",pointerEvents:d?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"}}),x.start&&o.jsx("path",{d:x.start.d,transform:x.start.transform,stroke:s,fill:x.start.filled?r:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":x.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),x.end&&o.jsx("path",{d:x.end.d,transform:x.end.transform,stroke:s,fill:x.end.filled?r:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":x.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}})]})}function k({rect:e,vertices:t,color:r="transparent",strokeColor:s="#000000",opacity:l=1,strokeWidth:a,strokeStyle:c=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,scale:u,isSelected:g,onClick:h,currentVertex:p,handleSize:x=14}){const f=p?[...t,p]:t,v=n.useMemo(()=>f.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[f,e]),b=n.useMemo(()=>{if(!v.length)return"";const[e,...t]=v,n=!!p;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(n?"":" Z")).trim()},[v,p]),y=p&&t.length>0,m=e.size.width*u,j=e.size.height*u;return o.jsxs("svg",{style:{position:"absolute",width:m,height:j,pointerEvents:"none",zIndex:2,overflow:"visible"},width:m,height:j,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[o.jsx("path",{d:b,onPointerDown:h,onTouchStart:h,opacity:l,style:{fill:p?"none":r,stroke:s??r,strokeWidth:a,cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===r?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter",...c===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}),y&&t.length>1&&o.jsx("path",{d:`M ${v[v.length-1].x} ${v[v.length-1].y} L ${v[0].x} ${v[0].y}`,fill:"none",style:{stroke:s,strokeWidth:a,strokeDasharray:"4,4",opacity:.7}}),y&&t.length>=2&&o.jsx("rect",{x:v[0].x-x/u/2,y:v[0].y-x/u/2,width:x/u,height:x/u,fill:s,opacity:.4,stroke:s,strokeWidth:a/2})]})}function S({isSelected:e,isEditing:t,annotation:r,pageIndex:s,scale:l,onClick:c}){const u=n.useRef(null),{provides:g}=d(),[h,p]=n.useState(!1);n.useEffect(()=>{if(t&&u.current){const e=u.current;e.focus();const t=window.getSelection();if(t){const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}}},[t]),n.useLayoutEffect(()=>{try{const e=navigator,t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1;p(t)}catch{p(!1)}},[]);const x=r.object.fontSize*l,f=h&&t&&x>0&&x<16,v=f?16:x,b=f?x/16:1,y=f?100/b:100;return o.jsx("div",{style:{position:"absolute",width:r.object.rect.size.width*l,height:r.object.rect.size.height*l,cursor:e&&!t?"move":"default",pointerEvents:e&&!t?"none":"auto",zIndex:2},onPointerDown:c,onTouchStart:c,children:o.jsx("span",{ref:u,onBlur:()=>{g&&u.current&&g.updateAnnotation(s,r.object.id,{contents:u.current.innerText})},tabIndex:0,style:{color:r.object.fontColor,fontSize:v,fontFamily:i.standardFontCss(r.object.fontFamily),textAlign:i.textAlignmentToCss(r.object.textAlign),flexDirection:"column",justifyContent:r.object.verticalAlign===i.PdfVerticalAlignment.Top?"flex-start":r.object.verticalAlign===i.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:r.object.color??r.object.backgroundColor,opacity:r.object.opacity,width:f?`${y}%`:"100%",height:f?`${y}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:t?"text":"pointer",outline:"none",transform:f?`scale(${b})`:void 0,transformOrigin:"top left"},contentEditable:t,...a,children:r.object.contents})})}function M({documentId:e,pageIndex:t,annotation:r,scaleFactor:s=1,style:l,...a}){const{provides:c}=d(),[u,g]=n.useState(null),h=n.useRef(null),{width:p,height:x}=r.rect.size;n.useEffect(()=>{if(c){const n=c.forDocument(e).renderAnnotation({pageIndex:t,annotation:r,options:{scaleFactor:s,dpr:window.devicePixelRatio}});return n.wait(e=>{const t=URL.createObjectURL(e);g(t),h.current=t},i.ignore),()=>{h.current?(URL.revokeObjectURL(h.current),h.current=null):n.abort({code:i.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,s,c,e,r.id,p,x]);return o.jsx(n.Fragment,{children:u&&o.jsx("img",{src:u,onLoad:()=>{h.current&&(URL.revokeObjectURL(h.current),h.current=null)},...a,style:{width:"100%",height:"100%",display:"block",...l||{}}})})}function z({isSelected:e,annotation:t,documentId:n,pageIndex:i,scale:r,onClick:s}){return o.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:e?"none":"auto",cursor:"pointer"},onPointerDown:s,onTouchStart:s,children:o.jsx(M,{documentId:n,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:r})})}function A({isSelected:e,strokeColor:t="#0000FF",strokeWidth:r=2,strokeStyle:s=i.PdfAnnotationBorderStyle.UNDERLINE,strokeDashArray:l,rect:a,scale:c,onClick:d,hasIRT:u=!1}){const{width:g,height:h}=n.useMemo(()=>({width:a.size.width,height:a.size.height}),[a]),p=g*c,x=h*c,f=n.useMemo(()=>{if(s===i.PdfAnnotationBorderStyle.DASHED)return(null==l?void 0:l.join(","))??`${3*r},${r}`},[s,l,r]),v=s===i.PdfAnnotationBorderStyle.UNDERLINE;return o.jsxs("svg",{style:{position:"absolute",width:p,height:x,pointerEvents:"none",zIndex:2},width:p,height:x,viewBox:`0 0 ${g} ${h}`,children:[o.jsx("rect",{x:0,y:0,width:g,height:h,fill:"transparent",onPointerDown:u?void 0:d,onTouchStart:u?void 0:d,style:{cursor:u?"default":e?"move":"pointer",pointerEvents:u||e?"none":"visible"}}),v?o.jsx("line",{x1:1,y1:h-1,x2:g-1,y2:h-1,stroke:t,strokeWidth:r,strokeDasharray:f,style:{pointerEvents:"none"}}):o.jsx("rect",{x:r/2,y:r/2,width:Math.max(g-r,0),height:Math.max(h-r,0),fill:"transparent",stroke:t,strokeWidth:r,strokeDasharray:f,style:{pointerEvents:"none"}})]})}function w(e){const{documentId:l,pageIndex:a,scale:c,pageWidth:M,pageHeight:w,selectionMenu:C}=e,{provides:D}=d(),{provides:R}=s.useSelectionCapability(),[I,P]=n.useState([]),{register:E}=r.usePointerHandlers({documentId:l,pageIndex:a}),[B,T]=n.useState([]),[$,L]=n.useState(null),F=n.useMemo(()=>D?D.forDocument(l):null,[D,l]),U=B.length>1;n.useEffect(()=>{if(F){const e=F.getState();return P(t.getAnnotationsByPageIndex(e,a)),T(t.getSelectedAnnotationIds(e)),F.onStateChange(e=>{P(t.getAnnotationsByPageIndex(e,a)),T(t.getSelectedAnnotationIds(e))})}},[F,a]);const W=n.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&F&&(F.deselectAnnotation(),L(null))}}),[F]),O=n.useCallback((e,t)=>{if(e.stopPropagation(),F&&R){R.clear();"metaKey"in e&&(e.metaKey||e.ctrlKey)?F.toggleSelection(a,t.object.id):F.selectAnnotation(a,t.object.id),t.object.id!==$&&L(null)}},[F,R,$,a]),H=n.useCallback((e,t)=>{if(e.stopPropagation(),F&&R){if(R.clear(),t.object.inReplyToId){const e=t.object.inReplyToId,n=I.find(t=>t.object.id===e);if(n)return void F.selectAnnotation(n.object.pageIndex,e)}F.selectAnnotation(a,t.object.id)}},[F,R,I,a]);n.useEffect(()=>E(W,{documentId:l}),[E,W]);const N=n.useMemo(()=>I.filter(e=>B.includes(e.object.id)),[I,B]),q=n.useMemo(()=>!(N.length<2)&&N.every(e=>{const t=null==F?void 0:F.findToolForAnnotation(e.object);return(null==t?void 0:t.interaction.isGroupDraggable)??(null==t?void 0:t.interaction.isDraggable)??!0}),[N,F]),V=n.useMemo(()=>!(N.length<2)&&N.every(e=>{const t=null==F?void 0:F.findToolForAnnotation(e.object);return(null==t?void 0:t.interaction.isGroupResizable)??(null==t?void 0:t.interaction.isResizable)??!0}),[N,F]),G=n.useMemo(()=>{if(!F)return!1;const e=F.getSelectedAnnotations();return e.length>1&&e.every(e=>e.object.pageIndex===a)},[F,a,B]);return o.jsxs(o.Fragment,{children:[I.map(r=>{const s=B.includes(r.object.id),d=$===r.object.id,g=null==F?void 0:F.findToolForAnnotation(r.object);if(t.isInk(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:(null==g?void 0:g.interaction.isDraggable)??!0,isResizable:(null==g?void 0:g.interaction.isResizable)??!0,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(v,{...e,isSelected:s,scale:c,onClick:e=>O(e,r)})},r.object.id);if(t.isSquare(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:(null==g?void 0:g.interaction.isDraggable)??!0,isResizable:(null==g?void 0:g.interaction.isResizable)??!0,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(b,{...e,isSelected:s,scale:c,onClick:e=>O(e,r)})},r.object.id);if(t.isCircle(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:(null==g?void 0:g.interaction.isDraggable)??!0,isResizable:(null==g?void 0:g.interaction.isResizable)??!0,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(y,{...e,isSelected:s,scale:c,onClick:e=>O(e,r)})},r.object.id);if(t.isUnderline(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:(null==g?void 0:g.interaction.isDraggable)??!1,isResizable:(null==g?void 0:g.interaction.isResizable)??!1,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),zIndex:0,style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(p,{...e,scale:c,onClick:e=>O(e,r)})},r.object.id);if(t.isStrikeout(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:(null==g?void 0:g.interaction.isDraggable)??!1,isResizable:(null==g?void 0:g.interaction.isResizable)??!1,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),zIndex:0,style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(x,{...e,scale:c,onClick:e=>O(e,r)})},r.object.id);if(t.isSquiggly(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:(null==g?void 0:g.interaction.isDraggable)??!1,isResizable:(null==g?void 0:g.interaction.isResizable)??!1,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),zIndex:0,style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(f,{...e,scale:c,onClick:e=>O(e,r)})},r.object.id);if(t.isHighlight(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:(null==g?void 0:g.interaction.isDraggable)??!1,isResizable:(null==g?void 0:g.interaction.isResizable)??!1,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),zIndex:0,style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Multiply)},...e,children:e=>o.jsx(h,{...e,scale:c,onClick:e=>O(e,r)})},r.object.id);if(t.isLine(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:(null==g?void 0:g.interaction.isDraggable)??!0,isResizable:(null==g?void 0:g.interaction.isResizable)??!1,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(m,{...e,isSelected:s,scale:c,onClick:e=>O(e,r)})})},r.object.id);if(t.isPolyline(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:(null==g?void 0:g.interaction.isDraggable)??!0,isResizable:(null==g?void 0:g.interaction.isResizable)??!1,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(j,{...e,isSelected:s,scale:c,onClick:e=>O(e,r)})})},r.object.id);if(t.isPolygon(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:(null==g?void 0:g.interaction.isDraggable)??!0,isResizable:(null==g?void 0:g.interaction.isResizable)??!1,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(k,{...e,isSelected:s,scale:c,onClick:e=>O(e,r)})})},r.object.id);if(t.isFreeText(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:((null==g?void 0:g.interaction.isDraggable)??!0)&&!d,isResizable:(null==g?void 0:g.interaction.isResizable)??!0,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Normal)},onDoubleClick:e=>{e.stopPropagation(),L(r.object.id)},...e,children:e=>o.jsx(S,{isSelected:s,isEditing:d,annotation:{...r,object:e},pageIndex:a,scale:c,onClick:e=>O(e,r)})},r.object.id);if(t.isStamp(r))return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:(null==g?void 0:g.interaction.isDraggable)??!0,isResizable:(null==g?void 0:g.interaction.isResizable)??!0,lockAspectRatio:(null==g?void 0:g.interaction.lockAspectRatio)??!1,selectionMenu:C,onSelect:e=>O(e,r),style:{mixBlendMode:i.blendModeToCss(r.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(z,{isSelected:s,annotation:r,documentId:l,pageIndex:a,scale:c,onClick:e=>O(e,r)})},r.object.id);if(t.isLink(r)){const t=!!r.object.inReplyToId;return o.jsx(u,{trackedAnnotation:r,isSelected:s,isMultiSelected:U,isDraggable:!1,isResizable:!1,lockAspectRatio:!1,selectionMenu:t?void 0:C,onSelect:e=>H(e,r),...e,children:e=>o.jsx(A,{...e,isSelected:s,scale:c,onClick:e=>H(e,r),hasIRT:t})},r.object.id)}return null}),G&&N.length>=2&&o.jsx(g,{documentId:l,pageIndex:a,scale:c,rotation:e.rotation,pageWidth:M,pageHeight:w,selectedAnnotations:N,isDraggable:q,isResizable:V,resizeUI:e.resizeUI,selectionOutlineColor:e.selectionOutlineColor,groupSelectionMenu:e.groupSelectionMenu})]})}function C({documentId:e,pageIndex:t,scale:r}){var l,a,c,u,g,v,b,y,m,j,k,S;const{provides:M}=s.useSelectionCapability(),{provides:z}=d(),[A,w]=n.useState([]),[C,D]=n.useState(null),[R,I]=n.useState(null);if(n.useEffect(()=>{if(M)return M.forDocument(e).onSelectionChange(()=>{w(M.forDocument(e).getHighlightRectsForPage(t)),D(M.forDocument(e).getBoundingRectForPage(t))})},[M,e,t]),n.useEffect(()=>{if(z)return I(z.forDocument(e).getActiveTool()),z.forDocument(e).onActiveToolChange(e=>I(e))},[z,e]),!C)return null;if(!R||!R.defaults)return null;switch(R.defaults.type){case i.PdfAnnotationSubtype.UNDERLINE:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(l=R.defaults)?void 0:l.blendMode)??i.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(p,{strokeColor:null==(a=R.defaults)?void 0:a.strokeColor,opacity:null==(c=R.defaults)?void 0:c.opacity,segmentRects:A,scale:r})});case i.PdfAnnotationSubtype.HIGHLIGHT:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(u=R.defaults)?void 0:u.blendMode)??i.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(h,{strokeColor:null==(g=R.defaults)?void 0:g.strokeColor,opacity:null==(v=R.defaults)?void 0:v.opacity,segmentRects:A,scale:r})});case i.PdfAnnotationSubtype.STRIKEOUT:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(b=R.defaults)?void 0:b.blendMode)??i.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(x,{strokeColor:null==(y=R.defaults)?void 0:y.strokeColor,opacity:null==(m=R.defaults)?void 0:m.opacity,segmentRects:A,scale:r})});case i.PdfAnnotationSubtype.SQUIGGLY:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(j=R.defaults)?void 0:j.blendMode)??i.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(f,{strokeColor:null==(k=R.defaults)?void 0:k.strokeColor,opacity:null==(S=R.defaults)?void 0:S.opacity,segmentRects:A,scale:r})});default:return null}}function D({preview:e,scale:t}){const{bounds:n}=e,r={position:"absolute",left:n.origin.x*t,top:n.origin.y*t,width:n.size.width*t,height:n.size.height*t,pointerEvents:"none",zIndex:10};return e.type===i.PdfAnnotationSubtype.CIRCLE?o.jsx("div",{style:r,children:o.jsx(y,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.SQUARE?o.jsx("div",{style:r,children:o.jsx(b,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.POLYGON?o.jsx("div",{style:r,children:o.jsx(k,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.POLYLINE?o.jsx("div",{style:r,children:o.jsx(j,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.LINE?o.jsx("div",{style:r,children:o.jsx(m,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.INK?o.jsx("div",{style:r,children:o.jsx(v,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.FREETEXT?o.jsx("div",{style:r,children:o.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})}):null}function R({documentId:e,pageIndex:t,scale:i}){const{plugin:r}=c(),[s,l]=n.useState(new Map),a=n.useRef(null),d=n.useRef(null),u=n.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!a.current)return;const n=a.current;n.accept=e,n.onchange=e=>{var o;const i=null==(o=e.target.files)?void 0:o[0];i&&(t(i),n.value="")},n.click()},processImage:({source:e,maxWidth:t,maxHeight:n,onComplete:o})=>{const i=d.current;if(!i||!i.getContext)return;const r=i.getContext("2d");if(!r)return;const s=new Image;s.crossOrigin="Anonymous",s.onload=()=>{let{naturalWidth:l,naturalHeight:a}=s;const c=t?t/l:1,d=n?n/a:1,u=Math.min(c,d,1),g=l*u,h=a*u;i.width=g,i.height=h,r.drawImage(s,0,0,g,h);const p=r.getImageData(0,0,g,h);"string"!=typeof e&&URL.revokeObjectURL(s.src),o({imageData:p,width:g,height:h})},s.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return n.useEffect(()=>{if(r)return r.registerPageHandlers(e,t,i,{services:u,onPreview:(e,t)=>{l(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,i,r,u]),o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:a,type:"file",style:{display:"none"}}),o.jsx("canvas",{ref:d,style:{display:"none"}}),Array.from(s.entries()).map(([e,t])=>o.jsx(D,{preview:t,scale:i},e))]})}exports.AnnotationLayer=function({style:t,documentId:r,pageIndex:s,scale:l,rotation:a,selectionMenu:c,groupSelectionMenu:d,resizeUI:u,vertexUI:g,selectionOutlineColor:h,customAnnotationRenderer:p,...x}){var f,v,b,y;const m=e.useDocumentState(r),j=null==(v=null==(f=null==m?void 0:m.document)?void 0:f.pages)?void 0:v[s],k=(null==(b=null==j?void 0:j.size)?void 0:b.width)??0,S=(null==(y=null==j?void 0:j.size)?void 0:y.height)??0,M=n.useMemo(()=>void 0!==l?l:(null==m?void 0:m.scale)??1,[l,null==m?void 0:m.scale]),z=n.useMemo(()=>void 0!==a?a:(null==m?void 0:m.rotation)??i.Rotation.Degree0,[a,null==m?void 0:m.rotation]);return o.jsxs("div",{style:{...t},...x,children:[o.jsx(w,{documentId:r,selectionMenu:c,groupSelectionMenu:d,pageIndex:s,scale:M,rotation:z,pageWidth:k,pageHeight:S,resizeUI:u,vertexUI:g,selectionOutlineColor:h,customAnnotationRenderer:p}),o.jsx(C,{documentId:r,pageIndex:s,scale:M}),o.jsx(R,{documentId:r,pageIndex:s,scale:M})]})},exports.GroupSelectionBox=g,exports.useAnnotation=e=>{var o;const{provides:i}=d(),[r,s]=n.useState((null==(o=null==i?void 0:i.forDocument(e))?void 0:o.getState())??t.initialDocumentState());return n.useEffect(()=>{if(!i)return;const t=i.forDocument(e);return s(t.getState()),t.onStateChange(e=>{s(e)})},[i,e]),{state:r,provides:(null==i?void 0:i.forDocument(e))??null}},exports.useAnnotationCapability=d,exports.useAnnotationPlugin=c,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
|