@embedpdf/plugin-annotation 2.10.1 → 2.11.1
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 +19 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +2 -1
- package/dist/lib/annotation-plugin.d.ts +1 -1
- package/dist/lib/handlers/types.d.ts +17 -5
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/tools/default-tools.d.ts +12 -12
- package/dist/lib/tools/tools-utils.d.ts +9 -9
- package/dist/lib/tools/types.d.ts +1 -1
- package/dist/lib/types.d.ts +5 -4
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +48 -45
- 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 +48 -45
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/types.d.ts +19 -5
- package/dist/shared-preact/components/types.d.ts +19 -5
- package/dist/shared-react/components/types.d.ts +19 -5
- package/dist/svelte/components/annotations/CirclePreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/FreeTextPreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/InkPreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/LinePreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/PolygonPreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/PolylinePreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/SquarePreview.svelte.d.ts +10 -0
- package/dist/svelte/context/types.d.ts +19 -5
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +247 -425
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/annotations/circle-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/free-text-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/ink-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/line-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/polygon-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/polyline-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/square-preview.vue.d.ts +10 -0
- package/dist/vue/context/types.d.ts +19 -5
- 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 +279 -163
- package/dist/vue/index.js.map +1 -1
- package/package.json +12 -12
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"),t=require("@embedpdf/plugin-annotation"),n=require("react/jsx-runtime"),o=require("react"),i=require("react-dom"),r=require("@embedpdf/core/react"),s=require("@embedpdf/models"),a=require("@embedpdf/plugin-interaction-manager/react"),l=require("@embedpdf/plugin-selection/react"),c=require("@embedpdf/utils/react"),d=require("@embedpdf/utils"),u={suppressContentEditableWarning:!0},p=o.createContext(null),h=o.createContext([]);function g({children:e}){const[t,i]=o.useState([]),r=o.useCallback(e=>(i(t=>{const n=new Set(e.map(e=>e.id));return[...t.filter(e=>!n.has(e.id)),...e]}),()=>i(t=>t.filter(t=>!e.some(e=>e.id===t.id)))),[]);return n.jsx(p.Provider,{value:r,children:n.jsx(h.Provider,{value:t,children:e})})}function v(){return o.useContext(h)}const f=()=>r.usePlugin(t.AnnotationPlugin.id),y=()=>r.useCapability(t.AnnotationPlugin.id);let x;function b(){return void 0===x&&(x=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}}()),x}function m(e,t){const n=b();return o.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 k({appearance:e,style:t}){const[i,r]=o.useState(null),s=o.useRef(null);o.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 i?n.jsx("img",{src:i,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 j({scale:e,documentId:t,pageIndex:a,rotation:l,pageWidth:u,pageHeight:p,trackedAnnotation:h,children:g,isSelected:v,isEditing:x=!1,isMultiSelected:b=!1,isDraggable:m,isResizable:j,isRotatable:S=!0,lockAspectRatio:C=!1,style:A={},blendMode:w,vertexConfig:I,selectionMenu:R,outlineOffset:P=1,onDoubleClick:z,onSelect:D,appearance:E,zIndex:M=1,resizeUI:L,vertexUI:$,rotationUI:O,selectionOutlineColor:F,selectionOutline:W,customAnnotationRenderer:B,groupSelectionMenu:U,groupSelectionOutline:T,annotationRenderers:H,...N}){var G,q,Y;const[V,X]=o.useState(h.object),[K,Z]=o.useState(null),[Q,_]=o.useState(null),[J,ee]=o.useState(!1),[te,ne]=o.useState(!1),{provides:oe}=y(),{plugin:ie}=f(),{canModifyAnnotations:re}=r.useDocumentPermissions(t),se=o.useRef(null),ae=re&&m&&!b,le=re&&j&&!b,ce=re&&S&&!b,de=o.useMemo(()=>oe?oe.forDocument(t):null,[oe,t]),ue=V?{...h.object,...V}:h.object,pe=h.object.flags??[],he=pe.includes("noZoom"),ge=pe.includes("noRotate"),ve=he?1:e,fe=ge?0:l,ye=(null==L?void 0:L.color)??"#007ACC",xe=(null==$?void 0:$.color)??"#007ACC",be=(null==O?void 0:O.color)??"white",me=(null==O?void 0:O.connectorColor)??"#007ACC",ke=(null==L?void 0:L.size)??12,je=(null==$?void 0:$.size)??12,Se=(null==O?void 0:O.size)??32,Ce=null==O?void 0:O.margin,Ae=(null==O?void 0:O.iconColor)??"#007ACC",we=(null==O?void 0:O.showConnector)??!1,Ie=(null==(G=null==O?void 0:O.border)?void 0:G.color)??"#007ACC",Re=(null==(q=null==O?void 0:O.border)?void 0:q.width)??1,Pe=(null==(Y=null==O?void 0:O.border)?void 0:Y.style)??"solid",ze=(null==W?void 0:W.color)??F??"#007ACC",De=(null==W?void 0:W.style)??"solid",Ee=(null==W?void 0:W.width)??1,Me=(null==W?void 0:W.offset)??P??1,Le=K??ue.rotation??0,$e=K??ue.rotation??0,Oe=Number.isFinite($e)?Math.round(10*$e)/10:0,Fe=null!==K,We=o.useRef(null),Be=o.useCallback(e=>{var n;if(!(null==(n=e.transformData)?void 0:n.type)||b||!ie)return;const{type:o,changes:i,metadata:r}=e.transformData,s=h.object.id,l={width:u,height:p};if("start"===e.state&&(We.current=h.object.unrotatedRect??h.object.rect,se.current=h.object,"resize"!==o&&"vertex-edit"!==o||ne(!0),"move"===o?ie.startDrag(t,{annotationIds:[s],pageSize:l}):"resize"===o&&ie.startResize(t,{annotationIds:[s],pageSize:l,resizeHandle:(null==r?void 0:r.handle)??"se"})),i.rect&&We.current)if("move"===o){const e={x:i.rect.origin.x-We.current.origin.x,y:i.rect.origin.y-We.current.origin.y};ie.updateDrag(t,e)}else"resize"===o&&ie.updateResize(t,i.rect);if("vertex-edit"===o&&i.vertices&&I){const t=se.current??h.object,n=I.transformAnnotation(t,i.vertices),l=null==oe?void 0:oe.transformAnnotation(t,{type:o,changes:n,metadata:r});l&&(X(e=>({...e,...l})),"end"===e.state&&(null==de||de.updateAnnotation(a,s,l)))}if("rotate"===o){const n=(null==r?void 0:r.rotationAngle)??Le,o=null==r?void 0:r.cursorPosition;return o&&_({x:o.clientX,y:o.clientY}),void("start"===e.state?(Z(n),ie.startRotation(t,{annotationIds:[s],cursorAngle:n,rotationCenter:null==r?void 0:r.rotationCenter})):"move"===e.state?(Z(n),ie.updateRotation(t,n,null==r?void 0:r.rotationDelta)):"end"===e.state&&(Z(null),_(null),ie.commitRotation(t)))}"end"===e.state&&(We.current=null,se.current=null,ne(!1),"move"===o?ie.commitDrag(t):"resize"===o&&ie.commitResize(t))},[ie,t,h.object,u,p,a,b,I,oe,de,Le]),Ue=ue.unrotatedRect,Te=Ue??ue.rect,He=Ue&&0!==Le?s.inferRotationCenterFromRects(Te,ue.rect,Le):void 0,Ne=Te,{dragProps:Ge,vertices:qe,resize:Ye,rotation:Ve}=c.useInteractionHandles({controller:{element:Ne,vertices:null==I?void 0:I.extractVertices(ue),constraints:{minWidth:10,minHeight:10,boundingBox:{width:u,height:p}},maintainAspectRatio:C,pageRotation:l,annotationRotation:Le,rotationCenter:He,rotationElement:ue.rect,scale:e,enabled:v&&!b,onUpdate:Be},resizeUI:{handleSize:ke,spacing:Me,offsetMode:"outside",includeSides:!C,zIndex:M+1},vertexUI:{vertexSize:je,zIndex:M+2},rotationUI:{handleSize:Se,margin:Ce,zIndex:M+3,showConnector:we},includeVertices:!!I,includeRotation:ce,currentRotation:Le}),Xe=o.useMemo(()=>{if(re&&z)return z},[re,z]),Ke=c.useDoublePressProps(Xe);o.useEffect(()=>{X(h.object)},[h.object]),o.useEffect(()=>{if(!ie)return;const e=h.object.id,n=n=>{var o;if(n.documentId!==t)return;"end"!==n.type&&"cancel"!==n.type||Z(null);const i=null==(o=n.previewPatches)?void 0:o[e];"update"===n.type&&i?X(e=>({...e,...i})):"cancel"===n.type&&X(h.object)},o=[ie.onDragChange(n),ie.onResizeChange(n),ie.onRotateChange(n)];return()=>o.forEach(e=>e())},[ie,t,h.object]);const Ze=v&&!b,Qe=ue.rect.size.width*ve,_e=ue.rect.size.height*ve,Je=Te.size.width*ve,et=Te.size.height*ve,tt=Boolean(Ue)&&0!==Le,nt=tt?(Te.origin.x-ue.rect.origin.x)*ve:(Qe-Je)/2,ot=tt?(Te.origin.y-ue.rect.origin.y)*ve:(_e-et)/2,it=tt&&He?`${(He.x-Te.origin.x)*ve}px ${(He.y-Te.origin.y)*ve}px`:"center center",rt=He?(He.x-ue.rect.origin.x)*ve:Qe/2,st=He?(He.y-ue.rect.origin.y)*ve:_e/2,at=Math.max(300,Math.max(Qe,_e)+80),lt=ge?d.getCounterRotation({origin:{x:0,y:0},size:{width:Qe,height:_e}},l):null,ct=o.useMemo(()=>Ue?{...ue,rect:Ue}:ue,[ue,Ue]),dt=!(!(null==E?void 0:E.normal)||te||x||h.dictMode),ut={position:"absolute",left:ue.rect.origin.x*e,top:ue.rect.origin.y*e,width:lt?lt.width:Qe,height:lt?lt.height:_e,pointerEvents:"none",zIndex:M,...lt&&{transform:lt.matrix,transformOrigin:"0 0"}},pt={position:"absolute",left:nt,top:ot,width:Je,height:et,transform:0!==Le?`rotate(${Le}deg)`:void 0,transformOrigin:it};return n.jsxs("div",{"data-no-interaction":!0,children:[n.jsx("div",{style:{...ut,...w&&{mixBlendMode:w},...A},children:n.jsxs("div",{style:{...pt,pointerEvents:x?"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:u,pageHeight:p,pageIndex:a,onSelect:D}))??t})(),(null==E?void 0:E.normal)&&n.jsx(k,{appearance:E.normal,style:{display:dt?"block":"none"}})]})}),n.jsxs("div",{style:ut,...N,children:[Fe&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:rt-at/2,top:st,width:at,height:1,backgroundColor:me,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:rt,top:st-at/2,width:1,height:at,backgroundColor:me,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:rt-at/2,top:st,width:at,height:1,transformOrigin:"center center",transform:`rotate(${Le}deg)`,backgroundColor:me,opacity:.8,pointerEvents:"none"}})]}),v&&ce&&Ve&&((null==O?void 0:O.component)?n.jsx("div",{onPointerEnter:()=>ee(!0),onPointerLeave:()=>{ee(!1),_(null)},onPointerMove:e=>{Fe||_({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:O.component({...Ve.handle,backgroundColor:be,iconColor:Ae,connectorStyle:{...Ve.connector.style,backgroundColor:me,opacity:Fe?0:1},showConnector:we,opacity:Fe?0:1,border:{color:Ie,width:Re,style:Pe}})}):n.jsxs("div",{onPointerEnter:()=>ee(!0),onPointerLeave:()=>{ee(!1),_(null)},onPointerMove:e=>{Fe||_({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[we&&n.jsx("div",{style:{...Ve.connector.style,backgroundColor:me,opacity:Fe?0:1}}),n.jsx("div",{...Ve.handle,style:{...Ve.handle.style,backgroundColor:be,border:`${Re}px ${Pe} ${Ie}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:Fe?0:1},children:n.jsxs("svg",{width:Math.round(.6*Se),height:Math.round(.6*Se),viewBox:"0 0 24 24",fill:"none",stroke:Ae,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),n.jsx("path",{d:"M21 3v5h-5"})]})})]})),n.jsxs("div",{...ae&&v?Ge:{},...Ke,style:{...pt,outline:Ze?`${Ee}px ${De} ${ze}`:"none",outlineOffset:Ze?`${Me}px`:"0px",pointerEvents:!v||b||x?"none":"auto",touchAction:"none",cursor:v&&ae?"move":"default"},children:[v&&le&&!Fe&&Ye.map(({key:e,...t})=>(null==L?void 0:L.component)?L.component({key:e,...t,backgroundColor:ye}):n.jsx("div",{...t,style:{...t.style,backgroundColor:ye}},e)),v&&re&&!b&&!Fe&&qe.map(({key:e,...t})=>(null==$?void 0:$.component)?$.component({key:e,...t,backgroundColor:xe}):n.jsx("div",{...t,style:{...t.style,backgroundColor:xe}},e))]})]}),R&&!b&&!Fe&&n.jsx(c.CounterRotate,{rect:{origin:{x:ue.rect.origin.x*e,y:ue.rect.origin.y*e},size:{width:ue.rect.size.width*ve,height:ue.rect.size.height*ve}},rotation:l,children:e=>{const t=((Le+90*fe)%360+360)%360;return R({...e,context:{type:"annotation",annotation:h,pageIndex:a},selected:v,placement:{suggestTop:ce&&t>90&&t<270}})}}),(Fe||J)&&Q&&i.createPortal(n.jsxs("div",{style:{position:"fixed",left:Q.x+16,top:Q.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[Oe.toFixed(0),"°"]}),document.body)]})}function 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:a,rotation:l,pageWidth:d,pageHeight:u,selectedAnnotations:p,isDraggable:h,isResizable:g,isRotatable:v=!0,lockAspectRatio:y=!1,resizeUI:x,rotationUI:b,selectionOutlineColor:m,outlineOffset:k,selectionOutline:j,zIndex:S=2,groupSelectionMenu:A}){var w,I,R;const{plugin:P}=f(),{canModifyAnnotations:z}=r.useDocumentPermissions(e),D=o.useRef(null),E=o.useRef(!1),M=o.useRef(!1),[L,$]=o.useState(null),[O,F]=o.useState(null),[W,B]=o.useState(!1),U=z&&h,T=z&&g,H=z&&v,N=o.useMemo(()=>{const e=p.map(e=>e.object.rect);return s.boundingRectOrEmpty(e)},[p]),[G,q]=o.useState(N);o.useEffect(()=>{E.current||M.current||q(N)},[N]),o.useEffect(()=>{if(!P)return;return P.onRotateChange(t=>{t.documentId===e&&("end"!==t.type&&"cancel"!==t.type||$(null))})},[P,e]);const Y=o.useCallback(t=>{var n,o,i,r,s,a;if(!(null==(n=t.transformData)?void 0:n.type))return;if(!P)return;const l=t.transformData.type,c="move"===l,h="resize"===l;if(c&&!U)return;if("start"===t.state&&(D.current=N,c?(E.current=!0,P.startDrag(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:d,height:u}})):h&&(M.current=!0,P.startResize(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:d,height:u},resizeHandle:(null==(o=t.transformData.metadata)?void 0:o.handle)??"se"}))),"rotate"===l){if(!v)return;const n=p.map(e=>e.object.id),o=(null==(i=t.transformData.metadata)?void 0:i.rotationAngle)??0,l=null==(r=t.transformData.metadata)?void 0:r.cursorPosition;return l&&F({x:l.clientX,y:l.clientY}),void("start"===t.state?($(o),P.startRotation(e,{annotationIds:n,cursorAngle:o,rotationCenter:null==(s=t.transformData.metadata)?void 0:s.rotationCenter})):"move"===t.state?($(o),P.updateRotation(e,o,null==(a=t.transformData.metadata)?void 0:a.rotationDelta)):"end"===t.state&&($(null),F(null),P.commitRotation(e)))}const g=D.current??N;if(c&&t.transformData.changes.rect){const n=t.transformData.changes.rect,o={x:n.origin.x-g.origin.x,y:n.origin.y-g.origin.y},i=P.updateDrag(e,o);q({...g,origin:{x:g.origin.x+i.x,y:g.origin.y+i.y}})}else if(h&&t.transformData.changes.rect){const n=t.transformData.changes.rect;P.updateResize(e,n),q(n)}"end"===t.state&&(D.current=null,c&&E.current?(E.current=!1,P.commitDrag(e)):h&&M.current&&(M.current=!1,P.commitResize(e)))},[P,e,d,u,N,U,p,v]),V=L??0,X=null!==L,K=Number.isFinite(V)?Math.round(10*V)/10:0,Z=(null==x?void 0:x.color)??"#007ACC",Q=(null==x?void 0:x.size)??12,_=(null==b?void 0:b.color)??"white",J=(null==b?void 0:b.connectorColor)??"#007ACC",ee=(null==b?void 0:b.size)??32,te=null==b?void 0:b.margin,ne=(null==b?void 0:b.iconColor)??"#007ACC",oe=(null==b?void 0:b.showConnector)??!1,ie=(null==(w=null==b?void 0:b.border)?void 0:w.color)??"#007ACC",re=(null==(I=null==b?void 0:b.border)?void 0:I.width)??1,se=(null==(R=null==b?void 0:b.border)?void 0:R.style)??"solid",ae=(null==j?void 0:j.color)??m??"#007ACC",le=(null==j?void 0:j.style)??"dashed",ce=(null==j?void 0:j.width)??2,de=(null==j?void 0:j.offset)??k??2,{dragProps:ue,resize:pe,rotation:he}=c.useInteractionHandles({controller:{element:G,constraints:{minWidth:20,minHeight:20,boundingBox:{width:d,height:u}},maintainAspectRatio:y,pageRotation:l,scale:a,enabled:!0,onUpdate:Y},resizeUI:{handleSize:Q,spacing:de,offsetMode:"outside",includeSides:!y,zIndex:S+1},vertexUI:{vertexSize:0,zIndex:S},rotationUI:{handleSize:ee,margin:te,zIndex:S+2,showConnector:oe},includeVertices:!1,includeRotation:H,currentRotation:L??0});if(p.length<2)return null;let ge=1/0,ve=1/0,fe=-1/0,ye=-1/0;for(const n of p){const e=C(n,a,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*a,be=ve-N.origin.y*a,me=fe-(N.origin.x+N.size.width)*a,ke=ye-(N.origin.y+N.size.height)*a,je=G.origin.x*a+xe,Se=G.origin.y*a+be,Ce=G.size.width*a+(me-xe),Ae=G.size.height*a+(ke-be),we=Ce/2,Ie=Ae/2,Re=Math.max(300,Math.max(Ce,Ae)+80);return n.jsxs("div",{"data-group-selection-box":!0,"data-no-interaction":!0,children:[n.jsxs("div",{style:{position:"absolute",left:je,top:Se,width:Ce,height:Ae,pointerEvents:"none",zIndex:S},children:[X&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:we-Re/2,top:Ie,width:Re,height:1,backgroundColor:Z,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:we,top:Ie-Re/2,width:1,height:Re,backgroundColor:Z,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:we-Re/2,top:Ie,width:Re,height:1,transformOrigin:"center center",transform:`rotate(${V}deg)`,backgroundColor:Z,opacity:.8,pointerEvents:"none"}})]}),H&&he&&((null==b?void 0:b.component)?n.jsx("div",{onPointerEnter:()=>B(!0),onPointerLeave:()=>{B(!1),F(null)},onPointerMove:e=>{X||F({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:b.component({...he.handle,backgroundColor:_,iconColor:ne,connectorStyle:{...he.connector.style,backgroundColor:J,opacity:X?0:1},showConnector:oe,opacity:X?0:1,border:{color:ie,width:re,style:se}})}):n.jsxs("div",{onPointerEnter:()=>B(!0),onPointerLeave:()=>{B(!1),F(null)},onPointerMove:e=>{X||F({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[oe&&n.jsx("div",{style:{...he.connector.style,backgroundColor:J,opacity:X?0:1}}),n.jsx("div",{...he.handle,style:{...he.handle.style,backgroundColor:_,border:`${re}px ${se} ${ie}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:X?0:1},children:n.jsxs("svg",{width:Math.round(.6*ee),height:Math.round(.6*ee),viewBox:"0 0 24 24",fill:"none",stroke:ne,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),n.jsx("path",{d:"M21 3v5h-5"})]})})]})),n.jsx("div",{...U?ue:{onPointerDown:e=>e.stopPropagation()},style:{position:"absolute",left:0,top:0,width:Ce,height:Ae,outline:X?"none":`${ce}px ${le} ${ae}`,outlineOffset:de-1,cursor:U?"move":"default",touchAction:"none",pointerEvents:"auto"},children:T&&!X&&pe.map(({key:e,...t})=>(null==x?void 0:x.component)?x.component({key:e,...t,backgroundColor:Z}):n.jsx("div",{...t,style:{...t.style,backgroundColor:Z}},e))})]}),(X||W)&&O&&i.createPortal(n.jsxs("div",{style:{position:"fixed",left:O.x+16,top:O.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[K.toFixed(0),"°"]}),document.body),A&&!X&&n.jsx(c.CounterRotate,{rect:{origin:{x:je,y:Se},size:{width:Ce,height:Ae}},rotation:l,children:e=>{const n=((V+90*l)%360+360)%360;return A({...e,context:{type:"group",annotations:p,pageIndex:t},selected:!0,placement:{suggestTop:H&&n>90&&n<270}})}})]})}function w(e){return{id:e.id,matches:t=>e.matches(t),render:t=>e.render(t),renderPreview:e.renderPreview?t=>e.renderPreview(t):void 0,vertexConfig:e.vertexConfig,zIndex:e.zIndex,defaultBlendMode:e.defaultBlendMode,containerStyle:e.containerStyle,interactionDefaults:e.interactionDefaults,useAppearanceStream:e.useAppearanceStream,isDraggable:e.isDraggable,onDoubleClick:e.onDoubleClick,selectOverride:e.selectOverride,hideSelectionMenu:e.hideSelectionMenu,hiddenWhenLocked:e.hiddenWhenLocked,renderLocked:e.renderLocked?t=>e.renderLocked(t):void 0}}function I({isSelected:e,strokeColor:t,opacity:i=1,strokeWidth:r,inkList:s,rect:a,scale:l,onClick:c,appearanceActive:d=!1}){const u=t??"#000000",p=o.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:i,style:{pointerEvents:"none",stroke:u,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}},`vis-${t}`))]})}function R({isSelected:e,color:i="#000000",strokeColor:r,opacity:a=1,strokeWidth:l,strokeStyle:c=s.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}=o.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=o.useMemo(()=>y?t.generateCloudyRectanglePath({x:0,y:0,width:u.size.width,height:u.size.height},f,v,l):null,[y,u,f,v,l]),S=u.size.width*p,C=u.size.height*p,A=Math.max(l,20/p);return n.jsxs("svg",{style:{position:"absolute",width:S,height:C,pointerEvents:"none",zIndex:2},width:S,height:C,viewBox:`0 0 ${u.size.width} ${u.size.height}`,overflow:"visible",children:[y&&j?n.jsx("path",{d:j.path,fill:"transparent",stroke:"transparent",strokeWidth:A,onPointerDown:h,style:{cursor:e?"move":h?"pointer":"default",pointerEvents:h?e?"none":"transparent"===i?"visibleStroke":"visible":"none"}}):n.jsx("rect",{x:m,y:k,width:x,height:b,fill:"transparent",stroke:"transparent",strokeWidth:A,onPointerDown:h,style:{cursor:e?"move":h?"pointer":"default",pointerEvents:h?e?"none":"transparent"===i?"visibleStroke":"visible":"none"}}),!g&&(y&&j?n.jsx("path",{d:j.path,fill:i,opacity:a,style:{pointerEvents:"none",stroke:r??i,strokeWidth:l,strokeLinejoin:"round"}}):n.jsx("rect",{x:m,y:k,width:x,height:b,fill:i,opacity:a,style:{pointerEvents:"none",stroke:r??i,strokeWidth:l,...c===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}))]})}function P({color:e="#000000",strokeColor:i,opacity:r=1,strokeWidth:a,strokeStyle:l=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:p,isSelected:h,appearanceActive:g=!1,cloudyBorderIntensity:v,rectangleDifferences:f}){const y=(v??0)>0,{width:x,height:b,cx:m,cy:k,rx:j,ry:S}=o.useMemo(()=>{const e=d.size.width,t=d.size.height,n=Math.max(e-a,0),o=Math.max(t-a,0);return{width:e,height:t,cx:a/2+n/2,cy:a/2+o/2,rx:n/2,ry:o/2}},[d,a]),C=o.useMemo(()=>y?t.generateCloudyEllipsePath({x:0,y:0,width:d.size.width,height:d.size.height},f,v,a):null,[y,d,f,v,a]),A=x*u,w=b*u,I=Math.max(a,20/u);return n.jsxs("svg",{style:{position:"absolute",width:A,height:w,pointerEvents:"none",zIndex:2},width:A,height:w,viewBox:`0 0 ${x} ${b}`,overflow:"visible",children:[y&&C?n.jsx("path",{d:C.path,fill:"transparent",stroke:"transparent",strokeWidth:I,onPointerDown:p,style:{cursor:h?"move":p?"pointer":"default",pointerEvents:p?h?"none":"transparent"===e?"visibleStroke":"visible":"none"}}):n.jsx("ellipse",{cx:m,cy:k,rx:j,ry:S,fill:"transparent",stroke:"transparent",strokeWidth:I,onPointerDown:p,style:{cursor:h?"move":p?"pointer":"default",pointerEvents:p?h?"none":"transparent"===e?"visibleStroke":"visible":"none"}}),!g&&(y&&C?n.jsx("path",{d:C.path,fill:e,opacity:r,style:{pointerEvents:"none",stroke:i??e,strokeWidth:a,strokeLinejoin:"round"}}):n.jsx("ellipse",{cx:m,cy:k,rx:j,ry:S,fill:e,opacity:r,style:{pointerEvents:"none",stroke:i??e,strokeWidth:a,...l===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}))]})}function z({color:e="transparent",opacity:i=1,strokeWidth:r,strokeColor:a="#000000",strokeStyle:l=s.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}=o.useMemo(()=>({x1:u.start.x-d.origin.x,y1:u.start.y-d.origin.y,x2:u.end.x-d.origin.x,y2:u.end.y-d.origin.y}),[u,d]),k=o.useMemo(()=>{const e=Math.atan2(m-x,b-y);return{start:t.patching.createEnding(null==p?void 0:p.start,r,e+Math.PI,y,x),end:t.patching.createEnding(null==p?void 0:p.end,r,e,b,m)}},[p,r,y,x,b,m]),j=d.size.width*h,S=d.size.height*h,C=Math.max(r,20/h);return n.jsxs("svg",{style:{position:"absolute",width:j,height:S,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:S,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[n.jsx("line",{x1:y,y1:x,x2:b,y2:m,stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":g?"pointer":"default",pointerEvents:g?v?"none":"visibleStroke":"none",strokeLinecap:"butt"}}),k.start&&n.jsx("path",{d:k.start.d,transform:k.start.transform,fill:"transparent",stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":g?"pointer":"default",pointerEvents:g?v?"none":k.start.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"}}),k.end&&n.jsx("path",{d:k.end.d,transform:k.end.transform,fill:"transparent",stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":g?"pointer":"default",pointerEvents:g?v?"none":k.end.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"}}),!f&&n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:y,y1:x,x2:b,y2:m,opacity:i,style:{pointerEvents:"none",stroke:a,strokeWidth:r,strokeLinecap:"butt",...l===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),k.start&&n.jsx("path",{d:k.start.d,transform:k.start.transform,stroke:a,fill:k.start.filled?e:"none",style:{pointerEvents:"none",strokeWidth:r,strokeLinecap:"butt",...l===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),k.end&&n.jsx("path",{d:k.end.d,transform:k.end.transform,stroke:a,fill:k.end.filled?e:"none",style:{pointerEvents:"none",strokeWidth:r,strokeLinecap:"butt",...l===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})]})]})}function D({rect:e,vertices:i,color:r="transparent",strokeColor:a="#000000",opacity:l=1,strokeWidth:c,strokeStyle:d=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:u,scale:p,isSelected:h,onClick:g,lineEndings:v,appearanceActive:f=!1}){const y=o.useMemo(()=>i.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[i,e]),x=o.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=o.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:a??r,strokeWidth:c,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...d===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),b.start&&n.jsx("path",{d:b.start.d,transform:b.start.transform,stroke:a,fill:b.start.filled?r:"none",style:{pointerEvents:"none",strokeWidth:c,strokeLinecap:"butt",...d===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),b.end&&n.jsx("path",{d:b.end.d,transform:b.end.transform,stroke:a,fill:b.end.filled?r:"none",style:{pointerEvents:"none",strokeWidth:c,strokeLinecap:"butt",...d===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}})]})]})}function E({rect:e,vertices:i,color:r="transparent",strokeColor:a="#000000",opacity:l=1,strokeWidth:c,strokeStyle:d=s.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?[...i,v]:i,k=o.useMemo(()=>m.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[m,e]),j=o.useMemo(()=>{if(!k.length)return"";const[e,...t]=k,n=!!v;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(n?"":" Z")).trim()},[k,v]),S=o.useMemo(()=>!b||m.length<3?null:t.generateCloudyPolygonPath(m,e.origin,x,c),[b,m,e.origin,x,c]),C=v&&i.length>0,A=e.size.width*p,w=e.size.height*p,I=Math.max(c,20/p);return n.jsxs("svg",{style:{position:"absolute",width:A,height:w,pointerEvents:"none",zIndex:2,overflow:"visible"},width:A,height:w,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:b&&S?S.path:j,fill:"transparent",stroke:"transparent",strokeWidth:I,onPointerDown:g,style:{cursor:h?"move":g?"pointer":"default",pointerEvents:g?h?"none":"transparent"===r?"visibleStroke":"visible":"none",strokeLinecap:"butt",strokeLinejoin:"miter"}}),!y&&n.jsx(n.Fragment,{children:b&&S?n.jsx("path",{d:S.path,opacity:l,style:{fill:r,stroke:a??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:a??r,strokeWidth:c,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...d===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),C&&i.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:a,strokeWidth:c,strokeDasharray:"4,4",opacity:.7,pointerEvents:"none"}}),C&&i.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:a,opacity:.4,stroke:a,strokeWidth:c/2,style:{pointerEvents:"none"}})]})})]})}function M({isSelected:e,color:t="#facc15",opacity:o=1,onClick:i,appearanceActive:r=!1}){const a=s.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:a,strokeWidth:"1",strokeLinejoin:"miter"}),n.jsx("line",{x1:"2.5",y1:"4.25",x2:"17.5",y2:"4.25",stroke:a,strokeWidth:"1"}),n.jsx("line",{x1:"2.5",y1:"8",x2:"17.5",y2:"8",stroke:a,strokeWidth:"1"}),n.jsx("line",{x1:"2.5",y1:"11.75",x2:"17.5",y2:"11.75",stroke:a,strokeWidth:"1"})]})})}function L({documentId:e,isSelected:t,isEditing:i,annotation:r,pageIndex:a,scale:l,onClick:c,appearanceActive:d=!1}){const p=o.useRef(null),h=o.useRef(!1),{provides:g}=y(),v=(null==g?void 0:g.forDocument(e))??null,{adjustedFontPx:f,wrapperStyle:x}=m(r.object.fontSize*l,i);o.useEffect(()=>{var e;if(i&&p.current){h.current=!0;const t=p.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)}}},[i]);return n.jsx("div",{style:{position:"absolute",width:r.object.rect.size.width*l,height:r.object.rect.size.height*l,cursor:t&&!i?"move":"default",pointerEvents:c?t&&!i?"none":"auto":"none",zIndex:2,opacity:d?0:1},onPointerDown:c,children:n.jsx("span",{ref:p,onBlur:()=>{h.current&&(h.current=!1,v&&p.current&&v.updateAnnotation(a,r.object.id,{contents:p.current.innerText.replace(/\u00A0/g," ")}))},tabIndex:0,style:{color:r.object.fontColor,fontSize:f,...s.standardFontCssProperties(r.object.fontFamily),textAlign:s.textAlignmentToCss(r.object.textAlign),flexDirection:"column",justifyContent:r.object.verticalAlign===s.PdfVerticalAlignment.Top?"flex-start":r.object.verticalAlign===s.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:i?"text":c?"pointer":"default",outline:"none",...x},contentEditable:i,...u,children:r.object.contents})})}function $({documentId:e,pageIndex:t,annotation:i,scaleFactor:r=1,unrotated:a,style:l,...c}){const{provides:d}=y(),[u,p]=o.useState(null),h=o.useRef(null),{width:g,height:v}=i.rect.size;o.useEffect(()=>{if(d){const n=d.forDocument(e).renderAnnotation({pageIndex:t,annotation:i,options:{scaleFactor:r,dpr:window.devicePixelRatio,unrotated:a}});return n.wait(e=>{const t=URL.createObjectURL(e);p(t),h.current=t},s.ignore),()=>{h.current?(URL.revokeObjectURL(h.current),h.current=null):n.abort({code:s.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,r,a,d,e,i.id,g,v]);return n.jsx(o.Fragment,{children:u&&n.jsx("img",{src:u,onLoad:()=>{h.current&&(URL.revokeObjectURL(h.current),h.current=null)},...c,style:{width:"100%",height:"100%",display:"block",...l||{}}})})}function O({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($,{documentId:o,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:r,unrotated:a})})}function F({isSelected:e,strokeColor:t="#0000FF",strokeWidth:i=2,strokeStyle:r=s.PdfAnnotationBorderStyle.UNDERLINE,strokeDashArray:a,rect:l,scale:c,onClick:d,hasIRT:u=!1}){const{width:p,height:h}=o.useMemo(()=>({width:l.size.width,height:l.size.height}),[l]),g=p*c,v=h*c,f=o.useMemo(()=>{if(r===s.PdfAnnotationBorderStyle.DASHED)return(null==a?void 0:a.join(","))??`${3*i},${i}`},[r,a,i]),y=r===s.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:i,strokeDasharray:f,style:{pointerEvents:"none"}}):n.jsx("rect",{x:i/2,y:i/2,width:Math.max(p-i,0),height:Math.max(h-i,0),fill:"transparent",stroke:t,strokeWidth:i,strokeDasharray:f,style:{pointerEvents:"none"}})]})}function W({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 B({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00",d=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:d,background:c,opacity:t,pointerEvents:"none"}})},o))})}function U({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00",d=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:d,background:c,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},o))})}function T({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=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 H({isSelected:e,strokeColor:t="#000000",opacity:i=1,rect:r,scale:s,onClick:a,appearanceActive:l=!1}){const{width:c,height:d,path:u}=o.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:i,fillRule:"evenodd",style:{pointerEvents:"none"}})]})}function N({annotation:e,documentId:t}){const{provides:i}=y(),r=o.useCallback(()=>{const n=e.object.target;n&&i&&i.forDocument(t).navigateTarget(n)},[e.object.target,i,t]);return n.jsx("div",{onClick:r,style:{width:"100%",height:"100%",cursor:"pointer",pointerEvents:"auto"}})}const G=[w({id:"ink",matches:e=>e.type===s.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}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),w({id:"square",matches:e=>e.type===s.PdfAnnotationSubtype.SQUARE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(R,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),w({id:"circle",matches:e=>e.type===s.PdfAnnotationSubtype.CIRCLE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(P,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),w({id:"line",matches:e=>e.type===s.PdfAnnotationSubtype.LINE,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(z,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),w({id:"polyline",matches:e=>e.type===s.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})}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),w({id:"polygon",matches:e=>e.type===s.PdfAnnotationSubtype.POLYGON,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(E,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),w({id:"highlight",matches:e=>e.type===s.PdfAnnotationSubtype.HIGHLIGHT,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(W,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},defaultBlendMode:s.PdfBlendMode.Multiply}),w({id:"underline",matches:e=>e.type===s.PdfAnnotationSubtype.UNDERLINE,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(B,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),w({id:"strikeout",matches:e=>e.type===s.PdfAnnotationSubtype.STRIKEOUT,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}}),w({id:"squiggly",matches:e=>e.type===s.PdfAnnotationSubtype.SQUIGGLY,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(T,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),w({id:"text",matches:e=>e.type===s.PdfAnnotationSubtype.TEXT&&!e.inReplyToId,render:({currentObject:e,isSelected:t,onClick:o,appearanceActive:i})=>n.jsx(M,{isSelected:t,color:e.strokeColor??e.color,opacity:e.opacity,onClick:o,appearanceActive:i}),interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!1}}),w({id:"caret",matches:e=>e.type===s.PdfAnnotationSubtype.CARET,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(H,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),w({id:"freeText",matches:e=>e.type===s.PdfAnnotationSubtype.FREETEXT,render:({annotation:e,currentObject:t,isSelected:o,isEditing:i,scale:r,pageIndex:s,documentId:a,onClick:l,appearanceActive:c})=>n.jsx(L,{documentId:a,isSelected:o,isEditing:i,annotation:{...e,object:t},pageIndex:s,scale:r,onClick:l,appearanceActive:c}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0},isDraggable:(e,{isEditing:t})=>e&&!t,onDoubleClick:(e,t)=>t(e)}),w({id:"stamp",matches:e=>e.type===s.PdfAnnotationSubtype.STAMP,render:({annotation:e,isSelected:t,documentId:o,pageIndex:i,scale:r,onClick:s})=>n.jsx(O,{isSelected:t,annotation:e,documentId:o,pageIndex:i,scale:r,onClick:s}),useAppearanceStream:!1,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),w({id:"link",matches:e=>e.type===s.PdfAnnotationSubtype.LINK,render:({currentObject:e,isSelected:t,scale:o,onClick:i})=>n.jsx(F,{...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(N,{...e})})];function q(e){const{documentId:i,pageIndex:r,scale:c,pageWidth:d,pageHeight:u,selectionMenu:p}=e,{provides:h}=y(),{provides:g}=l.useSelectionCapability(),[v,f]=o.useState([]),{register:x}=a.usePointerHandlers({documentId:i,pageIndex:r}),[b,m]=o.useState([]),[k,S]=o.useState(null),[C,w]=o.useState({}),[I,R]=o.useState({type:t.LockModeType.None}),P=o.useRef(c),z=o.useMemo(()=>h?h.forDocument(i):null,[h,i]),D=b.length>1;o.useEffect(()=>{if(z){const e=z.getState();return f(t.getAnnotationsByPageIndex(e,r)),m(t.getSelectedAnnotationIds(e)),R(e.locked),z.onStateChange(e=>{f(t.getAnnotationsByPageIndex(e,r)),m(t.getSelectedAnnotationIds(e)),R(e.locked)})}},[z,r]),o.useEffect(()=>{if(z)return z.onAnnotationEvent(e=>{"create"===e.type&&e.editAfterCreate&&S(e.annotation.id)})},[z]),o.useEffect(()=>{if(!z)return;P.current!==c&&(z.invalidatePageAppearances(r),P.current=c);z.getPageAppearances(r,{scaleFactor:c,dpr:"undefined"!=typeof window?window.devicePixelRatio:1}).wait(e=>w(e),()=>w({}))},[z,r,c]);const E=o.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&z&&(k&&v.some(e=>e.object.id===k)&&t.stopImmediatePropagation(),z.deselectAnnotation(),S(null))}}),[z,k,v]),M=o.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&&S(null)}},[z,g,k,r]);o.useEffect(()=>x(E,{documentId:i}),[x,E]);const L=o.useMemo(()=>v.filter(e=>b.includes(e.object.id)),[v,b]),$=o.useMemo(()=>!(L.length<2)&&L.every(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupDraggable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isDraggable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupDraggable)?o:i}),[L,z]),O=o.useMemo(()=>!(L.length<2)&&L.every(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupResizable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isResizable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupResizable)?o:i}),[L,z]),F=o.useMemo(()=>!(L.length<2)&&L.every(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupRotatable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isRotatable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupRotatable)?o:i}),[L,z]),W=o.useMemo(()=>!(L.length<2)&&L.some(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.lockGroupAspectRatio,e.object,!1),i=t.resolveInteractionProp(null==n?void 0:n.interaction.lockAspectRatio,e.object,!1);return void 0!==(null==n?void 0:n.interaction.lockGroupAspectRatio)?o:i}),[L,z]),B=o.useMemo(()=>{if(!z)return!1;const e=z.getSelectedAnnotations();return e.length>1&&e.every(e=>e.object.pageIndex===r)},[z,r,b]),U=o.useCallback(e=>{if(e.dictMode)return null;if(e.object.rotation&&e.object.unrotatedRect)return null;const t=C[e.object.id];return(null==t?void 0:t.normal)?t:null},[C]),T=o.useMemo(()=>{const t=e.annotationRenderers??[],n=new Set(t.map(e=>e.id));return[...t,...G.filter(e=>!n.has(e.id))]},[e.annotationRenderers]),H=o.useCallback(e=>T.find(t=>t.matches(e.object))??null,[T]),N=o.useMemo(()=>({defaultSelect:M,selectAnnotation:(e,t)=>null==z?void 0:z.selectAnnotation(e,t),clearSelection:()=>null==g?void 0:g.clear(),allAnnotations:v,pageIndex:r}),[M,z,g,v,r]);return n.jsxs(n.Fragment,{children:[v.map(o=>{var a,l,d;const u=H(o);if(!u)return null;const h=(null==z?void 0:z.findToolForAnnotation(o.object))??null,g=t.getAnnotationCategories(h),v=t.hasLockedFlag(o.object)||t.isCategoryLocked(g,I);if(v&&u.hiddenWhenLocked)return null;const f=v&&!!u.renderLocked,y=!v&&b.includes(o.object.id),x=!v&&k===o.object.id,m=u.interactionDefaults,C=t.resolveInteractionProp(null==h?void 0:h.interaction.isDraggable,o.object,(null==m?void 0:m.isDraggable)??!0),A=!v&&(u.isDraggable?u.isDraggable(C,{isEditing:x}):C),w=(null==(a=null==h?void 0:h.behavior)?void 0:a.useAppearanceStream)??u.useAppearanceStream??!0,R=f?void 0:w?U(o):void 0,P=v?e=>{e.stopPropagation()}:u.selectOverride?e=>u.selectOverride(e,o,N):e=>M(e,o);return n.jsx(j,{trackedAnnotation:o,isSelected:y,isEditing:x,isMultiSelected:!v&&D,isDraggable:A,isResizable:!v&&t.resolveInteractionProp(null==h?void 0:h.interaction.isResizable,o.object,(null==m?void 0:m.isResizable)??!1),lockAspectRatio:t.resolveInteractionProp(null==h?void 0:h.interaction.lockAspectRatio,o.object,(null==m?void 0:m.lockAspectRatio)??!1),isRotatable:!v&&t.resolveInteractionProp(null==h?void 0:h.interaction.isRotatable,o.object,(null==m?void 0:m.isRotatable)??!1),vertexConfig:v?void 0:u.vertexConfig,selectionMenu:v||(null==(l=u.hideSelectionMenu)?void 0:l.call(u,o.object))?void 0:p,onSelect:P,onDoubleClick:v?void 0:u.onDoubleClick?e=>{e.stopPropagation(),u.onDoubleClick(o.object.id,S)}:void 0,zIndex:u.zIndex,blendMode:s.blendModeToCss(o.object.blendMode??u.defaultBlendMode??s.PdfBlendMode.Normal),style:null==(d=u.containerStyle)?void 0:d.call(u,o.object),appearance:R,...e,children:(e,{appearanceActive:t})=>f?u.renderLocked({annotation:o,currentObject:e,isSelected:!1,isEditing:!1,scale:c,pageIndex:r,documentId:i,onClick:void 0,appearanceActive:t}):u.render({annotation:o,currentObject:e,isSelected:y,isEditing:x,scale:c,pageIndex:r,documentId:i,onClick:v?void 0:P,appearanceActive:t})},o.object.id)}),B&&L.length>=2&&n.jsx(A,{documentId:i,pageIndex:r,scale:c,rotation:e.rotation,pageWidth:d,pageHeight:u,selectedAnnotations:L,isDraggable:$,isResizable:O,isRotatable:F,lockAspectRatio:W,resizeUI:e.resizeUI,rotationUI:e.rotationUI,selectionOutlineColor:e.selectionOutlineColor,selectionOutline:e.groupSelectionOutline??e.selectionOutline,groupSelectionMenu:e.groupSelectionMenu})]})}function Y({documentId:e,pageIndex:t,scale:i}){var r,a,c,d,u,p,h,g,v,f,x,b;const{provides:m}=l.useSelectionCapability(),{provides:k}=y(),[j,S]=o.useState([]),[C,A]=o.useState(null),[w,I]=o.useState(null);if(o.useEffect(()=>{if(m)return m.forDocument(e).onSelectionChange(()=>{S(m.forDocument(e).getHighlightRectsForPage(t)),A(m.forDocument(e).getBoundingRectForPage(t))})},[m,e,t]),o.useEffect(()=>{if(k)return I(k.forDocument(e).getActiveTool()),k.forDocument(e).onActiveToolChange(e=>I(e))},[k,e]),!C)return null;if(!w||!w.defaults)return null;switch(w.defaults.type){case s.PdfAnnotationSubtype.UNDERLINE:return n.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(r=w.defaults)?void 0:r.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(B,{strokeColor:null==(a=w.defaults)?void 0:a.strokeColor,opacity:null==(c=w.defaults)?void 0:c.opacity,segmentRects:j,scale:i})});case s.PdfAnnotationSubtype.HIGHLIGHT:return n.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(d=w.defaults)?void 0:d.blendMode)??s.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(W,{strokeColor:null==(u=w.defaults)?void 0:u.strokeColor,opacity:null==(p=w.defaults)?void 0:p.opacity,segmentRects:j,scale:i})});case s.PdfAnnotationSubtype.STRIKEOUT:return n.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(h=w.defaults)?void 0:h.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(U,{strokeColor:null==(g=w.defaults)?void 0:g.strokeColor,opacity:null==(v=w.defaults)?void 0:v.opacity,segmentRects:j,scale:i})});case s.PdfAnnotationSubtype.SQUIGGLY:return n.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(f=w.defaults)?void 0:f.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(T,{strokeColor:null==(x=w.defaults)?void 0:x.strokeColor,opacity:null==(b=w.defaults)?void 0:b.opacity,segmentRects:j,scale:i})});case s.PdfAnnotationSubtype.CARET:default:return null}}function V({toolId:e,preview:t,scale:o}){const{bounds:i}=t,r=v(),a={position:"absolute",left:i.origin.x*o,top:i.origin.y*o,width:i.size.width*o,height:i.size.height*o,pointerEvents:"none",zIndex:10};if(t.type===s.PdfAnnotationSubtype.CIRCLE)return n.jsx("div",{style:a,children:n.jsx(P,{isSelected:!1,scale:o,...t.data})});if(t.type===s.PdfAnnotationSubtype.SQUARE)return n.jsx("div",{style:a,children:n.jsx(R,{isSelected:!1,scale:o,...t.data})});if(t.type===s.PdfAnnotationSubtype.POLYGON)return n.jsx("div",{style:a,children:n.jsx(E,{isSelected:!1,scale:o,...t.data})});if(t.type===s.PdfAnnotationSubtype.POLYLINE)return n.jsx("div",{style:a,children:n.jsx(D,{isSelected:!1,scale:o,...t.data})});if(t.type===s.PdfAnnotationSubtype.LINE)return n.jsx("div",{style:a,children:n.jsx(z,{isSelected:!1,scale:o,...t.data})});if(t.type===s.PdfAnnotationSubtype.INK)return n.jsx("div",{style:{...a,mixBlendMode:s.blendModeToCss(t.data.blendMode??s.PdfBlendMode.Normal)},children:n.jsx(I,{isSelected:!1,scale:o,...t.data})});if(t.type===s.PdfAnnotationSubtype.FREETEXT)return n.jsx("div",{style:a,children:n.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${t.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})});const l=r.find(t=>t.id===e&&t.renderPreview);return(null==l?void 0:l.renderPreview)?n.jsx("div",{style:a,children:l.renderPreview({data:t.data,bounds:t.bounds,scale:o})}):null}function X({documentId:e,pageIndex:t,scale:i}){const{plugin:r}=f(),[s,a]=o.useState(new Map),l=o.useRef(null),c=o.useRef(null),d=o.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!l.current)return;const n=l.current;n.accept=e,n.onchange=e=>{var o;const i=null==(o=e.target.files)?void 0:o[0];i&&(t(i),n.value="")},n.click()},processImage:({source:e,maxWidth:t,maxHeight:n,onComplete:o})=>{const i=c.current;if(!i||!i.getContext)return;const r=i.getContext("2d");if(!r)return;const s=new Image;s.crossOrigin="Anonymous",s.onload=()=>{let{naturalWidth:a,naturalHeight:l}=s;const c=t?t/a:1,d=n?n/l:1,u=Math.min(c,d,1),p=a*u,h=l*u;i.width=p,i.height=h,r.drawImage(s,0,0,p,h);const g=r.getImageData(0,0,p,h);"string"!=typeof e&&URL.revokeObjectURL(s.src),o({imageData:g,width:p,height:h})},s.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return o.useEffect(()=>{if(r)return r.registerPageHandlers(e,t,i,{services:d,onPreview:(e,t)=>{a(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,i,r,d]),n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:l,type:"file",style:{display:"none"}}),n.jsx("canvas",{ref:c,style:{display:"none"}}),Array.from(s.entries()).map(([e,t])=>n.jsx(V,{toolId:e,preview:t,scale:i},e))]})}const K=e.createPluginPackage(t.AnnotationPluginPackage).addWrapper(g).addUtility(function(){const{plugin:e}=f(),{provides:t}=y();return o.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:i,scale:s,rotation:a,selectionMenu:l,groupSelectionMenu:c,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:f,customAnnotationRenderer:y,annotationRenderers:x,...b}){var m,k,j,S;const C=r.useDocumentState(t),A=null==(k=null==(m=null==C?void 0:C.document)?void 0:m.pages)?void 0:k[i],w=(null==(j=null==A?void 0:A.size)?void 0:j.width)??0,I=(null==(S=null==A?void 0:A.size)?void 0:S.height)??0,R=v(),P=o.useMemo(()=>{const e=[...R];for(const t of x??[]){const n=e.findIndex(e=>e.id===t.id);n>=0?e[n]=t:e.push(t)}return e},[R,x]),z=o.useMemo(()=>void 0!==s?s:(null==C?void 0:C.scale)??1,[s,null==C?void 0:C.scale]),D=o.useMemo(()=>{if(void 0!==a)return a;return(((null==A?void 0:A.rotation)??0)+((null==C?void 0:C.rotation)??0))%4},[a,null==A?void 0:A.rotation,null==C?void 0:C.rotation]);return n.jsxs("div",{style:{...e},...b,children:[n.jsx(q,{documentId:t,selectionMenu:l,groupSelectionMenu:c,pageIndex:i,scale:z,rotation:D,pageWidth:w,pageHeight:I,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:f,customAnnotationRenderer:y,annotationRenderers:P}),n.jsx(Y,{documentId:t,pageIndex:i,scale:z}),n.jsx(X,{documentId:t,pageIndex:i,scale:z})]})},exports.AnnotationPluginPackage=K,exports.AnnotationRendererProvider=g,exports.GroupSelectionBox=A,exports.createRenderer=w,exports.useAnnotation=e=>{var n;const{provides:i}=y(),[r,s]=o.useState((null==(n=null==i?void 0:i.forDocument(e))?void 0:n.getState())??t.initialDocumentState());return o.useEffect(()=>{if(!i)return;const t=i.forDocument(e);return s(t.getState()),t.onStateChange(e=>{s(e)})},[i,e]),{state:r,provides:(null==i?void 0:i.forDocument(e))??null}},exports.useAnnotationCapability=y,exports.useAnnotationPlugin=f,exports.useIOSZoomPrevention=m,exports.useRegisterRenderers=function(e){const t=o.useContext(p),n=o.useRef(e);o.useEffect(()=>{if(t)return t(n.current)},[t])},exports.useRegisteredRenderers=v,exports.useRendererRegistry=function(){return o.useContext(p)},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("react/jsx-runtime"),o=require("react"),i=require("react-dom"),r=require("@embedpdf/core/react"),s=require("@embedpdf/models"),a=require("@embedpdf/plugin-interaction-manager/react"),l=require("@embedpdf/plugin-selection/react"),c=require("@embedpdf/utils/react"),d=require("@embedpdf/utils"),u={suppressContentEditableWarning:!0},p=o.createContext(null),h=o.createContext([]);function g({children:e}){const[t,i]=o.useState([]),r=o.useCallback(e=>(i(t=>{const n=new Set(e.map(e=>e.id));return[...t.filter(e=>!n.has(e.id)),...e]}),()=>i(t=>t.filter(t=>!e.some(e=>e.id===t.id)))),[]);return n.jsx(p.Provider,{value:r,children:n.jsx(h.Provider,{value:t,children:e})})}function v(){return o.useContext(h)}const f=()=>r.usePlugin(t.AnnotationPlugin.id),y=()=>r.useCapability(t.AnnotationPlugin.id);let x;function b(){return void 0===x&&(x=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}}()),x}function m(e,t){const n=b();return o.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 k({appearance:e,style:t}){const[i,r]=o.useState(null),s=o.useRef(null);o.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 i?n.jsx("img",{src:i,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 j({scale:e,documentId:t,pageIndex:a,rotation:l,pageWidth:u,pageHeight:p,trackedAnnotation:h,children:g,isSelected:v,isEditing:x=!1,isMultiSelected:b=!1,isDraggable:m,isResizable:j,isRotatable:S=!0,lockAspectRatio:w=!1,style:C={},blendMode:A,vertexConfig:P,selectionMenu:I,outlineOffset:R=1,onDoubleClick:z,onSelect:D,appearance:E,zIndex:M=1,resizeUI:L,vertexUI:$,rotationUI:O,selectionOutlineColor:F,selectionOutline:W,customAnnotationRenderer:B,groupSelectionMenu:U,groupSelectionOutline:T,annotationRenderers:H,...N}){var G,q,Y;const[K,V]=o.useState(h.object),[X,Z]=o.useState(null),[Q,_]=o.useState(null),[J,ee]=o.useState(!1),[te,ne]=o.useState(!1),{provides:oe}=y(),{plugin:ie}=f(),{canModifyAnnotations:re}=r.useDocumentPermissions(t),se=o.useRef(null),ae=re&&m&&!b,le=re&&j&&!b,ce=re&&S&&!b,de=o.useMemo(()=>oe?oe.forDocument(t):null,[oe,t]),ue=K?{...h.object,...K}:h.object,pe=h.object.flags??[],he=pe.includes("noZoom"),ge=pe.includes("noRotate"),ve=he?1:e,fe=ge?0:l,ye=(null==L?void 0:L.color)??"#007ACC",xe=(null==$?void 0:$.color)??"#007ACC",be=(null==O?void 0:O.color)??"white",me=(null==O?void 0:O.connectorColor)??"#007ACC",ke=(null==L?void 0:L.size)??12,je=(null==$?void 0:$.size)??12,Se=(null==O?void 0:O.size)??32,we=null==O?void 0:O.margin,Ce=(null==O?void 0:O.iconColor)??"#007ACC",Ae=(null==O?void 0:O.showConnector)??!1,Pe=(null==(G=null==O?void 0:O.border)?void 0:G.color)??"#007ACC",Ie=(null==(q=null==O?void 0:O.border)?void 0:q.width)??1,Re=(null==(Y=null==O?void 0:O.border)?void 0:Y.style)??"solid",ze=(null==W?void 0:W.color)??F??"#007ACC",De=(null==W?void 0:W.style)??"solid",Ee=(null==W?void 0:W.width)??1,Me=(null==W?void 0:W.offset)??R??1,Le=X??ue.rotation??0,$e=X??ue.rotation??0,Oe=Number.isFinite($e)?Math.round(10*$e)/10:0,Fe=null!==X,We=o.useRef(null),Be=o.useCallback(e=>{var n;if(!(null==(n=e.transformData)?void 0:n.type)||b||!ie)return;const{type:o,changes:i,metadata:r}=e.transformData,s=h.object.id,l={width:u,height:p};if("start"===e.state&&(We.current=h.object.unrotatedRect??h.object.rect,se.current=h.object,"resize"!==o&&"vertex-edit"!==o||ne(!0),"move"===o?ie.startDrag(t,{annotationIds:[s],pageSize:l}):"resize"===o&&ie.startResize(t,{annotationIds:[s],pageSize:l,resizeHandle:(null==r?void 0:r.handle)??"se"})),i.rect&&We.current)if("move"===o){const e={x:i.rect.origin.x-We.current.origin.x,y:i.rect.origin.y-We.current.origin.y};ie.updateDrag(t,e)}else"resize"===o&&ie.updateResize(t,i.rect);if("vertex-edit"===o&&i.vertices&&P){const t=se.current??h.object,n=P.transformAnnotation(t,i.vertices),l=null==oe?void 0:oe.transformAnnotation(t,{type:o,changes:n,metadata:r});l&&(V(e=>({...e,...l})),"end"===e.state&&(null==de||de.updateAnnotation(a,s,l)))}if("rotate"===o){const n=(null==r?void 0:r.rotationAngle)??Le,o=null==r?void 0:r.cursorPosition;return o&&_({x:o.clientX,y:o.clientY}),void("start"===e.state?(Z(n),ie.startRotation(t,{annotationIds:[s],cursorAngle:n,rotationCenter:null==r?void 0:r.rotationCenter})):"move"===e.state?(Z(n),ie.updateRotation(t,n,null==r?void 0:r.rotationDelta)):"end"===e.state&&(Z(null),_(null),ie.commitRotation(t)))}"end"===e.state&&(We.current=null,se.current=null,ne(!1),"move"===o?ie.commitDrag(t):"resize"===o&&ie.commitResize(t))},[ie,t,h.object,u,p,a,b,P,oe,de,Le]),Ue=ue.unrotatedRect,Te=Ue??ue.rect,He=Ue&&0!==Le?s.inferRotationCenterFromRects(Te,ue.rect,Le):void 0,Ne=Te,{dragProps:Ge,vertices:qe,resize:Ye,rotation:Ke}=c.useInteractionHandles({controller:{element:Ne,vertices:null==P?void 0:P.extractVertices(ue),constraints:{minWidth:10,minHeight:10,boundingBox:{width:u,height:p}},maintainAspectRatio:w,pageRotation:l,annotationRotation:Le,rotationCenter:He,rotationElement:ue.rect,scale:e,enabled:v&&!b,onUpdate:Be},resizeUI:{handleSize:ke,spacing:Me,offsetMode:"outside",includeSides:!w,zIndex:M+1},vertexUI:{vertexSize:je,zIndex:M+2},rotationUI:{handleSize:Se,margin:we,zIndex:M+3,showConnector:Ae},includeVertices:!!P,includeRotation:ce,currentRotation:Le}),Ve=o.useMemo(()=>{if(re&&z)return z},[re,z]),Xe=c.useDoublePressProps(Ve);o.useEffect(()=>{V(h.object)},[h.object]),o.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?V(e=>({...e,...i})):"cancel"===n.type&&V(h.object)},o=[ie.onDragChange(n),ie.onResizeChange(n),ie.onRotateChange(n)];return()=>o.forEach(e=>e())},[ie,t,h.object]);const Ze=v&&!b,Qe=ue.rect.size.width*ve,_e=ue.rect.size.height*ve,Je=Te.size.width*ve,et=Te.size.height*ve,tt=Boolean(Ue)&&0!==Le,nt=tt?(Te.origin.x-ue.rect.origin.x)*ve:(Qe-Je)/2,ot=tt?(Te.origin.y-ue.rect.origin.y)*ve:(_e-et)/2,it=tt&&He?`${(He.x-Te.origin.x)*ve}px ${(He.y-Te.origin.y)*ve}px`:"center center",rt=He?(He.x-ue.rect.origin.x)*ve:Qe/2,st=He?(He.y-ue.rect.origin.y)*ve:_e/2,at=Math.max(300,Math.max(Qe,_e)+80),lt=ge?d.getCounterRotation({origin:{x:0,y:0},size:{width:Qe,height:_e}},l):null,ct=o.useMemo(()=>Ue?{...ue,rect:Ue}:ue,[ue,Ue]),dt=!(!(null==E?void 0:E.normal)||te||x||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:x?"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:u,pageHeight:p,pageIndex:a,onSelect:D}))??t})(),(null==E?void 0:E.normal)&&n.jsx(k,{appearance:E.normal,style:{display:dt?"block":"none"}})]})}),n.jsxs("div",{style:ut,...N,children:[Fe&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:rt-at/2,top:st,width:at,height:1,backgroundColor:me,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:rt,top:st-at/2,width:1,height:at,backgroundColor:me,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:rt-at/2,top:st,width:at,height:1,transformOrigin:"center center",transform:`rotate(${Le}deg)`,backgroundColor:me,opacity:.8,pointerEvents:"none"}})]}),v&&ce&&Ke&&((null==O?void 0:O.component)?n.jsx("div",{onPointerEnter:()=>ee(!0),onPointerLeave:()=>{ee(!1),_(null)},onPointerMove:e=>{Fe||_({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:O.component({...Ke.handle,backgroundColor:be,iconColor:Ce,connectorStyle:{...Ke.connector.style,backgroundColor:me,opacity:Fe?0:1},showConnector:Ae,opacity:Fe?0:1,border:{color:Pe,width:Ie,style:Re}})}):n.jsxs("div",{onPointerEnter:()=>ee(!0),onPointerLeave:()=>{ee(!1),_(null)},onPointerMove:e=>{Fe||_({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[Ae&&n.jsx("div",{style:{...Ke.connector.style,backgroundColor:me,opacity:Fe?0:1}}),n.jsx("div",{...Ke.handle,style:{...Ke.handle.style,backgroundColor:be,border:`${Ie}px ${Re} ${Pe}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:Fe?0:1},children:n.jsxs("svg",{width:Math.round(.6*Se),height:Math.round(.6*Se),viewBox:"0 0 24 24",fill:"none",stroke: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:{},...Xe,style:{...pt,outline:Ze?`${Ee}px ${De} ${ze}`:"none",outlineOffset:Ze?`${Me}px`:"0px",pointerEvents:!v||b||x?"none":"auto",touchAction:"none",cursor:v&&ae?"move":"default"},children:[v&&le&&!Fe&&Ye.map(({key:e,...t})=>(null==L?void 0:L.component)?L.component({key:e,...t,backgroundColor:ye}):n.jsx("div",{...t,style:{...t.style,backgroundColor:ye}},e)),v&&re&&!b&&!Fe&&qe.map(({key:e,...t})=>(null==$?void 0:$.component)?$.component({key:e,...t,backgroundColor:xe}):n.jsx("div",{...t,style:{...t.style,backgroundColor:xe}},e))]})]}),I&&!b&&!Fe&&n.jsx(c.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:a},selected:v,placement:{suggestTop:ce&&t>90&&t<270}})}}),(Fe||J)&&Q&&i.createPortal(n.jsxs("div",{style:{position:"fixed",left:Q.x+16,top:Q.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[Oe.toFixed(0),"°"]}),document.body)]})}function 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 w(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 C({documentId:e,pageIndex:t,scale:a,rotation:l,pageWidth:d,pageHeight:u,selectedAnnotations:p,isDraggable:h,isResizable:g,isRotatable:v=!0,lockAspectRatio:y=!1,resizeUI:x,rotationUI:b,selectionOutlineColor:m,outlineOffset:k,selectionOutline:j,zIndex:S=2,groupSelectionMenu:C}){var A,P,I;const{plugin:R}=f(),{canModifyAnnotations:z}=r.useDocumentPermissions(e),D=o.useRef(null),E=o.useRef(!1),M=o.useRef(!1),[L,$]=o.useState(null),[O,F]=o.useState(null),[W,B]=o.useState(!1),U=z&&h,T=z&&g,H=z&&v,N=o.useMemo(()=>{const e=p.map(e=>e.object.rect);return s.boundingRectOrEmpty(e)},[p]),[G,q]=o.useState(N);o.useEffect(()=>{E.current||M.current||q(N)},[N]),o.useEffect(()=>{if(!R)return;return R.onRotateChange(t=>{t.documentId===e&&("end"!==t.type&&"cancel"!==t.type||$(null))})},[R,e]);const Y=o.useCallback(t=>{var n,o,i,r,s,a;if(!(null==(n=t.transformData)?void 0:n.type))return;if(!R)return;const l=t.transformData.type,c="move"===l,h="resize"===l;if(c&&!U)return;if("start"===t.state&&(D.current=N,c?(E.current=!0,R.startDrag(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:d,height:u}})):h&&(M.current=!0,R.startResize(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:d,height:u},resizeHandle:(null==(o=t.transformData.metadata)?void 0:o.handle)??"se"}))),"rotate"===l){if(!v)return;const n=p.map(e=>e.object.id),o=(null==(i=t.transformData.metadata)?void 0:i.rotationAngle)??0,l=null==(r=t.transformData.metadata)?void 0:r.cursorPosition;return l&&F({x:l.clientX,y:l.clientY}),void("start"===t.state?($(o),R.startRotation(e,{annotationIds:n,cursorAngle:o,rotationCenter:null==(s=t.transformData.metadata)?void 0:s.rotationCenter})):"move"===t.state?($(o),R.updateRotation(e,o,null==(a=t.transformData.metadata)?void 0:a.rotationDelta)):"end"===t.state&&($(null),F(null),R.commitRotation(e)))}const g=D.current??N;if(c&&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=R.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;R.updateResize(e,n),q(n)}"end"===t.state&&(D.current=null,c&&E.current?(E.current=!1,R.commitDrag(e)):h&&M.current&&(M.current=!1,R.commitResize(e)))},[R,e,d,u,N,U,p,v]),K=L??0,V=null!==L,X=Number.isFinite(K)?Math.round(10*K)/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}=c.useInteractionHandles({controller:{element:G,constraints:{minWidth:20,minHeight:20,boundingBox:{width:d,height:u}},maintainAspectRatio:y,pageRotation:l,scale:a,enabled:!0,onUpdate:Y},resizeUI:{handleSize:Q,spacing:de,offsetMode:"outside",includeSides:!y,zIndex:S+1},vertexUI:{vertexSize:0,zIndex:S},rotationUI:{handleSize:ee,margin:te,zIndex:S+2,showConnector:oe},includeVertices:!1,includeRotation:H,currentRotation:L??0});if(p.length<2)return null;let ge=1/0,ve=1/0,fe=-1/0,ye=-1/0;for(const n of p){const e=w(n,a,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*a,be=ve-N.origin.y*a,me=fe-(N.origin.x+N.size.width)*a,ke=ye-(N.origin.y+N.size.height)*a,je=G.origin.x*a+xe,Se=G.origin.y*a+be,we=G.size.width*a+(me-xe),Ce=G.size.height*a+(ke-be),Ae=we/2,Pe=Ce/2,Ie=Math.max(300,Math.max(we,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:Se,width:we,height:Ce,pointerEvents:"none",zIndex:S},children:[V&&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(${K}deg)`,backgroundColor:Z,opacity:.8,pointerEvents:"none"}})]}),H&&he&&((null==b?void 0:b.component)?n.jsx("div",{onPointerEnter:()=>B(!0),onPointerLeave:()=>{B(!1),F(null)},onPointerMove:e=>{V||F({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:b.component({...he.handle,backgroundColor:_,iconColor:ne,connectorStyle:{...he.connector.style,backgroundColor:J,opacity:V?0:1},showConnector:oe,opacity:V?0:1,border:{color:ie,width:re,style:se}})}):n.jsxs("div",{onPointerEnter:()=>B(!0),onPointerLeave:()=>{B(!1),F(null)},onPointerMove:e=>{V||F({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[oe&&n.jsx("div",{style:{...he.connector.style,backgroundColor:J,opacity:V?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:V?0:1},children:n.jsxs("svg",{width:Math.round(.6*ee),height:Math.round(.6*ee),viewBox:"0 0 24 24",fill:"none",stroke:ne,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),n.jsx("path",{d:"M21 3v5h-5"})]})})]})),n.jsx("div",{...U?ue:{onPointerDown:e=>e.stopPropagation()},style:{position:"absolute",left:0,top:0,width:we,height:Ce,outline:V?"none":`${ce}px ${le} ${ae}`,outlineOffset:de-1,cursor:U?"move":"default",touchAction:"none",pointerEvents:"auto"},children:T&&!V&&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))})]}),(V||W)&&O&&i.createPortal(n.jsxs("div",{style:{position:"fixed",left:O.x+16,top:O.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[X.toFixed(0),"°"]}),document.body),C&&!V&&n.jsx(c.CounterRotate,{rect:{origin:{x:je,y:Se},size:{width:we,height:Ce}},rotation:l,children:e=>{const n=((K+90*l)%360+360)%360;return C({...e,context:{type:"group",annotations:p,pageIndex:t},selected:!0,placement:{suggestTop:H&&n>90&&n<270}})}})]})}function A(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 P({isSelected:e,strokeColor:t,opacity:i=1,strokeWidth:r,inkList:s,rect:a,scale:l,onClick:c,appearanceActive:d=!1}){const u=t??"#000000",p=o.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:i,style:{pointerEvents:"none",stroke:u,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}},`vis-${t}`))]})}function I({isSelected:e,color:i="#000000",strokeColor:r,opacity:a=1,strokeWidth:l,strokeStyle:c=s.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}=o.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=o.useMemo(()=>y?t.generateCloudyRectanglePath({x:0,y:0,width:u.size.width,height:u.size.height},f,v,l):null,[y,u,f,v,l]),S=u.size.width*p,w=u.size.height*p,C=Math.max(l,20/p);return n.jsxs("svg",{style:{position:"absolute",width:S,height:w,pointerEvents:"none",zIndex:2},width:S,height:w,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"===i?"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"===i?"visibleStroke":"visible":"none"}}),!g&&(y&&j?n.jsx("path",{d:j.path,fill:i,opacity:a,style:{pointerEvents:"none",stroke:r??i,strokeWidth:l,strokeLinejoin:"round"}}):n.jsx("rect",{x:m,y:k,width:x,height:b,fill:i,opacity:a,style:{pointerEvents:"none",stroke:r??i,strokeWidth:l,...c===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}))]})}function R({color:e="#000000",strokeColor:i,opacity:r=1,strokeWidth:a,strokeStyle:l=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:p,isSelected:h,appearanceActive:g=!1,cloudyBorderIntensity:v,rectangleDifferences:f}){const y=(v??0)>0,{width:x,height:b,cx:m,cy:k,rx:j,ry:S}=o.useMemo(()=>{const e=d.size.width,t=d.size.height,n=Math.max(e-a,0),o=Math.max(t-a,0);return{width:e,height:t,cx:a/2+n/2,cy:a/2+o/2,rx:n/2,ry:o/2}},[d,a]),w=o.useMemo(()=>y?t.generateCloudyEllipsePath({x:0,y:0,width:d.size.width,height:d.size.height},f,v,a):null,[y,d,f,v,a]),C=x*u,A=b*u,P=Math.max(a,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&&w?n.jsx("path",{d:w.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:S,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&&w?n.jsx("path",{d:w.path,fill:e,opacity:r,style:{pointerEvents:"none",stroke:i??e,strokeWidth:a,strokeLinejoin:"round"}}):n.jsx("ellipse",{cx:m,cy:k,rx:j,ry:S,fill:e,opacity:r,style:{pointerEvents:"none",stroke:i??e,strokeWidth:a,...l===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}))]})}function z({color:e="transparent",opacity:i=1,strokeWidth:r,strokeColor:a="#000000",strokeStyle:l=s.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}=o.useMemo(()=>({x1:u.start.x-d.origin.x,y1:u.start.y-d.origin.y,x2:u.end.x-d.origin.x,y2:u.end.y-d.origin.y}),[u,d]),k=o.useMemo(()=>{const e=Math.atan2(m-x,b-y);return{start:t.patching.createEnding(null==p?void 0:p.start,r,e+Math.PI,y,x),end:t.patching.createEnding(null==p?void 0:p.end,r,e,b,m)}},[p,r,y,x,b,m]),j=d.size.width*h,S=d.size.height*h,w=Math.max(r,20/h);return n.jsxs("svg",{style:{position:"absolute",width:j,height:S,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:S,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[n.jsx("line",{x1:y,y1:x,x2:b,y2:m,stroke:"transparent",strokeWidth:w,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:w,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:w,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:i,style:{pointerEvents:"none",stroke:a,strokeWidth:r,strokeLinecap:"butt",...l===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),k.start&&n.jsx("path",{d:k.start.d,transform:k.start.transform,stroke:a,fill:k.start.filled?e:"none",style:{pointerEvents:"none",strokeWidth:r,strokeLinecap:"butt",...l===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),k.end&&n.jsx("path",{d:k.end.d,transform:k.end.transform,stroke:a,fill:k.end.filled?e:"none",style:{pointerEvents:"none",strokeWidth:r,strokeLinecap:"butt",...l===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})]})]})}function D({rect:e,vertices:i,color:r="transparent",strokeColor:a="#000000",opacity:l=1,strokeWidth:c,strokeStyle:d=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:u,scale:p,isSelected:h,onClick:g,lineEndings:v,appearanceActive:f=!1}){const y=o.useMemo(()=>i.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[i,e]),x=o.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=o.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:a??r,strokeWidth:c,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...d===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),b.start&&n.jsx("path",{d:b.start.d,transform:b.start.transform,stroke:a,fill:b.start.filled?r:"none",style:{pointerEvents:"none",strokeWidth:c,strokeLinecap:"butt",...d===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),b.end&&n.jsx("path",{d:b.end.d,transform:b.end.transform,stroke:a,fill:b.end.filled?r:"none",style:{pointerEvents:"none",strokeWidth:c,strokeLinecap:"butt",...d===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}})]})]})}function E({rect:e,vertices:i,color:r="transparent",strokeColor:a="#000000",opacity:l=1,strokeWidth:c,strokeStyle:d=s.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?[...i,v]:i,k=o.useMemo(()=>m.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[m,e]),j=o.useMemo(()=>{if(!k.length)return"";const[e,...t]=k,n=!!v;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(n?"":" Z")).trim()},[k,v]),S=o.useMemo(()=>!b||m.length<3?null:t.generateCloudyPolygonPath(m,e.origin,x,c),[b,m,e.origin,x,c]),w=v&&i.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&&S?S.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&&S?n.jsx("path",{d:S.path,opacity:l,style:{fill:r,stroke:a??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:a??r,strokeWidth:c,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...d===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),w&&i.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:a,strokeWidth:c,strokeDasharray:"4,4",opacity:.7,pointerEvents:"none"}}),w&&i.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:a,opacity:.4,stroke:a,strokeWidth:c/2,style:{pointerEvents:"none"}})]})})]})}function M({isSelected:e,color:t="#facc15",opacity:o=1,onClick:i,appearanceActive:r=!1}){const a=s.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:a,strokeWidth:"1",strokeLinejoin:"miter"}),n.jsx("line",{x1:"2.5",y1:"4.25",x2:"17.5",y2:"4.25",stroke:a,strokeWidth:"1"}),n.jsx("line",{x1:"2.5",y1:"8",x2:"17.5",y2:"8",stroke:a,strokeWidth:"1"}),n.jsx("line",{x1:"2.5",y1:"11.75",x2:"17.5",y2:"11.75",stroke:a,strokeWidth:"1"})]})})}function L({documentId:e,isSelected:t,isEditing:i,annotation:r,pageIndex:a,scale:l,onClick:c,appearanceActive:d=!1}){const p=o.useRef(null),h=o.useRef(!1),{provides:g}=y(),v=(null==g?void 0:g.forDocument(e))??null,{adjustedFontPx:f,wrapperStyle:x}=m(r.object.fontSize*l,i);o.useEffect(()=>{var e;if(i&&p.current){h.current=!0;const t=p.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)}}},[i]);return n.jsx("div",{style:{position:"absolute",width:r.object.rect.size.width*l,height:r.object.rect.size.height*l,cursor:t&&!i?"move":"default",pointerEvents:c?t&&!i?"none":"auto":"none",zIndex:2,opacity:d?0:1},onPointerDown:c,children:n.jsx("span",{ref:p,onBlur:()=>{h.current&&(h.current=!1,v&&p.current&&v.updateAnnotation(a,r.object.id,{contents:p.current.innerText.replace(/\u00A0/g," ")}))},tabIndex:0,style:{color:r.object.fontColor,fontSize:f,...s.standardFontCssProperties(r.object.fontFamily),textAlign:s.textAlignmentToCss(r.object.textAlign),flexDirection:"column",justifyContent:r.object.verticalAlign===s.PdfVerticalAlignment.Top?"flex-start":r.object.verticalAlign===s.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:i?"text":c?"pointer":"default",outline:"none",...x},contentEditable:i,...u,children:r.object.contents})})}function $({documentId:e,pageIndex:t,annotation:i,scaleFactor:r=1,unrotated:a,style:l,...c}){const{provides:d}=y(),[u,p]=o.useState(null),h=o.useRef(null),{width:g,height:v}=i.rect.size;o.useEffect(()=>{if(d){const n=d.forDocument(e).renderAnnotation({pageIndex:t,annotation:i,options:{scaleFactor:r,dpr:window.devicePixelRatio,unrotated:a}});return n.wait(e=>{const t=URL.createObjectURL(e);p(t),h.current=t},s.ignore),()=>{h.current?(URL.revokeObjectURL(h.current),h.current=null):n.abort({code:s.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,r,a,d,e,i.id,g,v]);return n.jsx(o.Fragment,{children:u&&n.jsx("img",{src:u,onLoad:()=>{h.current&&(URL.revokeObjectURL(h.current),h.current=null)},...c,style:{width:"100%",height:"100%",display:"block",...l||{}}})})}function O({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($,{documentId:o,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:r,unrotated:a})})}function F({isSelected:e,strokeColor:t="#0000FF",strokeWidth:i=2,strokeStyle:r=s.PdfAnnotationBorderStyle.UNDERLINE,strokeDashArray:a,rect:l,scale:c,onClick:d,hasIRT:u=!1}){const{width:p,height:h}=o.useMemo(()=>({width:l.size.width,height:l.size.height}),[l]),g=p*c,v=h*c,f=o.useMemo(()=>{if(r===s.PdfAnnotationBorderStyle.DASHED)return(null==a?void 0:a.join(","))??`${3*i},${i}`},[r,a,i]),y=r===s.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:i,strokeDasharray:f,style:{pointerEvents:"none"}}):n.jsx("rect",{x:i/2,y:i/2,width:Math.max(p-i,0),height:Math.max(h-i,0),fill:"transparent",stroke:t,strokeWidth:i,strokeDasharray:f,style:{pointerEvents:"none"}})]})}function W({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 B({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00",d=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:d,background:c,opacity:t,pointerEvents:"none"}})},o))})}function U({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00",d=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:d,background:c,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},o))})}function T({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=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 H({isSelected:e,strokeColor:t="#000000",opacity:i=1,rect:r,scale:s,onClick:a,appearanceActive:l=!1}){const{width:c,height:d,path:u}=o.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:i,fillRule:"evenodd",style:{pointerEvents:"none"}})]})}function N({annotation:e,documentId:t}){const{provides:i}=y(),r=o.useCallback(()=>{const n=e.object.target;n&&i&&i.forDocument(t).navigateTarget(n)},[e.object.target,i,t]);return n.jsx("div",{onClick:r,style:{width:"100%",height:"100%",cursor:"pointer",pointerEvents:"auto"}})}const G=[A({id:"ink",matches:e=>e.type===s.PdfAnnotationSubtype.INK,matchesPreview:e=>e.type===s.PdfAnnotationSubtype.INK,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(P,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),renderPreview:({data:e,scale:t})=>n.jsx(P,{isSelected:!1,scale:t,...e}),previewContainerStyle:({data:e})=>({mixBlendMode:s.blendModeToCss(e.blendMode??s.PdfBlendMode.Normal)}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),A({id:"square",matches:e=>e.type===s.PdfAnnotationSubtype.SQUARE,matchesPreview:e=>e.type===s.PdfAnnotationSubtype.SQUARE,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}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),A({id:"circle",matches:e=>e.type===s.PdfAnnotationSubtype.CIRCLE,matchesPreview:e=>e.type===s.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}}),A({id:"line",matches:e=>e.type===s.PdfAnnotationSubtype.LINE,matchesPreview:e=>e.type===s.PdfAnnotationSubtype.LINE,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(z,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),renderPreview:({data:e,scale:t})=>n.jsx(z,{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}}),A({id:"polyline",matches:e=>e.type===s.PdfAnnotationSubtype.POLYLINE,matchesPreview:e=>e.type===s.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}}),A({id:"polygon",matches:e=>e.type===s.PdfAnnotationSubtype.POLYGON,matchesPreview:e=>e.type===s.PdfAnnotationSubtype.POLYGON,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.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),A({id:"highlight",matches:e=>e.type===s.PdfAnnotationSubtype.HIGHLIGHT,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(W,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},defaultBlendMode:s.PdfBlendMode.Multiply}),A({id:"underline",matches:e=>e.type===s.PdfAnnotationSubtype.UNDERLINE,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(B,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),A({id:"strikeout",matches:e=>e.type===s.PdfAnnotationSubtype.STRIKEOUT,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}}),A({id:"squiggly",matches:e=>e.type===s.PdfAnnotationSubtype.SQUIGGLY,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(T,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),A({id:"text",matches:e=>e.type===s.PdfAnnotationSubtype.TEXT&&!e.inReplyToId,render:({currentObject:e,isSelected:t,onClick:o,appearanceActive:i})=>n.jsx(M,{isSelected:t,color:e.strokeColor??e.color,opacity:e.opacity,onClick:o,appearanceActive:i}),interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!1}}),A({id:"caret",matches:e=>e.type===s.PdfAnnotationSubtype.CARET,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(H,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),A({id:"freeText",matches:e=>e.type===s.PdfAnnotationSubtype.FREETEXT,matchesPreview:e=>e.type===s.PdfAnnotationSubtype.FREETEXT,render:({annotation:e,currentObject:t,isSelected:o,isEditing:i,scale:r,pageIndex:s,documentId:a,onClick:l,appearanceActive:c})=>n.jsx(L,{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)}),A({id:"stamp",matches:e=>e.type===s.PdfAnnotationSubtype.STAMP,render:({annotation:e,isSelected:t,documentId:o,pageIndex:i,scale:r,onClick:s})=>n.jsx(O,{isSelected:t,annotation:e,documentId:o,pageIndex:i,scale:r,onClick:s}),useAppearanceStream:!1,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),A({id:"link",matches:e=>e.type===s.PdfAnnotationSubtype.LINK,matchesPreview:e=>e.type===s.PdfAnnotationSubtype.LINK,render:({currentObject:e,isSelected:t,scale:o,onClick:i})=>n.jsx(F,{...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(N,{...e})})];function q(e){const{documentId:i,pageIndex:r,scale:c,pageWidth:d,pageHeight:u,selectionMenu:p}=e,{provides:h}=y(),{provides:g}=l.useSelectionCapability(),[v,f]=o.useState([]),{register:x}=a.usePointerHandlers({documentId:i,pageIndex:r}),[b,m]=o.useState([]),[k,S]=o.useState(null),[w,A]=o.useState({}),[P,I]=o.useState({type:t.LockModeType.None}),R=o.useRef(c),z=o.useMemo(()=>h?h.forDocument(i):null,[h,i]),D=b.length>1;o.useEffect(()=>{if(z){const e=z.getState();return f(t.getAnnotationsByPageIndex(e,r)),m(t.getSelectedAnnotationIds(e)),I(e.locked),z.onStateChange(e=>{f(t.getAnnotationsByPageIndex(e,r)),m(t.getSelectedAnnotationIds(e)),I(e.locked)})}},[z,r]),o.useEffect(()=>{if(z)return z.onAnnotationEvent(e=>{"create"===e.type&&e.editAfterCreate&&S(e.annotation.id)})},[z]),o.useEffect(()=>{if(!z)return;R.current!==c&&(z.invalidatePageAppearances(r),R.current=c);z.getPageAppearances(r,{scaleFactor:c,dpr:"undefined"!=typeof window?window.devicePixelRatio:1}).wait(e=>A(e),()=>A({}))},[z,r,c]);const E=o.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&z&&(k&&v.some(e=>e.object.id===k)&&t.stopImmediatePropagation(),z.deselectAnnotation(),S(null))}}),[z,k,v]),M=o.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&&S(null)}},[z,g,k,r]);o.useEffect(()=>x(E,{documentId:i}),[x,E]);const L=o.useMemo(()=>v.filter(e=>b.includes(e.object.id)),[v,b]),$=o.useMemo(()=>!(L.length<2)&&L.every(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupDraggable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isDraggable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupDraggable)?o:i}),[L,z]),O=o.useMemo(()=>!(L.length<2)&&L.every(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupResizable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isResizable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupResizable)?o:i}),[L,z]),F=o.useMemo(()=>!(L.length<2)&&L.every(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupRotatable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isRotatable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupRotatable)?o:i}),[L,z]),W=o.useMemo(()=>!(L.length<2)&&L.some(e=>{const n=null==z?void 0:z.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.lockGroupAspectRatio,e.object,!1),i=t.resolveInteractionProp(null==n?void 0:n.interaction.lockAspectRatio,e.object,!1);return void 0!==(null==n?void 0:n.interaction.lockGroupAspectRatio)?o:i}),[L,z]),B=o.useMemo(()=>{if(!z)return!1;const e=z.getSelectedAnnotations();return e.length>1&&e.every(e=>e.object.pageIndex===r)},[z,r,b]),U=o.useCallback(e=>{if(e.dictMode)return null;if(e.object.rotation&&e.object.unrotatedRect)return null;const t=w[e.object.id];return(null==t?void 0:t.normal)?t:null},[w]),T=o.useMemo(()=>{const t=e.annotationRenderers??[],n=new Set(t.map(e=>e.id));return[...t,...G.filter(e=>!n.has(e.id))]},[e.annotationRenderers]),H=o.useCallback(e=>T.find(t=>t.matches(e.object))??null,[T]),N=o.useMemo(()=>({defaultSelect:M,selectAnnotation:(e,t)=>null==z?void 0:z.selectAnnotation(e,t),clearSelection:()=>null==g?void 0:g.clear(),allAnnotations:v,pageIndex:r}),[M,z,g,v,r]);return n.jsxs(n.Fragment,{children:[v.map(o=>{var a,l,d;const u=H(o);if(!u)return null;const h=(null==z?void 0:z.findToolForAnnotation(o.object))??null,g=t.getAnnotationCategories(h),v=t.hasLockedFlag(o.object)||t.isCategoryLocked(g,P);if(v&&u.hiddenWhenLocked)return null;const f=v&&!!u.renderLocked,y=!v&&b.includes(o.object.id),x=!v&&k===o.object.id,m=u.interactionDefaults,w=t.resolveInteractionProp(null==h?void 0:h.interaction.isDraggable,o.object,(null==m?void 0:m.isDraggable)??!0),C=!v&&(u.isDraggable?u.isDraggable(w,{isEditing:x}):w),A=(null==(a=null==h?void 0:h.behavior)?void 0:a.useAppearanceStream)??u.useAppearanceStream??!0,I=f?void 0:A?U(o):void 0,R=v?e=>{e.stopPropagation()}:u.selectOverride?e=>u.selectOverride(e,o,N):e=>M(e,o);return n.jsx(j,{trackedAnnotation:o,isSelected:y,isEditing:x,isMultiSelected:!v&&D,isDraggable:C,isResizable:!v&&t.resolveInteractionProp(null==h?void 0:h.interaction.isResizable,o.object,(null==m?void 0:m.isResizable)??!1),lockAspectRatio:t.resolveInteractionProp(null==h?void 0:h.interaction.lockAspectRatio,o.object,(null==m?void 0:m.lockAspectRatio)??!1),isRotatable:!v&&t.resolveInteractionProp(null==h?void 0:h.interaction.isRotatable,o.object,(null==m?void 0:m.isRotatable)??!1),vertexConfig:v?void 0:u.vertexConfig,selectionMenu:v||(null==(l=u.hideSelectionMenu)?void 0:l.call(u,o.object))?void 0:p,onSelect:R,onDoubleClick:v?void 0:u.onDoubleClick?e=>{e.stopPropagation(),u.onDoubleClick(o.object.id,S)}:void 0,zIndex:u.zIndex,blendMode:s.blendModeToCss(o.object.blendMode??u.defaultBlendMode??s.PdfBlendMode.Normal),style:null==(d=u.containerStyle)?void 0:d.call(u,o.object),appearance:I,...e,children:(e,{appearanceActive:t})=>f?u.renderLocked({annotation:o,currentObject:e,isSelected:!1,isEditing:!1,scale:c,pageIndex:r,documentId:i,onClick:void 0,appearanceActive:t}):u.render({annotation:o,currentObject:e,isSelected:y,isEditing:x,scale:c,pageIndex:r,documentId:i,onClick:v?void 0:R,appearanceActive:t})},o.object.id)}),B&&L.length>=2&&n.jsx(C,{documentId:i,pageIndex:r,scale:c,rotation:e.rotation,pageWidth:d,pageHeight:u,selectedAnnotations:L,isDraggable:$,isResizable:O,isRotatable:F,lockAspectRatio:W,resizeUI:e.resizeUI,rotationUI:e.rotationUI,selectionOutlineColor:e.selectionOutlineColor,selectionOutline:e.groupSelectionOutline??e.selectionOutline,groupSelectionMenu:e.groupSelectionMenu})]})}function Y({documentId:e,pageIndex:t,scale:i}){var r,a,c,d,u,p,h,g,v,f,x,b;const{provides:m}=l.useSelectionCapability(),{provides:k}=y(),[j,S]=o.useState([]),[w,C]=o.useState(null),[A,P]=o.useState(null);if(o.useEffect(()=>{if(m)return m.forDocument(e).onSelectionChange(()=>{S(m.forDocument(e).getHighlightRectsForPage(t)),C(m.forDocument(e).getBoundingRectForPage(t))})},[m,e,t]),o.useEffect(()=>{if(k)return P(k.forDocument(e).getActiveTool()),k.forDocument(e).onActiveToolChange(e=>P(e))},[k,e]),!w)return null;if(!A||!A.defaults)return null;switch(A.defaults.type){case s.PdfAnnotationSubtype.UNDERLINE:return n.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(r=A.defaults)?void 0:r.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(B,{strokeColor:null==(a=A.defaults)?void 0:a.strokeColor,opacity:null==(c=A.defaults)?void 0:c.opacity,segmentRects:j,scale:i})});case s.PdfAnnotationSubtype.HIGHLIGHT:return n.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(d=A.defaults)?void 0:d.blendMode)??s.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(W,{strokeColor:null==(u=A.defaults)?void 0:u.strokeColor,opacity:null==(p=A.defaults)?void 0:p.opacity,segmentRects:j,scale:i})});case s.PdfAnnotationSubtype.STRIKEOUT:return n.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(h=A.defaults)?void 0:h.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(U,{strokeColor:null==(g=A.defaults)?void 0:g.strokeColor,opacity:null==(v=A.defaults)?void 0:v.opacity,segmentRects:j,scale:i})});case s.PdfAnnotationSubtype.SQUIGGLY:return n.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(f=A.defaults)?void 0:f.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(T,{strokeColor:null==(x=A.defaults)?void 0:x.strokeColor,opacity:null==(b=A.defaults)?void 0:b.opacity,segmentRects:j,scale:i})});case s.PdfAnnotationSubtype.CARET:default:return null}}function K({toolId:e,preview:t,scale:i}){var r;const{bounds:s}=t,a=v(),l=o.useMemo(()=>{const e=new Set(a.map(e=>e.id));return[...a,...G.filter(t=>!e.has(t.id))]},[a]),c={position:"absolute",left:s.origin.x*i,top:s.origin.y*i,width:s.size.width*i,height:s.size.height*i,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:i});return n.jsx("div",{style:{...c,...e},children:d.renderPreview({data:t.data,bounds:t.bounds,scale:i})})}return null}function V({documentId:e,pageIndex:t,scale:i}){const{plugin:r}=f(),[s,a]=o.useState(new Map),l=o.useRef(null),c=o.useRef(null),d=o.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!l.current)return;const n=l.current;n.accept=e,n.onchange=e=>{var o;const i=null==(o=e.target.files)?void 0:o[0];i&&(t(i),n.value="")},n.click()},processImage:({source:e,maxWidth:t,maxHeight:n,onComplete:o})=>{const i=c.current;if(!i||!i.getContext)return;const r=i.getContext("2d");if(!r)return;const s=new Image;s.crossOrigin="Anonymous",s.onload=()=>{let{naturalWidth:a,naturalHeight:l}=s;const c=t?t/a:1,d=n?n/l:1,u=Math.min(c,d,1),p=a*u,h=l*u;i.width=p,i.height=h,r.drawImage(s,0,0,p,h);const g=r.getImageData(0,0,p,h);"string"!=typeof e&&URL.revokeObjectURL(s.src),o({imageData:g,width:p,height:h})},s.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return o.useEffect(()=>{if(r)return r.registerPageHandlers(e,t,i,{services:d,onPreview:(e,t)=>{a(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,i,r,d]),n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:l,type:"file",style:{display:"none"}}),n.jsx("canvas",{ref:c,style:{display:"none"}}),Array.from(s.entries()).map(([e,t])=>n.jsx(K,{toolId:e,preview:t,scale:i},e))]})}const X=e.createPluginPackage(t.AnnotationPluginPackage).addWrapper(g).addUtility(function(){const{plugin:e}=f(),{provides:t}=y();return o.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:i,scale:s,rotation:a,selectionMenu:l,groupSelectionMenu:c,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:f,customAnnotationRenderer:y,annotationRenderers:x,...b}){var m,k,j,S;const w=r.useDocumentState(t),C=null==(k=null==(m=null==w?void 0:w.document)?void 0:m.pages)?void 0:k[i],A=(null==(j=null==C?void 0:C.size)?void 0:j.width)??0,P=(null==(S=null==C?void 0:C.size)?void 0:S.height)??0,I=v(),R=o.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]),z=o.useMemo(()=>void 0!==s?s:(null==w?void 0:w.scale)??1,[s,null==w?void 0:w.scale]),D=o.useMemo(()=>{if(void 0!==a)return a;return(((null==C?void 0:C.rotation)??0)+((null==w?void 0:w.rotation)??0))%4},[a,null==C?void 0:C.rotation,null==w?void 0:w.rotation]);return n.jsxs("div",{style:{...e},...b,children:[n.jsx(q,{documentId:t,selectionMenu:l,groupSelectionMenu:c,pageIndex:i,scale:z,rotation:D,pageWidth:A,pageHeight:P,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:f,customAnnotationRenderer:y,annotationRenderers:R}),n.jsx(Y,{documentId:t,pageIndex:i,scale:z}),n.jsx(V,{documentId:t,pageIndex:i,scale:z})]})},exports.AnnotationPluginPackage=X,exports.AnnotationRendererProvider=g,exports.GroupSelectionBox=C,exports.createRenderer=A,exports.useAnnotation=e=>{var n;const{provides:i}=y(),[r,s]=o.useState((null==(n=null==i?void 0:i.forDocument(e))?void 0:n.getState())??t.initialDocumentState());return o.useEffect(()=>{if(!i)return;const t=i.forDocument(e);return s(t.getState()),t.onStateChange(e=>{s(e)})},[i,e]),{state:r,provides:(null==i?void 0:i.forDocument(e))??null}},exports.useAnnotationCapability=y,exports.useAnnotationPlugin=f,exports.useIOSZoomPrevention=m,exports.useRegisterRenderers=function(e){const t=o.useContext(p),n=o.useRef(e);o.useEffect(()=>{if(t)return t(n.current)},[t])},exports.useRegisteredRenderers=v,exports.useRendererRegistry=function(){return o.useContext(p)},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
|